summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorxjm <xjm@65776.no-reply.drupal.org>2017-03-03 19:20:24 -0600
committerxjm <xjm@65776.no-reply.drupal.org>2017-03-03 19:20:24 -0600
commit52e3eec616efab4d5201e30d085a09ba5c4817e6 (patch)
treed295cc8b862edc04018ba0e04ded752fd1a2f5c6
parent3aba956a39a4852f42cad8483e4e6e307bedbd0e (diff)
downloaddrupal-52e3eec616efab4d5201e30d085a09ba5c4817e6.tar.gz
drupal-52e3eec616efab4d5201e30d085a09ba5c4817e6.zip
Issue #2776975 by joelpittet, dawehner, tim.plunkett, xjm, pfrenssen: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase
-rw-r--r--core/authorize.php12
-rw-r--r--core/core.api.php16
-rw-r--r--core/includes/batch.inc56
-rw-r--r--core/includes/bootstrap.inc24
-rw-r--r--core/includes/common.inc34
-rw-r--r--core/includes/database.inc26
-rw-r--r--core/includes/entity.inc12
-rw-r--r--core/includes/errors.inc50
-rw-r--r--core/includes/file.inc48
-rw-r--r--core/includes/form.inc70
-rw-r--r--core/includes/install.core.inc348
-rw-r--r--core/includes/install.inc78
-rw-r--r--core/includes/menu.inc34
-rw-r--r--core/includes/module.inc20
-rw-r--r--core/includes/pager.inc30
-rw-r--r--core/includes/schema.inc14
-rw-r--r--core/includes/tablesort.inc22
-rw-r--r--core/includes/theme.inc396
-rw-r--r--core/includes/unicode.inc16
-rw-r--r--core/includes/update.inc56
-rw-r--r--core/lib/Drupal.php2
-rw-r--r--core/lib/Drupal/Component/Annotation/Plugin.php2
-rw-r--r--core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php4
-rw-r--r--core/lib/Drupal/Component/Annotation/PluginID.php4
-rw-r--r--core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php2
-rw-r--r--core/lib/Drupal/Component/Datetime/DateTimePlus.php32
-rw-r--r--core/lib/Drupal/Component/DependencyInjection/Container.php36
-rw-r--r--core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php44
-rw-r--r--core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php2
-rw-r--r--core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php20
-rw-r--r--core/lib/Drupal/Component/Diff/Diff.php6
-rw-r--r--core/lib/Drupal/Component/Diff/DiffFormatter.php12
-rw-r--r--core/lib/Drupal/Component/Diff/Engine/DiffEngine.php28
-rw-r--r--core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php2
-rw-r--r--core/lib/Drupal/Component/Diff/WordLevelDiff.php6
-rw-r--r--core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php2
-rw-r--r--core/lib/Drupal/Component/Discovery/YamlDiscovery.php6
-rw-r--r--core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php10
-rw-r--r--core/lib/Drupal/Component/FileSystem/FileSystem.php2
-rw-r--r--core/lib/Drupal/Component/Gettext/PoHeader.php20
-rw-r--r--core/lib/Drupal/Component/Gettext/PoItem.php2
-rw-r--r--core/lib/Drupal/Component/Gettext/PoMemoryWriter.php2
-rw-r--r--core/lib/Drupal/Component/Gettext/PoStreamReader.php20
-rw-r--r--core/lib/Drupal/Component/Graph/Graph.php12
-rw-r--r--core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php2
-rw-r--r--core/lib/Drupal/Component/PhpStorage/FileStorage.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/Context/Context.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php4
-rw-r--r--core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php10
-rw-r--r--core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php4
-rw-r--r--core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php2
-rw-r--r--core/lib/Drupal/Component/Plugin/LazyPluginCollection.php6
-rw-r--r--core/lib/Drupal/Component/Plugin/PluginManagerBase.php2
-rw-r--r--core/lib/Drupal/Component/Transliteration/PhpTransliteration.php12
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/de.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/dk.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/eo.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/kg.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x00.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x01.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x02.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x03.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x04.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x05.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x06.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x07.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x09.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x0a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x0b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x0c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x0d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x0e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x0f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x10.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x11.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x12.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x13.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x14.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x15.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x16.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x17.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x18.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x1d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x1e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x1f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x20.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x21.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x22.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x23.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x24.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x25.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x26.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x27.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x28.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x29.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x2a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x2e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x2f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x30.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x31.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x32.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x33.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x34.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x35.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x36.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x37.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x38.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x39.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x3a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x3b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x3c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x3d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x3e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x3f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x40.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x41.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x42.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x43.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x44.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x45.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x46.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x47.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x48.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x49.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x4a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x4b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x4c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x4d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x4e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x4f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x50.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x51.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x52.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x53.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x54.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x55.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x56.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x57.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x58.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x59.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x5a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x5b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x5c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x5d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x5e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x5f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x60.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x61.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x62.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x63.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x64.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x65.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x66.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x67.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x68.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x69.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x6a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x6b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x6c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x6d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x6e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x6f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x70.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x71.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x72.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x73.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x74.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x75.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x76.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x77.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x78.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x79.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x7a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x7b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x7c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x7d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x7e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x7f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x80.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x81.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x82.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x83.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x84.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x85.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x86.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x87.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x88.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x89.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x8a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x8b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x8c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x8d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x8e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x8f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x90.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x91.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x92.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x93.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x94.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x95.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x96.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x97.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x98.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x99.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x9a.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x9b.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x9c.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x9d.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x9e.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/x9f.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xa0.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xa1.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xa2.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xa3.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xa4.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xac.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xad.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xae.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xaf.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb0.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb1.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb2.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb3.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb4.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb5.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb6.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb7.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb8.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xb9.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xba.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xbb.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xbc.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xbd.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xbe.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xbf.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc0.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc1.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc2.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc3.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc4.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc5.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc6.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc7.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc8.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xc9.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xca.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xcb.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xcc.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xcd.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xce.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xcf.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd0.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd1.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd2.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd3.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd4.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd5.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd6.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xd7.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xf9.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xfa.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xfb.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xfc.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xfd.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xfe.php4
-rw-r--r--core/lib/Drupal/Component/Transliteration/data/xff.php4
-rw-r--r--core/lib/Drupal/Component/Utility/ArgumentsResolver.php2
-rw-r--r--core/lib/Drupal/Component/Utility/Color.php4
-rw-r--r--core/lib/Drupal/Component/Utility/DiffArray.php2
-rw-r--r--core/lib/Drupal/Component/Utility/Html.php14
-rw-r--r--core/lib/Drupal/Component/Utility/NestedArray.php6
-rw-r--r--core/lib/Drupal/Component/Utility/Random.php14
-rw-r--r--core/lib/Drupal/Component/Utility/Tags.php4
-rw-r--r--core/lib/Drupal/Component/Utility/Timer.php2
-rw-r--r--core/lib/Drupal/Component/Utility/Unicode.php8
-rw-r--r--core/lib/Drupal/Component/Utility/UrlHelper.php16
-rw-r--r--core/lib/Drupal/Component/Utility/UserAgent.php4
-rw-r--r--core/lib/Drupal/Component/Utility/Variable.php2
-rw-r--r--core/lib/Drupal/Component/Utility/Xss.php10
-rw-r--r--core/lib/Drupal/Core/Access/AccessManager.php4
-rw-r--r--core/lib/Drupal/Core/Access/AccessManagerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Access/AccessResult.php4
-rw-r--r--core/lib/Drupal/Core/Access/CheckProvider.php14
-rw-r--r--core/lib/Drupal/Core/Access/CheckProviderInterface.php2
-rw-r--r--core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php4
-rw-r--r--core/lib/Drupal/Core/Action/ConfigurableActionBase.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/AddCssCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/AfterCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/AjaxResponse.php2
-rw-r--r--core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php2
-rw-r--r--core/lib/Drupal/Core/Ajax/AlertCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/AppendCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/BaseCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/BeforeCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/ChangedCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/CloseDialogCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/CssCommand.php8
-rw-r--r--core/lib/Drupal/Core/Ajax/DataCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/HtmlCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/InsertCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/InvokeCommand.php6
-rw-r--r--core/lib/Drupal/Core/Ajax/OpenDialogCommand.php8
-rw-r--r--core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php2
-rw-r--r--core/lib/Drupal/Core/Ajax/PrependCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/RedirectCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/RemoveCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/ReplaceCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/RestripeCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php4
-rw-r--r--core/lib/Drupal/Core/Ajax/SettingsCommand.php4
-rw-r--r--core/lib/Drupal/Core/Annotation/ContextDefinition.php4
-rw-r--r--core/lib/Drupal/Core/Annotation/Translation.php8
-rw-r--r--core/lib/Drupal/Core/Archiver/ArchiverInterface.php2
-rw-r--r--core/lib/Drupal/Core/Archiver/ArchiverManager.php2
-rw-r--r--core/lib/Drupal/Core/Archiver/Tar.php4
-rw-r--r--core/lib/Drupal/Core/Archiver/Zip.php6
-rw-r--r--core/lib/Drupal/Core/Asset/CssCollectionGrouper.php6
-rw-r--r--core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php8
-rw-r--r--core/lib/Drupal/Core/Asset/CssCollectionRenderer.php18
-rw-r--r--core/lib/Drupal/Core/Asset/CssOptimizer.php4
-rw-r--r--core/lib/Drupal/Core/Asset/JsCollectionGrouper.php6
-rw-r--r--core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php8
-rw-r--r--core/lib/Drupal/Core/Asset/JsCollectionRenderer.php10
-rw-r--r--core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php12
-rw-r--r--core/lib/Drupal/Core/Batch/BatchStorage.php10
-rw-r--r--core/lib/Drupal/Core/Block/BlockBase.php26
-rw-r--r--core/lib/Drupal/Core/Block/BlockManager.php2
-rw-r--r--core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php6
-rw-r--r--core/lib/Drupal/Core/Cache/ApcuBackend.php16
-rw-r--r--core/lib/Drupal/Core/Cache/BackendChain.php6
-rw-r--r--core/lib/Drupal/Core/Cache/Cache.php4
-rw-r--r--core/lib/Drupal/Core/Cache/CacheBackendInterface.php2
-rw-r--r--core/lib/Drupal/Core/Cache/CacheCollector.php20
-rw-r--r--core/lib/Drupal/Core/Cache/CacheFactory.php2
-rw-r--r--core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php4
-rw-r--r--core/lib/Drupal/Core/Cache/ChainedFastBackend.php12
-rw-r--r--core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php2
-rw-r--r--core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php2
-rw-r--r--core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php2
-rw-r--r--core/lib/Drupal/Core/Cache/DatabaseBackend.php84
-rw-r--r--core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php32
-rw-r--r--core/lib/Drupal/Core/Cache/ListCacheBinsPass.php4
-rw-r--r--core/lib/Drupal/Core/Cache/MemoryBackend.php16
-rw-r--r--core/lib/Drupal/Core/Cache/MemoryBackendFactory.php2
-rw-r--r--core/lib/Drupal/Core/Cache/MemoryCounterBackend.php8
-rw-r--r--core/lib/Drupal/Core/Cache/NullBackend.php6
-rw-r--r--core/lib/Drupal/Core/Cache/PhpBackend.php14
-rw-r--r--core/lib/Drupal/Core/Composer/Composer.php8
-rw-r--r--core/lib/Drupal/Core/Condition/Annotation/Condition.php2
-rw-r--r--core/lib/Drupal/Core/Condition/ConditionManager.php2
-rw-r--r--core/lib/Drupal/Core/Condition/ConditionPluginBase.php14
-rw-r--r--core/lib/Drupal/Core/Condition/ConditionPluginCollection.php4
-rw-r--r--core/lib/Drupal/Core/Config/CachedStorage.php16
-rw-r--r--core/lib/Drupal/Core/Config/Config.php10
-rw-r--r--core/lib/Drupal/Core/Config/ConfigBase.php4
-rw-r--r--core/lib/Drupal/Core/Config/ConfigCollectionInfo.php2
-rw-r--r--core/lib/Drupal/Core/Config/ConfigFactory.php24
-rw-r--r--core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php8
-rw-r--r--core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php2
-rw-r--r--core/lib/Drupal/Core/Config/ConfigImporter.php82
-rw-r--r--core/lib/Drupal/Core/Config/ConfigInstaller.php2
-rw-r--r--core/lib/Drupal/Core/Config/ConfigManager.php34
-rw-r--r--core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php4
-rw-r--r--core/lib/Drupal/Core/Config/DatabaseStorage.php60
-rw-r--r--core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php10
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php24
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php10
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php8
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php2
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php2
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php10
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php18
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php4
-rw-r--r--core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php34
-rw-r--r--core/lib/Drupal/Core/Config/Entity/Query/Condition.php10
-rw-r--r--core/lib/Drupal/Core/Config/Entity/Query/Query.php4
-rw-r--r--core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php6
-rw-r--r--core/lib/Drupal/Core/Config/ExtensionInstallStorage.php6
-rw-r--r--core/lib/Drupal/Core/Config/FileStorage.php8
-rw-r--r--core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/Config/InstallStorage.php10
-rw-r--r--core/lib/Drupal/Core/Config/NullStorage.php8
-rw-r--r--core/lib/Drupal/Core/Config/PreExistingConfigException.php6
-rw-r--r--core/lib/Drupal/Core/Config/Schema/ArrayElement.php6
-rw-r--r--core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php2
-rw-r--r--core/lib/Drupal/Core/Config/Schema/Mapping.php2
-rw-r--r--core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php12
-rw-r--r--core/lib/Drupal/Core/Config/Schema/Sequence.php2
-rw-r--r--core/lib/Drupal/Core/Config/StorableConfigBase.php2
-rw-r--r--core/lib/Drupal/Core/Config/StorageComparer.php36
-rw-r--r--core/lib/Drupal/Core/Config/TypedConfigManager.php12
-rw-r--r--core/lib/Drupal/Core/Config/UnmetDependenciesException.php4
-rw-r--r--core/lib/Drupal/Core/Controller/ControllerResolver.php4
-rw-r--r--core/lib/Drupal/Core/Controller/TitleResolver.php4
-rw-r--r--core/lib/Drupal/Core/Database/Connection.php56
-rw-r--r--core/lib/Drupal/Core/Database/Database.php24
-rw-r--r--core/lib/Drupal/Core/Database/Driver/mysql/Connection.php40
-rw-r--r--core/lib/Drupal/Core/Database/Driver/mysql/Insert.php4
-rw-r--r--core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php16
-rw-r--r--core/lib/Drupal/Core/Database/Driver/mysql/Schema.php58
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php20
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php10
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php40
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php2
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php80
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Select.php6
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Update.php4
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php6
-rw-r--r--core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php68
-rw-r--r--core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php4
-rw-r--r--core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php6
-rw-r--r--core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php96
-rw-r--r--core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php8
-rw-r--r--core/lib/Drupal/Core/Database/Install/Tasks.php122
-rw-r--r--core/lib/Drupal/Core/Database/Log.php14
-rw-r--r--core/lib/Drupal/Core/Database/Query/Condition.php70
-rw-r--r--core/lib/Drupal/Core/Database/Query/ConditionInterface.php2
-rw-r--r--core/lib/Drupal/Core/Database/Query/Delete.php4
-rw-r--r--core/lib/Drupal/Core/Database/Query/Insert.php6
-rw-r--r--core/lib/Drupal/Core/Database/Query/InsertTrait.php12
-rw-r--r--core/lib/Drupal/Core/Database/Query/Merge.php30
-rw-r--r--core/lib/Drupal/Core/Database/Query/Query.php2
-rw-r--r--core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php2
-rw-r--r--core/lib/Drupal/Core/Database/Query/Select.php58
-rw-r--r--core/lib/Drupal/Core/Database/Query/SelectExtender.php24
-rw-r--r--core/lib/Drupal/Core/Database/Query/SelectInterface.php16
-rw-r--r--core/lib/Drupal/Core/Database/Query/TableSortExtender.php2
-rw-r--r--core/lib/Drupal/Core/Database/Query/Truncate.php4
-rw-r--r--core/lib/Drupal/Core/Database/Query/Update.php16
-rw-r--r--core/lib/Drupal/Core/Database/Query/Upsert.php4
-rw-r--r--core/lib/Drupal/Core/Database/Schema.php14
-rw-r--r--core/lib/Drupal/Core/Database/Statement.php8
-rw-r--r--core/lib/Drupal/Core/Database/StatementEmpty.php12
-rw-r--r--core/lib/Drupal/Core/Database/StatementInterface.php4
-rw-r--r--core/lib/Drupal/Core/Database/StatementPrefetch.php40
-rw-r--r--core/lib/Drupal/Core/Database/database.api.php58
-rw-r--r--core/lib/Drupal/Core/Datetime/DateFormatter.php46
-rw-r--r--core/lib/Drupal/Core/Datetime/DateFormatterInterface.php6
-rw-r--r--core/lib/Drupal/Core/Datetime/DateHelper.php164
-rw-r--r--core/lib/Drupal/Core/Datetime/DrupalDateTime.php10
-rw-r--r--core/lib/Drupal/Core/Datetime/Element/DateElementBase.php2
-rw-r--r--core/lib/Drupal/Core/Datetime/Element/Datelist.php36
-rw-r--r--core/lib/Drupal/Core/Datetime/Element/Datetime.php72
-rw-r--r--core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php6
-rw-r--r--core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php4
-rw-r--r--core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php2
-rw-r--r--core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php2
-rw-r--r--core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php10
-rw-r--r--core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php6
-rw-r--r--core/lib/Drupal/Core/Diff/DiffFormatter.php52
-rw-r--r--core/lib/Drupal/Core/Display/VariantBase.php12
-rw-r--r--core/lib/Drupal/Core/DrupalKernel.php70
-rw-r--r--core/lib/Drupal/Core/DrupalKernelInterface.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php2
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityBase.php38
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php18
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php10
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php8
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php18
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityType.php4
-rw-r--r--core/lib/Drupal/Core/Entity/DependencyTrait.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php40
-rw-r--r--core/lib/Drupal/Core/Entity/Entity.php14
-rw-r--r--core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php30
-rw-r--r--core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php46
-rw-r--r--core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php22
-rw-r--r--core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php8
-rw-r--r--core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php18
-rw-r--r--core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php4
-rw-r--r--core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php6
-rw-r--r--core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php12
-rw-r--r--core/lib/Drupal/Core/Entity/EntityDisplayBase.php20
-rw-r--r--core/lib/Drupal/Core/Entity/EntityDisplayRepository.php4
-rw-r--r--core/lib/Drupal/Core/Entity/EntityForm.php24
-rw-r--r--core/lib/Drupal/Core/Entity/EntityFormBuilder.php2
-rw-r--r--core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php2
-rw-r--r--core/lib/Drupal/Core/Entity/EntityInterface.php8
-rw-r--r--core/lib/Drupal/Core/Entity/EntityListBuilder.php28
-rw-r--r--core/lib/Drupal/Core/Entity/EntityManager.php2
-rw-r--r--core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php18
-rw-r--r--core/lib/Drupal/Core/Entity/EntityRepository.php4
-rw-r--r--core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php2
-rw-r--r--core/lib/Drupal/Core/Entity/EntityResolverManager.php22
-rw-r--r--core/lib/Drupal/Core/Entity/EntityStorageBase.php26
-rw-r--r--core/lib/Drupal/Core/Entity/EntityStorageInterface.php4
-rw-r--r--core/lib/Drupal/Core/Entity/EntityType.php18
-rw-r--r--core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php2
-rw-r--r--core/lib/Drupal/Core/Entity/EntityTypeRepository.php4
-rw-r--r--core/lib/Drupal/Core/Entity/EntityViewBuilder.php56
-rw-r--r--core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php6
-rw-r--r--core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php2
-rw-r--r--core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php10
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php8
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php72
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Query/ConditionBase.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Query/QueryBase.php40
-rw-r--r--core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Query/Sql/Query.php22
-rw-r--r--core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php8
-rw-r--r--core/lib/Drupal/Core/Entity/Query/Sql/Tables.php14
-rw-r--r--core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php26
-rw-r--r--core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php100
-rw-r--r--core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php204
-rw-r--r--core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php10
-rw-r--r--core/lib/Drupal/Core/Entity/entity.api.php80
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php38
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php10
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php12
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php6
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php4
-rw-r--r--core/lib/Drupal/Core/Executable/ExecutablePluginBase.php2
-rw-r--r--core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php8
-rw-r--r--core/lib/Drupal/Core/Extension/Extension.php6
-rw-r--r--core/lib/Drupal/Core/Extension/ExtensionDiscovery.php14
-rw-r--r--core/lib/Drupal/Core/Extension/InfoParser.php2
-rw-r--r--core/lib/Drupal/Core/Extension/InfoParserDynamic.php4
-rw-r--r--core/lib/Drupal/Core/Extension/ModuleHandler.php40
-rw-r--r--core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php6
-rw-r--r--core/lib/Drupal/Core/Extension/ModuleInstaller.php32
-rw-r--r--core/lib/Drupal/Core/Extension/ThemeHandler.php40
-rw-r--r--core/lib/Drupal/Core/Extension/ThemeInstaller.php16
-rw-r--r--core/lib/Drupal/Core/Extension/module.api.php78
-rw-r--r--core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php2
-rw-r--r--core/lib/Drupal/Core/Field/Annotation/FieldWidget.php2
-rw-r--r--core/lib/Drupal/Core/Field/BaseFieldDefinition.php28
-rw-r--r--core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php10
-rw-r--r--core/lib/Drupal/Core/Field/FieldConfigBase.php10
-rw-r--r--core/lib/Drupal/Core/Field/FieldItemBase.php14
-rw-r--r--core/lib/Drupal/Core/Field/FieldItemInterface.php2
-rw-r--r--core/lib/Drupal/Core/Field/FieldItemList.php18
-rw-r--r--core/lib/Drupal/Core/Field/FieldItemListInterface.php2
-rw-r--r--core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php6
-rw-r--r--core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php2
-rw-r--r--core/lib/Drupal/Core/Field/FieldTypePluginManager.php6
-rw-r--r--core/lib/Drupal/Core/Field/FormatterBase.php10
-rw-r--r--core/lib/Drupal/Core/Field/FormatterPluginManager.php22
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php2
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php16
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php16
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php10
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php16
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php6
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php24
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php2
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php22
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php36
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php2
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php34
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php2
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php40
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php26
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php104
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php12
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php36
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php14
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php18
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php50
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php36
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php12
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php12
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php12
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php8
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php16
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php22
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php34
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php18
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php10
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php4
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php18
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php24
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php24
-rw-r--r--core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php22
-rw-r--r--core/lib/Drupal/Core/Field/PluginSettingsBase.php12
-rw-r--r--core/lib/Drupal/Core/Field/WidgetBase.php84
-rw-r--r--core/lib/Drupal/Core/Field/WidgetPluginManager.php28
-rw-r--r--core/lib/Drupal/Core/File/FileSystem.php2
-rw-r--r--core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php12
-rw-r--r--core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php4
-rw-r--r--core/lib/Drupal/Core/File/file.api.php12
-rw-r--r--core/lib/Drupal/Core/FileTransfer/FTPExtension.php14
-rw-r--r--core/lib/Drupal/Core/FileTransfer/FileTransfer.php22
-rw-r--r--core/lib/Drupal/Core/FileTransfer/FileTransferException.php2
-rw-r--r--core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php74
-rw-r--r--core/lib/Drupal/Core/FileTransfer/Local.php18
-rw-r--r--core/lib/Drupal/Core/FileTransfer/SSH.php18
-rw-r--r--core/lib/Drupal/Core/Flood/DatabaseBackend.php4
-rw-r--r--core/lib/Drupal/Core/Flood/MemoryBackend.php2
-rw-r--r--core/lib/Drupal/Core/Form/ConfigFormBase.php4
-rw-r--r--core/lib/Drupal/Core/Form/ConfirmFormBase.php10
-rw-r--r--core/lib/Drupal/Core/Form/FormBuilder.php48
-rw-r--r--core/lib/Drupal/Core/Form/FormCache.php2
-rw-r--r--core/lib/Drupal/Core/Form/FormState.php30
-rw-r--r--core/lib/Drupal/Core/Form/FormStateInterface.php2
-rw-r--r--core/lib/Drupal/Core/Form/FormSubmitter.php4
-rw-r--r--core/lib/Drupal/Core/Form/FormValidator.php20
-rw-r--r--core/lib/Drupal/Core/Form/OptGroup.php2
-rw-r--r--core/lib/Drupal/Core/Form/form.api.php32
-rw-r--r--core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php2
-rw-r--r--core/lib/Drupal/Core/Image/Image.php18
-rw-r--r--core/lib/Drupal/Core/Image/ImageInterface.php2
-rw-r--r--core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php8
-rw-r--r--core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php2
-rw-r--r--core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php2
-rw-r--r--core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php2
-rw-r--r--core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php6
-rw-r--r--core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php4
-rw-r--r--core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php32
-rw-r--r--core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php20
-rw-r--r--core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php82
-rw-r--r--core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php54
-rw-r--r--core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php2
-rw-r--r--core/lib/Drupal/Core/Installer/InstallerServiceProvider.php4
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php24
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php28
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php2
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php4
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php2
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php4
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php6
-rw-r--r--core/lib/Drupal/Core/KeyValueStore/StorageBase.php4
-rw-r--r--core/lib/Drupal/Core/Language/Language.php6
-rw-r--r--core/lib/Drupal/Core/Language/LanguageManager.php246
-rw-r--r--core/lib/Drupal/Core/Language/LanguageManagerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Link.php2
-rw-r--r--core/lib/Drupal/Core/Locale/CountryManager.php4
-rw-r--r--core/lib/Drupal/Core/Lock/DatabaseLockBackend.php12
-rw-r--r--core/lib/Drupal/Core/Lock/LockBackendAbstract.php2
-rw-r--r--core/lib/Drupal/Core/Logger/LogMessageParser.php2
-rw-r--r--core/lib/Drupal/Core/Logger/LoggerChannel.php14
-rw-r--r--core/lib/Drupal/Core/Logger/LoggerChannelFactory.php4
-rw-r--r--core/lib/Drupal/Core/Logger/RfcLoggerTrait.php18
-rw-r--r--core/lib/Drupal/Core/Mail/MailFormatHelper.php22
-rw-r--r--core/lib/Drupal/Core/Mail/MailManager.php22
-rw-r--r--core/lib/Drupal/Core/Mail/MailManagerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php2
-rw-r--r--core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php2
-rw-r--r--core/lib/Drupal/Core/Menu/ContextualLinkManager.php18
-rw-r--r--core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php6
-rw-r--r--core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php32
-rw-r--r--core/lib/Drupal/Core/Menu/LocalActionDefault.php2
-rw-r--r--core/lib/Drupal/Core/Menu/LocalActionManager.php30
-rw-r--r--core/lib/Drupal/Core/Menu/LocalTaskDefault.php2
-rw-r--r--core/lib/Drupal/Core/Menu/LocalTaskManager.php30
-rw-r--r--core/lib/Drupal/Core/Menu/MenuActiveTrail.php2
-rw-r--r--core/lib/Drupal/Core/Menu/MenuLinkBase.php8
-rw-r--r--core/lib/Drupal/Core/Menu/MenuLinkDefault.php4
-rw-r--r--core/lib/Drupal/Core/Menu/MenuLinkManager.php18
-rw-r--r--core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Menu/MenuLinkTree.php6
-rw-r--r--core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php2
-rw-r--r--core/lib/Drupal/Core/Menu/MenuParentFormSelector.php22
-rw-r--r--core/lib/Drupal/Core/Menu/MenuTreeParameters.php8
-rw-r--r--core/lib/Drupal/Core/Menu/MenuTreeStorage.php242
-rw-r--r--core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php2
-rw-r--r--core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php14
-rw-r--r--core/lib/Drupal/Core/Menu/menu.api.php22
-rw-r--r--core/lib/Drupal/Core/ParamConverter/EntityConverter.php2
-rw-r--r--core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php2
-rw-r--r--core/lib/Drupal/Core/Path/AliasManager.php24
-rw-r--r--core/lib/Drupal/Core/Path/AliasStorage.php12
-rw-r--r--core/lib/Drupal/Core/Path/PathMatcher.php8
-rw-r--r--core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php2
-rw-r--r--core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php2
-rw-r--r--core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php2
-rw-r--r--core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php2
-rw-r--r--core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php16
-rw-r--r--core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/Context/ContextHandler.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php12
-rw-r--r--core/lib/Drupal/Core/Plugin/DefaultPluginManager.php4
-rw-r--r--core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php4
-rw-r--r--core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php6
-rw-r--r--core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php2
-rw-r--r--core/lib/Drupal/Core/Plugin/PluginManagerPass.php2
-rw-r--r--core/lib/Drupal/Core/Queue/Batch.php6
-rw-r--r--core/lib/Drupal/Core/Queue/BatchMemory.php2
-rw-r--r--core/lib/Drupal/Core/Queue/DatabaseQueue.php20
-rw-r--r--core/lib/Drupal/Core/Queue/Memory.php4
-rw-r--r--core/lib/Drupal/Core/Queue/QueueFactory.php2
-rw-r--r--core/lib/Drupal/Core/Render/BubbleableMetadata.php2
-rw-r--r--core/lib/Drupal/Core/Render/Element.php6
-rw-r--r--core/lib/Drupal/Core/Render/Element/Actions.php26
-rw-r--r--core/lib/Drupal/Core/Render/Element/Ajax.php6
-rw-r--r--core/lib/Drupal/Core/Render/Element/Button.php22
-rw-r--r--core/lib/Drupal/Core/Render/Element/Checkbox.php28
-rw-r--r--core/lib/Drupal/Core/Render/Element/Checkboxes.php34
-rw-r--r--core/lib/Drupal/Core/Render/Element/Color.php30
-rw-r--r--core/lib/Drupal/Core/Render/Element/Container.php20
-rw-r--r--core/lib/Drupal/Core/Render/Element/Date.php4
-rw-r--r--core/lib/Drupal/Core/Render/Element/Details.php26
-rw-r--r--core/lib/Drupal/Core/Render/Element/Dropbutton.php12
-rw-r--r--core/lib/Drupal/Core/Render/Element/ElementInterface.php2
-rw-r--r--core/lib/Drupal/Core/Render/Element/Email.php34
-rw-r--r--core/lib/Drupal/Core/Render/Element/Fieldgroup.php6
-rw-r--r--core/lib/Drupal/Core/Render/Element/Fieldset.php20
-rw-r--r--core/lib/Drupal/Core/Render/Element/File.php24
-rw-r--r--core/lib/Drupal/Core/Render/Element/Form.php6
-rw-r--r--core/lib/Drupal/Core/Render/Element/FormElement.php6
-rw-r--r--core/lib/Drupal/Core/Render/Element/Hidden.php18
-rw-r--r--core/lib/Drupal/Core/Render/Element/Html.php10
-rw-r--r--core/lib/Drupal/Core/Render/Element/HtmlTag.php24
-rw-r--r--core/lib/Drupal/Core/Render/Element/ImageButton.php8
-rw-r--r--core/lib/Drupal/Core/Render/Element/InlineTemplate.php12
-rw-r--r--core/lib/Drupal/Core/Render/Element/Item.php6
-rw-r--r--core/lib/Drupal/Core/Render/Element/Label.php4
-rw-r--r--core/lib/Drupal/Core/Render/Element/LanguageSelect.php4
-rw-r--r--core/lib/Drupal/Core/Render/Element/Link.php14
-rw-r--r--core/lib/Drupal/Core/Render/Element/MachineName.php48
-rw-r--r--core/lib/Drupal/Core/Render/Element/MoreLink.php14
-rw-r--r--core/lib/Drupal/Core/Render/Element/Number.php36
-rw-r--r--core/lib/Drupal/Core/Render/Element/Operations.php4
-rw-r--r--core/lib/Drupal/Core/Render/Element/Page.php4
-rw-r--r--core/lib/Drupal/Core/Render/Element/Password.php24
-rw-r--r--core/lib/Drupal/Core/Render/Element/PasswordConfirm.php26
-rw-r--r--core/lib/Drupal/Core/Render/Element/PathElement.php14
-rw-r--r--core/lib/Drupal/Core/Render/Element/Radio.php22
-rw-r--r--core/lib/Drupal/Core/Render/Element/Radios.php26
-rw-r--r--core/lib/Drupal/Core/Render/Element/Range.php14
-rw-r--r--core/lib/Drupal/Core/Render/Element/RenderElement.php6
-rw-r--r--core/lib/Drupal/Core/Render/Element/Search.php24
-rw-r--r--core/lib/Drupal/Core/Render/Element/Select.php36
-rw-r--r--core/lib/Drupal/Core/Render/Element/Submit.php4
-rw-r--r--core/lib/Drupal/Core/Render/Element/SystemCompactLink.php40
-rw-r--r--core/lib/Drupal/Core/Render/Element/Table.php60
-rw-r--r--core/lib/Drupal/Core/Render/Element/Tableselect.php54
-rw-r--r--core/lib/Drupal/Core/Render/Element/Tel.php26
-rw-r--r--core/lib/Drupal/Core/Render/Element/Textarea.php20
-rw-r--r--core/lib/Drupal/Core/Render/Element/Textfield.php32
-rw-r--r--core/lib/Drupal/Core/Render/Element/Token.php10
-rw-r--r--core/lib/Drupal/Core/Render/Element/Url.php34
-rw-r--r--core/lib/Drupal/Core/Render/Element/Value.php4
-rw-r--r--core/lib/Drupal/Core/Render/Element/VerticalTabs.php30
-rw-r--r--core/lib/Drupal/Core/Render/Element/Weight.php14
-rw-r--r--core/lib/Drupal/Core/Render/ElementInfoManager.php6
-rw-r--r--core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php4
-rw-r--r--core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php2
-rw-r--r--core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php2
-rw-r--r--core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php4
-rw-r--r--core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php2
-rw-r--r--core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php8
-rw-r--r--core/lib/Drupal/Core/Render/Renderer.php8
-rw-r--r--core/lib/Drupal/Core/Render/theme.api.php40
-rw-r--r--core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php8
-rw-r--r--core/lib/Drupal/Core/Routing/AccessAwareRouter.php2
-rw-r--r--core/lib/Drupal/Core/Routing/CompiledRoute.php2
-rw-r--r--core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php4
-rw-r--r--core/lib/Drupal/Core/Routing/MatcherDumper.php14
-rw-r--r--core/lib/Drupal/Core/Routing/NullGenerator.php4
-rw-r--r--core/lib/Drupal/Core/Routing/NullMatcherDumper.php2
-rw-r--r--core/lib/Drupal/Core/Routing/RouteBuilder.php14
-rw-r--r--core/lib/Drupal/Core/Routing/RouteMatch.php6
-rw-r--r--core/lib/Drupal/Core/Routing/RoutePreloader.php10
-rw-r--r--core/lib/Drupal/Core/Routing/RouteProvider.php26
-rw-r--r--core/lib/Drupal/Core/Routing/Router.php4
-rw-r--r--core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php4
-rw-r--r--core/lib/Drupal/Core/Routing/UrlGenerator.php20
-rw-r--r--core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php4
-rw-r--r--core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php2
-rw-r--r--core/lib/Drupal/Core/Session/AccountSwitcher.php4
-rw-r--r--core/lib/Drupal/Core/Session/SessionHandler.php6
-rw-r--r--core/lib/Drupal/Core/Session/SessionManager.php10
-rw-r--r--core/lib/Drupal/Core/Session/UserSession.php6
-rw-r--r--core/lib/Drupal/Core/Site/Settings.php8
-rw-r--r--core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php2
-rw-r--r--core/lib/Drupal/Core/State/State.php4
-rw-r--r--core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php6
-rw-r--r--core/lib/Drupal/Core/StreamWrapper/LocalStream.php2
-rw-r--r--core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php6
-rw-r--r--core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php18
-rw-r--r--core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php4
-rw-r--r--core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php4
-rw-r--r--core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php4
-rw-r--r--core/lib/Drupal/Core/StringTranslation/TranslationInterface.php4
-rw-r--r--core/lib/Drupal/Core/StringTranslation/TranslationManager.php10
-rw-r--r--core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php2
-rw-r--r--core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php4
-rw-r--r--core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php6
-rw-r--r--core/lib/Drupal/Core/Template/Attribute.php8
-rw-r--r--core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php6
-rw-r--r--core/lib/Drupal/Core/Template/TwigEnvironment.php10
-rw-r--r--core/lib/Drupal/Core/Template/TwigExtension.php40
-rw-r--r--core/lib/Drupal/Core/Template/TwigNodeTrans.php12
-rw-r--r--core/lib/Drupal/Core/Template/TwigNodeVisitor.php2
-rw-r--r--core/lib/Drupal/Core/Template/TwigTransTokenParser.php6
-rw-r--r--core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php12
-rw-r--r--core/lib/Drupal/Core/Test/TestRunnerKernel.php12
-rw-r--r--core/lib/Drupal/Core/Test/TestSetupTrait.php8
-rw-r--r--core/lib/Drupal/Core/Theme/Registry.php26
-rw-r--r--core/lib/Drupal/Core/Theme/ThemeInitialization.php8
-rw-r--r--core/lib/Drupal/Core/Theme/ThemeManager.php24
-rw-r--r--core/lib/Drupal/Core/Theme/ThemeNegotiator.php4
-rw-r--r--core/lib/Drupal/Core/TypedData/DataDefinition.php8
-rw-r--r--core/lib/Drupal/Core/TypedData/ListDataDefinition.php4
-rw-r--r--core/lib/Drupal/Core/TypedData/MapDataDefinition.php2
-rw-r--r--core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php10
-rw-r--r--core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php10
-rw-r--r--core/lib/Drupal/Core/TypedData/TranslatableInterface.php2
-rw-r--r--core/lib/Drupal/Core/TypedData/TypedData.php2
-rw-r--r--core/lib/Drupal/Core/TypedData/TypedDataManager.php18
-rw-r--r--core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php2
-rw-r--r--core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php10
-rw-r--r--core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php2
-rw-r--r--core/lib/Drupal/Core/Update/UpdateRegistry.php2
-rw-r--r--core/lib/Drupal/Core/Updater/Module.php8
-rw-r--r--core/lib/Drupal/Core/Updater/Theme.php2
-rw-r--r--core/lib/Drupal/Core/Updater/Updater.php24
-rw-r--r--core/lib/Drupal/Core/Url.php12
-rw-r--r--core/lib/Drupal/Core/Utility/Error.php12
-rw-r--r--core/lib/Drupal/Core/Utility/LinkGenerator.php14
-rw-r--r--core/lib/Drupal/Core/Utility/ProjectInfo.php14
-rw-r--r--core/lib/Drupal/Core/Utility/ThemeRegistry.php4
-rw-r--r--core/lib/Drupal/Core/Utility/Token.php16
-rw-r--r--core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php2
-rw-r--r--core/lib/Drupal/Core/Utility/token.api.php52
-rw-r--r--core/lib/Drupal/Core/Validation/ConstraintManager.php24
-rw-r--r--core/lib/Drupal/Core/Validation/DrupalTranslator.php8
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php4
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php4
-rw-r--r--core/modules/action/action.module6
-rw-r--r--core/modules/action/action.views_execution.inc10
-rw-r--r--core/modules/action/src/ActionFormBase.php22
-rw-r--r--core/modules/action/src/ActionListBuilder.php6
-rw-r--r--core/modules/action/src/Form/ActionAdminManageForm.php22
-rw-r--r--core/modules/action/src/Plugin/Action/EmailAction.php26
-rw-r--r--core/modules/action/src/Plugin/Action/GotoAction.php10
-rw-r--r--core/modules/action/src/Plugin/Action/MessageAction.php8
-rw-r--r--core/modules/action/src/Plugin/migrate/source/Action.php4
-rw-r--r--core/modules/action/tests/src/Functional/ActionListTest.php2
-rw-r--r--core/modules/action/tests/src/Functional/ActionUninstallTest.php6
-rw-r--r--core/modules/action/tests/src/Functional/BulkFormTest.php32
-rw-r--r--core/modules/action/tests/src/Functional/ConfigurationTest.php14
-rw-r--r--core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php4
-rw-r--r--core/modules/aggregator/aggregator.install6
-rw-r--r--core/modules/aggregator/aggregator.module70
-rw-r--r--core/modules/aggregator/src/AggregatorFeedViewsData.php8
-rw-r--r--core/modules/aggregator/src/Controller/AggregatorController.php56
-rw-r--r--core/modules/aggregator/src/Entity/Feed.php30
-rw-r--r--core/modules/aggregator/src/Entity/Item.php16
-rw-r--r--core/modules/aggregator/src/FeedForm.php6
-rw-r--r--core/modules/aggregator/src/FeedStorage.php4
-rw-r--r--core/modules/aggregator/src/FeedViewBuilder.php44
-rw-r--r--core/modules/aggregator/src/Form/FeedDeleteForm.php4
-rw-r--r--core/modules/aggregator/src/Form/FeedItemsDeleteForm.php2
-rw-r--r--core/modules/aggregator/src/Form/OpmlFeedAdd.php44
-rw-r--r--core/modules/aggregator/src/Form/SettingsForm.php48
-rw-r--r--core/modules/aggregator/src/ItemViewBuilder.php4
-rw-r--r--core/modules/aggregator/src/ItemsImporter.php6
-rw-r--r--core/modules/aggregator/src/Plugin/AggregatorPluginManager.php8
-rw-r--r--core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php4
-rw-r--r--core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php14
-rw-r--r--core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php4
-rw-r--r--core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php6
-rw-r--r--core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php38
-rw-r--r--core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php4
-rw-r--r--core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php4
-rw-r--r--core/modules/aggregator/src/Plugin/views/argument/Fid.php2
-rw-r--r--core/modules/aggregator/src/Plugin/views/argument/Iid.php2
-rw-r--r--core/modules/aggregator/src/Plugin/views/row/Rss.php22
-rw-r--r--core/modules/aggregator/src/Tests/AddFeedTest.php4
-rw-r--r--core/modules/aggregator/src/Tests/AggregatorAdminTest.php12
-rw-r--r--core/modules/aggregator/src/Tests/AggregatorCronTest.php18
-rw-r--r--core/modules/aggregator/src/Tests/AggregatorRenderingTest.php26
-rw-r--r--core/modules/aggregator/src/Tests/AggregatorTestBase.php64
-rw-r--r--core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php4
-rw-r--r--core/modules/aggregator/src/Tests/FeedLanguageTest.php18
-rw-r--r--core/modules/aggregator/src/Tests/UpdateFeedItemTest.php22
-rw-r--r--core/modules/aggregator/src/Tests/UpdateFeedTest.php6
-rw-r--r--core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php8
-rw-r--r--core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php64
-rw-r--r--core/modules/aggregator/tests/src/Functional/DeleteFeedItemTest.php10
-rw-r--r--core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php4
-rw-r--r--core/modules/aggregator/tests/src/Functional/FeedCacheTagsTest.php6
-rw-r--r--core/modules/aggregator/tests/src/Functional/FeedParserTest.php20
-rw-r--r--core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php6
-rw-r--r--core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php24
-rw-r--r--core/modules/aggregator/tests/src/Functional/ItemCacheTagsTest.php16
-rw-r--r--core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php2
-rw-r--r--core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php2
-rw-r--r--core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php20
-rw-r--r--core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php30
-rw-r--r--core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php22
-rw-r--r--core/modules/ban/ban.install24
-rw-r--r--core/modules/ban/ban.module4
-rw-r--r--core/modules/ban/src/BanIpManager.php8
-rw-r--r--core/modules/ban/src/Form/BanAdmin.php36
-rw-r--r--core/modules/ban/src/Form/BanDelete.php6
-rw-r--r--core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php2
-rw-r--r--core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php28
-rw-r--r--core/modules/basic_auth/basic_auth.module2
-rw-r--r--core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php6
-rw-r--r--core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php10
-rw-r--r--core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php2
-rw-r--r--core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php4
-rw-r--r--core/modules/block/block.module34
-rw-r--r--core/modules/block/block.post_update.php4
-rw-r--r--core/modules/block/src/BlockForm.php38
-rw-r--r--core/modules/block/src/BlockListBuilder.php138
-rw-r--r--core/modules/block/src/BlockRepository.php6
-rw-r--r--core/modules/block/src/BlockViewBuilder.php16
-rw-r--r--core/modules/block/src/Controller/BlockAddController.php2
-rw-r--r--core/modules/block/src/Controller/BlockController.php14
-rw-r--r--core/modules/block/src/Controller/CategoryAutocompleteController.php4
-rw-r--r--core/modules/block/src/Entity/Block.php2
-rw-r--r--core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php2
-rw-r--r--core/modules/block/src/Form/BlockDeleteForm.php8
-rw-r--r--core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php2
-rw-r--r--core/modules/block/src/Plugin/migrate/destination/EntityBlock.php4
-rw-r--r--core/modules/block/src/Plugin/migrate/process/BlockPluginId.php8
-rw-r--r--core/modules/block/src/Plugin/migrate/process/BlockRegion.php2
-rw-r--r--core/modules/block/src/Plugin/migrate/process/BlockSettings.php2
-rw-r--r--core/modules/block/src/Plugin/migrate/process/BlockVisibility.php28
-rw-r--r--core/modules/block/src/Plugin/migrate/source/Block.php10
-rw-r--r--core/modules/block/src/Tests/BlockAdminThemeTest.php6
-rw-r--r--core/modules/block/src/Tests/BlockLanguageCacheTest.php20
-rw-r--r--core/modules/block/src/Tests/BlockRenderOrderTest.php26
-rw-r--r--core/modules/block/src/Tests/BlockSystemBrandingTest.php4
-rw-r--r--core/modules/block/src/Tests/BlockTest.php90
-rw-r--r--core/modules/block/src/Tests/BlockTestBase.php16
-rw-r--r--core/modules/block/src/Tests/BlockUiTest.php48
-rw-r--r--core/modules/block/src/Tests/NonDefaultBlockAdminTest.php6
-rw-r--r--core/modules/block/src/Tests/Views/DisplayBlockTest.php66
-rw-r--r--core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php12
-rw-r--r--core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php2
-rw-r--r--core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php4
-rw-r--r--core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php4
-rw-r--r--core/modules/block/tests/src/Functional/BlockCacheTest.php6
-rw-r--r--core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php8
-rw-r--r--core/modules/block/tests/src/Functional/BlockHookOperationTest.php8
-rw-r--r--core/modules/block/tests/src/Functional/BlockHtmlTest.php8
-rw-r--r--core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php14
-rw-r--r--core/modules/block/tests/src/Functional/BlockLanguageTest.php34
-rw-r--r--core/modules/block/tests/src/Functional/BlockTemplateSuggestionsTest.php12
-rw-r--r--core/modules/block/tests/src/Functional/NewDefaultThemeBlocksTest.php16
-rw-r--r--core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php16
-rw-r--r--core/modules/block/tests/src/Kernel/BlockInterfaceTest.php42
-rw-r--r--core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php22
-rw-r--r--core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php26
-rw-r--r--core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php12
-rw-r--r--core/modules/block/tests/src/Unit/BlockFormTest.php4
-rw-r--r--core/modules/block/tests/src/Unit/BlockRepositoryTest.php24
-rw-r--r--core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php38
-rw-r--r--core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php42
-rw-r--r--core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php36
-rw-r--r--core/modules/block_content/block_content.module32
-rw-r--r--core/modules/block_content/block_content.pages.inc16
-rw-r--r--core/modules/block_content/src/BlockContentForm.php10
-rw-r--r--core/modules/block_content/src/BlockContentTranslationHandler.php2
-rw-r--r--core/modules/block_content/src/BlockContentTypeForm.php48
-rw-r--r--core/modules/block_content/src/BlockContentViewBuilder.php12
-rw-r--r--core/modules/block_content/src/BlockContentViewsData.php8
-rw-r--r--core/modules/block_content/src/Controller/BlockContentController.php12
-rw-r--r--core/modules/block_content/src/Entity/BlockContent.php14
-rw-r--r--core/modules/block_content/src/Form/BlockContentDeleteForm.php4
-rw-r--r--core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php4
-rw-r--r--core/modules/block_content/src/Plugin/Block/BlockContentBlock.php16
-rw-r--r--core/modules/block_content/src/Plugin/Derivative/BlockContent.php4
-rw-r--r--core/modules/block_content/src/Plugin/migrate/source/d6/Box.php6
-rw-r--r--core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php4
-rw-r--r--core/modules/block_content/src/Plugin/views/area/ListingEmpty.php10
-rw-r--r--core/modules/block_content/src/Tests/BlockContentCreationTest.php74
-rw-r--r--core/modules/block_content/src/Tests/BlockContentListTest.php18
-rw-r--r--core/modules/block_content/src/Tests/BlockContentListViewsTest.php14
-rw-r--r--core/modules/block_content/src/Tests/BlockContentTestBase.php14
-rw-r--r--core/modules/block_content/src/Tests/BlockContentTranslationUITest.php32
-rw-r--r--core/modules/block_content/src/Tests/BlockContentTypeTest.php40
-rw-r--r--core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php18
-rw-r--r--core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php14
-rw-r--r--core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php6
-rw-r--r--core/modules/block_content/src/Tests/Views/BlockContentTestBase.php26
-rw-r--r--core/modules/block_content/src/Tests/Views/FieldTypeTest.php10
-rw-r--r--core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php42
-rw-r--r--core/modules/block_content/tests/modules/block_content_test/block_content_test.module4
-rw-r--r--core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php14
-rw-r--r--core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php2
-rw-r--r--core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php8
-rw-r--r--core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php8
-rw-r--r--core/modules/block_content/tests/src/Functional/BlockContentTestBase.php14
-rw-r--r--core/modules/block_content/tests/src/Functional/PageEditTest.php10
-rw-r--r--core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php2
-rw-r--r--core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php2
-rw-r--r--core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php4
-rw-r--r--core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php48
-rw-r--r--core/modules/book/book.install76
-rw-r--r--core/modules/book/book.module118
-rw-r--r--core/modules/book/src/BookBreadcrumbBuilder.php6
-rw-r--r--core/modules/book/src/BookExport.php14
-rw-r--r--core/modules/book/src/BookManager.php152
-rw-r--r--core/modules/book/src/BookManagerInterface.php6
-rw-r--r--core/modules/book/src/BookOutline.php2
-rw-r--r--core/modules/book/src/BookOutlineStorage.php14
-rw-r--r--core/modules/book/src/Controller/BookController.php32
-rw-r--r--core/modules/book/src/Form/BookAdminEditForm.php24
-rw-r--r--core/modules/book/src/Form/BookOutlineForm.php2
-rw-r--r--core/modules/book/src/Form/BookRemoveForm.php4
-rw-r--r--core/modules/book/src/Form/BookSettingsForm.php16
-rw-r--r--core/modules/book/src/Plugin/Block/BookNavigationBlock.php26
-rw-r--r--core/modules/book/src/Plugin/migrate/source/d6/Book.php8
-rw-r--r--core/modules/book/src/Tests/BookBreadcrumbTest.php18
-rw-r--r--core/modules/book/src/Tests/BookInstallTest.php2
-rw-r--r--core/modules/book/src/Tests/BookTest.php90
-rw-r--r--core/modules/book/src/Tests/Views/BookRelationshipTest.php14
-rw-r--r--core/modules/book/tests/src/Kernel/BookUninstallTest.php20
-rw-r--r--core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php2
-rw-r--r--core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php6
-rw-r--r--core/modules/book/tests/src/Unit/BookManagerTest.php40
-rw-r--r--core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php32
-rw-r--r--core/modules/breakpoint/breakpoint.module4
-rw-r--r--core/modules/breakpoint/src/Breakpoint.php2
-rw-r--r--core/modules/breakpoint/src/BreakpointManager.php30
-rw-r--r--core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php96
-rw-r--r--core/modules/breakpoint/tests/src/Unit/BreakpointTest.php12
-rw-r--r--core/modules/ckeditor/ckeditor.admin.inc34
-rw-r--r--core/modules/ckeditor/ckeditor.module20
-rw-r--r--core/modules/ckeditor/src/CKEditorPluginBase.php4
-rw-r--r--core/modules/ckeditor/src/CKEditorPluginManager.php18
-rw-r--r--core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php22
-rw-r--r--core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php16
-rw-r--r--core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php20
-rw-r--r--core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php164
-rw-r--r--core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php8
-rw-r--r--core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php40
-rw-r--r--core/modules/ckeditor/src/Plugin/Editor/CKEditor.php144
-rw-r--r--core/modules/ckeditor/src/Tests/CKEditorAdminTest.php88
-rw-r--r--core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php40
-rw-r--r--core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php50
-rw-r--r--core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php192
-rw-r--r--core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php6
-rw-r--r--core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php8
-rw-r--r--core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php14
-rw-r--r--core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php12
-rw-r--r--core/modules/color/color.install10
-rw-r--r--core/modules/color/color.module86
-rw-r--r--core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc32
-rw-r--r--core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php6
-rw-r--r--core/modules/color/tests/src/Functional/ColorTest.php26
-rw-r--r--core/modules/comment/comment.api.php14
-rw-r--r--core/modules/comment/comment.install66
-rw-r--r--core/modules/comment/comment.module92
-rw-r--r--core/modules/comment/comment.tokens.inc84
-rw-r--r--core/modules/comment/comment.views.inc52
-rw-r--r--core/modules/comment/src/CommentAccessControlHandler.php8
-rw-r--r--core/modules/comment/src/CommentForm.php56
-rw-r--r--core/modules/comment/src/CommentLazyBuilders.php44
-rw-r--r--core/modules/comment/src/CommentLinkBuilder.php46
-rw-r--r--core/modules/comment/src/CommentManager.php34
-rw-r--r--core/modules/comment/src/CommentStatistics.php44
-rw-r--r--core/modules/comment/src/CommentStorage.php12
-rw-r--r--core/modules/comment/src/CommentStorageSchema.php14
-rw-r--r--core/modules/comment/src/CommentTranslationHandler.php2
-rw-r--r--core/modules/comment/src/CommentTypeForm.php52
-rw-r--r--core/modules/comment/src/CommentViewBuilder.php8
-rw-r--r--core/modules/comment/src/CommentViewsData.php282
-rw-r--r--core/modules/comment/src/Controller/CommentController.php22
-rw-r--r--core/modules/comment/src/Entity/Comment.php6
-rw-r--r--core/modules/comment/src/Form/CommentAdminOverview.php104
-rw-r--r--core/modules/comment/src/Form/CommentTypeDeleteForm.php8
-rw-r--r--core/modules/comment/src/Form/ConfirmDeleteMultiple.php12
-rw-r--r--core/modules/comment/src/Form/DeleteForm.php2
-rw-r--r--core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php10
-rw-r--r--core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php10
-rw-r--r--core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php24
-rw-r--r--core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php64
-rw-r--r--core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php40
-rw-r--r--core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php2
-rw-r--r--core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php4
-rw-r--r--core/modules/comment/src/Plugin/migrate/destination/EntityComment.php2
-rw-r--r--core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php2
-rw-r--r--core/modules/comment/src/Plugin/migrate/source/d6/Comment.php10
-rw-r--r--core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php12
-rw-r--r--core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php14
-rw-r--r--core/modules/comment/src/Plugin/migrate/source/d7/Comment.php4
-rw-r--r--core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php18
-rw-r--r--core/modules/comment/src/Plugin/views/argument/UserUid.php4
-rw-r--r--core/modules/comment/src/Plugin/views/field/EntityLink.php8
-rw-r--r--core/modules/comment/src/Plugin/views/field/NodeNewComments.php20
-rw-r--r--core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php18
-rw-r--r--core/modules/comment/src/Plugin/views/filter/NodeComment.php4
-rw-r--r--core/modules/comment/src/Plugin/views/row/Rss.php28
-rw-r--r--core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php4
-rw-r--r--core/modules/comment/src/Plugin/views/wizard/Comment.php14
-rw-r--r--core/modules/comment/src/Tests/CommentActionsTest.php18
-rw-r--r--core/modules/comment/src/Tests/CommentAdminTest.php40
-rw-r--r--core/modules/comment/src/Tests/CommentAnonymousTest.php30
-rw-r--r--core/modules/comment/src/Tests/CommentBlockTest.php14
-rw-r--r--core/modules/comment/src/Tests/CommentBookTest.php8
-rw-r--r--core/modules/comment/src/Tests/CommentCSSTest.php24
-rw-r--r--core/modules/comment/src/Tests/CommentCacheTagsTest.php30
-rw-r--r--core/modules/comment/src/Tests/CommentFieldsTest.php46
-rw-r--r--core/modules/comment/src/Tests/CommentInterfaceTest.php42
-rw-r--r--core/modules/comment/src/Tests/CommentLanguageTest.php26
-rw-r--r--core/modules/comment/src/Tests/CommentLinksAlterTest.php2
-rw-r--r--core/modules/comment/src/Tests/CommentLinksTest.php24
-rw-r--r--core/modules/comment/src/Tests/CommentNewIndicatorTest.php36
-rw-r--r--core/modules/comment/src/Tests/CommentNodeAccessTest.php6
-rw-r--r--core/modules/comment/src/Tests/CommentNodeChangesTest.php2
-rw-r--r--core/modules/comment/src/Tests/CommentNonNodeTest.php82
-rw-r--r--core/modules/comment/src/Tests/CommentPagerTest.php104
-rw-r--r--core/modules/comment/src/Tests/CommentPreviewTest.php16
-rw-r--r--core/modules/comment/src/Tests/CommentRssTest.php4
-rw-r--r--core/modules/comment/src/Tests/CommentStatisticsTest.php20
-rw-r--r--core/modules/comment/src/Tests/CommentTestBase.php42
-rw-r--r--core/modules/comment/src/Tests/CommentTestTrait.php34
-rw-r--r--core/modules/comment/src/Tests/CommentThreadingTest.php10
-rw-r--r--core/modules/comment/src/Tests/CommentTitleTest.php6
-rw-r--r--core/modules/comment/src/Tests/CommentTokenReplaceTest.php22
-rw-r--r--core/modules/comment/src/Tests/CommentTranslationUITest.php52
-rw-r--r--core/modules/comment/src/Tests/CommentTypeTest.php42
-rw-r--r--core/modules/comment/src/Tests/CommentUninstallTest.php8
-rw-r--r--core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php18
-rw-r--r--core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php26
-rw-r--r--core/modules/comment/src/Tests/Views/CommentRestExportTest.php4
-rw-r--r--core/modules/comment/src/Tests/Views/CommentRowTest.php2
-rw-r--r--core/modules/comment/src/Tests/Views/CommentTestBase.php14
-rw-r--r--core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php20
-rw-r--r--core/modules/comment/src/Tests/Views/FilterUserUIDTest.php24
-rw-r--r--core/modules/comment/src/Tests/Views/RowRssTest.php2
-rw-r--r--core/modules/comment/src/Tests/Views/WizardTest.php14
-rw-r--r--core/modules/comment/tests/modules/comment_test/comment_test.module14
-rw-r--r--core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php18
-rw-r--r--core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php18
-rw-r--r--core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php20
-rw-r--r--core/modules/comment/tests/src/Kernel/CommentValidationTest.php50
-rw-r--r--core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php4
-rw-r--r--core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php10
-rw-r--r--core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php4
-rw-r--r--core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php74
-rw-r--r--core/modules/comment/tests/src/Unit/CommentManagerTest.php12
-rw-r--r--core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php6
-rw-r--r--core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php4
-rw-r--r--core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php24
-rw-r--r--core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php44
-rw-r--r--core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php64
-rw-r--r--core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php48
-rw-r--r--core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php60
-rw-r--r--core/modules/config/config.module16
-rw-r--r--core/modules/config/src/ConfigSubscriber.php2
-rw-r--r--core/modules/config/src/Controller/ConfigController.php36
-rw-r--r--core/modules/config/src/Form/ConfigExportForm.php4
-rw-r--r--core/modules/config/src/Form/ConfigImportForm.php14
-rw-r--r--core/modules/config/src/Form/ConfigSingleExportForm.php32
-rw-r--r--core/modules/config/src/Form/ConfigSingleImportForm.php58
-rw-r--r--core/modules/config/src/Form/ConfigSync.php78
-rw-r--r--core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php10
-rw-r--r--core/modules/config/src/Tests/ConfigEntityListTest.php76
-rw-r--r--core/modules/config/src/Tests/ConfigEntityTest.php78
-rw-r--r--core/modules/config/src/Tests/ConfigExportImportUITest.php68
-rw-r--r--core/modules/config/src/Tests/ConfigExportUITest.php14
-rw-r--r--core/modules/config/src/Tests/ConfigFormOverrideTest.php10
-rw-r--r--core/modules/config/src/Tests/ConfigImportAllTest.php6
-rw-r--r--core/modules/config/src/Tests/ConfigImportInstallProfileTest.php8
-rw-r--r--core/modules/config/src/Tests/ConfigImportUITest.php116
-rw-r--r--core/modules/config/src/Tests/ConfigImportUploadTest.php6
-rw-r--r--core/modules/config/src/Tests/ConfigInstallWebTest.php40
-rw-r--r--core/modules/config/src/Tests/ConfigSingleImportExportTest.php54
-rw-r--r--core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php12
-rw-r--r--core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php4
-rw-r--r--core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php8
-rw-r--r--core/modules/config/tests/config_events_test/src/EventSubscriber.php10
-rw-r--r--core/modules/config/tests/config_import_test/src/EventSubscriber.php14
-rw-r--r--core/modules/config/tests/config_override_test/src/ConfigOverrider.php6
-rw-r--r--core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php10
-rw-r--r--core/modules/config/tests/config_test/src/ConfigTestController.php6
-rw-r--r--core/modules/config/tests/config_test/src/ConfigTestForm.php80
-rw-r--r--core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php2
-rw-r--r--core/modules/config/tests/config_test/src/Entity/ConfigTest.php6
-rw-r--r--core/modules/config/tests/config_test/src/TestInstallStorage.php2
-rw-r--r--core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php60
-rw-r--r--core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php4
-rw-r--r--core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php8
-rw-r--r--core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php6
-rw-r--r--core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php16
-rw-r--r--core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php6
-rw-r--r--core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php10
-rw-r--r--core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php2
-rw-r--r--core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php16
-rw-r--r--core/modules/config_translation/config_translation.api.php4
-rw-r--r--core/modules/config_translation/config_translation.module36
-rw-r--r--core/modules/config_translation/src/ConfigEntityMapper.php20
-rw-r--r--core/modules/config_translation/src/ConfigFieldMapper.php2
-rw-r--r--core/modules/config_translation/src/ConfigMapperManager.php14
-rw-r--r--core/modules/config_translation/src/ConfigNamesMapper.php36
-rw-r--r--core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php16
-rw-r--r--core/modules/config_translation/src/Controller/ConfigTranslationController.php44
-rw-r--r--core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php28
-rw-r--r--core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php18
-rw-r--r--core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php12
-rw-r--r--core/modules/config_translation/src/Form/ConfigTranslationAddForm.php6
-rw-r--r--core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php4
-rw-r--r--core/modules/config_translation/src/Form/ConfigTranslationEditForm.php6
-rw-r--r--core/modules/config_translation/src/Form/ConfigTranslationFormBase.php14
-rw-r--r--core/modules/config_translation/src/FormElement/DateFormat.php2
-rw-r--r--core/modules/config_translation/src/FormElement/FormElementBase.php22
-rw-r--r--core/modules/config_translation/src/FormElement/ListElement.php12
-rw-r--r--core/modules/config_translation/src/FormElement/PluralVariants.php30
-rw-r--r--core/modules/config_translation/src/FormElement/TextFormat.php10
-rw-r--r--core/modules/config_translation/src/FormElement/Textarea.php4
-rw-r--r--core/modules/config_translation/src/FormElement/Textfield.php4
-rw-r--r--core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php2
-rw-r--r--core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php2
-rw-r--r--core/modules/config_translation/src/Plugin/migrate/source/d6/I18nProfileField.php4
-rw-r--r--core/modules/config_translation/src/Routing/RouteSubscriber.php2
-rw-r--r--core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php4
-rw-r--r--core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php20
-rw-r--r--core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php214
-rw-r--r--core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php2
-rw-r--r--core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module2
-rw-r--r--core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php8
-rw-r--r--core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php62
-rw-r--r--core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php8
-rw-r--r--core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php16
-rw-r--r--core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php6
-rw-r--r--core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php90
-rw-r--r--core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php158
-rw-r--r--core/modules/contact/contact.module64
-rw-r--r--core/modules/contact/contact.views.inc8
-rw-r--r--core/modules/contact/src/ContactFormEditForm.php46
-rw-r--r--core/modules/contact/src/Controller/ContactController.php16
-rw-r--r--core/modules/contact/src/Entity/ContactForm.php2
-rw-r--r--core/modules/contact/src/Entity/Message.php16
-rw-r--r--core/modules/contact/src/MailHandler.php12
-rw-r--r--core/modules/contact/src/MessageForm.php38
-rw-r--r--core/modules/contact/src/MessageViewBuilder.php6
-rw-r--r--core/modules/contact/src/Plugin/migrate/source/ContactCategory.php8
-rw-r--r--core/modules/contact/src/Plugin/views/field/ContactLink.php4
-rw-r--r--core/modules/contact/src/Tests/ContactPersonalTest.php38
-rw-r--r--core/modules/contact/src/Tests/ContactSitewideTest.php98
-rw-r--r--core/modules/contact/src/Tests/ContactStorageTest.php10
-rw-r--r--core/modules/contact/src/Tests/Views/ContactFieldsTest.php6
-rw-r--r--core/modules/contact/src/Tests/Views/ContactLinkTest.php22
-rw-r--r--core/modules/contact/tests/drupal-7.contact.database.php10
-rw-r--r--core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module6
-rw-r--r--core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php8
-rw-r--r--core/modules/contact/tests/src/Functional/ContactLanguageTest.php8
-rw-r--r--core/modules/contact/tests/src/Kernel/MessageEntityTest.php8
-rw-r--r--core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php2
-rw-r--r--core/modules/contact/tests/src/Unit/MailHandlerTest.php84
-rw-r--r--core/modules/content_moderation/src/ContentModerationStateStorageSchema.php6
-rw-r--r--core/modules/content_moderation/src/Entity/ContentModerationState.php2
-rw-r--r--core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php2
-rw-r--r--core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php2
-rw-r--r--core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php4
-rw-r--r--core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php2
-rw-r--r--core/modules/content_translation/content_translation.admin.inc126
-rw-r--r--core/modules/content_translation/content_translation.module58
-rw-r--r--core/modules/content_translation/src/ContentTranslationHandler.php96
-rw-r--r--core/modules/content_translation/src/ContentTranslationManager.php6
-rw-r--r--core/modules/content_translation/src/Controller/ContentTranslationController.php88
-rw-r--r--core/modules/content_translation/src/FieldTranslationSynchronizer.php16
-rw-r--r--core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php4
-rw-r--r--core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php98
-rw-r--r--core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php4
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php40
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php4
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationLanguageChangeTest.php4
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php62
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php58
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationTestBase.php20
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php80
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php20
-rw-r--r--core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php6
-rw-r--r--core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php6
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php12
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php2
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationStandardFieldsTest.php8
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php20
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php6
-rw-r--r--core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php80
-rw-r--r--core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php18
-rw-r--r--core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php2
-rw-r--r--core/modules/content_translation/tests/src/Kernel/ContentTranslationSyncUnitTest.php18
-rw-r--r--core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php14
-rw-r--r--core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php28
-rw-r--r--core/modules/contextual/contextual.module48
-rw-r--r--core/modules/contextual/contextual.views.inc8
-rw-r--r--core/modules/contextual/src/ContextualController.php6
-rw-r--r--core/modules/contextual/src/Element/ContextualLinks.php38
-rw-r--r--core/modules/contextual/src/Element/ContextualLinksPlaceholder.php10
-rw-r--r--core/modules/contextual/src/Plugin/views/field/ContextualLinks.php42
-rw-r--r--core/modules/contextual/src/Tests/ContextualDynamicContextTest.php32
-rw-r--r--core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php94
-rw-r--r--core/modules/datetime/datetime.module6
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php10
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php10
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php12
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php2
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php22
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php46
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php32
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php42
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php8
-rw-r--r--core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php4
-rw-r--r--core/modules/datetime/src/Tests/DateTimeFieldTest.php210
-rw-r--r--core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php12
-rw-r--r--core/modules/datetime_range/datetime_range.module6
-rw-r--r--core/modules/datetime_range/src/Tests/DateRangeFieldTest.php72
-rw-r--r--core/modules/dblog/dblog.admin.inc10
-rw-r--r--core/modules/dblog/dblog.install64
-rw-r--r--core/modules/dblog/dblog.module22
-rw-r--r--core/modules/dblog/dblog.views.inc222
-rw-r--r--core/modules/dblog/src/Controller/DbLogController.php188
-rw-r--r--core/modules/dblog/src/Form/DblogClearLogConfirmForm.php2
-rw-r--r--core/modules/dblog/src/Form/DblogFilterForm.php28
-rw-r--r--core/modules/dblog/src/Logger/DbLog.php6
-rw-r--r--core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php4
-rw-r--r--core/modules/dblog/src/Plugin/views/field/DblogMessage.php6
-rw-r--r--core/modules/dblog/src/Tests/DbLogTest.php122
-rw-r--r--core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php6
-rw-r--r--core/modules/dblog/tests/src/Functional/ConnectionFailureTest.php2
-rw-r--r--core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php6
-rw-r--r--core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php34
-rw-r--r--core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php6
-rw-r--r--core/modules/editor/editor.admin.inc52
-rw-r--r--core/modules/editor/editor.api.php2
-rw-r--r--core/modules/editor/editor.module70
-rw-r--r--core/modules/editor/src/Ajax/EditorDialogSave.php4
-rw-r--r--core/modules/editor/src/EditorController.php2
-rw-r--r--core/modules/editor/src/EditorXssFilter/Standard.php8
-rw-r--r--core/modules/editor/src/Element.php8
-rw-r--r--core/modules/editor/src/Entity/Editor.php4
-rw-r--r--core/modules/editor/src/Form/EditorImageDialog.php70
-rw-r--r--core/modules/editor/src/Form/EditorLinkDialog.php20
-rw-r--r--core/modules/editor/src/Plugin/EditorBase.php2
-rw-r--r--core/modules/editor/src/Plugin/EditorManager.php12
-rw-r--r--core/modules/editor/src/Plugin/Filter/EditorFileReference.php2
-rw-r--r--core/modules/editor/src/Plugin/InPlaceEditor/Editor.php4
-rw-r--r--core/modules/editor/src/Tests/EditorAdminTest.php26
-rw-r--r--core/modules/editor/src/Tests/EditorLoadingTest.php84
-rw-r--r--core/modules/editor/src/Tests/EditorSecurityTest.php206
-rw-r--r--core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php44
-rw-r--r--core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php12
-rw-r--r--core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php12
-rw-r--r--core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php10
-rw-r--r--core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php48
-rw-r--r--core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php4
-rw-r--r--core/modules/editor/tests/src/Kernel/EditorManagerTest.php36
-rw-r--r--core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php40
-rw-r--r--core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php6
-rw-r--r--core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php226
-rw-r--r--core/modules/field/field.api.php4
-rw-r--r--core/modules/field/field.module30
-rw-r--r--core/modules/field/field.purge.inc16
-rw-r--r--core/modules/field/src/ConfigImporterFieldPurger.php8
-rw-r--r--core/modules/field/src/Entity/FieldConfig.php6
-rw-r--r--core/modules/field/src/Entity/FieldStorageConfig.php20
-rw-r--r--core/modules/field/src/FieldConfigStorage.php12
-rw-r--r--core/modules/field/src/FieldStorageConfigStorage.php10
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php4
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceDefaults.php4
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php4
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php42
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php28
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php2
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php4
-rw-r--r--core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php2
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d6/Field.php12
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php16
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerFormDisplay.php14
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php14
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d7/Field.php18
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php24
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php24
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php26
-rw-r--r--core/modules/field/src/Tests/Boolean/BooleanFieldTest.php48
-rw-r--r--core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php26
-rw-r--r--core/modules/field/src/Tests/Email/EmailFieldTest.php28
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php132
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php44
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceTestTrait.php18
-rw-r--r--core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php6
-rw-r--r--core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php16
-rw-r--r--core/modules/field/src/Tests/FieldTestBase.php4
-rw-r--r--core/modules/field/src/Tests/FormTest.php172
-rw-r--r--core/modules/field/src/Tests/NestedFormTest.php70
-rw-r--r--core/modules/field/src/Tests/Number/NumberFieldTest.php272
-rw-r--r--core/modules/field/src/Tests/String/StringFieldTest.php24
-rw-r--r--core/modules/field/src/Tests/Views/FieldTestBase.php10
-rw-r--r--core/modules/field/src/Tests/Views/FieldUITest.php24
-rw-r--r--core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php42
-rw-r--r--core/modules/field/src/Tests/reEnableModuleFieldTest.php36
-rw-r--r--core/modules/field/tests/modules/field_test/field_test.entity.inc2
-rw-r--r--core/modules/field/tests/modules/field_test/field_test.field.inc2
-rw-r--r--core/modules/field/tests/modules/field_test/field_test.module6
-rw-r--r--core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php6
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php2
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php16
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php10
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php14
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php18
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php4
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php16
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php50
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php18
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php24
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php2
-rw-r--r--core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module8
-rw-r--r--core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php30
-rw-r--r--core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php56
-rw-r--r--core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php72
-rw-r--r--core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php54
-rw-r--r--core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php46
-rw-r--r--core/modules/field/tests/src/Functional/FieldAccessTest.php18
-rw-r--r--core/modules/field/tests/src/Functional/FieldHelpTest.php6
-rw-r--r--core/modules/field/tests/src/Functional/FieldTestBase.php4
-rw-r--r--core/modules/field/tests/src/Functional/TranslationWebTest.php22
-rw-r--r--core/modules/field/tests/src/Kernel/Boolean/BooleanItemTest.php8
-rw-r--r--core/modules/field/tests/src/Kernel/BulkDeleteTest.php66
-rw-r--r--core/modules/field/tests/src/Kernel/DisplayApiTest.php102
-rw-r--r--core/modules/field/tests/src/Kernel/Email/EmailItemTest.php8
-rw-r--r--core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php72
-rw-r--r--core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php24
-rw-r--r--core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php10
-rw-r--r--core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php78
-rw-r--r--core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php62
-rw-r--r--core/modules/field/tests/src/Kernel/FieldCrudTest.php14
-rw-r--r--core/modules/field/tests/src/Kernel/FieldDataCountTest.php22
-rw-r--r--core/modules/field/tests/src/Kernel/FieldImportChangeTest.php2
-rw-r--r--core/modules/field/tests/src/Kernel/FieldImportCreateTest.php2
-rw-r--r--core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php36
-rw-r--r--core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php26
-rw-r--r--core/modules/field/tests/src/Kernel/FieldKernelTestBase.php32
-rw-r--r--core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php118
-rw-r--r--core/modules/field/tests/src/Kernel/FieldTypePluginManagerTest.php24
-rw-r--r--core/modules/field/tests/src/Kernel/FieldValidationTest.php14
-rw-r--r--core/modules/field/tests/src/Kernel/FormatterPluginManagerTest.php8
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php40
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php16
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php24
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php18
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php36
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php12
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php4
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php4
-rw-r--r--core/modules/field/tests/src/Kernel/Number/NumberItemTest.php8
-rw-r--r--core/modules/field/tests/src/Kernel/ShapeItemTest.php6
-rw-r--r--core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php20
-rw-r--r--core/modules/field/tests/src/Kernel/String/StringFormatterTest.php20
-rw-r--r--core/modules/field/tests/src/Kernel/TestItemTest.php28
-rw-r--r--core/modules/field/tests/src/Kernel/TestItemWithDependenciesTest.php6
-rw-r--r--core/modules/field/tests/src/Kernel/TestObjectItemTest.php6
-rw-r--r--core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php2
-rw-r--r--core/modules/field/tests/src/Kernel/TranslationTest.php34
-rw-r--r--core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php8
-rw-r--r--core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php40
-rw-r--r--core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php38
-rw-r--r--core/modules/field_ui/field_ui.api.php12
-rw-r--r--core/modules/field_ui/field_ui.module48
-rw-r--r--core/modules/field_ui/src/Controller/EntityDisplayModeController.php28
-rw-r--r--core/modules/field_ui/src/Element/FieldUiTable.php2
-rw-r--r--core/modules/field_ui/src/EntityDisplayModeListBuilder.php22
-rw-r--r--core/modules/field_ui/src/FieldConfigListBuilder.php50
-rw-r--r--core/modules/field_ui/src/FieldStorageConfigListBuilder.php14
-rw-r--r--core/modules/field_ui/src/FieldUI.php8
-rw-r--r--core/modules/field_ui/src/Form/EntityDisplayFormBase.php286
-rw-r--r--core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php2
-rw-r--r--core/modules/field_ui/src/Form/EntityDisplayModeDeleteForm.php2
-rw-r--r--core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php16
-rw-r--r--core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php18
-rw-r--r--core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php40
-rw-r--r--core/modules/field_ui/src/Form/FieldConfigDeleteForm.php4
-rw-r--r--core/modules/field_ui/src/Form/FieldConfigEditForm.php54
-rw-r--r--core/modules/field_ui/src/Form/FieldStorageAddForm.php118
-rw-r--r--core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php52
-rw-r--r--core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php8
-rw-r--r--core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php46
-rw-r--r--core/modules/field_ui/src/Routing/RouteSubscriber.php60
-rw-r--r--core/modules/field_ui/src/Tests/FieldUIDeleteTest.php12
-rw-r--r--core/modules/field_ui/src/Tests/FieldUiTestTrait.php26
-rw-r--r--core/modules/field_ui/src/Tests/ManageDisplayTest.php126
-rw-r--r--core/modules/field_ui/src/Tests/ManageFieldsTest.php144
-rw-r--r--core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module36
-rw-r--r--core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php32
-rw-r--r--core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php6
-rw-r--r--core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php18
-rw-r--r--core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php166
-rw-r--r--core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php82
-rw-r--r--core/modules/file/file.api.php6
-rw-r--r--core/modules/file/file.field.inc66
-rw-r--r--core/modules/file/file.install46
-rw-r--r--core/modules/file/file.module246
-rw-r--r--core/modules/file/file.views.inc24
-rw-r--r--core/modules/file/src/Controller/FileWidgetAjaxController.php8
-rw-r--r--core/modules/file/src/Element/ManagedFile.php6
-rw-r--r--core/modules/file/src/Entity/File.php2
-rw-r--r--core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php14
-rw-r--r--core/modules/file/src/FileViewsData.php220
-rw-r--r--core/modules/file/src/Plugin/Field/FieldFormatter/FileExtensionFormatter.php4
-rw-r--r--core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php4
-rw-r--r--core/modules/file/src/Plugin/Field/FieldFormatter/GenericFileFormatter.php12
-rw-r--r--core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php8
-rw-r--r--core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php30
-rw-r--r--core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php10
-rw-r--r--core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php4
-rw-r--r--core/modules/file/src/Plugin/Field/FieldType/FileItem.php108
-rw-r--r--core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php120
-rw-r--r--core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php2
-rw-r--r--core/modules/file/src/Plugin/migrate/source/d6/File.php4
-rw-r--r--core/modules/file/src/Plugin/migrate/source/d6/Upload.php8
-rw-r--r--core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php14
-rw-r--r--core/modules/file/src/Plugin/migrate/source/d7/File.php6
-rw-r--r--core/modules/file/src/Plugin/views/argument/Fid.php2
-rw-r--r--core/modules/file/src/Plugin/views/field/File.php6
-rw-r--r--core/modules/file/src/Tests/DownloadTest.php8
-rw-r--r--core/modules/file/src/Tests/FileFieldAnonymousSubmissionTest.php48
-rw-r--r--core/modules/file/src/Tests/FileFieldDisplayTest.php56
-rw-r--r--core/modules/file/src/Tests/FileFieldPathTest.php18
-rw-r--r--core/modules/file/src/Tests/FileFieldRSSContentTest.php16
-rw-r--r--core/modules/file/src/Tests/FileFieldRevisionTest.php26
-rw-r--r--core/modules/file/src/Tests/FileFieldTestBase.php66
-rw-r--r--core/modules/file/src/Tests/FileFieldValidateTest.php62
-rw-r--r--core/modules/file/src/Tests/FileFieldWidgetTest.php114
-rw-r--r--core/modules/file/src/Tests/FileListingTest.php28
-rw-r--r--core/modules/file/src/Tests/FileManagedFileElementTest.php58
-rw-r--r--core/modules/file/src/Tests/FileManagedTestBase.php36
-rw-r--r--core/modules/file/src/Tests/FileOnTranslatedEntityTest.php34
-rw-r--r--core/modules/file/src/Tests/FilePrivateTest.php22
-rw-r--r--core/modules/file/src/Tests/FileTokenReplaceTest.php12
-rw-r--r--core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php28
-rw-r--r--core/modules/file/src/Tests/RemoteFileSaveUploadTest.php2
-rw-r--r--core/modules/file/src/Tests/SaveUploadTest.php92
-rw-r--r--core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php20
-rw-r--r--core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php20
-rw-r--r--core/modules/file/tests/file_test/file_test.module60
-rw-r--r--core/modules/file/tests/file_test/src/Form/FileTestForm.php46
-rw-r--r--core/modules/file/tests/src/Functional/FileFieldTestBase.php66
-rw-r--r--core/modules/file/tests/src/Functional/FileManagedAccessTest.php12
-rw-r--r--core/modules/file/tests/src/Functional/FileManagedTestBase.php36
-rw-r--r--core/modules/file/tests/src/Kernel/AccessTest.php6
-rw-r--r--core/modules/file/tests/src/Kernel/CopyTest.php8
-rw-r--r--core/modules/file/tests/src/Kernel/DeleteTest.php12
-rw-r--r--core/modules/file/tests/src/Kernel/FileItemTest.php12
-rw-r--r--core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php40
-rw-r--r--core/modules/file/tests/src/Kernel/LoadTest.php16
-rw-r--r--core/modules/file/tests/src/Kernel/Migrate/d6/MigrateFileTest.php8
-rw-r--r--core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php2
-rw-r--r--core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php2
-rw-r--r--core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadFieldTest.php2
-rw-r--r--core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php2
-rw-r--r--core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadTest.php8
-rw-r--r--core/modules/file/tests/src/Kernel/MoveTest.php12
-rw-r--r--core/modules/file/tests/src/Kernel/SaveDataTest.php10
-rw-r--r--core/modules/file/tests/src/Kernel/SaveTest.php14
-rw-r--r--core/modules/file/tests/src/Kernel/UsageTest.php28
-rw-r--r--core/modules/file/tests/src/Kernel/ValidateTest.php20
-rw-r--r--core/modules/file/tests/src/Kernel/Views/ExtensionViewsFieldTest.php6
-rw-r--r--core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php14
-rw-r--r--core/modules/filter/filter.api.php4
-rw-r--r--core/modules/filter/filter.module80
-rw-r--r--core/modules/filter/src/Annotation/Filter.php2
-rw-r--r--core/modules/filter/src/Controller/FilterController.php4
-rw-r--r--core/modules/filter/src/Element/ProcessedText.php16
-rw-r--r--core/modules/filter/src/Element/TextFormat.php46
-rw-r--r--core/modules/filter/src/Entity/FilterFormat.php12
-rw-r--r--core/modules/filter/src/FilterFormatAccessControlHandler.php2
-rw-r--r--core/modules/filter/src/FilterFormatAddForm.php2
-rw-r--r--core/modules/filter/src/FilterFormatEditForm.php2
-rw-r--r--core/modules/filter/src/FilterFormatFormBase.php82
-rw-r--r--core/modules/filter/src/FilterPluginCollection.php2
-rw-r--r--core/modules/filter/src/FilterPluginManager.php2
-rw-r--r--core/modules/filter/src/Form/FilterDisableForm.php4
-rw-r--r--core/modules/filter/src/Plugin/Filter/FilterAlign.php4
-rw-r--r--core/modules/filter/src/Plugin/Filter/FilterCaption.php14
-rw-r--r--core/modules/filter/src/Plugin/Filter/FilterHtml.php164
-rw-r--r--core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php2
-rw-r--r--core/modules/filter/src/Plugin/Filter/FilterNull.php4
-rw-r--r--core/modules/filter/src/Plugin/Filter/FilterUrl.php4
-rw-r--r--core/modules/filter/src/Plugin/FilterBase.php14
-rw-r--r--core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php2
-rw-r--r--core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php14
-rw-r--r--core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php4
-rw-r--r--core/modules/filter/src/Tests/FilterAdminTest.php138
-rw-r--r--core/modules/filter/src/Tests/FilterFormTest.php70
-rw-r--r--core/modules/filter/src/Tests/FilterFormatAccessTest.php40
-rw-r--r--core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php44
-rw-r--r--core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php72
-rw-r--r--core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php8
-rw-r--r--core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php4
-rw-r--r--core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPlaceholders.php2
-rw-r--r--core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php2
-rw-r--r--core/modules/filter/tests/src/Functional/FilterDefaultFormatTest.php18
-rw-r--r--core/modules/filter/tests/src/Functional/FilterHooksTest.php22
-rw-r--r--core/modules/filter/tests/src/Functional/FilterNoFormatTest.php2
-rw-r--r--core/modules/filter/tests/src/Functional/FilterSecurityTest.php20
-rw-r--r--core/modules/filter/tests/src/Kernel/FilterAPITest.php250
-rw-r--r--core/modules/filter/tests/src/Kernel/FilterCrudTest.php30
-rw-r--r--core/modules/filter/tests/src/Kernel/FilterDefaultConfigTest.php28
-rw-r--r--core/modules/filter/tests/src/Kernel/FilterKernelTest.php262
-rw-r--r--core/modules/filter/tests/src/Kernel/FilterSettingsTest.php16
-rw-r--r--core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php2
-rw-r--r--core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php6
-rw-r--r--core/modules/forum/forum.install112
-rw-r--r--core/modules/forum/forum.module154
-rw-r--r--core/modules/forum/forum.views.inc142
-rw-r--r--core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php4
-rw-r--r--core/modules/forum/src/Controller/ForumController.php20
-rw-r--r--core/modules/forum/src/Form/DeleteForm.php6
-rw-r--r--core/modules/forum/src/Form/ForumForm.php16
-rw-r--r--core/modules/forum/src/Form/Overview.php4
-rw-r--r--core/modules/forum/src/ForumIndexStorage.php32
-rw-r--r--core/modules/forum/src/ForumManager.php72
-rw-r--r--core/modules/forum/src/ForumSettingsForm.php20
-rw-r--r--core/modules/forum/src/Plugin/Block/ForumBlockBase.php20
-rw-r--r--core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php2
-rw-r--r--core/modules/forum/src/Tests/Views/ForumIntegrationTest.php34
-rw-r--r--core/modules/forum/tests/src/Functional/ForumBlockTest.php32
-rw-r--r--core/modules/forum/tests/src/Functional/ForumIndexTest.php16
-rw-r--r--core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php18
-rw-r--r--core/modules/forum/tests/src/Functional/ForumTest.php116
-rw-r--r--core/modules/forum/tests/src/Functional/ForumUninstallTest.php30
-rw-r--r--core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php2
-rw-r--r--core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php42
-rw-r--r--core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php78
-rw-r--r--core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php78
-rw-r--r--core/modules/forum/tests/src/Unit/ForumManagerTest.php6
-rw-r--r--core/modules/hal/hal.api.php4
-rw-r--r--core/modules/hal/hal.module4
-rw-r--r--core/modules/hal/src/LinkManager/LinkManager.php6
-rw-r--r--core/modules/hal/src/LinkManager/RelationLinkManager.php16
-rw-r--r--core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php2
-rw-r--r--core/modules/hal/src/LinkManager/TypeLinkManager.php16
-rw-r--r--core/modules/hal/src/LinkManager/TypeLinkManagerInterface.php4
-rw-r--r--core/modules/hal/src/Normalizer/ContentEntityNormalizer.php34
-rw-r--r--core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php22
-rw-r--r--core/modules/hal/src/Normalizer/FieldItemNormalizer.php10
-rw-r--r--core/modules/hal/src/Normalizer/FieldNormalizer.php6
-rw-r--r--core/modules/hal/src/Normalizer/FileEntityNormalizer.php4
-rw-r--r--core/modules/hal/src/Normalizer/NormalizerBase.php2
-rw-r--r--core/modules/hal/tests/modules/hal_test/hal_test.module8
-rw-r--r--core/modules/hal/tests/src/Functional/FileDenormalizeTest.php16
-rw-r--r--core/modules/hal/tests/src/Kernel/DenormalizeTest.php116
-rw-r--r--core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php4
-rw-r--r--core/modules/hal/tests/src/Kernel/FileNormalizeTest.php18
-rw-r--r--core/modules/hal/tests/src/Kernel/NormalizeTest.php168
-rw-r--r--core/modules/hal/tests/src/Kernel/NormalizerTestBase.php24
-rw-r--r--core/modules/hal/tests/src/Unit/FieldItemNormalizerDenormalizeExceptionsUnitTest.php4
-rw-r--r--core/modules/hal/tests/src/Unit/FieldNormalizerDenormalizeExceptionsUnitTest.php4
-rw-r--r--core/modules/hal/tests/src/Unit/NormalizerDenormalizeExceptionsUnitTestBase.php10
-rw-r--r--core/modules/help/help.api.php2
-rw-r--r--core/modules/help/help.module16
-rw-r--r--core/modules/help/src/Controller/HelpController.php18
-rw-r--r--core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php8
-rw-r--r--core/modules/help/tests/src/Functional/ExperimentalHelpTest.php2
-rw-r--r--core/modules/help/tests/src/Functional/HelpTest.php18
-rw-r--r--core/modules/help/tests/src/Functional/NoHelpTest.php4
-rw-r--r--core/modules/history/history.install64
-rw-r--r--core/modules/history/history.module22
-rw-r--r--core/modules/history/history.views.inc26
-rw-r--r--core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php16
-rw-r--r--core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php4
-rw-r--r--core/modules/history/src/Tests/HistoryTest.php44
-rw-r--r--core/modules/history/src/Tests/Views/HistoryTimestampTest.php22
-rw-r--r--core/modules/image/image.admin.inc46
-rw-r--r--core/modules/image/image.field.inc14
-rw-r--r--core/modules/image/image.install18
-rw-r--r--core/modules/image/image.module82
-rw-r--r--core/modules/image/image.views.inc24
-rw-r--r--core/modules/image/src/Controller/ImageStyleDownloadController.php12
-rw-r--r--core/modules/image/src/Entity/ImageStyle.php16
-rw-r--r--core/modules/image/src/Form/ImageEffectAddForm.php2
-rw-r--r--core/modules/image/src/Form/ImageEffectDeleteForm.php4
-rw-r--r--core/modules/image/src/Form/ImageEffectEditForm.php2
-rw-r--r--core/modules/image/src/Form/ImageEffectFormBase.php22
-rw-r--r--core/modules/image/src/Form/ImageStyleAddForm.php2
-rw-r--r--core/modules/image/src/Form/ImageStyleDeleteForm.php2
-rw-r--r--core/modules/image/src/Form/ImageStyleEditForm.php122
-rw-r--r--core/modules/image/src/Form/ImageStyleFlushForm.php4
-rw-r--r--core/modules/image/src/Form/ImageStyleFormBase.php14
-rw-r--r--core/modules/image/src/ImageEffectBase.php22
-rw-r--r--core/modules/image/src/ImageStyleListBuilder.php8
-rw-r--r--core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php30
-rw-r--r--core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php4
-rw-r--r--core/modules/image/src/Plugin/Field/FieldType/ImageItem.php178
-rw-r--r--core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php52
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php16
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php18
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php2
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php18
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php22
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php2
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php14
-rw-r--r--core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php2
-rw-r--r--core/modules/image/src/Plugin/migrate/source/d6/ImageCachePreset.php2
-rw-r--r--core/modules/image/src/Plugin/migrate/source/d7/ImageStyles.php2
-rw-r--r--core/modules/image/src/Routing/ImageStyleRoutes.php10
-rw-r--r--core/modules/image/src/Tests/FileMoveTest.php2
-rw-r--r--core/modules/image/src/Tests/ImageAdminStylesTest.php146
-rw-r--r--core/modules/image/src/Tests/ImageDimensionsTest.php76
-rw-r--r--core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php88
-rw-r--r--core/modules/image/src/Tests/ImageFieldDisplayTest.php122
-rw-r--r--core/modules/image/src/Tests/ImageFieldTestBase.php18
-rw-r--r--core/modules/image/src/Tests/ImageFieldValidateTest.php14
-rw-r--r--core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php34
-rw-r--r--core/modules/image/src/Tests/ImageStyleFlushTest.php32
-rw-r--r--core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php4
-rw-r--r--core/modules/image/src/Tests/ImageThemeFunctionTest.php58
-rw-r--r--core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php20
-rw-r--r--core/modules/image/tests/modules/image_module_test/image_module_test.module2
-rw-r--r--core/modules/image/tests/src/Functional/ImageEffectsTest.php44
-rw-r--r--core/modules/image/tests/src/Functional/ImageFieldTestBase.php18
-rw-r--r--core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php6
-rw-r--r--core/modules/image/tests/src/Kernel/ImageFieldCreationTrait.php14
-rw-r--r--core/modules/image/tests/src/Kernel/ImageFormatterTest.php8
-rw-r--r--core/modules/image/tests/src/Kernel/ImageItemTest.php12
-rw-r--r--core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php4
-rw-r--r--core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php2
-rw-r--r--core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php2
-rw-r--r--core/modules/image/tests/src/Kernel/Views/ImageViewsDataTest.php18
-rw-r--r--core/modules/image/tests/src/Unit/ImageStyleTest.php34
-rw-r--r--core/modules/language/language.admin.inc76
-rw-r--r--core/modules/language/language.api.php14
-rw-r--r--core/modules/language/language.module66
-rw-r--r--core/modules/language/src/Config/LanguageConfigFactoryOverride.php2
-rw-r--r--core/modules/language/src/Config/LanguageConfigOverride.php2
-rw-r--r--core/modules/language/src/ConfigurableLanguageManager.php26
-rw-r--r--core/modules/language/src/DefaultLanguageItem.php2
-rw-r--r--core/modules/language/src/Element/LanguageConfiguration.php38
-rw-r--r--core/modules/language/src/Entity/ConfigurableLanguage.php8
-rw-r--r--core/modules/language/src/EventSubscriber/ConfigSubscriber.php2
-rw-r--r--core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php2
-rw-r--r--core/modules/language/src/Form/ContentLanguageSettingsForm.php58
-rw-r--r--core/modules/language/src/Form/LanguageAddForm.php64
-rw-r--r--core/modules/language/src/Form/LanguageDeleteForm.php4
-rw-r--r--core/modules/language/src/Form/LanguageEditForm.php10
-rw-r--r--core/modules/language/src/Form/LanguageFormBase.php32
-rw-r--r--core/modules/language/src/Form/NegotiationBrowserDeleteForm.php6
-rw-r--r--core/modules/language/src/Form/NegotiationBrowserForm.php38
-rw-r--r--core/modules/language/src/Form/NegotiationConfigureForm.php88
-rw-r--r--core/modules/language/src/Form/NegotiationSelectedForm.php4
-rw-r--r--core/modules/language/src/Form/NegotiationSessionForm.php4
-rw-r--r--core/modules/language/src/Form/NegotiationUrlForm.php66
-rw-r--r--core/modules/language/src/HttpKernel/PathProcessorLanguage.php6
-rw-r--r--core/modules/language/src/LanguageListBuilder.php18
-rw-r--r--core/modules/language/src/LanguageNegotiator.php24
-rw-r--r--core/modules/language/src/LanguageServiceProvider.php4
-rw-r--r--core/modules/language/src/Plugin/Block/LanguageBlock.php14
-rw-r--r--core/modules/language/src/Plugin/Condition/Language.php18
-rw-r--r--core/modules/language/src/Plugin/Derivative/LanguageBlock.php2
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php12
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php14
-rw-r--r--core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php2
-rw-r--r--core/modules/language/src/Plugin/migrate/source/Language.php12
-rw-r--r--core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettings.php8
-rw-r--r--core/modules/language/src/Plugin/migrate/source/d7/LanguageContentSettings.php8
-rw-r--r--core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php8
-rw-r--r--core/modules/language/src/Tests/LanguageConfigurationElementTest.php48
-rw-r--r--core/modules/language/src/Tests/LanguageConfigurationTest.php52
-rw-r--r--core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php46
-rw-r--r--core/modules/language/src/Tests/LanguageListTest.php66
-rw-r--r--core/modules/language/src/Tests/LanguageLocaleListTest.php16
-rw-r--r--core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php12
-rw-r--r--core/modules/language/src/Tests/LanguageSwitchingTest.php188
-rw-r--r--core/modules/language/src/Tests/LanguageTourTest.php2
-rw-r--r--core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php196
-rw-r--r--core/modules/language/src/Tests/LanguageUrlRewritingTest.php22
-rw-r--r--core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php12
-rw-r--r--core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php4
-rw-r--r--core/modules/language/tests/language_test/language_test.module18
-rw-r--r--core/modules/language/tests/language_test/src/Controller/LanguageTestController.php44
-rw-r--r--core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php14
-rw-r--r--core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php6
-rw-r--r--core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php26
-rw-r--r--core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php12
-rw-r--r--core/modules/language/tests/src/Functional/LanguageConfigSchemaTest.php4
-rw-r--r--core/modules/language/tests/src/Functional/LanguageListModuleInstallTest.php6
-rw-r--r--core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php4
-rw-r--r--core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php28
-rw-r--r--core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php12
-rw-r--r--core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php12
-rw-r--r--core/modules/language/tests/src/Kernel/ConfigurableLanguageManagerTest.php2
-rw-r--r--core/modules/language/tests/src/Kernel/ConfigurableLanguageTest.php4
-rw-r--r--core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php16
-rw-r--r--core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php2
-rw-r--r--core/modules/language/tests/src/Kernel/LanguageConfigOverrideInstallTest.php6
-rw-r--r--core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php6
-rw-r--r--core/modules/language/tests/src/Kernel/LanguageFallbackTest.php10
-rw-r--r--core/modules/language/tests/src/Kernel/LanguageTestBase.php4
-rw-r--r--core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php4
-rw-r--r--core/modules/language/tests/src/Kernel/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php6
-rw-r--r--core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php2
-rw-r--r--core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php20
-rw-r--r--core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php10
-rw-r--r--core/modules/language/tests/src/Kernel/Views/FilterLanguageTest.php20
-rw-r--r--core/modules/language/tests/src/Kernel/Views/LanguageTestBase.php26
-rw-r--r--core/modules/language/tests/src/Unit/ConfigurableLanguageUnitTest.php6
-rw-r--r--core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php66
-rw-r--r--core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php62
-rw-r--r--core/modules/language/tests/src/Unit/Menu/LanguageLocalTasksTest.php18
-rw-r--r--core/modules/link/link.module14
-rw-r--r--core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php54
-rw-r--r--core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php10
-rw-r--r--core/modules/link/src/Plugin/Field/FieldType/LinkItem.php50
-rw-r--r--core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php64
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php2
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php2
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php2
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php2
-rw-r--r--core/modules/link/src/Tests/LinkFieldTest.php182
-rw-r--r--core/modules/link/src/Tests/Views/LinkViewsTokensTest.php16
-rw-r--r--core/modules/link/tests/src/Functional/LinkFieldUITest.php4
-rw-r--r--core/modules/link/tests/src/Kernel/LinkItemTest.php6
-rw-r--r--core/modules/locale/locale.api.php8
-rw-r--r--core/modules/locale/locale.batch.inc32
-rw-r--r--core/modules/locale/locale.bulk.inc108
-rw-r--r--core/modules/locale/locale.compare.inc34
-rw-r--r--core/modules/locale/locale.fetch.inc18
-rw-r--r--core/modules/locale/locale.install190
-rw-r--r--core/modules/locale/locale.module152
-rw-r--r--core/modules/locale/locale.pages.inc4
-rw-r--r--core/modules/locale/locale.translation.inc46
-rw-r--r--core/modules/locale/src/Controller/LocaleController.php4
-rw-r--r--core/modules/locale/src/Form/ExportForm.php50
-rw-r--r--core/modules/locale/src/Form/ImportForm.php74
-rw-r--r--core/modules/locale/src/Form/LocaleSettingsForm.php32
-rw-r--r--core/modules/locale/src/Form/TranslateEditForm.php60
-rw-r--r--core/modules/locale/src/Form/TranslateFilterForm.php30
-rw-r--r--core/modules/locale/src/Form/TranslateFormBase.php44
-rw-r--r--core/modules/locale/src/Form/TranslationStatusForm.php92
-rw-r--r--core/modules/locale/src/Gettext.php10
-rw-r--r--core/modules/locale/src/LocaleConfigManager.php38
-rw-r--r--core/modules/locale/src/LocaleConfigSubscriber.php6
-rw-r--r--core/modules/locale/src/LocaleEvent.php2
-rw-r--r--core/modules/locale/src/LocaleLookup.php18
-rw-r--r--core/modules/locale/src/LocaleProjectStorage.php14
-rw-r--r--core/modules/locale/src/LocaleTranslation.php4
-rw-r--r--core/modules/locale/src/PoDatabaseReader.php8
-rw-r--r--core/modules/locale/src/PoDatabaseWriter.php40
-rw-r--r--core/modules/locale/src/StringBase.php10
-rw-r--r--core/modules/locale/src/StringDatabaseStorage.php78
-rw-r--r--core/modules/locale/src/StringStorageInterface.php10
-rw-r--r--core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php30
-rw-r--r--core/modules/locale/src/Tests/LocaleConfigTranslationTest.php54
-rw-r--r--core/modules/locale/src/Tests/LocaleExportTest.php26
-rw-r--r--core/modules/locale/src/Tests/LocaleFileSystemFormTest.php8
-rw-r--r--core/modules/locale/src/Tests/LocaleImportFunctionalTest.php152
-rw-r--r--core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php26
-rw-r--r--core/modules/locale/src/Tests/LocaleLibraryAlterTest.php2
-rw-r--r--core/modules/locale/src/Tests/LocalePluralFormatTest.php150
-rw-r--r--core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php6
-rw-r--r--core/modules/locale/src/Tests/LocaleTranslationUiTest.php202
-rw-r--r--core/modules/locale/src/Tests/LocaleUpdateBase.php62
-rw-r--r--core/modules/locale/src/Tests/LocaleUpdateCronTest.php16
-rw-r--r--core/modules/locale/src/Tests/LocaleUpdateDevelopmentReleaseTest.php6
-rw-r--r--core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php20
-rw-r--r--core/modules/locale/src/Tests/LocaleUpdateTest.php122
-rw-r--r--core/modules/locale/src/TranslationString.php2
-rw-r--r--core/modules/locale/tests/modules/locale_test/locale_test.module44
-rw-r--r--core/modules/locale/tests/modules/locale_test_development_release/locale_test_development_release.module4
-rw-r--r--core/modules/locale/tests/src/Functional/LocaleContentTest.php60
-rw-r--r--core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php6
-rw-r--r--core/modules/locale/tests/src/Functional/LocalePathTest.php42
-rw-r--r--core/modules/locale/tests/src/Functional/LocaleStringTest.php74
-rw-r--r--core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php20
-rw-r--r--core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php14
-rw-r--r--core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php2
-rw-r--r--core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php8
-rw-r--r--core/modules/locale/tests/src/Kernel/Migrate/MigrateLocaleConfigsTest.php2
-rw-r--r--core/modules/locale/tests/src/Unit/LocaleLookupTest.php84
-rw-r--r--core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php22
-rw-r--r--core/modules/menu_link_content/menu_link_content.module6
-rw-r--r--core/modules/menu_link_content/src/Controller/MenuController.php4
-rw-r--r--core/modules/menu_link_content/src/Entity/MenuLinkContent.php56
-rw-r--r--core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php4
-rw-r--r--core/modules/menu_link_content/src/Form/MenuLinkContentForm.php6
-rw-r--r--core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php10
-rw-r--r--core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php4
-rw-r--r--core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php16
-rw-r--r--core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php20
-rw-r--r--core/modules/menu_link_content/tests/src/Functional/LinksTest.php62
-rw-r--r--core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php2
-rw-r--r--core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php2
-rw-r--r--core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php12
-rw-r--r--core/modules/menu_ui/menu_ui.module106
-rw-r--r--core/modules/menu_ui/src/Controller/MenuController.php2
-rw-r--r--core/modules/menu_ui/src/Form/MenuDeleteForm.php6
-rw-r--r--core/modules/menu_ui/src/Form/MenuLinkEditForm.php12
-rw-r--r--core/modules/menu_ui/src/Form/MenuLinkResetForm.php6
-rw-r--r--core/modules/menu_ui/src/MenuForm.php146
-rw-r--r--core/modules/menu_ui/src/MenuListBuilder.php16
-rw-r--r--core/modules/menu_ui/src/Tests/MenuLanguageTest.php42
-rw-r--r--core/modules/menu_ui/src/Tests/MenuNodeTest.php86
-rw-r--r--core/modules/menu_ui/src/Tests/MenuTest.php232
-rw-r--r--core/modules/menu_ui/src/Tests/MenuWebTestBase.php2
-rw-r--r--core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php20
-rw-r--r--core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php10
-rw-r--r--core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php6
-rw-r--r--core/modules/migrate/migrate.api.php2
-rw-r--r--core/modules/migrate/migrate.module2
-rw-r--r--core/modules/migrate/src/Exception/RequirementsException.php2
-rw-r--r--core/modules/migrate/src/MigrateExecutable.php36
-rw-r--r--core/modules/migrate/src/MigrateMessage.php4
-rw-r--r--core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php6
-rw-r--r--core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php6
-rw-r--r--core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php2
-rw-r--r--core/modules/migrate/src/Plugin/MigrateDestinationInterface.php2
-rw-r--r--core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php2
-rw-r--r--core/modules/migrate/src/Plugin/MigratePluginManager.php2
-rw-r--r--core/modules/migrate/src/Plugin/Migration.php12
-rw-r--r--core/modules/migrate/src/Plugin/MigrationPluginManager.php14
-rw-r--r--core/modules/migrate/src/Plugin/MigrationPluginManagerInterface.php2
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php6
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/Config.php2
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php8
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php6
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php2
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php4
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php2
-rw-r--r--core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php6
-rw-r--r--core/modules/migrate/src/Plugin/migrate/id_map/Sql.php96
-rw-r--r--core/modules/migrate/src/Plugin/migrate/process/FileCopy.php4
-rw-r--r--core/modules/migrate/src/Plugin/migrate/process/Get.php4
-rw-r--r--core/modules/migrate/src/Plugin/migrate/process/Iterator.php2
-rw-r--r--core/modules/migrate/src/Plugin/migrate/process/Migration.php12
-rw-r--r--core/modules/migrate/src/Plugin/migrate/process/Route.php4
-rw-r--r--core/modules/migrate/src/Plugin/migrate/process/StaticMap.php2
-rw-r--r--core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php2
-rw-r--r--core/modules/migrate/src/Plugin/migrate/source/EmptySource.php6
-rw-r--r--core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php6
-rw-r--r--core/modules/migrate/src/Plugin/migrate/source/SqlBase.php6
-rw-r--r--core/modules/migrate/src/Row.php10
-rw-r--r--core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php2
-rw-r--r--core/modules/migrate/tests/src/Kernel/MigrateEventsTest.php36
-rw-r--r--core/modules/migrate/tests/src/Kernel/MigrateExternalTranslatedTest.php2
-rw-r--r--core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php2
-rw-r--r--core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php2
-rw-r--r--core/modules/migrate/tests/src/Kernel/MigrateStatusTest.php4
-rw-r--r--core/modules/migrate/tests/src/Kernel/MigrateTestBase.php4
-rw-r--r--core/modules/migrate/tests/src/Kernel/SqlBaseTest.php4
-rw-r--r--core/modules/migrate/tests/src/Unit/Exception/RequirementsExceptionTest.php16
-rw-r--r--core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php4
-rw-r--r--core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php78
-rw-r--r--core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php100
-rw-r--r--core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php8
-rw-r--r--core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php8
-rw-r--r--core/modules/migrate/tests/src/Unit/RowTest.php42
-rw-r--r--core/modules/migrate/tests/src/Unit/TestSqlIdMap.php10
-rw-r--r--core/modules/migrate/tests/src/Unit/destination/ConfigTest.php12
-rw-r--r--core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php2
-rw-r--r--core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php12
-rw-r--r--core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php12
-rw-r--r--core/modules/migrate/tests/src/Unit/process/CallbackTest.php2
-rw-r--r--core/modules/migrate/tests/src/Unit/process/ConcatTest.php4
-rw-r--r--core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php64
-rw-r--r--core/modules/migrate/tests/src/Unit/process/ExtractTest.php8
-rw-r--r--core/modules/migrate/tests/src/Unit/process/FlattenTest.php6
-rw-r--r--core/modules/migrate/tests/src/Unit/process/GetTest.php16
-rw-r--r--core/modules/migrate/tests/src/Unit/process/IteratorTest.php26
-rw-r--r--core/modules/migrate/tests/src/Unit/process/MachineNameTest.php2
-rw-r--r--core/modules/migrate/tests/src/Unit/process/StaticMapTest.php20
-rw-r--r--core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php16
-rw-r--r--core/modules/migrate_drupal/migrate_drupal.module2
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php4
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php4
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php6
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php2
-rw-r--r--core/modules/migrate_drupal/tests/src/Kernel/MigrateCckFieldPluginManagerTest.php2
-rw-r--r--core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php2
-rw-r--r--core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php8
-rw-r--r--core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php10
-rw-r--r--core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php16
-rw-r--r--core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php36
-rw-r--r--core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php36
-rw-r--r--core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php42
-rw-r--r--core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php10
-rw-r--r--core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php2
-rw-r--r--core/modules/node/node.admin.inc16
-rw-r--r--core/modules/node/node.api.php52
-rw-r--r--core/modules/node/node.install74
-rw-r--r--core/modules/node/node.module166
-rw-r--r--core/modules/node/node.tokens.inc76
-rw-r--r--core/modules/node/node.views_execution.inc12
-rw-r--r--core/modules/node/src/Access/NodeRevisionAccessCheck.php10
-rw-r--r--core/modules/node/src/ContextProvider/NodeRouteContext.php2
-rw-r--r--core/modules/node/src/Controller/NodeController.php28
-rw-r--r--core/modules/node/src/Controller/NodeViewController.php16
-rw-r--r--core/modules/node/src/Entity/Node.php54
-rw-r--r--core/modules/node/src/Entity/NodeType.php4
-rw-r--r--core/modules/node/src/Form/DeleteMultiple.php10
-rw-r--r--core/modules/node/src/Form/NodeDeleteForm.php4
-rw-r--r--core/modules/node/src/Form/NodePreviewForm.php30
-rw-r--r--core/modules/node/src/Form/NodeRevisionDeleteForm.php14
-rw-r--r--core/modules/node/src/Form/NodeRevisionRevertForm.php4
-rw-r--r--core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php4
-rw-r--r--core/modules/node/src/Form/NodeTypeDeleteConfirm.php4
-rw-r--r--core/modules/node/src/NodeAccessControlHandler.php10
-rw-r--r--core/modules/node/src/NodeForm.php50
-rw-r--r--core/modules/node/src/NodeGrantDatabaseStorage.php12
-rw-r--r--core/modules/node/src/NodeListBuilder.php42
-rw-r--r--core/modules/node/src/NodePermissions.php40
-rw-r--r--core/modules/node/src/NodeStorage.php10
-rw-r--r--core/modules/node/src/NodeStorageSchema.php8
-rw-r--r--core/modules/node/src/NodeTranslationHandler.php4
-rw-r--r--core/modules/node/src/NodeTypeForm.php106
-rw-r--r--core/modules/node/src/NodeTypeListBuilder.php12
-rw-r--r--core/modules/node/src/NodeViewBuilder.php40
-rw-r--r--core/modules/node/src/NodeViewsData.php228
-rw-r--r--core/modules/node/src/Plugin/Action/AssignOwnerNode.php20
-rw-r--r--core/modules/node/src/Plugin/Action/DeleteNode.php2
-rw-r--r--core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php10
-rw-r--r--core/modules/node/src/Plugin/Block/SyndicateBlock.php8
-rw-r--r--core/modules/node/src/Plugin/Condition/NodeType.php12
-rw-r--r--core/modules/node/src/Plugin/Search/NodeSearch.php146
-rw-r--r--core/modules/node/src/Plugin/migrate/D6NodeDeriver.php2
-rw-r--r--core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php2
-rw-r--r--core/modules/node/src/Plugin/migrate/process/d6/NodeUpdate7008.php2
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d6/Node.php12
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php4
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d6/NodeType.php16
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php10
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d6/ViewModeBase.php4
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d7/Node.php12
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php4
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d7/NodeType.php12
-rw-r--r--core/modules/node/src/Plugin/views/area/ListingEmpty.php16
-rw-r--r--core/modules/node/src/Plugin/views/argument/Nid.php2
-rw-r--r--core/modules/node/src/Plugin/views/argument/UidRevision.php2
-rw-r--r--core/modules/node/src/Plugin/views/argument/Vid.php6
-rw-r--r--core/modules/node/src/Plugin/views/field/Node.php8
-rw-r--r--core/modules/node/src/Plugin/views/field/Path.php10
-rw-r--r--core/modules/node/src/Plugin/views/filter/UidRevision.php2
-rw-r--r--core/modules/node/src/Plugin/views/row/Rss.php32
-rw-r--r--core/modules/node/src/Plugin/views/wizard/Node.php40
-rw-r--r--core/modules/node/src/Plugin/views/wizard/NodeRevision.php8
-rw-r--r--core/modules/node/src/Routing/RouteSubscriber.php8
-rw-r--r--core/modules/node/src/Tests/NodeAccessBaseTableTest.php32
-rw-r--r--core/modules/node/src/Tests/NodeAccessPagerTest.php26
-rw-r--r--core/modules/node/src/Tests/NodeAccessRebuildNodeGrantsTest.php10
-rw-r--r--core/modules/node/src/Tests/NodeAdminTest.php34
-rw-r--r--core/modules/node/src/Tests/NodeBlockFunctionalTest.php24
-rw-r--r--core/modules/node/src/Tests/NodeEditFormTest.php28
-rw-r--r--core/modules/node/src/Tests/NodeEntityViewModeAlterTest.php6
-rw-r--r--core/modules/node/src/Tests/NodeFieldMultilingualTest.php28
-rw-r--r--core/modules/node/src/Tests/NodeFormButtonsTest.php32
-rw-r--r--core/modules/node/src/Tests/NodeQueryAlterTest.php12
-rw-r--r--core/modules/node/src/Tests/NodeRevisionPermissionsTest.php36
-rw-r--r--core/modules/node/src/Tests/NodeRevisionsTest.php58
-rw-r--r--core/modules/node/src/Tests/NodeSyndicateBlockTest.php6
-rw-r--r--core/modules/node/src/Tests/NodeTestBase.php16
-rw-r--r--core/modules/node/src/Tests/NodeTitleTest.php18
-rw-r--r--core/modules/node/src/Tests/NodeTitleXSSTest.php6
-rw-r--r--core/modules/node/src/Tests/NodeTranslationUITest.php82
-rw-r--r--core/modules/node/src/Tests/NodeTypeTest.php42
-rw-r--r--core/modules/node/src/Tests/NodeViewTest.php2
-rw-r--r--core/modules/node/src/Tests/PagePreviewTest.php76
-rw-r--r--core/modules/node/src/Tests/SummaryLengthTest.php6
-rw-r--r--core/modules/node/src/Tests/Views/BulkFormAccessTest.php50
-rw-r--r--core/modules/node/src/Tests/Views/BulkFormTest.php40
-rw-r--r--core/modules/node/src/Tests/Views/FilterUidRevisionTest.php18
-rw-r--r--core/modules/node/src/Tests/Views/FrontPageTest.php20
-rw-r--r--core/modules/node/src/Tests/Views/NodeContextualLinksTest.php28
-rw-r--r--core/modules/node/src/Tests/Views/NodeFieldFilterTest.php20
-rw-r--r--core/modules/node/src/Tests/Views/NodeFieldTokensTest.php2
-rw-r--r--core/modules/node/src/Tests/Views/NodeIntegrationTest.php12
-rw-r--r--core/modules/node/src/Tests/Views/NodeLanguageTest.php46
-rw-r--r--core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php12
-rw-r--r--core/modules/node/src/Tests/Views/NodeTestBase.php4
-rw-r--r--core/modules/node/src/Tests/Views/PathPluginTest.php18
-rw-r--r--core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php34
-rw-r--r--core/modules/node/src/Tests/Views/RowPluginTest.php18
-rw-r--r--core/modules/node/src/Tests/Views/StatusExtraTest.php8
-rw-r--r--core/modules/node/tests/modules/node_access_test/node_access_test.module34
-rw-r--r--core/modules/node/tests/modules/node_access_test_empty/node_access_test_empty.module4
-rw-r--r--core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module8
-rw-r--r--core/modules/node/tests/modules/node_test/node_test.module40
-rw-r--r--core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php14
-rw-r--r--core/modules/node/tests/src/Functional/NodeAccessFieldTest.php16
-rw-r--r--core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php12
-rw-r--r--core/modules/node/tests/src/Functional/NodeAccessLanguageAwareCombinationTest.php106
-rw-r--r--core/modules/node/tests/src/Functional/NodeAccessLanguageAwareTest.php78
-rw-r--r--core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php50
-rw-r--r--core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php10
-rw-r--r--core/modules/node/tests/src/Functional/NodeAccessRecordsTest.php28
-rw-r--r--core/modules/node/tests/src/Functional/NodeCacheTagsTest.php4
-rw-r--r--core/modules/node/tests/src/Functional/NodeCreationTest.php30
-rw-r--r--core/modules/node/tests/src/Functional/NodeFormSaveChangedTimeTest.php14
-rw-r--r--core/modules/node/tests/src/Functional/NodeHelpTest.php12
-rw-r--r--core/modules/node/tests/src/Functional/NodeLinksTest.php6
-rw-r--r--core/modules/node/tests/src/Functional/NodeLoadMultipleTest.php20
-rw-r--r--core/modules/node/tests/src/Functional/NodePostSettingsTest.php14
-rw-r--r--core/modules/node/tests/src/Functional/NodeRSSContentTest.php12
-rw-r--r--core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php42
-rw-r--r--core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php4
-rw-r--r--core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php8
-rw-r--r--core/modules/node/tests/src/Functional/NodeSaveTest.php20
-rw-r--r--core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php8
-rw-r--r--core/modules/node/tests/src/Functional/NodeTestBase.php16
-rw-r--r--core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php36
-rw-r--r--core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php42
-rw-r--r--core/modules/node/tests/src/Functional/NodeViewLanguageTest.php4
-rw-r--r--core/modules/node/tests/src/Functional/PageViewTest.php4
-rw-r--r--core/modules/node/tests/src/Kernel/Config/NodeImportChangeTest.php2
-rw-r--r--core/modules/node/tests/src/Kernel/Config/NodeImportCreateTest.php6
-rw-r--r--core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php8
-rw-r--r--core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTypeTest.php6
-rw-r--r--core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php2
-rw-r--r--core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php4
-rw-r--r--core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTypeTest.php4
-rw-r--r--core/modules/node/tests/src/Kernel/NodeAccessTest.php4
-rw-r--r--core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php4
-rw-r--r--core/modules/node/tests/src/Kernel/NodeConditionTest.php12
-rw-r--r--core/modules/node/tests/src/Kernel/NodeFieldAccessTest.php50
-rw-r--r--core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php4
-rw-r--r--core/modules/node/tests/src/Kernel/NodeOwnerTest.php10
-rw-r--r--core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php20
-rw-r--r--core/modules/node/tests/src/Kernel/NodeValidationTest.php2
-rw-r--r--core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php8
-rw-r--r--core/modules/options/options.api.php16
-rw-r--r--core/modules/options/options.module10
-rw-r--r--core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php6
-rw-r--r--core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php6
-rw-r--r--core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php22
-rw-r--r--core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php20
-rw-r--r--core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php32
-rw-r--r--core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php22
-rw-r--r--core/modules/options/src/Tests/OptionsDynamicValuesApiTest.php4
-rw-r--r--core/modules/options/src/Tests/OptionsFieldUITest.php96
-rw-r--r--core/modules/options/src/Tests/OptionsFloatFieldImportTest.php18
-rw-r--r--core/modules/options/src/Tests/OptionsSelectDynamicValuesTest.php2
-rw-r--r--core/modules/options/src/Tests/OptionsWidgetsTest.php122
-rw-r--r--core/modules/options/tests/options_test/options_test.module22
-rw-r--r--core/modules/options/tests/src/Kernel/OptionsFieldTest.php6
-rw-r--r--core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php16
-rw-r--r--core/modules/options/tests/src/Kernel/OptionsFormattersTest.php2
-rw-r--r--core/modules/options/tests/src/Kernel/Views/FileViewsDataTest.php18
-rw-r--r--core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php2
-rw-r--r--core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php2
-rw-r--r--core/modules/page_cache/page_cache.module4
-rw-r--r--core/modules/page_cache/src/StackMiddleware/PageCache.php6
-rw-r--r--core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php40
-rw-r--r--core/modules/page_cache/src/Tests/PageCacheTest.php60
-rw-r--r--core/modules/path/path.api.php6
-rw-r--r--core/modules/path/path.module26
-rw-r--r--core/modules/path/src/Controller/PathController.php52
-rw-r--r--core/modules/path/src/Form/AddForm.php4
-rw-r--r--core/modules/path/src/Form/DeleteForm.php6
-rw-r--r--core/modules/path/src/Form/EditForm.php20
-rw-r--r--core/modules/path/src/Form/PathFilterForm.php28
-rw-r--r--core/modules/path/src/Form/PathFormBase.php26
-rw-r--r--core/modules/path/src/Plugin/Field/FieldType/PathItem.php4
-rw-r--r--core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php32
-rw-r--r--core/modules/path/src/Plugin/migrate/destination/UrlAlias.php4
-rw-r--r--core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php4
-rw-r--r--core/modules/path/src/Tests/PathAdminTest.php34
-rw-r--r--core/modules/path/src/Tests/PathNodeFormTest.php4
-rw-r--r--core/modules/path/src/Tests/PathTaxonomyTermTest.php14
-rw-r--r--core/modules/path/src/Tests/PathTestBase.php6
-rw-r--r--core/modules/path/tests/src/Functional/PathAliasTest.php40
-rw-r--r--core/modules/path/tests/src/Functional/PathLanguageTest.php32
-rw-r--r--core/modules/path/tests/src/Functional/PathLanguageUiTest.php14
-rw-r--r--core/modules/path/tests/src/Functional/PathTestBase.php6
-rw-r--r--core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php20
-rw-r--r--core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php2
-rw-r--r--core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php4
-rw-r--r--core/modules/quickedit/quickedit.api.php4
-rw-r--r--core/modules/quickedit/quickedit.module6
-rw-r--r--core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php6
-rw-r--r--core/modules/quickedit/src/EditorSelector.php4
-rw-r--r--core/modules/quickedit/src/Form/QuickEditFieldForm.php14
-rw-r--r--core/modules/quickedit/src/MetadataGenerator.php12
-rw-r--r--core/modules/quickedit/src/Plugin/InPlaceEditor/FormEditor.php8
-rw-r--r--core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php8
-rw-r--r--core/modules/quickedit/src/Plugin/InPlaceEditorBase.php2
-rw-r--r--core/modules/quickedit/src/QuickEditController.php14
-rw-r--r--core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php32
-rw-r--r--core/modules/quickedit/src/Tests/QuickEditLoadingTest.php124
-rw-r--r--core/modules/quickedit/tests/modules/quickedit_test.module4
-rw-r--r--core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php8
-rw-r--r--core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php20
-rw-r--r--core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php46
-rw-r--r--core/modules/quickedit/tests/src/Kernel/QuickEditTestBase.php16
-rw-r--r--core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php36
-rw-r--r--core/modules/rdf/rdf.api.php4
-rw-r--r--core/modules/rdf/rdf.module82
-rw-r--r--core/modules/rdf/src/Entity/RdfMapping.php20
-rw-r--r--core/modules/rdf/src/RdfMappingInterface.php2
-rw-r--r--core/modules/rdf/src/Tests/CommentAttributesTest.php138
-rw-r--r--core/modules/rdf/src/Tests/GetNamespacesTest.php18
-rw-r--r--core/modules/rdf/src/Tests/ImageFieldAttributesTest.php24
-rw-r--r--core/modules/rdf/tests/rdf_conflicting_namespaces/rdf_conflicting_namespaces.module4
-rw-r--r--core/modules/rdf/tests/rdf_test_namespaces/rdf_test_namespaces.module4
-rw-r--r--core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php64
-rw-r--r--core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php14
-rw-r--r--core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php4
-rw-r--r--core/modules/rdf/tests/src/Functional/NodeAttributesTest.php46
-rw-r--r--core/modules/rdf/tests/src/Functional/StandardProfileTest.php120
-rw-r--r--core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php22
-rw-r--r--core/modules/rdf/tests/src/Functional/UserAttributesTest.php46
-rw-r--r--core/modules/rdf/tests/src/Kernel/CrudTest.php26
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/DateTimeFieldRdfaTest.php12
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/EmailFieldRdfaTest.php14
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/EntityReferenceRdfaTest.php16
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/FieldRdfaDatatypeCallbackTest.php16
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php16
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/LinkFieldRdfaTest.php78
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php84
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php8
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php24
-rw-r--r--core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php16
-rw-r--r--core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php54
-rw-r--r--core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php6
-rw-r--r--core/modules/responsive_image/responsive_image.module70
-rw-r--r--core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php14
-rw-r--r--core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php42
-rw-r--r--core/modules/responsive_image/src/ResponsiveImageStyleForm.php128
-rw-r--r--core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php4
-rw-r--r--core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php28
-rw-r--r--core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php152
-rw-r--r--core/modules/responsive_image/src/Tests/ResponsiveImageFieldUiTest.php50
-rw-r--r--core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php224
-rw-r--r--core/modules/rest/rest.api.php4
-rw-r--r--core/modules/rest/rest.install6
-rw-r--r--core/modules/rest/rest.module6
-rw-r--r--core/modules/rest/src/Plugin/Deriver/EntityDeriver.php8
-rw-r--r--core/modules/rest/src/Plugin/ResourceBase.php32
-rw-r--r--core/modules/rest/src/Plugin/rest/resource/EntityResource.php8
-rw-r--r--core/modules/rest/src/Plugin/views/display/RestExport.php18
-rw-r--r--core/modules/rest/src/Plugin/views/row/DataFieldRow.php34
-rw-r--r--core/modules/rest/src/Plugin/views/style/Serializer.php14
-rw-r--r--core/modules/rest/src/RequestHandler.php4
-rw-r--r--core/modules/rest/src/ResourceResponse.php2
-rw-r--r--core/modules/rest/src/Routing/ResourceRoutes.php4
-rw-r--r--core/modules/rest/src/Tests/RESTTestBase.php40
-rw-r--r--core/modules/rest/src/Tests/ResourceTest.php2
-rw-r--r--core/modules/rest/src/Tests/Views/StyleSerializerTest.php134
-rw-r--r--core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php4
-rw-r--r--core/modules/rest/tests/src/Unit/CollectRoutesTest.php22
-rw-r--r--core/modules/search/search.install104
-rw-r--r--core/modules/search/search.module82
-rw-r--r--core/modules/search/search.pages.inc10
-rw-r--r--core/modules/search/src/Controller/SearchController.php38
-rw-r--r--core/modules/search/src/Entity/SearchPage.php4
-rw-r--r--core/modules/search/src/Form/SearchBlockForm.php16
-rw-r--r--core/modules/search/src/Form/SearchPageAddForm.php2
-rw-r--r--core/modules/search/src/Form/SearchPageEditForm.php2
-rw-r--r--core/modules/search/src/Form/SearchPageForm.php34
-rw-r--r--core/modules/search/src/Form/SearchPageFormBase.php22
-rw-r--r--core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php4
-rw-r--r--core/modules/search/src/Plugin/Derivative/SearchLocalTask.php6
-rw-r--r--core/modules/search/src/Plugin/SearchPluginBase.php18
-rw-r--r--core/modules/search/src/Plugin/migrate/process/SearchConfigurationRankings.php2
-rw-r--r--core/modules/search/src/Plugin/migrate/process/d6/SearchConfigurationRankings.php2
-rw-r--r--core/modules/search/src/Plugin/views/argument/Search.php10
-rw-r--r--core/modules/search/src/Plugin/views/filter/Search.php24
-rw-r--r--core/modules/search/src/Plugin/views/row/SearchRow.php10
-rw-r--r--core/modules/search/src/Plugin/views/sort/Score.php2
-rw-r--r--core/modules/search/src/Routing/SearchPageRoutes.php62
-rw-r--r--core/modules/search/src/SearchPageAccessControlHandler.php2
-rw-r--r--core/modules/search/src/SearchPageListBuilder.php126
-rw-r--r--core/modules/search/src/SearchPageRepository.php2
-rw-r--r--core/modules/search/src/SearchQuery.php28
-rw-r--r--core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php24
-rw-r--r--core/modules/search/src/Tests/SearchBlockTest.php20
-rw-r--r--core/modules/search/src/Tests/SearchCommentTest.php76
-rw-r--r--core/modules/search/src/Tests/SearchConfigSettingsFormTest.php90
-rw-r--r--core/modules/search/src/Tests/SearchEmbedFormTest.php12
-rw-r--r--core/modules/search/src/Tests/SearchLanguageTest.php44
-rw-r--r--core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php26
-rw-r--r--core/modules/search/src/Tests/SearchNumberMatchingTest.php20
-rw-r--r--core/modules/search/src/Tests/SearchNumbersTest.php18
-rw-r--r--core/modules/search/src/Tests/SearchPageCacheTagsTest.php8
-rw-r--r--core/modules/search/src/Tests/SearchPageTextTest.php38
-rw-r--r--core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php20
-rw-r--r--core/modules/search/src/Tests/SearchQueryAlterTest.php12
-rw-r--r--core/modules/search/src/Tests/SearchRankingTest.php66
-rw-r--r--core/modules/search/src/Tests/SearchTestBase.php18
-rw-r--r--core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php12
-rw-r--r--core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php36
-rw-r--r--core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php12
-rw-r--r--core/modules/search/tests/src/Functional/SearchExactTest.php20
-rw-r--r--core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php12
-rw-r--r--core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php80
-rw-r--r--core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php20
-rw-r--r--core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php12
-rw-r--r--core/modules/search/tests/src/Functional/SearchPageOverrideTest.php6
-rw-r--r--core/modules/search/tests/src/Functional/SearchSetLocaleTest.php6
-rw-r--r--core/modules/search/tests/src/Functional/SearchSimplifyTest.php14
-rw-r--r--core/modules/search/tests/src/Functional/SearchTestBase.php18
-rw-r--r--core/modules/search/tests/src/Functional/SearchTokenizerTest.php12
-rw-r--r--core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php6
-rw-r--r--core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php8
-rw-r--r--core/modules/search/tests/src/Kernel/SearchExcerptTest.php2
-rw-r--r--core/modules/search/tests/src/Kernel/SearchMatchTest.php136
-rw-r--r--core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php26
-rw-r--r--core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php2
-rw-r--r--core/modules/serialization/serialization.install4
-rw-r--r--core/modules/serialization/serialization.module4
-rw-r--r--core/modules/serialization/src/Encoder/JsonEncoder.php2
-rw-r--r--core/modules/serialization/src/Encoder/XmlEncoder.php6
-rw-r--r--core/modules/serialization/src/EntityResolver/ChainEntityResolver.php4
-rw-r--r--core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php4
-rw-r--r--core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php4
-rw-r--r--core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php6
-rw-r--r--core/modules/serialization/src/Normalizer/FieldItemNormalizer.php2
-rw-r--r--core/modules/serialization/src/Normalizer/FieldNormalizer.php2
-rw-r--r--core/modules/serialization/src/Normalizer/ListNormalizer.php4
-rw-r--r--core/modules/serialization/src/Normalizer/MarkupNormalizer.php4
-rw-r--r--core/modules/serialization/src/Normalizer/NullNormalizer.php2
-rw-r--r--core/modules/serialization/src/Normalizer/TypedDataNormalizer.php2
-rw-r--r--core/modules/serialization/src/RegisterEntityResolversCompilerPass.php6
-rw-r--r--core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php4
-rw-r--r--core/modules/serialization/tests/modules/field_normalization_test/src/Normalization/TextItemSillyNormalizer.php2
-rw-r--r--core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php2
-rw-r--r--core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php2
-rw-r--r--core/modules/serialization/tests/src/Kernel/EntityResolverTest.php60
-rw-r--r--core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php96
-rw-r--r--core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php24
-rw-r--r--core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php16
-rw-r--r--core/modules/serialization/tests/src/Kernel/SerializationTest.php2
-rw-r--r--core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php6
-rw-r--r--core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php16
-rw-r--r--core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php14
-rw-r--r--core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php2
-rw-r--r--core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php12
-rw-r--r--core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php22
-rw-r--r--core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php4
-rw-r--r--core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php16
-rw-r--r--core/modules/shortcut/shortcut.install40
-rw-r--r--core/modules/shortcut/shortcut.module104
-rw-r--r--core/modules/shortcut/src/Controller/ShortcutController.php6
-rw-r--r--core/modules/shortcut/src/Controller/ShortcutSetController.php12
-rw-r--r--core/modules/shortcut/src/Entity/Shortcut.php16
-rw-r--r--core/modules/shortcut/src/Entity/ShortcutSet.php4
-rw-r--r--core/modules/shortcut/src/Form/SetCustomize.php58
-rw-r--r--core/modules/shortcut/src/Form/ShortcutDeleteForm.php4
-rw-r--r--core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php4
-rw-r--r--core/modules/shortcut/src/Form/SwitchShortcutSet.php72
-rw-r--r--core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php4
-rw-r--r--core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php16
-rw-r--r--core/modules/shortcut/src/Plugin/migrate/source/d7/Shortcut.php6
-rw-r--r--core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSet.php4
-rw-r--r--core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSetUsers.php16
-rw-r--r--core/modules/shortcut/src/ShortcutForm.php6
-rw-r--r--core/modules/shortcut/src/ShortcutSetForm.php18
-rw-r--r--core/modules/shortcut/src/ShortcutSetListBuilder.php4
-rw-r--r--core/modules/shortcut/src/ShortcutSetStorage.php8
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutLinksTest.php64
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutSetsTest.php20
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutTestBase.php34
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php26
-rw-r--r--core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php6
-rw-r--r--core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php4
-rw-r--r--core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php4
-rw-r--r--core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php4
-rw-r--r--core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php20
-rw-r--r--core/modules/simpletest/simpletest.install102
-rw-r--r--core/modules/simpletest/simpletest.module90
-rw-r--r--core/modules/simpletest/src/AssertContentTrait.php104
-rw-r--r--core/modules/simpletest/src/BlockCreationTrait.php10
-rw-r--r--core/modules/simpletest/src/ContentTypeCreationTrait.php10
-rw-r--r--core/modules/simpletest/src/Form/SimpletestResultsForm.php112
-rw-r--r--core/modules/simpletest/src/Form/SimpletestSettingsForm.php32
-rw-r--r--core/modules/simpletest/src/Form/SimpletestTestForm.php128
-rw-r--r--core/modules/simpletest/src/InstallerTestBase.php20
-rw-r--r--core/modules/simpletest/src/KernelTestBase.php48
-rw-r--r--core/modules/simpletest/src/NodeCreationTrait.php10
-rw-r--r--core/modules/simpletest/src/TestBase.php90
-rw-r--r--core/modules/simpletest/src/TestDiscovery.php18
-rw-r--r--core/modules/simpletest/src/Tests/BrokenSetUpTest.php4
-rw-r--r--core/modules/simpletest/src/Tests/BrowserTest.php14
-rw-r--r--core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php8
-rw-r--r--core/modules/simpletest/src/Tests/KernelTestBaseTest.php62
-rw-r--r--core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php8
-rw-r--r--core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php34
-rw-r--r--core/modules/simpletest/src/Tests/SimpleTestInstallBatchTest.php2
-rw-r--r--core/modules/simpletest/src/Tests/SimpleTestTest.php28
-rw-r--r--core/modules/simpletest/src/UserCreationTrait.php22
-rw-r--r--core/modules/simpletest/src/WebTestBase.php168
-rw-r--r--core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install10
-rw-r--r--core/modules/simpletest/tests/src/Functional/FolderTest.php2
-rw-r--r--core/modules/simpletest/tests/src/Functional/MailCaptureTest.php28
-rw-r--r--core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php4
-rw-r--r--core/modules/simpletest/tests/src/Kernel/Migrate/d6/MigrateSimpletestConfigsTest.php2
-rw-r--r--core/modules/simpletest/tests/src/Unit/TestBaseTest.php106
-rw-r--r--core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php48
-rw-r--r--core/modules/statistics/src/NodeStatisticsDatabaseStorage.php2
-rw-r--r--core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php22
-rw-r--r--core/modules/statistics/src/StatisticsSettingsForm.php8
-rw-r--r--core/modules/statistics/src/Tests/StatisticsAdminTest.php34
-rw-r--r--core/modules/statistics/src/Tests/StatisticsLoggingTest.php20
-rw-r--r--core/modules/statistics/src/Tests/StatisticsReportsTest.php12
-rw-r--r--core/modules/statistics/src/Tests/StatisticsTestBase.php8
-rw-r--r--core/modules/statistics/src/Tests/Views/IntegrationTest.php16
-rw-r--r--core/modules/statistics/statistics.install28
-rw-r--r--core/modules/statistics/statistics.module34
-rw-r--r--core/modules/statistics/statistics.tokens.inc22
-rw-r--r--core/modules/statistics/statistics.views.inc68
-rw-r--r--core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php4
-rw-r--r--core/modules/statistics/tests/src/Functional/StatisticsTestBase.php8
-rw-r--r--core/modules/statistics/tests/src/Functional/StatisticsTokenReplaceTest.php16
-rw-r--r--core/modules/statistics/tests/src/Kernel/Migrate/d6/MigrateStatisticsConfigsTest.php2
-rw-r--r--core/modules/statistics/tests/src/Kernel/Migrate/d7/MigrateStatisticsConfigsTest.php2
-rw-r--r--core/modules/syslog/src/Logger/SysLog.php6
-rw-r--r--core/modules/syslog/src/Tests/SyslogTest.php8
-rw-r--r--core/modules/syslog/syslog.module18
-rw-r--r--core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php2
-rw-r--r--core/modules/system/src/Controller/AdminController.php10
-rw-r--r--core/modules/system/src/Controller/DbUpdateController.php156
-rw-r--r--core/modules/system/src/Controller/EntityAutocompleteController.php2
-rw-r--r--core/modules/system/src/Controller/SystemController.php78
-rw-r--r--core/modules/system/src/Controller/SystemInfoController.php2
-rw-r--r--core/modules/system/src/Controller/ThemeController.php28
-rw-r--r--core/modules/system/src/DateFormatAccessControlHandler.php2
-rw-r--r--core/modules/system/src/Entity/Action.php4
-rw-r--r--core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php2
-rw-r--r--core/modules/system/src/FileDownloadController.php2
-rw-r--r--core/modules/system/src/Form/CronForm.php30
-rw-r--r--core/modules/system/src/Form/DateFormatDeleteForm.php4
-rw-r--r--core/modules/system/src/Form/DateFormatEditForm.php2
-rw-r--r--core/modules/system/src/Form/DateFormatFormBase.php22
-rw-r--r--core/modules/system/src/Form/FileSystemForm.php30
-rw-r--r--core/modules/system/src/Form/ImageToolkitForm.php26
-rw-r--r--core/modules/system/src/Form/LoggingForm.php8
-rw-r--r--core/modules/system/src/Form/ModulesListConfirmForm.php14
-rw-r--r--core/modules/system/src/Form/ModulesListForm.php116
-rw-r--r--core/modules/system/src/Form/ModulesUninstallConfirmForm.php6
-rw-r--r--core/modules/system/src/Form/ModulesUninstallForm.php36
-rw-r--r--core/modules/system/src/Form/PerformanceForm.php36
-rw-r--r--core/modules/system/src/Form/RegionalForm.php54
-rw-r--r--core/modules/system/src/Form/RssFeedsForm.php18
-rw-r--r--core/modules/system/src/Form/SiteInformationForm.php42
-rw-r--r--core/modules/system/src/Form/SiteMaintenanceModeForm.php10
-rw-r--r--core/modules/system/src/Form/ThemeAdminForm.php16
-rw-r--r--core/modules/system/src/Form/ThemeSettingsForm.php110
-rw-r--r--core/modules/system/src/PathBasedBreadcrumbBuilder.php6
-rw-r--r--core/modules/system/src/Plugin/Block/SystemBrandingBlock.php44
-rw-r--r--core/modules/system/src/Plugin/Block/SystemMenuBlock.php20
-rw-r--r--core/modules/system/src/Plugin/Block/SystemMessagesBlock.php4
-rw-r--r--core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php2
-rw-r--r--core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php10
-rw-r--r--core/modules/system/src/Plugin/Condition/RequestPath.php14
-rw-r--r--core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php2
-rw-r--r--core/modules/system/src/Plugin/Derivative/ThemeLocalTask.php2
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php20
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php12
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php24
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php26
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php4
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php18
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php18
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php18
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php18
-rw-r--r--core/modules/system/src/Plugin/migrate/source/Menu.php4
-rw-r--r--core/modules/system/src/Plugin/views/field/BulkForm.php64
-rw-r--r--core/modules/system/src/SystemConfigSubscriber.php6
-rw-r--r--core/modules/system/src/SystemManager.php20
-rw-r--r--core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php2
-rw-r--r--core/modules/system/src/Tests/Ajax/AjaxTestBase.php2
-rw-r--r--core/modules/system/src/Tests/Ajax/CommandsTest.php42
-rw-r--r--core/modules/system/src/Tests/Ajax/DialogTest.php76
-rw-r--r--core/modules/system/src/Tests/Ajax/ElementValidationTest.php4
-rw-r--r--core/modules/system/src/Tests/Ajax/FormValuesTest.php20
-rw-r--r--core/modules/system/src/Tests/Ajax/FrameworkTest.php56
-rw-r--r--core/modules/system/src/Tests/Ajax/MultiFormTest.php14
-rw-r--r--core/modules/system/src/Tests/Batch/PageTest.php8
-rw-r--r--core/modules/system/src/Tests/Batch/ProcessingTest.php26
-rw-r--r--core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php2
-rw-r--r--core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php84
-rw-r--r--core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php4
-rw-r--r--core/modules/system/src/Tests/Common/AddFeedTest.php42
-rw-r--r--core/modules/system/src/Tests/Common/AlterTest.php18
-rw-r--r--core/modules/system/src/Tests/Common/FormatDateTest.php22
-rw-r--r--core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php6
-rw-r--r--core/modules/system/src/Tests/Common/RenderWebTest.php104
-rw-r--r--core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php18
-rw-r--r--core/modules/system/src/Tests/Common/UrlTest.php124
-rw-r--r--core/modules/system/src/Tests/Condition/ConditionFormTest.php8
-rw-r--r--core/modules/system/src/Tests/Database/DatabaseWebTestBase.php2
-rw-r--r--core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php28
-rw-r--r--core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php32
-rw-r--r--core/modules/system/src/Tests/Database/TemporaryQueryTest.php8
-rw-r--r--core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php66
-rw-r--r--core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php6
-rw-r--r--core/modules/system/src/Tests/Entity/EntityFormTest.php40
-rw-r--r--core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php24
-rw-r--r--core/modules/system/src/Tests/Entity/EntityUnitTestBase.php20
-rw-r--r--core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php2
-rw-r--r--core/modules/system/src/Tests/Form/AlterTest.php8
-rw-r--r--core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php18
-rw-r--r--core/modules/system/src/Tests/Form/CheckboxTest.php28
-rw-r--r--core/modules/system/src/Tests/Form/ConfirmFormTest.php22
-rw-r--r--core/modules/system/src/Tests/Form/ElementTest.php48
-rw-r--r--core/modules/system/src/Tests/Form/ElementsLabelsTest.php8
-rw-r--r--core/modules/system/src/Tests/Form/ElementsTableSelectTest.php44
-rw-r--r--core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php4
-rw-r--r--core/modules/system/src/Tests/Form/EmailTest.php12
-rw-r--r--core/modules/system/src/Tests/Form/FormStoragePageCacheTest.php2
-rw-r--r--core/modules/system/src/Tests/Form/FormTest.php224
-rw-r--r--core/modules/system/src/Tests/Form/LanguageSelectElementTest.php34
-rw-r--r--core/modules/system/src/Tests/Form/ProgrammaticTest.php32
-rw-r--r--core/modules/system/src/Tests/Form/RebuildTest.php22
-rw-r--r--core/modules/system/src/Tests/Form/ResponseTest.php2
-rw-r--r--core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php4
-rw-r--r--core/modules/system/src/Tests/Form/StateValuesCleanTest.php26
-rw-r--r--core/modules/system/src/Tests/Form/StorageTest.php22
-rw-r--r--core/modules/system/src/Tests/Form/SystemConfigFormTest.php6
-rw-r--r--core/modules/system/src/Tests/Form/TriggeringElementTest.php20
-rw-r--r--core/modules/system/src/Tests/Form/UrlTest.php12
-rw-r--r--core/modules/system/src/Tests/Form/ValidationTest.php88
-rw-r--r--core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php16
-rw-r--r--core/modules/system/src/Tests/Image/ToolkitTest.php14
-rw-r--r--core/modules/system/src/Tests/Image/ToolkitTestBase.php42
-rw-r--r--core/modules/system/src/Tests/Installer/DistributionProfileTest.php12
-rw-r--r--core/modules/system/src/Tests/Installer/DistributionProfileTranslationQueryTest.php12
-rw-r--r--core/modules/system/src/Tests/Installer/DistributionProfileTranslationTest.php12
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php4
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php8
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerExistingConfigDirectoryTest.php4
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php14
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerExistingSettingsMismatchProfileTest.php16
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php16
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php20
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerTest.php6
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php6
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerTranslationTest.php6
-rw-r--r--core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php4
-rw-r--r--core/modules/system/src/Tests/Installer/StandardInstallerTest.php4
-rw-r--r--core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php14
-rw-r--r--core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php12
-rw-r--r--core/modules/system/src/Tests/Menu/BreadcrumbTest.php172
-rw-r--r--core/modules/system/src/Tests/Menu/LocalActionTest.php4
-rw-r--r--core/modules/system/src/Tests/Menu/LocalTasksTest.php14
-rw-r--r--core/modules/system/src/Tests/Menu/MenuRouterTest.php16
-rw-r--r--core/modules/system/src/Tests/Module/DependencyTest.php64
-rw-r--r--core/modules/system/src/Tests/Module/HookRequirementsTest.php6
-rw-r--r--core/modules/system/src/Tests/Module/InstallUninstallTest.php46
-rw-r--r--core/modules/system/src/Tests/Module/ModuleTestBase.php22
-rw-r--r--core/modules/system/src/Tests/Module/RequiredTest.php2
-rw-r--r--core/modules/system/src/Tests/Module/VersionTest.php4
-rw-r--r--core/modules/system/src/Tests/Pager/PagerTest.php20
-rw-r--r--core/modules/system/src/Tests/Path/UrlAliasFixtures.php22
-rw-r--r--core/modules/system/src/Tests/Routing/MockAliasManager.php6
-rw-r--r--core/modules/system/src/Tests/Routing/MockRouteProvider.php6
-rw-r--r--core/modules/system/src/Tests/Routing/RouterTest.php8
-rw-r--r--core/modules/system/src/Tests/Session/SessionHttpsTest.php24
-rw-r--r--core/modules/system/src/Tests/Session/SessionTest.php36
-rw-r--r--core/modules/system/src/Tests/Session/StackSessionHandlerIntegrationTest.php2
-rw-r--r--core/modules/system/src/Tests/System/AccessDeniedTest.php10
-rw-r--r--core/modules/system/src/Tests/System/AdminTest.php24
-rw-r--r--core/modules/system/src/Tests/System/CronRunTest.php6
-rw-r--r--core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php10
-rw-r--r--core/modules/system/src/Tests/System/ErrorHandlerTest.php36
-rw-r--r--core/modules/system/src/Tests/System/FrontPageTest.php18
-rw-r--r--core/modules/system/src/Tests/System/HtaccessTest.php2
-rw-r--r--core/modules/system/src/Tests/System/PageNotFoundTest.php10
-rw-r--r--core/modules/system/src/Tests/System/PageTitleTest.php16
-rw-r--r--core/modules/system/src/Tests/System/ResponseGeneratorTest.php4
-rw-r--r--core/modules/system/src/Tests/System/ShutdownFunctionsTest.php6
-rw-r--r--core/modules/system/src/Tests/System/SiteMaintenanceTest.php36
-rw-r--r--core/modules/system/src/Tests/System/SystemConfigFormTestBase.php6
-rw-r--r--core/modules/system/src/Tests/System/ThemeTest.php102
-rw-r--r--core/modules/system/src/Tests/System/UncaughtExceptionTest.php10
-rw-r--r--core/modules/system/src/Tests/Theme/EngineTwigTest.php16
-rw-r--r--core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php18
-rw-r--r--core/modules/system/src/Tests/Theme/FunctionsTest.php246
-rw-r--r--core/modules/system/src/Tests/Theme/HtmlAttributesTest.php2
-rw-r--r--core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php22
-rw-r--r--core/modules/system/src/Tests/Theme/ThemeTest.php74
-rw-r--r--core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php8
-rw-r--r--core/modules/system/src/Tests/Theme/TwigFilterTest.php94
-rw-r--r--core/modules/system/src/Tests/Theme/TwigNamespaceTest.php6
-rw-r--r--core/modules/system/src/Tests/Theme/TwigRawTest.php6
-rw-r--r--core/modules/system/src/Tests/Theme/TwigTransTest.php26
-rw-r--r--core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php2
-rw-r--r--core/modules/system/src/Tests/Update/DependencyMissingTest.php6
-rw-r--r--core/modules/system/src/Tests/Update/DependencyOrderingTest.php14
-rw-r--r--core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php4
-rw-r--r--core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php4
-rw-r--r--core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php4
-rw-r--r--core/modules/system/src/Tests/Update/UpdateScriptTest.php98
-rw-r--r--core/modules/system/src/Tests/Update/UpdatesWith7xTest.php6
-rw-r--r--core/modules/system/system.admin.inc62
-rw-r--r--core/modules/system/system.api.php6
-rw-r--r--core/modules/system/system.install444
-rw-r--r--core/modules/system/system.module346
-rw-r--r--core/modules/system/system.tokens.inc86
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php8
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php48
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-8.update-test-block-disabled-2513534.php8
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php16
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php8
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-8.views-revision-metadata-fields-2248983.php8
-rw-r--r--core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php2
-rw-r--r--core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module8
-rw-r--r--core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php134
-rw-r--r--core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php12
-rw-r--r--core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php44
-rw-r--r--core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php24
-rw-r--r--core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php114
-rw-r--r--core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php20
-rw-r--r--core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php22
-rw-r--r--core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc2
-rw-r--r--core/modules/system/tests/modules/batch_test/batch_test.module58
-rw-r--r--core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php32
-rw-r--r--core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php12
-rw-r--r--core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php8
-rw-r--r--core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php8
-rw-r--r--core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php12
-rw-r--r--core/modules/system/tests/modules/common_test/common_test.module20
-rw-r--r--core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php56
-rw-r--r--core/modules/system/tests/modules/condition_test/src/FormController.php4
-rw-r--r--core/modules/system/tests/modules/database_test/database_test.install262
-rw-r--r--core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php54
-rw-r--r--core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php22
-rw-r--r--core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php2
-rw-r--r--core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module6
-rw-r--r--core/modules/system/tests/modules/entity_test/entity_test.install20
-rw-r--r--core/modules/system/tests/modules/entity_test/entity_test.module66
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php2
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php18
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php24
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php8
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php6
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUpdate.php4
-rw-r--r--core/modules/system/tests/modules/entity_test/src/EntityTestAccessControlHandler.php4
-rw-r--r--core/modules/system/tests/modules/entity_test/src/EntityTestForm.php10
-rw-r--r--core/modules/system/tests/modules/entity_test/src/EntityTestStorageSchema.php2
-rw-r--r--core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php12
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php6
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php12
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php32
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php8
-rw-r--r--core/modules/system/tests/modules/entity_test_extra/entity_test_extra.module6
-rw-r--r--core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php8
-rw-r--r--core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php2
-rw-r--r--core/modules/system/tests/modules/form_test/form_test.module30
-rw-r--r--core/modules/system/tests/modules/form_test/src/AutocompleteController.php2
-rw-r--r--core/modules/system/tests/modules/form_test/src/Callbacks.php2
-rw-r--r--core/modules/system/tests/modules/form_test/src/ConfirmFormArrayPathTestForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php2
-rw-r--r--core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php4
-rw-r--r--core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php4
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php32
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php4
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php42
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php26
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php10
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php120
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php4
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php14
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php20
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php76
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php24
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php66
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php84
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php24
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php6
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php42
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php20
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php44
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php22
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php10
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestResponseForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php74
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php26
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestStoragePageCacheForm.php20
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php10
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php2
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php4
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php4
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php12
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php32
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php8
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php64
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php16
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php6
-rw-r--r--core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php10
-rw-r--r--core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php10
-rw-r--r--core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php10
-rw-r--r--core/modules/system/tests/modules/form_test/src/FormTestObject.php10
-rw-r--r--core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php10
-rw-r--r--core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/OperationBase.php2
-rw-r--r--core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php14
-rw-r--r--core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module2
-rw-r--r--core/modules/system/tests/modules/menu_test/menu_test.module26
-rw-r--r--core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php4
-rw-r--r--core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTest.php4
-rw-r--r--core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php2
-rw-r--r--core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php2
-rw-r--r--core/modules/system/tests/modules/menu_test/src/TestControllers.php2
-rw-r--r--core/modules/system/tests/modules/module_test/module_test.file.inc2
-rw-r--r--core/modules/system/tests/modules/module_test/module_test.install16
-rw-r--r--core/modules/system/tests/modules/module_test/module_test.module4
-rw-r--r--core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php24
-rw-r--r--core/modules/system/tests/modules/path_test/path_test.module4
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/Annotation/PluginExample.php4
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php24
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php44
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/TestLazyPluginCollection.php4
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/TestPluginManager.php4
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php8
-rw-r--r--core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php16
-rw-r--r--core/modules/system/tests/modules/requirements1_test/requirements1_test.install6
-rw-r--r--core/modules/system/tests/modules/router_test_directory/src/RouterTestServiceProvider.php2
-rw-r--r--core/modules/system/tests/modules/router_test_directory/src/TestContent.php2
-rw-r--r--core/modules/system/tests/modules/service_provider_test/src/TestClass.php4
-rw-r--r--core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php8
-rw-r--r--core/modules/system/tests/modules/session_test/src/EventSubscriber/SessionTestSubscriber.php4
-rw-r--r--core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php12
-rw-r--r--core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php30
-rw-r--r--core/modules/system/tests/modules/system_test/src/MockFileTransfer.php6
-rw-r--r--core/modules/system/tests/modules/system_test/system_test.module20
-rw-r--r--core/modules/system/tests/modules/test_page_test/src/Controller/Test.php8
-rw-r--r--core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module6
-rw-r--r--core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php14
-rw-r--r--core/modules/system/tests/modules/theme_test/src/ThemeTestController.php40
-rw-r--r--core/modules/system/tests/modules/theme_test/theme_test.module78
-rw-r--r--core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php14
-rw-r--r--core/modules/system/tests/modules/twig_extension_test/src/TwigExtensionTestController.php6
-rw-r--r--core/modules/system/tests/modules/twig_extension_test/twig_extension_test.module14
-rw-r--r--core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php20
-rw-r--r--core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module126
-rw-r--r--core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php4
-rw-r--r--core/modules/system/tests/modules/update_script_test/update_script_test.install10
-rw-r--r--core/modules/system/tests/modules/update_test_1/update_test_1.install8
-rw-r--r--core/modules/system/tests/modules/update_test_2/update_test_2.install12
-rw-r--r--core/modules/system/tests/modules/update_test_3/update_test_3.install4
-rw-r--r--core/modules/system/tests/modules/url_alter_test/src/PathProcessor.php2
-rw-r--r--core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php6
-rw-r--r--core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Cache/ClearTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php4
-rw-r--r--core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php16
-rw-r--r--core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php6
-rw-r--r--core/modules/system/tests/src/Functional/Entity/ConfigEntityImportTest.php10
-rw-r--r--core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php66
-rw-r--r--core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php8
-rw-r--r--core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php6
-rw-r--r--core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php520
-rw-r--r--core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php38
-rw-r--r--core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php22
-rw-r--r--core/modules/system/tests/src/Functional/File/ConfigTest.php10
-rw-r--r--core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php18
-rw-r--r--core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php4
-rw-r--r--core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php2
-rw-r--r--core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Form/FormObjectTest.php16
-rw-r--r--core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/Form/RedirectTest.php44
-rw-r--r--core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php28
-rw-r--r--core/modules/system/tests/src/Functional/Mail/MailTest.php12
-rw-r--r--core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php8
-rw-r--r--core/modules/system/tests/src/Functional/Module/InstallTest.php12
-rw-r--r--core/modules/system/tests/src/Functional/Module/ModuleTestBase.php22
-rw-r--r--core/modules/system/tests/src/Functional/Module/UninstallTest.php22
-rw-r--r--core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php16
-rw-r--r--core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php12
-rw-r--r--core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php14
-rw-r--r--core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php22
-rw-r--r--core/modules/system/tests/src/Functional/System/DateTimeTest.php58
-rw-r--r--core/modules/system/tests/src/Functional/System/IndexPhpTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php12
-rw-r--r--core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php8
-rw-r--r--core/modules/system/tests/src/Functional/System/StatusTest.php14
-rw-r--r--core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php6
-rw-r--r--core/modules/system/tests/src/Functional/System/TrustedHostsTest.php16
-rw-r--r--core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/Theme/FastTest.php6
-rw-r--r--core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php2
-rw-r--r--core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php20
-rw-r--r--core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php4
-rw-r--r--core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php4
-rw-r--r--core/modules/system/tests/src/Kernel/Action/ActionTest.php26
-rw-r--r--core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php72
-rw-r--r--core/modules/system/tests/src/Kernel/Common/SystemListingTest.php20
-rw-r--r--core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php50
-rw-r--r--core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php2
-rw-r--r--core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php2
-rw-r--r--core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php2
-rw-r--r--core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php14
-rw-r--r--core/modules/system/tests/src/Kernel/Render/ClassyTest.php6
-rw-r--r--core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php4
-rw-r--r--core/modules/system/tests/src/Kernel/System/CronQueueTest.php2
-rw-r--r--core/modules/system/tests/src/Kernel/System/InfoAlterTest.php4
-rw-r--r--core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php50
-rw-r--r--core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php4
-rw-r--r--core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php38
-rw-r--r--core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php24
-rw-r--r--core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php24
-rw-r--r--core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php24
-rw-r--r--core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine2
-rw-r--r--core/modules/system/tests/themes/test_subtheme/test_subtheme.theme2
-rw-r--r--core/modules/taxonomy/src/Controller/TaxonomyController.php2
-rw-r--r--core/modules/taxonomy/src/Entity/Term.php20
-rw-r--r--core/modules/taxonomy/src/Entity/Vocabulary.php4
-rw-r--r--core/modules/taxonomy/src/Form/OverviewTerms.php118
-rw-r--r--core/modules/taxonomy/src/Form/TermDeleteForm.php4
-rw-r--r--core/modules/taxonomy/src/Form/VocabularyDeleteForm.php4
-rw-r--r--core/modules/taxonomy/src/Form/VocabularyResetForm.php6
-rw-r--r--core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php2
-rw-r--r--core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php12
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php10
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/source/Term.php6
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php14
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php10
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php2
-rw-r--r--core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php8
-rw-r--r--core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php2
-rw-r--r--core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php18
-rw-r--r--core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php78
-rw-r--r--core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php8
-rw-r--r--core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php40
-rw-r--r--core/modules/taxonomy/src/Plugin/views/field/TermName.php6
-rw-r--r--core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php78
-rw-r--r--core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php10
-rw-r--r--core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php10
-rw-r--r--core/modules/taxonomy/src/TermBreadcrumbBuilder.php2
-rw-r--r--core/modules/taxonomy/src/TermForm.php36
-rw-r--r--core/modules/taxonomy/src/TermStorage.php84
-rw-r--r--core/modules/taxonomy/src/TermStorageInterface.php2
-rw-r--r--core/modules/taxonomy/src/TermStorageSchema.php94
-rw-r--r--core/modules/taxonomy/src/TermTranslationHandler.php2
-rw-r--r--core/modules/taxonomy/src/TermViewBuilder.php8
-rw-r--r--core/modules/taxonomy/src/TermViewsData.php136
-rw-r--r--core/modules/taxonomy/src/Tests/RssTest.php30
-rw-r--r--core/modules/taxonomy/src/Tests/TaxonomyImageTest.php34
-rw-r--r--core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php2
-rw-r--r--core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php10
-rw-r--r--core/modules/taxonomy/src/Tests/TaxonomyTestBase.php4
-rw-r--r--core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php2
-rw-r--r--core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php16
-rw-r--r--core/modules/taxonomy/src/Tests/TermTest.php100
-rw-r--r--core/modules/taxonomy/src/Tests/TermTranslationTest.php24
-rw-r--r--core/modules/taxonomy/src/Tests/TermTranslationUITest.php24
-rw-r--r--core/modules/taxonomy/src/Tests/ThemeTest.php4
-rw-r--r--core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php20
-rw-r--r--core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php16
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php6
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php2
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php36
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php2
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php2
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php4
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php6
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php4
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php22
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php32
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php2
-rw-r--r--core/modules/taxonomy/src/Tests/VocabularyUiTest.php22
-rw-r--r--core/modules/taxonomy/src/VocabularyForm.php48
-rw-r--r--core/modules/taxonomy/src/VocabularyListBuilder.php12
-rw-r--r--core/modules/taxonomy/src/VocabularyStorage.php2
-rw-r--r--core/modules/taxonomy/taxonomy.module68
-rw-r--r--core/modules/taxonomy/taxonomy.tokens.inc72
-rw-r--r--core/modules/taxonomy/taxonomy.views.inc32
-rw-r--r--core/modules/taxonomy/tests/src/Functional/EfqTest.php14
-rw-r--r--core/modules/taxonomy/tests/src/Functional/LegacyTest.php16
-rw-r--r--core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php8
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TaxonomyTestBase.php4
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TermCacheTagsTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TermEntityReferenceTest.php32
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TermIndexTest.php80
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php28
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php12
-rw-r--r--core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php50
-rw-r--r--core/modules/taxonomy/tests/src/Functional/VocabularyCrudTest.php32
-rw-r--r--core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php22
-rw-r--r--core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php26
-rw-r--r--core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/MigrateTaxonomyConfigsTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php46
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php4
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateNodeTaxonomyTest.php16
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php2
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php22
-rw-r--r--core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php14
-rw-r--r--core/modules/taxonomy/tests/src/Unit/Menu/TaxonomyLocalTasksTest.php18
-rw-r--r--core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php22
-rw-r--r--core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php26
-rw-r--r--core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php16
-rw-r--r--core/modules/telephone/telephone.module4
-rw-r--r--core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php32
-rw-r--r--core/modules/telephone/tests/src/Kernel/TelephoneItemTest.php6
-rw-r--r--core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php6
-rw-r--r--core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php20
-rw-r--r--core/modules/text/src/Plugin/Field/FieldType/TextItem.php46
-rw-r--r--core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php6
-rw-r--r--core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php22
-rw-r--r--core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php36
-rw-r--r--core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php2
-rw-r--r--core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php22
-rw-r--r--core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php2
-rw-r--r--core/modules/text/src/Plugin/migrate/cckfield/TextField.php4
-rw-r--r--core/modules/text/src/Tests/TextFieldTest.php60
-rw-r--r--core/modules/text/tests/src/Kernel/TextFormatterTest.php34
-rw-r--r--core/modules/text/tests/src/Kernel/TextSummaryTest.php36
-rw-r--r--core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php18
-rw-r--r--core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php58
-rw-r--r--core/modules/text/text.module14
-rw-r--r--core/modules/toolbar/src/Element/Toolbar.php34
-rw-r--r--core/modules/toolbar/src/Element/ToolbarItem.php30
-rw-r--r--core/modules/toolbar/src/Menu/ToolbarMenuLinkTree.php2
-rw-r--r--core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php42
-rw-r--r--core/modules/toolbar/src/Tests/ToolbarMenuTranslationTest.php16
-rw-r--r--core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module44
-rw-r--r--core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php4
-rw-r--r--core/modules/toolbar/toolbar.api.php92
-rw-r--r--core/modules/toolbar/toolbar.module124
-rw-r--r--core/modules/tour/src/Entity/Tour.php10
-rw-r--r--core/modules/tour/src/Plugin/tour/tip/TipPluginText.php2
-rw-r--r--core/modules/tour/src/Tests/TourTest.php58
-rw-r--r--core/modules/tour/src/Tests/TourTestBase.php8
-rw-r--r--core/modules/tour/src/Tests/TourTestBasic.php6
-rw-r--r--core/modules/tour/src/TourViewBuilder.php44
-rw-r--r--core/modules/tour/tests/src/Functional/TourCacheTagsTest.php2
-rw-r--r--core/modules/tour/tests/src/Kernel/TourPluginTest.php4
-rw-r--r--core/modules/tour/tests/src/Unit/Entity/TourTest.php122
-rw-r--r--core/modules/tour/tests/tour_test/src/Controller/TourTestController.php54
-rw-r--r--core/modules/tour/tour.module32
-rw-r--r--core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php2
-rw-r--r--core/modules/tracker/src/Tests/TrackerTest.php98
-rw-r--r--core/modules/tracker/src/Tests/Views/TrackerTestBase.php16
-rw-r--r--core/modules/tracker/src/Tests/Views/TrackerUserUidTest.php22
-rw-r--r--core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php16
-rw-r--r--core/modules/tracker/tracker.install86
-rw-r--r--core/modules/tracker/tracker.module48
-rw-r--r--core/modules/tracker/tracker.pages.inc48
-rw-r--r--core/modules/tracker/tracker.views.inc158
-rw-r--r--core/modules/update/src/Controller/UpdateController.php14
-rw-r--r--core/modules/update/src/Form/UpdateManagerInstall.php46
-rw-r--r--core/modules/update/src/Form/UpdateManagerUpdate.php98
-rw-r--r--core/modules/update/src/Form/UpdateReady.php24
-rw-r--r--core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php4
-rw-r--r--core/modules/update/src/Tests/UpdateContribTest.php176
-rw-r--r--core/modules/update/src/Tests/UpdateCoreTest.php72
-rw-r--r--core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php2
-rw-r--r--core/modules/update/src/Tests/UpdateTestBase.php2
-rw-r--r--core/modules/update/src/Tests/UpdateUploadTest.php52
-rw-r--r--core/modules/update/src/UpdateFetcher.php2
-rw-r--r--core/modules/update/src/UpdateManager.php14
-rw-r--r--core/modules/update/src/UpdateProcessor.php16
-rw-r--r--core/modules/update/src/UpdateSettingsForm.php34
-rw-r--r--core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php2
-rw-r--r--core/modules/update/tests/modules/update_test/src/Plugin/Archiver/UpdateTestArchiver.php4
-rw-r--r--core/modules/update/tests/modules/update_test/src/TestFileTransferWithSettingsForm.php6
-rw-r--r--core/modules/update/tests/modules/update_test/update_test.module12
-rw-r--r--core/modules/update/tests/src/Kernel/Migrate/d6/MigrateUpdateConfigsTest.php4
-rw-r--r--core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php42
-rw-r--r--core/modules/update/tests/src/Unit/UpdateFetcherTest.php14
-rw-r--r--core/modules/update/update.api.php22
-rw-r--r--core/modules/update/update.authorize.inc70
-rw-r--r--core/modules/update/update.compare.inc42
-rw-r--r--core/modules/update/update.fetch.inc4
-rw-r--r--core/modules/update/update.install6
-rw-r--r--core/modules/update/update.manager.inc32
-rw-r--r--core/modules/update/update.module100
-rw-r--r--core/modules/update/update.report.inc84
-rw-r--r--core/modules/user/src/AccountForm.php82
-rw-r--r--core/modules/user/src/AccountSettingsForm.php218
-rw-r--r--core/modules/user/src/Controller/UserController.php8
-rw-r--r--core/modules/user/src/Entity/Role.php4
-rw-r--r--core/modules/user/src/Entity/User.php36
-rw-r--r--core/modules/user/src/Form/UserCancelForm.php24
-rw-r--r--core/modules/user/src/Form/UserLoginForm.php38
-rw-r--r--core/modules/user/src/Form/UserMultipleCancelConfirm.php18
-rw-r--r--core/modules/user/src/Form/UserPasswordForm.php34
-rw-r--r--core/modules/user/src/Form/UserPasswordResetForm.php12
-rw-r--r--core/modules/user/src/Form/UserPermissionsForm.php70
-rw-r--r--core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php2
-rw-r--r--core/modules/user/src/PermissionHandler.php20
-rw-r--r--core/modules/user/src/Plugin/Action/CancelUser.php2
-rw-r--r--core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php8
-rw-r--r--core/modules/user/src/Plugin/Block/UserLoginBlock.php12
-rw-r--r--core/modules/user/src/Plugin/Condition/UserRole.php14
-rw-r--r--core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php42
-rw-r--r--core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php12
-rw-r--r--core/modules/user/src/Plugin/Search/UserSearch.php20
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidator.php2
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php2
-rw-r--r--core/modules/user/src/Plugin/migrate/destination/EntityUser.php4
-rw-r--r--core/modules/user/src/Plugin/migrate/destination/UserData.php2
-rw-r--r--core/modules/user/src/Plugin/migrate/process/ConvertTokens.php4
-rw-r--r--core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php2
-rw-r--r--core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php4
-rw-r--r--core/modules/user/src/Plugin/migrate/source/ProfileField.php6
-rw-r--r--core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php10
-rw-r--r--core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldValues.php26
-rw-r--r--core/modules/user/src/Plugin/migrate/source/d6/Role.php12
-rw-r--r--core/modules/user/src/Plugin/migrate/source/d6/User.php18
-rw-r--r--core/modules/user/src/Plugin/migrate/source/d6/UserPicture.php6
-rw-r--r--core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php6
-rw-r--r--core/modules/user/src/Plugin/migrate/source/d7/Role.php4
-rw-r--r--core/modules/user/src/Plugin/migrate/source/d7/User.php22
-rw-r--r--core/modules/user/src/Plugin/views/access/Permission.php6
-rw-r--r--core/modules/user/src/Plugin/views/access/Role.php10
-rw-r--r--core/modules/user/src/Plugin/views/argument/RolesRid.php2
-rw-r--r--core/modules/user/src/Plugin/views/argument_default/User.php6
-rw-r--r--core/modules/user/src/Plugin/views/argument_validator/User.php26
-rw-r--r--core/modules/user/src/Plugin/views/argument_validator/UserName.php12
-rw-r--r--core/modules/user/src/Plugin/views/field/Permissions.php6
-rw-r--r--core/modules/user/src/Plugin/views/field/Roles.php8
-rw-r--r--core/modules/user/src/Plugin/views/field/UserBulkForm.php2
-rw-r--r--core/modules/user/src/Plugin/views/field/UserData.php14
-rw-r--r--core/modules/user/src/Plugin/views/filter/Name.php12
-rw-r--r--core/modules/user/src/Plugin/views/filter/Permissions.php2
-rw-r--r--core/modules/user/src/Plugin/views/filter/Roles.php2
-rw-r--r--core/modules/user/src/Plugin/views/wizard/Users.php8
-rw-r--r--core/modules/user/src/PrivateTempStore.php4
-rw-r--r--core/modules/user/src/ProfileForm.php10
-rw-r--r--core/modules/user/src/ProfileTranslationHandler.php2
-rw-r--r--core/modules/user/src/RegisterForm.php12
-rw-r--r--core/modules/user/src/RoleForm.php24
-rw-r--r--core/modules/user/src/RoleListBuilder.php4
-rw-r--r--core/modules/user/src/SharedTempStore.php8
-rw-r--r--core/modules/user/src/Tests/UserAccountLinksTest.php28
-rw-r--r--core/modules/user/src/Tests/UserAdminLanguageTest.php16
-rw-r--r--core/modules/user/src/Tests/UserAdminListingTest.php18
-rw-r--r--core/modules/user/src/Tests/UserAdminSettingsFormTest.php24
-rw-r--r--core/modules/user/src/Tests/UserAdminTest.php66
-rw-r--r--core/modules/user/src/Tests/UserBlocksTest.php20
-rw-r--r--core/modules/user/src/Tests/UserCancelTest.php162
-rw-r--r--core/modules/user/src/Tests/UserCreateTest.php32
-rw-r--r--core/modules/user/src/Tests/UserEditTest.php28
-rw-r--r--core/modules/user/src/Tests/UserLanguageCreationTest.php20
-rw-r--r--core/modules/user/src/Tests/UserLoginTest.php26
-rw-r--r--core/modules/user/src/Tests/UserPasswordResetTest.php54
-rw-r--r--core/modules/user/src/Tests/UserPermissionsTest.php16
-rw-r--r--core/modules/user/src/Tests/UserPictureTest.php22
-rw-r--r--core/modules/user/src/Tests/UserRegistrationTest.php56
-rw-r--r--core/modules/user/src/Tests/UserRoleAdminTest.php30
-rw-r--r--core/modules/user/src/Tests/UserTimeZoneTest.php12
-rw-r--r--core/modules/user/src/Tests/UserTranslationUITest.php12
-rw-r--r--core/modules/user/src/Tests/Views/AccessPermissionTest.php2
-rw-r--r--core/modules/user/src/Tests/Views/AccessRoleTest.php14
-rw-r--r--core/modules/user/src/Tests/Views/AccessRoleUITest.php16
-rw-r--r--core/modules/user/src/Tests/Views/AccessTestBase.php6
-rw-r--r--core/modules/user/src/Tests/Views/ArgumentDefaultTest.php2
-rw-r--r--core/modules/user/src/Tests/Views/ArgumentValidateTest.php4
-rw-r--r--core/modules/user/src/Tests/Views/BulkFormAccessTest.php34
-rw-r--r--core/modules/user/src/Tests/Views/BulkFormTest.php38
-rw-r--r--core/modules/user/src/Tests/Views/FilterPermissionUiTest.php2
-rw-r--r--core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php12
-rw-r--r--core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php8
-rw-r--r--core/modules/user/src/Tests/Views/HandlerFieldUserNameTest.php4
-rw-r--r--core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php60
-rw-r--r--core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php16
-rw-r--r--core/modules/user/src/Tests/Views/RolesRidArgumentTest.php2
-rw-r--r--core/modules/user/src/Tests/Views/UserChangedTest.php8
-rw-r--r--core/modules/user/src/Tests/Views/UserDataTest.php2
-rw-r--r--core/modules/user/src/Tests/Views/UserTestBase.php12
-rw-r--r--core/modules/user/src/UserAccessControlHandler.php4
-rw-r--r--core/modules/user/src/UserAuth.php2
-rw-r--r--core/modules/user/src/UserData.php14
-rw-r--r--core/modules/user/src/UserListBuilder.php42
-rw-r--r--core/modules/user/src/UserStorage.php10
-rw-r--r--core/modules/user/src/UserStorageSchema.php6
-rw-r--r--core/modules/user/src/UserViewsData.php180
-rw-r--r--core/modules/user/tests/fixtures/update/drupal-8.user-email-token-2587275.php6
-rw-r--r--core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module2
-rw-r--r--core/modules/user/tests/src/Functional/UserCacheTagsTest.php2
-rw-r--r--core/modules/user/tests/src/Functional/UserCreateFailMailTest.php10
-rw-r--r--core/modules/user/tests/src/Functional/UserDeleteTest.php18
-rw-r--r--core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php6
-rw-r--r--core/modules/user/tests/src/Functional/UserEntityCallbacksTest.php2
-rw-r--r--core/modules/user/tests/src/Functional/UserLanguageTest.php12
-rw-r--r--core/modules/user/tests/src/Functional/UserMailNotifyTest.php2
-rw-r--r--core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php20
-rw-r--r--core/modules/user/tests/src/Functional/UserSearchTest.php32
-rw-r--r--core/modules/user/tests/src/Functional/UserTokenReplaceTest.php26
-rw-r--r--core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php38
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldTest.php4
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureFileTest.php2
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php14
-rw-r--r--core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php8
-rw-r--r--core/modules/user/tests/src/Kernel/TempStoreDatabaseTest.php10
-rw-r--r--core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php14
-rw-r--r--core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php4
-rw-r--r--core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php20
-rw-r--r--core/modules/user/tests/src/Kernel/UserEntityTest.php24
-rw-r--r--core/modules/user/tests/src/Kernel/UserFieldsTest.php2
-rw-r--r--core/modules/user/tests/src/Kernel/UserInstallTest.php2
-rw-r--r--core/modules/user/tests/src/Kernel/UserRoleDeleteTest.php14
-rw-r--r--core/modules/user/tests/src/Kernel/UserSaveStatusTest.php6
-rw-r--r--core/modules/user/tests/src/Kernel/UserValidationTest.php68
-rw-r--r--core/modules/user/tests/src/Kernel/Views/HandlerFieldPermissionTest.php8
-rw-r--r--core/modules/user/tests/src/Kernel/Views/HandlerFilterPermissionTest.php48
-rw-r--r--core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php2
-rw-r--r--core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php24
-rw-r--r--core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php46
-rw-r--r--core/modules/user/tests/src/Unit/PermissionHandlerTest.php78
-rw-r--r--core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php8
-rw-r--r--core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php8
-rw-r--r--core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php22
-rw-r--r--core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php2
-rw-r--r--core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php8
-rw-r--r--core/modules/user/tests/src/Unit/PrivateTempStoreTest.php4
-rw-r--r--core/modules/user/tests/src/Unit/SharedTempStoreTest.php4
-rw-r--r--core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php128
-rw-r--r--core/modules/user/tests/src/Unit/UserAuthTest.php34
-rw-r--r--core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php32
-rw-r--r--core/modules/user/user.api.php18
-rw-r--r--core/modules/user/user.install52
-rw-r--r--core/modules/user/user.module262
-rw-r--r--core/modules/user/user.tokens.inc60
-rw-r--r--core/modules/user/user.views_execution.inc2
-rw-r--r--core/modules/views/src/Ajax/HighlightCommand.php4
-rw-r--r--core/modules/views/src/Ajax/ReplaceTitleCommand.php4
-rw-r--r--core/modules/views/src/Ajax/ScrollTopCommand.php4
-rw-r--r--core/modules/views/src/Ajax/ShowButtonsCommand.php4
-rw-r--r--core/modules/views/src/Ajax/TriggerPreviewCommand.php4
-rw-r--r--core/modules/views/src/Analyzer.php14
-rw-r--r--core/modules/views/src/Controller/ViewAjaxController.php4
-rw-r--r--core/modules/views/src/DisplayPluginCollection.php2
-rw-r--r--core/modules/views/src/Element/View.php14
-rw-r--r--core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php4
-rw-r--r--core/modules/views/src/Entity/View.php30
-rw-r--r--core/modules/views/src/EntityViewsData.php32
-rw-r--r--core/modules/views/src/EventSubscriber/RouteSubscriber.php6
-rw-r--r--core/modules/views/src/ExposedFormCache.php4
-rw-r--r--core/modules/views/src/Form/ViewsExposedForm.php22
-rw-r--r--core/modules/views/src/Form/ViewsForm.php10
-rw-r--r--core/modules/views/src/Form/ViewsFormMainForm.php22
-rw-r--r--core/modules/views/src/ManyToOneHelper.php46
-rw-r--r--core/modules/views/src/Plugin/Block/ViewsBlock.php4
-rw-r--r--core/modules/views/src/Plugin/Block/ViewsBlockBase.php48
-rw-r--r--core/modules/views/src/Plugin/Derivative/DefaultWizardDeriver.php6
-rw-r--r--core/modules/views/src/Plugin/Derivative/ViewsBlock.php14
-rw-r--r--core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php10
-rw-r--r--core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php12
-rw-r--r--core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php16
-rw-r--r--core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php10
-rw-r--r--core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php2
-rw-r--r--core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php38
-rw-r--r--core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php12
-rw-r--r--core/modules/views/src/Plugin/Menu/ViewsMenuLink.php4
-rw-r--r--core/modules/views/src/Plugin/ViewsHandlerManager.php12
-rw-r--r--core/modules/views/src/Plugin/ViewsPluginManager.php4
-rw-r--r--core/modules/views/src/Plugin/views/BrokenHandlerTrait.php26
-rw-r--r--core/modules/views/src/Plugin/views/HandlerBase.php48
-rw-r--r--core/modules/views/src/Plugin/views/PluginBase.php64
-rw-r--r--core/modules/views/src/Plugin/views/ViewsPluginInterface.php4
-rw-r--r--core/modules/views/src/Plugin/views/area/AreaPluginBase.php6
-rw-r--r--core/modules/views/src/Plugin/views/area/Broken.php2
-rw-r--r--core/modules/views/src/Plugin/views/area/Entity.php8
-rw-r--r--core/modules/views/src/Plugin/views/area/HTTPStatusCode.php12
-rw-r--r--core/modules/views/src/Plugin/views/area/Messages.php6
-rw-r--r--core/modules/views/src/Plugin/views/area/Result.php22
-rw-r--r--core/modules/views/src/Plugin/views/area/Text.php22
-rw-r--r--core/modules/views/src/Plugin/views/area/TextCustom.php12
-rw-r--r--core/modules/views/src/Plugin/views/area/Title.php8
-rw-r--r--core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php36
-rw-r--r--core/modules/views/src/Plugin/views/area/View.php20
-rw-r--r--core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php366
-rw-r--r--core/modules/views/src/Plugin/views/argument/Date.php10
-rw-r--r--core/modules/views/src/Plugin/views/argument/Formula.php4
-rw-r--r--core/modules/views/src/Plugin/views/argument/GroupByNumeric.php4
-rw-r--r--core/modules/views/src/Plugin/views/argument/ManyToOne.php26
-rw-r--r--core/modules/views/src/Plugin/views/argument/NullArgument.php8
-rw-r--r--core/modules/views/src/Plugin/views/argument/NumericArgument.php24
-rw-r--r--core/modules/views/src/Plugin/views/argument/StringArgument.php80
-rw-r--r--core/modules/views/src/Plugin/views/argument/WeekDate.php2
-rw-r--r--core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php4
-rw-r--r--core/modules/views/src/Plugin/views/argument_default/Fixed.php6
-rw-r--r--core/modules/views/src/Plugin/views/argument_default/QueryParameter.php22
-rw-r--r--core/modules/views/src/Plugin/views/argument_default/Raw.php12
-rw-r--r--core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php4
-rw-r--r--core/modules/views/src/Plugin/views/argument_validator/Entity.php54
-rw-r--r--core/modules/views/src/Plugin/views/cache/CachePluginBase.php12
-rw-r--r--core/modules/views/src/Plugin/views/cache/Time.php52
-rw-r--r--core/modules/views/src/Plugin/views/display/Attachment.php76
-rw-r--r--core/modules/views/src/Plugin/views/display/Block.php84
-rw-r--r--core/modules/views/src/Plugin/views/display/DisplayPluginBase.php786
-rw-r--r--core/modules/views/src/Plugin/views/display/EntityReference.php8
-rw-r--r--core/modules/views/src/Plugin/views/display/Feed.php44
-rw-r--r--core/modules/views/src/Plugin/views/display/Page.php304
-rw-r--r--core/modules/views/src/Plugin/views/display/PathPluginBase.php54
-rw-r--r--core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php106
-rw-r--r--core/modules/views/src/Plugin/views/exposed_form/InputRequired.php24
-rw-r--r--core/modules/views/src/Plugin/views/field/Boolean.php64
-rw-r--r--core/modules/views/src/Plugin/views/field/Counter.php6
-rw-r--r--core/modules/views/src/Plugin/views/field/Custom.php6
-rw-r--r--core/modules/views/src/Plugin/views/field/Date.php62
-rw-r--r--core/modules/views/src/Plugin/views/field/Dropbutton.php4
-rw-r--r--core/modules/views/src/Plugin/views/field/EntityField.php216
-rw-r--r--core/modules/views/src/Plugin/views/field/EntityLabel.php10
-rw-r--r--core/modules/views/src/Plugin/views/field/EntityOperations.php14
-rw-r--r--core/modules/views/src/Plugin/views/field/FieldPluginBase.php750
-rw-r--r--core/modules/views/src/Plugin/views/field/FileSize.php10
-rw-r--r--core/modules/views/src/Plugin/views/field/LanguageField.php6
-rw-r--r--core/modules/views/src/Plugin/views/field/LinkBase.php2
-rw-r--r--core/modules/views/src/Plugin/views/field/Links.php20
-rw-r--r--core/modules/views/src/Plugin/views/field/MachineName.php8
-rw-r--r--core/modules/views/src/Plugin/views/field/Markup.php2
-rw-r--r--core/modules/views/src/Plugin/views/field/NumericField.php76
-rw-r--r--core/modules/views/src/Plugin/views/field/PrerenderList.php34
-rw-r--r--core/modules/views/src/Plugin/views/field/Serialized.php28
-rw-r--r--core/modules/views/src/Plugin/views/field/TimeInterval.php6
-rw-r--r--core/modules/views/src/Plugin/views/field/Url.php6
-rw-r--r--core/modules/views/src/Plugin/views/filter/BooleanOperator.php32
-rw-r--r--core/modules/views/src/Plugin/views/filter/Bundle.php4
-rw-r--r--core/modules/views/src/Plugin/views/filter/Combine.php36
-rw-r--r--core/modules/views/src/Plugin/views/filter/Date.php14
-rw-r--r--core/modules/views/src/Plugin/views/filter/Equality.php8
-rw-r--r--core/modules/views/src/Plugin/views/filter/FilterPluginBase.php428
-rw-r--r--core/modules/views/src/Plugin/views/filter/GroupByNumeric.php8
-rw-r--r--core/modules/views/src/Plugin/views/filter/InOperator.php68
-rw-r--r--core/modules/views/src/Plugin/views/filter/ManyToOne.php30
-rw-r--r--core/modules/views/src/Plugin/views/filter/NumericFilter.php114
-rw-r--r--core/modules/views/src/Plugin/views/filter/StringFilter.php94
-rw-r--r--core/modules/views/src/Plugin/views/join/JoinPluginBase.php14
-rw-r--r--core/modules/views/src/Plugin/views/join/Subquery.php4
-rw-r--r--core/modules/views/src/Plugin/views/pager/Full.php30
-rw-r--r--core/modules/views/src/Plugin/views/pager/Mini.php12
-rw-r--r--core/modules/views/src/Plugin/views/pager/None.php8
-rw-r--r--core/modules/views/src/Plugin/views/pager/Some.php16
-rw-r--r--core/modules/views/src/Plugin/views/pager/SqlBase.php170
-rw-r--r--core/modules/views/src/Plugin/views/query/QueryPluginBase.php12
-rw-r--r--core/modules/views/src/Plugin/views/query/Sql.php248
-rw-r--r--core/modules/views/src/Plugin/views/relationship/EntityReverse.php8
-rw-r--r--core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php42
-rw-r--r--core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php6
-rw-r--r--core/modules/views/src/Plugin/views/row/EntityReference.php2
-rw-r--r--core/modules/views/src/Plugin/views/row/EntityRow.php6
-rw-r--r--core/modules/views/src/Plugin/views/row/Fields.php50
-rw-r--r--core/modules/views/src/Plugin/views/row/OpmlFields.php118
-rw-r--r--core/modules/views/src/Plugin/views/row/RowPluginBase.php18
-rw-r--r--core/modules/views/src/Plugin/views/row/RssFields.php74
-rw-r--r--core/modules/views/src/Plugin/views/row/RssPluginBase.php8
-rw-r--r--core/modules/views/src/Plugin/views/sort/Date.php10
-rw-r--r--core/modules/views/src/Plugin/views/sort/GroupByNumeric.php4
-rw-r--r--core/modules/views/src/Plugin/views/sort/SortPluginBase.php76
-rw-r--r--core/modules/views/src/Plugin/views/style/DefaultSummary.php40
-rw-r--r--core/modules/views/src/Plugin/views/style/EntityReference.php8
-rw-r--r--core/modules/views/src/Plugin/views/style/Grid.php44
-rw-r--r--core/modules/views/src/Plugin/views/style/HtmlList.php20
-rw-r--r--core/modules/views/src/Plugin/views/style/Mapping.php34
-rw-r--r--core/modules/views/src/Plugin/views/style/Opml.php14
-rw-r--r--core/modules/views/src/Plugin/views/style/Rss.php22
-rw-r--r--core/modules/views/src/Plugin/views/style/StylePluginBase.php108
-rw-r--r--core/modules/views/src/Plugin/views/style/Table.php216
-rw-r--r--core/modules/views/src/Plugin/views/style/UnformattedSummary.php12
-rw-r--r--core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php350
-rw-r--r--core/modules/views/src/ResultRow.php2
-rw-r--r--core/modules/views/src/Routing/ViewPageController.php4
-rw-r--r--core/modules/views/src/Tests/DefaultViewsTest.php72
-rw-r--r--core/modules/views/src/Tests/Entity/BaseFieldAccessTest.php4
-rw-r--r--core/modules/views/src/Tests/Entity/FieldEntityTest.php12
-rw-r--r--core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php18
-rw-r--r--core/modules/views/src/Tests/Entity/ViewNonTranslatableEntityTest.php4
-rw-r--r--core/modules/views/src/Tests/FieldApiDataTest.php36
-rw-r--r--core/modules/views/src/Tests/GlossaryTest.php14
-rw-r--r--core/modules/views/src/Tests/Handler/AreaHTTPStatusCodeTest.php4
-rw-r--r--core/modules/views/src/Tests/Handler/AreaTest.php34
-rw-r--r--core/modules/views/src/Tests/Handler/ArgumentStringTest.php10
-rw-r--r--core/modules/views/src/Tests/Handler/FieldDropButtonTest.php10
-rw-r--r--core/modules/views/src/Tests/Handler/FieldEntityOperationsTest.php12
-rw-r--r--core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php20
-rw-r--r--core/modules/views/src/Tests/Handler/FieldWebTest.php90
-rw-r--r--core/modules/views/src/Tests/Handler/FilterDateTest.php64
-rw-r--r--core/modules/views/src/Tests/Handler/HandlerAllTest.php20
-rw-r--r--core/modules/views/src/Tests/Handler/HandlerTest.php86
-rw-r--r--core/modules/views/src/Tests/Plugin/AccessTest.php10
-rw-r--r--core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php42
-rw-r--r--core/modules/views/src/Tests/Plugin/CacheTagTest.php14
-rw-r--r--core/modules/views/src/Tests/Plugin/CacheWebTest.php12
-rw-r--r--core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php8
-rw-r--r--core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php6
-rw-r--r--core/modules/views/src/Tests/Plugin/DisplayEntityReferenceTest.php6
-rw-r--r--core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php4
-rw-r--r--core/modules/views/src/Tests/Plugin/DisplayFeedTest.php10
-rw-r--r--core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php10
-rw-r--r--core/modules/views/src/Tests/Plugin/DisplayTest.php54
-rw-r--r--core/modules/views/src/Tests/Plugin/ExposedFormTest.php42
-rw-r--r--core/modules/views/src/Tests/Plugin/FilterTest.php36
-rw-r--r--core/modules/views/src/Tests/Plugin/MiniPagerTest.php18
-rw-r--r--core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php8
-rw-r--r--core/modules/views/src/Tests/Plugin/PagerTest.php116
-rw-r--r--core/modules/views/src/Tests/Plugin/StyleGridTest.php12
-rw-r--r--core/modules/views/src/Tests/Plugin/StyleOpmlTest.php10
-rw-r--r--core/modules/views/src/Tests/Plugin/StyleTableTest.php22
-rw-r--r--core/modules/views/src/Tests/Plugin/StyleTest.php60
-rw-r--r--core/modules/views/src/Tests/Plugin/ViewsBulkTest.php2
-rw-r--r--core/modules/views/src/Tests/Plugin/ViewsFormTest.php2
-rw-r--r--core/modules/views/src/Tests/Plugin/ViewsSqlExceptionTest.php10
-rw-r--r--core/modules/views/src/Tests/SearchIntegrationTest.php14
-rw-r--r--core/modules/views/src/Tests/SearchMultilingualTest.php18
-rw-r--r--core/modules/views/src/Tests/ViewAjaxTest.php8
-rw-r--r--core/modules/views/src/Tests/ViewElementTest.php26
-rw-r--r--core/modules/views/src/Tests/ViewKernelTestBase.php12
-rw-r--r--core/modules/views/src/Tests/ViewRenderTest.php2
-rw-r--r--core/modules/views/src/Tests/ViewResultAssertionTrait.php14
-rw-r--r--core/modules/views/src/Tests/ViewTestBase.php10
-rw-r--r--core/modules/views/src/Tests/ViewTestData.php196
-rw-r--r--core/modules/views/src/Tests/ViewsEscapingTest.php6
-rw-r--r--core/modules/views/src/Tests/ViewsTemplateTest.php4
-rw-r--r--core/modules/views/src/Tests/ViewsThemeIntegrationTest.php6
-rw-r--r--core/modules/views/src/Tests/Wizard/BasicTest.php24
-rw-r--r--core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php16
-rw-r--r--core/modules/views/src/Tests/Wizard/MenuTest.php6
-rw-r--r--core/modules/views/src/Tests/Wizard/NodeWizardTest.php4
-rw-r--r--core/modules/views/src/Tests/Wizard/PagerTest.php10
-rw-r--r--core/modules/views/src/Tests/Wizard/SortingTest.php12
-rw-r--r--core/modules/views/src/Tests/Wizard/TaggedWithTest.php48
-rw-r--r--core/modules/views/src/Tests/Wizard/WizardTestBase.php4
-rw-r--r--core/modules/views/src/ViewExecutable.php76
-rw-r--r--core/modules/views/src/Views.php68
-rw-r--r--core/modules/views/src/ViewsData.php26
-rw-r--r--core/modules/views/src/ViewsDataHelper.php20
-rw-r--r--core/modules/views/tests/fixtures/update/argument-placeholder.php4
-rw-r--r--core/modules/views/tests/fixtures/update/boolean-filter-values.php4
-rw-r--r--core/modules/views/tests/fixtures/update/duplicate-field-handler.php4
-rw-r--r--core/modules/views/tests/modules/views_entity_test/views_entity_test.module4
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php6
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementEmbedForm.php6
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php6
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php8
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php2
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php10
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_default/ArgumentDefaultTest.php2
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php18
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php18
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php6
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php26
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php6
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php16
-rw-r--r--core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php6
-rw-r--r--core/modules/views/tests/modules/views_test_data/views_test_data.install4
-rw-r--r--core/modules/views/tests/modules/views_test_data/views_test_data.module30
-rw-r--r--core/modules/views/tests/modules/views_test_data/views_test_data.views.inc2
-rw-r--r--core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc4
-rw-r--r--core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/BasicTest.php60
-rw-r--r--core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php38
-rw-r--r--core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php18
-rw-r--r--core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php20
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/AreaMessagesTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php4
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/AreaTextTest.php20
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php6
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php6
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/ArgumentDateTest.php180
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/ArgumentNullTest.php20
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldBooleanTest.php12
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php40
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldCustomTest.php26
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldDateTest.php62
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php4
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php10
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php30
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FieldUrlTest.php20
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorStringTest.php96
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php124
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php160
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterEqualityTest.php108
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterInOperatorTest.php116
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php288
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php488
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/HandlerAliasTest.php12
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/SortDateTest.php204
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php26
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/SortTest.php50
-rw-r--r--core/modules/views/tests/src/Kernel/ModuleTest.php82
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php34
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/CacheTest.php100
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php12
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php4
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/JoinTest.php72
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/QueryTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php16
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/RelationshipTest.php52
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php6
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php4
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php8
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/StyleHtmlListTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php6
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/StyleTableUnitTest.php6
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/StyleUnformattedTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php24
-rw-r--r--core/modules/views/tests/src/Kernel/PluginInstanceTest.php10
-rw-r--r--core/modules/views/tests/src/Kernel/QueryGroupByTest.php34
-rw-r--r--core/modules/views/tests/src/Kernel/TestViewsTest.php2
-rw-r--r--core/modules/views/tests/src/Kernel/TokenReplaceTest.php34
-rw-r--r--core/modules/views/tests/src/Kernel/ViewExecutableTest.php34
-rw-r--r--core/modules/views/tests/src/Kernel/ViewStorageTest.php86
-rw-r--r--core/modules/views/tests/src/Kernel/ViewsHooksTest.php18
-rw-r--r--core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php8
-rw-r--r--core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php8
-rw-r--r--core/modules/views/tests/src/Unit/EntityViewsDataTest.php10
-rw-r--r--core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php40
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php14
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php42
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php2
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php8
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php42
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php6
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php2
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php48
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php78
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php140
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php44
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php20
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php6
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php30
-rw-r--r--core/modules/views/tests/src/Unit/PluginBaseTest.php294
-rw-r--r--core/modules/views/tests/src/Unit/PluginTypeListTest.php4
-rw-r--r--core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php2
-rw-r--r--core/modules/views/tests/src/Unit/ViewExecutableTest.php6
-rw-r--r--core/modules/views/tests/src/Unit/ViewsDataHelperTest.php38
-rw-r--r--core/modules/views/tests/src/Unit/ViewsDataTest.php44
-rw-r--r--core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php4
-rw-r--r--core/modules/views/views.api.php212
-rw-r--r--core/modules/views/views.module144
-rw-r--r--core/modules/views/views.theme.inc78
-rw-r--r--core/modules/views/views.tokens.inc52
-rw-r--r--core/modules/views/views.views.inc328
-rw-r--r--core/modules/views/views.views_execution.inc4
-rw-r--r--core/modules/views_ui/admin.inc48
-rw-r--r--core/modules/views_ui/src/Ajax/SetFormCommand.php4
-rw-r--r--core/modules/views_ui/src/Controller/ViewsUIController.php26
-rw-r--r--core/modules/views_ui/src/Form/AdvancedSettingsForm.php32
-rw-r--r--core/modules/views_ui/src/Form/Ajax/AddHandler.php92
-rw-r--r--core/modules/views_ui/src/Form/Ajax/Analyze.php4
-rw-r--r--core/modules/views_ui/src/Form/Ajax/ConfigHandler.php46
-rw-r--r--core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php18
-rw-r--r--core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php18
-rw-r--r--core/modules/views_ui/src/Form/Ajax/Display.php10
-rw-r--r--core/modules/views_ui/src/Form/Ajax/EditDetails.php24
-rw-r--r--core/modules/views_ui/src/Form/Ajax/Rearrange.php56
-rw-r--r--core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php102
-rw-r--r--core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php78
-rw-r--r--core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php10
-rw-r--r--core/modules/views_ui/src/Form/BasicSettingsForm.php80
-rw-r--r--core/modules/views_ui/src/Form/BreakLockForm.php10
-rw-r--r--core/modules/views_ui/src/Tests/AnalyzeTest.php14
-rw-r--r--core/modules/views_ui/src/Tests/ArgumentValidatorTest.php8
-rw-r--r--core/modules/views_ui/src/Tests/CachedDataUITest.php20
-rw-r--r--core/modules/views_ui/src/Tests/CustomBooleanTest.php54
-rw-r--r--core/modules/views_ui/src/Tests/DefaultViewsTest.php36
-rw-r--r--core/modules/views_ui/src/Tests/DisplayAttachmentTest.php32
-rw-r--r--core/modules/views_ui/src/Tests/DisplayCRUDTest.php42
-rw-r--r--core/modules/views_ui/src/Tests/DisplayExtenderUITest.php8
-rw-r--r--core/modules/views_ui/src/Tests/DisplayFeedTest.php12
-rw-r--r--core/modules/views_ui/src/Tests/DisplayPathTest.php54
-rw-r--r--core/modules/views_ui/src/Tests/DisplayTest.php66
-rw-r--r--core/modules/views_ui/src/Tests/DuplicateTest.php4
-rw-r--r--core/modules/views_ui/src/Tests/ExposedFormUITest.php50
-rw-r--r--core/modules/views_ui/src/Tests/FieldUITest.php10
-rw-r--r--core/modules/views_ui/src/Tests/FilterBooleanWebTest.php12
-rw-r--r--core/modules/views_ui/src/Tests/FilterNumericWebTest.php32
-rw-r--r--core/modules/views_ui/src/Tests/FilterUITest.php28
-rw-r--r--core/modules/views_ui/src/Tests/GroupByTest.php10
-rw-r--r--core/modules/views_ui/src/Tests/HandlerTest.php56
-rw-r--r--core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php10
-rw-r--r--core/modules/views_ui/src/Tests/OverrideDisplaysTest.php36
-rw-r--r--core/modules/views_ui/src/Tests/PreviewTest.php64
-rw-r--r--core/modules/views_ui/src/Tests/QueryTest.php6
-rw-r--r--core/modules/views_ui/src/Tests/RearrangeFieldsTest.php8
-rw-r--r--core/modules/views_ui/src/Tests/RedirectTest.php12
-rw-r--r--core/modules/views_ui/src/Tests/ReportTest.php4
-rw-r--r--core/modules/views_ui/src/Tests/RowUITest.php12
-rw-r--r--core/modules/views_ui/src/Tests/SettingsTest.php40
-rw-r--r--core/modules/views_ui/src/Tests/StorageTest.php14
-rw-r--r--core/modules/views_ui/src/Tests/StyleTableTest.php2
-rw-r--r--core/modules/views_ui/src/Tests/StyleUITest.php16
-rw-r--r--core/modules/views_ui/src/Tests/UITestBase.php14
-rw-r--r--core/modules/views_ui/src/Tests/UnsavedPreviewTest.php2
-rw-r--r--core/modules/views_ui/src/Tests/ViewEditTest.php48
-rw-r--r--core/modules/views_ui/src/Tests/ViewsListTest.php2
-rw-r--r--core/modules/views_ui/src/Tests/ViewsUITourTest.php16
-rw-r--r--core/modules/views_ui/src/Tests/WizardTest.php4
-rw-r--r--core/modules/views_ui/src/Tests/XssTest.php2
-rw-r--r--core/modules/views_ui/src/ViewAddForm.php72
-rw-r--r--core/modules/views_ui/src/ViewDuplicateForm.php22
-rw-r--r--core/modules/views_ui/src/ViewEditForm.php382
-rw-r--r--core/modules/views_ui/src/ViewFormBase.php12
-rw-r--r--core/modules/views_ui/src/ViewListBuilder.php154
-rw-r--r--core/modules/views_ui/src/ViewPreviewForm.php48
-rw-r--r--core/modules/views_ui/src/ViewUI.php238
-rw-r--r--core/modules/views_ui/tests/src/Kernel/TagTest.php10
-rw-r--r--core/modules/views_ui/tests/src/Unit/Form/Ajax/RearrangeFilterTest.php4
-rw-r--r--core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php80
-rw-r--r--core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php36
-rw-r--r--core/modules/views_ui/views_ui.module128
-rw-r--r--core/modules/views_ui/views_ui.theme.inc248
-rw-r--r--core/phpcs.xml.dist1
-rw-r--r--core/profiles/minimal/src/Tests/MinimalTest.php2
-rw-r--r--core/profiles/standard/standard.install28
-rw-r--r--core/profiles/standard/tests/src/Functional/StandardTest.php32
-rw-r--r--core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php2
-rw-r--r--core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php4
-rw-r--r--core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php8
-rw-r--r--core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php8
-rw-r--r--core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php2
-rw-r--r--core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php2
-rw-r--r--core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php6
-rw-r--r--core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php2
-rw-r--r--core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php18
-rw-r--r--core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php14
-rw-r--r--core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php84
-rw-r--r--core/tests/Drupal/KernelTests/Core/Common/SizeTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php42
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php234
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEventsTest.php44
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigFileContentTest.php30
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php26
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php106
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php38
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php20
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php98
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php48
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php30
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php18
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php74
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/FetchTest.php28
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/InsertTest.php68
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php18
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php22
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/MergeTest.php54
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/QueryTest.php20
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php314
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php22
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/SelectTest.php96
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php68
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php46
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php40
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php62
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php184
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php100
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php70
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php34
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php14
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php224
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php116
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php18
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php260
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php24
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php22
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php346
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php36
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php162
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php56
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php72
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php20
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php192
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php14
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php118
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/FileTestBase.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php28
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php32
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php22
-rw-r--r--core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php190
-rw-r--r--core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php22
-rw-r--r--core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php22
-rw-r--r--core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php34
-rw-r--r--core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php100
-rw-r--r--core/tests/Drupal/KernelTests/Core/Path/AliasTest.php44
-rw-r--r--core/tests/Drupal/KernelTests/Core/Path/PathUnitTestBase.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php12
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/Condition/RequestPathTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/ContextPluginTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php42
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php14
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php46
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php16
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php88
-rw-r--r--core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Queue/QueueTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php162
-rw-r--r--core/tests/Drupal/KernelTests/Core/Render/Element/TableSortExtenderTest.php74
-rw-r--r--core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php186
-rw-r--r--core/tests/Drupal/KernelTests/Core/Render/RenderTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php10
-rw-r--r--core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php20
-rw-r--r--core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php102
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php50
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php6
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php48
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php8
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php22
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php30
-rw-r--r--core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php28
-rw-r--r--core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php122
-rw-r--r--core/tests/Drupal/KernelTests/KernelTestBase.php62
-rw-r--r--core/tests/Drupal/KernelTests/KernelTestBaseTest.php60
-rw-r--r--core/tests/Drupal/Tests/BrowserTestBase.php48
-rw-r--r--core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php36
-rw-r--r--core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php198
-rw-r--r--core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php280
-rw-r--r--core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php294
-rw-r--r--core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php8
-rw-r--r--core/tests/Drupal/Tests/Component/DrupalComponentTest.php22
-rw-r--r--core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php92
-rw-r--r--core/tests/Drupal/Tests/Component/Graph/GraphTest.php94
-rw-r--r--core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php8
-rw-r--r--core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php4
-rw-r--r--core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php2
-rw-r--r--core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php6
-rw-r--r--core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php2
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php6
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php4
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php18
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php22
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php2
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php58
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php12
-rw-r--r--core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php2
-rw-r--r--core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php2
-rw-r--r--core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php14
-rw-r--r--core/tests/Drupal/Tests/Component/Serialization/JsonTest.php6
-rw-r--r--core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php78
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/BytesTest.php30
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/ColorTest.php48
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/CryptTest.php74
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php12
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/HtmlTest.php136
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/ImageTest.php102
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php108
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/NumberTest.php74
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/RandomTest.php6
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php24
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php184
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php302
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php268
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php126
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/VariableTest.php62
-rw-r--r--core/tests/Drupal/Tests/Component/Utility/XssTest.php330
-rw-r--r--core/tests/Drupal/Tests/Component/Uuid/UuidTest.php16
-rw-r--r--core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php162
-rw-r--r--core/tests/Drupal/Tests/Core/Access/AccessResultTest.php12
-rw-r--r--core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php12
-rw-r--r--core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php30
-rw-r--r--core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php18
-rw-r--r--core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php166
-rw-r--r--core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php16
-rw-r--r--core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php28
-rw-r--r--core/tests/Drupal/Tests/Core/Asset/CssCollectionGrouperUnitTest.php46
-rw-r--r--core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php130
-rw-r--r--core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php126
-rw-r--r--core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php50
-rw-r--r--core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php22
-rw-r--r--core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php28
-rw-r--r--core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php42
-rw-r--r--core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php24
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php38
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php30
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php18
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php6
-rw-r--r--core/tests/Drupal/Tests/Core/Common/AttributesTest.php32
-rw-r--r--core/tests/Drupal/Tests/Core/Common/DiffArrayTest.php28
-rw-r--r--core/tests/Drupal/Tests/Core/Common/TagsTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php68
-rw-r--r--core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Config/ConfigTest.php102
-rw-r--r--core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php112
-rw-r--r--core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityDependencyTest.php30
-rw-r--r--core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php28
-rw-r--r--core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php20
-rw-r--r--core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php76
-rw-r--r--core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php12
-rw-r--r--core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php40
-rw-r--r--core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php26
-rw-r--r--core/tests/Drupal/Tests/Core/Database/ConnectionTest.php130
-rw-r--r--core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php52
-rw-r--r--core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Datetime/DateTest.php220
-rw-r--r--core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php48
-rw-r--r--core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/BackendCompilerPassTest.php12
-rw-r--r--core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php56
-rw-r--r--core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php44
-rw-r--r--core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php20
-rw-r--r--core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/DrupalTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php26
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php48
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php20
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php26
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityRepositoryTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php122
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php122
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php58
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php108
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php1146
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php438
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php28
-rw-r--r--core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php260
-rw-r--r--core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php34
-rw-r--r--core/tests/Drupal/Tests/Core/EventSubscriber/PathRootsSubscriberTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php32
-rw-r--r--core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php172
-rw-r--r--core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php116
-rw-r--r--core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module6
-rw-r--r--core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all1/module_handler_test_all1.module2
-rw-r--r--core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php12
-rw-r--r--core/tests/Drupal/Tests/Core/Form/FormHelperTest.php100
-rw-r--r--core/tests/Drupal/Tests/Core/Form/FormStateTest.php62
-rw-r--r--core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php38
-rw-r--r--core/tests/Drupal/Tests/Core/Form/FormTestBase.php28
-rw-r--r--core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php232
-rw-r--r--core/tests/Drupal/Tests/Core/Form/OptGroupTest.php22
-rw-r--r--core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc24
-rw-r--r--core/tests/Drupal/Tests/Core/Image/ImageTest.php18
-rw-r--r--core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php70
-rw-r--r--core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php44
-rw-r--r--core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php16
-rw-r--r--core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php42
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php12
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php112
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php110
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php248
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php88
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php86
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php34
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/MenuLinkMock.php12
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php44
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php68
-rw-r--r--core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php110
-rw-r--r--core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php38
-rw-r--r--core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php84
-rw-r--r--core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php16
-rw-r--r--core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php66
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php58
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php138
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php30
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php48
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php12
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php60
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php30
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDirectoryDiscoveryTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php22
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/Fixtures/TestConfigurablePlugin.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php38
-rw-r--r--core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php66
-rw-r--r--core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php104
-rw-r--r--core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php46
-rw-r--r--core/tests/Drupal/Tests/Core/Render/ElementTest.php94
-rw-r--r--core/tests/Drupal/Tests/Core/Render/RendererTest.php22
-rw-r--r--core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php88
-rw-r--r--core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php6
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php24
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php22
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php14
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php26
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php26
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php94
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php44
-rw-r--r--core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php22
-rw-r--r--core/tests/Drupal/Tests/Core/Session/UserSessionTest.php80
-rw-r--r--core/tests/Drupal/Tests/Core/Site/SettingsTest.php22
-rw-r--r--core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php20
-rw-r--r--core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php20
-rw-r--r--core/tests/Drupal/Tests/Core/Template/AttributeTest.php118
-rw-r--r--core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php42
-rw-r--r--core/tests/Drupal/Tests/Core/Theme/RegistryTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/UrlTest.php48
-rw-r--r--core/tests/Drupal/Tests/Core/Utility/ErrorTest.php38
-rw-r--r--core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php218
-rw-r--r--core/tests/Drupal/Tests/Core/Utility/TokenTest.php12
-rw-r--r--core/tests/Drupal/Tests/RandomGeneratorTrait.php4
-rw-r--r--core/tests/Drupal/Tests/SchemaCheckTestTrait.php6
-rw-r--r--core/tests/Drupal/Tests/UnitTestCase.php18
-rw-r--r--core/tests/Drupal/Tests/WebAssert.php18
-rw-r--r--core/tests/TestSuites/TestSuiteBase.php2
-rw-r--r--core/tests/bootstrap.php10
-rw-r--r--core/themes/bartik/bartik.theme8
-rw-r--r--core/themes/bartik/color/color.inc72
-rw-r--r--core/themes/engines/twig/twig.engine2
-rw-r--r--core/themes/seven/seven.theme50
3953 files changed, 53398 insertions, 53397 deletions
diff --git a/core/authorize.php b/core/authorize.php
index 073770a07cd..a72e0ac6872 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -116,10 +116,10 @@ if ($is_allowed) {
drupal_set_message($results['page_message']['message'], $results['page_message']['type']);
}
- $content['authorize_report'] = array(
+ $content['authorize_report'] = [
'#theme' => 'authorize_report',
'#messages' => $results['messages'],
- );
+ ];
if (is_array($results['tasks'])) {
$links = $results['tasks'];
@@ -148,11 +148,11 @@ if ($is_allowed) {
];
}
- $content['next_steps'] = array(
+ $content['next_steps'] = [
'#theme' => 'item_list',
'#items' => $links,
'#title' => t('Next steps'),
- );
+ ];
}
// If a batch is running, let it run.
elseif ($request->query->has('batch')) {
@@ -189,9 +189,9 @@ else {
}
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
-$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'maintenance_page', array(
+$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'maintenance_page', [
'#show_messages' => $show_messages,
-));
+]);
if (!$is_allowed) {
$response->setStatusCode(403);
}
diff --git a/core/core.api.php b/core/core.api.php
index 68f46360bac..22447dfab57 100644
--- a/core/core.api.php
+++ b/core/core.api.php
@@ -2103,39 +2103,39 @@ function hook_mail_alter(&$message) {
function hook_mail($key, &$message, $params) {
$account = $params['account'];
$context = $params['context'];
- $variables = array(
+ $variables = [
'%site_name' => \Drupal::config('system.site')->get('name'),
'%username' => $account->getDisplayName(),
- );
+ ];
if ($context['hook'] == 'taxonomy') {
$entity = $params['entity'];
$vocabulary = Vocabulary::load($entity->id());
- $variables += array(
+ $variables += [
'%term_name' => $entity->name,
'%term_description' => $entity->description,
'%term_id' => $entity->id(),
'%vocabulary_name' => $vocabulary->label(),
'%vocabulary_description' => $vocabulary->getDescription(),
'%vocabulary_id' => $vocabulary->id(),
- );
+ ];
}
// Node-based variable translation is only available if we have a node.
if (isset($params['node'])) {
/** @var \Drupal\node\NodeInterface $node */
$node = $params['node'];
- $variables += array(
+ $variables += [
'%uid' => $node->getOwnerId(),
- '%url' => $node->url('canonical', array('absolute' => TRUE)),
+ '%url' => $node->url('canonical', ['absolute' => TRUE]),
'%node_type' => node_get_type_label($node),
'%title' => $node->getTitle(),
'%teaser' => $node->teaser,
'%body' => $node->body,
- );
+ ];
}
$subject = strtr($context['subject'], $variables);
$body = strtr($context['message'], $variables);
- $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
+ $message['subject'] .= str_replace(["\r", "\n"], '', $subject);
$message['body'][] = MailFormatHelper::htmlToText($body);
}
diff --git a/core/includes/batch.inc b/core/includes/batch.inc
index 84291ae29f5..5d05cd50392 100644
--- a/core/includes/batch.inc
+++ b/core/includes/batch.inc
@@ -50,7 +50,7 @@ function _batch_page(Request $request) {
// Register database update for the end of processing.
drupal_register_shutdown_function('_batch_shutdown');
- $build = array();
+ $build = [];
// Add batch-specific libraries.
foreach ($batch['sets'] as $batch_set) {
@@ -94,7 +94,7 @@ function _batch_do() {
// Perform actual processing.
list($percentage, $message, $label) = _batch_process();
- return new JsonResponse(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label));
+ return new JsonResponse(['status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label]);
}
/**
@@ -130,9 +130,9 @@ function _batch_progress_page() {
// it. While this causes invalid HTML, the same would be true if we didn't,
// as content is not allowed to appear after </html> anyway.
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
- $response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', array(
+ $response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', [
'#show_messages' => FALSE,
- ));
+ ]);
// Just use the content of the response.
$fallback = $response->getContent();
@@ -159,26 +159,26 @@ function _batch_progress_page() {
$url = $batch['url']->toString(TRUE)->getGeneratedUrl();
- $build = array(
+ $build = [
'#theme' => 'progress_bar',
'#percent' => $percentage,
- '#message' => array('#markup' => $message),
+ '#message' => ['#markup' => $message],
'#label' => $label,
- '#attached' => array(
- 'html_head' => array(
- array(
- array(
+ '#attached' => [
+ 'html_head' => [
+ [
+ [
// Redirect through a 'Refresh' meta tag if JavaScript is disabled.
'#tag' => 'meta',
'#noscript' => TRUE,
- '#attributes' => array(
+ '#attributes' => [
'http-equiv' => 'Refresh',
'content' => '0; URL=' . $url,
- ),
- ),
+ ],
+ ],
'batch_progress_meta_refresh',
- ),
- ),
+ ],
+ ],
// Adds JavaScript code and settings for clients where JavaScript is enabled.
'drupalSettings' => [
'batch' => [
@@ -187,11 +187,11 @@ function _batch_progress_page() {
'uri' => $url,
],
],
- 'library' => array(
+ 'library' => [
'core/drupal.batch',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $build;
}
@@ -243,13 +243,13 @@ function _batch_process() {
list($callback, $args) = $item->data;
// Build the 'context' array and execute the function call.
- $batch_context = array(
+ $batch_context = [
'sandbox' => &$current_set['sandbox'],
'results' => &$current_set['results'],
'finished' => &$finished,
'message' => &$task_message,
- );
- call_user_func_array($callback, array_merge($args, array(&$batch_context)));
+ ];
+ call_user_func_array($callback, array_merge($args, [&$batch_context]));
if ($finished >= 1) {
// Make sure this step is not counted twice when computing $current.
@@ -257,7 +257,7 @@ function _batch_process() {
// Remove the processed operation and clear the sandbox.
$queue->deleteItem($item);
$current_set['count']--;
- $current_set['sandbox'] = array();
+ $current_set['sandbox'] = [];
}
}
@@ -312,7 +312,7 @@ function _batch_process() {
$current = $total - $remaining + $finished;
$percentage = _batch_api_percentage($total, $current);
$elapsed = isset($current_set['elapsed']) ? $current_set['elapsed'] : 0;
- $values = array(
+ $values = [
'@remaining' => $remaining,
'@total' => $total,
'@current' => floor($current),
@@ -320,13 +320,13 @@ function _batch_process() {
'@elapsed' => \Drupal::service('date.formatter')->formatInterval($elapsed / 1000),
// If possible, estimate remaining processing time.
'@estimate' => ($current > 0) ? \Drupal::service('date.formatter')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',
- );
+ ];
$message = strtr($progress_message, $values);
if (!empty($task_message)) {
$label = $task_message;
}
- return array($percentage, $message, $label);
+ return [$percentage, $message, $label];
}
else {
// If we are not in progressive mode, the entire batch has been processed.
@@ -385,7 +385,7 @@ function _batch_next_set() {
// We use our stored copies of $form and $form_state to account for
// possible alterations by previous form submit handlers.
$complete_form = &$batch['form_state']->getCompleteForm();
- call_user_func_array($callback, array(&$complete_form, &$batch['form_state']));
+ call_user_func_array($callback, [&$complete_form, &$batch['form_state']]);
}
return TRUE;
}
@@ -411,7 +411,7 @@ function _batch_finished() {
if (is_callable($batch_set['finished'])) {
$queue = _batch_queue($batch_set);
$operations = $queue->getAllItems();
- $batch_set_result = call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)));
+ $batch_set_result = call_user_func_array($batch_set['finished'], [$batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)]);
// If a batch 'finished' callback requested a redirect after the batch
// is complete, save that for later use. If more than one batch set
// returned a redirect, the last one is used.
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 9c976eb0033..293f25ae9d2 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -197,7 +197,7 @@ function config_get_config_directory($type) {
function drupal_get_filename($type, $name, $filename = NULL) {
// The location of files will not change during the request, so do not use
// drupal_static().
- static $files = array();
+ static $files = [];
// Type 'core' only exists to simplify application-level logic; it always maps
// to the /core directory, whereas $name is ignored. It is only requested via
@@ -213,7 +213,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
$type = 'module';
}
if (!isset($files[$type])) {
- $files[$type] = array();
+ $files[$type] = [];
}
if (isset($filename)) {
@@ -233,11 +233,11 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// system_rebuild_module_data() and
// \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData().
if (!isset($files[$type][$name]) && \Drupal::hasService('state')) {
- $files[$type] += \Drupal::state()->get('system.' . $type . '.files', array());
+ $files[$type] += \Drupal::state()->get('system.' . $type . '.files', []);
}
// If still unknown, create a user-level error message.
if (!isset($files[$type][$name])) {
- trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', array('@type' => $type, '@name' => $name)), E_USER_WARNING);
+ trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING);
}
}
@@ -301,7 +301,7 @@ function drupal_get_path($type, $name) {
*
* @ingroup sanitization
*/
-function t($string, array $args = array(), array $options = array()) {
+function t($string, array $args = [], array $options = []) {
return new TranslatableMarkup($string, $args, $options);
}
@@ -376,7 +376,7 @@ function drupal_validate_utf8($text) {
*
* @see \Drupal\Core\Utility\Error::decodeException()
*/
-function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = RfcLogLevel::ERROR, $link = NULL) {
+function watchdog_exception($type, Exception $exception, $message = NULL, $variables = [], $severity = RfcLogLevel::ERROR, $link = NULL) {
// Use a default value if $message is not set.
if (empty($message)) {
@@ -447,7 +447,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) {
if (isset($message)) {
if (!isset($_SESSION['messages'][$type])) {
- $_SESSION['messages'][$type] = array();
+ $_SESSION['messages'][$type] = [];
}
// Convert strings which are safe to the simplest Markup objects.
@@ -501,7 +501,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
unset($_SESSION['messages'][$type]);
}
if (isset($messages[$type])) {
- return array($type => $messages[$type]);
+ return [$type => $messages[$type]];
}
}
else {
@@ -511,7 +511,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
return $messages;
}
}
- return array();
+ return [];
}
/**
@@ -899,7 +899,7 @@ function drupal_classloader_register($name, $path) {
* @see drupal_static_reset()
*/
function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
- static $data = array(), $default = array();
+ static $data = [], $default = [];
// First check if dealing with a previously defined static variable.
if (isset($data[$name]) || array_key_exists($name, $data)) {
// Non-NULL $name and both $data[$name] and $default[$name] statics exist.
@@ -978,7 +978,7 @@ function drupal_placeholder($text) {
function &drupal_register_shutdown_function($callback = NULL) {
// We cannot use drupal_static() here because the static cache is reset during
// batch processing, which breaks batch handling.
- static $callbacks = array();
+ static $callbacks = [];
if (isset($callback)) {
// Only register the internal shutdown function once.
@@ -989,7 +989,7 @@ function &drupal_register_shutdown_function($callback = NULL) {
// Remove $callback from the arguments.
unset($args[0]);
// Save callback and arguments
- $callbacks[] = array('callback' => $callback, 'arguments' => $args);
+ $callbacks[] = ['callback' => $callback, 'arguments' => $args];
}
return $callbacks;
}
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 037c5b0f448..323a666b89e 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -249,7 +249,7 @@ function check_url($uri) {
*/
function format_size($size, $langcode = NULL) {
if ($size < Bytes::KILOBYTE) {
- return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
+ return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', [], ['langcode' => $langcode]);
}
else {
$size = $size / Bytes::KILOBYTE; // Convert bytes to kilobytes.
@@ -352,7 +352,7 @@ function date_iso8601($date) {
* A ; separated string ready for insertion in a HTTP header. No escaping is
* performed for HTML entities, so this string is not safe to be printed.
*/
-function drupal_http_header_attributes(array $attributes = array()) {
+function drupal_http_header_attributes(array $attributes = []) {
foreach ($attributes as $attribute => &$data) {
if (is_array($data)) {
$data = implode(' ', $data);
@@ -433,18 +433,18 @@ function drupal_clear_css_cache() {
* @see hook_js_alter()
*/
function drupal_js_defaults($data = NULL) {
- return array(
+ return [
'type' => 'file',
'group' => JS_DEFAULT,
'weight' => 0,
'scope' => 'header',
'cache' => TRUE,
'preprocess' => TRUE,
- 'attributes' => array(),
+ 'attributes' => [],
'version' => NULL,
'data' => $data,
- 'browsers' => array(),
- );
+ 'browsers' => [],
+ ];
}
/**
@@ -704,12 +704,12 @@ function drupal_process_states(&$elements) {
*/
function drupal_attach_tabledrag(&$element, array $options) {
// Add default values to elements.
- $options = $options + array(
+ $options = $options + [
'subgroup' => NULL,
'source' => NULL,
'hidden' => TRUE,
'limit' => 0
- );
+ ];
$group = $options['group'];
@@ -719,14 +719,14 @@ function drupal_attach_tabledrag(&$element, array $options) {
// If a subgroup or source isn't set, assume it is the same as the group.
$target = isset($options['subgroup']) ? $options['subgroup'] : $group;
$source = isset($options['source']) ? $options['source'] : $target;
- $element['#attached']['drupalSettings']['tableDrag'][$options['table_id']][$group][$tabledrag_id] = array(
+ $element['#attached']['drupalSettings']['tableDrag'][$options['table_id']][$group][$tabledrag_id] = [
'target' => $target,
'source' => $source,
'relationship' => $options['relationship'],
'action' => $options['action'],
'hidden' => $options['hidden'],
'limit' => $options['limit'],
- );
+ ];
$element['#attached']['library'][] = 'core/drupal.tabledrag';
}
@@ -827,7 +827,7 @@ function drupal_pre_render_link($element) {
* properties of the parent are used.
*/
function drupal_pre_render_links($element) {
- $element += array('#links' => array(), '#attached' => array());
+ $element += ['#links' => [], '#attached' => []];
foreach (Element::children($element) as $key) {
$child = &$element[$key];
// If the child has links which have not been printed yet and the user has
@@ -1115,7 +1115,7 @@ function drupal_flush_all_caches() {
// Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not
// sufficient, since the list of enabled modules might have been adjusted
// above due to changed code.
- $files = array();
+ $files = [];
foreach ($module_data as $name => $extension) {
if ($extension->status) {
$files[$name] = $extension;
@@ -1217,7 +1217,7 @@ function drupal_check_incompatibility($v, $current_version) {
* validation system.
*/
function archiver_get_extensions() {
- $valid_extensions = array();
+ $valid_extensions = [];
foreach (\Drupal::service('plugin.manager.archiver')->getDefinitions() as $archive) {
foreach ($archive['extensions'] as $extension) {
foreach (explode('.', $extension) as $part) {
@@ -1246,9 +1246,9 @@ function archiver_get_archiver($file) {
// Archivers can only work on local paths
$filepath = drupal_realpath($file);
if (!is_file($filepath)) {
- throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file)));
+ throw new Exception(t('Archivers can only operate on local files: %file not supported', ['%file' => $file]));
}
- return \Drupal::service('plugin.manager.archiver')->getInstance(array('filepath' => $filepath));
+ return \Drupal::service('plugin.manager.archiver')->getInstance(['filepath' => $filepath]);
}
/**
@@ -1270,7 +1270,7 @@ function drupal_get_updaters() {
if (!isset($updaters)) {
$updaters = \Drupal::moduleHandler()->invokeAll('updater_info');
\Drupal::moduleHandler()->alter('updater_info', $updaters);
- uasort($updaters, array(SortArray::class, 'sortByWeightElement'));
+ uasort($updaters, [SortArray::class, 'sortByWeightElement']);
}
return $updaters;
}
@@ -1290,7 +1290,7 @@ function drupal_get_filetransfer_info() {
if (!isset($info)) {
$info = \Drupal::moduleHandler()->invokeAll('filetransfer_info');
\Drupal::moduleHandler()->alter('filetransfer_info', $info);
- uasort($info, array(SortArray::class, 'sortByWeightElement'));
+ uasort($info, [SortArray::class, 'sortByWeightElement']);
}
return $info;
}
diff --git a/core/includes/database.inc b/core/includes/database.inc
index ff03885a25c..d4cb593af6f 100644
--- a/core/includes/database.inc
+++ b/core/includes/database.inc
@@ -53,7 +53,7 @@ use Drupal\Core\Site\Settings;
* @see \Drupal\Core\Database\Connection::query()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_query($query, array $args = array(), array $options = array()) {
+function db_query($query, array $args = [], array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@@ -91,7 +91,7 @@ function db_query($query, array $args = array(), array $options = array()) {
* @see \Drupal\Core\Database\Connection::queryRange()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_query_range($query, $from, $count, array $args = array(), array $options = array()) {
+function db_query_range($query, $from, $count, array $args = [], array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@@ -127,7 +127,7 @@ function db_query_range($query, $from, $count, array $args = array(), array $opt
* @see \Drupal\Core\Database\Connection::queryTemporary()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_query_temporary($query, array $args = array(), array $options = array()) {
+function db_query_temporary($query, array $args = [], array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@@ -154,7 +154,7 @@ function db_query_temporary($query, array $args = array(), array $options = arra
* @see \Drupal\Core\Database\Connection::insert()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_insert($table, array $options = array()) {
+function db_insert($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@@ -180,7 +180,7 @@ function db_insert($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::merge()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_merge($table, array $options = array()) {
+function db_merge($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@@ -206,7 +206,7 @@ function db_merge($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::update()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_update($table, array $options = array()) {
+function db_update($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@@ -232,7 +232,7 @@ function db_update($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::delete()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_delete($table, array $options = array()) {
+function db_delete($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@@ -258,7 +258,7 @@ function db_delete($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::truncate()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_truncate($table, array $options = array()) {
+function db_truncate($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@@ -288,7 +288,7 @@ function db_truncate($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::select()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_select($table, $alias = NULL, array $options = array()) {
+function db_select($table, $alias = NULL, array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@@ -315,7 +315,7 @@ function db_select($table, $alias = NULL, array $options = array()) {
* @see \Drupal\Core\Database\Connection::startTransaction()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
-function db_transaction($name = NULL, array $options = array()) {
+function db_transaction($name = NULL, array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@@ -451,7 +451,7 @@ function db_driver() {
*
* @see \Drupal\Core\Database\Database::closeConnection()
*/
-function db_close(array $options = array()) {
+function db_close(array $options = []) {
if (empty($options['target'])) {
$options['target'] = NULL;
}
@@ -752,7 +752,7 @@ function db_drop_table($table) {
* @see \Drupal\Core\Database\Schema::addField()
* @see db_change_field()
*/
-function db_add_field($table, $field, $spec, $keys_new = array()) {
+function db_add_field($table, $field, $spec, $keys_new = []) {
return Database::getConnection()->schema()->addField($table, $field, $spec, $keys_new);
}
@@ -1020,7 +1020,7 @@ function db_drop_index($table, $name) {
*
* @see \Drupal\Core\Database\Schema::changeField()
*/
-function db_change_field($table, $field, $field_new, $spec, $keys_new = array()) {
+function db_change_field($table, $field, $field_new, $spec, $keys_new = []) {
return Database::getConnection()->schema()->changeField($table, $field, $field_new, $spec, $keys_new);
}
diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index 67122a2b6a9..45eaa3d8e40 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -80,7 +80,7 @@ function entity_get_bundles($entity_type = NULL) {
function entity_load($entity_type, $id, $reset = FALSE) {
$controller = \Drupal::entityManager()->getStorage($entity_type);
if ($reset) {
- $controller->resetCache(array($id));
+ $controller->resetCache([$id]);
}
return $controller->load($id);
}
@@ -305,7 +305,7 @@ function entity_delete_multiple($entity_type, array $ids) {
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
*/
-function entity_create($entity_type, array $values = array()) {
+function entity_create($entity_type, array $values = []) {
return \Drupal::entityManager()
->getStorage($entity_type)
->create($values);
@@ -483,12 +483,12 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
// configuration entries are only created when a display object is explicitly
// configured and saved.
if (!$display) {
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $view_mode,
'status' => TRUE,
- ));
+ ]);
}
return $display;
@@ -563,12 +563,12 @@ function entity_get_form_display($entity_type, $bundle, $form_mode) {
// configuration entries are only created when an entity form display is
// explicitly configured and saved.
if (!$entity_form_display) {
- $entity_form_display = EntityFormDisplay::create(array(
+ $entity_form_display = EntityFormDisplay::create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $form_mode,
'status' => TRUE,
- ));
+ ]);
}
return $entity_form_display;
diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index e3ad1c89e17..40e290338dc 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -21,23 +21,23 @@ use Symfony\Component\HttpFoundation\Response;
* @ingroup logging_severity_levels
*/
function drupal_error_levels() {
- $types = array(
- E_ERROR => array('Error', RfcLogLevel::ERROR),
- E_WARNING => array('Warning', RfcLogLevel::WARNING),
- E_PARSE => array('Parse error', RfcLogLevel::ERROR),
- E_NOTICE => array('Notice', RfcLogLevel::NOTICE),
- E_CORE_ERROR => array('Core error', RfcLogLevel::ERROR),
- E_CORE_WARNING => array('Core warning', RfcLogLevel::WARNING),
- E_COMPILE_ERROR => array('Compile error', RfcLogLevel::ERROR),
- E_COMPILE_WARNING => array('Compile warning', RfcLogLevel::WARNING),
- E_USER_ERROR => array('User error', RfcLogLevel::ERROR),
- E_USER_WARNING => array('User warning', RfcLogLevel::WARNING),
- E_USER_NOTICE => array('User notice', RfcLogLevel::NOTICE),
- E_STRICT => array('Strict warning', RfcLogLevel::DEBUG),
- E_RECOVERABLE_ERROR => array('Recoverable fatal error', RfcLogLevel::ERROR),
- E_DEPRECATED => array('Deprecated function', RfcLogLevel::DEBUG),
- E_USER_DEPRECATED => array('User deprecated function', RfcLogLevel::DEBUG),
- );
+ $types = [
+ E_ERROR => ['Error', RfcLogLevel::ERROR],
+ E_WARNING => ['Warning', RfcLogLevel::WARNING],
+ E_PARSE => ['Parse error', RfcLogLevel::ERROR],
+ E_NOTICE => ['Notice', RfcLogLevel::NOTICE],
+ E_CORE_ERROR => ['Core error', RfcLogLevel::ERROR],
+ E_CORE_WARNING => ['Core warning', RfcLogLevel::WARNING],
+ E_COMPILE_ERROR => ['Compile error', RfcLogLevel::ERROR],
+ E_COMPILE_WARNING => ['Compile warning', RfcLogLevel::WARNING],
+ E_USER_ERROR => ['User error', RfcLogLevel::ERROR],
+ E_USER_WARNING => ['User warning', RfcLogLevel::WARNING],
+ E_USER_NOTICE => ['User notice', RfcLogLevel::NOTICE],
+ E_STRICT => ['Strict warning', RfcLogLevel::DEBUG],
+ E_RECOVERABLE_ERROR => ['Recoverable fatal error', RfcLogLevel::ERROR],
+ E_DEPRECATED => ['Deprecated function', RfcLogLevel::DEBUG],
+ E_USER_DEPRECATED => ['User deprecated function', RfcLogLevel::DEBUG],
+ ];
return $types;
}
@@ -70,7 +70,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
// in PHP, we allow them to trigger a fatal error by emitting a user error
// using trigger_error().
$to_string = $error_level == E_USER_ERROR && substr($caller['function'], -strlen('__toString()')) == '__toString()';
- _drupal_log_error(array(
+ _drupal_log_error([
'%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
// The standard PHP error handler considers that the error messages
// are HTML. We mimick this behavior here.
@@ -81,7 +81,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
'severity_level' => $severity_level,
'backtrace' => $backtrace,
'@backtrace_string' => (new \Exception())->getTraceAsString(),
- ), $recoverable || $to_string);
+ ], $recoverable || $to_string);
}
}
@@ -139,15 +139,15 @@ function _drupal_log_error($error, $fatal = FALSE) {
// $number does not use drupal_static as it should not be reset
// as it uniquely identifies each PHP error.
static $number = 0;
- $assertion = array(
+ $assertion = [
$error['@message'],
$error['%type'],
- array(
+ [
'function' => $error['%function'],
'file' => $error['%file'],
'line' => $error['%line'],
- ),
- );
+ ],
+ ];
// For non-fatal errors (e.g. PHP notices) _drupal_log_error can be called
// multiple times per request. In that case the response is typically
// generated outside of the error handler, e.g., in a controller. As a
@@ -257,10 +257,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
if ($is_installer) {
// install_display_output() prints the output and ends script execution.
- $output = array(
+ $output = [
'#title' => 'Error',
'#markup' => $message,
- );
+ ];
install_display_output($output, $GLOBALS['install_state'], $response->headers->all());
exit;
}
diff --git a/core/includes/file.inc b/core/includes/file.inc
index 0dcd141ca24..c78ee5ba984 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -367,7 +367,7 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS
return drupal_chmod($htaccess_path, 0444);
}
else {
- $variables = array('%directory' => $directory, '@htaccess' => $htaccess_lines);
+ $variables = ['%directory' => $directory, '@htaccess' => $htaccess_lines];
\Drupal::logger('security')->error("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <pre><code>@htaccess</code></pre>", $variables);
return FALSE;
}
@@ -456,7 +456,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
$real_destination = drupal_realpath($destination) ?: $destination;
// Perform the copy operation.
if (!@copy($real_source, $real_destination)) {
- \Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination));
+ \Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', ['%file' => $source, '%destination' => $destination]);
return FALSE;
}
// Set the permissions on the new file.
@@ -501,12 +501,12 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
// Assert that the source file actually exists.
if (!file_exists($source)) {
// @todo Replace drupal_set_message() calls with exceptions instead.
- drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
+ drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', ['%file' => $original_source]), 'error');
if (($realpath = drupal_realpath($original_source)) !== FALSE) {
- $logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath));
+ $logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', ['%file' => $original_source, '%realpath' => $realpath]);
}
else {
- $logger->notice('File %file could not be moved/copied because it does not exist.', array('%file' => $original_source));
+ $logger->notice('File %file could not be moved/copied because it does not exist.', ['%file' => $original_source]);
}
return FALSE;
}
@@ -527,8 +527,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
$dirname = drupal_dirname($destination);
if (!file_prepare_directory($dirname)) {
// The destination is not valid.
- $logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', array('%file' => $original_source, '%destination' => $dirname));
- drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');
+ $logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', ['%file' => $original_source, '%destination' => $dirname]);
+ drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', ['%file' => $original_source]), 'error');
return FALSE;
}
}
@@ -536,8 +536,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
// Determine whether we can perform this operation based on overwrite rules.
$destination = file_destination($destination, $replace);
if ($destination === FALSE) {
- drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error');
- $logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', array('%file' => $original_source, '%destination' => $destination));
+ drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', ['%file' => $original_source]), 'error');
+ $logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', ['%file' => $original_source, '%destination' => $destination]);
return FALSE;
}
@@ -545,8 +545,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
$real_source = drupal_realpath($source);
$real_destination = drupal_realpath($destination);
if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) {
- drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', array('%file' => $source)), 'error');
- $logger->notice('File %file could not be moved/copied because it would overwrite itself.', array('%file' => $source));
+ drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', ['%file' => $source]), 'error');
+ $logger->notice('File %file could not be moved/copied because it would overwrite itself.', ['%file' => $source]);
return FALSE;
}
// Make sure the .htaccess files are present.
@@ -652,7 +652,7 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
// implemented. It's not necessary to use drupal_unlink() as the Windows
// issue has already been resolved above.
if (!@copy($real_source, $real_destination) || !@unlink($real_source)) {
- \Drupal::logger('file')->error('The specified file %file could not be moved to %destination.', array('%file' => $source, '%destination' => $destination));
+ \Drupal::logger('file')->error('The specified file %file could not be moved to %destination.', ['%file' => $source, '%destination' => $destination]);
return FALSE;
}
}
@@ -721,7 +721,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
$filename = $new_filename . '.' . $final_extension;
if ($alerts && $original != $filename) {
- drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename)));
+ drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', ['%filename' => $filename]));
}
}
@@ -762,7 +762,7 @@ function file_create_filename($basename, $directory) {
$basename = preg_replace('/[\x00-\x1F]/u', '_', $basename);
if (substr(PHP_OS, 0, 3) == 'WIN') {
// These characters are not allowed in Windows filenames
- $basename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $basename);
+ $basename = str_replace([':', '*', '?', '"', '<', '>', '|'], '_', $basename);
}
// A URI or path may already have a trailing slash or look like "public://".
@@ -810,7 +810,7 @@ function file_create_filename($basename, $directory) {
* @see \Drupal\file\FileUsage\FileUsageBase::delete()
*/
function file_delete($fid) {
- return file_delete_multiple(array($fid));
+ return file_delete_multiple([$fid]);
}
/**
@@ -852,18 +852,18 @@ function file_unmanaged_delete($path) {
}
$logger = \Drupal::logger('file');
if (is_dir($path)) {
- $logger->error('%path is a directory and cannot be removed using file_unmanaged_delete().', array('%path' => $path));
+ $logger->error('%path is a directory and cannot be removed using file_unmanaged_delete().', ['%path' => $path]);
return FALSE;
}
// Return TRUE for non-existent file, but log that nothing was actually
// deleted, as the current state is the intended result.
if (!file_exists($path)) {
- $logger->notice('The file %path was not deleted because it does not exist.', array('%path' => $path));
+ $logger->notice('The file %path was not deleted because it does not exist.', ['%path' => $path]);
return TRUE;
}
// We cannot handle anything other than files and directories. Log an error
// for everything else (sockets, symbolic links, etc).
- $logger->error('The file %path is not of a recognized type so it was not deleted.', array('%path' => $path));
+ $logger->error('The file %path is not of a recognized type so it was not deleted.', ['%path' => $path]);
return FALSE;
}
@@ -999,14 +999,14 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
* An associative array (keyed on the chosen key) of objects with 'uri',
* 'filename', and 'name' properties corresponding to the matched files.
*/
-function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
+function file_scan_directory($dir, $mask, $options = [], $depth = 0) {
// Merge in defaults.
- $options += array(
+ $options += [
'callback' => 0,
'recurse' => TRUE,
'key' => 'uri',
'min_depth' => 0,
- );
+ ];
// Normalize $dir only once.
if ($depth == 0) {
$dir = file_stream_wrapper_uri_normalize($dir);
@@ -1025,8 +1025,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
$default_nomask = '/^' . implode('|', $ignore_directories) . '$/';
}
- $options['key'] = in_array($options['key'], array('uri', 'filename', 'name')) ? $options['key'] : 'uri';
- $files = array();
+ $options['key'] = in_array($options['key'], ['uri', 'filename', 'name']) ? $options['key'] : 'uri';
+ $files = [];
// Avoid warnings when opendir does not have the permissions to open a
// directory.
if (is_dir($dir)) {
@@ -1067,7 +1067,7 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
closedir($handle);
}
else {
- \Drupal::logger('file')->error('@dir can not be opened', array('@dir' => $dir));
+ \Drupal::logger('file')->error('@dir can not be opened', ['@dir' => $dir]);
}
}
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 2e2d2be98f3..05f2a9e1fce 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -29,8 +29,8 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
function template_preprocess_select(&$variables) {
$element = $variables['element'];
- Element::setAttributes($element, array('id', 'name', 'size'));
- RenderElement::setAttributes($element, array('form-select'));
+ Element::setAttributes($element, ['id', 'name', 'size']);
+ RenderElement::setAttributes($element, ['form-select']);
$variables['attributes'] = $element['#attributes'];
$variables['options'] = form_select_options($element);
@@ -161,7 +161,7 @@ function form_select_options($element, $choices = NULL) {
* empty if no elements were found. FALSE if optgroups were found.
*/
function form_get_options($element, $key) {
- $keys = array();
+ $keys = [];
foreach ($element['#options'] as $index => $choice) {
if (is_array($choice)) {
return FALSE;
@@ -191,9 +191,9 @@ function form_get_options($element, $key) {
*/
function template_preprocess_fieldset(&$variables) {
$element = $variables['element'];
- Element::setAttributes($element, array('id'));
+ Element::setAttributes($element, ['id']);
RenderElement::setAttributes($element);
- $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : array();
+ $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : [];
$variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL;
$variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL;
$variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL;
@@ -273,7 +273,7 @@ function template_preprocess_details(&$variables) {
*/
function template_preprocess_radios(&$variables) {
$element = $variables['element'];
- $variables['attributes'] = array();
+ $variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@@ -295,7 +295,7 @@ function template_preprocess_radios(&$variables) {
*/
function template_preprocess_checkboxes(&$variables) {
$element = $variables['element'];
- $variables['attributes'] = array();
+ $variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@@ -354,7 +354,7 @@ function template_preprocess_form(&$variables) {
if (isset($element['#action'])) {
$element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']);
}
- Element::setAttributes($element, array('method', 'id'));
+ Element::setAttributes($element, ['method', 'id']);
if (empty($element['#attributes']['accept-charset'])) {
$element['#attributes']['accept-charset'] = "UTF-8";
}
@@ -375,8 +375,8 @@ function template_preprocess_form(&$variables) {
*/
function template_preprocess_textarea(&$variables) {
$element = $variables['element'];
- Element::setAttributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
- RenderElement::setAttributes($element, array('form-textarea'));
+ Element::setAttributes($element, ['id', 'name', 'rows', 'cols', 'placeholder']);
+ RenderElement::setAttributes($element, ['form-textarea']);
$variables['wrapper_attributes'] = new Attribute();
$variables['attributes'] = new Attribute($element['#attributes']);
$variables['value'] = $element['#value'];
@@ -429,11 +429,11 @@ function template_preprocess_form_element(&$variables) {
// This function is invoked as theme wrapper, but the rendered form element
// may not necessarily have been processed by
// \Drupal::formBuilder()->doBuildForm().
- $element += array(
+ $element += [
'#title_display' => 'before',
- '#wrapper_attributes' => array(),
- '#label_attributes' => array(),
- );
+ '#wrapper_attributes' => [],
+ '#label_attributes' => [],
+ ];
$variables['attributes'] = $element['#wrapper_attributes'];
// Add element #id for #type 'item'.
@@ -478,8 +478,8 @@ function template_preprocess_form_element(&$variables) {
// Add label_display and label variables to template.
$variables['label_display'] = $element['#title_display'];
- $variables['label'] = array('#theme' => 'form_element_label');
- $variables['label'] += array_intersect_key($element, array_flip(array('#id', '#required', '#title', '#title_display')));
+ $variables['label'] = ['#theme' => 'form_element_label'];
+ $variables['label'] += array_intersect_key($element, array_flip(['#id', '#required', '#title', '#title_display']));
$variables['label']['#attributes'] = $element['#label_attributes'];
$variables['children'] = $element['#children'];
@@ -717,26 +717,26 @@ function batch_set($batch_definition) {
// Initialize the batch if needed.
if (empty($batch)) {
- $batch = array(
- 'sets' => array(),
+ $batch = [
+ 'sets' => [],
'has_form_submits' => FALSE,
- );
+ ];
}
// Base and default properties for the batch set.
- $init = array(
- 'sandbox' => array(),
- 'results' => array(),
+ $init = [
+ 'sandbox' => [],
+ 'results' => [],
'success' => FALSE,
'start' => 0,
'elapsed' => 0,
- );
- $defaults = array(
+ ];
+ $defaults = [
'title' => t('Processing'),
'init_message' => t('Initializing.'),
'progress_message' => t('Completed @current of @total.'),
'error_message' => t('An error has occurred.'),
- );
+ ];
$batch_set = $init + $batch_definition + $defaults;
// Tweak init_message to avoid the bottom of the page flickering down after
@@ -760,7 +760,7 @@ function batch_set($batch_definition) {
$index = $batch['current_set'] + 1;
$slice1 = array_slice($batch['sets'], 0, $index);
$slice2 = array_slice($batch['sets'], $index);
- $batch['sets'] = array_merge($slice1, array($batch_set), $slice2);
+ $batch['sets'] = array_merge($slice1, [$batch_set], $slice2);
_batch_populate_queue($batch, $index);
}
}
@@ -800,7 +800,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
if (isset($batch)) {
// Add process information
- $process_info = array(
+ $process_info = [
'current_set' => 0,
'progressive' => TRUE,
'url' => isset($url) ? $url : Url::fromRoute('system.batch_page.html'),
@@ -808,7 +808,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
'batch_redirect' => $redirect,
'theme' => \Drupal::theme()->getActiveTheme()->getName(),
'redirect_callback' => $redirect_callback,
- );
+ ];
$batch += $process_info;
// The batch is now completely built. Allow other modules to make changes
@@ -839,7 +839,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
$query_options['op'] = 'finished';
$error_url->setOption('query', $query_options);
- $batch['error_message'] = t('Please continue to <a href=":error_url">the error page</a>', array(':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()));
+ $batch['error_message'] = t('Please continue to <a href=":error_url">the error page</a>', [':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()]);
// Clear the way for the redirection to the batch processing page, by
// saving and unsetting the 'destination', if there is any.
@@ -886,7 +886,7 @@ function &batch_get() {
// that are part of the Batch API and need to reset the batch information may
// call batch_get() and manipulate the result by reference. Functions that are
// not part of the Batch API can also do this, but shouldn't.
- static $batch = array();
+ static $batch = [];
return $batch;
}
@@ -907,12 +907,12 @@ function _batch_populate_queue(&$batch, $set_id) {
$batch_set = &$batch['sets'][$set_id];
if (isset($batch_set['operations'])) {
- $batch_set += array(
- 'queue' => array(
+ $batch_set += [
+ 'queue' => [
'name' => 'drupal_batch:' . $batch['id'] . ':' . $set_id,
'class' => $batch['progressive'] ? 'Drupal\Core\Queue\Batch' : 'Drupal\Core\Queue\BatchMemory',
- ),
- );
+ ],
+ ];
$queue = _batch_queue($batch_set);
$queue->createQueue();
@@ -937,7 +937,7 @@ function _batch_queue($batch_set) {
static $queues;
if (!isset($queues)) {
- $queues = array();
+ $queues = [];
}
if (isset($batch_set['queue'])) {
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index ca66c11398e..cfc0497bbcc 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -92,11 +92,11 @@ const INSTALL_TASK_RUN_IF_NOT_COMPLETED = 3;
*
* @see install_state_defaults()
*/
-function install_drupal($class_loader, $settings = array()) {
+function install_drupal($class_loader, $settings = []) {
// Support the old way of calling this function with just a settings array.
// @todo Remove this when Drush is updated in the Drupal testing
// infrastructure in https://www.drupal.org/node/2389243
- if (is_array($class_loader) && $settings === array()) {
+ if (is_array($class_loader) && $settings === []) {
$settings = $class_loader;
$class_loader = require __DIR__ . '/../../autoload.php';
}
@@ -106,7 +106,7 @@ function install_drupal($class_loader, $settings = array()) {
// as well as a boolean indicating whether or not this is an interactive
// installation.
$interactive = empty($settings);
- $install_state = $settings + array('interactive' => $interactive) + install_state_defaults();
+ $install_state = $settings + ['interactive' => $interactive] + install_state_defaults();
try {
// Begin the page request. This adds information about the current state of
@@ -121,10 +121,10 @@ function install_drupal($class_loader, $settings = array()) {
if (!$install_state['interactive']) {
throw $e;
}
- $output = array(
+ $output = [
'#title' => $e->getTitle(),
'#markup' => $e->getMessage(),
- );
+ ];
}
// After execution, all tasks might be complete, in which case
@@ -182,7 +182,7 @@ function install_drupal($class_loader, $settings = array()) {
* @see \Drupal\Core\Form\FormBuilderInterface::submitForm()
*/
function install_state_defaults() {
- $defaults = array(
+ $defaults = [
// The current task being processed.
'active_task' => NULL,
// The last task that was completed during the previous installation
@@ -207,7 +207,7 @@ function install_state_defaults() {
// installation task that the form submission is for, and the values are
// used as the $form_state->getValues() array that is passed on to the form
// submission via \Drupal::formBuilder()->submitForm().
- 'forms' => array(),
+ 'forms' => [],
// This becomes TRUE only at the end of the installation process, after
// all available tasks have been completed and Drupal is fully installed.
// It is used by the installer to store correct information in the database
@@ -224,16 +224,16 @@ function install_state_defaults() {
// and 'langcode' (the code of the chosen installation language), since
// these settings need to persist from page request to page request before
// the database is available for storage.
- 'parameters' => array(),
+ 'parameters' => [],
// Whether or not the parameters have changed during the current page
// request. For interactive installations, this will trigger a page
// redirect.
'parameters_changed' => FALSE,
// An array of information about the chosen installation profile. This will
// be filled in based on the profile's .info.yml file.
- 'profile_info' => array(),
+ 'profile_info' => [],
// An array of available installation profiles.
- 'profiles' => array(),
+ 'profiles' => [],
// The name of the theme to use during installation.
'theme' => 'seven',
// The server URL where the interface translation files can be downloaded.
@@ -261,11 +261,11 @@ function install_state_defaults() {
'task_not_complete' => FALSE,
// A list of installation tasks which have already been performed during
// the current page request.
- 'tasks_performed' => array(),
+ 'tasks_performed' => [],
// An array of translation files URIs available for the installation. Keyed
// by the translation language code.
- 'translations' => array(),
- );
+ 'translations' => [],
+ ];
return $defaults;
}
@@ -353,7 +353,7 @@ function install_begin_request($class_loader, &$install_state) {
// Register the stream wrapper manager.
$container
->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager')
- ->addMethodCall('setContainer', array(new Reference('service_container')));
+ ->addMethodCall('setContainer', [new Reference('service_container')]);
$container
->register('file_system', 'Drupal\Core\File\FileSystem')
->addArgument(new Reference('stream_wrapper_manager'))
@@ -429,7 +429,7 @@ function install_begin_request($class_loader, &$install_state) {
// Add list of all available profiles to the installation state.
$listing = new ExtensionDiscovery($container->get('app.root'));
- $listing->setProfileDirectories(array());
+ $listing->setProfileDirectories([]);
$install_state['profiles'] += $listing->scan('profile');
// Prime drupal_get_filename()'s static cache.
@@ -453,7 +453,7 @@ function install_begin_request($class_loader, &$install_state) {
// Set the default language to the selected language, if any.
if (isset($install_state['parameters']['langcode'])) {
- $default_language = new Language(array('id' => $install_state['parameters']['langcode']));
+ $default_language = new Language(['id' => $install_state['parameters']['langcode']]);
$container->get('language.default')->set($default_language);
\Drupal::translation()->setDefaultLangcode($install_state['parameters']['langcode']);
}
@@ -596,7 +596,7 @@ function install_run_task($task, &$install_state) {
}
// Create a one item list of batches if only one batch was provided.
if (isset($batches['operations'])) {
- $batches = array($batches);
+ $batches = [$batches];
}
foreach ($batches as $batch) {
batch_set($batch);
@@ -726,26 +726,26 @@ function install_tasks($install_state) {
// Start with the core installation tasks that run before handing control
// to the installation profile.
- $tasks = array(
- 'install_select_language' => array(
+ $tasks = [
+ 'install_select_language' => [
'display_name' => t('Choose language'),
'run' => INSTALL_TASK_RUN_IF_REACHED,
- ),
- 'install_download_translation' => array(
+ ],
+ 'install_download_translation' => [
'run' => $needs_download ? INSTALL_TASK_RUN_IF_REACHED : INSTALL_TASK_SKIP,
- ),
- 'install_select_profile' => array(
+ ],
+ 'install_select_profile' => [
'display_name' => t('Choose profile'),
'display' => empty($install_state['profile_info']['distribution']['name']) && count($install_state['profiles']) != 1,
'run' => INSTALL_TASK_RUN_IF_REACHED,
- ),
- 'install_load_profile' => array(
+ ],
+ 'install_load_profile' => [
'run' => INSTALL_TASK_RUN_IF_REACHED,
- ),
- 'install_verify_requirements' => array(
+ ],
+ 'install_verify_requirements' => [
'display_name' => t('Verify requirements'),
- ),
- 'install_settings_form' => array(
+ ],
+ 'install_settings_form' => [
'display_name' => t('Set up database'),
'type' => 'form',
// Even though the form only allows the user to enter database settings,
@@ -753,39 +753,39 @@ function install_tasks($install_state) {
// since the form submit handler is where settings.php is rewritten.
'run' => $install_state['settings_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
'function' => 'Drupal\Core\Installer\Form\SiteSettingsForm',
- ),
- 'install_write_profile' => array(
- ),
- 'install_verify_database_ready' => array(
+ ],
+ 'install_write_profile' => [
+ ],
+ 'install_verify_database_ready' => [
'run' => $install_state['database_ready'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
- ),
- 'install_base_system' => array(
+ ],
+ 'install_base_system' => [
'run' => $install_state['base_system_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
- ),
+ ],
// All tasks below are executed in a regular, full Drupal environment.
- 'install_bootstrap_full' => array(
+ 'install_bootstrap_full' => [
'run' => INSTALL_TASK_RUN_IF_REACHED,
- ),
- 'install_profile_modules' => array(
+ ],
+ 'install_profile_modules' => [
'display_name' => t('Install site'),
'type' => 'batch',
- ),
- 'install_profile_themes' => array(
- ),
- 'install_install_profile' => array(
- ),
- 'install_import_translations' => array(
+ ],
+ 'install_profile_themes' => [
+ ],
+ 'install_install_profile' => [
+ ],
+ 'install_import_translations' => [
'display_name' => t('Set up translations'),
'display' => $needs_translations,
'type' => 'batch',
'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
- ),
- 'install_configure_form' => array(
+ ],
+ 'install_configure_form' => [
'display_name' => t('Configure site'),
'type' => 'form',
'function' => 'Drupal\Core\Installer\Form\SiteConfigureForm',
- ),
- );
+ ],
+ ];
// Now add any tasks defined by the installation profile.
if (!empty($install_state['parameters']['profile'])) {
@@ -806,16 +806,16 @@ function install_tasks($install_state) {
}
// Finish by adding the remaining core tasks.
- $tasks += array(
- 'install_finish_translations' => array(
+ $tasks += [
+ 'install_finish_translations' => [
'display_name' => t('Finish translations'),
'display' => $needs_translations,
'type' => 'batch',
'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
- ),
- 'install_finished' => array(
- ),
- );
+ ],
+ 'install_finished' => [
+ ],
+ ];
// Allow the installation profile to modify the full list of tasks.
if (!empty($install_state['parameters']['profile'])) {
@@ -830,13 +830,13 @@ function install_tasks($install_state) {
// Fill in default parameters for each task before returning the list.
foreach ($tasks as $task_name => &$task) {
- $task += array(
+ $task += [
'display_name' => NULL,
'display' => !empty($task['display_name']),
'type' => 'normal',
'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
'function' => $task_name,
- );
+ ];
}
return $tasks;
}
@@ -857,7 +857,7 @@ function install_tasks($install_state) {
* @see maintenance-task-list.html.twig
*/
function install_tasks_to_display($install_state) {
- $displayed_tasks = array();
+ $displayed_tasks = [];
foreach (install_tasks($install_state) as $name => $task) {
if ($task['display']) {
$displayed_tasks[$name] = $task['display_name'];
@@ -971,39 +971,39 @@ function install_display_output($output, $install_state) {
// resulting in /subfolder/install.php being found through search engines.
// When settings.php is writeable this can be used via an external database
// leading a malicious user to gain php access to the server.
- $noindex_meta_tag = array(
+ $noindex_meta_tag = [
'#tag' => 'meta',
- '#attributes' => array(
+ '#attributes' => [
'name' => 'robots',
'content' => 'noindex, nofollow',
- ),
- );
+ ],
+ ];
$output['#attached']['html_head'][] = [$noindex_meta_tag, 'install_meta_robots'];
// Only show the task list if there is an active task; otherwise, the page
// request has ended before tasks have even been started, so there is nothing
// meaningful to show.
- $regions = array();
+ $regions = [];
if (isset($install_state['active_task'])) {
// Let the theming function know when every step of the installation has
// been completed.
$active_task = $install_state['installation_finished'] ? NULL : $install_state['active_task'];
- $task_list = array(
+ $task_list = [
'#theme' => 'maintenance_task_list',
'#items' => install_tasks_to_display($install_state),
'#active' => $active_task,
- );
+ ];
$regions['sidebar_first'] = $task_list;
}
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
$response = $bare_html_page_renderer->renderBarePage($output, $output['#title'], 'install_page', $regions);
- $default_headers = array(
+ $default_headers = [
'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
'Cache-Control' => 'no-cache, must-revalidate',
'ETag' => '"' . REQUEST_TIME . '"',
- );
+ ];
$response->headers->add($default_headers);
$response->send();
exit;
@@ -1069,13 +1069,13 @@ function install_base_system(&$install_state) {
// Enable the user module so that sessions can be recorded during the
// upcoming bootstrap step.
- \Drupal::service('module_installer')->install(array('user'), FALSE);
+ \Drupal::service('module_installer')->install(['user'], FALSE);
// Save the list of other modules to install for the upcoming tasks.
// State can be set to the database now that system.module is installed.
$modules = $install_state['profile_info']['dependencies'];
- \Drupal::state()->set('install_profile_modules', array_diff($modules, array('system')));
+ \Drupal::state()->set('install_profile_modules', array_diff($modules, ['system']));
$install_state['base_system_verified'] = TRUE;
}
@@ -1142,13 +1142,13 @@ function install_verify_database_ready() {
* Checks a database connection and returns any errors.
*/
function install_database_errors($database, $settings_file) {
- $errors = array();
+ $errors = [];
// Check database type.
$database_types = drupal_get_database_types();
$driver = $database['driver'];
if (!isset($database_types[$driver])) {
- $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver));
+ $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", ['%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver]);
}
else {
// Run driver specific validation
@@ -1260,10 +1260,10 @@ function _install_select_profile(&$install_state) {
* @see file_scan_directory()
*/
function install_find_translations() {
- $translations = array();
+ $translations = [];
$files = \Drupal::service('string_translator.file_translation')->findTranslationFiles();
// English does not need a translation file.
- array_unshift($files, (object) array('name' => 'en'));
+ array_unshift($files, (object) ['name' => 'en']);
foreach ($files as $uri => $file) {
// Strip off the file name component before the language code.
$langcode = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $file->name);
@@ -1384,7 +1384,7 @@ function install_retrieve_file($uri, $destination) {
}
try {
- $response = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'text/plain')));
+ $response = \Drupal::httpClient()->get($uri, ['headers' => ['Accept' => 'text/plain']]);
$data = (string) $response->getBody();
if (empty($data)) {
return FALSE;
@@ -1491,14 +1491,14 @@ function install_profile_modules(&$install_state) {
// as those will not be handled by the module installer.
install_core_entity_type_definitions();
- $modules = \Drupal::state()->get('install_profile_modules') ?: array();
+ $modules = \Drupal::state()->get('install_profile_modules') ?: [];
$files = system_rebuild_module_data();
\Drupal::state()->delete('install_profile_modules');
// Always install required modules first. Respect the dependencies between
// the modules.
- $required = array();
- $non_required = array();
+ $required = [];
+ $non_required = [];
// Add modules that other modules depend on.
foreach ($modules as $module) {
@@ -1518,15 +1518,15 @@ function install_profile_modules(&$install_state) {
arsort($required);
arsort($non_required);
- $operations = array();
+ $operations = [];
foreach ($required + $non_required as $module => $weight) {
- $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
+ $operations[] = ['_install_module_batch', [$module, $files[$module]->info['name']]];
}
- $batch = array(
+ $batch = [
'operations' => $operations,
- 'title' => t('Installing @drupal', array('@drupal' => drupal_install_profile_distribution_name())),
+ 'title' => t('Installing @drupal', ['@drupal' => drupal_install_profile_distribution_name()]),
'error_message' => t('The installation has encountered an error.'),
- );
+ ];
return $batch;
}
@@ -1569,7 +1569,7 @@ function install_profile_themes(&$install_state) {
* An array of information about the current installation state.
*/
function install_install_profile(&$install_state) {
- \Drupal::service('module_installer')->install(array(drupal_get_profile()), FALSE);
+ \Drupal::service('module_installer')->install([drupal_get_profile()], FALSE);
// Install all available optional config. During installation the module order
// is determined by dependencies. If there are no dependencies between modules
// then the order in which they are installed is dependent on random factors
@@ -1612,21 +1612,21 @@ function install_download_additional_translations_operations(&$install_state) {
->save();
\Drupal::service('language.default')->set($language);
if (empty($install_state['profile_info']['keep_english'])) {
- entity_delete_multiple('configurable_language', array('en'));
+ entity_delete_multiple('configurable_language', ['en']);
}
}
// If there is more than one language or the single one is not English, we
// should download/import translations.
$languages = \Drupal::languageManager()->getLanguages();
- $operations = array();
+ $operations = [];
foreach ($languages as $langcode => $language) {
// The installer language was already downloaded. Check downloads for the
// other languages if any. Ignore any download errors here, since we
// are in the middle of an install process and there is no way back. We
// will not import what we cannot download.
if ($langcode != 'en' && $langcode != $install_state['parameters']['langcode']) {
- $operations[] = array('install_check_translations', array($langcode, $install_state['server_pattern']));
+ $operations[] = ['install_check_translations', [$langcode, $install_state['server_pattern']]];
}
}
return $operations;
@@ -1649,26 +1649,26 @@ function install_import_translations(&$install_state) {
$operations = install_download_additional_translations_operations($install_state);
$languages = \Drupal::languageManager()->getLanguages();
if (count($languages) > 1 || !isset($languages['en'])) {
- $operations[] = array('_install_prepare_import', array(array_keys($languages), $install_state['server_pattern']));
+ $operations[] = ['_install_prepare_import', [array_keys($languages), $install_state['server_pattern']]];
// Set up a batch to import translations for drupal core. Translation import
// for contrib modules happens in install_import_translations_remaining.
foreach ($languages as $language) {
if (locale_translation_use_remote_source()) {
- $operations[] = array('locale_translation_batch_fetch_download', array('drupal', $language->getId()));
+ $operations[] = ['locale_translation_batch_fetch_download', ['drupal', $language->getId()]];
}
- $operations[] = array('locale_translation_batch_fetch_import', array('drupal', $language->getId(), array()));
+ $operations[] = ['locale_translation_batch_fetch_import', ['drupal', $language->getId(), []]];
}
module_load_include('fetch.inc', 'locale');
- $batch = array(
+ $batch = [
'operations' => $operations,
'title' => t('Updating translations.'),
'progress_message' => '',
'error_message' => t('Error importing translation files'),
'finished' => 'locale_translation_batch_fetch_finished',
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
- );
+ ];
return $batch;
}
}
@@ -1683,11 +1683,11 @@ function install_import_translations(&$install_state) {
*/
function _install_prepare_import($langcodes, $server_pattern) {
\Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
- $matches = array();
+ $matches = [];
foreach ($langcodes as $langcode) {
// Get the translation files located in the translations directory.
- $files = locale_translate_get_interface_translation_files(array('drupal'), array($langcode));
+ $files = locale_translate_get_interface_translation_files(['drupal'], [$langcode]);
// Pick the first file which matches the language, if any.
$file = reset($files);
if (is_object($file)) {
@@ -1700,17 +1700,17 @@ function _install_prepare_import($langcodes, $server_pattern) {
// we check if at least the major version number is available.
if ($info['major']) {
$core = $info['major'] . '.x';
- $data = array(
+ $data = [
'name' => 'drupal',
'project_type' => 'module',
'core' => $core,
'version' => $version,
'server_pattern' => $server_pattern,
'status' => 1,
- );
+ ];
\Drupal::service('locale.project')->set($data['name'], $data);
module_load_include('compare.inc', 'locale');
- locale_translation_check_projects_local(array('drupal'), array($langcode));
+ locale_translation_check_projects_local(['drupal'], [$langcode]);
}
}
}
@@ -1739,16 +1739,16 @@ function install_finish_translations(&$install_state) {
// using a batch.
$projects = locale_translation_build_projects();
$languages = \Drupal::languageManager()->getLanguages();
- $batches = array();
+ $batches = [];
if (count($projects) > 1) {
$options = _locale_translation_default_update_options();
- if ($batch = locale_translation_batch_update_build(array(), array_keys($languages), $options)) {
+ if ($batch = locale_translation_batch_update_build([], array_keys($languages), $options)) {
$batches[] = $batch;
}
}
// Creates configuration translations.
- $batches[] = locale_config_batch_update_components(array(), array_keys($languages));
+ $batches[] = locale_config_batch_update_components([], array_keys($languages));
return $batches;
}
@@ -1785,9 +1785,9 @@ function install_finished(&$install_state) {
user_login_finalize($account);
}
- $success_message = t('Congratulations, you installed @drupal!', array(
+ $success_message = t('Congratulations, you installed @drupal!', [
'@drupal' => drupal_install_profile_distribution_name(),
- ));
+ ]);
drupal_set_message($success_message);
}
@@ -1797,9 +1797,9 @@ function install_finished(&$install_state) {
* Performs batch installation of modules.
*/
function _install_module_batch($module, $module_name, &$context) {
- \Drupal::service('module_installer')->install(array($module), FALSE);
+ \Drupal::service('module_installer')->install([$module], FALSE);
$context['results'][] = $module;
- $context['message'] = t('Installed %module module.', array('%module' => $module_name));
+ $context['message'] = t('Installed %module module.', ['%module' => $module_name]);
}
/**
@@ -1816,7 +1816,7 @@ function _install_module_batch($module, $module_name, &$context) {
* error with detailed information.
*/
function install_check_translations($langcode, $server_pattern) {
- $requirements = array();
+ $requirements = [];
$readable = FALSE;
$writable = FALSE;
@@ -1845,12 +1845,12 @@ function install_check_translations($langcode, $server_pattern) {
}
// Build URL for the translation file and the translation server.
- $variables = array(
+ $variables = [
'%project' => 'drupal',
'%version' => \Drupal::VERSION,
'%core' => \Drupal::CORE_COMPATIBILITY,
'%language' => $langcode,
- );
+ ];
$translation_url = strtr($server_pattern, $variables);
$elements = parse_url($translation_url);
@@ -1874,73 +1874,73 @@ function install_check_translations($langcode, $server_pattern) {
// If the translations directory does not exists, throw an error.
if (!$translations_directory_exists) {
- $requirements['translations directory exists'] = array(
+ $requirements['translations directory exists'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory does not exist.'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', array('%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt')),
- );
+ 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', ['%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt']),
+ ];
}
else {
- $requirements['translations directory exists'] = array(
+ $requirements['translations directory exists'] = [
'title' => t('Translations directory'),
- 'value' => t('The directory %translations_directory exists.', array('%translations_directory' => $translations_directory)),
- );
+ 'value' => t('The directory %translations_directory exists.', ['%translations_directory' => $translations_directory]),
+ ];
// If the translations directory is not readable, throw an error.
if (!$readable) {
- $requirements['translations directory readable'] = array(
+ $requirements['translations directory readable'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory is not readable.'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires read permissions to %translations_directory at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')),
- );
+ 'description' => t('The installer requires read permissions to %translations_directory at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']),
+ ];
}
// If translations directory is not writable, throw an error.
if (!$writable) {
- $requirements['translations directory writable'] = array(
+ $requirements['translations directory writable'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory is not writable.'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires write permissions to %translations_directory during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')),
- );
+ 'description' => t('The installer requires write permissions to %translations_directory during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']),
+ ];
}
else {
- $requirements['translations directory writable'] = array(
+ $requirements['translations directory writable'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory is writable.'),
- );
+ ];
}
}
// If the translations server can not be contacted, throw an error.
if (!$online) {
- $requirements['online'] = array(
+ $requirements['online'] = [
'title' => t('Internet'),
'value' => t('The translation server is offline.'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href=":server_url">@server_url</a>.', array(':server_url' => $server_url, '@server_url' => $server_url)),
- );
+ 'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href=":server_url">@server_url</a>.', [':server_url' => $server_url, '@server_url' => $server_url]),
+ ];
}
else {
- $requirements['online'] = array(
+ $requirements['online'] = [
'title' => t('Internet'),
'value' => t('The translation server is online.'),
- );
+ ];
// If translation file is not found at the translation server, throw an
// error.
if (!$translation_available) {
- $requirements['translation available'] = array(
+ $requirements['translation available'] = [
'title' => t('Translation'),
- 'value' => t('The %language translation is not available.', array('%language' => $language)),
+ 'value' => t('The %language translation is not available.', ['%language' => $language]),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The %language translation file is not available at the translation server. <a href=":url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])),
- );
+ 'description' => t('The %language translation file is not available at the translation server. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]),
+ ];
}
else {
- $requirements['translation available'] = array(
+ $requirements['translation available'] = [
'title' => t('Translation'),
- 'value' => t('The %language translation is available.', array('%language' => $language)),
- );
+ 'value' => t('The %language translation is available.', ['%language' => $language]),
+ ];
}
}
@@ -1948,12 +1948,12 @@ function install_check_translations($langcode, $server_pattern) {
$translation_downloaded = install_retrieve_file($translation_url, $translations_directory);
if (!$translation_downloaded) {
- $requirements['translation downloaded'] = array(
+ $requirements['translation downloaded'] = [
'title' => t('Translation'),
- 'value' => t('The %language translation could not be downloaded.', array('%language' => $language)),
+ 'value' => t('The %language translation could not be downloaded.', ['%language' => $language]),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The %language translation file could not be downloaded. <a href=":url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])),
- );
+ 'description' => t('The %language translation file could not be downloaded. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]),
+ ];
}
}
@@ -1975,14 +1975,14 @@ function install_check_requirements($install_state) {
// If Drupal is not set up already, we need to try to create the default
// settings and services files.
- $default_files = array();
- $default_files['settings.php'] = array(
+ $default_files = [];
+ $default_files['settings.php'] = [
'file' => 'settings.php',
'file_default' => 'default.settings.php',
'title_default' => t('Default settings file'),
'description_default' => t('The default settings file does not exist.'),
'title' => t('Settings file'),
- );
+ ];
foreach ($default_files as $default_file_info) {
$readable = FALSE;
@@ -2004,15 +2004,15 @@ function install_check_requirements($install_state) {
// If the default $default_file does not exist, or is not readable,
// report an error.
if (!drupal_verify_install_file($default_file, FILE_EXIST | FILE_READABLE)) {
- $requirements["default $file file exists"] = array(
+ $requirements["default $file file exists"] = [
'title' => $default_file_info['title_default'],
'value' => $default_file_info['description_default'],
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array(
+ 'description' => t('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%default-file' => $default_file
- )),
- );
+ ]),
+ ];
}
// Otherwise, if $file does not exist yet, we can try to copy
// $default_file to create it.
@@ -2063,68 +2063,68 @@ function install_check_requirements($install_state) {
// If the $file does not exist, throw an error.
if (!$exists) {
- $requirements["$file file exists"] = array(
+ $requirements["$file file exists"] = [
'title' => $default_file_info['title'],
- 'value' => t('The %file does not exist.', array('%file' => $default_file_info['title'])),
+ 'value' => t('The %file does not exist.', ['%file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', array(
+ 'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
'%default_file' => $default_file,
':install_txt' => base_path() . 'core/INSTALL.txt'
- )),
- );
+ ]),
+ ];
}
else {
- $requirements["$file file exists"] = array(
+ $requirements["$file file exists"] = [
'title' => $default_file_info['title'],
- 'value' => t('The %file exists.', array('%file' => $file)),
- );
+ 'value' => t('The %file exists.', ['%file' => $file]),
+ ];
// If the $file is not readable, throw an error.
if (!$readable) {
- $requirements["$file file readable"] = array(
+ $requirements["$file file readable"] = [
'title' => $default_file_info['title'],
- 'value' => t('The %file is not readable.', array('%file' => $default_file_info['title'])),
+ 'value' => t('The %file is not readable.', ['%file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('@drupal requires read permissions to %file at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array(
+ 'description' => t('@drupal requires read permissions to %file at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
':handbook_url' => 'https://www.drupal.org/server-permissions'
- )),
- );
+ ]),
+ ];
}
// If the $file is not writable, throw an error.
if (!$writable) {
- $requirements["$file file writeable"] = array(
+ $requirements["$file file writeable"] = [
'title' => $default_file_info['title'],
- 'value' => t('The %file is not writable.', array('%file' => $default_file_info['title'])),
+ 'value' => t('The %file is not writable.', ['%file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer requires write permissions to %file during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array(
+ 'description' => t('The @drupal installer requires write permissions to %file during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
':handbook_url' => 'https://www.drupal.org/server-permissions'
- )),
- );
+ ]),
+ ];
}
else {
- $requirements["$file file"] = array(
+ $requirements["$file file"] = [
'title' => $default_file_info['title'],
- 'value' => t('The @file is writable.', array('@file' => $default_file_info['title'])),
- );
+ 'value' => t('The @file is writable.', ['@file' => $default_file_info['title']]),
+ ];
}
if (!empty($settings_file_ownership_error)) {
- $requirements["$file file ownership"] = array(
+ $requirements["$file file ownership"] = [
'title' => $default_file_info['title'],
- 'value' => t('The @file is owned by the web server.', array('@file' => $default_file_info['title'])),
+ 'value' => t('The @file is owned by the web server.', ['@file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array(
+ 'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
'%default_file' => $default_file,
':install_txt' => base_path() . 'core/INSTALL.txt',
':handbook_url' => 'https://www.drupal.org/server-permissions'
- )),
- );
+ ]),
+ ];
}
}
}
@@ -2162,17 +2162,17 @@ function install_display_requirements($install_state, $requirements) {
$build['report']['#requirements'] = $requirements;
if ($severity == REQUIREMENT_WARNING) {
$build['#title'] = t('Requirements review');
- $build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', array(':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)));
+ $build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', [':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)]);
}
else {
$build['#title'] = t('Requirements problem');
- $build['#suffix'] = t('Check the messages and <a href=":url">try again</a>.', array(':url' => drupal_requirements_url($severity)));
+ $build['#suffix'] = t('Check the messages and <a href=":url">try again</a>.', [':url' => drupal_requirements_url($severity)]);
}
return $build;
}
else {
// Throw an exception showing any unmet requirements.
- $failures = array();
+ $failures = [];
foreach ($requirements as $requirement) {
// Skip warnings altogether for non-interactive installations; these
// proceed in a single request so there is no good opportunity (and no
@@ -2207,10 +2207,10 @@ function install_write_profile($install_state) {
$settings_path = \Drupal::service('site.path') . '/settings.php';
if (is_writable($settings_path)) {
// Remember the profile which was used.
- $settings['settings']['install_profile'] = (object) array(
+ $settings['settings']['install_profile'] = (object) [
'value' => $install_state['parameters']['profile'],
'required' => TRUE,
- );
+ ];
drupal_rewrite_settings($settings);
}
elseif (($settings_profile = Settings::get('install_profile')) && $settings_profile !== $install_state['parameters']['profile']) {
diff --git a/core/includes/install.inc b/core/includes/install.inc
index 6bb6c11a0d1..c5b93b58a65 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -96,7 +96,7 @@ function drupal_load_updates() {
function drupal_install_profile_distribution_name() {
// During installation, the profile information is stored in the global
// installation state (it might not be saved anywhere yet).
- $info = array();
+ $info = [];
if (drupal_installation_attempted()) {
global $install_state;
if (isset($install_state['profile_info'])) {
@@ -158,14 +158,14 @@ function drupal_detect_database_types() {
* An array of available database driver installer objects.
*/
function drupal_get_database_types() {
- $databases = array();
- $drivers = array();
+ $databases = [];
+ $drivers = [];
// The internal database driver name is any valid PHP identifier.
$mask = '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '$/';
- $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, array('recurse' => FALSE));
+ $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, ['recurse' => FALSE]);
if (is_dir(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database')) {
- $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, array('recurse' => FALSE));
+ $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, ['recurse' => FALSE]);
}
foreach ($files as $file) {
if (file_exists($file->uri . '/Install/Tasks.php')) {
@@ -183,7 +183,7 @@ function drupal_get_database_types() {
if (isset($databases['mysql'])) {
$mysql_database = $databases['mysql'];
unset($databases['mysql']);
- $databases = array('mysql' => $mysql_database) + $databases;
+ $databases = ['mysql' => $mysql_database] + $databases;
}
return $databases;
@@ -213,13 +213,13 @@ function drupal_get_database_types() {
* $config_directories['sync'] = 'config_hash/sync'
* @endcode
*/
-function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
+function drupal_rewrite_settings($settings = [], $settings_file = NULL) {
if (!isset($settings_file)) {
$settings_file = \Drupal::service('site.path') . '/settings.php';
}
// Build list of setting names and insert the values into the global namespace.
- $variable_names = array();
- $settings_settings = array();
+ $variable_names = [];
+ $settings_settings = [];
foreach ($settings as $setting => $data) {
if ($setting != 'settings') {
_drupal_rewrite_settings_global($GLOBALS[$setting], $data);
@@ -248,7 +248,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
$value = $token;
}
// Do not operate on whitespace.
- if (!in_array($type, array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) {
+ if (!in_array($type, [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
switch ($state) {
case 'default':
if ($type === T_VARIABLE && isset($variable_names[$value])) {
@@ -335,7 +335,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
// Write the new settings file.
if (file_put_contents($settings_file, $buffer) === FALSE) {
- throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
+ throw new Exception(t('Failed to modify %settings. Verify the file permissions.', ['%settings' => $settings_file]));
}
else {
// In case any $settings variables were written, import them into the
@@ -352,7 +352,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
}
}
else {
- throw new Exception(t('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file)));
+ throw new Exception(t('Failed to open %settings. Verify the file permissions.', ['%settings' => $settings_file]));
}
}
@@ -375,7 +375,7 @@ function _drupal_rewrite_settings_is_simple($type, $value) {
$is_integer = $type == T_LNUMBER;
$is_float = $type == T_DNUMBER;
$is_string = $type == T_CONSTANT_ENCAPSED_STRING;
- $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), array('TRUE', 'FALSE', 'NULL'));
+ $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), ['TRUE', 'FALSE', 'NULL']);
return $is_integer || $is_float || $is_string || $is_boolean_or_null;
}
@@ -504,10 +504,10 @@ function drupal_install_config_directories() {
// Bail out using a similar error message as in system_requirements().
if (!file_prepare_directory($config_directories[CONFIG_SYNC_DIRECTORY], FILE_CREATE_DIRECTORY)
&& !file_exists($config_directories[CONFIG_SYNC_DIRECTORY])) {
- throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', array(
+ throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', [
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
':handbook_url' => 'https://www.drupal.org/server-permissions',
- )));
+ ]));
}
elseif (is_writable($config_directories[CONFIG_SYNC_DIRECTORY])) {
// Put a README.txt into the sync config directory. This is required so that
@@ -560,7 +560,7 @@ function drupal_verify_profile($install_state) {
// Get the list of available modules for the selected installation profile.
$listing = new ExtensionDiscovery(\Drupal::root());
- $present_modules = array();
+ $present_modules = [];
foreach ($listing->scan('module') as $present_module) {
$present_modules[] = $present_module->getName();
}
@@ -572,7 +572,7 @@ function drupal_verify_profile($install_state) {
// Verify that all of the profile's required modules are present.
$missing_modules = array_diff($info['dependencies'], $present_modules);
- $requirements = array();
+ $requirements = [];
if ($missing_modules) {
$build = [
@@ -581,16 +581,16 @@ function drupal_verify_profile($install_state) {
];
foreach ($missing_modules as $module) {
- $build['#items'][] = array('#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>');
+ $build['#items'][] = ['#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>'];
}
$modules_list = \Drupal::service('renderer')->renderPlain($build);
- $requirements['required_modules'] = array(
+ $requirements['required_modules'] = [
'title' => t('Required modules'),
'value' => t('Required modules not found.'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', array('@modules' => $modules_list)),
- );
+ 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', ['@modules' => $modules_list]),
+ ];
}
return $requirements;
}
@@ -628,7 +628,7 @@ function drupal_install_system($install_state) {
->save();
// Install System module and rebuild the newly available routes.
- $kernel->getContainer()->get('module_installer')->install(array('system'), FALSE);
+ $kernel->getContainer()->get('module_installer')->install(['system'], FALSE);
\Drupal::service('router.builder')->rebuild();
// Ensure default language is saved.
@@ -669,7 +669,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
// Verify file permissions.
if (isset($mask)) {
- $masks = array(FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+ $masks = [FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
foreach ($masks as $current_mask) {
if ($mask & $current_mask) {
switch ($current_mask) {
@@ -735,7 +735,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
*/
function drupal_install_mkdir($file, $mask, $message = TRUE) {
$mod = 0;
- $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+ $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
foreach ($masks as $m) {
if ($mask & $m) {
switch ($m) {
@@ -789,7 +789,7 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) {
}
$mod = fileperms($file) & 0777;
- $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+ $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
// FILE_READABLE, FILE_WRITABLE, and FILE_EXECUTABLE permission strings
// can theoretically be 0400, 0200, and 0100 respectively, but to be safe
@@ -851,10 +851,10 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) {
*/
function install_goto($path) {
global $base_url;
- $headers = array(
+ $headers = [
// Not a permanent redirect.
'Cache-Control' => 'no-cache',
- );
+ ];
$response = new RedirectResponse($base_url . '/' . $path, 302, $headers);
$response->send();
}
@@ -886,7 +886,7 @@ function install_goto($path) {
* @see drupal_requirements_url()
* @see Drupal\Component\Utility\UrlHelper::filterBadProtocol()
*/
-function drupal_current_script_url($query = array()) {
+function drupal_current_script_url($query = []) {
$uri = $_SERVER['SCRIPT_NAME'];
$query = array_merge(UrlHelper::filterQueryParameters(\Drupal::request()->query->all()), $query);
if (!empty($query)) {
@@ -916,7 +916,7 @@ function drupal_current_script_url($query = array()) {
* @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
*/
function drupal_requirements_url($severity) {
- $query = array();
+ $query = [];
// If there are no errors, only warnings, append 'continue=1' to the URL so
// the user can bypass this screen on the next page load.
if ($severity == REQUIREMENT_WARNING) {
@@ -937,7 +937,7 @@ function drupal_requirements_url($severity) {
function drupal_check_profile($profile) {
$info = install_profile_info($profile);
// Collect requirement testing results.
- $requirements = array();
+ $requirements = [];
// Performs an ExtensionDiscovery scan as the system module is unavailable and
// we don't yet know where all the modules are located.
// @todo Remove as part of https://www.drupal.org/node/2186491
@@ -1000,14 +1000,14 @@ function drupal_requirements_severity(&$requirements) {
function drupal_check_module($module) {
module_load_install($module);
// Check requirements
- $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', array('install'));
+ $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', ['install']);
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
// Print any error messages
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$message = $requirement['description'];
if (isset($requirement['value']) && $requirement['value']) {
- $message = t('@requirements_message (Currently using @item version @version)', array('@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']));
+ $message = t('@requirements_message (Currently using @item version @version)', ['@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']]);
}
drupal_set_message($message, 'error');
}
@@ -1066,27 +1066,27 @@ function drupal_check_module($module) {
* The info array.
*/
function install_profile_info($profile, $langcode = 'en') {
- $cache = &drupal_static(__FUNCTION__, array());
+ $cache = &drupal_static(__FUNCTION__, []);
if (!isset($cache[$profile][$langcode])) {
// Set defaults for module info.
- $defaults = array(
- 'dependencies' => array(),
- 'themes' => array('stark'),
+ $defaults = [
+ 'dependencies' => [],
+ 'themes' => ['stark'],
'description' => '',
'version' => NULL,
'hidden' => FALSE,
'php' => DRUPAL_MINIMUM_PHP,
- );
+ ];
$profile_file = drupal_get_path('profile', $profile) . "/$profile.info.yml";
$info = \Drupal::service('info_parser')->parse($profile_file);
$info += $defaults;
// drupal_required_modules() includes the current profile as a dependency.
// Remove that dependency, since a module cannot depend on itself.
- $required = array_diff(drupal_required_modules(), array($profile));
+ $required = array_diff(drupal_required_modules(), [$profile]);
- $locale = !empty($langcode) && $langcode != 'en' ? array('locale') : array();
+ $locale = !empty($langcode) && $langcode != 'en' ? ['locale'] : [];
$info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale));
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 9dbbc2037da..a75d008c872 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -28,27 +28,27 @@ use Drupal\Core\Render\Element;
*/
function template_preprocess_menu_local_task(&$variables) {
$link = $variables['element']['#link'];
- $link += array(
- 'localized_options' => array(),
- );
+ $link += [
+ 'localized_options' => [],
+ ];
$link_text = $link['title'];
if (!empty($variables['element']['#active'])) {
$variables['is_active'] = TRUE;
// Add text to indicate active tab for non-visual users.
- $active = SafeMarkup::format('<span class="visually-hidden">@label</span>', array('@label' => t('(active tab)')));
- $link_text = t('@local-task-title@active', array('@local-task-title' => $link_text, '@active' => $active));
+ $active = SafeMarkup::format('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
+ $link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]);
}
$link['localized_options']['set_active_class'] = TRUE;
- $variables['link'] = array(
+ $variables['link'] = [
'#type' => 'link',
'#title' => $link_text,
'#url' => $link['url'],
'#options' => $link['localized_options'],
- );
+ ];
}
/**
@@ -64,32 +64,32 @@ function template_preprocess_menu_local_task(&$variables) {
*/
function template_preprocess_menu_local_action(&$variables) {
$link = $variables['element']['#link'];
- $link += array(
- 'localized_options' => array(),
- );
+ $link += [
+ 'localized_options' => [],
+ ];
$link['localized_options']['attributes']['class'][] = 'button';
$link['localized_options']['attributes']['class'][] = 'button-action';
$link['localized_options']['set_active_class'] = TRUE;
- $variables['link'] = array(
+ $variables['link'] = [
'#type' => 'link',
'#title' => $link['title'],
'#options' => $link['localized_options'],
'#url' => $link['url'],
- );
+ ];
}
/**
* Returns an array containing the names of system-defined (default) menus.
*/
function menu_list_system_menus() {
- return array(
+ return [
'tools' => 'Tools',
'admin' => 'Administration',
'account' => 'User account menu',
'main' => 'Main navigation',
'footer' => 'Footer menu',
- );
+ ];
}
/**
@@ -144,12 +144,12 @@ function menu_secondary_local_tasks() {
* Returns a renderable element for the primary and secondary tabs.
*/
function menu_local_tabs() {
- $build = array(
+ $build = [
'#theme' => 'menu_local_tasks',
'#primary' => menu_primary_local_tasks(),
'#secondary' => menu_secondary_local_tasks(),
- );
- return !empty($build['#primary']) || !empty($build['#secondary']) ? $build : array();
+ ];
+ return !empty($build['#primary']) || !empty($build['#secondary']) ? $build : [];
}
/**
diff --git a/core/includes/module.inc b/core/includes/module.inc
index d80d74bb191..e3f446c6608 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -27,19 +27,19 @@ function system_list($type) {
$lists = $cached->data;
}
else {
- $lists = array(
- 'theme' => array(),
- 'filepaths' => array(),
- );
+ $lists = [
+ 'theme' => [],
+ 'filepaths' => [],
+ ];
// ThemeHandler maintains the 'system.theme.data' state record.
- $theme_data = \Drupal::state()->get('system.theme.data', array());
+ $theme_data = \Drupal::state()->get('system.theme.data', []);
foreach ($theme_data as $name => $theme) {
$lists['theme'][$name] = $theme;
- $lists['filepaths'][] = array(
+ $lists['filepaths'][] = [
'type' => 'theme',
'name' => $name,
'filepath' => $theme->getPathname(),
- );
+ ];
}
\Drupal::cache('bootstrap')->set('system_list', $lists);
}
@@ -146,7 +146,7 @@ function module_load_include($type, $module, $name = NULL) {
function drupal_required_modules() {
$listing = new ExtensionDiscovery(\Drupal::root());
$files = $listing->scan('module');
- $required = array();
+ $required = [];
// Unless called by the installer, an installation profile is required and
// must always be loaded. drupal_get_profile() also returns the installation
@@ -191,7 +191,7 @@ function module_set_weight($module, $weight) {
$current_module_filenames = $module_handler->getModuleList();
$current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
$current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module')));
- $module_filenames = array();
+ $module_filenames = [];
foreach ($current_modules as $name => $weight) {
$module_filenames[$name] = $current_module_filenames[$name];
}
@@ -222,7 +222,7 @@ function module_config_sort($data) {
// two modules and weights (spaces added for clarity):
// - Block with weight -5: 0 0000000000000000005 block
// - Node with weight 0: 1 0000000000000000000 node
- $sort = array();
+ $sort = [];
foreach ($data as $name => $weight) {
// Prefix negative weights with 0, positive weights with 1.
// +/- signs cannot be used, since + (ASCII 43) is before - (ASCII 45).
diff --git a/core/includes/pager.inc b/core/includes/pager.inc
index 6b6bbb736a7..62e8278ed26 100644
--- a/core/includes/pager.inc
+++ b/core/includes/pager.inc
@@ -147,7 +147,7 @@ function pager_default_initialize($total, $limit, $element = 0) {
function pager_get_query_parameters() {
$query = &drupal_static(__FUNCTION__);
if (!isset($query)) {
- $query = UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), array('page'));
+ $query = UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), ['page']);
}
return $query;
}
@@ -216,19 +216,19 @@ function template_preprocess_pager(&$variables) {
// Create the "first" and "previous" links if we are not on the first page.
if ($pager_page_array[$element] > 0) {
- $items['first'] = array();
- $options = array(
+ $items['first'] = [];
+ $options = [
'query' => pager_query_add_page($parameters, $element, 0),
- );
+ ];
$items['first']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[0])) {
$items['first']['text'] = $tags[0];
}
- $items['previous'] = array();
- $options = array(
+ $items['previous'] = [];
+ $options = [
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
- );
+ ];
$items['previous']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[1])) {
$items['previous']['text'] = $tags[1];
@@ -242,9 +242,9 @@ function template_preprocess_pager(&$variables) {
}
// Now generate the actual pager piece.
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
- $options = array(
+ $options = [
'query' => pager_query_add_page($parameters, $element, $i - 1),
- );
+ ];
$items['pages'][$i]['href'] = \Drupal::url($route_name, $route_parameters, $options);
if ($i == $pager_current) {
$variables['current'] = $i;
@@ -258,19 +258,19 @@ function template_preprocess_pager(&$variables) {
// Create the "next" and "last" links if we are not on the last page.
if ($pager_page_array[$element] < ($pager_max - 1)) {
- $items['next'] = array();
- $options = array(
+ $items['next'] = [];
+ $options = [
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
- );
+ ];
$items['next']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[3])) {
$items['next']['text'] = $tags[3];
}
- $items['last'] = array();
- $options = array(
+ $items['last'] = [];
+ $options = [
'query' => pager_query_add_page($parameters, $element, $pager_max - 1),
- );
+ ];
$items['last']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[4])) {
$items['last']['text'] = $tags[4];
diff --git a/core/includes/schema.inc b/core/includes/schema.inc
index aa3984b91ac..a2f9d23dc4f 100644
--- a/core/includes/schema.inc
+++ b/core/includes/schema.inc
@@ -28,9 +28,9 @@ const SCHEMA_UNINSTALLED = -1;
function drupal_get_schema_versions($module) {
$updates = &drupal_static(__FUNCTION__, NULL);
if (!isset($updates[$module])) {
- $updates = array();
+ $updates = [];
foreach (\Drupal::moduleHandler()->getModuleList() as $loaded_module => $filename) {
- $updates[$loaded_module] = array();
+ $updates[$loaded_module] = [];
}
// Prepare regular expression to match all possible defined hook_update_N().
@@ -74,15 +74,15 @@ function drupal_get_schema_versions($module) {
* module is not installed.
*/
function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
- $versions = &drupal_static(__FUNCTION__, array());
+ $versions = &drupal_static(__FUNCTION__, []);
if ($reset) {
- $versions = array();
+ $versions = [];
}
if (!$versions) {
if (!$versions = \Drupal::keyValue('system.schema')->getAll()) {
- $versions = array();
+ $versions = [];
}
}
@@ -162,12 +162,12 @@ function drupal_get_module_schema($module, $table = NULL) {
if (isset($schema[$table])) {
return $schema[$table];
}
- return array();
+ return [];
}
elseif (!empty($schema)) {
return $schema;
}
- return array();
+ return [];
}
/**
diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc
index 95642b38692..d8f16243138 100644
--- a/core/includes/tablesort.inc
+++ b/core/includes/tablesort.inc
@@ -41,7 +41,7 @@ function tablesort_init($header) {
function tablesort_header(&$cell_content, array &$cell_attributes, array $header, array $ts) {
// Special formatting for the currently sorted column header.
if (isset($cell_attributes['field'])) {
- $title = t('sort by @s', array('@s' => $cell_content));
+ $title = t('sort by @s', ['@s' => $cell_content]);
if ($cell_content == $ts['name']) {
// aria-sort is a WAI-ARIA property that indicates if items in a table
// or grid are sorted in ascending or descending order. See
@@ -49,10 +49,10 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
$cell_attributes['aria-sort'] = ($ts['sort'] == 'asc') ? 'ascending' : 'descending';
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
$cell_attributes['class'][] = 'is-active';
- $tablesort_indicator = array(
+ $tablesort_indicator = [
'#theme' => 'tablesort_indicator',
'#style' => $ts['sort'],
- );
+ ];
$image = drupal_render($tablesort_indicator);
}
else {
@@ -60,12 +60,12 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
$ts['sort'] = 'asc';
$image = '';
}
- $cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', array('@cell_content' => $cell_content, '@image' => $image)), new Url('<current>', [], [
- 'attributes' => array('title' => $title),
- 'query' => array_merge($ts['query'], array(
+ $cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [
+ 'attributes' => ['title' => $title],
+ 'query' => array_merge($ts['query'], [
'sort' => $ts['sort'],
'order' => $cell_content,
- )),
+ ]),
]));
unset($cell_attributes['field'], $cell_attributes['sort']);
@@ -80,7 +80,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
* page request except for those pertaining to table sorting.
*/
function tablesort_get_query_parameters() {
- return UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), array('sort', 'order'));
+ return UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), ['sort', 'order']);
}
/**
@@ -112,12 +112,12 @@ function tablesort_get_order($headers) {
if (!isset($default)) {
$default = reset($headers);
if (!is_array($default)) {
- $default = array('data' => $default);
+ $default = ['data' => $default];
}
}
- $default += array('data' => NULL, 'field' => NULL);
- return array('name' => $default['data'], 'sql' => $default['field']);
+ $default += ['data' => NULL, 'field' => NULL];
+ return ['name' => $default['data'], 'sql' => $default['field']];
}
/**
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 51d10a77e92..498c490beb2 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -102,13 +102,13 @@ function theme_get_registry($complete = TRUE) {
* @see \Drupal\Core\Extension\ThemeHandler::$defaultFeatures
*/
function _system_default_theme_features() {
- return array(
+ return [
'favicon',
'logo',
'node_user_picture',
'comment_user_picture',
'comment_user_verification',
- );
+ ];
}
/**
@@ -158,11 +158,11 @@ function drupal_find_theme_functions($cache, $prefixes) {
foreach ($matches as $match) {
$new_hook = substr($match, strlen($prefix) + 1);
$arg_name = isset($info['variables']) ? 'variables' : 'render element';
- $implementations[$new_hook] = array(
+ $implementations[$new_hook] = [
'function' => $match,
$arg_name => $info[$arg_name],
'base hook' => $hook,
- );
+ ];
}
}
}
@@ -170,9 +170,9 @@ function drupal_find_theme_functions($cache, $prefixes) {
// that in what is returned so that the registry knows that the theme has
// this implementation.
if (function_exists($prefix . '_' . $hook)) {
- $implementations[$hook] = array(
+ $implementations[$hook] = [
'function' => $prefix . '_' . $hook,
- );
+ ];
}
}
}
@@ -191,12 +191,12 @@ function drupal_find_theme_functions($cache, $prefixes) {
* The path to search.
*/
function drupal_find_theme_templates($cache, $extension, $path) {
- $implementations = array();
+ $implementations = [];
// Collect paths to all sub-themes grouped by base themes. These will be
// used for filtering. This allows base themes to have sub-themes in its
// folder hierarchy without affecting the base themes template discovery.
- $theme_paths = array();
+ $theme_paths = [];
foreach (\Drupal::service('theme_handler')->listInfo() as $theme_info) {
if (!empty($theme_info->base_theme)) {
$theme_paths[$theme_info->base_theme][$theme_info->getName()] = $theme_info->getPath();
@@ -210,12 +210,12 @@ function drupal_find_theme_templates($cache, $extension, $path) {
}
}
$theme = \Drupal::theme()->getActiveTheme()->getName();
- $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array();
+ $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : [];
// Escape the periods in the extension.
$regex = '/' . str_replace('.', '\.', $extension) . '$/';
// Get a listing of all template files in the path to search.
- $files = file_scan_directory($path, $regex, array('key' => 'filename'));
+ $files = file_scan_directory($path, $regex, ['key' => 'filename']);
// Find templates that implement registered theme hooks and include that in
// what is returned so that the registry knows that the theme has this
@@ -231,21 +231,21 @@ function drupal_find_theme_templates($cache, $extension, $path) {
// for the purposes of searching.
$hook = strtr($template, '-', '_');
if (isset($cache[$hook])) {
- $implementations[$hook] = array(
+ $implementations[$hook] = [
'template' => $template,
'path' => dirname($file->uri),
- );
+ ];
}
// Match templates based on the 'template' filename.
foreach ($cache as $hook => $info) {
if (isset($info['template'])) {
- $template_candidates = array($info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template']));
+ $template_candidates = [$info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template'])];
if (in_array($template, $template_candidates)) {
- $implementations[$hook] = array(
+ $implementations[$hook] = [
'template' => $template,
'path' => dirname($file->uri),
- );
+ ];
}
}
}
@@ -272,12 +272,12 @@ function drupal_find_theme_templates($cache, $extension, $path) {
// Put the underscores back in for the hook name and register this
// pattern.
$arg_name = isset($info['variables']) ? 'variables' : 'render element';
- $implementations[strtr($file, '-', '_')] = array(
+ $implementations[strtr($file, '-', '_')] = [
'template' => $file,
'path' => dirname($files[$match]->uri),
$arg_name => $info[$arg_name],
'base hook' => $hook,
- );
+ ];
}
}
}
@@ -305,7 +305,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
*/
function theme_get_setting($setting_name, $theme = NULL) {
/** @var \Drupal\Core\Theme\ThemeSettings[] $cache */
- $cache = &drupal_static(__FUNCTION__, array());
+ $cache = &drupal_static(__FUNCTION__, []);
// If no key is given, use the current theme if we can determine it.
if (!isset($theme)) {
@@ -488,7 +488,7 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config)
elseif (substr($key, 0, 7) == 'toggle_') {
$config->set('features.' . Unicode::substr($key, 7), $value);
}
- elseif (!in_array($key, array('theme', 'logo_upload'))) {
+ elseif (!in_array($key, ['theme', 'logo_upload'])) {
$config->set($key, $value);
}
}
@@ -545,7 +545,7 @@ function template_preprocess_time(&$variables) {
function template_preprocess_datetime_form(&$variables) {
$element = $variables['element'];
- $variables['attributes'] = array();
+ $variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@@ -664,34 +664,34 @@ function template_preprocess_links(&$variables) {
if (!empty($heading)) {
// Convert a string heading into an array, using a <h2> tag by default.
if (is_string($heading)) {
- $heading = array('text' => $heading);
+ $heading = ['text' => $heading];
}
// Merge in default array properties into $heading.
- $heading += array(
+ $heading += [
'level' => 'h2',
- 'attributes' => array(),
- );
+ 'attributes' => [],
+ ];
// Convert the attributes array into an Attribute object.
$heading['attributes'] = new Attribute($heading['attributes']);
}
- $variables['links'] = array();
+ $variables['links'] = [];
foreach ($links as $key => $link) {
- $item = array();
- $link += array(
+ $item = [];
+ $link += [
'ajax' => NULL,
'url' => NULL,
- );
+ ];
- $li_attributes = array();
+ $li_attributes = [];
$keys = ['title', 'url'];
- $link_element = array(
+ $link_element = [
'#type' => 'link',
'#title' => $link['title'],
'#options' => array_diff_key($link, array_combine($keys, $keys)),
'#url' => $link['url'],
'#ajax' => $link['ajax'],
- );
+ ];
// Handle links and ensure that the active class is added on the LIs, but
// only if the 'set_active_class' option is not empty.
@@ -779,7 +779,7 @@ function template_preprocess_image(&$variables) {
// Generate a srcset attribute conforming to the spec at
// http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-srcset
if (!empty($variables['srcset'])) {
- $srcset = array();
+ $srcset = [];
foreach ($variables['srcset'] as $src) {
// URI is mandatory.
$source = file_url_transform_relative(file_create_url($src['uri']));
@@ -794,7 +794,7 @@ function template_preprocess_image(&$variables) {
$variables['attributes']['srcset'] = implode(', ', $srcset);
}
- foreach (array('width', 'height', 'alt', 'title', 'sizes') as $key) {
+ foreach (['width', 'height', 'alt', 'title', 'sizes'] as $key) {
if (isset($variables[$key])) {
// If the property has already been defined in the attributes,
// do not override, including NULL.
@@ -908,11 +908,11 @@ function template_preprocess_table(&$variables) {
}
else {
$cols = $colgroup;
- $colgroup_attributes = array();
+ $colgroup_attributes = [];
}
- $colgroup = array();
+ $colgroup = [];
$colgroup['attributes'] = new Attribute($colgroup_attributes);
- $colgroup['cols'] = array();
+ $colgroup['cols'] = [];
// Build columns.
if (is_array($cols) && !empty($cols)) {
@@ -924,10 +924,10 @@ function template_preprocess_table(&$variables) {
}
// Build an associative array of responsive classes keyed by column.
- $responsive_classes = array();
+ $responsive_classes = [];
// Format the table header:
- $ts = array();
+ $ts = [];
$header_columns = 0;
if (!empty($variables['header'])) {
$ts = tablesort_init($variables['header']);
@@ -979,7 +979,7 @@ function template_preprocess_table(&$variables) {
// tablesort_header() removes the 'sort' and 'field' keys.
$cell_attributes = new Attribute($cell);
}
- $variables['header'][$col_key] = array();
+ $variables['header'][$col_key] = [];
$variables['header'][$col_key]['tag'] = $is_header ? 'th' : 'td';
$variables['header'][$col_key]['attributes'] = $cell_attributes;
$variables['header'][$col_key]['content'] = $cell_content;
@@ -988,12 +988,12 @@ function template_preprocess_table(&$variables) {
$variables['header_columns'] = $header_columns;
// Rows and footer have the same structure.
- $sections = array('rows' , 'footer');
+ $sections = ['rows' , 'footer'];
foreach ($sections as $section) {
if (!empty($variables[$section])) {
foreach ($variables[$section] as $row_key => $row) {
$cells = $row;
- $row_attributes = array();
+ $row_attributes = [];
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
@@ -1007,9 +1007,9 @@ function template_preprocess_table(&$variables) {
}
// Build row.
- $variables[$section][$row_key] = array();
+ $variables[$section][$row_key] = [];
$variables[$section][$row_key]['attributes'] = new Attribute($row_attributes);
- $variables[$section][$row_key]['cells'] = array();
+ $variables[$section][$row_key]['cells'] = [];
if (!empty($cells)) {
// Reset the responsive index.
$responsive_index = -1;
@@ -1019,7 +1019,7 @@ function template_preprocess_table(&$variables) {
if (!is_array($cell)) {
$cell_content = $cell;
- $cell_attributes = array();
+ $cell_attributes = [];
$is_header = FALSE;
}
else {
@@ -1079,7 +1079,7 @@ function template_preprocess_table(&$variables) {
function template_preprocess_item_list(&$variables) {
$variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']);
foreach ($variables['items'] as &$item) {
- $attributes = array();
+ $attributes = [];
// If the item value is an array, then it is a render array.
if (is_array($item)) {
// List items support attributes via the '#wrapper_attributes' property.
@@ -1118,10 +1118,10 @@ function template_preprocess_item_list(&$variables) {
}
// Set the item's value and attributes for the template.
- $item = array(
+ $item = [
'value' => $item,
'attributes' => new Attribute($attributes),
- );
+ ];
}
}
@@ -1139,7 +1139,7 @@ function template_preprocess_container(&$variables) {
$variables['has_parent'] = FALSE;
$element = $variables['element'];
// Ensure #attributes is set.
- $element += array('#attributes' => array());
+ $element += ['#attributes' => []];
// Special handling for form elements.
if (isset($element['#array_parents'])) {
@@ -1228,16 +1228,16 @@ function template_preprocess(&$variables, $hook, $info) {
*/
function _template_preprocess_default_variables() {
// Variables that don't depend on a database connection.
- $variables = array(
- 'attributes' => array(),
- 'title_attributes' => array(),
- 'content_attributes' => array(),
- 'title_prefix' => array(),
- 'title_suffix' => array(),
+ $variables = [
+ 'attributes' => [],
+ 'title_attributes' => [],
+ 'content_attributes' => [],
+ 'title_prefix' => [],
+ 'title_suffix' => [],
'db_is_active' => !defined('MAINTENANCE_MODE'),
'is_admin' => FALSE,
'logged_in' => FALSE,
- );
+ ];
// Give modules a chance to alter the default template variables.
\Drupal::moduleHandler()->alter('template_preprocess_default_variables', $variables);
@@ -1302,19 +1302,19 @@ function template_preprocess_html(&$variables) {
$variables['page']['#title'] = (string) \Drupal::service('renderer')->render($variables['page']['#title']);
}
if (!empty($variables['page']['#title'])) {
- $head_title = array(
+ $head_title = [
// Marking the title as safe since it has had the tags stripped.
'title' => Markup::create(trim(strip_tags($variables['page']['#title']))),
'name' => $site_config->get('name'),
- );
+ ];
}
// @todo Remove once views is not bypassing the view subscriber anymore.
// @see https://www.drupal.org/node/2068471
elseif ($is_front_page) {
- $head_title = array(
+ $head_title = [
'title' => t('Home'),
'name' => $site_config->get('name'),
- );
+ ];
}
else {
$head_title = ['name' => $site_config->get('name')];
@@ -1354,7 +1354,7 @@ function template_preprocess_page(&$variables) {
foreach (\Drupal::theme()->getActiveTheme()->getRegions() as $region) {
if (!isset($variables['page'][$region])) {
- $variables['page'][$region] = array();
+ $variables['page'][$region] = [];
}
}
@@ -1414,7 +1414,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
// page__node__1
// page__node__edit
- $suggestions = array();
+ $suggestions = [];
$prefix = $base;
foreach ($args as $arg) {
// Remove slashes or null per SA-CORE-2009-003 and change - (hyphen) to _
@@ -1429,7 +1429,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
// converted to underscores so here we must convert any hyphens in path
// arguments to underscores here before fetching theme hook suggestions
// to ensure the templates are appropriately recognized.
- $arg = str_replace(array("/", "\\", "\0", '-'), array('', '', '', '_'), $arg);
+ $arg = str_replace(["/", "\\", "\0", '-'], ['', '', '', '_'], $arg);
// The percent acts as a wildcard for numeric arguments since
// asterisks are not valid filename characters on many filesystems.
if (is_numeric($arg)) {
@@ -1562,7 +1562,7 @@ function template_preprocess_field(&$variables, $hook) {
// on those keys is faster than calling Element::children() or looping on all
// keys within $element, since that requires traversal of all element
// properties.
- $variables['items'] = array();
+ $variables['items'] = [];
$delta = 0;
while (!empty($element[$delta])) {
$variables['items'][$delta]['content'] = $element[$delta];
@@ -1597,29 +1597,29 @@ function template_preprocess_field_multiple_value_form(&$variables) {
if ($variables['multiple']) {
$table_id = Html::getUniqueId($element['#field_name'] . '_values');
$order_class = $element['#field_name'] . '-delta-order';
- $header_attributes = new Attribute(array('class' => array('label')));
+ $header_attributes = new Attribute(['class' => ['label']]);
if (!empty($element['#required'])) {
$header_attributes['class'][] = 'js-form-required';
$header_attributes['class'][] = 'form-required';
}
- $header = array(
- array(
- 'data' => array(
+ $header = [
+ [
+ 'data' => [
'#prefix' => '<h4' . $header_attributes . '>',
'#markup' => $element['#title'],
'#suffix' => '</h4>',
- ),
+ ],
'colspan' => 2,
- 'class' => array('field-label'),
- ),
- t('Order', array(), array('context' => 'Sort order')),
- );
- $rows = array();
+ 'class' => ['field-label'],
+ ],
+ t('Order', [], ['context' => 'Sort order']),
+ ];
+ $rows = [];
// Sort items according to '_weight' (needed when the form comes back after
// preview or failed validation).
- $items = array();
- $variables['button'] = array();
+ $items = [];
+ $variables['button'] = [];
foreach (Element::children($element) as $key) {
if ($key === 'add_more') {
$variables['button'] = &$element[$key];
@@ -1632,40 +1632,40 @@ function template_preprocess_field_multiple_value_form(&$variables) {
// Add the items as table rows.
foreach ($items as $item) {
- $item['_weight']['#attributes']['class'] = array($order_class);
+ $item['_weight']['#attributes']['class'] = [$order_class];
// Remove weight form element from item render array so it can be rendered
// in a separate table column.
$delta_element = $item['_weight'];
unset($item['_weight']);
- $cells = array(
- array('data' => '', 'class' => array('field-multiple-drag')),
- array('data' => $item),
- array('data' => $delta_element, 'class' => array('delta-order')),
- );
- $rows[] = array(
+ $cells = [
+ ['data' => '', 'class' => ['field-multiple-drag']],
+ ['data' => $item],
+ ['data' => $delta_element, 'class' => ['delta-order']],
+ ];
+ $rows[] = [
'data' => $cells,
- 'class' => array('draggable'),
- );
+ 'class' => ['draggable'],
+ ];
}
- $variables['table'] = array(
+ $variables['table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- '#attributes' => array(
+ '#attributes' => [
'id' => $table_id,
- 'class' => array('field-multiple-table'),
- ),
- '#tabledrag' => array(
- array(
+ 'class' => ['field-multiple-table'],
+ ],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => $order_class,
- ),
- ),
- );
+ ],
+ ],
+ ];
if (!empty($element['#description'])) {
$description_id = $element['#attributes']['aria-describedby'];
@@ -1678,7 +1678,7 @@ function template_preprocess_field_multiple_value_form(&$variables) {
}
}
else {
- $variables['elements'] = array();
+ $variables['elements'] = [];
foreach (Element::children($element) as $key) {
$variables['elements'][] = $element[$key];
}
@@ -1695,10 +1695,10 @@ function template_preprocess_field_multiple_value_form(&$variables) {
* - links: A list of \Drupal\Core\Link objects which should be rendered.
*/
function template_preprocess_breadcrumb(&$variables) {
- $variables['breadcrumb'] = array();
+ $variables['breadcrumb'] = [];
/** @var \Drupal\Core\Link $link */
foreach ($variables['links'] as $key => $link) {
- $variables['breadcrumb'][$key] = array('text' => $link->getText(), 'url' => $link->getUrl()->toString());
+ $variables['breadcrumb'][$key] = ['text' => $link->getText(), 'url' => $link->getUrl()->toString()];
}
}
@@ -1717,39 +1717,39 @@ function _field_multiple_value_form_sort_helper($a, $b) {
* Provides theme registration for themes across .inc files.
*/
function drupal_common_theme() {
- return array(
+ return [
// From theme.inc.
- 'html' => array(
+ 'html' => [
'render element' => 'html',
- ),
- 'page' => array(
+ ],
+ 'page' => [
'render element' => 'page',
- ),
- 'page_title' => array(
- 'variables' => array('title' => NULL),
- ),
- 'region' => array(
+ ],
+ 'page_title' => [
+ 'variables' => ['title' => NULL],
+ ],
+ 'region' => [
'render element' => 'elements',
- ),
- 'time' => array(
- 'variables' => array('timestamp' => NULL, 'text' => NULL, 'attributes' => array()),
- ),
- 'datetime_form' => array(
+ ],
+ 'time' => [
+ 'variables' => ['timestamp' => NULL, 'text' => NULL, 'attributes' => []],
+ ],
+ 'datetime_form' => [
'render element' => 'element',
- ),
- 'datetime_wrapper' => array(
+ ],
+ 'datetime_wrapper' => [
'render element' => 'element',
- ),
- 'status_messages' => array(
+ ],
+ 'status_messages' => [
'variables' => ['status_headings' => [], 'message_list' => NULL],
- ),
- 'links' => array(
- 'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array(), 'set_active_class' => FALSE),
- ),
- 'dropbutton_wrapper' => array(
- 'variables' => array('children' => NULL),
- ),
- 'image' => array(
+ ],
+ 'links' => [
+ 'variables' => ['links' => [], 'attributes' => ['class' => ['links']], 'heading' => [], 'set_active_class' => FALSE],
+ ],
+ 'dropbutton_wrapper' => [
+ 'variables' => ['children' => NULL],
+ ],
+ 'image' => [
// HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
// allows the alt attribute to be omitted in some cases. Therefore,
// default the alt attribute to an empty string, but allow code providing
@@ -1763,107 +1763,107 @@ function drupal_common_theme() {
// - http://dev.w3.org/html5/spec/Overview.html#alt
// The title attribute is optional in all cases, so it is omitted by
// default.
- 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array(), 'sizes' => NULL, 'srcset' => array(), 'style_name' => NULL),
- ),
- 'breadcrumb' => array(
- 'variables' => array('links' => array()),
- ),
- 'table' => array(
- 'variables' => array('header' => NULL, 'rows' => NULL, 'footer' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => FALSE, 'responsive' => TRUE, 'empty' => ''),
- ),
- 'tablesort_indicator' => array(
- 'variables' => array('style' => NULL),
- ),
- 'mark' => array(
- 'variables' => array('status' => MARK_NEW),
- ),
- 'item_list' => array(
- 'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => array(), 'attributes' => array(), 'empty' => NULL, 'context' => array()),
- ),
- 'feed_icon' => array(
- 'variables' => array('url' => NULL, 'title' => NULL),
- ),
- 'progress_bar' => array(
- 'variables' => array('label' => NULL, 'percent' => NULL, 'message' => NULL),
- ),
- 'indentation' => array(
- 'variables' => array('size' => 1),
- ),
+ 'variables' => ['uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => [], 'sizes' => NULL, 'srcset' => [], 'style_name' => NULL],
+ ],
+ 'breadcrumb' => [
+ 'variables' => ['links' => []],
+ ],
+ 'table' => [
+ 'variables' => ['header' => NULL, 'rows' => NULL, 'footer' => NULL, 'attributes' => [], 'caption' => NULL, 'colgroups' => [], 'sticky' => FALSE, 'responsive' => TRUE, 'empty' => ''],
+ ],
+ 'tablesort_indicator' => [
+ 'variables' => ['style' => NULL],
+ ],
+ 'mark' => [
+ 'variables' => ['status' => MARK_NEW],
+ ],
+ 'item_list' => [
+ 'variables' => ['items' => [], 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => [], 'attributes' => [], 'empty' => NULL, 'context' => []],
+ ],
+ 'feed_icon' => [
+ 'variables' => ['url' => NULL, 'title' => NULL],
+ ],
+ 'progress_bar' => [
+ 'variables' => ['label' => NULL, 'percent' => NULL, 'message' => NULL],
+ ],
+ 'indentation' => [
+ 'variables' => ['size' => 1],
+ ],
// From theme.maintenance.inc.
- 'maintenance_page' => array(
+ 'maintenance_page' => [
'render element' => 'page',
- ),
- 'install_page' => array(
+ ],
+ 'install_page' => [
'render element' => 'page',
- ),
- 'maintenance_task_list' => array(
- 'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL),
- ),
- 'authorize_report' => array(
+ ],
+ 'maintenance_task_list' => [
+ 'variables' => ['items' => NULL, 'active' => NULL, 'variant' => NULL],
+ ],
+ 'authorize_report' => [
'variables' => ['messages' => [], 'attributes' => []],
'includes' => ['core/includes/theme.maintenance.inc'],
'template' => 'authorize-report',
- ),
+ ],
// From pager.inc.
- 'pager' => array(
+ 'pager' => [
'render element' => 'pager',
- ),
+ ],
// From menu.inc.
- 'menu' => array(
- 'variables' => array('menu_name' => NULL, 'items' => array(), 'attributes' => array()),
- ),
- 'menu_local_task' => array(
+ 'menu' => [
+ 'variables' => ['menu_name' => NULL, 'items' => [], 'attributes' => []],
+ ],
+ 'menu_local_task' => [
'render element' => 'element',
- ),
- 'menu_local_action' => array(
+ ],
+ 'menu_local_action' => [
'render element' => 'element',
- ),
- 'menu_local_tasks' => array(
- 'variables' => array('primary' => array(), 'secondary' => array()),
- ),
+ ],
+ 'menu_local_tasks' => [
+ 'variables' => ['primary' => [], 'secondary' => []],
+ ],
// From form.inc.
- 'input' => array(
+ 'input' => [
'render element' => 'element',
- ),
- 'select' => array(
+ ],
+ 'select' => [
'render element' => 'element',
- ),
- 'fieldset' => array(
+ ],
+ 'fieldset' => [
'render element' => 'element',
- ),
- 'details' => array(
+ ],
+ 'details' => [
'render element' => 'element',
- ),
- 'radios' => array(
+ ],
+ 'radios' => [
'render element' => 'element',
- ),
- 'checkboxes' => array(
+ ],
+ 'checkboxes' => [
'render element' => 'element',
- ),
- 'form' => array(
+ ],
+ 'form' => [
'render element' => 'element',
- ),
- 'textarea' => array(
+ ],
+ 'textarea' => [
'render element' => 'element',
- ),
- 'form_element' => array(
+ ],
+ 'form_element' => [
'render element' => 'element',
- ),
- 'form_element_label' => array(
+ ],
+ 'form_element_label' => [
'render element' => 'element',
- ),
- 'vertical_tabs' => array(
+ ],
+ 'vertical_tabs' => [
'render element' => 'element',
- ),
- 'container' => array(
+ ],
+ 'container' => [
'render element' => 'element',
- ),
+ ],
// From field system.
- 'field' => array(
+ 'field' => [
'render element' => 'element',
- ),
- 'field_multiple_value_form' => array(
+ ],
+ 'field_multiple_value_form' => [
'render element' => 'element',
- ),
- );
+ ],
+ ];
}
diff --git a/core/includes/unicode.inc b/core/includes/unicode.inc
index b09ddb765fe..f6b3ee70dce 100644
--- a/core/includes/unicode.inc
+++ b/core/includes/unicode.inc
@@ -11,24 +11,24 @@ use Drupal\Component\Utility\Unicode;
* Returns Unicode library status and errors.
*/
function unicode_requirements() {
- $libraries = array(
+ $libraries = [
Unicode::STATUS_SINGLEBYTE => t('Standard PHP'),
Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'),
Unicode::STATUS_ERROR => t('Error'),
- );
- $severities = array(
+ ];
+ $severities = [
Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING,
Unicode::STATUS_MULTIBYTE => NULL,
Unicode::STATUS_ERROR => REQUIREMENT_ERROR,
- );
+ ];
$failed_check = Unicode::check();
$library = Unicode::getStatus();
- $requirements['unicode'] = array(
+ $requirements['unicode'] = [
'title' => t('Unicode library'),
'value' => $libraries[$library],
'severity' => $severities[$library],
- );
+ ];
switch ($failed_check) {
case 'mb_strlen':
$requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="http://php.net/mbstring">PHP mbstring extension</a> for improved Unicode support.');
@@ -97,7 +97,7 @@ function drupal_xml_parser_create(&$data) {
}
// Unsupported encodings are converted here into UTF-8.
- $php_supported = array('utf-8', 'iso-8859-1', 'us-ascii');
+ $php_supported = ['utf-8', 'iso-8859-1', 'us-ascii'];
if (!in_array(strtolower($encoding), $php_supported)) {
$out = Unicode::convertToUtf8($data, $encoding);
if ($out !== FALSE) {
@@ -105,7 +105,7 @@ function drupal_xml_parser_create(&$data) {
$data = preg_replace('/^(<\?xml[^>]+encoding)="(.+?)"/', '\\1="utf-8"', $out);
}
else {
- \Drupal::logger('php')->warning('Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding));
+ \Drupal::logger('php')->warning('Could not convert XML encoding %s to UTF-8.', ['%s' => $encoding]);
return FALSE;
}
}
diff --git a/core/includes/update.inc b/core/includes/update.inc
index a9b5de92320..6e0707f7a0c 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -17,7 +17,7 @@ use Drupal\Core\Utility\Error;
function update_fix_compatibility() {
$extension_config = \Drupal::configFactory()->getEditable('core.extension');
$save = FALSE;
- foreach (array('module', 'theme') as $type) {
+ foreach (['module', 'theme'] as $type) {
foreach ($extension_config->get($type) as $name => $weight) {
if (update_check_incompatibility($name, $type)) {
$extension_config->clear("$type.$name");
@@ -68,23 +68,23 @@ function update_check_incompatibility($name, $type = 'module') {
* A requirements info array.
*/
function update_system_schema_requirements() {
- $requirements = array();
+ $requirements = [];
$system_schema = drupal_get_installed_schema_version('system');
$requirements['minimum schema']['title'] = 'Minimum schema version';
if ($system_schema >= \Drupal::CORE_MINIMUM_SCHEMA_VERSION) {
- $requirements['minimum schema'] += array(
+ $requirements['minimum schema'] += [
'value' => 'The installed schema version meets the minimum.',
'description' => 'Schema version: ' . $system_schema,
- );
+ ];
}
else {
- $requirements['minimum schema'] += array(
+ $requirements['minimum schema'] += [
'value' => 'The installed schema version does not meet the minimum.',
'severity' => REQUIREMENT_ERROR,
'description' => 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must <a href="https://www.drupal.org/node/2179269">migrate your site to Drupal 8</a> first.',
- );
+ ];
}
return $requirements;
@@ -95,7 +95,7 @@ function update_system_schema_requirements() {
*/
function update_check_requirements() {
// Check requirements of all loaded modules.
- $requirements = \Drupal::moduleHandler()->invokeAll('requirements', array('update'));
+ $requirements = \Drupal::moduleHandler()->invokeAll('requirements', ['update']);
$requirements += update_system_schema_requirements();
return $requirements;
}
@@ -168,11 +168,11 @@ function update_do_one($module, $number, $dependency_map, &$context) {
// If this update was aborted in a previous step, or has a dependency that
// was aborted in a previous step, go no further.
- if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, array($function)))) {
+ if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, [$function]))) {
return;
}
- $ret = array();
+ $ret = [];
if (function_exists($function)) {
try {
$ret['results']['query'] = $function($context['sandbox']);
@@ -187,7 +187,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
$variables = Error::decodeException($e);
unset($variables['backtrace']);
- $ret['#abort'] = array('success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables));
+ $ret['#abort'] = ['success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables)];
}
}
@@ -197,10 +197,10 @@ function update_do_one($module, $number, $dependency_map, &$context) {
}
if (!isset($context['results'][$module])) {
- $context['results'][$module] = array();
+ $context['results'][$module] = [];
}
if (!isset($context['results'][$module][$number])) {
- $context['results'][$module][$number] = array();
+ $context['results'][$module][$number] = [];
}
$context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
@@ -266,7 +266,7 @@ function update_invoke_post_update($function, &$context) {
unset($context['sandbox']['#finished']);
}
if (!isset($context['results'][$module][$name])) {
- $context['results'][$module][$name] = array();
+ $context['results'][$module][$name] = [];
}
$context['results'][$module][$name] = array_merge($context['results'][$module][$name], $ret);
@@ -298,7 +298,7 @@ function update_invoke_post_update($function, &$context) {
*/
function update_get_update_list() {
// Make sure that the system module is first in the list of updates.
- $ret = array('system' => array());
+ $ret = ['system' => []];
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
foreach ($modules as $module => $schema_version) {
@@ -332,7 +332,7 @@ function update_get_update_list() {
if ($update > $schema_version) {
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module . '_update_' . $update);
- $description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
+ $description = str_replace(["\n", '*', '/'], '', $func->getDocComment());
$ret[$module]['pending'][$update] = "$update - $description";
if (!isset($ret[$module]['start'])) {
$ret[$module]['start'] = $update;
@@ -400,7 +400,7 @@ function update_resolve_dependencies($starting_updates) {
// Perform the depth-first search and sort on the results.
$graph_object = new Graph($graph);
$graph = $graph_object->searchAndSort();
- uasort($graph, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($graph, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
foreach ($graph as $function => &$data) {
$module = $data['module'];
@@ -416,7 +416,7 @@ function update_resolve_dependencies($starting_updates) {
}
elseif (!isset($data['allowed'])) {
$data['allowed'] = TRUE;
- $data['missing_dependencies'] = array();
+ $data['missing_dependencies'] = [];
}
// Now that we have finished processing this function, remove it from the
// graph if it was not part of the original list. This ensures that we
@@ -448,9 +448,9 @@ function update_resolve_dependencies($starting_updates) {
function update_get_update_function_list($starting_updates) {
// Go through each module and find all updates that we need (including the
// first update that was requested and any updates that run after it).
- $update_functions = array();
+ $update_functions = [];
foreach ($starting_updates as $module => $version) {
- $update_functions[$module] = array();
+ $update_functions[$module] = [];
$updates = drupal_get_schema_versions($module);
if ($updates !== FALSE) {
$max_version = max($updates);
@@ -512,7 +512,7 @@ function update_get_update_function_list($starting_updates) {
function update_build_dependency_graph($update_functions) {
// Initialize an array that will define a directed graph representing the
// dependencies between update functions.
- $graph = array();
+ $graph = [];
// Go through each update function and build an initial list of dependencies.
foreach ($update_functions as $module => $functions) {
@@ -600,7 +600,7 @@ function update_already_performed($module, $number) {
* @see hook_update_dependencies()
*/
function update_retrieve_dependencies() {
- $return = array();
+ $return = [];
// Get a list of installed modules, arranged so that we invoke their hooks in
// the same order that \Drupal::moduleHandler()->invokeAll() does.
foreach (\Drupal::keyValue('system.schema')->getAll() as $module => $schema) {
@@ -675,7 +675,7 @@ function update_replace_permissions($replace) {
foreach ($role_names as $role_name) {
$rid = substr($role_name, $cut);
$config = \Drupal::config("user.role.$rid");
- $permissions = $config->get('permissions') ?: array();
+ $permissions = $config->get('permissions') ?: [];
foreach ($replace as $old_permission => $new_permissions) {
if (($index = array_search($old_permission, $permissions)) !== FALSE) {
unset($permissions[$index]);
@@ -707,7 +707,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
// Initialize master language list.
if (!isset($languages)) {
// Initialize local language list cache.
- $languages = array();
+ $languages = [];
// Fill in master language list based on current configuration.
$default = \Drupal::languageManager()->getDefaultLanguage();
@@ -721,20 +721,20 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
foreach ($language_entities as $langcode_config_name) {
$langcode = substr($langcode_config_name, strlen('language.entity.'));
$info = \Drupal::config($langcode_config_name)->get();
- $languages[$langcode] = new Language(array(
+ $languages[$langcode] = new Language([
'default' => ($info['id'] == $default->getId()),
'name' => $info['label'],
'id' => $info['id'],
'direction' => $info['direction'],
'locked' => $info['locked'],
'weight' => $info['weight'],
- ));
+ ]);
}
Language::sort($languages);
}
else {
// No language module, so use the default language only.
- $languages = array($default->getId() => $default);
+ $languages = [$default->getId() => $default];
// Add the special languages, they will be filtered later if needed.
$languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight());
}
@@ -743,13 +743,13 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
// Filter the full list of languages based on the value of the $all flag. By
// default we remove the locked languages, but the caller may request for
// those languages to be added as well.
- $filtered_languages = array();
+ $filtered_languages = [];
// Add the site's default language if flagged as allowed value.
if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
$default = \Drupal::languageManager()->getDefaultLanguage();
// Rename the default language.
- $default->setName(t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())));
+ $default->setName(t("Site's default language (@lang_name)", ['@lang_name' => $default->getName()]));
$filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
}
diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php
index de2229755ce..1acfc12e9a6 100644
--- a/core/lib/Drupal.php
+++ b/core/lib/Drupal.php
@@ -566,7 +566,7 @@ class Drupal {
* Instead create a \Drupal\Core\Url object directly, for example using
* Url::fromRoute().
*/
- public static function url($route_name, $route_parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
+ public static function url($route_name, $route_parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) {
return static::getContainer()->get('url_generator')->generateFromRoute($route_name, $route_parameters, $options, $collect_bubbleable_metadata);
}
diff --git a/core/lib/Drupal/Component/Annotation/Plugin.php b/core/lib/Drupal/Component/Annotation/Plugin.php
index 29f36759c3d..790440d1129 100644
--- a/core/lib/Drupal/Component/Annotation/Plugin.php
+++ b/core/lib/Drupal/Component/Annotation/Plugin.php
@@ -52,7 +52,7 @@ class Plugin implements AnnotationInterface {
* The parsed annotation as a definition.
*/
protected function parse(array $values) {
- $definitions = array();
+ $definitions = [];
foreach ($values as $key => $value) {
if ($value instanceof AnnotationInterface) {
$definitions[$key] = $value->get();
diff --git a/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php
index 879f13b3c36..b350ac02293 100644
--- a/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php
+++ b/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php
@@ -69,7 +69,7 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
* @param string[] $annotation_namespaces
* (optional) Additional namespaces to be scanned for annotation classes.
*/
- function __construct($plugin_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) {
+ function __construct($plugin_namespaces = [], $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) {
$this->pluginNamespaces = $plugin_namespaces;
$this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
$this->annotationNamespaces = $annotation_namespaces;
@@ -105,7 +105,7 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
* {@inheritdoc}
*/
public function getDefinitions() {
- $definitions = array();
+ $definitions = [];
$reader = $this->getAnnotationReader();
diff --git a/core/lib/Drupal/Component/Annotation/PluginID.php b/core/lib/Drupal/Component/Annotation/PluginID.php
index 6120d19f639..462ebd4138f 100644
--- a/core/lib/Drupal/Component/Annotation/PluginID.php
+++ b/core/lib/Drupal/Component/Annotation/PluginID.php
@@ -22,11 +22,11 @@ class PluginID extends AnnotationBase {
* {@inheritdoc}
*/
public function get() {
- return array(
+ return [
'id' => $this->value,
'class' => $this->class,
'provider' => $this->provider,
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php
index 3d8f77b176f..f914b698c8b 100644
--- a/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php
+++ b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php
@@ -25,7 +25,7 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
*
* @see \Drupal\Component\Bridge\ZfExtensionManagerSfContainer::canonicalizeName().
*/
- protected $canonicalNamesReplacements = array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => '');
+ protected $canonicalNamesReplacements = ['-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''];
/**
* The prefix to be used when retrieving plugins from the container.
diff --git a/core/lib/Drupal/Component/Datetime/DateTimePlus.php b/core/lib/Drupal/Component/Datetime/DateTimePlus.php
index 3f59b59e570..d3cb15ec7c2 100644
--- a/core/lib/Drupal/Component/Datetime/DateTimePlus.php
+++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php
@@ -41,14 +41,14 @@ class DateTimePlus {
/**
* An array of possible date parts.
*/
- protected static $dateParts = array(
+ protected static $dateParts = [
'year',
'month',
'day',
'hour',
'minute',
'second',
- );
+ ];
/**
* The value of the time value passed to the constructor.
@@ -88,7 +88,7 @@ class DateTimePlus {
/**
* An array of errors encountered when creating this date.
*/
- protected $errors = array();
+ protected $errors = [];
/**
* The DateTime object.
@@ -108,7 +108,7 @@ class DateTimePlus {
* @return static
* A new DateTimePlus object.
*/
- public static function createFromDateTime(\DateTime $datetime, $settings = array()) {
+ public static function createFromDateTime(\DateTime $datetime, $settings = []) {
return new static($datetime->format(static::FORMAT), $datetime->getTimezone(), $settings);
}
@@ -133,7 +133,7 @@ class DateTimePlus {
* @throws \InvalidArgumentException
* If the array date values or value combination is not correct.
*/
- public static function createFromArray(array $date_parts, $timezone = NULL, $settings = array()) {
+ public static function createFromArray(array $date_parts, $timezone = NULL, $settings = []) {
$date_parts = static::prepareArray($date_parts, TRUE);
if (static::checkArray($date_parts)) {
// Even with validation, we can end up with a value that the
@@ -167,7 +167,7 @@ class DateTimePlus {
* @throws \InvalidArgumentException
* If the timestamp is not numeric.
*/
- public static function createFromTimestamp($timestamp, $timezone = NULL, $settings = array()) {
+ public static function createFromTimestamp($timestamp, $timezone = NULL, $settings = []) {
if (!is_numeric($timestamp)) {
throw new \InvalidArgumentException('The timestamp must be numeric.');
}
@@ -207,7 +207,7 @@ class DateTimePlus {
* @throws \UnexpectedValueException
* If the created date does not match the input value.
*/
- public static function createFromFormat($format, $time, $timezone = NULL, $settings = array()) {
+ public static function createFromFormat($format, $time, $timezone = NULL, $settings = []) {
if (!isset($settings['validate_format'])) {
$settings['validate_format'] = TRUE;
}
@@ -258,7 +258,7 @@ class DateTimePlus {
* - debug: (optional) Boolean choice to leave debug values in the
* date object for debugging purposes. Defaults to FALSE.
*/
- public function __construct($time = 'now', $timezone = NULL, $settings = array()) {
+ public function __construct($time = 'now', $timezone = NULL, $settings = []) {
// Unpack settings.
$this->langcode = !empty($settings['langcode']) ? $settings['langcode'] : NULL;
@@ -310,7 +310,7 @@ class DateTimePlus {
if (!method_exists($this->dateTimeObject, $method)) {
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method));
}
- return call_user_func_array(array($this->dateTimeObject, $method), $args);
+ return call_user_func_array([$this->dateTimeObject, $method], $args);
}
/**
@@ -346,7 +346,7 @@ class DateTimePlus {
if (!method_exists('\DateTime', $method)) {
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_called_class(), $method));
}
- return call_user_func_array(array('\DateTime', $method), $args);
+ return call_user_func_array(['\DateTime', $method], $args);
}
/**
@@ -529,24 +529,24 @@ class DateTimePlus {
public static function prepareArray($array, $force_valid_date = FALSE) {
if ($force_valid_date) {
$now = new \DateTime();
- $array += array(
+ $array += [
'year' => $now->format('Y'),
'month' => 1,
'day' => 1,
'hour' => 0,
'minute' => 0,
'second' => 0,
- );
+ ];
}
else {
- $array += array(
+ $array += [
'year' => '',
'month' => '',
'day' => '',
'hour' => '',
'minute' => '',
'second' => '',
- );
+ ];
}
return $array;
}
@@ -577,7 +577,7 @@ class DateTimePlus {
}
// Testing for valid time is reversed. Missing time is OK,
// but incorrect values are not.
- foreach (array('hour', 'minute', 'second') as $key) {
+ foreach (['hour', 'minute', 'second'] as $key) {
if (array_key_exists($key, $array)) {
$value = $array[$key];
switch ($key) {
@@ -628,7 +628,7 @@ class DateTimePlus {
* @return string
* The formatted value of the date.
*/
- public function format($format, $settings = array()) {
+ public function format($format, $settings = []) {
// If there were construction errors, we can't format the date.
if ($this->hasErrors()) {
diff --git a/core/lib/Drupal/Component/DependencyInjection/Container.php b/core/lib/Drupal/Component/DependencyInjection/Container.php
index 452a2c84d82..67373695452 100644
--- a/core/lib/Drupal/Component/DependencyInjection/Container.php
+++ b/core/lib/Drupal/Component/DependencyInjection/Container.php
@@ -57,42 +57,42 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
*
* @var array
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* The aliases of the container.
*
* @var array
*/
- protected $aliases = array();
+ protected $aliases = [];
/**
* The service definitions of the container.
*
* @var array
*/
- protected $serviceDefinitions = array();
+ protected $serviceDefinitions = [];
/**
* The instantiated services.
*
* @var array
*/
- protected $services = array();
+ protected $services = [];
/**
* The instantiated private services.
*
* @var array
*/
- protected $privateServices = array();
+ protected $privateServices = [];
/**
* The currently loading services.
*
* @var array
*/
- protected $loading = array();
+ protected $loading = [];
/**
* Whether the container parameters can still be changed.
@@ -116,14 +116,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
* - machine_format: Whether this container definition uses the optimized
* machine-readable container format.
*/
- public function __construct(array $container_definition = array()) {
+ public function __construct(array $container_definition = []) {
if (!empty($container_definition) && (!isset($container_definition['machine_format']) || $container_definition['machine_format'] !== TRUE)) {
throw new InvalidArgumentException('The non-optimized format is not supported by this class. Use an optimized machine-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.');
}
- $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array();
- $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array();
- $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array();
+ $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : [];
+ $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : [];
+ $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : [];
$this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE;
// Register the service_container with itself.
@@ -228,7 +228,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id));
}
- $arguments = array();
+ $arguments = [];
if (isset($definition['arguments'])) {
$arguments = $definition['arguments'];
@@ -238,14 +238,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
}
if (isset($definition['file'])) {
- $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file'])));
+ $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']]));
require_once $file;
}
if (isset($definition['factory'])) {
$factory = $definition['factory'];
if (is_array($factory)) {
- $factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1]));
+ $factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]);
}
elseif (!is_string($factory)) {
throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
@@ -254,7 +254,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
$service = call_user_func_array($factory, $arguments);
}
else {
- $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class'])));
+ $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']]));
$length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments);
// Optimize class instantiation for services with up to 10 parameters as
@@ -322,14 +322,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
if (isset($definition['calls'])) {
foreach ($definition['calls'] as $call) {
$method = $call[0];
- $arguments = array();
+ $arguments = [];
if (!empty($call[1])) {
$arguments = $call[1];
if ($arguments instanceof \stdClass) {
$arguments = $this->resolveServicesAndParameters($arguments);
}
}
- call_user_func_array(array($service, $method), $arguments);
+ call_user_func_array([$service, $method], $arguments);
}
}
@@ -362,7 +362,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
* {@inheritdoc}
*/
public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) {
- if (!in_array($scope, array('container', 'request')) || ('request' === $scope && 'request' !== $id)) {
+ if (!in_array($scope, ['container', 'request']) || ('request' === $scope && 'request' !== $id)) {
@trigger_error('The concept of container scopes is deprecated since version 2.8 and will be removed in 3.0. Omit the third parameter.', E_USER_DEPRECATED);
}
@@ -549,7 +549,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
* An array of strings with suitable alternatives.
*/
protected function getAlternatives($search_key, array $keys) {
- $alternatives = array();
+ $alternatives = [];
foreach ($keys as $key) {
$lev = levenshtein($search_key, $key);
if ($lev <= strlen($search_key) / 3 || strpos($key, $search_key) !== FALSE) {
diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
index 76a43fd2a51..7673cef8ba5 100644
--- a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
+++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
@@ -49,7 +49,7 @@ class OptimizedPhpArrayDumper extends Dumper {
/**
* {@inheritdoc}
*/
- public function dump(array $options = array()) {
+ public function dump(array $options = []) {
return serialize($this->getArray());
}
@@ -60,7 +60,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* A PHP array representation of the service container.
*/
public function getArray() {
- $definition = array();
+ $definition = [];
$this->aliases = $this->getAliases();
$definition['aliases'] = $this->getAliases();
$definition['parameters'] = $this->getParameters();
@@ -77,7 +77,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* The aliases.
*/
protected function getAliases() {
- $alias_definitions = array();
+ $alias_definitions = [];
$aliases = $this->container->getAliases();
foreach ($aliases as $alias => $id) {
@@ -99,7 +99,7 @@ class OptimizedPhpArrayDumper extends Dumper {
*/
protected function getParameters() {
if (!$this->container->getParameterBag()->all()) {
- return array();
+ return [];
}
$parameters = $this->container->getParameterBag()->all();
@@ -115,10 +115,10 @@ class OptimizedPhpArrayDumper extends Dumper {
*/
protected function getServiceDefinitions() {
if (!$this->container->getDefinitions()) {
- return array();
+ return [];
}
- $services = array();
+ $services = [];
foreach ($this->container->getDefinitions() as $id => $definition) {
// Only store public service definitions, references to shared private
// services are handled in ::getReferenceCall().
@@ -143,7 +143,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* An array of prepared parameters.
*/
protected function prepareParameters(array $parameters, $escape = TRUE) {
- $filtered = array();
+ $filtered = [];
foreach ($parameters as $key => $value) {
if (is_array($value)) {
$value = $this->prepareParameters($value, $escape);
@@ -168,7 +168,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* The escaped parameters.
*/
protected function escape(array $parameters) {
- $args = array();
+ $args = [];
foreach ($parameters as $key => $value) {
if (is_array($value)) {
@@ -199,7 +199,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* scope different from SCOPE_CONTAINER and SCOPE_PROTOTYPE.
*/
protected function getServiceDefinition(Definition $definition) {
- $service = array();
+ $service = [];
if ($definition->getClass()) {
$service['class'] = $definition->getClass();
}
@@ -279,11 +279,11 @@ class OptimizedPhpArrayDumper extends Dumper {
* The PHP array representation of the method calls.
*/
protected function dumpMethodCalls(array $calls) {
- $code = array();
+ $code = [];
foreach ($calls as $key => $call) {
$method = $call[0];
- $arguments = array();
+ $arguments = [];
if (!empty($call[1])) {
$arguments = $this->dumpCollection($call[1]);
}
@@ -309,7 +309,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* The collection in a suitable format.
*/
protected function dumpCollection($collection, &$resolve = FALSE) {
- $code = array();
+ $code = [];
foreach ($collection as $key => $value) {
if (is_array($value)) {
@@ -332,11 +332,11 @@ class OptimizedPhpArrayDumper extends Dumper {
return $collection;
}
- return (object) array(
+ return (object) [
'type' => 'collection',
'value' => $code,
'resolve' => $resolve,
- );
+ ];
}
/**
@@ -351,7 +351,7 @@ class OptimizedPhpArrayDumper extends Dumper {
protected function dumpCallable($callable) {
if (is_array($callable)) {
$callable[0] = $this->dumpValue($callable[0]);
- $callable = array($callable[0], $callable[1]);
+ $callable = [$callable[0], $callable[1]];
}
return $callable;
@@ -377,12 +377,12 @@ class OptimizedPhpArrayDumper extends Dumper {
$hash = Crypt::hashBase64(serialize($service_definition));
$id = 'private__' . $hash;
}
- return (object) array(
+ return (object) [
'type' => 'private_service',
'id' => $id,
'value' => $service_definition,
'shared' => $shared,
- );
+ ];
}
/**
@@ -399,7 +399,7 @@ class OptimizedPhpArrayDumper extends Dumper {
*/
protected function dumpValue($value) {
if (is_array($value)) {
- $code = array();
+ $code = [];
foreach ($value as $k => $v) {
$code[$k] = $this->dumpValue($v);
}
@@ -482,11 +482,11 @@ class OptimizedPhpArrayDumper extends Dumper {
* A suitable representation of the service reference.
*/
protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
- return (object) array(
+ return (object) [
'type' => 'service',
'id' => $id,
'invalidBehavior' => $invalid_behavior,
- );
+ ];
}
/**
@@ -499,10 +499,10 @@ class OptimizedPhpArrayDumper extends Dumper {
* A suitable representation of the parameter reference.
*/
protected function getParameterCall($name) {
- return (object) array(
+ return (object) [
'type' => 'parameter',
'name' => $name,
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php
index 7be318f7143..a6fa2b9b09e 100644
--- a/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php
+++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php
@@ -30,7 +30,7 @@ class PhpArrayDumper extends OptimizedPhpArrayDumper {
* {@inheritdoc}
*/
protected function dumpCollection($collection, &$resolve = FALSE) {
- $code = array();
+ $code = [];
foreach ($collection as $key => $value) {
if (is_array($value)) {
diff --git a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
index 3ec208630eb..83d558cbd34 100644
--- a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
+++ b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
@@ -27,16 +27,16 @@ class PhpArrayContainer extends Container {
/**
* {@inheritdoc}
*/
- public function __construct(array $container_definition = array()) {
+ public function __construct(array $container_definition = []) {
if (isset($container_definition['machine_format']) && $container_definition['machine_format'] === TRUE) {
throw new InvalidArgumentException('The machine-optimized format is not supported by this class. Use a human-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper.');
}
// Do not call the parent's constructor as it would bail on the
// machine-optimized format.
- $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array();
- $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array();
- $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array();
+ $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : [];
+ $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : [];
+ $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : [];
$this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE;
// Register the service_container with itself.
@@ -57,20 +57,20 @@ class PhpArrayContainer extends Container {
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id));
}
- $arguments = array();
+ $arguments = [];
if (isset($definition['arguments'])) {
$arguments = $this->resolveServicesAndParameters($definition['arguments']);
}
if (isset($definition['file'])) {
- $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file'])));
+ $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']]));
require_once $file;
}
if (isset($definition['factory'])) {
$factory = $definition['factory'];
if (is_array($factory)) {
- $factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1]));
+ $factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]);
}
elseif (!is_string($factory)) {
throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
@@ -79,7 +79,7 @@ class PhpArrayContainer extends Container {
$service = call_user_func_array($factory, $arguments);
}
else {
- $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class'])));
+ $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']]));
$length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments);
// Optimize class instantiation for services with up to 10 parameters as
@@ -147,12 +147,12 @@ class PhpArrayContainer extends Container {
if (isset($definition['calls'])) {
foreach ($definition['calls'] as $call) {
$method = $call[0];
- $arguments = array();
+ $arguments = [];
if (!empty($call[1])) {
$arguments = $call[1];
$arguments = $this->resolveServicesAndParameters($arguments);
}
- call_user_func_array(array($service, $method), $arguments);
+ call_user_func_array([$service, $method], $arguments);
}
}
diff --git a/core/lib/Drupal/Component/Diff/Diff.php b/core/lib/Drupal/Component/Diff/Diff.php
index 2e35611dbf7..d9042bcca71 100644
--- a/core/lib/Drupal/Component/Diff/Diff.php
+++ b/core/lib/Drupal/Component/Diff/Diff.php
@@ -49,7 +49,7 @@ class Diff {
*/
public function reverse() {
$rev = $this;
- $rev->edits = array();
+ $rev->edits = [];
foreach ($this->edits as $edit) {
$rev->edits[] = $edit->reverse();
}
@@ -96,7 +96,7 @@ class Diff {
* @return array The original sequence of strings.
*/
public function orig() {
- $lines = array();
+ $lines = [];
foreach ($this->edits as $edit) {
if ($edit->orig) {
@@ -115,7 +115,7 @@ class Diff {
* @return array The sequence of strings.
*/
public function closing() {
- $lines = array();
+ $lines = [];
foreach ($this->edits as $edit) {
if ($edit->closing) {
diff --git a/core/lib/Drupal/Component/Diff/DiffFormatter.php b/core/lib/Drupal/Component/Diff/DiffFormatter.php
index edcb84df78f..d70f3e61ad3 100644
--- a/core/lib/Drupal/Component/Diff/DiffFormatter.php
+++ b/core/lib/Drupal/Component/Diff/DiffFormatter.php
@@ -41,10 +41,10 @@ class DiffFormatter {
*
* @var array
*/
- protected $line_stats = array(
- 'counter' => array('x' => 0, 'y' => 0),
- 'offset' => array('x' => 0, 'y' => 0),
- );
+ protected $line_stats = [
+ 'counter' => ['x' => 0, 'y' => 0],
+ 'offset' => ['x' => 0, 'y' => 0],
+ ];
/**
* Format a diff.
@@ -58,7 +58,7 @@ class DiffFormatter {
public function format(Diff $diff) {
$xi = $yi = 1;
$block = FALSE;
- $context = array();
+ $context = [];
$nlead = $this->leading_context_lines;
$ntrail = $this->trailing_context_lines;
@@ -87,7 +87,7 @@ class DiffFormatter {
$context = array_slice($context, sizeof($context) - $nlead);
$x0 = $xi - sizeof($context);
$y0 = $yi - sizeof($context);
- $block = array();
+ $block = [];
if ($context) {
$block[] = new DiffOpCopy($context);
}
diff --git a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
index b27886d36dd..7885c6f00e5 100644
--- a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
+++ b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php
@@ -38,9 +38,9 @@ class DiffEngine {
$n_from = sizeof($from_lines);
$n_to = sizeof($to_lines);
- $this->xchanged = $this->ychanged = array();
- $this->xv = $this->yv = array();
- $this->xind = $this->yind = array();
+ $this->xchanged = $this->ychanged = [];
+ $this->xv = $this->yv = [];
+ $this->xind = $this->yind = [];
unset($this->seq);
unset($this->in_seq);
unset($this->lcs);
@@ -93,14 +93,14 @@ class DiffEngine {
$this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged);
// Compute the edit operations.
- $edits = array();
+ $edits = [];
$xi = $yi = 0;
while ($xi < $n_from || $yi < $n_to) {
$this::USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]);
$this::USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]);
// Skip matching "snake".
- $copy = array();
+ $copy = [];
while ( $xi < $n_from && $yi < $n_to && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
$copy[] = $from_lines[$xi++];
++$yi;
@@ -109,11 +109,11 @@ class DiffEngine {
$edits[] = new DiffOpCopy($copy);
}
// Find deletes & adds.
- $delete = array();
+ $delete = [];
while ($xi < $n_from && $this->xchanged[$xi]) {
$delete[] = $from_lines[$xi++];
}
- $add = array();
+ $add = [];
while ($yi < $n_to && $this->ychanged[$yi]) {
$add[] = $to_lines[$yi++];
}
@@ -167,7 +167,7 @@ class DiffEngine {
// Things seems faster (I'm not sure I understand why)
// when the shortest sequence in X.
$flip = TRUE;
- list($xoff, $xlim, $yoff, $ylim) = array($yoff, $ylim, $xoff, $xlim);
+ list($xoff, $xlim, $yoff, $ylim) = [$yoff, $ylim, $xoff, $xlim];
}
if ($flip) {
@@ -182,8 +182,8 @@ class DiffEngine {
}
$this->lcs = 0;
$this->seq[0] = $yoff - 1;
- $this->in_seq = array();
- $ymids[0] = array();
+ $this->in_seq = [];
+ $ymids[0] = [];
$numer = $xlim - $xoff + $nchunks - 1;
$x = $xoff;
@@ -228,16 +228,16 @@ class DiffEngine {
}
}
- $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
+ $seps[] = $flip ? [$yoff, $xoff] : [$xoff, $yoff];
$ymid = $ymids[$this->lcs];
for ($n = 0; $n < $nchunks - 1; $n++) {
$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
$y1 = $ymid[$n] + 1;
- $seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
+ $seps[] = $flip ? [$y1, $x1] : [$x1, $y1];
}
- $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
+ $seps[] = $flip ? [$ylim, $xlim] : [$xlim, $ylim];
- return array($this->lcs, $seps);
+ return [$this->lcs, $seps];
}
protected function _lcs_pos($ypos) {
diff --git a/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php b/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php
index 532c7014c17..eb7d9434c96 100644
--- a/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php
+++ b/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php
@@ -20,7 +20,7 @@ class HWLDFWordAccumulator {
*/
const NBSP = '&#160;';
- protected $lines = array();
+ protected $lines = [];
protected $line = '';
diff --git a/core/lib/Drupal/Component/Diff/WordLevelDiff.php b/core/lib/Drupal/Component/Diff/WordLevelDiff.php
index a19c687ef78..a8c2f80f256 100644
--- a/core/lib/Drupal/Component/Diff/WordLevelDiff.php
+++ b/core/lib/Drupal/Component/Diff/WordLevelDiff.php
@@ -22,8 +22,8 @@ class WordLevelDiff extends MappedDiff {
}
protected function _split($lines) {
- $words = array();
- $stripped = array();
+ $words = [];
+ $stripped = [];
$first = TRUE;
foreach ($lines as $line) {
// If the line is too long, just pretend the entire line is one big word
@@ -46,7 +46,7 @@ class WordLevelDiff extends MappedDiff {
}
}
}
- return array($words, $stripped);
+ return [$words, $stripped];
}
public function orig() {
diff --git a/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php b/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php
index 6d0eceb5284..db2c3cc9652 100644
--- a/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php
+++ b/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php
@@ -65,7 +65,7 @@ class YamlDirectoryDiscovery implements DiscoverableInterface {
* {@inheritdoc}
*/
public function findAll() {
- $all = array();
+ $all = [];
$files = $this->findFiles();
diff --git a/core/lib/Drupal/Component/Discovery/YamlDiscovery.php b/core/lib/Drupal/Component/Discovery/YamlDiscovery.php
index ea5c9c25b39..f13e60b97fa 100644
--- a/core/lib/Drupal/Component/Discovery/YamlDiscovery.php
+++ b/core/lib/Drupal/Component/Discovery/YamlDiscovery.php
@@ -22,7 +22,7 @@ class YamlDiscovery implements DiscoverableInterface {
*
* @var array
*/
- protected $directories = array();
+ protected $directories = [];
/**
* Constructs a YamlDiscovery object.
@@ -42,7 +42,7 @@ class YamlDiscovery implements DiscoverableInterface {
* {@inheritdoc}
*/
public function findAll() {
- $all = array();
+ $all = [];
$files = $this->findFiles();
$provider_by_files = array_flip($files);
@@ -86,7 +86,7 @@ class YamlDiscovery implements DiscoverableInterface {
* @return array
*/
protected function findFiles() {
- $files = array();
+ $files = [];
foreach ($this->directories as $provider => $directory) {
$file = $directory . '/' . $provider . '.' . $this->name . '.yml';
if (file_exists($file)) {
diff --git a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
index a933b065948..6c1e2008253 100644
--- a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
+++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
@@ -230,14 +230,14 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
public function addSubscriber(EventSubscriberInterface $subscriber) {
foreach ($subscriber->getSubscribedEvents() as $event_name => $params) {
if (is_string($params)) {
- $this->addListener($event_name, array($subscriber, $params));
+ $this->addListener($event_name, [$subscriber, $params]);
}
elseif (is_string($params[0])) {
- $this->addListener($event_name, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
+ $this->addListener($event_name, [$subscriber, $params[0]], isset($params[1]) ? $params[1] : 0);
}
else {
foreach ($params as $listener) {
- $this->addListener($event_name, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
+ $this->addListener($event_name, [$subscriber, $listener[0]], isset($listener[1]) ? $listener[1] : 0);
}
}
}
@@ -250,11 +250,11 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
foreach ($subscriber->getSubscribedEvents() as $event_name => $params) {
if (is_array($params) && is_array($params[0])) {
foreach ($params as $listener) {
- $this->removeListener($event_name, array($subscriber, $listener[0]));
+ $this->removeListener($event_name, [$subscriber, $listener[0]]);
}
}
else {
- $this->removeListener($event_name, array($subscriber, is_string($params) ? $params : $params[0]));
+ $this->removeListener($event_name, [$subscriber, is_string($params) ? $params : $params[0]]);
}
}
}
diff --git a/core/lib/Drupal/Component/FileSystem/FileSystem.php b/core/lib/Drupal/Component/FileSystem/FileSystem.php
index 26989cdb57f..7a1c551f243 100644
--- a/core/lib/Drupal/Component/FileSystem/FileSystem.php
+++ b/core/lib/Drupal/Component/FileSystem/FileSystem.php
@@ -15,7 +15,7 @@ class FileSystem {
* suitable temporary directory can be found.
*/
public static function getOsTemporaryDirectory() {
- $directories = array();
+ $directories = [];
// Has PHP been set with an upload_tmp_dir?
if (ini_get('upload_tmp_dir')) {
diff --git a/core/lib/Drupal/Component/Gettext/PoHeader.php b/core/lib/Drupal/Component/Gettext/PoHeader.php
index 59223014dd3..806beba008d 100644
--- a/core/lib/Drupal/Component/Gettext/PoHeader.php
+++ b/core/lib/Drupal/Component/Gettext/PoHeader.php
@@ -191,9 +191,9 @@ class PoHeader {
* @throws Exception
*/
function parsePluralForms($pluralforms) {
- $plurals = array();
+ $plurals = [];
// First, delete all whitespace.
- $pluralforms = strtr($pluralforms, array(" " => "", "\t" => ""));
+ $pluralforms = strtr($pluralforms, [" " => "", "\t" => ""]);
// Select the parts that define nplurals and plural.
$nplurals = strstr($pluralforms, "nplurals=");
@@ -215,7 +215,7 @@ class PoHeader {
// If the number of plurals is zero, we return a default result.
if ($nplurals == 0) {
- return array($nplurals, array('default' => 0));
+ return [$nplurals, ['default' => 0]];
}
// Calculate possible plural positions of different plural values. All known
@@ -233,7 +233,7 @@ class PoHeader {
});
$plurals['default'] = $default;
- return array($nplurals, $plurals);
+ return [$nplurals, $plurals];
}
else {
throw new \Exception('The plural formula could not be parsed.');
@@ -250,7 +250,7 @@ class PoHeader {
* An associative array of key-value pairs.
*/
private function parseHeader($header) {
- $header_parsed = array();
+ $header_parsed = [];
$lines = array_map('trim', explode("\n", $header));
foreach ($lines as $line) {
if ($line) {
@@ -275,17 +275,17 @@ class PoHeader {
*/
private function parseArithmetic($string) {
// Operator precedence table.
- $precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
+ $precedence = ["(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8];
// Right associativity.
- $right_associativity = array("?" => 1, ":" => 1);
+ $right_associativity = ["?" => 1, ":" => 1];
$tokens = $this->tokenizeFormula($string);
// Parse by converting into infix notation then back into postfix
// Operator stack - holds math operators and symbols.
- $operator_stack = array();
+ $operator_stack = [];
// Element Stack - holds data to be operated on.
- $element_stack = array();
+ $element_stack = [];
foreach ($tokens as $token) {
$current_token = $token;
@@ -373,7 +373,7 @@ class PoHeader {
*/
private function tokenizeFormula($formula) {
$formula = str_replace(" ", "", $formula);
- $tokens = array();
+ $tokens = [];
for ($i = 0; $i < strlen($formula); $i++) {
if (is_numeric($formula[$i])) {
$num = $formula[$i];
diff --git a/core/lib/Drupal/Component/Gettext/PoItem.php b/core/lib/Drupal/Component/Gettext/PoItem.php
index 6cedff11042..6d76d6c218c 100644
--- a/core/lib/Drupal/Component/Gettext/PoItem.php
+++ b/core/lib/Drupal/Component/Gettext/PoItem.php
@@ -171,7 +171,7 @@ class PoItem {
*
* @param array $values
*/
- public function setFromArray(array $values = array()) {
+ public function setFromArray(array $values = []) {
if (isset($values['context'])) {
$this->setContext($values['context']);
}
diff --git a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php
index 37070cb9b09..c8da6e6d86f 100644
--- a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php
+++ b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php
@@ -18,7 +18,7 @@ class PoMemoryWriter implements PoWriterInterface {
* Constructor, initialize empty items.
*/
function __construct() {
- $this->_items = array();
+ $this->_items = [];
}
/**
diff --git a/core/lib/Drupal/Component/Gettext/PoStreamReader.php b/core/lib/Drupal/Component/Gettext/PoStreamReader.php
index faaa95f91a8..c44f9a1a691 100644
--- a/core/lib/Drupal/Component/Gettext/PoStreamReader.php
+++ b/core/lib/Drupal/Component/Gettext/PoStreamReader.php
@@ -39,7 +39,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
*
* @var array
*/
- private $_current_item = array();
+ private $_current_item = [];
/**
* Current plural index for plural translations.
@@ -261,14 +261,14 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
$this->_line_number++;
// Initialize common values for error logging.
- $log_vars = array(
+ $log_vars = [
'%uri' => $this->getURI(),
'%line' => $this->_line_number,
- );
+ ];
// Trim away the linefeed. \\n might appear at the end of the string if
// another line continuing the same string follows. We can remove that.
- $line = trim(strtr($line, array("\\\n" => "")));
+ $line = trim(strtr($line, ["\\\n" => ""]));
if (!strncmp('#', $line, 1)) {
// Lines starting with '#' are comments.
@@ -282,7 +282,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
$this->setItemFromArray($this->_current_item);
// Start a new entry for the comment.
- $this->_current_item = array();
+ $this->_current_item = [];
$this->_current_item['#'][] = substr($line, 1);
$this->_context = 'COMMENT';
@@ -319,7 +319,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
if (is_string($this->_current_item['msgid'])) {
// The first value was stored as string. Now we know the context is
// plural, it is converted to array.
- $this->_current_item['msgid'] = array($this->_current_item['msgid']);
+ $this->_current_item['msgid'] = [$this->_current_item['msgid']];
}
$this->_current_item['msgid'][] = $quoted;
@@ -334,7 +334,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
$this->setItemFromArray($this->_current_item);
// Start a new context for the msgid.
- $this->_current_item = array();
+ $this->_current_item = [];
}
elseif ($this->_context == 'MSGID') {
// We are currently already in the context, meaning we passed an id with no data.
@@ -363,7 +363,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
// We are currently in string context, save current item.
$this->setItemFromArray($this->_current_item);
- $this->_current_item = array();
+ $this->_current_item = [];
}
elseif (!empty($this->_current_item['msgctxt'])) {
// A context cannot apply to another context.
@@ -421,7 +421,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
return FALSE;
}
if (!isset($this->_current_item['msgstr']) || !is_array($this->_current_item['msgstr'])) {
- $this->_current_item['msgstr'] = array();
+ $this->_current_item['msgstr'] = [];
}
$this->_current_item['msgstr'][$this->_current_plural_index] = $quoted;
@@ -500,7 +500,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
// Empty line read or EOF of PO stream, close out the last entry.
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
$this->setItemFromArray($this->_current_item);
- $this->_current_item = array();
+ $this->_current_item = [];
}
elseif ($this->_context != 'COMMENT') {
$this->_errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
diff --git a/core/lib/Drupal/Component/Graph/Graph.php b/core/lib/Drupal/Component/Graph/Graph.php
index 5d8d5caf878..b155faa6625 100644
--- a/core/lib/Drupal/Component/Graph/Graph.php
+++ b/core/lib/Drupal/Component/Graph/Graph.php
@@ -56,13 +56,13 @@ class Graph {
* identifier.
*/
public function searchAndSort() {
- $state = array(
+ $state = [
// The order of last visit of the depth first search. This is the reverse
// of the topological order if the graph is acyclic.
- 'last_visit_order' => array(),
+ 'last_visit_order' => [],
// The components of the graph.
- 'components' => array(),
- );
+ 'components' => [],
+ ];
// Perform the actual search.
foreach ($this->graph as $start => $data) {
$this->depthFirstSearch($state, $start);
@@ -71,7 +71,7 @@ class Graph {
// We do such a numbering that every component starts with 0. This is useful
// for module installs as we can install every 0 weighted module in one
// request, and then every 1 weighted etc.
- $component_weights = array();
+ $component_weights = [];
foreach ($state['last_visit_order'] as $vertex) {
$component = $this->graph[$vertex]['component'];
@@ -108,7 +108,7 @@ class Graph {
return;
}
// Mark $start as visited.
- $this->graph[$start]['paths'] = array();
+ $this->graph[$start]['paths'] = [];
// Assign $start to the current component.
$this->graph[$start]['component'] = $component;
diff --git a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php
index 5dc159ff576..5795638a373 100644
--- a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php
+++ b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php
@@ -83,7 +83,7 @@ class FileReadOnlyStorage implements PhpStorageInterface {
* {@inheritdoc}
*/
public function listAll() {
- $names = array();
+ $names = [];
if (file_exists($this->directory)) {
foreach (new \DirectoryIterator($this->directory) as $fileinfo) {
if (!$fileinfo->isDot()) {
diff --git a/core/lib/Drupal/Component/PhpStorage/FileStorage.php b/core/lib/Drupal/Component/PhpStorage/FileStorage.php
index f23c0c0671d..e82ec2d6dd8 100644
--- a/core/lib/Drupal/Component/PhpStorage/FileStorage.php
+++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php
@@ -238,7 +238,7 @@ EOF;
* {@inheritdoc}
*/
public function listAll() {
- $names = array();
+ $names = [];
if (file_exists($this->directory)) {
foreach (new \DirectoryIterator($this->directory) as $fileinfo) {
if (!$fileinfo->isDot()) {
diff --git a/core/lib/Drupal/Component/Plugin/Context/Context.php b/core/lib/Drupal/Component/Plugin/Context/Context.php
index 3713d48097e..8a225d4a4a8 100644
--- a/core/lib/Drupal/Component/Plugin/Context/Context.php
+++ b/core/lib/Drupal/Component/Plugin/Context/Context.php
@@ -79,7 +79,7 @@ class Context implements ContextInterface {
if (empty($this->contextDefinition['class'])) {
throw new ContextException("An error was encountered while trying to validate the context.");
}
- return array(new Type($this->contextDefinition['class']));
+ return [new Type($this->contextDefinition['class'])];
}
/**
diff --git a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php
index 96318ac79aa..b9f6e02217a 100644
--- a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php
+++ b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php
@@ -67,7 +67,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
*/
public function getContextDefinitions() {
$definition = $this->getPluginDefinition();
- return !empty($definition['context']) ? $definition['context'] : array();
+ return !empty($definition['context']) ? $definition['context'] : [];
}
/**
@@ -114,7 +114,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
* {@inheritdoc}
*/
public function getContextValues() {
- $values = array();
+ $values = [];
foreach ($this->getContextDefinitions() as $name => $definition) {
$values[$name] = isset($this->context[$name]) ? $this->context[$name]->getContextValue() : NULL;
}
diff --git a/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php b/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php
index 0c97c6df0fe..f49ab9920c9 100644
--- a/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php
+++ b/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php
@@ -12,7 +12,7 @@ abstract class DeriverBase implements DeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
index 0cee17055fd..6b47af01717 100644
--- a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
+++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
@@ -21,7 +21,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
* @var \Drupal\Component\Plugin\Derivative\DeriverInterface[]
* Keys are base plugin IDs.
*/
- protected $derivers = array();
+ protected $derivers = [];
/**
* The decorated plugin discovery.
@@ -94,7 +94,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
* DiscoveryInterface::getDefinitions().
*/
protected function getDerivatives(array $base_plugin_definitions) {
- $plugin_definitions = array();
+ $plugin_definitions = [];
foreach ($base_plugin_definitions as $base_plugin_id => $plugin_definition) {
$deriver = $this->getDeriver($base_plugin_id, $plugin_definition);
if ($deriver) {
@@ -137,7 +137,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
return explode(':', $plugin_id, 2);
}
- return array($plugin_id, NULL);
+ return [$plugin_id, NULL];
}
/**
@@ -239,7 +239,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
// Use this definition as defaults if a plugin already defined itself as
// this derivative, but filter out empty values first.
$filtered_base = array_filter($base_plugin_definition);
- $derivative_definition = $filtered_base + ($derivative_definition ?: array());
+ $derivative_definition = $filtered_base + ($derivative_definition ?: []);
// Add back any empty keys that the derivative didn't have.
return $derivative_definition + $base_plugin_definition;
}
@@ -248,7 +248,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
* Passes through all unknown calls onto the decorated object.
*/
public function __call($method, $args) {
- return call_user_func_array(array($this->decorated, $method), $args);
+ return call_user_func_array([$this->decorated, $method], $args);
}
}
diff --git a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php
index f7ee6718a8a..281860254dd 100644
--- a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php
+++ b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php
@@ -15,7 +15,7 @@ class StaticDiscovery implements DiscoveryInterface {
*/
public function getDefinitions() {
if (!$this->definitions) {
- $this->definitions = array();
+ $this->definitions = [];
}
return $this->definitions;
}
diff --git a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php
index 889d146b92d..968dcb9e355 100644
--- a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php
+++ b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php
@@ -61,7 +61,7 @@ class StaticDiscoveryDecorator extends StaticDiscovery {
* Passes through all unknown calls onto the decorated object
*/
public function __call($method, $args) {
- return call_user_func_array(array($this->decorated, $method), $args);
+ return call_user_func_array([$this->decorated, $method], $args);
}
}
diff --git a/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php b/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php
index 2cca811f884..1f203fb2073 100644
--- a/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php
+++ b/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php
@@ -49,7 +49,7 @@ class DefaultFactory implements FactoryInterface {
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
return new $plugin_class($configuration, $plugin_id, $plugin_definition);
diff --git a/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php b/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php
index f1d07ff7d74..8cf046b9c0d 100644
--- a/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php
+++ b/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php
@@ -21,6 +21,6 @@ interface FactoryInterface {
* @throws \Drupal\Component\Plugin\Exception\PluginException
* If the instance cannot be created, such as if the ID is invalid.
*/
- public function createInstance($plugin_id, array $configuration = array());
+ public function createInstance($plugin_id, array $configuration = []);
}
diff --git a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php
index 9954422d295..8a42ce3d2a5 100644
--- a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php
+++ b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php
@@ -13,7 +13,7 @@ class ReflectionFactory extends DefaultFactory {
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
@@ -51,7 +51,7 @@ class ReflectionFactory extends DefaultFactory {
*/
protected function getInstanceArguments(\ReflectionClass $reflector, $plugin_id, $plugin_definition, array $configuration) {
- $arguments = array();
+ $arguments = [];
foreach ($reflector->getMethod('__construct')->getParameters() as $param) {
$param_name = $param->getName();
diff --git a/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php b/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php
index 7af6c8affcc..0a85e67e118 100644
--- a/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php
+++ b/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php
@@ -18,6 +18,6 @@ interface FallbackPluginManagerInterface {
* @return string
* The id of an existing plugin to use when the plugin does not exist.
*/
- public function getFallbackPluginId($plugin_id, array $configuration = array());
+ public function getFallbackPluginId($plugin_id, array $configuration = []);
}
diff --git a/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php b/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php
index 1d90af79d10..b55b04e954a 100644
--- a/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php
+++ b/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php
@@ -14,14 +14,14 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable {
*
* @var array
*/
- protected $pluginInstances = array();
+ protected $pluginInstances = [];
/**
* Stores the IDs of all potential plugin instances.
*
* @var array
*/
- protected $instanceIDs = array();
+ protected $instanceIDs = [];
/**
* Initializes and stores a plugin.
@@ -53,7 +53,7 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable {
* Clears all instantiated plugins.
*/
public function clear() {
- $this->pluginInstances = array();
+ $this->pluginInstances = [];
}
/**
diff --git a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php
index 5fb32a2a6ae..34416ff4371 100644
--- a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php
+++ b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php
@@ -68,7 +68,7 @@ abstract class PluginManagerBase implements PluginManagerInterface {
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
// If this PluginManager has fallback capabilities catch
// PluginNotFoundExceptions.
if ($this instanceof FallbackPluginManagerInterface) {
diff --git a/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php b/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php
index c20168df047..3cd8d685650 100644
--- a/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php
+++ b/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php
@@ -44,7 +44,7 @@ class PhpTransliteration implements TransliterationInterface {
*
* @var array
*/
- protected $languageOverrides = array();
+ protected $languageOverrides = [];
/**
* Non-language-specific transliteration tables.
@@ -56,7 +56,7 @@ class PhpTransliteration implements TransliterationInterface {
*
* @var array
*/
- protected $genericMap = array();
+ protected $genericMap = [];
/**
* Constructs a transliteration object.
@@ -83,9 +83,9 @@ class PhpTransliteration implements TransliterationInterface {
// few characters that aren't accented letters mixed in. So define the
// ranges and the excluded characters.
$range1 = $code > 0x00bf && $code < 0x017f;
- $exclusions_range1 = array(0x00d0, 0x00d7, 0x00f0, 0x00f7, 0x0138, 0x014a, 0x014b);
+ $exclusions_range1 = [0x00d0, 0x00d7, 0x00f0, 0x00f7, 0x0138, 0x014a, 0x014b];
$range2 = $code > 0x01cc && $code < 0x0250;
- $exclusions_range2 = array(0x01DD, 0x01f7, 0x021c, 0x021d, 0x0220, 0x0221, 0x0241, 0x0242, 0x0245);
+ $exclusions_range2 = [0x01DD, 0x01f7, 0x021c, 0x021d, 0x0220, 0x0221, 0x0241, 0x0242, 0x0245];
$replacement = $character;
if (($range1 && !in_array($code, $exclusions_range1)) || ($range2 && !in_array($code, $exclusions_range2))) {
@@ -246,7 +246,7 @@ class PhpTransliteration implements TransliterationInterface {
include $file;
}
if (!isset($overrides) || !is_array($overrides)) {
- $overrides = array($langcode => array());
+ $overrides = [$langcode => []];
}
$this->languageOverrides[$langcode] = $overrides[$langcode];
}
@@ -274,7 +274,7 @@ class PhpTransliteration implements TransliterationInterface {
include $file;
}
if (!isset($base) || !is_array($base)) {
- $base = array();
+ $base = [];
}
// Save this data.
diff --git a/core/lib/Drupal/Component/Transliteration/data/de.php b/core/lib/Drupal/Component/Transliteration/data/de.php
index a0b7e78a28a..49a08c51994 100644
--- a/core/lib/Drupal/Component/Transliteration/data/de.php
+++ b/core/lib/Drupal/Component/Transliteration/data/de.php
@@ -5,11 +5,11 @@
* German transliteration data for the PhpTransliteration class.
*/
-$overrides['de'] = array(
+$overrides['de'] = [
0xC4 => 'Ae',
0xD6 => 'Oe',
0xDC => 'Ue',
0xE4 => 'ae',
0xF6 => 'oe',
0xFC => 'ue',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/dk.php b/core/lib/Drupal/Component/Transliteration/data/dk.php
index 4a3056a5730..e46b013fd61 100644
--- a/core/lib/Drupal/Component/Transliteration/data/dk.php
+++ b/core/lib/Drupal/Component/Transliteration/data/dk.php
@@ -5,9 +5,9 @@
* Danish transliteration data for the PhpTransliteration class.
*/
-$overrides['dk'] = array(
+$overrides['dk'] = [
0xC5 => 'Aa',
0xD8 => 'Oe',
0xE5 => 'aa',
0xF8 => 'oe',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/eo.php b/core/lib/Drupal/Component/Transliteration/data/eo.php
index 565af1902fe..e115866b526 100644
--- a/core/lib/Drupal/Component/Transliteration/data/eo.php
+++ b/core/lib/Drupal/Component/Transliteration/data/eo.php
@@ -5,7 +5,7 @@
* Esperanto transliteration data for the PhpTransliteration class.
*/
-$overrides['eo'] = array(
+$overrides['eo'] = [
0x18 => 'Cx',
0x19 => 'cx',
0x11C => 'Gx',
@@ -18,4 +18,4 @@ $overrides['eo'] = array(
0x15D => 'sx',
0x16C => 'Ux',
0x16D => 'ux',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/kg.php b/core/lib/Drupal/Component/Transliteration/data/kg.php
index 1f8ad0596d4..549f075cec7 100644
--- a/core/lib/Drupal/Component/Transliteration/data/kg.php
+++ b/core/lib/Drupal/Component/Transliteration/data/kg.php
@@ -5,7 +5,7 @@
* Kyrgyz transliteration data for the PhpTransliteration class.
*/
-$overrides['kg'] = array(
+$overrides['kg'] = [
0x41 => 'E',
0x416 => 'C',
0x419 => 'J',
@@ -28,4 +28,4 @@ $overrides['kg'] = array(
0x4AF => 'w',
0x4E8 => 'Q',
0x4E9 => 'q',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x00.php b/core/lib/Drupal/Component/Transliteration/data/x00.php
index 8685680362a..fd7c3f76ede 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x00.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x00.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
// Note: to save memory plain ASCII mappings have been left out.
0x80 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x90 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
@@ -15,4 +15,4 @@ $base = array(
0xD0 => 'D', 'N', 'O', 'O', 'O', 'O', 'O', '*', 'O', 'U', 'U', 'U', 'U', 'Y', 'TH', 'ss',
0xE0 => 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
0xF0 => 'd', 'n', 'o', 'o', 'o', 'o', 'o', '/', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x01.php b/core/lib/Drupal/Component/Transliteration/data/x01.php
index 535692ac130..a30aaa0e0e4 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x01.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x01.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd',
0x10 => 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g',
0x20 => 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '@', 'A', 'a',
0xE0 => 'A', 'a', 'AE', 'ae', 'G', 'g', 'G', 'g', 'K', 'k', 'O', 'o', 'O', 'o', 'ZH', 'zh',
0xF0 => 'j', 'DZ', 'Dz', 'dz', 'G', 'g', 'HV', 'W', 'N', 'n', 'A', 'a', 'AE', 'ae', 'O', 'o',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x02.php b/core/lib/Drupal/Component/Transliteration/data/x02.php
index b57d54b7bcd..ba942070043 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x02.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x02.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'A', 'a', 'A', 'a', 'E', 'e', 'E', 'e', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o',
0x10 => 'R', 'r', 'R', 'r', 'U', 'u', 'U', 'u', 'S', 's', 'T', 't', 'Y', 'y', 'H', 'h',
0x20 => 'N', 'd', 'OU', 'ou', 'Z', 'z', 'A', 'a', 'E', 'e', 'O', 'o', 'O', 'o', 'O', 'o',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => ':', '.', '`', '\'', '^', 'V', '+', '-', 'V', '.', '@', ',', '~', '"', 'R', 'X',
0xE0 => 'G', 'l', 's', 'x', '?', '', '', '', '', '', '', '', 'V', '=', '"', NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x03.php b/core/lib/Drupal/Component/Transliteration/data/x03.php
index 098428123db..f61602d2eb3 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x03.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x03.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x10 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x20 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'b', 'th', 'Y', 'Y', 'Y', 'ph', 'p', '&', NULL, NULL, 'St', 'st', 'W', 'w', 'Q', 'q',
0xE0 => 'Sp', 'sp', 'Sh', 'sh', 'F', 'f', 'Kh', 'kh', 'H', 'h', 'G', 'g', 'CH', 'ch', 'Ti', 'ti',
0xF0 => 'k', 'r', 's', 'j', 'TH', 'e', NULL, 'S', 's', 'S', 'S', 's', NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x04.php b/core/lib/Drupal/Component/Transliteration/data/x04.php
index a8fee7da73e..1be0d433249 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x04.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x04.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'E', 'E', 'D', 'G', 'E', 'Z', 'I', 'I', 'J', 'L', 'N', 'C', 'K', 'I', 'U', 'D',
0x10 => 'A', 'B', 'V', 'G', 'D', 'E', 'Z', 'Z', 'I', 'I', 'K', 'L', 'M', 'N', 'O', 'P',
0x20 => 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'C', 'S', 'S', '', 'Y', '', 'E', 'U', 'A',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'A', 'a', 'A', 'a', 'AE', 'ae', 'E', 'e', '@', '@', '@', '@', 'Z', 'z', 'Z', 'z',
0xE0 => 'Dz', 'dz', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o', 'O', 'o', 'E', 'e', 'U', 'u',
0xF0 => 'U', 'u', 'U', 'u', 'C', 'c', NULL, NULL, 'Y', 'y', NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x05.php b/core/lib/Drupal/Component/Transliteration/data/x05.php
index 29b523226da..f39fa5b4600 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x05.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x05.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '', 'b', 'g', 'd', 'h', 'w', 'z', 'h', 't', 'y', 'k', 'k', 'l', 'm', 'm', 'n',
0xE0 => 'n', 's', '`', 'p', 'p', 'z', 'z', 'q', 'r', 's', 't', NULL, NULL, NULL, NULL, NULL,
0xF0 => 'ww', 'wy', 'yy', '\'', '"', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x06.php b/core/lib/Drupal/Component/Transliteration/data/x06.php
index 68ea125b705..6999d90c70d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x06.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x06.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ',', NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ';', NULL, NULL, NULL, '?',
0x20 => NULL, '', 'a', 'a', 'w', 'a', 'y', 'a', 'b', 't', 't', 'th', 'j', 'h', 'kh', 'd',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '', '', 'y', 'y\'', '.', 'ae', '', '', '', '', '', '', '', '@', '#', '',
0xE0 => '', '', '', '', '', '', '', '', '', '^', '', '', '', '', NULL, NULL,
0xF0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Sh', 'D', 'Gh', '&', '+m', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x07.php b/core/lib/Drupal/Component/Transliteration/data/x07.php
index c141b66b329..35873139c2d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x07.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x07.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => '//', '/', ',', '!', '!', '-', ',', ',', ';', '?', '~', '{', '}', '*', NULL, '',
0x10 => '\'', '', 'b', 'g', 'g', 'd', 'dr', 'h', 'w', 'z', 'h', 't', 't', 'y', 'yh', 'k',
0x20 => 'l', 'm', 'n', 's', 's', '`', 'p', 'p', 's', 'q', 'r', 'sh', 't', NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x09.php b/core/lib/Drupal/Component/Transliteration/data/x09.php
index 88c28451d6c..6250925d873 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x09.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x09.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'N', 'N', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', 'e', 'e', 'e',
0x10 => 'ai', 'o', 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', 'na', 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, '+', NULL, NULL, NULL, NULL, 'da', 'dha', NULL, 'ya',
0xE0 => 'r', 'l', 'L', 'LL', NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
0xF0 => 'ra', 'ra', 'Rs', 'Rs', '1/', '2/', '3/', '4/', ' 1 - 1/', '/16', '', NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x0a.php b/core/lib/Drupal/Component/Transliteration/data/x0a.php
index 5d14d3f4a8e..0dc613f3647 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x0a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x0a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, 'N', NULL, NULL, 'a', 'a', 'i', 'i', 'u', 'u', NULL, NULL, NULL, NULL, 'e',
0x10 => 'ai', NULL, NULL, 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '\'om', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => 'r', 'l', NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x0b.php b/core/lib/Drupal/Component/Transliteration/data/x0b.php
index e700c6d864b..2f95b1bb0ce 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x0b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x0b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'N', 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, NULL, 'e',
0x10 => 'ai', NULL, NULL, 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, '+', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
0xF0 => '10', '100', '1000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x0c.php b/core/lib/Drupal/Component/Transliteration/data/x0c.php
index 51f7f50b755..1638bfdde05 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x0c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x0c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'm', 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, 'e', 'e',
0x10 => 'ai', NULL, 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, '+', '+', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'la', NULL,
0xE0 => 'r', 'l', NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x0d.php b/core/lib/Drupal/Component/Transliteration/data/x0d.php
index d92a68ce66e..8aa517b743d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x0d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x0d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, 'e', 'e',
0x10 => 'ai', NULL, 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta',
0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ae', 'aae', 'i', 'ii', 'u', NULL, 'uu', NULL, 'R', 'e', 'ee', 'ai', 'o', 'oo', 'au', 'L',
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, 'RR', 'LL', ' . ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x0e.php b/core/lib/Drupal/Component/Transliteration/data/x0e.php
index 03fb5a95885..13a589d904c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x0e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x0e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'k', 'kh', 'kh', 'kh', 'kh', 'kh', 'ng', 'c', 'ch', 'ch', 's', 'ch', 'y', 'd', 't',
0x10 => 'th', 'th', 'th', 'n', 'd', 't', 'th', 'th', 'th', 'n', 'b', 'p', 'ph', 'f', 'ph', 'f',
0x20 => 'ph', 'm', 'y', 'r', 'v', 'l', 'l', 'w', 's', 's', 's', 'h', 'l', 'x', 'h', '~',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, 'hn', 'hm', NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x0f.php b/core/lib/Drupal/Component/Transliteration/data/x0f.php
index addfa7501fe..32262e53a61 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x0f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x0f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'AUM', '', '', '', '', '', '', '', ' // ', ' * ', '', '-', ' / ', ' / ', ' // ', ' -/ ',
0x10 => ' +/ ', ' X/ ', ' /XX/ ', ' /X/ ', ',', '', '', '', '', '', '', '', '', '', '', '',
0x20 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.5', '1.5', '2.5', '3.5', '4.5', '5.5',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x10.php b/core/lib/Drupal/Component/Transliteration/data/x10.php
index 9aedcce80bd..cb1b13dce0f 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x10.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x10.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'k', 'kh', 'g', 'gh', 'ng', 'c', 'ch', 'j', 'jh', 'ny', 'nny', 'tt', 'tth', 'dd', 'ddh', 'nn',
0x10 => 'tt', 'th', 'd', 'dh', 'n', 'p', 'ph', 'b', 'bh', 'm', 'y', 'r', 'l', 'w', 's', 'h',
0x20 => 'll', 'a', NULL, 'i', 'ii', 'u', 'uu', 'e', NULL, 'o', 'au', NULL, 'aa', 'i', 'ii', 'u',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'a', 'b', 'g', 'd', 'e', 'v', 'z', 't', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'zh',
0xE0 => 'r', 's', 't', 'u', 'p', 'k', 'gh', 'q', 'sh', 'ch', 'ts', 'dz', 'c', 'ch', 'kh', 'j',
0xF0 => 'h', 'e', 'y', 'ui', 'q', 'oe', 'f', NULL, NULL, NULL, NULL, ' // ', NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x11.php b/core/lib/Drupal/Component/Transliteration/data/x11.php
index 66d2fe6776f..bf1a13e609e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x11.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x11.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'g', 'kk', 'n', 'd', 'tt', 'l', 'm', 'b', 'pp', 's', 'ss', '', 'j', 'jj', 'ch', 'k',
0x10 => 't', 'p', 'h', 'ng', 'nn', 'nd', 'nb', 'dg', 'rn', 'rr', 'rh', 'rN', 'mb', 'mN', 'bg', 'bn',
0x20 => '', 'bs', 'bsg', 'bst', 'bsb', 'bss', 'bsj', 'bj', 'bc', 'bt', 'bp', 'bN', 'bbN', 'sg', 'sn', 'sd',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'll', 'lmg', 'lms', 'lbs', 'lbh', 'rNp', 'lss', 'lZ', 'lk', 'lQ', 'mg', 'ml', 'mb', 'ms', 'mss', 'mZ',
0xE0 => 'mc', 'mh', 'mN', 'bl', 'bp', 'ph', 'pN', 'sg', 'sd', 'sl', 'sb', 'Z', 'g', 'ss', '', 'kh',
0xF0 => 'N', 'Ns', 'NZ', 'pb', 'pN', 'hn', 'hl', 'hm', 'hb', 'Q', NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x12.php b/core/lib/Drupal/Component/Transliteration/data/x12.php
index 1248209ef9e..43fdd369aac 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x12.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x12.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ha', 'hu', 'hi', 'haa', 'hee', 'he', 'ho', NULL, 'la', 'lu', 'li', 'laa', 'lee', 'le', 'lo', 'lwa',
0x10 => 'hha', 'hhu', 'hhi', 'hhaa', 'hhee', 'hhe', 'hho', 'hhwa', 'ma', 'mu', 'mi', 'maa', 'mee', 'me', 'mo', 'mwa',
0x20 => 'sza', 'szu', 'szi', 'szaa', 'szee', 'sze', 'szo', 'szwa', 'ra', 'ru', 'ri', 'raa', 'ree', 're', 'ro', 'rwa',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '`a', '`u', '`i', '`aa', '`ee', '`e', '`o', NULL, 'za', 'zu', 'zi', 'zaa', 'zee', 'ze', 'zo', 'zwa',
0xE0 => 'zha', 'zhu', 'zhi', 'zhaa', 'zhee', 'zhe', 'zho', 'zhwa', 'ya', 'yu', 'yi', 'yaa', 'yee', 'ye', 'yo', NULL,
0xF0 => 'da', 'du', 'di', 'daa', 'dee', 'de', 'do', 'dwa', 'dda', 'ddu', 'ddi', 'ddaa', 'ddee', 'dde', 'ddo', 'ddwa',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x13.php b/core/lib/Drupal/Component/Transliteration/data/x13.php
index 73976a8e941..a6a593605a6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x13.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x13.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ja', 'ju', 'ji', 'jaa', 'jee', 'je', 'jo', 'jwa', 'ga', 'gu', 'gi', 'gaa', 'gee', 'ge', 'go', NULL,
0x10 => 'gwa', NULL, 'gwi', 'gwaa', 'gwee', 'gwe', NULL, NULL, 'gga', 'ggu', 'ggi', 'ggaa', 'ggee', 'gge', 'ggo', NULL,
0x20 => 'tha', 'thu', 'thi', 'thaa', 'thee', 'the', 'tho', 'thwa', 'cha', 'chu', 'chi', 'chaa', 'chee', 'che', 'cho', 'chwa',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'so', 'su', 'sv', 'da', 'ta', 'de', 'te', 'di', 'ti', 'do', 'du', 'dv', 'dla', 'tla', 'tle', 'tli',
0xE0 => 'tlo', 'tlu', 'tlv', 'tsa', 'tse', 'tsi', 'tso', 'tsu', 'tsv', 'wa', 'we', 'wi', 'wo', 'wu', 'wv', 'ya',
0xF0 => 'ye', 'yi', 'yo', 'yu', 'yv', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x14.php b/core/lib/Drupal/Component/Transliteration/data/x14.php
index 8b4995e5777..e752a070285 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x14.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x14.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'ai', 'aai', 'i', 'ii', 'u', 'uu', 'oo', 'ee', 'i', 'a', 'aa', 'we', 'we', 'wi', 'wi',
0x10 => 'wii', 'wii', 'wo', 'wo', 'woo', 'woo', 'woo', 'wa', 'wa', 'waa', 'waa', 'waa', 'ai', 'w', '\'', 't',
0x20 => 'k', 'sh', 's', 'n', 'w', 'n', NULL, 'w', 'c', '?', 'l', 'en', 'in', 'on', 'an', 'pai',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'n', 'ng', 'nh', 'lai', 'laai', 'li', 'lii', 'lu', 'luu', 'loo', 'la', 'laa', 'lwe', 'lwe', 'lwi', 'lwi',
0xE0 => 'lwii', 'lwii', 'lwo', 'lwo', 'lwoo', 'lwoo', 'lwa', 'lwa', 'lwaa', 'lwaa', 'l', 'l', 'l', 'sai', 'saai', 'si',
0xF0 => 'sii', 'su', 'suu', 'soo', 'sa', 'saa', 'swe', 'swe', 'swi', 'swi', 'swii', 'swii', 'swo', 'swo', 'swoo', 'swoo',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x15.php b/core/lib/Drupal/Component/Transliteration/data/x15.php
index e40fc68b46d..426578393f6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x15.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x15.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'swa', 'swa', 'swaa', 'swaa', 'swaa', 's', 's', 'sw', 's', 'sk', 'skw', 'sW', 'spwa', 'stwa', 'skwa', 'scwa',
0x10 => 'she', 'shi', 'shii', 'sho', 'shoo', 'sha', 'shaa', 'shwe', 'shwe', 'shwi', 'shwi', 'shwii', 'shwii', 'shwo', 'shwo', 'shwoo',
0x20 => 'shwoo', 'shwa', 'shwa', 'shwaa', 'shwaa', 'sh', 'jai', 'yaai', 'ji', 'jii', 'ju', 'juu', 'yoo', 'ja', 'jaa', 'ywe',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'wu', 'wo', 'we', 'wee', 'wi', 'wa', 'hwu', 'hwo', 'hwe', 'hwee', 'hwi', 'hwa', 'thu', 'tho', 'the', 'thee',
0xE0 => 'thi', 'tha', 'ttu', 'tto', 'tte', 'ttee', 'tti', 'tta', 'pu', 'po', 'pe', 'pee', 'pi', 'pa', 'p', 'gu',
0xF0 => 'go', 'ge', 'gee', 'gi', 'ga', 'khu', 'kho', 'khe', 'khee', 'khi', 'kha', 'kku', 'kko', 'kke', 'kkee', 'kki',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x16.php b/core/lib/Drupal/Component/Transliteration/data/x16.php
index 9d977475dd7..dbb3d60b365 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x16.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x16.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'kka', 'kk', 'nu', 'no', 'ne', 'nee', 'ni', 'na', 'mu', 'mo', 'me', 'mee', 'mi', 'ma', 'yu', 'yo',
0x10 => 'ye', 'yee', 'yi', 'ya', 'ju', 'ju', 'jo', 'je', 'jee', 'ji', 'ji', 'ja', 'jju', 'jjo', 'jje', 'jjee',
0x20 => 'jji', 'jja', 'lu', 'lo', 'le', 'lee', 'li', 'la', 'dlu', 'dlo', 'dle', 'dlee', 'dli', 'dla', 'lhu', 'lho',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 't', 'd', 'b', 'b', 'p', 'p', 'e', 'm', 'm', 'm', 'l', 'l', 'ng', 'ng', 'd', 'o',
0xE0 => 'ear', 'ior', 'qu', 'qu', 'qu', 's', 'yr', 'yr', 'yr', 'q', 'x', '.', ':', '+', '17', '18',
0xF0 => '19', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x17.php b/core/lib/Drupal/Component/Transliteration/data/x17.php
index f98d03a7d8f..f08a09d65d6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x17.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x17.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '', '', '', '', '.', ' // ', ':', '+', '++', ' * ', ' /// ', 'KR', '\'', NULL, NULL, NULL,
0xE0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x18.php b/core/lib/Drupal/Component/Transliteration/data/x18.php
index 05c85a49731..b46d30df8b2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x18.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x18.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => ' @ ', ' ... ', ',', '. ', ': ', ' // ', '', '-', ',', '. ', '', '', '', '', '', NULL,
0x10 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => 'a', 'e', 'i', 'o', 'u', 'O', 'U', 'ee', 'n', 'ng', 'b', 'p', 'q', 'g', 'm', 'l',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x1d.php b/core/lib/Drupal/Component/Transliteration/data/x1d.php
index ab6b5d4cf52..1d6bacfd6ef 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x1d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x1d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'A', 'AE', NULL, 'B', 'C', 'D', 'D', 'E', NULL, NULL, 'J', 'K', 'L', 'M', NULL, 'O',
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'P', NULL, NULL, 'T', 'U', NULL, NULL, NULL,
0x20 => 'V', 'W', 'Z', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x1e.php b/core/lib/Drupal/Component/Transliteration/data/x1e.php
index 71b45bb9c66..592deec3360 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x1e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x1e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'A', 'a', 'B', 'b', 'B', 'b', 'B', 'b', 'C', 'c', 'D', 'd', 'D', 'd', 'D', 'd',
0x10 => 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'F', 'f',
0x20 => 'G', 'g', 'H', 'h', 'H', 'h', 'H', 'h', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o',
0xE0 => 'O', 'o', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u',
0xF0 => 'U', 'u', 'Y', 'y', 'Y', 'y', 'Y', 'y', 'Y', 'y', 'LL', 'll', 'V', 'v', 'Y', 'y',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x1f.php b/core/lib/Drupal/Component/Transliteration/data/x1f.php
index 9e0a60ebf8a..33fa4bcf0ba 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x1f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x1f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
0x10 => 'e', 'e', 'e', 'e', 'e', 'e', NULL, NULL, 'E', 'E', 'E', 'E', 'E', 'E', NULL, NULL,
0x20 => 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'i', 'i', 'i', 'i', NULL, NULL, 'i', 'i', 'I', 'I', 'I', 'I', NULL, '`\'', '`\'', '`~',
0xE0 => 'y', 'y', 'y', 'y', 'r', 'r', 'y', 'y', 'Y', 'Y', 'Y', 'Y', 'R', '"`', '"\'', '`',
0xF0 => NULL, NULL, 'o', 'o', 'o', NULL, 'o', 'o', 'O', 'O', 'O', 'O', 'O', '\'', '`', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x20.php b/core/lib/Drupal/Component/Transliteration/data/x20.php
index e1069537a5f..a556d497eeb 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x20.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x20.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', '', '',
0x10 => '-', '-', '-', '-', '-', '-', '||', '_', '\'', '\'', ',', '\'', '"', '"', ',,', '"',
0x20 => '+', '++', '*', '*>', '.', '..', '...', '.', '
@@ -25,4 +25,4 @@ $base = array(
0xD0 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0xE0 => '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x21.php b/core/lib/Drupal/Component/Transliteration/data/x21.php
index 1da0f418f49..44645a92b47 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x21.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x21.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'a/c', 'a/s', 'C', '', '', 'c/o', 'c/u', '', '', '', 'g', 'H', 'x', 'H', 'h', '',
0x10 => 'I', 'I', 'L', 'l', 'lb', 'N', 'No', '(p)', 'P', 'P', 'Q', 'R', 'R', 'R', 'Rx', '',
0x20 => '(sm)', 'TEL', '(tm)', '', 'Z', '', 'O', 'mho', 'Z', '', 'K', 'A', 'B', 'C', 'e', 'e',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '=', '|', '=', '|', '=', '|', '\\', '/', '\\', '/', '=', '=', '~', '~', '|', '|',
0xE0 => '-', '|', '-', '|', '-', '-', '-', '|', '-', '|', '|', '|', '|', '|', '|', '|',
0xF0 => '-', '\\', '\\', '|', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x22.php b/core/lib/Drupal/Component/Transliteration/data/x22.php
index e346ffbbe99..fa289784e85 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x22.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x22.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, '-', NULL, NULL, '/', '\\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => NULL, NULL, NULL, '|', '|', '||', '||', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x23.php b/core/lib/Drupal/Component/Transliteration/data/x23.php
index 3cef84f96e5..e38c438e528 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x23.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x23.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '<', '>', NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x24.php b/core/lib/Drupal/Component/Transliteration/data/x24.php
index 3e7b33bffb8..17ffeee58e9 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x24.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x24.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x10 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x20 => '', '', '', '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0xE0 => '', '', '', '', '', '', '', '', '', '', '', NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x25.php b/core/lib/Drupal/Component/Transliteration/data/x25.php
index 786bfceaa55..b24b056ade0 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x25.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x25.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => '-', '-', '|', '|', '-', '-', '|', '|', '-', '-', '|', '|', '+', '+', '+', '+',
0x10 => '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+',
0x20 => '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*',
0xE0 => '*', '*', '*', '*', '*', '*', '*', '#', '#', '#', '#', '#', '^', '^', '^', 'O',
0xF0 => '#', '#', '#', '#', '#', '#', '#', '#', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x26.php b/core/lib/Drupal/Component/Transliteration/data/x26.php
index c7dc4069486..3ef34ee6586 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x26.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x26.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x10 => '', '', '', '', NULL, NULL, NULL, NULL, NULL, '', '', '', '', '', '', '',
0x20 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x27.php b/core/lib/Drupal/Component/Transliteration/data/x27.php
index 9c001d28333..f067a78b975 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x27.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x27.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x10 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
0x20 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x28.php b/core/lib/Drupal/Component/Transliteration/data/x28.php
index 456f8e41c22..ce1789d4f9c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x28.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x28.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => ' ', 'a', '1', 'b', '\'', 'k', '2', 'l', '@', 'c', 'i', 'f', '/', 'm', 's', 'p',
0x10 => '"', 'e', '3', 'h', '9', 'o', '6', 'r', '^', 'd', 'j', 'g', '>', 'n', 't', 'q',
0x20 => ',', '*', '5', '<', '-', 'u', '8', 'v', '.', '%', '[', '$', '+', 'x', '!', '&',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => '[d578]', '[d1578]', '[d2578]', '[d12578]', '[d3578]', '[d13578]', '[d23578]', '[d123578]', '[d4578]', '[d14578]', '[d24578]', '[d124578]', '[d34578]', '[d134578]', '[d234578]', '[d1234578]',
0xE0 => '[d678]', '[d1678]', '[d2678]', '[d12678]', '[d3678]', '[d13678]', '[d23678]', '[d123678]', '[d4678]', '[d14678]', '[d24678]', '[d124678]', '[d34678]', '[d134678]', '[d234678]', '[d1234678]',
0xF0 => '[d5678]', '[d15678]', '[d25678]', '[d125678]', '[d35678]', '[d135678]', '[d235678]', '[d1235678]', '[d45678]', '[d145678]', '[d245678]', '[d1245678]', '[d345678]', '[d1345678]', '[d2345678]', '[d12345678]',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x29.php b/core/lib/Drupal/Component/Transliteration/data/x29.php
index 98390e61a49..cd18ef9505d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x29.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x29.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x2a.php b/core/lib/Drupal/Component/Transliteration/data/x2a.php
index 93349c59461..24013a35d1b 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x2a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x2a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x2e.php b/core/lib/Drupal/Component/Transliteration/data/x2e.php
index f9b3b3333d0..e62f56a1dea 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x2e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x2e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jin', 'chang', 'chang', 'zhang', 'men', NULL, 'fu', 'yu', 'qing', 'wei', 'ye', 'feng', 'fei', 'shi', NULL, 'shi',
0xE0 => 'shi', NULL, 'ma', 'gu', 'gui', 'yu', 'niao', 'lu', 'mai', 'huang', 'mian', 'qi', 'qi', 'chi', 'chi', 'long',
0xF0 => 'long', 'gui', 'gui', 'gui', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x2f.php b/core/lib/Drupal/Component/Transliteration/data/x2f.php
index a5e702928d2..ecf6f0b4cf5 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x2f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x2f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yi', 'gun', 'zhu', 'pie', 'yi', 'jue', 'er', 'tou', 'ren', 'er', 'ru', 'ba', 'jiong', 'mi', 'bing', 'ji',
0x10 => 'qian', 'dao', 'li', 'bao', 'bi', 'fang', 'xi', 'shi', 'bo', 'jie', 'chang', 'si', 'you', 'kou', 'wei', 'tu',
0x20 => 'shi', 'zhi', 'sui', 'xi', 'da', 'nu', 'zi', 'mian', 'cun', 'xiao', 'you', 'shi', 'che', 'shan', 'chuan', 'gong',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'bi', 'qi', 'chi', 'long', 'gui', 'yue', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x30.php b/core/lib/Drupal/Component/Transliteration/data/x30.php
index c92c0a6518f..3fe856787ba 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x30.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x30.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => ' ', ',', '.', '"', '[JIS]', '"', '/', 'ling', '<', '>', '<<', '>>', '[', '] ', '{', '} ',
0x10 => '[(', ')] ', '@', 'X ', '[', ']', '[[', ']] ', '[', ']', '[', ']', '~ ', '"', '"', ',,',
0x20 => '@', '1', '2', '3', '4', '5', '6', '7', '8', '9', '', '', '', '', '', '',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ha', 'ha', 'hi', 'hi', 'hi', 'fu', 'fu', 'fu', 'he', 'he', 'he', 'ho', 'ho', 'ho', 'ma', 'mi',
0xE0 => 'mu', 'me', 'mo', '~ya', 'ya', '~yu', 'yu', '~yo', 'yo', 'ra', 'ri', 'ru', 're', 'ro', '~wa', 'wa',
0xF0 => 'wi', 'we', 'wo', 'n', 'u', '~ka', '~ke', 'wa', 'wi', 'we', 'wo', '', '', '"', '"', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x31.php b/core/lib/Drupal/Component/Transliteration/data/x31.php
index 95b59f4a2ef..59ceddec645 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x31.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x31.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, 'b', 'p', 'm1', 'f', 'd', 't', 'n1', 'l', 'g', 'k', 'h',
0x10 => 'j', 'q', 'x', 'zhi1', 'chi1', 'shi1', 'ri1', 'zi1', 'ci1', 'si1', 'a1', 'o1', 'e1', 'eh1', 'ai1', 'ei1',
0x20 => 'ao1', 'ou1', 'an1', 'en1', 'ang1', 'eng1', 'er1', 'yi1', 'wu1', 'yu1', 'V', 'NG', 'GN', NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x32.php b/core/lib/Drupal/Component/Transliteration/data/x32.php
index 25cc5f3e690..20ffe76659e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x32.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x32.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => '(g)', '(n)', '(d)', '(l)', '(m)', '(b)', '(s)', '()', '(j)', '(ch)', '(k)', '(t)', '(p)', '(h)', '(ga)', '(na)',
0x10 => '(da)', '(la)', '(ma)', '(ba)', '(sa)', '(a)', '(ja)', '(cha)', '(ka)', '(ta)', '(pa)', '(ha)', '(ju)', NULL, NULL, NULL,
0x20 => '(1) ', '(2) ', '(3) ', '(4) ', '(5) ', '(6) ', '(7) ', '(8) ', '(9) ', '(10) ', '(Yue) ', '(Huo) ', '(Shui) ', '(Mu) ', '(Jin) ', '(Tu) ',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'a', 'i', 'u', 'u', 'o', 'ka', 'ki', 'ku', 'ke', 'ko', 'sa', 'si', 'su', 'se', 'so', 'ta',
0xE0 => 'ti', 'tu', 'te', 'to', 'na', 'ni', 'nu', 'ne', 'no', 'ha', 'hi', 'hu', 'he', 'ho', 'ma', 'mi',
0xF0 => 'mu', 'me', 'mo', 'ya', 'yu', 'yo', 'ra', 'ri', 'ru', 're', 'ro', 'wa', 'wi', 'we', 'wo', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x33.php b/core/lib/Drupal/Component/Transliteration/data/x33.php
index 8094290fc75..9eae1281329 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x33.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x33.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'apartment', 'alpha', 'ampere', 'are', 'inning', 'inch', 'won', 'escudo', 'acre', 'ounce', 'ohm', 'kai-ri', 'carat', 'calorie', 'gallon', 'gamma',
0x10 => 'giga', 'guinea', 'curie', 'guilder', 'kilo', 'kilogram', 'kilometer', 'kilowatt', 'gram', 'gram ton', 'cruzeiro', 'krone', 'case', 'koruna', 'co-op', 'cycle',
0x20 => 'centime', 'shilling', 'centi', 'cent', 'dozen', 'desi', 'dollar', 'ton', 'nano', 'knot', 'heights', 'percent', 'parts', 'barrel', 'piaster', 'picul',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lm', 'ln', 'log', 'lx', 'mb', 'mil', 'mol', 'pH', 'p.m.', 'PPM', 'PR', 'sr', 'Sv', 'Wb', 'V/m', 'A/m',
0xE0 => '1d', '2d', '3d', '4d', '5d', '6d', '7d', '8d', '9d', '10d', '11d', '12d', '13d', '14d', '15d', '16d',
0xF0 => '17d', '18d', '19d', '20d', '21d', '22d', '23d', '24d', '25d', '26d', '27d', '28d', '29d', '30d', '31d', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x34.php b/core/lib/Drupal/Component/Transliteration/data/x34.php
index 1281649f17e..ef4dcea4327 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x34.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x34.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'qiu', 'tian', NULL, NULL, 'kua', 'wu', 'yin', NULL, NULL, NULL, NULL, NULL, 'yi', NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, NULL, NULL, NULL, 'xie', NULL, NULL, NULL, NULL, NULL, 'chou', NULL, NULL, NULL,
0x20 => NULL, 'nuo', NULL, NULL, 'dan', NULL, NULL, NULL, 'xu', 'xing', NULL, 'xiong', 'liu', 'lin', 'xiang', 'yong',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lu', 'xing', NULL, 'nan', 'xie', NULL, 'bi', 'jie', 'su', NULL, 'gong', NULL, 'you', 'xing', 'qia', 'pi',
0xE0 => 'dian', 'fu', 'luo', 'qia', 'qia', 'tang', 'bai', 'gan', 'ci', 'xuan', 'lang', NULL, NULL, 'she', NULL, 'li',
0xF0 => 'hua', 'tou', 'pian', 'di', 'ruan', 'e', 'qie', 'yi', 'zhuo', 'rui', 'jian', NULL, 'chi', 'chong', 'xi', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x35.php b/core/lib/Drupal/Component/Transliteration/data/x35.php
index 08b6f5d7dfa..e3e0b888eb7 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x35.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x35.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'lue', 'deng', 'lin', 'jue', 'su', 'xiao', 'zan', NULL, NULL, 'zhu', 'zhan', 'jian', 'zou', 'chua', 'xie', 'li',
0x10 => NULL, 'chi', 'xi', 'jian', NULL, 'ji', NULL, 'fei', 'chu', 'beng', 'jie', NULL, 'ba', 'liang', 'kuai', NULL,
0x20 => 'xia', 'bie', 'jue', 'lei', 'xin', 'bai', 'yang', 'lu', 'bei', 'e', 'lu', NULL, NULL, 'che', 'nuo', 'xuan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, 'bai', 'ai', 'zhui', 'qian', 'gou', 'dan', 'bei', 'bo', 'chu', 'li', 'xiao', 'xiu', NULL, NULL, NULL,
0xE0 => NULL, NULL, 'hong', 'ti', 'cu', 'kuo', 'lao', 'zhi', 'xie', 'xi', NULL, 'qie', 'zha', 'xi', NULL, NULL,
0xF0 => 'cong', 'ji', 'huo', 'ta', 'yan', 'xu', 'po', 'sai', NULL, NULL, NULL, 'guo', 'ye', 'xiang', 'xue', 'he',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x36.php b/core/lib/Drupal/Component/Transliteration/data/x36.php
index f015cbeca56..975949b5f20 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x36.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x36.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'zuo', 'yi', 'ci', NULL, 'leng', 'xian', 'tai', 'rong', 'yi', 'zhi', 'xi', 'xian', 'ju', 'ji', 'han', NULL,
0x10 => 'pao', 'li', NULL, 'lan', 'sai', 'han', 'yan', 'qu', NULL, 'yan', 'han', 'kan', 'chi', 'nie', 'huo', NULL,
0x20 => 'bi', 'xia', 'weng', 'xuan', 'wan', 'you', 'qin', 'xu', 'nie', 'bi', 'hao', 'jing', 'ao', 'ao', NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'sou', 'can', 'dou', 'xi', 'feng', 'yi', 'suo', 'qie', 'po', 'xin', 'tong', 'xin', 'you', 'bei', 'long', NULL,
0xE0 => NULL, NULL, NULL, 'yun', 'li', 'ta', 'lan', 'man', 'qiang', 'zhou', 'yan', 'xi', 'lu', 'xi', 'sao', 'fan',
0xF0 => NULL, 'wei', 'fa', 'yi', 'nao', 'cheng', 'tan', 'ji', 'shu', 'pian', 'an', 'kua', 'cha', NULL, 'xian', 'zhi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x37.php b/core/lib/Drupal/Component/Transliteration/data/x37.php
index b3a9b7cb800..f584aea751c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x37.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x37.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, 'feng', 'lian', 'xun', 'xu', 'mi', 'hui', 'mu', 'yong', 'zhan', 'yi', 'nou', 'tang', 'xi', 'yun',
0x10 => 'shu', 'fu', 'yi', 'da', NULL, 'lian', 'cao', 'can', 'ju', 'lu', 'su', 'nen', 'ao', 'an', 'qian', NULL,
0x20 => 'cui', 'cong', NULL, 'ran', 'nian', 'mai', 'xin', 'yue', 'nai', 'ao', 'shen', 'ma', NULL, NULL, 'lan', 'xi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'mang', 'bo', 'qun', 'qi', 'han', NULL, 'long', NULL, 'tiao', 'ze', 'qi', 'zan', 'mi', 'pei', 'zhan', 'xiang',
0xE0 => 'gang', NULL, 'qi', NULL, 'lu', NULL, 'yun', 'e', 'duan', 'min', 'wei', 'quan', 'sou', 'min', 'tu', NULL,
0xF0 => 'ming', 'yao', 'jue', 'li', 'kuai', 'gang', 'yuan', 'da', NULL, 'lao', 'lou', 'qian', 'ao', 'biao', 'yong', 'mang',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x38.php b/core/lib/Drupal/Component/Transliteration/data/x38.php
index b807b9c86b0..c175ad5a1fb 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x38.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x38.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'dao', NULL, 'ao', NULL, 'xi', 'fu', 'dan', 'jiu', 'run', 'tong', 'qu', 'e', 'qi', 'ji', 'ji', 'hua',
0x10 => 'jiao', 'zui', 'biao', 'meng', 'bai', 'wei', 'yi', 'ao', 'yu', 'hao', 'dui', 'wo', 'ni', 'cuan', NULL, 'li',
0x20 => 'lu', 'niao', 'huai', 'li', NULL, 'lu', 'feng', 'mi', 'yu', NULL, 'ju', NULL, NULL, 'zhan', 'peng', 'yi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'bian', 'rong', 'ceng', 'can', 'ding', NULL, NULL, NULL, NULL, 'di', 'tong', 'ta', 'xing', 'song', 'duo', 'xi',
0xE0 => 'tao', NULL, 'ti', 'shan', 'jian', 'zhi', 'wei', 'yin', NULL, NULL, 'huan', 'zhong', 'qi', 'zong', NULL, 'xie',
0xF0 => 'xie', 'ze', 'wei', NULL, NULL, 'ta', 'zhan', 'ning', NULL, NULL, NULL, 'yi', 'ren', 'shu', 'cha', 'zhuo',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x39.php b/core/lib/Drupal/Component/Transliteration/data/x39.php
index d96877d3a75..b550c1c3341 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x39.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x39.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'mian', 'ji', 'fang', 'pei', 'ai', 'fan', 'ao', 'qin', 'qia', 'xiao', 'fen', 'gan', 'qiao', 'ge', 'tong',
0x10 => 'chan', 'you', 'gao', 'ben', 'fu', 'chu', 'zhu', NULL, 'zhou', NULL, 'hang', 'nin', 'jue', 'chong', 'cha', 'kong',
0x20 => 'lie', 'li', 'yu', NULL, 'yu', 'hai', 'li', 'hou', 'gong', 'ke', 'yuan', 'de', 'hui', NULL, 'guang', 'jiong',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'song', 'hui', 'yu', 'gua', 'guai', 'liu', 'e', 'zi', 'zi', 'bi', 'wa', NULL, 'lie', NULL, NULL, 'kuai',
0xE0 => NULL, 'hai', 'yin', 'zhu', 'chong', 'xian', 'xuan', NULL, 'qiu', 'pei', 'gui', 'er', 'gong', 'qiong', 'hu', 'lao',
0xF0 => 'li', 'chen', 'san', 'zhuo', 'wo', 'pou', 'keng', 'tun', 'peng', 'te', 'ta', 'zhuo', 'biao', 'gu', 'hu', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x3a.php b/core/lib/Drupal/Component/Transliteration/data/x3a.php
index e1ae1ade526..dd38ed1f59c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x3a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x3a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'bing', 'zhi', 'dong', 'dui', 'zhou', 'nei', 'lin', 'po', 'ji', 'min', 'wei', 'che', 'gou', 'bang', 'ru', 'tan',
0x10 => 'bu', 'zong', 'kui', 'lao', 'han', 'ying', 'zhi', 'jie', 'xing', 'xie', 'xun', 'shan', 'qian', 'xie', 'su', 'hai',
0x20 => 'mi', 'hun', 'pi', NULL, 'hui', 'na', 'song', 'ben', 'chou', 'jie', 'huang', 'lan', NULL, 'hu', 'dou', 'huo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yao', 'zhi', 'gong', 'qi', 'gen', NULL, NULL, 'hou', 'mi', 'fu', 'hu', 'guang', 'tan', 'di', NULL, 'yan',
0xE0 => NULL, NULL, 'qu', NULL, 'chang', 'ming', 'tao', 'bao', 'an', NULL, NULL, 'xian', NULL, NULL, NULL, 'mao',
0xF0 => 'lang', 'nan', 'bei', 'chen', NULL, 'fei', 'zhou', 'ji', 'jie', 'shu', NULL, 'kun', 'die', 'lu', NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x3b.php b/core/lib/Drupal/Component/Transliteration/data/x3b.php
index 4ce0a1e7bf5..8fc526cb530 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x3b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x3b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, 'yu', 'tai', 'chan', 'man', 'min', 'huan', 'wen', 'nuan', 'huan', 'hou', 'jing', 'bo', 'xian', 'li',
0x10 => 'jin', NULL, 'mang', 'piao', 'hao', 'yang', NULL, 'xian', 'su', 'wei', 'che', 'xi', 'jin', 'ceng', 'he', 'fen',
0x20 => 'shai', 'ling', NULL, 'dui', 'qi', 'pu', 'yue', 'bo', NULL, 'hui', 'die', 'yan', 'ju', 'jiao', 'nan', 'lie',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'fang', NULL, NULL, 'ta', 'cui', 'xi', 'de', 'xian', 'kuan', 'zhe', 'ta', 'hu', 'cui', 'lu', 'juan', 'lu',
0xE0 => 'qian', 'pao', 'zhen', NULL, 'li', 'cao', 'qi', NULL, NULL, 'ti', 'ling', 'qu', 'lian', 'lu', 'shu', 'gong',
0xF0 => 'zhe', 'pao', 'jin', 'qing', NULL, NULL, 'zong', 'pu', 'jin', 'biao', 'jian', 'gun', NULL, NULL, 'zao', 'lie',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x3c.php b/core/lib/Drupal/Component/Transliteration/data/x3c.php
index 31267d9cdae..c60d93602cd 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x3c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x3c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'li', 'luo', 'shen', 'mian', 'jian', 'di', 'bei', NULL, 'lian', NULL, 'xian', 'pin', 'que', 'long', 'zui', NULL,
0x10 => 'jue', 'shan', 'xue', NULL, 'xie', NULL, 'lan', 'qi', 'yi', 'nuo', 'li', 'yue', NULL, 'yi', 'chi', 'ji',
0x20 => 'hang', 'xie', 'keng', 'zi', 'he', 'xi', 'qu', 'hai', 'xia', 'hai', 'gui', 'chan', 'xun', 'xu', 'shen', 'kou',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zha', 'yi', 'bian', NULL, 'dui', 'lan', 'yi', 'chai', 'chong', 'xuan', 'xu', 'yu', 'xiu', NULL, NULL, NULL,
0xE0 => 'ta', 'guo', NULL, NULL, NULL, 'long', 'xie', 'che', 'jian', 'tan', 'pi', 'zan', 'xuan', 'xian', 'niao', NULL,
0xF0 => NULL, NULL, NULL, NULL, 'mi', 'ji', 'nou', 'hu', 'hua', 'wang', 'you', 'ze', 'bi', 'mi', 'qiang', 'xie',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x3d.php b/core/lib/Drupal/Component/Transliteration/data/x3d.php
index f83e669f66a..78b313142a7 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x3d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x3d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'fan', 'yi', 'tan', 'lei', 'yong', NULL, 'jin', 'she', 'yin', 'ji', NULL, 'su', NULL, NULL, NULL, 'wang',
0x10 => 'mian', 'su', 'yi', 'shai', 'xi', 'ji', 'luo', 'you', 'mao', 'zha', 'sui', 'zhi', 'bian', 'li', NULL, NULL,
0x20 => NULL, NULL, NULL, NULL, NULL, 'qiao', 'guan', 'xi', 'zhen', 'yong', 'nie', 'jun', 'xie', 'yao', 'xie', 'zhi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'hui', NULL, 'yu', 'zong', 'yan', 'qiu', 'zhao', 'jiong', 'tai', NULL, NULL, NULL, NULL, NULL, NULL, 'tui',
0xE0 => 'lin', 'jiong', 'zha', 'xing', 'hu', NULL, 'xu', NULL, NULL, NULL, 'cui', 'qing', 'mo', NULL, 'zao', 'beng',
0xF0 => 'chi', NULL, NULL, 'yan', 'ge', 'mo', 'bei', 'juan', 'die', 'zhao', NULL, 'wu', 'yan', NULL, 'jue', 'xian',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x3e.php b/core/lib/Drupal/Component/Transliteration/data/x3e.php
index 1c2e517bd93..f4b1fd43916 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x3e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x3e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'tai', 'han', NULL, 'dian', 'ji', 'jie', NULL, 'zuan', NULL, 'xie', 'lai', 'fan', 'huo', 'xi', 'nie', 'mi',
0x10 => 'ran', 'cuan', 'yin', 'mi', NULL, 'jue', 'qu', 'tong', 'wan', 'zhe', 'li', 'shao', 'kong', 'xian', 'zhe', 'zhi',
0x20 => 'tiao', 'shu', 'bei', 'ye', 'pian', 'chan', 'hu', 'ken', 'jiu', 'an', 'chun', 'qian', 'bei', 'ba', 'fen', 'ke',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, 'ji', 'jun', 'zou', 'duo', 'jue', 'dai', 'bei', NULL, NULL, NULL, NULL, NULL, 'la', 'bin', 'sui',
0xE0 => 'tu', 'xue', NULL, NULL, NULL, NULL, NULL, 'duo', NULL, NULL, 'sui', 'bi', 'tu', 'se', 'can', 'tu',
0xF0 => 'mian', 'jin', 'lu', NULL, NULL, 'zhan', 'bi', 'ji', 'zen', 'xuan', 'li', NULL, NULL, 'sui', 'yong', 'shu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x3f.php b/core/lib/Drupal/Component/Transliteration/data/x3f.php
index 7b6015891c0..1d227283799 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x3f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x3f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, 'e', NULL, NULL, NULL, NULL, 'qiong', 'luo', 'zhen', 'tun', 'gu', 'yu', 'lei', 'bo', 'nei',
0x10 => 'pian', 'lian', 'tang', 'lian', 'wen', 'dang', 'li', 'ting', 'wa', 'zhou', 'gang', 'xing', 'ang', 'fan', 'peng', 'bo',
0x20 => 'tuo', 'shu', 'yi', 'bo', 'qie', 'tou', 'gong', 'tong', 'han', 'cheng', 'jie', 'huan', 'xing', 'dian', 'chai', 'dong',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, 'yao', 'dao', 'jia', 'lei', 'yan', 'lu', 'tui', 'ying', 'pi', 'luo', 'li', 'bie', NULL, 'mao', 'bai',
0xE0 => 'huang', NULL, 'yao', 'he', 'chun', 'he', 'ning', 'chou', 'li', 'tang', 'huan', 'bi', 'ba', 'che', 'yang', 'da',
0xF0 => 'ao', 'xue', NULL, 'zi', 'da', 'ran', 'bang', 'cuo', 'wan', 'ta', 'bao', 'gan', 'yan', 'xi', 'zhu', 'ya',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x40.php b/core/lib/Drupal/Component/Transliteration/data/x40.php
index 9e7c307da06..ba952e9bae4 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x40.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x40.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'fan', 'you', 'an', 'tui', 'meng', 'she', 'jin', 'gu', 'ji', 'qiao', 'jiao', 'yan', 'xi', 'kan', 'mian', 'xuan',
0x10 => 'shan', 'wo', 'qian', 'huan', 'ren', 'zhen', 'tian', 'jue', 'xie', 'qi', 'ang', 'mei', 'gu', NULL, 'tao', 'fan',
0x20 => 'ju', 'chan', 'shun', 'bi', 'mao', 'shuo', 'gu', 'hong', 'hua', 'luo', 'hang', 'jia', 'quan', 'gai', 'huang', 'bu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, 'ban', 'he', 'gou', 'hong', 'lao', 'wu', 'bo', 'keng', 'lu', 'cu', 'lian', 'yi', 'qiao', 'shu', NULL,
0xE0 => 'xuan', 'jin', 'qin', 'hui', 'su', 'chuang', 'dun', 'long', NULL, 'nao', 'tan', 'dan', 'wei', 'gan', 'da', 'li',
0xF0 => 'ca', 'xian', 'pan', 'la', 'zhu', 'niao', 'huai', 'ying', 'xian', 'lan', 'mo', 'ba', NULL, 'gui', 'bi', 'fu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x41.php b/core/lib/Drupal/Component/Transliteration/data/x41.php
index f32b7e52d4b..bb33c8bdd2b 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x41.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x41.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'huo', 'yi', 'liu', NULL, 'yin', 'juan', 'huo', 'cheng', 'dou', 'e', NULL, 'yan', 'zhui', 'zha', 'qi', 'yu',
0x10 => 'quan', 'huo', 'nie', 'huang', 'ju', 'she', NULL, NULL, 'peng', 'ming', 'cao', 'lou', 'li', 'chuang', NULL, 'cui',
0x20 => 'shan', 'dan', 'qi', NULL, 'lai', 'ling', 'liao', 'reng', 'yu', 'yi', 'diao', 'qi', 'yi', 'nian', 'fu', 'jian',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'li', 'ba', 'jie', 'xu', 'luo', NULL, 'yun', 'zhong', 'hu', 'yin', NULL, 'zhi', 'qian', NULL, 'gan', 'jian',
0xE0 => 'zhu', 'zhu', 'ku', 'nie', 'rui', 'ze', 'ang', 'zhi', 'gong', 'yi', 'chi', 'ji', 'zhu', 'lao', 'ren', 'rong',
0xF0 => 'zheng', 'na', 'ce', NULL, NULL, 'yi', 'jue', 'bie', 'cheng', 'jun', 'dou', 'wei', 'yi', 'zhe', 'yan', NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x42.php b/core/lib/Drupal/Component/Transliteration/data/x42.php
index 27e73385d7b..d5043fc89b9 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x42.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x42.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'san', 'lun', 'ping', 'zhao', 'han', 'yu', 'dai', 'zhao', 'fei', 'sha', 'ling', 'ta', 'qu', 'mang', 'ye', 'bao',
0x10 => 'gui', 'gua', 'nan', 'ge', NULL, 'shi', 'ke', 'suo', 'ci', 'zhou', 'tai', 'kuai', 'qin', 'xu', 'du', 'ce',
0x20 => 'huan', 'cong', 'sai', 'zheng', 'qian', 'jin', 'zong', 'wei', NULL, NULL, 'xi', 'na', 'pu', 'sou', 'ju', 'zhen',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yue', 'lie', NULL, 'zhou', 'bi', 'ren', 'yu', NULL, 'chuo', 'er', 'yi', 'mi', 'qing', NULL, 'wang', 'ji',
0xE0 => 'bu', NULL, 'bie', 'fan', 'yue', 'li', 'fan', 'qu', 'fu', 'er', 'e', 'zheng', 'tian', 'yu', 'jin', 'qi',
0xF0 => 'ju', 'lai', 'che', 'bei', 'niu', 'yi', 'xu', 'mou', 'xun', 'fu', NULL, 'nin', 'ting', 'beng', 'zha', 'wei',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x43.php b/core/lib/Drupal/Component/Transliteration/data/x43.php
index 8291d9d39f7..81efa7dc6cb 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x43.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x43.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ke', 'yao', 'ou', 'xiao', 'geng', 'tang', 'gui', 'hui', 'ta', NULL, 'yao', 'da', 'qi', 'jin', 'lue', 'mi',
0x10 => 'mi', 'jian', 'lu', 'fan', 'ou', 'mi', 'jie', 'fu', 'bie', 'huang', 'su', 'yao', 'nie', 'jin', 'lian', 'bo',
0x20 => 'jian', 'ti', 'ling', 'zuan', 'shi', 'yin', 'dao', 'chou', 'ca', 'mie', 'yan', 'lan', 'chong', 'jiao', 'shuang', 'quan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jue', 'di', 'pian', 'guan', 'niu', 'ren', 'zhen', 'gai', 'pi', 'tan', 'chao', 'chun', 'he', 'zhuan', 'mo', 'bie',
0xE0 => 'qi', 'shi', 'bi', 'jue', 'si', NULL, 'gua', 'na', 'hui', 'xi', 'er', 'xiu', 'mou', NULL, 'xi', 'zhi',
0xF0 => 'run', 'ju', 'die', 'zhe', 'shao', 'meng', 'bi', 'han', 'yu', 'xian', 'pang', 'neng', 'can', 'bu', NULL, 'qi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x44.php b/core/lib/Drupal/Component/Transliteration/data/x44.php
index af44abbf2f5..8bbb7267659 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x44.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x44.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ji', 'zhuo', 'lu', 'jun', 'xian', 'xi', 'cai', 'wen', 'zhi', 'zi', 'kun', 'cong', 'tian', 'chu', 'di', 'chun',
0x10 => 'qiu', 'zhe', 'zha', 'rou', 'bin', 'ji', 'xi', 'zhu', 'jue', 'ge', 'ji', 'da', 'chen', 'suo', 'ruo', 'xiang',
0x20 => 'huang', 'qi', 'zhu', 'sun', 'chai', 'weng', 'ke', 'kao', 'gu', 'gai', 'fan', 'cong', 'cao', 'zhi', 'chan', 'lei',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chun', 'ping', 'kuai', 'chou', NULL, 'tuo', 'qiong', 'cong', 'gao', 'kua', 'qu', 'qu', 'zhi', 'meng', 'li', 'zhou',
0xE0 => 'ta', 'zhi', 'gu', 'liang', 'hu', 'la', 'dian', 'ci', 'ying', NULL, NULL, 'qi', NULL, 'cha', 'mao', 'du',
0xF0 => 'yin', 'chai', 'rui', 'hen', 'ruan', 'fu', 'lai', 'xing', 'jian', 'yi', 'mei', NULL, 'mang', 'ji', 'suo', 'han',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x45.php b/core/lib/Drupal/Component/Transliteration/data/x45.php
index 0ba25ac507a..88a0b279437 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x45.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x45.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'li', 'zi', 'zu', 'yao', 'ge', 'li', 'qi', 'gong', 'li', 'bing', 'suo', NULL, NULL, 'su', 'chou',
0x10 => 'jian', 'xie', 'bei', 'xu', 'jing', 'pu', 'ling', 'xiang', 'zuo', 'diao', 'chun', 'qing', 'nan', 'zhai', 'lu', 'yi',
0x20 => 'shao', 'yu', 'hua', 'li', 'pa', NULL, NULL, 'li', NULL, NULL, 'shuang', NULL, 'yi', 'ning', 'si', 'ku',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'shi', 'yi', 'bing', 'cong', 'hou', 'wan', 'di', 'ji', 'ge', 'han', 'bo', 'xiu', 'liu', 'can', 'can', 'yi',
0xE0 => 'xuan', 'yan', 'zao', 'han', 'yong', 'zong', NULL, 'kang', 'yu', 'qi', 'zhe', 'ma', NULL, NULL, 'shuang', 'jin',
0xF0 => 'guan', 'pu', 'lin', NULL, 'ting', 'jiang', 'la', 'yi', 'yong', 'ci', 'yan', 'jie', 'xun', 'wei', 'xian', 'ning',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x46.php b/core/lib/Drupal/Component/Transliteration/data/x46.php
index 3311641252d..032f0833c81 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x46.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x46.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'fu', 'ge', NULL, 'mo', 'zhu', 'nai', 'xian', 'wen', 'li', 'can', 'mie', 'jian', 'ni', 'chai', 'wan', 'xu',
0x10 => 'nu', 'mai', 'zui', 'kan', 'ka', 'hang', NULL, NULL, 'yu', 'wei', 'zhu', NULL, NULL, 'yi', NULL, 'diao',
0x20 => 'fu', 'bi', 'zhu', 'zi', 'shu', 'xia', 'ni', NULL, 'jiao', 'xun', 'chong', 'nou', 'rong', 'zhi', 'sang', NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ci', 'mi', 'bian', NULL, 'na', 'yu', 'e', 'zhi', 'ren', 'xu', 'lue', 'hui', 'xun', 'nao', 'han', 'jia',
0xE0 => 'dou', 'hua', 'tu', 'ping', 'cu', 'xi', 'song', 'mi', 'xin', 'wu', 'qiong', 'zhang', 'tao', 'xing', 'jiu', 'ju',
0xF0 => 'hun', 'ti', 'man', 'yan', 'ji', 'shou', 'lei', 'wan', 'che', 'can', 'jie', 'you', 'hui', 'zha', 'su', 'ge',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x47.php b/core/lib/Drupal/Component/Transliteration/data/x47.php
index 58a79c46d7b..4981e9fd1fc 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x47.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x47.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'nao', 'xi', NULL, 'dui', 'chi', 'wei', 'zhe', 'gun', 'chao', 'chi', 'zao', 'hui', 'luan', 'liao', 'lao', 'tuo',
0x10 => 'hui', 'wu', 'ao', 'she', 'sui', 'mai', 'tan', 'xin', 'jing', 'an', 'ta', 'chan', 'wei', 'tuan', 'ji', 'chen',
0x20 => 'che', 'yu', 'xian', 'xin', NULL, NULL, NULL, 'nao', NULL, 'yan', 'qiu', 'jiang', 'song', 'jun', 'liao', 'ju',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'li', 'yue', 'quan', 'cheng', 'fu', 'cha', 'tang', 'shi', 'hang', 'qie', 'qi', 'bo', 'na', 'tou', 'chu', 'cu',
0xE0 => 'yue', 'zhi', 'chen', 'chu', 'bi', 'meng', 'ba', 'tian', 'min', 'lie', 'feng', 'cheng', 'qiu', 'tiao', 'fu', 'kuo',
0xF0 => 'jian', NULL, NULL, NULL, 'zhen', 'qiu', 'zuo', 'chi', 'kui', 'lie', 'bei', 'du', 'wu', NULL, 'zhuo', 'lu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x48.php b/core/lib/Drupal/Component/Transliteration/data/x48.php
index 668713dbd0c..c5ee78f50d0 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x48.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x48.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'tang', NULL, 'chu', 'liang', 'tian', 'kun', 'chang', 'jue', 'tu', 'huan', 'fei', 'bi', NULL, 'xia', 'wo', 'ji',
0x10 => 'qu', 'kui', 'hu', 'qiu', 'sui', 'cai', NULL, 'qiu', 'pi', 'pang', 'wa', 'yao', 'rong', 'xun', 'cu', 'die',
0x20 => 'chi', 'cuo', 'meng', 'xuan', 'duo', 'bie', 'zhe', 'chu', 'chan', 'gui', 'duan', 'zou', 'deng', 'lai', 'teng', 'yue',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ying', 'chan', NULL, 'li', 'suo', 'ma', 'ma', NULL, 'tang', 'pei', 'lou', 'qi', 'cuo', 'tu', 'e', 'can',
0xE0 => 'jie', 'yi', 'ji', 'dang', 'jue', 'bi', 'lei', 'yi', 'chun', 'chun', 'po', 'li', 'zai', 'tai', 'po', 'cu',
0xF0 => 'ju', 'xu', 'fan', NULL, 'xu', 'er', 'huo', 'zhu', 'ran', 'fa', 'juan', 'han', 'liang', 'zhi', 'mi', 'yu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x49.php b/core/lib/Drupal/Component/Transliteration/data/x49.php
index d9bde7a81d8..75c9bafe6af 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x49.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x49.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, 'cen', 'mei', 'yin', 'mian', 'tu', 'kui', NULL, NULL, 'mi', 'rong', 'yu', 'qiang', 'mi', 'ju', 'pi',
0x10 => 'jin', 'wang', 'ji', 'meng', 'jian', 'xue', 'bao', 'gan', 'chan', 'li', 'li', 'qiu', 'dun', 'ying', 'yun', 'chen',
0x20 => 'zhi', 'ran', NULL, 'lue', 'kai', 'gui', 'yue', 'hui', 'pi', 'cha', 'duo', 'chan', 'sha', 'shi', 'she', 'xing',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, 'di', 'lai', 'zhou', 'nian', 'cheng', 'jian', 'bi', 'zhuan', 'ling', 'hao', 'bang', 'tang', 'chi', 'ma', 'xian',
0xE0 => 'shuan', 'yong', 'qu', NULL, 'pu', 'hui', 'wei', 'yi', 'ye', NULL, 'che', 'hao', 'bin', NULL, 'xian', 'chan',
0xF0 => 'hun', NULL, 'han', 'ci', 'zhi', 'qi', 'kui', 'rou', NULL, 'ying', 'xiong', NULL, 'hu', 'cui', NULL, 'que',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x4a.php b/core/lib/Drupal/Component/Transliteration/data/x4a.php
index 60e658b752e..12d5aee8d89 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x4a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x4a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'di', 'wu', 'qiu', NULL, 'yan', 'liao', 'bi', NULL, 'bin', NULL, 'yuan', 'nue', 'bao', 'ying', 'hong', 'ci',
0x10 => 'qia', 'ti', 'yu', 'lei', 'bao', NULL, 'ji', 'fu', 'xian', 'cen', 'hu', 'se', 'beng', 'qing', 'yu', 'wa',
0x20 => 'ai', 'han', 'dan', 'ge', 'di', 'huo', 'pang', NULL, 'zhui', 'ling', 'mai', 'mai', 'lian', 'xiao', 'xue', 'zhen',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lin', 'yi', 'men', 'wu', 'qi', 'die', 'chen', 'xia', 'he', 'sang', 'gua', 'hou', 'ao', 'fu', 'qiao', 'hun',
0xE0 => 'pi', 'yan', 'si', 'xi', 'ming', 'kui', 'ge', NULL, 'ao', 'san', 'shuang', 'lou', 'zhen', 'hui', 'chan', NULL,
0xF0 => 'lin', 'na', 'han', 'du', 'jin', 'mian', 'fan', 'e', 'chao', 'hong', 'hong', 'yu', 'xue', 'pao', 'bi', 'chao',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x4b.php b/core/lib/Drupal/Component/Transliteration/data/x4b.php
index 625a88040fa..8b542e0ce92 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x4b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x4b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'you', 'yi', 'xue', 'sa', 'xu', 'li', 'li', 'yuan', 'dui', 'huo', 'sha', 'leng', 'pou', 'hu', 'guo', 'bu',
0x10 => 'rui', 'wei', 'sou', 'an', 'yu', 'xiang', 'heng', 'yang', 'xiao', 'yao', NULL, 'bi', NULL, 'heng', 'tao', 'liu',
0x20 => NULL, 'zhu', NULL, 'xi', 'zan', 'yi', 'dou', 'yuan', 'jiu', NULL, 'bo', 'ti', 'ying', NULL, 'yi', 'nian',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'hai', 'kuang', 'heng', 'kui', 'ze', 'ting', 'lang', 'bi', 'huan', 'po', 'yao', 'wan', 'ti', 'sui', 'kua', 'dui',
0xE0 => 'ao', 'jian', 'mo', 'kui', 'kuai', 'an', 'ma', 'qing', 'qiao', NULL, 'kao', 'hao', 'duo', 'xian', 'nai', 'suo',
0xF0 => 'jie', 'pi', 'pa', 'song', 'chang', 'nie', 'man', 'song', 'ci', 'xian', 'kuo', NULL, 'di', 'pou', 'tiao', 'zu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x4c.php b/core/lib/Drupal/Component/Transliteration/data/x4c.php
index aa1852ce41a..38398a2d1d3 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x4c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x4c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'wo', 'fei', 'cai', 'peng', 'sai', NULL, 'rou', 'qi', 'cuo', 'pan', 'bo', 'man', 'zong', 'ci', 'kui', 'ji',
0x10 => 'lan', NULL, 'meng', 'mian', 'pan', 'lu', 'zuan', NULL, 'liu', 'yi', 'wen', 'li', 'li', 'zeng', 'zhu', 'hun',
0x20 => 'shen', 'chi', 'xing', 'wang', 'dong', 'huo', 'pi', 'hu', 'mei', 'che', 'mei', 'chao', 'ju', 'nou', NULL, 'yi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ci', 'you', 'yuan', 'lao', 'ju', 'fu', 'nie', 'e', 'e', 'xing', 'kan', 'yan', 'tu', 'pou', 'beng', 'ming',
0xE0 => 'shui', 'yan', 'qi', 'yuan', 'bie', NULL, 'xuan', 'hou', 'huang', 'yao', 'juan', 'kui', 'e', 'ji', 'mo', 'chong',
0xF0 => 'bao', 'wu', 'zhen', 'xu', 'ta', 'chi', 'xi', 'cong', 'ma', 'kou', 'yan', 'can', NULL, 'he', 'deng', 'ran',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x4d.php b/core/lib/Drupal/Component/Transliteration/data/x4d.php
index b77e988955a..fb9737fa8a2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x4d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x4d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'tong', 'yu', 'xiang', 'nao', 'shun', 'fen', 'pu', 'ling', 'ao', 'huan', 'yi', 'huan', 'meng', 'ying', 'lei', 'yan',
0x10 => 'bao', 'die', 'ling', 'shi', 'jiao', 'lie', 'jing', 'ju', 'ti', 'pi', 'gang', 'xiao', 'wai', 'chuai', 'di', 'huan',
0x20 => 'yao', 'li', 'mi', 'hu', 'sheng', 'jia', 'yin', 'wei', NULL, 'piao', 'lu', 'ling', 'yi', 'cai', 'shan', 'hu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x4e.php b/core/lib/Drupal/Component/Transliteration/data/x4e.php
index 868c80d3cc7..1d833446e22 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x4e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x4e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yi', 'ding', 'kao', 'qi', 'shang', 'xia', 'han', 'wan', 'zhang', 'san', 'shang', 'xia', 'ji', 'bu', 'yu', 'mian',
0x10 => 'gai', 'chou', 'chou', 'zhuan', 'qie', 'pi', 'shi', 'shi', 'qiu', 'bing', 'ye', 'cong', 'dong', 'si', 'cheng', 'diu',
0x20 => 'qiu', 'liang', 'diu', 'you', 'liang', 'yan', 'bing', 'sang', 'gun', 'jiu', 'ge', 'ya', 'qiang', 'zhong', 'ji', 'jie',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'san', 'lun', 'bing', 'cang', 'zi', 'shi', 'ta', 'zhang', 'fu', 'xian', 'xian', 'tuo', 'hong', 'tong', 'ren', 'qian',
0xE0 => 'gan', 'ge', 'bo', 'dai', 'ling', 'yi', 'chao', 'chang', 'sa', 'shang', 'yi', 'mu', 'men', 'ren', 'jia', 'chao',
0xF0 => 'yang', 'qian', 'zhong', 'pi', 'wo', 'wu', 'jian', 'jia', 'yao', 'feng', 'cang', 'ren', 'wang', 'fen', 'di', 'fang',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x4f.php b/core/lib/Drupal/Component/Transliteration/data/x4f.php
index 01144a550be..ee4723b1085 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x4f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x4f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'zhong', 'qi', 'pei', 'yu', 'diao', 'dun', 'wu', 'yi', 'xin', 'kang', 'yi', 'ji', 'ai', 'wu', 'ji', 'fu',
0x10 => 'fa', 'xiu', 'jin', 'pi', 'dan', 'fu', 'tang', 'zhong', 'you', 'huo', 'hui', 'yu', 'cui', 'chuan', 'san', 'wei',
0x20 => 'chuan', 'che', 'ya', 'xian', 'shang', 'chang', 'lun', 'cang', 'xun', 'xin', 'wei', 'zhu', 'ze', 'xian', 'nu', 'bo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'li', 'yong', 'hun', 'jing', 'qian', 'san', 'pei', 'su', 'fu', 'xi', 'li', 'fu', 'ping', 'bao', 'yu', 'qi',
0xE0 => 'xia', 'xin', 'xiu', 'yu', 'di', 'che', 'chou', 'zhi', 'yan', 'lia', 'li', 'lai', 'si', 'jian', 'xiu', 'fu',
0xF0 => 'huo', 'ju', 'xiao', 'pai', 'jian', 'biao', 'chu', 'fei', 'feng', 'ya', 'an', 'bei', 'yu', 'xin', 'bi', 'hu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x50.php b/core/lib/Drupal/Component/Transliteration/data/x50.php
index f3e3e53092a..1fd5d9dd0f1 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x50.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x50.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'chang', 'zhi', 'bing', 'jiu', 'yao', 'cui', 'lia', 'wan', 'lai', 'cang', 'zong', 'ge', 'guan', 'bei', 'tian', 'shu',
0x10 => 'shu', 'men', 'dao', 'tan', 'jue', 'chui', 'xing', 'peng', 'tang', 'hou', 'yi', 'qi', 'ti', 'gan', 'jing', 'jie',
0x20 => 'sui', 'chang', 'jie', 'fang', 'zhi', 'kong', 'juan', 'zong', 'ju', 'qian', 'ni', 'lun', 'zhuo', 'wo', 'luo', 'song',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'shan', 'qiao', 'jiong', 'tui', 'zun', 'pu', 'xi', 'lao', 'chang', 'guang', 'liao', 'qi', 'cheng', 'chan', 'wei', 'ji',
0xE0 => 'bo', 'hui', 'chuan', 'tie', 'dan', 'jiao', 'jiu', 'seng', 'fen', 'xian', 'ju', 'e', 'jiao', 'jian', 'tong', 'lin',
0xF0 => 'bo', 'gu', 'xian', 'su', 'xian', 'jiang', 'min', 'ye', 'jin', 'jia', 'qiao', 'pi', 'feng', 'zhou', 'ai', 'sai',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x51.php b/core/lib/Drupal/Component/Transliteration/data/x51.php
index 3f00d5ab9ea..f5ad0080eef 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x51.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x51.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yi', 'jun', 'nong', 'chan', 'yi', 'dang', 'jing', 'xuan', 'kuai', 'jian', 'chu', 'dan', 'jiao', 'sha', 'zai', 'can',
0x10 => 'bin', 'an', 'ru', 'tai', 'chou', 'chai', 'lan', 'ni', 'jin', 'qian', 'meng', 'wu', 'ning', 'qiong', 'ni', 'chang',
0x20 => 'lie', 'lei', 'lu', 'kuang', 'bao', 'yu', 'biao', 'zan', 'zhi', 'si', 'you', 'hao', 'chen', 'chen', 'li', 'teng',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yin', 'cou', 'yi', 'li', 'chuang', 'ming', 'zhun', 'cui', 'si', 'duo', 'jin', 'lin', 'lin', 'ning', 'xi', 'du',
0xE0 => 'ji', 'fan', 'fan', 'fan', 'feng', 'ju', 'chu', 'zheng', 'feng', 'mu', 'zhi', 'fu', 'feng', 'ping', 'feng', 'kai',
0xF0 => 'huang', 'kai', 'gan', 'deng', 'ping', 'qian', 'xiong', 'kuai', 'tu', 'ao', 'chu', 'ji', 'dang', 'han', 'han', 'zao',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x52.php b/core/lib/Drupal/Component/Transliteration/data/x52.php
index c09edddd564..a3df0ee4002 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x52.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x52.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'dao', 'diao', 'dao', 'ren', 'ren', 'chuang', 'fen', 'qie', 'yi', 'ji', 'kan', 'qian', 'cun', 'chu', 'wen', 'ji',
0x10 => 'dan', 'xing', 'hua', 'wan', 'jue', 'li', 'yue', 'lie', 'liu', 'ze', 'gang', 'chuang', 'fu', 'chu', 'qu', 'ju',
0x20 => 'shan', 'min', 'ling', 'zhong', 'pan', 'bie', 'jie', 'jie', 'pao', 'li', 'shan', 'bie', 'chan', 'jing', 'gua', 'geng',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'meng', 'chi', 'lei', 'kai', 'mian', 'dong', 'xu', 'xu', 'kan', 'wu', 'yi', 'xun', 'weng', 'sheng', 'lao', 'mu',
0xE0 => 'lu', 'piao', 'shi', 'ji', 'qin', 'jiang', 'chao', 'quan', 'xiang', 'yi', 'jue', 'fan', 'juan', 'tong', 'ju', 'dan',
0xF0 => 'xie', 'mai', 'xun', 'xun', 'lu', 'li', 'che', 'rang', 'quan', 'bao', 'shao', 'yun', 'jiu', 'bao', 'gou', 'wu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x53.php b/core/lib/Drupal/Component/Transliteration/data/x53.php
index 0af1ffc1060..bee5a9674de 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x53.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x53.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yun', 'wen', 'bi', 'gai', 'gai', 'bao', 'cong', 'yi', 'xiong', 'peng', 'ju', 'tao', 'ge', 'pu', 'e', 'pao',
0x10 => 'fu', 'gong', 'da', 'jiu', 'qiong', 'bi', 'hua', 'bei', 'nao', 'shi', 'fang', 'jiu', 'yi', 'za', 'jiang', 'kang',
0x20 => 'jiang', 'kuang', 'hu', 'xia', 'qu', 'bian', 'gui', 'qie', 'zang', 'kuang', 'fei', 'hu', 'yu', 'gui', 'kui', 'hui',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ba', 'fa', 'ruo', 'shi', 'shu', 'zhuo', 'qu', 'shou', 'bian', 'xu', 'jia', 'pan', 'sou', 'gao', 'wei', 'sou',
0xE0 => 'die', 'rui', 'cong', 'kou', 'gu', 'ju', 'ling', 'gua', 'dao', 'kou', 'zhi', 'jiao', 'zhao', 'ba', 'ding', 'ke',
0xF0 => 'tai', 'chi', 'shi', 'you', 'qiu', 'po', 'ye', 'hao', 'si', 'tan', 'chi', 'le', 'diao', 'ji', 'liao', 'hong',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x54.php b/core/lib/Drupal/Component/Transliteration/data/x54.php
index 85b047619f1..ae03398704d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x54.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x54.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'mie', 'xu', 'mang', 'chi', 'ge', 'xuan', 'yao', 'zi', 'he', 'ji', 'diao', 'cun', 'tong', 'ming', 'hou', 'li',
0x10 => 'tu', 'xiang', 'zha', 'xia', 'ye', 'lu', 'ya', 'ma', 'ou', 'huo', 'yi', 'jun', 'chou', 'lin', 'tun', 'yin',
0x20 => 'fei', 'bi', 'qin', 'qin', 'jie', 'bu', 'fou', 'ba', 'dun', 'fen', 'e', 'han', 'ting', 'keng', 'shun', 'qi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'kuang', 'ya', 'da', 'xiao', 'bi', 'hui', 'nian', 'hua', 'xing', 'kuai', 'duo', 'fen', 'ji', 'nong', 'mou', 'yo',
0xE0 => 'hao', 'yuan', 'long', 'pou', 'mang', 'ge', 'o', 'chi', 'shao', 'li', 'na', 'zu', 'he', 'ku', 'xiao', 'xian',
0xF0 => 'lao', 'bo', 'zhe', 'zha', 'liang', 'ba', 'mie', 'lie', 'sui', 'fu', 'bu', 'han', 'heng', 'geng', 'shuo', 'ge',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x55.php b/core/lib/Drupal/Component/Transliteration/data/x55.php
index 3f16ee5c216..af2d7772ce7 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x55.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x55.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'you', 'yan', 'gu', 'gu', 'bei', 'han', 'suo', 'chun', 'yi', 'ai', 'jia', 'tu', 'xian', 'wan', 'li', 'xi',
0x10 => 'tang', 'zuo', 'qiu', 'che', 'wu', 'zao', 'ya', 'dou', 'qi', 'di', 'qin', 'ma', 'mo', 'gong', 'dou', 'qu',
0x20 => 'lao', 'liang', 'suo', 'zao', 'huan', 'lang', 'sha', 'ji', 'zuo', 'wo', 'feng', 'jin', 'hu', 'qi', 'shou', 'wei',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'hai', 'ke', 'da', 'sang', 'chen', 'ru', 'sou', 'wa', 'ji', 'pang', 'wu', 'qian', 'shi', 'ge', 'zi', 'jie',
0xE0 => 'luo', 'weng', 'wa', 'si', 'chi', 'hao', 'suo', 'Jia ', 'hai', 'suo', 'qin', 'nie', 'he', 'zhi', 'sai', 'n',
0xF0 => 'ge', 'na', 'dia', 'ai', 'qiang', 'tong', 'bi', 'ao', 'ao', 'lian', 'zui', 'zhe', 'mo', 'sou', 'sou', 'tan',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x56.php b/core/lib/Drupal/Component/Transliteration/data/x56.php
index 8f34d3c0c38..3d35d44470c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x56.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x56.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'di', 'qi', 'jiao', 'chong', 'jiao', 'kai', 'tan', 'shan', 'cao', 'jia', 'ai', 'xiao', 'piao', 'lou', 'ga', 'gu',
0x10 => 'xiao', 'hu', 'hui', 'guo', 'ou', 'xian', 'ze', 'chang', 'xu', 'po', 'de', 'ma', 'ma', 'hu', 'lei', 'du',
0x20 => 'ga', 'tang', 'ye', 'beng', 'ying', 'sai', 'jiao', 'mi', 'xiao', 'hua', 'mai', 'ran', 'chuai', 'peng', 'lao', 'xiao',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'za', 'zhu', 'lan', 'nie', 'nang', 'lan', 'lo', 'wei', 'hui', 'yin', 'qiu', 'si', 'nin', 'jian', 'hui', 'xin',
0xE0 => 'yin', 'nan', 'tuan', 'tuan', 'dun', 'kang', 'yuan', 'jiong', 'pian', 'yun', 'cong', 'hu', 'hui', 'yuan', 'e', 'guo',
0xF0 => 'kun', 'cong', 'tong', 'tu', 'wei', 'lun', 'guo', 'qun', 'ri', 'ling', 'gu', 'guo', 'tai', 'guo', 'tu', 'you',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x57.php b/core/lib/Drupal/Component/Transliteration/data/x57.php
index 7983c7a8fe7..f337892b71e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x57.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x57.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'guo', 'yin', 'hun', 'pu', 'yu', 'han', 'yuan', 'lun', 'quan', 'yu', 'qing', 'guo', 'chuan', 'wei', 'yuan', 'quan',
0x10 => 'ku', 'fu', 'yuan', 'yuan', 'ya', 'tu', 'tu', 'tu', 'tuan', 'lue', 'hui', 'yi', 'huan', 'luan', 'luan', 'tu',
0x20 => 'ya', 'tu', 'ting', 'sheng', 'pu', 'lu', 'kuai', 'ya', 'zai', 'wei', 'ge', 'yu', 'wu', 'gui', 'pi', 'yi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jin', 'zhe', 'lie', 'lie', 'bu', 'cheng', 'hua', 'bu', 'shi', 'xun', 'guo', 'jiong', 'ye', 'nian', 'di', 'yu',
0xE0 => 'bu', 'ya', 'quan', 'sui', 'pi', 'qing', 'wan', 'ju', 'lun', 'zheng', 'kong', 'chong', 'dong', 'dai', 'tan', 'an',
0xF0 => 'cai', 'chu', 'beng', 'kan', 'zhi', 'duo', 'yi', 'zhi', 'yi', 'pei', 'ji', 'zhun', 'qi', 'sao', 'ju', 'ni',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x58.php b/core/lib/Drupal/Component/Transliteration/data/x58.php
index 73a217c730e..1e6255580c6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x58.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x58.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ku', 'ke', 'tang', 'kun', 'ni', 'jian', 'dui', 'jin', 'gang', 'yu', 'e', 'peng', 'gu', 'tu', 'leng', 'fang',
0x10 => 'ya', 'qian', 'kun', 'an', 'shen', 'duo', 'nao', 'tu', 'cheng', 'yin', 'hun', 'bi', 'lian', 'guo', 'die', 'zhuan',
0x20 => 'hou', 'bao', 'bao', 'yu', 'di', 'mao', 'jie', 'ruan', 'ye', 'geng', 'kan', 'zong', 'yu', 'huang', 'e', 'yao',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'xi', 'he', 'ai', 'ya', 'dao', 'hao', 'ruan', 'jin', 'lei', 'kuang', 'lu', 'yan', 'tan', 'wei', 'huai', 'long',
0xE0 => 'long', 'rui', 'li', 'lin', 'rang', 'chan', 'xun', 'yan', 'lei', 'ba', 'wan', 'shi', 'ren', 'san', 'zhuang', 'zhuang',
0xF0 => 'sheng', 'yi', 'mai', 'ke', 'zhu', 'zhuang', 'hu', 'hu', 'kun', 'yi', 'hu', 'xu', 'kun', 'shou', 'mang', 'zun',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x59.php b/core/lib/Drupal/Component/Transliteration/data/x59.php
index 5755e53b3a1..5df464c6add 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x59.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x59.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'shou', 'yi', 'zhi', 'gu', 'chu', 'jiang', 'feng', 'bei', 'zhai', 'bian', 'sui', 'qun', 'ling', 'fu', 'cuo', 'xia',
0x10 => 'xiong', 'xie', 'nao', 'xia', 'kui', 'xi', 'wai', 'yuan', 'mao', 'su', 'duo', 'duo', 'ye', 'qing', 'wai', 'gou',
0x20 => 'gou', 'qi', 'meng', 'meng', 'yin', 'huo', 'chen', 'da', 'ze', 'tian', 'tai', 'fu', 'guai', 'yao', 'yang', 'hang',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jie', 'gu', 'si', 'xing', 'wei', 'zi', 'ju', 'shan', 'pin', 'ren', 'yao', 'dong', 'jiang', 'shu', 'ji', 'gai',
0xE0 => 'xiang', 'hua', 'juan', 'jiao', 'gou', 'lao', 'jian', 'jian', 'yi', 'nian', 'zhi', 'ji', 'ji', 'xian', 'heng', 'guang',
0xF0 => 'jun', 'kua', 'yan', 'ming', 'lie', 'pei', 'e', 'you', 'yan', 'cha', 'shen', 'yin', 'shi', 'gui', 'quan', 'zi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x5a.php b/core/lib/Drupal/Component/Transliteration/data/x5a.php
index 306fce933e4..49b18ae92de 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x5a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x5a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'song', 'wei', 'hong', 'wa', 'lou', 'ya', 'rao', 'jiao', 'luan', 'ping', 'xian', 'shao', 'li', 'cheng', 'xie', 'mang',
0x10 => 'fu', 'suo', 'mei', 'wei', 'ke', 'chuo', 'chuo', 'ting', 'niang', 'xing', 'nan', 'yu', 'na', 'pou', 'nei', 'juan',
0x20 => 'shen', 'zhi', 'han', 'di', 'zhuang', 'e', 'pin', 'tui', 'xian', 'mian', 'wu', 'yan', 'wu', 'ai', 'yan', 'yu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'nao', 'bao', 'ai', 'pi', 'pin', 'yi', 'piao', 'yu', 'lei', 'xuan', 'man', 'yi', 'zhang', 'kang', 'yong', 'ni',
0xE0 => 'li', 'di', 'gui', 'yan', 'jin', 'zhuan', 'chang', 'ze', 'han', 'nen', 'lao', 'mo', 'zhe', 'hu', 'hu', 'ao',
0xF0 => 'nen', 'qiang', 'ma', 'pie', 'gu', 'wu', 'qiao', 'tuo', 'zhan', 'mao', 'xian', 'xian', 'mo', 'liao', 'lian', 'hua',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x5b.php b/core/lib/Drupal/Component/Transliteration/data/x5b.php
index 8f6c4adffd5..0c6a1b42a1b 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x5b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x5b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'gui', 'deng', 'zhi', 'xu', 'yi', 'hua', 'xi', 'kui', 'rao', 'xi', 'yan', 'chan', 'jiao', 'mei', 'fan', 'fan',
0x10 => 'xian', 'yi', 'hui', 'jiao', 'fu', 'shi', 'bi', 'shan', 'sui', 'qiang', 'lian', 'huan', 'xin', 'niao', 'dong', 'yi',
0x20 => 'can', 'ai', 'niang', 'ning', 'ma', 'tiao', 'chou', 'jin', 'ci', 'yu', 'pin', 'rong', 'ru', 'nai', 'yan', 'tai',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'mei', 'qin', 'han', 'yu', 'shi', 'ning', 'jin', 'ning', 'zhi', 'yu', 'bao', 'kuan', 'ning', 'qin', 'mo', 'cha',
0xE0 => 'ju', 'gua', 'qin', 'hu', 'wu', 'liao', 'shi', 'ning', 'zhai', 'shen', 'wei', 'xie', 'kuan', 'hui', 'liao', 'jun',
0xF0 => 'huan', 'yi', 'yi', 'bao', 'qin', 'chong', 'bao', 'feng', 'cun', 'dui', 'si', 'xun', 'dao', 'lu', 'dui', 'shou',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x5c.php b/core/lib/Drupal/Component/Transliteration/data/x5c.php
index a4173f26b99..fd28352019e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x5c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x5c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'po', 'feng', 'zhuan', 'fu', 'she', 'ke', 'jiang', 'jiang', 'zhuan', 'wei', 'zun', 'xun', 'shu', 'dui', 'dao', 'xiao',
0x10 => 'jie', 'shao', 'er', 'er', 'er', 'ga', 'jian', 'shu', 'chen', 'shang', 'shang', 'mo', 'ga', 'chang', 'liao', 'xian',
0x20 => 'xian', 'kun', 'you', 'wang', 'you', 'liao', 'liao', 'yao', 'mang', 'wang', 'wang', 'wang', 'ga', 'yao', 'duo', 'kui',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'gai', 'quan', 'dong', 'yi', 'mu', 'shi', 'an', 'wei', 'huan', 'zhi', 'mi', 'li', 'ji', 'tong', 'wei', 'you',
0xE0 => 'gu', 'xia', 'li', 'yao', 'jiao', 'zheng', 'luan', 'jiao', 'e', 'e', 'yu', 'xie', 'bu', 'qiao', 'qun', 'feng',
0xF0 => 'feng', 'nao', 'li', 'you', 'xian', 'hong', 'dao', 'shen', 'cheng', 'tu', 'geng', 'jun', 'hao', 'xia', 'yin', 'yu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x5d.php b/core/lib/Drupal/Component/Transliteration/data/x5d.php
index f6e54155beb..bfa89e1aeac 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x5d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x5d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'lang', 'kan', 'lao', 'lai', 'xian', 'que', 'kong', 'chong', 'chong', 'ta', 'lin', 'hua', 'ju', 'lai', 'qi', 'min',
0x10 => 'kun', 'kun', 'zu', 'gu', 'cui', 'ya', 'ya', 'gang', 'lun', 'lun', 'leng', 'jue', 'duo', 'zheng', 'guo', 'yin',
0x20 => 'dong', 'han', 'zheng', 'wei', 'xiao', 'pi', 'yan', 'song', 'jie', 'beng', 'zu', 'ku', 'dong', 'zhan', 'gu', 'yin',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chao', 'cuan', 'luan', 'dian', 'dian', 'nie', 'yan', 'yan', 'yan', 'kui', 'yan', 'chuan', 'kuai', 'chuan', 'zhou', 'huang',
0xE0 => 'jing', 'xun', 'chao', 'chao', 'lie', 'gong', 'zuo', 'qiao', 'ju', 'gong', 'ju', 'wu', 'pu', 'pu', 'cha', 'qiu',
0xF0 => 'qiu', 'ji', 'yi', 'si', 'ba', 'zhi', 'zhao', 'xiang', 'yi', 'jin', 'xun', 'juan', 'ba', 'xun', 'jin', 'fu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x5e.php b/core/lib/Drupal/Component/Transliteration/data/x5e.php
index 75c829d2eae..5d02629d413 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x5e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x5e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'za', 'bi', 'shi', 'bu', 'ding', 'shuai', 'fan', 'nie', 'shi', 'fen', 'pa', 'zhi', 'xi', 'hu', 'dan', 'wei',
0x10 => 'zhang', 'tang', 'dai', 'mo', 'pei', 'pa', 'tie', 'bo', 'lian', 'zhi', 'zhou', 'bo', 'zhi', 'di', 'mo', 'yi',
0x20 => 'yi', 'ping', 'qia', 'juan', 'ru', 'shuai', 'dai', 'zheng', 'shui', 'qiao', 'zhen', 'shi', 'qun', 'xi', 'bang', 'dai',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jiu', 'jin', 'ao', 'kuo', 'lou', 'yin', 'liao', 'dai', 'lu', 'yi', 'chu', 'chan', 'tu', 'si', 'xin', 'miao',
0xE0 => 'chang', 'wu', 'fei', 'guang', 'ku', 'kuai', 'bi', 'qiang', 'xie', 'lin', 'lin', 'liao', 'lu', 'ji', 'ying', 'xian',
0xF0 => 'ting', 'yong', 'li', 'ting', 'yin', 'xun', 'yan', 'ting', 'di', 'pai', 'jian', 'hui', 'nai', 'hui', 'gong', 'nian',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x5f.php b/core/lib/Drupal/Component/Transliteration/data/x5f.php
index 675ad3ee69e..25fe4acd7b1 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x5f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x5f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'kai', 'bian', 'yi', 'qi', 'nong', 'fen', 'ju', 'yan', 'yi', 'zang', 'bi', 'yi', 'yi', 'er', 'san', 'shi',
0x10 => 'er', 'shi', 'shi', 'gong', 'diao', 'yin', 'hu', 'fu', 'hong', 'wu', 'tui', 'chi', 'jiang', 'ba', 'shen', 'di',
0x20 => 'zhang', 'jue', 'tao', 'fu', 'di', 'mi', 'xian', 'hu', 'chao', 'nu', 'jing', 'zhen', 'yi', 'mi', 'quan', 'wan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'tan', 'te', 'te', 'gan', 'qi', 'shi', 'cun', 'zhi', 'wang', 'mang', 'xi', 'fan', 'ying', 'tian', 'min', 'wen',
0xE0 => 'zhong', 'chong', 'wu', 'ji', 'wu', 'xi', 'jia', 'you', 'wan', 'cong', 'song', 'kuai', 'yu', 'bian', 'zhi', 'qi',
0xF0 => 'cui', 'chen', 'tai', 'tun', 'qian', 'nian', 'hun', 'xiong', 'niu', 'kuang', 'xian', 'xin', 'kang', 'hu', 'kai', 'fen',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x60.php b/core/lib/Drupal/Component/Transliteration/data/x60.php
index 8186748f436..27467cc9761 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x60.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x60.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'huai', 'tai', 'song', 'wu', 'ou', 'chang', 'chuang', 'ju', 'yi', 'bao', 'chao', 'min', 'pei', 'zuo', 'zen', 'yang',
0x10 => 'ju', 'ban', 'nu', 'nao', 'zheng', 'pa', 'bu', 'tie', 'hu', 'hu', 'ju', 'da', 'lian', 'si', 'chou', 'di',
0x20 => 'dai', 'yi', 'tu', 'you', 'fu', 'ji', 'peng', 'xing', 'yuan', 'ni', 'guai', 'fu', 'xi', 'bi', 'you', 'qie',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yu', 'huo', 'he', 'quan', 'tan', 'ti', 'ti', 'nie', 'wang', 'chuo', 'hu', 'hun', 'xi', 'chang', 'xin', 'wei',
0xE0 => 'hui', 'e', 'suo', 'zong', 'jian', 'yong', 'dian', 'ju', 'can', 'cheng', 'de', 'bei', 'qie', 'can', 'dan', 'guan',
0xF0 => 'duo', 'nao', 'yun', 'xiang', 'zhui', 'die', 'huang', 'chun', 'qiong', 're', 'xing', 'ce', 'bian', 'min', 'zong', 'ti',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x61.php b/core/lib/Drupal/Component/Transliteration/data/x61.php
index 21b7a80b226..9890aff4aac 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x61.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x61.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'qiao', 'chou', 'bei', 'xuan', 'wei', 'ge', 'qian', 'wei', 'yu', 'yu', 'bi', 'xuan', 'huan', 'min', 'bi', 'yi',
0x10 => 'mian', 'yong', 'kai', 'dang', 'yin', 'e', 'chen', 'mao', 'qia', 'ke', 'yu', 'ai', 'qie', 'yan', 'nuo', 'gan',
0x20 => 'yun', 'zong', 'sai', 'leng', 'fen', 'ying', 'kui', 'kui', 'que', 'gong', 'yun', 'su', 'su', 'qi', 'yao', 'song',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'huai', 'men', 'lan', 'ai', 'lin', 'yan', 'kuo', 'xia', 'chi', 'yu', 'yin', 'dai', 'meng', 'ai', 'meng', 'dui',
0xE0 => 'qi', 'mo', 'lan', 'men', 'chou', 'zhi', 'nuo', 'nuo', 'yan', 'yang', 'bo', 'zhi', 'kuang', 'kuang', 'you', 'fu',
0xF0 => 'liu', 'mie', 'cheng', 'hui', 'chan', 'meng', 'lan', 'huai', 'xuan', 'rang', 'chan', 'ji', 'ju', 'huan', 'she', 'yi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x62.php b/core/lib/Drupal/Component/Transliteration/data/x62.php
index 0de5674f2fa..9f2315bd412 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x62.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x62.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'lian', 'nan', 'mi', 'tang', 'jue', 'gang', 'gang', 'zhuang', 'ge', 'yue', 'wu', 'jian', 'xu', 'shu', 'rong', 'xi',
0x10 => 'cheng', 'wo', 'jie', 'ge', 'jian', 'qiang', 'huo', 'qiang', 'zhan', 'dong', 'qi', 'jia', 'die', 'zei', 'jia', 'ji',
0x20 => 'zhi', 'kan', 'ji', 'kui', 'gai', 'deng', 'zhan', 'qiang', 'ge', 'jian', 'jie', 'yu', 'jian', 'yan', 'lu', 'hu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'guai', 'qian', 'ju', 'ta', 'ba', 'tuo', 'tuo', 'ao', 'ju', 'zhuo', 'pan', 'zhao', 'bai', 'bai', 'di', 'ni',
0xE0 => 'ju', 'kuo', 'long', 'jian', 'qia', 'yong', 'lan', 'ning', 'bo', 'ze', 'qian', 'hen', 'kuo', 'shi', 'jie', 'zheng',
0xF0 => 'nin', 'gong', 'gong', 'quan', 'shuan', 'cun', 'za', 'kao', 'yi', 'xie', 'ce', 'hui', 'pin', 'zhuai', 'shi', 'na',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x63.php b/core/lib/Drupal/Component/Transliteration/data/x63.php
index 9108c93cc17..e74aa0feef7 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x63.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x63.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'bai', 'chi', 'gua', 'zhi', 'kuo', 'duo', 'duo', 'zhi', 'qie', 'an', 'nong', 'zhen', 'ge', 'jiao', 'kua', 'dong',
0x10 => 'na', 'tiao', 'lie', 'zha', 'lu', 'die', 'wa', 'jue', 'lie', 'ju', 'zhi', 'luan', 'ya', 'wo', 'ta', 'xie',
0x20 => 'nao', 'dang', 'jiao', 'zheng', 'ji', 'hui', 'xian', 'yu', 'ai', 'tuo', 'nuo', 'cuo', 'bo', 'geng', 'ti', 'zhen',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ti', 'nie', 'cha', 'shi', 'zong', 'zhen', 'yi', 'xun', 'yong', 'bian', 'yang', 'huan', 'yan', 'zan', 'an', 'xu',
0xE0 => 'ya', 'wo', 'ke', 'chuai', 'ji', 'ti', 'la', 'la', 'chen', 'kai', 'jiu', 'jiu', 'tu', 'jie', 'hui', 'gen',
0xF0 => 'chong', 'xiao', 'die', 'xie', 'yuan', 'qian', 'ye', 'cha', 'zha', 'bei', 'yao', 'wei', 'beng', 'lan', 'wen', 'qin',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x64.php b/core/lib/Drupal/Component/Transliteration/data/x64.php
index 68f1e0577c9..29e7caa6baa 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x64.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x64.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'chan', 'ge', 'lou', 'zong', 'geng', 'jiao', 'gou', 'qin', 'rong', 'que', 'chou', 'chuai', 'zhan', 'sun', 'sun', 'bo',
0x10 => 'chu', 'rong', 'bang', 'cuo', 'sao', 'ke', 'yao', 'dao', 'zhi', 'nu', 'la', 'jian', 'sou', 'qiu', 'gao', 'xian',
0x20 => 'shuo', 'sang', 'jin', 'mie', 'e', 'chui', 'nuo', 'shan', 'ta', 'zha', 'tang', 'pan', 'ban', 'da', 'li', 'tao',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'huan', 'jie', 'qin', 'kuai', 'dan', 'xie', 'ka', 'pi', 'bai', 'ao', 'ju', 'ye', 'e', 'meng', 'sou', 'mi',
0xE0 => 'ji', 'tai', 'zhuo', 'dao', 'xing', 'lan', 'ca', 'ju', 'ye', 'ru', 'ye', 'ye', 'ni', 'wo', 'ji', 'bin',
0xF0 => 'ning', 'ge', 'zhi', 'zhi', 'kuo', 'mo', 'jian', 'xie', 'lie', 'tan', 'bai', 'sou', 'lu', 'lue', 'rao', 'ti',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x65.php b/core/lib/Drupal/Component/Transliteration/data/x65.php
index ff100d4a02a..f8b74f82980 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x65.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x65.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'pan', 'yang', 'lei', 'ca', 'shu', 'zan', 'nian', 'xian', 'jun', 'huo', 'li', 'la', 'huan', 'ying', 'lu', 'long',
0x10 => 'qian', 'qian', 'zan', 'qian', 'lan', 'xian', 'ying', 'mei', 'rang', 'chan', 'ying', 'cuan', 'xie', 'she', 'luo', 'jun',
0x20 => 'mi', 'li', 'zan', 'luan', 'tan', 'zuan', 'li', 'dian', 'wa', 'dang', 'jiao', 'jue', 'lan', 'li', 'nang', 'zhi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zhao', 'yi', 'liu', 'shao', 'jian', 'yu', 'yi', 'qi', 'zhi', 'fan', 'piao', 'fan', 'zhan', 'kuai', 'sui', 'yu',
0xE0 => 'wu', 'ji', 'ji', 'ji', 'huo', 'ri', 'dan', 'jiu', 'zhi', 'zao', 'xie', 'tiao', 'xun', 'xu', 'ga', 'la',
0xF0 => 'gan', 'han', 'tai', 'di', 'xu', 'chan', 'shi', 'kuang', 'yang', 'shi', 'wang', 'min', 'min', 'tun', 'chun', 'wu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x66.php b/core/lib/Drupal/Component/Transliteration/data/x66.php
index edebef0e595..23aa7d42279 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x66.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x66.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yun', 'bei', 'ang', 'ze', 'ban', 'jie', 'kun', 'sheng', 'hu', 'fang', 'hao', 'gui', 'chang', 'xuan', 'ming', 'hun',
0x10 => 'fen', 'qin', 'hu', 'yi', 'xi', 'xin', 'yan', 'ze', 'fang', 'tan', 'shen', 'ju', 'yang', 'zan', 'bing', 'xing',
0x20 => 'ying', 'xuan', 'po', 'zhen', 'ling', 'chun', 'hao', 'mei', 'zuo', 'mo', 'bian', 'xu', 'hun', 'zhao', 'zong', 'shi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'xing', 'shen', 'jiao', 'bao', 'jing', 'yan', 'ai', 'ye', 'ru', 'shu', 'meng', 'xun', 'yao', 'pu', 'li', 'chen',
0xE0 => 'kuang', 'die', 'liao', 'yan', 'huo', 'lu', 'xi', 'rong', 'long', 'nang', 'luo', 'luan', 'shai', 'tang', 'yan', 'zhu',
0xF0 => 'yue', 'yue', 'qu', 'ye', 'geng', 'ye', 'hu', 'he', 'shu', 'cao', 'cao', 'sheng', 'man', 'ceng', 'ceng', 'ti',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x67.php b/core/lib/Drupal/Component/Transliteration/data/x67.php
index d0e5d1a8c16..2b5e33feb4e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x67.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x67.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'zui', 'can', 'xu', 'hui', 'yin', 'qie', 'fen', 'pi', 'yue', 'you', 'ruan', 'peng', 'fen', 'fu', 'ling', 'fei',
0x10 => 'qu', 'ti', 'nu', 'tiao', 'shuo', 'zhen', 'lang', 'lang', 'zui', 'ming', 'huang', 'wang', 'tun', 'chao', 'ji', 'qi',
0x20 => 'ying', 'zong', 'wang', 'tong', 'lang', 'lao', 'meng', 'long', 'mu', 'deng', 'wei', 'mo', 'ben', 'zha', 'shu', 'shu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'mou', 'gan', 'qi', 'ran', 'rou', 'mao', 'shao', 'song', 'zhe', 'xia', 'you', 'shen', 'gui', 'tuo', 'zha', 'nan',
0xE0 => 'ning', 'yong', 'di', 'zhi', 'zha', 'cha', 'dan', 'gu', 'bu', 'jiu', 'ao', 'fu', 'jian', 'ba', 'duo', 'ke',
0xF0 => 'nai', 'zhu', 'bi', 'liu', 'chai', 'shan', 'si', 'chu', 'pei', 'shi', 'guai', 'zha', 'yao', 'cheng', 'jiu', 'shi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x68.php b/core/lib/Drupal/Component/Transliteration/data/x68.php
index 84f94478693..39662ffa884 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x68.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x68.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'zhi', 'liu', 'mei', 'li', 'rong', 'zha', 'zao', 'biao', 'zhan', 'zhi', 'long', 'dong', 'lu', 'sheng', 'li', 'lan',
0x10 => 'yong', 'shu', 'xun', 'shuan', 'qi', 'zhen', 'qi', 'li', 'yi', 'xiang', 'zhen', 'li', 'se', 'gua', 'kan', 'ben',
0x20 => 'ren', 'xiao', 'bai', 'ren', 'bing', 'zi', 'chou', 'yi', 'ci', 'xu', 'zhu', 'jian', 'zui', 'er', 'er', 'you',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'fei', 'pai', 'bang', 'bang', 'hun', 'zong', 'cheng', 'zao', 'ji', 'li', 'peng', 'yu', 'yu', 'gu', 'jun', 'dong',
0xE0 => 'tang', 'gang', 'wang', 'di', 'cuo', 'fan', 'cheng', 'zhan', 'qi', 'yuan', 'yan', 'yu', 'quan', 'yi', 'sen', 'ren',
0xF0 => 'chui', 'leng', 'qi', 'zhuo', 'fu', 'ke', 'lai', 'zou', 'zou', 'zhao', 'guan', 'fen', 'fen', 'shen', 'qing', 'ni',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x69.php b/core/lib/Drupal/Component/Transliteration/data/x69.php
index fcc08f2819f..4d094cb61f8 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x69.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x69.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'wan', 'guo', 'lu', 'hao', 'jie', 'yi', 'chou', 'ju', 'ju', 'cheng', 'zuo', 'liang', 'qiang', 'zhi', 'chui', 'ya',
0x10 => 'ju', 'bei', 'jiao', 'zhuo', 'zi', 'bin', 'peng', 'ding', 'chu', 'chang', 'men', 'hua', 'jian', 'gui', 'xi', 'du',
0x20 => 'qian', 'dao', 'gui', 'dian', 'luo', 'zhi', 'quan', 'ming', 'fu', 'geng', 'peng', 'zhan', 'yi', 'tuo', 'sen', 'duo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'huai', 'mei', 'xu', 'gang', 'gao', 'zhuo', 'tuo', 'qiao', 'yang', 'dian', 'jia', 'kan', 'zui', 'dao', 'long', 'bin',
0xE0 => 'zhu', 'sang', 'xi', 'ji', 'lian', 'hui', 'yong', 'qian', 'guo', 'gai', 'gai', 'tuan', 'hua', 'qi', 'sen', 'cui',
0xF0 => 'peng', 'you', 'hu', 'jiang', 'hu', 'huan', 'gui', 'nie', 'yi', 'gao', 'kang', 'gui', 'gui', 'cao', 'man', 'jin',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x6a.php b/core/lib/Drupal/Component/Transliteration/data/x6a.php
index d5557b84392..4a34fa639c6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x6a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x6a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'di', 'zhuang', 'le', 'lang', 'chen', 'cong', 'li', 'xiu', 'qing', 'shuang', 'fan', 'tong', 'guan', 'ze', 'su', 'lei',
0x10 => 'lu', 'liang', 'mi', 'lou', 'chao', 'su', 'ke', 'chu', 'tang', 'biao', 'lu', 'jiu', 'zhe', 'zha', 'shu', 'zhang',
0x20 => 'man', 'mo', 'niao', 'yang', 'tiao', 'peng', 'zhu', 'sha', 'xi', 'quan', 'heng', 'jian', 'cong', 'ji', 'yan', 'qiang',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lei', 'lei', 'sa', 'lu', 'li', 'cuan', 'lu', 'mie', 'hui', 'ou', 'lu', 'zhi', 'gao', 'du', 'yuan', 'li',
0xE0 => 'fei', 'zhuo', 'sou', 'lian', 'jiang', 'chu', 'qing', 'zhu', 'lu', 'yan', 'li', 'zhu', 'chen', 'jie', 'e', 'su',
0xF0 => 'huai', 'nie', 'yu', 'long', 'lai', 'jiao', 'xian', 'gui', 'ju', 'xiao', 'ling', 'ying', 'jian', 'yin', 'you', 'ying',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x6b.php b/core/lib/Drupal/Component/Transliteration/data/x6b.php
index 98dbdd198a6..0df0329384a 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x6b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x6b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'xiang', 'nong', 'bo', 'chan', 'lan', 'ju', 'shuang', 'she', 'wei', 'cong', 'quan', 'qu', 'cang', 'jiu', 'yu', 'luo',
0x10 => 'li', 'cuan', 'luan', 'dang', 'jue', 'yan', 'lan', 'lan', 'zhu', 'lei', 'li', 'ba', 'nang', 'yu', 'ling', 'guang',
0x20 => 'qian', 'ci', 'huan', 'xin', 'yu', 'yi', 'qian', 'ou', 'xu', 'chao', 'chu', 'qi', 'kai', 'yi', 'jue', 'xi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ai', 'jie', 'du', 'yu', 'bi', 'bi', 'bi', 'pi', 'pi', 'bi', 'chan', 'mao', 'hao', 'cai', 'pi', 'lie',
0xE0 => 'jia', 'zhan', 'sai', 'mu', 'tuo', 'xun', 'er', 'rong', 'xian', 'ju', 'mu', 'hao', 'qiu', 'dou', 'sha', 'tan',
0xF0 => 'pei', 'ju', 'duo', 'cui', 'bi', 'san', 'san', 'mao', 'sai', 'shu', 'yu', 'tuo', 'he', 'jian', 'ta', 'san',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x6c.php b/core/lib/Drupal/Component/Transliteration/data/x6c.php
index 37501ff6187..52c6c42a3fe 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x6c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x6c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'lu', 'mu', 'mao', 'tong', 'rong', 'chang', 'pu', 'lu', 'zhan', 'sao', 'zhan', 'meng', 'lu', 'qu', 'die', 'shi',
0x10 => 'di', 'min', 'jue', 'mang', 'qi', 'pie', 'nai', 'qi', 'dao', 'xian', 'chuan', 'fen', 'yang', 'nei', 'bin', 'fu',
0x20 => 'shen', 'dong', 'qing', 'qi', 'yin', 'xi', 'hai', 'yang', 'an', 'ya', 'ke', 'qing', 'ya', 'dong', 'dan', 'lu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'le', 'you', 'gu', 'hong', 'gan', 'fa', 'mao', 'si', 'hu', 'ping', 'ci', 'fan', 'zhi', 'su', 'ning', 'cheng',
0xE0 => 'ling', 'pao', 'bo', 'qi', 'si', 'ni', 'ju', 'sa', 'zhu', 'sheng', 'lei', 'xuan', 'jue', 'fu', 'pan', 'min',
0xF0 => 'tai', 'yang', 'ji', 'yong', 'guan', 'beng', 'xue', 'long', 'lu', 'dan', 'luo', 'xie', 'po', 'ze', 'jing', 'yin',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x6d.php b/core/lib/Drupal/Component/Transliteration/data/x6d.php
index 7c0efb343bc..db015464a1c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x6d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x6d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'pan', 'jie', 'yi', 'hui', 'hui', 'zai', 'cheng', 'yin', 'wei', 'hou', 'jian', 'yang', 'lie', 'si', 'ji', 'er',
0x10 => 'xing', 'fu', 'sa', 'se', 'zhi', 'yin', 'wu', 'xi', 'kao', 'zhu', 'jiang', 'luo', 'luo', 'an', 'dong', 'ti',
0x20 => 'mou', 'lei', 'yi', 'mi', 'quan', 'jin', 'po', 'wei', 'xiao', 'xie', 'hong', 'xu', 'su', 'kuang', 'tao', 'qie',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chang', 'shu', 'qi', 'fang', 'zhi', 'lu', 'nao', 'ju', 'tao', 'cong', 'lei', 'zhe', 'ping', 'fei', 'song', 'tian',
0xE0 => 'pi', 'dan', 'yu', 'ni', 'yu', 'lu', 'gan', 'mi', 'jing', 'ling', 'lun', 'yin', 'cui', 'qu', 'huai', 'yu',
0xF0 => 'nian', 'shen', 'biao', 'chun', 'hu', 'yuan', 'lai', 'hun', 'qing', 'yan', 'qian', 'tian', 'miao', 'zhi', 'yin', 'mi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x6e.php b/core/lib/Drupal/Component/Transliteration/data/x6e.php
index 50c7e503da4..ea795fe9244 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x6e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x6e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ben', 'yuan', 'wen', 'ruo', 'fei', 'qing', 'yuan', 'ke', 'ji', 'she', 'yuan', 'se', 'lu', 'zi', 'du', 'qi',
0x10 => 'jian', 'mian', 'pi', 'xi', 'yu', 'yuan', 'shen', 'shen', 'rou', 'huan', 'zhu', 'jian', 'nuan', 'yu', 'qiu', 'ting',
0x20 => 'qu', 'du', 'fan', 'zha', 'bo', 'wo', 'wo', 'di', 'wei', 'wen', 'ru', 'xie', 'ce', 'wei', 'he', 'gang',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jie', 'hua', 'ge', 'zi', 'tao', 'teng', 'sui', 'bi', 'jiao', 'hui', 'gun', 'yin', 'gao', 'long', 'zhi', 'yan',
0xE0 => 'she', 'man', 'ying', 'chun', 'lu', 'lan', 'luan', 'xiao', 'bin', 'tan', 'yu', 'xiu', 'hu', 'bi', 'biao', 'zhi',
0xF0 => 'jiang', 'kou', 'shen', 'shang', 'di', 'mi', 'ao', 'lu', 'hu', 'hu', 'you', 'chan', 'fan', 'yong', 'gun', 'man',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x6f.php b/core/lib/Drupal/Component/Transliteration/data/x6f.php
index bcb08f819b4..1b63e5c949e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x6f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x6f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'qing', 'yu', 'piao', 'ji', 'ya', 'chao', 'qi', 'xi', 'ji', 'lu', 'lou', 'long', 'jin', 'guo', 'cong', 'lou',
0x10 => 'zhi', 'gai', 'qiang', 'li', 'yan', 'cao', 'jiao', 'cong', 'chun', 'tuan', 'ou', 'teng', 'ye', 'xi', 'mi', 'tang',
0x20 => 'mo', 'shang', 'han', 'lian', 'lan', 'wa', 'chi', 'gan', 'feng', 'xuan', 'yi', 'man', 'zi', 'mang', 'kang', 'luo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zhu', 'lai', 'bin', 'lian', 'mi', 'shi', 'shu', 'mi', 'ning', 'ying', 'ying', 'meng', 'jin', 'qi', 'bi', 'ji',
0xE0 => 'hao', 'ru', 'cui', 'wo', 'tao', 'yin', 'yin', 'dui', 'ci', 'huo', 'jing', 'lan', 'jun', 'ai', 'pu', 'zhuo',
0xF0 => 'wei', 'bin', 'gu', 'qian', 'ying', 'bin', 'kuo', 'fei', 'cang', 'me', 'jian', 'wei', 'luo', 'zan', 'lu', 'li',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x70.php b/core/lib/Drupal/Component/Transliteration/data/x70.php
index a04c26a87d0..6b837726d4a 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x70.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x70.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'you', 'yang', 'lu', 'si', 'zhi', 'ying', 'du', 'wang', 'hui', 'xie', 'pan', 'shen', 'biao', 'chan', 'mo', 'liu',
0x10 => 'jian', 'pu', 'se', 'cheng', 'gu', 'bin', 'huo', 'xian', 'lu', 'qin', 'han', 'ying', 'rong', 'li', 'jing', 'xiao',
0x20 => 'ying', 'sui', 'wei', 'xie', 'huai', 'xue', 'zhu', 'long', 'lai', 'dui', 'fan', 'hu', 'lai', 'shu', 'ling', 'ying',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zhou', 'yao', 'shi', 'wei', 'tong', 'mie', 'zai', 'kai', 'hong', 'lao', 'xia', 'zhu', 'xuan', 'zheng', 'po', 'yan',
0xE0 => 'hui', 'guang', 'che', 'hui', 'kao', 'chen', 'fan', 'shao', 'ye', 'hui', NULL, 'tang', 'jin', 're', 'lie', 'xi',
0xF0 => 'fu', 'jiong', 'xie', 'pu', 'ting', 'zhuo', 'ting', 'wan', 'hai', 'peng', 'lang', 'yan', 'xu', 'feng', 'chi', 'rong',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x71.php b/core/lib/Drupal/Component/Transliteration/data/x71.php
index bec4af6ae12..df33f2f01e2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x71.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x71.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'hu', 'xi', 'shu', 'he', 'xun', 'ku', 'juan', 'xiao', 'xi', 'yan', 'han', 'zhuang', 'jun', 'di', 'xie', 'ji',
0x10 => 'wu', 'yan', 'lu', 'han', 'yan', 'huan', 'men', 'ju', 'dao', 'bei', 'fen', 'lin', 'kun', 'hun', 'tun', 'xi',
0x20 => 'cui', 'wu', 'hong', 'chao', 'fu', 'wo', 'jiao', 'cong', 'feng', 'ping', 'qiong', 'ruo', 'xi', 'qiong', 'xin', 'chao',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lin', 'tong', 'shao', 'fen', 'fan', 'yan', 'xun', 'lan', 'mei', 'tang', 'yi', 'jing', 'men', 'jing', 'jiao', 'ying',
0xE0 => 'yu', 'yi', 'xue', 'lan', 'tai', 'zao', 'can', 'sui', 'xi', 'que', 'cong', 'lian', 'hui', 'zhu', 'xie', 'ling',
0xF0 => 'wei', 'yi', 'xie', 'zhao', 'hui', 'da', 'nong', 'lan', 'ru', 'xian', 'kao', 'xun', 'jin', 'chou', 'dao', 'yao',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x72.php b/core/lib/Drupal/Component/Transliteration/data/x72.php
index bea999b7df3..7a84a0c3852 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x72.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x72.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'he', 'lan', 'biao', 'rong', 'li', 'mo', 'bao', 'ruo', 'lu', 'la', 'ao', 'xun', 'kuang', 'shuo', 'liao', 'li',
0x10 => 'lu', 'jue', 'liao', 'yan', 'xi', 'xie', 'long', 'ye', 'can', 'rang', 'yue', 'lan', 'cong', 'jue', 'chong', 'guan',
0x20 => 'ju', 'che', 'mi', 'tang', 'lan', 'zhu', 'lan', 'ling', 'cuan', 'yu', 'zhao', 'zhao', 'pa', 'zheng', 'pao', 'cheng',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'hu', 'ling', 'fei', 'pi', 'ni', 'yao', 'you', 'gou', 'xue', 'ju', 'dan', 'bo', 'ku', 'xian', 'ning', 'huan',
0xE0 => 'hen', 'jiao', 'he', 'zhao', 'ji', 'xun', 'shan', 'ta', 'rong', 'shou', 'tong', 'lao', 'du', 'xia', 'shi', 'kuai',
0xF0 => 'zheng', 'yu', 'sun', 'yu', 'bi', 'mang', 'xi', 'juan', 'li', 'xia', 'yin', 'suan', 'lang', 'bei', 'zhi', 'yan',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x73.php b/core/lib/Drupal/Component/Transliteration/data/x73.php
index 237fe058e66..62f3521ff86 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x73.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x73.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'sha', 'li', 'han', 'xian', 'jing', 'pai', 'fei', 'xiao', 'bai', 'qi', 'ni', 'biao', 'yin', 'lai', 'lie', 'jian',
0x10 => 'qiang', 'kun', 'yan', 'guo', 'zong', 'mi', 'chang', 'yi', 'zhi', 'zheng', 'ya', 'meng', 'cai', 'cu', 'she', 'lie',
0x20 => 'dian', 'luo', 'hu', 'zong', 'gui', 'wei', 'feng', 'wo', 'yuan', 'xing', 'zhu', 'mao', 'wei', 'chuan', 'xian', 'tuan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'fa', 'long', 'jin', 'jiao', 'jian', 'li', 'guang', 'xian', 'zhou', 'gong', 'yan', 'xiu', 'yang', 'xu', 'luo', 'su',
0xE0 => 'zhu', 'qin', 'yin', 'xun', 'bao', 'er', 'xiang', 'yao', 'xia', 'hang', 'gui', 'chong', 'xu', 'ban', 'pei', 'lao',
0xF0 => 'dang', 'ying', 'hui', 'wen', 'e', 'cheng', 'di', 'wu', 'wu', 'cheng', 'jun', 'mei', 'bei', 'ting', 'xian', 'chu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x74.php b/core/lib/Drupal/Component/Transliteration/data/x74.php
index e94a71c0440..c7d14a4a351 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x74.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x74.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'han', 'xuan', 'yan', 'qiu', 'xuan', 'lang', 'li', 'xiu', 'fu', 'liu', 'ya', 'xi', 'ling', 'li', 'jin', 'lian',
0x10 => 'suo', 'suo', 'feng', 'wan', 'dian', 'pin', 'zhan', 'se', 'min', 'yu', 'ju', 'chen', 'lai', 'wen', 'sheng', 'wei',
0x20 => 'tian', 'chu', 'zuo', 'beng', 'cheng', 'hu', 'qi', 'e', 'kun', 'chang', 'qi', 'beng', 'wan', 'lu', 'cong', 'guan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lu', 'li', 'zan', 'lan', 'ying', 'mi', 'xiang', 'qiong', 'guan', 'dao', 'zan', 'huan', 'gua', 'bo', 'die', 'bo',
0xE0 => 'hu', 'zhi', 'piao', 'ban', 'rang', 'li', 'wa', 'Dekaguramu ', 'xiang', 'qian', 'ban', 'pen', 'fang', 'dan', 'weng', 'ou',
0xF0 => 'Deshiguramu ', 'Miriguramu ', 'wa', 'hu', 'ling', 'yi', 'ping', 'ci', 'bai', 'juan', 'chang', 'chi', 'Sarake ', 'dang', 'meng', 'bu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x75.php b/core/lib/Drupal/Component/Transliteration/data/x75.php
index fd88d444fea..5db5531a798 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x75.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x75.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'zhui', 'ping', 'bian', 'zhou', 'zhen', 'Senchigura ', 'ci', 'ying', 'qi', 'xian', 'lou', 'di', 'ou', 'meng', 'zhuan', 'beng',
0x10 => 'lin', 'zeng', 'wu', 'pi', 'dan', 'weng', 'ying', 'yan', 'gan', 'dai', 'shen', 'tian', 'tian', 'han', 'chang', 'sheng',
0x20 => 'qing', 'shen', 'chan', 'chan', 'rui', 'sheng', 'su', 'shen', 'yong', 'shuai', 'lu', 'fu', 'yong', 'beng', 'feng', 'ning',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'hui', 'tan', 'yang', 'chi', 'zhi', 'hen', 'ya', 'mei', 'dou', 'jing', 'xiao', 'tong', 'tu', 'mang', 'pi', 'xiao',
0xE0 => 'suan', 'fu', 'li', 'zhi', 'cuo', 'duo', 'wu', 'sha', 'lao', 'shou', 'huan', 'xian', 'yi', 'beng', 'zhang', 'guan',
0xF0 => 'tan', 'fei', 'ma', 'lin', 'chi', 'ji', 'tian', 'an', 'chi', 'bi', 'bi', 'min', 'gu', 'dui', 'e', 'wei',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x76.php b/core/lib/Drupal/Component/Transliteration/data/x76.php
index abfbd36d8a1..eb3eafa148c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x76.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x76.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yu', 'cui', 'ya', 'zhu', 'cu', 'dan', 'shen', 'zhong', 'chi', 'yu', 'hou', 'feng', 'la', 'yang', 'chen', 'tu',
0x10 => 'yu', 'guo', 'wen', 'huan', 'ku', 'jia', 'yin', 'yi', 'lou', 'sao', 'jue', 'chi', 'xi', 'guan', 'yi', 'wen',
0x20 => 'ji', 'chuang', 'ban', 'hui', 'liu', 'chai', 'shou', 'nue', 'dian', 'da', 'bie', 'tan', 'zhang', 'biao', 'shen', 'cu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yan', 'jian', 'he', 'yu', 'kui', 'fan', 'gai', 'dao', 'pan', 'fu', 'qiu', 'sheng', 'dao', 'lu', 'zhan', 'meng',
0xE0 => 'li', 'jin', 'xu', 'jian', 'pan', 'guan', 'an', 'lu', 'xu', 'zhou', 'dang', 'an', 'gu', 'li', 'mu', 'ding',
0xF0 => 'gan', 'xu', 'mang', 'wang', 'zhi', 'qi', 'yuan', 'tian', 'xiang', 'dun', 'xin', 'xi', 'pan', 'feng', 'dun', 'min',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x77.php b/core/lib/Drupal/Component/Transliteration/data/x77.php
index 6a6c4b985f3..ecde8bb8fd7 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x77.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x77.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ming', 'sheng', 'shi', 'yun', 'mian', 'pan', 'fang', 'miao', 'dan', 'mei', 'mao', 'kan', 'xian', 'kou', 'shi', 'yang',
0x10 => 'zheng', 'yao', 'shen', 'huo', 'da', 'zhen', 'kuang', 'ju', 'shen', 'yi', 'sheng', 'mei', 'mo', 'zhu', 'zhen', 'zhen',
0x20 => 'mian', 'shi', 'yuan', 'die', 'ni', 'zi', 'zi', 'chao', 'zha', 'xuan', 'bing', 'mi', 'long', 'sui', 'tong', 'mi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'huo', 'lu', 'meng', 'long', 'guan', 'man', 'xi', 'chu', 'tang', 'kan', 'zhu', 'mao', 'jin', 'lin', 'yu', 'shuo',
0xE0 => 'ze', 'jue', 'shi', 'yi', 'shen', 'zhi', 'hou', 'shen', 'ying', 'ju', 'zhou', 'jiao', 'cuo', 'duan', 'ai', 'jiao',
0xF0 => 'zeng', 'yue', 'ba', 'shi', 'ding', 'qi', 'ji', 'zi', 'gan', 'wu', 'zhe', 'ku', 'gang', 'xi', 'fan', 'kuang',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x78.php b/core/lib/Drupal/Component/Transliteration/data/x78.php
index b7e4041c095..c79005b68ff 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x78.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x78.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'dang', 'ma', 'sha', 'dan', 'jue', 'li', 'fu', 'min', 'e', 'huo', 'kang', 'zhi', 'qi', 'kan', 'jie', 'bin',
0x10 => 'e', 'ya', 'pi', 'zhe', 'yan', 'sui', 'zhuan', 'che', 'dun', 'pan', 'yan', 'jin', 'feng', 'fa', 'mo', 'zha',
0x20 => 'ju', 'yu', 'ke', 'tuo', 'tuo', 'di', 'zhai', 'zhen', 'e', 'fu', 'mu', 'zhu', 'la', 'bian', 'nu', 'ping',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'pan', 'wei', 'yun', 'dui', 'zhe', 'ke', 'la', 'zhuan', 'qing', 'gun', 'zhuan', 'chan', 'qi', 'ao', 'peng', 'liu',
0xE0 => 'lu', 'kan', 'chuang', 'chen', 'yin', 'lei', 'biao', 'qi', 'mo', 'qi', 'cui', 'zong', 'qing', 'chuo', 'lun', 'ji',
0xF0 => 'shan', 'lao', 'qu', 'zeng', 'deng', 'jian', 'xi', 'lin', 'ding', 'tan', 'huang', 'pan', 'za', 'qiao', 'di', 'li',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x79.php b/core/lib/Drupal/Component/Transliteration/data/x79.php
index 77915644f3d..babcfd2ff78 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x79.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x79.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'jian', 'jiao', 'xi', 'zhang', 'qiao', 'dun', 'jian', 'yu', 'zhui', 'he', 'ke', 'ze', 'lei', 'ke', 'chu', 'ye',
0x10 => 'que', 'dang', 'yi', 'jiang', 'pi', 'pi', 'yu', 'pin', 'e', 'ai', 'ke', 'jian', 'yu', 'ruan', 'meng', 'pao',
0x20 => 'ci', 'bo', 'yang', 'ma', 'ca', 'xian', 'kuang', 'lei', 'lei', 'zhi', 'li', 'li', 'fan', 'que', 'pao', 'ying',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yun', 'ke', 'miao', 'zhi', 'jing', 'bi', 'zhi', 'yu', 'mi', 'ku', 'ban', 'pi', 'ni', 'li', 'you', 'zu',
0xE0 => 'pi', 'bo', 'ling', 'mo', 'cheng', 'nian', 'qin', 'yang', 'zuo', 'zhi', 'zhi', 'shu', 'ju', 'zi', 'huo', 'ji',
0xF0 => 'cheng', 'tong', 'zhi', 'huo', 'he', 'yin', 'zi', 'zhi', 'jie', 'ren', 'du', 'yi', 'zhu', 'hui', 'nong', 'fu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x7a.php b/core/lib/Drupal/Component/Transliteration/data/x7a.php
index db12d9b369f..eebb25760a6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x7a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x7a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'xi', 'kao', 'lang', 'fu', 'xun', 'shui', 'lu', 'kun', 'gan', 'jing', 'ti', 'cheng', 'tu', 'shao', 'shui', 'ya',
0x10 => 'lun', 'lu', 'gu', 'zuo', 'ren', 'zhun', 'bang', 'bai', 'ji', 'zhi', 'zhi', 'kun', 'leng', 'peng', 'ke', 'bing',
0x20 => 'chou', 'zui', 'yu', 'su', 'lue', 'xiang', 'yi', 'xi', 'bian', 'ji', 'fu', 'pi', 'nuo', 'jie', 'zhong', 'zong',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chu', 'hong', 'qi', 'hao', 'sheng', 'fen', 'shu', 'miao', 'qu', 'zhan', 'zhu', 'ling', 'long', 'bing', 'jing', 'jing',
0xE0 => 'zhang', 'bai', 'si', 'jun', 'hong', 'tong', 'song', 'jing', 'diao', 'yi', 'shu', 'jing', 'qu', 'jie', 'ping', 'duan',
0xF0 => 'shao', 'zhuan', 'ceng', 'deng', 'cun', 'wai', 'jing', 'kan', 'jing', 'zhu', 'zhu', 'le', 'peng', 'yu', 'chi', 'gan',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x7b.php b/core/lib/Drupal/Component/Transliteration/data/x7b.php
index 9db59111a62..29d7b03450b 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x7b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x7b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'mang', 'zhu', 'wan', 'du', 'ji', 'xiao', 'ba', 'suan', 'ji', 'qin', 'zhao', 'sun', 'ya', 'zhui', 'yuan', 'hu',
0x10 => 'hang', 'xiao', 'cen', 'bi', 'bi', 'jian', 'yi', 'dong', 'shan', 'sheng', 'da', 'di', 'zhu', 'na', 'chi', 'gu',
0x20 => 'li', 'qie', 'min', 'bao', 'tiao', 'si', 'fu', 'ce', 'ben', 'pei', 'da', 'zi', 'di', 'ling', 'ze', 'nu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'gu', 'kui', 'shi', 'lou', 'yun', 'he', 'tang', 'yue', 'chou', 'gao', 'fei', 'ruo', 'zheng', 'gou', 'nie', 'qian',
0xE0 => 'xiao', 'cuan', 'long', 'peng', 'du', 'li', 'bi', 'zhuo', 'chu', 'shai', 'chi', 'zhu', 'qiang', 'long', 'lan', 'jian',
0xF0 => 'bu', 'li', 'hui', 'bi', 'di', 'cong', 'yan', 'peng', 'can', 'zhuan', 'pi', 'piao', 'dou', 'yu', 'mie', 'tuan',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x7c.php b/core/lib/Drupal/Component/Transliteration/data/x7c.php
index 49aa0a667c4..3fff1c7a02a 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x7c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x7c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ze', 'shai', 'gui', 'yi', 'hu', 'chan', 'kou', 'cu', 'ping', 'zao', 'ji', 'gui', 'su', 'lou', 'ce', 'lu',
0x10 => 'nian', 'suo', 'cuan', 'diao', 'suo', 'le', 'duan', 'liang', 'xiao', 'bo', 'mi', 'shai', 'dang', 'liao', 'dan', 'dian',
0x20 => 'fu', 'jian', 'min', 'kui', 'dai', 'jiao', 'deng', 'huang', 'sun', 'lao', 'zan', 'xiao', 'lu', 'shi', 'zan', 'qi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'fu', 'nuo', 'bei', 'gu', 'xiu', 'gao', 'tang', 'qiu', 'jia', 'cao', 'zhuang', 'tang', 'mi', 'san', 'fen', 'zao',
0xE0 => 'kang', 'jiang', 'mo', 'san', 'san', 'nuo', 'xi', 'liang', 'jiang', 'kuai', 'bo', 'huan', 'shu', 'zong', 'xian', 'nuo',
0xF0 => 'tuan', 'nie', 'li', 'zuo', 'di', 'nie', 'tiao', 'lan', 'mi', 'si', 'jiu', 'xi', 'gong', 'zheng', 'jiu', 'you',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x7d.php b/core/lib/Drupal/Component/Transliteration/data/x7d.php
index 1cfdab205f3..352293d3b51 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x7d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x7d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ji', 'cha', 'zhou', 'xun', 'yue', 'hong', 'yu', 'he', 'wan', 'ren', 'wen', 'wen', 'qiu', 'na', 'zi', 'tou',
0x10 => 'niu', 'fou', 'ji', 'shu', 'chun', 'pi', 'zhen', 'sha', 'hong', 'zhi', 'ji', 'fen', 'yun', 'ren', 'dan', 'jin',
0x20 => 'su', 'fang', 'suo', 'cui', 'jiu', 'za', 'ba', 'jin', 'fu', 'zhi', 'ci', 'zi', 'chou', 'hong', 'za', 'lei',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'fan', 'lu', 'xu', 'ying', 'shang', 'qi', 'xu', 'xiang', 'jian', 'ke', 'xian', 'ruan', 'mian', 'ji', 'duan', 'chong',
0xE0 => 'di', 'min', 'miao', 'yuan', 'xie', 'bao', 'si', 'qiu', 'bian', 'huan', 'geng', 'cong', 'mian', 'wei', 'fu', 'wei',
0xF0 => 'tou', 'gou', 'miao', 'xie', 'lian', 'zong', 'bian', 'yun', 'yin', 'ti', 'gua', 'zhi', 'yun', 'cheng', 'chan', 'dai',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x7e.php b/core/lib/Drupal/Component/Transliteration/data/x7e.php
index e66acc5bbab..a278c2d1911 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x7e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x7e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'xia', 'yuan', 'zong', 'xu', 'ying', 'wei', 'geng', 'xuan', 'ying', 'jin', 'yi', 'zhui', 'ni', 'bang', 'gu', 'pan',
0x10 => 'zhou', 'jian', 'ci', 'quan', 'shuang', 'yun', 'xia', 'cui', 'xi', 'rong', 'tao', 'fu', 'yun', 'chen', 'gao', 'ru',
0x20 => 'hu', 'zai', 'teng', 'xian', 'su', 'zhen', 'zong', 'tao', 'huang', 'cai', 'bi', 'feng', 'cu', 'li', 'suo', 'yan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'dai', 'bang', 'rong', 'jie', 'ku', 'rao', 'die', 'hang', 'hui', 'gei', 'xuan', 'jiang', 'luo', 'jue', 'jiao', 'tong',
0xE0 => 'geng', 'xiao', 'juan', 'xiu', 'xi', 'sui', 'tao', 'ji', 'ti', 'ji', 'xu', 'ling', 'ying', 'xu', 'qi', 'fei',
0xF0 => 'chuo', 'shang', 'gun', 'sheng', 'wei', 'mian', 'shou', 'beng', 'chou', 'tao', 'liu', 'quan', 'zong', 'zhan', 'wan', 'lu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x7f.php b/core/lib/Drupal/Component/Transliteration/data/x7f.php
index 7f586dd1305..78e32434d55 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x7f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x7f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'zhui', 'zi', 'ke', 'xiang', 'jian', 'mian', 'lan', 'ti', 'miao', 'ji', 'yun', 'hui', 'si', 'duo', 'duan', 'bian',
0x10 => 'xian', 'gou', 'zhui', 'huan', 'di', 'lu', 'bian', 'min', 'yuan', 'jin', 'fu', 'ru', 'zhen', 'feng', 'cui', 'gao',
0x20 => 'chan', 'li', 'yi', 'jian', 'bin', 'piao', 'man', 'lei', 'ying', 'suo', 'mou', 'sao', 'xie', 'liao', 'shan', 'zeng',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zhi', 'qu', 'xi', 'xie', 'xiang', 'xi', 'xi', 'ke', 'qiao', 'hui', 'hui', 'xiao', 'sha', 'hong', 'jiang', 'di',
0xE0 => 'cui', 'fei', 'dao', 'sha', 'chi', 'zhu', 'jian', 'xuan', 'chi', 'pian', 'zong', 'wan', 'hui', 'hou', 'he', 'he',
0xF0 => 'han', 'ao', 'piao', 'yi', 'lian', 'hou', 'ao', 'lin', 'pen', 'qiao', 'ao', 'fan', 'yi', 'hui', 'xuan', 'dao',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x80.php b/core/lib/Drupal/Component/Transliteration/data/x80.php
index 33b80ca7481..0cbf2aae141 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x80.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x80.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yao', 'lao', 'lao', 'kao', 'mao', 'zhe', 'qi', 'gou', 'gou', 'gou', 'die', 'die', 'er', 'shua', 'ruan', 'nai',
0x10 => 'nai', 'duan', 'lei', 'ting', 'zi', 'geng', 'chao', 'hao', 'yun', 'ba', 'pi', 'yi', 'si', 'qu', 'jia', 'ju',
0x20 => 'huo', 'chu', 'lao', 'lun', 'ji', 'tang', 'ou', 'lou', 'nou', 'jiang', 'pang', 'zha', 'lou', 'ji', 'lao', 'huo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ku', 'zhi', 'ni', 'ping', 'zi', 'fu', 'pang', 'zhen', 'xian', 'zuo', 'pei', 'jia', 'sheng', 'zhi', 'bao', 'mu',
0xE0 => 'qu', 'hu', 'ke', 'chi', 'yin', 'xu', 'yang', 'long', 'dong', 'ka', 'lu', 'jing', 'nu', 'yan', 'pang', 'kua',
0xF0 => 'yi', 'guang', 'hai', 'ge', 'dong', 'chi', 'jiao', 'xiong', 'xiong', 'er', 'an', 'heng', 'pian', 'neng', 'zi', 'gui',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x81.php b/core/lib/Drupal/Component/Transliteration/data/x81.php
index 81fb4245e82..dd5afc1e552 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x81.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x81.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'cheng', 'tiao', 'zhi', 'cui', 'mei', 'xie', 'cui', 'xie', 'mai', 'mai', 'ji', 'xie', 'nin', 'kuai', 'sa', 'zang',
0x10 => 'qi', 'nao', 'mi', 'nong', 'luan', 'wan', 'bo', 'wen', 'wan', 'xiu', 'jiao', 'jing', 'you', 'heng', 'cuo', 'lie',
0x20 => 'shan', 'ting', 'mei', 'chun', 'shen', 'qian', 'de', 'juan', 'cu', 'xiu', 'xin', 'tuo', 'pao', 'cheng', 'nei', 'pu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'xun', 'nao', 'wo', 'zang', 'xian', 'biao', 'xing', 'kuan', 'la', 'yan', 'lu', 'huo', 'za', 'luo', 'qu', 'zang',
0xE0 => 'luan', 'ni', 'za', 'chen', 'qian', 'wo', 'guang', 'zang', 'lin', 'guang', 'zi', 'jiao', 'nie', 'chou', 'ji', 'gao',
0xF0 => 'chou', 'mian', 'nie', 'zhi', 'zhi', 'ge', 'jian', 'die', 'zhi', 'xiu', 'tai', 'zhen', 'jiu', 'xian', 'yu', 'cha',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x82.php b/core/lib/Drupal/Component/Transliteration/data/x82.php
index 101305755cb..415fdb5752d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x82.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x82.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yao', 'yu', 'chong', 'xi', 'xi', 'jiu', 'yu', 'yu', 'xing', 'ju', 'jiu', 'xin', 'she', 'she', 'she', 'jiu',
0x10 => 'shi', 'tan', 'shu', 'shi', 'tian', 'tan', 'pu', 'pu', 'guan', 'hua', 'tian', 'chuan', 'shun', 'xia', 'wu', 'zhou',
0x20 => 'dao', 'chuan', 'shan', 'yi', 'fan', 'pa', 'tai', 'fan', 'ban', 'chuan', 'hang', 'fang', 'ban', 'bi', 'lu', 'zhong',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ti', 'yuan', 'ran', 'ling', 'tai', 'shao', 'di', 'miao', 'qing', 'li', 'yong', 'ke', 'mu', 'bei', 'bao', 'gou',
0xE0 => 'min', 'yi', 'yi', 'ju', 'pie', 'ruo', 'ku', 'ning', 'ni', 'bo', 'bing', 'shan', 'xiu', 'yao', 'xian', 'ben',
0xF0 => 'hong', 'ying', 'zha', 'dong', 'ju', 'die', 'nie', 'gan', 'hu', 'ping', 'mei', 'fu', 'sheng', 'gu', 'bi', 'wei',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x83.php b/core/lib/Drupal/Component/Transliteration/data/x83.php
index 0c2a631772e..73fe3fc662d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x83.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x83.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'fu', 'zhuo', 'mao', 'fan', 'jia', 'mao', 'mao', 'ba', 'ci', 'mo', 'zi', 'di', 'chi', 'ji', 'jing', 'long',
0x10 => 'cong', 'niao', 'yuan', 'xue', 'ying', 'qiong', 'ge', 'ming', 'li', 'rong', 'yin', 'gen', 'qian', 'chai', 'chen', 'yu',
0x20 => 'hao', 'zi', 'lie', 'wu', 'ji', 'gui', 'ci', 'jian', 'ci', 'gou', 'guang', 'mang', 'cha', 'jiao', 'jiao', 'fu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'pu', 'zai', 'gao', 'guo', 'fu', 'lun', 'chang', 'chou', 'song', 'chui', 'zhan', 'men', 'cai', 'ba', 'li', 'tu',
0xE0 => 'bo', 'han', 'bao', 'qin', 'juan', 'xi', 'qin', 'di', 'jie', 'pu', 'dang', 'jin', 'qiao', 'tai', 'geng', 'hua',
0xF0 => 'gu', 'ling', 'fei', 'qin', 'an', 'wang', 'beng', 'zhou', 'yan', 'ju', 'jian', 'lin', 'tan', 'shu', 'tian', 'dao',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x84.php b/core/lib/Drupal/Component/Transliteration/data/x84.php
index 68399790454..4714535b7f8 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x84.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x84.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'hu', 'qi', 'he', 'cui', 'tao', 'chun', 'bi', 'chang', 'huan', 'fei', 'lai', 'qi', 'meng', 'ping', 'wei', 'dan',
0x10 => 'sha', 'huan', 'yan', 'yi', 'tiao', 'qi', 'wan', 'ce', 'nai', 'zhen', 'tuo', 'jiu', 'tie', 'luo', 'bi', 'yi',
0x20 => 'meng', 'bo', 'pao', 'ding', 'ying', 'ying', 'ying', 'xiao', 'sa', 'qiu', 'ke', 'xiang', 'wan', 'yu', 'yu', 'fu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ru', 'suo', 'xuan', 'bei', 'yao', 'gui', 'bi', 'zong', 'gun', 'zuo', 'tiao', 'ce', 'pei', 'lan', 'dan', 'ji',
0xE0 => 'li', 'shen', 'lang', 'yu', 'ling', 'ying', 'mo', 'diao', 'tiao', 'mao', 'tong', 'chu', 'peng', 'an', 'lian', 'cong',
0xF0 => 'xi', 'ping', 'qiu', 'jin', 'chun', 'jie', 'wei', 'tui', 'cao', 'yu', 'yi', 'zi', 'liao', 'bi', 'lu', 'xu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x85.php b/core/lib/Drupal/Component/Transliteration/data/x85.php
index 7fb87f17ecd..a5e4cd512ad 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x85.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x85.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'bu', 'zhang', 'lei', 'qiang', 'man', 'yan', 'ling', 'ji', 'biao', 'gun', 'han', 'di', 'su', 'lu', 'she', 'shang',
0x10 => 'di', 'mie', 'xun', 'man', 'bo', 'di', 'cuo', 'zhe', 'shen', 'xuan', 'wei', 'hu', 'ao', 'mi', 'lou', 'cu',
0x20 => 'zhong', 'cai', 'po', 'jiang', 'mi', 'cong', 'niao', 'hui', 'juan', 'yin', 'jian', 'nian', 'shu', 'yin', 'guo', 'chen',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'miao', 'qiong', 'qie', 'xian', 'liao', 'ou', 'xian', 'su', 'lu', 'yi', 'xu', 'xie', 'li', 'yi', 'la', 'lei',
0xE0 => 'jiao', 'di', 'zhi', 'bei', 'teng', 'yao', 'mo', 'huan', 'biao', 'fan', 'sou', 'tan', 'tui', 'qiong', 'qiao', 'wei',
0xF0 => 'liu', 'hui', 'ou', 'gao', 'yun', 'bao', 'li', 'shu', 'chu', 'ai', 'lin', 'zao', 'xuan', 'qin', 'lai', 'huo',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x86.php b/core/lib/Drupal/Component/Transliteration/data/x86.php
index 8615a1d20ac..285c2d12cc1 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x86.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x86.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'tuo', 'wu', 'rui', 'rui', 'qi', 'heng', 'lu', 'su', 'tui', 'meng', 'yun', 'ping', 'yu', 'xun', 'ji', 'jiong',
0x10 => 'xuan', 'mo', 'qiu', 'su', 'jiong', 'feng', 'nie', 'bo', 'rang', 'yi', 'xian', 'yu', 'ju', 'lian', 'lian', 'yin',
0x20 => 'qiang', 'ying', 'long', 'tou', 'wei', 'yue', 'ling', 'qu', 'yao', 'fan', 'mei', 'han', 'kui', 'lan', 'ji', 'dang',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'qu', 'mou', 'ge', 'ci', 'hui', 'hui', 'mang', 'fu', 'yang', 'wa', 'lie', 'zhu', 'yi', 'xian', 'kuo', 'jiao',
0xE0 => 'li', 'yi', 'ping', 'qi', 'ha', 'she', 'yi', 'wang', 'mo', 'qiong', 'qie', 'gui', 'qiong', 'zhi', 'man', 'lao',
0xF0 => 'zhe', 'jia', 'nao', 'si', 'qi', 'xing', 'jie', 'qiu', 'shao', 'yong', 'jia', 'tui', 'che', 'bai', 'e', 'han',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x87.php b/core/lib/Drupal/Component/Transliteration/data/x87.php
index be4f2270512..c9a1208674d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x87.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x87.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'shu', 'xuan', 'feng', 'shen', 'shen', 'fu', 'xian', 'zhe', 'wu', 'fu', 'li', 'lang', 'bi', 'chu', 'yuan', 'you',
0x10 => 'jie', 'dan', 'yan', 'ting', 'dian', 'tui', 'hui', 'wo', 'zhi', 'song', 'fei', 'ju', 'mi', 'qi', 'qi', 'yu',
0x20 => 'jun', 'la', 'meng', 'qiang', 'si', 'xi', 'lun', 'li', 'die', 'tiao', 'tao', 'kun', 'han', 'han', 'yu', 'bang',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chang', 'zhang', 'mang', 'xiang', 'mo', 'zui', 'si', 'qiu', 'te', 'zhi', 'peng', 'peng', 'jiao', 'qu', 'bie', 'liao',
0xE0 => 'pan', 'gui', 'xi', 'ji', 'zhuan', 'huang', 'fei', 'lao', 'jue', 'jue', 'hui', 'yin', 'chan', 'jiao', 'shan', 'nao',
0xF0 => 'xiao', 'wu', 'chong', 'xun', 'si', 'chu', 'cheng', 'dang', 'li', 'xie', 'shan', 'yi', 'jing', 'da', 'chan', 'qi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x88.php b/core/lib/Drupal/Component/Transliteration/data/x88.php
index 88430602638..45feb58f55d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x88.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x88.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ci', 'xiang', 'she', 'luo', 'qin', 'ying', 'chai', 'li', 'zei', 'xuan', 'lian', 'zhu', 'ze', 'xie', 'mang', 'xie',
0x10 => 'qi', 'rong', 'jian', 'meng', 'hao', 'ru', 'huo', 'zhuo', 'jie', 'pin', 'he', 'mie', 'fan', 'lei', 'jie', 'la',
0x20 => 'min', 'li', 'chun', 'li', 'qiu', 'nie', 'lu', 'du', 'xiao', 'zhu', 'long', 'li', 'long', 'feng', 'ye', 'beng',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'juan', 'shen', 'pou', 'ge', 'yi', 'yu', 'zhen', 'liu', 'qiu', 'qun', 'ji', 'yi', 'bu', 'zhuang', 'shui', 'sha',
0xE0 => 'qun', 'li', 'lian', 'lian', 'ku', 'jian', 'fou', 'chan', 'bi', 'kun', 'tao', 'yuan', 'ling', 'chi', 'chang', 'chou',
0xF0 => 'duo', 'biao', 'liang', 'shang', 'pei', 'pei', 'fei', 'yuan', 'luo', 'guo', 'yan', 'du', 'ti', 'zhi', 'ju', 'yi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x89.php b/core/lib/Drupal/Component/Transliteration/data/x89.php
index 05049636258..fbef66d8ce8 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x89.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x89.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ji', 'zhi', 'gua', 'ken', 'qi', 'ti', 'ti', 'fu', 'chong', 'xie', 'bian', 'die', 'kun', 'duan', 'xiu', 'xiu',
0x10 => 'he', 'yuan', 'bao', 'bao', 'fu', 'yu', 'tuan', 'yan', 'hui', 'bei', 'chu', 'lu', 'pao', 'dan', 'yun', 'ta',
0x20 => 'gou', 'da', 'huai', 'rong', 'yuan', 'ru', 'nai', 'jiong', 'suo', 'ban', 'tui', 'chi', 'sang', 'niao', 'ying', 'jie',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jin', 'qu', 'jiao', 'qiu', 'jin', 'cu', 'jue', 'zhi', 'chao', 'ji', 'gu', 'dan', 'zi', 'di', 'shang', 'hua',
0xE0 => 'quan', 'ge', 'shi', 'jie', 'gui', 'gong', 'chu', 'jie', 'hun', 'qiu', 'xing', 'su', 'ni', 'ji', 'lu', 'zhi',
0xF0 => 'zha', 'bi', 'xing', 'hu', 'shang', 'gong', 'zhi', 'xue', 'chu', 'xi', 'yi', 'li', 'jue', 'xi', 'yan', 'xi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x8a.php b/core/lib/Drupal/Component/Transliteration/data/x8a.php
index 111894c1200..03abb6687a5 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x8a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x8a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yan', 'yan', 'ding', 'fu', 'qiu', 'qiu', 'jiao', 'hong', 'ji', 'fan', 'xun', 'diao', 'hong', 'chai', 'tao', 'xu',
0x10 => 'jie', 'yi', 'ren', 'xun', 'yin', 'shan', 'qi', 'tuo', 'ji', 'xun', 'yin', 'e', 'fen', 'ya', 'yao', 'song',
0x20 => 'shen', 'yin', 'xin', 'jue', 'xiao', 'ne', 'chen', 'you', 'zhi', 'xiong', 'fang', 'xin', 'chao', 'she', 'xian', 'sa',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'qian', 'zhuo', 'liang', 'jian', 'chu', 'hao', 'lun', 'shen', 'biao', 'huai', 'pian', 'yu', 'die', 'xu', 'pian', 'shi',
0xE0 => 'xuan', 'shi', 'hun', 'hua', 'e', 'zhong', 'di', 'xie', 'fu', 'pu', 'ting', 'jian', 'qi', 'yu', 'zi', 'zhuan',
0xF0 => 'xi', 'hui', 'yin', 'an', 'xian', 'nan', 'chen', 'feng', 'zhu', 'yang', 'yan', 'huang', 'xuan', 'ge', 'nuo', 'qi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x8b.php b/core/lib/Drupal/Component/Transliteration/data/x8b.php
index 0a535f724e5..2cdc115ef51 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x8b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x8b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'mou', 'ye', 'wei', 'xing', 'teng', 'zhou', 'shan', 'jian', 'po', 'kui', 'huang', 'huo', 'ge', 'ying', 'mi', 'xiao',
0x10 => 'mi', 'xi', 'qiang', 'chen', 'xue', 'ti', 'su', 'bang', 'chi', 'qian', 'shi', 'jiang', 'yuan', 'xie', 'he', 'tao',
0x20 => 'yao', 'yao', 'zhi', 'yu', 'biao', 'cong', 'qing', 'li', 'mo', 'mo', 'shang', 'zhe', 'miu', 'jian', 'ze', 'jie',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'bi', 'yi', 'yi', 'kuang', 'lei', 'shi', 'gua', 'shi', 'ji', 'hui', 'cheng', 'zhu', 'shen', 'hua', 'dan', 'gou',
0xE0 => 'quan', 'gui', 'xun', 'yi', 'zheng', 'gai', 'xiang', 'cha', 'hun', 'xu', 'zhou', 'jie', 'wu', 'yu', 'qiao', 'wu',
0xF0 => 'gao', 'you', 'hui', 'kuang', 'shuo', 'song', 'ei', 'qing', 'zhu', 'zou', 'nuo', 'du', 'zhuo', 'fei', 'ke', 'wei',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x8c.php b/core/lib/Drupal/Component/Transliteration/data/x8c.php
index 5e805ad21af..8b3d3baaee9 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x8c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x8c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yu', 'shui', 'shen', 'diao', 'chan', 'liang', 'zhun', 'sui', 'tan', 'shen', 'yi', 'mou', 'chen', 'die', 'huang', 'jian',
0x10 => 'xie', 'xue', 'ye', 'wei', 'e', 'yu', 'xuan', 'chan', 'zi', 'an', 'yan', 'di', 'mi', 'pian', 'xu', 'mo',
0x20 => 'dang', 'su', 'xie', 'yao', 'bang', 'shi', 'qian', 'mi', 'jin', 'man', 'zhe', 'jian', 'miu', 'tan', 'zen', 'qiao',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'xun', 'zhen', 'she', 'bin', 'bin', 'qiu', 'she', 'chuan', 'zang', 'zhou', 'lai', 'zan', 'ci', 'chen', 'shang', 'tian',
0xE0 => 'pei', 'geng', 'xian', 'mai', 'jian', 'sui', 'fu', 'tan', 'cong', 'cong', 'zhi', 'ji', 'zhang', 'du', 'jin', 'xiong',
0xF0 => 'chun', 'yun', 'bao', 'zai', 'lai', 'feng', 'cang', 'ji', 'sheng', 'yi', 'zhuan', 'fu', 'gou', 'sai', 'ze', 'liao',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x8d.php b/core/lib/Drupal/Component/Transliteration/data/x8d.php
index c4b8695158e..07fc8d7fa38 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x8d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x8d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yi', 'bai', 'chen', 'wan', 'zhi', 'zhui', 'biao', 'yun', 'zeng', 'dan', 'zan', 'yan', 'pu', 'shan', 'wan', 'ying',
0x10 => 'jin', 'gan', 'xian', 'zang', 'bi', 'du', 'shu', 'yan', 'shang', 'xuan', 'long', 'gan', 'zang', 'bei', 'zhen', 'fu',
0x20 => 'yuan', 'gong', 'cai', 'ze', 'xian', 'bai', 'zhang', 'huo', 'zhi', 'fan', 'tan', 'pin', 'bian', 'gou', 'zhu', 'guan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ci', 'pao', 'qia', 'zhu', 'ju', 'dian', 'zhi', 'fu', 'pan', 'ju', 'shan', 'bo', 'ni', 'ju', 'li', 'gen',
0xE0 => 'yi', 'ji', 'duo', 'xian', 'jiao', 'duo', 'zhu', 'quan', 'kua', 'zhuai', 'gui', 'qiong', 'kui', 'xiang', 'chi', 'lu',
0xF0 => 'pian', 'zhi', 'jia', 'tiao', 'cai', 'jian', 'ta', 'qiao', 'bi', 'xian', 'duo', 'ji', 'ju', 'ji', 'shu', 'tu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x8e.php b/core/lib/Drupal/Component/Transliteration/data/x8e.php
index 80ef740c93a..c48ec1da8c1 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x8e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x8e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'chu', 'jing', 'nie', 'xiao', 'bu', 'xue', 'cun', 'mu', 'shu', 'liang', 'yong', 'jiao', 'chou', 'qiao', 'mou', 'ta',
0x10 => 'jian', 'qi', 'wo', 'wei', 'chuo', 'jie', 'ji', 'nie', 'ju', 'ju', 'lun', 'lu', 'leng', 'huai', 'ju', 'chi',
0x20 => 'wan', 'quan', 'ti', 'bo', 'zu', 'qie', 'yi', 'cu', 'zong', 'cai', 'zong', 'peng', 'zhi', 'zheng', 'dian', 'zhi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'xin', 'dai', 'xuan', 'fan', 'ren', 'shan', 'kuang', 'shu', 'tun', 'chen', 'dai', 'e', 'na', 'qi', 'mao', 'ruan',
0xE0 => 'ren', 'qian', 'zhuan', 'hong', 'hu', 'qu', 'kuang', 'di', 'ling', 'dai', 'ao', 'zhen', 'fan', 'kuang', 'yang', 'peng',
0xF0 => 'bei', 'gu', 'gu', 'pao', 'zhu', 'rong', 'e', 'ba', 'zhou', 'zhi', 'yao', 'ke', 'yi', 'zhi', 'shi', 'ping',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x8f.php b/core/lib/Drupal/Component/Transliteration/data/x8f.php
index a4cd21b3a10..e7185a9c002 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x8f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x8f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'er', 'gong', 'ju', 'jiao', 'guang', 'he', 'kai', 'quan', 'zhou', 'zai', 'zhi', 'she', 'liang', 'yu', 'shao', 'you',
0x10 => 'wan', 'yin', 'zhe', 'wan', 'fu', 'qing', 'zhou', 'ni', 'leng', 'zhe', 'zhan', 'liang', 'zi', 'hui', 'wang', 'chuo',
0x20 => 'guo', 'kan', 'yi', 'peng', 'qian', 'gun', 'nian', 'ping', 'guan', 'bei', 'lun', 'pai', 'liang', 'ruan', 'rou', 'ji',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yun', 'jin', 'hang', 'ya', 'fan', 'wu', 'da', 'e', 'hai', 'zhe', 'zhong', 'jin', 'yuan', 'wei', 'lian', 'chi',
0xE0 => 'che', 'ni', 'tiao', 'zhi', 'yi', 'jiong', 'jia', 'chen', 'dai', 'er', 'di', 'po', 'zhu', 'die', 'ze', 'tao',
0xF0 => 'shu', 'tuo', 'qu', 'jing', 'hui', 'dong', 'you', 'mi', 'beng', 'ji', 'nai', 'yi', 'jie', 'zhui', 'lie', 'xun',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x90.php b/core/lib/Drupal/Component/Transliteration/data/x90.php
index e2a817ba73d..97821c45219 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x90.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x90.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'tui', 'song', 'shi', 'tao', 'pang', 'hou', 'ni', 'dun', 'jiong', 'xuan', 'xun', 'bu', 'you', 'xiao', 'qiu', 'tou',
0x10 => 'zhu', 'qiu', 'di', 'di', 'tu', 'jing', 'ti', 'dou', 'yi', 'zhe', 'tong', 'guang', 'wu', 'shi', 'cheng', 'su',
0x20 => 'zao', 'qun', 'feng', 'lian', 'suo', 'hui', 'li', 'gu', 'lai', 'ben', 'cuo', 'jue', 'beng', 'huan', 'dai', 'lu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'kuai', 'zheng', 'lang', 'yun', 'yan', 'cheng', 'dou', 'xi', 'lu', 'fu', 'wu', 'fu', 'gao', 'hao', 'lang', 'jia',
0xE0 => 'geng', 'jun', 'ying', 'bo', 'xi', 'bei', 'li', 'yun', 'bu', 'xiao', 'qi', 'pi', 'qing', 'guo', 'zhou', 'tan',
0xF0 => 'zou', 'ping', 'lai', 'ni', 'chen', 'you', 'bu', 'xiang', 'dan', 'ju', 'yong', 'qiao', 'yi', 'dou', 'yan', 'mei',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x91.php b/core/lib/Drupal/Component/Transliteration/data/x91.php
index 2de4466a464..4f10582664b 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x91.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x91.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ruo', 'bei', 'e', 'shu', 'juan', 'yu', 'yun', 'hou', 'kui', 'xiang', 'xiang', 'sou', 'tang', 'ming', 'xi', 'ru',
0x10 => 'chu', 'zi', 'zou', 'ye', 'wu', 'xiang', 'yun', 'hao', 'yong', 'bi', 'mao', 'chao', 'fu', 'liao', 'yin', 'zhuan',
0x20 => 'hu', 'qiao', 'yan', 'zhang', 'man', 'qiao', 'xu', 'deng', 'bi', 'xun', 'bi', 'zeng', 'wei', 'zheng', 'mao', 'shan',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'li', 'jin', 'jin', 'qiu', 'yi', 'liao', 'dao', 'zhao', 'ding', 'po', 'qiu', 'ba', 'fu', 'zhen', 'zhi', 'ba',
0xE0 => 'luan', 'fu', 'nai', 'diao', 'shan', 'qiao', 'kou', 'chuan', 'zi', 'fan', 'hua', 'hua', 'han', 'gang', 'qi', 'mang',
0xF0 => 'ri', 'di', 'si', 'xi', 'yi', 'chai', 'shi', 'tu', 'xi', 'nu', 'qian', 'qiu', 'jian', 'pi', 'ye', 'jin',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x92.php b/core/lib/Drupal/Component/Transliteration/data/x92.php
index 037b461c612..2602bf68f7e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x92.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x92.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ba', 'fang', 'chen', 'xing', 'dou', 'yue', 'qian', 'fu', 'pi', 'na', 'xin', 'e', 'jue', 'dun', 'gou', 'yin',
0x10 => 'qian', 'ban', 'sa', 'ren', 'chao', 'niu', 'fen', 'yun', 'ji', 'qin', 'pi', 'guo', 'hong', 'yin', 'jun', 'shi',
0x20 => 'yi', 'zhong', 'xi', 'gai', 'ri', 'huo', 'tai', 'kang', 'yuan', 'lu', 'e', 'wen', 'duo', 'zi', 'ni', 'tu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'hong', 'cuan', 'feng', 'chan', 'wan', 'zhi', 'si', 'xuan', 'hua', 'yu', 'tiao', 'gong', 'zhuo', 'lue', 'xing', 'qin',
0xE0 => 'shen', 'han', 'lue', 'ye', 'chu', 'zeng', 'ju', 'xian', 'tie', 'mang', 'pu', 'li', 'pan', 'rui', 'cheng', 'gao',
0xF0 => 'li', 'te', 'bing', 'zhu', 'zhen', 'tu', 'liu', 'zui', 'ju', 'chang', 'yuan', 'jian', 'gang', 'diao', 'tao', 'chang',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x93.php b/core/lib/Drupal/Component/Transliteration/data/x93.php
index 34928a9d1a7..cecc3174fa3 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x93.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x93.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'lun', 'guo', 'ling', 'bei', 'lu', 'li', 'qiang', 'pou', 'juan', 'min', 'zui', 'peng', 'an', 'pi', 'xian', 'ya',
0x10 => 'zhui', 'lei', 'ke', 'kong', 'ta', 'kun', 'du', 'nei', 'chui', 'zi', 'zheng', 'ben', 'nie', 'zong', 'chun', 'tan',
0x20 => 'ding', 'qi', 'qian', 'zhui', 'ji', 'yu', 'jin', 'guan', 'mao', 'chang', 'tian', 'xi', 'lian', 'tao', 'gu', 'cuo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'liu', 'di', 'san', 'zong', 'yi', 'lu', 'ao', 'keng', 'qiang', 'cui', 'qi', 'chang', 'tang', 'man', 'yong', 'chan',
0xE0 => 'feng', 'jing', 'biao', 'shu', 'lou', 'xiu', 'cong', 'long', 'zan', 'jian', 'cao', 'li', 'xia', 'xi', 'kang', 'shuang',
0xF0 => 'beng', 'zhang', 'qian', 'cheng', 'lu', 'hua', 'ji', 'pu', 'hui', 'qiang', 'po', 'lin', 'se', 'xiu', 'san', 'cheng',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x94.php b/core/lib/Drupal/Component/Transliteration/data/x94.php
index 9763fbcc75d..1bb228ac73d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x94.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x94.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'kui', 'si', 'liu', 'nao', 'huang', 'pie', 'sui', 'fan', 'qiao', 'quan', 'yang', 'tang', 'xiang', 'jue', 'jiao', 'zun',
0x10 => 'liao', 'qie', 'lao', 'dui', 'xin', 'zan', 'ji', 'jian', 'zhong', 'deng', 'ya', 'ying', 'dui', 'jue', 'nou', 'zan',
0x20 => 'pu', 'tie', 'fan', 'zhang', 'ding', 'shan', 'kai', 'jian', 'fei', 'sui', 'lu', 'juan', 'hui', 'yu', 'lian', 'zhuo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'kao', 'lao', 'er', 'mang', 'ya', 'you', 'cheng', 'jia', 'ye', 'nao', 'zhi', 'dang', 'tong', 'lu', 'diao', 'yin',
0xE0 => 'kai', 'zha', 'zhu', 'xi', 'ding', 'diu', 'xian', 'hua', 'quan', 'sha', 'ha', 'diao', 'ge', 'ming', 'zheng', 'se',
0xF0 => 'jiao', 'yi', 'chan', 'chong', 'tang', 'an', 'yin', 'ru', 'zhu', 'lao', 'pu', 'wu', 'lai', 'te', 'lian', 'keng',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x95.php b/core/lib/Drupal/Component/Transliteration/data/x95.php
index 84f2f89af80..fc95f3641fb 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x95.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x95.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'xiao', 'suo', 'li', 'zeng', 'chu', 'guo', 'gao', 'e', 'xiu', 'cuo', 'lue', 'feng', 'xin', 'liu', 'kai', 'jian',
0x10 => 'rui', 'ti', 'lang', 'qin', 'ju', 'a', 'qiang', 'zhe', 'nuo', 'cuo', 'mao', 'ben', 'qi', 'de', 'ke', 'kun',
0x20 => 'chang', 'xi', 'gu', 'luo', 'chui', 'zhui', 'jin', 'zhi', 'xian', 'juan', 'huo', 'pei', 'tan', 'ding', 'jian', 'ju',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'tian', 'nie', 'ta', 'kai', 'he', 'que', 'chuang', 'guan', 'dou', 'qi', 'kui', 'tang', 'guan', 'piao', 'kan', 'xi',
0xE0 => 'hui', 'chan', 'pi', 'dang', 'huan', 'ta', 'wen', 'ta', 'men', 'shuan', 'shan', 'yan', 'han', 'bi', 'wen', 'chuang',
0xF0 => 'run', 'wei', 'xian', 'hong', 'jian', 'min', 'kang', 'men', 'zha', 'nao', 'gui', 'wen', 'ta', 'min', 'lu', 'kai',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x96.php b/core/lib/Drupal/Component/Transliteration/data/x96.php
index f665409c7be..7f62e478868 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x96.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x96.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'fa', 'ge', 'he', 'kun', 'jiu', 'yue', 'lang', 'du', 'yu', 'yan', 'chang', 'xi', 'wen', 'hun', 'yan', 'e',
0x10 => 'chan', 'lan', 'qu', 'hui', 'kuo', 'que', 'he', 'tian', 'da', 'que', 'han', 'huan', 'fu', 'fu', 'le', 'dui',
0x20 => 'xin', 'qian', 'wu', 'gai', 'zhi', 'yin', 'yang', 'dou', 'e', 'sheng', 'ban', 'pei', 'keng', 'yun', 'ruan', 'zhi',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'hu', 'za', 'luo', 'yu', 'chou', 'diao', 'sui', 'han', 'wo', 'shuang', 'guan', 'chu', 'za', 'yong', 'ji', 'xi',
0xE0 => 'chou', 'liu', 'li', 'nan', 'xue', 'za', 'ji', 'ji', 'yu', 'yu', 'xue', 'na', 'fou', 'se', 'mu', 'wen',
0xF0 => 'fen', 'pang', 'yun', 'li', 'chi', 'yang', 'ling', 'lei', 'an', 'bao', 'wu', 'dian', 'dang', 'hu', 'wu', 'diao',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x97.php b/core/lib/Drupal/Component/Transliteration/data/x97.php
index 1187fbb78e1..f9296c7bea8 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x97.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x97.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'xu', 'ji', 'mu', 'chen', 'xiao', 'zha', 'ting', 'zhen', 'pei', 'mei', 'ling', 'qi', 'zhou', 'huo', 'sha', 'fei',
0x10 => 'hong', 'zhan', 'yin', 'ni', 'zhu', 'tun', 'lin', 'ling', 'dong', 'ying', 'wu', 'ling', 'shuang', 'ling', 'xia', 'hong',
0x20 => 'yin', 'mai', 'mai', 'yun', 'liu', 'meng', 'bin', 'wu', 'wei', 'kuo', 'yin', 'xi', 'yi', 'ai', 'dan', 'teng',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ge', 'wei', 'qiao', 'han', 'chang', 'kuo', 'rou', 'yun', 'she', 'wei', 'ge', 'bai', 'tao', 'gou', 'yun', 'gao',
0xE0 => 'bi', 'wei', 'sui', 'du', 'wa', 'du', 'wei', 'ren', 'fu', 'han', 'wei', 'yun', 'tao', 'jiu', 'jiu', 'xian',
0xF0 => 'xie', 'xian', 'ji', 'yin', 'za', 'yun', 'shao', 'le', 'peng', 'huang', 'ying', 'yun', 'peng', 'an', 'yin', 'xiang',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x98.php b/core/lib/Drupal/Component/Transliteration/data/x98.php
index 8e1ff9251e5..cb1ec6aa328 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x98.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x98.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'hu', 'ye', 'ding', 'qing', 'kui', 'xiang', 'shun', 'han', 'xu', 'yi', 'xu', 'e', 'song', 'kui', 'qi', 'hang',
0x10 => 'yu', 'wan', 'ban', 'dun', 'di', 'dan', 'pan', 'po', 'ling', 'che', 'jing', 'lei', 'he', 'qiao', 'e', 'e',
0x20 => 'wei', 'xie', 'kuo', 'shen', 'yi', 'shen', 'hai', 'dui', 'yu', 'ping', 'lei', 'fu', 'jia', 'tou', 'hui', 'kui',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zhan', 'biao', 'sa', 'ju', 'si', 'sou', 'yao', 'liu', 'piao', 'biao', 'biao', 'fei', 'fan', 'fei', 'fei', 'shi',
0xE0 => 'shi', 'can', 'ji', 'ding', 'si', 'tuo', 'zhan', 'sun', 'xiang', 'tun', 'ren', 'yu', 'juan', 'chi', 'yin', 'fan',
0xF0 => 'fan', 'sun', 'yin', 'tou', 'yi', 'zuo', 'bi', 'jie', 'tao', 'liu', 'ci', 'tie', 'si', 'bao', 'shi', 'duo',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x99.php b/core/lib/Drupal/Component/Transliteration/data/x99.php
index 7e99ac0c0aa..6f6fb47f815 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x99.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x99.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'hai', 'ren', 'tian', 'jiao', 'jia', 'bing', 'yao', 'tong', 'ci', 'xiang', 'yang', 'juan', 'er', 'yan', 'le', 'xi',
0x10 => 'can', 'bo', 'nei', 'e', 'bu', 'jun', 'dou', 'su', 'yu', 'shi', 'yao', 'hun', 'guo', 'shi', 'jian', 'zhui',
0x20 => 'bing', 'xian', 'bu', 'ye', 'tan', 'fei', 'zhang', 'wei', 'guan', 'e', 'nuan', 'yun', 'hu', 'huang', 'tie', 'hui',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zhu', 'nu', 'ju', 'pi', 'zang', 'jia', 'ling', 'zhen', 'tai', 'fu', 'yang', 'shi', 'bi', 'tuo', 'tuo', 'si',
0xE0 => 'liu', 'ma', 'pian', 'tao', 'zhi', 'rong', 'teng', 'dong', 'xun', 'quan', 'shen', 'jiong', 'er', 'hai', 'bo', 'zhu',
0xF0 => 'yin', 'luo', 'zhou', 'dan', 'xie', 'liu', 'ju', 'song', 'qin', 'mang', 'lang', 'han', 'tu', 'xuan', 'tui', 'jun',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x9a.php b/core/lib/Drupal/Component/Transliteration/data/x9a.php
index 3c855404358..cd576596c7d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x9a.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x9a.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'e', 'cheng', 'xing', 'ai', 'lu', 'zhui', 'zhou', 'she', 'pian', 'kun', 'tao', 'lai', 'zong', 'ke', 'qi', 'qi',
0x10 => 'yan', 'fei', 'sao', 'yan', 'ge', 'yao', 'wu', 'pian', 'cong', 'pian', 'qian', 'fei', 'huang', 'qian', 'huo', 'yu',
0x20 => 'ti', 'quan', 'xia', 'zong', 'kui', 'rou', 'si', 'gua', 'tuo', 'gui', 'sou', 'qian', 'cheng', 'zhi', 'liu', 'peng',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'xiao', 'du', 'zang', 'sui', 'ti', 'bin', 'kuan', 'lu', 'gao', 'gao', 'qiao', 'kao', 'qiao', 'lao', 'sao', 'biao',
0xE0 => 'kun', 'kun', 'di', 'fang', 'xiu', 'ran', 'mao', 'dan', 'kun', 'bin', 'fa', 'tiao', 'pi', 'zi', 'fa', 'ran',
0xF0 => 'ti', 'bao', 'bi', 'mao', 'fu', 'er', 'rong', 'qu', 'gong', 'xiu', 'kuo', 'ji', 'peng', 'zhua', 'shao', 'suo',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x9b.php b/core/lib/Drupal/Component/Transliteration/data/x9b.php
index 9617f974573..2cbbd7eaf4a 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x9b.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x9b.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ti', 'li', 'bin', 'zong', 'di', 'peng', 'song', 'zheng', 'quan', 'zong', 'shun', 'jian', 'tuo', 'hu', 'la', 'jiu',
0x10 => 'qi', 'lian', 'zhen', 'bin', 'peng', 'ma', 'san', 'man', 'man', 'seng', 'xu', 'lie', 'qian', 'qian', 'nang', 'huan',
0x20 => 'kuo', 'ning', 'bin', 'lie', 'rang', 'dou', 'dou', 'nao', 'hong', 'xi', 'dou', 'han', 'dou', 'dou', 'jiu', 'chang',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zou', 'xi', 'yong', 'ni', 'zi', 'qi', 'zheng', 'xiang', 'nei', 'chun', 'ji', 'diao', 'qie', 'gu', 'zhou', 'dong',
0xE0 => 'lai', 'fei', 'ni', 'yi', 'kun', 'lu', 'jiu', 'chang', 'jing', 'lun', 'ling', 'zou', 'li', 'meng', 'zong', 'zhi',
0xF0 => 'nian', 'hu', 'yu', 'di', 'shi', 'shen', 'hun', 'ti', 'hou', 'xing', 'zhu', 'la', 'zong', 'zei', 'bian', 'bian',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x9c.php b/core/lib/Drupal/Component/Transliteration/data/x9c.php
index 76be43eb39e..4ca423cb14b 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x9c.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x9c.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'huan', 'quan', 'zei', 'wei', 'wei', 'yu', 'chun', 'rou', 'die', 'huang', 'lian', 'yan', 'qiu', 'qiu', 'jian', 'bi',
0x10 => 'e', 'yang', 'fu', 'sai', 'gan', 'xia', 'tuo', 'hu', 'shi', 'ruo', 'xuan', 'wen', 'qian', 'hao', 'wu', 'fang',
0x20 => 'sao', 'liu', 'ma', 'shi', 'shi', 'guan', 'zi', 'teng', 'ta', 'yao', 'e', 'yong', 'qian', 'qi', 'wen', 'ruo',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'yao', 'pang', 'jian', 'le', 'biao', 'xue', 'bie', 'man', 'min', 'yong', 'wei', 'xi', 'gui', 'shan', 'lin', 'zun',
0xE0 => 'hu', 'gan', 'li', 'zhan', 'guan', 'niao', 'yi', 'fu', 'li', 'jiu', 'bu', 'yan', 'fu', 'diao', 'ji', 'feng',
0xF0 => 'ru', 'gan', 'shi', 'feng', 'ming', 'bao', 'yuan', 'zhi', 'hu', 'qin', 'fu', 'ban', 'wen', 'jian', 'shi', 'yu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x9d.php b/core/lib/Drupal/Component/Transliteration/data/x9d.php
index 21e99773279..d3b4d78c9a9 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x9d.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x9d.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'fou', 'yao', 'jue', 'jue', 'pi', 'huan', 'zhen', 'bao', 'yan', 'ya', 'zheng', 'fang', 'feng', 'wen', 'ou', 'dai',
0x10 => 'ge', 'ru', 'ling', 'mie', 'fu', 'tuo', 'min', 'li', 'bian', 'zhi', 'ge', 'yuan', 'ci', 'qu', 'xiao', 'chi',
0x20 => 'dan', 'ju', 'yao', 'gu', 'dong', 'yu', 'yang', 'rong', 'ya', 'tie', 'yu', 'tian', 'ying', 'dui', 'wu', 'er',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chen', 'ji', 'tuan', 'zhe', 'ao', 'yao', 'yi', 'ou', 'chi', 'zhi', 'liu', 'yong', 'lu', 'bi', 'shuang', 'zhuo',
0xE0 => 'yu', 'wu', 'jue', 'yin', 'ti', 'si', 'jiao', 'yi', 'hua', 'bi', 'ying', 'su', 'huang', 'fan', 'jiao', 'liao',
0xF0 => 'yan', 'gao', 'jiu', 'xian', 'xian', 'tu', 'mai', 'zun', 'yu', 'ying', 'lu', 'tuan', 'xian', 'xue', 'yi', 'pi',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x9e.php b/core/lib/Drupal/Component/Transliteration/data/x9e.php
index b50dd0fe31a..db7e7f04eb3 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x9e.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x9e.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'chu', 'luo', 'xi', 'yi', 'ji', 'ze', 'yu', 'zhan', 'ye', 'yang', 'pi', 'ning', 'hu', 'mi', 'ying', 'meng',
0x10 => 'di', 'yue', 'yu', 'lei', 'bao', 'lu', 'he', 'long', 'shuang', 'yue', 'ying', 'guan', 'qu', 'li', 'luan', 'niao',
0x20 => 'jiu', 'ji', 'yuan', 'ming', 'shi', 'ou', 'ya', 'cang', 'bao', 'zhen', 'gu', 'dong', 'lu', 'ya', 'xiao', 'yang',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chi', 'hei', 'hei', 'yi', 'qian', 'dan', 'xi', 'tun', 'mo', 'mo', 'qian', 'dai', 'chu', 'you', 'dian', 'yi',
0xE0 => 'xia', 'yan', 'qu', 'mei', 'yan', 'qing', 'yue', 'li', 'dang', 'du', 'can', 'yan', 'yan', 'yan', 'dan', 'an',
0xF0 => 'zhen', 'dai', 'can', 'yi', 'mei', 'zhan', 'yan', 'du', 'lu', 'zhi', 'fen', 'fu', 'fu', 'mian', 'mian', 'yuan',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/x9f.php b/core/lib/Drupal/Component/Transliteration/data/x9f.php
index 49f08e5ab17..13ecd6e821f 100644
--- a/core/lib/Drupal/Component/Transliteration/data/x9f.php
+++ b/core/lib/Drupal/Component/Transliteration/data/x9f.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'cu', 'qu', 'chao', 'wa', 'zhu', 'zhi', 'meng', 'ao', 'bie', 'tuo', 'bi', 'yuan', 'chao', 'tuo', 'ding', 'mi',
0x10 => 'nai', 'ding', 'zi', 'gu', 'gu', 'dong', 'fen', 'tao', 'yuan', 'pi', 'chang', 'gao', 'qi', 'yuan', 'tang', 'teng',
0x20 => 'shu', 'shu', 'fen', 'fei', 'wen', 'ba', 'diao', 'tuo', 'zhong', 'qu', 'sheng', 'shi', 'you', 'shi', 'ting', 'wu',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xa0.php b/core/lib/Drupal/Component/Transliteration/data/xa0.php
index b7fee624332..ca55187fe2d 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xa0.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xa0.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'it', 'ix', 'i', 'ip', 'iet', 'iex', 'ie', 'iep', 'at', 'ax', 'a', 'ap', 'uox', 'uo', 'uop', 'ot',
0x10 => 'ox', 'o', 'op', 'ex', 'e', 'wu', 'bit', 'bix', 'bi', 'bip', 'biet', 'biex', 'bie', 'biep', 'bat', 'bax',
0x20 => 'ba', 'bap', 'buox', 'buo', 'buop', 'bot', 'box', 'bo', 'bop', 'bex', 'be', 'bep', 'but', 'bux', 'bu', 'bup',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'fip', 'fat', 'fax', 'fa', 'fap', 'fox', 'fo', 'fop', 'fut', 'fux', 'fu', 'fup', 'furx', 'fur', 'fyt', 'fyx',
0xE0 => 'fy', 'fyp', 'vit', 'vix', 'vi', 'vip', 'viet', 'viex', 'vie', 'viep', 'vat', 'vax', 'va', 'vap', 'vot', 'vox',
0xF0 => 'vo', 'vop', 'vex', 'vep', 'vut', 'vux', 'vu', 'vup', 'vurx', 'vur', 'vyt', 'vyx', 'vy', 'vyp', 'vyrx', 'vyr',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xa1.php b/core/lib/Drupal/Component/Transliteration/data/xa1.php
index 66cc4466e81..19ca96ec053 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xa1.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xa1.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'dit', 'dix', 'di', 'dip', 'diex', 'die', 'diep', 'dat', 'dax', 'da', 'dap', 'duox', 'duo', 'dot', 'dox', 'do',
0x10 => 'dop', 'dex', 'de', 'dep', 'dut', 'dux', 'du', 'dup', 'durx', 'dur', 'tit', 'tix', 'ti', 'tip', 'tiex', 'tie',
0x20 => 'tiep', 'tat', 'tax', 'ta', 'tap', 'tuot', 'tuox', 'tuo', 'tuop', 'tot', 'tox', 'to', 'top', 'tex', 'te', 'tep',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lu', 'lup', 'lurx', 'lur', 'lyt', 'lyx', 'ly', 'lyp', 'lyrx', 'lyr', 'git', 'gix', 'gi', 'gip', 'giet', 'giex',
0xE0 => 'gie', 'giep', 'gat', 'gax', 'ga', 'gap', 'guot', 'guox', 'guo', 'guop', 'got', 'gox', 'go', 'gop', 'get', 'gex',
0xF0 => 'ge', 'gep', 'gut', 'gux', 'gu', 'gup', 'gurx', 'gur', 'kit', 'kix', 'ki', 'kip', 'kiex', 'kie', 'kiep', 'kat',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xa2.php b/core/lib/Drupal/Component/Transliteration/data/xa2.php
index 95d4c8c6ef1..0603d5fb985 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xa2.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xa2.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'kax', 'ka', 'kap', 'kuox', 'kuo', 'kuop', 'kot', 'kox', 'ko', 'kop', 'ket', 'kex', 'ke', 'kep', 'kut', 'kux',
0x10 => 'ku', 'kup', 'kurx', 'kur', 'ggit', 'ggix', 'ggi', 'ggiex', 'ggie', 'ggiep', 'ggat', 'ggax', 'gga', 'ggap', 'gguot', 'gguox',
0x20 => 'gguo', 'gguop', 'ggot', 'ggox', 'ggo', 'ggop', 'gget', 'ggex', 'gge', 'ggep', 'ggut', 'ggux', 'ggu', 'ggup', 'ggurx', 'ggur',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'zzit', 'zzix', 'zzi', 'zzip', 'zziet', 'zziex', 'zzie', 'zziep', 'zzat', 'zzax', 'zza', 'zzap', 'zzox', 'zzo', 'zzop', 'zzex',
0xE0 => 'zze', 'zzep', 'zzux', 'zzu', 'zzup', 'zzurx', 'zzur', 'zzyt', 'zzyx', 'zzy', 'zzyp', 'zzyrx', 'zzyr', 'nzit', 'nzix', 'nzi',
0xF0 => 'nzip', 'nziex', 'nzie', 'nziep', 'nzat', 'nzax', 'nza', 'nzap', 'nzuox', 'nzuo', 'nzox', 'nzop', 'nzex', 'nze', 'nzux', 'nzu',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xa3.php b/core/lib/Drupal/Component/Transliteration/data/xa3.php
index a63b2815986..207736f930a 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xa3.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xa3.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'nzup', 'nzurx', 'nzur', 'nzyt', 'nzyx', 'nzy', 'nzyp', 'nzyrx', 'nzyr', 'sit', 'six', 'si', 'sip', 'siex', 'sie', 'siep',
0x10 => 'sat', 'sax', 'sa', 'sap', 'suox', 'suo', 'suop', 'sot', 'sox', 'so', 'sop', 'sex', 'se', 'sep', 'sut', 'sux',
0x20 => 'su', 'sup', 'surx', 'sur', 'syt', 'syx', 'sy', 'syp', 'syrx', 'syr', 'ssit', 'ssix', 'ssi', 'ssip', 'ssiex', 'ssie',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'rop', 'rex', 're', 'rep', 'rut', 'rux', 'ru', 'rup', 'rurx', 'rur', 'ryt', 'ryx', 'ry', 'ryp', 'ryrx', 'ryr',
0xE0 => 'jit', 'jix', 'ji', 'jip', 'jiet', 'jiex', 'jie', 'jiep', 'juot', 'juox', 'juo', 'juop', 'jot', 'jox', 'jo', 'jop',
0xF0 => 'jut', 'jux', 'ju', 'jup', 'jurx', 'jur', 'jyt', 'jyx', 'jy', 'jyp', 'jyrx', 'jyr', 'qit', 'qix', 'qi', 'qip',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xa4.php b/core/lib/Drupal/Component/Transliteration/data/xa4.php
index 2210454a8ec..736b03ca274 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xa4.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xa4.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'qiet', 'qiex', 'qie', 'qiep', 'quot', 'quox', 'quo', 'quop', 'qot', 'qox', 'qo', 'qop', 'qut', 'qux', 'qu', 'qup',
0x10 => 'qurx', 'qur', 'qyt', 'qyx', 'qy', 'qyp', 'qyrx', 'qyr', 'jjit', 'jjix', 'jji', 'jjip', 'jjiet', 'jjiex', 'jjie', 'jjiep',
0x20 => 'jjuox', 'jjuo', 'jjuop', 'jjot', 'jjox', 'jjo', 'jjop', 'jjut', 'jjux', 'jju', 'jjup', 'jjurx', 'jjur', 'jjyt', 'jjyx', 'jjy',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xac.php b/core/lib/Drupal/Component/Transliteration/data/xac.php
index 87c2d143868..7ece9df0467 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xac.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xac.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ga', 'gag', 'gakk', 'gags', 'gan', 'ganj', 'ganh', 'gad', 'gal', 'galg', 'galm', 'galb', 'gals', 'galt', 'galp', 'galh',
0x10 => 'gam', 'gab', 'gabs', 'gas', 'gass', 'gang', 'gaj', 'gach', 'gak', 'gat', 'gap', 'gah', 'gae', 'gaeg', 'gaekk', 'gaegs',
0x20 => 'gaen', 'gaenj', 'gaenh', 'gaed', 'gael', 'gaelg', 'gaelm', 'gaelb', 'gaels', 'gaelt', 'gaelp', 'gaelh', 'gaem', 'gaeb', 'gaebs', 'gaes',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'gyels', 'gyelt', 'gyelp', 'gyelh', 'gyem', 'gyeb', 'gyebs', 'gyes', 'gyess', 'gyeng', 'gyej', 'gyech', 'gyek', 'gyet', 'gyep', 'gyeh',
0xE0 => 'go', 'gog', 'gokk', 'gogs', 'gon', 'gonj', 'gonh', 'god', 'gol', 'golg', 'golm', 'golb', 'gols', 'golt', 'golp', 'golh',
0xF0 => 'gom', 'gob', 'gobs', 'gos', 'goss', 'gong', 'goj', 'goch', 'gok', 'got', 'gop', 'goh', 'gwa', 'gwag', 'gwakk', 'gwags',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xad.php b/core/lib/Drupal/Component/Transliteration/data/xad.php
index 4e8eb27d21a..8dd61dee9cf 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xad.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xad.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'gwan', 'gwanj', 'gwanh', 'gwad', 'gwal', 'gwalg', 'gwalm', 'gwalb', 'gwals', 'gwalt', 'gwalp', 'gwalh', 'gwam', 'gwab', 'gwabs', 'gwas',
0x10 => 'gwass', 'gwang', 'gwaj', 'gwach', 'gwak', 'gwat', 'gwap', 'gwah', 'gwae', 'gwaeg', 'gwaekk', 'gwaegs', 'gwaen', 'gwaenj', 'gwaenh', 'gwaed',
0x20 => 'gwael', 'gwaelg', 'gwaelm', 'gwaelb', 'gwaels', 'gwaelt', 'gwaelp', 'gwaelh', 'gwaem', 'gwaeb', 'gwaebs', 'gwaes', 'gwaess', 'gwaeng', 'gwaej', 'gwaech',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'gwim', 'gwib', 'gwibs', 'gwis', 'gwiss', 'gwing', 'gwij', 'gwich', 'gwik', 'gwit', 'gwip', 'gwih', 'gyu', 'gyug', 'gyukk', 'gyugs',
0xE0 => 'gyun', 'gyunj', 'gyunh', 'gyud', 'gyul', 'gyulg', 'gyulm', 'gyulb', 'gyuls', 'gyult', 'gyulp', 'gyulh', 'gyum', 'gyub', 'gyubs', 'gyus',
0xF0 => 'gyuss', 'gyung', 'gyuj', 'gyuch', 'gyuk', 'gyut', 'gyup', 'gyuh', 'geu', 'geug', 'geukk', 'geugs', 'geun', 'geunj', 'geunh', 'geud',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xae.php b/core/lib/Drupal/Component/Transliteration/data/xae.php
index 52f7f5c40b7..1584a5c01ba 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xae.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xae.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'geul', 'geulg', 'geulm', 'geulb', 'geuls', 'geult', 'geulp', 'geulh', 'geum', 'geub', 'geubs', 'geus', 'geuss', 'geung', 'geuj', 'geuch',
0x10 => 'geuk', 'geut', 'geup', 'geuh', 'gui', 'guig', 'guikk', 'guigs', 'guin', 'guinj', 'guinh', 'guid', 'guil', 'guilg', 'guilm', 'guilb',
0x20 => 'guils', 'guilt', 'guilp', 'guilh', 'guim', 'guib', 'guibs', 'guis', 'guiss', 'guing', 'guij', 'guich', 'guik', 'guit', 'guip', 'guih',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'kkeoss', 'kkeong', 'kkeoj', 'kkeoch', 'kkeok', 'kkeot', 'kkeop', 'kkeoh', 'kke', 'kkeg', 'kkekk', 'kkegs', 'kken', 'kkenj', 'kkenh', 'kked',
0xE0 => 'kkel', 'kkelg', 'kkelm', 'kkelb', 'kkels', 'kkelt', 'kkelp', 'kkelh', 'kkem', 'kkeb', 'kkebs', 'kkes', 'kkess', 'kkeng', 'kkej', 'kkech',
0xF0 => 'kkek', 'kket', 'kkep', 'kkeh', 'kkyeo', 'kkyeog', 'kkyeokk', 'kkyeogs', 'kkyeon', 'kkyeonj', 'kkyeonh', 'kkyeod', 'kkyeol', 'kkyeolg', 'kkyeolm', 'kkyeolb',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xaf.php b/core/lib/Drupal/Component/Transliteration/data/xaf.php
index e5f37fe450f..26c61c5cbe2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xaf.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xaf.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'kkyeols', 'kkyeolt', 'kkyeolp', 'kkyeolh', 'kkyeom', 'kkyeob', 'kkyeobs', 'kkyeos', 'kkyeoss', 'kkyeong', 'kkyeoj', 'kkyeoch', 'kkyeok', 'kkyeot', 'kkyeop', 'kkyeoh',
0x10 => 'kkye', 'kkyeg', 'kkyekk', 'kkyegs', 'kkyen', 'kkyenj', 'kkyenh', 'kkyed', 'kkyel', 'kkyelg', 'kkyelm', 'kkyelb', 'kkyels', 'kkyelt', 'kkyelp', 'kkyelh',
0x20 => 'kkyem', 'kkyeb', 'kkyebs', 'kkyes', 'kkyess', 'kkyeng', 'kkyej', 'kkyech', 'kkyek', 'kkyet', 'kkyep', 'kkyeh', 'kko', 'kkog', 'kkokk', 'kkogs',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'kkuk', 'kkut', 'kkup', 'kkuh', 'kkwo', 'kkwog', 'kkwokk', 'kkwogs', 'kkwon', 'kkwonj', 'kkwonh', 'kkwod', 'kkwol', 'kkwolg', 'kkwolm', 'kkwolb',
0xE0 => 'kkwols', 'kkwolt', 'kkwolp', 'kkwolh', 'kkwom', 'kkwob', 'kkwobs', 'kkwos', 'kkwoss', 'kkwong', 'kkwoj', 'kkwoch', 'kkwok', 'kkwot', 'kkwop', 'kkwoh',
0xF0 => 'kkwe', 'kkweg', 'kkwekk', 'kkwegs', 'kkwen', 'kkwenj', 'kkwenh', 'kkwed', 'kkwel', 'kkwelg', 'kkwelm', 'kkwelb', 'kkwels', 'kkwelt', 'kkwelp', 'kkwelh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb0.php b/core/lib/Drupal/Component/Transliteration/data/xb0.php
index 96071fde975..0ebe3707025 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb0.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb0.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'kkwem', 'kkweb', 'kkwebs', 'kkwes', 'kkwess', 'kkweng', 'kkwej', 'kkwech', 'kkwek', 'kkwet', 'kkwep', 'kkweh', 'kkwi', 'kkwig', 'kkwikk', 'kkwigs',
0x10 => 'kkwin', 'kkwinj', 'kkwinh', 'kkwid', 'kkwil', 'kkwilg', 'kkwilm', 'kkwilb', 'kkwils', 'kkwilt', 'kkwilp', 'kkwilh', 'kkwim', 'kkwib', 'kkwibs', 'kkwis',
0x20 => 'kkwiss', 'kkwing', 'kkwij', 'kkwich', 'kkwik', 'kkwit', 'kkwip', 'kkwih', 'kkyu', 'kkyug', 'kkyukk', 'kkyugs', 'kkyun', 'kkyunj', 'kkyunh', 'kkyud',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'nya', 'nyag', 'nyakk', 'nyags', 'nyan', 'nyanj', 'nyanh', 'nyad', 'nyal', 'nyalg', 'nyalm', 'nyalb', 'nyals', 'nyalt', 'nyalp', 'nyalh',
0xE0 => 'nyam', 'nyab', 'nyabs', 'nyas', 'nyass', 'nyang', 'nyaj', 'nyach', 'nyak', 'nyat', 'nyap', 'nyah', 'nyae', 'nyaeg', 'nyaekk', 'nyaegs',
0xF0 => 'nyaen', 'nyaenj', 'nyaenh', 'nyaed', 'nyael', 'nyaelg', 'nyaelm', 'nyaelb', 'nyaels', 'nyaelt', 'nyaelp', 'nyaelh', 'nyaem', 'nyaeb', 'nyaebs', 'nyaes',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb1.php b/core/lib/Drupal/Component/Transliteration/data/xb1.php
index d90ecfce3bc..2f4d010cd31 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb1.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb1.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'nyaess', 'nyaeng', 'nyaej', 'nyaech', 'nyaek', 'nyaet', 'nyaep', 'nyaeh', 'neo', 'neog', 'neokk', 'neogs', 'neon', 'neonj', 'neonh', 'neod',
0x10 => 'neol', 'neolg', 'neolm', 'neolb', 'neols', 'neolt', 'neolp', 'neolh', 'neom', 'neob', 'neobs', 'neos', 'neoss', 'neong', 'neoj', 'neoch',
0x20 => 'neok', 'neot', 'neop', 'neoh', 'ne', 'neg', 'nekk', 'negs', 'nen', 'nenj', 'nenh', 'ned', 'nel', 'nelg', 'nelm', 'nelb',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'noen', 'noenj', 'noenh', 'noed', 'noel', 'noelg', 'noelm', 'noelb', 'noels', 'noelt', 'noelp', 'noelh', 'noem', 'noeb', 'noebs', 'noes',
0xE0 => 'noess', 'noeng', 'noej', 'noech', 'noek', 'noet', 'noep', 'noeh', 'nyo', 'nyog', 'nyokk', 'nyogs', 'nyon', 'nyonj', 'nyonh', 'nyod',
0xF0 => 'nyol', 'nyolg', 'nyolm', 'nyolb', 'nyols', 'nyolt', 'nyolp', 'nyolh', 'nyom', 'nyob', 'nyobs', 'nyos', 'nyoss', 'nyong', 'nyoj', 'nyoch',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb2.php b/core/lib/Drupal/Component/Transliteration/data/xb2.php
index 1dced88cb73..ef3617bdcf6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb2.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb2.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'nyok', 'nyot', 'nyop', 'nyoh', 'nu', 'nug', 'nukk', 'nugs', 'nun', 'nunj', 'nunh', 'nud', 'nul', 'nulg', 'nulm', 'nulb',
0x10 => 'nuls', 'nult', 'nulp', 'nulh', 'num', 'nub', 'nubs', 'nus', 'nuss', 'nung', 'nuj', 'nuch', 'nuk', 'nut', 'nup', 'nuh',
0x20 => 'nwo', 'nwog', 'nwokk', 'nwogs', 'nwon', 'nwonj', 'nwonh', 'nwod', 'nwol', 'nwolg', 'nwolm', 'nwolb', 'nwols', 'nwolt', 'nwolp', 'nwolh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'nil', 'nilg', 'nilm', 'nilb', 'nils', 'nilt', 'nilp', 'nilh', 'nim', 'nib', 'nibs', 'nis', 'niss', 'ning', 'nij', 'nich',
0xE0 => 'nik', 'nit', 'nip', 'nih', 'da', 'dag', 'dakk', 'dags', 'dan', 'danj', 'danh', 'dad', 'dal', 'dalg', 'dalm', 'dalb',
0xF0 => 'dals', 'dalt', 'dalp', 'dalh', 'dam', 'dab', 'dabs', 'das', 'dass', 'dang', 'daj', 'dach', 'dak', 'dat', 'dap', 'dah',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb3.php b/core/lib/Drupal/Component/Transliteration/data/xb3.php
index 37a9a07241f..6b798078fc2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb3.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb3.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'dae', 'daeg', 'daekk', 'daegs', 'daen', 'daenj', 'daenh', 'daed', 'dael', 'daelg', 'daelm', 'daelb', 'daels', 'daelt', 'daelp', 'daelh',
0x10 => 'daem', 'daeb', 'daebs', 'daes', 'daess', 'daeng', 'daej', 'daech', 'daek', 'daet', 'daep', 'daeh', 'dya', 'dyag', 'dyakk', 'dyags',
0x20 => 'dyan', 'dyanj', 'dyanh', 'dyad', 'dyal', 'dyalg', 'dyalm', 'dyalb', 'dyals', 'dyalt', 'dyalp', 'dyalh', 'dyam', 'dyab', 'dyabs', 'dyas',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'dols', 'dolt', 'dolp', 'dolh', 'dom', 'dob', 'dobs', 'dos', 'doss', 'dong', 'doj', 'doch', 'dok', 'dot', 'dop', 'doh',
0xE0 => 'dwa', 'dwag', 'dwakk', 'dwags', 'dwan', 'dwanj', 'dwanh', 'dwad', 'dwal', 'dwalg', 'dwalm', 'dwalb', 'dwals', 'dwalt', 'dwalp', 'dwalh',
0xF0 => 'dwam', 'dwab', 'dwabs', 'dwas', 'dwass', 'dwang', 'dwaj', 'dwach', 'dwak', 'dwat', 'dwap', 'dwah', 'dwae', 'dwaeg', 'dwaekk', 'dwaegs',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb4.php b/core/lib/Drupal/Component/Transliteration/data/xb4.php
index 2c46b3a771c..0ae19d4472e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb4.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb4.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'dwaen', 'dwaenj', 'dwaenh', 'dwaed', 'dwael', 'dwaelg', 'dwaelm', 'dwaelb', 'dwaels', 'dwaelt', 'dwaelp', 'dwaelh', 'dwaem', 'dwaeb', 'dwaebs', 'dwaes',
0x10 => 'dwaess', 'dwaeng', 'dwaej', 'dwaech', 'dwaek', 'dwaet', 'dwaep', 'dwaeh', 'doe', 'doeg', 'doekk', 'doegs', 'doen', 'doenj', 'doenh', 'doed',
0x20 => 'doel', 'doelg', 'doelm', 'doelb', 'doels', 'doelt', 'doelp', 'doelh', 'doem', 'doeb', 'doebs', 'does', 'doess', 'doeng', 'doej', 'doech',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'dyum', 'dyub', 'dyubs', 'dyus', 'dyuss', 'dyung', 'dyuj', 'dyuch', 'dyuk', 'dyut', 'dyup', 'dyuh', 'deu', 'deug', 'deukk', 'deugs',
0xE0 => 'deun', 'deunj', 'deunh', 'deud', 'deul', 'deulg', 'deulm', 'deulb', 'deuls', 'deult', 'deulp', 'deulh', 'deum', 'deub', 'deubs', 'deus',
0xF0 => 'deuss', 'deung', 'deuj', 'deuch', 'deuk', 'deut', 'deup', 'deuh', 'dui', 'duig', 'duikk', 'duigs', 'duin', 'duinj', 'duinh', 'duid',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb5.php b/core/lib/Drupal/Component/Transliteration/data/xb5.php
index ee61e54303e..22be8a0ac8a 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb5.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb5.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'duil', 'duilg', 'duilm', 'duilb', 'duils', 'duilt', 'duilp', 'duilh', 'duim', 'duib', 'duibs', 'duis', 'duiss', 'duing', 'duij', 'duich',
0x10 => 'duik', 'duit', 'duip', 'duih', 'di', 'dig', 'dikk', 'digs', 'din', 'dinj', 'dinh', 'did', 'dil', 'dilg', 'dilm', 'dilb',
0x20 => 'dils', 'dilt', 'dilp', 'dilh', 'dim', 'dib', 'dibs', 'dis', 'diss', 'ding', 'dij', 'dich', 'dik', 'dit', 'dip', 'dih',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ttess', 'tteng', 'ttej', 'ttech', 'ttek', 'ttet', 'ttep', 'tteh', 'ttyeo', 'ttyeog', 'ttyeokk', 'ttyeogs', 'ttyeon', 'ttyeonj', 'ttyeonh', 'ttyeod',
0xE0 => 'ttyeol', 'ttyeolg', 'ttyeolm', 'ttyeolb', 'ttyeols', 'ttyeolt', 'ttyeolp', 'ttyeolh', 'ttyeom', 'ttyeob', 'ttyeobs', 'ttyeos', 'ttyeoss', 'ttyeong', 'ttyeoj', 'ttyeoch',
0xF0 => 'ttyeok', 'ttyeot', 'ttyeop', 'ttyeoh', 'ttye', 'ttyeg', 'ttyekk', 'ttyegs', 'ttyen', 'ttyenj', 'ttyenh', 'ttyed', 'ttyel', 'ttyelg', 'ttyelm', 'ttyelb',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb6.php b/core/lib/Drupal/Component/Transliteration/data/xb6.php
index 5b209ee8110..9a40cdcc2b8 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb6.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb6.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ttyels', 'ttyelt', 'ttyelp', 'ttyelh', 'ttyem', 'ttyeb', 'ttyebs', 'ttyes', 'ttyess', 'ttyeng', 'ttyej', 'ttyech', 'ttyek', 'ttyet', 'ttyep', 'ttyeh',
0x10 => 'tto', 'ttog', 'ttokk', 'ttogs', 'tton', 'ttonj', 'ttonh', 'ttod', 'ttol', 'ttolg', 'ttolm', 'ttolb', 'ttols', 'ttolt', 'ttolp', 'ttolh',
0x20 => 'ttom', 'ttob', 'ttobs', 'ttos', 'ttoss', 'ttong', 'ttoj', 'ttoch', 'ttok', 'ttot', 'ttop', 'ttoh', 'ttwa', 'ttwag', 'ttwakk', 'ttwags',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ttwok', 'ttwot', 'ttwop', 'ttwoh', 'ttwe', 'ttweg', 'ttwekk', 'ttwegs', 'ttwen', 'ttwenj', 'ttwenh', 'ttwed', 'ttwel', 'ttwelg', 'ttwelm', 'ttwelb',
0xE0 => 'ttwels', 'ttwelt', 'ttwelp', 'ttwelh', 'ttwem', 'ttweb', 'ttwebs', 'ttwes', 'ttwess', 'ttweng', 'ttwej', 'ttwech', 'ttwek', 'ttwet', 'ttwep', 'ttweh',
0xF0 => 'ttwi', 'ttwig', 'ttwikk', 'ttwigs', 'ttwin', 'ttwinj', 'ttwinh', 'ttwid', 'ttwil', 'ttwilg', 'ttwilm', 'ttwilb', 'ttwils', 'ttwilt', 'ttwilp', 'ttwilh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb7.php b/core/lib/Drupal/Component/Transliteration/data/xb7.php
index c19b876fde4..419dbe1bc31 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb7.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb7.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ttwim', 'ttwib', 'ttwibs', 'ttwis', 'ttwiss', 'ttwing', 'ttwij', 'ttwich', 'ttwik', 'ttwit', 'ttwip', 'ttwih', 'ttyu', 'ttyug', 'ttyukk', 'ttyugs',
0x10 => 'ttyun', 'ttyunj', 'ttyunh', 'ttyud', 'ttyul', 'ttyulg', 'ttyulm', 'ttyulb', 'ttyuls', 'ttyult', 'ttyulp', 'ttyulh', 'ttyum', 'ttyub', 'ttyubs', 'ttyus',
0x20 => 'ttyuss', 'ttyung', 'ttyuj', 'ttyuch', 'ttyuk', 'ttyut', 'ttyup', 'ttyuh', 'tteu', 'tteug', 'tteukk', 'tteugs', 'tteun', 'tteunj', 'tteunh', 'tteud',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lyae', 'lyaeg', 'lyaekk', 'lyaegs', 'lyaen', 'lyaenj', 'lyaenh', 'lyaed', 'lyael', 'lyaelg', 'lyaelm', 'lyaelb', 'lyaels', 'lyaelt', 'lyaelp', 'lyaelh',
0xE0 => 'lyaem', 'lyaeb', 'lyaebs', 'lyaes', 'lyaess', 'lyaeng', 'lyaej', 'lyaech', 'lyaek', 'lyaet', 'lyaep', 'lyaeh', 'leo', 'leog', 'leokk', 'leogs',
0xF0 => 'leon', 'leonj', 'leonh', 'leod', 'leol', 'leolg', 'leolm', 'leolb', 'leols', 'leolt', 'leolp', 'leolh', 'leom', 'leob', 'leobs', 'leos',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb8.php b/core/lib/Drupal/Component/Transliteration/data/xb8.php
index 3743ce2a1e5..0abd8a036f0 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb8.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb8.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'leoss', 'leong', 'leoj', 'leoch', 'leok', 'leot', 'leop', 'leoh', 'le', 'leg', 'lekk', 'legs', 'len', 'lenj', 'lenh', 'led',
0x10 => 'lel', 'lelg', 'lelm', 'lelb', 'lels', 'lelt', 'lelp', 'lelh', 'lem', 'leb', 'lebs', 'les', 'less', 'leng', 'lej', 'lech',
0x20 => 'lek', 'let', 'lep', 'leh', 'lyeo', 'lyeog', 'lyeokk', 'lyeogs', 'lyeon', 'lyeonj', 'lyeonh', 'lyeod', 'lyeol', 'lyeolg', 'lyeolm', 'lyeolb',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lyon', 'lyonj', 'lyonh', 'lyod', 'lyol', 'lyolg', 'lyolm', 'lyolb', 'lyols', 'lyolt', 'lyolp', 'lyolh', 'lyom', 'lyob', 'lyobs', 'lyos',
0xE0 => 'lyoss', 'lyong', 'lyoj', 'lyoch', 'lyok', 'lyot', 'lyop', 'lyoh', 'lu', 'lug', 'lukk', 'lugs', 'lun', 'lunj', 'lunh', 'lud',
0xF0 => 'lul', 'lulg', 'lulm', 'lulb', 'luls', 'lult', 'lulp', 'lulh', 'lum', 'lub', 'lubs', 'lus', 'luss', 'lung', 'luj', 'luch',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xb9.php b/core/lib/Drupal/Component/Transliteration/data/xb9.php
index 0307106cf8a..9b5fcd157a2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xb9.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xb9.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'luk', 'lut', 'lup', 'luh', 'lwo', 'lwog', 'lwokk', 'lwogs', 'lwon', 'lwonj', 'lwonh', 'lwod', 'lwol', 'lwolg', 'lwolm', 'lwolb',
0x10 => 'lwols', 'lwolt', 'lwolp', 'lwolh', 'lwom', 'lwob', 'lwobs', 'lwos', 'lwoss', 'lwong', 'lwoj', 'lwoch', 'lwok', 'lwot', 'lwop', 'lwoh',
0x20 => 'lwe', 'lweg', 'lwekk', 'lwegs', 'lwen', 'lwenj', 'lwenh', 'lwed', 'lwel', 'lwelg', 'lwelm', 'lwelb', 'lwels', 'lwelt', 'lwelp', 'lwelh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'mal', 'malg', 'malm', 'malb', 'mals', 'malt', 'malp', 'malh', 'mam', 'mab', 'mabs', 'mas', 'mass', 'mang', 'maj', 'mach',
0xE0 => 'mak', 'mat', 'map', 'mah', 'mae', 'maeg', 'maekk', 'maegs', 'maen', 'maenj', 'maenh', 'maed', 'mael', 'maelg', 'maelm', 'maelb',
0xF0 => 'maels', 'maelt', 'maelp', 'maelh', 'maem', 'maeb', 'maebs', 'maes', 'maess', 'maeng', 'maej', 'maech', 'maek', 'maet', 'maep', 'maeh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xba.php b/core/lib/Drupal/Component/Transliteration/data/xba.php
index 30878974e3c..5a5448a39d1 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xba.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xba.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'mya', 'myag', 'myakk', 'myags', 'myan', 'myanj', 'myanh', 'myad', 'myal', 'myalg', 'myalm', 'myalb', 'myals', 'myalt', 'myalp', 'myalh',
0x10 => 'myam', 'myab', 'myabs', 'myas', 'myass', 'myang', 'myaj', 'myach', 'myak', 'myat', 'myap', 'myah', 'myae', 'myaeg', 'myaekk', 'myaegs',
0x20 => 'myaen', 'myaenj', 'myaenh', 'myaed', 'myael', 'myaelg', 'myaelm', 'myaelb', 'myaels', 'myaelt', 'myaelp', 'myaelh', 'myaem', 'myaeb', 'myaebs', 'myaes',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'mwals', 'mwalt', 'mwalp', 'mwalh', 'mwam', 'mwab', 'mwabs', 'mwas', 'mwass', 'mwang', 'mwaj', 'mwach', 'mwak', 'mwat', 'mwap', 'mwah',
0xE0 => 'mwae', 'mwaeg', 'mwaekk', 'mwaegs', 'mwaen', 'mwaenj', 'mwaenh', 'mwaed', 'mwael', 'mwaelg', 'mwaelm', 'mwaelb', 'mwaels', 'mwaelt', 'mwaelp', 'mwaelh',
0xF0 => 'mwaem', 'mwaeb', 'mwaebs', 'mwaes', 'mwaess', 'mwaeng', 'mwaej', 'mwaech', 'mwaek', 'mwaet', 'mwaep', 'mwaeh', 'moe', 'moeg', 'moekk', 'moegs',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xbb.php b/core/lib/Drupal/Component/Transliteration/data/xbb.php
index 0f582fa79f0..1b1ab3ce06c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xbb.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xbb.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'moen', 'moenj', 'moenh', 'moed', 'moel', 'moelg', 'moelm', 'moelb', 'moels', 'moelt', 'moelp', 'moelh', 'moem', 'moeb', 'moebs', 'moes',
0x10 => 'moess', 'moeng', 'moej', 'moech', 'moek', 'moet', 'moep', 'moeh', 'myo', 'myog', 'myokk', 'myogs', 'myon', 'myonj', 'myonh', 'myod',
0x20 => 'myol', 'myolg', 'myolm', 'myolb', 'myols', 'myolt', 'myolp', 'myolh', 'myom', 'myob', 'myobs', 'myos', 'myoss', 'myong', 'myoj', 'myoch',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'meum', 'meub', 'meubs', 'meus', 'meuss', 'meung', 'meuj', 'meuch', 'meuk', 'meut', 'meup', 'meuh', 'mui', 'muig', 'muikk', 'muigs',
0xE0 => 'muin', 'muinj', 'muinh', 'muid', 'muil', 'muilg', 'muilm', 'muilb', 'muils', 'muilt', 'muilp', 'muilh', 'muim', 'muib', 'muibs', 'muis',
0xF0 => 'muiss', 'muing', 'muij', 'muich', 'muik', 'muit', 'muip', 'muih', 'mi', 'mig', 'mikk', 'migs', 'min', 'minj', 'minh', 'mid',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xbc.php b/core/lib/Drupal/Component/Transliteration/data/xbc.php
index e145545c454..df91ce6ae98 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xbc.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xbc.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'mil', 'milg', 'milm', 'milb', 'mils', 'milt', 'milp', 'milh', 'mim', 'mib', 'mibs', 'mis', 'miss', 'ming', 'mij', 'mich',
0x10 => 'mik', 'mit', 'mip', 'mih', 'ba', 'bag', 'bakk', 'bags', 'ban', 'banj', 'banh', 'bad', 'bal', 'balg', 'balm', 'balb',
0x20 => 'bals', 'balt', 'balp', 'balh', 'bam', 'bab', 'babs', 'bas', 'bass', 'bang', 'baj', 'bach', 'bak', 'bat', 'bap', 'bah',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'byeoss', 'byeong', 'byeoj', 'byeoch', 'byeok', 'byeot', 'byeop', 'byeoh', 'bye', 'byeg', 'byekk', 'byegs', 'byen', 'byenj', 'byenh', 'byed',
0xE0 => 'byel', 'byelg', 'byelm', 'byelb', 'byels', 'byelt', 'byelp', 'byelh', 'byem', 'byeb', 'byebs', 'byes', 'byess', 'byeng', 'byej', 'byech',
0xF0 => 'byek', 'byet', 'byep', 'byeh', 'bo', 'bog', 'bokk', 'bogs', 'bon', 'bonj', 'bonh', 'bod', 'bol', 'bolg', 'bolm', 'bolb',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xbd.php b/core/lib/Drupal/Component/Transliteration/data/xbd.php
index 539bb316fe8..5cb779c3ae9 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xbd.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xbd.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'bols', 'bolt', 'bolp', 'bolh', 'bom', 'bob', 'bobs', 'bos', 'boss', 'bong', 'boj', 'boch', 'bok', 'bot', 'bop', 'boh',
0x10 => 'bwa', 'bwag', 'bwakk', 'bwags', 'bwan', 'bwanj', 'bwanh', 'bwad', 'bwal', 'bwalg', 'bwalm', 'bwalb', 'bwals', 'bwalt', 'bwalp', 'bwalh',
0x20 => 'bwam', 'bwab', 'bwabs', 'bwas', 'bwass', 'bwang', 'bwaj', 'bwach', 'bwak', 'bwat', 'bwap', 'bwah', 'bwae', 'bwaeg', 'bwaekk', 'bwaegs',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'bwek', 'bwet', 'bwep', 'bweh', 'bwi', 'bwig', 'bwikk', 'bwigs', 'bwin', 'bwinj', 'bwinh', 'bwid', 'bwil', 'bwilg', 'bwilm', 'bwilb',
0xE0 => 'bwils', 'bwilt', 'bwilp', 'bwilh', 'bwim', 'bwib', 'bwibs', 'bwis', 'bwiss', 'bwing', 'bwij', 'bwich', 'bwik', 'bwit', 'bwip', 'bwih',
0xF0 => 'byu', 'byug', 'byukk', 'byugs', 'byun', 'byunj', 'byunh', 'byud', 'byul', 'byulg', 'byulm', 'byulb', 'byuls', 'byult', 'byulp', 'byulh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xbe.php b/core/lib/Drupal/Component/Transliteration/data/xbe.php
index 7d3bf6e825a..380003663aa 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xbe.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xbe.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'byum', 'byub', 'byubs', 'byus', 'byuss', 'byung', 'byuj', 'byuch', 'byuk', 'byut', 'byup', 'byuh', 'beu', 'beug', 'beukk', 'beugs',
0x10 => 'beun', 'beunj', 'beunh', 'beud', 'beul', 'beulg', 'beulm', 'beulb', 'beuls', 'beult', 'beulp', 'beulh', 'beum', 'beub', 'beubs', 'beus',
0x20 => 'beuss', 'beung', 'beuj', 'beuch', 'beuk', 'beut', 'beup', 'beuh', 'bui', 'buig', 'buikk', 'buigs', 'buin', 'buinj', 'buinh', 'buid',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ppeo', 'ppeog', 'ppeokk', 'ppeogs', 'ppeon', 'ppeonj', 'ppeonh', 'ppeod', 'ppeol', 'ppeolg', 'ppeolm', 'ppeolb', 'ppeols', 'ppeolt', 'ppeolp', 'ppeolh',
0xE0 => 'ppeom', 'ppeob', 'ppeobs', 'ppeos', 'ppeoss', 'ppeong', 'ppeoj', 'ppeoch', 'ppeok', 'ppeot', 'ppeop', 'ppeoh', 'ppe', 'ppeg', 'ppekk', 'ppegs',
0xF0 => 'ppen', 'ppenj', 'ppenh', 'pped', 'ppel', 'ppelg', 'ppelm', 'ppelb', 'ppels', 'ppelt', 'ppelp', 'ppelh', 'ppem', 'ppeb', 'ppebs', 'ppes',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xbf.php b/core/lib/Drupal/Component/Transliteration/data/xbf.php
index 5681ed1b84c..e355651088e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xbf.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xbf.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ppess', 'ppeng', 'ppej', 'ppech', 'ppek', 'ppet', 'ppep', 'ppeh', 'ppyeo', 'ppyeog', 'ppyeokk', 'ppyeogs', 'ppyeon', 'ppyeonj', 'ppyeonh', 'ppyeod',
0x10 => 'ppyeol', 'ppyeolg', 'ppyeolm', 'ppyeolb', 'ppyeols', 'ppyeolt', 'ppyeolp', 'ppyeolh', 'ppyeom', 'ppyeob', 'ppyeobs', 'ppyeos', 'ppyeoss', 'ppyeong', 'ppyeoj', 'ppyeoch',
0x20 => 'ppyeok', 'ppyeot', 'ppyeop', 'ppyeoh', 'ppye', 'ppyeg', 'ppyekk', 'ppyegs', 'ppyen', 'ppyenj', 'ppyenh', 'ppyed', 'ppyel', 'ppyelg', 'ppyelm', 'ppyelb',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ppun', 'ppunj', 'ppunh', 'ppud', 'ppul', 'ppulg', 'ppulm', 'ppulb', 'ppuls', 'ppult', 'ppulp', 'ppulh', 'ppum', 'ppub', 'ppubs', 'ppus',
0xE0 => 'ppuss', 'ppung', 'ppuj', 'ppuch', 'ppuk', 'pput', 'ppup', 'ppuh', 'ppwo', 'ppwog', 'ppwokk', 'ppwogs', 'ppwon', 'ppwonj', 'ppwonh', 'ppwod',
0xF0 => 'ppwol', 'ppwolg', 'ppwolm', 'ppwolb', 'ppwols', 'ppwolt', 'ppwolp', 'ppwolh', 'ppwom', 'ppwob', 'ppwobs', 'ppwos', 'ppwoss', 'ppwong', 'ppwoj', 'ppwoch',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc0.php b/core/lib/Drupal/Component/Transliteration/data/xc0.php
index 89512d1b199..003544e00e0 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc0.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc0.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ppwok', 'ppwot', 'ppwop', 'ppwoh', 'ppwe', 'ppweg', 'ppwekk', 'ppwegs', 'ppwen', 'ppwenj', 'ppwenh', 'ppwed', 'ppwel', 'ppwelg', 'ppwelm', 'ppwelb',
0x10 => 'ppwels', 'ppwelt', 'ppwelp', 'ppwelh', 'ppwem', 'ppweb', 'ppwebs', 'ppwes', 'ppwess', 'ppweng', 'ppwej', 'ppwech', 'ppwek', 'ppwet', 'ppwep', 'ppweh',
0x20 => 'ppwi', 'ppwig', 'ppwikk', 'ppwigs', 'ppwin', 'ppwinj', 'ppwinh', 'ppwid', 'ppwil', 'ppwilg', 'ppwilm', 'ppwilb', 'ppwils', 'ppwilt', 'ppwilp', 'ppwilh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'sael', 'saelg', 'saelm', 'saelb', 'saels', 'saelt', 'saelp', 'saelh', 'saem', 'saeb', 'saebs', 'saes', 'saess', 'saeng', 'saej', 'saech',
0xE0 => 'saek', 'saet', 'saep', 'saeh', 'sya', 'syag', 'syakk', 'syags', 'syan', 'syanj', 'syanh', 'syad', 'syal', 'syalg', 'syalm', 'syalb',
0xF0 => 'syals', 'syalt', 'syalp', 'syalh', 'syam', 'syab', 'syabs', 'syas', 'syass', 'syang', 'syaj', 'syach', 'syak', 'syat', 'syap', 'syah',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc1.php b/core/lib/Drupal/Component/Transliteration/data/xc1.php
index ae62f666741..217d8772b0f 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc1.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc1.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'syae', 'syaeg', 'syaekk', 'syaegs', 'syaen', 'syaenj', 'syaenh', 'syaed', 'syael', 'syaelg', 'syaelm', 'syaelb', 'syaels', 'syaelt', 'syaelp', 'syaelh',
0x10 => 'syaem', 'syaeb', 'syaebs', 'syaes', 'syaess', 'syaeng', 'syaej', 'syaech', 'syaek', 'syaet', 'syaep', 'syaeh', 'seo', 'seog', 'seokk', 'seogs',
0x20 => 'seon', 'seonj', 'seonh', 'seod', 'seol', 'seolg', 'seolm', 'seolb', 'seols', 'seolt', 'seolp', 'seolh', 'seom', 'seob', 'seobs', 'seos',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'swaels', 'swaelt', 'swaelp', 'swaelh', 'swaem', 'swaeb', 'swaebs', 'swaes', 'swaess', 'swaeng', 'swaej', 'swaech', 'swaek', 'swaet', 'swaep', 'swaeh',
0xE0 => 'soe', 'soeg', 'soekk', 'soegs', 'soen', 'soenj', 'soenh', 'soed', 'soel', 'soelg', 'soelm', 'soelb', 'soels', 'soelt', 'soelp', 'soelh',
0xF0 => 'soem', 'soeb', 'soebs', 'soes', 'soess', 'soeng', 'soej', 'soech', 'soek', 'soet', 'soep', 'soeh', 'syo', 'syog', 'syokk', 'syogs',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc2.php b/core/lib/Drupal/Component/Transliteration/data/xc2.php
index e540707e175..76a5738247c 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc2.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc2.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'syon', 'syonj', 'syonh', 'syod', 'syol', 'syolg', 'syolm', 'syolb', 'syols', 'syolt', 'syolp', 'syolh', 'syom', 'syob', 'syobs', 'syos',
0x10 => 'syoss', 'syong', 'syoj', 'syoch', 'syok', 'syot', 'syop', 'syoh', 'su', 'sug', 'sukk', 'sugs', 'sun', 'sunj', 'sunh', 'sud',
0x20 => 'sul', 'sulg', 'sulm', 'sulb', 'suls', 'sult', 'sulp', 'sulh', 'sum', 'sub', 'subs', 'sus', 'suss', 'sung', 'suj', 'such',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'suim', 'suib', 'suibs', 'suis', 'suiss', 'suing', 'suij', 'suich', 'suik', 'suit', 'suip', 'suih', 'si', 'sig', 'sikk', 'sigs',
0xE0 => 'sin', 'sinj', 'sinh', 'sid', 'sil', 'silg', 'silm', 'silb', 'sils', 'silt', 'silp', 'silh', 'sim', 'sib', 'sibs', 'sis',
0xF0 => 'siss', 'sing', 'sij', 'sich', 'sik', 'sit', 'sip', 'sih', 'ssa', 'ssag', 'ssakk', 'ssags', 'ssan', 'ssanj', 'ssanh', 'ssad',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc3.php b/core/lib/Drupal/Component/Transliteration/data/xc3.php
index 4fd97551ea9..24c8c247408 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc3.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc3.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ssal', 'ssalg', 'ssalm', 'ssalb', 'ssals', 'ssalt', 'ssalp', 'ssalh', 'ssam', 'ssab', 'ssabs', 'ssas', 'ssass', 'ssang', 'ssaj', 'ssach',
0x10 => 'ssak', 'ssat', 'ssap', 'ssah', 'ssae', 'ssaeg', 'ssaekk', 'ssaegs', 'ssaen', 'ssaenj', 'ssaenh', 'ssaed', 'ssael', 'ssaelg', 'ssaelm', 'ssaelb',
0x20 => 'ssaels', 'ssaelt', 'ssaelp', 'ssaelh', 'ssaem', 'ssaeb', 'ssaebs', 'ssaes', 'ssaess', 'ssaeng', 'ssaej', 'ssaech', 'ssaek', 'ssaet', 'ssaep', 'ssaeh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'ssyess', 'ssyeng', 'ssyej', 'ssyech', 'ssyek', 'ssyet', 'ssyep', 'ssyeh', 'sso', 'ssog', 'ssokk', 'ssogs', 'sson', 'ssonj', 'ssonh', 'ssod',
0xE0 => 'ssol', 'ssolg', 'ssolm', 'ssolb', 'ssols', 'ssolt', 'ssolp', 'ssolh', 'ssom', 'ssob', 'ssobs', 'ssos', 'ssoss', 'ssong', 'ssoj', 'ssoch',
0xF0 => 'ssok', 'ssot', 'ssop', 'ssoh', 'sswa', 'sswag', 'sswakk', 'sswags', 'sswan', 'sswanj', 'sswanh', 'sswad', 'sswal', 'sswalg', 'sswalm', 'sswalb',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc4.php b/core/lib/Drupal/Component/Transliteration/data/xc4.php
index 0e9034f32c6..5e0b9704a1e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc4.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc4.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'sswals', 'sswalt', 'sswalp', 'sswalh', 'sswam', 'sswab', 'sswabs', 'sswas', 'sswass', 'sswang', 'sswaj', 'sswach', 'sswak', 'sswat', 'sswap', 'sswah',
0x10 => 'sswae', 'sswaeg', 'sswaekk', 'sswaegs', 'sswaen', 'sswaenj', 'sswaenh', 'sswaed', 'sswael', 'sswaelg', 'sswaelm', 'sswaelb', 'sswaels', 'sswaelt', 'sswaelp', 'sswaelh',
0x20 => 'sswaem', 'sswaeb', 'sswaebs', 'sswaes', 'sswaess', 'sswaeng', 'sswaej', 'sswaech', 'sswaek', 'sswaet', 'sswaep', 'sswaeh', 'ssoe', 'ssoeg', 'ssoekk', 'ssoegs',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'sswik', 'sswit', 'sswip', 'sswih', 'ssyu', 'ssyug', 'ssyukk', 'ssyugs', 'ssyun', 'ssyunj', 'ssyunh', 'ssyud', 'ssyul', 'ssyulg', 'ssyulm', 'ssyulb',
0xE0 => 'ssyuls', 'ssyult', 'ssyulp', 'ssyulh', 'ssyum', 'ssyub', 'ssyubs', 'ssyus', 'ssyuss', 'ssyung', 'ssyuj', 'ssyuch', 'ssyuk', 'ssyut', 'ssyup', 'ssyuh',
0xF0 => 'sseu', 'sseug', 'sseukk', 'sseugs', 'sseun', 'sseunj', 'sseunh', 'sseud', 'sseul', 'sseulg', 'sseulm', 'sseulb', 'sseuls', 'sseult', 'sseulp', 'sseulh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc5.php b/core/lib/Drupal/Component/Transliteration/data/xc5.php
index 21085ce7e13..f6799281626 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc5.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc5.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'sseum', 'sseub', 'sseubs', 'sseus', 'sseuss', 'sseung', 'sseuj', 'sseuch', 'sseuk', 'sseut', 'sseup', 'sseuh', 'ssui', 'ssuig', 'ssuikk', 'ssuigs',
0x10 => 'ssuin', 'ssuinj', 'ssuinh', 'ssuid', 'ssuil', 'ssuilg', 'ssuilm', 'ssuilb', 'ssuils', 'ssuilt', 'ssuilp', 'ssuilh', 'ssuim', 'ssuib', 'ssuibs', 'ssuis',
0x20 => 'ssuiss', 'ssuing', 'ssuij', 'ssuich', 'ssuik', 'ssuit', 'ssuip', 'ssuih', 'ssi', 'ssig', 'ssikk', 'ssigs', 'ssin', 'ssinj', 'ssinh', 'ssid',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'e', 'eg', 'ekk', 'egs', 'en', 'enj', 'enh', 'ed', 'el', 'elg', 'elm', 'elb', 'els', 'elt', 'elp', 'elh',
0xE0 => 'em', 'eb', 'ebs', 'es', 'ess', 'eng', 'ej', 'ech', 'ek', 'et', 'ep', 'eh', 'yeo', 'yeog', 'yeokk', 'yeogs',
0xF0 => 'yeon', 'yeonj', 'yeonh', 'yeod', 'yeol', 'yeolg', 'yeolm', 'yeolb', 'yeols', 'yeolt', 'yeolp', 'yeolh', 'yeom', 'yeob', 'yeobs', 'yeos',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc6.php b/core/lib/Drupal/Component/Transliteration/data/xc6.php
index 7cd53f29779..fc2d89605f1 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc6.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc6.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yeoss', 'yeong', 'yeoj', 'yeoch', 'yeok', 'yeot', 'yeop', 'yeoh', 'ye', 'yeg', 'yekk', 'yegs', 'yen', 'yenj', 'yenh', 'yed',
0x10 => 'yel', 'yelg', 'yelm', 'yelb', 'yels', 'yelt', 'yelp', 'yelh', 'yem', 'yeb', 'yebs', 'yes', 'yess', 'yeng', 'yej', 'yech',
0x20 => 'yek', 'yet', 'yep', 'yeh', 'o', 'og', 'okk', 'ogs', 'on', 'onj', 'onh', 'od', 'ol', 'olg', 'olm', 'olb',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'won', 'wonj', 'wonh', 'wod', 'wol', 'wolg', 'wolm', 'wolb', 'wols', 'wolt', 'wolp', 'wolh', 'wom', 'wob', 'wobs', 'wos',
0xE0 => 'woss', 'wong', 'woj', 'woch', 'wok', 'wot', 'wop', 'woh', 'we', 'weg', 'wekk', 'wegs', 'wen', 'wenj', 'wenh', 'wed',
0xF0 => 'wel', 'welg', 'welm', 'welb', 'wels', 'welt', 'welp', 'welh', 'wem', 'web', 'webs', 'wes', 'wess', 'weng', 'wej', 'wech',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc7.php b/core/lib/Drupal/Component/Transliteration/data/xc7.php
index f362ad40ece..405fd162232 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc7.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc7.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'wek', 'wet', 'wep', 'weh', 'wi', 'wig', 'wikk', 'wigs', 'win', 'winj', 'winh', 'wid', 'wil', 'wilg', 'wilm', 'wilb',
0x10 => 'wils', 'wilt', 'wilp', 'wilh', 'wim', 'wib', 'wibs', 'wis', 'wiss', 'wing', 'wij', 'wich', 'wik', 'wit', 'wip', 'wih',
0x20 => 'yu', 'yug', 'yukk', 'yugs', 'yun', 'yunj', 'yunh', 'yud', 'yul', 'yulg', 'yulm', 'yulb', 'yuls', 'yult', 'yulp', 'yulh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jyal', 'jyalg', 'jyalm', 'jyalb', 'jyals', 'jyalt', 'jyalp', 'jyalh', 'jyam', 'jyab', 'jyabs', 'jyas', 'jyass', 'jyang', 'jyaj', 'jyach',
0xE0 => 'jyak', 'jyat', 'jyap', 'jyah', 'jyae', 'jyaeg', 'jyaekk', 'jyaegs', 'jyaen', 'jyaenj', 'jyaenh', 'jyaed', 'jyael', 'jyaelg', 'jyaelm', 'jyaelb',
0xF0 => 'jyaels', 'jyaelt', 'jyaelp', 'jyaelh', 'jyaem', 'jyaeb', 'jyaebs', 'jyaes', 'jyaess', 'jyaeng', 'jyaej', 'jyaech', 'jyaek', 'jyaet', 'jyaep', 'jyaeh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc8.php b/core/lib/Drupal/Component/Transliteration/data/xc8.php
index 656a0703fd1..952a1391797 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc8.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc8.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'jeo', 'jeog', 'jeokk', 'jeogs', 'jeon', 'jeonj', 'jeonh', 'jeod', 'jeol', 'jeolg', 'jeolm', 'jeolb', 'jeols', 'jeolt', 'jeolp', 'jeolh',
0x10 => 'jeom', 'jeob', 'jeobs', 'jeos', 'jeoss', 'jeong', 'jeoj', 'jeoch', 'jeok', 'jeot', 'jeop', 'jeoh', 'je', 'jeg', 'jekk', 'jegs',
0x20 => 'jen', 'jenj', 'jenh', 'jed', 'jel', 'jelg', 'jelm', 'jelb', 'jels', 'jelt', 'jelp', 'jelh', 'jem', 'jeb', 'jebs', 'jes',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'joels', 'joelt', 'joelp', 'joelh', 'joem', 'joeb', 'joebs', 'joes', 'joess', 'joeng', 'joej', 'joech', 'joek', 'joet', 'joep', 'joeh',
0xE0 => 'jyo', 'jyog', 'jyokk', 'jyogs', 'jyon', 'jyonj', 'jyonh', 'jyod', 'jyol', 'jyolg', 'jyolm', 'jyolb', 'jyols', 'jyolt', 'jyolp', 'jyolh',
0xF0 => 'jyom', 'jyob', 'jyobs', 'jyos', 'jyoss', 'jyong', 'jyoj', 'jyoch', 'jyok', 'jyot', 'jyop', 'jyoh', 'ju', 'jug', 'jukk', 'jugs',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xc9.php b/core/lib/Drupal/Component/Transliteration/data/xc9.php
index 5fd5eb5066e..0d990f77d55 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xc9.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xc9.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'jun', 'junj', 'junh', 'jud', 'jul', 'julg', 'julm', 'julb', 'juls', 'jult', 'julp', 'julh', 'jum', 'jub', 'jubs', 'jus',
0x10 => 'juss', 'jung', 'juj', 'juch', 'juk', 'jut', 'jup', 'juh', 'jwo', 'jwog', 'jwokk', 'jwogs', 'jwon', 'jwonj', 'jwonh', 'jwod',
0x20 => 'jwol', 'jwolg', 'jwolm', 'jwolb', 'jwols', 'jwolt', 'jwolp', 'jwolh', 'jwom', 'jwob', 'jwobs', 'jwos', 'jwoss', 'jwong', 'jwoj', 'jwoch',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jim', 'jib', 'jibs', 'jis', 'jiss', 'jing', 'jij', 'jich', 'jik', 'jit', 'jip', 'jih', 'jja', 'jjag', 'jjakk', 'jjags',
0xE0 => 'jjan', 'jjanj', 'jjanh', 'jjad', 'jjal', 'jjalg', 'jjalm', 'jjalb', 'jjals', 'jjalt', 'jjalp', 'jjalh', 'jjam', 'jjab', 'jjabs', 'jjas',
0xF0 => 'jjass', 'jjang', 'jjaj', 'jjach', 'jjak', 'jjat', 'jjap', 'jjah', 'jjae', 'jjaeg', 'jjaekk', 'jjaegs', 'jjaen', 'jjaenj', 'jjaenh', 'jjaed',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xca.php b/core/lib/Drupal/Component/Transliteration/data/xca.php
index 7ebaa755307..be314ec4fb6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xca.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xca.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'jjael', 'jjaelg', 'jjaelm', 'jjaelb', 'jjaels', 'jjaelt', 'jjaelp', 'jjaelh', 'jjaem', 'jjaeb', 'jjaebs', 'jjaes', 'jjaess', 'jjaeng', 'jjaej', 'jjaech',
0x10 => 'jjaek', 'jjaet', 'jjaep', 'jjaeh', 'jjya', 'jjyag', 'jjyakk', 'jjyags', 'jjyan', 'jjyanj', 'jjyanh', 'jjyad', 'jjyal', 'jjyalg', 'jjyalm', 'jjyalb',
0x20 => 'jjyals', 'jjyalt', 'jjyalp', 'jjyalh', 'jjyam', 'jjyab', 'jjyabs', 'jjyas', 'jjyass', 'jjyang', 'jjyaj', 'jjyach', 'jjyak', 'jjyat', 'jjyap', 'jjyah',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jjoss', 'jjong', 'jjoj', 'jjoch', 'jjok', 'jjot', 'jjop', 'jjoh', 'jjwa', 'jjwag', 'jjwakk', 'jjwags', 'jjwan', 'jjwanj', 'jjwanh', 'jjwad',
0xE0 => 'jjwal', 'jjwalg', 'jjwalm', 'jjwalb', 'jjwals', 'jjwalt', 'jjwalp', 'jjwalh', 'jjwam', 'jjwab', 'jjwabs', 'jjwas', 'jjwass', 'jjwang', 'jjwaj', 'jjwach',
0xF0 => 'jjwak', 'jjwat', 'jjwap', 'jjwah', 'jjwae', 'jjwaeg', 'jjwaekk', 'jjwaegs', 'jjwaen', 'jjwaenj', 'jjwaenh', 'jjwaed', 'jjwael', 'jjwaelg', 'jjwaelm', 'jjwaelb',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xcb.php b/core/lib/Drupal/Component/Transliteration/data/xcb.php
index cbd291ab0dd..c396fcd3ce2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xcb.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xcb.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'jjwaels', 'jjwaelt', 'jjwaelp', 'jjwaelh', 'jjwaem', 'jjwaeb', 'jjwaebs', 'jjwaes', 'jjwaess', 'jjwaeng', 'jjwaej', 'jjwaech', 'jjwaek', 'jjwaet', 'jjwaep', 'jjwaeh',
0x10 => 'jjoe', 'jjoeg', 'jjoekk', 'jjoegs', 'jjoen', 'jjoenj', 'jjoenh', 'jjoed', 'jjoel', 'jjoelg', 'jjoelm', 'jjoelb', 'jjoels', 'jjoelt', 'jjoelp', 'jjoelh',
0x20 => 'jjoem', 'jjoeb', 'jjoebs', 'jjoes', 'jjoess', 'jjoeng', 'jjoej', 'jjoech', 'jjoek', 'jjoet', 'jjoep', 'jjoeh', 'jjyo', 'jjyog', 'jjyokk', 'jjyogs',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'jjyuk', 'jjyut', 'jjyup', 'jjyuh', 'jjeu', 'jjeug', 'jjeukk', 'jjeugs', 'jjeun', 'jjeunj', 'jjeunh', 'jjeud', 'jjeul', 'jjeulg', 'jjeulm', 'jjeulb',
0xE0 => 'jjeuls', 'jjeult', 'jjeulp', 'jjeulh', 'jjeum', 'jjeub', 'jjeubs', 'jjeus', 'jjeuss', 'jjeung', 'jjeuj', 'jjeuch', 'jjeuk', 'jjeut', 'jjeup', 'jjeuh',
0xF0 => 'jjui', 'jjuig', 'jjuikk', 'jjuigs', 'jjuin', 'jjuinj', 'jjuinh', 'jjuid', 'jjuil', 'jjuilg', 'jjuilm', 'jjuilb', 'jjuils', 'jjuilt', 'jjuilp', 'jjuilh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xcc.php b/core/lib/Drupal/Component/Transliteration/data/xcc.php
index d543b26fa27..4dc25f26ecb 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xcc.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xcc.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'jjuim', 'jjuib', 'jjuibs', 'jjuis', 'jjuiss', 'jjuing', 'jjuij', 'jjuich', 'jjuik', 'jjuit', 'jjuip', 'jjuih', 'jji', 'jjig', 'jjikk', 'jjigs',
0x10 => 'jjin', 'jjinj', 'jjinh', 'jjid', 'jjil', 'jjilg', 'jjilm', 'jjilb', 'jjils', 'jjilt', 'jjilp', 'jjilh', 'jjim', 'jjib', 'jjibs', 'jjis',
0x20 => 'jjiss', 'jjing', 'jjij', 'jjich', 'jjik', 'jjit', 'jjip', 'jjih', 'cha', 'chag', 'chakk', 'chags', 'chan', 'chanj', 'chanh', 'chad',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chyeo', 'chyeog', 'chyeokk', 'chyeogs', 'chyeon', 'chyeonj', 'chyeonh', 'chyeod', 'chyeol', 'chyeolg', 'chyeolm', 'chyeolb', 'chyeols', 'chyeolt', 'chyeolp', 'chyeolh',
0xE0 => 'chyeom', 'chyeob', 'chyeobs', 'chyeos', 'chyeoss', 'chyeong', 'chyeoj', 'chyeoch', 'chyeok', 'chyeot', 'chyeop', 'chyeoh', 'chye', 'chyeg', 'chyekk', 'chyegs',
0xF0 => 'chyen', 'chyenj', 'chyenh', 'chyed', 'chyel', 'chyelg', 'chyelm', 'chyelb', 'chyels', 'chyelt', 'chyelp', 'chyelh', 'chyem', 'chyeb', 'chyebs', 'chyes',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xcd.php b/core/lib/Drupal/Component/Transliteration/data/xcd.php
index 6f730e57ea7..21f2ed7f9b4 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xcd.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xcd.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'chyess', 'chyeng', 'chyej', 'chyech', 'chyek', 'chyet', 'chyep', 'chyeh', 'cho', 'chog', 'chokk', 'chogs', 'chon', 'chonj', 'chonh', 'chod',
0x10 => 'chol', 'cholg', 'cholm', 'cholb', 'chols', 'cholt', 'cholp', 'cholh', 'chom', 'chob', 'chobs', 'chos', 'choss', 'chong', 'choj', 'choch',
0x20 => 'chok', 'chot', 'chop', 'choh', 'chwa', 'chwag', 'chwakk', 'chwags', 'chwan', 'chwanj', 'chwanh', 'chwad', 'chwal', 'chwalg', 'chwalm', 'chwalb',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'chwen', 'chwenj', 'chwenh', 'chwed', 'chwel', 'chwelg', 'chwelm', 'chwelb', 'chwels', 'chwelt', 'chwelp', 'chwelh', 'chwem', 'chweb', 'chwebs', 'chwes',
0xE0 => 'chwess', 'chweng', 'chwej', 'chwech', 'chwek', 'chwet', 'chwep', 'chweh', 'chwi', 'chwig', 'chwikk', 'chwigs', 'chwin', 'chwinj', 'chwinh', 'chwid',
0xF0 => 'chwil', 'chwilg', 'chwilm', 'chwilb', 'chwils', 'chwilt', 'chwilp', 'chwilh', 'chwim', 'chwib', 'chwibs', 'chwis', 'chwiss', 'chwing', 'chwij', 'chwich',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xce.php b/core/lib/Drupal/Component/Transliteration/data/xce.php
index 099354e8723..08dff787c29 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xce.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xce.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'chwik', 'chwit', 'chwip', 'chwih', 'chyu', 'chyug', 'chyukk', 'chyugs', 'chyun', 'chyunj', 'chyunh', 'chyud', 'chyul', 'chyulg', 'chyulm', 'chyulb',
0x10 => 'chyuls', 'chyult', 'chyulp', 'chyulh', 'chyum', 'chyub', 'chyubs', 'chyus', 'chyuss', 'chyung', 'chyuj', 'chyuch', 'chyuk', 'chyut', 'chyup', 'chyuh',
0x20 => 'cheu', 'cheug', 'cheukk', 'cheugs', 'cheun', 'cheunj', 'cheunh', 'cheud', 'cheul', 'cheulg', 'cheulm', 'cheulb', 'cheuls', 'cheult', 'cheulp', 'cheulh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'kyael', 'kyaelg', 'kyaelm', 'kyaelb', 'kyaels', 'kyaelt', 'kyaelp', 'kyaelh', 'kyaem', 'kyaeb', 'kyaebs', 'kyaes', 'kyaess', 'kyaeng', 'kyaej', 'kyaech',
0xE0 => 'kyaek', 'kyaet', 'kyaep', 'kyaeh', 'keo', 'keog', 'keokk', 'keogs', 'keon', 'keonj', 'keonh', 'keod', 'keol', 'keolg', 'keolm', 'keolb',
0xF0 => 'keols', 'keolt', 'keolp', 'keolh', 'keom', 'keob', 'keobs', 'keos', 'keoss', 'keong', 'keoj', 'keoch', 'keok', 'keot', 'keop', 'keoh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xcf.php b/core/lib/Drupal/Component/Transliteration/data/xcf.php
index 434113f8f05..2a0a946cd9e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xcf.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xcf.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ke', 'keg', 'kekk', 'kegs', 'ken', 'kenj', 'kenh', 'ked', 'kel', 'kelg', 'kelm', 'kelb', 'kels', 'kelt', 'kelp', 'kelh',
0x10 => 'kem', 'keb', 'kebs', 'kes', 'kess', 'keng', 'kej', 'kech', 'kek', 'ket', 'kep', 'keh', 'kyeo', 'kyeog', 'kyeokk', 'kyeogs',
0x20 => 'kyeon', 'kyeonj', 'kyeonh', 'kyeod', 'kyeol', 'kyeolg', 'kyeolm', 'kyeolb', 'kyeols', 'kyeolt', 'kyeolp', 'kyeolh', 'kyeom', 'kyeob', 'kyeobs', 'kyeos',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'kyols', 'kyolt', 'kyolp', 'kyolh', 'kyom', 'kyob', 'kyobs', 'kyos', 'kyoss', 'kyong', 'kyoj', 'kyoch', 'kyok', 'kyot', 'kyop', 'kyoh',
0xE0 => 'ku', 'kug', 'kukk', 'kugs', 'kun', 'kunj', 'kunh', 'kud', 'kul', 'kulg', 'kulm', 'kulb', 'kuls', 'kult', 'kulp', 'kulh',
0xF0 => 'kum', 'kub', 'kubs', 'kus', 'kuss', 'kung', 'kuj', 'kuch', 'kuk', 'kut', 'kup', 'kuh', 'kwo', 'kwog', 'kwokk', 'kwogs',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd0.php b/core/lib/Drupal/Component/Transliteration/data/xd0.php
index 848b49c7da6..3c94c683512 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd0.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd0.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'kwon', 'kwonj', 'kwonh', 'kwod', 'kwol', 'kwolg', 'kwolm', 'kwolb', 'kwols', 'kwolt', 'kwolp', 'kwolh', 'kwom', 'kwob', 'kwobs', 'kwos',
0x10 => 'kwoss', 'kwong', 'kwoj', 'kwoch', 'kwok', 'kwot', 'kwop', 'kwoh', 'kwe', 'kweg', 'kwekk', 'kwegs', 'kwen', 'kwenj', 'kwenh', 'kwed',
0x20 => 'kwel', 'kwelg', 'kwelm', 'kwelb', 'kwels', 'kwelt', 'kwelp', 'kwelh', 'kwem', 'kweb', 'kwebs', 'kwes', 'kwess', 'kweng', 'kwej', 'kwech',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'tam', 'tab', 'tabs', 'tas', 'tass', 'tang', 'taj', 'tach', 'tak', 'tat', 'tap', 'tah', 'tae', 'taeg', 'taekk', 'taegs',
0xE0 => 'taen', 'taenj', 'taenh', 'taed', 'tael', 'taelg', 'taelm', 'taelb', 'taels', 'taelt', 'taelp', 'taelh', 'taem', 'taeb', 'taebs', 'taes',
0xF0 => 'taess', 'taeng', 'taej', 'taech', 'taek', 'taet', 'taep', 'taeh', 'tya', 'tyag', 'tyakk', 'tyags', 'tyan', 'tyanj', 'tyanh', 'tyad',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd1.php b/core/lib/Drupal/Component/Transliteration/data/xd1.php
index c6504f4c869..418f2070d7e 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd1.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd1.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'tyal', 'tyalg', 'tyalm', 'tyalb', 'tyals', 'tyalt', 'tyalp', 'tyalh', 'tyam', 'tyab', 'tyabs', 'tyas', 'tyass', 'tyang', 'tyaj', 'tyach',
0x10 => 'tyak', 'tyat', 'tyap', 'tyah', 'tyae', 'tyaeg', 'tyaekk', 'tyaegs', 'tyaen', 'tyaenj', 'tyaenh', 'tyaed', 'tyael', 'tyaelg', 'tyaelm', 'tyaelb',
0x20 => 'tyaels', 'tyaelt', 'tyaelp', 'tyaelh', 'tyaem', 'tyaeb', 'tyaebs', 'tyaes', 'tyaess', 'tyaeng', 'tyaej', 'tyaech', 'tyaek', 'tyaet', 'tyaep', 'tyaeh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'twass', 'twang', 'twaj', 'twach', 'twak', 'twat', 'twap', 'twah', 'twae', 'twaeg', 'twaekk', 'twaegs', 'twaen', 'twaenj', 'twaenh', 'twaed',
0xE0 => 'twael', 'twaelg', 'twaelm', 'twaelb', 'twaels', 'twaelt', 'twaelp', 'twaelh', 'twaem', 'twaeb', 'twaebs', 'twaes', 'twaess', 'twaeng', 'twaej', 'twaech',
0xF0 => 'twaek', 'twaet', 'twaep', 'twaeh', 'toe', 'toeg', 'toekk', 'toegs', 'toen', 'toenj', 'toenh', 'toed', 'toel', 'toelg', 'toelm', 'toelb',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd2.php b/core/lib/Drupal/Component/Transliteration/data/xd2.php
index 741c229f7d1..d749276f84b 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd2.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd2.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'toels', 'toelt', 'toelp', 'toelh', 'toem', 'toeb', 'toebs', 'toes', 'toess', 'toeng', 'toej', 'toech', 'toek', 'toet', 'toep', 'toeh',
0x10 => 'tyo', 'tyog', 'tyokk', 'tyogs', 'tyon', 'tyonj', 'tyonh', 'tyod', 'tyol', 'tyolg', 'tyolm', 'tyolb', 'tyols', 'tyolt', 'tyolp', 'tyolh',
0x20 => 'tyom', 'tyob', 'tyobs', 'tyos', 'tyoss', 'tyong', 'tyoj', 'tyoch', 'tyok', 'tyot', 'tyop', 'tyoh', 'tu', 'tug', 'tukk', 'tugs',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'teuk', 'teut', 'teup', 'teuh', 'tui', 'tuig', 'tuikk', 'tuigs', 'tuin', 'tuinj', 'tuinh', 'tuid', 'tuil', 'tuilg', 'tuilm', 'tuilb',
0xE0 => 'tuils', 'tuilt', 'tuilp', 'tuilh', 'tuim', 'tuib', 'tuibs', 'tuis', 'tuiss', 'tuing', 'tuij', 'tuich', 'tuik', 'tuit', 'tuip', 'tuih',
0xF0 => 'ti', 'tig', 'tikk', 'tigs', 'tin', 'tinj', 'tinh', 'tid', 'til', 'tilg', 'tilm', 'tilb', 'tils', 'tilt', 'tilp', 'tilh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd3.php b/core/lib/Drupal/Component/Transliteration/data/xd3.php
index 54aab18ed2b..d56ee58a2c2 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd3.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd3.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'tim', 'tib', 'tibs', 'tis', 'tiss', 'ting', 'tij', 'tich', 'tik', 'tit', 'tip', 'tih', 'pa', 'pag', 'pakk', 'pags',
0x10 => 'pan', 'panj', 'panh', 'pad', 'pal', 'palg', 'palm', 'palb', 'pals', 'palt', 'palp', 'palh', 'pam', 'pab', 'pabs', 'pas',
0x20 => 'pass', 'pang', 'paj', 'pach', 'pak', 'pat', 'pap', 'pah', 'pae', 'paeg', 'paekk', 'paegs', 'paen', 'paenj', 'paenh', 'paed',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'pye', 'pyeg', 'pyekk', 'pyegs', 'pyen', 'pyenj', 'pyenh', 'pyed', 'pyel', 'pyelg', 'pyelm', 'pyelb', 'pyels', 'pyelt', 'pyelp', 'pyelh',
0xE0 => 'pyem', 'pyeb', 'pyebs', 'pyes', 'pyess', 'pyeng', 'pyej', 'pyech', 'pyek', 'pyet', 'pyep', 'pyeh', 'po', 'pog', 'pokk', 'pogs',
0xF0 => 'pon', 'ponj', 'ponh', 'pod', 'pol', 'polg', 'polm', 'polb', 'pols', 'polt', 'polp', 'polh', 'pom', 'pob', 'pobs', 'pos',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd4.php b/core/lib/Drupal/Component/Transliteration/data/xd4.php
index 0df64106af3..dcbf3ecbab6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd4.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd4.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'poss', 'pong', 'poj', 'poch', 'pok', 'pot', 'pop', 'poh', 'pwa', 'pwag', 'pwakk', 'pwags', 'pwan', 'pwanj', 'pwanh', 'pwad',
0x10 => 'pwal', 'pwalg', 'pwalm', 'pwalb', 'pwals', 'pwalt', 'pwalp', 'pwalh', 'pwam', 'pwab', 'pwabs', 'pwas', 'pwass', 'pwang', 'pwaj', 'pwach',
0x20 => 'pwak', 'pwat', 'pwap', 'pwah', 'pwae', 'pwaeg', 'pwaekk', 'pwaegs', 'pwaen', 'pwaenj', 'pwaenh', 'pwaed', 'pwael', 'pwaelg', 'pwaelm', 'pwaelb',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'pwin', 'pwinj', 'pwinh', 'pwid', 'pwil', 'pwilg', 'pwilm', 'pwilb', 'pwils', 'pwilt', 'pwilp', 'pwilh', 'pwim', 'pwib', 'pwibs', 'pwis',
0xE0 => 'pwiss', 'pwing', 'pwij', 'pwich', 'pwik', 'pwit', 'pwip', 'pwih', 'pyu', 'pyug', 'pyukk', 'pyugs', 'pyun', 'pyunj', 'pyunh', 'pyud',
0xF0 => 'pyul', 'pyulg', 'pyulm', 'pyulb', 'pyuls', 'pyult', 'pyulp', 'pyulh', 'pyum', 'pyub', 'pyubs', 'pyus', 'pyuss', 'pyung', 'pyuj', 'pyuch',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd5.php b/core/lib/Drupal/Component/Transliteration/data/xd5.php
index 2dbeadaae43..0b3efb145c0 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd5.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd5.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'pyuk', 'pyut', 'pyup', 'pyuh', 'peu', 'peug', 'peukk', 'peugs', 'peun', 'peunj', 'peunh', 'peud', 'peul', 'peulg', 'peulm', 'peulb',
0x10 => 'peuls', 'peult', 'peulp', 'peulh', 'peum', 'peub', 'peubs', 'peus', 'peuss', 'peung', 'peuj', 'peuch', 'peuk', 'peut', 'peup', 'peuh',
0x20 => 'pui', 'puig', 'puikk', 'puigs', 'puin', 'puinj', 'puinh', 'puid', 'puil', 'puilg', 'puilm', 'puilb', 'puils', 'puilt', 'puilp', 'puilh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'heol', 'heolg', 'heolm', 'heolb', 'heols', 'heolt', 'heolp', 'heolh', 'heom', 'heob', 'heobs', 'heos', 'heoss', 'heong', 'heoj', 'heoch',
0xE0 => 'heok', 'heot', 'heop', 'heoh', 'he', 'heg', 'hekk', 'hegs', 'hen', 'henj', 'henh', 'hed', 'hel', 'helg', 'helm', 'helb',
0xF0 => 'hels', 'helt', 'help', 'helh', 'hem', 'heb', 'hebs', 'hes', 'hess', 'heng', 'hej', 'hech', 'hek', 'het', 'hep', 'heh',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd6.php b/core/lib/Drupal/Component/Transliteration/data/xd6.php
index e86914f0835..ae1dcf781f7 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd6.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd6.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'hyeo', 'hyeog', 'hyeokk', 'hyeogs', 'hyeon', 'hyeonj', 'hyeonh', 'hyeod', 'hyeol', 'hyeolg', 'hyeolm', 'hyeolb', 'hyeols', 'hyeolt', 'hyeolp', 'hyeolh',
0x10 => 'hyeom', 'hyeob', 'hyeobs', 'hyeos', 'hyeoss', 'hyeong', 'hyeoj', 'hyeoch', 'hyeok', 'hyeot', 'hyeop', 'hyeoh', 'hye', 'hyeg', 'hyekk', 'hyegs',
0x20 => 'hyen', 'hyenj', 'hyenh', 'hyed', 'hyel', 'hyelg', 'hyelm', 'hyelb', 'hyels', 'hyelt', 'hyelp', 'hyelh', 'hyem', 'hyeb', 'hyebs', 'hyes',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'huls', 'hult', 'hulp', 'hulh', 'hum', 'hub', 'hubs', 'hus', 'huss', 'hung', 'huj', 'huch', 'huk', 'hut', 'hup', 'huh',
0xE0 => 'hwo', 'hwog', 'hwokk', 'hwogs', 'hwon', 'hwonj', 'hwonh', 'hwod', 'hwol', 'hwolg', 'hwolm', 'hwolb', 'hwols', 'hwolt', 'hwolp', 'hwolh',
0xF0 => 'hwom', 'hwob', 'hwobs', 'hwos', 'hwoss', 'hwong', 'hwoj', 'hwoch', 'hwok', 'hwot', 'hwop', 'hwoh', 'hwe', 'hweg', 'hwekk', 'hwegs',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xd7.php b/core/lib/Drupal/Component/Transliteration/data/xd7.php
index af74c89b632..c0f75b54c59 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xd7.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xd7.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'hwen', 'hwenj', 'hwenh', 'hwed', 'hwel', 'hwelg', 'hwelm', 'hwelb', 'hwels', 'hwelt', 'hwelp', 'hwelh', 'hwem', 'hweb', 'hwebs', 'hwes',
0x10 => 'hwess', 'hweng', 'hwej', 'hwech', 'hwek', 'hwet', 'hwep', 'hweh', 'hwi', 'hwig', 'hwikk', 'hwigs', 'hwin', 'hwinj', 'hwinh', 'hwid',
0x20 => 'hwil', 'hwilg', 'hwilm', 'hwilb', 'hwils', 'hwilt', 'hwilp', 'hwilh', 'hwim', 'hwib', 'hwibs', 'hwis', 'hwiss', 'hwing', 'hwij', 'hwich',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xf9.php b/core/lib/Drupal/Component/Transliteration/data/xf9.php
index efc84995a20..29eaa3bf679 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xf9.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xf9.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'qi', 'geng', 'che', 'jia', 'hua', 'chuan', 'ju', 'gui', 'gui', 'qi', 'jin', 'la', 'nai', 'lan', 'lai', 'luo',
0x10 => 'luo', 'luo', 'luo', 'luo', 'le', 'luo', 'lao', 'luo', 'luo', 'lao', 'luo', 'luan', 'luan', 'lan', 'lan', 'lan',
0x20 => 'luan', 'lan', 'lan', 'lan', 'lan', 'la', 'la', 'la', 'lang', 'lang', 'lang', 'lang', 'lang', 'lai', 'leng', 'lao',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'lei', 'liu', 'lu', 'lu', 'lun', 'lun', 'lun', 'lun', 'lu', 'li', 'li', 'lu', 'long', 'li', 'li', 'lu',
0xE0 => 'yi', 'li', 'li', 'ni', 'li', 'li', 'li', 'li', 'li', 'li', 'li', 'ni', 'ni', 'lin', 'lin', 'lin',
0xF0 => 'lin', 'lin', 'lin', 'lin', 'lin', 'lin', 'lin', 'li', 'li', 'li', 'zhuang', 'zhi', 'shi', 'shen', 'cha', 'ci',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xfa.php b/core/lib/Drupal/Component/Transliteration/data/xfa.php
index 7ba4ae8c0ca..d5b92f636b0 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xfa.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xfa.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'qie', 'du', 'ta', 'tang', 'zhai', 'dong', 'bao', 'fu', 'xing', 'jiang', 'jian', 'kuo', 'wu', 'hu', NULL, NULL,
0x10 => 'zhong', NULL, 'qing', NULL, NULL, 'xi', 'zhu', 'yi', 'li', 'shen', 'xiang', 'fu', 'jing', 'jing', 'yu', NULL,
0x20 => 'qiu', NULL, 'zhu', NULL, NULL, 'yi', 'dou', NULL, NULL, NULL, 'fan', 'si', 'guan', 'he', NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, 'he', 'xie', 'jie', NULL, 'qian', 'beng', 'e', 'pang', NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xfb.php b/core/lib/Drupal/Component/Transliteration/data/xfb.php
index 7dd47aee80e..aa734cd7bbc 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xfb.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xfb.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => NULL, NULL, NULL, 'mn', 'me', 'mi', 'vn', 'mkh', NULL, NULL, NULL, NULL, NULL, 'y', '', 'yy',
0x20 => '`', '', 'd', 'h', 'k', 'l', 'm', 'r', 't', '+', 's', 's', 's', 's', 'a', 'a',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, 'ng', 'ng', 'ng', 'ng', '', '', '', '', '', '', '', 'v', 'v',
0xE0 => '', '', '', '', '', '', '', '', 'y', 'y', 'ya', 'ya', '', '', 'yw', 'yw',
0xF0 => '', '', '', '', '', '', '', '', '', 'yy', 'yy', 'yy', 'y', 'y', 'y', 'y',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xfc.php b/core/lib/Drupal/Component/Transliteration/data/xfc.php
index 959ef1e7958..aac2f66cee6 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xfc.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xfc.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'yj', 'yh', 'ym', 'yy', 'yy', 'bj', 'bh', 'bkh', 'bm', 'by', 'by', 'tj', 'th', 'tkh', 'tm', 'ty',
0x10 => 'ty', 'thj', 'thm', 'thy', 'thy', 'jh', 'jm', 'hj', 'hm', 'khj', 'khh', 'khm', 'sj', 'sh', 'skh', 'sm',
0x20 => 'sh', 'sm', 'dj', 'dh', 'dkh', 'dm', 'th', 'tm', 'zm', '', '', 'ghj', 'ghm', 'fj', 'fh', 'fkh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'mkh', 'mm', 'nj', 'nh', 'nkh', 'nm', 'nh', 'hj', 'hm', 'h', 'yj', 'yh', 'ykh', 'ym', 'yh', 'ym',
0xE0 => 'yh', 'bm', 'bh', 'tm', 'th', 'thm', 'thh', 'sm', 'sh', 'shm', 'shh', 'kl', 'km', 'lm', 'nm', 'nh',
0xF0 => 'ym', 'yh', 'a', 'u', 'i', 'ty', 'ty', '', '', 'ghy', 'ghy', 'sy', 'sy', 'shy', 'shy', 'hy',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xfd.php b/core/lib/Drupal/Component/Transliteration/data/xfd.php
index 26372c4831a..a970732993a 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xfd.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xfd.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => 'hy', 'jy', 'jy', 'khy', 'khy', 'sy', 'sy', 'dy', 'dy', 'shj', 'shh', 'shkh', 'shm', 'shr', 'sr', 'sr',
0x10 => 'dr', 'ty', 'ty', '', '', 'ghy', 'ghy', 'sy', 'sy', 'shy', 'shy', 'hy', 'hy', 'jy', 'jy', 'khy',
0x20 => 'khy', 'sy', 'sy', 'dy', 'dy', 'shj', 'shh', 'shkh', 'shm', 'shr', 'sr', 'sr', 'dr', 'shj', 'shh', 'shkh',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0xF0 => '', '', 'allh', 'akbr', 'mhmd', '', 'rswl', '', 'wslm', 'sly', '', 'jl jlalh', 'ryal', NULL, NULL, NULL,
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xfe.php b/core/lib/Drupal/Component/Transliteration/data/xfe.php
index c53867bd48f..d05402004bf 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xfe.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xfe.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0x10 => ',', ',', '.', ':', ';', '!', '?', NULL, NULL, '...', NULL, NULL, NULL, NULL, NULL, NULL,
0x20 => '', '', '', '~', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -22,4 +22,4 @@ $base = array(
0xD0 => 'gh', 'f', 'f', 'f', 'f', 'q', 'q', 'q', 'q', 'k', 'k', 'k', 'k', 'l', 'l', 'l',
0xE0 => 'l', 'm', 'm', 'm', 'm', 'n', 'n', 'n', 'n', 'h', 'h', 'h', 'h', 'w', 'w', 'y',
0xF0 => 'y', 'y', 'y', 'y', 'y', 'la', 'la', 'la', 'la', 'la', 'la', 'la', 'la', NULL, NULL, '',
-);
+];
diff --git a/core/lib/Drupal/Component/Transliteration/data/xff.php b/core/lib/Drupal/Component/Transliteration/data/xff.php
index 80852980601..3f669bd23e9 100644
--- a/core/lib/Drupal/Component/Transliteration/data/xff.php
+++ b/core/lib/Drupal/Component/Transliteration/data/xff.php
@@ -5,7 +5,7 @@
* Generic transliteration data for the PhpTransliteration class.
*/
-$base = array(
+$base = [
0x00 => NULL, '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
0x10 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
0x20 => '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
@@ -22,4 +22,4 @@ $base = array(
0xD0 => NULL, NULL, 'yo', 'u', 'wo', 'we', 'wi', 'yu', NULL, NULL, 'eu', 'ui', 'i', NULL, NULL, NULL,
0xE0 => '/C', 'PS', '!', '-', '|', 'Y=', 'W=', NULL, '|', '-', '|', '-', '|', '#', 'O', NULL,
0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{', '|', '}', '', '', '', '',
-);
+];
diff --git a/core/lib/Drupal/Component/Utility/ArgumentsResolver.php b/core/lib/Drupal/Component/Utility/ArgumentsResolver.php
index e04cc353af3..0bd53b214e6 100644
--- a/core/lib/Drupal/Component/Utility/ArgumentsResolver.php
+++ b/core/lib/Drupal/Component/Utility/ArgumentsResolver.php
@@ -49,7 +49,7 @@ class ArgumentsResolver implements ArgumentsResolverInterface {
* {@inheritdoc}
*/
public function getArguments(callable $callable) {
- $arguments = array();
+ $arguments = [];
foreach ($this->getReflector($callable)->getParameters() as $parameter) {
$arguments[] = $this->getArgument($parameter);
}
diff --git a/core/lib/Drupal/Component/Utility/Color.php b/core/lib/Drupal/Component/Utility/Color.php
index d53261ca6c1..aa296e94bec 100644
--- a/core/lib/Drupal/Component/Utility/Color.php
+++ b/core/lib/Drupal/Component/Utility/Color.php
@@ -56,11 +56,11 @@ class Color {
$c = hexdec($hex);
- return array(
+ return [
'red' => $c >> 16 & 0xFF,
'green' => $c >> 8 & 0xFF,
'blue' => $c & 0xFF,
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Component/Utility/DiffArray.php b/core/lib/Drupal/Component/Utility/DiffArray.php
index 719049e305d..825648eb7a3 100644
--- a/core/lib/Drupal/Component/Utility/DiffArray.php
+++ b/core/lib/Drupal/Component/Utility/DiffArray.php
@@ -25,7 +25,7 @@ class DiffArray {
* in array2.
*/
public static function diffAssocRecursive(array $array1, array $array2) {
- $difference = array();
+ $difference = [];
foreach ($array1 as $key => $value) {
if (is_array($value)) {
diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php
index 5456cfaaf32..75bb62f806c 100644
--- a/core/lib/Drupal/Component/Utility/Html.php
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -14,7 +14,7 @@ class Html {
*
* @var array
*/
- protected static $classes = array();
+ protected static $classes = [];
/**
* An array of the initial IDs used in one request.
@@ -89,13 +89,13 @@ class Html {
* @return string
* The cleaned identifier.
*/
- public static function cleanCssIdentifier($identifier, array $filter = array(
+ public static function cleanCssIdentifier($identifier, array $filter = [
' ' => '-',
'_' => '-',
'/' => '-',
'[' => '-',
']' => '',
- )) {
+ ]) {
// We could also use strtr() here but its much slower than str_replace(). In
// order to keep '__' to stay '__' we first replace it with a different
// placeholder after checking that it is not defined as a filter.
@@ -120,10 +120,10 @@ class Html {
// We strip out any character not in the above list.
$identifier = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier);
// Identifiers cannot start with a digit, two hyphens, or a hyphen followed by a digit.
- $identifier = preg_replace(array(
+ $identifier = preg_replace([
'/^[0-9]/',
'/^(-[0-9])|^(--)/'
- ), array('_', '__'), $identifier);
+ ], ['_', '__'], $identifier);
return $identifier;
}
@@ -176,7 +176,7 @@ class Html {
// @todo Remove all that code once we switch over to random IDs only,
// see https://www.drupal.org/node/1090592.
if (!isset(static::$seenIdsInit)) {
- static::$seenIdsInit = array();
+ static::$seenIdsInit = [];
}
if (!isset(static::$seenIds)) {
static::$seenIds = static::$seenIdsInit;
@@ -279,7 +279,7 @@ EOD;
// PHP's \DOMDocument serialization adds extra whitespace when the markup
// of the wrapping document contains newlines, so ensure we remove all
// newlines before injecting the actual HTML body to be processed.
- $document = strtr($document, array("\n" => '', '!html' => $html));
+ $document = strtr($document, ["\n" => '', '!html' => $html]);
$dom = new \DOMDocument();
// Ignore warnings during HTML soup loading.
diff --git a/core/lib/Drupal/Component/Utility/NestedArray.php b/core/lib/Drupal/Component/Utility/NestedArray.php
index 0b7cf4fa59e..c11d6a65821 100644
--- a/core/lib/Drupal/Component/Utility/NestedArray.php
+++ b/core/lib/Drupal/Component/Utility/NestedArray.php
@@ -150,7 +150,7 @@ class NestedArray {
// PHP auto-creates container arrays and NULL entries without error if $ref
// is NULL, but throws an error if $ref is set, but not an array.
if ($force && isset($ref) && !is_array($ref)) {
- $ref = array();
+ $ref = [];
}
$ref = &$ref[$parent];
}
@@ -322,7 +322,7 @@ class NestedArray {
* @see NestedArray::mergeDeep()
*/
public static function mergeDeepArray(array $arrays, $preserve_integer_keys = FALSE) {
- $result = array();
+ $result = [];
foreach ($arrays as $array) {
foreach ($array as $key => $value) {
// Renumber integer keys as array_merge_recursive() does unless
@@ -333,7 +333,7 @@ class NestedArray {
}
// Recurse when both values are arrays.
elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
- $result[$key] = self::mergeDeepArray(array($result[$key], $value), $preserve_integer_keys);
+ $result[$key] = self::mergeDeepArray([$result[$key], $value], $preserve_integer_keys);
}
// Otherwise, use the latter value, overriding any previous value.
else {
diff --git a/core/lib/Drupal/Component/Utility/Random.php b/core/lib/Drupal/Component/Utility/Random.php
index 1aeeb958da0..3c98b83b637 100644
--- a/core/lib/Drupal/Component/Utility/Random.php
+++ b/core/lib/Drupal/Component/Utility/Random.php
@@ -24,14 +24,14 @@ class Random {
*
* @var array
*/
- protected $strings = array();
+ protected $strings = [];
/**
* A list of unique names generated by name().
*
* @var array
*/
- protected $names = array();
+ protected $names = [];
/**
* Generates a random string of ASCII characters of codes 32 to 126.
@@ -141,9 +141,9 @@ class Random {
public function word($length) {
mt_srand((double) microtime() * 1000000);
- $vowels = array("a", "e", "i", "o", "u");
- $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
- "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl", "sh");
+ $vowels = ["a", "e", "i", "o", "u"];
+ $cons = ["b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
+ "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl", "sh"];
$num_vowels = count($vowels);
$num_cons = count($cons);
@@ -190,7 +190,7 @@ class Random {
* Nonsense latin words which form sentence(s).
*/
public function sentences($min_word_count, $capitalize = FALSE) {
- $dictionary = array("abbas", "abdo", "abico", "abigo", "abluo", "accumsan",
+ $dictionary = ["abbas", "abdo", "abico", "abigo", "abluo", "accumsan",
"acsi", "ad", "adipiscing", "aliquam", "aliquip", "amet", "antehabeo",
"appellatio", "aptent", "at", "augue", "autem", "bene", "blandit",
"brevitas", "caecus", "camur", "capto", "causa", "cogo", "comis",
@@ -219,7 +219,7 @@ class Random {
"utrum", "uxor", "valde", "valetudo", "validus", "vel", "velit",
"veniam", "venio", "vereor", "vero", "verto", "vicis", "vindico",
"virtus", "voco", "volutpat", "vulpes", "vulputate", "wisi", "ymo",
- "zelus");
+ "zelus"];
$dictionary_flipped = array_flip($dictionary);
$greeking = '';
diff --git a/core/lib/Drupal/Component/Utility/Tags.php b/core/lib/Drupal/Component/Utility/Tags.php
index 3f8ed13ebaa..ac0ce60817a 100644
--- a/core/lib/Drupal/Component/Utility/Tags.php
+++ b/core/lib/Drupal/Component/Utility/Tags.php
@@ -25,7 +25,7 @@ class Tags {
preg_match_all($regexp, $tags, $matches);
$typed_tags = array_unique($matches[1]);
- $tags = array();
+ $tags = [];
foreach ($typed_tags as $tag) {
// If a user has escaped a term (to demonstrate that it is a group,
// or includes a comma or quote character), we remove the escape
@@ -65,7 +65,7 @@ class Tags {
* The imploded string.
*/
public static function implode($tags) {
- $encoded_tags = array();
+ $encoded_tags = [];
foreach ($tags as $tag) {
$encoded_tags[] = self::encode($tag);
}
diff --git a/core/lib/Drupal/Component/Utility/Timer.php b/core/lib/Drupal/Component/Utility/Timer.php
index 959eeb339e3..b8dc0269764 100644
--- a/core/lib/Drupal/Component/Utility/Timer.php
+++ b/core/lib/Drupal/Component/Utility/Timer.php
@@ -9,7 +9,7 @@ namespace Drupal\Component\Utility;
*/
class Timer {
- static protected $timers = array();
+ static protected $timers = [];
/**
* Starts the timer with the specified name.
diff --git a/core/lib/Drupal/Component/Utility/Unicode.php b/core/lib/Drupal/Component/Utility/Unicode.php
index f6b46684828..98db80431c7 100644
--- a/core/lib/Drupal/Component/Utility/Unicode.php
+++ b/core/lib/Drupal/Component/Utility/Unicode.php
@@ -125,7 +125,7 @@ EOD;
* The new status of multibyte support.
*/
public static function setStatus($status) {
- if (!in_array($status, array(static::STATUS_SINGLEBYTE, static::STATUS_MULTIBYTE, static::STATUS_ERROR))) {
+ if (!in_array($status, [static::STATUS_SINGLEBYTE, static::STATUS_MULTIBYTE, static::STATUS_ERROR])) {
throw new \InvalidArgumentException('Invalid status value for unicode support.');
}
static::$status = $status;
@@ -189,7 +189,7 @@ EOD;
* The name of the encoding, or FALSE if no byte order mark was present.
*/
public static function encodingFromBOM($data) {
- static $bomMap = array(
+ static $bomMap = [
"\xEF\xBB\xBF" => 'UTF-8',
"\xFE\xFF" => 'UTF-16BE',
"\xFF\xFE" => 'UTF-16LE',
@@ -200,7 +200,7 @@ EOD;
"\x2B\x2F\x76\x2B" => 'UTF-7',
"\x2B\x2F\x76\x2F" => 'UTF-7',
"\x2B\x2F\x76\x38\x2D" => 'UTF-7',
- );
+ ];
foreach ($bomMap as $bom => $encoding) {
if (strpos($data, $bom) === 0) {
@@ -542,7 +542,7 @@ EOD;
}
if ($wordsafe) {
- $matches = array();
+ $matches = [];
// Find the last word boundary, if there is one within $min_wordsafe_length
// to $max_length characters. preg_match() is always greedy, so it will
// find the longest string possible.
diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php
index 1395d818f04..04c217b6afd 100644
--- a/core/lib/Drupal/Component/Utility/UrlHelper.php
+++ b/core/lib/Drupal/Component/Utility/UrlHelper.php
@@ -14,7 +14,7 @@ class UrlHelper {
*
* @var array
*/
- protected static $allowedProtocols = array('http', 'https');
+ protected static $allowedProtocols = ['http', 'https'];
/**
* Parses an array into a valid, rawurlencoded query string.
@@ -43,7 +43,7 @@ class UrlHelper {
* @ingroup php_wrappers
*/
public static function buildQuery(array $query, $parent = '') {
- $params = array();
+ $params = [];
foreach ($query as $key => $value) {
$key = ($parent ? $parent . '[' . rawurlencode($key) . ']' : rawurlencode($key));
@@ -79,7 +79,7 @@ class UrlHelper {
* @return
* An array containing query parameters.
*/
- public static function filterQueryParameters(array $query, array $exclude = array(), $parent = '') {
+ public static function filterQueryParameters(array $query, array $exclude = [], $parent = '') {
// If $exclude is empty, there is nothing to filter.
if (empty($exclude)) {
return $query;
@@ -88,7 +88,7 @@ class UrlHelper {
$exclude = array_flip($exclude);
}
- $params = array();
+ $params = [];
foreach ($query as $key => $value) {
$string_key = ($parent ? $parent . '[' . $key . ']' : $key);
if (isset($exclude[$string_key])) {
@@ -134,11 +134,11 @@ class UrlHelper {
* @ingroup php_wrappers
*/
public static function parse($url) {
- $options = array(
+ $options = [
'path' => NULL,
- 'query' => array(),
+ 'query' => [],
'fragment' => '',
- );
+ ];
// External URLs: not using parse_url() here, so we do not have to rebuild
// the scheme, host, and path without having any use for it.
@@ -294,7 +294,7 @@ class UrlHelper {
* @param array $protocols
* An array of protocols, for example http, https and irc.
*/
- public static function setAllowedProtocols(array $protocols = array()) {
+ public static function setAllowedProtocols(array $protocols = []) {
static::$allowedProtocols = $protocols;
}
diff --git a/core/lib/Drupal/Component/Utility/UserAgent.php b/core/lib/Drupal/Component/Utility/UserAgent.php
index 2fc67d67d56..c80c44e19de 100644
--- a/core/lib/Drupal/Component/Utility/UserAgent.php
+++ b/core/lib/Drupal/Component/Utility/UserAgent.php
@@ -36,7 +36,7 @@ class UserAgent {
* The selected language code or FALSE if no valid language can be
* identified.
*/
- public static function getBestMatchingLangcode($http_accept_language, $langcodes, $mappings = array()) {
+ public static function getBestMatchingLangcode($http_accept_language, $langcodes, $mappings = []) {
// The Accept-Language header contains information about the language
// preferences configured in the user's user agent / operating system.
// RFC 2616 (section 14.4) defines the Accept-Language header as follows:
@@ -44,7 +44,7 @@ class UserAgent {
// 1#( language-range [ ";" "q" "=" qvalue ] )
// language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
// Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
- $ua_langcodes = array();
+ $ua_langcodes = [];
if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($http_accept_language), $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if ($mappings) {
diff --git a/core/lib/Drupal/Component/Utility/Variable.php b/core/lib/Drupal/Component/Utility/Variable.php
index 5a830797116..c6c6935a9bd 100644
--- a/core/lib/Drupal/Component/Utility/Variable.php
+++ b/core/lib/Drupal/Component/Utility/Variable.php
@@ -43,7 +43,7 @@ class Variable {
// If the string contains a line break or a single quote, use the
// double quote export mode. Encode backslash, dollar symbols, and
// double quotes and transform some common control characters.
- $var = str_replace(array('\\', '$', '"', "\n", "\r", "\t"), array('\\\\', '\$', '\"', '\n', '\r', '\t'), $var);
+ $var = str_replace(['\\', '$', '"', "\n", "\r", "\t"], ['\\\\', '\$', '\"', '\n', '\r', '\t'], $var);
$output = '"' . $var . '"';
}
else {
diff --git a/core/lib/Drupal/Component/Utility/Xss.php b/core/lib/Drupal/Component/Utility/Xss.php
index d9f24b4e832..f5e99fe8860 100644
--- a/core/lib/Drupal/Component/Utility/Xss.php
+++ b/core/lib/Drupal/Component/Utility/Xss.php
@@ -16,7 +16,7 @@ class Xss {
*
* @see \Drupal\Component\Utility\Xss::filterAdmin()
*/
- protected static $adminTags = array('a', 'abbr', 'acronym', 'address', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'command', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'em', 'figcaption', 'figure', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'menu', 'meter', 'nav', 'ol', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr');
+ protected static $adminTags = ['a', 'abbr', 'acronym', 'address', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'command', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'em', 'figcaption', 'figure', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'menu', 'meter', 'nav', 'ol', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr'];
/**
* The default list of HTML tags allowed by filter().
@@ -25,7 +25,7 @@ class Xss {
*
* @see \Drupal\Component\Utility\Xss::filter()
*/
- protected static $htmlTags = array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd');
+ protected static $htmlTags = ['a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'];
/**
* Filters HTML to prevent cross-site-scripting (XSS) vulnerabilities.
@@ -196,7 +196,7 @@ class Xss {
* Cleaned up version of the HTML attributes.
*/
protected static function attributes($attributes) {
- $attributes_array = array();
+ $attributes_array = [];
$mode = 0;
$attribute_name = '';
$skip = FALSE;
@@ -221,12 +221,12 @@ class Xss {
// such attributes.
// @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
// @see http://www.w3.org/TR/html4/index/attributes.html
- $skip_protocol_filtering = substr($attribute_name, 0, 5) === 'data-' || in_array($attribute_name, array(
+ $skip_protocol_filtering = substr($attribute_name, 0, 5) === 'data-' || in_array($attribute_name, [
'title',
'alt',
'rel',
'property',
- ));
+ ]);
$working = $mode = 1;
$attributes = preg_replace('/^[-a-zA-Z][-a-zA-Z0-9]*/', '', $attributes);
diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php
index 95e7721df09..b7b7c0bfc13 100644
--- a/core/lib/Drupal/Core/Access/AccessManager.php
+++ b/core/lib/Drupal/Core/Access/AccessManager.php
@@ -78,7 +78,7 @@ class AccessManager implements AccessManagerInterface {
/**
* {@inheritdoc}
*/
- public function checkNamedRoute($route_name, array $parameters = array(), AccountInterface $account = NULL, $return_as_object = FALSE) {
+ public function checkNamedRoute($route_name, array $parameters = [], AccountInterface $account = NULL, $return_as_object = FALSE) {
try {
$route = $this->routeProvider->getRouteByName($route_name, $parameters);
@@ -120,7 +120,7 @@ class AccessManager implements AccessManagerInterface {
$account = $this->currentUser;
}
$route = $route_match->getRouteObject();
- $checks = $route->getOption('_access_checks') ?: array();
+ $checks = $route->getOption('_access_checks') ?: [];
// Filter out checks which require the incoming request.
if (!isset($request)) {
diff --git a/core/lib/Drupal/Core/Access/AccessManagerInterface.php b/core/lib/Drupal/Core/Access/AccessManagerInterface.php
index fc2a0e83cb3..bbb1ec95efb 100644
--- a/core/lib/Drupal/Core/Access/AccessManagerInterface.php
+++ b/core/lib/Drupal/Core/Access/AccessManagerInterface.php
@@ -33,7 +33,7 @@ interface AccessManagerInterface {
* returned, i.e. TRUE means access is explicitly allowed, FALSE means
* access is either explicitly forbidden or "no opinion".
*/
- public function checkNamedRoute($route_name, array $parameters = array(), AccountInterface $account = NULL, $return_as_object = FALSE);
+ public function checkNamedRoute($route_name, array $parameters = [], AccountInterface $account = NULL, $return_as_object = FALSE);
/**
* Execute access checks against the incoming request.
diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php
index d87872a0a34..1cd6b8bacdc 100644
--- a/core/lib/Drupal/Core/Access/AccessResult.php
+++ b/core/lib/Drupal/Core/Access/AccessResult.php
@@ -261,7 +261,7 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable
* @return $this
*/
public function cachePerPermissions() {
- $this->addCacheContexts(array('user.permissions'));
+ $this->addCacheContexts(['user.permissions']);
return $this;
}
@@ -271,7 +271,7 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable
* @return $this
*/
public function cachePerUser() {
- $this->addCacheContexts(array('user'));
+ $this->addCacheContexts(['user']);
return $this;
}
diff --git a/core/lib/Drupal/Core/Access/CheckProvider.php b/core/lib/Drupal/Core/Access/CheckProvider.php
index c68cf38a20f..d6ba1cf6dd3 100644
--- a/core/lib/Drupal/Core/Access/CheckProvider.php
+++ b/core/lib/Drupal/Core/Access/CheckProvider.php
@@ -20,7 +20,7 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface {
*
* @var array
*/
- protected $checkIds = array();
+ protected $checkIds = [];
/**
* Array of access check objects keyed by service id.
@@ -34,12 +34,12 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface {
*
* @var array
*/
- protected $checkMethods = array();
+ protected $checkMethods = [];
/**
* Array of access checks which only will be run on the incoming request.
*/
- protected $checksNeedsRequest = array();
+ protected $checksNeedsRequest = [];
/**
* An array to map static requirement keys to service IDs.
@@ -58,7 +58,7 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface {
/**
* {@inheritdoc}
*/
- public function addCheckService($service_id, $service_method, array $applies_checks = array(), $needs_incoming_request = FALSE) {
+ public function addCheckService($service_id, $service_method, array $applies_checks = [], $needs_incoming_request = FALSE) {
$this->checkIds[] = $service_id;
$this->checkMethods[$service_id] = $service_method;
if ($needs_incoming_request) {
@@ -102,7 +102,7 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface {
if (!($check instanceof AccessInterface)) {
throw new AccessException('All access checks must implement AccessInterface.');
}
- if (!is_callable(array($check, $this->checkMethods[$service_id]))) {
+ if (!is_callable([$check, $this->checkMethods[$service_id]])) {
throw new AccessException(sprintf('Access check method %s in service %s must be callable.', $this->checkMethods[$service_id], $service_id));
}
@@ -122,7 +122,7 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface {
* route.
*/
protected function applies(Route $route) {
- $checks = array();
+ $checks = [];
// Iterate through map requirements from appliesTo() on access checkers.
// Only iterate through all checkIds if this is not used.
@@ -151,7 +151,7 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface {
}
// Set them here, so we can use the isset() check above.
- $this->dynamicRequirementMap = array();
+ $this->dynamicRequirementMap = [];
foreach ($this->checkIds as $service_id) {
if (empty($this->checks[$service_id])) {
diff --git a/core/lib/Drupal/Core/Access/CheckProviderInterface.php b/core/lib/Drupal/Core/Access/CheckProviderInterface.php
index bb0dd4af97c..a94a92c9784 100644
--- a/core/lib/Drupal/Core/Access/CheckProviderInterface.php
+++ b/core/lib/Drupal/Core/Access/CheckProviderInterface.php
@@ -37,7 +37,7 @@ interface CheckProviderInterface {
* @param bool $needs_incoming_request
* (optional) True if access-check method only acts on an incoming request.
*/
- public function addCheckService($service_id, $service_method, array $applies_checks = array(), $needs_incoming_request = FALSE);
+ public function addCheckService($service_id, $service_method, array $applies_checks = [], $needs_incoming_request = FALSE);
/**
* Lazy-loads access check services.
diff --git a/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php b/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php
index 5548c7f90fb..563355a6b76 100644
--- a/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php
+++ b/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php
@@ -64,7 +64,7 @@ class CsrfRequestHeaderAccessCheck implements AccessCheckInterface {
$methods = explode('|', $requirements['_method']);
// CSRF protection only applies to write operations, so we can filter
// out any routes that require reading methods only.
- $write_methods = array_diff($methods, array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
+ $write_methods = array_diff($methods, ['GET', 'HEAD', 'OPTIONS', 'TRACE']);
if (empty($write_methods)) {
return FALSE;
}
@@ -93,7 +93,7 @@ class CsrfRequestHeaderAccessCheck implements AccessCheckInterface {
// 1. this is a write operation
// 2. the user was successfully authenticated and
// 3. the request comes with a session cookie.
- if (!in_array($method, array('GET', 'HEAD', 'OPTIONS', 'TRACE'))
+ if (!in_array($method, ['GET', 'HEAD', 'OPTIONS', 'TRACE'])
&& $account->isAuthenticated()
&& $this->sessionConfiguration->hasSession($request)
) {
diff --git a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php
index 2bbc9122c27..3d372fe6469 100644
--- a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php
+++ b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php
@@ -24,7 +24,7 @@ abstract class ConfigurableActionBase extends ActionBase implements Configurable
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array();
+ return [];
}
/**
@@ -51,7 +51,7 @@ abstract class ConfigurableActionBase extends ActionBase implements Configurable
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/AddCssCommand.php b/core/lib/Drupal/Core/Ajax/AddCssCommand.php
index fbb5ce4bb20..80ee17aa033 100644
--- a/core/lib/Drupal/Core/Ajax/AddCssCommand.php
+++ b/core/lib/Drupal/Core/Ajax/AddCssCommand.php
@@ -39,10 +39,10 @@ class AddCssCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'add_css',
'data' => $this->styles,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/AfterCommand.php b/core/lib/Drupal/Core/Ajax/AfterCommand.php
index 05060a6ce75..41e232d20eb 100644
--- a/core/lib/Drupal/Core/Ajax/AfterCommand.php
+++ b/core/lib/Drupal/Core/Ajax/AfterCommand.php
@@ -23,13 +23,13 @@ class AfterCommand extends InsertCommand {
*/
public function render() {
- return array(
+ return [
'command' => 'insert',
'method' => 'after',
'selector' => $this->selector,
'data' => $this->getRenderedContent(),
'settings' => $this->settings,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponse.php b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
index 4b12578d85e..4d1c123348e 100644
--- a/core/lib/Drupal/Core/Ajax/AjaxResponse.php
+++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
@@ -21,7 +21,7 @@ class AjaxResponse extends JsonResponse implements AttachmentsInterface {
*
* @var array
*/
- protected $commands = array();
+ protected $commands = [];
/**
* Add an AJAX command to the response.
diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
index 45aa45e4f8c..ee5208b0784 100644
--- a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
+++ b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
@@ -167,7 +167,7 @@ class AjaxResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn
}
// Prepend commands to add the assets, preserving their relative order.
- $resource_commands = array();
+ $resource_commands = [];
if ($css_assets) {
$css_render_array = $this->cssCollectionRenderer->render($css_assets);
$resource_commands[] = new AddCssCommand($this->renderer->renderPlain($css_render_array));
diff --git a/core/lib/Drupal/Core/Ajax/AlertCommand.php b/core/lib/Drupal/Core/Ajax/AlertCommand.php
index 46388d00571..360036f4538 100644
--- a/core/lib/Drupal/Core/Ajax/AlertCommand.php
+++ b/core/lib/Drupal/Core/Ajax/AlertCommand.php
@@ -31,10 +31,10 @@ class AlertCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'alert',
'text' => $this->text,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/AppendCommand.php b/core/lib/Drupal/Core/Ajax/AppendCommand.php
index e1830914cc5..34c751d7ee6 100644
--- a/core/lib/Drupal/Core/Ajax/AppendCommand.php
+++ b/core/lib/Drupal/Core/Ajax/AppendCommand.php
@@ -23,13 +23,13 @@ class AppendCommand extends InsertCommand {
*/
public function render() {
- return array(
+ return [
'command' => 'insert',
'method' => 'append',
'selector' => $this->selector,
'data' => $this->getRenderedContent(),
'settings' => $this->settings,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/BaseCommand.php b/core/lib/Drupal/Core/Ajax/BaseCommand.php
index f1506579626..eeb36cf2b65 100644
--- a/core/lib/Drupal/Core/Ajax/BaseCommand.php
+++ b/core/lib/Drupal/Core/Ajax/BaseCommand.php
@@ -38,10 +38,10 @@ class BaseCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => $this->command,
'data' => $this->data,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/BeforeCommand.php b/core/lib/Drupal/Core/Ajax/BeforeCommand.php
index 04290e02644..8de47c8e64e 100644
--- a/core/lib/Drupal/Core/Ajax/BeforeCommand.php
+++ b/core/lib/Drupal/Core/Ajax/BeforeCommand.php
@@ -23,13 +23,13 @@ class BeforeCommand extends InsertCommand {
*/
public function render() {
- return array(
+ return [
'command' => 'insert',
'method' => 'before',
'selector' => $this->selector,
'data' => $this->getRenderedContent(),
'settings' => $this->settings,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/ChangedCommand.php b/core/lib/Drupal/Core/Ajax/ChangedCommand.php
index b128cfc4f3f..0027d7c59e4 100644
--- a/core/lib/Drupal/Core/Ajax/ChangedCommand.php
+++ b/core/lib/Drupal/Core/Ajax/ChangedCommand.php
@@ -50,11 +50,11 @@ class ChangedCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'changed',
'selector' => $this->selector,
'asterisk' => $this->asterisk,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php b/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php
index fa58208b400..1feeb0c8c02 100644
--- a/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php
+++ b/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php
@@ -40,11 +40,11 @@ class CloseDialogCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'closeDialog',
'selector' => $this->selector,
'persist' => $this->persist,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/CssCommand.php b/core/lib/Drupal/Core/Ajax/CssCommand.php
index b12cc09fcd1..016c8134ff4 100644
--- a/core/lib/Drupal/Core/Ajax/CssCommand.php
+++ b/core/lib/Drupal/Core/Ajax/CssCommand.php
@@ -32,7 +32,7 @@ class CssCommand implements CommandInterface {
*
* @var array
*/
- protected $css = array();
+ protected $css = [];
/**
* Constructs a CssCommand object.
@@ -42,7 +42,7 @@ class CssCommand implements CommandInterface {
* @param array $css
* An array of CSS property/value pairs to set.
*/
- public function __construct($selector, array $css = array()) {
+ public function __construct($selector, array $css = []) {
$this->selector = $selector;
$this->css = $css;
}
@@ -67,11 +67,11 @@ class CssCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'css',
'selector' => $this->selector,
'argument' => $this->css,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/DataCommand.php b/core/lib/Drupal/Core/Ajax/DataCommand.php
index 92b87bde8d8..a1bee21469a 100644
--- a/core/lib/Drupal/Core/Ajax/DataCommand.php
+++ b/core/lib/Drupal/Core/Ajax/DataCommand.php
@@ -62,12 +62,12 @@ class DataCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'data',
'selector' => $this->selector,
'name' => $this->name,
'value' => $this->value,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/HtmlCommand.php b/core/lib/Drupal/Core/Ajax/HtmlCommand.php
index 39635c3ca24..e39f08f59f7 100644
--- a/core/lib/Drupal/Core/Ajax/HtmlCommand.php
+++ b/core/lib/Drupal/Core/Ajax/HtmlCommand.php
@@ -23,13 +23,13 @@ class HtmlCommand extends InsertCommand {
*/
public function render() {
- return array(
+ return [
'command' => 'insert',
'method' => 'html',
'selector' => $this->selector,
'data' => $this->getRenderedContent(),
'settings' => $this->settings,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/InsertCommand.php b/core/lib/Drupal/Core/Ajax/InsertCommand.php
index 00cb616ef3b..1813e500645 100644
--- a/core/lib/Drupal/Core/Ajax/InsertCommand.php
+++ b/core/lib/Drupal/Core/Ajax/InsertCommand.php
@@ -66,13 +66,13 @@ class InsertCommand implements CommandInterface, CommandWithAttachedAssetsInterf
*/
public function render() {
- return array(
+ return [
'command' => 'insert',
'method' => NULL,
'selector' => $this->selector,
'data' => $this->getRenderedContent(),
'settings' => $this->settings,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/InvokeCommand.php b/core/lib/Drupal/Core/Ajax/InvokeCommand.php
index 41958885b35..46e37ffea4e 100644
--- a/core/lib/Drupal/Core/Ajax/InvokeCommand.php
+++ b/core/lib/Drupal/Core/Ajax/InvokeCommand.php
@@ -51,7 +51,7 @@ class InvokeCommand implements CommandInterface {
* @param array $arguments
* An optional array of arguments to pass to the method.
*/
- public function __construct($selector, $method, array $arguments = array()) {
+ public function __construct($selector, $method, array $arguments = []) {
$this->selector = $selector;
$this->method = $method;
$this->arguments = $arguments;
@@ -62,12 +62,12 @@ class InvokeCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'invoke',
'selector' => $this->selector,
'method' => $this->method,
'args' => $this->arguments,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
index 30b65fac441..2b0fcdd2620 100644
--- a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
+++ b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
@@ -70,9 +70,9 @@ class OpenDialogCommand implements CommandInterface, CommandWithAttachedAssetsIn
* on the content of the dialog. If left empty, the settings will be
* populated automatically from the current request.
*/
- public function __construct($selector, $title, $content, array $dialog_options = array(), $settings = NULL) {
+ public function __construct($selector, $title, $content, array $dialog_options = [], $settings = NULL) {
$title = PlainTextOutput::renderFromHtml($title);
- $dialog_options += array('title' => $title);
+ $dialog_options += ['title' => $title];
$this->selector = $selector;
$this->content = $content;
$this->dialogOptions = $dialog_options;
@@ -128,13 +128,13 @@ class OpenDialogCommand implements CommandInterface, CommandWithAttachedAssetsIn
public function render() {
// For consistency ensure the modal option is set to TRUE or FALSE.
$this->dialogOptions['modal'] = isset($this->dialogOptions['modal']) && $this->dialogOptions['modal'];
- return array(
+ return [
'command' => 'openDialog',
'selector' => $this->selector,
'settings' => $this->settings,
'data' => $this->getRenderedContent(),
'dialogOptions' => $this->dialogOptions,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php
index edb4fe30867..53d6e823eab 100644
--- a/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php
+++ b/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php
@@ -29,7 +29,7 @@ class OpenModalDialogCommand extends OpenDialogCommand {
* on the content of the dialog. If left empty, the settings will be
* populated automatically from the current request.
*/
- public function __construct($title, $content, array $dialog_options = array(), $settings = NULL) {
+ public function __construct($title, $content, array $dialog_options = [], $settings = NULL) {
$dialog_options['modal'] = TRUE;
parent::__construct('#drupal-modal', $title, $content, $dialog_options, $settings);
}
diff --git a/core/lib/Drupal/Core/Ajax/PrependCommand.php b/core/lib/Drupal/Core/Ajax/PrependCommand.php
index 5e41baec4ef..e3902b8f44f 100644
--- a/core/lib/Drupal/Core/Ajax/PrependCommand.php
+++ b/core/lib/Drupal/Core/Ajax/PrependCommand.php
@@ -23,13 +23,13 @@ class PrependCommand extends InsertCommand {
*/
public function render() {
- return array(
+ return [
'command' => 'insert',
'method' => 'prepend',
'selector' => $this->selector,
'data' => $this->getRenderedContent(),
'settings' => $this->settings,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/RedirectCommand.php b/core/lib/Drupal/Core/Ajax/RedirectCommand.php
index 7dbf26eb9fa..572c62f46c5 100644
--- a/core/lib/Drupal/Core/Ajax/RedirectCommand.php
+++ b/core/lib/Drupal/Core/Ajax/RedirectCommand.php
@@ -31,10 +31,10 @@ class RedirectCommand implements CommandInterface {
* Implements \Drupal\Core\Ajax\CommandInterface:render().
*/
public function render() {
- return array(
+ return [
'command' => 'redirect',
'url' => $this->url,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/RemoveCommand.php b/core/lib/Drupal/Core/Ajax/RemoveCommand.php
index c52211d80a4..d7f86ddd257 100644
--- a/core/lib/Drupal/Core/Ajax/RemoveCommand.php
+++ b/core/lib/Drupal/Core/Ajax/RemoveCommand.php
@@ -38,10 +38,10 @@ class RemoveCommand implements CommandInterface {
* Implements Drupal\Core\Ajax\CommandInterface:render().
*/
public function render() {
- return array(
+ return [
'command' => 'remove',
'selector' => $this->selector,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/ReplaceCommand.php b/core/lib/Drupal/Core/Ajax/ReplaceCommand.php
index 8ccb7c125b0..25927b7993b 100644
--- a/core/lib/Drupal/Core/Ajax/ReplaceCommand.php
+++ b/core/lib/Drupal/Core/Ajax/ReplaceCommand.php
@@ -24,13 +24,13 @@ class ReplaceCommand extends InsertCommand {
*/
public function render() {
- return array(
+ return [
'command' => 'insert',
'method' => 'replaceWith',
'selector' => $this->selector,
'data' => $this->getRenderedContent(),
'settings' => $this->settings,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/RestripeCommand.php b/core/lib/Drupal/Core/Ajax/RestripeCommand.php
index 331e1bff021..33b7e25269f 100644
--- a/core/lib/Drupal/Core/Ajax/RestripeCommand.php
+++ b/core/lib/Drupal/Core/Ajax/RestripeCommand.php
@@ -40,10 +40,10 @@ class RestripeCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'restripe',
'selector' => $this->selector,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php b/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php
index 9e7836b29c9..f24f97caf38 100644
--- a/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php
+++ b/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php
@@ -52,12 +52,12 @@ class SetDialogOptionCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'setDialogOption',
'selector' => $this->selector,
'optionName' => $this->optionName,
'optionValue' => $this->optionValue,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Ajax/SettingsCommand.php b/core/lib/Drupal/Core/Ajax/SettingsCommand.php
index 154ab9c813a..ca41720dcb2 100644
--- a/core/lib/Drupal/Core/Ajax/SettingsCommand.php
+++ b/core/lib/Drupal/Core/Ajax/SettingsCommand.php
@@ -54,11 +54,11 @@ class SettingsCommand implements CommandInterface {
*/
public function render() {
- return array(
+ return [
'command' => 'settings',
'settings' => $this->settings,
'merge' => $this->merge,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Annotation/ContextDefinition.php b/core/lib/Drupal/Core/Annotation/ContextDefinition.php
index abe14e5c901..0ff61e6f131 100644
--- a/core/lib/Drupal/Core/Annotation/ContextDefinition.php
+++ b/core/lib/Drupal/Core/Annotation/ContextDefinition.php
@@ -99,11 +99,11 @@ class ContextDefinition extends Plugin {
* ContextDefinitionInterface implementing class.
*/
public function __construct(array $values) {
- $values += array(
+ $values += [
'required' => TRUE,
'multiple' => FALSE,
'default_value' => NULL,
- );
+ ];
// Annotation classes extract data from passed annotation classes directly
// used in the classes they pass to.
foreach (['label', 'description'] as $key) {
diff --git a/core/lib/Drupal/Core/Annotation/Translation.php b/core/lib/Drupal/Core/Annotation/Translation.php
index 4fcfb9e459b..90fe5e02d59 100644
--- a/core/lib/Drupal/Core/Annotation/Translation.php
+++ b/core/lib/Drupal/Core/Annotation/Translation.php
@@ -74,12 +74,12 @@ class Translation extends AnnotationBase {
*/
public function __construct(array $values) {
$string = $values['value'];
- $arguments = isset($values['arguments']) ? $values['arguments'] : array();
- $options = array();
+ $arguments = isset($values['arguments']) ? $values['arguments'] : [];
+ $options = [];
if (!empty($values['context'])) {
- $options = array(
+ $options = [
'context' => $values['context'],
- );
+ ];
}
$this->translation = new TranslatableMarkup($string, $arguments, $options);
}
diff --git a/core/lib/Drupal/Core/Archiver/ArchiverInterface.php b/core/lib/Drupal/Core/Archiver/ArchiverInterface.php
index 38c62cb92c8..2e635364bc8 100644
--- a/core/lib/Drupal/Core/Archiver/ArchiverInterface.php
+++ b/core/lib/Drupal/Core/Archiver/ArchiverInterface.php
@@ -47,7 +47,7 @@ interface ArchiverInterface {
* @return \Drupal\Core\Archiver\ArchiverInterface
* The called object.
*/
- public function extract($path, array $files = array());
+ public function extract($path, array $files = []);
/**
* Lists all files in the archive.
diff --git a/core/lib/Drupal/Core/Archiver/ArchiverManager.php b/core/lib/Drupal/Core/Archiver/ArchiverManager.php
index ee2dad5d1df..7cd11f90a46 100644
--- a/core/lib/Drupal/Core/Archiver/ArchiverManager.php
+++ b/core/lib/Drupal/Core/Archiver/ArchiverManager.php
@@ -36,7 +36,7 @@ class ArchiverManager extends DefaultPluginManager {
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition, 'Drupal\Core\Archiver\ArchiverInterface');
return new $plugin_class($configuration['filepath']);
diff --git a/core/lib/Drupal/Core/Archiver/Tar.php b/core/lib/Drupal/Core/Archiver/Tar.php
index 33f4de63c61..3b33dddfe4d 100644
--- a/core/lib/Drupal/Core/Archiver/Tar.php
+++ b/core/lib/Drupal/Core/Archiver/Tar.php
@@ -52,7 +52,7 @@ class Tar implements ArchiverInterface {
/**
* {@inheritdoc}
*/
- public function extract($path, array $files = array()) {
+ public function extract($path, array $files = []) {
if ($files) {
$this->tar->extractList($files, $path);
}
@@ -67,7 +67,7 @@ class Tar implements ArchiverInterface {
* {@inheritdoc}
*/
public function listContents() {
- $files = array();
+ $files = [];
foreach ($this->tar->listContent() as $file_data) {
$files[] = $file_data['filename'];
}
diff --git a/core/lib/Drupal/Core/Archiver/Zip.php b/core/lib/Drupal/Core/Archiver/Zip.php
index 640bcde808c..fd769c13cff 100644
--- a/core/lib/Drupal/Core/Archiver/Zip.php
+++ b/core/lib/Drupal/Core/Archiver/Zip.php
@@ -29,7 +29,7 @@ class Zip implements ArchiverInterface {
public function __construct($file_path) {
$this->zip = new \ZipArchive();
if ($this->zip->open($file_path) !== TRUE) {
- throw new ArchiverException(t('Cannot open %file_path', array('%file_path' => $file_path)));
+ throw new ArchiverException(t('Cannot open %file_path', ['%file_path' => $file_path]));
}
}
@@ -54,7 +54,7 @@ class Zip implements ArchiverInterface {
/**
* {@inheritdoc}
*/
- public function extract($path, array $files = array()) {
+ public function extract($path, array $files = []) {
if ($files) {
$this->zip->extractTo($path, $files);
}
@@ -69,7 +69,7 @@ class Zip implements ArchiverInterface {
* {@inheritdoc}
*/
public function listContents() {
- $files = array();
+ $files = [];
for ($i = 0; $i < $this->zip->numFiles; $i++) {
$files[] = $this->zip->getNameIndex($i);
}
diff --git a/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php b/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php
index 2c4122d58f7..4dedfa6b3b2 100644
--- a/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php
+++ b/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php
@@ -20,7 +20,7 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface {
* type, media, and browsers, if needed to accommodate other items in between.
*/
public function group(array $css_assets) {
- $groups = array();
+ $groups = [];
// If a group can contain multiple items, we track the information that must
// be the same for each item in the group, so that when we iterate the next
// item, we can determine if it can be put into the current group, or if a
@@ -52,7 +52,7 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface {
// Group file items if their 'preprocess' flag is TRUE.
// Help ensure maximum reuse of aggregate files by only grouping
// together items that share the same 'group' value.
- $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['media'], $item['browsers']) : FALSE;
+ $group_keys = $item['preprocess'] ? [$item['type'], $item['group'], $item['media'], $item['browsers']] : FALSE;
break;
case 'external':
@@ -71,7 +71,7 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface {
// the group.
$groups[$i] = $item;
unset($groups[$i]['data'], $groups[$i]['weight'], $groups[$i]['basename']);
- $groups[$i]['items'] = array();
+ $groups[$i]['items'] = [];
$current_group_keys = $group_keys ? $group_keys : NULL;
}
diff --git a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php
index eb47cb2c593..5f23af49793 100644
--- a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php
+++ b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php
@@ -80,8 +80,8 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface {
// Drupal contrib can override this default CSS aggregator to keep the same
// grouping, optimizing and dumping, but change the strategy that is used to
// determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …).
- $map = $this->state->get('drupal_css_cache_files') ?: array();
- $css_assets = array();
+ $map = $this->state->get('drupal_css_cache_files') ?: [];
+ $css_assets = [];
foreach ($css_groups as $order => $css_group) {
// We have to return a single asset, not a group of assets. It is now up
// to one of the pieces of code in the switch statement below to set the
@@ -155,7 +155,7 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface {
* A hash to uniquely identify the given group of CSS assets.
*/
protected function generateHash(array $css_group) {
- $css_data = array();
+ $css_data = [];
foreach ($css_group['items'] as $css_file) {
$css_data[] = $css_file['data'];
}
@@ -181,7 +181,7 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface {
file_unmanaged_delete($uri);
}
};
- file_scan_directory('public://css', '/.*/', array('callback' => $delete_stale));
+ file_scan_directory('public://css', '/.*/', ['callback' => $delete_stale]);
}
}
diff --git a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
index 63721e65ffe..c3c83e11923 100644
--- a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php
@@ -74,7 +74,7 @@ class CssCollectionRenderer implements AssetCollectionRendererInterface {
* {@inheritdoc}
*/
public function render(array $css_assets) {
- $elements = array();
+ $elements = [];
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
@@ -83,22 +83,22 @@ class CssCollectionRenderer implements AssetCollectionRendererInterface {
$query_string = $this->state->get('system.css_js_query_string') ?: '0';
// Defaults for LINK and STYLE elements.
- $link_element_defaults = array(
+ $link_element_defaults = [
'#type' => 'html_tag',
'#tag' => 'link',
- '#attributes' => array(
+ '#attributes' => [
'rel' => 'stylesheet',
- ),
- );
- $style_element_defaults = array(
+ ],
+ ];
+ $style_element_defaults = [
'#type' => 'html_tag',
'#tag' => 'style',
- );
+ ];
// For filthy IE hack.
$current_ie_group_keys = NULL;
$get_ie_group_key = function ($css_asset) {
- return array($css_asset['type'], $css_asset['preprocess'], $css_asset['group'], $css_asset['media'], $css_asset['browsers']);
+ return [$css_asset['type'], $css_asset['preprocess'], $css_asset['group'], $css_asset['media'], $css_asset['browsers']];
};
// Loop through all CSS assets, by key, to allow for the special IE
@@ -151,7 +151,7 @@ class CssCollectionRenderer implements AssetCollectionRendererInterface {
// The file CSS asset can be aggregated, but hasn't been: combine
// multiple items into as few STYLE tags as possible.
else {
- $import = array();
+ $import = [];
// Start with the current CSS asset, iterate over subsequent CSS
// assets and find which ones have the same 'type', 'group',
// 'preprocess', 'media' and 'browsers' properties.
diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php
index d25fb8345a9..4ad7ba134cc 100644
--- a/core/lib/Drupal/Core/Asset/CssOptimizer.php
+++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php
@@ -61,7 +61,7 @@ class CssOptimizer implements AssetOptimizerInterface {
$this->rewriteFileURIBasePath = $css_base_path . '/';
// Anchor all paths in the CSS with its base URL, ignoring external and absolute paths.
- return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', array($this, 'rewriteFileURI'), $contents);
+ return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', [$this, 'rewriteFileURI'], $contents);
}
/**
@@ -230,7 +230,7 @@ class CssOptimizer implements AssetOptimizerInterface {
// Replaces @import commands with the actual stylesheet content.
// This happens recursively but omits external files.
- $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*;/', array($this, 'loadNestedFile'), $contents);
+ $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*;/', [$this, 'loadNestedFile'], $contents);
return $contents;
}
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php b/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php
index 710e3c0b986..9d29c40f268 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php
@@ -19,7 +19,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface {
* type and browsers, if needed to accommodate other items in between.
*/
public function group(array $js_assets) {
- $groups = array();
+ $groups = [];
// If a group can contain multiple items, we track the information that must
// be the same for each item in the group, so that when we iterate the next
// item, we can determine if it can be put into the current group, or if a
@@ -38,7 +38,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface {
// Group file items if their 'preprocess' flag is TRUE.
// Help ensure maximum reuse of aggregate files by only grouping
// together items that share the same 'group' value.
- $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['browsers']) : FALSE;
+ $group_keys = $item['preprocess'] ? [$item['type'], $item['group'], $item['browsers']] : FALSE;
break;
case 'external':
@@ -56,7 +56,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface {
// unique to the item and should not be carried over to the group.
$groups[$index] = $item;
unset($groups[$index]['data'], $groups[$index]['weight']);
- $groups[$index]['items'] = array();
+ $groups[$index]['items'] = [];
$current_group_keys = $group_keys ? $group_keys : NULL;
}
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php
index 566722dfb6c..4d49d87b4d8 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php
@@ -81,8 +81,8 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface {
// Drupal contrib can override this default JS aggregator to keep the same
// grouping, optimizing and dumping, but change the strategy that is used to
// determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …).
- $map = $this->state->get('system.js_cache_files') ?: array();
- $js_assets = array();
+ $map = $this->state->get('system.js_cache_files') ?: [];
+ $js_assets = [];
foreach ($js_groups as $order => $js_group) {
// We have to return a single asset, not a group of assets. It is now up
// to one of the pieces of code in the switch statement below to set the
@@ -159,7 +159,7 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface {
* A hash to uniquely identify the given group of JavaScript assets.
*/
protected function generateHash(array $js_group) {
- $js_data = array();
+ $js_data = [];
foreach ($js_group['items'] as $js_file) {
$js_data[] = $js_file['data'];
}
@@ -184,7 +184,7 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface {
file_unmanaged_delete($uri);
}
};
- file_scan_directory('public://js', '/.*/', array('callback' => $delete_stale));
+ file_scan_directory('public://js', '/.*/', ['callback' => $delete_stale]);
}
}
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
index 2e47d0f3d50..d3a062c9427 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
@@ -37,7 +37,7 @@ class JsCollectionRenderer implements AssetCollectionRendererInterface {
* logic for grouping and aggregating files.
*/
public function render(array $js_assets) {
- $elements = array();
+ $elements = [];
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
@@ -47,11 +47,11 @@ class JsCollectionRenderer implements AssetCollectionRendererInterface {
$default_query_string = $this->state->get('system.css_js_query_string') ?: '0';
// Defaults for each SCRIPT element.
- $element_defaults = array(
+ $element_defaults = [
'#type' => 'html_tag',
'#tag' => 'script',
'#value' => '',
- );
+ ];
// Loop through all JS assets.
foreach ($js_assets as $js_asset) {
@@ -62,12 +62,12 @@ class JsCollectionRenderer implements AssetCollectionRendererInterface {
// Element properties that depend on item type.
switch ($js_asset['type']) {
case 'setting':
- $element['#attributes'] = array(
+ $element['#attributes'] = [
// This type attribute prevents this from being parsed as an
// inline script.
'type' => 'application/json',
'data-drupal-selector' => 'drupal-settings-json',
- );
+ ];
$element['#value'] = Json::encode($js_asset['data']);
break;
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 799ee07f91f..b4c716d508a 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -69,7 +69,7 @@ class LibraryDiscoveryParser {
* Thrown when a js file defines a positive weight.
*/
public function buildByExtension($extension) {
- $libraries = array();
+ $libraries = [];
if ($extension === 'core') {
$path = 'core';
@@ -92,7 +92,7 @@ class LibraryDiscoveryParser {
if (!isset($library['js']) && !isset($library['css']) && !isset($library['drupalSettings'])) {
throw new IncompleteLibraryDefinitionException(sprintf("Incomplete library definition for definition '%s' in extension '%s'", $id, $extension));
}
- $library += array('dependencies' => array(), 'js' => array(), 'css' => array());
+ $library += ['dependencies' => [], 'js' => [], 'css' => []];
if (isset($library['header']) && !is_bool($library['header'])) {
throw new \LogicException(sprintf("The 'header' key in the library definition '%s' in extension '%s' is invalid: it must be a boolean.", $id, $extension));
@@ -116,14 +116,14 @@ class LibraryDiscoveryParser {
// Assign Drupal's license to libraries that don't have license info.
if (!isset($library['license'])) {
- $library['license'] = array(
+ $library['license'] = [
'name' => 'GNU-GPL-2.0-or-later',
'url' => 'https://www.drupal.org/licensing/faq',
'gpl-compatible' => TRUE,
- );
+ ];
}
- foreach (array('js', 'css') as $type) {
+ foreach (['js', 'css'] as $type) {
// Prepare (flatten) the SMACSS-categorized definitions.
// @todo After Asset(ic) changes, retain the definitions as-is and
// properly resolve dependencies for all (css) libraries per category,
@@ -145,7 +145,7 @@ class LibraryDiscoveryParser {
unset($library[$type][$source]);
// Allow to omit the options hashmap in YAML declarations.
if (!is_array($options)) {
- $options = array();
+ $options = [];
}
if ($type == 'js' && isset($options['weight']) && $options['weight'] > 0) {
throw new \UnexpectedValueException("The $extension/$id library defines a positive weight for '$source'. Only negative weights are allowed (but should be avoided). Instead of a positive weight, specify accurate dependencies for this library.");
diff --git a/core/lib/Drupal/Core/Batch/BatchStorage.php b/core/lib/Drupal/Core/Batch/BatchStorage.php
index 789703c3253..82f5b657675 100644
--- a/core/lib/Drupal/Core/Batch/BatchStorage.php
+++ b/core/lib/Drupal/Core/Batch/BatchStorage.php
@@ -58,10 +58,10 @@ class BatchStorage implements BatchStorageInterface {
// Ensure that a session is started before using the CSRF token generator.
$this->session->start();
try {
- $batch = $this->connection->query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
+ $batch = $this->connection->query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", [
':bid' => $id,
':token' => $this->csrfToken->get($id),
- ))->fetchField();
+ ])->fetchField();
}
catch (\Exception $e) {
$this->catchException($e);
@@ -93,7 +93,7 @@ class BatchStorage implements BatchStorageInterface {
public function update(array $batch) {
try {
$this->connection->update('batch')
- ->fields(array('batch' => serialize($batch)))
+ ->fields(['batch' => serialize($batch)])
->condition('bid', $batch['id'])
->execute();
}
@@ -150,12 +150,12 @@ class BatchStorage implements BatchStorageInterface {
*/
protected function doCreate(array $batch) {
$this->connection->insert('batch')
- ->fields(array(
+ ->fields([
'bid' => $batch['id'],
'timestamp' => REQUEST_TIME,
'token' => $this->csrfToken->get($batch['id']),
'batch' => serialize($batch),
- ))
+ ])
->execute();
}
diff --git a/core/lib/Drupal/Core/Block/BlockBase.php b/core/lib/Drupal/Core/Block/BlockBase.php
index 4d47afaeef8..ee9078335b8 100644
--- a/core/lib/Drupal/Core/Block/BlockBase.php
+++ b/core/lib/Drupal/Core/Block/BlockBase.php
@@ -82,19 +82,19 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
* An associative array with the default configuration.
*/
protected function baseConfigurationDefaults() {
- return array(
+ return [
'id' => $this->getPluginId(),
'label' => '',
'provider' => $this->pluginDefinition['provider'],
'label_display' => static::BLOCK_LABEL_VISIBLE,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array();
+ return [];
}
/**
@@ -108,7 +108,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
/**
@@ -151,29 +151,29 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$definition = $this->getPluginDefinition();
- $form['provider'] = array(
+ $form['provider'] = [
'#type' => 'value',
'#value' => $definition['provider'],
- );
+ ];
- $form['admin_label'] = array(
+ $form['admin_label'] = [
'#type' => 'item',
'#title' => $this->t('Block description'),
'#plain_text' => $definition['admin_label'],
- );
- $form['label'] = array(
+ ];
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Title'),
'#maxlength' => 255,
'#default_value' => $this->label(),
'#required' => TRUE,
- );
- $form['label_display'] = array(
+ ];
+ $form['label_display'] = [
'#type' => 'checkbox',
'#title' => $this->t('Display title'),
'#default_value' => ($this->configuration['label_display'] === static::BLOCK_LABEL_VISIBLE),
'#return_value' => static::BLOCK_LABEL_VISIBLE,
- );
+ ];
// Add context mapping UI form elements.
$contexts = $form_state->getTemporaryValue('gathered_contexts') ?: [];
@@ -187,7 +187,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state) {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Block/BlockManager.php b/core/lib/Drupal/Core/Block/BlockManager.php
index 3c88bdcc082..a837340a3c2 100644
--- a/core/lib/Drupal/Core/Block/BlockManager.php
+++ b/core/lib/Drupal/Core/Block/BlockManager.php
@@ -74,7 +74,7 @@ class BlockManager extends DefaultPluginManager implements BlockManagerInterface
/**
* {@inheritdoc}
*/
- public function getFallbackPluginId($plugin_id, array $configuration = array()) {
+ public function getFallbackPluginId($plugin_id, array $configuration = []) {
return 'broken';
}
diff --git a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php
index bb651ccf1e9..f418a5ee225 100644
--- a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php
+++ b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php
@@ -29,7 +29,7 @@ class BreadcrumbManager implements ChainBreadcrumbBuilderInterface {
*
* @var array
*/
- protected $builders = array();
+ protected $builders = [];
/**
* Holds the array of breadcrumb builders sorted by priority.
@@ -71,7 +71,7 @@ class BreadcrumbManager implements ChainBreadcrumbBuilderInterface {
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
- $context = array('builder' => NULL);
+ $context = ['builder' => NULL];
// Call the build method of registered breadcrumb builders,
// until one of them returns an array.
foreach ($this->getSortedBuilders() as $builder) {
@@ -107,7 +107,7 @@ class BreadcrumbManager implements ChainBreadcrumbBuilderInterface {
// Sort the builders according to priority.
krsort($this->builders);
// Merge nested builders from $this->builders into $this->sortedBuilders.
- $this->sortedBuilders = array();
+ $this->sortedBuilders = [];
foreach ($this->builders as $builders) {
$this->sortedBuilders = array_merge($this->sortedBuilders, $builders);
}
diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php
index 5338a747af9..d7847ffb8d4 100644
--- a/core/lib/Drupal/Core/Cache/ApcuBackend.php
+++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php
@@ -80,13 +80,13 @@ class ApcuBackend implements CacheBackendInterface {
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
// Translate the requested cache item IDs to APCu keys.
- $map = array();
+ $map = [];
foreach ($cids as $cid) {
$map[$this->getApcuKey($cid)] = $cid;
}
$result = apcu_fetch(array_keys($map));
- $cache = array();
+ $cache = [];
if ($result) {
foreach ($result as $key => $item) {
$item = $this->prepareItem($item, $allow_invalid);
@@ -140,7 +140,7 @@ class ApcuBackend implements CacheBackendInterface {
return FALSE;
}
- $cache->tags = $cache->tags ? explode(' ', $cache->tags) : array();
+ $cache->tags = $cache->tags ? explode(' ', $cache->tags) : [];
// Check expire time.
$cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME;
@@ -160,7 +160,7 @@ class ApcuBackend implements CacheBackendInterface {
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
+ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = []) {
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
$tags = array_unique($tags);
$cache = new \stdClass();
@@ -180,9 +180,9 @@ class ApcuBackend implements CacheBackendInterface {
/**
* {@inheritdoc}
*/
- public function setMultiple(array $items = array()) {
+ public function setMultiple(array $items = []) {
foreach ($items as $cid => $item) {
- $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : array());
+ $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []);
}
}
@@ -197,7 +197,7 @@ class ApcuBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function deleteMultiple(array $cids) {
- apcu_delete(array_map(array($this, 'getApcuKey'), $cids));
+ apcu_delete(array_map([$this, 'getApcuKey'], $cids));
}
/**
@@ -225,7 +225,7 @@ class ApcuBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function invalidate($cid) {
- $this->invalidateMultiple(array($cid));
+ $this->invalidateMultiple([$cid]);
}
/**
diff --git a/core/lib/Drupal/Core/Cache/BackendChain.php b/core/lib/Drupal/Core/Cache/BackendChain.php
index 851978b2930..a8cef19fd54 100644
--- a/core/lib/Drupal/Core/Cache/BackendChain.php
+++ b/core/lib/Drupal/Core/Cache/BackendChain.php
@@ -26,7 +26,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
*
* @var array
*/
- protected $backends = array();
+ protected $backends = [];
/**
* Constructs a DatabaseBackend object.
@@ -91,7 +91,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
- $return = array();
+ $return = [];
foreach ($this->backends as $index => $backend) {
$items = $backend->getMultiple($cids, $allow_invalid);
@@ -121,7 +121,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
foreach ($this->backends as $backend) {
$backend->set($cid, $data, $expire, $tags);
}
diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php
index d905132894e..f02a4e7cd71 100644
--- a/core/lib/Drupal/Core/Cache/Cache.php
+++ b/core/lib/Drupal/Core/Cache/Cache.php
@@ -152,7 +152,7 @@ class Cache {
* An array of cache backend objects keyed by cache bins.
*/
public static function getBins() {
- $bins = array();
+ $bins = [];
$container = \Drupal::getContainer();
foreach ($container->getParameter('cache_bins') as $service_id => $bin) {
$bins[$bin] = $container->get($service_id);
@@ -178,7 +178,7 @@ class Cache {
*/
public static function keyFromQuery(SelectInterface $query) {
$query->preExecute();
- $keys = array((string) $query, $query->getArguments());
+ $keys = [(string) $query, $query->getArguments()];
return hash('sha256', serialize($keys));
}
diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
index 68c5b5ab1fb..a8ce88890a9 100644
--- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
+++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
@@ -96,7 +96,7 @@ interface CacheBackendInterface {
* @see \Drupal\Core\Cache\CacheBackendInterface::get()
* @see \Drupal\Core\Cache\CacheBackendInterface::getMultiple()
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array());
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []);
/**
* Store multiple items in the persistent cache.
diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php
index 2db46084b52..acbbf006a05 100644
--- a/core/lib/Drupal/Core/Cache/CacheCollector.php
+++ b/core/lib/Drupal/Core/Cache/CacheCollector.php
@@ -56,21 +56,21 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn
*
* @var array
*/
- protected $keysToPersist = array();
+ protected $keysToPersist = [];
/**
* An array of keys to remove from the cache on service termination.
*
* @var array
*/
- protected $keysToRemove = array();
+ protected $keysToRemove = [];
/**
* Storage for the data itself.
*
* @var array
*/
- protected $storage = array();
+ protected $storage = [];
/**
* Stores the cache creation time.
@@ -110,7 +110,7 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn
* @param array $tags
* (optional) The tags to specify for the cache item.
*/
- public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = array()) {
+ public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = []) {
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.');
$this->cid = $cid;
$this->cache = $cache;
@@ -216,7 +216,7 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn
* TRUE.
*/
protected function updateCache($lock = TRUE) {
- $data = array();
+ $data = [];
foreach ($this->keysToPersist as $offset => $persist) {
if ($persist) {
$data[$offset] = $this->storage[$offset];
@@ -256,8 +256,8 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn
}
}
- $this->keysToPersist = array();
- $this->keysToRemove = array();
+ $this->keysToPersist = [];
+ $this->keysToRemove = [];
}
/**
@@ -288,9 +288,9 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn
* {@inheritdoc}
*/
public function reset() {
- $this->storage = array();
- $this->keysToPersist = array();
- $this->keysToRemove = array();
+ $this->storage = [];
+ $this->keysToPersist = [];
+ $this->keysToRemove = [];
$this->cacheLoaded = FALSE;
}
diff --git a/core/lib/Drupal/Core/Cache/CacheFactory.php b/core/lib/Drupal/Core/Cache/CacheFactory.php
index d9b39e4f486..d029cc1fe62 100644
--- a/core/lib/Drupal/Core/Cache/CacheFactory.php
+++ b/core/lib/Drupal/Core/Cache/CacheFactory.php
@@ -42,7 +42,7 @@ class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface {
* (optional) A mapping of bin to backend service name. Mappings in
* $settings take precedence over this.
*/
- public function __construct(Settings $settings, array $default_bin_backends = array()) {
+ public function __construct(Settings $settings, array $default_bin_backends = []) {
$this->settings = $settings;
$this->defaultBinBackends = $default_bin_backends;
}
diff --git a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
index cfc64f2a9ee..ceb8f49e88f 100644
--- a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
+++ b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php
@@ -16,7 +16,7 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface {
*
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface[]
*/
- protected $invalidators = array();
+ protected $invalidators = [];
/**
* {@inheritdoc}
@@ -66,7 +66,7 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface {
* interface, keyed by their cache bin.
*/
protected function getInvalidatorCacheBins() {
- $bins = array();
+ $bins = [];
foreach ($this->container->getParameter('cache_bins') as $service_id => $bin) {
$service = $this->container->get($service_id);
if ($service instanceof CacheTagsInvalidatorInterface) {
diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php
index 62839c2b0e1..9f6be9d8ab8 100644
--- a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php
+++ b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php
@@ -99,7 +99,7 @@ class ChainedFastBackend implements CacheBackendInterface, CacheTagsInvalidatorI
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
- $cids = array($cid);
+ $cids = [$cid];
$cache = $this->getMultiple($cids, $allow_invalid);
return reset($cache);
}
@@ -109,7 +109,7 @@ class ChainedFastBackend implements CacheBackendInterface, CacheTagsInvalidatorI
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
$cids_copy = $cids;
- $cache = array();
+ $cache = [];
// If we can determine the time at which the last write to the consistent
// backend occurred (we might not be able to if it has been recently
@@ -142,7 +142,7 @@ class ChainedFastBackend implements CacheBackendInterface, CacheTagsInvalidatorI
}
catch (\Exception $e) {
$cids = $cids_copy;
- $items = array();
+ $items = [];
}
// Even if items were successfully fetched from the fast backend, they
@@ -176,7 +176,7 @@ class ChainedFastBackend implements CacheBackendInterface, CacheTagsInvalidatorI
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
$this->consistentBackend->set($cid, $data, $expire, $tags);
$this->markAsOutdated();
// Don't write the cache tags to the fast backend as any cache tag
@@ -202,7 +202,7 @@ class ChainedFastBackend implements CacheBackendInterface, CacheTagsInvalidatorI
* {@inheritdoc}
*/
public function delete($cid) {
- $this->consistentBackend->deleteMultiple(array($cid));
+ $this->consistentBackend->deleteMultiple([$cid]);
$this->markAsOutdated();
}
@@ -226,7 +226,7 @@ class ChainedFastBackend implements CacheBackendInterface, CacheTagsInvalidatorI
* {@inheritdoc}
*/
public function invalidate($cid) {
- $this->invalidateMultiple(array($cid));
+ $this->invalidateMultiple([$cid]);
}
/**
diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php
index 00dc9b513e3..e4da328a9f0 100644
--- a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php
+++ b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php
@@ -43,7 +43,7 @@ class ChainedFastBackendFactory implements CacheFactoryInterface {
public function __construct(Settings $settings = NULL, $consistent_service_name = NULL, $fast_service_name = NULL) {
// Default the consistent backend to the site's default backend.
if (!isset($consistent_service_name)) {
- $cache_settings = isset($settings) ? $settings->get('cache') : array();
+ $cache_settings = isset($settings) ? $settings->get('cache') : [];
$consistent_service_name = isset($cache_settings['default']) ? $cache_settings['default'] : 'cache.backend.database';
}
diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
index 0e89fb9d43b..9a555f8bf1a 100644
--- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
+++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
@@ -71,7 +71,7 @@ class CacheContextsManager {
* An array of available cache contexts and corresponding labels.
*/
public function getLabels($include_calculated_cache_contexts = FALSE) {
- $with_labels = array();
+ $with_labels = [];
foreach ($this->contexts as $context) {
$service = $this->getService($context);
if (!$include_calculated_cache_contexts && $service instanceof CalculatedCacheContextInterface) {
diff --git a/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php b/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php
index a13b763fa06..952dc14adbf 100644
--- a/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php
+++ b/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php
@@ -50,7 +50,7 @@ class LanguagesCacheContext implements CalculatedCacheContextInterface {
*/
public function getContext($type = NULL) {
if ($type === NULL) {
- $context_parts = array();
+ $context_parts = [];
if ($this->languageManager->isMultilingual()) {
foreach ($this->languageManager->getLanguageTypes() as $type) {
$context_parts[] = $this->languageManager->getCurrentLanguage($type)->getId();
diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
index a96d1834723..d53c51c2fc8 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
@@ -59,7 +59,7 @@ class DatabaseBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
- $cids = array($cid);
+ $cids = [$cid];
$cache = $this->getMultiple($cids, $allow_invalid);
return reset($cache);
}
@@ -68,7 +68,7 @@ class DatabaseBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
- $cid_mapping = array();
+ $cid_mapping = [];
foreach ($cids as $cid) {
$cid_mapping[$this->normalizeCid($cid)] = $cid;
}
@@ -79,14 +79,14 @@ class DatabaseBackend implements CacheBackendInterface {
// is used here only due to the performance overhead we would incur
// otherwise. When serving an uncached page, the overhead of using
// ::select() is a much smaller proportion of the request.
- $result = array();
+ $result = [];
try {
- $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN ( :cids[] ) ORDER BY cid', array(':cids[]' => array_keys($cid_mapping)));
+ $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN ( :cids[] ) ORDER BY cid', [':cids[]' => array_keys($cid_mapping)]);
}
catch (\Exception $e) {
// Nothing to do.
}
- $cache = array();
+ $cache = [];
foreach ($result as $item) {
// Map the cache ID back to the original.
$item->cid = $cid_mapping[$item->cid];
@@ -119,7 +119,7 @@ class DatabaseBackend implements CacheBackendInterface {
return FALSE;
}
- $cache->tags = $cache->tags ? explode(' ', $cache->tags) : array();
+ $cache->tags = $cache->tags ? explode(' ', $cache->tags) : [];
// Check expire time.
$cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME;
@@ -144,7 +144,7 @@ class DatabaseBackend implements CacheBackendInterface {
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
$this->setMultiple([
$cid => [
'data' => $data,
@@ -186,26 +186,26 @@ class DatabaseBackend implements CacheBackendInterface {
* @see \Drupal\Core\Cache\CacheBackendInterface::setMultiple()
*/
protected function doSetMultiple(array $items) {
- $values = array();
+ $values = [];
foreach ($items as $cid => $item) {
- $item += array(
+ $item += [
'expire' => CacheBackendInterface::CACHE_PERMANENT,
- 'tags' => array(),
- );
+ 'tags' => [],
+ ];
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($item[\'tags\'])', 'Cache Tags must be strings.');
$item['tags'] = array_unique($item['tags']);
// Sort the cache tags so that they are stored consistently in the DB.
sort($item['tags']);
- $fields = array(
+ $fields = [
'cid' => $this->normalizeCid($cid),
'expire' => $item['expire'],
'created' => round(microtime(TRUE), 3),
'tags' => implode(' ', $item['tags']),
'checksum' => $this->checksumProvider->getCurrentChecksum($item['tags']),
- );
+ ];
if (!is_string($item['data'])) {
$fields['data'] = serialize($item['data']);
@@ -223,7 +223,7 @@ class DatabaseBackend implements CacheBackendInterface {
$query = $this->connection
->upsert($this->bin)
->key('cid')
- ->fields(array('cid', 'expire', 'created', 'tags', 'checksum', 'data', 'serialized'));
+ ->fields(['cid', 'expire', 'created', 'tags', 'checksum', 'data', 'serialized']);
foreach ($values as $fields) {
// Only pass the values since the order of $fields matches the order of
// the insert fields. This is a performance optimization to avoid
@@ -238,14 +238,14 @@ class DatabaseBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function delete($cid) {
- $this->deleteMultiple(array($cid));
+ $this->deleteMultiple([$cid]);
}
/**
* {@inheritdoc}
*/
public function deleteMultiple(array $cids) {
- $cids = array_values(array_map(array($this, 'normalizeCid'), $cids));
+ $cids = array_values(array_map([$this, 'normalizeCid'], $cids));
try {
// Delete in chunks when a large array is passed.
foreach (array_chunk($cids, 1000) as $cids_chunk) {
@@ -285,19 +285,19 @@ class DatabaseBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function invalidate($cid) {
- $this->invalidateMultiple(array($cid));
+ $this->invalidateMultiple([$cid]);
}
/**
* {@inheritdoc}
*/
public function invalidateMultiple(array $cids) {
- $cids = array_values(array_map(array($this, 'normalizeCid'), $cids));
+ $cids = array_values(array_map([$this, 'normalizeCid'], $cids));
try {
// Update in chunks when a large array is passed.
foreach (array_chunk($cids, 1000) as $cids_chunk) {
$this->connection->update($this->bin)
- ->fields(array('expire' => REQUEST_TIME - 1))
+ ->fields(['expire' => REQUEST_TIME - 1])
->condition('cid', $cids_chunk, 'IN')
->execute();
}
@@ -313,7 +313,7 @@ class DatabaseBackend implements CacheBackendInterface {
public function invalidateAll() {
try {
$this->connection->update($this->bin)
- ->fields(array('expire' => REQUEST_TIME - 1))
+ ->fields(['expire' => REQUEST_TIME - 1])
->execute();
}
catch (\Exception $e) {
@@ -419,62 +419,62 @@ class DatabaseBackend implements CacheBackendInterface {
* Defines the schema for the {cache_*} bin tables.
*/
public function schemaDefinition() {
- $schema = array(
+ $schema = [
'description' => 'Storage for the cache API.',
- 'fields' => array(
- 'cid' => array(
+ 'fields' => [
+ 'cid' => [
'description' => 'Primary Key: Unique cache ID.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'binary' => TRUE,
- ),
- 'data' => array(
+ ],
+ 'data' => [
'description' => 'A collection of data to cache.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
- ),
- 'expire' => array(
+ ],
+ 'expire' => [
'description' => 'A Unix timestamp indicating when the cache entry should expire, or ' . Cache::PERMANENT . ' for never.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'created' => array(
+ ],
+ 'created' => [
'description' => 'A timestamp with millisecond precision indicating when the cache entry was created.',
'type' => 'numeric',
'precision' => 14,
'scale' => 3,
'not null' => TRUE,
'default' => 0,
- ),
- 'serialized' => array(
+ ],
+ 'serialized' => [
'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
- ),
- 'tags' => array(
+ ],
+ 'tags' => [
'description' => 'Space-separated list of cache tags for this entry.',
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
- ),
- 'checksum' => array(
+ ],
+ 'checksum' => [
'description' => 'The tag invalidation checksum when this entry was saved.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
- ),
- ),
- 'indexes' => array(
- 'expire' => array('expire'),
- ),
- 'primary key' => array('cid'),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'expire' => ['expire'],
+ ],
+ 'primary key' => ['cid'],
+ ];
return $schema;
}
diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
index a133d88f6ab..450b4411a17 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php
@@ -22,7 +22,7 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags
*
* @var array
*/
- protected $tagCache = array();
+ protected $tagCache = [];
/**
* A list of tags that have already been invalidated in this request.
@@ -31,7 +31,7 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags
*
* @var array
*/
- protected $invalidatedTags = array();
+ protected $invalidatedTags = [];
/**
* Constructs a DatabaseCacheTagsChecksum object.
@@ -56,7 +56,7 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags
$this->invalidatedTags[$tag] = TRUE;
unset($this->tagCache[$tag]);
$this->connection->merge('cachetags')
- ->insertFields(array('invalidations' => 1))
+ ->insertFields(['invalidations' => 1])
->expression('invalidations', 'invalidations + 1')
->key('tag', $tag)
->execute();
@@ -107,9 +107,9 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags
$query_tags = array_diff($tags, array_keys($this->tagCache));
if ($query_tags) {
- $db_tags = array();
+ $db_tags = [];
try {
- $db_tags = $this->connection->query('SELECT tag, invalidations FROM {cachetags} WHERE tag IN ( :tags[] )', array(':tags[]' => $query_tags))
+ $db_tags = $this->connection->query('SELECT tag, invalidations FROM {cachetags} WHERE tag IN ( :tags[] )', [':tags[]' => $query_tags])
->fetchAllKeyed();
$this->tagCache += $db_tags;
}
@@ -134,8 +134,8 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags
* {@inheritdoc}
*/
public function reset() {
- $this->tagCache = array();
- $this->invalidatedTags = array();
+ $this->tagCache = [];
+ $this->invalidatedTags = [];
}
/**
@@ -165,25 +165,25 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags
* Defines the schema for the {cachetags} table.
*/
public function schemaDefinition() {
- $schema = array(
+ $schema = [
'description' => 'Cache table for tracking cache tag invalidations.',
- 'fields' => array(
- 'tag' => array(
+ 'fields' => [
+ 'tag' => [
'description' => 'Namespace-prefixed tag string.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'invalidations' => array(
+ ],
+ 'invalidations' => [
'description' => 'Number incremented when the tag is invalidated.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('tag'),
- );
+ ],
+ ],
+ 'primary key' => ['tag'],
+ ];
return $schema;
}
diff --git a/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php b/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php
index 27886ace08c..32bac09c086 100644
--- a/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php
+++ b/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php
@@ -16,8 +16,8 @@ class ListCacheBinsPass implements CompilerPassInterface {
* Collects the cache bins into the cache_bins parameter.
*/
public function process(ContainerBuilder $container) {
- $cache_bins = array();
- $cache_default_bin_backends = array();
+ $cache_bins = [];
+ $cache_default_bin_backends = [];
foreach ($container->findTaggedServiceIds('cache.bin') as $id => $attributes) {
$bin = substr($id, strpos($id, '.') + 1);
$cache_bins[$id] = $bin;
diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php
index aa2409c7e9c..76bff41eb54 100644
--- a/core/lib/Drupal/Core/Cache/MemoryBackend.php
+++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php
@@ -17,7 +17,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
/**
* Array to store cache objects.
*/
- protected $cache = array();
+ protected $cache = [];
/**
* {@inheritdoc}
@@ -35,7 +35,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
- $ret = array();
+ $ret = [];
$items = array_intersect_key($this->cache, array_flip($cids));
@@ -92,26 +92,26 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.');
$tags = array_unique($tags);
// Sort the cache tags so that they are stored consistently in the database.
sort($tags);
- $this->cache[$cid] = (object) array(
+ $this->cache[$cid] = (object) [
'cid' => $cid,
'data' => serialize($data),
'created' => $this->getRequestTime(),
'expire' => $expire,
'tags' => $tags,
- );
+ ];
}
/**
* {@inheritdoc}
*/
- public function setMultiple(array $items = array()) {
+ public function setMultiple(array $items = []) {
foreach ($items as $cid => $item) {
- $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : array());
+ $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []);
}
}
@@ -133,7 +133,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
* {@inheritdoc}
*/
public function deleteAll() {
- $this->cache = array();
+ $this->cache = [];
}
/**
diff --git a/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php b/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php
index 4457e5950d9..680f850af05 100644
--- a/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php
+++ b/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php
@@ -9,7 +9,7 @@ class MemoryBackendFactory implements CacheFactoryInterface {
*
* @var \Drupal\Core\Cache\MemoryBackend[]
*/
- protected $bins = array();
+ protected $bins = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php
index 5ec490c5969..63d20076c6f 100644
--- a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php
+++ b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php
@@ -17,7 +17,7 @@ class MemoryCounterBackend extends MemoryBackend {
*
* @var array
*/
- protected $counter = array();
+ protected $counter = [];
/**
* {@inheritdoc}
@@ -30,7 +30,7 @@ class MemoryCounterBackend extends MemoryBackend {
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
$this->increaseCounter(__FUNCTION__, $cid);
parent::set($cid, $data, $expire, $tags);
}
@@ -76,7 +76,7 @@ class MemoryCounterBackend extends MemoryBackend {
return isset($this->counter[$method][$cid]) ? $this->counter[$method][$cid] : 0;
}
elseif ($method) {
- return isset($this->counter[$method]) ? $this->counter[$method] : array();
+ return isset($this->counter[$method]) ? $this->counter[$method] : [];
}
else {
return $this->counter;
@@ -87,7 +87,7 @@ class MemoryCounterBackend extends MemoryBackend {
* Resets the call counter.
*/
public function resetCounter() {
- $this->counter = array();
+ $this->counter = [];
}
}
diff --git a/core/lib/Drupal/Core/Cache/NullBackend.php b/core/lib/Drupal/Core/Cache/NullBackend.php
index fec549f127d..b0077a50e36 100644
--- a/core/lib/Drupal/Core/Cache/NullBackend.php
+++ b/core/lib/Drupal/Core/Cache/NullBackend.php
@@ -36,18 +36,18 @@ class NullBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {}
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {}
/**
* {@inheritdoc}
*/
- public function setMultiple(array $items = array()) {}
+ public function setMultiple(array $items = []) {}
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php
index 38f9b9b4b42..2404493404f 100644
--- a/core/lib/Drupal/Core/Cache/PhpBackend.php
+++ b/core/lib/Drupal/Core/Cache/PhpBackend.php
@@ -28,7 +28,7 @@ class PhpBackend implements CacheBackendInterface {
/**
* Array to store cache objects.
*/
- protected $cache = array();
+ protected $cache = [];
/**
* The cache tags checksum provider.
@@ -83,7 +83,7 @@ class PhpBackend implements CacheBackendInterface {
*/
public function setMultiple(array $items) {
foreach ($items as $cid => $item) {
- $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : array());
+ $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []);
}
}
@@ -91,7 +91,7 @@ class PhpBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
- $ret = array();
+ $ret = [];
foreach ($cids as $cid) {
if ($item = $this->get($cid, $allow_invalid)) {
@@ -142,16 +142,16 @@ class PhpBackend implements CacheBackendInterface {
/**
* {@inheritdoc}
*/
- public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
+ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.');
- $item = (object) array(
+ $item = (object) [
'cid' => $cid,
'data' => $data,
'created' => round(microtime(TRUE), 3),
'expire' => $expire,
'tags' => array_unique($tags),
'checksum' => $this->checksumProvider->getCurrentChecksum($tags),
- );
+ ];
$this->writeItem($this->normalizeCid($cid), $item);
}
@@ -226,7 +226,7 @@ class PhpBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function removeBin() {
- $this->cache = array();
+ $this->cache = [];
$this->storage()->deleteAll();
}
diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php
index b2dc781dbbd..1ca6262c9b2 100644
--- a/core/lib/Drupal/Core/Composer/Composer.php
+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -84,22 +84,22 @@ class Composer {
// Check for our packages, and then optimize them if they're present.
if ($repository->findPackage('symfony/http-foundation', $constraint)) {
$autoload = $package->getAutoload();
- $autoload['classmap'] = array_merge($autoload['classmap'], array(
+ $autoload['classmap'] = array_merge($autoload['classmap'], [
'vendor/symfony/http-foundation/Request.php',
'vendor/symfony/http-foundation/ParameterBag.php',
'vendor/symfony/http-foundation/FileBag.php',
'vendor/symfony/http-foundation/ServerBag.php',
'vendor/symfony/http-foundation/HeaderBag.php',
- ));
+ ]);
$package->setAutoload($autoload);
}
if ($repository->findPackage('symfony/http-kernel', $constraint)) {
$autoload = $package->getAutoload();
- $autoload['classmap'] = array_merge($autoload['classmap'], array(
+ $autoload['classmap'] = array_merge($autoload['classmap'], [
'vendor/symfony/http-kernel/HttpKernel.php',
'vendor/symfony/http-kernel/HttpKernelInterface.php',
'vendor/symfony/http-kernel/TerminableInterface.php',
- ));
+ ]);
$package->setAutoload($autoload);
}
}
diff --git a/core/lib/Drupal/Core/Condition/Annotation/Condition.php b/core/lib/Drupal/Core/Condition/Annotation/Condition.php
index 0959ef7c73c..b6686cf6b0b 100644
--- a/core/lib/Drupal/Core/Condition/Annotation/Condition.php
+++ b/core/lib/Drupal/Core/Condition/Annotation/Condition.php
@@ -55,7 +55,7 @@ class Condition extends Plugin {
*
* @var \Drupal\Core\Annotation\ContextDefinition[]
*/
- public $context = array();
+ public $context = [];
/**
* The category under which the condition should listed in the UI.
diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php
index bbe6fe76c80..2c6b61b6ae8 100644
--- a/core/lib/Drupal/Core/Condition/ConditionManager.php
+++ b/core/lib/Drupal/Core/Condition/ConditionManager.php
@@ -46,7 +46,7 @@ class ConditionManager extends DefaultPluginManager implements ExecutableManager
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$plugin = $this->getFactory()->createInstance($plugin_id, $configuration);
// If we receive any context values via config set it into the plugin.
diff --git a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php
index aaa7ee817c8..b5134fb51da 100644
--- a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php
+++ b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php
@@ -53,11 +53,11 @@ abstract class ConditionPluginBase extends ExecutablePluginBase implements Condi
}
$contexts = $form_state->getTemporaryValue('gathered_contexts') ?: [];
$form['context_mapping'] = $this->addContextAssignmentElement($this, $contexts);
- $form['negate'] = array(
+ $form['negate'] = [
'#type' => 'checkbox',
'#title' => $this->t('Negate the condition'),
'#default_value' => $this->configuration['negate'],
- );
+ ];
return $form;
}
@@ -88,9 +88,9 @@ abstract class ConditionPluginBase extends ExecutablePluginBase implements Condi
* {@inheritdoc}
*/
public function getConfiguration() {
- return array(
+ return [
'id' => $this->getPluginId(),
- ) + $this->configuration;
+ ] + $this->configuration;
}
/**
@@ -105,16 +105,16 @@ abstract class ConditionPluginBase extends ExecutablePluginBase implements Condi
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'negate' => FALSE,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php b/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php
index 5801ac14e80..4d6dd704334 100644
--- a/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php
+++ b/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php
@@ -15,7 +15,7 @@ class ConditionPluginCollection extends DefaultLazyPluginCollection {
*
* @var \Drupal\Component\Plugin\Context\ContextInterface[]
*/
- protected $conditionContexts = array();
+ protected $conditionContexts = [];
/**
* {@inheritdoc}
@@ -33,7 +33,7 @@ class ConditionPluginCollection extends DefaultLazyPluginCollection {
$configuration = parent::getConfiguration();
// Remove configuration if it matches the defaults.
foreach ($configuration as $instance_id => $instance_config) {
- $default_config = array();
+ $default_config = [];
$default_config['id'] = $instance_id;
$default_config += $this->get($instance_id)->defaultConfiguration();
// In order to determine if a plugin is configured, we must compare it to
diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php
index 363fcd08ed3..7286fbcb321 100644
--- a/core/lib/Drupal/Core/Config/CachedStorage.php
+++ b/core/lib/Drupal/Core/Config/CachedStorage.php
@@ -34,7 +34,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
*
* @var array
*/
- protected $findByPrefixCache = array();
+ protected $findByPrefixCache = [];
/**
* Constructs a new CachedStorage.
@@ -80,7 +80,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
* {@inheritdoc}
*/
public function readMultiple(array $names) {
- $data_to_return = array();
+ $data_to_return = [];
$cache_keys_map = $this->getCacheKeys($names);
$cache_keys = array_values($cache_keys_map);
@@ -95,11 +95,11 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
$list = $this->storage->readMultiple($names_to_get);
// Cache configuration objects that were loaded from the storage, cache
// missing configuration objects as an explicit FALSE.
- $items = array();
+ $items = [];
foreach ($names_to_get as $name) {
$data = isset($list[$name]) ? $list[$name] : FALSE;
$data_to_return[$name] = $data;
- $items[$cache_keys_map[$name]] = array('data' => $data);
+ $items[$cache_keys_map[$name]] = ['data' => $data];
}
$this->cache->setMultiple($items);
@@ -125,7 +125,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
// While not all written data is read back, setting the cache instead of
// just deleting it avoids cache rebuild stampedes.
$this->cache->set($this->getCacheKey($name), $data);
- $this->findByPrefixCache = array();
+ $this->findByPrefixCache = [];
return TRUE;
}
return FALSE;
@@ -139,7 +139,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
// rebuilding the cache before the storage is gone.
if ($this->storage->delete($name)) {
$this->cache->delete($this->getCacheKey($name));
- $this->findByPrefixCache = array();
+ $this->findByPrefixCache = [];
return TRUE;
}
return FALSE;
@@ -154,7 +154,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
if ($this->storage->rename($name, $new_name)) {
$this->cache->delete($this->getCacheKey($name));
$this->cache->delete($this->getCacheKey($new_name));
- $this->findByPrefixCache = array();
+ $this->findByPrefixCache = [];
return TRUE;
}
return FALSE;
@@ -227,7 +227,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
* Clears the static list cache.
*/
public function resetListCache() {
- $this->findByPrefixCache = array();
+ $this->findByPrefixCache = [];
}
/**
diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php
index 0128c66fd59..584feb7c537 100644
--- a/core/lib/Drupal/Core/Config/Config.php
+++ b/core/lib/Drupal/Core/Config/Config.php
@@ -155,10 +155,10 @@ class Config extends StorableConfigBase {
protected function setOverriddenData() {
$this->overriddenData = $this->data;
if (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) {
- $this->overriddenData = NestedArray::mergeDeepArray(array($this->overriddenData, $this->moduleOverrides), TRUE);
+ $this->overriddenData = NestedArray::mergeDeepArray([$this->overriddenData, $this->moduleOverrides], TRUE);
}
if (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) {
- $this->overriddenData = NestedArray::mergeDeepArray(array($this->overriddenData, $this->settingsOverrides), TRUE);
+ $this->overriddenData = NestedArray::mergeDeepArray([$this->overriddenData, $this->settingsOverrides], TRUE);
}
return $this;
}
@@ -239,7 +239,7 @@ class Config extends StorableConfigBase {
* The configuration object.
*/
public function delete() {
- $this->data = array();
+ $this->data = [];
$this->storage->delete($this->name);
Cache::invalidateTags($this->getCacheTags());
$this->isNew = TRUE;
@@ -281,10 +281,10 @@ class Config extends StorableConfigBase {
if ($apply_overrides) {
// Apply overrides.
if (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) {
- $original_data = NestedArray::mergeDeepArray(array($original_data, $this->moduleOverrides), TRUE);
+ $original_data = NestedArray::mergeDeepArray([$original_data, $this->moduleOverrides], TRUE);
}
if (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) {
- $original_data = NestedArray::mergeDeepArray(array($original_data, $this->settingsOverrides), TRUE);
+ $original_data = NestedArray::mergeDeepArray([$original_data, $this->settingsOverrides], TRUE);
}
}
diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php
index 6dfa962d1b0..596ed921565 100644
--- a/core/lib/Drupal/Core/Config/ConfigBase.php
+++ b/core/lib/Drupal/Core/Config/ConfigBase.php
@@ -40,7 +40,7 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface {
*
* @var array
*/
- protected $data = array();
+ protected $data = [];
/**
* The maximum length of a configuration object name.
@@ -247,7 +247,7 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface {
*/
public function merge(array $data_to_merge) {
// Preserve integer keys so that configuration keys are not changed.
- $this->setData(NestedArray::mergeDeepArray(array($this->data, $data_to_merge), TRUE));
+ $this->setData(NestedArray::mergeDeepArray([$this->data, $data_to_merge], TRUE));
return $this;
}
diff --git a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php
index 483c96d2064..dfdd0b8daff 100644
--- a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php
+++ b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php
@@ -17,7 +17,7 @@ class ConfigCollectionInfo extends Event {
*
* @var array
*/
- protected $collections = array();
+ protected $collections = [];
/**
* Adds a collection to the list of possible collections.
diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php
index 1189a4a1536..d91bec92e40 100644
--- a/core/lib/Drupal/Core/Config/ConfigFactory.php
+++ b/core/lib/Drupal/Core/Config/ConfigFactory.php
@@ -43,7 +43,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
*
* @var \Drupal\Core\Config\Config[]
*/
- protected $cache = array();
+ protected $cache = [];
/**
* The typed config manager.
@@ -57,7 +57,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
*
* @var \Drupal\Core\Config\ConfigFactoryOverrideInterface[]
*/
- protected $configFactoryOverrides = array();
+ protected $configFactoryOverrides = [];
/**
* Constructs the Config factory.
@@ -101,7 +101,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
* A configuration object.
*/
protected function doGet($name, $immutable = TRUE) {
- if ($config = $this->doLoadMultiple(array($name), $immutable)) {
+ if ($config = $this->doLoadMultiple([$name], $immutable)) {
return $config[$name];
}
else {
@@ -111,7 +111,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
if ($immutable) {
// Get and apply any overrides.
- $overrides = $this->loadOverrides(array($name));
+ $overrides = $this->loadOverrides([$name]);
if (isset($overrides[$name])) {
$config->setModuleOverride($overrides[$name]);
}
@@ -148,7 +148,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
* List of successfully loaded configuration objects, keyed by name.
*/
protected function doLoadMultiple(array $names, $immutable = TRUE) {
- $list = array();
+ $list = [];
foreach ($names as $key => $name) {
$cache_key = $this->getConfigCacheKey($name, $immutable);
@@ -161,7 +161,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
// Pre-load remaining configuration files.
if (!empty($names)) {
// Initialise override information.
- $module_overrides = array();
+ $module_overrides = [];
$storage_data = $this->storage->readMultiple($names);
if ($immutable && !empty($storage_data)) {
@@ -202,11 +202,11 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
* An array of overrides keyed by the configuration object name.
*/
protected function loadOverrides(array $names) {
- $overrides = array();
+ $overrides = [];
foreach ($this->configFactoryOverrides as $override) {
// Existing overrides take precedence since these will have been added
// by events with a higher priority.
- $overrides = NestedArray::mergeDeepArray(array($override->loadOverrides($names), $overrides), TRUE);
+ $overrides = NestedArray::mergeDeepArray([$override->loadOverrides($names), $overrides], TRUE);
}
return $overrides;
}
@@ -236,7 +236,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
}
}
else {
- $this->cache = array();
+ $this->cache = [];
}
// Clear the static list cache if supported by the storage.
@@ -317,7 +317,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
* {@inheritdoc}
*/
public function clearStaticCache() {
- $this->cache = array();
+ $this->cache = [];
return $this;
}
@@ -366,8 +366,8 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::SAVE][] = array('onConfigSave', 255);
- $events[ConfigEvents::DELETE][] = array('onConfigDelete', 255);
+ $events[ConfigEvents::SAVE][] = ['onConfigSave', 255];
+ $events[ConfigEvents::DELETE][] = ['onConfigDelete', 255];
return $events;
}
diff --git a/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php b/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php
index 79eb29403b4..3ca16021fca 100644
--- a/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php
+++ b/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php
@@ -45,10 +45,10 @@ abstract class ConfigFactoryOverrideBase implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::COLLECTION_INFO][] = array('addCollections');
- $events[ConfigEvents::SAVE][] = array('onConfigSave', 20);
- $events[ConfigEvents::DELETE][] = array('onConfigDelete', 20);
- $events[ConfigEvents::RENAME][] = array('onConfigRename', 20);
+ $events[ConfigEvents::COLLECTION_INFO][] = ['addCollections'];
+ $events[ConfigEvents::SAVE][] = ['onConfigSave', 20];
+ $events[ConfigEvents::DELETE][] = ['onConfigDelete', 20];
+ $events[ConfigEvents::RENAME][] = ['onConfigRename', 20];
return $events;
}
diff --git a/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php b/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php
index 4f172a36550..ca4964552d2 100644
--- a/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php
+++ b/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php
@@ -23,7 +23,7 @@ abstract class ConfigImportValidateEventSubscriberBase implements EventSubscribe
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 20);
+ $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20];
return $events;
}
diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php
index 25071b006fa..7d48a4af3be 100644
--- a/core/lib/Drupal/Core/Config/ConfigImporter.php
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -135,7 +135,7 @@ class ConfigImporter {
*
* @var array
*/
- protected $errors = array();
+ protected $errors = [];
/**
* The total number of extensions to process.
@@ -253,16 +253,16 @@ class ConfigImporter {
* An empty list of extensions to process.
*/
protected function getEmptyExtensionsProcessedList() {
- return array(
- 'module' => array(
- 'install' => array(),
- 'uninstall' => array(),
- ),
- 'theme' => array(
- 'install' => array(),
- 'uninstall' => array(),
- ),
- );
+ return [
+ 'module' => [
+ 'install' => [],
+ 'uninstall' => [],
+ ],
+ 'theme' => [
+ 'install' => [],
+ 'uninstall' => [],
+ ],
+ ];
}
/**
@@ -273,7 +273,7 @@ class ConfigImporter {
*/
public function hasUnprocessedConfigurationChanges() {
foreach ($this->storageComparer->getAllCollectionNames() as $collection) {
- foreach (array('delete', 'create', 'rename', 'update') as $op) {
+ foreach (['delete', 'create', 'rename', 'update'] as $op) {
if (count($this->getUnprocessedConfiguration($op, $collection))) {
return TRUE;
}
@@ -440,10 +440,10 @@ class ConfigImporter {
*/
protected function getUnprocessedExtensions($type) {
$changelist = $this->getExtensionChangelist($type);
- return array(
+ return [
'install' => array_diff($changelist['install'], $this->processedExtensions[$type]['install']),
'uninstall' => array_diff($changelist['uninstall'], $this->processedExtensions[$type]['uninstall']),
- );
+ ];
}
/**
@@ -459,7 +459,7 @@ class ConfigImporter {
$sync_steps = $this->initialize();
foreach ($sync_steps as $step) {
- $context = array();
+ $context = [];
do {
$this->doSyncStep($step, $context);
} while ($context['finished'] < 1);
@@ -489,7 +489,7 @@ class ConfigImporter {
}
elseif (is_callable($sync_step)) {
\Drupal::service('config.installer')->setSyncing(TRUE);
- call_user_func_array($sync_step, array(&$context, $this));
+ call_user_func_array($sync_step, [&$context, $this]);
}
else {
throw new \InvalidArgumentException('Invalid configuration synchronization step');
@@ -517,13 +517,13 @@ class ConfigImporter {
throw new ConfigImporterException(sprintf('%s is already importing', static::LOCK_NAME));
}
- $sync_steps = array();
+ $sync_steps = [];
$modules = $this->getUnprocessedExtensions('module');
- foreach (array('install', 'uninstall') as $op) {
+ foreach (['install', 'uninstall'] as $op) {
$this->totalExtensionsToProcess += count($modules[$op]);
}
$themes = $this->getUnprocessedExtensions('theme');
- foreach (array('install', 'uninstall') as $op) {
+ foreach (['install', 'uninstall'] as $op) {
$this->totalExtensionsToProcess += count($themes[$op]);
}
@@ -549,7 +549,7 @@ class ConfigImporter {
$operation = $this->getNextExtensionOperation();
if (!empty($operation)) {
$this->processExtension($operation['type'], $operation['op'], $operation['name']);
- $context['message'] = t('Synchronizing extensions: @op @name.', array('@op' => $operation['op'], '@name' => $operation['name']));
+ $context['message'] = t('Synchronizing extensions: @op @name.', ['@op' => $operation['op'], '@name' => $operation['name']]);
$processed_count = count($this->processedExtensions['module']['install']) + count($this->processedExtensions['module']['uninstall']);
$processed_count += count($this->processedExtensions['theme']['uninstall']) + count($this->processedExtensions['theme']['install']);
$context['finished'] = $processed_count / $this->totalExtensionsToProcess;
@@ -573,7 +573,7 @@ class ConfigImporter {
if ($this->totalConfigurationToProcess == 0) {
$this->storageComparer->reset();
foreach ($this->storageComparer->getAllCollectionNames() as $collection) {
- foreach (array('delete', 'create', 'rename', 'update') as $op) {
+ foreach (['delete', 'create', 'rename', 'update'] as $op) {
$this->totalConfigurationToProcess += count($this->getUnprocessedConfiguration($op, $collection));
}
}
@@ -584,14 +584,14 @@ class ConfigImporter {
$this->processConfiguration($operation['collection'], $operation['op'], $operation['name']);
}
if ($operation['collection'] == StorageInterface::DEFAULT_COLLECTION) {
- $context['message'] = $this->t('Synchronizing configuration: @op @name.', array('@op' => $operation['op'], '@name' => $operation['name']));
+ $context['message'] = $this->t('Synchronizing configuration: @op @name.', ['@op' => $operation['op'], '@name' => $operation['name']]);
}
else {
- $context['message'] = $this->t('Synchronizing configuration: @op @name in @collection.', array('@op' => $operation['op'], '@name' => $operation['name'], '@collection' => $operation['collection']));
+ $context['message'] = $this->t('Synchronizing configuration: @op @name in @collection.', ['@op' => $operation['op'], '@name' => $operation['name'], '@collection' => $operation['collection']]);
}
$processed_count = 0;
foreach ($this->storageComparer->getAllCollectionNames() as $collection) {
- foreach (array('delete', 'create', 'rename', 'update') as $op) {
+ foreach (['delete', 'create', 'rename', 'update'] as $op) {
$processed_count += count($this->processedConfiguration[$collection][$op]);
}
}
@@ -657,15 +657,15 @@ class ConfigImporter {
* on. If there is nothing left to do returns FALSE;
*/
protected function getNextExtensionOperation() {
- foreach (array('module', 'theme') as $type) {
- foreach (array('install', 'uninstall') as $op) {
+ foreach (['module', 'theme'] as $type) {
+ foreach (['install', 'uninstall'] as $op) {
$unprocessed = $this->getUnprocessedExtensions($type);
if (!empty($unprocessed[$op])) {
- return array(
+ return [
'op' => $op,
'type' => $type,
'name' => array_shift($unprocessed[$op]),
- );
+ ];
}
}
}
@@ -683,14 +683,14 @@ class ConfigImporter {
// The order configuration operations is processed is important. Deletes
// have to come first so that recreates can work.
foreach ($this->storageComparer->getAllCollectionNames() as $collection) {
- foreach (array('delete', 'create', 'rename', 'update') as $op) {
+ foreach (['delete', 'create', 'rename', 'update'] as $op) {
$config_names = $this->getUnprocessedConfiguration($op, $collection);
if (!empty($config_names)) {
- return array(
+ return [
'op' => $op,
'name' => array_shift($config_names),
'collection' => $collection,
- );
+ ];
}
}
}
@@ -716,11 +716,11 @@ class ConfigImporter {
$old_entity_type_id = $this->configManager->getEntityTypeIdByName($names['old_name']);
$new_entity_type_id = $this->configManager->getEntityTypeIdByName($names['new_name']);
if ($old_entity_type_id != $new_entity_type_id) {
- $this->logError($this->t('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', array('@old_type' => $old_entity_type_id, '@new_type' => $new_entity_type_id, '@old_name' => $names['old_name'], '@new_name' => $names['new_name'])));
+ $this->logError($this->t('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => $old_entity_type_id, '@new_type' => $new_entity_type_id, '@old_name' => $names['old_name'], '@new_name' => $names['new_name']]));
}
// Has to be a configuration entity.
if (!$old_entity_type_id) {
- $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', array('@old_name' => $names['old_name'], '@new_name' => $names['new_name'])));
+ $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => $names['old_name'], '@new_name' => $names['new_name']]));
}
}
$this->eventDispatcher->dispatch(ConfigEvents::IMPORT_VALIDATE, new ConfigImporterEvent($this));
@@ -760,7 +760,7 @@ class ConfigImporter {
}
}
catch (\Exception $e) {
- $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', array('@op' => $op, '@name' => $name, '@message' => $e->getMessage())));
+ $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', ['@op' => $op, '@name' => $name, '@message' => $e->getMessage()]));
// Error for that operation was logged, mark it as processed so that
// the import can continue.
$this->setProcessedConfiguration($collection, $op, $name);
@@ -783,7 +783,7 @@ class ConfigImporter {
\Drupal::service('config.installer')
->setSourceStorage($this->storageComparer->getSourceStorage());
if ($type == 'module') {
- $this->moduleInstaller->$op(array($name), FALSE);
+ $this->moduleInstaller->$op([$name], FALSE);
// Installing a module can cause a kernel boot therefore reinject all the
// services.
$this->reInjectMe();
@@ -803,7 +803,7 @@ class ConfigImporter {
$this->configManager->getConfigFactory()->reset('system.theme');
$this->processedSystemTheme = TRUE;
}
- $this->themeHandler->$op(array($name));
+ $this->themeHandler->$op([$name]);
}
$this->setProcessedExtension($type, $op, $name);
@@ -863,11 +863,11 @@ class ConfigImporter {
$entity_type = $this->configManager->getEntityManager()->getDefinition($entity_type_id);
$entity = $entity_storage->load($entity_storage->getIDFromConfigName($name, $entity_type->getConfigPrefix()));
$entity->delete();
- $this->logError($this->t('Deleted and replaced configuration entity "@name"', array('@name' => $name)));
+ $this->logError($this->t('Deleted and replaced configuration entity "@name"', ['@name' => $name]));
}
else {
$this->storageComparer->getTargetStorage($collection)->delete($name);
- $this->logError($this->t('Deleted and replaced configuration "@name"', array('@name' => $name)));
+ $this->logError($this->t('Deleted and replaced configuration "@name"', ['@name' => $name]));
}
return TRUE;
}
@@ -875,7 +875,7 @@ class ConfigImporter {
case 'update':
if (!$target_exists) {
- $this->logError($this->t('Update target "@name" is missing.', array('@name' => $name)));
+ $this->logError($this->t('Update target "@name" is missing.', ['@name' => $name]));
// Mark as processed so that the synchronization continues. Once the
// the current synchronization is complete it will show up as a
// create.
@@ -912,7 +912,7 @@ class ConfigImporter {
}
else {
$data = $this->storageComparer->getSourceStorage($collection)->read($name);
- $config->setData($data ? $data : array());
+ $config->setData($data ? $data : []);
$config->save();
}
$this->setProcessedConfiguration($collection, $op, $name);
@@ -1037,7 +1037,7 @@ class ConfigImporter {
* keep the services used by the importer in sync.
*/
protected function reInjectMe() {
- $this->_serviceIds = array();
+ $this->_serviceIds = [];
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value) && isset($value->_serviceId)) {
diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php
index 7b938fa8f0a..c632aa8bbb9 100644
--- a/core/lib/Drupal/Core/Config/ConfigInstaller.php
+++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php
@@ -425,7 +425,7 @@ class ConfigInstaller implements ConfigInstallerInterface {
* collection.
*/
protected function findPreExistingConfiguration(StorageInterface $storage) {
- $existing_configuration = array();
+ $existing_configuration = [];
// Gather information about all the supported collections.
$collection_info = $this->configManager->getConfigCollectionInfo();
diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php
index b5b1c905e1d..65da2e9136d 100644
--- a/core/lib/Drupal/Core/Config/ConfigManager.php
+++ b/core/lib/Drupal/Core/Config/ConfigManager.php
@@ -148,17 +148,17 @@ class ConfigManager implements ConfigManagerInterface {
$target_data = explode("\n", Yaml::encode($target_storage->read($target_name)));
// Check for new or removed files.
- if ($source_data === array('false')) {
+ if ($source_data === ['false']) {
// Added file.
// Cast the result of t() to a string, as the diff engine doesn't know
// about objects.
- $source_data = array((string) $this->t('File added'));
+ $source_data = [(string) $this->t('File added')];
}
- if ($target_data === array('false')) {
+ if ($target_data === ['false']) {
// Deleted file.
// Cast the result of t() to a string, as the diff engine doesn't know
// about objects.
- $target_data = array((string) $this->t('File removed'));
+ $target_data = [(string) $this->t('File removed')];
}
return new Diff($source_data, $target_data);
@@ -251,7 +251,7 @@ class ConfigManager implements ConfigManagerInterface {
if (!$dependency_manager) {
$dependency_manager = $this->getConfigDependencyManager();
}
- $dependencies = array();
+ $dependencies = [];
foreach ($names as $name) {
$dependencies = array_merge($dependencies, $dependency_manager->getDependentEntities($type, $name));
}
@@ -263,7 +263,7 @@ class ConfigManager implements ConfigManagerInterface {
*/
public function findConfigEntityDependentsAsEntities($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
$dependencies = $this->findConfigEntityDependents($type, $names, $dependency_manager);
- $entities = array();
+ $entities = [];
$definitions = $this->entityManager->getDefinitions();
foreach ($dependencies as $config_name => $dependency) {
// Group by entity type to efficient load entities using
@@ -278,7 +278,7 @@ class ConfigManager implements ConfigManagerInterface {
$entities[$entity_type_id][] = $id;
}
}
- $entities_to_return = array();
+ $entities_to_return = [];
foreach ($entities as $entity_type_id => $entities_to_load) {
$storage = $this->entityManager->getStorage($entity_type_id);
// Remove the keys since there are potential ID clashes from different
@@ -411,12 +411,12 @@ class ConfigManager implements ConfigManagerInterface {
return FALSE;
}
- $affected_dependencies = array(
- 'config' => array(),
- 'content' => array(),
- 'module' => array(),
- 'theme' => array(),
- );
+ $affected_dependencies = [
+ 'config' => [],
+ 'content' => [],
+ 'module' => [],
+ 'theme' => [],
+ ];
// Work out if any of the entity's dependencies are going to be affected.
if (isset($entity_dependencies[$type])) {
@@ -465,8 +465,8 @@ class ConfigManager implements ConfigManagerInterface {
* {@inheritdoc}
*/
public function findMissingContentDependencies() {
- $content_dependencies = array();
- $missing_dependencies = array();
+ $content_dependencies = [];
+ $missing_dependencies = [];
foreach ($this->activeStorage->readMultiple($this->activeStorage->listAll()) as $config_data) {
if (isset($config_data['dependencies']['content'])) {
$content_dependencies = array_merge($content_dependencies, $config_data['dependencies']['content']);
@@ -479,11 +479,11 @@ class ConfigManager implements ConfigManagerInterface {
// Format of the dependency is entity_type:bundle:uuid.
list($entity_type, $bundle, $uuid) = explode(':', $content_dependency, 3);
if (!$this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
- $missing_dependencies[$uuid] = array(
+ $missing_dependencies[$uuid] = [
'entity_type' => $entity_type,
'bundle' => $bundle,
'uuid' => $uuid,
- );
+ ];
}
}
return $missing_dependencies;
diff --git a/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php b/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php
index f6a6261bcd8..c4b4230df83 100644
--- a/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php
+++ b/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php
@@ -43,7 +43,7 @@ class ConfigModuleOverridesEvent extends Event {
public function __construct(array $names, LanguageInterface $language = NULL) {
$this->names = $names;
$this->language = $language;
- $this->overrides = array();
+ $this->overrides = [];
}
/**
@@ -91,7 +91,7 @@ class ConfigModuleOverridesEvent extends Event {
if (isset($this->overrides[$name])) {
// Existing overrides take precedence since these will have been added
// by events with a higher priority.
- $this->overrides[$name] = NestedArray::mergeDeepArray(array($values, $this->overrides[$name]), TRUE);
+ $this->overrides[$name] = NestedArray::mergeDeepArray([$values, $this->overrides[$name]], TRUE);
}
else {
$this->overrides[$name] = $values;
diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php
index 4e0c1844b88..1368dfff5d0 100644
--- a/core/lib/Drupal/Core/Config/DatabaseStorage.php
+++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php
@@ -32,7 +32,7 @@ class DatabaseStorage implements StorageInterface {
*
* @var array
*/
- protected $options = array();
+ protected $options = [];
/**
* The storage collection.
@@ -54,7 +54,7 @@ class DatabaseStorage implements StorageInterface {
* (optional) The collection to store configuration in. Defaults to the
* default collection.
*/
- public function __construct(Connection $connection, $table, array $options = array(), $collection = StorageInterface::DEFAULT_COLLECTION) {
+ public function __construct(Connection $connection, $table, array $options = [], $collection = StorageInterface::DEFAULT_COLLECTION) {
$this->connection = $connection;
$this->table = $table;
$this->options = $options;
@@ -66,10 +66,10 @@ class DatabaseStorage implements StorageInterface {
*/
public function exists($name) {
try {
- return (bool) $this->connection->queryRange('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', 0, 1, array(
+ return (bool) $this->connection->queryRange('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', 0, 1, [
':collection' => $this->collection,
':name' => $name,
- ), $this->options)->fetchField();
+ ], $this->options)->fetchField();
}
catch (\Exception $e) {
// If we attempt a read without actually having the database or the table
@@ -84,7 +84,7 @@ class DatabaseStorage implements StorageInterface {
public function read($name) {
$data = FALSE;
try {
- $raw = $this->connection->query('SELECT data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', array(':collection' => $this->collection, ':name' => $name), $this->options)->fetchField();
+ $raw = $this->connection->query('SELECT data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', [':collection' => $this->collection, ':name' => $name], $this->options)->fetchField();
if ($raw !== FALSE) {
$data = $this->decode($raw);
}
@@ -100,9 +100,9 @@ class DatabaseStorage implements StorageInterface {
* {@inheritdoc}
*/
public function readMultiple(array $names) {
- $list = array();
+ $list = [];
try {
- $list = $this->connection->query('SELECT name, data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name IN ( :names[] )', array(':collection' => $this->collection, ':names[]' => $names), $this->options)->fetchAllKeyed();
+ $list = $this->connection->query('SELECT name, data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name IN ( :names[] )', [':collection' => $this->collection, ':names[]' => $names], $this->options)->fetchAllKeyed();
foreach ($list as &$data) {
$data = $this->decode($data);
}
@@ -143,10 +143,10 @@ class DatabaseStorage implements StorageInterface {
* @return bool
*/
protected function doWrite($name, $data) {
- $options = array('return' => Database::RETURN_AFFECTED) + $this->options;
+ $options = ['return' => Database::RETURN_AFFECTED] + $this->options;
return (bool) $this->connection->merge($this->table, $options)
- ->keys(array('collection', 'name'), array($this->collection, $name))
- ->fields(array('data' => $data))
+ ->keys(['collection', 'name'], [$this->collection, $name])
+ ->fields(['data' => $data])
->execute();
}
@@ -182,32 +182,32 @@ class DatabaseStorage implements StorageInterface {
* Defines the schema for the configuration table.
*/
protected static function schemaDefinition() {
- $schema = array(
+ $schema = [
'description' => 'The base table for configuration data.',
- 'fields' => array(
- 'collection' => array(
+ 'fields' => [
+ 'collection' => [
'description' => 'Primary Key: Config object collection.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => 'Primary Key: Config object name.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'data' => array(
+ ],
+ 'data' => [
'description' => 'A serialized configuration object data.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
- ),
- ),
- 'primary key' => array('collection', 'name'),
- );
+ ],
+ ],
+ 'primary key' => ['collection', 'name'],
+ ];
return $schema;
}
@@ -219,7 +219,7 @@ class DatabaseStorage implements StorageInterface {
* @todo Ignore replica targets for data manipulation operations.
*/
public function delete($name) {
- $options = array('return' => Database::RETURN_AFFECTED) + $this->options;
+ $options = ['return' => Database::RETURN_AFFECTED] + $this->options;
return (bool) $this->connection->delete($this->table, $options)
->condition('collection', $this->collection)
->condition('name', $name)
@@ -233,9 +233,9 @@ class DatabaseStorage implements StorageInterface {
* @throws PDOException
*/
public function rename($name, $new_name) {
- $options = array('return' => Database::RETURN_AFFECTED) + $this->options;
+ $options = ['return' => Database::RETURN_AFFECTED] + $this->options;
return (bool) $this->connection->update($this->table, $options)
- ->fields(array('name' => $new_name))
+ ->fields(['name' => $new_name])
->condition('name', $name)
->condition('collection', $this->collection)
->execute();
@@ -266,14 +266,14 @@ class DatabaseStorage implements StorageInterface {
public function listAll($prefix = '') {
try {
$query = $this->connection->select($this->table);
- $query->fields($this->table, array('name'));
+ $query->fields($this->table, ['name']);
$query->condition('collection', $this->collection, '=');
$query->condition('name', $prefix . '%', 'LIKE');
$query->orderBy('collection')->orderBy('name');
return $query->execute()->fetchCol();
}
catch (\Exception $e) {
- return array();
+ return [];
}
}
@@ -282,7 +282,7 @@ class DatabaseStorage implements StorageInterface {
*/
public function deleteAll($prefix = '') {
try {
- $options = array('return' => Database::RETURN_AFFECTED) + $this->options;
+ $options = ['return' => Database::RETURN_AFFECTED] + $this->options;
return (bool) $this->connection->delete($this->table, $options)
->condition('name', $prefix . '%', 'LIKE')
->condition('collection', $this->collection)
@@ -317,12 +317,12 @@ class DatabaseStorage implements StorageInterface {
*/
public function getAllCollectionNames() {
try {
- return $this->connection->query('SELECT DISTINCT collection FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection <> :collection ORDER by collection', array(
- ':collection' => StorageInterface::DEFAULT_COLLECTION)
+ return $this->connection->query('SELECT DISTINCT collection FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection <> :collection ORDER by collection', [
+ ':collection' => StorageInterface::DEFAULT_COLLECTION]
)->fetchCol();
}
catch (\Exception $e) {
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php
index e639966c2da..ba69001f4d7 100644
--- a/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php
+++ b/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php
@@ -38,14 +38,14 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
*
* @var array
*/
- protected $checked = array();
+ protected $checked = [];
/**
* An array of config object names that are excluded from schema checking.
*
* @var string[]
*/
- protected $exclude = array();
+ protected $exclude = [];
/**
* Constructs the ConfigSchemaChecker object.
@@ -55,7 +55,7 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
* @param string[] $exclude
* An array of config object names that are excluded from schema checking.
*/
- public function __construct(TypedConfigManagerInterface $typed_manager, array $exclude = array()) {
+ public function __construct(TypedConfigManagerInterface $typed_manager, array $exclude = []) {
$this->typedManager = $typed_manager;
$this->exclude = $exclude;
}
@@ -90,7 +90,7 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
elseif (is_array($errors)) {
$text_errors = [];
foreach ($errors as $key => $error) {
- $text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $error));
+ $text_errors[] = SafeMarkup::format('@key @error', ['@key' => $key, '@error' => $error]);
}
throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors));
}
@@ -101,7 +101,7 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events[ConfigEvents::SAVE][] = array('onConfigSave', 255);
+ $events[ConfigEvents::SAVE][] = ['onConfigSave', 255];
return $events;
}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php
index 44c02e3f8e9..2ec87ddfacf 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php
@@ -17,7 +17,7 @@ trait ConfigDependencyDeleteFormTrait {
*
* Provided by \Drupal\Core\StringTranslation\StringTranslationTrait.
*/
- abstract protected function t($string, array $args = array(), array $options = array());
+ abstract protected function t($string, array $args = [], array $options = []);
/**
* Adds form elements to list affected configuration entities.
@@ -41,15 +41,15 @@ trait ConfigDependencyDeleteFormTrait {
protected function addDependencyListsToForm(array &$form, $type, array $names, ConfigManagerInterface $config_manager, EntityManagerInterface $entity_manager) {
// Get the dependent entities.
$dependent_entities = $config_manager->getConfigEntitiesToChangeOnDependencyRemoval($type, $names);
- $entity_types = array();
+ $entity_types = [];
- $form['entity_updates'] = array(
+ $form['entity_updates'] = [
'#type' => 'details',
'#title' => $this->t('Configuration updates'),
'#description' => $this->t('The listed configuration will be updated.'),
'#open' => TRUE,
'#access' => FALSE,
- );
+ ];
foreach ($dependent_entities['update'] as $entity) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
@@ -59,11 +59,11 @@ trait ConfigDependencyDeleteFormTrait {
// Store the ID and label to sort the entity types and entities later.
$label = $entity_type->getLabel();
$entity_types[$entity_type_id] = $label;
- $form['entity_updates'][$entity_type_id] = array(
+ $form['entity_updates'][$entity_type_id] = [
'#theme' => 'item_list',
'#title' => $label,
- '#items' => array(),
- );
+ '#items' => [],
+ ];
}
$form['entity_updates'][$entity_type_id]['#items'][$entity->id()] = $entity->label() ?: $entity->id();
}
@@ -81,13 +81,13 @@ trait ConfigDependencyDeleteFormTrait {
}
}
- $form['entity_deletes'] = array(
+ $form['entity_deletes'] = [
'#type' => 'details',
'#title' => $this->t('Configuration deletions'),
'#description' => $this->t('The listed configuration will be deleted.'),
'#open' => TRUE,
'#access' => FALSE,
- );
+ ];
foreach ($dependent_entities['delete'] as $entity) {
$entity_type_id = $entity->getEntityTypeId();
@@ -96,11 +96,11 @@ trait ConfigDependencyDeleteFormTrait {
// Store the ID and label to sort the entity types and entities later.
$label = $entity_type->getLabel();
$entity_types[$entity_type_id] = $label;
- $form['entity_deletes'][$entity_type_id] = array(
+ $form['entity_deletes'][$entity_type_id] = [
'#theme' => 'item_list',
'#title' => $label,
- '#items' => array(),
- );
+ '#items' => [],
+ ];
}
$form['entity_deletes'][$entity_type_id]['#items'][$entity->id()] = $entity->label() ?: $entity->id();
}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php
index 0dc1971383b..237929d42bd 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php
@@ -126,7 +126,7 @@ class ConfigDependencyManager {
*
* @var \Drupal\Core\Config\Entity\ConfigEntityDependency[]
*/
- protected $data = array();
+ protected $data = [];
/**
* The directed acyclic graph.
@@ -150,9 +150,9 @@ class ConfigDependencyManager {
* An array of config entity dependency objects that are dependent.
*/
public function getDependentEntities($type, $name) {
- $dependent_entities = array();
+ $dependent_entities = [];
- $entities_to_check = array();
+ $entities_to_check = [];
if ($type == 'config') {
$entities_to_check[] = $name;
}
@@ -281,7 +281,7 @@ class ConfigDependencyManager {
* supplied entities to check.
*/
protected function createGraphConfigEntityDependencies($entities_to_check) {
- $dependent_entities = array();
+ $dependent_entities = [];
$graph = $this->getGraph();
foreach ($entities_to_check as $entity) {
@@ -304,7 +304,7 @@ class ConfigDependencyManager {
*/
protected function getGraph() {
if (!isset($this->graph)) {
- $graph = array();
+ $graph = [];
foreach ($this->data as $entity) {
$graph_key = $entity->getConfigDependencyName();
if (!isset($graph[$graph_key])) {
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index 08e7e19170a..90bb7023799 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -86,7 +86,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
*
* @var array
*/
- protected $third_party_settings = array();
+ protected $third_party_settings = [];
/**
* Information maintained by Drupal core about configuration.
@@ -263,7 +263,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
* {@inheritdoc}
*/
public function toArray() {
- $properties = array();
+ $properties = [];
/** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */
$entity_type = $this->getEntityType();
@@ -411,7 +411,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
/**
* {@inheritdoc}
*/
- public function url($rel = 'edit-form', $options = array()) {
+ public function url($rel = 'edit-form', $options = []) {
// Do not remove this override: the default value of $rel is different.
return parent::url($rel, $options);
}
@@ -551,7 +551,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
* {@inheritdoc}
*/
public function getThirdPartySettings($module) {
- return isset($this->third_party_settings[$module]) ? $this->third_party_settings[$module] : array();
+ return isset($this->third_party_settings[$module]) ? $this->third_party_settings[$module] : [];
}
/**
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php
index dc17e054607..59128d86c77 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php
@@ -109,7 +109,7 @@ abstract class ConfigEntityBundleBase extends ConfigEntityBase {
$storage = $this->entityManager()->getStorage($entity_type_id);
return $storage->loadMultiple($ids);
}
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php
index 1b9a80edd71..d92b55b6ebe 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php
@@ -57,7 +57,7 @@ class ConfigEntityDependency {
* The list of dependencies of the supplied type.
*/
public function getDependencies($type) {
- $dependencies = array();
+ $dependencies = [];
if (isset($this->dependencies[$type])) {
$dependencies = $this->dependencies[$type];
}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
index acd9d030adf..38b7fa87a15 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
@@ -21,7 +21,7 @@ class ConfigEntityListBuilder extends EntityListBuilder {
// Sort the entities using the entity class's sort() method.
// See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
- uasort($entities, array($this->entityType->getClass(), 'sort'));
+ uasort($entities, [$this->entityType->getClass(), 'sort']);
return $entities;
}
@@ -34,18 +34,18 @@ class ConfigEntityListBuilder extends EntityListBuilder {
if ($this->entityType->hasKey('status')) {
if (!$entity->status() && $entity->hasLinkTemplate('enable')) {
- $operations['enable'] = array(
+ $operations['enable'] = [
'title' => t('Enable'),
'weight' => -10,
'url' => $entity->urlInfo('enable'),
- );
+ ];
}
elseif ($entity->hasLinkTemplate('disable')) {
- $operations['disable'] = array(
+ $operations['disable'] = [
'title' => t('Disable'),
'weight' => 40,
'url' => $entity->urlInfo('disable'),
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
index 3834dae082a..11b66fc7a19 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
@@ -84,7 +84,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
* @var array
* @see \Drupal\Core\Config\ConfigFactoryInterface::getCacheKeys().
*/
- protected $entities = array();
+ protected $entities = [];
/**
* Determines if the underlying configuration is retrieved override free.
@@ -170,7 +170,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
$names = $this->configFactory->listAll($prefix);
}
else {
- $names = array();
+ $names = [];
foreach ($ids as $id) {
// Add the prefix to the ID to serve as the configuration object name.
$names[] = $prefix . $id;
@@ -220,7 +220,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
*/
protected function doCreate(array $values) {
// Set default language to current language if not provided.
- $values += array($this->langcodeKey => $this->languageManager->getCurrentLanguage()->getId());
+ $values += [$this->langcodeKey => $this->languageManager->getCurrentLanguage()->getId()];
$entity = new $this->entityClass($values, $this->entityTypeId);
return $entity;
@@ -282,7 +282,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
// Update the entity with the values stored in configuration. It is possible
// that configuration schema has casted some of the values.
if (!$entity->hasTrustedData()) {
- $data = $this->mapFromStorageRecords(array($config->get()));
+ $data = $this->mapFromStorageRecords([$config->get()]);
$updated_entity = current($data);
foreach (array_keys($config->get()) as $property) {
@@ -326,7 +326,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
* Array of entities from the entity cache.
*/
protected function getFromStaticCache(array $ids) {
- $entities = array();
+ $entities = [];
// Load any available entities from the internal cache.
if ($this->entityType->isStaticallyCacheable() && !empty($this->entities)) {
$config_overrides_key = $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys());
@@ -366,9 +366,9 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
*/
protected function invokeHook($hook, EntityInterface $entity) {
// Invoke the hook.
- $this->moduleHandler->invokeAll($this->entityTypeId . '_' . $hook, array($entity));
+ $this->moduleHandler->invokeAll($this->entityTypeId . '_' . $hook, [$entity]);
// Invoke the respective entity-level hook.
- $this->moduleHandler->invokeAll('entity_' . $hook, array($entity, $this->entityTypeId));
+ $this->moduleHandler->invokeAll('entity_' . $hook, [$entity, $this->entityTypeId]);
}
/**
@@ -449,7 +449,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) {
$values[$this->uuidKey] = $this->uuidService->generate();
}
- $data = $this->mapFromStorageRecords(array($values));
+ $data = $this->mapFromStorageRecords([$values]);
$entity = current($data);
$entity->original = clone $entity;
$entity->setSyncing($is_syncing);
@@ -469,7 +469,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
public function updateFromStorageRecord(ConfigEntityInterface $entity, array $values) {
$entity->original = clone $entity;
- $data = $this->mapFromStorageRecords(array($values));
+ $data = $this->mapFromStorageRecords([$values]);
$updated_entity = current($data);
foreach (array_keys($values) as $property) {
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
index 1a364272395..11c9ff1bf09 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
@@ -64,9 +64,9 @@ class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface {
// Always add a default 'uuid' key.
$this->entity_keys['uuid'] = 'uuid';
$this->entity_keys['langcode'] = 'langcode';
- $this->handlers += array(
+ $this->handlers += [
'storage' => 'Drupal\Core\Config\Entity\ConfigEntityStorage',
- );
+ ];
$this->lookup_keys[] = 'uuid';
}
diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php
index 3aed1ece8dc..f6bf463b163 100644
--- a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php
+++ b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php
@@ -25,7 +25,7 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
*
* @var \Drupal\Core\Entity\EntityInterface[]
*/
- protected $entities = array();
+ protected $entities = [];
/**
* Name of the entity's weight field or FALSE if no field is provided.
@@ -62,7 +62,7 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
* {@inheritdoc}
*/
public function buildHeader() {
- $header = array();
+ $header = [];
if (!empty($this->weightKey)) {
$header['weight'] = t('Weight');
}
@@ -73,19 +73,19 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
- $row = array();
+ $row = [];
if (!empty($this->weightKey)) {
// Override default values to markup elements.
$row['#attributes']['class'][] = 'draggable';
$row['#weight'] = $entity->get($this->weightKey);
// Add weight column.
- $row['weight'] = array(
+ $row['weight'] = [
'#type' => 'weight',
- '#title' => t('Weight for @title', array('@title' => $entity->label())),
+ '#title' => t('Weight for @title', ['@title' => $entity->label()]),
'#title_display' => 'invisible',
'#default_value' => $entity->get($this->weightKey),
- '#attributes' => array('class' => array('weight')),
- );
+ '#attributes' => ['class' => ['weight']],
+ ];
}
return $row + parent::buildRow($entity);
}
@@ -104,18 +104,18 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form[$this->entitiesKey] = array(
+ $form[$this->entitiesKey] = [
'#type' => 'table',
'#header' => $this->buildHeader(),
- '#empty' => t('There is no @label yet.', array('@label' => $this->entityType->getLabel())),
- '#tabledrag' => array(
- array(
+ '#empty' => t('There is no @label yet.', ['@label' => $this->entityType->getLabel()]),
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'weight',
- ),
- ),
- );
+ ],
+ ],
+ ];
$this->entities = $this->load();
$delta = 10;
@@ -129,7 +129,7 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
foreach ($this->entities as $entity) {
$row = $this->buildRow($entity);
if (isset($row['label'])) {
- $row['label'] = array('#markup' => $row['label']);
+ $row['label'] = ['#markup' => $row['label']];
}
if (isset($row['weight'])) {
$row['weight']['#delta'] = $delta;
@@ -138,11 +138,11 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
}
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php
index c7e993db1f4..6764d01ea6e 100644
--- a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php
+++ b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php
@@ -19,8 +19,8 @@ class Condition extends ConditionBase {
*/
public function compile($configs) {
$and = strtoupper($this->conjunction) == 'AND';
- $single_conditions = array();
- $condition_groups = array();
+ $single_conditions = [];
+ $condition_groups = [];
foreach ($this->conditions as $condition) {
if ($condition['field'] instanceof ConditionInterface) {
$condition_groups[] = $condition;
@@ -41,7 +41,7 @@ class Condition extends ConditionBase {
$single_conditions[] = $condition;
}
}
- $return = array();
+ $return = [];
if ($single_conditions) {
foreach ($configs as $config_name => $config) {
foreach ($single_conditions as $condition) {
@@ -110,7 +110,7 @@ class Condition extends ConditionBase {
* @return bool
* TRUE when the condition matched to the data else FALSE.
*/
- protected function matchArray(array $condition, array $data, array $needs_matching, array $parents = array()) {
+ protected function matchArray(array $condition, array $data, array $needs_matching, array $parents = []) {
$parent = array_shift($needs_matching);
if ($parent === '*') {
$candidates = array_keys($data);
@@ -120,7 +120,7 @@ class Condition extends ConditionBase {
if (!isset($data[$parent])) {
$data[$parent] = NULL;
}
- $candidates = array($parent);
+ $candidates = [$parent];
}
foreach ($candidates as $key) {
if ($needs_matching) {
diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
index eee073f56cc..e75b98a868d 100644
--- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php
+++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
@@ -141,7 +141,7 @@ class Query extends QueryBase implements QueryInterface {
elseif (in_array($condition['field'], $lookup_keys)) {
// If we don't find anything then there are no matches. No point in
// listing anything.
- $names = array();
+ $names = [];
$keys = (array) $condition['value'];
$keys = array_map(function ($value) use ($condition) {
return $condition['field'] . ':' . $value;
@@ -208,7 +208,7 @@ class Query extends QueryBase implements QueryInterface {
}
// Load the corresponding records.
- $records = array();
+ $records = [];
foreach ($this->configFactory->loadMultiple($names) as $config) {
$records[substr($config->getName(), $prefix_length)] = $config->get();
}
diff --git a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
index 0327e902b38..ac12f56e743 100644
--- a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
+++ b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
@@ -163,7 +163,7 @@ class QueryFactory implements QueryFactoryInterface, EventSubscriberInterface {
$values = (array) $this->getValues($config, $parts[0], $get_method, $parts);
- $output = array();
+ $output = [];
// Flatten the array to a single dimension and add the key to all the
// values.
array_walk_recursive($values, function ($current) use (&$output, $key) {
@@ -250,8 +250,8 @@ class QueryFactory implements QueryFactoryInterface, EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::SAVE][] = array('onConfigSave', 128);
- $events[ConfigEvents::DELETE][] = array('onConfigDelete', 128);
+ $events[ConfigEvents::SAVE][] = ['onConfigSave', 128];
+ $events[ConfigEvents::DELETE][] = ['onConfigDelete', 128];
return $events;
}
diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
index 16fecbc3966..9103ab8c07a 100644
--- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
+++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
@@ -88,7 +88,7 @@ class ExtensionInstallStorage extends InstallStorage {
*/
protected function getAllFolders() {
if (!isset($this->folders)) {
- $this->folders = array();
+ $this->folders = [];
$this->folders += $this->getCoreNames();
$extensions = $this->configStorage->read('core.extension');
@@ -107,7 +107,7 @@ class ExtensionInstallStorage extends InstallStorage {
drupal_get_filename('profile', $this->installProfile, $profile_list[$this->installProfile]->getPathname());
}
$module_list_scan = $listing->scan('module');
- $module_list = array();
+ $module_list = [];
foreach (array_keys($modules) as $module) {
if (isset($module_list_scan[$module])) {
$module_list[$module] = $module_list_scan[$module];
@@ -134,7 +134,7 @@ class ExtensionInstallStorage extends InstallStorage {
$profile_list = $listing->scan('profile');
}
if (isset($profile_list[$this->installProfile])) {
- $profile_folders = $this->getComponentNames(array($profile_list[$this->installProfile]));
+ $profile_folders = $this->getComponentNames([$profile_list[$this->installProfile]]);
$this->folders = $profile_folders + $this->folders;
}
}
diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php
index 4904576e226..84d23d32745 100644
--- a/core/lib/Drupal/Core/Config/FileStorage.php
+++ b/core/lib/Drupal/Core/Config/FileStorage.php
@@ -125,7 +125,7 @@ class FileStorage implements StorageInterface {
* {@inheritdoc}
*/
public function readMultiple(array $names) {
- $list = array();
+ $list = [];
foreach ($names as $name) {
if ($data = $this->read($name)) {
$list[$name] = $data;
@@ -217,7 +217,7 @@ class FileStorage implements StorageInterface {
public function listAll($prefix = '') {
$dir = $this->getCollectionDirectory();
if (!is_dir($dir)) {
- return array();
+ return [];
}
$extension = '.' . static::getFileExtension();
@@ -227,7 +227,7 @@ class FileStorage implements StorageInterface {
// @see https://github.com/mikey179/vfsStream/issues/2
$files = scandir($dir);
- $names = array();
+ $names = [];
$pattern = '/^' . preg_quote($prefix, '/') . '.*' . preg_quote($extension, '/') . '$/';
foreach ($files as $file) {
if ($file[0] !== '.' && preg_match($pattern, $file)) {
@@ -311,7 +311,7 @@ class FileStorage implements StorageInterface {
* A list of collection names contained within the provided directory.
*/
protected function getAllCollectionNamesHelper($directory) {
- $collections = array();
+ $collections = [];
$pattern = '/\.' . preg_quote($this->getFileExtension(), '/') . '$/';
foreach (new \DirectoryIterator($directory) as $fileinfo) {
if ($fileinfo->isDir() && !$fileinfo->isDot()) {
diff --git a/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php b/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php
index 9def6df921d..3dca3fbf001 100644
--- a/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php
+++ b/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php
@@ -33,7 +33,7 @@ class FinalMissingContentSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
// This should always be the final event as it will mark all content
// dependencies as resolved.
- $events[ConfigEvents::IMPORT_MISSING_CONTENT][] = array('onMissingContent', -1024);
+ $events[ConfigEvents::IMPORT_MISSING_CONTENT][] = ['onMissingContent', -1024];
return $events;
}
diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php
index bd9bf3055f8..9fea3df4730 100644
--- a/core/lib/Drupal/Core/Config/InstallStorage.php
+++ b/core/lib/Drupal/Core/Config/InstallStorage.php
@@ -131,7 +131,7 @@ class InstallStorage extends FileStorage {
return $names;
}
else {
- $return = array();
+ $return = [];
foreach ($names as $index => $name) {
if (strpos($name, $prefix) === 0 ) {
$return[$index] = $names[$index];
@@ -149,7 +149,7 @@ class InstallStorage extends FileStorage {
*/
protected function getAllFolders() {
if (!isset($this->folders)) {
- $this->folders = array();
+ $this->folders = [];
$this->folders += $this->getCoreNames();
// Perform an ExtensionDiscovery scan as we cannot use drupal_get_path()
// yet because the system module may not yet be enabled during install.
@@ -163,7 +163,7 @@ class InstallStorage extends FileStorage {
// during the module scan.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname());
- $this->folders += $this->getComponentNames(array($profile_list[$profile]));
+ $this->folders += $this->getComponentNames([$profile_list[$profile]]);
}
}
// @todo Remove as part of https://www.drupal.org/node/2186491
@@ -185,7 +185,7 @@ class InstallStorage extends FileStorage {
public function getComponentNames(array $list) {
$extension = '.' . $this->getFileExtension();
$pattern = '/' . preg_quote($extension, '/') . '$/';
- $folders = array();
+ $folders = [];
foreach ($list as $extension_object) {
// We don't have to use ExtensionDiscovery here because our list of
// extensions was already obtained through an ExtensionDiscovery scan.
@@ -216,7 +216,7 @@ class InstallStorage extends FileStorage {
public function getCoreNames() {
$extension = '.' . $this->getFileExtension();
$pattern = '/' . preg_quote($extension, '/') . '$/';
- $folders = array();
+ $folders = [];
$directory = $this->getCoreFolder();
if (is_dir($directory)) {
// glob() directly calls into libc glob(), which is not aware of PHP
diff --git a/core/lib/Drupal/Core/Config/NullStorage.php b/core/lib/Drupal/Core/Config/NullStorage.php
index 796603368fe..0dd14730a21 100644
--- a/core/lib/Drupal/Core/Config/NullStorage.php
+++ b/core/lib/Drupal/Core/Config/NullStorage.php
@@ -29,14 +29,14 @@ class NullStorage implements StorageInterface {
* {@inheritdoc}
*/
public function read($name) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function readMultiple(array $names) {
- return array();
+ return [];
}
/**
@@ -78,7 +78,7 @@ class NullStorage implements StorageInterface {
* {@inheritdoc}
*/
public function listAll($prefix = '') {
- return array();
+ return [];
}
/**
@@ -99,7 +99,7 @@ class NullStorage implements StorageInterface {
* {@inheritdoc}
*/
public function getAllCollectionNames() {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Config/PreExistingConfigException.php b/core/lib/Drupal/Core/Config/PreExistingConfigException.php
index 4c19dfaff42..57f54b29656 100644
--- a/core/lib/Drupal/Core/Config/PreExistingConfigException.php
+++ b/core/lib/Drupal/Core/Config/PreExistingConfigException.php
@@ -57,10 +57,10 @@ class PreExistingConfigException extends ConfigException {
*/
public static function create($extension, array $config_objects) {
$message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension already exist in active configuration',
- array(
+ [
'@config_names' => implode(', ', static::flattenConfigObjects($config_objects)),
'@extension' => $extension
- )
+ ]
);
$e = new static($message);
$e->configObjects = $config_objects;
@@ -80,7 +80,7 @@ class PreExistingConfigException extends ConfigException {
* collection.
*/
public static function flattenConfigObjects(array $config_objects) {
- $flat_config_objects = array();
+ $flat_config_objects = [];
foreach ($config_objects as $collection => $config_names) {
$config_names = array_map(function ($config_name) use ($collection) {
if ($collection != StorageInterface::DEFAULT_COLLECTION) {
diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php
index 7fc6cc51532..c5076554475 100644
--- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php
+++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php
@@ -19,7 +19,7 @@ abstract class ArrayElement extends Element implements \IteratorAggregate, Typed
* Array of valid configuration data keys.
*/
protected function getAllKeys() {
- return is_array($this->value) ? array_keys($this->value) : array();
+ return is_array($this->value) ? array_keys($this->value) : [];
}
/**
@@ -29,7 +29,7 @@ abstract class ArrayElement extends Element implements \IteratorAggregate, Typed
* An array of elements contained in this element.
*/
protected function parse() {
- $elements = array();
+ $elements = [];
foreach ($this->getAllKeys() as $key) {
$value = isset($this->value[$key]) ? $this->value[$key] : NULL;
$definition = $this->getElementDefinition($key);
@@ -96,7 +96,7 @@ abstract class ArrayElement extends Element implements \IteratorAggregate, Typed
* {@inheritdoc}
*/
public function toArray() {
- return isset($this->value) ? $this->value : array();
+ return isset($this->value) ? $this->value : [];
}
/**
diff --git a/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php b/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php
index f74cc91c1ee..b086c62cbb5 100644
--- a/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php
+++ b/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php
@@ -34,7 +34,7 @@ class ConfigSchemaDiscovery implements DiscoveryInterface {
* {@inheritdoc}
*/
public function getDefinitions() {
- $definitions = array();
+ $definitions = [];
foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
foreach ($schema as $type => $definition) {
$definitions[$type] = $definition;
diff --git a/core/lib/Drupal/Core/Config/Schema/Mapping.php b/core/lib/Drupal/Core/Config/Schema/Mapping.php
index 2f4b58f8eb7..220a350490e 100644
--- a/core/lib/Drupal/Core/Config/Schema/Mapping.php
+++ b/core/lib/Drupal/Core/Config/Schema/Mapping.php
@@ -22,7 +22,7 @@ class Mapping extends ArrayElement {
*/
protected function getElementDefinition($key) {
$value = isset($this->value[$key]) ? $this->value[$key] : NULL;
- $definition = isset($this->definition['mapping'][$key]) ? $this->definition['mapping'][$key] : array();
+ $definition = isset($this->definition['mapping'][$key]) ? $this->definition['mapping'][$key] : [];
return $this->buildDataDefinition($definition, $value, $key);
}
diff --git a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php
index 972eda43838..9230281f55d 100644
--- a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php
+++ b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php
@@ -58,7 +58,7 @@ trait SchemaCheckTrait {
$definition = $typed_config->getDefinition($config_name);
$data_definition = $typed_config->buildDataDefinition($definition, $config_data);
$this->schema = $typed_config->create($data_definition, $config_data);
- $errors = array();
+ $errors = [];
foreach ($config_data as $key => $value) {
$errors = array_merge($errors, $this->checkValue($key, $value));
}
@@ -83,12 +83,12 @@ trait SchemaCheckTrait {
$error_key = $this->configName . ':' . $key;
$element = $this->schema->get($key);
if ($element instanceof Undefined) {
- return array($error_key => 'missing schema');
+ return [$error_key => 'missing schema'];
}
// Do not check value if it is defined to be ignored.
if ($element && $element instanceof Ignore) {
- return array();
+ return [];
}
if ($element && is_scalar($value) || $value === NULL) {
@@ -110,11 +110,11 @@ trait SchemaCheckTrait {
}
$class = get_class($element);
if (!$success) {
- return array($error_key => "variable type is $type but applied schema class is $class");
+ return [$error_key => "variable type is $type but applied schema class is $class"];
}
}
else {
- $errors = array();
+ $errors = [];
if (!$element instanceof TraversableTypedDataInterface) {
$errors[$error_key] = 'non-scalar value but not defined as an array (such as mapping or sequence)';
}
@@ -131,7 +131,7 @@ trait SchemaCheckTrait {
return $errors;
}
// No errors found.
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Config/Schema/Sequence.php b/core/lib/Drupal/Core/Config/Schema/Sequence.php
index e03427e6b73..ce8dc1bc0b2 100644
--- a/core/lib/Drupal/Core/Config/Schema/Sequence.php
+++ b/core/lib/Drupal/Core/Config/Schema/Sequence.php
@@ -19,7 +19,7 @@ class Sequence extends ArrayElement {
protected function getElementDefinition($key) {
$value = isset($this->value[$key]) ? $this->value[$key] : NULL;
// @todo: Remove BC layer for sequence with hyphen in front. https://www.drupal.org/node/2444979
- $definition = array();
+ $definition = [];
if (isset($this->definition['sequence'][0])) {
$definition = $this->definition['sequence'][0];
}
diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php
index 40a25ef306b..4b227c9efbd 100644
--- a/core/lib/Drupal/Core/Config/StorableConfigBase.php
+++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php
@@ -55,7 +55,7 @@ abstract class StorableConfigBase extends ConfigBase {
*
* @var array
*/
- protected $originalData = array();
+ protected $originalData = [];
/**
* Saves the configuration object.
diff --git a/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php
index bf071de300e..55aeebc561f 100644
--- a/core/lib/Drupal/Core/Config/StorageComparer.php
+++ b/core/lib/Drupal/Core/Config/StorageComparer.php
@@ -63,7 +63,7 @@ class StorageComparer implements StorageComparerInterface {
*
* @var array
*/
- protected $sourceNames = array();
+ protected $sourceNames = [];
/**
* Sorted list of all the configuration object names in the target storage.
@@ -72,7 +72,7 @@ class StorageComparer implements StorageComparerInterface {
*
* @var array
*/
- protected $targetNames = array();
+ protected $targetNames = [];
/**
* A memory cache backend to statically cache source configuration data.
@@ -149,12 +149,12 @@ class StorageComparer implements StorageComparerInterface {
* {@inheritdoc}
*/
public function getEmptyChangelist() {
- return array(
- 'create' => array(),
- 'update' => array(),
- 'delete' => array(),
- 'rename' => array(),
- );
+ return [
+ 'create' => [],
+ 'update' => [],
+ 'delete' => [],
+ 'rename' => [],
+ ];
}
/**
@@ -254,7 +254,7 @@ class StorageComparer implements StorageComparerInterface {
* The storage collection to operate on.
*/
protected function addChangelistUpdate($collection) {
- $recreates = array();
+ $recreates = [];
foreach (array_intersect($this->sourceNames[$collection], $this->targetNames[$collection]) as $name) {
$source_data = $this->getSourceStorage($collection)->read($name);
$target_data = $this->getTargetStorage($collection)->read($name);
@@ -266,7 +266,7 @@ class StorageComparer implements StorageComparerInterface {
$recreates[] = $name;
}
else {
- $this->addChangeList($collection, 'update', array($name));
+ $this->addChangeList($collection, 'update', [$name]);
}
}
}
@@ -298,7 +298,7 @@ class StorageComparer implements StorageComparerInterface {
return;
}
- $create_uuids = array();
+ $create_uuids = [];
foreach ($this->sourceNames[$collection] as $name) {
$data = $this->getSourceStorage($collection)->read($name);
if (isset($data['uuid']) && in_array($name, $create_list)) {
@@ -309,7 +309,7 @@ class StorageComparer implements StorageComparerInterface {
return;
}
- $renames = array();
+ $renames = [];
// Renames should be ordered so that dependencies are renamed last. This
// ensures that if there is logic in the configuration entity class to keep
@@ -357,15 +357,15 @@ class StorageComparer implements StorageComparerInterface {
public function moveRenameToUpdate($rename, $collection = StorageInterface::DEFAULT_COLLECTION) {
$names = $this->extractRenameNames($rename);
$this->removeFromChangelist($collection, 'rename', $rename);
- $this->addChangeList($collection, 'update', array($names['new_name']), $this->sourceNames[$collection]);
+ $this->addChangeList($collection, 'update', [$names['new_name']], $this->sourceNames[$collection]);
}
/**
* {@inheritdoc}
*/
public function reset() {
- $this->changelist = array(StorageInterface::DEFAULT_COLLECTION => $this->getEmptyChangelist());
- $this->sourceNames = $this->targetNames = array();
+ $this->changelist = [StorageInterface::DEFAULT_COLLECTION => $this->getEmptyChangelist()];
+ $this->sourceNames = $this->targetNames = [];
// Reset the static configuration data caches.
$this->sourceCacheStorage->deleteAll();
$this->targetCacheStorage->deleteAll();
@@ -377,7 +377,7 @@ class StorageComparer implements StorageComparerInterface {
*/
public function hasChanges() {
foreach ($this->getAllCollectionNames() as $collection) {
- foreach (array('delete', 'create', 'update', 'rename') as $op) {
+ foreach (['delete', 'create', 'update', 'rename'] as $op) {
if (!empty($this->changelist[$collection][$op])) {
return TRUE;
}
@@ -442,10 +442,10 @@ class StorageComparer implements StorageComparerInterface {
*/
public function extractRenameNames($name) {
$names = explode('::', $name, 2);
- return array(
+ return [
'old_name' => $names[0],
'new_name' => $names[1],
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php
index b90e463a604..22795ad6fff 100644
--- a/core/lib/Drupal/Core/Config/TypedConfigManager.php
+++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php
@@ -79,13 +79,13 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
*/
public function buildDataDefinition(array $definition, $value, $name = NULL, $parent = NULL) {
// Add default values for data type and replace variables.
- $definition += array('type' => 'undefined');
+ $definition += ['type' => 'undefined'];
$replace = [];
$type = $definition['type'];
if (strpos($type, ']')) {
// Replace variable names in definition.
- $replace = is_array($value) ? $value : array();
+ $replace = is_array($value) ? $value : [];
if (isset($parent)) {
$replace['%parent'] = $parent;
}
@@ -161,7 +161,7 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
$merge = $this->getDefinition($definition['type'], $exception_on_invalid);
// Preserve integer keys on merge, so sequence item types can override
// parent settings as opposed to adding unused second, third, etc. items.
- $definition = NestedArray::mergeDeepArray(array($merge, $definition), TRUE);
+ $definition = NestedArray::mergeDeepArray([$merge, $definition], TRUE);
// Replace dynamic portions of the definition type.
if (!empty($replacements) && strpos($definition['type'], ']')) {
@@ -181,10 +181,10 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
$this->definitions[$type] = $definition;
}
// Add type and default definition class.
- $definition += array(
+ $definition += [
'definition_class' => '\Drupal\Core\TypedData\DataDefinition',
'type' => $type,
- );
+ ];
return $definition;
}
@@ -270,7 +270,7 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
protected function replaceName($name, $data) {
if (preg_match_all("/\[(.*)\]/U", $name, $matches)) {
// Build our list of '[value]' => replacement.
- $replace = array();
+ $replace = [];
foreach (array_combine($matches[0], $matches[1]) as $key => $value) {
$replace[$key] = $this->replaceVariable($value, $data);
}
diff --git a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
index 9ce487b34f6..6c37c763720 100644
--- a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
+++ b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
@@ -90,10 +90,10 @@ class UnmetDependenciesException extends ConfigException {
*/
public static function create($extension, array $config_objects) {
$message = new FormattableMarkup('Configuration objects provided by %extension have unmet dependencies: %config_names',
- array(
+ [
'%config_names' => static::formatConfigObjectList($config_objects),
'%extension' => $extension
- )
+ ]
);
$e = new static($message);
$e->configObjects = $config_objects;
diff --git a/core/lib/Drupal/Core/Controller/ControllerResolver.php b/core/lib/Drupal/Core/Controller/ControllerResolver.php
index 3a1d8684acb..c16a087449b 100644
--- a/core/lib/Drupal/Core/Controller/ControllerResolver.php
+++ b/core/lib/Drupal/Core/Controller/ControllerResolver.php
@@ -122,7 +122,7 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes
$controller = $this->classResolver->getInstanceFromDefinition($class_or_service);
- return array($controller, $method);
+ return [$controller, $method];
}
/**
@@ -131,7 +131,7 @@ class ControllerResolver extends BaseControllerResolver implements ControllerRes
protected function doGetArguments(Request $request, $controller, array $parameters) {
$attributes = $request->attributes->all();
$raw_parameters = $request->attributes->has('_raw_variables') ? $request->attributes->get('_raw_variables') : [];
- $arguments = array();
+ $arguments = [];
foreach ($parameters as $param) {
if (array_key_exists($param->name, $attributes)) {
$arguments[] = $attributes[$param->name];
diff --git a/core/lib/Drupal/Core/Controller/TitleResolver.php b/core/lib/Drupal/Core/Controller/TitleResolver.php
index e5e5fcebf58..954835d7549 100644
--- a/core/lib/Drupal/Core/Controller/TitleResolver.php
+++ b/core/lib/Drupal/Core/Controller/TitleResolver.php
@@ -47,11 +47,11 @@ class TitleResolver implements TitleResolverInterface {
$route_title = call_user_func_array($callable, $arguments);
}
elseif ($title = $route->getDefault('_title')) {
- $options = array();
+ $options = [];
if ($context = $route->getDefault('_title_context')) {
$options['context'] = $context;
}
- $args = array();
+ $args = [];
if (($raw_parameters = $request->attributes->get('_raw_variables'))) {
foreach ($raw_parameters->all() as $key => $value) {
$args['@' . $key] = $value;
diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index daf4668c16e..f6963c585b7 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -50,14 +50,14 @@ abstract class Connection {
*
* @var array
*/
- protected $transactionLayers = array();
+ protected $transactionLayers = [];
/**
* Index of what driver-specific class to use for various operations.
*
* @var array
*/
- protected $driverClasses = array();
+ protected $driverClasses = [];
/**
* The name of the Statement class for this connection.
@@ -101,7 +101,7 @@ abstract class Connection {
*
* @var array
*/
- protected $connectionOptions = array();
+ protected $connectionOptions = [];
/**
* The schema object for this connection.
@@ -117,21 +117,21 @@ abstract class Connection {
*
* @var array
*/
- protected $prefixes = array();
+ protected $prefixes = [];
/**
* List of search values for use in prefixTables().
*
* @var array
*/
- protected $prefixSearch = array();
+ protected $prefixSearch = [];
/**
* List of replacement values for use in prefixTables().
*
* @var array
*/
- protected $prefixReplace = array();
+ protected $prefixReplace = [];
/**
* List of un-prefixed table names, keyed by prefixed table names.
@@ -171,7 +171,7 @@ abstract class Connection {
// Set a Statement class, unless the driver opted out.
if (!empty($this->statementClass)) {
- $connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
+ $connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [$this->statementClass, [$this]]);
}
$this->connection = $connection;
@@ -187,7 +187,7 @@ abstract class Connection {
* @return \PDO
* A \PDO object.
*/
- public static function open(array &$connection_options = array()) { }
+ public static function open(array &$connection_options = []) { }
/**
* Destroys this Connection object.
@@ -202,7 +202,7 @@ abstract class Connection {
// The Statement class attribute only accepts a new value that presents a
// proper callable, so we reset it to PDOStatement.
if (!empty($this->statementClass)) {
- $this->connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array()));
+ $this->connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, ['PDOStatement', []]);
}
$this->schema = NULL;
}
@@ -259,13 +259,13 @@ abstract class Connection {
* An array of default query options.
*/
protected function defaultOptions() {
- return array(
+ return [
'target' => 'default',
'fetch' => \PDO::FETCH_OBJ,
'return' => Database::RETURN_STATEMENT,
'throw_exception' => TRUE,
'allow_delimiter_in_query' => FALSE,
- );
+ ];
}
/**
@@ -293,16 +293,16 @@ abstract class Connection {
*/
protected function setPrefix($prefix) {
if (is_array($prefix)) {
- $this->prefixes = $prefix + array('default' => '');
+ $this->prefixes = $prefix + ['default' => ''];
}
else {
- $this->prefixes = array('default' => $prefix);
+ $this->prefixes = ['default' => $prefix];
}
// Set up variables for use in prefixTables(). Replace table-specific
// prefixes first.
- $this->prefixSearch = array();
- $this->prefixReplace = array();
+ $this->prefixSearch = [];
+ $this->prefixReplace = [];
foreach ($this->prefixes as $key => $val) {
if ($key != 'default') {
$this->prefixSearch[] = '{' . $key . '}';
@@ -596,7 +596,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
- public function query($query, array $args = array(), $options = array()) {
+ public function query($query, array $args = [], $options = []) {
// Use default values if not already set.
$options += $this->defaultOptions();
@@ -670,7 +670,7 @@ abstract class Connection {
* @throws \Drupal\Core\Database\DatabaseExceptionWrapper
* @throws \Drupal\Core\Database\IntegrityConstraintViolationException
*/
- protected function handleQueryException(\PDOException $e, $query, array $args = array(), $options = array()) {
+ protected function handleQueryException(\PDOException $e, $query, array $args = [], $options = []) {
if ($options['throw_exception']) {
// Wrap the exception in another exception, because PHP does not allow
// overriding Exception::getMessage(). Its message is the extra database
@@ -732,7 +732,7 @@ abstract class Connection {
}
// Handle expansion of arrays.
$key_name = str_replace('[]', '__', $key);
- $new_keys = array();
+ $new_keys = [];
// We require placeholders to have trailing brackets if the developer
// intends them to be expanded to an array to make the intent explicit.
foreach (array_values($data) as $i => $value) {
@@ -796,7 +796,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Query\Select
*/
- public function select($table, $alias = NULL, array $options = array()) {
+ public function select($table, $alias = NULL, array $options = []) {
$class = $this->getDriverClass('Select');
return new $class($table, $alias, $this, $options);
}
@@ -814,7 +814,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Query\Insert
*/
- public function insert($table, array $options = array()) {
+ public function insert($table, array $options = []) {
$class = $this->getDriverClass('Insert');
return new $class($this, $table, $options);
}
@@ -832,7 +832,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Query\Merge
*/
- public function merge($table, array $options = array()) {
+ public function merge($table, array $options = []) {
$class = $this->getDriverClass('Merge');
return new $class($this, $table, $options);
}
@@ -850,7 +850,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Query\Upsert
*/
- public function upsert($table, array $options = array()) {
+ public function upsert($table, array $options = []) {
$class = $this->getDriverClass('Upsert');
return new $class($this, $table, $options);
}
@@ -868,7 +868,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Query\Update
*/
- public function update($table, array $options = array()) {
+ public function update($table, array $options = []) {
$class = $this->getDriverClass('Update');
return new $class($this, $table, $options);
}
@@ -886,7 +886,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Query\Delete
*/
- public function delete($table, array $options = array()) {
+ public function delete($table, array $options = []) {
$class = $this->getDriverClass('Delete');
return new $class($this, $table, $options);
}
@@ -904,7 +904,7 @@ abstract class Connection {
*
* @see \Drupal\Core\Database\Query\Truncate
*/
- public function truncate($table, array $options = array()) {
+ public function truncate($table, array $options = []) {
$class = $this->getDriverClass('Truncate');
return new $class($this, $table, $options);
}
@@ -1237,7 +1237,7 @@ abstract class Connection {
* A database query result resource, or NULL if the query was not executed
* correctly.
*/
- abstract public function queryRange($query, $from, $count, array $args = array(), array $options = array());
+ abstract public function queryRange($query, $from, $count, array $args = [], array $options = []);
/**
* Generates a temporary table name.
@@ -1274,7 +1274,7 @@ abstract class Connection {
* @return string
* The name of the temporary table.
*/
- abstract function queryTemporary($query, array $args = array(), array $options = array());
+ abstract function queryTemporary($query, array $args = [], array $options = []);
/**
* Returns the type of database driver.
@@ -1421,7 +1421,7 @@ abstract class Connection {
*
* @see \PDO::prepare()
*/
- public function prepare($statement, array $driver_options = array()) {
+ public function prepare($statement, array $driver_options = []) {
return $this->connection->prepare($statement, $driver_options);
}
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 8fe1c453eab..dd19018828b 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -40,21 +40,21 @@ abstract class Database {
*
* @var array
*/
- static protected $connections = array();
+ static protected $connections = [];
/**
* A processed copy of the database connection information from settings.php.
*
* @var array
*/
- static protected $databaseInfo = array();
+ static protected $databaseInfo = [];
/**
* A list of key/target credentials to simply ignore.
*
* @var array
*/
- static protected $ignoreTargets = array();
+ static protected $ignoreTargets = [];
/**
* The key of the currently active database connection.
@@ -75,7 +75,7 @@ abstract class Database {
*
* @var array
*/
- static protected $logs = array();
+ static protected $logs = [];
/**
* Starts logging a given logging key on the specified connection.
@@ -214,15 +214,15 @@ abstract class Database {
// Parse the prefix information.
if (!isset($info['prefix'])) {
// Default to an empty prefix.
- $info['prefix'] = array(
+ $info['prefix'] = [
'default' => '',
- );
+ ];
}
elseif (!is_array($info['prefix'])) {
// Transform the flat form into an array form.
- $info['prefix'] = array(
+ $info['prefix'] = [
'default' => $info['prefix'],
- );
+ ];
}
return $info;
}
@@ -459,11 +459,11 @@ abstract class Database {
if (!isset($info['scheme'], $info['host'], $info['path'])) {
throw new \InvalidArgumentException('Minimum requirement: driver://host/database');
}
- $info += array(
+ $info += [
'user' => '',
'pass' => '',
'fragment' => '',
- );
+ ];
// A SQLite database path with two leading slashes indicates a system path.
// Otherwise the path is relative to the Drupal root.
@@ -474,13 +474,13 @@ abstract class Database {
$info['path'] = $root . '/' . $info['path'];
}
- $database = array(
+ $database = [
'driver' => $info['scheme'],
'username' => $info['user'],
'password' => $info['pass'],
'host' => $info['host'],
'database' => $info['path'],
- );
+ ];
if (isset($info['port'])) {
$database['port'] = $info['port'];
}
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
index fd464388a1e..164f68a947c 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
@@ -67,7 +67,7 @@ class Connection extends DatabaseConnection {
/**
* Constructs a Connection object.
*/
- public function __construct(\PDO $connection, array $connection_options = array()) {
+ public function __construct(\PDO $connection, array $connection_options = []) {
parent::__construct($connection, $connection_options);
// This driver defaults to transaction support, except if explicitly passed FALSE.
@@ -82,7 +82,7 @@ class Connection extends DatabaseConnection {
/**
* {@inheritdoc}
*/
- public function query($query, array $args = array(), $options = array()) {
+ public function query($query, array $args = [], $options = []) {
try {
return parent::query($query, $args, $options);
}
@@ -101,7 +101,7 @@ class Connection extends DatabaseConnection {
/**
* {@inheritdoc}
*/
- public static function open(array &$connection_options = array()) {
+ public static function open(array &$connection_options = []) {
if (isset($connection_options['_dsn_utf8_fallback']) && $connection_options['_dsn_utf8_fallback'] === TRUE) {
// Only used during the installer version check, as a fallback from utf8mb4.
$charset = 'utf8';
@@ -125,10 +125,10 @@ class Connection extends DatabaseConnection {
$dsn .= ';dbname=' . $connection_options['database'];
}
// Allow PDO options to be overridden.
- $connection_options += array(
- 'pdo' => array(),
- );
- $connection_options['pdo'] += array(
+ $connection_options += [
+ 'pdo' => [],
+ ];
+ $connection_options['pdo'] += [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
// So we don't have to mess around with cursors and unbuffered queries by default.
\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE,
@@ -138,7 +138,7 @@ class Connection extends DatabaseConnection {
\PDO::MYSQL_ATTR_FOUND_ROWS => TRUE,
// Because MySQL's prepared statements skip the query cache, because it's dumb.
\PDO::ATTR_EMULATE_PREPARES => TRUE,
- );
+ ];
if (defined('\PDO::MYSQL_ATTR_MULTI_STATEMENTS')) {
// An added connection option in PHP 5.5.21 to optionally limit SQL to a
// single statement like mysqli.
@@ -176,12 +176,12 @@ class Connection extends DatabaseConnection {
// https://www.drupal.org/node/344575 for further discussion. Also, as MySQL
// 5.5 changed the meaning of TRADITIONAL we need to spell out the modes one
// by one.
- $connection_options += array(
- 'init_commands' => array(),
- );
- $connection_options['init_commands'] += array(
+ $connection_options += [
+ 'init_commands' => [],
+ ];
+ $connection_options['init_commands'] += [
'sql_mode' => "SET sql_mode = 'ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,ONLY_FULL_GROUP_BY'",
- );
+ ];
// Execute initial commands.
foreach ($connection_options['init_commands'] as $sql) {
$pdo->exec($sql);
@@ -212,11 +212,11 @@ class Connection extends DatabaseConnection {
}
}
- public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
+ public function queryRange($query, $from, $count, array $args = [], array $options = []) {
return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options);
}
- public function queryTemporary($query, array $args = array(), array $options = array()) {
+ public function queryTemporary($query, array $args = [], array $options = []) {
$tablename = $this->generateTemporaryTableName();
$this->query('CREATE TEMPORARY TABLE {' . $tablename . '} Engine=MEMORY ' . $query, $args, $options);
return $tablename;
@@ -258,7 +258,7 @@ class Connection extends DatabaseConnection {
}
public function nextId($existing_id = 0) {
- $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID));
+ $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', [], ['return' => Database::RETURN_INSERT_ID]);
// This should only happen after an import or similar event.
if ($existing_id >= $new_id) {
// If we INSERT a value manually into the sequences table, on the next
@@ -268,8 +268,8 @@ class Connection extends DatabaseConnection {
// other than duplicate keys. Instead, we use INSERT ... ON DUPLICATE KEY
// UPDATE in such a way that the UPDATE does not do anything. This way,
// duplicate keys do not generate errors but everything else does.
- $this->query('INSERT INTO {sequences} (value) VALUES (:value) ON DUPLICATE KEY UPDATE value = value', array(':value' => $existing_id));
- $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID));
+ $this->query('INSERT INTO {sequences} (value) VALUES (:value) ON DUPLICATE KEY UPDATE value = value', [':value' => $existing_id]);
+ $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', [], ['return' => Database::RETURN_INSERT_ID]);
}
$this->needsCleanup = TRUE;
return $new_id;
@@ -287,7 +287,7 @@ class Connection extends DatabaseConnection {
try {
$max_id = $this->query('SELECT MAX(value) FROM {sequences}')->fetchField();
// We know we are using MySQL here, no need for the slower db_delete().
- $this->query('DELETE FROM {sequences} WHERE value < :value', array(':value' => $max_id));
+ $this->query('DELETE FROM {sequences} WHERE value < :value', [':value' => $max_id]);
}
// During testing, this function is called from shutdown with the
// simpletest prefix stored in $this->connection, and those tables are gone
@@ -333,7 +333,7 @@ class Connection extends DatabaseConnection {
if ($e->getPrevious()->errorInfo[1] == '1305') {
// If one SAVEPOINT was released automatically, then all were.
// Therefore, clean the transaction stack.
- $this->transactionLayers = array();
+ $this->transactionLayers = [];
// We also have to explain to PDO that the transaction stack has
// been cleaned-up.
$this->connection->commit();
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php b/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php
index 213eb83e6e8..8b7c602e872 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php
@@ -18,7 +18,7 @@ class Insert extends QueryInsert {
// pass it back, as any remaining options are irrelevant.
if (empty($this->fromQuery)) {
$max_placeholder = 0;
- $values = array();
+ $values = [];
foreach ($this->insertValues as $insert_values) {
foreach ($insert_values as $value) {
$values[':db_insert_placeholder_' . $max_placeholder++] = $value;
@@ -32,7 +32,7 @@ class Insert extends QueryInsert {
$last_insert_id = $this->connection->query((string) $this, $values, $this->queryOptions);
// Re-initialize the values array so that we can re-use this query.
- $this->insertValues = array();
+ $this->insertValues = [];
return $last_insert_id;
}
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
index 40a589c1218..b19af64cb46 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
@@ -33,10 +33,10 @@ class Tasks extends InstallTasks {
* Constructs a \Drupal\Core\Database\Driver\mysql\Install\Tasks object.
*/
public function __construct() {
- $this->tasks[] = array(
- 'arguments' => array(),
+ $this->tasks[] = [
+ 'arguments' => [],
'function' => 'ensureInnoDbAvailable',
- );
+ ];
}
/**
@@ -67,7 +67,7 @@ class Tasks extends InstallTasks {
catch (\Exception $e) {
// Detect utf8mb4 incompability.
if ($e->getCode() == Connection::UNSUPPORTED_CHARSET || ($e->getCode() == Connection::SQLSTATE_SYNTAX_ERROR && $e->errorInfo[1] == Connection::UNKNOWN_CHARSET)) {
- $this->fail(t('Your MySQL server and PHP MySQL driver must support utf8mb4 character encoding. Make sure to use a database system that supports this (such as MySQL/MariaDB/Percona 5.5.3 and up), and that the utf8mb4 character set is compiled in. See the <a href=":documentation" target="_blank">MySQL documentation</a> for more information.', array(':documentation' => 'https://dev.mysql.com/doc/refman/5.0/en/cannot-initialize-character-set.html')));
+ $this->fail(t('Your MySQL server and PHP MySQL driver must support utf8mb4 character encoding. Make sure to use a database system that supports this (such as MySQL/MariaDB/Percona 5.5.3 and up), and that the utf8mb4 character set is compiled in. See the <a href=":documentation" target="_blank">MySQL documentation</a> for more information.', [':documentation' => 'https://dev.mysql.com/doc/refman/5.0/en/cannot-initialize-character-set.html']));
$info = Database::getConnectionInfo();
$info_copy = $info;
// Set a flag to fall back to utf8. Note: this flag should only be
@@ -112,13 +112,13 @@ class Tasks extends InstallTasks {
catch (DatabaseNotFoundException $e) {
// Still no dice; probably a permission issue. Raise the error to the
// installer.
- $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
+ $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', ['%database' => $database, '%error' => $e->getMessage()]));
}
}
else {
// Database connection failed for some other reason than the database
// not existing.
- $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist or does the database user have sufficient privileges to create the database?</li><li>Have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
+ $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist or does the database user have sufficient privileges to create the database?</li><li>Have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', ['%error' => $e->getMessage()]));
return FALSE;
}
}
@@ -159,13 +159,13 @@ class Tasks extends InstallTasks {
// The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
$version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
if (version_compare($version, self::MYSQLND_MINIMUM_VERSION, '<')) {
- $this->fail(t("The MySQLnd driver version %version is less than the minimum required version. Upgrade to MySQLnd version %mysqlnd_minimum_version or up, or alternatively switch mysql drivers to libmysqlclient version %libmysqlclient_minimum_version or up.", array('%version' => $version, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION)));
+ $this->fail(t("The MySQLnd driver version %version is less than the minimum required version. Upgrade to MySQLnd version %mysqlnd_minimum_version or up, or alternatively switch mysql drivers to libmysqlclient version %libmysqlclient_minimum_version or up.", ['%version' => $version, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION]));
}
}
else {
// The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
if (version_compare($version, self::LIBMYSQLCLIENT_MINIMUM_VERSION, '<')) {
- $this->fail(t("The libmysqlclient driver version %version is less than the minimum required version. Upgrade to libmysqlclient version %libmysqlclient_minimum_version or up, or alternatively switch mysql drivers to MySQLnd version %mysqlnd_minimum_version or up.", array('%version' => $version, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION)));
+ $this->fail(t("The libmysqlclient driver version %version is less than the minimum required version. Upgrade to libmysqlclient version %libmysqlclient_minimum_version or up, or alternatively switch mysql drivers to MySQLnd version %mysqlnd_minimum_version or up.", ['%version' => $version, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION]));
}
}
}
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
index c952630d9b7..5dcd487976b 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
@@ -33,14 +33,14 @@ class Schema extends DatabaseSchema {
* @var array
* List of MySQL string types.
*/
- protected $mysqlStringTypes = array(
+ protected $mysqlStringTypes = [
'VARCHAR',
'CHAR',
'TINYTEXT',
'MEDIUMTEXT',
'LONGTEXT',
'TEXT',
- );
+ ];
/**
* Get information about the table and database name from the prefix.
@@ -49,7 +49,7 @@ class Schema extends DatabaseSchema {
* A keyed array with information about the database, table name and prefix.
*/
protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
- $info = array('prefix' => $this->connection->tablePrefix($table));
+ $info = ['prefix' => $this->connection->tablePrefix($table)];
if ($add_prefix) {
$table = $info['prefix'] . $table;
}
@@ -95,10 +95,10 @@ class Schema extends DatabaseSchema {
$info = $this->connection->getConnectionOptions();
// Provide defaults if needed.
- $table += array(
+ $table += [
'mysql_engine' => 'InnoDB',
'mysql_character_set' => 'utf8mb4',
- );
+ ];
$sql = "CREATE TABLE {" . $name . "} (\n";
@@ -130,7 +130,7 @@ class Schema extends DatabaseSchema {
$sql .= ' COMMENT ' . $this->prepareComment($table['description'], self::COMMENT_MAX_TABLE);
}
- return array($sql);
+ return [$sql];
}
/**
@@ -231,7 +231,7 @@ class Schema extends DatabaseSchema {
// it much easier for modules (such as schema.module) to map
// database types back into schema types.
// $map does not use drupal_static as its value never changes.
- static $map = array(
+ static $map = [
'varchar_ascii:normal' => 'VARCHAR',
'varchar:normal' => 'VARCHAR',
@@ -265,12 +265,12 @@ class Schema extends DatabaseSchema {
'blob:big' => 'LONGBLOB',
'blob:normal' => 'BLOB',
- );
+ ];
return $map;
}
protected function createKeysSql($spec) {
- $keys = array();
+ $keys = [];
if (!empty($spec['primary key'])) {
$keys[] = 'PRIMARY KEY (' . $this->createKeySql($spec['primary key']) . ')';
@@ -349,12 +349,12 @@ class Schema extends DatabaseSchema {
}
}
else {
- $index = array($index, 191);
+ $index = [$index, 191];
}
}
protected function createKeySql($fields) {
- $return = array();
+ $return = [];
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = '`' . $field[0] . '`(' . $field[1] . ')';
@@ -368,10 +368,10 @@ class Schema extends DatabaseSchema {
public function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name]));
}
if ($this->tableExists($new_name)) {
- throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name)));
+ throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name]));
}
$info = $this->getPrefixInfo($new_name);
@@ -387,12 +387,12 @@ class Schema extends DatabaseSchema {
return TRUE;
}
- public function addField($table, $field, $spec, $keys_new = array()) {
+ public function addField($table, $field, $spec, $keys_new = []) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table]));
}
if ($this->fieldExists($table, $field)) {
- throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table)));
+ throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table]));
}
$fixnull = FALSE;
@@ -408,7 +408,7 @@ class Schema extends DatabaseSchema {
$this->connection->query($query);
if (isset($spec['initial'])) {
$this->connection->update($table)
- ->fields(array($field => $spec['initial']))
+ ->fields([$field => $spec['initial']])
->execute();
}
if (isset($spec['initial_from_field'])) {
@@ -433,7 +433,7 @@ class Schema extends DatabaseSchema {
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $this->escapeDefaultValue($default));
@@ -441,7 +441,7 @@ class Schema extends DatabaseSchema {
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT');
@@ -456,10 +456,10 @@ class Schema extends DatabaseSchema {
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table]));
}
if ($this->indexExists($table, 'PRIMARY')) {
- throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table)));
+ throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table]));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
@@ -476,10 +476,10 @@ class Schema extends DatabaseSchema {
public function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name]));
}
if ($this->indexExists($table, $name)) {
- throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name]));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')');
@@ -499,10 +499,10 @@ class Schema extends DatabaseSchema {
*/
public function addIndex($table, $name, $fields, array $spec) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name]));
}
if ($this->indexExists($table, $name)) {
- throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name]));
}
$spec['indexes'][$name] = $fields;
@@ -520,12 +520,12 @@ class Schema extends DatabaseSchema {
return TRUE;
}
- public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
+ public function changeField($table, $field, $field_new, $spec, $keys_new = []) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field]));
}
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
- throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new)));
+ throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new]));
}
$sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec));
@@ -542,7 +542,7 @@ class Schema extends DatabaseSchema {
$comment = Unicode::truncate($this->connection->prefixTables($comment), $length, TRUE, TRUE);
}
// Remove semicolons to avoid triggering multi-statement check.
- $comment = strtr($comment, array(';' => '.'));
+ $comment = strtr($comment, [';' => '.']);
return $this->connection->quote($comment);
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
index 59f3bd5a49b..3769e548590 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
@@ -96,7 +96,7 @@ class Connection extends DatabaseConnection {
/**
* {@inheritdoc}
*/
- public static function open(array &$connection_options = array()) {
+ public static function open(array &$connection_options = []) {
// Default to TCP connection on port 5432.
if (empty($connection_options['port'])) {
$connection_options['port'] = 5432;
@@ -120,10 +120,10 @@ class Connection extends DatabaseConnection {
$dsn = 'pgsql:host=' . $connection_options['host'] . ' dbname=' . $connection_options['database'] . ' port=' . $connection_options['port'];
// Allow PDO options to be overridden.
- $connection_options += array(
- 'pdo' => array(),
- );
- $connection_options['pdo'] += array(
+ $connection_options += [
+ 'pdo' => [],
+ ];
+ $connection_options['pdo'] += [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
// Prepared statements are most effective for performance when queries
// are recycled (used several times). However, if they are not re-used,
@@ -134,7 +134,7 @@ class Connection extends DatabaseConnection {
\PDO::ATTR_EMULATE_PREPARES => TRUE,
// Convert numeric values to strings when fetching.
\PDO::ATTR_STRINGIFY_FETCHES => TRUE,
- );
+ ];
try {
$pdo = new \PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
@@ -157,7 +157,7 @@ class Connection extends DatabaseConnection {
/**
* {@inheritdoc}
*/
- public function query($query, array $args = array(), $options = array()) {
+ public function query($query, array $args = [], $options = []) {
$options += $this->defaultOptions();
// The PDO PostgreSQL driver has a bug which doesn't type cast booleans
@@ -211,11 +211,11 @@ class Connection extends DatabaseConnection {
return parent::prepareQuery(preg_replace('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE|~\*) /i', ' ${1}::text ${2} ', $query));
}
- public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
+ public function queryRange($query, $from, $count, array $args = [], array $options = []) {
return $this->query($query . ' LIMIT ' . (int) $count . ' OFFSET ' . (int) $from, $args, $options);
}
- public function queryTemporary($query, array $args = array(), array $options = array()) {
+ public function queryTemporary($query, array $args = [], array $options = []) {
$tablename = $this->generateTemporaryTableName();
$this->query('CREATE TEMPORARY TABLE {' . $tablename . '} AS ' . $query, $args, $options);
return $tablename;
@@ -441,7 +441,7 @@ class Connection extends DatabaseConnection {
/**
* {@inheritdoc}
*/
- public function upsert($table, array $options = array()) {
+ public function upsert($table, array $options = []) {
// Use the (faster) native Upsert implementation for PostgreSQL >= 9.5.
if (version_compare($this->version(), '9.5', '>=')) {
$class = $this->getDriverClass('NativeUpsert');
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php
index 6b9be78ee62..45c7a47ea66 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php
@@ -26,7 +26,7 @@ class Insert extends QueryInsert {
$table_information = $this->connection->schema()->queryTableInformation($this->table);
$max_placeholder = 0;
- $blobs = array();
+ $blobs = [];
$blob_count = 0;
foreach ($this->insertValues as $insert_values) {
foreach ($this->insertFields as $idx => $field) {
@@ -66,7 +66,7 @@ class Insert extends QueryInsert {
// used twice. However, trying to insert a value into a serial
// column should only be done in very rare cases and is not thread
// safe by definition.
- $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", array(':serial_value' => (int)$serial_value));
+ $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int)$serial_value]);
}
}
}
@@ -103,10 +103,10 @@ class Insert extends QueryInsert {
try {
// Only use the returned last_insert_id if it is not already set.
if (!empty($last_insert_id)) {
- $this->connection->query($stmt, array(), $options);
+ $this->connection->query($stmt, [], $options);
}
else {
- $last_insert_id = $this->connection->query($stmt, array(), $options);
+ $last_insert_id = $this->connection->query($stmt, [], $options);
}
$this->connection->releaseSavepoint();
}
@@ -116,7 +116,7 @@ class Insert extends QueryInsert {
}
// Re-initialize the values array so that we can re-use this query.
- $this->insertValues = array();
+ $this->insertValues = [];
return $last_insert_id;
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php
index 77e0a47538e..33579de8e13 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php
@@ -20,22 +20,22 @@ class Tasks extends InstallTasks {
* Constructs a \Drupal\Core\Database\Driver\pgsql\Install\Tasks object.
*/
public function __construct() {
- $this->tasks[] = array(
+ $this->tasks[] = [
'function' => 'checkEncoding',
- 'arguments' => array(),
- );
- $this->tasks[] = array(
+ 'arguments' => [],
+ ];
+ $this->tasks[] = [
'function' => 'checkBinaryOutput',
- 'arguments' => array(),
- );
- $this->tasks[] = array(
+ 'arguments' => [],
+ ];
+ $this->tasks[] = [
'function' => 'checkStandardConformingStrings',
- 'arguments' => array(),
- );
- $this->tasks[] = array(
+ 'arguments' => [],
+ ];
+ $this->tasks[] = [
'function' => 'initializeDatabase',
- 'arguments' => array(),
- );
+ 'arguments' => [],
+ ];
}
/**
@@ -94,13 +94,13 @@ class Tasks extends InstallTasks {
catch (DatabaseNotFoundException $e) {
// Still no dice; probably a permission issue. Raise the error to the
// installer.
- $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
+ $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', ['%database' => $database, '%error' => $e->getMessage()]));
}
}
else {
// Database connection failed for some other reason than the database
// not existing.
- $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
+ $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', ['%error' => $e->getMessage()]));
return FALSE;
}
}
@@ -116,10 +116,10 @@ class Tasks extends InstallTasks {
$this->pass(t('Database is encoded in UTF-8'));
}
else {
- $this->fail(t('The %driver database must use %encoding encoding to work with Drupal. Recreate the database with %encoding encoding. See <a href="INSTALL.pgsql.txt">INSTALL.pgsql.txt</a> for more details.', array(
+ $this->fail(t('The %driver database must use %encoding encoding to work with Drupal. Recreate the database with %encoding encoding. See <a href="INSTALL.pgsql.txt">INSTALL.pgsql.txt</a> for more details.', [
'%encoding' => 'UTF8',
'%driver' => $this->name(),
- )));
+ ]));
}
}
catch (\Exception $e) {
@@ -161,12 +161,12 @@ class Tasks extends InstallTasks {
// Recheck, if it fails, finally just rely on the end user to do the
// right thing.
if (!$this->checkBinaryOutputSuccess()) {
- $replacements = array(
+ $replacements = [
'%setting' => 'bytea_output',
'%current_value' => 'hex',
'%needed_value' => 'escape',
'@query' => $query,
- );
+ ];
$this->fail(t("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: <code>@query</code>", $replacements));
}
}
@@ -214,12 +214,12 @@ class Tasks extends InstallTasks {
// Recheck, if it fails, finally just rely on the end user to do the
// right thing.
if (!$this->checkStandardConformingStringsSuccess()) {
- $replacements = array(
+ $replacements = [
'%setting' => 'standard_conforming_strings',
'%current_value' => 'off',
'%needed_value' => 'on',
'@query' => $query,
- );
+ ];
$this->fail(t("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: <code>@query</code>", $replacements));
}
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php
index 23c026429a7..8cb2ce77607 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php
@@ -60,7 +60,7 @@ class NativeUpsert extends QueryUpsert {
// used twice. However, trying to insert a value into a serial
// column should only be done in very rare cases and is not thread
// safe by definition.
- $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", array(':serial_value' => (int)$serial_value));
+ $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int)$serial_value]);
}
}
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index 4a5f4044a25..19efe50c0b2 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -26,7 +26,7 @@ class Schema extends DatabaseSchema {
* @see \Drupal\Core\Database\Driver\pgsql\Schema::queryTableInformation()
* @var array
*/
- protected $tableInformation = array();
+ protected $tableInformation = [];
/**
* The maximum allowed length for index, primary key and constraint names.
@@ -108,10 +108,10 @@ class Schema extends DatabaseSchema {
}
if (!isset($this->tableInformation[$key])) {
- $table_information = (object) array(
- 'blob_fields' => array(),
- 'sequences' => array(),
- );
+ $table_information = (object) [
+ 'blob_fields' => [],
+ 'sequences' => [],
+ ];
$this->connection->addSavepoint();
try {
@@ -215,11 +215,11 @@ EOD;
$this->connection->addSavepoint();
try {
- $checks = $this->connection->query("SELECT conname FROM pg_class cl INNER JOIN pg_constraint co ON co.conrelid = cl.oid INNER JOIN pg_attribute attr ON attr.attrelid = cl.oid AND attr.attnum = ANY (co.conkey) INNER JOIN pg_namespace ns ON cl.relnamespace = ns.oid WHERE co.contype = 'c' AND ns.nspname = :schema AND cl.relname = :table AND attr.attname = :column", array(
+ $checks = $this->connection->query("SELECT conname FROM pg_class cl INNER JOIN pg_constraint co ON co.conrelid = cl.oid INNER JOIN pg_attribute attr ON attr.attrelid = cl.oid AND attr.attnum = ANY (co.conkey) INNER JOIN pg_namespace ns ON cl.relnamespace = ns.oid WHERE co.contype = 'c' AND ns.nspname = :schema AND cl.relname = :table AND attr.attname = :column", [
':schema' => $schema,
':table' => $table_name,
':column' => $field,
- ));
+ ]);
}
catch (\Exception $e) {
$this->connection->rollbackSavepoint();
@@ -244,12 +244,12 @@ EOD;
* An array of SQL statements to create the table.
*/
protected function createTableSql($name, $table) {
- $sql_fields = array();
+ $sql_fields = [];
foreach ($table['fields'] as $field_name => $field) {
$sql_fields[] = $this->createFieldSql($field_name, $this->processField($field));
}
- $sql_keys = array();
+ $sql_keys = [];
if (isset($table['primary key']) && is_array($table['primary key'])) {
$sql_keys[] = 'CONSTRAINT ' . $this->ensureIdentifiersLength($name, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($table['primary key']) . ')';
}
@@ -309,7 +309,7 @@ EOD;
unset($spec['not null']);
}
- if (in_array($spec['pgsql_type'], array('varchar', 'character')) && isset($spec['length'])) {
+ if (in_array($spec['pgsql_type'], ['varchar', 'character']) && isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
@@ -391,7 +391,7 @@ EOD;
// it much easier for modules (such as schema.module) to map
// database types back into schema types.
// $map does not use drupal_static as its value never changes.
- static $map = array(
+ static $map = [
'varchar_ascii:normal' => 'varchar',
'varchar:normal' => 'varchar',
@@ -425,12 +425,12 @@ EOD;
'serial:medium' => 'serial',
'serial:big' => 'bigserial',
'serial:normal' => 'serial',
- );
+ ];
return $map;
}
protected function _createKeySql($fields) {
- $return = array();
+ $return = [];
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = 'substr(' . $field[0] . ', 1, ' . $field[1] . ')';
@@ -450,7 +450,7 @@ EOD;
* key length defined in the schema is ignored.
*/
protected function createPrimaryKeySql($fields) {
- $return = array();
+ $return = [];
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = '"' . $field[0] . '"';
@@ -468,24 +468,24 @@ EOD;
public function tableExists($table) {
$prefixInfo = $this->getPrefixInfo($table, TRUE);
- return (bool) $this->connection->query("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table", array(':schema' => $prefixInfo['schema'], ':table' => $prefixInfo['table']))->fetchField();
+ return (bool) $this->connection->query("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table", [':schema' => $prefixInfo['schema'], ':table' => $prefixInfo['table']])->fetchField();
}
function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name]));
}
if ($this->tableExists($new_name)) {
- throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name)));
+ throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name]));
}
// Get the schema and tablename for the old table.
$old_full_name = $this->connection->prefixTables('{' . $table . '}');
- list($old_schema, $old_table_name) = strpos($old_full_name, '.') ? explode('.', $old_full_name) : array('public', $old_full_name);
+ list($old_schema, $old_table_name) = strpos($old_full_name, '.') ? explode('.', $old_full_name) : ['public', $old_full_name];
// Index names and constraint names are global in PostgreSQL, so we need to
// rename them when renaming the table.
- $indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', array(':schema' => $old_schema, ':table' => $old_table_name));
+ $indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', [':schema' => $old_schema, ':table' => $old_table_name]);
foreach ($indexes as $index) {
// Get the index type by suffix, e.g. idx/key/pkey
@@ -535,12 +535,12 @@ EOD;
return TRUE;
}
- public function addField($table, $field, $spec, $new_keys = array()) {
+ public function addField($table, $field, $spec, $new_keys = []) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table]));
}
if ($this->fieldExists($table, $field)) {
- throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table)));
+ throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table]));
}
$fixnull = FALSE;
@@ -553,7 +553,7 @@ EOD;
$this->connection->query($query);
if (isset($spec['initial'])) {
$this->connection->update($table)
- ->fields(array($field => $spec['initial']))
+ ->fields([$field => $spec['initial']])
->execute();
}
if (isset($spec['initial_from_field'])) {
@@ -586,7 +586,7 @@ EOD;
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
}
$default = $this->escapeDefaultValue($default);
@@ -596,7 +596,7 @@ EOD;
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" DROP DEFAULT');
@@ -644,10 +644,10 @@ EOD;
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table]));
}
if ($this->constraintExists($table, 'pkey')) {
- throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table)));
+ throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table]));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT ' . $this->ensureIdentifiersLength($table, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($fields) . ')');
@@ -666,10 +666,10 @@ EOD;
function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name]));
}
if ($this->constraintExists($table, $name . '__key')) {
- throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name]));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT ' . $this->ensureIdentifiersLength($table, $name, 'key') . ' UNIQUE (' . implode(',', $fields) . ')');
@@ -691,10 +691,10 @@ EOD;
*/
public function addIndex($table, $name, $fields, array $spec) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name]));
}
if ($this->indexExists($table, $name)) {
- throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name]));
}
$this->connection->query($this->_createIndexSql($table, $name, $fields));
@@ -711,12 +711,12 @@ EOD;
return TRUE;
}
- public function changeField($table, $field, $field_new, $spec, $new_keys = array()) {
+ public function changeField($table, $field, $field_new, $spec, $new_keys = []) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field]));
}
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
- throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new)));
+ throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new]));
}
$spec = $this->processField($spec);
@@ -724,14 +724,14 @@ EOD;
// Type 'serial' is known to PostgreSQL, but only during table creation,
// not when altering. Because of that, we create it here as an 'int'. After
// we create it we manually re-apply the sequence.
- if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) {
+ if (in_array($spec['pgsql_type'], ['serial', 'bigserial'])) {
$field_def = 'int';
}
else {
$field_def = $spec['pgsql_type'];
}
- if (in_array($spec['pgsql_type'], array('varchar', 'character', 'text')) && isset($spec['length'])) {
+ if (in_array($spec['pgsql_type'], ['varchar', 'character', 'text']) && isset($spec['length'])) {
$field_def .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
@@ -782,7 +782,7 @@ EOD;
$this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" ' . $nullaction);
}
- if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) {
+ if (in_array($spec['pgsql_type'], ['serial', 'bigserial'])) {
// Type "serial" is known to PostgreSQL, but *only* during table creation,
// not when altering. Because of that, the sequence needs to be created
// and initialized by hand.
@@ -852,10 +852,10 @@ EOD;
$info = $this->getPrefixInfo($table);
// Don't use {} around pg_class, pg_attribute tables.
if (isset($column)) {
- return $this->connection->query('SELECT col_description(oid, attnum) FROM pg_class, pg_attribute WHERE attrelid = oid AND relname = ? AND attname = ?', array($info['table'], $column))->fetchField();
+ return $this->connection->query('SELECT col_description(oid, attnum) FROM pg_class, pg_attribute WHERE attrelid = oid AND relname = ? AND attname = ?', [$info['table'], $column])->fetchField();
}
else {
- return $this->connection->query('SELECT obj_description(oid, ?) FROM pg_class WHERE relname = ?', array('pg_class', $info['table']))->fetchField();
+ return $this->connection->query('SELECT obj_description(oid, ?) FROM pg_class WHERE relname = ?', ['pg_class', $info['table']])->fetchField();
}
}
@@ -872,7 +872,7 @@ EOD;
protected function hashBase64($data) {
$hash = base64_encode(hash('sha256', $data, TRUE));
// Modify the hash so it's safe to use in PostgreSQL identifiers.
- return strtr($hash, array('+' => '_', '/' => '_', '=' => ''));
+ return strtr($hash, ['+' => '_', '/' => '_', '=' => '']);
}
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php
index 3214b332c3b..e76cb0f9522 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php
@@ -114,7 +114,7 @@ class Select extends QuerySelect {
/**
* {@inheritdoc}
*/
- public function addExpression($expression, $alias = NULL, $arguments = array()) {
+ public function addExpression($expression, $alias = NULL, $arguments = []) {
if (empty($alias)) {
$alias = 'expression';
}
@@ -127,11 +127,11 @@ class Select extends QuerySelect {
}
$alias = $alias_candidate;
- $this->expressions[$alias] = array(
+ $this->expressions[$alias] = [
'expression' => $expression,
'alias' => $this->connection->escapeAlias($alias_candidate),
'arguments' => $arguments,
- );
+ ];
return $alias;
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php
index f6319523aa5..e937f6c8eac 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php
@@ -13,7 +13,7 @@ class Update extends QueryUpdate {
public function execute() {
$max_placeholder = 0;
- $blobs = array();
+ $blobs = [];
$blob_count = 0;
// Because we filter $fields the same way here and in __toString(), the
@@ -75,7 +75,7 @@ class Update extends QueryUpdate {
$this->connection->addSavepoint();
try {
- $result = $this->connection->query($stmt, array(), $options);
+ $result = $this->connection->query($stmt, [], $options);
$this->connection->releaseSavepoint();
return $result;
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php
index 267a8c9ca95..52e077a179c 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php
@@ -18,9 +18,9 @@ class Upsert extends QueryUpsert {
}
// Default options for upsert queries.
- $this->queryOptions += array(
+ $this->queryOptions += [
'throw_exception' => TRUE,
- );
+ ];
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
@@ -66,7 +66,7 @@ class Upsert extends QueryUpsert {
}
// Re-initialize the values array so that we can re-use this query.
- $this->insertValues = array();
+ $this->insertValues = [];
// Transaction commits here where $transaction looses scope.
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
index e71b74dbe9b..a14a83f0778 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
@@ -41,7 +41,7 @@ class Connection extends DatabaseConnection {
*
* @var array
*/
- protected $attachedDatabases = array();
+ protected $attachedDatabases = [];
/**
* Whether or not a table has been dropped this request: the destructor will
@@ -82,10 +82,10 @@ class Connection extends DatabaseConnection {
// In memory database use ':memory:' as database name. According to
// http://www.sqlite.org/inmemorydb.html it will open a unique
// database so attaching it twice is not a problem.
- $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'], ':prefix' => $prefix));
+ $this->query('ATTACH DATABASE :database AS :prefix', [':database' => $connection_options['database'], ':prefix' => $prefix]);
}
else {
- $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix));
+ $this->query('ATTACH DATABASE :database AS :prefix', [':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix]);
}
}
@@ -101,16 +101,16 @@ class Connection extends DatabaseConnection {
/**
* {@inheritdoc}
*/
- public static function open(array &$connection_options = array()) {
+ public static function open(array &$connection_options = []) {
// Allow PDO options to be overridden.
- $connection_options += array(
- 'pdo' => array(),
- );
- $connection_options['pdo'] += array(
+ $connection_options += [
+ 'pdo' => [],
+ ];
+ $connection_options['pdo'] += [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
// Convert numeric values to strings when fetching.
\PDO::ATTR_STRINGIFY_FETCHES => TRUE,
- );
+ ];
try {
$pdo = new \PDO('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']);
@@ -126,37 +126,37 @@ class Connection extends DatabaseConnection {
// Create functions needed by SQLite.
- $pdo->sqliteCreateFunction('if', array(__CLASS__, 'sqlFunctionIf'));
- $pdo->sqliteCreateFunction('greatest', array(__CLASS__, 'sqlFunctionGreatest'));
+ $pdo->sqliteCreateFunction('if', [__CLASS__, 'sqlFunctionIf']);
+ $pdo->sqliteCreateFunction('greatest', [__CLASS__, 'sqlFunctionGreatest']);
$pdo->sqliteCreateFunction('pow', 'pow', 2);
$pdo->sqliteCreateFunction('exp', 'exp', 1);
$pdo->sqliteCreateFunction('length', 'strlen', 1);
$pdo->sqliteCreateFunction('md5', 'md5', 1);
- $pdo->sqliteCreateFunction('concat', array(__CLASS__, 'sqlFunctionConcat'));
- $pdo->sqliteCreateFunction('concat_ws', array(__CLASS__, 'sqlFunctionConcatWs'));
- $pdo->sqliteCreateFunction('substring', array(__CLASS__, 'sqlFunctionSubstring'), 3);
- $pdo->sqliteCreateFunction('substring_index', array(__CLASS__, 'sqlFunctionSubstringIndex'), 3);
- $pdo->sqliteCreateFunction('rand', array(__CLASS__, 'sqlFunctionRand'));
- $pdo->sqliteCreateFunction('regexp', array(__CLASS__, 'sqlFunctionRegexp'));
+ $pdo->sqliteCreateFunction('concat', [__CLASS__, 'sqlFunctionConcat']);
+ $pdo->sqliteCreateFunction('concat_ws', [__CLASS__, 'sqlFunctionConcatWs']);
+ $pdo->sqliteCreateFunction('substring', [__CLASS__, 'sqlFunctionSubstring'], 3);
+ $pdo->sqliteCreateFunction('substring_index', [__CLASS__, 'sqlFunctionSubstringIndex'], 3);
+ $pdo->sqliteCreateFunction('rand', [__CLASS__, 'sqlFunctionRand']);
+ $pdo->sqliteCreateFunction('regexp', [__CLASS__, 'sqlFunctionRegexp']);
// SQLite does not support the LIKE BINARY operator, so we overload the
// non-standard GLOB operator for case-sensitive matching. Another option
// would have been to override another non-standard operator, MATCH, but
// that does not support the NOT keyword prefix.
- $pdo->sqliteCreateFunction('glob', array(__CLASS__, 'sqlFunctionLikeBinary'));
+ $pdo->sqliteCreateFunction('glob', [__CLASS__, 'sqlFunctionLikeBinary']);
// Create a user-space case-insensitive collation with UTF-8 support.
- $pdo->sqliteCreateCollation('NOCASE_UTF8', array('Drupal\Component\Utility\Unicode', 'strcasecmp'));
+ $pdo->sqliteCreateCollation('NOCASE_UTF8', ['Drupal\Component\Utility\Unicode', 'strcasecmp']);
// Set SQLite init_commands if not already defined. Enable the Write-Ahead
// Logging (WAL) for SQLite. See https://www.drupal.org/node/2348137 and
// https://www.sqlite.org/wal.html.
- $connection_options += array(
- 'init_commands' => array(),
- );
- $connection_options['init_commands'] += array(
+ $connection_options += [
+ 'init_commands' => [],
+ ];
+ $connection_options['init_commands'] += [
'wal' => "PRAGMA journal_mode=WAL",
- );
+ ];
// Execute sqlite init_commands.
if (isset($connection_options['init_commands'])) {
@@ -179,7 +179,7 @@ class Connection extends DatabaseConnection {
foreach ($this->attachedDatabases as $prefix) {
// Check if the database is now empty, ignore the internal SQLite tables.
try {
- $count = $this->query('SELECT COUNT(*) FROM ' . $prefix . '.sqlite_master WHERE type = :type AND name NOT LIKE :pattern', array(':type' => 'table', ':pattern' => 'sqlite_%'))->fetchField();
+ $count = $this->query('SELECT COUNT(*) FROM ' . $prefix . '.sqlite_master WHERE type = :type AND name NOT LIKE :pattern', [':type' => 'table', ':pattern' => 'sqlite_%'])->fetchField();
// We can prune the database file if it doesn't have any tables.
if ($count == 0) {
@@ -325,21 +325,21 @@ class Connection extends DatabaseConnection {
// Replace the SQL LIKE wildcard meta-characters with the equivalent regular
// expression meta-characters and escape the delimiter that will be used for
// matching.
- $pattern = str_replace(array('%', '_'), array('.*?', '.'), preg_quote($pattern, '/'));
+ $pattern = str_replace(['%', '_'], ['.*?', '.'], preg_quote($pattern, '/'));
return preg_match('/^' . $pattern . '$/', $subject);
}
/**
* {@inheritdoc}
*/
- public function prepare($statement, array $driver_options = array()) {
+ public function prepare($statement, array $driver_options = []) {
return new Statement($this->connection, $this, $statement, $driver_options);
}
/**
* {@inheritdoc}
*/
- protected function handleQueryException(\PDOException $e, $query, array $args = array(), $options = array()) {
+ protected function handleQueryException(\PDOException $e, $query, array $args = [], $options = []) {
// The database schema might be changed by another process in between the
// time that the statement was prepared and the time the statement was run
// (e.g. usually happens when running tests). In this case, we need to
@@ -353,11 +353,11 @@ class Connection extends DatabaseConnection {
parent::handleQueryException($e, $query, $args, $options);
}
- public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
+ public function queryRange($query, $from, $count, array $args = [], array $options = []) {
return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options);
}
- public function queryTemporary($query, array $args = array(), array $options = array()) {
+ public function queryTemporary($query, array $args = [], array $options = []) {
// Generate a new temporary table name and protect it from prefixing.
// SQLite requires that temporary tables to be non-qualified.
$tablename = $this->generateTemporaryTableName();
@@ -414,13 +414,13 @@ class Connection extends DatabaseConnection {
// wait until this transaction commits. Also, the return value needs to be
// set to RETURN_AFFECTED as if it were a real update() query otherwise it
// is not possible to get the row count properly.
- $affected = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', array(
+ $affected = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', [
':existing_id' => $existing_id,
- ), array('return' => Database::RETURN_AFFECTED));
+ ], ['return' => Database::RETURN_AFFECTED]);
if (!$affected) {
- $this->query('INSERT INTO {sequences} (value) VALUES (:existing_id + 1)', array(
+ $this->query('INSERT INTO {sequences} (value) VALUES (:existing_id + 1)', [
':existing_id' => $existing_id,
- ));
+ ]);
}
// The transaction gets committed when the transaction object gets destroyed
// because it gets out of scope.
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php
index 506e65518ae..0c4fdb668b9 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php
@@ -21,7 +21,7 @@ class Insert extends QueryInsert {
return parent::execute();
}
else {
- return $this->connection->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', array(), $this->queryOptions);
+ return $this->connection->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', [], $this->queryOptions);
}
}
@@ -30,7 +30,7 @@ class Insert extends QueryInsert {
$comments = $this->connection->makeComment($this->comments);
// Produce as many generic placeholders as necessary.
- $placeholders = array();
+ $placeholders = [];
if (!empty($this->insertFields)) {
$placeholders = array_fill(0, count($this->insertFields), '?');
}
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php
index f56b26ce443..b0ea18877ae 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php
@@ -42,7 +42,7 @@ class Tasks extends InstallTasks {
// Make the text more accurate for SQLite.
$form['database']['#title'] = t('Database file');
- $form['database']['#description'] = t('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
+ $form['database']['#description'] = t('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', ['@drupal' => drupal_install_profile_distribution_name()]);
$default_database = \Drupal::service('site.path') . '/files/.ht.sqlite';
$form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
return $form;
@@ -91,13 +91,13 @@ class Tasks extends InstallTasks {
catch (DatabaseNotFoundException $e) {
// Still no dice; probably a permission issue. Raise the error to the
// installer.
- $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
+ $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', ['%database' => $database, '%error' => $e->getMessage()]));
}
}
else {
// Database connection failed for some other reason than the database
// not existing.
- $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
+ $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', ['%error' => $e->getMessage()]));
return FALSE;
}
}
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
index 4b954ed35df..385b8d30f95 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
@@ -26,7 +26,7 @@ class Schema extends DatabaseSchema {
$info = $this->getPrefixInfo($table);
// Don't use {} around sqlite_master table.
- return (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', array(':type' => 'table', ':name' => $info['table']))->fetchField();
+ return (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', [':type' => 'table', ':name' => $info['table']])->fetchField();
}
public function fieldExists($table, $column) {
@@ -45,7 +45,7 @@ class Schema extends DatabaseSchema {
* An array of SQL statements to create the table.
*/
public function createTableSql($name, $table) {
- $sql = array();
+ $sql = [];
$sql[] = "CREATE TABLE {" . $name . "} (\n" . $this->createColumnsSql($name, $table) . "\n)\n";
return array_merge($sql, $this->createIndexSql($name, $table));
}
@@ -54,7 +54,7 @@ class Schema extends DatabaseSchema {
* Build the SQL expression for indexes.
*/
protected function createIndexSql($tablename, $schema) {
- $sql = array();
+ $sql = [];
$info = $this->getPrefixInfo($tablename);
if (!empty($schema['unique keys'])) {
foreach ($schema['unique keys'] as $key => $fields) {
@@ -73,7 +73,7 @@ class Schema extends DatabaseSchema {
* Build the SQL expression for creating columns.
*/
protected function createColumnsSql($tablename, $schema) {
- $sql_array = array();
+ $sql_array = [];
// Add the SQL statement for each field.
foreach ($schema['fields'] as $name => $field) {
@@ -97,7 +97,7 @@ class Schema extends DatabaseSchema {
* Build the SQL expression for keys.
*/
protected function createKeySql($fields) {
- $return = array();
+ $return = [];
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = $field[0];
@@ -163,7 +163,7 @@ class Schema extends DatabaseSchema {
else {
$sql = $name . ' ' . $spec['sqlite_type'];
- if (in_array($spec['sqlite_type'], array('VARCHAR', 'TEXT'))) {
+ if (in_array($spec['sqlite_type'], ['VARCHAR', 'TEXT'])) {
if (isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
@@ -209,7 +209,7 @@ class Schema extends DatabaseSchema {
// it much easier for modules (such as schema.module) to map
// database types back into schema types.
// $map does not use drupal_static as its value never changes.
- static $map = array(
+ static $map = [
'varchar_ascii:normal' => 'VARCHAR',
'varchar:normal' => 'VARCHAR',
@@ -243,16 +243,16 @@ class Schema extends DatabaseSchema {
'blob:big' => 'BLOB',
'blob:normal' => 'BLOB',
- );
+ ];
return $map;
}
public function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name]));
}
if ($this->tableExists($new_name)) {
- throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name)));
+ throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name]));
}
$schema = $this->introspectSchema($table);
@@ -293,12 +293,12 @@ class Schema extends DatabaseSchema {
return TRUE;
}
- public function addField($table, $field, $specification, $keys_new = array()) {
+ public function addField($table, $field, $specification, $keys_new = []) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table]));
}
if ($this->fieldExists($table, $field)) {
- throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table)));
+ throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table]));
}
// SQLite doesn't have a full-featured ALTER TABLE statement. It only
@@ -313,7 +313,7 @@ class Schema extends DatabaseSchema {
// Apply the initial value if set.
if (isset($specification['initial'])) {
$this->connection->update($table)
- ->fields(array($field => $specification['initial']))
+ ->fields([$field => $specification['initial']])
->execute();
}
if (isset($specification['initial_from_field'])) {
@@ -332,20 +332,20 @@ class Schema extends DatabaseSchema {
$new_schema['fields'][$field] = $specification;
// Build the mapping between the old fields and the new fields.
- $mapping = array();
+ $mapping = [];
if (isset($specification['initial'])) {
// If we have a initial value, copy it over.
- $mapping[$field] = array(
+ $mapping[$field] = [
'expression' => ':newfieldinitial',
- 'arguments' => array(':newfieldinitial' => $specification['initial']),
- );
+ 'arguments' => [':newfieldinitial' => $specification['initial']],
+ ];
}
elseif (isset($specification['initial_from_field'])) {
// If we have a initial value, copy it over.
- $mapping[$field] = array(
+ $mapping[$field] = [
'expression' => $specification['initial_from_field'],
'arguments' => [],
- );
+ ];
}
else {
// Else use the default of the field.
@@ -380,7 +380,7 @@ class Schema extends DatabaseSchema {
* - an associative array with two keys 'expression' and 'arguments',
* that will be used as an expression field.
*/
- protected function alterTable($table, $old_schema, $new_schema, array $mapping = array()) {
+ protected function alterTable($table, $old_schema, $new_schema, array $mapping = []) {
$i = 0;
do {
$new_table = $table . '_' . $i++;
@@ -441,12 +441,12 @@ class Schema extends DatabaseSchema {
*/
protected function introspectSchema($table) {
$mapped_fields = array_flip($this->getFieldTypeMap());
- $schema = array(
- 'fields' => array(),
- 'primary key' => array(),
- 'unique keys' => array(),
- 'indexes' => array(),
- );
+ $schema = [
+ 'fields' => [],
+ 'primary key' => [],
+ 'unique keys' => [],
+ 'indexes' => [],
+ ];
$info = $this->getPrefixInfo($table);
$result = $this->connection->query('PRAGMA ' . $info['schema'] . '.table_info(' . $info['table'] . ')');
@@ -461,12 +461,12 @@ class Schema extends DatabaseSchema {
}
if (isset($mapped_fields[$type])) {
list($type, $size) = explode(':', $mapped_fields[$type]);
- $schema['fields'][$row->name] = array(
+ $schema['fields'][$row->name] = [
'type' => $type,
'size' => $size,
'not null' => !empty($row->notnull),
'default' => trim($row->dflt_value, "'"),
- );
+ ];
if ($length) {
$schema['fields'][$row->name]['length'] = $length;
}
@@ -478,14 +478,14 @@ class Schema extends DatabaseSchema {
throw new \Exception("Unable to parse the column type " . $row->type);
}
}
- $indexes = array();
+ $indexes = [];
$result = $this->connection->query('PRAGMA ' . $info['schema'] . '.index_list(' . $info['table'] . ')');
foreach ($result as $row) {
if (strpos($row->name, 'sqlite_autoindex_') !== 0) {
- $indexes[] = array(
+ $indexes[] = [
'schema_key' => $row->unique ? 'unique keys' : 'indexes',
'name' => $row->name,
- );
+ ];
}
}
foreach ($indexes as $index) {
@@ -531,12 +531,12 @@ class Schema extends DatabaseSchema {
return TRUE;
}
- public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
+ public function changeField($table, $field, $field_new, $spec, $keys_new = []) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field]));
}
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
- throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new)));
+ throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new]));
}
$old_schema = $this->introspectSchema($table);
@@ -547,7 +547,7 @@ class Schema extends DatabaseSchema {
$mapping[$field_new] = $field;
}
else {
- $mapping = array();
+ $mapping = [];
}
// Remove the previous definition and swap in the new one.
@@ -556,7 +556,7 @@ class Schema extends DatabaseSchema {
// Map the former indexes to the new column name.
$new_schema['primary key'] = $this->mapKeyDefinition($new_schema['primary key'], $mapping);
- foreach (array('unique keys', 'indexes') as $k) {
+ foreach (['unique keys', 'indexes'] as $k) {
foreach ($new_schema[$k] as &$key_definition) {
$key_definition = $this->mapKeyDefinition($key_definition, $mapping);
}
@@ -566,7 +566,7 @@ class Schema extends DatabaseSchema {
if (isset($keys_new['primary key'])) {
$new_schema['primary key'] = $keys_new['primary key'];
}
- foreach (array('unique keys', 'indexes') as $k) {
+ foreach (['unique keys', 'indexes'] as $k) {
if (!empty($keys_new[$k])) {
$new_schema[$k] = $keys_new[$k] + $new_schema[$k];
}
@@ -601,10 +601,10 @@ class Schema extends DatabaseSchema {
*/
public function addIndex($table, $name, $fields, array $spec) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name]));
}
if ($this->indexExists($table, $name)) {
- throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name]));
}
$schema['indexes'][$name] = $fields;
@@ -633,10 +633,10 @@ class Schema extends DatabaseSchema {
public function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name]));
}
if ($this->indexExists($table, $name)) {
- throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name)));
+ throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name]));
}
$schema['unique keys'][$name] = $fields;
@@ -659,14 +659,14 @@ class Schema extends DatabaseSchema {
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table]));
}
$old_schema = $this->introspectSchema($table);
$new_schema = $old_schema;
if (!empty($new_schema['primary key'])) {
- throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table)));
+ throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table]));
}
$new_schema['primary key'] = $fields;
@@ -688,7 +688,7 @@ class Schema extends DatabaseSchema {
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
}
$old_schema = $this->introspectSchema($table);
@@ -700,7 +700,7 @@ class Schema extends DatabaseSchema {
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
- throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field)));
+ throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
}
$old_schema = $this->introspectSchema($table);
@@ -726,11 +726,11 @@ class Schema extends DatabaseSchema {
// Can't use query placeholders for the schema because the query would
// have to be :prefixsqlite_master, which does not work. We also need to
// ignore the internal SQLite tables.
- $result = $this->connection->query("SELECT name FROM " . $schema . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", array(
+ $result = $this->connection->query("SELECT name FROM " . $schema . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [
':type' => 'table',
':table_name' => $table_expression,
':pattern' => 'sqlite_%',
- ));
+ ]);
$tables += $result->fetchAllKeyed(0, 0);
}
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
index adc537cc345..5610d071ce3 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
@@ -26,13 +26,13 @@ class Statement extends StatementPrefetch implements StatementInterface {
*
* See http://bugs.php.net/bug.php?id=45259 for more details.
*/
- protected function getStatement($query, &$args = array()) {
+ protected function getStatement($query, &$args = []) {
if (count($args)) {
// Check if $args is a simple numeric array.
if (range(0, count($args) - 1) === array_keys($args)) {
// In that case, we have unnamed placeholders.
$count = 0;
- $new_args = array();
+ $new_args = [];
foreach ($args as $value) {
if (is_float($value) || is_int($value)) {
if (is_float($value)) {
@@ -85,7 +85,7 @@ class Statement extends StatementPrefetch implements StatementInterface {
/**
* {@inheritdoc}
*/
- public function execute($args = array(), $options = array()) {
+ public function execute($args = [], $options = []) {
try {
$return = parent::execute($args, $options);
}
@@ -103,7 +103,7 @@ class Statement extends StatementPrefetch implements StatementInterface {
// In some weird cases, SQLite will prefix some column names by the name
// of the table. We post-process the data, by renaming the column names
// using the same convention as MySQL and PostgreSQL.
- $rename_columns = array();
+ $rename_columns = [];
foreach ($this->columnNames as $k => $column) {
// In some SQLite versions, SELECT DISTINCT(field) will return "(field)"
// instead of "field".
diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php
index 28196154989..a2ea41b0d89 100644
--- a/core/lib/Drupal/Core/Database/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
@@ -26,58 +26,58 @@ abstract class Tasks {
* Each value of the tasks array is an associative array defining the function
* to call (optional) and any arguments to be passed to the function.
*/
- protected $tasks = array(
- array(
+ protected $tasks = [
+ [
'function' => 'checkEngineVersion',
- 'arguments' => array(),
- ),
- array(
- 'arguments' => array(
+ 'arguments' => [],
+ ],
+ [
+ 'arguments' => [
'CREATE TABLE {drupal_install_test} (id int NULL)',
'Drupal can use CREATE TABLE database commands.',
'Failed to <strong>CREATE</strong> a test table on your database server with the command %query. The server reports the following message: %error.<p>Are you sure the configured username has the necessary permissions to create tables in the database?</p>',
TRUE,
- ),
- ),
- array(
- 'arguments' => array(
+ ],
+ ],
+ [
+ 'arguments' => [
'INSERT INTO {drupal_install_test} (id) VALUES (1)',
'Drupal can use INSERT database commands.',
'Failed to <strong>INSERT</strong> a value into a test table on your database server. We tried inserting a value with the command %query and the server reported the following error: %error.',
- ),
- ),
- array(
- 'arguments' => array(
+ ],
+ ],
+ [
+ 'arguments' => [
'UPDATE {drupal_install_test} SET id = 2',
'Drupal can use UPDATE database commands.',
'Failed to <strong>UPDATE</strong> a value in a test table on your database server. We tried updating a value with the command %query and the server reported the following error: %error.',
- ),
- ),
- array(
- 'arguments' => array(
+ ],
+ ],
+ [
+ 'arguments' => [
'DELETE FROM {drupal_install_test}',
'Drupal can use DELETE database commands.',
'Failed to <strong>DELETE</strong> a value from a test table on your database server. We tried deleting a value with the command %query and the server reported the following error: %error.',
- ),
- ),
- array(
- 'arguments' => array(
+ ],
+ ],
+ [
+ 'arguments' => [
'DROP TABLE {drupal_install_test}',
'Drupal can use DROP TABLE database commands.',
'Failed to <strong>DROP</strong> a test table from your database server. We tried dropping a table with the command %query and the server reported the following error %error.',
- ),
- ),
- );
+ ],
+ ],
+ ];
/**
* Results from tasks.
*
* @var array
*/
- protected $results = array(
- 'fail' => array(),
- 'pass' => array(),
- );
+ protected $results = [
+ 'fail' => [],
+ 'pass' => [],
+ ];
/**
* Ensure the PDO driver is supported by the version of PHP in use.
@@ -138,12 +138,12 @@ abstract class Tasks {
}
if (method_exists($this, $task['function'])) {
// Returning false is fatal. No other tasks can run.
- if (FALSE === call_user_func_array(array($this, $task['function']), $task['arguments'])) {
+ if (FALSE === call_user_func_array([$this, $task['function']], $task['arguments'])) {
break;
}
}
else {
- $this->fail(t("Failed to run all tasks against the database server. The task %task wasn't found.", array('%task' => $task['function'])));
+ $this->fail(t("Failed to run all tasks against the database server. The task %task wasn't found.", ['%task' => $task['function']]));
}
}
}
@@ -162,7 +162,7 @@ abstract class Tasks {
$this->pass('Drupal can CONNECT to the database ok.');
}
catch (\Exception $e) {
- $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
+ $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', ['%error' => $e->getMessage()]));
return FALSE;
}
return TRUE;
@@ -177,7 +177,7 @@ abstract class Tasks {
$this->pass(t($pass));
}
catch (\Exception $e) {
- $this->fail(t($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name())));
+ $this->fail(t($fail, ['%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name()]));
return !$fatal;
}
}
@@ -188,7 +188,7 @@ abstract class Tasks {
protected function checkEngineVersion() {
// Ensure that the database server has the right version.
if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion(), '<')) {
- $this->fail(t("The database server version %version is less than the minimum required version %minimum_version.", array('%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion())));
+ $this->fail(t("The database server version %version is less than the minimum required version %minimum_version.", ['%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion()]));
}
}
@@ -202,58 +202,58 @@ abstract class Tasks {
* The options form array.
*/
public function getFormOptions(array $database) {
- $form['database'] = array(
+ $form['database'] = [
'#type' => 'textfield',
'#title' => t('Database name'),
'#default_value' => empty($database['database']) ? '' : $database['database'],
'#size' => 45,
'#required' => TRUE,
- '#states' => array(
- 'required' => array(
- ':input[name=driver]' => array('value' => $this->pdoDriver),
- ),
- ),
- );
+ '#states' => [
+ 'required' => [
+ ':input[name=driver]' => ['value' => $this->pdoDriver],
+ ],
+ ],
+ ];
- $form['username'] = array(
+ $form['username'] = [
'#type' => 'textfield',
'#title' => t('Database username'),
'#default_value' => empty($database['username']) ? '' : $database['username'],
'#size' => 45,
'#required' => TRUE,
- '#states' => array(
- 'required' => array(
- ':input[name=driver]' => array('value' => $this->pdoDriver),
- ),
- ),
- );
+ '#states' => [
+ 'required' => [
+ ':input[name=driver]' => ['value' => $this->pdoDriver],
+ ],
+ ],
+ ];
- $form['password'] = array(
+ $form['password'] = [
'#type' => 'password',
'#title' => t('Database password'),
'#default_value' => empty($database['password']) ? '' : $database['password'],
'#required' => FALSE,
'#size' => 45,
- );
+ ];
- $form['advanced_options'] = array(
+ $form['advanced_options'] = [
'#type' => 'details',
'#title' => t('Advanced options'),
'#weight' => 10,
- );
+ ];
$profile = drupal_get_profile();
$db_prefix = ($profile == 'standard') ? 'drupal_' : $profile . '_';
- $form['advanced_options']['prefix'] = array(
+ $form['advanced_options']['prefix'] = [
'#type' => 'textfield',
'#title' => t('Table name prefix'),
'#default_value' => empty($database['prefix']) ? '' : $database['prefix'],
'#size' => 45,
- '#description' => t('If more than one application will be sharing this database, a unique table name prefix – such as %prefix – will prevent collisions.', array('%prefix' => $db_prefix)),
+ '#description' => t('If more than one application will be sharing this database, a unique table name prefix – such as %prefix – will prevent collisions.', ['%prefix' => $db_prefix]),
'#weight' => 10,
- );
+ ];
- $form['advanced_options']['host'] = array(
+ $form['advanced_options']['host'] = [
'#type' => 'textfield',
'#title' => t('Host'),
'#default_value' => empty($database['host']) ? 'localhost' : $database['host'],
@@ -261,15 +261,15 @@ abstract class Tasks {
// Hostnames can be 255 characters long.
'#maxlength' => 255,
'#required' => TRUE,
- );
+ ];
- $form['advanced_options']['port'] = array(
+ $form['advanced_options']['port'] = [
'#type' => 'number',
'#title' => t('Port number'),
'#default_value' => empty($database['port']) ? '' : $database['port'],
'#min' => 0,
'#max' => 65535,
- );
+ ];
return $form;
}
@@ -287,11 +287,11 @@ abstract class Tasks {
* An array of driver configuration errors, keyed by form element name.
*/
public function validateDatabaseSettings($database) {
- $errors = array();
+ $errors = [];
// Verify the table prefix.
if (!empty($database['prefix']) && is_string($database['prefix']) && !preg_match('/^[A-Za-z0-9_.]+$/', $database['prefix'])) {
- $errors[$database['driver'] . '][prefix'] = t('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array('%prefix' => $database['prefix']));
+ $errors[$database['driver'] . '][prefix'] = t('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', ['%prefix' => $database['prefix']]);
}
return $errors;
diff --git a/core/lib/Drupal/Core/Database/Log.php b/core/lib/Drupal/Core/Database/Log.php
index 76c39db296c..bf142c2cded 100644
--- a/core/lib/Drupal/Core/Database/Log.php
+++ b/core/lib/Drupal/Core/Database/Log.php
@@ -29,7 +29,7 @@ class Log {
*
* @var array
*/
- protected $queryLog = array();
+ protected $queryLog = [];
/**
* The connection key for which this object is logging.
@@ -86,7 +86,7 @@ class Log {
* The logging key to empty.
*/
public function clear($logging_key) {
- $this->queryLog[$logging_key] = array();
+ $this->queryLog[$logging_key] = [];
}
/**
@@ -111,13 +111,13 @@ class Log {
*/
public function log(StatementInterface $statement, $args, $time) {
foreach (array_keys($this->queryLog) as $key) {
- $this->queryLog[$key][] = array(
+ $this->queryLog[$key][] = [
'query' => $statement->getQueryString(),
'args' => $args,
'target' => $statement->dbh->getTarget(),
'caller' => $this->findCaller(),
'time' => $time,
- );
+ ];
}
}
@@ -151,15 +151,15 @@ class Log {
$stack[$i]['class'] = '';
}
if (strpos($stack[$i]['class'], __NAMESPACE__) === FALSE && strpos($stack[$i + 1]['function'], 'db_') === FALSE && !empty($stack[$i]['file'])) {
- $stack[$i] += array('file' => '?', 'line' => '?', 'args' => array());
- return array(
+ $stack[$i] += ['file' => '?', 'line' => '?', 'args' => []];
+ return [
'file' => $stack[$i]['file'],
'line' => $stack[$i]['line'],
'function' => $stack[$i + 1]['function'],
'class' => isset($stack[$i + 1]['class']) ? $stack[$i + 1]['class'] : NULL,
'type' => isset($stack[$i + 1]['type']) ? $stack[$i + 1]['type'] : NULL,
'args' => $stack[$i + 1]['args'],
- );
+ ];
}
}
}
diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php
index 52a5700b04e..d04fec58e3c 100644
--- a/core/lib/Drupal/Core/Database/Query/Condition.php
+++ b/core/lib/Drupal/Core/Database/Query/Condition.php
@@ -13,41 +13,41 @@ class Condition implements ConditionInterface, \Countable {
/**
* Provides a map of condition operators to condition operator options.
*/
- protected static $conditionOperatorMap = array(
- 'BETWEEN' => array('delimiter' => ' AND '),
- 'NOT BETWEEN' => array('delimiter' => ' AND '),
- 'IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'),
- 'NOT IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'),
- 'IS NULL' => array('use_value' => FALSE),
- 'IS NOT NULL' => array('use_value' => FALSE),
+ protected static $conditionOperatorMap = [
+ 'BETWEEN' => ['delimiter' => ' AND '],
+ 'NOT BETWEEN' => ['delimiter' => ' AND '],
+ 'IN' => ['delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'],
+ 'NOT IN' => ['delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'],
+ 'IS NULL' => ['use_value' => FALSE],
+ 'IS NOT NULL' => ['use_value' => FALSE],
// Use backslash for escaping wildcard characters.
- 'LIKE' => array('postfix' => " ESCAPE '\\\\'"),
- 'NOT LIKE' => array('postfix' => " ESCAPE '\\\\'"),
+ 'LIKE' => ['postfix' => " ESCAPE '\\\\'"],
+ 'NOT LIKE' => ['postfix' => " ESCAPE '\\\\'"],
// Exists expects an already bracketed subquery as right hand part. Do
// not define additional brackets.
- 'EXISTS' => array(),
- 'NOT EXISTS' => array(),
+ 'EXISTS' => [],
+ 'NOT EXISTS' => [],
// These ones are here for performance reasons.
- '=' => array(),
- '<' => array(),
- '>' => array(),
- '>=' => array(),
- '<=' => array(),
- );
+ '=' => [],
+ '<' => [],
+ '>' => [],
+ '>=' => [],
+ '<=' => [],
+ ];
/**
* Array of conditions.
*
* @var array
*/
- protected $conditions = array();
+ protected $conditions = [];
/**
* Array of arguments.
*
* @var array
*/
- protected $arguments = array();
+ protected $arguments = [];
/**
* Whether the conditions have been changed.
@@ -103,11 +103,11 @@ class Condition implements ConditionInterface, \Countable {
throw new InvalidQueryException(sprintf("Query condition '%s %s ()' cannot be empty.", $field, $operator));
}
- $this->conditions[] = array(
+ $this->conditions[] = [
'field' => $field,
'value' => $value,
'operator' => $operator,
- );
+ ];
$this->changed = TRUE;
@@ -117,12 +117,12 @@ class Condition implements ConditionInterface, \Countable {
/**
* {@inheritdoc}
*/
- public function where($snippet, $args = array()) {
- $this->conditions[] = array(
+ public function where($snippet, $args = []) {
+ $this->conditions[] = [
'field' => $snippet,
'value' => $args,
'operator' => NULL,
- );
+ ];
$this->changed = TRUE;
return $this;
@@ -183,8 +183,8 @@ class Condition implements ConditionInterface, \Countable {
if ($this->changed || isset($this->queryPlaceholderIdentifier) && ($this->queryPlaceholderIdentifier != $queryPlaceholder->uniqueIdentifier())) {
$this->queryPlaceholderIdentifier = $queryPlaceholder->uniqueIdentifier();
- $condition_fragments = array();
- $arguments = array();
+ $condition_fragments = [];
+ $arguments = [];
$conditions = $this->conditions;
$conjunction = $conditions['#conjunction'];
@@ -224,7 +224,7 @@ class Condition implements ConditionInterface, \Countable {
// Process operator.
if ($ignore_operator) {
- $operator = array('operator' => '', 'use_value' => FALSE);
+ $operator = ['operator' => '', 'use_value' => FALSE];
}
else {
// Remove potentially dangerous characters.
@@ -255,15 +255,15 @@ class Condition implements ConditionInterface, \Countable {
if (!isset($operator)) {
$operator = $this->mapConditionOperator($condition['operator']);
}
- $operator += array('operator' => $condition['operator']);
+ $operator += ['operator' => $condition['operator']];
}
// Add defaults.
- $operator += array(
+ $operator += [
'prefix' => '',
'postfix' => '',
'delimiter' => '',
'use_value' => TRUE,
- );
+ ];
$operator_fragment = $operator['operator'];
// Process value.
@@ -279,10 +279,10 @@ class Condition implements ConditionInterface, \Countable {
$operator['prefix'] = '';
$operator['postfix'] = '';
}
- $condition['value'] = array($condition['value']);
+ $condition['value'] = [$condition['value']];
}
// Process all individual values.
- $value_fragment = array();
+ $value_fragment = [];
foreach ($condition['value'] as $value) {
if ($value instanceof SelectInterface) {
// Right hand part is a subquery. Compile, put brackets around it
@@ -303,7 +303,7 @@ class Condition implements ConditionInterface, \Countable {
}
// Concatenate the left hand part, operator and right hand part.
- $condition_fragments[] = trim(implode(' ', array($field_fragment, $operator_fragment, $value_fragment)));
+ $condition_fragments[] = trim(implode(' ', [$field_fragment, $operator_fragment, $value_fragment]));
}
// Concatenate all conditions using the conjunction and brackets around
@@ -377,10 +377,10 @@ class Condition implements ConditionInterface, \Countable {
// We need to upper case because PHP index matches are case sensitive but
// do not need the more expensive Unicode::strtoupper() because SQL statements are ASCII.
$operator = strtoupper($operator);
- $return = isset(static::$conditionOperatorMap[$operator]) ? static::$conditionOperatorMap[$operator] : array();
+ $return = isset(static::$conditionOperatorMap[$operator]) ? static::$conditionOperatorMap[$operator] : [];
}
- $return += array('operator' => $operator);
+ $return += ['operator' => $operator];
return $return;
}
diff --git a/core/lib/Drupal/Core/Database/Query/ConditionInterface.php b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php
index 0c82a10fd3e..aa5090a89a3 100644
--- a/core/lib/Drupal/Core/Database/Query/ConditionInterface.php
+++ b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php
@@ -86,7 +86,7 @@ interface ConditionInterface {
* @return \Drupal\Core\Database\Query\ConditionInterface
* The called object.
*/
- public function where($snippet, $args = array());
+ public function where($snippet, $args = []);
/**
* Sets a condition that the specified field be NULL.
diff --git a/core/lib/Drupal/Core/Database/Query/Delete.php b/core/lib/Drupal/Core/Database/Query/Delete.php
index 65f96c94748..def88385e0b 100644
--- a/core/lib/Drupal/Core/Database/Query/Delete.php
+++ b/core/lib/Drupal/Core/Database/Query/Delete.php
@@ -31,7 +31,7 @@ class Delete extends Query implements ConditionInterface {
* @param array $options
* Array of database options.
*/
- public function __construct(Connection $connection, $table, array $options = array()) {
+ public function __construct(Connection $connection, $table, array $options = []) {
$options['return'] = Database::RETURN_AFFECTED;
parent::__construct($connection, $options);
$this->table = $table;
@@ -46,7 +46,7 @@ class Delete extends Query implements ConditionInterface {
* The number of rows affected by the delete query.
*/
public function execute() {
- $values = array();
+ $values = [];
if (count($this->condition)) {
$this->condition->compile($this->connection, $this);
$values = $this->condition->arguments();
diff --git a/core/lib/Drupal/Core/Database/Query/Insert.php b/core/lib/Drupal/Core/Database/Query/Insert.php
index c8f99215919..3af2d2ac6ff 100644
--- a/core/lib/Drupal/Core/Database/Query/Insert.php
+++ b/core/lib/Drupal/Core/Database/Query/Insert.php
@@ -30,7 +30,7 @@ class Insert extends Query implements \Countable {
* @param array $options
* Array of database options.
*/
- public function __construct($connection, $table, array $options = array()) {
+ public function __construct($connection, $table, array $options = []) {
if (!isset($options['return'])) {
$options['return'] = Database::RETURN_INSERT_ID;
}
@@ -97,7 +97,7 @@ class Insert extends Query implements \Countable {
}
// Re-initialize the values array so that we can re-use this query.
- $this->insertValues = array();
+ $this->insertValues = [];
// Transaction commits here where $transaction looses scope.
@@ -124,7 +124,7 @@ class Insert extends Query implements \Countable {
// For simplicity, we will use the $placeholders array to inject
// default keywords even though they are not, strictly speaking,
// placeholders for prepared statements.
- $placeholders = array();
+ $placeholders = [];
$placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
$placeholders = array_pad($placeholders, count($this->insertFields), '?');
diff --git a/core/lib/Drupal/Core/Database/Query/InsertTrait.php b/core/lib/Drupal/Core/Database/Query/InsertTrait.php
index a97c132b8b4..f291da1a810 100644
--- a/core/lib/Drupal/Core/Database/Query/InsertTrait.php
+++ b/core/lib/Drupal/Core/Database/Query/InsertTrait.php
@@ -21,14 +21,14 @@ trait InsertTrait {
*
* @var array
*/
- protected $insertFields = array();
+ protected $insertFields = [];
/**
* An array of fields that should be set to their database-defined defaults.
*
* @var array
*/
- protected $defaultFields = array();
+ protected $defaultFields = [];
/**
* A nested array of values to insert.
@@ -45,7 +45,7 @@ trait InsertTrait {
*
* @var array
*/
- protected $insertValues = array();
+ protected $insertValues = [];
/**
* Adds a set of field->value pairs to be inserted.
@@ -67,7 +67,7 @@ trait InsertTrait {
* @return $this
* The called object.
*/
- public function fields(array $fields, array $values = array()) {
+ public function fields(array $fields, array $values = []) {
if (empty($this->insertFields)) {
if (empty($values)) {
if (!is_numeric(key($fields))) {
@@ -150,10 +150,10 @@ trait InsertTrait {
*/
protected function getInsertPlaceholderFragment(array $nested_insert_values, array $default_fields) {
$max_placeholder = 0;
- $values = array();
+ $values = [];
if ($nested_insert_values) {
foreach ($nested_insert_values as $insert_values) {
- $placeholders = array();
+ $placeholders = [];
// Default fields aren't really placeholders, but this is the most convenient
// way to handle them.
diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php
index 8bd02fab9cc..43188ec8ca7 100644
--- a/core/lib/Drupal/Core/Database/Query/Merge.php
+++ b/core/lib/Drupal/Core/Database/Query/Merge.php
@@ -74,7 +74,7 @@ class Merge extends Query implements ConditionInterface {
*
* @var array
*/
- protected $insertFields = array();
+ protected $insertFields = [];
/**
* An array of fields which should be set to their database-defined defaults.
@@ -83,21 +83,21 @@ class Merge extends Query implements ConditionInterface {
*
* @var array
*/
- protected $defaultFields = array();
+ protected $defaultFields = [];
/**
* An array of values to be inserted.
*
* @var string
*/
- protected $insertValues = array();
+ protected $insertValues = [];
/**
* An array of fields that will be updated.
*
* @var array
*/
- protected $updateFields = array();
+ protected $updateFields = [];
/**
* Array of fields to update to an expression in case of a duplicate record.
@@ -112,7 +112,7 @@ class Merge extends Query implements ConditionInterface {
*
* @var array
*/
- protected $expressionFields = array();
+ protected $expressionFields = [];
/**
* Flag indicating whether an UPDATE is necessary.
@@ -131,7 +131,7 @@ class Merge extends Query implements ConditionInterface {
* @param array $options
* Array of database options.
*/
- public function __construct(Connection $connection, $table, array $options = array()) {
+ public function __construct(Connection $connection, $table, array $options = []) {
$options['return'] = Database::RETURN_AFFECTED;
parent::__construct($connection, $options);
$this->table = $table;
@@ -190,10 +190,10 @@ class Merge extends Query implements ConditionInterface {
* The called object.
*/
public function expression($field, $expression, array $arguments = NULL) {
- $this->expressionFields[$field] = array(
+ $this->expressionFields[$field] = [
'expression' => $expression,
'arguments' => $arguments,
- );
+ ];
$this->needsUpdate = TRUE;
return $this;
}
@@ -214,7 +214,7 @@ class Merge extends Query implements ConditionInterface {
* @return \Drupal\Core\Database\Query\Merge
* The called object.
*/
- public function insertFields(array $fields, array $values = array()) {
+ public function insertFields(array $fields, array $values = []) {
if ($values) {
$fields = array_combine($fields, $values);
}
@@ -267,7 +267,7 @@ class Merge extends Query implements ConditionInterface {
* @return \Drupal\Core\Database\Query\Merge
* The called object.
*/
- public function fields(array $fields, array $values = array()) {
+ public function fields(array $fields, array $values = []) {
if ($values) {
$fields = array_combine($fields, $values);
}
@@ -300,7 +300,7 @@ class Merge extends Query implements ConditionInterface {
*
* @return $this
*/
- public function keys(array $fields, array $values = array()) {
+ public function keys(array $fields, array $values = []) {
if ($values) {
$fields = array_combine($fields, $values);
}
@@ -329,10 +329,10 @@ class Merge extends Query implements ConditionInterface {
public function key($field, $value = NULL) {
// @todo D9: Remove this backwards-compatibility shim.
if (is_array($field)) {
- $this->keys($field, isset($value) ? $value : array());
+ $this->keys($field, isset($value) ? $value : []);
}
else {
- $this->keys(array($field => $value));
+ $this->keys([$field => $value]);
}
return $this;
}
@@ -351,9 +351,9 @@ class Merge extends Query implements ConditionInterface {
public function execute() {
// Default options for merge queries.
- $this->queryOptions += array(
+ $this->queryOptions += [
'throw_exception' => TRUE,
- );
+ ];
try {
if (!count($this->condition)) {
diff --git a/core/lib/Drupal/Core/Database/Query/Query.php b/core/lib/Drupal/Core/Database/Query/Query.php
index 6fe3db5b60f..94f71a5a4e4 100644
--- a/core/lib/Drupal/Core/Database/Query/Query.php
+++ b/core/lib/Drupal/Core/Database/Query/Query.php
@@ -56,7 +56,7 @@ abstract class Query implements PlaceholderInterface {
*
* @var array
*/
- protected $comments = array();
+ protected $comments = [];
/**
* Constructs a Query object.
diff --git a/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php b/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php
index bc7ed5a15b3..44cc2208afe 100644
--- a/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php
+++ b/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php
@@ -77,7 +77,7 @@ trait QueryConditionTrait {
/**
* {@inheritdoc}
*/
- public function where($snippet, $args = array()) {
+ public function where($snippet, $args = []) {
$this->condition->where($snippet, $args);
return $this;
}
diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php
index 04efcf4eaab..b3426e6d4de 100644
--- a/core/lib/Drupal/Core/Database/Query/Select.php
+++ b/core/lib/Drupal/Core/Database/Query/Select.php
@@ -19,14 +19,14 @@ class Select extends Query implements SelectInterface {
*
* @var array
*/
- protected $fields = array();
+ protected $fields = [];
/**
* The expressions to SELECT as virtual fields.
*
* @var array
*/
- protected $expressions = array();
+ protected $expressions = [];
/**
* The tables against which to JOIN.
@@ -52,7 +52,7 @@ class Select extends Query implements SelectInterface {
*
* @var array
*/
- protected $tables = array();
+ protected $tables = [];
/**
* The fields by which to order this query.
@@ -62,14 +62,14 @@ class Select extends Query implements SelectInterface {
*
* @var array
*/
- protected $order = array();
+ protected $order = [];
/**
* The fields by which to group.
*
* @var array
*/
- protected $group = array();
+ protected $group = [];
/**
* The conditional object for the HAVING clause.
@@ -103,7 +103,7 @@ class Select extends Query implements SelectInterface {
*
* @var array
*/
- protected $union = array();
+ protected $union = [];
/**
* Indicates if preExecute() has already been called.
@@ -128,7 +128,7 @@ class Select extends Query implements SelectInterface {
* @param array $options
* Array of query options.
*/
- public function __construct($table, $alias = NULL, Connection $connection, $options = array()) {
+ public function __construct($table, $alias = NULL, Connection $connection, $options = []) {
$options['return'] = Database::RETURN_STATEMENT;
parent::__construct($connection, $options);
$conjunction = isset($options['conjunction']) ? $options['conjunction'] : 'AND';
@@ -300,7 +300,7 @@ class Select extends Query implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function having($snippet, $args = array()) {
+ public function having($snippet, $args = []) {
$this->having->where($snippet, $args);
return $this;
}
@@ -467,11 +467,11 @@ class Select extends Query implements SelectInterface {
// issue.
// - Emit E_USER_DEPRECATED if term_access is used.
// https://www.drupal.org/node/2575081
- $term_access_tags = array('term_access' => 1, 'taxonomy_term_access' => 1);
+ $term_access_tags = ['term_access' => 1, 'taxonomy_term_access' => 1];
if (array_intersect_key($this->alterTags, $term_access_tags)) {
$this->alterTags += $term_access_tags;
}
- $hooks = array('query');
+ $hooks = ['query'];
foreach ($this->alterTags as $tag => $value) {
$hooks[] = 'query_' . $tag;
}
@@ -538,11 +538,11 @@ class Select extends Query implements SelectInterface {
}
$alias = $alias_candidate;
- $this->fields[$alias] = array(
+ $this->fields[$alias] = [
'field' => $field,
'table' => $table_alias,
'alias' => $alias,
- );
+ ];
return $alias;
}
@@ -550,7 +550,7 @@ class Select extends Query implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function fields($table_alias, array $fields = array()) {
+ public function fields($table_alias, array $fields = []) {
if ($fields) {
foreach ($fields as $field) {
// We don't care what alias was assigned.
@@ -568,7 +568,7 @@ class Select extends Query implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function addExpression($expression, $alias = NULL, $arguments = array()) {
+ public function addExpression($expression, $alias = NULL, $arguments = []) {
if (empty($alias)) {
$alias = 'expression';
}
@@ -580,11 +580,11 @@ class Select extends Query implements SelectInterface {
}
$alias = $alias_candidate;
- $this->expressions[$alias] = array(
+ $this->expressions[$alias] = [
'expression' => $expression,
'alias' => $alias,
'arguments' => $arguments,
- );
+ ];
return $alias;
}
@@ -592,35 +592,35 @@ class Select extends Query implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function join($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->addJoin('INNER', $table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->addJoin('INNER', $table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->addJoin('LEFT OUTER', $table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->addJoin('RIGHT OUTER', $table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []) {
if (empty($alias)) {
if ($table instanceof SelectInterface) {
$alias = 'subquery';
@@ -641,13 +641,13 @@ class Select extends Query implements SelectInterface {
$condition = str_replace('%alias', $alias, $condition);
}
- $this->tables[$alias] = array(
+ $this->tables[$alias] = [
'join type' => $type,
'table' => $table,
'alias' => $alias,
'condition' => $condition,
'arguments' => $arguments,
- );
+ ];
return $alias;
}
@@ -675,7 +675,7 @@ class Select extends Query implements SelectInterface {
* {@inheritdoc}
*/
public function range($start = NULL, $length = NULL) {
- $this->range = $start !== NULL ? array('start' => $start, 'length' => $length) : array();
+ $this->range = $start !== NULL ? ['start' => $start, 'length' => $length] : [];
return $this;
}
@@ -696,10 +696,10 @@ class Select extends Query implements SelectInterface {
default:
}
- $this->union[] = array(
+ $this->union[] = [
'type' => $type,
'query' => $query,
- );
+ ];
return $this;
}
@@ -770,7 +770,7 @@ class Select extends Query implements SelectInterface {
// Ordering a count query is a waste of cycles, and breaks on some
// databases anyway.
$orders = &$count->getOrderBy();
- $orders = array();
+ $orders = [];
if ($count->distinct && !empty($group_by)) {
// If the query is distinct and contains a GROUP BY, we need to remove the
@@ -809,7 +809,7 @@ class Select extends Query implements SelectInterface {
}
// FIELDS and EXPRESSIONS
- $fields = array();
+ $fields = [];
foreach ($this->tables as $alias => $table) {
if (!empty($table['all_fields'])) {
$fields[] = $this->connection->escapeTable($alias) . '.*';
@@ -886,7 +886,7 @@ class Select extends Query implements SelectInterface {
// ORDER BY
if ($this->order) {
$query .= "\nORDER BY ";
- $fields = array();
+ $fields = [];
foreach ($this->order as $field => $direction) {
$fields[] = $this->connection->escapeField($field) . ' ' . $direction;
}
diff --git a/core/lib/Drupal/Core/Database/Query/SelectExtender.php b/core/lib/Drupal/Core/Database/Query/SelectExtender.php
index 808593c58cb..56fe7c13251 100644
--- a/core/lib/Drupal/Core/Database/Query/SelectExtender.php
+++ b/core/lib/Drupal/Core/Database/Query/SelectExtender.php
@@ -72,14 +72,14 @@ class SelectExtender implements SelectInterface {
* {@inheritdoc}
*/
public function hasAllTags() {
- return call_user_func_array(array($this->query, 'hasAllTags'), func_get_args());
+ return call_user_func_array([$this->query, 'hasAllTags'], func_get_args());
}
/**
* {@inheritdoc}
*/
public function hasAnyTag() {
- return call_user_func_array(array($this->query, 'hasAnyTag'), func_get_args());
+ return call_user_func_array([$this->query, 'hasAnyTag'], func_get_args());
}
/**
@@ -122,7 +122,7 @@ class SelectExtender implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function where($snippet, $args = array()) {
+ public function where($snippet, $args = []) {
$this->query->where($snippet, $args);
return $this;
}
@@ -166,7 +166,7 @@ class SelectExtender implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function having($snippet, $args = array()) {
+ public function having($snippet, $args = []) {
$this->query->having($snippet, $args);
return $this;
}
@@ -335,7 +335,7 @@ class SelectExtender implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function fields($table_alias, array $fields = array()) {
+ public function fields($table_alias, array $fields = []) {
$this->query->fields($table_alias, $fields);
return $this;
}
@@ -343,42 +343,42 @@ class SelectExtender implements SelectInterface {
/**
* {@inheritdoc}
*/
- public function addExpression($expression, $alias = NULL, $arguments = array()) {
+ public function addExpression($expression, $alias = NULL, $arguments = []) {
return $this->query->addExpression($expression, $alias, $arguments);
}
/**
* {@inheritdoc}
*/
- public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function join($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->query->join($table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->query->innerJoin($table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->query->leftJoin($table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->query->rightJoin($table, $alias, $condition, $arguments);
}
/**
* {@inheritdoc}
*/
- public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) {
+ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []) {
return $this->query->addJoin($type, $table, $alias, $condition, $arguments);
}
@@ -497,7 +497,7 @@ class SelectExtender implements SelectInterface {
* to handle any additional methods.
*/
public function __call($method, $args) {
- $return = call_user_func_array(array($this->query, $method), $args);
+ $return = call_user_func_array([$this->query, $method], $args);
// Some methods will return the called object as part of a fluent interface.
// Others will return some useful value. If it's a value, then the caller
diff --git a/core/lib/Drupal/Core/Database/Query/SelectInterface.php b/core/lib/Drupal/Core/Database/Query/SelectInterface.php
index aa358d3c29f..59b15d0790c 100644
--- a/core/lib/Drupal/Core/Database/Query/SelectInterface.php
+++ b/core/lib/Drupal/Core/Database/Query/SelectInterface.php
@@ -214,7 +214,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @return \Drupal\Core\Database\Query\SelectInterface
* The called object.
*/
- public function fields($table_alias, array $fields = array());
+ public function fields($table_alias, array $fields = []);
/**
* Adds an expression to the list of "fields" to be SELECTed.
@@ -235,7 +235,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @return
* The unique alias that was assigned for this expression.
*/
- public function addExpression($expression, $alias = NULL, $arguments = array());
+ public function addExpression($expression, $alias = NULL, $arguments = []);
/**
* Default Join against another table in the database.
@@ -263,7 +263,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @return
* The unique alias that was assigned for this table.
*/
- public function join($table, $alias = NULL, $condition = NULL, $arguments = array());
+ public function join($table, $alias = NULL, $condition = NULL, $arguments = []);
/**
* Inner Join against another table in the database.
@@ -289,7 +289,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @return
* The unique alias that was assigned for this table.
*/
- public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array());
+ public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = []);
/**
* Left Outer Join against another table in the database.
@@ -315,7 +315,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @return
* The unique alias that was assigned for this table.
*/
- public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array());
+ public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = []);
/**
* Right Outer Join against another table in the database.
@@ -347,7 +347,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* db_query('B')->leftJoin('A'). This functionality has been deprecated
* because SQLite does not support it.
*/
- public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array());
+ public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = []);
/**
* Join against another table in the database.
@@ -380,7 +380,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* @return
* The unique alias that was assigned for this table.
*/
- public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array());
+ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []);
/**
* Orders the result set by a given field.
@@ -574,7 +574,7 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
*
* @return $this
*/
- public function having($snippet, $args = array());
+ public function having($snippet, $args = []);
/**
* Compiles the HAVING clause for later retrieval.
diff --git a/core/lib/Drupal/Core/Database/Query/TableSortExtender.php b/core/lib/Drupal/Core/Database/Query/TableSortExtender.php
index 285f1d6a9bb..4f739ee3049 100644
--- a/core/lib/Drupal/Core/Database/Query/TableSortExtender.php
+++ b/core/lib/Drupal/Core/Database/Query/TableSortExtender.php
@@ -12,7 +12,7 @@ class TableSortExtender extends SelectExtender {
/**
* The array of fields that can be sorted by.
*/
- protected $header = array();
+ protected $header = [];
public function __construct(SelectInterface $query, Connection $connection) {
parent::__construct($query, $connection);
diff --git a/core/lib/Drupal/Core/Database/Query/Truncate.php b/core/lib/Drupal/Core/Database/Query/Truncate.php
index 64520ee97eb..1711adee551 100644
--- a/core/lib/Drupal/Core/Database/Query/Truncate.php
+++ b/core/lib/Drupal/Core/Database/Query/Truncate.php
@@ -28,7 +28,7 @@ class Truncate extends Query {
* @param array $options
* Array of database options.
*/
- public function __construct(Connection $connection, $table, array $options = array()) {
+ public function __construct(Connection $connection, $table, array $options = []) {
$options['return'] = Database::RETURN_AFFECTED;
parent::__construct($connection, $options);
$this->table = $table;
@@ -55,7 +55,7 @@ class Truncate extends Query {
* Return value is dependent on the database type.
*/
public function execute() {
- return $this->connection->query((string) $this, array(), $this->queryOptions);
+ return $this->connection->query((string) $this, [], $this->queryOptions);
}
/**
diff --git a/core/lib/Drupal/Core/Database/Query/Update.php b/core/lib/Drupal/Core/Database/Query/Update.php
index d6b93b76f4d..ba0661c7a08 100644
--- a/core/lib/Drupal/Core/Database/Query/Update.php
+++ b/core/lib/Drupal/Core/Database/Query/Update.php
@@ -26,14 +26,14 @@ class Update extends Query implements ConditionInterface {
*
* @var array
*/
- protected $fields = array();
+ protected $fields = [];
/**
* An array of values to update to.
*
* @var array
*/
- protected $arguments = array();
+ protected $arguments = [];
/**
* Array of fields to update to an expression in case of a duplicate record.
@@ -48,7 +48,7 @@ class Update extends Query implements ConditionInterface {
*
* @var array
*/
- protected $expressionFields = array();
+ protected $expressionFields = [];
/**
* Constructs an Update query object.
@@ -60,7 +60,7 @@ class Update extends Query implements ConditionInterface {
* @param array $options
* Array of database options.
*/
- public function __construct(Connection $connection, $table, array $options = array()) {
+ public function __construct(Connection $connection, $table, array $options = []) {
$options['return'] = Database::RETURN_AFFECTED;
parent::__construct($connection, $options);
$this->table = $table;
@@ -102,10 +102,10 @@ class Update extends Query implements ConditionInterface {
* The called object.
*/
public function expression($field, $expression, array $arguments = NULL) {
- $this->expressionFields[$field] = array(
+ $this->expressionFields[$field] = [
'expression' => $expression,
'arguments' => $arguments,
- );
+ ];
return $this;
}
@@ -121,7 +121,7 @@ class Update extends Query implements ConditionInterface {
// Expressions take priority over literal fields, so we process those first
// and remove any literal fields that conflict.
$fields = $this->fields;
- $update_values = array();
+ $update_values = [];
foreach ($this->expressionFields as $field => $data) {
if (!empty($data['arguments'])) {
$update_values += $data['arguments'];
@@ -161,7 +161,7 @@ class Update extends Query implements ConditionInterface {
// Expressions take priority over literal fields, so we process those first
// and remove any literal fields that conflict.
$fields = $this->fields;
- $update_fields = array();
+ $update_fields = [];
foreach ($this->expressionFields as $field => $data) {
if ($data['expression'] instanceof SelectInterface) {
// Compile and cast expression subquery to a string.
diff --git a/core/lib/Drupal/Core/Database/Query/Upsert.php b/core/lib/Drupal/Core/Database/Query/Upsert.php
index dec2d3b3ec6..a406d7ab97c 100644
--- a/core/lib/Drupal/Core/Database/Query/Upsert.php
+++ b/core/lib/Drupal/Core/Database/Query/Upsert.php
@@ -96,7 +96,7 @@ abstract class Upsert extends Query implements \Countable {
}
$max_placeholder = 0;
- $values = array();
+ $values = [];
foreach ($this->insertValues as $insert_values) {
foreach ($insert_values as $value) {
$values[':db_insert_placeholder_' . $max_placeholder++] = $value;
@@ -106,7 +106,7 @@ abstract class Upsert extends Query implements \Countable {
$last_insert_id = $this->connection->query((string) $this, $values, $this->queryOptions);
// Re-initialize the values array so that we can re-use this query.
- $this->insertValues = array();
+ $this->insertValues = [];
return $last_insert_id;
}
diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php
index 8b9eb7e129d..eb98bb1d588 100644
--- a/core/lib/Drupal/Core/Database/Schema.php
+++ b/core/lib/Drupal/Core/Database/Schema.php
@@ -77,10 +77,10 @@ abstract class Schema implements PlaceholderInterface {
* A keyed array with information about the schema, table name and prefix.
*/
protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
- $info = array(
+ $info = [
'schema' => $this->defaultSchema,
'prefix' => $this->connection->tablePrefix($table),
- );
+ ];
if ($add_prefix) {
$table = $info['prefix'] . $table;
}
@@ -224,7 +224,7 @@ abstract class Schema implements PlaceholderInterface {
// Convert the table expression from its SQL LIKE syntax to a regular
// expression and escape the delimiter that will be used for matching.
- $table_expression = str_replace(array('%', '_'), array('.*?', '.'), preg_quote($table_expression, '/'));
+ $table_expression = str_replace(['%', '_'], ['.*?', '.'], preg_quote($table_expression, '/'));
$tables = preg_grep('/^' . $table_expression . '$/i', $tables);
return $tables;
@@ -320,7 +320,7 @@ abstract class Schema implements PlaceholderInterface {
* @throws \Drupal\Core\Database\SchemaObjectExistsException
* If the specified table already has a field by that name.
*/
- abstract public function addField($table, $field, $spec, $keys_new = array());
+ abstract public function addField($table, $field, $spec, $keys_new = []);
/**
* Drop a field.
@@ -576,7 +576,7 @@ abstract class Schema implements PlaceholderInterface {
* @throws \Drupal\Core\Database\SchemaObjectExistsException
* If the specified destination field already exists.
*/
- abstract public function changeField($table, $field, $field_new, $spec, $keys_new = array());
+ abstract public function changeField($table, $field, $field_new, $spec, $keys_new = []);
/**
* Create a new table from a Drupal table definition.
@@ -591,7 +591,7 @@ abstract class Schema implements PlaceholderInterface {
*/
public function createTable($name, $table) {
if ($this->tableExists($name)) {
- throw new SchemaObjectExistsException(t('Table @name already exists.', array('@name' => $name)));
+ throw new SchemaObjectExistsException(t('Table @name already exists.', ['@name' => $name]));
}
$statements = $this->createTableSql($name, $table);
foreach ($statements as $statement) {
@@ -612,7 +612,7 @@ abstract class Schema implements PlaceholderInterface {
* An array of field names.
*/
public function fieldNames($fields) {
- $return = array();
+ $return = [];
foreach ($fields as $field) {
if (is_array($field)) {
$return[] = $field[0];
diff --git a/core/lib/Drupal/Core/Database/Statement.php b/core/lib/Drupal/Core/Database/Statement.php
index d44853279ba..8060fbcde59 100644
--- a/core/lib/Drupal/Core/Database/Statement.php
+++ b/core/lib/Drupal/Core/Database/Statement.php
@@ -39,7 +39,7 @@ class Statement extends \PDOStatement implements StatementInterface {
/**
* {@inheritdoc}
*/
- public function execute($args = array(), $options = array()) {
+ public function execute($args = [], $options = []) {
if (isset($options['fetch'])) {
if (is_string($options['fetch'])) {
// \PDO::FETCH_PROPS_LATE tells __construct() to run before properties
@@ -84,7 +84,7 @@ class Statement extends \PDOStatement implements StatementInterface {
* {@inheritdoc}
*/
public function fetchAllAssoc($key, $fetch = NULL) {
- $return = array();
+ $return = [];
if (isset($fetch)) {
if (is_string($fetch)) {
$this->setFetchMode(\PDO::FETCH_CLASS, $fetch);
@@ -106,7 +106,7 @@ class Statement extends \PDOStatement implements StatementInterface {
* {@inheritdoc}
*/
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
- $return = array();
+ $return = [];
$this->setFetchMode(\PDO::FETCH_NUM);
foreach ($this as $record) {
$return[$record[$key_index]] = $record[$value_index];
@@ -146,7 +146,7 @@ class Statement extends \PDOStatement implements StatementInterface {
/**
* {@inheritdoc}
*/
- public function setFetchMode($mode, $a1 = NULL, $a2 = array()) {
+ public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
// Call \PDOStatement::setFetchMode to set fetch mode.
// \PDOStatement is picky about the number of arguments in some cases so we
// need to be pass the exact number of arguments we where given.
diff --git a/core/lib/Drupal/Core/Database/StatementEmpty.php b/core/lib/Drupal/Core/Database/StatementEmpty.php
index 32b29d5e90a..343b90ce8e8 100644
--- a/core/lib/Drupal/Core/Database/StatementEmpty.php
+++ b/core/lib/Drupal/Core/Database/StatementEmpty.php
@@ -26,7 +26,7 @@ class StatementEmpty implements \Iterator, StatementInterface {
/**
* {@inheritdoc}
*/
- public function execute($args = array(), $options = array()) {
+ public function execute($args = [], $options = []) {
return FALSE;
}
@@ -50,7 +50,7 @@ class StatementEmpty implements \Iterator, StatementInterface {
/**
* {@inheritdoc}
*/
- public function setFetchMode($mode, $a1 = NULL, $a2 = array()) {
+ public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
return;
}
@@ -86,28 +86,28 @@ class StatementEmpty implements \Iterator, StatementInterface {
* {@inheritdoc}
*/
public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function fetchCol($index = 0) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function fetchAllAssoc($key, $fetch = NULL) {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Database/StatementInterface.php b/core/lib/Drupal/Core/Database/StatementInterface.php
index 971d031e032..c0ee92936a3 100644
--- a/core/lib/Drupal/Core/Database/StatementInterface.php
+++ b/core/lib/Drupal/Core/Database/StatementInterface.php
@@ -51,7 +51,7 @@ interface StatementInterface extends \Traversable {
* @return
* TRUE on success, or FALSE on failure.
*/
- public function execute($args = array(), $options = array());
+ public function execute($args = [], $options = []);
/**
* Gets the query string of this statement.
@@ -90,7 +90,7 @@ interface StatementInterface extends \Traversable {
* If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the
* constructor.
*/
- public function setFetchMode($mode, $a1 = NULL, $a2 = array());
+ public function setFetchMode($mode, $a1 = NULL, $a2 = []);
/**
* Fetches the next row from a result set.
diff --git a/core/lib/Drupal/Core/Database/StatementPrefetch.php b/core/lib/Drupal/Core/Database/StatementPrefetch.php
index 6864f00ef3b..80252209e69 100644
--- a/core/lib/Drupal/Core/Database/StatementPrefetch.php
+++ b/core/lib/Drupal/Core/Database/StatementPrefetch.php
@@ -43,7 +43,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
*
* @var Array
*/
- protected $data = array();
+ protected $data = [];
/**
* The current row, retrieved in \PDO::FETCH_ASSOC format.
@@ -93,12 +93,12 @@ class StatementPrefetch implements \Iterator, StatementInterface {
*
* @var Array
*/
- protected $fetchOptions = array(
+ protected $fetchOptions = [
'class' => 'stdClass',
- 'constructor_args' => array(),
+ 'constructor_args' => [],
'object' => NULL,
'column' => 0,
- );
+ ];
/**
* Holds the default fetch style.
@@ -112,12 +112,12 @@ class StatementPrefetch implements \Iterator, StatementInterface {
*
* @var Array
*/
- protected $defaultFetchOptions = array(
+ protected $defaultFetchOptions = [
'class' => 'stdClass',
- 'constructor_args' => array(),
+ 'constructor_args' => [],
'object' => NULL,
'column' => 0,
- );
+ ];
/**
* Is rowCount() execution allowed.
@@ -126,7 +126,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
*/
public $allowRowCount = FALSE;
- public function __construct(\PDO $pdo_connection, Connection $connection, $query, array $driver_options = array()) {
+ public function __construct(\PDO $pdo_connection, Connection $connection, $query, array $driver_options = []) {
$this->pdoConnection = $pdo_connection;
$this->dbh = $connection;
$this->queryString = $query;
@@ -136,7 +136,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
/**
* {@inheritdoc}
*/
- public function execute($args = array(), $options = array()) {
+ public function execute($args = [], $options = []) {
if (isset($options['fetch'])) {
if (is_string($options['fetch'])) {
// Default to an object. Note: db fields will be added to the object
@@ -181,7 +181,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
$this->columnNames = array_keys($this->data[0]);
}
else {
- $this->columnNames = array();
+ $this->columnNames = [];
}
if (!empty($logger)) {
@@ -219,7 +219,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
* @return \PDOStatement
* A PDOStatement object.
*/
- protected function getStatement($query, &$args = array()) {
+ protected function getStatement($query, &$args = []) {
return $this->dbh->prepare($query);
}
@@ -233,7 +233,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
/**
* {@inheritdoc}
*/
- public function setFetchMode($mode, $a1 = NULL, $a2 = array()) {
+ public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
$this->defaultFetchStyle = $mode;
switch ($mode) {
case \PDO::FETCH_CLASS:
@@ -409,7 +409,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
/**
* {@inheritdoc}
*/
- public function fetchObject($class_name = NULL, $constructor_args = array()) {
+ public function fetchObject($class_name = NULL, $constructor_args = []) {
if (isset($this->currentRow)) {
if (!isset($class_name)) {
// Directly cast to an object to avoid a function call.
@@ -417,7 +417,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
}
else {
$this->fetchStyle = \PDO::FETCH_CLASS;
- $this->fetchOptions = array('constructor_args' => $constructor_args);
+ $this->fetchOptions = ['constructor_args' => $constructor_args];
// Grab the row in the format specified above.
$result = $this->current();
// Reset the fetch parameters to the value stored using setFetchMode().
@@ -461,7 +461,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
$this->fetchOptions['constructor_args'] = $constructor_arguments;
}
- $result = array();
+ $result = [];
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
// Grab the row in the format specified above.
@@ -480,7 +480,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
*/
public function fetchCol($index = 0) {
if (isset($this->columnNames[$index])) {
- $result = array();
+ $result = [];
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
$result[] = $this->currentRow[$this->columnNames[$index]];
@@ -489,7 +489,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
return $result;
}
else {
- return array();
+ return [];
}
}
@@ -498,12 +498,12 @@ class StatementPrefetch implements \Iterator, StatementInterface {
*/
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
if (!isset($this->columnNames[$key_index]) || !isset($this->columnNames[$value_index]))
- return array();
+ return [];
$key = $this->columnNames[$key_index];
$value = $this->columnNames[$value_index];
- $result = array();
+ $result = [];
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
$result[$this->currentRow[$key]] = $this->currentRow[$value];
@@ -519,7 +519,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
$this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
- $result = array();
+ $result = [];
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
// Grab the row in its raw \PDO::FETCH_ASSOC format.
diff --git a/core/lib/Drupal/Core/Database/database.api.php b/core/lib/Drupal/Core/Database/database.api.php
index bf2f1fd3444..45a561872a7 100644
--- a/core/lib/Drupal/Core/Database/database.api.php
+++ b/core/lib/Drupal/Core/Database/database.api.php
@@ -484,60 +484,60 @@ function hook_query_TAG_alter(Drupal\Core\Database\Query\AlterableInterface $que
* @ingroup schemaapi
*/
function hook_schema() {
- $schema['node'] = array(
+ $schema['node'] = [
// Example (partial) specification for table "node".
'description' => 'The base table for nodes.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The primary identifier for a node.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'vid' => array(
+ ],
+ 'vid' => [
'description' => 'The current {node_field_revision}.vid version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'type' => array(
+ ],
+ 'type' => [
'description' => 'The type of this node.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
- ),
- 'title' => array(
+ ],
+ 'title' => [
'description' => 'The node title.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- ),
- 'indexes' => array(
- 'node_changed' => array('changed'),
- 'node_created' => array('created'),
- ),
- 'unique keys' => array(
- 'nid_vid' => array('nid', 'vid'),
- 'vid' => array('vid'),
- ),
+ ],
+ ],
+ 'indexes' => [
+ 'node_changed' => ['changed'],
+ 'node_created' => ['created'],
+ ],
+ 'unique keys' => [
+ 'nid_vid' => ['nid', 'vid'],
+ 'vid' => ['vid'],
+ ],
// For documentation purposes only; foreign keys are not created in the
// database.
- 'foreign keys' => array(
- 'node_revision' => array(
+ 'foreign keys' => [
+ 'node_revision' => [
'table' => 'node_field_revision',
- 'columns' => array('vid' => 'vid'),
- ),
- 'node_author' => array(
+ 'columns' => ['vid' => 'vid'],
+ ],
+ 'node_author' => [
'table' => 'users',
- 'columns' => array('uid' => 'uid'),
- ),
- ),
- 'primary key' => array('nid'),
- );
+ 'columns' => ['uid' => 'uid'],
+ ],
+ ],
+ 'primary key' => ['nid'],
+ ];
return $schema;
}
diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php
index 421b03b51eb..77290803520 100644
--- a/core/lib/Drupal/Core/Datetime/DateFormatter.php
+++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php
@@ -54,7 +54,7 @@ class DateFormatter implements DateFormatterInterface {
protected $requestStack;
protected $country = NULL;
- protected $dateFormats = array();
+ protected $dateFormats = [];
/**
* Contains the different date interval units.
@@ -65,7 +65,7 @@ class DateFormatter implements DateFormatterInterface {
*
* @var array
*/
- protected $units = array(
+ protected $units = [
'1 year|@count years' => 31536000,
'1 month|@count months' => 2592000,
'1 week|@count weeks' => 604800,
@@ -73,7 +73,7 @@ class DateFormatter implements DateFormatterInterface {
'1 hour|@count hours' => 3600,
'1 min|@count min' => 60,
'1 sec|@count sec' => 1,
- );
+ ];
/**
* Constructs a Date object.
@@ -115,10 +115,10 @@ class DateFormatter implements DateFormatterInterface {
}
// Create a DrupalDateTime object from the timestamp and timezone.
- $create_settings = array(
+ $create_settings = [
'langcode' => $langcode,
'country' => $this->country(),
- );
+ ];
$date = DrupalDateTime::createFromTimestamp($timestamp, $this->timezones[$timezone], $create_settings);
// If we have a non-custom date format use the provided date format pattern.
@@ -136,9 +136,9 @@ class DateFormatter implements DateFormatterInterface {
}
// Call $date->format().
- $settings = array(
+ $settings = [
'langcode' => $langcode,
- );
+ ];
return $date->format($format, $settings);
}
@@ -150,7 +150,7 @@ class DateFormatter implements DateFormatterInterface {
foreach ($this->units as $key => $value) {
$key = explode('|', $key);
if ($interval >= $value) {
- $output .= ($output ? ' ' : '') . $this->formatPlural(floor($interval / $value), $key[0], $key[1], array(), array('langcode' => $langcode));
+ $output .= ($output ? ' ' : '') . $this->formatPlural(floor($interval / $value), $key[0], $key[1], [], ['langcode' => $langcode]);
$interval %= $value;
$granularity--;
}
@@ -164,7 +164,7 @@ class DateFormatter implements DateFormatterInterface {
break;
}
}
- return $output ? $output : $this->t('0 sec', array(), array('langcode' => $langcode));
+ return $output ? $output : $this->t('0 sec', [], ['langcode' => $langcode]);
}
/**
@@ -183,7 +183,7 @@ class DateFormatter implements DateFormatterInterface {
/**
* {@inheritdoc}
*/
- public function formatTimeDiffUntil($timestamp, $options = array()) {
+ public function formatTimeDiffUntil($timestamp, $options = []) {
$request_time = $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME');
return $this->formatDiff($request_time, $timestamp, $options);
}
@@ -191,7 +191,7 @@ class DateFormatter implements DateFormatterInterface {
/**
* {@inheritdoc}
*/
- public function formatTimeDiffSince($timestamp, $options = array()) {
+ public function formatTimeDiffSince($timestamp, $options = []) {
$request_time = $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME');
return $this->formatDiff($timestamp, $request_time, $options);
}
@@ -199,14 +199,14 @@ class DateFormatter implements DateFormatterInterface {
/**
* {@inheritdoc}
*/
- public function formatDiff($from, $to, $options = array()) {
+ public function formatDiff($from, $to, $options = []) {
- $options += array(
+ $options += [
'granularity' => 2,
'langcode' => NULL,
'strict' => TRUE,
'return_as_object' => FALSE,
- );
+ ];
if ($options['strict'] && $from > $to) {
$string = $this->t('0 seconds');
@@ -231,18 +231,18 @@ class DateFormatter implements DateFormatterInterface {
// don't take the "invert" property into account, the resulting output value
// will always be positive.
$max_age = 1e99;
- foreach (array('y', 'm', 'd', 'h', 'i', 's') as $value) {
+ foreach (['y', 'm', 'd', 'h', 'i', 's'] as $value) {
if ($interval->$value > 0) {
// Switch over the keys to call formatPlural() explicitly with literal
// strings for all different possibilities.
switch ($value) {
case 'y':
- $interval_output = $this->formatPlural($interval->y, '1 year', '@count years', array(), array('langcode' => $options['langcode']));
+ $interval_output = $this->formatPlural($interval->y, '1 year', '@count years', [], ['langcode' => $options['langcode']]);
$max_age = min($max_age, 365 * 86400);
break;
case 'm':
- $interval_output = $this->formatPlural($interval->m, '1 month', '@count months', array(), array('langcode' => $options['langcode']));
+ $interval_output = $this->formatPlural($interval->m, '1 month', '@count months', [], ['langcode' => $options['langcode']]);
$max_age = min($max_age, 30 * 86400);
break;
@@ -253,14 +253,14 @@ class DateFormatter implements DateFormatterInterface {
$days = $interval->d;
$weeks = floor($days / 7);
if ($weeks) {
- $interval_output .= $this->formatPlural($weeks, '1 week', '@count weeks', array(), array('langcode' => $options['langcode']));
+ $interval_output .= $this->formatPlural($weeks, '1 week', '@count weeks', [], ['langcode' => $options['langcode']]);
$days -= $weeks * 7;
$granularity--;
$max_age = min($max_age, 7 * 86400);
}
if ((!$output || $weeks > 0) && $granularity > 0 && $days > 0) {
- $interval_output .= ($interval_output ? ' ' : '') . $this->formatPlural($days, '1 day', '@count days', array(), array('langcode' => $options['langcode']));
+ $interval_output .= ($interval_output ? ' ' : '') . $this->formatPlural($days, '1 day', '@count days', [], ['langcode' => $options['langcode']]);
$max_age = min($max_age, 86400);
}
else {
@@ -271,17 +271,17 @@ class DateFormatter implements DateFormatterInterface {
break;
case 'h':
- $interval_output = $this->formatPlural($interval->h, '1 hour', '@count hours', array(), array('langcode' => $options['langcode']));
+ $interval_output = $this->formatPlural($interval->h, '1 hour', '@count hours', [], ['langcode' => $options['langcode']]);
$max_age = min($max_age, 3600);
break;
case 'i':
- $interval_output = $this->formatPlural($interval->i, '1 minute', '@count minutes', array(), array('langcode' => $options['langcode']));
+ $interval_output = $this->formatPlural($interval->i, '1 minute', '@count minutes', [], ['langcode' => $options['langcode']]);
$max_age = min($max_age, 60);
break;
case 's':
- $interval_output = $this->formatPlural($interval->s, '1 second', '@count seconds', array(), array('langcode' => $options['langcode']));
+ $interval_output = $this->formatPlural($interval->s, '1 second', '@count seconds', [], ['langcode' => $options['langcode']]);
$max_age = min($max_age, 1);
break;
@@ -327,7 +327,7 @@ class DateFormatter implements DateFormatterInterface {
protected function dateFormat($format, $langcode) {
if (!isset($this->dateFormats[$format][$langcode])) {
$original_language = $this->languageManager->getConfigOverrideLanguage();
- $this->languageManager->setConfigOverrideLanguage(new Language(array('id' => $langcode)));
+ $this->languageManager->setConfigOverrideLanguage(new Language(['id' => $langcode]));
$this->dateFormats[$format][$langcode] = $this->dateFormatStorage->load($format);
$this->languageManager->setConfigOverrideLanguage($original_language);
}
diff --git a/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php b/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php
index 3515ee4da4d..6bddf8fe39f 100644
--- a/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php
+++ b/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php
@@ -112,7 +112,7 @@ interface DateFormatterInterface {
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatDiff()
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffSince()
*/
- public function formatTimeDiffUntil($timestamp, $options = array());
+ public function formatTimeDiffUntil($timestamp, $options = []);
/**
* Formats the time difference from a timestamp to the current request time.
@@ -142,7 +142,7 @@ interface DateFormatterInterface {
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatDiff()
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffUntil()
*/
- public function formatTimeDiffSince($timestamp, $options = array());
+ public function formatTimeDiffSince($timestamp, $options = []);
/**
* Formats a time interval between two timestamps.
@@ -174,6 +174,6 @@ interface DateFormatterInterface {
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffSince()
* @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffUntil()
*/
- public function formatDiff($from, $to, $options = array());
+ public function formatDiff($from, $to, $options = []);
}
diff --git a/core/lib/Drupal/Core/Datetime/DateHelper.php b/core/lib/Drupal/Core/Datetime/DateHelper.php
index 70db9b3c41e..b3a8ce75d60 100644
--- a/core/lib/Drupal/Core/Datetime/DateHelper.php
+++ b/core/lib/Drupal/Core/Datetime/DateHelper.php
@@ -27,7 +27,7 @@ class DateHelper {
public static function monthNamesUntranslated() {
// Force the key to use the correct month value, rather than
// starting with zero.
- return array(
+ return [
1 => 'January',
2 => 'February',
3 => 'March',
@@ -40,7 +40,7 @@ class DateHelper {
10 => 'October',
11 => 'November',
12 => 'December',
- );
+ ];
}
/**
@@ -52,7 +52,7 @@ class DateHelper {
public static function monthNamesAbbrUntranslated() {
// Force the key to use the correct month value, rather than
// starting with zero.
- return array(
+ return [
1 => 'Jan',
2 => 'Feb',
3 => 'Mar',
@@ -65,7 +65,7 @@ class DateHelper {
10 => 'Oct',
11 => 'Nov',
12 => 'Dec',
- );
+ ];
}
/**
@@ -81,21 +81,21 @@ class DateHelper {
public static function monthNames($required = FALSE) {
// Force the key to use the correct month value, rather than
// starting with zero.
- $monthnames = array(
- 1 => t('January', array(), array('context' => 'Long month name')),
- 2 => t('February', array(), array('context' => 'Long month name')),
- 3 => t('March', array(), array('context' => 'Long month name')),
- 4 => t('April', array(), array('context' => 'Long month name')),
- 5 => t('May', array(), array('context' => 'Long month name')),
- 6 => t('June', array(), array('context' => 'Long month name')),
- 7 => t('July', array(), array('context' => 'Long month name')),
- 8 => t('August', array(), array('context' => 'Long month name')),
- 9 => t('September', array(), array('context' => 'Long month name')),
- 10 => t('October', array(), array('context' => 'Long month name')),
- 11 => t('November', array(), array('context' => 'Long month name')),
- 12 => t('December', array(), array('context' => 'Long month name')),
- );
- $none = array('' => '');
+ $monthnames = [
+ 1 => t('January', [], ['context' => 'Long month name']),
+ 2 => t('February', [], ['context' => 'Long month name']),
+ 3 => t('March', [], ['context' => 'Long month name']),
+ 4 => t('April', [], ['context' => 'Long month name']),
+ 5 => t('May', [], ['context' => 'Long month name']),
+ 6 => t('June', [], ['context' => 'Long month name']),
+ 7 => t('July', [], ['context' => 'Long month name']),
+ 8 => t('August', [], ['context' => 'Long month name']),
+ 9 => t('September', [], ['context' => 'Long month name']),
+ 10 => t('October', [], ['context' => 'Long month name']),
+ 11 => t('November', [], ['context' => 'Long month name']),
+ 12 => t('December', [], ['context' => 'Long month name']),
+ ];
+ $none = ['' => ''];
return !$required ? $none + $monthnames : $monthnames;
}
@@ -112,21 +112,21 @@ class DateHelper {
public static function monthNamesAbbr($required = FALSE) {
// Force the key to use the correct month value, rather than
// starting with zero.
- $monthnames = array(
- 1 => t('Jan', array(), array('context' => 'Abbreviated month name')),
- 2 => t('Feb', array(), array('context' => 'Abbreviated month name')),
- 3 => t('Mar', array(), array('context' => 'Abbreviated month name')),
- 4 => t('Apr', array(), array('context' => 'Abbreviated month name')),
- 5 => t('May', array(), array('context' => 'Abbreviated month name')),
- 6 => t('Jun', array(), array('context' => 'Abbreviated month name')),
- 7 => t('Jul', array(), array('context' => 'Abbreviated month name')),
- 8 => t('Aug', array(), array('context' => 'Abbreviated month name')),
- 9 => t('Sep', array(), array('context' => 'Abbreviated month name')),
- 10 => t('Oct', array(), array('context' => 'Abbreviated month name')),
- 11 => t('Nov', array(), array('context' => 'Abbreviated month name')),
- 12 => t('Dec', array(), array('context' => 'Abbreviated month name')),
- );
- $none = array('' => '');
+ $monthnames = [
+ 1 => t('Jan', [], ['context' => 'Abbreviated month name']),
+ 2 => t('Feb', [], ['context' => 'Abbreviated month name']),
+ 3 => t('Mar', [], ['context' => 'Abbreviated month name']),
+ 4 => t('Apr', [], ['context' => 'Abbreviated month name']),
+ 5 => t('May', [], ['context' => 'Abbreviated month name']),
+ 6 => t('Jun', [], ['context' => 'Abbreviated month name']),
+ 7 => t('Jul', [], ['context' => 'Abbreviated month name']),
+ 8 => t('Aug', [], ['context' => 'Abbreviated month name']),
+ 9 => t('Sep', [], ['context' => 'Abbreviated month name']),
+ 10 => t('Oct', [], ['context' => 'Abbreviated month name']),
+ 11 => t('Nov', [], ['context' => 'Abbreviated month name']),
+ 12 => t('Dec', [], ['context' => 'Abbreviated month name']),
+ ];
+ $none = ['' => ''];
return !$required ? $none + $monthnames : $monthnames;
}
@@ -137,7 +137,7 @@ class DateHelper {
* An array of week day names
*/
public static function weekDaysUntranslated() {
- return array(
+ return [
'Sunday',
'Monday',
'Tuesday',
@@ -145,7 +145,7 @@ class DateHelper {
'Thursday',
'Friday',
'Saturday',
- );
+ ];
}
/**
@@ -159,7 +159,7 @@ class DateHelper {
* An array of week day names
*/
public static function weekDays($required = FALSE) {
- $weekdays = array(
+ $weekdays = [
t('Sunday'),
t('Monday'),
t('Tuesday'),
@@ -167,8 +167,8 @@ class DateHelper {
t('Thursday'),
t('Friday'),
t('Saturday'),
- );
- $none = array('' => '');
+ ];
+ $none = ['' => ''];
return !$required ? $none + $weekdays : $weekdays;
}
@@ -183,16 +183,16 @@ class DateHelper {
* An array of week day abbreviations
*/
public static function weekDaysAbbr($required = FALSE) {
- $weekdays = array(
- t('Sun', array(), array('context' => 'Abbreviated weekday')),
- t('Mon', array(), array('context' => 'Abbreviated weekday')),
- t('Tue', array(), array('context' => 'Abbreviated weekday')),
- t('Wed', array(), array('context' => 'Abbreviated weekday')),
- t('Thu', array(), array('context' => 'Abbreviated weekday')),
- t('Fri', array(), array('context' => 'Abbreviated weekday')),
- t('Sat', array(), array('context' => 'Abbreviated weekday')),
- );
- $none = array('' => '');
+ $weekdays = [
+ t('Sun', [], ['context' => 'Abbreviated weekday']),
+ t('Mon', [], ['context' => 'Abbreviated weekday']),
+ t('Tue', [], ['context' => 'Abbreviated weekday']),
+ t('Wed', [], ['context' => 'Abbreviated weekday']),
+ t('Thu', [], ['context' => 'Abbreviated weekday']),
+ t('Fri', [], ['context' => 'Abbreviated weekday']),
+ t('Sat', [], ['context' => 'Abbreviated weekday']),
+ ];
+ $none = ['' => ''];
return !$required ? $none + $weekdays : $weekdays;
}
@@ -207,16 +207,16 @@ class DateHelper {
* An array of week day 2 letter abbreviations
*/
public static function weekDaysAbbr2($required = FALSE) {
- $weekdays = array(
- t('Su', array(), array('context' => 'Abbreviated weekday')),
- t('Mo', array(), array('context' => 'Abbreviated weekday')),
- t('Tu', array(), array('context' => 'Abbreviated weekday')),
- t('We', array(), array('context' => 'Abbreviated weekday')),
- t('Th', array(), array('context' => 'Abbreviated weekday')),
- t('Fr', array(), array('context' => 'Abbreviated weekday')),
- t('Sa', array(), array('context' => 'Abbreviated weekday')),
- );
- $none = array('' => '');
+ $weekdays = [
+ t('Su', [], ['context' => 'Abbreviated weekday']),
+ t('Mo', [], ['context' => 'Abbreviated weekday']),
+ t('Tu', [], ['context' => 'Abbreviated weekday']),
+ t('We', [], ['context' => 'Abbreviated weekday']),
+ t('Th', [], ['context' => 'Abbreviated weekday']),
+ t('Fr', [], ['context' => 'Abbreviated weekday']),
+ t('Sa', [], ['context' => 'Abbreviated weekday']),
+ ];
+ $none = ['' => ''];
return !$required ? $none + $weekdays : $weekdays;
}
@@ -231,16 +231,16 @@ class DateHelper {
* An array of week day 1 letter abbreviations
*/
public static function weekDaysAbbr1($required = FALSE) {
- $weekdays = array(
- t('S', array(), array('context' => 'Abbreviated 1 letter weekday Sunday')),
- t('M', array(), array('context' => 'Abbreviated 1 letter weekday Monday')),
- t('T', array(), array('context' => 'Abbreviated 1 letter weekday Tuesday')),
- t('W', array(), array('context' => 'Abbreviated 1 letter weekday Wednesday')),
- t('T', array(), array('context' => 'Abbreviated 1 letter weekday Thursday')),
- t('F', array(), array('context' => 'Abbreviated 1 letter weekday Friday')),
- t('S', array(), array('context' => 'Abbreviated 1 letter weekday Saturday')),
- );
- $none = array('' => '');
+ $weekdays = [
+ t('S', [], ['context' => 'Abbreviated 1 letter weekday Sunday']),
+ t('M', [], ['context' => 'Abbreviated 1 letter weekday Monday']),
+ t('T', [], ['context' => 'Abbreviated 1 letter weekday Tuesday']),
+ t('W', [], ['context' => 'Abbreviated 1 letter weekday Wednesday']),
+ t('T', [], ['context' => 'Abbreviated 1 letter weekday Thursday']),
+ t('F', [], ['context' => 'Abbreviated 1 letter weekday Friday']),
+ t('S', [], ['context' => 'Abbreviated 1 letter weekday Saturday']),
+ ];
+ $none = ['' => ''];
return !$required ? $none + $weekdays : $weekdays;
}
@@ -296,7 +296,7 @@ class DateHelper {
if (empty($max)) {
$max = intval(date('Y', REQUEST_TIME) + 3);
}
- $none = array('' => '');
+ $none = ['' => ''];
$range = range($min, $max);
$range = array_combine($range, $range);
return !$required ? $none + $range : $range;
@@ -328,7 +328,7 @@ class DateHelper {
if (empty($max)) {
$max = 31;
}
- $none = array('' => '');
+ $none = ['' => ''];
$range = range(1, $max);
$range = array_combine($range, $range);
return !$required ? $none + $range : $range;
@@ -349,7 +349,7 @@ class DateHelper {
* An array of hours in the selected format.
*/
public static function hours($format = 'H', $required = FALSE) {
- $hours = array();
+ $hours = [];
if ($format == 'h' || $format == 'g') {
$min = 1;
$max = 12;
@@ -362,7 +362,7 @@ class DateHelper {
$formatted = ($format == 'H' || $format == 'h') ? DrupalDateTime::datePad($i) : $i;
$hours[$i] = $formatted;
}
- $none = array('' => '');
+ $none = ['' => ''];
return !$required ? $none + $hours : $hours;
}
@@ -382,7 +382,7 @@ class DateHelper {
* An array of minutes in the selected format.
*/
public static function minutes($format = 'i', $required = FALSE, $increment = 1) {
- $minutes = array();
+ $minutes = [];
// Ensure $increment has a value so we don't loop endlessly.
if (empty($increment)) {
$increment = 1;
@@ -391,7 +391,7 @@ class DateHelper {
$formatted = $format == 'i' ? DrupalDateTime::datePad($i) : $i;
$minutes[$i] = $formatted;
}
- $none = array('' => '');
+ $none = ['' => ''];
return !$required ? $none + $minutes : $minutes;
}
@@ -411,7 +411,7 @@ class DateHelper {
* An array of seconds in the selected format.
*/
public static function seconds($format = 's', $required = FALSE, $increment = 1) {
- $seconds = array();
+ $seconds = [];
// Ensure $increment has a value so we don't loop endlessly.
if (empty($increment)) {
$increment = 1;
@@ -420,7 +420,7 @@ class DateHelper {
$formatted = $format == 's' ? DrupalDateTime::datePad($i) : $i;
$seconds[$i] = $formatted;
}
- $none = array('' => '');
+ $none = ['' => ''];
return !$required ? $none + $seconds : $seconds;
}
@@ -435,11 +435,11 @@ class DateHelper {
* An array of AM and PM options.
*/
public static function ampm($required = FALSE) {
- $none = array('' => '');
- $ampm = array(
- 'am' => t('am', array(), array('context' => 'ampm')),
- 'pm' => t('pm', array(), array('context' => 'ampm')),
- );
+ $none = ['' => ''];
+ $ampm = [
+ 'am' => t('am', [], ['context' => 'ampm']),
+ 'pm' => t('pm', [], ['context' => 'ampm']),
+ ];
return !$required ? $none + $ampm : $ampm;
}
diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
index faa0d022330..572a6e3c662 100644
--- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
+++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
@@ -48,7 +48,7 @@ class DrupalDateTime extends DateTimePlus {
* - debug: (optional) Boolean choice to leave debug values in the
* date object for debugging purposes. Defaults to FALSE.
*/
- public function __construct($time = 'now', $timezone = NULL, $settings = array()) {
+ public function __construct($time = 'now', $timezone = NULL, $settings = []) {
if (!isset($settings['langcode'])) {
$settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
}
@@ -87,7 +87,7 @@ class DrupalDateTime extends DateTimePlus {
* The formatted value of the date. Since the format may contain user input,
* this value should be escaped when output.
*/
- public function format($format, $settings = array()) {
+ public function format($format, $settings = []) {
$langcode = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode;
$value = '';
// Format the date and catch errors.
@@ -98,7 +98,7 @@ class DrupalDateTime extends DateTimePlus {
// Paired backslashes are isolated to prevent errors in
// read-ahead evaluation. The read-ahead expression ensures that
// A matches, but not \A.
- $format = preg_replace(array('/\\\\\\\\/', '/(?<!\\\\)([AaeDlMTF])/'), array("\xEF\\\\\\\\\xFF", "\xEF\\\\\$1\$1\xFF"), $format);
+ $format = preg_replace(['/\\\\\\\\/', '/(?<!\\\\)([AaeDlMTF])/'], ["\xEF\\\\\\\\\xFF", "\xEF\\\\\$1\$1\xFF"], $format);
// Call date_format().
$format = parent::format($format, $settings);
@@ -108,7 +108,7 @@ class DrupalDateTime extends DateTimePlus {
$code = $matches[1];
$string = $matches[2];
if (!isset($this->formatTranslationCache[$langcode][$code][$string])) {
- $options = array('langcode' => $langcode);
+ $options = ['langcode' => $langcode];
if ($code == 'F') {
$options['context'] = 'Long month name';
}
@@ -117,7 +117,7 @@ class DrupalDateTime extends DateTimePlus {
$this->formatTranslationCache[$langcode][$code][$string] = $string;
}
else {
- $this->formatTranslationCache[$langcode][$code][$string] = $this->t($string, array(), $options);
+ $this->formatTranslationCache[$langcode][$code][$string] = $this->t($string, [], $options);
}
}
return $this->formatTranslationCache[$langcode][$code][$string];
diff --git a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php
index 12ab03ba3f6..63b9abb871b 100644
--- a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php
+++ b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php
@@ -66,7 +66,7 @@ abstract class DateElementBase extends FormElement {
$min_year = min($value_year, $min_year);
$max_year = max($value_year, $max_year);
}
- return array($min_year, $max_year);
+ return [$min_year, $max_year];
}
}
diff --git a/core/lib/Drupal/Core/Datetime/Element/Datelist.php b/core/lib/Drupal/Core/Datetime/Element/Datelist.php
index f39d0a29047..59177e77e9b 100644
--- a/core/lib/Drupal/Core/Datetime/Element/Datelist.php
+++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php
@@ -19,22 +19,22 @@ class Datelist extends DateElementBase {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
- '#element_validate' => array(
- array($class, 'validateDatelist'),
- ),
- '#process' => array(
- array($class, 'processDatelist'),
- ),
+ '#element_validate' => [
+ [$class, 'validateDatelist'],
+ ],
+ '#process' => [
+ [$class, 'processDatelist'],
+ ],
'#theme' => 'datetime_form',
- '#theme_wrappers' => array('datetime_wrapper'),
- '#date_part_order' => array('year', 'month', 'day', 'hour', 'minute'),
+ '#theme_wrappers' => ['datetime_wrapper'],
+ '#date_part_order' => ['year', 'month', 'day', 'hour', 'minute'],
'#date_year_range' => '1900:2050',
'#date_increment' => 1,
- '#date_date_callbacks' => array(),
+ '#date_date_callbacks' => [],
'#date_timezone' => '',
- );
+ ];
}
/**
@@ -197,8 +197,8 @@ class Datelist extends DateElementBase {
$element['#tree'] = TRUE;
// Determine the order of the date elements.
- $order = !empty($element['#date_part_order']) ? $element['#date_part_order'] : array('year', 'month', 'day');
- $text_parts = !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array();
+ $order = !empty($element['#date_part_order']) ? $element['#date_part_order'] : ['year', 'month', 'day'];
+ $text_parts = !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : [];
// Output multi-selector for date.
foreach ($order as $part) {
@@ -248,7 +248,7 @@ class Datelist extends DateElementBase {
default:
$format = '';
- $options = array();
+ $options = [];
$title = '';
}
@@ -259,7 +259,7 @@ class Datelist extends DateElementBase {
}
$element['#attributes']['title'] = $title;
- $element[$part] = array(
+ $element[$part] = [
'#type' => in_array($part, $text_parts) ? 'textfield' : 'select',
'#title' => $title,
'#title_display' => 'invisible',
@@ -269,7 +269,7 @@ class Datelist extends DateElementBase {
'#required' => $element['#required'],
'#error_no_message' => FALSE,
'#empty_option' => $title,
- );
+ ];
}
// Allows custom callbacks to alter the element.
@@ -315,7 +315,7 @@ class Datelist extends DateElementBase {
}
elseif (!empty($all_empty)) {
foreach ($all_empty as $value) {
- $form_state->setError($element[$value], t('A value must be selected for %part.', array('%part' => $value)));
+ $form_state->setError($element[$value], t('A value must be selected for %part.', ['%part' => $value]));
}
}
else {
@@ -326,7 +326,7 @@ class Datelist extends DateElementBase {
}
// If the input is invalid and an error doesn't exist, set one.
elseif ($form_state->getError($element) === NULL) {
- $form_state->setError($element, t('The %field date is invalid.', array('%field' => !empty($element['#title']) ? $element['#title'] : '')));
+ $form_state->setError($element, t('The %field date is invalid.', ['%field' => !empty($element['#title']) ? $element['#title'] : '']));
}
}
}
diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
index 44a39490700..d00547535b1 100644
--- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php
+++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
@@ -38,30 +38,30 @@ class Datetime extends DateElementBase {
}
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
- '#element_validate' => array(
- array($class, 'validateDatetime'),
- ),
- '#process' => array(
- array($class, 'processDatetime'),
- array($class, 'processGroup'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderGroup'),
- ),
+ '#element_validate' => [
+ [$class, 'validateDatetime'],
+ ],
+ '#process' => [
+ [$class, 'processDatetime'],
+ [$class, 'processGroup'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderGroup'],
+ ],
'#theme' => 'datetime_form',
- '#theme_wrappers' => array('datetime_wrapper'),
+ '#theme_wrappers' => ['datetime_wrapper'],
'#date_date_format' => $date_format,
'#date_date_element' => 'date',
- '#date_date_callbacks' => array(),
+ '#date_date_callbacks' => [],
'#date_time_format' => $time_format,
'#date_time_element' => 'time',
- '#date_time_callbacks' => array(),
+ '#date_time_callbacks' => [],
'#date_year_range' => '1900:2050',
'#date_increment' => 1,
'#date_timezone' => '',
- );
+ ];
}
/**
@@ -88,27 +88,27 @@ class Datetime extends DateElementBase {
catch (\Exception $e) {
$date = NULL;
}
- $input = array(
+ $input = [
'date' => $date_input,
'time' => $time_input,
'object' => $date,
- );
+ ];
}
else {
$date = $element['#default_value'];
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
- $input = array(
+ $input = [
'date' => $date->format($element['#date_date_format']),
'time' => $date->format($element['#date_time_format']),
'object' => $date,
- );
+ ];
}
else {
- $input = array(
+ $input = [
'date' => '',
'time' => '',
'object' => NULL,
- );
+ ];
}
}
return $input;
@@ -213,7 +213,7 @@ class Datetime extends DateElementBase {
* The form element whose value has been processed.
*/
public static function processDatetime(&$element, FormStateInterface $form_state, &$complete_form) {
- $format_settings = array();
+ $format_settings = [];
// The value callback has populated the #value array.
$date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL;
@@ -235,10 +235,10 @@ class Datetime extends DateElementBase {
// Creating format examples on every individual date item is messy, and
// placeholders are invalid for HTML5 date and datetime, so an example
// format is appended to the title to appear in tooltips.
- $extra_attributes = array(
- 'title' => t('Date (e.g. @format)', array('@format' => static::formatExample($date_format))),
+ $extra_attributes = [
+ 'title' => t('Date (e.g. @format)', ['@format' => static::formatExample($date_format)]),
'type' => $element['#date_date_element'],
- );
+ ];
// Adds the HTML5 date attributes.
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
@@ -248,13 +248,13 @@ class Datetime extends DateElementBase {
$html5_max = clone($date);
$html5_max->setDate($range[1], 12, 31)->setTime(23, 59, 59);
- $extra_attributes += array(
+ $extra_attributes += [
'min' => $html5_min->format($date_format, $format_settings),
'max' => $html5_max->format($date_format, $format_settings),
- );
+ ];
}
- $element['date'] = array(
+ $element['date'] = [
'#type' => 'date',
'#title' => t('Date'),
'#title_display' => 'invisible',
@@ -264,7 +264,7 @@ class Datetime extends DateElementBase {
'#size' => max(12, strlen($element['#value']['date'])),
'#error_no_message' => TRUE,
'#date_date_format' => $element['#date_date_format'],
- );
+ ];
// Allows custom callbacks to alter the element.
if (!empty($element['#date_date_callbacks'])) {
@@ -282,12 +282,12 @@ class Datetime extends DateElementBase {
$time_value = !empty($date) ? $date->format($time_format, $format_settings) : $element['#value']['time'];
// Adds the HTML5 attributes.
- $extra_attributes = array(
- 'title' => t('Time (e.g. @format)', array('@format' => static::formatExample($time_format))),
+ $extra_attributes = [
+ 'title' => t('Time (e.g. @format)', ['@format' => static::formatExample($time_format)]),
'type' => $element['#date_time_element'],
'step' => $element['#date_increment'],
- );
- $element['time'] = array(
+ ];
+ $element['time'] = [
'#type' => 'date',
'#title' => t('Time'),
'#title_display' => 'invisible',
@@ -296,7 +296,7 @@ class Datetime extends DateElementBase {
'#required' => $element['#required'],
'#size' => 12,
'#error_no_message' => TRUE,
- );
+ ];
// Allows custom callbacks to alter the element.
if (!empty($element['#date_time_callbacks'])) {
@@ -343,7 +343,7 @@ class Datetime extends DateElementBase {
// If there's empty input and the field is required, set an error. A
// reminder of the required format in the message provides a good UX.
elseif (empty($input['date']) && empty($input['time']) && $element['#required']) {
- $form_state->setError($element, t('The %field date is required. Please enter a date in the format %format.', array('%field' => $title, '%format' => static::formatExample($format))));
+ $form_state->setError($element, t('The %field date is required. Please enter a date in the format %format.', ['%field' => $title, '%format' => static::formatExample($format)]));
}
else {
// If the date is valid, set it.
@@ -354,7 +354,7 @@ class Datetime extends DateElementBase {
// If the date is invalid, set an error. A reminder of the required
// format in the message provides a good UX.
else {
- $form_state->setError($element, t('The %field date is invalid. Please enter a date in the format %format.', array('%field' => $title, '%format' => static::formatExample($format))));
+ $form_state->setError($element, t('The %field date is invalid. Please enter a date in the format %format.', ['%field' => $title, '%format' => static::formatExample($format)]));
}
}
}
diff --git a/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php b/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
index d11cf54eb53..1ffa0109164 100644
--- a/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
+++ b/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php
@@ -30,12 +30,12 @@ class TimestampDatetimeWidget extends WidgetBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
$default_value = isset($items[$delta]->value) ? DrupalDateTime::createFromTimestamp($items[$delta]->value) : '';
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'datetime',
'#default_value' => $default_value,
'#date_year_range' => '1902:2037',
- );
- $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', array('%format' => Datetime::formatExample($date_format . ' ' . $time_format)));
+ ];
+ $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', ['%format' => Datetime::formatExample($date_format . ' ' . $time_format)]);
return $element;
}
diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php
index 52254a1bd4e..f636fb023f3 100644
--- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php
+++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php
@@ -20,7 +20,7 @@ class RegisterAccessChecksPass implements CompilerPassInterface {
// Add services tagged 'access_check' to the access_manager service.
$access_manager = $container->getDefinition('access_manager.check_provider');
foreach ($container->findTaggedServiceIds('access_check') as $id => $attributes) {
- $applies = array();
+ $applies = [];
$method = 'access';
$needs_incoming_request = FALSE;
foreach ($attributes as $attribute) {
@@ -34,7 +34,7 @@ class RegisterAccessChecksPass implements CompilerPassInterface {
$needs_incoming_request = TRUE;
}
}
- $access_manager->addMethodCall('addCheckService', array($id, $method, $applies, $needs_incoming_request));
+ $access_manager->addMethodCall('addCheckService', [$id, $method, $applies, $needs_incoming_request]);
}
}
diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
index a106cfcab74..5e13eea0260 100644
--- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
+++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
@@ -24,7 +24,7 @@ class RegisterServicesForDestructionPass implements CompilerPassInterface {
$definition = $container->getDefinition('kernel_destruct_subscriber');
$services = $container->findTaggedServiceIds('needs_destruction');
foreach ($services as $id => $attributes) {
- $definition->addMethodCall('registerService', array($id));
+ $definition->addMethodCall('registerService', [$id]);
}
}
diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php
index 7abf49f4985..f1ea8cd5b79 100644
--- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php
+++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php
@@ -24,7 +24,7 @@ class RegisterStreamWrappersPass implements CompilerPassInterface {
$class = $container->getDefinition($id)->getClass();
$scheme = $attributes[0]['scheme'];
- $stream_wrapper_manager->addMethodCall('addStreamWrapper', array($id, $class, $scheme));
+ $stream_wrapper_manager->addMethodCall('addStreamWrapper', [$id, $class, $scheme]);
}
}
diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php
index 3386e6af6bd..bb87d5e4842 100644
--- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php
+++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php
@@ -108,17 +108,17 @@ class TaggedHandlersPass implements CompilerPassInterface {
// Determine the ID.
if (!isset($interface)) {
- throw new LogicException(vsprintf("Service consumer '%s' class method %s::%s() has to type-hint an interface.", array(
+ throw new LogicException(vsprintf("Service consumer '%s' class method %s::%s() has to type-hint an interface.", [
$consumer_id,
$consumer->getClass(),
$method_name,
- )));
+ ]));
}
$interface = $interface->getName();
// Find all tagged handlers.
- $handlers = array();
- $extra_arguments = array();
+ $handlers = [];
+ $extra_arguments = [];
foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) {
// Validate the interface.
$handler = $container->getDefinition($id);
@@ -143,7 +143,7 @@ class TaggedHandlersPass implements CompilerPassInterface {
// Add a method call for each handler to the consumer service
// definition.
foreach ($handlers as $id => $priority) {
- $arguments = array();
+ $arguments = [];
$arguments[$interface_pos] = new Reference($id);
if (isset($priority_pos)) {
$arguments[$priority_pos] = $priority;
diff --git a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php
index ed2b35fb7dd..7f3cb5d6f98 100644
--- a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php
+++ b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php
@@ -14,13 +14,13 @@ trait DependencySerializationTrait {
*
* @var array
*/
- protected $_serviceIds = array();
+ protected $_serviceIds = [];
/**
* {@inheritdoc}
*/
public function __sleep() {
- $this->_serviceIds = array();
+ $this->_serviceIds = [];
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value) && isset($value->_serviceId)) {
@@ -52,7 +52,7 @@ trait DependencySerializationTrait {
foreach ($this->_serviceIds as $key => $service_id) {
$this->$key = $container->get($service_id);
}
- $this->_serviceIds = array();
+ $this->_serviceIds = [];
}
}
diff --git a/core/lib/Drupal/Core/Diff/DiffFormatter.php b/core/lib/Drupal/Core/Diff/DiffFormatter.php
index 8ebe2f4793d..a613711f59e 100644
--- a/core/lib/Drupal/Core/Diff/DiffFormatter.php
+++ b/core/lib/Drupal/Core/Diff/DiffFormatter.php
@@ -17,7 +17,7 @@ class DiffFormatter extends DiffFormatterBase {
*
* @var array
*/
- protected $rows = array();
+ protected $rows = [];
/**
* Creates a DiffFormatter to render diffs in a table.
@@ -35,7 +35,7 @@ class DiffFormatter extends DiffFormatterBase {
* {@inheritdoc}
*/
protected function _start_diff() {
- $this->rows = array();
+ $this->rows = [];
}
/**
@@ -49,16 +49,16 @@ class DiffFormatter extends DiffFormatterBase {
* {@inheritdoc}
*/
protected function _block_header($xbeg, $xlen, $ybeg, $ylen) {
- return array(
- array(
+ return [
+ [
'data' => $xbeg + $this->line_stats['offset']['x'],
'colspan' => 2,
- ),
- array(
+ ],
+ [
'data' => $ybeg + $this->line_stats['offset']['y'],
'colspan' => 2,
- )
- );
+ ]
+ ];
}
/**
@@ -86,16 +86,16 @@ class DiffFormatter extends DiffFormatterBase {
* An array representing a table row.
*/
protected function addedLine($line) {
- return array(
- array(
+ return [
+ [
'data' => '+',
'class' => 'diff-marker',
- ),
- array(
+ ],
+ [
'data' => ['#markup' => $line],
'class' => 'diff-context diff-addedline',
- )
- );
+ ]
+ ];
}
/**
@@ -108,16 +108,16 @@ class DiffFormatter extends DiffFormatterBase {
* An array representing a table row.
*/
protected function deletedLine($line) {
- return array(
- array(
+ return [
+ [
'data' => '-',
'class' => 'diff-marker',
- ),
- array(
+ ],
+ [
'data' => ['#markup' => $line],
'class' => 'diff-context diff-deletedline',
- )
- );
+ ]
+ ];
}
/**
@@ -130,13 +130,13 @@ class DiffFormatter extends DiffFormatterBase {
* An array representing a table row.
*/
protected function contextLine($line) {
- return array(
+ return [
' ',
- array(
+ [
'data' => ['#markup' => $line],
'class' => 'diff-context',
- )
- );
+ ]
+ ];
}
/**
@@ -146,10 +146,10 @@ class DiffFormatter extends DiffFormatterBase {
* An array representing a table row.
*/
protected function emptyLine() {
- return array(
+ return [
' ',
' ',
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Display/VariantBase.php b/core/lib/Drupal/Core/Display/VariantBase.php
index 5110d209bd1..4f7ce9e9ffc 100644
--- a/core/lib/Drupal/Core/Display/VariantBase.php
+++ b/core/lib/Drupal/Core/Display/VariantBase.php
@@ -69,9 +69,9 @@ abstract class VariantBase extends PluginBase implements VariantInterface {
* {@inheritdoc}
*/
public function getConfiguration() {
- return array(
+ return [
'id' => $this->getPluginId(),
- ) + $this->configuration;
+ ] + $this->configuration;
}
/**
@@ -86,11 +86,11 @@ abstract class VariantBase extends PluginBase implements VariantInterface {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'label' => '',
'uuid' => '',
'weight' => 0,
- );
+ ];
}
/**
@@ -104,13 +104,13 @@ abstract class VariantBase extends PluginBase implements VariantInterface {
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#description' => $this->t('The label for this display variant.'),
'#default_value' => $this->label(),
'#maxlength' => '255',
- );
+ ];
return $form;
}
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index b8130b30bb7..db773ed2832 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -142,7 +142,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
*
* @var \Drupal\Core\Extension\Extension[]
*/
- protected $moduleData = array();
+ protected $moduleData = [];
/**
* The class loader object.
@@ -387,7 +387,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
}
$http_host = $request->getHttpHost();
- $sites = array();
+ $sites = [];
include $app_root . '/sites/sites.php';
$uri = explode('/', $script_name);
@@ -480,7 +480,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
$this->booted = FALSE;
$this->container = NULL;
$this->moduleList = NULL;
- $this->moduleData = array();
+ $this->moduleData = [];
}
/**
@@ -569,21 +569,21 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* {@inheritdoc}
*/
public function discoverServiceProviders() {
- $this->serviceYamls = array(
- 'app' => array(),
- 'site' => array(),
- );
- $this->serviceProviderClasses = array(
- 'app' => array(),
- 'site' => array(),
- );
+ $this->serviceYamls = [
+ 'app' => [],
+ 'site' => [],
+ ];
+ $this->serviceProviderClasses = [
+ 'app' => [],
+ 'site' => [],
+ ];
$this->serviceYamls['app']['core'] = 'core/core.services.yml';
$this->serviceProviderClasses['app']['core'] = 'Drupal\Core\CoreServiceProvider';
// Retrieve enabled modules and register their namespaces.
if (!isset($this->moduleList)) {
$extensions = $this->getConfigStorage()->read('core.extension');
- $this->moduleList = isset($extensions['module']) ? $extensions['module'] : array();
+ $this->moduleList = isset($extensions['module']) ? $extensions['module'] : [];
}
$module_filenames = $this->getModuleFileNames();
$this->classLoaderAddMultiplePsr4($this->getModuleNamespacesPsr4($module_filenames));
@@ -732,7 +732,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
if (!$this->moduleData) {
// First, find profiles.
$listing = new ExtensionDiscovery($this->root);
- $listing->setProfileDirectories(array());
+ $listing->setProfileDirectories([]);
$all_profiles = $listing->scan('profile');
$profiles = array_intersect_key($all_profiles, $this->moduleList);
@@ -743,7 +743,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
if ($parent_profile && !isset($profiles[$parent_profile])) {
// In case both profile directories contain the same extension, the
// actual profile always has precedence.
- $profiles = array($parent_profile => $all_profiles[$parent_profile]) + $profiles;
+ $profiles = [$parent_profile => $all_profiles[$parent_profile]] + $profiles;
}
$profile_directories = array_map(function ($profile) {
@@ -763,7 +763,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* @todo Remove obsolete $module_list parameter. Only $module_filenames is
* needed.
*/
- public function updateModules(array $module_list, array $module_filenames = array()) {
+ public function updateModules(array $module_list, array $module_filenames = []) {
$pre_existing_module_namespaces = [];
if ($this->booted && is_array($this->moduleList)) {
$pre_existing_module_namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames());
@@ -814,7 +814,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* The cache key used for the service container.
*/
protected function getContainerCacheKey() {
- $parts = array('service_container', $this->environment, \Drupal::VERSION, Settings::get('deployment_identifier'), PHP_OS, serialize(Settings::get('container_yamls')));
+ $parts = ['service_container', $this->environment, \Drupal::VERSION, Settings::get('deployment_identifier'), PHP_OS, serialize(Settings::get('container_yamls'))];
return implode(':', $parts);
}
@@ -824,9 +824,9 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* @return array An array of kernel parameters
*/
protected function getKernelParameters() {
- return array(
+ return [
'kernel.environment' => $this->environment,
- );
+ ];
}
/**
@@ -1023,7 +1023,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
// Initialize our list of trusted HTTP Host headers to protect against
// header attacks.
- $host_patterns = Settings::get('trusted_host_patterns', array());
+ $host_patterns = Settings::get('trusted_host_patterns', []);
if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
throw new BadRequestHttpException('The provided host name is not valid for this server.');
@@ -1109,7 +1109,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* Returns service instances to persist from an old container to a new one.
*/
protected function getServicesToPersist(ContainerInterface $container) {
- $persist = array();
+ $persist = [];
foreach ($container->getParameter('persist_ids') as $id) {
// It's pointless to persist services not yet initialized.
if ($container->initialized($id)) {
@@ -1138,7 +1138,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
public function rebuildContainer() {
// Empty module properties and for them to be reloaded from scratch.
$this->moduleList = NULL;
- $this->moduleData = array();
+ $this->moduleData = [];
$this->containerNeedsRebuild = TRUE;
return $this->initializeContainer();
}
@@ -1170,7 +1170,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* @return ContainerInterface
*/
protected function attachSynthetic(ContainerInterface $container) {
- $persist = array();
+ $persist = [];
if (isset($this->container)) {
$persist = $this->getServicesToPersist($this->container);
}
@@ -1213,7 +1213,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
// - Element
// - Entity
// - Plugin
- foreach (array('Core', 'Component') as $parent_directory) {
+ foreach (['Core', 'Component'] as $parent_directory) {
$path = 'core/lib/Drupal/' . $parent_directory;
$parent_namespace = 'Drupal\\' . $parent_directory;
foreach (new \DirectoryIterator($this->root . '/' . $path) as $component) {
@@ -1238,7 +1238,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
$default_language_values = Language::$defaultValues;
if ($system = $this->getConfigStorage()->read('system.site')) {
if ($default_language_values['id'] != $system['langcode']) {
- $default_language_values = array('id' => $system['langcode']);
+ $default_language_values = ['id' => $system['langcode']];
}
}
$container->setParameter('language.default_values', $default_language_values);
@@ -1272,7 +1272,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
// the container during the lifetime of the kernel (e.g., during a kernel
// reboot). Include synthetic services, because by definition, they cannot
// be automatically reinstantiated. Also include services tagged to persist.
- $persist_ids = array();
+ $persist_ids = [];
foreach ($container->getDefinitions() as $id => $definition) {
// It does not make sense to persist the container itself, exclude it.
if ($id !== 'service_container' && ($definition->isSynthetic() || $definition->getTag('persist'))) {
@@ -1292,10 +1292,10 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
*/
protected function initializeServiceProviders() {
$this->discoverServiceProviders();
- $this->serviceProviders = array(
- 'app' => array(),
- 'site' => array(),
- );
+ $this->serviceProviders = [
+ 'app' => [],
+ 'site' => [],
+ ];
foreach ($this->serviceProviderClasses as $origin => $classes) {
foreach ($classes as $name => $class) {
if (!is_object($class)) {
@@ -1375,14 +1375,14 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* @return array
*/
protected function getModulesParameter() {
- $extensions = array();
+ $extensions = [];
foreach ($this->moduleList as $name => $weight) {
if ($data = $this->moduleData($name)) {
- $extensions[$name] = array(
+ $extensions[$name] = [
'type' => $data->getType(),
'pathname' => $data->getPathname(),
'filename' => $data->getExtensionFilename(),
- );
+ ];
}
}
return $extensions;
@@ -1396,7 +1396,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* respective *.info.yml file.
*/
protected function getModuleFileNames() {
- $filenames = array();
+ $filenames = [];
foreach ($this->moduleList as $module => $weight) {
if ($data = $this->moduleData($module)) {
$filenames[$module] = $data->getPathname();
@@ -1417,7 +1417,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* value is the PSR-4 base directory associated with the module namespace.
*/
protected function getModuleNamespacesPsr4($module_file_names) {
- $namespaces = array();
+ $namespaces = [];
foreach ($module_file_names as $module => $filename) {
$namespaces["Drupal\\$module"] = dirname($filename) . '/src';
}
@@ -1436,7 +1436,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
* the front controller, but may also be decorated; e.g.,
* \Symfony\Component\ClassLoader\ApcClassLoader.
*/
- protected function classLoaderAddMultiplePsr4(array $namespaces = array(), $class_loader = NULL) {
+ protected function classLoaderAddMultiplePsr4(array $namespaces = [], $class_loader = NULL) {
if ($class_loader === NULL) {
$class_loader = $this->classLoader;
}
diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php
index 862fbec59d0..c38fff5db93 100644
--- a/core/lib/Drupal/Core/DrupalKernelInterface.php
+++ b/core/lib/Drupal/Core/DrupalKernelInterface.php
@@ -100,7 +100,7 @@ interface DrupalKernelInterface extends HttpKernelInterface, ContainerAwareInter
* @param array $module_filenames
* List of module filenames, keyed by module name.
*/
- public function updateModules(array $module_list, array $module_filenames = array());
+ public function updateModules(array $module_list, array $module_filenames = []);
/**
* Force a container rebuild.
diff --git a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
index b74f21b5f2e..4e17852990f 100644
--- a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
+++ b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
@@ -31,7 +31,7 @@ class ConfigEntityType extends EntityType {
* {@inheritdoc}
*/
public function get() {
- $this->definition['group_label'] = new TranslatableMarkup('Configuration', array(), array('context' => 'Entity type group'));
+ $this->definition['group_label'] = new TranslatableMarkup('Configuration', [], ['context' => 'Entity type group']);
return parent::get();
}
diff --git a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php
index 4995d449f5f..0817c930f81 100644
--- a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php
+++ b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php
@@ -32,7 +32,7 @@ class ContentEntityType extends EntityType {
* {@inheritdoc}
*/
public function get() {
- $this->definition['group_label'] = new TranslatableMarkup('Content', array(), array('context' => 'Entity type group'));
+ $this->definition['group_label'] = new TranslatableMarkup('Content', [], ['context' => 'Entity type group']);
return parent::get();
}
diff --git a/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php b/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php
index c3949e70901..96bc6b127aa 100644
--- a/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php
+++ b/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php
@@ -60,7 +60,7 @@ class EntityReferenceSelection extends Plugin {
*
* @var array (optional)
*/
- public $entity_types = array();
+ public $entity_types = [];
/**
* The weight of the plugin in it's group.
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
index 70ea52094e4..971e551db46 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
@@ -32,14 +32,14 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
*
* @var array
*/
- protected $values = array();
+ protected $values = [];
/**
* The array of fields, each being an instance of FieldItemListInterface.
*
* @var array
*/
- protected $fields = array();
+ protected $fields = [];
/**
* Local cache for field definitions.
@@ -97,7 +97,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
*
* @var array
*/
- protected $translations = array();
+ protected $translations = [];
/**
* A flag indicating whether a translation object is being initialized.
@@ -125,14 +125,14 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
*
* @var array
*/
- protected $entityKeys = array();
+ protected $entityKeys = [];
/**
* Holds translatable entity keys such as the label.
*
* @var array
*/
- protected $translatableEntityKeys = array();
+ protected $translatableEntityKeys = [];
/**
* Whether entity validation was performed.
@@ -158,7 +158,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
/**
* {@inheritdoc}
*/
- public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) {
+ public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = []) {
$this->entityTypeId = $entity_type;
$this->entityKeys['bundle'] = $bundle ? $bundle : $this->entityTypeId;
$this->langcodeKey = $this->getEntityType()->getKey('langcode');
@@ -243,7 +243,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
// we return a mock language object to avoid disrupting the consuming
// code.
if (!isset($this->languages[$this->defaultLangcode])) {
- $this->languages[$this->defaultLangcode] = new Language(array('id' => $this->defaultLangcode));
+ $this->languages[$this->defaultLangcode] = new Language(['id' => $this->defaultLangcode]);
}
}
return $this->languages;
@@ -445,7 +445,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
$this->values[$name][$langcode] = $field->getValue();
}
}
- $this->fields = array();
+ $this->fields = [];
$this->fieldDefinitions = NULL;
$this->languages = NULL;
$this->clearTranslationCache();
@@ -554,7 +554,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
* {@inheritdoc}
*/
public function getFields($include_computed = TRUE) {
- $fields = array();
+ $fields = [];
foreach ($this->getFieldDefinitions() as $name => $definition) {
if ($include_computed || !$definition->isComputed()) {
$fields[$name] = $this->get($name);
@@ -609,7 +609,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
* {@inheritdoc}
*/
public function toArray() {
- $values = array();
+ $values = [];
foreach ($this->getFields() as $name => $property) {
$values[$name] = $property->getValue();
}
@@ -721,7 +721,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
// Update the default internal language cache.
$this->setDefaultLangcode();
if (isset($this->translations[$this->defaultLangcode])) {
- $message = SafeMarkup::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode));
+ $message = SafeMarkup::format('A translation already exists for the specified language (@langcode).', ['@langcode' => $this->defaultLangcode]);
throw new \InvalidArgumentException($message);
}
$this->updateFieldLangcodes($this->defaultLangcode);
@@ -732,7 +732,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
$items = $this->get($this->langcodeKey);
if ($items->value != $this->activeLangcode) {
$items->setValue($this->activeLangcode, FALSE);
- $message = SafeMarkup::format('The translation language cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode));
+ $message = SafeMarkup::format('The translation language cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
throw new \LogicException($message);
}
}
@@ -743,7 +743,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
// read-only. See https://www.drupal.org/node/2443991.
if (isset($this->values[$this->defaultLangcodeKey]) && $this->get($this->defaultLangcodeKey)->value != $this->isDefaultTranslation()) {
$this->get($this->defaultLangcodeKey)->setValue($this->isDefaultTranslation(), FALSE);
- $message = SafeMarkup::format('The default translation flag cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode));
+ $message = SafeMarkup::format('The default translation flag cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
throw new \LogicException($message);
}
break;
@@ -853,7 +853,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
/**
* {@inheritdoc}
*/
- public function addTranslation($langcode, array $values = array()) {
+ public function addTranslation($langcode, array $values = []) {
// Make sure we do not attempt to create a translation if an invalid
// language is specified or the entity cannot be translated.
$this->getLanguages();
@@ -1021,7 +1021,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
public function __unset($name) {
// Unsetting a field means emptying it.
if ($this->hasField($name)) {
- $this->get($name)->setValue(array());
+ $this->get($name)->setValue([]);
}
// For non-field properties, unset the internal value.
else {
@@ -1107,13 +1107,13 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
$this->fields = &$fields;
foreach ($this->fields as $name => $values) {
- $this->fields[$name] = array();
+ $this->fields[$name] = [];
// Untranslatable fields may have multiple references for the same field
// object keyed by language. To avoid creating different field objects
// we retain just the original value, as references will be recreated
// later as needed.
if (!$definitions[$name]->isTranslatable() && count($values) > 1) {
- $values = array_intersect_key($values, array(LanguageInterface::LANGCODE_DEFAULT => TRUE));
+ $values = array_intersect_key($values, [LanguageInterface::LANGCODE_DEFAULT => TRUE]);
}
foreach ($values as $langcode => $items) {
$this->fields[$name][$langcode] = clone $items;
@@ -1141,7 +1141,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
* {@inheritdoc}
*/
public function referencedEntities() {
- $referenced_entities = array();
+ $referenced_entities = [];
// Gather a list of referenced entities.
foreach ($this->getFields() as $field_items) {
@@ -1260,7 +1260,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
* {@inheritdoc}
*/
public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php
index 84d24de73e0..bc0bdf3a27a 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php
@@ -55,8 +55,8 @@ abstract class ContentEntityConfirmFormBase extends ContentEntityForm implements
$form['#title'] = $this->getQuestion();
$form['#attributes']['class'][] = 'confirmation';
- $form['description'] = array('#markup' => $this->getDescription());
- $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1);
+ $form['description'] = ['#markup' => $this->getDescription()];
+ $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1];
// By default, render the form using theme_confirm_form().
if (!isset($form['#theme'])) {
@@ -77,16 +77,16 @@ abstract class ContentEntityConfirmFormBase extends ContentEntityForm implements
* {@inheritdoc}
*/
protected function actions(array $form, FormStateInterface $form_state) {
- return array(
- 'submit' => array(
+ return [
+ 'submit' => [
'#type' => 'submit',
'#value' => $this->getConfirmText(),
- '#submit' => array(
- array($this, 'submitForm'),
- ),
- ),
+ '#submit' => [
+ [$this, 'submitForm'],
+ ],
+ ],
'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()),
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php
index ac94c26d00e..9a70ef5bc78 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php
@@ -34,19 +34,19 @@ class ContentEntityDeleteForm extends ContentEntityConfirmFormBase {
$languages[] = $language->getName();
}
- $form['deleted_translations'] = array(
+ $form['deleted_translations'] = [
'#theme' => 'item_list',
'#title' => $this->t('The following @entity-type translations will be deleted:', [
'@entity-type' => $entity->getEntityType()->getLowercaseLabel()
]),
'#items' => $languages,
- );
+ ];
$form['actions']['submit']['#value'] = $this->t('Delete all translations');
}
}
else {
- $form['actions']['submit']['#value'] = $this->t('Delete @language translation', array('@language' => $entity->language()->getName()));
+ $form['actions']['submit']['#value'] = $this->t('Delete @language translation', ['@language' => $entity->language()->getName()]);
}
return $form;
@@ -129,11 +129,11 @@ class ContentEntityDeleteForm extends ContentEntityConfirmFormBase {
$entity = $this->getEntity();
if (!$entity->isDefaultTranslation()) {
- return $this->t('Are you sure you want to delete the @language translation of the @entity-type %label?', array(
+ return $this->t('Are you sure you want to delete the @language translation of the @entity-type %label?', [
'@language' => $entity->language()->getName(),
'@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(),
'%label' => $this->getEntity()->label(),
- ));
+ ]);
}
return $this->traitGetQuestion();
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php
index 5d3379f619a..3dc00c9a993 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php
@@ -15,7 +15,7 @@ class ContentEntityNullStorage extends ContentEntityStorageBase {
* {@inheritdoc}
*/
public function loadMultiple(array $ids = NULL) {
- return array();
+ return [];
}
/**
@@ -47,8 +47,8 @@ class ContentEntityNullStorage extends ContentEntityStorageBase {
/**
* {@inheritdoc}
*/
- public function loadByProperties(array $values = array()) {
- return array();
+ public function loadByProperties(array $values = []) {
+ return [];
}
/**
@@ -104,7 +104,7 @@ class ContentEntityNullStorage extends ContentEntityStorageBase {
* {@inheritdoc}
*/
protected function readFieldItemsToPurge(FieldDefinitionInterface $field_definition, $batch_size) {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
index 2b3bbecf428..9d6b8d64f50 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
@@ -84,7 +84,7 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
}
$bundle = $values[$this->bundleKey];
}
- $entity = new $this->entityClass(array(), $this->entityTypeId, $bundle);
+ $entity = new $this->entityClass([], $this->entityTypeId, $bundle);
$this->initFieldValues($entity, $values);
return $entity;
}
@@ -605,11 +605,11 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
*/
protected function getFromPersistentCache(array &$ids = NULL) {
if (!$this->entityType->isPersistentlyCacheable() || empty($ids)) {
- return array();
+ return [];
}
- $entities = array();
+ $entities = [];
// Build the list of cache entries to retrieve.
- $cid_map = array();
+ $cid_map = [];
foreach ($ids as $id) {
$cid_map[$id] = $this->buildCacheId($id);
}
@@ -638,10 +638,10 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
return;
}
- $cache_tags = array(
+ $cache_tags = [
$this->entityTypeId . '_values',
'entity_field_info',
- );
+ ];
foreach ($entities as $id => $entity) {
$this->cacheBackend->set($this->buildCacheId($id), $entity, CacheBackendInterface::CACHE_PERMANENT, $cache_tags);
}
@@ -692,7 +692,7 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
*/
public function resetCache(array $ids = NULL) {
if ($ids) {
- $cids = array();
+ $cids = [];
foreach ($ids as $id) {
unset($this->entities[$id]);
$cids[] = $this->buildCacheId($id);
@@ -702,9 +702,9 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
}
}
else {
- $this->entities = array();
+ $this->entities = [];
if ($this->entityType->isPersistentlyCacheable()) {
- Cache::invalidateTags(array($this->entityTypeId . '_values'));
+ Cache::invalidateTags([$this->entityTypeId . '_values']);
}
}
}
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityType.php b/core/lib/Drupal/Core/Entity/ContentEntityType.php
index 6103a562919..0e26c3bb510 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityType.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityType.php
@@ -19,10 +19,10 @@ class ContentEntityType extends EntityType implements ContentEntityTypeInterface
*/
public function __construct($definition) {
parent::__construct($definition);
- $this->handlers += array(
+ $this->handlers += [
'storage' => 'Drupal\Core\Entity\Sql\SqlContentEntityStorage',
'view_builder' => 'Drupal\Core\Entity\EntityViewBuilder',
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/DependencyTrait.php b/core/lib/Drupal/Core/Entity/DependencyTrait.php
index f56a6a0a5f6..1ba2579d40b 100644
--- a/core/lib/Drupal/Core/Entity/DependencyTrait.php
+++ b/core/lib/Drupal/Core/Entity/DependencyTrait.php
@@ -12,7 +12,7 @@ trait DependencyTrait {
*
* @var array
*/
- protected $dependencies = array();
+ protected $dependencies = [];
/**
* Adds a dependency.
@@ -30,7 +30,7 @@ trait DependencyTrait {
*/
protected function addDependency($type, $name) {
if (empty($this->dependencies[$type])) {
- $this->dependencies[$type] = array($name);
+ $this->dependencies[$type] = [$name];
if (count($this->dependencies) > 1) {
// Ensure a consistent order of type keys.
ksort($this->dependencies);
diff --git a/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
index 7fa45a51fb0..38baa15fe56 100644
--- a/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
+++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
@@ -54,7 +54,7 @@ interface EntityDisplayInterface extends ConfigEntityInterface, EntityWithPlugin
*
* @return $this
*/
- public function setComponent($name, array $options = array());
+ public function setComponent($name, array $options = []);
/**
* Sets a component to be hidden.
diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
index 9c3e705bd37..3e10f4a1ccb 100644
--- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
+++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
@@ -31,7 +31,7 @@ class EntityAutocomplete extends Textfield {
// Apply default form element properties.
$info['#target_type'] = NULL;
$info['#selection_handler'] = 'default';
- $info['#selection_settings'] = array();
+ $info['#selection_settings'] = [];
$info['#tags'] = FALSE;
$info['#autocreate'] = NULL;
// This should only be set to FALSE if proper validation by the selection
@@ -42,8 +42,8 @@ class EntityAutocomplete extends Textfield {
// it's value is properly checked for access.
$info['#process_default_value'] = TRUE;
- $info['#element_validate'] = array(array($class, 'validateEntityAutocomplete'));
- array_unshift($info['#process'], array($class, 'processEntityAutocomplete'));
+ $info['#element_validate'] = [[$class, 'validateEntityAutocomplete']];
+ array_unshift($info['#process'], [$class, 'processEntityAutocomplete']);
return $info;
}
@@ -60,7 +60,7 @@ class EntityAutocomplete extends Textfield {
elseif (!empty($element['#default_value']) && !is_array($element['#default_value'])) {
// Convert the default value into an array for easier processing in
// static::getEntityLabels().
- $element['#default_value'] = array($element['#default_value']);
+ $element['#default_value'] = [$element['#default_value']];
}
if ($element['#default_value']) {
@@ -136,11 +136,11 @@ class EntityAutocomplete extends Textfield {
}
$element['#autocomplete_route_name'] = 'system.entity_autocomplete';
- $element['#autocomplete_route_parameters'] = array(
+ $element['#autocomplete_route_parameters'] = [
'target_type' => $element['#target_type'],
'selection_handler' => $element['#selection_handler'],
'selection_settings_key' => $selection_settings_key,
- );
+ ];
return $element;
}
@@ -152,11 +152,11 @@ class EntityAutocomplete extends Textfield {
$value = NULL;
if (!empty($element['#value'])) {
- $options = array(
+ $options = [
'target_type' => $element['#target_type'],
'handler' => $element['#selection_handler'],
'handler_settings' => $element['#selection_settings'],
- );
+ ];
/** @var /Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler */
$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance($options);
$autocreate = (bool) $element['#autocreate'] && $handler instanceof SelectionWithAutocreateInterface;
@@ -167,7 +167,7 @@ class EntityAutocomplete extends Textfield {
$value = $element['#value'];
}
else {
- $input_values = $element['#tags'] ? Tags::explode($element['#value']) : array($element['#value']);
+ $input_values = $element['#tags'] ? Tags::explode($element['#value']) : [$element['#value']];
foreach ($input_values as $input) {
$match = static::extractEntityIdFromAutocompleteInput($input);
@@ -178,17 +178,17 @@ class EntityAutocomplete extends Textfield {
}
if ($match !== NULL) {
- $value[] = array(
+ $value[] = [
'target_id' => $match,
- );
+ ];
}
elseif ($autocreate) {
/** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface $handler */
// Auto-create item. See an example of how this is handled in
// \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave().
- $value[] = array(
+ $value[] = [
'entity' => $handler->createNewEntity($element['#target_type'], $element['#autocreate']['bundle'], $input, $element['#autocreate']['uid']),
- );
+ ];
}
}
}
@@ -207,7 +207,7 @@ class EntityAutocomplete extends Textfield {
$valid_ids = $handler->validateReferenceableEntities($ids);
if ($invalid_ids = array_diff($ids, $valid_ids)) {
foreach ($invalid_ids as $invalid_id) {
- $form_state->setError($element, t('The referenced entity (%type: %id) does not exist.', array('%type' => $element['#target_type'], '%id' => $invalid_id)));
+ $form_state->setError($element, t('The referenced entity (%type: %id) does not exist.', ['%type' => $element['#target_type'], '%id' => $invalid_id]));
}
}
}
@@ -233,7 +233,7 @@ class EntityAutocomplete extends Textfield {
foreach ($invalid_new_entities as $entity) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
- $form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', array('%type' => $element['#target_type'], '%label' => $entity->label())));
+ $form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', ['%type' => $element['#target_type'], '%label' => $entity->label()]));
}
}
}
@@ -275,10 +275,10 @@ class EntityAutocomplete extends Textfield {
$entities = array_reduce($entities_by_bundle, function ($flattened, $bundle_entities) {
return $flattened + $bundle_entities;
}, []);
- $params = array(
+ $params = [
'%value' => $input,
'@value' => $input,
- );
+ ];
if (empty($entities)) {
if ($strict) {
// Error if there are no entities available for a required field.
@@ -292,12 +292,12 @@ class EntityAutocomplete extends Textfield {
}
elseif (count($entities) > 1) {
// More helpful error if there are only a few matching entities.
- $multiples = array();
+ $multiples = [];
foreach ($entities as $id => $name) {
$multiples[] = $name . ' (' . $id . ')';
}
$params['@id'] = $id;
- $form_state->setError($element, t('Multiple entities match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".', array('%multiple' => implode('", "', $multiples)) + $params));
+ $form_state->setError($element, t('Multiple entities match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".', ['%multiple' => implode('", "', $multiples)] + $params));
}
else {
// Take the one and only matching entity.
@@ -318,7 +318,7 @@ class EntityAutocomplete extends Textfield {
* A string of entity labels separated by commas.
*/
public static function getEntityLabels(array $entities) {
- $entity_labels = array();
+ $entity_labels = [];
foreach ($entities as $entity) {
// Use the special view label, since some entities allow the label to be
// viewed, even if the entity is not allowed to be viewed.
diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php
index 2c6dbc118b1..f36f74fe679 100644
--- a/core/lib/Drupal/Core/Entity/Entity.php
+++ b/core/lib/Drupal/Core/Entity/Entity.php
@@ -190,7 +190,7 @@ abstract class Entity implements EntityInterface {
if (isset($link_templates[$rel])) {
$route_parameters = $this->urlRouteParameters($rel);
- $route_name = "entity.{$this->entityTypeId}." . str_replace(array('-', 'drupal:'), array('_', ''), $rel);
+ $route_name = "entity.{$this->entityTypeId}." . str_replace(['-', 'drupal:'], ['_', ''], $rel);
$uri = new Url($route_name, $route_parameters);
}
else {
@@ -275,7 +275,7 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*/
- public function url($rel = 'canonical', $options = array()) {
+ public function url($rel = 'canonical', $options = []) {
// While self::toUrl() will throw an exception if the entity has no id,
// the expected result for a URL is always a string.
if ($this->id() === NULL || !$this->hasLinkTemplate($rel)) {
@@ -353,7 +353,7 @@ abstract class Entity implements EntityInterface {
}
// Make sure we return a proper language object.
$langcode = !empty($this->langcode) ? $this->langcode : LanguageInterface::LANGCODE_NOT_SPECIFIED;
- $language = new Language(array('id' => $langcode));
+ $language = new Language(['id' => $langcode]);
return $language;
}
@@ -369,7 +369,7 @@ abstract class Entity implements EntityInterface {
*/
public function delete() {
if (!$this->isNew()) {
- $this->entityManager()->getStorage($this->entityTypeId)->delete(array($this->id() => $this));
+ $this->entityManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]);
}
}
@@ -452,7 +452,7 @@ abstract class Entity implements EntityInterface {
* {@inheritdoc}
*/
public function referencedEntities() {
- return array();
+ return [];
}
/**
@@ -510,7 +510,7 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*/
- public static function create(array $values = array()) {
+ public static function create(array $values = []) {
$entity_manager = \Drupal::entityManager();
return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->create($values);
}
@@ -585,7 +585,7 @@ abstract class Entity implements EntityInterface {
* {@inheritdoc}
*/
public function toArray() {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
index cd90ecce053..faa6d0d6af2 100644
--- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
+++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
@@ -95,23 +95,23 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
}
// Else create a fresh runtime object.
if (empty($display)) {
- $display = $storage->create(array(
+ $display = $storage->create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $form_mode,
'status' => TRUE,
- ));
+ ]);
}
// Let the display know which form mode was originally requested.
$display->originalMode = $form_mode;
// Let modules alter the display.
- $display_context = array(
+ $display_context = [
'entity_type' => $entity_type,
'bundle' => $bundle,
'form_mode' => $form_mode,
- );
+ ];
\Drupal::moduleHandler()->alter('entity_form_display', $display, $display_context);
return $display;
@@ -136,13 +136,13 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
// Instantiate the widget object from the stored display properties.
if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this->getFieldDefinition($field_name))) {
- $widget = $this->pluginManager->getInstance(array(
+ $widget = $this->pluginManager->getInstance([
'field_definition' => $definition,
'form_mode' => $this->originalMode,
// No need to prepare, defaults have been merged in setComponent().
'prepare' => FALSE,
'configuration' => $configuration
- ));
+ ]);
}
else {
$widget = NULL;
@@ -158,7 +158,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
*/
public function buildForm(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) {
// Set #parents to 'top-level' by default.
- $form += array('#parents' => array());
+ $form += ['#parents' => []];
// Let each widget generate the form elements.
foreach ($this->getComponents() as $name => $options) {
@@ -185,7 +185,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
$this->renderer->addCacheableDependency($form, $this);
// Add a process callback so we can assign weights and hide extra fields.
- $form['#process'][] = array($this, 'processForm');
+ $form['#process'][] = [$this, 'processForm'];
}
/**
@@ -203,7 +203,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
// Hide extra fields.
$extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle);
- $extra_fields = isset($extra_fields['form']) ? $extra_fields['form'] : array();
+ $extra_fields = isset($extra_fields['form']) ? $extra_fields['form'] : [];
foreach ($extra_fields as $extra_field => $info) {
if (!$this->getComponent($extra_field)) {
$element[$extra_field]['#access'] = FALSE;
@@ -216,7 +216,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
* {@inheritdoc}
*/
public function extractFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) {
- $extracted = array();
+ $extracted = [];
foreach ($entity as $name => $items) {
if ($widget = $this->getRenderer($name)) {
$widget->extractFormValues($items, $form, $form_state);
@@ -316,19 +316,19 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
* {@inheritdoc}
*/
public function getPluginCollections() {
- $configurations = array();
+ $configurations = [];
foreach ($this->getComponents() as $field_name => $configuration) {
if (!empty($configuration['type']) && ($field_definition = $this->getFieldDefinition($field_name))) {
- $configurations[$configuration['type']] = $configuration + array(
+ $configurations[$configuration['type']] = $configuration + [
'field_definition' => $field_definition,
'form_mode' => $this->mode,
- );
+ ];
}
}
- return array(
+ return [
'widgets' => new EntityDisplayPluginCollection($this->pluginManager, $configurations)
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
index a6b83cf2c47..74b15b65f47 100644
--- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
+++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
@@ -70,12 +70,12 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
*/
public static function collectRenderDisplays($entities, $view_mode) {
if (empty($entities)) {
- return array();
+ return [];
}
// Collect entity type and bundles.
$entity_type = current($entities)->getEntityTypeId();
- $bundles = array();
+ $bundles = [];
foreach ($entities as $entity) {
$bundles[$entity->bundle()] = TRUE;
}
@@ -84,7 +84,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
// For each bundle, check the existence and status of:
// - the display for the view mode,
// - the 'default' display.
- $candidate_ids = array();
+ $candidate_ids = [];
foreach ($bundles as $bundle) {
if ($view_mode != 'default') {
$candidate_ids[$bundle][] = $entity_type . '.' . $bundle . '.' . $view_mode;
@@ -97,7 +97,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
->execute();
// For each bundle, select the first valid candidate display, if any.
- $load_ids = array();
+ $load_ids = [];
foreach ($bundles as $bundle) {
foreach ($candidate_ids[$bundle] as $candidate_id) {
if (isset($results[$candidate_id])) {
@@ -111,30 +111,30 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
$storage = \Drupal::entityManager()->getStorage('entity_view_display');
$displays = $storage->loadMultiple($load_ids);
- $displays_by_bundle = array();
+ $displays_by_bundle = [];
foreach ($bundles as $bundle) {
// Use the selected display if any, or create a fresh runtime object.
if (isset($load_ids[$bundle])) {
$display = $displays[$load_ids[$bundle]];
}
else {
- $display = $storage->create(array(
+ $display = $storage->create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $view_mode,
'status' => TRUE,
- ));
+ ]);
}
// Let the display know which view mode was originally requested.
$display->originalMode = $view_mode;
// Let modules alter the display.
- $display_context = array(
+ $display_context = [
'entity_type' => $entity_type,
'bundle' => $bundle,
'view_mode' => $view_mode,
- );
+ ];
\Drupal::moduleHandler()->alter('entity_view_display', $display, $display_context);
$displays_by_bundle[$bundle] = $display;
@@ -159,7 +159,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
* @see \Drupal\Core\Entity\Entity\EntityViewDisplay::collectRenderDisplays()
*/
public static function collectRenderDisplay(FieldableEntityInterface $entity, $view_mode) {
- $displays = static::collectRenderDisplays(array($entity), $view_mode);
+ $displays = static::collectRenderDisplays([$entity], $view_mode);
return $displays[$entity->bundle()];
}
@@ -193,13 +193,13 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
// Instantiate the formatter object from the stored display properties.
if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this->getFieldDefinition($field_name))) {
- $formatter = $this->pluginManager->getInstance(array(
+ $formatter = $this->pluginManager->getInstance([
'field_definition' => $definition,
'view_mode' => $this->originalMode,
// No need to prepare, defaults have been merged in setComponent().
'prepare' => FALSE,
'configuration' => $configuration
- ));
+ ]);
}
else {
$formatter = NULL;
@@ -214,7 +214,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
* {@inheritdoc}
*/
public function build(FieldableEntityInterface $entity) {
- $build = $this->buildMultiple(array($entity));
+ $build = $this->buildMultiple([$entity]);
return $build[0];
}
@@ -222,9 +222,9 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
* {@inheritdoc}
*/
public function buildMultiple(array $entities) {
- $build_list = array();
+ $build_list = [];
foreach ($entities as $key => $entity) {
- $build_list[$key] = array();
+ $build_list[$key] = [];
}
// Run field formatters.
@@ -232,7 +232,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
if ($formatter = $this->getRenderer($name)) {
// Group items across all entities and pass them to the formatter's
// prepareView() method.
- $grouped_items = array();
+ $grouped_items = [];
foreach ($entities as $id => $entity) {
$items = $entity->get($name);
$items->filterEmptyItems();
@@ -272,11 +272,11 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
}
// Let other modules alter the renderable array.
- $context = array(
+ $context = [
'entity' => $entity,
'view_mode' => $this->originalMode,
'display' => $this,
- );
+ ];
\Drupal::moduleHandler()->alter('entity_display_build', $build_list[$id], $context);
}
@@ -287,19 +287,19 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn
* {@inheritdoc}
*/
public function getPluginCollections() {
- $configurations = array();
+ $configurations = [];
foreach ($this->getComponents() as $field_name => $configuration) {
if (!empty($configuration['type']) && ($field_definition = $this->getFieldDefinition($field_name))) {
- $configurations[$configuration['type']] = $configuration + array(
+ $configurations[$configuration['type']] = $configuration + [
'field_definition' => $field_definition,
'view_mode' => $this->originalMode,
- );
+ ];
}
}
- return array(
+ return [
'formatters' => new EntityDisplayPluginCollection($this->pluginManager, $configurations)
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
index 15306934692..d1d43ee900b 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
@@ -18,7 +18,7 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
*
* @var array
*/
- protected $accessCache = array();
+ protected $accessCache = [];
/**
* The entity type ID of the access control handler instance.
@@ -207,18 +207,18 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
* {@inheritdoc}
*/
public function resetCache() {
- $this->accessCache = array();
+ $this->accessCache = [];
}
/**
* {@inheritdoc}
*/
- public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE) {
+ public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE) {
$account = $this->prepareUser($account);
- $context += array(
+ $context += [
'entity_type_id' => $this->entityTypeId,
'langcode' => LanguageInterface::LANGCODE_DEFAULT,
- );
+ ];
$cid = $entity_bundle ? 'create:' . $entity_bundle : 'create';
if (($access = $this->getCache($cid, 'create', $context['langcode'], $account)) !== NULL) {
@@ -236,8 +236,8 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
// - No modules say to deny access.
// - At least one module says to grant access.
$access = array_merge(
- $this->moduleHandler()->invokeAll('entity_create_access', array($account, $context, $entity_bundle)),
- $this->moduleHandler()->invokeAll($this->entityTypeId . '_create_access', array($account, $context, $entity_bundle))
+ $this->moduleHandler()->invokeAll('entity_create_access', [$account, $context, $entity_bundle]),
+ $this->moduleHandler()->invokeAll($this->entityTypeId . '_create_access', [$account, $context, $entity_bundle])
);
$return = $this->processAccessHookResults($access);
@@ -312,19 +312,19 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
// Invoke hook and collect grants/denies for field access from other
// modules. Our default access flag is masked under the ':default' key.
- $grants = array(':default' => $default);
+ $grants = [':default' => $default];
$hook_implementations = $this->moduleHandler()->getImplementations('entity_field_access');
foreach ($hook_implementations as $module) {
- $grants = array_merge($grants, array($module => $this->moduleHandler()->invoke($module, 'entity_field_access', array($operation, $field_definition, $account, $items))));
+ $grants = array_merge($grants, [$module => $this->moduleHandler()->invoke($module, 'entity_field_access', [$operation, $field_definition, $account, $items])]);
}
// Also allow modules to alter the returned grants/denies.
- $context = array(
+ $context = [
'operation' => $operation,
'field_definition' => $field_definition,
'items' => $items,
'account' => $account,
- );
+ ];
$this->moduleHandler()->alter('entity_field_access', $grants, $context);
$result = $this->processAccessHookResults($grants);
diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php
index 0bec9c20397..5532996b2d9 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php
@@ -60,7 +60,7 @@ interface EntityAccessControlHandlerInterface {
* returned, i.e. TRUE means access is explicitly allowed, FALSE means
* access is either explicitly forbidden or "no opinion".
*/
- public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE);
+ public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE);
/**
* Clears all cached access checks.
diff --git a/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php b/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php
index 01a29b26bb8..55372f9e718 100644
--- a/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php
+++ b/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php
@@ -50,13 +50,13 @@ class EntityAutocompleteMatcher {
* @see \Drupal\system\Controller\EntityAutocompleteController
*/
public function getMatches($target_type, $selection_handler, $selection_settings, $string = '') {
- $matches = array();
+ $matches = [];
- $options = array(
+ $options = [
'target_type' => $target_type,
'handler' => $selection_handler,
'handler_settings' => $selection_settings,
- );
+ ];
$handler = $this->selectionManager->getInstance($options);
if (isset($string)) {
@@ -73,7 +73,7 @@ class EntityAutocompleteMatcher {
$key = preg_replace('/\s\s+/', ' ', str_replace("\n", '', trim(Html::decodeEntities(strip_tags($key)))));
// Names containing commas or quotes must be wrapped in quotes.
$key = Tags::encode($key);
- $matches[] = array('value' => $key, 'label' => $label);
+ $matches[] = ['value' => $key, 'label' => $label];
}
}
}
diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php
index 759183b9048..d8c39e439fa 100644
--- a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php
@@ -57,8 +57,8 @@ abstract class EntityConfirmFormBase extends EntityForm implements ConfirmFormIn
$form['#title'] = $this->getQuestion();
$form['#attributes']['class'][] = 'confirmation';
- $form['description'] = array('#markup' => $this->getDescription());
- $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1);
+ $form['description'] = ['#markup' => $this->getDescription()];
+ $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1];
// By default, render the form using theme_confirm_form().
if (!isset($form['#theme'])) {
@@ -71,16 +71,16 @@ abstract class EntityConfirmFormBase extends EntityForm implements ConfirmFormIn
* {@inheritdoc}
*/
protected function actions(array $form, FormStateInterface $form_state) {
- return array(
- 'submit' => array(
+ return [
+ 'submit' => [
'#type' => 'submit',
'#value' => $this->getConfirmText(),
- '#submit' => array(
- array($this, 'submitForm'),
- ),
- ),
+ '#submit' => [
+ [$this, 'submitForm'],
+ ],
+ ],
'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()),
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
index 927dcd340d4..c3404b6fa7f 100644
--- a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
+++ b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
@@ -47,7 +47,7 @@ class EntityConstraintViolationList extends ConstraintViolationList implements E
* @param array $violations
* The array of violations.
*/
- public function __construct(FieldableEntityInterface $entity, array $violations = array()) {
+ public function __construct(FieldableEntityInterface $entity, array $violations = []) {
parent::__construct($violations);
$this->entity = $entity;
}
@@ -156,7 +156,7 @@ class EntityConstraintViolationList extends ConstraintViolationList implements E
* {@inheritdoc}
*/
public function filterByFieldAccess(AccountInterface $account = NULL) {
- $filtered_fields = array();
+ $filtered_fields = [];
foreach ($this->getFieldNames() as $field_name) {
if (!$this->entity->get($field_name)->access('edit', $account)) {
$filtered_fields[] = $field_name;
diff --git a/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php
index 3ead817353f..70dec2c27e3 100644
--- a/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php
@@ -42,7 +42,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte
* {@inheritdoc}
*/
public function getChangeSummary() {
- $summary = array();
+ $summary = [];
foreach ($this->getChangeList() as $entity_type_id => $change_list) {
// Process entity type definition changes.
@@ -259,7 +259,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte
*/
protected function getChangeList() {
$this->entityManager->useCaches(FALSE);
- $change_list = array();
+ $change_list = [];
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
$original = $this->entityManager->getLastInstalledDefinition($entity_type_id);
@@ -275,7 +275,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte
}
if ($this->entityManager->getStorage($entity_type_id) instanceof DynamicallyFieldableEntityStorageInterface) {
- $field_changes = array();
+ $field_changes = [];
$storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
$original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id);
diff --git a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php
index 8d5352bf2ad..2faf45c44a3 100644
--- a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php
+++ b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php
@@ -44,10 +44,10 @@ trait EntityDeleteFormTrait {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete the @entity-type %label?', array(
+ return $this->t('Are you sure you want to delete the @entity-type %label?', [
'@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(),
'%label' => $this->getEntity()->label(),
- ));
+ ]);
}
/**
@@ -65,10 +65,10 @@ trait EntityDeleteFormTrait {
*/
protected function getDeletionMessage() {
$entity = $this->getEntity();
- return $this->t('The @entity-type %label has been deleted.', array(
+ return $this->t('The @entity-type %label has been deleted.', [
'@entity-type' => $entity->getEntityType()->getLowercaseLabel(),
'%label' => $entity->label(),
- ));
+ ]);
}
/**
@@ -109,10 +109,10 @@ trait EntityDeleteFormTrait {
*/
protected function logDeletionMessage() {
$entity = $this->getEntity();
- $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label has been deleted.', array(
+ $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label has been deleted.', [
'@entity-type' => $entity->getEntityType()->getLowercaseLabel(),
'%label' => $entity->label(),
- ));
+ ]);
}
/**
diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
index b6c73e55506..ca106b290fe 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -69,14 +69,14 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
*
* @var array
*/
- protected $content = array();
+ protected $content = [];
/**
* List of components that are set to be hidden.
*
* @var array
*/
- protected $hidden = array();
+ protected $hidden = [];
/**
* The original view or form mode that was requested (case of view/form modes
@@ -91,7 +91,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
*
* @var array
*/
- protected $plugins = array();
+ protected $plugins = [];
/**
* Context in which this entity will be used (e.g. 'view', 'form').
@@ -158,14 +158,14 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
// Fill in defaults for extra fields.
$context = $this->displayContext == 'view' ? 'display' : $this->displayContext;
$extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle);
- $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : array();
+ $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : [];
foreach ($extra_fields as $name => $definition) {
if (!isset($this->content[$name]) && !isset($this->hidden[$name])) {
// Extra fields are visible by default unless they explicitly say so.
if (!isset($definition['visible']) || $definition['visible'] == TRUE) {
- $this->content[$name] = array(
+ $this->content[$name] = [
'weight' => $definition['weight']
- );
+ ];
}
else {
$this->hidden[$name] = TRUE;
@@ -359,7 +359,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
/**
* {@inheritdoc}
*/
- public function setComponent($name, array $options = array()) {
+ public function setComponent($name, array $options = []) {
// If no weight specified, make sure the field sinks at the bottom.
if (!isset($options['weight'])) {
$max = $this->getHighestWeight();
@@ -396,7 +396,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
* {@inheritdoc}
*/
public function getHighestWeight() {
- $weights = array();
+ $weights = [];
// Collect weights for the components in the display.
foreach ($this->content as $options) {
@@ -406,7 +406,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
}
// Let other modules feedback about their own additions.
- $weights = array_merge($weights, \Drupal::moduleHandler()->invokeAll('field_info_max_weight', array($this->targetEntityType, $this->bundle, $this->displayContext, $this->mode)));
+ $weights = array_merge($weights, \Drupal::moduleHandler()->invokeAll('field_info_max_weight', [$this->targetEntityType, $this->bundle, $this->displayContext, $this->mode]));
return $weights ? max($weights) : NULL;
}
@@ -428,7 +428,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
// For "official" view modes and form modes, ignore fields whose
// definition states they should not be displayed.
if ($this->mode !== static::CUSTOM_MODE) {
- $definitions = array_filter($definitions, array($this, 'fieldHasDisplayOptions'));
+ $definitions = array_filter($definitions, [$this, 'fieldHasDisplayOptions']);
}
$this->fieldDefinitions = $definitions;
}
diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php b/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php
index 0ee431738d9..d959881eac5 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php
@@ -187,7 +187,7 @@ class EntityDisplayRepository implements EntityDisplayRepositoryInterface {
* An array of display mode labels, keyed by the display mode ID.
*/
protected function getDisplayModeOptions($display_type, $entity_type_id) {
- $options = array('default' => t('Default'));
+ $options = ['default' => t('Default')];
foreach ($this->getDisplayModesByEntityType($display_type, $entity_type_id) as $mode => $settings) {
$options[$mode] = $settings['label'];
}
@@ -213,7 +213,7 @@ class EntityDisplayRepository implements EntityDisplayRepositoryInterface {
// Filter out modes for which the entity display is disabled
// (or non-existent).
- $load_ids = array();
+ $load_ids = [];
// Get the list of available entity displays for the current bundle.
foreach (array_keys($options) as $mode) {
$load_ids[] = $entity_type_id . '.' . $bundle . '.' . $mode;
diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php
index b4f6bd6f022..35062185e9f 100644
--- a/core/lib/Drupal/Core/Entity/EntityForm.php
+++ b/core/lib/Drupal/Core/Entity/EntityForm.php
@@ -204,9 +204,9 @@ class EntityForm extends FormBase implements EntityFormInterface {
$count = 0;
foreach (Element::children($element) as $action) {
- $element[$action] += array(
+ $element[$action] += [
'#weight' => ++$count * 5,
- );
+ ];
}
if (!empty($element)) {
@@ -226,11 +226,11 @@ class EntityForm extends FormBase implements EntityFormInterface {
// @todo Consider renaming the action key from submit to save. The impacts
// are hard to predict. For example, see
// \Drupal\language\Element\LanguageConfiguration::processLanguageConfiguration().
- $actions['submit'] = array(
+ $actions['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
- '#submit' => array('::submitForm', '::save'),
- );
+ '#submit' => ['::submitForm', '::save'],
+ ];
if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('delete-form')) {
$route_info = $this->entity->urlInfo('delete-form');
@@ -239,14 +239,14 @@ class EntityForm extends FormBase implements EntityFormInterface {
$query['destination'] = $this->getRequest()->query->get('destination');
$route_info->setOption('query', $query);
}
- $actions['delete'] = array(
+ $actions['delete'] = [
'#type' => 'link',
'#title' => $this->t('Delete'),
'#access' => $this->entity->access('delete'),
- '#attributes' => array(
- 'class' => array('button', 'button--danger'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['button', 'button--danger'],
+ ],
+ ];
$actions['delete']['#url'] = $route_info;
}
@@ -294,7 +294,7 @@ class EntityForm extends FormBase implements EntityFormInterface {
// properties.
if (isset($form['#entity_builders'])) {
foreach ($form['#entity_builders'] as $function) {
- call_user_func_array($form_state->prepareCallback($function), array($entity->getEntityTypeId(), $entity, &$form, &$form_state));
+ call_user_func_array($form_state->prepareCallback($function), [$entity->getEntityTypeId(), $entity, &$form, &$form_state]);
}
}
@@ -391,7 +391,7 @@ class EntityForm extends FormBase implements EntityFormInterface {
if (function_exists($function)) {
// Ensure we pass an updated translation object and form display at
// each invocation, since they depend on form state which is alterable.
- $args = array($this->entity, $this->operation, &$form_state);
+ $args = [$this->entity, $this->operation, &$form_state];
call_user_func_array($function, $args);
}
}
diff --git a/core/lib/Drupal/Core/Entity/EntityFormBuilder.php b/core/lib/Drupal/Core/Entity/EntityFormBuilder.php
index ff4b9178bc7..d5f0baf00f0 100644
--- a/core/lib/Drupal/Core/Entity/EntityFormBuilder.php
+++ b/core/lib/Drupal/Core/Entity/EntityFormBuilder.php
@@ -40,7 +40,7 @@ class EntityFormBuilder implements EntityFormBuilderInterface {
/**
* {@inheritdoc}
*/
- public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array()) {
+ public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []) {
$form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation);
$form_object->setEntity($entity);
diff --git a/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php b/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php
index bfcead12b37..2265cd0ff6a 100644
--- a/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php
@@ -53,6 +53,6 @@ interface EntityFormBuilderInterface {
* @see \Drupal\Core\Entity\EntityTypeInterface::setFormClass()
* @see system_entity_type_build()
*/
- public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array());
+ public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []);
}
diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php
index 3a38e072dd6..8890fb7f34c 100644
--- a/core/lib/Drupal/Core/Entity/EntityInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityInterface.php
@@ -112,7 +112,7 @@ interface EntityInterface extends AccessibleInterface, CacheableDependencyInterf
*
* @see \Drupal\Core\Entity\EntityInterface::toUrl
*/
- public function urlInfo($rel = 'canonical', array $options = array());
+ public function urlInfo($rel = 'canonical', array $options = []);
/**
* Gets the URL object for the entity.
@@ -150,7 +150,7 @@ interface EntityInterface extends AccessibleInterface, CacheableDependencyInterf
* @throws \Drupal\Core\Entity\EntityMalformedException
* @throws \Drupal\Core\Entity\Exception\UndefinedLinkTemplateException
*/
- public function toUrl($rel = 'canonical', array $options = array());
+ public function toUrl($rel = 'canonical', array $options = []);
/**
* Gets the public URL for this entity.
@@ -169,7 +169,7 @@ interface EntityInterface extends AccessibleInterface, CacheableDependencyInterf
*
* @see \Drupal\Core\Entity\EntityInterface::toUrl
*/
- public function url($rel = 'canonical', $options = array());
+ public function url($rel = 'canonical', $options = []);
/**
* Deprecated way of generating a link to the entity. See toLink().
@@ -264,7 +264,7 @@ interface EntityInterface extends AccessibleInterface, CacheableDependencyInterf
* @return static
* The entity object.
*/
- public static function create(array $values = array());
+ public static function create(array $values = []);
/**
* Saves an entity permanently.
diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php
index b9c8db3d04a..7f46915ae98 100644
--- a/core/lib/Drupal/Core/Entity/EntityListBuilder.php
+++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php
@@ -120,7 +120,7 @@ class EntityListBuilder extends EntityHandlerBase implements EntityListBuilderIn
*/
public function getOperations(EntityInterface $entity) {
$operations = $this->getDefaultOperations($entity);
- $operations += $this->moduleHandler()->invokeAll('entity_operation', array($entity));
+ $operations += $this->moduleHandler()->invokeAll('entity_operation', [$entity]);
$this->moduleHandler->alter('entity_operation', $operations, $entity);
uasort($operations, '\Drupal\Component\Utility\SortArray::sortByWeightElement');
@@ -138,20 +138,20 @@ class EntityListBuilder extends EntityHandlerBase implements EntityListBuilderIn
* self::getOperations().
*/
protected function getDefaultOperations(EntityInterface $entity) {
- $operations = array();
+ $operations = [];
if ($entity->access('update') && $entity->hasLinkTemplate('edit-form')) {
- $operations['edit'] = array(
+ $operations['edit'] = [
'title' => $this->t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo('edit-form'),
- );
+ ];
}
if ($entity->access('delete') && $entity->hasLinkTemplate('delete-form')) {
- $operations['delete'] = array(
+ $operations['delete'] = [
'title' => $this->t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo('delete-form'),
- );
+ ];
}
return $operations;
@@ -198,10 +198,10 @@ class EntityListBuilder extends EntityHandlerBase implements EntityListBuilderIn
* @see \Drupal\Core\Entity\EntityListBuilder::buildRow()
*/
public function buildOperations(EntityInterface $entity) {
- $build = array(
+ $build = [
'#type' => 'operations',
'#links' => $this->getOperations($entity),
- );
+ ];
return $build;
}
@@ -214,17 +214,17 @@ class EntityListBuilder extends EntityHandlerBase implements EntityListBuilderIn
* @todo Add a link to add a new item to the #empty text.
*/
public function render() {
- $build['table'] = array(
+ $build['table'] = [
'#type' => 'table',
'#header' => $this->buildHeader(),
'#title' => $this->getTitle(),
- '#rows' => array(),
- '#empty' => $this->t('There is no @label yet.', array('@label' => $this->entityType->getLabel())),
+ '#rows' => [],
+ '#empty' => $this->t('There is no @label yet.', ['@label' => $this->entityType->getLabel()]),
'#cache' => [
'contexts' => $this->entityType->getListCacheContexts(),
'tags' => $this->entityType->getListCacheTags(),
],
- );
+ ];
foreach ($this->load() as $entity) {
if ($row = $this->buildRow($entity)) {
$build['table']['#rows'][$entity->id()] = $row;
@@ -233,9 +233,9 @@ class EntityListBuilder extends EntityHandlerBase implements EntityListBuilderIn
// Only add the pager if a limit is specified.
if ($this->limit) {
- $build['pager'] = array(
+ $build['pager'] = [
'#type' => 'pager',
- );
+ ];
}
return $build;
}
diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php
index bf4acf357b0..fa2ddf8c792 100644
--- a/core/lib/Drupal/Core/Entity/EntityManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityManager.php
@@ -265,7 +265,7 @@ class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
*/
- public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array()) {
+ public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) {
return $this->container->get('entity.repository')->getTranslationFromContext($entity, $langcode, $context);
}
diff --git a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php
index 1b35d4aafaa..53b43fdc689 100644
--- a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php
@@ -37,10 +37,10 @@ class SelectionPluginManager extends DefaultPluginManager implements SelectionPl
}
// Initialize default options.
- $options += array(
+ $options += [
'handler' => $this->getPluginId($options['target_type'], 'default'),
- 'handler_settings' => array(),
- );
+ 'handler_settings' => [],
+ ];
// A specific selection plugin ID was already specified.
if (strpos($options['handler'], ':') !== FALSE) {
@@ -62,7 +62,7 @@ class SelectionPluginManager extends DefaultPluginManager implements SelectionPl
$selection_handler_groups = $this->getSelectionGroups($target_type);
// Sort the selection plugins by weight and select the best match.
- uasort($selection_handler_groups[$base_plugin_id], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($selection_handler_groups[$base_plugin_id], ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
end($selection_handler_groups[$base_plugin_id]);
$plugin_id = key($selection_handler_groups[$base_plugin_id]);
@@ -73,7 +73,7 @@ class SelectionPluginManager extends DefaultPluginManager implements SelectionPl
* {@inheritdoc}
*/
public function getSelectionGroups($entity_type_id) {
- $plugins = array();
+ $plugins = [];
$definitions = $this->getDefinitions();
// Do not display the 'broken' plugin in the UI.
@@ -92,19 +92,19 @@ class SelectionPluginManager extends DefaultPluginManager implements SelectionPl
* {@inheritdoc}
*/
public function getSelectionHandler(FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL) {
- $options = array(
+ $options = [
'target_type' => $field_definition->getFieldStorageDefinition()->getSetting('target_type'),
'handler' => $field_definition->getSetting('handler'),
- 'handler_settings' => $field_definition->getSetting('handler_settings') ?: array(),
+ 'handler_settings' => $field_definition->getSetting('handler_settings') ?: [],
'entity' => $entity,
- );
+ ];
return $this->getInstance($options);
}
/**
* {@inheritdoc}
*/
- public function getFallbackPluginId($plugin_id, array $configuration = array()) {
+ public function getFallbackPluginId($plugin_id, array $configuration = []) {
return 'broken';
}
diff --git a/core/lib/Drupal/Core/Entity/EntityRepository.php b/core/lib/Drupal/Core/Entity/EntityRepository.php
index 5fb7501f0a3..986cc50b543 100644
--- a/core/lib/Drupal/Core/Entity/EntityRepository.php
+++ b/core/lib/Drupal/Core/Entity/EntityRepository.php
@@ -79,7 +79,7 @@ class EntityRepository implements EntityRepositoryInterface {
/**
* {@inheritdoc}
*/
- public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array()) {
+ public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) {
$translation = $entity;
if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) {
@@ -92,7 +92,7 @@ class EntityRepository implements EntityRepositoryInterface {
// negotiation, unless the current translation is already the desired one.
if ($entity->language()->getId() != $langcode) {
$context['data'] = $entity;
- $context += array('operation' => 'entity_view', 'langcode' => $langcode);
+ $context += ['operation' => 'entity_view', 'langcode' => $langcode];
$candidates = $this->languageManager->getFallbackCandidates($context);
// Ensure the default language has the proper language code.
diff --git a/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php b/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php
index efbfb6be039..d1229d4554c 100644
--- a/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php
@@ -67,6 +67,6 @@ interface EntityRepositoryInterface {
*
* @see \Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates()
*/
- public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array());
+ public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []);
}
diff --git a/core/lib/Drupal/Core/Entity/EntityResolverManager.php b/core/lib/Drupal/Core/Entity/EntityResolverManager.php
index 847a480e4c9..e9a87d6a6e7 100644
--- a/core/lib/Drupal/Core/Entity/EntityResolverManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityResolverManager.php
@@ -70,13 +70,13 @@ class EntityResolverManager {
// Check if the class exists and if so use the buildForm() method from the
// interface.
if (class_exists($controller)) {
- return array($controller, 'buildForm');
+ return [$controller, 'buildForm'];
}
}
if (strpos($controller, ':') === FALSE) {
if (method_exists($controller, '__invoke')) {
- return array($controller, '__invoke');
+ return [$controller, '__invoke'];
}
if (function_exists($controller)) {
return $controller;
@@ -91,7 +91,7 @@ class EntityResolverManager {
// that could not exist at this point. There is however no other way to
// do it, as the container does not allow static introspection.
list($class_or_service, $method) = explode(':', $controller, 2);
- return array($this->classResolver->getInstanceFromDefinition($class_or_service), $method);
+ return [$this->classResolver->getInstanceFromDefinition($class_or_service), $method];
}
elseif (strpos($controller, '::') !== FALSE) {
// Controller in the class::method notation.
@@ -114,7 +114,7 @@ class EntityResolverManager {
*/
protected function setParametersFromReflection($controller, Route $route) {
$entity_types = $this->getEntityTypes();
- $parameter_definitions = $route->getOption('parameters') ?: array();
+ $parameter_definitions = $route->getOption('parameters') ?: [];
$result = FALSE;
@@ -136,10 +136,10 @@ class EntityResolverManager {
$entity_type = $entity_types[$parameter_name];
$entity_class = $entity_type->getClass();
if (($reflection_class = $parameter->getClass()) && (is_subclass_of($entity_class, $reflection_class->name) || $entity_class == $reflection_class->name)) {
- $parameter_definitions += array($parameter_name => array());
- $parameter_definitions[$parameter_name] += array(
+ $parameter_definitions += [$parameter_name => []];
+ $parameter_definitions[$parameter_name] += [
'type' => 'entity:' . $parameter_name,
- );
+ ];
$result = TRUE;
}
}
@@ -170,7 +170,7 @@ class EntityResolverManager {
// parameter in the first place. This is the case for add forms, for
// example.
if (isset($entity_type) && isset($this->getEntityTypes()[$entity_type]) && (strpos($route->getPath(), '{' . $entity_type . '}') !== FALSE)) {
- $parameter_definitions = $route->getOption('parameters') ?: array();
+ $parameter_definitions = $route->getOption('parameters') ?: [];
// First try to figure out whether there is already a parameter upcasting
// the same entity type already.
@@ -185,11 +185,11 @@ class EntityResolverManager {
}
if (!isset($parameter_definitions[$entity_type])) {
- $parameter_definitions[$entity_type] = array();
+ $parameter_definitions[$entity_type] = [];
}
- $parameter_definitions[$entity_type] += array(
+ $parameter_definitions[$entity_type] += [
'type' => 'entity:' . $entity_type,
- );
+ ];
if (!empty($parameter_definitions)) {
$route->setOption('parameters', $parameter_definitions);
}
diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php
index f58312106e4..99698df0ae2 100644
--- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php
@@ -14,7 +14,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
*
* @var array
*/
- protected $entities = array();
+ protected $entities = [];
/**
* Entity type ID for this storage.
@@ -105,7 +105,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
* {@inheritdoc}
*/
public function loadUnchanged($id) {
- $this->resetCache(array($id));
+ $this->resetCache([$id]);
return $this->load($id);
}
@@ -119,7 +119,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
}
}
else {
- $this->entities = array();
+ $this->entities = [];
}
}
@@ -133,7 +133,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
* Array of entities from the entity cache.
*/
protected function getFromStaticCache(array $ids) {
- $entities = array();
+ $entities = [];
// Load any available entities from the internal cache.
if ($this->entityType->isStaticallyCacheable() && !empty($this->entities)) {
$entities += array_intersect_key($this->entities, array_flip($ids));
@@ -164,15 +164,15 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
*/
protected function invokeHook($hook, EntityInterface $entity) {
// Invoke the hook.
- $this->moduleHandler()->invokeAll($this->entityTypeId . '_' . $hook, array($entity));
+ $this->moduleHandler()->invokeAll($this->entityTypeId . '_' . $hook, [$entity]);
// Invoke the respective entity-level hook.
- $this->moduleHandler()->invokeAll('entity_' . $hook, array($entity));
+ $this->moduleHandler()->invokeAll('entity_' . $hook, [$entity]);
}
/**
* {@inheritdoc}
*/
- public function create(array $values = array()) {
+ public function create(array $values = []) {
$entity_class = $this->entityClass;
$entity_class::preCreate($this, $values);
@@ -209,7 +209,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
* {@inheritdoc}
*/
public function load($id) {
- $entities = $this->loadMultiple(array($id));
+ $entities = $this->loadMultiple([$id]);
return isset($entities[$id]) ? $entities[$id] : NULL;
}
@@ -217,7 +217,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
* {@inheritdoc}
*/
public function loadMultiple(array $ids = NULL) {
- $entities = array();
+ $entities = [];
// Create a new variable which is either a prepared version of the $ids
// array for later comparison with the entity cache, or FALSE if no $ids
@@ -317,7 +317,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
* An array of entity objects implementing the EntityInterface.
*/
protected function mapFromStorageRecords(array $records) {
- $entities = array();
+ $entities = [];
foreach ($records as $record) {
$entity = new $this->entityClass($record, $this->entityTypeId);
$entities[$entity->id()] = $entity;
@@ -460,7 +460,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
* Specifies whether the entity is being updated or created.
*/
protected function doPostSave(EntityInterface $entity, $update) {
- $this->resetCache(array($entity->id()));
+ $this->resetCache([$entity->id()]);
// The entity is no longer new.
$entity->enforceIsNew(FALSE);
@@ -496,12 +496,12 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
/**
* {@inheritdoc}
*/
- public function loadByProperties(array $values = array()) {
+ public function loadByProperties(array $values = []) {
// Build a query to fetch the entity IDs.
$entity_query = $this->getQuery();
$this->buildPropertyQuery($entity_query, $values);
$result = $entity_query->execute();
- return $result ? $this->loadMultiple($result) : array();
+ return $result ? $this->loadMultiple($result) : [];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/EntityStorageInterface.php b/core/lib/Drupal/Core/Entity/EntityStorageInterface.php
index e4031239be7..50166d6e278 100644
--- a/core/lib/Drupal/Core/Entity/EntityStorageInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityStorageInterface.php
@@ -102,7 +102,7 @@ interface EntityStorageInterface {
* @return \Drupal\Core\Entity\EntityInterface[]
* An array of entity objects indexed by their ids.
*/
- public function loadByProperties(array $values = array());
+ public function loadByProperties(array $values = []);
/**
* Constructs a new entity object, without permanently saving it.
@@ -114,7 +114,7 @@ interface EntityStorageInterface {
* @return \Drupal\Core\Entity\EntityInterface
* A new entity object.
*/
- public function create(array $values = array());
+ public function create(array $values = []);
/**
* Deletes permanently saved entities.
diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php
index 9f2587e69db..f9555a8dde1 100644
--- a/core/lib/Drupal/Core/Entity/EntityType.php
+++ b/core/lib/Drupal/Core/Entity/EntityType.php
@@ -43,7 +43,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*
* @var array
*/
- protected $entity_keys = array();
+ protected $entity_keys = [];
/**
* The unique identifier of this entity type.
@@ -66,7 +66,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*
* @var array
*/
- protected $handlers = array();
+ protected $handlers = [];
/**
* The name of the default administrative permission.
@@ -88,7 +88,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*
* @var array
*/
- protected $links = array();
+ protected $links = [];
/**
* The name of a callback that returns the label of the entity.
@@ -258,7 +258,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*
* @var array[]
*/
- protected $constraints = array();
+ protected $constraints = [];
/**
* Any additional properties and values.
@@ -287,15 +287,15 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
}
// Ensure defaults.
- $this->entity_keys += array(
+ $this->entity_keys += [
'revision' => '',
'bundle' => '',
'langcode' => '',
'default_langcode' => 'default_langcode',
- );
- $this->handlers += array(
+ ];
+ $this->handlers += [
'access' => 'Drupal\Core\Entity\EntityAccessControlHandler',
- );
+ ];
if (isset($this->handlers['storage'])) {
$this->checkStorageClass($this->handlers['storage']);
}
@@ -804,7 +804,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
* {@inheritdoc}
*/
public function getGroupLabel() {
- return !empty($this->group_label) ? $this->group_label : $this->t('Other', array(), array('context' => 'Entity type group'));
+ return !empty($this->group_label) ? $this->group_label : $this->t('Other', [], ['context' => 'Entity type group']);
}
/**
diff --git a/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php b/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php
index 4f4213f7aaf..98223ce044d 100644
--- a/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php
+++ b/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php
@@ -22,7 +22,7 @@ trait EntityTypeEventSubscriberTrait {
* @see \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()
*/
public static function getEntityTypeEvents() {
- $event = array('onEntityTypeEvent', 100);
+ $event = ['onEntityTypeEvent', 100];
$events[EntityTypeEvents::CREATE][] = $event;
$events[EntityTypeEvents::UPDATE][] = $event;
$events[EntityTypeEvents::DELETE][] = $event;
diff --git a/core/lib/Drupal/Core/Entity/EntityTypeRepository.php b/core/lib/Drupal/Core/Entity/EntityTypeRepository.php
index 6d3d37627cc..d89b75e3ffc 100644
--- a/core/lib/Drupal/Core/Entity/EntityTypeRepository.php
+++ b/core/lib/Drupal/Core/Entity/EntityTypeRepository.php
@@ -62,8 +62,8 @@ class EntityTypeRepository implements EntityTypeRepositoryInterface {
}
// Make sure that the 'Content' group is situated at the top.
- $content = $this->t('Content', array(), array('context' => 'Entity type group'));
- $options = array((string) $content => $options[(string) $content]) + $options;
+ $content = $this->t('Content', [], ['context' => 'Entity type group']);
+ $options = [(string) $content => $options[(string) $content]] + $options;
}
return $options;
diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
index 1b3e6c0fbbe..2c3340ec54f 100644
--- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
+++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
@@ -108,14 +108,14 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
* {@inheritdoc}
*/
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
- $build_list = $this->viewMultiple(array($entity), $view_mode, $langcode);
+ $build_list = $this->viewMultiple([$entity], $view_mode, $langcode);
// The default ::buildMultiple() #pre_render callback won't run, because we
// extract a child element of the default renderable array. Thus we must
// assign an alternative #pre_render callback that applies the necessary
// transformations and then still calls ::buildMultiple().
$build = $build_list[0];
- $build['#pre_render'][] = array($this, 'build');
+ $build['#pre_render'][] = [$this, 'build'];
return $build;
}
@@ -123,11 +123,11 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
/**
* {@inheritdoc}
*/
- public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
- $build_list = array(
+ public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) {
+ $build_list = [
'#sorted' => TRUE,
- '#pre_render' => array(array($this, 'buildMultiple')),
- );
+ '#pre_render' => [[$this, 'buildMultiple']],
+ ];
$weight = 0;
foreach ($entities as $key => $entity) {
// Ensure that from now on we are dealing with the proper translation
@@ -137,7 +137,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
// Set build defaults.
$build_list[$key] = $this->getBuildDefaults($entity, $view_mode);
$entityType = $this->entityTypeId;
- $this->moduleHandler()->alter(array($entityType . '_build_defaults', 'entity_build_defaults'), $build_list[$key], $entity, $view_mode);
+ $this->moduleHandler()->alter([$entityType . '_build_defaults', 'entity_build_defaults'], $build_list[$key], $entity, $view_mode);
$build_list[$key]['#weight'] = $weight++;
}
@@ -160,16 +160,16 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
$context = [];
$this->moduleHandler()->alter('entity_view_mode', $view_mode, $entity, $context);
- $build = array(
+ $build = [
"#{$this->entityTypeId}" => $entity,
'#view_mode' => $view_mode,
// Collect cache defaults for this entity.
- '#cache' => array(
+ '#cache' => [
'tags' => Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags()),
'contexts' => $entity->getCacheContexts(),
'max-age' => $entity->getCacheMaxAge(),
- ),
- );
+ ],
+ ];
// Add the default #theme key if a template exists for it.
if ($this->themeRegistry->getRuntime()->has($this->entityTypeId)) {
@@ -179,15 +179,15 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
// Cache the rendered output if permitted by the view mode and global entity
// type configuration.
if ($this->isViewModeCacheable($view_mode) && !$entity->isNew() && $entity->isDefaultRevision() && $this->entityType->isRenderCacheable()) {
- $build['#cache'] += array(
- 'keys' => array(
+ $build['#cache'] += [
+ 'keys' => [
'entity_view',
$this->entityTypeId,
$entity->id(),
$view_mode,
- ),
+ ],
'bin' => $this->cacheBin,
- );
+ ];
if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) {
$build['#cache']['keys'][] = $entity->language()->getId();
@@ -241,7 +241,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
*/
public function buildMultiple(array $build_list) {
// Build the view modes and display objects.
- $view_modes = array();
+ $view_modes = [];
$entity_type_key = "#{$this->entityTypeId}";
$view_hook = "{$this->entityTypeId}_view";
@@ -282,7 +282,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
}
// Allow modules to modify the render array.
- $this->moduleHandler()->alter(array($view_hook, 'entity_view'), $build_list[$key], $entity, $display);
+ $this->moduleHandler()->alter([$view_hook, 'entity_view'], $build_list[$key], $entity, $display);
}
}
@@ -293,7 +293,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
- $entities_by_bundle = array();
+ $entities_by_bundle = [];
foreach ($entities as $id => $entity) {
// Initialize the field item attributes for the fields being displayed.
// The entity can include fields that are not displayed, and the display
@@ -304,7 +304,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
foreach ($displays[$entity->bundle()]->getComponents() as $name => $options) {
if ($entity->hasField($name)) {
foreach ($entity->get($name) as $item) {
- $item->_attributes = array();
+ $item->_attributes = [];
}
}
}
@@ -313,7 +313,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
}
// Invoke hook_entity_prepare_view().
- $this->moduleHandler()->invokeAll('entity_prepare_view', array($this->entityTypeId, $entities, $displays, $view_mode));
+ $this->moduleHandler()->invokeAll('entity_prepare_view', [$this->entityTypeId, $entities, $displays, $view_mode]);
// Let the displays build their render arrays.
foreach ($entities_by_bundle as $bundle => $bundle_entities) {
@@ -343,7 +343,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
* {@inheritdoc}
*/
public function getCacheTags() {
- return array($this->entityTypeId . '_view');
+ return [$this->entityTypeId . '_view'];
}
/**
@@ -394,12 +394,12 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
/**
* {@inheritdoc}
*/
- public function viewField(FieldItemListInterface $items, $display_options = array()) {
+ public function viewField(FieldItemListInterface $items, $display_options = []) {
$entity = $items->getEntity();
$field_name = $items->getFieldDefinition()->getName();
$display = $this->getSingleFieldDisplay($entity, $field_name, $display_options);
- $output = array();
+ $output = [];
$build = $display->build($entity);
if (isset($build[$field_name])) {
$output = $build[$field_name];
@@ -411,7 +411,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
/**
* {@inheritdoc}
*/
- public function viewFieldItem(FieldItemInterface $item, $display = array()) {
+ public function viewFieldItem(FieldItemInterface $item, $display = []) {
$entity = $item->getEntity();
$field_name = $item->getFieldDefinition()->getName();
@@ -420,11 +420,11 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
// Push the item as the single value for the field, and defer to viewField()
// to build the render array for the whole list.
- $clone->{$field_name}->setValue(array($item->getValue()));
+ $clone->{$field_name}->setValue([$item->getValue()]);
$elements = $this->viewField($clone->{$field_name}, $display);
// Extract the part of the render array we need.
- $output = isset($elements[0]) ? $elements[0] : array();
+ $output = isset($elements[0]) ? $elements[0] : [];
if (isset($elements['#access'])) {
$output['#access'] = $elements['#access'];
}
@@ -465,11 +465,11 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
$bundle = $entity->bundle();
$key = $entity_type_id . ':' . $bundle . ':' . $field_name . ':' . Crypt::hashBase64(serialize($display_options));
if (!isset($this->singleFieldDisplays[$key])) {
- $this->singleFieldDisplays[$key] = EntityViewDisplay::create(array(
+ $this->singleFieldDisplays[$key] = EntityViewDisplay::create([
'targetEntityType' => $entity_type_id,
'bundle' => $bundle,
'status' => TRUE,
- ))->setComponent($field_name, $display_options);
+ ])->setComponent($field_name, $display_options);
}
$display = $this->singleFieldDisplays[$key];
}
diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php
index b86b5922c18..3da44873079 100644
--- a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php
@@ -70,7 +70,7 @@ interface EntityViewBuilderInterface {
* comments belongs to, or not passing one, and having the comments node not
* be available for loading.
*/
- public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL);
+ public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL);
/**
* Resets the entity render cache.
@@ -122,7 +122,7 @@ interface EntityViewBuilderInterface {
*
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewFieldItem()
*/
- public function viewField(FieldItemListInterface $items, $display_options = array());
+ public function viewField(FieldItemListInterface $items, $display_options = []);
/**
* Builds a renderable array for a single field item.
@@ -138,7 +138,7 @@ interface EntityViewBuilderInterface {
*
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewField()
*/
- public function viewFieldItem(FieldItemInterface $item, $display_options = array());
+ public function viewFieldItem(FieldItemInterface $item, $display_options = []);
/**
* The cache tag associated with this entity view builder.
diff --git a/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php b/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php
index 680c0e32ca4..03ef29c5834 100644
--- a/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php
+++ b/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php
@@ -64,7 +64,7 @@ class BundleConfigImportValidate extends ConfigImportValidateEventSubscriberBase
->execute();
if (!empty($entity_ids)) {
$entity = $this->entityManager->getStorage($entity_type_id)->load($bundle_id);
- $event->getConfigImporter()->logError($this->t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', array('%entity_type' => $bundle_of_entity_type->getLabel(), '%bundle_label' => $bundle_of_entity_type->getBundleLabel(), '%bundle' => $entity->label())));
+ $event->getConfigImporter()->logError($this->t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $bundle_of_entity_type->getLabel(), '%bundle_label' => $bundle_of_entity_type->getBundleLabel(), '%bundle' => $entity->label()]));
}
}
}
diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php
index 478bca758e8..de77e09d20f 100644
--- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php
+++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php
@@ -86,9 +86,9 @@ class KeyValueEntityStorage extends EntityStorageBase {
/**
* {@inheritdoc}
*/
- public function doCreate(array $values = array()) {
+ public function doCreate(array $values = []) {
// Set default language to site default if not provided.
- $values += array($this->getEntityType()->getKey('langcode') => $this->languageManager->getDefaultLanguage()->getId());
+ $values += [$this->getEntityType()->getKey('langcode') => $this->languageManager->getDefaultLanguage()->getId()];
$entity = new $this->entityClass($values, $this->entityTypeId);
// @todo This is handled by ContentEntityStorageBase, which assumes
diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php
index 5242e8db4aa..98be20e04ea 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php
@@ -17,7 +17,7 @@ class EntityDeriver implements ContainerDeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* The base plugin ID this derivative is for.
@@ -86,18 +86,18 @@ class EntityDeriver implements ContainerDeriverInterface {
$this->derivatives[''] = $base_plugin_definition;
// Add definitions for each entity type and bundle.
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
- $this->derivatives[$entity_type_id] = array(
+ $this->derivatives[$entity_type_id] = [
'label' => $entity_type->getLabel(),
'constraints' => $entity_type->getConstraints(),
- ) + $base_plugin_definition;
+ ] + $base_plugin_definition;
// Incorporate the bundles as entity:$entity_type:$bundle, if any.
foreach ($this->bundleInfoService->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
if ($bundle !== $entity_type_id) {
- $this->derivatives[$entity_type_id . ':' . $bundle] = array(
+ $this->derivatives[$entity_type_id . ':' . $bundle] = [
'label' => $bundle_info['label'],
'constraints' => $this->derivatives[$entity_type_id]['constraints']
- ) + $base_plugin_definition;
+ ] + $base_plugin_definition;
}
}
}
diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
index 2a9f1728dba..eafb6d88bfb 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
@@ -113,7 +113,7 @@ class EntityAdapter extends TypedData implements \IteratorAggregate, ComplexData
if (!$this->entity instanceof FieldableEntityInterface) {
// @todo: Add support for config entities in
// https://www.drupal.org/node/1818574.
- return array();
+ return [];
}
return $this->entity->getFields($include_computed);
}
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php
index 7877289e539..d8d21fdbef2 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php
@@ -50,8 +50,8 @@ class DefaultSelectionDeriver extends DeriverBase implements ContainerDeriverInt
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
$this->derivatives[$entity_type_id] = $base_plugin_definition;
- $this->derivatives[$entity_type_id]['entity_types'] = array($entity_type_id);
- $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', array('@entity_type' => $entity_type->getLabel()));
+ $this->derivatives[$entity_type_id]['entity_types'] = [$entity_type_id];
+ $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', ['@entity_type' => $entity_type->getLabel()]);
$this->derivatives[$entity_type_id]['base_plugin_label'] = (string) $base_plugin_definition['label'];
// If the entity type doesn't provide a 'label' key in its plugin
diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php
index d74fb6e11a2..f53eeb61890 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php
@@ -20,9 +20,9 @@ class Broken implements SelectionInterface {
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['selection_handler'] = array(
+ $form['selection_handler'] = [
'#markup' => t('The selected selection handler is broken.'),
- );
+ ];
return $form;
}
@@ -40,7 +40,7 @@ class Broken implements SelectionInterface {
* {@inheritdoc}
*/
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
- return array();
+ return [];
}
/**
@@ -54,7 +54,7 @@ class Broken implements SelectionInterface {
* {@inheritdoc}
*/
public function validateReferenceableEntities(array $ids) {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
index d924e1ae137..e3b41b1bbe3 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
@@ -109,26 +109,26 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
$bundles = $this->entityManager->getBundleInfo($entity_type_id);
// Merge-in default values.
- $selection_handler_settings += array(
+ $selection_handler_settings += [
// For the 'target_bundles' setting, a NULL value is equivalent to "allow
// entities from any bundle to be referenced" and an empty array value is
// equivalent to "no entities from any bundle can be referenced".
'target_bundles' => NULL,
- 'sort' => array(
+ 'sort' => [
'field' => '_none',
- ),
+ ],
'auto_create' => FALSE,
'auto_create_bundle' => NULL,
- );
+ ];
if ($entity_type->hasKey('bundle')) {
- $bundle_options = array();
+ $bundle_options = [];
foreach ($bundles as $bundle_name => $bundle_info) {
$bundle_options[$bundle_name] = $bundle_info['label'];
}
natsort($bundle_options);
- $form['target_bundles'] = array(
+ $form['target_bundles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Bundles'),
'#options' => $bundle_options,
@@ -139,7 +139,7 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
'#element_validate' => [[get_class($this), 'elementValidateFilter']],
'#ajax' => TRUE,
'#limit_validation_errors' => [],
- );
+ ];
$form['target_bundles_update'] = [
'#type' => 'submit',
@@ -152,14 +152,14 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
];
}
else {
- $form['target_bundles'] = array(
+ $form['target_bundles'] = [
'#type' => 'value',
- '#value' => array(),
- );
+ '#value' => [],
+ ];
}
if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
- $fields = array();
+ $fields = [];
foreach (array_keys($bundles) as $bundle) {
$bundle_fields = array_filter($this->entityManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) {
return !$field_definition->isComputed();
@@ -172,57 +172,57 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
// @todo: Use property labels instead of the column name.
if (count($columns) > 1) {
foreach ($columns as $column_name => $column_info) {
- $fields[$field_name . '.' . $column_name] = $this->t('@label (@column)', array('@label' => $field_definition->getLabel(), '@column' => $column_name));
+ $fields[$field_name . '.' . $column_name] = $this->t('@label (@column)', ['@label' => $field_definition->getLabel(), '@column' => $column_name]);
}
}
else {
- $fields[$field_name] = $this->t('@label', array('@label' => $field_definition->getLabel()));
+ $fields[$field_name] = $this->t('@label', ['@label' => $field_definition->getLabel()]);
}
}
}
- $form['sort']['field'] = array(
+ $form['sort']['field'] = [
'#type' => 'select',
'#title' => $this->t('Sort by'),
- '#options' => array(
+ '#options' => [
'_none' => $this->t('- None -'),
- ) + $fields,
+ ] + $fields,
'#ajax' => TRUE,
- '#limit_validation_errors' => array(),
+ '#limit_validation_errors' => [],
'#default_value' => $selection_handler_settings['sort']['field'],
- );
+ ];
- $form['sort']['settings'] = array(
+ $form['sort']['settings'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('entity_reference-settings')),
+ '#attributes' => ['class' => ['entity_reference-settings']],
'#process' => [[EntityReferenceItem::class, 'formProcessMergeParent']],
- );
+ ];
if ($selection_handler_settings['sort']['field'] != '_none') {
// Merge-in default values.
- $selection_handler_settings['sort'] += array(
+ $selection_handler_settings['sort'] += [
'direction' => 'ASC',
- );
+ ];
- $form['sort']['settings']['direction'] = array(
+ $form['sort']['settings']['direction'] = [
'#type' => 'select',
'#title' => $this->t('Sort direction'),
'#required' => TRUE,
- '#options' => array(
+ '#options' => [
'ASC' => $this->t('Ascending'),
'DESC' => $this->t('Descending'),
- ),
+ ],
'#default_value' => $selection_handler_settings['sort']['direction'],
- );
+ ];
}
}
- $form['auto_create'] = array(
+ $form['auto_create'] = [
'#type' => 'checkbox',
'#title' => $this->t("Create referenced entities if they don't already exist"),
'#default_value' => $selection_handler_settings['auto_create'],
'#weight' => -2,
- );
+ ];
if ($entity_type->hasKey('bundle')) {
$bundles = array_intersect_key($bundle_options, array_filter((array) $selection_handler_settings['target_bundles']));
@@ -288,10 +288,10 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
$result = $query->execute();
if (empty($result)) {
- return array();
+ return [];
}
- $options = array();
+ $options = [];
$entities = $this->entityManager->getStorage($target_type)->loadMultiple($result);
foreach ($entities as $entity_id => $entity) {
$bundle = $entity->bundle();
@@ -315,7 +315,7 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
* {@inheritdoc}
*/
public function validateReferenceableEntities(array $ids) {
- $result = array();
+ $result = [];
if ($ids) {
$target_type = $this->configuration['target_type'];
$entity_type = $this->entityManager->getDefinition($target_type);
@@ -336,10 +336,10 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
$bundle_key = $entity_type->getKey('bundle');
$label_key = $entity_type->getKey('label');
- $entity = $this->entityManager->getStorage($entity_type_id)->create(array(
+ $entity = $this->entityManager->getStorage($entity_type_id)->create([
$bundle_key => $bundle,
$label_key => $label,
- ));
+ ]);
if ($entity instanceof EntityOwnerInterface) {
$entity->setOwnerId($uid);
@@ -433,9 +433,9 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
$old_tags = $query->alterTags;
$old_metadata = $query->alterMetaData;
- $query->alterTags = array($tag => TRUE);
+ $query->alterTags = [$tag => TRUE];
$query->alterMetaData['base_table'] = $base_table;
- $this->moduleHandler->alter(array('query', 'query_' . $tag), $query);
+ $this->moduleHandler->alter(['query', 'query_' . $tag], $query);
// Restore the tags and metadata.
$query->alterTags = $old_tags;
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php
index 513213feb7b..161e9f2f6b1 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php
@@ -37,7 +37,7 @@ class BundleConstraint extends Constraint {
public function getBundleOption() {
// Support passing the bundle as string, but force it to be an array.
if (!is_array($this->bundle)) {
- $this->bundle = array($this->bundle);
+ $this->bundle = [$this->bundle];
}
return $this->bundle;
}
@@ -53,7 +53,7 @@ class BundleConstraint extends Constraint {
* {@inheritdoc}
*/
public function getRequiredOptions() {
- return array('bundle');
+ return ['bundle'];
}
}
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php
index 0a0988976be..39e99afc5e2 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php
@@ -19,7 +19,7 @@ class BundleConstraintValidator extends ConstraintValidator {
}
if (!in_array($entity->bundle(), $constraint->getBundleOption())) {
- $this->context->addViolation($constraint->message, array('%bundle' => implode(', ', $constraint->getBundleOption())));
+ $this->context->addViolation($constraint->message, ['%bundle' => implode(', ', $constraint->getBundleOption())]);
}
}
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php
index c9f2d815950..c39152f2aa3 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php
@@ -40,7 +40,7 @@ class EntityTypeConstraint extends Constraint {
* {@inheritdoc}
*/
public function getRequiredOptions() {
- return array('type');
+ return ['type'];
}
}
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php
index 5d2b8625882..89c5e8ead72 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php
@@ -20,7 +20,7 @@ class EntityTypeConstraintValidator extends ConstraintValidator {
/** @var $entity \Drupal\Core\Entity\EntityInterface */
if ($entity->getEntityTypeId() != $constraint->type) {
- $this->context->addViolation($constraint->message, array('%type' => $constraint->type));
+ $this->context->addViolation($constraint->message, ['%type' => $constraint->type]);
}
}
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php
index c57478197bb..7860c90d654 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php
@@ -43,7 +43,7 @@ class ReferenceAccessConstraintValidator extends ConstraintValidator {
// referenced entity.
if ($check_permission && !$referenced_entity->access('view')) {
$type = $value->getFieldDefinition()->getSetting('target_type');
- $this->context->addViolation($constraint->message, array('%type' => $type, '%id' => $id));
+ $this->context->addViolation($constraint->message, ['%type' => $type, '%id' => $id]);
}
}
}
diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php b/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php
index 50884db2039..27ec70ce98b 100644
--- a/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php
+++ b/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php
@@ -11,13 +11,13 @@ abstract class ConditionAggregateBase extends ConditionFundamentals implements C
* {@inheritdoc}
*/
public function condition($field, $function = NULL, $value = NULL, $operator = NULL, $langcode = NULL) {
- $this->conditions[] = array(
+ $this->conditions[] = [
'field' => $field,
'function' => $function,
'value' => $value,
'operator' => $operator,
'langcode' => $langcode,
- );
+ ];
return $this;
}
diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionBase.php b/core/lib/Drupal/Core/Entity/Query/ConditionBase.php
index 4393935c15e..030f51dc3ac 100644
--- a/core/lib/Drupal/Core/Entity/Query/ConditionBase.php
+++ b/core/lib/Drupal/Core/Entity/Query/ConditionBase.php
@@ -11,12 +11,12 @@ abstract class ConditionBase extends ConditionFundamentals implements ConditionI
* {@inheritdoc}
*/
public function condition($field, $value = NULL, $operator = NULL, $langcode = NULL) {
- $this->conditions[] = array(
+ $this->conditions[] = [
'field' => $field,
'value' => $value,
'operator' => $operator,
'langcode' => $langcode,
- );
+ ];
return $this;
}
diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php
index 980d83e60e8..d03e2b2e810 100644
--- a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php
+++ b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php
@@ -12,7 +12,7 @@ abstract class ConditionFundamentals {
*
* @var array
*/
- protected $conditions = array();
+ protected $conditions = [];
/**
* The conjunction of this condition group. The value is one of the following:
@@ -36,7 +36,7 @@ abstract class ConditionFundamentals {
*
* @var array
*/
- protected $namespaces = array();
+ protected $namespaces = [];
/**
* Constructs a Condition object.
diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
index 227d90c5132..f805747e9cf 100644
--- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php
+++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
@@ -29,7 +29,7 @@ abstract class QueryBase implements QueryInterface {
*
* @var array
*/
- protected $sort = array();
+ protected $sort = [];
/**
* TRUE if this is a count query, FALSE if it isn't.
@@ -50,14 +50,14 @@ abstract class QueryBase implements QueryInterface {
*
* @var array
*/
- protected $aggregate = array();
+ protected $aggregate = [];
/**
* The list of columns to group on.
*
* @var array
*/
- protected $groupBy = array();
+ protected $groupBy = [];
/**
* Aggregate Conditions
@@ -71,14 +71,14 @@ abstract class QueryBase implements QueryInterface {
*
* @var array
*/
- protected $sortAggregate = array();
+ protected $sortAggregate = [];
/**
* The query range.
*
* @var array
*/
- protected $range = array();
+ protected $range = [];
/**
* The query metadata for alter purposes.
@@ -115,14 +115,14 @@ abstract class QueryBase implements QueryInterface {
*
* @see Query::pager()
*/
- protected $pager = array();
+ protected $pager = [];
/**
* List of potential namespaces of the classes belonging to this query.
*
* @var array
*/
- protected $namespaces = array();
+ protected $namespaces = [];
/**
* Constructs this object.
@@ -181,10 +181,10 @@ abstract class QueryBase implements QueryInterface {
* {@inheritdoc}
*/
public function range($start = NULL, $length = NULL) {
- $this->range = array(
+ $this->range = [
'start' => $start,
'length' => $length,
- );
+ ];
return $this;
}
@@ -223,11 +223,11 @@ abstract class QueryBase implements QueryInterface {
* {@inheritdoc}
*/
public function sort($field, $direction = 'ASC', $langcode = NULL) {
- $this->sort[] = array(
+ $this->sort[] = [
'field' => $field,
'direction' => strtoupper($direction),
'langcode' => $langcode,
- );
+ ];
return $this;
}
@@ -276,10 +276,10 @@ abstract class QueryBase implements QueryInterface {
PagerSelectExtender::$maxElement = $element + 1;
}
- $this->pager = array(
+ $this->pager = [
'limit' => $limit,
'element' => $element,
- );
+ ];
return $this;
}
@@ -381,12 +381,12 @@ abstract class QueryBase implements QueryInterface {
$alias = $this->getAggregationAlias($field, $function);
}
- $this->aggregate[$alias] = array(
+ $this->aggregate[$alias] = [
'field' => $field,
'function' => $function,
'alias' => $alias,
'langcode' => $langcode,
- );
+ ];
return $this;
}
@@ -407,12 +407,12 @@ abstract class QueryBase implements QueryInterface {
public function sortAggregate($field, $function, $direction = 'ASC', $langcode = NULL) {
$alias = $this->getAggregationAlias($field, $function);
- $this->sortAggregate[$alias] = array(
+ $this->sortAggregate[$alias] = [
'field' => $field,
'function' => $function,
'direction' => $direction,
'langcode' => $langcode,
- );
+ ];
$this->aggregate($field, $function, $langcode, $alias);
return $this;
@@ -422,10 +422,10 @@ abstract class QueryBase implements QueryInterface {
* {@inheritdoc}
*/
public function groupBy($field, $langcode = NULL) {
- $this->groupBy[] = array(
+ $this->groupBy[] = [
'field' => $field,
'langcode' => $langcode,
- );
+ ];
return $this;
}
@@ -456,7 +456,7 @@ abstract class QueryBase implements QueryInterface {
* parent of the class and so on and so on.
*/
public static function getNamespaces($object) {
- $namespaces = array();
+ $namespaces = [];
for ($class = get_class($object); $class; $class = get_parent_class($class)) {
$namespaces[] = substr($class, 0, strrpos($class, '\\'));
}
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php
index 7bdf793c645..f48ab65d878 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php
@@ -39,7 +39,7 @@ class ConditionAggregate extends ConditionAggregateBase {
$condition_class::translateCondition($condition, $sql_query, $tables->isFieldCaseSensitive($condition['field']));
$function = $condition['function'];
$placeholder = ':db_placeholder_' . $conditionContainer->nextPlaceholder();
- $conditionContainer->having("$function($field) {$condition['operator']} $placeholder", array($placeholder => $condition['value']));
+ $conditionContainer->having("$function($field) {$condition['operator']} $placeholder", [$placeholder => $condition['value']]);
}
}
}
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
index 78f831aff3f..cd245ef7b52 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
@@ -31,7 +31,7 @@ class Query extends QueryBase implements QueryInterface {
*
* @var array
*/
- protected $sqlFields = array();
+ protected $sqlFields = [];
/**
* An array of strings added as to the group by, keyed by the string to avoid
@@ -39,7 +39,7 @@ class Query extends QueryBase implements QueryInterface {
*
* @var array
*/
- protected $sqlGroupBy = array();
+ protected $sqlGroupBy = [];
/**
* @var \Drupal\Core\Database\Connection
@@ -101,23 +101,23 @@ class Query extends QueryBase implements QueryInterface {
if ($this->entityType->getDataTable()) {
$simple_query = FALSE;
}
- $this->sqlQuery = $this->connection->select($base_table, 'base_table', array('conjunction' => $this->conjunction));
+ $this->sqlQuery = $this->connection->select($base_table, 'base_table', ['conjunction' => $this->conjunction]);
$this->sqlQuery->addMetaData('entity_type', $this->entityTypeId);
$id_field = $this->entityType->getKey('id');
// Add the key field for fetchAllKeyed().
if (!$revision_field = $this->entityType->getKey('revision')) {
// When there is no revision support, the key field is the entity key.
- $this->sqlFields["base_table.$id_field"] = array('base_table', $id_field);
+ $this->sqlFields["base_table.$id_field"] = ['base_table', $id_field];
// Now add the value column for fetchAllKeyed(). This is always the
// entity id.
- $this->sqlFields["base_table.$id_field" . '_1'] = array('base_table', $id_field);
+ $this->sqlFields["base_table.$id_field" . '_1'] = ['base_table', $id_field];
}
else {
// When there is revision support, the key field is the revision key.
- $this->sqlFields["base_table.$revision_field"] = array('base_table', $revision_field);
+ $this->sqlFields["base_table.$revision_field"] = ['base_table', $revision_field];
// Now add the value column for fetchAllKeyed(). This is always the
// entity id.
- $this->sqlFields["base_table.$id_field"] = array('base_table', $id_field);
+ $this->sqlFields["base_table.$id_field"] = ['base_table', $id_field];
}
if ($this->accessCheck) {
$this->sqlQuery->addTag($this->entityTypeId . '_access');
@@ -164,12 +164,12 @@ class Query extends QueryBase implements QueryInterface {
*/
protected function addSort() {
if ($this->count) {
- $this->sort = array();
+ $this->sort = [];
}
// Gather the SQL field aliases first to make sure every field table
// necessary is added. This might change whether the query is simple or
// not. See below for more on simple queries.
- $sort = array();
+ $sort = [];
if ($this->sort) {
foreach ($this->sort as $key => $data) {
$sort[$key] = $this->getSqlField($data['field'], $data['langcode']);
@@ -291,8 +291,8 @@ class Query extends QueryBase implements QueryInterface {
*/
public function __clone() {
parent::__clone();
- $this->sqlFields = array();
- $this->sqlGroupBy = array();
+ $this->sqlFields = [];
+ $this->sqlGroupBy = [];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
index 0fa2f665237..f8e42f05bcd 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
@@ -15,7 +15,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface {
* @var array
* An array of expressions.
*/
- protected $sqlExpressions = array();
+ protected $sqlExpressions = [];
/**
* {@inheritdoc}
@@ -39,7 +39,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface {
public function prepare() {
parent::prepare();
// Throw away the id fields.
- $this->sqlFields = array();
+ $this->sqlFields = [];
return $this;
}
@@ -105,7 +105,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface {
$sql_field = $this->getSqlField($field, $group_by['langcode']);
$this->sqlGroupBy[$sql_field] = $sql_field;
list($table, $real_sql_field) = explode('.', $sql_field);
- $this->sqlFields[$sql_field] = array($table, $real_sql_field, $this->createSqlAlias($field, $real_sql_field));
+ $this->sqlFields[$sql_field] = [$table, $real_sql_field, $this->createSqlAlias($field, $real_sql_field)];
}
return $this;
@@ -170,7 +170,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface {
if ($this->count) {
return parent::result();
}
- $return = array();
+ $return = [];
foreach ($this->sqlQuery->execute() as $row) {
$return[] = (array)$row;
}
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
index e813cde3859..e2182473273 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
@@ -28,7 +28,7 @@ class Tables implements TablesInterface {
*
* @var array
*/
- protected $entityTables = array();
+ protected $entityTables = [];
/**
* Field table array, key is table name, value is alias.
@@ -37,7 +37,7 @@ class Tables implements TablesInterface {
*
* @var array
*/
- protected $fieldTables = array();
+ protected $fieldTables = [];
/**
* The entity manager.
@@ -51,7 +51,7 @@ class Tables implements TablesInterface {
*
* @var array
*/
- protected $caseSensitiveFields = array();
+ protected $caseSensitiveFields = [];
/**
* @param \Drupal\Core\Database\Query\SelectInterface $sql_query
@@ -80,7 +80,7 @@ class Tables implements TablesInterface {
$count = count($specifiers) - 1;
// This will contain the definitions of the last specifier seen by the
// system.
- $propertyDefinitions = array();
+ $propertyDefinitions = [];
$entity_type = $this->entityManager->getDefinition($entity_type_id);
$field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
@@ -183,7 +183,7 @@ class Tables implements TablesInterface {
// queried from the data table or the base table based on where it
// finds the property first. The data table is preferred, which is why
// it gets added before the base table.
- $entity_tables = array();
+ $entity_tables = [];
if ($all_revisions && $field_storage && $field_storage->isRevisionable()) {
$data_table = $entity_type->getRevisionDataTable();
$entity_base_table = $entity_type->getRevisionTable();
@@ -274,7 +274,7 @@ class Tables implements TablesInterface {
$field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
// Add the new entity base table using the table and sql column.
$base_table = $this->addNextBaseTable($entity_type, $table, $sql_column);
- $propertyDefinitions = array();
+ $propertyDefinitions = [];
$key++;
$index_prefix .= "$next_index_prefix.";
}
@@ -340,7 +340,7 @@ class Tables implements TablesInterface {
}
protected function addJoin($type, $table, $join_condition, $langcode, $delta = NULL) {
- $arguments = array();
+ $arguments = [];
if ($langcode) {
$entity_type_id = $this->sqlQuery->getMetaData('entity_type');
$entity_type = $this->entityManager->getDefinition($entity_type_id);
diff --git a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
index 5f20c3f08d8..4fd6a32dfbe 100644
--- a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
+++ b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
@@ -22,7 +22,7 @@ class DefaultTableMapping implements TableMappingInterface {
*
* @var \Drupal\Core\Field\FieldStorageDefinitionInterface[]
*/
- protected $fieldStorageDefinitions = array();
+ protected $fieldStorageDefinitions = [];
/**
* A list of field names per table.
@@ -33,7 +33,7 @@ class DefaultTableMapping implements TableMappingInterface {
*
* @var array[]
*/
- protected $fieldNames = array();
+ protected $fieldNames = [];
/**
* A list of database columns which store denormalized data per table.
@@ -44,7 +44,7 @@ class DefaultTableMapping implements TableMappingInterface {
*
* @var array[]
*/
- protected $extraColumns = array();
+ protected $extraColumns = [];
/**
* A mapping of column names per field name.
@@ -58,7 +58,7 @@ class DefaultTableMapping implements TableMappingInterface {
*
* @var array[]
*/
- protected $columnMapping = array();
+ protected $columnMapping = [];
/**
* A list of all database columns per table.
@@ -73,7 +73,7 @@ class DefaultTableMapping implements TableMappingInterface {
*
* @var array[]
*/
- protected $allColumns = array();
+ protected $allColumns = [];
/**
* Constructs a DefaultTableMapping.
@@ -101,7 +101,7 @@ class DefaultTableMapping implements TableMappingInterface {
*/
public function getAllColumns($table_name) {
if (!isset($this->allColumns[$table_name])) {
- $this->allColumns[$table_name] = array();
+ $this->allColumns[$table_name] = [];
foreach ($this->getFieldNames($table_name) as $field_name) {
$this->allColumns[$table_name] = array_merge($this->allColumns[$table_name], array_values($this->getColumnNames($field_name)));
@@ -128,7 +128,7 @@ class DefaultTableMapping implements TableMappingInterface {
if (isset($this->fieldNames[$table_name])) {
return $this->fieldNames[$table_name];
}
- return array();
+ return [];
}
/**
@@ -148,15 +148,15 @@ class DefaultTableMapping implements TableMappingInterface {
/** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $storage */
$storage = \Drupal::entityManager()->getStorage($this->entityType->id());
$storage_definition = $this->fieldStorageDefinitions[$field_name];
- $table_names = array(
+ $table_names = [
$storage->getDataTable(),
$storage->getBaseTable(),
$storage->getRevisionTable(),
$this->getDedicatedDataTableName($storage_definition),
- );
+ ];
// Collect field columns.
- $field_columns = array();
+ $field_columns = [];
foreach (array_keys($storage_definition->getColumns()) as $property_name) {
$field_columns[] = $this->getFieldColumnName($storage_definition, $property_name);
}
@@ -184,7 +184,7 @@ class DefaultTableMapping implements TableMappingInterface {
*/
public function getColumnNames($field_name) {
if (!isset($this->columnMapping[$field_name])) {
- $this->columnMapping[$field_name] = array();
+ $this->columnMapping[$field_name] = [];
if (isset($this->fieldStorageDefinitions[$field_name]) && !$this->fieldStorageDefinitions[$field_name]->hasCustomStorage()) {
foreach (array_keys($this->fieldStorageDefinitions[$field_name]->getColumns()) as $property_name) {
$this->columnMapping[$field_name][$property_name] = $this->getFieldColumnName($this->fieldStorageDefinitions[$field_name], $property_name);
@@ -242,7 +242,7 @@ class DefaultTableMapping implements TableMappingInterface {
if (isset($this->extraColumns[$table_name])) {
return $this->extraColumns[$table_name];
}
- return array();
+ return [];
}
/**
@@ -307,7 +307,7 @@ class DefaultTableMapping implements TableMappingInterface {
* {@inheritdoc}
*/
public function getReservedColumns() {
- return array('deleted');
+ return ['deleted'];
}
/**
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
index 5c03b65ce96..d696a947cfc 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
@@ -286,7 +286,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
return $table_mapping->allowsSharedTableStorage($definition);
});
- $key_fields = array_values(array_filter(array($this->idKey, $this->revisionKey, $this->bundleKey, $this->uuidKey, $this->langcodeKey)));
+ $key_fields = array_values(array_filter([$this->idKey, $this->revisionKey, $this->bundleKey, $this->uuidKey, $this->langcodeKey]));
$all_fields = array_keys($shared_table_definitions);
$revisionable_fields = array_keys(array_filter($shared_table_definitions, function (FieldStorageDefinitionInterface $definition) {
return $definition->isRevisionable();
@@ -310,7 +310,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
// denormalized in the base table but also stored in the revision table
// together with the entity ID and the revision ID as identifiers.
$table_mapping->setFieldNames($this->baseTable, array_diff($all_fields, $revision_metadata_fields));
- $revision_key_fields = array($this->idKey, $this->revisionKey);
+ $revision_key_fields = [$this->idKey, $this->revisionKey];
$table_mapping->setFieldNames($this->revisionTable, array_merge($revision_key_fields, $revisionable_fields));
}
elseif (!$revisionable && $translatable) {
@@ -322,7 +322,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
// the data table.
$table_mapping
->setFieldNames($this->baseTable, $key_fields)
- ->setFieldNames($this->dataTable, array_values(array_diff($all_fields, array($this->uuidKey))));
+ ->setFieldNames($this->dataTable, array_values(array_diff($all_fields, [$this->uuidKey])));
}
elseif ($revisionable && $translatable) {
// The revisionable multilingual layout stores key field values in the
@@ -337,14 +337,14 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
// Like in the multilingual, non-revisionable case the UUID is not
// in the data table. Additionally, do not store revision metadata
// fields in the data table.
- $data_fields = array_values(array_diff($all_fields, array($this->uuidKey), $revision_metadata_fields));
+ $data_fields = array_values(array_diff($all_fields, [$this->uuidKey], $revision_metadata_fields));
$table_mapping->setFieldNames($this->dataTable, $data_fields);
- $revision_base_fields = array_merge(array($this->idKey, $this->revisionKey, $this->langcodeKey), $revision_metadata_fields);
+ $revision_base_fields = array_merge([$this->idKey, $this->revisionKey, $this->langcodeKey], $revision_metadata_fields);
$table_mapping->setFieldNames($this->revisionTable, $revision_base_fields);
- $revision_data_key_fields = array($this->idKey, $this->revisionKey, $this->langcodeKey);
- $revision_data_fields = array_diff($revisionable_fields, $revision_metadata_fields, array($this->langcodeKey));
+ $revision_data_key_fields = [$this->idKey, $this->revisionKey, $this->langcodeKey];
+ $revision_data_fields = array_diff($revisionable_fields, $revision_metadata_fields, [$this->langcodeKey]);
$table_mapping->setFieldNames($this->revisionDataTable, array_merge($revision_data_key_fields, $revision_data_fields));
}
@@ -352,21 +352,21 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$dedicated_table_definitions = array_filter($definitions, function (FieldStorageDefinitionInterface $definition) use ($table_mapping) {
return $table_mapping->requiresDedicatedTableStorage($definition);
});
- $extra_columns = array(
+ $extra_columns = [
'bundle',
'deleted',
'entity_id',
'revision_id',
'langcode',
'delta',
- );
+ ];
foreach ($dedicated_table_definitions as $field_name => $definition) {
$tables = [$table_mapping->getDedicatedDataTableName($definition)];
if ($revisionable && $definition->isRevisionable()) {
$tables[] = $table_mapping->getDedicatedRevisionTableName($definition);
}
foreach ($tables as $table_name) {
- $table_mapping->setFieldNames($table_name, array($field_name));
+ $table_mapping->setFieldNames($table_name, [$field_name]);
$table_mapping->setExtraColumns($table_name, $extra_columns);
}
}
@@ -409,7 +409,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
* Array of entities from the storage.
*/
protected function getFromStorage(array $ids = NULL) {
- $entities = array();
+ $entities = [];
if (!empty($ids)) {
// Sanitize IDs. Before feeding ID array into buildQuery, check whether
@@ -444,12 +444,12 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
*/
protected function mapFromStorageRecords(array $records, $load_from_revision = FALSE) {
if (!$records) {
- return array();
+ return [];
}
- $values = array();
+ $values = [];
foreach ($records as $id => $record) {
- $values[$id] = array();
+ $values[$id] = [];
// Skip the item delta and item value levels (if possible) but let the
// field assign the value as suiting. This avoids unnecessary array
// hierarchies and saves memory here.
@@ -469,13 +469,13 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
}
// Initialize translations array.
- $translations = array_fill_keys(array_keys($values), array());
+ $translations = array_fill_keys(array_keys($values), []);
// Load values from shared and dedicated tables.
$this->loadFromSharedTables($values, $translations);
$this->loadFromDedicatedTables($values, $load_from_revision);
- $entities = array();
+ $entities = [];
foreach ($values as $id => $entity_values) {
$bundle = $this->bundleKey ? $entity_values[$this->bundleKey][LanguageInterface::LANGCODE_DEFAULT] : FALSE;
// Turn the record into an entity class.
@@ -499,7 +499,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
// latest revision. Otherwise we fall back to the data table.
$table = $this->revisionDataTable ?: $this->dataTable;
$alias = $this->revisionDataTable ? 'revision' : 'data';
- $query = $this->database->select($table, $alias, array('fetch' => \PDO::FETCH_ASSOC))
+ $query = $this->database->select($table, $alias, ['fetch' => \PDO::FETCH_ASSOC])
->fields($alias)
->condition($alias . '.' . $this->idKey, array_keys($values), 'IN')
->orderBy($alias . '.' . $this->idKey);
@@ -508,7 +508,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
if ($this->revisionDataTable) {
// Find revisioned fields that are not entity keys. Exclude the langcode
// key as the base table holds only the default language.
- $base_fields = array_diff($table_mapping->getFieldNames($this->baseTable), array($this->langcodeKey));
+ $base_fields = array_diff($table_mapping->getFieldNames($this->baseTable), [$this->langcodeKey]);
$revisioned_fields = array_diff($table_mapping->getFieldNames($this->revisionDataTable), $base_fields);
// Find fields that are not revisioned or entity keys. Data fields have
@@ -535,7 +535,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
}
// Get the revision IDs.
- $revision_ids = array();
+ $revision_ids = [];
foreach ($values as $entity_values) {
$revision_ids[] = $entity_values[$this->revisionKey][LanguageInterface::LANGCODE_DEFAULT];
}
@@ -578,7 +578,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$revision = NULL;
// Build and execute the query.
- $query_result = $this->buildQuery(array(), $revision_id)->execute();
+ $query_result = $this->buildQuery([], $revision_id)->execute();
$records = $query_result->fetchAllAssoc($this->idKey);
if (!empty($records)) {
@@ -649,7 +649,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$query->addTag($this->entityTypeId . '_load_multiple');
if ($revision_id) {
- $query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $revision_id));
+ $query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", [':revisionId' => $revision_id]);
}
elseif ($this->revisionTable) {
$query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}");
@@ -832,7 +832,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
}
else {
$insert_id = $this->database
- ->insert($this->baseTable, array('return' => Database::RETURN_INSERT_ID))
+ ->insert($this->baseTable, ['return' => Database::RETURN_INSERT_ID])
->fields((array) $record)
->execute();
// Even if this is a new entity the ID key might have been set, in which
@@ -944,7 +944,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
// @todo Give field types more control over this behavior in
// https://www.drupal.org/node/2232427.
if (!$definition->getMainPropertyName() && count($columns) == 1) {
- $value = ($item = $entity->$field_name->first()) ? $item->getValue() : array();
+ $value = ($item = $entity->$field_name->first()) ? $item->getValue() : [];
}
else {
$value = isset($entity->$field_name->$column_name) ? $entity->$field_name->$column_name : NULL;
@@ -1031,7 +1031,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
if ($entity->isNewRevision()) {
$insert_id = $this->database
- ->insert($this->revisionTable, array('return' => Database::RETURN_INSERT_ID))
+ ->insert($this->revisionTable, ['return' => Database::RETURN_INSERT_ID])
->fields((array) $record)
->execute();
// Even if this is a new revision, the revision ID key might have been
@@ -1041,7 +1041,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
}
if ($entity->isDefaultRevision()) {
$this->database->update($this->entityType->getBaseTable())
- ->fields(array($this->revisionKey => $record->{$this->revisionKey}))
+ ->fields([$this->revisionKey => $record->{$this->revisionKey}])
->condition($this->idKey, $record->{$this->idKey})
->execute();
}
@@ -1082,9 +1082,9 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
}
// Collect entities ids, bundles and languages.
- $bundles = array();
- $ids = array();
- $default_langcodes = array();
+ $bundles = [];
+ $ids = [];
+ $default_langcodes = [];
foreach ($values as $key => $entity_values) {
$bundles[$this->bundleKey ? $entity_values[$this->bundleKey][LanguageInterface::LANGCODE_DEFAULT] : $this->entityTypeId] = TRUE;
$ids[] = !$load_from_revision ? $key : $entity_values[$this->revisionKey][LanguageInterface::LANGCODE_DEFAULT];
@@ -1094,8 +1094,8 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
}
// Collect impacted fields.
- $storage_definitions = array();
- $definitions = array();
+ $storage_definitions = [];
+ $definitions = [];
$table_mapping = $this->getTableMapping();
foreach ($bundles as $bundle => $v) {
$definitions[$bundle] = $this->entityManager->getFieldDefinitions($this->entityTypeId, $bundle);
@@ -1134,14 +1134,14 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
}
if (!isset($values[$row->entity_id][$field_name][$langcode])) {
- $values[$row->entity_id][$field_name][$langcode] = array();
+ $values[$row->entity_id][$field_name][$langcode] = [];
}
// Ensure that records for non-translatable fields having invalid
// languages are skipped.
if ($langcode == LanguageInterface::LANGCODE_DEFAULT || $definitions[$bundle][$field_name]->isTranslatable()) {
if ($storage_definition->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || count($values[$row->entity_id][$field_name][$langcode]) < $storage_definition->getCardinality()) {
- $item = array();
+ $item = [];
// For each column declared by the field, populate the item from the
// prefixed database column.
foreach ($storage_definition->getColumns() as $column => $attributes) {
@@ -1169,7 +1169,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
* (optional) The names of the fields to be stored. Defaults to all the
* available fields.
*/
- protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = array()) {
+ protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = []) {
$vid = $entity->getRevisionId();
$id = $entity->id();
$bundle = $entity->bundle();
@@ -1224,7 +1224,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
// Prepare the multi-insert query.
$do_insert = FALSE;
- $columns = array('entity_id', 'revision_id', 'bundle', 'delta', 'langcode');
+ $columns = ['entity_id', 'revision_id', 'bundle', 'delta', 'langcode'];
foreach ($storage_definition->getColumns() as $column => $attributes) {
$columns[] = $table_mapping->getFieldColumnName($storage_definition, $column);
}
@@ -1233,7 +1233,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$revision_query = $this->database->insert($revision_name)->fields($columns);
}
- $langcodes = $field_definition->isTranslatable() ? $translation_langcodes : array($default_langcode);
+ $langcodes = $field_definition->isTranslatable() ? $translation_langcodes : [$default_langcode];
foreach ($langcodes as $langcode) {
$delta_count = 0;
$items = $entity->getTranslation($langcode)->get($field_name);
@@ -1241,13 +1241,13 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
foreach ($items as $delta => $item) {
// We now know we have something to insert.
$do_insert = TRUE;
- $record = array(
+ $record = [
'entity_id' => $id,
'revision_id' => $vid,
'bundle' => $bundle,
'delta' => $delta,
'langcode' => $langcode,
- );
+ ];
foreach ($storage_definition->getColumns() as $column => $attributes) {
$column_name = $table_mapping->getFieldColumnName($storage_definition, $column);
// Serialize the value if specified in the column schema.
@@ -1434,11 +1434,11 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$table = $table_mapping->getDedicatedDataTableName($storage_definition);
$revision_table = $table_mapping->getDedicatedRevisionTableName($storage_definition);
$this->database->update($table)
- ->fields(array('deleted' => 1))
+ ->fields(['deleted' => 1])
->execute();
if ($this->entityType->isRevisionable()) {
$this->database->update($revision_table)
- ->fields(array('deleted' => 1))
+ ->fields(['deleted' => 1])
->execute();
}
}
@@ -1484,12 +1484,12 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$table_name = $table_mapping->getDedicatedDataTableName($storage_definition);
$revision_name = $table_mapping->getDedicatedRevisionTableName($storage_definition);
$this->database->update($table_name)
- ->fields(array('deleted' => 1))
+ ->fields(['deleted' => 1])
->condition('bundle', $field_definition->getTargetBundle())
->execute();
if ($this->entityType->isRevisionable()) {
$this->database->update($revision_name)
- ->fields(array('deleted' => 1))
+ ->fields(['deleted' => 1])
->condition('bundle', $field_definition->getTargetBundle())
->execute();
}
@@ -1518,27 +1518,27 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$table_name = $table_mapping->getDedicatedDataTableName($storage_definition, $is_deleted);
// Get the entities which we want to purge first.
- $entity_query = $this->database->select($table_name, 't', array('fetch' => \PDO::FETCH_ASSOC));
+ $entity_query = $this->database->select($table_name, 't', ['fetch' => \PDO::FETCH_ASSOC]);
$or = $entity_query->orConditionGroup();
foreach ($storage_definition->getColumns() as $column_name => $data) {
$or->isNotNull($table_mapping->getFieldColumnName($storage_definition, $column_name));
}
$entity_query
->distinct(TRUE)
- ->fields('t', array('entity_id'))
+ ->fields('t', ['entity_id'])
->condition('bundle', $field_definition->getTargetBundle())
->range(0, $batch_size);
// Create a map of field data table column names to field column names.
- $column_map = array();
+ $column_map = [];
foreach ($storage_definition->getColumns() as $column_name => $data) {
$column_map[$table_mapping->getFieldColumnName($storage_definition, $column_name)] = $column_name;
}
- $entities = array();
- $items_by_entity = array();
+ $entities = [];
+ $items_by_entity = [];
foreach ($entity_query->execute() as $row) {
- $item_query = $this->database->select($table_name, 't', array('fetch' => \PDO::FETCH_ASSOC))
+ $item_query = $this->database->select($table_name, 't', ['fetch' => \PDO::FETCH_ASSOC])
->fields('t')
->condition('entity_id', $row['entity_id'])
->condition('deleted', 1)
@@ -1552,7 +1552,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
// factory, see https://www.drupal.org/node/1867228.
$entities[$item_row['revision_id']] = _field_create_entity_from_ids((object) $item_row);
}
- $item = array();
+ $item = [];
foreach ($column_map as $db_column => $field_column) {
$item[$field_column] = $item_row[$db_column];
}
@@ -1625,7 +1625,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$query->condition($or);
if (!$as_bool) {
$query
- ->fields('t', array('entity_id'))
+ ->fields('t', ['entity_id'])
->distinct(TRUE);
}
}
@@ -1650,7 +1650,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$query->condition($or);
if (!$as_bool) {
$query
- ->fields('t', array($this->idKey))
+ ->fields('t', [$this->idKey])
->distinct(TRUE);
}
}
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
index 96cea9f49db..85d6fbed33e 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
@@ -522,7 +522,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
foreach ($table_names as $table_name) {
if (!isset($schema[$table_name])) {
- $schema[$table_name] = array();
+ $schema[$table_name] = [];
}
foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
if (!isset($storage_definitions[$field_name])) {
@@ -583,12 +583,12 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* A list of entity type tables, keyed by table key.
*/
protected function getEntitySchemaTables() {
- return array_filter(array(
+ return array_filter([
'base_table' => $this->storage->getBaseTable(),
'revision_table' => $this->storage->getRevisionTable(),
'data_table' => $this->storage->getDataTable(),
'revision_data_table' => $this->storage->getRevisionDataTable(),
- ));
+ ]);
}
/**
@@ -693,7 +693,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* The schema definition for the specified key.
*/
protected function getFieldSchemaData($field_name, array $field_schema, array $column_mapping, $schema_key) {
- $data = array();
+ $data = [];
$entity_type_id = $this->entityType->id();
foreach ($field_schema[$schema_key] as $key => $columns) {
@@ -708,7 +708,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
// name and length.
if (is_array($column)) {
list($column_name, $length) = $column;
- $data[$real_key][] = array($column_mapping[$column_name], $length);
+ $data[$real_key][] = [$column_mapping[$column_name], $length];
}
else {
$data[$real_key][] = $column_mapping[$column];
@@ -761,7 +761,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* The schema definition for the foreign keys.
*/
protected function getFieldForeignKeys($field_name, array $field_schema, array $column_mapping) {
- $foreign_keys = array();
+ $foreign_keys = [];
foreach ($field_schema['foreign keys'] as $specifier => $specification) {
// To avoid clashes with entity-level foreign keys we use
@@ -790,7 +790,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* The entity schema data array.
*/
protected function loadEntitySchemaData(EntityTypeInterface $entity_type) {
- return $this->installedStorageSchema()->get($entity_type->id() . '.entity_schema_data', array());
+ return $this->installedStorageSchema()->get($entity_type->id() . '.entity_schema_data', []);
}
/**
@@ -826,7 +826,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* The field schema data array.
*/
protected function loadFieldSchemaData(FieldStorageDefinitionInterface $storage_definition) {
- return $this->installedStorageSchema()->get($storage_definition->getTargetEntityTypeId() . '.field_schema_data.' . $storage_definition->getName(), array());
+ return $this->installedStorageSchema()->get($storage_definition->getTargetEntityTypeId() . '.field_schema_data.' . $storage_definition->getName(), []);
}
/**
@@ -863,21 +863,21 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
protected function initializeBaseTable(ContentEntityTypeInterface $entity_type) {
$entity_type_id = $entity_type->id();
- $schema = array(
+ $schema = [
'description' => "The base table for $entity_type_id entities.",
- 'primary key' => array($entity_type->getKey('id')),
- 'indexes' => array(),
- 'foreign keys' => array(),
- );
+ 'primary key' => [$entity_type->getKey('id')],
+ 'indexes' => [],
+ 'foreign keys' => [],
+ ];
if ($entity_type->hasKey('revision')) {
$revision_key = $entity_type->getKey('revision');
$key_name = $this->getEntityIndexName($entity_type, $revision_key);
- $schema['unique keys'][$key_name] = array($revision_key);
- $schema['foreign keys'][$entity_type_id . '__revision'] = array(
+ $schema['unique keys'][$key_name] = [$revision_key];
+ $schema['foreign keys'][$entity_type_id . '__revision'] = [
'table' => $this->storage->getRevisionTable(),
- 'columns' => array($revision_key => $revision_key),
- );
+ 'columns' => [$revision_key => $revision_key],
+ ];
}
$this->addTableDefaults($schema);
@@ -899,19 +899,19 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$id_key = $entity_type->getKey('id');
$revision_key = $entity_type->getKey('revision');
- $schema = array(
+ $schema = [
'description' => "The revision table for $entity_type_id entities.",
- 'primary key' => array($revision_key),
- 'indexes' => array(),
- 'foreign keys' => array(
- $entity_type_id . '__revisioned' => array(
+ 'primary key' => [$revision_key],
+ 'indexes' => [],
+ 'foreign keys' => [
+ $entity_type_id . '__revisioned' => [
'table' => $this->storage->getBaseTable(),
- 'columns' => array($id_key => $id_key),
- ),
- ),
- );
+ 'columns' => [$id_key => $id_key],
+ ],
+ ],
+ ];
- $schema['indexes'][$this->getEntityIndexName($entity_type, $id_key)] = array($id_key);
+ $schema['indexes'][$this->getEntityIndexName($entity_type, $id_key)] = [$id_key];
$this->addTableDefaults($schema);
@@ -931,23 +931,23 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$entity_type_id = $entity_type->id();
$id_key = $entity_type->getKey('id');
- $schema = array(
+ $schema = [
'description' => "The data table for $entity_type_id entities.",
- 'primary key' => array($id_key, $entity_type->getKey('langcode')),
- 'indexes' => array(
- $entity_type_id . '__id__default_langcode__langcode' => array($id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')),
- ),
- 'foreign keys' => array(
- $entity_type_id => array(
+ 'primary key' => [$id_key, $entity_type->getKey('langcode')],
+ 'indexes' => [
+ $entity_type_id . '__id__default_langcode__langcode' => [$id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')],
+ ],
+ 'foreign keys' => [
+ $entity_type_id => [
'table' => $this->storage->getBaseTable(),
- 'columns' => array($id_key => $id_key),
- ),
- ),
- );
+ 'columns' => [$id_key => $id_key],
+ ],
+ ],
+ ];
if ($entity_type->hasKey('revision')) {
$key = $entity_type->getKey('revision');
- $schema['indexes'][$this->getEntityIndexName($entity_type, $key)] = array($key);
+ $schema['indexes'][$this->getEntityIndexName($entity_type, $key)] = [$key];
}
$this->addTableDefaults($schema);
@@ -969,23 +969,23 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$id_key = $entity_type->getKey('id');
$revision_key = $entity_type->getKey('revision');
- $schema = array(
+ $schema = [
'description' => "The revision data table for $entity_type_id entities.",
- 'primary key' => array($revision_key, $entity_type->getKey('langcode')),
- 'indexes' => array(
- $entity_type_id . '__id__default_langcode__langcode' => array($id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')),
- ),
- 'foreign keys' => array(
- $entity_type_id => array(
+ 'primary key' => [$revision_key, $entity_type->getKey('langcode')],
+ 'indexes' => [
+ $entity_type_id . '__id__default_langcode__langcode' => [$id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')],
+ ],
+ 'foreign keys' => [
+ $entity_type_id => [
'table' => $this->storage->getBaseTable(),
- 'columns' => array($id_key => $id_key),
- ),
- $entity_type_id . '__revision' => array(
+ 'columns' => [$id_key => $id_key],
+ ],
+ $entity_type_id . '__revision' => [
'table' => $this->storage->getRevisionTable(),
- 'columns' => array($revision_key => $revision_key),
- )
- ),
- );
+ 'columns' => [$revision_key => $revision_key],
+ ]
+ ],
+ ];
$this->addTableDefaults($schema);
@@ -999,12 +999,12 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* The schema definition array for a single table, passed by reference.
*/
protected function addTableDefaults(&$schema) {
- $schema += array(
- 'fields' => array(),
- 'unique keys' => array(),
- 'indexes' => array(),
- 'foreign keys' => array(),
- );
+ $schema += [
+ 'fields' => [],
+ 'unique keys' => [],
+ 'indexes' => [],
+ 'foreign keys' => [],
+ ];
}
/**
@@ -1149,7 +1149,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
// Iterate over the mapped table to find the ones that will host the created
// field schema.
- $schema = array();
+ $schema = [];
foreach ($shared_table_names as $table_name) {
foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
if ($field_name == $created_field_name) {
@@ -1329,15 +1329,15 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
foreach ($schema['indexes'] as $name => $columns) {
if (!isset($original_schema['indexes'][$name]) || $columns != $original_schema['indexes'][$name]) {
$real_name = $this->getFieldIndexName($storage_definition, $name);
- $real_columns = array();
+ $real_columns = [];
foreach ($columns as $column_name) {
// Indexes can be specified as either a column name or an array with
// column name and length. Allow for either case.
if (is_array($column_name)) {
- $real_columns[] = array(
+ $real_columns[] = [
$table_mapping->getFieldColumnName($storage_definition, $column_name[0]),
$column_name[1],
- );
+ ];
}
else {
$real_columns[] = $table_mapping->getFieldColumnName($storage_definition, $column_name);
@@ -1403,7 +1403,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
// Iterate over the mapped table to find the ones that host the deleted
// field schema.
$original_schema = $this->loadFieldSchemaData($original);
- $schema = array();
+ $schema = [];
foreach ($table_mapping->getTableNames() as $table_name) {
foreach ($table_mapping->getFieldNames($table_name) as $field_name) {
if ($field_name == $updated_field_name) {
@@ -1598,7 +1598,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
* Exception thrown if the schema contains reserved column names.
*/
protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
- $schema = array();
+ $schema = [];
$field_schema = $storage_definition->getSchema();
// Check that the schema does not include forbidden column names.
@@ -1670,7 +1670,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
protected function addSharedTableFieldIndex(FieldStorageDefinitionInterface $storage_definition, &$schema, $not_null = FALSE, $size = NULL) {
$name = $storage_definition->getName();
$real_key = $this->getFieldSchemaIdentifierName($storage_definition->getTargetEntityTypeId(), $name);
- $schema['indexes'][$real_key] = array($size ? array($name, $size) : $name);
+ $schema['indexes'][$real_key] = [$size ? [$name, $size] : $name];
if ($not_null) {
$schema['fields'][$name]['not null'] = TRUE;
}
@@ -1690,7 +1690,7 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
protected function addSharedTableFieldUniqueKey(FieldStorageDefinitionInterface $storage_definition, &$schema) {
$name = $storage_definition->getName();
$real_key = $this->getFieldSchemaIdentifierName($storage_definition->getTargetEntityTypeId(), $name);
- $schema['unique keys'][$real_key] = array($name);
+ $schema['unique keys'][$real_key] = [$name];
$schema['fields'][$name]['not null'] = TRUE;
}
@@ -1709,10 +1709,10 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
protected function addSharedTableFieldForeignKey(FieldStorageDefinitionInterface $storage_definition, &$schema, $foreign_table, $foreign_column) {
$name = $storage_definition->getName();
$real_key = $this->getFieldSchemaIdentifierName($storage_definition->getTargetEntityTypeId(), $name);
- $schema['foreign keys'][$real_key] = array(
+ $schema['foreign keys'][$real_key] = [
'table' => $foreign_table,
- 'columns' => array($name => $foreign_column),
- );
+ 'columns' => [$name => $foreign_column],
+ ];
}
/**
@@ -1742,20 +1742,20 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$id_definition = $this->fieldStorageDefinitions[$this->entityType->getKey('id')];
if ($id_definition->getType() == 'integer') {
- $id_schema = array(
+ $id_schema = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The entity id this data is attached to',
- );
+ ];
}
else {
- $id_schema = array(
+ $id_schema = [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'description' => 'The entity id this data is attached to',
- );
+ ];
}
// Define the revision ID schema.
@@ -1764,61 +1764,61 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$revision_id_schema['description'] = 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id';
}
elseif ($this->fieldStorageDefinitions[$this->entityType->getKey('revision')]->getType() == 'integer') {
- $revision_id_schema = array(
+ $revision_id_schema = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The entity revision id this data is attached to',
- );
+ ];
}
else {
- $revision_id_schema = array(
+ $revision_id_schema = [
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'description' => 'The entity revision id this data is attached to',
- );
+ ];
}
- $data_schema = array(
+ $data_schema = [
'description' => $description_current,
- 'fields' => array(
- 'bundle' => array(
+ 'fields' => [
+ 'bundle' => [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The field instance bundle to which this row belongs, used when deleting a field instance',
- ),
- 'deleted' => array(
+ ],
+ 'deleted' => [
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'A boolean indicating whether this data item has been deleted'
- ),
+ ],
'entity_id' => $id_schema,
'revision_id' => $revision_id_schema,
- 'langcode' => array(
+ 'langcode' => [
'type' => 'varchar_ascii',
'length' => 32,
'not null' => TRUE,
'default' => '',
'description' => 'The language code for this data item.',
- ),
- 'delta' => array(
+ ],
+ 'delta' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The sequence number for this data item, used for multi-value fields',
- ),
- ),
- 'primary key' => array('entity_id', 'deleted', 'delta', 'langcode'),
- 'indexes' => array(
- 'bundle' => array('bundle'),
- 'revision_id' => array('revision_id'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['entity_id', 'deleted', 'delta', 'langcode'],
+ 'indexes' => [
+ 'bundle' => ['bundle'],
+ 'revision_id' => ['revision_id'],
+ ],
+ ];
// Check that the schema does not include forbidden column names.
$schema = $storage_definition->getSchema();
@@ -1845,10 +1845,10 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
// Indexes can be specified as either a column name or an array with
// column name and length. Allow for either case.
if (is_array($column_name)) {
- $data_schema['indexes'][$real_name][] = array(
+ $data_schema['indexes'][$real_name][] = [
$table_mapping->getFieldColumnName($storage_definition, $column_name[0]),
$column_name[1],
- );
+ ];
}
else {
$data_schema['indexes'][$real_name][] = $table_mapping->getFieldColumnName($storage_definition, $column_name);
@@ -1863,10 +1863,10 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
// Unique keys can be specified as either a column name or an array with
// column name and length. Allow for either case.
if (is_array($column_name)) {
- $data_schema['unique keys'][$real_name][] = array(
+ $data_schema['unique keys'][$real_name][] = [
$table_mapping->getFieldColumnName($storage_definition, $column_name[0]),
$column_name[1],
- );
+ ];
}
else {
$data_schema['unique keys'][$real_name][] = $table_mapping->getFieldColumnName($storage_definition, $column_name);
@@ -1884,17 +1884,17 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
}
}
- $dedicated_table_schema = array($table_mapping->getDedicatedDataTableName($storage_definition) => $data_schema);
+ $dedicated_table_schema = [$table_mapping->getDedicatedDataTableName($storage_definition) => $data_schema];
// If the entity type is revisionable, construct the revision table.
$entity_type = $entity_type ?: $this->entityType;
if ($entity_type->isRevisionable()) {
$revision_schema = $data_schema;
$revision_schema['description'] = $description_revision;
- $revision_schema['primary key'] = array('entity_id', 'revision_id', 'deleted', 'delta', 'langcode');
+ $revision_schema['primary key'] = ['entity_id', 'revision_id', 'deleted', 'delta', 'langcode'];
$revision_schema['fields']['revision_id']['not null'] = TRUE;
$revision_schema['fields']['revision_id']['description'] = 'The entity revision id this data is attached to';
- $dedicated_table_schema += array($table_mapping->getDedicatedRevisionTableName($storage_definition) => $revision_schema);
+ $dedicated_table_schema += [$table_mapping->getDedicatedRevisionTableName($storage_definition) => $revision_schema];
}
return $dedicated_table_schema;
diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php
index 12e7f8d780d..be6405af4ab 100644
--- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php
+++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php
@@ -19,7 +19,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
* @return static
*/
public static function create($entity_type_id = NULL) {
- $definition = new static(array());
+ $definition = new static([]);
// Set the passed entity type.
if (isset($entity_type_id)) {
$definition->setEntityTypeId($entity_type_id);
@@ -41,7 +41,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
$definition->setEntityTypeId($parts[1]);
}
if (isset($parts[2])) {
- $definition->setBundles(array($parts[2]));
+ $definition->setBundles([$parts[2]]);
}
return $definition;
}
@@ -55,7 +55,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
// Return an empty array for entities that are not content entities.
$entity_type_class = \Drupal::entityManager()->getDefinition($entity_type_id)->getClass();
if (!in_array('Drupal\Core\Entity\FieldableEntityInterface', class_implements($entity_type_class))) {
- $this->propertyDefinitions = array();
+ $this->propertyDefinitions = [];
}
else {
// @todo: Add support for handling multiple bundles.
@@ -71,7 +71,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
}
else {
// No entity type given.
- $this->propertyDefinitions = array();
+ $this->propertyDefinitions = [];
}
}
return $this->propertyDefinitions;
@@ -115,7 +115,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
*/
public function getBundles() {
$bundle = isset($this->definition['constraints']['Bundle']) ? $this->definition['constraints']['Bundle'] : NULL;
- return is_string($bundle) ? array($bundle) : $bundle;
+ return is_string($bundle) ? [$bundle] : $bundle;
}
/**
diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php
index 5ee5af61489..f9f4271e3b6 100644
--- a/core/lib/Drupal/Core/Entity/entity.api.php
+++ b/core/lib/Drupal/Core/Entity/entity.api.php
@@ -939,12 +939,12 @@ function hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) {
function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
// Insert the new entity into a fictional table of all entities.
db_insert('example_entity')
- ->fields(array(
+ ->fields([
'type' => $entity->getEntityTypeId(),
'id' => $entity->id(),
'created' => REQUEST_TIME,
'updated' => REQUEST_TIME,
- ))
+ ])
->execute();
}
@@ -963,11 +963,11 @@ function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) {
// Insert the new entity into a fictional table of this type of entity.
db_insert('example_entity')
- ->fields(array(
+ ->fields([
'id' => $entity->id(),
'created' => REQUEST_TIME,
'updated' => REQUEST_TIME,
- ))
+ ])
->execute();
}
@@ -987,9 +987,9 @@ function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) {
function hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
// Update the entity's entry in a fictional table of all entities.
db_update('example_entity')
- ->fields(array(
+ ->fields([
'updated' => REQUEST_TIME,
- ))
+ ])
->condition('type', $entity->getEntityTypeId())
->condition('id', $entity->id())
->execute();
@@ -1011,9 +1011,9 @@ function hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
function hook_ENTITY_TYPE_update(Drupal\Core\Entity\EntityInterface $entity) {
// Update the entity's entry in a fictional table of this type of entity.
db_update('example_entity')
- ->fields(array(
+ ->fields([
'updated' => REQUEST_TIME,
- ))
+ ])
->condition('id', $entity->id())
->execute();
}
@@ -1063,10 +1063,10 @@ function hook_ENTITY_TYPE_translation_create(\Drupal\Core\Entity\EntityInterface
* @see hook_ENTITY_TYPE_translation_insert()
*/
function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) {
- $variables = array(
+ $variables = [
'@language' => $translation->language()->getName(),
'@label' => $translation->getUntranslated()->label(),
- );
+ ];
\Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables);
}
@@ -1083,10 +1083,10 @@ function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $tra
* @see hook_entity_translation_insert()
*/
function hook_ENTITY_TYPE_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) {
- $variables = array(
+ $variables = [
'@language' => $translation->language()->getName(),
'@label' => $translation->getUntranslated()->label(),
- );
+ ];
\Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables);
}
@@ -1102,10 +1102,10 @@ function hook_ENTITY_TYPE_translation_insert(\Drupal\Core\Entity\EntityInterface
* @see hook_ENTITY_TYPE_translation_delete()
*/
function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) {
- $variables = array(
+ $variables = [
'@language' => $translation->language()->getName(),
'@label' => $translation->label(),
- );
+ ];
\Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables);
}
@@ -1121,10 +1121,10 @@ function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $tra
* @see hook_entity_translation_delete()
*/
function hook_ENTITY_TYPE_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) {
- $variables = array(
+ $variables = [
'@language' => $translation->language()->getName(),
'@label' => $translation->label(),
- );
+ ];
\Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables);
}
@@ -1151,8 +1151,8 @@ function hook_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) {
// Log the count in a table that records this statistic for deleted entities.
db_merge('example_deleted_entity_statistics')
- ->key(array('type' => $type, 'id' => $id))
- ->fields(array('count' => $count))
+ ->key(['type' => $type, 'id' => $id])
+ ->fields(['count' => $count])
->execute();
}
@@ -1179,8 +1179,8 @@ function hook_ENTITY_TYPE_predelete(Drupal\Core\Entity\EntityInterface $entity)
// Log the count in a table that records this statistic for deleted entities.
db_merge('example_deleted_entity_statistics')
- ->key(array('type' => $type, 'id' => $id))
- ->fields(array('count' => $count))
+ ->key(['type' => $type, 'id' => $id])
+ ->fields(['count' => $count])
->execute();
}
@@ -1283,10 +1283,10 @@ function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $en
// This assumes a 'mymodule_addition' extra field has been defined for the
// entity bundle in hook_entity_extra_field_info().
if ($display->getComponent('mymodule_addition')) {
- $build['mymodule_addition'] = array(
+ $build['mymodule_addition'] = [
'#markup' => mymodule_addition($entity),
'#theme' => 'mymodule_my_additional_field',
- );
+ ];
}
}
@@ -1315,10 +1315,10 @@ function hook_ENTITY_TYPE_view(array &$build, \Drupal\Core\Entity\EntityInterfac
// This assumes a 'mymodule_addition' extra field has been defined for the
// entity bundle in hook_entity_extra_field_info().
if ($display->getComponent('mymodule_addition')) {
- $build['mymodule_addition'] = array(
+ $build['mymodule_addition'] = [
'#markup' => mymodule_addition($entity),
'#theme' => 'mymodule_my_additional_field',
- );
+ ];
}
}
@@ -1423,7 +1423,7 @@ function hook_entity_prepare_view($entity_type_id, array $entities, array $displ
// Only do the extra work if the component is configured to be
// displayed. This assumes a 'mymodule_addition' extra field has been
// defined for the entity bundle in hook_entity_extra_field_info().
- $ids = array();
+ $ids = [];
foreach ($entities as $id => $entity) {
if ($displays[$entity->bundle()]->getComponent('mymodule_addition')) {
$ids[] = $id;
@@ -1634,9 +1634,9 @@ function hook_ENTITY_TYPE_prepare_form(\Drupal\Core\Entity\EntityInterface $enti
function hook_entity_form_display_alter(\Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display, array $context) {
// Hide the 'user_picture' field from the register form.
if ($context['entity_type'] == 'user' && $context['form_mode'] == 'register') {
- $form_display->setComponent('user_picture', array(
+ $form_display->setComponent('user_picture', [
'region' => 'hidden',
- ));
+ ]);
}
}
@@ -1657,7 +1657,7 @@ function hook_entity_form_display_alter(\Drupal\Core\Entity\Display\EntityFormDi
*/
function hook_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'node') {
- $fields = array();
+ $fields = [];
$fields['mymodule_text'] = BaseFieldDefinition::create('string')
->setLabel(t('The text'))
->setDescription(t('A text property added by mymodule.'))
@@ -1721,7 +1721,7 @@ function hook_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityT
function hook_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
// Add a property only to nodes of the 'article' bundle.
if ($entity_type->id() == 'node' && $bundle == 'article') {
- $fields = array();
+ $fields = [];
$fields['mymodule_text_more'] = BaseFieldDefinition::create('string')
->setLabel(t('More text'))
->setComputed(TRUE)
@@ -1776,7 +1776,7 @@ function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface
->execute();
// Fetch all fields and key them by field name.
$field_storages = FieldStorageConfig::loadMultiple($ids);
- $result = array();
+ $result = [];
foreach ($field_storages as $field_storage) {
$result[$field_storage->getName()] = $field_storage;
}
@@ -1815,12 +1815,12 @@ function hook_entity_field_storage_info_alter(&$fields, \Drupal\Core\Entity\Enti
* @see \Drupal\Core\Entity\EntityListBuilderInterface::getOperations()
*/
function hook_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
- $operations = array();
- $operations['translate'] = array(
+ $operations = [];
+ $operations['translate'] = [
'title' => t('Translate'),
'url' => \Drupal\Core\Url::fromRoute('foo_module.entity.translate'),
'weight' => 50,
- );
+ ];
return $operations;
}
@@ -1836,9 +1836,9 @@ function hook_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
*/
function hook_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
// Alter the title and weight.
- $operations['translate']['title'] = t('Translate @entity_type', array(
+ $operations['translate']['title'] = t('Translate @entity_type', [
'@entity_type' => $entity->getEntityTypeId(),
- ));
+ ]);
$operations['translate']['weight'] = 99;
}
@@ -1964,7 +1964,7 @@ function hook_ENTITY_TYPE_field_values_init(\Drupal\Core\Entity\FieldableEntityI
* \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields().
*/
function hook_entity_extra_field_info() {
- $extra = array();
+ $extra = [];
$module_language_enabled = \Drupal::moduleHandler()->moduleExists('language');
$description = t('Node module element');
@@ -1977,19 +1977,19 @@ function hook_entity_extra_field_info() {
if ($module_language_enabled) {
$configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $bundle->id());
if ($configuration->isLanguageAlterable()) {
- $extra['node'][$bundle->id()]['form']['language'] = array(
+ $extra['node'][$bundle->id()]['form']['language'] = [
'label' => t('Language'),
'description' => $description,
'weight' => 0,
- );
+ ];
}
}
- $extra['node'][$bundle->id()]['display']['language'] = array(
+ $extra['node'][$bundle->id()]['display']['language'] = [
'label' => t('Language'),
'description' => $description,
'weight' => 0,
'visible' => FALSE,
- );
+ ];
}
return $extra;
diff --git a/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php
index e2ffc058e09..701c4337392 100644
--- a/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php
@@ -110,8 +110,8 @@ class AjaxResponseSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events[KernelEvents::RESPONSE][] = array('onResponse', -100);
- $events[KernelEvents::REQUEST][] = array('onRequest', 50);
+ $events[KernelEvents::RESPONSE][] = ['onResponse', -100];
+ $events[KernelEvents::REQUEST][] = ['onRequest', 50];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
index 24b4c70d5fb..e948aa584c2 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
@@ -54,13 +54,13 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
* @throws \Drupal\Core\Config\ConfigNameException
*/
public function onConfigImporterValidate(ConfigImporterEvent $event) {
- foreach (array('delete', 'create', 'update') as $op) {
+ foreach (['delete', 'create', 'update'] as $op) {
foreach ($event->getConfigImporter()->getUnprocessedConfiguration($op) as $name) {
try {
Config::validateName($name);
}
catch (ConfigNameException $e) {
- $message = $this->t('The config name @config_name is invalid.', array('@config_name' => $name));
+ $message = $this->t('The config name @config_name is invalid.', ['@config_name' => $name]);
$event->getConfigImporter()->logError($message);
}
}
@@ -88,7 +88,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
$module_data = $this->getModuleData();
$nonexistent_modules = array_keys(array_diff_key($core_extension['module'], $module_data));
foreach ($nonexistent_modules as $module) {
- $config_importer->logError($this->t('Unable to install the %module module since it does not exist.', array('%module' => $module)));
+ $config_importer->logError($this->t('Unable to install the %module module since it does not exist.', ['%module' => $module]));
}
// Ensure that all modules being installed have their dependencies met.
@@ -105,7 +105,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
$message = $this->formatPlural(count($missing_dependencies),
'Unable to install the %module module since it requires the %required_module module.',
'Unable to install the %module module since it requires the %required_module modules.',
- array('%module' => $module_name, '%required_module' => implode(', ', $missing_dependencies))
+ ['%module' => $module_name, '%required_module' => implode(', ', $missing_dependencies)]
);
$config_importer->logError($message);
}
@@ -123,7 +123,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
if ($module_data[$dependent_module]->status && !in_array($dependent_module, $uninstalls, TRUE) && $dependent_module !== $install_profile) {
$module_name = $module_data[$module]->info['name'];
$dependent_module_name = $module_data[$dependent_module]->info['name'];
- $config_importer->logError($this->t('Unable to uninstall the %module module since the %dependent_module module is installed.', array('%module' => $module_name, '%dependent_module' => $dependent_module_name)));
+ $config_importer->logError($this->t('Unable to uninstall the %module module since the %dependent_module module is installed.', ['%module' => $module_name, '%dependent_module' => $dependent_module_name]));
}
}
}
@@ -131,12 +131,12 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
// Ensure that the install profile is not being uninstalled.
if (in_array($install_profile, $uninstalls, TRUE)) {
$profile_name = $module_data[$install_profile]->info['name'];
- $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the install profile.', array('%profile' => $profile_name)));
+ $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the install profile.', ['%profile' => $profile_name]));
}
// Ensure the profile is not changing.
if ($install_profile !== $core_extension['profile']) {
- $config_importer->logError($this->t('Cannot change the install profile from %new_profile to %profile once Drupal is installed.', array('%profile' => $install_profile, '%new_profile' => $core_extension['profile'])));
+ $config_importer->logError($this->t('Cannot change the install profile from %new_profile to %profile once Drupal is installed.', ['%profile' => $install_profile, '%new_profile' => $core_extension['profile']]));
}
}
@@ -153,7 +153,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
$installs = $config_importer->getExtensionChangelist('theme', 'install');
foreach ($installs as $key => $theme) {
if (!isset($theme_data[$theme])) {
- $config_importer->logError($this->t('Unable to install the %theme theme since it does not exist.', array('%theme' => $theme)));
+ $config_importer->logError($this->t('Unable to install the %theme theme since it does not exist.', ['%theme' => $theme]));
// Remove non-existing installs from the list so we can validate theme
// dependencies later.
unset($installs[$key]);
@@ -166,7 +166,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
if (!isset($core_extension['theme'][$required_theme])) {
$theme_name = $theme_data[$theme]->info['name'];
$required_theme_name = $theme_data[$required_theme]->info['name'];
- $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_theme theme.', array('%theme' => $theme_name, '%required_theme' => $required_theme_name)));
+ $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_theme theme.', ['%theme' => $theme_name, '%required_theme' => $required_theme_name]));
}
}
}
@@ -179,7 +179,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
if ($theme_data[$dependent_theme]->status && !in_array($dependent_theme, $uninstalls, TRUE)) {
$theme_name = $theme_data[$theme]->info['name'];
$dependent_theme_name = $theme_data[$dependent_theme]->info['name'];
- $config_importer->logError($this->t('Unable to uninstall the %theme theme since the %dependent_theme theme is installed.', array('%theme' => $theme_name, '%dependent_theme' => $dependent_theme_name)));
+ $config_importer->logError($this->t('Unable to uninstall the %theme theme since the %dependent_theme theme is installed.', ['%theme' => $theme_name, '%dependent_theme' => $dependent_theme_name]));
}
}
}
@@ -212,22 +212,22 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
if ($owner !== 'core') {
$message = FALSE;
if (!isset($core_extension['module'][$owner]) && isset($module_data[$owner])) {
- $message = $this->t('Configuration %name depends on the %owner module that will not be installed after import.', array(
+ $message = $this->t('Configuration %name depends on the %owner module that will not be installed after import.', [
'%name' => $name,
'%owner' => $module_data[$owner]->info['name']
- ));
+ ]);
}
elseif (!isset($core_extension['theme'][$owner]) && isset($theme_data[$owner])) {
- $message = $this->t('Configuration %name depends on the %owner theme that will not be installed after import.', array(
+ $message = $this->t('Configuration %name depends on the %owner theme that will not be installed after import.', [
'%name' => $name,
'%owner' => $theme_data[$owner]->info['name']
- ));
+ ]);
}
elseif (!isset($core_extension['module'][$owner]) && !isset($core_extension['theme'][$owner])) {
- $message = $this->t('Configuration %name depends on the %owner extension that will not be installed after import.', array(
+ $message = $this->t('Configuration %name depends on the %owner extension that will not be installed after import.', [
'%name' => $name,
'%owner' => $owner
- ));
+ ]);
}
if ($message) {
@@ -254,7 +254,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
count($diffs),
'Configuration %name depends on the %module module that will not be installed after import.',
'Configuration %name depends on modules (%module) that will not be installed after import.',
- array('%name' => $name, '%module' => implode(', ', $this->getNames($diffs, $module_data)))
+ ['%name' => $name, '%module' => implode(', ', $this->getNames($diffs, $module_data))]
);
break;
case 'theme':
@@ -262,7 +262,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
count($diffs),
'Configuration %name depends on the %theme theme that will not be installed after import.',
'Configuration %name depends on themes (%theme) that will not be installed after import.',
- array('%name' => $name, '%theme' => implode(', ', $this->getNames($diffs, $theme_data)))
+ ['%name' => $name, '%theme' => implode(', ', $this->getNames($diffs, $theme_data))]
);
break;
case 'config':
@@ -270,7 +270,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
count($diffs),
'Configuration %name depends on the %config configuration that will not exist after import.',
'Configuration %name depends on configuration (%config) that will not exist after import.',
- array('%name' => $name, '%config' => implode(', ', $diffs))
+ ['%name' => $name, '%config' => implode(', ', $diffs)]
);
break;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php
index e20e52f579d..330970138d9 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php
@@ -65,7 +65,7 @@ class ConfigSnapshotSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::IMPORT][] = array('onConfigImporterImport', 40);
+ $events[ConfigEvents::IMPORT][] = ['onConfigImporterImport', 40];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php
index fc491af537c..351642617d3 100644
--- a/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php
@@ -39,8 +39,8 @@ class EnforcedFormResponseSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events[KernelEvents::EXCEPTION] = array('onKernelException', 128);
- $events[KernelEvents::RESPONSE] = array('onKernelResponse', 128);
+ $events[KernelEvents::EXCEPTION] = ['onKernelException', 128];
+ $events[KernelEvents::RESPONSE] = ['onKernelResponse', 128];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php
index 3c37195ca1f..ae8dafc4e3d 100644
--- a/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php
@@ -53,7 +53,7 @@ class EntityRouteAlterSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[RoutingEvents::ALTER][] = array('onRoutingRouteAlterSetType', -150);
+ $events[RoutingEvents::ALTER][] = ['onRoutingRouteAlterSetType', -150];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
index f1088bf25f3..ab50f217ada 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
@@ -37,7 +37,7 @@ class ExceptionTestSiteSubscriber extends HttpExceptionSubscriberBase {
$exception = $event->getException();
$error = Error::decodeException($exception);
- $headers = array();
+ $headers = [];
// When running inside the testing framework, we relay the errors
// to the tested site by the way of HTTP headers.
@@ -45,15 +45,15 @@ class ExceptionTestSiteSubscriber extends HttpExceptionSubscriberBase {
// $number does not use drupal_static as it should not be reset
// as it uniquely identifies each PHP error.
static $number = 0;
- $assertion = array(
+ $assertion = [
$error['@message'],
$error['%type'],
- array(
+ [
'function' => $error['%function'],
'file' => $error['%file'],
'line' => $error['%line'],
- ),
- );
+ ],
+ ];
$headers['X-Drupal-Assertion-' . $number] = rawurlencode(serialize($assertion));
$number++;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
index 5898d17ae6a..9ea7a830239 100644
--- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
@@ -298,10 +298,10 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
public static function getSubscribedEvents() {
- $events[KernelEvents::RESPONSE][] = array('onRespond');
+ $events[KernelEvents::RESPONSE][] = ['onRespond'];
// There is no specific reason for choosing 16 beside it should be executed
// before ::onRespond().
- $events[KernelEvents::RESPONSE][] = array('onAllResponds', 16);
+ $events[KernelEvents::RESPONSE][] = ['onAllResponds', 16];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php
index 7b10dde4575..79d7dd5a39a 100644
--- a/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php
@@ -20,7 +20,7 @@ class KernelDestructionSubscriber implements EventSubscriberInterface, Container
*
* @var array
*/
- protected $services = array();
+ protected $services = [];
/**
* Registers a service for destruction.
@@ -62,7 +62,7 @@ class KernelDestructionSubscriber implements EventSubscriberInterface, Container
// Run this subscriber after others as those might use services that need
// to be terminated as well or run code that needs to run before
// termination.
- $events[KernelEvents::TERMINATE][] = array('onKernelTerminate', -100);
+ $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', -100];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
index 57d43ec0be1..ba82988a14d 100644
--- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
@@ -103,7 +103,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
// If the request format is not 'html' then show default maintenance
// mode page else show a text/plain page with maintenance message.
if ($request->getRequestFormat() !== 'html') {
- $response = new Response($this->getSiteMaintenanceMessage(), 503, array('Content-Type' => 'text/plain'));
+ $response = new Response($this->getSiteMaintenanceMessage(), 503, ['Content-Type' => 'text/plain']);
$event->setResponse($response);
return;
}
@@ -118,7 +118,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
// settings page.
if ($route_match->getRouteName() != 'system.site_maintenance_mode') {
if ($this->account->hasPermission('administer site configuration')) {
- $this->drupalSetMessage($this->t('Operating in maintenance mode. <a href=":url">Go online.</a>', array(':url' => $this->urlGenerator->generate('system.site_maintenance_mode'))), 'status', FALSE);
+ $this->drupalSetMessage($this->t('Operating in maintenance mode. <a href=":url">Go online.</a>', [':url' => $this->urlGenerator->generate('system.site_maintenance_mode')]), 'status', FALSE);
}
else {
$this->drupalSetMessage($this->t('Operating in maintenance mode.'), 'status', FALSE);
@@ -135,9 +135,9 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
* The formatted site maintenance message.
*/
protected function getSiteMaintenanceMessage() {
- return SafeMarkup::format($this->config->get('system.maintenance')->get('message'), array(
+ return SafeMarkup::format($this->config->get('system.maintenance')->get('message'), [
'@site' => $this->config->get('system.site')->get('name'),
- ));
+ ]);
}
/**
@@ -151,8 +151,8 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events[KernelEvents::REQUEST][] = array('onKernelRequestMaintenance', 30);
- $events[KernelEvents::EXCEPTION][] = array('onKernelRequestMaintenance');
+ $events[KernelEvents::REQUEST][] = ['onKernelRequestMaintenance', 30];
+ $events[KernelEvents::EXCEPTION][] = ['onKernelRequestMaintenance'];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php
index dc84a57c47f..1bc662c54df 100644
--- a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php
@@ -47,7 +47,7 @@ class MenuRouterRebuildSubscriber implements EventSubscriberInterface {
*/
public function onRouterRebuild(Event $event) {
$this->menuLinksRebuild();
- Cache::invalidateTags(array('local_task'));
+ Cache::invalidateTags(['local_task']);
}
/**
@@ -82,7 +82,7 @@ class MenuRouterRebuildSubscriber implements EventSubscriberInterface {
*/
static function getSubscribedEvents() {
// Run after CachedRouteRebuildSubscriber.
- $events[RoutingEvents::FINISHED][] = array('onRouterRebuild', 100);
+ $events[RoutingEvents::FINISHED][] = ['onRouterRebuild', 100];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php
index 271ddbee67d..19590ae6dd0 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php
@@ -45,7 +45,7 @@ class ParamConverterSubscriber implements EventSubscriberInterface {
*/
static function getSubscribedEvents() {
// Run after \Drupal\system\EventSubscriber\AdminRouteSubscriber.
- $events[RoutingEvents::ALTER][] = array('onRoutingRouteAlterSetParameterConverters', -220);
+ $events[RoutingEvents::ALTER][] = ['onRoutingRouteAlterSetParameterConverters', -220];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php
index a0bd7b06400..0ded041a26b 100644
--- a/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php
@@ -65,10 +65,10 @@ class PathRootsSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events = array();
+ $events = [];
// Try to set a low priority to ensure that all routes are already added.
- $events[RoutingEvents::ALTER][] = array('onRouteAlter', -1024);
- $events[RoutingEvents::FINISHED][] = array('onRouteFinished');
+ $events[RoutingEvents::ALTER][] = ['onRouteAlter', -1024];
+ $events[RoutingEvents::FINISHED][] = ['onRouteFinished'];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
index 77dbdbc993c..737c77cd167 100644
--- a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
@@ -71,8 +71,8 @@ class PathSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
- $events[KernelEvents::CONTROLLER][] = array('onKernelController', 200);
- $events[KernelEvents::TERMINATE][] = array('onKernelTerminate', 200);
+ $events[KernelEvents::CONTROLLER][] = ['onKernelController', 200];
+ $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 200];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
index b9a64d51ba6..bf5ca05dbe4 100644
--- a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php
@@ -166,8 +166,8 @@ class RedirectResponseSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
- $events[KernelEvents::RESPONSE][] = array('checkRedirectUrl');
- $events[KernelEvents::REQUEST][] = array('sanitizeDestination', 100);
+ $events[KernelEvents::RESPONSE][] = ['checkRedirectUrl'];
+ $events[KernelEvents::REQUEST][] = ['sanitizeDestination', 100];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php
index 64968ba8af7..b0228f888fb 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php
@@ -48,7 +48,7 @@ class ReplicaDatabaseIgnoreSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[KernelEvents::REQUEST][] = array('checkReplicaServer');
+ $events[KernelEvents::REQUEST][] = ['checkReplicaServer'];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php
index 7431e96cb18..765b1deb8c1 100644
--- a/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php
@@ -49,7 +49,7 @@ class RequestCloseSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
- $events[KernelEvents::TERMINATE][] = array('onTerminate', 100);
+ $events[KernelEvents::TERMINATE][] = ['onTerminate', 100];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php
index ebc699b5922..f12174a6bba 100644
--- a/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php
@@ -41,7 +41,7 @@ class RouteEnhancerSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[RoutingEvents::ALTER][] = array('onRouteAlter', -300);
+ $events[RoutingEvents::ALTER][] = ['onRouteAlter', -300];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php
index 901aa0c9b85..79f98a43074 100644
--- a/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php
@@ -43,7 +43,7 @@ class RouteFilterSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[RoutingEvents::ALTER][] = array('onRouteAlter', -300);
+ $events[RoutingEvents::ALTER][] = ['onRouteAlter', -300];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php
index c88e306193e..b43ebf4b8bd 100644
--- a/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php
@@ -27,7 +27,7 @@ class RouteMethodSubscriber implements EventSubscriberInterface {
foreach ($event->getRouteCollection() as $route) {
$methods = $route->getMethods();
if (empty($methods)) {
- $route->setMethods(array('GET', 'POST'));
+ $route->setMethods(['GET', 'POST']);
}
}
}
@@ -38,7 +38,7 @@ class RouteMethodSubscriber implements EventSubscriberInterface {
static function getSubscribedEvents() {
// Set a higher priority to ensure that routes get the default HTTP methods
// as early as possible.
- $events[RoutingEvents::ALTER][] = array('onRouteBuilding', 5000);
+ $events[RoutingEvents::ALTER][] = ['onRouteBuilding', 5000];
return $events;
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
index 85489cca953..0f40c5a58eb 100644
--- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php
@@ -16,7 +16,7 @@ class SpecialAttributesRouteSubscriber extends RouteSubscriberBase {
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
- $special_variables = array(
+ $special_variables = [
'system_path',
'_legacy',
'_raw_variables',
@@ -25,7 +25,7 @@ class SpecialAttributesRouteSubscriber extends RouteSubscriberBase {
'_content',
'_controller',
'_form',
- );
+ ];
foreach ($collection->all() as $name => $route) {
if ($not_allowed_variables = array_intersect($route->compile()->getVariables(), $special_variables)) {
$reserved = implode(', ', $not_allowed_variables);
diff --git a/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php b/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php
index 9970bf0cdd3..0b758c60c71 100644
--- a/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php
+++ b/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php
@@ -24,7 +24,7 @@ abstract class ExecutablePluginBase extends ContextAwarePluginBase implements Ex
if (!empty($definition['configuration'])) {
return $definition['configuration'];
}
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php b/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php
index 5c3ebc32b42..ac69f01a0ca 100644
--- a/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php
+++ b/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php
@@ -38,11 +38,11 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator {
*
* @var array
*/
- protected $whitelist = array(
+ protected $whitelist = [
'profiles',
'modules',
'themes',
- );
+ ];
/**
* List of directory names to skip when recursing.
@@ -53,7 +53,7 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator {
*
* @var array
*/
- protected $blacklist = array(
+ protected $blacklist = [
// Object-oriented code subdirectories.
'src',
'lib',
@@ -72,7 +72,7 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator {
'fixtures',
// @todo ./tests/Drupal should be ./tests/src/Drupal
'Drupal',
- );
+ ];
/**
* Whether to include test directories when recursing.
diff --git a/core/lib/Drupal/Core/Extension/Extension.php b/core/lib/Drupal/Core/Extension/Extension.php
index 02387147b98..7cb6b56be85 100644
--- a/core/lib/Drupal/Core/Extension/Extension.php
+++ b/core/lib/Drupal/Core/Extension/Extension.php
@@ -152,7 +152,7 @@ class Extension implements \Serializable {
if (!isset($this->splFileInfo)) {
$this->splFileInfo = new \SplFileInfo($this->pathname);
}
- return call_user_func_array(array($this->splFileInfo, $method), $args);
+ return call_user_func_array([$this->splFileInfo, $method], $args);
}
/**
@@ -163,11 +163,11 @@ class Extension implements \Serializable {
public function serialize() {
// Don't serialize the app root, since this could change if the install is
// moved.
- $data = array(
+ $data = [
'type' => $this->type,
'pathname' => $this->pathname,
'filename' => $this->filename,
- );
+ ];
// @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and
// system_list() are adding custom properties to the Extension object.
diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
index 177f011259c..836bee87f7b 100644
--- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
+++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
@@ -61,7 +61,7 @@ class ExtensionDiscovery {
*
* @var array
*/
- protected static $files = array();
+ protected static $files = [];
/**
* List of installation profile directories to additionally scan.
@@ -198,7 +198,7 @@ class ExtensionDiscovery {
$include_tests = Settings::get('extension_discovery_scan_tests') || drupal_valid_test_ua();
}
- $files = array();
+ $files = [];
foreach ($searchdirs as $dir) {
// Discover all extensions in the directory, unless we did already.
if (!isset(static::$files[$this->root][$dir][$include_tests])) {
@@ -227,7 +227,7 @@ class ExtensionDiscovery {
* @return $this
*/
public function setProfileDirectoriesFromSettings() {
- $this->profileDirectories = array();
+ $this->profileDirectories = [];
$profile = drupal_get_profile();
// For SimpleTest to be able to test modules packaged together with a
// distribution we need to include the profile of the parent site (in
@@ -316,8 +316,8 @@ class ExtensionDiscovery {
* The sorted list of extensions.
*/
protected function sort(array $all_files, array $weights) {
- $origins = array();
- $profiles = array();
+ $origins = [];
+ $profiles = [];
foreach ($all_files as $key => $file) {
// If the extension does not belong to a profile, just apply the weight
// of the originating directory.
@@ -371,7 +371,7 @@ class ExtensionDiscovery {
* The filtered list of extensions, keyed by extension name.
*/
protected function process(array $all_files) {
- $files = array();
+ $files = [];
// Duplicate files found in later search directories take precedence over
// earlier ones; they replace the extension in the existing $files array.
foreach ($all_files as $file) {
@@ -397,7 +397,7 @@ class ExtensionDiscovery {
* @see \Drupal\Core\Extension\Discovery\RecursiveExtensionFilterIterator
*/
protected function scanDirectory($dir, $include_tests) {
- $files = array();
+ $files = [];
// In order to scan top-level directories, absolute directory paths have to
// be used (which also improves performance, since any configured PHP
diff --git a/core/lib/Drupal/Core/Extension/InfoParser.php b/core/lib/Drupal/Core/Extension/InfoParser.php
index 4981885bd70..594a83ee698 100644
--- a/core/lib/Drupal/Core/Extension/InfoParser.php
+++ b/core/lib/Drupal/Core/Extension/InfoParser.php
@@ -12,7 +12,7 @@ class InfoParser extends InfoParserDynamic {
*
* @var array
*/
- protected static $parsedInfos = array();
+ protected static $parsedInfos = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php
index 914bb5df6a8..3b00cea0930 100644
--- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php
+++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php
@@ -15,7 +15,7 @@ class InfoParserDynamic implements InfoParserInterface {
*/
public function parse($filename) {
if (!file_exists($filename)) {
- $parsed_info = array();
+ $parsed_info = [];
}
else {
try {
@@ -42,7 +42,7 @@ class InfoParserDynamic implements InfoParserInterface {
* An array of required keys.
*/
protected function getRequiredKeys() {
- return array('type', 'core', 'name');
+ return ['type', 'core', 'name'];
}
}
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php
index f857bf10ae0..cfbaa61a8e4 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -106,9 +106,9 @@ class ModuleHandler implements ModuleHandlerInterface {
* @see \Drupal\Core\DrupalKernel
* @see \Drupal\Core\CoreServiceProvider
*/
- public function __construct($root, array $module_list = array(), CacheBackendInterface $cache_backend) {
+ public function __construct($root, array $module_list = [], CacheBackendInterface $cache_backend) {
$this->root = $root;
- $this->moduleList = array();
+ $this->moduleList = [];
foreach ($module_list as $name => $module) {
$this->moduleList[$name] = new Extension($this->root, $module['type'], $module['pathname'], $module['filename']);
}
@@ -178,7 +178,7 @@ class ModuleHandler implements ModuleHandlerInterface {
/**
* {@inheritdoc}
*/
- public function setModuleList(array $module_list = array()) {
+ public function setModuleList(array $module_list = []) {
$this->moduleList = $module_list;
// Reset the implementations, so a new call triggers a reloading of the
// available hooks.
@@ -221,7 +221,7 @@ class ModuleHandler implements ModuleHandlerInterface {
*/
public function buildModuleDependencies(array $modules) {
foreach ($modules as $module) {
- $graph[$module->getName()]['edges'] = array();
+ $graph[$module->getName()]['edges'] = [];
if (isset($module->info['dependencies']) && is_array($module->info['dependencies'])) {
foreach ($module->info['dependencies'] as $dependency) {
$dependency_data = static::parseDependency($dependency);
@@ -232,8 +232,8 @@ class ModuleHandler implements ModuleHandlerInterface {
$graph_object = new Graph($graph);
$graph = $graph_object->searchAndSort();
foreach ($graph as $module_name => $data) {
- $modules[$module_name]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
- $modules[$module_name]->requires = isset($data['paths']) ? $data['paths'] : array();
+ $modules[$module_name]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : [];
+ $modules[$module_name]->requires = isset($data['paths']) ? $data['paths'] : [];
$modules[$module_name]->sort = $data['weight'];
}
return $modules;
@@ -305,7 +305,7 @@ class ModuleHandler implements ModuleHandlerInterface {
* @see \Drupal\Core\Extension\ModuleHandler::getHookInfo()
*/
protected function buildHookInfo() {
- $this->hookInfo = array();
+ $this->hookInfo = [];
// Make sure that the modules are loaded before checking.
$this->reload();
// $this->invokeAll() would cause an infinite recursion.
@@ -356,7 +356,7 @@ class ModuleHandler implements ModuleHandlerInterface {
// invoked, since this can quickly lead to
// \Drupal::moduleHandler()->implementsHook() being called several thousand
// times per request.
- $this->cacheBackend->set('module_implements', array());
+ $this->cacheBackend->set('module_implements', []);
$this->cacheBackend->delete('hook_info');
}
@@ -383,7 +383,7 @@ class ModuleHandler implements ModuleHandlerInterface {
/**
* {@inheritdoc}
*/
- public function invoke($module, $hook, array $args = array()) {
+ public function invoke($module, $hook, array $args = []) {
if (!$this->implementsHook($module, $hook)) {
return;
}
@@ -394,8 +394,8 @@ class ModuleHandler implements ModuleHandlerInterface {
/**
* {@inheritdoc}
*/
- public function invokeAll($hook, array $args = array()) {
- $return = array();
+ public function invokeAll($hook, array $args = []) {
+ $return = [];
$implementations = $this->getImplementations($hook);
foreach ($implementations as $module) {
$function = $module . '_' . $hook;
@@ -438,7 +438,7 @@ class ModuleHandler implements ModuleHandlerInterface {
// list of functions to call, and on subsequent calls, iterate through them
// quickly.
if (!isset($this->alterFunctions[$cid])) {
- $this->alterFunctions[$cid] = array();
+ $this->alterFunctions[$cid] = [];
$hook = $type . '_alter';
$modules = $this->getImplementations($hook);
if (!isset($extra_types)) {
@@ -452,7 +452,7 @@ class ModuleHandler implements ModuleHandlerInterface {
else {
// For multiple hooks, we need $modules to contain every module that
// implements at least one of them.
- $extra_modules = array();
+ $extra_modules = [];
foreach ($extra_types as $extra_type) {
$extra_modules = array_merge($extra_modules, $this->getImplementations($extra_type . '_alter'));
}
@@ -516,8 +516,8 @@ class ModuleHandler implements ModuleHandlerInterface {
*/
protected function getImplementationInfo($hook) {
if (!isset($this->implementations)) {
- $this->implementations = array();
- $this->verified = array();
+ $this->implementations = [];
+ $this->verified = [];
if ($cache = $this->cacheBackend->get('module_implements')) {
$this->implementations = $cache->data;
}
@@ -561,7 +561,7 @@ class ModuleHandler implements ModuleHandlerInterface {
* @see \Drupal\Core\Extension\ModuleHandler::getImplementationInfo()
*/
protected function buildImplementationInfo($hook) {
- $implementations = array();
+ $implementations = [];
$hook_info = $this->getHookInfo();
foreach ($this->moduleList as $module => $extension) {
$include_file = isset($hook_info[$hook]['group']) && $this->loadInclude($module, 'inc', $module . '.' . $hook_info[$hook]['group']);
@@ -658,7 +658,7 @@ class ModuleHandler implements ModuleHandlerInterface {
* @see drupal_check_incompatibility()
*/
public static function parseDependency($dependency) {
- $value = array();
+ $value = [];
// Split out the optional project name.
if (strpos($dependency, ':') !== FALSE) {
list($project_name, $dependency) = explode(':', $dependency);
@@ -691,11 +691,11 @@ class ModuleHandler implements ModuleHandlerInterface {
}
// Equivalence can be checked by adding two restrictions.
if ($op == '=' || $op == '==') {
- $value['versions'][] = array('op' => '<', 'version' => ($matches['major'] + 1) . '.x');
+ $value['versions'][] = ['op' => '<', 'version' => ($matches['major'] + 1) . '.x'];
$op = '>=';
}
}
- $value['versions'][] = array('op' => $op, 'version' => $matches['major'] . '.' . $matches['minor']);
+ $value['versions'][] = ['op' => $op, 'version' => $matches['major'] . '.' . $matches['minor']];
}
}
}
@@ -706,7 +706,7 @@ class ModuleHandler implements ModuleHandlerInterface {
* {@inheritdoc}
*/
public function getModuleDirectories() {
- $dirs = array();
+ $dirs = [];
foreach ($this->getModuleList() as $name => $module) {
$dirs[$name] = $this->root . '/' . $module->getPath();
}
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
index e0336dd0a07..6b2738c7793 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
@@ -73,7 +73,7 @@ interface ModuleHandlerInterface {
* An associative array whose keys are the names of the modules and whose
* values are Extension objects.
*/
- public function setModuleList(array $module_list = array());
+ public function setModuleList(array $module_list = []);
/**
* Adds a module to the list of currently active modules.
@@ -220,7 +220,7 @@ interface ModuleHandlerInterface {
* @return mixed
* The return value of the hook implementation.
*/
- public function invoke($module, $hook, array $args = array());
+ public function invoke($module, $hook, array $args = []);
/**
* Invokes a hook in all enabled modules that implement it.
@@ -236,7 +236,7 @@ interface ModuleHandlerInterface {
* recursively. Note: integer keys in arrays will be lost, as the merge is
* done using array_merge_recursive().
*/
- public function invokeAll($hook, array $args = array());
+ public function invokeAll($hook, array $args = []);
/**
* Passes alterable variables to specific hook_TYPE_alter() implementations.
diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
index c3dbcc86ac0..f9500a5fc7d 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
@@ -79,14 +79,14 @@ class ModuleInstaller implements ModuleInstallerInterface {
if ($enable_dependencies) {
// Get all module data so we can find dependencies and sort.
$module_data = system_rebuild_module_data();
- $module_list = $module_list ? array_combine($module_list, $module_list) : array();
+ $module_list = $module_list ? array_combine($module_list, $module_list) : [];
if ($missing_modules = array_diff_key($module_list, $module_data)) {
// One or more of the given modules doesn't exist.
throw new MissingDependencyException(sprintf('Unable to install modules %s due to missing modules %s.', implode(', ', $module_list), implode(', ', $missing_modules)));
}
// Only process currently uninstalled modules.
- $installed_modules = $extension_config->get('module') ?: array();
+ $installed_modules = $extension_config->get('module') ?: [];
if (!$module_list = array_diff_key($module_list, $installed_modules)) {
// Nothing to do. All modules already installed.
return TRUE;
@@ -127,7 +127,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
if ($sync_status) {
$source_storage = $config_installer->getSourceStorage();
}
- $modules_installed = array();
+ $modules_installed = [];
foreach ($module_list as $module) {
$enabled = $extension_config->get("module.$module") !== NULL;
if (!$enabled) {
@@ -160,7 +160,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
$current_module_filenames = $this->moduleHandler->getModuleList();
$current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
$current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module')));
- $module_filenames = array();
+ $module_filenames = [];
foreach ($current_modules as $name => $weight) {
if (isset($current_module_filenames[$name])) {
$module_filenames[$name] = $current_module_filenames[$name];
@@ -191,7 +191,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
$this->updateKernel($module_filenames);
// Allow modules to react prior to the installation of a module.
- $this->moduleHandler->invokeAll('module_preinstall', array($module));
+ $this->moduleHandler->invokeAll('module_preinstall', [$module]);
// Now install the module's schema if necessary.
drupal_install_schema($module);
@@ -287,7 +287,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
$this->moduleHandler->invoke($module, 'install');
// Record the fact that it was installed.
- \Drupal::logger('system')->info('%module module installed.', array('%module' => $module));
+ \Drupal::logger('system')->info('%module module installed.', ['%module' => $module]);
}
}
@@ -302,7 +302,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
\Drupal::service('router.builder')->rebuild();
}
- $this->moduleHandler->invokeAll('modules_installed', array($modules_installed));
+ $this->moduleHandler->invokeAll('modules_installed', [$modules_installed]);
}
return TRUE;
@@ -314,14 +314,14 @@ class ModuleInstaller implements ModuleInstallerInterface {
public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
// Get all module data so we can find dependencies and sort.
$module_data = system_rebuild_module_data();
- $module_list = $module_list ? array_combine($module_list, $module_list) : array();
+ $module_list = $module_list ? array_combine($module_list, $module_list) : [];
if (array_diff_key($module_list, $module_data)) {
// One or more of the given modules doesn't exist.
return FALSE;
}
$extension_config = \Drupal::configFactory()->getEditable('core.extension');
- $installed_modules = $extension_config->get('module') ?: array();
+ $installed_modules = $extension_config->get('module') ?: [];
if (!$module_list = array_intersect_key($module_list, $installed_modules)) {
// Nothing to do. All modules already uninstalled.
return TRUE;
@@ -381,7 +381,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
}
// Allow modules to react prior to the uninstallation of a module.
- $this->moduleHandler->invokeAll('module_preuninstall', array($module));
+ $this->moduleHandler->invokeAll('module_preuninstall', [$module]);
// Uninstall the module.
module_load_install($module);
@@ -457,7 +457,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
// @see https://www.drupal.org/node/2208429
\Drupal::service('theme_handler')->refreshInfo();
- \Drupal::logger('system')->info('%module module uninstalled.', array('%module' => $module));
+ \Drupal::logger('system')->info('%module module uninstalled.', ['%module' => $module]);
$schema_store = \Drupal::keyValue('system.schema');
$schema_store->delete($module);
@@ -474,7 +474,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
drupal_get_installed_schema_version(NULL, TRUE);
// Let other modules react.
- $this->moduleHandler->invokeAll('modules_uninstalled', array($module_list));
+ $this->moduleHandler->invokeAll('modules_uninstalled', [$module_list]);
// Flush all persistent caches.
// Any cache entry might implicitly depend on the uninstalled modules,
@@ -509,14 +509,14 @@ class ModuleInstaller implements ModuleInstallerInterface {
try {
$factory = \Drupal::service($definition['factory_service']);
if (method_exists($factory, $definition['factory_method'])) {
- $backend = call_user_func_array(array($factory, $definition['factory_method']), $definition['arguments']);
+ $backend = call_user_func_array([$factory, $definition['factory_method']], $definition['arguments']);
if ($backend instanceof CacheBackendInterface) {
$backend->removeBin();
}
}
}
catch (\Exception $e) {
- watchdog_exception('system', $e, 'Failed to remove cache bin defined by the service %id.', array('%id' => $id));
+ watchdog_exception('system', $e, 'Failed to remove cache bin defined by the service %id.', ['%id' => $id]);
}
}
}
@@ -548,13 +548,13 @@ class ModuleInstaller implements ModuleInstallerInterface {
* {@inheritdoc}
*/
public function validateUninstall(array $module_list) {
- $reasons = array();
+ $reasons = [];
foreach ($module_list as $module) {
foreach ($this->uninstallValidators as $validator) {
$validation_reasons = $validator->validate($module);
if (!empty($validation_reasons)) {
if (!isset($reasons[$module])) {
- $reasons[$module] = array();
+ $reasons[$module] = [];
}
$reasons[$module] = array_merge($reasons[$module], $validation_reasons);
}
diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php
index 3363efc5188..2fd75e190ca 100644
--- a/core/lib/Drupal/Core/Extension/ThemeHandler.php
+++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php
@@ -17,13 +17,13 @@ class ThemeHandler implements ThemeHandlerInterface {
*
* @see _system_default_theme_features()
*/
- protected $defaultFeatures = array(
+ protected $defaultFeatures = [
'favicon',
'logo',
'node_user_picture',
'comment_user_picture',
'comment_user_verification',
- );
+ ];
/**
* A list of all currently available themes.
@@ -178,14 +178,14 @@ class ThemeHandler implements ThemeHandlerInterface {
*/
public function listInfo() {
if (!isset($this->list)) {
- $this->list = array();
+ $this->list = [];
$themes = $this->systemThemeList();
// @todo Ensure that systemThemeList() does not contain an empty list
// during the batch installer, see https://www.drupal.org/node/2322619.
if (empty($themes)) {
$this->refreshInfo();
- $this->list = $this->list ?: array();
- $themes = \Drupal::state()->get('system.theme.data', array());
+ $this->list = $this->list ?: [];
+ $themes = \Drupal::state()->get('system.theme.data', []);
}
foreach ($themes as $theme) {
$this->addTheme($theme);
@@ -247,13 +247,13 @@ class ThemeHandler implements ThemeHandlerInterface {
$themes = $listing->scan('theme');
$engines = $listing->scan('theme_engine');
$extension_config = $this->configFactory->get('core.extension');
- $installed = $extension_config->get('theme') ?: array();
+ $installed = $extension_config->get('theme') ?: [];
// Set defaults for theme info.
- $defaults = array(
+ $defaults = [
'engine' => 'twig',
'base theme' => 'stable',
- 'regions' => array(
+ 'regions' => [
'sidebar_first' => 'Left sidebar',
'sidebar_second' => 'Right sidebar',
'content' => 'Content',
@@ -266,17 +266,17 @@ class ThemeHandler implements ThemeHandlerInterface {
'page_top' => 'Page top',
'page_bottom' => 'Page bottom',
'breadcrumb' => 'Breadcrumb',
- ),
+ ],
'description' => '',
'features' => $this->defaultFeatures,
'screenshot' => 'screenshot.png',
'php' => DRUPAL_MINIMUM_PHP,
- 'libraries' => array(),
- );
+ 'libraries' => [],
+ ];
- $sub_themes = array();
- $files_theme = array();
- $files_theme_engine = array();
+ $sub_themes = [];
+ $files_theme = [];
+ $files_theme_engine = [];
// Read info files for each theme.
foreach ($themes as $key => $theme) {
// @todo Remove all code that relies on the $status property.
@@ -382,18 +382,18 @@ class ThemeHandler implements ThemeHandlerInterface {
* @return array
* An array of base themes.
*/
- protected function doGetBaseThemes(array $themes, $theme, $used_themes = array()) {
+ protected function doGetBaseThemes(array $themes, $theme, $used_themes = []) {
if (!isset($themes[$theme]->info['base theme'])) {
- return array();
+ return [];
}
$base_key = $themes[$theme]->info['base theme'];
// Does the base theme exist?
if (!isset($themes[$base_key])) {
- return array($base_key => NULL);
+ return [$base_key => NULL];
}
- $current_base_theme = array($base_key => $themes[$base_key]->info['name']);
+ $current_base_theme = [$base_key => $themes[$base_key]->info['name']];
// Is the base theme itself a child of another theme?
if (isset($themes[$base_key]->info['base theme'])) {
@@ -403,7 +403,7 @@ class ThemeHandler implements ThemeHandlerInterface {
}
// Prevent loops.
if (!empty($used_themes[$base_key])) {
- return array($base_key => NULL);
+ return [$base_key => NULL];
}
$used_themes[$base_key] = TRUE;
return $this->doGetBaseThemes($themes, $base_key, $used_themes) + $current_base_theme;
@@ -457,7 +457,7 @@ class ThemeHandler implements ThemeHandlerInterface {
* {@inheritdoc}
*/
public function getThemeDirectories() {
- $dirs = array();
+ $dirs = [];
foreach ($this->listInfo() as $name => $theme) {
$dirs[$name] = $this->root . '/' . $theme->getPath();
}
diff --git a/core/lib/Drupal/Core/Extension/ThemeInstaller.php b/core/lib/Drupal/Core/Extension/ThemeInstaller.php
index c76e76c07fd..db1226fa982 100644
--- a/core/lib/Drupal/Core/Extension/ThemeInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ThemeInstaller.php
@@ -115,7 +115,7 @@ class ThemeInstaller implements ThemeInstallerInterface {
}
// Only process themes that are not installed currently.
- $installed_themes = $extension_config->get('theme') ?: array();
+ $installed_themes = $extension_config->get('theme') ?: [];
if (!$theme_list = array_diff_key($theme_list, $installed_themes)) {
// Nothing to do. All themes already installed.
return TRUE;
@@ -147,10 +147,10 @@ class ThemeInstaller implements ThemeInstallerInterface {
$theme_list = array_keys($theme_list);
}
else {
- $installed_themes = $extension_config->get('theme') ?: array();
+ $installed_themes = $extension_config->get('theme') ?: [];
}
- $themes_installed = array();
+ $themes_installed = [];
foreach ($theme_list as $key) {
// Only process themes that are not already installed.
$installed = $extension_config->get("theme.$key") !== NULL;
@@ -179,7 +179,7 @@ class ThemeInstaller implements ThemeInstallerInterface {
$this->themeHandler->addTheme($theme_data[$key]);
// Update the current theme data accordingly.
- $current_theme_data = $this->state->get('system.theme.data', array());
+ $current_theme_data = $this->state->get('system.theme.data', []);
$current_theme_data[$key] = $theme_data[$key];
$this->state->set('system.theme.data', $current_theme_data);
@@ -200,14 +200,14 @@ class ThemeInstaller implements ThemeInstallerInterface {
$themes_installed[] = $key;
// Record the fact that it was installed.
- $this->logger->info('%theme theme installed.', array('%theme' => $key));
+ $this->logger->info('%theme theme installed.', ['%theme' => $key]);
}
$this->cssCollectionOptimizer->deleteAll();
$this->resetSystem();
// Invoke hook_themes_installed() after the themes have been installed.
- $this->moduleHandler->invokeAll('themes_installed', array($themes_installed));
+ $this->moduleHandler->invokeAll('themes_installed', [$themes_installed]);
return !empty($themes_installed);
}
@@ -244,7 +244,7 @@ class ThemeInstaller implements ThemeInstallerInterface {
}
$this->cssCollectionOptimizer->deleteAll();
- $current_theme_data = $this->state->get('system.theme.data', array());
+ $current_theme_data = $this->state->get('system.theme.data', []);
foreach ($theme_list as $key) {
// The value is not used; the weight is ignored for themes currently.
$extension_config->clear("theme.$key");
@@ -284,7 +284,7 @@ class ThemeInstaller implements ThemeInstallerInterface {
// @todo It feels wrong to have the requirement to clear the local tasks
// cache here.
- Cache::invalidateTags(array('local_task'));
+ Cache::invalidateTags(['local_task']);
$this->themeRegistryRebuild();
}
diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php
index 74fc76699ea..944d3547b78 100644
--- a/core/lib/Drupal/Core/Extension/module.api.php
+++ b/core/lib/Drupal/Core/Extension/module.api.php
@@ -84,12 +84,12 @@ use Drupal\Core\Utility\UpdateException;
* @see hook_hook_info_alter()
*/
function hook_hook_info() {
- $hooks['token_info'] = array(
+ $hooks['token_info'] = [
'group' => 'tokens',
- );
- $hooks['tokens'] = array(
+ ];
+ $hooks['tokens'] = [
'group' => 'tokens',
- );
+ ];
return $hooks;
}
@@ -398,7 +398,7 @@ function hook_install_tasks(&$install_state) {
// processor-intensive batch process needs to be triggered later on in the
// installation.
$myprofile_needs_batch_processing = \Drupal::state()->get('myprofile.needs_batch_processing', FALSE);
- $tasks = array(
+ $tasks = [
// This is an example of a task that defines a form which the user who is
// installing the site will be asked to fill out. To implement this task,
// your profile would define a function named myprofile_data_import_form()
@@ -408,10 +408,10 @@ function hook_install_tasks(&$install_state) {
// \Drupal::state()->set('myprofile.needs_batch_processing', TRUE) if the
// user has entered data which requires that batch processing will need to
// occur later on.
- 'myprofile_data_import_form' => array(
+ 'myprofile_data_import_form' => [
'display_name' => t('Data import options'),
'type' => 'form',
- ),
+ ],
// Similarly, to implement this task, your profile would define a function
// named myprofile_settings_form() with associated validation and submit
// handlers. This form might be used to collect and save additional
@@ -419,10 +419,10 @@ function hook_install_tasks(&$install_state) {
// steps required for your profile to act as an "installation wizard"; you
// can simply define as many tasks of type 'form' as you wish to execute,
// and the forms will be presented to the user, one after another.
- 'myprofile_settings_form' => array(
+ 'myprofile_settings_form' => [
'display_name' => t('Additional options'),
'type' => 'form',
- ),
+ ],
// This is an example of a task that performs batch operations. To
// implement this task, your profile would define a function named
// myprofile_batch_processing() which returns a batch API array definition
@@ -430,12 +430,12 @@ function hook_install_tasks(&$install_state) {
// 'myprofile.needs_batch_processing' variable used here, this task will be
// hidden and skipped unless your profile set it to TRUE in one of the
// previous tasks.
- 'myprofile_batch_processing' => array(
+ 'myprofile_batch_processing' => [
'display_name' => t('Import additional data'),
'display' => $myprofile_needs_batch_processing,
'type' => 'batch',
'run' => $myprofile_needs_batch_processing ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
- ),
+ ],
// This is an example of a task that will not be displayed in the list that
// the user sees. To implement this task, your profile would define a
// function named myprofile_final_site_setup(), in which additional,
@@ -449,9 +449,9 @@ function hook_install_tasks(&$install_state) {
// tasks are complete, with a link to reload the current page and therefore
// pass on to the final Drupal installation tasks when the user is ready to
// do so).
- 'myprofile_final_site_setup' => array(
- ),
- );
+ 'myprofile_final_site_setup' => [
+ ],
+ ];
return $tasks;
}
@@ -622,12 +622,12 @@ function hook_update_N(&$sandbox) {
// Example function body for adding a field to a database table, which does
// not require a batch operation:
- $spec = array(
+ $spec = [
'type' => 'varchar',
'description' => "New Col",
'length' => 20,
'not null' => FALSE,
- );
+ ];
$schema = Database::getConnection()->schema();
$schema->addField('mytable1', 'newcol', $spec);
@@ -647,7 +647,7 @@ function hook_update_N(&$sandbox) {
// Update in chunks of 20.
$records = Database::getConnection()->select('mytable1', 'm')
- ->fields('m', array('myprimarykey', 'otherfield'))
+ ->fields('m', ['myprimarykey', 'otherfield'])
->condition('myprimarykey', $sandbox['current_pk'], '>')
->range(0, 20)
->orderBy('myprimarykey', 'ASC')
@@ -656,7 +656,7 @@ function hook_update_N(&$sandbox) {
// Here, you would make an update something related to this record. In this
// example, some text is added to the other field.
Database::getConnection()->update('mytable1')
- ->fields(array('otherfield' => $record->otherfield . '-suffix'))
+ ->fields(['otherfield' => $record->otherfield . '-suffix'])
->condition('myprimarykey', $record->myprimarykey)
->execute();
@@ -767,9 +767,9 @@ function hook_update_dependencies() {
// Indicate that the mymodule_update_8001() function provided by this module
// must run after the another_module_update_8003() function provided by the
// 'another_module' module.
- $dependencies['mymodule'][8001] = array(
+ $dependencies['mymodule'][8001] = [
'another_module' => 8003,
- );
+ ];
// Indicate that the mymodule_update_8002() function provided by this module
// must run before the yet_another_module_update_8005() function provided by
// the 'yet_another_module' module. (Note that declaring dependencies in this
@@ -777,9 +777,9 @@ function hook_update_dependencies() {
// following problem: If a site has already run the yet_another_module
// module's database updates before it updates its codebase to pick up the
// newest mymodule code, then the dependency declared here will be ignored.)
- $dependencies['yet_another_module'][8005] = array(
+ $dependencies['yet_another_module'][8005] = [
'mymodule' => 8002,
- );
+ ];
return $dependencies;
}
@@ -834,18 +834,18 @@ function hook_update_last_removed() {
* @see hook_updater_info_alter()
*/
function hook_updater_info() {
- return array(
- 'module' => array(
+ return [
+ 'module' => [
'class' => 'Drupal\Core\Updater\Module',
'name' => t('Update modules'),
'weight' => 0,
- ),
- 'theme' => array(
+ ],
+ 'theme' => [
'class' => 'Drupal\Core\Updater\Theme',
'name' => t('Update themes'),
'weight' => 0,
- ),
- );
+ ],
+ ];
}
/**
@@ -928,24 +928,24 @@ function hook_updater_info_alter(&$updaters) {
* - REQUIREMENT_ERROR: The requirement failed with an error.
*/
function hook_requirements($phase) {
- $requirements = array();
+ $requirements = [];
// Report Drupal version
if ($phase == 'runtime') {
- $requirements['drupal'] = array(
+ $requirements['drupal'] = [
'title' => t('Drupal'),
'value' => \Drupal::VERSION,
'severity' => REQUIREMENT_INFO
- );
+ ];
}
// Test PHP version
- $requirements['php'] = array(
+ $requirements['php'] = [
'title' => t('PHP'),
'value' => ($phase == 'runtime') ? \Drupal::l(phpversion(), new Url('system.php')) : phpversion(),
- );
+ ];
if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
- $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
+ $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]);
$requirements['php']['severity'] = REQUIREMENT_ERROR;
}
@@ -954,17 +954,17 @@ function hook_requirements($phase) {
$cron_last = \Drupal::state()->get('system.cron_last');
if (is_numeric($cron_last)) {
- $requirements['cron']['value'] = t('Last run @time ago', array('@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
+ $requirements['cron']['value'] = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
}
else {
- $requirements['cron'] = array(
- 'description' => t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href=":url">configuring cron jobs</a>.', array(':url' => 'https://www.drupal.org/cron')),
+ $requirements['cron'] = [
+ 'description' => t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href=":url">configuring cron jobs</a>.', [':url' => 'https://www.drupal.org/cron']),
'severity' => REQUIREMENT_ERROR,
'value' => t('Never run'),
- );
+ ];
}
- $requirements['cron']['description'] .= ' ' . t('You can <a href=":cron">run cron manually</a>.', array(':cron' => \Drupal::url('system.run_cron')));
+ $requirements['cron']['description'] .= ' ' . t('You can <a href=":cron">run cron manually</a>.', [':cron' => \Drupal::url('system.run_cron')]);
$requirements['cron']['title'] = t('Cron maintenance tasks');
}
diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
index 92786b13437..1a2439109c0 100644
--- a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
+++ b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php
@@ -61,7 +61,7 @@ class FieldFormatter extends Plugin {
*
* @var array
*/
- public $field_types = array();
+ public $field_types = [];
/**
* An integer to determine the weight of this formatter relative to other
diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php b/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php
index 22d7796e5a5..38d3f869e54 100644
--- a/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php
+++ b/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php
@@ -60,7 +60,7 @@ class FieldWidget extends Plugin {
*
* @var array
*/
- public $field_types = array();
+ public $field_types = [];
/**
* Does the field widget handles multiple values at once.
diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php
index e703b385285..5194d85e9a2 100644
--- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php
+++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php
@@ -42,7 +42,7 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
/**
* @var array
*/
- protected $indexes = array();
+ protected $indexes = [];
/**
* Creates a new field definition.
@@ -54,7 +54,7 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
* A new field definition object.
*/
public static function create($type) {
- $field_definition = new static(array());
+ $field_definition = new static([]);
$field_definition->type = $type;
$field_definition->itemDefinition = FieldItemDataDefinition::create($field_definition);
// Create a definition for the items, and initialize it with the default
@@ -420,7 +420,7 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
public function setDisplayConfigurable($display_context, $configurable) {
// If no explicit display options have been specified, default to 'hidden'.
if (empty($this->definition['display'][$display_context])) {
- $this->definition['display'][$display_context]['options'] = array('region' => 'hidden');
+ $this->definition['display'][$display_context]['options'] = ['region' => 'hidden'];
}
$this->definition['display'][$display_context]['configurable'] = $configurable;
return $this;
@@ -469,9 +469,9 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
if (isset($value) && !is_array($value)) {
$properties = $this->getPropertyNames();
$property = reset($properties);
- $value = array(
- array($property => $value),
- );
+ $value = [
+ [$property => $value],
+ ];
}
// Allow the field type to process default values.
$field_item_list_class = $this->getClass();
@@ -488,10 +488,10 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
// Unless the value is an empty array, we may need to transform it.
if (!is_array($value) || !empty($value)) {
if (!is_array($value)) {
- $value = array(array($this->getMainPropertyName() => $value));
+ $value = [[$this->getMainPropertyName() => $value]];
}
elseif (is_array($value) && !is_numeric(array_keys($value)[0])) {
- $value = array(0 => $value);
+ $value = [0 => $value];
}
}
$this->definition['default_value'] = $value;
@@ -639,12 +639,12 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
$class = $definition['class'];
$schema = $class::schema($this);
// Fill in default values.
- $schema += array(
- 'columns' => array(),
- 'unique keys' => array(),
- 'indexes' => array(),
- 'foreign keys' => array(),
- );
+ $schema += [
+ 'columns' => [],
+ 'unique keys' => [],
+ 'indexes' => [],
+ 'foreign keys' => [],
+ ];
// Merge custom indexes with those specified by the field type. Custom
// indexes prevail.
diff --git a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php
index d21ac9697da..0a53d9894a3 100644
--- a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php
+++ b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php
@@ -25,12 +25,12 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere
*/
public function referencedEntities() {
if (empty($this->list)) {
- return array();
+ return [];
}
// Collect the IDs of existing entities to load, and directly grab the
// "autocreate" entities that are already populated in $item->entity.
- $target_entities = $ids = array();
+ $target_entities = $ids = [];
foreach ($this->list as $delta => $item) {
if ($item->target_id !== NULL) {
$ids[$delta] = $item->target_id;
@@ -64,7 +64,7 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere
if ($default_value) {
// Convert UUIDs to numeric IDs.
- $uuids = array();
+ $uuids = [];
foreach ($default_value as $delta => $properties) {
if (isset($properties['target_uuid'])) {
$uuids[$delta] = $properties['target_uuid'];
@@ -79,7 +79,7 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere
->getStorage($target_type)
->loadMultiple($entity_ids);
- $entity_uuids = array();
+ $entity_uuids = [];
foreach ($entities as $id => $entity) {
$entity_uuids[$entity->uuid()] = $id;
}
@@ -107,7 +107,7 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere
$default_value = parent::defaultValuesFormSubmit($element, $form, $form_state);
// Convert numeric IDs to UUIDs to ensure config deployability.
- $ids = array();
+ $ids = [];
foreach ($default_value as $delta => $properties) {
if (isset($properties['entity']) && $properties['entity']->isNew()) {
// This may be a newly created term.
diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php
index d7ddd189820..76366bfe21c 100644
--- a/core/lib/Drupal/Core/Field/FieldConfigBase.php
+++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php
@@ -89,7 +89,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var array
*/
- protected $settings = array();
+ protected $settings = [];
/**
* Flag indicating whether the field is required.
@@ -139,7 +139,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*
* @var array
*/
- protected $default_value = array();
+ protected $default_value = [];
/**
* The name of a callback function that returns default values.
@@ -413,9 +413,9 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
$key = $this->getFieldStorageDefinition()->getPropertyNames()[0];
// Convert to the multi value format to support fields with a cardinality
// greater than 1.
- $value = array(
- array($key => $value),
- );
+ $value = [
+ [$key => $value],
+ ];
}
$this->default_value = $value;
return $this;
diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php
index d489c8e1ba4..84d73ec5b35 100644
--- a/core/lib/Drupal/Core/Field/FieldItemBase.php
+++ b/core/lib/Drupal/Core/Field/FieldItemBase.php
@@ -23,14 +23,14 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array();
+ return [];
}
/**
@@ -106,7 +106,7 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
// given.
if (isset($values) && !is_array($values)) {
$keys = array_keys($this->definition->getPropertyDefinitions());
- $values = array($keys[0] => $values);
+ $values = [$keys[0] => $values];
}
parent::setValue($values, $notify);
}
@@ -183,7 +183,7 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
/**
* {@inheritdoc}
*/
- public function view($display_options = array()) {
+ public function view($display_options = []) {
$view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId());
return $view_builder->viewFieldItem($this, $display_options);
}
@@ -217,14 +217,14 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- return array();
+ return [];
}
/**
@@ -259,7 +259,7 @@ abstract class FieldItemBase extends Map implements FieldItemInterface {
* {@inheritdoc}
*/
public static function calculateDependencies(FieldDefinitionInterface $field_definition) {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php
index a257dd0f7c2..69906c1414d 100644
--- a/core/lib/Drupal/Core/Field/FieldItemInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php
@@ -173,7 +173,7 @@ interface FieldItemInterface extends ComplexDataInterface {
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewFieldItem()
* @see \Drupal\Core\Field\FieldItemListInterface::view()
*/
- public function view($display_options = array());
+ public function view($display_options = []);
/**
* Defines custom presave behavior for field values.
diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php
index 97dd493195a..a1a1ebdb9eb 100644
--- a/core/lib/Drupal/Core/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Field/FieldItemList.php
@@ -24,7 +24,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
*
* @var \Drupal\Core\Field\FieldItemInterface[]
*/
- protected $list = array();
+ protected $list = [];
/**
* The langcode of the field values held in the object.
@@ -99,7 +99,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
* @todo Revisit the need when all entity types are converted to NG entities.
*/
public function getValue($include_computed = FALSE) {
- $values = array();
+ $values = [];
foreach ($this->list as $delta => $item) {
$values[$delta] = $item->getValue($include_computed);
}
@@ -113,7 +113,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
// Support passing in only the value of the first item, either as a literal
// (value of the first property) or as an array of properties.
if (isset($values) && (!is_array($values) || (!empty($values) && !is_numeric(current(array_keys($values)))))) {
- $values = array(0 => $values);
+ $values = [0 => $values];
}
parent::setValue($values, $notify);
}
@@ -249,7 +249,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
/**
* {@inheritdoc}
*/
- public function view($display_options = array()) {
+ public function view($display_options = []) {
$view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId());
return $view_builder->viewField($this, $display_options);
}
@@ -278,10 +278,10 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
if ($cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
$constraints[] = $this->getTypedDataManager()
->getValidationConstraintManager()
- ->create('Count', array(
+ ->create('Count', [
'max' => $cardinality,
- 'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality)),
- ));
+ 'maxMessage' => t('%name: this field cannot hold more than @count values.', ['%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality]),
+ ]);
}
return $constraints;
@@ -294,7 +294,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
if (empty($this->getFieldDefinition()->getDefaultValueCallback())) {
if ($widget = $this->defaultValueWidget($form_state)) {
// Place the input in a separate place in the submitted values tree.
- $element = array('#parents' => array('default_value_input'));
+ $element = ['#parents' => ['default_value_input']];
$element += $widget->form($this, $element, $form_state);
return $element;
@@ -365,7 +365,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
$entity_form_display = entity_get_form_display($entity->getEntityTypeId(), $entity->bundle(), 'default');
$widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getName());
if (!$widget) {
- $widget = \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $this->getFieldDefinition()));
+ $widget = \Drupal::service('plugin.manager.field.widget')->getInstance(['field_definition' => $this->getFieldDefinition()]);
}
$form_state->set('default_value_widget', $widget);
diff --git a/core/lib/Drupal/Core/Field/FieldItemListInterface.php b/core/lib/Drupal/Core/Field/FieldItemListInterface.php
index 4e77202b654..c350432e21a 100644
--- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php
@@ -181,7 +181,7 @@ interface FieldItemListInterface extends ListInterface, AccessibleInterface {
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewField()
* @see \Drupal\Core\Field\FieldItemInterface::view()
*/
- public function view($display_options = array());
+ public function view($display_options = []);
/**
* Populates a specified number of field items with valid sample data.
diff --git a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php
index 2170b36047c..08a27cb76ff 100644
--- a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php
+++ b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php
@@ -35,7 +35,7 @@ class FieldModuleUninstallValidator implements ModuleUninstallValidatorInterface
* {@inheritdoc}
*/
public function validate($module_name) {
- $reasons = array();
+ $reasons = [];
// We skip fields provided by the Field module as it implements field
// purging.
@@ -49,10 +49,10 @@ class FieldModuleUninstallValidator implements ModuleUninstallValidatorInterface
if ($storage_definition->getProvider() == $module_name) {
$storage = $this->entityManager->getStorage($entity_type_id);
if ($storage instanceof FieldableEntityStorageInterface && $storage->countFieldData($storage_definition, TRUE)) {
- $reasons[] = $this->t('There is data for the field @field-name on entity type @entity_type', array(
+ $reasons[] = $this->t('There is data for the field @field-name on entity type @entity_type', [
'@field-name' => $storage_definition->getName(),
'@entity_type' => $entity_type->getLabel(),
- ));
+ ]);
}
}
}
diff --git a/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php b/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php
index 5ac4b6e0d08..895045bda02 100644
--- a/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php
+++ b/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php
@@ -22,7 +22,7 @@ trait FieldStorageDefinitionEventSubscriberTrait {
* @see \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()
*/
public static function getFieldStorageDefinitionEvents() {
- $event = array('onFieldStorageDefinitionEvent', 100);
+ $event = ['onFieldStorageDefinitionEvent', 100];
$events[FieldStorageDefinitionEvents::CREATE][] = $event;
$events[FieldStorageDefinitionEvents::UPDATE][] = $event;
$events[FieldStorageDefinitionEvents::DELETE][] = $event;
diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php
index 84bb4c0917b..905cdb4f1bb 100644
--- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php
+++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php
@@ -61,7 +61,7 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePl
* @return \Drupal\Core\Field\FieldItemInterface
* The instantiated object.
*/
- public function createInstance($field_type, array $configuration = array()) {
+ public function createInstance($field_type, array $configuration = []) {
$configuration['data_definition'] = $configuration['field_definition']->getItemDefinition();
return $this->typedDataManager->createInstance("field_item:$field_type", $configuration);
}
@@ -106,7 +106,7 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePl
$plugin_class = DefaultFactory::getPluginClass($type, $plugin_definition);
return $plugin_class::defaultStorageSettings();
}
- return array();
+ return [];
}
/**
@@ -118,7 +118,7 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePl
$plugin_class = DefaultFactory::getPluginClass($type, $plugin_definition);
return $plugin_class::defaultFieldSettings();
}
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Field/FormatterBase.php b/core/lib/Drupal/Core/Field/FormatterBase.php
index db7587ae250..3b3abcc6199 100644
--- a/core/lib/Drupal/Core/Field/FormatterBase.php
+++ b/core/lib/Drupal/Core/Field/FormatterBase.php
@@ -60,7 +60,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
* Any third party settings.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings) {
- parent::__construct(array(), $plugin_id, $plugin_definition);
+ parent::__construct([], $plugin_id, $plugin_definition);
$this->fieldDefinition = $field_definition;
$this->settings = $settings;
@@ -85,7 +85,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
$entity = $items->getEntity();
$entity_type = $entity->getEntityTypeId();
$field_name = $this->fieldDefinition->getName();
- $info = array(
+ $info = [
'#theme' => 'field',
'#title' => $this->fieldDefinition->getLabel(),
'#label_display' => $this->label,
@@ -100,7 +100,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
'#items' => $items,
'#formatter' => $this->getPluginId(),
'#is_multiple' => $this->fieldDefinition->getFieldStorageDefinition()->isMultiple(),
- );
+ ];
$elements = array_merge($info, $elements);
}
@@ -112,14 +112,14 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php
index ca9bd068718..c4df0f5f2fd 100644
--- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php
+++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php
@@ -52,7 +52,7 @@ class FormatterPluginManager extends DefaultPluginManager {
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
@@ -119,10 +119,10 @@ class FormatterPluginManager extends DefaultPluginManager {
$plugin_id = $field_type_definition['default_formatter'];
}
- $configuration += array(
+ $configuration += [
'field_definition' => $field_definition,
'view_mode' => $options['view_mode'],
- );
+ ];
return $this->createInstance($plugin_id, $configuration);
}
@@ -139,11 +139,11 @@ class FormatterPluginManager extends DefaultPluginManager {
*/
public function prepareConfiguration($field_type, array $configuration) {
// Fill in defaults for missing properties.
- $configuration += array(
+ $configuration += [
'label' => 'above',
- 'settings' => array(),
- 'third_party_settings' => array(),
- );
+ 'settings' => [],
+ 'third_party_settings' => [],
+ ];
// If no formatter is specified, use the default formatter.
if (!isset($configuration['type'])) {
$field_type = $this->fieldTypeManager->getDefinition($field_type);
@@ -168,10 +168,10 @@ class FormatterPluginManager extends DefaultPluginManager {
*/
public function getOptions($field_type = NULL) {
if (!isset($this->formatterOptions)) {
- $options = array();
+ $options = [];
$field_types = $this->fieldTypeManager->getDefinitions();
$formatter_types = $this->getDefinitions();
- uasort($formatter_types, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($formatter_types, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
foreach ($formatter_types as $name => $formatter_type) {
foreach ($formatter_type['field_types'] as $formatter_field_type) {
// Check that the field type exists.
@@ -183,7 +183,7 @@ class FormatterPluginManager extends DefaultPluginManager {
$this->formatterOptions = $options;
}
if ($field_type) {
- return !empty($this->formatterOptions[$field_type]) ? $this->formatterOptions[$field_type] : array();
+ return !empty($this->formatterOptions[$field_type]) ? $this->formatterOptions[$field_type] : [];
}
return $this->formatterOptions;
}
@@ -204,7 +204,7 @@ class FormatterPluginManager extends DefaultPluginManager {
$plugin_class = DefaultFactory::getPluginClass($type, $plugin_definition);
return $plugin_class::defaultSettings();
}
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
index 0d993388722..de57317e2b9 100644
--- a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
+++ b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
@@ -16,7 +16,7 @@ class FieldItemDeriver implements ContainerDeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* The base plugin ID this derivative is for.
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php
index 60c632a449a..c52a2d7bee7 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php
@@ -67,10 +67,10 @@ class BooleanFormatter extends FormatterBase {
foreach ($this->getOutputFormats() as $format_name => $format) {
if (is_array($format)) {
if ($format_name == 'default') {
- $formats[$format_name] = $this->t('Field settings (@on_label / @off_label)', array('@on_label' => $format[0], '@off_label' => $format[1]));
+ $formats[$format_name] = $this->t('Field settings (@on_label / @off_label)', ['@on_label' => $format[0], '@off_label' => $format[1]]);
}
else {
- $formats[$format_name] = $this->t('@on_label / @off_label', array('@on_label' => $format[0], '@off_label' => $format[1]));
+ $formats[$format_name] = $this->t('@on_label / @off_label', ['@on_label' => $format[0], '@off_label' => $format[1]]);
}
}
else {
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
index 0c389291e87..58e8fffc771 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
@@ -26,12 +26,12 @@ class DecimalFormatter extends NumericFormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'thousand_separator' => '',
'decimal_separator' => '.',
'scale' => 2,
'prefix_suffix' => TRUE,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -40,22 +40,22 @@ class DecimalFormatter extends NumericFormatterBase {
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
- $elements['decimal_separator'] = array(
+ $elements['decimal_separator'] = [
'#type' => 'select',
'#title' => t('Decimal marker'),
- '#options' => array('.' => t('Decimal point'), ',' => t('Comma')),
+ '#options' => ['.' => t('Decimal point'), ',' => t('Comma')],
'#default_value' => $this->getSetting('decimal_separator'),
'#weight' => 5,
- );
- $elements['scale'] = array(
+ ];
+ $elements['scale'] = [
'#type' => 'number',
- '#title' => t('Scale', array(), array('context' => 'decimal places')),
+ '#title' => t('Scale', [], ['context' => 'decimal places']),
'#min' => 0,
'#max' => 10,
'#default_value' => $this->getSetting('scale'),
'#description' => t('The number of digits to the right of the decimal.'),
'#weight' => 6,
- );
+ ];
return $elements;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
index 2692d84e114..af994361fa0 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
@@ -118,23 +118,23 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'view_mode' => 'default',
'link' => FALSE,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $elements['view_mode'] = array(
+ $elements['view_mode'] = [
'#type' => 'select',
'#options' => $this->entityDisplayRepository->getViewModeOptions($this->getFieldSetting('target_type')),
'#title' => t('View mode'),
'#default_value' => $this->getSetting('view_mode'),
'#required' => TRUE,
- );
+ ];
return $elements;
}
@@ -143,11 +143,11 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$view_modes = $this->entityDisplayRepository->getViewModeOptions($this->getFieldSetting('target_type'));
$view_mode = $this->getSetting('view_mode');
- $summary[] = t('Rendered as @mode', array('@mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode));
+ $summary[] = t('Rendered as @mode', ['@mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode]);
return $summary;
}
@@ -157,7 +157,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$view_mode = $this->getSetting('view_mode');
- $elements = array();
+ $elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
// Due to render caching and delayed calls, the viewElements() method
@@ -199,7 +199,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
// entity's url. Since we don't know what the markup of the entity will
// be, we shouldn't rely on it for structured data such as RDFa.
if (!empty($items[$delta]->_attributes) && !$entity->isNew() && $entity->hasLinkTemplate('canonical')) {
- $items[$delta]->_attributes += array('resource' => $entity->toUrl()->toString());
+ $items[$delta]->_attributes += ['resource' => $entity->toUrl()->toString()];
}
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php
index e3af1b5eff6..12a349afe54 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php
@@ -40,7 +40,7 @@ abstract class EntityReferenceFormatterBase extends FormatterBase {
* @see ::prepareView()
*/
protected function getEntitiesToView(EntityReferenceFieldItemListInterface $items, $langcode) {
- $entities = array();
+ $entities = [];
foreach ($items as $delta => $item) {
// Ignore items where no entity could be loaded in prepareView().
@@ -120,7 +120,7 @@ abstract class EntityReferenceFormatterBase extends FormatterBase {
// "multiple entity load" to load all the entities for the multiple
// "entity reference item lists" being displayed. We thus cannot use
// \Drupal\Core\Field\EntityReferenceFieldItemList::referencedEntities().
- $ids = array();
+ $ids = [];
foreach ($entities_items as $items) {
foreach ($items as $item) {
// To avoid trying to reload non-existent entities in
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php
index 62e54a777bf..9fa695de0a9 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php
@@ -22,19 +22,19 @@ class EntityReferenceIdFormatter extends EntityReferenceFormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
if ($entity->id()) {
- $elements[$delta] = array(
+ $elements[$delta] = [
'#plain_text' => $entity->id(),
// Create a cache tag entry for the referenced entity. In the case
// that the referenced entity is deleted, the cache for referring
// entities must be cleared.
- '#cache' => array(
+ '#cache' => [
'tags' => $entity->getCacheTags(),
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
index 4cb5d149004..011e3051eb8 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
@@ -25,20 +25,20 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'link' => TRUE,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $elements['link'] = array(
+ $elements['link'] = [
'#title' => t('Link label to the referenced entity'),
'#type' => 'checkbox',
'#default_value' => $this->getSetting('link'),
- );
+ ];
return $elements;
}
@@ -47,7 +47,7 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$summary[] = $this->getSetting('link') ? t('Link to the referenced entity') : t('No link');
return $summary;
}
@@ -56,7 +56,7 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
$output_as_link = $this->getSetting('link');
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
@@ -85,7 +85,7 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
];
if (!empty($items[$delta]->_attributes)) {
- $elements[$delta]['#options'] += array('attributes' => array());
+ $elements[$delta]['#options'] += ['attributes' => []];
$elements[$delta]['#options']['attributes'] += $items[$delta]->_attributes;
// Unset field item attributes since they have been included in the
// formatter output and shouldn't be rendered in the field template.
@@ -93,7 +93,7 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
}
}
else {
- $elements[$delta] = array('#plain_text' => $label);
+ $elements[$delta] = ['#plain_text' => $label];
}
$elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php
index 17ddf9cbce4..058de4d34e6 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php
@@ -23,10 +23,10 @@ class IntegerFormatter extends NumericFormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'thousand_separator' => '',
'prefix_suffix' => TRUE,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php
index 3a0ee89d546..43bbaa5309e 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php
@@ -89,11 +89,11 @@ class LanguageFormatter extends StringFormatter {
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
- $form['native_language'] = array(
+ $form['native_language'] = [
'#title' => $this->t('Display in native language'),
'#type' => 'checkbox',
'#default_value' => $this->getSetting('native_language'),
- );
+ ];
return $form;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php
index 4b9c011cc39..3cc34304167 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php
@@ -23,14 +23,14 @@ class MailToFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
- $elements[$delta] = array(
+ $elements[$delta] = [
'#type' => 'link',
'#title' => $item->value,
'#url' => Url::fromUri('mailto:' . $item->value),
- );
+ ];
}
return $elements;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
index 0e35629e8a8..cf75facc8a1 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
@@ -18,28 +18,28 @@ abstract class NumericFormatterBase extends FormatterBase {
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $options = array(
+ $options = [
'' => t('- None -'),
'.' => t('Decimal point'),
',' => t('Comma'),
' ' => t('Space'),
chr(8201) => t('Thin space'),
"'" => t('Apostrophe'),
- );
- $elements['thousand_separator'] = array(
+ ];
+ $elements['thousand_separator'] = [
'#type' => 'select',
'#title' => t('Thousand marker'),
'#options' => $options,
'#default_value' => $this->getSetting('thousand_separator'),
'#weight' => 0,
- );
+ ];
- $elements['prefix_suffix'] = array(
+ $elements['prefix_suffix'] = [
'#type' => 'checkbox',
'#title' => t('Display prefix and suffix'),
'#default_value' => $this->getSetting('prefix_suffix'),
'#weight' => 10,
- );
+ ];
return $elements;
}
@@ -48,7 +48,7 @@ abstract class NumericFormatterBase extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$summary[] = $this->numberFormat(1234.1234567890);
if ($this->getSetting('prefix_suffix')) {
@@ -62,7 +62,7 @@ abstract class NumericFormatterBase extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
$settings = $this->getFieldSettings();
foreach ($items as $delta => $item) {
@@ -70,8 +70,8 @@ abstract class NumericFormatterBase extends FormatterBase {
// Account for prefix and suffix.
if ($this->getSetting('prefix_suffix')) {
- $prefixes = isset($settings['prefix']) ? array_map(array('Drupal\Core\Field\FieldFilteredMarkup', 'create'), explode('|', $settings['prefix'])) : array('');
- $suffixes = isset($settings['suffix']) ? array_map(array('Drupal\Core\Field\FieldFilteredMarkup', 'create'), explode('|', $settings['suffix'])) : array('');
+ $prefixes = isset($settings['prefix']) ? array_map(['Drupal\Core\Field\FieldFilteredMarkup', 'create'], explode('|', $settings['prefix'])) : [''];
+ $suffixes = isset($settings['suffix']) ? array_map(['Drupal\Core\Field\FieldFilteredMarkup', 'create'], explode('|', $settings['suffix'])) : [''];
$prefix = (count($prefixes) > 1) ? $this->formatPlural($item->value, $prefixes[0], $prefixes[1]) : $prefixes[0];
$suffix = (count($suffixes) > 1) ? $this->formatPlural($item->value, $suffixes[0], $suffixes[1]) : $suffixes[0];
$output = $prefix . $output . $suffix;
@@ -79,10 +79,10 @@ abstract class NumericFormatterBase extends FormatterBase {
// Output the raw value in a content attribute if the text of the HTML
// element differs from the raw value (for example when a prefix is used).
if (isset($item->_attributes) && $item->value != $output) {
- $item->_attributes += array('content' => $item->value);
+ $item->_attributes += ['content' => $item->value];
}
- $elements[$delta] = array('#markup' => $output);
+ $elements[$delta] = ['#markup' => $output];
}
return $elements;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php
index 9881473d1b6..63246b3ff7b 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php
@@ -24,10 +24,10 @@ class NumericUnformattedFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
- $elements[$delta] = array('#markup' => $item->value);
+ $elements[$delta] = ['#markup' => $item->value];
}
return $elements;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
index a1f618b9084..95ab0b2cf48 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
@@ -113,7 +113,7 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
$url = NULL;
if ($this->getSetting('link_to_entity')) {
// For the default revision this falls back to 'canonical'
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php
index 2d7ce8100db..55a2fb1a049 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php
@@ -93,11 +93,11 @@ class TimestampAgoFormatter extends FormatterBase implements ContainerFactoryPlu
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'future_format' => '@interval hence',
'past_format' => '@interval ago',
'granularity' => 2,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -106,28 +106,28 @@ class TimestampAgoFormatter extends FormatterBase implements ContainerFactoryPlu
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
- $form['future_format'] = array(
+ $form['future_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Future format'),
'#default_value' => $this->getSetting('future_format'),
'#description' => $this->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
- );
+ ];
- $form['past_format'] = array(
+ $form['past_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Past format'),
'#default_value' => $this->getSetting('past_format'),
'#description' => $this->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
- );
+ ];
- $elements['granularity'] = array(
+ $elements['granularity'] = [
'#type' => 'number',
'#title' => $this->t('Granularity'),
'#description' => $this->t('How many time interval units should be shown in the formatted output.'),
'#default_value' => $this->getSetting('granularity') ?: 2,
'#min' => 1,
'#max' => 6,
- );
+ ];
return $elements;
}
@@ -140,8 +140,8 @@ class TimestampAgoFormatter extends FormatterBase implements ContainerFactoryPlu
$future_date = strtotime('1 year 1 month 1 week 1 day 1 hour 1 minute');
$past_date = strtotime('-1 year -1 month -1 week -1 day -1 hour -1 minute');
- $summary[] = $this->t('Future date: %display', array('%display' => $this->formatTimestamp($future_date)));
- $summary[] = $this->t('Past date: %display', array('%display' => $this->formatTimestamp($past_date)));
+ $summary[] = $this->t('Future date: %display', ['%display' => $this->formatTimestamp($future_date)]);
+ $summary[] = $this->t('Past date: %display', ['%display' => $this->formatTimestamp($past_date)]);
return $summary;
}
@@ -150,7 +150,7 @@ class TimestampAgoFormatter extends FormatterBase implements ContainerFactoryPlu
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
if ($item->value) {
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php
index 8efe8d5a7f0..a24f5dd9b75 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php
@@ -90,11 +90,11 @@ class TimestampFormatter extends FormatterBase implements ContainerFactoryPlugin
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'date_format' => 'medium',
'custom_date_format' => '',
'timezone' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -103,38 +103,38 @@ class TimestampFormatter extends FormatterBase implements ContainerFactoryPlugin
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
- $date_formats = array();
+ $date_formats = [];
foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) {
- $date_formats[$machine_name] = $this->t('@name format: @date', array('@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)));
+ $date_formats[$machine_name] = $this->t('@name format: @date', ['@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)]);
}
$date_formats['custom'] = $this->t('Custom');
- $elements['date_format'] = array(
+ $elements['date_format'] = [
'#type' => 'select',
'#title' => $this->t('Date format'),
'#options' => $date_formats,
'#default_value' => $this->getSetting('date_format') ?: 'medium',
- );
+ ];
- $elements['custom_date_format'] = array(
+ $elements['custom_date_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Custom date format'),
'#description' => $this->t('See <a href="http://php.net/manual/function.date.php" target="_blank">the documentation for PHP date formats</a>.'),
'#default_value' => $this->getSetting('custom_date_format') ?: '',
- );
+ ];
- $elements['custom_date_format']['#states']['visible'][] = array(
- ':input[name="fields[' . $this->fieldDefinition->getName() . '][settings_edit_form][settings][date_format]"]' => array('value' => 'custom'),
- );
+ $elements['custom_date_format']['#states']['visible'][] = [
+ ':input[name="fields[' . $this->fieldDefinition->getName() . '][settings_edit_form][settings][date_format]"]' => ['value' => 'custom'],
+ ];
- $elements['timezone'] = array(
+ $elements['timezone'] = [
'#type' => 'select',
'#title' => $this->t('Time zone'),
- '#options' => array('' => $this->t('- Default site/user time zone -')) + system_time_zones(FALSE),
+ '#options' => ['' => $this->t('- Default site/user time zone -')] + system_time_zones(FALSE),
'#default_value' => $this->getSetting('timezone'),
- );
+ ];
return $elements;
}
@@ -146,12 +146,12 @@ class TimestampFormatter extends FormatterBase implements ContainerFactoryPlugin
$summary = parent::settingsSummary();
$date_format = $this->getSetting('date_format');
- $summary[] = $this->t('Date format: @date_format', array('@date_format' => $date_format));
+ $summary[] = $this->t('Date format: @date_format', ['@date_format' => $date_format]);
if ($this->getSetting('date_format') === 'custom' && ($custom_date_format = $this->getSetting('custom_date_format'))) {
- $summary[] = $this->t('Custom date format: @custom_date_format', array('@custom_date_format' => $custom_date_format));
+ $summary[] = $this->t('Custom date format: @custom_date_format', ['@custom_date_format' => $custom_date_format]);
}
if ($timezone = $this->getSetting('timezone')) {
- $summary[] = $this->t('Time zone: @timezone', array('@timezone' => $timezone));
+ $summary[] = $this->t('Time zone: @timezone', ['@timezone' => $timezone]);
}
return $summary;
@@ -161,7 +161,7 @@ class TimestampFormatter extends FormatterBase implements ContainerFactoryPlugin
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
$date_format = $this->getSetting('date_format');
$custom_date_format = '';
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php
index 8f2213e1305..42163513edf 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php
@@ -23,7 +23,7 @@ class UriLinkFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
if (!$item->isEmpty()) {
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php
index 01931913a17..51a29d860b8 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php
@@ -28,10 +28,10 @@ class BooleanItem extends FieldItemBase implements OptionsProviderInterface {
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'on_label' => new TranslatableMarkup('On'),
'off_label' => new TranslatableMarkup('Off'),
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
@@ -49,34 +49,34 @@ class BooleanItem extends FieldItemBase implements OptionsProviderInterface {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
'size' => 'tiny',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- $element = array();
+ $element = [];
- $element['on_label'] = array(
+ $element['on_label'] = [
'#type' => 'textfield',
'#title' => $this->t('"On" label'),
'#default_value' => $this->getSetting('on_label'),
'#required' => TRUE,
- );
- $element['off_label'] = array(
+ ];
+ $element['off_label'] = [
'#type' => 'textfield',
'#title' => $this->t('"Off" label'),
'#default_value' => $this->getSetting('off_label'),
'#required' => TRUE,
- );
+ ];
return $element;
}
@@ -85,24 +85,24 @@ class BooleanItem extends FieldItemBase implements OptionsProviderInterface {
* {@inheritdoc}
*/
public function getPossibleValues(AccountInterface $account = NULL) {
- return array(0, 1);
+ return [0, 1];
}
/**
* {@inheritdoc}
*/
public function getPossibleOptions(AccountInterface $account = NULL) {
- return array(
+ return [
0 => $this->getSetting('off_label'),
1 => $this->getSetting('on_label'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getSettableValues(AccountInterface $account = NULL) {
- return array(0, 1);
+ return [0, 1];
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php
index b4bcac530c8..228c8e6bbac 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php
@@ -22,7 +22,7 @@ class CreatedItem extends TimestampItem {
public function applyDefaultValue($notify = TRUE) {
parent::applyDefaultValue($notify);
// Created fields default to the current timestamp.
- $this->setValue(array('value' => REQUEST_TIME), $notify);
+ $this->setValue(['value' => REQUEST_TIME], $notify);
return $this;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
index a8849fd37bf..00fe4098c76 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
@@ -25,10 +25,10 @@ class DecimalItem extends NumericItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'precision' => 10,
'scale' => 2,
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
@@ -46,25 +46,25 @@ class DecimalItem extends NumericItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'numeric',
'precision' => $field_definition->getSetting('precision'),
'scale' => $field_definition->getSetting('scale'),
- )
- ),
- );
+ ]
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element = array();
+ $element = [];
$settings = $this->getSettings();
- $element['precision'] = array(
+ $element['precision'] = [
'#type' => 'number',
'#title' => t('Precision'),
'#min' => 10,
@@ -72,17 +72,17 @@ class DecimalItem extends NumericItemBase {
'#default_value' => $settings['precision'],
'#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
'#disabled' => $has_data,
- );
+ ];
- $element['scale'] = array(
+ $element['scale'] = [
'#type' => 'number',
- '#title' => t('Scale', array(), array('context' => 'decimal places')),
+ '#title' => t('Scale', [], ['context' => 'decimal places']),
'#min' => 0,
'#max' => 10,
'#default_value' => $settings['scale'],
'#description' => t('The number of digits to the right of the decimal.'),
'#disabled' => $has_data,
- );
+ ];
return $element;
}
@@ -94,13 +94,13 @@ class DecimalItem extends NumericItemBase {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Regex' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Regex' => [
'pattern' => '/^[+-]?((\d+(\.\d*)?)|(\.\d+))$/i',
- )
- ),
- ));
+ ]
+ ],
+ ]);
return $constraints;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php
index f42a2b4252b..ca30ede2681 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php
@@ -37,14 +37,14 @@ class EmailItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => Email::EMAIL_MAX_LENGTH,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -54,14 +54,14 @@ class EmailItem extends FieldItemBase {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Length' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Length' => [
'max' => Email::EMAIL_MAX_LENGTH,
- 'maxMessage' => t('%name: the email address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH)),
- )
- ),
- ));
+ 'maxMessage' => t('%name: the email address can not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH]),
+ ]
+ ],
+ ]);
return $constraints;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
index 3babf428752..72c0532f37d 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
@@ -44,19 +44,19 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'target_type' => \Drupal::moduleHandler()->moduleExists('node') ? 'node' : 'user',
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'handler' => 'default',
- 'handler_settings' => array(),
- ) + parent::defaultFieldSettings();
+ 'handler_settings' => [],
+ ] + parent::defaultFieldSettings();
}
/**
@@ -116,32 +116,32 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
$target_type_info = \Drupal::entityManager()->getDefinition($target_type);
$properties = static::propertyDefinitions($field_definition)['target_id'];
if ($target_type_info->entityClassImplements(FieldableEntityInterface::class) && $properties->getDataType() === 'integer') {
- $columns = array(
- 'target_id' => array(
+ $columns = [
+ 'target_id' => [
'description' => 'The ID of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
- ),
- );
+ ],
+ ];
}
else {
- $columns = array(
- 'target_id' => array(
+ $columns = [
+ 'target_id' => [
'description' => 'The ID of the target entity.',
'type' => 'varchar_ascii',
// If the target entities act as bundles for another entity type,
// their IDs should not exceed the maximum length for bundles.
'length' => $target_type_info->getBundleOf() ? EntityTypeInterface::BUNDLE_MAX_LENGTH : 255,
- ),
- );
+ ],
+ ];
}
- $schema = array(
+ $schema = [
'columns' => $columns,
- 'indexes' => array(
- 'target_id' => array('target_id'),
- ),
- );
+ 'indexes' => [
+ 'target_id' => ['target_id'],
+ ],
+ ];
return $schema;
}
@@ -272,12 +272,12 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
// Instead of calling $manager->getSelectionHandler($field_definition)
// replicate the behavior to be able to override the sorting settings.
- $options = array(
+ $options = [
'target_type' => $field_definition->getFieldStorageDefinition()->getSetting('target_type'),
'handler' => $field_definition->getSetting('handler'),
- 'handler_settings' => $field_definition->getSetting('handler_settings') ?: array(),
+ 'handler_settings' => $field_definition->getSetting('handler_settings') ?: [],
'entity' => NULL,
- );
+ ];
$entity_type = \Drupal::entityManager()->getDefinition($options['target_type']);
$options['handler_settings']['sort'] = [
@@ -299,7 +299,7 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element['target_type'] = array(
+ $element['target_type'] = [
'#type' => 'select',
'#title' => t('Type of item to reference'),
'#options' => \Drupal::entityManager()->getEntityTypeLabels(TRUE),
@@ -307,7 +307,7 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
'#required' => TRUE,
'#disabled' => $has_data,
'#size' => 1,
- );
+ ];
return $element;
}
@@ -320,7 +320,7 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
// Get all selection plugins for this entity type.
$selection_plugins = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionGroups($this->getSetting('target_type'));
- $handlers_options = array();
+ $handlers_options = [];
foreach (array_keys($selection_plugins) as $selection_group_id) {
// We only display base plugins (e.g. 'default', 'views', ...) and not
// entity type specific plugins (e.g. 'default:node', 'default:user',
@@ -334,46 +334,46 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
}
}
- $form = array(
+ $form = [
'#type' => 'container',
- '#process' => array(array(get_class($this), 'fieldSettingsAjaxProcess')),
- '#element_validate' => array(array(get_class($this), 'fieldSettingsFormValidate')),
+ '#process' => [[get_class($this), 'fieldSettingsAjaxProcess']],
+ '#element_validate' => [[get_class($this), 'fieldSettingsFormValidate']],
- );
- $form['handler'] = array(
+ ];
+ $form['handler'] = [
'#type' => 'details',
'#title' => t('Reference type'),
'#open' => TRUE,
'#tree' => TRUE,
- '#process' => array(array(get_class($this), 'formProcessMergeParent')),
- );
+ '#process' => [[get_class($this), 'formProcessMergeParent']],
+ ];
- $form['handler']['handler'] = array(
+ $form['handler']['handler'] = [
'#type' => 'select',
'#title' => t('Reference method'),
'#options' => $handlers_options,
'#default_value' => $field->getSetting('handler'),
'#required' => TRUE,
'#ajax' => TRUE,
- '#limit_validation_errors' => array(),
- );
- $form['handler']['handler_submit'] = array(
+ '#limit_validation_errors' => [],
+ ];
+ $form['handler']['handler_submit'] = [
'#type' => 'submit',
'#value' => t('Change handler'),
- '#limit_validation_errors' => array(),
- '#attributes' => array(
- 'class' => array('js-hide'),
- ),
- '#submit' => array(array(get_class($this), 'settingsAjaxSubmit')),
- );
-
- $form['handler']['handler_settings'] = array(
+ '#limit_validation_errors' => [],
+ '#attributes' => [
+ 'class' => ['js-hide'],
+ ],
+ '#submit' => [[get_class($this), 'settingsAjaxSubmit']],
+ ];
+
+ $form['handler']['handler_settings'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('entity_reference-settings')),
- );
+ '#attributes' => ['class' => ['entity_reference-settings']],
+ ];
$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($field);
- $form['handler']['handler_settings'] += $handler->buildConfigurationForm(array(), $form_state);
+ $form['handler']['handler_settings'] += $handler->buildConfigurationForm([], $form_state);
return $form;
}
@@ -556,14 +556,14 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
public function getSettableOptions(AccountInterface $account = NULL) {
$field_definition = $this->getFieldDefinition();
if (!$options = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($field_definition, $this->getEntity())->getReferenceableEntities()) {
- return array();
+ return [];
}
// Rebuild the array by changing the bundle key into the bundle label.
$target_type = $field_definition->getSetting('target_type');
$bundles = \Drupal::entityManager()->getBundleInfo($target_type);
- $return = array();
+ $return = [];
foreach ($options as $bundle => $entity_ids) {
// The label does not need sanitizing since it is used as an optgroup
// which is only supported by select elements and auto-escaped.
@@ -593,11 +593,11 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
*/
public static function fieldSettingsAjaxProcessElement(&$element, $main_form) {
if (!empty($element['#ajax'])) {
- $element['#ajax'] = array(
- 'callback' => array(get_called_class(), 'settingsAjax'),
+ $element['#ajax'] = [
+ 'callback' => [get_called_class(), 'settingsAjax'],
'wrapper' => $main_form['#id'],
'element' => $main_form['#array_parents'],
- );
+ ];
}
foreach (Element::children($element) as $key) {
@@ -641,7 +641,7 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
* {@inheritdoc}
*/
public static function getPreconfiguredOptions() {
- $options = array();
+ $options = [];
// Add all the commonly referenced entity types as distinct pre-configured
// options.
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php
index 601bc8a1944..7b2234c18e1 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php
@@ -36,13 +36,13 @@ class FloatItem extends NumericItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'float',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php
index 0e954171312..8469126729a 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php
@@ -24,24 +24,24 @@ class IntegerItem extends NumericItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'unsigned' => FALSE,
// Valid size property values include: 'tiny', 'small', 'medium', 'normal'
// and 'big'.
'size' => 'normal',
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'min' => '',
'max' => '',
'prefix' => '',
'suffix' => '',
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
@@ -65,17 +65,17 @@ class IntegerItem extends NumericItemBase {
// integer to be positive.
if ($this->getSetting('unsigned')) {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Range' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Range' => [
'min' => 0,
- 'minMessage' => t('%name: The integer must be larger or equal to %min.', array(
+ 'minMessage' => t('%name: The integer must be larger or equal to %min.', [
'%name' => $this->getFieldDefinition()->getLabel(),
'%min' => 0,
- )),
- ),
- ),
- ));
+ ]),
+ ],
+ ],
+ ]);
}
return $constraints;
@@ -85,18 +85,18 @@ class IntegerItem extends NumericItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
// Expose the 'unsigned' setting in the field item schema.
'unsigned' => $field_definition->getSetting('unsigned'),
// Expose the 'size' setting in the field item schema. For instance,
// supply 'big' as a value to produce a 'bigint' type.
'size' => $field_definition->getSetting('size'),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php
index 0b9bba97c96..18935c1b8f5 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php
@@ -65,14 +65,14 @@ class LanguageItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar_ascii',
'length' => 12,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -99,7 +99,7 @@ class LanguageItem extends FieldItemBase {
public function applyDefaultValue($notify = TRUE) {
// Default to the site's default language. When language module is enabled,
// this behavior is configurable, see language_field_info_alter().
- $this->setValue(array('value' => \Drupal::languageManager()->getDefaultLanguage()->getId()), $notify);
+ $this->setValue(['value' => \Drupal::languageManager()->getDefaultLanguage()->getId()], $notify);
return $this;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php
index cff52d8e91a..04045c7d242 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php
@@ -22,22 +22,22 @@ class MapItem extends FieldItemBase {
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
// The properties are dynamic and can not be defined statically.
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'blob',
'size' => 'big',
'serialize' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -53,7 +53,7 @@ class MapItem extends FieldItemBase {
* {@inheritdoc}
*/
public function setValue($values, $notify = TRUE) {
- $this->values = array();
+ $this->values = [];
if (!isset($values)) {
return;
}
@@ -80,7 +80,7 @@ class MapItem extends FieldItemBase {
*/
public function __get($name) {
if (!isset($this->values[$name])) {
- $this->values[$name] = array();
+ $this->values[$name] = [];
}
return $this->values[$name];
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php
index 678ab1ff2d1..23f5161f28b 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php
@@ -14,47 +14,47 @@ abstract class NumericItemBase extends FieldItemBase {
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'min' => '',
'max' => '',
'prefix' => '',
'suffix' => '',
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- $element = array();
+ $element = [];
$settings = $this->getSettings();
- $element['min'] = array(
+ $element['min'] = [
'#type' => 'number',
'#title' => t('Minimum'),
'#default_value' => $settings['min'],
'#description' => t('The minimum value that should be allowed in this field. Leave blank for no minimum.'),
- );
- $element['max'] = array(
+ ];
+ $element['max'] = [
'#type' => 'number',
'#title' => t('Maximum'),
'#default_value' => $settings['max'],
'#description' => t('The maximum value that should be allowed in this field. Leave blank for no maximum.'),
- );
- $element['prefix'] = array(
+ ];
+ $element['prefix'] = [
'#type' => 'textfield',
'#title' => t('Prefix'),
'#default_value' => $settings['prefix'],
'#size' => 60,
'#description' => t("Define a string that should be prefixed to the value, like '$ ' or '&euro; '. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
- );
- $element['suffix'] = array(
+ ];
+ $element['suffix'] = [
'#type' => 'textfield',
'#title' => t('Suffix'),
'#default_value' => $settings['suffix'],
'#size' => 60,
'#description' => t("Define a string that should be suffixed to the value, like ' m', ' kb/s'. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
- );
+ ];
return $element;
}
@@ -81,26 +81,26 @@ abstract class NumericItemBase extends FieldItemBase {
if (!empty($settings['min'])) {
$min = $settings['min'];
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Range' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Range' => [
'min' => $min,
- 'minMessage' => t('%name: the value may be no less than %min.', array('%name' => $label, '%min' => $min)),
- )
- ),
- ));
+ 'minMessage' => t('%name: the value may be no less than %min.', ['%name' => $label, '%min' => $min]),
+ ]
+ ],
+ ]);
}
if (!empty($settings['max'])) {
$max = $settings['max'];
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Range' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Range' => [
'max' => $max,
- 'maxMessage' => t('%name: the value may be no greater than %max.', array('%name' => $label, '%max' => $max)),
- )
- ),
- ));
+ 'maxMessage' => t('%name: the value may be no greater than %max.', ['%name' => $label, '%max' => $max]),
+ ]
+ ],
+ ]);
}
return $constraints;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
index 67414d98fb9..b51764c2948 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
@@ -25,25 +25,25 @@ class StringItem extends StringItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'max_length' => 255,
'is_ascii' => FALSE,
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => $field_definition->getSetting('is_ascii') === TRUE ? 'varchar_ascii' : 'varchar',
'length' => (int) $field_definition->getSetting('max_length'),
'binary' => $field_definition->getSetting('case_sensitive'),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -54,14 +54,14 @@ class StringItem extends StringItemBase {
if ($max_length = $this->getSetting('max_length')) {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Length' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Length' => [
'max' => $max_length,
- 'maxMessage' => t('%name: may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)),
- ),
- ),
- ));
+ 'maxMessage' => t('%name: may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
+ ],
+ ],
+ ]);
}
return $constraints;
@@ -80,9 +80,9 @@ class StringItem extends StringItemBase {
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element = array();
+ $element = [];
- $element['max_length'] = array(
+ $element['max_length'] = [
'#type' => 'number',
'#title' => t('Maximum length'),
'#default_value' => $this->getSetting('max_length'),
@@ -90,7 +90,7 @@ class StringItem extends StringItemBase {
'#description' => t('The maximum length of the field in characters.'),
'#min' => 1,
'#disabled' => $has_data,
- );
+ ];
return $element;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php
index 6a784d6ca4a..f59c10c985f 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php
@@ -16,9 +16,9 @@ abstract class StringItemBase extends FieldItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'case_sensitive' => FALSE,
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php
index ae998d321c8..93c6b27bcb6 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php
@@ -24,14 +24,14 @@ class StringLongItem extends StringItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => $field_definition->getSetting('case_sensitive') ? 'blob' : 'text',
'size' => 'big',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php
index 98094caffa3..f48e4f01cac 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php
@@ -44,13 +44,13 @@ class TimestampItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php
index 034fc164d73..8d1d6e64949 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php
@@ -52,15 +52,15 @@ class UriItem extends StringItem {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => (int) $field_definition->getSetting('max_length'),
'binary' => $field_definition->getSetting('case_sensitive'),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php
index 8bd33ce4478..a5f94010880 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php
@@ -24,10 +24,10 @@ class UuidItem extends StringItem {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'max_length' => 128,
'is_ascii' => TRUE,
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
@@ -36,7 +36,7 @@ class UuidItem extends StringItem {
public function applyDefaultValue($notify = TRUE) {
// Default to one field item with a generated UUID.
$uuid = \Drupal::service('uuid');
- $this->setValue(array('value' => $uuid->generate()), $notify);
+ $this->setValue(['value' => $uuid->generate()], $notify);
return $this;
}
@@ -45,7 +45,7 @@ class UuidItem extends StringItem {
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$schema = parent::schema($field_definition);
- $schema['unique keys']['value'] = array('value');
+ $schema['unique keys']['value'] = ['value'];
return $schema;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php
index 3106fbe6b33..1d4a202f00f 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php
@@ -24,21 +24,21 @@ class BooleanCheckboxWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'display_label' => TRUE,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['display_label'] = array(
+ $element['display_label'] = [
'#type' => 'checkbox',
'#title' => t('Use field label instead of the "On label" as label'),
'#default_value' => $this->getSetting('display_label'),
'#weight' => -1,
- );
+ ];
return $element;
}
@@ -46,10 +46,10 @@ class BooleanCheckboxWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$display_label = $this->getSetting('display_label');
- $summary[] = t('Use field label: @display_label', array('@display_label' => ($display_label ? t('Yes') : 'No')));
+ $summary[] = t('Use field label: @display_label', ['@display_label' => ($display_label ? t('Yes') : 'No')]);
return $summary;
}
@@ -58,10 +58,10 @@ class BooleanCheckboxWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'checkbox',
'#default_value' => !empty($items[0]->value),
- );
+ ];
// Override the title from the incoming $element.
if ($this->getSetting('display_label')) {
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php
index 9931d4e6fb1..07f66cf269a 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php
@@ -24,29 +24,29 @@ class EmailDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'size' => 60,
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['size'] = array(
+ $element['size'] = [
'#type' => 'number',
'#title' => $this->t('Textfield size'),
'#default_value' => $this->getSetting('size'),
'#required' => TRUE,
'#min' => 1,
- );
- $element['placeholder'] = array(
+ ];
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
+ ];
return $element;
}
@@ -54,16 +54,16 @@ class EmailDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
- $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
else {
$summary[] = t('No placeholder');
}
- $summary[] = t('Textfield size: @size', array('@size' => $this->getSetting('size')));
+ $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
return $summary;
}
@@ -72,13 +72,13 @@ class EmailDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'email',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#placeholder' => $this->getSetting('placeholder'),
'#size' => $this->getSetting('size'),
'#maxlength' => Email::EMAIL_MAX_LENGTH,
- );
+ ];
return $element;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
index 3824810a923..11f048e6f89 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
@@ -26,37 +26,37 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'match_operator' => 'CONTAINS',
'size' => '60',
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['match_operator'] = array(
+ $element['match_operator'] = [
'#type' => 'radios',
'#title' => t('Autocomplete matching'),
'#default_value' => $this->getSetting('match_operator'),
'#options' => $this->getMatchOperatorOptions(),
'#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of entities.'),
- );
- $element['size'] = array(
+ ];
+ $element['size'] = [
'#type' => 'number',
'#title' => t('Size of textfield'),
'#default_value' => $this->getSetting('size'),
'#min' => 1,
'#required' => TRUE,
- );
- $element['placeholder'] = array(
+ ];
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
+ ];
return $element;
}
@@ -64,14 +64,14 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$operators = $this->getMatchOperatorOptions();
- $summary[] = t('Autocomplete matching: @match_operator', array('@match_operator' => $operators[$this->getSetting('match_operator')]));
- $summary[] = t('Textfield size: @size', array('@size' => $this->getSetting('size')));
+ $summary[] = t('Autocomplete matching: @match_operator', ['@match_operator' => $operators[$this->getSetting('match_operator')]]);
+ $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
- $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
else {
$summary[] = t('No placeholder');
@@ -90,7 +90,7 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
// Append the match operation to the selection settings.
$selection_settings = $this->getFieldSetting('handler_settings') + ['match_operator' => $this->getSetting('match_operator')];
- $element += array(
+ $element += [
'#type' => 'entity_autocomplete',
'#target_type' => $this->getFieldSetting('target_type'),
'#selection_handler' => $this->getFieldSetting('handler'),
@@ -102,16 +102,16 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
'#default_value' => isset($referenced_entities[$delta]) ? $referenced_entities[$delta] : NULL,
'#size' => $this->getSetting('size'),
'#placeholder' => $this->getSetting('placeholder'),
- );
+ ];
if ($this->getSelectionHandlerSetting('auto_create') && ($bundle = $this->getAutocreateBundle())) {
- $element['#autocreate'] = array(
+ $element['#autocreate'] = [
'bundle' => $bundle,
'uid' => ($entity instanceof EntityOwnerInterface) ? $entity->getOwnerId() : \Drupal::currentUser()->id()
- );
+ ];
}
- return array('target_id' => $element);
+ return ['target_id' => $element];
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php
index 697c603ab40..0872ba3b207 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php
@@ -24,11 +24,11 @@ class LanguageSelectWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'language_select',
'#default_value' => $items[$delta]->value,
'#languages' => $this->getSetting('include_locked') ? LanguageInterface::STATE_ALL : LanguageInterface::STATE_CONFIGURABLE,
- );
+ ];
return $element;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php
index 82005696ddc..b4fac537b47 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php
@@ -27,21 +27,21 @@ class NumberWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['placeholder'] = array(
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
+ ];
return $element;
}
@@ -49,11 +49,11 @@ class NumberWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
- $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
else {
$summary[] = t('No placeholder');
@@ -69,11 +69,11 @@ class NumberWidget extends WidgetBase {
$value = isset($items[$delta]->value) ? $items[$delta]->value : NULL;
$field_settings = $this->getFieldSettings();
- $element += array(
+ $element += [
'#type' => 'number',
'#default_value' => $value,
'#placeholder' => $this->getSetting('placeholder'),
- );
+ ];
// Set the step for floating point and decimal numbers.
switch ($this->fieldDefinition->getType()) {
@@ -104,7 +104,7 @@ class NumberWidget extends WidgetBase {
$element['#field_suffix'] = FieldFilteredMarkup::create(array_pop($suffixes));
}
- return array('value' => $element);
+ return ['value' => $element];
}
/**
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php
index 1224c63c04c..7787106d85f 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php
@@ -35,25 +35,25 @@ class OptionsButtonsWidget extends OptionsWidgetBase {
// If required and there is one single option, preselect it.
if ($this->required && count($options) == 1) {
reset($options);
- $selected = array(key($options));
+ $selected = [key($options)];
}
if ($this->multiple) {
- $element += array(
+ $element += [
'#type' => 'checkboxes',
'#default_value' => $selected,
'#options' => $options,
- );
+ ];
}
else {
- $element += array(
+ $element += [
'#type' => 'radios',
// Radio buttons need a scalar value. Take the first default value, or
// default to NULL so that the form element is properly recognized as
// not having a default value.
'#default_value' => $selected ? reset($selected) : NULL,
'#options' => $options,
- );
+ ];
}
return $element;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php
index 3a719896f45..b623c8755ee 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php
@@ -29,13 +29,13 @@ class OptionsSelectWidget extends OptionsWidgetBase {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
- $element += array(
+ $element += [
'#type' => 'select',
'#options' => $this->getOptions($items->getEntity()),
'#default_value' => $this->getSelectedOptions($items),
// Do not display a 'multiple' select box if there is only one option.
'#multiple' => $this->multiple && count($this->options) > 1,
- );
+ ];
return $element;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
index ca00bcc6485..bb773cdeabf 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
@@ -50,7 +50,7 @@ abstract class OptionsWidgetBase extends WidgetBase {
$this->has_value = isset($items[0]->{$this->column});
// Add our custom validator.
- $element['#element_validate'][] = array(get_class($this), 'validateElement');
+ $element['#element_validate'][] = [get_class($this), 'validateElement'];
$element['#key_column'] = $this->column;
// The rest of the $element is built by child method implementations.
@@ -68,7 +68,7 @@ abstract class OptionsWidgetBase extends WidgetBase {
*/
public static function validateElement(array $element, FormStateInterface $form_state) {
if ($element['#required'] && $element['#value'] == '_none') {
- $form_state->setError($element, t('@name field is required.', array('@name' => $element['#title'])));
+ $form_state->setError($element, t('@name field is required.', ['@name' => $element['#title']]));
}
// Massage submitted form values.
@@ -80,7 +80,7 @@ abstract class OptionsWidgetBase extends WidgetBase {
$values = array_values($element['#value']);
}
else {
- $values = array($element['#value']);
+ $values = [$element['#value']];
}
// Filter out the 'none' option. Use a strict comparison, because
@@ -91,9 +91,9 @@ abstract class OptionsWidgetBase extends WidgetBase {
}
// Transpose selections from field => delta to delta => field.
- $items = array();
+ $items = [];
foreach ($values as $value) {
- $items[] = array($element['#key_column'] => $value);
+ $items[] = [$element['#key_column'] => $value];
}
$form_state->setValueForElement($element, $items);
}
@@ -121,13 +121,13 @@ abstract class OptionsWidgetBase extends WidgetBase {
}
$module_handler = \Drupal::moduleHandler();
- $context = array(
+ $context = [
'fieldDefinition' => $this->fieldDefinition,
'entity' => $entity,
- );
+ ];
$module_handler->alter('options_list', $options, $context);
- array_walk_recursive($options, array($this, 'sanitizeLabel'));
+ array_walk_recursive($options, [$this, 'sanitizeLabel']);
// Options might be nested ("optgroups"). If the widget does not support
// nested options, flatten the list.
@@ -153,7 +153,7 @@ abstract class OptionsWidgetBase extends WidgetBase {
// We need to check against a flat list of options.
$flat_options = OptGroup::flattenOptions($this->getOptions($items->getEntity()));
- $selected_options = array();
+ $selected_options = [];
foreach ($items as $item) {
$value = $item->{$this->column};
// Keep the value if it actually is in the list of options (needs to be
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php
index e6b0ff08d32..5f21b5edd49 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php
@@ -23,29 +23,29 @@ class StringTextareaWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'rows' => '5',
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['rows'] = array(
+ $element['rows'] = [
'#type' => 'number',
'#title' => t('Rows'),
'#default_value' => $this->getSetting('rows'),
'#required' => TRUE,
'#min' => 1,
- );
- $element['placeholder'] = array(
+ ];
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
+ ];
return $element;
}
@@ -53,12 +53,12 @@ class StringTextareaWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
- $summary[] = t('Number of rows: @rows', array('@rows' => $this->getSetting('rows')));
+ $summary[] = t('Number of rows: @rows', ['@rows' => $this->getSetting('rows')]);
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
- $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
return $summary;
@@ -68,13 +68,13 @@ class StringTextareaWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'textarea',
'#default_value' => $items[$delta]->value,
'#rows' => $this->getSetting('rows'),
'#placeholder' => $this->getSetting('placeholder'),
- '#attributes' => array('class' => array('js-text-full', 'text-full')),
- );
+ '#attributes' => ['class' => ['js-text-full', 'text-full']],
+ ];
return $element;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php
index d89f0b2f5f9..3be16817614 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php
@@ -23,29 +23,29 @@ class StringTextfieldWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'size' => 60,
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['size'] = array(
+ $element['size'] = [
'#type' => 'number',
'#title' => t('Size of textfield'),
'#default_value' => $this->getSetting('size'),
'#required' => TRUE,
'#min' => 1,
- );
- $element['placeholder'] = array(
+ ];
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
+ ];
return $element;
}
@@ -53,12 +53,12 @@ class StringTextfieldWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
- $summary[] = t('Textfield size: @size', array('@size' => $this->getSetting('size')));
+ $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
- $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
return $summary;
@@ -68,14 +68,14 @@ class StringTextfieldWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'textfield',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#size' => $this->getSetting('size'),
'#placeholder' => $this->getSetting('placeholder'),
'#maxlength' => $this->getFieldSetting('max_length'),
- '#attributes' => array('class' => array('js-text-full', 'text-full')),
- );
+ '#attributes' => ['class' => ['js-text-full', 'text-full']],
+ ];
return $element;
}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
index 714b4e04d3b..f89b4442e45 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
@@ -23,29 +23,29 @@ class UriWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'size' => 60,
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['size'] = array(
+ $element['size'] = [
'#type' => 'number',
'#title' => $this->t('Size of URI field'),
'#default_value' => $this->getSetting('size'),
'#required' => TRUE,
'#min' => 1,
- );
- $element['placeholder'] = array(
+ ];
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => $this->t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
+ ];
return $element;
}
@@ -53,12 +53,12 @@ class UriWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
- $summary[] = $this->t('URI field size: @size', array('@size' => $this->getSetting('size')));
+ $summary[] = $this->t('URI field size: @size', ['@size' => $this->getSetting('size')]);
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
- $summary[] = $this->t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
return $summary;
@@ -68,13 +68,13 @@ class UriWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'url',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#size' => $this->getSetting('size'),
'#placeholder' => $this->getSetting('placeholder'),
'#maxlength' => $this->getFieldSetting('max_length'),
- );
+ ];
return $element;
}
diff --git a/core/lib/Drupal/Core/Field/PluginSettingsBase.php b/core/lib/Drupal/Core/Field/PluginSettingsBase.php
index a6196ec5258..073bd2c787e 100644
--- a/core/lib/Drupal/Core/Field/PluginSettingsBase.php
+++ b/core/lib/Drupal/Core/Field/PluginSettingsBase.php
@@ -17,7 +17,7 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
*
* @var array
*/
- protected $settings = array();
+ protected $settings = [];
/**
* The plugin settings injected by third party modules.
@@ -26,7 +26,7 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
*
* @var array
*/
- protected $thirdPartySettings = array();
+ protected $thirdPartySettings = [];
/**
* Whether default settings have been merged into the current $settings.
@@ -39,7 +39,7 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array();
+ return [];
}
/**
@@ -140,11 +140,11 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
public function calculateDependencies() {
if (!empty($this->thirdPartySettings)) {
// Create dependencies on any modules providing third party settings.
- return array(
+ return [
'module' => array_keys($this->thirdPartySettings)
- );
+ ];
}
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php
index 497889582fc..b1579f2445a 100644
--- a/core/lib/Drupal/Core/Field/WidgetBase.php
+++ b/core/lib/Drupal/Core/Field/WidgetBase.php
@@ -48,7 +48,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* Any third party settings.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings) {
- parent::__construct(array(), $plugin_id, $plugin_definition);
+ parent::__construct([], $plugin_id, $plugin_definition);
$this->fieldDefinition = $field_definition;
$this->settings = $settings;
$this->thirdPartySettings = $third_party_settings;
@@ -63,25 +63,25 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
// Store field information in $form_state.
if (!static::getWidgetState($parents, $field_name, $form_state)) {
- $field_state = array(
+ $field_state = [
'items_count' => count($items),
- 'array_parents' => array(),
- );
+ 'array_parents' => [],
+ ];
static::setWidgetState($parents, $field_name, $form_state, $field_state);
}
// Collect widget elements.
- $elements = array();
+ $elements = [];
// If the widget is handling multiple values (e.g Options), or if we are
// displaying an individual element, just get a single form element and make
// it the $delta value.
if ($this->handlesMultipleValues() || isset($get_delta)) {
$delta = isset($get_delta) ? $get_delta : 0;
- $element = array(
+ $element = [
'#title' => $this->fieldDefinition->getLabel(),
'#description' => FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())),
- );
+ ];
$element = $this->formSingleElement($items, $delta, $element, $form, $form_state);
if ($element) {
@@ -107,28 +107,28 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
// Populate the 'array_parents' information in $form_state->get('field')
// after the form is built, so that we catch changes in the form structure
// performed in alter() hooks.
- $elements['#after_build'][] = array(get_class($this), 'afterBuild');
+ $elements['#after_build'][] = [get_class($this), 'afterBuild'];
$elements['#field_name'] = $field_name;
$elements['#field_parents'] = $parents;
// Enforce the structure of submitted values.
- $elements['#parents'] = array_merge($parents, array($field_name));
+ $elements['#parents'] = array_merge($parents, [$field_name]);
// Most widgets need their internal structure preserved in submitted values.
- $elements += array('#tree' => TRUE);
+ $elements += ['#tree' => TRUE];
- return array(
+ return [
// Aid in theming of widgets by rendering a classified container.
'#type' => 'container',
// Assign a different parent, to keep the main id for the widget itself.
- '#parents' => array_merge($parents, array($field_name . '_wrapper')),
- '#attributes' => array(
- 'class' => array(
+ '#parents' => array_merge($parents, [$field_name . '_wrapper']),
+ '#attributes' => [
+ 'class' => [
'field--type-' . Html::getClass($this->fieldDefinition->getType()),
'field--name-' . Html::getClass($field_name),
'field--widget-' . Html::getClass($this->getPluginId()),
- ),
- ),
+ ],
+ ],
'widget' => $elements,
- );
+ ];
}
/**
@@ -161,7 +161,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
$title = $this->fieldDefinition->getLabel();
$description = FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription()));
- $elements = array();
+ $elements = [];
for ($delta = 0; $delta <= $max; $delta++) {
// Add a new empty item if it doesn't exist yet at this delta.
@@ -193,15 +193,15 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
if ($is_multiple) {
// We name the element '_weight' to avoid clashing with elements
// defined by widget.
- $element['_weight'] = array(
+ $element['_weight'] = [
'#type' => 'weight',
- '#title' => $this->t('Weight for row @number', array('@number' => $delta + 1)),
+ '#title' => $this->t('Weight for row @number', ['@number' => $delta + 1]),
'#title_display' => 'invisible',
// Note: this 'delta' is the FAPI #type 'weight' element's property.
'#delta' => $max,
'#default_value' => $items[$delta]->_weight ?: $delta,
'#weight' => 100,
- );
+ ];
}
$elements[$delta] = $element;
@@ -209,7 +209,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
}
if ($elements) {
- $elements += array(
+ $elements += [
'#theme' => 'field_multiple_value_form',
'#field_name' => $field_name,
'#cardinality' => $cardinality,
@@ -218,28 +218,28 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
'#title' => $title,
'#description' => $description,
'#max_delta' => $max,
- );
+ ];
// Add 'add more' button, if not working with a programmed form.
if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && !$form_state->isProgrammed()) {
- $id_prefix = implode('-', array_merge($parents, array($field_name)));
+ $id_prefix = implode('-', array_merge($parents, [$field_name]));
$wrapper_id = Html::getUniqueId($id_prefix . '-add-more-wrapper');
$elements['#prefix'] = '<div id="' . $wrapper_id . '">';
$elements['#suffix'] = '</div>';
- $elements['add_more'] = array(
+ $elements['add_more'] = [
'#type' => 'submit',
'#name' => strtr($id_prefix, '-', '_') . '_add_more',
'#value' => t('Add another item'),
- '#attributes' => array('class' => array('field-add-more-submit')),
- '#limit_validation_errors' => array(array_merge($parents, array($field_name))),
- '#submit' => array(array(get_class($this), 'addMoreSubmit')),
- '#ajax' => array(
- 'callback' => array(get_class($this), 'addMoreAjax'),
+ '#attributes' => ['class' => ['field-add-more-submit']],
+ '#limit_validation_errors' => [array_merge($parents, [$field_name])],
+ '#submit' => [[get_class($this), 'addMoreSubmit']],
+ '#ajax' => [
+ 'callback' => [get_class($this), 'addMoreAjax'],
'wrapper' => $wrapper_id,
'effect' => 'fade',
- ),
- );
+ ],
+ ];
}
}
@@ -311,26 +311,26 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
* Generates the form element for a single copy of the widget.
*/
protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element += array(
+ $element += [
'#field_parents' => $form['#parents'],
// Only the first widget should be required.
'#required' => $delta == 0 && $this->fieldDefinition->isRequired(),
'#delta' => $delta,
'#weight' => $delta,
- );
+ ];
$element = $this->formElement($items, $delta, $element, $form, $form_state);
if ($element) {
// Allow modules to alter the field widget form element.
- $context = array(
+ $context = [
'form' => $form,
'widget' => $this,
'items' => $items,
'delta' => $delta,
'default' => $this->isDefaultValueWidget($form_state),
- );
- \Drupal::moduleHandler()->alter(array('field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'), $element, $form_state, $context);
+ ];
+ \Drupal::moduleHandler()->alter(['field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'], $element, $form_state, $context);
}
return $element;
@@ -343,7 +343,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
$field_name = $this->fieldDefinition->getName();
// Extract the values from $form_state->getValues().
- $path = array_merge($form['#parents'], array($field_name));
+ $path = array_merge($form['#parents'], [$field_name]);
$key_exists = NULL;
$values = NestedArray::getValue($form_state->getValues(), $path, $key_exists);
@@ -410,7 +410,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
if (Element::isVisibleElement($element)) {
$handles_multiple = $this->handlesMultipleValues();
- $violations_by_delta = array();
+ $violations_by_delta = [];
foreach ($violations as $violation) {
// Separate violations by delta.
$property_path = explode('.', $violation->getPropertyPath());
@@ -473,21 +473,21 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
// Field processing data is placed at
// $form_state->get(['field_storage', '#parents', ...$parents..., '#fields', $field_name]),
// to avoid clashes between field names and $parents parts.
- return array_merge(array('field_storage', '#parents'), $parents, array('#fields', $field_name));
+ return array_merge(['field_storage', '#parents'], $parents, ['#fields', $field_name]);
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php
index 6be1b9ef8ea..c7c2d796da7 100644
--- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php
+++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php
@@ -74,10 +74,10 @@ class WidgetPluginManager extends DefaultPluginManager {
*/
public function getInstance(array $options) {
// Fill in defaults for missing properties.
- $options += array(
- 'configuration' => array(),
+ $options += [
+ 'configuration' => [],
'prepare' => TRUE,
- );
+ ];
$configuration = $options['configuration'];
$field_definition = $options['field_definition'];
@@ -104,16 +104,16 @@ class WidgetPluginManager extends DefaultPluginManager {
$plugin_id = $field_type_definition['default_widget'];
}
- $configuration += array(
+ $configuration += [
'field_definition' => $field_definition,
- );
+ ];
return $this->createInstance($plugin_id, $configuration);
}
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
@@ -139,10 +139,10 @@ class WidgetPluginManager extends DefaultPluginManager {
*/
public function prepareConfiguration($field_type, array $configuration) {
// Fill in defaults for missing properties.
- $configuration += array(
- 'settings' => array(),
- 'third_party_settings' => array(),
- );
+ $configuration += [
+ 'settings' => [],
+ 'third_party_settings' => [],
+ ];
// If no widget is specified, use the default widget.
if (!isset($configuration['type'])) {
$field_type = $this->fieldTypeManager->getDefinition($field_type);
@@ -168,10 +168,10 @@ class WidgetPluginManager extends DefaultPluginManager {
*/
public function getOptions($field_type = NULL) {
if (!isset($this->widgetOptions)) {
- $options = array();
+ $options = [];
$field_types = $this->fieldTypeManager->getDefinitions();
$widget_types = $this->getDefinitions();
- uasort($widget_types, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($widget_types, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
foreach ($widget_types as $name => $widget_type) {
foreach ($widget_type['field_types'] as $widget_field_type) {
// Check that the field type exists.
@@ -183,7 +183,7 @@ class WidgetPluginManager extends DefaultPluginManager {
$this->widgetOptions = $options;
}
if (isset($field_type)) {
- return !empty($this->widgetOptions[$field_type]) ? $this->widgetOptions[$field_type] : array();
+ return !empty($this->widgetOptions[$field_type]) ? $this->widgetOptions[$field_type] : [];
}
return $this->widgetOptions;
@@ -206,7 +206,7 @@ class WidgetPluginManager extends DefaultPluginManager {
return $plugin_class::defaultSettings();
}
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/File/FileSystem.php b/core/lib/Drupal/Core/File/FileSystem.php
index a2fafbb60da..9f92d0bd8b2 100644
--- a/core/lib/Drupal/Core/File/FileSystem.php
+++ b/core/lib/Drupal/Core/File/FileSystem.php
@@ -95,7 +95,7 @@ class FileSystem implements FileSystemInterface {
return TRUE;
}
- $this->logger->error('The file permissions could not be set on %uri.', array('%uri' => $uri));
+ $this->logger->error('The file permissions could not be set on %uri.', ['%uri' => $uri]);
return FALSE;
}
diff --git a/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php b/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php
index 8e5c95a2c0a..cc54d6c1c24 100644
--- a/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php
+++ b/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php
@@ -16,8 +16,8 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface {
* @var array
* Array of mimetypes correlated to the extensions that relate to them.
*/
- protected $defaultMapping = array(
- 'mimetypes' => array(
+ protected $defaultMapping = [
+ 'mimetypes' => [
0 => 'application/andrew-inset',
1 => 'application/atom',
2 => 'application/atomcat+xml',
@@ -377,10 +377,10 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface {
343 => 'x-conference/x-cooltalk',
344 => 'x-epoc/x-sisx-app',
345 => 'x-world/x-vrml',
- ),
+ ],
// Extensions added to this list MUST be lower-case.
- 'extensions' => array(
+ 'extensions' => [
'ez' => 0,
'atom' => 1,
'atomcat' => 2,
@@ -856,8 +856,8 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface {
'weba' => 356,
'webm' => 357,
'vtt' => 358,
- ),
- );
+ ],
+ ];
/**
* The MIME types mapping array after going through the module handler.
diff --git a/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php b/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php
index 85d0261631f..a8ad4010bd1 100644
--- a/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php
+++ b/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php
@@ -17,7 +17,7 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface {
*
* @var array
*/
- protected $guessers = array();
+ protected $guessers = [];
/**
* Holds the array of guessers sorted by priority.
@@ -98,7 +98,7 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface {
* A sorted array of MIME type guesser objects.
*/
protected function sortGuessers() {
- $sorted = array();
+ $sorted = [];
krsort($this->guessers);
foreach ($this->guessers as $guesser) {
diff --git a/core/lib/Drupal/Core/File/file.api.php b/core/lib/Drupal/Core/File/file.api.php
index d1e125e5363..506884fad36 100644
--- a/core/lib/Drupal/Core/File/file.api.php
+++ b/core/lib/Drupal/Core/File/file.api.php
@@ -33,9 +33,9 @@ function hook_file_download($uri) {
$scheme = file_uri_scheme($uri);
$target = file_uri_target($uri);
if ($scheme == 'temporary' && $target == 'config.tar.gz') {
- return array(
+ return [
'Content-disposition' => 'attachment; filename="config.tar.gz"',
- );
+ ];
}
}
@@ -64,11 +64,11 @@ function hook_file_url_alter(&$uri) {
$cdn1 = 'http://cdn1.example.com';
$cdn2 = 'http://cdn2.example.com';
- $cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png');
+ $cdn_extensions = ['css', 'js', 'gif', 'jpg', 'jpeg', 'png'];
// Most CDNs don't support private file transfers without a lot of hassle,
// so don't support this in the common case.
- $schemes = array('public');
+ $schemes = ['public'];
$scheme = file_uri_scheme($uri);
@@ -166,11 +166,11 @@ function hook_archiver_info_alter(&$info) {
* @see drupal_get_filetransfer_info()
*/
function hook_filetransfer_info() {
- $info['sftp'] = array(
+ $info['sftp'] = [
'title' => t('SFTP (Secure FTP)'),
'class' => 'Drupal\Core\FileTransfer\SFTP',
'weight' => 10,
- );
+ ];
return $info;
}
diff --git a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php
index 3617a63c9e2..7cb0c540c77 100644
--- a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php
+++ b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php
@@ -26,7 +26,7 @@ class FTPExtension extends FTP implements ChmodInterface {
*/
protected function copyFileJailed($source, $destination) {
if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) {
- throw new FileTransferException("Cannot move @source to @destination", NULL, array("@source" => $source, "@destination" => $destination));
+ throw new FileTransferException("Cannot move @source to @destination", NULL, ["@source" => $source, "@destination" => $destination]);
}
}
@@ -35,7 +35,7 @@ class FTPExtension extends FTP implements ChmodInterface {
*/
protected function createDirectoryJailed($directory) {
if (!ftp_mkdir($this->connection, $directory)) {
- throw new FileTransferException("Cannot create directory @directory", NULL, array("@directory" => $directory));
+ throw new FileTransferException("Cannot create directory @directory", NULL, ["@directory" => $directory]);
}
}
@@ -45,11 +45,11 @@ class FTPExtension extends FTP implements ChmodInterface {
protected function removeDirectoryJailed($directory) {
$pwd = ftp_pwd($this->connection);
if (!ftp_chdir($this->connection, $directory)) {
- throw new FileTransferException("Unable to change to directory @directory", NULL, array('@directory' => $directory));
+ throw new FileTransferException("Unable to change to directory @directory", NULL, ['@directory' => $directory]);
}
$list = @ftp_nlist($this->connection, '.');
if (!$list) {
- $list = array();
+ $list = [];
}
foreach ($list as $item) {
if ($item == '.' || $item == '..') {
@@ -65,7 +65,7 @@ class FTPExtension extends FTP implements ChmodInterface {
}
ftp_chdir($this->connection, $pwd);
if (!ftp_rmdir($this->connection, $directory)) {
- throw new FileTransferException("Unable to remove to directory @directory", NULL, array('@directory' => $directory));
+ throw new FileTransferException("Unable to remove to directory @directory", NULL, ['@directory' => $directory]);
}
}
@@ -74,7 +74,7 @@ class FTPExtension extends FTP implements ChmodInterface {
*/
protected function removeFileJailed($destination) {
if (!ftp_delete($this->connection, $destination)) {
- throw new FileTransferException("Unable to remove to file @file", NULL, array('@file' => $destination));
+ throw new FileTransferException("Unable to remove to file @file", NULL, ['@file' => $destination]);
}
}
@@ -103,7 +103,7 @@ class FTPExtension extends FTP implements ChmodInterface {
*/
function chmodJailed($path, $mode, $recursive) {
if (!ftp_chmod($this->connection, $mode, $path)) {
- throw new FileTransferException("Unable to set permissions on %file", NULL, array('%file' => $path));
+ throw new FileTransferException("Unable to set permissions on %file", NULL, ['%file' => $path]);
}
if ($this->isDirectory($path) && $recursive) {
$filelist = @ftp_nlist($this->connection, $path);
diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php
index dbe2559c0f9..a3cf6781e00 100644
--- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php
+++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php
@@ -210,7 +210,7 @@ abstract class FileTransfer {
$full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail)));
$full_path = $this->fixRemotePath($full_path, FALSE);
if ($full_jail !== $full_path) {
- throw new FileTransferException('@directory is outside of the @jail', NULL, array('@directory' => $path, '@jail' => $this->jail));
+ throw new FileTransferException('@directory is outside of the @jail', NULL, ['@directory' => $path, '@jail' => $this->jail]);
}
}
@@ -388,30 +388,30 @@ abstract class FileTransfer {
* An array that contains a Form API definition.
*/
public function getSettingsForm() {
- $form['username'] = array(
+ $form['username'] = [
'#type' => 'textfield',
'#title' => t('Username'),
- );
- $form['password'] = array(
+ ];
+ $form['password'] = [
'#type' => 'password',
'#title' => t('Password'),
'#description' => t('Your password is not saved in the database and is only used to establish a connection.'),
- );
- $form['advanced'] = array(
+ ];
+ $form['advanced'] = [
'#type' => 'details',
'#title' => t('Advanced settings'),
- );
- $form['advanced']['hostname'] = array(
+ ];
+ $form['advanced']['hostname'] = [
'#type' => 'textfield',
'#title' => t('Host'),
'#default_value' => 'localhost',
'#description' => t('The connection will be created between your web server and the machine hosting the web server files. In the vast majority of cases, this will be the same machine, and "localhost" is correct.'),
- );
- $form['advanced']['port'] = array(
+ ];
+ $form['advanced']['port'] = [
'#type' => 'textfield',
'#title' => t('Port'),
'#default_value' => NULL,
- );
+ ];
return $form;
}
diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransferException.php b/core/lib/Drupal/Core/FileTransfer/FileTransferException.php
index 15e657012a8..f8d0d07f406 100644
--- a/core/lib/Drupal/Core/FileTransfer/FileTransferException.php
+++ b/core/lib/Drupal/Core/FileTransfer/FileTransferException.php
@@ -24,7 +24,7 @@ class FileTransferException extends \RuntimeException {
* @param array $arguments
* Arguments to be used in this exception.
*/
- function __construct($message, $code = 0, $arguments = array()) {
+ function __construct($message, $code = 0, $arguments = []) {
parent::__construct($message, $code);
$this->arguments = $arguments;
}
diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php
index 647463aadc7..2adbd1f0f0b 100644
--- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php
+++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php
@@ -51,37 +51,37 @@ class FileTransferAuthorizeForm extends FormBase {
// Get all the available ways to transfer files.
if (empty($_SESSION['authorize_filetransfer_info'])) {
drupal_set_message($this->t('Unable to continue, no available methods of file transfer'), 'error');
- return array();
+ return [];
}
$available_backends = $_SESSION['authorize_filetransfer_info'];
if (!$this->getRequest()->isSecure()) {
- $form['information']['https_warning'] = array(
+ $form['information']['https_warning'] = [
'#prefix' => '<div class="messages messages--error">',
- '#markup' => $this->t('WARNING: You are not using an encrypted connection, so your password will be sent in plain text. <a href=":https-link">Learn more</a>.', array(':https-link' => 'https://www.drupal.org/https-information')),
+ '#markup' => $this->t('WARNING: You are not using an encrypted connection, so your password will be sent in plain text. <a href=":https-link">Learn more</a>.', [':https-link' => 'https://www.drupal.org/https-information']),
'#suffix' => '</div>',
- );
+ ];
}
// Decide on a default backend.
- $authorize_filetransfer_default = $form_state->getValue(array('connection_settings', 'authorize_filetransfer_default'));
+ $authorize_filetransfer_default = $form_state->getValue(['connection_settings', 'authorize_filetransfer_default']);
if (!$authorize_filetransfer_default) {
$authorize_filetransfer_default = key($available_backends);
}
- $form['information']['main_header'] = array(
+ $form['information']['main_header'] = [
'#prefix' => '<h3>',
'#markup' => $this->t('To continue, provide your server connection details'),
'#suffix' => '</h3>',
- );
+ ];
$form['connection_settings']['#tree'] = TRUE;
- $form['connection_settings']['authorize_filetransfer_default'] = array(
+ $form['connection_settings']['authorize_filetransfer_default'] = [
'#type' => 'select',
'#title' => $this->t('Connection method'),
'#default_value' => $authorize_filetransfer_default,
'#weight' => -10,
- );
+ ];
/*
* Here we create two submit buttons. For a JS enabled client, they will
@@ -90,46 +90,46 @@ class FileTransferAuthorizeForm extends FormBase {
* what filetransfer type to use, and submit_process on the second one (which
* leads to the actual operation).
*/
- $form['submit_connection'] = array(
+ $form['submit_connection'] = [
'#prefix' => "<br style='clear:both'/>",
'#name' => 'enter_connection_settings',
'#type' => 'submit',
'#value' => $this->t('Enter connection settings'),
'#weight' => 100,
- );
+ ];
- $form['submit_process'] = array(
+ $form['submit_process'] = [
'#name' => 'process_updates',
'#type' => 'submit',
'#value' => $this->t('Continue'),
'#weight' => 100,
- );
+ ];
// Build a container for each connection type.
foreach ($available_backends as $name => $backend) {
$form['connection_settings']['authorize_filetransfer_default']['#options'][$name] = $backend['title'];
- $form['connection_settings'][$name] = array(
+ $form['connection_settings'][$name] = [
'#type' => 'container',
- '#attributes' => array('class' => array("filetransfer-$name", 'filetransfer')),
- '#states' => array(
- 'visible' => array(
- 'select[name="connection_settings[authorize_filetransfer_default]"]' => array('value' => $name),
- ),
- ),
- );
+ '#attributes' => ['class' => ["filetransfer-$name", 'filetransfer']],
+ '#states' => [
+ 'visible' => [
+ 'select[name="connection_settings[authorize_filetransfer_default]"]' => ['value' => $name],
+ ],
+ ],
+ ];
// We can't use #prefix on the container itself since then the header won't
// be hidden and shown when the containers are being manipulated via JS.
- $form['connection_settings'][$name]['header'] = array(
- '#markup' => '<h4>' . $this->t('@backend connection settings', array('@backend' => $backend['title'])) . '</h4>',
- );
+ $form['connection_settings'][$name]['header'] = [
+ '#markup' => '<h4>' . $this->t('@backend connection settings', ['@backend' => $backend['title']]) . '</h4>',
+ ];
$form['connection_settings'][$name] += $this->addConnectionSettings($name);
// Start non-JS code.
- if ($form_state->getValue(array('connection_settings', 'authorize_filetransfer_default')) == $name) {
+ if ($form_state->getValue(['connection_settings', 'authorize_filetransfer_default']) == $name) {
// Change the submit button to the submit_process one.
- $form['submit_process']['#attributes'] = array();
+ $form['submit_process']['#attributes'] = [];
unset($form['submit_connection']);
// Activate the proper filetransfer settings form.
@@ -138,13 +138,13 @@ class FileTransferAuthorizeForm extends FormBase {
$form['connection_settings']['authorize_filetransfer_default']['#disabled'] = TRUE;
// Create a button for changing the type of connection.
- $form['connection_settings']['change_connection_type'] = array(
+ $form['connection_settings']['change_connection_type'] = [
'#name' => 'change_connection_type',
'#type' => 'submit',
'#value' => $this->t('Change connection type'),
'#weight' => -5,
- '#attributes' => array('class' => array('filetransfer-change-connection-type')),
- );
+ '#attributes' => ['class' => ['filetransfer-change-connection-type']],
+ ];
}
// End non-JS code.
}
@@ -166,17 +166,17 @@ class FileTransferAuthorizeForm extends FormBase {
$filetransfer = $this->getFiletransfer($backend, $form_connection_settings[$backend]);
try {
if (!$filetransfer) {
- throw new \Exception($this->t('The connection protocol %backend does not exist.', array('%backend' => $backend)));
+ throw new \Exception($this->t('The connection protocol %backend does not exist.', ['%backend' => $backend]));
}
$filetransfer->connect();
}
catch (\Exception $e) {
// The format of this error message is similar to that used on the
// database connection form in the installer.
- $form_state->setErrorByName('connection_settings', $this->t('Failed to connect to the server. The server reports the following message: <p class="error">@message</p> For more help installing or updating code on your server, see the <a href=":handbook_url">handbook</a>.', array(
+ $form_state->setErrorByName('connection_settings', $this->t('Failed to connect to the server. The server reports the following message: <p class="error">@message</p> For more help installing or updating code on your server, see the <a href=":handbook_url">handbook</a>.', [
'@message' => $e->getMessage(),
':handbook_url' => 'https://www.drupal.org/documentation/install/modules-themes',
- )));
+ ]));
}
}
}
@@ -218,7 +218,7 @@ class FileTransferAuthorizeForm extends FormBase {
case 'change_connection_type':
$form_state->setRebuild();
- $form_state->unsetValue(array('connection_settings', 'authorize_filetransfer_default'));
+ $form_state->unsetValue(['connection_settings', 'authorize_filetransfer_default']);
break;
}
}
@@ -235,7 +235,7 @@ class FileTransferAuthorizeForm extends FormBase {
* An instantiated FileTransfer object for the requested method and settings,
* or FALSE if there was an error finding or instantiating it.
*/
- protected function getFiletransfer($backend, $settings = array()) {
+ protected function getFiletransfer($backend, $settings = []) {
$filetransfer = FALSE;
if (!empty($_SESSION['authorize_filetransfer_info'][$backend])) {
$backend_info = $_SESSION['authorize_filetransfer_info'][$backend];
@@ -258,8 +258,8 @@ class FileTransferAuthorizeForm extends FormBase {
* @see hook_filetransfer_backends()
*/
protected function addConnectionSettings($backend) {
- $defaults = array();
- $form = array();
+ $defaults = [];
+ $form = [];
// Create an instance of the file transfer class to get its settings form.
$filetransfer = $this->getFiletransfer($backend);
@@ -320,7 +320,7 @@ class FileTransferAuthorizeForm extends FormBase {
unset($_SESSION['authorize_operation']);
require_once $operation['file'];
- return call_user_func_array($operation['callback'], array_merge(array($filetransfer), $operation['arguments']));
+ return call_user_func_array($operation['callback'], array_merge([$filetransfer], $operation['arguments']));
}
}
diff --git a/core/lib/Drupal/Core/FileTransfer/Local.php b/core/lib/Drupal/Core/FileTransfer/Local.php
index e6879316d8f..9320f4a3a1d 100644
--- a/core/lib/Drupal/Core/FileTransfer/Local.php
+++ b/core/lib/Drupal/Core/FileTransfer/Local.php
@@ -26,7 +26,7 @@ class Local extends FileTransfer implements ChmodInterface {
*/
protected function copyFileJailed($source, $destination) {
if (@!copy($source, $destination)) {
- throw new FileTransferException('Cannot copy %source to %destination.', NULL, array('%source' => $source, '%destination' => $destination));
+ throw new FileTransferException('Cannot copy %source to %destination.', NULL, ['%source' => $source, '%destination' => $destination]);
}
}
@@ -35,7 +35,7 @@ class Local extends FileTransfer implements ChmodInterface {
*/
protected function createDirectoryJailed($directory) {
if (!is_dir($directory) && @!mkdir($directory, 0777, TRUE)) {
- throw new FileTransferException('Cannot create directory %directory.', NULL, array('%directory' => $directory));
+ throw new FileTransferException('Cannot create directory %directory.', NULL, ['%directory' => $directory]);
}
}
@@ -45,22 +45,22 @@ class Local extends FileTransfer implements ChmodInterface {
protected function removeDirectoryJailed($directory) {
if (!is_dir($directory)) {
// Programmer error assertion, not something we expect users to see.
- throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, array('%directory' => $directory));
+ throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, ['%directory' => $directory]);
}
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
if ($file->isDir()) {
if (@!drupal_rmdir($filename)) {
- throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $filename));
+ throw new FileTransferException('Cannot remove directory %directory.', NULL, ['%directory' => $filename]);
}
}
elseif ($file->isFile()) {
if (@!drupal_unlink($filename)) {
- throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $filename));
+ throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $filename]);
}
}
}
if (@!drupal_rmdir($directory)) {
- throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $directory));
+ throw new FileTransferException('Cannot remove directory %directory.', NULL, ['%directory' => $directory]);
}
}
@@ -69,7 +69,7 @@ class Local extends FileTransfer implements ChmodInterface {
*/
protected function removeFileJailed($file) {
if (@!drupal_unlink($file)) {
- throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $file));
+ throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $file]);
}
}
@@ -94,12 +94,12 @@ class Local extends FileTransfer implements ChmodInterface {
if ($recursive && is_dir($path)) {
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
if (@!chmod($filename, $mode)) {
- throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $filename));
+ throw new FileTransferException('Cannot chmod %path.', NULL, ['%path' => $filename]);
}
}
}
elseif (@!chmod($path, $mode)) {
- throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $path));
+ throw new FileTransferException('Cannot chmod %path.', NULL, ['%path' => $path]);
}
}
diff --git a/core/lib/Drupal/Core/FileTransfer/SSH.php b/core/lib/Drupal/Core/FileTransfer/SSH.php
index 8250c1641d5..256aaf4c635 100644
--- a/core/lib/Drupal/Core/FileTransfer/SSH.php
+++ b/core/lib/Drupal/Core/FileTransfer/SSH.php
@@ -24,7 +24,7 @@ class SSH extends FileTransfer implements ChmodInterface {
public function connect() {
$this->connection = @ssh2_connect($this->hostname, $this->port);
if (!$this->connection) {
- throw new FileTransferException('SSH Connection failed to @host:@port', NULL, array('@host' => $this->hostname, '@port' => $this->port));
+ throw new FileTransferException('SSH Connection failed to @host:@port', NULL, ['@host' => $this->hostname, '@port' => $this->port]);
}
if (!@ssh2_auth_password($this->connection, $this->username, $this->password)) {
throw new FileTransferException('The supplied username/password combination was not accepted.');
@@ -47,7 +47,7 @@ class SSH extends FileTransfer implements ChmodInterface {
*/
protected function copyFileJailed($source, $destination) {
if (!@ssh2_scp_send($this->connection, $source, $destination)) {
- throw new FileTransferException('Cannot copy @source_file to @destination_file.', NULL, array('@source' => $source, '@destination' => $destination));
+ throw new FileTransferException('Cannot copy @source_file to @destination_file.', NULL, ['@source' => $source, '@destination' => $destination]);
}
}
@@ -56,7 +56,7 @@ class SSH extends FileTransfer implements ChmodInterface {
*/
protected function copyDirectoryJailed($source, $destination) {
if (@!ssh2_exec($this->connection, 'cp -Rp ' . escapeshellarg($source) . ' ' . escapeshellarg($destination))) {
- throw new FileTransferException('Cannot copy directory @directory.', NULL, array('@directory' => $source));
+ throw new FileTransferException('Cannot copy directory @directory.', NULL, ['@directory' => $source]);
}
}
@@ -65,7 +65,7 @@ class SSH extends FileTransfer implements ChmodInterface {
*/
protected function createDirectoryJailed($directory) {
if (@!ssh2_exec($this->connection, 'mkdir ' . escapeshellarg($directory))) {
- throw new FileTransferException('Cannot create directory @directory.', NULL, array('@directory' => $directory));
+ throw new FileTransferException('Cannot create directory @directory.', NULL, ['@directory' => $directory]);
}
}
@@ -74,7 +74,7 @@ class SSH extends FileTransfer implements ChmodInterface {
*/
protected function removeDirectoryJailed($directory) {
if (@!ssh2_exec($this->connection, 'rm -Rf ' . escapeshellarg($directory))) {
- throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $directory));
+ throw new FileTransferException('Cannot remove @directory.', NULL, ['@directory' => $directory]);
}
}
@@ -83,7 +83,7 @@ class SSH extends FileTransfer implements ChmodInterface {
*/
protected function removeFileJailed($destination) {
if (!@ssh2_exec($this->connection, 'rm ' . escapeshellarg($destination))) {
- throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $destination));
+ throw new FileTransferException('Cannot remove @directory.', NULL, ['@directory' => $destination]);
}
}
@@ -103,7 +103,7 @@ class SSH extends FileTransfer implements ChmodInterface {
return FALSE;
}
else {
- throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path));
+ throw new FileTransferException('Cannot check @path.', NULL, ['@path' => $path]);
}
}
@@ -120,7 +120,7 @@ class SSH extends FileTransfer implements ChmodInterface {
return FALSE;
}
else {
- throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path));
+ throw new FileTransferException('Cannot check @path.', NULL, ['@path' => $path]);
}
}
@@ -130,7 +130,7 @@ class SSH extends FileTransfer implements ChmodInterface {
function chmodJailed($path, $mode, $recursive) {
$cmd = sprintf("chmod %s%o %s", $recursive ? '-R ' : '', $mode, escapeshellarg($path));
if (@!ssh2_exec($this->connection, $cmd)) {
- throw new FileTransferException('Cannot change permissions of @path.', NULL, array('@path' => $path));
+ throw new FileTransferException('Cannot change permissions of @path.', NULL, ['@path' => $path]);
}
}
diff --git a/core/lib/Drupal/Core/Flood/DatabaseBackend.php b/core/lib/Drupal/Core/Flood/DatabaseBackend.php
index 4b2f0d00c17..12e9102af0e 100644
--- a/core/lib/Drupal/Core/Flood/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Flood/DatabaseBackend.php
@@ -80,12 +80,12 @@ class DatabaseBackend implements FloodInterface {
*/
protected function doInsert($name, $window, $identifier) {
$this->connection->insert(static::TABLE_NAME)
- ->fields(array(
+ ->fields([
'event' => $name,
'identifier' => $identifier,
'timestamp' => REQUEST_TIME,
'expiration' => REQUEST_TIME + $window,
- ))
+ ])
->execute();
}
diff --git a/core/lib/Drupal/Core/Flood/MemoryBackend.php b/core/lib/Drupal/Core/Flood/MemoryBackend.php
index 5b3377e8d8d..ddb42bc4cd6 100644
--- a/core/lib/Drupal/Core/Flood/MemoryBackend.php
+++ b/core/lib/Drupal/Core/Flood/MemoryBackend.php
@@ -19,7 +19,7 @@ class MemoryBackend implements FloodInterface {
/**
* An array holding flood events, keyed by event name and identifier.
*/
- protected $events = array();
+ protected $events = [];
/**
* Construct the MemoryBackend.
diff --git a/core/lib/Drupal/Core/Form/ConfigFormBase.php b/core/lib/Drupal/Core/Form/ConfigFormBase.php
index fb508f85459..e7878a7db04 100644
--- a/core/lib/Drupal/Core/Form/ConfigFormBase.php
+++ b/core/lib/Drupal/Core/Form/ConfigFormBase.php
@@ -35,11 +35,11 @@ abstract class ConfigFormBase extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save configuration'),
'#button_type' => 'primary',
- );
+ ];
// By default, render the form using system-config-form.html.twig.
$form['#theme'] = 'system_config_form';
diff --git a/core/lib/Drupal/Core/Form/ConfirmFormBase.php b/core/lib/Drupal/Core/Form/ConfirmFormBase.php
index 6de9fdfcd6d..4214bfcabd1 100644
--- a/core/lib/Drupal/Core/Form/ConfirmFormBase.php
+++ b/core/lib/Drupal/Core/Form/ConfirmFormBase.php
@@ -42,15 +42,15 @@ abstract class ConfirmFormBase extends FormBase implements ConfirmFormInterface
$form['#title'] = $this->getQuestion();
$form['#attributes']['class'][] = 'confirmation';
- $form['description'] = array('#markup' => $this->getDescription());
- $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1);
+ $form['description'] = ['#markup' => $this->getDescription()];
+ $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->getConfirmText(),
'#button_type' => 'primary',
- );
+ ];
$form['actions']['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this->getRequest());
diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index 803b4f1c57a..c4a1fd266c3 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -496,7 +496,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
$callback = [$form_state->getFormObject(), 'buildForm'];
- $form = array();
+ $form = [];
// Assign a default CSS class name based on $form_id.
// This happens here and not in self::prepareForm() in order to allow the
// form constructor function to override or remove the default class.
@@ -509,7 +509,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// We need to pass $form_state by reference in order for forms to modify it,
// since call_user_func_array() requires that referenced variables are
// passed explicitly.
- $args = array_merge(array($form, &$form_state), $args);
+ $args = array_merge([$form, &$form_state], $args);
$form = call_user_func_array($callback, $args);
// If the form returns a response, skip subsequent page construction by
@@ -716,7 +716,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
if (!isset($form['#build_id'])) {
$form['#build_id'] = 'form-' . Crypt::randomBytesBase64();
}
- $form['form_build_id'] = array(
+ $form['form_build_id'] = [
'#type' => 'hidden',
'#value' => $form['#build_id'],
'#id' => $form['#build_id'],
@@ -724,8 +724,8 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// Form processing and validation requires this value, so ensure the
// submitted form value appears literally, regardless of custom #tree
// and #parents being set elsewhere.
- '#parents' => array('form_build_id'),
- );
+ '#parents' => ['form_build_id'],
+ ];
// Add a token, based on either #token or form_id, to any form displayed to
// authenticated users. This ensures that any submitted form was actually
@@ -748,14 +748,14 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
$placeholder = 'form_token_placeholder_' . Crypt::hashBase64($form_id);
$form['#token'] = $placeholder;
- $form['form_token'] = array(
+ $form['form_token'] = [
'#id' => Html::getUniqueId('edit-' . $form_id . '-form-token'),
'#type' => 'token',
'#default_value' => $placeholder,
// Form processing and validation requires this value, so ensure the
// submitted form value appears literally, regardless of custom #tree
// and #parents being set elsewhere.
- '#parents' => array('form_token'),
+ '#parents' => ['form_token'],
// Instead of setting an actual CSRF token, we've set the placeholder
// in form_token's #default_value and #placeholder. These will be
// replaced at the very last moment. This ensures forms with a CSRF
@@ -770,20 +770,20 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
'#cache' => [
'max-age' => 0,
],
- );
+ ];
}
}
if (isset($form_id)) {
- $form['form_id'] = array(
+ $form['form_id'] = [
'#type' => 'hidden',
'#value' => $form_id,
'#id' => Html::getUniqueId("edit-$form_id"),
// Form processing and validation requires this value, so ensure the
// submitted form value appears literally, regardless of custom #tree
// and #parents being set elsewhere.
- '#parents' => array('form_id'),
- );
+ '#parents' => ['form_id'],
+ ];
}
if (!isset($form['#id'])) {
$form['#id'] = Html::getUniqueId($form_id);
@@ -793,7 +793,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
}
$form += $this->elementInfo->getInfo('form');
- $form += array('#tree' => FALSE, '#parents' => array());
+ $form += ['#tree' => FALSE, '#parents' => []];
$form['#validate'][] = '::validateForm';
$form['#submit'][] = '::submitForm';
@@ -803,7 +803,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// is in #theme_wrappers. Therefore, the #theme function only has to care
// for rendering the inner form elements, not the form itself.
if (!isset($form['#theme'])) {
- $form['#theme'] = array($form_id);
+ $form['#theme'] = [$form_id];
if (isset($build_info['base_form_id'])) {
$form['#theme'][] = $build_info['base_form_id'];
}
@@ -811,7 +811,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// Invoke hook_form_alter(), hook_form_BASE_FORM_ID_alter(), and
// hook_form_FORM_ID_alter() implementations.
- $hooks = array('form');
+ $hooks = ['form'];
if (isset($build_info['base_form_id'])) {
$hooks[] = 'form_' . $build_info['base_form_id'];
}
@@ -901,13 +901,13 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
$element['#defaults_loaded'] = TRUE;
}
// Assign basic defaults common for all form elements.
- $element += array(
+ $element += [
'#required' => FALSE,
- '#attributes' => array(),
+ '#attributes' => [],
'#title_display' => 'before',
'#description_display' => 'after',
'#errors' => NULL,
- );
+ ];
// Special handling if we're on the top level form element.
if (isset($element['#type']) && $element['#type'] == 'form') {
@@ -949,7 +949,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
}
// All form elements should have an #array_parents property.
- $element['#array_parents'] = array();
+ $element['#array_parents'] = [];
}
if (!isset($element['#id'])) {
@@ -979,7 +979,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
if (isset($element['#process']) && !$element['#processed']) {
foreach ($element['#process'] as $callback) {
$complete_form = &$form_state->getCompleteForm();
- $element = call_user_func_array($form_state->prepareCallback($callback), array(&$element, &$form_state, &$complete_form));
+ $element = call_user_func_array($form_state->prepareCallback($callback), [&$element, &$form_state, &$complete_form]);
}
$element['#processed'] = TRUE;
}
@@ -1016,7 +1016,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// Make child elements inherit their parent's #disabled and #allow_focus
// values unless they specify their own.
- foreach (array('#disabled', '#allow_focus') as $property) {
+ foreach (['#disabled', '#allow_focus'] as $property) {
if (isset($element[$property]) && !isset($element[$key][$property])) {
$element[$key][$property] = $element[$property];
}
@@ -1026,7 +1026,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
if (!isset($element[$key]['#parents'])) {
// Check to see if a tree of child elements is present. If so,
// continue down the tree if required.
- $element[$key]['#parents'] = $element[$key]['#tree'] && $element['#tree'] ? array_merge($element['#parents'], array($key)) : array($key);
+ $element[$key]['#parents'] = $element[$key]['#tree'] && $element['#tree'] ? array_merge($element['#parents'], [$key]) : [$key];
}
// Ensure #array_parents follows the actual form structure.
$array_parents = $element['#array_parents'];
@@ -1050,7 +1050,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// after normal input parsing has been completed.
if (isset($element['#after_build']) && !isset($element['#after_build_done'])) {
foreach ($element['#after_build'] as $callback) {
- $element = call_user_func_array($form_state->prepareCallback($callback), array($element, &$form_state));
+ $element = call_user_func_array($form_state->prepareCallback($callback), [$element, &$form_state]);
}
$element['#after_build_done'] = TRUE;
}
@@ -1236,7 +1236,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// Skip all value callbacks except safe ones like text if the CSRF
// token was invalid.
if (!$form_state->hasInvalidToken() || $this->valueCallableIsSafe($value_callable)) {
- $element['#value'] = call_user_func_array($value_callable, array(&$element, $input, &$form_state));
+ $element['#value'] = call_user_func_array($value_callable, [&$element, $input, &$form_state]);
}
else {
$input = NULL;
@@ -1255,7 +1255,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
if (!isset($element['#value'])) {
// Call #type_value without a second argument to request default_value
// handling.
- $element['#value'] = call_user_func_array($value_callable, array(&$element, FALSE, &$form_state));
+ $element['#value'] = call_user_func_array($value_callable, [&$element, FALSE, &$form_state]);
// Final catch. If we haven't set a value yet, use the explicit default
// value. Avoid image buttons (which come with garbage value), so we
diff --git a/core/lib/Drupal/Core/Form/FormCache.php b/core/lib/Drupal/Core/Form/FormCache.php
index 13e54303235..7064e10fb95 100644
--- a/core/lib/Drupal/Core/Form/FormCache.php
+++ b/core/lib/Drupal/Core/Form/FormCache.php
@@ -156,7 +156,7 @@ class FormCache implements FormCacheInterface {
$build_info += ['files' => []];
foreach ($build_info['files'] as $file) {
if (is_array($file)) {
- $file += array('type' => 'inc', 'name' => $file['module']);
+ $file += ['type' => 'inc', 'name' => $file['module']];
$this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']);
}
elseif (file_exists($file)) {
diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php
index 33ca1fafba0..b78efb30d10 100644
--- a/core/lib/Drupal/Core/Form/FormState.php
+++ b/core/lib/Drupal/Core/Form/FormState.php
@@ -63,10 +63,10 @@ class FormState implements FormStateInterface {
*
* @var array
*/
- protected $build_info = array(
- 'args' => array(),
- 'files' => array(),
- );
+ protected $build_info = [
+ 'args' => [],
+ 'files' => [],
+ ];
/**
* Similar to self::$build_info, but pertaining to
@@ -76,7 +76,7 @@ class FormState implements FormStateInterface {
*
* @var array
*/
- protected $rebuild_info = array();
+ protected $rebuild_info = [];
/**
* Normally, after the entire form processing is completed and submit handlers
@@ -216,7 +216,7 @@ class FormState implements FormStateInterface {
*
* @var array
*/
- protected $values = array();
+ protected $values = [];
/**
* An associative array of form value keys to be removed by cleanValues().
@@ -348,7 +348,7 @@ class FormState implements FormStateInterface {
*
* @var array
*/
- protected $groups = array();
+ protected $groups = [];
/**
* This is not a special key, and no specific support is provided for it in
@@ -368,7 +368,7 @@ class FormState implements FormStateInterface {
*
* @var array
*/
- protected $storage = array();
+ protected $storage = [];
/**
* A list containing copies of all submit and button elements in the form.
@@ -377,7 +377,7 @@ class FormState implements FormStateInterface {
*
* @var array
*/
- protected $buttons = array();
+ protected $buttons = [];
/**
* Holds temporary data accessible during the current page request only.
@@ -413,7 +413,7 @@ class FormState implements FormStateInterface {
*
* @var array
*/
- protected $errors = array();
+ protected $errors = [];
/**
* Stores which errors should be limited during validation.
@@ -618,7 +618,7 @@ class FormState implements FormStateInterface {
* @see \Symfony\Component\HttpFoundation\Request::isMethodSafe()
*/
protected function isRequestMethodSafe() {
- return in_array($this->requestMethod, array('GET', 'HEAD'));
+ return in_array($this->requestMethod, ['GET', 'HEAD']);
}
/**
@@ -862,11 +862,11 @@ class FormState implements FormStateInterface {
if (!isset($build_info['files']["$module:$name.$type"])) {
// Only add successfully included files to the form state.
if ($result = $this->moduleLoadInclude($module, $type, $name)) {
- $build_info['files']["$module:$name.$type"] = array(
+ $build_info['files']["$module:$name.$type"] = [
'type' => $type,
'module' => $module,
'name' => $name,
- );
+ ];
$this->setBuildInfo($build_info);
return $result;
}
@@ -998,7 +998,7 @@ class FormState implements FormStateInterface {
/**
* {@inheritdoc}
*/
- public function setRedirect($route_name, array $route_parameters = array(), array $options = array()) {
+ public function setRedirect($route_name, array $route_parameters = [], array $options = []) {
$url = new Url($route_name, $route_parameters, $options);
return $this->setRedirectUrl($url);
}
@@ -1108,7 +1108,7 @@ class FormState implements FormStateInterface {
*/
public function getError(array $element) {
if ($errors = $this->getErrors()) {
- $parents = array();
+ $parents = [];
foreach ($element['#parents'] as $parent) {
$parents[] = $parent;
$key = implode('][', $parents);
diff --git a/core/lib/Drupal/Core/Form/FormStateInterface.php b/core/lib/Drupal/Core/Form/FormStateInterface.php
index b1e3f3bc02e..43b2d8ebf68 100644
--- a/core/lib/Drupal/Core/Form/FormStateInterface.php
+++ b/core/lib/Drupal/Core/Form/FormStateInterface.php
@@ -129,7 +129,7 @@ interface FormStateInterface {
*
* @see \Drupal\Core\Form\FormSubmitterInterface::redirectForm()
*/
- public function setRedirect($route_name, array $route_parameters = array(), array $options = array());
+ public function setRedirect($route_name, array $route_parameters = [], array $options = []);
/**
* Sets the redirect URL for the form.
diff --git a/core/lib/Drupal/Core/Form/FormSubmitter.php b/core/lib/Drupal/Core/Form/FormSubmitter.php
index a467924feca..4a4275ef8d0 100644
--- a/core/lib/Drupal/Core/Form/FormSubmitter.php
+++ b/core/lib/Drupal/Core/Form/FormSubmitter.php
@@ -104,11 +104,11 @@ class FormSubmitter implements FormSubmitterInterface {
// Some previous submit handler has set a batch. To ensure correct
// execution order, store the call in a special 'control' batch set.
// See _batch_next_set().
- $batch['sets'][] = array('form_submit' => $callback);
+ $batch['sets'][] = ['form_submit' => $callback];
$batch['has_form_submits'] = TRUE;
}
else {
- call_user_func_array($form_state->prepareCallback($callback), array(&$form, &$form_state));
+ call_user_func_array($form_state->prepareCallback($callback), [&$form, &$form_state]);
}
}
}
diff --git a/core/lib/Drupal/Core/Form/FormValidator.php b/core/lib/Drupal/Core/Form/FormValidator.php
index d4f3ee56401..8e976f5a860 100644
--- a/core/lib/Drupal/Core/Form/FormValidator.php
+++ b/core/lib/Drupal/Core/Form/FormValidator.php
@@ -80,7 +80,7 @@ class FormValidator implements FormValidatorInterface {
}
foreach ($handlers as $callback) {
- call_user_func_array($form_state->prepareCallback($callback), array(&$form, &$form_state));
+ call_user_func_array($form_state->prepareCallback($callback), [&$form, &$form_state]);
}
}
@@ -128,7 +128,7 @@ class FormValidator implements FormValidatorInterface {
$url = $this->requestStack->getCurrentRequest()->getRequestUri();
// Setting this error will cause the form to fail validation.
- $form_state->setErrorByName('form_token', $this->t('The form has become outdated. Copy any unsaved work in the form below and then <a href=":link">reload this page</a>.', array(':link' => $url)));
+ $form_state->setErrorByName('form_token', $this->t('The form has become outdated. Copy any unsaved work in the form below and then <a href=":link">reload this page</a>.', [':link' => $url]));
}
/**
@@ -149,7 +149,7 @@ class FormValidator implements FormValidatorInterface {
// so that only values that passed validation are left for submit callbacks.
$triggering_element = $form_state->getTriggeringElement();
if (isset($triggering_element['#limit_validation_errors']) && $triggering_element['#limit_validation_errors'] !== FALSE) {
- $values = array();
+ $values = [];
foreach ($triggering_element['#limit_validation_errors'] as $section) {
// If the section exists within $form_state->getValues(), even if the
// value is NULL, copy it to $values.
@@ -278,7 +278,7 @@ class FormValidator implements FormValidatorInterface {
elseif (isset($elements['#element_validate'])) {
foreach ($elements['#element_validate'] as $callback) {
$complete_form = &$form_state->getCompleteForm();
- call_user_func_array($form_state->prepareCallback($callback), array(&$elements, &$form_state, &$complete_form));
+ call_user_func_array($form_state->prepareCallback($callback), [&$elements, &$form_state, &$complete_form]);
}
}
@@ -295,7 +295,7 @@ class FormValidator implements FormValidatorInterface {
// form constructors are encouraged to set #title anyway, and then set
// #title_display to 'invisible'. This improves accessibility.
elseif (isset($elements['#title'])) {
- $form_state->setError($elements, $this->t('@name field is required.', array('@name' => $elements['#title'])));
+ $form_state->setError($elements, $this->t('@name field is required.', ['@name' => $elements['#title']]));
}
else {
$form_state->setError($elements);
@@ -330,7 +330,7 @@ class FormValidator implements FormValidatorInterface {
protected function performRequiredValidation(&$elements, FormStateInterface &$form_state) {
// Verify that the value is not longer than #maxlength.
if (isset($elements['#maxlength']) && Unicode::strlen($elements['#value']) > $elements['#maxlength']) {
- $form_state->setError($elements, $this->t('@name cannot be longer than %max characters but is currently %length characters long.', array('@name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => Unicode::strlen($elements['#value']))));
+ $form_state->setError($elements, $this->t('@name cannot be longer than %max characters but is currently %length characters long.', ['@name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => Unicode::strlen($elements['#value'])]));
}
if (isset($elements['#options']) && isset($elements['#value'])) {
@@ -341,11 +341,11 @@ class FormValidator implements FormValidatorInterface {
$options = $elements['#options'];
}
if (is_array($elements['#value'])) {
- $value = in_array($elements['#type'], array('checkboxes', 'tableselect')) ? array_keys($elements['#value']) : $elements['#value'];
+ $value = in_array($elements['#type'], ['checkboxes', 'tableselect']) ? array_keys($elements['#value']) : $elements['#value'];
foreach ($value as $v) {
if (!isset($options[$v])) {
$form_state->setError($elements, $this->t('An illegal choice has been detected. Please contact the site administrator.'));
- $this->logger->error('Illegal choice %choice in %name element.', array('%choice' => $v, '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']));
+ $this->logger->error('Illegal choice %choice in %name element.', ['%choice' => $v, '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']]);
}
}
}
@@ -364,7 +364,7 @@ class FormValidator implements FormValidatorInterface {
}
elseif (!isset($options[$elements['#value']])) {
$form_state->setError($elements, $this->t('An illegal choice has been detected. Please contact the site administrator.'));
- $this->logger->error('Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']));
+ $this->logger->error('Illegal choice %choice in %name element.', ['%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']]);
}
}
}
@@ -402,7 +402,7 @@ class FormValidator implements FormValidatorInterface {
// types, #limit_validation_errors defaults to FALSE, so that full
// validation is their default behavior.
elseif ($triggering_element && !isset($triggering_element['#limit_validation_errors']) && !$form_state->isSubmitted()) {
- return array();
+ return [];
}
// As an extra security measure, explicitly turn off error suppression if
// one of the above conditions wasn't met. Since this is also done at the
diff --git a/core/lib/Drupal/Core/Form/OptGroup.php b/core/lib/Drupal/Core/Form/OptGroup.php
index ac4e5fb0af0..2ba28bde9cc 100644
--- a/core/lib/Drupal/Core/Form/OptGroup.php
+++ b/core/lib/Drupal/Core/Form/OptGroup.php
@@ -21,7 +21,7 @@ class OptGroup {
* An array with all hierarchical elements flattened to a single array.
*/
public static function flattenOptions(array $array) {
- $options = array();
+ $options = [];
static::doFlattenOptions($array, $options);
return $options;
}
diff --git a/core/lib/Drupal/Core/Form/form.api.php b/core/lib/Drupal/Core/Form/form.api.php
index 701871f9299..fcf9c2eeb5f 100644
--- a/core/lib/Drupal/Core/Form/form.api.php
+++ b/core/lib/Drupal/Core/Form/form.api.php
@@ -73,7 +73,7 @@ function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
foreach ($result as $row) {
// Here we actually perform our processing on the current node.
- $node_storage->resetCache(array($row['nid']));
+ $node_storage->resetCache([$row['nid']]);
$node = $node_storage->load($row['nid']);
$node->value1 = $options1;
$node->value2 = $options2;
@@ -85,7 +85,7 @@ function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
// Update our progress information.
$context['sandbox']['progress']++;
$context['sandbox']['current_node'] = $node->nid;
- $context['message'] = t('Now processing %node', array('%node' => $node->title));
+ $context['message'] = t('Now processing %node', ['%node' => $node->title]);
}
// Inform the batch engine that we are not finished,
@@ -113,13 +113,13 @@ function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
function callback_batch_finished($success, $results, $operations) {
if ($success) {
// Here we do something meaningful with the results.
- $message = t("@count items were processed.", array(
+ $message = t("@count items were processed.", [
'@count' => count($results),
- ));
- $list = array(
+ ]);
+ $list = [
'#theme' => 'item_list',
'#items' => $results,
- );
+ ];
$message .= drupal_render($list);
drupal_set_message($message);
}
@@ -127,10 +127,10 @@ function callback_batch_finished($success, $results, $operations) {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
- $message = t('An error occurred while processing %error_operation with arguments: @arguments', array(
+ $message = t('An error occurred while processing %error_operation with arguments: @arguments', [
'%error_operation' => $error_operation[0],
'@arguments' => print_r($error_operation[1], TRUE)
- ));
+ ]);
drupal_set_message($message, 'error');
}
}
@@ -152,7 +152,7 @@ function callback_batch_finished($success, $results, $operations) {
*/
function hook_ajax_render_alter(array &$data) {
// Inject any new status messages into the content area.
- $status_messages = array('#type' => 'status_messages');
+ $status_messages = ['#type' => 'status_messages'];
$command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', \Drupal::service('renderer')->renderRoot($status_messages));
$data[] = $command->render();
}
@@ -201,12 +201,12 @@ function hook_ajax_render_alter(array &$data) {
function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
$upload_enabled_types = \Drupal::config('mymodule.settings')->get('upload_enabled_types');
- $form['workflow']['upload_' . $form['type']['#value']] = array(
+ $form['workflow']['upload_' . $form['type']['#value']] = [
'#type' => 'radios',
'#title' => t('Attachments'),
'#default_value' => in_array($form['type']['#value'], $upload_enabled_types) ? 1 : 0,
- '#options' => array(t('Disabled'), t('Enabled')),
- );
+ '#options' => [t('Disabled'), t('Enabled')],
+ ];
// Add a custom submit handler to save the array of types back to the config file.
$form['actions']['submit']['#submit'][] = 'mymodule_upload_enabled_types_submit';
}
@@ -248,11 +248,11 @@ function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $f
// registration form.
// Add a checkbox to registration form about agreeing to terms of use.
- $form['terms_of_use'] = array(
+ $form['terms_of_use'] = [
'#type' => 'checkbox',
'#title' => t("I agree with the website's terms and conditions."),
'#required' => TRUE,
- );
+ ];
}
/**
@@ -298,11 +298,11 @@ function hook_form_BASE_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterfa
// node form, regardless of node type.
// Add a checkbox to the node form about agreeing to terms of use.
- $form['terms_of_use'] = array(
+ $form['terms_of_use'] = [
'#type' => 'checkbox',
'#title' => t("I agree with the website's terms and conditions."),
'#required' => TRUE,
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php b/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php
index 59751c06bfd..3aa0490f4fe 100644
--- a/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php
+++ b/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php
@@ -57,7 +57,7 @@ class TrustedHostsRequestFactory {
* @return \Symfony\Component\HttpFoundation\Request
* A new request object.
*/
- public function createRequest(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = NULL) {
+ public function createRequest(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = NULL) {
if (empty($server['HTTP_HOST']) || ($server['HTTP_HOST'] === 'localhost' && $this->host !== 'localhost')) {
$server['HTTP_HOST'] = $this->host;
}
diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php
index 42cdc92f811..e4c787632f5 100644
--- a/core/lib/Drupal/Core/Image/Image.php
+++ b/core/lib/Drupal/Core/Image/Image.php
@@ -139,7 +139,7 @@ class Image implements ImageInterface {
/**
* {@inheritdoc}
*/
- public function apply($operation, array $arguments = array()) {
+ public function apply($operation, array $arguments = []) {
return $this->getToolkit()->apply($operation, $arguments);
}
@@ -147,56 +147,56 @@ class Image implements ImageInterface {
* {@inheritdoc}
*/
public function createNew($width, $height, $extension = 'png', $transparent_color = '#ffffff') {
- return $this->apply('create_new', array('width' => $width, 'height' => $height, 'extension' => $extension, 'transparent_color' => $transparent_color));
+ return $this->apply('create_new', ['width' => $width, 'height' => $height, 'extension' => $extension, 'transparent_color' => $transparent_color]);
}
/**
* {@inheritdoc}
*/
public function convert($extension) {
- return $this->apply('convert', array('extension' => $extension));
+ return $this->apply('convert', ['extension' => $extension]);
}
/**
* {@inheritdoc}
*/
public function crop($x, $y, $width, $height = NULL) {
- return $this->apply('crop', array('x' => $x, 'y' => $y, 'width' => $width, 'height' => $height));
+ return $this->apply('crop', ['x' => $x, 'y' => $y, 'width' => $width, 'height' => $height]);
}
/**
* {@inheritdoc}
*/
public function desaturate() {
- return $this->apply('desaturate', array());
+ return $this->apply('desaturate', []);
}
/**
* {@inheritdoc}
*/
public function resize($width, $height) {
- return $this->apply('resize', array('width' => $width, 'height' => $height));
+ return $this->apply('resize', ['width' => $width, 'height' => $height]);
}
/**
* {@inheritdoc}
*/
public function rotate($degrees, $background = NULL) {
- return $this->apply('rotate', array('degrees' => $degrees, 'background' => $background));
+ return $this->apply('rotate', ['degrees' => $degrees, 'background' => $background]);
}
/**
* {@inheritdoc}
*/
public function scaleAndCrop($width, $height) {
- return $this->apply('scale_and_crop', array('width' => $width, 'height' => $height));
+ return $this->apply('scale_and_crop', ['width' => $width, 'height' => $height]);
}
/**
* {@inheritdoc}
*/
public function scale($width, $height = NULL, $upscale = FALSE) {
- return $this->apply('scale', array('width' => $width, 'height' => $height, 'upscale' => $upscale));
+ return $this->apply('scale', ['width' => $width, 'height' => $height, 'upscale' => $upscale]);
}
/**
diff --git a/core/lib/Drupal/Core/Image/ImageInterface.php b/core/lib/Drupal/Core/Image/ImageInterface.php
index 9e112c67ea1..29d092a7368 100644
--- a/core/lib/Drupal/Core/Image/ImageInterface.php
+++ b/core/lib/Drupal/Core/Image/ImageInterface.php
@@ -91,7 +91,7 @@ interface ImageInterface {
* @return bool
* TRUE on success, FALSE on failure.
*/
- public function apply($operation, array $arguments = array());
+ public function apply($operation, array $arguments = []);
/**
* Closes the image and saves the changes to a file.
diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php
index 0c7eb7dff9b..72f3d29256d 100644
--- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php
@@ -100,7 +100,7 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf
* {@inheritdoc}
*/
public function getRequirements() {
- return array();
+ return [];
}
/**
@@ -119,17 +119,17 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf
/**
* {@inheritdoc}
*/
- public function apply($operation, array $arguments = array()) {
+ public function apply($operation, array $arguments = []) {
try {
// Get the plugin to use for the operation and apply the operation.
return $this->getToolkitOperation($operation)->apply($arguments);
}
catch (PluginNotFoundException $e) {
- $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", array('@toolkit' => $this->getPluginId(), '@operation' => $operation));
+ $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", ['@toolkit' => $this->getPluginId(), '@operation' => $operation]);
return FALSE;
}
catch (\InvalidArgumentException $e) {
- $this->logger->warning($e->getMessage(), array());
+ $this->logger->warning($e->getMessage(), []);
return FALSE;
}
}
diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php
index f84131529fe..51867f4c3ff 100644
--- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php
@@ -169,6 +169,6 @@ interface ImageToolkitInterface extends ContainerFactoryPluginInterface, PluginI
* @return bool
* TRUE if the operation was performed successfully, FALSE otherwise.
*/
- public function apply($operation, array $arguments = array());
+ public function apply($operation, array $arguments = []);
}
diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php
index 1c63807c7b6..d53364704fe 100644
--- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php
@@ -87,7 +87,7 @@ class ImageToolkitManager extends DefaultPluginManager {
// Use plugin system to get list of available toolkits.
$toolkits = $this->getDefinitions();
- $output = array();
+ $output = [];
foreach ($toolkits as $id => $definition) {
// Only allow modules that aren't marked as unavailable.
if (call_user_func($definition['class'] . '::isAvailable')) {
diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php
index 2a1e61ec30e..c9a93ffe4d3 100644
--- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php
@@ -103,7 +103,7 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool
*/
protected function prepareArguments(array $arguments) {
foreach ($this->arguments() as $id => $argument) {
- $argument += array('required' => TRUE);
+ $argument += ['required' => TRUE];
// Check if the argument is required and, if so, has been provided.
if ($argument['required']) {
if (!array_key_exists($id, $arguments)) {
diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php
index b3a3e757129..5fc434ca1e3 100644
--- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php
@@ -91,7 +91,7 @@ class ImageToolkitOperationManager extends DefaultPluginManager implements Image
return $this->getToolkitOperationPluginId($base_toolkit, $operation);
}
- $message = SafeMarkup::format("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", array('@toolkit' => $toolkit_id, '@operation' => $operation));
+ $message = SafeMarkup::format("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", ['@toolkit' => $toolkit_id, '@operation' => $operation]);
throw new PluginNotFoundException($toolkit_id . '.' . $operation, $message);
}
else {
@@ -106,7 +106,7 @@ class ImageToolkitOperationManager extends DefaultPluginManager implements Image
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array(), ImageToolkitInterface $toolkit = NULL) {
+ public function createInstance($plugin_id, array $configuration = [], ImageToolkitInterface $toolkit = NULL) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
return new $plugin_class($configuration, $plugin_id, $plugin_definition, $toolkit, $this->logger);
@@ -117,7 +117,7 @@ class ImageToolkitOperationManager extends DefaultPluginManager implements Image
*/
public function getToolkitOperation(ImageToolkitInterface $toolkit, $operation) {
$plugin_id = $this->getToolkitOperationPluginId($toolkit, $operation);
- return $this->createInstance($plugin_id, array(), $toolkit);
+ return $this->createInstance($plugin_id, [], $toolkit);
}
}
diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
index ed0cfac9844..ca00d0be81f 100644
--- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
+++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
@@ -23,10 +23,10 @@ class AlreadyInstalledException extends InstallerException {
<li>To start over, you must empty your existing database and copy <em>default.settings.php</em> over <em>settings.php</em>.</li>
<li>To upgrade an existing installation, proceed to the <a href=":update-url">update script</a>.</li>
<li>View your <a href=":base-url">existing site</a>.</li>
-</ul>', array(
+</ul>', [
':base-url' => $GLOBALS['base_url'],
':update-url' => $GLOBALS['base_path'] . 'update.php',
- ));
+ ]);
parent::__construct($message, $title);
}
diff --git a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php
index 9342f5cf740..686b1a2c343 100644
--- a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php
@@ -31,11 +31,11 @@ class SelectLanguageForm extends FormBase {
$files = $install_state['translations'];
}
else {
- $files = array();
+ $files = [];
}
$standard_languages = LanguageManager::getStandardLanguageList();
- $select_options = array();
- $browser_options = array();
+ $select_options = [];
+ $browser_options = [];
$form['#title'] = 'Choose language';
@@ -57,32 +57,32 @@ class SelectLanguageForm extends FormBase {
asort($select_options);
$request = Request::createFromGlobals();
$browser_langcode = UserAgent::getBestMatchingLangcode($request->server->get('HTTP_ACCEPT_LANGUAGE'), $browser_options);
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'select',
'#title' => 'Choose language',
'#title_display' => 'invisible',
'#options' => $select_options,
// Use the browser detected language as default or English if nothing found.
'#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en',
- );
- $link_to_english = install_full_redirect_url(array('parameters' => array('langcode' => 'en')));
- $form['help'] = array(
+ ];
+ $link_to_english = install_full_redirect_url(['parameters' => ['langcode' => 'en']]);
+ $form['help'] = [
'#type' => 'item',
// #markup is XSS admin filtered which ensures unsafe protocols will be
// removed from the url.
'#markup' => '<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>. If you do not want this, select <a href="' . $link_to_english . '">English</a>.</p>',
- '#states' => array(
- 'invisible' => array(
- 'select[name="langcode"]' => array('value' => 'en'),
- ),
- ),
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ '#states' => [
+ 'invisible' => [
+ 'select[name="langcode"]' => ['value' => 'en'],
+ ],
+ ],
+ ];
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Save and continue',
'#button_type' => 'primary',
- );
+ ];
return $form;
}
diff --git a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
index 7ccdf2759f9..679e6db00b2 100644
--- a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
@@ -23,8 +23,8 @@ class SelectProfileForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) {
$form['#title'] = $this->t('Select an installation profile');
- $profiles = array();
- $names = array();
+ $profiles = [];
+ $names = [];
foreach ($install_state['profiles'] as $profile) {
/** @var $profile \Drupal\Core\Extension\Extension */
$details = install_profile_info($profile->getName());
@@ -49,34 +49,34 @@ class SelectProfileForm extends FormBase {
// any non-core profiles rather than including it with them alphabetically,
// since the other profiles might be intended to group together in a
// particular way.
- $names = array('minimal' => $names['minimal']) + $names;
+ $names = ['minimal' => $names['minimal']] + $names;
}
if (isset($names['standard'])) {
// If the default ("Standard") core profile is present, put it at the very
// top of the list. This profile will have its radio button pre-selected,
// so we want it to always appear at the top.
- $names = array('standard' => $names['standard']) + $names;
+ $names = ['standard' => $names['standard']] + $names;
}
// The profile name and description are extracted for translation from the
// .info file, so we can use $this->t() on them even though they are dynamic
// data at this point.
- $form['profile'] = array(
+ $form['profile'] = [
'#type' => 'radios',
'#title' => $this->t('Select an installation profile'),
'#title_display' => 'invisible',
- '#options' => array_map(array($this, 't'), $names),
+ '#options' => array_map([$this, 't'], $names),
'#default_value' => 'standard',
- );
+ ];
foreach (array_keys($names) as $profile_name) {
$form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : '';
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
index 8720b00a317..c28b7f8fd49 100644
--- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
@@ -132,7 +132,7 @@ class SiteConfigureForm extends ConfigFormBase {
// successfully.)
$post_params = $this->getRequest()->request->all();
if (empty($post_params) && (!drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
- drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions')), 'warning');
+ drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', ['%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions']), 'warning');
}
$form['#attached']['library'][] = 'system/drupal.system';
@@ -142,55 +142,55 @@ class SiteConfigureForm extends ConfigFormBase {
// work during installation.
$form['#attached']['drupalSettings']['copyFieldValue']['edit-site-mail'] = ['edit-account-mail'];
- $form['site_information'] = array(
+ $form['site_information'] = [
'#type' => 'fieldgroup',
'#title' => $this->t('Site information'),
- );
- $form['site_information']['site_name'] = array(
+ ];
+ $form['site_information']['site_name'] = [
'#type' => 'textfield',
'#title' => $this->t('Site name'),
'#required' => TRUE,
'#weight' => -20,
- );
- $form['site_information']['site_mail'] = array(
+ ];
+ $form['site_information']['site_mail'] = [
'#type' => 'email',
'#title' => $this->t('Site email address'),
'#default_value' => ini_get('sendmail_from'),
'#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."),
'#required' => TRUE,
'#weight' => -15,
- );
+ ];
- $form['admin_account'] = array(
+ $form['admin_account'] = [
'#type' => 'fieldgroup',
'#title' => $this->t('Site maintenance account'),
- );
- $form['admin_account']['account']['name'] = array(
+ ];
+ $form['admin_account']['account']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Username'),
'#maxlength' => USERNAME_MAX_LENGTH,
'#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."),
'#required' => TRUE,
- '#attributes' => array('class' => array('username')),
- );
- $form['admin_account']['account']['pass'] = array(
+ '#attributes' => ['class' => ['username']],
+ ];
+ $form['admin_account']['account']['pass'] = [
'#type' => 'password_confirm',
'#required' => TRUE,
'#size' => 25,
- );
+ ];
$form['admin_account']['account']['#tree'] = TRUE;
- $form['admin_account']['account']['mail'] = array(
+ $form['admin_account']['account']['mail'] = [
'#type' => 'email',
'#title' => $this->t('Email address'),
'#required' => TRUE,
- );
+ ];
- $form['regional_settings'] = array(
+ $form['regional_settings'] = [
'#type' => 'fieldgroup',
'#title' => $this->t('Regional settings'),
- );
+ ];
$countries = $this->countryManager->getList();
- $form['regional_settings']['site_default_country'] = array(
+ $form['regional_settings']['site_default_country'] = [
'#type' => 'select',
'#title' => $this->t('Default country'),
'#empty_value' => '',
@@ -198,8 +198,8 @@ class SiteConfigureForm extends ConfigFormBase {
'#options' => $countries,
'#description' => $this->t('Select the default country for the site.'),
'#weight' => 0,
- );
- $form['regional_settings']['date_default_timezone'] = array(
+ ];
+ $form['regional_settings']['date_default_timezone'] = [
'#type' => 'select',
'#title' => $this->t('Default time zone'),
// Use system timezone if set, but avoid throwing a warning in PHP >=5.4
@@ -207,37 +207,37 @@ class SiteConfigureForm extends ConfigFormBase {
'#options' => system_time_zones(),
'#description' => $this->t('By default, dates in this site will be displayed in the chosen time zone.'),
'#weight' => 5,
- '#attributes' => array('class' => array('timezone-detect')),
- );
+ '#attributes' => ['class' => ['timezone-detect']],
+ ];
- $form['update_notifications'] = array(
+ $form['update_notifications'] = [
'#type' => 'fieldgroup',
'#title' => $this->t('Update notifications'),
- '#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href=":drupal">Drupal.org</a>.', array(':drupal' => 'https://www.drupal.org')),
- );
- $form['update_notifications']['enable_update_status_module'] = array(
+ '#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href=":drupal">Drupal.org</a>.', [':drupal' => 'https://www.drupal.org']),
+ ];
+ $form['update_notifications']['enable_update_status_module'] = [
'#type' => 'checkbox',
'#title' => $this->t('Check for updates automatically'),
'#default_value' => 1,
- );
- $form['update_notifications']['enable_update_status_emails'] = array(
+ ];
+ $form['update_notifications']['enable_update_status_emails'] = [
'#type' => 'checkbox',
'#title' => $this->t('Receive email notifications'),
'#default_value' => 1,
- '#states' => array(
- 'visible' => array(
- 'input[name="enable_update_status_module"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ 'input[name="enable_update_status_module"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#weight' => 15,
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -246,7 +246,7 @@ class SiteConfigureForm extends ConfigFormBase {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
- if ($error = user_validate_name($form_state->getValue(array('account', 'name')))) {
+ if ($error = user_validate_name($form_state->getValue(['account', 'name']))) {
$form_state->setErrorByName('account][name', $error);
}
}
@@ -270,7 +270,7 @@ class SiteConfigureForm extends ConfigFormBase {
// Enable update.module if this option was selected.
$update_status_module = $form_state->getValue('enable_update_status_module');
if ($update_status_module) {
- $this->moduleInstaller->install(array('file', 'update'), FALSE);
+ $this->moduleInstaller->install(['file', 'update'], FALSE);
// Add the site maintenance account's email address to the list of
// addresses to be notified when updates are available, if selected.
@@ -278,7 +278,7 @@ class SiteConfigureForm extends ConfigFormBase {
if ($email_update_status_emails) {
// Reset the configuration factory so it is updated with the new module.
$this->resetConfigFactory();
- $this->config('update.settings')->set('notification.emails', array($account_values['mail']))->save(TRUE);
+ $this->config('update.settings')->set('notification.emails', [$account_values['mail']])->save(TRUE);
}
}
diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php
index f5d1c7fe506..5442d1542ef 100644
--- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php
@@ -97,15 +97,15 @@ class SiteSettingsForm extends FormBase {
// when JavaScript is enabled (see below).
else {
$default_driver = current($drivers_keys);
- $default_options = array();
+ $default_options = [];
}
- $form['driver'] = array(
+ $form['driver'] = [
'#type' => 'radios',
'#title' => $this->t('Database type'),
'#required' => TRUE,
'#default_value' => $default_driver,
- );
+ ];
if (count($drivers) == 1) {
$form['driver']['#disabled'] = TRUE;
}
@@ -115,31 +115,31 @@ class SiteSettingsForm extends FormBase {
$form['driver']['#options'][$key] = $driver->name();
$form['settings'][$key] = $driver->getFormOptions($default_options);
- $form['settings'][$key]['#prefix'] = '<h2 class="js-hide">' . $this->t('@driver_name settings', array('@driver_name' => $driver->name())) . '</h2>';
+ $form['settings'][$key]['#prefix'] = '<h2 class="js-hide">' . $this->t('@driver_name settings', ['@driver_name' => $driver->name()]) . '</h2>';
$form['settings'][$key]['#type'] = 'container';
$form['settings'][$key]['#tree'] = TRUE;
- $form['settings'][$key]['advanced_options']['#parents'] = array($key);
- $form['settings'][$key]['#states'] = array(
- 'visible' => array(
- ':input[name=driver]' => array('value' => $key),
- )
- );
+ $form['settings'][$key]['advanced_options']['#parents'] = [$key];
+ $form['settings'][$key]['#states'] = [
+ 'visible' => [
+ ':input[name=driver]' => ['value' => $key],
+ ]
+ ];
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['save'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['save'] = [
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#button_type' => 'primary',
- '#limit_validation_errors' => array(
- array('driver'),
- array($default_driver),
- ),
- '#submit' => array('::submitForm'),
- );
+ '#limit_validation_errors' => [
+ ['driver'],
+ [$default_driver],
+ ],
+ '#submit' => ['::submitForm'],
+ ];
- $form['errors'] = array();
- $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);
+ $form['errors'] = [];
+ $form['settings_file'] = ['#type' => 'value', '#value' => $settings_file];
return $form;
}
@@ -213,21 +213,21 @@ class SiteSettingsForm extends FormBase {
global $install_state;
// Update global settings array and save.
- $settings = array();
+ $settings = [];
$database = $form_state->get('database');
- $settings['databases']['default']['default'] = (object) array(
+ $settings['databases']['default']['default'] = (object) [
'value' => $database,
'required' => TRUE,
- );
- $settings['settings']['hash_salt'] = (object) array(
+ ];
+ $settings['settings']['hash_salt'] = (object) [
'value' => Crypt::randomBytesBase64(55),
'required' => TRUE,
- );
+ ];
// Remember the profile which was used.
- $settings['settings']['install_profile'] = (object) array(
+ $settings['settings']['install_profile'] = (object) [
'value' => $install_state['parameters']['profile'],
'required' => TRUE,
- );
+ ];
drupal_rewrite_settings($settings);
diff --git a/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php b/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php
index c2ec5ede472..a432f2389c7 100644
--- a/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php
+++ b/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php
@@ -17,7 +17,7 @@ class InstallerRouteBuilder extends RouteBuilder {
* @todo Convert installer steps into routes; add an installer.routing.yml.
*/
protected function getRouteDefinitions() {
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php
index 1ace991de83..48341492bdb 100644
--- a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php
+++ b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php
@@ -28,8 +28,8 @@ class InstallerServiceProvider implements ServiceProviderInterface, ServiceModif
// Replace services with in-memory implementations.
$definition = $container->getDefinition('cache_factory');
$definition->setClass('Drupal\Core\Cache\MemoryBackendFactory');
- $definition->setArguments(array());
- $definition->setMethodCalls(array());
+ $definition->setArguments([]);
+ $definition->setMethodCalls([]);
$container
->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory');
$container
diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
index aca4f31acda..bd96df2f208 100644
--- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
+++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php
@@ -61,19 +61,19 @@ class DatabaseStorage extends StorageBase {
* {@inheritdoc}
*/
public function has($key) {
- return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key', array(
+ return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key', [
':collection' => $this->collection,
':key' => $key,
- ))->fetchField();
+ ])->fetchField();
}
/**
* {@inheritdoc}
*/
public function getMultiple(array $keys) {
- $values = array();
+ $values = [];
try {
- $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE name IN ( :keys[] ) AND collection = :collection', array(':keys[]' => $keys, ':collection' => $this->collection))->fetchAllAssoc('name');
+ $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE name IN ( :keys[] ) AND collection = :collection', [':keys[]' => $keys, ':collection' => $this->collection])->fetchAllAssoc('name');
foreach ($keys as $key) {
if (isset($result[$key])) {
$values[$key] = $this->serializer->decode($result[$key]->value);
@@ -92,8 +92,8 @@ class DatabaseStorage extends StorageBase {
* {@inheritdoc}
*/
public function getAll() {
- $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection', array(':collection' => $this->collection));
- $values = array();
+ $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection', [':collection' => $this->collection]);
+ $values = [];
foreach ($result as $item) {
if ($item) {
@@ -108,11 +108,11 @@ class DatabaseStorage extends StorageBase {
*/
public function set($key, $value) {
$this->connection->merge($this->table)
- ->keys(array(
+ ->keys([
'name' => $key,
'collection' => $this->collection,
- ))
- ->fields(array('value' => $this->serializer->encode($value)))
+ ])
+ ->fields(['value' => $this->serializer->encode($value)])
->execute();
}
@@ -121,11 +121,11 @@ class DatabaseStorage extends StorageBase {
*/
public function setIfNotExists($key, $value) {
$result = $this->connection->merge($this->table)
- ->insertFields(array(
+ ->insertFields([
'collection' => $this->collection,
'name' => $key,
'value' => $this->serializer->encode($value),
- ))
+ ])
->condition('collection', $this->collection)
->condition('name', $key)
->execute();
@@ -137,7 +137,7 @@ class DatabaseStorage extends StorageBase {
*/
public function rename($key, $new_key) {
$this->connection->update($this->table)
- ->fields(array('name' => $new_key))
+ ->fields(['name' => $new_key])
->condition('collection', $this->collection)
->condition('name', $key)
->execute();
diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php
index 9f3b4284f32..8e487d18330 100644
--- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php
+++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php
@@ -34,11 +34,11 @@ class DatabaseStorageExpirable extends DatabaseStorage implements KeyValueStoreE
* {@inheritdoc}
*/
public function has($key) {
- return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key AND expire > :now', array(
+ return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key AND expire > :now', [
':collection' => $this->collection,
':key' => $key,
':now' => REQUEST_TIME,
- ))->fetchField();
+ ])->fetchField();
}
/**
@@ -47,12 +47,12 @@ class DatabaseStorageExpirable extends DatabaseStorage implements KeyValueStoreE
public function getMultiple(array $keys) {
$values = $this->connection->query(
'SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE expire > :now AND name IN ( :keys[] ) AND collection = :collection',
- array(
+ [
':now' => REQUEST_TIME,
':keys[]' => $keys,
':collection' => $this->collection,
- ))->fetchAllKeyed();
- return array_map(array($this->serializer, 'decode'), $values);
+ ])->fetchAllKeyed();
+ return array_map([$this->serializer, 'decode'], $values);
}
/**
@@ -61,11 +61,11 @@ class DatabaseStorageExpirable extends DatabaseStorage implements KeyValueStoreE
public function getAll() {
$values = $this->connection->query(
'SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND expire > :now',
- array(
+ [
':collection' => $this->collection,
':now' => REQUEST_TIME
- ))->fetchAllKeyed();
- return array_map(array($this->serializer, 'decode'), $values);
+ ])->fetchAllKeyed();
+ return array_map([$this->serializer, 'decode'], $values);
}
/**
@@ -73,14 +73,14 @@ class DatabaseStorageExpirable extends DatabaseStorage implements KeyValueStoreE
*/
function setWithExpire($key, $value, $expire) {
$this->connection->merge($this->table)
- ->keys(array(
+ ->keys([
'name' => $key,
'collection' => $this->collection,
- ))
- ->fields(array(
+ ])
+ ->fields([
'value' => $this->serializer->encode($value),
'expire' => REQUEST_TIME + $expire,
- ))
+ ])
->execute();
}
@@ -89,12 +89,12 @@ class DatabaseStorageExpirable extends DatabaseStorage implements KeyValueStoreE
*/
function setWithExpireIfNotExists($key, $value, $expire) {
$result = $this->connection->merge($this->table)
- ->insertFields(array(
+ ->insertFields([
'collection' => $this->collection,
'name' => $key,
'value' => $this->serializer->encode($value),
'expire' => REQUEST_TIME + $expire,
- ))
+ ])
->condition('collection', $this->collection)
->condition('name', $key)
->execute();
diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php
index 5670fe5b283..7815b8c1578 100644
--- a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php
+++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php
@@ -15,7 +15,7 @@ class KeyValueDatabaseExpirableFactory implements KeyValueExpirableFactoryInterf
*
* @var \Drupal\Core\KeyValueStore\DatabaseStorageExpirable[]
*/
- protected $storages = array();
+ protected $storages = [];
/**
* The serialization class to use.
diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php
index 9f6d28cc4bb..0801ca1f0a7 100644
--- a/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php
+++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php
@@ -37,7 +37,7 @@ class KeyValueFactory implements KeyValueFactoryInterface {
*
* @var array
*/
- protected $stores = array();
+ protected $stores = [];
/**
* var \Symfony\Component\DependencyInjection\ContainerInterface
@@ -50,7 +50,7 @@ class KeyValueFactory implements KeyValueFactoryInterface {
* @param array $options
* (optional) Collection-specific storage override options.
*/
- function __construct(ContainerInterface $container, array $options = array()) {
+ function __construct(ContainerInterface $container, array $options = []) {
$this->container = $container;
$this->options = $options;
}
diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php
index f1720264cc5..701e2bd9183 100644
--- a/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php
+++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php
@@ -12,7 +12,7 @@ class KeyValueMemoryFactory implements KeyValueFactoryInterface {
*
* @var array
*/
- protected $collections = array();
+ protected $collections = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php b/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php
index ea9e056c34d..d6a6ca91d40 100644
--- a/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php
+++ b/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php
@@ -12,7 +12,7 @@ class MemoryStorage extends StorageBase {
*
* @var array
*/
- protected $data = array();
+ protected $data = [];
/**
* {@inheritdoc}
@@ -95,7 +95,7 @@ class MemoryStorage extends StorageBase {
* {@inheritdoc}
*/
public function deleteAll() {
- $this->data = array();
+ $this->data = [];
}
}
diff --git a/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php b/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php
index 8e7ab531311..5ea8cbc9dc3 100644
--- a/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php
+++ b/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php
@@ -12,7 +12,7 @@ class NullStorageExpirable implements KeyValueStoreExpirableInterface {
*
* @var array
*/
- protected $data = array();
+ protected $data = [];
/**
* The name of the collection holding key and value pairs.
@@ -46,14 +46,14 @@ class NullStorageExpirable implements KeyValueStoreExpirableInterface {
* {@inheritdoc}
*/
public function getMultiple(array $keys) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function getAll() {
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/KeyValueStore/StorageBase.php b/core/lib/Drupal/Core/KeyValueStore/StorageBase.php
index ecdd08c5751..ad5e3b4a56f 100644
--- a/core/lib/Drupal/Core/KeyValueStore/StorageBase.php
+++ b/core/lib/Drupal/Core/KeyValueStore/StorageBase.php
@@ -32,7 +32,7 @@ abstract class StorageBase implements KeyValueStoreInterface {
* {@inheritdoc}
*/
public function get($key, $default = NULL) {
- $values = $this->getMultiple(array($key));
+ $values = $this->getMultiple([$key]);
return isset($values[$key]) ? $values[$key] : $default;
}
@@ -49,7 +49,7 @@ abstract class StorageBase implements KeyValueStoreInterface {
* {@inheritdoc}
*/
public function delete($key) {
- $this->deleteMultiple(array($key));
+ $this->deleteMultiple([$key]);
}
}
diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php
index abaad81d592..5c4068d0505 100644
--- a/core/lib/Drupal/Core/Language/Language.php
+++ b/core/lib/Drupal/Core/Language/Language.php
@@ -16,13 +16,13 @@ class Language implements LanguageInterface {
*
* @var array
*/
- public static $defaultValues = array(
+ public static $defaultValues = [
'id' => 'en',
'name' => 'English',
'direction' => self::DIRECTION_LTR,
'weight' => 0,
'locked' => FALSE,
- );
+ ];
// Properties within the Language are set up as the default language.
@@ -74,7 +74,7 @@ class Language implements LanguageInterface {
* An array of property values, keyed by property name, used to construct
* the language.
*/
- public function __construct(array $values = array()) {
+ public function __construct(array $values = []) {
// Set all the provided properties for the language.
foreach ($values as $key => $value) {
if (property_exists($this, $key)) {
diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php
index ef542171340..7f3ddc816bf 100644
--- a/core/lib/Drupal/Core/Language/LanguageManager.php
+++ b/core/lib/Drupal/Core/Language/LanguageManager.php
@@ -23,7 +23,7 @@ class LanguageManager implements LanguageManagerInterface {
*
* @see \Drupal\Core\Language\LanguageManager::getLanguages()
*/
- protected $languages = array();
+ protected $languages = [];
/**
* The default language object.
@@ -53,7 +53,7 @@ class LanguageManager implements LanguageManagerInterface {
* {@inheritdoc}
*/
public function getLanguageTypes() {
- return array(LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT, LanguageInterface::TYPE_URL);
+ return [LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT, LanguageInterface::TYPE_URL];
}
/**
@@ -77,21 +77,21 @@ class LanguageManager implements LanguageManagerInterface {
* hook_language_types_info().
*/
public function getDefinedLanguageTypesInfo() {
- $this->definedLanguageTypesInfo = array(
- LanguageInterface::TYPE_INTERFACE => array(
+ $this->definedLanguageTypesInfo = [
+ LanguageInterface::TYPE_INTERFACE => [
'name' => new TranslatableMarkup('Interface text'),
'description' => new TranslatableMarkup('Order of language detection methods for interface text. If a translation of interface text is available in the detected language, it will be displayed.'),
'locked' => TRUE,
- ),
- LanguageInterface::TYPE_CONTENT => array(
+ ],
+ LanguageInterface::TYPE_CONTENT => [
'name' => new TranslatableMarkup('Content'),
'description' => new TranslatableMarkup('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'),
'locked' => TRUE,
- ),
- LanguageInterface::TYPE_URL => array(
+ ],
+ LanguageInterface::TYPE_URL => [
'locked' => TRUE,
- ),
- );
+ ],
+ ];
return $this->definedLanguageTypesInfo;
}
@@ -127,7 +127,7 @@ class LanguageManager implements LanguageManagerInterface {
// The default language and locked languages comprise the full language
// list.
$default = $this->getDefaultLanguage();
- $languages = array($default->getId() => $default);
+ $languages = [$default->getId() => $default];
$languages += $this->getDefaultLockedLanguages($default->getWeight());
// Filter the full list of languages based on the value of $flags.
@@ -165,33 +165,33 @@ class LanguageManager implements LanguageManagerInterface {
if (empty($langcode)) {
return new TranslatableMarkup('Unknown');
}
- return new TranslatableMarkup('Unknown (@langcode)', array('@langcode' => $langcode));
+ return new TranslatableMarkup('Unknown (@langcode)', ['@langcode' => $langcode]);
}
/**
* {@inheritdoc}
*/
public function getDefaultLockedLanguages($weight = 0) {
- $languages = array();
+ $languages = [];
- $locked_language = array(
+ $locked_language = [
'default' => FALSE,
'locked' => TRUE,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
// This is called very early while initializing the language system. Prevent
// early t() calls by using the TranslatableMarkup.
- $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = new Language(array(
+ $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = new Language([
'id' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'name' => new TranslatableMarkup('Not specified'),
'weight' => ++$weight,
- ) + $locked_language);
+ ] + $locked_language);
- $languages[LanguageInterface::LANGCODE_NOT_APPLICABLE] = new Language(array(
+ $languages[LanguageInterface::LANGCODE_NOT_APPLICABLE] = new Language([
'id' => LanguageInterface::LANGCODE_NOT_APPLICABLE,
'name' => new TranslatableMarkup('Not applicable'),
'weight' => ++$weight,
- ) + $locked_language);
+ ] + $locked_language);
return $languages;
}
@@ -207,15 +207,15 @@ class LanguageManager implements LanguageManagerInterface {
/**
* {@inheritdoc}
*/
- public function getFallbackCandidates(array $context = array()) {
- return array(LanguageInterface::LANGCODE_DEFAULT);
+ public function getFallbackCandidates(array $context = []) {
+ return [LanguageInterface::LANGCODE_DEFAULT];
}
/**
* {@inheritdoc}
*/
public function getLanguageSwitchLinks($type, Url $url) {
- return array();
+ return [];
}
/**
@@ -229,103 +229,103 @@ class LanguageManager implements LanguageManagerInterface {
// The "Left-to-right marker" comments and the enclosed UTF-8 markers are to
// make otherwise strange looking PHP syntax natural (to not be displayed in
// right to left). See https://www.drupal.org/node/128866#comment-528929.
- return array(
- 'af' => array('Afrikaans', 'Afrikaans'),
- 'am' => array('Amharic', 'አማርኛ'),
- 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', LanguageInterface::DIRECTION_RTL),
- 'ast' => array('Asturian', 'Asturianu'),
- 'az' => array('Azerbaijani', 'Azərbaycanca'),
- 'be' => array('Belarusian', 'Беларуская'),
- 'bg' => array('Bulgarian', 'Български'),
- 'bn' => array('Bengali', 'বাংলা'),
- 'bo' => array('Tibetan', 'བོད་སྐད་'),
- 'bs' => array('Bosnian', 'Bosanski'),
- 'ca' => array('Catalan', 'Català'),
- 'cs' => array('Czech', 'Čeština'),
- 'cy' => array('Welsh', 'Cymraeg'),
- 'da' => array('Danish', 'Dansk'),
- 'de' => array('German', 'Deutsch'),
- 'dz' => array('Dzongkha', 'རྫོང་ཁ'),
- 'el' => array('Greek', 'Ελληνικά'),
- 'en' => array('English', 'English'),
- 'en-x-simple' => array('Simple English', 'Simple English'),
- 'eo' => array('Esperanto', 'Esperanto'),
- 'es' => array('Spanish', 'Español'),
- 'et' => array('Estonian', 'Eesti'),
- 'eu' => array('Basque', 'Euskera'),
- 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', LanguageInterface::DIRECTION_RTL),
- 'fi' => array('Finnish', 'Suomi'),
- 'fil' => array('Filipino', 'Filipino'),
- 'fo' => array('Faeroese', 'Føroyskt'),
- 'fr' => array('French', 'Français'),
- 'fy' => array('Frisian, Western', 'Frysk'),
- 'ga' => array('Irish', 'Gaeilge'),
- 'gd' => array('Scots Gaelic', 'Gàidhlig'),
- 'gl' => array('Galician', 'Galego'),
- 'gsw-berne' => array('Swiss German', 'Schwyzerdütsch'),
- 'gu' => array('Gujarati', 'ગુજરાતી'),
- 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', LanguageInterface::DIRECTION_RTL),
- 'hi' => array('Hindi', 'हिन्दी'),
- 'hr' => array('Croatian', 'Hrvatski'),
- 'ht' => array('Haitian Creole', 'Kreyòl ayisyen'),
- 'hu' => array('Hungarian', 'Magyar'),
- 'hy' => array('Armenian', 'Հայերեն'),
- 'id' => array('Indonesian', 'Bahasa Indonesia'),
- 'is' => array('Icelandic', 'Íslenska'),
- 'it' => array('Italian', 'Italiano'),
- 'ja' => array('Japanese', '日本語'),
- 'jv' => array('Javanese', 'Basa Java'),
- 'ka' => array('Georgian', 'ქართული ენა'),
- 'kk' => array('Kazakh', 'Қазақ'),
- 'km' => array('Khmer', 'ភាសាខ្មែរ'),
- 'kn' => array('Kannada', 'ಕನ್ನಡ'),
- 'ko' => array('Korean', '한국어'),
- 'ku' => array('Kurdish', 'Kurdî'),
- 'ky' => array('Kyrgyz', 'Кыргызча'),
- 'lo' => array('Lao', 'ພາສາລາວ'),
- 'lt' => array('Lithuanian', 'Lietuvių'),
- 'lv' => array('Latvian', 'Latviešu'),
- 'mg' => array('Malagasy', 'Malagasy'),
- 'mk' => array('Macedonian', 'Македонски'),
- 'ml' => array('Malayalam', 'മലയാളം'),
- 'mn' => array('Mongolian', 'монгол'),
- 'mr' => array('Marathi', 'मराठी'),
- 'ms' => array('Bahasa Malaysia', 'بهاس ملايو'),
- 'my' => array('Burmese', 'ဗမာစကား'),
- 'ne' => array('Nepali', 'नेपाली'),
- 'nl' => array('Dutch', 'Nederlands'),
- 'nb' => array('Norwegian Bokmål', 'Norsk, bokmål'),
- 'nn' => array('Norwegian Nynorsk', 'Norsk, nynorsk'),
- 'oc' => array('Occitan', 'Occitan'),
- 'pa' => array('Punjabi', 'ਪੰਜਾਬੀ'),
- 'pl' => array('Polish', 'Polski'),
- 'pt-pt' => array('Portuguese, Portugal', 'Português, Portugal'),
- 'pt-br' => array('Portuguese, Brazil', 'Português, Brasil'),
- 'ro' => array('Romanian', 'Română'),
- 'ru' => array('Russian', 'Русский'),
- 'sco' => array('Scots', 'Scots'),
- 'se' => array('Northern Sami', 'Sámi'),
- 'si' => array('Sinhala', 'සිංහල'),
- 'sk' => array('Slovak', 'Slovenčina'),
- 'sl' => array('Slovenian', 'Slovenščina'),
- 'sq' => array('Albanian', 'Shqip'),
- 'sr' => array('Serbian', 'Српски'),
- 'sv' => array('Swedish', 'Svenska'),
- 'sw' => array('Swahili', 'Kiswahili'),
- 'ta' => array('Tamil', 'தமிழ்'),
- 'ta-lk' => array('Tamil, Sri Lanka', 'தமிழ், இலங்கை'),
- 'te' => array('Telugu', 'తెలుగు'),
- 'th' => array('Thai', 'ภาษาไทย'),
- 'tr' => array('Turkish', 'Türkçe'),
- 'tyv' => array('Tuvan', 'Тыва дыл'),
- 'ug' => array('Uyghur', /* Left-to-right marker "‭" */ 'ئۇيغۇرچە', LanguageInterface::DIRECTION_RTL),
- 'uk' => array('Ukrainian', 'Українська'),
- 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', LanguageInterface::DIRECTION_RTL),
- 'vi' => array('Vietnamese', 'Tiếng Việt'),
- 'xx-lolspeak' => array('Lolspeak', 'Lolspeak'),
- 'zh-hans' => array('Chinese, Simplified', '简体中文'),
- 'zh-hant' => array('Chinese, Traditional', '繁體中文'),
- );
+ return [
+ 'af' => ['Afrikaans', 'Afrikaans'],
+ 'am' => ['Amharic', 'አማርኛ'],
+ 'ar' => ['Arabic', /* Left-to-right marker "‭" */ 'العربية', LanguageInterface::DIRECTION_RTL],
+ 'ast' => ['Asturian', 'Asturianu'],
+ 'az' => ['Azerbaijani', 'Azərbaycanca'],
+ 'be' => ['Belarusian', 'Беларуская'],
+ 'bg' => ['Bulgarian', 'Български'],
+ 'bn' => ['Bengali', 'বাংলা'],
+ 'bo' => ['Tibetan', 'བོད་སྐད་'],
+ 'bs' => ['Bosnian', 'Bosanski'],
+ 'ca' => ['Catalan', 'Català'],
+ 'cs' => ['Czech', 'Čeština'],
+ 'cy' => ['Welsh', 'Cymraeg'],
+ 'da' => ['Danish', 'Dansk'],
+ 'de' => ['German', 'Deutsch'],
+ 'dz' => ['Dzongkha', 'རྫོང་ཁ'],
+ 'el' => ['Greek', 'Ελληνικά'],
+ 'en' => ['English', 'English'],
+ 'en-x-simple' => ['Simple English', 'Simple English'],
+ 'eo' => ['Esperanto', 'Esperanto'],
+ 'es' => ['Spanish', 'Español'],
+ 'et' => ['Estonian', 'Eesti'],
+ 'eu' => ['Basque', 'Euskera'],
+ 'fa' => ['Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', LanguageInterface::DIRECTION_RTL],
+ 'fi' => ['Finnish', 'Suomi'],
+ 'fil' => ['Filipino', 'Filipino'],
+ 'fo' => ['Faeroese', 'Føroyskt'],
+ 'fr' => ['French', 'Français'],
+ 'fy' => ['Frisian, Western', 'Frysk'],
+ 'ga' => ['Irish', 'Gaeilge'],
+ 'gd' => ['Scots Gaelic', 'Gàidhlig'],
+ 'gl' => ['Galician', 'Galego'],
+ 'gsw-berne' => ['Swiss German', 'Schwyzerdütsch'],
+ 'gu' => ['Gujarati', 'ગુજરાતી'],
+ 'he' => ['Hebrew', /* Left-to-right marker "‭" */ 'עברית', LanguageInterface::DIRECTION_RTL],
+ 'hi' => ['Hindi', 'हिन्दी'],
+ 'hr' => ['Croatian', 'Hrvatski'],
+ 'ht' => ['Haitian Creole', 'Kreyòl ayisyen'],
+ 'hu' => ['Hungarian', 'Magyar'],
+ 'hy' => ['Armenian', 'Հայերեն'],
+ 'id' => ['Indonesian', 'Bahasa Indonesia'],
+ 'is' => ['Icelandic', 'Íslenska'],
+ 'it' => ['Italian', 'Italiano'],
+ 'ja' => ['Japanese', '日本語'],
+ 'jv' => ['Javanese', 'Basa Java'],
+ 'ka' => ['Georgian', 'ქართული ენა'],
+ 'kk' => ['Kazakh', 'Қазақ'],
+ 'km' => ['Khmer', 'ភាសាខ្មែរ'],
+ 'kn' => ['Kannada', 'ಕನ್ನಡ'],
+ 'ko' => ['Korean', '한국어'],
+ 'ku' => ['Kurdish', 'Kurdî'],
+ 'ky' => ['Kyrgyz', 'Кыргызча'],
+ 'lo' => ['Lao', 'ພາສາລາວ'],
+ 'lt' => ['Lithuanian', 'Lietuvių'],
+ 'lv' => ['Latvian', 'Latviešu'],
+ 'mg' => ['Malagasy', 'Malagasy'],
+ 'mk' => ['Macedonian', 'Македонски'],
+ 'ml' => ['Malayalam', 'മലയാളം'],
+ 'mn' => ['Mongolian', 'монгол'],
+ 'mr' => ['Marathi', 'मराठी'],
+ 'ms' => ['Bahasa Malaysia', 'بهاس ملايو'],
+ 'my' => ['Burmese', 'ဗမာစကား'],
+ 'ne' => ['Nepali', 'नेपाली'],
+ 'nl' => ['Dutch', 'Nederlands'],
+ 'nb' => ['Norwegian Bokmål', 'Norsk, bokmål'],
+ 'nn' => ['Norwegian Nynorsk', 'Norsk, nynorsk'],
+ 'oc' => ['Occitan', 'Occitan'],
+ 'pa' => ['Punjabi', 'ਪੰਜਾਬੀ'],
+ 'pl' => ['Polish', 'Polski'],
+ 'pt-pt' => ['Portuguese, Portugal', 'Português, Portugal'],
+ 'pt-br' => ['Portuguese, Brazil', 'Português, Brasil'],
+ 'ro' => ['Romanian', 'Română'],
+ 'ru' => ['Russian', 'Русский'],
+ 'sco' => ['Scots', 'Scots'],
+ 'se' => ['Northern Sami', 'Sámi'],
+ 'si' => ['Sinhala', 'සිංහල'],
+ 'sk' => ['Slovak', 'Slovenčina'],
+ 'sl' => ['Slovenian', 'Slovenščina'],
+ 'sq' => ['Albanian', 'Shqip'],
+ 'sr' => ['Serbian', 'Српски'],
+ 'sv' => ['Swedish', 'Svenska'],
+ 'sw' => ['Swahili', 'Kiswahili'],
+ 'ta' => ['Tamil', 'தமிழ்'],
+ 'ta-lk' => ['Tamil, Sri Lanka', 'தமிழ், இலங்கை'],
+ 'te' => ['Telugu', 'తెలుగు'],
+ 'th' => ['Thai', 'ภาษาไทย'],
+ 'tr' => ['Turkish', 'Türkçe'],
+ 'tyv' => ['Tuvan', 'Тыва дыл'],
+ 'ug' => ['Uyghur', /* Left-to-right marker "‭" */ 'ئۇيغۇرچە', LanguageInterface::DIRECTION_RTL],
+ 'uk' => ['Ukrainian', 'Українська'],
+ 'ur' => ['Urdu', /* Left-to-right marker "‭" */ 'اردو', LanguageInterface::DIRECTION_RTL],
+ 'vi' => ['Vietnamese', 'Tiếng Việt'],
+ 'xx-lolspeak' => ['Lolspeak', 'Lolspeak'],
+ 'zh-hans' => ['Chinese, Simplified', '简体中文'],
+ 'zh-hant' => ['Chinese, Traditional', '繁體中文'],
+ ];
}
/**
@@ -391,7 +391,7 @@ class LanguageManager implements LanguageManagerInterface {
return $languages;
}
- $filtered_languages = array();
+ $filtered_languages = [];
// Add the site's default language if requested.
if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
@@ -399,13 +399,13 @@ class LanguageManager implements LanguageManagerInterface {
// default language only for runtime.
$defaultLanguage = $this->getDefaultLanguage();
$default = new Language(
- array(
+ [
'id' => $defaultLanguage->getId(),
'name' => new TranslatableMarkup("Site's default language (@lang_name)",
- array('@lang_name' => $defaultLanguage->getName())),
+ ['@lang_name' => $defaultLanguage->getName()]),
'direction' => $defaultLanguage->getDirection(),
'weight' => $defaultLanguage->getWeight(),
- )
+ ]
);
$filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
}
diff --git a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php
index be0188d429e..eaefd18a276 100644
--- a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php
+++ b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php
@@ -161,7 +161,7 @@ interface LanguageManagerInterface {
* An array of language codes sorted by priority: first values should be
* tried first.
*/
- public function getFallbackCandidates(array $context = array());
+ public function getFallbackCandidates(array $context = []);
/**
* Returns the language switch links for the given language type.
diff --git a/core/lib/Drupal/Core/Link.php b/core/lib/Drupal/Core/Link.php
index e7c9e3a83ca..e435d442791 100644
--- a/core/lib/Drupal/Core/Link.php
+++ b/core/lib/Drupal/Core/Link.php
@@ -57,7 +57,7 @@ class Link implements RenderableInterface {
*
* @return static
*/
- public static function createFromRoute($text, $route_name, $route_parameters = array(), $options = array()) {
+ public static function createFromRoute($text, $route_name, $route_parameters = [], $options = []) {
return new static($text, new Url($route_name, $route_parameters, $options));
}
diff --git a/core/lib/Drupal/Core/Locale/CountryManager.php b/core/lib/Drupal/Core/Locale/CountryManager.php
index 451758e0827..adc110cae17 100644
--- a/core/lib/Drupal/Core/Locale/CountryManager.php
+++ b/core/lib/Drupal/Core/Locale/CountryManager.php
@@ -37,7 +37,7 @@ class CountryManager implements CountryManagerInterface {
* An array of country code => country name pairs.
*/
public static function getStandardList() {
- $countries = array(
+ $countries = [
'AC' => t('Ascension Island'),
'AD' => t('Andorra'),
'AE' => t('United Arab Emirates'),
@@ -296,7 +296,7 @@ class CountryManager implements CountryManagerInterface {
'ZA' => t('South Africa'),
'ZM' => t('Zambia'),
'ZW' => t('Zimbabwe'),
- );
+ ];
// Sort the list.
natcasesort($countries);
diff --git a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php
index d09502826f4..91077e7ad31 100644
--- a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php
+++ b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php
@@ -34,7 +34,7 @@ class DatabaseLockBackend extends LockBackendAbstract {
public function __construct(Connection $database) {
// __destruct() is causing problems with garbage collections, register a
// shutdown function instead.
- drupal_register_shutdown_function(array($this, 'releaseAll'));
+ drupal_register_shutdown_function([$this, 'releaseAll']);
$this->database = $database;
}
@@ -48,7 +48,7 @@ class DatabaseLockBackend extends LockBackendAbstract {
if (isset($this->locks[$name])) {
// Try to extend the expiration of a lock we already acquired.
$success = (bool) $this->database->update('semaphore')
- ->fields(array('expire' => $expire))
+ ->fields(['expire' => $expire])
->condition('name', $name)
->condition('value', $this->getLockId())
->execute();
@@ -66,11 +66,11 @@ class DatabaseLockBackend extends LockBackendAbstract {
do {
try {
$this->database->insert('semaphore')
- ->fields(array(
+ ->fields([
'name' => $name,
'value' => $this->getLockId(),
'expire' => $expire,
- ))
+ ])
->execute();
// We track all acquired locks in the global variable.
$this->locks[$name] = TRUE;
@@ -107,7 +107,7 @@ class DatabaseLockBackend extends LockBackendAbstract {
*/
public function lockMayBeAvailable($name) {
try {
- $lock = $this->database->query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc();
+ $lock = $this->database->query('SELECT expire, value FROM {semaphore} WHERE name = :name', [':name' => $name])->fetchAssoc();
}
catch (\Exception $e) {
$this->catchException($e);
@@ -154,7 +154,7 @@ class DatabaseLockBackend extends LockBackendAbstract {
public function releaseAll($lock_id = NULL) {
// Only attempt to release locks if any were acquired.
if (!empty($this->locks)) {
- $this->locks = array();
+ $this->locks = [];
if (empty($lock_id)) {
$lock_id = $this->getLockId();
}
diff --git a/core/lib/Drupal/Core/Lock/LockBackendAbstract.php b/core/lib/Drupal/Core/Lock/LockBackendAbstract.php
index 32322d4e83b..41ee27cab4f 100644
--- a/core/lib/Drupal/Core/Lock/LockBackendAbstract.php
+++ b/core/lib/Drupal/Core/Lock/LockBackendAbstract.php
@@ -21,7 +21,7 @@ abstract class LockBackendAbstract implements LockBackendInterface {
*
* @var array
*/
- protected $locks = array();
+ protected $locks = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/Logger/LogMessageParser.php b/core/lib/Drupal/Core/Logger/LogMessageParser.php
index 3ce39bbf4ec..8a67df12dca 100644
--- a/core/lib/Drupal/Core/Logger/LogMessageParser.php
+++ b/core/lib/Drupal/Core/Logger/LogMessageParser.php
@@ -11,7 +11,7 @@ class LogMessageParser implements LogMessageParserInterface {
* {@inheritdoc}
*/
public function parseMessagePlaceholders(&$message, array &$context) {
- $variables = array();
+ $variables = [];
$has_psr3 = FALSE;
if (($start = strpos($message, '{')) !== FALSE && strpos($message, '}') > $start) {
$has_psr3 = TRUE;
diff --git a/core/lib/Drupal/Core/Logger/LoggerChannel.php b/core/lib/Drupal/Core/Logger/LoggerChannel.php
index 9253a24958c..51141f78460 100644
--- a/core/lib/Drupal/Core/Logger/LoggerChannel.php
+++ b/core/lib/Drupal/Core/Logger/LoggerChannel.php
@@ -46,7 +46,7 @@ class LoggerChannel implements LoggerChannelInterface {
*
* @var array
*/
- protected $levelTranslation = array(
+ protected $levelTranslation = [
LogLevel::EMERGENCY => RfcLogLevel::EMERGENCY,
LogLevel::ALERT => RfcLogLevel::ALERT,
LogLevel::CRITICAL => RfcLogLevel::CRITICAL,
@@ -55,14 +55,14 @@ class LoggerChannel implements LoggerChannelInterface {
LogLevel::NOTICE => RfcLogLevel::NOTICE,
LogLevel::INFO => RfcLogLevel::INFO,
LogLevel::DEBUG => RfcLogLevel::DEBUG,
- );
+ ];
/**
* An array of arrays of \Psr\Log\LoggerInterface keyed by priority.
*
* @var array
*/
- protected $loggers = array();
+ protected $loggers = [];
/**
* The request stack object.
@@ -91,14 +91,14 @@ class LoggerChannel implements LoggerChannelInterface {
/**
* {@inheritdoc}
*/
- public function log($level, $message, array $context = array()) {
+ public function log($level, $message, array $context = []) {
if ($this->callDepth == self::MAX_CALL_DEPTH) {
return;
}
$this->callDepth++;
// Merge in defaults.
- $context += array(
+ $context += [
'channel' => $this->channel,
'link' => '',
'user' => NULL,
@@ -107,7 +107,7 @@ class LoggerChannel implements LoggerChannelInterface {
'referer' => '',
'ip' => '',
'timestamp' => time(),
- );
+ ];
// Some context values are only available when in a request context.
if ($this->requestStack && $request = $this->requestStack->getCurrentRequest()) {
$context['request_uri'] = $request->getUri();
@@ -174,7 +174,7 @@ class LoggerChannel implements LoggerChannelInterface {
* An array of sorted loggers by priority.
*/
protected function sortLoggers() {
- $sorted = array();
+ $sorted = [];
krsort($this->loggers);
foreach ($this->loggers as $loggers) {
diff --git a/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php b/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php
index 2fa55316bf5..6c487d17531 100644
--- a/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php
+++ b/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php
@@ -17,14 +17,14 @@ class LoggerChannelFactory implements LoggerChannelFactoryInterface, ContainerAw
*
* @var \Drupal\Core\Logger\LoggerChannelInterface[]
*/
- protected $channels = array();
+ protected $channels = [];
/**
* An array of arrays of \Psr\Log\LoggerInterface keyed by priority.
*
* @var array
*/
- protected $loggers = array();
+ protected $loggers = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php b/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php
index c05d733b15b..0152efe2c7b 100644
--- a/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php
+++ b/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php
@@ -17,62 +17,62 @@ trait RfcLoggerTrait {
/**
* {@inheritdoc}
*/
- public function emergency($message, array $context = array()) {
+ public function emergency($message, array $context = []) {
$this->log(RfcLogLevel::EMERGENCY, $message, $context);
}
/**
* {@inheritdoc}
*/
- public function alert($message, array $context = array()) {
+ public function alert($message, array $context = []) {
$this->log(RfcLogLevel::ALERT, $message, $context);
}
/**
* {@inheritdoc}
*/
- public function critical($message, array $context = array()) {
+ public function critical($message, array $context = []) {
$this->log(RfcLogLevel::CRITICAL, $message, $context);
}
/**
* {@inheritdoc}
*/
- public function error($message, array $context = array()) {
+ public function error($message, array $context = []) {
$this->log(RfcLogLevel::ERROR, $message, $context);
}
/**
* {@inheritdoc}
*/
- public function warning($message, array $context = array()) {
+ public function warning($message, array $context = []) {
$this->log(RfcLogLevel::WARNING, $message, $context);
}
/**
* {@inheritdoc}
*/
- public function notice($message, array $context = array()) {
+ public function notice($message, array $context = []) {
$this->log(RfcLogLevel::NOTICE, $message, $context);
}
/**
* {@inheritdoc}
*/
- public function info($message, array $context = array()) {
+ public function info($message, array $context = []) {
$this->log(RfcLogLevel::INFO, $message, $context);
}
/**
* {@inheritdoc}
*/
- public function debug($message, array $context = array()) {
+ public function debug($message, array $context = []) {
$this->log(RfcLogLevel::DEBUG, $message, $context);
}
/**
* {@inheritdoc}
*/
- abstract public function log($level, $message, array $context = array());
+ abstract public function log($level, $message, array $context = []);
}
diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
index 3dffe830c20..021028fce81 100644
--- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php
+++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
@@ -17,7 +17,7 @@ class MailFormatHelper {
*
* @var array
*/
- protected static $urls = array();
+ protected static $urls = [];
/**
* Quoted regex expression based on base path.
@@ -31,7 +31,7 @@ class MailFormatHelper {
*
* @var array
*/
- protected static $supportedTags = array();
+ protected static $supportedTags = [];
/**
* Performs format=flowed soft wrapping for mail (RFC 3676).
@@ -63,12 +63,12 @@ class MailFormatHelper {
$text = preg_replace('/(?(?<!^--) +\n| +\n)/m', "\n", $text);
// Wrap each line at the needed width.
$lines = explode("\n", $text);
- array_walk($lines, '\Drupal\Core\Mail\MailFormatHelper::wrapMailLine', array('soft' => $soft, 'length' => strlen($indent)));
+ array_walk($lines, '\Drupal\Core\Mail\MailFormatHelper::wrapMailLine', ['soft' => $soft, 'length' => strlen($indent)]);
$text = implode("\n", $lines);
}
else {
// Wrap this line.
- static::wrapMailLine($text, 0, array('soft' => $soft, 'length' => strlen($indent)));
+ static::wrapMailLine($text, 0, ['soft' => $soft, 'length' => strlen($indent)]);
}
// Empty lines with nothing but spaces.
$text = preg_replace('/^ +\n/m', "\n", $text);
@@ -104,9 +104,9 @@ class MailFormatHelper {
public static function htmlToText($string, $allowed_tags = NULL) {
// Cache list of supported tags.
if (empty(static::$supportedTags)) {
- static::$supportedTags = array('a', 'em', 'i', 'strong', 'b', 'br', 'p',
+ static::$supportedTags = ['a', 'em', 'i', 'strong', 'b', 'br', 'p',
'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'h1', 'h2', 'h3',
- 'h4', 'h5', 'h6', 'hr');
+ 'h4', 'h5', 'h6', 'hr'];
}
// Make sure only supported tags are kept.
@@ -146,9 +146,9 @@ class MailFormatHelper {
$casing = NULL;
$output = '';
// All current indentation string chunks.
- $indent = array();
+ $indent = [];
// Array of counters for opened lists.
- $lists = array();
+ $lists = [];
foreach ($split as $value) {
// Holds a string ready to be formatted and output.
$chunk = NULL;
@@ -302,12 +302,12 @@ class MailFormatHelper {
*/
protected static function wrapMailLine(&$line, $key, $values) {
$line_is_mime_header = FALSE;
- $mime_headers = array(
+ $mime_headers = [
'Content-Type',
'Content-Transfer-Encoding',
'Content-Disposition',
'Content-Description',
- );
+ ];
// Do not break MIME headers which could be longer than 77 characters.
foreach ($mime_headers as $header) {
@@ -336,7 +336,7 @@ class MailFormatHelper {
if ($reset) {
// Reset internal URL list.
- static::$urls = array();
+ static::$urls = [];
}
else {
if (empty(static::$regexp)) {
diff --git a/core/lib/Drupal/Core/Mail/MailManager.php b/core/lib/Drupal/Core/Mail/MailManager.php
index 2abba6b3c99..6de2dd818c6 100644
--- a/core/lib/Drupal/Core/Mail/MailManager.php
+++ b/core/lib/Drupal/Core/Mail/MailManager.php
@@ -50,7 +50,7 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
*
* @var array
*/
- protected $instances = array();
+ protected $instances = [];
/**
* Constructs the MailManager object.
@@ -163,7 +163,7 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
/**
* {@inheritdoc}
*/
- public function mail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE) {
+ public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {
// Mailing can invoke rendering (e.g., generating URLs, replacing tokens),
// but e-mails are not HTTP responses: they're not cached, they don't have
// attachments. Therefore we perform mailing inside its own render context,
@@ -215,7 +215,7 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
*
* @see \Drupal\Core\Mail\MailManagerInterface::mail()
*/
- public function doMail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE) {
+ public function doMail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {
$site_config = $this->configFactory->get('system.site');
$site_mail = $site_config->get('mail');
if (empty($site_mail)) {
@@ -223,7 +223,7 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
}
// Bundle up the variables into a structured array for altering.
- $message = array(
+ $message = [
'id' => $module . '_' . $key,
'module' => $module,
'key' => $key,
@@ -234,16 +234,16 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
'params' => $params,
'send' => TRUE,
'subject' => '',
- 'body' => array(),
- );
+ 'body' => [],
+ ];
// Build the default headers.
- $headers = array(
+ $headers = [
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal',
- );
+ ];
// To prevent email from looking like spam, the addresses in the Sender and
// Return-Path headers should have a domain authorized to use the
// originating SMTP server.
@@ -267,7 +267,7 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
$this->moduleHandler->alter('mail', $message);
// Retrieve the responsible implementation for this message.
- $system = $this->getInstance(array('module' => $module, 'key' => $key));
+ $system = $this->getInstance(['module' => $module, 'key' => $key]);
// Format the message body.
$message = $system->format($message);
@@ -292,11 +292,11 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
// Log errors.
if (!$message['result']) {
$this->loggerFactory->get('mail')
- ->error('Error sending email (from %from to %to with reply-to %reply).', array(
+ ->error('Error sending email (from %from to %to with reply-to %reply).', [
'%from' => $message['from'],
'%to' => $message['to'],
'%reply' => $message['reply-to'] ? $message['reply-to'] : $this->t('not set'),
- ));
+ ]);
drupal_set_message($this->t('Unable to send email. Contact the site administrator if the problem persists.'), 'error');
}
}
diff --git a/core/lib/Drupal/Core/Mail/MailManagerInterface.php b/core/lib/Drupal/Core/Mail/MailManagerInterface.php
index cdf4c8ae514..0228fbcb971 100644
--- a/core/lib/Drupal/Core/Mail/MailManagerInterface.php
+++ b/core/lib/Drupal/Core/Mail/MailManagerInterface.php
@@ -119,6 +119,6 @@ interface MailManagerInterface extends PluginManagerInterface {
* watchdog. (Success means nothing more than the message being accepted at
* php-level, which still doesn't guarantee it to be delivered.)
*/
- public function mail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE);
+ public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE);
}
diff --git a/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php b/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php
index 652c6b30552..1fced2e4791 100644
--- a/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php
+++ b/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php
@@ -61,7 +61,7 @@ class PhpMail implements MailInterface {
unset($message['headers']['Return-Path']);
}
}
- $mimeheaders = array();
+ $mimeheaders = [];
foreach ($message['headers'] as $name => $value) {
$mimeheaders[] = $name . ': ' . Unicode::mimeHeaderEncode($value);
}
diff --git a/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php b/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php
index ede465e7298..607906f4c8c 100644
--- a/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php
+++ b/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php
@@ -21,7 +21,7 @@ class TestMailCollector extends PhpMail implements MailInterface {
* {@inheritdoc}
*/
public function mail(array $message) {
- $captured_emails = \Drupal::state()->get('system.test_mail_collector') ?: array();
+ $captured_emails = \Drupal::state()->get('system.test_mail_collector') ?: [];
$captured_emails[] = $message;
\Drupal::state()->set('system.test_mail_collector', $captured_emails);
diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php
index e264036fc4c..057f7ded403 100644
--- a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php
+++ b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php
@@ -27,7 +27,7 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi
*
* @var array
*/
- protected $defaults = array(
+ protected $defaults = [
// (required) The name of the route to link to.
'route_name' => '',
// (required) The contextual links group.
@@ -35,14 +35,14 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi
// The static title text for the link.
'title' => '',
// The default link options.
- 'options' => array(),
+ 'options' => [],
// The weight of the link.
'weight' => NULL,
// Default class for contextual link implementations.
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
// The plugin id. Set by the plugin system based on the top-level YAML key.
'id' => '',
- );
+ ];
/**
* A controller resolver object.
@@ -105,7 +105,7 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi
$this->moduleHandler = $module_handler;
$this->requestStack = $request_stack;
$this->alterInfo('contextual_links_plugins');
- $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('contextual_links_plugins'));
+ $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['contextual_links_plugins']);
}
/**
@@ -148,7 +148,7 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi
$this->pluginsByGroup[$group_name] = $contextual_links;
}
else {
- $contextual_links = array();
+ $contextual_links = [];
foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) {
if ($plugin_definition['group'] == $group_name) {
$contextual_links[$plugin_id] = $plugin_definition;
@@ -163,8 +163,8 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi
/**
* {@inheritdoc}
*/
- public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = array()) {
- $links = array();
+ public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = []) {
+ $links = [];
$request = $this->requestStack->getCurrentRequest();
foreach ($this->getContextualLinkPluginsByGroup($group_name) as $plugin_id => $plugin_definition) {
/** @var $plugin \Drupal\Core\Menu\ContextualLinkInterface */
@@ -176,14 +176,14 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi
continue;
}
- $links[$plugin_id] = array(
+ $links[$plugin_id] = [
'route_name' => $route_name,
'route_parameters' => $route_parameters,
'title' => $plugin->getTitle($request),
'weight' => $plugin->getWeight(),
'localized_options' => $plugin->getOptions(),
'metadata' => $metadata,
- );
+ ];
}
$this->moduleHandler->alter('contextual_links', $links, $group_name, $route_parameters);
diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php b/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php
index 9e294364ec5..12f0275584c 100644
--- a/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php
+++ b/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php
@@ -41,6 +41,6 @@ interface ContextualLinkManagerInterface {
* to the link generator.
* - metadata: The array of additional metadata that was passed in.
*/
- public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = array());
+ public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = []);
}
diff --git a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php
index c74e38083ff..7eefd12754a 100644
--- a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php
+++ b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php
@@ -130,7 +130,7 @@ class DefaultMenuLinkTreeManipulators {
* The manipulated menu link tree.
*/
public function checkNodeAccess(array $tree) {
- $node_links = array();
+ $node_links = [];
$this->collectNodeLinks($tree, $node_links);
if ($node_links) {
$nids = array_keys($node_links);
@@ -225,7 +225,7 @@ class DefaultMenuLinkTreeManipulators {
* The manipulated menu link tree.
*/
public function generateIndexAndSort(array $tree) {
- $new_tree = array();
+ $new_tree = [];
foreach ($tree as $key => $v) {
if ($tree[$key]->subtree) {
$tree[$key]->subtree = $this->generateIndexAndSort($tree[$key]->subtree);
@@ -255,7 +255,7 @@ class DefaultMenuLinkTreeManipulators {
if ($tree[$key]->subtree) {
$tree += $this->flatten($tree[$key]->subtree);
}
- $tree[$key]->subtree = array();
+ $tree[$key]->subtree = [];
}
return $tree;
}
diff --git a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
index e7c04e370d6..17031199e10 100644
--- a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
+++ b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
@@ -98,41 +98,41 @@ class MenuLinkDefaultForm implements MenuLinkFormInterface, ContainerInjectionIn
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['#title'] = $this->t('Edit menu link %title', array('%title' => $this->menuLink->getTitle()));
+ $form['#title'] = $this->t('Edit menu link %title', ['%title' => $this->menuLink->getTitle()]);
$provider = $this->menuLink->getProvider();
- $form['info'] = array(
+ $form['info'] = [
'#type' => 'item',
- '#title' => $this->t('This link is provided by the @name module. The title and path cannot be edited.', array('@name' => $this->moduleHandler->getName($provider))),
- );
- $form['id'] = array(
+ '#title' => $this->t('This link is provided by the @name module. The title and path cannot be edited.', ['@name' => $this->moduleHandler->getName($provider)]),
+ ];
+ $form['id'] = [
'#type' => 'value',
'#value' => $this->menuLink->getPluginId(),
- );
- $link = array(
+ ];
+ $link = [
'#type' => 'link',
'#title' => $this->menuLink->getTitle(),
'#url' => $this->menuLink->getUrlObject(),
- );
- $form['path'] = array(
+ ];
+ $form['path'] = [
'link' => $link,
'#type' => 'item',
'#title' => $this->t('Link'),
- );
+ ];
- $form['enabled'] = array(
+ $form['enabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable menu link'),
'#description' => $this->t('Menu links that are not enabled will not be listed in any menu.'),
'#default_value' => $this->menuLink->isEnabled(),
- );
+ ];
- $form['expanded'] = array(
+ $form['expanded'] = [
'#type' => 'checkbox',
'#title' => t('Show as expanded'),
'#description' => $this->t('If selected and this menu link has children, the menu will always appear expanded.'),
'#default_value' => $this->menuLink->isExpanded(),
- );
+ ];
$menu_parent = $this->menuLink->getMenuName() . ':' . $this->menuLink->getParent();
$form['menu_parent'] = $this->menuParentSelector->parentSelectElement($menu_parent, $this->menuLink->getPluginId());
@@ -141,14 +141,14 @@ class MenuLinkDefaultForm implements MenuLinkFormInterface, ContainerInjectionIn
$form['menu_parent']['#attributes']['class'][] = 'menu-title-select';
$delta = max(abs($this->menuLink->getWeight()), 50);
- $form['weight'] = array(
+ $form['weight'] = [
'#type' => 'number',
'#min' => -$delta,
'#max' => $delta,
'#default_value' => $this->menuLink->getWeight(),
'#title' => $this->t('Weight'),
'#description' => $this->t('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.'),
- );
+ ];
return $form;
}
diff --git a/core/lib/Drupal/Core/Menu/LocalActionDefault.php b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
index bfa088e0adb..ab562e6ddb4 100644
--- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php
+++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
@@ -83,7 +83,7 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
* {@inheritdoc}
*/
public function getRouteParameters(RouteMatchInterface $route_match) {
- $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array();
+ $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : [];
$route = $this->routeProvider->getRouteByName($this->getRouteName());
$variables = $route->compile()->getVariables();
diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php
index 924af7c4a91..f262d4724d7 100644
--- a/core/lib/Drupal/Core/Menu/LocalActionManager.php
+++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php
@@ -28,7 +28,7 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana
*
* @var array
*/
- protected $defaults = array(
+ protected $defaults = [
// The plugin id. Set by the plugin system based on the top-level YAML key.
'id' => NULL,
// The static title for the local action.
@@ -38,14 +38,14 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana
// (Required) the route name used to generate a link.
'route_name' => NULL,
// Default route parameters for generating links.
- 'route_parameters' => array(),
+ 'route_parameters' => [],
// Associative array of link options.
- 'options' => array(),
+ 'options' => [],
// The route names where this local action appears.
- 'appears_on' => array(),
+ 'appears_on' => [],
// Default class for local action implementations.
'class' => 'Drupal\Core\Menu\LocalActionDefault',
- );
+ ];
/**
* A controller resolver object.
@@ -94,7 +94,7 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana
*
* @var \Drupal\Core\Menu\LocalActionInterface[]
*/
- protected $instances = array();
+ protected $instances = [];
/**
* Constructs a LocalActionManager object.
@@ -130,7 +130,7 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana
$this->moduleHandler = $module_handler;
$this->account = $account;
$this->alterInfo('menu_local_actions');
- $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_action'));
+ $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['local_action']);
}
/**
@@ -149,7 +149,7 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana
* {@inheritdoc}
*/
public function getTitle(LocalActionInterface $local_action) {
- $controller = array($local_action, 'getTitle');
+ $controller = [$local_action, 'getTitle'];
$arguments = $this->controllerResolver->getArguments($this->requestStack->getCurrentRequest(), $controller);
return call_user_func_array($controller, $arguments);
}
@@ -159,8 +159,8 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana
*/
public function getActionsForRoute($route_appears) {
if (!isset($this->instances[$route_appears])) {
- $route_names = array();
- $this->instances[$route_appears] = array();
+ $route_names = [];
+ $this->instances[$route_appears] = [];
// @todo - optimize this lookup by compiling or caching.
foreach ($this->getDefinitions() as $plugin_id => $action_info) {
if (in_array($route_appears, $action_info['appears_on'])) {
@@ -175,23 +175,23 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana
$this->routeProvider->getRoutesByNames($route_names);
}
}
- $links = array();
+ $links = [];
/** @var $plugin \Drupal\Core\Menu\LocalActionInterface */
foreach ($this->instances[$route_appears] as $plugin_id => $plugin) {
$cacheability = new CacheableMetadata();
$route_name = $plugin->getRouteName();
$route_parameters = $plugin->getRouteParameters($this->routeMatch);
$access = $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE);
- $links[$plugin_id] = array(
+ $links[$plugin_id] = [
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => $this->getTitle($plugin),
'url' => Url::fromRoute($route_name, $route_parameters),
'localized_options' => $plugin->getOptions($this->routeMatch),
- ),
+ ],
'#access' => $access,
'#weight' => $plugin->getWeight(),
- );
+ ];
$cacheability->addCacheableDependency($access)->addCacheableDependency($plugin);
$cacheability->applyTo($links[$plugin_id]);
}
diff --git a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
index 38534b11994..30fba4fb43f 100644
--- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
+++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
@@ -41,7 +41,7 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface, Cacheab
* {@inheritdoc}
*/
public function getRouteParameters(RouteMatchInterface $route_match) {
- $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array();
+ $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : [];
$route = $this->routeProvider()->getRouteByName($this->getRouteName());
$variables = $route->compile()->getVariables();
diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php
index 26b2ed5b164..c14d1de1a32 100644
--- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php
+++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php
@@ -29,11 +29,11 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
/**
* {@inheritdoc}
*/
- protected $defaults = array(
+ protected $defaults = [
// (required) The name of the route this task links to.
'route_name' => '',
// Parameters for route variables when generating a link.
- 'route_parameters' => array(),
+ 'route_parameters' => [],
// The static title for the local task.
'title' => '',
// The route name where the root tab appears.
@@ -43,12 +43,12 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
// The weight of the tab.
'weight' => NULL,
// The default link options.
- 'options' => array(),
+ 'options' => [],
// Default class for local task implementations.
'class' => 'Drupal\Core\Menu\LocalTaskDefault',
// The plugin id. Set by the plugin system based on the top-level YAML key.
'id' => '',
- );
+ ];
/**
* A controller resolver object.
@@ -76,7 +76,7 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
*
* @var array
*/
- protected $instances = array();
+ protected $instances = [];
/**
* The local task render arrays for the current route.
@@ -138,7 +138,7 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
$this->account = $account;
$this->moduleHandler = $module_handler;
$this->alterInfo('local_tasks');
- $this->setCacheBackend($cache, 'local_task_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_task'));
+ $this->setCacheBackend($cache, 'local_task_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['local_task']);
}
/**
@@ -168,7 +168,7 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
* {@inheritdoc}
*/
public function getTitle(LocalTaskInterface $local_task) {
- $controller = array($local_task, 'getTitle');
+ $controller = [$local_task, 'getTitle'];
$request = $this->requestStack->getCurrentRequest();
$arguments = $this->controllerResolver->getArguments($request, $controller);
return call_user_func_array($controller, $arguments);
@@ -196,7 +196,7 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
*/
public function getLocalTasksForRoute($route_name) {
if (!isset($this->instances[$route_name])) {
- $this->instances[$route_name] = array();
+ $this->instances[$route_name] = [];
if ($cache = $this->cacheBackend->get($this->cacheKey . ':' . $route_name)) {
$base_routes = $cache->data['base_routes'];
$parents = $cache->data['parents'];
@@ -206,9 +206,9 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
$definitions = $this->getDefinitions();
// We build the hierarchy by finding all tabs that should
// appear on the current route.
- $base_routes = array();
- $parents = array();
- $children = array();
+ $base_routes = [];
+ $parents = [];
+ $children = [];
foreach ($definitions as $plugin_id => $task_info) {
// Fill in the base_route from the parent to insure consistency.
if (!empty($task_info['parent_id']) && !empty($definitions[$task_info['parent_id']])) {
@@ -242,11 +242,11 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
}
}
}
- $data = array(
+ $data = [
'base_routes' => $base_routes,
'parents' => $parents,
'children' => $children,
- );
+ ];
$this->cacheBackend->set($this->cacheKey . ':' . $route_name, $data, Cache::PERMANENT, $this->cacheTags);
}
// Create a plugin instance for each element of the hierarchy.
@@ -288,10 +288,10 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
*/
public function getTasksBuild($current_route_name, RefinableCacheableDependencyInterface &$cacheability) {
$tree = $this->getLocalTasksForRoute($current_route_name);
- $build = array();
+ $build = [];
// Collect all route names.
- $route_names = array();
+ $route_names = [];
foreach ($tree as $instances) {
foreach ($instances as $child) {
$route_names[] = $child->getRouteName();
diff --git a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php
index b99a0e48c31..353a8143d91 100644
--- a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php
+++ b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php
@@ -98,7 +98,7 @@ class MenuActiveTrail extends CacheCollector implements MenuActiveTrailInterface
protected function doGetActiveTrailIds($menu_name) {
// Parent ids; used both as key and value to ensure uniqueness.
// We always want all the top-level links with parent == ''.
- $active_trail = array('' => '');
+ $active_trail = ['' => ''];
// If a link in the given menu indeed matches the route, then use it to
// complete the active trail.
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkBase.php b/core/lib/Drupal/Core/Menu/MenuLinkBase.php
index 760ced22bbe..c61b5db0aa0 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkBase.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php
@@ -19,7 +19,7 @@ abstract class MenuLinkBase extends PluginBase implements MenuLinkInterface {
*
* @var array
*/
- protected $overrideAllowed = array();
+ protected $overrideAllowed = [];
/**
* {@inheritdoc}
@@ -92,14 +92,14 @@ abstract class MenuLinkBase extends PluginBase implements MenuLinkInterface {
* {@inheritdoc}
*/
public function getOptions() {
- return $this->pluginDefinition['options'] ?: array();
+ return $this->pluginDefinition['options'] ?: [];
}
/**
* {@inheritdoc}
*/
public function getMetaData() {
- return $this->pluginDefinition['metadata'] ?: array();
+ return $this->pluginDefinition['metadata'] ?: [];
}
/**
@@ -113,7 +113,7 @@ abstract class MenuLinkBase extends PluginBase implements MenuLinkInterface {
* {@inheritdoc}
*/
public function getRouteParameters() {
- return isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array();
+ return isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : [];
}
/**
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkDefault.php b/core/lib/Drupal/Core/Menu/MenuLinkDefault.php
index 0dda7e16756..80a02cdb76c 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkDefault.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkDefault.php
@@ -13,13 +13,13 @@ class MenuLinkDefault extends MenuLinkBase implements ContainerFactoryPluginInte
/**
* {@inheritdoc}
*/
- protected $overrideAllowed = array(
+ protected $overrideAllowed = [
'menu_name' => 1,
'parent' => 1,
'weight' => 1,
'expanded' => 1,
'enabled' => 1,
- );
+ ];
/**
* The static menu link service used to store updates to weight/parent etc.
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManager.php b/core/lib/Drupal/Core/Menu/MenuLinkManager.php
index 15b2e4d7c0a..e9cd165be95 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkManager.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkManager.php
@@ -26,13 +26,13 @@ class MenuLinkManager implements MenuLinkManagerInterface {
*
* @var array
*/
- protected $defaults = array(
+ protected $defaults = [
// (required) The name of the menu for this link.
'menu_name' => 'tools',
// (required) The name of the route this links to, unless it's external.
'route_name' => '',
// Parameters for route variables when generating a link.
- 'route_parameters' => array(),
+ 'route_parameters' => [],
// The external URL if this link has one (required if route_name is empty).
'url' => '',
// The static title for the menu link. If this came from a YAML definition
@@ -46,18 +46,18 @@ class MenuLinkManager implements MenuLinkManagerInterface {
// The weight of the link.
'weight' => 0,
// The default link options.
- 'options' => array(),
+ 'options' => [],
'expanded' => 0,
'enabled' => 1,
// The name of the module providing this link.
'provider' => '',
- 'metadata' => array(),
+ 'metadata' => [],
// Default class for local task implementations.
'class' => 'Drupal\Core\Menu\MenuLinkDefault',
'form_class' => 'Drupal\Core\Menu\Form\MenuLinkDefaultForm',
// The plugin ID. Set by the plugin system based on the top-level YAML key.
'id' => '',
- );
+ ];
/**
* The object that discovers plugins managed by this manager.
@@ -231,7 +231,7 @@ class MenuLinkManager implements MenuLinkManagerInterface {
* @throws \Drupal\Component\Plugin\Exception\PluginException
* If the instance cannot be created, such as if the ID is invalid.
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
return $this->getFactory()->createInstance($plugin_id, $configuration);
}
@@ -248,7 +248,7 @@ class MenuLinkManager implements MenuLinkManagerInterface {
* {@inheritdoc}
*/
public function deleteLinksInMenu($menu_name) {
- foreach ($this->treeStorage->loadByProperties(array('menu_name' => $menu_name)) as $plugin_id => $definition) {
+ foreach ($this->treeStorage->loadByProperties(['menu_name' => $menu_name]) as $plugin_id => $definition) {
$instance = $this->createInstance($plugin_id);
if ($instance->isDeletable()) {
$this->deleteInstance($instance, TRUE);
@@ -333,8 +333,8 @@ class MenuLinkManager implements MenuLinkManagerInterface {
/**
* {@inheritdoc}
*/
- public function loadLinksByRoute($route_name, array $route_parameters = array(), $menu_name = NULL) {
- $instances = array();
+ public function loadLinksByRoute($route_name, array $route_parameters = [], $menu_name = NULL) {
+ $instances = [];
$loaded = $this->treeStorage->loadByRoute($route_name, $route_parameters, $menu_name);
foreach ($loaded as $plugin_id => $definition) {
$instances[$plugin_id] = $this->createInstance($plugin_id);
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php b/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php
index c64c47f4278..d415570de63 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php
@@ -72,7 +72,7 @@ interface MenuLinkManagerInterface extends PluginManagerInterface {
* @return \Drupal\Core\Menu\MenuLinkInterface[]
* An array of instances keyed by plugin ID.
*/
- public function loadLinksByRoute($route_name, array $route_parameters = array(), $menu_name = NULL);
+ public function loadLinksByRoute($route_name, array $route_parameters = [], $menu_name = NULL);
/**
* Adds a new menu link definition to the menu tree storage.
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php
index 72e8ee9dfc3..8dd4c51c90c 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkTree.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php
@@ -107,7 +107,7 @@ class MenuLinkTree implements MenuLinkTreeInterface {
* An array containing the elements of a menu tree.
*/
protected function createInstances(array $data_tree) {
- $tree = array();
+ $tree = [];
foreach ($data_tree as $key => $element) {
$subtree = $this->createInstances($element['subtree']);
// Build a MenuLinkTreeElement out of the menu tree link definition:
@@ -202,7 +202,7 @@ class MenuLinkTree implements MenuLinkTreeInterface {
* @throws \DomainException
*/
protected function buildItems(array $tree, CacheableMetadata &$tree_access_cacheability, CacheableMetadata &$tree_link_cacheability) {
- $items = array();
+ $items = [];
foreach ($tree as $data) {
/** @var \Drupal\Core\Menu\MenuLinkInterface $link */
@@ -262,7 +262,7 @@ class MenuLinkTree implements MenuLinkTreeInterface {
$element['title'] = $link->getTitle();
$element['url'] = $link->getUrlObject();
$element['url']->setOption('set_active_class', TRUE);
- $element['below'] = $data->subtree ? $this->buildItems($data->subtree, $tree_access_cacheability, $tree_link_cacheability) : array();
+ $element['below'] = $data->subtree ? $this->buildItems($data->subtree, $tree_access_cacheability, $tree_link_cacheability) : [];
if (isset($data->options)) {
$element['url']->setOptions(NestedArray::mergeDeep($element['url']->getOptions(), $data->options));
}
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php b/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php
index e7e12c42ba5..f58dd913b24 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php
@@ -79,7 +79,7 @@ class MenuLinkTreeElement {
* \Drupal\Core\Menu\MenuLinkInterface::getOptions(), to allow menu link tree
* manipulators to add or override link options.
*/
- public $options = array();
+ public $options = [];
/**
* Constructs a new \Drupal\Core\Menu\MenuLinkTreeElement.
diff --git a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
index b112104b316..8add3b06f9a 100644
--- a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
+++ b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
@@ -54,7 +54,7 @@ class MenuParentFormSelector implements MenuParentFormSelectorInterface {
$menus = $this->getMenuOptions();
}
- $options = array();
+ $options = [];
$depth_limit = $this->getParentDepthLimit($id);
foreach ($menus as $menu_name => $menu_title) {
$options[$menu_name . ':'] = '<' . $menu_title . '>';
@@ -62,11 +62,11 @@ class MenuParentFormSelector implements MenuParentFormSelectorInterface {
$parameters = new MenuTreeParameters();
$parameters->setMaxDepth($depth_limit);
$tree = $this->menuLinkTree->load($menu_name, $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkNodeAccess'),
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkNodeAccess'],
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ];
$tree = $this->menuLinkTree->transform($tree, $manipulators);
$this->parentSelectOptionsTreeWalk($tree, $menu_name, '--', $options, $id, $depth_limit, $cacheability);
}
@@ -81,10 +81,10 @@ class MenuParentFormSelector implements MenuParentFormSelectorInterface {
$options = $this->getParentSelectOptions($id, $menus, $options_cacheability);
// If no options were found, there is nothing to select.
if ($options) {
- $element = array(
+ $element = [
'#type' => 'select',
'#options' => $options,
- );
+ ];
if (!isset($options[$menu_parent])) {
// The requested menu parent cannot be found in the menu anymore. Try
// setting it to the top level in the current menu.
@@ -93,12 +93,12 @@ class MenuParentFormSelector implements MenuParentFormSelectorInterface {
}
if (isset($options[$menu_parent])) {
// Only provide the default value if it is valid among the options.
- $element += array('#default_value' => $menu_parent);
+ $element += ['#default_value' => $menu_parent];
}
$options_cacheability->applyTo($element);
return $element;
}
- return array();
+ return [];
}
/**
@@ -183,7 +183,7 @@ class MenuParentFormSelector implements MenuParentFormSelectorInterface {
*/
protected function getMenuOptions(array $menu_names = NULL) {
$menus = $this->entityManager->getStorage('menu')->loadMultiple($menu_names);
- $options = array();
+ $options = [];
/** @var \Drupal\system\MenuInterface[] $menus */
foreach ($menus as $menu) {
$options[$menu->id()] = $menu->label();
diff --git a/core/lib/Drupal/Core/Menu/MenuTreeParameters.php b/core/lib/Drupal/Core/Menu/MenuTreeParameters.php
index cb210732833..702dcb4978a 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeParameters.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeParameters.php
@@ -50,7 +50,7 @@ class MenuTreeParameters {
*
* @var string[]
*/
- public $expandedParents = array();
+ public $expandedParents = [];
/**
* The IDs from the currently active menu link to the root of the whole tree.
@@ -62,7 +62,7 @@ class MenuTreeParameters {
*
* @var string[]
*/
- public $activeTrail = array();
+ public $activeTrail = [];
/**
* The conditions used to restrict which links are loaded.
@@ -71,7 +71,7 @@ class MenuTreeParameters {
*
* @var array
*/
- public $conditions = array();
+ public $conditions = [];
/**
* Sets a root for menu tree loading.
@@ -170,7 +170,7 @@ class MenuTreeParameters {
$this->conditions[$definition_field] = $value;
}
else {
- $this->conditions[$definition_field] = array($value, $operator);
+ $this->conditions[$definition_field] = [$value, $operator];
}
return $this;
}
diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
index 3cd0b8c6612..0b11f868837 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
@@ -55,7 +55,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
*
* @var array
*/
- protected $options = array();
+ protected $options = [];
/**
* Stores definitions that have already been loaded for better performance.
@@ -64,7 +64,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
*
* @var array
*/
- protected $definitions = array();
+ protected $definitions = [];
/**
* List of serialized fields.
@@ -83,7 +83,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
*
* @var array
*/
- protected $definitionFields = array(
+ protected $definitionFields = [
'menu_name',
'route_name',
'route_parameters',
@@ -100,7 +100,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
'class',
'form_class',
'id',
- );
+ ];
/**
* Constructs a new \Drupal\Core\Menu\MenuTreeStorage.
@@ -116,7 +116,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
* @param array $options
* (optional) Any additional database connection options to use in queries.
*/
- public function __construct(Connection $connection, CacheBackendInterface $menu_cache_backend, CacheTagsInvalidatorInterface $cache_tags_invalidator, $table, array $options = array()) {
+ public function __construct(Connection $connection, CacheBackendInterface $menu_cache_backend, CacheTagsInvalidatorInterface $cache_tags_invalidator, $table, array $options = []) {
$this->connection = $connection;
$this->menuCacheBackend = $menu_cache_backend;
$this->cacheTagsInvalidator = $cache_tags_invalidator;
@@ -135,16 +135,16 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
* {@inheritdoc}
*/
public function resetDefinitions() {
- $this->definitions = array();
+ $this->definitions = [];
}
/**
* {@inheritdoc}
*/
public function rebuild(array $definitions) {
- $links = array();
- $children = array();
- $top_links = array();
+ $links = [];
+ $children = [];
+ $top_links = [];
// Fetch the list of existing menus, in case some are not longer populated
// after the rebuild.
$before_menus = $this->getMenuNames();
@@ -214,7 +214,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
$loaded = $this->loadFullMultiple($ids);
foreach ($loaded as $id => $link) {
if ($link['has_children']) {
- $children = $this->loadByProperties(array('parent' => $id));
+ $children = $this->loadByProperties(['parent' => $id]);
foreach ($children as $child) {
$child['parent'] = $link['parent'];
$this->save($child);
@@ -286,7 +286,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
// @todo Should we just return here if the link values match the original
// values completely?
// https://www.drupal.org/node/2302137
- $affected_menus = array();
+ $affected_menus = [];
$transaction = $this->connection->startTransaction();
try {
@@ -297,9 +297,9 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
}
else {
// Generate a new mlid.
- $options = array('return' => Database::RETURN_INSERT_ID) + $this->options;
+ $options = ['return' => Database::RETURN_INSERT_ID] + $this->options;
$link['mlid'] = $this->connection->insert($this->table, $options)
- ->fields(array('id' => $link['id'], 'menu_name' => $link['menu_name']))
+ ->fields(['id' => $link['id'], 'menu_name' => $link['menu_name']])
->execute();
}
$fields = $this->preSave($link, $original);
@@ -401,7 +401,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
// It's possible the link is already deleted.
if ($item) {
$parent = $item['parent'];
- $children = $this->loadByProperties(array('parent' => $id));
+ $children = $this->loadByProperties(['parent' => $id]);
foreach ($children as $child) {
$child['parent'] = $parent;
$this->save($child);
@@ -512,18 +512,18 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
protected function moveChildren($fields, $original) {
$query = $this->connection->update($this->table, $this->options);
- $query->fields(array('menu_name' => $fields['menu_name']));
+ $query->fields(['menu_name' => $fields['menu_name']]);
- $expressions = array();
+ $expressions = [];
for ($i = 1; $i <= $fields['depth']; $i++) {
- $expressions[] = array("p$i", ":p_$i", array(":p_$i" => $fields["p$i"]));
+ $expressions[] = ["p$i", ":p_$i", [":p_$i" => $fields["p$i"]]];
}
$j = $original['depth'] + 1;
while ($i <= $this->maxDepth() && $j <= $this->maxDepth()) {
- $expressions[] = array('p' . $i++, 'p' . $j++, array());
+ $expressions[] = ['p' . $i++, 'p' . $j++, []];
}
while ($i <= $this->maxDepth()) {
- $expressions[] = array('p' . $i++, 0, array());
+ $expressions[] = ['p' . $i++, 0, []];
}
$shift = $fields['depth'] - $original['depth'];
@@ -538,7 +538,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
$query->expression($expression[0], $expression[1], $expression[2]);
}
- $query->expression('depth', 'depth + :depth', array(':depth' => $shift));
+ $query->expression('depth', 'depth + :depth', [':depth' => $shift]);
$query->condition('menu_name', $original['menu_name']);
for ($i = 1; $i <= $this->maxDepth() && $original["p$i"]; $i++) {
@@ -569,7 +569,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
}
// If we have a parent link ID, try to use that.
- $candidates = array();
+ $candidates = [];
if (isset($link['parent'])) {
$candidates[] = $link['parent'];
}
@@ -607,7 +607,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
$parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0;
$this->connection->update($this->table, $this->options)
- ->fields(array('has_children' => $parent_has_children))
+ ->fields(['has_children' => $parent_has_children])
->condition('id', $link['parent'])
->execute();
}
@@ -660,7 +660,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
/**
* {@inheritdoc}
*/
- public function loadByRoute($route_name, array $route_parameters = array(), $menu_name = NULL) {
+ public function loadByRoute($route_name, array $route_parameters = [], $menu_name = NULL) {
// Sort the route parameters so that the query string will be the same.
asort($route_parameters);
// Since this will be urlencoded, it's safe to store and match against a
@@ -711,7 +711,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
if (isset($this->definitions[$id])) {
return $this->definitions[$id];
}
- $loaded = $this->loadMultiple(array($id));
+ $loaded = $this->loadMultiple([$id]);
return isset($loaded[$id]) ? $loaded[$id] : FALSE;
}
@@ -725,8 +725,8 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
* The loaded menu link definition or an empty array if not be found.
*/
protected function loadFull($id) {
- $loaded = $this->loadFullMultiple(array($id));
- return isset($loaded[$id]) ? $loaded[$id] : array();
+ $loaded = $this->loadFullMultiple([$id]);
+ return isset($loaded[$id]) ? $loaded[$id] : [];
}
/**
@@ -761,20 +761,20 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
// @todo Consider making this dynamic based on static::MAX_DEPTH or from the
// schema if that is generated using static::MAX_DEPTH.
// https://www.drupal.org/node/2302043
- $subquery->fields($this->table, array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'));
+ $subquery->fields($this->table, ['p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9']);
$subquery->condition('id', $id);
$result = current($subquery->execute()->fetchAll(\PDO::FETCH_ASSOC));
$ids = array_filter($result);
if ($ids) {
$query = $this->connection->select($this->table, $this->options);
- $query->fields($this->table, array('id'));
+ $query->fields($this->table, ['id']);
$query->orderBy('depth', 'DESC');
$query->condition('mlid', $ids, 'IN');
// @todo Cache this result in memory if we find it is being used more
// than once per page load. https://www.drupal.org/node/2302185
return $this->safeExecuteSelect($query)->fetchAllKeyed(0, 0);
}
- return array();
+ return [];
}
/**
@@ -785,7 +785,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
// expanded links? https://www.drupal.org/node/2302187
do {
$query = $this->connection->select($this->table, $this->options);
- $query->fields($this->table, array('id'));
+ $query->fields($this->table, ['id']);
$query->condition('menu_name', $menu_name);
$query->condition('expanded', 1);
$query->condition('has_children', 1);
@@ -843,7 +843,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
else {
$links = $this->loadLinks($menu_name, $parameters);
$data['tree'] = $this->doBuildTreeData($links, $parameters->activeTrail, $parameters->minDepth);
- $data['definitions'] = array();
+ $data['definitions'] = [];
$data['route_names'] = $this->collectRoutesAndDefinitions($data['tree'], $data['definitions']);
$this->menuCacheBackend->set($tree_cid, $data, Cache::PERMANENT, ['config:system.menu.' . $menu_name]);
// The definitions were already added to $this->definitions in
@@ -880,7 +880,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
// If the custom root does not exist, we cannot load the links below it.
if (!$root) {
- return array();
+ return [];
}
// When specifying a custom root, we only want to find links whose
@@ -986,7 +986,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
* The collected route names.
*/
protected function doCollectRoutesAndDefinitions(array $tree, array &$definitions) {
- $route_names = array();
+ $route_names = [];
foreach (array_keys($tree) as $id) {
$definitions[$id] = $this->definitions[$id];
if (!empty($definition['route_name'])) {
@@ -1003,7 +1003,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
* {@inheritdoc}
*/
public function loadSubtreeData($id, $max_relative_depth = NULL) {
- $tree = array();
+ $tree = [];
$root = $this->loadFull($id);
if (!$root) {
return $tree;
@@ -1051,10 +1051,10 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
public function getAllChildIds($id) {
$root = $this->loadFull($id);
if (!$root) {
- return array();
+ return [];
}
$query = $this->connection->select($this->table, $this->options);
- $query->fields($this->table, array('id'));
+ $query->fields($this->table, ['id']);
$query->condition('menu_name', $root['menu_name']);
for ($i = 1; $i <= $root['depth']; $i++) {
$query->condition("p$i", $root["p$i"]);
@@ -1080,7 +1080,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
/**
* Prepares the data for calling $this->treeDataRecursive().
*/
- protected function doBuildTreeData(array $links, array $parents = array(), $depth = 1) {
+ protected function doBuildTreeData(array $links, array $parents = [], $depth = 1) {
// Reverse the array so we can use the more efficient array_pop() function.
$links = array_reverse($links);
return $this->treeDataRecursive($links, $parents, $depth);
@@ -1109,17 +1109,17 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
* @see \Drupal\Core\Menu\MenuTreeStorage::loadTreeData()
*/
protected function treeDataRecursive(array &$links, array $parents, $depth) {
- $tree = array();
+ $tree = [];
while ($tree_link_definition = array_pop($links)) {
- $tree[$tree_link_definition['id']] = array(
+ $tree[$tree_link_definition['id']] = [
'definition' => $this->prepareLink($tree_link_definition, TRUE),
'has_children' => $tree_link_definition['has_children'],
// We need to determine if we're on the path to root so we can later
// build the correct active trail.
'in_active_trail' => in_array($tree_link_definition['id'], $parents),
- 'subtree' => array(),
+ 'subtree' => [],
'depth' => $tree_link_definition['depth'],
- );
+ ];
// Look ahead to the next link, but leave it on the array so it's
// available to other recursive function calls if we return or build a
// sub-tree.
@@ -1202,211 +1202,211 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
* The schema API definition for the SQL storage table.
*/
protected static function schemaDefinition() {
- $schema = array(
+ $schema = [
'description' => 'Contains the menu tree hierarchy.',
- 'fields' => array(
- 'menu_name' => array(
+ 'fields' => [
+ 'menu_name' => [
'description' => "The menu name. All links with the same menu name (such as 'tools') are part of the same menu.",
'type' => 'varchar_ascii',
'length' => 32,
'not null' => TRUE,
'default' => '',
- ),
- 'mlid' => array(
+ ],
+ 'mlid' => [
'description' => 'The menu link ID (mlid) is the integer primary key.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'id' => array(
+ ],
+ 'id' => [
'description' => 'Unique machine name: the plugin ID.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
- ),
- 'parent' => array(
+ ],
+ 'parent' => [
'description' => 'The plugin ID for the parent of this link.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'route_name' => array(
+ ],
+ 'route_name' => [
'description' => 'The machine name of a defined Symfony Route this menu item represents.',
'type' => 'varchar_ascii',
'length' => 255,
- ),
- 'route_param_key' => array(
+ ],
+ 'route_param_key' => [
'description' => 'An encoded string of route parameters for loading by route.',
'type' => 'varchar',
'length' => 255,
- ),
- 'route_parameters' => array(
+ ],
+ 'route_parameters' => [
'description' => 'Serialized array of route parameters of this menu link.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
- ),
- 'url' => array(
+ ],
+ 'url' => [
'description' => 'The external path this link points to (when not using a route).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'title' => array(
+ ],
+ 'title' => [
'description' => 'The serialized title for the link. May be a TranslatableMarkup.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
- ),
- 'description' => array(
+ ],
+ 'description' => [
'description' => 'The serialized description of this link - used for admin pages and title attribute. May be a TranslatableMarkup.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
- ),
- 'class' => array(
+ ],
+ 'class' => [
'description' => 'The class for this link plugin.',
'type' => 'text',
'not null' => FALSE,
- ),
- 'options' => array(
+ ],
+ 'options' => [
'description' => 'A serialized array of URL options, such as a query string or HTML attributes.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
- ),
- 'provider' => array(
+ ],
+ 'provider' => [
'description' => 'The name of the module that generated this link.',
'type' => 'varchar_ascii',
'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
'not null' => TRUE,
'default' => 'system',
- ),
- 'enabled' => array(
+ ],
+ 'enabled' => [
'description' => 'A flag for whether the link should be rendered in menus. (0 = a disabled menu item that may be shown on admin screens, 1 = a normal, visible link)',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'small',
- ),
- 'discovered' => array(
+ ],
+ 'discovered' => [
'description' => 'A flag for whether the link was discovered, so can be purged on rebuild',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'small',
- ),
- 'expanded' => array(
+ ],
+ 'expanded' => [
'description' => 'Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'small',
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'description' => 'Link weight among links in the same menu at the same depth.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'metadata' => array(
+ ],
+ 'metadata' => [
'description' => 'A serialized array of data that may be used by the plugin instance.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
- ),
- 'has_children' => array(
+ ],
+ 'has_children' => [
'description' => 'Flag indicating whether any enabled links have this link as a parent (1 = enabled children exist, 0 = no enabled children).',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'small',
- ),
- 'depth' => array(
+ ],
+ 'depth' => [
'description' => 'The depth relative to the top level. A link with empty parent will have depth == 1.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'small',
- ),
- 'p1' => array(
+ ],
+ 'p1' => [
'description' => 'The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p2' => array(
+ ],
+ 'p2' => [
'description' => 'The second mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p3' => array(
+ ],
+ 'p3' => [
'description' => 'The third mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p4' => array(
+ ],
+ 'p4' => [
'description' => 'The fourth mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p5' => array(
+ ],
+ 'p5' => [
'description' => 'The fifth mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p6' => array(
+ ],
+ 'p6' => [
'description' => 'The sixth mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p7' => array(
+ ],
+ 'p7' => [
'description' => 'The seventh mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p8' => array(
+ ],
+ 'p8' => [
'description' => 'The eighth mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p9' => array(
+ ],
+ 'p9' => [
'description' => 'The ninth mlid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'form_class' => array(
+ ],
+ 'form_class' => [
'description' => 'meh',
'type' => 'varchar',
'length' => 255,
- ),
- ),
- 'indexes' => array(
- 'menu_parents' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'menu_parents' => [
'menu_name',
'p1',
'p2',
@@ -1417,24 +1417,24 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
'p7',
'p8',
'p9',
- ),
+ ],
// @todo Test this index for effectiveness.
// https://www.drupal.org/node/2302197
- 'menu_parent_expand_child' => array(
+ 'menu_parent_expand_child' => [
'menu_name', 'expanded',
'has_children',
- array('parent', 16),
- ),
- 'route_values' => array(
- array('route_name', 32),
- array('route_param_key', 16),
- ),
- ),
- 'primary key' => array('mlid'),
- 'unique keys' => array(
- 'id' => array('id'),
- ),
- );
+ ['parent', 16],
+ ],
+ 'route_values' => [
+ ['route_name', 32],
+ ['route_param_key', 16],
+ ],
+ ],
+ 'primary key' => ['mlid'],
+ 'unique keys' => [
+ 'id' => ['id'],
+ ],
+ ];
return $schema;
}
@@ -1459,7 +1459,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
$result = $query->execute()->fetchCol();
}
else {
- $result = array();
+ $result = [];
}
return $result;
}
diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php
index 0a580d64a39..0e36e13c40c 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php
@@ -86,7 +86,7 @@ interface MenuTreeStorageInterface {
* @return array
* An array of menu link definitions keyed by ID and ordered by depth.
*/
- public function loadByRoute($route_name, array $route_parameters = array(), $menu_name = NULL);
+ public function loadByRoute($route_name, array $route_parameters = [], $menu_name = NULL);
/**
* Saves a plugin definition to the storage.
diff --git a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php
index a2d7591c7b3..07b7526bafb 100644
--- a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php
+++ b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php
@@ -73,7 +73,7 @@ class StaticMenuLinkOverrides implements StaticMenuLinkOverridesInterface {
public function loadOverride($id) {
$all_overrides = $this->getConfig()->get('definitions');
$id = static::encodeId($id);
- return $id && isset($all_overrides[$id]) ? $all_overrides[$id] : array();
+ return $id && isset($all_overrides[$id]) ? $all_overrides[$id] : [];
}
/**
@@ -99,16 +99,16 @@ class StaticMenuLinkOverrides implements StaticMenuLinkOverridesInterface {
* {@inheritdoc}
*/
public function deleteOverride($id) {
- return $this->deleteMultipleOverrides(array($id));
+ return $this->deleteMultipleOverrides([$id]);
}
/**
* {@inheritdoc}
*/
public function loadMultipleOverrides(array $ids) {
- $result = array();
+ $result = [];
if ($ids) {
- $all_overrides = $this->getConfig()->get('definitions') ?: array();
+ $all_overrides = $this->getConfig()->get('definitions') ?: [];
foreach ($ids as $id) {
$encoded_id = static::encodeId($id);
if (isset($all_overrides[$encoded_id])) {
@@ -124,13 +124,13 @@ class StaticMenuLinkOverrides implements StaticMenuLinkOverridesInterface {
*/
public function saveOverride($id, array $definition) {
// Only allow to override a specific subset of the keys.
- $expected = array(
+ $expected = [
'menu_name' => '',
'parent' => '',
'weight' => 0,
'expanded' => FALSE,
'enabled' => FALSE,
- );
+ ];
// Filter the overrides to only those that are expected.
$definition = array_intersect_key($definition, $expected);
// Ensure all values are set.
@@ -173,7 +173,7 @@ class StaticMenuLinkOverrides implements StaticMenuLinkOverridesInterface {
* The menu plugin ID with double underscore instead of dots.
*/
protected static function encodeId($id) {
- return strtr($id, array('.' => '__', '__' => '___'));
+ return strtr($id, ['.' => '__', '__' => '___']);
}
}
diff --git a/core/lib/Drupal/Core/Menu/menu.api.php b/core/lib/Drupal/Core/Menu/menu.api.php
index ddb56734eef..12e85ee38ec 100644
--- a/core/lib/Drupal/Core/Menu/menu.api.php
+++ b/core/lib/Drupal/Core/Menu/menu.api.php
@@ -268,12 +268,12 @@ function hook_menu_links_discovered_alter(&$links) {
$links['user.logout']['title'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Logout');
// Conditionally add an additional link with a title that's not translated.
if (\Drupal::moduleHandler()->moduleExists('search')) {
- $links['menu.api.search'] = array(
+ $links['menu.api.search'] = [
'title' => \Drupal::config('system.site')->get('name'),
'route_name' => 'menu.api.search',
'description' => new \Drupal\Core\StringTranslation\TranslatableMarkup('View popular search phrases for this site.'),
'parent' => 'system.admin_reports',
- );
+ ];
}
}
@@ -308,18 +308,18 @@ function hook_menu_links_discovered_alter(&$links) {
function hook_menu_local_tasks_alter(&$data, $route_name) {
// Add a tab linking to node/add to all pages.
- $data['tabs'][0]['node.add_page'] = array(
+ $data['tabs'][0]['node.add_page'] = [
'#theme' => 'menu_local_task',
- '#link' => array(
+ '#link' => [
'title' => t('Example tab'),
'url' => Url::fromRoute('node.add_page'),
- 'localized_options' => array(
- 'attributes' => array(
+ 'localized_options' => [
+ 'attributes' => [
'title' => t('Add content'),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
}
/**
@@ -391,7 +391,7 @@ function hook_contextual_links_alter(array &$links, $group, array $route_paramet
// Dynamically use the menu name for the title of the menu_edit contextual
// link.
$menu = \Drupal::entityManager()->getStorage('menu')->load($route_parameters['menu']);
- $links['menu_edit']['title'] = t('Edit menu: @label', array('@label' => $menu->label()));
+ $links['menu_edit']['title'] = t('Edit menu: @label', ['@label' => $menu->label()]);
}
}
diff --git a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php
index 573cd49e780..67f6a89c8e0 100644
--- a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php
+++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php
@@ -65,7 +65,7 @@ class EntityConverter implements ParamConverterInterface {
// If the entity type is translatable, ensure we return the proper
// translation object for the current context.
if ($entity instanceof EntityInterface && $entity instanceof TranslatableInterface) {
- $entity = $this->entityManager->getTranslationFromContext($entity, NULL, array('operation' => 'entity_upcast'));
+ $entity = $this->entityManager->getTranslationFromContext($entity, NULL, ['operation' => 'entity_upcast']);
}
return $entity;
}
diff --git a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
index d54bd7fe18e..cad7609c83b 100644
--- a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
+++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php
@@ -18,7 +18,7 @@ class ParamConverterManager implements ParamConverterManagerInterface {
*
* @var array
*/
- protected $converters = array();
+ protected $converters = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php
index 3a31917310d..6773e798351 100644
--- a/core/lib/Drupal/Core/Path/AliasManager.php
+++ b/core/lib/Drupal/Core/Path/AliasManager.php
@@ -52,14 +52,14 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface {
*
* @var array
*/
- protected $lookupMap = array();
+ protected $lookupMap = [];
/**
* Holds an array of aliases for which no path was found.
*
* @var array
*/
- protected $noPath = array();
+ protected $noPath = [];
/**
* Holds the array of whitelisted path aliases.
@@ -73,14 +73,14 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface {
*
* @var array
*/
- protected $noAlias = array();
+ protected $noAlias = [];
/**
* Whether preloaded path lookups has already been loaded.
*
* @var array
*/
- protected $langcodePreloaded = array();
+ protected $langcodePreloaded = [];
/**
* Holds an array of previously looked up paths for the current request path.
@@ -132,7 +132,7 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface {
if ($this->cacheNeedsWriting && !empty($this->cacheKey)) {
// Start with the preloaded path lookups, so that cached entries for other
// languages will not be lost.
- $path_lookups = $this->preloadedPathLookups ?: array();
+ $path_lookups = $this->preloadedPathLookups ?: [];
foreach ($this->lookupMap as $langcode => $lookups) {
$path_lookups[$langcode] = array_keys($lookups);
if (!empty($this->noAlias[$langcode])) {
@@ -202,12 +202,12 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface {
// paths for the page from cache.
if (empty($this->langcodePreloaded[$langcode])) {
$this->langcodePreloaded[$langcode] = TRUE;
- $this->lookupMap[$langcode] = array();
+ $this->lookupMap[$langcode] = [];
// Load the cached paths that should be used for preloading. This only
// happens if a cache key has been set.
if ($this->preloadedPathLookups === FALSE) {
- $this->preloadedPathLookups = array();
+ $this->preloadedPathLookups = [];
if ($this->cacheKey) {
if ($cached = $this->cache->get($this->cacheKey)) {
$this->preloadedPathLookups = $cached->data;
@@ -258,12 +258,12 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface {
}
}
else {
- $this->lookupMap = array();
+ $this->lookupMap = [];
}
- $this->noPath = array();
- $this->noAlias = array();
- $this->langcodePreloaded = array();
- $this->preloadedPathLookups = array();
+ $this->noPath = [];
+ $this->noAlias = [];
+ $this->langcodePreloaded = [];
+ $this->preloadedPathLookups = [];
$this->cache->delete($this->cacheKey);
$this->pathAliasWhitelistRebuild($source);
}
diff --git a/core/lib/Drupal/Core/Path/AliasStorage.php b/core/lib/Drupal/Core/Path/AliasStorage.php
index 5379edad1d9..4f380125bbe 100644
--- a/core/lib/Drupal/Core/Path/AliasStorage.php
+++ b/core/lib/Drupal/Core/Path/AliasStorage.php
@@ -63,11 +63,11 @@ class AliasStorage implements AliasStorageInterface {
throw new \InvalidArgumentException(sprintf('Alias path %s has to start with a slash.', $alias));
}
- $fields = array(
+ $fields = [
'source' => $source,
'alias' => $alias,
'langcode' => $langcode,
- );
+ ];
// Insert or update the alias.
if (empty($pid)) {
@@ -99,7 +99,7 @@ class AliasStorage implements AliasStorageInterface {
// Fetch the current values so that an update hook can identify what
// exactly changed.
try {
- $original = $this->connection->query('SELECT source, alias, langcode FROM {url_alias} WHERE pid = :pid', array(':pid' => $pid))
+ $original = $this->connection->query('SELECT source, alias, langcode FROM {url_alias} WHERE pid = :pid', [':pid' => $pid])
->fetchAssoc();
}
catch (\Exception $e) {
@@ -116,7 +116,7 @@ class AliasStorage implements AliasStorageInterface {
}
if ($pid) {
// @todo Switch to using an event for this instead of a hook.
- $this->moduleHandler->invokeAll('path_' . $operation, array($fields));
+ $this->moduleHandler->invokeAll('path_' . $operation, [$fields]);
Cache::invalidateTags(['route_match']);
return $fields;
}
@@ -174,7 +174,7 @@ class AliasStorage implements AliasStorageInterface {
$deleted = FALSE;
}
// @todo Switch to using an event for this instead of a hook.
- $this->moduleHandler->invokeAll('path_delete', array($path));
+ $this->moduleHandler->invokeAll('path_delete', [$path]);
Cache::invalidateTags(['route_match']);
return $deleted;
}
@@ -313,7 +313,7 @@ class AliasStorage implements AliasStorageInterface {
*/
public function languageAliasExists() {
try {
- return (bool) $this->connection->queryRange('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED))->fetchField();
+ return (bool) $this->connection->queryRange('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, [':langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])->fetchField();
}
catch (\Exception $e) {
$this->catchException($e);
diff --git a/core/lib/Drupal/Core/Path/PathMatcher.php b/core/lib/Drupal/Core/Path/PathMatcher.php
index 2b616c2e4e7..cc4f2cccfdd 100644
--- a/core/lib/Drupal/Core/Path/PathMatcher.php
+++ b/core/lib/Drupal/Core/Path/PathMatcher.php
@@ -66,19 +66,19 @@ class PathMatcher implements PathMatcherInterface {
if (!isset($this->regexes[$patterns])) {
// Convert path settings to a regular expression.
- $to_replace = array(
+ $to_replace = [
// Replace newlines with a logical 'or'.
'/(\r\n?|\n)/',
// Quote asterisks.
'/\\\\\*/',
// Quote <front> keyword.
'/(^|\|)\\\\<front\\\\>($|\|)/',
- );
- $replacements = array(
+ ];
+ $replacements = [
'|',
'.*',
'\1' . preg_quote($this->getFrontPagePath(), '/') . '\2',
- );
+ ];
$patterns_quoted = preg_quote($patterns, '/');
$this->regexes[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
}
diff --git a/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php b/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php
index 3718663a37b..9e6d3dae619 100644
--- a/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php
+++ b/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php
@@ -22,7 +22,7 @@ class NullPathProcessorManager implements InboundPathProcessorInterface, Outboun
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
return $path;
}
diff --git a/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php b/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php
index db7d8969ae1..a5e6570ebe4 100644
--- a/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php
+++ b/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php
@@ -45,6 +45,6 @@ interface OutboundPathProcessorInterface {
* @return string
* The processed path.
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL);
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL);
}
diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php
index a067b3d6b38..b85737f3cf1 100644
--- a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php
+++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php
@@ -39,7 +39,7 @@ class PathProcessorAlias implements InboundPathProcessorInterface, OutboundPathP
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
if (empty($options['alias'])) {
$langcode = isset($options['language']) ? $options['language']->getId() : NULL;
$path = $this->aliasManager->getAliasByPath($path, $langcode);
diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php
index a800842c763..94ff1183ee3 100644
--- a/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php
+++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php
@@ -49,7 +49,7 @@ class PathProcessorFront implements InboundPathProcessorInterface, OutboundPathP
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
// The special path '<front>' links to the default front page.
if ($path === '/<front>') {
$path = '/';
diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php
index f1987f807cb..2a3181ee2ed 100644
--- a/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php
+++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php
@@ -20,7 +20,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat
* An array whose keys are priorities and whose values are arrays of path
* processor objects.
*/
- protected $inboundProcessors = array();
+ protected $inboundProcessors = [];
/**
* Holds the array of inbound processors, sorted by priority.
@@ -28,7 +28,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat
* @var array
* An array of path processor objects.
*/
- protected $sortedInbound = array();
+ protected $sortedInbound = [];
/**
@@ -38,7 +38,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat
* An array whose keys are priorities and whose values are arrays of path
* processor objects.
*/
- protected $outboundProcessors = array();
+ protected $outboundProcessors = [];
/**
* Holds the array of outbound processors, sorted by priority.
@@ -46,7 +46,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat
* @var array
* An array of path processor objects.
*/
- protected $sortedOutbound = array();
+ protected $sortedOutbound = [];
/**
* Adds an inbound processor object to the $inboundProcessors property.
@@ -58,7 +58,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat
*/
public function addInbound(InboundPathProcessorInterface $processor, $priority = 0) {
$this->inboundProcessors[$priority][] = $processor;
- $this->sortedInbound = array();
+ $this->sortedInbound = [];
}
/**
@@ -97,13 +97,13 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat
*/
public function addOutbound(OutboundPathProcessorInterface $processor, $priority = 0) {
$this->outboundProcessors[$priority][] = $processor;
- $this->sortedOutbound = array();
+ $this->sortedOutbound = [];
}
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
$processors = $this->getOutbound();
foreach ($processors as $processor) {
$path = $processor->processOutbound($path, $options, $request, $bubbleable_metadata);
@@ -132,7 +132,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat
* The processor type to sort, e.g. 'inboundProcessors'.
*/
protected function sortProcessors($type) {
- $sorted = array();
+ $sorted = [];
krsort($this->{$type});
foreach ($this->{$type} as $processors) {
diff --git a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php
index e76e27ff28e..17f889e4b18 100644
--- a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php
+++ b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php
@@ -29,7 +29,7 @@ class PhpStorageFactory {
* An instantiated storage for the specified name.
*/
static function get($name) {
- $configuration = array();
+ $configuration = [];
$overrides = Settings::get('php_storage');
if (isset($overrides[$name])) {
$configuration = $overrides[$name];
diff --git a/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php b/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php
index 3689df59615..80c0adae5cb 100644
--- a/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php
+++ b/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php
@@ -14,7 +14,7 @@ class CachedDiscoveryClearer implements CachedDiscoveryClearerInterface {
*
* @var \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface[]
*/
- protected $cachedDiscoveries = array();
+ protected $cachedDiscoveries = [];
/**
* {@inheritdoc}
diff --git a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php
index 1426562e955..52d153c3edc 100644
--- a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php
+++ b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php
@@ -105,7 +105,7 @@ trait CategorizingPluginManagerTrait {
public function getGroupedDefinitions(array $definitions = NULL, $label_key = 'label') {
/** @var \Drupal\Core\Plugin\CategorizingPluginManagerTrait|\Drupal\Component\Plugin\PluginManagerInterface $this */
$definitions = $this->getSortedDefinitions(isset($definitions) ? $definitions : $this->getDefinitions(), $label_key);
- $grouped_definitions = array();
+ $grouped_definitions = [];
foreach ($definitions as $id => $definition) {
$grouped_definitions[(string) $definition['category']][$id] = $definition;
}
diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php
index a53de3ff2e8..5c29411f32b 100644
--- a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php
+++ b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php
@@ -21,6 +21,6 @@ interface ContextAwarePluginManagerInterface extends PluginManagerInterface {
* @return array
* An array of plugin definitions.
*/
- public function getDefinitionsForContexts(array $contexts = array());
+ public function getDefinitionsForContexts(array $contexts = []);
}
diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php
index fadaebd44ea..afe2aa59e12 100644
--- a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php
+++ b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php
@@ -19,7 +19,7 @@ trait ContextAwarePluginManagerTrait {
/**
* See \Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface::getDefinitionsForContexts().
*/
- public function getDefinitionsForContexts(array $contexts = array()) {
+ public function getDefinitionsForContexts(array $contexts = []) {
return $this->contextHandler()->filterPluginDefinitionsByContexts($contexts, $this->getDefinitions());
}
diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php
index 50d8db601b2..2a13d364d7e 100644
--- a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php
+++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php
@@ -66,7 +66,7 @@ class ContextHandler implements ContextHandlerInterface {
/**
* {@inheritdoc}
*/
- public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = array()) {
+ public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = []) {
/** @var $contexts \Drupal\Core\Plugin\Context\ContextInterface[] */
$mappings += $plugin->getContextMapping();
// Loop through each of the expected contexts.
diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php
index 2a219e93788..a0d57036083 100644
--- a/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php
+++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php
@@ -75,6 +75,6 @@ interface ContextHandlerInterface {
* @throws \Drupal\Component\Plugin\Exception\ContextException
* Thrown when a context assignment was not satisfied.
*/
- public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = array());
+ public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = []);
}
diff --git a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php
index a5ef4cf8778..31ff649faff 100644
--- a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php
+++ b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php
@@ -12,7 +12,7 @@ trait ContextAwarePluginAssignmentTrait {
*
* @see \Drupal\Core\StringTranslation\StringTranslationTrait
*/
- abstract protected function t($string, array $args = array(), array $options = array());
+ abstract protected function t($string, array $args = [], array $options = []);
/**
* Wraps the context handler.
diff --git a/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php b/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php
index 1928bfb0034..3c48892ad5c 100644
--- a/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php
+++ b/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php
@@ -33,7 +33,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection {
* An associative array containing the initial configuration for each plugin
* in the collection, keyed by plugin instance ID.
*/
- protected $configurations = array();
+ protected $configurations = [];
/**
* The key within the plugin configuration that contains the plugin ID.
@@ -47,7 +47,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection {
*
* @var array
*/
- protected $originalOrder = array();
+ protected $originalOrder = [];
/**
* Constructs a new DefaultLazyPluginCollection object.
@@ -58,7 +58,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection {
* (optional) An associative array containing the initial configuration for
* each plugin in the collection, keyed by plugin instance ID.
*/
- public function __construct(PluginManagerInterface $manager, array $configurations = array()) {
+ public function __construct(PluginManagerInterface $manager, array $configurations = []) {
$this->manager = $manager;
$this->configurations = $configurations;
@@ -74,7 +74,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection {
* {@inheritdoc}
*/
protected function initializePlugin($instance_id) {
- $configuration = isset($this->configurations[$instance_id]) ? $this->configurations[$instance_id] : array();
+ $configuration = isset($this->configurations[$instance_id]) ? $this->configurations[$instance_id] : [];
if (!isset($configuration[$this->pluginKey])) {
throw new PluginNotFoundException($instance_id);
}
@@ -87,7 +87,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection {
* @return $this
*/
public function sort() {
- uasort($this->instanceIDs, array($this, 'sortHelper'));
+ uasort($this->instanceIDs, [$this, 'sortHelper']);
return $this;
}
@@ -104,7 +104,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection {
* {@inheritdoc}
*/
public function getConfiguration() {
- $instances = array();
+ $instances = [];
// Store the current order of the instances.
$current_order = $this->instanceIDs;
// Reorder the instances to match the original order, adding new instances
diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
index 8622db997ba..f9acafba801 100644
--- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
+++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
@@ -149,7 +149,7 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
* clearCachedDefinitions() method. Only use cache tags when cached plugin
* definitions should be cleared along with other, related cache entries.
*/
- public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = array()) {
+ public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = []) {
assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($cache_tags)', 'Cache Tags must be strings.');
$this->cacheBackend = $cache_backend;
$this->cacheKey = $cache_key;
@@ -291,7 +291,7 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
// plugin definition.
foreach ($definitions as $plugin_id => $plugin_definition) {
$provider = $this->extractProviderFromDefinition($plugin_definition);
- if ($provider && !in_array($provider, array('core', 'component')) && !$this->providerExists($provider)) {
+ if ($provider && !in_array($provider, ['core', 'component']) && !$this->providerExists($provider)) {
unset($definitions[$plugin_id]);
}
}
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
index 770308defb0..bbcc858c9cc 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
@@ -61,7 +61,7 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
$this->namespaceSuffix = str_replace('/', '\\', $subdir);
}
$this->rootNamespacesIterator = $root_namespaces;
- $plugin_namespaces = array();
+ $plugin_namespaces = [];
parent::__construct($plugin_namespaces, $plugin_definition_annotation_name, $annotation_namespaces);
}
@@ -113,7 +113,7 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
* {@inheritdoc}
*/
protected function getPluginNamespaces() {
- $plugin_namespaces = array();
+ $plugin_namespaces = [];
if ($this->namespaceSuffix) {
foreach ($this->rootNamespacesIterator as $namespace => $dirs) {
// Append the namespace suffix to the base namespace, to obtain the
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
index 24f5caeafa8..e366bcb2897 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
@@ -45,7 +45,7 @@ class HookDiscovery implements DiscoveryInterface {
* {@inheritdoc}
*/
public function getDefinitions() {
- $definitions = array();
+ $definitions = [];
foreach ($this->moduleHandler->getImplementations($this->hook) as $module) {
$result = $this->moduleHandler->invoke($module, $this->hook);
foreach ($result as $plugin_id => $definition) {
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php
index af250d95747..6501ce0d105 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php
@@ -55,7 +55,7 @@ class InfoHookDecorator implements DiscoveryInterface {
* Passes through all unknown calls onto the decorated object.
*/
public function __call($method, $args) {
- return call_user_func_array(array($this->decorated, $method), $args);
+ return call_user_func_array([$this->decorated, $method], $args);
}
}
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
index c149c104d13..af5630c764b 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
@@ -75,7 +75,7 @@ class YamlDiscovery implements DiscoveryInterface {
$plugins = $this->discovery->findAll();
// Flatten definitions into what's expected from plugins.
- $definitions = array();
+ $definitions = [];
foreach ($plugins as $provider => $list) {
foreach ($list as $id => $definition) {
// Add TranslatableMarkup.
@@ -92,10 +92,10 @@ class YamlDiscovery implements DiscoveryInterface {
}
}
// Add ID and provider.
- $definitions[$id] = $definition + array(
+ $definitions[$id] = $definition + [
'provider' => $provider,
'id' => $id,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php
index a061f4be3f0..e415c5b2657 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php
@@ -47,7 +47,7 @@ class YamlDiscoveryDecorator extends YamlDiscovery {
* Passes through all unknown calls onto the decorated object.
*/
public function __call($method, $args) {
- return call_user_func_array(array($this->decorated, $method), $args);
+ return call_user_func_array([$this->decorated, $method], $args);
}
}
diff --git a/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php b/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php
index 7658b42f640..7aefa5917e0 100644
--- a/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php
+++ b/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php
@@ -12,7 +12,7 @@ class ContainerFactory extends DefaultFactory {
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
diff --git a/core/lib/Drupal/Core/Plugin/PluginManagerPass.php b/core/lib/Drupal/Core/Plugin/PluginManagerPass.php
index dcacf7b5254..9d4a483ae17 100644
--- a/core/lib/Drupal/Core/Plugin/PluginManagerPass.php
+++ b/core/lib/Drupal/Core/Plugin/PluginManagerPass.php
@@ -19,7 +19,7 @@ class PluginManagerPass implements CompilerPassInterface {
foreach ($container->getDefinitions() as $service_id => $definition) {
if (strpos($service_id, 'plugin.manager.') === 0 || $definition->hasTag('plugin_manager_cache_clear')) {
if (is_subclass_of($definition->getClass(), '\Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface')) {
- $cache_clearer_definition->addMethodCall('addCachedDiscovery', array(new Reference($service_id)));
+ $cache_clearer_definition->addMethodCall('addCachedDiscovery', [new Reference($service_id)]);
}
}
}
diff --git a/core/lib/Drupal/Core/Queue/Batch.php b/core/lib/Drupal/Core/Queue/Batch.php
index a7827a992f7..1be96d877cc 100644
--- a/core/lib/Drupal/Core/Queue/Batch.php
+++ b/core/lib/Drupal/Core/Queue/Batch.php
@@ -26,7 +26,7 @@ class Batch extends DatabaseQueue {
*/
public function claimItem($lease_time = 0) {
try {
- $item = $this->connection->queryRange('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject();
+ $item = $this->connection->queryRange('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, [':name' => $this->name])->fetchObject();
if ($item) {
$item->data = unserialize($item->data);
return $item;
@@ -48,9 +48,9 @@ class Batch extends DatabaseQueue {
* An array of queue items.
*/
public function getAllItems() {
- $result = array();
+ $result = [];
try {
- $items = $this->connection->query('SELECT data FROM {queue} q WHERE name = :name ORDER BY item_id ASC', array(':name' => $this->name))->fetchAll();
+ $items = $this->connection->query('SELECT data FROM {queue} q WHERE name = :name ORDER BY item_id ASC', [':name' => $this->name])->fetchAll();
foreach ($items as $item) {
$result[] = unserialize($item->data);
}
diff --git a/core/lib/Drupal/Core/Queue/BatchMemory.php b/core/lib/Drupal/Core/Queue/BatchMemory.php
index 8245308427e..bf4ba55913f 100644
--- a/core/lib/Drupal/Core/Queue/BatchMemory.php
+++ b/core/lib/Drupal/Core/Queue/BatchMemory.php
@@ -40,7 +40,7 @@ class BatchMemory extends Memory {
* An array of queue items.
*/
public function getAllItems() {
- $result = array();
+ $result = [];
foreach ($this->queue as $item) {
$result[] = $item->data;
}
diff --git a/core/lib/Drupal/Core/Queue/DatabaseQueue.php b/core/lib/Drupal/Core/Queue/DatabaseQueue.php
index eaa67576670..710a99b4941 100644
--- a/core/lib/Drupal/Core/Queue/DatabaseQueue.php
+++ b/core/lib/Drupal/Core/Queue/DatabaseQueue.php
@@ -84,13 +84,13 @@ class DatabaseQueue implements ReliableQueueInterface, QueueGarbageCollectionInt
*/
protected function doCreateItem($data) {
$query = $this->connection->insert(static::TABLE_NAME)
- ->fields(array(
+ ->fields([
'name' => $this->name,
'data' => serialize($data),
// We cannot rely on REQUEST_TIME because many items might be created
// by a single request which takes longer than 1 second.
'created' => time(),
- ));
+ ]);
// Return the new serial ID, or FALSE on failure.
return $query->execute();
}
@@ -100,7 +100,7 @@ class DatabaseQueue implements ReliableQueueInterface, QueueGarbageCollectionInt
*/
public function numberOfItems() {
try {
- return $this->connection->query('SELECT COUNT(item_id) FROM {' . static::TABLE_NAME . '} WHERE name = :name', array(':name' => $this->name))
+ return $this->connection->query('SELECT COUNT(item_id) FROM {' . static::TABLE_NAME . '} WHERE name = :name', [':name' => $this->name])
->fetchField();
}
catch (\Exception $e) {
@@ -120,7 +120,7 @@ class DatabaseQueue implements ReliableQueueInterface, QueueGarbageCollectionInt
// are no unclaimed items left.
while (TRUE) {
try {
- $item = $this->connection->queryRange('SELECT data, created, item_id FROM {' . static::TABLE_NAME . '} q WHERE expire = 0 AND name = :name ORDER BY created, item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject();
+ $item = $this->connection->queryRange('SELECT data, created, item_id FROM {' . static::TABLE_NAME . '} q WHERE expire = 0 AND name = :name ORDER BY created, item_id ASC', 0, 1, [':name' => $this->name])->fetchObject();
}
catch (\Exception $e) {
$this->catchException($e);
@@ -136,9 +136,9 @@ class DatabaseQueue implements ReliableQueueInterface, QueueGarbageCollectionInt
// time from the lease, and will tend to reset items before the lease
// should really expire.
$update = $this->connection->update(static::TABLE_NAME)
- ->fields(array(
+ ->fields([
'expire' => time() + $lease_time,
- ))
+ ])
->condition('item_id', $item->item_id)
->condition('expire', 0);
// If there are affected rows, this update succeeded.
@@ -160,9 +160,9 @@ class DatabaseQueue implements ReliableQueueInterface, QueueGarbageCollectionInt
public function releaseItem($item) {
try {
$update = $this->connection->update(static::TABLE_NAME)
- ->fields(array(
+ ->fields([
'expire' => 0,
- ))
+ ])
->condition('item_id', $item->item_id);
return $update->execute();
}
@@ -223,9 +223,9 @@ class DatabaseQueue implements ReliableQueueInterface, QueueGarbageCollectionInt
// Reset expired items in the default queue implementation table. If that's
// not used, this will simply be a no-op.
$this->connection->update(static::TABLE_NAME)
- ->fields(array(
+ ->fields([
'expire' => 0,
- ))
+ ])
->condition('expire', 0, '<>')
->condition('expire', REQUEST_TIME, '<')
->execute();
diff --git a/core/lib/Drupal/Core/Queue/Memory.php b/core/lib/Drupal/Core/Queue/Memory.php
index b921d2c0e0c..2e4ac0f1c97 100644
--- a/core/lib/Drupal/Core/Queue/Memory.php
+++ b/core/lib/Drupal/Core/Queue/Memory.php
@@ -33,7 +33,7 @@ class Memory implements QueueInterface {
* An arbitrary string. The name of the queue to work with.
*/
public function __construct($name) {
- $this->queue = array();
+ $this->queue = [];
$this->idSequence = 0;
}
@@ -100,7 +100,7 @@ class Memory implements QueueInterface {
* {@inheritdoc}
*/
public function deleteQueue() {
- $this->queue = array();
+ $this->queue = [];
$this->idSequence = 0;
}
diff --git a/core/lib/Drupal/Core/Queue/QueueFactory.php b/core/lib/Drupal/Core/Queue/QueueFactory.php
index db493d9f980..74126ef9041 100644
--- a/core/lib/Drupal/Core/Queue/QueueFactory.php
+++ b/core/lib/Drupal/Core/Queue/QueueFactory.php
@@ -18,7 +18,7 @@ class QueueFactory implements ContainerAwareInterface {
*
* @var array
*/
- protected $queues = array();
+ protected $queues = [];
/**
* The settings object.
diff --git a/core/lib/Drupal/Core/Render/BubbleableMetadata.php b/core/lib/Drupal/Core/Render/BubbleableMetadata.php
index d1e43c9c614..33aa755ea8c 100644
--- a/core/lib/Drupal/Core/Render/BubbleableMetadata.php
+++ b/core/lib/Drupal/Core/Render/BubbleableMetadata.php
@@ -149,7 +149,7 @@ class BubbleableMetadata extends CacheableMetadata implements AttachmentsInterfa
// correctly; adding the same settings multiple times needs to behave
// idempotently.
if (!empty($a['drupalSettings']) && !empty($b['drupalSettings'])) {
- $drupalSettings = NestedArray::mergeDeepArray(array($a['drupalSettings'], $b['drupalSettings']), TRUE);
+ $drupalSettings = NestedArray::mergeDeepArray([$a['drupalSettings'], $b['drupalSettings']], TRUE);
// No need for re-merging them.
unset($a['drupalSettings']);
unset($b['drupalSettings']);
diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php
index c150519addf..e394a399465 100644
--- a/core/lib/Drupal/Core/Render/Element.php
+++ b/core/lib/Drupal/Core/Render/Element.php
@@ -74,7 +74,7 @@ class Element {
// Filter out properties from the element, leaving only children.
$count = count($elements);
- $child_weights = array();
+ $child_weights = [];
$i = 0;
$sortable = FALSE;
foreach ($elements as $key => $value) {
@@ -94,7 +94,7 @@ class Element {
// Only trigger an error if the value is not null.
// @see https://www.drupal.org/node/1283892
elseif (isset($value)) {
- trigger_error(SafeMarkup::format('"@key" is an invalid render array key', array('@key' => $key)), E_USER_ERROR);
+ trigger_error(SafeMarkup::format('"@key" is an invalid render array key', ['@key' => $key]), E_USER_ERROR);
}
}
$i++;
@@ -127,7 +127,7 @@ class Element {
* The array keys of the element's visible children.
*/
public static function getVisibleChildren(array $elements) {
- $visible_children = array();
+ $visible_children = [];
foreach (static::children($elements) as $key) {
$child = $elements[$key];
diff --git a/core/lib/Drupal/Core/Render/Element/Actions.php b/core/lib/Drupal/Core/Render/Element/Actions.php
index 1f94466d8e8..ad85401ed92 100644
--- a/core/lib/Drupal/Core/Render/Element/Actions.php
+++ b/core/lib/Drupal/Core/Render/Element/Actions.php
@@ -30,16 +30,16 @@ class Actions extends Container {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#process' => array(
+ return [
+ '#process' => [
// @todo Move this to #pre_render.
- array($class, 'preRenderActionsDropbutton'),
- array($class, 'processActions'),
- array($class, 'processContainer'),
- ),
+ [$class, 'preRenderActionsDropbutton'],
+ [$class, 'processActions'],
+ [$class, 'processContainer'],
+ ],
'#weight' => 100,
- '#theme_wrappers' => array('container'),
- );
+ '#theme_wrappers' => ['container'],
+ ];
}
/**
@@ -86,23 +86,23 @@ class Actions extends Container {
* into new #type 'dropbutton' elements.
*/
public static function preRenderActionsDropbutton(&$element, FormStateInterface $form_state, &$complete_form) {
- $dropbuttons = array();
+ $dropbuttons = [];
foreach (Element::children($element, TRUE) as $key) {
if (isset($element[$key]['#dropbutton'])) {
$dropbutton = $element[$key]['#dropbutton'];
// If there is no dropbutton for this button group yet, create one.
if (!isset($dropbuttons[$dropbutton])) {
- $dropbuttons[$dropbutton] = array(
+ $dropbuttons[$dropbutton] = [
'#type' => 'dropbutton',
- );
+ ];
}
// Add this button to the corresponding dropbutton.
// @todo Change #type 'dropbutton' to be based on item-list.html.twig
// instead of links.html.twig to avoid this preemptive rendering.
$button = \Drupal::service('renderer')->renderPlain($element[$key]);
- $dropbuttons[$dropbutton]['#links'][$key] = array(
+ $dropbuttons[$dropbutton]['#links'][$key] = [
'title' => $button,
- );
+ ];
}
}
// @todo For now, all dropbuttons appear first. Consider to invent a more
diff --git a/core/lib/Drupal/Core/Render/Element/Ajax.php b/core/lib/Drupal/Core/Render/Element/Ajax.php
index 672e4ca77fc..d22d7edf221 100644
--- a/core/lib/Drupal/Core/Render/Element/Ajax.php
+++ b/core/lib/Drupal/Core/Render/Element/Ajax.php
@@ -21,11 +21,11 @@ class Ajax extends RenderElement {
// an HTML page, so we don't provide defaults for #theme or #theme_wrappers.
// However, modules can set these properties (for example, to provide an
// HTML debugging page that displays rather than executes Ajax commands).
- return array(
+ return [
'#header' => TRUE,
- '#commands' => array(),
+ '#commands' => [],
'#error' => NULL,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Button.php b/core/lib/Drupal/Core/Render/Element/Button.php
index c5b84f078d1..63451ea060f 100644
--- a/core/lib/Drupal/Core/Render/Element/Button.php
+++ b/core/lib/Drupal/Core/Render/Element/Button.php
@@ -37,21 +37,21 @@ class Button extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#name' => 'op',
'#is_button' => TRUE,
'#executes_submit_callback' => FALSE,
'#limit_validation_errors' => FALSE,
- '#process' => array(
- array($class, 'processButton'),
- array($class, 'processAjaxForm'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderButton'),
- ),
- '#theme_wrappers' => array('input__submit'),
- );
+ '#process' => [
+ [$class, 'processButton'],
+ [$class, 'processAjaxForm'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderButton'],
+ ],
+ '#theme_wrappers' => ['input__submit'],
+ ];
}
/**
@@ -81,7 +81,7 @@ class Button extends FormElement {
*/
public static function preRenderButton($element) {
$element['#attributes']['type'] = 'submit';
- Element::setAttributes($element, array('id', 'name', 'value'));
+ Element::setAttributes($element, ['id', 'name', 'value']);
$element['#attributes']['class'][] = 'button';
if (!empty($element['#button_type'])) {
diff --git a/core/lib/Drupal/Core/Render/Element/Checkbox.php b/core/lib/Drupal/Core/Render/Element/Checkbox.php
index c9b8817044e..9092314dfde 100644
--- a/core/lib/Drupal/Core/Render/Element/Checkbox.php
+++ b/core/lib/Drupal/Core/Render/Element/Checkbox.php
@@ -30,22 +30,22 @@ class Checkbox extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#return_value' => 1,
- '#process' => array(
- array($class, 'processCheckbox'),
- array($class, 'processAjaxForm'),
- array($class, 'processGroup'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderCheckbox'),
- array($class, 'preRenderGroup'),
- ),
+ '#process' => [
+ [$class, 'processCheckbox'],
+ [$class, 'processAjaxForm'],
+ [$class, 'processGroup'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderCheckbox'],
+ [$class, 'preRenderGroup'],
+ ],
'#theme' => 'input__checkbox',
- '#theme_wrappers' => array('form_element'),
+ '#theme_wrappers' => ['form_element'],
'#title_display' => 'after',
- );
+ ];
}
/**
@@ -93,13 +93,13 @@ class Checkbox extends FormElement {
*/
public static function preRenderCheckbox($element) {
$element['#attributes']['type'] = 'checkbox';
- Element::setAttributes($element, array('id', 'name', '#return_value' => 'value'));
+ Element::setAttributes($element, ['id', 'name', '#return_value' => 'value']);
// Unchecked checkbox has #value of integer 0.
if (!empty($element['#checked'])) {
$element['#attributes']['checked'] = 'checked';
}
- static::setAttributes($element, array('form-checkbox'));
+ static::setAttributes($element, ['form-checkbox']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Checkboxes.php b/core/lib/Drupal/Core/Render/Element/Checkboxes.php
index 78108b5391e..3663cd57bb4 100644
--- a/core/lib/Drupal/Core/Render/Element/Checkboxes.php
+++ b/core/lib/Drupal/Core/Render/Element/Checkboxes.php
@@ -37,27 +37,27 @@ class Checkboxes extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
- '#process' => array(
- array($class, 'processCheckboxes'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderCompositeFormElement'),
- ),
- '#theme_wrappers' => array('checkboxes'),
- );
+ '#process' => [
+ [$class, 'processCheckboxes'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderCompositeFormElement'],
+ ],
+ '#theme_wrappers' => ['checkboxes'],
+ ];
}
/**
* Processes a checkboxes form element.
*/
public static function processCheckboxes(&$element, FormStateInterface $form_state, &$complete_form) {
- $value = is_array($element['#value']) ? $element['#value'] : array();
+ $value = is_array($element['#value']) ? $element['#value'] : [];
$element['#tree'] = TRUE;
if (count($element['#options']) > 0) {
if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
- $element['#default_value'] = array();
+ $element['#default_value'] = [];
}
$weight = 0;
foreach ($element['#options'] as $key => $choice) {
@@ -73,8 +73,8 @@ class Checkboxes extends FormElement {
// sub-elements.
$weight += 0.001;
- $element += array($key => array());
- $element[$key] += array(
+ $element += [$key => []];
+ $element[$key] += [
'#type' => 'checkbox',
'#title' => $choice,
'#return_value' => $key,
@@ -84,7 +84,7 @@ class Checkboxes extends FormElement {
// Errors should only be shown on the parent checkboxes element.
'#error_no_message' => TRUE,
'#weight' => $weight,
- );
+ ];
}
}
return $element;
@@ -95,8 +95,8 @@ class Checkboxes extends FormElement {
*/
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
if ($input === FALSE) {
- $value = array();
- $element += array('#default_value' => array());
+ $value = [];
+ $element += ['#default_value' => []];
foreach ($element['#default_value'] as $key) {
$value[$key] = $key;
}
@@ -118,7 +118,7 @@ class Checkboxes extends FormElement {
return array_combine($input, $input);
}
else {
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Color.php b/core/lib/Drupal/Core/Render/Element/Color.php
index 0f0228cc138..716a0760de1 100644
--- a/core/lib/Drupal/Core/Render/Element/Color.php
+++ b/core/lib/Drupal/Core/Render/Element/Color.php
@@ -30,20 +30,20 @@ class Color extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
- '#process' => array(
- array($class, 'processAjaxForm'),
- ),
- '#element_validate' => array(
- array($class, 'validateColor'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderColor'),
- ),
+ '#process' => [
+ [$class, 'processAjaxForm'],
+ ],
+ '#element_validate' => [
+ [$class, 'validateColor'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderColor'],
+ ],
'#theme' => 'input__color',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -63,7 +63,7 @@ class Color extends FormElement {
$form_state->setValueForElement($element, ColorUtility::rgbToHex(ColorUtility::hexToRgb($value)));
}
catch (\InvalidArgumentException $e) {
- $form_state->setError($element, t('%name must be a valid color.', array('%name' => empty($element['#title']) ? $element['#parents'][0] : $element['#title'])));
+ $form_state->setError($element, t('%name must be a valid color.', ['%name' => empty($element['#title']) ? $element['#parents'][0] : $element['#title']]));
}
}
}
@@ -80,8 +80,8 @@ class Color extends FormElement {
*/
public static function preRenderColor($element) {
$element['#attributes']['type'] = 'color';
- Element::setAttributes($element, array('id', 'name', 'value'));
- static::setAttributes($element, array('form-color'));
+ Element::setAttributes($element, ['id', 'name', 'value']);
+ static::setAttributes($element, ['form-color']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Container.php b/core/lib/Drupal/Core/Render/Element/Container.php
index eb46f20ceca..212000d7be5 100644
--- a/core/lib/Drupal/Core/Render/Element/Container.php
+++ b/core/lib/Drupal/Core/Render/Element/Container.php
@@ -45,16 +45,16 @@ class Container extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#process' => array(
- array($class, 'processGroup'),
- array($class, 'processContainer'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderGroup'),
- ),
- '#theme_wrappers' => array('container'),
- );
+ return [
+ '#process' => [
+ [$class, 'processGroup'],
+ [$class, 'processContainer'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderGroup'],
+ ],
+ '#theme_wrappers' => ['container'],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Render/Element/Date.php b/core/lib/Drupal/Core/Render/Element/Date.php
index 7a0801d9c84..11e15d8443b 100644
--- a/core/lib/Drupal/Core/Render/Element/Date.php
+++ b/core/lib/Drupal/Core/Render/Element/Date.php
@@ -88,8 +88,8 @@ class Date extends FormElement {
if (empty($element['#attributes']['type'])) {
$element['#attributes']['type'] = 'date';
}
- Element::setAttributes($element, array('id', 'name', 'type', 'min', 'max', 'step', 'value', 'size'));
- static::setAttributes($element, array('form-' . $element['#attributes']['type']));
+ Element::setAttributes($element, ['id', 'name', 'type', 'min', 'max', 'step', 'value', 'size']);
+ static::setAttributes($element, ['form-' . $element['#attributes']['type']]);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Details.php b/core/lib/Drupal/Core/Render/Element/Details.php
index 2ae6f1d8ef7..92bbb32bd1e 100644
--- a/core/lib/Drupal/Core/Render/Element/Details.php
+++ b/core/lib/Drupal/Core/Render/Element/Details.php
@@ -41,19 +41,19 @@ class Details extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#open' => FALSE,
'#value' => NULL,
- '#process' => array(
- array($class, 'processGroup'),
- array($class, 'processAjaxForm'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderDetails'),
- array($class, 'preRenderGroup'),
- ),
- '#theme_wrappers' => array('details'),
- );
+ '#process' => [
+ [$class, 'processGroup'],
+ [$class, 'processAjaxForm'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderDetails'],
+ [$class, 'preRenderGroup'],
+ ],
+ '#theme_wrappers' => ['details'],
+ ];
}
/**
@@ -67,11 +67,11 @@ class Details extends RenderElement {
* The modified element.
*/
public static function preRenderDetails($element) {
- Element::setAttributes($element, array('id'));
+ Element::setAttributes($element, ['id']);
// The .js-form-wrapper class is required for #states to treat details like
// containers.
- static::setAttributes($element, array('js-form-wrapper', 'form-wrapper'));
+ static::setAttributes($element, ['js-form-wrapper', 'form-wrapper']);
// Collapsible details.
$element['#attached']['library'][] = 'core/drupal.collapse';
diff --git a/core/lib/Drupal/Core/Render/Element/Dropbutton.php b/core/lib/Drupal/Core/Render/Element/Dropbutton.php
index 30f9755326e..682f5cce57c 100644
--- a/core/lib/Drupal/Core/Render/Element/Dropbutton.php
+++ b/core/lib/Drupal/Core/Render/Element/Dropbutton.php
@@ -46,12 +46,12 @@ class Dropbutton extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderDropbutton'),
- ),
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderDropbutton'],
+ ],
'#theme' => 'links__dropbutton',
- );
+ ];
}
/**
@@ -61,7 +61,7 @@ class Dropbutton extends RenderElement {
$element['#attached']['library'][] = 'core/drupal.dropbutton';
$element['#attributes']['class'][] = 'dropbutton';
if (!isset($element['#theme_wrappers'])) {
- $element['#theme_wrappers'] = array();
+ $element['#theme_wrappers'] = [];
}
array_unshift($element['#theme_wrappers'], 'dropbutton_wrapper');
diff --git a/core/lib/Drupal/Core/Render/Element/ElementInterface.php b/core/lib/Drupal/Core/Render/Element/ElementInterface.php
index 320a83dca6e..12cb67d3a14 100644
--- a/core/lib/Drupal/Core/Render/Element/ElementInterface.php
+++ b/core/lib/Drupal/Core/Render/Element/ElementInterface.php
@@ -47,6 +47,6 @@ interface ElementInterface extends PluginInspectionInterface {
* @param array $class
* Array of new class names to be added.
*/
- public static function setAttributes(&$element, $class = array());
+ public static function setAttributes(&$element, $class = []);
}
diff --git a/core/lib/Drupal/Core/Render/Element/Email.php b/core/lib/Drupal/Core/Render/Element/Email.php
index 247967667f0..dce2a344c49 100644
--- a/core/lib/Drupal/Core/Render/Element/Email.php
+++ b/core/lib/Drupal/Core/Render/Element/Email.php
@@ -43,25 +43,25 @@ class Email extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#size' => 60,
'#maxlength' => self::EMAIL_MAX_LENGTH,
'#autocomplete_route_name' => FALSE,
- '#process' => array(
- array($class, 'processAutocomplete'),
- array($class, 'processAjaxForm'),
- array($class, 'processPattern'),
- ),
- '#element_validate' => array(
- array($class, 'validateEmail'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderEmail'),
- ),
+ '#process' => [
+ [$class, 'processAutocomplete'],
+ [$class, 'processAjaxForm'],
+ [$class, 'processPattern'],
+ ],
+ '#element_validate' => [
+ [$class, 'validateEmail'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderEmail'],
+ ],
'#theme' => 'input__email',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -74,7 +74,7 @@ class Email extends FormElement {
$form_state->setValueForElement($element, $value);
if ($value !== '' && !\Drupal::service('email.validator')->isValid($value)) {
- $form_state->setError($element, t('The email address %mail is not valid.', array('%mail' => $value)));
+ $form_state->setError($element, t('The email address %mail is not valid.', ['%mail' => $value]));
}
}
@@ -91,8 +91,8 @@ class Email extends FormElement {
*/
public static function preRenderEmail($element) {
$element['#attributes']['type'] = 'email';
- Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
- static::setAttributes($element, array('form-email'));
+ Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']);
+ static::setAttributes($element, ['form-email']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Fieldgroup.php b/core/lib/Drupal/Core/Render/Element/Fieldgroup.php
index a1bc1eec2d2..6c73c35f6ce 100644
--- a/core/lib/Drupal/Core/Render/Element/Fieldgroup.php
+++ b/core/lib/Drupal/Core/Render/Element/Fieldgroup.php
@@ -19,9 +19,9 @@ namespace Drupal\Core\Render\Element;
class Fieldgroup extends Fieldset {
public function getInfo() {
- return array(
- '#attributes' => array('class' => array('fieldgroup')),
- ) + parent::getInfo();
+ return [
+ '#attributes' => ['class' => ['fieldgroup']],
+ ] + parent::getInfo();
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Fieldset.php b/core/lib/Drupal/Core/Render/Element/Fieldset.php
index d8cb540338e..baed3913676 100644
--- a/core/lib/Drupal/Core/Render/Element/Fieldset.php
+++ b/core/lib/Drupal/Core/Render/Element/Fieldset.php
@@ -30,17 +30,17 @@ class Fieldset extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#process' => array(
- array($class, 'processGroup'),
- array($class, 'processAjaxForm'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderGroup'),
- ),
+ return [
+ '#process' => [
+ [$class, 'processGroup'],
+ [$class, 'processAjaxForm'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderGroup'],
+ ],
'#value' => NULL,
- '#theme_wrappers' => array('fieldset'),
- );
+ '#theme_wrappers' => ['fieldset'],
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/File.php b/core/lib/Drupal/Core/Render/Element/File.php
index d37d5c7c1d8..07bd415078d 100644
--- a/core/lib/Drupal/Core/Render/Element/File.php
+++ b/core/lib/Drupal/Core/Render/Element/File.php
@@ -24,19 +24,19 @@ class File extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#multiple' => FALSE,
- '#process' => array(
- array($class, 'processFile'),
- ),
+ '#process' => [
+ [$class, 'processFile'],
+ ],
'#size' => 60,
- '#pre_render' => array(
- array($class, 'preRenderFile'),
- ),
+ '#pre_render' => [
+ [$class, 'preRenderFile'],
+ ],
'#theme' => 'input__file',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -44,7 +44,7 @@ class File extends FormElement {
*/
public static function processFile(&$element, FormStateInterface $form_state, &$complete_form) {
if ($element['#multiple']) {
- $element['#attributes'] = array('multiple' => 'multiple');
+ $element['#attributes'] = ['multiple' => 'multiple'];
$element['#name'] .= '[]';
}
return $element;
@@ -66,8 +66,8 @@ class File extends FormElement {
*/
public static function preRenderFile($element) {
$element['#attributes']['type'] = 'file';
- Element::setAttributes($element, array('id', 'name', 'size'));
- static::setAttributes($element, array('js-form-file', 'form-file'));
+ Element::setAttributes($element, ['id', 'name', 'size']);
+ static::setAttributes($element, ['js-form-file', 'form-file']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Form.php b/core/lib/Drupal/Core/Render/Element/Form.php
index 61739caf071..d81c2545c9d 100644
--- a/core/lib/Drupal/Core/Render/Element/Form.php
+++ b/core/lib/Drupal/Core/Render/Element/Form.php
@@ -13,10 +13,10 @@ class Form extends RenderElement {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#method' => 'post',
- '#theme_wrappers' => array('form'),
- );
+ '#theme_wrappers' => ['form'],
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/FormElement.php b/core/lib/Drupal/Core/Render/Element/FormElement.php
index 513f103df9f..0168d2beb96 100644
--- a/core/lib/Drupal/Core/Render/Element/FormElement.php
+++ b/core/lib/Drupal/Core/Render/Element/FormElement.php
@@ -108,7 +108,7 @@ abstract class FormElement extends RenderElement implements FormElementInterface
public static function processPattern(&$element, FormStateInterface $form_state, &$complete_form) {
if (isset($element['#pattern']) && !isset($element['#attributes']['pattern'])) {
$element['#attributes']['pattern'] = $element['#pattern'];
- $element['#element_validate'][] = array(get_called_class(), 'validatePattern');
+ $element['#element_validate'][] = [get_called_class(), 'validatePattern'];
}
return $element;
@@ -136,7 +136,7 @@ abstract class FormElement extends RenderElement implements FormElementInterface
$pattern = '{^(?:' . $element['#pattern'] . ')$}';
if (!preg_match($pattern, $element['#value'])) {
- $form_state->setError($element, t('%name field is not in the right format.', array('%name' => $element['#title'])));
+ $form_state->setError($element, t('%name field is not in the right format.', ['%name' => $element['#title']]));
}
}
}
@@ -178,7 +178,7 @@ abstract class FormElement extends RenderElement implements FormElementInterface
$access = FALSE;
if (!empty($element['#autocomplete_route_name'])) {
- $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : array();
+ $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : [];
$url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->toString(TRUE);
/** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */
$access_manager = \Drupal::service('access_manager');
diff --git a/core/lib/Drupal/Core/Render/Element/Hidden.php b/core/lib/Drupal/Core/Render/Element/Hidden.php
index 8e1f8560a54..6fb62ffc995 100644
--- a/core/lib/Drupal/Core/Render/Element/Hidden.php
+++ b/core/lib/Drupal/Core/Render/Element/Hidden.php
@@ -31,16 +31,16 @@ class Hidden extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
- '#process' => array(
- array($class, 'processAjaxForm'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderHidden'),
- ),
+ '#process' => [
+ [$class, 'processAjaxForm'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderHidden'],
+ ],
'#theme' => 'input__hidden',
- );
+ ];
}
/**
@@ -55,7 +55,7 @@ class Hidden extends FormElement {
*/
public static function preRenderHidden($element) {
$element['#attributes']['type'] = 'hidden';
- Element::setAttributes($element, array('name', 'value'));
+ Element::setAttributes($element, ['name', 'value']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Html.php b/core/lib/Drupal/Core/Render/Element/Html.php
index 0a83d560935..fb79b94e9fe 100644
--- a/core/lib/Drupal/Core/Render/Element/Html.php
+++ b/core/lib/Drupal/Core/Render/Element/Html.php
@@ -13,13 +13,13 @@ class Html extends RenderElement {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#theme' => 'html',
// HTML5 Shiv
- '#attached' => array(
- 'library' => array('core/html5shiv'),
- ),
- );
+ '#attached' => [
+ 'library' => ['core/html5shiv'],
+ ],
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/HtmlTag.php b/core/lib/Drupal/Core/Render/Element/HtmlTag.php
index 1d71350fafc..0b9ac91e4bc 100644
--- a/core/lib/Drupal/Core/Render/Element/HtmlTag.php
+++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php
@@ -38,24 +38,24 @@ class HtmlTag extends RenderElement {
* @see http://www.w3.org/TR/html5/syntax.html#syntax-start-tag
* @see http://www.w3.org/TR/html5/syntax.html#void-elements
*/
- static protected $voidElements = array(
+ static protected $voidElements = [
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',
- );
+ ];
/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderConditionalComments'),
- array($class, 'preRenderHtmlTag'),
- ),
- '#attributes' => array(),
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderConditionalComments'],
+ [$class, 'preRenderHtmlTag'],
+ ],
+ '#attributes' => [],
'#value' => NULL,
- );
+ ];
}
/**
@@ -132,11 +132,11 @@ class HtmlTag extends RenderElement {
* added to '#prefix' and '#suffix'.
*/
public static function preRenderConditionalComments($element) {
- $browsers = isset($element['#browsers']) ? $element['#browsers'] : array();
- $browsers += array(
+ $browsers = isset($element['#browsers']) ? $element['#browsers'] : [];
+ $browsers += [
'IE' => TRUE,
'!IE' => TRUE,
- );
+ ];
// If rendering in all browsers, no need for conditional comments.
if ($browsers['IE'] === TRUE && $browsers['!IE']) {
diff --git a/core/lib/Drupal/Core/Render/Element/ImageButton.php b/core/lib/Drupal/Core/Render/Element/ImageButton.php
index a7d8be37631..2404ba8084c 100644
--- a/core/lib/Drupal/Core/Render/Element/ImageButton.php
+++ b/core/lib/Drupal/Core/Render/Element/ImageButton.php
@@ -19,12 +19,12 @@ class ImageButton extends Submit {
$info = parent::getInfo();
unset($info['name']);
- return array(
+ return [
'#return_value' => TRUE,
'#has_garbage_value' => TRUE,
'#src' => NULL,
- '#theme_wrappers' => array('input__image_button'),
- ) + $info;
+ '#theme_wrappers' => ['input__image_button'],
+ ] + $info;
}
/**
@@ -68,7 +68,7 @@ class ImageButton extends Submit {
*/
public static function preRenderButton($element) {
$element['#attributes']['type'] = 'image';
- Element::setAttributes($element, array('id', 'name', 'value'));
+ Element::setAttributes($element, ['id', 'name', 'value']);
$element['#attributes']['src'] = file_url_transform_relative(file_create_url($element['#src']));
if (!empty($element['#title'])) {
diff --git a/core/lib/Drupal/Core/Render/Element/InlineTemplate.php b/core/lib/Drupal/Core/Render/Element/InlineTemplate.php
index 2fbdf433fdb..0005ea2740f 100644
--- a/core/lib/Drupal/Core/Render/Element/InlineTemplate.php
+++ b/core/lib/Drupal/Core/Render/Element/InlineTemplate.php
@@ -30,13 +30,13 @@ class InlineTemplate extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderInlineTemplate'),
- ),
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderInlineTemplate'],
+ ],
'#template' => '',
- '#context' => array(),
- );
+ '#context' => [],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Render/Element/Item.php b/core/lib/Drupal/Core/Render/Element/Item.php
index b952da1e90f..6c282b3798b 100644
--- a/core/lib/Drupal/Core/Render/Element/Item.php
+++ b/core/lib/Drupal/Core/Render/Element/Item.php
@@ -17,7 +17,7 @@ class Item extends FormElement {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
// Forms that show author fields to both anonymous and authenticated users
// need to dynamically switch between #type 'textfield' and #type 'item'
// to automatically take over the authenticated user's information.
@@ -25,8 +25,8 @@ class Item extends FormElement {
// assigned by Form API based on the #default_value or #value properties.
'#input' => TRUE,
'#markup' => '',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Label.php b/core/lib/Drupal/Core/Render/Element/Label.php
index 1dbaa70c8dd..28eb6a0d4bb 100644
--- a/core/lib/Drupal/Core/Render/Element/Label.php
+++ b/core/lib/Drupal/Core/Render/Element/Label.php
@@ -17,9 +17,9 @@ class Label extends RenderElement {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#theme' => 'form_element_label',
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/LanguageSelect.php b/core/lib/Drupal/Core/Render/Element/LanguageSelect.php
index 0e6011d3053..bd0a3c0a40f 100644
--- a/core/lib/Drupal/Core/Render/Element/LanguageSelect.php
+++ b/core/lib/Drupal/Core/Render/Element/LanguageSelect.php
@@ -21,10 +21,10 @@ class LanguageSelect extends FormElement {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#input' => TRUE,
'#default_value' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php
index 3888c7938d0..216f068a49d 100644
--- a/core/lib/Drupal/Core/Render/Element/Link.php
+++ b/core/lib/Drupal/Core/Render/Element/Link.php
@@ -33,11 +33,11 @@ class Link extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderLink'),
- ),
- );
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderLink'],
+ ],
+ ];
}
/**
@@ -58,12 +58,12 @@ class Link extends RenderElement {
public static function preRenderLink($element) {
// By default, link options to pass to the link generator are normally set
// in #options.
- $element += array('#options' => array());
+ $element += ['#options' => []];
// However, within the scope of renderable elements, #attributes is a valid
// way to specify attributes, too. Take them into account, but do not override
// attributes from #options.
if (isset($element['#attributes'])) {
- $element['#options'] += array('attributes' => array());
+ $element['#options'] += ['attributes' => []];
$element['#options']['attributes'] += $element['#attributes'];
}
diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php
index 6cf455942a0..ace452b0725 100644
--- a/core/lib/Drupal/Core/Render/Element/MachineName.php
+++ b/core/lib/Drupal/Core/Render/Element/MachineName.php
@@ -75,27 +75,27 @@ class MachineName extends Textfield {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#default_value' => NULL,
'#required' => TRUE,
'#maxlength' => 64,
'#size' => 60,
'#autocomplete_route_name' => FALSE,
- '#process' => array(
- array($class, 'processMachineName'),
- array($class, 'processAutocomplete'),
- array($class, 'processAjaxForm'),
- ),
- '#element_validate' => array(
- array($class, 'validateMachineName'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderTextfield'),
- ),
+ '#process' => [
+ [$class, 'processMachineName'],
+ [$class, 'processAutocomplete'],
+ [$class, 'processAjaxForm'],
+ ],
+ '#element_validate' => [
+ [$class, 'validateMachineName'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderTextfield'],
+ ],
'#theme' => 'input__textfield',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -128,19 +128,19 @@ class MachineName extends Textfield {
$language = \Drupal::languageManager()->getCurrentLanguage();
// Apply default form element properties.
- $element += array(
+ $element += [
'#title' => t('Machine-readable name'),
'#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
- '#machine_name' => array(),
+ '#machine_name' => [],
'#field_prefix' => '',
'#field_suffix' => '',
'#suffix' => '',
- );
+ ];
// A form element that only wants to set one #machine_name property (usually
// 'source' only) would leave all other properties undefined, if the defaults
// were defined by an element plugin. Therefore, we apply the defaults here.
- $element['#machine_name'] += array(
- 'source' => array('label'),
+ $element['#machine_name'] += [
+ 'source' => ['label'],
'target' => '#' . $element['#id'],
'label' => t('Machine name'),
'replace_pattern' => '[^a-z0-9_]+',
@@ -148,14 +148,14 @@ class MachineName extends Textfield {
'standalone' => FALSE,
'field_prefix' => $element['#field_prefix'],
'field_suffix' => $element['#field_suffix'],
- );
+ ];
// By default, machine names are restricted to Latin alphanumeric characters.
// So, default to LTR directionality.
if (!isset($element['#attributes'])) {
- $element['#attributes'] = array();
+ $element['#attributes'] = [];
}
- $element['#attributes'] += array('dir' => LanguageInterface::DIRECTION_LTR);
+ $element['#attributes'] += ['dir' => LanguageInterface::DIRECTION_LTR];
// The source element defaults to array('name'), but may have been overridden.
if (empty($element['#machine_name']['source'])) {
@@ -180,10 +180,10 @@ class MachineName extends Textfield {
else {
// Append a field suffix to the source form element, which will contain
// the live preview of the machine name.
- $source += array('#field_suffix' => '');
+ $source += ['#field_suffix' => ''];
$source['#field_suffix'] = $source['#field_suffix'] . ' <small id="' . $suffix_id . '">&nbsp;</small>';
- $parents = array_merge($element['#machine_name']['source'], array('#field_suffix'));
+ $parents = array_merge($element['#machine_name']['source'], ['#field_suffix']);
NestedArray::setValue($form_state->getCompleteForm(), $parents, $source['#field_suffix']);
}
diff --git a/core/lib/Drupal/Core/Render/Element/MoreLink.php b/core/lib/Drupal/Core/Render/Element/MoreLink.php
index 7c042b22cc4..596c66068ae 100644
--- a/core/lib/Drupal/Core/Render/Element/MoreLink.php
+++ b/core/lib/Drupal/Core/Render/Element/MoreLink.php
@@ -27,14 +27,14 @@ class MoreLink extends Link {
*/
public function getInfo() {
$info = parent::getInfo();
- return array(
+ return [
'#title' => $this->t('More'),
- '#theme_wrappers' => array(
- 'container' => array(
- '#attributes' => array('class' => array('more-link')),
- ),
- ),
- ) + $info;
+ '#theme_wrappers' => [
+ 'container' => [
+ '#attributes' => ['class' => ['more-link']],
+ ],
+ ],
+ ] + $info;
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Number.php b/core/lib/Drupal/Core/Render/Element/Number.php
index 788aa1e6c77..b7b25241260 100644
--- a/core/lib/Drupal/Core/Render/Element/Number.php
+++ b/core/lib/Drupal/Core/Render/Element/Number.php
@@ -38,21 +38,21 @@ class Number extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#step' => 1,
- '#process' => array(
- array($class, 'processAjaxForm'),
- ),
- '#element_validate' => array(
- array($class, 'validateNumber'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderNumber'),
- ),
+ '#process' => [
+ [$class, 'processAjaxForm'],
+ ],
+ '#element_validate' => [
+ [$class, 'validateNumber'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderNumber'],
+ ],
'#theme' => 'input__number',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -70,18 +70,18 @@ class Number extends FormElement {
// Ensure the input is numeric.
if (!is_numeric($value)) {
- $form_state->setError($element, t('%name must be a number.', array('%name' => $name)));
+ $form_state->setError($element, t('%name must be a number.', ['%name' => $name]));
return;
}
// Ensure that the input is greater than the #min property, if set.
if (isset($element['#min']) && $value < $element['#min']) {
- $form_state->setError($element, t('%name must be higher than or equal to %min.', array('%name' => $name, '%min' => $element['#min'])));
+ $form_state->setError($element, t('%name must be higher than or equal to %min.', ['%name' => $name, '%min' => $element['#min']]));
}
// Ensure that the input is less than the #max property, if set.
if (isset($element['#max']) && $value > $element['#max']) {
- $form_state->setError($element, t('%name must be lower than or equal to %max.', array('%name' => $name, '%max' => $element['#max'])));
+ $form_state->setError($element, t('%name must be lower than or equal to %max.', ['%name' => $name, '%max' => $element['#max']]));
}
if (isset($element['#step']) && strtolower($element['#step']) != 'any') {
@@ -90,7 +90,7 @@ class Number extends FormElement {
$offset = isset($element['#min']) ? $element['#min'] : 0.0;
if (!NumberUtility::validStep($value, $element['#step'], $offset)) {
- $form_state->setError($element, t('%name is not a valid number.', array('%name' => $name)));
+ $form_state->setError($element, t('%name is not a valid number.', ['%name' => $name]));
}
}
}
@@ -108,8 +108,8 @@ class Number extends FormElement {
*/
public static function preRenderNumber($element) {
$element['#attributes']['type'] = 'number';
- Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max', 'placeholder', 'size'));
- static::setAttributes($element, array('form-number'));
+ Element::setAttributes($element, ['id', 'name', 'value', 'step', 'min', 'max', 'placeholder', 'size']);
+ static::setAttributes($element, ['form-number']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Operations.php b/core/lib/Drupal/Core/Render/Element/Operations.php
index a0c972836aa..3a53cd7030b 100644
--- a/core/lib/Drupal/Core/Render/Element/Operations.php
+++ b/core/lib/Drupal/Core/Render/Element/Operations.php
@@ -19,9 +19,9 @@ class Operations extends Dropbutton {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#theme' => 'links__dropbutton__operations',
- ) + parent::getInfo();
+ ] + parent::getInfo();
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Page.php b/core/lib/Drupal/Core/Render/Element/Page.php
index 7aeef85fe6a..c7a4e070c3d 100644
--- a/core/lib/Drupal/Core/Render/Element/Page.php
+++ b/core/lib/Drupal/Core/Render/Element/Page.php
@@ -15,10 +15,10 @@ class Page extends RenderElement {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#theme' => 'page',
'#title' => '',
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Password.php b/core/lib/Drupal/Core/Render/Element/Password.php
index 06d5532e550..4ba2058397d 100644
--- a/core/lib/Drupal/Core/Render/Element/Password.php
+++ b/core/lib/Drupal/Core/Render/Element/Password.php
@@ -32,20 +32,20 @@ class Password extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#size' => 60,
'#maxlength' => 128,
- '#process' => array(
- array($class, 'processAjaxForm'),
- array($class, 'processPattern'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderPassword'),
- ),
+ '#process' => [
+ [$class, 'processAjaxForm'],
+ [$class, 'processPattern'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderPassword'],
+ ],
'#theme' => 'input__password',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -61,8 +61,8 @@ class Password extends FormElement {
*/
public static function preRenderPassword($element) {
$element['#attributes']['type'] = 'password';
- Element::setAttributes($element, array('id', 'name', 'size', 'maxlength', 'placeholder'));
- static::setAttributes($element, array('form-text'));
+ Element::setAttributes($element, ['id', 'name', 'size', 'maxlength', 'placeholder']);
+ static::setAttributes($element, ['form-text']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php
index 0d5e0e2865a..07c31490f4d 100644
--- a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php
+++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php
@@ -33,14 +33,14 @@ class PasswordConfirm extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#markup' => '',
- '#process' => array(
- array($class, 'processPasswordConfirm'),
- ),
- '#theme_wrappers' => array('form_element'),
- );
+ '#process' => [
+ [$class, 'processPasswordConfirm'],
+ ],
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -68,23 +68,23 @@ class PasswordConfirm extends FormElement {
* Expand a password_confirm field into two text boxes.
*/
public static function processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form) {
- $element['pass1'] = array(
+ $element['pass1'] = [
'#type' => 'password',
'#title' => t('Password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
'#required' => $element['#required'],
- '#attributes' => array('class' => array('password-field', 'js-password-field')),
+ '#attributes' => ['class' => ['password-field', 'js-password-field']],
'#error_no_message' => TRUE,
- );
- $element['pass2'] = array(
+ ];
+ $element['pass2'] = [
'#type' => 'password',
'#title' => t('Confirm password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
'#required' => $element['#required'],
- '#attributes' => array('class' => array('password-confirm', 'js-password-confirm')),
+ '#attributes' => ['class' => ['password-confirm', 'js-password-confirm']],
'#error_no_message' => TRUE,
- );
- $element['#element_validate'] = array(array(get_called_class(), 'validatePasswordConfirm'));
+ ];
+ $element['#element_validate'] = [[get_called_class(), 'validatePasswordConfirm']];
$element['#tree'] = TRUE;
if (isset($element['#size'])) {
diff --git a/core/lib/Drupal/Core/Render/Element/PathElement.php b/core/lib/Drupal/Core/Render/Element/PathElement.php
index ee466ef559c..b08dbc7ea2f 100644
--- a/core/lib/Drupal/Core/Render/Element/PathElement.php
+++ b/core/lib/Drupal/Core/Render/Element/PathElement.php
@@ -38,9 +38,9 @@ class PathElement extends Textfield {
$class = get_class($this);
$info['#validate_path'] = TRUE;
$info['#convert_path'] = self::CONVERT_ROUTE;
- $info['#element_validate'] = array(
- array($class, 'validateMatchedPath'),
- );
+ $info['#element_validate'] = [
+ [$class, 'validateMatchedPath'],
+ ];
return $info;
}
@@ -73,10 +73,10 @@ class PathElement extends Textfield {
// We do the value conversion here whilst the Url object is in scope
// after validation has occurred.
if ($element['#convert_path'] == self::CONVERT_ROUTE) {
- $form_state->setValueForElement($element, array(
+ $form_state->setValueForElement($element, [
'route_name' => $url->getRouteName(),
'route_parameters' => $url->getRouteParameters(),
- ));
+ ]);
return;
}
elseif ($element['#convert_path'] == self::CONVERT_URL) {
@@ -84,9 +84,9 @@ class PathElement extends Textfield {
return;
}
}
- $form_state->setError($element, t('This path does not exist or you do not have permission to link to %path.', array(
+ $form_state->setError($element, t('This path does not exist or you do not have permission to link to %path.', [
'%path' => $element['#value'],
- )));
+ ]));
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/Radio.php b/core/lib/Drupal/Core/Render/Element/Radio.php
index ae20284b9f7..8687a9dcfc9 100644
--- a/core/lib/Drupal/Core/Render/Element/Radio.php
+++ b/core/lib/Drupal/Core/Render/Element/Radio.php
@@ -22,19 +22,19 @@ class Radio extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#default_value' => NULL,
- '#process' => array(
- array($class, 'processAjaxForm'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderRadio'),
- ),
+ '#process' => [
+ [$class, 'processAjaxForm'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderRadio'],
+ ],
'#theme' => 'input__radio',
- '#theme_wrappers' => array('form_element'),
+ '#theme_wrappers' => ['form_element'],
'#title_display' => 'after',
- );
+ ];
}
/**
@@ -52,12 +52,12 @@ class Radio extends FormElement {
*/
public static function preRenderRadio($element) {
$element['#attributes']['type'] = 'radio';
- Element::setAttributes($element, array('id', 'name', '#return_value' => 'value'));
+ Element::setAttributes($element, ['id', 'name', '#return_value' => 'value']);
if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
$element['#attributes']['checked'] = 'checked';
}
- static::setAttributes($element, array('form-radio'));
+ static::setAttributes($element, ['form-radio']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Radios.php b/core/lib/Drupal/Core/Render/Element/Radios.php
index e7179f479c2..2c9797a3c13 100644
--- a/core/lib/Drupal/Core/Render/Element/Radios.php
+++ b/core/lib/Drupal/Core/Render/Element/Radios.php
@@ -37,16 +37,16 @@ class Radios extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
- '#process' => array(
- array($class, 'processRadios'),
- ),
- '#theme_wrappers' => array('radios'),
- '#pre_render' => array(
- array($class, 'preRenderCompositeFormElement'),
- ),
- );
+ '#process' => [
+ [$class, 'processRadios'],
+ ],
+ '#theme_wrappers' => ['radios'],
+ '#pre_render' => [
+ [$class, 'preRenderCompositeFormElement'],
+ ],
+ ];
}
/**
@@ -61,11 +61,11 @@ class Radios extends FormElement {
// sub-elements.
$weight += 0.001;
- $element += array($key => array());
+ $element += [$key => []];
// Generate the parents as the autogenerator does, so we will have a
// unique id for each radio button.
- $parents_for_id = array_merge($element['#parents'], array($key));
- $element[$key] += array(
+ $parents_for_id = array_merge($element['#parents'], [$key]);
+ $element[$key] += [
'#type' => 'radio',
'#title' => $choice,
// The key is sanitized in Drupal\Core\Template\Attribute during output
@@ -81,7 +81,7 @@ class Radios extends FormElement {
// Errors should only be shown on the parent radios element.
'#error_no_message' => TRUE,
'#weight' => $weight,
- );
+ ];
}
}
return $element;
diff --git a/core/lib/Drupal/Core/Render/Element/Range.php b/core/lib/Drupal/Core/Render/Element/Range.php
index d28d787c2ac..24595abdd69 100644
--- a/core/lib/Drupal/Core/Render/Element/Range.php
+++ b/core/lib/Drupal/Core/Render/Element/Range.php
@@ -35,14 +35,14 @@ class Range extends Number {
public function getInfo() {
$info = parent::getInfo();
$class = get_class($this);
- return array(
+ return [
'#min' => 0,
'#max' => 100,
- '#pre_render' => array(
- array($class, 'preRenderRange'),
- ),
+ '#pre_render' => [
+ [$class, 'preRenderRange'],
+ ],
'#theme' => 'input__range',
- ) + $info;
+ ] + $info;
}
/**
@@ -58,8 +58,8 @@ class Range extends Number {
*/
public static function preRenderRange($element) {
$element['#attributes']['type'] = 'range';
- Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max'));
- static::setAttributes($element, array('form-range'));
+ Element::setAttributes($element, ['id', 'name', 'value', 'step', 'min', 'max']);
+ static::setAttributes($element, ['form-range']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php
index 1f39e1050ea..243a9af7671 100644
--- a/core/lib/Drupal/Core/Render/Element/RenderElement.php
+++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php
@@ -126,10 +126,10 @@ abstract class RenderElement extends PluginBase implements ElementInterface {
/**
* {@inheritdoc}
*/
- public static function setAttributes(&$element, $class = array()) {
+ public static function setAttributes(&$element, $class = []) {
if (!empty($class)) {
if (!isset($element['#attributes']['class'])) {
- $element['#attributes']['class'] = array();
+ $element['#attributes']['class'] = [];
}
$element['#attributes']['class'] = array_merge($element['#attributes']['class'], $class);
}
@@ -398,7 +398,7 @@ abstract class RenderElement extends PluginBase implements ElementInterface {
// Convert a simple #ajax['progress'] string into an array.
if (isset($settings['progress']) && is_string($settings['progress'])) {
- $settings['progress'] = array('type' => $settings['progress']);
+ $settings['progress'] = ['type' => $settings['progress']];
}
// Change progress path to a full URL.
if (isset($settings['progress']['url']) && $settings['progress']['url'] instanceof Url) {
diff --git a/core/lib/Drupal/Core/Render/Element/Search.php b/core/lib/Drupal/Core/Render/Element/Search.php
index 45333c5da41..01db3b7ecc4 100644
--- a/core/lib/Drupal/Core/Render/Element/Search.php
+++ b/core/lib/Drupal/Core/Render/Element/Search.php
@@ -26,21 +26,21 @@ class Search extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#size' => 60,
'#maxlength' => 128,
'#autocomplete_route_name' => FALSE,
- '#process' => array(
- array($class, 'processAutocomplete'),
- array($class, 'processAjaxForm'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderSearch'),
- ),
+ '#process' => [
+ [$class, 'processAutocomplete'],
+ [$class, 'processAjaxForm'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderSearch'],
+ ],
'#theme' => 'input__search',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -56,8 +56,8 @@ class Search extends FormElement {
*/
public static function preRenderSearch($element) {
$element['#attributes']['type'] = 'search';
- Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
- static::setAttributes($element, array('form-search'));
+ Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']);
+ static::setAttributes($element, ['form-search']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Select.php b/core/lib/Drupal/Core/Render/Element/Select.php
index b1e0f4ab686..300c244fc12 100644
--- a/core/lib/Drupal/Core/Render/Element/Select.php
+++ b/core/lib/Drupal/Core/Render/Element/Select.php
@@ -65,20 +65,20 @@ class Select extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#multiple' => FALSE,
- '#process' => array(
- array($class, 'processSelect'),
- array($class, 'processAjaxForm'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderSelect'),
- ),
+ '#process' => [
+ [$class, 'processSelect'],
+ [$class, 'processAjaxForm'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderSelect'],
+ ],
'#theme' => 'select',
- '#theme_wrappers' => array('form_element'),
- '#options' => array(),
- );
+ '#theme_wrappers' => ['form_element'],
+ '#options' => [],
+ ];
}
/**
@@ -118,14 +118,14 @@ class Select extends FormElement {
// make a choice. Also, if there's a value for #empty_value or
// #empty_option, then add an option that represents emptiness.
if (($required && !isset($element['#default_value'])) || isset($element['#empty_value']) || isset($element['#empty_option'])) {
- $element += array(
+ $element += [
'#empty_value' => '',
'#empty_option' => $required ? t('- Select -') : t('- None -'),
- );
+ ];
// The empty option is prepended to #options and purposively not merged
// to prevent another option in #options mistakenly using the same value
// as #empty_value.
- $empty_option = array($element['#empty_value'] => $element['#empty_option']);
+ $empty_option = [$element['#empty_value'] => $element['#empty_option']];
$element['#options'] = $empty_option + $element['#options'];
}
}
@@ -142,10 +142,10 @@ class Select extends FormElement {
// unselected. A disabled multi-select always submits NULL, and the
// default value should be used.
if (empty($element['#disabled'])) {
- return (is_array($input)) ? array_combine($input, $input) : array();
+ return (is_array($input)) ? array_combine($input, $input) : [];
}
else {
- return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : array();
+ return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : [];
}
}
// Non-multiple select elements may have an empty option prepended to them
@@ -167,8 +167,8 @@ class Select extends FormElement {
* Prepares a select render element.
*/
public static function preRenderSelect($element) {
- Element::setAttributes($element, array('id', 'name', 'size'));
- static::setAttributes($element, array('form-select'));
+ Element::setAttributes($element, ['id', 'name', 'size']);
+ static::setAttributes($element, ['form-select']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Submit.php b/core/lib/Drupal/Core/Render/Element/Submit.php
index 4fa52bd1f0d..4ac7685a599 100644
--- a/core/lib/Drupal/Core/Render/Element/Submit.php
+++ b/core/lib/Drupal/Core/Render/Element/Submit.php
@@ -32,9 +32,9 @@ class Submit extends Button {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#executes_submit_callback' => TRUE,
- ) + parent::getInfo();
+ ] + parent::getInfo();
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
index 455113d4bf4..89f39a8460c 100644
--- a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
+++ b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
@@ -24,17 +24,17 @@ class SystemCompactLink extends Link {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderCompactLink'),
- array($class, 'preRenderLink'),
- ),
- '#theme_wrappers' => array(
- 'container' => array(
- '#attributes' => array('class' => array('compact-link')),
- ),
- ),
- );
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderCompactLink'],
+ [$class, 'preRenderLink'],
+ ],
+ '#theme_wrappers' => [
+ 'container' => [
+ '#attributes' => ['class' => ['compact-link']],
+ ],
+ ],
+ ];
}
/**
@@ -58,23 +58,23 @@ class SystemCompactLink extends Link {
*/
public static function preRenderCompactLink($element) {
// By default, link options to pass to l() are normally set in #options.
- $element += array('#options' => array());
+ $element += ['#options' => []];
if (system_admin_compact_mode()) {
$element['#title'] = t('Show descriptions');
- $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'off'));
- $element['#options'] = array(
- 'attributes' => array('title' => t('Expand layout to include descriptions.')),
+ $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', ['mode' => 'off']);
+ $element['#options'] = [
+ 'attributes' => ['title' => t('Expand layout to include descriptions.')],
'query' => \Drupal::destination()->getAsArray()
- );
+ ];
}
else {
$element['#title'] = t('Hide descriptions');
- $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'on'));
- $element['#options'] = array(
- 'attributes' => array('title' => t('Compress layout by hiding descriptions.')),
+ $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', ['mode' => 'on']);
+ $element['#options'] = [
+ 'attributes' => ['title' => t('Compress layout by hiding descriptions.')],
'query' => \Drupal::destination()->getAsArray(),
- );
+ ];
}
$options = NestedArray::mergeDeep($element['#url']->getOptions(), $element['#options']);
diff --git a/core/lib/Drupal/Core/Render/Element/Table.php b/core/lib/Drupal/Core/Render/Element/Table.php
index 298a27fa651..c6c08b10664 100644
--- a/core/lib/Drupal/Core/Render/Element/Table.php
+++ b/core/lib/Drupal/Core/Render/Element/Table.php
@@ -65,9 +65,9 @@ class Table extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#header' => array(),
- '#rows' => array(),
+ return [
+ '#header' => [],
+ '#rows' => [],
'#empty' => '',
// Properties for tableselect support.
'#input' => TRUE,
@@ -77,24 +77,24 @@ class Table extends FormElement {
'#responsive' => TRUE,
'#multiple' => TRUE,
'#js_select' => TRUE,
- '#process' => array(
- array($class, 'processTable'),
- ),
- '#element_validate' => array(
- array($class, 'validateTable'),
- ),
+ '#process' => [
+ [$class, 'processTable'],
+ ],
+ '#element_validate' => [
+ [$class, 'validateTable'],
+ ],
// Properties for tabledrag support.
// The value is a list of arrays that are passed to
// drupal_attach_tabledrag(). Table::preRenderTable() prepends the HTML ID
// of the table to each set of options.
// @see drupal_attach_tabledrag()
- '#tabledrag' => array(),
+ '#tabledrag' => [],
// Render properties.
- '#pre_render' => array(
- array($class, 'preRenderTable'),
- ),
+ '#pre_render' => [
+ [$class, 'preRenderTable'],
+ ],
'#theme' => 'table',
- );
+ ];
}
/**
@@ -108,12 +108,12 @@ class Table extends FormElement {
// #default_value property.
// @todo D8: Remove this inconsistency.
if ($input === FALSE) {
- $element += array('#default_value' => array());
+ $element += ['#default_value' => []];
$value = array_keys(array_filter($element['#default_value']));
return array_combine($value, $value);
}
else {
- return is_array($input) ? array_combine($input, $input) : array();
+ return is_array($input) ? array_combine($input, $input) : [];
}
}
}
@@ -135,7 +135,7 @@ class Table extends FormElement {
public static function processTable(&$element, FormStateInterface $form_state, &$complete_form) {
if ($element['#tableselect']) {
if ($element['#multiple']) {
- $value = is_array($element['#value']) ? $element['#value'] : array();
+ $value = is_array($element['#value']) ? $element['#value'] : [];
}
// Advanced selection behavior makes no sense for radios.
else {
@@ -145,7 +145,7 @@ class Table extends FormElement {
// @todo D8: Rename into #select_all?
if ($element['#js_select']) {
$element['#attached']['library'][] = 'core/drupal.tableselect';
- array_unshift($element['#header'], array('class' => array('select-all')));
+ array_unshift($element['#header'], ['class' => ['select-all']]);
}
// Add an empty header column for radio buttons or when a "Select all"
// checkbox is not desired.
@@ -154,7 +154,7 @@ class Table extends FormElement {
}
if (!isset($element['#default_value']) || $element['#default_value'] === 0) {
- $element['#default_value'] = array();
+ $element['#default_value'] = [];
}
// Create a checkbox or radio for each row in a way that the value of the
// tableselect element behaves as if it had been of #type checkboxes or
@@ -165,7 +165,7 @@ class Table extends FormElement {
// Their values have to be located in child keys (#tree is ignored),
// since Table::validateTable() has to be able to validate whether input
// (for the parent #type 'table' element) has been submitted.
- $element_parents = array_merge($element['#parents'], array($key));
+ $element_parents = array_merge($element['#parents'], [$key]);
// Since the #parents of the tableselect form element will equal the
// #parents of the row element, prevent FormBuilder from auto-generating
@@ -202,23 +202,23 @@ class Table extends FormElement {
}
}
if (isset($title) && $title !== '') {
- $title = t('Update @title', array('@title' => $title));
+ $title = t('Update @title', ['@title' => $title]);
}
}
// Prepend the select column to existing columns.
- $row = array('select' => array()) + $row;
- $row['select'] += array(
+ $row = ['select' => []] + $row;
+ $row['select'] += [
'#type' => $element['#multiple'] ? 'checkbox' : 'radio',
'#id' => HtmlUtility::getUniqueId('edit-' . implode('-', $element_parents)),
// @todo If rows happen to use numeric indexes instead of string keys,
// this results in a first row with $key === 0, which is always FALSE.
'#return_value' => $key,
'#attributes' => $element['#attributes'],
- '#wrapper_attributes' => array(
- 'class' => array('table-select'),
- ),
- );
+ '#wrapper_attributes' => [
+ 'class' => ['table-select'],
+ ],
+ ];
if ($element['#multiple']) {
$row['select']['#default_value'] = isset($value[$key]) ? $key : NULL;
$row['select']['#parents'] = $element_parents;
@@ -339,7 +339,7 @@ class Table extends FormElement {
*/
public static function preRenderTable($element) {
foreach (Element::children($element) as $first) {
- $row = array('data' => array());
+ $row = ['data' => []];
// Apply attributes of first-level elements as table row attributes.
if (isset($element[$first]['#attributes'])) {
$row += $element[$first]['#attributes'];
@@ -350,7 +350,7 @@ class Table extends FormElement {
foreach (Element::children($element[$first]) as $second) {
// Assign the element by reference, so any potential changes to the
// original element are taken over.
- $column = array('data' => &$element[$first][$second]);
+ $column = ['data' => &$element[$first][$second]];
// Apply wrapper attributes of second-level elements as table cell
// attributes.
@@ -364,7 +364,7 @@ class Table extends FormElement {
}
// Take over $element['#id'] as HTML ID attribute, if not already set.
- Element::setAttributes($element, array('id'));
+ Element::setAttributes($element, ['id']);
// Add sticky headers, if applicable.
if (count($element['#header']) && $element['#sticky']) {
diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php
index faa288e4743..a8f0e9596c4 100644
--- a/core/lib/Drupal/Core/Render/Element/Tableselect.php
+++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php
@@ -57,23 +57,23 @@ class Tableselect extends Table {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#js_select' => TRUE,
'#multiple' => TRUE,
'#responsive' => TRUE,
'#sticky' => FALSE,
- '#pre_render' => array(
- array($class, 'preRenderTable'),
- array($class, 'preRenderTableselect'),
- ),
- '#process' => array(
- array($class, 'processTableselect'),
- ),
- '#options' => array(),
+ '#pre_render' => [
+ [$class, 'preRenderTable'],
+ [$class, 'preRenderTableselect'],
+ ],
+ '#process' => [
+ [$class, 'processTableselect'],
+ ],
+ '#options' => [],
'#empty' => '',
'#theme' => 'table__tableselect',
- );
+ ];
}
/**
@@ -87,8 +87,8 @@ class Tableselect extends Table {
// keys of the #default_value property. This differs from the checkboxes
// element which uses the array values.
if ($input === FALSE) {
- $value = array();
- $element += array('#default_value' => array());
+ $value = [];
+ $element += ['#default_value' => []];
foreach ($element['#default_value'] as $key => $flag) {
if ($flag) {
$value[$key] = $key;
@@ -97,7 +97,7 @@ class Tableselect extends Table {
return $value;
}
else {
- return is_array($input) ? array_combine($input, $input) : array();
+ return is_array($input) ? array_combine($input, $input) : [];
}
}
}
@@ -147,14 +147,14 @@ class Tableselect extends Table {
* The processed element.
*/
public static function preRenderTableselect($element) {
- $rows = array();
+ $rows = [];
$header = $element['#header'];
if (!empty($element['#options'])) {
// Generate a table row for each selectable item in #options.
foreach (Element::children($element) as $key) {
- $row = array();
+ $row = [];
- $row['data'] = array();
+ $row['data'] = [];
if (isset($element['#options'][$key]['#attributes'])) {
$row += $element['#options'][$key]['#attributes'];
}
@@ -187,7 +187,7 @@ class Tableselect extends Table {
if ($element['#js_select']) {
// Add a "Select all" checkbox.
$element['#attached']['library'][] = 'core/drupal.tableselect';
- array_unshift($header, array('class' => array('select-all')));
+ array_unshift($header, ['class' => ['select-all']]);
}
else {
// Add an empty header when radio buttons are displayed or a "Select all"
@@ -218,7 +218,7 @@ class Tableselect extends Table {
*/
public static function processTableselect(&$element, FormStateInterface $form_state, &$complete_form) {
if ($element['#multiple']) {
- $value = is_array($element['#value']) ? $element['#value'] : array();
+ $value = is_array($element['#value']) ? $element['#value'] : [];
}
else {
// Advanced selection behavior makes no sense for radios.
@@ -229,7 +229,7 @@ class Tableselect extends Table {
if (count($element['#options']) > 0) {
if (!isset($element['#default_value']) || $element['#default_value'] === 0) {
- $element['#default_value'] = array();
+ $element['#default_value'] = [];
}
// Create a checkbox or radio for each item in #options in such a way that
@@ -242,12 +242,12 @@ class Tableselect extends Table {
$title = '';
if (isset($element['#options'][$key]['title']) && is_array($element['#options'][$key]['title'])) {
if (!empty($element['#options'][$key]['title']['data']['#title'])) {
- $title = new TranslatableMarkup('Update @title', array(
+ $title = new TranslatableMarkup('Update @title', [
'@title' => $element['#options'][$key]['title']['data']['#title'],
- ));
+ ]);
}
}
- $element[$key] = array(
+ $element[$key] = [
'#type' => 'checkbox',
'#title' => $title,
'#title_display' => 'invisible',
@@ -255,13 +255,13 @@ class Tableselect extends Table {
'#default_value' => isset($value[$key]) ? $key : NULL,
'#attributes' => $element['#attributes'],
'#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
- );
+ ];
}
else {
// Generate the parents as the autogenerator does, so we will have a
// unique id for each radio button.
- $parents_for_id = array_merge($element['#parents'], array($key));
- $element[$key] = array(
+ $parents_for_id = array_merge($element['#parents'], [$key]);
+ $element[$key] = [
'#type' => 'radio',
'#title' => '',
'#return_value' => $key,
@@ -270,7 +270,7 @@ class Tableselect extends Table {
'#parents' => $element['#parents'],
'#id' => HtmlUtility::getUniqueId('edit-' . implode('-', $parents_for_id)),
'#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
- );
+ ];
}
if (isset($element['#options'][$key]['#weight'])) {
$element[$key]['#weight'] = $element['#options'][$key]['#weight'];
@@ -279,7 +279,7 @@ class Tableselect extends Table {
}
}
else {
- $element['#value'] = array();
+ $element['#value'] = [];
}
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Tel.php b/core/lib/Drupal/Core/Render/Element/Tel.php
index 09093938420..9289a1d028c 100644
--- a/core/lib/Drupal/Core/Render/Element/Tel.php
+++ b/core/lib/Drupal/Core/Render/Element/Tel.php
@@ -32,22 +32,22 @@ class Tel extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#size' => 30,
'#maxlength' => 128,
'#autocomplete_route_name' => FALSE,
- '#process' => array(
- array($class, 'processAutocomplete'),
- array($class, 'processAjaxForm'),
- array($class, 'processPattern'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderTel'),
- ),
+ '#process' => [
+ [$class, 'processAutocomplete'],
+ [$class, 'processAjaxForm'],
+ [$class, 'processPattern'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderTel'],
+ ],
'#theme' => 'input__tel',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -63,8 +63,8 @@ class Tel extends FormElement {
*/
public static function preRenderTel($element) {
$element['#attributes']['type'] = 'tel';
- Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
- static::setAttributes($element, array('form-tel'));
+ Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']);
+ static::setAttributes($element, ['form-tel']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Textarea.php b/core/lib/Drupal/Core/Render/Element/Textarea.php
index f9286ea64f6..340bc114e60 100644
--- a/core/lib/Drupal/Core/Render/Element/Textarea.php
+++ b/core/lib/Drupal/Core/Render/Element/Textarea.php
@@ -33,21 +33,21 @@ class Textarea extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#cols' => 60,
'#rows' => 5,
'#resizable' => 'vertical',
- '#process' => array(
- array($class, 'processAjaxForm'),
- array($class, 'processGroup'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderGroup'),
- ),
+ '#process' => [
+ [$class, 'processAjaxForm'],
+ [$class, 'processGroup'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderGroup'],
+ ],
'#theme' => 'textarea',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Render/Element/Textfield.php b/core/lib/Drupal/Core/Render/Element/Textfield.php
index 1cb35e8a34c..0bdc294a096 100644
--- a/core/lib/Drupal/Core/Render/Element/Textfield.php
+++ b/core/lib/Drupal/Core/Render/Element/Textfield.php
@@ -47,24 +47,24 @@ class Textfield extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#size' => 60,
'#maxlength' => 128,
'#autocomplete_route_name' => FALSE,
- '#process' => array(
- array($class, 'processAutocomplete'),
- array($class, 'processAjaxForm'),
- array($class, 'processPattern'),
- array($class, 'processGroup'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderTextfield'),
- array($class, 'preRenderGroup'),
- ),
+ '#process' => [
+ [$class, 'processAutocomplete'],
+ [$class, 'processAjaxForm'],
+ [$class, 'processPattern'],
+ [$class, 'processGroup'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderTextfield'],
+ [$class, 'preRenderGroup'],
+ ],
'#theme' => 'input__textfield',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -77,7 +77,7 @@ class Textfield extends FormElement {
if (!is_scalar($input)) {
$input = '';
}
- return str_replace(array("\r", "\n"), '', $input);
+ return str_replace(["\r", "\n"], '', $input);
}
return NULL;
}
@@ -95,8 +95,8 @@ class Textfield extends FormElement {
*/
public static function preRenderTextfield($element) {
$element['#attributes']['type'] = 'text';
- Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
- static::setAttributes($element, array('form-text'));
+ Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']);
+ static::setAttributes($element, ['form-text']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Token.php b/core/lib/Drupal/Core/Render/Element/Token.php
index 2f9e03add50..aa244356cc5 100644
--- a/core/lib/Drupal/Core/Render/Element/Token.php
+++ b/core/lib/Drupal/Core/Render/Element/Token.php
@@ -21,13 +21,13 @@ class Token extends Hidden {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
- '#pre_render' => array(
- array($class, 'preRenderHidden'),
- ),
+ '#pre_render' => [
+ [$class, 'preRenderHidden'],
+ ],
'#theme' => 'input__hidden',
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Render/Element/Url.php b/core/lib/Drupal/Core/Render/Element/Url.php
index c66cadc6387..c3574b095ef 100644
--- a/core/lib/Drupal/Core/Render/Element/Url.php
+++ b/core/lib/Drupal/Core/Render/Element/Url.php
@@ -34,25 +34,25 @@ class Url extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#size' => 60,
'#maxlength' => 255,
'#autocomplete_route_name' => FALSE,
- '#process' => array(
- array($class, 'processAutocomplete'),
- array($class, 'processAjaxForm'),
- array($class, 'processPattern'),
- ),
- '#element_validate' => array(
- array($class, 'validateUrl'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderUrl'),
- ),
+ '#process' => [
+ [$class, 'processAutocomplete'],
+ [$class, 'processAjaxForm'],
+ [$class, 'processPattern'],
+ ],
+ '#element_validate' => [
+ [$class, 'validateUrl'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderUrl'],
+ ],
'#theme' => 'input__url',
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
}
/**
@@ -65,7 +65,7 @@ class Url extends FormElement {
$form_state->setValueForElement($element, $value);
if ($value !== '' && !UrlHelper::isValid($value, TRUE)) {
- $form_state->setError($element, t('The URL %url is not valid.', array('%url' => $value)));
+ $form_state->setError($element, t('The URL %url is not valid.', ['%url' => $value]));
}
}
@@ -82,8 +82,8 @@ class Url extends FormElement {
*/
public static function preRenderUrl($element) {
$element['#attributes']['type'] = 'url';
- Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
- static::setAttributes($element, array('form-url'));
+ Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']);
+ static::setAttributes($element, ['form-url']);
return $element;
}
diff --git a/core/lib/Drupal/Core/Render/Element/Value.php b/core/lib/Drupal/Core/Render/Element/Value.php
index 015b0bdb355..023bb1af0e5 100644
--- a/core/lib/Drupal/Core/Render/Element/Value.php
+++ b/core/lib/Drupal/Core/Render/Element/Value.php
@@ -25,9 +25,9 @@ class Value extends FormElement {
* {@inheritdoc}
*/
public function getInfo() {
- return array(
+ return [
'#input' => TRUE,
- );
+ ];
}
}
diff --git a/core/lib/Drupal/Core/Render/Element/VerticalTabs.php b/core/lib/Drupal/Core/Render/Element/VerticalTabs.php
index 1d108aaed74..759723b4a6f 100644
--- a/core/lib/Drupal/Core/Render/Element/VerticalTabs.php
+++ b/core/lib/Drupal/Core/Render/Element/VerticalTabs.php
@@ -54,16 +54,16 @@ class VerticalTabs extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#default_tab' => '',
- '#process' => array(
- array($class, 'processVerticalTabs'),
- ),
- '#pre_render' => array(
- array($class, 'preRenderVerticalTabs'),
- ),
- '#theme_wrappers' => array('vertical_tabs', 'form_element'),
- );
+ '#process' => [
+ [$class, 'processVerticalTabs'],
+ ],
+ '#pre_render' => [
+ [$class, 'preRenderVerticalTabs'],
+ ],
+ '#theme_wrappers' => ['vertical_tabs', 'form_element'],
+ ];
}
/**
@@ -106,11 +106,11 @@ class VerticalTabs extends RenderElement {
// Inject a new details as child, so that form_process_details() processes
// this details element like any other details.
- $element['group'] = array(
+ $element['group'] = [
'#type' => 'details',
- '#theme_wrappers' => array(),
+ '#theme_wrappers' => [],
'#parents' => $element['#parents'],
- );
+ ];
// Add an invisible label for accessibility.
if (!isset($element['#title'])) {
@@ -128,11 +128,11 @@ class VerticalTabs extends RenderElement {
if ($form_state->hasValue($name . '__active_tab')) {
$element['#default_tab'] = $form_state->getValue($name . '__active_tab');
}
- $element[$name . '__active_tab'] = array(
+ $element[$name . '__active_tab'] = [
'#type' => 'hidden',
'#default_value' => $element['#default_tab'],
- '#attributes' => array('class' => array('vertical-tabs__active-tab')),
- );
+ '#attributes' => ['class' => ['vertical-tabs__active-tab']],
+ ];
// Clean up the active tab value so it's not accidentally stored in
// settings forms.
$form_state->addCleanValueKey($name . '__active_tab');
diff --git a/core/lib/Drupal/Core/Render/Element/Weight.php b/core/lib/Drupal/Core/Render/Element/Weight.php
index a6ecbee764e..468290a1a70 100644
--- a/core/lib/Drupal/Core/Render/Element/Weight.php
+++ b/core/lib/Drupal/Core/Render/Element/Weight.php
@@ -33,15 +33,15 @@ class Weight extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#delta' => 10,
'#default_value' => 0,
- '#process' => array(
- array($class, 'processWeight'),
- array($class, 'processAjaxForm'),
- ),
- );
+ '#process' => [
+ [$class, 'processWeight'],
+ [$class, 'processAjaxForm'],
+ ],
+ ];
}
/**
@@ -55,7 +55,7 @@ class Weight extends FormElement {
$max_elements = \Drupal::config('system.site')->get('weight_select_max');
if ($element['#delta'] <= $max_elements) {
$element['#type'] = 'select';
- $weights = array();
+ $weights = [];
for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
$weights[$n] = $n;
}
diff --git a/core/lib/Drupal/Core/Render/ElementInfoManager.php b/core/lib/Drupal/Core/Render/ElementInfoManager.php
index 17545248944..015e3900bd3 100644
--- a/core/lib/Drupal/Core/Render/ElementInfoManager.php
+++ b/core/lib/Drupal/Core/Render/ElementInfoManager.php
@@ -75,7 +75,7 @@ class ElementInfoManager extends DefaultPluginManager implements ElementInfoMana
if (!isset($this->elementInfo[$theme_name])) {
$this->elementInfo[$theme_name] = $this->buildInfo($theme_name);
}
- $info = isset($this->elementInfo[$theme_name][$type]) ? $this->elementInfo[$theme_name][$type] : array();
+ $info = isset($this->elementInfo[$theme_name][$type]) ? $this->elementInfo[$theme_name][$type] : [];
$info['#defaults_loaded'] = TRUE;
return $info;
}
@@ -114,7 +114,7 @@ class ElementInfoManager extends DefaultPluginManager implements ElementInfoMana
// will receive input, and assign the value callback.
if ($element instanceof FormElementInterface) {
$element_info['#input'] = TRUE;
- $element_info['#value_callback'] = array($definition['class'], 'valueCallback');
+ $element_info['#value_callback'] = [$definition['class'], 'valueCallback'];
}
$info[$element_type] = $element_info;
}
@@ -136,7 +136,7 @@ class ElementInfoManager extends DefaultPluginManager implements ElementInfoMana
*
* @return \Drupal\Core\Render\Element\ElementInterface
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
return parent::createInstance($plugin_id, $configuration);
}
diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
index 358b1f1b725..7b171f8202f 100644
--- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
+++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
@@ -410,10 +410,10 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn
$attributes = $item[0];
$should_add_header = isset($item[1]) ? $item[1] : FALSE;
- $element = array(
+ $element = [
'#tag' => 'link',
'#attributes' => $attributes,
- );
+ ];
$href = $attributes['href'];
$attached['html_head'][] = [$element, 'html_head_link:' . $attributes['rel'] . ':' . $href];
diff --git a/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php b/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php
index 0a1b993987a..2b2a2a59ba9 100644
--- a/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php
+++ b/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php
@@ -66,7 +66,7 @@ class AjaxRenderer implements MainContentRendererInterface {
// replace the element making the Ajax call. The default 'replaceWith'
// behavior can be changed with #ajax['method'].
$response->addCommand(new InsertCommand(NULL, $html));
- $status_messages = array('#type' => 'status_messages');
+ $status_messages = ['#type' => 'status_messages'];
$output = $this->drupalRenderRoot($status_messages);
if (!empty($output)) {
$response->addCommand(new PrependCommand(NULL, $output));
diff --git a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php
index c71604b5116..664063a5fe8 100644
--- a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php
+++ b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php
@@ -50,7 +50,7 @@ class DialogRenderer implements MainContentRendererInterface {
$title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject());
// Determine the dialog options and the target for the OpenDialogCommand.
- $options = $request->request->get('dialogOptions', array());
+ $options = $request->request->get('dialogOptions', []);
$target = $this->determineTargetSelector($options, $route_match);
$response->addCommand(new OpenDialogCommand($target, $title, $content, $options));
diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
index 54c40f63ca3..c76a9728d28 100644
--- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
+++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
@@ -253,9 +253,9 @@ class HtmlRenderer implements MainContentRendererInterface {
// Generate a #type => page render array using the page display variant,
// the page display will build the content for the various page regions.
- $page = array(
+ $page = [
'#type' => 'page',
- );
+ ];
$page += $page_display->build();
}
diff --git a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php
index fcb38e253ad..60a495122dd 100644
--- a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php
+++ b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php
@@ -31,7 +31,7 @@ class ModalRenderer extends DialogRenderer {
// Determine the title: use the title provided by the main content if any,
// otherwise get it from the routing information.
- $options = $request->request->get('dialogOptions', array());
+ $options = $request->request->get('dialogOptions', []);
$response->addCommand(new OpenModalDialogCommand($title, $content, $options));
return $response;
diff --git a/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php b/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php
index de52da2f6cb..6a5527bdebd 100644
--- a/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php
+++ b/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php
@@ -64,7 +64,7 @@ class MetadataBubblingUrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function getPathFromRoute($name, $parameters = array()) {
+ public function getPathFromRoute($name, $parameters = []) {
return $this->urlGenerator->getPathFromRoute($name, $parameters);
}
@@ -91,7 +91,7 @@ class MetadataBubblingUrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) {
+ public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) {
$options['absolute'] = is_bool($referenceType) ? $referenceType : $referenceType === self::ABSOLUTE_URL;
$generated_url = $this->generateFromRoute($name, $parameters, $options, TRUE);
$this->bubble($generated_url);
@@ -101,7 +101,7 @@ class MetadataBubblingUrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
+ public function generateFromRoute($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) {
$generated_url = $this->urlGenerator->generateFromRoute($name, $parameters, $options, TRUE);
if (!$collect_bubbleable_metadata) {
$this->bubble($generated_url, $options);
@@ -119,7 +119,7 @@ class MetadataBubblingUrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function getRouteDebugMessage($name, array $parameters = array()) {
+ public function getRouteDebugMessage($name, array $parameters = []) {
return $this->urlGenerator->getRouteDebugMessage($name, $parameters);
}
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index 503359ef784..257349f973c 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -383,9 +383,9 @@ class Renderer implements RendererInterface {
}
// Defaults for bubbleable rendering metadata.
- $elements['#cache']['tags'] = isset($elements['#cache']['tags']) ? $elements['#cache']['tags'] : array();
+ $elements['#cache']['tags'] = isset($elements['#cache']['tags']) ? $elements['#cache']['tags'] : [];
$elements['#cache']['max-age'] = isset($elements['#cache']['max-age']) ? $elements['#cache']['max-age'] : Cache::PERMANENT;
- $elements['#attached'] = isset($elements['#attached']) ? $elements['#attached'] : array();
+ $elements['#attached'] = isset($elements['#attached']) ? $elements['#attached'] : [];
// Allow #pre_render to abort rendering.
if (!empty($elements['#printed'])) {
@@ -415,11 +415,11 @@ class Renderer implements RendererInterface {
$theme_is_implemented = isset($elements['#theme']);
// Check the elements for insecure HTML and pass through sanitization.
if (isset($elements)) {
- $markup_keys = array(
+ $markup_keys = [
'#description',
'#field_prefix',
'#field_suffix',
- );
+ ];
foreach ($markup_keys as $key) {
if (!empty($elements[$key]) && is_scalar($elements[$key])) {
$elements[$key] = $this->xssFilterAdminIfUnsafe($elements[$key]);
diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php
index 2970b2744ea..fec05d1d8f8 100644
--- a/core/lib/Drupal/Core/Render/theme.api.php
+++ b/core/lib/Drupal/Core/Render/theme.api.php
@@ -528,12 +528,12 @@
*/
function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
// Add a checkbox to toggle the breadcrumb trail.
- $form['toggle_breadcrumb'] = array(
+ $form['toggle_breadcrumb'] = [
'#type' => 'checkbox',
'#title' => t('Display the breadcrumb'),
'#default_value' => theme_get_setting('features.breadcrumb'),
'#description' => t('Show a trail of links from the homepage to the current page.'),
- );
+ ];
}
/**
@@ -603,7 +603,7 @@ function hook_preprocess(&$variables, $hook) {
function hook_preprocess_HOOK(&$variables) {
// This example is from rdf_preprocess_image(). It adds an RDF attribute
// to the image hook's variables.
- $variables['attributes']['typeof'] = array('foaf:Image');
+ $variables['attributes']['typeof'] = ['foaf:Image'];
}
/**
@@ -630,7 +630,7 @@ function hook_preprocess_HOOK(&$variables) {
* @see hook_theme_suggestions_HOOK_alter()
*/
function hook_theme_suggestions_HOOK(array $variables) {
- $suggestions = array();
+ $suggestions = [];
$suggestions[] = 'node__' . $variables['elements']['#langcode'];
@@ -962,10 +962,10 @@ function hook_library_info_alter(&$libraries, $extension) {
// relative to the original extension, specify an absolute path (relative
// to DRUPAL_ROOT / base_path()) to the new location.
$new_path = '/' . drupal_get_path('module', 'farbtastic_update') . '/js';
- $new_js = array();
- $replacements = array(
+ $new_js = [];
+ $replacements = [
$old_path . '/farbtastic.js' => $new_path . '/farbtastic-2.0.js',
- );
+ ];
foreach ($libraries['jquery.farbtastic']['js'] as $source => $options) {
if (isset($replacements[$source])) {
$new_js[$replacements[$source]] = $options;
@@ -1178,21 +1178,21 @@ function hook_page_bottom(array &$page_bottom) {
* @see hook_theme_registry_alter()
*/
function hook_theme($existing, $type, $theme, $path) {
- return array(
- 'forum_display' => array(
- 'variables' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
- ),
- 'forum_list' => array(
- 'variables' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
- ),
- 'forum_icon' => array(
- 'variables' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0),
- ),
- 'status_report' => array(
+ return [
+ 'forum_display' => [
+ 'variables' => ['forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL],
+ ],
+ 'forum_list' => [
+ 'variables' => ['forums' => NULL, 'parents' => NULL, 'tid' => NULL],
+ ],
+ 'forum_icon' => [
+ 'variables' => ['new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0],
+ ],
+ 'status_report' => [
'render element' => 'requirements',
'file' => 'system.admin.inc',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php b/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php
index 4e710ba9eb3..74a791dfbdb 100644
--- a/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php
+++ b/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php
@@ -20,7 +20,7 @@ class RouteProcessorManager implements OutboundRouteProcessorInterface {
* An array whose keys are priorities and whose values are arrays of path
* processor objects.
*/
- protected $outboundProcessors = array();
+ protected $outboundProcessors = [];
/**
* Holds the array of outbound processors, sorted by priority.
@@ -28,7 +28,7 @@ class RouteProcessorManager implements OutboundRouteProcessorInterface {
* @var array
* An array of path processor objects.
*/
- protected $sortedOutbound = array();
+ protected $sortedOutbound = [];
/**
* Adds an outbound processor object to the $outboundProcessors property.
@@ -40,7 +40,7 @@ class RouteProcessorManager implements OutboundRouteProcessorInterface {
*/
public function addOutbound(OutboundRouteProcessorInterface $processor, $priority = 0) {
$this->outboundProcessors[$priority][] = $processor;
- $this->sortedOutbound = array();
+ $this->sortedOutbound = [];
}
/**
@@ -71,7 +71,7 @@ class RouteProcessorManager implements OutboundRouteProcessorInterface {
* Sorts the processors according to priority.
*/
protected function sortProcessors() {
- $sorted = array();
+ $sorted = [];
krsort($this->outboundProcessors);
foreach ($this->outboundProcessors as $processors) {
diff --git a/core/lib/Drupal/Core/Routing/AccessAwareRouter.php b/core/lib/Drupal/Core/Routing/AccessAwareRouter.php
index 5c3d93182eb..d8487c6ef92 100644
--- a/core/lib/Drupal/Core/Routing/AccessAwareRouter.php
+++ b/core/lib/Drupal/Core/Routing/AccessAwareRouter.php
@@ -127,7 +127,7 @@ class AccessAwareRouter implements AccessAwareRouterInterface {
/**
* {@inheritdoc}
*/
- public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) {
+ public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) {
if ($this->router instanceof UrlGeneratorInterface) {
return $this->router->generate($name, $parameters, $referenceType);
}
diff --git a/core/lib/Drupal/Core/Routing/CompiledRoute.php b/core/lib/Drupal/Core/Routing/CompiledRoute.php
index 76d6ef16eba..a1366a60849 100644
--- a/core/lib/Drupal/Core/Routing/CompiledRoute.php
+++ b/core/lib/Drupal/Core/Routing/CompiledRoute.php
@@ -62,7 +62,7 @@ class CompiledRoute extends SymfonyCompiledRoute {
* @param array $variables
* An array of variables (variables defined in the path and in the host patterns)
*/
- public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = NULL, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) {
+ public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = NULL, array $hostTokens = [], array $hostVariables = [], array $variables = []) {
parent::__construct($staticPrefix, $regex, $tokens, $pathVariables, $hostRegex, $hostTokens, $hostVariables, $variables);
$this->fit = $fit;
diff --git a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
index e804f2e6672..09d61481186 100644
--- a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
+++ b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php
@@ -62,7 +62,7 @@ class ParamConversionEnhancer implements RouteEnhancerInterface, EventSubscriber
// Foreach will copy the values from the array it iterates. Even if they
// are references, use it to break them. This avoids any scenarios where raw
// variables also get replaced with converted values.
- $raw_variables = array();
+ $raw_variables = [];
foreach (array_intersect_key($defaults, $variables) as $key => $value) {
$raw_variables[$key] = $value;
}
@@ -85,7 +85,7 @@ class ParamConversionEnhancer implements RouteEnhancerInterface, EventSubscriber
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events[KernelEvents::EXCEPTION][] = array('onException', 75);
+ $events[KernelEvents::EXCEPTION][] = ['onException', 75];
return $events;
}
diff --git a/core/lib/Drupal/Core/Routing/MatcherDumper.php b/core/lib/Drupal/Core/Routing/MatcherDumper.php
index 82c7074f81d..5e329f7daf8 100644
--- a/core/lib/Drupal/Core/Routing/MatcherDumper.php
+++ b/core/lib/Drupal/Core/Routing/MatcherDumper.php
@@ -84,10 +84,10 @@ class MatcherDumper implements MatcherDumperInterface {
* @param array $options
* An array of options.
*/
- public function dump(array $options = array()) {
+ public function dump(array $options = []) {
// Convert all of the routes into database records.
// Accumulate the menu masks on top of any we found before.
- $masks = array_flip($this->state->get('routing.menu_masks.' . $this->tableName, array()));
+ $masks = array_flip($this->state->get('routing.menu_masks.' . $this->tableName, []));
// Delete any old records first, then insert the new ones. That avoids
// stale data. The transaction makes it atomic to avoid unstable router
// states due to random failures.
@@ -106,15 +106,15 @@ class MatcherDumper implements MatcherDumperInterface {
// Split the routes into chunks to avoid big INSERT queries.
$route_chunks = array_chunk($this->routes->all(), 50, TRUE);
foreach ($route_chunks as $routes) {
- $insert = $this->connection->insert($this->tableName)->fields(array(
+ $insert = $this->connection->insert($this->tableName)->fields([
'name',
'fit',
'path',
'pattern_outline',
'number_parts',
'route',
- ));
- $names = array();
+ ]);
+ $names = [];
foreach ($routes as $name => $route) {
/** @var \Symfony\Component\Routing\Route $route */
$route->setOption('compiler_class', '\Drupal\Core\Routing\RouteCompiler');
@@ -126,14 +126,14 @@ class MatcherDumper implements MatcherDumperInterface {
// patterns we need to check in the RouteProvider.
$masks[$compiled->getFit()] = 1;
$names[] = $name;
- $values = array(
+ $values = [
'name' => $name,
'fit' => $compiled->getFit(),
'path' => $route->getPath(),
'pattern_outline' => $compiled->getPatternOutline(),
'number_parts' => $compiled->getNumParts(),
'route' => serialize($route),
- );
+ ];
$insert->values($values);
}
diff --git a/core/lib/Drupal/Core/Routing/NullGenerator.php b/core/lib/Drupal/Core/Routing/NullGenerator.php
index 9d6db83d0fa..74db5c96922 100644
--- a/core/lib/Drupal/Core/Routing/NullGenerator.php
+++ b/core/lib/Drupal/Core/Routing/NullGenerator.php
@@ -52,7 +52,7 @@ class NullGenerator extends UrlGenerator {
/**
* {@inheritdoc}
*/
- protected function getInternalPathFromRoute($name, Route $route, $parameters = array(), &$query_params = array()) {
+ protected function getInternalPathFromRoute($name, Route $route, $parameters = [], &$query_params = []) {
return $route->getPath();
}
@@ -71,7 +71,7 @@ class NullGenerator extends UrlGenerator {
/**
* {@inheritdoc}
*/
- protected function processPath($path, &$options = array(), BubbleableMetadata $bubbleable_metadata = NULL) {
+ protected function processPath($path, &$options = [], BubbleableMetadata $bubbleable_metadata = NULL) {
return $path;
}
diff --git a/core/lib/Drupal/Core/Routing/NullMatcherDumper.php b/core/lib/Drupal/Core/Routing/NullMatcherDumper.php
index 938a426c438..3378e1bbfc1 100644
--- a/core/lib/Drupal/Core/Routing/NullMatcherDumper.php
+++ b/core/lib/Drupal/Core/Routing/NullMatcherDumper.php
@@ -39,7 +39,7 @@ class NullMatcherDumper implements MatcherDumperInterface {
* @param array $options
* An array of options.
*/
- public function dump(array $options = array()) {
+ public function dump(array $options = []) {
// The dumper is reused for multiple providers, so reset the queued routes.
$this->routes = NULL;
}
diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php
index 29da760604d..2a0720a2d46 100644
--- a/core/lib/Drupal/Core/Routing/RouteBuilder.php
+++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php
@@ -159,15 +159,15 @@ class RouteBuilder implements RouteBuilderInterface, DestructableInterface {
unset($routes['route_callbacks']);
}
foreach ($routes as $name => $route_info) {
- $route_info += array(
- 'defaults' => array(),
- 'requirements' => array(),
- 'options' => array(),
+ $route_info += [
+ 'defaults' => [],
+ 'requirements' => [],
+ 'options' => [],
'host' => NULL,
- 'schemes' => array(),
- 'methods' => array(),
+ 'schemes' => [],
+ 'methods' => [],
'condition' => '',
- );
+ ];
$route = new Route($route_info['path'], $route_info['defaults'], $route_info['requirements'], $route_info['options'], $route_info['host'], $route_info['schemes'], $route_info['methods'], $route_info['condition']);
$collection->add($name, $route);
diff --git a/core/lib/Drupal/Core/Routing/RouteMatch.php b/core/lib/Drupal/Core/Routing/RouteMatch.php
index 29ff5c6c4c0..5784b7f7c8a 100644
--- a/core/lib/Drupal/Core/Routing/RouteMatch.php
+++ b/core/lib/Drupal/Core/Routing/RouteMatch.php
@@ -52,7 +52,7 @@ class RouteMatch implements RouteMatchInterface {
* @param array $raw_parameters
* The raw $parameters array.
*/
- public function __construct($route_name, Route $route, array $parameters = array(), array $raw_parameters = array()) {
+ public function __construct($route_name, Route $route, array $parameters = [], array $raw_parameters = []) {
$this->routeName = $route_name;
$this->route = $route;
@@ -77,7 +77,7 @@ class RouteMatch implements RouteMatchInterface {
*/
public static function createFromRequest(Request $request) {
if ($request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) {
- $raw_variables = array();
+ $raw_variables = [];
if ($raw = $request->attributes->get('_raw_variables')) {
$raw_variables = $raw->all();
}
@@ -141,7 +141,7 @@ class RouteMatch implements RouteMatchInterface {
* Route parameter names as both the keys and values.
*/
protected function getParameterNames() {
- $names = array();
+ $names = [];
if ($route = $this->getRouteObject()) {
// Variables defined in path and host patterns are route parameters.
$variables = $route->compile()->getVariables();
diff --git a/core/lib/Drupal/Core/Routing/RoutePreloader.php b/core/lib/Drupal/Core/Routing/RoutePreloader.php
index 2d382bb7496..9e75cdf1f54 100644
--- a/core/lib/Drupal/Core/Routing/RoutePreloader.php
+++ b/core/lib/Drupal/Core/Routing/RoutePreloader.php
@@ -38,7 +38,7 @@ class RoutePreloader implements EventSubscriberInterface {
*
* @var array
*/
- protected $nonAdminRoutesOnRebuild = array();
+ protected $nonAdminRoutesOnRebuild = [];
/**
* The cache backend used to skip the state loading.
@@ -114,7 +114,7 @@ class RoutePreloader implements EventSubscriberInterface {
*/
public function onFinishedRoutes(Event $event) {
$this->state->set('routing.non_admin_routes', $this->nonAdminRoutesOnRebuild);
- $this->nonAdminRoutesOnRebuild = array();
+ $this->nonAdminRoutesOnRebuild = [];
}
/**
@@ -122,11 +122,11 @@ class RoutePreloader implements EventSubscriberInterface {
*/
public static function getSubscribedEvents() {
// Set a really low priority to catch as many as possible routes.
- $events[RoutingEvents::ALTER] = array('onAlterRoutes', -1024);
- $events[RoutingEvents::FINISHED] = array('onFinishedRoutes');
+ $events[RoutingEvents::ALTER] = ['onAlterRoutes', -1024];
+ $events[RoutingEvents::FINISHED] = ['onFinishedRoutes'];
// Load the routes before the controller is executed (which happens after
// the kernel request event).
- $events[KernelEvents::REQUEST][] = array('onRequest');
+ $events[KernelEvents::REQUEST][] = ['onRequest'];
return $events;
}
diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php
index f16aa9f0a50..1ba5f0d96c8 100644
--- a/core/lib/Drupal/Core/Routing/RouteProvider.php
+++ b/core/lib/Drupal/Core/Routing/RouteProvider.php
@@ -48,7 +48,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
*
* @var \Symfony\Component\Routing\Route[]
*/
- protected $routes = array();
+ protected $routes = [];
/**
* A cache of already-loaded serialized routes, keyed by route name.
@@ -185,7 +185,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
* Thrown if there is no route with that name in this repository.
*/
public function getRouteByName($name) {
- $routes = $this->getRoutesByNames(array($name));
+ $routes = $this->getRoutesByNames([$name]);
if (empty($routes)) {
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
}
@@ -210,7 +210,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
}
else {
try {
- $result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN ( :names[] )', array(':names[]' => $routes_to_load));
+ $result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN ( :names[] )', [':names[]' => $routes_to_load]);
$routes = $result->fetchAllKeyed();
$this->cache->set($cid, $routes, Cache::PERMANENT, ['routes']);
@@ -252,14 +252,14 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
*/
protected function getCandidateOutlines(array $parts) {
$number_parts = count($parts);
- $ancestors = array();
+ $ancestors = [];
$length = $number_parts - 1;
$end = (1 << $number_parts) - 1;
// The highest possible mask is a 1 bit for every part of the path. We will
// check every value down from there to generate a possible outline.
if ($number_parts == 1) {
- $masks = array(1);
+ $masks = [1];
}
elseif ($number_parts <= 3 && $number_parts > 0) {
// Optimization - don't query the state system for short paths. This also
@@ -269,11 +269,11 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
}
elseif ($number_parts <= 0) {
// No path can match, short-circuit the process.
- $masks = array();
+ $masks = [];
}
else {
// Get the actual patterns that exist out of state.
- $masks = (array) $this->state->get('routing.menu_masks.' . $this->tableName, array());
+ $masks = (array) $this->state->get('routing.menu_masks.' . $this->tableName, []);
}
// Only examine patterns that actually exist as router items (the masks).
@@ -346,9 +346,9 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
// trailing wildcard parts as long as the pattern matches, since we
// dump the route pattern without those optional parts.
try {
- $routes = $this->connection->query("SELECT name, route, fit FROM {" . $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN ( :patterns[] ) AND number_parts >= :count_parts", array(
+ $routes = $this->connection->query("SELECT name, route, fit FROM {" . $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN ( :patterns[] ) AND number_parts >= :count_parts", [
':patterns[]' => $ancestors, ':count_parts' => count($parts),
- ))
+ ])
->fetchAll(\PDO::FETCH_ASSOC);
}
catch (\Exception $e) {
@@ -357,7 +357,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
// We sort by fit and name in PHP to avoid a SQL filesort and avoid any
// difference in the sorting behavior of SQL back-ends.
- usort($routes, array($this, 'routeProviderRouteCompare'));
+ usort($routes, [$this, 'routeProviderRouteCompare']);
foreach ($routes as $row) {
$collection->add($row['name'], unserialize($row['route']));
@@ -389,8 +389,8 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
* {@inheritdoc}
*/
public function reset() {
- $this->routes = array();
- $this->serializedRoutes = array();
+ $this->routes = [];
+ $this->serializedRoutes = [];
$this->cacheTagInvalidator->invalidateTags(['routes']);
}
@@ -398,7 +398,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[RoutingEvents::FINISHED][] = array('reset');
+ $events[RoutingEvents::FINISHED][] = ['reset'];
return $events;
}
diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php
index dc724bc2db8..e949c5efb86 100644
--- a/core/lib/Drupal/Core/Routing/Router.php
+++ b/core/lib/Drupal/Core/Routing/Router.php
@@ -214,7 +214,7 @@ class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterf
continue;
}
- $hostMatches = array();
+ $hostMatches = [];
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
$routes->remove($name);
continue;
@@ -383,7 +383,7 @@ class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterf
/**
* {@inheritdoc}
*/
- public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) {
+ public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) {
@trigger_error('Use the \Drupal\Core\Url object instead', E_USER_DEPRECATED);
return $this->urlGenerator->generate($name, $parameters, $referenceType);
}
diff --git a/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php b/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php
index e959c2a2902..625f7a341ab 100644
--- a/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php
+++ b/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php
@@ -16,12 +16,12 @@ class TrustedRedirectResponse extends CacheableSecuredRedirectResponse {
*
* @var string[]
*/
- protected $trustedUrls = array();
+ protected $trustedUrls = [];
/**
* {@inheritdoc}
*/
- public function __construct($url, $status = 302, $headers = array()) {
+ public function __construct($url, $status = 302, $headers = []) {
$this->trustedUrls[$url] = TRUE;
parent::__construct($url, $status, $headers);
}
diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php
index 36ed0f6b6cb..63dcd47b6cc 100644
--- a/core/lib/Drupal/Core/Routing/UrlGenerator.php
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php
@@ -124,7 +124,7 @@ class UrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function getPathFromRoute($name, $parameters = array()) {
+ public function getPathFromRoute($name, $parameters = []) {
$route = $this->getRoute($name);
$name = $this->getRouteDebugMessage($name);
$this->processRoute($name, $route, $parameters);
@@ -241,7 +241,7 @@ class UrlGenerator implements UrlGeneratorInterface {
* The URL path corresponding to the route, without the base path, not URL
* encoded.
*/
- protected function getInternalPathFromRoute($name, SymfonyRoute $route, $parameters = array(), &$query_params = array()) {
+ protected function getInternalPathFromRoute($name, SymfonyRoute $route, $parameters = [], &$query_params = []) {
// The Route has a cache of its own and is not recompiled as long as it does
// not get modified.
$compiledRoute = $route->compile();
@@ -252,7 +252,7 @@ class UrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) {
+ public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) {
$options['absolute'] = is_bool($referenceType) ? $referenceType : $referenceType === self::ABSOLUTE_URL;
return $this->generateFromRoute($name, $parameters, $options);
}
@@ -260,10 +260,10 @@ class UrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
- $options += array('prefix' => '');
+ public function generateFromRoute($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) {
+ $options += ['prefix' => ''];
if (!isset($options['query']) || !is_array($options['query'])) {
- $options['query'] = array();
+ $options['query'] = [];
}
$route = $this->getRoute($name);
@@ -284,7 +284,7 @@ class UrlGenerator implements UrlGeneratorInterface {
}
$options += $route->getOption('default_url_options') ?: [];
- $options += array('prefix' => '', 'path_processing' => TRUE);
+ $options += ['prefix' => '', 'path_processing' => TRUE];
$name = $this->getRouteDebugMessage($name);
$this->processRoute($name, $route, $parameters, $generated_url);
@@ -306,7 +306,7 @@ class UrlGenerator implements UrlGeneratorInterface {
// so we need to encode them as they are not used for this purpose here
// otherwise we would generate a URI that, when followed by a user agent
// (e.g. browser), does not match this route
- $path = strtr($path, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
+ $path = strtr($path, ['/../' => '/%2E%2E/', '/./' => '/%2E/']);
if ('/..' === substr($path, -3)) {
$path = substr($path, 0, -2) . '%2E%2E';
}
@@ -377,7 +377,7 @@ class UrlGenerator implements UrlGeneratorInterface {
/**
* Passes the path to a processor manager to allow alterations.
*/
- protected function processPath($path, &$options = array(), BubbleableMetadata $bubbleable_metadata = NULL) {
+ protected function processPath($path, &$options = [], BubbleableMetadata $bubbleable_metadata = NULL) {
$actual_path = $path === '/' ? $path : rtrim($path, '/');
return $this->pathProcessor->processOutbound($actual_path, $options, $this->requestStack->getCurrentRequest(), $bubbleable_metadata);
}
@@ -433,7 +433,7 @@ class UrlGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function getRouteDebugMessage($name, array $parameters = array()) {
+ public function getRouteDebugMessage($name, array $parameters = []) {
if (is_scalar($name)) {
return $name;
}
diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
index b2b81968f5c..e63383df5f8 100644
--- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
@@ -24,7 +24,7 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface {
* The internal Drupal path corresponding to the route. This string is
* not urlencoded and will be an empty string for the front page.
*/
- public function getPathFromRoute($name, $parameters = array());
+ public function getPathFromRoute($name, $parameters = []);
/**
* Generates a URL or path for a specific route based on the given parameters.
@@ -78,6 +78,6 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface {
* Should not be used in user code.
* Use \Drupal\Core\Url instead.
*/
- public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE);
+ public function generateFromRoute($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE);
}
diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php b/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php
index 98429d43ab9..7854a0ac96a 100644
--- a/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php
+++ b/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php
@@ -38,7 +38,7 @@ trait UrlGeneratorTrait {
*
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
*/
- protected function url($route_name, $route_parameters = array(), $options = array()) {
+ protected function url($route_name, $route_parameters = [], $options = []) {
return $this->getUrlGenerator()->generateFromRoute($route_name, $route_parameters, $options);
}
diff --git a/core/lib/Drupal/Core/Session/AccountSwitcher.php b/core/lib/Drupal/Core/Session/AccountSwitcher.php
index cbebac4010d..3c2b3d88c48 100644
--- a/core/lib/Drupal/Core/Session/AccountSwitcher.php
+++ b/core/lib/Drupal/Core/Session/AccountSwitcher.php
@@ -16,14 +16,14 @@ class AccountSwitcher implements AccountSwitcherInterface {
*
* @var \Drupal\Core\Session\AccountInterface[]
*/
- protected $accountStack = array();
+ protected $accountStack = [];
/**
* The current user service.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
- protected $currentUser = array();
+ protected $currentUser = [];
/**
* The write-safe session handler.
diff --git a/core/lib/Drupal/Core/Session/SessionHandler.php b/core/lib/Drupal/Core/Session/SessionHandler.php
index 50bb22ffb75..4078d41f645 100644
--- a/core/lib/Drupal/Core/Session/SessionHandler.php
+++ b/core/lib/Drupal/Core/Session/SessionHandler.php
@@ -72,14 +72,14 @@ class SessionHandler extends AbstractProxy implements \SessionHandlerInterface {
// manually.
try {
$request = $this->requestStack->getCurrentRequest();
- $fields = array(
+ $fields = [
'uid' => $request->getSession()->get('uid', 0),
'hostname' => $request->getClientIP(),
'session' => $value,
'timestamp' => REQUEST_TIME,
- );
+ ];
$this->connection->merge('sessions')
- ->keys(array('sid' => Crypt::hashBase64($sid)))
+ ->keys(['sid' => Crypt::hashBase64($sid)])
->fields($fields)
->execute();
return TRUE;
diff --git a/core/lib/Drupal/Core/Session/SessionManager.php b/core/lib/Drupal/Core/Session/SessionManager.php
index 5f986021c1b..95495cfd033 100644
--- a/core/lib/Drupal/Core/Session/SessionManager.php
+++ b/core/lib/Drupal/Core/Session/SessionManager.php
@@ -83,7 +83,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
* @see \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage::setSaveHandler()
*/
public function __construct(RequestStack $request_stack, Connection $connection, MetadataBag $metadata_bag, SessionConfigurationInterface $session_configuration, $handler = NULL) {
- $options = array();
+ $options = [];
$this->sessionConfiguration = $session_configuration;
$this->requestStack = $request_stack;
$this->connection = $connection;
@@ -96,7 +96,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
// https://www.drupal.org/node/2229145, when we will be using the Symfony
// session object (which registers an attribute bag with the
// manager upon instantiation).
- $this->bags = array();
+ $this->bags = [];
}
/**
@@ -130,7 +130,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
$this->setId(Crypt::randomBytesBase64());
// Initialize the session global and attach the Symfony session bags.
- $_SESSION = array();
+ $_SESSION = [];
$this->loadSession();
// NativeSessionStorage::loadSession() sets started to TRUE, reset it to
@@ -305,7 +305,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
*/
protected function getSessionDataMask() {
if (empty($_SESSION)) {
- return array();
+ return [];
}
// Start out with a completely filled mask.
@@ -330,7 +330,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
* The old session ID. The new session ID is $this->getId().
*/
protected function migrateStoredSession($old_session_id) {
- $fields = array('sid' => Crypt::hashBase64($this->getId()));
+ $fields = ['sid' => Crypt::hashBase64($this->getId())];
$this->connection->update('sessions')
->fields($fields)
->condition('sid', Crypt::hashBase64($old_session_id))
diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php
index d4cdfe73f84..f25247d213e 100644
--- a/core/lib/Drupal/Core/Session/UserSession.php
+++ b/core/lib/Drupal/Core/Session/UserSession.php
@@ -23,7 +23,7 @@ class UserSession implements AccountInterface {
*
* @var array
*/
- protected $roles = array(AccountInterface::ANONYMOUS_ROLE);
+ protected $roles = [AccountInterface::ANONYMOUS_ROLE];
/**
* The Unix timestamp when the user last accessed the site.
@@ -73,7 +73,7 @@ class UserSession implements AccountInterface {
* @param array $values
* Array of initial values for the user session.
*/
- public function __construct(array $values = array()) {
+ public function __construct(array $values = []) {
foreach ($values as $key => $value) {
$this->$key = $value;
}
@@ -93,7 +93,7 @@ class UserSession implements AccountInterface {
$roles = $this->roles;
if ($exclude_locked_roles) {
- $roles = array_values(array_diff($roles, array(AccountInterface::ANONYMOUS_ROLE, AccountInterface::AUTHENTICATED_ROLE)));
+ $roles = array_values(array_diff($roles, [AccountInterface::ANONYMOUS_ROLE, AccountInterface::AUTHENTICATED_ROLE]));
}
return $roles;
diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php
index 2673fe8a9a0..a1a6c38893e 100644
--- a/core/lib/Drupal/Core/Site/Settings.php
+++ b/core/lib/Drupal/Core/Site/Settings.php
@@ -17,7 +17,7 @@ final class Settings {
*
* @var array
*/
- private $storage = array();
+ private $storage = [];
/**
* Singleton instance.
@@ -114,9 +114,9 @@ final class Settings {
public static function initialize($app_root, $site_path, &$class_loader) {
// Export these settings.php variables to the global namespace.
global $config_directories, $config;
- $settings = array();
- $config = array();
- $databases = array();
+ $settings = [];
+ $config = [];
+ $databases = [];
if (is_readable($app_root . '/' . $site_path . '/settings.php')) {
require $app_root . '/' . $site_path . '/settings.php';
diff --git a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
index 5208a2d0daa..e3e4895efec 100644
--- a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
+++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
@@ -73,7 +73,7 @@ class ReverseProxyMiddleware implements HttpKernelInterface {
$forwarded_header = $settings->get('reverse_proxy_forwarded_header', 'FORWARDED');
$request::setTrustedHeaderName($request::HEADER_FORWARDED, $forwarded_header);
- $proxies = $settings->get('reverse_proxy_addresses', array());
+ $proxies = $settings->get('reverse_proxy_addresses', []);
if (count($proxies) > 0) {
$request::setTrustedProxies($proxies);
}
diff --git a/core/lib/Drupal/Core/State/State.php b/core/lib/Drupal/Core/State/State.php
index 8b3b106fd14..572e5cbf339 100644
--- a/core/lib/Drupal/Core/State/State.php
+++ b/core/lib/Drupal/Core/State/State.php
@@ -56,7 +56,7 @@ class State extends CacheCollector implements StateInterface {
* {@inheritdoc}
*/
public function getMultiple(array $keys) {
- $values = array();
+ $values = [];
foreach ($keys as $key) {
$values[$key] = $this->get($key);
}
@@ -86,7 +86,7 @@ class State extends CacheCollector implements StateInterface {
*/
public function delete($key) {
parent::delete($key);
- $this->deleteMultiple(array($key));
+ $this->deleteMultiple([$key]);
}
/**
diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php
index 55d896aa49f..edcf4b7549f 100644
--- a/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php
+++ b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php
@@ -26,7 +26,7 @@ abstract class LocalReadOnlyStream extends LocalStream {
* {@inheritdoc}
*/
public function stream_open($uri, $mode, $options, &$opened_path) {
- if (!in_array($mode, array('r', 'rb', 'rt'))) {
+ if (!in_array($mode, ['r', 'rb', 'rt'])) {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING);
}
@@ -58,11 +58,11 @@ abstract class LocalReadOnlyStream extends LocalStream {
*/
public function stream_lock($operation) {
// Disallow exclusive lock or non-blocking lock requests
- if (in_array($operation, array(LOCK_EX, LOCK_EX | LOCK_NB))) {
+ if (in_array($operation, [LOCK_EX, LOCK_EX | LOCK_NB])) {
trigger_error('stream_lock() exclusive lock operations not supported for read-only stream wrappers', E_USER_WARNING);
return FALSE;
}
- if (in_array($operation, array(LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB))) {
+ if (in_array($operation, [LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB])) {
return flock($this->handle, $operation);
}
diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
index 343b461eecc..a6c8d2e48d6 100644
--- a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
+++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
@@ -189,7 +189,7 @@ abstract class LocalStream implements StreamWrapperInterface {
* @see http://php.net/manual/streamwrapper.stream-lock.php
*/
public function stream_lock($operation) {
- if (in_array($operation, array(LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB))) {
+ if (in_array($operation, [LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB])) {
return flock($this->handle, $operation);
}
diff --git a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php
index 1b48910b4aa..e5538cc42f2 100644
--- a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php
+++ b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php
@@ -71,7 +71,7 @@ abstract class ReadOnlyStream implements StreamWrapperInterface {
* @see http://php.net/manual/streamwrapper.stream-open.php
*/
public function stream_open($uri, $mode, $options, &$opened_path) {
- if (!in_array($mode, array('r', 'rb', 'rt'))) {
+ if (!in_array($mode, ['r', 'rb', 'rt'])) {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING);
}
@@ -111,11 +111,11 @@ abstract class ReadOnlyStream implements StreamWrapperInterface {
* @see http://php.net/manual/streamwrapper.stream-lock.php
*/
public function stream_lock($operation) {
- if (in_array($operation, array(LOCK_EX, LOCK_EX | LOCK_NB))) {
+ if (in_array($operation, [LOCK_EX, LOCK_EX | LOCK_NB])) {
trigger_error('stream_lock() exclusive lock operations not supported for read-only stream wrappers', E_USER_WARNING);
return FALSE;
}
- if (in_array($operation, array(LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB))) {
+ if (in_array($operation, [LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB])) {
return flock($this->handle, $operation);
}
diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php
index 26b8eeecc94..83310f68af2 100644
--- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php
+++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php
@@ -23,7 +23,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
*
* @var array
*/
- protected $info = array();
+ protected $info = [];
/**
* Contains collected stream wrappers.
@@ -41,7 +41,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
*
* @var array
*/
- protected $wrappers = array();
+ protected $wrappers = [];
/**
* {@inheritdoc}
@@ -51,7 +51,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
return $this->wrappers[$filter];
}
elseif (isset($this->wrappers[StreamWrapperInterface::ALL])) {
- $this->wrappers[$filter] = array();
+ $this->wrappers[$filter] = [];
foreach ($this->wrappers[StreamWrapperInterface::ALL] as $scheme => $info) {
// Bit-wise filter.
if (($info['type'] & $filter) == $filter) {
@@ -61,7 +61,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
return $this->wrappers[$filter];
}
else {
- return array();
+ return [];
}
}
@@ -69,7 +69,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
* {@inheritdoc}
*/
public function getNames($filter = StreamWrapperInterface::ALL) {
- $names = array();
+ $names = [];
foreach (array_keys($this->getWrappers($filter)) as $scheme) {
$names[$scheme] = $this->getViaScheme($scheme)->getName();
}
@@ -81,7 +81,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
* {@inheritdoc}
*/
public function getDescriptions($filter = StreamWrapperInterface::ALL) {
- $descriptions = array();
+ $descriptions = [];
foreach (array_keys($this->getWrappers($filter)) as $scheme) {
$descriptions[$scheme] = $this->getViaScheme($scheme)->getDescription();
}
@@ -149,11 +149,11 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
* The scheme for which the wrapper should be registered.
*/
public function addStreamWrapper($service_id, $class, $scheme) {
- $this->info[$scheme] = array(
+ $this->info[$scheme] = [
'class' => $class,
'type' => $class::getType(),
'service_id' => $service_id,
- );
+ ];
}
/**
@@ -200,7 +200,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana
}
// Pre-populate the static cache with the filters most typically used.
- $info = array('type' => $type, 'class' => $class);
+ $info = ['type' => $type, 'class' => $class];
$this->wrappers[StreamWrapperInterface::ALL][$scheme] = $info;
if (($type & StreamWrapperInterface::WRITE_VISIBLE) == StreamWrapperInterface::WRITE_VISIBLE) {
diff --git a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php
index 674145617fb..4600c170aaf 100644
--- a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php
+++ b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php
@@ -62,7 +62,7 @@ class PluralTranslatableMarkup extends TranslatableMarkup {
*/
public function __construct($count, $singular, $plural, array $args = [], array $options = [], TranslationInterface $string_translation = NULL) {
$this->count = $count;
- $translatable_string = implode(static::DELIMITER, array($singular, $plural));
+ $translatable_string = implode(static::DELIMITER, [$singular, $plural]);
parent::__construct($translatable_string, $args, $options, $string_translation);
}
@@ -161,7 +161,7 @@ class PluralTranslatableMarkup extends TranslatableMarkup {
* {@inheritdoc}
*/
public function __sleep() {
- return array_merge(parent::__sleep(), array('count'));
+ return array_merge(parent::__sleep(), ['count']);
}
}
diff --git a/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php b/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php
index 63ff01915b2..c435f79500c 100644
--- a/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php
+++ b/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php
@@ -67,7 +67,7 @@ trait StringTranslationTrait {
*
* @ingroup sanitization
*/
- protected function t($string, array $args = array(), array $options = array()) {
+ protected function t($string, array $args = [], array $options = []) {
return new TranslatableMarkup($string, $args, $options, $this->getStringTranslation());
}
@@ -76,7 +76,7 @@ trait StringTranslationTrait {
*
* @see \Drupal\Core\StringTranslation\TranslationInterface::formatPlural()
*/
- protected function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) {
+ protected function formatPlural($count, $singular, $plural, array $args = [], array $options = []) {
return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this->getStringTranslation());
}
diff --git a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php
index 8e3c13c6431..80162125850 100644
--- a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php
+++ b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php
@@ -134,7 +134,7 @@ class TranslatableMarkup extends FormattableMarkup {
*
* @ingroup sanitization
*/
- public function __construct($string, array $arguments = array(), array $options = array(), TranslationInterface $string_translation = NULL) {
+ public function __construct($string, array $arguments = [], array $options = [], TranslationInterface $string_translation = NULL) {
if (!is_string($string)) {
$message = $string instanceof TranslatableMarkup ? '$string ("' . $string->getUntranslatedString() . '") must be a string.' : '$string ("' . (string) $string . '") must be a string.';
throw new \InvalidArgumentException($message);
@@ -210,7 +210,7 @@ class TranslatableMarkup extends FormattableMarkup {
* Magic __sleep() method to avoid serializing the string translator.
*/
public function __sleep() {
- return array('string', 'arguments', 'options');
+ return ['string', 'arguments', 'options'];
}
/**
diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
index 8244302e63e..6a977b4a59e 100644
--- a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
+++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php
@@ -45,7 +45,7 @@ interface TranslationInterface {
*
* @ingroup sanitization
*/
- public function translate($string, array $args = array(), array $options = array());
+ public function translate($string, array $args = [], array $options = []);
/**
* Translates a TranslatableMarkup object to a string.
@@ -107,6 +107,6 @@ interface TranslationInterface {
* @see \Drupal\Component\Utility\SafeMarkup::format()
* @see \Drupal\Core\StringTranslation\PluralTranslatableMarkup::createFromTranslatedString()
*/
- public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array());
+ public function formatPlural($count, $singular, $plural, array $args = [], array $options = []);
}
diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php
index ce961207a02..40bf8f4b31d 100644
--- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php
+++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php
@@ -21,7 +21,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
* @see \Drupal\Core\StringTranslation\TranslationManager::addTranslator()
* @see \Drupal\Core\StringTranslation\TranslationManager::sortTranslators()
*/
- protected $translators = array();
+ protected $translators = [];
/**
* An array of translators, sorted by priority.
@@ -77,7 +77,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
* A sorted array of translator objects.
*/
protected function sortTranslators() {
- $sorted = array();
+ $sorted = [];
krsort($this->translators);
foreach ($this->translators as $translators) {
@@ -106,7 +106,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
/**
* {@inheritdoc}
*/
- public function translate($string, array $args = array(), array $options = array()) {
+ public function translate($string, array $args = [], array $options = []) {
return new TranslatableMarkup($string, $args, $options, $this);
}
@@ -131,7 +131,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
* @return string
* The translated string.
*/
- protected function doTranslate($string, array $options = array()) {
+ protected function doTranslate($string, array $options = []) {
// If a NULL langcode has been provided, unset it.
if (!isset($options['langcode']) && array_key_exists('langcode', $options)) {
unset($options['langcode']);
@@ -149,7 +149,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
/**
* {@inheritdoc}
*/
- public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) {
+ public function formatPlural($count, $singular, $plural, array $args = [], array $options = []) {
return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this);
}
diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php
index 8e733d5488a..286ab61b1d4 100644
--- a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php
+++ b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php
@@ -37,7 +37,7 @@ class CustomStrings extends StaticTranslation {
* {@inheritdoc}
*/
protected function getLanguage($langcode) {
- return $this->settings->get('locale_custom_strings_' . $langcode, array());
+ return $this->settings->get('locale_custom_strings_' . $langcode, []);
}
}
diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php b/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php
index abe5e9a7b55..deee5f4f055 100644
--- a/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php
+++ b/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php
@@ -47,7 +47,7 @@ class FileTranslation extends StaticTranslation {
return $this->filesToArray($langcode, $files);
}
else {
- return array();
+ return [];
}
}
@@ -70,7 +70,7 @@ class FileTranslation extends StaticTranslation {
* @see file_scan_directory()
*/
public function findTranslationFiles($langcode = NULL) {
- $files = file_scan_directory($this->directory, $this->getTranslationFilesPattern($langcode), array('recurse' => FALSE));
+ $files = file_scan_directory($this->directory, $this->getTranslationFilesPattern($langcode), ['recurse' => FALSE]);
return $files;
}
diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php
index 375130fb3c1..15ee5c5a286 100644
--- a/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php
+++ b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php
@@ -23,7 +23,7 @@ class StaticTranslation implements TranslatorInterface {
* @param array $translations
* Array of override strings indexed by language and context
*/
- public function __construct($translations = array()) {
+ public function __construct($translations = []) {
$this->translations = $translations;
}
@@ -46,7 +46,7 @@ class StaticTranslation implements TranslatorInterface {
* {@inheritdoc}
*/
public function reset() {
- $this->translations = array();
+ $this->translations = [];
}
/**
@@ -66,7 +66,7 @@ class StaticTranslation implements TranslatorInterface {
// constructor. This can be useful while testing, but it does not support
// loading specific languages. All available languages should be passed
// in the constructor array.
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php
index 945c5bc0d62..5449cde3da3 100644
--- a/core/lib/Drupal/Core/Template/Attribute.php
+++ b/core/lib/Drupal/Core/Template/Attribute.php
@@ -69,7 +69,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface {
*
* @var \Drupal\Core\Template\AttributeValueBase[]
*/
- protected $storage = array();
+ protected $storage = [];
/**
* Constructs a \Drupal\Core\Template\Attribute object.
@@ -77,7 +77,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface {
* @param array $attributes
* An associative array of key-value pairs to be converted to attributes.
*/
- public function __construct($attributes = array()) {
+ public function __construct($attributes = []) {
foreach ($attributes as $name => $value) {
$this->offsetSet($name, $value);
}
@@ -170,7 +170,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface {
public function addClass() {
$args = func_get_args();
if ($args) {
- $classes = array();
+ $classes = [];
foreach ($args as $arg) {
// Merge the values passed in from the classes array.
// The argument is cast to an array to support comma separated single
@@ -245,7 +245,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface {
// With no class attribute, there is no need to remove.
if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) {
$args = func_get_args();
- $classes = array();
+ $classes = [];
foreach ($args as $arg) {
// Merge the values passed in from the classes array.
// The argument is cast to an array to support comma separated single
diff --git a/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php b/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php
index abd4ef24fd2..3f727cf5238 100644
--- a/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php
+++ b/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php
@@ -24,11 +24,11 @@ class FilesystemLoader extends \Twig_Loader_Filesystem {
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler service.
*/
- public function __construct($paths = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
+ public function __construct($paths = [], ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
parent::__construct($paths);
// Add namespaced paths for modules and themes.
- $namespaces = array();
+ $namespaces = [];
foreach ($module_handler->getModuleList() as $name => $extension) {
$namespaces[$name] = $extension->getPath();
}
@@ -51,7 +51,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem {
*/
public function addPath($path, $namespace = self::MAIN_NAMESPACE) {
// Invalidate the cache.
- $this->cache = array();
+ $this->cache = [];
$this->paths[$namespace][] = rtrim($path, '/\\');
}
diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php
index f5ee4597675..21755a5057c 100644
--- a/core/lib/Drupal/Core/Template/TwigEnvironment.php
+++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php
@@ -42,19 +42,19 @@ class TwigEnvironment extends \Twig_Environment {
* @param array $options
* The options for the Twig environment.
*/
- public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, StateInterface $state, \Twig_LoaderInterface $loader = NULL, $options = array()) {
+ public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, StateInterface $state, \Twig_LoaderInterface $loader = NULL, $options = []) {
// Ensure that twig.engine is loaded, given that it is needed to render a
// template because functions like TwigExtension::escapeFilter() are called.
require_once $root . '/core/themes/engines/twig/twig.engine';
- $this->templateClasses = array();
+ $this->templateClasses = [];
- $options += array(
+ $options += [
// @todo Ensure garbage collection of expired files.
'cache' => TRUE,
'debug' => FALSE,
'auto_reload' => NULL,
- );
+ ];
// Ensure autoescaping is always on.
$options['autoescape'] = 'html';
@@ -137,7 +137,7 @@ class TwigEnvironment extends \Twig_Environment {
*
* @see \Drupal\Core\Template\Loader\StringLoader::exists()
*/
- public function renderInline($template_string, array $context = array()) {
+ public function renderInline($template_string, array $context = []) {
// Prefix all inline templates with a special comment.
$template_string = '{# inline_template_start #}' . $template_string;
return Markup::create($this->loadTemplate($template_string, NULL)->render($context));
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 9f259598cbe..520a8beb25f 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -137,12 +137,12 @@ class TwigExtension extends \Twig_Extension {
public function getFunctions() {
return [
// This function will receive a renderable array, if an array is detected.
- new \Twig_SimpleFunction('render_var', array($this, 'renderVar')),
+ new \Twig_SimpleFunction('render_var', [$this, 'renderVar']),
// The url and path function are defined in close parallel to those found
// in \Symfony\Bridge\Twig\Extension\RoutingExtension
- new \Twig_SimpleFunction('url', array($this, 'getUrl'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))),
- new \Twig_SimpleFunction('path', array($this, 'getPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))),
- new \Twig_SimpleFunction('link', array($this, 'getLink')),
+ new \Twig_SimpleFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
+ new \Twig_SimpleFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
+ new \Twig_SimpleFunction('link', [$this, 'getLink']),
new \Twig_SimpleFunction('file_url', function ($uri) {
return file_url_transform_relative(file_create_url($uri));
}),
@@ -157,19 +157,19 @@ class TwigExtension extends \Twig_Extension {
* {@inheritdoc}
*/
public function getFilters() {
- return array(
+ return [
// Translation filters.
- new \Twig_SimpleFilter('t', 't', array('is_safe' => array('html'))),
- new \Twig_SimpleFilter('trans', 't', array('is_safe' => array('html'))),
+ new \Twig_SimpleFilter('t', 't', ['is_safe' => ['html']]),
+ new \Twig_SimpleFilter('trans', 't', ['is_safe' => ['html']]),
// The "raw" filter is not detectable when parsing "trans" tags. To detect
// which prefix must be used for translation (@, !, %), we must clone the
// "raw" filter and give it identifiable names. These filters should only
// be used in "trans" tags.
// @see TwigNodeTrans::compileString()
- new \Twig_SimpleFilter('placeholder', [$this, 'escapePlaceholder'], array('is_safe' => array('html'), 'needs_environment' => TRUE)),
+ new \Twig_SimpleFilter('placeholder', [$this, 'escapePlaceholder'], ['is_safe' => ['html'], 'needs_environment' => TRUE]),
// Replace twig's escape filter with our own.
- new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], array('needs_environment' => TRUE, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
+ new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], ['needs_environment' => TRUE, 'is_safe_callback' => 'twig_escape_filter_is_safe']),
// Implements safe joining.
// @todo Make that the default for |join? Upstream issue:
@@ -183,9 +183,9 @@ class TwigExtension extends \Twig_Extension {
new \Twig_SimpleFilter('clean_class', '\Drupal\Component\Utility\Html::getClass'),
new \Twig_SimpleFilter('clean_id', '\Drupal\Component\Utility\Html::getId'),
// This filter will render a renderable array to use the string results.
- new \Twig_SimpleFilter('render', array($this, 'renderVar')),
- new \Twig_SimpleFilter('format_date', array($this->dateFormatter, 'format')),
- );
+ new \Twig_SimpleFilter('render', [$this, 'renderVar']),
+ new \Twig_SimpleFilter('format_date', [$this->dateFormatter, 'format']),
+ ];
}
/**
@@ -194,18 +194,18 @@ class TwigExtension extends \Twig_Extension {
public function getNodeVisitors() {
// The node visitor is needed to wrap all variables with
// render_var -> TwigExtension->renderVar() function.
- return array(
+ return [
new TwigNodeVisitor(),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getTokenParsers() {
- return array(
+ return [
new TwigTransTokenParser(),
- );
+ ];
}
/**
@@ -231,7 +231,7 @@ class TwigExtension extends \Twig_Extension {
*
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
*/
- public function getPath($name, $parameters = array(), $options = array()) {
+ public function getPath($name, $parameters = [], $options = []) {
$options['absolute'] = FALSE;
return $this->urlGenerator->generateFromRoute($name, $parameters, $options);
}
@@ -252,7 +252,7 @@ class TwigExtension extends \Twig_Extension {
*
* @todo Add an option for scheme-relative URLs.
*/
- public function getUrl($name, $parameters = array(), $options = array()) {
+ public function getUrl($name, $parameters = [], $options = []) {
// Generate URL.
$options['absolute'] = TRUE;
$generated_url = $this->urlGenerator->generateFromRoute($name, $parameters, $options, TRUE);
@@ -356,10 +356,10 @@ class TwigExtension extends \Twig_Extension {
if (!isset($parameter_node) || $parameter_node instanceof \Twig_Node_Expression_Array && count($parameter_node) <= 2 &&
(!$parameter_node->hasNode(1) || $parameter_node->getNode(1) instanceof \Twig_Node_Expression_Constant)) {
- return array('html');
+ return ['html'];
}
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Template/TwigNodeTrans.php b/core/lib/Drupal/Core/Template/TwigNodeTrans.php
index 21006fd1ed3..264a511172b 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeTrans.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeTrans.php
@@ -18,12 +18,12 @@ class TwigNodeTrans extends \Twig_Node {
* {@inheritdoc}
*/
public function __construct(\Twig_Node $body, \Twig_Node $plural = NULL, \Twig_Node_Expression $count = NULL, \Twig_Node_Expression $options = NULL, $lineno, $tag = NULL) {
- parent::__construct(array(
+ parent::__construct([
'count' => $count,
'body' => $body,
'plural' => $plural,
'options' => $options,
- ), array(), $lineno, $tag);
+ ], [], $lineno, $tag);
}
/**
@@ -95,10 +95,10 @@ class TwigNodeTrans extends \Twig_Node {
*/
protected function compileString(\Twig_Node $body) {
if ($body instanceof \Twig_Node_Expression_Name || $body instanceof \Twig_Node_Expression_Constant || $body instanceof \Twig_Node_Expression_TempName) {
- return array($body, array());
+ return [$body, []];
}
- $tokens = array();
+ $tokens = [];
if (count($body)) {
$text = '';
@@ -135,7 +135,7 @@ class TwigNodeTrans extends \Twig_Node {
$args = $args->getNode('node');
}
if ($args instanceof \Twig_Node_Expression_GetAttr) {
- $argName = array();
+ $argName = [];
// Reuse the incoming expression.
$expr = $args;
// Assemble a valid argument name by walking through the expression.
@@ -176,7 +176,7 @@ class TwigNodeTrans extends \Twig_Node {
$text = $body->getAttribute('data');
}
- return array(new \Twig_Node(array(new \Twig_Node_Expression_Constant(trim($text), $body->getLine()))), $tokens);
+ return [new \Twig_Node([new \Twig_Node_Expression_Constant(trim($text), $body->getLine())]), $tokens];
}
}
diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
index 6222d69e3a9..1ebfa57de92 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
@@ -35,7 +35,7 @@ class TwigNodeVisitor extends \Twig_BaseNodeVisitor {
$class = get_class($node);
$line = $node->getLine();
return new $class(
- new \Twig_Node_Expression_Function('render_var', new \Twig_Node(array($node->getNode('expr'))), $line),
+ new \Twig_Node_Expression_Function('render_var', new \Twig_Node([$node->getNode('expr')]), $line),
$line
);
}
diff --git a/core/lib/Drupal/Core/Template/TwigTransTokenParser.php b/core/lib/Drupal/Core/Template/TwigTransTokenParser.php
index fb160175375..96f55607f35 100644
--- a/core/lib/Drupal/Core/Template/TwigTransTokenParser.php
+++ b/core/lib/Drupal/Core/Template/TwigTransTokenParser.php
@@ -35,11 +35,11 @@ class TwigTransTokenParser extends \Twig_TokenParser {
}
if (!$body) {
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideForFork'));
+ $body = $this->parser->subparse([$this, 'decideForFork']);
if ('plural' === $stream->next()->getValue()) {
$count = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
- $plural = $this->parser->subparse(array($this, 'decideForEnd'), TRUE);
+ $plural = $this->parser->subparse([$this, 'decideForEnd'], TRUE);
}
}
@@ -56,7 +56,7 @@ class TwigTransTokenParser extends \Twig_TokenParser {
* Detect a 'plural' switch or the end of a 'trans' tag.
*/
public function decideForFork($token) {
- return $token->test(array('plural', 'endtrans'));
+ return $token->test(['plural', 'endtrans']);
}
/**
diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
index 25571b96a2b..e9d8d6686ef 100644
--- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
@@ -37,7 +37,7 @@ trait FunctionalTestSetupTrait {
/**
* The config directories used in this test.
*/
- protected $configDirectories = array();
+ protected $configDirectories = [];
/**
* Prepares site settings and services before installation.
@@ -218,7 +218,7 @@ trait FunctionalTestSetupTrait {
// Clear the tag cache.
\Drupal::service('cache_tags.invalidator')->resetChecksums();
foreach (Cache::getBins() as $backend) {
- if (is_callable(array($backend, 'reset'))) {
+ if (is_callable([$backend, 'reset'])) {
$backend->reset();
}
}
@@ -244,7 +244,7 @@ trait FunctionalTestSetupTrait {
* @return \Symfony\Component\HttpFoundation\Request
* The mocked request object.
*/
- protected function prepareRequestForGenerator($clean_urls = TRUE, $override_server_vars = array()) {
+ protected function prepareRequestForGenerator($clean_urls = TRUE, $override_server_vars = []) {
$request = Request::createFromGlobals();
$server = $request->server->all();
if (basename($server['SCRIPT_FILENAME']) != basename($server['SCRIPT_NAME'])) {
@@ -266,7 +266,7 @@ trait FunctionalTestSetupTrait {
}
$server = array_merge($server, $override_server_vars);
- $request = Request::create($request_path, 'GET', array(), array(), array(), $server);
+ $request = Request::create($request_path, 'GET', [], [], [], $server);
// Ensure the request time is REQUEST_TIME to ensure that API calls
// in the test use the right timestamp.
$request->server->set('REQUEST_TIME', REQUEST_TIME);
@@ -361,14 +361,14 @@ trait FunctionalTestSetupTrait {
protected function initUserSession() {
$password = $this->randomMachineName();
// Define information about the user 1 account.
- $this->rootUser = new UserSession(array(
+ $this->rootUser = new UserSession([
'uid' => 1,
'name' => 'admin',
'mail' => 'admin@example.com',
'pass_raw' => $password,
'passRaw' => $password,
'timezone' => date_default_timezone_get(),
- ));
+ ]);
// The child site derives its session name from the database prefix when
// running web tests.
diff --git a/core/lib/Drupal/Core/Test/TestRunnerKernel.php b/core/lib/Drupal/Core/Test/TestRunnerKernel.php
index f76e82c1d7a..5be2b83669a 100644
--- a/core/lib/Drupal/Core/Test/TestRunnerKernel.php
+++ b/core/lib/Drupal/Core/Test/TestRunnerKernel.php
@@ -33,14 +33,14 @@ class TestRunnerKernel extends DrupalKernel {
// \Drupal\Core\Datetime\DateFormatter has a (needless) dependency on the
// 'date_format' entity, so calls to format_date()/format_interval() cause
// a plugin not found exception.
- $this->moduleList = array(
+ $this->moduleList = [
'system' => 0,
'simpletest' => 0,
- );
- $this->moduleData = array(
+ ];
+ $this->moduleData = [
'system' => new Extension($this->root, 'module', 'core/modules/system/system.info.yml', 'system.module'),
'simpletest' => new Extension($this->root, 'module', 'core/modules/simpletest/simpletest.info.yml', 'simpletest.module'),
- );
+ ];
}
/**
@@ -49,13 +49,13 @@ class TestRunnerKernel extends DrupalKernel {
public function boot() {
// Ensure that required Settings exist.
if (!Settings::getAll()) {
- new Settings(array(
+ new Settings([
'hash_salt' => 'run-tests',
'container_yamls' => [],
// If there is no settings.php, then there is no parent site. In turn,
// there is no public files directory; use a custom public files path.
'file_public_path' => 'sites/default/files',
- ));
+ ]);
}
// Remove Drupal's error/exception handlers; they are designed for HTML
diff --git a/core/lib/Drupal/Core/Test/TestSetupTrait.php b/core/lib/Drupal/Core/Test/TestSetupTrait.php
index 31849c825e1..ea9137e4797 100644
--- a/core/lib/Drupal/Core/Test/TestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/TestSetupTrait.php
@@ -14,7 +14,7 @@ trait TestSetupTrait {
*
* @var string[]
*/
- protected static $configSchemaCheckerExclusions = array(
+ protected static $configSchemaCheckerExclusions = [
// Following are used to test lack of or partial schema. Where partial
// schema is provided, that is explicitly tested in specific tests.
'config_schema_test.noschema',
@@ -23,7 +23,7 @@ trait TestSetupTrait {
'config_schema_test.no_schema_data_types',
// Used to test application of schema to filtering of configuration.
'config_test.dynamic.system',
- );
+ ];
/**
* The dependency injection container used in the test.
@@ -172,9 +172,9 @@ trait TestSetupTrait {
foreach ($connection_info as $target => $value) {
// Replace the full table prefix definition to ensure that no table
// prefixes of the test runner leak into the test.
- $connection_info[$target]['prefix'] = array(
+ $connection_info[$target]['prefix'] = [
'default' => $value['prefix']['default'] . $this->databasePrefix,
- );
+ ];
}
Database::addConnectionInfo('default', 'default', $connection_info['default']);
}
diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php
index a3054e300d5..a0af70261cb 100644
--- a/core/lib/Drupal/Core/Theme/Registry.php
+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -249,7 +249,7 @@ class Registry implements DestructableInterface {
public function getRuntime() {
$this->init($this->themeName);
if (!isset($this->runtimeRegistry[$this->theme->getName()])) {
- $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->runtimeCache ?: $this->cache, $this->lock, array('theme_registry'), $this->moduleHandler->isLoaded());
+ $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->runtimeCache ?: $this->cache, $this->lock, ['theme_registry'], $this->moduleHandler->isLoaded());
}
return $this->runtimeRegistry[$this->theme->getName()];
}
@@ -258,7 +258,7 @@ class Registry implements DestructableInterface {
* Persists the theme registry in the cache backend.
*/
protected function setCache() {
- $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry[$this->theme->getName()], Cache::PERMANENT, array('theme_registry'));
+ $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry[$this->theme->getName()], Cache::PERMANENT, ['theme_registry']);
}
/**
@@ -320,7 +320,7 @@ class Registry implements DestructableInterface {
* @see hook_theme_registry_alter()
*/
protected function build() {
- $cache = array();
+ $cache = [];
// First, preprocess the theme hooks advertised by modules. This will
// serve as the basic registry. Since the list of enabled modules is the
// same regardless of the theme used, this is cached in its own entry to
@@ -334,7 +334,7 @@ class Registry implements DestructableInterface {
}
// Only cache this registry if all modules are loaded.
if ($this->moduleHandler->isLoaded()) {
- $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, array('theme_registry'));
+ $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, ['theme_registry']);
}
}
@@ -428,14 +428,14 @@ class Registry implements DestructableInterface {
* @throws \BadFunctionCallException
*/
protected function processExtension(array &$cache, $name, $type, $theme, $path) {
- $result = array();
+ $result = [];
- $hook_defaults = array(
+ $hook_defaults = [
'variables' => TRUE,
'render element' => TRUE,
'pattern' => TRUE,
'base hook' => TRUE,
- );
+ ];
$module_list = array_keys($this->moduleHandler->getModuleList());
@@ -519,8 +519,8 @@ class Registry implements DestructableInterface {
// Preprocess variables for all theming hooks, whether the hook is
// implemented as a template or as a function. Ensure they are arrays.
if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) {
- $info['preprocess functions'] = array();
- $prefixes = array();
+ $info['preprocess functions'] = [];
+ $prefixes = [];
if ($type == 'module') {
// Default variable preprocessor prefix.
$prefixes[] = 'template';
@@ -578,7 +578,7 @@ class Registry implements DestructableInterface {
// Check only if not registered by the theme or engine.
if (empty($result[$hook])) {
if (!isset($info['preprocess functions'])) {
- $cache[$hook]['preprocess functions'] = array();
+ $cache[$hook]['preprocess functions'] = [];
}
// Only use non-hook-specific variable preprocessors for theme hooks
// implemented as templates. See the @defgroup themeable topic.
@@ -605,7 +605,7 @@ class Registry implements DestructableInterface {
*/
protected function completeSuggestion($hook, array &$cache) {
$previous_hook = $hook;
- $incomplete_previous_hook = array();
+ $incomplete_previous_hook = [];
// Continue looping if the candidate hook doesn't exist or if the candidate
// hook has incomplete preprocess functions, and if the candidate hook is a
// suggestion (has a double underscore).
@@ -767,7 +767,7 @@ class Registry implements DestructableInterface {
$this->runtimeRegistry = [];
$this->registry = [];
- Cache::invalidateTags(array('theme_registry'));
+ Cache::invalidateTags(['theme_registry']);
return $this;
}
@@ -788,7 +788,7 @@ class Registry implements DestructableInterface {
* @return array
* Functions grouped by the first prefix.
*/
- public function getPrefixGroupedUserFunctions($prefixes = array()) {
+ public function getPrefixGroupedUserFunctions($prefixes = []) {
$functions = get_defined_functions();
// If a list of prefixes is supplied, trim down the list to those items
diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
index bf585844ba0..95ce5f3e951 100644
--- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php
+++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
@@ -100,7 +100,7 @@ class ThemeInitialization implements ThemeInitializationInterface {
}
// Find all our ancestor themes and put them in an array.
- $base_themes = array();
+ $base_themes = [];
$ancestor = $theme_name;
while ($ancestor && isset($themes[$ancestor]->base_theme)) {
$ancestor = $themes[$ancestor]->base_theme;
@@ -220,7 +220,7 @@ class ThemeInitialization implements ThemeInitializationInterface {
}
// Do basically the same as the above for libraries
- $values['libraries'] = array();
+ $values['libraries'] = [];
// Grab libraries from base theme
foreach ($base_themes as $base) {
@@ -242,7 +242,7 @@ class ThemeInitialization implements ThemeInitializationInterface {
$values['owner'] = isset($theme->owner) ? $theme->owner : NULL;
$values['extension'] = $theme;
- $base_active_themes = array();
+ $base_active_themes = [];
foreach ($base_themes as $base_theme) {
$base_active_themes[$base_theme->getName()] = $this->getActiveTheme($base_theme, array_slice($base_themes, 1));
}
@@ -310,7 +310,7 @@ class ThemeInitialization implements ThemeInitializationInterface {
// Prepare stylesheets from this theme as well as all ancestor themes.
// We work it this way so that we can have child themes remove CSS files
// easily from parent.
- $stylesheets_remove = array();
+ $stylesheets_remove = [];
// Grab stylesheets from base theme.
foreach ($base_themes as $base) {
if (!empty($base->info['stylesheets-remove'])) {
diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php
index ed18039f7d4..c58d176d451 100644
--- a/core/lib/Drupal/Core/Theme/ThemeManager.php
+++ b/core/lib/Drupal/Core/Theme/ThemeManager.php
@@ -171,7 +171,7 @@ class ThemeManager implements ThemeManagerInterface {
// Only log a message when not trying theme suggestions ($hook being an
// array).
if (!isset($candidate)) {
- \Drupal::logger('theme')->warning('Theme hook %hook not found.', array('%hook' => $hook));
+ \Drupal::logger('theme')->warning('Theme hook %hook not found.', ['%hook' => $hook]);
}
// There is no theme implementation for the hook passed. Return FALSE so
// the function calling
@@ -188,7 +188,7 @@ class ThemeManager implements ThemeManagerInterface {
// the arguments expected by the theme function.
if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
$element = $variables;
- $variables = array();
+ $variables = [];
if (isset($info['variables'])) {
foreach (array_keys($info['variables']) as $name) {
if (isset($element["#$name"]) || array_key_exists("#$name", $element)) {
@@ -208,12 +208,12 @@ class ThemeManager implements ThemeManagerInterface {
$variables += $info['variables'];
}
elseif (!empty($info['render element'])) {
- $variables += array($info['render element'] => array());
+ $variables += [$info['render element'] => []];
}
// Supply original caller info.
- $variables += array(
+ $variables += [
'theme_hook_original' => $original_hook,
- );
+ ];
// Set base hook for later use. For example if '#theme' => 'node__article'
// is called, we run hook_theme_suggestions_node_alter() rather than
@@ -227,7 +227,7 @@ class ThemeManager implements ThemeManagerInterface {
}
// Invoke hook_theme_suggestions_HOOK().
- $suggestions = $this->moduleHandler->invokeAll('theme_suggestions_' . $base_theme_hook, array($variables));
+ $suggestions = $this->moduleHandler->invokeAll('theme_suggestions_' . $base_theme_hook, [$variables]);
// If the theme implementation was invoked with a direct theme suggestion
// like '#theme' => 'node__article', add it to the suggestions array before
// invoking suggestion alter hooks.
@@ -237,10 +237,10 @@ class ThemeManager implements ThemeManagerInterface {
// Invoke hook_theme_suggestions_alter() and
// hook_theme_suggestions_HOOK_alter().
- $hooks = array(
+ $hooks = [
'theme_suggestions',
'theme_suggestions_' . $base_theme_hook,
- );
+ ];
$this->moduleHandler->alter($hooks, $suggestions, $variables, $base_theme_hook);
$this->alter($hooks, $suggestions, $variables, $base_theme_hook);
@@ -347,14 +347,14 @@ class ThemeManager implements ThemeManagerInterface {
// intuitive, is reasonably safe, and allows us to save on the overhead of
// adding some new variable to track that.
if (!isset($variables['directory'])) {
- $default_template_variables = array();
+ $default_template_variables = [];
template_preprocess($default_template_variables, $hook, $info);
$variables += $default_template_variables;
}
if (!isset($default_attributes)) {
$default_attributes = new Attribute();
}
- foreach (array('attributes', 'title_attributes', 'content_attributes') as $key) {
+ foreach (['attributes', 'title_attributes', 'content_attributes'] as $key) {
if (isset($variables[$key]) && !($variables[$key] instanceof Attribute)) {
if ($variables[$key]) {
$variables[$key] = new Attribute($variables[$key]);
@@ -427,13 +427,13 @@ class ThemeManager implements ThemeManagerInterface {
}
}
- $theme_keys = array();
+ $theme_keys = [];
foreach ($theme->getBaseThemes() as $base) {
$theme_keys[] = $base->getName();
}
$theme_keys[] = $theme->getName();
- $functions = array();
+ $functions = [];
foreach ($theme_keys as $theme_key) {
$function = $theme_key . '_' . $type . '_alter';
if (function_exists($function)) {
diff --git a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php
index 3064eb073e6..c932e89d532 100644
--- a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php
+++ b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php
@@ -17,7 +17,7 @@ class ThemeNegotiator implements ThemeNegotiatorInterface {
*
* @var array
*/
- protected $negotiators = array();
+ protected $negotiators = [];
/**
* Holds the array of theme negotiators sorted by priority.
@@ -71,7 +71,7 @@ class ThemeNegotiator implements ThemeNegotiatorInterface {
krsort($this->negotiators);
// Merge nested negotiators from $this->negotiators into
// $this->sortedNegotiators.
- $this->sortedNegotiators = array();
+ $this->sortedNegotiators = [];
foreach ($this->negotiators as $builders) {
$this->sortedNegotiators = array_merge($this->sortedNegotiators, $builders);
}
diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php
index d0878ede45a..7eec1a90c45 100644
--- a/core/lib/Drupal/Core/TypedData/DataDefinition.php
+++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php
@@ -12,7 +12,7 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess {
*
* @var array
*/
- protected $definition = array();
+ protected $definition = [];
/**
* Creates a new data definition.
@@ -41,7 +41,7 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess {
* @param array $values
* (optional) If given, an array of initial values to set on the definition.
*/
- public function __construct(array $values = array()) {
+ public function __construct(array $values = []) {
$this->definition = $values;
}
@@ -213,7 +213,7 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess {
* {@inheritdoc}
*/
public function getSettings() {
- return isset($this->definition['settings']) ? $this->definition['settings'] : array();
+ return isset($this->definition['settings']) ? $this->definition['settings'] : [];
}
/**
@@ -257,7 +257,7 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess {
* {@inheritdoc}
*/
public function getConstraints() {
- $constraints = isset($this->definition['constraints']) ? $this->definition['constraints'] : array();
+ $constraints = isset($this->definition['constraints']) ? $this->definition['constraints'] : [];
$constraints += \Drupal::typedDataManager()->getDefaultConstraints($this);
return $constraints;
}
diff --git a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php
index 302f501be52..3109cd21156 100644
--- a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php
+++ b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php
@@ -41,13 +41,13 @@ class ListDataDefinition extends DataDefinition implements ListDataDefinitionInt
* {@inheritdoc}
*/
public static function createFromItemType($item_type) {
- return new static(array(), \Drupal::typedDataManager()->createDataDefinition($item_type));
+ return new static([], \Drupal::typedDataManager()->createDataDefinition($item_type));
}
/**
* {@inheritdoc}
*/
- public function __construct(array $values = array(), DataDefinitionInterface $item_definition = NULL) {
+ public function __construct(array $values = [], DataDefinitionInterface $item_definition = NULL) {
$this->definition = $values;
$this->itemDefinition = $item_definition;
}
diff --git a/core/lib/Drupal/Core/TypedData/MapDataDefinition.php b/core/lib/Drupal/Core/TypedData/MapDataDefinition.php
index 067a0f413fc..203e4a367ed 100644
--- a/core/lib/Drupal/Core/TypedData/MapDataDefinition.php
+++ b/core/lib/Drupal/Core/TypedData/MapDataDefinition.php
@@ -39,7 +39,7 @@ class MapDataDefinition extends ComplexDataDefinitionBase {
*/
public function getPropertyDefinitions() {
if (!isset($this->propertyDefinitions)) {
- $this->propertyDefinitions = array();
+ $this->propertyDefinitions = [];
}
return $this->propertyDefinitions;
}
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
index 77334272380..4f756dadf25 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
@@ -30,13 +30,13 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface {
*
* @var \Drupal\Core\TypedData\TypedDataInterface[]
*/
- protected $list = array();
+ protected $list = [];
/**
* {@inheritdoc}
*/
public function getValue() {
- $values = array();
+ $values = [];
foreach ($this->list as $delta => $item) {
$values[$delta] = $item->getValue();
}
@@ -50,8 +50,8 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface {
* An array of values of the field items, or NULL to unset the field.
*/
public function setValue($values, $notify = TRUE) {
- if (!isset($values) || $values === array()) {
- $this->list = array();
+ if (!isset($values) || $values === []) {
+ $this->list = [];
}
else {
// Only arrays with numeric keys are supported.
@@ -82,7 +82,7 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface {
* {@inheritdoc}
*/
public function getString() {
- $strings = array();
+ $strings = [];
foreach ($this->list as $item) {
$strings[] = $item->getString();
}
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
index 3af3a6b3080..a95c14b30e3 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
@@ -38,14 +38,14 @@ class Map extends TypedData implements \IteratorAggregate, ComplexDataInterface
*
* @var array
*/
- protected $values = array();
+ protected $values = [];
/**
* The array of properties.
*
* @var \Drupal\Core\TypedData\TypedDataInterface[]
*/
- protected $properties = array();
+ protected $properties = [];
/**
* {@inheritdoc}
@@ -95,7 +95,7 @@ class Map extends TypedData implements \IteratorAggregate, ComplexDataInterface
* {@inheritdoc}
*/
public function getString() {
- $strings = array();
+ $strings = [];
foreach ($this->getProperties() as $property) {
$strings[] = $property->getString();
}
@@ -154,7 +154,7 @@ class Map extends TypedData implements \IteratorAggregate, ComplexDataInterface
* {@inheritdoc}
*/
public function getProperties($include_computed = FALSE) {
- $properties = array();
+ $properties = [];
foreach ($this->definition->getPropertyDefinitions() as $name => $definition) {
if ($include_computed || !$definition->isComputed()) {
$properties[$name] = $this->get($name);
@@ -167,7 +167,7 @@ class Map extends TypedData implements \IteratorAggregate, ComplexDataInterface
* {@inheritdoc}
*/
public function toArray() {
- $values = array();
+ $values = [];
foreach ($this->getProperties() as $name => $property) {
$values[$name] = $property->getValue();
}
diff --git a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php
index 5100e6e6395..5b57a8717f1 100644
--- a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php
+++ b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php
@@ -95,7 +95,7 @@ interface TranslatableInterface {
* @throws \InvalidArgumentException
* If an invalid or existing translation language is specified.
*/
- public function addTranslation($langcode, array $values = array());
+ public function addTranslation($langcode, array $values = []);
/**
* Removes the translation identified by the given language code.
diff --git a/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php
index 809d0e63b30..243d48a92f6 100644
--- a/core/lib/Drupal/Core/TypedData/TypedData.php
+++ b/core/lib/Drupal/Core/TypedData/TypedData.php
@@ -121,7 +121,7 @@ abstract class TypedData implements TypedDataInterface, PluginInspectionInterfac
*/
public function getConstraints() {
$constraint_manager = $this->getTypedDataManager()->getValidationConstraintManager();
- $constraints = array();
+ $constraints = [];
foreach ($this->definition->getConstraints() as $name => $options) {
$constraints[] = $constraint_manager->create($name, $options);
}
diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
index b1c295d00e4..8c4f265ebdb 100644
--- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php
+++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
@@ -40,7 +40,7 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
*
* @var array
*/
- protected $prototypes = array();
+ protected $prototypes = [];
/**
* The class resolver.
@@ -73,7 +73,7 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
/**
* {@inheritdoc}
*/
- public function createInstance($data_type, array $configuration = array()) {
+ public function createInstance($data_type, array $configuration = []) {
$data_definition = $configuration['data_definition'];
$type_definition = $this->getDefinition($data_type);
@@ -97,11 +97,11 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
* {@inheritdoc}
*/
public function create(DataDefinitionInterface $definition, $value = NULL, $name = NULL, $parent = NULL) {
- $typed_data = $this->createInstance($definition->getDataType(), array(
+ $typed_data = $this->createInstance($definition->getDataType(), [
'data_definition' => $definition,
'name' => $name,
'parent' => $parent,
- ));
+ ]);
if (isset($value)) {
$typed_data->setValue($value, FALSE);
}
@@ -239,12 +239,12 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
* {@inheritdoc}
*/
public function getDefaultConstraints(DataDefinitionInterface $definition) {
- $constraints = array();
+ $constraints = [];
$type_definition = $this->getDefinition($definition->getDataType());
// Auto-generate a constraint for data types implementing a primitive
// interface.
if (is_subclass_of($type_definition['class'], '\Drupal\Core\TypedData\PrimitiveInterface')) {
- $constraints['PrimitiveType'] = array();
+ $constraints['PrimitiveType'] = [];
}
// Add in constraints specified by the data type.
if (isset($type_definition['constraints'])) {
@@ -252,11 +252,11 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
}
// Add the NotNull constraint for required data.
if ($definition->isRequired()) {
- $constraints['NotNull'] = array();
+ $constraints['NotNull'] = [];
}
// Check if the class provides allowed values.
if (is_subclass_of($definition->getClass(), 'Drupal\Core\TypedData\OptionsProviderInterface')) {
- $constraints['AllowedValues'] = array();
+ $constraints['AllowedValues'] = [];
}
return $constraints;
}
@@ -266,7 +266,7 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
*/
public function clearCachedDefinitions() {
parent::clearCachedDefinitions();
- $this->prototypes = array();
+ $this->prototypes = [];
}
/**
diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php b/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php
index 20a4a76af28..29723c6fc19 100644
--- a/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php
+++ b/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php
@@ -34,7 +34,7 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
*
* @see \Drupal\Core\TypedData\TypedDataManager::create()
*/
- public function createInstance($data_type, array $configuration = array());
+ public function createInstance($data_type, array $configuration = []);
/**
* Creates a new typed data object instance.
diff --git a/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php b/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php
index a20fa527a5b..c72cd55d402 100644
--- a/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php
+++ b/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php
@@ -96,14 +96,14 @@ class ExecutionContext implements ExecutionContextInterface {
*
* @var array
*/
- protected $validatedObjects = array();
+ protected $validatedObjects = [];
/**
* Stores which class constraint has been validated for which object.
*
* @var array
*/
- protected $validatedConstraints = array();
+ protected $validatedConstraints = [];
/**
* Creates a new ExecutionContext.
@@ -155,7 +155,7 @@ class ExecutionContext implements ExecutionContextInterface {
/**
* {@inheritdoc}
*/
- public function addViolation($message, array $parameters = array(), $invalidValue = NULL, $plural = NULL, $code = NULL) {
+ public function addViolation($message, array $parameters = [], $invalidValue = NULL, $plural = NULL, $code = NULL) {
// The parameters $invalidValue and following are ignored by the new
// API, as they are not present in the new interface anymore.
// You should use buildViolation() instead.
@@ -169,7 +169,7 @@ class ExecutionContext implements ExecutionContextInterface {
/**
* {@inheritdoc}
*/
- public function buildViolation($message, array $parameters = array()) {
+ public function buildViolation($message, array $parameters = []) {
return new ConstraintViolationBuilder($this->violations, $this->constraint, $message, $parameters, $this->root, $this->propertyPath, $this->value, $this->translator, $this->translationDomain);
}
@@ -246,7 +246,7 @@ class ExecutionContext implements ExecutionContextInterface {
/**
* {@inheritdoc}
*/
- public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = NULL, $plural = NULL, $code = NULL) {
+ public function addViolationAt($subPath, $message, array $parameters = [], $invalidValue = NULL, $plural = NULL, $code = NULL) {
throw new \LogicException('Legacy validator API is unsupported.');
}
diff --git a/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php b/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php
index b765b051ec0..a5d453ae58e 100644
--- a/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php
+++ b/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php
@@ -93,7 +93,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface {
// You can pass a single constraint or an array of constraints.
// Make sure to deal with an array in the rest of the code.
if (isset($constraints) && !is_array($constraints)) {
- $constraints = array($constraints);
+ $constraints = [$constraints];
}
$this->validateNode($data, $constraints, $is_root_call);
diff --git a/core/lib/Drupal/Core/Update/UpdateRegistry.php b/core/lib/Drupal/Core/Update/UpdateRegistry.php
index 4d4bbf5af64..bb0b91f5ade 100644
--- a/core/lib/Drupal/Core/Update/UpdateRegistry.php
+++ b/core/lib/Drupal/Core/Update/UpdateRegistry.php
@@ -187,7 +187,7 @@ class UpdateRegistry {
list($module, $update) = explode("_{$this->updateType}_", $function);
// The description for an update comes from its Doxygen.
$func = new \ReflectionFunction($function);
- $description = trim(str_replace(array("\n", '*', '/'), '', $func->getDocComment()), ' ');
+ $description = trim(str_replace(["\n", '*', '/'], '', $func->getDocComment()), ' ');
$ret[$module]['pending'][$update] = $description;
if (!isset($ret[$module]['start'])) {
$ret[$module]['start'] = $update;
diff --git a/core/lib/Drupal/Core/Updater/Module.php b/core/lib/Drupal/Core/Updater/Module.php
index be0d34be371..0a244b46bc1 100644
--- a/core/lib/Drupal/Core/Updater/Module.php
+++ b/core/lib/Drupal/Core/Updater/Module.php
@@ -49,7 +49,7 @@ class Module extends Updater implements UpdaterInterface {
public function isInstalled() {
// Check if the module exists in the file system, regardless of whether it
// is enabled or not.
- $modules = \Drupal::state()->get('system.module.files', array());
+ $modules = \Drupal::state()->get('system.module.files', []);
return isset($modules[$this->name]);
}
@@ -84,12 +84,12 @@ class Module extends Updater implements UpdaterInterface {
require_once DRUPAL_ROOT . '/core/includes/update.inc';
if (!self::canUpdate($this->name)) {
- return array();
+ return [];
}
module_load_include('install', $this->name);
if (!$updates = drupal_get_schema_versions($this->name)) {
- return array();
+ return [];
}
$modules_with_updates = update_get_update_list();
if ($updates = $modules_with_updates[$this->name]) {
@@ -97,7 +97,7 @@ class Module extends Updater implements UpdaterInterface {
return $updates['pending'];
}
}
- return array();
+ return [];
}
/**
diff --git a/core/lib/Drupal/Core/Updater/Theme.php b/core/lib/Drupal/Core/Updater/Theme.php
index 48f68c75673..d16af573818 100644
--- a/core/lib/Drupal/Core/Updater/Theme.php
+++ b/core/lib/Drupal/Core/Updater/Theme.php
@@ -49,7 +49,7 @@ class Theme extends Updater implements UpdaterInterface {
public function isInstalled() {
// Check if the theme exists in the file system, regardless of whether it
// is enabled or not.
- $themes = \Drupal::state()->get('system.theme.files', array());
+ $themes = \Drupal::state()->get('system.theme.files', []);
return isset($themes[$this->name]);
}
diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php
index 0381728e9b4..a1ba1031173 100644
--- a/core/lib/Drupal/Core/Updater/Updater.php
+++ b/core/lib/Drupal/Core/Updater/Updater.php
@@ -86,7 +86,7 @@ class Updater {
$updaters = drupal_get_updaters();
foreach ($updaters as $updater) {
$class = $updater['class'];
- if (call_user_func(array($class, 'canUpdateDirectory'), $directory)) {
+ if (call_user_func([$class, 'canUpdateDirectory'], $directory)) {
return $class;
}
}
@@ -174,7 +174,7 @@ class Updater {
$info_file = self::findInfoFile($directory);
$info = \Drupal::service('info_parser')->parse($info_file);
if (empty($info)) {
- throw new UpdaterException(t('Unable to parse info file: %info_file.', array('%info_file' => $info_file)));
+ throw new UpdaterException(t('Unable to parse info file: %info_file.', ['%info_file' => $info_file]));
}
return $info['name'];
}
@@ -188,12 +188,12 @@ class Updater {
* @return array
* An array of configuration parameters for an update or install operation.
*/
- protected function getInstallArgs($overrides = array()) {
- $args = array(
+ protected function getInstallArgs($overrides = []) {
+ $args = [
'make_backup' => FALSE,
'install_dir' => $this->getInstallDirectory(),
'backup_dir' => $this->getBackupDir(),
- );
+ ];
return array_merge($args, $overrides);
}
@@ -212,7 +212,7 @@ class Updater {
* @throws \Drupal\Core\Updater\UpdaterException
* @throws \Drupal\Core\Updater\UpdaterFileTransferException
*/
- public function update(&$filetransfer, $overrides = array()) {
+ public function update(&$filetransfer, $overrides = []) {
try {
// Establish arguments with possible overrides.
$args = $this->getInstallArgs($overrides);
@@ -249,7 +249,7 @@ class Updater {
return $this->postUpdateTasks();
}
catch (FileTransferException $e) {
- throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments))));
+ throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', ['@reason' => strtr($e->getMessage(), $e->arguments)]));
}
}
@@ -266,7 +266,7 @@ class Updater {
*
* @throws \Drupal\Core\Updater\UpdaterFileTransferException
*/
- public function install(&$filetransfer, $overrides = array()) {
+ public function install(&$filetransfer, $overrides = []) {
try {
// Establish arguments with possible overrides.
$args = $this->getInstallArgs($overrides);
@@ -287,7 +287,7 @@ class Updater {
return $this->postInstallTasks();
}
catch (FileTransferException $e) {
- throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments))));
+ throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', ['@reason' => strtr($e->getMessage(), $e->arguments)]));
}
}
@@ -326,7 +326,7 @@ class Updater {
}
catch (FileTransferException $e) {
$message = t($e->getMessage(), $e->arguments);
- $throw_message = t('Unable to create %directory due to the following: %reason', array('%directory' => $directory, '%reason' => $message));
+ $throw_message = t('Unable to create %directory due to the following: %reason', ['%directory' => $directory, '%reason' => $message]);
throw new UpdaterException($throw_message);
}
}
@@ -395,7 +395,7 @@ class Updater {
* Links which provide actions to take after the install is finished.
*/
public function postInstallTasks() {
- return array();
+ return [];
}
/**
@@ -405,7 +405,7 @@ class Updater {
* Links which provide actions to take after the update is finished.
*/
public function postUpdateTasks() {
- return array();
+ return [];
}
}
diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php
index ccc62fe750b..76dc46c77b1 100644
--- a/core/lib/Drupal/Core/Url.php
+++ b/core/lib/Drupal/Core/Url.php
@@ -51,7 +51,7 @@ class Url {
*
* @var array
*/
- protected $routeParameters = array();
+ protected $routeParameters = [];
/**
* The URL options.
@@ -60,7 +60,7 @@ class Url {
*
* @var array
*/
- protected $options = array();
+ protected $options = [];
/**
* Indicates whether this object contains an external URL.
@@ -112,7 +112,7 @@ class Url {
* @todo Update this documentation for non-routed URIs in
* https://www.drupal.org/node/2346787
*/
- public function __construct($route_name, $route_parameters = array(), $options = array()) {
+ public function __construct($route_name, $route_parameters = [], $options = []) {
$this->routeName = $route_name;
$this->routeParameters = $route_parameters;
$this->options = $options;
@@ -138,7 +138,7 @@ class Url {
* @see \Drupal\Core\Url::fromUserInput()
* @see \Drupal\Core\Url::fromUri()
*/
- public static function fromRoute($route_name, $route_parameters = array(), $options = array()) {
+ public static function fromRoute($route_name, $route_parameters = [], $options = []) {
return new static($route_name, $route_parameters, $options);
}
@@ -310,7 +310,7 @@ class Url {
$url = static::fromRouteUri($uri_parts, $uri_options, $uri);
}
else {
- $url = new static($uri, array(), $options);
+ $url = new static($uri, [], $options);
if ($uri_parts['scheme'] !== 'base') {
$url->external = TRUE;
$url->setOption('external', TRUE);
@@ -494,7 +494,7 @@ class Url {
$this->uri = $this->routeName;
// Set empty route name and parameters.
$this->routeName = NULL;
- $this->routeParameters = array();
+ $this->routeParameters = [];
return $this;
}
diff --git a/core/lib/Drupal/Core/Utility/Error.php b/core/lib/Drupal/Core/Utility/Error.php
index 6105a59021c..eb452c24268 100644
--- a/core/lib/Drupal/Core/Utility/Error.php
+++ b/core/lib/Drupal/Core/Utility/Error.php
@@ -23,7 +23,7 @@ class Error {
*
* @var array
*/
- protected static $blacklistFunctions = array('debug', '_drupal_error_handler', '_drupal_exception_handler');
+ protected static $blacklistFunctions = ['debug', '_drupal_error_handler', '_drupal_exception_handler'];
/**
* Decodes an exception and retrieves the correct caller.
@@ -39,7 +39,7 @@ class Error {
$backtrace = $exception->getTrace();
// Add the line throwing the exception to the backtrace.
- array_unshift($backtrace, array('line' => $exception->getLine(), 'file' => $exception->getFile()));
+ array_unshift($backtrace, ['line' => $exception->getLine(), 'file' => $exception->getFile()]);
// For PDOException errors, we try to return the initial caller,
// skipping internal functions of the database layer.
@@ -47,7 +47,7 @@ class Error {
// The first element in the stack is the call, the second element gives us
// the caller. We skip calls that occurred in one of the classes of the
// database layer or in one of its global functions.
- $db_functions = array('db_query', 'db_query_range');
+ $db_functions = ['db_query', 'db_query_range'];
while (!empty($backtrace[1]) && ($caller = $backtrace[1]) &&
((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) ||
in_array($caller['function'], $db_functions))) {
@@ -61,7 +61,7 @@ class Error {
$caller = static::getLastCaller($backtrace);
- return array(
+ return [
'%type' => get_class($exception),
// The standard PHP exception handler considers that the exception message
// is plain-text. We mimic this behavior here.
@@ -72,7 +72,7 @@ class Error {
'severity_level' => static::ERROR,
'backtrace' => $backtrace,
'@backtrace_string' => $exception->getTraceAsString(),
- );
+ ];
}
/**
@@ -152,7 +152,7 @@ class Error {
$return = '';
foreach ($backtrace as $trace) {
- $call = array('function' => '', 'args' => array());
+ $call = ['function' => '', 'args' => []];
if (isset($trace['class'])) {
$call['function'] = $trace['class'] . $trace['type'] . $trace['function'];
diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php
index 1dad742a822..8367556445e 100644
--- a/core/lib/Drupal/Core/Utility/LinkGenerator.php
+++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php
@@ -90,20 +90,20 @@ class LinkGenerator implements LinkGeneratorInterface {
}
// Start building a structured representation of our link to be altered later.
- $variables = array(
+ $variables = [
'text' => $text,
'url' => $url,
'options' => $url->getOptions(),
- );
+ ];
// Merge in default options.
- $variables['options'] += array(
- 'attributes' => array(),
- 'query' => array(),
+ $variables['options'] += [
+ 'attributes' => [],
+ 'query' => [],
'language' => NULL,
'set_active_class' => FALSE,
'absolute' => FALSE,
- );
+ ];
// Add a hreflang attribute if we know the language of this link's url and
// hreflang has not already been set.
@@ -150,7 +150,7 @@ class LinkGenerator implements LinkGeneratorInterface {
// Move attributes out of options since generateFromRoute() doesn't need
// them. Make sure the "href" comes first for testing purposes.
- $attributes = array('href' => '') + $variables['options']['attributes'];
+ $attributes = ['href' => ''] + $variables['options']['attributes'];
unset($variables['options']['attributes']);
$url->setOptions($variables['options']);
diff --git a/core/lib/Drupal/Core/Utility/ProjectInfo.php b/core/lib/Drupal/Core/Utility/ProjectInfo.php
index 24043d3b438..4a4d0c0a657 100644
--- a/core/lib/Drupal/Core/Utility/ProjectInfo.php
+++ b/core/lib/Drupal/Core/Utility/ProjectInfo.php
@@ -39,7 +39,7 @@ class ProjectInfo {
* (optional) Array of additional elements to be collected from the .info.yml
* file. Defaults to array().
*/
- function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_whitelist = array()) {
+ function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_whitelist = []) {
foreach ($list as $file) {
// Just projects with a matching status should be listed.
if ($file->status != $status) {
@@ -107,16 +107,16 @@ class ProjectInfo {
if (!isset($projects[$project_name])) {
// Only process this if we haven't done this project, since a single
// project can have multiple modules or themes.
- $projects[$project_name] = array(
+ $projects[$project_name] = [
'name' => $project_name,
// Only save attributes from the .info.yml file we care about so we do
// not bloat our RAM usage needlessly.
'info' => $this->filterProjectInfo($file->info, $additional_whitelist),
'datestamp' => $file->info['datestamp'],
- 'includes' => array($file->getName() => $file->info['name']),
+ 'includes' => [$file->getName() => $file->info['name']],
'project_type' => $project_display_type,
'project_status' => $status,
- );
+ ];
}
elseif ($projects[$project_name]['project_type'] == $project_display_type) {
// Only add the file we're processing to the 'includes' array for this
@@ -174,8 +174,8 @@ class ProjectInfo {
*
* @see \Drupal\Core\Utility\ProjectInfo::processInfoList()
*/
- function filterProjectInfo($info, $additional_whitelist = array()) {
- $whitelist = array(
+ function filterProjectInfo($info, $additional_whitelist = []) {
+ $whitelist = [
'_info_file_ctime',
'datestamp',
'major',
@@ -184,7 +184,7 @@ class ProjectInfo {
'project',
'project status url',
'version',
- );
+ ];
$whitelist = array_merge($whitelist, $additional_whitelist);
return array_intersect_key($info, array_combine($whitelist, $whitelist));
}
diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
index 8dbf42e242d..99b970ca9d0 100644
--- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php
+++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
@@ -46,7 +46,7 @@ class ThemeRegistry extends CacheCollector implements DestructableInterface {
* @param bool $modules_loaded
* Whether all modules have already been loaded.
*/
- function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, $tags = array(), $modules_loaded = FALSE) {
+ function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, $tags = [], $modules_loaded = FALSE) {
$this->cid = $cid;
$this->cache = $cache;
$this->lock = $lock;
@@ -136,7 +136,7 @@ class ThemeRegistry extends CacheCollector implements DestructableInterface {
return;
}
// @todo: Is the custom implementation necessary?
- $data = array();
+ $data = [];
foreach ($this->keysToPersist as $offset => $persist) {
if ($persist) {
$data[$offset] = $this->storage[$offset];
diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php
index 53432e8cc1e..2a7fd4a753e 100644
--- a/core/lib/Drupal/Core/Utility/Token.php
+++ b/core/lib/Drupal/Core/Utility/Token.php
@@ -182,7 +182,7 @@ class Token {
* otherwise for example the result can be put into #markup, in which case
* it would be sanitized by Xss::filterAdmin().
*/
- public function replace($text, array $data = array(), array $options = array(), BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function replace($text, array $data = [], array $options = [], BubbleableMetadata $bubbleable_metadata = NULL) {
$text_tokens = $this->scan($text);
if (empty($text_tokens)) {
return $text;
@@ -191,7 +191,7 @@ class Token {
$bubbleable_metadata_is_passed_in = (bool) $bubbleable_metadata;
$bubbleable_metadata = $bubbleable_metadata ?: new BubbleableMetadata();
- $replacements = array();
+ $replacements = [];
foreach ($text_tokens as $type => $tokens) {
$replacements += $this->generate($type, $tokens, $data, $options, $bubbleable_metadata);
if (!empty($options['clear'])) {
@@ -251,7 +251,7 @@ class Token {
// Iterate through the matches, building an associative array containing
// $tokens grouped by $types, pointing to the version of the token found in
// the source text. For example, $results['node']['title'] = '[node:title]';
- $results = array();
+ $results = [];
for ($i = 0; $i < count($tokens); $i++) {
$results[$types[$i]][$tokens[$i]] = $matches[0][$i];
}
@@ -304,12 +304,12 @@ class Token {
$replacements = $this->moduleHandler->invokeAll('tokens', [$type, $tokens, $data, $options, $bubbleable_metadata]);
// Allow other modules to alter the replacements.
- $context = array(
+ $context = [
'type' => $type,
'tokens' => $tokens,
'data' => $data,
'options' => $options,
- );
+ ];
$this->moduleHandler->alter('tokens', $replacements, $context, $bubbleable_metadata);
return $replacements;
@@ -343,7 +343,7 @@ class Token {
* stripped from the key.
*/
public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') {
- $results = array();
+ $results = [];
foreach ($tokens as $token => $raw) {
$parts = explode($delimiter, $token, 2);
if (count($parts) == 2 && $parts[0] == $prefix) {
@@ -376,9 +376,9 @@ class Token {
else {
$this->tokenInfo = $this->moduleHandler->invokeAll('token_info');
$this->moduleHandler->alter('token_info', $this->tokenInfo);
- $this->cache->set($cache_id, $this->tokenInfo, CacheBackendInterface::CACHE_PERMANENT, array(
+ $this->cache->set($cache_id, $this->tokenInfo, CacheBackendInterface::CACHE_PERMANENT, [
static::TOKEN_INFO_CACHE_TAG,
- ));
+ ]);
}
}
diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php
index e0c07943371..4422055b0f6 100644
--- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php
+++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php
@@ -52,6 +52,6 @@ interface UnroutedUrlAssemblerInterface {
* @throws \InvalidArgumentException
* Thrown when the passed in path has no scheme.
*/
- public function assemble($uri, array $options = array(), $collect_bubbleable_metadata = FALSE);
+ public function assemble($uri, array $options = [], $collect_bubbleable_metadata = FALSE);
}
diff --git a/core/lib/Drupal/Core/Utility/token.api.php b/core/lib/Drupal/Core/Utility/token.api.php
index 56d8f3a5fb8..54a5226ffbe 100644
--- a/core/lib/Drupal/Core/Utility/token.api.php
+++ b/core/lib/Drupal/Core/Utility/token.api.php
@@ -74,7 +74,7 @@ use Drupal\user\Entity\User;
function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@@ -82,7 +82,7 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R
else {
$langcode = NULL;
}
- $replacements = array();
+ $replacements = [];
if ($type == 'node' && !empty($data['node'])) {
/** @var \Drupal\node\NodeInterface $node */
@@ -117,11 +117,11 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R
}
if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) {
- $replacements = $token_service->generate('user', $author_tokens, array('user' => $node->getOwner()), $options, $bubbleable_metadata);
+ $replacements = $token_service->generate('user', $author_tokens, ['user' => $node->getOwner()], $options, $bubbleable_metadata);
}
if ($created_tokens = $token_service->findWithPrefix($tokens, 'created')) {
- $replacements = $token_service->generate('date', $created_tokens, array('date' => $node->getCreatedTime()), $options, $bubbleable_metadata);
+ $replacements = $token_service->generate('date', $created_tokens, ['date' => $node->getCreatedTime()], $options, $bubbleable_metadata);
}
}
@@ -219,39 +219,39 @@ function hook_tokens_alter(array &$replacements, array $context, \Drupal\Core\Re
* @see hook_tokens()
*/
function hook_token_info() {
- $type = array(
+ $type = [
'name' => t('Nodes'),
'description' => t('Tokens related to individual nodes.'),
'needs-data' => 'node',
- );
+ ];
// Core tokens for nodes.
- $node['nid'] = array(
+ $node['nid'] = [
'name' => t("Node ID"),
'description' => t("The unique ID of the node."),
- );
- $node['title'] = array(
+ ];
+ $node['title'] = [
'name' => t("Title"),
- );
- $node['edit-url'] = array(
+ ];
+ $node['edit-url'] = [
'name' => t("Edit URL"),
'description' => t("The URL of the node's edit page."),
- );
+ ];
// Chained tokens for nodes.
- $node['created'] = array(
+ $node['created'] = [
'name' => t("Date created"),
'type' => 'date',
- );
- $node['author'] = array(
+ ];
+ $node['author'] = [
'name' => t("Author"),
'type' => 'user',
- );
+ ];
- return array(
- 'types' => array('node' => $type),
- 'tokens' => array('node' => $node),
- );
+ return [
+ 'types' => ['node' => $type],
+ 'tokens' => ['node' => $node],
+ ];
}
/**
@@ -264,21 +264,21 @@ function hook_token_info() {
*/
function hook_token_info_alter(&$data) {
// Modify description of node tokens for our site.
- $data['tokens']['node']['nid'] = array(
+ $data['tokens']['node']['nid'] = [
'name' => t("Node ID"),
'description' => t("The unique ID of the article."),
- );
- $data['tokens']['node']['title'] = array(
+ ];
+ $data['tokens']['node']['title'] = [
'name' => t("Title"),
'description' => t("The title of the article."),
- );
+ ];
// Chained tokens for nodes.
- $data['tokens']['node']['created'] = array(
+ $data['tokens']['node']['created'] = [
'name' => t("Date created"),
'description' => t("The date the article was posted."),
'type' => 'date',
- );
+ ];
}
/**
diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php
index 23bd7eb165d..a2bd604c0a1 100644
--- a/core/lib/Drupal/Core/Validation/ConstraintManager.php
+++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php
@@ -74,7 +74,7 @@ class ConstraintManager extends DefaultPluginManager {
// Plugins need an array as configuration, so make sure we have one.
// The constraint classes support passing the options as part of the
// 'value' key also.
- $options = isset($options) ? array('value' => $options) : array();
+ $options = isset($options) ? ['value' => $options] : [];
}
return $this->createInstance($name, $options);
}
@@ -85,26 +85,26 @@ class ConstraintManager extends DefaultPluginManager {
* @see ConstraintManager::__construct()
*/
public function registerDefinitions() {
- $this->getDiscovery()->setDefinition('Callback', array(
+ $this->getDiscovery()->setDefinition('Callback', [
'label' => new TranslatableMarkup('Callback'),
'class' => '\Symfony\Component\Validator\Constraints\Callback',
'type' => FALSE,
- ));
- $this->getDiscovery()->setDefinition('Blank', array(
+ ]);
+ $this->getDiscovery()->setDefinition('Blank', [
'label' => new TranslatableMarkup('Blank'),
'class' => '\Symfony\Component\Validator\Constraints\Blank',
'type' => FALSE,
- ));
- $this->getDiscovery()->setDefinition('NotBlank', array(
+ ]);
+ $this->getDiscovery()->setDefinition('NotBlank', [
'label' => new TranslatableMarkup('Not blank'),
'class' => '\Symfony\Component\Validator\Constraints\NotBlank',
'type' => FALSE,
- ));
- $this->getDiscovery()->setDefinition('Email', array(
+ ]);
+ $this->getDiscovery()->setDefinition('Email', [
'label' => new TranslatableMarkup('Email'),
'class' => '\Drupal\Core\Validation\Plugin\Validation\Constraint\EmailConstraint',
- 'type' => array('string'),
- ));
+ 'type' => ['string'],
+ ]);
}
/**
@@ -113,7 +113,7 @@ class ConstraintManager extends DefaultPluginManager {
public function processDefinition(&$definition, $plugin_id) {
// Make sure 'type' is set and either an array or FALSE.
if ($definition['type'] !== FALSE && !is_array($definition['type'])) {
- $definition['type'] = array($definition['type']);
+ $definition['type'] = [$definition['type']];
}
}
@@ -128,7 +128,7 @@ class ConstraintManager extends DefaultPluginManager {
* keyed by constraint name (plugin ID).
*/
public function getDefinitionsByType($type) {
- $definitions = array();
+ $definitions = [];
foreach ($this->getDefinitions() as $plugin_id => $definition) {
if ($definition['type'] === FALSE || in_array($type, $definition['type'])) {
$definitions[$plugin_id] = $definition;
diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php
index f00df20b81a..505decaff2c 100644
--- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php
+++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php
@@ -22,7 +22,7 @@ class DrupalTranslator implements TranslatorInterface {
/**
* {@inheritdoc}
*/
- public function trans($id, array $parameters = array(), $domain = NULL, $locale = NULL) {
+ public function trans($id, array $parameters = [], $domain = NULL, $locale = NULL) {
// If a TranslatableMarkup object is passed in as $id, return it since the
// message has already been translated.
return $id instanceof TranslatableMarkup ? $id : t($id, $this->processParameters($parameters), $this->getOptions($domain, $locale));
@@ -31,7 +31,7 @@ class DrupalTranslator implements TranslatorInterface {
/**
* {@inheritdoc}
*/
- public function transChoice($id, $number, array $parameters = array(), $domain = NULL, $locale = NULL) {
+ public function transChoice($id, $number, array $parameters = [], $domain = NULL, $locale = NULL) {
// Violation messages can separated singular and plural versions by "|".
$ids = explode('|', $id);
@@ -70,7 +70,7 @@ class DrupalTranslator implements TranslatorInterface {
* Processes the parameters array for use with t().
*/
protected function processParameters(array $parameters) {
- $return = array();
+ $return = [];
foreach ($parameters as $key => $value) {
// We allow the values in the parameters to be safe string objects. This
// can be useful when we want to use parameter values that are
@@ -101,7 +101,7 @@ class DrupalTranslator implements TranslatorInterface {
// We do not support domains, so we ignore this parameter.
// If locale is left NULL, t() will default to the interface language.
$locale = isset($locale) ? $locale : $this->locale;
- return array('langcode' => $locale);
+ return ['langcode' => $locale];
}
}
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php
index 5e7d0c7ebc0..a020cdc3c27 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php
@@ -29,7 +29,7 @@ class ComplexDataConstraint extends Constraint {
public function __construct($options = NULL) {
// Allow skipping the 'properties' key in the options.
if (is_array($options) && !array_key_exists('properties', $options)) {
- $options = array('properties' => $options);
+ $options = ['properties' => $options];
}
parent::__construct($options);
$constraint_manager = \Drupal::service('validation.constraint');
@@ -55,7 +55,7 @@ class ComplexDataConstraint extends Constraint {
* {@inheritdoc}
*/
public function getRequiredOptions() {
- return array('properties');
+ return ['properties'];
}
}
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php
index 5829e396ec0..f71e2e11420 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php
@@ -72,9 +72,9 @@ class PrimitiveTypeConstraintValidator extends ConstraintValidator {
if (!$valid) {
// @todo: Provide a good violation message for each problem.
- $this->context->addViolation($constraint->message, array(
+ $this->context->addViolation($constraint->message, [
'%value' => is_object($value) ? get_class($value) : (is_array($value) ? 'Array' : (string) $value)
- ));
+ ]);
}
}
diff --git a/core/modules/action/action.module b/core/modules/action/action.module
index 7461302d17a..5004a84b115 100644
--- a/core/modules/action/action.module
+++ b/core/modules/action/action.module
@@ -15,13 +15,13 @@ function action_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.action':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Actions module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the <a href=":documentation">online documentation for the Actions module</a>.', array(':documentation' => 'https://www.drupal.org/documentation/modules/action')) . '</p>';
+ $output .= '<p>' . t('The Actions module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the <a href=":documentation">online documentation for the Actions module</a>.', [':documentation' => 'https://www.drupal.org/documentation/modules/action']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Using simple actions') . '</dt>';
- $output .= '<dd>' . t('<em>Simple actions</em> do not require configuration and are listed automatically as available on the <a href=":actions">Actions page</a>.', array(':actions' => \Drupal::url('entity.action.collection'))) . '</dd>';
+ $output .= '<dd>' . t('<em>Simple actions</em> do not require configuration and are listed automatically as available on the <a href=":actions">Actions page</a>.', [':actions' => \Drupal::url('entity.action.collection')]) . '</dd>';
$output .= '<dt>' . t('Creating and configuring advanced actions') . '</dt>';
- $output .= '<dd>' . t('<em>Advanced actions</em> are user-created and have to be configured individually. Create an advanced action on the <a href=":actions">Actions page</a> by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', array(':actions' => \Drupal::url('entity.action.collection'))) . '</dd>';
+ $output .= '<dd>' . t('<em>Advanced actions</em> are user-created and have to be configured individually. Create an advanced action on the <a href=":actions">Actions page</a> by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', [':actions' => \Drupal::url('entity.action.collection')]) . '</dd>';
$output .= '</dl>';
return $output;
diff --git a/core/modules/action/action.views_execution.inc b/core/modules/action/action.views_execution.inc
index 5b4f71f8116..71b8eebe428 100644
--- a/core/modules/action/action.views_execution.inc
+++ b/core/modules/action/action.views_execution.inc
@@ -9,12 +9,12 @@
* Implements hook_views_form_substitutions().
*/
function action_views_form_substitutions() {
- $select_all = array(
+ $select_all = [
'#type' => 'checkbox',
'#default_value' => FALSE,
- '#attributes' => array('class' => array('action-table-select-all')),
- );
- return array(
+ '#attributes' => ['class' => ['action-table-select-all']],
+ ];
+ return [
'<!--action-bulk-form-select-all-->' => drupal_render($select_all),
- );
+ ];
}
diff --git a/core/modules/action/src/ActionFormBase.php b/core/modules/action/src/ActionFormBase.php
index 7a5746a36ae..3fafd035eee 100644
--- a/core/modules/action/src/ActionFormBase.php
+++ b/core/modules/action/src/ActionFormBase.php
@@ -58,32 +58,32 @@ abstract class ActionFormBase extends EntityForm {
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#default_value' => $this->entity->label(),
'#maxlength' => '255',
'#description' => $this->t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
- );
+ ];
- $form['id'] = array(
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $this->entity->id(),
'#disabled' => !$this->entity->isNew(),
'#maxlength' => 64,
'#description' => $this->t('A unique name for this action. It must only contain lowercase letters, numbers and underscores.'),
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
- ),
- );
- $form['plugin'] = array(
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
+ ],
+ ];
+ $form['plugin'] = [
'#type' => 'value',
'#value' => $this->entity->get('plugin'),
- );
- $form['type'] = array(
+ ];
+ $form['type'] = [
'#type' => 'value',
'#value' => $this->entity->getType(),
- );
+ ];
if ($this->plugin instanceof PluginFormInterface) {
$form += $this->plugin->buildConfigurationForm($form, $form_state);
diff --git a/core/modules/action/src/ActionListBuilder.php b/core/modules/action/src/ActionListBuilder.php
index 0a54cd65270..2167d8e0940 100644
--- a/core/modules/action/src/ActionListBuilder.php
+++ b/core/modules/action/src/ActionListBuilder.php
@@ -86,10 +86,10 @@ class ActionListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function buildHeader() {
- $header = array(
+ $header = [
'type' => t('Action type'),
'label' => t('Label'),
- ) + parent::buildHeader();
+ ] + parent::buildHeader();
return $header;
}
@@ -97,7 +97,7 @@ class ActionListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function getDefaultOperations(EntityInterface $entity) {
- $operations = $entity->isConfigurable() ? parent::getDefaultOperations($entity) : array();
+ $operations = $entity->isConfigurable() ? parent::getDefaultOperations($entity) : [];
if (isset($operations['edit'])) {
$operations['edit']['title'] = t('Configure');
}
diff --git a/core/modules/action/src/Form/ActionAdminManageForm.php b/core/modules/action/src/Form/ActionAdminManageForm.php
index de487557d1d..478e919be04 100644
--- a/core/modules/action/src/Form/ActionAdminManageForm.php
+++ b/core/modules/action/src/Form/ActionAdminManageForm.php
@@ -50,33 +50,33 @@ class ActionAdminManageForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $actions = array();
+ $actions = [];
foreach ($this->manager->getDefinitions() as $id => $definition) {
if (is_subclass_of($definition['class'], '\Drupal\Core\Plugin\PluginFormInterface')) {
$key = Crypt::hashBase64($id);
$actions[$key] = $definition['label'] . '...';
}
}
- $form['parent'] = array(
+ $form['parent'] = [
'#type' => 'details',
'#title' => $this->t('Create an advanced action'),
- '#attributes' => array('class' => array('container-inline')),
+ '#attributes' => ['class' => ['container-inline']],
'#open' => TRUE,
- );
- $form['parent']['action'] = array(
+ ];
+ $form['parent']['action'] = [
'#type' => 'select',
'#title' => $this->t('Action'),
'#title_display' => 'invisible',
'#options' => $actions,
'#empty_option' => $this->t('Choose an advanced action'),
- );
- $form['parent']['actions'] = array(
+ ];
+ $form['parent']['actions'] = [
'#type' => 'actions'
- );
- $form['parent']['actions']['submit'] = array(
+ ];
+ $form['parent']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Create'),
- );
+ ];
return $form;
}
@@ -87,7 +87,7 @@ class ActionAdminManageForm extends FormBase {
if ($form_state->getValue('action')) {
$form_state->setRedirect(
'action.admin_add',
- array('action_id' => $form_state->getValue('action'))
+ ['action_id' => $form_state->getValue('action')]
);
}
}
diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php
index f23827975dc..0f469ec6bfe 100644
--- a/core/modules/action/src/Plugin/Action/EmailAction.php
+++ b/core/modules/action/src/Plugin/Action/EmailAction.php
@@ -129,7 +129,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
// If the recipient is a registered user with a language preference, use
// the recipient's preferred language. Otherwise, use the system default
// language.
- $recipient_accounts = $this->storage->loadByProperties(array('mail' => $recipient));
+ $recipient_accounts = $this->storage->loadByProperties(['mail' => $recipient]);
$recipient_account = reset($recipient_accounts);
if ($recipient_account) {
$langcode = $recipient_account->getPreferredLangcode();
@@ -137,13 +137,13 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
else {
$langcode = $this->languageManager->getDefaultLanguage()->getId();
}
- $params = array('context' => $this->configuration);
+ $params = ['context' => $this->configuration];
if ($this->mailManager->mail('system', 'action_send_email', $recipient, $langcode, $params)) {
- $this->logger->notice('Sent email to %recipient', array('%recipient' => $recipient));
+ $this->logger->notice('Sent email to %recipient', ['%recipient' => $recipient]);
}
else {
- $this->logger->error('Unable to send email to %recipient', array('%recipient' => $recipient));
+ $this->logger->error('Unable to send email to %recipient', ['%recipient' => $recipient]);
}
}
@@ -151,39 +151,39 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'recipient' => '',
'subject' => '',
'message' => '',
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['recipient'] = array(
+ $form['recipient'] = [
'#type' => 'textfield',
'#title' => t('Recipient email address'),
'#default_value' => $this->configuration['recipient'],
'#maxlength' => '254',
'#description' => t('You may also use tokens: [node:author:mail], [comment:author:mail], etc. Separate recipients with a comma.'),
- );
- $form['subject'] = array(
+ ];
+ $form['subject'] = [
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => $this->configuration['subject'],
'#maxlength' => '254',
'#description' => t('The subject of the message.'),
- );
- $form['message'] = array(
+ ];
+ $form['message'] = [
'#type' => 'textarea',
'#title' => t('Message'),
'#default_value' => $this->configuration['message'],
'#cols' => '80',
'#rows' => '20',
'#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
- );
+ ];
return $form;
}
@@ -193,7 +193,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
if (!$this->emailValidator->isValid($form_state->getValue('recipient')) && strpos($form_state->getValue('recipient'), ':mail') === FALSE) {
// We want the literal %author placeholder to be emphasized in the error message.
- $form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]')));
+ $form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', ['%author' => '[node:author:mail]']));
}
}
diff --git a/core/modules/action/src/Plugin/Action/GotoAction.php b/core/modules/action/src/Plugin/Action/GotoAction.php
index 5c1b5522004..44e871b92a9 100644
--- a/core/modules/action/src/Plugin/Action/GotoAction.php
+++ b/core/modules/action/src/Plugin/Action/GotoAction.php
@@ -103,22 +103,22 @@ class GotoAction extends ConfigurableActionBase implements ContainerFactoryPlugi
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'url' => '',
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['url'] = array(
+ $form['url'] = [
'#type' => 'textfield',
'#title' => t('URL'),
- '#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', array('@url' => 'http://example.com')),
+ '#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', ['@url' => 'http://example.com']),
'#default_value' => $this->configuration['url'],
'#required' => TRUE,
- );
+ ];
return $form;
}
diff --git a/core/modules/action/src/Plugin/Action/MessageAction.php b/core/modules/action/src/Plugin/Action/MessageAction.php
index ab32b4c9fc4..c85d249b08c 100644
--- a/core/modules/action/src/Plugin/Action/MessageAction.php
+++ b/core/modules/action/src/Plugin/Action/MessageAction.php
@@ -84,23 +84,23 @@ class MessageAction extends ConfigurableActionBase implements ContainerFactoryPl
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'message' => '',
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['message'] = array(
+ $form['message'] = [
'#type' => 'textarea',
'#title' => t('Message'),
'#default_value' => $this->configuration['message'],
'#required' => TRUE,
'#rows' => '8',
'#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
- );
+ ];
return $form;
}
diff --git a/core/modules/action/src/Plugin/migrate/source/Action.php b/core/modules/action/src/Plugin/migrate/source/Action.php
index e983b00139e..ac14a44b470 100644
--- a/core/modules/action/src/Plugin/migrate/source/Action.php
+++ b/core/modules/action/src/Plugin/migrate/source/Action.php
@@ -27,12 +27,12 @@ class Action extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'aid' => $this->t('Action ID'),
'type' => $this->t('Module'),
'callback' => $this->t('Callback function'),
'parameters' => $this->t('Action configuration'),
- );
+ ];
if ($this->getModuleSchemaVersion('system') >= 7000) {
$fields['label'] = $this->t('Label of the action');
}
diff --git a/core/modules/action/tests/src/Functional/ActionListTest.php b/core/modules/action/tests/src/Functional/ActionListTest.php
index 2510e86ef13..309160f4be9 100644
--- a/core/modules/action/tests/src/Functional/ActionListTest.php
+++ b/core/modules/action/tests/src/Functional/ActionListTest.php
@@ -16,7 +16,7 @@ class ActionListTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('action');
+ public static $modules = ['action'];
/**
* Tests the behavior when there are no actions to list in the admin page.
diff --git a/core/modules/action/tests/src/Functional/ActionUninstallTest.php b/core/modules/action/tests/src/Functional/ActionUninstallTest.php
index 93e0bc0c26d..6b52643bc54 100644
--- a/core/modules/action/tests/src/Functional/ActionUninstallTest.php
+++ b/core/modules/action/tests/src/Functional/ActionUninstallTest.php
@@ -17,19 +17,19 @@ class ActionUninstallTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('views', 'action');
+ public static $modules = ['views', 'action'];
/**
* Tests Action uninstall.
*/
public function testActionUninstall() {
- \Drupal::service('module_installer')->uninstall(array('action'));
+ \Drupal::service('module_installer')->uninstall(['action']);
$storage = $this->container->get('entity_type.manager')->getStorage('action');
$storage->resetCache(['user_block_user_action']);
$this->assertTrue($storage->load('user_block_user_action'), 'Configuration entity \'user_block_user_action\' still exists after uninstalling action module.' );
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/people');
diff --git a/core/modules/action/tests/src/Functional/BulkFormTest.php b/core/modules/action/tests/src/Functional/BulkFormTest.php
index 7d32b947112..439ffe4d6d4 100644
--- a/core/modules/action/tests/src/Functional/BulkFormTest.php
+++ b/core/modules/action/tests/src/Functional/BulkFormTest.php
@@ -18,7 +18,7 @@ class BulkFormTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'action_bulk_test');
+ public static $modules = ['node', 'action_bulk_test'];
/**
* Tests the bulk form.
@@ -31,30 +31,30 @@ class BulkFormTest extends BrowserTestBase {
$this->drupalGet('test_bulk_form_empty');
$this->assertText(t('This view is empty.'), 'Empty text found on empty bulk form.');
- $nodes = array();
+ $nodes = [];
for ($i = 0; $i < 10; $i++) {
// Ensure nodes are sorted in the same order they are inserted in the
// array.
$timestamp = REQUEST_TIME - $i;
- $nodes[] = $this->drupalCreateNode(array(
+ $nodes[] = $this->drupalCreateNode([
'sticky' => FALSE,
'created' => $timestamp,
'changed' => $timestamp,
- ));
+ ]);
}
$this->drupalGet('test_bulk_form');
// Test that the views edit header appears first.
- $first_form_element = $this->xpath('//form/div[1][@id = :id]', array(':id' => 'edit-header'));
+ $first_form_element = $this->xpath('//form/div[1][@id = :id]', [':id' => 'edit-header']);
$this->assertTrue($first_form_element, 'The views form edit header appears first.');
$this->assertFieldById('edit-action', NULL, 'The action select field appears.');
// Make sure a checkbox appears on all rows.
- $edit = array();
+ $edit = [];
for ($i = 0; $i < 10; $i++) {
- $this->assertFieldById('edit-node-bulk-form-' . $i, NULL, format_string('The checkbox on row @row appears.', array('@row' => $i)));
+ $this->assertFieldById('edit-node-bulk-form-' . $i, NULL, format_string('The checkbox on row @row appears.', ['@row' => $i]));
$edit["node_bulk_form[$i]"] = TRUE;
}
@@ -67,12 +67,12 @@ class BulkFormTest extends BrowserTestBase {
$this->drupalGet('test_bulk_form');
// Set all nodes to sticky and check that.
- $edit += array('action' => 'node_make_sticky_action');
+ $edit += ['action' => 'node_make_sticky_action'];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
foreach ($nodes as $node) {
$changed_node = $node_storage->load($node->id());
- $this->assertTrue($changed_node->isSticky(), format_string('Node @nid got marked as sticky.', array('@nid' => $node->id())));
+ $this->assertTrue($changed_node->isSticky(), format_string('Node @nid got marked as sticky.', ['@nid' => $node->id()]));
}
$this->assertText('Make content sticky was applied to 10 items.');
@@ -81,18 +81,18 @@ class BulkFormTest extends BrowserTestBase {
$node = $node_storage->load($nodes[0]->id());
$this->assertTrue($node->isPublished(), 'The node is published.');
- $edit = array('node_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action');
+ $edit = ['node_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action'];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$this->assertText('Unpublish content was applied to 1 item.');
// Load the node again.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$node = $node_storage->load($node->id());
$this->assertFalse($node->isPublished(), 'A single node has been unpublished.');
// The second node should still be published.
- $node_storage->resetCache(array($nodes[1]->id()));
+ $node_storage->resetCache([$nodes[1]->id()]);
$node = $node_storage->load($nodes[1]->id());
$this->assertTrue($node->isPublished(), 'An unchecked node is still published.');
@@ -105,7 +105,7 @@ class BulkFormTest extends BrowserTestBase {
$view->save();
$this->drupalGet('test_bulk_form');
- $options = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-action'));
+ $options = $this->xpath('//select[@id=:id]/option', [':id' => 'edit-action']);
$this->assertEqual(count($options), 2);
$this->assertOption('edit-action', 'node_make_sticky_action');
$this->assertOption('edit-action', 'node_make_unsticky_action');
@@ -137,17 +137,17 @@ class BulkFormTest extends BrowserTestBase {
$this->drupalGet('test_bulk_form');
// Call the node delete action.
- $edit = array();
+ $edit = [];
for ($i = 0; $i < 5; $i++) {
$edit["node_bulk_form[$i]"] = TRUE;
}
- $edit += array('action' => 'node_delete_action');
+ $edit += ['action' => 'node_delete_action'];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
// Make sure we don't show an action message while we are still on the
// confirmation page.
$errors = $this->xpath('//div[contains(@class, "messages--status")]');
$this->assertFalse($errors, 'No action message shown.');
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->assertText(t('Deleted 5 posts.'));
// Check if we got redirected to the original page.
$this->assertUrl('test_bulk_form');
diff --git a/core/modules/action/tests/src/Functional/ConfigurationTest.php b/core/modules/action/tests/src/Functional/ConfigurationTest.php
index 23d0a381912..063e4a89ebc 100644
--- a/core/modules/action/tests/src/Functional/ConfigurationTest.php
+++ b/core/modules/action/tests/src/Functional/ConfigurationTest.php
@@ -19,24 +19,24 @@ class ConfigurationTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('action');
+ public static $modules = ['action'];
/**
* Tests configuration of advanced actions through administration interface.
*/
function testActionConfiguration() {
// Create a user with permission to view the actions administration pages.
- $user = $this->drupalCreateUser(array('administer actions'));
+ $user = $this->drupalCreateUser(['administer actions']);
$this->drupalLogin($user);
// Make a POST request to admin/config/system/actions.
- $edit = array();
+ $edit = [];
$edit['action'] = Crypt::hashBase64('action_goto_action');
$this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
$this->assertResponse(200);
// Make a POST request to the individual action configuration page.
- $edit = array();
+ $edit = [];
$action_label = $this->randomMachineName();
$edit['label'] = $action_label;
$edit['id'] = strtolower($action_label);
@@ -52,7 +52,7 @@ class ConfigurationTest extends BrowserTestBase {
$this->clickLink(t('Configure'));
preg_match('|admin/config/system/actions/configure/(.+)|', $this->getUrl(), $matches);
$aid = $matches[1];
- $edit = array();
+ $edit = [];
$new_action_label = $this->randomMachineName();
$edit['label'] = $new_action_label;
$edit['url'] = 'admin';
@@ -72,12 +72,12 @@ class ConfigurationTest extends BrowserTestBase {
$this->drupalGet('admin/config/system/actions');
$this->clickLink(t('Delete'));
$this->assertResponse(200);
- $edit = array();
+ $edit = [];
$this->drupalPostForm("admin/config/system/actions/configure/$aid/delete", $edit, t('Delete'));
$this->assertResponse(200);
// Make sure that the action was actually deleted.
- $this->assertRaw(t('The action %action has been deleted.', array('%action' => $new_action_label)), 'Make sure that we get a delete confirmation message.');
+ $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.');
$this->drupalGet('admin/config/system/actions');
$this->assertResponse(200);
$this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action.");
diff --git a/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php b/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php
index 34d24b1ce1b..1959f6510a0 100644
--- a/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php
+++ b/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php
@@ -12,7 +12,7 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class ActionLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array('action' => 'core/modules/action');
+ $this->directoryList = ['action' => 'core/modules/action'];
parent::setUp();
}
@@ -20,7 +20,7 @@ class ActionLocalTasksTest extends LocalTaskIntegrationTestBase {
* Tests local task existence.
*/
public function testActionLocalTasks() {
- $this->assertLocalTasks('entity.action.collection', array(array('action.admin')));
+ $this->assertLocalTasks('entity.action.collection', [['action.admin']]);
}
}
diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install
index 5edc5031815..9e05400b8c1 100644
--- a/core/modules/aggregator/aggregator.install
+++ b/core/modules/aggregator/aggregator.install
@@ -10,11 +10,11 @@
*/
function aggregator_requirements($phase) {
$has_curl = function_exists('curl_init');
- $requirements = array();
- $requirements['curl'] = array(
+ $requirements = [];
+ $requirements['curl'] = [
'title' => t('cURL'),
'value' => $has_curl ? t('Enabled') : t('Not found'),
- );
+ ];
if (!$has_curl) {
$requirements['curl']['severity'] = REQUIREMENT_ERROR;
$requirements['curl']['description'] = t('The Aggregator module requires the <a href="https://secure.php.net/manual/en/curl.setup.php">PHP cURL library</a>. For more information, see the <a href="https://www.drupal.org/requirements/php/curl">online information on installing the PHP cURL extension</a>.');
diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index cf32734a30c..0f856e31257 100644
--- a/core/modules/aggregator/aggregator.module
+++ b/core/modules/aggregator/aggregator.module
@@ -25,35 +25,35 @@ function aggregator_help($route_name, RouteMatchInterface $route_match) {
$path_validator = \Drupal::pathValidator();
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the <a href=":aggregator-module">online documentation for the Aggregator module</a>.', array(':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator')) . '</p>';
+ $output .= '<p>' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the <a href=":aggregator-module">online documentation for the Aggregator module</a>.', [':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
// Check if the aggregator sources View is enabled.
if ($url = $path_validator->getUrlIfValid('aggregator/sources')) {
$output .= '<dt>' . t('Viewing feeds') . '</dt>';
- $output .= '<dd>' . t('Users view feed content in the <a href=":aggregator">main aggregator display</a>, or by <a href=":aggregator-sources">their source</a> (usually via an RSS feed reader). The most recent content in a feed can be displayed as a block through the <a href=":admin-block">Blocks administration page</a>.', array(':aggregator' => \Drupal::url('aggregator.page_last'), ':aggregator-sources' => $url->toString(), ':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
+ $output .= '<dd>' . t('Users view feed content in the <a href=":aggregator">main aggregator display</a>, or by <a href=":aggregator-sources">their source</a> (usually via an RSS feed reader). The most recent content in a feed can be displayed as a block through the <a href=":admin-block">Blocks administration page</a>.', [':aggregator' => \Drupal::url('aggregator.page_last'), ':aggregator-sources' => $url->toString(), ':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
}
$output .= '<dt>' . t('Adding, editing, and deleting feeds') . '</dt>';
- $output .= '<dd>' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the <a href=":feededit">Aggregator administration page</a>.', array(':feededit' => \Drupal::url('aggregator.admin_overview'))) . '</dd>';
+ $output .= '<dd>' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the <a href=":feededit">Aggregator administration page</a>.', [':feededit' => \Drupal::url('aggregator.admin_overview')]) . '</dd>';
$output .= '<dt>' . t('Configuring the display of feed items') . '</dt>';
- $output .= '<dd>' . t('Administrators can choose how many items are displayed in the listing pages, which HTML tags are allowed in the content of feed items, and whether they should be trimmed to a maximum number of characters on the <a href=":settings">Aggregator settings page</a>.', array(':settings' => \Drupal::url('aggregator.admin_settings'))) . '</dd>';
+ $output .= '<dd>' . t('Administrators can choose how many items are displayed in the listing pages, which HTML tags are allowed in the content of feed items, and whether they should be trimmed to a maximum number of characters on the <a href=":settings">Aggregator settings page</a>.', [':settings' => \Drupal::url('aggregator.admin_settings')]) . '</dd>';
$output .= '<dt>' . t('Discarding old feed items') . '</dt>';
- $output .= '<dd>' . t('Administrators can choose whether to discard feed items that are older than a specified period of time on the <a href=":settings">Aggregator settings page</a>. This requires a correctly configured cron maintenance task (see below).', array(':settings' => \Drupal::url('aggregator.admin_settings'))) . '<dd>';
+ $output .= '<dd>' . t('Administrators can choose whether to discard feed items that are older than a specified period of time on the <a href=":settings">Aggregator settings page</a>. This requires a correctly configured cron maintenance task (see below).', [':settings' => \Drupal::url('aggregator.admin_settings')]) . '<dd>';
$output .= '<dt>' . t('<abbr title="Outline Processor Markup Language">OPML</abbr> integration') . '</dt>';
// Check if the aggregator opml View is enabled.
if ($url = $path_validator->getUrlIfValid('aggregator/opml')) {
- $output .= '<dd>' . t('A <a href=":aggregator-opml">machine-readable OPML file</a> of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be <a href=":import-opml">imported via an OPML file</a>.', array(':aggregator-opml' => $url->toString(), ':import-opml' => \Drupal::url('aggregator.opml_add'))) . '</dd>';
+ $output .= '<dd>' . t('A <a href=":aggregator-opml">machine-readable OPML file</a> of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be <a href=":import-opml">imported via an OPML file</a>.', [':aggregator-opml' => $url->toString(), ':import-opml' => \Drupal::url('aggregator.opml_add')]) . '</dd>';
}
$output .= '<dt>' . t('Configuring cron') . '</dt>';
- $output .= '<dd>' . t('A working <a href=":cron">cron maintenance task</a> is required to update feeds automatically.', array(':cron' => \Drupal::url('system.cron_settings'))) . '</dd>';
+ $output .= '<dd>' . t('A working <a href=":cron">cron maintenance task</a> is required to update feeds automatically.', [':cron' => \Drupal::url('system.cron_settings')]) . '</dd>';
$output .= '</dl>';
return $output;
case 'aggregator.admin_overview':
// Don't use placeholders for possibility to change URLs for translators.
$output = '<p>' . t('Many sites publish their headlines and posts in feeds, using a number of standardized XML-based formats. The aggregator supports <a href="http://en.wikipedia.org/wiki/Rss">RSS</a>, <a href="http://en.wikipedia.org/wiki/Resource_Description_Framework">RDF</a>, and <a href="http://en.wikipedia.org/wiki/Atom_%28standard%29">Atom</a>.') . '</p>';
- $output .= '<p>' . t('Current feeds are listed below, and <a href=":addfeed">new feeds may be added</a>. For each feed, the <em>latest items</em> block may be enabled at the <a href=":block">blocks administration page</a>.', array(':addfeed' => \Drupal::url('aggregator.feed_add'), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</p>';
+ $output .= '<p>' . t('Current feeds are listed below, and <a href=":addfeed">new feeds may be added</a>. For each feed, the <em>latest items</em> block may be enabled at the <a href=":block">blocks administration page</a>.', [':addfeed' => \Drupal::url('aggregator.feed_add'), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</p>';
return $output;
case 'aggregator.feed_add':
@@ -68,66 +68,66 @@ function aggregator_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function aggregator_theme() {
- return array(
- 'aggregator_feed' => array(
+ return [
+ 'aggregator_feed' => [
'render element' => 'elements',
'file' => 'aggregator.theme.inc',
- ),
- 'aggregator_item' => array(
+ ],
+ 'aggregator_item' => [
'render element' => 'elements',
'file' => 'aggregator.theme.inc',
- ),
- );
+ ],
+ ];
}
/**
* Implements hook_entity_extra_field_info().
*/
function aggregator_entity_extra_field_info() {
- $extra = array();
+ $extra = [];
- $extra['aggregator_feed']['aggregator_feed'] = array(
- 'display' => array(
- 'items' => array(
+ $extra['aggregator_feed']['aggregator_feed'] = [
+ 'display' => [
+ 'items' => [
'label' => t('Items'),
'description' => t('Items associated with this feed'),
'weight' => 0,
- ),
+ ],
// @todo Move to a formatter at https://www.drupal.org/node/2339917.
- 'image' => array(
+ 'image' => [
'label' => t('Image'),
'description' => t('The feed image'),
'weight' => 2,
- ),
+ ],
// @todo Move to a formatter at https://www.drupal.org/node/2149845.
- 'description' => array(
+ 'description' => [
'label' => t('Description'),
'description' => t('The description of this feed'),
'weight' => 3,
- ),
- 'more_link' => array(
+ ],
+ 'more_link' => [
'label' => t('More link'),
'description' => t('A more link to the feed detail page'),
'weight' => 5,
- ),
- 'feed_icon' => array(
+ ],
+ 'feed_icon' => [
'label' => t('Feed icon'),
'description' => t('An icon that links to the feed URL'),
'weight' => 6,
- ),
- ),
- );
+ ],
+ ],
+ ];
- $extra['aggregator_item']['aggregator_item'] = array(
- 'display' => array(
+ $extra['aggregator_item']['aggregator_item'] = [
+ 'display' => [
// @todo Move to a formatter at https://www.drupal.org/node/2149845.
- 'description' => array(
+ 'description' => [
'label' => t('Description'),
'description' => t('The description of this feed item'),
'weight' => 2,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $extra;
}
diff --git a/core/modules/aggregator/src/AggregatorFeedViewsData.php b/core/modules/aggregator/src/AggregatorFeedViewsData.php
index 2eb0d344f4f..b47f837dbdf 100644
--- a/core/modules/aggregator/src/AggregatorFeedViewsData.php
+++ b/core/modules/aggregator/src/AggregatorFeedViewsData.php
@@ -15,12 +15,12 @@ class AggregatorFeedViewsData extends EntityViewsData {
public function getViewsData() {
$data = parent::getViewsData();
- $data['aggregator_feed']['table']['join'] = array(
- 'aggregator_item' => array(
+ $data['aggregator_feed']['table']['join'] = [
+ 'aggregator_item' => [
'left_field' => 'fid',
'field' => 'fid',
- ),
- );
+ ],
+ ];
$data['aggregator_feed']['fid']['help'] = $this->t('The unique ID of the aggregator feed.');
$data['aggregator_feed']['fid']['argument']['id'] = 'aggregator_fid';
diff --git a/core/modules/aggregator/src/Controller/AggregatorController.php b/core/modules/aggregator/src/Controller/AggregatorController.php
index c84fb18b634..021e4d10a29 100644
--- a/core/modules/aggregator/src/Controller/AggregatorController.php
+++ b/core/modules/aggregator/src/Controller/AggregatorController.php
@@ -48,9 +48,9 @@ class AggregatorController extends ControllerBase {
*/
public function feedAdd() {
$feed = $this->entityManager()->getStorage('aggregator_feed')
- ->create(array(
+ ->create([
'refresh' => 3600,
- ));
+ ]);
return $this->entityFormBuilder()->getForm($feed);
}
@@ -67,15 +67,15 @@ class AggregatorController extends ControllerBase {
*/
protected function buildPageList(array $items, $feed_source = '') {
// Assemble output.
- $build = array(
+ $build = [
'#type' => 'container',
- '#attributes' => array('class' => array('aggregator-wrapper')),
- );
- $build['feed_source'] = is_array($feed_source) ? $feed_source : array('#markup' => $feed_source);
+ '#attributes' => ['class' => ['aggregator-wrapper']],
+ ];
+ $build['feed_source'] = is_array($feed_source) ? $feed_source : ['#markup' => $feed_source];
if ($items) {
$build['items'] = $this->entityManager()->getViewBuilder('aggregator_item')
->viewMultiple($items, 'default');
- $build['pager'] = array('#type' => 'pager');
+ $build['pager'] = ['#type' => 'pager'];
}
return $build;
}
@@ -94,8 +94,8 @@ class AggregatorController extends ControllerBase {
*/
public function feedRefresh(FeedInterface $aggregator_feed) {
$message = $aggregator_feed->refreshItems()
- ? $this->t('There is new syndicated content from %site.', array('%site' => $aggregator_feed->label()))
- : $this->t('There is no new syndicated content from %site.', array('%site' => $aggregator_feed->label()));
+ ? $this->t('There is new syndicated content from %site.', ['%site' => $aggregator_feed->label()])
+ : $this->t('There is no new syndicated content from %site.', ['%site' => $aggregator_feed->label()]);
drupal_set_message($message);
return $this->redirect('aggregator.admin_overview');
}
@@ -111,22 +111,22 @@ class AggregatorController extends ControllerBase {
$feeds = $entity_manager->getStorage('aggregator_feed')
->loadMultiple();
- $header = array($this->t('Title'), $this->t('Items'), $this->t('Last update'), $this->t('Next update'), $this->t('Operations'));
- $rows = array();
+ $header = [$this->t('Title'), $this->t('Items'), $this->t('Last update'), $this->t('Next update'), $this->t('Operations')];
+ $rows = [];
/** @var \Drupal\aggregator\FeedInterface[] $feeds */
foreach ($feeds as $feed) {
- $row = array();
+ $row = [];
$row[] = $feed->link();
$row[] = $this->formatPlural($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items');
$last_checked = $feed->getLastCheckedTime();
$refresh_rate = $feed->getRefreshRate();
- $row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked))) : $this->t('never'));
+ $row[] = ($last_checked ? $this->t('@time ago', ['@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked)]) : $this->t('never'));
if (!$last_checked && $refresh_rate) {
$next_update = $this->t('imminently');
}
elseif ($last_checked && $refresh_rate) {
- $next_update = $next = $this->t('%time left', array('%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)));
+ $next_update = $next = $this->t('%time left', ['%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)]);
}
else {
$next_update = $this->t('never');
@@ -136,33 +136,33 @@ class AggregatorController extends ControllerBase {
'title' => $this->t('Edit'),
'url' => Url::fromRoute('entity.aggregator_feed.edit_form', ['aggregator_feed' => $feed->id()]),
];
- $links['delete'] = array(
+ $links['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('entity.aggregator_feed.delete_form', ['aggregator_feed' => $feed->id()]),
- );
- $links['delete_items'] = array(
+ ];
+ $links['delete_items'] = [
'title' => $this->t('Delete items'),
'url' => Url::fromRoute('aggregator.feed_items_delete', ['aggregator_feed' => $feed->id()]),
- );
- $links['update'] = array(
+ ];
+ $links['update'] = [
'title' => $this->t('Update items'),
'url' => Url::fromRoute('aggregator.feed_refresh', ['aggregator_feed' => $feed->id()]),
- );
- $row[] = array(
- 'data' => array(
+ ];
+ $row[] = [
+ 'data' => [
'#type' => 'operations',
'#links' => $links,
- ),
- );
+ ],
+ ];
$rows[] = $row;
}
- $build['feeds'] = array(
+ $build['feeds'] = [
'#prefix' => '<h3>' . $this->t('Feed overview') . '</h3>',
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- '#empty' => $this->t('No feeds available. <a href=":link">Add feed</a>.', array(':link' => $this->url('aggregator.feed_add'))),
- );
+ '#empty' => $this->t('No feeds available. <a href=":link">Add feed</a>.', [':link' => $this->url('aggregator.feed_add')]),
+ ];
return $build;
}
@@ -176,7 +176,7 @@ class AggregatorController extends ControllerBase {
public function pageLast() {
$items = $this->entityManager()->getStorage('aggregator_item')->loadAll(20);
$build = $this->buildPageList($items);
- $build['#attached']['feed'][] = array('aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator'));
+ $build['#attached']['feed'][] = ['aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator')];
return $build;
}
diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php
index 834a55e9a85..3b14e8c24e3 100644
--- a/core/modules/aggregator/src/Entity/Feed.php
+++ b/core/modules/aggregator/src/Entity/Feed.php
@@ -88,11 +88,11 @@ class Feed extends ContentEntityBase implements FeedInterface {
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage, array &$values) {
- $values += array(
+ $values += [
'link' => '',
'description' => '',
'image' => '',
- );
+ ];
}
/**
@@ -143,10 +143,10 @@ class Feed extends ContentEntityBase implements FeedInterface {
->setDescription(t('The name of the feed (or the name of the website providing the feed).'))
->setRequired(TRUE)
->setSetting('max_length', 255)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ))
+ ])
->setDisplayConfigurable('form', TRUE)
->addConstraint('FeedTitle');
@@ -154,15 +154,15 @@ class Feed extends ContentEntityBase implements FeedInterface {
->setLabel(t('URL'))
->setDescription(t('The fully-qualified URL of the feed.'))
->setRequired(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'uri',
'weight' => -3,
- ))
+ ])
->setDisplayConfigurable('form', TRUE)
->addConstraint('FeedUrl');
- $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
- $period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals));
+ $intervals = [900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200];
+ $period = array_map([\Drupal::service('date.formatter'), 'formatInterval'], array_combine($intervals, $intervals));
$period[AGGREGATOR_CLEAR_NEVER] = t('Never');
$fields['refresh'] = BaseFieldDefinition::create('list_integer')
@@ -171,21 +171,21 @@ class Feed extends ContentEntityBase implements FeedInterface {
->setSetting('unsigned', TRUE)
->setRequired(TRUE)
->setSetting('allowed_values', $period)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => -2,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['checked'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Checked'))
->setDescription(t('Last time feed was checked for new items, as Unix timestamp.'))
->setDefaultValue(0)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'timestamp_ago',
'weight' => 1,
- ))
+ ])
->setDisplayConfigurable('view', TRUE);
$fields['queued'] = BaseFieldDefinition::create('timestamp')
@@ -196,15 +196,15 @@ class Feed extends ContentEntityBase implements FeedInterface {
$fields['link'] = BaseFieldDefinition::create('uri')
->setLabel(t('URL'))
->setDescription(t('The link of the feed.'))
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'inline',
'weight' => 4,
- ))
+ ])
->setDisplayConfigurable('view', TRUE);
$fields['description'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Description'))
- ->setDescription(t("The parent website's description that comes from the @description element in the feed.", array('@description' => '<description>')));
+ ->setDescription(t("The parent website's description that comes from the @description element in the feed.", ['@description' => '<description>']));
$fields['image'] = BaseFieldDefinition::create('uri')
->setLabel(t('Image'))
diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php
index 969e4e40bda..ef0c6d24518 100644
--- a/core/modules/aggregator/src/Entity/Item.php
+++ b/core/modules/aggregator/src/Entity/Item.php
@@ -61,11 +61,11 @@ class Item extends ContentEntityBase implements ItemInterface {
->setRequired(TRUE)
->setDescription(t('The aggregator feed entity associated with this item.'))
->setSetting('target_type', 'aggregator_feed')
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'entity_reference_label',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['title'] = BaseFieldDefinition::create('string')
@@ -75,18 +75,18 @@ class Item extends ContentEntityBase implements ItemInterface {
$fields['link'] = BaseFieldDefinition::create('uri')
->setLabel(t('Link'))
->setDescription(t('The link of the feed item.'))
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'region' => 'hidden',
- ))
+ ])
->setDisplayConfigurable('view', TRUE);
$fields['author'] = BaseFieldDefinition::create('string')
->setLabel(t('Author'))
->setDescription(t('The author of the feed item.'))
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'weight' => 3,
- ))
+ ])
->setDisplayConfigurable('view', TRUE);
$fields['description'] = BaseFieldDefinition::create('string_long')
@@ -96,11 +96,11 @@ class Item extends ContentEntityBase implements ItemInterface {
$fields['timestamp'] = BaseFieldDefinition::create('created')
->setLabel(t('Posted on'))
->setDescription(t('Posted date of the feed item, as a Unix timestamp.'))
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp_ago',
'weight' => 1,
- ))
+ ])
->setDisplayConfigurable('view', TRUE);
// @todo Convert to a real UUID field in
diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php
index 3447cc8c0f4..1580a307dc1 100644
--- a/core/modules/aggregator/src/FeedForm.php
+++ b/core/modules/aggregator/src/FeedForm.php
@@ -20,12 +20,12 @@ class FeedForm extends ContentEntityForm {
$label = $feed->label();
$view_link = $feed->link($label, 'canonical');
if ($status == SAVED_UPDATED) {
- drupal_set_message($this->t('The feed %feed has been updated.', array('%feed' => $view_link)));
+ drupal_set_message($this->t('The feed %feed has been updated.', ['%feed' => $view_link]));
$form_state->setRedirectUrl($feed->urlInfo('canonical'));
}
else {
- $this->logger('aggregator')->notice('Feed %feed added.', array('%feed' => $feed->label(), 'link' => $this->l($this->t('View'), new Url('aggregator.admin_overview'))));
- drupal_set_message($this->t('The feed %feed has been added.', array('%feed' => $view_link)));
+ $this->logger('aggregator')->notice('Feed %feed added.', ['%feed' => $feed->label(), 'link' => $this->l($this->t('View'), new Url('aggregator.admin_overview'))]);
+ drupal_set_message($this->t('The feed %feed has been added.', ['%feed' => $view_link]));
}
}
diff --git a/core/modules/aggregator/src/FeedStorage.php b/core/modules/aggregator/src/FeedStorage.php
index 5085e6d3533..ded3531380d 100644
--- a/core/modules/aggregator/src/FeedStorage.php
+++ b/core/modules/aggregator/src/FeedStorage.php
@@ -16,10 +16,10 @@ class FeedStorage extends SqlContentEntityStorage implements FeedStorageInterfac
* {@inheritdoc}
*/
public function getFeedIdsToRefresh() {
- return $this->database->query('SELECT fid FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array(
+ return $this->database->query('SELECT fid FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', [
':time' => REQUEST_TIME,
':never' => AGGREGATOR_CLEAR_NEVER,
- ))->fetchCol();
+ ])->fetchCol();
}
}
diff --git a/core/modules/aggregator/src/FeedViewBuilder.php b/core/modules/aggregator/src/FeedViewBuilder.php
index 5ce69ffd873..1efaa3028ce 100644
--- a/core/modules/aggregator/src/FeedViewBuilder.php
+++ b/core/modules/aggregator/src/FeedViewBuilder.php
@@ -68,65 +68,65 @@ class FeedViewBuilder extends EntityViewBuilder {
if ($view_mode == 'full') {
// Also add the pager.
- $build[$id]['pager'] = array('#type' => 'pager');
+ $build[$id]['pager'] = ['#type' => 'pager'];
}
}
if ($display->getComponent('description')) {
- $build[$id]['description'] = array(
+ $build[$id]['description'] = [
'#markup' => $entity->getDescription(),
'#allowed_tags' => _aggregator_allowed_tags(),
'#prefix' => '<div class="feed-description">',
'#suffix' => '</div>',
- );
+ ];
}
if ($display->getComponent('image')) {
- $image_link = array();
+ $image_link = [];
// Render the image as link if it is available.
$image = $entity->getImage();
$label = $entity->label();
$link_href = $entity->getWebsiteUrl();
if ($image && $label && $link_href) {
- $link_title = array(
+ $link_title = [
'#theme' => 'image',
'#uri' => $image,
'#alt' => $label,
- );
- $image_link = array(
+ ];
+ $image_link = [
'#type' => 'link',
'#title' => $link_title,
'#url' => Url::fromUri($link_href),
- '#options' => array(
- 'attributes' => array('class' => array('feed-image')),
- ),
- );
+ '#options' => [
+ 'attributes' => ['class' => ['feed-image']],
+ ],
+ ];
}
$build[$id]['image'] = $image_link;
}
if ($display->getComponent('feed_icon')) {
- $build[$id]['feed_icon'] = array(
+ $build[$id]['feed_icon'] = [
'#theme' => 'feed_icon',
'#url' => $entity->getUrl(),
- '#title' => t('@title feed', array('@title' => $entity->label())),
- );
+ '#title' => t('@title feed', ['@title' => $entity->label()]),
+ ];
}
if ($display->getComponent('more_link')) {
$title_stripped = strip_tags($entity->label());
- $build[$id]['more_link'] = array(
+ $build[$id]['more_link'] = [
'#type' => 'link',
- '#title' => t('More<span class="visually-hidden"> posts about @title</span>', array(
+ '#title' => t('More<span class="visually-hidden"> posts about @title</span>', [
'@title' => $title_stripped,
- )),
+ ]),
'#url' => Url::fromRoute('entity.aggregator_feed.canonical', ['aggregator_feed' => $entity->id()]),
- '#options' => array(
- 'attributes' => array(
+ '#options' => [
+ 'attributes' => [
'title' => $title_stripped,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
diff --git a/core/modules/aggregator/src/Form/FeedDeleteForm.php b/core/modules/aggregator/src/Form/FeedDeleteForm.php
index bcf1a3273a0..17a179864fc 100644
--- a/core/modules/aggregator/src/Form/FeedDeleteForm.php
+++ b/core/modules/aggregator/src/Form/FeedDeleteForm.php
@@ -28,9 +28,9 @@ class FeedDeleteForm extends ContentEntityDeleteForm {
* {@inheritdoc}
*/
protected function getDeletionMessage() {
- return $this->t('The feed %label has been deleted.', array(
+ return $this->t('The feed %label has been deleted.', [
'%label' => $this->entity->label(),
- ));
+ ]);
}
}
diff --git a/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php b/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php
index 1117359c0d9..48c83dc8386 100644
--- a/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php
+++ b/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php
@@ -15,7 +15,7 @@ class FeedItemsDeleteForm extends ContentEntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete all items from the feed %feed?', array('%feed' => $this->entity->label()));
+ return $this->t('Are you sure you want to delete all items from the feed %feed?', ['%feed' => $this->entity->label()]);
}
/**
diff --git a/core/modules/aggregator/src/Form/OpmlFeedAdd.php b/core/modules/aggregator/src/Form/OpmlFeedAdd.php
index c78a8b73acc..59e70d9727a 100644
--- a/core/modules/aggregator/src/Form/OpmlFeedAdd.php
+++ b/core/modules/aggregator/src/Form/OpmlFeedAdd.php
@@ -63,33 +63,33 @@ class OpmlFeedAdd extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
- $period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals));
+ $intervals = [900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200];
+ $period = array_map([\Drupal::service('date.formatter'), 'formatInterval'], array_combine($intervals, $intervals));
- $form['upload'] = array(
+ $form['upload'] = [
'#type' => 'file',
'#title' => $this->t('OPML File'),
'#description' => $this->t('Upload an OPML file containing a list of feeds to be imported.'),
- );
- $form['remote'] = array(
+ ];
+ $form['remote'] = [
'#type' => 'url',
'#title' => $this->t('OPML Remote URL'),
'#maxlength' => 1024,
'#description' => $this->t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'),
- );
- $form['refresh'] = array(
+ ];
+ $form['refresh'] = [
'#type' => 'select',
'#title' => $this->t('Update interval'),
'#default_value' => 3600,
'#options' => $period,
- '#description' => $this->t('The length of time between feed updates. Requires a correctly configured <a href=":cron">cron maintenance task</a>.', array(':cron' => $this->url('system.status'))),
- );
+ '#description' => $this->t('The length of time between feed updates. Requires a correctly configured <a href=":cron">cron maintenance task</a>.', [':cron' => $this->url('system.status')]),
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Import'),
- );
+ ];
return $form;
}
@@ -109,7 +109,7 @@ class OpmlFeedAdd extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $validators = array('file_validate_extensions' => array('opml xml'));
+ $validators = ['file_validate_extensions' => ['opml xml']];
if ($file = file_save_upload('upload', $validators, FALSE, 0)) {
$data = file_get_contents($file->getFileUri());
}
@@ -120,8 +120,8 @@ class OpmlFeedAdd extends FormBase {
$data = (string) $response->getBody();
}
catch (RequestException $e) {
- $this->logger('aggregator')->warning('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()));
- drupal_set_message($this->t('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage())));
+ $this->logger('aggregator')->warning('Failed to download OPML file due to "%error".', ['%error' => $e->getMessage()]);
+ drupal_set_message($this->t('Failed to download OPML file due to "%error".', ['%error' => $e->getMessage()]));
return;
}
}
@@ -136,7 +136,7 @@ class OpmlFeedAdd extends FormBase {
foreach ($feeds as $feed) {
// Ensure URL is valid.
if (!UrlHelper::isValid($feed['url'], TRUE)) {
- drupal_set_message($this->t('The URL %url is invalid.', array('%url' => $feed['url'])), 'warning');
+ drupal_set_message($this->t('The URL %url is invalid.', ['%url' => $feed['url']]), 'warning');
continue;
}
@@ -151,20 +151,20 @@ class OpmlFeedAdd extends FormBase {
$result = $this->feedStorage->loadMultiple($ids);
foreach ($result as $old) {
if (strcasecmp($old->label(), $feed['title']) == 0) {
- drupal_set_message($this->t('A feed named %title already exists.', array('%title' => $old->label())), 'warning');
+ drupal_set_message($this->t('A feed named %title already exists.', ['%title' => $old->label()]), 'warning');
continue 2;
}
if (strcasecmp($old->getUrl(), $feed['url']) == 0) {
- drupal_set_message($this->t('A feed with the URL %url already exists.', array('%url' => $old->getUrl())), 'warning');
+ drupal_set_message($this->t('A feed with the URL %url already exists.', ['%url' => $old->getUrl()]), 'warning');
continue 2;
}
}
- $new_feed = $this->feedStorage->create(array(
+ $new_feed = $this->feedStorage->create([
'title' => $feed['title'],
'url' => $feed['url'],
'refresh' => $form_state->getValue('refresh'),
- ));
+ ]);
$new_feed->save();
}
@@ -189,7 +189,7 @@ class OpmlFeedAdd extends FormBase {
* @todo Move this to a parser in https://www.drupal.org/node/1963540.
*/
protected function parseOpml($opml) {
- $feeds = array();
+ $feeds = [];
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8');
if (xml_parse_into_struct($xml_parser, $opml, $values)) {
@@ -197,7 +197,7 @@ class OpmlFeedAdd extends FormBase {
if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) {
$item = $entry['attributes'];
if (!empty($item['XMLURL']) && !empty($item['TEXT'])) {
- $feeds[] = array('title' => $item['TEXT'], 'url' => $item['XMLURL']);
+ $feeds[] = ['title' => $item['TEXT'], 'url' => $item['XMLURL']];
}
}
}
diff --git a/core/modules/aggregator/src/Form/SettingsForm.php b/core/modules/aggregator/src/Form/SettingsForm.php
index edd574189df..48b2dfe87e2 100644
--- a/core/modules/aggregator/src/Form/SettingsForm.php
+++ b/core/modules/aggregator/src/Form/SettingsForm.php
@@ -21,25 +21,25 @@ class SettingsForm extends ConfigFormBase {
*
* @var \Drupal\aggregator\Plugin\AggregatorPluginManager[]
*/
- protected $managers = array();
+ protected $managers = [];
/**
* The instantiated plugin instances that have configuration forms.
*
* @var \Drupal\Core\Plugin\PluginFormInterface[]
*/
- protected $configurableInstances = array();
+ protected $configurableInstances = [];
/**
* The aggregator plugin definitions.
*
* @var array
*/
- protected $definitions = array(
- 'fetcher' => array(),
- 'parser' => array(),
- 'processor' => array(),
- );
+ protected $definitions = [
+ 'fetcher' => [],
+ 'parser' => [],
+ 'processor' => [],
+ ];
/**
* Constructs a \Drupal\aggregator\SettingsForm object.
@@ -58,15 +58,15 @@ class SettingsForm extends ConfigFormBase {
public function __construct(ConfigFactoryInterface $config_factory, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager, TranslationInterface $string_translation) {
parent::__construct($config_factory);
$this->stringTranslation = $string_translation;
- $this->managers = array(
+ $this->managers = [
'fetcher' => $fetcher_manager,
'parser' => $parser_manager,
'processor' => $processor_manager,
- );
+ ];
// Get all available fetcher, parser and processor definitions.
- foreach (array('fetcher', 'parser', 'processor') as $type) {
+ foreach (['fetcher', 'parser', 'processor'] as $type) {
foreach ($this->managers[$type]->getDefinitions() as $id => $definition) {
- $this->definitions[$type][$id] = SafeMarkup::format('@title <span class="description">@description</span>', array('@title' => $definition['title'], '@description' => $definition['description']));
+ $this->definitions[$type][$id] = SafeMarkup::format('@title <span class="description">@description</span>', ['@title' => $definition['title'], '@description' => $definition['description']]);
}
}
}
@@ -105,56 +105,56 @@ class SettingsForm extends ConfigFormBase {
$config = $this->config('aggregator.settings');
// Global aggregator settings.
- $form['aggregator_allowed_html_tags'] = array(
+ $form['aggregator_allowed_html_tags'] = [
'#type' => 'textfield',
'#title' => $this->t('Allowed HTML tags'),
'#size' => 80,
'#maxlength' => 255,
'#default_value' => $config->get('items.allowed_html'),
'#description' => $this->t('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'),
- );
+ ];
// Only show basic configuration if there are actually options.
- $basic_conf = array();
+ $basic_conf = [];
if (count($this->definitions['fetcher']) > 1) {
- $basic_conf['aggregator_fetcher'] = array(
+ $basic_conf['aggregator_fetcher'] = [
'#type' => 'radios',
'#title' => $this->t('Fetcher'),
'#description' => $this->t('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'),
'#options' => $this->definitions['fetcher'],
'#default_value' => $config->get('fetcher'),
- );
+ ];
}
if (count($this->definitions['parser']) > 1) {
- $basic_conf['aggregator_parser'] = array(
+ $basic_conf['aggregator_parser'] = [
'#type' => 'radios',
'#title' => $this->t('Parser'),
'#description' => $this->t('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'),
'#options' => $this->definitions['parser'],
'#default_value' => $config->get('parser'),
- );
+ ];
}
if (count($this->definitions['processor']) > 1) {
- $basic_conf['aggregator_processors'] = array(
+ $basic_conf['aggregator_processors'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Processors'),
'#description' => $this->t('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'),
'#options' => $this->definitions['processor'],
'#default_value' => $config->get('processors'),
- );
+ ];
}
if (count($basic_conf)) {
- $form['basic_conf'] = array(
+ $form['basic_conf'] = [
'#type' => 'details',
'#title' => $this->t('Basic configuration'),
'#description' => $this->t('For most aggregation tasks, the default settings are fine.'),
'#open' => TRUE,
- );
+ ];
$form['basic_conf'] += $basic_conf;
}
// Call buildConfigurationForm() on the active fetcher and parser.
- foreach (array('fetcher', 'parser') as $type) {
+ foreach (['fetcher', 'parser'] as $type) {
$active = $config->get($type);
if (array_key_exists($active, $this->definitions[$type])) {
$instance = $this->managers[$type]->createInstance($active);
@@ -169,7 +169,7 @@ class SettingsForm extends ConfigFormBase {
}
// Implementing processor plugins will expect an array at $form['processors'].
- $form['processors'] = array();
+ $form['processors'] = [];
// Call buildConfigurationForm() for each active processor.
foreach ($this->definitions['processor'] as $id => $definition) {
if (in_array($id, $config->get('processors'))) {
diff --git a/core/modules/aggregator/src/ItemViewBuilder.php b/core/modules/aggregator/src/ItemViewBuilder.php
index feb0ffafb86..feb35b58358 100644
--- a/core/modules/aggregator/src/ItemViewBuilder.php
+++ b/core/modules/aggregator/src/ItemViewBuilder.php
@@ -20,12 +20,12 @@ class ItemViewBuilder extends EntityViewBuilder {
$display = $displays[$bundle];
if ($display->getComponent('description')) {
- $build[$id]['description'] = array(
+ $build[$id]['description'] = [
'#markup' => $entity->getDescription(),
'#allowed_tags' => _aggregator_allowed_tags(),
'#prefix' => '<div class="item-description">',
'#suffix' => '</div>',
- );
+ ];
}
}
}
diff --git a/core/modules/aggregator/src/ItemsImporter.php b/core/modules/aggregator/src/ItemsImporter.php
index df02564080c..aa18d65c9af 100644
--- a/core/modules/aggregator/src/ItemsImporter.php
+++ b/core/modules/aggregator/src/ItemsImporter.php
@@ -95,7 +95,7 @@ class ItemsImporter implements ItemsImporterInterface {
}
// Store instances in an array so we dont have to instantiate new objects.
- $processor_instances = array();
+ $processor_instances = [];
foreach ($this->config->get('processors') as $processor) {
try {
$processor_instances[$processor] = $this->processorManager->createInstance($processor);
@@ -124,10 +124,10 @@ class ItemsImporter implements ItemsImporterInterface {
// Log if feed URL has changed.
if ($feed->getUrl() != $feed_url) {
- $this->logger->notice('Updated URL for feed %title to %url.', array('%title' => $feed->label(), '%url' => $feed->getUrl()));
+ $this->logger->notice('Updated URL for feed %title to %url.', ['%title' => $feed->label(), '%url' => $feed->getUrl()]);
}
- $this->logger->notice('There is new syndicated content from %site.', array('%site' => $feed->label()));
+ $this->logger->notice('There is new syndicated content from %site.', ['%site' => $feed->label()]);
// If there are items on the feed, let enabled processors process them.
if (!empty($feed->items)) {
diff --git a/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php
index cd8a6e3e1c7..7310987988c 100644
--- a/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php
+++ b/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php
@@ -34,16 +34,16 @@ class AggregatorPluginManager extends DefaultPluginManager {
* The module handler.
*/
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
- $type_annotations = array(
+ $type_annotations = [
'fetcher' => 'Drupal\aggregator\Annotation\AggregatorFetcher',
'parser' => 'Drupal\aggregator\Annotation\AggregatorParser',
'processor' => 'Drupal\aggregator\Annotation\AggregatorProcessor',
- );
- $plugin_interfaces = array(
+ ];
+ $plugin_interfaces = [
'fetcher' => 'Drupal\aggregator\Plugin\FetcherInterface',
'parser' => 'Drupal\aggregator\Plugin\ParserInterface',
'processor' => 'Drupal\aggregator\Plugin\ProcessorInterface',
- );
+ ];
parent::__construct("Plugin/aggregator/$type", $namespaces, $module_handler, $plugin_interfaces[$type], $type_annotations[$type]);
$this->setCacheBackend($cache_backend, 'aggregator_' . $type . '_plugins');
diff --git a/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php b/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php
index bc59ec5eb28..403e6a34900 100644
--- a/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php
+++ b/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php
@@ -25,7 +25,7 @@ abstract class AggregatorPluginSettingsBase extends PluginBase implements Plugin
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array();
+ return [];
}
/**
@@ -38,7 +38,7 @@ abstract class AggregatorPluginSettingsBase extends PluginBase implements Plugin
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
}
diff --git a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
index 72e7a30892a..90d8f669dda 100644
--- a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
+++ b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php
@@ -77,10 +77,10 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt
*/
public function defaultConfiguration() {
// By default, the block will contain 10 feed items.
- return array(
+ return [
'block_count' => 10,
'feed' => NULL,
- );
+ ];
}
/**
@@ -96,23 +96,23 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt
*/
public function blockForm($form, FormStateInterface $form_state) {
$feeds = $this->feedStorage->loadMultiple();
- $options = array();
+ $options = [];
foreach ($feeds as $feed) {
$options[$feed->id()] = $feed->label();
}
- $form['feed'] = array(
+ $form['feed'] = [
'#type' => 'select',
'#title' => $this->t('Select the feed that should be displayed'),
'#default_value' => $this->configuration['feed'],
'#options' => $options,
- );
+ ];
$range = range(2, 20);
- $form['block_count'] = array(
+ $form['block_count'] = [
'#type' => 'select',
'#title' => $this->t('Number of news items in block'),
'#default_value' => $this->configuration['block_count'],
'#options' => array_combine($range, $range),
- );
+ ];
return $form;
}
diff --git a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
index 99ec48d9ce8..91c7ac36ed8 100644
--- a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
+++ b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
@@ -112,8 +112,8 @@ class DefaultFetcher implements FetcherInterface, ContainerFactoryPluginInterfac
return TRUE;
}
catch (RequestException $e) {
- $this->logger->warning('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage()));
- drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())), 'warning');
+ $this->logger->warning('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]);
+ drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]), 'warning');
return FALSE;
}
}
diff --git a/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php b/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php
index 2fb36823d86..03fa55f01cc 100644
--- a/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php
+++ b/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php
@@ -31,7 +31,7 @@ class DefaultParser implements ParserInterface {
}
catch (ExceptionInterface $e) {
watchdog_exception('aggregator', $e);
- drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())), 'error');
+ drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]), 'error');
return FALSE;
}
@@ -42,10 +42,10 @@ class DefaultParser implements ParserInterface {
$feed->setImage($image['uri']);
}
// Initialize items array.
- $feed->items = array();
+ $feed->items = [];
foreach ($channel as $item) {
// Reset the parsed item.
- $parsed_item = array();
+ $parsed_item = [];
// Move the values to an array as expected by processors.
$parsed_item['title'] = $item->getTitle();
$parsed_item['guid'] = $item->getId();
diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php
index 4469c51a6dd..525ef34f13a 100644
--- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php
+++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php
@@ -105,53 +105,53 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
$config = $this->config('aggregator.settings');
$processors = $config->get('processors');
$info = $this->getPluginDefinition();
- $counts = array(3, 5, 10, 15, 20, 25);
+ $counts = [3, 5, 10, 15, 20, 25];
$items = array_map(function ($count) {
return $this->formatPlural($count, '1 item', '@count items');
}, array_combine($counts, $counts));
- $intervals = array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800);
- $period = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($intervals, $intervals));
+ $intervals = [3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800];
+ $period = array_map([$this->dateFormatter, 'formatInterval'], array_combine($intervals, $intervals));
$period[AGGREGATOR_CLEAR_NEVER] = t('Never');
- $form['processors'][$info['id']] = array();
+ $form['processors'][$info['id']] = [];
// Only wrap into details if there is a basic configuration.
if (isset($form['basic_conf'])) {
- $form['processors'][$info['id']] = array(
+ $form['processors'][$info['id']] = [
'#type' => 'details',
'#title' => t('Default processor settings'),
'#description' => $info['description'],
'#open' => in_array($info['id'], $processors),
- );
+ ];
}
- $form['processors'][$info['id']]['aggregator_summary_items'] = array(
+ $form['processors'][$info['id']]['aggregator_summary_items'] = [
'#type' => 'select',
'#title' => t('Number of items shown in listing pages'),
'#default_value' => $config->get('source.list_max'),
'#empty_value' => 0,
'#options' => $items,
- );
+ ];
- $form['processors'][$info['id']]['aggregator_clear'] = array(
+ $form['processors'][$info['id']]['aggregator_clear'] = [
'#type' => 'select',
'#title' => t('Discard items older than'),
'#default_value' => $config->get('items.expire'),
'#options' => $period,
- '#description' => t('Requires a correctly configured <a href=":cron">cron maintenance task</a>.', array(':cron' => $this->url('system.status'))),
- );
+ '#description' => t('Requires a correctly configured <a href=":cron">cron maintenance task</a>.', [':cron' => $this->url('system.status')]),
+ ];
- $lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000);
+ $lengths = [0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000];
$options = array_map(function($length) {
return ($length == 0) ? t('Unlimited') : $this->formatPlural($length, '1 character', '@count characters');
}, array_combine($lengths, $lengths));
- $form['processors'][$info['id']]['aggregator_teaser_length'] = array(
+ $form['processors'][$info['id']]['aggregator_teaser_length'] = [
'#type' => 'select',
'#title' => t('Length of trimmed description'),
'#default_value' => $config->get('items.teaser_length'),
'#options' => $options,
'#description' => t('The maximum number of characters used in the trimmed version of content.'),
- );
+ ];
return $form;
}
@@ -185,13 +185,13 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
// we find a duplicate entry, we resolve it and pass along its ID is such
// that we can update it if needed.
if (!empty($item['guid'])) {
- $values = array('fid' => $feed->id(), 'guid' => $item['guid']);
+ $values = ['fid' => $feed->id(), 'guid' => $item['guid']];
}
elseif ($item['link'] && $item['link'] != $feed->link && $item['link'] != $feed->url) {
- $values = array('fid' => $feed->id(), 'link' => $item['link']);
+ $values = ['fid' => $feed->id(), 'link' => $item['link']];
}
else {
- $values = array('fid' => $feed->id(), 'title' => $item['title']);
+ $values = ['fid' => $feed->id(), 'title' => $item['title']];
}
// Try to load an existing entry.
@@ -199,7 +199,7 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
$entry = reset($entry);
}
else {
- $entry = Item::create(array('langcode' => $feed->language()->getId()));
+ $entry = Item::create(['langcode' => $feed->language()->getId()]);
}
if ($item['timestamp']) {
$entry->setPostedTime($item['timestamp']);
@@ -231,7 +231,7 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
$this->itemStorage->delete($items);
}
// @todo This should be moved out to caller with a different message maybe.
- drupal_set_message(t('The news items from %site have been deleted.', array('%site' => $feed->label())));
+ drupal_set_message(t('The news items from %site have been deleted.', ['%site' => $feed->label()]));
}
/**
diff --git a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php
index e623e5fd0ba..59244d4e4af 100644
--- a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php
+++ b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php
@@ -26,7 +26,7 @@ class AggregatorFeed extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'fid' => $this->t('The feed ID.'),
'title' => $this->t('Title of the feed.'),
'url' => $this->t('URL to the feed.'),
@@ -38,7 +38,7 @@ class AggregatorFeed extends DrupalSqlBase {
'etag' => $this->t('Entity tag HTTP response header.'),
'modified' => $this->t('When the feed was last modified.'),
'block' => $this->t("Number of items to display in the feed's block."),
- );
+ ];
if ($this->getModuleSchemaVersion('system') >= 7000) {
$fields['queued'] = $this->t('Time when this feed was queued for refresh, 0 if not queued.');
}
diff --git a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php
index fc1c5c6c71f..428c558ea7c 100644
--- a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php
+++ b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php
@@ -27,7 +27,7 @@ class AggregatorItem extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'iid' => $this->t('Primary Key: Unique ID for feed item.'),
'fid' => $this->t('The {aggregator_feed}.fid to which this item belongs.'),
'title' => $this->t('Title of the feed item.'),
@@ -36,7 +36,7 @@ class AggregatorItem extends DrupalSqlBase {
'description' => $this->t('Body of the feed item.'),
'timestamp' => $this->t('Post date of feed item, as a Unix timestamp.'),
'guid' => $this->t('Unique identifier for the feed item.'),
- );
+ ];
}
/**
diff --git a/core/modules/aggregator/src/Plugin/views/argument/Fid.php b/core/modules/aggregator/src/Plugin/views/argument/Fid.php
index bb912e1ce64..90564d5bb64 100644
--- a/core/modules/aggregator/src/Plugin/views/argument/Fid.php
+++ b/core/modules/aggregator/src/Plugin/views/argument/Fid.php
@@ -50,7 +50,7 @@ class Fid extends NumericArgument {
* {@inheritdoc}
*/
public function titleQuery() {
- $titles = array();
+ $titles = [];
$feeds = $this->entityManager->getStorage('aggregator_feed')->loadMultiple($this->value);
foreach ($feeds as $feed) {
diff --git a/core/modules/aggregator/src/Plugin/views/argument/Iid.php b/core/modules/aggregator/src/Plugin/views/argument/Iid.php
index 9468c9868c5..44b4569779e 100644
--- a/core/modules/aggregator/src/Plugin/views/argument/Iid.php
+++ b/core/modules/aggregator/src/Plugin/views/argument/Iid.php
@@ -50,7 +50,7 @@ class Iid extends NumericArgument {
* {@inheritdoc}
*/
public function titleQuery() {
- $titles = array();
+ $titles = [];
$items = $this->entityManager->getStorage('aggregator_item')->loadMultiple($this->value);
foreach ($items as $feed) {
diff --git a/core/modules/aggregator/src/Plugin/views/row/Rss.php b/core/modules/aggregator/src/Plugin/views/row/Rss.php
index ef46466490c..464a28592e4 100644
--- a/core/modules/aggregator/src/Plugin/views/row/Rss.php
+++ b/core/modules/aggregator/src/Plugin/views/row/Rss.php
@@ -48,31 +48,31 @@ class Rss extends RssPluginBase {
$item->{$name} = $field->value;
}
- $item->elements = array(
- array(
+ $item->elements = [
+ [
'key' => 'pubDate',
// views_view_row_rss takes care about the escaping.
'value' => gmdate('r', $entity->timestamp->value),
- ),
- array(
+ ],
+ [
'key' => 'dc:creator',
// views_view_row_rss takes care about the escaping.
'value' => $entity->author->value,
- ),
- array(
+ ],
+ [
'key' => 'guid',
// views_view_row_rss takes care about the escaping.
'value' => $entity->guid->value,
- 'attributes' => array('isPermaLink' => 'false'),
- ),
- );
+ 'attributes' => ['isPermaLink' => 'false'],
+ ],
+ ];
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $item,
- );
+ ];
return $build;
}
diff --git a/core/modules/aggregator/src/Tests/AddFeedTest.php b/core/modules/aggregator/src/Tests/AddFeedTest.php
index b7ffe5fbc71..4dfeb955720 100644
--- a/core/modules/aggregator/src/Tests/AddFeedTest.php
+++ b/core/modules/aggregator/src/Tests/AddFeedTest.php
@@ -39,8 +39,8 @@ class AddFeedTest extends AggregatorTestBase {
'refresh' => '900',
];
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
- $this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $feed->label())));
- $this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', array('%url' => $feed->getUrl())));
+ $this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()]));
+ $this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()]));
// Delete feed.
$this->deleteFeed($feed);
diff --git a/core/modules/aggregator/src/Tests/AggregatorAdminTest.php b/core/modules/aggregator/src/Tests/AggregatorAdminTest.php
index 487e0ef921c..3d09bbcac0a 100644
--- a/core/modules/aggregator/src/Tests/AggregatorAdminTest.php
+++ b/core/modules/aggregator/src/Tests/AggregatorAdminTest.php
@@ -22,7 +22,7 @@ class AggregatorAdminTest extends AggregatorTestBase {
$this->assertText('Test processor');
// Set new values and enable test plugins.
- $edit = array(
+ $edit = [
'aggregator_allowed_html_tags' => '<a>',
'aggregator_summary_items' => 10,
'aggregator_clear' => 3600,
@@ -30,27 +30,27 @@ class AggregatorAdminTest extends AggregatorTestBase {
'aggregator_fetcher' => 'aggregator_test_fetcher',
'aggregator_parser' => 'aggregator_test_parser',
'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor',
- );
+ ];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
foreach ($edit as $name => $value) {
- $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', array('@name' => $name)));
+ $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', ['@name' => $name]));
}
// Check for our test processor settings form.
$this->assertText(t('Dummy length setting'));
// Change its value to ensure that settingsSubmit is called.
- $edit = array(
+ $edit = [
'dummy_length' => 100,
- );
+ ];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->assertFieldByName('dummy_length', 100, '"dummy_length" has correct default value.');
// Make sure settings form is still accessible even after uninstalling a module
// that provides the selected plugins.
- $this->container->get('module_installer')->uninstall(array('aggregator_test'));
+ $this->container->get('module_installer')->uninstall(['aggregator_test']);
$this->resetAll();
$this->drupalGet('admin/config/services/aggregator/settings');
$this->assertResponse(200);
diff --git a/core/modules/aggregator/src/Tests/AggregatorCronTest.php b/core/modules/aggregator/src/Tests/AggregatorCronTest.php
index 34a4cb930ce..9ebb2d25c00 100644
--- a/core/modules/aggregator/src/Tests/AggregatorCronTest.php
+++ b/core/modules/aggregator/src/Tests/AggregatorCronTest.php
@@ -16,30 +16,30 @@ class AggregatorCronTest extends AggregatorTestBase {
$this->createSampleNodes();
$feed = $this->createFeed();
$this->cronRun();
- $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField());
+ $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
$this->deleteFeedItems($feed);
- $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField());
+ $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
$this->cronRun();
- $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField());
+ $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
// Test feed locking when queued for update.
$this->deleteFeedItems($feed);
db_update('aggregator_feed')
->condition('fid', $feed->id())
- ->fields(array(
+ ->fields([
'queued' => REQUEST_TIME,
- ))
+ ])
->execute();
$this->cronRun();
- $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField());
+ $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
db_update('aggregator_feed')
->condition('fid', $feed->id())
- ->fields(array(
+ ->fields([
'queued' => 0,
- ))
+ ])
->execute();
$this->cronRun();
- $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField());
+ $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
}
}
diff --git a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
index 888f1da5676..de7e401058b 100644
--- a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
+++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
@@ -17,7 +17,7 @@ class AggregatorRenderingTest extends AggregatorTestBase {
*
* @var array
*/
- public static $modules = array('block', 'test_page_test');
+ public static $modules = ['block', 'test_page_test'];
protected function setUp() {
parent::setUp();
@@ -35,15 +35,15 @@ class AggregatorRenderingTest extends AggregatorTestBase {
$this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
// Need admin user to be able to access block admin.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer blocks',
'access administration pages',
'administer news feeds',
'access news feeds',
- ));
+ ]);
$this->drupalLogin($admin_user);
- $block = $this->drupalPlaceBlock("aggregator_feed_block", array('label' => 'feed-' . $feed->label()));
+ $block = $this->drupalPlaceBlock("aggregator_feed_block", ['label' => 'feed-' . $feed->label()]);
// Configure the feed that should be displayed.
$block->getPlugin()->setConfigurationValue('feed', $feed->id());
@@ -56,20 +56,20 @@ class AggregatorRenderingTest extends AggregatorTestBase {
// Confirm items appear as links.
$items = $this->container->get('entity.manager')->getStorage('aggregator_item')->loadByFeed($feed->id(), 1);
- $links = $this->xpath('//a[@href = :href]', array(':href' => reset($items)->getLink()));
+ $links = $this->xpath('//a[@href = :href]', [':href' => reset($items)->getLink()]);
$this->assert(isset($links[0]), 'Item link found.');
// Find the expected read_more link.
$href = $feed->url();
- $links = $this->xpath('//a[@href = :href]', array(':href' => $href));
- $this->assert(isset($links[0]), format_string('Link to href %href found.', array('%href' => $href)));
+ $links = $this->xpath('//a[@href = :href]', [':href' => $href]);
+ $this->assert(isset($links[0]), format_string('Link to href %href found.', ['%href' => $href]));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
// Visit that page.
$this->drupalGet($feed->urlInfo()->getInternalPath());
- $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->label()));
+ $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => $feed->label()]);
$this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.');
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
@@ -103,18 +103,18 @@ class AggregatorRenderingTest extends AggregatorTestBase {
// Check for presence of an aggregator pager.
$this->drupalGet('aggregator');
- $elements = $this->xpath("//ul[contains(@class, :class)]", array(':class' => 'pager__items'));
+ $elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
// Check for sources page title.
$this->drupalGet('aggregator/sources');
- $titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => 'Sources'));
+ $titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => 'Sources']);
$this->assertTrue(!empty($titles), 'Source page contains correct title.');
// Find the expected read_more link on the sources page.
$href = $feed->url();
- $links = $this->xpath('//a[@href = :href]', array(':href' => $href));
- $this->assertTrue(isset($links[0]), SafeMarkup::format('Link to href %href found.', array('%href' => $href)));
+ $links = $this->xpath('//a[@href = :href]', [':href' => $href]);
+ $this->assertTrue(isset($links[0]), SafeMarkup::format('Link to href %href found.', ['%href' => $href]));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
@@ -139,7 +139,7 @@ class AggregatorRenderingTest extends AggregatorTestBase {
// Check for the presence of a pager.
$this->drupalGet('aggregator/sources/' . $feed->id());
- $elements = $this->xpath("//ul[contains(@class, :class)]", array(':class' => 'pager__items'));
+ $elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php
index 35bd9a96892..f42248975ae 100644
--- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php
+++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php
@@ -37,10 +37,10 @@ abstract class AggregatorTestBase extends WebTestBase {
// Create an Article node type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer news feeds', 'access news feeds', 'create article content'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer news feeds', 'access news feeds', 'create article content']);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_tasks_block');
}
@@ -61,16 +61,16 @@ abstract class AggregatorTestBase extends WebTestBase {
*
* @see getFeedEditArray()
*/
- public function createFeed($feed_url = NULL, array $edit = array()) {
+ public function createFeed($feed_url = NULL, array $edit = []) {
$edit = $this->getFeedEditArray($feed_url, $edit);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
- $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
+ $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), format_string('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a feed.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']);
$this->assert(isset($view_link), 'The message area contains a link to a feed');
- $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField();
+ $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']])->fetchField();
$this->assertTrue(!empty($fid), 'The feed found in database.');
return Feed::load($fid);
}
@@ -82,8 +82,8 @@ abstract class AggregatorTestBase extends WebTestBase {
* Feed object representing the feed.
*/
public function deleteFeed(FeedInterface $feed) {
- $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', array(), t('Delete'));
- $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->label())), 'Feed deleted successfully.');
+ $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], t('Delete'));
+ $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]), 'Feed deleted successfully.');
}
/**
@@ -98,19 +98,19 @@ abstract class AggregatorTestBase extends WebTestBase {
* @return array
* A feed array.
*/
- public function getFeedEditArray($feed_url = NULL, array $edit = array()) {
+ public function getFeedEditArray($feed_url = NULL, array $edit = []) {
$feed_name = $this->randomMachineName(10);
if (!$feed_url) {
- $feed_url = \Drupal::url('view.frontpage.feed_1', array(), array(
- 'query' => array('feed' => $feed_name),
+ $feed_url = \Drupal::url('view.frontpage.feed_1', [], [
+ 'query' => ['feed' => $feed_name],
'absolute' => TRUE,
- ));
+ ]);
}
- $edit += array(
+ $edit += [
'title[0][value]' => $feed_name,
'url[0][value]' => $feed_url,
'refresh' => '900',
- );
+ ];
return $edit;
}
@@ -126,19 +126,19 @@ abstract class AggregatorTestBase extends WebTestBase {
* @return \Drupal\aggregator\FeedInterface
* A feed object.
*/
- public function getFeedEditObject($feed_url = NULL, array $values = array()) {
+ public function getFeedEditObject($feed_url = NULL, array $values = []) {
$feed_name = $this->randomMachineName(10);
if (!$feed_url) {
- $feed_url = \Drupal::url('view.frontpage.feed_1', array(
- 'query' => array('feed' => $feed_name),
+ $feed_url = \Drupal::url('view.frontpage.feed_1', [
+ 'query' => ['feed' => $feed_name],
'absolute' => TRUE,
- ));
+ ]);
}
- $values += array(
+ $values += [
'title' => $feed_name,
'url' => $feed_url,
'refresh' => '900',
- );
+ ];
return Feed::create($values);
}
@@ -168,7 +168,7 @@ abstract class AggregatorTestBase extends WebTestBase {
public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
// First, let's ensure we can get to the rss xml.
$this->drupalGet($feed->getUrl());
- $this->assertResponse(200, format_string(':url is reachable.', array(':url' => $feed->getUrl())));
+ $this->assertResponse(200, format_string(':url is reachable.', [':url' => $feed->getUrl()]));
// Attempt to access the update link directly without an access token.
$this->drupalGet('admin/config/services/aggregator/update/' . $feed->id());
@@ -179,15 +179,15 @@ abstract class AggregatorTestBase extends WebTestBase {
$this->clickLink('Update items');
// Ensure we have the right number of items.
- $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()));
- $feed->items = array();
+ $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()]);
+ $feed->items = [];
foreach ($result as $item) {
$feed->items[] = $item->iid;
}
if ($expected_count !== NULL) {
$feed->item_count = count($feed->items);
- $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', array('@val1' => $expected_count, '@val2' => $feed->item_count)));
+ $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', ['@val1' => $expected_count, '@val2' => $feed->item_count]));
}
}
@@ -198,8 +198,8 @@ abstract class AggregatorTestBase extends WebTestBase {
* Feed object representing the feed.
*/
public function deleteFeedItems(FeedInterface $feed) {
- $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), array(), t('Delete items'));
- $this->assertRaw(t('The news items from %title have been deleted.', array('%title' => $feed->label())), 'Feed items deleted.');
+ $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], t('Delete items'));
+ $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]), 'Feed items deleted.');
}
/**
@@ -212,10 +212,10 @@ abstract class AggregatorTestBase extends WebTestBase {
*/
public function updateAndDelete(FeedInterface $feed, $expected_count) {
$this->updateFeedItems($feed, $expected_count);
- $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
+ $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$this->assertTrue($count);
$this->deleteFeedItems($feed);
- $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
+ $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$this->assertTrue($count == 0);
}
@@ -231,7 +231,7 @@ abstract class AggregatorTestBase extends WebTestBase {
* TRUE if feed is unique.
*/
public function uniqueFeed($feed_name, $feed_url) {
- $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed_name, ':url' => $feed_url))->fetchField();
+ $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $feed_name, ':url' => $feed_url])->fetchField();
return (1 == $result);
}
@@ -358,7 +358,7 @@ EOF;
public function createSampleNodes($count = 5) {
// Post $count article nodes.
for ($i = 0; $i < $count; $i++) {
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/article', $edit, t('Save'));
@@ -372,10 +372,10 @@ EOF;
$this->config('aggregator.settings')
->set('fetcher', 'aggregator_test_fetcher')
->set('parser', 'aggregator_test_parser')
- ->set('processors', array(
+ ->set('processors', [
'aggregator_test_processor' => 'aggregator_test_processor',
'aggregator' => 'aggregator',
- ))
+ ])
->save();
}
diff --git a/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php b/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php
index 0324e3b9a55..0dbb872b568 100644
--- a/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php
+++ b/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php
@@ -14,7 +14,7 @@ class FeedAdminDisplayTest extends AggregatorTestBase {
*/
public function testFeedUpdateFields() {
// Create scheduled feed.
- $scheduled_feed = $this->createFeed(NULL, array('refresh' => '900'));
+ $scheduled_feed = $this->createFeed(NULL, ['refresh' => '900']);
$this->drupalGet('admin/config/services/aggregator');
$this->assertResponse(200, 'Aggregator feed overview page exists.');
@@ -40,7 +40,7 @@ class FeedAdminDisplayTest extends AggregatorTestBase {
$this->deleteFeed($scheduled_feed);
// Create non-scheduled feed.
- $non_scheduled_feed = $this->createFeed(NULL, array('refresh' => '0'));
+ $non_scheduled_feed = $this->createFeed(NULL, ['refresh' => '0']);
$this->drupalGet('admin/config/services/aggregator');
// The non scheduled feed shows that it has not been updated yet.
diff --git a/core/modules/aggregator/src/Tests/FeedLanguageTest.php b/core/modules/aggregator/src/Tests/FeedLanguageTest.php
index af8335e10e0..98d04fa5c13 100644
--- a/core/modules/aggregator/src/Tests/FeedLanguageTest.php
+++ b/core/modules/aggregator/src/Tests/FeedLanguageTest.php
@@ -16,14 +16,14 @@ class FeedLanguageTest extends AggregatorTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* List of langcodes.
*
* @var string[]
*/
- protected $langcodes = array();
+ protected $langcodes = [];
/**
* {@inheritdoc}
@@ -32,12 +32,12 @@ class FeedLanguageTest extends AggregatorTestBase {
parent::setUp();
// Create test languages.
- $this->langcodes = array(ConfigurableLanguage::load('en'));
+ $this->langcodes = [ConfigurableLanguage::load('en')];
for ($i = 1; $i < 3; ++$i) {
- $language = ConfigurableLanguage::create(array(
+ $language = ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this->randomString(),
- ));
+ ]);
$language->save();
$this->langcodes[$i] = $language->id();
}
@@ -57,10 +57,10 @@ class FeedLanguageTest extends AggregatorTestBase {
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
/** @var \Drupal\aggregator\FeedInterface[] $feeds */
- $feeds = array();
+ $feeds = [];
// Create feeds.
- $feeds[1] = $this->createFeed(NULL, array('langcode[0][value]' => $this->langcodes[1]));
- $feeds[2] = $this->createFeed(NULL, array('langcode[0][value]' => $this->langcodes[2]));
+ $feeds[1] = $this->createFeed(NULL, ['langcode[0][value]' => $this->langcodes[1]]);
+ $feeds[2] = $this->createFeed(NULL, ['langcode[0][value]' => $this->langcodes[2]]);
// Make sure that the language has been assigned.
$this->assertEqual($feeds[1]->language()->getId(), $this->langcodes[1]);
@@ -74,7 +74,7 @@ class FeedLanguageTest extends AggregatorTestBase {
// the one from the feed.
foreach ($feeds as $feed) {
/** @var \Drupal\aggregator\ItemInterface[] $items */
- $items = entity_load_multiple_by_properties('aggregator_item', array('fid' => $feed->id()));
+ $items = entity_load_multiple_by_properties('aggregator_item', ['fid' => $feed->id()]);
$this->assertTrue(count($items) > 0, 'Feed items were created.');
foreach ($items as $item) {
$this->assertEqual($item->language()->getId(), $feed->language()->getId());
diff --git a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php
index ae78205bcd5..67e96f17269 100644
--- a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php
+++ b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php
@@ -26,47 +26,47 @@ class UpdateFeedItemTest extends AggregatorTestBase {
$this->deleteFeed($feed);
// Test updating feed items without valid timestamp information.
- $edit = array(
+ $edit = [
'title[0][value]' => "Feed without publish timestamp",
'url[0][value]' => $this->getRSS091Sample(),
- );
+ ];
$this->drupalGet($edit['url[0][value]']);
$this->assertResponse(200);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
- $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
+ $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), format_string('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a feed.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']);
$this->assert(isset($view_link), 'The message area contains a link to a feed');
- $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField();
+ $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", [':url' => $edit['url[0][value]']])->fetchField();
$feed = Feed::load($fid);
$feed->refreshItems();
- $before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
+ $before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
// Sleep for 3 second.
sleep(3);
db_update('aggregator_feed')
->condition('fid', $feed->id())
- ->fields(array(
+ ->fields([
'checked' => 0,
'hash' => '',
'etag' => '',
'modified' => 0,
- ))
+ ])
->execute();
$feed->refreshItems();
- $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
- $this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', array('@before' => $before, '@after' => $after)));
+ $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
+ $this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', ['@before' => $before, '@after' => $after]));
// Make sure updating items works even after uninstalling a module
// that provides the selected plugins.
$this->enableTestPlugins();
- $this->container->get('module_installer')->uninstall(array('aggregator_test'));
+ $this->container->get('module_installer')->uninstall(['aggregator_test']);
$this->updateFeedItems($feed);
$this->assertResponse(200);
}
diff --git a/core/modules/aggregator/src/Tests/UpdateFeedTest.php b/core/modules/aggregator/src/Tests/UpdateFeedTest.php
index 8c797a5e828..d2308744c24 100644
--- a/core/modules/aggregator/src/Tests/UpdateFeedTest.php
+++ b/core/modules/aggregator/src/Tests/UpdateFeedTest.php
@@ -12,7 +12,7 @@ class UpdateFeedTest extends AggregatorTestBase {
* Creates a feed and attempts to update it.
*/
public function testUpdateFeed() {
- $remaining_fields = array('title[0][value]', 'url[0][value]', '');
+ $remaining_fields = ['title[0][value]', 'url[0][value]', ''];
foreach ($remaining_fields as $same_field) {
$feed = $this->createFeed();
@@ -24,10 +24,10 @@ class UpdateFeedTest extends AggregatorTestBase {
$edit[$same_field] = $feed->{$same_field}->value;
}
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save'));
- $this->assertText(t('The feed @name has been updated.', array('@name' => $edit['title[0][value]'])), format_string('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])));
+ $this->assertText(t('The feed @name has been updated.', ['@name' => $edit['title[0][value]']]), format_string('The feed %name has been updated.', ['%name' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a feed.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']);
$this->assert(isset($view_link), 'The message area contains a link to a feed');
// Check feed data.
diff --git a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php
index 2f73c5f4af6..294697a2bc2 100644
--- a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php
+++ b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php
@@ -75,20 +75,20 @@ class TestProcessor extends AggregatorPluginSettingsBase implements ProcessorInt
$processors = $this->config('aggregator.settings')->get('processors');
$info = $this->getPluginDefinition();
- $form['processors'][$info['id']] = array(
+ $form['processors'][$info['id']] = [
'#type' => 'details',
'#title' => t('Test processor settings'),
'#description' => $info['description'],
'#open' => in_array($info['id'], $processors),
- );
+ ];
// Add some dummy settings to verify settingsForm is called.
- $form['processors'][$info['id']]['dummy_length'] = array(
+ $form['processors'][$info['id']]['dummy_length'] = [
'#title' => t('Dummy length setting'),
'#type' => 'number',
'#min' => 1,
'#max' => 1000,
'#default_value' => $this->configuration['items']['dummy_length'],
- );
+ ];
return $form;
}
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
index 9a07135244b..ddd98bb82f4 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
@@ -34,10 +34,10 @@ abstract class AggregatorTestBase extends BrowserTestBase {
// Create an Article node type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer news feeds', 'access news feeds', 'create article content'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer news feeds', 'access news feeds', 'create article content']);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_tasks_block');
}
@@ -58,16 +58,16 @@ abstract class AggregatorTestBase extends BrowserTestBase {
*
* @see getFeedEditArray()
*/
- public function createFeed($feed_url = NULL, array $edit = array()) {
+ public function createFeed($feed_url = NULL, array $edit = []) {
$edit = $this->getFeedEditArray($feed_url, $edit);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
- $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
+ $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), format_string('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a feed.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']);
$this->assert(isset($view_link), 'The message area contains a link to a feed');
- $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField();
+ $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']])->fetchField();
$this->assertTrue(!empty($fid), 'The feed found in database.');
return Feed::load($fid);
}
@@ -79,8 +79,8 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* Feed object representing the feed.
*/
public function deleteFeed(FeedInterface $feed) {
- $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', array(), t('Delete'));
- $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->label())), 'Feed deleted successfully.');
+ $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], t('Delete'));
+ $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]), 'Feed deleted successfully.');
}
/**
@@ -95,19 +95,19 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* @return array
* A feed array.
*/
- public function getFeedEditArray($feed_url = NULL, array $edit = array()) {
+ public function getFeedEditArray($feed_url = NULL, array $edit = []) {
$feed_name = $this->randomMachineName(10);
if (!$feed_url) {
- $feed_url = \Drupal::url('view.frontpage.feed_1', array(), array(
- 'query' => array('feed' => $feed_name),
+ $feed_url = \Drupal::url('view.frontpage.feed_1', [], [
+ 'query' => ['feed' => $feed_name],
'absolute' => TRUE,
- ));
+ ]);
}
- $edit += array(
+ $edit += [
'title[0][value]' => $feed_name,
'url[0][value]' => $feed_url,
'refresh' => '900',
- );
+ ];
return $edit;
}
@@ -123,19 +123,19 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* @return \Drupal\aggregator\FeedInterface
* A feed object.
*/
- public function getFeedEditObject($feed_url = NULL, array $values = array()) {
+ public function getFeedEditObject($feed_url = NULL, array $values = []) {
$feed_name = $this->randomMachineName(10);
if (!$feed_url) {
- $feed_url = \Drupal::url('view.frontpage.feed_1', array(
- 'query' => array('feed' => $feed_name),
+ $feed_url = \Drupal::url('view.frontpage.feed_1', [
+ 'query' => ['feed' => $feed_name],
'absolute' => TRUE,
- ));
+ ]);
}
- $values += array(
+ $values += [
'title' => $feed_name,
'url' => $feed_url,
'refresh' => '900',
- );
+ ];
return Feed::create($values);
}
@@ -165,7 +165,7 @@ abstract class AggregatorTestBase extends BrowserTestBase {
public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
// First, let's ensure we can get to the rss xml.
$this->drupalGet($feed->getUrl());
- $this->assertResponse(200, format_string(':url is reachable.', array(':url' => $feed->getUrl())));
+ $this->assertResponse(200, format_string(':url is reachable.', [':url' => $feed->getUrl()]));
// Attempt to access the update link directly without an access token.
$this->drupalGet('admin/config/services/aggregator/update/' . $feed->id());
@@ -176,15 +176,15 @@ abstract class AggregatorTestBase extends BrowserTestBase {
$this->clickLink('Update items');
// Ensure we have the right number of items.
- $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()));
- $feed->items = array();
+ $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()]);
+ $feed->items = [];
foreach ($result as $item) {
$feed->items[] = $item->iid;
}
if ($expected_count !== NULL) {
$feed->item_count = count($feed->items);
- $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', array('@val1' => $expected_count, '@val2' => $feed->item_count)));
+ $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', ['@val1' => $expected_count, '@val2' => $feed->item_count]));
}
}
@@ -195,8 +195,8 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* Feed object representing the feed.
*/
public function deleteFeedItems(FeedInterface $feed) {
- $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), array(), t('Delete items'));
- $this->assertRaw(t('The news items from %title have been deleted.', array('%title' => $feed->label())), 'Feed items deleted.');
+ $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], t('Delete items'));
+ $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]), 'Feed items deleted.');
}
/**
@@ -209,10 +209,10 @@ abstract class AggregatorTestBase extends BrowserTestBase {
*/
public function updateAndDelete(FeedInterface $feed, $expected_count) {
$this->updateFeedItems($feed, $expected_count);
- $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
+ $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$this->assertTrue($count);
$this->deleteFeedItems($feed);
- $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
+ $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$this->assertTrue($count == 0);
}
@@ -228,7 +228,7 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* TRUE if feed is unique.
*/
public function uniqueFeed($feed_name, $feed_url) {
- $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed_name, ':url' => $feed_url))->fetchField();
+ $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $feed_name, ':url' => $feed_url])->fetchField();
return (1 == $result);
}
@@ -355,7 +355,7 @@ EOF;
public function createSampleNodes($count = 5) {
// Post $count article nodes.
for ($i = 0; $i < $count; $i++) {
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/article', $edit, t('Save'));
@@ -369,10 +369,10 @@ EOF;
$this->config('aggregator.settings')
->set('fetcher', 'aggregator_test_fetcher')
->set('parser', 'aggregator_test_parser')
- ->set('processors', array(
+ ->set('processors', [
'aggregator_test_processor' => 'aggregator_test_processor',
'aggregator' => 'aggregator',
- ))
+ ])
->save();
}
diff --git a/core/modules/aggregator/tests/src/Functional/DeleteFeedItemTest.php b/core/modules/aggregator/tests/src/Functional/DeleteFeedItemTest.php
index 95202b813cb..a8527f6b1c6 100644
--- a/core/modules/aggregator/tests/src/Functional/DeleteFeedItemTest.php
+++ b/core/modules/aggregator/tests/src/Functional/DeleteFeedItemTest.php
@@ -13,15 +13,15 @@ class DeleteFeedItemTest extends AggregatorTestBase {
*/
public function testDeleteFeedItem() {
// Create a bunch of test feeds.
- $feed_urls = array();
+ $feed_urls = [];
// No last-modified, no etag.
- $feed_urls[] = \Drupal::url('aggregator_test.feed', array(), array('absolute' => TRUE));
+ $feed_urls[] = \Drupal::url('aggregator_test.feed', [], ['absolute' => TRUE]);
// Last-modified, but no etag.
- $feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 1), array('absolute' => TRUE));
+ $feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 1], ['absolute' => TRUE]);
// No Last-modified, but etag.
- $feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 0, 'use_etag' => 1), array('absolute' => TRUE));
+ $feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 0, 'use_etag' => 1], ['absolute' => TRUE]);
// Last-modified and etag.
- $feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 1, 'use_etag' => 1), array('absolute' => TRUE));
+ $feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 1, 'use_etag' => 1], ['absolute' => TRUE]);
foreach ($feed_urls as $feed_url) {
$feed = $this->createFeed($feed_url);
diff --git a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php
index 5bf5bd3eefc..7d756962815 100644
--- a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php
@@ -14,7 +14,7 @@ class DeleteFeedTest extends AggregatorTestBase {
*
* @var array
*/
- public static $modules = array('block');
+ public static $modules = ['block'];
/**
* Deletes a feed and ensures that all of its services are deleted.
@@ -43,7 +43,7 @@ class DeleteFeedTest extends AggregatorTestBase {
$this->assertResponse(404, 'Deleted feed source does not exists.');
// Check database for feed.
- $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed1->label(), ':url' => $feed1->getUrl()))->fetchField();
+ $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $feed1->label(), ':url' => $feed1->getUrl()])->fetchField();
$this->assertFalse($result, 'Feed not found in database');
}
diff --git a/core/modules/aggregator/tests/src/Functional/FeedCacheTagsTest.php b/core/modules/aggregator/tests/src/Functional/FeedCacheTagsTest.php
index 1a307201370..dc0aab9263e 100644
--- a/core/modules/aggregator/tests/src/Functional/FeedCacheTagsTest.php
+++ b/core/modules/aggregator/tests/src/Functional/FeedCacheTagsTest.php
@@ -17,7 +17,7 @@ class FeedCacheTagsTest extends EntityWithUriCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('aggregator');
+ public static $modules = ['aggregator'];
/**
* {@inheritdoc}
@@ -37,13 +37,13 @@ class FeedCacheTagsTest extends EntityWithUriCacheTagsTestBase {
*/
protected function createEntity() {
// Create a "Llama" feed.
- $feed = Feed::create(array(
+ $feed = Feed::create([
'title' => 'Llama',
'url' => 'https://www.drupal.org/',
'refresh' => 900,
'checked' => 1389919932,
'description' => 'Drupal.org',
- ));
+ ]);
$feed->save();
return $feed;
diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
index 00c7b70492f..ecb2e50c76e 100644
--- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
+++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
@@ -30,7 +30,7 @@ class FeedParserTest extends AggregatorTestBase {
$feed = $this->createFeed($this->getRSS091Sample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
+ $this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()]));
$this->assertText('First example feed item title');
$this->assertLinkByHref('http://example.com/example-turns-one');
$this->assertText('First example feed item description.');
@@ -53,19 +53,19 @@ class FeedParserTest extends AggregatorTestBase {
$feed = $this->createFeed($this->getAtomSample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
+ $this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()]));
$this->assertText('Atom-Powered Robots Run Amok');
$this->assertLinkByHref('http://example.org/2003/12/13/atom03');
$this->assertText('Some text.');
- $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', array(':link' => 'http://example.org/2003/12/13/atom03'))->fetchField(), 'Atom entry id element is parsed correctly.');
+ $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', [':link' => 'http://example.org/2003/12/13/atom03'])->fetchField(), 'Atom entry id element is parsed correctly.');
// Check for second feed entry.
$this->assertText('We tried to stop them, but we failed.');
$this->assertLinkByHref('http://example.org/2003/12/14/atom03');
$this->assertText('Some other text.');
- $db_guid = db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', array(
+ $db_guid = db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', [
':link' => 'http://example.org/2003/12/14/atom03',
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-bbbb-80da344efa6a', $db_guid, 'Atom entry id element is parsed correctly.');
}
@@ -76,7 +76,7 @@ class FeedParserTest extends AggregatorTestBase {
$feed = $this->createFeed($this->getHtmlEntitiesSample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
+ $this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()]));
$this->assertRaw("Quote&quot; Amp&amp;");
}
@@ -85,12 +85,12 @@ class FeedParserTest extends AggregatorTestBase {
*/
public function testRedirectFeed() {
$redirect_url = Url::fromRoute('aggregator_test.redirect')->setAbsolute()->toString();
- $feed = Feed::create(array('url' => $redirect_url, 'title' => $this->randomMachineName()));
+ $feed = Feed::create(['url' => $redirect_url, 'title' => $this->randomMachineName()]);
$feed->save();
$feed->refreshItems();
// Make sure that the feed URL was updated correctly.
- $this->assertEqual($feed->getUrl(), \Drupal::url('aggregator_test.feed', array(), array('absolute' => TRUE)));
+ $this->assertEqual($feed->getUrl(), \Drupal::url('aggregator_test.feed', [], ['absolute' => TRUE]));
}
/**
@@ -99,13 +99,13 @@ class FeedParserTest extends AggregatorTestBase {
public function testInvalidFeed() {
// Simulate a typo in the URL to force a curl exception.
$invalid_url = 'http:/www.drupal.org';
- $feed = Feed::create(array('url' => $invalid_url, 'title' => $this->randomMachineName()));
+ $feed = Feed::create(['url' => $invalid_url, 'title' => $this->randomMachineName()]);
$feed->save();
// Update the feed. Use the UI to be able to check the message easily.
$this->drupalGet('admin/config/services/aggregator');
$this->clickLink(t('Update items'));
- $this->assertRaw(t('The feed from %title seems to be broken because of error', array('%title' => $feed->label())));
+ $this->assertRaw(t('The feed from %title seems to be broken because of error', ['%title' => $feed->label()]));
}
}
diff --git a/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php b/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php
index 5527d956132..bdc63f56b0b 100644
--- a/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php
+++ b/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php
@@ -45,7 +45,7 @@ class FeedProcessorPluginTest extends AggregatorTestBase {
$description = $feed->description->value ?: '';
$this->updateAndDelete($feed, NULL);
// Make sure the feed title is changed.
- $entities = entity_load_multiple_by_properties('aggregator_feed', array('description' => $description));
+ $entities = entity_load_multiple_by_properties('aggregator_feed', ['description' => $description]);
$this->assertTrue(empty($entities));
}
@@ -53,11 +53,11 @@ class FeedProcessorPluginTest extends AggregatorTestBase {
* Test post-processing functionality.
*/
public function testPostProcess() {
- $feed = $this->createFeed(NULL, array('refresh' => 1800));
+ $feed = $this->createFeed(NULL, ['refresh' => 1800]);
$this->updateFeedItems($feed);
$feed_id = $feed->id();
// Reset entity cache manually.
- \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache(array($feed_id));
+ \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache([$feed_id]);
// Reload the feed to get new values.
$feed = Feed::load($feed_id);
// Make sure its refresh rate doubled.
diff --git a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
index 8994e3fe875..2500b9ebb54 100644
--- a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
+++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
@@ -14,7 +14,7 @@ class ImportOpmlTest extends AggregatorTestBase {
*
* @var array
*/
- public static $modules = array('block', 'help');
+ public static $modules = ['block', 'help'];
/**
* {@inheritdoc}
@@ -22,7 +22,7 @@ class ImportOpmlTest extends AggregatorTestBase {
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds', 'create article content', 'administer blocks'));
+ $admin_user = $this->drupalCreateUser(['administer news feeds', 'access news feeds', 'create article content', 'administer blocks']);
$this->drupalLogin($admin_user);
}
@@ -31,7 +31,7 @@ class ImportOpmlTest extends AggregatorTestBase {
*/
public function openImportForm() {
// Enable the help block.
- $this->drupalPlaceBlock('help_block', array('region' => 'help'));
+ $this->drupalPlaceBlock('help_block', ['region' => 'help']);
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->assertText('A single OPML document may contain many feeds.', 'Found OPML help text.');
@@ -46,19 +46,19 @@ class ImportOpmlTest extends AggregatorTestBase {
public function validateImportFormFields() {
$before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if no fields are filled.');
$path = $this->getEmptyOpml();
- $edit = array(
+ $edit = [
'files[upload]' => $path,
'remote' => file_create_url($path),
- );
+ ];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');
- $edit = array('remote' => 'invalidUrl://empty');
+ $edit = ['remote' => 'invalidUrl://empty'];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->assertText(t('The URL invalidUrl://empty is not valid.'), 'Error if the URL is invalid.');
@@ -76,7 +76,7 @@ class ImportOpmlTest extends AggregatorTestBase {
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import'));
$this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.');
- $edit = array('remote' => file_create_url($this->getEmptyOpml()));
+ $edit = ['remote' => file_create_url($this->getEmptyOpml())];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
$this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.');
@@ -88,13 +88,13 @@ class ImportOpmlTest extends AggregatorTestBase {
$feeds[0] = $this->getFeedEditArray();
$feeds[1] = $this->getFeedEditArray();
$feeds[2] = $this->getFeedEditArray();
- $edit = array(
+ $edit = [
'files[upload]' => $this->getValidOpml($feeds),
'refresh' => '900',
- );
+ ];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
- $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url[0][value]'])), 'Verifying that a duplicate URL was identified');
- $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title[0][value]'])), 'Verifying that a duplicate title was identified');
+ $this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]), 'Verifying that a duplicate URL was identified');
+ $this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]), 'Verifying that a duplicate title was identified');
$after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
$this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
diff --git a/core/modules/aggregator/tests/src/Functional/ItemCacheTagsTest.php b/core/modules/aggregator/tests/src/Functional/ItemCacheTagsTest.php
index 46b076cb296..09da3436827 100644
--- a/core/modules/aggregator/tests/src/Functional/ItemCacheTagsTest.php
+++ b/core/modules/aggregator/tests/src/Functional/ItemCacheTagsTest.php
@@ -19,7 +19,7 @@ class ItemCacheTagsTest extends EntityCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('aggregator');
+ public static $modules = ['aggregator'];
/**
* {@inheritdoc}
@@ -39,21 +39,21 @@ class ItemCacheTagsTest extends EntityCacheTagsTestBase {
*/
protected function createEntity() {
// Create a "Camelids" feed.
- $feed = Feed::create(array(
+ $feed = Feed::create([
'title' => 'Camelids',
'url' => 'https://groups.drupal.org/not_used/167169',
'refresh' => 900,
'checked' => 1389919932,
'description' => 'Drupal Core Group feed',
- ));
+ ]);
$feed->save();
// Create a "Llama" aggregator feed item.
- $item = Item::create(array(
+ $item = Item::create([
'fid' => $feed->id(),
'title' => t('Llama'),
'path' => 'https://www.drupal.org/',
- ));
+ ]);
$item->save();
return $item;
@@ -67,14 +67,14 @@ class ItemCacheTagsTest extends EntityCacheTagsTestBase {
\Drupal::cache('render')->set('foo', 'bar', CacheBackendInterface::CACHE_PERMANENT, $this->entity->getCacheTags());
// Verify a cache hit.
- $this->verifyRenderCache('foo', array('aggregator_feed:1'));
+ $this->verifyRenderCache('foo', ['aggregator_feed:1']);
// Now create a feed item in that feed.
- Item::create(array(
+ Item::create([
'fid' => $this->entity->getFeedId(),
'title' => t('Llama 2'),
'path' => 'https://groups.drupal.org/',
- ))->save();
+ ])->save();
// Verify a cache miss.
$this->assertFalse(\Drupal::cache('render')->get('foo'), 'Creating a new feed item invalidates the cache tag of the feed.');
diff --git a/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php b/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php
index 81a501e3ba9..d8804dd9c37 100644
--- a/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php
+++ b/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php
@@ -17,7 +17,7 @@ class FeedValidationTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('aggregator', 'options');
+ public static $modules = ['aggregator', 'options'];
/**
* {@inheritdoc}
diff --git a/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php b/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php
index d8f1b6f8761..280a103db8e 100644
--- a/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php
+++ b/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php
@@ -34,7 +34,7 @@ class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase {
$config = $this->config('aggregator.settings');
$this->assertIdentical('aggregator', $config->get('fetcher'));
$this->assertIdentical('aggregator', $config->get('parser'));
- $this->assertIdentical(array('aggregator'), $config->get('processors'));
+ $this->assertIdentical(['aggregator'], $config->get('processors'));
$this->assertIdentical(600, $config->get('items.teaser_length'));
$this->assertIdentical('<a> <b> <br /> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>', $config->get('items.allowed_html'));
$this->assertIdentical(9676800, $config->get('items.expire'));
diff --git a/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php b/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php
index a72da23c8b2..39f57b25188 100644
--- a/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php
+++ b/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php
@@ -21,14 +21,14 @@ class IntegrationTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user');
+ public static $modules = ['aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_aggregator_items');
+ public static $testViews = ['test_aggregator_items'];
/**
* The entity storage for aggregator items.
@@ -53,7 +53,7 @@ class IntegrationTest extends ViewsKernelTestBase {
$this->installEntitySchema('aggregator_item');
$this->installEntitySchema('aggregator_feed');
- ViewTestData::createTestViews(get_class($this), array('aggregator_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['aggregator_test_views']);
$this->itemStorage = $this->container->get('entity.manager')->getStorage('aggregator_item');
$this->feedStorage = $this->container->get('entity.manager')->getStorage('aggregator_feed');
@@ -66,19 +66,19 @@ class IntegrationTest extends ViewsKernelTestBase {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
- $feed = $this->feedStorage->create(array(
+ $feed = $this->feedStorage->create([
'title' => $this->randomMachineName(),
'url' => 'https://www.drupal.org/',
'refresh' => 900,
'checked' => 123543535,
'description' => $this->randomMachineName(),
- ));
+ ]);
$feed->save();
- $items = array();
- $expected = array();
+ $items = [];
+ $expected = [];
for ($i = 0; $i < 10; $i++) {
- $values = array();
+ $values = [];
$values['fid'] = $feed->id();
$values['timestamp'] = mt_rand(REQUEST_TIME - 10, REQUEST_TIME + 10);
$values['title'] = $this->randomMachineName();
@@ -99,13 +99,13 @@ class IntegrationTest extends ViewsKernelTestBase {
$view = Views::getView('test_aggregator_items');
$this->executeView($view);
- $column_map = array(
+ $column_map = [
'iid' => 'iid',
'title' => 'title',
'aggregator_item_timestamp' => 'timestamp',
'description' => 'description',
'aggregator_item_author' => 'author',
- );
+ ];
$this->assertIdenticalResultset($view, $expected, $column_map);
// Ensure that the rendering of the linked title works as expected.
diff --git a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
index c9f6906f66e..7a78ad9fb4e 100644
--- a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
+++ b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
@@ -15,7 +15,7 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->directoryList = array('aggregator' => 'core/modules/aggregator');
+ $this->directoryList = ['aggregator' => 'core/modules/aggregator'];
parent::setUp();
}
@@ -25,19 +25,19 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getAggregatorAdminRoutes
*/
public function testAggregatorAdminLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('aggregator.admin_overview', 'aggregator.admin_settings'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['aggregator.admin_overview', 'aggregator.admin_settings'],
+ ]);
}
/**
* Provides a list of routes to test.
*/
public function getAggregatorAdminRoutes() {
- return array(
- array('aggregator.admin_overview'),
- array('aggregator.admin_settings'),
- );
+ return [
+ ['aggregator.admin_overview'],
+ ['aggregator.admin_settings'],
+ ];
}
/**
@@ -46,9 +46,9 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getAggregatorSourceRoutes
*/
public function testAggregatorSourceLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'],
+ ]);
;
}
@@ -56,10 +56,10 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of source routes to test.
*/
public function getAggregatorSourceRoutes() {
- return array(
- array('entity.aggregator_feed.canonical'),
- array('entity.aggregator_feed.edit_form'),
- );
+ return [
+ ['entity.aggregator_feed.canonical'],
+ ['entity.aggregator_feed.edit_form'],
+ ];
}
}
diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
index 87a5d934329..926723702df 100644
--- a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
+++ b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
@@ -39,20 +39,20 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
*/
protected function setUp() {
$this->configFactory = $this->getConfigFactoryStub(
- array(
- 'aggregator.settings' => array(
- 'processors' => array('aggregator_test'),
- ),
- 'aggregator_test.settings' => array(),
- )
+ [
+ 'aggregator.settings' => [
+ 'processors' => ['aggregator_test'],
+ ],
+ 'aggregator_test.settings' => [],
+ ]
);
- foreach (array('fetcher', 'parser', 'processor') as $type) {
+ foreach (['fetcher', 'parser', 'processor'] as $type) {
$this->managers[$type] = $this->getMockBuilder('Drupal\aggregator\Plugin\AggregatorPluginManager')
->disableOriginalConstructor()
->getMock();
$this->managers[$type]->expects($this->once())
->method('getDefinitions')
- ->will($this->returnValue(array('aggregator_test' => array('title' => '', 'description' => ''))));
+ ->will($this->returnValue(['aggregator_test' => ['title' => '', 'description' => '']]));
}
$this->settingsForm = new SettingsForm(
@@ -79,8 +79,8 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
$test_processor = $this->getMock(
'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor',
- array('buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'),
- array(array(), 'aggregator_test', array('description' => ''), $this->configFactory)
+ ['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'],
+ [[], 'aggregator_test', ['description' => ''], $this->configFactory]
);
$test_processor->expects($this->at(0))
->method('buildConfigurationForm')
@@ -98,7 +98,7 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
->with($this->equalTo('aggregator_test'))
->will($this->returnValue($test_processor));
- $form = $this->settingsForm->buildForm(array(), $form_state);
+ $form = $this->settingsForm->buildForm([], $form_state);
$this->settingsForm->validateForm($form, $form_state);
$this->settingsForm->submitForm($form, $form_state);
}
diff --git a/core/modules/ban/ban.install b/core/modules/ban/ban.install
index b2ea1fe3d33..f3c003a91c3 100644
--- a/core/modules/ban/ban.install
+++ b/core/modules/ban/ban.install
@@ -9,27 +9,27 @@
* Implements hook_schema().
*/
function ban_schema() {
- $schema['ban_ip'] = array(
+ $schema['ban_ip'] = [
'description' => 'Stores banned IP addresses.',
- 'fields' => array(
- 'iid' => array(
+ 'fields' => [
+ 'iid' => [
'description' => 'Primary Key: unique ID for IP addresses.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'ip' => array(
+ ],
+ 'ip' => [
'description' => 'IP address',
'type' => 'varchar_ascii',
'length' => 40,
'not null' => TRUE,
'default' => '',
- ),
- ),
- 'indexes' => array(
- 'ip' => array('ip'),
- ),
- 'primary key' => array('iid'),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'ip' => ['ip'],
+ ],
+ 'primary key' => ['iid'],
+ ];
return $schema;
}
diff --git a/core/modules/ban/ban.module b/core/modules/ban/ban.module
index a1ee23803b4..b8b72c5035e 100644
--- a/core/modules/ban/ban.module
+++ b/core/modules/ban/ban.module
@@ -15,11 +15,11 @@ function ban_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.ban':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see the <a href=":url">online documentation for the Ban module</a>.', array(':url' => 'https://www.drupal.org/documentation/modules/ban')) . '</p>';
+ $output .= '<p>' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see the <a href=":url">online documentation for the Ban module</a>.', [':url' => 'https://www.drupal.org/documentation/modules/ban']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Banning IP addresses') . '</dt>';
- $output .= '<dd>' . t('Administrators can enter IP addresses to ban on the <a href=":bans">IP address bans</a> page.', array(':bans' => \Drupal::url('ban.admin_page'))) . '</dd>';
+ $output .= '<dd>' . t('Administrators can enter IP addresses to ban on the <a href=":bans">IP address bans</a> page.', [':bans' => \Drupal::url('ban.admin_page')]) . '</dd>';
$output .= '</dl>';
return $output;
diff --git a/core/modules/ban/src/BanIpManager.php b/core/modules/ban/src/BanIpManager.php
index a92731c288e..d354f7a71cb 100644
--- a/core/modules/ban/src/BanIpManager.php
+++ b/core/modules/ban/src/BanIpManager.php
@@ -30,7 +30,7 @@ class BanIpManager implements BanIpManagerInterface {
* {@inheritdoc}
*/
public function isBanned($ip) {
- return (bool) $this->connection->query("SELECT * FROM {ban_ip} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
+ return (bool) $this->connection->query("SELECT * FROM {ban_ip} WHERE ip = :ip", [':ip' => $ip])->fetchField();
}
/**
@@ -45,8 +45,8 @@ class BanIpManager implements BanIpManagerInterface {
*/
public function banIp($ip) {
$this->connection->merge('ban_ip')
- ->key(array('ip' => $ip))
- ->fields(array('ip' => $ip))
+ ->key(['ip' => $ip])
+ ->fields(['ip' => $ip])
->execute();
}
@@ -63,7 +63,7 @@ class BanIpManager implements BanIpManagerInterface {
* {@inheritdoc}
*/
public function findById($ban_id) {
- return $this->connection->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", array(':iid' => $ban_id))->fetchField();
+ return $this->connection->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", [':iid' => $ban_id])->fetchField();
}
}
diff --git a/core/modules/ban/src/Form/BanAdmin.php b/core/modules/ban/src/Form/BanAdmin.php
index a0c769fd476..731d06518c8 100644
--- a/core/modules/ban/src/Form/BanAdmin.php
+++ b/core/modules/ban/src/Form/BanAdmin.php
@@ -52,47 +52,47 @@ class BanAdmin extends FormBase {
* address form field.
*/
public function buildForm(array $form, FormStateInterface $form_state, $default_ip = '') {
- $rows = array();
- $header = array($this->t('banned IP addresses'), $this->t('Operations'));
+ $rows = [];
+ $header = [$this->t('banned IP addresses'), $this->t('Operations')];
$result = $this->ipManager->findAll();
foreach ($result as $ip) {
- $row = array();
+ $row = [];
$row[] = $ip->ip;
- $links = array();
- $links['delete'] = array(
+ $links = [];
+ $links['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('ban.delete', ['ban_id' => $ip->iid]),
- );
- $row[] = array(
- 'data' => array(
+ ];
+ $row[] = [
+ 'data' => [
'#type' => 'operations',
'#links' => $links,
- ),
- );
+ ],
+ ];
$rows[] = $row;
}
- $form['ip'] = array(
+ $form['ip'] = [
'#title' => $this->t('IP address'),
'#type' => 'textfield',
'#size' => 48,
'#maxlength' => 40,
'#default_value' => $default_ip,
'#description' => $this->t('Enter a valid IP address.'),
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ ];
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Add'),
- );
+ ];
- $form['ban_ip_banning_table'] = array(
+ $form['ban_ip_banning_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $this->t('No blocked IP addresses available.'),
'#weight' => 120,
- );
+ ];
return $form;
}
@@ -118,7 +118,7 @@ class BanAdmin extends FormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$ip = trim($form_state->getValue('ip'));
$this->ipManager->banIp($ip);
- drupal_set_message($this->t('The IP address %ip has been banned.', array('%ip' => $ip)));
+ drupal_set_message($this->t('The IP address %ip has been banned.', ['%ip' => $ip]));
$form_state->setRedirect('ban.admin_page');
}
diff --git a/core/modules/ban/src/Form/BanDelete.php b/core/modules/ban/src/Form/BanDelete.php
index a8a4962458e..3d14ca34153 100644
--- a/core/modules/ban/src/Form/BanDelete.php
+++ b/core/modules/ban/src/Form/BanDelete.php
@@ -58,7 +58,7 @@ class BanDelete extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to unblock %ip?', array('%ip' => $this->banIp));
+ return $this->t('Are you sure you want to unblock %ip?', ['%ip' => $this->banIp]);
}
/**
@@ -93,8 +93,8 @@ class BanDelete extends ConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->ipManager->unbanIp($this->banIp);
- $this->logger('user')->notice('Deleted %ip', array('%ip' => $this->banIp));
- drupal_set_message($this->t('The IP address %ip was deleted.', array('%ip' => $this->banIp)));
+ $this->logger('user')->notice('Deleted %ip', ['%ip' => $this->banIp]);
+ drupal_set_message($this->t('The IP address %ip was deleted.', ['%ip' => $this->banIp]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php
index 94135fd3f6f..7c570bb793c 100644
--- a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php
+++ b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php
@@ -76,7 +76,7 @@ class BlockedIP extends DestinationBase implements ContainerFactoryPluginInterfa
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$this->banManager->banIp($row->getDestinationProperty('ip'));
}
diff --git a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
index 9738915023a..0a155fb471b 100644
--- a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
+++ b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
@@ -18,55 +18,55 @@ class IpAddressBlockingTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('ban');
+ public static $modules = ['ban'];
/**
* Tests various user input to confirm correct validation and saving of data.
*/
function testIPAddressValidation() {
// Create user.
- $admin_user = $this->drupalCreateUser(array('ban IP addresses'));
+ $admin_user = $this->drupalCreateUser(['ban IP addresses']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/config/people/ban');
// Ban a valid IP address.
- $edit = array();
+ $edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
- $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField();
+ $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $edit['ip']])->fetchField();
$this->assertTrue($ip, 'IP address found in database.');
- $this->assertRaw(t('The IP address %ip has been banned.', array('%ip' => $edit['ip'])), 'IP address was banned.');
+ $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]), 'IP address was banned.');
// Try to block an IP address that's already blocked.
- $edit = array();
+ $edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('This IP address is already banned.'));
// Try to block a reserved IP address.
- $edit = array();
+ $edit = [];
$edit['ip'] = '255.255.255.255';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.'));
// Try to block a reserved IP address.
- $edit = array();
+ $edit = [];
$edit['ip'] = 'test.example.com';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.'));
// Submit an empty form.
- $edit = array();
+ $edit = [];
$edit['ip'] = '';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.'));
// Pass an IP address as a URL parameter and submit it.
$submit_ip = '1.2.3.4';
- $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, array(), t('Add'));
- $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", array(':ip' => $submit_ip))->fetchField();
+ $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, [], t('Add'));
+ $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $submit_ip])->fetchField();
$this->assertTrue($ip, 'IP address found in database');
- $this->assertRaw(t('The IP address %ip has been banned.', array('%ip' => $submit_ip)), 'IP address was banned.');
+ $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]), 'IP address was banned.');
// Submit your own IP address. This fails, although it works when testing
// manually.
@@ -85,7 +85,7 @@ class IpAddressBlockingTest extends BrowserTestBase {
$banIp->banIp($ip);
$banIp->banIp($ip);
$query = db_select('ban_ip', 'bip');
- $query->fields('bip', array('iid'));
+ $query->fields('bip', ['iid']);
$query->condition('bip.ip', $ip);
$ip_count = $query->execute()->fetchAll();
$this->assertEqual(1, count($ip_count));
@@ -93,7 +93,7 @@ class IpAddressBlockingTest extends BrowserTestBase {
$banIp->banIp($ip);
$banIp->banIp($ip);
$query = db_select('ban_ip', 'bip');
- $query->fields('bip', array('iid'));
+ $query->fields('bip', ['iid']);
$query->condition('bip.ip', $ip);
$ip_count = $query->execute()->fetchAll();
$this->assertEqual(1, count($ip_count));
diff --git a/core/modules/basic_auth/basic_auth.module b/core/modules/basic_auth/basic_auth.module
index ea64c5ba18e..7d1d01f6b69 100644
--- a/core/modules/basic_auth/basic_auth.module
+++ b/core/modules/basic_auth/basic_auth.module
@@ -15,7 +15,7 @@ function basic_auth_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.basic_auth':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The HTTP Basic Authentication module supplies an <a href="http://en.wikipedia.org/wiki/Basic_access_authentication">HTTP Basic authentication</a> provider for web service requests. This authentication provider authenticates requests using the HTTP Basic Authentication username and password, as an alternative to using Drupal\'s standard cookie-based authentication system. It is only useful if your site provides web services configured to use this type of authentication (for instance, the <a href=":rest_help">RESTful Web Services module</a>). For more information, see the <a href=":hba_do">online documentation for the HTTP Basic Authentication module</a>.', array(':hba_do' => 'https://www.drupal.org/documentation/modules/basic_auth', ':rest_help' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', array('name' => 'rest')) : '#')) . '</p>';
+ $output .= '<p>' . t('The HTTP Basic Authentication module supplies an <a href="http://en.wikipedia.org/wiki/Basic_access_authentication">HTTP Basic authentication</a> provider for web service requests. This authentication provider authenticates requests using the HTTP Basic Authentication username and password, as an alternative to using Drupal\'s standard cookie-based authentication system. It is only useful if your site provides web services configured to use this type of authentication (for instance, the <a href=":rest_help">RESTful Web Services module</a>). For more information, see the <a href=":hba_do">online documentation for the HTTP Basic Authentication module</a>.', [':hba_do' => 'https://www.drupal.org/documentation/modules/basic_auth', ':rest_help' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', ['name' => 'rest']) : '#']) . '</p>';
return $output;
}
}
diff --git a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
index eac482c8125..c72e3f0c016 100644
--- a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
+++ b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php
@@ -88,7 +88,7 @@ class BasicAuth implements AuthenticationProviderInterface, AuthenticationProvid
// in to many different user accounts. We have a reasonably high limit
// since there may be only one apparent IP for all users at an institution.
if ($this->flood->isAllowed('basic_auth.failed_login_ip', $flood_config->get('ip_limit'), $flood_config->get('ip_window'))) {
- $accounts = $this->entityManager->getStorage('user')->loadByProperties(array('name' => $username, 'status' => 1));
+ $accounts = $this->entityManager->getStorage('user')->loadByProperties(['name' => $username, 'status' => 1]);
$account = reset($accounts);
if ($account) {
if ($flood_config->get('uid_only')) {
@@ -127,9 +127,9 @@ class BasicAuth implements AuthenticationProviderInterface, AuthenticationProvid
*/
public function challengeException(Request $request, \Exception $previous) {
$site_name = $this->configFactory->get('system.site')->get('name');
- $challenge = SafeMarkup::format('Basic realm="@realm"', array(
+ $challenge = SafeMarkup::format('Basic realm="@realm"', [
'@realm' => !empty($site_name) ? $site_name : 'Access restricted',
- ));
+ ]);
return new UnauthorizedHttpException((string) $challenge, 'No authentication credentials provided.', $previous);
}
diff --git a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php
index 04bb0fdc998..45b9b356eb5 100644
--- a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php
+++ b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php
@@ -22,7 +22,7 @@ class BasicAuthTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('basic_auth', 'router_test', 'locale', 'basic_auth_test');
+ public static $modules = ['basic_auth', 'router_test', 'locale', 'basic_auth_test'];
/**
* Test http basic authentication.
@@ -55,7 +55,7 @@ class BasicAuthTest extends WebTestBase {
$this->drupalGet('admin');
$this->assertResponse('403', 'No authentication prompt for routes not explicitly defining authentication providers.');
- $account = $this->drupalCreateUser(array('access administration pages'));
+ $account = $this->drupalCreateUser(['access administration pages']);
$this->basicAuthGet(Url::fromRoute('system.admin'), $account->getUsername(), $account->pass_raw);
$this->assertNoLink('Log out', 'User is not logged in');
@@ -82,7 +82,7 @@ class BasicAuthTest extends WebTestBase {
->set('user_limit', 4000)
->save();
- $user = $this->drupalCreateUser(array());
+ $user = $this->drupalCreateUser([]);
$incorrect_user = clone $user;
$incorrect_user->pass_raw .= 'incorrect';
$url = Url::fromRoute('router_test.11');
@@ -107,10 +107,10 @@ class BasicAuthTest extends WebTestBase {
->set('user_limit', 2)
->save();
- $user = $this->drupalCreateUser(array());
+ $user = $this->drupalCreateUser([]);
$incorrect_user = clone $user;
$incorrect_user->pass_raw .= 'incorrect';
- $user2 = $this->drupalCreateUser(array());
+ $user2 = $this->drupalCreateUser([]);
$url = Url::fromRoute('router_test.11');
// Try a failed login.
diff --git a/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php b/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php
index b5766fb64a6..8a289b0037e 100644
--- a/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php
+++ b/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php
@@ -51,7 +51,7 @@ trait BasicAuthTestTrait {
*
* @see \Drupal\simpletest\WebTestBase::drupalPostForm()
*/
- protected function basicAuthPostForm($path, $edit, $submit, $username, $password, array $options = array(), $form_html_id = NULL, $extra_post = NULL) {
+ protected function basicAuthPostForm($path, $edit, $submit, $username, $password, array $options = [], $form_html_id = NULL, $extra_post = NULL) {
return $this->drupalPostForm($path, $edit, $submit, $options, $this->getBasicAuthHeaders($username, $password), $form_html_id, $extra_post);
}
diff --git a/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php b/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php
index ccb15b737cc..c56ee327871 100644
--- a/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php
+++ b/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php
@@ -20,14 +20,14 @@ class BigPipeTestForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#token'] = FALSE;
- $form['big_pipe'] = array(
+ $form['big_pipe'] = [
'#type' => 'checkboxes',
'#title' => $this->t('BigPipe works…'),
'#options' => [
'js' => $this->t('… with JavaScript'),
'nojs' => $this->t('… without JavaScript'),
],
- );
+ ];
return $form;
}
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 7e39da40068..ee6a4a11ea5 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -18,24 +18,24 @@ use Drupal\block\Entity\Block;
function block_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.block':
- $block_content = \Drupal::moduleHandler()->moduleExists('block_content') ? \Drupal::url('help.page', array('name' => 'block_content')) : '#';
+ $block_content = \Drupal::moduleHandler()->moduleExists('block_content') ? \Drupal::url('help.page', ['name' => 'block_content']) : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Block module allows you to place blocks in regions of your installed themes, and configure block settings. For more information, see the <a href=":blocks-documentation">online documentation for the Block module</a>.', array(':blocks-documentation' => 'https://www.drupal.org/documentation/modules/block/')) . '</p>';
+ $output .= '<p>' . t('The Block module allows you to place blocks in regions of your installed themes, and configure block settings. For more information, see the <a href=":blocks-documentation">online documentation for the Block module</a>.', [':blocks-documentation' => 'https://www.drupal.org/documentation/modules/block/']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Placing and moving blocks') . '</dt>';
- $output .= '<dd>' . t('You can place a new block in a region by selecting <em>Place block</em> on the <a href=":blocks">Block layout page</a>. Once a block is placed, it can be moved to a different region by drag-and-drop or by using the <em>Region</em> drop-down list, and then clicking <em>Save blocks</em>.', array(':blocks' => \Drupal::url('block.admin_display'))) . '</dd>';
+ $output .= '<dd>' . t('You can place a new block in a region by selecting <em>Place block</em> on the <a href=":blocks">Block layout page</a>. Once a block is placed, it can be moved to a different region by drag-and-drop or by using the <em>Region</em> drop-down list, and then clicking <em>Save blocks</em>.', [':blocks' => \Drupal::url('block.admin_display')]) . '</dd>';
$output .= '<dt>' . t('Toggling between different themes') . '</dt>';
$output .= '<dd>' . t('Blocks are placed and configured specifically for each theme. The Block layout page opens with the default theme, but you can toggle to other installed themes.') . '</dd>';
$output .= '<dt>' . t('Demonstrating block regions for a theme') . '</dt>';
- $output .= '<dd>' . t('You can see where the regions are for the current theme by clicking the <em>Demonstrate block regions</em> link on the <a href=":blocks">Block layout page</a>. Regions are specific to each theme.', array(':blocks' => \Drupal::url('block.admin_display'))) . '</dd>';
+ $output .= '<dd>' . t('You can see where the regions are for the current theme by clicking the <em>Demonstrate block regions</em> link on the <a href=":blocks">Block layout page</a>. Regions are specific to each theme.', [':blocks' => \Drupal::url('block.admin_display')]) . '</dd>';
$output .= '<dt>' . t('Configuring block settings') . '</dt>';
- $output .= '<dd>' . t('To change the settings of an individual block click on the <em>Configure</em> link on the <a href=":blocks">Block layout page</a>. The available options vary depending on the module that provides the block. For all blocks you can change the block title and toggle whether to display it.', array(':blocks' => Drupal::url('block.admin_display'))) . '</dd>';
+ $output .= '<dd>' . t('To change the settings of an individual block click on the <em>Configure</em> link on the <a href=":blocks">Block layout page</a>. The available options vary depending on the module that provides the block. For all blocks you can change the block title and toggle whether to display it.', [':blocks' => Drupal::url('block.admin_display')]) . '</dd>';
$output .= '<dt>' . t('Controlling visibility') . '</dt>';
$output .= '<dd>' . t('You can control the visibility of a block by restricting it to specific pages, content types, and/or roles by setting the appropriate options under <em>Visibility settings</em> of the block configuration.') . '</dd>';
$output .= '<dt>' . t('Adding custom blocks') . '</dt>';
- $output .= '<dd>' . t('You can add custom blocks, if the <em>Custom Block</em> module is installed. For more information, see the <a href=":blockcontent-help">Custom Block help page</a>.', array(':blockcontent-help' => $block_content)) . '</dd>';
+ $output .= '<dd>' . t('You can add custom blocks, if the <em>Custom Block</em> module is installed. For more information, see the <a href=":blockcontent-help">Custom Block help page</a>.', [':blockcontent-help' => $block_content]) . '</dd>';
$output .= '</dl>';
return $output;
}
@@ -43,7 +43,7 @@ function block_help($route_name, RouteMatchInterface $route_match) {
$demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default');
$themes = \Drupal::service('theme_handler')->listInfo();
$output = '<p>' . t('Block placement is specific to each theme on your site. Changes will not be saved until you click <em>Save blocks</em> at the bottom of the page.') . '</p>';
- $output .= '<p>' . \Drupal::l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), new Url('block.admin_demo', array('theme' => $demo_theme))) . '</p>';
+ $output .= '<p>' . \Drupal::l(t('Demonstrate block regions (@theme)', ['@theme' => $themes[$demo_theme]->info['name']]), new Url('block.admin_demo', ['theme' => $demo_theme])) . '</p>';
return $output;
}
}
@@ -52,11 +52,11 @@ function block_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function block_theme() {
- return array(
- 'block' => array(
+ return [
+ 'block' => [
'render element' => 'elements',
- ),
- );
+ ],
+ ];
}
/**
@@ -65,12 +65,12 @@ function block_theme() {
function block_page_top(array &$page_top) {
if (\Drupal::routeMatch()->getRouteName() === 'block.admin_demo') {
$theme = \Drupal::theme()->getActiveTheme()->getName();
- $page_top['backlink'] = array(
+ $page_top['backlink'] = [
'#type' => 'link',
'#title' => t('Exit block region demonstration'),
- '#options' => array('attributes' => array('class' => array('block-demo-backlink'))),
+ '#options' => ['attributes' => ['class' => ['block-demo-backlink']]],
'#weight' => -10,
- );
+ ];
if (\Drupal::config('system.theme')->get('default') == $theme) {
$page_top['backlink']['#url'] = Url::fromRoute('block.admin_display');
}
@@ -108,12 +108,12 @@ function block_themes_installed($theme_list) {
*/
function block_theme_initialize($theme) {
// Initialize theme's blocks if none already registered.
- $has_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $theme));
+ $has_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $theme]);
if (!$has_blocks) {
$default_theme = \Drupal::config('system.theme')->get('default');
// Apply only to new theme's visible regions.
$regions = system_region_list($theme, REGIONS_VISIBLE);
- $default_theme_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $default_theme));
+ $default_theme_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $default_theme]);
foreach ($default_theme_blocks as $default_theme_block_id => $default_theme_block) {
if (strpos($default_theme_block_id, $default_theme . '_') === 0) {
$id = str_replace($default_theme, $theme, $default_theme_block_id);
@@ -161,7 +161,7 @@ function block_rebuild() {
* Implements hook_theme_suggestions_HOOK().
*/
function block_theme_suggestions_block(array $variables) {
- $suggestions = array();
+ $suggestions = [];
$suggestions[] = 'block__' . $variables['elements']['#configuration']['provider'];
// Hyphens (-) and underscores (_) play a special role in theme suggestions.
diff --git a/core/modules/block/block.post_update.php b/core/modules/block/block.post_update.php
index d3544e8bd64..bd0a67c7d8a 100644
--- a/core/modules/block/block.post_update.php
+++ b/core/modules/block/block.post_update.php
@@ -63,10 +63,10 @@ function block_post_update_disable_blocks_with_missing_contexts() {
$message = t('Encountered an unknown context mapping key coming probably from a contributed or custom module: One or more mappings could not be updated. Please manually review your visibility settings for the following blocks, which are disabled now:');
$message .= '<ul>';
foreach ($blocks as $disabled_block_id => $disabled_block) {
- $message .= '<li>' . t('@label (Visibility: @plugin_ids)', array(
+ $message .= '<li>' . t('@label (Visibility: @plugin_ids)', [
'@label' => $disabled_block->get('settings')['label'],
'@plugin_ids' => implode(', ', array_intersect_key($condition_plugin_id_label_map, array_flip(array_keys($block_update_8001[$disabled_block_id]['missing_context_ids']))))
- )) . '</li>';
+ ]) . '</li>';
}
$message .= '</ul>';
diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php
index 42dfbc3b2f6..b2d180aa467 100644
--- a/core/modules/block/src/BlockForm.php
+++ b/core/modules/block/src/BlockForm.php
@@ -140,57 +140,57 @@ class BlockForm extends EntityForm {
$form['visibility'] = $this->buildVisibilityInterface([], $form_state);
// If creating a new block, calculate a safe default machine name.
- $form['id'] = array(
+ $form['id'] = [
'#type' => 'machine_name',
'#maxlength' => 64,
'#description' => $this->t('A unique name for this block instance. Must be alpha-numeric and underscore separated.'),
'#default_value' => !$entity->isNew() ? $entity->id() : $this->getUniqueMachineName($entity),
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\block\Entity\Block::load',
'replace_pattern' => '[^a-z0-9_.]+',
- 'source' => array('settings', 'label'),
- ),
+ 'source' => ['settings', 'label'],
+ ],
'#required' => TRUE,
'#disabled' => !$entity->isNew(),
- );
+ ];
// Theme settings.
if ($entity->getTheme()) {
- $form['theme'] = array(
+ $form['theme'] = [
'#type' => 'value',
'#value' => $theme,
- );
+ ];
}
else {
- $theme_options = array();
+ $theme_options = [];
foreach ($this->themeHandler->listInfo() as $theme_name => $theme_info) {
if (!empty($theme_info->status)) {
$theme_options[$theme_name] = $theme_info->info['name'];
}
}
- $form['theme'] = array(
+ $form['theme'] = [
'#type' => 'select',
'#options' => $theme_options,
'#title' => t('Theme'),
'#default_value' => $theme,
- '#ajax' => array(
+ '#ajax' => [
'callback' => '::themeSwitch',
'wrapper' => 'edit-block-region-wrapper',
- ),
- );
+ ],
+ ];
}
// Hidden weight setting.
$weight = $entity->isNew() ? $this->getRequest()->query->get('weight', 0) : $entity->getWeight();
- $form['weight'] = array(
+ $form['weight'] = [
'#type' => 'hidden',
'#default_value' => $weight,
- );
+ ];
// Region settings.
$entity_region = $entity->getRegion();
$region = $entity->isNew() ? $this->getRequest()->query->get('region', $entity_region) : $entity_region;
- $form['region'] = array(
+ $form['region'] = [
'#type' => 'select',
'#title' => $this->t('Region'),
'#description' => $this->t('Select the region where this block should be displayed.'),
@@ -199,7 +199,7 @@ class BlockForm extends EntityForm {
'#options' => system_region_list($theme, REGIONS_VISIBLE),
'#prefix' => '<div id="edit-block-region-wrapper">',
'#suffix' => '</div>',
- );
+ ];
$form['#attached']['library'][] = 'block/drupal.block.admin';
return $form;
}
@@ -360,10 +360,10 @@ class BlockForm extends EntityForm {
drupal_set_message($this->t('The block configuration has been saved.'));
$form_state->setRedirect(
'block.admin_display_theme',
- array(
+ [
'theme' => $form_state->getValue('theme'),
- ),
- array('query' => array('block-placement' => Html::getClass($this->entity->id())))
+ ],
+ ['query' => ['block-placement' => Html::getClass($this->entity->id())]]
);
}
diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php
index 6e5c968b6c5..37b2e8bfc34 100644
--- a/core/modules/block/src/BlockListBuilder.php
+++ b/core/modules/block/src/BlockListBuilder.php
@@ -125,15 +125,15 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
// Build the form tree.
$form['blocks'] = $this->buildBlocksForm();
- $form['actions'] = array(
+ $form['actions'] = [
'#tree' => FALSE,
'#type' => 'actions',
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save blocks'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -150,29 +150,29 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
/** @var \Drupal\block\BlockInterface[] $entities */
foreach ($entities as $entity_id => $entity) {
$definition = $entity->getPlugin()->getPluginDefinition();
- $blocks[$entity->getRegion()][$entity_id] = array(
+ $blocks[$entity->getRegion()][$entity_id] = [
'label' => $entity->label(),
'entity_id' => $entity_id,
'weight' => $entity->getWeight(),
'entity' => $entity,
'category' => $definition['category'],
'status' => $entity->status(),
- );
+ ];
}
- $form = array(
+ $form = [
'#type' => 'table',
- '#header' => array(
+ '#header' => [
$this->t('Block'),
$this->t('Category'),
$this->t('Region'),
$this->t('Weight'),
$this->t('Operations'),
- ),
- '#attributes' => array(
+ ],
+ '#attributes' => [
'id' => 'blocks',
- ),
- );
+ ],
+ ];
// Weights range from -delta to +delta, so delta should be at least half
// of the amount of blocks present. This makes sure all blocks in the same
@@ -188,39 +188,39 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
// Loop over each region and build blocks.
$regions = $this->systemRegionList($this->getThemeName(), REGIONS_VISIBLE);
foreach ($regions as $region => $title) {
- $form['#tabledrag'][] = array(
+ $form['#tabledrag'][] = [
'action' => 'match',
'relationship' => 'sibling',
'group' => 'block-region-select',
'subgroup' => 'block-region-' . $region,
'hidden' => FALSE,
- );
- $form['#tabledrag'][] = array(
+ ];
+ $form['#tabledrag'][] = [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'block-weight',
'subgroup' => 'block-weight-' . $region,
- );
+ ];
- $form['region-' . $region] = array(
- '#attributes' => array(
- 'class' => array('region-title', 'region-title-' . $region),
+ $form['region-' . $region] = [
+ '#attributes' => [
+ 'class' => ['region-title', 'region-title-' . $region],
'no_striping' => TRUE,
- ),
- );
- $form['region-' . $region]['title'] = array(
- '#theme_wrappers' => array(
- 'container' => array(
- '#attributes' => array('class' => 'region-title__action'),
- )
- ),
+ ],
+ ];
+ $form['region-' . $region]['title'] = [
+ '#theme_wrappers' => [
+ 'container' => [
+ '#attributes' => ['class' => 'region-title__action'],
+ ]
+ ],
'#prefix' => $title,
'#type' => 'link',
'#title' => $this->t('Place block <span class="visually-hidden">in the %region region</span>', ['%region' => $title]),
'#url' => Url::fromRoute('block.admin_library', ['theme' => $this->getThemeName()], ['query' => ['region' => $region]]),
- '#wrapper_attributes' => array(
+ '#wrapper_attributes' => [
'colspan' => 5,
- ),
+ ],
'#attributes' => [
'class' => ['use-ajax', 'button', 'button--small'],
'data-dialog-type' => 'modal',
@@ -228,74 +228,74 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
'width' => 700,
]),
],
- );
+ ];
- $form['region-' . $region . '-message'] = array(
- '#attributes' => array(
- 'class' => array(
+ $form['region-' . $region . '-message'] = [
+ '#attributes' => [
+ 'class' => [
'region-message',
'region-' . $region . '-message',
empty($blocks[$region]) ? 'region-empty' : 'region-populated',
- ),
- ),
- );
- $form['region-' . $region . '-message']['message'] = array(
+ ],
+ ],
+ ];
+ $form['region-' . $region . '-message']['message'] = [
'#markup' => '<em>' . $this->t('No blocks in this region') . '</em>',
- '#wrapper_attributes' => array(
+ '#wrapper_attributes' => [
'colspan' => 5,
- ),
- );
+ ],
+ ];
if (isset($blocks[$region])) {
foreach ($blocks[$region] as $info) {
$entity_id = $info['entity_id'];
- $form[$entity_id] = array(
- '#attributes' => array(
- 'class' => array('draggable'),
- ),
- );
+ $form[$entity_id] = [
+ '#attributes' => [
+ 'class' => ['draggable'],
+ ],
+ ];
$form[$entity_id]['#attributes']['class'][] = $info['status'] ? 'block-enabled' : 'block-disabled';
if ($placement && $placement == Html::getClass($entity_id)) {
$form[$entity_id]['#attributes']['class'][] = 'color-success';
$form[$entity_id]['#attributes']['class'][] = 'js-block-placed';
}
- $form[$entity_id]['info'] = array(
+ $form[$entity_id]['info'] = [
'#plain_text' => $info['status'] ? $info['label'] : $this->t('@label (disabled)', ['@label' => $info['label']]),
- '#wrapper_attributes' => array(
- 'class' => array('block'),
- ),
- );
- $form[$entity_id]['type'] = array(
+ '#wrapper_attributes' => [
+ 'class' => ['block'],
+ ],
+ ];
+ $form[$entity_id]['type'] = [
'#markup' => $info['category'],
- );
- $form[$entity_id]['region-theme']['region'] = array(
+ ];
+ $form[$entity_id]['region-theme']['region'] = [
'#type' => 'select',
'#default_value' => $region,
'#required' => TRUE,
- '#title' => $this->t('Region for @block block', array('@block' => $info['label'])),
+ '#title' => $this->t('Region for @block block', ['@block' => $info['label']]),
'#title_display' => 'invisible',
'#options' => $regions,
- '#attributes' => array(
- 'class' => array('block-region-select', 'block-region-' . $region),
- ),
- '#parents' => array('blocks', $entity_id, 'region'),
- );
- $form[$entity_id]['region-theme']['theme'] = array(
+ '#attributes' => [
+ 'class' => ['block-region-select', 'block-region-' . $region],
+ ],
+ '#parents' => ['blocks', $entity_id, 'region'],
+ ];
+ $form[$entity_id]['region-theme']['theme'] = [
'#type' => 'hidden',
'#value' => $this->getThemeName(),
- '#parents' => array('blocks', $entity_id, 'theme'),
- );
- $form[$entity_id]['weight'] = array(
+ '#parents' => ['blocks', $entity_id, 'theme'],
+ ];
+ $form[$entity_id]['weight'] = [
'#type' => 'weight',
'#default_value' => $info['weight'],
'#delta' => $weight_delta,
- '#title' => $this->t('Weight for @block block', array('@block' => $info['label'])),
+ '#title' => $this->t('Weight for @block block', ['@block' => $info['label']]),
'#title_display' => 'invisible',
- '#attributes' => array(
- 'class' => array('block-weight', 'block-weight-' . $region),
- ),
- );
+ '#attributes' => [
+ 'class' => ['block-weight', 'block-weight-' . $region],
+ ],
+ ];
$form[$entity_id]['operations'] = $this->buildOperations($info['entity']);
}
}
@@ -362,7 +362,7 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
$entities = $this->storage->loadMultiple(array_keys($form_state->getValue('blocks')));
/** @var \Drupal\block\BlockInterface[] $entities */
foreach ($entities as $entity_id => $entity) {
- $entity_values = $form_state->getValue(array('blocks', $entity_id));
+ $entity_values = $form_state->getValue(['blocks', $entity_id]);
$entity->setWeight($entity_values['weight']);
$entity->setRegion($entity_values['region']);
$entity->save();
diff --git a/core/modules/block/src/BlockRepository.php b/core/modules/block/src/BlockRepository.php
index 53620a09f16..4cdd71071d6 100644
--- a/core/modules/block/src/BlockRepository.php
+++ b/core/modules/block/src/BlockRepository.php
@@ -48,10 +48,10 @@ class BlockRepository implements BlockRepositoryInterface {
public function getVisibleBlocksPerRegion(array &$cacheable_metadata = []) {
$active_theme = $this->themeManager->getActiveTheme();
// Build an array of the region names in the right order.
- $empty = array_fill_keys($active_theme->getRegions(), array());
+ $empty = array_fill_keys($active_theme->getRegions(), []);
- $full = array();
- foreach ($this->blockStorage->loadByProperties(array('theme' => $active_theme->getName())) as $block_id => $block) {
+ $full = [];
+ foreach ($this->blockStorage->loadByProperties(['theme' => $active_theme->getName()]) as $block_id => $block) {
/** @var \Drupal\block\BlockInterface $block */
$access = $block->access('view', NULL, TRUE);
$region = $block->getRegion();
diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php
index d3f501bd7a0..3b20d7b25ca 100644
--- a/core/modules/block/src/BlockViewBuilder.php
+++ b/core/modules/block/src/BlockViewBuilder.php
@@ -68,16 +68,16 @@ class BlockViewBuilder extends EntityViewBuilder {
* {@inheritdoc}
*/
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
- $build = $this->viewMultiple(array($entity), $view_mode, $langcode);
+ $build = $this->viewMultiple([$entity], $view_mode, $langcode);
return reset($build);
}
/**
* {@inheritdoc}
*/
- public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
+ public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) {
/** @var \Drupal\block\BlockInterface[] $entities */
- $build = array();
+ $build = [];
foreach ($entities as $entity) {
$entity_id = $entity->id();
$plugin = $entity->getPlugin();
@@ -87,7 +87,7 @@ class BlockViewBuilder extends EntityViewBuilder {
// Create the render array for the block as a whole.
// @see template_preprocess_block().
- $build[$entity_id] = array(
+ $build[$entity_id] = [
'#cache' => [
'keys' => ['entity_view', 'block', $entity->id()],
'contexts' => Cache::mergeContexts(
@@ -98,7 +98,7 @@ class BlockViewBuilder extends EntityViewBuilder {
'max-age' => $plugin->getCacheMaxAge(),
],
'#weight' => $entity->getWeight(),
- );
+ ];
// Allow altering of cacheability metadata or setting #create_placeholder.
$this->moduleHandler->alter(['block_build', "block_build_" . $plugin->getBaseId()], $build[$entity_id], $plugin);
@@ -216,7 +216,7 @@ class BlockViewBuilder extends EntityViewBuilder {
// #contextual_links is information about the *entire* block. Therefore,
// we must move these properties from $content and merge them into the
// top-level element.
- foreach (array('#attributes', '#contextual_links') as $property) {
+ foreach (['#attributes', '#contextual_links'] as $property) {
if (isset($content[$property])) {
$build[$property] += $content[$property];
unset($content[$property]);
@@ -231,10 +231,10 @@ class BlockViewBuilder extends EntityViewBuilder {
// render cached, so we can avoid the work of having to repeatedly
// determine whether the block is empty. For instance, modifying or adding
// entities could cause the block to no longer be empty.
- $build = array(
+ $build = [
'#markup' => '',
'#cache' => $build['#cache'],
- );
+ ];
// If $content is not empty, then it contains cacheability metadata, and
// we must merge it with the existing cacheability metadata. This allows
// blocks to be empty, yet still bubble cacheability metadata, to indicate
diff --git a/core/modules/block/src/Controller/BlockAddController.php b/core/modules/block/src/Controller/BlockAddController.php
index f983763fcc2..973a85995e0 100644
--- a/core/modules/block/src/Controller/BlockAddController.php
+++ b/core/modules/block/src/Controller/BlockAddController.php
@@ -22,7 +22,7 @@ class BlockAddController extends ControllerBase {
*/
public function blockAddConfigureForm($plugin_id, $theme) {
// Create a block entity.
- $entity = $this->entityManager()->getStorage('block')->create(array('plugin' => $plugin_id, 'theme' => $theme));
+ $entity = $this->entityManager()->getStorage('block')->create(['plugin' => $plugin_id, 'theme' => $theme]);
return $this->entityFormBuilder()->getForm($entity);
}
diff --git a/core/modules/block/src/Controller/BlockController.php b/core/modules/block/src/Controller/BlockController.php
index 58417d515f4..7398ff98e12 100644
--- a/core/modules/block/src/Controller/BlockController.php
+++ b/core/modules/block/src/Controller/BlockController.php
@@ -74,7 +74,7 @@ class BlockController extends ControllerBase {
$page = [
'#title' => Html::escape($this->themeHandler->getName($theme)),
'#type' => 'page',
- '#attached' => array(
+ '#attached' => [
'drupalSettings' => [
// The block demonstration page is not marked as an administrative
// page by \Drupal::service('router.admin_context')->isAdminRoute()
@@ -83,20 +83,20 @@ class BlockController extends ControllerBase {
// is an actual administrative page.
'path' => ['currentPathIsAdmin' => TRUE],
],
- 'library' => array(
+ 'library' => [
'block/drupal.block.admin',
- ),
- ),
+ ],
+ ],
];
// Show descriptions in each visible page region, nothing else.
$visible_regions = $this->getVisibleRegionNames($theme);
foreach (array_keys($visible_regions) as $region) {
- $page[$region]['block_description'] = array(
+ $page[$region]['block_description'] = [
'#type' => 'inline_template',
'#template' => '<div class="block-region demo-block">{{ region_name }}</div>',
- '#context' => array('region_name' => $visible_regions[$region]),
- );
+ '#context' => ['region_name' => $visible_regions[$region]],
+ ];
}
return $page;
diff --git a/core/modules/block/src/Controller/CategoryAutocompleteController.php b/core/modules/block/src/Controller/CategoryAutocompleteController.php
index a856670f6c4..c95fd477e82 100644
--- a/core/modules/block/src/Controller/CategoryAutocompleteController.php
+++ b/core/modules/block/src/Controller/CategoryAutocompleteController.php
@@ -51,10 +51,10 @@ class CategoryAutocompleteController implements ContainerInjectionInterface {
*/
public function autocomplete(Request $request) {
$typed_category = $request->query->get('q');
- $matches = array();
+ $matches = [];
foreach ($this->blockManager->getCategories() as $category) {
if (stripos($category, $typed_category) === 0) {
- $matches[] = array('value' => $category, 'label' => Html::escape($category));
+ $matches[] = ['value' => $category, 'label' => Html::escape($category)];
}
}
return new JsonResponse($matches);
diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php
index 63b52054333..a0bbd25c889 100644
--- a/core/modules/block/src/Entity/Block.php
+++ b/core/modules/block/src/Entity/Block.php
@@ -66,7 +66,7 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin
*
* @var array
*/
- protected $settings = array();
+ protected $settings = [];
/**
* The region this block is placed in.
diff --git a/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php b/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php
index 2c85587d27f..5faf8b870ac 100644
--- a/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php
+++ b/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php
@@ -27,7 +27,7 @@ class BlockPageDisplayVariantSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = array('onSelectPageDisplayVariant');
+ $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = ['onSelectPageDisplayVariant'];
return $events;
}
diff --git a/core/modules/block/src/Form/BlockDeleteForm.php b/core/modules/block/src/Form/BlockDeleteForm.php
index 63cdb922589..5209b329bf1 100644
--- a/core/modules/block/src/Form/BlockDeleteForm.php
+++ b/core/modules/block/src/Form/BlockDeleteForm.php
@@ -28,10 +28,10 @@ class BlockDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to remove the @entity-type %label?', array(
+ return $this->t('Are you sure you want to remove the @entity-type %label?', [
'@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(),
'%label' => $this->getEntity()->label(),
- ));
+ ]);
}
/**
@@ -39,10 +39,10 @@ class BlockDeleteForm extends EntityDeleteForm {
*/
protected function getDeletionMessage() {
$entity = $this->getEntity();
- return $this->t('The @entity-type %label has been removed.', array(
+ return $this->t('The @entity-type %label has been removed.', [
'@entity-type' => $entity->getEntityType()->getLowercaseLabel(),
'%label' => $entity->label(),
- ));
+ ]);
}
}
diff --git a/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php b/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php
index 74da932003e..927cb6133fe 100644
--- a/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php
+++ b/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php
@@ -48,7 +48,7 @@ class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface {
if ($this->themeHandler->hasUi($theme_name)) {
$this->derivatives[$theme_name] = $base_plugin_definition;
$this->derivatives[$theme_name]['title'] = $theme->info['name'];
- $this->derivatives[$theme_name]['route_parameters'] = array('theme' => $theme_name);
+ $this->derivatives[$theme_name]['route_parameters'] = ['theme' => $theme_name];
}
// Default task!
if ($default_theme == $theme_name) {
diff --git a/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php b/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php
index c904a377af4..537b16073ed 100644
--- a/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php
+++ b/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php
@@ -17,10 +17,10 @@ class EntityBlock extends EntityConfigBase {
*/
protected function getEntityId(Row $row) {
// Try to find the block by its plugin ID and theme.
- $properties = array(
+ $properties = [
'plugin' => $row->getDestinationProperty('plugin'),
'theme' => $row->getDestinationProperty('theme'),
- );
+ ];
$blocks = array_keys($this->storage->loadByProperties($properties));
return reset($blocks);
}
diff --git a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php
index cd4bce57e31..08525674e34 100644
--- a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php
+++ b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php
@@ -47,12 +47,12 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
$entity_manager = $container->get('entity.manager');
- $migration_configuration = array(
- 'migration' => array(
+ $migration_configuration = [
+ 'migration' => [
'd6_custom_block',
'd7_custom_block',
- ),
- );
+ ],
+ ];
return new static(
$configuration,
$plugin_id,
diff --git a/core/modules/block/src/Plugin/migrate/process/BlockRegion.php b/core/modules/block/src/Plugin/migrate/process/BlockRegion.php
index 8aba3ee84cb..0eb984fd20c 100644
--- a/core/modules/block/src/Plugin/migrate/process/BlockRegion.php
+++ b/core/modules/block/src/Plugin/migrate/process/BlockRegion.php
@@ -43,7 +43,7 @@ class BlockRegion extends StaticMap implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- $regions = array();
+ $regions = [];
foreach ($container->get('theme_handler')->listInfo() as $key => $theme) {
$regions[$key] = $theme->info['regions'];
}
diff --git a/core/modules/block/src/Plugin/migrate/process/BlockSettings.php b/core/modules/block/src/Plugin/migrate/process/BlockSettings.php
index 9f11be852b3..68e8f186ba2 100644
--- a/core/modules/block/src/Plugin/migrate/process/BlockSettings.php
+++ b/core/modules/block/src/Plugin/migrate/process/BlockSettings.php
@@ -21,7 +21,7 @@ class BlockSettings extends ProcessPluginBase {
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($plugin, $delta, $old_settings, $title) = $value;
- $settings = array();
+ $settings = [];
$settings['label'] = $title;
if ($title) {
$settings['label_display'] = BlockPluginInterface::BLOCK_LABEL_VISIBLE;
diff --git a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php
index e38d60be995..88607912541 100644
--- a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php
+++ b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php
@@ -59,12 +59,12 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
- $migration_configuration = array(
- 'migration' => array(
+ $migration_configuration = [
+ 'migration' => [
'd6_user_role',
'd7_user_role',
- ),
- );
+ ],
+ ];
return new static(
$configuration,
$plugin_id,
@@ -80,18 +80,18 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($old_visibility, $pages, $roles) = $value;
- $visibility = array();
+ $visibility = [];
// If the block is assigned to specific roles, add the user_role condition.
if ($roles) {
- $visibility['user_role'] = array(
+ $visibility['user_role'] = [
'id' => 'user_role',
- 'roles' => array(),
- 'context_mapping' => array(
+ 'roles' => [],
+ 'context_mapping' => [
'user' => '@user.current_user_context:current_user',
- ),
+ ],
'negate' => FALSE,
- );
+ ];
foreach ($roles as $key => $role_id) {
$roles[$key] = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property);
@@ -104,12 +104,12 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi
if ($old_visibility == 2) {
// If the PHP module is present, migrate the visibility code unaltered.
if ($this->moduleHandler->moduleExists('php')) {
- $visibility['php'] = array(
+ $visibility['php'] = [
'id' => 'php',
// PHP code visibility could not be negated in Drupal 6 or 7.
'negate' => FALSE,
'php' => $pages,
- );
+ ];
}
// Skip the row if we're configured to. If not, we don't need to do
// anything else -- the block will simply have no PHP or request_path
@@ -123,11 +123,11 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi
foreach ($paths as $key => $path) {
$paths[$key] = $path === '<front>' ? $path : '/' . ltrim($path, '/');
}
- $visibility['request_path'] = array(
+ $visibility['request_path'] = [
'id' => 'request_path',
'negate' => !$old_visibility,
'pages' => implode("\n", $paths),
- );
+ ];
}
}
diff --git a/core/modules/block/src/Plugin/migrate/source/Block.php b/core/modules/block/src/Plugin/migrate/source/Block.php
index b69128369a8..df4c0e9e194 100644
--- a/core/modules/block/src/Plugin/migrate/source/Block.php
+++ b/core/modules/block/src/Plugin/migrate/source/Block.php
@@ -81,7 +81,7 @@ class Block extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'bid' => $this->t('The block numeric identifier.'),
'module' => $this->t('The module providing the block.'),
'delta' => $this->t('The block\'s delta.'),
@@ -93,7 +93,7 @@ class Block extends DrupalSqlBase {
'pages' => $this->t('Pages list.'),
'title' => $this->t('Block title.'),
'cache' => $this->t('Cache rule.'),
- );
+ ];
}
/**
@@ -117,7 +117,7 @@ class Block extends DrupalSqlBase {
$delta = $row->getSourceProperty('delta');
$query = $this->select($this->blockRoleTable, 'br')
- ->fields('br', array('rid'))
+ ->fields('br', ['rid'])
->condition('module', $module)
->condition('delta', $delta);
$query->join($this->userRoleTable, 'ur', 'br.rid = ur.rid');
@@ -125,7 +125,7 @@ class Block extends DrupalSqlBase {
->fetchCol();
$row->setSourceProperty('roles', $roles);
- $settings = array();
+ $settings = [];
switch ($module) {
case 'aggregator':
list($type, $id) = explode('-', $delta);
@@ -152,7 +152,7 @@ class Block extends DrupalSqlBase {
$settings['forum']['block_num'] = $this->variableGet('forum_block_num_' . $delta, 5);
break;
case 'statistics':
- foreach (array('statistics_block_top_day_num', 'statistics_block_top_all_num', 'statistics_block_top_last_num') as $name) {
+ foreach (['statistics_block_top_day_num', 'statistics_block_top_all_num', 'statistics_block_top_last_num'] as $name) {
$settings['statistics'][$name] = $this->variableGet($name, 0);
}
break;
diff --git a/core/modules/block/src/Tests/BlockAdminThemeTest.php b/core/modules/block/src/Tests/BlockAdminThemeTest.php
index ab444d5e34d..7736e05362d 100644
--- a/core/modules/block/src/Tests/BlockAdminThemeTest.php
+++ b/core/modules/block/src/Tests/BlockAdminThemeTest.php
@@ -16,14 +16,14 @@ class BlockAdminThemeTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'contextual');
+ public static $modules = ['block', 'contextual'];
/**
* Check for the accessibility of the admin theme on the block admin page.
*/
function testAdminTheme() {
// Create administrative user.
- $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
+ $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$this->drupalLogin($admin_user);
// Ensure that access to block admin page is denied when theme is not
@@ -32,7 +32,7 @@ class BlockAdminThemeTest extends WebTestBase {
$this->assertResponse(403);
// Install admin theme and confirm that tab is accessible.
- \Drupal::service('theme_handler')->install(array('bartik'));
+ \Drupal::service('theme_handler')->install(['bartik']);
$edit['admin_theme'] = 'bartik';
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('admin/structure/block/list/bartik');
diff --git a/core/modules/block/src/Tests/BlockLanguageCacheTest.php b/core/modules/block/src/Tests/BlockLanguageCacheTest.php
index fd5871e3a1b..269536d9ce1 100644
--- a/core/modules/block/src/Tests/BlockLanguageCacheTest.php
+++ b/core/modules/block/src/Tests/BlockLanguageCacheTest.php
@@ -18,25 +18,25 @@ class BlockLanguageCacheTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'language', 'menu_ui');
+ public static $modules = ['block', 'language', 'menu_ui'];
/**
* List of langcodes.
*
* @var array
*/
- protected $langcodes = array();
+ protected $langcodes = [];
protected function setUp() {
parent::setUp();
// Create test languages.
- $this->langcodes = array(ConfigurableLanguage::load('en'));
+ $this->langcodes = [ConfigurableLanguage::load('en')];
for ($i = 1; $i < 3; ++$i) {
- $language = ConfigurableLanguage::create(array(
+ $language = ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this->randomString(),
- ));
+ ]);
$language->save();
$this->langcodes[$i] = $language;
}
@@ -47,16 +47,16 @@ class BlockLanguageCacheTest extends WebTestBase {
*/
public function testBlockLinks() {
// Create admin user to be able to access block admin.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer blocks',
'access administration pages',
'administer menu',
- ));
+ ]);
$this->drupalLogin($admin_user);
// Create the block cache for all languages.
foreach ($this->langcodes as $langcode) {
- $this->drupalGet('admin/structure/block', array('language' => $langcode));
+ $this->drupalGet('admin/structure/block', ['language' => $langcode]);
$this->clickLinkPartialName('Place block');
}
@@ -64,11 +64,11 @@ class BlockLanguageCacheTest extends WebTestBase {
$edit['label'] = $this->randomMachineName();
$edit['id'] = Unicode::strtolower($edit['label']);
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
- $this->assertText(t('Menu @label has been added.', array('@label' => $edit['label'])));
+ $this->assertText(t('Menu @label has been added.', ['@label' => $edit['label']]));
// Check that the block is listed for all languages.
foreach ($this->langcodes as $langcode) {
- $this->drupalGet('admin/structure/block', array('language' => $langcode));
+ $this->drupalGet('admin/structure/block', ['language' => $langcode]);
$this->clickLinkPartialName('Place block');
$this->assertText($edit['label']);
}
diff --git a/core/modules/block/src/Tests/BlockRenderOrderTest.php b/core/modules/block/src/Tests/BlockRenderOrderTest.php
index faf667ed805..d74a90afc47 100644
--- a/core/modules/block/src/Tests/BlockRenderOrderTest.php
+++ b/core/modules/block/src/Tests/BlockRenderOrderTest.php
@@ -17,14 +17,14 @@ class BlockRenderOrderTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'block');
+ public static $modules = ['node', 'block'];
protected function setUp() {
parent::setUp();
// Create a test user.
- $end_user = $this->drupalCreateUser(array(
+ $end_user = $this->drupalCreateUser([
'access content',
- ));
+ ]);
$this->drupalLogin($end_user);
}
@@ -34,32 +34,32 @@ class BlockRenderOrderTest extends WebTestBase {
function testBlockRenderOrder() {
// Enable test blocks and place them in the same region.
$region = 'header';
- $test_blocks = array(
- 'stark_powered' => array(
+ $test_blocks = [
+ 'stark_powered' => [
'weight' => '-3',
'id' => 'stark_powered',
'label' => 'Test block A',
- ),
- 'stark_by' => array(
+ ],
+ 'stark_by' => [
'weight' => '3',
'id' => 'stark_by',
'label' => 'Test block C',
- ),
- 'stark_drupal' => array(
+ ],
+ 'stark_drupal' => [
'weight' => '3',
'id' => 'stark_drupal',
'label' => 'Test block B',
- ),
- );
+ ],
+ ];
// Place the test blocks.
foreach ($test_blocks as $test_block) {
- $this->drupalPlaceBlock('system_powered_by_block', array(
+ $this->drupalPlaceBlock('system_powered_by_block', [
'label' => $test_block['label'],
'region' => $region,
'weight' => $test_block['weight'],
'id' => $test_block['id'],
- ));
+ ]);
}
$this->drupalGet('');
diff --git a/core/modules/block/src/Tests/BlockSystemBrandingTest.php b/core/modules/block/src/Tests/BlockSystemBrandingTest.php
index f3dfa3cdb42..b5025e80177 100644
--- a/core/modules/block/src/Tests/BlockSystemBrandingTest.php
+++ b/core/modules/block/src/Tests/BlockSystemBrandingTest.php
@@ -14,7 +14,7 @@ class BlockSystemBrandingTest extends BlockTestBase {
*
* @var array
*/
- public static $modules = array('block', 'system');
+ public static $modules = ['block', 'system'];
/**
* {@inheritdoc}
@@ -26,7 +26,7 @@ class BlockSystemBrandingTest extends BlockTestBase {
->set('slogan', 'Community plumbing')
->save();
// Add the system branding block to the page.
- $this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'site-branding'));
+ $this->drupalPlaceBlock('system_branding_block', ['region' => 'header', 'id' => 'site-branding']);
}
/**
diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php
index 57f46476445..e6066c4fd27 100644
--- a/core/modules/block/src/Tests/BlockTest.php
+++ b/core/modules/block/src/Tests/BlockTest.php
@@ -24,12 +24,12 @@ class BlockTest extends BlockTestBase {
$title = $this->randomMachineName(8);
// Enable a standard block.
$default_theme = $this->config('system.theme')->get('default');
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName(8)),
'region' => 'sidebar_first',
'settings[label]' => $title,
'settings[label_display]' => TRUE,
- );
+ ];
// Set the block to be hidden on any user path, and to be shown only to
// authenticated users.
$edit['visibility[request_path][pages]'] = '/user*';
@@ -69,11 +69,11 @@ class BlockTest extends BlockTestBase {
$title = $this->randomMachineName(8);
// Enable a standard block.
$default_theme = $this->config('system.theme')->get('default');
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName(8)),
'region' => 'sidebar_first',
'settings[label]' => $title,
- );
+ ];
$block_id = $edit['id'];
// Set the block to be shown only to authenticated users.
$edit['visibility[user_role][roles][' . RoleInterface::AUTHENTICATED_ID . ']'] = TRUE;
@@ -105,12 +105,12 @@ class BlockTest extends BlockTestBase {
$title = $this->randomMachineName(8);
// Enable a standard block.
$default_theme = $this->config('system.theme')->get('default');
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName(8)),
'region' => 'sidebar_first',
'settings[label]' => $title,
'visibility[request_path][negate]' => TRUE,
- );
+ ];
// Set the block to be hidden on any user path, and to be shown only to
// authenticated users.
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block'));
@@ -185,7 +185,7 @@ class BlockTest extends BlockTestBase {
$this->clickLink('Disable');
// Select the 'Powered by Drupal' block to be configured and moved.
- $block = array();
+ $block = [];
$block['id'] = 'system_powered_by_block';
$block['settings[label]'] = $this->randomMachineName(8);
$block['settings[label_display]'] = TRUE;
@@ -193,7 +193,7 @@ class BlockTest extends BlockTestBase {
$block['region'] = 'header';
// Set block title to confirm that interface works and override any custom titles.
- $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], 'id' => $block['id'], 'region' => $block['region']), t('Save block'));
+ $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], ['settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], 'id' => $block['id'], 'region' => $block['region']], t('Save block'));
$this->assertText(t('The block configuration has been saved.'), 'Block title set.');
// Check to see if the block was created by checking its configuration.
$instance = Block::load($block['id']);
@@ -217,23 +217,23 @@ class BlockTest extends BlockTestBase {
$this->assertNoText(t($block['settings[label]']));
// Check for <div id="block-my-block-instance-name"> if the machine name
// is my_block_instance_name.
- $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))));
+ $xpath = $this->buildXPathQuery('//div[@id=:id]/*', [':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))]);
$this->assertNoFieldByXPath($xpath, FALSE, 'Block found in no regions.');
// Test deleting the block from the edit form.
$this->drupalGet('admin/structure/block/manage/' . $block['id']);
$this->clickLink(t('Remove block'));
- $this->assertRaw(t('Are you sure you want to remove the block @name?', array('@name' => $block['settings[label]'])));
- $this->drupalPostForm(NULL, array(), t('Remove'));
- $this->assertRaw(t('The block %name has been removed.', array('%name' => $block['settings[label]'])));
+ $this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block['settings[label]']]));
+ $this->drupalPostForm(NULL, [], t('Remove'));
+ $this->assertRaw(t('The block %name has been removed.', ['%name' => $block['settings[label]']]));
// Test deleting a block via "Configure block" link.
$block = $this->drupalPlaceBlock('system_powered_by_block');
- $this->drupalGet('admin/structure/block/manage/' . $block->id(), array('query' => array('destination' => 'admin')));
+ $this->drupalGet('admin/structure/block/manage/' . $block->id(), ['query' => ['destination' => 'admin']]);
$this->clickLink(t('Remove block'));
- $this->assertRaw(t('Are you sure you want to remove the block @name?', array('@name' => $block->label())));
- $this->drupalPostForm(NULL, array(), t('Remove'));
- $this->assertRaw(t('The block %name has been removed.', array('%name' => $block->label())));
+ $this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block->label()]));
+ $this->drupalPostForm(NULL, [], t('Remove'));
+ $this->assertRaw(t('The block %name has been removed.', ['%name' => $block->label()]));
$this->assertUrl('admin');
$this->assertNoRaw($block->id());
}
@@ -249,7 +249,7 @@ class BlockTest extends BlockTestBase {
$this->drupalGet('admin/structure/block/list/' . $theme);
$this->assertTitle(t('Block layout') . ' | Drupal');
// Select the 'Powered by Drupal' block to be placed.
- $block = array();
+ $block = [];
$block['id'] = strtolower($this->randomMachineName());
$block['theme'] = $theme;
$block['region'] = 'content';
@@ -260,7 +260,7 @@ class BlockTest extends BlockTestBase {
// Set the default theme and ensure the block is placed.
$theme_settings->set('default', $theme)->save();
$this->drupalGet('');
- $elements = $this->xpath('//div[@id = :id]', array(':id' => Html::getUniqueId('block-' . $block['id'])));
+ $elements = $this->xpath('//div[@id = :id]', [':id' => Html::getUniqueId('block-' . $block['id'])]);
$this->assertTrue(!empty($elements), 'The block was found.');
}
}
@@ -270,11 +270,11 @@ class BlockTest extends BlockTestBase {
*/
function testThemeName() {
// Enable the help block.
- $this->drupalPlaceBlock('help_block', array('region' => 'help'));
+ $this->drupalPlaceBlock('help_block', ['region' => 'help']);
$this->drupalPlaceBlock('local_tasks_block');
// Explicitly set the default and admin themes.
$theme = 'block_test_specialchars_theme';
- \Drupal::service('theme_handler')->install(array($theme));
+ \Drupal::service('theme_handler')->install([$theme]);
\Drupal::service('router.builder')->rebuild();
$this->drupalGet('admin/structure/block');
$this->assertEscaped('<"Cat" & \'Mouse\'>');
@@ -292,20 +292,20 @@ class BlockTest extends BlockTestBase {
$id = strtolower($this->randomMachineName(8));
// Enable a standard block.
$default_theme = $this->config('system.theme')->get('default');
- $edit = array(
+ $edit = [
'id' => $id,
'region' => 'sidebar_first',
'settings[label]' => $title,
- );
+ ];
$this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block'));
$this->assertText('The block configuration has been saved.', 'Block was saved');
$this->drupalGet('user');
$this->assertNoText($title, 'Block title was not displayed by default.');
- $edit = array(
+ $edit = [
'settings[label_display]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/block/manage/' . $id, $edit, t('Save block'));
$this->assertText('The block configuration has been saved.', 'Block was saved');
@@ -330,24 +330,24 @@ class BlockTest extends BlockTestBase {
*/
function moveBlockToRegion(array $block, $region) {
// Set the created block to a specific region.
- $block += array('theme' => $this->config('system.theme')->get('default'));
- $edit = array();
+ $block += ['theme' => $this->config('system.theme')->get('default')];
+ $edit = [];
$edit['blocks[' . $block['id'] . '][region]'] = $region;
$this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
// Confirm that the block was moved to the proper region.
- $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region)));
+ $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', [ '%region_name' => $region]));
// Confirm that the block is being displayed.
$this->drupalGet('');
$this->assertText(t($block['settings[label]']), 'Block successfully being displayed on the page.');
// Confirm that the custom block was found at the proper region.
- $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array(
+ $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', [
':region-class' => 'region region-' . Html::getClass($region),
':block-id' => 'block-' . str_replace('_', '-', strtolower($block['id'])),
- ));
- $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', array('%region_name' => Html::getClass($region))));
+ ]);
+ $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', ['%region_name' => Html::getClass($region)]));
}
/**
@@ -367,7 +367,7 @@ class BlockTest extends BlockTestBase {
$config->save();
// Place the "Powered by Drupal" block.
- $block = $this->drupalPlaceBlock('system_powered_by_block', array('id' => 'powered'));
+ $block = $this->drupalPlaceBlock('system_powered_by_block', ['id' => 'powered']);
// Prime the page cache.
$this->drupalGet('<front>');
@@ -377,26 +377,26 @@ class BlockTest extends BlockTestBase {
// both the page and block caches.
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
- $cid_parts = array(\Drupal::url('<front>', array(), array('absolute' => TRUE)), 'html');
+ $cid_parts = [\Drupal::url('<front>', [], ['absolute' => TRUE]), 'html'];
$cid = implode(':', $cid_parts);
$cache_entry = \Drupal::cache('render')->get($cid);
- $expected_cache_tags = array(
+ $expected_cache_tags = [
'config:block_list',
'block_view',
'config:block.block.powered',
'config:user.role.anonymous',
'http_response',
'rendered',
- );
+ ];
sort($expected_cache_tags);
$keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys();
$this->assertIdentical($cache_entry->tags, $expected_cache_tags);
$cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys));
- $expected_cache_tags = array(
+ $expected_cache_tags = [
'block_view',
'config:block.block.powered',
'rendered',
- );
+ ];
sort($expected_cache_tags);
$this->assertIdentical($cache_entry->tags, $expected_cache_tags);
@@ -411,17 +411,17 @@ class BlockTest extends BlockTestBase {
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
// Place the "Powered by Drupal" block another time; verify a cache miss.
- $block_2 = $this->drupalPlaceBlock('system_powered_by_block', array('id' => 'powered-2'));
+ $block_2 = $this->drupalPlaceBlock('system_powered_by_block', ['id' => 'powered-2']);
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
// Verify a cache hit, but also the presence of the correct cache tags.
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
- $cid_parts = array(\Drupal::url('<front>', array(), array('absolute' => TRUE)), 'html');
+ $cid_parts = [\Drupal::url('<front>', [], ['absolute' => TRUE]), 'html'];
$cid = implode(':', $cid_parts);
$cache_entry = \Drupal::cache('render')->get($cid);
- $expected_cache_tags = array(
+ $expected_cache_tags = [
'config:block_list',
'block_view',
'config:block.block.powered',
@@ -429,23 +429,23 @@ class BlockTest extends BlockTestBase {
'config:user.role.anonymous',
'http_response',
'rendered',
- );
+ ];
sort($expected_cache_tags);
$this->assertEqual($cache_entry->tags, $expected_cache_tags);
- $expected_cache_tags = array(
+ $expected_cache_tags = [
'block_view',
'config:block.block.powered',
'rendered',
- );
+ ];
sort($expected_cache_tags);
$keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys();
$cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys));
$this->assertIdentical($cache_entry->tags, $expected_cache_tags);
- $expected_cache_tags = array(
+ $expected_cache_tags = [
'block_view',
'config:block.block.powered-2',
'rendered',
- );
+ ];
sort($expected_cache_tags);
$keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys();
$cache_entry = \Drupal::cache('render')->get('entity_view:block:powered-2:' . implode(':', $keys));
@@ -456,7 +456,7 @@ class BlockTest extends BlockTestBase {
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
// Delete the "Powered by Drupal" blocks; verify a cache miss.
- entity_delete_multiple('block', array('powered', 'powered-2'));
+ entity_delete_multiple('block', ['powered', 'powered-2']);
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
}
diff --git a/core/modules/block/src/Tests/BlockTestBase.php b/core/modules/block/src/Tests/BlockTestBase.php
index 970de5266ef..71f0ae6cffd 100644
--- a/core/modules/block/src/Tests/BlockTestBase.php
+++ b/core/modules/block/src/Tests/BlockTestBase.php
@@ -15,7 +15,7 @@ abstract class BlockTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'filter', 'test_page_test', 'help', 'block_test');
+ public static $modules = ['block', 'filter', 'test_page_test', 'help', 'block_test'];
/**
* A list of theme regions to test.
@@ -38,31 +38,31 @@ abstract class BlockTestBase extends WebTestBase {
$this->config('system.site')->set('page.front', '/test-page')->save();
// Create Full HTML text format.
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
- ));
+ ]);
$full_html_format->save();
// Create and log in an administrative user having access to the Full HTML
// text format.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer blocks',
$full_html_format->getPermissionName(),
'access administration pages',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
// Define the existing regions.
- $this->regions = array(
+ $this->regions = [
'header',
'sidebar_first',
'content',
'sidebar_second',
'footer',
- );
+ ];
$block_storage = $this->container->get('entity_type.manager')->getStorage('block');
- $blocks = $block_storage->loadByProperties(array('theme' => $this->config('system.theme')->get('default')));
+ $blocks = $block_storage->loadByProperties(['theme' => $this->config('system.theme')->get('default')]);
foreach ($blocks as $block) {
$block->delete();
}
diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php
index 65183cdce62..5f18ae162b2 100644
--- a/core/modules/block/src/Tests/BlockUiTest.php
+++ b/core/modules/block/src/Tests/BlockUiTest.php
@@ -17,7 +17,7 @@ class BlockUiTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test', 'help', 'condition_test');
+ public static $modules = ['block', 'block_test', 'help', 'condition_test'];
protected $regions;
@@ -43,30 +43,30 @@ class BlockUiTest extends WebTestBase {
protected function setUp() {
parent::setUp();
// Create and log in an administrative user.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer blocks',
'access administration pages',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
// Enable some test blocks.
- $this->blockValues = array(
- array(
+ $this->blockValues = [
+ [
'label' => 'Tools',
'tr' => '5',
'plugin_id' => 'system_menu_block:tools',
- 'settings' => array('region' => 'sidebar_second', 'id' => 'tools'),
+ 'settings' => ['region' => 'sidebar_second', 'id' => 'tools'],
'test_weight' => '-1',
- ),
- array(
+ ],
+ [
'label' => 'Powered by Drupal',
'tr' => '16',
'plugin_id' => 'system_powered_by_block',
- 'settings' => array('region' => 'footer', 'id' => 'powered'),
+ 'settings' => ['region' => 'footer', 'id' => 'powered'],
'test_weight' => '0',
- ),
- );
- $this->blocks = array();
+ ],
+ ];
+ $this->blocks = [];
foreach ($this->blockValues as $values) {
$this->blocks[] = $this->drupalPlaceBlock($values['plugin_id'], $values['settings']);
}
@@ -76,13 +76,13 @@ class BlockUiTest extends WebTestBase {
* Test block demo page exists and functions correctly.
*/
public function testBlockDemoUiPage() {
- $this->drupalPlaceBlock('help_block', array('region' => 'help'));
+ $this->drupalPlaceBlock('help_block', ['region' => 'help']);
$this->drupalGet('admin/structure/block');
- $this->clickLink(t('Demonstrate block regions (@theme)', array('@theme' => 'Classy')));
- $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', array(':title' => 'Highlighted'));
+ $this->clickLink(t('Demonstrate block regions (@theme)', ['@theme' => 'Classy']));
+ $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', [':title' => 'Highlighted']);
$this->assertTrue(!empty($elements), 'Block demo regions are shown.');
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
$this->drupalGet('admin/structure/block/demo/test_theme');
$this->assertEscaped('<strong>Test theme</strong>');
@@ -163,11 +163,11 @@ class BlockUiTest extends WebTestBase {
* Tests the block categories on the listing page.
*/
public function testCandidateBlockList() {
- $arguments = array(
+ $arguments = [
':title' => 'Display message',
':category' => 'Block test',
':href' => 'admin/structure/block/add/test_block_instantiation/classy',
- );
+ ];
$pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]';
$this->drupalGet('admin/structure/block');
@@ -190,11 +190,11 @@ class BlockUiTest extends WebTestBase {
* Tests the behavior of unsatisfied context-aware blocks.
*/
public function testContextAwareUnsatisfiedBlocks() {
- $arguments = array(
+ $arguments = [
':category' => 'Block test',
':href' => 'admin/structure/block/add/test_context_aware_unsatisfied/classy',
':text' => 'Test context-aware unsatisfied block',
- );
+ ];
$this->drupalGet('admin/structure/block');
$this->clickLinkPartialName('Place block');
@@ -215,11 +215,11 @@ class BlockUiTest extends WebTestBase {
$this->assertNoRaw($expected_text);
$block_url = 'admin/structure/block/add/test_context_aware/classy';
- $arguments = array(
+ $arguments = [
':title' => 'Test context-aware block',
':category' => 'Block test',
':href' => $block_url,
- );
+ ];
$pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]';
$this->drupalGet('admin/structure/block');
@@ -282,7 +282,7 @@ class BlockUiTest extends WebTestBase {
*/
public function testBlockPlacementIndicator() {
// Select the 'Powered by Drupal' block to be placed.
- $block = array();
+ $block = [];
$block['id'] = strtolower($this->randomMachineName());
$block['theme'] = 'classy';
$block['region'] = 'content';
@@ -292,7 +292,7 @@ class BlockUiTest extends WebTestBase {
$this->assertUrl('admin/structure/block/list/classy?block-placement=' . Html::getClass($block['id']));
// Resaving the block page will remove the block indicator.
- $this->drupalPostForm(NULL, array(), t('Save blocks'));
+ $this->drupalPostForm(NULL, [], t('Save blocks'));
$this->assertUrl('admin/structure/block/list/classy');
}
diff --git a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php
index 218832d6c82..9f3590c7fa5 100644
--- a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php
+++ b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php
@@ -16,7 +16,7 @@ class NonDefaultBlockAdminTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block');
+ public static $modules = ['block'];
/**
* {@inheritdoc}
@@ -31,10 +31,10 @@ class NonDefaultBlockAdminTest extends WebTestBase {
* Test non-default theme admin.
*/
function testNonDefaultBlockAdmin() {
- $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
+ $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$this->drupalLogin($admin_user);
$new_theme = 'bartik';
- \Drupal::service('theme_handler')->install(array($new_theme));
+ \Drupal::service('theme_handler')->install([$new_theme]);
$this->drupalGet('admin/structure/block/list/' . $new_theme);
$this->assertText('Bartik(' . t('active tab') . ')', 'Tab for non-default theme found.');
}
diff --git a/core/modules/block/src/Tests/Views/DisplayBlockTest.php b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
index 31f531cc22d..3d3584579ac 100644
--- a/core/modules/block/src/Tests/Views/DisplayBlockTest.php
+++ b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
@@ -26,19 +26,19 @@ class DisplayBlockTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'block_test_views', 'test_page_test', 'contextual', 'views_ui');
+ public static $modules = ['node', 'block_test_views', 'test_page_test', 'contextual', 'views_ui'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view_block', 'test_view_block2');
+ public static $testViews = ['test_view_block', 'test_view_block2'];
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('block_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['block_test_views']);
$this->enableViewsTestModule();
}
@@ -46,10 +46,10 @@ class DisplayBlockTest extends ViewTestBase {
* Tests default and custom block categories.
*/
public function testBlockCategory() {
- $this->drupalLogin($this->drupalCreateUser(array('administer views', 'administer blocks')));
+ $this->drupalLogin($this->drupalCreateUser(['administer views', 'administer blocks']));
// Create a new view in the UI.
- $edit = array();
+ $edit = [];
$edit['label'] = $this->randomString();
$edit['id'] = strtolower($this->randomMachineName());
$edit['show[wizard_key]'] = 'standard:views_test_data';
@@ -62,20 +62,20 @@ class DisplayBlockTest extends ViewTestBase {
// Test that the block was given a default category corresponding to its
// base table.
- $arguments = array(
- ':href' => \Drupal::Url('block.admin_add', array(
+ $arguments = [
+ ':href' => \Drupal::Url('block.admin_add', [
'plugin_id' => 'views_block:' . $edit['id'] . '-block_1',
'theme' => 'classy',
- )),
+ ]),
':category' => t('Lists (Views)'),
- );
+ ];
$this->drupalGet('admin/structure/block');
$this->clickLinkPartialName('Place block');
$elements = $this->xpath($pattern, $arguments);
$this->assertTrue(!empty($elements), 'The test block appears in the category for its base table.');
// Duplicate the block before changing the category.
- $this->drupalPostForm('admin/structure/views/view/' . $edit['id'] . '/edit/block_1', array(), t('Duplicate @display_title', array('@display_title' => 'Block')));
+ $this->drupalPostForm('admin/structure/views/view/' . $edit['id'] . '/edit/block_1', [], t('Duplicate @display_title', ['@display_title' => 'Block']));
$this->assertUrl('admin/structure/views/view/' . $edit['id'] . '/edit/block_2');
// Change the block category to a random string.
@@ -84,13 +84,13 @@ class DisplayBlockTest extends ViewTestBase {
$this->assertTrue(!empty($link));
$this->clickLink(t('Lists (Views)'));
$category = $this->randomString();
- $this->drupalPostForm(NULL, array('block_category' => $category), t('Apply'));
+ $this->drupalPostForm(NULL, ['block_category' => $category], t('Apply'));
// Duplicate the block after changing the category.
- $this->drupalPostForm(NULL, array(), t('Duplicate @display_title', array('@display_title' => 'Block')));
+ $this->drupalPostForm(NULL, [], t('Duplicate @display_title', ['@display_title' => 'Block']));
$this->assertUrl('admin/structure/views/view/' . $edit['id'] . '/edit/block_3');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Test that the blocks are listed under the correct categories.
$arguments[':category'] = $category;
@@ -99,23 +99,23 @@ class DisplayBlockTest extends ViewTestBase {
$elements = $this->xpath($pattern, $arguments);
$this->assertTrue(!empty($elements), 'The test block appears in the custom category.');
- $arguments = array(
- ':href' => \Drupal::Url('block.admin_add', array(
+ $arguments = [
+ ':href' => \Drupal::Url('block.admin_add', [
'plugin_id' => 'views_block:' . $edit['id'] . '-block_2',
'theme' => 'classy',
- )),
+ ]),
':category' => t('Lists (Views)'),
- );
+ ];
$elements = $this->xpath($pattern, $arguments);
$this->assertTrue(!empty($elements), 'The first duplicated test block remains in the original category.');
- $arguments = array(
- ':href' => \Drupal::Url('block.admin_add', array(
+ $arguments = [
+ ':href' => \Drupal::Url('block.admin_add', [
'plugin_id' => 'views_block:' . $edit['id'] . '-block_3',
'theme' => 'classy',
- )),
+ ]),
':category' => $category,
- );
+ ];
$elements = $this->xpath($pattern, $arguments);
$this->assertTrue(!empty($elements), 'The second duplicated test block appears in the custom category.');
}
@@ -126,13 +126,13 @@ class DisplayBlockTest extends ViewTestBase {
public function testDeleteBlockDisplay() {
// To test all combinations possible we first place create two instances
// of the block display of the first view.
- $block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1'));
- $block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:2'));
+ $block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1']);
+ $block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:2']);
// Then we add one instance of blocks for each of the two displays of the
// second view.
- $block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', array('label' => 'test_view_block2-block_1'));
- $block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', array('label' => 'test_view_block2-block_2'));
+ $block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', ['label' => 'test_view_block2-block_1']);
+ $block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', ['label' => 'test_view_block2-block_2']);
$this->drupalGet('test-page');
$this->assertBlockAppears($block_1);
@@ -177,7 +177,7 @@ class DisplayBlockTest extends ViewTestBase {
* Test the block form for a Views block.
*/
public function testViewsBlockForm() {
- $this->drupalLogin($this->drupalCreateUser(array('administer blocks')));
+ $this->drupalLogin($this->drupalCreateUser(['administer blocks']));
$default_theme = $this->config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme);
$elements = $this->xpath('//input[@name="label"]');
@@ -239,7 +239,7 @@ class DisplayBlockTest extends ViewTestBase {
*/
public function testBlockRendering() {
// Create a block and set a custom title.
- $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title'));
+ $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title']);
$this->drupalGet('');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
@@ -276,7 +276,7 @@ class DisplayBlockTest extends ViewTestBase {
$view = View::load('test_view_block');
$view->invalidateCaches();
- $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title'));
+ $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title']);
$this->drupalGet('');
$this->assertEqual(1, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
@@ -349,7 +349,7 @@ class DisplayBlockTest extends ViewTestBase {
* Tests the contextual links on a Views block.
*/
public function testBlockContextualLinks() {
- $this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links', 'administer blocks')));
+ $this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links', 'administer blocks']));
$block = $this->drupalPlaceBlock('views_block:test_view_block-block_1');
$cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1');
$this->drupalGet('test-page');
@@ -357,13 +357,13 @@ class DisplayBlockTest extends ViewTestBase {
$id = 'block:block=' . $block->id() . ':langcode=en|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1&langcode=en';
$cached_id = 'block:block=' . $cached_block->id() . ':langcode=en|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1&langcode=en';
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
- $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
- $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $cached_id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $cached_id)));
+ $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
+ $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $cached_id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $cached_id]));
// Get server-rendered contextual links.
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
- $post = array('ids[0]' => $id, 'ids[1]' => $cached_id);
- $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => 'test-page')));
+ $post = ['ids[0]' => $id, 'ids[1]' => $cached_id];
+ $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => 'test-page']]);
$this->assertResponse(200);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>');
diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php
index e5ad8daecc3..0d146390c51 100644
--- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php
+++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php
@@ -21,9 +21,9 @@ class TestBlockInstantiation extends BlockBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'display_message' => 'no message set',
- );
+ ];
}
/**
@@ -37,11 +37,11 @@ class TestBlockInstantiation extends BlockBase {
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state) {
- $form['display_message'] = array(
+ $form['display_message'] = [
'#type' => 'textfield',
'#title' => $this->t('Display message'),
'#default_value' => $this->configuration['display_message'],
- );
+ ];
return $form;
}
@@ -56,9 +56,9 @@ class TestBlockInstantiation extends BlockBase {
* {@inheritdoc}
*/
public function build() {
- return array(
+ return [
'#children' => $this->configuration['display_message'],
- );
+ ];
}
}
diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php
index b395b9266cc..5fec14ccc77 100644
--- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php
+++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php
@@ -20,7 +20,7 @@ class TestCacheBlock extends BlockBase {
public function build() {
$content = \Drupal::state()->get('block_test.content');
- $build = array();
+ $build = [];
if (!empty($content)) {
$build['#markup'] = $content;
}
diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
index bc7f20b256e..7db350da813 100644
--- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
+++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
@@ -25,11 +25,11 @@ class TestContextAwareBlock extends BlockBase {
public function build() {
/** @var $user \Drupal\user\UserInterface */
$user = $this->getContextValue('user');
- return array(
+ return [
'#prefix' => '<div id="' . $this->getPluginId() . '--username">',
'#suffix' => '</div>',
'#markup' => $user ? $user->getUsername() : 'No context mapping selected.' ,
- );
+ ];
}
/**
diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php
index de90af46128..35f08c4b041 100644
--- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php
+++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php
@@ -18,10 +18,10 @@ class TestHtmlBlock extends BlockBase {
* {@inheritdoc}
*/
public function build() {
- return array(
+ return [
'#attributes' => \Drupal::state()->get('block_test.attributes'),
'#children' => \Drupal::state()->get('block_test.content'),
- );
+ ];
}
}
diff --git a/core/modules/block/tests/src/Functional/BlockCacheTest.php b/core/modules/block/tests/src/Functional/BlockCacheTest.php
index 9285c644f04..4ea433f76a8 100644
--- a/core/modules/block/tests/src/Functional/BlockCacheTest.php
+++ b/core/modules/block/tests/src/Functional/BlockCacheTest.php
@@ -17,7 +17,7 @@ class BlockCacheTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test', 'test_page_test');
+ public static $modules = ['block', 'block_test', 'test_page_test'];
/**
* A user with permission to create and edit books and to administer blocks.
@@ -51,7 +51,7 @@ class BlockCacheTest extends BrowserTestBase {
parent::setUp();
// Create an admin user, log in and enable test blocks.
- $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'access administration pages'));
+ $this->adminUser = $this->drupalCreateUser(['administer blocks', 'access administration pages']);
$this->drupalLogin($this->adminUser);
// Create additional users to test caching modes.
@@ -87,7 +87,7 @@ class BlockCacheTest extends BrowserTestBase {
$this->assertText($old_content, 'Block is served from the cache.');
// Clear the cache and verify that the stale data is no longer there.
- Cache::invalidateTags(array('block_view'));
+ Cache::invalidateTags(['block_view']);
$this->drupalGet('');
$this->assertNoText($old_content, 'Block cache clear removes stale cache data.');
$this->assertText($current_content, 'Fresh block content is displayed after clearing the cache.');
diff --git a/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php b/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php
index e2965dcdcb7..c51551521ab 100644
--- a/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php
+++ b/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php
@@ -22,17 +22,17 @@ class BlockHiddenRegionTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test', 'search');
+ public static $modules = ['block', 'block_test', 'search'];
protected function setUp() {
parent::setUp();
// Create administrative user.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer blocks',
'administer themes',
'search content',
- )
+ ]
);
$this->drupalLogin($this->adminUser);
@@ -53,7 +53,7 @@ class BlockHiddenRegionTest extends BrowserTestBase {
$theme = 'block_test_theme';
// We need to install a non-hidden theme so that there is more than one
// local task.
- \Drupal::service('theme_handler')->install(array($theme, 'stark'));
+ \Drupal::service('theme_handler')->install([$theme, 'stark']);
$this->config('system.theme')
->set('default', $theme)
->save();
diff --git a/core/modules/block/tests/src/Functional/BlockHookOperationTest.php b/core/modules/block/tests/src/Functional/BlockHookOperationTest.php
index 9cb2272ce7d..3a5c1ffbd5c 100644
--- a/core/modules/block/tests/src/Functional/BlockHookOperationTest.php
+++ b/core/modules/block/tests/src/Functional/BlockHookOperationTest.php
@@ -17,14 +17,14 @@ class BlockHookOperationTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block', 'entity_test');
+ public static $modules = ['block', 'entity_test'];
protected function setUp() {
parent::setUp();
- $permissions = array(
+ $permissions = [
'administer blocks',
- );
+ ];
// Create and log in user.
$admin_user = $this->drupalCreateUser($permissions);
@@ -38,7 +38,7 @@ class BlockHookOperationTest extends BrowserTestBase {
// Add a test block, any block will do.
// Set the machine name so the test_operation link can be built later.
$block_id = Unicode::strtolower($this->randomMachineName(16));
- $this->drupalPlaceBlock('system_powered_by_block', array('id' => $block_id));
+ $this->drupalPlaceBlock('system_powered_by_block', ['id' => $block_id]);
// Get the Block listing.
$this->drupalGet('admin/structure/block');
diff --git a/core/modules/block/tests/src/Functional/BlockHtmlTest.php b/core/modules/block/tests/src/Functional/BlockHtmlTest.php
index 89bbcf9ee7c..94369907963 100644
--- a/core/modules/block/tests/src/Functional/BlockHtmlTest.php
+++ b/core/modules/block/tests/src/Functional/BlockHtmlTest.php
@@ -16,7 +16,7 @@ class BlockHtmlTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test');
+ public static $modules = ['block', 'block_test'];
protected function setUp() {
parent::setUp();
@@ -24,9 +24,9 @@ class BlockHtmlTest extends BrowserTestBase {
$this->drupalLogin($this->rootUser);
// Enable the test_html block, to test HTML ID and attributes.
- \Drupal::state()->set('block_test.attributes', array('data-custom-attribute' => 'foo'));
+ \Drupal::state()->set('block_test.attributes', ['data-custom-attribute' => 'foo']);
\Drupal::state()->set('block_test.content', $this->randomMachineName());
- $this->drupalPlaceBlock('test_html', array('id' => 'test_html_block'));
+ $this->drupalPlaceBlock('test_html', ['id' => 'test_html_block']);
// Enable a menu block, to test more complicated HTML.
$this->drupalPlaceBlock('system_menu_block:admin');
@@ -43,7 +43,7 @@ class BlockHtmlTest extends BrowserTestBase {
$this->assertFieldByXPath('//div[@id="block-test-html-block" and @data-custom-attribute="foo"]', NULL, 'HTML ID and attributes for test block are valid and on the same DOM element.');
// Ensure expected markup for a menu block.
- $elements = $this->xpath('//nav[contains(@class, :nav-class)]/ul[contains(@class, :ul-class)]/li', array(':nav-class' => 'block-menu', ':ul-class' => 'menu'));
+ $elements = $this->xpath('//nav[contains(@class, :nav-class)]/ul[contains(@class, :ul-class)]/li', [':nav-class' => 'block-menu', ':ul-class' => 'menu']);
$this->assertTrue(!empty($elements), 'The proper block markup was found.');
}
diff --git a/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php b/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
index b0e08b9e37f..9b18633d675 100644
--- a/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
+++ b/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
@@ -18,16 +18,16 @@ class BlockInvalidRegionTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test');
+ public static $modules = ['block', 'block_test'];
protected function setUp() {
parent::setUp();
// Create an admin user.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer site configuration',
'access administration pages',
'administer blocks',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
@@ -40,14 +40,14 @@ class BlockInvalidRegionTest extends BrowserTestBase {
\Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
$block = Block::load($block->id());
- $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block->id(), '%region' => 'invalid_region'));
+ $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block->id(), '%region' => 'invalid_region']);
// Clearing the cache should disable the test block placed in the invalid region.
- $this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches');
+ $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
$this->assertRaw($warning_message, 'Enabled block was in the invalid region and has been disabled.');
// Clear the cache to check if the warning message is not triggered.
- $this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches');
+ $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
$this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
// Place disabled test block in the invalid region of the default theme.
@@ -55,7 +55,7 @@ class BlockInvalidRegionTest extends BrowserTestBase {
$block = Block::load($block->id());
// Clear the cache to check if the warning message is not triggered.
- $this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches');
+ $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
$this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
}
diff --git a/core/modules/block/tests/src/Functional/BlockLanguageTest.php b/core/modules/block/tests/src/Functional/BlockLanguageTest.php
index 7e0a0e1851b..cf1b87720a2 100644
--- a/core/modules/block/tests/src/Functional/BlockLanguageTest.php
+++ b/core/modules/block/tests/src/Functional/BlockLanguageTest.php
@@ -23,19 +23,19 @@ class BlockLanguageTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('language', 'block', 'content_translation');
+ public static $modules = ['language', 'block', 'content_translation'];
protected function setUp() {
parent::setUp();
// Create a new user, allow him to manage the blocks and the languages.
- $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'administer languages'));
+ $this->adminUser = $this->drupalCreateUser(['administer blocks', 'administer languages']);
$this->drupalLogin($this->adminUser);
// Add predefined language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->assertText('French', 'Language added successfully.');
}
@@ -52,17 +52,17 @@ class BlockLanguageTest extends BrowserTestBase {
$this->assertNoField('visibility[language][context_mapping][language]', 'Language type field is not visible.');
// Enable a standard block and set the visibility setting for one language.
- $edit = array(
+ $edit = [
'visibility[language][langcodes][en]' => TRUE,
'id' => strtolower($this->randomMachineName(8)),
'region' => 'sidebar_first',
- );
+ ];
$this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, t('Save block'));
// Change the default language.
- $edit = array(
+ $edit = [
'site_default_language' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
// Check that a page has a block.
@@ -79,16 +79,16 @@ class BlockLanguageTest extends BrowserTestBase {
*/
public function testLanguageBlockVisibilityLanguageDelete() {
// Enable a standard block and set the visibility setting for one language.
- $edit = array(
- 'visibility' => array(
- 'language' => array(
- 'langcodes' => array(
+ $edit = [
+ 'visibility' => [
+ 'language' => [
+ 'langcodes' => [
'fr' => 'fr',
- ),
+ ],
'context_mapping' => ['language' => '@language.current_language_context:language_interface'],
- ),
- ),
- );
+ ],
+ ],
+ ];
$block = $this->drupalPlaceBlock('system_powered_by_block', $edit);
// Check that we have the language in config after saving the setting.
@@ -96,7 +96,7 @@ class BlockLanguageTest extends BrowserTestBase {
$this->assertEqual('fr', $visibility['language']['langcodes']['fr'], 'Language is set in the block configuration.');
// Delete the language.
- $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
// Check that the language is no longer stored in the configuration after
// it is deleted.
diff --git a/core/modules/block/tests/src/Functional/BlockTemplateSuggestionsTest.php b/core/modules/block/tests/src/Functional/BlockTemplateSuggestionsTest.php
index ca13c58b7dc..61a37454200 100644
--- a/core/modules/block/tests/src/Functional/BlockTemplateSuggestionsTest.php
+++ b/core/modules/block/tests/src/Functional/BlockTemplateSuggestionsTest.php
@@ -17,7 +17,7 @@ class BlockTemplateSuggestionsTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block');
+ public static $modules = ['block'];
/**
* Tests template suggestions from block_theme_suggestions_block().
@@ -27,22 +27,22 @@ class BlockTemplateSuggestionsTest extends BrowserTestBase {
// an underscore (not transformed) and a hyphen (transformed to underscore),
// and generates possibilities for each level of derivative.
// @todo Clarify this comment.
- $block = Block::create(array(
+ $block = Block::create([
'plugin' => 'system_menu_block:admin',
'region' => 'footer',
'id' => 'machinename',
- ));
+ ]);
- $variables = array();
+ $variables = [];
$plugin = $block->getPlugin();
$variables['elements']['#configuration'] = $plugin->getConfiguration();
$variables['elements']['#plugin_id'] = $plugin->getPluginId();
$variables['elements']['#id'] = $block->id();
$variables['elements']['#base_plugin_id'] = $plugin->getBaseId();
$variables['elements']['#derivative_plugin_id'] = $plugin->getDerivativeId();
- $variables['elements']['content'] = array();
+ $variables['elements']['content'] = [];
$suggestions = block_theme_suggestions_block($variables);
- $this->assertEqual($suggestions, array('block__system', 'block__system_menu_block', 'block__system_menu_block__admin', 'block__machinename'));
+ $this->assertEqual($suggestions, ['block__system', 'block__system_menu_block', 'block__system_menu_block__admin', 'block__machinename']);
}
}
diff --git a/core/modules/block/tests/src/Functional/NewDefaultThemeBlocksTest.php b/core/modules/block/tests/src/Functional/NewDefaultThemeBlocksTest.php
index 5c23a660420..767a7da5900 100644
--- a/core/modules/block/tests/src/Functional/NewDefaultThemeBlocksTest.php
+++ b/core/modules/block/tests/src/Functional/NewDefaultThemeBlocksTest.php
@@ -16,7 +16,7 @@ class NewDefaultThemeBlocksTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block');
+ public static $modules = ['block'];
/**
* Check the enabled Bartik blocks are correctly copied over.
@@ -25,22 +25,22 @@ class NewDefaultThemeBlocksTest extends BrowserTestBase {
$default_theme = $this->config('system.theme')->get('default');
// Add two instances of the user login block.
- $this->drupalPlaceBlock('user_login_block', array(
+ $this->drupalPlaceBlock('user_login_block', [
'id' => $default_theme . '_' . strtolower($this->randomMachineName(8)),
- ));
- $this->drupalPlaceBlock('user_login_block', array(
+ ]);
+ $this->drupalPlaceBlock('user_login_block', [
'id' => $default_theme . '_' . strtolower($this->randomMachineName(8)),
- ));
+ ]);
// Add an instance of a different block.
- $this->drupalPlaceBlock('system_powered_by_block', array(
+ $this->drupalPlaceBlock('system_powered_by_block', [
'id' => $default_theme . '_' . strtolower($this->randomMachineName(8)),
- ));
+ ]);
// Install a different theme.
$new_theme = 'bartik';
$this->assertFalse($new_theme == $default_theme, 'The new theme is different from the previous default theme.');
- \Drupal::service('theme_handler')->install(array($new_theme));
+ \Drupal::service('theme_handler')->install([$new_theme]);
$this->config('system.theme')
->set('default', $new_theme)
->save();
diff --git a/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php b/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php
index a401ea51366..2bf41e0f4c0 100644
--- a/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php
+++ b/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php
@@ -18,7 +18,7 @@ class BlockConfigSchemaTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array(
+ public static $modules = [
'block',
'aggregator',
'book',
@@ -32,7 +32,7 @@ class BlockConfigSchemaTest extends KernelTestBase {
'taxonomy',
'user',
'text',
- );
+ ];
/**
* The typed config manager.
@@ -59,7 +59,7 @@ class BlockConfigSchemaTest extends KernelTestBase {
$this->installEntitySchema('block_content');
$this->installEntitySchema('taxonomy_term');
$this->installEntitySchema('node');
- $this->installSchema('book', array('book'));
+ $this->installSchema('book', ['book']);
}
/**
@@ -68,20 +68,20 @@ class BlockConfigSchemaTest extends KernelTestBase {
public function testBlockConfigSchema() {
foreach ($this->blockManager->getDefinitions() as $block_id => $definition) {
$id = strtolower($this->randomMachineName());
- $block = Block::create(array(
+ $block = Block::create([
'id' => $id,
'theme' => 'classy',
'weight' => 00,
'status' => TRUE,
'region' => 'content',
'plugin' => $block_id,
- 'settings' => array(
+ 'settings' => [
'label' => $this->randomMachineName(),
'provider' => 'system',
'label_display' => FALSE,
- ),
- 'visibility' => array(),
- ));
+ ],
+ 'visibility' => [],
+ ]);
$block->save();
$config = $this->config("block.block.$id");
diff --git a/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php b/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php
index 5959c0d6a85..48d63a302d2 100644
--- a/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php
+++ b/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php
@@ -13,7 +13,7 @@ use Drupal\KernelTests\KernelTestBase;
*/
class BlockInterfaceTest extends KernelTestBase {
- public static $modules = array('system', 'block', 'block_test', 'user');
+ public static $modules = ['system', 'block', 'block_test', 'user'];
/**
* Test configuration and subsequent form() and build() method calls.
@@ -31,16 +31,16 @@ class BlockInterfaceTest extends KernelTestBase {
*/
public function testBlockInterface() {
$manager = $this->container->get('plugin.manager.block');
- $configuration = array(
+ $configuration = [
'label' => 'Custom Display Message',
- );
- $expected_configuration = array(
+ ];
+ $expected_configuration = [
'id' => 'test_block_instantiation',
'label' => 'Custom Display Message',
'provider' => 'block_test',
'label_display' => BlockPluginInterface::BLOCK_LABEL_VISIBLE,
'display_message' => 'no message set',
- );
+ ];
// Initial configuration of the block at construction time.
/** @var $display_block \Drupal\Core\Block\BlockPluginInterface */
$display_block = $manager->createInstance('test_block_instantiation', $configuration);
@@ -52,46 +52,46 @@ class BlockInterfaceTest extends KernelTestBase {
$this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block configuration was updated correctly.');
$definition = $display_block->getPluginDefinition();
- $expected_form = array(
- 'provider' => array(
+ $expected_form = [
+ 'provider' => [
'#type' => 'value',
'#value' => 'block_test',
- ),
- 'admin_label' => array(
+ ],
+ 'admin_label' => [
'#type' => 'item',
'#title' => t('Block description'),
'#plain_text' => $definition['admin_label'],
- ),
- 'label' => array(
+ ],
+ 'label' => [
'#type' => 'textfield',
'#title' => 'Title',
'#maxlength' => 255,
'#default_value' => 'Custom Display Message',
'#required' => TRUE,
- ),
- 'label_display' => array(
+ ],
+ 'label_display' => [
'#type' => 'checkbox',
'#title' => 'Display title',
'#default_value' => TRUE,
'#return_value' => 'visible',
- ),
- 'context_mapping' => array(),
- 'display_message' => array(
+ ],
+ 'context_mapping' => [],
+ 'display_message' => [
'#type' => 'textfield',
'#title' => t('Display message'),
'#default_value' => 'My custom display message.',
- ),
- );
+ ],
+ ];
$form_state = new FormState();
// Ensure there are no form elements that do not belong to the plugin.
- $actual_form = $display_block->buildConfigurationForm(array(), $form_state);
+ $actual_form = $display_block->buildConfigurationForm([], $form_state);
// Remove the visibility sections, as that just tests condition plugins.
unset($actual_form['visibility'], $actual_form['visibility_tabs']);
$this->assertIdentical($this->castSafeStrings($actual_form), $this->castSafeStrings($expected_form), 'Only the expected form elements were present.');
- $expected_build = array(
+ $expected_build = [
'#children' => 'My custom display message.',
- );
+ ];
// Ensure the build array is proper.
$this->assertIdentical($display_block->build(), $expected_build, 'The plugin returned the appropriate build array.');
diff --git a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php
index d31c92c950e..2a7c7710c30 100644
--- a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php
+++ b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php
@@ -21,7 +21,7 @@ class BlockStorageUnitTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test', 'system');
+ public static $modules = ['block', 'block_test', 'system'];
/**
* The block storage.
@@ -56,7 +56,7 @@ class BlockStorageUnitTest extends KernelTestBase {
protected function createTests() {
// Attempt to create a block without a plugin.
try {
- $entity = $this->controller->create(array());
+ $entity = $this->controller->create([]);
$entity->getPlugin();
$this->fail('A block without a plugin was created with no exception thrown.');
}
@@ -65,12 +65,12 @@ class BlockStorageUnitTest extends KernelTestBase {
}
// Create a block with only required values.
- $entity = $this->controller->create(array(
+ $entity = $this->controller->create([
'id' => 'test_block',
'theme' => 'stark',
'region' => 'content',
'plugin' => 'test_html',
- ));
+ ]);
$entity->save();
$this->assertTrue($entity instanceof Block, 'The newly created entity is a Block.');
@@ -81,24 +81,24 @@ class BlockStorageUnitTest extends KernelTestBase {
unset($actual_properties['uuid']);
// Ensure that default values are filled in.
- $expected_properties = array(
+ $expected_properties = [
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
'status' => TRUE,
- 'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')),
+ 'dependencies' => ['module' => ['block_test'], 'theme' => ['stark']],
'id' => 'test_block',
'theme' => 'stark',
'region' => 'content',
'weight' => NULL,
'provider' => NULL,
'plugin' => 'test_html',
- 'settings' => array(
+ 'settings' => [
'id' => 'test_html',
'label' => '',
'provider' => 'block_test',
'label_display' => BlockPluginInterface::BLOCK_LABEL_VISIBLE,
- ),
- 'visibility' => array(),
- );
+ ],
+ 'visibility' => [],
+ ];
$this->assertIdentical($actual_properties, $expected_properties);
@@ -148,7 +148,7 @@ class BlockStorageUnitTest extends KernelTestBase {
$this->assertTrue(empty($entities), 'There are no blocks initially.');
// Install the block_test.module, so that its default config is installed.
- $this->installConfig(array('block_test'));
+ $this->installConfig(['block_test']);
$entities = $this->controller->loadMultiple();
$entity = reset($entities);
diff --git a/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php b/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php
index 64b21096c0a..71c4f55b8d0 100644
--- a/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php
+++ b/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php
@@ -20,7 +20,7 @@ class BlockViewBuilderTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test', 'system', 'user');
+ public static $modules = ['block', 'block_test', 'system', 'user'];
/**
* The block being tested.
@@ -56,11 +56,11 @@ class BlockViewBuilderTest extends KernelTestBase {
\Drupal::state()->set('block_test.content', 'Llamas &gt; unicorns!');
// Create a block with only required values.
- $this->block = $this->controller->create(array(
+ $this->block = $this->controller->create([
'id' => 'test_block',
'theme' => 'stark',
'plugin' => 'test_cache',
- ));
+ ]);
$this->block->save();
$this->container->get('cache.render')->deleteAll();
@@ -74,17 +74,17 @@ class BlockViewBuilderTest extends KernelTestBase {
public function testBasicRendering() {
\Drupal::state()->set('block_test.content', '');
- $entity = $this->controller->create(array(
+ $entity = $this->controller->create([
'id' => 'test_block1',
'theme' => 'stark',
'plugin' => 'test_html',
- ));
+ ]);
$entity->save();
// Test the rendering of a block.
$entity = Block::load('test_block1');
$output = entity_view($entity, 'block');
- $expected = array();
+ $expected = [];
$expected[] = '<div id="block-test-block1">';
$expected[] = ' ';
$expected[] = ' ';
@@ -98,17 +98,17 @@ class BlockViewBuilderTest extends KernelTestBase {
Html::resetSeenIds();
// Test the rendering of a block with a given title.
- $entity = $this->controller->create(array(
+ $entity = $this->controller->create([
'id' => 'test_block2',
'theme' => 'stark',
'plugin' => 'test_html',
- 'settings' => array(
+ 'settings' => [
'label' => 'Powered by Bananas',
- ),
- ));
+ ],
+ ]);
$entity->save();
$output = entity_view($entity, 'block');
- $expected = array();
+ $expected = [];
$expected[] = '<div id="block-test-block2">';
$expected[] = ' ';
$expected[] = ' <h2>Powered by Bananas</h2>';
@@ -128,11 +128,11 @@ class BlockViewBuilderTest extends KernelTestBase {
$this->verifyRenderCacheHandling();
// Create an empty block.
- $this->block = $this->controller->create(array(
+ $this->block = $this->controller->create([
'id' => 'test_block',
'theme' => 'stark',
'plugin' => 'test_cache',
- ));
+ ]);
$this->block->save();
\Drupal::state()->set('block_test.content', NULL);
diff --git a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php
index 453cdcc8210..8df0e93a274 100644
--- a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php
+++ b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php
@@ -69,20 +69,20 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
* @covers ::calculateDependencies
*/
public function testCalculateDependencies() {
- $values = array('theme' => 'stark');
+ $values = ['theme' => 'stark'];
// Mock the entity under test so that we can mock getPluginCollections().
$entity = $this->getMockBuilder('\Drupal\block\Entity\Block')
- ->setConstructorArgs(array($values, $this->entityTypeId))
- ->setMethods(array('getPluginCollections'))
+ ->setConstructorArgs([$values, $this->entityTypeId])
+ ->setMethods(['getPluginCollections'])
->getMock();
// Create a configurable plugin that would add a dependency.
$instance_id = $this->randomMachineName();
- $instance = new TestConfigurablePlugin(array(), $instance_id, array('provider' => 'test'));
+ $instance = new TestConfigurablePlugin([], $instance_id, ['provider' => 'test']);
// Create a plugin collection to contain the instance.
$plugin_collection = $this->getMockBuilder('\Drupal\Core\Plugin\DefaultLazyPluginCollection')
->disableOriginalConstructor()
- ->setMethods(array('get'))
+ ->setMethods(['get'])
->getMock();
$plugin_collection->expects($this->atLeastOnce())
->method('get')
@@ -93,7 +93,7 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
// Return the mocked plugin collection.
$entity->expects($this->once())
->method('getPluginCollections')
- ->will($this->returnValue(array($plugin_collection)));
+ ->will($this->returnValue([$plugin_collection]));
$dependencies = $entity->calculateDependencies()->getDependencies();
$this->assertContains('test', $dependencies['module']);
diff --git a/core/modules/block/tests/src/Unit/BlockFormTest.php b/core/modules/block/tests/src/Unit/BlockFormTest.php
index d8efe2b7910..b8463490bd3 100644
--- a/core/modules/block/tests/src/Unit/BlockFormTest.php
+++ b/core/modules/block/tests/src/Unit/BlockFormTest.php
@@ -88,7 +88,7 @@ class BlockFormTest extends UnitTestCase {
* @see \Drupal\block\BlockForm::getUniqueMachineName()
*/
public function testGetUniqueMachineName() {
- $blocks = array();
+ $blocks = [];
$blocks['test'] = $this->getBlockMockWithMachineName('test');
$blocks['other_test'] = $this->getBlockMockWithMachineName('other_test');
@@ -102,7 +102,7 @@ class BlockFormTest extends UnitTestCase {
$query->expects($this->exactly(5))
->method('execute')
- ->will($this->returnValue(array('test', 'other_test', 'other_test_1', 'other_test_2')));
+ ->will($this->returnValue(['test', 'other_test', 'other_test_1', 'other_test_2']));
$this->storage->expects($this->exactly(5))
->method('getQuery')
diff --git a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php
index aab11fe9fc2..5584b0bfdda 100644
--- a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php
+++ b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php
@@ -116,25 +116,25 @@ class BlockRepositoryTest extends UnitTestCase {
}
public function providerBlocksConfig() {
- $blocks_config = array(
- 'block1' => array(
+ $blocks_config = [
+ 'block1' => [
AccessResult::allowed(), 'top', 0
- ),
+ ],
// Test a block without access.
- 'block2' => array(
+ 'block2' => [
AccessResult::forbidden(), 'bottom', 0
- ),
+ ],
// Test some blocks in the same region with specific weight.
- 'block4' => array(
+ 'block4' => [
AccessResult::allowed(), 'bottom', 5
- ),
- 'block3' => array(
+ ],
+ 'block3' => [
AccessResult::allowed(), 'bottom', 5
- ),
- 'block5' => array(
+ ],
+ 'block5' => [
AccessResult::allowed(), 'bottom', -5
- ),
- );
+ ],
+ ];
$test_cases = [];
$test_cases[] = [$blocks_config,
diff --git a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
index c47d65ab445..d91ebbcdbc2 100644
--- a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
+++ b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
@@ -24,7 +24,7 @@ class CategoryAutocompleteTest extends UnitTestCase {
$block_manager = $this->getMock('Drupal\Core\Block\BlockManagerInterface');
$block_manager->expects($this->any())
->method('getCategories')
- ->will($this->returnValue(array('Comment', 'Node', 'None & Such', 'User')));
+ ->will($this->returnValue(['Comment', 'Node', 'None & Such', 'User']));
$this->autocompleteController = new CategoryAutocompleteController($block_manager);
}
@@ -43,9 +43,9 @@ class CategoryAutocompleteTest extends UnitTestCase {
*/
public function testAutocompleteSuggestions($string, $suggestions) {
$suggestions = array_map(function ($suggestion) {
- return array('value' => $suggestion, 'label' => Html::escape($suggestion));
+ return ['value' => $suggestion, 'label' => Html::escape($suggestion)];
}, $suggestions);
- $result = $this->autocompleteController->autocomplete(new Request(array('q' => $string)));
+ $result = $this->autocompleteController->autocomplete(new Request(['q' => $string]));
$this->assertSame($suggestions, json_decode($result->getContent(), TRUE));
}
@@ -55,30 +55,30 @@ class CategoryAutocompleteTest extends UnitTestCase {
* @return array
*/
public function providerTestAutocompleteSuggestions() {
- $test_parameters = array();
- $test_parameters[] = array(
+ $test_parameters = [];
+ $test_parameters[] = [
'string' => 'Com',
- 'suggestions' => array(
+ 'suggestions' => [
'Comment',
- ),
- );
- $test_parameters[] = array(
+ ],
+ ];
+ $test_parameters[] = [
'string' => 'No',
- 'suggestions' => array(
+ 'suggestions' => [
'Node',
'None & Such',
- ),
- );
- $test_parameters[] = array(
+ ],
+ ];
+ $test_parameters[] = [
'string' => 'us',
- 'suggestions' => array(
+ 'suggestions' => [
'User',
- ),
- );
- $test_parameters[] = array(
+ ],
+ ];
+ $test_parameters[] = [
'string' => 'Banana',
- 'suggestions' => array(),
- );
+ 'suggestions' => [],
+ ];
return $test_parameters;
}
diff --git a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
index a513c4ef756..6d7dbf2b9b7 100644
--- a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
+++ b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
@@ -13,33 +13,33 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
class BlockLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array('block' => 'core/modules/block');
+ $this->directoryList = ['block' => 'core/modules/block'];
parent::setUp();
- $config_factory = $this->getConfigFactoryStub(array('system.theme' => array(
+ $config_factory = $this->getConfigFactoryStub(['system.theme' => [
'default' => 'test_c',
- )));
+ ]]);
- $themes = array();
- $themes['test_a'] = (object) array(
+ $themes = [];
+ $themes['test_a'] = (object) [
'status' => 1,
- 'info' => array(
+ 'info' => [
'name' => 'test_a',
'hidden' => TRUE,
- ),
- );
- $themes['test_b'] = (object) array(
+ ],
+ ];
+ $themes['test_b'] = (object) [
'status' => 1,
- 'info' => array(
+ 'info' => [
'name' => 'test_b',
- ),
- );
- $themes['test_c'] = (object) array(
+ ],
+ ];
+ $themes['test_c'] = (object) [
'status' => 1,
- 'info' => array(
+ 'info' => [
'name' => 'test_c',
- ),
- );
+ ],
+ ];
$theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler->expects($this->any())
->method('listInfo')
@@ -63,7 +63,7 @@ class BlockLocalTasksTest extends LocalTaskIntegrationTestBase {
* Tests the admin edit local task.
*/
public function testBlockAdminLocalTasks() {
- $this->assertLocalTasks('entity.block.edit_form', array(array('entity.block.edit_form')));
+ $this->assertLocalTasks('entity.block.edit_form', [['entity.block.edit_form']]);
}
/**
@@ -79,10 +79,10 @@ class BlockLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function providerTestBlockAdminDisplay() {
- return array(
- array('block.admin_display', array(array('block.admin_display'), array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'))),
- array('block.admin_display_theme', array(array('block.admin_display'), array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'))),
- );
+ return [
+ ['block.admin_display', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]],
+ ['block.admin_display_theme', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]],
+ ];
}
}
diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
index 7701ecac0b5..15694113534 100644
--- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
+++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
@@ -44,7 +44,7 @@ class BlockPageVariantTest extends UnitTestCase {
* @return \Drupal\block\Plugin\DisplayVariant\BlockPageVariant|\PHPUnit_Framework_MockObject_MockObject
* A mocked display variant plugin.
*/
- public function setUpDisplayVariant($configuration = array(), $definition = array()) {
+ public function setUpDisplayVariant($configuration = [], $definition = []) {
$container = new Container();
$cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager')
@@ -60,37 +60,37 @@ class BlockPageVariantTest extends UnitTestCase {
$this->blockViewBuilder = $this->getMock('Drupal\Core\Entity\EntityViewBuilderInterface');
return $this->getMockBuilder('Drupal\block\Plugin\DisplayVariant\BlockPageVariant')
- ->setConstructorArgs(array($configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, ['config:block_list']))
- ->setMethods(array('getRegionNames'))
+ ->setConstructorArgs([$configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, ['config:block_list']])
+ ->setMethods(['getRegionNames'])
->getMock();
}
public function providerBuild() {
- $blocks_config = array(
- 'block1' => array(
+ $blocks_config = [
+ 'block1' => [
// region, is main content block, is messages block, is title block
'top', FALSE, FALSE, FALSE,
- ),
+ ],
// Test multiple blocks in the same region.
- 'block2' => array(
+ 'block2' => [
'bottom', FALSE, FALSE, FALSE,
- ),
- 'block3' => array(
+ ],
+ 'block3' => [
'bottom', FALSE, FALSE, FALSE,
- ),
+ ],
// Test a block implementing MainContentBlockPluginInterface.
- 'block4' => array(
+ 'block4' => [
'center', TRUE, FALSE, FALSE,
- ),
+ ],
// Test a block implementing MessagesBlockPluginInterface.
- 'block5' => array(
+ 'block5' => [
'center', FALSE, TRUE, FALSE,
- ),
+ ],
// Test a block implementing TitleBlockPluginInterface.
- 'block6' => array(
+ 'block6' => [
'center', FALSE, FALSE, TRUE,
- ),
- );
+ ],
+ ];
$test_cases = [];
$test_cases[] = [$blocks_config, 6,
@@ -219,7 +219,7 @@ class BlockPageVariantTest extends UnitTestCase {
}
$this->blockViewBuilder->expects($this->exactly($visible_block_count))
->method('view')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->blockRepository->expects($this->once())
->method('getVisibleBlocksPerRegion')
->willReturnCallback(function (&$cacheable_metadata) use ($blocks) {
diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module
index e0b57295617..1b32a522940 100644
--- a/core/modules/block_content/block_content.module
+++ b/core/modules/block_content/block_content.module
@@ -15,25 +15,25 @@ use Drupal\field\Entity\FieldStorageConfig;
function block_content_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.block_content':
- $field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
+ $field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Custom Block module allows you to create and manage custom <em>block types</em> and <em>content-containing blocks</em> from the <a href = ":block-library" >Custom block library<a/> page. Custom block types have fields; see the <a href=":field-help">Field module help</a> for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the <a href=":blocks">Block module help</a> page for details. For more information, see the <a href=":online-help">online documentation for the Custom Block module</a>.', array(':block-library' => \Drupal::url('entity.block_content.collection'), ':block-content' => \Drupal::url('entity.block_content.collection'), ':field-help' => \Drupal::url('help.page', array('name' => 'field')), ':blocks' => \Drupal::url('help.page', array('name' => 'block')), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '</p>';
+ $output .= '<p>' . t('The Custom Block module allows you to create and manage custom <em>block types</em> and <em>content-containing blocks</em> from the <a href = ":block-library" >Custom block library<a/> page. Custom block types have fields; see the <a href=":field-help">Field module help</a> for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the <a href=":blocks">Block module help</a> page for details. For more information, see the <a href=":online-help">online documentation for the Custom Block module</a>.', [':block-library' => \Drupal::url('entity.block_content.collection'), ':block-content' => \Drupal::url('entity.block_content.collection'), ':field-help' => \Drupal::url('help.page', ['name' => 'field']), ':blocks' => \Drupal::url('help.page', ['name' => 'block']), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating and managing custom block types') . '</dt>';
- $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create and edit custom block types with fields and display settings, from the <a href=":types">Block types</a> page in the Custom block library. For more information about managing fields and display settings, see the <a href=":field-ui">Field UI module help</a>.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':field-ui' => $field_ui)) . '</dd>';
+ $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create and edit custom block types with fields and display settings, from the <a href=":types">Block types</a> page in the Custom block library. For more information about managing fields and display settings, see the <a href=":field-ui">Field UI module help</a>.', [':types' => \Drupal::url('entity.block_content_type.collection'), ':field-ui' => $field_ui]) . '</dd>';
$output .= '<dt>' . t('Creating custom blocks') . '</dt>';
- $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create, edit, and delete custom blocks of each defined custom block type, from the <a href=":block-library">Blocks</a> page in the Custom block library. After creating a block, place it in a region from the <a href=":blocks">Block layout</a> page; see the <a href=":block_help">Block module help</a> for more information about placing blocks.', array(':blocks' => \Drupal::url('block.admin_display'), ':block-library' => \Drupal::url('entity.block_content.collection'), ':block_help' => \Drupal::url('help.page', array('name' => 'block')))) . '</dd>';
+ $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create, edit, and delete custom blocks of each defined custom block type, from the <a href=":block-library">Blocks</a> page in the Custom block library. After creating a block, place it in a region from the <a href=":blocks">Block layout</a> page; see the <a href=":block_help">Block module help</a> for more information about placing blocks.', [':blocks' => \Drupal::url('block.admin_display'), ':block-library' => \Drupal::url('entity.block_content.collection'), ':block_help' => \Drupal::url('help.page', ['name' => 'block'])]) . '</dd>';
$output .= '</dl>';
return $output;
case 'entity.block_content.collection':
- $output = '<p>' . t('Blocks in the block library belong to <a href=":types">Custom block types</a>, each with its own fields and display settings. After creating a block, place it in a region from the <a href=":blocks">Block layout</a> page.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':blocks' => \Drupal::url('block.admin_display'))) . '</p>';
+ $output = '<p>' . t('Blocks in the block library belong to <a href=":types">Custom block types</a>, each with its own fields and display settings. After creating a block, place it in a region from the <a href=":blocks">Block layout</a> page.', [':types' => \Drupal::url('entity.block_content_type.collection'), ':blocks' => \Drupal::url('block.admin_display')]) . '</p>';
return $output;
case 'entity.block_content_type.collection':
- $output = '<p>' . t('Each block type has its own fields and display settings. Create blocks of each type on the <a href=":block-library">Blocks</a> page in the custom block library.', array(':block-library' => \Drupal::url('entity.block_content.collection'))) . '</p>';
+ $output = '<p>' . t('Each block type has its own fields and display settings. Create blocks of each type on the <a href=":block-library">Blocks</a> page in the custom block library.', [':block-library' => \Drupal::url('entity.block_content.collection')]) . '</p>';
return $output;
}
@@ -43,12 +43,12 @@ function block_content_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function block_content_theme($existing, $type, $theme, $path) {
- return array(
- 'block_content_add_list' => array(
- 'variables' => array('content' => NULL),
+ return [
+ 'block_content_add_list' => [
+ 'variables' => ['content' => NULL],
'file' => 'block_content.pages.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -83,23 +83,23 @@ function block_content_add_body_field($block_type_id, $label = 'Body') {
'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
'bundle' => $block_type_id,
'label' => $label,
- 'settings' => array('display_summary' => FALSE),
+ 'settings' => ['display_summary' => FALSE],
]);
$field->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('block_content', $block_type_id, 'default')
- ->setComponent('body', array(
+ ->setComponent('body', [
'type' => 'text_textarea_with_summary',
- ))
+ ])
->save();
// Assign display settings for 'default' view mode.
entity_get_display('block_content', $block_type_id, 'default')
- ->setComponent('body', array(
+ ->setComponent('body', [
'label' => 'hidden',
'type' => 'text_default',
- ))
+ ])
->save();
}
diff --git a/core/modules/block_content/block_content.pages.inc b/core/modules/block_content/block_content.pages.inc
index 86296900df6..e50e71787b3 100644
--- a/core/modules/block_content/block_content.pages.inc
+++ b/core/modules/block_content/block_content.pages.inc
@@ -19,18 +19,18 @@ use Drupal\Core\Url;
* @see block_content_add_page()
*/
function template_preprocess_block_content_add_list(&$variables) {
- $variables['types'] = array();
+ $variables['types'] = [];
$query = \Drupal::request()->query->all();
foreach ($variables['content'] as $type) {
- $variables['types'][$type->id()] = array(
- 'link' => \Drupal::l($type->label(), new Url('block_content.add_form', array('block_content_type' => $type->id()), array('query' => $query))),
- 'description' => array(
+ $variables['types'][$type->id()] = [
+ 'link' => \Drupal::l($type->label(), new Url('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query])),
+ 'description' => [
'#markup' => $type->getDescription(),
- ),
+ ],
'title' => $type->label(),
- 'localized_options' => array(
+ 'localized_options' => [
'query' => $query,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php
index b3f50f7a952..eefd4e97908 100644
--- a/core/modules/block_content/src/BlockContentForm.php
+++ b/core/modules/block_content/src/BlockContentForm.php
@@ -27,7 +27,7 @@ class BlockContentForm extends ContentEntityForm {
$form = parent::form($form, $form_state);
if ($this->operation == 'edit') {
- $form['#title'] = $this->t('Edit custom block %label', array('%label' => $block->label()));
+ $form['#title'] = $this->t('Edit custom block %label', ['%label' => $block->label()]);
}
// Override the default CSS class name, since the user-defined custom block
// type name in 'TYPE-block-form' potentially clashes with third-party class
@@ -45,10 +45,10 @@ class BlockContentForm extends ContentEntityForm {
$insert = $block->isNew();
$block->save();
- $context = array('@type' => $block->bundle(), '%info' => $block->label());
+ $context = ['@type' => $block->bundle(), '%info' => $block->label()];
$logger = $this->logger('block_content');
$block_type = $this->getBundleEntity();
- $t_args = array('@type' => $block_type->label(), '%info' => $block->label());
+ $t_args = ['@type' => $block_type->label(), '%info' => $block->label()];
if ($insert) {
$logger->notice('@type: added %info.', $context);
@@ -68,10 +68,10 @@ class BlockContentForm extends ContentEntityForm {
}
$form_state->setRedirect(
'block.admin_add',
- array(
+ [
'plugin_id' => 'block_content:' . $block->uuid(),
'theme' => $theme,
- )
+ ]
);
}
else {
diff --git a/core/modules/block_content/src/BlockContentTranslationHandler.php b/core/modules/block_content/src/BlockContentTranslationHandler.php
index b446cde8c51..612613b376b 100644
--- a/core/modules/block_content/src/BlockContentTranslationHandler.php
+++ b/core/modules/block_content/src/BlockContentTranslationHandler.php
@@ -16,7 +16,7 @@ class BlockContentTranslationHandler extends ContentTranslationHandler {
*/
protected function entityFormTitle(EntityInterface $entity) {
$block_type = BlockContentType::load($entity->bundle());
- return t('<em>Edit @type</em> @title', array('@type' => $block_type->label(), '@title' => $entity->label()));
+ return t('<em>Edit @type</em> @title', ['@type' => $block_type->label(), '@title' => $entity->label()]);
}
}
diff --git a/core/modules/block_content/src/BlockContentTypeForm.php b/core/modules/block_content/src/BlockContentTypeForm.php
index d864e8d56f3..4e140b19322 100644
--- a/core/modules/block_content/src/BlockContentTypeForm.php
+++ b/core/modules/block_content/src/BlockContentTypeForm.php
@@ -25,65 +25,65 @@ class BlockContentTypeForm extends BundleEntityFormBase {
$form['#title'] = $this->t('Add custom block type');
}
else {
- $form['#title'] = $this->t('Edit %label custom block type', array('%label' => $block_type->label()));
+ $form['#title'] = $this->t('Edit %label custom block type', ['%label' => $block_type->label()]);
}
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => t('Label'),
'#maxlength' => 255,
'#default_value' => $block_type->label(),
'#description' => t("Provide a label for this block type to help identify it in the administration pages."),
'#required' => TRUE,
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $block_type->id(),
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\block_content\Entity\BlockContentType::load',
- ),
+ ],
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
- );
+ ];
- $form['description'] = array(
+ $form['description'] = [
'#type' => 'textarea',
'#default_value' => $block_type->getDescription(),
'#description' => t('Enter a description for this block type.'),
'#title' => t('Description'),
- );
+ ];
- $form['revision'] = array(
+ $form['revision'] = [
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $block_type->shouldCreateNewRevision(),
'#description' => t('Create a new revision by default for this block type.'),
- );
+ ];
if ($this->moduleHandler->moduleExists('language')) {
- $form['language'] = array(
+ $form['language'] = [
'#type' => 'details',
'#title' => t('Language settings'),
'#group' => 'additional_settings',
- );
+ ];
$language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('block_content', $block_type->id());
- $form['language']['language_configuration'] = array(
+ $form['language']['language_configuration'] = [
'#type' => 'language_configuration',
- '#entity_information' => array(
+ '#entity_information' => [
'entity_type' => 'block_content',
'bundle' => $block_type->id(),
- ),
+ ],
'#default_value' => $language_configuration,
- );
+ ];
$form['#submit'][] = 'language_configuration_element_submit';
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
- );
+ ];
return $this->protectBundleIdElement($form);
}
@@ -98,13 +98,13 @@ class BlockContentTypeForm extends BundleEntityFormBase {
$edit_link = $this->entity->link($this->t('Edit'));
$logger = $this->logger('block_content');
if ($status == SAVED_UPDATED) {
- drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label())));
- $logger->notice('Custom block type %label has been updated.', array('%label' => $block_type->label(), 'link' => $edit_link));
+ drupal_set_message(t('Custom block type %label has been updated.', ['%label' => $block_type->label()]));
+ $logger->notice('Custom block type %label has been updated.', ['%label' => $block_type->label(), 'link' => $edit_link]);
}
else {
block_content_add_body_field($block_type->id());
- drupal_set_message(t('Custom block type %label has been added.', array('%label' => $block_type->label())));
- $logger->notice('Custom block type %label has been added.', array('%label' => $block_type->label(), 'link' => $edit_link));
+ drupal_set_message(t('Custom block type %label has been added.', ['%label' => $block_type->label()]));
+ $logger->notice('Custom block type %label has been added.', ['%label' => $block_type->label(), 'link' => $edit_link]);
}
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
diff --git a/core/modules/block_content/src/BlockContentViewBuilder.php b/core/modules/block_content/src/BlockContentViewBuilder.php
index 322a087d9fe..29c668cd63d 100644
--- a/core/modules/block_content/src/BlockContentViewBuilder.php
+++ b/core/modules/block_content/src/BlockContentViewBuilder.php
@@ -15,13 +15,13 @@ class BlockContentViewBuilder extends EntityViewBuilder {
* {@inheritdoc}
*/
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
- return $this->viewMultiple(array($entity), $view_mode, $langcode)[0];
+ return $this->viewMultiple([$entity], $view_mode, $langcode)[0];
}
/**
* {@inheritdoc}
*/
- public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
+ public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) {
$build_list = parent::viewMultiple($entities, $view_mode, $langcode);
// Apply the buildMultiple() #pre_render callback immediately, to make
// bubbling of attributes and contextual links to the actual block work.
@@ -48,10 +48,10 @@ class BlockContentViewBuilder extends EntityViewBuilder {
parent::alterBuild($build, $entity, $display, $view_mode);
// Add contextual links for this custom block.
if (!$entity->isNew()) {
- $build['#contextual_links']['block_content'] = array(
- 'route_parameters' => array('block_content' => $entity->id()),
- 'metadata' => array('changed' => $entity->getChangedTime()),
- );
+ $build['#contextual_links']['block_content'] = [
+ 'route_parameters' => ['block_content' => $entity->id()],
+ 'metadata' => ['changed' => $entity->getChangedTime()],
+ ];
}
}
diff --git a/core/modules/block_content/src/BlockContentViewsData.php b/core/modules/block_content/src/BlockContentViewsData.php
index 1d5d46f5f03..010ede0ea59 100644
--- a/core/modules/block_content/src/BlockContentViewsData.php
+++ b/core/modules/block_content/src/BlockContentViewsData.php
@@ -23,13 +23,13 @@ class BlockContentViewsData extends EntityViewsData {
$data['block_content_field_data']['type']['field']['id'] = 'field';
- $data['block_content']['block_content_listing_empty'] = array(
+ $data['block_content']['block_content_listing_empty'] = [
'title' => $this->t('Empty block library behavior'),
'help' => $this->t('Provides a link to add a new block.'),
- 'area' => array(
+ 'area' => [
'id' => 'block_content_listing_empty',
- ),
- );
+ ],
+ ];
// Advertise this table as a possible base table.
$data['block_content_field_revision']['table']['base']['help'] = $this->t('Block Content revision is a history of changes to block content.');
$data['block_content_field_revision']['table']['base']['defaults']['title'] = 'info';
diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php
index 1caad741535..7c1f8aac335 100644
--- a/core/modules/block_content/src/Controller/BlockContentController.php
+++ b/core/modules/block_content/src/Controller/BlockContentController.php
@@ -79,14 +79,14 @@ class BlockContentController extends ControllerBase {
return $this->addForm($type, $request);
}
if (count($types) === 0) {
- return array(
+ return [
'#markup' => $this->t('You have not created any block types yet. Go to the <a href=":url">block type creation page</a> to add a new block type.', [
':url' => Url::fromRoute('block_content.type_add')->toString(),
]),
- );
+ ];
}
- return array('#theme' => 'block_content_add_list', '#content' => $types);
+ return ['#theme' => 'block_content_add_list', '#content' => $types];
}
/**
@@ -101,9 +101,9 @@ class BlockContentController extends ControllerBase {
* A form array as expected by drupal_render().
*/
public function addForm(BlockContentTypeInterface $block_content_type, Request $request) {
- $block = $this->blockContentStorage->create(array(
+ $block = $this->blockContentStorage->create([
'type' => $block_content_type->id()
- ));
+ ]);
if (($theme = $request->query->get('theme')) && in_array($theme, array_keys($this->themeHandler->listInfo()))) {
// We have navigated to this page from the block library and will keep track
// of the theme for redirecting the user to the configuration page for the
@@ -123,7 +123,7 @@ class BlockContentController extends ControllerBase {
* The page title.
*/
public function getAddFormTitle(BlockContentTypeInterface $block_content_type) {
- return $this->t('Add %type custom block', array('%type' => $block_content_type->label()));
+ return $this->t('Add %type custom block', ['%type' => $block_content_type->label()]);
}
}
diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php
index 7c06ed869ee..11c0c5470d8 100644
--- a/core/modules/block_content/src/Entity/BlockContent.php
+++ b/core/modules/block_content/src/Entity/BlockContent.php
@@ -126,7 +126,7 @@ class BlockContent extends ContentEntityBase implements BlockContentInterface {
* {@inheritdoc}
*/
public function getInstances() {
- return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('plugin' => 'block_content:' . $this->uuid()));
+ return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['plugin' => 'block_content:' . $this->uuid()]);
}
/**
@@ -178,10 +178,10 @@ class BlockContent extends ContentEntityBase implements BlockContentInterface {
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setRequired(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ))
+ ])
->setDisplayConfigurable('form', TRUE)
->addConstraint('UniqueField', []);
@@ -189,13 +189,13 @@ class BlockContent extends ContentEntityBase implements BlockContentInterface {
->setLabel(t('Revision log message'))
->setDescription(t('The log entry explaining the changes in this revision.'))
->setRevisionable(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textarea',
'weight' => 25,
- 'settings' => array(
+ 'settings' => [
'rows' => 4,
- ),
- ));
+ ],
+ ]);
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
diff --git a/core/modules/block_content/src/Form/BlockContentDeleteForm.php b/core/modules/block_content/src/Form/BlockContentDeleteForm.php
index 3fe725daa89..035ec4c2fb5 100644
--- a/core/modules/block_content/src/Form/BlockContentDeleteForm.php
+++ b/core/modules/block_content/src/Form/BlockContentDeleteForm.php
@@ -16,10 +16,10 @@ class BlockContentDeleteForm extends ContentEntityDeleteForm {
public function buildForm(array $form, FormStateInterface $form_state) {
$instances = $this->entity->getInstances();
- $form['message'] = array(
+ $form['message'] = [
'#markup' => $this->formatPlural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'),
'#access' => !empty($instances),
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php
index b68e695b38a..aea4ab5e835 100644
--- a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php
+++ b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php
@@ -18,8 +18,8 @@ class BlockContentTypeDeleteForm extends EntityDeleteForm {
->condition('type', $this->entity->id())
->execute();
if (!empty($blocks)) {
- $caption = '<p>' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '</p>';
- $form['description'] = array('#markup' => $caption);
+ $caption = '<p>' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', ['%label' => $this->entity->label()]) . '</p>';
+ $form['description'] = ['#markup' => $caption];
return $form;
}
else {
diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php
index 2afd0402ebf..e97e740187e 100644
--- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php
+++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php
@@ -105,11 +105,11 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'status' => TRUE,
'info' => '',
'view_mode' => 'full',
- );
+ ];
}
/**
@@ -122,14 +122,14 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
$block = $this->entityManager->loadEntityByUuid('block_content', $uuid);
$options = $this->entityManager->getViewModeOptionsByBundle('block_content', $block->bundle());
- $form['view_mode'] = array(
+ $form['view_mode'] = [
'#type' => 'select',
'#options' => $options,
'#title' => $this->t('View mode'),
'#description' => $this->t('Output the block in this view mode.'),
'#default_value' => $this->configuration['view_mode'],
'#access' => (count($options) > 1),
- );
+ ];
$form['title']['#description'] = $this->t('The title of the block as shown to the user.');
return $form;
}
@@ -161,13 +161,13 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
return $this->entityManager->getViewBuilder($block->getEntityTypeId())->view($block, $this->configuration['view_mode']);
}
else {
- return array(
- '#markup' => $this->t('Block with uuid %uuid does not exist. <a href=":url">Add custom block</a>.', array(
+ return [
+ '#markup' => $this->t('Block with uuid %uuid does not exist. <a href=":url">Add custom block</a>.', [
'%uuid' => $this->getDerivativeId(),
':url' => $this->urlGenerator->generate('block_content.add_page')
- )),
+ ]),
'#access' => $this->account->hasPermission('administer blocks')
- );
+ ];
}
}
diff --git a/core/modules/block_content/src/Plugin/Derivative/BlockContent.php b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php
index ab564451cb2..25806c5f132 100644
--- a/core/modules/block_content/src/Plugin/Derivative/BlockContent.php
+++ b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php
@@ -50,9 +50,9 @@ class BlockContent extends DeriverBase implements ContainerDeriverInterface {
foreach ($block_contents as $block_content) {
$this->derivatives[$block_content->uuid()] = $base_plugin_definition;
$this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label();
- $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = array(
+ $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = [
$block_content->getConfigDependencyName()
- );
+ ];
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
diff --git a/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php b/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php
index 41352336b40..a28927bd588 100644
--- a/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php
+++ b/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php
@@ -18,7 +18,7 @@ class Box extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('boxes', 'b')
- ->fields('b', array('bid', 'body', 'info', 'format'));
+ ->fields('b', ['bid', 'body', 'info', 'format']);
$query->orderBy('b.bid');
return $query;
@@ -28,12 +28,12 @@ class Box extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'bid' => $this->t('The numeric identifier of the block/box'),
'body' => $this->t('The block/box content'),
'info' => $this->t('Admin title of the block/box.'),
'format' => $this->t('Input format of the custom block/box content.'),
- );
+ ];
}
/**
diff --git a/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php b/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php
index 4aee2a4599b..ea336829bfb 100644
--- a/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php
+++ b/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php
@@ -24,12 +24,12 @@ class BlockCustom extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'bid' => $this->t('The numeric identifier of the block/box'),
'body' => $this->t('The block/box content'),
'info' => $this->t('Admin title of the block/box.'),
'format' => $this->t('Input format of the custom block/box content.'),
- );
+ ];
}
/**
diff --git a/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php b/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php
index d2bd0261572..e412f182ec7 100644
--- a/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php
+++ b/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php
@@ -71,19 +71,19 @@ class ListingEmpty extends AreaPluginBase {
public function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
/** @var \Drupal\Core\Access\AccessResultInterface|\Drupal\Core\Cache\CacheableDependencyInterface $access_result */
- $access_result = $this->accessManager->checkNamedRoute('block_content.add_page', array(), $this->currentUser, TRUE);
- $element = array(
- '#markup' => $this->t('Add a <a href=":url">custom block</a>.', array(':url' => Url::fromRoute('block_content.add_page')->toString())),
+ $access_result = $this->accessManager->checkNamedRoute('block_content.add_page', [], $this->currentUser, TRUE);
+ $element = [
+ '#markup' => $this->t('Add a <a href=":url">custom block</a>.', [':url' => Url::fromRoute('block_content.add_page')->toString()]),
'#access' => $access_result->isAllowed(),
'#cache' => [
'contexts' => $access_result->getCacheContexts(),
'tags' => $access_result->getCacheTags(),
'max-age' => $access_result->getCacheMaxAge(),
],
- );
+ ];
return $element;
}
- return array();
+ return [];
}
}
diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php
index e45892c5c3c..ac9e824d494 100644
--- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php
@@ -21,17 +21,17 @@ class BlockContentCreationTest extends BlockContentTestBase {
*
* @var array
*/
- public static $modules = array('block_content_test', 'dblog', 'field_ui');
+ public static $modules = ['block_content_test', 'dblog', 'field_ui'];
/**
* Permissions to grant admin user.
*
* @var array
*/
- protected $permissions = array(
+ protected $permissions = [
'administer blocks',
'administer block_content display'
- );
+ ];
/**
* Sets the test up.
@@ -48,22 +48,22 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->drupalLogin($this->adminUser);
// Create a block.
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = 'Test Block';
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Check that the Basic block has been created.
- $this->assertRaw(format_string('@block %name has been created.', array(
+ $this->assertRaw(format_string('@block %name has been created.', [
'@block' => 'basic',
'%name' => $edit['info[0][value]']
- )), 'Basic block created.');
+ ]), 'Basic block created.');
// Check that the view mode setting is hidden because only one exists.
$this->assertNoFieldByXPath('//select[@name="settings[view_mode]"]', NULL, 'View mode setting hidden because only one exists');
// Check that the block exists in the database.
- $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]']));
+ $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]);
$block = reset($blocks);
$this->assertTrue($block, 'Custom Block found in database.');
@@ -72,9 +72,9 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Check that the Basic block has been created.
- $this->assertRaw(format_string('A custom block with block description %value already exists.', array(
+ $this->assertRaw(format_string('A custom block with block description %value already exists.', [
'%value' => $edit['info[0][value]']
- )));
+ ]));
$this->assertResponse(200);
}
@@ -83,28 +83,28 @@ class BlockContentCreationTest extends BlockContentTestBase {
*/
public function testBlockContentCreationMultipleViewModes() {
// Add a new view mode and verify if it is selected as expected.
- $this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
+ $this->drupalLogin($this->drupalCreateUser(['administer display modes']));
$this->drupalGet('admin/structure/display-modes/view/add/block_content');
- $edit = array(
+ $edit = [
'id' => 'test_view_mode',
'label' => 'Test View Mode',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('Saved the %label view mode.', array('%label' => $edit['label'])));
+ $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
$this->drupalLogin($this->adminUser);
// Create a block.
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = 'Test Block';
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Check that the Basic block has been created.
- $this->assertRaw(format_string('@block %name has been created.', array(
+ $this->assertRaw(format_string('@block %name has been created.', [
'@block' => 'basic',
'%name' => $edit['info[0][value]']
- )), 'Basic block created.');
+ ]), 'Basic block created.');
// Save our block permanently
$this->drupalPostForm(NULL, ['region' => 'content'], t('Save block'));
@@ -114,9 +114,9 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->drupalGet('admin/structure/block/block-content/types');
$this->clickLink(t('Manage display'));
$this->drupalGet('admin/structure/block/block-content/manage/basic/display');
- $custom_view_mode = array(
+ $custom_view_mode = [
'display_modes_custom[test_view_mode]' => 1,
- );
+ ];
$this->drupalPostForm(NULL, $custom_view_mode, t('Save'));
// Go to the configure page and change the view mode.
@@ -143,7 +143,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->assertFieldByXPath('//select[@name="settings[view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode');
// Check that the block exists in the database.
- $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]']));
+ $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]);
$block = reset($blocks);
$this->assertTrue($block, 'Custom Block found in database.');
@@ -152,9 +152,9 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Check that the Basic block has been created.
- $this->assertRaw(format_string('A custom block with block description %value already exists.', array(
+ $this->assertRaw(format_string('A custom block with block description %value already exists.', [
'%value' => $edit['info[0][value]']
- )));
+ ]));
$this->assertResponse(200);
}
@@ -165,20 +165,20 @@ class BlockContentCreationTest extends BlockContentTestBase {
* type is being used.
*/
public function testDefaultBlockContentCreation() {
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
// Don't pass the custom block type in the url so the default is forced.
$this->drupalPostForm('block/add', $edit, t('Save'));
// Check that the block has been created and that it is a basic block.
- $this->assertRaw(format_string('@block %name has been created.', array(
+ $this->assertRaw(format_string('@block %name has been created.', [
'@block' => 'basic',
'%name' => $edit['info[0][value]'],
- )), 'Basic block created.');
+ ]), 'Basic block created.');
// Check that the block exists in the database.
- $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]']));
+ $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]);
$block = reset($blocks);
$this->assertTrue($block, 'Default Custom Block found in database.');
}
@@ -199,7 +199,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
if (Database::getConnection()->supportsTransactions()) {
// Check that the block does not exist in the database.
$id = db_select('block_content_field_data', 'b')
- ->fields('b', array('id'))
+ ->fields('b', ['id'])
->condition('info', 'fail_creation')
->execute()
->fetchField();
@@ -208,7 +208,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
else {
// Check that the block exists in the database.
$id = db_select('block_content_field_data', 'b')
- ->fields('b', array('id'))
+ ->fields('b', ['id'])
->condition('info', 'fail_creation')
->execute()
->fetchField();
@@ -225,18 +225,18 @@ class BlockContentCreationTest extends BlockContentTestBase {
*/
public function testBlockDelete() {
// Create a block.
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = $this->randomMachineName(8);
$body = $this->randomMachineName(16);
$edit['body[0][value]'] = $body;
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Place the block.
- $instance = array(
+ $instance = [
'id' => Unicode::strtolower($edit['info[0][value]']),
'settings[label]' => $edit['info[0][value]'],
'region' => 'sidebar_first',
- );
+ ];
$block = BlockContent::load(1);
$url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default');
$this->drupalPostForm($url, $instance, t('Save block'));
@@ -254,11 +254,11 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->drupalGet('block/1/delete');
$this->assertText(\Drupal::translation()->formatPlural(1, 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instance.'));
- $this->drupalPostForm(NULL, array(), 'Delete');
- $this->assertRaw(t('The custom block %name has been deleted.', array('%name' => $edit['info[0][value]'])));
+ $this->drupalPostForm(NULL, [], 'Delete');
+ $this->assertRaw(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']]));
// Create another block and force the plugin cache to flush.
- $edit2 = array();
+ $edit2 = [];
$edit2['info[0][value]'] = $this->randomMachineName(8);
$body2 = $this->randomMachineName(16);
$edit2['body[0][value]'] = $body2;
@@ -268,7 +268,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
// Create another block with no instances, and test we don't get a
// confirmation message about deleting instances.
- $edit3 = array();
+ $edit3 = [];
$edit3['info[0][value]'] = $this->randomMachineName(8);
$body = $this->randomMachineName(16);
$edit3['body[0][value]'] = $body;
@@ -286,16 +286,16 @@ class BlockContentCreationTest extends BlockContentTestBase {
$block = $this->createBlockContent();
// Place the block.
$block_placement_id = Unicode::strtolower($block->label());
- $instance = array(
+ $instance = [
'id' => $block_placement_id,
'settings[label]' => $block->label(),
'region' => 'sidebar_first',
- );
+ ];
$block = BlockContent::load(1);
$url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default');
$this->drupalPostForm($url, $instance, t('Save block'));
- $dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('content', array($block->getConfigDependencyName()));
+ $dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('content', [$block->getConfigDependencyName()]);
$block_placement = reset($dependencies);
$this->assertEqual($block_placement_id, $block_placement->id(), "The block placement config entity has a dependency on the block content entity.");
}
diff --git a/core/modules/block_content/src/Tests/BlockContentListTest.php b/core/modules/block_content/src/Tests/BlockContentListTest.php
index be8ea5e4c8b..e00706e9ff5 100644
--- a/core/modules/block_content/src/Tests/BlockContentListTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentListTest.php
@@ -18,13 +18,13 @@ class BlockContentListTest extends BlockContentTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_content', 'config_translation');
+ public static $modules = ['block', 'block_content', 'config_translation'];
/**
* Tests the custom block listing page.
*/
public function testListing() {
- $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration']));
$this->drupalGet('admin/structure/block/block-content');
// Test for the page title.
@@ -39,7 +39,7 @@ class BlockContentListTest extends BlockContentTestBase {
$this->assertEqual(count($elements), 2, 'Correct number of table header cells found.');
// Test the contents of each th cell.
- $expected_items = array(t('Block description'), t('Operations'));
+ $expected_items = [t('Block description'), t('Operations')];
foreach ($elements as $key => $element) {
$this->assertEqual($element[0], $expected_items[$key]);
}
@@ -51,7 +51,7 @@ class BlockContentListTest extends BlockContentTestBase {
$this->assertLink($link_text);
$this->clickLink($link_text);
$this->assertResponse(200);
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = $label;
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm(NULL, $edit, t('Save'));
@@ -72,14 +72,14 @@ class BlockContentListTest extends BlockContentTestBase {
$blocks = $this->container
->get('entity.manager')
->getStorage('block_content')
- ->loadByProperties(array('info' => $label));
+ ->loadByProperties(['info' => $label]);
$block = reset($blocks);
if (!empty($block)) {
$this->assertLinkByHref('block/' . $block->id());
$this->clickLink(t('Edit'));
$this->assertResponse(200);
- $this->assertTitle(strip_tags(t('Edit custom block %label', array('%label' => $label)) . ' | Drupal'));
- $edit = array('info[0][value]' => $new_label);
+ $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal'));
+ $edit = ['info[0][value]' => $new_label];
$this->drupalPostForm(NULL, $edit, t('Save'));
}
else {
@@ -95,8 +95,8 @@ class BlockContentListTest extends BlockContentTestBase {
$delete_text = t('Delete');
$this->clickLink($delete_text);
$this->assertResponse(200);
- $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', array('%label' => $new_label)) . ' | Drupal'));
- $this->drupalPostForm(NULL, array(), $delete_text);
+ $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal'));
+ $this->drupalPostForm(NULL, [], $delete_text);
// Verify that the text of the label and machine name does not appear in
// the list (though it may appear elsewhere on the page).
diff --git a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php
index de0ff3bdeb3..77117fb009f 100644
--- a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php
@@ -22,7 +22,7 @@ class BlockContentListViewsTest extends BlockContentTestBase {
* Tests the custom block listing page.
*/
public function testListing() {
- $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration']));
$this->drupalGet('admin/structure/block/block-content');
// Test for the page title.
@@ -58,7 +58,7 @@ class BlockContentListViewsTest extends BlockContentTestBase {
$this->assertLink($link_text);
$this->clickLink($link_text);
$this->assertResponse(200);
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = $label;
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm(NULL, $edit, t('Save'));
@@ -79,14 +79,14 @@ class BlockContentListViewsTest extends BlockContentTestBase {
$blocks = $this->container
->get('entity.manager')
->getStorage('block_content')
- ->loadByProperties(array('info' => $label));
+ ->loadByProperties(['info' => $label]);
$block = reset($blocks);
if (!empty($block)) {
$this->assertLinkByHref('block/' . $block->id());
$this->clickLink(t('Edit'));
$this->assertResponse(200);
- $this->assertTitle(strip_tags(t('Edit custom block %label', array('%label' => $label)) . ' | Drupal'));
- $edit = array('info[0][value]' => $new_label);
+ $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal'));
+ $edit = ['info[0][value]' => $new_label];
$this->drupalPostForm(NULL, $edit, t('Save'));
}
else {
@@ -102,8 +102,8 @@ class BlockContentListViewsTest extends BlockContentTestBase {
$delete_text = t('Delete');
$this->clickLink($delete_text);
$this->assertResponse(200);
- $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', array('%label' => $new_label)) . ' | Drupal'));
- $this->drupalPostForm(NULL, array(), $delete_text);
+ $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal'));
+ $this->drupalPostForm(NULL, [], $delete_text);
// Verify that the text of the label and machine name does not appear in
// the list (though it may appear elsewhere on the page).
diff --git a/core/modules/block_content/src/Tests/BlockContentTestBase.php b/core/modules/block_content/src/Tests/BlockContentTestBase.php
index 28c6e227efb..3794478d52f 100644
--- a/core/modules/block_content/src/Tests/BlockContentTestBase.php
+++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php
@@ -31,16 +31,16 @@ abstract class BlockContentTestBase extends WebTestBase {
*
* @var array
*/
- protected $permissions = array(
+ protected $permissions = [
'administer blocks'
- );
+ ];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('block', 'block_content');
+ public static $modules = ['block', 'block_content'];
/**
* Whether or not to auto-create the basic block type during setup.
@@ -78,11 +78,11 @@ abstract class BlockContentTestBase extends WebTestBase {
*/
protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) {
$title = $title ?: $this->randomMachineName();
- $block_content = BlockContent::create(array(
+ $block_content = BlockContent::create([
'info' => $title,
'type' => $bundle,
'langcode' => 'en'
- ));
+ ]);
if ($block_content && $save === TRUE) {
$block_content->save();
}
@@ -101,11 +101,11 @@ abstract class BlockContentTestBase extends WebTestBase {
* Created custom block type.
*/
protected function createBlockContentType($label, $create_body = FALSE) {
- $bundle = BlockContentType::create(array(
+ $bundle = BlockContentType::create([
'id' => $label,
'label' => $label,
'revision' => FALSE,
- ));
+ ]);
$bundle->save();
if ($create_body) {
block_content_add_body_field($bundle->id());
diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
index 332bf3d7344..198beee8fb3 100644
--- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
+++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
@@ -19,13 +19,13 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'language',
'content_translation',
'block',
'field_ui',
'block_content'
- );
+ ];
/**
* {@inheritdoc}
@@ -57,11 +57,11 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
*/
protected function setupBundle() {
// Create the basic bundle since it is provided by standard.
- $bundle = BlockContentType::create(array(
+ $bundle = BlockContentType::create([
'id' => $this->bundle,
'label' => $this->bundle,
'revision' => FALSE
- ));
+ ]);
$bundle->save();
}
@@ -69,12 +69,12 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
public function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array(
+ return array_merge(parent::getTranslatorPermissions(), [
'translate any entity',
'access administration pages',
'administer blocks',
'administer block_content fields'
- ));
+ ]);
}
/**
@@ -93,11 +93,11 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
protected function createBlockContent($title = FALSE, $bundle = FALSE) {
$title = $title ?: $this->randomMachineName();
$bundle = $bundle ?: $this->bundle;
- $block_content = BlockContent::create(array(
+ $block_content = BlockContent::create([
'info' => $title,
'type' => $bundle,
'langcode' => 'en'
- ));
+ ]);
$block_content->save();
return $block_content;
}
@@ -106,7 +106,7 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getNewEntityValues($langcode) {
- return array('info' => Unicode::strtolower($this->randomMachineName())) + parent::getNewEntityValues($langcode);
+ return ['info' => Unicode::strtolower($this->randomMachineName())] + parent::getNewEntityValues($langcode);
}
/**
@@ -135,7 +135,7 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
$values = $this->getNewEntityValues($default_langcode);
$storage = \Drupal::entityManager()->getStorage($this->entityTypeId);
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
- $entity = $storage->create(array('type' => 'basic') + $values);
+ $entity = $storage->create(['type' => 'basic'] + $values);
$entity->save();
$entity->addTranslation('it', $values);
@@ -159,11 +159,11 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
public function testDisabledBundle() {
// Create a bundle that does not have translation enabled.
$disabled_bundle = $this->randomMachineName();
- $bundle = BlockContentType::create(array(
+ $bundle = BlockContentType::create([
'id' => $disabled_bundle,
'label' => $disabled_bundle,
'revision' => FALSE
- ));
+ ]);
$bundle->save();
// Create a block content for each bundle.
@@ -171,7 +171,7 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
$disabled_block_content = $this->createBlockContent(FALSE, $bundle->id());
// Make sure that only a single row was inserted into the block table.
- $rows = db_query('SELECT * FROM {block_content_field_data} WHERE id = :id', array(':id' => $enabled_block_content->id()))->fetchAll();
+ $rows = db_query('SELECT * FROM {block_content_field_data} WHERE id = :id', [':id' => $enabled_block_content->id()])->fetchAll();
$this->assertEqual(1, count($rows));
}
@@ -188,15 +188,15 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('<em>Edit @type</em> @title [%language translation]', array(
+ $title = t('<em>Edit @type</em> @title [%language translation]', [
'@type' => $entity->bundle(),
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php
index 8f6ffe19d8f..e69394b8835 100644
--- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php
@@ -17,17 +17,17 @@ class BlockContentTypeTest extends BlockContentTestBase {
*
* @var array
*/
- public static $modules = array('field_ui');
+ public static $modules = ['field_ui'];
/**
* Permissions to grant admin user.
*
* @var array
*/
- protected $permissions = array(
+ protected $permissions = [
'administer blocks',
'administer block_content fields'
- );
+ ];
/**
* Whether or not to create an initial block type.
@@ -56,10 +56,10 @@ class BlockContentTypeTest extends BlockContentTestBase {
$this->clickLink('block type creation page');
// Create a block type via the user interface.
- $edit = array(
+ $edit = [
'id' => 'foo',
'label' => 'title for foo',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$block_type = BlockContentType::load('foo');
$this->assertTrue($block_type, 'The new block type has been created.');
@@ -107,9 +107,9 @@ class BlockContentTypeTest extends BlockContentTestBase {
$this->assertRaw('Body', 'Body field was found.');
// Change the block type name.
- $edit = array(
+ $edit = [
'label' => 'Bar',
- );
+ ];
$this->drupalGet('admin/structure/block/block-content/manage/basic');
$this->assertTitle(format_string('Edit @type custom block type | Drupal', ['@type' => 'basic']));
$this->drupalPostForm(NULL, $edit, t('Save'));
@@ -121,9 +121,9 @@ class BlockContentTypeTest extends BlockContentTestBase {
$this->assertUrl(\Drupal::url('block_content.add_form', ['block_content_type' => 'basic'], ['absolute' => TRUE]), [], 'Original machine name was used in URL.');
// Remove the body field.
- $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', [], t('Delete'));
// Resave the settings for this type.
- $this->drupalPostForm('admin/structure/block/block-content/manage/basic', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/block/block-content/manage/basic', [], t('Save'));
// Check that the body field doesn't exist.
$this->drupalGet('block/add/basic');
$this->assertNoRaw('Body', 'Body field was not found.');
@@ -146,7 +146,7 @@ class BlockContentTypeTest extends BlockContentTestBase {
// Attempt to delete the block type, which should not be allowed.
$this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
$this->assertRaw(
- t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', array('%label' => $type->label())),
+ t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', ['%label' => $type->label()]),
'The block type will not be deleted until all blocks of that type are removed.'
);
$this->assertNoText(t('This action cannot be undone.'), 'The block type deletion confirmation form is not available.');
@@ -156,7 +156,7 @@ class BlockContentTypeTest extends BlockContentTestBase {
// Attempt to delete the block type, which should now be allowed.
$this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
$this->assertRaw(
- t('Are you sure you want to delete the custom block type %type?', array('%type' => $type->id())),
+ t('Are you sure you want to delete the custom block type %type?', ['%type' => $type->id()]),
'The block type is available for deletion.'
);
$this->assertText(t('This action cannot be undone.'), 'The custom block type deletion confirmation form is available.');
@@ -197,22 +197,22 @@ class BlockContentTypeTest extends BlockContentTestBase {
$this->clickLink(t('Add custom block'));
// The seven theme has markup inside the link, we cannot use clickLink().
if ($default_theme == 'seven') {
- $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array();
- $this->assertLinkByHref(\Drupal::url('block_content.add_form', array('block_content_type' => 'foo'), $options));
+ $options = $theme != $default_theme ? ['query' => ['theme' => $theme]] : [];
+ $this->assertLinkByHref(\Drupal::url('block_content.add_form', ['block_content_type' => 'foo'], $options));
$this->drupalGet('block/add/foo', $options);
}
else {
$this->clickLink('foo');
}
// Create a new block.
- $edit = array('info[0][value]' => $this->randomMachineName(8));
+ $edit = ['info[0][value]' => $this->randomMachineName(8)];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]']));
+ $blocks = $storage->loadByProperties(['info' => $edit['info[0][value]']]);
if (!empty($blocks)) {
$block = reset($blocks);
- $this->assertUrl(\Drupal::url('block.admin_add', array('plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme), array('absolute' => TRUE)));
+ $this->assertUrl(\Drupal::url('block.admin_add', ['plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme], ['absolute' => TRUE]));
$this->drupalPostForm(NULL, ['region' => 'content'], t('Save block'));
- $this->assertUrl(\Drupal::url('block.admin_display_theme', array('theme' => $theme), array('absolute' => TRUE, 'query' => array('block-placement' => Html::getClass($edit['info[0][value]'])))));
+ $this->assertUrl(\Drupal::url('block.admin_display_theme', ['theme' => $theme], ['absolute' => TRUE, 'query' => ['block-placement' => Html::getClass($edit['info[0][value]'])]]));
}
else {
$this->fail('Could not load created block.');
@@ -225,11 +225,11 @@ class BlockContentTypeTest extends BlockContentTestBase {
$this->drupalGet('admin/structure/block/block-content');
$this->clickLink(t('Add custom block'));
$this->clickLink('foo');
- $edit = array('info[0][value]' => $this->randomMachineName(8));
+ $edit = ['info[0][value]' => $this->randomMachineName(8)];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]']));
+ $blocks = $storage->loadByProperties(['info' => $edit['info[0][value]']]);
if (!empty($blocks)) {
- $this->assertUrl(\Drupal::url('entity.block_content.collection', array(), array('absolute' => TRUE)));
+ $this->assertUrl(\Drupal::url('entity.block_content.collection', [], ['absolute' => TRUE]));
}
else {
$this->fail('Could not load created block.');
diff --git a/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php b/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php
index 5a46dddd76c..905a7a0053e 100644
--- a/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php
+++ b/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php
@@ -15,14 +15,14 @@ class BlockContentFieldFilterTest extends BlockContentTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_field_filters');
+ public static $testViews = ['test_field_filters'];
/**
* List of block_content infos by language.
@@ -49,15 +49,15 @@ class BlockContentFieldFilterTest extends BlockContentTestBase {
$field_storage->save();
// Set up block_content infos.
- $this->blockContentInfos = array(
+ $this->blockContentInfos = [
'en' => 'Food in Paris',
'es' => 'Comida en Paris',
'fr' => 'Nouriture en Paris',
- );
+ ];
// Create block_content with translations.
$block_content = $this->createBlockContent(['info' => $this->blockContentInfos['en'], 'langcode' => 'en', 'type' => 'basic', 'body' => [['value' => $this->blockContentInfos['en']]]]);
- foreach (array('es', 'fr') as $langcode) {
+ foreach (['es', 'fr'] as $langcode) {
$translation = $block_content->addTranslation($langcode, ['info' => $this->blockContentInfos[$langcode]]);
$translation->body->value = $this->blockContentInfos[$langcode];
}
@@ -70,19 +70,19 @@ class BlockContentFieldFilterTest extends BlockContentTestBase {
public function testFilters() {
// Test the info filter page, which filters for info contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-info-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida info filter');
+ $this->assertPageCounts('test-info-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida info filter');
// Test the body filter page, which filters for body contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-body-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida body filter');
+ $this->assertPageCounts('test-body-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida body filter');
// Test the info Paris filter page, which filters for info contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-info-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris info filter');
+ $this->assertPageCounts('test-info-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris info filter');
// Test the body Paris filter page, which filters for body contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-body-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris body filter');
+ $this->assertPageCounts('test-body-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris body filter');
}
/**
diff --git a/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php b/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php
index d92c5beb4f0..8ec17e23816 100644
--- a/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php
+++ b/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php
@@ -14,23 +14,23 @@ class BlockContentIntegrationTest extends BlockContentTestBase {
*
* @var array
*/
- public static $testViews = array('test_block_content_view');
+ public static $testViews = ['test_block_content_view'];
/**
* Tests basic block_content view with a block_content_type argument.
*/
public function testBlockContentViewTypeArgument() {
// Create two content types with three block_contents each.
- $types = array();
- $all_ids = array();
- $block_contents = array();
+ $types = [];
+ $all_ids = [];
+ $block_contents = [];
for ($i = 0; $i < 2; $i++) {
$type = $this->createBlockContentType();
$types[] = $type;
for ($j = 0; $j < 5; $j++) {
// Ensure the right order of the block_contents.
- $block_content = $this->createBlockContent(array('type' => $type->id()));
+ $block_content = $this->createBlockContent(['type' => $type->id()]);
$block_contents[$type->id()][$block_content->id()] = $block_content;
$all_ids[] = $block_content->id();
}
@@ -55,9 +55,9 @@ class BlockContentIntegrationTest extends BlockContentTestBase {
* @param array $expected_ids
* An array of block_content IDs.
*/
- protected function assertIds(array $expected_ids = array()) {
+ protected function assertIds(array $expected_ids = []) {
$result = $this->xpath('//span[@class="field-content"]');
- $ids = array();
+ $ids = [];
foreach ($result as $element) {
$ids[] = (int) $element;
}
diff --git a/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php b/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php
index ff80665b579..828aa8468b1 100644
--- a/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php
+++ b/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php
@@ -21,18 +21,18 @@ class BlockContentRedirectTest extends BlockContentTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_content', 'views');
+ public static $modules = ['block', 'block_content', 'views'];
/**
* Tests the redirect destination when editing block content.
*/
public function testRedirectDestination() {
- $this->drupalLogin($this->drupalCreateUser(array('administer blocks')));
+ $this->drupalLogin($this->drupalCreateUser(['administer blocks']));
$this->drupalGet('admin/structure/block/block-content');
// Create a custom block.
$this->clickLink('custom block');
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = 'Test redirect destination';
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm(NULL, $edit, 'Save');
diff --git a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
index 65d33c88b1b..db665c9e45c 100644
--- a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
+++ b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
@@ -25,26 +25,26 @@ abstract class BlockContentTestBase extends ViewTestBase {
*
* @var array
*/
- protected $permissions = array(
+ protected $permissions = [
'administer blocks',
- );
+ ];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('block', 'block_content', 'block_content_test_views');
+ public static $modules = ['block', 'block_content', 'block_content_test_views'];
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
// Ensure the basic bundle exists. This is provided by the standard profile.
- $this->createBlockContentType(array('id' => 'basic'));
+ $this->createBlockContentType(['id' => 'basic']);
$this->adminUser = $this->drupalCreateUser($this->permissions);
if ($import_test_views) {
- ViewTestData::createTestViews(get_class($this), array('block_content_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['block_content_test_views']);
}
}
@@ -58,17 +58,17 @@ abstract class BlockContentTestBase extends ViewTestBase {
* @return \Drupal\block_content\Entity\BlockContent
* Created custom block.
*/
- protected function createBlockContent(array $settings = array()) {
+ protected function createBlockContent(array $settings = []) {
$status = 0;
- $settings += array(
+ $settings += [
'info' => $this->randomMachineName(),
'type' => 'basic',
'langcode' => 'en',
- );
+ ];
if ($block_content = BlockContent::create($settings)) {
$status = $block_content->save();
}
- $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', array('%info' => $block_content->label())));
+ $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', ['%info' => $block_content->label()]));
return $block_content;
}
@@ -81,7 +81,7 @@ abstract class BlockContentTestBase extends ViewTestBase {
* @return \Drupal\block_content\Entity\BlockContentType
* Created custom block type.
*/
- protected function createBlockContentType(array $values = array()) {
+ protected function createBlockContentType(array $values = []) {
// Find a non-existent random type name.
if (!isset($values['id'])) {
do {
@@ -91,16 +91,16 @@ abstract class BlockContentTestBase extends ViewTestBase {
else {
$id = $values['id'];
}
- $values += array(
+ $values += [
'id' => $id,
'label' => $id,
'revision' => FALSE
- );
+ ];
$bundle = BlockContentType::create($values);
$status = $bundle->save();
block_content_add_body_field($bundle->id());
- $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', array('%bundle' => $bundle->id())));
+ $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', ['%bundle' => $bundle->id()]));
return $bundle;
}
diff --git a/core/modules/block_content/src/Tests/Views/FieldTypeTest.php b/core/modules/block_content/src/Tests/Views/FieldTypeTest.php
index f14653fea3d..e9aa3369853 100644
--- a/core/modules/block_content/src/Tests/Views/FieldTypeTest.php
+++ b/core/modules/block_content/src/Tests/Views/FieldTypeTest.php
@@ -16,18 +16,18 @@ class FieldTypeTest extends BlockContentTestBase {
*
* @var array
*/
- public static $testViews = array('test_field_type');
+ public static $testViews = ['test_field_type'];
public function testFieldType() {
$block_content = $this->createBlockContent();
- $expected_result[] = array(
+ $expected_result[] = [
'id' => $block_content->id(),
'type' => $block_content->bundle(),
- );
- $column_map = array(
+ ];
+ $column_map = [
'id' => 'id',
'type:target_id' => 'type',
- );
+ ];
$view = Views::getView('test_field_type');
$this->executeView($view);
diff --git a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php
index 516705d2b22..7bad093dd3a 100644
--- a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php
+++ b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php
@@ -20,72 +20,72 @@ class RevisionRelationshipsTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('block_content' , 'block_content_test_views');
+ public static $modules = ['block_content' , 'block_content_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_block_content_revision_id', 'test_block_content_revision_revision_id');
+ public static $testViews = ['test_block_content_revision_id', 'test_block_content_revision_revision_id'];
protected function setUp() {
parent::setUp();
- BlockContentType::create(array(
+ BlockContentType::create([
'id' => 'basic',
'label' => 'basic',
'revision' => TRUE,
- ));
- ViewTestData::createTestViews(get_class($this), array('block_content_test_views'));
+ ]);
+ ViewTestData::createTestViews(get_class($this), ['block_content_test_views']);
}
/**
* Create a block_content with revision and rest result count for both views.
*/
public function testBlockContentRevisionRelationship() {
- $block_content = BlockContent::create(array(
+ $block_content = BlockContent::create([
'info' => $this->randomMachineName(),
'type' => 'basic',
'langcode' => 'en',
- ));
+ ]);
$block_content->save();
// Create revision of the block_content.
$block_content_revision = clone $block_content;
$block_content_revision->setNewRevision();
$block_content_revision->save();
- $column_map = array(
+ $column_map = [
'revision_id' => 'revision_id',
'id_1' => 'id_1',
'block_content_field_data_block_content_field_revision_id' => 'block_content_field_data_block_content_field_revision_id',
- );
+ ];
// Here should be two rows.
$view_id = Views::getView('test_block_content_revision_id');
- $this->executeView($view_id, array($block_content->id()));
- $resultset_id = array(
- array(
+ $this->executeView($view_id, [$block_content->id()]);
+ $resultset_id = [
+ [
'revision_id' => '1',
'id_1' => '1',
'block_content_field_data_block_content_field_revision_id' => '1',
- ),
- array(
+ ],
+ [
'revision_id' => '2',
'id_1' => '1',
'block_content_field_data_block_content_field_revision_id' => '1',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view_id, $resultset_id, $column_map);
// There should be only one row with active revision 2.
$view_revision_id = Views::getView('test_block_content_revision_revision_id');
- $this->executeView($view_revision_id, array($block_content->id()));
- $resultset_revision_id = array(
- array(
+ $this->executeView($view_revision_id, [$block_content->id()]);
+ $resultset_revision_id = [
+ [
'revision_id' => '2',
'id_1' => '1',
'block_content_field_data_block_content_field_revision_id' => '1',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view_revision_id, $resultset_revision_id, $column_map);
}
diff --git a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module
index 57ea2a6864c..0489a617b62 100644
--- a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module
+++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module
@@ -15,9 +15,9 @@ use Drupal\block_content\Entity\BlockContent;
*/
function block_content_test_block_content_view(array &$build, BlockContent $block_content, $view_mode) {
// Add extra content.
- $build['extra_content'] = array(
+ $build['extra_content'] = [
'#markup' => '<blink>Yowser</blink>',
- );
+ ];
}
/**
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php
index f44a773bfd1..e00de6b5a92 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php
@@ -20,29 +20,29 @@ class BlockContentCacheTagsTest extends EntityCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('block_content');
+ public static $modules = ['block_content'];
/**
* {@inheritdoc}
*/
protected function createEntity() {
- $block_content_type = BlockContentType::create(array(
+ $block_content_type = BlockContentType::create([
'id' => 'basic',
'label' => 'basic',
'revision' => FALSE
- ));
+ ]);
$block_content_type->save();
block_content_add_body_field($block_content_type->id());
// Create a "Llama" custom block.
- $block_content = BlockContent::create(array(
+ $block_content = BlockContent::create([
'info' => 'Llama',
'type' => 'basic',
- 'body' => array(
+ 'body' => [
'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
'format' => 'plain_text',
- ),
- ));
+ ],
+ ]);
$block_content->save();
return $block_content;
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
index 8c55da3c0cd..355faf1f0f4 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
@@ -14,7 +14,7 @@ class BlockContentPageViewTest extends BlockContentTestBase {
*
* @var array
*/
- public static $modules = array('block_content_test');
+ public static $modules = ['block_content_test'];
/**
* Checks block edit and fallback functionality.
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php
index 33f75ed4fa8..fa88c64c261 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php
@@ -37,8 +37,8 @@ class BlockContentRevisionsTest extends BlockContentTestBase {
// Create initial block.
$block = $this->createBlockContent('initial');
- $blocks = array();
- $logs = array();
+ $blocks = [];
+ $logs = [];
// Get original block.
$blocks[] = $block->getRevisionId();
@@ -74,9 +74,9 @@ class BlockContentRevisionsTest extends BlockContentTestBase {
->getStorage('block_content')
->loadRevision($revision_id);
// Verify revision log is the same.
- $this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], format_string('Correct log message found for revision @revision', array(
+ $this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], format_string('Correct log message found for revision @revision', [
'@revision' => $loaded->getRevisionId(),
- )));
+ ]));
if ($delta > 0) {
$this->assertTrue($loaded->getRevisionUser() instanceof UserInterface, 'Revision User found.');
$this->assertTrue(is_numeric($loaded->getRevisionUserId()), 'Revision User ID found.');
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php b/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php
index a68f4233df4..0f7ae5a2e68 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php
@@ -16,7 +16,7 @@ class BlockContentSaveTest extends BlockContentTestBase {
*
* @var array
*/
- public static $modules = array('block_content_test');
+ public static $modules = ['block_content_test'];
/**
* Sets the test up.
@@ -35,12 +35,12 @@ class BlockContentSaveTest extends BlockContentTestBase {
$max_id = db_query('SELECT MAX(id) FROM {block_content}')->fetchField();
$test_id = $max_id + mt_rand(1000, 1000000);
$info = $this->randomMachineName(8);
- $block_array = array(
+ $block_array = [
'info' => $info,
- 'body' => array('value' => $this->randomMachineName(32)),
+ 'body' => ['value' => $this->randomMachineName(32)],
'type' => 'basic',
'id' => $test_id
- );
+ ];
$block = BlockContent::create($block_array);
$block->enforceIsNew(TRUE);
$block->save();
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
index e5e7736409b..45c7e269998 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
@@ -28,16 +28,16 @@ abstract class BlockContentTestBase extends BrowserTestBase {
*
* @var array
*/
- protected $permissions = array(
+ protected $permissions = [
'administer blocks'
- );
+ ];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('block', 'block_content');
+ public static $modules = ['block', 'block_content'];
/**
* Whether or not to auto-create the basic block type during setup.
@@ -75,11 +75,11 @@ abstract class BlockContentTestBase extends BrowserTestBase {
*/
protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) {
$title = $title ?: $this->randomMachineName();
- $block_content = BlockContent::create(array(
+ $block_content = BlockContent::create([
'info' => $title,
'type' => $bundle,
'langcode' => 'en'
- ));
+ ]);
if ($block_content && $save === TRUE) {
$block_content->save();
}
@@ -98,11 +98,11 @@ abstract class BlockContentTestBase extends BrowserTestBase {
* Created custom block type.
*/
protected function createBlockContentType($label, $create_body = FALSE) {
- $bundle = BlockContentType::create(array(
+ $bundle = BlockContentType::create([
'id' => $label,
'label' => $label,
'revision' => FALSE,
- ));
+ ]);
$bundle->save();
if ($create_body) {
block_content_add_body_field($bundle->id());
diff --git a/core/modules/block_content/tests/src/Functional/PageEditTest.php b/core/modules/block_content/tests/src/Functional/PageEditTest.php
index bab2a2992b5..41638bd2bc2 100644
--- a/core/modules/block_content/tests/src/Functional/PageEditTest.php
+++ b/core/modules/block_content/tests/src/Functional/PageEditTest.php
@@ -27,7 +27,7 @@ class PageEditTest extends BlockContentTestBase {
$title_key = 'info[0][value]';
$body_key = 'body[0][value]';
// Create block to edit.
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = Unicode::strtolower($this->randomMachineName(8));
$edit[$body_key] = $this->randomMachineName(16);
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
@@ -43,7 +43,7 @@ class PageEditTest extends BlockContentTestBase {
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
// Edit the content of the block.
- $edit = array();
+ $edit = [];
$edit[$title_key] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
// Stay on the current page, without reloading.
@@ -51,21 +51,21 @@ class PageEditTest extends BlockContentTestBase {
// Edit the same block, creating a new revision.
$this->drupalGet("block/" . $block->id());
- $edit = array();
+ $edit = [];
$edit['info[0][value]'] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
$edit['revision'] = TRUE;
$this->drupalPostForm(NULL, $edit, t('Save'));
// Ensure that the block revision has been created.
- \Drupal::entityManager()->getStorage('block_content')->resetCache(array($block->id()));
+ \Drupal::entityManager()->getStorage('block_content')->resetCache([$block->id()]);
$revised_block = BlockContent::load($block->id());
$this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.');
// Test deleting the block.
$this->drupalGet("block/" . $revised_block->id());
$this->clickLink(t('Delete'));
- $this->assertText(format_string('Are you sure you want to delete the custom block @label?', array('@label' => $revised_block->label())));
+ $this->assertText(format_string('Are you sure you want to delete the custom block @label?', ['@label' => $revised_block->label()]));
}
}
diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php
index 0bf29fdc6a2..7d343738c9b 100644
--- a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php
+++ b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php
@@ -15,7 +15,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateBlockContentBodyFieldTest extends MigrateDrupal7TestBase {
- public static $modules = array('block', 'block_content', 'filter', 'text');
+ public static $modules = ['block', 'block_content', 'filter', 'text'];
/**
* {@inheritdoc}
diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php
index 9a3cbf04669..4accc2040b7 100644
--- a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php
+++ b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php
@@ -13,7 +13,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateBlockContentTypeTest extends MigrateDrupal7TestBase {
- public static $modules = array('block', 'block_content', 'filter', 'text');
+ public static $modules = ['block', 'block_content', 'filter', 'text'];
/**
* {@inheritdoc}
diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php
index 42990db760f..706a7ccf05c 100644
--- a/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php
+++ b/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php
@@ -13,11 +13,11 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateCustomBlockTest extends MigrateDrupal7TestBase {
- public static $modules = array(
+ public static $modules = [
'block_content',
'filter',
'text',
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
index 3ab934c0a23..ced7e84c30c 100644
--- a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
+++ b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
@@ -13,32 +13,32 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array(
+ $this->directoryList = [
'block' => 'core/modules/block',
'block_content' => 'core/modules/block_content',
- );
+ ];
parent::setUp();
- $config_factory = $this->getConfigFactoryStub(array('system.theme' => array(
+ $config_factory = $this->getConfigFactoryStub(['system.theme' => [
'default' => 'test_c',
- )));
+ ]]);
- $themes = array();
- $themes['test_a'] = (object) array(
+ $themes = [];
+ $themes['test_a'] = (object) [
'status' => 0,
- );
- $themes['test_b'] = (object) array(
+ ];
+ $themes['test_b'] = (object) [
'status' => 1,
- 'info' => array(
+ 'info' => [
'name' => 'test_b',
- ),
- );
- $themes['test_c'] = (object) array(
+ ],
+ ];
+ $themes['test_c'] = (object) [
'status' => 1,
- 'info' => array(
+ 'info' => [
'name' => 'test_c',
- ),
- );
+ ],
+ ];
$theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler->expects($this->any())
->method('listInfo')
@@ -56,25 +56,25 @@ class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getBlockContentListingRoutes
*/
public function testBlockContentListLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array(
+ $this->assertLocalTasks($route, [
+ 0 => [
'block.admin_display',
'entity.block_content.collection',
- ),
- 1 => array(
+ ],
+ 1 => [
'block_content.list_sub',
'entity.block_content_type.collection',
- ),
- ));
+ ],
+ ]);
}
/**
* Provides a list of routes to test.
*/
public function getBlockContentListingRoutes() {
- return array(
- array('entity.block_content.collection', 'entity.block_content_type.collection'),
- );
+ return [
+ ['entity.block_content.collection', 'entity.block_content_type.collection'],
+ ];
}
}
diff --git a/core/modules/book/book.install b/core/modules/book/book.install
index 76ddc81ed0c..77044833651 100644
--- a/core/modules/book/book.install
+++ b/core/modules/book/book.install
@@ -17,119 +17,119 @@ function book_uninstall() {
* Implements hook_schema().
*/
function book_schema() {
- $schema['book'] = array(
+ $schema['book'] = [
'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "The book page's {node}.nid.",
- ),
- 'bid' => array(
+ ],
+ 'bid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "The book ID is the {book}.nid of the top-level page.",
- ),
- 'pid' => array(
+ ],
+ 'pid' => [
'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its outline.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'has_children' => array(
+ ],
+ 'has_children' => [
'description' => 'Flag indicating whether any nodes have this node as a parent (1 = children exist, 0 = no children).',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'small',
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'description' => 'Weight among book entries in the same book at the same depth.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'depth' => array(
+ ],
+ 'depth' => [
'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'small',
- ),
- 'p1' => array(
+ ],
+ 'p1' => [
'description' => 'The first nid in the materialized path. If N = depth, then pN must equal the nid. If depth > 1 then p(N-1) must equal the pid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p2' => array(
+ ],
+ 'p2' => [
'description' => 'The second nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p3' => array(
+ ],
+ 'p3' => [
'description' => 'The third nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p4' => array(
+ ],
+ 'p4' => [
'description' => 'The fourth nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p5' => array(
+ ],
+ 'p5' => [
'description' => 'The fifth nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p6' => array(
+ ],
+ 'p6' => [
'description' => 'The sixth nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p7' => array(
+ ],
+ 'p7' => [
'description' => 'The seventh nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p8' => array(
+ ],
+ 'p8' => [
'description' => 'The eighth nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'p9' => array(
+ ],
+ 'p9' => [
'description' => 'The ninth nid in the materialized path. See p1.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('nid'),
- 'indexes' => array(
- 'book_parents' => array('bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['nid'],
+ 'indexes' => [
+ 'book_parents' => ['bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'],
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index ecccb745272..988201ee1e5 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -25,17 +25,17 @@ function book_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.book':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type <em>Book page</em>. For more information, see the <a href=":book">online documentation for the Book module</a>.', array(':book' => 'https://www.drupal.org/documentation/modules/book')) . '</p>';
+ $output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type <em>Book page</em>. For more information, see the <a href=":book">online documentation for the Book module</a>.', [':book' => 'https://www.drupal.org/documentation/modules/book']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Adding and managing book content') . '</dt>';
$output .= '<dd>' . t('Books have a hierarchical structure, called a <em>book outline</em>. Each book outline can have nested pages up to nine levels deep. Multiple content types can be configured to behave as a book outline. From the content edit form, it is possible to add a page to a book outline or create a new book.') . '</dd>';
- $output .= '<dd>' . t('You can assign separate permissions for <em>creating new books</em> as well as <em>creating</em>, <em>editing</em> and <em>deleting</em> book content. Users with the <em>Administer book outlines</em> permission can add <em>any</em> type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the <a href=":admin-book">Book list page</a>.', array(':admin-book' => \Drupal::url('book.admin'))) . '</dd>';
+ $output .= '<dd>' . t('You can assign separate permissions for <em>creating new books</em> as well as <em>creating</em>, <em>editing</em> and <em>deleting</em> book content. Users with the <em>Administer book outlines</em> permission can add <em>any</em> type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the <a href=":admin-book">Book list page</a>.', [':admin-book' => \Drupal::url('book.admin')]) . '</dd>';
$output .= '<dt>' . t('Configuring content types for books') . '</dt>';
- $output .= '<dd>' . t('The <em>Book page</em> content type is the initial content type enabled for book outlines. On the <a href=":admin-settings">Book settings page</a> you can configure content types that can used in book outlines.', array(':admin-settings' => \Drupal::url('book.settings'))) . '</dd>';
- $output .= '<dd>' . t('Users with the <em>Add content and child pages to books</em> permission will see a link to <em>Add child page</em> when viewing a content item that is part of a book outline. This link will allow users to create a new content item of the content type you select on the <a href=":admin-settings">Book settings page</a>. By default this is the <em>Book page</em> content type.', array(':admin-settings' => \Drupal::url('book.settings'))) . '</dd>';
+ $output .= '<dd>' . t('The <em>Book page</em> content type is the initial content type enabled for book outlines. On the <a href=":admin-settings">Book settings page</a> you can configure content types that can used in book outlines.', [':admin-settings' => \Drupal::url('book.settings')]) . '</dd>';
+ $output .= '<dd>' . t('Users with the <em>Add content and child pages to books</em> permission will see a link to <em>Add child page</em> when viewing a content item that is part of a book outline. This link will allow users to create a new content item of the content type you select on the <a href=":admin-settings">Book settings page</a>. By default this is the <em>Book page</em> content type.', [':admin-settings' => \Drupal::url('book.settings')]) . '</dd>';
$output .= '<dt>' . t('Book navigation') . '</dt>';
- $output .= '<dd>' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the <a href=':admin-block'>Blocks layout page</a>. For book pages to show up in the book navigation, they must be added to a book outline.", array(':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
+ $output .= '<dd>' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the <a href=':admin-block'>Blocks layout page</a>. For book pages to show up in the book navigation, they must be added to a book outline.", [':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
$output .= '<dt>' . t('Collaboration') . '</dt>';
$output .= '<dd>' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents.') . '</dd>';
$output .= '<dt>' . t('Printing books') . '</dt>';
@@ -47,7 +47,7 @@ function book_help($route_name, RouteMatchInterface $route_match) {
return '<p>' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '</p>';
case 'entity.node.book_outline_form':
- return '<p>' . t('The outline feature allows you to include pages in the <a href=":book">Book hierarchy</a>, as well as move them within the hierarchy or to <a href=":book-admin">reorder an entire book</a>.', array(':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin'))) . '</p>';
+ return '<p>' . t('The outline feature allows you to include pages in the <a href=":book">Book hierarchy</a>, as well as move them within the hierarchy or to <a href=":book-admin">reorder an entire book</a>.', [':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin')]) . '</p>';
}
}
@@ -55,23 +55,23 @@ function book_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function book_theme() {
- return array(
- 'book_navigation' => array(
- 'variables' => array('book_link' => NULL),
- ),
- 'book_tree' => array(
- 'variables' => array('items' => array(), 'attributes' => array()),
- ),
- 'book_export_html' => array(
- 'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL),
- ),
- 'book_all_books_block' => array(
+ return [
+ 'book_navigation' => [
+ 'variables' => ['book_link' => NULL],
+ ],
+ 'book_tree' => [
+ 'variables' => ['items' => [], 'attributes' => []],
+ ],
+ 'book_export_html' => [
+ 'variables' => ['title' => NULL, 'contents' => NULL, 'depth' => NULL],
+ ],
+ 'book_all_books_block' => [
'render element' => 'book_menus',
- ),
- 'book_node_export_html' => array(
- 'variables' => array('node' => NULL, 'content' => NULL, 'children' => NULL),
- ),
- );
+ ],
+ 'book_node_export_html' => [
+ 'variables' => ['node' => NULL, 'content' => NULL, 'children' => NULL],
+ ],
+ ];
}
/**
@@ -97,31 +97,31 @@ function book_node_links_alter(array &$links, NodeInterface $node, array &$conte
$child_type = \Drupal::config('book.settings')->get('child_type');
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node');
if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) {
- $book_links['book_add_child'] = array(
+ $book_links['book_add_child'] = [
'title' => t('Add child page'),
'url' => Url::fromRoute('node.add', ['node_type' => $child_type], ['query' => ['parent' => $node->id()]]),
- );
+ ];
}
if ($account->hasPermission('access printer-friendly version')) {
- $book_links['book_printer'] = array(
+ $book_links['book_printer'] = [
'title' => t('Printer-friendly version'),
'url' => Url::fromRoute('book.export', [
'type' => 'html',
'node' => $node->id(),
]),
- 'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
- );
+ 'attributes' => ['title' => t('Show a printer-friendly version of this book page and its sub-pages.')]
+ ];
}
}
}
if (!empty($book_links)) {
- $links['book'] = array(
+ $links['book'] = [
'#theme' => 'links__node__book',
'#links' => $book_links,
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
}
}
}
@@ -148,17 +148,17 @@ function book_form_node_form_alter(&$form, FormStateInterface $form_state, $form
$collapsed = !($node->isNew() && !empty($node->book['pid']));
$form = \Drupal::service('book.manager')->addFormElements($form, $form_state, $node, $account, $collapsed);
// The "js-hide" class hides submit button when Javascript is enabled.
- $form['book']['pick-book'] = array(
+ $form['book']['pick-book'] = [
'#type' => 'submit',
'#value' => t('Change book (update list of parents)'),
- '#submit' => array('book_pick_book_nojs_submit'),
+ '#submit' => ['book_pick_book_nojs_submit'],
'#weight' => 20,
- '#attributes' => array(
- 'class' => array(
+ '#attributes' => [
+ 'class' => [
'js-hide',
- ),
- ),
- );
+ ],
+ ],
+ ];
$form['#entity_builders'][] = 'book_node_builder';
}
}
@@ -232,7 +232,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI
if (!$book_node->access()) {
return;
}
- $build['book_navigation'] = array(
+ $build['book_navigation'] = [
'#theme' => 'book_navigation',
'#book_link' => $node->book,
'#weight' => 100,
@@ -241,7 +241,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI
'#cache' => [
'tags' => $node->getEntityType()->getListCacheTags(),
],
- );
+ ];
}
}
}
@@ -295,7 +295,7 @@ function book_node_prepare_form(NodeInterface $node, $operation, FormStateInterf
// Prepare defaults for the add/edit form.
$account = \Drupal::currentUser();
if (empty($node->book) && ($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines'))) {
- $node->book = array();
+ $node->book = [];
$query = \Drupal::request()->query;
if ($node->isNew() && !is_null($query->get('parent')) && is_numeric($query->get('parent'))) {
@@ -341,10 +341,10 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat
}
if (isset($node->book) && $node->book['has_children']) {
- $form['book_warning'] = array(
- '#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->label())) . '</p>',
+ $form['book_warning'] = [
+ '#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $node->label()]) . '</p>',
'#weight' => -10,
- );
+ ];
}
}
@@ -365,13 +365,13 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat
function template_preprocess_book_all_books_block(&$variables) {
// Remove all non-renderable elements.
$elements = $variables['book_menus'];
- $variables['book_menus'] = array();
+ $variables['book_menus'] = [];
foreach (Element::children($elements) as $index) {
- $variables['book_menus'][] = array(
+ $variables['book_menus'][] = [
'id' => $index,
'menu' => $elements[$index],
'title' => $elements[$index]['#book_title'],
- );
+ ];
}
}
@@ -391,7 +391,7 @@ function template_preprocess_book_navigation(&$variables) {
// Provide extra variables for themers. Not needed by default.
$variables['book_id'] = $book_link['bid'];
$variables['book_title'] = $book_link['link_title'];
- $variables['book_url'] = \Drupal::url('entity.node.canonical', array('node' => $book_link['bid']));
+ $variables['book_url'] = \Drupal::url('entity.node.canonical', ['node' => $book_link['bid']]);
$variables['current_depth'] = $book_link['depth'];
$variables['tree'] = '';
@@ -401,14 +401,14 @@ function template_preprocess_book_navigation(&$variables) {
if ($book_link['nid']) {
$variables['tree'] = $book_outline->childrenLinks($book_link);
- $build = array();
+ $build = [];
if ($prev = $book_outline->prevLink($book_link)) {
- $prev_href = \Drupal::url('entity.node.canonical', array('node' => $prev['nid']));
- $build['#attached']['html_head_link'][][] = array(
+ $prev_href = \Drupal::url('entity.node.canonical', ['node' => $prev['nid']]);
+ $build['#attached']['html_head_link'][][] = [
'rel' => 'prev',
'href' => $prev_href,
- );
+ ];
$variables['prev_url'] = $prev_href;
$variables['prev_title'] = $prev['title'];
}
@@ -416,21 +416,21 @@ function template_preprocess_book_navigation(&$variables) {
/** @var \Drupal\book\BookManagerInterface $book_manager */
$book_manager = \Drupal::service('book.manager');
if ($book_link['pid'] && $parent = $book_manager->loadBookLink($book_link['pid'])) {
- $parent_href = \Drupal::url('entity.node.canonical', array('node' => $book_link['pid']));
- $build['#attached']['html_head_link'][][] = array(
+ $parent_href = \Drupal::url('entity.node.canonical', ['node' => $book_link['pid']]);
+ $build['#attached']['html_head_link'][][] = [
'rel' => 'up',
'href' => $parent_href,
- );
+ ];
$variables['parent_url'] = $parent_href;
$variables['parent_title'] = $parent['title'];
}
if ($next = $book_outline->nextLink($book_link)) {
- $next_href = \Drupal::url('entity.node.canonical', array('node' => $next['nid']));
- $build['#attached']['html_head_link'][][] = array(
+ $next_href = \Drupal::url('entity.node.canonical', ['node' => $next['nid']]);
+ $build['#attached']['html_head_link'][][] = [
'rel' => 'next',
'href' => $next_href,
- );
+ ];
$variables['next_url'] = $next_href;
$variables['next_title'] = $next['title'];
}
@@ -442,7 +442,7 @@ function template_preprocess_book_navigation(&$variables) {
$variables['has_links'] = FALSE;
// Link variables to filter for values and set state of the flag variable.
- $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
+ $links = ['prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title'];
foreach ($links as $link) {
if (isset($variables[$link])) {
// Flag when there is a value.
@@ -475,7 +475,7 @@ function template_preprocess_book_export_html(&$variables) {
$variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL);
// HTML element attributes.
- $attributes = array();
+ $attributes = [];
$attributes['lang'] = $language_interface->getId();
$attributes['dir'] = $language_interface->getDirection();
$variables['html_attributes'] = new Attribute($attributes);
diff --git a/core/modules/book/src/BookBreadcrumbBuilder.php b/core/modules/book/src/BookBreadcrumbBuilder.php
index ed39a53d2e1..90591d8d49b 100644
--- a/core/modules/book/src/BookBreadcrumbBuilder.php
+++ b/core/modules/book/src/BookBreadcrumbBuilder.php
@@ -56,10 +56,10 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
- $book_nids = array();
+ $book_nids = [];
$breadcrumb = new Breadcrumb();
- $links = array(Link::createFromRoute($this->t('Home'), '<front>'));
+ $links = [Link::createFromRoute($this->t('Home'), '<front>')];
$book = $route_match->getParameter('node')->book;
$depth = 1;
// We skip the current node.
@@ -76,7 +76,7 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
$breadcrumb->addCacheableDependency($access);
if ($access->isAllowed()) {
$breadcrumb->addCacheableDependency($parent_book);
- $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id()));
+ $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', ['node' => $parent_book->id()]);
}
}
$depth++;
diff --git a/core/modules/book/src/BookExport.php b/core/modules/book/src/BookExport.php
index 8261c42ea92..a3233700510 100644
--- a/core/modules/book/src/BookExport.php
+++ b/core/modules/book/src/BookExport.php
@@ -73,8 +73,8 @@ class BookExport {
}
$tree = $this->bookManager->bookSubtreeData($node->book);
- $contents = $this->exportTraverse($tree, array($this, 'bookNodeExport'));
- return array(
+ $contents = $this->exportTraverse($tree, [$this, 'bookNodeExport']);
+ return [
'#theme' => 'book_export_html',
'#title' => $node->label(),
'#contents' => $contents,
@@ -82,7 +82,7 @@ class BookExport {
'#cache' => [
'tags' => $node->getEntityType()->getListCacheTags(),
],
- );
+ ];
}
/**
@@ -101,9 +101,9 @@ class BookExport {
*/
protected function exportTraverse(array $tree, $callable) {
// If there is no valid callable, use the default callback.
- $callable = !empty($callable) ? $callable : array($this, 'bookNodeExport');
+ $callable = !empty($callable) ? $callable : [$this, 'bookNodeExport'];
- $build = array();
+ $build = [];
foreach ($tree as $data) {
// Note- access checking is already performed when building the tree.
if ($node = $this->nodeStorage->load($data['link']['nid'])) {
@@ -133,12 +133,12 @@ class BookExport {
$build = $this->viewBuilder->view($node, 'print', NULL);
unset($build['#theme']);
- return array(
+ return [
'#theme' => 'book_node_export_html',
'#content' => $build,
'#node' => $node,
'#children' => $children,
- );
+ ];
}
}
diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php
index 60754be7bd1..3e14c400767 100644
--- a/core/modules/book/src/BookManager.php
+++ b/core/modules/book/src/BookManager.php
@@ -92,7 +92,7 @@ class BookManager implements BookManagerInterface {
* Loads Books Array.
*/
protected function loadBooks() {
- $this->books = array();
+ $this->books = [];
$nids = $this->bookOutlineStorage->getBooks();
if ($nids) {
@@ -117,15 +117,15 @@ class BookManager implements BookManagerInterface {
* {@inheritdoc}
*/
public function getLinkDefaults($nid) {
- return array(
+ return [
'original_bid' => 0,
'nid' => $nid,
'bid' => 0,
'pid' => 0,
'has_children' => 0,
'weight' => 0,
- 'options' => array(),
- );
+ 'options' => [],
+ ];
}
/**
@@ -159,40 +159,40 @@ class BookManager implements BookManagerInterface {
if ($form_state->hasValue('book')) {
$node->book = $form_state->getValue('book');
}
- $form['book'] = array(
+ $form['book'] = [
'#type' => 'details',
'#title' => $this->t('Book outline'),
'#weight' => 10,
'#open' => !$collapsed,
'#group' => 'advanced',
- '#attributes' => array(
- 'class' => array('book-outline-form'),
- ),
- '#attached' => array(
- 'library' => array('book/drupal.book'),
- ),
+ '#attributes' => [
+ 'class' => ['book-outline-form'],
+ ],
+ '#attached' => [
+ 'library' => ['book/drupal.book'],
+ ],
'#tree' => TRUE,
- );
- foreach (array('nid', 'has_children', 'original_bid', 'parent_depth_limit') as $key) {
- $form['book'][$key] = array(
+ ];
+ foreach (['nid', 'has_children', 'original_bid', 'parent_depth_limit'] as $key) {
+ $form['book'][$key] = [
'#type' => 'value',
'#value' => $node->book[$key],
- );
+ ];
}
$form['book']['pid'] = $this->addParentSelectFormElements($node->book);
// @see \Drupal\book\Form\BookAdminEditForm::bookAdminTableTree(). The
// weight may be larger than 15.
- $form['book']['weight'] = array(
+ $form['book']['weight'] = [
'#type' => 'weight',
'#title' => $this->t('Weight'),
'#default_value' => $node->book['weight'],
'#delta' => max(15, abs($node->book['weight'])),
'#weight' => 5,
'#description' => $this->t('Pages at a given level are ordered first by weight and then by title.'),
- );
- $options = array();
+ ];
+ $options = [];
$nid = !$node->isNew() ? $node->id() : 'new';
if ($node->id() && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
// This is the top level node in a maximum depth book and thus cannot be
@@ -207,15 +207,15 @@ class BookManager implements BookManagerInterface {
if ($account->hasPermission('create new books') && ($nid == 'new' || ($nid != $node->book['original_bid']))) {
// The node can become a new book, if it is not one already.
- $options = array($nid => $this->t('- Create a new book -')) + $options;
+ $options = [$nid => $this->t('- Create a new book -')] + $options;
}
if (!$node->book['bid']) {
// The node is not currently in the hierarchy.
- $options = array(0 => $this->t('- None -')) + $options;
+ $options = [0 => $this->t('- None -')] + $options;
}
// Add a drop-down to select the destination book.
- $form['book']['bid'] = array(
+ $form['book']['bid'] = [
'#type' => 'select',
'#title' => $this->t('Book'),
'#default_value' => $node->book['bid'],
@@ -223,14 +223,14 @@ class BookManager implements BookManagerInterface {
'#access' => (bool) $options,
'#description' => $this->t('Your page will be a part of the selected book.'),
'#weight' => -5,
- '#attributes' => array('class' => array('book-title-select')),
- '#ajax' => array(
+ '#attributes' => ['class' => ['book-title-select']],
+ '#ajax' => [
'callback' => 'book_form_update',
'wrapper' => 'edit-book-plid-wrapper',
'effect' => 'fade',
'speed' => 'fast',
- ),
- );
+ ],
+ ];
return $form;
}
@@ -281,8 +281,8 @@ class BookManager implements BookManagerInterface {
/**
* {@inheritdoc}
*/
- public function getBookParents(array $item, array $parent = array()) {
- $book = array();
+ public function getBookParents(array $item, array $parent = []) {
+ $book = [];
if ($item['pid'] == 0) {
$book['p1'] = $item['nid'];
for ($i = 2; $i <= static::BOOK_MAX_DEPTH; $i++) {
@@ -325,15 +325,15 @@ class BookManager implements BookManagerInterface {
protected function addParentSelectFormElements(array $book_link) {
$config = $this->configFactory->get('book.settings');
if ($config->get('override_parent_selector')) {
- return array();
+ return [];
}
// Offer a message or a drop-down to choose a different parent page.
- $form = array(
+ $form = [
'#type' => 'hidden',
'#value' => -1,
'#prefix' => '<div id="edit-book-plid-wrapper">',
'#suffix' => '</div>',
- );
+ ];
if ($book_link['nid'] === $book_link['bid']) {
// This is a book - at the top level.
@@ -348,16 +348,16 @@ class BookManager implements BookManagerInterface {
$form['#prefix'] .= '<em>' . $this->t('No book selected.') . '</em>';
}
else {
- $form = array(
+ $form = [
'#type' => 'select',
'#title' => $this->t('Parent item'),
'#default_value' => $book_link['pid'],
- '#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('@maxdepth' => static::BOOK_MAX_DEPTH)),
- '#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], array($book_link['nid'])),
- '#attributes' => array('class' => array('book-title-select')),
+ '#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', ['@maxdepth' => static::BOOK_MAX_DEPTH]),
+ '#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], [$book_link['nid']]),
+ '#attributes' => ['class' => ['book-title-select']],
'#prefix' => '<div id="edit-book-plid-wrapper">',
'#suffix' => '</div>',
- );
+ ];
}
$this->renderer->addCacheableDependency($form, $config);
@@ -388,7 +388,7 @@ class BookManager implements BookManagerInterface {
* children).
*/
protected function recurseTableOfContents(array $tree, $indent, array &$toc, array $exclude, $depth_limit) {
- $nids = array();
+ $nids = [];
foreach ($tree as $data) {
if ($data['link']['depth'] > $depth_limit) {
// Don't iterate through any links on this level.
@@ -417,9 +417,9 @@ class BookManager implements BookManagerInterface {
/**
* {@inheritdoc}
*/
- public function getTableOfContents($bid, $depth_limit, array $exclude = array()) {
+ public function getTableOfContents($bid, $depth_limit, array $exclude = []) {
$tree = $this->bookTreeAllData($bid);
- $toc = array();
+ $toc = [];
$this->recurseTableOfContents($tree, '', $toc, $exclude, $depth_limit);
return $toc;
@@ -443,14 +443,14 @@ class BookManager implements BookManagerInterface {
}
$this->updateOriginalParent($original);
$this->books = NULL;
- Cache::invalidateTags(array('bid:' . $original['bid']));
+ Cache::invalidateTags(['bid:' . $original['bid']]);
}
/**
* {@inheritdoc}
*/
public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) {
- $tree = &drupal_static(__METHOD__, array());
+ $tree = &drupal_static(__METHOD__, []);
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
// Use $nid as a flag for whether the data being loaded is for the whole
@@ -462,10 +462,10 @@ class BookManager implements BookManagerInterface {
if (!isset($tree[$cid])) {
// If the tree data was not in the static cache, build $tree_parameters.
- $tree_parameters = array(
+ $tree_parameters = [
'min_depth' => 1,
'max_depth' => $max_depth,
- );
+ ];
if ($nid) {
$active_trail = $this->getActiveTrailIds($bid, $link);
$tree_parameters['expanded'] = $active_trail;
@@ -486,7 +486,7 @@ class BookManager implements BookManagerInterface {
public function getActiveTrailIds($bid, $link) {
// The tree is for a single item, so we need to match the values in its
// p columns and 0 (the top level) with the plid values of other links.
- $active_trail = array(0);
+ $active_trail = [0];
for ($i = 1; $i < static::BOOK_MAX_DEPTH; $i++) {
if (!empty($link["p$i"])) {
$active_trail[] = $link["p$i"];
@@ -600,7 +600,7 @@ class BookManager implements BookManagerInterface {
* @return array
* A fully built book tree.
*/
- protected function bookTreeBuild($bid, array $parameters = array()) {
+ protected function bookTreeBuild($bid, array $parameters = []) {
// Build the book tree.
$data = $this->doBookTreeBuild($bid, $parameters);
// Check access for the current user to each item in the tree.
@@ -639,9 +639,9 @@ class BookManager implements BookManagerInterface {
*
* @see \Drupal\book\BookOutlineStorageInterface::getBookMenuTree()
*/
- protected function doBookTreeBuild($bid, array $parameters = array()) {
+ protected function doBookTreeBuild($bid, array $parameters = []) {
// Static cache of already built menu trees.
- $trees = &drupal_static(__METHOD__, array());
+ $trees = &drupal_static(__METHOD__, []);
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
// Build the cache id; sort parents to prevent duplicate storage and remove
@@ -664,18 +664,18 @@ class BookManager implements BookManagerInterface {
$result = $this->bookOutlineStorage->getBookMenuTree($bid, $parameters, $min_depth, static::BOOK_MAX_DEPTH);
// Build an ordered array of links using the query result object.
- $links = array();
+ $links = [];
foreach ($result as $link) {
$link = (array) $link;
$links[$link['nid']] = $link;
}
- $active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : array());
+ $active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : []);
$data['tree'] = $this->buildBookOutlineData($links, $active_trail, $min_depth);
- $data['node_links'] = array();
+ $data['node_links'] = [];
$this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache.
- \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $bid));
+ \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, ['bid:' . $bid]);
$trees[$tree_cid] = $data;
}
@@ -705,7 +705,7 @@ class BookManager implements BookManagerInterface {
if (!isset($this->bookTreeFlattened[$book_link['nid']])) {
// Call $this->bookTreeAllData() to take advantage of caching.
$tree = $this->bookTreeAllData($book_link['bid'], $book_link, $book_link['depth'] + 1);
- $this->bookTreeFlattened[$book_link['nid']] = array();
+ $this->bookTreeFlattened[$book_link['nid']] = [];
$this->flatBookTree($tree, $this->bookTreeFlattened[$book_link['nid']]);
}
@@ -735,7 +735,7 @@ class BookManager implements BookManagerInterface {
* {@inheritdoc}
*/
public function loadBookLink($nid, $translate = TRUE) {
- $links = $this->loadBookLinks(array($nid), $translate);
+ $links = $this->loadBookLinks([$nid], $translate);
return isset($links[$nid]) ? $links[$nid] : FALSE;
}
@@ -744,7 +744,7 @@ class BookManager implements BookManagerInterface {
*/
public function loadBookLinks($nids, $translate = TRUE) {
$result = $this->bookOutlineStorage->loadMultiple($nids, $translate);
- $links = array();
+ $links = [];
foreach ($result as $link) {
if ($translate) {
$this->bookLinkTranslate($link);
@@ -779,7 +779,7 @@ class BookManager implements BookManagerInterface {
// Update the bid for this page and all children.
if ($link['pid'] == 0) {
$link['depth'] = 1;
- $parent = array();
+ $parent = [];
}
// In case the form did not specify a proper PID we use the BID as new
// parent.
@@ -801,11 +801,11 @@ class BookManager implements BookManagerInterface {
$this->updateParent($link);
}
// Update the weight and pid.
- $this->bookOutlineStorage->update($link['nid'], array(
+ $this->bookOutlineStorage->update($link['nid'], [
'weight' => $link['weight'],
'pid' => $link['pid'],
'bid' => $link['bid'],
- ));
+ ]);
}
$cache_tags = [];
foreach ($affected_bids as $bid) {
@@ -825,16 +825,16 @@ class BookManager implements BookManagerInterface {
*/
protected function moveChildren(array $link, array $original) {
$p = 'p1';
- $expressions = array();
+ $expressions = [];
for ($i = 1; $i <= $link['depth']; $p = 'p' . ++$i) {
- $expressions[] = array($p, ":p_$i", array(":p_$i" => $link[$p]));
+ $expressions[] = [$p, ":p_$i", [":p_$i" => $link[$p]]];
}
$j = $original['depth'] + 1;
while ($i <= static::BOOK_MAX_DEPTH && $j <= static::BOOK_MAX_DEPTH) {
- $expressions[] = array('p' . $i++, 'p' . $j++, array());
+ $expressions[] = ['p' . $i++, 'p' . $j++, []];
}
while ($i <= static::BOOK_MAX_DEPTH) {
- $expressions[] = array('p' . $i++, 0, array());
+ $expressions[] = ['p' . $i++, 0, []];
}
$shift = $link['depth'] - $original['depth'];
@@ -868,7 +868,7 @@ class BookManager implements BookManagerInterface {
// Nothing to update.
return TRUE;
}
- return $this->bookOutlineStorage->update($link['pid'], array('has_children' => 1));
+ return $this->bookOutlineStorage->update($link['pid'], ['has_children' => 1]);
}
/**
@@ -897,7 +897,7 @@ class BookManager implements BookManagerInterface {
// Update the parent. If the original link did not have children, then the
// parent now does not have children. If the original had children, then the
// the parent has children now (still).
- return $this->bookOutlineStorage->update($original['pid'], array('has_children' => $parent_has_children));
+ return $this->bookOutlineStorage->update($original['pid'], ['has_children' => $parent_has_children]);
}
/**
@@ -926,7 +926,7 @@ class BookManager implements BookManagerInterface {
/**
* {@inheritdoc}
*/
- public function bookTreeCheckAccess(&$tree, $node_links = array()) {
+ public function bookTreeCheckAccess(&$tree, $node_links = []) {
if ($node_links) {
// @todo Extract that into its own method.
$nids = array_keys($node_links);
@@ -954,7 +954,7 @@ class BookManager implements BookManagerInterface {
* The book tree to operate on.
*/
protected function doBookTreeCheckAccess(&$tree) {
- $new_tree = array();
+ $new_tree = [];
foreach ($tree as $key => $v) {
$item = &$tree[$key]['link'];
$this->bookLinkTranslate($item);
@@ -993,7 +993,7 @@ class BookManager implements BookManagerInterface {
}
// The node label will be the value for the current user's language.
$link['title'] = $node->label();
- $link['options'] = array();
+ $link['options'] = [];
}
return $link;
}
@@ -1021,7 +1021,7 @@ class BookManager implements BookManagerInterface {
* array will be empty if the book link has no items in its sub-tree
* having a depth greater than or equal to $depth.
*/
- protected function buildBookOutlineData(array $links, array $parents = array(), $depth = 1) {
+ protected function buildBookOutlineData(array $links, array $parents = [], $depth = 1) {
// Reverse the array so we can use the more efficient array_pop() function.
$links = array_reverse($links);
return $this->buildBookOutlineRecursive($links, $parents, $depth);
@@ -1047,16 +1047,16 @@ class BookManager implements BookManagerInterface {
* Book tree.
*/
protected function buildBookOutlineRecursive(&$links, $parents, $depth) {
- $tree = array();
+ $tree = [];
while ($item = array_pop($links)) {
// We need to determine if we're on the path to root so we can later build
// the correct active trail.
$item['in_active_trail'] = in_array($item['nid'], $parents);
// Add the current link to the tree.
- $tree[$item['nid']] = array(
+ $tree[$item['nid']] = [
'link' => $item,
- 'below' => array(),
- );
+ 'below' => [],
+ ];
// Look ahead to the next link, but leave it on the array so it's
// available to other recursive function calls if we return or build a
// sub-tree.
@@ -1080,7 +1080,7 @@ class BookManager implements BookManagerInterface {
* {@inheritdoc}
*/
public function bookSubtreeData($link) {
- $tree = &drupal_static(__METHOD__, array());
+ $tree = &drupal_static(__METHOD__, []);
// Generate a cache ID (cid) specific for this $link.
$cid = 'book-links:subtree-cid:' . $link['nid'];
@@ -1101,23 +1101,23 @@ class BookManager implements BookManagerInterface {
// If the subtree data was not in the cache, $data will be NULL.
if (!isset($data)) {
$result = $this->bookOutlineStorage->getBookSubtree($link, static::BOOK_MAX_DEPTH);
- $links = array();
+ $links = [];
foreach ($result as $item) {
$links[] = $item;
}
- $data['tree'] = $this->buildBookOutlineData($links, array(), $link['depth']);
- $data['node_links'] = array();
+ $data['tree'] = $this->buildBookOutlineData($links, [], $link['depth']);
+ $data['node_links'] = [];
$this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']);
// Compute the real cid for book subtree data.
$tree_cid = 'book-links:subtree-data:' . hash('sha256', serialize($data));
// Cache the data, if it is not already in the cache.
if (!\Drupal::cache('data')->get($tree_cid)) {
- \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $link['bid']));
+ \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, ['bid:' . $link['bid']]);
}
// Cache the cid of the (shared) data using the book and item-specific
// cid.
- \Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, array('bid:' . $link['bid']));
+ \Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, ['bid:' . $link['bid']]);
}
// Check access for the current user to each item in the tree.
$this->bookTreeCheckAccess($data['tree'], $data['node_links']);
diff --git a/core/modules/book/src/BookManagerInterface.php b/core/modules/book/src/BookManagerInterface.php
index 70d0107c639..5402bf51d7e 100644
--- a/core/modules/book/src/BookManagerInterface.php
+++ b/core/modules/book/src/BookManagerInterface.php
@@ -108,7 +108,7 @@ interface BookManagerInterface {
* An array of (menu link ID, title) pairs for use as options for selecting
* a book page.
*/
- public function getTableOfContents($bid, $depth_limit, array $exclude = array());
+ public function getTableOfContents($bid, $depth_limit, array $exclude = []);
/**
* Finds the depth limit for items in the parent select.
@@ -207,7 +207,7 @@ interface BookManagerInterface {
*/
public function getLinkDefaults($nid);
- public function getBookParents(array $item, array $parent = array());
+ public function getBookParents(array $item, array $parent = []);
/**
* Builds the common elements of the book form for the node and outline forms.
@@ -262,7 +262,7 @@ interface BookManagerInterface {
* A collection of node link references generated from $tree by
* menu_tree_collect_node_links().
*/
- public function bookTreeCheckAccess(&$tree, $node_links = array());
+ public function bookTreeCheckAccess(&$tree, $node_links = []);
/**
* Gets the data representing a subtree of the book hierarchy.
diff --git a/core/modules/book/src/BookOutline.php b/core/modules/book/src/BookOutline.php
index bc03b7c5a96..ec28d50c720 100644
--- a/core/modules/book/src/BookOutline.php
+++ b/core/modules/book/src/BookOutline.php
@@ -105,7 +105,7 @@ class BookOutline {
public function childrenLinks(array $book_link) {
$flat = $this->bookManager->bookTreeGetFlat($book_link);
- $children = array();
+ $children = [];
if ($book_link['has_children']) {
// Walk through the array until we find the current page.
diff --git a/core/modules/book/src/BookOutlineStorage.php b/core/modules/book/src/BookOutlineStorage.php
index 92076cba3f6..4f61b5c0054 100644
--- a/core/modules/book/src/BookOutlineStorage.php
+++ b/core/modules/book/src/BookOutlineStorage.php
@@ -43,7 +43,7 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
* {@inheritdoc}
*/
public function loadMultiple($nids, $access = TRUE) {
- $query = $this->connection->select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC));
+ $query = $this->connection->select('book', 'b', ['fetch' => \PDO::FETCH_ASSOC]);
$query->fields('b');
$query->condition('b.nid', $nids, 'IN');
@@ -89,7 +89,7 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
*/
public function loadBookChildren($pid) {
return $this->connection
- ->query("SELECT * FROM {book} WHERE pid = :pid", array(':pid' => $pid))
+ ->query("SELECT * FROM {book} WHERE pid = :pid", [':pid' => $pid])
->fetchAllAssoc('nid', \PDO::FETCH_ASSOC);
}
@@ -128,12 +128,12 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
public function insert($link, $parents) {
return $this->connection
->insert('book')
- ->fields(array(
+ ->fields([
'nid' => $link['nid'],
'bid' => $link['bid'],
'pid' => $link['pid'],
'weight' => $link['weight'],
- ) + $parents
+ ] + $parents
)
->execute();
}
@@ -154,13 +154,13 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
*/
public function updateMovedChildren($bid, $original, $expressions, $shift) {
$query = $this->connection->update('book');
- $query->fields(array('bid' => $bid));
+ $query->fields(['bid' => $bid]);
foreach ($expressions as $expression) {
$query->expression($expression[0], $expression[1], $expression[2]);
}
- $query->expression('depth', 'depth + :depth', array(':depth' => $shift));
+ $query->expression('depth', 'depth + :depth', [':depth' => $shift]);
$query->condition('bid', $original['bid']);
$p = 'p1';
for ($i = 1; !empty($original[$p]); $p = 'p' . ++$i) {
@@ -186,7 +186,7 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
* {@inheritdoc}
*/
public function getBookSubtree($link, $max_depth) {
- $query = db_select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC));
+ $query = db_select('book', 'b', ['fetch' => \PDO::FETCH_ASSOC]);
$query->fields('b');
$query->condition('b.bid', $link['bid']);
diff --git a/core/modules/book/src/Controller/BookController.php b/core/modules/book/src/Controller/BookController.php
index 920afeb2b1f..b92c3e3fcfe 100644
--- a/core/modules/book/src/Controller/BookController.php
+++ b/core/modules/book/src/Controller/BookController.php
@@ -73,9 +73,9 @@ class BookController extends ControllerBase {
* A render array representing the administrative page content.
*/
public function adminOverview() {
- $rows = array();
+ $rows = [];
- $headers = array(t('Book'), t('Operations'));
+ $headers = [t('Book'), t('Operations')];
// Add any recognized books to the table list.
foreach ($this->bookManager->getAllBooks() as $book) {
/** @var \Drupal\Core\Url $url */
@@ -83,28 +83,28 @@ class BookController extends ControllerBase {
if (isset($book['options'])) {
$url->setOptions($book['options']);
}
- $row = array(
+ $row = [
$this->l($book['title'], $url),
- );
- $links = array();
- $links['edit'] = array(
+ ];
+ $links = [];
+ $links['edit'] = [
'title' => t('Edit order and titles'),
'url' => Url::fromRoute('book.admin_edit', ['node' => $book['nid']]),
- );
- $row[] = array(
- 'data' => array(
+ ];
+ $row[] = [
+ 'data' => [
'#type' => 'operations',
'#links' => $links,
- ),
- );
+ ],
+ ];
$rows[] = $row;
}
- return array(
+ return [
'#type' => 'table',
'#header' => $headers,
'#rows' => $rows,
'#empty' => t('No books available.'),
- );
+ ];
}
/**
@@ -114,17 +114,17 @@ class BookController extends ControllerBase {
* A render array representing the listing of all books content.
*/
public function bookRender() {
- $book_list = array();
+ $book_list = [];
foreach ($this->bookManager->getAllBooks() as $book) {
$book_list[] = $this->l($book['title'], $book['url']);
}
- return array(
+ return [
'#theme' => 'item_list',
'#items' => $book_list,
'#cache' => [
'tags' => \Drupal::entityManager()->getDefinition('node')->getListCacheTags(),
],
- );
+ ];
}
/**
diff --git a/core/modules/book/src/Form/BookAdminEditForm.php b/core/modules/book/src/Form/BookAdminEditForm.php
index 175394422f2..e91f52ea8b2 100644
--- a/core/modules/book/src/Form/BookAdminEditForm.php
+++ b/core/modules/book/src/Form/BookAdminEditForm.php
@@ -70,10 +70,10 @@ class BookAdminEditForm extends FormBase {
$form['#title'] = $node->label();
$form['#node'] = $node;
$this->bookAdminTable($node, $form);
- $form['save'] = array(
+ $form['save'] = [
'#type' => 'submit',
'#value' => $this->t('Save book pages'),
- );
+ ];
return $form;
}
@@ -101,7 +101,7 @@ class BookAdminEditForm extends FormBase {
foreach (Element::children($form['table']) as $key) {
if ($form['table'][$key]['#item']) {
$row = $form['table'][$key];
- $values = $form_state->getValue(array('table', $key));
+ $values = $form_state->getValue(['table', $key]);
// Update menu item if moved.
if ($row['parent']['pid']['#default_value'] != $values['pid'] || $row['weight']['#default_value'] != $values['weight']) {
@@ -114,18 +114,18 @@ class BookAdminEditForm extends FormBase {
// Update the title if changed.
if ($row['title']['#default_value'] != $values['title']) {
$node = $this->nodeStorage->load($values['nid']);
- $node->revision_log = $this->t('Title changed from %original to %current.', array('%original' => $node->label(), '%current' => $values['title']));
+ $node->revision_log = $this->t('Title changed from %original to %current.', ['%original' => $node->label(), '%current' => $values['title']]);
$node->title = $values['title'];
$node->book['link_title'] = $values['title'];
$node->setNewRevision();
$node->save();
- $this->logger('content')->notice('book: updated %title.', array('%title' => $node->label(), 'link' => $node->link($this->t('View'))));
+ $this->logger('content')->notice('book: updated %title.', ['%title' => $node->label(), 'link' => $node->link($this->t('View'))]);
}
}
}
}
- drupal_set_message($this->t('Updated book %title.', array('%title' => $form['#node']->label())));
+ drupal_set_message($this->t('Updated book %title.', ['%title' => $form['#node']->label()]));
}
/**
@@ -139,7 +139,7 @@ class BookAdminEditForm extends FormBase {
* @see self::buildForm()
*/
protected function bookAdminTable(NodeInterface $node, array &$form) {
- $form['table'] = array(
+ $form['table'] = [
'#type' => 'table',
'#header' => [
$this->t('Title'),
@@ -164,7 +164,7 @@ class BookAdminEditForm extends FormBase {
'group' => 'book-weight',
],
],
- );
+ ];
$tree = $this->bookManager->bookSubtreeData($node->book);
// Do not include the book item itself.
@@ -173,14 +173,14 @@ class BookAdminEditForm extends FormBase {
$hash = Crypt::hashBase64(serialize($tree['below']));
// Store the hash value as a hidden form element so that we can detect
// if another user changed the book hierarchy.
- $form['tree_hash'] = array(
+ $form['tree_hash'] = [
'#type' => 'hidden',
'#default_value' => $hash,
- );
- $form['tree_current_hash'] = array(
+ ];
+ $form['tree_current_hash'] = [
'#type' => 'value',
'#value' => $hash,
- );
+ ];
$this->bookAdminTableTree($tree['below'], $form['table']);
}
}
diff --git a/core/modules/book/src/Form/BookOutlineForm.php b/core/modules/book/src/Form/BookOutlineForm.php
index 8b4e3640b78..1d63aacf0c0 100644
--- a/core/modules/book/src/Form/BookOutlineForm.php
+++ b/core/modules/book/src/Form/BookOutlineForm.php
@@ -107,7 +107,7 @@ class BookOutlineForm extends ContentEntityForm {
public function save(array $form, FormStateInterface $form_state) {
$form_state->setRedirect(
'entity.node.canonical',
- array('node' => $this->entity->id())
+ ['node' => $this->entity->id()]
);
$book_link = $form_state->getValue('book');
if (!$book_link['bid']) {
diff --git a/core/modules/book/src/Form/BookRemoveForm.php b/core/modules/book/src/Form/BookRemoveForm.php
index 4848fa29438..e31c0940e82 100644
--- a/core/modules/book/src/Form/BookRemoveForm.php
+++ b/core/modules/book/src/Form/BookRemoveForm.php
@@ -65,7 +65,7 @@ class BookRemoveForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getDescription() {
- $title = array('%title' => $this->node->label());
+ $title = ['%title' => $this->node->label()];
if ($this->node->book['has_children']) {
return $this->t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hierarchy (as it was before removing this page), %title may be added again using the Outline tab, and each of its former child pages will need to be relocated manually.', $title);
}
@@ -85,7 +85,7 @@ class BookRemoveForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to remove %title from the book hierarchy?', array('%title' => $this->node->label()));
+ return $this->t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $this->node->label()]);
}
/**
diff --git a/core/modules/book/src/Form/BookSettingsForm.php b/core/modules/book/src/Form/BookSettingsForm.php
index 058d0cd0637..29590ccdb57 100644
--- a/core/modules/book/src/Form/BookSettingsForm.php
+++ b/core/modules/book/src/Form/BookSettingsForm.php
@@ -30,22 +30,22 @@ class BookSettingsForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$types = node_type_get_names();
$config = $this->config('book.settings');
- $form['book_allowed_types'] = array(
+ $form['book_allowed_types'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Content types allowed in book outlines'),
'#default_value' => $config->get('allowed_types'),
'#options' => $types,
- '#description' => $this->t('Users with the %outline-perm permission can add all content types.', array('%outline-perm' => $this->t('Administer book outlines'))),
+ '#description' => $this->t('Users with the %outline-perm permission can add all content types.', ['%outline-perm' => $this->t('Administer book outlines')]),
'#required' => TRUE,
- );
- $form['book_child_type'] = array(
+ ];
+ $form['book_child_type'] = [
'#type' => 'radios',
'#title' => $this->t('Content type for the <em>Add child page</em> link'),
'#default_value' => $config->get('child_type'),
'#options' => $types,
'#required' => TRUE,
- );
- $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
+ ];
+ $form['array_filter'] = ['#type' => 'value', '#value' => TRUE];
return parent::buildForm($form, $form_state);
}
@@ -55,8 +55,8 @@ class BookSettingsForm extends ConfigFormBase {
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$child_type = $form_state->getValue('book_child_type');
- if ($form_state->isValueEmpty(array('book_allowed_types', $child_type))) {
- $form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => $this->t('Add child page'))));
+ if ($form_state->isValueEmpty(['book_allowed_types', $child_type])) {
+ $form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', ['%add-child' => $this->t('Add child page')]));
}
parent::validateForm($form, $form_state);
diff --git a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
index a7b0f1e32ae..7b0156f2405 100644
--- a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
+++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
@@ -86,26 +86,26 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'block_mode' => "all pages",
- );
+ ];
}
/**
* {@inheritdoc}
*/
function blockForm($form, FormStateInterface $form_state) {
- $options = array(
+ $options = [
'all pages' => $this->t('Show block on all pages'),
'book pages' => $this->t('Show block only on book pages'),
- );
- $form['book_block_mode'] = array(
+ ];
+ $form['book_block_mode'] = [
'#type' => 'radios',
'#title' => $this->t('Book navigation block display'),
'#options' => $options,
'#default_value' => $this->configuration['block_mode'],
'#description' => $this->t("If <em>Show block on all pages</em> is selected, the block will contain the automatically generated menus for all of the site's books. If <em>Show block only on book pages</em> is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The <em>Page specific visibility settings</em> or other visibility settings can be used in addition to selectively display this block."),
- );
+ ];
return $form;
}
@@ -127,8 +127,8 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
$current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
}
if ($this->configuration['block_mode'] == 'all pages') {
- $book_menus = array();
- $pseudo_tree = array(0 => array('below' => FALSE));
+ $book_menus = [];
+ $pseudo_tree = [0 => ['below' => FALSE]];
foreach ($this->bookManager->getAllBooks() as $book_id => $book) {
if ($book['bid'] == $current_bid) {
// If the current page is a node associated with a book, the menu
@@ -146,14 +146,14 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
$pseudo_tree[0]['link'] = $book;
$book_menus[$book_id] = $this->bookManager->bookTreeOutput($pseudo_tree);
}
- $book_menus[$book_id] += array(
+ $book_menus[$book_id] += [
'#book_title' => $book['title'],
- );
+ ];
}
if ($book_menus) {
- return array(
+ return [
'#theme' => 'book_all_books_block',
- ) + $book_menus;
+ ] + $book_menus;
}
}
elseif ($current_bid) {
@@ -175,7 +175,7 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
}
}
}
- return array();
+ return [];
}
/**
diff --git a/core/modules/book/src/Plugin/migrate/source/d6/Book.php b/core/modules/book/src/Plugin/migrate/source/d6/Book.php
index 76833aa7531..f41bb42dfa7 100644
--- a/core/modules/book/src/Plugin/migrate/source/d6/Book.php
+++ b/core/modules/book/src/Plugin/migrate/source/d6/Book.php
@@ -17,9 +17,9 @@ class Book extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
- $query = $this->select('book', 'b')->fields('b', array('nid', 'bid'));
+ $query = $this->select('book', 'b')->fields('b', ['nid', 'bid']);
$query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
- $ml_fields = array('mlid', 'plid', 'weight', 'has_children', 'depth');
+ $ml_fields = ['mlid', 'plid', 'weight', 'has_children', 'depth'];
for ($i = 1; $i <= 9; $i++) {
$field = "p$i";
$ml_fields[] = $field;
@@ -42,7 +42,7 @@ class Book extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'nid' => $this->t('Node ID'),
'bid' => $this->t('Book ID'),
'mlid' => $this->t('Menu link ID'),
@@ -57,7 +57,7 @@ class Book extends DrupalSqlBase {
'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
- );
+ ];
}
}
diff --git a/core/modules/book/src/Tests/BookBreadcrumbTest.php b/core/modules/book/src/Tests/BookBreadcrumbTest.php
index 57e1b3d6ce4..d2f4d5d386a 100644
--- a/core/modules/book/src/Tests/BookBreadcrumbTest.php
+++ b/core/modules/book/src/Tests/BookBreadcrumbTest.php
@@ -16,7 +16,7 @@ class BookBreadcrumbTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('book', 'block', 'book_breadcrumb_test');
+ public static $modules = ['book', 'block', 'book_breadcrumb_test'];
/**
* A book node.
@@ -48,8 +48,8 @@ class BookBreadcrumbTest extends WebTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create users.
- $this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
- $this->adminUser = $this->drupalCreateUser(array('create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration'));
+ $this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']);
+ $this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration']);
}
/**
@@ -76,7 +76,7 @@ class BookBreadcrumbTest extends WebTestBase {
* |- Node 5
* |- Node 6
*/
- $nodes = array();
+ $nodes = [];
$nodes[0] = $this->createBookNode($book->id());
$nodes[1] = $this->createBookNode($book->id(), $nodes[0]->id());
$nodes[2] = $this->createBookNode($book->id(), $nodes[0]->id());
@@ -107,7 +107,7 @@ class BookBreadcrumbTest extends WebTestBase {
// that when sorted nodes stay in same order.
static $number = 0;
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
$edit['book[bid]'] = $book_nid;
@@ -146,7 +146,7 @@ class BookBreadcrumbTest extends WebTestBase {
$this->drupalGet($nodes[4]->toUrl());
// Fetch each node title in the current breadcrumb.
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
- $got_breadcrumb = array();
+ $got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = (string) $link;
}
@@ -160,7 +160,7 @@ class BookBreadcrumbTest extends WebTestBase {
$this->drupalGet($nodes[4]->toUrl());
// Fetch each node title in the current breadcrumb.
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
- $got_breadcrumb = array();
+ $got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = (string) $link;
}
@@ -181,7 +181,7 @@ class BookBreadcrumbTest extends WebTestBase {
$this->drupalPostForm($nodes[3]->toUrl('edit-form'), $edit, 'Save');
$this->drupalGet($nodes[4]->toUrl());
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
- $got_breadcrumb = array();
+ $got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = (string) $link;
}
@@ -191,7 +191,7 @@ class BookBreadcrumbTest extends WebTestBase {
$config->set('hide', TRUE)->save();
$this->drupalGet($nodes[4]->toUrl());
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
- $got_breadcrumb = array();
+ $got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = (string) $link;
}
diff --git a/core/modules/book/src/Tests/BookInstallTest.php b/core/modules/book/src/Tests/BookInstallTest.php
index ba70a9bcd02..9933b1c5f8c 100644
--- a/core/modules/book/src/Tests/BookInstallTest.php
+++ b/core/modules/book/src/Tests/BookInstallTest.php
@@ -17,7 +17,7 @@ class BookInstallTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* {@inheritdoc}
diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php
index cdd61c60ab3..183674fa4aa 100644
--- a/core/modules/book/src/Tests/BookTest.php
+++ b/core/modules/book/src/Tests/BookTest.php
@@ -20,7 +20,7 @@ class BookTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('book', 'block', 'node_access_test', 'book_test');
+ public static $modules = ['book', 'block', 'node_access_test', 'book_test'];
/**
* A book node.
@@ -69,10 +69,10 @@ class BookTest extends WebTestBase {
node_access_rebuild();
// Create users.
- $this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
- $this->webUser = $this->drupalCreateUser(array('access printer-friendly version', 'node test view'));
- $this->webUserWithoutNodeAccess = $this->drupalCreateUser(array('access printer-friendly version'));
- $this->adminUser = $this->drupalCreateUser(array('create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration'));
+ $this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']);
+ $this->webUser = $this->drupalCreateUser(['access printer-friendly version', 'node test view']);
+ $this->webUserWithoutNodeAccess = $this->drupalCreateUser(['access printer-friendly version']);
+ $this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration']);
}
/**
@@ -96,7 +96,7 @@ class BookTest extends WebTestBase {
* |- Node 3
* |- Node 4
*/
- $nodes = array();
+ $nodes = [];
$nodes[] = $this->createBookNode($book->id()); // Node 0.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid']); // Node 1.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid']); // Node 2.
@@ -159,8 +159,8 @@ class BookTest extends WebTestBase {
// Log in as a user with access to the book outline and save the form.
$this->drupalLogin($this->adminUser);
- $this->drupalPostForm('admin/structure/book/' . $book->id(), array(), t('Save book pages'));
- $this->assertText(t('Updated book @book.', array('@book' => $book->label())));
+ $this->drupalPostForm('admin/structure/book/' . $book->id(), [], t('Save book pages'));
+ $this->assertText(t('Updated book @book.', ['@book' => $book->label()]));
}
/**
@@ -175,12 +175,12 @@ class BookTest extends WebTestBase {
// Check that book pages display along with the correct outlines and
// previous/next links.
- $this->checkBookNode($book, array($nodes[0], $nodes[3], $nodes[4]), FALSE, FALSE, $nodes[0], array());
- $this->checkBookNode($nodes[0], array($nodes[1], $nodes[2]), $book, $book, $nodes[1], array($book));
- $this->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], array($book, $nodes[0]));
- $this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], array($book, $nodes[0]));
- $this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], array($book));
- $this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, array($book));
+ $this->checkBookNode($book, [$nodes[0], $nodes[3], $nodes[4]], FALSE, FALSE, $nodes[0], []);
+ $this->checkBookNode($nodes[0], [$nodes[1], $nodes[2]], $book, $book, $nodes[1], [$book]);
+ $this->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], [$book, $nodes[0]]);
+ $this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], [$book, $nodes[0]]);
+ $this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], [$book]);
+ $this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, [$book]);
$this->drupalLogout();
$this->drupalLogin($this->bookAuthor);
@@ -203,14 +203,14 @@ class BookTest extends WebTestBase {
$this->drupalLogout();
$this->drupalLogin($this->webUser);
// Verify the new outline - make sure we don't get stale cached data.
- $this->checkBookNode($nodes[3], array($nodes[5]), $nodes[2], $book, $nodes[5], array($book));
- $this->checkBookNode($nodes[4], NULL, $nodes[5], $book, FALSE, array($book));
+ $this->checkBookNode($nodes[3], [$nodes[5]], $nodes[2], $book, $nodes[5], [$book]);
+ $this->checkBookNode($nodes[4], NULL, $nodes[5], $book, FALSE, [$book]);
$this->drupalLogout();
// Create a second book, and move an existing book page into it.
$this->drupalLogin($this->bookAuthor);
$other_book = $this->createBookNode('new');
$node = $this->createBookNode($book->id());
- $edit = array('book[bid]' => $other_book->id());
+ $edit = ['book[bid]' => $other_book->id()];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->drupalLogout();
@@ -220,8 +220,8 @@ class BookTest extends WebTestBase {
// First we must set $this->book to the second book, so that the
// correct regex will be generated for testing the outline.
$this->book = $other_book;
- $this->checkBookNode($other_book, array($node), FALSE, FALSE, $node, array());
- $this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, array($other_book));
+ $this->checkBookNode($other_book, [$node], FALSE, FALSE, $node, []);
+ $this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, [$other_book]);
// Test that we can save a book programatically.
$this->drupalLogin($this->bookAuthor);
@@ -255,38 +255,38 @@ class BookTest extends WebTestBase {
// Check outline structure.
if ($nodes !== NULL) {
- $this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node @number outline confirmed.', array('@number' => $number)));
+ $this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node @number outline confirmed.', ['@number' => $number]));
}
else {
- $this->pass(format_string('Node %number does not have outline.', array('%number' => $number)));
+ $this->pass(format_string('Node %number does not have outline.', ['%number' => $number]));
}
// Check previous, up, and next links.
if ($previous) {
/** @var \Drupal\Core\Url $url */
$url = $previous->urlInfo();
- $url->setOptions(array('attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page'))));
- $text = SafeMarkup::format('<b>‹</b> @label', array('@label' => $previous->label()));
+ $url->setOptions(['attributes' => ['rel' => ['prev'], 'title' => t('Go to previous page')]]);
+ $text = SafeMarkup::format('<b>‹</b> @label', ['@label' => $previous->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Previous page link found.');
}
if ($up) {
/** @var \Drupal\Core\Url $url */
$url = $up->urlInfo();
- $url->setOptions(array('attributes' => array('title' => t('Go to parent page'))));
+ $url->setOptions(['attributes' => ['title' => t('Go to parent page')]]);
$this->assertRaw(\Drupal::l('Up', $url), 'Up page link found.');
}
if ($next) {
/** @var \Drupal\Core\Url $url */
$url = $next->urlInfo();
- $url->setOptions(array('attributes' => array('rel' => array('next'), 'title' => t('Go to next page'))));
- $text = SafeMarkup::format('@label <b>›</b>', array('@label' => $next->label()));
+ $url->setOptions(['attributes' => ['rel' => ['next'], 'title' => t('Go to next page')]]);
+ $text = SafeMarkup::format('@label <b>›</b>', ['@label' => $next->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Next page link found.');
}
// Compute the expected breadcrumb.
- $expected_breadcrumb = array();
+ $expected_breadcrumb = [];
$expected_breadcrumb[] = \Drupal::url('<front>');
foreach ($breadcrumb as $a_node) {
$expected_breadcrumb[] = $a_node->url();
@@ -294,7 +294,7 @@ class BookTest extends WebTestBase {
// Fetch links in the current breadcrumb.
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
- $got_breadcrumb = array();
+ $got_breadcrumb = [];
foreach ($links as $link) {
$got_breadcrumb[] = (string) $link['href'];
}
@@ -344,7 +344,7 @@ class BookTest extends WebTestBase {
// since it uniquely identifies each call to createBookNode().
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
$edit['book[bid]'] = $book_nid;
@@ -410,7 +410,7 @@ class BookTest extends WebTestBase {
// Now grant anonymous users permission to view the printer-friendly
// version and verify that node access restrictions still prevent them from
// seeing it.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access printer-friendly version'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access printer-friendly version']);
$this->drupalGet('book/export/html/' . $this->book->id());
$this->assertResponse('403', 'Anonymous user properly forbidden from seeing the printer-friendly version when denied by node access.');
}
@@ -425,7 +425,7 @@ class BookTest extends WebTestBase {
$block = $this->drupalPlaceBlock('book_navigation');
// Give anonymous users the permission 'node test view'.
- $edit = array();
+ $edit = [];
$edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE;
$this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users.");
@@ -434,7 +434,7 @@ class BookTest extends WebTestBase {
$nodes = $this->createBook();
$this->drupalGet('<front>');
$this->assertText($block->label(), 'Book navigation block is displayed.');
- $this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->label())));
+ $this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', ['@title' => $nodes[0]->label()]));
$this->assertNoText($nodes[0]->label(), 'No links to individual book pages are displayed.');
}
@@ -485,8 +485,8 @@ class BookTest extends WebTestBase {
$diff = array_diff($expected_nids, array_keys($options));
$this->assertTrue(empty($diff), 'Found all expected option keys');
// Exclude Node 3.
- $options = $manager->getTableOfContents($book->id(), 3, array($nodes[3]->id()));
- $expected_nids = array($book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id());
+ $options = $manager->getTableOfContents($book->id(), 3, [$nodes[3]->id()]);
+ $expected_nids = [$book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id()];
$this->assertEqual(count($options), count($expected_nids));
$diff = array_diff($expected_nids, array_keys($options));
$this->assertTrue(empty($diff), 'Found all expected option keys after excluding Node 3');
@@ -497,10 +497,10 @@ class BookTest extends WebTestBase {
*/
function testNavigationBlockOnAccessModuleInstalled() {
$this->drupalLogin($this->adminUser);
- $block = $this->drupalPlaceBlock('book_navigation', array('block_mode' => 'book pages'));
+ $block = $this->drupalPlaceBlock('book_navigation', ['block_mode' => 'book pages']);
// Give anonymous users the permission 'node test view'.
- $edit = array();
+ $edit = [];
$edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE;
$this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users.");
@@ -530,13 +530,13 @@ class BookTest extends WebTestBase {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
- $edit = array();
+ $edit = [];
// Test access to delete top-level and child book nodes.
$this->drupalGet('node/' . $this->book->id() . '/outline/remove');
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
$this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove'));
- $node_storage->resetCache(array($nodes[4]->id()));
+ $node_storage->resetCache([$nodes[4]->id()]);
$node4 = $node_storage->load($nodes[4]->id());
$this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.');
@@ -546,7 +546,7 @@ class BookTest extends WebTestBase {
}
entity_delete_multiple('node', $nids);
$this->drupalPostForm('node/' . $this->book->id() . '/outline/remove', $edit, t('Remove'));
- $node_storage->resetCache(array($this->book->id()));
+ $node_storage->resetCache([$this->book->id()]);
$node = $node_storage->load($this->book->id());
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
@@ -577,7 +577,7 @@ class BookTest extends WebTestBase {
$this->drupalLogin($this->bookAuthor);
// Create new node not yet a book.
- $empty_book = $this->drupalCreateNode(array('type' => 'book'));
+ $empty_book = $this->drupalCreateNode(['type' => 'book']);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertNoLink(t('Book outline'), 'Book Author is not allowed to outline');
@@ -587,7 +587,7 @@ class BookTest extends WebTestBase {
$this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
$this->assertNoLink(t('Remove from book outline'));
- $edit = array();
+ $edit = [];
$edit['book[bid]'] = '1';
$this->drupalPostForm('node/' . $empty_book->id() . '/outline', $edit, t('Add to book outline'));
$node = \Drupal::entityManager()->getStorage('node')->load($empty_book->id());
@@ -606,11 +606,11 @@ class BookTest extends WebTestBase {
$this->drupalGet('node/' . $book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->clickLink(t('Remove from book outline'));
- $this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', array('%title' => $book->label())));
+ $this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $book->label()]));
// Create a new node and set the book after the node was created.
- $node = $this->drupalCreateNode(array('type' => 'book'));
- $edit = array();
+ $node = $this->drupalCreateNode(['type' => 'book']);
+ $edit = [];
$edit['book[bid]'] = $node->id();
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$node = \Drupal::entityManager()->getStorage('node')->load($node->id());
@@ -634,7 +634,7 @@ class BookTest extends WebTestBase {
$book_manager = \Drupal::service('book.manager');
// Mock a link for a new book.
- $link = array('nid' => 1, 'has_children' => 0, 'original_bid' => 0, 'parent_depth_limit' => 8, 'pid' => 0, 'weight' => 0, 'bid' => 1);
+ $link = ['nid' => 1, 'has_children' => 0, 'original_bid' => 0, 'parent_depth_limit' => 8, 'pid' => 0, 'weight' => 0, 'bid' => 1];
$new = TRUE;
// Save the link.
diff --git a/core/modules/book/src/Tests/Views/BookRelationshipTest.php b/core/modules/book/src/Tests/Views/BookRelationshipTest.php
index 2302e8b04e1..c1f872803ae 100644
--- a/core/modules/book/src/Tests/Views/BookRelationshipTest.php
+++ b/core/modules/book/src/Tests/Views/BookRelationshipTest.php
@@ -19,14 +19,14 @@ class BookRelationshipTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_book_view');
+ public static $testViews = ['test_book_view'];
/**
* Modules to install.
*
* @var array
*/
- public static $modules = array('book_test_views', 'book', 'views');
+ public static $modules = ['book_test_views', 'book', 'views'];
/**
* A book node.
@@ -50,14 +50,14 @@ class BookRelationshipTest extends ViewTestBase {
// Create users.
$this->bookAuthor = $this->drupalCreateUser(
- array(
+ [
'create new books',
'create book content',
'edit own book content',
'add content to books',
- )
+ ]
);
- ViewTestData::createTestViews(get_class($this), array('book_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['book_test_views']);
}
/**
@@ -70,7 +70,7 @@ class BookRelationshipTest extends ViewTestBase {
$this->book = $this->createBookNode('new');
$book = $this->book;
- $nodes = array();
+ $nodes = [];
// Node 0.
$nodes[] = $this->createBookNode($book->id());
// Node 1.
@@ -110,7 +110,7 @@ class BookRelationshipTest extends ViewTestBase {
// Used to ensure that when sorted nodes stay in same order.
static $number = 0;
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $number . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
$edit['book[bid]'] = $book_nid;
diff --git a/core/modules/book/tests/src/Kernel/BookUninstallTest.php b/core/modules/book/tests/src/Kernel/BookUninstallTest.php
index bcd08124841..9430991ffe7 100644
--- a/core/modules/book/tests/src/Kernel/BookUninstallTest.php
+++ b/core/modules/book/tests/src/Kernel/BookUninstallTest.php
@@ -27,11 +27,11 @@ class BookUninstallTest extends KernelTestBase {
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('node');
- $this->installSchema('book', array('book'));
- $this->installSchema('node', array('node_access'));
- $this->installConfig(array('node', 'book', 'field'));
+ $this->installSchema('book', ['book']);
+ $this->installSchema('node', ['node_access']);
+ $this->installConfig(['node', 'book', 'field']);
// For uninstall to work.
- $this->installSchema('user', array('users_data'));
+ $this->installSchema('user', ['users_data']);
}
/**
@@ -42,17 +42,17 @@ class BookUninstallTest extends KernelTestBase {
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
$this->assertEqual([], $validation_reasons, 'The book module is not required.');
- $content_type = NodeType::create(array(
+ $content_type = NodeType::create([
'type' => $this->randomMachineName(),
'name' => $this->randomString(),
- ));
+ ]);
$content_type->save();
$book_config = $this->config('book.settings');
$allowed_types = $book_config->get('allowed_types');
$allowed_types[] = $content_type->id();
$book_config->set('allowed_types', $allowed_types)->save();
- $node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
+ $node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]);
$node->book['bid'] = 'new';
$node->save();
@@ -60,7 +60,7 @@ class BookUninstallTest extends KernelTestBase {
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
$this->assertEqual(['To uninstall Book, delete all content that is part of a book'], $validation_reasons['book']);
- $book_node = Node::create(array('title' => $this->randomString(), 'type' => 'book'));
+ $book_node = Node::create(['title' => $this->randomString(), 'type' => 'book']);
$book_node->book['bid'] = FALSE;
$book_node->save();
@@ -79,7 +79,7 @@ class BookUninstallTest extends KernelTestBase {
$module_data = _system_rebuild_module_data();
$this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.');
- $node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
+ $node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]);
$node->save();
// One node exists but is not part of a book therefore the book module is
// not required.
@@ -87,7 +87,7 @@ class BookUninstallTest extends KernelTestBase {
$this->assertEqual([], $validation_reasons, 'The book module is not required.');
// Uninstall the Book module and check the node type is deleted.
- \Drupal::service('module_installer')->uninstall(array('book'));
+ \Drupal::service('module_installer')->uninstall(['book']);
$this->assertNull(NodeType::load('book'), "The book node type does not exist.");
}
diff --git a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php
index ee3c0b21773..17a3bfff104 100644
--- a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php
+++ b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php
@@ -34,7 +34,7 @@ class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
$config = $this->config('book.settings');
$this->assertIdentical('book', $config->get('child_type'));
$this->assertIdentical('all pages', $config->get('block.navigation.mode'));
- $this->assertIdentical(array('book'), $config->get('allowed_types'));
+ $this->assertIdentical(['book'], $config->get('allowed_types'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
}
diff --git a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php
index ffcc3fec292..f6f1730e35c 100644
--- a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php
+++ b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php
@@ -32,7 +32,7 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
* Tests the Drupal 6 book structure to Drupal 8 migration.
*/
public function testBook() {
- $nodes = Node::loadMultiple(array(4, 5, 6, 7, 8));
+ $nodes = Node::loadMultiple([4, 5, 6, 7, 8]);
$this->assertIdentical('4', $nodes[4]->book['bid']);
$this->assertIdentical('0', $nodes[4]->book['pid']);
@@ -53,8 +53,8 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
$this->assertIdentical('5', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['link']['nid']);
$this->assertIdentical('6', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['link']['nid']);
$this->assertIdentical('7', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['link']['nid']);
- $this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']);
- $this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']);
+ $this->assertIdentical([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']);
+ $this->assertIdentical([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']);
}
}
diff --git a/core/modules/book/tests/src/Unit/BookManagerTest.php b/core/modules/book/tests/src/Unit/BookManagerTest.php
index fdecbbe5817..d7835539b55 100644
--- a/core/modules/book/tests/src/Unit/BookManagerTest.php
+++ b/core/modules/book/tests/src/Unit/BookManagerTest.php
@@ -59,7 +59,7 @@ class BookManagerTest extends UnitTestCase {
protected function setUp() {
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$this->translation = $this->getStringTranslationStub();
- $this->configFactory = $this->getConfigFactoryStub(array());
+ $this->configFactory = $this->getConfigFactoryStub([]);
$this->bookOutlineStorage = $this->getMock('Drupal\book\BookOutlineStorageInterface');
$this->renderer = $this->getMock('\Drupal\Core\Render\RendererInterface');
$this->bookManager = new BookManager($this->entityManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer);
@@ -81,7 +81,7 @@ class BookManagerTest extends UnitTestCase {
* The test data.
*/
public function providerTestGetBookParents() {
- $empty = array(
+ $empty = [
'p1' => 0,
'p2' => 0,
'p3' => 0,
@@ -91,27 +91,27 @@ class BookManagerTest extends UnitTestCase {
'p7' => 0,
'p8' => 0,
'p9' => 0,
- );
- return array(
+ ];
+ return [
// Provides a book without an existing parent.
- array(
- array('pid' => 0, 'nid' => 12),
- array(),
- array('depth' => 1, 'p1' => 12) + $empty,
- ),
+ [
+ ['pid' => 0, 'nid' => 12],
+ [],
+ ['depth' => 1, 'p1' => 12] + $empty,
+ ],
// Provides a book with an existing parent.
- array(
- array('pid' => 11, 'nid' => 12),
- array('nid' => 11, 'depth' => 1, 'p1' => 11,),
- array('depth' => 2, 'p1' => 11, 'p2' => 12) + $empty,
- ),
+ [
+ ['pid' => 11, 'nid' => 12],
+ ['nid' => 11, 'depth' => 1, 'p1' => 11,],
+ ['depth' => 2, 'p1' => 11, 'p2' => 12] + $empty,
+ ],
// Provides a book with two existing parents.
- array(
- array('pid' => 11, 'nid' => 12),
- array('nid' => 11, 'depth' => 2, 'p1' => 10, 'p2' => 11),
- array('depth' => 3, 'p1' => 10, 'p2' => 11, 'p3' => 12) + $empty,
- ),
- );
+ [
+ ['pid' => 11, 'nid' => 12],
+ ['nid' => 11, 'depth' => 2, 'p1' => 10, 'p2' => 11],
+ ['depth' => 3, 'p1' => 10, 'p2' => 11, 'p3' => 12] + $empty,
+ ],
+ ];
}
}
diff --git a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php
index 927241f0b2e..5b7662c50a9 100644
--- a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php
+++ b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php
@@ -12,10 +12,10 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class BookLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array(
+ $this->directoryList = [
'book' => 'core/modules/book',
'node' => 'core/modules/node',
- );
+ ];
parent::setUp();
}
@@ -26,19 +26,19 @@ class BookLocalTasksTest extends LocalTaskIntegrationTestBase {
*/
public function testBookAdminLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('book.admin', 'book.settings'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['book.admin', 'book.settings'],
+ ]);
}
/**
* Provides a list of routes to test.
*/
public function getBookAdminRoutes() {
- return array(
- array('book.admin'),
- array('book.settings'),
- );
+ return [
+ ['book.admin'],
+ ['book.settings'],
+ ];
}
/**
@@ -47,19 +47,19 @@ class BookLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getBookNodeRoutes
*/
public function testBookNodeLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',],
+ ]);
}
/**
* Provides a list of routes to test.
*/
public function getBookNodeRoutes() {
- return array(
- array('entity.node.canonical'),
- array('entity.node.book_outline_form'),
- );
+ return [
+ ['entity.node.canonical'],
+ ['entity.node.book_outline_form'],
+ ];
}
}
diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module
index 103edd9b0de..a0fd468df07 100644
--- a/core/modules/breakpoint/breakpoint.module
+++ b/core/modules/breakpoint/breakpoint.module
@@ -15,13 +15,13 @@ function breakpoint_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.breakpoint':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the <a href=":docs">online documentation for the Breakpoint module</a>.', array(':docs' => 'https://www.drupal.org/documentation/modules/breakpoint')) . '</p>';
+ $output .= '<p>' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the <a href=":docs">online documentation for the Breakpoint module</a>.', [':docs' => 'https://www.drupal.org/documentation/modules/breakpoint']) . '</p>';
$output .= '<h4>' . t('Terminology') . '</h4>';
$output .= '<dl>';
$output .= '<dt>' . t('Breakpoint') . '</dt>';
$output .= '<dd>' . t('A breakpoint separates the height or width of viewports (screens, printers, and other media output types) into steps. For instance, a width breakpoint of 40em creates two steps: one for widths up to 40em and one for widths above 40em. Breakpoints can be used to define when layouts should shift from one form to another, when images should be resized, and other changes that need to respond to changes in viewport height or width.') . '</dd>';
$output .= '<dt>' . t('Media query') . '</dt>';
- $output .= '<dd>' . t('<a href=":w3">Media queries</a> are a formal way to encode breakpoints. For instance, a width breakpoint at 40em would be written as the media query "(min-width: 40em)". Breakpoints are really just media queries with some additional meta-data, such as a name and multiplier information.', array(':w3' => 'http://www.w3.org/TR/css3-mediaqueries/')) . '</dd>';
+ $output .= '<dd>' . t('<a href=":w3">Media queries</a> are a formal way to encode breakpoints. For instance, a width breakpoint at 40em would be written as the media query "(min-width: 40em)". Breakpoints are really just media queries with some additional meta-data, such as a name and multiplier information.', [':w3' => 'http://www.w3.org/TR/css3-mediaqueries/']) . '</dd>';
$output .= '<dt>' . t('Resolution multiplier') . '</dt>';
$output .= '<dd>' . t('Resolution multipliers are a measure of the viewport\'s device resolution, defined to be the ratio between the physical pixel size of the active device and the <a href="http://en.wikipedia.org/wiki/Device_independent_pixel">device-independent pixel</a> size. The Breakpoint module defines multipliers of 1, 1.5, and 2; when defining breakpoints, modules and themes can define which multipliers apply to each breakpoint.') . '</dd>';
$output .= '<dt>' . t('Breakpoint group') . '</dt>';
diff --git a/core/modules/breakpoint/src/Breakpoint.php b/core/modules/breakpoint/src/Breakpoint.php
index 0c51e6353f3..0928d559616 100644
--- a/core/modules/breakpoint/src/Breakpoint.php
+++ b/core/modules/breakpoint/src/Breakpoint.php
@@ -16,7 +16,7 @@ class Breakpoint extends PluginBase implements BreakpointInterface {
* {@inheritdoc}
*/
public function getLabel() {
- return $this->t($this->pluginDefinition['label'], array(), array('context' => 'breakpoint'));
+ return $this->t($this->pluginDefinition['label'], [], ['context' => 'breakpoint']);
}
/**
diff --git a/core/modules/breakpoint/src/BreakpointManager.php b/core/modules/breakpoint/src/BreakpointManager.php
index 693ffa9b1ed..30caf27ebeb 100644
--- a/core/modules/breakpoint/src/BreakpointManager.php
+++ b/core/modules/breakpoint/src/BreakpointManager.php
@@ -50,7 +50,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
/**
* {@inheritdoc}
*/
- protected $defaults = array(
+ protected $defaults = [
// Human readable label for breakpoint.
'label' => '',
// The media query for the breakpoint.
@@ -58,14 +58,14 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
// Weight used for ordering breakpoints.
'weight' => 0,
// Breakpoint multipliers.
- 'multipliers' => array(),
+ 'multipliers' => [],
// The breakpoint group.
'group' => '',
// Default class for breakpoint implementations.
'class' => 'Drupal\breakpoint\Breakpoint',
// The plugin id. Set by the plugin system based on the top-level YAML key.
'id' => '',
- );
+ ];
/**
* The theme handler.
@@ -86,7 +86,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
*
* @var array
*/
- protected $instances = array();
+ protected $instances = [];
/**
* Constructs a new BreakpointManager instance.
@@ -106,7 +106,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
$this->themeHandler = $theme_handler;
$this->setStringTranslation($string_translation);
$this->alterInfo('breakpoints');
- $this->setCacheBackend($cache_backend, 'breakpoints', array('breakpoints'));
+ $this->setCacheBackend($cache_backend, 'breakpoints', ['breakpoints']);
}
/**
@@ -153,19 +153,19 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
$this->breakpointsByGroup[$group] = $cache->data;
}
else {
- $breakpoints = array();
+ $breakpoints = [];
foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) {
if ($plugin_definition['group'] == $group) {
$breakpoints[$plugin_id] = $plugin_definition;
}
}
- uasort($breakpoints, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
- $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, array('breakpoints'));
+ uasort($breakpoints, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
+ $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, ['breakpoints']);
$this->breakpointsByGroup[$group] = $breakpoints;
}
}
- $instances = array();
+ $instances = [];
foreach ($this->breakpointsByGroup[$group] as $plugin_id => $definition) {
if (!isset($this->instances[$plugin_id])) {
$this->instances[$plugin_id] = $this->createInstance($plugin_id);
@@ -184,16 +184,16 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
$groups = $cache->data;
}
else {
- $groups = array();
+ $groups = [];
foreach ($this->getDefinitions() as $plugin_definition) {
if (!isset($groups[$plugin_definition['group']])) {
$groups[$plugin_definition['group']] = $plugin_definition['group'];
}
}
- $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, array('breakpoints'));
+ $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, ['breakpoints']);
}
// Get the labels. This is not cacheable due to translation.
- $group_labels = array();
+ $group_labels = [];
foreach ($groups as $group) {
$group_labels[$group] = $this->getGroupLabel($group);
}
@@ -205,7 +205,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
* {@inheritdoc}
*/
public function getGroupProviders($group) {
- $providers = array();
+ $providers = [];
$breakpoints = $this->getBreakpointsByGroup($group);
foreach ($breakpoints as $breakpoint) {
$provider = $breakpoint->getProvider();
@@ -229,7 +229,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
public function clearCachedDefinitions() {
parent::clearCachedDefinitions();
$this->breakpointsByGroup = NULL;
- $this->instances = array();
+ $this->instances = [];
}
/**
@@ -251,7 +251,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
}
else {
// Custom group label that should be translatable.
- $label = $this->t($group, array(), array('context' => 'breakpoint'));
+ $label = $this->t($group, [], ['context' => 'breakpoint']);
}
return $label;
}
diff --git a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
index 7683ea1f668..dc8175787b4 100644
--- a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
+++ b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
@@ -16,11 +16,11 @@ class BreakpointDiscoveryTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'breakpoint', 'breakpoint_module_test');
+ public static $modules = ['system', 'breakpoint', 'breakpoint_module_test'];
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('breakpoint_theme_test'));
+ \Drupal::service('theme_handler')->install(['breakpoint_theme_test']);
}
/**
@@ -28,56 +28,56 @@ class BreakpointDiscoveryTest extends KernelTestBase {
*/
public function testThemeBreakpoints() {
// Verify the breakpoint group for breakpoint_theme_test was created.
- $expected_breakpoints = array(
- 'breakpoint_theme_test.mobile' => array(
+ $expected_breakpoints = [
+ 'breakpoint_theme_test.mobile' => [
'label' => 'mobile',
'mediaQuery' => '(min-width: 0px)',
'weight' => 0,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.mobile',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.narrow' => array(
+ ],
+ 'breakpoint_theme_test.narrow' => [
'label' => 'narrow',
'mediaQuery' => '(min-width: 560px)',
'weight' => 1,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.narrow',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.wide' => array(
+ ],
+ 'breakpoint_theme_test.wide' => [
'label' => 'wide',
'mediaQuery' => '(min-width: 851px)',
'weight' => 2,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.wide',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.tv' => array(
+ ],
+ 'breakpoint_theme_test.tv' => [
'label' => 'tv',
'mediaQuery' => 'only screen and (min-width: 1220px)',
'weight' => 3,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.tv',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- );
+ ],
+ ];
$breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test');
foreach ($expected_breakpoints as $id => $expected_breakpoint) {
@@ -93,46 +93,46 @@ class BreakpointDiscoveryTest extends KernelTestBase {
*/
public function testCustomBreakpointGroups() {
// Verify the breakpoint group for breakpoint_theme_test.group2 was created.
- $expected_breakpoints = array(
- 'breakpoint_theme_test.group2.narrow' => array(
+ $expected_breakpoints = [
+ 'breakpoint_theme_test.group2.narrow' => [
'label' => 'narrow',
'mediaQuery' => '(min-width: 560px)',
'weight' => 0,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
'2x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.group2.narrow',
'group' => 'breakpoint_theme_test.group2',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.group2.wide' => array(
+ ],
+ 'breakpoint_theme_test.group2.wide' => [
'label' => 'wide',
'mediaQuery' => '(min-width: 851px)',
'weight' => 1,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
'2x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.group2.wide',
'group' => 'breakpoint_theme_test.group2',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_module_test.breakpoint_theme_test.group2.tv' => array(
+ ],
+ 'breakpoint_module_test.breakpoint_theme_test.group2.tv' => [
'label' => 'tv',
'mediaQuery' => '(min-width: 6000px)',
'weight' => 2,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_module_test',
'id' => 'breakpoint_module_test.breakpoint_theme_test.group2.tv',
'group' => 'breakpoint_theme_test.group2',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- );
+ ],
+ ];
$breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test.group2');
foreach ($expected_breakpoints as $id => $expected_breakpoint) {
@@ -144,33 +144,33 @@ class BreakpointDiscoveryTest extends KernelTestBase {
* Test the breakpoint group created for a module.
*/
public function testModuleBreakpoints() {
- $expected_breakpoints = array(
- 'breakpoint_module_test.mobile' => array(
+ $expected_breakpoints = [
+ 'breakpoint_module_test.mobile' => [
'label' => 'mobile',
'mediaQuery' => '(min-width: 0px)',
'weight' => 0,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_module_test',
'id' => 'breakpoint_module_test.mobile',
'group' => 'breakpoint_module_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_module_test.standard' => array(
+ ],
+ 'breakpoint_module_test.standard' => [
'label' => 'standard',
'mediaQuery' => '(min-width: 560px)',
'weight' => 1,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
'2x',
- ),
+ ],
'provider' => 'breakpoint_module_test',
'id' => 'breakpoint_module_test.standard',
'group' => 'breakpoint_module_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- );
+ ],
+ ];
$breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_module_test');
$this->assertEqual(array_keys($expected_breakpoints), array_keys($breakpoints));
@@ -180,20 +180,20 @@ class BreakpointDiscoveryTest extends KernelTestBase {
* Test the collection of breakpoint groups.
*/
public function testBreakpointGroups() {
- $expected = array(
+ $expected = [
'bartik' => 'Bartik',
'breakpoint_module_test' => 'Breakpoint test module',
'breakpoint_theme_test' => 'Breakpoint test theme',
'breakpoint_theme_test.group2' => 'breakpoint_theme_test.group2',
- );
+ ];
$breakpoint_groups = \Drupal::service('breakpoint.manager')->getGroups();
// Ensure the order is as expected. Should be sorted by label.
$this->assertIdentical($expected, $this->castSafeStrings($breakpoint_groups));
- $expected = array(
+ $expected = [
'breakpoint_theme_test' => 'theme',
'breakpoint_module_test' => 'module',
- );
+ ];
$breakpoint_group_providers = \Drupal::service('breakpoint.manager')->getGroupProviders('breakpoint_theme_test.group2');
$this->assertEqual($expected, $breakpoint_group_providers);
}
diff --git a/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php b/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
index bdd5cd9341e..4b8fd884655 100644
--- a/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
+++ b/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
@@ -24,9 +24,9 @@ class BreakpointTest extends UnitTestCase {
*
* @var array
*/
- protected $pluginDefinition = array(
+ protected $pluginDefinition = [
'id' => 'breakpoint',
- );
+ ];
/**
* The breakpoint under test.
@@ -52,7 +52,7 @@ class BreakpointTest extends UnitTestCase {
* Sets up the breakpoint defaults.
*/
protected function setupBreakpoint() {
- $this->breakpoint = new Breakpoint(array(), $this->pluginId, $this->pluginDefinition);
+ $this->breakpoint = new Breakpoint([], $this->pluginId, $this->pluginDefinition);
$this->breakpoint->setStringTranslation($this->stringTranslation);
}
@@ -62,7 +62,7 @@ class BreakpointTest extends UnitTestCase {
public function testGetLabel() {
$this->pluginDefinition['label'] = 'Test label';
$this->setupBreakpoint();
- $this->assertEquals(new TranslatableMarkup('Test label', array(), array('context' => 'breakpoint'), $this->stringTranslation), $this->breakpoint->getLabel());
+ $this->assertEquals(new TranslatableMarkup('Test label', [], ['context' => 'breakpoint'], $this->stringTranslation), $this->breakpoint->getLabel());
}
/**
@@ -88,9 +88,9 @@ class BreakpointTest extends UnitTestCase {
* @covers ::getMultipliers
*/
public function testGetMultipliers() {
- $this->pluginDefinition['multipliers'] = array('1x', '2x');
+ $this->pluginDefinition['multipliers'] = ['1x', '2x'];
$this->setupBreakpoint();
- $this->assertSame(array('1x', '2x'), $this->breakpoint->getMultipliers());
+ $this->assertSame(['1x', '2x'], $this->breakpoint->getMultipliers());
}
/**
diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc
index 14b2fd7c919..8a8f68c69bd 100644
--- a/core/modules/ckeditor/ckeditor.admin.inc
+++ b/core/modules/ckeditor/ckeditor.admin.inc
@@ -29,8 +29,8 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
// Create lists of active and disabled buttons.
$editor = $variables['editor'];
$plugins = $variables['plugins'];
- $buttons = array();
- $multiple_buttons = array();
+ $buttons = [];
+ $multiple_buttons = [];
foreach ($plugins as $plugin_buttons) {
foreach ($plugin_buttons as $button_name => $button) {
$button['name'] = $button_name;
@@ -40,11 +40,11 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
$buttons[$button_name] = $button;
}
}
- $button_groups = array();
- $active_buttons = array();
+ $button_groups = [];
+ $active_buttons = [];
$settings = $editor->getSettings();
foreach ($settings['toolbar']['rows'] as $row_number => $row) {
- $button_groups[$row_number] = array();
+ $button_groups[$row_number] = [];
foreach ($row as $group) {
foreach ($group['items'] as $button_name) {
if (isset($buttons[$button_name])) {
@@ -75,31 +75,31 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
$value = $button['image_alternative'];
}
elseif (isset($button['image']) || isset($button['image' . $rtl])) {
- $value = array(
+ $value = [
'#theme' => 'image',
'#uri' => isset($button['image' . $rtl]) ? $button['image' . $rtl] : $button['image'],
'#title' => $button['label'],
'#prefix' => '<a href="#" role="button" title="' . $button['label'] . '" aria-label="' . $button['label'] . '"><span class="cke_button_icon">',
'#suffix' => '</span></a>',
- );
+ ];
}
else {
$value = '?';
}
// Build the button attributes.
- $attributes = array(
+ $attributes = [
'data-drupal-ckeditor-button-name' => $button['name'],
- );
+ ];
if (!empty($button['attributes'])) {
$attributes = array_merge($attributes, $button['attributes']);
}
// Build the button item.
- $button_item = array(
+ $button_item = [
'value' => $value,
'attributes' => new Attribute($attributes),
- );
+ ];
// If this button has group information, add it to the attributes.
if (!empty($button['group'])) {
$button_item['group'] = $button['group'];
@@ -114,14 +114,14 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
};
// Assemble list of disabled buttons (which are always a single row).
- $variables['active_buttons'] = array();
+ $variables['active_buttons'] = [];
foreach ($active_buttons as $row_number => $button_row) {
foreach ($button_groups[$row_number] as $group_name) {
$group_name = (string) $group_name;
- $variables['active_buttons'][$row_number][$group_name] = array(
+ $variables['active_buttons'][$row_number][$group_name] = [
'group_name_class' => Html::getClass($group_name),
- 'buttons' => array(),
- );
+ 'buttons' => [],
+ ];
$buttons = array_filter($button_row, function ($button) use ($group_name) {
return (string) $button['group'] === $group_name;
});
@@ -131,12 +131,12 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
}
}
// Assemble list of disabled buttons (which are always a single row).
- $variables['disabled_buttons'] = array();
+ $variables['disabled_buttons'] = [];
foreach ($disabled_buttons as $button) {
$variables['disabled_buttons'][] = $build_button_item($button, $rtl);
}
// Assemble list of multiple buttons that may be added multiple times.
- $variables['multiple_buttons'] = array();
+ $variables['multiple_buttons'] = [];
foreach ($multiple_buttons as $button) {
$variables['multiple_buttons'][] = $build_button_item($button, $rtl);
}
diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module
index 115afe24cf9..79052534406 100644
--- a/core/modules/ckeditor/ckeditor.module
+++ b/core/modules/ckeditor/ckeditor.module
@@ -17,21 +17,21 @@ function ckeditor_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.ckeditor':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The CKEditor module provides a highly-accessible, highly-usable visual text editor and adds a toolbar to text fields. Users can use buttons to format content and to create semantically correct and valid HTML. The CKEditor module uses the framework provided by the <a href=":text_editor">Text Editor module</a>. It requires JavaScript to be enabled in the browser. For more information, see the <a href=":doc_url">online documentation for the CKEditor module</a> and the <a href=":cke_url">CKEditor website</a>.', array( ':doc_url' => 'https://www.drupal.org/documentation/modules/ckeditor', ':cke_url' => 'http://ckeditor.com', ':text_editor' => \Drupal::url('help.page', array('name' => 'editor')))) . '</p>';
+ $output .= '<p>' . t('The CKEditor module provides a highly-accessible, highly-usable visual text editor and adds a toolbar to text fields. Users can use buttons to format content and to create semantically correct and valid HTML. The CKEditor module uses the framework provided by the <a href=":text_editor">Text Editor module</a>. It requires JavaScript to be enabled in the browser. For more information, see the <a href=":doc_url">online documentation for the CKEditor module</a> and the <a href=":cke_url">CKEditor website</a>.', [ ':doc_url' => 'https://www.drupal.org/documentation/modules/ckeditor', ':cke_url' => 'http://ckeditor.com', ':text_editor' => \Drupal::url('help.page', ['name' => 'editor'])]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Enabling CKEditor for individual text formats') . '</dt>';
- $output .= '<dd>' . t('CKEditor has to be enabled and configured separately for individual text formats from the <a href=":formats">Text formats and editors page</a> because the filter settings for each text format can be different. For more information, see the <a href=":text_editor">Text Editor help page</a> and <a href=":filter">Filter help page</a>.', array(':formats' => \Drupal::url('filter.admin_overview'), ':text_editor' => \Drupal::url('help.page', array('name' => 'editor')), ':filter' => \Drupal::url('help.page', array('name' => 'filter')))) . '</dd>';
+ $output .= '<dd>' . t('CKEditor has to be enabled and configured separately for individual text formats from the <a href=":formats">Text formats and editors page</a> because the filter settings for each text format can be different. For more information, see the <a href=":text_editor">Text Editor help page</a> and <a href=":filter">Filter help page</a>.', [':formats' => \Drupal::url('filter.admin_overview'), ':text_editor' => \Drupal::url('help.page', ['name' => 'editor']), ':filter' => \Drupal::url('help.page', ['name' => 'filter'])]) . '</dd>';
$output .= '<dt>' . t('Configuring the toolbar') . '</dt>';
$output .= '<dd>' . t('When CKEditor is chosen from the <em>Text editor</em> drop-down menu, its toolbar configuration is displayed. You can add and remove buttons from the <em>Active toolbar</em> by dragging and dropping them, and additional rows can be added to organize the buttons.') . '</dd>';
$output .= '<dt>' . t('Formatting content') . '</dt>';
- $output .= '<dd>' . t('CKEditor only allow users to format content in accordance with the filter configuration of the specific text format. If a text format excludes certain HTML tags, the corresponding toolbar buttons are not displayed to users when they edit a text field in this format. For more information see the <a href=":filter">Filter help page</a>.', array(':filter' => \Drupal::url('help.page', array('name' => 'filter')))) . '</dd>';
+ $output .= '<dd>' . t('CKEditor only allow users to format content in accordance with the filter configuration of the specific text format. If a text format excludes certain HTML tags, the corresponding toolbar buttons are not displayed to users when they edit a text field in this format. For more information see the <a href=":filter">Filter help page</a>.', [':filter' => \Drupal::url('help.page', ['name' => 'filter'])]) . '</dd>';
$output .= '<dt>' . t('Toggling between formatted text and HTML source') . '</dt>';
$output .= '<dd>' . t('If the <em>Source</em> button is available in the toolbar, users can click this button to disable the visual editor and edit the HTML source directly. After toggling back, the visual editor uses the allowed HTML tags to format the text — independent of whether buttons for these tags are available in the toolbar. If the text format is set to <em>limit the use of HTML tags</em>, then all excluded tags will be stripped out of the HTML source when the user toggles back to the text editor.') . '</dd>';
$output .= '<dt>' . t('Check my spelling as I type') . '</dt>';
$output .= '<dd>' . t('By default, CKEditor is configured to leverage your browser\'s spell check capability. Make sure your browser\'s spell checker is enabled in your browser\'s settings. To access suggested corrections for misspelled words, it may be necessary to hold the <em>Control</em> or <em>command</em> (Mac) key while right-clicking the misspelling.') . '</dd>';
$output .= '<dt>' . t('Accessibility features') . '</dt>';
- $output .= '<dd>' . t('The built in WYSIWYG editor (CKEditor) comes with a number of <a href=":features">accessibility features</a>. CKEditor comes with built in <a href=":shortcuts">keyboard shortcuts</a>, which can be beneficial for both power users and keyboard only users.', array(':features' => 'http://docs.ckeditor.com/#!/guide/dev_a11y', ':shortcuts' => 'http://docs.ckeditor.com/#!/guide/dev_shortcuts')) . '</dd>';
+ $output .= '<dd>' . t('The built in WYSIWYG editor (CKEditor) comes with a number of <a href=":features">accessibility features</a>. CKEditor comes with built in <a href=":shortcuts">keyboard shortcuts</a>, which can be beneficial for both power users and keyboard only users.', [':features' => 'http://docs.ckeditor.com/#!/guide/dev_a11y', ':shortcuts' => 'http://docs.ckeditor.com/#!/guide/dev_shortcuts']) . '</dd>';
$output .= '<dt>' . t('Generating accessible content') . '</dt>';
$output .= '<dd>' . t('HTML tables can be created with both table headers as well as caption/summary elements. Alt text is required by default on images added through CKEditor (note that this can be overridden). Semantic HTML5 figure/figcaption are available to add captions to images.') . '</dd>';
$output .= '</dl>';
@@ -43,12 +43,12 @@ function ckeditor_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function ckeditor_theme() {
- return array(
- 'ckeditor_settings_toolbar' => array(
+ return [
+ 'ckeditor_settings_toolbar' => [
'file' => 'ckeditor.admin.inc',
- 'variables' => array('editor' => NULL, 'plugins' => NULL),
- ),
- );
+ 'variables' => ['editor' => NULL, 'plugins' => NULL],
+ ],
+ ];
}
/**
@@ -79,7 +79,7 @@ function ckeditor_ckeditor_css_alter(array &$css, Editor $editor) {
* @endcode
*/
function _ckeditor_theme_css($theme = NULL) {
- $css = array();
+ $css = [];
if (!isset($theme)) {
$theme = \Drupal::config('system.theme')->get('default');
}
diff --git a/core/modules/ckeditor/src/CKEditorPluginBase.php b/core/modules/ckeditor/src/CKEditorPluginBase.php
index 2fb479834b6..99f26630f23 100644
--- a/core/modules/ckeditor/src/CKEditorPluginBase.php
+++ b/core/modules/ckeditor/src/CKEditorPluginBase.php
@@ -41,14 +41,14 @@ abstract class CKEditorPluginBase extends PluginBase implements CKEditorPluginIn
* {@inheritdoc}
*/
function getDependencies(Editor $editor) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
function getLibraries(Editor $editor) {
- return array();
+ return [];
}
}
diff --git a/core/modules/ckeditor/src/CKEditorPluginManager.php b/core/modules/ckeditor/src/CKEditorPluginManager.php
index dd3315a35a2..735cfa6678c 100644
--- a/core/modules/ckeditor/src/CKEditorPluginManager.php
+++ b/core/modules/ckeditor/src/CKEditorPluginManager.php
@@ -68,8 +68,8 @@ class CKEditorPluginManager extends DefaultPluginManager {
public function getEnabledPluginFiles(Editor $editor, $include_internal_plugins = FALSE) {
$plugins = array_keys($this->getDefinitions());
$toolbar_buttons = $this->getEnabledButtons($editor);
- $enabled_plugins = array();
- $additional_plugins = array();
+ $enabled_plugins = [];
+ $additional_plugins = [];
foreach ($plugins as $plugin_id) {
$plugin = $this->createInstance($plugin_id);
@@ -139,7 +139,7 @@ class CKEditorPluginManager extends DefaultPluginManager {
*/
public function getButtons() {
$plugins = array_keys($this->getDefinitions());
- $buttons_plugins = array();
+ $buttons_plugins = [];
foreach ($plugins as $plugin_id) {
$plugin = $this->createInstance($plugin_id);
@@ -167,16 +167,16 @@ class CKEditorPluginManager extends DefaultPluginManager {
foreach (array_keys($definitions) as $plugin_id) {
$plugin = $this->createInstance($plugin_id);
if ($plugin instanceof CKEditorPluginConfigurableInterface) {
- $plugin_settings_form = array();
- $form['plugins'][$plugin_id] = array(
+ $plugin_settings_form = [];
+ $form['plugins'][$plugin_id] = [
'#type' => 'details',
'#title' => $definitions[$plugin_id]['label'],
'#open' => TRUE,
'#group' => 'editor][settings][plugin_settings',
- '#attributes' => array(
+ '#attributes' => [
'data-ckeditor-plugin-id' => $plugin_id,
- ),
- );
+ ],
+ ];
// Provide enough metadata for the drupal.ckeditor.admin library to
// allow it to automatically show/hide the vertical tab containing the
// settings for this plugin. Only do this if it's a CKEditor plugin that
@@ -206,7 +206,7 @@ class CKEditorPluginManager extends DefaultPluginManager {
*/
public function getCssFiles(Editor $editor) {
$enabled_plugins = array_keys($this->getEnabledPluginFiles($editor, TRUE));
- $css_files = array();
+ $css_files = [];
foreach ($enabled_plugins as $plugin_id) {
$plugin = $this->createInstance($plugin_id);
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php
index 8529adb5add..90d4eae8f47 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php
@@ -29,31 +29,31 @@ class DrupalImage extends CKEditorPluginBase implements CKEditorPluginConfigurab
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
- return array(
+ return [
'core/drupal.ajax',
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
- return array(
+ return [
'drupalImage_dialogTitleAdd' => $this->t('Insert Image'),
'drupalImage_dialogTitleEdit' => $this->t('Edit Image'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getButtons() {
- return array(
- 'DrupalImage' => array(
+ return [
+ 'DrupalImage' => [
'label' => $this->t('Image'),
'image' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage/icons/drupalimage.png',
- ),
- );
+ ],
+ ];
}
/**
@@ -66,7 +66,7 @@ class DrupalImage extends CKEditorPluginBase implements CKEditorPluginConfigurab
$form_state->loadInclude('editor', 'admin.inc');
$form['image_upload'] = editor_image_upload_settings_form($editor);
$form['image_upload']['#attached']['library'][] = 'ckeditor/drupal.ckeditor.drupalimage.admin';
- $form['image_upload']['#element_validate'][] = array($this, 'validateImageUploadSettings');
+ $form['image_upload']['#element_validate'][] = [$this, 'validateImageUploadSettings'];
return $form;
}
@@ -80,9 +80,9 @@ class DrupalImage extends CKEditorPluginBase implements CKEditorPluginConfigurab
* @see editor_image_upload_settings_form()
*/
function validateImageUploadSettings(array $element, FormStateInterface $form_state) {
- $settings = &$form_state->getValue(array('editor', 'settings', 'plugins', 'drupalimage', 'image_upload'));
+ $settings = &$form_state->getValue(['editor', 'settings', 'plugins', 'drupalimage', 'image_upload']);
$form_state->get('editor')->setImageUploadSettings($settings);
- $form_state->unsetValue(array('editor', 'settings', 'plugins', 'drupalimage'));
+ $form_state->unsetValue(['editor', 'settings', 'plugins', 'drupalimage']);
}
}
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php
index 16c3759d936..4241c3ca027 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php
@@ -30,16 +30,16 @@ class DrupalImageCaption extends PluginBase implements CKEditorPluginInterface,
* {@inheritdoc}
*/
public function getDependencies(Editor $editor) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
- return array(
+ return [
'ckeditor/drupal.ckeditor.plugins.drupalimagecaption',
- );
+ ];
}
/**
@@ -54,24 +54,24 @@ class DrupalImageCaption extends PluginBase implements CKEditorPluginInterface,
*/
public function getConfig(Editor $editor) {
$format = $editor->getFilterFormat();
- return array(
+ return [
'image2_captionedClass' => 'caption caption-img',
- 'image2_alignClasses' => array('align-left', 'align-center', 'align-right'),
+ 'image2_alignClasses' => ['align-left', 'align-center', 'align-right'],
'drupalImageCaption_captionPlaceholderText' => $this->t('Enter caption here'),
// Only enable those parts of DrupalImageCaption for which the
// corresponding Drupal text filters are enabled.
'drupalImageCaption_captionFilterEnabled' => $format->filters('filter_caption')->status,
'drupalImageCaption_alignFilterEnabled' => $format->filters('filter_align')->status,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getCssFiles(Editor $editor) {
- return array(
+ return [
drupal_get_path('module', 'ckeditor') . '/css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css'
- );
+ ];
}
/**
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php
index f347ebf230f..a6363f6b73f 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php
@@ -27,19 +27,19 @@ class DrupalLink extends CKEditorPluginBase {
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
- return array(
+ return [
'core/drupal.ajax',
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
- return array(
+ return [
'drupalLink_dialogTitleAdd' => $this->t('Add Link'),
'drupalLink_dialogTitleEdit' => $this->t('Edit Link'),
- );
+ ];
}
/**
@@ -47,16 +47,16 @@ class DrupalLink extends CKEditorPluginBase {
*/
public function getButtons() {
$path = drupal_get_path('module', 'ckeditor') . '/js/plugins/drupallink';
- return array(
- 'DrupalLink' => array(
+ return [
+ 'DrupalLink' => [
'label' => $this->t('Link'),
'image' => $path . '/icons/drupallink.png',
- ),
- 'DrupalUnlink' => array(
+ ],
+ 'DrupalUnlink' => [
'label' => $this->t('Unlink'),
'image' => $path . '/icons/drupalunlink.png',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
index 5011282c391..9a04ce72a20 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
@@ -100,14 +100,14 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
*/
public function getConfig(Editor $editor) {
// Reasonable defaults that provide expected basic behavior.
- $config = array(
+ $config = [
'customConfig' => '', // Don't load CKEditor's config.js file.
'pasteFromWordPromptCleanup' => TRUE,
'resize_dir' => 'vertical',
- 'justifyClasses' => array('text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'),
+ 'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'],
'entities' => FALSE,
'disableNativeSpellChecker' => FALSE,
- );
+ ];
// Add the allowedContent setting, which ensures CKEditor only allows tags
// and attributes that are allowed by the text format for this text editor.
@@ -144,145 +144,145 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
];
};
- return array(
+ return [
// "basicstyles" plugin.
- 'Bold' => array(
+ 'Bold' => [
'label' => $this->t('Bold'),
'image_alternative' => $button('bold'),
'image_alternative_rtl' => $button('bold', 'rtl'),
- ),
- 'Italic' => array(
+ ],
+ 'Italic' => [
'label' => $this->t('Italic'),
'image_alternative' => $button('italic'),
'image_alternative_rtl' => $button('italic', 'rtl'),
- ),
- 'Underline' => array(
+ ],
+ 'Underline' => [
'label' => $this->t('Underline'),
'image_alternative' => $button('underline'),
'image_alternative_rtl' => $button('underline', 'rtl'),
- ),
- 'Strike' => array(
+ ],
+ 'Strike' => [
'label' => $this->t('Strike-through'),
'image_alternative' => $button('strike'),
'image_alternative_rtl' => $button('strike', 'rtl'),
- ),
- 'Superscript' => array(
+ ],
+ 'Superscript' => [
'label' => $this->t('Superscript'),
'image_alternative' => $button('super script'),
'image_alternative_rtl' => $button('super script', 'rtl'),
- ),
- 'Subscript' => array(
+ ],
+ 'Subscript' => [
'label' => $this->t('Subscript'),
'image_alternative' => $button('sub script'),
'image_alternative_rtl' => $button('sub script', 'rtl'),
- ),
+ ],
// "removeformat" plugin.
- 'RemoveFormat' => array(
+ 'RemoveFormat' => [
'label' => $this->t('Remove format'),
'image_alternative' => $button('remove format'),
'image_alternative_rtl' => $button('remove format', 'rtl'),
- ),
+ ],
// "justify" plugin.
- 'JustifyLeft' => array(
+ 'JustifyLeft' => [
'label' => $this->t('Align left'),
'image_alternative' => $button('justify left'),
'image_alternative_rtl' => $button('justify left', 'rtl'),
- ),
- 'JustifyCenter' => array(
+ ],
+ 'JustifyCenter' => [
'label' => $this->t('Align center'),
'image_alternative' => $button('justify center'),
'image_alternative_rtl' => $button('justify center', 'rtl'),
- ),
- 'JustifyRight' => array(
+ ],
+ 'JustifyRight' => [
'label' => $this->t('Align right'),
'image_alternative' => $button('justify right'),
'image_alternative_rtl' => $button('justify right', 'rtl'),
- ),
- 'JustifyBlock' => array(
+ ],
+ 'JustifyBlock' => [
'label' => $this->t('Justify'),
'image_alternative' => $button('justify block'),
'image_alternative_rtl' => $button('justify block', 'rtl'),
- ),
+ ],
// "list" plugin.
- 'BulletedList' => array(
+ 'BulletedList' => [
'label' => $this->t('Bullet list'),
'image_alternative' => $button('bulleted list'),
'image_alternative_rtl' => $button('bulleted list', 'rtl'),
- ),
- 'NumberedList' => array(
+ ],
+ 'NumberedList' => [
'label' => $this->t('Numbered list'),
'image_alternative' => $button('numbered list'),
'image_alternative_rtl' => $button('numbered list', 'rtl'),
- ),
+ ],
// "indent" plugin.
- 'Outdent' => array(
+ 'Outdent' => [
'label' => $this->t('Outdent'),
'image_alternative' => $button('outdent'),
'image_alternative_rtl' => $button('outdent', 'rtl'),
- ),
- 'Indent' => array(
+ ],
+ 'Indent' => [
'label' => $this->t('Indent'),
'image_alternative' => $button('indent'),
'image_alternative_rtl' => $button('indent', 'rtl'),
- ),
+ ],
// "undo" plugin.
- 'Undo' => array(
+ 'Undo' => [
'label' => $this->t('Undo'),
'image_alternative' => $button('undo'),
'image_alternative_rtl' => $button('undo', 'rtl'),
- ),
- 'Redo' => array(
+ ],
+ 'Redo' => [
'label' => $this->t('Redo'),
'image_alternative' => $button('redo'),
'image_alternative_rtl' => $button('redo', 'rtl'),
- ),
+ ],
// "blockquote" plugin.
- 'Blockquote' => array(
+ 'Blockquote' => [
'label' => $this->t('Blockquote'),
'image_alternative' => $button('blockquote'),
'image_alternative_rtl' => $button('blockquote', 'rtl'),
- ),
+ ],
// "horizontalrule" plugin
- 'HorizontalRule' => array(
+ 'HorizontalRule' => [
'label' => $this->t('Horizontal rule'),
'image_alternative' => $button('horizontal rule'),
'image_alternative_rtl' => $button('horizontal rule', 'rtl'),
- ),
+ ],
// "clipboard" plugin.
- 'Cut' => array(
+ 'Cut' => [
'label' => $this->t('Cut'),
'image_alternative' => $button('cut'),
'image_alternative_rtl' => $button('cut', 'rtl'),
- ),
- 'Copy' => array(
+ ],
+ 'Copy' => [
'label' => $this->t('Copy'),
'image_alternative' => $button('copy'),
'image_alternative_rtl' => $button('copy', 'rtl'),
- ),
- 'Paste' => array(
+ ],
+ 'Paste' => [
'label' => $this->t('Paste'),
'image_alternative' => $button('paste'),
'image_alternative_rtl' => $button('paste', 'rtl'),
- ),
+ ],
// "pastetext" plugin.
- 'PasteText' => array(
+ 'PasteText' => [
'label' => $this->t('Paste Text'),
'image_alternative' => $button('paste text'),
'image_alternative_rtl' => $button('paste text', 'rtl'),
- ),
+ ],
// "pastefromword" plugin.
- 'PasteFromWord' => array(
+ 'PasteFromWord' => [
'label' => $this->t('Paste from Word'),
'image_alternative' => $button('paste from word'),
'image_alternative_rtl' => $button('paste from word', 'rtl'),
- ),
+ ],
// "specialchar" plugin.
- 'SpecialChar' => array(
+ 'SpecialChar' => [
'label' => $this->t('Character map'),
'image_alternative' => $button('special char'),
'image_alternative_rtl' => $button('special char', 'rtl'),
- ),
- 'Format' => array(
+ ],
+ 'Format' => [
'label' => $this->t('HTML block format'),
'image_alternative' => [
'#type' => 'inline_template',
@@ -291,33 +291,33 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
'format_text' => $this->t('Format'),
],
],
- ),
+ ],
// "table" plugin.
- 'Table' => array(
+ 'Table' => [
'label' => $this->t('Table'),
'image_alternative' => $button('table'),
'image_alternative_rtl' => $button('table', 'rtl'),
- ),
+ ],
// "showblocks" plugin.
- 'ShowBlocks' => array(
+ 'ShowBlocks' => [
'label' => $this->t('Show blocks'),
'image_alternative' => $button('show blocks'),
'image_alternative_rtl' => $button('show blocks', 'rtl'),
- ),
+ ],
// "sourcearea" plugin.
- 'Source' => array(
+ 'Source' => [
'label' => $this->t('Source code'),
'image_alternative' => $button('source'),
'image_alternative_rtl' => $button('source', 'rtl'),
- ),
+ ],
// "maximize" plugin.
- 'Maximize' => array(
+ 'Maximize' => [
'label' => $this->t('Maximize'),
'image_alternative' => $button('maximize'),
'image_alternative_rtl' => $button('maximize', 'rtl'),
- ),
+ ],
// No plugin, separator "button" for toolbar builder UI use only.
- '-' => array(
+ '-' => [
'label' => $this->t('Separator'),
'image_alternative' => [
'#type' => 'inline_template',
@@ -326,13 +326,13 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
'button_separator_text' => $this->t('Button separator'),
],
],
- 'attributes' => array(
- 'class' => array('ckeditor-button-separator'),
+ 'attributes' => [
+ 'class' => ['ckeditor-button-separator'],
'data-drupal-ckeditor-type' => 'separator',
- ),
+ ],
'multiple' => TRUE,
- ),
- );
+ ],
+ ];
}
/**
@@ -350,7 +350,7 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
// When no text format is associated yet, assume no tag is allowed.
// @see \Drupal\Editor\EditorInterface::hasAssociatedFilterFormat()
if (!$editor->hasAssociatedFilterFormat()) {
- return array();
+ return [];
}
$format = $editor->getFilterFormat();
@@ -416,7 +416,7 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
// When nothing is disallowed, set allowedContent to true.
if (!in_array(FilterInterface::TYPE_HTML_RESTRICTOR, $filter_types)) {
- return array(TRUE, FALSE);
+ return [TRUE, FALSE];
}
// Generate setting that accurately reflects allowed tags and attributes.
else {
@@ -441,10 +441,10 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
// When all HTML is allowed, also set allowedContent to true and
// disallowedContent to false.
if ($html_restrictions === FALSE) {
- return array(TRUE, FALSE);
+ return [TRUE, FALSE];
}
- $allowed = array();
- $disallowed = array();
+ $allowed = [];
+ $disallowed = [];
if (isset($html_restrictions['forbidden_tags'])) {
foreach ($html_restrictions['forbidden_tags'] as $tag) {
$disallowed[$tag] = TRUE;
@@ -453,11 +453,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
foreach ($html_restrictions['allowed'] as $tag => $attributes) {
// Tell CKEditor the tag is allowed, but no attributes.
if ($attributes === FALSE) {
- $allowed[$tag] = array(
+ $allowed[$tag] = [
'attributes' => FALSE,
'styles' => FALSE,
'classes' => FALSE,
- );
+ ];
}
// Tell CKEditor the tag is allowed, as well as any attribute on it. The
// "style" and "class" attributes are handled separately by CKEditor:
@@ -465,11 +465,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
// attributes, unless you state specific values for them that are
// allowed. Or, in this case: any value for them is allowed.
elseif ($attributes === TRUE) {
- $allowed[$tag] = array(
+ $allowed[$tag] = [
'attributes' => TRUE,
'styles' => TRUE,
'classes' => TRUE,
- );
+ ];
// We've just marked that any value for the "style" and "class"
// attributes is allowed. However, that may not be the case: the "*"
// tag may still apply restrictions.
@@ -518,11 +518,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
elseif (is_array($attributes)) {
// Set defaults (these will be overridden below if more specific
// values are present).
- $allowed[$tag] = array(
+ $allowed[$tag] = [
'attributes' => FALSE,
'styles' => FALSE,
'classes' => FALSE,
- );
+ ];
// Configure allowed attributes, allowed "style" attribute values and
// allowed "class" attribute values.
// CKEditor only allows specific values for the "class" and "style"
@@ -600,7 +600,7 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
ksort($allowed);
ksort($disallowed);
- return array($allowed, $disallowed);
+ return [$allowed, $disallowed];
}
}
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php
index 980d5e909a6..31ce08fc07a 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php
@@ -104,7 +104,7 @@ class Language extends CKEditorPluginBase implements CKEditorPluginConfigurableI
}
$predefined_languages = LanguageManager::getStandardLanguageList();
- $form['language_list'] = array(
+ $form['language_list'] = [
'#title' => $this->t('Language list'),
'#title_display' => 'invisible',
'#type' => 'select',
@@ -118,7 +118,7 @@ class Language extends CKEditorPluginBase implements CKEditorPluginConfigurableI
'@count' => count($predefined_languages),
]),
'#attached' => ['library' => ['ckeditor/drupal.ckeditor.language.admin']],
- );
+ ];
return $form;
}
@@ -127,9 +127,9 @@ class Language extends CKEditorPluginBase implements CKEditorPluginConfigurableI
* {@inheritdoc}
*/
function getCssFiles(Editor $editor) {
- return array(
+ return [
drupal_get_path('module', 'ckeditor') . '/css/plugins/language/ckeditor.language.css'
- );
+ ];
}
}
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
index 9c4f224752e..7b3386efe03 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
@@ -36,7 +36,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
- $config = array();
+ $config = [];
$settings = $editor->getSettings();
if (!isset($settings['plugins']['stylescombo']['styles'])) {
return $config;
@@ -50,8 +50,8 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
* {@inheritdoc}
*/
public function getButtons() {
- return array(
- 'Styles' => array(
+ return [
+ 'Styles' => [
'label' => $this->t('Font style'),
'image_alternative' => [
'#type' => 'inline_template',
@@ -60,8 +60,8 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
'styles_text' => $this->t('Styles'),
],
],
- ),
- );
+ ],
+ ];
}
/**
@@ -69,25 +69,25 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
*/
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
// Defaults.
- $config = array('styles' => '');
+ $config = ['styles' => ''];
$settings = $editor->getSettings();
if (isset($settings['plugins']['stylescombo'])) {
$config = $settings['plugins']['stylescombo'];
}
- $form['styles'] = array(
+ $form['styles'] = [
'#title' => $this->t('Styles'),
'#title_display' => 'invisible',
'#type' => 'textarea',
'#default_value' => $config['styles'],
'#description' => $this->t('A list of classes that will be provided in the "Styles" dropdown. Enter one or more classes on each line in the format: element.classA.classB|Label. Example: h1.title|Title. Advanced example: h1.fancy.title|Fancy title.<br />These styles should be available in your theme\'s CSS file.'),
- '#attached' => array(
- 'library' => array('ckeditor/drupal.ckeditor.stylescombo.admin'),
- ),
- '#element_validate' => array(
- array($this, 'validateStylesValue'),
- ),
- );
+ '#attached' => [
+ 'library' => ['ckeditor/drupal.ckeditor.stylescombo.admin'],
+ ],
+ '#element_validate' => [
+ [$this, 'validateStylesValue'],
+ ],
+ ];
return $form;
}
@@ -120,7 +120,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
* syntax is invalid.
*/
protected function generateStylesSetSetting($styles) {
- $styles_set = array();
+ $styles_set = [];
// Early-return when empty.
$styles = trim($styles);
@@ -128,7 +128,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
return $styles_set;
}
- $styles = str_replace(array("\r\n", "\r"), "\n", $styles);
+ $styles = str_replace(["\r\n", "\r"], "\n", $styles);
foreach (explode("\n", $styles) as $style) {
$style = trim($style);
@@ -149,14 +149,14 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
// Build the data structure CKEditor's stylescombo plugin expects.
// @see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Styles
- $configured_style = array(
+ $configured_style = [
'name' => trim($label),
'element' => trim($element),
- );
+ ];
if (!empty($classes)) {
- $configured_style['attributes'] = array(
+ $configured_style['attributes'] = [
'class' => implode(' ', array_map('trim', $classes))
- );
+ ];
}
$styles_set[] = $configured_style;
}
diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
index ba054a61ce5..d3a7f6b7370 100644
--- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
+++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
@@ -102,36 +102,36 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public function getDefaultSettings() {
- return array(
- 'toolbar' => array(
- 'rows' => array(
+ return [
+ 'toolbar' => [
+ 'rows' => [
// Button groups.
- array(
- array(
+ [
+ [
'name' => $this->t('Formatting'),
- 'items' => array('Bold', 'Italic',),
- ),
- array(
+ 'items' => ['Bold', 'Italic',],
+ ],
+ [
'name' => $this->t('Links'),
- 'items' => array('DrupalLink', 'DrupalUnlink',),
- ),
- array(
+ 'items' => ['DrupalLink', 'DrupalUnlink',],
+ ],
+ [
'name' => $this->t('Lists'),
- 'items' => array('BulletedList', 'NumberedList',),
- ),
- array(
+ 'items' => ['BulletedList', 'NumberedList',],
+ ],
+ [
'name' => $this->t('Media'),
- 'items' => array('Blockquote', 'DrupalImage',),
- ),
- array(
+ 'items' => ['Blockquote', 'DrupalImage',],
+ ],
+ [
'name' => $this->t('Tools'),
- 'items' => array('Source',),
- ),
- ),
- ),
- ),
+ 'items' => ['Source',],
+ ],
+ ],
+ ],
+ ],
'plugins' => ['language' => ['language_list' => 'un']],
- );
+ ];
}
/**
@@ -140,39 +140,39 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
$settings = $editor->getSettings();
- $ckeditor_settings_toolbar = array(
+ $ckeditor_settings_toolbar = [
'#theme' => 'ckeditor_settings_toolbar',
'#editor' => $editor,
'#plugins' => $this->ckeditorPluginManager->getButtons(),
- );
- $form['toolbar'] = array(
+ ];
+ $form['toolbar'] = [
'#type' => 'container',
- '#attached' => array(
- 'library' => array('ckeditor/drupal.ckeditor.admin'),
+ '#attached' => [
+ 'library' => ['ckeditor/drupal.ckeditor.admin'],
'drupalSettings' => [
'ckeditor' => [
'toolbarAdmin' => (string) $this->renderer->renderPlain($ckeditor_settings_toolbar),
],
],
- ),
- '#attributes' => array('class' => array('ckeditor-toolbar-configuration')),
- );
+ ],
+ '#attributes' => ['class' => ['ckeditor-toolbar-configuration']],
+ ];
- $form['toolbar']['button_groups'] = array(
+ $form['toolbar']['button_groups'] = [
'#type' => 'textarea',
'#title' => $this->t('Toolbar buttons'),
'#default_value' => json_encode($settings['toolbar']['rows']),
- '#attributes' => array('class' => array('ckeditor-toolbar-textarea')),
- );
+ '#attributes' => ['class' => ['ckeditor-toolbar-textarea']],
+ ];
// CKEditor plugin settings, if any.
- $form['plugin_settings'] = array(
+ $form['plugin_settings'] = [
'#type' => 'vertical_tabs',
'#title' => $this->t('CKEditor plugin settings'),
- '#attributes' => array(
+ '#attributes' => [
'id' => 'ckeditor-plugin-settings',
- ),
- );
+ ],
+ ];
$this->ckeditorPluginManager->injectPluginSettingsForm($form, $form_state, $editor);
if (count(Element::children($form['plugins'])) === 0) {
unset($form['plugins']);
@@ -186,7 +186,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
// settings to be updated accordingly.
// Get a list of all external plugins and their corresponding files.
$plugins = array_keys($this->ckeditorPluginManager->getDefinitions());
- $all_external_plugins = array();
+ $all_external_plugins = [];
foreach ($plugins as $plugin_id) {
$plugin = $this->ckeditorPluginManager->createInstance($plugin_id);
if (!$plugin->isInternal()) {
@@ -196,37 +196,37 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
// Get a list of all buttons that are provided by all plugins.
$all_buttons = array_reduce($this->ckeditorPluginManager->getButtons(), function($result, $item) {
return array_merge($result, array_keys($item));
- }, array());
+ }, []);
// Build a fake Editor object, which we'll use to generate JavaScript
// settings for this fake Editor instance.
- $fake_editor = Editor::create(array(
+ $fake_editor = Editor::create([
'format' => $editor->id(),
'editor' => 'ckeditor',
- 'settings' => array(
+ 'settings' => [
// Single toolbar row, single button group, all existing buttons.
- 'toolbar' => array(
- 'rows' => array(
- 0 => array(
- 0 => array(
+ 'toolbar' => [
+ 'rows' => [
+ 0 => [
+ 0 => [
'name' => 'All existing buttons',
'items' => $all_buttons,
- )
- )
- ),
- ),
+ ]
+ ]
+ ],
+ ],
'plugins' => $settings['plugins'],
- ),
- ));
+ ],
+ ]);
$config = $this->getJSSettings($fake_editor);
// Remove the ACF configuration that is generated based on filter settings,
// because otherwise we cannot retrieve per-feature metadata.
unset($config['allowedContent']);
- $form['hidden_ckeditor'] = array(
+ $form['hidden_ckeditor'] = [
'#markup' => '<div id="ckeditor-hidden" class="hidden"></div>',
- '#attached' => array(
+ '#attached' => [
'drupalSettings' => ['ckeditor' => ['hiddenCKEditorConfig' => $config]],
- ),
- );
+ ],
+ ];
return $form;
}
@@ -238,7 +238,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
// Modify the toolbar settings by reference. The values in
// $form_state->getValue(array('editor', 'settings')) will be saved directly
// by editor_form_filter_admin_format_submit().
- $toolbar_settings = &$form_state->getValue(array('editor', 'settings', 'toolbar'));
+ $toolbar_settings = &$form_state->getValue(['editor', 'settings', 'toolbar']);
// The rows key is not built into the form structure, so decode the button
// groups data into this new key and remove the button_groups key.
@@ -246,8 +246,8 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
unset($toolbar_settings['button_groups']);
// Remove the plugin settings' vertical tabs state; no need to save that.
- if ($form_state->hasValue(array('editor', 'settings', 'plugins'))) {
- $form_state->unsetValue(array('editor', 'settings', 'plugin_settings'));
+ if ($form_state->hasValue(['editor', 'settings', 'plugins'])) {
+ $form_state->unsetValue(['editor', 'settings', 'plugin_settings']);
}
}
@@ -255,7 +255,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public function getJSSettings(Editor $editor) {
- $settings = array();
+ $settings = [];
// Get the settings for all enabled plugins, even the internal ones.
$enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor, TRUE));
@@ -279,7 +279,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
// Next, set the most fundamental CKEditor settings.
$external_plugin_files = $this->ckeditorPluginManager->getEnabledPluginFiles($editor);
- $settings += array(
+ $settings += [
'toolbar' => $this->buildToolbarJSSetting($editor),
'contentsCss' => $this->buildContentsCssJSSetting($editor),
'extraPlugins' => implode(',', array_keys($external_plugin_files)),
@@ -290,15 +290,15 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
// styles.js by default.
// See http://dev.ckeditor.com/ticket/9992#comment:9.
'stylesSet' => FALSE,
- );
+ ];
// Finally, set Drupal-specific CKEditor settings.
$root_relative_file_url = function ($uri) {
return file_url_transform_relative(file_create_url($uri));
};
- $settings += array(
+ $settings += [
'drupalExternalPlugins' => array_map($root_relative_file_url, $external_plugin_files),
- );
+ ];
// Parse all CKEditor plugin JavaScript files for translations.
if ($this->moduleHandler->moduleExists('locale')) {
@@ -326,7 +326,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
$langcodes = $langcode_cache->data;
}
if (empty($langcodes)) {
- $langcodes = array();
+ $langcodes = [];
// Collect languages included with CKEditor based on file listing.
$files = scandir('core/assets/vendor/ckeditor/lang');
foreach ($files as $file) {
@@ -341,7 +341,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
// Get language mapping if available to map to Drupal language codes.
// This is configurable in the user interface and not expensive to get, so
// we don't include it in the cached language list.
- $language_mappings = $this->moduleHandler->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : array();
+ $language_mappings = $this->moduleHandler->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : [];
foreach ($langcodes as $langcode) {
// If this language code is available in a Drupal mapping, use that to
// compute a possibility for matching from the Drupal langcode to the
@@ -363,9 +363,9 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
- $libraries = array(
+ $libraries = [
'ckeditor/drupal.ckeditor',
- );
+ ];
// Get the required libraries for any enabled plugins.
$enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor));
@@ -389,7 +389,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
* An array containing the "toolbar" configuration.
*/
public function buildToolbarJSSetting(Editor $editor) {
- $toolbar = array();
+ $toolbar = [];
$settings = $editor->getSettings();
foreach ($settings['toolbar']['rows'] as $row) {
@@ -412,15 +412,15 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
* An array containing the "contentsCss" configuration.
*/
public function buildContentsCssJSSetting(Editor $editor) {
- $css = array(
+ $css = [
drupal_get_path('module', 'ckeditor') . '/css/ckeditor-iframe.css',
drupal_get_path('module', 'system') . '/css/components/align.module.css',
- );
+ ];
$this->moduleHandler->alter('ckeditor_css', $css, $editor);
// Get a list of all enabled plugins' iframe instance CSS files.
$plugins_css = array_reduce($this->ckeditorPluginManager->getCssFiles($editor), function($result, $item) {
return array_merge($result, array_values($item));
- }, array());
+ }, []);
$css = array_merge($css, $plugins_css);
$css = array_merge($css, _ckeditor_theme_css());
$css = array_map('file_create_url', $css);
diff --git a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
index d10180db3b4..ed08c26d0c0 100644
--- a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
@@ -20,7 +20,7 @@ class CKEditorAdminTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'editor', 'ckeditor');
+ public static $modules = ['filter', 'editor', 'ckeditor'];
/**
* A user with the 'administer filters' permission.
@@ -33,16 +33,16 @@ class CKEditorAdminTest extends WebTestBase {
parent::setUp();
// Create text format.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
// Create admin user.
- $this->adminUser = $this->drupalCreateUser(array('administer filters'));
+ $this->adminUser = $this->drupalCreateUser(['administer filters']);
}
/**
@@ -70,43 +70,43 @@ class CKEditorAdminTest extends WebTestBase {
$this->assertTrue(((string) $options[0]['selected']) === 'selected', 'Option 1 ("None") is selected.');
// Select the "CKEditor" editor and click the "Save configuration" button.
- $edit = array(
+ $edit = [
'editor[editor]' => 'ckeditor',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertRaw(t('You must configure the selected text editor.'));
// Ensure the CKEditor editor returns the expected default settings.
- $expected_default_settings = array(
- 'toolbar' => array(
- 'rows' => array(
+ $expected_default_settings = [
+ 'toolbar' => [
+ 'rows' => [
// Button groups
- array(
- array(
+ [
+ [
'name' => 'Formatting',
- 'items' => array('Bold', 'Italic',),
- ),
- array(
+ 'items' => ['Bold', 'Italic',],
+ ],
+ [
'name' => 'Links',
- 'items' => array('DrupalLink', 'DrupalUnlink',),
- ),
- array(
+ 'items' => ['DrupalLink', 'DrupalUnlink',],
+ ],
+ [
'name' => 'Lists',
- 'items' => array('BulletedList', 'NumberedList',),
- ),
- array(
+ 'items' => ['BulletedList', 'NumberedList',],
+ ],
+ [
'name' => 'Media',
- 'items' => array('Blockquote', 'DrupalImage',),
- ),
- array(
+ 'items' => ['Blockquote', 'DrupalImage',],
+ ],
+ [
'name' => 'Tools',
- 'items' => array('Source',),
- ),
- ),
- ),
- ),
+ 'items' => ['Source',],
+ ],
+ ],
+ ],
+ ],
'plugins' => ['language' => ['language_list' => 'un']],
- );
+ ];
$this->assertIdentical($this->castSafeStrings($ckeditor->getDefaultSettings()), $expected_default_settings);
// Keep the "CKEditor" editor selected and click the "Configure" button.
@@ -115,11 +115,11 @@ class CKEditorAdminTest extends WebTestBase {
$this->assertFalse($editor, 'No Editor config entity exists yet.');
// Ensure that drupalSettings is correct.
- $ckeditor_settings_toolbar = array(
+ $ckeditor_settings_toolbar = [
'#theme' => 'ckeditor_settings_toolbar',
'#editor' => Editor::create(['editor' => 'ckeditor']),
'#plugins' => $this->container->get('plugin.manager.ckeditor.plugin')->getButtons(),
- );
+ ];
$this->assertEqual(
$this->drupalSettings['ckeditor']['toolbarAdmin'],
$this->container->get('renderer')->renderPlain($ckeditor_settings_toolbar),
@@ -148,9 +148,9 @@ class CKEditorAdminTest extends WebTestBase {
// Configure the Styles plugin, and ensure the updated settings are saved.
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
- $edit = array(
+ $edit = [
'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Callout\n\n",
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
$editor = Editor::load('filtered_html');
@@ -161,13 +161,13 @@ class CKEditorAdminTest extends WebTestBase {
// done via drag and drop, but here we can only emulate the end result of
// that interaction). Test multiple toolbar rows and a divider within a row.
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
- $expected_settings['toolbar']['rows'][0][] = array(
+ $expected_settings['toolbar']['rows'][0][] = [
'name' => 'Action history',
- 'items' => array('Undo', '|', 'Redo', 'JustifyCenter'),
- );
- $edit = array(
+ 'items' => ['Undo', '|', 'Redo', 'JustifyCenter'],
+ ];
+ $edit = [
'editor[settings][toolbar][button_groups]' => json_encode($expected_settings['toolbar']['rows']),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$editor = Editor::load('filtered_html');
$this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
@@ -191,7 +191,7 @@ class CKEditorAdminTest extends WebTestBase {
// Now enable the ckeditor_test module, which provides one configurable
// CKEditor plugin — this should not affect the Editor config entity.
- \Drupal::service('module_installer')->install(array('ckeditor_test'));
+ \Drupal::service('module_installer')->install(['ckeditor_test']);
$this->resetAll();
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
@@ -203,9 +203,9 @@ class CKEditorAdminTest extends WebTestBase {
// Finally, check the "Ultra llama mode" checkbox.
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
- $edit = array(
+ $edit = [
'editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]' => '1',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]');
@@ -239,11 +239,11 @@ class CKEditorAdminTest extends WebTestBase {
// Name our fancy new text format, select the "CKEditor" editor and click
// the "Configure" button.
- $edit = array(
+ $edit = [
'name' => 'My amazing text format',
'format' => 'amazing_format',
'editor[editor]' => 'ckeditor',
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, 'editor_configure');
$filter_format = FilterFormat::load('amazing_format');
$this->assertFalse($filter_format, 'No FilterFormat config entity exists yet.');
diff --git a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php
index 6efe647b542..6de5467533a 100644
--- a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php
+++ b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php
@@ -18,7 +18,7 @@ class CKEditorLoadingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'editor', 'ckeditor', 'node');
+ public static $modules = ['filter', 'editor', 'ckeditor', 'node'];
/**
* An untrusted user with access to only the 'plain_text' format.
@@ -38,12 +38,12 @@ class CKEditorLoadingTest extends WebTestBase {
parent::setUp();
// Create text format, associate CKEditor.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
$editor = Editor::create([
'format' => 'filtered_html',
@@ -53,22 +53,22 @@ class CKEditorLoadingTest extends WebTestBase {
// Create a second format without an associated editor so a drop down select
// list is created when selecting formats.
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$full_html_format->save();
// Create node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
- ));
+ ]);
- $this->untrustedUser = $this->drupalCreateUser(array('create article content', 'edit any article content'));
- $this->normalUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html'));
+ $this->untrustedUser = $this->drupalCreateUser(['create article content', 'edit any article content']);
+ $this->normalUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html']);
}
/**
@@ -101,13 +101,13 @@ class CKEditorLoadingTest extends WebTestBase {
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
$ckeditor_plugin = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
$editor = Editor::load('filtered_html');
- $expected = array('formats' => array('filtered_html' => array(
+ $expected = ['formats' => ['filtered_html' => [
'format' => 'filtered_html',
'editor' => 'ckeditor',
'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)),
'editorSupportsContentFiltering' => TRUE,
'isXssSafe' => FALSE,
- )));
+ ]]];
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
@@ -122,7 +122,7 @@ class CKEditorLoadingTest extends WebTestBase {
// NOTE: the tests in CKEditorTest already ensure that changing the
// configuration also results in modified CKEditor configuration, so we
// don't test that here.
- \Drupal::service('module_installer')->install(array('ckeditor_test'));
+ \Drupal::service('module_installer')->install(['ckeditor_test']);
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
$editor_settings = $editor->getSettings();
$editor_settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
@@ -130,15 +130,15 @@ class CKEditorLoadingTest extends WebTestBase {
$editor->save();
$this->drupalGet('node/add/article');
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
- $expected = array(
- 'formats' => array(
- 'filtered_html' => array(
+ $expected = [
+ 'formats' => [
+ 'filtered_html' => [
'format' => 'filtered_html',
'editor' => 'ckeditor',
'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)),
'editorSupportsContentFiltering' => TRUE,
'isXssSafe' => FALSE,
- )));
+ ]]];
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
@@ -226,7 +226,7 @@ class CKEditorLoadingTest extends WebTestBase {
protected function getThingsToCheck() {
$settings = $this->getDrupalSettings();
- return array(
+ return [
// JavaScript settings.
$settings,
// Editor.module's JS settings present.
@@ -239,7 +239,7 @@ class CKEditorLoadingTest extends WebTestBase {
$this->xpath('//textarea[@id="edit-body-0-value"]'),
// Format selector.
$this->xpath('//select[contains(@class, "filter-list")]'),
- );
+ ];
}
}
diff --git a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php
index 92c448b691c..fc79273487e 100644
--- a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php
+++ b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php
@@ -18,7 +18,7 @@ class CKEditorPluginManagerTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'filter', 'editor', 'ckeditor');
+ public static $modules = ['system', 'user', 'filter', 'editor', 'ckeditor'];
/**
* The manager for "CKEditor plugin" plugins.
@@ -33,12 +33,12 @@ class CKEditorPluginManagerTest extends KernelTestBase {
// Install the Filter module.
// Create text format, associate CKEditor.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
$editor = Editor::create([
'format' => 'filtered_html',
@@ -57,27 +57,27 @@ class CKEditorPluginManagerTest extends KernelTestBase {
// Case 1: no CKEditor plugins.
$definitions = array_keys($this->manager->getDefinitions());
sort($definitions);
- $this->assertIdentical(array('drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'stylescombo'), $definitions, 'No CKEditor plugins found besides the built-in ones.');
- $enabled_plugins = array(
+ $this->assertIdentical(['drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'stylescombo'], $definitions, 'No CKEditor plugins found besides the built-in ones.');
+ $enabled_plugins = [
'drupalimage' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage/plugin.js',
'drupallink' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupallink/plugin.js',
- );
+ ];
$this->assertIdentical($enabled_plugins, $this->manager->getEnabledPluginFiles($editor), 'Only built-in plugins are enabled.');
- $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.');
+ $this->assertIdentical(['internal' => NULL] + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.');
// Enable the CKEditor Test module, which has the Llama plugin (plus four
// variations of it, to cover all possible ways a plugin can be enabled) and
// clear the editor manager's cache so it is picked up.
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$this->manager = $this->container->get('plugin.manager.ckeditor.plugin');
$this->manager->clearCachedDefinitions();
// Case 2: CKEditor plugins are available.
$plugin_ids = array_keys($this->manager->getDefinitions());
sort($plugin_ids);
- $this->assertIdentical(array('drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'llama', 'llama_button', 'llama_contextual', 'llama_contextual_and_button', 'llama_css', 'stylescombo'), $plugin_ids, 'Additional CKEditor plugins found.');
+ $this->assertIdentical(['drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'llama', 'llama_button', 'llama_contextual', 'llama_contextual_and_button', 'llama_css', 'stylescombo'], $plugin_ids, 'Additional CKEditor plugins found.');
$this->assertIdentical($enabled_plugins, $this->manager->getEnabledPluginFiles($editor), 'Only the internal plugins are enabled.');
- $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.');
+ $this->assertIdentical(['internal' => NULL] + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.');
// Case 3: enable each of the newly available plugins, if possible:
// a. Llama: cannot be enabled, since it does not implement
@@ -100,33 +100,33 @@ class CKEditorPluginManagerTest extends KernelTestBase {
$settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
$editor->setSettings($settings);
$editor->save();
- $file = array();
+ $file = [];
$file['b'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_button.js';
$file['c'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual.js';
$file['cb'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual_and_button.js';
$file['css'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_css.js';
- $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual_and_button' => $file['cb']);
+ $expected = $enabled_plugins + ['llama_button' => $file['b'], 'llama_contextual_and_button' => $file['cb']];
$this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.');
- $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.');
+ $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.');
$settings['toolbar'] = $original_toolbar;
$settings['toolbar']['rows'][0][0]['items'][] = 'Strike';
$editor->setSettings($settings);
$editor->save();
- $expected = $enabled_plugins + array('llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']);
+ $expected = $enabled_plugins + ['llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']];
$this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LLamaContextual and LlamaContextualAndButton plugins are enabled.');
- $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaContextual and LlamaContextualAndButton plugins are enabled.');
+ $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaContextual and LlamaContextualAndButton plugins are enabled.');
$settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
$editor->setSettings($settings);
$editor->save();
- $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']);
+ $expected = $enabled_plugins + ['llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']];
$this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.');
- $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.');
+ $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.');
$settings['toolbar']['rows'][0][0]['items'][] = 'LlamaCSS';
$editor->setSettings($settings);
$editor->save();
- $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb'], 'llama_css' => $file['css']);
+ $expected = $enabled_plugins + ['llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb'], 'llama_css' => $file['css']];
$this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton, LlamaContextual, LlamaContextualAndButton and LlamaCSS plugins are enabled.');
- $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual, LlamaContextualAndButton and LlamaCSS plugins are enabled.');
+ $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual, LlamaContextualAndButton and LlamaCSS plugins are enabled.');
}
/**
@@ -137,11 +137,11 @@ class CKEditorPluginManagerTest extends KernelTestBase {
$editor = Editor::load('filtered_html');
// Case 1: no CKEditor iframe instance CSS file.
- $this->assertIdentical(array(), $this->manager->getCssFiles($editor), 'No iframe instance CSS file found.');
+ $this->assertIdentical([], $this->manager->getCssFiles($editor), 'No iframe instance CSS file found.');
// Enable the CKEditor Test module, which has the LlamaCss plugin and
// clear the editor manager's cache so it is picked up.
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$this->manager = $this->container->get('plugin.manager.ckeditor.plugin');
$settings = $editor->getSettings();
// LlamaCss: automatically enabled by adding its 'LlamaCSS' button.
@@ -150,9 +150,9 @@ class CKEditorPluginManagerTest extends KernelTestBase {
$editor->save();
// Case 2: CKEditor iframe instance CSS file.
- $expected = array(
- 'llama_css' => array(drupal_get_path('module', 'ckeditor_test') . '/css/llama.css')
- );
+ $expected = [
+ 'llama_css' => [drupal_get_path('module', 'ckeditor_test') . '/css/llama.css']
+ ];
$this->assertIdentical($expected, $this->manager->getCssFiles($editor), 'Iframe instance CSS file found.');
}
diff --git a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php
index 3711a54e384..9e159c3d519 100644
--- a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php
+++ b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php
@@ -19,7 +19,7 @@ class CKEditorTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'filter', 'editor', 'ckeditor', 'filter_test');
+ public static $modules = ['system', 'user', 'filter', 'editor', 'ckeditor', 'filter_test'];
/**
* An instance of the "CKEditor" text editor plugin.
@@ -41,19 +41,19 @@ class CKEditorTest extends KernelTestBase {
// Install the Filter module.
// Create text format, associate CKEditor.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(
- 'filter_html' => array(
+ 'filters' => [
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<h2 id> <h3> <h4> <h5> <h6> <p> <br> <strong> <a href hreflang>',
- )
- ),
- ),
- ));
+ ]
+ ],
+ ],
+ ]);
$filtered_html_format->save();
$editor = Editor::create([
'format' => 'filtered_html',
@@ -72,7 +72,7 @@ class CKEditorTest extends KernelTestBase {
$editor = Editor::load('filtered_html');
// Default toolbar.
- $expected_config = $this->getDefaultInternalConfig() + array(
+ $expected_config = $this->getDefaultInternalConfig() + [
'drupalImage_dialogTitleAdd' => 'Insert Image',
'drupalImage_dialogTitleEdit' => 'Edit Image',
'drupalLink_dialogTitleAdd' => 'Add Link',
@@ -84,11 +84,11 @@ class CKEditorTest extends KernelTestBase {
'extraPlugins' => 'drupalimage,drupallink',
'language' => 'en',
'stylesSet' => FALSE,
- 'drupalExternalPlugins' => array(
+ 'drupalExternalPlugins' => [
'drupalimage' => file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupalimage/plugin.js')),
'drupallink' => file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupallink/plugin.js')),
- ),
- );
+ ],
+ ];
$expected_config = $this->castSafeStrings($expected_config);
ksort($expected_config);
ksort($expected_config['allowedContent']);
@@ -96,7 +96,7 @@ class CKEditorTest extends KernelTestBase {
// Customize the configuration: add button, have two contextually enabled
// buttons, and configure a CKEditor plugin setting.
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$this->container->get('plugin.manager.editor')->clearCachedDefinitions();
$this->ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
@@ -121,16 +121,16 @@ class CKEditorTest extends KernelTestBase {
$format->filters('filter_html')->settings['allowed_html'] .= '<pre class> <h1> <blockquote class="*"> <address class="foo bar-* *">';
$format->save();
- $expected_config['allowedContent']['pre'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE);
- $expected_config['allowedContent']['h1'] = array('attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE);
- $expected_config['allowedContent']['blockquote'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE);
- $expected_config['allowedContent']['address'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => 'foo,bar-*');
+ $expected_config['allowedContent']['pre'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE];
+ $expected_config['allowedContent']['h1'] = ['attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE];
+ $expected_config['allowedContent']['blockquote'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE];
+ $expected_config['allowedContent']['address'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => 'foo,bar-*'];
$expected_config['format_tags'] = 'p;h1;h2;h3;h4;h5;h6;pre';
ksort($expected_config['allowedContent']);
$this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
// Disable the filter_html filter: allow *all *tags.
- $format->setFilterConfig('filter_html', array('status' => 0));
+ $format->setFilterConfig('filter_html', ['status' => 0]);
$format->save();
$expected_config['allowedContent'] = TRUE;
@@ -139,73 +139,73 @@ class CKEditorTest extends KernelTestBase {
$this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
// Enable the filter_test_restrict_tags_and_attributes filter.
- $format->setFilterConfig('filter_test_restrict_tags_and_attributes', array(
+ $format->setFilterConfig('filter_test_restrict_tags_and_attributes', [
'status' => 1,
- 'settings' => array(
- 'restrictions' => array(
- 'allowed' => array(
+ 'settings' => [
+ 'restrictions' => [
+ 'allowed' => [
'p' => TRUE,
- 'a' => array(
+ 'a' => [
'href' => TRUE,
- 'rel' => array('nofollow' => TRUE),
- 'class' => array('external' => TRUE),
- 'target' => array('_blank' => FALSE),
- ),
- 'span' => array(
- 'class' => array('dodo' => FALSE),
- 'property' => array('dc:*' => TRUE),
- 'rel' => array('foaf:*' => FALSE),
- 'style' => array('underline' => FALSE, 'color' => FALSE, 'font-size' => TRUE),
- ),
- '*' => array(
+ 'rel' => ['nofollow' => TRUE],
+ 'class' => ['external' => TRUE],
+ 'target' => ['_blank' => FALSE],
+ ],
+ 'span' => [
+ 'class' => ['dodo' => FALSE],
+ 'property' => ['dc:*' => TRUE],
+ 'rel' => ['foaf:*' => FALSE],
+ 'style' => ['underline' => FALSE, 'color' => FALSE, 'font-size' => TRUE],
+ ],
+ '*' => [
'style' => FALSE,
'on*' => FALSE,
- 'class' => array('is-a-hipster-llama' => TRUE, 'and-more' => TRUE),
+ 'class' => ['is-a-hipster-llama' => TRUE, 'and-more' => TRUE],
'data-*' => TRUE,
- ),
+ ],
'del' => FALSE,
- ),
- ),
- ),
- ));
+ ],
+ ],
+ ],
+ ]);
$format->save();
- $expected_config['allowedContent'] = array(
- 'p' => array(
+ $expected_config['allowedContent'] = [
+ 'p' => [
'attributes' => TRUE,
'styles' => FALSE,
'classes' => 'is-a-hipster-llama,and-more',
- ),
- 'a' => array(
+ ],
+ 'a' => [
'attributes' => 'href,rel,class,target',
'styles' => FALSE,
'classes' => 'external',
- ),
- 'span' => array(
+ ],
+ 'span' => [
'attributes' => 'class,property,rel,style',
'styles' => 'font-size',
'classes' => FALSE,
- ),
- '*' => array(
+ ],
+ '*' => [
'attributes' => 'class,data-*',
'styles' => FALSE,
'classes' => 'is-a-hipster-llama,and-more',
- ),
- 'del' => array(
+ ],
+ 'del' => [
'attributes' => FALSE,
'styles' => FALSE,
'classes' => FALSE,
- ),
- );
- $expected_config['disallowedContent'] = array(
- 'span' => array(
+ ],
+ ];
+ $expected_config['disallowedContent'] = [
+ 'span' => [
'styles' => 'underline,color',
'classes' => 'dodo',
- ),
- '*' => array(
+ ],
+ '*' => [
'attributes' => 'on*',
- ),
- );
+ ],
+ ];
$expected_config['format_tags'] = 'p';
ksort($expected_config);
ksort($expected_config['allowedContent']);
@@ -232,7 +232,7 @@ class CKEditorTest extends KernelTestBase {
$this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for customized toolbar.');
// Enable the editor_test module, customize further.
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
// Override the label of a toolbar component.
$settings['toolbar']['rows'][0][0]['name'] = 'JunkScience';
@@ -255,7 +255,7 @@ class CKEditorTest extends KernelTestBase {
$this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly for default toolbar.');
// Enable the editor_test module, which implements hook_ckeditor_css_alter().
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$expected[] = file_url_transform_relative(file_create_url(drupal_get_path('module', 'ckeditor_test') . '/ckeditor_test.css'));
$this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly while a hook_ckeditor_css_alter() implementation exists.');
@@ -315,7 +315,7 @@ class CKEditorTest extends KernelTestBase {
$settings['plugins']['stylescombo']['styles'] = '';
$editor->setSettings($settings);
$editor->save();
- $expected['stylesSet'] = array();
+ $expected['stylesSet'] = [];
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
// Configure the optional "styles" setting in odd ways that shouldn't affect
@@ -333,10 +333,10 @@ class CKEditorTest extends KernelTestBase {
$settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.mAgical.Callout|Callout";
$editor->setSettings($settings);
$editor->save();
- $expected['stylesSet'] = array(
- array('name' => 'Title', 'element' => 'h1', 'attributes' => array('class' => 'title')),
- array('name' => 'Callout', 'element' => 'p', 'attributes' => array('class' => 'mAgical Callout')),
- );
+ $expected['stylesSet'] = [
+ ['name' => 'Title', 'element' => 'h1', 'attributes' => ['class' => 'title']],
+ ['name' => 'Callout', 'element' => 'p', 'attributes' => ['class' => 'mAgical Callout']],
+ ];
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
// Same configuration, but now interspersed with nonsense. Should yield the
@@ -350,7 +350,7 @@ class CKEditorTest extends KernelTestBase {
$settings['plugins']['stylescombo']['styles'] = " h1 | Title ";
$editor->setSettings($settings);
$editor->save();
- $expected['stylesSet'] = array(array('name' => 'Title', 'element' => 'h1'));
+ $expected['stylesSet'] = [['name' => 'Title', 'element' => 'h1']];
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
// Invalid syntax should cause stylesSet to be set to FALSE.
@@ -366,8 +366,8 @@ class CKEditorTest extends KernelTestBase {
*/
function testLanguages() {
// Get CKEditor supported language codes and spot-check.
- $this->enableModules(array('language'));
- $this->installConfig(array('language'));
+ $this->enableModules(['language']);
+ $this->installConfig(['language']);
$langcodes = $this->ckeditor->getLangcodes();
// Language codes transformed with browser mappings.
@@ -390,14 +390,14 @@ class CKEditorTest extends KernelTestBase {
* Tests that CKEditor plugins participate in JS translation.
*/
function testJSTranslation() {
- $this->enableModules(array('language', 'locale'));
+ $this->enableModules(['language', 'locale']);
$this->installSchema('locale', 'locales_source');
$this->installSchema('locale', 'locales_location');
$this->installSchema('locale', 'locales_target');
$editor = Editor::load('filtered_html');
$this->ckeditor->getJSSettings($editor);
$localeStorage = $this->container->get('locale.storage');
- $string = $localeStorage->findString(array('source' => 'Edit Link', 'context' => ''));
+ $string = $localeStorage->findString(['source' => 'Edit Link', 'context' => '']);
$this->assertTrue(!empty($string), 'String from JavaScript file saved.');
// With locale module, CKEditor should not adhere to the language selected.
@@ -428,14 +428,14 @@ class CKEditorTest extends KernelTestBase {
}
protected function getDefaultInternalConfig() {
- return array(
+ return [
'customConfig' => '',
'pasteFromWordPromptCleanup' => TRUE,
'resize_dir' => 'vertical',
- 'justifyClasses' => array('text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'),
+ 'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'],
'entities' => FALSE,
'disableNativeSpellChecker' => FALSE,
- );
+ ];
}
protected function getDefaultAllowedContentConfig() {
@@ -454,42 +454,42 @@ class CKEditorTest extends KernelTestBase {
}
protected function getDefaultDisallowedContentConfig() {
- return array(
- '*' => array('attributes' => 'on*'),
- );
+ return [
+ '*' => ['attributes' => 'on*'],
+ ];
}
protected function getDefaultToolbarConfig() {
- return array(
- array(
+ return [
+ [
'name' => 'Formatting',
- 'items' => array('Bold', 'Italic',),
- ),
- array(
+ 'items' => ['Bold', 'Italic',],
+ ],
+ [
'name' => 'Links',
- 'items' => array('DrupalLink', 'DrupalUnlink',),
- ),
- array(
+ 'items' => ['DrupalLink', 'DrupalUnlink',],
+ ],
+ [
'name' => 'Lists',
- 'items' => array('BulletedList', 'NumberedList',),
- ),
- array(
+ 'items' => ['BulletedList', 'NumberedList',],
+ ],
+ [
'name' => 'Media',
- 'items' => array('Blockquote', 'DrupalImage',),
- ),
- array(
+ 'items' => ['Blockquote', 'DrupalImage',],
+ ],
+ [
'name' => 'Tools',
- 'items' => array('Source',),
- ),
+ 'items' => ['Source',],
+ ],
'/',
- );
+ ];
}
protected function getDefaultContentsCssConfig() {
- return array(
+ return [
file_url_transform_relative(file_create_url('core/modules/ckeditor/css/ckeditor-iframe.css')),
file_url_transform_relative(file_create_url('core/modules/system/css/components/align.module.css')),
- );
+ ];
}
}
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
index 932b05ca4d6..012579de89d 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
@@ -30,14 +30,14 @@ class Llama extends PluginBase implements CKEditorPluginInterface {
* {@inheritdoc}
*/
function getDependencies(Editor $editor) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
function getLibraries(Editor $editor) {
- return array();
+ return [];
}
/**
@@ -58,7 +58,7 @@ class Llama extends PluginBase implements CKEditorPluginInterface {
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
- return array();
+ return [];
}
}
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
index 7520dfd1176..4568192e03d 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
@@ -18,11 +18,11 @@ class LlamaButton extends Llama implements CKEditorPluginButtonsInterface {
* {@inheritdoc}
*/
function getButtons() {
- return array(
- 'Llama' => array(
+ return [
+ 'Llama' => [
'label' => t('Insert Llama'),
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
index 43060d90468..5e1955fbd30 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
@@ -39,11 +39,11 @@ class LlamaContextualAndButton extends Llama implements CKEditorPluginContextual
* {@inheritdoc}
*/
function getButtons() {
- return array(
- 'Llama' => array(
+ return [
+ 'Llama' => [
'label' => t('Insert Llama'),
- ),
- );
+ ],
+ ];
}
/**
@@ -58,17 +58,17 @@ class LlamaContextualAndButton extends Llama implements CKEditorPluginContextual
*/
function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
// Defaults.
- $config = array('ultra_llama_mode' => FALSE);
+ $config = ['ultra_llama_mode' => FALSE];
$settings = $editor->getSettings();
if (isset($settings['plugins']['llama_contextual_and_button'])) {
$config = $settings['plugins']['llama_contextual_and_button'];
}
- $form['ultra_llama_mode'] = array(
+ $form['ultra_llama_mode'] = [
'#title' => t('Ultra llama mode'),
'#type' => 'checkbox',
'#default_value' => $config['ultra_llama_mode'],
- );
+ ];
return $form;
}
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
index 294b39c92a4..d3b9a7f6235 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
@@ -20,20 +20,20 @@ class LlamaCss extends Llama implements CKEditorPluginButtonsInterface, CKEditor
* {@inheritdoc}
*/
function getButtons() {
- return array(
- 'LlamaCSS' => array(
+ return [
+ 'LlamaCSS' => [
'label' => t('Insert Llama CSS'),
- ),
- );
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
function getCssFiles(Editor $editor) {
- return array(
+ return [
drupal_get_path('module', 'ckeditor_test') . '/css/llama.css'
- );
+ ];
}
/**
diff --git a/core/modules/color/color.install b/core/modules/color/color.install
index 7f6133819de..3cc098caa05 100644
--- a/core/modules/color/color.install
+++ b/core/modules/color/color.install
@@ -9,15 +9,15 @@
* Implements hook_requirements().
*/
function color_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if ($phase == 'runtime') {
// Check for the PHP GD library.
if (function_exists('imagegd2')) {
$info = gd_info();
- $requirements['color_gd'] = array(
+ $requirements['color_gd'] = [
'value' => $info['GD Version'],
- );
+ ];
// Check for PNG support.
if (!function_exists('imagecreatefrompng')) {
@@ -26,11 +26,11 @@ function color_requirements($phase) {
}
}
else {
- $requirements['color_gd'] = array(
+ $requirements['color_gd'] = [
'value' => t('Not installed'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The GD library for PHP is missing or outdated. Check the <a href="http://php.net/manual/book.image.php">PHP image documentation</a> for information on how to correct this.'),
- );
+ ];
}
$requirements['color_gd']['title'] = t('GD library PNG support');
}
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index 3cae04532e7..20d099abcf2 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -23,11 +23,11 @@ function color_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.color':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Color module allows users with the <em>Administer site configuration</em> permission to change the color scheme (color of links, backgrounds, text, and other theme elements) of compatible themes. For more information, see the <a href=":color_do">online documentation for the Color module</a>.', array(':color_do' => 'https://www.drupal.org/documentation/modules/color')) . '</p>';
+ $output .= '<p>' . t('The Color module allows users with the <em>Administer site configuration</em> permission to change the color scheme (color of links, backgrounds, text, and other theme elements) of compatible themes. For more information, see the <a href=":color_do">online documentation for the Color module</a>.', [':color_do' => 'https://www.drupal.org/documentation/modules/color']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Changing colors') . '</dt>';
- $output .= '<dd><p>' . t('To change the color settings, select the <em>Settings</em> link for your theme on the <a href=":appearance">Appearance</a> page. If the color picker does not appear then the theme is not compatible with the Color module.', array(':appearance' => \Drupal::url('system.themes_page'))) . '</p>';
+ $output .= '<dd><p>' . t('To change the color settings, select the <em>Settings</em> link for your theme on the <a href=":appearance">Appearance</a> page. If the color picker does not appear then the theme is not compatible with the Color module.', [':appearance' => \Drupal::url('system.themes_page')]) . '</p>';
$output .= '<p>' . t('The Color module saves a modified copy of the theme\'s specified stylesheets in the files directory. If you make any manual changes to your theme\'s stylesheet, <em>you must save your color settings again, even if you haven\'t changed the colors</em>. This step is required because the module stylesheets in the files directory need to be recreated to reflect your changes.') . '</p></dd>';
$output .= '</dl>';
return $output;
@@ -38,11 +38,11 @@ function color_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function color_theme() {
- return array(
- 'color_scheme_form' => array(
+ return [
+ 'color_scheme_form' => [
'render element' => 'form',
- ),
- );
+ ],
+ ];
}
/**
@@ -51,14 +51,14 @@ function color_theme() {
function color_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) {
$build_info = $form_state->getBuildInfo();
if (isset($build_info['args'][0]) && ($theme = $build_info['args'][0]) && color_get_info($theme) && function_exists('gd_info')) {
- $form['color'] = array(
+ $form['color'] = [
'#type' => 'details',
'#title' => t('Color scheme'),
'#open' => TRUE,
'#weight' => -1,
- '#attributes' => array('id' => 'color_scheme_form'),
+ '#attributes' => ['id' => 'color_scheme_form'],
'#theme' => 'color_scheme_form',
- );
+ ];
$form['color'] += color_scheme_form($form, $form_state, $theme);
$form['#validate'][] = 'color_scheme_form_validate';
// Ensure color submission happens first so we can unset extra values.
@@ -137,7 +137,7 @@ function color_block_view_pre_render(array $build) {
* Retrieves the Color module information for a particular theme.
*/
function color_get_info($theme) {
- static $theme_info = array();
+ static $theme_info = [];
if (isset($theme_info[$theme])) {
return $theme_info[$theme];
@@ -148,21 +148,21 @@ function color_get_info($theme) {
if ($path && file_exists($file)) {
include $file;
// Add in default values.
- $info += array(
+ $info += [
// CSS files (excluding @import) to rewrite with new color scheme.
- 'css' => array(),
+ 'css' => [],
// Files to copy.
- 'copy' => array(),
+ 'copy' => [],
// Gradient definitions.
- 'gradients' => array(),
+ 'gradients' => [],
// Color areas to fill (x, y, width, height).
- 'fill' => array(),
+ 'fill' => [],
// Coordinates of all the theme slices (x, y, width, height) with their
// filename as used in the stylesheet.
- 'slices' => array(),
+ 'slices' => [],
// Reference color used for blending.
'blend_target' => '#ffffff',
- );
+ ];
$theme_info[$theme] = $info;
return $info;
}
@@ -200,9 +200,9 @@ function color_get_palette($theme, $default = FALSE) {
function color_scheme_form($complete_form, FormStateInterface $form_state, $theme) {
$info = color_get_info($theme);
- $info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
- $color_sets = array();
- $schemes = array();
+ $info['schemes'][''] = ['title' => t('Custom'), 'colors' => []];
+ $color_sets = [];
+ $schemes = [];
foreach ($info['schemes'] as $key => $scheme) {
$color_sets[$key] = $scheme['title'];
$schemes[$key] = $scheme['colors'];
@@ -233,16 +233,16 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them
// Add scheme selector.
$default_palette = color_get_palette($theme, TRUE);
- $form['scheme'] = array(
+ $form['scheme'] = [
'#type' => 'select',
'#title' => t('Color set'),
'#options' => $color_sets,
'#default_value' => $scheme_name,
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'color/drupal.color',
'color/admin',
- ),
+ ],
// Add custom JavaScript.
'drupalSettings' => [
'color' => [
@@ -251,8 +251,8 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them
],
'gradients' => $info['gradients'],
],
- ),
- );
+ ],
+ ];
// Add palette fields. Use the configuration if available.
$palette = $current_scheme ?: $default_palette;
@@ -260,22 +260,22 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them
$form['palette']['#tree'] = TRUE;
foreach ($palette as $name => $value) {
if (isset($names[$name])) {
- $form['palette'][$name] = array(
+ $form['palette'][$name] = [
'#type' => 'textfield',
'#title' => $names[$name],
'#value_callback' => 'color_palette_color_value',
'#default_value' => $value,
'#size' => 8,
- '#attributes' => array('dir' => LanguageInterface::DIRECTION_LTR),
- );
+ '#attributes' => ['dir' => LanguageInterface::DIRECTION_LTR],
+ ];
}
}
- $form['theme'] = array('#type' => 'value', '#value' => $theme);
+ $form['theme'] = ['#type' => 'value', '#value' => $theme];
if (isset($info['#attached'])) {
$form['#attached'] = $info['#attached'];
unset($info['#attached']);
}
- $form['info'] = array('#type' => 'value', '#value' => $info);
+ $form['info'] = ['#type' => 'value', '#value' => $info];
return $form;
}
@@ -360,7 +360,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) {
// Only accept hexadecimal CSS color strings to avoid XSS upon use.
foreach ($form_state->getValue('palette') as $key => $color) {
if (!color_valid_hexadecimal_string($color)) {
- $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title'])));
+ $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', ['%name' => $form['color']['palette'][$key]['#title']]));
}
}
}
@@ -373,7 +373,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) {
function color_scheme_form_submit($form, FormStateInterface $form_state) {
// Avoid color settings spilling over to theme settings.
- $color_settings = array('theme', 'palette', 'scheme');
+ $color_settings = ['theme', 'palette', 'scheme'];
if ($form_state->hasValue('info')) {
$color_settings[] = 'info';
}
@@ -414,7 +414,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
$memory_limit = ini_get('memory_limit');
$size = Bytes::toInt($memory_limit);
if (!Environment::checkMemoryLimit($usage + $required, $memory_limit)) {
- drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="http://php.net/manual/ini.core.php#ini.sect.resource-limits">PHP documentation</a> for more information.', array('%size' => format_size($usage + $required - $size))), 'error');
+ drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="http://php.net/manual/ini.core.php#ini.sect.resource-limits">PHP documentation</a> for more information.', ['%size' => format_size($usage + $required - $size)]), 'error');
return;
}
}
@@ -446,7 +446,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
$paths['target'] = $paths['target'] . '/';
$paths['id'] = $id;
$paths['source'] = drupal_get_path('theme', $theme) . '/';
- $paths['files'] = $paths['map'] = array();
+ $paths['files'] = $paths['map'] = [];
// Save palette and logo location.
$config
@@ -469,10 +469,10 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
}
// Rewrite theme stylesheets.
- $css = array();
+ $css = [];
foreach ($info['css'] as $stylesheet) {
// Build a temporary array with CSS files.
- $files = array();
+ $files = [];
if (file_exists($paths['source'] . $stylesheet)) {
$files[] = $stylesheet;
}
@@ -489,7 +489,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
$css_optimizer->rewriteFileURIBasePath = base_path() . dirname($paths['source'] . $file) . '/';
// Prefix all paths within this CSS file, ignoring absolute paths.
- $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style);
+ $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', [$css_optimizer, 'rewriteFileURI'], $style);
// Rewrite stylesheet with new colors.
$style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);
@@ -729,7 +729,7 @@ function _color_shift($given, $ref1, $ref2, $target) {
* Converts a hex triplet into a GD color.
*/
function _color_gd($img, $hex) {
- $c = array_merge(array($img), _color_unpack($hex));
+ $c = array_merge([$img], _color_unpack($hex));
return call_user_func_array('imagecolorallocate', $c);
}
@@ -739,7 +739,7 @@ function _color_gd($img, $hex) {
function _color_blend($img, $hex1, $hex2, $alpha) {
$in1 = _color_unpack($hex1);
$in2 = _color_unpack($hex2);
- $out = array($img);
+ $out = [$img];
for ($i = 0; $i < 3; ++$i) {
$out[] = $in1[$i] + ($in2[$i] - $in1[$i]) * $alpha;
}
@@ -784,11 +784,11 @@ function _color_hsl2rgb($hsl) {
$m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l * $s;
$m1 = $l * 2 - $m2;
- return array(
+ return [
_color_hue2rgb($m1, $m2, $h + 0.33333),
_color_hue2rgb($m1, $m2, $h),
_color_hue2rgb($m1, $m2, $h - 0.33333),
- );
+ ];
}
/**
@@ -828,5 +828,5 @@ function _color_rgb2hsl($rgb) {
$h /= 6;
}
- return array($h, $s, $l);
+ return [$h, $s, $l];
}
diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
index b88e8eae72b..ee77a5a1736 100644
--- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
+++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
@@ -5,29 +5,29 @@
* Lists available colors and color schemes for the Color test theme.
*/
-$info = array(
- 'fields' => array(
+$info = [
+ 'fields' => [
'bg' => t('Main background'),
'text' => t('Text color'),
- ),
- 'schemes' => array(
- 'default' => array(
+ ],
+ 'schemes' => [
+ 'default' => [
'title' => t('Default'),
- 'colors' => array(
+ 'colors' => [
'bg' => '#ff0000',
'text' => '#0000ff',
- ),
- ),
- 'custom' => array(
+ ],
+ ],
+ 'custom' => [
'title' => t('Custom'),
- 'colors' => array(
+ 'colors' => [
'bg' => '#ff0000',
'text' => '#3b3b3b',
- ),
- ),
- ),
- 'css' => array(
+ ],
+ ],
+ ],
+ 'css' => [
'css/colors.css',
- ),
+ ],
'preview_html' => 'color/preview.html',
-);
+];
diff --git a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php
index 157deb8dc08..e55275deb78 100644
--- a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php
+++ b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php
@@ -16,7 +16,7 @@ class ColorConfigSchemaTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('color');
+ public static $modules = ['color'];
/**
* A user with administrative permissions.
@@ -30,10 +30,10 @@ class ColorConfigSchemaTest extends BrowserTestBase {
*/
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('bartik'));
+ \Drupal::service('theme_handler')->install(['bartik']);
// Create user.
- $this->adminUser = $this->drupalCreateUser(array('administer themes'));
+ $this->adminUser = $this->drupalCreateUser(['administer themes']);
$this->drupalLogin($this->adminUser);
}
diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php
index dc4456608ec..8416913396d 100644
--- a/core/modules/color/tests/src/Functional/ColorTest.php
+++ b/core/modules/color/tests/src/Functional/ColorTest.php
@@ -17,7 +17,7 @@ class ColorTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('color', 'color_test', 'block', 'file');
+ public static $modules = ['color', 'color_test', 'block', 'file'];
/**
* A user with administrative permissions.
@@ -50,25 +50,25 @@ class ColorTest extends BrowserTestBase {
parent::setUp();
// Create user.
- $this->bigUser = $this->drupalCreateUser(array('administer themes'));
+ $this->bigUser = $this->drupalCreateUser(['administer themes']);
// This tests the color module in Bartik.
- $this->themes = array(
- 'bartik' => array(
+ $this->themes = [
+ 'bartik' => [
'palette_input' => 'palette[bg]',
'scheme' => 'slate',
'scheme_color' => '#3b3b3b',
- ),
- 'color_test_theme' => array(
+ ],
+ 'color_test_theme' => [
'palette_input' => 'palette[bg]',
'scheme' => 'custom',
'scheme_color' => '#3b3b3b',
- ),
- );
+ ],
+ ];
\Drupal::service('theme_handler')->install(array_keys($this->themes));
// Array filled with valid and not valid color values.
- $this->colorTests = array(
+ $this->colorTests = [
'#000' => TRUE,
'#123456' => TRUE,
'#abcdef' => TRUE,
@@ -78,7 +78,7 @@ class ColorTest extends BrowserTestBase {
'#00000' => FALSE,
'123456' => FALSE,
'#00000g' => FALSE,
- );
+ ];
}
/**
@@ -138,7 +138,7 @@ class ColorTest extends BrowserTestBase {
$config->set('css.preprocess', 1);
$config->save();
$this->drupalGet('<front>');
- $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array();
+ $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: [];
$stylesheet_content = '';
foreach ($stylesheets as $uri) {
$stylesheet_content .= join("\n", file(drupal_realpath($uri)));
@@ -178,10 +178,10 @@ class ColorTest extends BrowserTestBase {
*/
function testLogoSettingOverride() {
$this->drupalLogin($this->bigUser);
- $edit = array(
+ $edit = [
'default_logo' => FALSE,
'logo_path' => 'core/misc/druplicon.png',
- );
+ ];
$this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
// Ensure that the overridden logo is present in Bartik, which is colorable.
diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php
index 7b922cbcc06..ec6b4ce8ef1 100644
--- a/core/modules/comment/comment.api.php
+++ b/core/modules/comment/comment.api.php
@@ -31,16 +31,16 @@ use Drupal\Core\Url;
* @see \Drupal\comment\CommentViewBuilder::buildLinks()
*/
function hook_comment_links_alter(array &$links, CommentInterface $entity, array &$context) {
- $links['mymodule'] = array(
+ $links['mymodule'] = [
'#theme' => 'links__comment__mymodule',
- '#attributes' => array('class' => array('links', 'inline')),
- '#links' => array(
- 'comment-report' => array(
+ '#attributes' => ['class' => ['links', 'inline']],
+ '#links' => [
+ 'comment-report' => [
'title' => t('Report'),
'url' => Url::fromRoute('comment_test.report', ['comment' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("comment/{$entity->id()}/report")]]),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install
index ca356eb0315..a0d819ee236 100644
--- a/core/modules/comment/comment.install
+++ b/core/modules/comment/comment.install
@@ -15,7 +15,7 @@ use Drupal\field\Entity\FieldStorageConfig;
*/
function comment_uninstall() {
// Remove the comment fields.
- $fields = entity_load_multiple_by_properties('field_storage_config', array('type' => 'comment'));
+ $fields = entity_load_multiple_by_properties('field_storage_config', ['type' => 'comment']);
foreach ($fields as $field) {
$field->delete();
}
@@ -37,78 +37,78 @@ function comment_install() {
* Implements hook_schema().
*/
function comment_schema() {
- $schema['comment_entity_statistics'] = array(
+ $schema['comment_entity_statistics'] = [
'description' => 'Maintains statistics of entity and comments posts to show "new" and "updated" flags.',
- 'fields' => array(
- 'entity_id' => array(
+ 'fields' => [
+ 'entity_id' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The entity_id of the entity for which the statistics are compiled.',
- ),
- 'entity_type' => array(
+ ],
+ 'entity_type' => [
'type' => 'varchar_ascii',
'not null' => TRUE,
'default' => 'node',
'length' => EntityTypeInterface::ID_MAX_LENGTH,
'description' => 'The entity_type of the entity to which this comment is a reply.',
- ),
- 'field_name' => array(
+ ],
+ 'field_name' => [
'type' => 'varchar_ascii',
'not null' => TRUE,
'default' => '',
'length' => FieldStorageConfig::NAME_MAX_LENGTH,
'description' => 'The field_name of the field that was used to add this comment.',
- ),
- 'cid' => array(
+ ],
+ 'cid' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {comment}.cid of the last comment.',
- ),
- 'last_comment_timestamp' => array(
+ ],
+ 'last_comment_timestamp' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.changed.',
- ),
- 'last_comment_name' => array(
+ ],
+ 'last_comment_name' => [
'type' => 'varchar',
'length' => 60,
'not null' => FALSE,
'description' => 'The name of the latest author to post a comment on this node, from {comment}.name.',
- ),
- 'last_comment_uid' => array(
+ ],
+ 'last_comment_uid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The user ID of the latest author to post a comment on this node, from {comment}.uid.',
- ),
- 'comment_count' => array(
+ ],
+ 'comment_count' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The total number of comments on this entity.',
- ),
- ),
- 'primary key' => array('entity_id', 'entity_type', 'field_name'),
- 'indexes' => array(
- 'last_comment_timestamp' => array('last_comment_timestamp'),
- 'comment_count' => array('comment_count'),
- 'last_comment_uid' => array('last_comment_uid'),
- ),
- 'foreign keys' => array(
- 'last_comment_author' => array(
+ ],
+ ],
+ 'primary key' => ['entity_id', 'entity_type', 'field_name'],
+ 'indexes' => [
+ 'last_comment_timestamp' => ['last_comment_timestamp'],
+ 'comment_count' => ['comment_count'],
+ 'last_comment_uid' => ['last_comment_uid'],
+ ],
+ 'foreign keys' => [
+ 'last_comment_author' => [
'table' => 'users',
- 'columns' => array(
+ 'columns' => [
'last_comment_uid' => 'uid',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index ae8131559dd..ee26510729e 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -68,19 +68,19 @@ function comment_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.comment':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the <a href=":comment">online documentation for the Comment module</a>.', array(':comment' => 'https://www.drupal.org/documentation/modules/comment')) . '</p>';
+ $output .= '<p>' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the <a href=":comment">online documentation for the Comment module</a>.', [':comment' => 'https://www.drupal.org/documentation/modules/comment']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Enabling commenting') . '</dt>';
- $output .= '<dd>' . t('Comment functionality can be enabled for any entity sub-type (for example, a <a href=":content-type">content type</a>) by adding a <em>Comments</em> field on its <em>Manage fields page</em>. Adding or removing commenting for an entity through the user interface requires the <a href=":field_ui">Field UI</a> module to be enabled, even though the commenting functionality works without it. For more information on fields and entities, see the <a href=":field">Field module help page</a>.', array(':content-type' => (\Drupal::moduleHandler()->moduleExists('node')) ? \Drupal::url('entity.node_type.collection') : '#', ':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('Comment functionality can be enabled for any entity sub-type (for example, a <a href=":content-type">content type</a>) by adding a <em>Comments</em> field on its <em>Manage fields page</em>. Adding or removing commenting for an entity through the user interface requires the <a href=":field_ui">Field UI</a> module to be enabled, even though the commenting functionality works without it. For more information on fields and entities, see the <a href=":field">Field module help page</a>.', [':content-type' => (\Drupal::moduleHandler()->moduleExists('node')) ? \Drupal::url('entity.node_type.collection') : '#', ':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Configuring commenting settings') . '</dt>';
$output .= '<dd>' . t('Commenting settings can be configured by editing the <em>Comments</em> field on the <em>Manage fields page</em> of an entity type if the <em>Field UI module</em> is enabled. Configuration includes the label of the comments field, the number of comments to be displayed, and whether they are shown in threaded list. Commenting can be be configured as: <em>Open</em> to allow new comments, <em>Closed</em> to view existing comments, but prevent new comments, or <em>Hidden</em> to hide existing comments and prevent new comments. Changing this configuration for an entity type will not change existing entity items.') . '</dd>';
$output .= '<dt>' . t('Overriding default settings') . '</dt>';
$output .= '<dd>' . t('Users with the appropriate permissions can override the default commenting settings of an entity type when they create an item of that type.') . '</dd>';
$output .= '<dt>' . t('Adding comment types') . '</dt>';
- $output .= '<dd>' . t('Additional <em>comment types</em> can be created per entity sub-type and added on the <a href=":field">Comment types page</a>. If there are multiple comment types available you can select the appropriate one after adding a <em>Comments field</em>.', array(':field' => \Drupal::url('entity.comment_type.collection'))) . '</dd>';
+ $output .= '<dd>' . t('Additional <em>comment types</em> can be created per entity sub-type and added on the <a href=":field">Comment types page</a>. If there are multiple comment types available you can select the appropriate one after adding a <em>Comments field</em>.', [':field' => \Drupal::url('entity.comment_type.collection')]) . '</dd>';
$output .= '<dt>' . t('Approving and managing comments') . '</dt>';
- $output .= '<dd>' . t('Comments from users who have the <em>Skip comment approval</em> permission are published immediately. All other comments are placed in the <a href=":comment-approval">Unapproved comments</a> queue, until a user who has permission to <em>Administer comments and comment settings</em> publishes or deletes them. Published comments can be bulk managed on the <a href=":admin-comment">Published comments</a> administration page. When a comment has no replies, it remains editable by its author, as long as the author has <em>Edit own comments</em> permission.', array(':comment-approval' => \Drupal::url('comment.admin_approval'), ':admin-comment' => \Drupal::url('comment.admin'))) . '</dd>';
+ $output .= '<dd>' . t('Comments from users who have the <em>Skip comment approval</em> permission are published immediately. All other comments are placed in the <a href=":comment-approval">Unapproved comments</a> queue, until a user who has permission to <em>Administer comments and comment settings</em> publishes or deletes them. Published comments can be bulk managed on the <a href=":admin-comment">Published comments</a> administration page. When a comment has no replies, it remains editable by its author, as long as the author has <em>Edit own comments</em> permission.', [':comment-approval' => \Drupal::url('comment.admin_approval'), ':admin-comment' => \Drupal::url('comment.admin')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -96,10 +96,10 @@ function comment_help($route_name, RouteMatchInterface $route_match) {
function comment_uri(CommentInterface $comment) {
return new Url(
'entity.comment.canonical',
- array(
+ [
'comment' => $comment->id(),
- ),
- array('fragment' => 'comment-' . $comment->id())
+ ],
+ ['fragment' => 'comment-' . $comment->id()]
);
}
@@ -107,23 +107,23 @@ function comment_uri(CommentInterface $comment) {
* Implements hook_entity_extra_field_info().
*/
function comment_entity_extra_field_info() {
- $return = array();
+ $return = [];
foreach (CommentType::loadMultiple() as $comment_type) {
- $return['comment'][$comment_type->id()] = array(
- 'form' => array(
- 'author' => array(
+ $return['comment'][$comment_type->id()] = [
+ 'form' => [
+ 'author' => [
'label' => t('Author'),
'description' => t('Author textfield'),
'weight' => -2,
- ),
- ),
- );
- $return['comment'][$comment_type->id()]['display']['links'] = array(
+ ],
+ ],
+ ];
+ $return['comment'][$comment_type->id()]['display']['links'] = [
'label' => t('Links'),
'description' => t('Comment operation links'),
'weight' => 100,
'visible' => TRUE,
- );
+ ];
}
return $return;
@@ -133,14 +133,14 @@ function comment_entity_extra_field_info() {
* Implements hook_theme().
*/
function comment_theme() {
- return array(
- 'comment' => array(
+ return [
+ 'comment' => [
'render element' => 'elements',
- ),
- 'field__comment' => array(
+ ],
+ 'field__comment' => [
'base hook' => 'field',
- ),
- );
+ ],
+ ];
}
/**
@@ -150,15 +150,15 @@ function comment_field_config_create(FieldConfigInterface $field) {
if ($field->getType() == 'comment' && !$field->isSyncing()) {
// Assign default values for the field.
$default_value = $field->getDefaultValueLiteral();
- $default_value += array(array());
- $default_value[0] += array(
+ $default_value += [[]];
+ $default_value[0] += [
'status' => CommentItemInterface::OPEN,
'cid' => 0,
'last_comment_timestamp' => 0,
'last_comment_name' => '',
'last_comment_uid' => 0,
'comment_count' => 0,
- );
+ ];
$field->setDefaultValue($default_value);
}
}
@@ -227,14 +227,14 @@ function comment_entity_view(array &$build, EntityInterface $entity, EntityViewD
if ($entity->hasField($field_name) && $entity->get($field_name)->status != CommentItemInterface::HIDDEN) {
// Add a comments RSS element which is a URL to the comments of this
// entity.
- $options = array(
+ $options = [
'fragment' => 'comments',
'absolute' => TRUE,
- );
- $entity->rss_elements[] = array(
+ ];
+ $entity->rss_elements[] = [
'key' => 'comments',
'value' => $entity->url('canonical', $options),
- );
+ ];
}
}
}
@@ -457,7 +457,7 @@ function comment_node_update_index(EntityInterface $node) {
}
}
- $build = array();
+ $build = [];
if ($index_comments) {
foreach (\Drupal::service('comment.manager')->getFields('node') as $field_name => $info) {
@@ -517,7 +517,7 @@ function comment_node_search_result(EntityInterface $node) {
// Do not make a string if there are no comment fields, or no comments exist
// or all comment fields are hidden.
if ($comments > 0 || $open) {
- return array('comment' => \Drupal::translation()->formatPlural($comments, '1 comment', '@count comments'));
+ return ['comment' => \Drupal::translation()->formatPlural($comments, '1 comment', '@count comments')];
}
}
@@ -527,7 +527,7 @@ function comment_node_search_result(EntityInterface $node) {
function comment_user_cancel($edit, $account, $method) {
switch ($method) {
case 'user_cancel_block_unpublish':
- $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id()));
+ $comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]);
foreach ($comments as $comment) {
$comment->setPublished(CommentInterface::NOT_PUBLISHED);
$comment->save();
@@ -536,7 +536,7 @@ function comment_user_cancel($edit, $account, $method) {
case 'user_cancel_reassign':
/** @var \Drupal\comment\CommentInterface[] $comments */
- $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id()));
+ $comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]);
foreach ($comments as $comment) {
$comment->setOwnerId(0);
$comment->setAuthorName(\Drupal::config('user.settings')->get('anonymous'));
@@ -568,7 +568,7 @@ function comment_user_predelete($account) {
* An array as expected by drupal_render().
*/
function comment_preview(CommentInterface $comment, FormStateInterface $form_state) {
- $preview_build = array();
+ $preview_build = [];
$entity = $comment->getCommentedEntity();
if (!$form_state->getErrors()) {
@@ -580,7 +580,7 @@ function comment_preview(CommentInterface $comment, FormStateInterface $form_sta
}
if ($comment->hasParentComment()) {
- $build = array();
+ $build = [];
$parent = $comment->getParentComment();
if ($parent && $parent->isPublished()) {
$build = \Drupal::entityTypeManager()->getViewBuilder('comment')->view($parent);
@@ -636,10 +636,10 @@ function template_preprocess_comment(&$variables) {
$variables['threaded'] = $variables['elements']['#comment_threaded'];
$account = $comment->getOwner();
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $account,
- );
+ ];
$variables['author'] = drupal_render($username);
$variables['author_id'] = $comment->getOwnerId();
$variables['new_indicator_timestamp'] = $comment->getChangedTime();
@@ -658,7 +658,7 @@ function template_preprocess_comment(&$variables) {
$variables['user_picture'] = user_view($account, 'compact');
}
else {
- $variables['user_picture'] = array();
+ $variables['user_picture'] = [];
}
if (isset($comment->in_preview)) {
@@ -667,25 +667,25 @@ function template_preprocess_comment(&$variables) {
}
else {
$uri = $comment->permalink();
- $attributes = $uri->getOption('attributes') ?: array();
- $attributes += array('class' => array('permalink'), 'rel' => 'bookmark');
+ $attributes = $uri->getOption('attributes') ?: [];
+ $attributes += ['class' => ['permalink'], 'rel' => 'bookmark'];
$uri->setOption('attributes', $attributes);
$variables['title'] = \Drupal::l($comment->getSubject(), $uri);
$variables['permalink'] = \Drupal::l(t('Permalink'), $comment->permalink());
}
- $variables['submitted'] = t('Submitted by @username on @datetime', array('@username' => $variables['author'], '@datetime' => $variables['created']));
+ $variables['submitted'] = t('Submitted by @username on @datetime', ['@username' => $variables['author'], '@datetime' => $variables['created']]);
if ($comment->hasParentComment()) {
// Fetch and store the parent comment information for use in templates.
$comment_parent = $comment->getParentComment();
$account_parent = $comment_parent->getOwner();
$variables['parent_comment'] = $comment_parent;
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $account_parent,
- );
+ ];
$variables['parent_author'] = drupal_render($username);
$variables['parent_created'] = format_date($comment_parent->getCreatedTime());
// Avoid calling format_date() twice on the same timestamp.
@@ -696,13 +696,13 @@ function template_preprocess_comment(&$variables) {
$variables['parent_changed'] = format_date($comment_parent->getChangedTime());
}
$permalink_uri_parent = $comment_parent->permalink();
- $attributes = $permalink_uri_parent->getOption('attributes') ?: array();
- $attributes += array('class' => array('permalink'), 'rel' => 'bookmark');
+ $attributes = $permalink_uri_parent->getOption('attributes') ?: [];
+ $attributes += ['class' => ['permalink'], 'rel' => 'bookmark'];
$permalink_uri_parent->setOption('attributes', $attributes);
$variables['parent_title'] = \Drupal::l($comment_parent->getSubject(), $permalink_uri_parent);
$variables['parent_permalink'] = \Drupal::l(t('Parent permalink'), $permalink_uri_parent);
$variables['parent'] = t('In reply to @parent_title by @parent_username',
- array('@parent_username' => $variables['parent_author'], '@parent_title' => $variables['parent_title']));
+ ['@parent_username' => $variables['parent_author'], '@parent_title' => $variables['parent_title']]);
}
else {
$variables['parent_comment'] = '';
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index 5af2e6a1747..884144196a2 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -15,11 +15,11 @@ use Drupal\Core\Render\BubbleableMetadata;
* Implements hook_token_info().
*/
function comment_token_info() {
- $type = array(
+ $type = [
'name' => t('Comments'),
'description' => t('Tokens for comments posted on the site.'),
'needs-data' => 'comment',
- );
+ ];
$tokens = [];
// Provide a integration for each entity type except comment.
@@ -45,76 +45,76 @@ function comment_token_info() {
}
// Core comment tokens
- $comment['cid'] = array(
+ $comment['cid'] = [
'name' => t("Comment ID"),
'description' => t("The unique ID of the comment."),
- );
- $comment['hostname'] = array(
+ ];
+ $comment['hostname'] = [
'name' => t("IP Address"),
'description' => t("The IP address of the computer the comment was posted from."),
- );
- $comment['mail'] = array(
+ ];
+ $comment['mail'] = [
'name' => t("Email address"),
'description' => t("The email address left by the comment author."),
- );
- $comment['homepage'] = array(
+ ];
+ $comment['homepage'] = [
'name' => t("Home page"),
'description' => t("The home page URL left by the comment author."),
- );
- $comment['title'] = array(
+ ];
+ $comment['title'] = [
'name' => t("Title"),
'description' => t("The title of the comment."),
- );
- $comment['body'] = array(
+ ];
+ $comment['body'] = [
'name' => t("Content"),
'description' => t("The formatted content of the comment itself."),
- );
- $comment['langcode'] = array(
+ ];
+ $comment['langcode'] = [
'name' => t('Language code'),
'description' => t('The language code of the language the comment is written in.'),
- );
- $comment['url'] = array(
+ ];
+ $comment['url'] = [
'name' => t("URL"),
'description' => t("The URL of the comment."),
- );
- $comment['edit-url'] = array(
+ ];
+ $comment['edit-url'] = [
'name' => t("Edit URL"),
'description' => t("The URL of the comment's edit page."),
- );
+ ];
// Chained tokens for comments
- $comment['created'] = array(
+ $comment['created'] = [
'name' => t("Date created"),
'description' => t("The date the comment was posted."),
'type' => 'date',
- );
- $comment['changed'] = array(
+ ];
+ $comment['changed'] = [
'name' => t("Date changed"),
'description' => t("The date the comment was most recently updated."),
'type' => 'date',
- );
- $comment['parent'] = array(
+ ];
+ $comment['parent'] = [
'name' => t("Parent"),
'description' => t("The comment's parent, if comment threading is active."),
'type' => 'comment',
- );
- $comment['entity'] = array(
+ ];
+ $comment['entity'] = [
'name' => t("Entity"),
'description' => t("The entity the comment was posted to."),
'type' => 'entity',
- );
- $comment['author'] = array(
+ ];
+ $comment['author'] = [
'name' => t("Author"),
'description' => t("The author name of the comment."),
'type' => 'user',
- );
+ ];
- return array(
- 'types' => array('comment' => $type),
- 'tokens' => array(
+ return [
+ 'types' => ['comment' => $type],
+ 'tokens' => [
'comment' => $comment,
- ) + $tokens,
- );
+ ] + $tokens,
+ ];
}
/**
@@ -123,7 +123,7 @@ function comment_token_info() {
function comment_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@@ -131,7 +131,7 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
else {
$langcode = NULL;
}
- $replacements = array();
+ $replacements = [];
if ($type == 'comment' && !empty($data['comment'])) {
/** @var \Drupal\comment\CommentInterface $comment */
@@ -230,23 +230,23 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
// Chained token relationships.
if ($entity_tokens = $token_service->findwithPrefix($tokens, 'entity')) {
$entity = $comment->getCommentedEntity();
- $replacements += $token_service->generate($comment->getCommentedEntityTypeId(), $entity_tokens, array($comment->getCommentedEntityTypeId() => $entity), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate($comment->getCommentedEntityTypeId(), $entity_tokens, [$comment->getCommentedEntityTypeId() => $entity], $options, $bubbleable_metadata);
}
if ($date_tokens = $token_service->findwithPrefix($tokens, 'created')) {
- $replacements += $token_service->generate('date', $date_tokens, array('date' => $comment->getCreatedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $date_tokens, ['date' => $comment->getCreatedTime()], $options, $bubbleable_metadata);
}
if ($date_tokens = $token_service->findwithPrefix($tokens, 'changed')) {
- $replacements += $token_service->generate('date', $date_tokens, array('date' => $comment->getChangedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $date_tokens, ['date' => $comment->getChangedTime()], $options, $bubbleable_metadata);
}
if (($parent_tokens = $token_service->findwithPrefix($tokens, 'parent')) && $parent = $comment->getParentComment()) {
- $replacements += $token_service->generate('comment', $parent_tokens, array('comment' => $parent), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('comment', $parent_tokens, ['comment' => $parent], $options, $bubbleable_metadata);
}
if (($author_tokens = $token_service->findwithPrefix($tokens, 'author')) && $account = $comment->getOwner()) {
- $replacements += $token_service->generate('user', $author_tokens, array('user' => $account), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('user', $author_tokens, ['user' => $account], $options, $bubbleable_metadata);
}
}
// Replacement tokens for any content entities that have comment field.
diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc
index fb11a4f7a55..11abede944c 100644
--- a/core/modules/comment/comment.views.inc
+++ b/core/modules/comment/comment.views.inc
@@ -13,14 +13,14 @@ use Drupal\Core\Entity\ContentEntityInterface;
function comment_views_data_alter(&$data) {
// New comments are only supported for node table because it requires the
// history table.
- $data['node']['new_comments'] = array(
+ $data['node']['new_comments'] = [
'title' => t('New comments'),
'help' => t('The number of new comments on the node.'),
- 'field' => array(
+ 'field' => [
'id' => 'node_new_comments',
'no group by' => TRUE,
- ),
- );
+ ],
+ ];
// Provide a integration for each entity type except comment.
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
@@ -29,25 +29,25 @@ function comment_views_data_alter(&$data) {
}
$fields = \Drupal::service('comment.manager')->getFields($entity_type_id);
$base_table = $entity_type->getDataTable() ?: $entity_type->getBaseTable();
- $args = array('@entity_type' => $entity_type_id);
+ $args = ['@entity_type' => $entity_type_id];
if ($fields) {
- $data[$base_table]['comments_link'] = array(
- 'field' => array(
+ $data[$base_table]['comments_link'] = [
+ 'field' => [
'title' => t('Add comment link'),
'help' => t('Display the standard add comment link used on regular @entity_type, which will only display if the viewing user has access to add a comment.', $args),
'id' => 'comment_entity_link',
- ),
- );
+ ],
+ ];
// Multilingual properties are stored in data table.
if (!($table = $entity_type->getDataTable())) {
$table = $entity_type->getBaseTable();
}
- $data[$table]['uid_touch'] = array(
+ $data[$table]['uid_touch'] = [
'title' => t('User posted or commented'),
'help' => t('Display nodes only if a user posted the @entity_type or commented on the @entity_type.', $args),
- 'argument' => array(
+ 'argument' => [
'field' => 'uid',
'name table' => 'users_field_data',
'name field' => 'name',
@@ -55,40 +55,40 @@ function comment_views_data_alter(&$data) {
'no group by' => TRUE,
'entity_type' => $entity_type_id,
'entity_id' => $entity_type->getKey('id'),
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'field' => 'uid',
'name table' => 'users_field_data',
'name field' => 'name',
'id' => 'comment_user_uid',
'entity_type' => $entity_type_id,
'entity_id' => $entity_type->getKey('id'),
- ),
- );
+ ],
+ ];
foreach ($fields as $field_name => $field) {
- $data[$base_table][$field_name . '_cid'] = array(
- 'title' => t('Comments of the @entity_type using field: @field_name', $args + array('@field_name' => $field_name)),
+ $data[$base_table][$field_name . '_cid'] = [
+ 'title' => t('Comments of the @entity_type using field: @field_name', $args + ['@field_name' => $field_name]),
'help' => t('Relate all comments on the @entity_type. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.', $args),
- 'relationship' => array(
+ 'relationship' => [
'group' => t('Comment'),
'label' => t('Comments'),
'base' => 'comment_field_data',
'base field' => 'entity_id',
'relationship field' => $entity_type->getKey('id'),
'id' => 'standard',
- 'extra' => array(
- array(
+ 'extra' => [
+ [
'field' => 'entity_type',
'value' => $entity_type_id,
- ),
- array(
+ ],
+ [
'field' => 'field_name',
'value' => $field_name,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
}
}
}
diff --git a/core/modules/comment/src/CommentAccessControlHandler.php b/core/modules/comment/src/CommentAccessControlHandler.php
index 639575a423d..bcb0fd7a082 100644
--- a/core/modules/comment/src/CommentAccessControlHandler.php
+++ b/core/modules/comment/src/CommentAccessControlHandler.php
@@ -67,23 +67,23 @@ class CommentAccessControlHandler extends EntityAccessControlHandler {
if ($operation == 'edit') {
// Only users with the "administer comments" permission can edit
// administrative fields.
- $administrative_fields = array(
+ $administrative_fields = [
'uid',
'status',
'created',
'date',
- );
+ ];
if (in_array($field_definition->getName(), $administrative_fields, TRUE)) {
return AccessResult::allowedIfHasPermission($account, 'administer comments');
}
// No user can change read-only fields.
- $read_only_fields = array(
+ $read_only_fields = [
'hostname',
'changed',
'cid',
'thread',
- );
+ ];
// These fields can be edited during comment creation.
$create_only_fields = [
'comment_type',
diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php
index 3a2e7041002..28231b8cb77 100644
--- a/core/modules/comment/src/CommentForm.php
+++ b/core/modules/comment/src/CommentForm.php
@@ -91,7 +91,7 @@ class CommentForm extends ContentEntityForm {
// Use #comment-form as unique jump target, regardless of entity type.
$form['#id'] = Html::getUniqueId('comment_form');
- $form['#theme'] = array('comment_form__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form');
+ $form['#theme'] = ['comment_form__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form'];
$anonymous_contact = $field_definition->getSetting('anonymous');
$is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments');
@@ -104,7 +104,7 @@ class CommentForm extends ContentEntityForm {
// If not replying to a comment, use our dedicated page callback for new
// Comments on entities.
if (!$comment->id() && !$comment->hasParentComment()) {
- $form['#action'] = $this->url('comment.reply', array('entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name));
+ $form['#action'] = $this->url('comment.reply', ['entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name]);
}
$comment_preview = $form_state->get('comment_preview');
@@ -112,13 +112,13 @@ class CommentForm extends ContentEntityForm {
$form += $comment_preview;
}
- $form['author'] = array();
+ $form['author'] = [];
// Display author information in a details element for comment moderators.
if ($is_admin) {
- $form['author'] += array(
+ $form['author'] += [
'#type' => 'details',
'#title' => $this->t('Administration'),
- );
+ ];
}
// Prepare default values for form elements.
@@ -129,9 +129,9 @@ class CommentForm extends ContentEntityForm {
}
$status = $comment->getStatus();
if (empty($comment_preview)) {
- $form['#title'] = $this->t('Edit comment %title', array(
+ $form['#title'] = $this->t('Edit comment %title', [
'%title' => $comment->getSubject(),
- ));
+ ]);
}
}
else {
@@ -162,7 +162,7 @@ class CommentForm extends ContentEntityForm {
// The name field is displayed when an anonymous user is adding a comment or
// when a user with the permission 'administer comments' is editing an
// existing comment from an anonymous user.
- $form['author']['name'] = array(
+ $form['author']['name'] = [
'#type' => 'textfield',
'#title' => $is_admin ? $this->t('Name for @anonymous', ['@anonymous' => $config->get('anonymous')]) : $this->t('Your name'),
'#default_value' => $author,
@@ -173,20 +173,20 @@ class CommentForm extends ContentEntityForm {
'#attributes' => [
'data-drupal-default-value' => $config->get('anonymous'),
],
- );
+ ];
if ($is_admin) {
// When editing a comment only display the name textfield if the uid field
// is empty.
$form['author']['name']['#states'] = [
'visible' => [
- ':input[name="uid"]' => array('empty' => TRUE),
+ ':input[name="uid"]' => ['empty' => TRUE],
],
];
}
// Add author email and homepage fields depending on the current user.
- $form['author']['mail'] = array(
+ $form['author']['mail'] = [
'#type' => 'email',
'#title' => $this->t('Email'),
'#default_value' => $comment->getAuthorEmail(),
@@ -195,36 +195,36 @@ class CommentForm extends ContentEntityForm {
'#size' => 30,
'#description' => $this->t('The content of this field is kept private and will not be shown publicly.'),
'#access' => ($comment->getOwner()->isAnonymous() && $is_admin) || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
- );
+ ];
- $form['author']['homepage'] = array(
+ $form['author']['homepage'] = [
'#type' => 'url',
'#title' => $this->t('Homepage'),
'#default_value' => $comment->getHomepage(),
'#maxlength' => 255,
'#size' => 30,
'#access' => $is_admin || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
- );
+ ];
// Add administrative comment publishing options.
- $form['author']['date'] = array(
+ $form['author']['date'] = [
'#type' => 'datetime',
'#title' => $this->t('Authored on'),
'#default_value' => $date,
'#size' => 20,
'#access' => $is_admin,
- );
+ ];
- $form['author']['status'] = array(
+ $form['author']['status'] = [
'#type' => 'radios',
'#title' => $this->t('Status'),
'#default_value' => $status,
- '#options' => array(
+ '#options' => [
CommentInterface::PUBLISHED => $this->t('Published'),
CommentInterface::NOT_PUBLISHED => $this->t('Not published'),
- ),
+ ],
'#access' => $is_admin,
- );
+ ];
return parent::form($form, $form_state, $comment);
}
@@ -250,12 +250,12 @@ class CommentForm extends ContentEntityForm {
// already previewing the submission.
$element['submit']['#access'] = ($comment->id() && $this->currentUser->hasPermission('administer comments')) || $preview_mode != DRUPAL_REQUIRED || $form_state->get('comment_preview');
- $element['preview'] = array(
+ $element['preview'] = [
'#type' => 'submit',
'#value' => $this->t('Preview'),
'#access' => $preview_mode != DRUPAL_DISABLED,
- '#submit' => array('::submitForm', '::preview'),
- );
+ '#submit' => ['::submitForm', '::preview'],
+ ];
return $element;
}
@@ -365,10 +365,10 @@ class CommentForm extends ContentEntityForm {
$form_state->setValue('cid', $comment->id());
// Add a log entry.
- $logger->notice('Comment posted: %subject.', array(
+ $logger->notice('Comment posted: %subject.', [
'%subject' => $comment->getSubject(),
'link' => $this->l(t('View'), $comment->urlInfo()->setOption('fragment', 'comment-' . $comment->id()))
- ));
+ ]);
// Explain the approval queue if necessary.
if (!$comment->isPublished()) {
@@ -379,7 +379,7 @@ class CommentForm extends ContentEntityForm {
else {
drupal_set_message($this->t('Your comment has been posted.'));
}
- $query = array();
+ $query = [];
// Find the current display page for this comment.
$field_definition = $this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle())[$field_name];
$page = $this->entityManager->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page'));
@@ -391,8 +391,8 @@ class CommentForm extends ContentEntityForm {
$uri->setOption('fragment', 'comment-' . $comment->id());
}
else {
- $logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject()));
- drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject())), 'error');
+ $logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', ['%subject' => $comment->getSubject()]);
+ drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', ['%subject' => $comment->getSubject()]), 'error');
// Redirect the user to the entity they are commenting on.
}
$form_state->setRedirectUrl($uri);
diff --git a/core/modules/comment/src/CommentLazyBuilders.php b/core/modules/comment/src/CommentLazyBuilders.php
index 4eeeb59d0c0..730c840897f 100644
--- a/core/modules/comment/src/CommentLazyBuilders.php
+++ b/core/modules/comment/src/CommentLazyBuilders.php
@@ -99,13 +99,13 @@ class CommentLazyBuilders {
* A renderable array containing the comment form.
*/
public function renderForm($commented_entity_type_id, $commented_entity_id, $field_name, $comment_type_id) {
- $values = array(
+ $values = [
'entity_type' => $commented_entity_type_id,
'entity_id' => $commented_entity_id,
'field_name' => $field_name,
'comment_type' => $comment_type_id,
'pid' => NULL,
- );
+ ];
$comment = $this->entityManager->getStorage('comment')->create($values);
return $this->entityFormBuilder->getForm($comment);
}
@@ -126,11 +126,11 @@ class CommentLazyBuilders {
* A renderable array representing the comment links.
*/
public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_preview) {
- $links = array(
+ $links = [
'#theme' => 'links__comment',
- '#pre_render' => array('drupal_pre_render_links'),
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#pre_render' => ['drupal_pre_render_links'],
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
if (!$is_in_preview) {
/** @var \Drupal\comment\CommentInterface $entity */
@@ -140,11 +140,11 @@ class CommentLazyBuilders {
$links['comment'] = $this->buildLinks($entity, $commented_entity);
// Allow other modules to alter the comment links.
- $hook_context = array(
+ $hook_context = [
'view_mode' => $view_mode,
'langcode' => $langcode,
'commented_entity' => $commented_entity,
- );
+ ];
$this->moduleHandler->alter('comment_links', $links, $entity, $hook_context);
}
return $links;
@@ -162,25 +162,25 @@ class CommentLazyBuilders {
* An array that can be processed by drupal_pre_render_links().
*/
protected function buildLinks(CommentInterface $entity, EntityInterface $commented_entity) {
- $links = array();
+ $links = [];
$status = $commented_entity->get($entity->getFieldName())->status;
if ($status == CommentItemInterface::OPEN) {
if ($entity->access('delete')) {
- $links['comment-delete'] = array(
+ $links['comment-delete'] = [
'title' => t('Delete'),
'url' => $entity->urlInfo('delete-form'),
- );
+ ];
}
if ($entity->access('update')) {
- $links['comment-edit'] = array(
+ $links['comment-edit'] = [
'title' => t('Edit'),
'url' => $entity->urlInfo('edit-form'),
- );
+ ];
}
if ($entity->access('create')) {
- $links['comment-reply'] = array(
+ $links['comment-reply'] = [
'title' => t('Reply'),
'url' => Url::fromRoute('comment.reply', [
'entity_type' => $entity->getCommentedEntityTypeId(),
@@ -188,13 +188,13 @@ class CommentLazyBuilders {
'field_name' => $entity->getFieldName(),
'pid' => $entity->id(),
]),
- );
+ ];
}
if (!$entity->isPublished() && $entity->access('approve')) {
- $links['comment-approve'] = array(
+ $links['comment-approve'] = [
'title' => t('Approve'),
'url' => Url::fromRoute('comment.approve', ['comment' => $entity->id()]),
- );
+ ];
}
if (empty($links) && $this->currentUser->isAnonymous()) {
$links['comment-forbidden']['title'] = $this->commentManager->forbiddenMessage($commented_entity, $entity->getFieldName());
@@ -203,18 +203,18 @@ class CommentLazyBuilders {
// Add translations link for translation-enabled comment bundles.
if ($this->moduleHandler->moduleExists('content_translation') && $this->access($entity)->isAllowed()) {
- $links['comment-translations'] = array(
+ $links['comment-translations'] = [
'title' => t('Translate'),
'url' => $entity->urlInfo('drupal:content-translation-overview'),
- );
+ ];
}
- return array(
+ return [
'#theme' => 'links__comment__comment',
// The "entity" property is specified to be present, so no need to check.
'#links' => $links,
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
}
/**
diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php
index 9998e3f3d6f..c7cbc18d376 100644
--- a/core/modules/comment/src/CommentLinkBuilder.php
+++ b/core/modules/comment/src/CommentLinkBuilder.php
@@ -75,7 +75,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
* {@inheritdoc}
*/
public function buildCommentedEntityLinks(FieldableEntityInterface $entity, array &$context) {
- $entity_links = array();
+ $entity_links = [];
$view_mode = $context['view_mode'];
if ($view_mode == 'search_index' || $view_mode == 'search_result' || $view_mode == 'print' || $view_mode == 'rss') {
// Do not add any links if the entity is displayed for:
@@ -83,7 +83,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
// - constructing a search result excerpt.
// - print.
// - rss.
- return array();
+ return [];
}
$fields = $this->commentManager->getFields($entity->getEntityTypeId());
@@ -92,7 +92,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
if (!$entity->hasField($field_name)) {
continue;
}
- $links = array();
+ $links = [];
$commenting_status = $entity->get($field_name)->status;
if ($commenting_status != CommentItemInterface::HIDDEN) {
// Entity has commenting status open or closed.
@@ -103,23 +103,23 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
// entity is open to new comments, and there currently are none.
if ($this->currentUser->hasPermission('access comments')) {
if (!empty($entity->get($field_name)->comment_count)) {
- $links['comment-comments'] = array(
+ $links['comment-comments'] = [
'title' => $this->formatPlural($entity->get($field_name)->comment_count, '1 comment', '@count comments'),
- 'attributes' => array('title' => $this->t('Jump to the first comment.')),
+ 'attributes' => ['title' => $this->t('Jump to the first comment.')],
'fragment' => 'comments',
'url' => $entity->urlInfo(),
- );
+ ];
if ($this->moduleHandler->moduleExists('history')) {
- $links['comment-new-comments'] = array(
+ $links['comment-new-comments'] = [
'title' => '',
'url' => Url::fromRoute('<current>'),
- 'attributes' => array(
+ 'attributes' => [
'class' => 'hidden',
'title' => $this->t('Jump to the first new comment.'),
'data-history-node-last-comment-timestamp' => $entity->get($field_name)->last_comment_timestamp,
'data-history-node-field-name' => $field_name,
- ),
- );
+ ],
+ ];
}
}
}
@@ -127,12 +127,12 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
if ($commenting_status == CommentItemInterface::OPEN) {
$comment_form_location = $field_definition->getSetting('form_location');
if ($this->currentUser->hasPermission('post comments')) {
- $links['comment-add'] = array(
+ $links['comment-add'] = [
'title' => $this->t('Add new comment'),
'language' => $entity->language(),
- 'attributes' => array('title' => $this->t('Share your thoughts and opinions.')),
+ 'attributes' => ['title' => $this->t('Share your thoughts and opinions.')],
'fragment' => 'comment-form',
- );
+ ];
if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE) {
$links['comment-add']['url'] = Url::fromRoute('comment.reply', [
'entity_type' => $entity->getEntityTypeId(),
@@ -145,9 +145,9 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
}
}
elseif ($this->currentUser->isAnonymous()) {
- $links['comment-forbidden'] = array(
+ $links['comment-forbidden'] = [
'title' => $this->commentManager->forbiddenMessage($entity, $field_name),
- );
+ ];
}
}
}
@@ -161,11 +161,11 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
// Show the "post comment" link if the form is on another page, or
// if there are existing comments that the link will skip past.
if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE || (!empty($entity->get($field_name)->comment_count) && $this->currentUser->hasPermission('access comments'))) {
- $links['comment-add'] = array(
+ $links['comment-add'] = [
'title' => $this->t('Add new comment'),
- 'attributes' => array('title' => $this->t('Share your thoughts and opinions.')),
+ 'attributes' => ['title' => $this->t('Share your thoughts and opinions.')],
'fragment' => 'comment-form',
- );
+ ];
if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE) {
$links['comment-add']['url'] = Url::fromRoute('comment.reply', [
'entity_type' => $entity->getEntityTypeId(),
@@ -179,20 +179,20 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
}
}
elseif ($this->currentUser->isAnonymous()) {
- $links['comment-forbidden'] = array(
+ $links['comment-forbidden'] = [
'title' => $this->commentManager->forbiddenMessage($entity, $field_name),
- );
+ ];
}
}
}
}
if (!empty($links)) {
- $entity_links['comment__' . $field_name] = array(
+ $entity_links['comment__' . $field_name] = [
'#theme' => 'links__entity__comment__' . $field_name,
'#links' => $links,
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
if ($view_mode == 'teaser' && $this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated()) {
$entity_links['comment__' . $field_name]['#cache']['contexts'][] = 'user';
$entity_links['comment__' . $field_name]['#attached']['library'][] = 'comment/drupal.node-new-comments-link';
diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php
index fb1c61e4da6..80cc427e34c 100644
--- a/core/modules/comment/src/CommentManager.php
+++ b/core/modules/comment/src/CommentManager.php
@@ -90,11 +90,11 @@ class CommentManager implements CommentManagerInterface {
public function getFields($entity_type_id) {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
- return array();
+ return [];
}
$map = $this->entityManager->getFieldMapByFieldType('comment');
- return isset($map[$entity_type_id]) ? $map[$entity_type_id] : array();
+ return isset($map[$entity_type_id]) ? $map[$entity_type_id] : [];
}
/**
@@ -103,28 +103,28 @@ class CommentManager implements CommentManagerInterface {
public function addBodyField($comment_type_id) {
if (!FieldConfig::loadByName('comment', $comment_type_id, 'comment_body')) {
// Attaches the body field by default.
- $field = $this->entityManager->getStorage('field_config')->create(array(
+ $field = $this->entityManager->getStorage('field_config')->create([
'label' => 'Comment',
'bundle' => $comment_type_id,
'required' => TRUE,
'field_storage' => FieldStorageConfig::loadByName('comment', 'comment_body'),
- ));
+ ]);
$field->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('comment', $comment_type_id, 'default')
- ->setComponent('comment_body', array(
+ ->setComponent('comment_body', [
'type' => 'text_textarea',
- ))
+ ])
->save();
// Assign display settings for the 'default' view mode.
entity_get_display('comment', $comment_type_id, 'default')
- ->setComponent('comment_body', array(
+ ->setComponent('comment_body', [
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
- ))
+ ])
->save();
}
}
@@ -151,24 +151,24 @@ class CommentManager implements CommentManagerInterface {
'entity' => $entity->id(),
'field_name' => $field_name,
];
- $destination = array('destination' => $this->url('comment.reply', $comment_reply_parameters, array('fragment' => 'comment-form')));
+ $destination = ['destination' => $this->url('comment.reply', $comment_reply_parameters, ['fragment' => 'comment-form'])];
}
else {
- $destination = array('destination' => $entity->url('canonical', array('fragment' => 'comment-form')));
+ $destination = ['destination' => $entity->url('canonical', ['fragment' => 'comment-form'])];
}
if ($this->userConfig->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
// Users can register themselves.
- return $this->t('<a href=":login">Log in</a> or <a href=":register">register</a> to post comments', array(
- ':login' => $this->urlGenerator->generateFromRoute('user.login', array(), array('query' => $destination)),
- ':register' => $this->urlGenerator->generateFromRoute('user.register', array(), array('query' => $destination)),
- ));
+ return $this->t('<a href=":login">Log in</a> or <a href=":register">register</a> to post comments', [
+ ':login' => $this->urlGenerator->generateFromRoute('user.login', [], ['query' => $destination]),
+ ':register' => $this->urlGenerator->generateFromRoute('user.register', [], ['query' => $destination]),
+ ]);
}
else {
// Only admins can add new users, no public registration.
- return $this->t('<a href=":login">Log in</a> to post comments', array(
- ':login' => $this->urlGenerator->generateFromRoute('user.login', array(), array('query' => $destination)),
- ));
+ return $this->t('<a href=":login">Log in</a> to post comments', [
+ ':login' => $this->urlGenerator->generateFromRoute('user.login', [], ['query' => $destination]),
+ ]);
}
}
return '';
diff --git a/core/modules/comment/src/CommentStatistics.php b/core/modules/comment/src/CommentStatistics.php
index 74061ee6154..3c6b571c26c 100644
--- a/core/modules/comment/src/CommentStatistics.php
+++ b/core/modules/comment/src/CommentStatistics.php
@@ -65,14 +65,14 @@ class CommentStatistics implements CommentStatisticsInterface {
* {@inheritdoc}
*/
public function read($entities, $entity_type, $accurate = TRUE) {
- $options = $accurate ? array() : array('target' => 'replica');
+ $options = $accurate ? [] : ['target' => 'replica'];
$stats = $this->database->select('comment_entity_statistics', 'ces', $options)
->fields('ces')
->condition('ces.entity_id', array_keys($entities), 'IN')
->condition('ces.entity_type', $entity_type)
->execute();
- $statistics_records = array();
+ $statistics_records = [];
while ($entry = $stats->fetchObject()) {
$statistics_records[] = $entry;
}
@@ -94,7 +94,7 @@ class CommentStatistics implements CommentStatisticsInterface {
*/
public function create(FieldableEntityInterface $entity, $fields) {
$query = $this->database->insert('comment_entity_statistics')
- ->fields(array(
+ ->fields([
'entity_id',
'entity_type',
'field_name',
@@ -103,7 +103,7 @@ class CommentStatistics implements CommentStatisticsInterface {
'last_comment_name',
'last_comment_uid',
'comment_count',
- ));
+ ]);
foreach ($fields as $field_name => $detail) {
// Skip fields that entity does not have.
if (!$entity->hasField($field_name)) {
@@ -127,7 +127,7 @@ class CommentStatistics implements CommentStatisticsInterface {
if ($entity instanceof EntityChangedInterface) {
$last_comment_timestamp = $entity->getChangedTimeAcrossTranslations();
}
- $query->values(array(
+ $query->values([
'entity_id' => $entity->id(),
'entity_type' => $entity->getEntityTypeId(),
'field_name' => $field_name,
@@ -136,7 +136,7 @@ class CommentStatistics implements CommentStatisticsInterface {
'last_comment_name' => NULL,
'last_comment_uid' => $last_comment_uid,
'comment_count' => 0,
- ));
+ ]);
}
$query->execute();
}
@@ -145,24 +145,24 @@ class CommentStatistics implements CommentStatisticsInterface {
* {@inheritdoc}
*/
public function getMaximumCount($entity_type) {
- return $this->database->query('SELECT MAX(comment_count) FROM {comment_entity_statistics} WHERE entity_type = :entity_type', array(':entity_type' => $entity_type))->fetchField();
+ return $this->database->query('SELECT MAX(comment_count) FROM {comment_entity_statistics} WHERE entity_type = :entity_type', [':entity_type' => $entity_type])->fetchField();
}
/**
* {@inheritdoc}
*/
public function getRankingInfo() {
- return array(
- 'comments' => array(
+ return [
+ 'comments' => [
'title' => t('Number of comments'),
- 'join' => array(
+ 'join' => [
'type' => 'LEFT',
'table' => 'comment_entity_statistics',
'alias' => 'ces',
// Default to comment field as this is the most common use case for
// nodes.
'on' => "ces.entity_id = i.sid AND ces.entity_type = 'node' AND ces.field_name = 'comment'",
- ),
+ ],
// Inverse law that maps the highest view count on the site to 1 and 0
// to 0. Note that the ROUND here is necessary for PostgreSQL and SQLite
// in order to ensure that the :comment_scale argument is treated as
@@ -170,9 +170,9 @@ class CommentStatistics implements CommentStatisticsInterface {
// values in as strings instead of numbers in complex expressions like
// this.
'score' => '2.0 - 2.0 / (1.0 + ces.comment_count * (ROUND(:comment_scale, 4)))',
- 'arguments' => array(':comment_scale' => \Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0),
- ),
- );
+ 'arguments' => [':comment_scale' => \Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0],
+ ],
+ ];
}
/**
@@ -198,7 +198,7 @@ class CommentStatistics implements CommentStatisticsInterface {
if ($count > 0) {
// Comments exist.
$last_reply = $this->database->select('comment_field_data', 'c')
- ->fields('c', array('cid', 'name', 'changed', 'uid'))
+ ->fields('c', ['cid', 'name', 'changed', 'uid'])
->condition('c.entity_id', $comment->getCommentedEntityId())
->condition('c.entity_type', $comment->getCommentedEntityTypeId())
->condition('c.field_name', $comment->getFieldName())
@@ -210,18 +210,18 @@ class CommentStatistics implements CommentStatisticsInterface {
->fetchObject();
// Use merge here because entity could be created before comment field.
$this->database->merge('comment_entity_statistics')
- ->fields(array(
+ ->fields([
'cid' => $last_reply->cid,
'comment_count' => $count,
'last_comment_timestamp' => $last_reply->changed,
'last_comment_name' => $last_reply->uid ? '' : $last_reply->name,
'last_comment_uid' => $last_reply->uid,
- ))
- ->keys(array(
+ ])
+ ->keys([
'entity_id' => $comment->getCommentedEntityId(),
'entity_type' => $comment->getCommentedEntityTypeId(),
'field_name' => $comment->getFieldName(),
- ))
+ ])
->execute();
}
else {
@@ -238,7 +238,7 @@ class CommentStatistics implements CommentStatisticsInterface {
$last_comment_uid = $this->currentUser->id();
}
$this->database->update('comment_entity_statistics')
- ->fields(array(
+ ->fields([
'cid' => 0,
'comment_count' => 0,
// Use the changed date of the entity if it's set, or default to
@@ -246,7 +246,7 @@ class CommentStatistics implements CommentStatisticsInterface {
'last_comment_timestamp' => ($entity instanceof EntityChangedInterface) ? $entity->getChangedTimeAcrossTranslations() : REQUEST_TIME,
'last_comment_name' => '',
'last_comment_uid' => $last_comment_uid,
- ))
+ ])
->condition('entity_id', $comment->getCommentedEntityId())
->condition('entity_type', $comment->getCommentedEntityTypeId())
->condition('field_name', $comment->getFieldName())
@@ -255,7 +255,7 @@ class CommentStatistics implements CommentStatisticsInterface {
// Reset the cache of the commented entity so that when the entity is loaded
// the next time, the statistics will be loaded again.
- $this->entityManager->getStorage($comment->getCommentedEntityTypeId())->resetCache(array($comment->getCommentedEntityId()));
+ $this->entityManager->getStorage($comment->getCommentedEntityTypeId())->resetCache([$comment->getCommentedEntityId()]);
}
}
diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php
index cc4fdcfc46f..d164d8ad9e9 100644
--- a/core/modules/comment/src/CommentStorage.php
+++ b/core/modules/comment/src/CommentStorage.php
@@ -147,7 +147,7 @@ class CommentStorage extends SqlContentEntityStorage implements CommentStorageIn
// 1. Find all the threads with a new comment.
$unread_threads_query = $this->database->select('comment_field_data', 'comment')
- ->fields('comment', array('thread'))
+ ->fields('comment', ['thread'])
->condition('entity_id', $entity->id())
->condition('entity_type', $entity->getEntityTypeId())
->condition('field_name', $field_name)
@@ -161,7 +161,7 @@ class CommentStorage extends SqlContentEntityStorage implements CommentStorageIn
$first_thread_query = $this->database->select($unread_threads_query, 'thread');
$first_thread_query->addExpression('SUBSTRING(thread, 1, (LENGTH(thread) - 1))', 'torder');
$first_thread = $first_thread_query
- ->fields('thread', array('thread'))
+ ->fields('thread', ['thread'])
->orderBy('torder')
->range(0, 1)
->execute()
@@ -176,13 +176,13 @@ class CommentStorage extends SqlContentEntityStorage implements CommentStorageIn
AND field_name = :field_name
AND status = :status
AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread
- AND default_langcode = 1', array(
+ AND default_langcode = 1', [
':status' => CommentInterface::PUBLISHED,
':entity_id' => $entity->id(),
':field_name' => $field_name,
':entity_type' => $entity->getEntityTypeId(),
':thread' => $first_thread,
- ))->fetchField();
+ ])->fetchField();
}
return $comments_per_page > 0 ? (int) ($count / $comments_per_page) : 0;
@@ -193,7 +193,7 @@ class CommentStorage extends SqlContentEntityStorage implements CommentStorageIn
*/
public function getChildCids(array $comments) {
return $this->database->select('comment_field_data', 'c')
- ->fields('c', array('cid'))
+ ->fields('c', ['cid'])
->condition('pid', array_keys($comments), 'IN')
->condition('default_langcode', 1)
->execute()
@@ -312,7 +312,7 @@ class CommentStorage extends SqlContentEntityStorage implements CommentStorageIn
$cids = $query->execute()->fetchCol();
- $comments = array();
+ $comments = [];
if ($cids) {
$comments = $this->loadMultiple($cids);
}
diff --git a/core/modules/comment/src/CommentStorageSchema.php b/core/modules/comment/src/CommentStorageSchema.php
index ee663c0d0cc..2106a8ec2b8 100644
--- a/core/modules/comment/src/CommentStorageSchema.php
+++ b/core/modules/comment/src/CommentStorageSchema.php
@@ -17,9 +17,9 @@ class CommentStorageSchema extends SqlContentEntityStorageSchema {
protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
$schema = parent::getEntitySchema($entity_type, $reset);
- $schema['comment_field_data']['indexes'] += array(
- 'comment__status_pid' => array('pid', 'status'),
- 'comment__num_new' => array(
+ $schema['comment_field_data']['indexes'] += [
+ 'comment__status_pid' => ['pid', 'status'],
+ 'comment__num_new' => [
'entity_id',
'entity_type',
'comment_type',
@@ -27,14 +27,14 @@ class CommentStorageSchema extends SqlContentEntityStorageSchema {
'created',
'cid',
'thread',
- ),
- 'comment__entity_langcode' => array(
+ ],
+ 'comment__entity_langcode' => [
'entity_id',
'entity_type',
'comment_type',
'default_langcode',
- ),
- );
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/comment/src/CommentTranslationHandler.php b/core/modules/comment/src/CommentTranslationHandler.php
index 98afe3bdbc5..a0abe4b710a 100644
--- a/core/modules/comment/src/CommentTranslationHandler.php
+++ b/core/modules/comment/src/CommentTranslationHandler.php
@@ -30,7 +30,7 @@ class CommentTranslationHandler extends ContentTranslationHandler {
* {@inheritdoc}
*/
protected function entityFormTitle(EntityInterface $entity) {
- return t('Edit comment @subject', array('@subject' => $entity->label()));
+ return t('Edit comment @subject', ['@subject' => $entity->label()]);
}
/**
diff --git a/core/modules/comment/src/CommentTypeForm.php b/core/modules/comment/src/CommentTypeForm.php
index 594726ae62d..9cb147f7f0e 100644
--- a/core/modules/comment/src/CommentTypeForm.php
+++ b/core/modules/comment/src/CommentTypeForm.php
@@ -71,32 +71,32 @@ class CommentTypeForm extends EntityForm {
$comment_type = $this->entity;
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => t('Label'),
'#maxlength' => 255,
'#default_value' => $comment_type->label(),
'#required' => TRUE,
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $comment_type->id(),
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\comment\Entity\CommentType::load',
- ),
+ ],
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
'#disabled' => !$comment_type->isNew(),
- );
+ ];
- $form['description'] = array(
+ $form['description'] = [
'#type' => 'textarea',
'#default_value' => $comment_type->getDescription(),
'#description' => t('Describe this comment type. The text will be displayed on the <em>Comment types</em> administration overview page.'),
'#title' => t('Description'),
- );
+ ];
if ($comment_type->isNew()) {
- $options = array();
+ $options = [];
foreach ($this->entityManager->getDefinitions() as $entity_type) {
// Only expose entities that have field UI enabled, only those can
// get comment fields added in the UI.
@@ -104,47 +104,47 @@ class CommentTypeForm extends EntityForm {
$options[$entity_type->id()] = $entity_type->getLabel();
}
}
- $form['target_entity_type_id'] = array(
+ $form['target_entity_type_id'] = [
'#type' => 'select',
'#default_value' => $comment_type->getTargetEntityTypeId(),
'#title' => t('Target entity type'),
'#options' => $options,
'#description' => t('The target entity type can not be changed after the comment type has been created.')
- );
+ ];
}
else {
- $form['target_entity_type_id_display'] = array(
+ $form['target_entity_type_id_display'] = [
'#type' => 'item',
'#markup' => $this->entityManager->getDefinition($comment_type->getTargetEntityTypeId())->getLabel(),
'#title' => t('Target entity type'),
- );
+ ];
}
if ($this->moduleHandler->moduleExists('content_translation')) {
- $form['language'] = array(
+ $form['language'] = [
'#type' => 'details',
'#title' => t('Language settings'),
'#group' => 'additional_settings',
- );
+ ];
$language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('comment', $comment_type->id());
- $form['language']['language_configuration'] = array(
+ $form['language']['language_configuration'] = [
'#type' => 'language_configuration',
- '#entity_information' => array(
+ '#entity_information' => [
'entity_type' => 'comment',
'bundle' => $comment_type->id(),
- ),
+ ],
'#default_value' => $language_configuration,
- );
+ ];
$form['#submit'][] = 'language_configuration_element_submit';
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
- );
+ ];
return $form;
}
@@ -158,13 +158,13 @@ class CommentTypeForm extends EntityForm {
$edit_link = $this->entity->link($this->t('Edit'));
if ($status == SAVED_UPDATED) {
- drupal_set_message(t('Comment type %label has been updated.', array('%label' => $comment_type->label())));
- $this->logger->notice('Comment type %label has been updated.', array('%label' => $comment_type->label(), 'link' => $edit_link));
+ drupal_set_message(t('Comment type %label has been updated.', ['%label' => $comment_type->label()]));
+ $this->logger->notice('Comment type %label has been updated.', ['%label' => $comment_type->label(), 'link' => $edit_link]);
}
else {
$this->commentManager->addBodyField($comment_type->id());
- drupal_set_message(t('Comment type %label has been added.', array('%label' => $comment_type->label())));
- $this->logger->notice('Comment type %label has been added.', array('%label' => $comment_type->label(), 'link' => $edit_link));
+ drupal_set_message(t('Comment type %label has been added.', ['%label' => $comment_type->label()]));
+ $this->logger->notice('Comment type %label has been added.', ['%label' => $comment_type->label(), 'link' => $edit_link]);
}
$form_state->setRedirectUrl($comment_type->urlInfo('collection'));
diff --git a/core/modules/comment/src/CommentViewBuilder.php b/core/modules/comment/src/CommentViewBuilder.php
index 5771ed5064c..ec6d49a5b07 100644
--- a/core/modules/comment/src/CommentViewBuilder.php
+++ b/core/modules/comment/src/CommentViewBuilder.php
@@ -88,7 +88,7 @@ class CommentViewBuilder extends EntityViewBuilder {
}
// Pre-load associated users into cache to leverage multiple loading.
- $uids = array();
+ $uids = [];
foreach ($entities as $entity) {
$uids[] = $entity->getOwnerId();
}
@@ -125,7 +125,7 @@ class CommentViewBuilder extends EntityViewBuilder {
$display = $displays[$entity->bundle()];
if ($display->getComponent('links')) {
- $build[$id]['links'] = array(
+ $build[$id]['links'] = [
'#lazy_builder' => ['comment.lazy_builders:renderLinks', [
$entity->id(),
$view_mode,
@@ -133,11 +133,11 @@ class CommentViewBuilder extends EntityViewBuilder {
!empty($entity->in_preview),
]],
'#create_placeholder' => TRUE,
- );
+ ];
}
if (!isset($build[$id]['#attached'])) {
- $build[$id]['#attached'] = array();
+ $build[$id]['#attached'] = [];
}
$build[$id]['#attached']['library'][] = 'comment/drupal.comment-by-viewer';
if ($this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated()) {
diff --git a/core/modules/comment/src/CommentViewsData.php b/core/modules/comment/src/CommentViewsData.php
index e4ca5b02595..52af015d59c 100644
--- a/core/modules/comment/src/CommentViewsData.php
+++ b/core/modules/comment/src/CommentViewsData.php
@@ -36,148 +36,148 @@ class CommentViewsData extends EntityViewsData {
$data['comment_field_data']['created']['title'] = $this->t('Post date');
$data['comment_field_data']['created']['help'] = $this->t('Date and time of when the comment was created.');
- $data['comment_field_data']['created_fulldata'] = array(
+ $data['comment_field_data']['created_fulldata'] = [
'title' => $this->t('Created date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['created_year_month'] = array(
+ $data['comment_field_data']['created_year_month'] = [
'title' => $this->t('Created year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['created_year'] = array(
+ $data['comment_field_data']['created_year'] = [
'title' => $this->t('Created year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['created_month'] = array(
+ $data['comment_field_data']['created_month'] = [
'title' => $this->t('Created month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['created_day'] = array(
+ $data['comment_field_data']['created_day'] = [
'title' => $this->t('Created day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['created_week'] = array(
+ $data['comment_field_data']['created_week'] = [
'title' => $this->t('Created week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
$data['comment_field_data']['changed']['title'] = $this->t('Updated date');
$data['comment_field_data']['changed']['help'] = $this->t('Date and time of when the comment was last updated.');
- $data['comment_field_data']['changed_fulldata'] = array(
+ $data['comment_field_data']['changed_fulldata'] = [
'title' => $this->t('Changed date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['changed_year_month'] = array(
+ $data['comment_field_data']['changed_year_month'] = [
'title' => $this->t('Changed year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['changed_year'] = array(
+ $data['comment_field_data']['changed_year'] = [
'title' => $this->t('Changed year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['changed_month'] = array(
+ $data['comment_field_data']['changed_month'] = [
'title' => $this->t('Changed month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['changed_day'] = array(
+ $data['comment_field_data']['changed_day'] = [
'title' => $this->t('Changed day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['changed_week'] = array(
+ $data['comment_field_data']['changed_week'] = [
'title' => $this->t('Changed week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
$data['comment_field_data']['status']['title'] = $this->t('Approved status');
$data['comment_field_data']['status']['help'] = $this->t('Whether the comment is approved (or still in the moderation queue).');
$data['comment_field_data']['status']['filter']['label'] = $this->t('Approved comment status');
$data['comment_field_data']['status']['filter']['type'] = 'yes-no';
- $data['comment']['approve_comment'] = array(
- 'field' => array(
+ $data['comment']['approve_comment'] = [
+ 'field' => [
'title' => $this->t('Link to approve comment'),
'help' => $this->t('Provide a simple link to approve the comment.'),
'id' => 'comment_link_approve',
- ),
- );
+ ],
+ ];
- $data['comment']['replyto_comment'] = array(
- 'field' => array(
+ $data['comment']['replyto_comment'] = [
+ 'field' => [
'title' => $this->t('Link to reply-to comment'),
'help' => $this->t('Provide a simple link to reply to the comment.'),
'id' => 'comment_link_reply',
- ),
- );
+ ],
+ ];
- $data['comment_field_data']['thread']['field'] = array(
+ $data['comment_field_data']['thread']['field'] = [
'title' => $this->t('Depth'),
'help' => $this->t('Display the depth of the comment if it is threaded.'),
'id' => 'comment_depth',
- );
- $data['comment_field_data']['thread']['sort'] = array(
+ ];
+ $data['comment_field_data']['thread']['sort'] = [
'title' => $this->t('Thread'),
'help' => $this->t('Sort by the threaded order. This will keep child comments together with their parents.'),
'id' => 'comment_thread',
- );
+ ];
unset($data['comment_field_data']['thread']['filter']);
unset($data['comment_field_data']['thread']['argument']);
@@ -189,24 +189,24 @@ class CommentViewsData extends EntityViewsData {
continue;
}
if ($fields = \Drupal::service('comment.manager')->getFields($type)) {
- $data['comment_field_data'][$type] = array(
- 'relationship' => array(
+ $data['comment_field_data'][$type] = [
+ 'relationship' => [
'title' => $entity_type->getLabel(),
- 'help' => $this->t('The @entity_type to which the comment is a reply to.', array('@entity_type' => $entity_type->getLabel())),
+ 'help' => $this->t('The @entity_type to which the comment is a reply to.', ['@entity_type' => $entity_type->getLabel()]),
'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(),
'base field' => $entity_type->getKey('id'),
'relationship field' => 'entity_id',
'id' => 'standard',
'label' => $entity_type->getLabel(),
- 'extra' => array(
- array(
+ 'extra' => [
+ [
'field' => 'entity_type',
'value' => $type,
'table' => 'comment_field_data'
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
}
}
@@ -237,84 +237,84 @@ class CommentViewsData extends EntityViewsData {
// {comment_entity_statistics} for each field as multiple joins between
// the same two tables is not supported.
if (\Drupal::service('comment.manager')->getFields($type)) {
- $data['comment_entity_statistics']['table']['join'][$entity_type->getDataTable() ?: $entity_type->getBaseTable()] = array(
+ $data['comment_entity_statistics']['table']['join'][$entity_type->getDataTable() ?: $entity_type->getBaseTable()] = [
'type' => 'INNER',
'left_field' => $entity_type->getKey('id'),
'field' => 'entity_id',
- 'extra' => array(
- array(
+ 'extra' => [
+ [
'field' => 'entity_type',
'value' => $type,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
- $data['comment_entity_statistics']['last_comment_timestamp'] = array(
+ $data['comment_entity_statistics']['last_comment_timestamp'] = [
'title' => $this->t('Last comment time'),
'help' => $this->t('Date and time of when the last comment was posted.'),
- 'field' => array(
+ 'field' => [
'id' => 'comment_last_timestamp',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'date',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- );
+ ],
+ ];
- $data['comment_entity_statistics']['last_comment_name'] = array(
+ $data['comment_entity_statistics']['last_comment_name'] = [
'title' => $this->t("Last comment author"),
'help' => $this->t('The name of the author of the last posted comment.'),
- 'field' => array(
+ 'field' => [
'id' => 'comment_ces_last_comment_name',
'no group by' => TRUE,
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'comment_ces_last_comment_name',
'no group by' => TRUE,
- ),
- );
+ ],
+ ];
- $data['comment_entity_statistics']['comment_count'] = array(
+ $data['comment_entity_statistics']['comment_count'] = [
'title' => $this->t('Comment count'),
'help' => $this->t('The number of comments an entity has.'),
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['comment_entity_statistics']['last_updated'] = array(
+ $data['comment_entity_statistics']['last_updated'] = [
'title' => $this->t('Updated/commented date'),
'help' => $this->t('The most recent of last comment posted or entity updated time.'),
- 'field' => array(
+ 'field' => [
'id' => 'comment_ces_last_updated',
'no group by' => TRUE,
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'comment_ces_last_updated',
'no group by' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'comment_ces_last_updated',
- ),
- );
+ ],
+ ];
- $data['comment_entity_statistics']['cid'] = array(
+ $data['comment_entity_statistics']['cid'] = [
'title' => $this->t('Last comment CID'),
'help' => $this->t('Display the last comment of an entity'),
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('Last comment'),
'help' => $this->t('The last comment of an entity.'),
'group' => $this->t('Comment'),
@@ -322,62 +322,62 @@ class CommentViewsData extends EntityViewsData {
'base field' => 'cid',
'id' => 'standard',
'label' => $this->t('Last Comment'),
- ),
- );
+ ],
+ ];
- $data['comment_entity_statistics']['last_comment_uid'] = array(
+ $data['comment_entity_statistics']['last_comment_uid'] = [
'title' => $this->t('Last comment uid'),
'help' => $this->t('The User ID of the author of the last comment of an entity.'),
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('Last comment author'),
'base' => 'users',
'base field' => 'uid',
'id' => 'standard',
'label' => $this->t('Last comment author'),
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'field' => array(
+ ],
+ 'field' => [
'id' => 'numeric',
- ),
- );
+ ],
+ ];
- $data['comment_entity_statistics']['entity_type'] = array(
+ $data['comment_entity_statistics']['entity_type'] = [
'title' => $this->t('Entity type'),
'help' => $this->t('The entity type to which the comment is a reply to.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['comment_entity_statistics']['field_name'] = array(
+ ],
+ ];
+ $data['comment_entity_statistics']['field_name'] = [
'title' => $this->t('Comment field name'),
'help' => $this->t('The field name from which the comment originated.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/comment/src/Controller/CommentController.php b/core/modules/comment/src/Controller/CommentController.php
index 5f1b504b634..c834fa67a1c 100644
--- a/core/modules/comment/src/Controller/CommentController.php
+++ b/core/modules/comment/src/Controller/CommentController.php
@@ -125,7 +125,7 @@ class CommentController extends ControllerBase {
$page = $this->entityManager()->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page'));
// @todo: Cleaner sub request handling.
$subrequest_url = $entity->urlInfo()->setOption('query', ['page' => $page])->toString(TRUE);
- $redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all());
+ $redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), [], $request->server->all());
// Carry over the session to the subrequest.
if ($session = $request->getSession()) {
$redirect_request->setSession($session);
@@ -174,11 +174,11 @@ class CommentController extends ControllerBase {
// Legacy nodes only had a single comment field, so use the first comment
// field on the entity.
if (!empty($fields) && ($field_names = array_keys($fields)) && ($field_name = reset($field_names))) {
- return $this->redirect('comment.reply', array(
+ return $this->redirect('comment.reply', [
'entity_type' => 'node',
'entity' => $node->id(),
'field_name' => $field_name,
- ));
+ ]);
}
throw new NotFoundHttpException();
}
@@ -211,7 +211,7 @@ class CommentController extends ControllerBase {
*/
public function getReplyForm(Request $request, EntityInterface $entity, $field_name, $pid = NULL) {
$account = $this->currentUser();
- $build = array();
+ $build = [];
// The user is not just previewing a comment.
if ($request->request->get('op') != $this->t('Preview')) {
@@ -240,12 +240,12 @@ class CommentController extends ControllerBase {
}
// Show the actual reply box.
- $comment = $this->entityManager()->getStorage('comment')->create(array(
+ $comment = $this->entityManager()->getStorage('comment')->create([
'entity_id' => $entity->id(),
'pid' => $pid,
'entity_type' => $entity->getEntityTypeId(),
'field_name' => $field_name,
- ));
+ ]);
$build['comment_form'] = $this->entityFormBuilder()->getForm($comment);
return $build;
@@ -324,17 +324,17 @@ class CommentController extends ControllerBase {
// Only handle up to 100 nodes.
$nids = array_slice($nids, 0, 100);
- $links = array();
+ $links = [];
foreach ($nids as $nid) {
$node = $this->entityManager->getStorage('node')->load($nid);
$new = $this->commentManager->getCountNewComments($node);
$page_number = $this->entityManager()->getStorage('comment')
->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node, $field_name);
- $query = $page_number ? array('page' => $page_number) : NULL;
- $links[$nid] = array(
+ $query = $page_number ? ['page' => $page_number] : NULL;
+ $links[$nid] = [
'new_comment_count' => (int) $new,
- 'first_new_comment_link' => $this->getUrlGenerator()->generateFromRoute('entity.node.canonical', array('node' => $node->id()), array('query' => $query, 'fragment' => 'new')),
- );
+ 'first_new_comment_link' => $this->getUrlGenerator()->generateFromRoute('entity.node.canonical', ['node' => $node->id()], ['query' => $query, 'fragment' => 'new']),
+ ];
}
return new JsonResponse($links);
diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php
index d52f04dcbb9..83dffaa9e53 100644
--- a/core/modules/comment/src/Entity/Comment.php
+++ b/core/modules/comment/src/Entity/Comment.php
@@ -249,11 +249,11 @@ class Comment extends ContentEntityBase implements CommentInterface {
->setLabel(t('Subject'))
->setTranslatable(TRUE)
->setSetting('max_length', 64)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
// Default comment body field has weight 20.
'weight' => 10,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
@@ -328,7 +328,7 @@ class Comment extends ContentEntityBase implements CommentInterface {
$fields['entity_id']->setSetting('target_type', $comment_type->getTargetEntityTypeId());
return $fields;
}
- return array();
+ return [];
}
/**
diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php
index 3966fca1bfc..24f8b0aa2e6 100644
--- a/core/modules/comment/src/Form/CommentAdminOverview.php
+++ b/core/modules/comment/src/Form/CommentAdminOverview.php
@@ -99,12 +99,12 @@ class CommentAdminOverview extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state, $type = 'new') {
// Build an 'Update options' form.
- $form['options'] = array(
+ $form['options'] = [
'#type' => 'details',
'#title' => $this->t('Update options'),
'#open' => TRUE,
- '#attributes' => array('class' => array('container-inline')),
- );
+ '#attributes' => ['class' => ['container-inline']],
+ ];
if ($type == 'approval') {
$options['publish'] = $this->t('Publish the selected comments');
@@ -114,42 +114,42 @@ class CommentAdminOverview extends FormBase {
}
$options['delete'] = $this->t('Delete the selected comments');
- $form['options']['operation'] = array(
+ $form['options']['operation'] = [
'#type' => 'select',
'#title' => $this->t('Action'),
'#title_display' => 'invisible',
'#options' => $options,
'#default_value' => 'publish',
- );
- $form['options']['submit'] = array(
+ ];
+ $form['options']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Update'),
- );
+ ];
// Load the comments that need to be displayed.
$status = ($type == 'approval') ? CommentInterface::NOT_PUBLISHED : CommentInterface::PUBLISHED;
- $header = array(
- 'subject' => array(
+ $header = [
+ 'subject' => [
'data' => $this->t('Subject'),
'specifier' => 'subject',
- ),
- 'author' => array(
+ ],
+ 'author' => [
'data' => $this->t('Author'),
'specifier' => 'name',
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
- ),
- 'posted_in' => array(
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+ ],
+ 'posted_in' => [
'data' => $this->t('Posted in'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
- 'changed' => array(
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
+ 'changed' => [
'data' => $this->t('Updated'),
'specifier' => 'changed',
'sort' => 'desc',
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
'operations' => $this->t('Operations'),
- );
+ ];
$cids = $this->commentStorage->getQuery()
->condition('status', $status)
->tableSort($header)
@@ -160,11 +160,11 @@ class CommentAdminOverview extends FormBase {
$comments = $this->commentStorage->loadMultiple($cids);
// Build a table listing the appropriate comments.
- $options = array();
+ $options = [];
$destination = $this->getDestinationArray();
- $commented_entity_ids = array();
- $commented_entities = array();
+ $commented_entity_ids = [];
+ $commented_entities = [];
foreach ($comments as $comment) {
$commented_entity_ids[$comment->getCommentedEntityTypeId()][] = $comment->getCommentedEntityId();
@@ -179,61 +179,61 @@ class CommentAdminOverview extends FormBase {
$commented_entity = $commented_entities[$comment->getCommentedEntityTypeId()][$comment->getCommentedEntityId()];
$comment_permalink = $comment->permalink();
if ($comment->hasField('comment_body') && ($body = $comment->get('comment_body')->value)) {
- $attributes = $comment_permalink->getOption('attributes') ?: array();
- $attributes += array('title' => Unicode::truncate($body, 128));
+ $attributes = $comment_permalink->getOption('attributes') ?: [];
+ $attributes += ['title' => Unicode::truncate($body, 128)];
$comment_permalink->setOption('attributes', $attributes);
}
- $options[$comment->id()] = array(
- 'title' => array('data' => array('#title' => $comment->getSubject() ?: $comment->id())),
- 'subject' => array(
- 'data' => array(
+ $options[$comment->id()] = [
+ 'title' => ['data' => ['#title' => $comment->getSubject() ?: $comment->id()]],
+ 'subject' => [
+ 'data' => [
'#type' => 'link',
'#title' => $comment->getSubject(),
'#url' => $comment_permalink,
- ),
- ),
- 'author' => array(
- 'data' => array(
+ ],
+ ],
+ 'author' => [
+ 'data' => [
'#theme' => 'username',
'#account' => $comment->getOwner(),
- ),
- ),
- 'posted_in' => array(
- 'data' => array(
+ ],
+ ],
+ 'posted_in' => [
+ 'data' => [
'#type' => 'link',
'#title' => $commented_entity->label(),
'#access' => $commented_entity->access('view'),
'#url' => $commented_entity->urlInfo(),
- ),
- ),
+ ],
+ ],
'changed' => $this->dateFormatter->format($comment->getChangedTimeAcrossTranslations(), 'short'),
- );
+ ];
$comment_uri_options = $comment->urlInfo()->getOptions() + ['query' => $destination];
- $links = array();
- $links['edit'] = array(
+ $links = [];
+ $links['edit'] = [
'title' => $this->t('Edit'),
'url' => $comment->urlInfo('edit-form', $comment_uri_options),
- );
- if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', array($comment))->isAllowed()) {
- $links['translate'] = array(
+ ];
+ if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', [$comment])->isAllowed()) {
+ $links['translate'] = [
'title' => $this->t('Translate'),
'url' => $comment->urlInfo('drupal:content-translation-overview', $comment_uri_options),
- );
+ ];
}
- $options[$comment->id()]['operations']['data'] = array(
+ $options[$comment->id()]['operations']['data'] = [
'#type' => 'operations',
'#links' => $links,
- );
+ ];
}
- $form['comments'] = array(
+ $form['comments'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => $this->t('No comments available.'),
- );
+ ];
- $form['pager'] = array('#type' => 'pager');
+ $form['pager'] = ['#type' => 'pager'];
return $form;
}
@@ -242,7 +242,7 @@ class CommentAdminOverview extends FormBase {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
- $form_state->setValue('comments', array_diff($form_state->getValue('comments'), array(0)));
+ $form_state->setValue('comments', array_diff($form_state->getValue('comments'), [0]));
// We can't execute any 'Update options' if no comments were selected.
if (count($form_state->getValue('comments')) == 0) {
$form_state->setErrorByName('', $this->t('Select one or more comments to perform the update on.'));
diff --git a/core/modules/comment/src/Form/CommentTypeDeleteForm.php b/core/modules/comment/src/Form/CommentTypeDeleteForm.php
index 8c3da7a20ee..30181c1d9b8 100644
--- a/core/modules/comment/src/Form/CommentTypeDeleteForm.php
+++ b/core/modules/comment/src/Form/CommentTypeDeleteForm.php
@@ -82,18 +82,18 @@ class CommentTypeDeleteForm extends EntityDeleteForm {
foreach (array_keys($this->commentManager->getFields($entity_type)) as $field_name) {
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') == $this->entity->id() && !$field_storage->isDeleted()) {
- $caption .= '<p>' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array(
+ $caption .= '<p>' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [
'%label' => $this->entity->label(),
'%field' => $field_storage->label(),
- )) . '</p>';
+ ]) . '</p>';
}
}
if (!empty($comments)) {
- $caption .= '<p>' . $this->formatPlural(count($comments), '%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', '%label is used by @count comments on your site. You may not remove %label until you have removed all of the %label comments.', array('%label' => $this->entity->label())) . '</p>';
+ $caption .= '<p>' . $this->formatPlural(count($comments), '%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', '%label is used by @count comments on your site. You may not remove %label until you have removed all of the %label comments.', ['%label' => $this->entity->label()]) . '</p>';
}
if ($caption) {
- $form['description'] = array('#markup' => $caption);
+ $form['description'] = ['#markup' => $caption];
return $form;
}
else {
diff --git a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php
index c66e428e92b..59062483163 100644
--- a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php
+++ b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php
@@ -81,25 +81,25 @@ class ConfirmDeleteMultiple extends ConfirmFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$edit = $form_state->getUserInput();
- $form['comments'] = array(
+ $form['comments'] = [
'#prefix' => '<ul>',
'#suffix' => '</ul>',
'#tree' => TRUE,
- );
+ ];
// array_filter() returns only elements with actual values.
$comment_counter = 0;
$this->comments = $this->commentStorage->loadMultiple(array_keys(array_filter($edit['comments'])));
foreach ($this->comments as $comment) {
$cid = $comment->id();
- $form['comments'][$cid] = array(
+ $form['comments'][$cid] = [
'#type' => 'hidden',
'#value' => $cid,
'#prefix' => '<li>',
'#suffix' => Html::escape($comment->label()) . '</li>'
- );
+ ];
$comment_counter++;
}
- $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
+ $form['operation'] = ['#type' => 'hidden', '#value' => 'delete'];
if (!$comment_counter) {
drupal_set_message($this->t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.'));
@@ -116,7 +116,7 @@ class ConfirmDeleteMultiple extends ConfirmFormBase {
if ($form_state->getValue('confirm')) {
$this->commentStorage->delete($this->comments);
$count = count($form_state->getValue('comments'));
- $this->logger('comment')->notice('Deleted @count comments.', array('@count' => $count));
+ $this->logger('comment')->notice('Deleted @count comments.', ['@count' => $count]);
drupal_set_message($this->formatPlural($count, 'Deleted 1 comment.', 'Deleted @count comments.'));
}
$form_state->setRedirectUrl($this->getCancelUrl());
diff --git a/core/modules/comment/src/Form/DeleteForm.php b/core/modules/comment/src/Form/DeleteForm.php
index 285abe58ef0..fa7ab9d2070 100644
--- a/core/modules/comment/src/Form/DeleteForm.php
+++ b/core/modules/comment/src/Form/DeleteForm.php
@@ -42,7 +42,7 @@ class DeleteForm extends ContentEntityDeleteForm {
* {@inheritdoc}
*/
public function logDeletionMessage() {
- $this->logger('comment')->notice('Deleted comment @cid and its replies.', array('@cid' => $this->entity->id()));
+ $this->logger('comment')->notice('Deleted comment @cid and its replies.', ['@cid' => $this->entity->id()]);
}
}
diff --git a/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php
index cacac89f660..ec1b268d7bd 100644
--- a/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php
+++ b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php
@@ -89,21 +89,21 @@ class UnpublishByKeywordComment extends ConfigurableActionBase implements Contai
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
- 'keywords' => array(),
- );
+ return [
+ 'keywords' => [],
+ ];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['keywords'] = array(
+ $form['keywords'] = [
'#title' => $this->t('Keywords'),
'#type' => 'textarea',
'#description' => $this->t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
'#default_value' => Tags::implode($this->configuration['keywords']),
- );
+ ];
return $form;
}
diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php
index 43542a0eb57..3e22ede6e36 100644
--- a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php
+++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php
@@ -24,19 +24,19 @@ class AuthorNameFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
/** @var $comment \Drupal\comment\CommentInterface */
$comment = $item->getEntity();
$account = $comment->getOwner();
- $elements[$delta] = array(
+ $elements[$delta] = [
'#theme' => 'username',
'#account' => $account,
- '#cache' => array(
+ '#cache' => [
'tags' => $account->getCacheTags() + $comment->getCacheTags(),
- ),
- );
+ ],
+ ];
}
return $elements;
diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
index c7d9bba85fb..b03accc4893 100644
--- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
+++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
@@ -36,10 +36,10 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'view_mode' => 'default',
'pager_id' => 0,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -141,8 +141,8 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
- $output = array();
+ $elements = [];
+ $output = [];
$field_name = $this->fieldDefinition->getName();
$entity = $items->getEntity();
@@ -153,7 +153,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
// Comments are added to the search results and search index by
// comment_node_update_index() instead of by this formatter, so don't
// return anything if the view mode is search_index or search_result.
- !in_array($this->viewMode, array('search_result', 'search_index'))) {
+ !in_array($this->viewMode, ['search_result', 'search_index'])) {
$comment_settings = $this->getFieldSettings();
// Only attempt to render comments if the entity has visible comments.
@@ -203,12 +203,12 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
}
}
- $elements[] = $output + array(
+ $elements[] = $output + [
'#comment_type' => $this->getFieldSetting('comment_type'),
'#comment_display_mode' => $this->getFieldSetting('default_mode'),
- 'comments' => array(),
- 'comment_form' => array(),
- );
+ 'comments' => [],
+ 'comment_form' => [],
+ ];
}
return $elements;
@@ -218,7 +218,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element = array();
+ $element = [];
$view_modes = $this->getViewModes();
$element['view_mode'] = [
'#type' => 'select',
@@ -229,13 +229,13 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
// Only show the select element when there are more than one options.
'#access' => count($view_modes) > 1,
];
- $element['pager_id'] = array(
+ $element['pager_id'] = [
'#type' => 'select',
'#title' => $this->t('Pager ID'),
'#options' => range(0, 10),
'#default_value' => $this->getSetting('pager_id'),
'#description' => $this->t("Unless you're experiencing problems with pagers related to this field, you should leave this at 0. If using multiple pagers on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add a lot of commas to your URLs, so avoid if possible."),
- );
+ ];
return $element;
}
diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
index 888b64b255c..e3fd2b060eb 100644
--- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
+++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
@@ -31,22 +31,22 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'comment_type' => '',
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'default_mode' => CommentManagerInterface::COMMENT_MODE_THREADED,
'per_page' => 50,
'form_location' => CommentItemInterface::FORM_BELOW,
'anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT,
'preview' => DRUPAL_OPTIONAL,
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
@@ -82,36 +82,36 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'status' => array(
+ return [
+ 'columns' => [
+ 'status' => [
'description' => 'Whether comments are allowed on this entity: 0 = no, 1 = closed (read only), 2 = open (read/write).',
'type' => 'int',
'default' => 0,
- ),
- ),
- 'indexes' => array(),
- 'foreign keys' => array(),
- );
+ ],
+ ],
+ 'indexes' => [],
+ 'foreign keys' => [],
+ ];
}
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- $element = array();
+ $element = [];
$settings = $this->getSettings();
$anonymous_user = new AnonymousUserSession();
- $element['default_mode'] = array(
+ $element['default_mode'] = [
'#type' => 'checkbox',
'#title' => t('Threading'),
'#default_value' => $settings['default_mode'],
'#description' => t('Show comment replies in a threaded list.'),
- );
- $element['per_page'] = array(
+ ];
+ $element['per_page'] = [
'#type' => 'number',
'#title' => t('Comments per page'),
'#default_value' => $settings['per_page'],
@@ -119,33 +119,33 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
'#min' => 10,
'#max' => 1000,
'#step' => 10,
- );
- $element['anonymous'] = array(
+ ];
+ $element['anonymous'] = [
'#type' => 'select',
'#title' => t('Anonymous commenting'),
'#default_value' => $settings['anonymous'],
- '#options' => array(
+ '#options' => [
COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
- ),
+ ],
'#access' => $anonymous_user->hasPermission('post comments'),
- );
- $element['form_location'] = array(
+ ];
+ $element['form_location'] = [
'#type' => 'checkbox',
'#title' => t('Show reply form on the same page as comments'),
'#default_value' => $settings['form_location'],
- );
- $element['preview'] = array(
+ ];
+ $element['preview'] = [
'#type' => 'radios',
'#title' => t('Preview comment'),
'#default_value' => $settings['preview'],
- '#options' => array(
+ '#options' => [
DRUPAL_DISABLED => t('Disabled'),
DRUPAL_OPTIONAL => t('Optional'),
DRUPAL_REQUIRED => t('Required'),
- ),
- );
+ ],
+ ];
return $element;
}
@@ -171,27 +171,27 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element = array();
+ $element = [];
// @todo Inject entity storage once typed-data supports container injection.
// See https://www.drupal.org/node/2053415 for more details.
$comment_types = CommentType::loadMultiple();
- $options = array();
+ $options = [];
$entity_type = $this->getEntity()->getEntityTypeId();
foreach ($comment_types as $comment_type) {
if ($comment_type->getTargetEntityTypeId() == $entity_type) {
$options[$comment_type->id()] = $comment_type->label();
}
}
- $element['comment_type'] = array(
+ $element['comment_type'] = [
'#type' => 'select',
'#title' => t('Comment type'),
'#options' => $options,
'#required' => TRUE,
- '#description' => $this->t('Select the Comment type to use for this comment field. Manage the comment types from the <a href=":url">administration overview page</a>.', array(':url' => $this->url('entity.comment_type.collection'))),
+ '#description' => $this->t('Select the Comment type to use for this comment field. Manage the comment types from the <a href=":url">administration overview page</a>.', [':url' => $this->url('entity.comment_type.collection')]),
'#default_value' => $this->getSetting('comment_type'),
'#disabled' => $has_data,
- );
+ ];
return $element;
}
diff --git a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php
index 818226d053a..c9478f622c2 100644
--- a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php
+++ b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php
@@ -27,26 +27,26 @@ class CommentWidget extends WidgetBase {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$entity = $items->getEntity();
- $element['status'] = array(
+ $element['status'] = [
'#type' => 'radios',
'#title' => t('Comments'),
'#title_display' => 'invisible',
'#default_value' => $items->status,
- '#options' => array(
+ '#options' => [
CommentItemInterface::OPEN => t('Open'),
CommentItemInterface::CLOSED => t('Closed'),
CommentItemInterface::HIDDEN => t('Hidden'),
- ),
- CommentItemInterface::OPEN => array(
+ ],
+ CommentItemInterface::OPEN => [
'#description' => t('Users with the "Post comments" permission can post comments.'),
- ),
- CommentItemInterface::CLOSED => array(
+ ],
+ CommentItemInterface::CLOSED => [
'#description' => t('Users cannot post comments, but existing comments will be displayed.'),
- ),
- CommentItemInterface::HIDDEN => array(
+ ],
+ CommentItemInterface::HIDDEN => [
'#description' => t('Comments are hidden from view.'),
- ),
- );
+ ],
+ ];
// If the entity doesn't have any comments, the "hidden" option makes no
// sense, so don't even bother presenting it to the user unless this is the
// default value widget on the field settings form.
@@ -65,19 +65,19 @@ class CommentWidget extends WidgetBase {
// Override widget title to be helpful for end users.
$element['#title'] = $this->t('Comment settings');
- $element += array(
+ $element += [
'#type' => 'details',
// Open the details when the selected value is different to the stored
// default values for the field.
'#open' => ($items->status != $field_default_values[0]['status']),
'#group' => 'advanced',
- '#attributes' => array(
- 'class' => array('comment-' . Html::getClass($entity->getEntityTypeId()) . '-settings-form'),
- ),
- '#attached' => array(
- 'library' => array('comment/drupal.comment'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['comment-' . Html::getClass($entity->getEntityTypeId()) . '-settings-form'],
+ ],
+ '#attached' => [
+ 'library' => ['comment/drupal.comment'],
+ ],
+ ];
}
return $element;
@@ -90,13 +90,13 @@ class CommentWidget extends WidgetBase {
// Add default values for statistics properties because we don't want to
// have them in form.
foreach ($values as &$value) {
- $value += array(
+ $value += [
'cid' => 0,
'last_comment_timestamp' => 0,
'last_comment_name' => '',
'last_comment_uid' => 0,
'comment_count' => 0,
- );
+ ];
}
return $values;
}
diff --git a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
index 5fa01936519..89542d34ff3 100644
--- a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
+++ b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
@@ -54,7 +54,7 @@ class UnapprovedComments extends LocalTaskDefault implements ContainerFactoryPlu
* {@inheritdoc}
*/
public function getTitle() {
- return $this->t('Unapproved comments (@count)', array('@count' => $this->commentStorage->getUnapprovedCount()));
+ return $this->t('Unapproved comments (@count)', ['@count' => $this->commentStorage->getUnapprovedCount()]);
}
}
diff --git a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php
index f06dfd83831..87cdaf91ded 100644
--- a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php
+++ b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php
@@ -55,9 +55,9 @@ class CommentNameConstraintValidator extends ConstraintValidator implements Cont
// Do not allow unauthenticated comment authors to use a name that is
// taken by a registered user.
if (isset($author_name) && $author_name !== '' && $owner_id === 0) {
- $users = $this->userStorage->loadByProperties(array('name' => $author_name));
+ $users = $this->userStorage->loadByProperties(['name' => $author_name]);
if (!empty($users)) {
- $this->context->buildViolation($constraint->messageNameTaken, array('%name' => $author_name))
+ $this->context->buildViolation($constraint->messageNameTaken, ['%name' => $author_name])
->atPath('name')
->addViolation();
}
diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
index a3e82af61b1..efce666a77f 100644
--- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
+++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
@@ -80,7 +80,7 @@ class EntityComment extends EntityContentBase {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
if ($row->isStub() && ($state = $this->state->get('comment.maintain_entity_statistics', 0))) {
$this->state->set('comment.maintain_entity_statistics', 0);
}
diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php b/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php
index b014af3fad6..9bee87a3a1d 100644
--- a/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php
+++ b/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php
@@ -15,7 +15,7 @@ class EntityCommentType extends EntityConfigBase {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$entity_ids = parent::import($row, $old_destination_id_values);
\Drupal::service('comment.manager')->addBodyField(reset($entity_ids));
return $entity_ids;
diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
index 6081f39f91f..93f77a0e3f5 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
@@ -20,11 +20,11 @@ class Comment extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('comments', 'c')
- ->fields('c', array('cid', 'pid', 'nid', 'uid', 'subject',
+ ->fields('c', ['cid', 'pid', 'nid', 'uid', 'subject',
'comment', 'hostname', 'timestamp', 'status', 'thread', 'name',
- 'mail', 'homepage', 'format'));
+ 'mail', 'homepage', 'format']);
$query->innerJoin('node', 'n', 'c.nid = n.nid');
- $query->fields('n', array('type'));
+ $query->fields('n', ['type']);
$query->orderBy('c.timestamp');
return $query;
}
@@ -52,7 +52,7 @@ class Comment extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'cid' => $this->t('Comment ID.'),
'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'),
'nid' => $this->t('The {node}.nid to which this comment is a reply.'),
@@ -68,7 +68,7 @@ class Comment extends DrupalSqlBase {
'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
'type' => $this->t("The {node}.type to which this comment is a reply."),
- );
+ ];
}
/**
diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
index 3294721381f..a56fb4dc218 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
@@ -35,7 +35,7 @@ class CommentVariable extends DrupalSqlBase {
*/
protected function getCommentVariables() {
$comment_prefixes = array_keys($this->commentPrefixes());
- $variables = array();
+ $variables = [];
$node_types = $this->select('node_type', 'nt')
->fields('nt', ['type'])
->execute()
@@ -45,7 +45,7 @@ class CommentVariable extends DrupalSqlBase {
$variables[] = $prefix . '_' . $node_type;
}
}
- $return = array();
+ $return = [];
$values = $this->select('variable', 'v')
->fields('v', ['name', 'value'])
->condition('name', $variables, 'IN')
@@ -74,17 +74,17 @@ class CommentVariable extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return $this->commentPrefixes() + array(
+ return $this->commentPrefixes() + [
'node_type' => $this->t('The node type'),
'comment_type' => $this->t('The comment type'),
- );
+ ];
}
/**
* Comment related data for fields.
*/
protected function commentPrefixes() {
- return array(
+ return [
'comment' => $this->t('Default comment setting'),
'comment_default_mode' => $this->t('Default display mode'),
'comment_default_order' => $this->t('Default display order'),
@@ -94,7 +94,7 @@ class CommentVariable extends DrupalSqlBase {
'comment_subject_field' => $this->t('Comment subject field'),
'comment_preview' => $this->t('Preview comment'),
'comment_form_location' => $this->t('Location of comment submission form'),
- );
+ ];
}
/**
diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
index 5d16ed0297f..0eea68608cf 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
@@ -17,24 +17,24 @@ class CommentVariablePerCommentType extends CommentVariable {
protected function getCommentVariables() {
$node_types = parent::getCommentVariables();
// The return key used to separate comment types with hidden subject field.
- $return = array();
+ $return = [];
foreach ($node_types as $node_type => $data) {
// Only 2 comment types depending on subject field visibility.
if (!empty($data['comment_subject_field'])) {
// Default label and description should be set in migration.
- $return['comment'] = array(
+ $return['comment'] = [
'comment_type' => 'comment',
'label' => $this->t('Default comments'),
'description' => $this->t('Allows commenting on content')
- );
+ ];
}
else {
// Provide a special comment type with hidden subject field.
- $return['comment_no_subject'] = array(
+ $return['comment_no_subject'] = [
'comment_type' => 'comment_no_subject',
'label' => $this->t('Comments without subject field'),
'description' => $this->t('Allows commenting on content, comments without subject field')
- );
+ ];
}
}
return $return;
@@ -44,11 +44,11 @@ class CommentVariablePerCommentType extends CommentVariable {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'comment_type' => $this->t('The comment type'),
'label' => $this->t('The comment type label'),
'description' => $this->t('The comment type description'),
- );
+ ];
}
/**
diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
index 5531f1d3958..e643eb178c3 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
@@ -47,7 +47,7 @@ class Comment extends FieldableEntity {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'cid' => $this->t('Comment ID.'),
'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'),
'nid' => $this->t('The {node}.nid to which this comment is a reply.'),
@@ -64,7 +64,7 @@ class Comment extends FieldableEntity {
'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
'type' => $this->t("The {node}.type to which this comment is a reply."),
- );
+ ];
}
/**
diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php
index fc194b2a6df..2ac7c97a05d 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php
@@ -21,7 +21,7 @@ class CommentType extends DrupalSqlBase {
*
* @var string[]
*/
- protected $nodeTypes = array();
+ protected $nodeTypes = [];
/**
* {@inheritdoc}
@@ -29,7 +29,7 @@ class CommentType extends DrupalSqlBase {
public function query() {
return $this->select('field_config_instance', 'fci')
->distinct()
- ->fields('fci', array('bundle'))
+ ->fields('fci', ['bundle'])
->condition('fci.entity_type', 'comment');
}
@@ -38,7 +38,7 @@ class CommentType extends DrupalSqlBase {
*/
protected function initializeIterator() {
$this->nodeTypes = $this->select('node_type', 'nt')
- ->fields('nt', array('type', 'name'))
+ ->fields('nt', ['type', 'name'])
->execute()
->fetchAllKeyed();
@@ -71,7 +71,7 @@ class CommentType extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'label' => $this->t('The label of the comment type.'),
'bundle' => $this->t('Bundle ID of the comment type.'),
'node_type' => $this->t('The node type to which this comment type is attached.'),
@@ -81,18 +81,18 @@ class CommentType extends DrupalSqlBase {
'form_location' => $this->t('Location of the comment form.'),
'preview' => $this->t('Whether previews are enabled for the comment type.'),
'subject' => $this->t('Whether a subject field is enabled for the comment type.'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'bundle' => array(
+ return [
+ 'bundle' => [
'type' => 'string',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/comment/src/Plugin/views/argument/UserUid.php b/core/modules/comment/src/Plugin/views/argument/UserUid.php
index 4ad41854bbd..1fc59929df0 100644
--- a/core/modules/comment/src/Plugin/views/argument/UserUid.php
+++ b/core/modules/comment/src/Plugin/views/argument/UserUid.php
@@ -54,7 +54,7 @@ class UserUid extends ArgumentPluginBase {
$title = \Drupal::config('user.settings')->get('anonymous');
}
else {
- $title = $this->database->query('SELECT name FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', array(':uid' => $this->argument))->fetchField();
+ $title = $this->database->query('SELECT name FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', [':uid' => $this->argument])->fetchField();
}
if (empty($title)) {
return $this->t('No user');
@@ -103,7 +103,7 @@ class UserUid extends ArgumentPluginBase {
* {@inheritdoc}
*/
public function getSortName() {
- return $this->t('Numerical', array(), array('context' => 'Sort order'));
+ return $this->t('Numerical', [], ['context' => 'Sort order']);
}
}
diff --git a/core/modules/comment/src/Plugin/views/field/EntityLink.php b/core/modules/comment/src/Plugin/views/field/EntityLink.php
index dc4f8cf1811..03e6f6c8434 100644
--- a/core/modules/comment/src/Plugin/views/field/EntityLink.php
+++ b/core/modules/comment/src/Plugin/views/field/EntityLink.php
@@ -27,7 +27,7 @@ class EntityLink extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['teaser'] = array('default' => FALSE);
+ $options['teaser'] = ['default' => FALSE];
return $options;
}
@@ -35,12 +35,12 @@ class EntityLink extends FieldPluginBase {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['teaser'] = array(
+ $form['teaser'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show teaser-style link'),
'#default_value' => $this->options['teaser'],
'#description' => $this->t('Show the comment link in the form used on standard entity teasers, rather than the full entity form.'),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -55,7 +55,7 @@ class EntityLink extends FieldPluginBase {
*/
public function preRender(&$values) {
// Render all nodes, so you can grep the comment links.
- $entities = array();
+ $entities = [];
foreach ($values as $row) {
$entity = $row->_entity;
$entities[$entity->id()] = $entity;
diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
index 5a9f5b3a12f..c53b52ed154 100644
--- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
+++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
@@ -68,7 +68,7 @@ class NodeNewComments extends NumericField {
$this->additional_fields['entity_id'] = 'nid';
$this->additional_fields['type'] = 'type';
- $this->additional_fields['comment_count'] = array('table' => 'comment_entity_statistics', 'field' => 'comment_count');
+ $this->additional_fields['comment_count'] = ['table' => 'comment_entity_statistics', 'field' => 'comment_count'];
}
/**
@@ -77,7 +77,7 @@ class NodeNewComments extends NumericField {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['link_to_comment'] = array('default' => TRUE);
+ $options['link_to_comment'] = ['default' => TRUE];
return $options;
}
@@ -86,12 +86,12 @@ class NodeNewComments extends NumericField {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['link_to_comment'] = array(
+ $form['link_to_comment'] = [
'#title' => $this->t('Link this field to new comments'),
'#description' => $this->t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => $this->options['link_to_comment'],
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -114,14 +114,14 @@ class NodeNewComments extends NumericField {
return;
}
- $nids = array();
- $ids = array();
+ $nids = [];
+ $ids = [];
foreach ($values as $id => $result) {
$nids[] = $result->{$this->aliases['nid']};
$values[$id]->{$this->field_alias} = 0;
// Create a reference so we can find this record in the values again.
if (empty($ids[$result->{$this->aliases['nid']}])) {
- $ids[$result->{$this->aliases['nid']}] = array();
+ $ids[$result->{$this->aliases['nid']}] = [];
}
$ids[$result->{$this->aliases['nid']}][] = $id;
}
@@ -129,13 +129,13 @@ class NodeNewComments extends NumericField {
if ($nids) {
$result = $this->database->query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment_field_data} c ON n.nid = c.entity_id AND c.entity_type = 'node' AND c.default_langcode = 1
LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN ( :nids[] )
- AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp1), :timestamp2) AND c.status = :status GROUP BY n.nid", array(
+ AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp1), :timestamp2) AND c.status = :status GROUP BY n.nid", [
':status' => CommentInterface::PUBLISHED,
':h_uid' => $user->id(),
':nids[]' => $nids,
':timestamp1' => HISTORY_READ_LIMIT,
':timestamp2' => HISTORY_READ_LIMIT,
- ));
+ ]);
foreach ($result as $node) {
foreach ($ids[$node->nid] as $id) {
$values[$id]->{$this->field_alias} = $node->num_comments;
@@ -181,7 +181,7 @@ class NodeNewComments extends NumericField {
->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node, $comment_field_name);
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['url'] = $node->urlInfo();
- $this->options['alter']['query'] = $page_number ? array('page' => $page_number) : NULL;
+ $this->options['alter']['query'] = $page_number ? ['page' => $page_number] : NULL;
$this->options['alter']['fragment'] = 'new';
}
diff --git a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php
index 61a5d17ef4a..fa24c3ffe82 100644
--- a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php
+++ b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php
@@ -23,19 +23,19 @@ class StatisticsLastCommentName extends FieldPluginBase {
// have to join in a specially related user table.
$this->ensureMyTable();
// join 'users' to this table via vid
- $definition = array(
+ $definition = [
'table' => 'users_field_data',
'field' => 'uid',
'left_table' => 'comment_entity_statistics',
'left_field' => 'last_comment_uid',
- 'extra' => array(
- array(
+ 'extra' => [
+ [
'field' => 'uid',
'operator' => '!=',
'value' => '0'
- )
- )
- );
+ ]
+ ]
+ ];
$join = \Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition);
// nes_user alias so this can work with the sort handler, below.
@@ -53,7 +53,7 @@ class StatisticsLastCommentName extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['link_to_user'] = array('default' => TRUE);
+ $options['link_to_user'] = ['default' => TRUE];
return $options;
}
@@ -66,10 +66,10 @@ class StatisticsLastCommentName extends FieldPluginBase {
$account = User::create();
$account->name = $this->getValue($values);
$account->uid = $values->{$this->uid};
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $account,
- );
+ ];
return drupal_render($username);
}
else {
diff --git a/core/modules/comment/src/Plugin/views/filter/NodeComment.php b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
index e34584f4b3c..238c05e867f 100644
--- a/core/modules/comment/src/Plugin/views/filter/NodeComment.php
+++ b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
@@ -15,11 +15,11 @@ use Drupal\views\Plugin\views\filter\InOperator;
class NodeComment extends InOperator {
public function getValueOptions() {
- $this->valueOptions = array(
+ $this->valueOptions = [
CommentItemInterface::HIDDEN => $this->t('Hidden'),
CommentItemInterface::CLOSED => $this->t('Closed'),
CommentItemInterface::OPEN => $this->t('Open'),
- );
+ ];
return $this->valueOptions;
}
diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php
index d5280400027..cb9c1046d1a 100644
--- a/core/modules/comment/src/Plugin/views/row/Rss.php
+++ b/core/modules/comment/src/Plugin/views/row/Rss.php
@@ -40,7 +40,7 @@ class Rss extends RssPluginBase {
protected $entityTypeId = 'comment';
public function preRender($result) {
- $cids = array();
+ $cids = [];
foreach ($result as $row) {
$cids[] = $row->cid;
@@ -79,23 +79,23 @@ class Rss extends RssPluginBase {
return;
}
- $comment->link = $comment->url('canonical', array('absolute' => TRUE));
- $comment->rss_namespaces = array();
- $comment->rss_elements = array(
- array(
+ $comment->link = $comment->url('canonical', ['absolute' => TRUE]);
+ $comment->rss_namespaces = [];
+ $comment->rss_elements = [
+ [
'key' => 'pubDate',
'value' => gmdate('r', $comment->getCreatedTime()),
- ),
- array(
+ ],
+ [
'key' => 'dc:creator',
'value' => $comment->getAuthorName(),
- ),
- array(
+ ],
+ [
'key' => 'guid',
'value' => 'comment ' . $comment->id() . ' at ' . $base_url,
- 'attributes' => array('isPermaLink' => 'false'),
- ),
- );
+ 'attributes' => ['isPermaLink' => 'false'],
+ ],
+ ];
// The comment gets built and modules add to or modify
// $comment->rss_elements and $comment->rss_namespaces.
@@ -118,12 +118,12 @@ class Rss extends RssPluginBase {
$item->elements = &$comment->rss_elements;
$item->cid = $comment->id();
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $item,
- );
+ ];
return $build;
}
diff --git a/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php b/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php
index 863b3a43ba0..48f556e68ac 100644
--- a/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php
+++ b/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php
@@ -16,12 +16,12 @@ class StatisticsLastCommentName extends SortPluginBase {
public function query() {
$this->ensureMyTable();
- $definition = array(
+ $definition = [
'table' => 'users_field_data',
'field' => 'uid',
'left_table' => 'comment_entity_statistics',
'left_field' => 'last_comment_uid',
- );
+ ];
$join = \Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition);
// @todo this might be safer if we had an ensure_relationship rather than guessing
diff --git a/core/modules/comment/src/Plugin/views/wizard/Comment.php b/core/modules/comment/src/Plugin/views/wizard/Comment.php
index 1f0d4aa45e6..61d92c591ab 100644
--- a/core/modules/comment/src/Plugin/views/wizard/Comment.php
+++ b/core/modules/comment/src/Plugin/views/wizard/Comment.php
@@ -27,16 +27,16 @@ class Comment extends WizardPluginBase {
/**
* Set default values for the filters.
*/
- protected $filters = array(
- 'status' => array(
+ protected $filters = [
+ 'status' => [
'value' => TRUE,
'table' => 'comment_field_data',
'field' => 'status',
'plugin_id' => 'boolean',
'entity_type' => 'comment',
'entity_field' => 'status',
- ),
- 'status_node' => array(
+ ],
+ 'status_node' => [
'value' => TRUE,
'table' => 'node_field_data',
'field' => 'status',
@@ -44,14 +44,14 @@ class Comment extends WizardPluginBase {
'relationship' => 'node',
'entity_type' => 'node',
'entity_field' => 'status',
- ),
- );
+ ],
+ ];
/**
* {@inheritdoc}
*/
protected function rowStyleOptions() {
- $options = array();
+ $options = [];
$options['entity:comment'] = $this->t('comments');
$options['fields'] = $this->t('fields');
return $options;
diff --git a/core/modules/comment/src/Tests/CommentActionsTest.php b/core/modules/comment/src/Tests/CommentActionsTest.php
index 220be20be7b..8b741e79272 100644
--- a/core/modules/comment/src/Tests/CommentActionsTest.php
+++ b/core/modules/comment/src/Tests/CommentActionsTest.php
@@ -17,7 +17,7 @@ class CommentActionsTest extends CommentTestBase {
*
* @var array
*/
- public static $modules = array('dblog', 'action');
+ public static $modules = ['dblog', 'action'];
/**
* Tests comment publish and unpublish actions.
@@ -30,12 +30,12 @@ class CommentActionsTest extends CommentTestBase {
// Unpublish a comment.
$action = Action::load('comment_unpublish_action');
- $action->execute(array($comment));
+ $action->execute([$comment]);
$this->assertTrue($comment->isPublished() === FALSE, 'Comment was unpublished');
// Publish a comment.
$action = Action::load('comment_publish_action');
- $action->execute(array($comment));
+ $action->execute([$comment]);
$this->assertTrue($comment->isPublished() === TRUE, 'Comment was published');
}
@@ -46,15 +46,15 @@ class CommentActionsTest extends CommentTestBase {
$this->drupalLogin($this->adminUser);
$keyword_1 = $this->randomMachineName();
$keyword_2 = $this->randomMachineName();
- $action = Action::create(array(
+ $action = Action::create([
'id' => 'comment_unpublish_by_keyword_action',
'label' => $this->randomMachineName(),
'type' => 'comment',
- 'configuration' => array(
- 'keywords' => array($keyword_1, $keyword_2),
- ),
+ 'configuration' => [
+ 'keywords' => [$keyword_1, $keyword_2],
+ ],
'plugin' => 'comment_unpublish_by_keyword_action',
- ));
+ ]);
$action->save();
$comment = $this->postComment($this->node, $keyword_2, $this->randomMachineName());
@@ -64,7 +64,7 @@ class CommentActionsTest extends CommentTestBase {
$this->assertTrue($comment->isPublished() === TRUE, 'The comment status was set to published.');
- $action->execute(array($comment));
+ $action->execute([$comment]);
$this->assertTrue($comment->isPublished() === FALSE, 'The comment status was set to not published.');
}
diff --git a/core/modules/comment/src/Tests/CommentAdminTest.php b/core/modules/comment/src/Tests/CommentAdminTest.php
index 5ae57cb8199..74e6e459691 100644
--- a/core/modules/comment/src/Tests/CommentAdminTest.php
+++ b/core/modules/comment/src/Tests/CommentAdminTest.php
@@ -23,11 +23,11 @@ class CommentAdminTest extends CommentTestBase {
*/
function testApprovalAdminInterface() {
// Set anonymous comments to require approval.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => FALSE,
- ));
+ ]);
$this->drupalLogin($this->adminUser);
$this->setCommentAnonymous('0'); // Ensure that doesn't require contact info.
@@ -46,14 +46,14 @@ class CommentAdminTest extends CommentTestBase {
// Get unapproved comment id.
$this->drupalLogin($this->adminUser);
$anonymous_comment4 = $this->getUnapprovedComment($subject);
- $anonymous_comment4 = Comment::create(array(
+ $anonymous_comment4 = Comment::create([
'cid' => $anonymous_comment4,
'subject' => $subject,
'comment_body' => $body,
'entity_id' => $this->node->id(),
'entity_type' => 'node',
'field_name' => 'comment'
- ));
+ ]);
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');
@@ -73,29 +73,29 @@ class CommentAdminTest extends CommentTestBase {
// Publish multiple comments in one operation.
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/content/comment/approval');
- $this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), 'Two unapproved comments waiting for approval.');
- $edit = array(
+ $this->assertText(t('Unapproved comments (@count)', ['@count' => 2]), 'Two unapproved comments waiting for approval.');
+ $edit = [
"comments[{$comments[0]->id()}]" => 1,
"comments[{$comments[1]->id()}]" => 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Update'));
- $this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), 'All comments were approved.');
+ $this->assertText(t('Unapproved comments (@count)', ['@count' => 0]), 'All comments were approved.');
// Delete multiple comments in one operation.
- $edit = array(
+ $edit = [
'operation' => 'delete',
"comments[{$comments[0]->id()}]" => 1,
"comments[{$comments[1]->id()}]" => 1,
"comments[{$anonymous_comment4->id()}]" => 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Update'));
$this->assertText(t('Are you sure you want to delete these comments and all their children?'), 'Confirmation required.');
$this->drupalPostForm(NULL, $edit, t('Delete comments'));
$this->assertText(t('No comments available.'), 'All comments were deleted.');
// Test message when no comments selected.
- $edit = array(
+ $edit = [
'operation' => 'delete',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Update'));
$this->assertText(t('Select one or more comments to perform the update on.'));
}
@@ -105,11 +105,11 @@ class CommentAdminTest extends CommentTestBase {
*/
function testApprovalNodeInterface() {
// Set anonymous comments to require approval.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => FALSE,
- ));
+ ]);
$this->drupalLogin($this->adminUser);
$this->setCommentAnonymous('0'); // Ensure that doesn't require contact info.
$this->drupalLogout();
@@ -123,14 +123,14 @@ class CommentAdminTest extends CommentTestBase {
// Get unapproved comment id.
$this->drupalLogin($this->adminUser);
$anonymous_comment4 = $this->getUnapprovedComment($subject);
- $anonymous_comment4 = Comment::create(array(
+ $anonymous_comment4 = Comment::create([
'cid' => $anonymous_comment4,
'subject' => $subject,
'comment_body' => $body,
'entity_id' => $this->node->id(),
'entity_type' => 'node',
'field_name' => 'comment'
- ));
+ ]);
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');
@@ -139,7 +139,7 @@ class CommentAdminTest extends CommentTestBase {
$this->drupalLogin($this->adminUser);
$this->drupalGet('comment/1/approve');
$this->assertResponse(403, 'Forged comment approval was denied.');
- $this->drupalGet('comment/1/approve', array('query' => array('token' => 'forged')));
+ $this->drupalGet('comment/1/approve', ['query' => ['token' => 'forged']]);
$this->assertResponse(403, 'Forged comment approval was denied.');
$this->drupalGet('comment/1/edit');
$this->assertFieldChecked('edit-status-0');
@@ -178,11 +178,11 @@ class CommentAdminTest extends CommentTestBase {
*/
public function testEditComment() {
// Enable anonymous user comments.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments',
'post comments',
'skip comment approval',
- ));
+ ]);
// Log in as a web user.
$this->drupalLogin($this->webUser);
@@ -199,7 +199,7 @@ class CommentAdminTest extends CommentTestBase {
// Post comment with contact info (required).
$author_name = $this->randomMachineName();
$author_mail = $this->randomMachineName() . '@example.com';
- $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), array('name' => $author_name, 'mail' => $author_mail));
+ $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), ['name' => $author_name, 'mail' => $author_mail]);
// Log in as an admin user.
$this->drupalLogin($this->adminUser);
diff --git a/core/modules/comment/src/Tests/CommentAnonymousTest.php b/core/modules/comment/src/Tests/CommentAnonymousTest.php
index 2a5feb2f1fa..7c94e5af871 100644
--- a/core/modules/comment/src/Tests/CommentAnonymousTest.php
+++ b/core/modules/comment/src/Tests/CommentAnonymousTest.php
@@ -15,16 +15,16 @@ class CommentAnonymousTest extends CommentTestBase {
parent::setUp();
// Enable anonymous and authenticated user comments.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments',
'post comments',
'skip comment approval',
- ));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array(
+ ]);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [
'access comments',
'post comments',
'skip comment approval',
- ));
+ ]);
}
/**
@@ -66,10 +66,10 @@ class CommentAnonymousTest extends CommentTestBase {
$this->assertTrue($this->commentExists($anonymous_comment1), 'Anonymous comment without contact info found.');
// Ensure anonymous users cannot post in the name of registered users.
- $edit = array(
+ $edit = [
'name' => $this->adminUser->getUsername(),
'comment_body[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit, t('Save'));
$this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
'%name' => $this->adminUser->getUsername(),
@@ -97,12 +97,12 @@ class CommentAnonymousTest extends CommentTestBase {
$this->assertTrue($this->commentExists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.');
// Ensure anonymous users cannot post in the name of registered users.
- $edit = array(
+ $edit = [
'name' => $this->adminUser->getUsername(),
'mail' => $this->randomMachineName() . '@example.com',
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit, t('Save'));
$this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
'%name' => $this->adminUser->getUsername(),
@@ -125,7 +125,7 @@ class CommentAnonymousTest extends CommentTestBase {
// Post comment with contact info (required).
$author_name = $this->randomMachineName();
$author_mail = $this->randomMachineName() . '@example.com';
- $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), array('name' => $author_name, 'mail' => $author_mail));
+ $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), ['name' => $author_name, 'mail' => $author_mail]);
$this->assertTrue($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) found.');
// Make sure the user data appears correctly when editing the comment.
@@ -159,11 +159,11 @@ class CommentAnonymousTest extends CommentTestBase {
$this->assertResponse(403);
// Reset.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => FALSE,
'post comments' => FALSE,
'skip comment approval' => FALSE,
- ));
+ ]);
// Attempt to view comments while disallowed.
// NOTE: if authenticated user has permission to post comments, then a
@@ -176,21 +176,21 @@ class CommentAnonymousTest extends CommentTestBase {
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertResponse(403);
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => FALSE,
'skip comment approval' => FALSE,
- ));
+ ]);
$this->drupalGet('node/' . $this->node->id());
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 1, 'Link to login was found.');
$this->assertLink('register', 1, 'Link to register was found.');
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => FALSE,
'post comments' => TRUE,
'skip comment approval' => TRUE,
- ));
+ ]);
$this->drupalGet('node/' . $this->node->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
diff --git a/core/modules/comment/src/Tests/CommentBlockTest.php b/core/modules/comment/src/Tests/CommentBlockTest.php
index de92238ddfa..fca7223a41c 100644
--- a/core/modules/comment/src/Tests/CommentBlockTest.php
+++ b/core/modules/comment/src/Tests/CommentBlockTest.php
@@ -17,12 +17,12 @@ class CommentBlockTest extends CommentTestBase {
*
* @var array
*/
- public static $modules = array('block', 'views');
+ public static $modules = ['block', 'views'];
protected function setUp() {
parent::setUp();
// Update admin user to have the 'administer blocks' permission.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer content types',
'administer comments',
'skip comment approval',
@@ -30,7 +30,7 @@ class CommentBlockTest extends CommentTestBase {
'access comments',
'access content',
'administer blocks',
- ));
+ ]);
}
/**
@@ -54,10 +54,10 @@ class CommentBlockTest extends CommentTestBase {
// Test that a user without the 'access comments' permission cannot see the
// block.
$this->drupalLogout();
- user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access comments'));
+ user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']);
$this->drupalGet('');
$this->assertNoText(t('Recent comments'));
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access comments'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']);
// Test that a user with the 'access comments' permission can see the
// block.
@@ -68,11 +68,11 @@ class CommentBlockTest extends CommentTestBase {
// Test the only the 10 latest comments are shown and in the proper order.
$this->assertNoText($comments[10]->getSubject(), 'Comment 11 not found in block.');
for ($i = 0; $i < 10; $i++) {
- $this->assertText($comments[$i]->getSubject(), SafeMarkup::format('Comment @number found in block.', array('@number' => 10 - $i)));
+ $this->assertText($comments[$i]->getSubject(), SafeMarkup::format('Comment @number found in block.', ['@number' => 10 - $i]));
if ($i > 1) {
$previous_position = $position;
$position = strpos($this->getRawContent(), $comments[$i]->getSubject());
- $this->assertTrue($position > $previous_position, SafeMarkup::format('Comment @a appears after comment @b', array('@a' => 10 - $i, '@b' => 11 - $i)));
+ $this->assertTrue($position > $previous_position, SafeMarkup::format('Comment @a appears after comment @b', ['@a' => 10 - $i, '@b' => 11 - $i]));
}
$position = strpos($this->getRawContent(), $comments[$i]->getSubject());
}
diff --git a/core/modules/comment/src/Tests/CommentBookTest.php b/core/modules/comment/src/Tests/CommentBookTest.php
index b23028b42ea..4afd07ed83c 100644
--- a/core/modules/comment/src/Tests/CommentBookTest.php
+++ b/core/modules/comment/src/Tests/CommentBookTest.php
@@ -21,7 +21,7 @@ class CommentBookTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('book', 'comment');
+ public static $modules = ['book', 'comment'];
protected function setUp() {
parent::setUp();
@@ -44,17 +44,17 @@ class CommentBookTest extends WebTestBase {
$comment_subject = $this->randomMachineName(8);
$comment_body = $this->randomMachineName(8);
- $comment = Comment::create(array(
+ $comment = Comment::create([
'subject' => $comment_subject,
'comment_body' => $comment_body,
'entity_id' => $book_node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'status' => CommentInterface::PUBLISHED,
- ));
+ ]);
$comment->save();
- $commenting_user = $this->drupalCreateUser(array('access printer-friendly version', 'access comments', 'post comments'));
+ $commenting_user = $this->drupalCreateUser(['access printer-friendly version', 'access comments', 'post comments']);
$this->drupalLogin($commenting_user);
$this->drupalGet('node/' . $book_node->id());
diff --git a/core/modules/comment/src/Tests/CommentCSSTest.php b/core/modules/comment/src/Tests/CommentCSSTest.php
index f015f3fb399..3c48f698cda 100644
--- a/core/modules/comment/src/Tests/CommentCSSTest.php
+++ b/core/modules/comment/src/Tests/CommentCSSTest.php
@@ -18,10 +18,10 @@ class CommentCSSTest extends CommentTestBase {
parent::setUp();
// Allow anonymous users to see comments.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments',
'access content'
- ));
+ ]);
}
/**
@@ -29,21 +29,21 @@ class CommentCSSTest extends CommentTestBase {
*/
function testCommentClasses() {
// Create all permutations for comments, users, and nodes.
- $parameters = array(
- 'node_uid' => array(0, $this->webUser->id()),
- 'comment_uid' => array(0, $this->webUser->id(), $this->adminUser->id()),
- 'comment_status' => array(CommentInterface::PUBLISHED, CommentInterface::NOT_PUBLISHED),
- 'user' => array('anonymous', 'authenticated', 'admin'),
- );
+ $parameters = [
+ 'node_uid' => [0, $this->webUser->id()],
+ 'comment_uid' => [0, $this->webUser->id(), $this->adminUser->id()],
+ 'comment_status' => [CommentInterface::PUBLISHED, CommentInterface::NOT_PUBLISHED],
+ 'user' => ['anonymous', 'authenticated', 'admin'],
+ ];
$permutations = $this->generatePermutations($parameters);
foreach ($permutations as $case) {
// Create a new node.
- $node = $this->drupalCreateNode(array('type' => 'article', 'uid' => $case['node_uid']));
+ $node = $this->drupalCreateNode(['type' => 'article', 'uid' => $case['node_uid']]);
// Add a comment.
/** @var \Drupal\comment\CommentInterface $comment */
- $comment = Comment::create(array(
+ $comment = Comment::create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
@@ -51,8 +51,8 @@ class CommentCSSTest extends CommentTestBase {
'status' => $case['comment_status'],
'subject' => $this->randomMachineName(),
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomMachineName())),
- ));
+ 'comment_body' => [LanguageInterface::LANGCODE_NOT_SPECIFIED => [$this->randomMachineName()]],
+ ]);
$comment->save();
// Adjust the current/viewing user.
diff --git a/core/modules/comment/src/Tests/CommentCacheTagsTest.php b/core/modules/comment/src/Tests/CommentCacheTagsTest.php
index 3c7ab009638..12e0ef8451b 100644
--- a/core/modules/comment/src/Tests/CommentCacheTagsTest.php
+++ b/core/modules/comment/src/Tests/CommentCacheTagsTest.php
@@ -24,7 +24,7 @@ class CommentCacheTagsTest extends EntityWithUriCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('comment');
+ public static $modules = ['comment'];
/**
* @var \Drupal\entity_test\Entity\EntityTest
@@ -66,24 +66,24 @@ class CommentCacheTagsTest extends EntityWithUriCacheTagsTestBase {
$field->save();
// Create a "Camelids" test entity that the comment will be assigned to.
- $this->entityTestCamelid = EntityTest::create(array(
+ $this->entityTestCamelid = EntityTest::create([
'name' => 'Camelids',
'type' => 'bar',
- ));
+ ]);
$this->entityTestCamelid->save();
// Create a "Llama" comment.
- $comment = Comment::create(array(
+ $comment = Comment::create([
'subject' => 'Llama',
- 'comment_body' => array(
+ 'comment_body' => [
'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
'format' => 'plain_text',
- ),
+ ],
'entity_id' => $this->entityTestCamelid->id(),
'entity_type' => 'entity_test',
'field_name' => 'comment',
'status' => CommentInterface::PUBLISHED,
- ));
+ ]);
$comment->save();
return $comment;
@@ -97,26 +97,26 @@ class CommentCacheTagsTest extends EntityWithUriCacheTagsTestBase {
$this->verifyPageCache($this->entityTestCamelid->urlInfo(), 'HIT');
// Create a "Hippopotamus" comment.
- $this->entityTestHippopotamidae = EntityTest::create(array(
+ $this->entityTestHippopotamidae = EntityTest::create([
'name' => 'Hippopotamus',
'type' => 'bar',
- ));
+ ]);
$this->entityTestHippopotamidae->save();
$this->verifyPageCache($this->entityTestHippopotamidae->urlInfo(), 'MISS');
$this->verifyPageCache($this->entityTestHippopotamidae->urlInfo(), 'HIT');
- $hippo_comment = Comment::create(array(
+ $hippo_comment = Comment::create([
'subject' => 'Hippopotamus',
- 'comment_body' => array(
+ 'comment_body' => [
'value' => 'The common hippopotamus (Hippopotamus amphibius), or hippo, is a large, mostly herbivorous mammal in sub-Saharan Africa',
'format' => 'plain_text',
- ),
+ ],
'entity_id' => $this->entityTestHippopotamidae->id(),
'entity_type' => 'entity_test',
'field_name' => 'comment',
'status' => CommentInterface::PUBLISHED,
- ));
+ ]);
$hippo_comment->save();
// Ensure that a new comment only invalidates the commented entity.
@@ -145,11 +145,11 @@ class CommentCacheTagsTest extends EntityWithUriCacheTagsTestBase {
*/
protected function getAdditionalCacheTagsForEntity(EntityInterface $entity) {
/** @var \Drupal\comment\CommentInterface $entity */
- return array(
+ return [
'config:filter.format.plain_text',
'user:' . $entity->getOwnerId(),
'user_view',
- );
+ ];
}
}
diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php
index 4da6e756eee..fa8a72a6a8a 100644
--- a/core/modules/comment/src/Tests/CommentFieldsTest.php
+++ b/core/modules/comment/src/Tests/CommentFieldsTest.php
@@ -19,7 +19,7 @@ class CommentFieldsTest extends CommentTestBase {
*
* @var array
*/
- public static $modules = array('field_ui');
+ public static $modules = ['field_ui'];
/**
* Tests that the default 'comment_body' field is correctly added.
@@ -27,7 +27,7 @@ class CommentFieldsTest extends CommentTestBase {
function testCommentDefaultFields() {
// Do not make assumptions on default node types created by the test
// installation profile, and create our own.
- $this->drupalCreateContentType(array('type' => 'test_node_type'));
+ $this->drupalCreateContentType(['type' => 'test_node_type']);
$this->addDefaultCommentField('node', 'test_node_type');
// Check that the 'comment_body' field is present on the comment bundle.
@@ -43,7 +43,7 @@ class CommentFieldsTest extends CommentTestBase {
// Create a new content type.
$type_name = 'test_node_type_2';
- $this->drupalCreateContentType(array('type' => $type_name));
+ $this->drupalCreateContentType(['type' => $type_name]);
$this->addDefaultCommentField('node', $type_name);
// Check that the 'comment_body' field exists and has an instance on the
@@ -51,7 +51,7 @@ class CommentFieldsTest extends CommentTestBase {
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$this->assertTrue($field_storage, 'The comment_body field exists');
$field = FieldConfig::loadByName('comment', 'comment', 'comment_body');
- $this->assertTrue(isset($field), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
+ $this->assertTrue(isset($field), format_string('The comment_body field is present for comments on type @type', ['@type' => $type_name]));
// Test adding a field that defaults to CommentItemInterface::CLOSED.
$this->addDefaultCommentField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED, 'who_likes_ponies');
@@ -63,7 +63,7 @@ class CommentFieldsTest extends CommentTestBase {
* Tests that you can remove a comment field.
*/
public function testCommentFieldDelete() {
- $this->drupalCreateContentType(array('type' => 'test_node_type'));
+ $this->drupalCreateContentType(['type' => 'test_node_type']);
$this->addDefaultCommentField('node', 'test_node_type');
// We want to test the handling of removing the primary comment field, so we
// ensure there is at least one other comment field attached to a node type
@@ -71,10 +71,10 @@ class CommentFieldsTest extends CommentTestBase {
$this->addDefaultCommentField('node', 'test_node_type', 'comment2');
// Create a sample node.
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'title' => 'Baloney',
'type' => 'test_node_type',
- ));
+ ]);
$this->drupalLogin($this->webUser);
@@ -143,38 +143,38 @@ class CommentFieldsTest extends CommentTestBase {
*/
public function testCommentFieldCreate() {
// Create user who can administer user fields.
- $user = $this->drupalCreateUser(array(
+ $user = $this->drupalCreateUser([
'administer user fields',
- ));
+ ]);
$this->drupalLogin($user);
// Create comment field in account settings.
- $edit = array(
+ $edit = [
'new_storage_type' => 'comment',
'label' => 'User comment',
'field_name' => 'user_comment',
- );
+ ];
$this->drupalPostForm('admin/config/people/accounts/fields/add-field', $edit, 'Save and continue');
// Try to save the comment field without selecting a comment type.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/config/people/accounts/fields/user.user.field_user_comment/storage', $edit, t('Save field settings'));
// We should get an error message.
$this->assertText(t('An illegal choice has been detected. Please contact the site administrator.'));
// Create a comment type for users.
- $bundle = CommentType::create(array(
+ $bundle = CommentType::create([
'id' => 'user_comment_type',
'label' => 'user_comment_type',
'description' => '',
'target_entity_type_id' => 'user',
- ));
+ ]);
$bundle->save();
// Select a comment type and try to save again.
- $edit = array(
+ $edit = [
'settings[comment_type]' => 'user_comment_type',
- );
+ ];
$this->drupalPostForm('admin/config/people/accounts/fields/user.user.field_user_comment/storage', $edit, t('Save field settings'));
// We shouldn't get an error message.
$this->assertNoText(t('An illegal choice has been detected. Please contact the site administrator.'));
@@ -185,7 +185,7 @@ class CommentFieldsTest extends CommentTestBase {
*/
function testCommentInstallAfterContentModule() {
// Create a user to do module administration.
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$this->drupalLogin($this->adminUser);
// Drop default comment field added in CommentTestBase::setup().
@@ -199,20 +199,20 @@ class CommentFieldsTest extends CommentTestBase {
field_purge_batch(10);
// Uninstall the comment module.
- $edit = array();
+ $edit = [];
$edit['uninstall[comment]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
- $this->drupalPostForm(NULL, array(), t('Uninstall'));
+ $this->drupalPostForm(NULL, [], t('Uninstall'));
$this->rebuildContainer();
$this->assertFalse($this->container->get('module_handler')->moduleExists('comment'), 'Comment module uninstalled.');
// Install core content type module (book).
- $edit = array();
+ $edit = [];
$edit['modules[book][enable]'] = 'book';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Now install the comment module.
- $edit = array();
+ $edit = [];
$edit['modules[comment][enable]'] = 'comment';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->rebuildContainer();
@@ -220,14 +220,14 @@ class CommentFieldsTest extends CommentTestBase {
// Create nodes of each type.
$this->addDefaultCommentField('node', 'book');
- $book_node = $this->drupalCreateNode(array('type' => 'book'));
+ $book_node = $this->drupalCreateNode(['type' => 'book']);
$this->drupalLogout();
// Try to post a comment on each node. A failure will be triggered if the
// comment body is missing on one of these forms, due to postComment()
// asserting that the body is actually posted correctly.
- $this->webUser = $this->drupalCreateUser(array('access content', 'access comments', 'post comments', 'skip comment approval'));
+ $this->webUser = $this->drupalCreateUser(['access content', 'access comments', 'post comments', 'skip comment approval']);
$this->drupalLogin($this->webUser);
$this->postComment($book_node, $this->randomMachineName(), $this->randomMachineName());
}
diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php
index ba43224c738..6f67ca84dbb 100644
--- a/core/modules/comment/src/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php
@@ -68,7 +68,7 @@ class CommentInterfaceTest extends CommentTestBase {
// Comment as anonymous with preview required.
$this->drupalLogout();
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access content', 'access comments', 'post comments', 'skip comment approval'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access content', 'access comments', 'post comments', 'skip comment approval']);
$anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$this->assertTrue($this->commentExists($anonymous_comment), 'Comment found.');
$anonymous_comment->delete();
@@ -92,24 +92,24 @@ class CommentInterfaceTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->drupalGet('comment/' . $comment->id() . '/edit');
- $this->assertTitle(t('Edit comment @title | Drupal', array(
+ $this->assertTitle(t('Edit comment @title | Drupal', [
'@title' => $comment->getSubject(),
- )));
+ ]));
// Test changing the comment author to "Anonymous".
- $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('uid' => ''));
+ $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => '']);
$this->assertTrue($comment->getAuthorName() == t('Anonymous') && $comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.');
// Test changing the comment author to an unverified user.
$random_name = $this->randomMachineName();
$this->drupalGet('comment/' . $comment->id() . '/edit');
- $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => $random_name));
+ $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['name' => $random_name]);
$this->drupalGet('node/' . $this->node->id());
$this->assertText($random_name . ' (' . t('not verified') . ')', 'Comment author successfully changed to an unverified user.');
// Test changing the comment author to a verified user.
$this->drupalGet('comment/' . $comment->id() . '/edit');
- $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('uid' => $this->webUser->getUsername() . ' (' . $this->webUser->id() . ')'));
+ $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => $this->webUser->getUsername() . ' (' . $this->webUser->id() . ')']);
$this->assertTrue($comment->getAuthorName() == $this->webUser->getUsername() && $comment->getOwnerId() == $this->webUser->id(), 'Comment author successfully changed to a registered user.');
$this->drupalLogout();
@@ -121,7 +121,7 @@ class CommentInterfaceTest extends CommentTestBase {
// \Drupal\comment\Controller\CommentController::redirectNode().
$this->drupalGet('comment/' . $this->node->id() . '/reply');
// Verify we were correctly redirected.
- $this->assertUrl(\Drupal::url('comment.reply', array('entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'), array('absolute' => TRUE)));
+ $this->assertUrl(\Drupal::url('comment.reply', ['entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'], ['absolute' => TRUE]));
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id());
$this->assertText($subject_text, 'Individual comment-reply subject found.');
$this->assertText($comment_text, 'Individual comment-reply body found.');
@@ -161,7 +161,7 @@ class CommentInterfaceTest extends CommentTestBase {
$this->setCommentsPerPage(2);
$comment_new_page = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$this->assertTrue($this->commentExists($comment_new_page), 'Page one exists. %s');
- $this->drupalGet('node/' . $this->node->id(), array('query' => array('page' => 2)));
+ $this->drupalGet('node/' . $this->node->id(), ['query' => ['page' => 2]]);
$this->assertTrue($this->commentExists($reply, TRUE), 'Page two exists. %s');
$this->setCommentsPerPage(50);
@@ -172,21 +172,21 @@ class CommentInterfaceTest extends CommentTestBase {
$this->assertResponse(403);
// Attempt to post to node with comments disabled.
- $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::HIDDEN))));
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::HIDDEN]]]);
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertResponse(403);
$this->assertNoField('edit-comment', 'Comment body field found.');
// Attempt to post to node with read-only comments.
- $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::CLOSED))));
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::CLOSED]]]);
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertResponse(403);
$this->assertNoField('edit-comment', 'Comment body field found.');
// Attempt to post to node with comments enabled (check field names etc).
- $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::OPEN))));
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::OPEN]]]);
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertNoText('This discussion is closed', 'Posting to node with comments enabled');
@@ -254,17 +254,17 @@ class CommentInterfaceTest extends CommentTestBase {
// can select one of them. Then create a user that can use these formats,
// log the user in, and then GET the node page on which to test the
// comments.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
- ));
+ ]);
$filtered_html_format->save();
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
- ));
+ ]);
$full_html_format->save();
- $html_user = $this->drupalCreateUser(array(
+ $html_user = $this->drupalCreateUser([
'access comments',
'post comments',
'edit own comments',
@@ -272,25 +272,25 @@ class CommentInterfaceTest extends CommentTestBase {
'access content',
$filtered_html_format->getPermissionName(),
$full_html_format->getPermissionName(),
- ));
+ ]);
$this->drupalLogin($html_user);
$this->drupalGet('node/' . $this->node->id());
// HTML should not be included in the character count.
$body_text1 = '<span></span><strong> </strong><span> </span><strong></strong>Hello World<br />';
- $edit1 = array(
+ $edit1 = [
'comment_body[0][value]' => $body_text1,
'comment_body[0][format]' => 'filtered_html',
- );
+ ];
$this->drupalPostForm(NULL, $edit1, t('Save'));
$this->assertEqual('Hello World', Comment::load(1)->getSubject());
// If there's nothing other than HTML, the subject should be '(No subject)'.
$body_text2 = '<span></span><strong> </strong><span> </span><strong></strong> <br />';
- $edit2 = array(
+ $edit2 = [
'comment_body[0][value]' => $body_text2,
'comment_body[0][format]' => 'filtered_html',
- );
+ ];
$this->drupalPostForm(NULL, $edit2, t('Save'));
$this->assertEqual('(No subject)', Comment::load(2)->getSubject());
}
diff --git a/core/modules/comment/src/Tests/CommentLanguageTest.php b/core/modules/comment/src/Tests/CommentLanguageTest.php
index c60f82783f0..b047b403410 100644
--- a/core/modules/comment/src/Tests/CommentLanguageTest.php
+++ b/core/modules/comment/src/Tests/CommentLanguageTest.php
@@ -25,23 +25,23 @@ class CommentLanguageTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'language', 'language_test', 'comment_test');
+ public static $modules = ['node', 'language', 'language_test', 'comment_test'];
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Create and log in user.
- $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content', 'access comments', 'post comments', 'skip comment approval'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content', 'access comments', 'post comments', 'skip comment approval']);
$this->drupalLogin($admin_user);
// Add language.
- $edit = array('predefined_langcode' => 'fr');
+ $edit = ['predefined_langcode' => 'fr'];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Set "Article" content type to use multilingual support.
- $edit = array('language_configuration[language_alterable]' => TRUE);
+ $edit = ['language_configuration[language_alterable]' => TRUE];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
// Enable content language negotiation UI.
@@ -51,16 +51,16 @@ class CommentLanguageTest extends WebTestBase {
// to URL. Disable inheritance from interface language to ensure content
// language will fall back to the default language if no URL language can be
// detected.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-user]' => TRUE,
'language_content[enabled][language-url]' => TRUE,
'language_content[enabled][language-interface]' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Change user language preference, this way interface language is always
// French no matter what path prefix the URLs have.
- $edit = array('preferred_langcode' => 'fr');
+ $edit = ['preferred_langcode' => 'fr'];
$this->drupalPostForm("user/" . $admin_user->id() . "/edit", $edit, t('Save'));
// Create comment field on article.
@@ -87,12 +87,12 @@ class CommentLanguageTest extends WebTestBase {
foreach ($this->container->get('language_manager')->getLanguages() as $node_langcode => $node_language) {
// Create "Article" content.
$title = $this->randomMachineName();
- $edit = array(
+ $edit = [
'title[0][value]' => $title,
'body[0][value]' => $this->randomMachineName(),
'langcode[0][value]' => $node_langcode,
'comment[0][status]' => CommentItemInterface::OPEN,
- );
+ ];
$this->drupalPostForm("node/add/article", $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($title);
@@ -101,10 +101,10 @@ class CommentLanguageTest extends WebTestBase {
// Post a comment with content language $langcode.
$prefix = empty($prefixes[$langcode]) ? '' : $prefixes[$langcode] . '/';
$comment_values[$node_langcode][$langcode] = $this->randomMachineName();
- $edit = array(
+ $edit = [
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $comment_values[$node_langcode][$langcode],
- );
+ ];
$this->drupalPostForm($prefix . 'node/' . $node->id(), $edit, t('Preview'));
$this->drupalPostForm(NULL, $edit, t('Save'));
@@ -117,7 +117,7 @@ class CommentLanguageTest extends WebTestBase {
->range(0, 1)
->execute();
$comment = Comment::load(reset($cids));
- $args = array('%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode);
+ $args = ['%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode];
$this->assertEqual($comment->langcode->value, $langcode, format_string('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
$this->assertEqual($comment->comment_body->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.');
}
diff --git a/core/modules/comment/src/Tests/CommentLinksAlterTest.php b/core/modules/comment/src/Tests/CommentLinksAlterTest.php
index 22ff587c3d2..88e092f08d3 100644
--- a/core/modules/comment/src/Tests/CommentLinksAlterTest.php
+++ b/core/modules/comment/src/Tests/CommentLinksAlterTest.php
@@ -9,7 +9,7 @@ namespace Drupal\comment\Tests;
*/
class CommentLinksAlterTest extends CommentTestBase {
- public static $modules = array('comment_test');
+ public static $modules = ['comment_test'];
protected function setUp() {
parent::setUp();
diff --git a/core/modules/comment/src/Tests/CommentLinksTest.php b/core/modules/comment/src/Tests/CommentLinksTest.php
index 1115f57936c..589a3556635 100644
--- a/core/modules/comment/src/Tests/CommentLinksTest.php
+++ b/core/modules/comment/src/Tests/CommentLinksTest.php
@@ -27,7 +27,7 @@ class CommentLinksTest extends CommentTestBase {
*
* @var array
*/
- protected $seen = array();
+ protected $seen = [];
/**
* Use the main node listing to test rendering on teasers.
@@ -36,14 +36,14 @@ class CommentLinksTest extends CommentTestBase {
*
* @todo Remove this dependency.
*/
- public static $modules = array('views');
+ public static $modules = ['views'];
/**
* Tests that comment links are output and can be hidden.
*/
public function testCommentLinks() {
// Bartik theme alters comment links, so use a different theme.
- \Drupal::service('theme_handler')->install(array('stark'));
+ \Drupal::service('theme_handler')->install(['stark']);
$this->config('system.theme')
->set('default', 'stark')
->save();
@@ -51,11 +51,11 @@ class CommentLinksTest extends CommentTestBase {
// Remove additional user permissions from $this->webUser added by setUp(),
// since this test is limited to anonymous and authenticated roles only.
$roles = $this->webUser->getRoles();
- entity_delete_multiple('user_role', array(reset($roles)));
+ entity_delete_multiple('user_role', [reset($roles)]);
// Create a comment via CRUD API functionality, since
// $this->postComment() relies on actual user permissions.
- $comment = Comment::create(array(
+ $comment = Comment::create([
'cid' => NULL,
'entity_id' => $this->node->id(),
'entity_type' => 'node',
@@ -66,8 +66,8 @@ class CommentLinksTest extends CommentTestBase {
'subject' => $this->randomMachineName(),
'hostname' => '127.0.0.1',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- 'comment_body' => array(array('value' => $this->randomMachineName())),
- ));
+ 'comment_body' => [['value' => $this->randomMachineName()]],
+ ]);
$comment->save();
$this->comment = $comment;
@@ -78,19 +78,19 @@ class CommentLinksTest extends CommentTestBase {
$this->node->save();
// Change user permissions.
- $perms = array(
+ $perms = [
'access comments' => 1,
'post comments' => 1,
'skip comment approval' => 1,
'edit own comments' => 1,
- );
+ ];
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, $perms);
$nid = $this->node->id();
// Assert basic link is output, actual functionality is unit-tested in
// \Drupal\comment\Tests\CommentLinkBuilderTest.
- foreach (array('node', "node/$nid") as $path) {
+ foreach (['node', "node/$nid"] as $path) {
$this->drupalGet($path);
// In teaser view, a link containing the comment count is always
@@ -103,7 +103,7 @@ class CommentLinksTest extends CommentTestBase {
// Change weight to make links go before comment body.
entity_get_display('comment', 'comment', 'default')
- ->setComponent('links', array('weight' => -100))
+ ->setComponent('links', ['weight' => -100])
->save();
$this->drupalGet($this->node->urlInfo());
$element = $this->cssSelect('article.js-comment > div');
@@ -113,7 +113,7 @@ class CommentLinksTest extends CommentTestBase {
// Change weight to make links go after comment body.
entity_get_display('comment', 'comment', 'default')
- ->setComponent('links', array('weight' => 100))
+ ->setComponent('links', ['weight' => 100])
->save();
$this->drupalGet($this->node->urlInfo());
$element = $this->cssSelect('article.js-comment > div');
diff --git a/core/modules/comment/src/Tests/CommentNewIndicatorTest.php b/core/modules/comment/src/Tests/CommentNewIndicatorTest.php
index 6d89d4a6467..55609e3778e 100644
--- a/core/modules/comment/src/Tests/CommentNewIndicatorTest.php
+++ b/core/modules/comment/src/Tests/CommentNewIndicatorTest.php
@@ -22,7 +22,7 @@ class CommentNewIndicatorTest extends CommentTestBase {
*
* @todo Remove this dependency.
*/
- public static $modules = array('views');
+ public static $modules = ['views'];
/**
* Get node "x new comments" metadata from the server for the current user.
@@ -35,7 +35,7 @@ class CommentNewIndicatorTest extends CommentTestBase {
*/
protected function renderNewCommentsNodeLinks(array $node_ids) {
// Build POST values.
- $post = array();
+ $post = [];
for ($i = 0; $i < count($node_ids); $i++) {
$post['node_ids[' . $i . ']'] = $node_ids[$i];
}
@@ -51,15 +51,15 @@ class CommentNewIndicatorTest extends CommentTestBase {
$post = implode('&', $post);
// Perform HTTP request.
- return $this->curlExec(array(
- CURLOPT_URL => \Drupal::url('comment.new_comments_node_links', array(), array('absolute' => TRUE)),
+ return $this->curlExec([
+ CURLOPT_URL => \Drupal::url('comment.new_comments_node_links', [], ['absolute' => TRUE]),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $post,
- CURLOPT_HTTPHEADER => array(
+ CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
- ),
- ));
+ ],
+ ]);
}
/**
@@ -70,7 +70,7 @@ class CommentNewIndicatorTest extends CommentTestBase {
// node.
$this->drupalLogin($this->adminUser);
$this->drupalGet('node');
- $this->assertNoLink(t('@count comments', array('@count' => 0)));
+ $this->assertNoLink(t('@count comments', ['@count' => 0]));
$this->assertLink(t('Read more'));
// Verify the data-history-node-last-comment-timestamp attribute, which is
// used by the drupal.node-new-comments-link library to determine whether
@@ -81,7 +81,7 @@ class CommentNewIndicatorTest extends CommentTestBase {
// Create a new comment. This helper function may be run with different
// comment settings so use $comment->save() to avoid complex setup.
/** @var \Drupal\comment\CommentInterface $comment */
- $comment = Comment::create(array(
+ $comment = Comment::create([
'cid' => NULL,
'entity_id' => $this->node->id(),
'entity_type' => 'node',
@@ -92,8 +92,8 @@ class CommentNewIndicatorTest extends CommentTestBase {
'subject' => $this->randomMachineName(),
'hostname' => '127.0.0.1',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomMachineName())),
- ));
+ 'comment_body' => [LanguageInterface::LANGCODE_NOT_SPECIFIED => [$this->randomMachineName()]],
+ ]);
$comment->save();
$this->drupalLogout();
@@ -126,24 +126,24 @@ class CommentNewIndicatorTest extends CommentTestBase {
]);
// Pretend the data was not present in drupalSettings, i.e. test the
// separate request to the server.
- $response = $this->renderNewCommentsNodeLinks(array($this->node->id()));
+ $response = $this->renderNewCommentsNodeLinks([$this->node->id()]);
$this->assertResponse(200);
$json = Json::decode($response);
- $expected = array($this->node->id() => array(
+ $expected = [$this->node->id() => [
'new_comment_count' => 1,
- 'first_new_comment_link' => $this->node->url('canonical', array('fragment' => 'new')),
- ));
+ 'first_new_comment_link' => $this->node->url('canonical', ['fragment' => 'new']),
+ ]];
$this->assertIdentical($expected, $json);
// Failing to specify node IDs for the endpoint should return a 404.
- $this->renderNewCommentsNodeLinks(array());
+ $this->renderNewCommentsNodeLinks([]);
$this->assertResponse(404);
// Accessing the endpoint as the anonymous user should return a 403.
$this->drupalLogout();
- $this->renderNewCommentsNodeLinks(array($this->node->id()));
+ $this->renderNewCommentsNodeLinks([$this->node->id()]);
$this->assertResponse(403);
- $this->renderNewCommentsNodeLinks(array());
+ $this->renderNewCommentsNodeLinks([]);
$this->assertResponse(403);
}
diff --git a/core/modules/comment/src/Tests/CommentNodeAccessTest.php b/core/modules/comment/src/Tests/CommentNodeAccessTest.php
index e69bfdeda5d..60f8bbdd5ad 100644
--- a/core/modules/comment/src/Tests/CommentNodeAccessTest.php
+++ b/core/modules/comment/src/Tests/CommentNodeAccessTest.php
@@ -19,7 +19,7 @@ class CommentNodeAccessTest extends CommentTestBase {
*
* @var array
*/
- public static $modules = array('node_access_test');
+ public static $modules = ['node_access_test'];
protected function setUp() {
parent::setUp();
@@ -27,14 +27,14 @@ class CommentNodeAccessTest extends CommentTestBase {
node_access_rebuild();
// Re-create user.
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'access comments',
'post comments',
'create article content',
'edit own comments',
'node test view',
'skip comment approval',
- ));
+ ]);
// Set the author of the created node to the web_user uid.
$this->node->setOwnerId($this->webUser->id())->save();
diff --git a/core/modules/comment/src/Tests/CommentNodeChangesTest.php b/core/modules/comment/src/Tests/CommentNodeChangesTest.php
index 9fed4df8878..7724f9979a0 100644
--- a/core/modules/comment/src/Tests/CommentNodeChangesTest.php
+++ b/core/modules/comment/src/Tests/CommentNodeChangesTest.php
@@ -27,7 +27,7 @@ class CommentNodeChangesTest extends CommentTestBase {
$this->assertNotNull(FieldStorageConfig::load('node.comment'), 'Comment field storage exists');
$this->assertNotNull(FieldConfig::load('node.article.comment'), 'Comment field exists');
// Delete the node type.
- entity_delete_multiple('node_type', array($this->node->bundle()));
+ entity_delete_multiple('node_type', [$this->node->bundle()]);
$this->assertNull(FieldStorageConfig::load('node.comment'), 'Comment field storage deleted');
$this->assertNull(FieldConfig::load('node.article.comment'), 'Comment field deleted');
}
diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php
index e43e0bc42a6..bc40c9d8adf 100644
--- a/core/modules/comment/src/Tests/CommentNonNodeTest.php
+++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php
@@ -24,7 +24,7 @@ class CommentNonNodeTest extends WebTestBase {
use FieldUiTestTrait;
use CommentTestTrait;
- public static $modules = array('comment', 'user', 'field_ui', 'entity_test', 'block');
+ public static $modules = ['comment', 'user', 'field_ui', 'entity_test', 'block'];
/**
* An administrative user with permission to configure comment settings.
@@ -50,12 +50,12 @@ class CommentNonNodeTest extends WebTestBase {
// Create a bundle for entity_test.
entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test');
- CommentType::create(array(
+ CommentType::create([
'id' => 'comment',
'label' => 'Comment settings',
'description' => 'Comment settings',
'target_entity_type_id' => 'entity_test',
- ))->save();
+ ])->save();
// Create comment field on entity_test bundle.
$this->addDefaultCommentField('entity_test', 'entity_test');
@@ -64,30 +64,30 @@ class CommentNonNodeTest extends WebTestBase {
$this->assertEqual($bundles['comment']['label'], 'Comment settings');
// Create test user.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer comments',
'skip comment approval',
'post comments',
'access comments',
'view test entity',
'administer entity_test content',
- ));
+ ]);
// Enable anonymous and authenticated user comments.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments',
'post comments',
'skip comment approval',
- ));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array(
+ ]);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [
'access comments',
'post comments',
'skip comment approval',
- ));
+ ]);
// Create a test entity.
$random_label = $this->randomMachineName();
- $data = array('type' => 'entity_test', 'name' => $random_label);
+ $data = ['type' => 'entity_test', 'name' => $random_label];
$this->entity = EntityTest::create($data);
$this->entity->save();
}
@@ -109,7 +109,7 @@ class CommentNonNodeTest extends WebTestBase {
* The new comment entity.
*/
function postComment(EntityInterface $entity, $comment, $subject = '', $contact = NULL) {
- $edit = array();
+ $edit = [];
$edit['comment_body[0][value]'] = $comment;
$field = FieldConfig::loadByName('entity_test', 'entity_test', 'comment');
@@ -151,7 +151,7 @@ class CommentNonNodeTest extends WebTestBase {
$this->drupalPostForm(NULL, $edit, t('Save'));
break;
}
- $match = array();
+ $match = [];
// Get comment ID
preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
@@ -216,17 +216,17 @@ class CommentNonNodeTest extends WebTestBase {
* Operation is found on approval page.
*/
function performCommentOperation($comment, $operation, $approval = FALSE) {
- $edit = array();
+ $edit = [];
$edit['operation'] = $operation;
$edit['comments[' . $comment->id() . ']'] = TRUE;
$this->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update'));
if ($operation == 'delete') {
- $this->drupalPostForm(NULL, array(), t('Delete comments'));
- $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+ $this->drupalPostForm(NULL, [], t('Delete comments'));
+ $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
}
else {
- $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+ $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
}
}
@@ -250,9 +250,9 @@ class CommentNonNodeTest extends WebTestBase {
* Tests anonymous comment functionality.
*/
function testCommentFunctionality() {
- $limited_user = $this->drupalCreateUser(array(
+ $limited_user = $this->drupalCreateUser([
'administer entity_test fields'
- ));
+ ]);
$this->drupalLogin($limited_user);
// Test that default field exists.
$this->drupalGet('entity_test/structure/entity_test/fields');
@@ -320,9 +320,9 @@ class CommentNonNodeTest extends WebTestBase {
// Check that entity access applies to administrative page.
$this->assertText($this->entity->label(), 'Name of commented account found.');
- $limited_user = $this->drupalCreateUser(array(
+ $limited_user = $this->drupalCreateUser([
'administer comments',
- ));
+ ]);
$this->drupalLogin($limited_user);
$this->drupalGet('admin/content/comment');
$this->assertNoText($this->entity->label(), 'No commented account name found.');
@@ -330,12 +330,12 @@ class CommentNonNodeTest extends WebTestBase {
$this->drupalLogout();
// Deny anonymous users access to comments.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => FALSE,
'post comments' => FALSE,
'skip comment approval' => FALSE,
'view test entity' => TRUE,
- ));
+ ]);
// Attempt to view comments while disallowed.
$this->drupalGet('entity-test/' . $this->entity->id());
@@ -348,12 +348,12 @@ class CommentNonNodeTest extends WebTestBase {
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.');
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => FALSE,
'view test entity' => TRUE,
'skip comment approval' => FALSE,
- ));
+ ]);
$this->drupalGet('entity_test/' . $this->entity->id());
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 0, 'Link to login was found.');
@@ -364,12 +364,12 @@ class CommentNonNodeTest extends WebTestBase {
// Test the combination of anonymous users being able to post, but not view
// comments, to ensure that access to post comments doesn't grant access to
// view them.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => FALSE,
'post comments' => TRUE,
'skip comment approval' => TRUE,
'view test entity' => TRUE,
- ));
+ ]);
$this->drupalGet('entity_test/' . $this->entity->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
@@ -380,22 +380,22 @@ class CommentNonNodeTest extends WebTestBase {
$this->assertNoText($comment1->getSubject(), 'Comment not displayed.');
// Test comment field widget changes.
- $limited_user = $this->drupalCreateUser(array(
+ $limited_user = $this->drupalCreateUser([
'administer entity_test fields',
'view test entity',
'administer entity_test content',
'administer comments',
- ));
+ ]);
$this->drupalLogin($limited_user);
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1');
$this->assertFieldChecked('edit-default-value-input-comment-0-status-2');
// Test comment option change in field settings.
- $edit = array(
+ $edit = [
'default_value_input[comment][0][status]' => CommentItemInterface::CLOSED,
'settings[anonymous]' => COMMENT_ANONYMOUS_MAY_CONTACT,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
@@ -404,18 +404,18 @@ class CommentNonNodeTest extends WebTestBase {
$this->assertFieldByName('settings[anonymous]', COMMENT_ANONYMOUS_MAY_CONTACT);
// Add a new comment-type.
- $bundle = CommentType::create(array(
+ $bundle = CommentType::create([
'id' => 'foobar',
'label' => 'Foobar',
'description' => '',
'target_entity_type_id' => 'entity_test',
- ));
+ ]);
$bundle->save();
// Add a new comment field.
- $storage_edit = array(
+ $storage_edit = [
'settings[comment_type]' => 'foobar',
- );
+ ];
$this->fieldUIAddNewField('entity_test/structure/entity_test', 'foobar', 'Foobar', 'comment', $storage_edit);
// Add a third comment field.
@@ -429,7 +429,7 @@ class CommentNonNodeTest extends WebTestBase {
// Test the new entity commenting inherits default.
$random_label = $this->randomMachineName();
- $data = array('bundle' => 'entity_test', 'name' => $random_label);
+ $data = ['bundle' => 'entity_test', 'name' => $random_label];
$new_entity = EntityTest::create($data);
$new_entity->save();
$this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit');
@@ -443,12 +443,12 @@ class CommentNonNodeTest extends WebTestBase {
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field found.');
// Test removal of comment_body field.
- $limited_user = $this->drupalCreateUser(array(
+ $limited_user = $this->drupalCreateUser([
'administer entity_test fields',
'post comments',
'administer comment fields',
'administer comment types',
- ));
+ ]);
$this->drupalLogin($limited_user);
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
@@ -467,9 +467,9 @@ class CommentNonNodeTest extends WebTestBase {
public function testsNonIntegerIdEntities() {
// Create a bundle for entity_test_string_id.
entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_string_id');
- $limited_user = $this->drupalCreateUser(array(
+ $limited_user = $this->drupalCreateUser([
'administer entity_test_string_id fields',
- ));
+ ]);
$this->drupalLogin($limited_user);
// Visit the Field UI field add page.
$this->drupalGet('entity_test_string_id/structure/entity_test/fields/add-field');
@@ -480,9 +480,9 @@ class CommentNonNodeTest extends WebTestBase {
// Create a bundle for entity_test_no_id.
entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_no_id');
- $this->drupalLogin($this->drupalCreateUser(array(
+ $this->drupalLogin($this->drupalCreateUser([
'administer entity_test_no_id fields',
- )));
+ ]));
// Visit the Field UI field add page.
$this->drupalGet('entity_test_no_id/structure/entity_test/fields/add-field');
// Ensure field isn't shown for empty IDs.
diff --git a/core/modules/comment/src/Tests/CommentPagerTest.php b/core/modules/comment/src/Tests/CommentPagerTest.php
index aa7d09997bf..1bfda557f50 100644
--- a/core/modules/comment/src/Tests/CommentPagerTest.php
+++ b/core/modules/comment/src/Tests/CommentPagerTest.php
@@ -24,8 +24,8 @@ class CommentPagerTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_DISABLED);
// Create a node and three comments.
- $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
- $comments = array();
+ $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
+ $comments = [];
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
@@ -45,13 +45,13 @@ class CommentPagerTest extends CommentTestBase {
$this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 1.');
// Check the second page.
- $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 1)));
+ $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 1]]);
$this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page 2.');
$this->assertFalse($this->commentExists($comments[0]), 'Comment 1 does not appear on page 2.');
$this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 2.');
// Check the third page.
- $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 2)));
+ $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 2]]);
$this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page 3.');
$this->assertFalse($this->commentExists($comments[0]), 'Comment 1 does not appear on page 3.');
$this->assertFalse($this->commentExists($comments[1]), 'Comment 2 does not appear on page 3.');
@@ -64,27 +64,27 @@ class CommentPagerTest extends CommentTestBase {
$this->setCommentsPerPage(2);
// We are still in flat view - the replies should not be on the first page,
// even though they are replies to the oldest comment.
- $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0)));
+ $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]);
$this->assertFalse($this->commentExists($reply, TRUE), 'In flat mode, reply does not appear on page 1.');
// If we switch to threaded mode, the replies on the oldest comment
// should be bumped to the first page and comment 6 should be bumped
// to the second page.
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
- $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0)));
+ $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]);
$this->assertTrue($this->commentExists($reply, TRUE), 'In threaded mode, reply appears on page 1.');
$this->assertFalse($this->commentExists($comments[1]), 'In threaded mode, comment 2 has been bumped off of page 1.');
// If (# replies > # comments per page) in threaded expanded view,
// the overage should be bumped.
$reply2 = $this->postComment(NULL, $this->randomMachineName(), $this->randomMachineName(), TRUE);
- $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0)));
+ $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]);
$this->assertFalse($this->commentExists($reply2, TRUE), 'In threaded mode where # replies > # comments per page, the newest reply does not appear on page 1.');
// Test that the page build process does not somehow generate errors when
// # comments per page is set to 0.
$this->setCommentsPerPage(0);
- $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0)));
+ $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]);
$this->assertFalse($this->commentExists($reply2, TRUE), 'Threaded mode works correctly when comments per page is 0.');
$this->drupalLogout();
@@ -102,8 +102,8 @@ class CommentPagerTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_DISABLED);
// Create a node and three comments.
- $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
- $comments = array();
+ $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
+ $comments = [];
$comments[] = $this->postComment($node, 'comment 1: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, 'comment 2: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, 'comment 3: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
@@ -137,8 +137,8 @@ class CommentPagerTest extends CommentTestBase {
$this->setCommentsPerPage(1000);
// Create a node and three comments.
- $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
- $comments = array();
+ $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
+ $comments = [];
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
@@ -170,7 +170,7 @@ class CommentPagerTest extends CommentTestBase {
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
- $expected_order = array(
+ $expected_order = [
0,
1,
2,
@@ -178,13 +178,13 @@ class CommentPagerTest extends CommentTestBase {
4,
5,
6,
- );
+ ];
$this->drupalGet('node/' . $node->id());
$this->assertCommentOrder($comments, $expected_order);
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
- $expected_order = array(
+ $expected_order = [
0,
4,
1,
@@ -192,7 +192,7 @@ class CommentPagerTest extends CommentTestBase {
6,
2,
5,
- );
+ ];
$this->drupalGet('node/' . $node->id());
$this->assertCommentOrder($comments, $expected_order);
}
@@ -206,7 +206,7 @@ class CommentPagerTest extends CommentTestBase {
* An array of keys from $comments describing the expected order.
*/
function assertCommentOrder(array $comments, array $expected_order) {
- $expected_cids = array();
+ $expected_cids = [];
// First, rekey the expected order by cid.
foreach ($expected_order as $key) {
@@ -214,11 +214,11 @@ class CommentPagerTest extends CommentTestBase {
}
$comment_anchors = $this->xpath('//a[starts-with(@id,"comment-")]');
- $result_order = array();
+ $result_order = [];
foreach ($comment_anchors as $anchor) {
$result_order[] = substr($anchor['id'], 8);
}
- return $this->assertEqual($expected_cids, $result_order, format_string('Comment order: expected @expected, returned @returned.', array('@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order))));
+ return $this->assertEqual($expected_cids, $result_order, format_string('Comment order: expected @expected, returned @returned.', ['@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)]));
}
/**
@@ -237,8 +237,8 @@ class CommentPagerTest extends CommentTestBase {
$this->setCommentsPerPage(1);
// Create a node and three comments.
- $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
- $comments = array();
+ $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
+ $comments = [];
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
@@ -265,39 +265,39 @@ class CommentPagerTest extends CommentTestBase {
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
- $expected_pages = array(
+ $expected_pages = [
1 => 5, // Page of comment 5
2 => 4, // Page of comment 4
3 => 3, // Page of comment 3
4 => 2, // Page of comment 2
5 => 1, // Page of comment 1
6 => 0, // Page of comment 0
- );
+ ];
$node = Node::load($node->id());
foreach ($expected_pages as $new_replies => $expected_page) {
$returned_page = \Drupal::entityManager()->getStorage('comment')
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment');
- $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
+ $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page]));
}
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
- $expected_pages = array(
+ $expected_pages = [
1 => 5, // Page of comment 5
2 => 1, // Page of comment 4
3 => 1, // Page of comment 4
4 => 1, // Page of comment 4
5 => 1, // Page of comment 4
6 => 0, // Page of comment 0
- );
+ ];
- \Drupal::entityManager()->getStorage('node')->resetCache(array($node->id()));
+ \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
$node = Node::load($node->id());
foreach ($expected_pages as $new_replies => $expected_page) {
$returned_page = \Drupal::entityManager()->getStorage('comment')
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment');
- $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
+ $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page]));
}
}
@@ -309,39 +309,39 @@ class CommentPagerTest extends CommentTestBase {
$this->addDefaultCommentField('node', 'article', 'comment_2');
// Set default to display comment list with unique pager id.
entity_get_display('node', 'article', 'default')
- ->setComponent('comment_2', array(
+ ->setComponent('comment_2', [
'label' => 'hidden',
'type' => 'comment_default',
'weight' => 30,
- 'settings' => array(
+ 'settings' => [
'pager_id' => 1,
'view_mode' => 'default',
- )
- ))
+ ]
+ ])
->save();
// Make sure pager appears in formatter summary and settings form.
- $account = $this->drupalCreateUser(array('administer node display'));
+ $account = $this->drupalCreateUser(['administer node display']);
$this->drupalLogin($account);
$this->drupalGet('admin/structure/types/manage/article/display');
- $this->assertNoText(t('Pager ID: @id', array('@id' => 0)), 'No summary for standard pager');
- $this->assertText(t('Pager ID: @id', array('@id' => 1)));
- $this->drupalPostAjaxForm(NULL, array(), 'comment_settings_edit');
+ $this->assertNoText(t('Pager ID: @id', ['@id' => 0]), 'No summary for standard pager');
+ $this->assertText(t('Pager ID: @id', ['@id' => 1]));
+ $this->drupalPostAjaxForm(NULL, [], 'comment_settings_edit');
// Change default pager to 2.
- $this->drupalPostForm(NULL, array('fields[comment][settings_edit_form][settings][pager_id]' => 2), t('Save'));
- $this->assertText(t('Pager ID: @id', array('@id' => 2)));
+ $this->drupalPostForm(NULL, ['fields[comment][settings_edit_form][settings][pager_id]' => 2], t('Save'));
+ $this->assertText(t('Pager ID: @id', ['@id' => 2]));
// Revert the changes.
- $this->drupalPostAjaxForm(NULL, array(), 'comment_settings_edit');
- $this->drupalPostForm(NULL, array('fields[comment][settings_edit_form][settings][pager_id]' => 0), t('Save'));
- $this->assertNoText(t('Pager ID: @id', array('@id' => 0)), 'No summary for standard pager');
+ $this->drupalPostAjaxForm(NULL, [], 'comment_settings_edit');
+ $this->drupalPostForm(NULL, ['fields[comment][settings_edit_form][settings][pager_id]' => 0], t('Save'));
+ $this->assertNoText(t('Pager ID: @id', ['@id' => 0]), 'No summary for standard pager');
$this->drupalLogin($this->adminUser);
// Add a new node with both comment fields open.
- $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()));
+ $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
// Set comment options.
- $comments = array();
- foreach (array('comment', 'comment_2') as $field_name) {
+ $comments = [];
+ foreach (['comment', 'comment_2'] as $field_name) {
$this->setCommentForm(TRUE, $field_name);
$this->setCommentPreview(DRUPAL_OPTIONAL, $field_name);
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.', $field_name);
@@ -350,10 +350,10 @@ class CommentPagerTest extends CommentTestBase {
// needing to insert large numbers of comments.
$this->setCommentsPerPage(1, $field_name);
for ($i = 0; $i < 3; $i++) {
- $comment = t('Comment @count on field @field', array(
+ $comment = t('Comment @count on field @field', [
'@count' => $i + 1,
'@field' => $field_name,
- ));
+ ]);
$comments[] = $this->postComment($node, $comment, $comment, TRUE, $field_name);
}
}
@@ -365,19 +365,19 @@ class CommentPagerTest extends CommentTestBase {
$this->assertRaw('Comment 1 on field comment');
$this->assertRaw('Comment 1 on field comment_2');
// Navigate to next page of field 1.
- $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', array(':label' => 'Comment 1 on field comment'));
+ $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment']);
// Check only one pager updated.
$this->assertRaw('Comment 2 on field comment');
$this->assertRaw('Comment 1 on field comment_2');
// Return to page 1.
$this->drupalGet('node/' . $node->id());
// Navigate to next page of field 2.
- $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', array(':label' => 'Comment 1 on field comment_2'));
+ $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment_2']);
// Check only one pager updated.
$this->assertRaw('Comment 1 on field comment');
$this->assertRaw('Comment 2 on field comment_2');
// Navigate to next page of field 1.
- $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', array(':label' => 'Comment 1 on field comment'));
+ $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment']);
// Check only one pager updated.
$this->assertRaw('Comment 2 on field comment');
$this->assertRaw('Comment 2 on field comment_2');
@@ -405,15 +405,15 @@ class CommentPagerTest extends CommentTestBase {
*
* @see WebTestBase::clickLink()
*/
- protected function clickLinkWithXPath($xpath, $arguments = array(), $index = 0) {
+ protected function clickLinkWithXPath($xpath, $arguments = [], $index = 0) {
$url_before = $this->getUrl();
$urls = $this->xpath($xpath, $arguments);
if (isset($urls[$index])) {
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
- $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', array('%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
+ $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', ['%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before]), 'Browser');
return $this->drupalGet($url_target);
}
- $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', array('%label' => $xpath, '@url_before' => $url_before)), 'Browser');
+ $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', ['%label' => $xpath, '@url_before' => $url_before]), 'Browser');
return FALSE;
}
diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php
index 837a78aa940..039c6ab10ba 100644
--- a/core/modules/comment/src/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/src/Tests/CommentPreviewTest.php
@@ -41,7 +41,7 @@ class CommentPreviewTest extends CommentTestBase {
// Test escaping of the username on the preview form.
\Drupal::service('module_installer')->install(['user_hooks_test']);
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
- $edit = array();
+ $edit = [];
$edit['subject[0][value]'] = $this->randomMachineName(8);
$edit['comment_body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview'));
@@ -90,7 +90,7 @@ class CommentPreviewTest extends CommentTestBase {
$this->drupalLogin($this->webUser);
// As the web user, fill in the comment form and preview the comment.
- $edit = array();
+ $edit = [];
$edit['subject[0][value]'] = $this->randomMachineName(8);
$edit['comment_body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview'));
@@ -124,14 +124,14 @@ class CommentPreviewTest extends CommentTestBase {
* Tests comment edit, preview, and save.
*/
function testCommentEditPreviewSave() {
- $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'edit own comments'));
+ $web_user = $this->drupalCreateUser(['access comments', 'post comments', 'skip comment approval', 'edit own comments']);
$this->drupalLogin($this->adminUser);
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
- $edit = array();
+ $edit = [];
$date = new DrupalDateTime('2008-03-02 17:23');
$edit['subject[0][value]'] = $this->randomMachineName(8);
$edit['comment_body[0][value]'] = $this->randomMachineName(16);
@@ -172,7 +172,7 @@ class CommentPreviewTest extends CommentTestBase {
$this->assertFieldByName('date[time]', $expected_form_time, 'Time field displayed.');
// Submit the form using the displayed values.
- $displayed = array();
+ $displayed = [];
$displayed['subject[0][value]'] = (string) current($this->xpath("//input[@id='edit-subject-0-value']/@value"));
$displayed['comment_body[0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-0-value']"));
$displayed['uid'] = (string) current($this->xpath("//input[@id='edit-uid']/@value"));
@@ -182,7 +182,7 @@ class CommentPreviewTest extends CommentTestBase {
// Check that the saved comment is still correct.
$comment_storage = \Drupal::entityManager()->getStorage('comment');
- $comment_storage->resetCache(array($comment->id()));
+ $comment_storage->resetCache([$comment->id()]);
/** @var \Drupal\comment\CommentInterface $comment_loaded */
$comment_loaded = Comment::load($comment->id());
$this->assertEqual($comment_loaded->getSubject(), $edit['subject[0][value]'], 'Subject loaded.');
@@ -193,13 +193,13 @@ class CommentPreviewTest extends CommentTestBase {
// Check that the date and time of the comment are correct when edited by
// non-admin users.
- $user_edit = array();
+ $user_edit = [];
$expected_created_time = $comment_loaded->getCreatedTime();
$this->drupalLogin($web_user);
// Web user cannot change the comment author.
unset($edit['uid']);
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $user_edit, t('Save'));
- $comment_storage->resetCache(array($comment->id()));
+ $comment_storage->resetCache([$comment->id()]);
$comment_loaded = Comment::load($comment->id());
$this->assertEqual($comment_loaded->getCreatedTime(), $expected_created_time, 'Expected date and time for comment edited.');
$this->drupalLogout();
diff --git a/core/modules/comment/src/Tests/CommentRssTest.php b/core/modules/comment/src/Tests/CommentRssTest.php
index ec673dfb46e..5c9fe3d667f 100644
--- a/core/modules/comment/src/Tests/CommentRssTest.php
+++ b/core/modules/comment/src/Tests/CommentRssTest.php
@@ -21,7 +21,7 @@ class CommentRssTest extends CommentTestBase {
*
* @var array
*/
- public static $modules = array('views');
+ public static $modules = ['views'];
/**
* {@inheritdoc}
@@ -66,7 +66,7 @@ class CommentRssTest extends CommentTestBase {
'user:3',
]));
- $raw = '<comments>' . $this->node->url('canonical', array('fragment' => 'comments', 'absolute' => TRUE)) . '</comments>';
+ $raw = '<comments>' . $this->node->url('canonical', ['fragment' => 'comments', 'absolute' => TRUE]) . '</comments>';
$this->assertRaw($raw, 'Comments as part of RSS feed.');
// Hide comments from RSS feed and check presence.
diff --git a/core/modules/comment/src/Tests/CommentStatisticsTest.php b/core/modules/comment/src/Tests/CommentStatisticsTest.php
index 0c370d1127a..bd0838ca5d2 100644
--- a/core/modules/comment/src/Tests/CommentStatisticsTest.php
+++ b/core/modules/comment/src/Tests/CommentStatisticsTest.php
@@ -24,7 +24,7 @@ class CommentStatisticsTest extends CommentTestBase {
parent::setUp();
// Create a second user to post comments.
- $this->webUser2 = $this->drupalCreateUser(array(
+ $this->webUser2 = $this->drupalCreateUser([
'post comments',
'create article content',
'edit own comments',
@@ -32,7 +32,7 @@ class CommentStatisticsTest extends CommentTestBase {
'skip comment approval',
'access comments',
'access content',
- ));
+ ]);
}
/**
@@ -62,7 +62,7 @@ class CommentStatisticsTest extends CommentTestBase {
// Checks the new values of node comment statistics with comment #1.
// The node cache needs to be reset before reload.
- $node_storage->resetCache(array($this->node->id()));
+ $node_storage->resetCache([$this->node->id()]);
$node = $node_storage->load($this->node->id());
$this->assertEqual($node->get('comment')->last_comment_name, NULL, 'The value of node last_comment_name is NULL.');
$this->assertEqual($node->get('comment')->last_comment_uid, $this->webUser2->id(), 'The value of node last_comment_uid is the comment #1 uid.');
@@ -70,11 +70,11 @@ class CommentStatisticsTest extends CommentTestBase {
// Prepare for anonymous comment submission (comment approval enabled).
$this->drupalLogin($this->adminUser);
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => FALSE,
- ));
+ ]);
// Ensure that the poster can leave some contact info.
$this->setCommentAnonymous('1');
$this->drupalLogout();
@@ -86,7 +86,7 @@ class CommentStatisticsTest extends CommentTestBase {
// Checks the new values of node comment statistics with comment #2 and
// ensure they haven't changed since the comment has not been moderated.
// The node needs to be reloaded with the cache reset.
- $node_storage->resetCache(array($this->node->id()));
+ $node_storage->resetCache([$this->node->id()]);
$node = $node_storage->load($this->node->id());
$this->assertEqual($node->get('comment')->last_comment_name, NULL, 'The value of node last_comment_name is still NULL.');
$this->assertEqual($node->get('comment')->last_comment_uid, $this->webUser2->id(), 'The value of node last_comment_uid is still the comment #1 uid.');
@@ -94,21 +94,21 @@ class CommentStatisticsTest extends CommentTestBase {
// Prepare for anonymous comment submission (no approval required).
$this->drupalLogin($this->adminUser);
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => TRUE,
- ));
+ ]);
$this->drupalLogout();
// Post comment #3 as anonymous.
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
- $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', array('name' => $this->randomMachineName()));
+ $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', ['name' => $this->randomMachineName()]);
$comment_loaded = Comment::load($anonymous_comment->id());
// Checks the new values of node comment statistics with comment #3.
// The node needs to be reloaded with the cache reset.
- $node_storage->resetCache(array($this->node->id()));
+ $node_storage->resetCache([$this->node->id()]);
$node = $node_storage->load($this->node->id());
$this->assertEqual($node->get('comment')->last_comment_name, $comment_loaded->getAuthorName(), 'The value of node last_comment_name is the name of the anonymous user.');
$this->assertEqual($node->get('comment')->last_comment_uid, 0, 'The value of node last_comment_uid is zero.');
diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php
index c99dd32fc4f..716b3bd96fe 100644
--- a/core/modules/comment/src/Tests/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/CommentTestBase.php
@@ -52,11 +52,11 @@ abstract class CommentTestBase extends WebTestBase {
// child classes may specify the standard profile.
$types = NodeType::loadMultiple();
if (empty($types['article'])) {
- $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article')));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]);
}
// Create two test users.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer content types',
'administer comments',
'administer comment types',
@@ -69,21 +69,21 @@ abstract class CommentTestBase extends WebTestBase {
// permission is granted.
'access user profiles',
'access content',
- ));
- $this->webUser = $this->drupalCreateUser(array(
+ ]);
+ $this->webUser = $this->drupalCreateUser([
'access comments',
'post comments',
'create article content',
'edit own comments',
'skip comment approval',
'access content',
- ));
+ ]);
// Create comment field on article.
$this->addDefaultCommentField('node', 'article');
// Create a test node authored by the web user.
- $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()));
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
$this->drupalPlaceBlock('local_tasks_block');
}
@@ -107,7 +107,7 @@ abstract class CommentTestBase extends WebTestBase {
* The posted comment or NULL when posted comment was not found.
*/
public function postComment($entity, $comment, $subject = '', $contact = NULL, $field_name = 'comment') {
- $edit = array();
+ $edit = [];
$edit['comment_body[0][value]'] = $comment;
if ($entity !== NULL) {
@@ -154,7 +154,7 @@ abstract class CommentTestBase extends WebTestBase {
$this->drupalPostForm(NULL, $edit, t('Save'));
break;
}
- $match = array();
+ $match = [];
// Get comment ID
preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
@@ -168,7 +168,7 @@ abstract class CommentTestBase extends WebTestBase {
}
if (isset($match[1])) {
- \Drupal::entityManager()->getStorage('comment')->resetCache(array($match[1]));
+ \Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]);
return Comment::load($match[1]);
}
}
@@ -215,7 +215,7 @@ abstract class CommentTestBase extends WebTestBase {
* Comment to delete.
*/
function deleteComment(CommentInterface $comment) {
- $this->drupalPostForm('comment/' . $comment->id() . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('comment/' . $comment->id() . '/delete', [], t('Delete'));
$this->assertText(t('The comment and all its replies have been deleted.'), 'Comment deleted.');
}
@@ -228,9 +228,9 @@ abstract class CommentTestBase extends WebTestBase {
public function setCommentSubject($enabled) {
$form_display = entity_get_form_display('comment', 'comment', 'default');
if ($enabled) {
- $form_display->setComponent('subject', array(
+ $form_display->setComponent('subject', [
'type' => 'string_textfield',
- ));
+ ]);
}
else {
$form_display->removeComponent('subject');
@@ -263,7 +263,7 @@ abstract class CommentTestBase extends WebTestBase {
$mode_text = 'required';
break;
}
- $this->setCommentSettings('preview', $mode, format_string('Comment preview @mode_text.', array('@mode_text' => $mode_text)), $field_name);
+ $this->setCommentSettings('preview', $mode, format_string('Comment preview @mode_text.', ['@mode_text' => $mode_text]), $field_name);
}
/**
@@ -290,7 +290,7 @@ abstract class CommentTestBase extends WebTestBase {
* - 2: Contact information required.
*/
function setCommentAnonymous($level) {
- $this->setCommentSettings('anonymous', $level, format_string('Anonymous commenting set to level @level.', array('@level' => $level)));
+ $this->setCommentSettings('anonymous', $level, format_string('Anonymous commenting set to level @level.', ['@level' => $level]));
}
/**
@@ -303,7 +303,7 @@ abstract class CommentTestBase extends WebTestBase {
* Defaults to 'comment'.
*/
public function setCommentsPerPage($number, $field_name = 'comment') {
- $this->setCommentSettings('per_page', $number, format_string('Number of comments per page set to @number.', array('@number' => $number)), $field_name);
+ $this->setCommentSettings('per_page', $number, format_string('Number of comments per page set to @number.', ['@number' => $number]), $field_name);
}
/**
@@ -348,17 +348,17 @@ abstract class CommentTestBase extends WebTestBase {
* Operation is found on approval page.
*/
function performCommentOperation(CommentInterface $comment, $operation, $approval = FALSE) {
- $edit = array();
+ $edit = [];
$edit['operation'] = $operation;
$edit['comments[' . $comment->id() . ']'] = TRUE;
$this->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update'));
if ($operation == 'delete') {
- $this->drupalPostForm(NULL, array(), t('Delete comments'));
- $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+ $this->drupalPostForm(NULL, [], t('Delete comments'));
+ $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
}
else {
- $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation)));
+ $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
}
}
@@ -388,12 +388,12 @@ abstract class CommentTestBase extends WebTestBase {
* Created comment type.
*/
protected function createCommentType($label) {
- $bundle = CommentType::create(array(
+ $bundle = CommentType::create([
'id' => $label,
'label' => $label,
'description' => '',
'target_entity_type_id' => 'node',
- ));
+ ]);
$bundle->save();
return $bundle;
}
diff --git a/core/modules/comment/src/Tests/CommentTestTrait.php b/core/modules/comment/src/Tests/CommentTestTrait.php
index f22d80f8939..038a3df0910 100644
--- a/core/modules/comment/src/Tests/CommentTestTrait.php
+++ b/core/modules/comment/src/Tests/CommentTestTrait.php
@@ -43,12 +43,12 @@ trait CommentTestTrait {
}
}
else {
- $comment_type_storage->create(array(
+ $comment_type_storage->create([
'id' => $comment_type_id,
'label' => Unicode::ucfirst($comment_type_id),
'target_entity_type_id' => $entity_type,
'description' => 'Default comment field',
- ))->save();
+ ])->save();
}
// Add a body field to the comment type.
\Drupal::service('comment.manager')->addBodyField($comment_type_id);
@@ -56,43 +56,43 @@ trait CommentTestTrait {
// Add a comment field to the host entity type. Create the field storage if
// needed.
if (!array_key_exists($field_name, $entity_manager->getFieldStorageDefinitions($entity_type))) {
- $entity_manager->getStorage('field_storage_config')->create(array(
+ $entity_manager->getStorage('field_storage_config')->create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'comment',
'translatable' => TRUE,
- 'settings' => array(
+ 'settings' => [
'comment_type' => $comment_type_id,
- ),
- ))->save();
+ ],
+ ])->save();
}
// Create the field if needed, and configure its form and view displays.
if (!array_key_exists($field_name, $entity_manager->getFieldDefinitions($entity_type, $bundle))) {
- $entity_manager->getStorage('field_config')->create(array(
+ $entity_manager->getStorage('field_config')->create([
'label' => 'Comments',
'description' => '',
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
'required' => 1,
- 'default_value' => array(
- array(
+ 'default_value' => [
+ [
'status' => $default_value,
'cid' => 0,
'last_comment_name' => '',
'last_comment_timestamp' => 0,
'last_comment_uid' => 0,
- ),
- ),
- ))->save();
+ ],
+ ],
+ ])->save();
// Entity form displays: assign widget settings for the 'default' form
// mode, and hide the field in all other form modes.
entity_get_form_display($entity_type, $bundle, 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'comment_default',
'weight' => 20,
- ))
+ ])
->save();
foreach ($entity_manager->getFormModes($entity_type) as $id => $form_mode) {
$display = entity_get_form_display($entity_type, $bundle, $id);
@@ -105,12 +105,12 @@ trait CommentTestTrait {
// Entity view displays: assign widget settings for the 'default' view
// mode, and hide the field in all other view modes.
entity_get_display($entity_type, $bundle, 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'label' => 'above',
'type' => 'comment_default',
'weight' => 20,
- 'settings' => array('view_mode' => $comment_view_mode),
- ))
+ 'settings' => ['view_mode' => $comment_view_mode],
+ ])
->save();
foreach ($entity_manager->getViewModes($entity_type) as $id => $view_mode) {
$display = entity_get_display($entity_type, $bundle, $id);
diff --git a/core/modules/comment/src/Tests/CommentThreadingTest.php b/core/modules/comment/src/Tests/CommentThreadingTest.php
index c8ea93e276c..2dbf5bdea85 100644
--- a/core/modules/comment/src/Tests/CommentThreadingTest.php
+++ b/core/modules/comment/src/Tests/CommentThreadingTest.php
@@ -24,7 +24,7 @@ class CommentThreadingTest extends CommentTestBase {
// Create a node.
$this->drupalLogin($this->webUser);
- $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()));
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
// Post comment #1.
$this->drupalLogin($this->webUser);
@@ -139,10 +139,10 @@ class CommentThreadingTest extends CommentTestBase {
$this->assertFieldByXpath($pattern, NULL, format_string(
'Comment %cid has a link to parent %pid.',
- array(
+ [
'%cid' => $cid,
'%pid' => $pid,
- )
+ ]
));
}
@@ -162,9 +162,9 @@ class CommentThreadingTest extends CommentTestBase {
$pattern = "//a[@id='comment-$cid']/following-sibling::article//p[contains(@class, 'parent')]";
$this->assertNoFieldByXpath($pattern, NULL, format_string(
'Comment %cid does not have a link to a parent.',
- array(
+ [
'%cid' => $cid,
- )
+ ]
));
}
diff --git a/core/modules/comment/src/Tests/CommentTitleTest.php b/core/modules/comment/src/Tests/CommentTitleTest.php
index aab1cf5ec87..30d39357bac 100644
--- a/core/modules/comment/src/Tests/CommentTitleTest.php
+++ b/core/modules/comment/src/Tests/CommentTitleTest.php
@@ -14,7 +14,7 @@ class CommentTitleTest extends CommentTestBase {
*/
public function testCommentEmptyTitles() {
// Installs module that sets comments to an empty string.
- \Drupal::service('module_installer')->install(array('comment_empty_title_test'));
+ \Drupal::service('module_installer')->install(['comment_empty_title_test']);
// Set comments to have a subject with preview disabled.
$this->setCommentPreview(DRUPAL_DISABLED);
@@ -23,7 +23,7 @@ class CommentTitleTest extends CommentTestBase {
// Create a node.
$this->drupalLogin($this->webUser);
- $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()));
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
// Post comment #1 and verify that h3's are not rendered.
$subject_text = $this->randomMachineName();
@@ -49,7 +49,7 @@ class CommentTitleTest extends CommentTestBase {
// Create a node.
$this->drupalLogin($this->webUser);
- $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()));
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
// Post comment #1 and verify that title is rendered in h3.
$subject_text = $this->randomMachineName();
diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
index c7b72276a15..325aecb2daa 100644
--- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
+++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
@@ -32,10 +32,10 @@ class CommentTokenReplaceTest extends CommentTestBase {
function testCommentTokenReplacement() {
$token_service = \Drupal::token();
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
- $url_options = array(
+ $url_options = [
'absolute' => TRUE,
'language' => $language_interface,
- );
+ ];
// Setup vocabulary.
Vocabulary::create([
@@ -65,7 +65,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
$comment->setSubject('<blink>Blinking Comment</blink>');
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$tests['[comment:cid]'] = $comment->id();
$tests['[comment:hostname]'] = $comment->getHostname();
$tests['[comment:author]'] = Html::escape($comment->getAuthorName());
@@ -74,11 +74,11 @@ class CommentTokenReplaceTest extends CommentTestBase {
$tests['[comment:title]'] = Html::escape($comment->getSubject());
$tests['[comment:body]'] = $comment->comment_body->processed;
$tests['[comment:langcode]'] = $comment->language()->getId();
- $tests['[comment:url]'] = $comment->url('canonical', $url_options + array('fragment' => 'comment-' . $comment->id()));
+ $tests['[comment:url]'] = $comment->url('canonical', $url_options + ['fragment' => 'comment-' . $comment->id()]);
$tests['[comment:edit-url]'] = $comment->url('edit-form', $url_options);
- $tests['[comment:created]'] = \Drupal::service('date.formatter')->format($comment->getCreatedTime(), 'medium', array('langcode' => $language_interface->getId()));
- $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), array('langcode' => $language_interface->getId()));
- $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), array('langcode' => $language_interface->getId()));
+ $tests['[comment:created]'] = \Drupal::service('date.formatter')->format($comment->getCreatedTime(), 'medium', ['langcode' => $language_interface->getId()]);
+ $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), ['langcode' => $language_interface->getId()]);
+ $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), ['langcode' => $language_interface->getId()]);
$tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL;
$tests['[comment:parent:title]'] = $parent_comment->getSubject();
$tests['[comment:entity]'] = Html::escape($node->getTitle());
@@ -127,7 +127,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()), $bubbleable_metadata);
+ $output = $token_service->replace($input, ['comment' => $comment], ['langcode' => $language_interface->getId()], $bubbleable_metadata);
$this->assertEqual($output, $expected, new FormattableMarkup('Comment token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
@@ -136,8 +136,8 @@ class CommentTokenReplaceTest extends CommentTestBase {
$author_name = 'This is a random & " > string';
$comment->setOwnerId(0)->setAuthorName($author_name);
$input = '[comment:author]';
- $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()));
- $this->assertEqual($output, Html::escape($author_name), format_string('Comment author token %token replaced.', array('%token' => $input)));
+ $output = $token_service->replace($input, ['comment' => $comment], ['langcode' => $language_interface->getId()]);
+ $this->assertEqual($output, Html::escape($author_name), format_string('Comment author token %token replaced.', ['%token' => $input]));
// Add comment field to user and term entities.
$this->addDefaultCommentField('user', 'user', 'comment', CommentItemInterface::OPEN, 'comment_user');
$this->addDefaultCommentField('taxonomy_term', 'tags', 'comment', CommentItemInterface::OPEN, 'comment_term');
@@ -162,7 +162,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
// Generate comment tokens for node (it has 2 comments, both new),
// user and term.
- $tests = array();
+ $tests = [];
$tests['[entity:comment-count]'] = 2;
$tests['[entity:comment-count-new]'] = 2;
$tests['[node:comment-count]'] = 2;
diff --git a/core/modules/comment/src/Tests/CommentTranslationUITest.php b/core/modules/comment/src/Tests/CommentTranslationUITest.php
index e89bd3f3186..3157e23bddb 100644
--- a/core/modules/comment/src/Tests/CommentTranslationUITest.php
+++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php
@@ -46,7 +46,7 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'node', 'comment');
+ public static $modules = ['language', 'content_translation', 'node', 'comment'];
protected function setUp() {
$this->entityTypeId = 'comment';
@@ -62,11 +62,11 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
*/
function setupBundle() {
parent::setupBundle();
- $this->drupalCreateContentType(array('type' => $this->nodeBundle, 'name' => $this->nodeBundle));
+ $this->drupalCreateContentType(['type' => $this->nodeBundle, 'name' => $this->nodeBundle]);
// Add a comment field to the article content type.
$this->addDefaultCommentField('node', 'article', 'comment_article', CommentItemInterface::OPEN, 'comment_article');
// Create a page content type.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'page']);
// Add a comment field to the page content type - this one won't be
// translatable.
$this->addDefaultCommentField('node', 'page', 'comment');
@@ -78,7 +78,7 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('post comments', 'administer comments', 'access comments'));
+ return array_merge(parent::getTranslatorPermissions(), ['post comments', 'administer comments', 'access comments']);
}
/**
@@ -95,12 +95,12 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
$node_type = 'page';
$field_name = 'comment';
}
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'type' => $node_type,
- $field_name => array(
- array('status' => CommentItemInterface::OPEN)
- ),
- ));
+ $field_name => [
+ ['status' => CommentItemInterface::OPEN]
+ ],
+ ]);
$values['entity_id'] = $node->id();
$values['entity_type'] = 'node';
$values['field_name'] = $field_name;
@@ -113,10 +113,10 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
*/
protected function getNewEntityValues($langcode) {
// Comment subject is not translatable hence we use a fixed value.
- return array(
- 'subject' => array(array('value' => $this->subject)),
- 'comment_body' => array(array('value' => $this->randomMachineName(16))),
- ) + parent::getNewEntityValues($langcode);
+ return [
+ 'subject' => [['value' => $this->subject]],
+ 'comment_body' => [['value' => $this->randomMachineName(16)]],
+ ] + parent::getNewEntityValues($langcode);
}
/**
@@ -132,8 +132,8 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
// Unpublish translations.
foreach ($this->langcodes as $index => $langcode) {
if ($index > 0) {
- $edit = array('status' => 0);
- $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($langcode)));
+ $edit = ['status' => 0];
+ $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]);
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage->resetCache();
$entity = $storage->load($this->entityId);
@@ -151,21 +151,21 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
$languages = $this->container->get('language_manager')->getLanguages();
- $values = array();
+ $values = [];
// Post different authoring information for each translation.
foreach ($this->langcodes as $langcode) {
$url = $entity->urlInfo('edit-form', ['language' => $languages[$langcode]]);
$user = $this->drupalCreateUser();
- $values[$langcode] = array(
+ $values[$langcode] = [
'uid' => $user->id(),
'created' => REQUEST_TIME - mt_rand(0, 1000),
- );
- $edit = array(
+ ];
+ $edit = [
'uid' => $user->getUsername() . ' (' . $user->id() . ')',
'date[date]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d'),
'date[time]' => format_date($values[$langcode]['created'], 'custom', 'H:i:s'),
- );
+ ];
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
}
@@ -182,11 +182,11 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
* Tests translate link on comment content admin page.
*/
function testTranslateLinkCommentAdminPage() {
- $this->adminUser = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer comments', 'skip comment approval')));
+ $this->adminUser = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), ['access administration pages', 'administer comments', 'skip comment approval']));
$this->drupalLogin($this->adminUser);
- $cid_translatable = $this->createEntity(array(), $this->langcodes[0]);
- $cid_untranslatable = $this->createEntity(array(), $this->langcodes[0], 'comment');
+ $cid_translatable = $this->createEntity([], $this->langcodes[0]);
+ $cid_untranslatable = $this->createEntity([], $this->langcodes[0], 'comment');
// Verify translation links.
$this->drupalGet('admin/content/comment');
@@ -208,15 +208,15 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('Edit @type @title [%language translation]', array(
+ $title = t('Edit @type @title [%language translation]', [
'@type' => $this->entityTypeId,
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
diff --git a/core/modules/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/src/Tests/CommentTypeTest.php
index fb5028f719b..343bb9148c0 100644
--- a/core/modules/comment/src/Tests/CommentTypeTest.php
+++ b/core/modules/comment/src/Tests/CommentTypeTest.php
@@ -27,11 +27,11 @@ class CommentTypeTest extends CommentTestBase {
*
* @var array
*/
- protected $permissions = array(
+ protected $permissions = [
'administer comments',
'administer comment fields',
'administer comment types',
- );
+ ];
/**
* Sets the test up.
@@ -61,12 +61,12 @@ class CommentTypeTest extends CommentTestBase {
$this->assertResponse(200, 'The new comment type can be accessed at the edit form.');
// Create a comment type via the user interface.
- $edit = array(
+ $edit = [
'id' => 'foo',
'label' => 'title for foo',
'description' => '',
'target_entity_type_id' => 'node',
- );
+ ];
$this->drupalPostForm('admin/structure/comment/types/add', $edit, t('Save'));
$comment_type = CommentType::load('foo');
$this->assertTrue($comment_type, 'The new comment type has been created.');
@@ -81,8 +81,8 @@ class CommentTypeTest extends CommentTestBase {
$this->assertText(t('Target entity type'));
// Save the form and ensure the entity-type value is preserved even though
// the field isn't present.
- $this->drupalPostForm(NULL, array(), t('Save'));
- \Drupal::entityManager()->getStorage('comment_type')->resetCache(array('foo'));
+ $this->drupalPostForm(NULL, [], t('Save'));
+ \Drupal::entityManager()->getStorage('comment_type')->resetCache(['foo']);
$comment_type = CommentType::load('foo');
$this->assertEqual($comment_type->getTargetEntityTypeId(), 'node');
}
@@ -98,9 +98,9 @@ class CommentTypeTest extends CommentTestBase {
// Change the comment type name.
$this->drupalGet('admin/structure/comment');
- $edit = array(
+ $edit = [
'label' => 'Bar',
- );
+ ];
$this->drupalPostForm('admin/structure/comment/manage/comment', $edit, t('Save'));
$this->drupalGet('admin/structure/comment');
@@ -110,9 +110,9 @@ class CommentTypeTest extends CommentTestBase {
$this->assertTrue($this->cssSelect('tr#comment-body'), 'Body field exists.');
// Remove the body field.
- $this->drupalPostForm('admin/structure/comment/manage/comment/fields/comment.comment.comment_body/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/structure/comment/manage/comment/fields/comment.comment.comment_body/delete', [], t('Delete'));
// Resave the settings for this type.
- $this->drupalPostForm('admin/structure/comment/manage/comment', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/comment/manage/comment', [], t('Save'));
// Check that the body field doesn't exist.
$this->drupalGet('admin/structure/comment/manage/comment/fields');
$this->assertFalse($this->cssSelect('tr#comment-body'), 'Body field does not exist.');
@@ -124,39 +124,39 @@ class CommentTypeTest extends CommentTestBase {
public function testCommentTypeDeletion() {
// Create a comment type programmatically.
$type = $this->createCommentType('foo');
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
$this->addDefaultCommentField('node', 'page', 'foo', CommentItemInterface::OPEN, 'foo');
$field_storage = FieldStorageConfig::loadByName('node', 'foo');
$this->drupalLogin($this->adminUser);
// Create a node.
- $node = Node::create(array(
+ $node = Node::create([
'type' => 'page',
'title' => 'foo',
- ));
+ ]);
$node->save();
// Add a new comment of this type.
- $comment = Comment::create(array(
+ $comment = Comment::create([
'comment_type' => 'foo',
'entity_type' => 'node',
'field_name' => 'foo',
'entity_id' => $node->id(),
- ));
+ ]);
$comment->save();
// Attempt to delete the comment type, which should not be allowed.
$this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
$this->assertRaw(
- t('%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', array('%label' => $type->label())),
+ t('%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', ['%label' => $type->label()]),
'The comment type will not be deleted until all comments of that type are removed.'
);
$this->assertRaw(
- t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array(
+ t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [
'%label' => 'foo',
'%field' => 'node.foo',
- )),
+ ]),
'The comment type will not be deleted until all fields of that type are removed.'
);
$this->assertNoText(t('This action cannot be undone.'), 'The comment type deletion confirmation form is not available.');
@@ -167,7 +167,7 @@ class CommentTypeTest extends CommentTestBase {
// Attempt to delete the comment type, which should now be allowed.
$this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
$this->assertRaw(
- t('Are you sure you want to delete the comment type %type?', array('%type' => $type->id())),
+ t('Are you sure you want to delete the comment type %type?', ['%type' => $type->id()]),
'The comment type is available for deletion.'
);
$this->assertText(t('This action cannot be undone.'), 'The comment type deletion confirmation form is available.');
@@ -182,9 +182,9 @@ class CommentTypeTest extends CommentTestBase {
}
// Delete the comment type.
- $this->drupalPostForm('admin/structure/comment/manage/' . $type->id() . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/structure/comment/manage/' . $type->id() . '/delete', [], t('Delete'));
$this->assertNull(CommentType::load($type->id()), 'Comment type deleted.');
- $this->assertRaw(t('The comment type %label has been deleted.', array('%label' => $type->label())));
+ $this->assertRaw(t('The comment type %label has been deleted.', ['%label' => $type->label()]));
}
}
diff --git a/core/modules/comment/src/Tests/CommentUninstallTest.php b/core/modules/comment/src/Tests/CommentUninstallTest.php
index 4d86df94790..9f9d36ad012 100644
--- a/core/modules/comment/src/Tests/CommentUninstallTest.php
+++ b/core/modules/comment/src/Tests/CommentUninstallTest.php
@@ -20,13 +20,13 @@ class CommentUninstallTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('comment', 'node');
+ public static $modules = ['comment', 'node'];
protected function setUp() {
parent::setup();
// Create an article content type.
- $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article')));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]);
// Create comment field on article so that adds 'comment_body' field.
$this->addDefaultCommentField('node', 'article');
}
@@ -43,7 +43,7 @@ class CommentUninstallTest extends WebTestBase {
// Uninstall the comment module which should trigger an exception.
try {
- $this->container->get('module_installer')->uninstall(array('comment'));
+ $this->container->get('module_installer')->uninstall(['comment']);
$this->fail("Expected an exception when uninstall was attempted.");
}
catch (ModuleUninstallValidatorException $e) {
@@ -77,7 +77,7 @@ class CommentUninstallTest extends WebTestBase {
field_purge_batch(10);
// Ensure that uninstallation succeeds even if the field has already been
// deleted manually beforehand.
- $this->container->get('module_installer')->uninstall(array('comment'));
+ $this->container->get('module_installer')->uninstall(['comment']);
}
}
diff --git a/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php b/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php
index 63a008277cf..3365918ff95 100644
--- a/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php
+++ b/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php
@@ -18,7 +18,7 @@ class ArgumentUserUIDTest extends CommentTestBase {
*
* @var array
*/
- public static $testViews = array('test_comment_user_uid');
+ public static $testViews = ['test_comment_user_uid'];
function testCommentUserUIDTest() {
// Add an additional comment which is not created by the user.
@@ -35,16 +35,16 @@ class ArgumentUserUIDTest extends CommentTestBase {
$comment->save();
$view = Views::getView('test_comment_user_uid');
- $this->executeView($view, array($this->account->id()));
- $result_set = array(
- array(
+ $this->executeView($view, [$this->account->id()]);
+ $result_set = [
+ [
'nid' => $this->nodeUserPosted->id(),
- ),
- array(
+ ],
+ [
'nid' => $this->nodeUserCommented->id(),
- ),
- );
- $column_map = array('nid' => 'nid');
+ ],
+ ];
+ $column_map = ['nid' => 'nid'];
$this->assertIdenticalResultset($view, $result_set, $column_map);
}
diff --git a/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php b/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php
index c0cf374762b..040fc7dadb1 100644
--- a/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php
+++ b/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php
@@ -15,21 +15,21 @@ class CommentFieldFilterTest extends CommentTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_field_filters');
+ public static $testViews = ['test_field_filters'];
/**
* List of comment titles by language.
*
* @var array
*/
- public $commentTitles = array();
+ public $commentTitles = [];
function setUp() {
parent::setUp();
@@ -40,15 +40,15 @@ class CommentFieldFilterTest extends CommentTestBase {
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up comment titles.
- $this->commentTitles = array(
+ $this->commentTitles = [
'en' => 'Food in Paris',
'es' => 'Comida en Paris',
'fr' => 'Nouriture en Paris',
- );
+ ];
// Create a new comment. Using the one created earlier will not work,
// as it predates the language set-up.
- $comment = array(
+ $comment = [
'uid' => $this->loggedInUser->id(),
'entity_id' => $this->nodeUserCommented->id(),
'entity_type' => 'node',
@@ -56,7 +56,7 @@ class CommentFieldFilterTest extends CommentTestBase {
'cid' => '',
'pid' => '',
'node_type' => '',
- );
+ ];
$this->comment = Comment::create($comment);
// Add field values and translate the comment.
@@ -64,8 +64,8 @@ class CommentFieldFilterTest extends CommentTestBase {
$this->comment->comment_body->value = $this->commentTitles['en'];
$this->comment->langcode = 'en';
$this->comment->save();
- foreach (array('es', 'fr') as $langcode) {
- $translation = $this->comment->addTranslation($langcode, array());
+ foreach (['es', 'fr'] as $langcode) {
+ $translation = $this->comment->addTranslation($langcode, []);
$translation->comment_body->value = $this->commentTitles[$langcode];
$translation->subject->value = $this->commentTitles[$langcode];
}
@@ -78,19 +78,19 @@ class CommentFieldFilterTest extends CommentTestBase {
public function testFilters() {
// Test the title filter page, which filters for title contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-title-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida title filter');
+ $this->assertPageCounts('test-title-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida title filter');
// Test the body filter page, which filters for body contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-body-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida body filter');
+ $this->assertPageCounts('test-body-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida body filter');
// Test the title Paris filter page, which filters for title contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-title-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris title filter');
+ $this->assertPageCounts('test-title-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris title filter');
// Test the body Paris filter page, which filters for body contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-body-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris body filter');
+ $this->assertPageCounts('test-body-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris body filter');
}
/**
diff --git a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php b/core/modules/comment/src/Tests/Views/CommentRestExportTest.php
index a3d7e2dcc2e..ed7ce55e355 100644
--- a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php
+++ b/core/modules/comment/src/Tests/Views/CommentRestExportTest.php
@@ -27,7 +27,7 @@ class CommentRestExportTest extends CommentTestBase {
protected function setUp() {
parent::setUp();
// Add another anonymous comment.
- $comment = array(
+ $comment = [
'uid' => 0,
'entity_id' => $this->nodeUserCommented->id(),
'entity_type' => 'node',
@@ -38,7 +38,7 @@ class CommentRestExportTest extends CommentTestBase {
'mail' => 'someone@example.com',
'name' => 'bobby tables',
'hostname' => 'public.example.com',
- );
+ ];
$this->comment = Comment::create($comment);
$this->comment->save();
diff --git a/core/modules/comment/src/Tests/Views/CommentRowTest.php b/core/modules/comment/src/Tests/Views/CommentRowTest.php
index e96869c0b27..d73811e51e0 100644
--- a/core/modules/comment/src/Tests/Views/CommentRowTest.php
+++ b/core/modules/comment/src/Tests/Views/CommentRowTest.php
@@ -14,7 +14,7 @@ class CommentRowTest extends CommentTestBase {
*
* @var array
*/
- public static $testViews = array('test_comment_row');
+ public static $testViews = ['test_comment_row'];
/**
* Test comment row.
diff --git a/core/modules/comment/src/Tests/Views/CommentTestBase.php b/core/modules/comment/src/Tests/Views/CommentTestBase.php
index d687488b537..d7bec048126 100644
--- a/core/modules/comment/src/Tests/Views/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
@@ -19,7 +19,7 @@ abstract class CommentTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment', 'comment_test_views');
+ public static $modules = ['node', 'comment', 'comment_test_views'];
/**
* A normal user with permission to post comments (without approval).
@@ -59,21 +59,21 @@ abstract class CommentTestBase extends ViewTestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('comment_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
// Add two users, create a node with the user1 as author and another node
// with user2 as author. For the second node add a comment from user1.
- $this->account = $this->drupalCreateUser(array('skip comment approval'));
+ $this->account = $this->drupalCreateUser(['skip comment approval']);
$this->account2 = $this->drupalCreateUser();
$this->drupalLogin($this->account);
- $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page')));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
$this->addDefaultCommentField('node', 'page');
$this->nodeUserPosted = $this->drupalCreateNode();
- $this->nodeUserCommented = $this->drupalCreateNode(array('uid' => $this->account2->id()));
+ $this->nodeUserCommented = $this->drupalCreateNode(['uid' => $this->account2->id()]);
- $comment = array(
+ $comment = [
'uid' => $this->loggedInUser->id(),
'entity_id' => $this->nodeUserCommented->id(),
'entity_type' => 'node',
@@ -82,7 +82,7 @@ abstract class CommentTestBase extends ViewTestBase {
'cid' => '',
'pid' => '',
'mail' => 'someone@example.com',
- );
+ ];
$this->comment = Comment::create($comment);
$this->comment->save();
}
diff --git a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php b/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
index ff151c68b66..3e5f26b0e84 100644
--- a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
+++ b/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
@@ -22,7 +22,7 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment', 'block');
+ public static $modules = ['node', 'comment', 'block'];
/**
* Number of results for the Master display.
@@ -50,7 +50,7 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
*
* @var array
*/
- protected $commentsCreated = array();
+ protected $commentsCreated = [];
/**
* Contains the node object used for comments of this test.
@@ -66,9 +66,9 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
$content_type = $this->drupalCreateContentType();
// Add a node of the new content type.
- $node_data = array(
+ $node_data = [
'type' => $content_type->id(),
- );
+ ];
$this->addDefaultCommentField('node', $content_type->id());
$this->node = $this->drupalCreateNode($node_data);
@@ -79,12 +79,12 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
// Create some comments and attach them to the created node.
for ($i = 0; $i < $this->masterDisplayResults; $i++) {
/** @var \Drupal\comment\CommentInterface $comment */
- $comment = Comment::create(array(
+ $comment = Comment::create([
'status' => CommentInterface::PUBLISHED,
'field_name' => 'comment',
'entity_type' => 'node',
'entity_id' => $this->node->id(),
- ));
+ ]);
$comment->setOwnerId(0);
$comment->setSubject('Test comment ' . $i);
$comment->comment_body->value = 'Test body ' . $i;
@@ -116,12 +116,12 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
$view->setDisplay('block_1');
$this->executeView($view);
- $map = array(
+ $map = [
'subject' => 'subject',
'cid' => 'cid',
'comment_field_data_created' => 'created'
- );
- $expected_result = array();
+ ];
+ $expected_result = [];
foreach (array_values($this->commentsCreated) as $key => $comment) {
$expected_result[$key]['subject'] = $comment->getSubject();
$expected_result[$key]['cid'] = $comment->id();
@@ -132,7 +132,7 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
// Check the number of results given by the display is the expected.
$this->assertEqual(sizeof($view->result), $this->blockDisplayResults,
format_string('There are exactly @results comments. Expected @expected',
- array('@results' => count($view->result), '@expected' => $this->blockDisplayResults)
+ ['@results' => count($view->result), '@expected' => $this->blockDisplayResults]
)
);
}
diff --git a/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php b/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php
index ee8281b50c4..c4570cee328 100644
--- a/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php
+++ b/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php
@@ -20,7 +20,7 @@ class FilterUserUIDTest extends CommentTestBase {
*
* @var array
*/
- public static $testViews = array('test_comment_user_uid');
+ public static $testViews = ['test_comment_user_uid'];
function testCommentUserUIDTest() {
$view = Views::getView('test_comment_user_uid');
@@ -40,23 +40,23 @@ class FilterUserUIDTest extends CommentTestBase {
]);
$comment->save();
- $options = array(
+ $options = [
'id' => 'uid_touch',
'table' => 'node_field_data',
'field' => 'uid_touch',
- 'value' => array($this->loggedInUser->id()),
- );
+ 'value' => [$this->loggedInUser->id()],
+ ];
$view->addHandler('default', 'filter', 'node_field_data', 'uid_touch', $options);
- $this->executeView($view, array($this->account->id()));
- $result_set = array(
- array(
+ $this->executeView($view, [$this->account->id()]);
+ $result_set = [
+ [
'nid' => $this->nodeUserPosted->id(),
- ),
- array(
+ ],
+ [
'nid' => $this->nodeUserCommented->id(),
- ),
- );
- $column_map = array('nid' => 'nid');
+ ],
+ ];
+ $column_map = ['nid' => 'nid'];
$this->assertIdenticalResultset($view, $result_set, $column_map);
}
diff --git a/core/modules/comment/src/Tests/Views/RowRssTest.php b/core/modules/comment/src/Tests/Views/RowRssTest.php
index 85bd34fb687..343b797cf5c 100644
--- a/core/modules/comment/src/Tests/Views/RowRssTest.php
+++ b/core/modules/comment/src/Tests/Views/RowRssTest.php
@@ -15,7 +15,7 @@ class RowRssTest extends CommentTestBase {
*
* @var array
*/
- public static $testViews = array('test_comment_rss');
+ public static $testViews = ['test_comment_rss'];
/**
* Test comment rss output.
diff --git a/core/modules/comment/src/Tests/Views/WizardTest.php b/core/modules/comment/src/Tests/Views/WizardTest.php
index 885ce2cf469..a7f14c82eaa 100644
--- a/core/modules/comment/src/Tests/Views/WizardTest.php
+++ b/core/modules/comment/src/Tests/Views/WizardTest.php
@@ -21,7 +21,7 @@ class WizardTest extends WizardTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment');
+ public static $modules = ['node', 'comment'];
/**
@@ -29,7 +29,7 @@ class WizardTest extends WizardTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page')));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
// Add comment field to page node type.
$this->addDefaultCommentField('node', 'page');
}
@@ -38,7 +38,7 @@ class WizardTest extends WizardTestBase {
* Tests adding a view of comments.
*/
public function testCommentWizard() {
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['show[wizard_key]'] = 'comment';
@@ -48,7 +48,7 @@ class WizardTest extends WizardTestBase {
// Just triggering the saving should automatically choose a proper row
// plugin.
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
- $this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
+ $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
// If we update the type first we should get a selection of comment valid
// row plugins as the select field.
@@ -59,19 +59,19 @@ class WizardTest extends WizardTestBase {
// Check for available options of the row plugin.
$xpath = $this->constructFieldXpath('name', 'page[style][row_plugin]');
$fields = $this->xpath($xpath);
- $options = array();
+ $options = [];
foreach ($fields as $field) {
$items = $this->getAllOptions($field);
foreach ($items as $item) {
$options[] = $item->attributes()->value;
}
}
- $expected_options = array('entity:comment', 'fields');
+ $expected_options = ['entity:comment', 'fields'];
$this->assertEqual($options, $expected_options);
$view['id'] = strtolower($this->randomMachineName(16));
$this->drupalPostForm(NULL, $view, t('Save and edit'));
- $this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
+ $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
$user = $this->drupalCreateUser(['access comments']);
$this->drupalLogin($user);
diff --git a/core/modules/comment/tests/modules/comment_test/comment_test.module b/core/modules/comment/tests/modules/comment_test/comment_test.module
index d54814ba1c4..b1cca02f25d 100644
--- a/core/modules/comment/tests/modules/comment_test/comment_test.module
+++ b/core/modules/comment/tests/modules/comment_test/comment_test.module
@@ -31,14 +31,14 @@ function comment_test_comment_links_alter(array &$links, CommentInterface &$enti
return;
}
- $links['comment_test'] = array(
+ $links['comment_test'] = [
'#theme' => 'links__comment__comment_test',
- '#attributes' => array('class' => array('links', 'inline')),
- '#links' => array(
- 'comment-report' => array(
+ '#attributes' => ['class' => ['links', 'inline']],
+ '#links' => [
+ 'comment-report' => [
'title' => t('Report'),
'url' => Url::fromRoute('comment_test.report', ['comment' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("comment/{$entity->id()}/report")]]),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
diff --git a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php
index a95088e9417..bdea71df15f 100644
--- a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php
+++ b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php
@@ -26,7 +26,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('entity_test', 'comment');
+ public static $modules = ['entity_test', 'comment'];
/**
* {@inheritdoc}
@@ -48,11 +48,11 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
// user does not have access to the 'administer comments' permission, to
// ensure only published comments are visible to the end user.
$current_user = $this->container->get('current_user');
- $current_user->setAccount($this->createUser(array(), array('access comments')));
+ $current_user->setAccount($this->createUser([], ['access comments']));
// Install tables and config needed to render comments.
- $this->installSchema('comment', array('comment_entity_statistics'));
- $this->installConfig(array('system', 'filter', 'comment'));
+ $this->installSchema('comment', ['comment_entity_statistics']);
+ $this->installConfig(['system', 'filter', 'comment']);
// Comment rendering generates links, so build the router.
$this->container->get('router.builder')->rebuild();
@@ -70,7 +70,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
$renderer = $this->container->get('renderer');
// Create the entity that will be commented upon.
- $commented_entity = EntityTest::create(array('name' => $this->randomMachineName()));
+ $commented_entity = EntityTest::create(['name' => $this->randomMachineName()]);
$commented_entity->save();
// Verify cache tags on the rendered entity before it has comments.
@@ -94,19 +94,19 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
// also exists in the {users} table.
$user = $this->createUser();
$user->save();
- $comment = Comment::create(array(
+ $comment = Comment::create([
'subject' => 'Llama',
- 'comment_body' => array(
+ 'comment_body' => [
'value' => 'Llamas are cool!',
'format' => 'plain_text',
- ),
+ ],
'entity_id' => $commented_entity->id(),
'entity_type' => 'entity_test',
'field_name' => 'comment',
'comment_type' => 'comment',
'status' => CommentInterface::PUBLISHED,
'uid' => $user->id(),
- ));
+ ]);
$comment->save();
// Load commented entity so comment_count gets computed.
diff --git a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php
index 674c7f3e331..5046353302e 100644
--- a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php
+++ b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php
@@ -29,30 +29,30 @@ class CommentFieldAccessTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('comment', 'entity_test', 'user');
+ public static $modules = ['comment', 'entity_test', 'user'];
/**
* Fields that only users with administer comments permissions can change.
*
* @var array
*/
- protected $administrativeFields = array(
+ protected $administrativeFields = [
'uid',
'status',
'created',
- );
+ ];
/**
* These fields are automatically managed and can not be changed by any user.
*
* @var array
*/
- protected $readOnlyFields = array(
+ protected $readOnlyFields = [
'changed',
'hostname',
'cid',
'thread',
- );
+ ];
/**
* These fields can be edited on create only.
@@ -73,19 +73,19 @@ class CommentFieldAccessTest extends EntityKernelTestBase {
*
* @var array
*/
- protected $contactFields = array(
+ protected $contactFields = [
'name',
'mail',
'homepage',
- );
+ ];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('user', 'comment'));
- $this->installSchema('comment', array('comment_entity_statistics'));
+ $this->installConfig(['user', 'comment']);
+ $this->installSchema('comment', ['comment_entity_statistics']);
}
/**
diff --git a/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php b/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php
index ed56cc9aedf..adbe1b08d5e 100644
--- a/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php
+++ b/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php
@@ -18,21 +18,21 @@ class CommentStringIdEntitiesTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'comment',
'user',
'field',
'field_ui',
'entity_test',
'text',
- );
+ ];
protected function setUp() {
parent::setUp();
$this->installEntitySchema('comment');
- $this->installSchema('comment', array('comment_entity_statistics'));
+ $this->installSchema('comment', ['comment_entity_statistics']);
// Create the comment body field storage.
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
}
/**
@@ -40,21 +40,21 @@ class CommentStringIdEntitiesTest extends KernelTestBase {
*/
public function testCommentFieldNonStringId() {
try {
- $bundle = CommentType::create(array(
+ $bundle = CommentType::create([
'id' => 'foo',
'label' => 'foo',
'description' => '',
'target_entity_type_id' => 'entity_test_string_id',
- ));
+ ]);
$bundle->save();
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'foo',
'entity_type' => 'entity_test_string_id',
- 'settings' => array(
+ 'settings' => [
'comment_type' => 'entity_test_string_id',
- ),
+ ],
'type' => 'comment',
- ));
+ ]);
$field_storage->save();
$this->fail('Did not throw an exception as expected.');
}
diff --git a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php
index eb37006ac47..98b771513b9 100644
--- a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php
+++ b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php
@@ -19,14 +19,14 @@ class CommentValidationTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('comment', 'node');
+ public static $modules = ['comment', 'node'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installSchema('comment', array('comment_entity_statistics'));
+ $this->installSchema('comment', ['comment_entity_statistics']);
}
/**
@@ -34,54 +34,54 @@ class CommentValidationTest extends EntityKernelTestBase {
*/
public function testValidation() {
// Add a user.
- $user = User::create(array('name' => 'test', 'status' => TRUE));
+ $user = User::create(['name' => 'test', 'status' => TRUE]);
$user->save();
// Add comment type.
- $this->entityManager->getStorage('comment_type')->create(array(
+ $this->entityManager->getStorage('comment_type')->create([
'id' => 'comment',
'label' => 'comment',
'target_entity_type_id' => 'node',
- ))->save();
+ ])->save();
// Add comment field to content.
- $this->entityManager->getStorage('field_storage_config')->create(array(
+ $this->entityManager->getStorage('field_storage_config')->create([
'entity_type' => 'node',
'field_name' => 'comment',
'type' => 'comment',
- 'settings' => array(
+ 'settings' => [
'comment_type' => 'comment',
- )
- ))->save();
+ ]
+ ])->save();
// Create a page node type.
- $this->entityManager->getStorage('node_type')->create(array(
+ $this->entityManager->getStorage('node_type')->create([
'type' => 'page',
'name' => 'page',
- ))->save();
+ ])->save();
// Add comment field to page content.
/** @var \Drupal\field\FieldConfigInterface $field */
- $field = $this->entityManager->getStorage('field_config')->create(array(
+ $field = $this->entityManager->getStorage('field_config')->create([
'field_name' => 'comment',
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'Comment settings',
- ));
+ ]);
$field->save();
- $node = $this->entityManager->getStorage('node')->create(array(
+ $node = $this->entityManager->getStorage('node')->create([
'type' => 'page',
'title' => 'test',
- ));
+ ]);
$node->save();
- $comment = $this->entityManager->getStorage('comment')->create(array(
+ $comment = $this->entityManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'comment_body' => $this->randomMachineName(),
- ));
+ ]);
$violations = $comment->validate();
$this->assertEqual(count($violations), 0, 'No violations when validating a default comment.');
@@ -101,7 +101,7 @@ class CommentValidationTest extends EntityKernelTestBase {
$violations = $comment->validate();
$this->assertEqual(count($violations), 1, "Violation found on author name collision");
$this->assertEqual($violations[0]->getPropertyPath(), "name");
- $this->assertEqual($violations[0]->getMessage(), t('The name you used (%name) belongs to a registered user.', array('%name' => 'test')));
+ $this->assertEqual($violations[0]->getMessage(), t('The name you used (%name) belongs to a registered user.', ['%name' => 'test']));
// Make the name valid.
$comment->set('name', 'valid unused name');
@@ -141,39 +141,39 @@ class CommentValidationTest extends EntityKernelTestBase {
\Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
$node = Node::load($node->id());
// Create a new comment with the new field.
- $comment = $this->entityManager->getStorage('comment')->create(array(
+ $comment = $this->entityManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'comment_body' => $this->randomMachineName(),
'uid' => 0,
'name' => '',
- ));
+ ]);
$violations = $comment->validate();
$this->assertEqual(count($violations), 1, 'Violation found when name is required, but empty and UID is anonymous.');
$this->assertEqual($violations[0]->getPropertyPath(), 'name');
$this->assertEqual($violations[0]->getMessage(), t('You have to specify a valid author.'));
// Test creating a default comment with a given user id works.
- $comment = $this->entityManager->getStorage('comment')->create(array(
+ $comment = $this->entityManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'comment_body' => $this->randomMachineName(),
'uid' => $user->id(),
- ));
+ ]);
$violations = $comment->validate();
$this->assertEqual(count($violations), 0, 'No violations when validating a default comment with an author.');
// Test specifying a wrong author name does not work.
- $comment = $this->entityManager->getStorage('comment')->create(array(
+ $comment = $this->entityManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'comment_body' => $this->randomMachineName(),
'uid' => $user->id(),
'name' => 'not-test',
- ));
+ ]);
$violations = $comment->validate();
$this->assertEqual(count($violations), 1, 'Violation found when author name and comment author do not match.');
$this->assertEqual($violations[0]->getPropertyPath(), 'name');
@@ -195,7 +195,7 @@ class CommentValidationTest extends EntityKernelTestBase {
$this->assertEqual(count($violations), 1, "Violation found when $field_name is too long.");
$this->assertEqual($violations[0]->getPropertyPath(), "$field_name.0.value");
$field_label = $comment->get($field_name)->getFieldDefinition()->getLabel();
- $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => $length)));
+ $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => $field_label, '@max' => $length]));
}
}
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php b/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php
index b5fc4fe34a4..0b256ea51a2 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php
@@ -33,11 +33,11 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase {
$storage = \Drupal::entityManager()->getStorage('user');
// Insert a row for the anonymous user.
$storage
- ->create(array(
+ ->create([
'uid' => 0,
'status' => 0,
'name' => '',
- ))
+ ])
->save();
// Need at least one node type and comment type present.
NodeType::create([
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
index 4d4df032e4a..f1e094f39b8 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
@@ -34,11 +34,11 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
$this->executeMigration('d7_node_type');
// We only need the test_content_type node migration to run for real, so
// mock all the others.
- $this->prepareMigrations(array(
- 'd7_node' => array(
- array(array(0), array(0)),
- ),
- ));
+ $this->prepareMigrations([
+ 'd7_node' => [
+ [[0], [0]],
+ ],
+ ]);
$this->executeMigrations([
'd7_node',
'd7_comment_type',
diff --git a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php
index dae2c480cff..cad7b2b9815 100644
--- a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php
+++ b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php
@@ -43,11 +43,11 @@ class CommentUserNameTest extends ViewsKernelTestBase {
$storage = \Drupal::entityManager()->getStorage('user');
// Insert a row for the anonymous user.
$storage
- ->create(array(
+ ->create([
'uid' => 0,
'name' => '',
'status' => 0,
- ))
+ ])
->save();
$admin_role = Role::create([
diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
index 61e93a11271..18da223d9a1 100644
--- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
@@ -75,9 +75,9 @@ class CommentLinkBuilderTest extends UnitTestCase {
$this->commentManager->expects($this->any())
->method('getFields')
->with('node')
- ->willReturn(array(
- 'comment' => array(),
- ));
+ ->willReturn([
+ 'comment' => [],
+ ]);
$this->commentManager->expects($this->any())
->method('forbiddenMessage')
->willReturn("Can't let you do that Dave.");
@@ -116,10 +116,10 @@ class CommentLinkBuilderTest extends UnitTestCase {
->willReturn($history_exists);
$this->currentUser->expects($this->any())
->method('hasPermission')
- ->willReturnMap(array(
- array('access comments', $has_access_comments),
- array('post comments', $has_post_comments),
- ));
+ ->willReturnMap([
+ ['access comments', $has_access_comments],
+ ['post comments', $has_post_comments],
+ ]);
$this->currentUser->expects($this->any())
->method('isAuthenticated')
->willReturn(!$is_anonymous);
@@ -155,57 +155,57 @@ class CommentLinkBuilderTest extends UnitTestCase {
* Data provider for ::testCommentLinkBuilder.
*/
public function getLinkCombinations() {
- $cases = array();
+ $cases = [];
// No links should be created if the entity doesn't have the field.
- $cases[] = array(
+ $cases[] = [
$this->getMockNode(FALSE, CommentItemInterface::OPEN, CommentItemInterface::FORM_BELOW, 1),
- array('view_mode' => 'teaser'),
+ ['view_mode' => 'teaser'],
TRUE,
TRUE,
TRUE,
TRUE,
- array(),
- );
- foreach (array('search_result', 'search_index', 'print') as $view_mode) {
+ [],
+ ];
+ foreach (['search_result', 'search_index', 'print'] as $view_mode) {
// Nothing should be output in these view modes.
- $cases[] = array(
+ $cases[] = [
$this->getMockNode(TRUE, CommentItemInterface::OPEN, CommentItemInterface::FORM_BELOW, 1),
- array('view_mode' => $view_mode),
+ ['view_mode' => $view_mode],
TRUE,
TRUE,
TRUE,
TRUE,
- array(),
- );
+ [],
+ ];
}
// All other combinations.
- $combinations = array(
- 'is_anonymous' => array(FALSE, TRUE),
- 'comment_count' => array(0, 1),
- 'has_access_comments' => array(0, 1),
- 'history_exists' => array(FALSE, TRUE),
- 'has_post_comments' => array(0, 1),
- 'form_location' => array(CommentItemInterface::FORM_BELOW, CommentItemInterface::FORM_SEPARATE_PAGE),
- 'comments' => array(
+ $combinations = [
+ 'is_anonymous' => [FALSE, TRUE],
+ 'comment_count' => [0, 1],
+ 'has_access_comments' => [0, 1],
+ 'history_exists' => [FALSE, TRUE],
+ 'has_post_comments' => [0, 1],
+ 'form_location' => [CommentItemInterface::FORM_BELOW, CommentItemInterface::FORM_SEPARATE_PAGE],
+ 'comments' => [
CommentItemInterface::OPEN,
CommentItemInterface::CLOSED,
CommentItemInterface::HIDDEN,
- ),
- 'view_mode' => array(
+ ],
+ 'view_mode' => [
'teaser', 'rss', 'full',
- ),
- );
+ ],
+ ];
$permutations = TestBase::generatePermutations($combinations);
foreach ($permutations as $combination) {
- $case = array(
+ $case = [
$this->getMockNode(TRUE, $combination['comments'], $combination['form_location'], $combination['comment_count']),
- array('view_mode' => $combination['view_mode']),
+ ['view_mode' => $combination['view_mode']],
$combination['has_access_comments'],
$combination['history_exists'],
$combination['has_post_comments'],
$combination['is_anonymous'],
- );
- $expected = array();
+ ];
+ $expected = [];
// When comments are enabled in teaser mode, and comments exist, and the
// user has access - we can output the comment count.
if ($combination['comments'] && $combination['view_mode'] == 'teaser' && $combination['comment_count'] && $combination['has_access_comments']) {
@@ -225,7 +225,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
// comments exist or the form is on a separate page.
if ($combination['view_mode'] == 'teaser' || ($combination['has_access_comments'] && $combination['comment_count']) || $combination['form_location'] == CommentItemInterface::FORM_SEPARATE_PAGE) {
// There should be a add comment link.
- $expected['comment-add'] = array('title' => 'Add new comment');
+ $expected['comment-add'] = ['title' => 'Add new comment'];
if ($combination['form_location'] == CommentItemInterface::FORM_BELOW) {
// On the same page.
$expected['comment-add']['url'] = Url::fromRoute('node.view');
@@ -274,11 +274,11 @@ class CommentLinkBuilderTest extends UnitTestCase {
if (empty($this->timestamp)) {
$this->timestamp = time();
}
- $field_item = (object) array(
+ $field_item = (object) [
'status' => $comment_status,
'comment_count' => $comment_count,
'last_comment_timestamp' => $this->timestamp,
- );
+ ];
$node->expects($this->any())
->method('get')
->with('comment')
@@ -312,7 +312,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
->willReturn($url);
$node->expects($this->any())
->method('url')
- ->willReturn(array('route_name' => 'node.view'));
+ ->willReturn(['route_name' => 'node.view']);
return $node;
}
diff --git a/core/modules/comment/tests/src/Unit/CommentManagerTest.php b/core/modules/comment/tests/src/Unit/CommentManagerTest.php
index 78f14bbb1bb..3a6e20124bf 100644
--- a/core/modules/comment/tests/src/Unit/CommentManagerTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentManagerTest.php
@@ -32,13 +32,13 @@ class CommentManagerTest extends UnitTestCase {
$entity_manager->expects($this->once())
->method('getFieldMapByFieldType')
- ->will($this->returnValue(array(
- 'node' => array(
- 'field_foobar' => array(
+ ->will($this->returnValue([
+ 'node' => [
+ 'field_foobar' => [
'type' => 'comment',
- ),
- ),
- )));
+ ],
+ ],
+ ]));
$entity_manager->expects($this->any())
->method('getDefinition')
diff --git a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
index 39b4cf0a07d..2a6d3793087 100644
--- a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
@@ -56,7 +56,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
$this->statement->expects($this->any())
->method('fetchObject')
- ->will($this->returnCallback(array($this, 'fetchObjectCallback')));
+ ->will($this->returnCallback([$this, 'fetchObjectCallback']));
$this->select = $this->getMockBuilder('Drupal\Core\Database\Query\Select')
->disableOriginalConstructor()
@@ -95,8 +95,8 @@ class CommentStatisticsUnitTest extends UnitTestCase {
*/
public function testRead() {
$this->calls_to_fetch = 0;
- $results = $this->commentStatistics->read(array('1' => 'boo', '2' => 'foo'), 'snafoos');
- $this->assertEquals($results, array('something', 'something-else'));
+ $results = $this->commentStatistics->read(['1' => 'boo', '2' => 'foo'], 'snafoos');
+ $this->assertEquals($results, ['something', 'something-else']);
}
/**
diff --git a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
index 97c109f0ed2..e724dc6b89c 100644
--- a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
+++ b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
@@ -26,7 +26,7 @@ class CommentLockTest extends UnitTestCase {
$request_stack = new RequestStack();
$request_stack->push(Request::create('/'));
$container->set('request_stack', $request_stack);
- $container->setParameter('cache_bins', array('cache.test' => 'test'));
+ $container->setParameter('cache_bins', ['cache.test' => 'test']);
$lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
$cid = 2;
$lock_name = "comment:$cid:.00/";
@@ -84,7 +84,7 @@ class CommentLockTest extends UnitTestCase {
$comment->expects($this->at(1))
->method('get')
->with('status')
- ->will($this->returnValue((object) array('value' => NULL)));
+ ->will($this->returnValue((object) ['value' => NULL]));
$storage = $this->getMock('Drupal\comment\CommentStorageInterface');
// preSave() should acquire the lock. (This is what's really being tested.)
diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php
index 79bae3e3a16..220328be005 100644
--- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php
+++ b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php
@@ -14,20 +14,20 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d6\Comment';
// The fake Migration configuration entity.
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
// The ID of the entity, can be any string.
'id' => 'test',
// This needs to be the identifier of the actual key: cid for comment, nid
// for node and so on.
- 'source' => array(
+ 'source' => [
'plugin' => 'd6_comment',
- ),
- );
+ ],
+ ];
// We need to set up the database contents; it's easier to do that below.
- protected $expectedResults = array(
- array(
+ protected $expectedResults = [
+ [
'cid' => 1,
'pid' => 0,
'nid' => 2,
@@ -43,8 +43,8 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
'homepage' => '',
'format' => 'testformat1',
'type' => 'story',
- ),
- array(
+ ],
+ [
'cid' => 2,
'pid' => 1,
'nid' => 3,
@@ -60,8 +60,8 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
'homepage' => '',
'format' => 'testformat2',
'type' => 'page',
- ),
- );
+ ],
+ ];
/**
* {@inheritdoc}
@@ -72,8 +72,8 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
$this->databaseContents['comments'][$k]['status'] = 1 - $this->databaseContents['comments'][$k]['status'];
}
// Add node table data.
- $this->databaseContents['node'][] = array('nid' => 2, 'type' => 'story');
- $this->databaseContents['node'][] = array('nid' => 3, 'type' => 'page');
+ $this->databaseContents['node'][] = ['nid' => 2, 'type' => 'story'];
+ $this->databaseContents['node'][] = ['nid' => 3, 'type' => 'page'];
parent::setUp();
}
diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php
index 75d0932a998..892319a18ed 100644
--- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php
+++ b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php
@@ -13,46 +13,46 @@ class CommentVariablePerCommentTypeTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = CommentVariablePerCommentType::class;
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- 'source' => array(
+ 'source' => [
'plugin' => 'd6_comment_variable_per_comment_type',
- ),
- );
+ ],
+ ];
- protected $expectedResults = array(
+ protected $expectedResults = [
// Each result will also include a label and description, but those are
// static values set by the source plugin and don't need to be asserted.
- array(
+ [
'comment_type' => 'comment',
- ),
- array(
+ ],
+ [
'comment_type' => 'comment_no_subject',
- ),
- );
+ ],
+ ];
/**
* {@inheritdoc}
*/
protected function setUp() {
- $this->databaseContents['node_type'] = array(
- array(
+ $this->databaseContents['node_type'] = [
+ [
'type' => 'page',
- ),
- array(
+ ],
+ [
'type' => 'story',
- ),
- );
- $this->databaseContents['variable'] = array(
- array(
+ ],
+ ];
+ $this->databaseContents['variable'] = [
+ [
'name' => 'comment_subject_field_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_subject_field_story',
'value' => serialize(0),
- ),
- );
+ ],
+ ];
parent::setUp();
}
diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php
index 6d25a2bd3e4..406cd11f6f2 100644
--- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php
+++ b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php
@@ -13,15 +13,15 @@ class CommentVariableTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = CommentVariable::class;
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- 'source' => array(
+ 'source' => [
'plugin' => 'd6_comment_variable',
- ),
- );
+ ],
+ ];
- protected $expectedResults = array(
- array(
+ protected $expectedResults = [
+ [
'comment' => '1',
'comment_default_mode' => '1',
'comment_default_order' => '1',
@@ -33,56 +33,56 @@ class CommentVariableTest extends MigrateSqlSourceTestCase {
'comment_form_location' => '1',
'node_type' => 'page',
'comment_type' => 'comment',
- ),
- );
+ ],
+ ];
/**
* {@inheritdoc}
*/
protected function setUp() {
- $this->databaseContents['node_type'] = array(
- array(
+ $this->databaseContents['node_type'] = [
+ [
'type' => 'page',
- ),
- );
- $this->databaseContents['variable'] = array(
- array(
+ ],
+ ];
+ $this->databaseContents['variable'] = [
+ [
'name' => 'comment_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_default_mode_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_default_order_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_default_per_page_page',
'value' => serialize(50),
- ),
- array(
+ ],
+ [
'name' => 'comment_controls_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_anonymous_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_subject_field_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_preview_page',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_form_location_page',
'value' => serialize(1),
- ),
- );
+ ],
+ ];
parent::setUp();
}
diff --git a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php
index 7793348690f..aed2f285504 100644
--- a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php
+++ b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php
@@ -13,15 +13,15 @@ class CommentTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\Comment';
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- 'source' => array(
+ 'source' => [
'plugin' => 'd7_comment',
- ),
- );
+ ],
+ ];
- protected $expectedResults = array(
- array(
+ protected $expectedResults = [
+ [
'cid' => '1',
'pid' => '0',
'nid' => '1',
@@ -36,14 +36,14 @@ class CommentTest extends MigrateSqlSourceTestCase {
'mail' => '',
'homepage' => '',
'language' => 'und',
- 'comment_body' => array(
- array(
+ 'comment_body' => [
+ [
'value' => 'This is a comment',
'format' => 'filtered_html',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
/**
* {@inheritdoc}
@@ -52,8 +52,8 @@ class CommentTest extends MigrateSqlSourceTestCase {
$this->databaseContents['comment'] = $this->expectedResults;
unset($this->databaseContents['comment'][0]['comment_body']);
- $this->databaseContents['node'] = array(
- array(
+ $this->databaseContents['node'] = [
+ [
'nid' => '1',
'vid' => '1',
'type' => 'test_content_type',
@@ -68,10 +68,10 @@ class CommentTest extends MigrateSqlSourceTestCase {
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
- ),
- );
- $this->databaseContents['field_config_instance'] = array(
- array(
+ ],
+ ];
+ $this->databaseContents['field_config_instance'] = [
+ [
'id' => '14',
'field_id' => '1',
'field_name' => 'comment_body',
@@ -79,10 +79,10 @@ class CommentTest extends MigrateSqlSourceTestCase {
'bundle' => 'comment_node_test_content_type',
'data' => 'a:0:{}',
'deleted' => '0',
- ),
- );
- $this->databaseContents['field_data_comment_body'] = array(
- array(
+ ],
+ ];
+ $this->databaseContents['field_data_comment_body'] = [
+ [
'entity_type' => 'comment',
'bundle' => 'comment_node_test_content_type',
'deleted' => '0',
@@ -92,8 +92,8 @@ class CommentTest extends MigrateSqlSourceTestCase {
'delta' => '0',
'comment_body_value' => 'This is a comment',
'comment_body_format' => 'filtered_html',
- ),
- );
+ ],
+ ];
parent::setUp();
}
diff --git a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php
index 71c651bbe74..106716d8f27 100644
--- a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php
+++ b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php
@@ -13,15 +13,15 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\CommentType';
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- 'source' => array(
+ 'source' => [
'plugin' => 'd7_comment_type',
- ),
- );
+ ],
+ ];
- protected $expectedResults = array(
- array(
+ protected $expectedResults = [
+ [
'bundle' => 'comment_node_article',
'node_type' => 'article',
'default_mode' => '1',
@@ -31,15 +31,15 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
'preview' => '0',
'subject' => '1',
'label' => 'Article comment',
- ),
- );
+ ],
+ ];
/**
* {@inheritdoc}
*/
protected function setUp() {
- $this->databaseContents['node_type'] = array(
- array(
+ $this->databaseContents['node_type'] = [
+ [
'type' => 'article',
'name' => 'Article',
'base' => 'node_content',
@@ -53,10 +53,10 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
'locked' => '0',
'disabled' => '0',
'orig_type' => 'article',
- ),
- );
- $this->databaseContents['field_config_instance'] = array(
- array(
+ ],
+ ];
+ $this->databaseContents['field_config_instance'] = [
+ [
'id' => '14',
'field_id' => '1',
'field_name' => 'comment_body',
@@ -64,34 +64,34 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
'bundle' => 'comment_node_article',
'data' => 'a:0:{}',
'deleted' => '0',
- ),
- );
- $this->databaseContents['variable'] = array(
- array(
+ ],
+ ];
+ $this->databaseContents['variable'] = [
+ [
'name' => 'comment_default_mode_article',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_per_page_article',
'value' => serialize(50),
- ),
- array(
+ ],
+ [
'name' => 'comment_anonymous_article',
'value' => serialize(0),
- ),
- array(
+ ],
+ [
'name' => 'comment_form_location_article',
'value' => serialize(1),
- ),
- array(
+ ],
+ [
'name' => 'comment_preview_article',
'value' => serialize(0),
- ),
- array(
+ ],
+ [
'name' => 'comment_subject_article',
'value' => serialize(1),
- ),
- );
+ ],
+ ];
parent::setUp();
}
diff --git a/core/modules/config/config.module b/core/modules/config/config.module
index 874caac8b5f..b280fe84fa2 100644
--- a/core/modules/config/config.module
+++ b/core/modules/config/config.module
@@ -15,19 +15,19 @@ function config_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.config':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the <a href=":url">online documentation for the Configuration Manager module</a>.', array(':url' => 'https://www.drupal.org/documentation/administer/config')) . '</p>';
+ $output .= '<p>' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the <a href=":url">online documentation for the Configuration Manager module</a>.', [':url' => 'https://www.drupal.org/documentation/administer/config']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Exporting the full configuration') . '</dt>';
- $output .= '<dd>' . t('You can create and download an archive consisting of all your site\'s configuration exported as <em>*.yml</em> files on the <a href=":url">Export</a> page.', array(':url' => \Drupal::url('config.export_full'))) . '</dd>';
+ $output .= '<dd>' . t('You can create and download an archive consisting of all your site\'s configuration exported as <em>*.yml</em> files on the <a href=":url">Export</a> page.', [':url' => \Drupal::url('config.export_full')]) . '</dd>';
$output .= '<dt>' . t('Importing a full configuration') . '</dt>';
- $output .= '<dd>' . t('You can upload a full site configuration from an archive file on the <a href=":url">Import</a> page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the <em>system.site</em> configuration item. That means that your other environments should initially be set up as clones of the target site. Migrations are not supported.', array(':url' => \Drupal::url('config.import_full'))) . '</dd>';
+ $output .= '<dd>' . t('You can upload a full site configuration from an archive file on the <a href=":url">Import</a> page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the <em>system.site</em> configuration item. That means that your other environments should initially be set up as clones of the target site. Migrations are not supported.', [':url' => \Drupal::url('config.import_full')]) . '</dd>';
$output .= '<dt>' . t('Synchronizing configuration') . '</dt>';
- $output .= '<dd>' . t('You can review differences between the active configuration and an imported configuration archive on the <a href=":synchronize">Synchronize</a> page to ensure that the changes are as expected, before finalizing the import. The Synchronize page also shows configuration items that would be added or removed.', array(':synchronize' => \Drupal::url('config.sync'))) . '</dd>';
+ $output .= '<dd>' . t('You can review differences between the active configuration and an imported configuration archive on the <a href=":synchronize">Synchronize</a> page to ensure that the changes are as expected, before finalizing the import. The Synchronize page also shows configuration items that would be added or removed.', [':synchronize' => \Drupal::url('config.sync')]) . '</dd>';
$output .= '<dt>' . t('Exporting a single configuration item') . '</dt>';
- $output .= '<dd>' . t('You can export a single configuration item by selecting a <em>Configuration type</em> and <em>Configuration name</em> on the <a href=":single-export">Single export</a> page. The configuration and its corresponding <em>*.yml file name</em> are then displayed on the page for you to copy.', array(':single-export' => \Drupal::url('config.export_single'))) . '</dd>';
+ $output .= '<dd>' . t('You can export a single configuration item by selecting a <em>Configuration type</em> and <em>Configuration name</em> on the <a href=":single-export">Single export</a> page. The configuration and its corresponding <em>*.yml file name</em> are then displayed on the page for you to copy.', [':single-export' => \Drupal::url('config.export_single')]) . '</dd>';
$output .= '<dt>' . t('Importing a single configuration item') . '</dt>';
- $output .= '<dd>' . t('You can import a single configuration item by pasting it in YAML format into the form on the <a href=":single-import">Single import</a> page.', array(':single-import' => \Drupal::url('config.import_single'))) . '</dd>';
+ $output .= '<dd>' . t('You can import a single configuration item by pasting it in YAML format into the form on the <a href=":single-import">Single import</a> page.', [':single-import' => \Drupal::url('config.import_single')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -72,9 +72,9 @@ function config_file_download($uri) {
$hostname = str_replace('.', '-', $request->getHttpHost());
$filename = 'config' . '-' . $hostname . '-' . $date_string . '.tar.gz';
$disposition = 'attachment; filename="' . $filename . '"';
- return array(
+ return [
'Content-disposition' => $disposition,
- );
+ ];
}
return -1;
}
diff --git a/core/modules/config/src/ConfigSubscriber.php b/core/modules/config/src/ConfigSubscriber.php
index 9b6c8421184..aebc86e61ca 100644
--- a/core/modules/config/src/ConfigSubscriber.php
+++ b/core/modules/config/src/ConfigSubscriber.php
@@ -30,7 +30,7 @@ class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 20);
+ $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20];
return $events;
}
diff --git a/core/modules/config/src/Controller/ConfigController.php b/core/modules/config/src/Controller/ConfigController.php
index 8b9dc2541df..bf47f72d4bc 100644
--- a/core/modules/config/src/Controller/ConfigController.php
+++ b/core/modules/config/src/Controller/ConfigController.php
@@ -103,7 +103,7 @@ class ConfigController implements ContainerInjectionInterface {
}
}
- $request = new Request(array('file' => 'config.tar.gz'));
+ $request = new Request(['file' => 'config.tar.gz']);
return $this->fileDownloadController->download($request, 'temporary');
}
@@ -129,34 +129,34 @@ class ConfigController implements ContainerInjectionInterface {
$diff = $this->configManager->diff($this->targetStorage, $this->sourceStorage, $source_name, $target_name, $collection);
$this->diffFormatter->show_header = FALSE;
- $build = array();
+ $build = [];
- $build['#title'] = t('View changes of @config_file', array('@config_file' => $source_name));
+ $build['#title'] = t('View changes of @config_file', ['@config_file' => $source_name]);
// Add the CSS for the inline diff.
$build['#attached']['library'][] = 'system/diff';
- $build['diff'] = array(
+ $build['diff'] = [
'#type' => 'table',
- '#attributes' => array(
- 'class' => array('diff'),
- ),
- '#header' => array(
- array('data' => t('Active'), 'colspan' => '2'),
- array('data' => t('Staged'), 'colspan' => '2'),
- ),
+ '#attributes' => [
+ 'class' => ['diff'],
+ ],
+ '#header' => [
+ ['data' => t('Active'), 'colspan' => '2'],
+ ['data' => t('Staged'), 'colspan' => '2'],
+ ],
'#rows' => $this->diffFormatter->format($diff),
- );
+ ];
- $build['back'] = array(
+ $build['back'] = [
'#type' => 'link',
- '#attributes' => array(
- 'class' => array(
+ '#attributes' => [
+ 'class' => [
'dialog-cancel',
- ),
- ),
+ ],
+ ],
'#title' => "Back to 'Synchronize configuration' page.",
'#url' => Url::fromRoute('config.sync'),
- );
+ ];
return $build;
}
diff --git a/core/modules/config/src/Form/ConfigExportForm.php b/core/modules/config/src/Form/ConfigExportForm.php
index 0da43ff31c5..e822f7fa422 100644
--- a/core/modules/config/src/Form/ConfigExportForm.php
+++ b/core/modules/config/src/Form/ConfigExportForm.php
@@ -21,10 +21,10 @@ class ConfigExportForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Export'),
- );
+ ];
return $form;
}
diff --git a/core/modules/config/src/Form/ConfigImportForm.php b/core/modules/config/src/Form/ConfigImportForm.php
index 1d651d8bf0a..0c3def8619d 100644
--- a/core/modules/config/src/Form/ConfigImportForm.php
+++ b/core/modules/config/src/Form/ConfigImportForm.php
@@ -55,17 +55,17 @@ class ConfigImportForm extends FormBase {
if (!$directory_is_writable) {
drupal_set_message($this->t('The directory %directory is not writable.', ['%directory' => $directory]), 'error');
}
- $form['import_tarball'] = array(
+ $form['import_tarball'] = [
'#type' => 'file',
'#title' => $this->t('Configuration archive'),
- '#description' => $this->t('Allowed types: @extensions.', array('@extensions' => 'tar.gz tgz tar.bz2')),
- );
+ '#description' => $this->t('Allowed types: @extensions.', ['@extensions' => 'tar.gz tgz tar.bz2']),
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Upload'),
'#disabled' => !$directory_is_writable,
- );
+ ];
return $form;
}
@@ -93,7 +93,7 @@ class ConfigImportForm extends FormBase {
$this->configStorage->deleteAll();
try {
$archiver = new ArchiveTar($path, 'gz');
- $files = array();
+ $files = [];
foreach ($archiver->listContent() as $file) {
$files[] = $file['filename'];
}
@@ -102,7 +102,7 @@ class ConfigImportForm extends FormBase {
$form_state->setRedirect('config.sync');
}
catch (\Exception $e) {
- drupal_set_message($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', array('@message' => $e->getMessage())), 'error');
+ drupal_set_message($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', ['@message' => $e->getMessage()]), 'error');
}
drupal_unlink($path);
}
diff --git a/core/modules/config/src/Form/ConfigSingleExportForm.php b/core/modules/config/src/Form/ConfigSingleExportForm.php
index 86f1047e597..8710655d7f9 100644
--- a/core/modules/config/src/Form/ConfigSingleExportForm.php
+++ b/core/modules/config/src/Form/ConfigSingleExportForm.php
@@ -37,7 +37,7 @@ class ConfigSingleExportForm extends FormBase {
*
* @var \Drupal\Core\Entity\EntityTypeInterface[]
*/
- protected $definitions = array();
+ protected $definitions = [];
/**
* Constructs a new ConfigSingleImportForm.
@@ -83,40 +83,40 @@ class ConfigSingleExportForm extends FormBase {
}, $this->definitions);
// Sort the entity types by label, then add the simple config to the top.
uasort($entity_types, 'strnatcasecmp');
- $config_types = array(
+ $config_types = [
'system.simple' => $this->t('Simple configuration'),
- ) + $entity_types;
- $form['config_type'] = array(
+ ] + $entity_types;
+ $form['config_type'] = [
'#title' => $this->t('Configuration type'),
'#type' => 'select',
'#options' => $config_types,
'#default_value' => $config_type,
- '#ajax' => array(
+ '#ajax' => [
'callback' => '::updateConfigurationType',
'wrapper' => 'edit-config-type-wrapper',
- ),
- );
+ ],
+ ];
$default_type = $form_state->getValue('config_type', $config_type);
- $form['config_name'] = array(
+ $form['config_name'] = [
'#title' => $this->t('Configuration name'),
'#type' => 'select',
'#options' => $this->findConfiguration($default_type),
'#default_value' => $config_name,
'#prefix' => '<div id="edit-config-type-wrapper">',
'#suffix' => '</div>',
- '#ajax' => array(
+ '#ajax' => [
'callback' => '::updateExport',
'wrapper' => 'edit-export-wrapper',
- ),
- );
+ ],
+ ];
- $form['export'] = array(
+ $form['export'] = [
'#title' => $this->t('Here is your configuration:'),
'#type' => 'textarea',
'#rows' => 24,
'#prefix' => '<div id="edit-export-wrapper">',
'#suffix' => '</div>',
- );
+ ];
if ($config_type && $config_name) {
$fake_form_state = (new FormState())->setValues([
'config_type' => $config_type,
@@ -150,7 +150,7 @@ class ConfigSingleExportForm extends FormBase {
}
// Read the raw data for this config name, encode it, and display it.
$form['export']['#value'] = Yaml::encode($this->configStorage->read($name));
- $form['export']['#description'] = $this->t('Filename: %name', array('%name' => $name . '.yml'));
+ $form['export']['#description'] = $this->t('Filename: %name', ['%name' => $name . '.yml']);
return $form['export'];
}
@@ -158,9 +158,9 @@ class ConfigSingleExportForm extends FormBase {
* Handles switching the configuration type selector.
*/
protected function findConfiguration($config_type) {
- $names = array(
+ $names = [
'' => $this->t('- Select -'),
- );
+ ];
// For a given entity type, load all entities.
if ($config_type && $config_type !== 'system.simple') {
$entity_storage = $this->entityManager->getStorage($config_type);
diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php
index e2179577006..fcb388305e9 100644
--- a/core/modules/config/src/Form/ConfigSingleImportForm.php
+++ b/core/modules/config/src/Form/ConfigSingleImportForm.php
@@ -111,7 +111,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
*
* @var array
*/
- protected $data = array();
+ protected $data = [];
/**
* Constructs a new ConfigSingleImportForm.
@@ -198,10 +198,10 @@ class ConfigSingleImportForm extends ConfirmFormBase {
$type = $definition->getLowercaseLabel();
}
- $args = array(
+ $args = [
'%name' => $name,
'@type' => strtolower($type),
- );
+ ];
if ($this->configExists) {
$question = $this->t('Are you sure you want to update the %name @type?', $args);
}
@@ -220,7 +220,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
return parent::buildForm($form, $form_state);
}
- $entity_types = array();
+ $entity_types = [];
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
if ($definition->entityClassImplements(ConfigEntityInterface::class)) {
$entity_types[$entity_type] = $definition->getLabel();
@@ -228,49 +228,49 @@ class ConfigSingleImportForm extends ConfirmFormBase {
}
// Sort the entity types by label, then add the simple config to the top.
uasort($entity_types, 'strnatcasecmp');
- $config_types = array(
+ $config_types = [
'system.simple' => $this->t('Simple configuration'),
- ) + $entity_types;
- $form['config_type'] = array(
+ ] + $entity_types;
+ $form['config_type'] = [
'#title' => $this->t('Configuration type'),
'#type' => 'select',
'#options' => $config_types,
'#required' => TRUE,
- );
- $form['config_name'] = array(
+ ];
+ $form['config_name'] = [
'#title' => $this->t('Configuration name'),
'#description' => $this->t('Enter the name of the configuration file without the <em>.yml</em> extension. (e.g. <em>system.site</em>)'),
'#type' => 'textfield',
- '#states' => array(
- 'required' => array(
- ':input[name="config_type"]' => array('value' => 'system.simple'),
- ),
- 'visible' => array(
- ':input[name="config_type"]' => array('value' => 'system.simple'),
- ),
- ),
- );
- $form['import'] = array(
+ '#states' => [
+ 'required' => [
+ ':input[name="config_type"]' => ['value' => 'system.simple'],
+ ],
+ 'visible' => [
+ ':input[name="config_type"]' => ['value' => 'system.simple'],
+ ],
+ ],
+ ];
+ $form['import'] = [
'#title' => $this->t('Paste your configuration here'),
'#type' => 'textarea',
'#rows' => 24,
'#required' => TRUE,
- );
- $form['advanced'] = array(
+ ];
+ $form['advanced'] = [
'#type' => 'details',
'#title' => $this->t('Advanced'),
- );
- $form['advanced']['custom_entity_id'] = array(
+ ];
+ $form['advanced']['custom_entity_id'] = [
'#title' => $this->t('Custom Entity ID'),
'#type' => 'textfield',
'#description' => $this->t('Specify a custom entity ID. This will override the entity ID in the configuration above.'),
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ ];
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Import'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -305,7 +305,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
$entity_storage = $this->entityManager->getStorage($form_state->getValue('config_type'));
// If an entity ID was not specified, set an error.
if (!isset($data[$id_key])) {
- $form_state->setErrorByName('import', $this->t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => $id_key, '@entity_type' => $definition->getLabel())));
+ $form_state->setErrorByName('import', $this->t('Missing ID key "@id_key" for this @entity_type import.', ['@id_key' => $id_key, '@entity_type' => $definition->getLabel()]));
return;
}
@@ -323,7 +323,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
}
}
// If there is no entity with a matching ID, check for a UUID match.
- elseif (isset($data['uuid']) && $entity_storage->loadByProperties(array('uuid' => $data['uuid']))) {
+ elseif (isset($data['uuid']) && $entity_storage->loadByProperties(['uuid' => $data['uuid']])) {
$form_state->setErrorByName('import', $this->t('An entity with this UUID already exists but the machine name does not match.'));
}
}
diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php
index 51cded2690e..fe1b2e496a2 100644
--- a/core/modules/config/src/Form/ConfigSync.php
+++ b/core/modules/config/src/Form/ConfigSync.php
@@ -171,20 +171,20 @@ class ConfigSync extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Import all'),
- );
+ ];
$source_list = $this->syncStorage->listAll();
$storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage, $this->configManager);
if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) {
- $form['no_changes'] = array(
+ $form['no_changes'] = [
'#type' => 'table',
- '#header' => array($this->t('Name'), $this->t('Operations')),
- '#rows' => array(),
+ '#header' => [$this->t('Name'), $this->t('Operations')],
+ '#rows' => [],
'#empty' => $this->t('There are no configuration changes to import.'),
- );
+ ];
$form['actions']['#access'] = FALSE;
return $form;
}
@@ -198,7 +198,7 @@ class ConfigSync extends FormBase {
if ($this->snapshotStorage->exists('core.extension')) {
$snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage, $this->configManager);
if (!$form_state->getUserInput() && $snapshot_comparer->createChangelist()->hasChanges()) {
- $change_list = array();
+ $change_list = [];
foreach ($snapshot_comparer->getAllCollectionNames() as $collection) {
foreach ($snapshot_comparer->getChangelist(NULL, $collection) as $config_names) {
if (empty($config_names)) {
@@ -231,11 +231,11 @@ class ConfigSync extends FormBase {
foreach ($storage_comparer->getAllCollectionNames() as $collection) {
if ($collection != StorageInterface::DEFAULT_COLLECTION) {
- $form[$collection]['collection_heading'] = array(
+ $form[$collection]['collection_heading'] = [
'#type' => 'html_tag',
'#tag' => 'h2',
- '#value' => $this->t('@collection configuration collection', array('@collection' => $collection)),
- );
+ '#value' => $this->t('@collection configuration collection', ['@collection' => $collection]),
+ ];
}
foreach ($storage_comparer->getChangelist(NULL, $collection) as $config_change_type => $config_names) {
if (empty($config_names)) {
@@ -244,10 +244,10 @@ class ConfigSync extends FormBase {
// @todo A table caption would be more appropriate, but does not have the
// visual importance of a heading.
- $form[$collection][$config_change_type]['heading'] = array(
+ $form[$collection][$config_change_type]['heading'] = [
'#type' => 'html_tag',
'#tag' => 'h3',
- );
+ ];
switch ($config_change_type) {
case 'create':
$form[$collection][$config_change_type]['heading']['#value'] = $this->formatPlural(count($config_names), '@count new', '@count new');
@@ -265,19 +265,19 @@ class ConfigSync extends FormBase {
$form[$collection][$config_change_type]['heading']['#value'] = $this->formatPlural(count($config_names), '@count renamed', '@count renamed');
break;
}
- $form[$collection][$config_change_type]['list'] = array(
+ $form[$collection][$config_change_type]['list'] = [
'#type' => 'table',
- '#header' => array($this->t('Name'), $this->t('Operations')),
- );
+ '#header' => [$this->t('Name'), $this->t('Operations')],
+ ];
foreach ($config_names as $config_name) {
if ($config_change_type == 'rename') {
$names = $storage_comparer->extractRenameNames($config_name);
- $route_options = array('source_name' => $names['old_name'], 'target_name' => $names['new_name']);
- $config_name = $this->t('@source_name to @target_name', array('@source_name' => $names['old_name'], '@target_name' => $names['new_name']));
+ $route_options = ['source_name' => $names['old_name'], 'target_name' => $names['new_name']];
+ $config_name = $this->t('@source_name to @target_name', ['@source_name' => $names['old_name'], '@target_name' => $names['new_name']]);
}
else {
- $route_options = array('source_name' => $config_name);
+ $route_options = ['source_name' => $config_name];
}
if ($collection != StorageInterface::DEFAULT_COLLECTION) {
$route_name = 'config.diff_collection';
@@ -286,26 +286,26 @@ class ConfigSync extends FormBase {
else {
$route_name = 'config.diff';
}
- $links['view_diff'] = array(
+ $links['view_diff'] = [
'title' => $this->t('View differences'),
'url' => Url::fromRoute($route_name, $route_options),
- 'attributes' => array(
- 'class' => array('use-ajax'),
+ 'attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
- 'data-dialog-options' => json_encode(array(
+ 'data-dialog-options' => json_encode([
'width' => 700
- )),
- ),
- );
- $form[$collection][$config_change_type]['list']['#rows'][] = array(
+ ]),
+ ],
+ ];
+ $form[$collection][$config_change_type]['list']['#rows'][] = [
'name' => $config_name,
- 'operations' => array(
- 'data' => array(
+ 'operations' => [
+ 'data' => [
'#type' => 'operations',
'#links' => $links,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
}
@@ -333,17 +333,17 @@ class ConfigSync extends FormBase {
else {
try {
$sync_steps = $config_importer->initialize();
- $batch = array(
- 'operations' => array(),
- 'finished' => array(get_class($this), 'finishBatch'),
+ $batch = [
+ 'operations' => [],
+ 'finished' => [get_class($this), 'finishBatch'],
'title' => t('Synchronizing configuration'),
'init_message' => t('Starting configuration synchronization.'),
'progress_message' => t('Completed step @current of @total.'),
'error_message' => t('Configuration synchronization has encountered an error.'),
'file' => __DIR__ . '/../../config.admin.inc',
- );
+ ];
foreach ($sync_steps as $sync_step) {
- $batch['operations'][] = array(array(get_class($this), 'processBatch'), array($config_importer, $sync_step));
+ $batch['operations'][] = [[get_class($this), 'processBatch'], [$config_importer, $sync_step]];
}
batch_set($batch);
@@ -377,7 +377,7 @@ class ConfigSync extends FormBase {
$config_importer->doSyncStep($sync_step, $context);
if ($errors = $config_importer->getErrors()) {
if (!isset($context['results']['errors'])) {
- $context['results']['errors'] = array();
+ $context['results']['errors'] = [];
}
$context['results']['errors'] += $errors;
}
@@ -406,7 +406,7 @@ class ConfigSync extends FormBase {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
- $message = \Drupal::translation()->translate('An error occurred while processing %error_operation with arguments: @arguments', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)));
+ $message = \Drupal::translation()->translate('An error occurred while processing %error_operation with arguments: @arguments', ['%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)]);
drupal_set_message($message, 'error');
}
}
diff --git a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php
index 92693c4a9e8..41419b031e6 100644
--- a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php
+++ b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php
@@ -14,7 +14,7 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Tests that overrides do not affect forms or listing screens.
@@ -29,10 +29,10 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
$config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
// Set up an override.
- $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array(
+ $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [
'value' => $overridden_label,
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
// Test that the overridden label is loaded with the entity.
@@ -50,9 +50,9 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
$this->assertNoText($overridden_label);
// Change to a new label and test that the listing now has the edited label.
- $edit = array(
+ $edit = [
'label' => $edited_label,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->drupalGet('admin/structure/config_test');
$this->assertNoText($overridden_label);
diff --git a/core/modules/config/src/Tests/ConfigEntityListTest.php b/core/modules/config/src/Tests/ConfigEntityListTest.php
index 9d31de05cb4..fbc7ad6a73c 100644
--- a/core/modules/config/src/Tests/ConfigEntityListTest.php
+++ b/core/modules/config/src/Tests/ConfigEntityListTest.php
@@ -50,71 +50,71 @@ class ConfigEntityListTest extends WebTestBase {
$this->assertTrue($entity instanceof ConfigTest, '"Default" ConfigTest entity is an instance of ConfigTest.');
// Test getOperations() method.
- $expected_operations = array(
- 'edit' => array (
+ $expected_operations = [
+ 'edit' => [
'title' => t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo(),
- ),
- 'disable' => array(
+ ],
+ 'disable' => [
'title' => t('Disable'),
'weight' => 40,
'url' => $entity->urlInfo('disable'),
- ),
- 'delete' => array (
+ ],
+ 'delete' => [
'title' => t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo('delete-form'),
- ),
- );
+ ],
+ ];
$actual_operations = $controller->getOperations($entity);
// Sort the operations to normalize link order.
- uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($actual_operations, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
$this->assertEqual($expected_operations, $actual_operations, 'The operations are identical.');
// Test buildHeader() method.
- $expected_items = array(
+ $expected_items = [
'label' => 'Label',
'id' => 'Machine name',
'operations' => 'Operations',
- );
+ ];
$actual_items = $controller->buildHeader();
$this->assertEqual($expected_items, $actual_items, 'Return value from buildHeader matches expected.');
// Test buildRow() method.
$build_operations = $controller->buildOperations($entity);
- $expected_items = array(
+ $expected_items = [
'label' => 'Default',
'id' => 'dotted.default',
- 'operations' => array(
+ 'operations' => [
'data' => $build_operations,
- ),
- );
+ ],
+ ];
$actual_items = $controller->buildRow($entity);
$this->assertEqual($expected_items, $actual_items, 'Return value from buildRow matches expected.');
// Test sorting.
$storage = $controller->getStorage();
- $entity = $storage->create(array(
+ $entity = $storage->create([
'id' => 'alpha',
'label' => 'Alpha',
'weight' => 1,
- ));
+ ]);
$entity->save();
- $entity = $storage->create(array(
+ $entity = $storage->create([
'id' => 'omega',
'label' => 'Omega',
'weight' => 1,
- ));
+ ]);
$entity->save();
- $entity = $storage->create(array(
+ $entity = $storage->create([
'id' => 'beta',
'label' => 'Beta',
'weight' => 0,
- ));
+ ]);
$entity->save();
$list = $controller->load();
- $this->assertIdentical(array_keys($list), array('beta', 'dotted.default', 'alpha', 'omega'));
+ $this->assertIdentical(array_keys($list), ['beta', 'dotted.default', 'alpha', 'omega']);
// Test that config entities that do not support status, do not have
// enable/disable operations.
@@ -125,22 +125,22 @@ class ConfigEntityListTest extends WebTestBase {
$entity = $list['default'];
// Test getOperations() method.
- $expected_operations = array(
- 'edit' => array(
+ $expected_operations = [
+ 'edit' => [
'title' => t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo(),
- ),
- 'delete' => array(
+ ],
+ 'delete' => [
'title' => t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo('delete-form'),
- ),
- );
+ ],
+ ];
$actual_operations = $controller->getOperations($entity);
// Sort the operations to normalize link order.
- uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($actual_operations, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
$this->assertEqual($expected_operations, $actual_operations, 'The operations are identical.');
}
@@ -149,7 +149,7 @@ class ConfigEntityListTest extends WebTestBase {
*/
function testListUI() {
// Log in as an administrative user to access the full menu trail.
- $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
// Get the list callback page.
$this->drupalGet('admin/structure/config_test');
@@ -166,7 +166,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->assertEqual(count($elements), 3, 'Correct number of table header cells found.');
// Test the contents of each th cell.
- $expected_items = array('Label', 'Machine name', 'Operations');
+ $expected_items = ['Label', 'Machine name', 'Operations'];
foreach ($elements as $key => $element) {
$this->assertIdentical((string) $element[0], $expected_items[$key]);
}
@@ -186,11 +186,11 @@ class ConfigEntityListTest extends WebTestBase {
$this->assertLink('Add test configuration');
$this->clickLink('Add test configuration');
$this->assertResponse(200);
- $edit = array(
+ $edit = [
'label' => 'Antelope',
'id' => 'antelope',
'weight' => 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Ensure that the entity's sort method was called.
@@ -207,7 +207,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->clickLink('Edit', 1);
$this->assertResponse(200);
$this->assertTitle('Edit Antelope | Drupal');
- $edit = array('label' => 'Albatross', 'id' => 'albatross');
+ $edit = ['label' => 'Albatross', 'id' => 'albatross'];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Confirm that the user is returned to the listing, and verify that the
@@ -221,7 +221,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->clickLink('Delete', 1);
$this->assertResponse(200);
$this->assertTitle('Are you sure you want to delete the test configuration Albatross? | Drupal');
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
// Verify that the text of the label and machine name does not appear in
// the list (though it may appear elsewhere on the page).
@@ -232,7 +232,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->clickLink('Delete');
$this->assertResponse(200);
$this->assertTitle('Are you sure you want to delete the test configuration Default? | Drupal');
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
// Verify that the text of the label and machine name does not appear in
// the list (though it may appear elsewhere on the page).
@@ -253,12 +253,12 @@ class ConfigEntityListTest extends WebTestBase {
// Create 51 test entities.
for ($i = 1; $i < 52; $i++) {
- $storage->create(array(
+ $storage->create([
'id' => str_pad($i, 2, '0', STR_PAD_LEFT),
'label' => 'Test config entity ' . $i,
'weight' => $i,
'protected_property' => $i,
- ))->save();
+ ])->save();
}
// Load the listing page.
diff --git a/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php
index a8a8f0f7479..77b35cc040d 100644
--- a/core/modules/config/src/Tests/ConfigEntityTest.php
+++ b/core/modules/config/src/Tests/ConfigEntityTest.php
@@ -27,7 +27,7 @@ class ConfigEntityTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Tests CRUD operations.
@@ -76,9 +76,9 @@ class ConfigEntityTest extends WebTestBase {
}
// Verify that an entity with an empty ID string is considered empty, too.
- $empty_id = entity_create('config_test', array(
+ $empty_id = entity_create('config_test', [
'id' => '',
- ));
+ ]);
$this->assertIdentical($empty_id->isNew(), TRUE);
try {
$empty_id->save();
@@ -89,11 +89,11 @@ class ConfigEntityTest extends WebTestBase {
}
// Verify properties on a newly created entity.
- $config_test = entity_create('config_test', $expected = array(
+ $config_test = entity_create('config_test', $expected = [
'id' => $this->randomMachineName(),
'label' => $this->randomString(),
'style' => $this->randomMachineName(),
- ));
+ ]);
$this->assertTrue($config_test->uuid());
$this->assertNotEqual($config_test->uuid(), $empty->uuid());
$this->assertIdentical($config_test->label, $expected['label']);
@@ -141,13 +141,13 @@ class ConfigEntityTest extends WebTestBase {
// maximum allowed length, but not longer.
// Test with a short ID.
- $id_length_config_test = entity_create('config_test', array(
+ $id_length_config_test = entity_create('config_test', [
'id' => $this->randomMachineName(8),
- ));
+ ]);
try {
$id_length_config_test->save();
- $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array(
- '@length' => strlen($id_length_config_test->id()))
+ $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [
+ '@length' => strlen($id_length_config_test->id())]
));
}
catch (ConfigEntityIdLengthException $e) {
@@ -155,42 +155,42 @@ class ConfigEntityTest extends WebTestBase {
}
// Test with an ID of the maximum allowed length.
- $id_length_config_test = entity_create('config_test', array(
+ $id_length_config_test = entity_create('config_test', [
'id' => $this->randomMachineName(static::MAX_ID_LENGTH),
- ));
+ ]);
try {
$id_length_config_test->save();
- $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array(
+ $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [
'@length' => strlen($id_length_config_test->id()),
- )));
+ ]));
}
catch (ConfigEntityIdLengthException $e) {
$this->fail($e->getMessage());
}
// Test with an ID exceeding the maximum allowed length.
- $id_length_config_test = entity_create('config_test', array(
+ $id_length_config_test = entity_create('config_test', [
'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1),
- ));
+ ]);
try {
$status = $id_length_config_test->save();
- $this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", array(
+ $this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", [
'@length' => strlen($id_length_config_test->id()),
'@max' => static::MAX_ID_LENGTH,
- )));
+ ]));
}
catch (ConfigEntityIdLengthException $e) {
- $this->pass(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", array(
+ $this->pass(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [
'@length' => strlen($id_length_config_test->id()),
'@max' => static::MAX_ID_LENGTH,
- )));
+ ]));
}
// Ensure that creating an entity with the same id as an existing one is not
// possible.
- $same_id = entity_create('config_test', array(
+ $same_id = entity_create('config_test', [
'id' => $config_test->id(),
- ));
+ ]);
$this->assertIdentical($same_id->isNew(), TRUE);
try {
$same_id->save();
@@ -201,7 +201,7 @@ class ConfigEntityTest extends WebTestBase {
}
// Verify that renaming the ID returns correct status and properties.
- $ids = array($expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4));
+ $ids = [$expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4)];
for ($i = 1; $i < 3; $i++) {
$old_id = $ids[$i - 1];
$new_id = $ids[$i];
@@ -223,7 +223,7 @@ class ConfigEntityTest extends WebTestBase {
// Test config entity prepopulation.
\Drupal::state()->set('config_test.prepopulate', TRUE);
- $config_test = entity_create('config_test', array('foo' => 'bar'));
+ $config_test = entity_create('config_test', ['foo' => 'bar']);
$this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated');
}
@@ -237,15 +237,15 @@ class ConfigEntityTest extends WebTestBase {
$label1 = $this->randomMachineName();
$label2 = $this->randomMachineName();
$label3 = $this->randomMachineName();
- $message_insert = format_string('%label configuration has been created.', array('%label' => $label1));
- $message_update = format_string('%label configuration has been updated.', array('%label' => $label2));
- $message_delete = format_string('The test configuration %label has been deleted.', array('%label' => $label2));
+ $message_insert = format_string('%label configuration has been created.', ['%label' => $label1]);
+ $message_update = format_string('%label configuration has been updated.', ['%label' => $label2]);
+ $message_delete = format_string('The test configuration %label has been deleted.', ['%label' => $label2]);
// Create a configuration entity.
- $edit = array(
+ $edit = [
'id' => $id,
'label' => $label1,
- );
+ ];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@@ -254,9 +254,9 @@ class ConfigEntityTest extends WebTestBase {
$this->assertLinkByHref("admin/structure/config_test/manage/$id");
// Update the configuration entity.
- $edit = array(
+ $edit = [
'label' => $label2,
- );
+ ];
$this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@@ -269,7 +269,7 @@ class ConfigEntityTest extends WebTestBase {
$this->drupalGet("admin/structure/config_test/manage/$id");
$this->clickLink(t('Delete'));
$this->assertUrl("admin/structure/config_test/manage/$id/delete");
- $this->drupalPostForm(NULL, array(), 'Delete');
+ $this->drupalPostForm(NULL, [], 'Delete');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
$this->assertNoRaw($message_update);
@@ -278,10 +278,10 @@ class ConfigEntityTest extends WebTestBase {
$this->assertNoLinkByHref("admin/structure/config_test/manage/$id");
// Re-create a configuration entity.
- $edit = array(
+ $edit = [
'id' => $id,
'label' => $label1,
- );
+ ];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@@ -289,10 +289,10 @@ class ConfigEntityTest extends WebTestBase {
$this->assertLinkByHref("admin/structure/config_test/manage/$id");
// Rename the configuration entity's ID/machine name.
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName()),
'label' => $label3,
- );
+ ];
$this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@@ -304,17 +304,17 @@ class ConfigEntityTest extends WebTestBase {
$this->assertLinkByHref("admin/structure/config_test/manage/$id");
// Create a configuration entity with '0' machine name.
- $edit = array(
+ $edit = [
'id' => '0',
'label' => '0',
- );
+ ];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$this->assertResponse(200);
- $message_insert = format_string('%label configuration has been created.', array('%label' => $edit['label']));
+ $message_insert = format_string('%label configuration has been created.', ['%label' => $edit['label']]);
$this->assertRaw($message_insert);
$this->assertLinkByHref('admin/structure/config_test/manage/0');
$this->assertLinkByHref('admin/structure/config_test/manage/0/delete');
- $this->drupalPostForm('admin/structure/config_test/manage/0/delete', array(), 'Delete');
+ $this->drupalPostForm('admin/structure/config_test/manage/0/delete', [], 'Delete');
$this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted');
// Create a configuration entity with a property that uses AJAX to show
diff --git a/core/modules/config/src/Tests/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php
index 828d4aa07bd..9ba59a85cad 100644
--- a/core/modules/config/src/Tests/ConfigExportImportUITest.php
+++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php
@@ -67,7 +67,7 @@ class ConfigExportImportUITest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('config', 'node', 'field');
+ public static $modules = ['config', 'node', 'field'];
/**
* {@inheritdoc}
@@ -103,11 +103,11 @@ class ConfigExportImportUITest extends WebTestBase {
// Create a field.
$this->fieldName = Unicode::strtolower($this->randomMachineName());
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text',
- ));
+ ]);
$this->fieldStorage->save();
FieldConfig::create([
'field_storage' => $this->fieldStorage,
@@ -116,9 +116,9 @@ class ConfigExportImportUITest extends WebTestBase {
// Update the displays so that configuration does not change unexpectedly on
// import.
entity_get_form_display('node', $this->contentType->id(), 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'text_textfield',
- ))
+ ])
->save();
entity_get_display('node', $this->contentType->id(), 'full')
->setComponent($this->fieldName)
@@ -134,7 +134,7 @@ class ConfigExportImportUITest extends WebTestBase {
$this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed');
// Export the configuration.
- $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
+ $this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
$this->tarball = $this->getRawContent();
$this->config('system.site')
@@ -161,13 +161,13 @@ class ConfigExportImportUITest extends WebTestBase {
// Import the configuration.
$filename = 'temporary://' . $this->randomMachineName();
file_put_contents($filename, $this->tarball);
- $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload');
+ $this->drupalPostForm('admin/config/development/configuration/full/import', ['files[import_tarball]' => $filename], 'Upload');
// There is no snapshot yet because an import has never run.
$this->assertNoText(t('Warning message'));
$this->assertNoText(t('There are no configuration changes to import.'));
$this->assertText($this->contentType->label());
- $this->drupalPostForm(NULL, array(), 'Import all');
+ $this->drupalPostForm(NULL, [], 'Import all');
// After importing the snapshot has been updated an there are no warnings.
$this->assertNoText(t('Warning message'));
$this->assertText(t('There are no configuration changes to import.'));
@@ -217,25 +217,25 @@ class ConfigExportImportUITest extends WebTestBase {
/** @var \Drupal\Core\Config\StorageInterface $active_storage */
$active_storage = \Drupal::service('config.storage');
$test1_storage = $active_storage->createCollection('collection.test1');
- $test1_storage->write('config_test.create', array('foo' => 'bar'));
- $test1_storage->write('config_test.update', array('foo' => 'bar'));
+ $test1_storage->write('config_test.create', ['foo' => 'bar']);
+ $test1_storage->write('config_test.update', ['foo' => 'bar']);
$test2_storage = $active_storage->createCollection('collection.test2');
- $test2_storage->write('config_test.another_create', array('foo' => 'bar'));
- $test2_storage->write('config_test.another_update', array('foo' => 'bar'));
+ $test2_storage->write('config_test.another_create', ['foo' => 'bar']);
+ $test2_storage->write('config_test.another_update', ['foo' => 'bar']);
// Export the configuration.
- $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
+ $this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
$this->tarball = $this->getRawContent();
$filename = file_directory_temp() . '/' . $this->randomMachineName();
file_put_contents($filename, $this->tarball);
// Set up the active storage collections to test import.
$test1_storage->delete('config_test.create');
- $test1_storage->write('config_test.update', array('foo' => 'baz'));
- $test1_storage->write('config_test.delete', array('foo' => 'bar'));
+ $test1_storage->write('config_test.update', ['foo' => 'baz']);
+ $test1_storage->write('config_test.delete', ['foo' => 'bar']);
$test2_storage->delete('config_test.another_create');
- $test2_storage->write('config_test.another_update', array('foo' => 'baz'));
- $test2_storage->write('config_test.another_delete', array('foo' => 'bar'));
+ $test2_storage->write('config_test.another_update', ['foo' => 'baz']);
+ $test2_storage->write('config_test.another_delete', ['foo' => 'bar']);
// Create a snapshot.
$snapshot_storage = \Drupal::service('config.storage.snapshot');
@@ -244,22 +244,22 @@ class ConfigExportImportUITest extends WebTestBase {
// Ensure that the snapshot has the expected collection data before import.
$test1_snapshot = $snapshot_storage->createCollection('collection.test1');
$data = $test1_snapshot->read('config_test.delete');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.delete in collection.test1 exists in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.delete in collection.test1 exists in the snapshot storage.');
$data = $test1_snapshot->read('config_test.update');
- $this->assertEqual($data, array('foo' => 'baz'), 'The config_test.update in collection.test1 exists in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'baz'], 'The config_test.update in collection.test1 exists in the snapshot storage.');
$this->assertFalse($test1_snapshot->read('config_test.create'), 'The config_test.create in collection.test1 does not exist in the snapshot storage.');
$test2_snapshot = $snapshot_storage->createCollection('collection.test2');
$data = $test2_snapshot->read('config_test.another_delete');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_delete in collection.test2 exists in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_delete in collection.test2 exists in the snapshot storage.');
$data = $test2_snapshot->read('config_test.another_update');
- $this->assertEqual($data, array('foo' => 'baz'), 'The config_test.another_update in collection.test2 exists in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'baz'], 'The config_test.another_update in collection.test2 exists in the snapshot storage.');
$this->assertFalse($test2_snapshot->read('config_test.another_create'), 'The config_test.another_create in collection.test2 does not exist in the snapshot storage.');
// Create the tar that contains the expected content for the collections.
$tar = new ArchiveTar($filename, 'gz');
$content_list = $tar->listContent();
// Convert the list of files into something easy to search.
- $files = array();
+ $files = [];
foreach ($content_list as $file) {
$files[] = $file['filename'];
}
@@ -270,12 +270,12 @@ class ConfigExportImportUITest extends WebTestBase {
$this->assertFalse(in_array('collection/test1/config_test.delete.yml', $files), 'Config export does not contain collection/test1/config_test.delete.yml.');
$this->assertFalse(in_array('collection/test2/config_test.another_delete.yml', $files), 'Config export does not contain collection/test2/config_test.another_delete.yml.');
- $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload');
+ $this->drupalPostForm('admin/config/development/configuration/full/import', ['files[import_tarball]' => $filename], 'Upload');
// Verify that there are configuration differences to import.
$this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('There are no configuration changes to import.'));
- $this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test1')));
- $this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test2')));
+ $this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test1']));
+ $this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test2']));
$this->assertText('config_test.create');
$this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create');
$this->assertText('config_test.update');
@@ -289,35 +289,35 @@ class ConfigExportImportUITest extends WebTestBase {
$this->assertText('config_test.another_delete');
$this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_delete');
- $this->drupalPostForm(NULL, array(), 'Import all');
+ $this->drupalPostForm(NULL, [], 'Import all');
$this->assertText(t('There are no configuration changes to import.'));
// Test data in collections.
$data = $test1_storage->read('config_test.create');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.create in collection.test1 has been created.');
$data = $test1_storage->read('config_test.update');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.update in collection.test1 has been updated.');
$this->assertFalse($test1_storage->read('config_test.delete'), 'The config_test.delete in collection.test1 has been deleted.');
$data = $test2_storage->read('config_test.another_create');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_create in collection.test2 has been created.');
$data = $test2_storage->read('config_test.another_update');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_update in collection.test2 has been updated.');
$this->assertFalse($test2_storage->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 has been deleted.');
// Ensure that the snapshot has been updated with the collection data.
$snapshot_storage = \Drupal::service('config.storage.snapshot');
$test1_snapshot = $snapshot_storage->createCollection('collection.test1');
$data = $test1_snapshot->read('config_test.create');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.create in collection.test1 has been created in the snapshot storage.');
$data = $test1_snapshot->read('config_test.update');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.update in collection.test1 has been updated in the snapshot storage.');
$this->assertFalse($test1_snapshot->read('config_test.delete'), 'The config_test.delete in collection.test1 does not exist in the snapshot storage.');
$test2_snapshot = $snapshot_storage->createCollection('collection.test2');
$data = $test2_snapshot->read('config_test.another_create');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_create in collection.test2 has been created in the snapshot storage.');
$data = $test2_snapshot->read('config_test.another_update');
- $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated in the snapshot storage.');
+ $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_update in collection.test2 has been updated in the snapshot storage.');
$this->assertFalse($test2_snapshot->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 does not exist in the snapshot storage.');
}
diff --git a/core/modules/config/src/Tests/ConfigExportUITest.php b/core/modules/config/src/Tests/ConfigExportUITest.php
index d3133d8dfdd..839aa26cade 100644
--- a/core/modules/config/src/Tests/ConfigExportUITest.php
+++ b/core/modules/config/src/Tests/ConfigExportUITest.php
@@ -18,7 +18,7 @@ class ConfigExportUITest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('config', 'config_test');
+ public static $modules = ['config', 'config_test'];
/**
* {@inheritdoc}
@@ -27,13 +27,13 @@ class ConfigExportUITest extends WebTestBase {
parent::setUp();
// Set up an override.
- $settings['config']['system.maintenance']['message'] = (object) array(
+ $settings['config']['system.maintenance']['message'] = (object) [
'value' => 'Foo',
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
- $this->drupalLogin($this->drupalCreateUser(array('export configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['export configuration']));
}
/**
@@ -45,7 +45,7 @@ class ConfigExportUITest extends WebTestBase {
$this->assertFieldById('edit-submit', t('Export'));
// Submit the export form and verify response.
- $this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
+ $this->drupalPostForm('admin/config/development/configuration/full/export', [], t('Export'));
$this->assertResponse(200, 'User can access the download callback.');
// Test if header contains file name with hostname and timestamp.
@@ -70,7 +70,7 @@ class ConfigExportUITest extends WebTestBase {
// Prepare the list of config files from active storage, see
// \Drupal\config\Controller\ConfigController::downloadExport().
$storage_active = $this->container->get('config.storage');
- $config_files = array();
+ $config_files = [];
foreach ($storage_active->listAll() as $config_name) {
$config_files[] = $config_name . '.yml';
}
@@ -80,7 +80,7 @@ class ConfigExportUITest extends WebTestBase {
// Ensure the test configuration override is in effect but was not exported.
$this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
- $archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
+ $archiver->extract(file_directory_temp(), ['system.maintenance.yml']);
$file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
$exported = Yaml::decode($file_contents);
$this->assertNotIdentical($exported['message'], 'Foo');
diff --git a/core/modules/config/src/Tests/ConfigFormOverrideTest.php b/core/modules/config/src/Tests/ConfigFormOverrideTest.php
index ffd44282093..f721eeba747 100644
--- a/core/modules/config/src/Tests/ConfigFormOverrideTest.php
+++ b/core/modules/config/src/Tests/ConfigFormOverrideTest.php
@@ -16,15 +16,15 @@ class ConfigFormOverrideTest extends WebTestBase {
* Tests that overrides do not affect forms.
*/
public function testFormsWithOverrides() {
- $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$overridden_name = 'Site name global conf override';
// Set up an override.
- $settings['config']['system.site']['name'] = (object) array(
+ $settings['config']['system.site']['name'] = (object) [
'value' => $overridden_name,
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
// Test that everything on the form is the same, but that the override
@@ -35,9 +35,9 @@ class ConfigFormOverrideTest extends WebTestBase {
$this->assertIdentical((string) $elements[0]['value'], 'Drupal');
// Submit the form and ensure the site name is not changed.
- $edit = array(
+ $edit = [
'site_name' => 'Custom site name',
- );
+ ];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this->assertTitle('Basic site settings | ' . $overridden_name);
$elements = $this->xpath('//input[@name="site_name"]');
diff --git a/core/modules/config/src/Tests/ConfigImportAllTest.php b/core/modules/config/src/Tests/ConfigImportAllTest.php
index baeacb966f3..459be7a24fd 100644
--- a/core/modules/config/src/Tests/ConfigImportAllTest.php
+++ b/core/modules/config/src/Tests/ConfigImportAllTest.php
@@ -36,7 +36,7 @@ class ConfigImportAllTest extends ModuleTestBase {
protected function setUp() {
parent::setUp();
- $this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
+ $this->webUser = $this->drupalCreateUser(['synchronize configuration']);
$this->drupalLogin($this->webUser);
}
@@ -124,12 +124,12 @@ class ConfigImportAllTest extends ModuleTestBase {
}
// Import the configuration thereby re-installing all the modules.
- $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
+ $this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
// Modules have been installed that have services.
$this->rebuildContainer();
// Check that there are no errors.
- $this->assertIdentical($this->configImporter()->getErrors(), array());
+ $this->assertIdentical($this->configImporter()->getErrors(), []);
// Check that all modules that were uninstalled are now reinstalled.
$this->assertModules(array_keys($modules_to_uninstall), TRUE);
diff --git a/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php b/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php
index 0c74c7fa102..eaece36db3a 100644
--- a/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php
+++ b/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php
@@ -23,7 +23,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('config');
+ public static $modules = ['config'];
/**
* A user with the 'synchronize configuration' permission.
@@ -35,7 +35,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
+ $this->webUser = $this->drupalCreateUser(['synchronize configuration']);
$this->drupalLogin($this->webUser);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
}
@@ -54,7 +54,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
unset($core['module']['testing_config_import']);
$sync->write('core.extension', $core);
- $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
+ $this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
$this->assertText('Unable to uninstall the Testing config import profile since it is the install profile.');
@@ -69,7 +69,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
$theme = $sync->read('system.theme');
$theme['default'] = 'classy';
$sync->write('system.theme', $theme);
- $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
+ $this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
$this->assertText('The configuration was imported successfully.');
$this->rebuildContainer();
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('syslog'), 'The syslog module has been uninstalled.');
diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php
index afa9b99582b..1b63c2abe63 100644
--- a/core/modules/config/src/Tests/ConfigImportUITest.php
+++ b/core/modules/config/src/Tests/ConfigImportUITest.php
@@ -19,7 +19,7 @@ class ConfigImportUITest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('config', 'config_test', 'config_import_test', 'text', 'options');
+ public static $modules = ['config', 'config_test', 'config_import_test', 'text', 'options'];
/**
* A user with the 'synchronize configuration' permission.
@@ -31,7 +31,7 @@ class ConfigImportUITest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
+ $this->webUser = $this->drupalCreateUser(['synchronize configuration']);
$this->drupalLogin($this->webUser);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
}
@@ -55,11 +55,11 @@ class ConfigImportUITest extends WebTestBase {
$this->assertIdentical($sync->exists($name), TRUE, $name . ' found.');
// Create new config entity.
- $original_dynamic_data = array(
+ $original_dynamic_data = [
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
'status' => TRUE,
- 'dependencies' => array(),
+ 'dependencies' => [],
'id' => 'new',
'label' => 'New',
'weight' => 0,
@@ -67,7 +67,7 @@ class ConfigImportUITest extends WebTestBase {
'size' => '',
'size_value' => '',
'protected_property' => '',
- );
+ ];
$sync->write($dynamic_name, $original_dynamic_data);
$this->assertIdentical($sync->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
@@ -102,11 +102,11 @@ class ConfigImportUITest extends WebTestBase {
// handled correctly. Options depends on Text so Text should be installed
// first. Since they were enabled during the test setup the core.extension
// file in sync will already contain them.
- \Drupal::service('module_installer')->uninstall(array('text', 'options'));
+ \Drupal::service('module_installer')->uninstall(['text', 'options']);
// Set the state system to record installations and uninstallations.
- \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', array());
- \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', array());
+ \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', []);
+ \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', []);
// Verify that both appear as ready to import.
$this->drupalGet('admin/config/development/configuration');
@@ -118,7 +118,7 @@ class ConfigImportUITest extends WebTestBase {
$this->assertFieldById('edit-submit', t('Import all'));
// Import and verify that both do not appear anymore.
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$this->assertNoRaw('<td>' . $name);
$this->assertNoRaw('<td>' . $dynamic_name);
$this->assertNoRaw('<td>core.extension');
@@ -150,9 +150,9 @@ class ConfigImportUITest extends WebTestBase {
$this->assertTrue($theme_info['bartik']->status, 'Bartik theme installed during import.');
// Ensure installations and uninstallation occur as expected.
- $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array());
- $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
- $expected = array('action', 'ban', 'text', 'options');
+ $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', []);
+ $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
+ $expected = ['action', 'ban', 'text', 'options'];
$this->assertIdentical($expected, $installed, 'Action, Ban, Text and Options modules installed in the correct order.');
$this->assertTrue(empty($uninstalled), 'No modules uninstalled during import');
@@ -161,8 +161,8 @@ class ConfigImportUITest extends WebTestBase {
// configuration. This verifies that the module's default configuration is
// used during configuration import and, additionally, that after installing
// a module, that configuration is not synced twice.
- $recursion_limit_values = \Drupal::state()->get('ConfigImportUITest.action.settings.recursion_limit', array());
- $this->assertIdentical($recursion_limit_values, array(50));
+ $recursion_limit_values = \Drupal::state()->get('ConfigImportUITest.action.settings.recursion_limit', []);
+ $this->assertIdentical($recursion_limit_values, [50]);
$core_extension = $this->config('core.extension')->get();
unset($core_extension['module']['action']);
@@ -180,8 +180,8 @@ class ConfigImportUITest extends WebTestBase {
$sync->write('system.theme', $system_theme);
// Set the state system to record installations and uninstallations.
- \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', array());
- \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', array());
+ \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', []);
+ \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', []);
// Verify that both appear as ready to import.
$this->drupalGet('admin/config/development/configuration');
@@ -190,7 +190,7 @@ class ConfigImportUITest extends WebTestBase {
$this->assertRaw('<td>action.settings');
// Import and verify that both do not appear anymore.
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$this->assertNoRaw('<td>core.extension');
$this->assertNoRaw('<td>system.theme');
$this->assertNoRaw('<td>action.settings');
@@ -203,9 +203,9 @@ class ConfigImportUITest extends WebTestBase {
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('text'), 'Text module uninstalled during import.');
// Ensure installations and uninstallation occur as expected.
- $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array());
- $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
- $expected = array('options', 'text', 'ban', 'action');
+ $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', []);
+ $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
+ $expected = ['options', 'text', 'ban', 'action'];
$this->assertIdentical($expected, $uninstalled, 'Options, Text, Ban and Action modules uninstalled in the correct order.');
$this->assertTrue(empty($installed), 'No modules installed during import');
@@ -235,7 +235,7 @@ class ConfigImportUITest extends WebTestBase {
$this->container->get('lock.persistent')->acquire($config_importer::LOCK_NAME);
// Attempt to import configuration and verify that an error message appears.
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$this->assertText(t('Another request may be synchronizing configuration already.'));
// Release the lock, just to keep testing sane.
@@ -273,11 +273,11 @@ class ConfigImportUITest extends WebTestBase {
$add_key = 'biff';
$add_data = '<em>bangpow</em>';
$change_data = '<p><em>foobar</em></p>';
- $original_data = array(
+ $original_data = [
'foo' => '<p>foobar</p>',
'baz' => '<strong>no change</strong>',
'404' => '<em>herp</em>',
- );
+ ];
// Update active storage to have html in config data.
$this->config($config_name)->setData($original_data)->save();
@@ -290,7 +290,7 @@ class ConfigImportUITest extends WebTestBase {
// Load the diff UI and verify that the diff reflects the change.
$this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name);
- $this->assertTitle(format_string('View changes of @config_name | Drupal', array('@config_name' => $config_name)));
+ $this->assertTitle(format_string('View changes of @config_name | Drupal', ['@config_name' => $config_name]));
// The following assertions do not use $this::assertEscaped() because
// \Drupal\Component\Diff\DiffFormatter adds markup that signifies what has
@@ -307,7 +307,7 @@ class ConfigImportUITest extends WebTestBase {
$this->assertText(Html::escape("404: '<em>herp</em>'"));
// Verify diff colors are displayed.
- $result = $this->xpath('//table[contains(@class, :class)]', array(':class' => 'diff'));
+ $result = $this->xpath('//table[contains(@class, :class)]', [':class' => 'diff']);
$this->assertEqual(count($result), 1, "Diff UI is displaying colors.");
// Reset data back to original, and remove a key
@@ -351,7 +351,7 @@ class ConfigImportUITest extends WebTestBase {
$this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('There are no configuration changes to import.'));
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
// Verify that the validation messages appear.
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
@@ -373,7 +373,7 @@ class ConfigImportUITest extends WebTestBase {
$this->assertText('core.extension');
// Import and verify that both do not appear anymore.
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$this->assertText('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.');
}
@@ -394,11 +394,11 @@ class ConfigImportUITest extends WebTestBase {
$sync = $this->container->get('config.storage.sync');
$uuid = $this->container->get('uuid');
- $values_primary = array(
+ $values_primary = [
'uuid' => $uuid->generate(),
'langcode' => 'en',
'status' => TRUE,
- 'dependencies' => array(),
+ 'dependencies' => [],
'id' => 'primary',
'label' => 'Primary',
'weight' => 0,
@@ -406,16 +406,16 @@ class ConfigImportUITest extends WebTestBase {
'size' => NULL,
'size_value' => NULL,
'protected_property' => NULL,
- );
+ ];
$sync->write($name_primary, $values_primary);
- $values_secondary = array(
+ $values_secondary = [
'uuid' => $uuid->generate(),
'langcode' => 'en',
'status' => TRUE,
// Add a dependency on primary, to ensure that is synced first.
- 'dependencies' => array(
- 'config' => array($name_primary),
- ),
+ 'dependencies' => [
+ 'config' => [$name_primary],
+ ],
'id' => 'secondary',
'label' => 'Secondary Sync',
'weight' => 0,
@@ -423,15 +423,15 @@ class ConfigImportUITest extends WebTestBase {
'size' => NULL,
'size_value' => NULL,
'protected_property' => NULL,
- );
+ ];
$sync->write($name_secondary, $values_secondary);
// Verify that there are configuration differences to import.
$this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('There are no configuration changes to import.'));
// Attempt to import configuration and verify that an error message appears.
- $this->drupalPostForm(NULL, array(), t('Import all'));
- $this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary)));
+ $this->drupalPostForm(NULL, [], t('Import all'));
+ $this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', ['@name' => $name_secondary]));
$this->assertText(t('The configuration was imported with errors.'));
$this->assertNoText(t('The configuration was imported successfully.'));
$this->assertText(t('There are no configuration changes to import.'));
@@ -443,42 +443,42 @@ class ConfigImportUITest extends WebTestBase {
* @see \Drupal\Core\Entity\Event\BundleConfigImportValidate
*/
public function testEntityBundleDelete() {
- \Drupal::service('module_installer')->install(array('node'));
+ \Drupal::service('module_installer')->install(['node']);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
$node_type = $this->drupalCreateContentType();
- $node = $this->drupalCreateNode(array('type' => $node_type->id()));
+ $node = $this->drupalCreateNode(['type' => $node_type->id()]);
$this->drupalGet('admin/config/development/configuration');
// The node type, body field and entity displays will be scheduled for
// removal.
- $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id())));
- $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
- $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
- $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
- $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
+ $this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()]));
// Attempt to import configuration and verify that an error message appears
// and the node type, body field and entity displays are still scheduled for
// removal.
- $this->drupalPostForm(NULL, array(), t('Import all'));
- $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', array('%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()));
+ $this->drupalPostForm(NULL, [], t('Import all'));
+ $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]);
$this->assertRaw($validation_message);
- $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id())));
- $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
- $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
- $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
- $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
+ $this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()]));
+ $this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()]));
// Delete the node and try to import again.
$node->delete();
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$this->assertNoRaw($validation_message);
$this->assertText(t('There are no configuration changes to import.'));
- $this->assertNoText(format_string('node.type.@type', array('@type' => $node_type->id())));
- $this->assertNoText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
- $this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
- $this->assertNoText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
- $this->assertNoText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
+ $this->assertNoText(format_string('node.type.@type', ['@type' => $node_type->id()]));
+ $this->assertNoText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()]));
+ $this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()]));
+ $this->assertNoText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()]));
+ $this->assertNoText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()]));
}
/**
@@ -508,7 +508,7 @@ class ConfigImportUITest extends WebTestBase {
$core['theme']['does_not_exist'] = 0;
$sync->write('core.extension', $core);
- $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
+ $this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
$this->assertText('Unable to uninstall the Text module since the Node module is installed.');
$this->assertText('Unable to uninstall the Classy theme since the Bartik theme is installed.');
diff --git a/core/modules/config/src/Tests/ConfigImportUploadTest.php b/core/modules/config/src/Tests/ConfigImportUploadTest.php
index 9836d771dd1..9792213a688 100644
--- a/core/modules/config/src/Tests/ConfigImportUploadTest.php
+++ b/core/modules/config/src/Tests/ConfigImportUploadTest.php
@@ -23,12 +23,12 @@ class ConfigImportUploadTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('config');
+ public static $modules = ['config'];
protected function setUp() {
parent::setUp();
- $this->webUser = $this->drupalCreateUser(array('import configuration'));
+ $this->webUser = $this->drupalCreateUser(['import configuration']);
$this->drupalLogin($this->webUser);
}
@@ -42,7 +42,7 @@ class ConfigImportUploadTest extends WebTestBase {
// Attempt to upload a non-tar file.
$text_file = current($this->drupalGetTestFiles('text'));
- $edit = array('files[import_tarball]' => drupal_realpath($text_file->uri));
+ $edit = ['files[import_tarball]' => drupal_realpath($text_file->uri)];
$this->drupalPostForm('admin/config/development/configuration/full/import', $edit, t('Upload'));
$this->assertText(t('Could not extract the contents of the tar file'));
diff --git a/core/modules/config/src/Tests/ConfigInstallWebTest.php b/core/modules/config/src/Tests/ConfigInstallWebTest.php
index 8f9e1a1b8f9..79b50a0a672 100644
--- a/core/modules/config/src/Tests/ConfigInstallWebTest.php
+++ b/core/modules/config/src/Tests/ConfigInstallWebTest.php
@@ -26,7 +26,7 @@ class ConfigInstallWebTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer modules', 'administer themes', 'administer site configuration'));
+ $this->adminUser = $this->drupalCreateUser(['administer modules', 'administer themes', 'administer site configuration']);
// Ensure the global variable being asserted by this test does not exist;
// a previous test executed in this request/process might have set it.
@@ -41,7 +41,7 @@ class ConfigInstallWebTest extends WebTestBase {
$default_configuration_entity = 'config_test.dynamic.config_integration_test';
// Install the config_test module we're integrating with.
- \Drupal::service('module_installer')->install(array('config_test'));
+ \Drupal::service('module_installer')->install(['config_test']);
// Verify the configuration does not exist prior to installation.
$config_static = $this->config($default_config);
@@ -50,7 +50,7 @@ class ConfigInstallWebTest extends WebTestBase {
$this->assertIdentical($config_entity->isNew(), TRUE);
// Install the integration module.
- \Drupal::service('module_installer')->install(array('config_integration_test'));
+ \Drupal::service('module_installer')->install(['config_integration_test']);
// Verify that default module config exists.
\Drupal::configFactory()->reset($default_config);
@@ -73,7 +73,7 @@ class ConfigInstallWebTest extends WebTestBase {
$this->container->get('config.factory')->reset();
// Disable and uninstall the integration module.
- $this->container->get('module_installer')->uninstall(array('config_integration_test'));
+ $this->container->get('module_installer')->uninstall(['config_integration_test']);
// Verify the integration module's config was uninstalled.
$config_static = $this->config($default_config);
@@ -86,7 +86,7 @@ class ConfigInstallWebTest extends WebTestBase {
// Reinstall the integration module.
try {
- \Drupal::service('module_installer')->install(array('config_integration_test'));
+ \Drupal::service('module_installer')->install(['config_integration_test']);
$this->fail('Expected PreExistingConfigException not thrown.');
}
catch (PreExistingConfigException $e) {
@@ -97,7 +97,7 @@ class ConfigInstallWebTest extends WebTestBase {
// Delete the configuration entity so that the install will work.
$config_entity->delete();
- \Drupal::service('module_installer')->install(array('config_integration_test'));
+ \Drupal::service('module_installer')->install(['config_integration_test']);
// Verify the integration module's config was re-installed.
\Drupal::configFactory()->reset($default_config);
@@ -122,19 +122,19 @@ class ConfigInstallWebTest extends WebTestBase {
// will install the config_test module first because it is a dependency of
// config_install_fail_test.
// @see \Drupal\system\Form\ModulesListForm::submitForm()
- $this->drupalPostForm('admin/modules', array('modules[config_test][enable]' => TRUE, 'modules[config_install_fail_test][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE, 'modules[config_install_fail_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
// Uninstall the config_test module to test the confirm form.
- $this->drupalPostForm('admin/modules/uninstall', array('uninstall[config_test]' => TRUE), t('Uninstall'));
- $this->drupalPostForm(NULL, array(), t('Uninstall'));
+ $this->drupalPostForm('admin/modules/uninstall', ['uninstall[config_test]' => TRUE], t('Uninstall'));
+ $this->drupalPostForm(NULL, [], t('Uninstall'));
// Try to install config_install_fail_test without selecting config_test.
// The user is shown a confirm form because the config_test module is a
// dependency.
// @see \Drupal\system\Form\ModulesListConfirmForm::submitForm()
- $this->drupalPostForm('admin/modules', array('modules[config_install_fail_test][enable]' => TRUE), t('Install'));
- $this->drupalPostForm(NULL, array(), t('Continue'));
+ $this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('Install'));
+ $this->drupalPostForm(NULL, [], t('Continue'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
// Test that collection configuration clashes during a module install are
@@ -147,7 +147,7 @@ class ConfigInstallWebTest extends WebTestBase {
->set('label', 'Je suis Charlie')
->save();
- $this->drupalPostForm('admin/modules', array('modules[config_install_fail_test][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.');
// Test installing a theme through the UI that has existing configuration.
@@ -178,16 +178,16 @@ class ConfigInstallWebTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
// We need to install separately since config_install_dependency_test does
// not depend on config_test and order is important.
- $this->drupalPostForm('admin/modules', array('modules[config_test][enable]' => TRUE), t('Install'));
- $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE], t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
- $this->drupalPostForm('admin/modules', array('modules[config_test_language][enable]' => TRUE), t('Install'));
- $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_test_language][enable]' => TRUE], t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');
- $this->drupalPostForm('admin/modules', array('modules[config_other_module_config_test][enable]' => TRUE), t('Install'));
- $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_other_module_config_test][enable]' => TRUE], t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
$this->rebuildContainer();
$this->assertTrue(entity_load('config_test', 'other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.');
}
@@ -197,12 +197,12 @@ class ConfigInstallWebTest extends WebTestBase {
*/
public function testConfigModuleRequirements() {
$this->drupalLogin($this->adminUser);
- $this->drupalPostForm('admin/modules', array('modules[config][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[config][enable]' => TRUE], t('Install'));
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
file_unmanaged_delete_recursive($directory);
$this->drupalGet('/admin/reports/status');
- $this->assertRaw(t('The directory %directory does not exist.', array('%directory' => $directory)));
+ $this->assertRaw(t('The directory %directory does not exist.', ['%directory' => $directory]));
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
\Drupal::service('file_system')->chmod($directory, 0555);
diff --git a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php
index 53f6164cc6b..16cff0aa8a7 100644
--- a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php
+++ b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php
@@ -39,7 +39,7 @@ class ConfigSingleImportExportTest extends WebTestBase {
$storage = \Drupal::entityManager()->getStorage('config_test');
$uuid = \Drupal::service('uuid');
- $this->drupalLogin($this->drupalCreateUser(array('import configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['import configuration']));
// Attempt an import with invalid YAML.
$edit = [
@@ -57,20 +57,20 @@ weight: 0
style: ''
status: '1'
EOD;
- $edit = array(
+ $edit = [
'config_type' => 'config_test',
'import' => $import,
- );
+ ];
// Attempt an import with a missing ID.
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
- $this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => 'id', '@entity_type' => 'Test configuration')));
+ $this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', ['@id_key' => 'id', '@entity_type' => 'Test configuration']));
// Perform an import with no specified UUID and a unique ID.
$this->assertNull($storage->load('first'));
$edit['import'] = "id: first\n" . $edit['import'];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
- $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'first', '@type' => 'test configuration')));
- $this->drupalPostForm(NULL, array(), t('Confirm'));
+ $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration']));
+ $this->drupalPostForm(NULL, [], t('Confirm'));
$entity = $storage->load('first');
$this->assertIdentical($entity->label(), 'First');
$this->assertIdentical($entity->id(), 'first');
@@ -89,8 +89,8 @@ EOD;
// Attempt an import with a custom ID.
$edit['custom_entity_id'] = 'custom_id';
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
- $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'custom_id', '@type' => 'test configuration')));
- $this->drupalPostForm(NULL, array(), t('Confirm'));
+ $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration']));
+ $this->drupalPostForm(NULL, [], t('Confirm'));
$this->assertRaw(t('The configuration was imported successfully.'));
// Perform an import with a unique ID and UUID.
@@ -101,15 +101,15 @@ weight: 0
style: ''
status: '0'
EOD;
- $edit = array(
+ $edit = [
'config_type' => 'config_test',
'import' => $import,
- );
+ ];
$second_uuid = $uuid->generate();
$edit['import'] .= "\nuuid: " . $second_uuid;
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
- $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'second', '@type' => 'test configuration')));
- $this->drupalPostForm(NULL, array(), t('Confirm'));
+ $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
+ $this->drupalPostForm(NULL, [], t('Confirm'));
$entity = $storage->load('second');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertIdentical($entity->label(), 'Second');
@@ -126,13 +126,13 @@ weight: 0
style: ''
status: '0'
EOD;
- $edit = array(
+ $edit = [
'config_type' => 'config_test',
'import' => $import,
- );
+ ];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
- $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => 'second', '@type' => 'test configuration')));
- $this->drupalPostForm(NULL, array(), t('Confirm'));
+ $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
+ $this->drupalPostForm(NULL, [], t('Confirm'));
$entity = $storage->load('second');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertIdentical($entity->label(), 'Second updated');
@@ -149,10 +149,10 @@ dependencies:
module:
- does_not_exist
EOD;
- $edit = array(
+ $edit = [
'config_type' => 'config_test',
'import' => $import,
- );
+ ];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist']));
}
@@ -161,20 +161,20 @@ EOD;
* Tests importing a simple configuration file.
*/
public function testImportSimpleConfiguration() {
- $this->drupalLogin($this->drupalCreateUser(array('import configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['import configuration']));
$config = $this->config('system.site')->set('name', 'Test simple import');
// Place branding block with site name into header region.
$this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
- $edit = array(
+ $edit = [
'config_type' => 'system.simple',
'config_name' => $config->getName(),
'import' => Yaml::encode($config->get()),
- );
+ ];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
- $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => $config->getName(), '@type' => 'simple configuration')));
- $this->drupalPostForm(NULL, array(), t('Confirm'));
+ $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration']));
+ $this->drupalPostForm(NULL, [], t('Confirm'));
$this->drupalGet('');
$this->assertText('Test simple import');
@@ -183,11 +183,11 @@ EOD;
$config_data = $this->config('core.extension')->get();
// Simulate uninstalling the Config module.
unset($config_data['module']['config']);
- $edit = array(
+ $edit = [
'config_type' => 'system.simple',
'config_name' => 'core.extension',
'import' => Yaml::encode($config_data),
- );
+ ];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertText(t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'));
@@ -197,14 +197,14 @@ EOD;
* Tests exporting a single configuration file.
*/
public function testExport() {
- $this->drupalLogin($this->drupalCreateUser(array('export configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['export configuration']));
$this->drupalGet('admin/config/development/configuration/single/export/system.simple');
$this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Simple configuration'), 'The simple configuration option is selected when specified in the URL.');
// Spot check several known simple configuration files.
$element = $this->xpath('//select[@name="config_name"]');
$options = $this->getAllOptions($element[0]);
- $expected_options = array('system.site', 'user.settings');
+ $expected_options = ['system.site', 'user.settings'];
foreach ($options as &$option) {
$option = (string) $option;
}
diff --git a/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php b/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php
index 1aa4c9a2bf4..ba67960650b 100644
--- a/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php
+++ b/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php
@@ -12,7 +12,7 @@ use Drupal\simpletest\WebTestBase;
*/
class LanguageNegotiationFormOverrideTest extends WebTestBase {
- public static $modules = array('language', 'locale', 'locale_test');
+ public static $modules = ['language', 'locale', 'locale_test'];
/**
* Tests that overrides do not affect language-negotiation form values.
@@ -23,16 +23,16 @@ class LanguageNegotiationFormOverrideTest extends WebTestBase {
$overridden_value_es = 'loquesea';
// Set up an override.
- $settings['config']['language.negotiation']['url']['prefixes'] = (object) array(
- 'value' => array('en' => $overridden_value_en, 'es' => $overridden_value_es),
+ $settings['config']['language.negotiation']['url']['prefixes'] = (object) [
+ 'value' => ['en' => $overridden_value_en, 'es' => $overridden_value_es],
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
// Add predefined language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'es',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Overridden string for language-negotiation should not exist in the form.
diff --git a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php
index da3a9f1131d..76714a5b97d 100644
--- a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php
+++ b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php
@@ -33,7 +33,7 @@ class EventSubscriber implements EventSubscriberInterface {
* The configuration collection info event.
*/
public function addCollections(ConfigCollectionInfo $collection_info) {
- $collections = $this->state->get('config_collection_install_test.collection_names', array());
+ $collections = $this->state->get('config_collection_install_test.collection_names', []);
foreach ($collections as $collection) {
$collection_info->addCollection($collection);
}
@@ -43,7 +43,7 @@ class EventSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::COLLECTION_INFO][] = array('addCollections');
+ $events[ConfigEvents::COLLECTION_INFO][] = ['addCollections'];
return $events;
}
diff --git a/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php b/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php
index 2345d55175a..8d21ee4e832 100644
--- a/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php
+++ b/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php
@@ -15,11 +15,11 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface {
* {@inheritdoc}
*/
public function loadOverrides($names) {
- return array(
- 'config_test.dynamic.test_1' => array(
+ return [
+ 'config_test.dynamic.test_1' => [
'label' => 'Overridden label',
- )
- );
+ ]
+ ];
}
/**
diff --git a/core/modules/config/tests/config_events_test/src/EventSubscriber.php b/core/modules/config/tests/config_events_test/src/EventSubscriber.php
index bfa70db3ca8..39e8eb80fc1 100644
--- a/core/modules/config/tests/config_events_test/src/EventSubscriber.php
+++ b/core/modules/config/tests/config_events_test/src/EventSubscriber.php
@@ -37,21 +37,21 @@ class EventSubscriber implements EventSubscriberInterface {
*/
public function configEventRecorder(ConfigCrudEvent $event, $name) {
$config = $event->getConfig();
- $this->state->set('config_events_test.event', array(
+ $this->state->set('config_events_test.event', [
'event_name' => $name,
'current_config_data' => $config->get(),
'original_config_data' => $config->getOriginal(),
'raw_config_data' => $config->getRawData()
- ));
+ ]);
}
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::SAVE][] = array('configEventRecorder');
- $events[ConfigEvents::DELETE][] = array('configEventRecorder');
- $events[ConfigEvents::RENAME][] = array('configEventRecorder');
+ $events[ConfigEvents::SAVE][] = ['configEventRecorder'];
+ $events[ConfigEvents::DELETE][] = ['configEventRecorder'];
+ $events[ConfigEvents::RENAME][] = ['configEventRecorder'];
return $events;
}
diff --git a/core/modules/config/tests/config_import_test/src/EventSubscriber.php b/core/modules/config/tests/config_import_test/src/EventSubscriber.php
index f4ae97f9647..e0ef923a390 100644
--- a/core/modules/config/tests/config_import_test/src/EventSubscriber.php
+++ b/core/modules/config/tests/config_import_test/src/EventSubscriber.php
@@ -88,14 +88,14 @@ class EventSubscriber implements EventSubscriberInterface {
public function onConfigSave(ConfigCrudEvent $event) {
$config = $event->getConfig();
if ($config->getName() == 'action.settings') {
- $values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', array());
+ $values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', []);
$values[] = $config->get('recursion_limit');
$this->state->set('ConfigImportUITest.action.settings.recursion_limit', $values);
}
if ($config->getName() == 'core.extension') {
- $installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', array());
- $uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
+ $installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', []);
+ $uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
$original = $config->getOriginal('module');
$data = $config->get('module');
$install = array_diff_key($data, $original);
@@ -132,10 +132,10 @@ class EventSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::SAVE][] = array('onConfigSave', 40);
- $events[ConfigEvents::DELETE][] = array('onConfigDelete', 40);
- $events[ConfigEvents::IMPORT_VALIDATE] = array('onConfigImporterValidate');
- $events[ConfigEvents::IMPORT_MISSING_CONTENT] = array(array('onConfigImporterMissingContentOne'), array('onConfigImporterMissingContentTwo', -100));
+ $events[ConfigEvents::SAVE][] = ['onConfigSave', 40];
+ $events[ConfigEvents::DELETE][] = ['onConfigDelete', 40];
+ $events[ConfigEvents::IMPORT_VALIDATE] = ['onConfigImporterValidate'];
+ $events[ConfigEvents::IMPORT_MISSING_CONTENT] = [['onConfigImporterMissingContentOne'], ['onConfigImporterMissingContentTwo', -100]];
return $events;
}
diff --git a/core/modules/config/tests/config_override_test/src/ConfigOverrider.php b/core/modules/config/tests/config_override_test/src/ConfigOverrider.php
index 895f041b5b6..c8ffc694b3f 100644
--- a/core/modules/config/tests/config_override_test/src/ConfigOverrider.php
+++ b/core/modules/config/tests/config_override_test/src/ConfigOverrider.php
@@ -14,13 +14,13 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface {
* {@inheritdoc}
*/
public function loadOverrides($names) {
- $overrides = array();
+ $overrides = [];
if (!empty($GLOBALS['config_test_run_module_overrides'])) {
if (in_array('system.site', $names)) {
- $overrides = $overrides + array('system.site' => array('name' => 'ZOMG overridden site name'));
+ $overrides = $overrides + ['system.site' => ['name' => 'ZOMG overridden site name']];
}
if (in_array('config_override_test.new', $names)) {
- $overrides = $overrides + array('config_override_test.new' => array('module' => 'override'));
+ $overrides = $overrides + ['config_override_test.new' => ['module' => 'override']];
}
}
return $overrides;
diff --git a/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php b/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php
index 6f0b12d1efc..b8109db6826 100644
--- a/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php
+++ b/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php
@@ -15,17 +15,17 @@ class ConfigOverriderLowPriority implements ConfigFactoryOverrideInterface {
* {@inheritdoc}
*/
public function loadOverrides($names) {
- $overrides = array();
+ $overrides = [];
if (!empty($GLOBALS['config_test_run_module_overrides'])) {
if (in_array('system.site', $names)) {
- $overrides = array('system.site' =>
- array(
+ $overrides = ['system.site' =>
+ [
'name' => 'Should not apply because of higher priority listener',
// This override should apply because it is not overridden by the
// higher priority listener.
'slogan' => 'Yay for overrides!',
- )
- );
+ ]
+ ];
}
}
return $overrides;
diff --git a/core/modules/config/tests/config_test/src/ConfigTestController.php b/core/modules/config/tests/config_test/src/ConfigTestController.php
index d60c62e5cef..6799dc1b6f0 100644
--- a/core/modules/config/tests/config_test/src/ConfigTestController.php
+++ b/core/modules/config/tests/config_test/src/ConfigTestController.php
@@ -21,7 +21,7 @@ class ConfigTestController extends ControllerBase {
* The title for the ConfigTest edit form.
*/
public function editTitle(ConfigTest $config_test) {
- return $this->t('Edit %label', array('%label' => $config_test->label()));
+ return $this->t('Edit %label', ['%label' => $config_test->label()]);
}
/**
@@ -35,7 +35,7 @@ class ConfigTestController extends ControllerBase {
*/
function enable(ConfigTest $config_test) {
$config_test->enable()->save();
- return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE)));
+ return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));
}
/**
@@ -49,7 +49,7 @@ class ConfigTestController extends ControllerBase {
*/
function disable(ConfigTest $config_test) {
$config_test->disable()->save();
- return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE)));
+ return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));
}
}
diff --git a/core/modules/config/tests/config_test/src/ConfigTestForm.php b/core/modules/config/tests/config_test/src/ConfigTestForm.php
index 8384e6a66a0..6a56c3dfb1e 100644
--- a/core/modules/config/tests/config_test/src/ConfigTestForm.php
+++ b/core/modules/config/tests/config_test/src/ConfigTestForm.php
@@ -18,33 +18,33 @@ class ConfigTestForm extends EntityForm {
$form = parent::form($form, $form_state);
$entity = $this->entity;
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => 'Label',
'#default_value' => $entity->label(),
'#required' => TRUE,
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $entity->id(),
'#required' => TRUE,
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => [$this, 'exists'],
'replace_pattern' => '[^a-z0-9_.]+',
- ),
- );
- $form['weight'] = array(
+ ],
+ ];
+ $form['weight'] = [
'#type' => 'weight',
'#title' => 'Weight',
'#default_value' => $entity->get('weight'),
- );
- $form['style'] = array(
+ ];
+ $form['style'] = [
'#type' => 'select',
'#title' => 'Image style',
- '#options' => array(),
+ '#options' => [],
'#default_value' => $entity->get('style'),
'#access' => FALSE,
- );
+ ];
if ($this->moduleHandler->moduleExists('image')) {
$form['style']['#access'] = TRUE;
$form['style']['#options'] = image_style_options();
@@ -55,61 +55,61 @@ class ConfigTestForm extends EntityForm {
// state.
$size = $entity->get('size');
- $form['size_wrapper'] = array(
+ $form['size_wrapper'] = [
'#type' => 'container',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'size-wrapper',
- ),
- );
- $form['size_wrapper']['size'] = array(
+ ],
+ ];
+ $form['size_wrapper']['size'] = [
'#type' => 'select',
'#title' => 'Size',
- '#options' => array(
+ '#options' => [
'custom' => 'Custom',
- ),
+ ],
'#empty_option' => '- None -',
'#default_value' => $size,
- '#ajax' => array(
+ '#ajax' => [
'callback' => '::updateSize',
'wrapper' => 'size-wrapper',
- ),
- );
- $form['size_wrapper']['size_submit'] = array(
+ ],
+ ];
+ $form['size_wrapper']['size_submit'] = [
'#type' => 'submit',
'#value' => t('Change size'),
- '#attributes' => array(
- 'class' => array('js-hide'),
- ),
- '#submit' => array(array(get_class($this), 'changeSize')),
- );
- $form['size_wrapper']['size_value'] = array(
+ '#attributes' => [
+ 'class' => ['js-hide'],
+ ],
+ '#submit' => [[get_class($this), 'changeSize']],
+ ];
+ $form['size_wrapper']['size_value'] = [
'#type' => 'select',
'#title' => 'Custom size value',
- '#options' => array(
+ '#options' => [
'small' => 'Small',
'medium' => 'Medium',
'large' => 'Large',
- ),
+ ],
'#default_value' => $entity->get('size_value'),
'#access' => !empty($size),
- );
+ ];
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'language_select',
'#title' => t('Language'),
'#languages' => LanguageInterface::STATE_ALL,
'#default_value' => $entity->language()->getId(),
- );
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- );
- $form['actions']['delete'] = array(
+ ];
+ $form['actions']['delete'] = [
'#type' => 'submit',
'#value' => 'Delete',
- );
+ ];
return $form;
}
@@ -136,10 +136,10 @@ class ConfigTestForm extends EntityForm {
$status = $entity->save();
if ($status === SAVED_UPDATED) {
- drupal_set_message(format_string('%label configuration has been updated.', array('%label' => $entity->label())));
+ drupal_set_message(format_string('%label configuration has been updated.', ['%label' => $entity->label()]));
}
else {
- drupal_set_message(format_string('%label configuration has been created.', array('%label' => $entity->label())));
+ drupal_set_message(format_string('%label configuration has been created.', ['%label' => $entity->label()]));
}
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php
index 10914f01964..ca3b354984d 100644
--- a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php
+++ b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php
@@ -38,6 +38,6 @@ class ConfigQueryTest extends ConfigTest {
*
* @var array
*/
- public $array = array();
+ public $array = [];
}
diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php
index f19eb65ae22..1bd1d8dee9b 100644
--- a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php
+++ b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php
@@ -88,10 +88,10 @@ class ConfigTest extends ConfigEntityBase implements ConfigTestInterface {
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
// Used to test secondary writes during config sync.
if ($this->id() == 'primary') {
- $secondary = $storage->create(array(
+ $secondary = $storage->create([
'id' => 'secondary',
'label' => 'Secondary Default',
- ));
+ ]);
$secondary->save();
}
if ($this->id() == 'deleter') {
@@ -126,7 +126,7 @@ class ConfigTest extends ConfigEntityBase implements ConfigTestInterface {
if (!isset($this->dependencies['enforced']['config'])) {
return $changed;
}
- $fix_deps = \Drupal::state()->get('config_test.fix_dependencies', array());
+ $fix_deps = \Drupal::state()->get('config_test.fix_dependencies', []);
foreach ($dependencies['config'] as $entity) {
if (in_array($entity->getConfigDependencyName(), $fix_deps)) {
$key = array_search($entity->getConfigDependencyName(), $this->dependencies['enforced']['config']);
diff --git a/core/modules/config/tests/config_test/src/TestInstallStorage.php b/core/modules/config/tests/config_test/src/TestInstallStorage.php
index 074e99ca611..e3c4918df40 100644
--- a/core/modules/config/tests/config_test/src/TestInstallStorage.php
+++ b/core/modules/config/tests/config_test/src/TestInstallStorage.php
@@ -20,7 +20,7 @@ class TestInstallStorage extends InstallStorage {
if (!isset($this->folders)) {
$this->folders = $this->getCoreNames();
$listing = new ExtensionDiscovery(\Drupal::root());
- $listing->setProfileDirectories(array());
+ $listing->setProfileDirectories([]);
$this->folders += $this->getComponentNames($listing->scan('profile'));
$this->folders += $this->getComponentNames($listing->scan('module'));
$this->folders += $this->getComponentNames($listing->scan('theme'));
diff --git a/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php b/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php
index c243e9ac227..ba80401bc4d 100644
--- a/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php
@@ -22,7 +22,7 @@ class ConfigDependencyWebTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Tests ConfigDependencyDeleteFormTrait.
@@ -36,10 +36,10 @@ class ConfigDependencyWebTest extends BrowserTestBase {
$storage = $this->container->get('entity.manager')->getStorage('config_test');
// Entity1 will be deleted by the test.
$entity1 = $storage->create(
- array(
+ [
'id' => 'entity1',
'label' => 'Entity One',
- )
+ ]
);
$entity1->save();
@@ -47,14 +47,14 @@ class ConfigDependencyWebTest extends BrowserTestBase {
// \Drupal\config_test\Entity::onDependencyRemoval() will remove the
// dependency before config entities are deleted.
$entity2 = $storage->create(
- array(
+ [
'id' => 'entity2',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity1->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity1->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity2->save();
@@ -65,47 +65,47 @@ class ConfigDependencyWebTest extends BrowserTestBase {
$this->assertNoText(t('Configuration updates'), 'No configuration updates found.');
$this->assertText(t('Configuration deletions'), 'Configuration deletions found.');
$this->assertText($entity2->id(), 'Entity2 id found');
- $this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete');
+ $this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete');
$storage->resetCache();
$this->assertFalse($storage->loadMultiple([$entity1->id(), $entity2->id()]), 'Test entities deleted');
// Set a more complicated test where dependencies will be fixed.
// Entity1 will be deleted by the test.
$entity1 = $storage->create(
- array(
+ [
'id' => 'entity1',
- )
+ ]
);
$entity1->save();
- \Drupal::state()->set('config_test.fix_dependencies', array($entity1->getConfigDependencyName()));
+ \Drupal::state()->set('config_test.fix_dependencies', [$entity1->getConfigDependencyName()]);
// Entity2 has a dependency on Entity1 but it can be fixed because
// \Drupal\config_test\Entity::onDependencyRemoval() will remove the
// dependency before config entities are deleted.
$entity2 = $storage->create(
- array(
+ [
'id' => 'entity2',
'label' => 'Entity Two',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity1->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity1->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity2->save();
// Entity3 will be unchanged because it is dependent on Entity2 which can
// be fixed.
$entity3 = $storage->create(
- array(
+ [
'id' => 'entity3',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity2->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity2->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity3->save();
@@ -115,12 +115,12 @@ class ConfigDependencyWebTest extends BrowserTestBase {
$this->assertNoText($entity2->id(), 'Entity2 id not found');
$this->assertText($entity2->label(), 'Entity2 label not found');
$this->assertNoText($entity3->id(), 'Entity3 id not found');
- $this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete');
+ $this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete');
$storage->resetCache();
$this->assertFalse($storage->load('entity1'), 'Test entity 1 deleted');
$entity2 = $storage->load('entity2');
$this->assertTrue($entity2, 'Entity 2 not deleted');
- $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.');
+ $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], [], 'Entity 2 dependencies updated to remove dependency on Entity1.');
$entity3 = $storage->load('entity3');
$this->assertTrue($entity3, 'Entity 3 not deleted');
$this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.');
diff --git a/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php b/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php
index 417e9f13cbf..74829359a10 100644
--- a/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php
@@ -15,13 +15,13 @@ class ConfigDraggableListBuilderTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Test draggable lists.
*/
public function testDraggableList() {
- $this->drupalLogin($this->drupalCreateUser(array('administer permissions')));
+ $this->drupalLogin($this->drupalCreateUser(['administer permissions']));
// Create more than 50 roles.
for ($i = 0; $i < 51; $i++) {
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php
index 6c40dedcd6f..5d99252d9c9 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php
@@ -17,7 +17,7 @@ class ConfigEntityListMultilingualTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('config_test', 'language', 'block');
+ public static $modules = ['config_test', 'language', 'block'];
/**
* {@inheritdoc}
@@ -36,7 +36,7 @@ class ConfigEntityListMultilingualTest extends BrowserTestBase {
*/
function testListUI() {
// Log in as an administrative user to access the full menu trail.
- $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
// Get the list page.
$this->drupalGet('admin/structure/config_test');
@@ -44,11 +44,11 @@ class ConfigEntityListMultilingualTest extends BrowserTestBase {
// Add a new entity using the action link.
$this->clickLink('Add test configuration');
- $edit = array(
+ $edit = [
'label' => 'Antilop',
'id' => 'antilop',
'langcode' => 'hu',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Ensure that operations for editing the Hungarian entity appear in English.
$this->assertLinkByHref('admin/structure/config_test/manage/antilop');
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php
index 9ae94125477..4ad4d59b9d2 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php
@@ -16,7 +16,7 @@ class ConfigEntityStatusUITest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Tests status operations.
@@ -25,10 +25,10 @@ class ConfigEntityStatusUITest extends BrowserTestBase {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$id = strtolower($this->randomMachineName());
- $edit = array(
+ $edit = [
'id' => $id,
'label' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$entity = entity_load('config_test', $id);
diff --git a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php
index 9ed75a4e935..88218b9899f 100644
--- a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php
@@ -31,21 +31,21 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase {
function testInstallProfileConfigOverwrite() {
$config_name = 'system.cron';
// The expected configuration from the system module.
- $expected_original_data = array(
- 'threshold' => array(
+ $expected_original_data = [
+ 'threshold' => [
'requirements_warning' => 172800,
'requirements_error' => 1209600,
- ),
+ ],
'logging' => 1,
- );
+ ];
// The expected active configuration altered by the install profile.
- $expected_profile_data = array(
- 'threshold' => array(
+ $expected_profile_data = [
+ 'threshold' => [
'requirements_warning' => 259200,
'requirements_error' => 1209600,
- ),
+ ],
'logging' => 1,
- );
+ ];
$expected_profile_data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($expected_profile_data));
// Verify that the original data matches. We have to read the module config
diff --git a/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php b/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php
index 5aa194edcf3..5fdd1a14417 100644
--- a/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php
@@ -35,18 +35,18 @@ class ConfigLanguageOverrideWebTest extends BrowserTestBase {
* Tests translating the site name.
*/
function testSiteNameTranslation() {
- $adminUser = $this->drupalCreateUser(array('administer site configuration', 'administer languages'));
+ $adminUser = $this->drupalCreateUser(['administer site configuration', 'administer languages']);
$this->drupalLogin($adminUser);
// Add a custom language.
$langcode = 'xx';
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
\Drupal::languageManager()
->getLanguageConfigOverride($langcode, 'system.site')
diff --git a/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php b/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php
index e1d0d8d5be7..a99676072b5 100644
--- a/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php
@@ -87,14 +87,14 @@ class ConfigOtherModuleTest extends BrowserTestBase {
public function testUninstall() {
$this->installModule('views');
$storage = $this->container->get('entity_type.manager')->getStorage('view');
- $storage->resetCache(array('frontpage'));
+ $storage->resetCache(['frontpage']);
$this->assertTrue($storage->load('frontpage') === NULL, 'After installing Views, frontpage view which is dependant on the Node and Views modules does not exist.');
$this->installModule('node');
- $storage->resetCache(array('frontpage'));
+ $storage->resetCache(['frontpage']);
$this->assertTrue($storage->load('frontpage') !== NULL, 'After installing Node, frontpage view which is dependant on the Node and Views modules exists.');
$this->uninstallModule('node');
$storage = $this->container->get('entity_type.manager')->getStorage('view');
- $storage->resetCache(array('frontpage'));
+ $storage->resetCache(['frontpage']);
$this->assertTrue($storage->load('frontpage') === NULL, 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.');
}
@@ -105,7 +105,7 @@ class ConfigOtherModuleTest extends BrowserTestBase {
* The module name.
*/
protected function installModule($module) {
- $this->container->get('module_installer')->install(array($module));
+ $this->container->get('module_installer')->install([$module]);
$this->container = \Drupal::getContainer();
}
@@ -116,7 +116,7 @@ class ConfigOtherModuleTest extends BrowserTestBase {
* The module name.
*/
protected function uninstallModule($module) {
- $this->container->get('module_installer')->uninstall(array($module));
+ $this->container->get('module_installer')->uninstall([$module]);
$this->container = \Drupal::getContainer();
}
diff --git a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php
index bab8a3e9baa..189d78fc637 100644
--- a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php
+++ b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php
@@ -15,7 +15,7 @@ class SchemaConfigListenerWebTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Tests \Drupal\Core\Config\Development\ConfigSchemaChecker.
diff --git a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php
index 7dd8d7dac82..0bfb32e93fd 100644
--- a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php
+++ b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php
@@ -12,7 +12,7 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class ConfigLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array('config' => 'core/modules/config');
+ $this->directoryList = ['config' => 'core/modules/config'];
parent::setUp();
}
@@ -29,13 +29,13 @@ class ConfigLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getConfigAdminRoutes() {
- return array(
- array('config.sync', array(array('config.sync', 'config.import', 'config.export'))),
- array('config.import_full', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))),
- array('config.import_single', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))),
- array('config.export_full', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))),
- array('config.export_single', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))),
- );
+ return [
+ ['config.sync', [['config.sync', 'config.import', 'config.export']]],
+ ['config.import_full', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]],
+ ['config.import_single', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]],
+ ['config.export_full', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]],
+ ['config.export_single', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]],
+ ];
}
}
diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php
index f2ee4a290f0..f97e25997ad 100644
--- a/core/modules/config_translation/config_translation.api.php
+++ b/core/modules/config_translation/config_translation.api.php
@@ -50,14 +50,14 @@ function hook_config_translation_info(&$info) {
// Make sure entity type has field UI enabled and has a base route.
if ($entity_type->get('field_ui_base_route') && !empty($base_route)) {
- $info[$entity_type_id . '_fields'] = array(
+ $info[$entity_type_id . '_fields'] = [
'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form',
'entity_type' => 'field_config',
'title' => t('Title'),
'class' => '\Drupal\config_translation\ConfigFieldMapper',
'base_entity_type' => $entity_type_id,
'weight' => 10,
- );
+ ];
}
}
}
diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module
index d018d6402b1..344d90e27b1 100644
--- a/core/modules/config_translation/config_translation.module
+++ b/core/modules/config_translation/config_translation.module
@@ -18,15 +18,15 @@ function config_translation_help($route_name, RouteMatchInterface $route_match)
case 'help.page.config_translation':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Configuration Translation module allows you to translate configuration text; for example, the site name, vocabularies, menus, or date formats. Together with the modules <a href=":language">Language</a>, <a href=":content-translation">Content Translation</a>, and <a href=":locale">Interface Translation</a>, it allows you to build multilingual websites. For more information, see the <a href=":doc_url">online documentation for the Configuration Translation module</a>.', array(':doc_url' => 'https://www.drupal.org/documentation/modules/config_translation', ':config' => \Drupal::url('help.page', array('name' => 'config')), ':language' => \Drupal::url('help.page', array('name' => 'language')), ':locale' => \Drupal::url('help.page', array('name' => 'locale')), ':content-translation' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', array('name' => 'content_translation')) : '#')) . '</p>';
+ $output .= '<p>' . t('The Configuration Translation module allows you to translate configuration text; for example, the site name, vocabularies, menus, or date formats. Together with the modules <a href=":language">Language</a>, <a href=":content-translation">Content Translation</a>, and <a href=":locale">Interface Translation</a>, it allows you to build multilingual websites. For more information, see the <a href=":doc_url">online documentation for the Configuration Translation module</a>.', [':doc_url' => 'https://www.drupal.org/documentation/modules/config_translation', ':config' => \Drupal::url('help.page', ['name' => 'config']), ':language' => \Drupal::url('help.page', ['name' => 'language']), ':locale' => \Drupal::url('help.page', ['name' => 'locale']), ':content-translation' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', ['name' => 'content_translation']) : '#']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Enabling translation') . '</dt>';
- $output .= '<dd>' . t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', array(':url' => \Drupal::url('entity.configurable_language.collection'))) . '</dd>';
+ $output .= '<dd>' . t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', [':url' => \Drupal::url('entity.configurable_language.collection')]) . '</dd>';
$output .= '<dt>' . t('Translating configuration text') . '</dt>';
- $output .= '<dd>' . t('Users with the <em>Translate user edited configuration</em> permission can access the configuration translation overview, and manage translations for specific languages. The <a href=":translation-page">Configuration translation</a> page shows a list of all configuration text that can be translated, either as individual items or as lists. After you click on <em>Translate</em>, you are provided with a list of all languages. You can <em>add</em> or <em>edit</em> a translation for a specific language. Users with specific configuration permissions can also <em>edit</em> the text for the site\'s default language. For some configuration text items (for example for the site information), the specific translation pages can also be accessed directly from their configuration pages.', array(':translation-page' => \Drupal::url('config_translation.mapper_list'))) . '</dd>';
+ $output .= '<dd>' . t('Users with the <em>Translate user edited configuration</em> permission can access the configuration translation overview, and manage translations for specific languages. The <a href=":translation-page">Configuration translation</a> page shows a list of all configuration text that can be translated, either as individual items or as lists. After you click on <em>Translate</em>, you are provided with a list of all languages. You can <em>add</em> or <em>edit</em> a translation for a specific language. Users with specific configuration permissions can also <em>edit</em> the text for the site\'s default language. For some configuration text items (for example for the site information), the specific translation pages can also be accessed directly from their configuration pages.', [':translation-page' => \Drupal::url('config_translation.mapper_list')]) . '</dd>';
$output .= '<dt>' . t('Translating date formats') . '</dt>';
- $output .= '<dd>' . t('You can choose to translate date formats on the <a href=":translation-page">Configuration translation</a> page. This allows you not only to translate the label text, but also to set a language-specific <em>PHP date format</em>.', array(':translation-page' => \Drupal::url('config_translation.mapper_list'))) . '</dd>';
+ $output .= '<dd>' . t('You can choose to translate date formats on the <a href=":translation-page">Configuration translation</a> page. This allows you not only to translate the label text, but also to set a language-specific <em>PHP date format</em>.', [':translation-page' => \Drupal::url('config_translation.mapper_list')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -40,12 +40,12 @@ function config_translation_help($route_name, RouteMatchInterface $route_match)
* Implements hook_theme().
*/
function config_translation_theme() {
- return array(
- 'config_translation_manage_form_element' => array(
+ return [
+ 'config_translation_manage_form_element' => [
'render element' => 'element',
'template' => 'config_translation_manage_form_element',
- ),
- );
+ ],
+ ];
}
/**
@@ -110,13 +110,13 @@ function config_translation_config_translation_info(&$info) {
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
// Make sure entity type has field UI enabled and has a base route.
if ($entity_type->get('field_ui_base_route')) {
- $info[$entity_type_id . '_fields'] = array(
+ $info[$entity_type_id . '_fields'] = [
'base_route_name' => "entity.field_config.{$entity_type_id}_field_edit_form",
'entity_type' => 'field_config',
'class' => '\Drupal\config_translation\ConfigFieldMapper',
'base_entity_type' => $entity_type_id,
'weight' => 10,
- );
+ ];
}
}
}
@@ -138,14 +138,14 @@ function config_translation_config_translation_info(&$info) {
// Use the entity type as the plugin ID.
$base_route_name = "entity.$entity_type_id.edit_form";
- $info[$entity_type_id] = array(
+ $info[$entity_type_id] = [
'class' => '\Drupal\config_translation\ConfigEntityMapper',
'base_route_name' => $base_route_name,
'title' => $entity_type->getLowercaseLabel(),
- 'names' => array(),
+ 'names' => [],
'entity_type' => $entity_type_id,
'weight' => 10,
- );
+ ];
}
}
@@ -153,7 +153,7 @@ function config_translation_config_translation_info(&$info) {
* Implements hook_entity_operation().
*/
function config_translation_entity_operation(EntityInterface $entity) {
- $operations = array();
+ $operations = [];
$entity_type = $entity->getEntityType();
if ($entity_type->entityClassImplements(ConfigEntityInterface::class) &&
$entity->hasLinkTemplate('config-translation-overview') &&
@@ -164,11 +164,11 @@ function config_translation_entity_operation(EntityInterface $entity) {
$link_template = "config-translation-overview.{$entity->getTargetEntityTypeId()}";
}
- $operations['translate'] = array(
+ $operations['translate'] = [
'title' => t('Translate'),
'weight' => 50,
'url' => $entity->urlInfo($link_template),
- );
+ ];
}
return $operations;
@@ -178,7 +178,7 @@ function config_translation_entity_operation(EntityInterface $entity) {
* Implements hook_config_schema_info_alter().
*/
function config_translation_config_schema_info_alter(&$definitions) {
- $map = array(
+ $map = [
'label' => '\Drupal\config_translation\FormElement\Textfield',
'text' => '\Drupal\config_translation\FormElement\Textarea',
'date_format' => '\Drupal\config_translation\FormElement\DateFormat',
@@ -186,7 +186,7 @@ function config_translation_config_schema_info_alter(&$definitions) {
'mapping' => '\Drupal\config_translation\FormElement\ListElement',
'sequence' => '\Drupal\config_translation\FormElement\ListElement',
'plural_label' => '\Drupal\config_translation\FormElement\PluralVariants',
- );
+ ];
// Enhance the text and date type definitions with classes to generate proper
// form elements in ConfigTranslationFormBase. Other translatable types will
diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php
index d172e1b7050..2ae30959332 100644
--- a/core/modules/config_translation/src/ConfigEntityMapper.php
+++ b/core/modules/config_translation/src/ConfigEntityMapper.php
@@ -165,7 +165,7 @@ class ConfigEntityMapper extends ConfigNamesMapper {
* {@inheritdoc}
*/
public function getBaseRouteParameters() {
- return array($this->entityType => $this->entity->id());
+ return [$this->entityType => $this->entity->id()];
}
/**
@@ -220,14 +220,14 @@ class ConfigEntityMapper extends ConfigNamesMapper {
* {@inheritdoc}
*/
public function getOperations() {
- return array(
- 'list' => array(
+ return [
+ 'list' => [
'title' => $this->t('List'),
'url' => Url::fromRoute('config_translation.entity_list', [
'mapper_id' => $this->getPluginId(),
]),
- ),
- );
+ ],
+ ];
}
/**
@@ -259,12 +259,12 @@ class ConfigEntityMapper extends ConfigNamesMapper {
*/
protected function processRoute(Route $route) {
// Add entity upcasting information.
- $parameters = $route->getOption('parameters') ?: array();
- $parameters += array(
- $this->entityType => array(
+ $parameters = $route->getOption('parameters') ?: [];
+ $parameters += [
+ $this->entityType => [
'type' => 'entity:' . $this->entityType,
- )
- );
+ ]
+ ];
$route->setOption('parameters', $parameters);
}
diff --git a/core/modules/config_translation/src/ConfigFieldMapper.php b/core/modules/config_translation/src/ConfigFieldMapper.php
index a9f6d76621b..c0e085f1153 100644
--- a/core/modules/config_translation/src/ConfigFieldMapper.php
+++ b/core/modules/config_translation/src/ConfigFieldMapper.php
@@ -44,7 +44,7 @@ class ConfigFieldMapper extends ConfigEntityMapper {
*/
public function getTypeLabel() {
$base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
- return $this->t('@label fields', array('@label' => $base_entity_info->getLabel()));
+ return $this->t('@label fields', ['@label' => $base_entity_info->getLabel()]);
}
/**
diff --git a/core/modules/config_translation/src/ConfigMapperManager.php b/core/modules/config_translation/src/ConfigMapperManager.php
index cd0b72f967d..a43f08083a5 100644
--- a/core/modules/config_translation/src/ConfigMapperManager.php
+++ b/core/modules/config_translation/src/ConfigMapperManager.php
@@ -39,12 +39,12 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
/**
* {@inheritdoc}
*/
- protected $defaults = array(
+ protected $defaults = [
'title' => '',
- 'names' => array(),
+ 'names' => [],
'weight' => 20,
'class' => '\Drupal\config_translation\ConfigNamesMapper',
- );
+ ];
/**
* Constructs a ConfigMapperManager.
@@ -72,7 +72,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
$this->alterInfo('config_translation_info');
// Config translation only uses an info hook discovery, cache by language.
$cache_key = 'config_translation_info_plugins' . ':' . $language_manager->getCurrentLanguage()->getId();
- $this->setCacheBackend($cache_backend, $cache_key, array('config_translation_info_plugins'));
+ $this->setCacheBackend($cache_backend, $cache_key, ['config_translation_info_plugins']);
}
/**
@@ -90,7 +90,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
// request; when routes are being rebuilt at the end of the request,
// this service only happens to get instantiated with the updated list
// of installed themes.
- $directories = array();
+ $directories = [];
foreach ($this->moduleHandler->getModuleList() as $name => $module) {
$directories[$name] = $module->getPath();
}
@@ -111,7 +111,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
* {@inheritdoc}
*/
public function getMappers(RouteCollection $collection = NULL) {
- $mappers = array();
+ $mappers = [];
foreach ($this->getDefinitions() as $id => $definition) {
$mappers[$id] = $this->createInstance($id);
if ($collection) {
@@ -155,7 +155,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
// If this plugin was provided by a module that does not exist, remove the
// plugin definition.
foreach ($definitions as $plugin_id => $plugin_definition) {
- if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) {
+ if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], ['core', 'component']) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) {
unset($definitions[$plugin_id]);
}
}
diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php
index 0784090daf5..03716e9725c 100644
--- a/core/modules/config_translation/src/ConfigNamesMapper.php
+++ b/core/modules/config_translation/src/ConfigNamesMapper.php
@@ -180,7 +180,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
* {@inheritdoc}
*/
public function getBaseRouteParameters() {
- return array();
+ return [];
}
/**
@@ -231,11 +231,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
public function getOverviewRoute() {
$route = new Route(
$this->getBaseRoute()->getPath() . '/translate',
- array(
+ [
'_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage',
'plugin_id' => $this->getPluginId(),
- ),
- array('_config_translation_overview_access' => 'TRUE')
+ ],
+ ['_config_translation_overview_access' => 'TRUE']
);
$this->processRoute($route);
return $route;
@@ -272,11 +272,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
public function getAddRoute() {
$route = new Route(
$this->getBaseRoute()->getPath() . '/translate/{langcode}/add',
- array(
+ [
'_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm',
'plugin_id' => $this->getPluginId(),
- ),
- array('_config_translation_form_access' => 'TRUE')
+ ],
+ ['_config_translation_form_access' => 'TRUE']
);
$this->processRoute($route);
return $route;
@@ -302,11 +302,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
public function getEditRoute() {
$route = new Route(
$this->getBaseRoute()->getPath() . '/translate/{langcode}/edit',
- array(
+ [
'_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm',
'plugin_id' => $this->getPluginId(),
- ),
- array('_config_translation_form_access' => 'TRUE')
+ ],
+ ['_config_translation_form_access' => 'TRUE']
);
$this->processRoute($route);
return $route;
@@ -332,11 +332,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
public function getDeleteRoute() {
$route = new Route(
$this->getBaseRoute()->getPath() . '/translate/{langcode}/delete',
- array(
+ [
'_form' => '\Drupal\config_translation\Form\ConfigTranslationDeleteForm',
'plugin_id' => $this->getPluginId(),
- ),
- array('_config_translation_form_access' => 'TRUE')
+ ],
+ ['_config_translation_form_access' => 'TRUE']
);
$this->processRoute($route);
return $route;
@@ -413,7 +413,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
* {@inheritdoc}
*/
public function getConfigData() {
- $config_data = array();
+ $config_data = [];
foreach ($this->getConfigNames() as $name) {
$config_data[$name] = $this->configFactory->getEditable($name)->get();
}
@@ -467,12 +467,12 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
* {@inheritdoc}
*/
public function getOperations() {
- return array(
- 'translate' => array(
+ return [
+ 'translate' => [
'title' => $this->t('Translate'),
'url' => Url::fromRoute($this->getOverviewRouteName(), $this->getOverviewRouteParameters()),
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php
index d0de3419ba8..c226dfbd60a 100644
--- a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php
+++ b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php
@@ -18,7 +18,7 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild
*
* @var array
*/
- protected $themes = array();
+ protected $themes = [];
/**
* {@inheritdoc}
@@ -58,20 +58,20 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild
$theme = $entity->getTheme();
$plugin_definition = $entity->getPlugin()->getPluginDefinition();
- $row['label'] = array(
+ $row['label'] = [
'data' => $entity->label(),
'class' => 'table-filter-text-source',
- );
+ ];
- $row['theme'] = array(
+ $row['theme'] = [
'data' => $this->themes[$theme]->info['name'],
'class' => 'table-filter-text-source',
- );
+ ];
- $row['category'] = array(
+ $row['category'] = [
'data' => $plugin_definition['category'],
'class' => 'table-filter-text-source',
- );
+ ];
$row['operations']['data'] = $this->buildOperations($entity);
@@ -93,7 +93,7 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild
* {@inheritdoc}
*/
public function sortRows($a, $b) {
- return $this->sortRowsMultiple($a, $b, array('theme', 'category', 'label'));
+ return $this->sortRowsMultiple($a, $b, ['theme', 'category', 'label']);
}
}
diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php
index 927a1e2bf58..8d9bfe7bdef 100644
--- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php
+++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php
@@ -134,12 +134,12 @@ class ConfigTranslationController extends ControllerBase {
$mapper = $this->configMapperManager->createInstance($plugin_id);
$mapper->populateFromRouteMatch($route_match);
- $page = array();
- $page['#title'] = $this->t('Translations for %label', array('%label' => $mapper->getTitle()));
+ $page = [];
+ $page['#title'] = $this->t('Translations for %label', ['%label' => $mapper->getTitle()]);
$languages = $this->languageManager->getLanguages();
if (count($languages) == 1) {
- drupal_set_message($this->t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', array(':url' => $this->url('entity.configurable_language.collection'))), 'warning');
+ drupal_set_message($this->t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', [':url' => $this->url('entity.configurable_language.collection')]), 'warning');
}
try {
@@ -172,7 +172,7 @@ class ConfigTranslationController extends ControllerBase {
// If the language is not configured on the site, create a dummy language
// object for this listing only to ensure the user gets useful info.
$language_name = $this->languageManager->getLanguageName($original_langcode);
- $languages[$original_langcode] = new Language(array('id' => $original_langcode, 'name' => $language_name));
+ $languages[$original_langcode] = new Language(['id' => $original_langcode, 'name' => $language_name]);
}
// We create a fake request object to pass into
@@ -181,10 +181,10 @@ class ConfigTranslationController extends ControllerBase {
// possible nor performant.
$fake_request = $request->duplicate();
- $page['languages'] = array(
+ $page['languages'] = [
'#type' => 'table',
- '#header' => array($this->t('Language'), $this->t('Operations')),
- );
+ '#header' => [$this->t('Language'), $this->t('Operations')],
+ ];
foreach ($languages as $language) {
$langcode = $language->getId();
@@ -198,57 +198,57 @@ class ConfigTranslationController extends ControllerBase {
// Prepare the language name and the operations depending on whether this
// is the original language or not.
if ($langcode == $original_langcode) {
- $language_name = '<strong>' . $this->t('@language (original)', array('@language' => $language->getName())) . '</strong>';
+ $language_name = '<strong>' . $this->t('@language (original)', ['@language' => $language->getName()]) . '</strong>';
// Check access for the path/route for editing, so we can decide to
// include a link to edit or not.
$edit_access = $this->accessManager->checkNamedRoute($mapper->getBaseRouteName(), $route_match->getRawParameters()->all(), $this->account);
// Build list of operations.
- $operations = array();
+ $operations = [];
if ($edit_access) {
- $operations['edit'] = array(
+ $operations['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute($mapper->getBaseRouteName(), $mapper->getBaseRouteParameters(), ['query' => ['destination' => $mapper->getOverviewPath()]]),
- );
+ ];
}
}
else {
$language_name = $language->getName();
- $operations = array();
+ $operations = [];
// If no translation exists for this language, link to add one.
if (!$mapper->hasTranslation($language)) {
- $operations['add'] = array(
+ $operations['add'] = [
'title' => $this->t('Add'),
'url' => Url::fromRoute($mapper->getAddRouteName(), $mapper->getAddRouteParameters()),
- );
+ ];
}
else {
// Otherwise, link to edit the existing translation.
- $operations['edit'] = array(
+ $operations['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute($mapper->getEditRouteName(), $mapper->getEditRouteParameters()),
- );
+ ];
- $operations['delete'] = array(
+ $operations['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute($mapper->getDeleteRouteName(), $mapper->getDeleteRouteParameters()),
- );
+ ];
}
}
- $page['languages'][$langcode]['language'] = array(
+ $page['languages'][$langcode]['language'] = [
'#markup' => $language_name,
- );
+ ];
- $page['languages'][$langcode]['operations'] = array(
+ $page['languages'][$langcode]['operations'] = [
'#type' => 'operations',
'#links' => $operations,
// Even if the mapper contains multiple language codes, the source
// configuration can still be edited.
'#access' => ($langcode == $original_langcode) || $operations_access,
- );
+ ];
}
return $page;
}
diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php
index e86237e3c96..87cb2605c03 100644
--- a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php
+++ b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php
@@ -16,10 +16,10 @@ class ConfigTranslationEntityListBuilder extends ConfigEntityListBuilder impleme
* @return array
*/
protected function getFilterLabels() {
- return array(
+ return [
'placeholder' => $this->t('Enter label'),
'description' => $this->t('Enter a part of the label or description to filter by.'),
- );
+ ];
}
/**
@@ -29,28 +29,28 @@ class ConfigTranslationEntityListBuilder extends ConfigEntityListBuilder impleme
$build = parent::render();
$filter = $this->getFilterLabels();
- usort($build['table']['#rows'], array($this, 'sortRows'));
+ usort($build['table']['#rows'], [$this, 'sortRows']);
- $build['filters'] = array(
+ $build['filters'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('table-filter', 'js-show'),
- ),
+ '#attributes' => [
+ 'class' => ['table-filter', 'js-show'],
+ ],
'#weight' => -10,
- );
+ ];
- $build['filters']['text'] = array(
+ $build['filters']['text'] = [
'#type' => 'search',
'#title' => $this->t('Search'),
'#size' => 30,
'#placeholder' => $filter['placeholder'],
- '#attributes' => array(
- 'class' => array('table-filter-text'),
+ '#attributes' => [
+ 'class' => ['table-filter-text'],
'data-table' => '.config-translation-entity-list',
'autocomplete' => 'off',
'title' => $filter['description'],
- ),
- );
+ ],
+ ];
$build['table']['#attributes']['class'][] = 'config-translation-entity-list';
$build['table']['#weight'] = 0;
@@ -95,7 +95,7 @@ class ConfigTranslationEntityListBuilder extends ConfigEntityListBuilder impleme
* {@inheritdoc}
*/
public function sortRows($a, $b) {
- return $this->sortRowsMultiple($a, $b, array('label'));
+ return $this->sortRowsMultiple($a, $b, ['label']);
}
/**
diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php
index 6388c811dfe..566afdbb230 100644
--- a/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php
+++ b/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php
@@ -26,14 +26,14 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
*
* @var array
*/
- protected $baseEntityInfo = array();
+ protected $baseEntityInfo = [];
/**
* The bundle info for the base entity type.
*
* @var array
*/
- protected $baseEntityBundles = array();
+ protected $baseEntityBundles = [];
/**
* The entity manager.
@@ -99,8 +99,8 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
$bundle = $this->baseEntityInfo->getBundleLabel() ?: $this->t('Bundle');
$bundle = Unicode::strtolower($bundle);
- $info['placeholder'] = $this->t('Enter field or @bundle', array('@bundle' => $bundle));
- $info['description'] = $this->t('Enter a part of the field or @bundle to filter by.', array('@bundle' => $bundle));
+ $info['placeholder'] = $this->t('Enter field or @bundle', ['@bundle' => $bundle]);
+ $info['description'] = $this->t('Enter a part of the field or @bundle to filter by.', ['@bundle' => $bundle]);
return $info;
}
@@ -109,17 +109,17 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
- $row['label'] = array(
+ $row['label'] = [
'data' => $entity->label(),
'class' => 'table-filter-text-source',
- );
+ ];
if ($this->displayBundle()) {
$bundle = $entity->get('bundle');
- $row['bundle'] = array(
+ $row['bundle'] = [
'data' => $this->baseEntityBundles[$bundle]['label'],
'class' => 'table-filter-text-source',
- );
+ ];
}
return $row + parent::buildRow($entity);
@@ -165,7 +165,7 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
* {@inheritdoc}
*/
public function sortRows($a, $b) {
- return $this->sortRowsMultiple($a, $b, array('bundle', 'label'));
+ return $this->sortRowsMultiple($a, $b, ['bundle', 'label']);
}
}
diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php b/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php
index f47d313c28f..4e510aaf38e 100644
--- a/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php
+++ b/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php
@@ -46,13 +46,13 @@ class ConfigTranslationMapperList extends ControllerBase {
* Renderable array with config translation mappers.
*/
public function render() {
- $build = array(
+ $build = [
'#type' => 'table',
'#header' => $this->buildHeader(),
- '#rows' => array(),
- );
+ '#rows' => [],
+ ];
- $mappers = array();
+ $mappers = [];
foreach ($this->mappers as $mapper) {
if ($row = $this->buildRow($mapper)) {
@@ -120,10 +120,10 @@ class ConfigTranslationMapperList extends ControllerBase {
// Retrieve and sort operations.
$operations = $mapper->getOperations();
uasort($operations, 'Drupal\Component\Utility\SortArray::sortByWeightElement');
- $build = array(
+ $build = [
'#type' => 'operations',
'#links' => $operations,
- );
+ ];
return $build;
}
diff --git a/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php b/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php
index 3d0620218ad..9edcb8c60a7 100644
--- a/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php
+++ b/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php
@@ -22,10 +22,10 @@ class ConfigTranslationAddForm extends ConfigTranslationFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) {
$form = parent::buildForm($form, $form_state, $route_match, $plugin_id, $langcode);
- $form['#title'] = $this->t('Add @language translation for %label', array(
+ $form['#title'] = $this->t('Add @language translation for %label', [
'%label' => $this->mapper->getTitle(),
'@language' => $this->language->getName(),
- ));
+ ]);
return $form;
}
@@ -34,7 +34,7 @@ class ConfigTranslationAddForm extends ConfigTranslationFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
- drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->getName())));
+ drupal_set_message($this->t('Successfully saved @language translation.', ['@language' => $this->language->getName()]));
}
}
diff --git a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php
index 089ae271090..ca3ad28aa30 100644
--- a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php
+++ b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php
@@ -84,7 +84,7 @@ class ConfigTranslationDeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete the @language translation of %label?', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()));
+ return $this->t('Are you sure you want to delete the @language translation of %label?', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]);
}
/**
@@ -140,7 +140,7 @@ class ConfigTranslationDeleteForm extends ConfirmFormBase {
$cache_backend->deleteAll();
}
- drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName())));
+ drupal_set_message($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php b/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php
index 5af4244349f..86a8f1cac2f 100644
--- a/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php
+++ b/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php
@@ -22,10 +22,10 @@ class ConfigTranslationEditForm extends ConfigTranslationFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) {
$form = parent::buildForm($form, $form_state, $route_match, $plugin_id, $langcode);
- $form['#title'] = $this->t('Edit @language translation for %label', array(
+ $form['#title'] = $this->t('Edit @language translation for %label', [
'%label' => $this->mapper->getTitle(),
'@language' => $this->language->getName(),
- ));
+ ]);
return $form;
}
@@ -34,7 +34,7 @@ class ConfigTranslationEditForm extends ConfigTranslationFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
- drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->getName())));
+ drupal_set_message($this->t('Successfully updated @language translation.', ['@language' => $this->language->getName()]));
}
}
diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
index 12e02162836..82f01d714ab 100644
--- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
+++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
@@ -65,7 +65,7 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
*
* @var array
*/
- protected $baseConfigData = array();
+ protected $baseConfigData = [];
/**
* Constructs a ConfigTranslationFormBase.
@@ -164,26 +164,26 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
// Even though this is a nested form, we do not set #tree to TRUE because
// the form value structure is generated by using #parents for each element.
// @see \Drupal\config_translation\FormElement\FormElementBase::getElements()
- $form['config_names'] = array('#type' => 'container');
+ $form['config_names'] = ['#type' => 'container'];
foreach ($this->mapper->getConfigNames() as $name) {
- $form['config_names'][$name] = array('#type' => 'container');
+ $form['config_names'][$name] = ['#type' => 'container'];
$schema = $this->typedConfigManager->get($name);
$source_config = $this->baseConfigData[$name];
$translation_config = $this->configFactory()->get($name)->get();
if ($form_element = $this->createFormElement($schema)) {
- $parents = array('config_names', $name);
+ $parents = ['config_names', $name];
$form['config_names'][$name] += $form_element->getTranslationBuild($this->sourceLanguage, $this->language, $source_config, $translation_config, $parents);
}
}
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save translation'),
'#button_type' => 'primary',
- );
+ ];
// Set the configuration language back.
$this->languageManager->setConfigOverrideLanguage($original_language);
@@ -195,7 +195,7 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $form_values = $form_state->getValue(array('translation', 'config_names'));
+ $form_values = $form_state->getValue(['translation', 'config_names']);
foreach ($this->mapper->getConfigNames() as $name) {
$schema = $this->typedConfigManager->get($name);
diff --git a/core/modules/config_translation/src/FormElement/DateFormat.php b/core/modules/config_translation/src/FormElement/DateFormat.php
index 4a4b995861a..d0ae033a426 100644
--- a/core/modules/config_translation/src/FormElement/DateFormat.php
+++ b/core/modules/config_translation/src/FormElement/DateFormat.php
@@ -16,7 +16,7 @@ class DateFormat extends FormElementBase {
/** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
$date_formatter = \Drupal::service('date.formatter');
$description = $this->t('A user-defined date format. See the <a href="http://php.net/manual/function.date.php">PHP manual</a> for available options.');
- $format = $this->t('Displayed as %date_format', array('%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config)));
+ $format = $this->t('Displayed as %date_format', ['%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config)]);
return [
'#type' => 'textfield',
diff --git a/core/modules/config_translation/src/FormElement/FormElementBase.php b/core/modules/config_translation/src/FormElement/FormElementBase.php
index 2b5c8f47805..3c97daf1b4b 100644
--- a/core/modules/config_translation/src/FormElement/FormElementBase.php
+++ b/core/modules/config_translation/src/FormElement/FormElementBase.php
@@ -64,8 +64,8 @@ abstract class FormElementBase implements ElementInterface {
$build['source'] = $this->getSourceElement($source_language, $source_config);
$build['translation'] = $this->getTranslationElement($translation_language, $source_config, $translation_config);
- $build['source']['#parents'] = array_merge(array('source'), $parents);
- $build['translation']['#parents'] = array_merge(array('translation'), $parents);
+ $build['source']['#parents'] = array_merge(['source'], $parents);
+ $build['translation']['#parents'] = array_merge(['translation'], $parents);
return $build;
}
@@ -93,15 +93,15 @@ abstract class FormElementBase implements ElementInterface {
$value = $this->t('(Empty)');
}
- return array(
+ return [
'#type' => 'item',
- '#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array(
+ '#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', [
// Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()),
'@source_language' => $source_language->getName(),
- )),
+ ]),
'#markup' => $value,
- );
+ ];
}
/**
@@ -157,15 +157,15 @@ abstract class FormElementBase implements ElementInterface {
*/
protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
// Add basic properties that apply to all form elements.
- return array(
- '#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array(
+ return [
+ '#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', [
// Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()),
'@source_language' => $translation_language->getName(),
- )),
+ ]),
'#default_value' => $translation_config,
- '#attributes' => array('lang' => $translation_language->getId()),
- );
+ '#attributes' => ['lang' => $translation_language->getId()],
+ ];
}
/**
diff --git a/core/modules/config_translation/src/FormElement/ListElement.php b/core/modules/config_translation/src/FormElement/ListElement.php
index e956536e78b..1ea452362b8 100644
--- a/core/modules/config_translation/src/FormElement/ListElement.php
+++ b/core/modules/config_translation/src/FormElement/ListElement.php
@@ -46,14 +46,14 @@ class ListElement implements ElementInterface {
* {@inheritdoc}
*/
public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL) {
- $build = array();
+ $build = [];
foreach ($this->element as $key => $element) {
- $sub_build = array();
+ $sub_build = [];
$element_key = isset($base_key) ? "$base_key.$key" : $key;
$definition = $element->getDataDefinition();
if ($form_element = ConfigTranslationFormBase::createFormElement($element)) {
- $element_parents = array_merge($parents, array($key));
+ $element_parents = array_merge($parents, [$key]);
$sub_build += $form_element->getTranslationBuild($source_language, $translation_language, $source_config[$key], $translation_config[$key], $element_parents, $element_key);
if (empty($sub_build)) {
@@ -62,13 +62,13 @@ class ListElement implements ElementInterface {
// Build the sub-structure and include it with a wrapper in the form if
// there are any translatable elements there.
- $build[$key] = array();
+ $build[$key] = [];
if ($element instanceof TraversableTypedDataInterface) {
- $build[$key] = array(
+ $build[$key] = [
'#type' => 'details',
'#title' => $this->getGroupTitle($definition, $sub_build),
'#open' => empty($base_key),
- );
+ ];
}
$build[$key] += $sub_build;
}
diff --git a/core/modules/config_translation/src/FormElement/PluralVariants.php b/core/modules/config_translation/src/FormElement/PluralVariants.php
index 624ff77bc76..aabca8a5578 100644
--- a/core/modules/config_translation/src/FormElement/PluralVariants.php
+++ b/core/modules/config_translation/src/FormElement/PluralVariants.php
@@ -18,25 +18,25 @@ class PluralVariants extends FormElementBase {
protected function getSourceElement(LanguageInterface $source_language, $source_config) {
$plurals = $this->getNumberOfPlurals($source_language->getId());
$values = explode(LOCALE_PLURAL_DELIMITER, $source_config);
- $element = array(
+ $element = [
'#type' => 'fieldset',
- '#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', array(
+ '#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', [
// Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()),
'@source_language' => $source_language->getName(),
- )),
+ ]),
'#tree' => TRUE,
- );
+ ];
for ($i = 0; $i < $plurals; $i++) {
- $element[$i] = array(
+ $element[$i] = [
'#type' => 'item',
// @todo Should use better labels https://www.drupal.org/node/2499639
'#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'),
- '#markup' => SafeMarkup::format('<span lang="@langcode">@value</span>', array(
+ '#markup' => SafeMarkup::format('<span lang="@langcode">@value</span>', [
'@langcode' => $source_language->getId(),
'@value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'),
- )),
- );
+ ]),
+ ];
}
return $element;
}
@@ -47,23 +47,23 @@ class PluralVariants extends FormElementBase {
protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
$plurals = $this->getNumberOfPlurals($translation_language->getId());
$values = explode(LOCALE_PLURAL_DELIMITER, $translation_config);
- $element = array(
+ $element = [
'#type' => 'fieldset',
- '#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', array(
+ '#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', [
// Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()),
'@translation_language' => $translation_language->getName(),
- )),
+ ]),
'#tree' => TRUE,
- );
+ ];
for ($i = 0; $i < $plurals; $i++) {
- $element[$i] = array(
+ $element[$i] = [
'#type' => 'textfield',
// @todo Should use better labels https://www.drupal.org/node/2499639
'#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'),
'#default_value' => isset($values[$i]) ? $values[$i] : '',
- '#attributes' => array('lang' => $translation_language->getId()),
- );
+ '#attributes' => ['lang' => $translation_language->getId()],
+ ];
}
return $element;
}
diff --git a/core/modules/config_translation/src/FormElement/TextFormat.php b/core/modules/config_translation/src/FormElement/TextFormat.php
index e9d56f29b98..f9f6bc61bca 100644
--- a/core/modules/config_translation/src/FormElement/TextFormat.php
+++ b/core/modules/config_translation/src/FormElement/TextFormat.php
@@ -16,25 +16,25 @@ class TextFormat extends FormElementBase {
// Instead of the formatted output show a disabled textarea. This allows for
// easier side-by-side comparison, especially with formats with text
// editors.
- return $this->getTranslationElement($source_language, $source_config, $source_config) + array(
+ return $this->getTranslationElement($source_language, $source_config, $source_config) + [
'#value' => $source_config['value'],
'#disabled' => TRUE,
'#allow_focus' => TRUE,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
- return array(
+ return [
'#type' => 'text_format',
// Override the #default_value property from the parent class.
'#default_value' => $translation_config['value'],
'#format' => $translation_config['format'],
// @see \Drupal\config_translation\Element\FormElementBase::getTranslationElement()
- '#allowed_formats' => array($source_config['format']),
- ) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
+ '#allowed_formats' => [$source_config['format']],
+ ] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
}
}
diff --git a/core/modules/config_translation/src/FormElement/Textarea.php b/core/modules/config_translation/src/FormElement/Textarea.php
index 174a70c5c31..ff9e4cde403 100644
--- a/core/modules/config_translation/src/FormElement/Textarea.php
+++ b/core/modules/config_translation/src/FormElement/Textarea.php
@@ -18,10 +18,10 @@ class Textarea extends FormElementBase {
$rows_newlines = substr_count($translation_config, "\n" ) + 1;
$rows = max($rows_words, $rows_newlines);
- return array(
+ return [
'#type' => 'textarea',
'#rows' => $rows,
- ) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
+ ] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
}
}
diff --git a/core/modules/config_translation/src/FormElement/Textfield.php b/core/modules/config_translation/src/FormElement/Textfield.php
index fa0c869a0a6..cff1037183d 100644
--- a/core/modules/config_translation/src/FormElement/Textfield.php
+++ b/core/modules/config_translation/src/FormElement/Textfield.php
@@ -13,9 +13,9 @@ class Textfield extends FormElementBase {
* {@inheritdoc}
*/
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
- return array(
+ return [
'#type' => 'textfield',
- ) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
+ ] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
}
}
diff --git a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
index fb2bf24cc22..63145a5d3b3 100644
--- a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
+++ b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
@@ -28,7 +28,7 @@ class ConfigTranslationContextualLink extends ContextualLinkDefault {
// storing the title on the plugin definition for the link) because it
// contains translated parts that we need in the runtime language.
$type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
- return $this->t('Translate @type_name', array('@type_name' => $type_name));
+ return $this->t('Translate @type_name', ['@type_name' => $type_name]);
}
/**
diff --git a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
index 63605c66ac9..5a88d91d0ab 100644
--- a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
+++ b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
@@ -28,7 +28,7 @@ class ConfigTranslationLocalTask extends LocalTaskDefault {
// storing the title on the plugin definition for the link) because
// it contains translated parts that we need in the runtime language.
$type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
- return $this->t('Translate @type_name', array('@type_name' => $type_name));
+ return $this->t('Translate @type_name', ['@type_name' => $type_name]);
}
/**
diff --git a/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nProfileField.php b/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nProfileField.php
index ecdffd65b64..2989f967b59 100644
--- a/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nProfileField.php
+++ b/core/modules/config_translation/src/Plugin/migrate/source/d6/I18nProfileField.php
@@ -31,12 +31,12 @@ class I18nProfileField extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'fid' => $this->t('Profile field ID.'),
'lid' => $this->t('Locales target language ID.'),
'language' => $this->t('Language for this field.'),
'translation' => $this->t('Translation of either the title or explanation.'),
- );
+ ];
}
/**
diff --git a/core/modules/config_translation/src/Routing/RouteSubscriber.php b/core/modules/config_translation/src/Routing/RouteSubscriber.php
index b20c13fdca4..10044aa7f80 100644
--- a/core/modules/config_translation/src/Routing/RouteSubscriber.php
+++ b/core/modules/config_translation/src/Routing/RouteSubscriber.php
@@ -48,7 +48,7 @@ class RouteSubscriber extends RouteSubscriberBase {
*/
public static function getSubscribedEvents() {
// Come after field_ui.
- $events[RoutingEvents::ALTER] = array('onAlterRoutes', -110);
+ $events[RoutingEvents::ALTER] = ['onAlterRoutes', -110];
return $events;
}
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php
index 648f04739aa..387d6864604 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php
@@ -17,7 +17,7 @@ class ConfigTranslationFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('config_translation', 'config_translation_test', 'editor');
+ public static $modules = ['config_translation', 'config_translation_test', 'editor'];
/**
* The plugin ID of the mapper to test.
@@ -40,7 +40,7 @@ class ConfigTranslationFormTest extends WebTestBase {
$this->pluginId = key($definitions);
$this->langcode = 'xx';
- ConfigurableLanguage::create(array('id' => $this->langcode, 'label' => 'XX'))->save();
+ ConfigurableLanguage::create(['id' => $this->langcode, 'label' => 'XX'])->save();
\Drupal::state()->set('config_translation_test_alter_form_alter', TRUE);
}
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php
index e7c58fd97d5..d593a69d385 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php
@@ -35,7 +35,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
*
* @var array
*/
- protected $langcodes = array('fr', 'ta');
+ protected $langcodes = ['fr', 'ta'];
/**
* String translation storage object.
@@ -46,7 +46,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $permissions = array(
+ $permissions = [
'translate configuration',
'administer languages',
'administer site configuration',
@@ -54,7 +54,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
'access site-wide contact form',
'access contextual links',
'administer views',
- );
+ ];
// Create and log in user.
$this->drupalLogin($this->drupalCreateUser($permissions));
@@ -83,17 +83,17 @@ class ConfigTranslationOverviewTest extends WebTestBase {
}
}
- $labels = array(
+ $labels = [
'&$nxd~i0',
'some "label" with quotes',
$this->randomString(),
- );
+ ];
foreach ($labels as $label) {
- $test_entity = entity_create('config_test', array(
+ $test_entity = entity_create('config_test', [
'id' => $this->randomMachineName(),
'label' => $label,
- ));
+ ]);
$test_entity->save();
$base_url = 'admin/structure/config_test/manage/' . $test_entity->id();
@@ -119,7 +119,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->drupalGet($base_url);
- $this->assertLink(t('Translate @title', array('@title' => $entity_type->getLowercaseLabel())));
+ $this->assertLink(t('Translate @title', ['@title' => $entity_type->getLowercaseLabel()]));
}
}
@@ -154,10 +154,10 @@ class ConfigTranslationOverviewTest extends WebTestBase {
$config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
// Set up an override.
- $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array(
+ $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [
'value' => $overridden_label,
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
// Test that the overridden label is loaded with the entity.
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
index 5018efa21f4..7ec350ba2c8 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
@@ -48,7 +48,7 @@ class ConfigTranslationUiTest extends WebTestBase {
*
* @var array
*/
- protected $langcodes = array('fr', 'ta');
+ protected $langcodes = ['fr', 'ta'];
/**
* Administrator user for tests.
@@ -157,13 +157,13 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertRaw($site_slogan);
// Update site name and slogan for French.
- $edit = array(
+ $edit = [
'translation[config_names][system.site][name]' => $fr_site_name,
'translation[config_names][system.site][slogan]' => $fr_site_slogan,
- );
+ ];
$this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
- $this->assertRaw(t('Successfully saved @language translation.', array('@language' => 'French')));
+ $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
// Check for edit, delete links (and no 'add' link) for French language.
$this->assertNoLinkByHref("$translation_base_url/fr/add");
@@ -189,18 +189,18 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertText($site_slogan);
// Translate 'Site name' label in French.
- $search = array(
+ $search = [
'string' => $site_name_label,
'langcode' => 'fr',
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $fr_site_name_label,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Ensure that the label is in French (and not in English).
@@ -234,10 +234,10 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->drupalGet($translation_base_url);
// Case 1: Update new value for site slogan and site name.
- $edit = array(
+ $edit = [
'translation[config_names][system.site][name]' => 'FR ' . $site_name,
'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan,
- );
+ ];
// First time, no overrides, so just Add link.
$this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
@@ -245,10 +245,10 @@ class ConfigTranslationUiTest extends WebTestBase {
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
// Expect both name and slogan in language specific file.
- $expected = array(
+ $expected = [
'name' => 'FR ' . $site_name,
'slogan' => 'FR ' . $site_slogan,
- );
+ ];
$this->assertEqual($expected, $override->get());
// Case 2: Update new value for site slogan and default value for site name.
@@ -257,12 +257,12 @@ class ConfigTranslationUiTest extends WebTestBase {
// translation form into the actual site name and slogan.
$this->assertNoText('FR ' . $site_name);
$this->assertNoText('FR ' . $site_slogan);
- $edit = array(
+ $edit = [
'translation[config_names][system.site][name]' => $site_name,
'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save translation'));
- $this->assertRaw(t('Successfully updated @language translation.', array('@language' => 'French')));
+ $this->assertRaw(t('Successfully updated @language translation.', ['@language' => 'French']));
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
// Expect only slogan in language specific file.
@@ -272,10 +272,10 @@ class ConfigTranslationUiTest extends WebTestBase {
// Case 3: Keep default value for site name and slogan.
$this->drupalGet("$translation_base_url/fr/edit");
$this->assertNoText('FR ' . $site_slogan);
- $edit = array(
+ $edit = [
'translation[config_names][system.site][name]' => $site_name,
'translation[config_names][system.site][slogan]' => $site_slogan,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save translation'));
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
@@ -310,11 +310,11 @@ class ConfigTranslationUiTest extends WebTestBase {
// Save default language configuration.
$label = 'Send your feedback';
- $edit = array(
+ $edit = [
'label' => $label,
'recipients' => 'sales@example.com,support@example.com',
'reply' => 'Thank you for your mail',
- );
+ ];
$this->drupalPostForm('admin/structure/contact/manage/feedback', $edit, t('Save'));
// Ensure translation link is present.
@@ -323,7 +323,7 @@ class ConfigTranslationUiTest extends WebTestBase {
// Make sure translate tab is present.
$this->drupalGet('admin/structure/contact/manage/feedback');
- $this->assertLink(t('Translate @type', array('@type' => 'contact form')));
+ $this->assertLink(t('Translate @type', ['@type' => 'contact form']));
// Visit the form to confirm the changes.
$this->drupalGet('contact/feedback');
@@ -331,7 +331,7 @@ class ConfigTranslationUiTest extends WebTestBase {
foreach ($this->langcodes as $langcode) {
$this->drupalGet($translation_base_url);
- $this->assertLink(t('Translate @type', array('@type' => 'contact form')));
+ $this->assertLink(t('Translate @type', ['@type' => 'contact form']));
// 'Add' link should be present for $langcode translation.
$translation_page_url = "$translation_base_url/$langcode/add";
@@ -342,20 +342,20 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertText($label);
// Update translatable fields.
- $edit = array(
+ $edit = [
'translation[config_names][contact.form.feedback][label]' => 'Website feedback - ' . $langcode,
'translation[config_names][contact.form.feedback][reply]' => 'Thank you for your mail - ' . $langcode,
- );
+ ];
// Save language specific version of form.
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
// Expect translated values in language specific file.
$override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.form.feedback');
- $expected = array(
+ $expected = [
'label' => 'Website feedback - ' . $langcode,
'reply' => 'Thank you for your mail - ' . $langcode,
- );
+ ];
$this->assertEqual($expected, $override->get());
// Check for edit, delete links (and no 'add' link) for $langcode.
@@ -368,10 +368,10 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertText('Website feedback - ' . $langcode);
// Submit feedback.
- $edit = array(
+ $edit = [
'subject[0][value]' => 'Test subject',
'message[0][value]' => 'Test message',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Send message'));
}
@@ -379,7 +379,7 @@ class ConfigTranslationUiTest extends WebTestBase {
// original text all appear in any translated page on the translation
// forms.
foreach ($this->langcodes as $langcode) {
- $langcode_prefixes = array_merge(array(''), $this->langcodes);
+ $langcode_prefixes = array_merge([''], $this->langcodes);
foreach ($langcode_prefixes as $langcode_prefix) {
$this->drupalGet(ltrim("$langcode_prefix/$translation_base_url/$langcode/edit", '/'));
$this->assertFieldByName('translation[config_names][contact.form.feedback][label]', 'Website feedback - ' . $langcode);
@@ -400,14 +400,14 @@ class ConfigTranslationUiTest extends WebTestBase {
// Test that delete links work and operations perform properly.
foreach ($this->langcodes as $langcode) {
- $replacements = array('%label' => t('@label @entity_type', array('@label' => $label, '@entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName());
+ $replacements = ['%label' => t('@label @entity_type', ['@label' => $label, '@entity_type' => Unicode::strtolower(t('Contact form'))]), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()];
$this->drupalGet("$translation_base_url/$langcode/delete");
$this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
// Assert link back to list page to cancel delete is present.
$this->assertLinkByHref($translation_base_url);
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->assertRaw(t('@language translation of %label was deleted', $replacements));
$this->assertLinkByHref("$translation_base_url/$langcode/add");
$this->assertNoLinkByHref("translation_base_url/$langcode/edit");
@@ -445,18 +445,18 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium');
// Save default language configuration for a new format.
- $edit = array(
+ $edit = [
'label' => 'Custom medium date',
'id' => 'custom_medium',
'date_format_pattern' => 'Y. m. d. H:i',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
// Test translating a default shipped format and our custom format.
- $formats = array(
+ $formats = [
'medium' => 'Default medium date',
'custom_medium' => 'Custom medium date',
- );
+ ];
foreach ($formats as $id => $label) {
$translation_base_url = 'admin/config/regional/date-time/formats/manage/' . $id . '/translate';
@@ -474,20 +474,20 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertRaw('core/modules/system/js/system.date.js');
// Update translatable fields.
- $edit = array(
+ $edit = [
'translation[config_names][core.date_format.' . $id . '][label]' => $id . ' - FR',
'translation[config_names][core.date_format.' . $id . '][pattern]' => 'D',
- );
+ ];
// Save language specific version of form.
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
// Get translation and check we've got the right value.
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'core.date_format.' . $id);
- $expected = array(
+ $expected = [
'label' => $id . ' - FR',
'pattern' => 'D',
- );
+ ];
$this->assertEqual($expected, $override->get());
// Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should
@@ -508,18 +508,18 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/people/accounts');
- $this->assertLink(t('Translate @type', array('@type' => 'account settings')));
+ $this->assertLink(t('Translate @type', ['@type' => 'account settings']));
$this->drupalGet('admin/config/people/accounts/translate');
- $this->assertLink(t('Translate @type', array('@type' => 'account settings')));
+ $this->assertLink(t('Translate @type', ['@type' => 'account settings']));
$this->assertLinkByHref('admin/config/people/accounts/translate/fr/add');
// Update account settings fields for French.
- $edit = array(
+ $edit = [
'translation[config_names][user.settings][anonymous]' => 'Anonyme',
'translation[config_names][user.mail][status_blocked][subject]' => 'Testing, your account is blocked.',
'translation[config_names][user.mail][status_blocked][body]' => 'Testing account blocked body.',
- );
+ ];
$this->drupalPostForm('admin/config/people/accounts/translate/fr/add', $edit, t('Save translation'));
@@ -588,7 +588,7 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
// Assert contextual link related to views.
- $ids = array('entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1');
+ $ids = ['entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1'];
$response = $this->renderContextualLinks($ids, 'node');
$this->assertResponse(200);
$json = Json::decode($response);
@@ -611,14 +611,14 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertRaw($human_readable_name);
// Update Views Fields for French.
- $edit = array(
+ $edit = [
'translation[config_names][views.view.frontpage][description]' => $description . " FR",
'translation[config_names][views.view.frontpage][label]' => $human_readable_name . " FR",
'translation[config_names][views.view.frontpage][display][default][display_title]' => $display_settings_master . " FR",
'translation[config_names][views.view.frontpage][display][default][display_options][title]' => $display_options_master . " FR",
- );
+ ];
$this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
- $this->assertRaw(t('Successfully saved @language translation.', array('@language' => 'French')));
+ $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
// Check for edit, delete links (and no 'add' link) for French language.
$this->assertNoLinkByHref("$translation_base_url/fr/add");
@@ -640,20 +640,20 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
// Languages to test, with various number of plural forms.
- $languages = array(
- 'vi' => array('plurals' => 1, 'expected' => array(TRUE, FALSE, FALSE, FALSE)),
- 'fr' => array('plurals' => 2, 'expected' => array(TRUE, TRUE, FALSE, FALSE)),
- 'sl' => array('plurals' => 4, 'expected' => array(TRUE, TRUE, TRUE, TRUE)),
- );
+ $languages = [
+ 'vi' => ['plurals' => 1, 'expected' => [TRUE, FALSE, FALSE, FALSE]],
+ 'fr' => ['plurals' => 2, 'expected' => [TRUE, TRUE, FALSE, FALSE]],
+ 'sl' => ['plurals' => 4, 'expected' => [TRUE, TRUE, TRUE, TRUE]],
+ ];
foreach ($languages as $langcode => $data) {
// Import a .po file to add a new language with a given number of plural forms
$name = \Drupal::service('file_system')->tempnam('temporary://', $langcode . '_') . '.po';
file_put_contents($name, $this->getPoFile($data['plurals']));
- $this->drupalPostForm('admin/config/regional/translate/import', array(
+ $this->drupalPostForm('admin/config/regional/translate/import', [
'langcode' => $langcode,
'files[file]' => $name,
- ), t('Import'));
+ ], t('Import'));
// Change the config langcode of the 'files' view.
$config = \Drupal::service('config.factory')->getEditable('views.view.files');
@@ -686,10 +686,10 @@ class ConfigTranslationUiTest extends WebTestBase {
// This will also automatically add the 'sl' language.
$name = \Drupal::service('file_system')->tempnam('temporary://', "sl_") . '.po';
file_put_contents($name, $this->getPoFile(4));
- $this->drupalPostForm('admin/config/regional/translate/import', array(
+ $this->drupalPostForm('admin/config/regional/translate/import', [
'langcode' => 'sl',
'files[file]' => $name,
- ), t('Import'));
+ ], t('Import'));
// Translate the files view, as this one uses numeric formatters.
$description = 'Singular form';
@@ -817,12 +817,12 @@ class ConfigTranslationUiTest extends WebTestBase {
$langcode = 'xx';
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => Language::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Make sure there is no translation stored in locale storage before edit.
@@ -830,9 +830,9 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertTrue(empty($translation));
// Add custom translation.
- $edit = array(
+ $edit = [
'translation[config_names][user.settings][anonymous]' => 'Anonyme',
- );
+ ];
$this->drupalPostForm('admin/config/people/accounts/translate/fr/add', $edit, t('Save translation'));
// Make sure translation stored in locale storage after saved language
@@ -841,9 +841,9 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertEqual('Anonyme', $translation->getString());
// revert custom translations to base translation.
- $edit = array(
+ $edit = [
'translation[config_names][user.settings][anonymous]' => 'Anonymous',
- );
+ ];
$this->drupalPostForm('admin/config/people/accounts/translate/fr/edit', $edit, t('Save translation'));
// Make sure there is no translation stored in locale storage after revert.
@@ -858,19 +858,19 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
// Delete French language
- $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete'));
- $this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'French', '%langcode' => 'fr')));
+ $this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
+ $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'French', '%langcode' => 'fr']));
// Change default language to Tamil.
- $edit = array(
+ $edit = [
'site_default_language' => 'ta',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
$this->assertRaw(t('Configuration saved.'));
// Delete English language
- $this->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete'));
- $this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'English', '%langcode' => 'en')));
+ $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
+ $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
// Visit account setting translation page, this should not
// throw any notices.
@@ -907,32 +907,32 @@ class ConfigTranslationUiTest extends WebTestBase {
/** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
$config_factory = $this->container->get('config.factory');
- $expected = array(
+ $expected = [
'kitten',
'llama',
'elephant'
- );
+ ];
$actual = $config_factory
->getEditable('config_translation_test.content')
->get('animals');
$this->assertEqual($expected, $actual);
- $edit = array(
+ $edit = [
'translation[config_names][config_translation_test.content][content][value]' => '<p><strong>Hello World</strong> - FR</p>',
'translation[config_names][config_translation_test.content][animals][0]' => 'kitten - FR',
'translation[config_names][config_translation_test.content][animals][1]' => 'llama - FR',
'translation[config_names][config_translation_test.content][animals][2]' => 'elephant - FR',
- );
+ ];
$this->drupalPostForm('admin/config/media/file-system/translate/fr/add', $edit, t('Save translation'));
$this->container->get('language.config_factory_override')
- ->setLanguage(new Language(array('id' => 'fr')));
+ ->setLanguage(new Language(['id' => 'fr']));
- $expected = array(
+ $expected = [
'kitten - FR',
'llama - FR',
'elephant - FR',
- );
+ ];
$actual = $config_factory
->get('config_translation_test.content')
->get('animals');
@@ -947,10 +947,10 @@ class ConfigTranslationUiTest extends WebTestBase {
/** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
$config_factory = $this->container->get('config.factory');
- $expected = array(
+ $expected = [
'value' => '<p><strong>Hello World</strong></p>',
'format' => 'plain_text',
- );
+ ];
$actual = $config_factory
->get('config_translation_test.content')
->getOriginal('content', FALSE);
@@ -970,20 +970,20 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->assertNoFieldByName('translation[config_names][config_translation_test.content][content][format]');
// Update translatable fields.
- $edit = array(
+ $edit = [
'translation[config_names][config_translation_test.content][content][value]' => '<p><strong>Hello World</strong> - FR</p>',
- );
+ ];
// Save language specific version of form.
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
// Get translation and check we've got the right value.
- $expected = array(
+ $expected = [
'value' => '<p><strong>Hello World</strong> - FR</p>',
'format' => 'plain_text',
- );
+ ];
$this->container->get('language.config_factory_override')
- ->setLanguage(new Language(array('id' => 'fr')));
+ ->setLanguage(new Language(['id' => 'fr']));
$actual = $config_factory
->get('config_translation_test.content')
->get('content');
@@ -1009,7 +1009,7 @@ class ConfigTranslationUiTest extends WebTestBase {
$this->drupalLogin($this->translatorUser);
$this->drupalGet($translation_page_url);
$this->assertDisabledTextarea('edit-translation-config-names-config-translation-testcontent-content-value');
- $this->drupalPostForm(NULL, array(), t('Save translation'));
+ $this->drupalPostForm(NULL, [], t('Save translation'));
// Check that submitting the form did not update the text format of the
// translation.
$actual = $config_factory
@@ -1019,14 +1019,14 @@ class ConfigTranslationUiTest extends WebTestBase {
// The administrator must explicitly change the text format.
$this->drupalLogin($this->adminUser);
- $edit = array(
+ $edit = [
'translation[config_names][config_translation_test.content][content][format]' => 'full_html',
- );
+ ];
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
- $expected = array(
+ $expected = [
'value' => '<p><strong>Hello World</strong> - FR</p>',
'format' => 'full_html',
- );
+ ];
$actual = $config_factory
->get('config_translation_test.content')
->get('content');
@@ -1047,20 +1047,20 @@ class ConfigTranslationUiTest extends WebTestBase {
* Returns translation if exists, FALSE otherwise.
*/
protected function getTranslation($config_name, $key, $langcode) {
- $settings_locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $config_name));
- $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', array('%config_name' => $config_name)));
+ $settings_locations = $this->localeStorage->getLocations(['type' => 'configuration', 'name' => $config_name]);
+ $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', ['%config_name' => $config_name]));
if (!empty($settings_locations)) {
$source = $this->container->get('config.factory')->get($config_name)->get($key);
- $source_string = $this->localeStorage->findString(array('source' => $source, 'type' => 'configuration'));
- $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', array('%config_name' => $config_name, '%key' => $key)));
+ $source_string = $this->localeStorage->findString(['source' => $source, 'type' => 'configuration']);
+ $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', ['%config_name' => $config_name, '%key' => $key]));
if (!empty($source_string)) {
- $conditions = array(
+ $conditions = [
'lid' => $source_string->lid,
'language' => $langcode,
- );
- $translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE));
+ ];
+ $translations = $this->localeStorage->getTranslations($conditions + ['translated' => TRUE]);
return reset($translations);
}
}
@@ -1074,10 +1074,10 @@ class ConfigTranslationUiTest extends WebTestBase {
* @param string $site_slogan
*/
protected function setSiteInformation($site_name, $site_slogan) {
- $edit = array(
+ $edit = [
'site_name' => $site_name,
'site_slogan' => $site_slogan,
- );
+ ];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this->assertRaw(t('The configuration options have been saved.'));
}
@@ -1094,11 +1094,11 @@ class ConfigTranslationUiTest extends WebTestBase {
* The response body.
*/
protected function renderContextualLinks($ids, $current_path) {
- $post = array();
+ $post = [];
for ($i = 0; $i < count($ids); $i++) {
$post['ids[' . $i . ']'] = $ids[$i];
}
- return $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => $current_path)));
+ return $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => $current_path]]);
}
/**
@@ -1111,30 +1111,30 @@ class ConfigTranslationUiTest extends WebTestBase {
* TRUE if the assertion passed; FALSE otherwise.
*/
protected function assertDisabledTextarea($id) {
- $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', array(
+ $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [
':id' => $id,
- ));
+ ]);
$textarea = reset($textarea);
- $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', array(
+ $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', [
'@id' => $id,
- )));
+ ]));
$expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
- $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', array(
+ $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [
'@id' => $id,
- )));
+ ]));
// Make sure the text format select is not shown.
$select_id = str_replace('value', 'format--2', $id);
- $select = $this->xpath('//select[@id=:id]', array(':id' => $select_id));
- return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', array(
+ $select = $this->xpath('//select[@id=:id]', [':id' => $select_id]);
+ return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [
'@id' => $id,
- )));
+ ]));
}
/**
* Helper function that returns a .po file with a given number of plural forms.
*/
public function getPoFile($plurals) {
- $po_file = array();
+ $po_file = [];
$po_file[1] = <<< EOF
msgid ""
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php
index ab51a43efaa..53713a92384 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php
@@ -24,7 +24,7 @@ class ConfigTranslationUiThemeTest extends WebTestBase {
*
* @var array
*/
- protected $langcodes = array('fr', 'ta');
+ protected $langcodes = ['fr', 'ta'];
/**
* Administrator user for tests.
diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module
index eb41793ab4f..8c00b90d05b 100644
--- a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module
+++ b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module
@@ -33,7 +33,7 @@ function config_translation_test_entity_type_alter(array &$entity_types) {
function config_translation_test_config_translation_info_alter(&$info) {
if (\Drupal::state()->get('config_translation_test_config_translation_info_alter')) {
// Limit account settings config files to only one of them.
- $info['entity.user.admin_form']['names'] = array('user.settings');
+ $info['entity.user.admin_form']['names'] = ['user.settings'];
// Add one more config file to the site information page.
$info['system.site_information_settings']['names'][] = 'system.rss';
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php
index 9ddbdf3a917..95af49eea92 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php
@@ -12,11 +12,11 @@ use Drupal\Tests\BrowserTestBase;
*/
class ConfigTranslationDateFormatUiTest extends BrowserTestBase {
- public static $modules = array(
+ public static $modules = [
'language',
'config_translation',
'system'
- );
+ ];
protected function setUp() {
parent::setUp();
@@ -27,10 +27,10 @@ class ConfigTranslationDateFormatUiTest extends BrowserTestBase {
ConfigurableLanguage::createFromLangcode($langcode)->save();
}
- $user = $this->drupalCreateUser(array(
+ $user = $this->drupalCreateUser([
'administer site configuration',
'translate configuration',
- ));
+ ]);
$this->drupalLogin($user);
}
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
index db4af565bc8..586d1975799 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
@@ -26,7 +26,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'block',
'config_translation',
'contact',
@@ -40,7 +40,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
'image',
'responsive_image',
'toolbar',
- );
+ ];
/**
* Admin user with all needed permissions.
@@ -52,7 +52,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $permissions = array(
+ $permissions = [
'access site-wide contact form',
'administer blocks',
'administer contact forms',
@@ -70,7 +70,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
'administer image styles',
'administer responsive images',
'translate configuration',
- );
+ ];
// Create and log in user.
$this->adminUser = $this->drupalCreateUser($permissions);
@@ -94,7 +94,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
// Add a test block, any block will do.
// Set the machine name so the translate link can be built later.
$id = Unicode::strtolower($this->randomMachineName(16));
- $this->drupalPlaceBlock('system_powered_by_block', array('id' => $id));
+ $this->drupalPlaceBlock('system_powered_by_block', ['id' => $id]);
// Get the Block listing.
$this->drupalGet('admin/structure/block');
@@ -118,11 +118,11 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
// Lowercase the machine name.
$menu_name = Unicode::strtolower($this->randomMachineName(16));
$label = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'id' => $menu_name,
'description' => '',
'label' => $label,
- );
+ ];
// Create the menu by posting the form.
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
@@ -135,9 +135,9 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
// Check if the Link is not added if you are missing 'translate
// configuration' permission.
- $permissions = array(
+ $permissions = [
'administer menu',
- );
+ ];
$this->drupalLogin($this->drupalCreateUser($permissions));
// Get the Menu listing.
@@ -186,11 +186,11 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
public function doCustomContentTypeListTest() {
// Create a test custom block type to decouple looking for translate
// operations link so this does not test more than necessary.
- $block_content_type = BlockContentType::create(array(
+ $block_content_type = BlockContentType::create([
'id' => Unicode::strtolower($this->randomMachineName(16)),
'label' => $this->randomMachineName(),
'revision' => FALSE
- ));
+ ]);
$block_content_type->save();
// Get the custom block type listing.
@@ -235,10 +235,10 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
public function doContentTypeListTest() {
// Create a test content type to decouple looking for translate operations
// link so this does not test more than necessary.
- $content_type = $this->drupalCreateContentType(array(
+ $content_type = $this->drupalCreateContentType([
'type' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
- ));
+ ]);
// Get the content type listing.
$this->drupalGet('admin/structure/types');
@@ -258,10 +258,10 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
public function doFormatsListTest() {
// Create a test format to decouple looking for translate operations
// link so this does not test more than necessary.
- $filter_format = FilterFormat::create(array(
+ $filter_format = FilterFormat::create([
'format' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
- ));
+ ]);
$filter_format->save();
// Get the format listing.
@@ -282,10 +282,10 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
public function doShortcutListTest() {
// Create a test shortcut to decouple looking for translate operations
// link so this does not test more than necessary.
- $shortcut = ShortcutSet::create(array(
+ $shortcut = ShortcutSet::create([
'id' => Unicode::strtolower($this->randomMachineName(16)),
'label' => $this->randomString(),
- ));
+ ]);
$shortcut->save();
// Get the shortcut listing.
@@ -307,7 +307,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
// Create a test role to decouple looking for translate operations
// link so this does not test more than necessary.
$role_id = Unicode::strtolower($this->randomMachineName(16));
- $this->drupalCreateRole(array(), $role_id);
+ $this->drupalCreateRole([], $role_id);
// Get the role listing.
$this->drupalGet('admin/people/roles');
@@ -361,13 +361,13 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
* Tests the responsive image mapping listing for the translate operation.
*/
public function doResponsiveImageListTest() {
- $edit = array();
+ $edit = [];
$edit['label'] = $this->randomMachineName();
$edit['id'] = strtolower($edit['label']);
$edit['fallback_image_style'] = 'thumbnail';
$this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
- $this->assertRaw(t('Responsive image style %label saved.', array('%label' => $edit['label'])));
+ $this->assertRaw(t('Responsive image style %label saved.', ['%label' => $edit['label']]));
// Get the responsive image style listing.
$this->drupalGet('admin/config/media/responsive-image-style');
@@ -386,17 +386,17 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
*/
public function doFieldListTest() {
// Create a base content type.
- $content_type = $this->drupalCreateContentType(array(
+ $content_type = $this->drupalCreateContentType([
'type' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
- ));
+ ]);
// Create a block content type.
- $block_content_type = BlockContentType::create(array(
+ $block_content_type = BlockContentType::create([
'id' => 'basic',
'label' => 'Basic',
'revision' => FALSE
- ));
+ ]);
$block_content_type->save();
$field = FieldConfig::create([
// The field storage is guaranteed to exist because it is supplied by the
@@ -404,21 +404,21 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
'bundle' => $block_content_type->id(),
'label' => 'Body',
- 'settings' => array('display_summary' => FALSE),
+ 'settings' => ['display_summary' => FALSE],
]);
$field->save();
// Look at a few fields on a few entity types.
- $pages = array(
- array(
+ $pages = [
+ [
'list' => 'admin/structure/types/manage/' . $content_type->id() . '/fields',
'field' => 'node.' . $content_type->id() . '.body',
- ),
- array(
+ ],
+ [
'list' => 'admin/structure/block/block-content/manage/basic/fields',
'field' => 'block_content.basic.body',
- ),
- );
+ ],
+ ];
foreach ($pages as $values) {
// Get fields listing.
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
index 9a9aee3d266..066dcd52bdc 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
@@ -16,22 +16,22 @@ class ConfigTranslationViewListUiTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('node', 'test_view');
+ public static $testViews = ['node', 'test_view'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('config_translation', 'views_ui');
+ public static $modules = ['config_translation', 'views_ui'];
protected function setUp() {
parent::setUp();
- $permissions = array(
+ $permissions = [
'administer views',
'translate configuration',
- );
+ ];
// Create and log in user.
$this->drupalLogin($this->drupalCreateUser($permissions));
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php
index dc56e8db91a..11e72c2dff3 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php
@@ -62,14 +62,14 @@ class ConfigEntityMapperTest extends UnitTestCase {
->with('entity.configurable_language.edit_form')
->will($this->returnValue(new Route('/admin/config/regional/language/edit/{configurable_language}')));
- $definition = array(
+ $definition = [
'class' => '\Drupal\config_translation\ConfigEntityMapper',
'base_route_name' => 'entity.configurable_language.edit_form',
'title' => '@label language',
- 'names' => array(),
+ 'names' => [],
'entity_type' => 'configurable_language',
'route_name' => 'config_translation.item.overview.entity.configurable_language.edit_form',
- );
+ ];
$typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
@@ -152,7 +152,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
$result = $this->configEntityMapper->getOverviewRouteParameters();
- $this->assertSame(array('configurable_language' => 'entity_id'), $result);
+ $this->assertSame(['configurable_language' => 'entity_id'], $result);
}
/**
@@ -205,12 +205,12 @@ class ConfigEntityMapperTest extends UnitTestCase {
public function testGetOperations() {
$result = $this->configEntityMapper->getOperations();
- $expected = array(
- 'list' => array(
+ $expected = [
+ 'list' => [
'title' => 'List',
'url' => Url::fromRoute('config_translation.entity_list', ['mapper_id' => 'configurable_language']),
- ),
- );
+ ],
+ ];
$this->assertEquals($expected, $result);
}
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
index 204d84e1ed5..8e6d0b903b6 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
@@ -42,13 +42,13 @@ class ConfigFieldMapperTest extends UnitTestCase {
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$this->entity = $this->getMock('Drupal\field\FieldConfigInterface');
- $definition = array(
+ $definition = [
'class' => '\Drupal\config_translation\ConfigFieldMapper',
'base_route_name' => 'entity.field_config.node_field_edit_form',
'title' => '@label field',
- 'names' => array(),
+ 'names' => [],
'entity_type' => 'field_config',
- );
+ ];
$locale_config_manager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager')
->disableOriginalConstructor()
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
index 10bbf7da887..9f064aca217 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
@@ -31,7 +31,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
protected $typedConfigManager;
protected function setUp() {
- $language = new Language(array('id' => 'en'));
+ $language = new Language(['id' => 'en']);
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->once())
->method('getCurrentLanguage')
@@ -83,50 +83,50 @@ class ConfigMapperManagerTest extends UnitTestCase {
* ConfigMapperManager::hasTranslatable() as the second key.
*/
public function providerTestHasTranslatable() {
- return array(
- array($this->getElement(array()), FALSE),
- array($this->getElement(array('aaa' => 'bbb')), FALSE),
- array($this->getElement(array('translatable' => FALSE)), FALSE),
- array($this->getElement(array('translatable' => TRUE)), TRUE),
- array($this->getNestedElement(array(
- $this->getElement(array()),
- )), FALSE),
- array($this->getNestedElement(array(
- $this->getElement(array('translatable' => TRUE)),
- )), TRUE),
- array($this->getNestedElement(array(
- $this->getElement(array('aaa' => 'bbb')),
- $this->getElement(array('ccc' => 'ddd')),
- $this->getElement(array('eee' => 'fff')),
- )), FALSE),
- array($this->getNestedElement(array(
- $this->getElement(array('aaa' => 'bbb')),
- $this->getElement(array('ccc' => 'ddd')),
- $this->getElement(array('translatable' => TRUE)),
- )), TRUE),
- array($this->getNestedElement(array(
- $this->getElement(array('aaa' => 'bbb')),
- $this->getNestedElement(array(
- $this->getElement(array('ccc' => 'ddd')),
- $this->getElement(array('eee' => 'fff')),
- )),
- $this->getNestedElement(array(
- $this->getElement(array('ggg' => 'hhh')),
- $this->getElement(array('iii' => 'jjj')),
- )),
- )), FALSE),
- array($this->getNestedElement(array(
- $this->getElement(array('aaa' => 'bbb')),
- $this->getNestedElement(array(
- $this->getElement(array('ccc' => 'ddd')),
- $this->getElement(array('eee' => 'fff')),
- )),
- $this->getNestedElement(array(
- $this->getElement(array('ggg' => 'hhh')),
- $this->getElement(array('translatable' => TRUE)),
- )),
- )), TRUE),
- );
+ return [
+ [$this->getElement([]), FALSE],
+ [$this->getElement(['aaa' => 'bbb']), FALSE],
+ [$this->getElement(['translatable' => FALSE]), FALSE],
+ [$this->getElement(['translatable' => TRUE]), TRUE],
+ [$this->getNestedElement([
+ $this->getElement([]),
+ ]), FALSE],
+ [$this->getNestedElement([
+ $this->getElement(['translatable' => TRUE]),
+ ]), TRUE],
+ [$this->getNestedElement([
+ $this->getElement(['aaa' => 'bbb']),
+ $this->getElement(['ccc' => 'ddd']),
+ $this->getElement(['eee' => 'fff']),
+ ]), FALSE],
+ [$this->getNestedElement([
+ $this->getElement(['aaa' => 'bbb']),
+ $this->getElement(['ccc' => 'ddd']),
+ $this->getElement(['translatable' => TRUE]),
+ ]), TRUE],
+ [$this->getNestedElement([
+ $this->getElement(['aaa' => 'bbb']),
+ $this->getNestedElement([
+ $this->getElement(['ccc' => 'ddd']),
+ $this->getElement(['eee' => 'fff']),
+ ]),
+ $this->getNestedElement([
+ $this->getElement(['ggg' => 'hhh']),
+ $this->getElement(['iii' => 'jjj']),
+ ]),
+ ]), FALSE],
+ [$this->getNestedElement([
+ $this->getElement(['aaa' => 'bbb']),
+ $this->getNestedElement([
+ $this->getElement(['ccc' => 'ddd']),
+ $this->getElement(['eee' => 'fff']),
+ ]),
+ $this->getNestedElement([
+ $this->getElement(['ggg' => 'hhh']),
+ $this->getElement(['translatable' => TRUE]),
+ ]),
+ ]), TRUE],
+ ];
}
/**
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php
index cbf42c809cc..e7a06794f8f 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php
@@ -91,13 +91,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
protected function setUp() {
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
- $this->pluginDefinition = array(
+ $this->pluginDefinition = [
'class' => '\Drupal\config_translation\ConfigNamesMapper',
'base_route_name' => 'system.site_information_settings',
'title' => 'System information',
- 'names' => array('system.site'),
+ 'names' => ['system.site'],
'weight' => 42,
- );
+ ];
$this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
@@ -156,7 +156,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetBaseRouteParameters() {
$result = $this->configNamesMapper->getBaseRouteParameters();
- $this->assertSame(array(), $result);
+ $this->assertSame([], $result);
}
/**
@@ -193,7 +193,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetOverviewRouteParameters() {
$result = $this->configNamesMapper->getOverviewRouteParameters();
- $this->assertSame(array(), $result);
+ $this->assertSame([], $result);
}
/**
@@ -201,13 +201,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetOverviewRoute() {
$expected = new Route('/admin/config/system/site-information/translate',
- array(
+ [
'_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage',
'plugin_id' => 'system.site_information_settings',
- ),
- array(
+ ],
+ [
'_config_translation_overview_access' => 'TRUE',
- )
+ ]
);
$result = $this->configNamesMapper->getOverviewRoute();
$this->assertSame(serialize($expected), serialize($result));
@@ -242,7 +242,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
$route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']);
$this->configNamesMapper->populateFromRouteMatch($route_match);
- $expected = array('langcode' => 'xx');
+ $expected = ['langcode' => 'xx'];
$result = $this->configNamesMapper->getAddRouteParameters();
$this->assertSame($expected, $result);
}
@@ -252,13 +252,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetAddRoute() {
$expected = new Route('/admin/config/system/site-information/translate/{langcode}/add',
- array(
+ [
'_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm',
'plugin_id' => 'system.site_information_settings',
- ),
- array(
+ ],
+ [
'_config_translation_form_access' => 'TRUE',
- )
+ ]
);
$result = $this->configNamesMapper->getAddRoute();
$this->assertSame(serialize($expected), serialize($result));
@@ -280,7 +280,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
$route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']);
$this->configNamesMapper->populateFromRouteMatch($route_match);
- $expected = array('langcode' => 'xx');
+ $expected = ['langcode' => 'xx'];
$result = $this->configNamesMapper->getEditRouteParameters();
$this->assertSame($expected, $result);
}
@@ -290,13 +290,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetEditRoute() {
$expected = new Route('/admin/config/system/site-information/translate/{langcode}/edit',
- array(
+ [
'_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm',
'plugin_id' => 'system.site_information_settings',
- ),
- array(
+ ],
+ [
'_config_translation_form_access' => 'TRUE',
- )
+ ]
);
$result = $this->configNamesMapper->getEditRoute();
$this->assertSame(serialize($expected), serialize($result));
@@ -318,7 +318,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
$route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']);
$this->configNamesMapper->populateFromRouteMatch($route_match);
- $expected = array('langcode' => 'xx'); $result = $this->configNamesMapper->getDeleteRouteParameters();
+ $expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getDeleteRouteParameters();
$this->assertSame($expected, $result);
}
@@ -327,13 +327,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetDeleteRoute() {
$expected = new Route('/admin/config/system/site-information/translate/{langcode}/delete',
- array(
+ [
'_form' => '\Drupal\config_translation\Form\ConfigTranslationDeleteForm',
'plugin_id' => 'system.site_information_settings',
- ),
- array(
+ ],
+ [
'_config_translation_form_access' => 'TRUE',
- )
+ ]
);
$result = $this->configNamesMapper->getDeleteRoute();
$this->assertSame(serialize($expected), serialize($result));
@@ -403,38 +403,38 @@ class ConfigNamesMapperTest extends UnitTestCase {
public function testGetLangcode() {
// Test that the getLangcode() falls back to 'en', if no explicit language
// code is provided.
- $config_factory = $this->getConfigFactoryStub(array(
- 'system.site' => array('key' => 'value'),
- ));
+ $config_factory = $this->getConfigFactoryStub([
+ 'system.site' => ['key' => 'value'],
+ ]);
$this->configNamesMapper->setConfigFactory($config_factory);
$result = $this->configNamesMapper->getLangcode();
$this->assertSame('en', $result);
// Test that getLangcode picks up the language code provided by the
// configuration.
- $config_factory = $this->getConfigFactoryStub(array(
- 'system.site' => array('langcode' => 'xx'),
- ));
+ $config_factory = $this->getConfigFactoryStub([
+ 'system.site' => ['langcode' => 'xx'],
+ ]);
$this->configNamesMapper->setConfigFactory($config_factory);
$result = $this->configNamesMapper->getLangcode();
$this->assertSame('xx', $result);
// Test that getLangcode() works for multiple configuration names.
$this->configNamesMapper->addConfigName('system.maintenance');
- $config_factory = $this->getConfigFactoryStub(array(
- 'system.site' => array('langcode' => 'xx'),
- 'system.maintenance' => array('langcode' => 'xx'),
- ));
+ $config_factory = $this->getConfigFactoryStub([
+ 'system.site' => ['langcode' => 'xx'],
+ 'system.maintenance' => ['langcode' => 'xx'],
+ ]);
$this->configNamesMapper->setConfigFactory($config_factory);
$result = $this->configNamesMapper->getLangcode();
$this->assertSame('xx', $result);
// Test that getLangcode() throws an exception when different language codes
// are given.
- $config_factory = $this->getConfigFactoryStub(array(
- 'system.site' => array('langcode' => 'xx'),
- 'system.maintenance' => array('langcode' => 'yy'),
- ));
+ $config_factory = $this->getConfigFactoryStub([
+ 'system.site' => ['langcode' => 'xx'],
+ 'system.maintenance' => ['langcode' => 'yy'],
+ ]);
$this->configNamesMapper->setConfigFactory($config_factory);
try {
$this->configNamesMapper->getLangcode();
@@ -448,22 +448,22 @@ class ConfigNamesMapperTest extends UnitTestCase {
* Tests ConfigNamesMapper::getConfigData().
*/
public function testGetConfigData() {
- $configs = array(
- 'system.site' => array(
+ $configs = [
+ 'system.site' => [
'name' => 'Drupal',
'slogan' => 'Come for the software, stay for the community!',
- ),
- 'system.maintenance' => array(
+ ],
+ 'system.maintenance' => [
'enabled' => FALSE,
'message' => '@site is currently under maintenance.',
- ),
- 'system.rss' => array(
- 'items' => array(
+ ],
+ 'system.rss' => [
+ 'items' => [
'limit' => 10,
'view_mode' => 'rss',
- ),
- ),
- );
+ ],
+ ],
+ ];
$this->configNamesMapper->setConfigNames(array_keys($configs));
$config_factory = $this->getConfigFactoryStub($configs);
@@ -489,9 +489,9 @@ class ConfigNamesMapperTest extends UnitTestCase {
$config_names = range(1, count($mock_return_values));
$this->configNamesMapper->setConfigNames($config_names);
- $map = array();
+ $map = [];
foreach ($config_names as $i => $config_name) {
- $map[] = array($config_name, $mock_return_values[$i]);
+ $map[] = [$config_name, $mock_return_values[$i]];
}
$this->typedConfigManager
->expects($this->any())
@@ -512,12 +512,12 @@ class ConfigNamesMapperTest extends UnitTestCase {
* ConfigNamesMapper::hasSchema() as the second value.
*/
public function providerTestHasSchema() {
- return array(
- array(array(TRUE), TRUE),
- array(array(FALSE), FALSE),
- array(array(TRUE, TRUE, TRUE), TRUE),
- array(array(TRUE, FALSE, TRUE), FALSE),
- );
+ return [
+ [[TRUE], TRUE],
+ [[FALSE], FALSE],
+ [[TRUE, TRUE, TRUE], TRUE],
+ [[TRUE, FALSE, TRUE], FALSE],
+ ];
}
/**
@@ -536,9 +536,9 @@ class ConfigNamesMapperTest extends UnitTestCase {
$config_names = range(1, count($mock_return_values));
$this->configNamesMapper->setConfigNames($config_names);
- $map = array();
+ $map = [];
foreach ($config_names as $i => $config_name) {
- $map[] = isset($mock_return_values[$i]) ? array($config_name, $mock_return_values[$i]) : array();
+ $map[] = isset($mock_return_values[$i]) ? [$config_name, $mock_return_values[$i]] : [];
}
$this->configMapperManager
->expects($this->any())
@@ -559,14 +559,14 @@ class ConfigNamesMapperTest extends UnitTestCase {
* ConfigNamesMapper::hasTranslatable() as the second value.
*/
public function providerTestHasTranslatable() {
- return array(
- array(array(), FALSE),
- array(array(TRUE), TRUE),
- array(array(FALSE), FALSE),
- array(array(TRUE, TRUE, TRUE), TRUE),
- array(array(FALSE, FALSE, FALSE), FALSE),
- array(array(TRUE, FALSE, TRUE), TRUE),
- );
+ return [
+ [[], FALSE],
+ [[TRUE], TRUE],
+ [[FALSE], FALSE],
+ [[TRUE, TRUE, TRUE], TRUE],
+ [[FALSE, FALSE, FALSE], FALSE],
+ [[TRUE, FALSE, TRUE], TRUE],
+ ];
}
/**
@@ -587,9 +587,9 @@ class ConfigNamesMapperTest extends UnitTestCase {
$config_names = range(1, count($mock_return_values));
$this->configNamesMapper->setConfigNames($config_names);
- $map = array();
+ $map = [];
foreach ($config_names as $i => $config_name) {
- $map[] = array($config_name, $language->getId(), $mock_return_values[$i]);
+ $map[] = [$config_name, $language->getId(), $mock_return_values[$i]];
}
$this->localeConfigManager
->expects($this->any())
@@ -610,13 +610,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
* ConfigNamesMapper::hasTranslation() as the second value.
*/
public function providerTestHasTranslation() {
- return array(
- array(array(TRUE), TRUE),
- array(array(FALSE), FALSE),
- array(array(TRUE, TRUE, TRUE), TRUE),
- array(array(FALSE, FALSE, TRUE), TRUE),
- array(array(FALSE, FALSE, FALSE), FALSE),
- );
+ return [
+ [[TRUE], TRUE],
+ [[FALSE], FALSE],
+ [[TRUE, TRUE, TRUE], TRUE],
+ [[FALSE, FALSE, TRUE], TRUE],
+ [[FALSE, FALSE, FALSE], FALSE],
+ ];
}
/**
@@ -631,12 +631,12 @@ class ConfigNamesMapperTest extends UnitTestCase {
* Tests ConfigNamesMapper::hasTranslation().
*/
public function testGetOperations() {
- $expected = array(
- 'translate' => array(
+ $expected = [
+ 'translate' => [
'title' => 'Translate',
'url' => Url::fromRoute('config_translation.item.overview.system.site_information_settings'),
- ),
- );
+ ],
+ ];
$result = $this->configNamesMapper->getOperations();
$this->assertEquals($expected, $result);
}
diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module
index 4306e3beb87..65e7592cce4 100644
--- a/core/modules/contact/contact.module
+++ b/core/modules/contact/contact.module
@@ -21,17 +21,17 @@ function contact_help($route_name, RouteMatchInterface $route_match) {
$contact_page = \Drupal::url('entity.contact_form.collection');
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the <a href=":contact">online documentation for the Contact module</a>.', array(':contact' => 'https://www.drupal.org/documentation/modules/contact')) . '</p>';
+ $output .= '<p>' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the <a href=":contact">online documentation for the Contact module</a>.', [':contact' => 'https://www.drupal.org/documentation/modules/contact']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Using the personal contact form') . '</dt>';
$output .= '<dd>' . t("Site visitors can email registered users on your site by using the personal contact form, without knowing or learning the email address of the recipient. When a site visitor is viewing a user profile, the viewer will see a <em>Contact</em> tab or link, which leads to the personal contact form. The personal contact link is not shown when you are viewing your own profile, and users must have both <em>View user information</em> (to see user profiles) and <em>Use users' personal contact forms</em> permission to see the link. The user whose profile is being viewed must also have their personal contact form enabled (this is a user account setting); viewers with <em>Administer users</em> permission can bypass this setting.") . '</dd>';
$output .= '<dt>' . t('Configuring contact forms') . '</dt>';
- $output .= '<dd>' . t('On the <a href=":contact_admin">Contact forms page</a>, you can configure the fields and display of the personal contact form, and you can set up one or more site-wide contact forms. Each site-wide contact form has a machine name, a label, and one or more defined recipients; when a site visitor submits the form, the field values are sent to those recipients.', array(':contact_admin' => $contact_page)) . '</dd>';
+ $output .= '<dd>' . t('On the <a href=":contact_admin">Contact forms page</a>, you can configure the fields and display of the personal contact form, and you can set up one or more site-wide contact forms. Each site-wide contact form has a machine name, a label, and one or more defined recipients; when a site visitor submits the form, the field values are sent to those recipients.', [':contact_admin' => $contact_page]) . '</dd>';
$output .= '<dt>' . t('Linking to contact forms') . '</dt>';
- $output .= '<dd>' . t('One site-wide contact form can be designated as the default contact form. If you choose to designate a default form, the <em>Contact</em> menu link in the <em>Footer</em> menu will link to it. You can modify this link from the <a href=":menu-settings">Menus page</a> if you have the Menu UI module installed. You can also create links to other contact forms; the URL for each form you have set up has format <em>contact/machine_name_of_form</em>.', array(':menu-settings' => $menu_page)) . '</p>';
+ $output .= '<dd>' . t('One site-wide contact form can be designated as the default contact form. If you choose to designate a default form, the <em>Contact</em> menu link in the <em>Footer</em> menu will link to it. You can modify this link from the <a href=":menu-settings">Menus page</a> if you have the Menu UI module installed. You can also create links to other contact forms; the URL for each form you have set up has format <em>contact/machine_name_of_form</em>.', [':menu-settings' => $menu_page]) . '</p>';
$output .= '<dt>' . t('Adding content to contact forms') . '</dt>';
- $output .= '<dd>' . t('From the <a href=":contact_admin">Contact forms page</a>, you can configure the fields to be shown on contact forms, including their labels and help text. If you would like other content (such as text or images) to appear on a contact form, use a block. You can create and edit blocks on the <a href=":blocks">Block layout page</a>, if the Block module is installed.', array(':blocks' => $block_page, ':contact_admin' => $contact_page)) . '</dd>';
+ $output .= '<dd>' . t('From the <a href=":contact_admin">Contact forms page</a>, you can configure the fields to be shown on contact forms, including their labels and help text. If you would like other content (such as text or images) to appear on a contact form, use a block. You can create and edit blocks on the <a href=":blocks">Block layout page</a>, if the Block module is installed.', [':blocks' => $block_page, ':contact_admin' => $contact_page]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -50,42 +50,42 @@ function contact_entity_type_alter(array &$entity_types) {
* Implements hook_entity_extra_field_info().
*/
function contact_entity_extra_field_info() {
- $fields = array();
+ $fields = [];
foreach (array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo('contact_message')) as $bundle) {
- $fields['contact_message'][$bundle]['form']['name'] = array(
+ $fields['contact_message'][$bundle]['form']['name'] = [
'label' => t('Sender name'),
'description' => t('Text'),
'weight' => -50,
- );
- $fields['contact_message'][$bundle]['form']['mail'] = array(
+ ];
+ $fields['contact_message'][$bundle]['form']['mail'] = [
'label' => t('Sender email'),
'description' => t('Email'),
'weight' => -40,
- );
+ ];
if ($bundle == 'personal') {
- $fields['contact_message'][$bundle]['form']['recipient'] = array(
+ $fields['contact_message'][$bundle]['form']['recipient'] = [
'label' => t('Recipient username'),
'description' => t('User'),
'weight' => -30,
- );
+ ];
}
- $fields['contact_message'][$bundle]['form']['preview'] = array(
+ $fields['contact_message'][$bundle]['form']['preview'] = [
'label' => t('Preview sender message'),
'description' => t('Preview'),
'weight' => 40,
- );
- $fields['contact_message'][$bundle]['form']['copy'] = array(
+ ];
+ $fields['contact_message'][$bundle]['form']['copy'] = [
'label' => t('Send copy to sender'),
'description' => t('Option'),
'weight' => 50,
- );
+ ];
}
- $fields['user']['user']['form']['contact'] = array(
+ $fields['user']['user']['form']['contact'] = [
'label' => t('Contact settings'),
'description' => t('Contact module form element.'),
'weight' => 5,
- );
+ ];
return $fields;
}
@@ -118,21 +118,21 @@ function contact_mail($key, &$message, $params) {
$sender = $params['sender'];
$language = \Drupal::languageManager()->getLanguage($message['langcode']);
- $variables = array(
+ $variables = [
'@site-name' => \Drupal::config('system.site')->get('name'),
'@subject' => $contact_message->getSubject(),
'@form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL,
'@form-url' => \Drupal::url('<current>', [], ['absolute' => TRUE, 'language' => $language]),
'@sender-name' => $sender->getDisplayName(),
- );
+ ];
if ($sender->isAuthenticated()) {
- $variables['@sender-url'] = $sender->url('canonical', array('absolute' => TRUE, 'language' => $language));
+ $variables['@sender-url'] = $sender->url('canonical', ['absolute' => TRUE, 'language' => $language]);
}
else {
$variables['@sender-url'] = $params['sender']->getEmail();
}
- $options = array('langcode' => $language->getId());
+ $options = ['langcode' => $language->getId()];
switch ($key) {
case 'page_mail':
@@ -150,10 +150,10 @@ function contact_mail($key, &$message, $params) {
case 'user_mail':
case 'user_copy':
- $variables += array(
+ $variables += [
'@recipient-name' => $params['recipient']->getDisplayName(),
- '@recipient-edit-url' => $params['recipient']->url('edit-form', array('absolute' => TRUE, 'language' => $language)),
- );
+ '@recipient-edit-url' => $params['recipient']->url('edit-form', ['absolute' => TRUE, 'language' => $language]),
+ ];
$message['subject'] .= t('[@site-name] @subject', $variables, $options);
$message['body'][] = t('Hello @recipient-name,', $variables, $options);
$message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options);
@@ -172,22 +172,22 @@ function contact_mail($key, &$message, $params) {
* @see \Drupal\user\ProfileForm::form()
*/
function contact_form_user_form_alter(&$form, FormStateInterface $form_state) {
- $form['contact'] = array(
+ $form['contact'] = [
'#type' => 'details',
'#title' => t('Contact settings'),
'#open' => TRUE,
'#weight' => 5,
- );
+ ];
$account = $form_state->getFormObject()->getEntity();
if (!\Drupal::currentUser()->isAnonymous() && $account->id()) {
$account_data = \Drupal::service('user.data')->get('contact', $account->id(), 'enabled');
}
- $form['contact']['contact'] = array(
+ $form['contact']['contact'] = [
'#type' => 'checkbox',
'#title' => t('Personal contact form'),
'#default_value' => isset($account_data) ? $account_data : \Drupal::config('contact.settings')->get('user_default_enabled'),
'#description' => t('Allow other users to contact you via a personal contact form which keeps your email address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.'),
- );
+ ];
$form['actions']['submit']['#submit'][] = 'contact_user_profile_form_submit';
}
@@ -209,18 +209,18 @@ function contact_user_profile_form_submit($form, FormStateInterface $form_state)
* @see \Drupal\user\AccountSettingsForm
*/
function contact_form_user_admin_settings_alter(&$form, FormStateInterface $form_state) {
- $form['contact'] = array(
+ $form['contact'] = [
'#type' => 'details',
'#title' => t('Contact settings'),
'#open' => TRUE,
'#weight' => 0,
- );
- $form['contact']['contact_default_status'] = array(
+ ];
+ $form['contact']['contact_default_status'] = [
'#type' => 'checkbox',
'#title' => t('Enable the personal contact form by default for new users'),
'#description' => t('Changing this setting will not affect existing users.'),
'#default_value' => \Drupal::configFactory()->getEditable('contact.settings')->get('user_default_enabled'),
- );
+ ];
// Add submit handler to save contact configuration.
$form['#submit'][] = 'contact_form_user_admin_settings_submit';
}
diff --git a/core/modules/contact/contact.views.inc b/core/modules/contact/contact.views.inc
index 15603624d34..a18c9e796f3 100644
--- a/core/modules/contact/contact.views.inc
+++ b/core/modules/contact/contact.views.inc
@@ -9,11 +9,11 @@
* Implements hook_views_data_alter().
*/
function contact_views_data_alter(&$data) {
- $data['users']['contact'] = array(
- 'field' => array(
+ $data['users']['contact'] = [
+ 'field' => [
'title' => t('Contact link'),
'help' => t('Provide a simple link to the user contact page.'),
'id' => 'contact_link',
- ),
- );
+ ],
+ ];
}
diff --git a/core/modules/contact/src/ContactFormEditForm.php b/core/modules/contact/src/ContactFormEditForm.php
index 01ca0251086..aa94540bb98 100644
--- a/core/modules/contact/src/ContactFormEditForm.php
+++ b/core/modules/contact/src/ContactFormEditForm.php
@@ -72,60 +72,60 @@ class ContactFormEditForm extends EntityForm implements ContainerInjectionInterf
$contact_form = $this->entity;
$default_form = $this->config('contact.settings')->get('default_form');
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $contact_form->label(),
'#description' => $this->t("Example: 'website feedback' or 'product information'."),
'#required' => TRUE,
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $contact_form->id(),
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\contact\Entity\ContactForm::load',
- ),
+ ],
'#disabled' => !$contact_form->isNew(),
- );
- $form['recipients'] = array(
+ ];
+ $form['recipients'] = [
'#type' => 'textarea',
'#title' => $this->t('Recipients'),
'#default_value' => implode(', ', $contact_form->getRecipients()),
'#description' => $this->t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com' . To specify multiple recipients, separate each email address with a comma."),
'#required' => TRUE,
- );
- $form['message'] = array(
+ ];
+ $form['message'] = [
'#type' => 'textarea',
'#title' => $this->t('Message'),
'#default_value' => $contact_form->getMessage(),
'#description' => $this->t('The message to display to the user after submission of this form. Leave blank for no message.'),
- );
- $form['redirect'] = array(
+ ];
+ $form['redirect'] = [
'#type' => 'path',
'#title' => $this->t('Redirect path'),
'#convert_path' => PathElement::CONVERT_NONE,
'#default_value' => $contact_form->getRedirectPath(),
'#description' => $this->t('Path to redirect the user to after submission of this form. For example, type "/about" to redirect to that page. Use a relative path with a slash in front.'),
- );
- $form['reply'] = array(
+ ];
+ $form['reply'] = [
'#type' => 'textarea',
'#title' => $this->t('Auto-reply'),
'#default_value' => $contact_form->getReply(),
'#description' => $this->t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'),
- );
- $form['weight'] = array(
+ ];
+ $form['weight'] = [
'#type' => 'weight',
'#title' => $this->t('Weight'),
'#default_value' => $contact_form->getWeight(),
'#description' => $this->t('When listing forms, those with lighter (smaller) weights get listed before forms with heavier (larger) weights. Forms with equal weights are sorted alphabetically.'),
- );
- $form['selected'] = array(
+ ];
+ $form['selected'] = [
'#type' => 'checkbox',
'#title' => $this->t('Make this the default form'),
'#default_value' => $default_form === $contact_form->id(),
- );
+ ];
return $form;
}
@@ -142,7 +142,7 @@ class ContactFormEditForm extends EntityForm implements ContainerInjectionInterf
foreach ($recipients as &$recipient) {
$recipient = trim($recipient);
if (!$this->emailValidator->isValid($recipient)) {
- $form_state->setErrorByName('recipients', $this->t('%recipient is an invalid email address.', array('%recipient' => $recipient)));
+ $form_state->setErrorByName('recipients', $this->t('%recipient is an invalid email address.', ['%recipient' => $recipient]));
}
}
$form_state->setValue('recipients', $recipients);
@@ -165,12 +165,12 @@ class ContactFormEditForm extends EntityForm implements ContainerInjectionInterf
$edit_link = $this->entity->link($this->t('Edit'));
$view_link = $contact_form->link($contact_form->label(), 'canonical');
if ($status == SAVED_UPDATED) {
- drupal_set_message($this->t('Contact form %label has been updated.', array('%label' => $view_link)));
- $this->logger('contact')->notice('Contact form %label has been updated.', array('%label' => $contact_form->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Contact form %label has been updated.', ['%label' => $view_link]));
+ $this->logger('contact')->notice('Contact form %label has been updated.', ['%label' => $contact_form->label(), 'link' => $edit_link]);
}
else {
- drupal_set_message($this->t('Contact form %label has been added.', array('%label' => $view_link)));
- $this->logger('contact')->notice('Contact form %label has been added.', array('%label' => $contact_form->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Contact form %label has been added.', ['%label' => $view_link]));
+ $this->logger('contact')->notice('Contact form %label has been added.', ['%label' => $contact_form->label(), 'link' => $edit_link]);
}
// Update the default form.
diff --git a/core/modules/contact/src/Controller/ContactController.php b/core/modules/contact/src/Controller/ContactController.php
index 4d46f83d043..b8b69d5f19a 100644
--- a/core/modules/contact/src/Controller/ContactController.php
+++ b/core/modules/contact/src/Controller/ContactController.php
@@ -64,9 +64,9 @@ class ContactController extends ControllerBase {
// If there are no forms, do not display the form.
if (empty($contact_form)) {
if ($this->currentUser()->hasPermission('administer contact forms')) {
- drupal_set_message($this->t('The contact form has not been configured. <a href=":add">Add one or more forms</a> .', array(
- ':add' => $this->url('contact.form_add'))), 'error');
- return array();
+ drupal_set_message($this->t('The contact form has not been configured. <a href=":add">Add one or more forms</a> .', [
+ ':add' => $this->url('contact.form_add')]), 'error');
+ return [];
}
else {
throw new NotFoundHttpException();
@@ -76,9 +76,9 @@ class ContactController extends ControllerBase {
$message = $this->entityManager()
->getStorage('contact_message')
- ->create(array(
+ ->create([
'contact_form' => $contact_form->id(),
- ));
+ ]);
$form = $this->entityFormBuilder()->getForm($message);
$form['#title'] = $contact_form->label();
@@ -106,13 +106,13 @@ class ContactController extends ControllerBase {
throw new NotFoundHttpException();
}
- $message = $this->entityManager()->getStorage('contact_message')->create(array(
+ $message = $this->entityManager()->getStorage('contact_message')->create([
'contact_form' => 'personal',
'recipient' => $user->id(),
- ));
+ ]);
$form = $this->entityFormBuilder()->getForm($message);
- $form['#title'] = $this->t('Contact @username', array('@username' => $user->getDisplayName()));
+ $form['#title'] = $this->t('Contact @username', ['@username' => $user->getDisplayName()]);
$form['#cache']['contexts'][] = 'user.permissions';
return $form;
}
diff --git a/core/modules/contact/src/Entity/ContactForm.php b/core/modules/contact/src/Entity/ContactForm.php
index 9c637470655..00e5416bc81 100644
--- a/core/modules/contact/src/Entity/ContactForm.php
+++ b/core/modules/contact/src/Entity/ContactForm.php
@@ -73,7 +73,7 @@ class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface
*
* @var array
*/
- protected $recipients = array();
+ protected $recipients = [];
/**
* The path to redirect to on form submission.
diff --git a/core/modules/contact/src/Entity/Message.php b/core/modules/contact/src/Entity/Message.php
index 20f360f6a4f..d75496ba72d 100644
--- a/core/modules/contact/src/Entity/Message.php
+++ b/core/modules/contact/src/Entity/Message.php
@@ -153,29 +153,29 @@ class Message extends ContentEntityBase implements MessageInterface {
->setLabel(t('Subject'))
->setRequired(TRUE)
->setSetting('max_length', 100)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -10,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
// The text of the contact message.
$fields['message'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Message'))
->setRequired(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textarea',
'weight' => 0,
- 'settings' => array(
+ 'settings' => [
'rows' => 12,
- ),
- ))
+ ],
+ ])
->setDisplayConfigurable('form', TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'type' => 'string',
'weight' => 0,
'label' => 'above',
- ))
+ ])
->setDisplayConfigurable('view', TRUE);
$fields['copy'] = BaseFieldDefinition::create('boolean')
diff --git a/core/modules/contact/src/MailHandler.php b/core/modules/contact/src/MailHandler.php
index bb3b95e8d37..b57864c0596 100644
--- a/core/modules/contact/src/MailHandler.php
+++ b/core/modules/contact/src/MailHandler.php
@@ -73,7 +73,7 @@ class MailHandler implements MailHandlerInterface {
public function sendMailMessages(MessageInterface $message, AccountInterface $sender) {
// Clone the sender, as we make changes to mail and name properties.
$sender_cloned = clone $this->userStorage->load($sender->id());
- $params = array();
+ $params = [];
$current_langcode = $this->languageManager->getCurrentLanguage()->getId();
$recipient_langcode = $this->languageManager->getDefaultLanguage()->getId();
$contact_form = $message->getContactForm();
@@ -86,7 +86,7 @@ class MailHandler implements MailHandlerInterface {
// For the email message, clarify that the sender name is not verified; it
// could potentially clash with a username on this site.
- $sender_cloned->name = $this->t('@name (not verified)', array('@name' => $message->getSenderName()));
+ $sender_cloned->name = $this->t('@name (not verified)', ['@name' => $message->getSenderName()]);
}
// Build email parameters.
@@ -133,18 +133,18 @@ class MailHandler implements MailHandlerInterface {
}
if (!$message->isPersonal()) {
- $this->logger->notice('%sender-name (@sender-from) sent an email regarding %contact_form.', array(
+ $this->logger->notice('%sender-name (@sender-from) sent an email regarding %contact_form.', [
'%sender-name' => $sender_cloned->getUsername(),
'@sender-from' => $sender_cloned->getEmail(),
'%contact_form' => $contact_form->label(),
- ));
+ ]);
}
else {
- $this->logger->notice('%sender-name (@sender-from) sent %recipient-name an email.', array(
+ $this->logger->notice('%sender-name (@sender-from) sent %recipient-name an email.', [
'%sender-name' => $sender_cloned->getUsername(),
'@sender-from' => $sender_cloned->getEmail(),
'%recipient-name' => $message->getPersonalRecipient()->getUsername(),
- ));
+ ]);
}
}
diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php
index da221ff8352..16d41b5acc4 100644
--- a/core/modules/contact/src/MessageForm.php
+++ b/core/modules/contact/src/MessageForm.php
@@ -103,24 +103,24 @@ class MessageForm extends ContentEntityForm {
$form['#attributes']['class'][] = 'contact-form';
if (!empty($message->preview)) {
- $form['preview'] = array(
- '#theme_wrappers' => array('container__preview'),
- '#attributes' => array('class' => array('preview')),
- );
+ $form['preview'] = [
+ '#theme_wrappers' => ['container__preview'],
+ '#attributes' => ['class' => ['preview']],
+ ];
$form['preview']['message'] = $this->entityManager->getViewBuilder('contact_message')->view($message, 'full');
}
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Your name'),
'#maxlength' => 255,
'#required' => TRUE,
- );
- $form['mail'] = array(
+ ];
+ $form['mail'] = [
'#type' => 'email',
'#title' => $this->t('Your email address'),
'#required' => TRUE,
- );
+ ];
if ($user->isAnonymous()) {
$form['#attached']['library'][] = 'core/drupal.form';
$form['#attributes']['data-user-info-from-browser'] = TRUE;
@@ -141,24 +141,24 @@ class MessageForm extends ContentEntityForm {
// The user contact form has a preset recipient.
if ($message->isPersonal()) {
- $form['recipient'] = array(
+ $form['recipient'] = [
'#type' => 'item',
'#title' => $this->t('To'),
'#value' => $message->getPersonalRecipient()->id(),
- 'name' => array(
+ 'name' => [
'#theme' => 'username',
'#account' => $message->getPersonalRecipient(),
- ),
- );
+ ],
+ ];
}
- $form['copy'] = array(
+ $form['copy'] = [
'#type' => 'checkbox',
'#title' => $this->t('Send yourself a copy'),
// Do not allow anonymous users to send themselves a copy, because it can
// be abused to spam people.
'#access' => $user->isAuthenticated(),
- );
+ ];
return $form;
}
@@ -168,11 +168,11 @@ class MessageForm extends ContentEntityForm {
public function actions(array $form, FormStateInterface $form_state) {
$elements = parent::actions($form, $form_state);
$elements['submit']['#value'] = $this->t('Send message');
- $elements['preview'] = array(
+ $elements['preview'] = [
'#type' => 'submit',
'#value' => $this->t('Preview'),
- '#submit' => array('::submitForm', '::preview'),
- );
+ '#submit' => ['::submitForm', '::preview'],
+ ];
return $elements;
}
@@ -197,10 +197,10 @@ class MessageForm extends ContentEntityForm {
$interval = $this->config('contact.settings')->get('flood.interval');
if (!$this->flood->isAllowed('contact', $limit, $interval)) {
- $form_state->setErrorByName('', $this->t('You cannot send more than %limit messages in @interval. Try again later.', array(
+ $form_state->setErrorByName('', $this->t('You cannot send more than %limit messages in @interval. Try again later.', [
'%limit' => $limit,
'@interval' => $this->dateFormatter->formatInterval($interval),
- )));
+ ]));
}
}
diff --git a/core/modules/contact/src/MessageViewBuilder.php b/core/modules/contact/src/MessageViewBuilder.php
index 3024f629126..6cbf0e738e4 100644
--- a/core/modules/contact/src/MessageViewBuilder.php
+++ b/core/modules/contact/src/MessageViewBuilder.php
@@ -33,11 +33,11 @@ class MessageViewBuilder extends EntityViewBuilder {
// Add the message extra field, if enabled.
$display = $displays[$entity->bundle()];
if ($entity->getMessage() && $display->getComponent('message')) {
- $build[$id]['message'] = array(
+ $build[$id]['message'] = [
'#type' => 'item',
'#title' => t('Message'),
'#plain_text' => $entity->getMessage(),
- );
+ ];
}
}
}
@@ -54,7 +54,7 @@ class MessageViewBuilder extends EntityViewBuilder {
// convert DIVs correctly.
foreach (Element::children($build) as $key) {
if (isset($build[$key]['#label_display']) && $build[$key]['#label_display'] == 'above') {
- $build[$key] += array('#prefix' => '');
+ $build[$key] += ['#prefix' => ''];
$build[$key]['#prefix'] = $build[$key]['#title'] . ":\n";
$build[$key]['#label_display'] = 'hidden';
}
diff --git a/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php b/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php
index 2975431ad5d..0b9f7b3b837 100644
--- a/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php
+++ b/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php
@@ -20,14 +20,14 @@ class ContactCategory extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('contact', 'c')
- ->fields('c', array(
+ ->fields('c', [
'cid',
'category',
'recipients',
'reply',
'weight',
'selected',
- )
+ ]
);
$query->orderBy('c.cid');
return $query;
@@ -45,14 +45,14 @@ class ContactCategory extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'cid' => $this->t('Primary Key: Unique category ID.'),
'category' => $this->t('Category name.'),
'recipients' => $this->t('Comma-separated list of recipient email addresses.'),
'reply' => $this->t('Text of the auto-reply message.'),
'weight' => $this->t("The category's weight."),
'selected' => $this->t('Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)'),
- );
+ ];
}
/**
diff --git a/core/modules/contact/src/Plugin/views/field/ContactLink.php b/core/modules/contact/src/Plugin/views/field/ContactLink.php
index ecc4cea9fa4..a98be137ddd 100644
--- a/core/modules/contact/src/Plugin/views/field/ContactLink.php
+++ b/core/modules/contact/src/Plugin/views/field/ContactLink.php
@@ -42,8 +42,8 @@ class ContactLink extends LinkBase {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['url'] = $this->getUrlInfo($row);
- $title = $this->t('Contact %user', array('%user' => $entity->label()));
- $this->options['alter']['attributes'] = array('title' => $title);
+ $title = $this->t('Contact %user', ['%user' => $entity->label()]);
+ $this->options['alter']['attributes'] = ['title' => $title];
if (!empty($this->options['text'])) {
return $this->options['text'];
diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/src/Tests/ContactPersonalTest.php
index 936aed5892c..d80484f4298 100644
--- a/core/modules/contact/src/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/src/Tests/ContactPersonalTest.php
@@ -20,7 +20,7 @@ class ContactPersonalTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('contact', 'dblog');
+ public static $modules = ['contact', 'dblog'];
/**
* A user with some administrative permissions.
@@ -47,11 +47,11 @@ class ContactPersonalTest extends WebTestBase {
parent::setUp();
// Create an admin user.
- $this->adminUser = $this->drupalCreateUser(array('administer contact forms', 'administer users', 'administer account settings', 'access site reports'));
+ $this->adminUser = $this->drupalCreateUser(['administer contact forms', 'administer users', 'administer account settings', 'access site reports']);
// Create some normal users with their contact forms enabled by default.
$this->config('contact.settings')->set('user_default_enabled', TRUE)->save();
- $this->webUser = $this->drupalCreateUser(array('access user profiles', 'access user contact forms'));
+ $this->webUser = $this->drupalCreateUser(['access user profiles', 'access user contact forms']);
$this->contactUser = $this->drupalCreateUser();
}
@@ -74,11 +74,11 @@ class ContactPersonalTest extends WebTestBase {
$this->assertEqual($mail['from'], $this->config('system.site')->get('mail'));
$this->assertEqual($mail['reply-to'], $this->webUser->getEmail());
$this->assertEqual($mail['key'], 'user_mail');
- $variables = array(
+ $variables = [
'@site-name' => $this->config('system.site')->get('name'),
'@subject' => $message['subject[0][value]'],
'@recipient-name' => $this->contactUser->getDisplayName(),
- );
+ ];
$subject = PlainTextOutput::renderFromHtml(t('[@site-name] @subject', $variables));
$this->assertEqual($mail['subject'], $subject, 'Subject is in sent message.');
$this->assertTrue(strpos($mail['body'], 'Hello ' . $variables['@recipient-name']) !== FALSE, 'Recipient name is in sent message.');
@@ -90,11 +90,11 @@ class ContactPersonalTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
// Verify that the correct watchdog message has been logged.
$this->drupalGet('/admin/reports/dblog');
- $placeholders = array(
+ $placeholders = [
'@sender_name' => $this->webUser->username,
'@sender_email' => $this->webUser->getEmail(),
'@recipient_name' => $this->contactUser->getUsername()
- );
+ ];
$this->assertRaw(SafeMarkup::format('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders));
// Ensure an unescaped version of the email does not exist anywhere.
$this->assertNoRaw($this->webUser->getEmail());
@@ -109,7 +109,7 @@ class ContactPersonalTest extends WebTestBase {
$this->drupalGet('user/' . $this->adminUser->id() . '/contact');
$this->assertResponse(200);
// Check the page title is properly displayed.
- $this->assertRaw(t('Contact @username', array('@username' => $this->adminUser->getDisplayName())));
+ $this->assertRaw(t('Contact @username', ['@username' => $this->adminUser->getDisplayName()]));
// Test denied access to admin user's own contact form.
$this->drupalLogout();
@@ -149,7 +149,7 @@ class ContactPersonalTest extends WebTestBase {
// Test that anonymous users can access the contact form.
$this->drupalLogout();
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']);
$this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(200);
@@ -159,7 +159,7 @@ class ContactPersonalTest extends WebTestBase {
$this->assertCacheContext('user');
// Revoke the personal contact permission for the anonymous user.
- user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms'));
+ user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']);
$this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(403);
$this->assertCacheContext('user');
@@ -168,7 +168,7 @@ class ContactPersonalTest extends WebTestBase {
// Disable the personal contact form.
$this->drupalLogin($this->adminUser);
- $edit = array('contact_default_status' => FALSE);
+ $edit = ['contact_default_status' => FALSE];
$this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.');
$this->drupalLogout();
@@ -206,7 +206,7 @@ class ContactPersonalTest extends WebTestBase {
$this->drupalGet('user/' . $this->webUser->id() . '/edit');
$this->assertNoFieldChecked('edit-contact--2');
$this->assertFalse(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form disabled');
- $this->drupalPostForm(NULL, array('contact' => TRUE), t('Save'));
+ $this->drupalPostForm(NULL, ['contact' => TRUE], t('Save'));
$this->assertFieldChecked('edit-contact--2');
$this->assertTrue(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form enabled');
@@ -237,7 +237,7 @@ class ContactPersonalTest extends WebTestBase {
// Submit contact form one over limit.
$this->submitPersonalContact($this->contactUser);
- $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
+ $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', ['%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'))]), 'Normal user denied access to flooded contact form.');
// Test that the admin user can still access the contact form even though
// the flood limit was reached.
@@ -249,7 +249,7 @@ class ContactPersonalTest extends WebTestBase {
* Tests the personal contact form based access when an admin adds users.
*/
function testAdminContact() {
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']);
$this->checkContactAccess(200);
$this->checkContactAccess(403, FALSE);
$config = $this->config('contact.settings');
@@ -276,13 +276,13 @@ class ContactPersonalTest extends WebTestBase {
$this->assertNoFieldChecked('edit-contact--2');
}
$name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'name' => $name,
'mail' => $this->randomMachineName() . '@example.com',
'pass[pass1]' => $pass = $this->randomString(),
'pass[pass2]' => $pass,
'notify' => FALSE,
- );
+ ];
if (isset($contact_value)) {
$edit['contact'] = $contact_value;
}
@@ -306,11 +306,11 @@ class ContactPersonalTest extends WebTestBase {
* @return array
* An array with the form fields being used.
*/
- protected function submitPersonalContact(AccountInterface $account, array $message = array()) {
- $message += array(
+ protected function submitPersonalContact(AccountInterface $account, array $message = []) {
+ $message += [
'subject[0][value]' => $this->randomMachineName(16),
'message[0][value]' => $this->randomMachineName(64),
- );
+ ];
$this->drupalPostForm('user/' . $account->id() . '/contact', $message, t('Send message'));
return $message;
}
diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php
index ffc2e9091c9..0721cf4dc9d 100644
--- a/core/modules/contact/src/Tests/ContactSitewideTest.php
+++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
@@ -65,7 +65,7 @@ class ContactSitewideTest extends WebTestBase {
->save();
// Set settings.
- $edit = array();
+ $edit = [];
$edit['contact_default_status'] = TRUE;
$this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
@@ -77,11 +77,11 @@ class ContactSitewideTest extends WebTestBase {
// Cannot use ::assertNoLinkByHref as it does partial url matching and with
// field_ui enabled admin/structure/contact/manage/personal/fields exists.
// @todo: See https://www.drupal.org/node/2031223 for the above.
- $edit_link = $this->xpath('//a[@href=:href]', array(
- ':href' => \Drupal::url('entity.contact_form.edit_form', array('contact_form' => 'personal'))
- ));
+ $edit_link = $this->xpath('//a[@href=:href]', [
+ ':href' => \Drupal::url('entity.contact_form.edit_form', ['contact_form' => 'personal'])
+ ]);
$this->assertTrue(empty($edit_link), format_string('No link containing href %href found.',
- array('%href' => 'admin/structure/contact/manage/personal')
+ ['%href' => 'admin/structure/contact/manage/personal']
));
$this->assertNoLinkByHref('admin/structure/contact/manage/personal/delete');
@@ -95,7 +95,7 @@ class ContactSitewideTest extends WebTestBase {
$this->assertNoLinkByHref('admin/structure/contact/manage/feedback');
// Ensure that the contact form won't be shown without forms.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
$this->drupalLogout();
$this->drupalGet('contact');
$this->assertResponse(404);
@@ -110,10 +110,10 @@ class ContactSitewideTest extends WebTestBase {
// Add forms.
// Test invalid recipients.
- $invalid_recipients = array('invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com');
+ $invalid_recipients = ['invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'];
foreach ($invalid_recipients as $invalid_recipient) {
$this->addContactForm($this->randomMachineName(16), $this->randomMachineName(16), $invalid_recipient, '', FALSE);
- $this->assertRaw(t('%recipient is an invalid email address.', array('%recipient' => $invalid_recipient)));
+ $this->assertRaw(t('%recipient is an invalid email address.', ['%recipient' => $invalid_recipient]));
}
// Test validation of empty form and recipients fields.
@@ -123,24 +123,24 @@ class ContactSitewideTest extends WebTestBase {
$this->assertText(t('Recipients field is required.'));
// Test validation of max_length machine name.
- $recipients = array('simpletest&@example.com', 'simpletest2@example.com', 'simpletest3@example.com');
+ $recipients = ['simpletest&@example.com', 'simpletest2@example.com', 'simpletest3@example.com'];
$max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH;
$max_length_exceeded = $max_length + 1;
- $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE);
- $this->assertText(format_string('Machine-readable name cannot be longer than @max characters but is currently @exceeded characters long.', array('@max' => $max_length, '@exceeded' => $max_length_exceeded)));
- $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE);
- $this->assertText(t('Contact form @label has been added.', array('@label' => $label)));
+ $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', [$recipients[0]]), '', TRUE);
+ $this->assertText(format_string('Machine-readable name cannot be longer than @max characters but is currently @exceeded characters long.', ['@max' => $max_length, '@exceeded' => $max_length_exceeded]));
+ $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', [$recipients[0]]), '', TRUE);
+ $this->assertText(t('Contact form @label has been added.', ['@label' => $label]));
// Verify that the creation message contains a link to a contact form.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'contact/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'contact/']);
$this->assert(isset($view_link), 'The message area contains a link to a contact form.');
// Create first valid form.
- $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0])), '', TRUE);
- $this->assertText(t('Contact form @label has been added.', array('@label' => $label)));
+ $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0]]), '', TRUE);
+ $this->assertText(t('Contact form @label has been added.', ['@label' => $label]));
// Verify that the creation message contains a link to a contact form.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'contact/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'contact/']);
$this->assert(isset($view_link), 'The message area contains a link to a contact form.');
// Check that the form was created in site default language.
@@ -156,13 +156,13 @@ class ContactSitewideTest extends WebTestBase {
$this->assertEscaped($recipients[0]);
// Test update contact form.
- $this->updateContactForm($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomMachineName(30), FALSE, 'Your message has been sent.', '/user');
+ $this->updateContactForm($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', [$recipients[0], $recipients[1]]), $reply = $this->randomMachineName(30), FALSE, 'Your message has been sent.', '/user');
$config = $this->config('contact.form.' . $id)->get();
$this->assertEqual($config['label'], $label);
- $this->assertEqual($config['recipients'], array($recipients[0], $recipients[1]));
+ $this->assertEqual($config['recipients'], [$recipients[0], $recipients[1]]);
$this->assertEqual($config['reply'], $reply);
$this->assertNotEqual($id, $this->config('contact.settings')->get('default_form'));
- $this->assertText(t('Contact form @label has been updated.', array('@label' => $label)));
+ $this->assertText(t('Contact form @label has been updated.', ['@label' => $label]));
// Ensure the label is displayed on the contact page for this form.
$this->drupalGet('contact/' . $id);
$this->assertText($label);
@@ -171,7 +171,7 @@ class ContactSitewideTest extends WebTestBase {
$this->config('contact.settings')->set('default_form', $id)->save();
// Ensure that the contact form is shown without a form selection input.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
$this->drupalLogout();
$this->drupalGet('contact');
$this->assertText(t('Your email address'));
@@ -179,26 +179,26 @@ class ContactSitewideTest extends WebTestBase {
$this->drupalLogin($admin_user);
// Add more forms.
- $this->addContactForm(Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE);
- $this->assertText(t('Contact form @label has been added.', array('@label' => $label)));
+ $this->addContactForm(Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1]]), '', FALSE);
+ $this->assertText(t('Contact form @label has been added.', ['@label' => $label]));
- $this->addContactForm($name = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE);
- $this->assertText(t('Contact form @label has been added.', array('@label' => $label)));
+ $this->addContactForm($name = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1], $recipients[2]]), '', FALSE);
+ $this->assertText(t('Contact form @label has been added.', ['@label' => $label]));
// Try adding a form that already exists.
$this->addContactForm($name, $label, '', '', FALSE);
- $this->assertNoText(t('Contact form @label has been added.', array('@label' => $label)));
+ $this->assertNoText(t('Contact form @label has been added.', ['@label' => $label]));
$this->assertRaw(t('The machine-readable name is already in use. It must be unique.'));
$this->drupalLogout();
// Check to see that anonymous user cannot see contact page without permission.
- user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
+ user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
$this->drupalGet('contact');
$this->assertResponse(403);
// Give anonymous user permission and see that page is viewable.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
$this->drupalGet('contact');
$this->assertResponse(200);
@@ -210,7 +210,7 @@ class ContactSitewideTest extends WebTestBase {
$this->assertText(t('Your email address field is required.'));
$this->submitContact($this->randomMachineName(16), $invalid_recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
- $this->assertRaw(t('The email address %mail is not valid.', array('%mail' => 'invalid')));
+ $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
$this->submitContact($this->randomMachineName(16), $recipients[0], '', $id, $this->randomMachineName(64));
$this->assertText(t('Subject field is required.'));
@@ -238,7 +238,7 @@ class ContactSitewideTest extends WebTestBase {
}
// Submit contact form one over limit.
$this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
- $this->assertRaw(t('You cannot send more than %number messages in 10 min. Try again later.', array('%number' => $this->config('contact.settings')->get('flood.limit'))));
+ $this->assertRaw(t('You cannot send more than %number messages in 10 min. Try again later.', ['%number' => $this->config('contact.settings')->get('flood.limit')]));
// Test listing controller.
$this->drupalLogin($admin_user);
@@ -246,7 +246,7 @@ class ContactSitewideTest extends WebTestBase {
$this->deleteContactForms();
$label = $this->randomMachineName(16);
- $recipients = implode(',', array($recipients[0], $recipients[1], $recipients[2]));
+ $recipients = implode(',', [$recipients[0], $recipients[1], $recipients[2]]);
$contact_form = Unicode::strtolower($this->randomMachineName(16));
$this->addContactForm($contact_form, $label, $recipients, '', FALSE);
$this->drupalGet('admin/structure/contact');
@@ -293,15 +293,15 @@ class ContactSitewideTest extends WebTestBase {
$this->assertText($field_label);
// Submit the contact form and verify the content.
- $edit = array(
+ $edit = [
'subject[0][value]' => $this->randomMachineName(),
'message[0][value]' => $this->randomMachineName(),
$field_name . '[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Send message'));
$mails = $this->drupalGetMails();
$mail = array_pop($mails);
- $this->assertEqual($mail['subject'], t('[@label] @subject', array('@label' => $label, '@subject' => $edit['subject[0][value]'])));
+ $this->assertEqual($mail['subject'], t('[@label] @subject', ['@label' => $label, '@subject' => $edit['subject[0][value]']]));
$this->assertTrue(strpos($mail['body'], $field_label));
$this->assertTrue(strpos($mail['body'], $edit[$field_name . '[0][value]']));
@@ -315,11 +315,11 @@ class ContactSitewideTest extends WebTestBase {
$this->drupalGet('contact/' . $contact_form);
// Submit the contact form and verify the content.
- $edit = array(
+ $edit = [
'subject[0][value]' => $this->randomMachineName(),
'message[0][value]' => $this->randomMachineName(),
$field_name . '[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Send message'));
$this->assertText('Thanks for your submission.');
$this->assertUrl('user/' . $admin_user->id());
@@ -335,13 +335,13 @@ class ContactSitewideTest extends WebTestBase {
$this->drupalGet('contact/' . $contact_form);
// Submit the contact form and verify the content.
- $edit = array(
+ $edit = [
'subject[0][value]' => $this->randomMachineName(),
'message[0][value]' => $this->randomMachineName(),
$field_name . '[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Send message'));
- $result = $this->xpath('//div[@role=:role]', array(':role' => 'contentinfo'));
+ $result = $this->xpath('//div[@role=:role]', [':role' => 'contentinfo']);
$this->assertEqual(count($result), 0, 'Messages not found.');
$this->assertUrl('user/' . $admin_user->id());
}
@@ -369,7 +369,7 @@ class ContactSitewideTest extends WebTestBase {
// Log the current user out in order to test the name and email fields.
$this->drupalLogout();
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
// Test the auto-reply for form 'foo'.
$email = $this->randomMachineName(32) . '@example.com';
@@ -377,7 +377,7 @@ class ContactSitewideTest extends WebTestBase {
$this->submitContact($this->randomMachineName(16), $email, $subject, 'foo', $this->randomString(128));
// We are testing the auto-reply, so there should be one email going to the sender.
- $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email));
+ $captured_emails = $this->drupalGetMails(['id' => 'contact_page_autoreply', 'to' => $email]);
$this->assertEqual(count($captured_emails), 1);
$this->assertEqual(trim($captured_emails[0]['body']), trim(MailFormatHelper::htmlToText($foo_autoreply)));
@@ -386,14 +386,14 @@ class ContactSitewideTest extends WebTestBase {
$this->submitContact($this->randomMachineName(16), $email, $this->randomString(64), 'bar', $this->randomString(128));
// Auto-reply for form 'bar' should result in one auto-reply email to the sender.
- $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email));
+ $captured_emails = $this->drupalGetMails(['id' => 'contact_page_autoreply', 'to' => $email]);
$this->assertEqual(count($captured_emails), 1);
$this->assertEqual(trim($captured_emails[0]['body']), trim(MailFormatHelper::htmlToText($bar_autoreply)));
// Verify that no auto-reply is sent when the auto-reply field is left blank.
$email = $this->randomMachineName(32) . '@example.com';
$this->submitContact($this->randomMachineName(16), $email, $this->randomString(64), 'no_autoreply', $this->randomString(128));
- $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email));
+ $captured_emails = $this->drupalGetMails(['id' => 'contact_page_autoreply', 'to' => $email]);
$this->assertEqual(count($captured_emails), 0);
// Verify that the current error message doesn't show, that the auto-reply
@@ -432,7 +432,7 @@ class ContactSitewideTest extends WebTestBase {
* Array of third party settings to be added to the posted form data.
*/
function addContactForm($id, $label, $recipients, $reply, $selected, $message = 'Your message has been sent.', $third_party_settings = []) {
- $edit = array();
+ $edit = [];
$edit['label'] = $label;
$edit['id'] = $id;
$edit['message'] = $message;
@@ -464,7 +464,7 @@ class ContactSitewideTest extends WebTestBase {
* The path where user will be redirect after this form has been submitted..
*/
function updateContactForm($id, $label, $recipients, $reply, $selected, $message = 'Your message has been sent.', $redirect = '/') {
- $edit = array();
+ $edit = [];
$edit['label'] = $label;
$edit['recipients'] = $recipients;
$edit['reply'] = $reply;
@@ -489,7 +489,7 @@ class ContactSitewideTest extends WebTestBase {
* The message body.
*/
function submitContact($name, $mail, $subject, $id, $message) {
- $edit = array();
+ $edit = [];
$edit['name'] = $name;
$edit['mail'] = $mail;
$edit['subject[0][value]'] = $subject;
@@ -514,9 +514,9 @@ class ContactSitewideTest extends WebTestBase {
$this->assertResponse(403);
}
else {
- $this->drupalPostForm("admin/structure/contact/manage/$id/delete", array(), t('Delete'));
- $this->assertRaw(t('The contact form %label has been deleted.', array('%label' => $contact_form->label())));
- $this->assertFalse(ContactForm::load($id), format_string('Form %contact_form not found', array('%contact_form' => $contact_form->label())));
+ $this->drupalPostForm("admin/structure/contact/manage/$id/delete", [], t('Delete'));
+ $this->assertRaw(t('The contact form %label has been deleted.', ['%label' => $contact_form->label()]));
+ $this->assertFalse(ContactForm::load($id), format_string('Form %contact_form not found', ['%contact_form' => $contact_form->label()]));
}
}
}
diff --git a/core/modules/contact/src/Tests/ContactStorageTest.php b/core/modules/contact/src/Tests/ContactStorageTest.php
index ad0e8d46c53..f9165a8534f 100644
--- a/core/modules/contact/src/Tests/ContactStorageTest.php
+++ b/core/modules/contact/src/Tests/ContactStorageTest.php
@@ -37,23 +37,23 @@ class ContactStorageTest extends ContactSitewideTest {
*/
public function testContactStorage() {
// Create and log in administrative user.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'access site-wide contact form',
'administer contact forms',
'administer users',
'administer account settings',
'administer contact_message fields',
- ));
+ ]);
$this->drupalLogin($admin_user);
// Create first valid contact form.
$mail = 'simpletest@example.com';
- $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE, 'Your message has been sent.', [
+ $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$mail]), '', TRUE, 'Your message has been sent.', [
'send_a_pony' => 1,
]);
- $this->assertText(t('Contact form @label has been added.', array('@label' => $label)));
+ $this->assertText(t('Contact form @label has been added.', ['@label' => $label]));
// Ensure that anonymous can submit site-wide contact form.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
$this->drupalLogout();
$this->drupalGet('contact');
$this->assertText(t('Your email address'));
diff --git a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
index cf707996f11..fafe451be5c 100644
--- a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
+++ b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
@@ -19,7 +19,7 @@ class ContactFieldsTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('field', 'text', 'contact');
+ public static $modules = ['field', 'text', 'contact'];
/**
* Contains the field storage definition for contact used for this test.
@@ -31,11 +31,11 @@ class ContactFieldsTest extends ViewTestBase {
protected function setUp() {
parent::setUp();
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => strtolower($this->randomMachineName()),
'entity_type' => 'contact_message',
'type' => 'text'
- ));
+ ]);
$this->fieldStorage->save();
ContactForm::create([
diff --git a/core/modules/contact/src/Tests/Views/ContactLinkTest.php b/core/modules/contact/src/Tests/Views/ContactLinkTest.php
index 738f67c1b44..f6b6013b43a 100644
--- a/core/modules/contact/src/Tests/Views/ContactLinkTest.php
+++ b/core/modules/contact/src/Tests/Views/ContactLinkTest.php
@@ -27,14 +27,14 @@ class ContactLinkTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('contact_test_views');
+ public static $modules = ['contact_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_contact_link');
+ public static $testViews = ['test_contact_link'];
/**
* {@inheritdoc}
@@ -42,7 +42,7 @@ class ContactLinkTest extends ViewTestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('contact_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['contact_test_views']);
$this->userData = $this->container->get('user.data');
}
@@ -51,39 +51,39 @@ class ContactLinkTest extends ViewTestBase {
* Tests contact link.
*/
public function testContactLink() {
- $accounts = array();
+ $accounts = [];
$accounts['root'] = User::load(1);
// Create an account with access to all contact pages.
- $admin_account = $this->drupalCreateUser(array('administer users'));
+ $admin_account = $this->drupalCreateUser(['administer users']);
$accounts['admin'] = $admin_account;
// Create an account with no access to contact pages.
$no_contact_account = $this->drupalCreateUser();
$accounts['no_contact'] = $no_contact_account;
// Create an account with access to contact pages.
- $contact_account = $this->drupalCreateUser(array('access user contact forms'));
+ $contact_account = $this->drupalCreateUser(['access user contact forms']);
$accounts['contact'] = $contact_account;
$this->drupalLogin($admin_account);
$this->drupalGet('test-contact-link');
// The admin user has access to all contact links beside his own.
- $this->assertContactLinks($accounts, array('root', 'no_contact', 'contact'));
+ $this->assertContactLinks($accounts, ['root', 'no_contact', 'contact']);
$this->drupalLogin($no_contact_account);
$this->drupalGet('test-contact-link');
// Ensure that the user without the permission doesn't see any link.
- $this->assertContactLinks($accounts, array());
+ $this->assertContactLinks($accounts, []);
$this->drupalLogin($contact_account);
$this->drupalGet('test-contact-link');
- $this->assertContactLinks($accounts, array('root', 'admin', 'no_contact'));
+ $this->assertContactLinks($accounts, ['root', 'admin', 'no_contact']);
// Disable contact link for no_contact.
$this->userData->set('contact', $no_contact_account->id(), 'enabled', FALSE);
// @todo Remove cache invalidation in https://www.drupal.org/node/2477903.
Cache::invalidateTags($no_contact_account->getCacheTagsToInvalidate());
$this->drupalGet('test-contact-link');
- $this->assertContactLinks($accounts, array('root', 'admin'));
+ $this->assertContactLinks($accounts, ['root', 'admin']);
}
/**
@@ -100,7 +100,7 @@ class ContactLinkTest extends ViewTestBase {
foreach ($names as $name) {
$account = $accounts[$name];
- $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', array(':url' => $account->url('contact-form')));
+ $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', [':url' => $account->url('contact-form')]);
$this->assertTrue(count($result));
}
}
diff --git a/core/modules/contact/tests/drupal-7.contact.database.php b/core/modules/contact/tests/drupal-7.contact.database.php
index 115f83c17cf..bd36384d7ea 100644
--- a/core/modules/contact/tests/drupal-7.contact.database.php
+++ b/core/modules/contact/tests/drupal-7.contact.database.php
@@ -11,23 +11,23 @@
// Update the default category to that it is not selected.
db_update('contact')
- ->fields(array('selected' => '0'))
+ ->fields(['selected' => '0'])
->condition('cid', '1')
->execute();
// Add a custom contact category.
-db_insert('contact')->fields(array(
+db_insert('contact')->fields([
'category',
'recipients',
'reply',
'weight',
'selected'
-))
- ->values(array(
+])
+ ->values([
'category' => 'Upgrade test',
'recipients' => 'test1@example.com,test2@example.com',
'reply' => 'Test reply',
'weight' => 1,
'selected' => 1,
-))
+])
->execute();
diff --git a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module
index e20dc436fcc..cef976c6ffe 100644
--- a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module
+++ b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module
@@ -15,7 +15,7 @@ use Drupal\Core\Form\FormStateInterface;
*/
function contact_storage_test_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'contact_message') {
- $fields = array();
+ $fields = [];
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('Message ID'))
@@ -48,12 +48,12 @@ function contact_storage_test_entity_type_alter(array &$entity_types) {
function contact_storage_test_form_contact_form_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\contact\ContactFormInterface $contact_form */
$contact_form = $form_state->getFormObject()->getEntity();
- $form['send_a_pony'] = array(
+ $form['send_a_pony'] = [
'#type' => 'checkbox',
'#title' => t('Send submitters a voucher for a free pony.'),
'#description' => t('Enable to send an additional email with a free pony voucher to anyone who submits the form.'),
'#default_value' => $contact_form->getThirdPartySetting('contact_storage_test', 'send_a_pony', FALSE),
- );
+ ];
$form['#entity_builders'][] = 'contact_storage_test_contact_form_form_builder';
}
/**
diff --git a/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php b/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php
index 4b4a520de67..306fe5d41cc 100644
--- a/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php
@@ -16,20 +16,20 @@ class ContactAuthenticatedUserTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('contact');
+ public static $modules = ['contact'];
/**
* Tests that name and email fields are not present for authenticated users.
*/
function testContactSiteWideTextfieldsLoggedInTestCase() {
- $this->drupalLogin($this->drupalCreateUser(array('access site-wide contact form')));
+ $this->drupalLogin($this->drupalCreateUser(['access site-wide contact form']));
$this->drupalGet('contact');
// Ensure that there is no textfield for name.
- $this->assertFalse($this->xpath('//input[@name=:name]', array(':name' => 'name')));
+ $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'name']));
// Ensure that there is no textfield for email.
- $this->assertFalse($this->xpath('//input[@name=:name]', array(':name' => 'mail')));
+ $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'mail']));
}
}
diff --git a/core/modules/contact/tests/src/Functional/ContactLanguageTest.php b/core/modules/contact/tests/src/Functional/ContactLanguageTest.php
index 47d15332d4e..0c34884503c 100644
--- a/core/modules/contact/tests/src/Functional/ContactLanguageTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactLanguageTest.php
@@ -20,11 +20,11 @@ class ContactLanguageTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'contact',
'language',
'contact_test',
- );
+ ];
/**
* {@inheritdoc}
@@ -33,10 +33,10 @@ class ContactLanguageTest extends BrowserTestBase {
parent::setUp();
// Create and log in administrative user.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'access site-wide contact form',
'administer languages',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
diff --git a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php
index 70ddea194e9..e7343b9166c 100644
--- a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php
+++ b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php
@@ -17,17 +17,17 @@ class MessageEntityTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'system',
'contact',
'field',
'user',
'contact_test',
- );
+ ];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('contact', 'contact_test'));
+ $this->installConfig(['contact', 'contact_test']);
}
/**
@@ -35,7 +35,7 @@ class MessageEntityTest extends EntityKernelTestBase {
*/
public function testMessageMethods() {
$message_storage = $this->container->get('entity.manager')->getStorage('contact_message');
- $message = $message_storage->create(array('contact_form' => 'feedback'));
+ $message = $message_storage->create(['contact_form' => 'feedback']);
// Check for empty values first.
$this->assertEqual($message->getMessage(), '');
diff --git a/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php b/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php
index 89f98b17399..ffadad409c9 100644
--- a/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php
+++ b/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php
@@ -18,7 +18,7 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
*
* @var array
*/
- public static $modules = array('contact');
+ public static $modules = ['contact'];
/**
* {@inheritdoc}
diff --git a/core/modules/contact/tests/src/Unit/MailHandlerTest.php b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
index 9e5c82c0c65..ce24cf4848a 100644
--- a/core/modules/contact/tests/src/Unit/MailHandlerTest.php
+++ b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
@@ -80,7 +80,7 @@ class MailHandlerTest extends UnitTestCase {
$string_translation = $this->getStringTranslationStub();
$this->contactMailHandler = new MailHandler($this->mailManager, $this->languageManager, $this->logger, $string_translation, $this->entityManager);
- $language = new Language(array('id' => 'en'));
+ $language = new Language(['id' => 'en']);
$this->languageManager->expects($this->any())
->method('getDefaultLanguage')
@@ -156,76 +156,76 @@ class MailHandlerTest extends UnitTestCase {
* Data provider for ::testSendMailMessages.
*/
public function getSendMailMessages() {
- $data = array();
- $recipients = array('admin@drupal.org', 'user@drupal.org');
- $default_result = array(
+ $data = [];
+ $recipients = ['admin@drupal.org', 'user@drupal.org'];
+ $default_result = [
'module' => 'contact',
'key' => '',
'to' => implode(', ', $recipients),
'langcode' => 'en',
- 'params' => array(),
+ 'params' => [],
'from' => 'anonymous@drupal.org',
- );
- $results = array();
+ ];
+ $results = [];
$message = $this->getAnonymousMockMessage($recipients, '');
$sender = $this->getMockSender();
- $result = array(
+ $result = [
'key' => 'page_mail',
- 'params' => array(
+ 'params' => [
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message->getContactForm(),
- ),
- );
+ ],
+ ];
$results[] = $result + $default_result;
- $data[] = array($message, $sender, $results);
+ $data[] = [$message, $sender, $results];
- $results = array();
+ $results = [];
$message = $this->getAnonymousMockMessage($recipients, 'reply');
$sender = $this->getMockSender();
- $result = array(
+ $result = [
'key' => 'page_mail',
- 'params' => array(
+ 'params' => [
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message->getContactForm(),
- ),
- );
+ ],
+ ];
$results[] = $result + $default_result;
$result['key'] = 'page_autoreply';
$result['to'] = 'anonymous@drupal.org';
$result['from'] = NULL;
$results[] = $result + $default_result;
- $data[] = array($message, $sender, $results);
+ $data[] = [$message, $sender, $results];
- $results = array();
+ $results = [];
$message = $this->getAnonymousMockMessage($recipients, '', TRUE);
$sender = $this->getMockSender();
- $result = array(
+ $result = [
'key' => 'page_mail',
- 'params' => array(
+ 'params' => [
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message->getContactForm(),
- ),
- );
+ ],
+ ];
$results[] = $result + $default_result;
$result['key'] = 'page_copy';
$result['to'] = 'anonymous@drupal.org';
$results[] = $result + $default_result;
- $data[] = array($message, $sender, $results);
+ $data[] = [$message, $sender, $results];
- $results = array();
+ $results = [];
$message = $this->getAnonymousMockMessage($recipients, 'reply', TRUE);
$sender = $this->getMockSender();
- $result = array(
+ $result = [
'key' => 'page_mail',
- 'params' => array(
+ 'params' => [
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message->getContactForm(),
- ),
- );
+ ],
+ ];
$results[] = $result + $default_result;
$result['key'] = 'page_copy';
$result['to'] = 'anonymous@drupal.org';
@@ -233,48 +233,48 @@ class MailHandlerTest extends UnitTestCase {
$result['key'] = 'page_autoreply';
$result['from'] = NULL;
$results[] = $result + $default_result;
- $data[] = array($message, $sender, $results);
+ $data[] = [$message, $sender, $results];
//For authenticated user.
- $results = array();
+ $results = [];
$message = $this->getAuthenticatedMockMessage();
$sender = $this->getMockSender(FALSE, 'user@drupal.org');
- $result = array(
+ $result = [
'module' => 'contact',
'key' => 'user_mail',
'to' => 'user2@drupal.org',
'langcode' => 'en',
- 'params' => array(
+ 'params' => [
'contact_message' => $message,
'sender' => $sender,
'recipient' => $message->getPersonalRecipient(),
- ),
+ ],
'from' => 'user@drupal.org',
- );
+ ];
$results[] = $result;
- $data[] = array($message, $sender, $results);
+ $data[] = [$message, $sender, $results];
- $results = array();
+ $results = [];
$message = $this->getAuthenticatedMockMessage(TRUE);
$sender = $this->getMockSender(FALSE, 'user@drupal.org');
- $result = array(
+ $result = [
'module' => 'contact',
'key' => 'user_mail',
'to' => 'user2@drupal.org',
'langcode' => 'en',
- 'params' => array(
+ 'params' => [
'contact_message' => $message,
'sender' => $sender,
'recipient' => $message->getPersonalRecipient(),
- ),
+ ],
'from' => 'user@drupal.org',
- );
+ ];
$results[] = $result;
$result['key'] = 'user_copy';
$result['to'] = $result['from'];
$results[] = $result;
- $data[] = array($message, $sender, $results);
+ $data[] = [$message, $sender, $results];
return $data;
}
diff --git a/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php b/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php
index 19ec324c1a9..cb87cc19ab8 100644
--- a/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php
+++ b/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php
@@ -19,9 +19,9 @@ class ContentModerationStateStorageSchema extends SqlContentEntityStorageSchema
// Creates an index to ensure that the lookup in
// \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::getModerationState()
// is performant.
- $schema['content_moderation_state_field_data']['indexes'] += array(
- 'content_moderation_state__lookup' => array('content_entity_type_id', 'content_entity_id', 'content_entity_revision_id'),
- );
+ $schema['content_moderation_state_field_data']['indexes'] += [
+ 'content_moderation_state__lookup' => ['content_entity_type_id', 'content_entity_id', 'content_entity_revision_id'],
+ ];
return $schema;
}
diff --git a/core/modules/content_moderation/src/Entity/ContentModerationState.php b/core/modules/content_moderation/src/Entity/ContentModerationState.php
index 6d5b39c2b47..cb1bc1fe9fd 100644
--- a/core/modules/content_moderation/src/Entity/ContentModerationState.php
+++ b/core/modules/content_moderation/src/Entity/ContentModerationState.php
@@ -148,7 +148,7 @@ class ContentModerationState extends ContentEntityBase implements ContentModerat
* An array of default values.
*/
public static function getCurrentUserId() {
- return array(\Drupal::currentUser()->id());
+ return [\Drupal::currentUser()->id()];
}
/**
diff --git a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php
index 980c61ebd88..94f10e9f00e 100644
--- a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php
+++ b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php
@@ -95,7 +95,7 @@ class EntityRevisionConverter extends EntityConverter {
// If the entity type is translatable, ensure we return the proper
// translation object for the current context.
if ($latest_revision instanceof EntityInterface && $entity instanceof TranslatableInterface) {
- $latest_revision = $this->entityManager->getTranslationFromContext($latest_revision, NULL, array('operation' => 'entity_upcast'));
+ $latest_revision = $this->entityManager->getTranslationFromContext($latest_revision, NULL, ['operation' => 'entity_upcast']);
}
if ($latest_revision->isRevisionTranslationAffected()) {
diff --git a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php
index 7fe5a6db9a5..970ac33a5dc 100644
--- a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php
+++ b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php
@@ -139,7 +139,7 @@ class ModerationStateWidget extends OptionsSelectWidget implements ContainerFact
'#published' => $default->isPublishedState(),
'#key_column' => $this->column,
];
- $element['#element_validate'][] = array(get_class($this), 'validateElement');
+ $element['#element_validate'][] = [get_class($this), 'validateElement'];
// Use the dropbutton.
$element['#process'][] = [get_called_class(), 'processActions'];
diff --git a/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php b/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php
index e42f536b91d..593a9f96187 100644
--- a/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php
+++ b/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php
@@ -73,11 +73,11 @@ class ModerationStateBlockTest extends ModerationStateTestBase {
$this->assertText(t('basic Moderated block has been created.'));
// Place the block in the Sidebar First region.
- $instance = array(
+ $instance = [
'id' => 'moderated_block',
'settings[label]' => $edit['info[0][value]'],
'region' => 'sidebar_first',
- );
+ ];
$block = BlockContent::load(1);
$url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default');
$this->drupalPostForm($url, $instance, t('Save block'));
diff --git a/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php b/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php
index fe36336176f..49eee6d5271 100644
--- a/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php
+++ b/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php
@@ -48,7 +48,7 @@ class ModerationStateNodeTest extends ModerationStateTestBase {
$this->assertNoText('Published');
// Delete the node.
- $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete'));
$this->assertText(t('The Moderated content moderated content has been deleted.'));
// Disable content moderation.
diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc
index 39e3247ca17..f29a7e65563 100644
--- a/core/modules/content_translation/content_translation.admin.inc
+++ b/core/modules/content_translation/content_translation.admin.inc
@@ -29,10 +29,10 @@ use Drupal\Core\Render\Element;
function content_translation_field_sync_widget(FieldDefinitionInterface $field, $element_name = 'third_party_settings[content_translation][translation_sync]') {
// No way to store field sync information on this field.
if (!($field instanceof ThirdPartySettingsInterface)) {
- return array();
+ return [];
}
- $element = array();
+ $element = [];
$definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getType());
$column_groups = $definition['column_groups'];
if (!empty($column_groups) && count($column_groups) > 1) {
@@ -50,12 +50,12 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field,
$default = $field->getThirdPartySetting('content_translation', 'translation_sync', $default);
- $element = array(
+ $element = [
'#type' => 'checkboxes',
'#title' => t('Translatable elements'),
'#options' => $options,
'#default_value' => $default,
- );
+ ];
if ($require_all_groups_for_translation) {
// The actual checkboxes are sometimes rendered separately and the parent
@@ -96,7 +96,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$
$bundle_info_service = \Drupal::service('entity_type.bundle.info');
foreach ($form['#labels'] as $entity_type_id => $label) {
$entity_type = $entity_manager->getDefinition($entity_type_id);
- $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : array();
+ $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : [];
$entity_type_translatable = $content_translation_manager->isSupported($entity_type_id);
foreach ($bundle_info_service->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
@@ -106,7 +106,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$
// about UI integration.
$form['settings'][$entity_type_id][$bundle]['settings']['language']['#content_translation_skip_alter'] = TRUE;
if (!$entity_type_translatable) {
- $form['settings'][$entity_type_id]['#title'] = t('@label (Translation is not supported).', array('@label' => $entity_type->getLabel()));
+ $form['settings'][$entity_type_id]['#title'] = t('@label (Translation is not supported).', ['@label' => $entity_type->getLabel()]);
continue;
}
@@ -114,11 +114,11 @@ function _content_translation_form_language_content_settings_form_alter(array &$
if ($fields) {
foreach ($fields as $field_name => $definition) {
if ($definition->isComputed() || (!empty($storage_definitions[$field_name]) && _content_translation_is_field_translatability_configurable($entity_type, $storage_definitions[$field_name]))) {
- $form['settings'][$entity_type_id][$bundle]['fields'][$field_name] = array(
+ $form['settings'][$entity_type_id][$bundle]['fields'][$field_name] = [
'#label' => $definition->getLabel(),
'#type' => 'checkbox',
'#default_value' => $definition->isTranslatable(),
- );
+ ];
// Display the column translatability configuration widget.
$column_element = content_translation_field_sync_widget($definition, "settings[{$entity_type_id}][{$bundle}][columns][{$field_name}]");
if ($column_element) {
@@ -129,10 +129,10 @@ function _content_translation_form_language_content_settings_form_alter(array &$
if (!empty($form['settings'][$entity_type_id][$bundle]['fields'])) {
// Only show the checkbox to enable translation if the bundles in the
// entity might have fields and if there are fields to translate.
- $form['settings'][$entity_type_id][$bundle]['translatable'] = array(
+ $form['settings'][$entity_type_id][$bundle]['translatable'] = [
'#type' => 'checkbox',
'#default_value' => $content_translation_manager->isEnabled($entity_type_id, $bundle),
- );
+ ];
}
}
}
@@ -177,102 +177,102 @@ function _content_translation_preprocess_language_content_settings_table(&$varia
$element = $variables['element'];
$build = &$variables['build'];
- array_unshift($build['#header'], array('data' => t('Translatable'), 'class' => array('translatable')));
- $rows = array();
+ array_unshift($build['#header'], ['data' => t('Translatable'), 'class' => ['translatable']]);
+ $rows = [];
foreach (Element::children($element) as $bundle) {
- $field_names = !empty($element[$bundle]['fields']) ? Element::children($element[$bundle]['fields']) : array();
+ $field_names = !empty($element[$bundle]['fields']) ? Element::children($element[$bundle]['fields']) : [];
if (!empty($element[$bundle]['translatable'])) {
$checkbox_id = $element[$bundle]['translatable']['#id'];
}
$rows[$bundle] = $build['#rows'][$bundle];
if (!empty($element[$bundle]['translatable'])) {
- $translatable = array(
+ $translatable = [
'data' => $element[$bundle]['translatable'],
- 'class' => array('translatable'),
- );
+ 'class' => ['translatable'],
+ ];
array_unshift($rows[$bundle]['data'], $translatable);
$rows[$bundle]['data'][1]['data']['#prefix'] = '<label for="' . $checkbox_id . '">';
}
else {
- $translatable = array(
+ $translatable = [
'data' => t('N/A'),
- 'class' => array('untranslatable'),
- );
+ 'class' => ['untranslatable'],
+ ];
array_unshift($rows[$bundle]['data'], $translatable);
}
foreach ($field_names as $field_name) {
$field_element = &$element[$bundle]['fields'][$field_name];
- $rows[] = array(
- 'data' => array(
- array(
+ $rows[] = [
+ 'data' => [
+ [
'data' => drupal_render($field_element),
- 'class' => array('translatable'),
- ),
- array(
- 'data' => array(
+ 'class' => ['translatable'],
+ ],
+ [
+ 'data' => [
'#prefix' => '<label for="' . $field_element['#id'] . '">',
'#suffix' => '</label>',
- 'bundle' => array(
+ 'bundle' => [
'#prefix' => '<span class="visually-hidden">',
'#suffix' => '</span> ',
'#plain_text' => $element[$bundle]['settings']['#label'],
- ),
- 'field' => array(
+ ],
+ 'field' => [
'#plain_text' => $field_element['#label'],
- ),
- ),
- 'class' => array('field'),
- ),
- array(
+ ],
+ ],
+ 'class' => ['field'],
+ ],
+ [
'data' => '',
- 'class' => array('operations'),
- ),
- ),
- 'class' => array('field-settings'),
- );
+ 'class' => ['operations'],
+ ],
+ ],
+ 'class' => ['field-settings'],
+ ];
if (!empty($element[$bundle]['columns'][$field_name])) {
$column_element = &$element[$bundle]['columns'][$field_name];
foreach (Element::children($column_element) as $key) {
$column_label = $column_element[$key]['#title'];
unset($column_element[$key]['#title']);
- $rows[] = array(
- 'data' => array(
- array(
+ $rows[] = [
+ 'data' => [
+ [
'data' => drupal_render($column_element[$key]),
- 'class' => array('translatable'),
- ),
- array(
- 'data' => array(
+ 'class' => ['translatable'],
+ ],
+ [
+ 'data' => [
'#prefix' => '<label for="' . $column_element[$key]['#id'] . '">',
'#suffix' => '</label>',
- 'bundle' => array(
+ 'bundle' => [
'#prefix' => '<span class="visually-hidden">',
'#suffix' => '</span> ',
'#plain_text' => $element[$bundle]['settings']['#label'],
- ),
- 'field' => array(
+ ],
+ 'field' => [
'#prefix' => '<span class="visually-hidden">',
'#suffix' => '</span> ',
'#plain_text' => $field_element['#label'],
- ),
- 'columns' => array(
+ ],
+ 'columns' => [
'#plain_text' => $column_label,
- ),
- ),
- 'class' => array('column'),
- ),
- array(
+ ],
+ ],
+ 'class' => ['column'],
+ ],
+ [
'data' => '',
- 'class' => array('operations'),
- ),
- ),
- 'class' => array('column-settings'),
- );
+ 'class' => ['operations'],
+ ],
+ ],
+ 'class' => ['column-settings'],
+ ];
}
}
}
@@ -295,7 +295,7 @@ function content_translation_form_language_content_settings_validate(array $form
$translatable_fields = isset($settings[$entity_type][$bundle]['fields']) ? array_filter($settings[$entity_type][$bundle]['fields']) : FALSE;
if (empty($translatable_fields)) {
- $t_args = array('%bundle' => $form['settings'][$entity_type][$bundle]['settings']['#label']);
+ $t_args = ['%bundle' => $form['settings'][$entity_type][$bundle]['settings']['#label']];
$form_state->setErrorByName($name, t('At least one field needs to be translatable to enable %bundle for translation.', $t_args));
}
@@ -304,7 +304,7 @@ function content_translation_form_language_content_settings_validate(array $form
foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) {
$locked_languages[] = $language->getName();
}
- $form_state->setErrorByName($name, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
+ $form_state->setErrorByName($name, t('Translation is not supported if language is always one of: @locked_languages', ['@locked_languages' => implode(', ', $locked_languages)]));
}
}
}
diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index a8416db42b6..68fafbf07d5 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -23,11 +23,11 @@ function content_translation_help($route_name, RouteMatchInterface $route_match)
case 'help.page.content_translation':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Content Translation module allows you to translate content, comments, custom blocks, taxonomy terms, users and other <a href=":field_help" title="Field module help, with background on content entities">content entities</a>. Together with the modules <a href=":language">Language</a>, <a href=":config-trans">Configuration Translation</a>, and <a href=":locale">Interface Translation</a>, it allows you to build multilingual websites. For more information, see the <a href=":translation-entity">online documentation for the Content Translation module</a>.', array(':locale' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', array('name' => 'locale')) : '#', ':config-trans' => (\Drupal::moduleHandler()->moduleExists('config_translation')) ? \Drupal::url('help.page', array('name' => 'config_translation')) : '#', ':language' => \Drupal::url('help.page', array('name' => 'language')), ':translation-entity' => 'https://www.drupal.org/documentation/modules/translation', ':field_help' => \Drupal::url('help.page', array('name' => 'field')))) . '</p>';
+ $output .= '<p>' . t('The Content Translation module allows you to translate content, comments, custom blocks, taxonomy terms, users and other <a href=":field_help" title="Field module help, with background on content entities">content entities</a>. Together with the modules <a href=":language">Language</a>, <a href=":config-trans">Configuration Translation</a>, and <a href=":locale">Interface Translation</a>, it allows you to build multilingual websites. For more information, see the <a href=":translation-entity">online documentation for the Content Translation module</a>.', [':locale' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', ['name' => 'locale']) : '#', ':config-trans' => (\Drupal::moduleHandler()->moduleExists('config_translation')) ? \Drupal::url('help.page', ['name' => 'config_translation']) : '#', ':language' => \Drupal::url('help.page', ['name' => 'language']), ':translation-entity' => 'https://www.drupal.org/documentation/modules/translation', ':field_help' => \Drupal::url('help.page', ['name' => 'field'])]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Enabling translation') . '</dt>';
- $output .= '<dd>' . t('In order to translate content, the website must have at least two <a href=":url">languages</a>. When that is the case, you can enable translation for the desired content entities on the <a href=":translation-entity">Content language</a> page. When enabling translation you can choose the default language for content and decide whether to show the language selection field on the content editing forms.', array(':url' => \Drupal::url('entity.configurable_language.collection'), ':translation-entity' => \Drupal::url('language.content_settings_page'), ':language-help' => \Drupal::url('help.page', array('name' => 'language')))) . '</dd>';
+ $output .= '<dd>' . t('In order to translate content, the website must have at least two <a href=":url">languages</a>. When that is the case, you can enable translation for the desired content entities on the <a href=":translation-entity">Content language</a> page. When enabling translation you can choose the default language for content and decide whether to show the language selection field on the content editing forms.', [':url' => \Drupal::url('entity.configurable_language.collection'), ':translation-entity' => \Drupal::url('language.content_settings_page'), ':language-help' => \Drupal::url('help.page', ['name' => 'language'])]) . '</dd>';
$output .= '<dt>' . t('Enabling field translation') . '</dt>';
$output .= '<dd>' . t('You can define which fields of a content entity can be translated. For example, you might want to translate the title and body field while leaving the image field untranslated. If you exclude a field from being translated, it will still show up in the content editing form, but any changes made to that field will be applied to <em>all</em> translations of that content.') . '</dd>';
$output .= '<dt>' . t('Translating content') . '</dt>';
@@ -42,7 +42,7 @@ function content_translation_help($route_name, RouteMatchInterface $route_match)
case 'language.content_settings_page':
$output = '';
if (!\Drupal::languageManager()->isMultilingual()) {
- $output .= '<p>' . t('Before you can translate content, there must be at least two languages added on the <a href=":url">languages administration</a> page.', array(':url' => \Drupal::url('entity.configurable_language.collection'))) . '</p>';
+ $output .= '<p>' . t('Before you can translate content, there must be at least two languages added on the <a href=":url">languages administration</a> page.', [':url' => \Drupal::url('entity.configurable_language.collection')]) . '</p>';
}
return $output;
}
@@ -134,7 +134,7 @@ function content_translation_entity_type_alter(array &$entity_types) {
$translation = $entity_type->get('translation');
if (!$translation || !isset($translation['content_translation'])) {
- $translation['content_translation'] = array();
+ $translation['content_translation'] = [];
}
if ($entity_type->hasLinkTemplate('canonical')) {
@@ -148,9 +148,9 @@ function content_translation_entity_type_alter(array &$entity_types) {
}
// @todo Remove this as soon as menu access checks rely on the
// controller. See https://www.drupal.org/node/2155787.
- $translation['content_translation'] += array(
+ $translation['content_translation'] += [
'access_callback' => 'content_translation_translate_access',
- );
+ ];
}
$entity_type->set('translation', $translation);
}
@@ -215,7 +215,7 @@ function content_translation_field_info_alter(&$info) {
foreach ($info as $key => $settings) {
// Supply the column_groups key if it's not there.
if (empty($settings['column_groups'])) {
- $info[$key]['column_groups'] = array();
+ $info[$key]['column_groups'] = [];
}
}
}
@@ -224,13 +224,13 @@ function content_translation_field_info_alter(&$info) {
* Implements hook_entity_operation().
*/
function content_translation_entity_operation(EntityInterface $entity) {
- $operations = array();
+ $operations = [];
if ($entity->hasLinkTemplate('drupal:content-translation-overview') && content_translation_translate_access($entity)->isAllowed()) {
- $operations['translate'] = array(
+ $operations['translate'] = [
'title' => t('Translate'),
'url' => $entity->urlInfo('drupal:content-translation-overview'),
'weight' => 50,
- );
+ ];
}
return $operations;
}
@@ -350,16 +350,16 @@ function content_translation_language_fallback_candidates_entity_view_alter(&$ca
* Implements hook_entity_extra_field_info().
*/
function content_translation_entity_extra_field_info() {
- $extra = array();
+ $extra = [];
$bundle_info_service = \Drupal::service('entity_type.bundle.info');
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $info) {
foreach ($bundle_info_service->getBundleInfo($entity_type) as $bundle => $bundle_info) {
if (\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle)) {
- $extra[$entity_type][$bundle]['form']['translation'] = array(
+ $extra[$entity_type][$bundle]['form']['translation'] = [
'label' => t('Translation'),
'description' => t('Translation settings'),
'weight' => 10,
- );
+ ];
}
}
}
@@ -374,23 +374,23 @@ function content_translation_form_field_config_edit_form_alter(array &$form, For
$field = $form_state->getFormObject()->getEntity();
$bundle_is_translatable = \Drupal::service('content_translation.manager')->isEnabled($field->getTargetEntityTypeId(), $field->getTargetBundle());
- $form['translatable'] = array(
+ $form['translatable'] = [
'#type' => 'checkbox',
'#title' => t('Users may translate this field'),
'#default_value' => $field->isTranslatable(),
'#weight' => -1,
'#disabled' => !$bundle_is_translatable,
'#access' => $field->getFieldStorageDefinition()->isTranslatable(),
- );
+ ];
// Provide helpful pointers for administrators.
if (\Drupal::currentUser()->hasPermission('administer content translation') && !$bundle_is_translatable) {
- $toggle_url = \Drupal::url('language.content_settings_page', array(), array(
+ $toggle_url = \Drupal::url('language.content_settings_page', [], [
'query' => \Drupal::destination()->getAsArray(),
- ));
- $form['translatable']['#description'] = t('To configure translation for this field, <a href=":language-settings-url">enable language support</a> for this type.', array(
+ ]);
+ $form['translatable']['#description'] = t('To configure translation for this field, <a href=":language-settings-url">enable language support</a> for this type.', [
':language-settings-url' => $toggle_url,
- ));
+ ]);
}
if ($field->isTranslatable()) {
@@ -454,7 +454,7 @@ function content_translation_enable_widget($entity_type, $bundle, array &$form,
$context = $form_state->get(['language', $key]) ?: [];
$context += ['entity_type' => $entity_type, 'bundle' => $bundle];
$form_state->set(['language', $key], $context);
- $element = content_translation_language_configuration_element_process(array('#name' => $key), $form_state, $form);
+ $element = content_translation_language_configuration_element_process(['#name' => $key], $form_state, $form);
unset($element['content_translation']['#element_validate']);
return $element;
}
@@ -474,14 +474,14 @@ function content_translation_language_configuration_element_process(array $eleme
$form_state->set(['content_translation', 'key'], $key);
$context = $form_state->get(['language', $key]);
- $element['content_translation'] = array(
+ $element['content_translation'] = [
'#type' => 'checkbox',
'#title' => t('Enable translation'),
// For new bundle, we don't know the bundle name yet,
// default to no translatability.
'#default_value' => $context['bundle'] ? \Drupal::service('content_translation.manager')->isEnabled($context['entity_type'], $context['bundle']) : FALSE,
- '#element_validate' => array('content_translation_language_configuration_element_validate'),
- );
+ '#element_validate' => ['content_translation_language_configuration_element_validate'],
+ ];
$submit_name = isset($form['actions']['save_continue']) ? 'save_continue' : 'submit';
// Only add the submit handler on the submit button if the #submit property
@@ -515,7 +515,7 @@ function content_translation_language_configuration_element_validate($element, F
// @todo Set the correct form element name as soon as the element parents
// are correctly set. We should be using NestedArray::getValue() but for
// now we cannot.
- $form_state->setErrorByName('', t('"Show language selector" is not compatible with translating content that has default language: %choice. Either do not hide the language selector or pick a specific language.', array('%choice' => $locked_languages[$values['langcode']])));
+ $form_state->setErrorByName('', t('"Show language selector" is not compatible with translating content that has default language: %choice. Either do not hide the language selector or pick a specific language.', ['%choice' => $locked_languages[$values['langcode']]]));
}
}
@@ -529,7 +529,7 @@ function content_translation_language_configuration_element_validate($element, F
function content_translation_language_configuration_element_submit(array $form, FormStateInterface $form_state) {
$key = $form_state->get(['content_translation', 'key']);
$context = $form_state->get(['language', $key]);
- $enabled = $form_state->getValue(array($key, 'content_translation'));
+ $enabled = $form_state->getValue([$key, 'content_translation']);
if (\Drupal::service('content_translation.manager')->isEnabled($context['entity_type'], $context['bundle']) != $enabled) {
\Drupal::service('content_translation.manager')->setEnabled($context['entity_type'], $context['bundle'], $enabled);
@@ -579,14 +579,14 @@ function content_translation_page_attachments(&$page) {
->setOption('language', $language)
->setAbsolute()
->toString();
- $page['#attached']['html_head_link'][] = array(
- array(
+ $page['#attached']['html_head_link'][] = [
+ [
'rel' => 'alternate',
'hreflang' => $language->getId(),
'href' => $url,
- ),
+ ],
TRUE,
- );
+ ];
}
}
// Since entity was found, no need to iterate further.
diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php
index c1550695511..9a6050d7942 100644
--- a/core/modules/content_translation/src/ContentTranslationHandler.php
+++ b/core/modules/content_translation/src/ContentTranslationHandler.php
@@ -110,7 +110,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
* {@inheritdoc}
*/
public function getFieldDefinitions() {
- $definitions = array();
+ $definitions = [];
$definitions['content_translation_source'] = BaseFieldDefinition::create('language')
->setLabel(t('Translation source'))
@@ -287,7 +287,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
$title = $this->entityFormTitle($entity);
// When editing the original values display just the entity label.
if ($is_translation) {
- $t_args = array('%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label(), '@title' => $title);
+ $t_args = ['%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label(), '@title' => $title];
$title = empty($source_langcode) ? t('@title [%language translation]', $t_args) : t('Create %language translation of %title', $t_args);
}
$form['#title'] = $title;
@@ -296,25 +296,25 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
// Display source language selector only if we are creating a new
// translation and there are at least two translations available.
if ($has_translations && $new_translation) {
- $form['source_langcode'] = array(
+ $form['source_langcode'] = [
'#type' => 'details',
- '#title' => t('Source language: @language', array('@language' => $languages[$source_langcode]->getName())),
+ '#title' => t('Source language: @language', ['@language' => $languages[$source_langcode]->getName()]),
'#tree' => TRUE,
'#weight' => -100,
'#multilingual' => TRUE,
- 'source' => array(
+ 'source' => [
'#title' => t('Select source language'),
'#title_display' => 'invisible',
'#type' => 'select',
'#default_value' => $source_langcode,
- '#options' => array(),
- ),
- 'submit' => array(
+ '#options' => [],
+ ],
+ 'submit' => [
'#type' => 'submit',
'#value' => t('Change'),
- '#submit' => array(array($this, 'entityFormSourceChange')),
- ),
- );
+ '#submit' => [[$this, 'entityFormSourceChange']],
+ ],
+ ];
foreach ($this->languageManager->getLanguages() as $language) {
if (isset($translations[$language->getId()])) {
$form['source_langcode']['source']['#options'][$language->getId()] = $language->getName();
@@ -335,7 +335,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
if (isset($language_widget['widget'][0]['value']) && !$is_translation && $has_translations) {
$language_select = &$language_widget['widget'][0]['value'];
if ($language_select['#type'] == 'language_select') {
- $options = array();
+ $options = [];
foreach ($this->languageManager->getLanguages() as $language) {
// Show the current language, and the languages for which no
// translation already exists.
@@ -354,20 +354,20 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
// Replace the delete button with the delete translation one.
if (!$new_translation) {
$weight = 100;
- foreach (array('delete', 'submit') as $key) {
+ foreach (['delete', 'submit'] as $key) {
if (isset($form['actions'][$key]['weight'])) {
$weight = $form['actions'][$key]['weight'];
break;
}
}
$access = $this->getTranslationAccess($entity, 'delete')->isAllowed() || ($entity->access('delete') && $this->entityType->hasLinkTemplate('delete-form'));
- $form['actions']['delete_translation'] = array(
+ $form['actions']['delete_translation'] = [
'#type' => 'submit',
'#value' => t('Delete translation'),
'#weight' => $weight,
- '#submit' => array(array($this, 'entityFormDeleteTranslation')),
+ '#submit' => [[$this, 'entityFormDeleteTranslation']],
'#access' => $access,
- );
+ ];
}
// Always remove the delete button on translation forms.
@@ -377,23 +377,23 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
// We need to display the translation tab only when there is at least one
// translation available or a new one is about to be created.
if ($new_translation || $has_translations) {
- $form['content_translation'] = array(
+ $form['content_translation'] = [
'#type' => 'details',
'#title' => t('Translation'),
'#tree' => TRUE,
'#weight' => 10,
'#access' => $this->getTranslationAccess($entity, $source_langcode ? 'create' : 'update')->isAllowed(),
'#multilingual' => TRUE,
- );
+ ];
if (isset($form['advanced'])) {
- $form['content_translation'] += array(
+ $form['content_translation'] += [
'#group' => 'advanced',
'#weight' => 100,
- '#attributes' => array(
- 'class' => array('entity-translation-options'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['entity-translation-options'],
+ ],
+ ];
}
// A new translation is enabled by default.
@@ -414,30 +414,30 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
t('An unpublished translation will not be visible without translation permissions.') :
t('Only this translation is published. You must publish at least one more translation to unpublish this one.');
- $form['content_translation']['status'] = array(
+ $form['content_translation']['status'] = [
'#type' => 'checkbox',
'#title' => t('This translation is published'),
'#default_value' => $status,
'#description' => $description,
'#disabled' => !$enabled,
- );
+ ];
$translate = !$new_translation && $metadata->isOutdated();
if (!$translate) {
- $form['content_translation']['retranslate'] = array(
+ $form['content_translation']['retranslate'] = [
'#type' => 'checkbox',
'#title' => t('Flag other translations as outdated'),
'#default_value' => FALSE,
'#description' => t('If you made a significant change, which means the other translations should be updated, you can flag all translations of this content as outdated. This will not change any other property of them, like whether they are published or not.'),
- );
+ ];
}
else {
- $form['content_translation']['outdated'] = array(
+ $form['content_translation']['outdated'] = [
'#type' => 'checkbox',
'#title' => t('This translation needs to be updated'),
'#default_value' => $translate,
'#description' => t('When this option is checked, this translation needs to be updated. Uncheck when the translation is up to date again.'),
- );
+ ];
$form['content_translation']['#open'] = TRUE;
}
@@ -449,7 +449,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
elseif (($account = $metadata->getAuthor()) && $account->id()) {
$uid = $account->id();
}
- $form['content_translation']['uid'] = array(
+ $form['content_translation']['uid'] = [
'#type' => 'entity_autocomplete',
'#title' => t('Authored by'),
'#target_type' => 'user',
@@ -457,34 +457,34 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
// Validation is done by static::entityFormValidate().
'#validate_reference' => FALSE,
'#maxlength' => 60,
- '#description' => t('Leave blank for %anonymous.', array('%anonymous' => \Drupal::config('user.settings')->get('anonymous'))),
- );
+ '#description' => t('Leave blank for %anonymous.', ['%anonymous' => \Drupal::config('user.settings')->get('anonymous')]),
+ ];
$date = $new_translation ? REQUEST_TIME : $metadata->getCreatedTime();
- $form['content_translation']['created'] = array(
+ $form['content_translation']['created'] = [
'#type' => 'textfield',
'#title' => t('Authored on'),
'#maxlength' => 25,
- '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array('%time' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date(REQUEST_TIME, 'custom', 'O'))),
+ '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', ['%time' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date(REQUEST_TIME, 'custom', 'O')]),
'#default_value' => $new_translation || !$date ? '' : format_date($date, 'custom', 'Y-m-d H:i:s O'),
- );
+ ];
if (isset($language_widget)) {
$language_widget['#multilingual'] = TRUE;
}
- $form['#process'][] = array($this, 'entityFormSharedElements');
+ $form['#process'][] = [$this, 'entityFormSharedElements'];
}
// Process the submitted values before they are stored.
- $form['#entity_builders'][] = array($this, 'entityFormEntityBuild');
+ $form['#entity_builders'][] = [$this, 'entityFormEntityBuild'];
// Handle entity validation.
- $form['#validate'][] = array($this, 'entityFormValidate');
+ $form['#validate'][] = [$this, 'entityFormValidate'];
// Handle entity deletion.
if (isset($form['actions']['delete'])) {
- $form['actions']['delete']['#submit'][] = array($this, 'entityFormDelete');
+ $form['actions']['delete']['#submit'][] = [$this, 'entityFormDelete'];
}
// Handle entity form submission before the entity has been saved.
@@ -506,7 +506,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
// @todo Find a more reliable way to determine if a form element concerns a
// multilingual value.
if (!isset($ignored_types)) {
- $ignored_types = array_flip(array('actions', 'value', 'hidden', 'vertical_tabs', 'token', 'details'));
+ $ignored_types = array_flip(['actions', 'value', 'hidden', 'vertical_tabs', 'token', 'details']);
}
foreach (Element::children($element) as $key) {
@@ -551,7 +551,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
// Elements which can have a #title attribute according to FAPI Reference.
if (!isset($suffix)) {
$suffix = ' <span class="translation-entity-all-languages">(' . t('all languages') . ')</span>';
- $fapi_title_elements = array_flip(array('checkbox', 'checkboxes', 'date', 'details', 'fieldset', 'file', 'item', 'password', 'password_confirm', 'radio', 'radios', 'select', 'text_format', 'textarea', 'textfield', 'weight'));
+ $fapi_title_elements = array_flip(['checkbox', 'checkboxes', 'date', 'details', 'fieldset', 'file', 'item', 'password', 'password_confirm', 'radio', 'radios', 'select', 'text_format', 'textarea', 'textfield', 'weight']);
}
// Update #title attribute for all elements that are allowed to have a
@@ -587,7 +587,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
$form_object = $form_state->getFormObject();
$form_langcode = $form_object->getFormLangcode($form_state);
- $values = &$form_state->getValue('content_translation', array());
+ $values = &$form_state->getValue('content_translation', []);
$metadata = $this->manager->getTranslationMetadata($entity);
$metadata->setAuthor(!empty($values['uid']) ? User::load($values['uid']) : User::load(0));
@@ -615,7 +615,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
$translation = $form_state->getValue('content_translation');
// Validate the "authored by" field.
if (!empty($translation['uid']) && !($account = User::load($translation['uid']))) {
- $form_state->setErrorByName('content_translation][uid', t('The translation authoring username %name does not exist.', array('%name' => $account->getUsername())));
+ $form_state->setErrorByName('content_translation][uid', t('The translation authoring username %name does not exist.', ['%name' => $account->getUsername()]));
}
// Validate the "authored on" field.
if (!empty($translation['created']) && strtotime($translation['created']) === FALSE) {
@@ -656,16 +656,16 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
public function entityFormSourceChange($form, FormStateInterface $form_state) {
$form_object = $form_state->getFormObject();
$entity = $form_object->getEntity();
- $source = $form_state->getValue(array('source_langcode', 'source'));
+ $source = $form_state->getValue(['source_langcode', 'source']);
$entity_type_id = $entity->getEntityTypeId();
- $form_state->setRedirect("entity.$entity_type_id.content_translation_add", array(
+ $form_state->setRedirect("entity.$entity_type_id.content_translation_add", [
$entity_type_id => $entity->id(),
'source' => $source,
'target' => $form_object->getFormLangcode($form_state),
- ));
+ ]);
$languages = $this->languageManager->getLanguages();
- drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->getName())));
+ drupal_set_message(t('Source language set to: %language', ['%language' => $languages[$source]->getName()]));
}
/**
@@ -677,7 +677,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
$form_object = $form_state->getFormObject()->getEntity();
$entity = $form_object->getEntity();
if (count($entity->getTranslationLanguages()) > 1) {
- drupal_set_message(t('This will delete all the translations of %label.', array('%label' => $entity->label())), 'warning');
+ drupal_set_message(t('This will delete all the translations of %label.', ['%label' => $entity->label()]), 'warning');
}
}
diff --git a/core/modules/content_translation/src/ContentTranslationManager.php b/core/modules/content_translation/src/ContentTranslationManager.php
index a1c2391e437..70adc289bf2 100644
--- a/core/modules/content_translation/src/ContentTranslationManager.php
+++ b/core/modules/content_translation/src/ContentTranslationManager.php
@@ -66,7 +66,7 @@ class ContentTranslationManager implements ContentTranslationManagerInterface {
* {@inheritdoc}
*/
public function getSupportedEntityTypes() {
- $supported_types = array();
+ $supported_types = [];
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
if ($this->isSupported($entity_type_id)) {
$supported_types[$entity_type_id] = $entity_type;
@@ -82,7 +82,7 @@ class ContentTranslationManager implements ContentTranslationManagerInterface {
$config = $this->loadContentLanguageSettings($entity_type_id, $bundle);
$config->setThirdPartySetting('content_translation', 'enabled', $value)->save();
$entity_type = $this->entityManager->getDefinition($entity_type_id);
- $this->updatesManager->updateDefinitions(array($entity_type_id => $entity_type));
+ $this->updatesManager->updateDefinitions([$entity_type_id => $entity_type]);
}
/**
@@ -92,7 +92,7 @@ class ContentTranslationManager implements ContentTranslationManagerInterface {
$enabled = FALSE;
if ($this->isSupported($entity_type_id)) {
- $bundles = !empty($bundle) ? array($bundle) : array_keys($this->entityManager->getBundleInfo($entity_type_id));
+ $bundles = !empty($bundle) ? [$bundle] : array_keys($this->entityManager->getBundleInfo($entity_type_id));
foreach ($bundles as $bundle) {
$config = $this->loadContentLanguageSettings($entity_type_id, $bundle);
if ($config->getThirdPartySetting('content_translation', 'enabled', FALSE)) {
diff --git a/core/modules/content_translation/src/Controller/ContentTranslationController.php b/core/modules/content_translation/src/Controller/ContentTranslationController.php
index 43b59aaf1e1..c97f185a63f 100644
--- a/core/modules/content_translation/src/Controller/ContentTranslationController.php
+++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php
@@ -97,7 +97,7 @@ class ContentTranslationController extends ControllerBase {
$translations = $entity->getTranslationLanguages();
$field_ui = $this->moduleHandler()->moduleExists('field_ui') && $account->hasPermission('administer ' . $entity_type_id . ' fields');
- $rows = array();
+ $rows = [];
$show_source_column = FALSE;
if ($this->languageManager()->isMultilingual()) {
@@ -123,41 +123,41 @@ class ContentTranslationController extends ControllerBase {
$add_url = new Url(
"entity.$entity_type_id.content_translation_add",
- array(
+ [
'source' => $original,
'target' => $language->getId(),
$entity_type_id => $entity->id(),
- ),
- array(
+ ],
+ [
'language' => $language,
- )
+ ]
);
$edit_url = new Url(
"entity.$entity_type_id.content_translation_edit",
- array(
+ [
'language' => $language->getId(),
$entity_type_id => $entity->id(),
- ),
- array(
+ ],
+ [
'language' => $language,
- )
+ ]
);
$delete_url = new Url(
"entity.$entity_type_id.content_translation_delete",
- array(
+ [
'language' => $language->getId(),
$entity_type_id => $entity->id(),
- ),
- array(
+ ],
+ [
'language' => $language,
- )
+ ]
);
- $operations = array(
- 'data' => array(
+ $operations = [
+ 'data' => [
'#type' => 'operations',
- '#links' => array(),
- ),
- );
+ '#links' => [],
+ ],
+ ];
$links = &$operations['data']['#links'];
if (array_key_exists($langcode, $translations)) {
@@ -167,7 +167,7 @@ class ContentTranslationController extends ControllerBase {
$source = $metadata->getSource() ?: LanguageInterface::LANGCODE_NOT_SPECIFIED;
$is_original = $langcode == $original;
$label = $entity->getTranslation($langcode)->label();
- $link = isset($links->links[$langcode]['url']) ? $links->links[$langcode] : array('url' => $entity->urlInfo());
+ $link = isset($links->links[$langcode]['url']) ? $links->links[$langcode] : ['url' => $entity->urlInfo()];
if (!empty($link['url'])) {
$link['url']->setOption('language', $language);
$row_title = $this->l($label, $link['url']);
@@ -196,17 +196,17 @@ class ContentTranslationController extends ControllerBase {
if (isset($links['edit'])) {
$links['edit']['title'] = $this->t('Edit');
}
- $status = array('data' => array(
+ $status = ['data' => [
'#type' => 'inline_template',
'#template' => '<span class="status">{% if status %}{{ "Published"|t }}{% else %}{{ "Not published"|t }}{% endif %}</span>{% if outdated %} <span class="marker">{{ "outdated"|t }}</span>{% endif %}',
- '#context' => array(
+ '#context' => [
'status' => $metadata->isPublished(),
'outdated' => $metadata->isOutdated(),
- ),
- ));
+ ],
+ ]];
if ($is_original) {
- $language_name = $this->t('<strong>@language_name (Original language)</strong>', array('@language_name' => $language_name));
+ $language_name = $this->t('<strong>@language_name (Original language)</strong>', ['@language_name' => $language_name]);
$source_name = $this->t('n/a');
}
else {
@@ -217,17 +217,17 @@ class ContentTranslationController extends ControllerBase {
->merge(CacheableMetadata::createFromObject($delete_access))
->merge(CacheableMetadata::createFromObject($translation_access));
if ($entity->access('delete') && $entity_type->hasLinkTemplate('delete-form')) {
- $links['delete'] = array(
+ $links['delete'] = [
'title' => $this->t('Delete'),
'url' => $entity->urlInfo('delete-form'),
'language' => $language,
- );
+ ];
}
elseif ($translation_access->isAllowed()) {
- $links['delete'] = array(
+ $links['delete'] = [
'title' => $this->t('Delete'),
'url' => $delete_url,
- );
+ ];
}
}
}
@@ -241,58 +241,58 @@ class ContentTranslationController extends ControllerBase {
->merge(CacheableMetadata::createFromObject($create_translation_access));
if ($source != $langcode && $create_translation_access->isAllowed()) {
if ($translatable) {
- $links['add'] = array(
+ $links['add'] = [
'title' => $this->t('Add'),
'url' => $add_url,
- );
+ ];
}
elseif ($field_ui) {
$url = new Url('language.content_settings_page');
// Link directly to the fields tab to make it easier to find the
// setting to enable translation on fields.
- $links['nofields'] = array(
+ $links['nofields'] = [
'title' => $this->t('No translatable fields'),
'url' => $url,
- );
+ ];
}
}
$status = $this->t('Not translated');
}
if ($show_source_column) {
- $rows[] = array(
+ $rows[] = [
$language_name,
$row_title,
$source_name,
$status,
$operations,
- );
+ ];
}
else {
- $rows[] = array($language_name, $row_title, $status, $operations);
+ $rows[] = [$language_name, $row_title, $status, $operations];
}
}
}
if ($show_source_column) {
- $header = array(
+ $header = [
$this->t('Language'),
$this->t('Translation'),
$this->t('Source language'),
$this->t('Status'),
$this->t('Operations'),
- );
+ ];
}
else {
- $header = array(
+ $header = [
$this->t('Language'),
$this->t('Translation'),
$this->t('Status'),
$this->t('Operations'),
- );
+ ];
}
- $build['#title'] = $this->t('Translations of %label', array('%label' => $entity->label()));
+ $build['#title'] = $this->t('Translations of %label', ['%label' => $entity->label()]);
// Add metadata to the build render array to let other modules know about
// which entity this is.
@@ -301,11 +301,11 @@ class ContentTranslationController extends ControllerBase {
->addCacheTags($entity->getCacheTags())
->applyTo($build);
- $build['content_translation_overview'] = array(
+ $build['content_translation_overview'] = [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
- );
+ ];
return $build;
}
@@ -339,7 +339,7 @@ class ContentTranslationController extends ControllerBase {
// See https://www.drupal.org/node/2006348.
$operation = 'default';
- $form_state_additions = array();
+ $form_state_additions = [];
$form_state_additions['langcode'] = $target->getId();
$form_state_additions['content_translation']['source'] = $source;
$form_state_additions['content_translation']['target'] = $target;
@@ -370,7 +370,7 @@ class ContentTranslationController extends ControllerBase {
// See https://www.drupal.org/node/2006348.
$operation = 'default';
- $form_state_additions = array();
+ $form_state_additions = [];
$form_state_additions['langcode'] = $language->getId();
$form_state_additions['content_translation']['translation_form'] = TRUE;
diff --git a/core/modules/content_translation/src/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php
index 8f7584d8b62..13b805df8ac 100644
--- a/core/modules/content_translation/src/FieldTranslationSynchronizer.php
+++ b/core/modules/content_translation/src/FieldTranslationSynchronizer.php
@@ -73,14 +73,14 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
}
}
if (!empty($groups)) {
- $columns = array();
+ $columns = [];
foreach ($groups as $group) {
$info = $column_groups[$group];
// A missing 'columns' key indicates we have a single-column group.
- $columns = array_merge($columns, isset($info['columns']) ? $info['columns'] : array($group));
+ $columns = array_merge($columns, isset($info['columns']) ? $info['columns'] : [$group]);
}
if (!empty($columns)) {
- $values = array();
+ $values = [];
foreach ($translations as $langcode => $language) {
$values[$langcode] = $entity->getTranslation($langcode)->get($field_name)->getValue();
}
@@ -108,18 +108,18 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
$source_items = $values[$sync_langcode];
// Make sure we can detect any change in the source items.
- $change_map = array();
+ $change_map = [];
// By picking the maximum size between updated and unchanged items, we make
// sure to process also removed items.
- $total = max(array(count($source_items), count($unchanged_items)));
+ $total = max([count($source_items), count($unchanged_items)]);
// As a first step we build a map of the deltas corresponding to the column
// values to be synchronized. Recording both the old values and the new
// values will allow us to detect any change in the order of the new items
// for each column.
for ($delta = 0; $delta < $total; $delta++) {
- foreach (array('old' => $unchanged_items, 'new' => $source_items) as $key => $items) {
+ foreach (['old' => $unchanged_items, 'new' => $source_items] as $key => $items) {
if ($item_id = $this->itemHash($items, $delta, $columns)) {
$change_map[$item_id][$key][] = $delta;
}
@@ -132,7 +132,7 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
// Reset field values so that no spurious one is stored. Source values must
// be preserved in any case.
- $values = array($sync_langcode => $source_items);
+ $values = [$sync_langcode => $source_items];
// Update field translations.
foreach ($translations as $langcode) {
@@ -211,7 +211,7 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
* A hash code that can be used to identify the item.
*/
protected function itemHash(array $items, $delta, array $columns) {
- $values = array();
+ $values = [];
if (isset($items[$delta])) {
foreach ($columns as $column) {
diff --git a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php
index 84e12637048..e364de91f64 100644
--- a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php
+++ b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationLocalTasks.php
@@ -66,12 +66,12 @@ class ContentTranslationLocalTasks extends DeriverBase implements ContainerDeriv
$translation_route_name = "entity.$entity_type_id.content_translation_overview";
$base_route_name = "entity.$entity_type_id.canonical";
- $this->derivatives[$translation_route_name] = array(
+ $this->derivatives[$translation_route_name] = [
'entity_type' => $entity_type_id,
'title' => $this->t('Translate'),
'route_name' => $translation_route_name,
'base_route' => $base_route_name,
- ) + $base_plugin_definition;
+ ] + $base_plugin_definition;
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
diff --git a/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php
index fb4b76117d9..6aae426abe3 100644
--- a/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php
+++ b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php
@@ -58,104 +58,104 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
$route = new Route(
$path,
- array(
+ [
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::overview',
'entity_type_id' => $entity_type_id,
- ),
- array(
+ ],
+ [
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_overview' => $entity_type_id,
- ),
- array(
- 'parameters' => array(
- $entity_type_id => array(
+ ],
+ [
+ 'parameters' => [
+ $entity_type_id => [
'type' => 'entity:' . $entity_type_id,
- ),
- ),
+ ],
+ ],
'_admin_route' => $is_admin,
- )
+ ]
);
$route_name = "entity.$entity_type_id.content_translation_overview";
$collection->add($route_name, $route);
$route = new Route(
$path . '/add/{source}/{target}',
- array(
+ [
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::add',
'source' => NULL,
'target' => NULL,
'_title' => 'Add',
'entity_type_id' => $entity_type_id,
- ),
- array(
+ ],
+ [
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_manage' => 'create',
- ),
- array(
- 'parameters' => array(
- 'source' => array(
+ ],
+ [
+ 'parameters' => [
+ 'source' => [
'type' => 'language',
- ),
- 'target' => array(
+ ],
+ 'target' => [
'type' => 'language',
- ),
- $entity_type_id => array(
+ ],
+ $entity_type_id => [
'type' => 'entity:' . $entity_type_id,
- ),
- ),
+ ],
+ ],
'_admin_route' => $is_admin,
- )
+ ]
);
$collection->add("entity.$entity_type_id.content_translation_add", $route);
$route = new Route(
$path . '/edit/{language}',
- array(
+ [
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::edit',
'language' => NULL,
'_title' => 'Edit',
'entity_type_id' => $entity_type_id,
- ),
- array(
+ ],
+ [
'_access_content_translation_manage' => 'update',
- ),
- array(
- 'parameters' => array(
- 'language' => array(
+ ],
+ [
+ 'parameters' => [
+ 'language' => [
'type' => 'language',
- ),
- $entity_type_id => array(
+ ],
+ $entity_type_id => [
'type' => 'entity:' . $entity_type_id,
- ),
- ),
+ ],
+ ],
'_admin_route' => $is_admin,
- )
+ ]
);
$collection->add("entity.$entity_type_id.content_translation_edit", $route);
$route = new Route(
$path . '/delete/{language}',
- array(
+ [
'_entity_form' => $entity_type_id . '.content_translation_deletion',
'language' => NULL,
'_title' => 'Delete',
'entity_type_id' => $entity_type_id,
- ),
- array(
+ ],
+ [
'_access_content_translation_manage' => 'delete',
- ),
- array(
- 'parameters' => array(
- 'language' => array(
+ ],
+ [
+ 'parameters' => [
+ 'language' => [
'type' => 'language',
- ),
- $entity_type_id => array(
+ ],
+ $entity_type_id => [
'type' => 'entity:' . $entity_type_id,
- ),
- ),
+ ],
+ ],
'_admin_route' => $is_admin,
- )
+ ]
);
$collection->add("entity.$entity_type_id.content_translation_delete", $route);
}
@@ -168,7 +168,7 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
$events = parent::getSubscribedEvents();
// Should run after AdminRouteSubscriber so the routes can inherit admin
// status of the edit routes on entities. Therefore priority -210.
- $events[RoutingEvents::ALTER] = array('onAlterRoutes', -210);
+ $events[RoutingEvents::ALTER] = ['onAlterRoutes', -210];
return $events;
}
diff --git a/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php b/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php
index e94802aa1cd..1688f75fd6b 100644
--- a/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php
+++ b/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php
@@ -19,7 +19,7 @@ class ContentTestTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'entity_test');
+ public static $modules = ['language', 'content_translation', 'entity_test'];
/**
* {@inheritdoc}
@@ -34,7 +34,7 @@ class ContentTestTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('administer entity_test content', 'view test entity'));
+ return array_merge(parent::getTranslatorPermissions(), ['administer entity_test content', 'view test entity']);
}
}
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php
index efbd3c11fd4..080ffb95493 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php
@@ -48,7 +48,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('content_translation', 'contextual', 'node');
+ public static $modules = ['content_translation', 'contextual', 'node'];
/**
* The profile to install as a basis for testing.
@@ -60,20 +60,20 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
protected function setUp() {
parent::setUp();
// Set up an additional language.
- $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'es');
+ $this->langcodes = [\Drupal::languageManager()->getDefaultLanguage()->getId(), 'es'];
ConfigurableLanguage::createFromLangcode('es')->save();
// Create a content type.
$this->bundle = $this->randomMachineName();
- $this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
+ $this->contentType = $this->drupalCreateContentType(['type' => $this->bundle]);
// Add a field to the content type. The field is not yet translatable.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_test_text',
'entity_type' => 'node',
'type' => 'text',
'cardinality' => 1,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'node',
'field_name' => 'field_test_text',
@@ -81,19 +81,19 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
'label' => 'Test text-field',
])->save();
entity_get_form_display('node', $this->bundle, 'default')
- ->setComponent('field_test_text', array(
+ ->setComponent('field_test_text', [
'type' => 'text_textfield',
'weight' => 0,
- ))
+ ])
->save();
// Create a translator user.
- $permissions = array(
+ $permissions = [
'access contextual links',
'administer nodes',
"edit any $this->bundle content",
'translate any entity',
- );
+ ];
$this->translator = $this->drupalCreateUser($permissions);
}
@@ -103,18 +103,18 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
public function testContentTranslationContextualLinks() {
// Create a node.
$title = $this->randomString();
- $this->drupalCreateNode(array('type' => $this->bundle, 'title' => $title, 'langcode' => 'en'));
+ $this->drupalCreateNode(['type' => $this->bundle, 'title' => $title, 'langcode' => 'en']);
$node = $this->drupalGetNodeByTitle($title);
// Use a UI form submission to make the node type and field translatable.
// This tests that caches are properly invalidated.
$this->drupalLogin($this->rootUser);
- $edit = array(
+ $edit = [
'entity_types[node]' => TRUE,
'settings[node][' . $this->bundle . '][settings][language][language_alterable]' => TRUE,
'settings[node][' . $this->bundle . '][translatable]' => TRUE,
'settings[node][' . $this->bundle . '][fields][field_test_text]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$this->drupalLogout();
@@ -122,7 +122,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
$this->drupalLogin($this->translator);
$translate_link = 'node/' . $node->id() . '/translations';
- $response = $this->renderContextualLinks(array('node:node=1:'), 'node/' . $node->id());
+ $response = $this->renderContextualLinks(['node:node=1:'], 'node/' . $node->id());
$this->assertResponse(200);
$json = Json::decode($response);
$this->setRawContent($json['node:node=1:']);
@@ -130,7 +130,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
// Check that the link leads to the translate page.
$this->drupalGet($translate_link);
- $this->assertRaw(t('Translations of %label', array('%label' => $node->label())), 'The contextual link leads to the translate page.');
+ $this->assertRaw(t('Translations of %label', ['%label' => $node->label()]), 'The contextual link leads to the translate page.');
}
/**
@@ -148,7 +148,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
*/
protected function renderContextualLinks($ids, $current_path) {
// Build POST values.
- $post = array();
+ $post = [];
for ($i = 0; $i < count($ids); $i++) {
$post['ids[' . $i . ']'] = $ids[$i];
}
@@ -163,15 +163,15 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
$post = implode('&', $post);
// Perform HTTP request.
- return $this->curlExec(array(
- CURLOPT_URL => \Drupal::url('contextual.render', array(), array('absolute' => TRUE, 'query' => array('destination' => $current_path))),
+ return $this->curlExec([
+ CURLOPT_URL => \Drupal::url('contextual.render', [], ['absolute' => TRUE, 'query' => ['destination' => $current_path]]),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $post,
- CURLOPT_HTTPHEADER => array(
+ CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
- ),
- ));
+ ],
+ ]);
}
}
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php b/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php
index ded8c1bee4e..11c816c1d72 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php
@@ -58,11 +58,11 @@ class ContentTranslationEnableTest extends WebTestBase {
// Create a node type and check the content translation settings are now
// available for nodes.
- $edit = array(
+ $edit = [
'name' => 'foo',
'title_label' => 'title for foo',
'type' => 'foo',
- );
+ ];
$this->drupalPostForm('admin/structure/types/add', $edit, t('Save content type'));
$this->drupalGet('admin/config/regional/content-language');
$this->assertRaw('entity_types[node]');
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationLanguageChangeTest.php b/core/modules/content_translation/src/Tests/ContentTranslationLanguageChangeTest.php
index fea0e140eec..bb9b2235ebd 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationLanguageChangeTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationLanguageChangeTest.php
@@ -29,7 +29,7 @@ class ContentTranslationLanguageChangeTest extends NodeTestBase {
ConfigurableLanguage::createFromLangcode($langcode)->save();
}
$this->drupalPlaceBlock('local_tasks_block');
- $user = $this->drupalCreateUser(array(
+ $user = $this->drupalCreateUser([
'administer site configuration',
'administer nodes',
'create article content',
@@ -41,7 +41,7 @@ class ContentTranslationLanguageChangeTest extends NodeTestBase {
'administer languages',
'administer content types',
'administer node fields',
- ));
+ ]);
$this->drupalLogin($user);
// Enable translation for article.
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
index d7490c0471a..aed653b9036 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php
@@ -24,19 +24,19 @@ class ContentTranslationSettingsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'node', 'comment', 'field_ui', 'entity_test');
+ public static $modules = ['language', 'content_translation', 'node', 'comment', 'field_ui', 'entity_test'];
protected function setUp() {
parent::setUp();
// Set up two content types to test fields shared between different
// bundles.
- $this->drupalCreateContentType(array('type' => 'article'));
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'article']);
+ $this->drupalCreateContentType(['type' => 'page']);
$this->addDefaultCommentField('node', 'article', 'comment_article', CommentItemInterface::OPEN, 'comment_article');
$this->addDefaultCommentField('node', 'page', 'comment_page');
- $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer languages', 'administer content translation', 'administer content types', 'administer node fields', 'administer comment fields', 'administer comments', 'administer comment types', 'administer account settings'));
+ $admin_user = $this->drupalCreateUser(['access administration pages', 'administer languages', 'administer content translation', 'administer content types', 'administer node fields', 'administer comment fields', 'administer comments', 'administer comment types', 'administer account settings']);
$this->drupalLogin($admin_user);
}
@@ -50,17 +50,17 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->assertText('Configure language and translation support for content.');
// Test that the translation settings are ignored if the bundle is marked
// translatable but the entity type is not.
- $edit = array('settings[comment][comment_article][translatable]' => TRUE);
+ $edit = ['settings[comment][comment_article][translatable]' => TRUE];
$this->assertSettings('comment', NULL, FALSE, $edit);
// Test that the translation settings are ignored if only a field is marked
// as translatable and not the related entity type and bundle.
- $edit = array('settings[comment][comment_article][fields][comment_body]' => TRUE);
+ $edit = ['settings[comment][comment_article][fields][comment_body]' => TRUE];
$this->assertSettings('comment', NULL, FALSE, $edit);
// Test that the translation settings are not stored if an entity type and
// bundle are marked as translatable but no field is.
- $edit = array(
+ $edit = [
'entity_types[comment]' => TRUE,
'settings[comment][comment_article][translatable]' => TRUE,
// Base fields are translatable by default.
@@ -73,26 +73,26 @@ class ContentTranslationSettingsTest extends WebTestBase {
'settings[comment][comment_article][fields][status]' => FALSE,
'settings[comment][comment_article][fields][subject]' => FALSE,
'settings[comment][comment_article][fields][uid]' => FALSE,
- );
+ ];
$this->assertSettings('comment', 'comment_article', FALSE, $edit);
$xpath_err = '//div[contains(@class, "error")]';
$this->assertTrue($this->xpath($xpath_err), 'Enabling translation only for entity bundles generates a form error.');
// Test that the translation settings are not stored if a non-configurable
// language is set as default and the language selector is hidden.
- $edit = array(
+ $edit = [
'entity_types[comment]' => TRUE,
'settings[comment][comment_article][settings][language][langcode]' => Language::LANGCODE_NOT_SPECIFIED,
'settings[comment][comment_article][settings][language][language_alterable]' => FALSE,
'settings[comment][comment_article][translatable]' => TRUE,
'settings[comment][comment_article][fields][comment_body]' => TRUE,
- );
+ ];
$this->assertSettings('comment', 'comment_article', FALSE, $edit);
$this->assertTrue($this->xpath($xpath_err), 'Enabling translation with a fixed non-configurable language generates a form error.');
// Test that a field shared among different bundles can be enabled without
// needing to make all the related bundles translatable.
- $edit = array(
+ $edit = [
'entity_types[comment]' => TRUE,
'settings[comment][comment_article][settings][language][langcode]' => 'current_interface',
'settings[comment][comment_article][settings][language][language_alterable]' => TRUE,
@@ -101,7 +101,7 @@ class ContentTranslationSettingsTest extends WebTestBase {
// Override both comment subject fields to untranslatable.
'settings[comment][comment_article][fields][subject]' => FALSE,
'settings[comment][comment][fields][subject]' => FALSE,
- );
+ ];
$this->assertSettings('comment', 'comment_article', TRUE, $edit);
$definition = $this->entityManager()->getFieldDefinitions('comment', 'comment_article')['comment_body'];
$this->assertTrue($definition->isTranslatable(), 'Article comment body is translatable.');
@@ -114,12 +114,12 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->assertFalse($definition->isTranslatable(), 'Page comment subject is not translatable.');
// Test that translation can be enabled for base fields.
- $edit = array(
+ $edit = [
'entity_types[entity_test_mul]' => TRUE,
'settings[entity_test_mul][entity_test_mul][translatable]' => TRUE,
'settings[entity_test_mul][entity_test_mul][fields][name]' => TRUE,
'settings[entity_test_mul][entity_test_mul][fields][user_id]' => FALSE,
- );
+ ];
$this->assertSettings('entity_test_mul', 'entity_test_mul', TRUE, $edit);
$field_override = BaseFieldOverride::loadByName('entity_test_mul', 'entity_test_mul', 'name');
$this->assertTrue($field_override->isTranslatable(), 'Base fields can be overridden with a base field bundle override entity.');
@@ -137,9 +137,9 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->assertFieldChecked('edit-language-configuration-content-translation');
// Verify that translation may be enabled for the article content type.
- $edit = array(
+ $edit = [
'language_configuration[content_translation]' => TRUE,
- );
+ ];
// Make sure the checkbox is available and not checked by default.
$this->drupalGet('admin/structure/types/manage/article');
$this->assertField('language_configuration[content_translation]');
@@ -149,18 +149,18 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->assertFieldChecked('edit-language-configuration-content-translation');
// Test that the title field of nodes is available in the settings form.
- $edit = array(
+ $edit = [
'entity_types[node]' => TRUE,
'settings[node][article][settings][language][langcode]' => 'current_interface',
'settings[node][article][settings][language][language_alterable]' => TRUE,
'settings[node][article][translatable]' => TRUE,
'settings[node][article][fields][title]' => TRUE
- );
+ ];
$this->assertSettings('node', NULL, TRUE, $edit);
- foreach (array(TRUE, FALSE) as $translatable) {
+ foreach ([TRUE, FALSE] as $translatable) {
// Test that configurable field translatability is correctly switched.
- $edit = array('settings[node][article][fields][body]' => $translatable);
+ $edit = ['settings[node][article][fields][body]' => $translatable];
$this->assertSettings('node', 'article', TRUE, $edit);
$field = FieldConfig::loadByName('node', 'article', 'body');
$definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article');
@@ -169,7 +169,7 @@ class ContentTranslationSettingsTest extends WebTestBase {
// Test that also the Field UI form behaves correctly.
$translatable = !$translatable;
- $edit = array('translatable' => $translatable);
+ $edit = ['translatable' => $translatable];
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body', $edit, t('Save settings'));
\Drupal::entityManager()->clearCachedFieldDefinitions();
$field = FieldConfig::loadByName('node', 'article', 'body');
@@ -182,14 +182,14 @@ class ContentTranslationSettingsTest extends WebTestBase {
// lists, such as in Views UI.
$this->drupalGet('admin/config/regional/content-language');
- $expected_elements = array(
+ $expected_elements = [
'site_default',
'current_interface',
'authors_default',
'en',
'und',
'zxx',
- );
+ ];
$elements = $this->xpath('//select[@id="edit-settings-node-article-settings-language-langcode"]/option');
// Compare values inside the option elements with expected values.
for ($i = 0; $i < count($elements); $i++) {
@@ -206,15 +206,15 @@ class ContentTranslationSettingsTest extends WebTestBase {
$this->assertField('language[content_translation]');
$this->assertNoFieldChecked('edit-language-content-translation');
- $edit = array(
+ $edit = [
'language[content_translation]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration'));
$this->drupalGet('admin/config/people/accounts');
$this->assertFieldChecked('edit-language-content-translation');
// Make sure account settings can be saved.
- $this->drupalPostForm('admin/config/people/accounts', array('anonymous' => 'Save me please!'), 'Save configuration');
+ $this->drupalPostForm('admin/config/people/accounts', ['anonymous' => 'Save me please!'], 'Save configuration');
$this->assertFieldByName('anonymous', 'Save me please!', 'Anonymous name has been changed.');
$this->assertText('The configuration options have been saved.');
}
@@ -236,7 +236,7 @@ class ContentTranslationSettingsTest extends WebTestBase {
*/
protected function assertSettings($entity_type, $bundle, $enabled, $edit) {
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
- $args = array('@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled');
+ $args = ['@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled'];
$message = format_string('Translation for entity @entity_type (@bundle) is @enabled.', $args);
\Drupal::entityManager()->clearCachedDefinitions();
return $this->assertEqual(\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle), $enabled, $message);
@@ -249,11 +249,11 @@ class ContentTranslationSettingsTest extends WebTestBase {
// At least one field needs to be translatable to enable article for
// translation. Create an extra field to be used for this purpose. We use
// the UI to test our form alterations.
- $edit = array(
+ $edit = [
'new_storage_type' => 'text',
'label' => 'Test',
'field_name' => 'article_text',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article/fields/add-field', $edit, 'Save and continue');
// Tests that field doesn't have translatable setting if bundle is not
@@ -265,12 +265,12 @@ class ContentTranslationSettingsTest extends WebTestBase {
// Tests that field has translatable setting if bundle is translatable.
// Note: this field is not translatable when enable bundle translatability.
- $edit = array(
+ $edit = [
'entity_types[node]' => TRUE,
'settings[node][article][settings][language][language_alterable]' => TRUE,
'settings[node][article][translatable]' => TRUE,
'settings[node][article][fields][field_article_text]' => TRUE,
- );
+ ];
$this->assertSettings('node', 'article', TRUE, $edit);
$this->drupalGet($path);
$this->assertFieldByXPath('//input[@id="edit-translatable" and not(@disabled) and @checked="checked"]');
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
index 5f881a71054..10b3c5e0b63 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
@@ -33,7 +33,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'entity_test', 'image', 'field_ui');
+ public static $modules = ['language', 'content_translation', 'entity_test', 'image', 'field_ui'];
protected function setUp() {
parent::setUp();
@@ -47,27 +47,27 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
$this->fieldName = 'field_test_et_ui_image';
$this->cardinality = 3;
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $this->entityTypeId,
'type' => 'image',
'cardinality' => $this->cardinality,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->entityTypeId,
'label' => 'Test translatable image field',
- 'third_party_settings' => array(
- 'content_translation' => array(
- 'translation_sync' => array(
+ 'third_party_settings' => [
+ 'content_translation' => [
+ 'translation_sync' => [
'file' => FALSE,
'alt' => 'alt',
'title' => 'title',
- ),
- ),
- ),
+ ],
+ ],
+ ],
])->save();
}
@@ -76,7 +76,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
*/
protected function getEditorPermissions() {
// Every entity-type-specific test needs to define these.
- return array('administer entity_test_mul fields', 'administer languages', 'administer content translation');
+ return ['administer entity_test_mul fields', 'administer languages', 'administer content translation'];
}
/**
@@ -88,10 +88,10 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
$this->drupalGet('entity_test_mul/structure/' . $this->entityTypeId . '/fields/' . $this->entityTypeId . '.' . $this->entityTypeId . '.' . $this->fieldName);
$this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt');
$this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-title');
- $edit = array(
+ $edit = [
'third_party_settings[content_translation][translation_sync][alt]' => FALSE,
'third_party_settings[content_translation][translation_sync][title]' => FALSE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
// Check that the content translation settings page reflects the changes
@@ -99,11 +99,11 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
$this->drupalGet('admin/config/regional/content-language');
$this->assertNoFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt');
$this->assertNoFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title');
- $edit = array(
+ $edit = [
'settings[entity_test_mul][entity_test_mul][fields][field_test_et_ui_image]' => TRUE,
'settings[entity_test_mul][entity_test_mul][columns][field_test_et_ui_image][alt]' => TRUE,
'settings[entity_test_mul][entity_test_mul][columns][field_test_et_ui_image][title]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$errors = $this->xpath('//div[contains(@class, "messages--error")]');
$this->assertFalse($errors, 'Settings correctly stored.');
@@ -115,26 +115,26 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
$langcode = $this->langcodes[1];
// Populate the test entity with some random initial values.
- $values = array(
+ $values = [
'name' => $this->randomMachineName(),
'user_id' => mt_rand(1, 128),
'langcode' => $default_langcode,
- );
+ ];
$entity = entity_create($this->entityTypeId, $values);
// Create some file entities from the generated test files and store them.
- $values = array();
+ $values = [];
for ($delta = 0; $delta < $this->cardinality; $delta++) {
// For the default language use the same order for files and field items.
$index = $delta;
// Create the file entity for the image being processed and record its
// identifier.
- $field_values = array(
+ $field_values = [
'uri' => $this->files[$index]->uri,
'uid' => \Drupal::currentUser()->id(),
'status' => FILE_STATUS_PERMANENT,
- );
+ ];
$file = File::create($field_values);
$file->save();
$fid = $file->id();
@@ -142,11 +142,11 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
// Generate the item for the current image file entity and attach it to
// the entity.
- $item = array(
+ $item = [
'target_id' => $fid,
'alt' => $default_langcode . '_' . $fid . '_' . $this->randomMachineName(),
'title' => $default_langcode . '_' . $fid . '_' . $this->randomMachineName(),
- );
+ ];
$entity->{$this->fieldName}[] = $item;
// Store the generated values keying them by fid for easier lookup.
@@ -168,11 +168,11 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
// Generate the item for the current image file entity and attach it to
// the entity.
$fid = $this->files[$index]->fid;
- $item = array(
+ $item = [
'target_id' => $fid,
'alt' => $langcode . '_' . $fid . '_' . $this->randomMachineName(),
'title' => $langcode . '_' . $fid . '_' . $this->randomMachineName(),
- );
+ ];
$translation->{$this->fieldName}[] = $item;
// Again store the generated values keying them by fid for easier lookup.
@@ -191,25 +191,25 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
// Check that fids have been synchronized and translatable column values
// have been retained.
- $fids = array();
+ $fids = [];
foreach ($entity->{$this->fieldName} as $delta => $item) {
$value = $values[$default_langcode][$item->target_id];
$source_item = $translation->{$this->fieldName}->get($delta);
$assert = $item->target_id == $source_item->target_id && $item->alt == $value['alt'] && $item->title == $value['title'];
- $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id)));
+ $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', ['@fid' => $item->target_id]));
$fids[$item->target_id] = TRUE;
}
// Check that the dropped value is the right one.
$removed_fid = $this->files[0]->fid;
- $this->assertTrue(!isset($fids[$removed_fid]), format_string('Field item @fid has been correctly removed.', array('@fid' => $removed_fid)));
+ $this->assertTrue(!isset($fids[$removed_fid]), format_string('Field item @fid has been correctly removed.', ['@fid' => $removed_fid]));
// Add back an item for the dropped value and perform synchronization again.
- $values[$langcode][$removed_fid] = array(
+ $values[$langcode][$removed_fid] = [
'target_id' => $removed_fid,
'alt' => $langcode . '_' . $removed_fid . '_' . $this->randomMachineName(),
'title' => $langcode . '_' . $removed_fid . '_' . $this->randomMachineName(),
- );
+ ];
$translation->{$this->fieldName}->setValue(array_values($values[$langcode]));
$entity = $this->saveEntity($translation);
$translation = $entity->getTranslation($langcode);
@@ -226,7 +226,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
$value = $values[$fid_langcode][$item->target_id];
$source_item = $translation->{$this->fieldName}->get($delta);
$assert = $item->target_id == $source_item->target_id && $item->alt == $value['alt'] && $item->title == $value['title'];
- $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id)));
+ $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', ['@fid' => $item->target_id]));
}
}
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php
index 96921c0190a..a84bb73b8ef 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php
@@ -21,7 +21,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('text');
+ public static $modules = ['text'];
/**
* The entity type being tested.
@@ -105,7 +105,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
* Adds additional languages.
*/
protected function setupLanguages() {
- $this->langcodes = array('it', 'fr');
+ $this->langcodes = ['it', 'fr'];
foreach ($this->langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)->save();
}
@@ -116,7 +116,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
* Returns an array of permissions needed for the translator.
*/
protected function getTranslatorPermissions() {
- return array_filter(array($this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations'));
+ return array_filter([$this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations']);
}
/**
@@ -134,14 +134,14 @@ abstract class ContentTranslationTestBase extends WebTestBase {
*/
protected function getEditorPermissions() {
// Every entity-type-specific test needs to define these.
- return array();
+ return [];
}
/**
* Returns an array of permissions needed for the administrator.
*/
protected function getAdministratorPermissions() {
- return array_merge($this->getEditorPermissions(), $this->getTranslatorPermissions(), array('administer content translation'));
+ return array_merge($this->getEditorPermissions(), $this->getTranslatorPermissions(), ['administer content translation']);
}
/**
@@ -183,12 +183,12 @@ abstract class ContentTranslationTestBase extends WebTestBase {
if (empty($this->fieldName)) {
$this->fieldName = 'field_test_et_ui_test';
}
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'type' => 'string',
'entity_type' => $this->entityTypeId,
'cardinality' => 1,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
@@ -196,10 +196,10 @@ abstract class ContentTranslationTestBase extends WebTestBase {
'label' => 'Test translatable text-field',
])->save();
entity_get_form_display($this->entityTypeId, $this->bundle, 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'string_textfield',
'weight' => 0,
- ))
+ ])
->save();
}
@@ -228,7 +228,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
if (!($controller instanceof SqlContentEntityStorage)) {
foreach ($values as $property => $value) {
if (is_array($value)) {
- $entity_values[$property] = array($langcode => $value);
+ $entity_values[$property] = [$langcode => $value];
}
}
}
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
index e5b14c2f45e..c6d1a5d4453 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
@@ -100,7 +100,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($values[$default_langcode] as $property => $value) {
$stored_value = $this->getValue($translation, $property, $default_langcode);
$value = is_array($value) ? $value[0]['value'] : $value;
- $message = format_string('@property correctly stored in the default language.', array('@property' => $property));
+ $message = format_string('@property correctly stored in the default language.', ['@property' => $property]);
$this->assertEqual($stored_value, $value, $message);
}
@@ -114,7 +114,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$entity->getEntityTypeId() => $entity->id(),
'source' => $default_langcode,
'target' => $langcode
- ], array('language' => $language));
+ ], ['language' => $language]);
$this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), $this->getFormSubmitActionForNewTranslation($entity, $langcode));
// Assert that HTML is escaped in "all languages" in UI after SafeMarkup
@@ -141,11 +141,11 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$author_field_name = $entity->hasField('content_translation_uid') ? 'content_translation_uid' : 'uid';
if ($entity->getFieldDefinition($author_field_name)->isTranslatable()) {
$this->assertEqual($metadata_target_translation->getAuthor()->id(), $this->translator->id(),
- SafeMarkup::format('Author of the target translation @langcode correctly stored for translatable owner field.', array('@langcode' => $langcode)));
+ SafeMarkup::format('Author of the target translation @langcode correctly stored for translatable owner field.', ['@langcode' => $langcode]));
$this->assertNotEqual($metadata_target_translation->getAuthor()->id(), $metadata_source_translation->getAuthor()->id(),
SafeMarkup::format('Author of the target translation @target different from the author of the source translation @source for translatable owner field.',
- array('@target' => $langcode, '@source' => $default_langcode)));
+ ['@target' => $langcode, '@source' => $default_langcode]));
}
else {
$this->assertEqual($metadata_target_translation->getAuthor()->id(), $this->editor->id(), 'Author of the entity remained untouched after translation for non translatable owner field.');
@@ -155,7 +155,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
if ($entity->getFieldDefinition($created_field_name)->isTranslatable()) {
$this->assertTrue($metadata_target_translation->getCreatedTime() > $metadata_source_translation->getCreatedTime(),
SafeMarkup::format('Translation creation timestamp of the target translation @target is newer than the creation timestamp of the source translation @source for translatable created field.',
- array('@target' => $langcode, '@source' => $default_langcode)));
+ ['@target' => $langcode, '@source' => $default_langcode]));
}
else {
$this->assertEqual($metadata_target_translation->getCreatedTime(), $metadata_source_translation->getCreatedTime(), 'Creation timestamp of the entity remained untouched after translation for non translatable created field.');
@@ -173,13 +173,13 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$langcode = 'fr';
$language = ConfigurableLanguage::load($langcode);
$source_langcode = 'it';
- $edit = array('source_langcode[source]' => $source_langcode);
+ $edit = ['source_langcode[source]' => $source_langcode];
$entity_type_id = $entity->getEntityTypeId();
$add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [
$entity->getEntityTypeId() => $entity->id(),
'source' => $default_langcode,
'target' => $langcode
- ], array('language' => $language));
+ ], ['language' => $language]);
// This does not save anything, it merely reloads the form and fills in the
// fields with the values from the different source language.
$this->drupalPostForm($add_url, $edit, t('Change'));
@@ -187,13 +187,13 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Add another translation and mark the other ones as outdated.
$values[$langcode] = $this->getNewEntityValues($langcode);
- $edit = $this->getEditValues($values, $langcode) + array('content_translation[retranslate]' => TRUE);
+ $edit = $this->getEditValues($values, $langcode) + ['content_translation[retranslate]' => TRUE];
$entity_type_id = $entity->getEntityTypeId();
$add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [
$entity->getEntityTypeId() => $entity->id(),
'source' => $source_langcode,
'target' => $langcode
- ], array('language' => $language));
+ ], ['language' => $language]);
$this->drupalPostForm($add_url, $edit, $this->getFormSubmitActionForNewTranslation($entity, $langcode));
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
@@ -206,7 +206,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($property_values as $property => $value) {
$stored_value = $this->getValue($translation, $property, $langcode);
$value = is_array($value) ? $value[0]['value'] : $value;
- $message = format_string('%property correctly stored with language %language.', array('%property' => $property, '%language' => $langcode));
+ $message = format_string('%property correctly stored with language %language.', ['%property' => $property, '%language' => $langcode]);
$this->assertEqual($stored_value, $value, $message);
}
}
@@ -226,13 +226,13 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($this->langcodes as $langcode) {
if ($entity->hasTranslation($langcode)) {
- $language = new Language(array('id' => $langcode));
+ $language = new Language(['id' => $langcode]);
$view_url = $entity->url('canonical', ['language' => $language]);
$elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]);
- $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', array('%language' => $langcode)));
- $edit_path = $entity->url('edit-form', array('language' => $language));
- $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', array(':href' => $edit_path));
- $this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', array('%language' => $langcode)));
+ $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', ['%language' => $langcode]));
+ $edit_path = $entity->url('edit-form', ['language' => $language]);
+ $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [':href' => $edit_path]);
+ $this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode]));
}
}
}
@@ -249,8 +249,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$languages = \Drupal::languageManager()->getLanguages();
// Mark translations as outdated.
- $edit = array('content_translation[retranslate]' => TRUE);
- $edit_path = $entity->urlInfo('edit-form', array('language' => $languages[$langcode]));
+ $edit = ['content_translation[retranslate]' => TRUE];
+ $edit_path = $entity->urlInfo('edit-form', ['language' => $languages[$langcode]]);
$this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
@@ -258,7 +258,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Check that every translation has the correct "outdated" status, and that
// the Translation fieldset is open if the translation is "outdated".
foreach ($this->langcodes as $added_langcode) {
- $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($added_langcode)));
+ $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($added_langcode)]);
$this->drupalGet($url);
if ($added_langcode == $langcode) {
$this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.');
@@ -267,7 +267,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
else {
$this->assertFieldByXPath('//input[@name="content_translation[outdated]"]', TRUE, 'The translate flag is checked by default.');
$this->assertTrue($this->xpath('//details[@id="edit-content-translation" and @open="open"]'), 'The translation tab is correctly expanded when the translation is outdated.');
- $edit = array('content_translation[outdated]' => FALSE);
+ $edit = ['content_translation[outdated]' => FALSE];
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $added_langcode));
$this->drupalGet($url);
$this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is now shown.');
@@ -292,8 +292,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Unpublish translations.
foreach ($this->langcodes as $index => $langcode) {
if ($index > 0) {
- $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($langcode)));
- $edit = array('content_translation[status]' => FALSE);
+ $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]);
+ $edit = ['content_translation[status]' => FALSE];
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId);
@@ -316,20 +316,20 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
->getStorage($this->entityTypeId);
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
- $values = array();
+ $values = [];
// Post different authoring information for each translation.
foreach ($this->langcodes as $index => $langcode) {
$user = $this->drupalCreateUser();
- $values[$langcode] = array(
+ $values[$langcode] = [
'uid' => $user->id(),
'created' => REQUEST_TIME - mt_rand(0, 1000),
- );
- $edit = array(
+ ];
+ $edit = [
'content_translation[uid]' => $user->getUsername(),
'content_translation[created]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'),
- );
- $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($langcode)));
+ ];
+ $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]);
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
}
@@ -345,11 +345,11 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Try to post non valid values and check that they are rejected.
$langcode = 'en';
- $edit = array(
+ $edit = [
// User names have by default length 8.
'content_translation[uid]' => $this->randomMachineName(12),
'content_translation[created]' => '19/11/1978',
- );
+ ];
$this->drupalPostForm($entity->urlInfo('edit-form'), $edit, $this->getFormSubmitAction($entity, $langcode));
$this->assertTrue($this->xpath('//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.');
$metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode));
@@ -369,9 +369,9 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
$language = ConfigurableLanguage::load($langcode);
- $url = $entity->urlInfo('edit-form', array('language' => $language));
- $this->drupalPostForm($url, array(), t('Delete translation'));
- $this->drupalPostForm(NULL, array(), t('Delete @language translation', array('@language' => $language->getName())));
+ $url = $entity->urlInfo('edit-form', ['language' => $language]);
+ $this->drupalPostForm($url, [], t('Delete translation'));
+ $this->drupalPostForm(NULL, [], t('Delete @language translation', ['@language' => $language->getName()]));
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId, TRUE);
if ($this->assertTrue(is_object($entity), 'Entity found')) {
@@ -389,7 +389,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
* Returns an array of entity field values to be tested.
*/
protected function getNewEntityValues($langcode) {
- return array($this->fieldName => array(array('value' => $this->randomMachineName(16))));
+ return [$this->fieldName => [['value' => $this->randomMachineName(16)]]];
}
/**
@@ -512,7 +512,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
@@ -555,10 +555,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$langcode = $language->getId();
- $edit = array(
+ $edit = [
$this->fieldName . '[0][value]' => $this->randomString(),
- );
- $edit_path = $entity->urlInfo('edit-form', array('language' => $language));
+ ];
+ $edit_path = $entity->urlInfo('edit-form', ['language' => $language]);
$this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage = $this->container->get('entity_type.manager')
@@ -567,11 +567,11 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$entity = $storage->load($this->entityId);
$this->assertEqual(
$entity->getChangedTimeAcrossTranslations(), $entity->getTranslation($langcode)->getChangedTime(),
- format_string('Changed time for language %language is the latest change over all languages.', array('%language' => $language->getName()))
+ format_string('Changed time for language %language is the latest change over all languages.', ['%language' => $language->getName()])
);
}
- $timestamps = array();
+ $timestamps = [];
foreach ($entity->getTranslationLanguages() as $language) {
$next_timestamp = $entity->getTranslation($language->getId())->getChangedTime();
if (!in_array($next_timestamp, $timestamps)) {
@@ -618,7 +618,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Save the entity on the regular edit form.
$language = $entity->language();
- $edit_path = $entity->urlInfo('edit-form', array('language' => $language));
+ $edit_path = $entity->urlInfo('edit-form', ['language' => $language]);
$this->drupalPostForm($edit_path, [], $this->getFormSubmitAction($entity, $language->getId()));
$storage->resetCache([$this->entityId]);
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
index b1524eea1e9..ac26a39abb5 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
@@ -26,7 +26,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'entity_test');
+ public static $modules = ['language', 'content_translation', 'entity_test'];
protected function setUp() {
parent::setUp();
@@ -47,7 +47,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
* {@inheritdoc}
*/
protected function getEditorPermissions() {
- return array('administer entity_test content');
+ return ['administer entity_test content'];
}
/**
@@ -58,11 +58,11 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
// Create a test entity.
$user = $this->drupalCreateUser();
- $values = array(
+ $values = [
'name' => $this->randomMachineName(),
'user_id' => $user->id(),
- $this->fieldName => array(array('value' => $this->randomMachineName(16))),
- );
+ $this->fieldName => [['value' => $this->randomMachineName(16)]],
+ ];
$id = $this->createEntity($values, $default_langcode);
$storage = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId);
@@ -72,7 +72,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
// Create a translation.
$this->drupalLogin($this->translator);
$add_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_add", [$this->entityTypeId => $this->entity->id(), 'source' => $default_langcode, 'target' => $this->langcodes[2]]);
- $this->drupalPostForm($add_translation_url, array(), t('Save'));
+ $this->drupalPostForm($add_translation_url, [], t('Save'));
$this->rebuildContainer();
}
@@ -114,10 +114,10 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
$this->doTestWorkflows($this->administrator, $expected_status);
// Check that translation permissions allow the associated operations.
- $ops = array('create' => t('Add'), 'update' => t('Edit'), 'delete' => t('Delete'));
+ $ops = ['create' => t('Add'), 'update' => t('Edit'), 'delete' => t('Delete')];
$translations_url = $this->entity->urlInfo('drupal:content-translation-overview');
foreach ($ops as $current_op => $item) {
- $user = $this->drupalCreateUser(array($this->getTranslatePermission(), "$current_op content translations", 'view test entity'));
+ $user = $this->drupalCreateUser([$this->getTranslatePermission(), "$current_op content translations", 'view test entity']);
$this->drupalLogin($user);
$this->drupalGet($translations_url);
@@ -130,10 +130,10 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
foreach ($ops as $op => $label) {
if ($op != $current_op) {
- $this->assertNoLink($label, format_string('No %op link found.', array('%op' => $label)));
+ $this->assertNoLink($label, format_string('No %op link found.', ['%op' => $label]));
}
else {
- $this->assertLink($label, 0, format_string('%op link found.', array('%op' => $label)));
+ $this->assertLink($label, 0, format_string('%op link found.', ['%op' => $label]));
}
}
}
diff --git a/core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php b/core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php
index 36d880edf44..07b5d00b084 100644
--- a/core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php
+++ b/core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php
@@ -16,21 +16,21 @@ class ContentTranslationViewsUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('content_translation');
+ public static $modules = ['content_translation'];
/**
* Tests the views UI.
*/
public function testViewsUI() {
$this->drupalGet('admin/structure/views/view/test_view/edit');
- $this->assertTitle(t('@label (@table) | @site-name', array('@label' => 'Test view', '@table' => 'Views test data', '@site-name' => $this->config('system.site')->get('name'))));
+ $this->assertTitle(t('@label (@table) | @site-name', ['@label' => 'Test view', '@table' => 'Views test data', '@site-name' => $this->config('system.site')->get('name')]));
}
}
diff --git a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php
index 4f5389568b1..23c74a40f54 100644
--- a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php
+++ b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php
@@ -20,14 +20,14 @@ class TranslationLinkTest extends ContentTranslationTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_translations_link');
+ public static $testViews = ['test_entity_translations_link'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('content_translation_test_views');
+ public static $modules = ['content_translation_test_views'];
protected function setUp() {
// @todo Use entity_type once it is has multilingual Views integration.
@@ -45,7 +45,7 @@ class TranslationLinkTest extends ContentTranslationTestBase {
$user->langcode = Language::LANGCODE_NOT_SPECIFIED;
$user->save();
- ViewTestData::createTestViews(get_class($this), array('content_translation_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['content_translation_test_views']);
}
/**
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php
index c735716e1b8..163b5e8ff31 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php
@@ -11,11 +11,11 @@ use Drupal\Tests\BrowserTestBase;
*/
class ContentTranslationEntityBundleUITest extends BrowserTestBase {
- public static $modules = array('language', 'content_translation', 'node', 'comment', 'field_ui');
+ public static $modules = ['language', 'content_translation', 'node', 'comment', 'field_ui'];
protected function setUp() {
parent::setUp();
- $user = $this->drupalCreateUser(array('access administration pages', 'administer languages', 'administer content translation', 'administer content types'));
+ $user = $this->drupalCreateUser(['access administration pages', 'administer languages', 'administer content translation', 'administer content types']);
$this->drupalLogin($user);
}
@@ -24,9 +24,9 @@ class ContentTranslationEntityBundleUITest extends BrowserTestBase {
*/
public function testContentTypeUI() {
// Create first content type.
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
// Enable content translation.
- $edit = array('language_configuration[content_translation]' => TRUE);
+ $edit = ['language_configuration[content_translation]' => TRUE];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, 'Save content type');
// Make sure add page does not inherit translation configuration from first
@@ -35,11 +35,11 @@ class ContentTranslationEntityBundleUITest extends BrowserTestBase {
$this->assertNoFieldChecked('edit-language-configuration-content-translation');
// Create second content type and set content translation.
- $edit = array(
+ $edit = [
'name' => 'Page',
'type' => 'page',
'language_configuration[content_translation]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/add', $edit, 'Save and manage fields');
// Make sure the settings are saved when creating the content type.
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php
index 0f1307945a8..bbad25ca9c2 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php
@@ -28,7 +28,7 @@ class ContentTranslationMetadataFieldsTest extends ContentTranslationTestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'node');
+ public static $modules = ['language', 'content_translation', 'node'];
/**
* The profile to install as a basis for testing.
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationStandardFieldsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationStandardFieldsTest.php
index 37178cacfad..c6a72a325ea 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationStandardFieldsTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationStandardFieldsTest.php
@@ -16,14 +16,14 @@ class ContentTranslationStandardFieldsTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'language',
'content_translation',
'node',
'comment',
'field_ui',
'entity_test',
- );
+ ];
/**
* {@inheritdoc}
@@ -36,7 +36,7 @@ class ContentTranslationStandardFieldsTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'access administration pages',
'administer languages',
'administer content translation',
@@ -45,7 +45,7 @@ class ContentTranslationStandardFieldsTest extends BrowserTestBase {
'administer comment fields',
'administer comments',
'administer comment types',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php
index 822cbdda383..ec7f87dd1bc 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php
@@ -18,7 +18,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('text');
+ public static $modules = ['text'];
/**
* The entity type being tested.
@@ -102,7 +102,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
* Adds additional languages.
*/
protected function setupLanguages() {
- $this->langcodes = array('it', 'fr');
+ $this->langcodes = ['it', 'fr'];
foreach ($this->langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)->save();
}
@@ -113,7 +113,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
* Returns an array of permissions needed for the translator.
*/
protected function getTranslatorPermissions() {
- return array_filter(array($this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations'));
+ return array_filter([$this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations']);
}
/**
@@ -131,14 +131,14 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
*/
protected function getEditorPermissions() {
// Every entity-type-specific test needs to define these.
- return array();
+ return [];
}
/**
* Returns an array of permissions needed for the administrator.
*/
protected function getAdministratorPermissions() {
- return array_merge($this->getEditorPermissions(), $this->getTranslatorPermissions(), array('administer content translation'));
+ return array_merge($this->getEditorPermissions(), $this->getTranslatorPermissions(), ['administer content translation']);
}
/**
@@ -180,12 +180,12 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
if (empty($this->fieldName)) {
$this->fieldName = 'field_test_et_ui_test';
}
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'type' => 'string',
'entity_type' => $this->entityTypeId,
'cardinality' => 1,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
@@ -193,10 +193,10 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
'label' => 'Test translatable text-field',
])->save();
entity_get_form_display($this->entityTypeId, $this->bundle, 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'string_textfield',
'weight' => 0,
- ))
+ ])
->save();
}
@@ -225,7 +225,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
if (!($controller instanceof SqlContentEntityStorage)) {
foreach ($values as $property => $value) {
if (is_array($value)) {
- $entity_values[$property] = array($langcode => $value);
+ $entity_values[$property] = [$langcode => $value];
}
}
}
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php
index 74d5de5b97b..02755e001a0 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php
@@ -16,17 +16,17 @@ class ContentTranslationUISkipTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('content_translation_test', 'user', 'node');
+ public static $modules = ['content_translation_test', 'user', 'node'];
/**
* Tests the content_translation_ui_skip key functionality.
*/
function testUICheckSkip() {
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'translate any entity',
'administer content translation',
'administer languages'
- ));
+ ]);
$this->drupalLogin($admin_user);
// Visit the content translation.
$this->drupalGet('admin/config/regional/content-language');
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
index 769006e5a49..accc3ca8c23 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
@@ -97,7 +97,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($values[$default_langcode] as $property => $value) {
$stored_value = $this->getValue($translation, $property, $default_langcode);
$value = is_array($value) ? $value[0]['value'] : $value;
- $message = format_string('@property correctly stored in the default language.', array('@property' => $property));
+ $message = format_string('@property correctly stored in the default language.', ['@property' => $property]);
$this->assertEqual($stored_value, $value, $message);
}
@@ -111,7 +111,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$entity->getEntityTypeId() => $entity->id(),
'source' => $default_langcode,
'target' => $langcode
- ], array('language' => $language));
+ ], ['language' => $language]);
$this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), $this->getFormSubmitActionForNewTranslation($entity, $langcode));
// Assert that HTML is escaped in "all languages" in UI after SafeMarkup
@@ -138,11 +138,11 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$author_field_name = $entity->hasField('content_translation_uid') ? 'content_translation_uid' : 'uid';
if ($entity->getFieldDefinition($author_field_name)->isTranslatable()) {
$this->assertEqual($metadata_target_translation->getAuthor()->id(), $this->translator->id(),
- SafeMarkup::format('Author of the target translation @langcode correctly stored for translatable owner field.', array('@langcode' => $langcode)));
+ SafeMarkup::format('Author of the target translation @langcode correctly stored for translatable owner field.', ['@langcode' => $langcode]));
$this->assertNotEqual($metadata_target_translation->getAuthor()->id(), $metadata_source_translation->getAuthor()->id(),
SafeMarkup::format('Author of the target translation @target different from the author of the source translation @source for translatable owner field.',
- array('@target' => $langcode, '@source' => $default_langcode)));
+ ['@target' => $langcode, '@source' => $default_langcode]));
}
else {
$this->assertEqual($metadata_target_translation->getAuthor()->id(), $this->editor->id(), 'Author of the entity remained untouched after translation for non translatable owner field.');
@@ -152,7 +152,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
if ($entity->getFieldDefinition($created_field_name)->isTranslatable()) {
$this->assertTrue($metadata_target_translation->getCreatedTime() > $metadata_source_translation->getCreatedTime(),
SafeMarkup::format('Translation creation timestamp of the target translation @target is newer than the creation timestamp of the source translation @source for translatable created field.',
- array('@target' => $langcode, '@source' => $default_langcode)));
+ ['@target' => $langcode, '@source' => $default_langcode]));
}
else {
$this->assertEqual($metadata_target_translation->getCreatedTime(), $metadata_source_translation->getCreatedTime(), 'Creation timestamp of the entity remained untouched after translation for non translatable created field.');
@@ -170,13 +170,13 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$langcode = 'fr';
$language = ConfigurableLanguage::load($langcode);
$source_langcode = 'it';
- $edit = array('source_langcode[source]' => $source_langcode);
+ $edit = ['source_langcode[source]' => $source_langcode];
$entity_type_id = $entity->getEntityTypeId();
$add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [
$entity->getEntityTypeId() => $entity->id(),
'source' => $default_langcode,
'target' => $langcode
- ], array('language' => $language));
+ ], ['language' => $language]);
// This does not save anything, it merely reloads the form and fills in the
// fields with the values from the different source language.
$this->drupalPostForm($add_url, $edit, t('Change'));
@@ -184,13 +184,13 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Add another translation and mark the other ones as outdated.
$values[$langcode] = $this->getNewEntityValues($langcode);
- $edit = $this->getEditValues($values, $langcode) + array('content_translation[retranslate]' => TRUE);
+ $edit = $this->getEditValues($values, $langcode) + ['content_translation[retranslate]' => TRUE];
$entity_type_id = $entity->getEntityTypeId();
$add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [
$entity->getEntityTypeId() => $entity->id(),
'source' => $source_langcode,
'target' => $langcode
- ], array('language' => $language));
+ ], ['language' => $language]);
$this->drupalPostForm($add_url, $edit, $this->getFormSubmitActionForNewTranslation($entity, $langcode));
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
@@ -203,7 +203,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($property_values as $property => $value) {
$stored_value = $this->getValue($translation, $property, $langcode);
$value = is_array($value) ? $value[0]['value'] : $value;
- $message = format_string('%property correctly stored with language %language.', array('%property' => $property, '%language' => $langcode));
+ $message = format_string('%property correctly stored with language %language.', ['%property' => $property, '%language' => $langcode]);
$this->assertEqual($stored_value, $value, $message);
}
}
@@ -223,13 +223,13 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($this->langcodes as $langcode) {
if ($entity->hasTranslation($langcode)) {
- $language = new Language(array('id' => $langcode));
+ $language = new Language(['id' => $langcode]);
$view_url = $entity->url('canonical', ['language' => $language]);
$elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]);
- $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', array('%language' => $langcode)));
- $edit_path = $entity->url('edit-form', array('language' => $language));
- $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', array(':href' => $edit_path));
- $this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', array('%language' => $langcode)));
+ $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', ['%language' => $langcode]));
+ $edit_path = $entity->url('edit-form', ['language' => $language]);
+ $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [':href' => $edit_path]);
+ $this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode]));
}
}
}
@@ -246,8 +246,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$languages = \Drupal::languageManager()->getLanguages();
// Mark translations as outdated.
- $edit = array('content_translation[retranslate]' => TRUE);
- $edit_path = $entity->urlInfo('edit-form', array('language' => $languages[$langcode]));
+ $edit = ['content_translation[retranslate]' => TRUE];
+ $edit_path = $entity->urlInfo('edit-form', ['language' => $languages[$langcode]]);
$this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
@@ -255,7 +255,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Check that every translation has the correct "outdated" status, and that
// the Translation fieldset is open if the translation is "outdated".
foreach ($this->langcodes as $added_langcode) {
- $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($added_langcode)));
+ $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($added_langcode)]);
$this->drupalGet($url);
if ($added_langcode == $langcode) {
$this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.');
@@ -264,7 +264,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
else {
$this->assertFieldByXPath('//input[@name="content_translation[outdated]"]', TRUE, 'The translate flag is checked by default.');
$this->assertTrue($this->xpath('//details[@id="edit-content-translation" and @open="open"]'), 'The translation tab is correctly expanded when the translation is outdated.');
- $edit = array('content_translation[outdated]' => FALSE);
+ $edit = ['content_translation[outdated]' => FALSE];
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $added_langcode));
$this->drupalGet($url);
$this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is now shown.');
@@ -289,8 +289,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Unpublish translations.
foreach ($this->langcodes as $index => $langcode) {
if ($index > 0) {
- $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($langcode)));
- $edit = array('content_translation[status]' => FALSE);
+ $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]);
+ $edit = ['content_translation[status]' => FALSE];
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId);
@@ -313,20 +313,20 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
->getStorage($this->entityTypeId);
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
- $values = array();
+ $values = [];
// Post different authoring information for each translation.
foreach ($this->langcodes as $index => $langcode) {
$user = $this->drupalCreateUser();
- $values[$langcode] = array(
+ $values[$langcode] = [
'uid' => $user->id(),
'created' => REQUEST_TIME - mt_rand(0, 1000),
- );
- $edit = array(
+ ];
+ $edit = [
'content_translation[uid]' => $user->getUsername(),
'content_translation[created]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'),
- );
- $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($langcode)));
+ ];
+ $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]);
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
}
@@ -342,11 +342,11 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Try to post non valid values and check that they are rejected.
$langcode = 'en';
- $edit = array(
+ $edit = [
// User names have by default length 8.
'content_translation[uid]' => $this->randomMachineName(12),
'content_translation[created]' => '19/11/1978',
- );
+ ];
$this->drupalPostForm($entity->urlInfo('edit-form'), $edit, $this->getFormSubmitAction($entity, $langcode));
$this->assertTrue($this->xpath('//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.');
$metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode));
@@ -366,9 +366,9 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
$language = ConfigurableLanguage::load($langcode);
- $url = $entity->urlInfo('edit-form', array('language' => $language));
- $this->drupalPostForm($url, array(), t('Delete translation'));
- $this->drupalPostForm(NULL, array(), t('Delete @language translation', array('@language' => $language->getName())));
+ $url = $entity->urlInfo('edit-form', ['language' => $language]);
+ $this->drupalPostForm($url, [], t('Delete translation'));
+ $this->drupalPostForm(NULL, [], t('Delete @language translation', ['@language' => $language->getName()]));
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId, TRUE);
if ($this->assertTrue(is_object($entity), 'Entity found')) {
@@ -386,7 +386,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
* Returns an array of entity field values to be tested.
*/
protected function getNewEntityValues($langcode) {
- return array($this->fieldName => array(array('value' => $this->randomMachineName(16))));
+ return [$this->fieldName => [['value' => $this->randomMachineName(16)]]];
}
/**
@@ -509,7 +509,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
@@ -552,10 +552,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$langcode = $language->getId();
- $edit = array(
+ $edit = [
$this->fieldName . '[0][value]' => $this->randomString(),
- );
- $edit_path = $entity->urlInfo('edit-form', array('language' => $language));
+ ];
+ $edit_path = $entity->urlInfo('edit-form', ['language' => $language]);
$this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode));
$storage = $this->container->get('entity_type.manager')
@@ -564,11 +564,11 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
$entity = $storage->load($this->entityId);
$this->assertEqual(
$entity->getChangedTimeAcrossTranslations(), $entity->getTranslation($langcode)->getChangedTime(),
- format_string('Changed time for language %language is the latest change over all languages.', array('%language' => $language->getName()))
+ format_string('Changed time for language %language is the latest change over all languages.', ['%language' => $language->getName()])
);
}
- $timestamps = array();
+ $timestamps = [];
foreach ($entity->getTranslationLanguages() as $language) {
$next_timestamp = $entity->getTranslation($language->getId())->getChangedTime();
if (!in_array($next_timestamp, $timestamps)) {
@@ -615,7 +615,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
// Save the entity on the regular edit form.
$language = $entity->language();
- $edit_path = $entity->urlInfo('edit-form', array('language' => $language));
+ $edit_path = $entity->urlInfo('edit-form', ['language' => $language]);
$this->drupalPostForm($edit_path, [], $this->getFormSubmitAction($entity, $language->getId()));
$storage->resetCache([$this->entityId]);
diff --git a/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php b/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php
index f650270085e..732d74be289 100644
--- a/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php
+++ b/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php
@@ -25,7 +25,7 @@ class ContentTranslationConfigImportTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'entity_test', 'language', 'content_translation');
+ public static $modules = ['system', 'user', 'entity_test', 'language', 'content_translation'];
/**
* {@inheritdoc}
@@ -69,22 +69,22 @@ class ContentTranslationConfigImportTest extends KernelTestBase {
$this->assertIdentical($storage->exists($config_name), FALSE, $config_name . ' not found.');
// Create new config entity.
- $data = array(
+ $data = [
'uuid' => 'a019d89b-c4d9-4ed4-b859-894e4e2e93cf',
'langcode' => 'en',
'status' => TRUE,
- 'dependencies' => array(
- 'module' => array('content_translation')
- ),
+ 'dependencies' => [
+ 'module' => ['content_translation']
+ ],
'id' => $config_id,
'target_entity_type_id' => 'entity_test_mul',
'target_bundle' => 'entity_test_mul',
'default_langcode' => 'site_default',
'language_alterable' => FALSE,
- 'third_party_settings' => array(
- 'content_translation' => array('enabled' => TRUE),
- ),
- );
+ 'third_party_settings' => [
+ 'content_translation' => ['enabled' => TRUE],
+ ],
+ ];
$sync->write($config_name, $data);
$this->assertIdentical($sync->exists($config_name), TRUE, $config_name . ' found.');
diff --git a/core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php b/core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php
index 291cdf9714e..9b64ba83d40 100644
--- a/core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php
+++ b/core/modules/content_translation/tests/src/Kernel/ContentTranslationSettingsApiTest.php
@@ -16,7 +16,7 @@ class ContentTranslationSettingsApiTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'user', 'entity_test');
+ public static $modules = ['language', 'content_translation', 'user', 'entity_test'];
/**
* {@inheritdoc}
diff --git a/core/modules/content_translation/tests/src/Kernel/ContentTranslationSyncUnitTest.php b/core/modules/content_translation/tests/src/Kernel/ContentTranslationSyncUnitTest.php
index eb52e5092a0..30228076ac0 100644
--- a/core/modules/content_translation/tests/src/Kernel/ContentTranslationSyncUnitTest.php
+++ b/core/modules/content_translation/tests/src/Kernel/ContentTranslationSyncUnitTest.php
@@ -54,17 +54,17 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
*/
protected $unchangedFieldValues;
- public static $modules = array('language', 'content_translation');
+ public static $modules = ['language', 'content_translation'];
protected function setUp() {
parent::setUp();
$this->synchronizer = new FieldTranslationSynchronizer($this->container->get('entity.manager'));
- $this->synchronized = array('sync1', 'sync2');
- $this->columns = array_merge($this->synchronized, array('var1', 'var2'));
- $this->langcodes = array('en', 'it', 'fr', 'de', 'es');
+ $this->synchronized = ['sync1', 'sync2'];
+ $this->columns = array_merge($this->synchronized, ['var1', 'var2']);
+ $this->langcodes = ['en', 'it', 'fr', 'de', 'es'];
$this->cardinality = 4;
- $this->unchangedFieldValues = array();
+ $this->unchangedFieldValues = [];
// Set up an initial set of values in the correct state, that is with
// "synchronized" values being equal.
@@ -88,7 +88,7 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
$sync_langcode = $this->langcodes[2];
$unchanged_items = $this->unchangedFieldValues[$sync_langcode];
$field_values = $this->unchangedFieldValues;
- $item = array();
+ $item = [];
foreach ($this->columns as $column) {
$item[$column] = $this->randomMachineName();
}
@@ -140,7 +140,7 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
$sync_langcode = $this->langcodes[3];
$unchanged_items = $this->unchangedFieldValues[$sync_langcode];
$field_values = $this->unchangedFieldValues;
- $field_values[$sync_langcode] = array();
+ $field_values[$sync_langcode] = [];
// Scramble the items.
foreach ($unchanged_items as $delta => $item) {
$new_delta = ($delta + 1) % $this->cardinality;
@@ -179,7 +179,7 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
// Determine whether the unchanged values should be altered depending on
// their delta.
- $delta_callbacks = array(
+ $delta_callbacks = [
// Continuous field values: all values are equal.
function($delta) { return TRUE; },
// Alternated field values: only the even ones are equal.
@@ -188,7 +188,7 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
function($delta) { return $delta === 1 || $delta === 2; },
// Sparse field values: only the "extreme" ones are equal.
function($delta) { return $delta === 0 || $delta === 3; },
- );
+ ];
foreach ($delta_callbacks as $delta_callback) {
$field_values = $this->unchangedFieldValues;
diff --git a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php
index 7390c0e44ce..ad7317f3ad6 100644
--- a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php
+++ b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php
@@ -69,18 +69,18 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
$language_manager->expects($this->at(0))
->method('getLanguage')
->with($this->equalTo($source))
- ->will($this->returnValue(new Language(array('id' => 'en'))));
+ ->will($this->returnValue(new Language(['id' => 'en'])));
$language_manager->expects($this->at(1))
->method('getLanguages')
- ->will($this->returnValue(array('en' => array(), 'it' => array())));
+ ->will($this->returnValue(['en' => [], 'it' => []]));
$language_manager->expects($this->at(2))
->method('getLanguage')
->with($this->equalTo($source))
- ->will($this->returnValue(new Language(array('id' => 'en'))));
+ ->will($this->returnValue(new Language(['id' => 'en'])));
$language_manager->expects($this->at(3))
->method('getLanguage')
->with($this->equalTo($target))
- ->will($this->returnValue(new Language(array('id' => 'it'))));
+ ->will($this->returnValue(new Language(['id' => 'it'])));
// Set the mock entity. We need to use ContentEntityBase for mocking due to
// issues with phpunit and multiple interfaces.
@@ -92,7 +92,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
$entity->expects($this->once())
->method('getTranslationLanguages')
->with()
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$entity->expects($this->once())
->method('getCacheContexts')
->willReturn([]);
@@ -101,10 +101,10 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
->willReturn(Cache::PERMANENT);
$entity->expects($this->once())
->method('getCacheTags')
- ->will($this->returnValue(array('node:1337')));
+ ->will($this->returnValue(['node:1337']));
$entity->expects($this->once())
->method('getCacheContexts')
- ->willReturn(array());
+ ->willReturn([]);
// Set the route requirements.
$route = new Route('test_route');
diff --git a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php
index 63dad2f6f6a..a72d9b7ff6c 100644
--- a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php
+++ b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php
@@ -12,25 +12,25 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array(
+ $this->directoryList = [
'content_translation' => 'core/modules/content_translation',
'node' => 'core/modules/node',
- );
+ ];
parent::setUp();
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->any())
->method('getLinkTemplate')
- ->will($this->returnValueMap(array(
- array('canonical', 'entity.node.canonical'),
- array('drupal:content-translation-overview', 'entity.node.content_translation_overview'),
- )));
+ ->will($this->returnValueMap([
+ ['canonical', 'entity.node.canonical'],
+ ['drupal:content-translation-overview', 'entity.node.content_translation_overview'],
+ ]));
$content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface');
$content_translation_manager->expects($this->any())
->method('getSupportedEntityTypes')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'node' => $entity_type,
- )));
+ ]));
\Drupal::getContainer()->set('content_translation.manager', $content_translation_manager);
\Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub());
}
@@ -48,22 +48,22 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function providerTestBlockAdminDisplay() {
- return array(
- array('entity.node.canonical', array(array(
+ return [
+ ['entity.node.canonical', [[
'content_translation.local_tasks:entity.node.content_translation_overview',
'entity.node.canonical',
'entity.node.edit_form',
'entity.node.delete_form',
'entity.node.version_history',
- ))),
- array('entity.node.content_translation_overview', array(array(
+ ]]],
+ ['entity.node.content_translation_overview', [[
'content_translation.local_tasks:entity.node.content_translation_overview',
'entity.node.canonical',
'entity.node.edit_form',
'entity.node.delete_form',
'entity.node.version_history',
- ))),
- );
+ ]]],
+ ];
}
}
diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module
index 6cb1fcffcf0..cf20318cb1e 100644
--- a/core/modules/contextual/contextual.module
+++ b/core/modules/contextual/contextual.module
@@ -27,26 +27,26 @@ function contextual_toolbar() {
return $items;
}
- $items['contextual'] += array(
+ $items['contextual'] += [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'html_tag',
'#tag' => 'button',
'#value' => t('Edit'),
- '#attributes' => array(
- 'class' => array('toolbar-icon', 'toolbar-icon-edit'),
+ '#attributes' => [
+ 'class' => ['toolbar-icon', 'toolbar-icon-edit'],
'aria-pressed' => 'false',
- ),
- ),
- '#wrapper_attributes' => array(
- 'class' => array('hidden', 'contextual-toolbar-tab'),
- ),
- '#attached' => array(
- 'library' => array(
+ ],
+ ],
+ '#wrapper_attributes' => [
+ 'class' => ['hidden', 'contextual-toolbar-tab'],
+ ],
+ '#attached' => [
+ 'library' => [
'contextual/drupal.contextual-toolbar',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $items;
}
@@ -75,7 +75,7 @@ function contextual_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.contextual':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Contextual links module gives users with the <em>Use contextual links</em> permission quick access to tasks associated with certain areas of pages on your site. For example, a menu displayed as a block has links to edit the menu and configure the block. For more information, see the <a href=":contextual">online documentation for the Contextual Links module</a>.', array(':contextual' => 'https://www.drupal.org/documentation/modules/contextual')) . '</p>';
+ $output .= '<p>' . t('The Contextual links module gives users with the <em>Use contextual links</em> permission quick access to tasks associated with certain areas of pages on your site. For example, a menu displayed as a block has links to edit the menu and configure the block. For more information, see the <a href=":contextual">online documentation for the Contextual Links module</a>.', [':contextual' => 'https://www.drupal.org/documentation/modules/contextual']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Displaying contextual links') . '</dt>';
@@ -88,8 +88,8 @@ function contextual_help($route_name, RouteMatchInterface $route_match) {
'#alt' => t('contextual links button')
];
$sample_picture = \Drupal::service('renderer')->render($sample_picture);
- $output .= '<li>' . t('Hovering over the area of interest will temporarily make the contextual links button visible (which looks like a pencil in most themes, and is normally displayed in the upper right corner of the area). The icon typically looks like this: @picture', array('@picture' => $sample_picture)) . '</li>';
- $output .= '<li>' . t('If you have the <a href=":toolbar">Toolbar module</a> enabled, clicking the contextual links button in the toolbar (which looks like a pencil) will make all contextual links buttons on the page visible. Clicking this button again will toggle them to invisible.', array(':toolbar' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', array('name' => 'toolbar')) : '#')) . '</li>';
+ $output .= '<li>' . t('Hovering over the area of interest will temporarily make the contextual links button visible (which looks like a pencil in most themes, and is normally displayed in the upper right corner of the area). The icon typically looks like this: @picture', ['@picture' => $sample_picture]) . '</li>';
+ $output .= '<li>' . t('If you have the <a href=":toolbar">Toolbar module</a> enabled, clicking the contextual links button in the toolbar (which looks like a pencil) will make all contextual links buttons on the page visible. Clicking this button again will toggle them to invisible.', [':toolbar' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', ['name' => 'toolbar']) : '#']) . '</li>';
$output .= '</ol>';
$output .= t('Once the contextual links button for the area of interest is visible, click the button to display the links.');
$output .= '</dd>';
@@ -132,10 +132,10 @@ function contextual_preprocess(&$variables, $hook, $info) {
// users, contextual_page_attachments() only adds the asset library for
// users with the 'access contextual links' permission, thus preventing
// unnecessary HTTP requests for users without that permission.
- $variables['title_suffix']['contextual_links'] = array(
+ $variables['title_suffix']['contextual_links'] = [
'#type' => 'contextual_links_placeholder',
'#id' => _contextual_links_to_id($element['#contextual_links']),
- );
+ ];
}
}
@@ -172,7 +172,7 @@ function contextual_contextual_links_view_alter(&$element, $items) {
* use in a data- attribute.
*/
function _contextual_links_to_id($contextual_links) {
- $ids = array();
+ $ids = [];
$langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();
foreach ($contextual_links as $group => $args) {
$route_parameters = UrlHelper::buildQuery($args['route_parameters']);
@@ -199,17 +199,17 @@ function _contextual_links_to_id($contextual_links) {
* The value for a #contextual_links property.
*/
function _contextual_id_to_links($id) {
- $contextual_links = array();
+ $contextual_links = [];
$contexts = explode('|', $id);
foreach ($contexts as $context) {
list($group, $route_parameters_raw, $metadata_raw) = explode(':', $context);
parse_str($route_parameters_raw, $route_parameters);
- $metadata = array();
+ $metadata = [];
parse_str($metadata_raw, $metadata);
- $contextual_links[$group] = array(
+ $contextual_links[$group] = [
'route_parameters' => $route_parameters,
'metadata' => $metadata,
- );
+ ];
}
return $contextual_links;
}
diff --git a/core/modules/contextual/contextual.views.inc b/core/modules/contextual/contextual.views.inc
index 528b3bbed09..bac5522f159 100644
--- a/core/modules/contextual/contextual.views.inc
+++ b/core/modules/contextual/contextual.views.inc
@@ -9,11 +9,11 @@
* Implements hook_views_data_alter().
*/
function contextual_views_data_alter(&$data) {
- $data['views']['contextual_links'] = array(
+ $data['views']['contextual_links'] = [
'title' => t('Contextual Links'),
'help' => t('Display fields in a contextual links menu.'),
- 'field' => array(
+ 'field' => [
'id' => 'contextual_links',
- ),
- );
+ ],
+ ];
}
diff --git a/core/modules/contextual/src/ContextualController.php b/core/modules/contextual/src/ContextualController.php
index 0812ad13d26..b1fe245c040 100644
--- a/core/modules/contextual/src/ContextualController.php
+++ b/core/modules/contextual/src/ContextualController.php
@@ -32,12 +32,12 @@ class ContextualController implements ContainerAwareInterface {
throw new BadRequestHttpException(t('No contextual ids specified.'));
}
- $rendered = array();
+ $rendered = [];
foreach ($ids as $id) {
- $element = array(
+ $element = [
'#type' => 'contextual_links',
'#contextual_links' => _contextual_id_to_links($id),
- );
+ ];
$rendered[$id] = $this->container->get('renderer')->renderRoot($element);
}
diff --git a/core/modules/contextual/src/Element/ContextualLinks.php b/core/modules/contextual/src/Element/ContextualLinks.php
index 8f670236fd2..62e8966afae 100644
--- a/core/modules/contextual/src/Element/ContextualLinks.php
+++ b/core/modules/contextual/src/Element/ContextualLinks.php
@@ -18,19 +18,19 @@ class ContextualLinks extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderLinks'),
- ),
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderLinks'],
+ ],
'#theme' => 'links__contextual',
- '#links' => array(),
- '#attributes' => array('class' => array('contextual-links')),
- '#attached' => array(
- 'library' => array(
+ '#links' => [],
+ '#attributes' => ['class' => ['contextual-links']],
+ '#attached' => [
+ 'library' => [
'contextual/drupal.contextual-links',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -60,26 +60,26 @@ class ContextualLinks extends RenderElement {
*/
public static function preRenderLinks(array $element) {
// Retrieve contextual menu links.
- $items = array();
+ $items = [];
$contextual_links_manager = static::contextualLinkManager();
foreach ($element['#contextual_links'] as $group => $args) {
- $args += array(
- 'route_parameters' => array(),
- 'metadata' => array(),
- );
+ $args += [
+ 'route_parameters' => [],
+ 'metadata' => [],
+ ];
$items += $contextual_links_manager->getContextualLinksArrayByGroup($group, $args['route_parameters'], $args['metadata']);
}
// Transform contextual links into parameters suitable for links.html.twig.
- $links = array();
+ $links = [];
foreach ($items as $class => $item) {
$class = Html::getClass($class);
- $links[$class] = array(
+ $links[$class] = [
'title' => $item['title'],
'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : []),
- );
+ ];
}
$element['#links'] = $links;
diff --git a/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php b/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php
index 92f4b2bed50..2fba8db3f13 100644
--- a/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php
+++ b/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php
@@ -18,12 +18,12 @@ class ContextualLinksPlaceholder extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderPlaceholder'),
- ),
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderPlaceholder'],
+ ],
'#id' => NULL,
- );
+ ];
}
/**
diff --git a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php
index 585b7f6691c..6bd5c01a439 100644
--- a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php
+++ b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php
@@ -35,8 +35,8 @@ class ContextualLinks extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['fields'] = array('default' => array());
- $options['destination'] = array('default' => 1);
+ $options['fields'] = ['default' => []];
+ $options['destination'] = ['default' => 1];
return $options;
}
@@ -48,23 +48,23 @@ class ContextualLinks extends FieldPluginBase {
$all_fields = $this->view->display_handler->getFieldLabels();
// Offer to include only those fields that follow this one.
$field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));
- $form['fields'] = array(
+ $form['fields'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Fields'),
'#description' => $this->t('Fields to be included as contextual links.'),
'#options' => $field_options,
'#default_value' => $this->options['fields'],
- );
- $form['destination'] = array(
+ ];
+ $form['destination'] = [
'#type' => 'select',
'#title' => $this->t('Include destination'),
'#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
- '#options' => array(
+ '#options' => [
'0' => $this->t('No'),
'1' => $this->t('Yes'),
- ),
+ ],
'#default_value' => $this->options['destination'],
- );
+ ];
}
/**
@@ -93,7 +93,7 @@ class ContextualLinks extends FieldPluginBase {
* @see contextual_contextual_links_view_alter()
*/
public function render(ResultRow $values) {
- $links = array();
+ $links = [];
foreach ($this->options['fields'] as $field) {
$rendered_field = $this->view->style_plugin->getField($values->index, $field);
if (empty($rendered_field)) {
@@ -109,13 +109,13 @@ class ContextualLinks extends FieldPluginBase {
}
if (!empty($title) && !empty($path)) {
// Make sure that tokens are replaced for this paths as well.
- $tokens = $this->getRenderTokens(array());
+ $tokens = $this->getRenderTokens([]);
$path = strip_tags(Html::decodeEntities(strtr($path, $tokens)));
- $links[$field] = array(
+ $links[$field] = [
'href' => $path,
'title' => $title,
- );
+ ];
if (!empty($this->options['destination'])) {
$links[$field]['query'] = $this->getDestinationArray();
}
@@ -124,20 +124,20 @@ class ContextualLinks extends FieldPluginBase {
// Renders a contextual links placeholder.
if (!empty($links)) {
- $contextual_links = array(
- 'contextual' => array(
+ $contextual_links = [
+ 'contextual' => [
'',
- array(),
- array(
+ [],
+ [
'contextual-views-field-links' => UrlHelper::encodePath(Json::encode($links)),
- )
- )
- );
+ ]
+ ]
+ ];
- $element = array(
+ $element = [
'#type' => 'contextual_links_placeholder',
'#id' => _contextual_links_to_id($contextual_links),
- );
+ ];
return drupal_render($element);
}
else {
diff --git a/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php b/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php
index e5d2c85469e..e2c57fc1681 100644
--- a/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php
+++ b/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php
@@ -42,20 +42,20 @@ class ContextualDynamicContextTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('contextual', 'node', 'views', 'views_ui', 'language', 'menu_test');
+ public static $modules = ['contextual', 'node', 'views', 'views_ui', 'language', 'menu_test'];
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
ConfigurableLanguage::createFromLangcode('it')->save();
$this->rebuildContainer();
- $this->editorUser = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content'));
- $this->authenticatedUser = $this->drupalCreateUser(array('access content', 'access contextual links'));
- $this->anonymousUser = $this->drupalCreateUser(array('access content'));
+ $this->editorUser = $this->drupalCreateUser(['access content', 'access contextual links', 'edit any article content']);
+ $this->authenticatedUser = $this->drupalCreateUser(['access content', 'access contextual links']);
+ $this->anonymousUser = $this->drupalCreateUser(['access content']);
}
/**
@@ -71,9 +71,9 @@ class ContextualDynamicContextTest extends WebTestBase {
// - An article, which should be user-editable.
// - A page, which should not be user-editable.
// - A second article, which should also be user-editable.
- $node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
- $node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
- $node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
+ $node1 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
+ $node2 = $this->drupalCreateNode(['type' => 'page', 'promote' => 1]);
+ $node3 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
// Now, on the front page, all article nodes should have contextual links
// placeholders, as should the view that contains them.
@@ -89,7 +89,7 @@ class ContextualDynamicContextTest extends WebTestBase {
for ($i = 0; $i < count($ids); $i++) {
$this->assertContextualLinkPlaceHolder($ids[$i]);
}
- $this->renderContextualLinks(array(), 'node');
+ $this->renderContextualLinks([], 'node');
$this->assertResponse(400);
$this->assertRaw('No contextual ids specified.');
$response = $this->renderContextualLinks($ids, 'node');
@@ -112,7 +112,7 @@ class ContextualDynamicContextTest extends WebTestBase {
for ($i = 0; $i < count($ids); $i++) {
$this->assertContextualLinkPlaceHolder($ids[$i]);
}
- $this->renderContextualLinks(array(), 'node');
+ $this->renderContextualLinks([], 'node');
$this->assertResponse(400);
$this->assertRaw('No contextual ids specified.');
$response = $this->renderContextualLinks($ids, 'node');
@@ -129,7 +129,7 @@ class ContextualDynamicContextTest extends WebTestBase {
for ($i = 0; $i < count($ids); $i++) {
$this->assertNoContextualLinkPlaceHolder($ids[$i]);
}
- $this->renderContextualLinks(array(), 'node');
+ $this->renderContextualLinks([], 'node');
$this->assertResponse(403);
$this->renderContextualLinks($ids, 'node');
$this->assertResponse(403);
@@ -150,7 +150,7 @@ class ContextualDynamicContextTest extends WebTestBase {
* The result of the assertion.
*/
protected function assertContextualLinkPlaceHolder($id) {
- return $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+ return $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
}
/**
@@ -163,7 +163,7 @@ class ContextualDynamicContextTest extends WebTestBase {
* The result of the assertion.
*/
protected function assertNoContextualLinkPlaceHolder($id) {
- return $this->assertNoRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id does not exist.', array('@id' => $id)));
+ return $this->assertNoRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id does not exist.', ['@id' => $id]));
}
/**
@@ -178,11 +178,11 @@ class ContextualDynamicContextTest extends WebTestBase {
* The response body.
*/
protected function renderContextualLinks($ids, $current_path) {
- $post = array();
+ $post = [];
for ($i = 0; $i < count($ids); $i++) {
$post['ids[' . $i . ']'] = $ids[$i];
}
- return $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => $current_path)));
+ return $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => $current_path]]);
}
}
diff --git a/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php b/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php
index 680303db322..1d86da06f09 100644
--- a/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php
+++ b/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php
@@ -17,7 +17,7 @@ class ContextualUnitTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('contextual');
+ public static $modules = ['contextual'];
/**
* Provides testcases for testContextualLinksToId() and
@@ -27,82 +27,82 @@ class ContextualUnitTest extends KernelTestBase {
// - one group.
// - one dynamic path argument.
// - no metadata.
- $tests[] = array(
- 'links' => array(
- 'node' => array(
- 'route_parameters' => array(
+ $tests[] = [
+ 'links' => [
+ 'node' => [
+ 'route_parameters' => [
'node' => '14031991',
- ),
- 'metadata' => array('langcode' => 'en'),
- ),
- ),
+ ],
+ 'metadata' => ['langcode' => 'en'],
+ ],
+ ],
'id' => 'node:node=14031991:langcode=en',
- );
+ ];
// Test branch conditions:
// - one group.
// - multiple dynamic path arguments.
// - no metadata.
- $tests[] = array(
- 'links' => array(
- 'foo' => array(
- 'route_parameters' => array(
+ $tests[] = [
+ 'links' => [
+ 'foo' => [
+ 'route_parameters' => [
'bar',
'key' => 'baz',
'qux',
- ),
- 'metadata' => array('langcode' => 'en'),
- ),
- ),
+ ],
+ 'metadata' => ['langcode' => 'en'],
+ ],
+ ],
'id' => 'foo:0=bar&key=baz&1=qux:langcode=en',
- );
+ ];
// Test branch conditions:
// - one group.
// - one dynamic path argument.
// - metadata.
- $tests[] = array(
- 'links' => array(
- 'views_ui_edit' => array(
- 'route_parameters' => array(
+ $tests[] = [
+ 'links' => [
+ 'views_ui_edit' => [
+ 'route_parameters' => [
'view' => 'frontpage'
- ),
- 'metadata' => array(
+ ],
+ 'metadata' => [
'location' => 'page',
'display' => 'page_1',
'langcode' => 'en',
- ),
- ),
- ),
+ ],
+ ],
+ ],
'id' => 'views_ui_edit:view=frontpage:location=page&display=page_1&langcode=en',
- );
+ ];
// Test branch conditions:
// - multiple groups.
// - multiple dynamic path arguments.
- $tests[] = array(
- 'links' => array(
- 'node' => array(
- 'route_parameters' => array(
+ $tests[] = [
+ 'links' => [
+ 'node' => [
+ 'route_parameters' => [
'node' => '14031991',
- ),
- 'metadata' => array('langcode' => 'en'),
- ),
- 'foo' => array(
- 'route_parameters' => array(
+ ],
+ 'metadata' => ['langcode' => 'en'],
+ ],
+ 'foo' => [
+ 'route_parameters' => [
'bar',
'key' => 'baz',
'qux',
- ),
- 'metadata' => array('langcode' => 'en'),
- ),
- 'edge' => array(
- 'route_parameters' => array('20011988'),
- 'metadata' => array('langcode' => 'en'),
- ),
- ),
+ ],
+ 'metadata' => ['langcode' => 'en'],
+ ],
+ 'edge' => [
+ 'route_parameters' => ['20011988'],
+ 'metadata' => ['langcode' => 'en'],
+ ],
+ ],
'id' => 'node:node=14031991:langcode=en|foo:0=bar&key=baz&1=qux:langcode=en|edge:0=20011988:langcode=en',
- );
+ ];
return $tests;
}
diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module
index 10785419927..bb10d13a6ce 100644
--- a/core/modules/datetime/datetime.module
+++ b/core/modules/datetime/datetime.module
@@ -30,13 +30,13 @@ function datetime_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.datetime':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Datetime module provides a Date field that stores dates and times. It also provides the Form API elements <em>datetime</em> and <em>datelist</em> for use in programming modules. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI module help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":datetime_do">online documentation for the Datetime module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':datetime_do' => 'https://www.drupal.org/documentation/modules/datetime')) . '</p>';
+ $output .= '<p>' . t('The Datetime module provides a Date field that stores dates and times. It also provides the Form API elements <em>datetime</em> and <em>datelist</em> for use in programming modules. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI module help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":datetime_do">online documentation for the Datetime module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':datetime_do' => 'https://www.drupal.org/documentation/modules/datetime']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying date fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the Date field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the Date field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Displaying dates') . '</dt>';
- $output .= '<dd>' . t('Dates can be displayed using the <em>Plain</em> or the <em>Default</em> formatter. The <em>Plain</em> formatter displays the date in the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format. If you choose the <em>Default</em> formatter, you can choose a format from a predefined list that can be managed on the <a href=":date_format_list">Date and time formats</a> page.', array(':date_format_list' => \Drupal::url('entity.date_format.collection'))) . '</dd>';
+ $output .= '<dd>' . t('Dates can be displayed using the <em>Plain</em> or the <em>Default</em> formatter. The <em>Plain</em> formatter displays the date in the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format. If you choose the <em>Default</em> formatter, you can choose a format from a predefined list that can be managed on the <a href=":date_format_list">Date and time formats</a> page.', [':date_format_list' => \Drupal::url('entity.date_format.collection')]) . '</dd>';
$output .= '</dl>';
return $output;
}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php
index fe5fa752e32..984423d07f5 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php
@@ -23,9 +23,9 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'date_format' => DATETIME_DATETIME_STORAGE_FORMAT,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -35,7 +35,7 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase {
// @todo Evaluate removing this method in
// https://www.drupal.org/node/2793143 to determine if the behavior and
// markup in the base class implementation can be used instead.
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
if (!empty($item->date)) {
@@ -64,12 +64,12 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase {
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
- $form['date_format'] = array(
+ $form['date_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Date/time format'),
'#description' => $this->t('See <a href="http://php.net/manual/function.date.php" target="_blank">the documentation for PHP date formats</a>.'),
'#default_value' => $this->getSetting('date_format'),
- );
+ ];
return $form;
}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
index 8f703fbc9ed..0b75b4e57ae 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
@@ -22,9 +22,9 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'format_type' => 'medium',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -50,13 +50,13 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
$options[$type] = $type_info->label() . ' (' . $format . ')';
}
- $form['format_type'] = array(
+ $form['format_type'] = [
'#type' => 'select',
'#title' => t('Date format'),
'#description' => t("Choose a format for displaying the date. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date."),
'#options' => $options,
'#default_value' => $this->getSetting('format_type'),
- );
+ ];
return $form;
}
@@ -68,7 +68,7 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
$summary = parent::settingsSummary();
$date = new DrupalDateTime();
- $summary[] = t('Format: @display', array('@display' => $this->formatDate($date, $this->getFormatSettings())));
+ $summary[] = t('Format: @display', ['@display' => $this->formatDate($date, $this->getFormatSettings())]);
return $summary;
}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php
index 22e5aa830ae..71b94670f4d 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php
@@ -83,9 +83,9 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'timezone_override' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -94,13 +94,13 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
- $form['timezone_override'] = array(
+ $form['timezone_override'] = [
'#type' => 'select',
'#title' => $this->t('Time zone override'),
'#description' => $this->t('The time zone selected here will always be used'),
'#options' => system_time_zones(TRUE),
'#default_value' => $this->getSetting('timezone_override'),
- );
+ ];
return $form;
}
@@ -112,7 +112,7 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
$summary = parent::settingsSummary();
if ($override = $this->getSetting('timezone_override')) {
- $summary[] = $this->t('Time zone: @timezone', array('@timezone' => $override));
+ $summary[] = $this->t('Time zone: @timezone', ['@timezone' => $override]);
}
return $summary;
@@ -122,7 +122,7 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
if ($item->date) {
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php
index 5bb676600fb..7f0dee2c31d 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php
@@ -22,7 +22,7 @@ class DateTimePlainFormatter extends DateTimeFormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
if (!empty($item->date)) {
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php
index 859ea5da72c..3fc31576167 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php
@@ -74,11 +74,11 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
* {@inheritdoc}
*/
public static function defaultSettings() {
- $settings = array(
+ $settings = [
'future_format' => '@interval hence',
'past_format' => '@interval ago',
'granularity' => 2,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
return $settings;
}
@@ -104,7 +104,7 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
$date = $item->date;
@@ -128,26 +128,26 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
- $form['future_format'] = array(
+ $form['future_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Future format'),
'#default_value' => $this->getSetting('future_format'),
'#description' => $this->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
- );
+ ];
- $form['past_format'] = array(
+ $form['past_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Past format'),
'#default_value' => $this->getSetting('past_format'),
'#description' => $this->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
- );
+ ];
- $form['granularity'] = array(
+ $form['granularity'] = [
'#type' => 'number',
'#title' => $this->t('Granularity'),
'#default_value' => $this->getSetting('granularity'),
'#description' => $this->t('How many time units should be shown in the formatted output.'),
- );
+ ];
return $form;
}
@@ -160,8 +160,8 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
$future_date = new DrupalDateTime('1 year 1 month 1 week 1 day 1 hour 1 minute');
$past_date = new DrupalDateTime('-1 year -1 month -1 week -1 day -1 hour -1 minute');
- $summary[] = t('Future date: %display', array('%display' => $this->formatDate($future_date)));
- $summary[] = t('Past date: %display', array('%display' => $this->formatDate($past_date)));
+ $summary[] = t('Future date: %display', ['%display' => $this->formatDate($future_date)]);
+ $summary[] = t('Past date: %display', ['%display' => $this->formatDate($past_date)]);
return $summary;
}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
index d246011ae21..45a781b4b98 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
@@ -30,31 +30,31 @@ class DateTimeFieldItemList extends FieldItemList {
if (empty($this->getFieldDefinition()->getDefaultValueCallback())) {
$default_value = $this->getFieldDefinition()->getDefaultValueLiteral();
- $element = array(
- '#parents' => array('default_value_input'),
- 'default_date_type' => array(
+ $element = [
+ '#parents' => ['default_value_input'],
+ 'default_date_type' => [
'#type' => 'select',
'#title' => t('Default date'),
'#description' => t('Set a default value for this date.'),
'#default_value' => isset($default_value[0]['default_date_type']) ? $default_value[0]['default_date_type'] : '',
- '#options' => array(
+ '#options' => [
static::DEFAULT_VALUE_NOW => t('Current date'),
static::DEFAULT_VALUE_CUSTOM => t('Relative date'),
- ),
+ ],
'#empty_value' => '',
- ),
- 'default_date' => array(
+ ],
+ 'default_date' => [
'#type' => 'textfield',
'#title' => t('Relative default value'),
'#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See <a href=\"http://php.net/manual/function.strtotime.php\">strtotime</a> for more details."),
'#default_value' => (isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] == static::DEFAULT_VALUE_CUSTOM) ? $default_value[0]['default_date'] : '',
- '#states' => array(
- 'visible' => array(
- ':input[id="edit-default-value-input-default-date-type"]' => array('value' => static::DEFAULT_VALUE_CUSTOM),
- )
- )
- )
- );
+ '#states' => [
+ 'visible' => [
+ ':input[id="edit-default-value-input-default-date-type"]' => ['value' => static::DEFAULT_VALUE_CUSTOM],
+ ]
+ ]
+ ]
+ ];
return $element;
}
@@ -65,7 +65,7 @@ class DateTimeFieldItemList extends FieldItemList {
*/
public function defaultValuesFormValidate(array $element, array &$form, FormStateInterface $form_state) {
if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_CUSTOM) {
- $is_strtotime = @strtotime($form_state->getValue(array('default_value_input', 'default_date')));
+ $is_strtotime = @strtotime($form_state->getValue(['default_value_input', 'default_date']));
if (!$is_strtotime) {
$form_state->setErrorByName('default_value_input][default_date', t('The relative date value entered is invalid.'));
}
@@ -76,13 +76,13 @@ class DateTimeFieldItemList extends FieldItemList {
* {@inheritdoc}
*/
public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) {
- if ($form_state->getValue(array('default_value_input', 'default_date_type'))) {
- if ($form_state->getValue(array('default_value_input', 'default_date_type')) == static::DEFAULT_VALUE_NOW) {
+ if ($form_state->getValue(['default_value_input', 'default_date_type'])) {
+ if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_NOW) {
$form_state->setValueForElement($element['default_date'], static::DEFAULT_VALUE_NOW);
}
- return array($form_state->getValue('default_value_input'));
+ return [$form_state->getValue('default_value_input')];
}
- return array();
+ return [];
}
/**
@@ -108,12 +108,12 @@ class DateTimeFieldItemList extends FieldItemList {
// We only provide a default value for the first item, as do all fields.
// Otherwise, there is no way to clear out unwanted values on multiple value
// fields.
- $default_value = array(
- array(
+ $default_value = [
+ [
'value' => $value,
'date' => $date,
- )
- );
+ ]
+ ];
}
return $default_value;
}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php
index f07d56409f4..f5c06e6e5dd 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php
@@ -26,9 +26,9 @@ class DateTimeItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'datetime_type' => 'datetime',
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
@@ -63,37 +63,37 @@ class DateTimeItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'description' => 'The date value.',
'type' => 'varchar',
'length' => 20,
- ),
- ),
- 'indexes' => array(
- 'value' => array('value'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'value' => ['value'],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element = array();
+ $element = [];
- $element['datetime_type'] = array(
+ $element['datetime_type'] = [
'#type' => 'select',
'#title' => t('Date type'),
'#description' => t('Choose the type of date to create.'),
'#default_value' => $this->getSetting('datetime_type'),
- '#options' => array(
+ '#options' => [
static::DATETIME_TYPE_DATETIME => t('Date and time'),
static::DATETIME_TYPE_DATE => t('Date only'),
- ),
+ ],
'#disabled' => $has_data,
- );
+ ];
return $element;
}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php
index 06ced059e3f..d1309767f47 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php
@@ -22,11 +22,11 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'increment' => '15',
'date_order' => 'YMD',
'time_type' => '24',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -52,35 +52,35 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
// Set up the date part order array.
switch ($date_order) {
case 'YMD':
- $date_part_order = array('year', 'month', 'day');
+ $date_part_order = ['year', 'month', 'day'];
break;
case 'MDY':
- $date_part_order = array('month', 'day', 'year');
+ $date_part_order = ['month', 'day', 'year'];
break;
case 'DMY':
- $date_part_order = array('day', 'month', 'year');
+ $date_part_order = ['day', 'month', 'year'];
break;
}
switch ($time_type) {
case '24':
- $date_part_order = array_merge($date_part_order, array('hour', 'minute'));
+ $date_part_order = array_merge($date_part_order, ['hour', 'minute']);
break;
case '12':
- $date_part_order = array_merge($date_part_order, array('hour', 'minute', 'ampm'));
+ $date_part_order = array_merge($date_part_order, ['hour', 'minute', 'ampm']);
break;
case 'none':
break;
}
- $element['value'] = array(
+ $element['value'] = [
'#type' => 'datelist',
'#date_increment' => $increment,
'#date_part_order' => $date_part_order,
- ) + $element['value'];
+ ] + $element['value'];
return $element;
}
@@ -91,20 +91,20 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
- $element['date_order'] = array(
+ $element['date_order'] = [
'#type' => 'select',
'#title' => t('Date part order'),
'#default_value' => $this->getSetting('date_order'),
- '#options' => array('MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')),
- );
+ '#options' => ['MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')],
+ ];
if ($this->getFieldSetting('datetime_type') == 'datetime') {
- $element['time_type'] = array(
+ $element['time_type'] = [
'#type' => 'select',
'#title' => t('Time type'),
'#default_value' => $this->getSetting('time_type'),
- '#options' => array('24' => t('24 hour time'), '12' => t('12 hour time')),
- );
+ '#options' => ['24' => t('24 hour time'), '12' => t('12 hour time')],
+ ];
$element['increment'] = [
'#type' => 'select',
@@ -120,10 +120,10 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
];
}
else {
- $element['time_type'] = array(
+ $element['time_type'] = [
'#type' => 'hidden',
'#value' => 'none',
- );
+ ];
$element['increment'] = [
'#type' => 'hidden',
@@ -138,12 +138,12 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
- $summary[] = t('Date part order: @order', array('@order' => $this->getSetting('date_order')));
+ $summary[] = t('Date part order: @order', ['@order' => $this->getSetting('date_order')]);
if ($this->getFieldSetting('datetime_type') == 'datetime') {
- $summary[] = t('Time type: @time_type', array('@time_type' => $this->getSetting('time_type')));
- $summary[] = t('Time increments: @increment', array('@increment' => $this->getSetting('increment')));
+ $summary[] = t('Time type: @time_type', ['@time_type' => $this->getSetting('time_type')]);
+ $summary[] = t('Time increments: @increment', ['@increment' => $this->getSetting('increment')]);
}
return $summary;
diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php
index 6d03ffd4180..2a4ffcd2975 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php
@@ -86,14 +86,14 @@ class DateTimeDefaultWidget extends DateTimeWidgetBase implements ContainerFacto
break;
}
- $element['value'] += array(
+ $element['value'] += [
'#date_date_format' => $date_format,
'#date_date_element' => $date_type,
- '#date_date_callbacks' => array(),
+ '#date_date_callbacks' => [],
'#date_time_format' => $time_format,
'#date_time_element' => $time_type,
- '#date_time_callbacks' => array(),
- );
+ '#date_time_callbacks' => [],
+ ];
return $element;
}
diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php
index b363eed8adc..f965e218489 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php
@@ -17,13 +17,13 @@ class DateTimeWidgetBase extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = array(
+ $element['value'] = [
'#type' => 'datetime',
'#default_value' => NULL,
'#date_increment' => 1,
'#date_timezone' => drupal_get_user_timezone(),
'#required' => $element['#required'],
- );
+ ];
if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) {
// A date-only field should have no timezone conversion performed, so
diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
index 67e5183ccdf..aeed9bc7a0c 100644
--- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php
+++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
@@ -63,13 +63,13 @@ class DateTimeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date->format($date_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($date->format($date_format));
$this->assertNoRaw($date->format($time_format));
@@ -87,15 +87,15 @@ class DateTimeFieldTest extends DateTestBase {
$this->assertEqual('2012-12-31', $entity->{$field_name}->value);
// Reset display options since these get changed below.
- $this->displayOptions = array(
+ $this->displayOptions = [
'type' => 'datetime_default',
'label' => 'hidden',
- 'settings' => array('format_type' => 'medium') + $this->defaultSettings,
- );
+ 'settings' => ['format_type' => 'medium'] + $this->defaultSettings,
+ ];
// Verify that the date is output according to the formatter settings.
- $options = array(
- 'format_type' => array('short', 'medium', 'long'),
- );
+ $options = [
+ 'format_type' => ['short', 'medium', 'long'],
+ ];
// Formats that display a time component for date-only fields will display
// the default time, so that is applied before calculating the expected
// value.
@@ -103,7 +103,7 @@ class DateTimeFieldTest extends DateTestBase {
foreach ($options as $setting => $values) {
foreach ($values as $new_value) {
// Update the entity display settings.
- $this->displayOptions['settings'] = array($setting => $new_value) + $this->defaultSettings;
+ $this->displayOptions['settings'] = [$setting => $new_value] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
@@ -116,7 +116,7 @@ class DateTimeFieldTest extends DateTestBase {
$expected = format_date($date->getTimestamp(), $new_value, '', DATETIME_STORAGE_TIMEZONE);
$expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE);
$this->renderTestEntity($id);
- $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', array('%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso)));
+ $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso]));
break;
}
}
@@ -130,17 +130,17 @@ class DateTimeFieldTest extends DateTestBase {
->save();
$expected = $date->format(DATETIME_DATE_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_custom' formatter works.
$this->displayOptions['type'] = 'datetime_custom';
- $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings;
+ $this->displayOptions['settings'] = ['date_format' => 'm/d/Y'] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected]));
// Test that allowed markup in custom format is preserved and XSS is
// removed.
@@ -150,7 +150,7 @@ class DateTimeFieldTest extends DateTestBase {
->save();
$expected = '<strong>' . $date->format('m/d/Y') . '</strong>alert(String.fromCharCode(88,83,83))';
$this->renderTestEntity($id);
- $this->assertRaw($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertRaw($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_time_ago' formatter works for intervals in the
// past. First update the test entity so that the date difference always
@@ -165,11 +165,11 @@ class DateTimeFieldTest extends DateTestBase {
$entity->save();
$this->displayOptions['type'] = 'datetime_time_ago';
- $this->displayOptions['settings'] = array(
+ $this->displayOptions['settings'] = [
'future_format' => '@interval in the future',
'past_format' => '@interval in the past',
'granularity' => 3,
- );
+ ];
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
@@ -177,7 +177,7 @@ class DateTimeFieldTest extends DateTestBase {
'@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']])
]);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_time_ago' formatter works for intervals in the
// future. First update the test entity so that the date difference always
@@ -198,7 +198,7 @@ class DateTimeFieldTest extends DateTestBase {
'@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']])
]);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
}
}
@@ -230,25 +230,25 @@ class DateTimeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date->format($date_format),
"{$field_name}[0][value][time]" => $date->format($time_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($date->format($date_format));
$this->assertRaw($date->format($time_format));
// Verify that the date is output according to the formatter settings.
- $options = array(
- 'format_type' => array('short', 'medium', 'long'),
- );
+ $options = [
+ 'format_type' => ['short', 'medium', 'long'],
+ ];
foreach ($options as $setting => $values) {
foreach ($values as $new_value) {
// Update the entity display settings.
- $this->displayOptions['settings'] = array($setting => $new_value) + $this->defaultSettings;
+ $this->displayOptions['settings'] = [$setting => $new_value] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
@@ -260,7 +260,7 @@ class DateTimeFieldTest extends DateTestBase {
$expected = format_date($date->getTimestamp(), $new_value);
$expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC');
$this->renderTestEntity($id);
- $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', array('%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso)));
+ $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso]));
break;
}
}
@@ -274,27 +274,27 @@ class DateTimeFieldTest extends DateTestBase {
->save();
$expected = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_custom' formatter works.
$this->displayOptions['type'] = 'datetime_custom';
- $this->displayOptions['settings'] = array('date_format' => 'm/d/Y g:i:s A') + $this->defaultSettings;
+ $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A'] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'timezone_override' setting works.
$this->displayOptions['type'] = 'datetime_custom';
- $this->displayOptions['settings'] = array('date_format' => 'm/d/Y g:i:s A', 'timezone_override' => 'America/New_York') + $this->defaultSettings;
+ $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A', 'timezone_override' => 'America/New_York'] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
- $expected = $date->format($this->displayOptions['settings']['date_format'], array('timezone' => 'America/New_York'));
+ $expected = $date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_time_ago' formatter works for intervals in the
// past. First update the test entity so that the date difference always
@@ -309,11 +309,11 @@ class DateTimeFieldTest extends DateTestBase {
$entity->save();
$this->displayOptions['type'] = 'datetime_time_ago';
- $this->displayOptions['settings'] = array(
+ $this->displayOptions['settings'] = [
'future_format' => '@interval from now',
'past_format' => '@interval earlier',
'granularity' => 3,
- );
+ ];
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
@@ -321,7 +321,7 @@ class DateTimeFieldTest extends DateTestBase {
'@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']])
]);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_time_ago' formatter works for intervals in the
// future. First update the test entity so that the date difference always
@@ -342,7 +342,7 @@ class DateTimeFieldTest extends DateTestBase {
'@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']])
]);
$this->renderTestEntity($id);
- $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
}
/**
@@ -357,12 +357,12 @@ class DateTimeFieldTest extends DateTestBase {
// Change the widget to a datelist widget.
entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'datetime_datelist',
- 'settings' => array(
+ 'settings' => [
'date_order' => 'YMD',
- ),
- ))
+ ],
+ ])
->save();
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -381,7 +381,7 @@ class DateTimeFieldTest extends DateTestBase {
$this->drupalGet($fieldEditUrl);
// Click on the widget settings button to open the widget settings form.
- $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit");
$xpathIncr = "//select[starts-with(@id, \"edit-fields-$field_name-settings-edit-form-settings-increment\")]";
$this->assertNoFieldByXPath($xpathIncr, NULL, 'Increment element not found for Date Only.');
@@ -391,14 +391,14 @@ class DateTimeFieldTest extends DateTestBase {
// Change the widget to a datelist widget.
entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'datetime_datelist',
- 'settings' => array(
+ 'settings' => [
'increment' => 1,
'date_order' => 'YMD',
'time_type' => '12',
- ),
- ))
+ ],
+ ])
->save();
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -407,7 +407,7 @@ class DateTimeFieldTest extends DateTestBase {
$this->drupalGet($fieldEditUrl);
// Click on the widget settings button to open the widget settings form.
- $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit");
$this->assertFieldByXPath($xpathIncr, NULL, 'Increment element found for Date and time.');
// Display creation form.
@@ -434,9 +434,9 @@ class DateTimeFieldTest extends DateTestBase {
$this->assertOptionByText("edit-$field_name-0-value-ampm", t('AM/PM'));
// Submit a valid date and ensure it is accepted.
- $date_value = array('year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15);
+ $date_value = ['year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15];
- $edit = array();
+ $edit = [];
// Add the ampm indicator since we are testing 12 hour time.
$date_value['ampm'] = 'am';
foreach ($date_value as $part => $value) {
@@ -446,7 +446,7 @@ class DateTimeFieldTest extends DateTestBase {
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.');
@@ -457,14 +457,14 @@ class DateTimeFieldTest extends DateTestBase {
// Test the widget using increment other than 1 and 24 hour mode.
entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'datetime_datelist',
- 'settings' => array(
+ 'settings' => [
'increment' => 15,
'date_order' => 'YMD',
'time_type' => '24',
- ),
- ))
+ ],
+ ])
->save();
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -477,9 +477,9 @@ class DateTimeFieldTest extends DateTestBase {
$this->assertNoFieldByXPath("//*[@id=\"edit-$field_name-0-value-ampm\"]", NULL, 'AMPM element not found.');
// Submit a valid date and ensure it is accepted.
- $date_value = array('year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 17, 'minute' => 15);
+ $date_value = ['year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 17, 'minute' => 15];
- $edit = array();
+ $edit = [];
foreach ($date_value as $part => $value) {
$edit["{$field_name}[0][value][$part]"] = $value;
}
@@ -487,7 +487,7 @@ class DateTimeFieldTest extends DateTestBase {
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.');
@@ -497,14 +497,14 @@ class DateTimeFieldTest extends DateTestBase {
// Test the widget for partial completion of fields.
entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'datetime_datelist',
- 'settings' => array(
+ 'settings' => [
'increment' => 1,
'date_order' => 'YMD',
'time_type' => '24',
- ),
- ))
+ ],
+ ])
->save();
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -516,7 +516,7 @@ class DateTimeFieldTest extends DateTestBase {
$this->drupalGet('entity_test/add');
// Submit a partial date and ensure and error message is provided.
- $edit = array();
+ $edit = [];
foreach ($date_value as $part => $value) {
$edit["{$field_name}[0][value][$part]"] = $value;
}
@@ -531,8 +531,8 @@ class DateTimeFieldTest extends DateTestBase {
// Test the widget for complete input with zeros as part of selections.
$this->drupalGet('entity_test/add');
- $date_value = array('year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '0', 'minute' => '0');
- $edit = array();
+ $date_value = ['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '0', 'minute' => '0'];
+ $edit = [];
foreach ($date_value as $part => $value) {
$edit["{$field_name}[0][value][$part]"] = $value;
}
@@ -541,13 +541,13 @@ class DateTimeFieldTest extends DateTestBase {
$this->assertResponse(200);
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
// Test the widget to ensure zeros are not deselected on validation.
$this->drupalGet('entity_test/add');
- $date_value = array('year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '', 'minute' => '0');
- $edit = array();
+ $date_value = ['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '', 'minute' => '0'];
+ $edit = [];
foreach ($date_value as $part => $value) {
$edit["{$field_name}[0][value][$part]"] = $value;
}
@@ -595,16 +595,16 @@ class DateTimeFieldTest extends DateTestBase {
*/
function testDefaultValue() {
// Create a test content type.
- $this->drupalCreateContentType(array('type' => 'date_content'));
+ $this->drupalCreateContentType(['type' => 'date_content']);
// Create a field storage with settings to validate.
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'datetime',
- 'settings' => array('datetime_type' => 'date'),
- ));
+ 'settings' => ['datetime_type' => 'date'],
+ ]);
$field_storage->save();
$field = FieldConfig::create([
@@ -620,9 +620,9 @@ class DateTimeFieldTest extends DateTestBase {
$this->setSiteTimezone($timezone);
// Set now as default_value.
- $field_edit = array(
+ $field_edit = [
'default_value_input[default_date_type]' => 'now',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings'));
// Check that default value is selected in default value form.
@@ -633,10 +633,10 @@ class DateTimeFieldTest extends DateTestBase {
// Check if default_date has been stored successfully.
$config_entity = $this->config('field.field.node.date_content.' . $field_name)
->get();
- $this->assertEqual($config_entity['default_value'][0], array(
+ $this->assertEqual($config_entity['default_value'][0], [
'default_date_type' => 'now',
'default_date' => 'now',
- ), 'Default value has been stored successfully');
+ ], 'Default value has been stored successfully');
// Clear field cache in order to avoid stale cache values.
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -648,19 +648,19 @@ class DateTimeFieldTest extends DateTestBase {
->offsetGet(0)->value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT));
// Set an invalid relative default_value to test validation.
- $field_edit = array(
+ $field_edit = [
'default_value_input[default_date_type]' => 'relative',
'default_value_input[default_date]' => 'invalid date',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings'));
$this->assertText('The relative date value entered is invalid.');
// Set a relative default_value.
- $field_edit = array(
+ $field_edit = [
'default_value_input[default_date_type]' => 'relative',
'default_value_input[default_date]' => '+90 days',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings'));
// Check that default value is selected in default value form.
@@ -671,10 +671,10 @@ class DateTimeFieldTest extends DateTestBase {
// Check if default_date has been stored successfully.
$config_entity = $this->config('field.field.node.date_content.' . $field_name)
->get();
- $this->assertEqual($config_entity['default_value'][0], array(
+ $this->assertEqual($config_entity['default_value'][0], [
'default_date_type' => 'relative',
'default_date' => '+90 days',
- ), 'Default value has been stored successfully');
+ ], 'Default value has been stored successfully');
// Clear field cache in order to avoid stale cache values.
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -687,9 +687,9 @@ class DateTimeFieldTest extends DateTestBase {
->offsetGet(0)->value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT));
// Remove default value.
- $field_edit = array(
+ $field_edit = [
'default_value_input[default_date_type]' => '',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings'));
// Check that default value is selected in default value form.
@@ -728,72 +728,72 @@ class DateTimeFieldTest extends DateTestBase {
// Submit invalid dates and ensure they is not accepted.
$date_value = '';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => '12:00:00',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText('date is invalid', 'Empty date value has been caught.');
$date_value = 'aaaa-12-01';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => '00:00:00',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText('date is invalid', format_string('Invalid year value %date has been caught.', array('%date' => $date_value)));
+ $this->assertText('date is invalid', format_string('Invalid year value %date has been caught.', ['%date' => $date_value]));
$date_value = '2012-75-01';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => '00:00:00',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText('date is invalid', format_string('Invalid month value %date has been caught.', array('%date' => $date_value)));
+ $this->assertText('date is invalid', format_string('Invalid month value %date has been caught.', ['%date' => $date_value]));
$date_value = '2012-12-99';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => '00:00:00',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText('date is invalid', format_string('Invalid day value %date has been caught.', array('%date' => $date_value)));
+ $this->assertText('date is invalid', format_string('Invalid day value %date has been caught.', ['%date' => $date_value]));
$date_value = '2012-12-01';
$time_value = '';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => $time_value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText('date is invalid', 'Empty time value has been caught.');
$date_value = '2012-12-01';
$time_value = '49:00:00';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => $time_value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText('date is invalid', format_string('Invalid hour value %time has been caught.', array('%time' => $time_value)));
+ $this->assertText('date is invalid', format_string('Invalid hour value %time has been caught.', ['%time' => $time_value]));
$date_value = '2012-12-01';
$time_value = '12:99:00';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => $time_value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText('date is invalid', format_string('Invalid minute value %time has been caught.', array('%time' => $time_value)));
+ $this->assertText('date is invalid', format_string('Invalid minute value %time has been caught.', ['%time' => $time_value]));
$date_value = '2012-12-01';
$time_value = '12:15:99';
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $date_value,
"{$field_name}[0][value][time]" => $time_value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText('date is invalid', format_string('Invalid second value %time has been caught.', array('%time' => $time_value)));
+ $this->assertText('date is invalid', format_string('Invalid second value %time has been caught.', ['%time' => $time_value]));
}
/**
diff --git a/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php b/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php
index 424cbd98c67..e28667f0725 100644
--- a/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php
+++ b/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php
@@ -36,25 +36,25 @@ class DateTimeItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('datetime');
+ public static $modules = ['datetime'];
protected function setUp() {
parent::setUp();
// Create a field with settings to validate.
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => 'field_datetime',
'type' => 'datetime',
'entity_type' => 'entity_test',
- 'settings' => array('datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME),
- ));
+ 'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME],
+ ]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
- 'settings' => array(
+ 'settings' => [
'default_value' => 'blank',
- ),
+ ],
]);
$this->field->save();
}
diff --git a/core/modules/datetime_range/datetime_range.module b/core/modules/datetime_range/datetime_range.module
index ceeb99dd8a5..b2b87dae7ae 100644
--- a/core/modules/datetime_range/datetime_range.module
+++ b/core/modules/datetime_range/datetime_range.module
@@ -15,13 +15,13 @@ function datetime_range_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.datetime_range':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Datetime Range module provides a Date field that stores start dates and times, as well as end dates and times. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI module help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":datetime_do">online documentation for the Datetime Range module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':datetime_do' => 'https://www.drupal.org/documentation/modules/datetime_range')) . '</p>';
+ $output .= '<p>' . t('The Datetime Range module provides a Date field that stores start dates and times, as well as end dates and times. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI module help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":datetime_do">online documentation for the Datetime Range module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':datetime_do' => 'https://www.drupal.org/documentation/modules/datetime_range']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying date fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the Date field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the Date field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Displaying dates') . '</dt>';
- $output .= '<dd>' . t('Dates can be displayed using the <em>Plain</em> or the <em>Default</em> formatter. The <em>Plain</em> formatter displays the date in the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format. If you choose the <em>Default</em> formatter, you can choose a format from a predefined list that can be managed on the <a href=":date_format_list">Date and time formats</a> page.', array(':date_format_list' => \Drupal::url('entity.date_format.collection'))) . '</dd>';
+ $output .= '<dd>' . t('Dates can be displayed using the <em>Plain</em> or the <em>Default</em> formatter. The <em>Plain</em> formatter displays the date in the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format. If you choose the <em>Default</em> formatter, you can choose a format from a predefined list that can be managed on the <a href=":date_format_list">Date and time formats</a> page.', [':date_format_list' => \Drupal::url('entity.date_format.collection')]) . '</dd>';
$output .= '</dl>';
return $output;
}
diff --git a/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php b/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php
index b2d259ad41c..f5533150ee5 100644
--- a/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php
+++ b/core/modules/datetime_range/src/Tests/DateRangeFieldTest.php
@@ -78,14 +78,14 @@ class DateRangeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $start_date->format($date_format),
"{$field_name}[0][end_value][date]" => $end_date->format($date_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($start_date->format($date_format));
$this->assertNoRaw($start_date->format($time_format));
$this->assertRaw($end_date->format($date_format));
@@ -156,17 +156,17 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATE_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
// Verify that the custom formatter works.
$this->displayOptions['type'] = 'daterange_custom';
- $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings;
+ $this->displayOptions['settings'] = ['date_format' => 'm/d/Y'] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
// Test that allowed markup in custom format is preserved and XSS is
// removed.
@@ -176,7 +176,7 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = '<strong>' . $start_date->format('m/d/Y') . '</strong>alert(String.fromCharCode(88,83,83)) - <strong>' . $end_date->format('m/d/Y') . '</strong>alert(String.fromCharCode(88,83,83))';
$this->renderTestEntity($id);
- $this->assertRaw($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertRaw($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
// Test formatters when start date and end date are the same
$this->drupalGet('entity_test/add');
@@ -186,15 +186,15 @@ class DateRangeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $start_date->format($date_format),
"{$field_name}[0][end_value][date]" => $start_date->format($date_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
datetime_date_default_time($start_date);
@@ -233,17 +233,17 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
$this->assertNoText(' THESEPARATOR ', 'Separator not found on page');
$this->displayOptions['type'] = 'daterange_custom';
- $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings;
+ $this->displayOptions['settings'] = ['date_format' => 'm/d/Y'] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
$this->assertNoText(' THESEPARATOR ', 'Separator not found on page');
}
}
@@ -282,16 +282,16 @@ class DateRangeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $start_date->format($date_format),
"{$field_name}[0][value][time]" => $start_date->format($time_format),
"{$field_name}[0][end_value][date]" => $end_date->format($date_format),
"{$field_name}[0][end_value][time]" => $end_date->format($time_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($start_date->format($date_format));
$this->assertRaw($start_date->format($time_format));
$this->assertRaw($end_date->format($date_format));
@@ -328,7 +328,7 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_custom' formatter works.
$this->displayOptions['type'] = 'daterange_custom';
@@ -338,7 +338,7 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'timezone_override' setting works.
$this->displayOptions['type'] = 'daterange_custom';
@@ -349,7 +349,7 @@ class DateRangeFieldTest extends DateTestBase {
$expected = $start_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']);
$expected .= ' - ' . $end_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
// Test formatters when start date and end date are the same
$this->drupalGet('entity_test/add');
@@ -360,17 +360,17 @@ class DateRangeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $start_date->format($date_format),
"{$field_name}[0][value][time]" => $start_date->format($time_format),
"{$field_name}[0][end_value][date]" => $start_date->format($date_format),
"{$field_name}[0][end_value][time]" => $start_date->format($time_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->displayOptions = [
'type' => 'daterange_default',
@@ -403,7 +403,7 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
$this->assertNoText(' THESEPARATOR ', 'Separator not found on page');
$this->displayOptions['type'] = 'daterange_custom';
@@ -413,7 +413,7 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
$this->assertNoText(' THESEPARATOR ', 'Separator not found on page');
}
@@ -448,14 +448,14 @@ class DateRangeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $start_date->format($date_format),
"{$field_name}[0][end_value][date]" => $end_date->format($date_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($start_date->format($date_format));
$this->assertNoRaw($start_date->format($time_format));
$this->assertRaw($end_date->format($date_format));
@@ -492,17 +492,17 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
// Verify that the custom formatter works.
$this->displayOptions['type'] = 'daterange_custom';
- $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings;
+ $this->displayOptions['settings'] = ['date_format' => 'm/d/Y'] + $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' - ' . $end_date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'timezone_override' setting works.
$this->displayOptions['type'] = 'daterange_custom';
@@ -513,7 +513,7 @@ class DateRangeFieldTest extends DateTestBase {
$expected = $start_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']);
$expected .= ' - ' . $end_date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
// Test formatters when start date and end date are the same
$this->drupalGet('entity_test/add');
@@ -526,14 +526,14 @@ class DateRangeFieldTest extends DateTestBase {
$date_format = DateFormat::load('html_date')->getPattern();
$time_format = DateFormat::load('html_time')->getPattern();
- $edit = array(
+ $edit = [
"{$field_name}[0][value][date]" => $start_date->format($date_format),
"{$field_name}[0][end_value][date]" => $start_date->format($date_format),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->displayOptions = [
'type' => 'daterange_default',
@@ -568,7 +568,7 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' THESEPARATOR ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
$this->assertText(' THESEPARATOR ', 'Found proper separator');
$this->displayOptions['type'] = 'daterange_custom';
@@ -578,7 +578,7 @@ class DateRangeFieldTest extends DateTestBase {
->save();
$expected = $start_date->format($this->displayOptions['settings']['date_format']) . ' THESEPARATOR ' . $end_date->format($this->displayOptions['settings']['date_format']);
$this->renderTestEntity($id);
- $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', array('%expected' => $expected)));
+ $this->assertText($expected, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected.', ['%expected' => $expected]));
$this->assertText(' THESEPARATOR ', 'Found proper separator');
}
diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc
index 2b08878c5ce..1af89a63ae3 100644
--- a/core/modules/dblog/dblog.admin.inc
+++ b/core/modules/dblog/dblog.admin.inc
@@ -19,25 +19,25 @@ use Drupal\Core\Logger\RfcLogLevel;
* - options: Array of options for the select list for the filter.
*/
function dblog_filters() {
- $filters = array();
+ $filters = [];
foreach (_dblog_get_message_types() as $type) {
$types[$type] = t($type);
}
if (!empty($types)) {
- $filters['type'] = array(
+ $filters['type'] = [
'title' => t('Type'),
'where' => "w.type = ?",
'options' => $types,
- );
+ ];
}
- $filters['severity'] = array(
+ $filters['severity'] = [
'title' => t('Severity'),
'where' => 'w.severity = ?',
'options' => RfcLogLevel::getLevels(),
- );
+ ];
return $filters;
}
diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install
index 08270d2b4d0..f226ed04d9c 100644
--- a/core/modules/dblog/dblog.install
+++ b/core/modules/dblog/dblog.install
@@ -9,84 +9,84 @@
* Implements hook_schema().
*/
function dblog_schema() {
- $schema['watchdog'] = array(
+ $schema['watchdog'] = [
'description' => 'Table that contains logs of all system events.',
- 'fields' => array(
- 'wid' => array(
+ 'fields' => [
+ 'wid' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique watchdog event ID.',
- ),
- 'uid' => array(
+ ],
+ 'uid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid of the user who triggered the event.',
- ),
- 'type' => array(
+ ],
+ 'type' => [
'type' => 'varchar_ascii',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'Type of log message, for example "user" or "page not found."',
- ),
- 'message' => array(
+ ],
+ 'message' => [
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Text of log message to be passed into the t() function.',
- ),
- 'variables' => array(
+ ],
+ 'variables' => [
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
- ),
- 'severity' => array(
+ ],
+ 'severity' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
- ),
- 'link' => array(
+ ],
+ 'link' => [
'type' => 'text',
'not null' => FALSE,
'description' => 'Link to view the result of the event.',
- ),
- 'location' => array(
+ ],
+ 'location' => [
'type' => 'text',
'not null' => TRUE,
'description' => 'URL of the origin of the event.',
- ),
- 'referer' => array(
+ ],
+ 'referer' => [
'type' => 'text',
'not null' => FALSE,
'description' => 'URL of referring page.',
- ),
- 'hostname' => array(
+ ],
+ 'hostname' => [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Hostname of the user who triggered the event.',
- ),
- 'timestamp' => array(
+ ],
+ 'timestamp' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Unix timestamp of when event occurred.',
- ),
- ),
- 'primary key' => array('wid'),
- 'indexes' => array(
- 'type' => array('type'),
- 'uid' => array('uid'),
- 'severity' => array('severity'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['wid'],
+ 'indexes' => [
+ 'type' => ['type'],
+ 'uid' => ['uid'],
+ 'severity' => ['severity'],
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module
index 06fef103fe5..ed92d6c8f2a 100644
--- a/core/modules/dblog/dblog.module
+++ b/core/modules/dblog/dblog.module
@@ -21,13 +21,13 @@ function dblog_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.dblog':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Database Logging module logs system events in the Drupal database. For more information, see the <a href=":dblog">online documentation for the Database Logging module</a>.', array(':dblog' => 'https://www.drupal.org/documentation/modules/dblog')) . '</p>';
+ $output .= '<p>' . t('The Database Logging module logs system events in the Drupal database. For more information, see the <a href=":dblog">online documentation for the Database Logging module</a>.', [':dblog' => 'https://www.drupal.org/documentation/modules/dblog']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Monitoring your site') . '</dt>';
- $output .= '<dd>' . t('The Database Logging module allows you to view an event log on the <a href=":dblog">Recent log messages</a> page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', array(':dblog' => \Drupal::url('dblog.overview'))) . '</dd>';
+ $output .= '<dd>' . t('The Database Logging module allows you to view an event log on the <a href=":dblog">Recent log messages</a> page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', [':dblog' => \Drupal::url('dblog.overview')]) . '</dd>';
$output .= '<dt>' . t('Debugging site problems') . '</dt>';
- $output .= '<dd>' . t('In case of errors or problems with the site, the <a href=":dblog">Recent log messages</a> page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', array(':dblog' => \Drupal::url('dblog.overview'))) . '</dd>';
+ $output .= '<dd>' . t('In case of errors or problems with the site, the <a href=":dblog">Recent log messages</a> page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', [':dblog' => \Drupal::url('dblog.overview')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -41,12 +41,12 @@ function dblog_help($route_name, RouteMatchInterface $route_match) {
*/
function dblog_menu_links_discovered_alter(&$links) {
if (\Drupal::moduleHandler()->moduleExists('search')) {
- $links['dblog.search'] = array(
+ $links['dblog.search'] = [
'title' => new TranslatableMarkup('Top search phrases'),
'route_name' => 'dblog.search',
'description' => new TranslatableMarkup('View most popular search phrases.'),
'parent' => 'system.admin_reports',
- );
+ ];
}
return $links;
@@ -66,7 +66,7 @@ function dblog_cron() {
// e.g. auto_increment value > 1 or rows deleted directly from the table.
if ($row_limit > 0) {
$min_row = db_select('watchdog', 'w')
- ->fields('w', array('wid'))
+ ->fields('w', ['wid'])
->orderBy('wid', 'DESC')
->range($row_limit - 1, 1)
->execute()->fetchField();
@@ -95,14 +95,14 @@ function _dblog_get_message_types() {
* Implements hook_form_FORM_ID_alter() for system_logging_settings().
*/
function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) {
- $row_limits = array(100, 1000, 10000, 100000, 1000000);
- $form['dblog_row_limit'] = array(
+ $row_limits = [100, 1000, 10000, 100000, 1000000];
+ $form['dblog_row_limit'] = [
'#type' => 'select',
'#title' => t('Database log messages to keep'),
'#default_value' => \Drupal::configFactory()->getEditable('dblog.settings')->get('row_limit'),
- '#options' => array(0 => t('All')) + array_combine($row_limits, $row_limits),
- '#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', array(':cron' => \Drupal::url('system.status')))
- );
+ '#options' => [0 => t('All')] + array_combine($row_limits, $row_limits),
+ '#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', [':cron' => \Drupal::url('system.status')])
+ ];
$form['#submit'][] = 'dblog_logging_settings_submit';
}
diff --git a/core/modules/dblog/dblog.views.inc b/core/modules/dblog/dblog.views.inc
index dfc1fdec3f7..20ad9ceb290 100644
--- a/core/modules/dblog/dblog.views.inc
+++ b/core/modules/dblog/dblog.views.inc
@@ -9,208 +9,208 @@
* Implements hook_views_data().
*/
function dblog_views_data() {
- $data = array();
+ $data = [];
$data['watchdog']['table']['group'] = t('Watchdog');
$data['watchdog']['table']['wizard_id'] = 'watchdog';
- $data['watchdog']['table']['base'] = array(
+ $data['watchdog']['table']['base'] = [
'field' => 'wid',
'title' => t('Log entries'),
'help' => t('Contains a list of log entries.'),
- );
+ ];
- $data['watchdog']['wid'] = array(
+ $data['watchdog']['wid'] = [
'title' => t('WID'),
'help' => t('Unique watchdog event ID.'),
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['uid'] = array(
+ $data['watchdog']['uid'] = [
'title' => t('UID'),
'help' => t('The user ID of the user on which the log entry was written..'),
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'relationship' => array(
+ ],
+ 'relationship' => [
'title' => t('User'),
'help' => t('The user on which the log entry as written.'),
'base' => 'users',
'base field' => 'uid',
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['type'] = array(
+ $data['watchdog']['type'] = [
'title' => t('Type'),
'help' => t('The type of the log entry, for example "user" or "page not found".'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'in_operator',
'options callback' => '_dblog_get_message_types',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['message'] = array(
+ $data['watchdog']['message'] = [
'title' => t('Message'),
'help' => t('The actual message of the log entry.'),
- 'field' => array(
+ 'field' => [
'id' => 'dblog_message',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['variables'] = array(
+ $data['watchdog']['variables'] = [
'title' => t('Variables'),
'help' => t('The variables of the log entry in a serialized format.'),
- 'field' => array(
+ 'field' => [
'id' => 'serialized',
'click sortable' => FALSE,
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['severity'] = array(
+ $data['watchdog']['severity'] = [
'title' => t('Severity level'),
'help' => t('The severity level of the event; ranges from 0 (Emergency) to 7 (Debug).'),
- 'field' => array(
+ 'field' => [
'id' => 'machine_name',
'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'in_operator',
'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['link'] = array(
+ $data['watchdog']['link'] = [
'title' => t('Operations'),
'help' => t('Operation links for the event.'),
- 'field' => array(
+ 'field' => [
'id' => 'dblog_operations',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['location'] = array(
+ $data['watchdog']['location'] = [
'title' => t('Location'),
'help' => t('URL of the origin of the event.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['referer'] = array(
+ $data['watchdog']['referer'] = [
'title' => t('Referer'),
'help' => t('URL of the previous page.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['hostname'] = array(
+ $data['watchdog']['hostname'] = [
'title' => t('Hostname'),
'help' => t('Hostname of the user who triggered the event.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['watchdog']['timestamp'] = array(
+ $data['watchdog']['timestamp'] = [
'title' => t('Timestamp'),
'help' => t('Date when the event occurred.'),
- 'field' => array(
+ 'field' => [
'id' => 'date',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'date',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'date',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php
index 36ee20411e8..946a73c9f22 100644
--- a/core/modules/dblog/src/Controller/DbLogController.php
+++ b/core/modules/dblog/src/Controller/DbLogController.php
@@ -94,7 +94,7 @@ class DbLogController extends ControllerBase {
* An array of log level classes.
*/
public static function getLogLevelClassMap() {
- return array(
+ return [
RfcLogLevel::DEBUG => 'dblog-debug',
RfcLogLevel::INFO => 'dblog-info',
RfcLogLevel::NOTICE => 'dblog-notice',
@@ -103,7 +103,7 @@ class DbLogController extends ControllerBase {
RfcLogLevel::CRITICAL => 'dblog-critical',
RfcLogLevel::ALERT => 'dblog-alert',
RfcLogLevel::EMERGENCY => 'dblog-emergency',
- );
+ ];
}
/**
@@ -121,7 +121,7 @@ class DbLogController extends ControllerBase {
public function overview() {
$filter = $this->buildFilterQuery();
- $rows = array();
+ $rows = [];
$classes = static::getLogLevelClassMap();
@@ -129,32 +129,32 @@ class DbLogController extends ControllerBase {
$build['dblog_filter_form'] = $this->formBuilder->getForm('Drupal\dblog\Form\DblogFilterForm');
- $header = array(
+ $header = [
// Icon column.
'',
- array(
+ [
'data' => $this->t('Type'),
'field' => 'w.type',
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)),
- array(
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM]],
+ [
'data' => $this->t('Date'),
'field' => 'w.wid',
'sort' => 'desc',
- 'class' => array(RESPONSIVE_PRIORITY_LOW)),
+ 'class' => [RESPONSIVE_PRIORITY_LOW]],
$this->t('Message'),
- array(
+ [
'data' => $this->t('User'),
'field' => 'ufd.name',
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)),
- array(
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM]],
+ [
'data' => $this->t('Operations'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW)),
- );
+ 'class' => [RESPONSIVE_PRIORITY_LOW]],
+ ];
$query = $this->database->select('watchdog', 'w')
->extend('\Drupal\Core\Database\Query\PagerSelectExtender')
->extend('\Drupal\Core\Database\Query\TableSortExtender');
- $query->fields('w', array(
+ $query->fields('w', [
'wid',
'uid',
'severity',
@@ -163,7 +163,7 @@ class DbLogController extends ControllerBase {
'message',
'variables',
'link',
- ));
+ ]);
$query->leftJoin('users_field_data', 'ufd', 'w.uid = ufd.uid');
if (!empty($filter['where'])) {
@@ -181,45 +181,45 @@ class DbLogController extends ControllerBase {
$log_text = Unicode::truncate($title, 56, TRUE, TRUE);
// The link generator will escape any unsafe HTML entities in the final
// text.
- $message = $this->l($log_text, new Url('dblog.event', array('event_id' => $dblog->wid), array(
- 'attributes' => array(
+ $message = $this->l($log_text, new Url('dblog.event', ['event_id' => $dblog->wid], [
+ 'attributes' => [
// Provide a title for the link for useful hover hints. The
// Attribute object will escape any unsafe HTML entities in the
// final text.
'title' => $title,
- ),
- )));
+ ],
+ ]));
}
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $this->userStorage->load($dblog->uid),
- );
- $rows[] = array(
- 'data' => array(
+ ];
+ $rows[] = [
+ 'data' => [
// Cells.
- array('class' => array('icon')),
+ ['class' => ['icon']],
$this->t($dblog->type),
$this->dateFormatter->format($dblog->timestamp, 'short'),
$message,
- array('data' => $username),
- array('data' => array('#markup' => $dblog->link)),
- ),
+ ['data' => $username],
+ ['data' => ['#markup' => $dblog->link]],
+ ],
// Attributes for table row.
- 'class' => array(Html::getClass('dblog-' . $dblog->type), $classes[$dblog->severity]),
- );
+ 'class' => [Html::getClass('dblog-' . $dblog->type), $classes[$dblog->severity]],
+ ];
}
- $build['dblog_table'] = array(
+ $build['dblog_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')),
+ '#attributes' => ['id' => 'admin-dblog', 'class' => ['admin-dblog']],
'#empty' => $this->t('No log messages available.'),
- '#attached' => array(
- 'library' => array('dblog/drupal.dblog'),
- ),
- );
- $build['dblog_pager'] = array('#type' => 'pager');
+ '#attached' => [
+ 'library' => ['dblog/drupal.dblog'],
+ ],
+ ];
+ $build['dblog_pager'] = ['#type' => 'pager'];
return $build;
@@ -236,60 +236,60 @@ class DbLogController extends ControllerBase {
* format expected by drupal_render();
*/
public function eventDetails($event_id) {
- $build = array();
- if ($dblog = $this->database->query('SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', array(':id' => $event_id))->fetchObject()) {
+ $build = [];
+ if ($dblog = $this->database->query('SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', [':id' => $event_id])->fetchObject()) {
$severity = RfcLogLevel::getLevels();
$message = $this->formatMessage($dblog);
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $dblog->uid ? $this->userStorage->load($dblog->uid) : User::getAnonymousUser(),
- );
- $rows = array(
- array(
- array('data' => $this->t('Type'), 'header' => TRUE),
+ ];
+ $rows = [
+ [
+ ['data' => $this->t('Type'), 'header' => TRUE],
$this->t($dblog->type),
- ),
- array(
- array('data' => $this->t('Date'), 'header' => TRUE),
+ ],
+ [
+ ['data' => $this->t('Date'), 'header' => TRUE],
$this->dateFormatter->format($dblog->timestamp, 'long'),
- ),
- array(
- array('data' => $this->t('User'), 'header' => TRUE),
- array('data' => $username),
- ),
- array(
- array('data' => $this->t('Location'), 'header' => TRUE),
+ ],
+ [
+ ['data' => $this->t('User'), 'header' => TRUE],
+ ['data' => $username],
+ ],
+ [
+ ['data' => $this->t('Location'), 'header' => TRUE],
$this->l($dblog->location, $dblog->location ? Url::fromUri($dblog->location) : Url::fromRoute('<none>')),
- ),
- array(
- array('data' => $this->t('Referrer'), 'header' => TRUE),
+ ],
+ [
+ ['data' => $this->t('Referrer'), 'header' => TRUE],
$this->l($dblog->referer, $dblog->referer ? Url::fromUri($dblog->referer) : Url::fromRoute('<none>')),
- ),
- array(
- array('data' => $this->t('Message'), 'header' => TRUE),
+ ],
+ [
+ ['data' => $this->t('Message'), 'header' => TRUE],
$message,
- ),
- array(
- array('data' => $this->t('Severity'), 'header' => TRUE),
+ ],
+ [
+ ['data' => $this->t('Severity'), 'header' => TRUE],
$severity[$dblog->severity],
- ),
- array(
- array('data' => $this->t('Hostname'), 'header' => TRUE),
+ ],
+ [
+ ['data' => $this->t('Hostname'), 'header' => TRUE],
$dblog->hostname,
- ),
- array(
- array('data' => $this->t('Operations'), 'header' => TRUE),
- array('data' => array('#markup' => $dblog->link)),
- ),
- );
- $build['dblog_table'] = array(
+ ],
+ [
+ ['data' => $this->t('Operations'), 'header' => TRUE],
+ ['data' => ['#markup' => $dblog->link]],
+ ],
+ ];
+ $build['dblog_table'] = [
'#type' => 'table',
'#rows' => $rows,
- '#attributes' => array('class' => array('dblog-event')),
- '#attached' => array(
- 'library' => array('dblog/drupal.dblog'),
- ),
- );
+ '#attributes' => ['class' => ['dblog-event']],
+ '#attached' => [
+ 'library' => ['dblog/drupal.dblog'],
+ ],
+ ];
}
return $build;
@@ -311,9 +311,9 @@ class DbLogController extends ControllerBase {
$filters = dblog_filters();
// Build query.
- $where = $args = array();
+ $where = $args = [];
foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
- $filter_where = array();
+ $filter_where = [];
foreach ($filter as $value) {
$filter_where[] = $filters[$key]['where'];
$args[] = $value;
@@ -324,10 +324,10 @@ class DbLogController extends ControllerBase {
}
$where = !empty($where) ? implode(' AND ', $where) : '';
- return array(
+ return [
'where' => $where,
'args' => $args,
- );
+ ];
}
/**
@@ -378,10 +378,10 @@ class DbLogController extends ControllerBase {
* A build array in the format expected by drupal_render().
*/
public function topLogMessages($type) {
- $header = array(
- array('data' => $this->t('Count'), 'field' => 'count', 'sort' => 'desc'),
- array('data' => $this->t('Message'), 'field' => 'message'),
- );
+ $header = [
+ ['data' => $this->t('Count'), 'field' => 'count', 'sort' => 'desc'],
+ ['data' => $this->t('Message'), 'field' => 'message'],
+ ];
$count_query = $this->database->select('watchdog');
$count_query->addExpression('COUNT(DISTINCT(message))');
@@ -392,7 +392,7 @@ class DbLogController extends ControllerBase {
->extend('\Drupal\Core\Database\Query\TableSortExtender');
$query->addExpression('COUNT(wid)', 'count');
$query = $query
- ->fields('w', array('message', 'variables'))
+ ->fields('w', ['message', 'variables'])
->condition('w.type', $type)
->groupBy('message')
->groupBy('variables')
@@ -401,23 +401,23 @@ class DbLogController extends ControllerBase {
$query->setCountQuery($count_query);
$result = $query->execute();
- $rows = array();
+ $rows = [];
foreach ($result as $dblog) {
if ($message = $this->formatMessage($dblog)) {
- $rows[] = array($dblog->count, $message);
+ $rows[] = [$dblog->count, $message];
}
}
- $build['dblog_top_table'] = array(
+ $build['dblog_top_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $this->t('No log messages available.'),
- '#attached' => array(
- 'library' => array('dblog/drupal.dblog'),
- ),
- );
- $build['dblog_top_pager'] = array('#type' => 'pager');
+ '#attached' => [
+ 'library' => ['dblog/drupal.dblog'],
+ ],
+ ];
+ $build['dblog_top_pager'] = ['#type' => 'pager'];
return $build;
}
diff --git a/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php b/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php
index b1710df298e..0f420f05687 100644
--- a/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php
+++ b/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php
@@ -64,7 +64,7 @@ class DblogClearLogConfirmForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $_SESSION['dblog_overview_filter'] = array();
+ $_SESSION['dblog_overview_filter'] = [];
$this->connection->truncate('watchdog')->execute();
drupal_set_message($this->t('Database log cleared.'));
$form_state->setRedirectUrl($this->getCancelUrl());
diff --git a/core/modules/dblog/src/Form/DblogFilterForm.php b/core/modules/dblog/src/Form/DblogFilterForm.php
index 0434f121a0f..c8de0fc68bb 100644
--- a/core/modules/dblog/src/Form/DblogFilterForm.php
+++ b/core/modules/dblog/src/Form/DblogFilterForm.php
@@ -23,39 +23,39 @@ class DblogFilterForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$filters = dblog_filters();
- $form['filters'] = array(
+ $form['filters'] = [
'#type' => 'details',
'#title' => $this->t('Filter log messages'),
'#open' => TRUE,
- );
+ ];
foreach ($filters as $key => $filter) {
- $form['filters']['status'][$key] = array(
+ $form['filters']['status'][$key] = [
'#title' => $filter['title'],
'#type' => 'select',
'#multiple' => TRUE,
'#size' => 8,
'#options' => $filter['options'],
- );
+ ];
if (!empty($_SESSION['dblog_overview_filter'][$key])) {
$form['filters']['status'][$key]['#default_value'] = $_SESSION['dblog_overview_filter'][$key];
}
}
- $form['filters']['actions'] = array(
+ $form['filters']['actions'] = [
'#type' => 'actions',
- '#attributes' => array('class' => array('container-inline')),
- );
- $form['filters']['actions']['submit'] = array(
+ '#attributes' => ['class' => ['container-inline']],
+ ];
+ $form['filters']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Filter'),
- );
+ ];
if (!empty($_SESSION['dblog_overview_filter'])) {
- $form['filters']['actions']['reset'] = array(
+ $form['filters']['actions']['reset'] = [
'#type' => 'submit',
'#value' => $this->t('Reset'),
- '#limit_validation_errors' => array(),
- '#submit' => array('::resetForm'),
- );
+ '#limit_validation_errors' => [],
+ '#submit' => ['::resetForm'],
+ ];
}
return $form;
}
@@ -90,7 +90,7 @@ class DblogFilterForm extends FormBase {
* The current state of the form.
*/
public function resetForm(array &$form, FormStateInterface $form_state) {
- $_SESSION['dblog_overview_filter'] = array();
+ $_SESSION['dblog_overview_filter'] = [];
}
}
diff --git a/core/modules/dblog/src/Logger/DbLog.php b/core/modules/dblog/src/Logger/DbLog.php
index af77be4d1c1..97b0b7b3059 100644
--- a/core/modules/dblog/src/Logger/DbLog.php
+++ b/core/modules/dblog/src/Logger/DbLog.php
@@ -53,7 +53,7 @@ class DbLog implements LoggerInterface {
/**
* {@inheritdoc}
*/
- public function log($level, $message, array $context = array()) {
+ public function log($level, $message, array $context = []) {
// Remove any backtraces since they may contain an unserializable variable.
unset($context['backtrace']);
@@ -64,7 +64,7 @@ class DbLog implements LoggerInterface {
try {
$this->connection
->insert('watchdog')
- ->fields(array(
+ ->fields([
'uid' => $context['uid'],
'type' => Unicode::substr($context['channel'], 0, 64),
'message' => $message,
@@ -75,7 +75,7 @@ class DbLog implements LoggerInterface {
'referer' => $context['referer'],
'hostname' => Unicode::substr($context['ip'], 0, 128),
'timestamp' => $context['timestamp'],
- ))
+ ])
->execute();
}
catch (\Exception $e) {
diff --git a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php
index 4ac76f046bd..ed801fceccb 100644
--- a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php
+++ b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php
@@ -38,13 +38,13 @@ class DBLogResource extends ResourceBase {
*/
public function get($id = NULL) {
if ($id) {
- $record = db_query("SELECT * FROM {watchdog} WHERE wid = :wid", array(':wid' => $id))
+ $record = db_query("SELECT * FROM {watchdog} WHERE wid = :wid", [':wid' => $id])
->fetchAssoc();
if (!empty($record)) {
return new ResourceResponse($record);
}
- throw new NotFoundHttpException(t('Log entry with ID @id was not found', array('@id' => $id)));
+ throw new NotFoundHttpException(t('Log entry with ID @id was not found', ['@id' => $id]));
}
throw new BadRequestHttpException(t('No log entry ID was provided'));
diff --git a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php
index e0558d897c3..3c682428439 100644
--- a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php
+++ b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php
@@ -34,7 +34,7 @@ class DblogMessage extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['replace_variables'] = array('default' => TRUE);
+ $options['replace_variables'] = ['default' => TRUE];
return $options;
}
@@ -45,11 +45,11 @@ class DblogMessage extends FieldPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['replace_variables'] = array(
+ $form['replace_variables'] = [
'#title' => $this->t('Replace variables'),
'#type' => 'checkbox',
'#default_value' => $this->options['replace_variables'],
- );
+ ];
}
/**
diff --git a/core/modules/dblog/src/Tests/DbLogTest.php b/core/modules/dblog/src/Tests/DbLogTest.php
index daa9421b731..878f632b00e 100644
--- a/core/modules/dblog/src/Tests/DbLogTest.php
+++ b/core/modules/dblog/src/Tests/DbLogTest.php
@@ -22,7 +22,7 @@ class DbLogTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('dblog', 'node', 'forum', 'help', 'block');
+ public static $modules = ['dblog', 'node', 'forum', 'help', 'block'];
/**
* A user with some relevant administrative permissions.
@@ -47,8 +47,8 @@ class DbLogTest extends WebTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create users with specific permissions.
- $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access site reports', 'administer users'));
- $this->webUser = $this->drupalCreateUser(array());
+ $this->adminUser = $this->drupalCreateUser(['administer site configuration', 'access administration pages', 'access site reports', 'administer users']);
+ $this->webUser = $this->drupalCreateUser([]);
}
/**
@@ -70,8 +70,8 @@ class DbLogTest extends WebTestBase {
$this->verifyBreadcrumbs();
$this->verifyLinkEscaping();
// Verify the overview table sorting.
- $orders = array('Date', 'Type', 'User');
- $sorts = array('asc', 'desc');
+ $orders = ['Date', 'Type', 'User'];
+ $sorts = ['asc', 'desc'];
foreach ($orders as $order) {
foreach ($sorts as $sort) {
$this->verifySort($sort, $order);
@@ -124,14 +124,14 @@ class DbLogTest extends WebTestBase {
*/
private function verifyRowLimit($row_limit) {
// Change the database log row limit.
- $edit = array();
+ $edit = [];
$edit['dblog_row_limit'] = $row_limit;
$this->drupalPostForm('admin/config/development/logging', $edit, t('Save configuration'));
$this->assertResponse(200);
// Check row limit variable.
$current_limit = $this->config('dblog.settings')->get('row_limit');
- $this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit)));
+ $this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', ['@count' => $current_limit, '@limit' => $row_limit]));
}
/**
@@ -145,18 +145,18 @@ class DbLogTest extends WebTestBase {
$this->generateLogEntries($row_limit + 10);
// Verify that the database log row count exceeds the row limit.
$count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField();
- $this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit)));
+ $this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', ['@count' => $count, '@limit' => $row_limit]));
// Get the number of enabled modules. Cron adds a log entry for each module.
$list = \Drupal::moduleHandler()->getImplementations('cron');
$module_count = count($list);
$cron_detailed_count = $this->runCron();
- $this->assertTrue($cron_detailed_count == $module_count + 2, format_string('Cron added @count of @expected new log entries', array('@count' => $cron_detailed_count, '@expected' => $module_count + 2)));
+ $this->assertTrue($cron_detailed_count == $module_count + 2, format_string('Cron added @count of @expected new log entries', ['@count' => $cron_detailed_count, '@expected' => $module_count + 2]));
// Test disabling of detailed cron logging.
$this->config('system.cron')->set('logging', 0)->save();
$cron_count = $this->runCron();
- $this->assertTrue($cron_count = 1, format_string('Cron added @count of @expected new log entries', array('@count' => $cron_count, '@expected' => 1)));
+ $this->assertTrue($cron_count = 1, format_string('Cron added @count of @expected new log entries', ['@count' => $cron_count, '@expected' => 1]));
}
/**
@@ -203,7 +203,7 @@ class DbLogTest extends WebTestBase {
* entry.
* - 'timestamp': Int unix timestamp.
*/
- private function generateLogEntries($count, $options = array()) {
+ private function generateLogEntries($count, $options = []) {
global $base_root;
// This long URL makes it just a little bit harder to pass the link part of
@@ -212,10 +212,10 @@ class DbLogTest extends WebTestBase {
$link = urldecode('/content/xo%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A-lake-isabelle');
// Prepare the fields to be logged
- $log = $options + array(
+ $log = $options + [
'channel' => 'custom',
'message' => 'Dblog test log message',
- 'variables' => array(),
+ 'variables' => [],
'severity' => RfcLogLevel::NOTICE,
'link' => $link,
'user' => $this->adminUser,
@@ -224,7 +224,7 @@ class DbLogTest extends WebTestBase {
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
'ip' => '127.0.0.1',
'timestamp' => REQUEST_TIME,
- );
+ ];
$logger = $this->container->get('logger.dblog');
$message = $log['message'] . ' Entry #';
@@ -250,7 +250,7 @@ class DbLogTest extends WebTestBase {
* (optional) The log entry severity.
*/
protected function filterLogsEntries($type = NULL, $severity = NULL) {
- $edit = array();
+ $edit = [];
if (!is_null($type)) {
$edit['type[]'] = $type;
}
@@ -321,8 +321,8 @@ class DbLogTest extends WebTestBase {
private function verifyEvents() {
// Invoke events.
$this->doUser();
- $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article')));
- $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page')));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]);
+ $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
$this->doNode('article');
$this->doNode('page');
$this->doNode('forum');
@@ -341,7 +341,7 @@ class DbLogTest extends WebTestBase {
* The order by which the table should be sorted.
*/
public function verifySort($sort = 'asc', $order = 'Date') {
- $this->drupalGet('admin/reports/dblog', array('query' => array('sort' => $sort, 'order' => $order)));
+ $this->drupalGet('admin/reports/dblog', ['query' => ['sort' => $sort, 'order' => $order]]);
$this->assertResponse(200);
$this->assertText(t('Recent log messages'), 'DBLog report was displayed correctly and sorting went fine.');
}
@@ -351,12 +351,12 @@ class DbLogTest extends WebTestBase {
* page.
*/
private function verifyLinkEscaping() {
- $link = \Drupal::l('View', Url::fromRoute('entity.node.canonical', array('node' => 1)));
+ $link = \Drupal::l('View', Url::fromRoute('entity.node.canonical', ['node' => 1]));
$message = 'Log entry added to do the verifyLinkEscaping test.';
- $this->generateLogEntries(1, array(
+ $this->generateLogEntries(1, [
'message' => $message,
'link' => $link,
- ));
+ ]);
$result = db_query_range('SELECT wid FROM {watchdog} ORDER BY wid DESC', 0, 1);
$this->drupalGet('admin/reports/dblog/event/' . $result->fetchField());
@@ -374,7 +374,7 @@ class DbLogTest extends WebTestBase {
$pass = user_password();
// Add a user using the form to generate an add user event (which is not
// triggered by drupalCreateUser).
- $edit = array();
+ $edit = [];
$edit['name'] = $name;
$edit['mail'] = $name . '@example.com';
$edit['pass[pass1]'] = $pass;
@@ -384,7 +384,7 @@ class DbLogTest extends WebTestBase {
$this->assertResponse(200);
// Retrieve the user object.
$user = user_load_by_name($name);
- $this->assertTrue($user != NULL, format_string('User @name was loaded', array('@name' => $name)));
+ $this->assertTrue($user != NULL, format_string('User @name was loaded', ['@name' => $name]));
// pass_raw property is needed by drupalLogin.
$user->pass_raw = $pass;
// Log in user.
@@ -392,18 +392,18 @@ class DbLogTest extends WebTestBase {
// Log out user.
$this->drupalLogout();
// Fetch the row IDs in watchdog that relate to the user.
- $result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', array(':uid' => $user->id()));
+ $result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', [':uid' => $user->id()]);
foreach ($result as $row) {
$ids[] = $row->wid;
}
$count_before = (isset($ids)) ? count($ids) : 0;
- $this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->getUsername())));
+ $this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', ['@count' => $count_before, '@name' => $user->getUsername()]));
// Log in the admin user.
$this->drupalLogin($this->adminUser);
// Delete the user created at the start of this test.
// We need to POST here to invoke batch_process() in the internal browser.
- $this->drupalPostForm('user/' . $user->id() . '/cancel', array('user_cancel_method' => 'user_cancel_reassign'), t('Cancel account'));
+ $this->drupalPostForm('user/' . $user->id() . '/cancel', ['user_cancel_method' => 'user_cancel_reassign'], t('Cancel account'));
// View the database log report.
$this->drupalGet('admin/reports/dblog');
@@ -413,13 +413,13 @@ class DbLogTest extends WebTestBase {
// Add user.
// Default display includes name and email address; if too long, the email
// address is replaced by three periods.
- $this->assertLogMessage(t('New user: %name %email.', array('%name' => $name, '%email' => '<' . $user->getEmail() . '>')), 'DBLog event was recorded: [add user]');
+ $this->assertLogMessage(t('New user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']), 'DBLog event was recorded: [add user]');
// Log in user.
- $this->assertLogMessage(t('Session opened for %name.', array('%name' => $name)), 'DBLog event was recorded: [login user]');
+ $this->assertLogMessage(t('Session opened for %name.', ['%name' => $name]), 'DBLog event was recorded: [login user]');
// Log out user.
- $this->assertLogMessage(t('Session closed for %name.', array('%name' => $name)), 'DBLog event was recorded: [logout user]');
+ $this->assertLogMessage(t('Session closed for %name.', ['%name' => $name]), 'DBLog event was recorded: [logout user]');
// Delete user.
- $message = t('Deleted user: %name %email.', array('%name' => $name, '%email' => '<' . $user->getEmail() . '>'));
+ $message = t('Deleted user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']);
$message_text = Unicode::truncate(Html::decodeEntities(strip_tags($message)), 56, TRUE, TRUE);
// Verify that the full message displays on the details page.
$link = FALSE;
@@ -457,7 +457,7 @@ class DbLogTest extends WebTestBase {
*/
private function doNode($type) {
// Create user.
- $perm = array('create ' . $type . ' content', 'edit own ' . $type . ' content', 'delete own ' . $type . ' content');
+ $perm = ['create ' . $type . ' content', 'edit own ' . $type . ' content', 'delete own ' . $type . ' content'];
$user = $this->drupalCreateUser($perm);
// Log in user.
$this->drupalLogin($user);
@@ -470,13 +470,13 @@ class DbLogTest extends WebTestBase {
$this->assertResponse(200);
// Retrieve the node object.
$node = $this->drupalGetNodeByTitle($title);
- $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
+ $this->assertTrue($node != NULL, format_string('Node @title was loaded', ['@title' => $title]));
// Edit the node.
$edit = $this->getContentUpdate($type);
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->assertResponse(200);
// Delete the node.
- $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete'));
$this->assertResponse(200);
// View the node (to generate page not found event).
$this->drupalGet('node/' . $node->id());
@@ -493,11 +493,11 @@ class DbLogTest extends WebTestBase {
// Verify that node events were recorded.
// Was node content added?
- $this->assertLogMessage(t('@type: added %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content added]');
+ $this->assertLogMessage(t('@type: added %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content added]');
// Was node content updated?
- $this->assertLogMessage(t('@type: updated %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content updated]');
+ $this->assertLogMessage(t('@type: updated %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content updated]');
// Was node content deleted?
- $this->assertLogMessage(t('@type: deleted %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content deleted]');
+ $this->assertLogMessage(t('@type: deleted %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content deleted]');
// View the database log access-denied report page.
$this->drupalGet('admin/reports/access-denied');
@@ -524,18 +524,18 @@ class DbLogTest extends WebTestBase {
private function getContent($type) {
switch ($type) {
case 'forum':
- $content = array(
+ $content = [
'title[0][value]' => $this->randomMachineName(8),
- 'taxonomy_forums' => array(1),
+ 'taxonomy_forums' => [1],
'body[0][value]' => $this->randomMachineName(32),
- );
+ ];
break;
default:
- $content = array(
+ $content = [
'title[0][value]' => $this->randomMachineName(8),
'body[0][value]' => $this->randomMachineName(32),
- );
+ ];
break;
}
return $content;
@@ -551,9 +551,9 @@ class DbLogTest extends WebTestBase {
* Random content needed by various node types.
*/
private function getContentUpdate($type) {
- $content = array(
+ $content = [
'body[0][value]' => $this->randomMachineName(32),
- );
+ ];
return $content;
}
@@ -567,10 +567,10 @@ class DbLogTest extends WebTestBase {
global $base_root;
// Get a count of how many watchdog entries already exist.
$count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField();
- $log = array(
+ $log = [
'channel' => 'system',
'message' => 'Log entry added to test the doClearTest clear down.',
- 'variables' => array(),
+ 'variables' => [],
'severity' => RfcLogLevel::NOTICE,
'link' => NULL,
'user' => $this->adminUser,
@@ -579,20 +579,20 @@ class DbLogTest extends WebTestBase {
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
'ip' => '127.0.0.1',
'timestamp' => REQUEST_TIME,
- );
+ ];
// Add a watchdog entry.
$this->container->get('logger.dblog')->log($log['severity'], $log['message'], $log);
// Make sure the table count has actually been incremented.
- $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', array(':count' => $count)));
+ $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', [':count' => $count]));
// Log in the admin user.
$this->drupalLogin($this->adminUser);
// Post in order to clear the database table.
$this->clearLogsEntries();
// Confirm that the logs should be cleared.
- $this->drupalPostForm(NULL, array(), 'Confirm');
+ $this->drupalPostForm(NULL, [], 'Confirm');
// Count the rows in watchdog that previously related to the deleted user.
$count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField();
- $this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', array(':count' => $count)));
+ $this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', [':count' => $count]));
}
/**
@@ -605,21 +605,21 @@ class DbLogTest extends WebTestBase {
db_delete('watchdog')->execute();
// Generate 9 random watchdog entries.
- $type_names = array();
- $types = array();
+ $type_names = [];
+ $types = [];
for ($i = 0; $i < 3; $i++) {
$type_names[] = $type_name = $this->randomMachineName();
$severity = RfcLogLevel::EMERGENCY;
for ($j = 0; $j < 3; $j++) {
- $types[] = $type = array(
+ $types[] = $type = [
'count' => $j + 1,
'type' => $type_name,
'severity' => $severity++,
- );
- $this->generateLogEntries($type['count'], array(
+ ];
+ $this->generateLogEntries($type['count'], [
'channel' => $type['type'],
'severity' => $type['severity'],
- ));
+ ]);
}
}
@@ -658,14 +658,14 @@ class DbLogTest extends WebTestBase {
$this->assertEqual(array_sum($count), $type['count'], 'Count matched');
}
- $this->drupalGet('admin/reports/dblog', array('query' => array('order' => 'Type')));
+ $this->drupalGet('admin/reports/dblog', ['query' => ['order' => 'Type']]);
$this->assertResponse(200);
$this->assertText(t('Operations'), 'Operations text found');
// Clear all logs and make sure the confirmation message is found.
$this->clearLogsEntries();
// Confirm that the logs should be cleared.
- $this->drupalPostForm(NULL, array(), 'Confirm');
+ $this->drupalPostForm(NULL, [], 'Confirm');
$this->assertText(t('Database log cleared.'), 'Confirmation message found');
}
@@ -680,16 +680,16 @@ class DbLogTest extends WebTestBase {
* - user: (string) The user associated with this database log event.
*/
protected function getLogEntries() {
- $entries = array();
+ $entries = [];
if ($table = $this->getLogsEntriesTable()) {
$table = array_shift($table);
foreach ($table->tbody->tr as $row) {
- $entries[] = array(
+ $entries[] = [
'severity' => $this->getSeverityConstant($row['class']),
'type' => $this->asText($row->td[1]),
'message' => $this->asText($row->td[3]),
'user' => $this->asText($row->td[4]),
- );
+ ];
}
}
return $entries;
@@ -795,7 +795,7 @@ class DbLogTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
// Generate a single watchdog entry.
- $this->generateLogEntries(1, array('user' => $tempuser, 'uid' => $tempuser_uid));
+ $this->generateLogEntries(1, ['user' => $tempuser, 'uid' => $tempuser_uid]);
$wid = db_query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
// Check if the full message displays on the details page.
diff --git a/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php b/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php
index 279d202a145..44dbe99dd1e 100644
--- a/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php
+++ b/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php
@@ -18,7 +18,7 @@ class DbLogResourceTest extends RESTTestBase {
*
* @var array
*/
- public static $modules = array('hal', 'dblog');
+ public static $modules = ['hal', 'dblog'];
protected function setUp() {
parent::setUp();
@@ -33,12 +33,12 @@ class DbLogResourceTest extends RESTTestBase {
// Write a log message to the DB.
$this->container->get('logger.channel.rest')->notice('Test message');
// Get the ID of the written message.
- $id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, array(':type' => 'rest'))
+ $id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, [':type' => 'rest'])
->fetchField();
// Create a user account that has the required permissions to read
// the watchdog resource via the REST API.
- $account = $this->drupalCreateUser(array('restful get dblog'));
+ $account = $this->drupalCreateUser(['restful get dblog']);
$this->drupalLogin($account);
$response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => $id, '_format' => $this->defaultFormat]), 'GET');
diff --git a/core/modules/dblog/tests/src/Functional/ConnectionFailureTest.php b/core/modules/dblog/tests/src/Functional/ConnectionFailureTest.php
index df088a3d256..44b045782da 100644
--- a/core/modules/dblog/tests/src/Functional/ConnectionFailureTest.php
+++ b/core/modules/dblog/tests/src/Functional/ConnectionFailureTest.php
@@ -12,7 +12,7 @@ use Drupal\Tests\BrowserTestBase;
*/
class ConnectionFailureTest extends BrowserTestBase {
- public static $modules = array('dblog');
+ public static $modules = ['dblog'];
/**
* Tests logging of connection failures.
diff --git a/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php b/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php
index 569cdbf7d64..c0d97bee35b 100644
--- a/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php
+++ b/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php
@@ -31,7 +31,7 @@ class DbLogFormInjectionTest extends KernelTestBase implements FormInterface {
*
* @var array
*/
- public static $modules = array('system', 'dblog', 'user');
+ public static $modules = ['system', 'dblog', 'user'];
/**
* {@inheritdoc}
@@ -82,10 +82,10 @@ class DbLogFormInjectionTest extends KernelTestBase implements FormInterface {
$this->installSchema('system', ['key_value_expire', 'sequences']);
$this->installEntitySchema('user');
$this->logger = \Drupal::logger('test_logger');
- $test_user = User::create(array(
+ $test_user = User::create([
'name' => 'foobar',
'mail' => 'foobar@example.com',
- ));
+ ]);
$test_user->save();
\Drupal::service('current_user')->setAccount($test_user);
}
diff --git a/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php b/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php
index 1968a12e964..7b63394d52b 100644
--- a/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php
+++ b/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php
@@ -22,14 +22,14 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_dblog');
+ public static $testViews = ['test_dblog'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('dblog', 'dblog_test_views', 'user');
+ public static $modules = ['dblog', 'dblog_test_views', 'user'];
/**
* {@inheritdoc}
@@ -40,9 +40,9 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
// Rebuild the router, otherwise we can't generate links.
$this->container->get('router.builder')->rebuild();
- $this->installSchema('dblog', array('watchdog'));
+ $this->installSchema('dblog', ['watchdog']);
- ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['dblog_test_views']);
}
/**
@@ -53,35 +53,35 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
// Remove the watchdog entries added by the potential batch process.
$this->container->get('database')->truncate('watchdog')->execute();
- $entries = array();
+ $entries = [];
// Setup a watchdog entry without tokens.
- $entries[] = array(
+ $entries[] = [
'message' => $this->randomMachineName(),
- 'variables' => array('link' => \Drupal::l('Link', new Url('<front>'))),
- );
+ 'variables' => ['link' => \Drupal::l('Link', new Url('<front>'))],
+ ];
// Setup a watchdog entry with one token.
- $entries[] = array(
+ $entries[] = [
'message' => '@token1',
- 'variables' => array('@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', new Url('<front>'))),
- );
+ 'variables' => ['@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', new Url('<front>'))],
+ ];
// Setup a watchdog entry with two tokens.
- $entries[] = array(
+ $entries[] = [
'message' => '@token1 @token2',
// Setup a link with a tag which is filtered by
// \Drupal\Component\Utility\Xss::filterAdmin() in order to make sure
// that strings which are not marked as safe get filtered.
- 'variables' => array(
+ 'variables' => [
'@token1' => $this->randomMachineName(),
'@token2' => $this->randomMachineName(),
'link' => '<a href="' . \Drupal::url('<front>') . '"><object>Link</object></a>',
- ),
- );
+ ],
+ ];
$logger_factory = $this->container->get('logger.factory');
foreach ($entries as $entry) {
- $entry += array(
+ $entry += [
'type' => 'test-views',
'severity' => RfcLogLevel::NOTICE,
- );
+ ];
$logger_factory->get($entry['type'])->log($entry['severity'], $entry['message'], $entry['variables']);
}
diff --git a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
index 5b8e5d73329..ffa8f4375f6 100644
--- a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
+++ b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
@@ -94,11 +94,11 @@ class DynamicPageCacheIntegrationTest extends BrowserTestBase {
// Controllers returning render arrays, rendered as anything except a HTML
// response, are ignored by Dynamic Page Cache (but only because those
// wrapper formats' responses do not implement CacheableResponseInterface).
- $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax')));
+ $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertFalse($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as AJAX response: Dynamic Page Cache is ignoring.');
- $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog')));
+ $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']]);
$this->assertFalse($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as dialog response: Dynamic Page Cache is ignoring.');
- $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
+ $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
$this->assertFalse($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as modal response: Dynamic Page Cache is ignoring.');
// Admin routes are ignored by Dynamic Page Cache.
diff --git a/core/modules/editor/editor.admin.inc b/core/modules/editor/editor.admin.inc
index 83bc2cf3785..f91db4b9619 100644
--- a/core/modules/editor/editor.admin.inc
+++ b/core/modules/editor/editor.admin.inc
@@ -27,77 +27,77 @@ use Drupal\editor\Entity\Editor;
function editor_image_upload_settings_form(Editor $editor) {
// Defaults.
$image_upload = $editor->getImageUploadSettings();
- $image_upload += array(
+ $image_upload += [
'status' => FALSE,
'scheme' => file_default_scheme(),
'directory' => 'inline-images',
'max_size' => '',
- 'max_dimensions' => array('width' => '', 'height' => ''),
- );
+ 'max_dimensions' => ['width' => '', 'height' => ''],
+ ];
- $form['status'] = array(
+ $form['status'] = [
'#type' => 'checkbox',
'#title' => t('Enable image uploads'),
'#default_value' => $image_upload['status'],
- '#attributes' => array(
+ '#attributes' => [
'data-editor-image-upload' => 'status',
- ),
- );
- $show_if_image_uploads_enabled = array(
- 'visible' => array(
- ':input[data-editor-image-upload="status"]' => array('checked' => TRUE),
- ),
- );
+ ],
+ ];
+ $show_if_image_uploads_enabled = [
+ 'visible' => [
+ ':input[data-editor-image-upload="status"]' => ['checked' => TRUE],
+ ],
+ ];
// Any visible, writable wrapper can potentially be used for uploads,
// including a remote file system that integrates with a CDN.
$options = \Drupal::service('stream_wrapper_manager')->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE);
if (!empty($options)) {
- $form['scheme'] = array(
+ $form['scheme'] = [
'#type' => 'radios',
'#title' => t('File storage'),
'#default_value' => $image_upload['scheme'],
'#options' => $options,
'#states' => $show_if_image_uploads_enabled,
'#access' => count($options) > 1,
- );
+ ];
}
// Set data- attributes with human-readable names for all possible stream
// wrappers, so that drupal.ckeditor.drupalimage.admin's summary rendering
// can use that.
foreach (\Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE) as $scheme => $name) {
- $form['scheme'][$scheme]['#attributes']['data-label'] = t('Storage: @name', array('@name' => $name));
+ $form['scheme'][$scheme]['#attributes']['data-label'] = t('Storage: @name', ['@name' => $name]);
}
- $form['directory'] = array(
+ $form['directory'] = [
'#type' => 'textfield',
'#default_value' => $image_upload['directory'],
'#title' => t('Upload directory'),
'#description' => t("A directory relative to Drupal's files directory where uploaded images will be stored."),
'#states' => $show_if_image_uploads_enabled,
- );
+ ];
$default_max_size = format_size(file_upload_max_size());
- $form['max_size'] = array(
+ $form['max_size'] = [
'#type' => 'textfield',
'#default_value' => $image_upload['max_size'],
'#title' => t('Maximum file size'),
- '#description' => t('If this is left empty, then the file size will be limited by the PHP maximum upload size of @size.', array('@size' => $default_max_size)),
+ '#description' => t('If this is left empty, then the file size will be limited by the PHP maximum upload size of @size.', ['@size' => $default_max_size]),
'#maxlength' => 20,
'#size' => 10,
'#placeholder' => $default_max_size,
'#states' => $show_if_image_uploads_enabled,
- );
+ ];
- $form['max_dimensions'] = array(
+ $form['max_dimensions'] = [
'#type' => 'item',
'#title' => t('Maximum dimensions'),
'#field_prefix' => '<div class="container-inline clearfix">',
'#field_suffix' => '</div>',
'#description' => t('Images larger than these dimensions will be scaled down.'),
'#states' => $show_if_image_uploads_enabled,
- );
- $form['max_dimensions']['width'] = array(
+ ];
+ $form['max_dimensions']['width'] = [
'#title' => t('Width'),
'#title_display' => 'invisible',
'#type' => 'number',
@@ -109,8 +109,8 @@ function editor_image_upload_settings_form(Editor $editor) {
'#placeholder' => t('width'),
'#field_suffix' => ' x ',
'#states' => $show_if_image_uploads_enabled,
- );
- $form['max_dimensions']['height'] = array(
+ ];
+ $form['max_dimensions']['height'] = [
'#title' => t('Height'),
'#title_display' => 'invisible',
'#type' => 'number',
@@ -122,7 +122,7 @@ function editor_image_upload_settings_form(Editor $editor) {
'#placeholder' => t('height'),
'#field_suffix' => t('pixels'),
'#states' => $show_if_image_uploads_enabled,
- );
+ ];
return $form;
}
diff --git a/core/modules/editor/editor.api.php b/core/modules/editor/editor.api.php
index 2fd9fa41b91..6485a1e5fc3 100644
--- a/core/modules/editor/editor.api.php
+++ b/core/modules/editor/editor.api.php
@@ -36,7 +36,7 @@ function hook_editor_info_alter(array &$editors) {
function hook_editor_js_settings_alter(array &$settings) {
if (isset($settings['editor']['formats']['basic_html'])) {
$settings['editor']['formats']['basic_html']['editor'] = 'MyDifferentEditor';
- $settings['editor']['formats']['basic_html']['editorSettings']['buttons'] = array('strong', 'italic', 'underline');
+ $settings['editor']['formats']['basic_html']['editorSettings']['buttons'] = ['strong', 'italic', 'underline'];
}
}
diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module
index 8df1f0460a9..04e4cd5a3c1 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -25,13 +25,13 @@ function editor_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.editor':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Text Editor module provides a framework that other modules (such as <a href=":ckeditor">CKEditor module</a>) can use to provide toolbars and other functionality that allow users to format text more easily than typing HTML tags directly. For more information, see the <a href=":documentation">online documentation for the Text Editor module</a>.', array(':documentation' => 'https://www.drupal.org/documentation/modules/editor', ':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', array('name' => 'ckeditor')) : '#')) . '</p>';
+ $output .= '<p>' . t('The Text Editor module provides a framework that other modules (such as <a href=":ckeditor">CKEditor module</a>) can use to provide toolbars and other functionality that allow users to format text more easily than typing HTML tags directly. For more information, see the <a href=":documentation">online documentation for the Text Editor module</a>.', [':documentation' => 'https://www.drupal.org/documentation/modules/editor', ':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', ['name' => 'ckeditor']) : '#']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Installing text editors') . '</dt>';
- $output .= '<dd>' . t('The Text Editor module provides a framework for managing editors. To use it, you also need to enable a text editor. This can either be the core <a href=":ckeditor">CKEditor module</a>, which can be enabled on the <a href=":extend">Extend page</a>, or a contributed module for any other text editor. When installing a contributed text editor module, be sure to check the installation instructions, because you will most likely need to download and install an external library as well as the Drupal module.', array(':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', array('name' => 'ckeditor')) : '#', ':extend' => \Drupal::url('system.modules_list'))) . '</dd>';
+ $output .= '<dd>' . t('The Text Editor module provides a framework for managing editors. To use it, you also need to enable a text editor. This can either be the core <a href=":ckeditor">CKEditor module</a>, which can be enabled on the <a href=":extend">Extend page</a>, or a contributed module for any other text editor. When installing a contributed text editor module, be sure to check the installation instructions, because you will most likely need to download and install an external library as well as the Drupal module.', [':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', ['name' => 'ckeditor']) : '#', ':extend' => \Drupal::url('system.modules_list')]) . '</dd>';
$output .= '<dt>' . t('Enabling a text editor for a text format') . '</dt>';
- $output .= '<dd>' . t('On the <a href=":formats">Text formats and editors page</a> you can see which text editor is associated with each text format. You can change this by clicking on the <em>Configure</em> link, and then choosing a text editor or <em>none</em> from the <em>Text editor</em> drop-down list. The text editor will then be displayed with any text field for which this text format is chosen.', array(':formats' => \Drupal::url('filter.admin_overview'))) . '</dd>';
+ $output .= '<dd>' . t('On the <a href=":formats">Text formats and editors page</a> you can see which text editor is associated with each text format. You can change this by clicking on the <em>Configure</em> link, and then choosing a text editor or <em>none</em> from the <em>Text editor</em> drop-down list. The text editor will then be displayed with any text field for which this text format is chosen.', [':formats' => \Drupal::url('filter.admin_overview')]) . '</dd>';
$output .= '<dt>' . t('Configuring a text editor') . '</dt>';
$output .= '<dd>' . t('Once a text editor is associated with a text format, you can configure it by clicking on the <em>Configure</em> link for this format. Depending on the specific text editor, you can configure it for example by adding buttons to its toolbar. Typically these buttons provide formatting or editing tools, and they often insert HTML tags into the field source. For details, see the help page of the specific text editor.') . '</dd>';
$output .= '<dt>' . t('Using different text editors and formats') . '</dt>';
@@ -86,7 +86,7 @@ function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $for
// @todo Cleanup column injection: https://www.drupal.org/node/1876718.
// Splice in the column for "Text editor" into the header.
$position = array_search('name', $form['formats']['#header']) + 1;
- $start = array_splice($form['formats']['#header'], 0, $position, array('editor' => t('Text editor')));
+ $start = array_splice($form['formats']['#header'], 0, $position, ['editor' => t('Text editor')]);
$form['formats']['#header'] = array_merge($start, $form['formats']['#header']);
// Then splice in the name of each text editor for each text format.
@@ -94,7 +94,7 @@ function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $for
foreach (Element::children($form['formats']) as $format_id) {
$editor = editor_load($format_id);
$editor_name = ($editor && isset($editors[$editor->getEditor()])) ? $editors[$editor->getEditor()]['label'] : '—';
- $editor_column['editor'] = array('#markup' => $editor_name);
+ $editor_column['editor'] = ['#markup' => $editor_name];
$position = array_search('name', array_keys($form['formats'][$format_id])) + 1;
$start = array_splice($form['formats'][$format_id], 0, $position, $editor_column);
$form['formats'][$format_id] = array_merge($start, $form['formats'][$format_id]);
@@ -116,37 +116,37 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s
// Associate a text editor with this text format.
$manager = \Drupal::service('plugin.manager.editor');
$editor_options = $manager->listOptions();
- $form['editor'] = array(
+ $form['editor'] = [
// Position the editor selection before the filter settings (weight of 0),
// but after the filter label and name (weight of -20).
'#weight' => -9,
- );
- $form['editor']['editor'] = array(
+ ];
+ $form['editor']['editor'] = [
'#type' => 'select',
'#title' => t('Text editor'),
'#options' => $editor_options,
'#empty_option' => t('None'),
'#default_value' => $editor ? $editor->getEditor() : '',
- '#ajax' => array(
- 'trigger_as' => array('name' => 'editor_configure'),
+ '#ajax' => [
+ 'trigger_as' => ['name' => 'editor_configure'],
'callback' => 'editor_form_filter_admin_form_ajax',
'wrapper' => 'editor-settings-wrapper',
- ),
+ ],
'#weight' => -10,
- );
- $form['editor']['configure'] = array(
+ ];
+ $form['editor']['configure'] = [
'#type' => 'submit',
'#name' => 'editor_configure',
'#value' => t('Configure'),
- '#limit_validation_errors' => array(array('editor')),
- '#submit' => array('editor_form_filter_admin_format_editor_configure'),
- '#ajax' => array(
+ '#limit_validation_errors' => [['editor']],
+ '#submit' => ['editor_form_filter_admin_format_editor_configure'],
+ '#ajax' => [
'callback' => 'editor_form_filter_admin_form_ajax',
'wrapper' => 'editor-settings-wrapper',
- ),
+ ],
'#weight' => -10,
- '#attributes' => array('class' => array('js-hide')),
- );
+ '#attributes' => ['class' => ['js-hide']],
+ ];
// If there aren't any options (other than "None"), disable the select list.
if (empty($editor_options)) {
@@ -154,27 +154,27 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s
$form['editor']['editor']['#description'] = t('This option is disabled because no modules that provide a text editor are currently enabled.');
}
- $form['editor']['settings'] = array(
+ $form['editor']['settings'] = [
'#tree' => TRUE,
'#weight' => -8,
'#type' => 'container',
'#id' => 'editor-settings-wrapper',
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'editor/drupal.editor.admin',
- ),
- ),
- );
+ ],
+ ],
+ ];
// Add editor-specific validation and submit handlers.
if ($editor) {
/** @var $plugin \Drupal\editor\Plugin\EditorPluginInterface */
$plugin = $manager->createInstance($editor->getEditor());
- $settings_form = array();
- $settings_form['#element_validate'][] = array($plugin, 'validateConfigurationForm');
+ $settings_form = [];
+ $settings_form['#element_validate'][] = [$plugin, 'validateConfigurationForm'];
$form['editor']['settings']['subform'] = $plugin->buildConfigurationForm($settings_form, $form_state);
- $form['editor']['settings']['subform']['#parents'] = array('editor', 'settings');
- $form['actions']['submit']['#submit'][] = array($plugin, 'submitConfigurationForm');
+ $form['editor']['settings']['subform']['#parents'] = ['editor', 'settings'];
+ $form['actions']['submit']['#submit'][] = [$plugin, 'submitConfigurationForm'];
}
$form['#validate'][] = 'editor_form_filter_admin_format_validate';
@@ -186,7 +186,7 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s
*/
function editor_form_filter_admin_format_editor_configure($form, FormStateInterface $form_state) {
$editor = $form_state->get('editor');
- $editor_value = $form_state->getValue(array('editor', 'editor'));
+ $editor_value = $form_state->getValue(['editor', 'editor']);
if ($editor_value !== NULL) {
if ($editor_value === '') {
$form_state->set('editor', FALSE);
@@ -236,7 +236,7 @@ function editor_form_filter_admin_format_submit($form, FormStateInterface $form_
$format = $form_state->getFormObject()->getEntity();
$format_id = $format->isNew() ? NULL : $format->id();
$original_editor = editor_load($format_id);
- if ($original_editor && $original_editor->getEditor() != $form_state->getValue(array('editor', 'editor'))) {
+ if ($original_editor && $original_editor->getEditor() != $form_state->getValue(['editor', 'editor'])) {
$original_editor->delete();
}
@@ -550,7 +550,7 @@ function editor_file_download($uri) {
* An array of file entity UUIDs.
*/
function _editor_get_file_uuids_by_field(EntityInterface $entity) {
- $uuids = array();
+ $uuids = [];
$formatted_text_fields = _editor_get_formatted_text_fields($entity);
foreach ($formatted_text_fields as $formatted_text_field) {
@@ -579,12 +579,12 @@ function _editor_get_file_uuids_by_field(EntityInterface $entity) {
function _editor_get_formatted_text_fields(FieldableEntityInterface $entity) {
$field_definitions = $entity->getFieldDefinitions();
if (empty($field_definitions)) {
- return array();
+ return [];
}
// Only return formatted text fields.
return array_keys(array_filter($field_definitions, function (FieldDefinitionInterface $definition) {
- return in_array($definition->getType(), array('text', 'text_long', 'text_with_summary'), TRUE);
+ return in_array($definition->getType(), ['text', 'text_long', 'text_with_summary'], TRUE);
}));
}
@@ -601,7 +601,7 @@ function _editor_get_formatted_text_fields(FieldableEntityInterface $entity) {
function _editor_parse_file_uuids($text) {
$dom = Html::load($text);
$xpath = new \DOMXPath($dom);
- $uuids = array();
+ $uuids = [];
foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
$uuids[] = $node->getAttribute('data-entity-uuid');
}
diff --git a/core/modules/editor/src/Ajax/EditorDialogSave.php b/core/modules/editor/src/Ajax/EditorDialogSave.php
index b4d1c27363b..48a7867ad62 100644
--- a/core/modules/editor/src/Ajax/EditorDialogSave.php
+++ b/core/modules/editor/src/Ajax/EditorDialogSave.php
@@ -33,10 +33,10 @@ class EditorDialogSave implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'editorDialogSave',
'values' => $this->values,
- );
+ ];
}
}
diff --git a/core/modules/editor/src/EditorController.php b/core/modules/editor/src/EditorController.php
index 2ef0b041824..995ff7c6c50 100644
--- a/core/modules/editor/src/EditorController.php
+++ b/core/modules/editor/src/EditorController.php
@@ -38,7 +38,7 @@ class EditorController extends ControllerBase {
// Direct text editing is only supported for single-valued fields.
$field = $entity->getTranslation($langcode)->$field_name;
- $editable_text = check_markup($field->value, $field->format, $langcode, array(FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE));
+ $editable_text = check_markup($field->value, $field->format, $langcode, [FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE]);
$response->addCommand(new GetUntransformedTextCommand($editable_text));
return $response;
diff --git a/core/modules/editor/src/EditorXssFilter/Standard.php b/core/modules/editor/src/EditorXssFilter/Standard.php
index 9a8b2b1b1e2..19d5c06c6f5 100644
--- a/core/modules/editor/src/EditorXssFilter/Standard.php
+++ b/core/modules/editor/src/EditorXssFilter/Standard.php
@@ -35,7 +35,7 @@ class Standard extends Xss implements EditorXssFilterInterface {
// directly.
// <iframe> is considered safe because it only allows HTML content to be
// embedded, hence ensuring the same origin policy always applies.
- $dangerous_tags = array('script', 'style', 'link', 'embed', 'object');
+ $dangerous_tags = ['script', 'style', 'link', 'embed', 'object'];
// Simply blacklisting these five dangerous tags would bring safety, but
// also user frustration: what if a text format is configured to allow
@@ -130,13 +130,13 @@ class Standard extends Xss implements EditorXssFilterInterface {
*/
protected static function getAllowedTags($restrictions) {
if ($restrictions === FALSE || !isset($restrictions['allowed'])) {
- return array();
+ return [];
}
$allowed_tags = array_keys($restrictions['allowed']);
// Exclude the wildcard tag, which is used to set attribute restrictions on
// all tags simultaneously.
- $allowed_tags = array_diff($allowed_tags, array('*'));
+ $allowed_tags = array_diff($allowed_tags, ['*']);
return $allowed_tags;
}
@@ -154,7 +154,7 @@ class Standard extends Xss implements EditorXssFilterInterface {
*/
protected static function getForbiddenTags($restrictions) {
if ($restrictions === FALSE || !isset($restrictions['forbidden_tags'])) {
- return array();
+ return [];
}
else {
return $restrictions['forbidden_tags'];
diff --git a/core/modules/editor/src/Element.php b/core/modules/editor/src/Element.php
index b83e9dc7a7f..901731019be 100644
--- a/core/modules/editor/src/Element.php
+++ b/core/modules/editor/src/Element.php
@@ -64,14 +64,14 @@ class Element {
if (!$element['format']['format']['#access']) {
// Use the first (and only) available text format.
$format_id = $format_ids[0];
- $element['format']['editor'] = array(
+ $element['format']['editor'] = [
'#type' => 'hidden',
'#name' => $element['format']['format']['#name'],
'#value' => $format_id,
- '#attributes' => array(
+ '#attributes' => [
'data-editor-for' => $field_id,
- ),
- );
+ ],
+ ];
}
// Otherwise, attach to text format selector.
else {
diff --git a/core/modules/editor/src/Entity/Editor.php b/core/modules/editor/src/Entity/Editor.php
index f504cec7c8c..1a417d77a18 100644
--- a/core/modules/editor/src/Entity/Editor.php
+++ b/core/modules/editor/src/Entity/Editor.php
@@ -49,14 +49,14 @@ class Editor extends ConfigEntityBase implements EditorInterface {
*
* @var array
*/
- protected $settings = array();
+ protected $settings = [];
/**
* The structured array of image upload settings.
*
* @var array
*/
- protected $image_upload = array();
+ protected $image_upload = [];
/**
* The filter format this text editor is associated with.
diff --git a/core/modules/editor/src/Form/EditorImageDialog.php b/core/modules/editor/src/Form/EditorImageDialog.php
index 6f1854663ca..547032e67aa 100644
--- a/core/modules/editor/src/Form/EditorImageDialog.php
+++ b/core/modules/editor/src/Form/EditorImageDialog.php
@@ -94,26 +94,26 @@ class EditorImageDialog extends FormBase {
$existing_file = isset($image_element['data-entity-uuid']) ? \Drupal::entityManager()->loadEntityByUuid('file', $image_element['data-entity-uuid']) : NULL;
$fid = $existing_file ? $existing_file->id() : NULL;
- $form['fid'] = array(
+ $form['fid'] = [
'#title' => $this->t('Image'),
'#type' => 'managed_file',
'#upload_location' => $image_upload['scheme'] . '://' . $image_upload['directory'],
- '#default_value' => $fid ? array($fid) : NULL,
- '#upload_validators' => array(
- 'file_validate_extensions' => array('gif png jpg jpeg'),
- 'file_validate_size' => array($max_filesize),
- 'file_validate_image_resolution' => array($max_dimensions),
- ),
+ '#default_value' => $fid ? [$fid] : NULL,
+ '#upload_validators' => [
+ 'file_validate_extensions' => ['gif png jpg jpeg'],
+ 'file_validate_size' => [$max_filesize],
+ 'file_validate_image_resolution' => [$max_dimensions],
+ ],
'#required' => TRUE,
- );
+ ];
- $form['attributes']['src'] = array(
+ $form['attributes']['src'] = [
'#title' => $this->t('URL'),
'#type' => 'textfield',
'#default_value' => isset($image_element['src']) ? $image_element['src'] : '',
'#maxlength' => 2048,
'#required' => TRUE,
- );
+ ];
// If the editor has image uploads enabled, show a managed_file form item,
// otherwise show a (file URL) text form item.
@@ -137,7 +137,7 @@ class EditorImageDialog extends FormBase {
if ($alt === '' && !empty($image_element['src'])) {
$alt = '""';
}
- $form['attributes']['alt'] = array(
+ $form['attributes']['alt'] = [
'#title' => $this->t('Alternative text'),
'#placeholder' => $this->t('Short description for the visually impaired'),
'#type' => 'textfield',
@@ -145,51 +145,51 @@ class EditorImageDialog extends FormBase {
'#required_error' => $this->t('Alternative text is required.<br />(Only in rare cases should this be left empty. To create empty alternative text, enter <code>""</code> — two double quotes without any content).'),
'#default_value' => $alt,
'#maxlength' => 2048,
- );
+ ];
// When Drupal core's filter_align is being used, the text editor may
// offer the ability to change the alignment.
if (isset($image_element['data-align']) && $editor->getFilterFormat()->filters('filter_align')->status) {
- $form['align'] = array(
+ $form['align'] = [
'#title' => $this->t('Align'),
'#type' => 'radios',
- '#options' => array(
+ '#options' => [
'none' => $this->t('None'),
'left' => $this->t('Left'),
'center' => $this->t('Center'),
'right' => $this->t('Right'),
- ),
+ ],
'#default_value' => $image_element['data-align'] === '' ? 'none' : $image_element['data-align'],
- '#wrapper_attributes' => array('class' => array('container-inline')),
- '#attributes' => array('class' => array('container-inline')),
- '#parents' => array('attributes', 'data-align'),
- );
+ '#wrapper_attributes' => ['class' => ['container-inline']],
+ '#attributes' => ['class' => ['container-inline']],
+ '#parents' => ['attributes', 'data-align'],
+ ];
}
// When Drupal core's filter_caption is being used, the text editor may
// offer the ability to in-place edit the image's caption: show a toggle.
if (isset($image_element['hasCaption']) && $editor->getFilterFormat()->filters('filter_caption')->status) {
- $form['caption'] = array(
+ $form['caption'] = [
'#title' => $this->t('Caption'),
'#type' => 'checkbox',
'#default_value' => $image_element['hasCaption'] === 'true',
- '#parents' => array('attributes', 'hasCaption'),
- );
+ '#parents' => ['attributes', 'hasCaption'],
+ ];
}
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['save_modal'] = array(
+ ];
+ $form['actions']['save_modal'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
// No regular submit-handler. This form only works via JavaScript.
- '#submit' => array(),
- '#ajax' => array(
+ '#submit' => [],
+ '#ajax' => [
'callback' => '::submitForm',
'event' => 'click',
- ),
- );
+ ],
+ ];
return $form;
}
@@ -202,22 +202,22 @@ class EditorImageDialog extends FormBase {
// Convert any uploaded files from the FID values to data-entity-uuid
// attributes and set data-entity-type to 'file'.
- $fid = $form_state->getValue(array('fid', 0));
+ $fid = $form_state->getValue(['fid', 0]);
if (!empty($fid)) {
$file = $this->fileStorage->load($fid);
$file_url = file_create_url($file->getFileUri());
// Transform absolute image URLs to relative image URLs: prevent problems
// on multisite set-ups and prevent mixed content errors.
$file_url = file_url_transform_relative($file_url);
- $form_state->setValue(array('attributes', 'src'), $file_url);
- $form_state->setValue(array('attributes', 'data-entity-uuid'), $file->uuid());
- $form_state->setValue(array('attributes', 'data-entity-type'), 'file');
+ $form_state->setValue(['attributes', 'src'], $file_url);
+ $form_state->setValue(['attributes', 'data-entity-uuid'], $file->uuid());
+ $form_state->setValue(['attributes', 'data-entity-type'], 'file');
}
// When the alt attribute is set to two double quotes, transform it to the
// empty string: two double quotes signify "empty alt attribute". See above.
- if (trim($form_state->getValue(array('attributes', 'alt'))) === '""') {
- $form_state->setValue(array('attributes', 'alt'), '');
+ if (trim($form_state->getValue(['attributes', 'alt'])) === '""') {
+ $form_state->setValue(['attributes', 'alt'], '');
}
if ($form_state->getErrors()) {
diff --git a/core/modules/editor/src/Form/EditorLinkDialog.php b/core/modules/editor/src/Form/EditorLinkDialog.php
index 05703ba2bf9..724f41307be 100644
--- a/core/modules/editor/src/Form/EditorLinkDialog.php
+++ b/core/modules/editor/src/Form/EditorLinkDialog.php
@@ -32,7 +32,7 @@ class EditorLinkDialog extends FormBase {
// The default values are set directly from \Drupal::request()->request,
// provided by the editor plugin opening the dialog.
$user_input = $form_state->getUserInput();
- $input = isset($user_input['editor_object']) ? $user_input['editor_object'] : array();
+ $input = isset($user_input['editor_object']) ? $user_input['editor_object'] : [];
$form['#tree'] = TRUE;
$form['#attached']['library'][] = 'editor/drupal.editor.dialog';
@@ -41,26 +41,26 @@ class EditorLinkDialog extends FormBase {
// Everything under the "attributes" key is merged directly into the
// generated link tag's attributes.
- $form['attributes']['href'] = array(
+ $form['attributes']['href'] = [
'#title' => $this->t('URL'),
'#type' => 'textfield',
'#default_value' => isset($input['href']) ? $input['href'] : '',
'#maxlength' => 2048,
- );
+ ];
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['save_modal'] = array(
+ ];
+ $form['actions']['save_modal'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
// No regular submit-handler. This form only works via JavaScript.
- '#submit' => array(),
- '#ajax' => array(
+ '#submit' => [],
+ '#ajax' => [
'callback' => '::submitForm',
'event' => 'click',
- ),
- );
+ ],
+ ];
return $form;
}
diff --git a/core/modules/editor/src/Plugin/EditorBase.php b/core/modules/editor/src/Plugin/EditorBase.php
index bd429d1376d..11cf01bde8f 100644
--- a/core/modules/editor/src/Plugin/EditorBase.php
+++ b/core/modules/editor/src/Plugin/EditorBase.php
@@ -26,7 +26,7 @@ abstract class EditorBase extends PluginBase implements EditorPluginInterface {
* {@inheritdoc}
*/
public function getDefaultSettings() {
- return array();
+ return [];
}
/**
diff --git a/core/modules/editor/src/Plugin/EditorManager.php b/core/modules/editor/src/Plugin/EditorManager.php
index 5ae5bd29957..4585da7e721 100644
--- a/core/modules/editor/src/Plugin/EditorManager.php
+++ b/core/modules/editor/src/Plugin/EditorManager.php
@@ -40,7 +40,7 @@ class EditorManager extends DefaultPluginManager {
* An array of translated text editor labels, keyed by ID.
*/
public function listOptions() {
- $options = array();
+ $options = [];
foreach ($this->getDefinitions() as $key => $definition) {
$options[$key] = $definition['label'];
}
@@ -59,9 +59,9 @@ class EditorManager extends DefaultPluginManager {
* @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
*/
public function getAttachments(array $format_ids) {
- $attachments = array('library' => array());
+ $attachments = ['library' => []];
- $settings = array();
+ $settings = [];
foreach ($format_ids as $format_id) {
$editor = editor_load($format_id);
if (!$editor) {
@@ -75,20 +75,20 @@ class EditorManager extends DefaultPluginManager {
$attachments['library'] = array_merge($attachments['library'], $plugin->getLibraries($editor));
// Format-specific JavaScript settings.
- $settings['editor']['formats'][$format_id] = array(
+ $settings['editor']['formats'][$format_id] = [
'format' => $format_id,
'editor' => $editor->getEditor(),
'editorSettings' => $plugin->getJSSettings($editor),
'editorSupportsContentFiltering' => $plugin_definition['supports_content_filtering'],
'isXssSafe' => $plugin_definition['is_xss_safe'],
- );
+ ];
}
// Allow other modules to alter all JavaScript settings.
$this->moduleHandler->alter('editor_js_settings', $settings);
if (empty($attachments['library']) && empty($settings)) {
- return array();
+ return [];
}
$attachments['drupalSettings'] = $settings;
diff --git a/core/modules/editor/src/Plugin/Filter/EditorFileReference.php b/core/modules/editor/src/Plugin/Filter/EditorFileReference.php
index 5eb76c6303d..cf725a71371 100644
--- a/core/modules/editor/src/Plugin/Filter/EditorFileReference.php
+++ b/core/modules/editor/src/Plugin/Filter/EditorFileReference.php
@@ -68,7 +68,7 @@ class EditorFileReference extends FilterBase implements ContainerFactoryPluginIn
if (stristr($text, 'data-entity-type="file"') !== FALSE) {
$dom = Html::load($text);
$xpath = new \DOMXPath($dom);
- $processed_uuids = array();
+ $processed_uuids = [];
foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
$uuid = $node->getAttribute('data-entity-uuid');
diff --git a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
index 5d5034293a0..27a700bd1e7 100644
--- a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
+++ b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
@@ -60,7 +60,7 @@ class Editor extends PluginBase implements InPlaceEditorInterface {
*/
protected function textFormatHasTransformationFilters($format_id) {
$format = FilterFormat::load($format_id);
- return (bool) count(array_intersect(array(FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE), $format->getFiltertypes()));
+ return (bool) count(array_intersect([FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE], $format->getFiltertypes()));
}
/**
@@ -74,7 +74,7 @@ class Editor extends PluginBase implements InPlaceEditorInterface {
$definitions = $manager->getDefinitions();
// Filter the current user's formats to those that support inline editing.
- $formats = array();
+ $formats = [];
foreach ($user_format_ids as $format_id) {
if ($editor = editor_load($format_id)) {
$editor_id = $editor->getEditor();
diff --git a/core/modules/editor/src/Tests/EditorAdminTest.php b/core/modules/editor/src/Tests/EditorAdminTest.php
index 97d47b11e63..4315a6dabd8 100644
--- a/core/modules/editor/src/Tests/EditorAdminTest.php
+++ b/core/modules/editor/src/Tests/EditorAdminTest.php
@@ -20,7 +20,7 @@ class EditorAdminTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'editor');
+ public static $modules = ['filter', 'editor'];
/**
* A user with the 'administer filters' permission.
@@ -33,16 +33,16 @@ class EditorAdminTest extends WebTestBase {
parent::setUp();
// Add text format.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
// Create admin user.
- $this->adminUser = $this->drupalCreateUser(array('administer filters'));
+ $this->adminUser = $this->drupalCreateUser(['administer filters']);
}
/**
@@ -83,9 +83,9 @@ class EditorAdminTest extends WebTestBase {
$this->verifyUnicornEditorConfiguration('filtered_html', FALSE);
// Switch back to 'None' and check the Unicorn Editor's settings are gone.
- $edit = array(
+ $edit = [
'editor[editor]' => '',
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, 'editor_configure');
$unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
$this->assertTrue(count($unicorn_setting) === 0, "Unicorn Editor's settings form is no longer present.");
@@ -135,7 +135,7 @@ class EditorAdminTest extends WebTestBase {
$this->drupalLogin($account);
// The node edit page header.
- $text = t('<em>Edit @type</em> @title', array('@type' => $node_type->label(), '@title' => $node->label()));
+ $text = t('<em>Edit @type</em> @title', ['@type' => $node_type->label(), '@title' => $node->label()]);
// Go to node edit form.
$this->drupalGet('node/' . $node->id() . '/edit');
@@ -162,10 +162,10 @@ class EditorAdminTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/content/formats/add');
// Configure the text format name.
- $edit = array(
+ $edit = [
'name' => $format_name,
'format' => $format_id,
- );
+ ];
$edit += $this->selectUnicornEditor();
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
}
@@ -175,7 +175,7 @@ class EditorAdminTest extends WebTestBase {
*/
protected function enableUnicornEditor() {
if (!$this->container->get('module_handler')->moduleExists('editor_test')) {
- $this->container->get('module_installer')->install(array('editor_test'));
+ $this->container->get('module_installer')->install(['editor_test']);
}
}
@@ -200,9 +200,9 @@ class EditorAdminTest extends WebTestBase {
$this->assertNoRaw(t('This option is disabled because no modules that provide a text editor are currently enabled.'), 'Description for select absent that tells users to install a text editor module.');
// Select the "Unicorn Editor" editor and click the "Configure" button.
- $edit = array(
+ $edit = [
'editor[editor]' => 'unicorn',
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, 'editor_configure');
$unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
$this->assertTrue(count($unicorn_setting), "Unicorn Editor's settings form is present.");
diff --git a/core/modules/editor/src/Tests/EditorLoadingTest.php b/core/modules/editor/src/Tests/EditorLoadingTest.php
index 88055e916a5..419215f8732 100644
--- a/core/modules/editor/src/Tests/EditorLoadingTest.php
+++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
@@ -20,7 +20,7 @@ class EditorLoadingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'editor', 'editor_test', 'node');
+ public static $modules = ['filter', 'editor', 'editor_test', 'node'];
/**
* An untrusted user, with access to the 'plain_text' format.
@@ -51,57 +51,57 @@ class EditorLoadingTest extends WebTestBase {
\Drupal::service('plugin.manager.editor')->clearCachedDefinitions();
// Add text formats.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$full_html_format->save();
// Create article node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
- ));
+ ]);
// Create page node type, but remove the body.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'page',
'name' => 'Page',
- ));
+ ]);
$body = FieldConfig::loadByName('node', 'page', 'body');
$body->delete();
// Create a formatted text field, which uses an <input type="text">.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_text',
'entity_type' => 'node',
'type' => 'text',
- ))->save();
+ ])->save();
- FieldConfig::create(array(
+ FieldConfig::create([
'field_name' => 'field_text',
'entity_type' => 'node',
'label' => 'Textfield',
'bundle' => 'page',
- ))->save();
+ ])->save();
entity_get_form_display('node', 'page', 'default')
->setComponent('field_text')
->save();
// Create 3 users, each with access to different text formats.
- $this->untrustedUser = $this->drupalCreateUser(array('create article content', 'edit any article content'));
- $this->normalUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html'));
- $this->privilegedUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'create page content', 'edit any page content', 'use text format filtered_html', 'use text format full_html'));
+ $this->untrustedUser = $this->drupalCreateUser(['create article content', 'edit any article content']);
+ $this->normalUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'use text format filtered_html']);
+ $this->privilegedUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'create page content', 'edit any page content', 'use text format filtered_html', 'use text format full_html']);
}
/**
@@ -112,13 +112,13 @@ class EditorLoadingTest extends WebTestBase {
$editor = Editor::create([
'format' => 'full_html',
'editor' => 'unicorn',
- 'image_upload' => array(
+ 'image_upload' => [
'status' => FALSE,
'scheme' => file_default_scheme(),
'directory' => 'inline-images',
'max_size' => '',
- 'max_dimensions' => array('width' => '', 'height' => ''),
- )
+ 'max_dimensions' => ['width' => '', 'height' => ''],
+ ]
]);
$editor->save();
@@ -140,13 +140,13 @@ class EditorLoadingTest extends WebTestBase {
$this->drupalLogin($this->privilegedUser);
$this->drupalGet('node/add/article');
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck('body');
- $expected = array('formats' => array('full_html' => array(
+ $expected = ['formats' => ['full_html' => [
'format' => 'full_html',
'editor' => 'unicorn',
- 'editorSettings' => array('ponyModeEnabled' => TRUE),
+ 'editorSettings' => ['ponyModeEnabled' => TRUE],
'editorSupportsContentFiltering' => TRUE,
'isXssSafe' => FALSE,
- )));
+ ]]];
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $settings['editor'], "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
@@ -174,13 +174,13 @@ class EditorLoadingTest extends WebTestBase {
$this->drupalLogin($this->untrustedUser);
$this->drupalGet('node/add/article');
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck('body');
- $expected = array('formats' => array('plain_text' => array(
+ $expected = ['formats' => ['plain_text' => [
'format' => 'plain_text',
'editor' => 'unicorn',
- 'editorSettings' => array('ponyModeEnabled' => TRUE),
+ 'editorSettings' => ['ponyModeEnabled' => TRUE],
'editorSupportsContentFiltering' => TRUE,
'isXssSafe' => FALSE,
- )));
+ ]]];
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $settings['editor'], "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
@@ -191,12 +191,12 @@ class EditorLoadingTest extends WebTestBase {
// Create an "article" node that uses the full_html text format, then try
// to let the untrusted user edit it.
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'type' => 'article',
- 'body' => array(
- array('value' => $this->randomMachineName(32), 'format' => 'full_html')
- ),
- ));
+ 'body' => [
+ ['value' => $this->randomMachineName(32), 'format' => 'full_html']
+ ],
+ ]);
// The untrusted user tries to edit content that is written in a text format
// that (s)he is not allowed to use. The editor is still loaded. CKEditor,
@@ -220,23 +220,23 @@ class EditorLoadingTest extends WebTestBase {
$editor = Editor::create([
'format' => 'full_html',
'editor' => 'unicorn',
- 'image_upload' => array(
+ 'image_upload' => [
'status' => FALSE,
'scheme' => file_default_scheme(),
'directory' => 'inline-images',
'max_size' => '',
- 'max_dimensions' => array('width' => '', 'height' => ''),
- )
+ 'max_dimensions' => ['width' => '', 'height' => ''],
+ ]
]);
$editor->save();
// Create an "page" node that uses the full_html text format.
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'type' => 'page',
- 'field_text' => array(
- array('value' => $this->randomMachineName(32), 'format' => 'full_html')
- ),
- ));
+ 'field_text' => [
+ ['value' => $this->randomMachineName(32), 'format' => 'full_html']
+ ],
+ ]);
// Assert the unicorn editor works with textfields.
$this->drupalLogin($this->privilegedUser);
@@ -268,7 +268,7 @@ class EditorLoadingTest extends WebTestBase {
protected function getThingsToCheck($field_name, $type = 'textarea') {
$settings = $this->getDrupalSettings();
- return array(
+ return [
// JavaScript settings.
$settings,
// Editor.module's JS settings present.
@@ -279,7 +279,7 @@ class EditorLoadingTest extends WebTestBase {
$this->xpath('//' . $type . '[@id="edit-' . $field_name . '-0-value"]'),
// Format selector.
$this->xpath('//select[contains(@class, "filter-list")]'),
- );
+ ];
}
}
diff --git a/core/modules/editor/src/Tests/EditorSecurityTest.php b/core/modules/editor/src/Tests/EditorSecurityTest.php
index c771439c697..0c29a58d5ba 100644
--- a/core/modules/editor/src/Tests/EditorSecurityTest.php
+++ b/core/modules/editor/src/Tests/EditorSecurityTest.php
@@ -40,7 +40,7 @@ class EditorSecurityTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'editor', 'editor_test', 'node');
+ public static $modules = ['filter', 'editor', 'editor_test', 'node'];
/**
* User with access to Restricted HTML text format without text editor.
@@ -83,74 +83,74 @@ class EditorSecurityTest extends WebTestBase {
// With text formats 2, 3 and 5, we also associate a text editor that does
// not guarantee XSS safety. "restricted" means the text format has XSS
// filters on output, "unrestricted" means the opposite.
- $format = FilterFormat::create(array(
+ $format = FilterFormat::create([
'format' => 'restricted_without_editor',
'name' => 'Restricted HTML, without text editor',
'weight' => 0,
- 'filters' => array(
+ 'filters' => [
// A filter of the FilterInterface::TYPE_HTML_RESTRICTOR type.
- 'filter_html' => array(
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<h2> <h3> <h4> <h5> <h6> <p> <br> <strong> <a>',
- )
- ),
- ),
- ));
+ ]
+ ],
+ ],
+ ]);
$format->save();
- $format = FilterFormat::create(array(
+ $format = FilterFormat::create([
'format' => 'restricted_with_editor',
'name' => 'Restricted HTML, with text editor',
'weight' => 1,
- 'filters' => array(
+ 'filters' => [
// A filter of the FilterInterface::TYPE_HTML_RESTRICTOR type.
- 'filter_html' => array(
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<h2> <h3> <h4> <h5> <h6> <p> <br> <strong> <a>',
- )
- ),
- ),
- ));
+ ]
+ ],
+ ],
+ ]);
$format->save();
$editor = Editor::create([
'format' => 'restricted_with_editor',
'editor' => 'unicorn',
]);
$editor->save();
- $format = FilterFormat::create(array(
+ $format = FilterFormat::create([
'format' => 'restricted_plus_dangerous_tag_with_editor',
'name' => 'Restricted HTML, dangerous tag allowed, with text editor',
'weight' => 1,
- 'filters' => array(
+ 'filters' => [
// A filter of the FilterInterface::TYPE_HTML_RESTRICTOR type.
- 'filter_html' => array(
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<h2> <h3> <h4> <h5> <h6> <p> <br> <strong> <a> <embed>',
- )
- ),
- ),
- ));
+ ]
+ ],
+ ],
+ ]);
$format->save();
$editor = Editor::create([
'format' => 'restricted_plus_dangerous_tag_with_editor',
'editor' => 'unicorn',
]);
$editor->save();
- $format = FilterFormat::create(array(
+ $format = FilterFormat::create([
'format' => 'unrestricted_without_editor',
'name' => 'Unrestricted HTML, without text editor',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$format->save();
- $format = FilterFormat::create(array(
+ $format = FilterFormat::create([
'format' => 'unrestricted_with_editor',
'name' => 'Unrestricted HTML, with text editor',
'weight' => 1,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$format->save();
$editor = Editor::create([
'format' => 'unrestricted_with_editor',
@@ -160,10 +160,10 @@ class EditorSecurityTest extends WebTestBase {
// Create node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
- ));
+ ]);
// Create 4 users, each with access to different text formats/editors:
// - "untrusted": restricted_without_editor
@@ -172,22 +172,22 @@ class EditorSecurityTest extends WebTestBase {
// - "privileged": restricted_without_editor, restricted_with_editor,
// restricted_plus_dangerous_tag_with_editor,
// unrestricted_without_editor and unrestricted_with_editor
- $this->untrustedUser = $this->drupalCreateUser(array(
+ $this->untrustedUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'use text format restricted_without_editor',
- ));
- $this->normalUser = $this->drupalCreateUser(array(
+ ]);
+ $this->normalUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'use text format restricted_with_editor',
- ));
- $this->trustedUser = $this->drupalCreateUser(array(
+ ]);
+ $this->trustedUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'use text format restricted_plus_dangerous_tag_with_editor',
- ));
- $this->privilegedUser = $this->drupalCreateUser(array(
+ ]);
+ $this->privilegedUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'use text format restricted_without_editor',
@@ -195,25 +195,25 @@ class EditorSecurityTest extends WebTestBase {
'use text format restricted_plus_dangerous_tag_with_editor',
'use text format unrestricted_without_editor',
'use text format unrestricted_with_editor',
- ));
+ ]);
// Create an "article" node for each possible text format, with the same
// sample content, to do our tests on.
- $samples = array(
- array('author' => $this->untrustedUser->id(), 'format' => 'restricted_without_editor'),
- array('author' => $this->normalUser->id(), 'format' => 'restricted_with_editor'),
- array('author' => $this->trustedUser->id(), 'format' => 'restricted_plus_dangerous_tag_with_editor'),
- array('author' => $this->privilegedUser->id(), 'format' => 'unrestricted_without_editor'),
- array('author' => $this->privilegedUser->id(), 'format' => 'unrestricted_with_editor'),
- );
+ $samples = [
+ ['author' => $this->untrustedUser->id(), 'format' => 'restricted_without_editor'],
+ ['author' => $this->normalUser->id(), 'format' => 'restricted_with_editor'],
+ ['author' => $this->trustedUser->id(), 'format' => 'restricted_plus_dangerous_tag_with_editor'],
+ ['author' => $this->privilegedUser->id(), 'format' => 'unrestricted_without_editor'],
+ ['author' => $this->privilegedUser->id(), 'format' => 'unrestricted_with_editor'],
+ ];
foreach ($samples as $sample) {
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'type' => 'article',
- 'body' => array(
- array('value' => self::$sampleContent, 'format' => $sample['format'])
- ),
+ 'body' => [
+ ['value' => self::$sampleContent, 'format' => $sample['format']]
+ ],
'uid' => $sample['author']
- ));
+ ]);
}
}
@@ -223,64 +223,64 @@ class EditorSecurityTest extends WebTestBase {
* Tests 8 scenarios. Tests only with a text editor that is not XSS-safe.
*/
function testInitialSecurity() {
- $expected = array(
- array(
+ $expected = [
+ [
'node_id' => 1,
'format' => 'restricted_without_editor',
// No text editor => no XSS filtering.
'value' => self::$sampleContent,
- 'users' => array(
+ 'users' => [
$this->untrustedUser,
$this->privilegedUser,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 2,
'format' => 'restricted_with_editor',
// Text editor => XSS filtering.
'value' => self::$sampleContentSecured,
- 'users' => array(
+ 'users' => [
$this->normalUser,
$this->privilegedUser,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 3,
'format' => 'restricted_plus_dangerous_tag_with_editor',
// Text editor => XSS filtering.
'value' => self::$sampleContentSecuredEmbedAllowed,
- 'users' => array(
+ 'users' => [
$this->trustedUser,
$this->privilegedUser,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 4,
'format' => 'unrestricted_without_editor',
// No text editor => no XSS filtering.
'value' => self::$sampleContent,
- 'users' => array(
+ 'users' => [
$this->privilegedUser,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 5,
'format' => 'unrestricted_with_editor',
// Text editor, no security filter => no XSS filtering.
'value' => self::$sampleContent,
- 'users' => array(
+ 'users' => [
$this->privilegedUser,
- ),
- ),
- );
+ ],
+ ],
+ ];
// Log in as each user that may edit the content, and assert the value.
foreach ($expected as $case) {
foreach ($case['users'] as $account) {
- $this->pass(format_string('Scenario: sample %sample_id, %format.', array(
+ $this->pass(format_string('Scenario: sample %sample_id, %format.', [
'%sample_id' => $case['node_id'],
'%format' => $case['format'],
- )));
+ ]));
$this->drupalLogin($account);
$this->drupalGet('node/' . $case['node_id'] . '/edit');
$dom_node = $this->xpath('//textarea[@id="edit-body-0-value"]');
@@ -303,25 +303,25 @@ class EditorSecurityTest extends WebTestBase {
* <script> tag would be executed. Unless we apply appropriate filtering.
*/
function testSwitchingSecurity() {
- $expected = array(
- array(
+ $expected = [
+ [
'node_id' => 1,
'value' => self::$sampleContent, // No text editor => no XSS filtering.
'format' => 'restricted_without_editor',
- 'switch_to' => array(
+ 'switch_to' => [
'restricted_with_editor' => self::$sampleContentSecured,
// Intersection of restrictions => most strict XSS filtering.
'restricted_plus_dangerous_tag_with_editor' => self::$sampleContentSecured,
// No text editor => no XSS filtering.
'unrestricted_without_editor' => FALSE,
'unrestricted_with_editor' => self::$sampleContentSecured,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 2,
'value' => self::$sampleContentSecured, // Text editor => XSS filtering.
'format' => 'restricted_with_editor',
- 'switch_to' => array(
+ 'switch_to' => [
// No text editor => no XSS filtering.
'restricted_without_editor' => FALSE,
// Intersection of restrictions => most strict XSS filtering.
@@ -329,13 +329,13 @@ class EditorSecurityTest extends WebTestBase {
// No text editor => no XSS filtering.
'unrestricted_without_editor' => FALSE,
'unrestricted_with_editor' => self::$sampleContentSecured,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 3,
'value' => self::$sampleContentSecuredEmbedAllowed, // Text editor => XSS filtering.
'format' => 'restricted_plus_dangerous_tag_with_editor',
- 'switch_to' => array(
+ 'switch_to' => [
// No text editor => no XSS filtering.
'restricted_without_editor' => FALSE,
// Intersection of restrictions => most strict XSS filtering.
@@ -344,13 +344,13 @@ class EditorSecurityTest extends WebTestBase {
'unrestricted_without_editor' => FALSE,
// Intersection of restrictions => most strict XSS filtering.
'unrestricted_with_editor' => self::$sampleContentSecured,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 4,
'value' => self::$sampleContent, // No text editor => no XSS filtering.
'format' => 'unrestricted_without_editor',
- 'switch_to' => array(
+ 'switch_to' => [
// No text editor => no XSS filtering.
'restricted_without_editor' => FALSE,
'restricted_with_editor' => self::$sampleContentSecured,
@@ -360,13 +360,13 @@ class EditorSecurityTest extends WebTestBase {
// filters: resulting content when viewed was already vulnerable, so
// it must be intentional.
'unrestricted_with_editor' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
'node_id' => 5,
'value' => self::$sampleContentSecured, // Text editor => XSS filtering.
'format' => 'unrestricted_with_editor',
- 'switch_to' => array(
+ 'switch_to' => [
// From editor, no security filters to security filters, no editor: no
// risk.
'restricted_without_editor' => FALSE,
@@ -377,9 +377,9 @@ class EditorSecurityTest extends WebTestBase {
// filters: resulting content when viewed was already vulnerable, so
// it must be intentional.
'unrestricted_without_editor' => FALSE,
- ),
- ),
- );
+ ],
+ ],
+ ];
// Log in as the privileged user, and for every sample, do the following:
// - switch to every other text format/editor
@@ -395,15 +395,15 @@ class EditorSecurityTest extends WebTestBase {
// Switch to every other text format/editor and verify the results.
foreach ($case['switch_to'] as $format => $expected_filtered_value) {
- $this->pass(format_string('Scenario: sample %sample_id, switch from %original_format to %format.', array(
+ $this->pass(format_string('Scenario: sample %sample_id, switch from %original_format to %format.', [
'%sample_id' => $case['node_id'],
'%original_format' => $case['format'],
'%format' => $format,
- )));
- $post = array(
+ ]));
+ $post = [
'value' => self::$sampleContent,
'original_format_id' => $case['format'],
- );
+ ];
$response = $this->drupalPostWithFormat('editor/filter_xss/' . $format, 'json', $post);
$this->assertResponse(200);
$json = Json::decode($response);
diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php
index c827450aeb0..a4515d56730 100644
--- a/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php
+++ b/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php
@@ -19,47 +19,47 @@ class QuickEditIntegrationLoadingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('quickedit', 'filter', 'node', 'editor');
+ public static $modules = ['quickedit', 'filter', 'node', 'editor'];
/**
* The basic permissions necessary to view content and use in-place editing.
*
* @var array
*/
- protected static $basicPermissions = array('access content', 'create article content', 'use text format filtered_html', 'access contextual links');
+ protected static $basicPermissions = ['access content', 'create article content', 'use text format filtered_html', 'access contextual links'];
protected function setUp() {
parent::setUp();
// Create a text format.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(
- 'filter_caption' => array(
+ 'filters' => [
+ 'filter_caption' => [
'status' => 1,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$filtered_html_format->save();
// Create a node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
- ));
+ ]);
// Create one node of the above node type using the above text format.
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'type' => 'article',
- 'body' => array(
- 0 => array(
+ 'body' => [
+ 0 => [
'value' => '<p>Do you also love Drupal?</p><img src="druplicon.png" data-caption="Druplicon" />',
'format' => 'filtered_html',
- )
- )
- ));
+ ]
+ ]
+ ]);
}
/**
@@ -70,11 +70,11 @@ class QuickEditIntegrationLoadingTest extends WebTestBase {
// or both of the following permissions:
// - the 'access in-place editing' permission
// - the 'edit any article content' permission (necessary to edit node 1)
- $users = array(
+ $users = [
$this->drupalCreateUser(static::$basicPermissions),
- $this->drupalCreateUser(array_merge(static::$basicPermissions, array('edit any article content'))),
- $this->drupalCreateUser(array_merge(static::$basicPermissions, array('access in-place editing')))
- );
+ $this->drupalCreateUser(array_merge(static::$basicPermissions, ['edit any article content'])),
+ $this->drupalCreateUser(array_merge(static::$basicPermissions, ['access in-place editing']))
+ ];
// Now test with each of the 3 users with insufficient permissions.
foreach ($users as $user) {
@@ -86,7 +86,7 @@ class QuickEditIntegrationLoadingTest extends WebTestBase {
// Retrieving the untransformed text should result in an 403 response and
// return a different error message depending of the missing permission.
- $response = $this->drupalPost('editor/' . 'node/1/body/en/full', '', array(), array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax')));
+ $response = $this->drupalPost('editor/' . 'node/1/body/en/full', '', [], ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(403);
if (!$user->hasPermission('access in-place editing')) {
$message = "The 'access in-place editing' permission is required.";
@@ -102,7 +102,7 @@ class QuickEditIntegrationLoadingTest extends WebTestBase {
* Test loading of untransformed text when a user does have access to it.
*/
public function testUserWithPermission() {
- $user = $this->drupalCreateUser(array_merge(static::$basicPermissions, array('edit any article content', 'access in-place editing')));
+ $user = $this->drupalCreateUser(array_merge(static::$basicPermissions, ['edit any article content', 'access in-place editing']));
$this->drupalLogin($user);
$this->drupalGet('node/1');
diff --git a/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php b/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
index e78536950d4..0d787a8d896 100644
--- a/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
+++ b/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
@@ -26,18 +26,18 @@ class TRexEditor extends EditorBase {
* {@inheritdoc}
*/
public function getDefaultSettings() {
- return array('stumpy_arms' => TRUE);
+ return ['stumpy_arms' => TRUE];
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
- $form['stumpy_arms'] = array(
+ $form['stumpy_arms'] = [
'#title' => t('Stumpy arms'),
'#type' => 'checkbox',
'#default_value' => TRUE,
- );
+ ];
return $form;
}
@@ -45,7 +45,7 @@ class TRexEditor extends EditorBase {
* {@inheritdoc}
*/
public function getJSSettings(Editor $editor) {
- $js_settings = array();
+ $js_settings = [];
$settings = $editor->getSettings();
if ($settings['stumpy_arms']) {
$js_settings['doMyArmsLookStumpy'] = TRUE;
@@ -57,9 +57,9 @@ class TRexEditor extends EditorBase {
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
- return array(
+ return [
'editor_test/trex',
- );
+ ];
}
}
diff --git a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
index c196751ef30..ddc730cb36b 100644
--- a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
+++ b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
@@ -27,18 +27,18 @@ class UnicornEditor extends EditorBase {
* {@inheritdoc}
*/
function getDefaultSettings() {
- return array('ponies_too' => TRUE);
+ return ['ponies_too' => TRUE];
}
/**
* {@inheritdoc}
*/
function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
- $form['ponies_too'] = array(
+ $form['ponies_too'] = [
'#title' => t('Pony mode'),
'#type' => 'checkbox',
'#default_value' => TRUE,
- );
+ ];
return $form;
}
@@ -46,7 +46,7 @@ class UnicornEditor extends EditorBase {
* {@inheritdoc}
*/
function getJSSettings(Editor $editor) {
- $js_settings = array();
+ $js_settings = [];
$settings = $editor->getSettings();
if ($settings['ponies_too']) {
$js_settings['ponyModeEnabled'] = TRUE;
@@ -58,9 +58,9 @@ class UnicornEditor extends EditorBase {
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
- return array(
+ return [
'editor_test/unicorn',
- );
+ ];
}
}
diff --git a/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php b/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php
index 51eee9731c6..621aabe4bde 100644
--- a/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php
+++ b/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php
@@ -19,7 +19,7 @@ class EditorFileReferenceFilterTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'filter', 'editor', 'field', 'file', 'user');
+ public static $modules = ['system', 'filter', 'editor', 'field', 'file', 'user'];
/**
* @var \Drupal\filter\Plugin\FilterInterface[]
@@ -31,12 +31,12 @@ class EditorFileReferenceFilterTest extends KernelTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
$this->installEntitySchema('file');
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('file', ['file_usage']);
$manager = $this->container->get('plugin.manager.filter');
- $bag = new FilterPluginCollection($manager, array());
+ $bag = new FilterPluginCollection($manager, []);
$this->filters = $bag->getAll();
}
@@ -99,7 +99,7 @@ class EditorFileReferenceFilterTest extends KernelTestBase {
$input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="invalid-' . $uuid . '" />';
$output = $test($input);
$this->assertIdentical($input, $output->getProcessedText());
- $this->assertEqual(array(), $output->getCacheTags());
+ $this->assertEqual([], $output->getCacheTags());
$this->pass('Two different data-entity-uuid attributes.');
$input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
diff --git a/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php b/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php
index 04113880cdb..aac665d61b5 100644
--- a/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php
+++ b/core/modules/editor/tests/src/Kernel/EditorFileUsageTest.php
@@ -23,22 +23,22 @@ class EditorFileUsageTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('editor', 'editor_test', 'node', 'file');
+ public static $modules = ['editor', 'editor_test', 'node', 'file'];
protected function setUp() {
parent::setUp();
$this->installEntitySchema('file');
- $this->installSchema('node', array('node_access'));
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('node', ['node_access']);
+ $this->installSchema('file', ['file_usage']);
$this->installConfig(['node']);
// Add text formats.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
// Set cardinality for body field.
@@ -63,13 +63,13 @@ class EditorFileUsageTest extends EntityKernelTestBase {
* Tests the configurable text editor manager.
*/
public function testEditorEntityHooks() {
- $image_paths = array(
+ $image_paths = [
0 => 'core/misc/druplicon.png',
1 => 'core/misc/tree.png',
2 => 'core/misc/help.png',
- );
+ ];
- $image_entities = array();
+ $image_entities = [];
foreach ($image_paths as $key => $image_path) {
$image = File::create();
$image->setFileUri($image_path);
@@ -77,12 +77,12 @@ class EditorFileUsageTest extends EntityKernelTestBase {
$image->save();
$file_usage = $this->container->get('file.usage');
- $this->assertIdentical(array(), $file_usage->listUsage($image), 'The image ' . $image_paths[$key] . ' has zero usages.');
+ $this->assertIdentical([], $file_usage->listUsage($image), 'The image ' . $image_paths[$key] . ' has zero usages.');
$image_entities[] = $image;
}
- $body = array();
+ $body = [];
foreach ($image_entities as $key => $image_entity) {
// Don't be rude, say hello.
$body_value = '<p>Hello, world!</p>';
@@ -95,10 +95,10 @@ class EditorFileUsageTest extends EntityKernelTestBase {
// Test handling of a non-existing UUID.
$body_value .= '<img src="awesome-llama-' . $key . '.jpg" data-entity-type="file" data-entity-uuid="30aac704-ba2c-40fc-b609-9ed121aa90f4" />';
- $body[] = array(
+ $body[] = [
'value' => $body_value,
'format' => 'filtered_html',
- );
+ ];
}
// Test editor_entity_insert(): increment.
@@ -111,7 +111,7 @@ class EditorFileUsageTest extends EntityKernelTestBase {
]);
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '1'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 1 usage.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '1']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 1 usage.');
}
// Test editor_entity_update(): increment, twice, by creating new revisions.
@@ -121,12 +121,12 @@ class EditorFileUsageTest extends EntityKernelTestBase {
$node->setNewRevision(TRUE);
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '3'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 3 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '3']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 3 usages.');
}
// Test hook_entity_update(): decrement, by modifying the last revision:
// remove the data-entity-type attribute from the body field.
- $original_values = array();
+ $original_values = [];
for ($i = 0; $i < count($image_entities); $i++) {
$original_value = $node->body[$i]->value;
$new_value = str_replace('data-entity-type', 'data-entity-type-modified', $original_value);
@@ -135,7 +135,7 @@ class EditorFileUsageTest extends EntityKernelTestBase {
}
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '2']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
}
// Test editor_entity_update(): increment again by creating a new revision:
@@ -146,7 +146,7 @@ class EditorFileUsageTest extends EntityKernelTestBase {
}
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '3'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 3 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '3']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 3 usages.');
}
// Test hook_entity_update(): decrement, by modifying the last revision:
@@ -158,7 +158,7 @@ class EditorFileUsageTest extends EntityKernelTestBase {
}
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '2']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
}
// Test hook_entity_update(): increment, by modifying the last revision:
@@ -168,13 +168,13 @@ class EditorFileUsageTest extends EntityKernelTestBase {
}
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '3'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 3 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '3']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 3 usages.');
}
// Test editor_entity_revision_delete(): decrement, by deleting a revision.
$this->container->get('entity_type.manager')->getStorage('node')->deleteRevision($second_revision_id);
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '2']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
}
// Populate both the body and summary. Because this will be the same
@@ -185,7 +185,7 @@ class EditorFileUsageTest extends EntityKernelTestBase {
}
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '2']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
}
// Empty out the body value, but keep the summary. The number of usages
@@ -196,13 +196,13 @@ class EditorFileUsageTest extends EntityKernelTestBase {
}
$node->save();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
+ $this->assertIdentical(['editor' => ['node' => [1 => '2']]], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has 2 usages.');
}
// Test editor_entity_delete().
$node->delete();
foreach ($image_entities as $key => $image_entity) {
- $this->assertIdentical(array(), $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has zero usages again.');
+ $this->assertIdentical([], $file_usage->listUsage($image_entity), 'The image ' . $image_paths[$key] . ' has zero usages again.');
}
}
diff --git a/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php b/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php
index 329018b9e5d..6500d1adefd 100644
--- a/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php
+++ b/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php
@@ -37,8 +37,8 @@ class EditorImageDialogTest extends EntityKernelTestBase {
parent::setUp();
$this->installEntitySchema('file');
$this->installSchema('system', ['key_value_expire']);
- $this->installSchema('node', array('node_access'));
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('node', ['node_access']);
+ $this->installSchema('file', ['file_usage']);
$this->installConfig(['node']);
// Add text formats.
diff --git a/core/modules/editor/tests/src/Kernel/EditorManagerTest.php b/core/modules/editor/tests/src/Kernel/EditorManagerTest.php
index b6077a587c9..d1d6eafa186 100644
--- a/core/modules/editor/tests/src/Kernel/EditorManagerTest.php
+++ b/core/modules/editor/tests/src/Kernel/EditorManagerTest.php
@@ -18,7 +18,7 @@ class EditorManagerTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'filter', 'editor');
+ public static $modules = ['system', 'user', 'filter', 'editor'];
/**
* The manager for text editor plugins.
@@ -33,19 +33,19 @@ class EditorManagerTest extends KernelTestBase {
// Install the Filter module.
// Add text formats.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$full_html_format->save();
}
@@ -59,13 +59,13 @@ class EditorManagerTest extends KernelTestBase {
// - listOptions() should return an empty list of options
// - getAttachments() should return an empty #attachments array (and not
// a JS settings structure that is empty)
- $this->assertIdentical(array(), $this->editorManager->listOptions(), 'When no text editor is enabled, the manager works correctly.');
- $this->assertIdentical(array(), $this->editorManager->getAttachments(array()), 'No attachments when no text editor is enabled and retrieving attachments for zero text formats.');
- $this->assertIdentical(array(), $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'No attachments when no text editor is enabled and retrieving attachments for multiple text formats.');
+ $this->assertIdentical([], $this->editorManager->listOptions(), 'When no text editor is enabled, the manager works correctly.');
+ $this->assertIdentical([], $this->editorManager->getAttachments([]), 'No attachments when no text editor is enabled and retrieving attachments for zero text formats.');
+ $this->assertIdentical([], $this->editorManager->getAttachments(['filtered_html', 'full_html']), 'No attachments when no text editor is enabled and retrieving attachments for multiple text formats.');
// Enable the Text Editor Test module, which has the Unicorn Editor and
// clear the editor manager's cache so it is picked up.
- $this->enableModules(array('editor_test'));
+ $this->enableModules(['editor_test']);
$this->editorManager = $this->container->get('plugin.manager.editor');
$this->editorManager->clearCachedDefinitions();
@@ -80,11 +80,11 @@ class EditorManagerTest extends KernelTestBase {
'editor' => 'unicorn',
]);
$editor->save();
- $this->assertIdentical(array(), $this->editorManager->getAttachments(array()), 'No attachments when one text editor is enabled and retrieving attachments for zero text formats.');
- $expected = array(
- 'library' => array(
+ $this->assertIdentical([], $this->editorManager->getAttachments([]), 'No attachments when one text editor is enabled and retrieving attachments for zero text formats.');
+ $expected = [
+ 'library' => [
0 => 'editor_test/unicorn',
- ),
+ ],
'drupalSettings' => [
'editor' => [
'formats' => [
@@ -98,14 +98,14 @@ class EditorManagerTest extends KernelTestBase {
],
],
],
- );
- $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'Correct attachments when one text editor is enabled and retrieving attachments for multiple text formats.');
+ ];
+ $this->assertIdentical($expected, $this->editorManager->getAttachments(['filtered_html', 'full_html']), 'Correct attachments when one text editor is enabled and retrieving attachments for multiple text formats.');
// Case 4: a text editor available associated, but now with its JS settings
// being altered via hook_editor_js_settings_alter().
\Drupal::state()->set('editor_test_js_settings_alter_enabled', TRUE);
$expected['drupalSettings']['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
- $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'hook_editor_js_settings_alter() works correctly.');
+ $this->assertIdentical($expected, $this->editorManager->getAttachments(['filtered_html', 'full_html']), 'hook_editor_js_settings_alter() works correctly.');
}
}
diff --git a/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php b/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php
index c04fe2df41c..276f5592255 100644
--- a/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php
+++ b/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php
@@ -26,7 +26,7 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('editor', 'editor_test');
+ public static $modules = ['editor', 'editor_test'];
/**
* The manager for editor plug-ins.
@@ -73,22 +73,22 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$this->fieldName, 'text', 1, 'Long text field',
// Instance settings.
- array(),
+ [],
// Widget type & settings.
'text_textarea',
- array('size' => 42),
+ ['size' => 42],
// 'default' formatter type & settings.
'text_default',
- array()
+ []
);
// Create text format.
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$full_html_format->save();
// Associate text editor with text format.
@@ -99,12 +99,12 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
$editor->save();
// Also create a text format without an associated text editor.
- FilterFormat::create(array(
+ FilterFormat::create([
'format' => 'no_editor',
'name' => 'No Text Editor',
'weight' => 2,
- 'filters' => array(),
- ))->save();
+ 'filters' => [],
+ ])->save();
}
/**
@@ -179,15 +179,15 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
// Verify metadata.
$items = $entity->get($this->fieldName);
$metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default');
- $expected = array(
+ $expected = [
'access' => TRUE,
'label' => 'Long text field',
'editor' => 'editor',
- 'custom' => array(
+ 'custom' => [
'format' => 'full_html',
'formatHasTransformations' => FALSE,
- ),
- );
+ ],
+ ];
$this->assertEqual($expected, $metadata, 'The correct metadata (including custom metadata) is generated.');
}
@@ -197,9 +197,9 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
public function testAttachments() {
$this->editorSelector = $this->container->get('quickedit.editor.selector');
- $editors = array('editor');
+ $editors = ['editor'];
$attachments = $this->editorSelector->getEditorAttachments($editors);
- $this->assertIdentical($attachments, array('library' => array('editor/quickedit.inPlaceEditor.formattedText')), "Expected attachments for Editor module's in-place editor found.");
+ $this->assertIdentical($attachments, ['library' => ['editor/quickedit.inPlaceEditor.formattedText']], "Expected attachments for Editor module's in-place editor found.");
}
/**
@@ -217,12 +217,12 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
$controller = new EditorController();
$request = new Request();
$response = $controller->getUntransformedText($entity, $this->fieldName, LanguageInterface::LANGCODE_DEFAULT, 'default');
- $expected = array(
- array(
+ $expected = [
+ [
'command' => 'editorGetUntransformedText',
'data' => 'Test',
- )
- );
+ ]
+ ];
$ajax_response_attachments_processor = \Drupal::service('ajax_response.attachments_processor');
$subscriber = new AjaxResponseSubscriber($ajax_response_attachments_processor);
diff --git a/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php b/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php
index e419f0aa1ab..4e96f4ac651 100644
--- a/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php
+++ b/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php
@@ -90,17 +90,17 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
*/
public function testCalculateDependencies() {
$format_id = 'filter.format.test';
- $values = array('editor' => $this->editorId, 'format' => $format_id);
+ $values = ['editor' => $this->editorId, 'format' => $format_id];
$plugin = $this->getMockBuilder('Drupal\editor\Plugin\EditorPluginInterface')
->disableOriginalConstructor()
->getMock();
$plugin->expects($this->once())
->method('getPluginDefinition')
- ->will($this->returnValue(array('provider' => 'test_module')));
+ ->will($this->returnValue(['provider' => 'test_module']));
$plugin->expects($this->once())
->method('getDefaultSettings')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->editorPluginManager->expects($this->any())
->method('createInstance')
diff --git a/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php b/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php
index d19758e5a06..ce6309262c2 100644
--- a/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php
+++ b/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php
@@ -27,17 +27,17 @@ class StandardTest extends UnitTestCase {
->getMock();
$this->format->expects($this->any())
->method('getFilterTypes')
- ->will($this->returnValue(array(FilterInterface::TYPE_HTML_RESTRICTOR)));
- $restrictions = array(
- 'allowed' => array(
+ ->will($this->returnValue([FilterInterface::TYPE_HTML_RESTRICTOR]));
+ $restrictions = [
+ 'allowed' => [
'p' => TRUE,
'a' => TRUE,
- '*' => array(
+ '*' => [
'style' => FALSE,
'on*' => FALSE,
- ),
- ),
- );
+ ],
+ ],
+ ];
$this->format->expects($this->any())
->method('getHtmlRestrictions')
->will($this->returnValue($restrictions));
@@ -49,130 +49,130 @@ class StandardTest extends UnitTestCase {
* @see \Drupal\Tests\editor\Unit\editor\EditorXssFilter\StandardTest::testFilterXss()
*/
public function providerTestFilterXss() {
- $data = array();
- $data[] = array('<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>');
- $data[] = array('<p style="color:red">Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>');
- $data[] = array('<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><script>alert("evil");</script>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>alert("evil");');
- $data[] = array('<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="javascript:alert(1)">test</a>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="alert(1)">test</a>');
+ $data = [];
+ $data[] = ['<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>'];
+ $data[] = ['<p style="color:red">Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>'];
+ $data[] = ['<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><script>alert("evil");</script>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>alert("evil");'];
+ $data[] = ['<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="javascript:alert(1)">test</a>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="alert(1)">test</a>'];
// All cases listed on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
// No Filter Evasion.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#No_Filter_Evasion
- $data[] = array('<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>', '');
+ $data[] = ['<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>', ''];
// Image XSS using the JavaScript directive.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Image_XSS_using_the_JavaScript_directive
- $data[] = array('<IMG SRC="javascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<IMG SRC="javascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">'];
// No quotes and no semicolon.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#No_quotes_and_no_semicolon
- $data[] = array('<IMG SRC=javascript:alert(\'XSS\')>', '<IMG>');
+ $data[] = ['<IMG SRC=javascript:alert(\'XSS\')>', '<IMG>'];
// Case insensitive XSS attack vector.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Case_insensitive_XSS_attack_vector
- $data[] = array('<IMG SRC=JaVaScRiPt:alert(\'XSS\')>', '<IMG>');
+ $data[] = ['<IMG SRC=JaVaScRiPt:alert(\'XSS\')>', '<IMG>'];
// HTML entities.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#HTML_entities
- $data[] = array('<IMG SRC=javascript:alert("XSS")>', '<IMG>');
+ $data[] = ['<IMG SRC=javascript:alert("XSS")>', '<IMG>'];
// Grave accent obfuscation.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Grave_accent_obfuscation
- $data[] = array('<IMG SRC=`javascript:alert("RSnake says, \'XSS\'")`>', '<IMG>');
+ $data[] = ['<IMG SRC=`javascript:alert("RSnake says, \'XSS\'")`>', '<IMG>'];
// Malformed A tags.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Malformed_A_tags
- $data[] = array('<a onmouseover="alert(document.cookie)">xxs link</a>', '<a>xxs link</a>');
- $data[] = array('<a onmouseover=alert(document.cookie)>xxs link</a>', '<a>xxs link</a>');
+ $data[] = ['<a onmouseover="alert(document.cookie)">xxs link</a>', '<a>xxs link</a>'];
+ $data[] = ['<a onmouseover=alert(document.cookie)>xxs link</a>', '<a>xxs link</a>'];
// Malformed IMG tags.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Malformed_IMG_tags
- $data[] = array('<IMG """><SCRIPT>alert("XSS")</SCRIPT>">', '<IMG>alert("XSS")"&gt;');
+ $data[] = ['<IMG """><SCRIPT>alert("XSS")</SCRIPT>">', '<IMG>alert("XSS")"&gt;'];
// fromCharCode.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#fromCharCode
- $data[] = array('<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>', '<IMG src="alert(String.fromCharCode(88,83,83))">');
+ $data[] = ['<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>', '<IMG src="alert(String.fromCharCode(88,83,83))">'];
// Default SRC tag to get past filters that check SRC domain.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Default_SRC_tag_to_get_past_filters_that_check_SRC_domain
- $data[] = array('<IMG SRC=# onmouseover="alert(\'xxs\')">', '<IMG src="#">');
+ $data[] = ['<IMG SRC=# onmouseover="alert(\'xxs\')">', '<IMG src="#">'];
// Default SRC tag by leaving it empty.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Default_SRC_tag_by_leaving_it_empty
- $data[] = array('<IMG SRC= onmouseover="alert(\'xxs\')">', '<IMG nmouseover="alert(&#039;xxs&#039;)">');
+ $data[] = ['<IMG SRC= onmouseover="alert(\'xxs\')">', '<IMG nmouseover="alert(&#039;xxs&#039;)">'];
// Default SRC tag by leaving it out entirely.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Default_SRC_tag_by_leaving_it_out_entirely
- $data[] = array('<IMG onmouseover="alert(\'xxs\')">', '<IMG>');
+ $data[] = ['<IMG onmouseover="alert(\'xxs\')">', '<IMG>'];
// Decimal HTML character references.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Decimal_HTML_character_references
- $data[] = array('<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>', '<IMG src="alert(&#039;XSS&#039;)">');
+ $data[] = ['<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>', '<IMG src="alert(&#039;XSS&#039;)">'];
// Decimal HTML character references without trailing semicolons.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Decimal_HTML_character_references_without_trailing_semicolons
- $data[] = array('<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>', '<IMG src="&amp;#0000106&amp;#0000097&amp;#0000118&amp;#0000097&amp;#0000115&amp;#0000099&amp;#0000114&amp;#0000105&amp;#0000112&amp;#0000116&amp;#0000058&amp;#0000097&amp;#0000108&amp;#0000101&amp;#0000114&amp;#0000116&amp;#0000040&amp;#0000039&amp;#0000088&amp;#0000083&amp;#0000083&amp;#0000039&amp;#0000041">');
+ $data[] = ['<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>', '<IMG src="&amp;#0000106&amp;#0000097&amp;#0000118&amp;#0000097&amp;#0000115&amp;#0000099&amp;#0000114&amp;#0000105&amp;#0000112&amp;#0000116&amp;#0000058&amp;#0000097&amp;#0000108&amp;#0000101&amp;#0000114&amp;#0000116&amp;#0000040&amp;#0000039&amp;#0000088&amp;#0000083&amp;#0000083&amp;#0000039&amp;#0000041">'];
// Hexadecimal HTML character references without trailing semicolons.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Hexadecimal_HTML_character_references_without_trailing_semicolons
- $data[] = array('<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>', '<IMG src="&amp;#x6A&amp;#x61&amp;#x76&amp;#x61&amp;#x73&amp;#x63&amp;#x72&amp;#x69&amp;#x70&amp;#x74&amp;#x3A&amp;#x61&amp;#x6C&amp;#x65&amp;#x72&amp;#x74&amp;#x28&amp;#x27&amp;#x58&amp;#x53&amp;#x53&amp;#x27&amp;#x29">');
+ $data[] = ['<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>', '<IMG src="&amp;#x6A&amp;#x61&amp;#x76&amp;#x61&amp;#x73&amp;#x63&amp;#x72&amp;#x69&amp;#x70&amp;#x74&amp;#x3A&amp;#x61&amp;#x6C&amp;#x65&amp;#x72&amp;#x74&amp;#x28&amp;#x27&amp;#x58&amp;#x53&amp;#x53&amp;#x27&amp;#x29">'];
// Embedded tab.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_tab
- $data[] = array('<IMG SRC="jav ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<IMG SRC="jav ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">'];
// Embedded Encoded tab.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_Encoded_tab
- $data[] = array('<IMG SRC="jav&#x09;ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<IMG SRC="jav&#x09;ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">'];
// Embedded newline to break up XSS.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_newline_to_break_up_XSS
- $data[] = array('<IMG SRC="jav&#x0A;ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<IMG SRC="jav&#x0A;ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">'];
// Embedded carriage return to break up XSS.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_carriage_return_to_break_up_XSS
- $data[] = array('<IMG SRC="jav&#x0D;ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<IMG SRC="jav&#x0D;ascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">'];
// Null breaks up JavaScript directive.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Null_breaks_up_JavaScript_directive
- $data[] = array("<IMG SRC=java\0script:alert(\"XSS\")>", '<IMG>');
+ $data[] = ["<IMG SRC=java\0script:alert(\"XSS\")>", '<IMG>'];
// Spaces and meta chars before the JavaScript in images for XSS.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Spaces_and_meta_chars_before_the_JavaScript_in_images_for_XSS
// @fixme This dataset currently fails under 5.4 because of
// https://www.drupal.org/node/1210798. Restore after it's fixed.
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
- $data[] = array('<IMG SRC=" &#14; javascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<IMG SRC=" &#14; javascript:alert(\'XSS\');">', '<IMG src="alert(&#039;XSS&#039;);">'];
}
// Non-alpha-non-digit XSS.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Non-alpha-non-digit_XSS
- $data[] = array('<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '');
- $data[] = array('<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>', '<BODY>');
- $data[] = array('<SCRIPT/SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '');
+ $data[] = ['<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>', ''];
+ $data[] = ['<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>', '<BODY>'];
+ $data[] = ['<SCRIPT/SRC="http://ha.ckers.org/xss.js"></SCRIPT>', ''];
// Extraneous open brackets.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Extraneous_open_brackets
- $data[] = array('<<SCRIPT>alert("XSS");//<</SCRIPT>', '&lt;alert("XSS");//&lt;');
+ $data[] = ['<<SCRIPT>alert("XSS");//<</SCRIPT>', '&lt;alert("XSS");//&lt;'];
// No closing script tags.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#No_closing_script_tags
- $data[] = array('<SCRIPT SRC=http://ha.ckers.org/xss.js?< B >', '');
+ $data[] = ['<SCRIPT SRC=http://ha.ckers.org/xss.js?< B >', ''];
// Protocol resolution in script tags.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Protocol_resolution_in_script_tags
- $data[] = array('<SCRIPT SRC=//ha.ckers.org/.j>', '');
+ $data[] = ['<SCRIPT SRC=//ha.ckers.org/.j>', ''];
// Half open HTML/JavaScript XSS vector.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Half_open_HTML.2FJavaScript_XSS_vector
- $data[] = array('<IMG SRC="javascript:alert(\'XSS\')"', '<IMG src="alert(&#039;XSS&#039;)">');
+ $data[] = ['<IMG SRC="javascript:alert(\'XSS\')"', '<IMG src="alert(&#039;XSS&#039;)">'];
// Double open angle brackets.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Double_open_angle_brackets
// @see http://ha.ckers.org/blog/20060611/hotbot-xss-vulnerability/ to
// understand why this is a vulnerability.
- $data[] = array('<iframe src=http://ha.ckers.org/scriptlet.html <', '<iframe src="http://ha.ckers.org/scriptlet.html">');
+ $data[] = ['<iframe src=http://ha.ckers.org/scriptlet.html <', '<iframe src="http://ha.ckers.org/scriptlet.html">'];
// Escaping JavaScript escapes.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Escaping_JavaScript_escapes
@@ -181,43 +181,43 @@ class StandardTest extends UnitTestCase {
// End title tag.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#End_title_tag
- $data[] = array('</TITLE><SCRIPT>alert("XSS");</SCRIPT>', '</TITLE>alert("XSS");');
+ $data[] = ['</TITLE><SCRIPT>alert("XSS");</SCRIPT>', '</TITLE>alert("XSS");'];
// INPUT image.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#INPUT_image
- $data[] = array('<INPUT TYPE="IMAGE" SRC="javascript:alert(\'XSS\');">', '<INPUT type="IMAGE" src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<INPUT TYPE="IMAGE" SRC="javascript:alert(\'XSS\');">', '<INPUT type="IMAGE" src="alert(&#039;XSS&#039;);">'];
// BODY image.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BODY_image
- $data[] = array('<BODY BACKGROUND="javascript:alert(\'XSS\')">', '<BODY background="alert(&#039;XSS&#039;)">');
+ $data[] = ['<BODY BACKGROUND="javascript:alert(\'XSS\')">', '<BODY background="alert(&#039;XSS&#039;)">'];
// IMG Dynsrc.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IMG_Dynsrc
- $data[] = array('<IMG DYNSRC="javascript:alert(\'XSS\')">', '<IMG dynsrc="alert(&#039;XSS&#039;)">');
+ $data[] = ['<IMG DYNSRC="javascript:alert(\'XSS\')">', '<IMG dynsrc="alert(&#039;XSS&#039;)">'];
// IMG lowsrc.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IMG_lowsrc
- $data[] = array('<IMG LOWSRC="javascript:alert(\'XSS\')">', '<IMG lowsrc="alert(&#039;XSS&#039;)">');
+ $data[] = ['<IMG LOWSRC="javascript:alert(\'XSS\')">', '<IMG lowsrc="alert(&#039;XSS&#039;)">'];
// List-style-image.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#List-style-image
- $data[] = array('<STYLE>li {list-style-image: url("javascript:alert(\'XSS\')");}</STYLE><UL><LI>XSS</br>', 'li {list-style-image: url("javascript:alert(\'XSS\')");}<UL><LI>XSS</br>');
+ $data[] = ['<STYLE>li {list-style-image: url("javascript:alert(\'XSS\')");}</STYLE><UL><LI>XSS</br>', 'li {list-style-image: url("javascript:alert(\'XSS\')");}<UL><LI>XSS</br>'];
// VBscript in an image.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#VBscript_in_an_image
- $data[] = array('<IMG SRC=\'vbscript:msgbox("XSS")\'>', '<IMG src=\'msgbox(&quot;XSS&quot;)\'>');
+ $data[] = ['<IMG SRC=\'vbscript:msgbox("XSS")\'>', '<IMG src=\'msgbox(&quot;XSS&quot;)\'>'];
// Livescript (older versions of Netscape only).
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Livescript_.28older_versions_of_Netscape_only.29
- $data[] = array('<IMG SRC="livescript:[code]">', '<IMG src="[code]">');
+ $data[] = ['<IMG SRC="livescript:[code]">', '<IMG src="[code]">'];
// BODY tag.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BODY_tag
- $data[] = array('<BODY ONLOAD=alert(\'XSS\')>', '<BODY>');
+ $data[] = ['<BODY ONLOAD=alert(\'XSS\')>', '<BODY>'];
// Event handlers.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Event_Handlers
- $events = array(
+ $events = [
'onAbort',
'onActivate',
'onAfterPrint',
@@ -321,71 +321,71 @@ class StandardTest extends UnitTestCase {
'onUndo',
'onUnload',
'onURLFlip',
- );
+ ];
foreach ($events as $event) {
- $data[] = array('<p ' . $event . '="javascript:alert(\'XSS\');">Dangerous llama!</p>', '<p>Dangerous llama!</p>');
+ $data[] = ['<p ' . $event . '="javascript:alert(\'XSS\');">Dangerous llama!</p>', '<p>Dangerous llama!</p>'];
}
// BGSOUND.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BGSOUND
- $data[] = array('<BGSOUND SRC="javascript:alert(\'XSS\');">', '<BGSOUND src="alert(&#039;XSS&#039;);">');
+ $data[] = ['<BGSOUND SRC="javascript:alert(\'XSS\');">', '<BGSOUND src="alert(&#039;XSS&#039;);">'];
// & JavaScript includes.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#.26_JavaScript_includes
- $data[] = array('<BR SIZE="&{alert(\'XSS\')}">', '<BR size="">');
+ $data[] = ['<BR SIZE="&{alert(\'XSS\')}">', '<BR size="">'];
// STYLE sheet.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_sheet
- $data[] = array('<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">', '');
+ $data[] = ['<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">', ''];
// Remote style sheet.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet
- $data[] = array('<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">', '');
+ $data[] = ['<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">', ''];
// Remote style sheet part 2.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet_part_2
- $data[] = array('<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>', '@import\'http://ha.ckers.org/xss.css\';');
+ $data[] = ['<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>', '@import\'http://ha.ckers.org/xss.css\';'];
// Remote style sheet part 3.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet_part_3
- $data[] = array('<META HTTP-EQUIV="Link" Content="<http://ha.ckers.org/xss.css>; REL=stylesheet">', '<META http-equiv="Link">; REL=stylesheet"&gt;');
+ $data[] = ['<META HTTP-EQUIV="Link" Content="<http://ha.ckers.org/xss.css>; REL=stylesheet">', '<META http-equiv="Link">; REL=stylesheet"&gt;'];
// Remote style sheet part 4.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet_part_4
- $data[] = array('<STYLE>BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}</STYLE>', 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}');
+ $data[] = ['<STYLE>BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}</STYLE>', 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}'];
// STYLE tags with broken up JavaScript for XSS.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tags_with_broken_up_JavaScript_for_XSS
- $data[] = array('<STYLE>@im\port\'\ja\vasc\ript:alert("XSS")\';</STYLE>', '@im\port\'\ja\vasc\ript:alert("XSS")\';');
+ $data[] = ['<STYLE>@im\port\'\ja\vasc\ript:alert("XSS")\';</STYLE>', '@im\port\'\ja\vasc\ript:alert("XSS")\';'];
// STYLE attribute using a comment to break up expression.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_attribute_using_a_comment_to_break_up_expression
- $data[] = array('<IMG STYLE="xss:expr/*XSS*/ession(alert(\'XSS\'))">', '<IMG>');
+ $data[] = ['<IMG STYLE="xss:expr/*XSS*/ession(alert(\'XSS\'))">', '<IMG>'];
// IMG STYLE with expression.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IMG_STYLE_with_expression
- $data[] = array('exp/*<A STYLE=\'no\xss:noxss("*//*");
-xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>');
+ $data[] = ['exp/*<A STYLE=\'no\xss:noxss("*//*");
+xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>'];
// STYLE tag (Older versions of Netscape only).
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tag_.28Older_versions_of_Netscape_only.29
- $data[] = array('<STYLE TYPE="text/javascript">alert(\'XSS\');</STYLE>', 'alert(\'XSS\');');
+ $data[] = ['<STYLE TYPE="text/javascript">alert(\'XSS\');</STYLE>', 'alert(\'XSS\');'];
// STYLE tag using background-image.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tag_using_background-image
- $data[] = array('<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>', '.XSS{background-image:url("javascript:alert(\'XSS\')");}<A class="XSS"></A>');
+ $data[] = ['<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>', '.XSS{background-image:url("javascript:alert(\'XSS\')");}<A class="XSS"></A>'];
// STYLE tag using background.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tag_using_background
- $data[] = array('<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>', 'BODY{background:url("javascript:alert(\'XSS\')")}');
+ $data[] = ['<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>', 'BODY{background:url("javascript:alert(\'XSS\')")}'];
// Anonymous HTML with STYLE attribute.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Anonymous_HTML_with_STYLE_attribute
- $data[] = array('<XSS STYLE="xss:expression(alert(\'XSS\'))">', '<XSS>');
+ $data[] = ['<XSS STYLE="xss:expression(alert(\'XSS\'))">', '<XSS>'];
// Local htc file.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Local_htc_file
- $data[] = array('<XSS STYLE="behavior: url(xss.htc);">', '<XSS>');
+ $data[] = ['<XSS STYLE="behavior: url(xss.htc);">', '<XSS>'];
// US-ASCII encoding.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#US-ASCII_encoding
@@ -393,77 +393,77 @@ xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>');
// META.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#META
- $data[] = array('<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">', '<META http-equiv="refresh" content="alert(&#039;XSS&#039;);">');
+ $data[] = ['<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">', '<META http-equiv="refresh" content="alert(&#039;XSS&#039;);">'];
// META using data.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#META_using_data
- $data[] = array('<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">', '<META http-equiv="refresh" content="text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">');
+ $data[] = ['<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">', '<META http-equiv="refresh" content="text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">'];
// META with additional URL parameter
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#META
- $data[] = array('<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">', '<META http-equiv="refresh" content="//;URL=javascript:alert(&#039;XSS&#039;);">');
+ $data[] = ['<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">', '<META http-equiv="refresh" content="//;URL=javascript:alert(&#039;XSS&#039;);">'];
// IFRAME.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IFRAME
- $data[] = array('<IFRAME SRC="javascript:alert(\'XSS\');"></IFRAME>', '<IFRAME src="alert(&#039;XSS&#039;);"></IFRAME>');
+ $data[] = ['<IFRAME SRC="javascript:alert(\'XSS\');"></IFRAME>', '<IFRAME src="alert(&#039;XSS&#039;);"></IFRAME>'];
// IFRAME Event based.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IFRAME_Event_based
- $data[] = array('<IFRAME SRC=# onmouseover="alert(document.cookie)"></IFRAME>', '<IFRAME src="#"></IFRAME>');
+ $data[] = ['<IFRAME SRC=# onmouseover="alert(document.cookie)"></IFRAME>', '<IFRAME src="#"></IFRAME>'];
// FRAME.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#FRAME
- $data[] = array('<FRAMESET><FRAME SRC="javascript:alert(\'XSS\');"></FRAMESET>', '<FRAMESET><FRAME src="alert(&#039;XSS&#039;);"></FRAMESET>');
+ $data[] = ['<FRAMESET><FRAME SRC="javascript:alert(\'XSS\');"></FRAMESET>', '<FRAMESET><FRAME src="alert(&#039;XSS&#039;);"></FRAMESET>'];
// TABLE.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#TABLE
- $data[] = array('<TABLE BACKGROUND="javascript:alert(\'XSS\')">', '<TABLE background="alert(&#039;XSS&#039;)">');
+ $data[] = ['<TABLE BACKGROUND="javascript:alert(\'XSS\')">', '<TABLE background="alert(&#039;XSS&#039;)">'];
// TD.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#TD
- $data[] = array('<TABLE><TD BACKGROUND="javascript:alert(\'XSS\')">', '<TABLE><TD background="alert(&#039;XSS&#039;)">');
+ $data[] = ['<TABLE><TD BACKGROUND="javascript:alert(\'XSS\')">', '<TABLE><TD background="alert(&#039;XSS&#039;)">'];
// DIV background-image.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image
- $data[] = array('<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">', '<DIV>');
+ $data[] = ['<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">', '<DIV>'];
// DIV background-image with unicoded XSS exploit.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image_with_unicoded_XSS_exploit
- $data[] = array('<DIV STYLE="background-image:\0075\0072\006C\0028\'\006a\0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061\006c\0065\0072\0074\0028.1027\0058.1053\0053\0027\0029\'\0029">', '<DIV>');
+ $data[] = ['<DIV STYLE="background-image:\0075\0072\006C\0028\'\006a\0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061\006c\0065\0072\0074\0028.1027\0058.1053\0053\0027\0029\'\0029">', '<DIV>'];
// DIV background-image plus extra characters.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image_plus_extra_characters
- $data[] = array('<DIV STYLE="background-image: url(&#1;javascript:alert(\'XSS\'))">', '<DIV>');
+ $data[] = ['<DIV STYLE="background-image: url(&#1;javascript:alert(\'XSS\'))">', '<DIV>'];
// DIV expression.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_expression
- $data[] = array('<DIV STYLE="width: expression(alert(\'XSS\'));">', '<DIV>');
+ $data[] = ['<DIV STYLE="width: expression(alert(\'XSS\'));">', '<DIV>'];
// Downlevel-Hidden block.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Downlevel-Hidden_block
- $data[] = array('<!--[if gte IE 4]>
+ $data[] = ['<!--[if gte IE 4]>
<SCRIPT>alert(\'XSS\');</SCRIPT>
- <![endif]-->', "\n alert('XSS');\n ");
+ <![endif]-->', "\n alert('XSS');\n "];
// BASE tag.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BASE_tag
- $data[] = array('<BASE HREF="javascript:alert(\'XSS\');//">', '<BASE href="alert(&#039;XSS&#039;);//">');
+ $data[] = ['<BASE HREF="javascript:alert(\'XSS\');//">', '<BASE href="alert(&#039;XSS&#039;);//">'];
// OBJECT tag.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#OBJECT_tag
- $data[] = array('<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>', '');
+ $data[] = ['<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>', ''];
// Using an EMBED tag you can embed a Flash movie that contains XSS.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Using_an_EMBED_tag_you_can_embed_a_Flash_movie_that_contains_XSS
- $data[] = array('<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>', '');
+ $data[] = ['<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>', ''];
// You can EMBED SVG which can contain your XSS vector.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#You_can_EMBED_SVG_which_can_contain_your_XSS_vector
- $data[] = array('<EMBED SRC="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==" type="image/svg+xml" AllowScriptAccess="always"></EMBED>', '');
+ $data[] = ['<EMBED SRC="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==" type="image/svg+xml" AllowScriptAccess="always"></EMBED>', ''];
// XML data island with CDATA obfuscation.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#XML_data_island_with_CDATA_obfuscation
- $data[] = array('<XML ID="xss"><I><B><IMG SRC="javas<!-- -->cript:alert(\'XSS\')"></B></I></XML><SPAN DATASRC="#xss" DATAFLD="B" DATAFORMATAS="HTML"></SPAN>', '<XML id="xss"><I><B><IMG>cript:alert(\'XSS\')"&gt;</B></I></XML><SPAN datasrc="#xss" datafld="B" dataformatas="HTML"></SPAN>');
+ $data[] = ['<XML ID="xss"><I><B><IMG SRC="javas<!-- -->cript:alert(\'XSS\')"></B></I></XML><SPAN DATASRC="#xss" DATAFLD="B" DATAFORMATAS="HTML"></SPAN>', '<XML id="xss"><I><B><IMG>cript:alert(\'XSS\')"&gt;</B></I></XML><SPAN datasrc="#xss" datafld="B" dataformatas="HTML"></SPAN>'];
// Locally hosted XML with embedded JavaScript that is generated using an XML data island.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Locally_hosted_XML_with_embedded_JavaScript_that_is_generated_using_an_XML_data_island
@@ -472,11 +472,11 @@ xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>');
// HTML+TIME in XML.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#HTML.2BTIME_in_XML
- $data[] = array('<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2"><t:set attributeName="innerHTML" to="XSS<SCRIPT DEFER>alert("XSS")</SCRIPT>">', '&lt;?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"&gt;&lt;?import namespace="t" implementation="#default#time2"&gt;<t set attributename="innerHTML">alert("XSS")"&gt;');
+ $data[] = ['<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2"><t:set attributeName="innerHTML" to="XSS<SCRIPT DEFER>alert("XSS")</SCRIPT>">', '&lt;?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"&gt;&lt;?import namespace="t" implementation="#default#time2"&gt;<t set attributename="innerHTML">alert("XSS")"&gt;'];
// Assuming you can only fit in a few characters and it filters against ".js".
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Assuming_you_can_only_fit_in_a_few_characters_and_it_filters_against_.22.js.22
- $data[] = array('<SCRIPT SRC="http://ha.ckers.org/xss.jpg"></SCRIPT>', '');
+ $data[] = ['<SCRIPT SRC="http://ha.ckers.org/xss.jpg"></SCRIPT>', ''];
// IMG Embedded commands.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IMG_Embedded_commands
@@ -485,7 +485,7 @@ xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>');
// Cookie manipulation.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Cookie_manipulation
- $data[] = array('<META HTTP-EQUIV="Set-Cookie" Content="USERID=<SCRIPT>alert(\'XSS\')</SCRIPT>">', '<META http-equiv="Set-Cookie">alert(\'XSS\')"&gt;');
+ $data[] = ['<META HTTP-EQUIV="Set-Cookie" Content="USERID=<SCRIPT>alert(\'XSS\')</SCRIPT>">', '<META http-equiv="Set-Cookie">alert(\'XSS\')"&gt;'];
// UTF-7 encoding.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#UTF-7_encoding
@@ -493,13 +493,13 @@ xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>');
// XSS using HTML quote encapsulation.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#XSS_using_HTML_quote_encapsulation
- $data[] = array('<SCRIPT a=">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" SRC="http://ha.ckers.org/xss.js"&gt;');
- $data[] = array('<SCRIPT =">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" SRC="http://ha.ckers.org/xss.js"&gt;');
- $data[] = array('<SCRIPT a=">" \'\' SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" \'\' SRC="http://ha.ckers.org/xss.js"&gt;');
- $data[] = array('<SCRIPT "a=\'>\'" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '\'" SRC="http://ha.ckers.org/xss.js"&gt;');
- $data[] = array('<SCRIPT a=`>` SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '` SRC="http://ha.ckers.org/xss.js"&gt;');
- $data[] = array('<SCRIPT a=">\'>" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '\'&gt;" SRC="http://ha.ckers.org/xss.js"&gt;');
- $data[] = array('<SCRIPT>document.write("<SCRI");</SCRIPT>PT SRC="http://ha.ckers.org/xss.js"></SCRIPT>', 'document.write("<SCRI>PT SRC="http://ha.ckers.org/xss.js"&gt;');
+ $data[] = ['<SCRIPT a=">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" SRC="http://ha.ckers.org/xss.js"&gt;'];
+ $data[] = ['<SCRIPT =">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" SRC="http://ha.ckers.org/xss.js"&gt;'];
+ $data[] = ['<SCRIPT a=">" \'\' SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" \'\' SRC="http://ha.ckers.org/xss.js"&gt;'];
+ $data[] = ['<SCRIPT "a=\'>\'" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '\'" SRC="http://ha.ckers.org/xss.js"&gt;'];
+ $data[] = ['<SCRIPT a=`>` SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '` SRC="http://ha.ckers.org/xss.js"&gt;'];
+ $data[] = ['<SCRIPT a=">\'>" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '\'&gt;" SRC="http://ha.ckers.org/xss.js"&gt;'];
+ $data[] = ['<SCRIPT>document.write("<SCRI");</SCRIPT>PT SRC="http://ha.ckers.org/xss.js"></SCRIPT>', 'document.write("<SCRI>PT SRC="http://ha.ckers.org/xss.js"&gt;'];
// URL string evasion.
// @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#URL_string_evasion
@@ -511,12 +511,12 @@ xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>');
// @see \Drupal\editor\EditorXssFilter::filterXssDataAttributes()
// The following two test cases verify that XSS attack vectors are filtered.
- $data[] = array('<img src="butterfly.jpg" data-caption="&lt;script&gt;alert();&lt;/script&gt;" />', '<img src="butterfly.jpg" data-caption="alert();" />');
- $data[] = array('<img src="butterfly.jpg" data-caption="&lt;EMBED SRC=&quot;http://ha.ckers.org/xss.swf&quot; AllowScriptAccess=&quot;always&quot;&gt;&lt;/EMBED&gt;" />', '<img src="butterfly.jpg" data-caption="" />');
+ $data[] = ['<img src="butterfly.jpg" data-caption="&lt;script&gt;alert();&lt;/script&gt;" />', '<img src="butterfly.jpg" data-caption="alert();" />'];
+ $data[] = ['<img src="butterfly.jpg" data-caption="&lt;EMBED SRC=&quot;http://ha.ckers.org/xss.swf&quot; AllowScriptAccess=&quot;always&quot;&gt;&lt;/EMBED&gt;" />', '<img src="butterfly.jpg" data-caption="" />'];
// When including HTML-tags as visible content, they are double-escaped.
// This test case ensures that we leave that content unchanged.
- $data[] = array('<img src="butterfly.jpg" data-caption="&amp;lt;script&amp;gt;alert();&amp;lt;/script&amp;gt;" />', '<img src="butterfly.jpg" data-caption="&amp;lt;script&amp;gt;alert();&amp;lt;/script&amp;gt;" />');
+ $data[] = ['<img src="butterfly.jpg" data-caption="&amp;lt;script&amp;gt;alert();&amp;lt;/script&amp;gt;" />', '<img src="butterfly.jpg" data-caption="&amp;lt;script&amp;gt;alert();&amp;lt;/script&amp;gt;" />'];
return $data;
}
@@ -573,27 +573,27 @@ xss:ex/*XSS*//*/*/pression(alert("XSS"))\'>', 'exp/*<A>');
* - (optional) The disallowed HTML tags to be passed to \Drupal\Component\Utility\Xss::filter().
*/
public function providerTestBlackListMode() {
- return array(
- array(
+ return [
+ [
'<unknown style="visibility:hidden">Pink Fairy Armadillo</unknown><video src="gerenuk.mp4"><script>alert(0)</script>',
'<unknown>Pink Fairy Armadillo</unknown><video src="gerenuk.mp4">alert(0)',
'Disallow only the script tag',
- array('script')
- ),
- array(
+ ['script']
+ ],
+ [
'<unknown style="visibility:hidden">Pink Fairy Armadillo</unknown><video src="gerenuk.mp4"><script>alert(0)</script>',
'<unknown>Pink Fairy Armadillo</unknown>alert(0)',
'Disallow both the script and video tags',
- array('script', 'video')
- ),
+ ['script', 'video']
+ ],
// No real use case for this, but it is an edge case we must ensure works.
- array(
+ [
'<unknown style="visibility:hidden">Pink Fairy Armadillo</unknown><video src="gerenuk.mp4"><script>alert(0)</script>',
'<unknown>Pink Fairy Armadillo</unknown><video src="gerenuk.mp4"><script>alert(0)</script>',
'Disallow no tags',
- array()
- ),
- );
+ []
+ ],
+ ];
}
}
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index 8e11650f5cb..b0899ea02b0 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -85,7 +85,7 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
$prior_allowed_values = $prior_field_storage->getSetting('allowed_values');
$lost_keys = array_keys(array_diff_key($prior_allowed_values, $allowed_values));
if (_options_values_in_use($field_storage->getTargetEntityTypeId(), $field_storage->getName(), $lost_keys)) {
- throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
+ throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', ['@field_name' => $field_storage->getName()]));
}
}
}
@@ -257,7 +257,7 @@ function hook_field_formatter_info_alter(array &$info) {
* @ingroup field_info
*/
function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode) {
- $weights = array();
+ $weights = [];
foreach (my_module_entity_additions($entity_type, $bundle, $context, $context_mode) as $addition) {
$weights[] = $addition['weight'];
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index 81330071762..8f3877d0f38 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -67,10 +67,10 @@ require_once __DIR__ . '/field.purge.inc';
function field_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.field':
- $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
+ $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Field module allows custom data fields to be defined for <em>entity</em> types (see below). The Field module takes care of storing, loading, editing, and rendering field data. Most users will not interact with the Field module directly, but will instead use the <a href=":field-ui-help">Field UI module</a> user interface. Module developers can use the Field API to make new entity types "fieldable" and thus allow fields to be attached to them. For more information, see the <a href=":field">online documentation for the Field module</a>.', array(':field-ui-help' => $field_ui_url, ':field' => 'https://www.drupal.org/documentation/modules/field')) . '</p>';
+ $output .= '<p>' . t('The Field module allows custom data fields to be defined for <em>entity</em> types (see below). The Field module takes care of storing, loading, editing, and rendering field data. Most users will not interact with the Field module directly, but will instead use the <a href=":field-ui-help">Field UI module</a> user interface. Module developers can use the Field API to make new entity types "fieldable" and thus allow fields to be attached to them. For more information, see the <a href=":field">online documentation for the Field module</a>.', [':field-ui-help' => $field_ui_url, ':field' => 'https://www.drupal.org/documentation/modules/field']) . '</p>';
$output .= '<h3>' . t('Terminology') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Entities and entity types') . '</dt>';
@@ -87,19 +87,19 @@ function field_help($route_name, RouteMatchInterface $route_match) {
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Enabling field types, widgets, and formatters') . '</dt>';
- $output .= '<dd>' . t('The Field module provides the infrastructure for fields; the field types, formatters, and widgets are provided by Drupal core or additional modules. Some of the modules are required; the optional modules can be enabled from the <a href=":modules">Extend administration page</a>. Additional fields, formatters, and widgets may be provided by contributed modules, which you can find in the <a href=":contrib">contributed module section of Drupal.org</a>.', array(':modules' => \Drupal::url('system.modules_list'), ':contrib' => 'https://www.drupal.org/project/modules')) . '</dd>';
+ $output .= '<dd>' . t('The Field module provides the infrastructure for fields; the field types, formatters, and widgets are provided by Drupal core or additional modules. Some of the modules are required; the optional modules can be enabled from the <a href=":modules">Extend administration page</a>. Additional fields, formatters, and widgets may be provided by contributed modules, which you can find in the <a href=":contrib">contributed module section of Drupal.org</a>.', [':modules' => \Drupal::url('system.modules_list'), ':contrib' => 'https://www.drupal.org/project/modules']) . '</dd>';
$output .= '<h3>' . t('Field, widget, and formatter information') . '</h3>';
// Make a list of all widget, formatter, and field modules currently
// enabled, ordered by displayed module name (module names are not
// translated).
- $items = array();
+ $items = [];
$modules = \Drupal::moduleHandler()->getModuleList();
$widgets = \Drupal::service('plugin.manager.field.widget')->getDefinitions();
$field_types = \Drupal::service('plugin.manager.field.field_type')->getUiDefinitions();
$formatters = \Drupal::service('plugin.manager.field.formatter')->getDefinitions();
- $providers = array();
+ $providers = [];
foreach (array_merge($field_types, $widgets, $formatters) as $plugin) {
$providers[] = $plugin['provider'];
}
@@ -111,7 +111,7 @@ function field_help($route_name, RouteMatchInterface $route_match) {
if (isset($modules[$provider])) {
$display = \Drupal::moduleHandler()->getName($provider);
if (\Drupal::moduleHandler()->implementsHook($provider, 'help')) {
- $items[] = \Drupal::l($display, new Url('help.page', array('name' => $provider)));
+ $items[] = \Drupal::l($display, new Url('help.page', ['name' => $provider]));
}
else {
$items[] = $display;
@@ -121,10 +121,10 @@ function field_help($route_name, RouteMatchInterface $route_match) {
if ($items) {
$output .= '<dt>' . t('Provided by modules') . '</dt>';
$output .= '<dd>' . t('Here is a list of the currently enabled field, formatter, and widget modules:');
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
$output .= \Drupal::service('renderer')->renderPlain($item_list);
$output .= '</dd>';
}
@@ -132,10 +132,10 @@ function field_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dt>' . t('Provided by Drupal core') . '</dt>';
$output .= '<dd>' . t('As mentioned previously, some field types, widgets, and formatters are provided by Drupal core. Here are some notes on how to use some of these:');
$output .= '<ul>';
- $output .= '<li><p>' . t('<strong>Entity Reference</strong> fields allow you to create fields that contain links to other entities (such as content items, taxonomy terms, etc.) within the site. This allows you, for example, to include a link to a user within a content item. For more information, see <a href=":er_do">the online documentation for the Entity Reference module</a>.', array(':er_do' => 'https://drupal.org/documentation/modules/entityreference')) . '</p>';
+ $output .= '<li><p>' . t('<strong>Entity Reference</strong> fields allow you to create fields that contain links to other entities (such as content items, taxonomy terms, etc.) within the site. This allows you, for example, to include a link to a user within a content item. For more information, see <a href=":er_do">the online documentation for the Entity Reference module</a>.', [':er_do' => 'https://drupal.org/documentation/modules/entityreference']) . '</p>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying entity reference fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the entity reference field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => $field_ui_url)) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the entity reference field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => $field_ui_url]) . '</dd>';
$output .= '<dt>' . t('Selecting reference type') . '</dt>';
$output .= '<dd>' . t('In the field settings you can select which entity type you want to create a reference to.') . '</dd>';
$output .= '<dt>' . t('Filtering and sorting reference fields') . '</dt>';
@@ -179,7 +179,7 @@ function field_entity_field_storage_info(EntityTypeInterface $entity_type) {
->execute();
// Fetch all fields and key them by field name.
$field_storages = FieldStorageConfig::loadMultiple($ids);
- $result = array();
+ $result = [];
foreach ($field_storages as $field_storage) {
$result[$field_storage->getName()] = $field_storage;
}
@@ -200,7 +200,7 @@ function field_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundl
->execute();
// Fetch all fields and key them by field name.
$field_configs = FieldConfig::loadMultiple($ids);
- $result = array();
+ $result = [];
foreach ($field_configs as $field_instance) {
$result[$field_instance->getName()] = $field_instance;
}
@@ -283,7 +283,7 @@ function field_entity_bundle_delete($entity_type_id, $bundle) {
* An entity, initialized with the provided IDs.
*/
function _field_create_entity_from_ids($ids) {
- $id_properties = array();
+ $id_properties = [];
$entity_type = \Drupal::entityManager()->getDefinition($ids->entity_type);
if ($id_key = $entity_type->getKey('id')) {
$id_properties[$id_key] = $ids->entity_id;
@@ -311,7 +311,7 @@ function field_config_import_steps_alter(&$sync_steps, ConfigImporter $config_im
// Add a step to the beginning of the configuration synchronization process
// to purge field data where the module that provides the field is being
// uninstalled.
- array_unshift($sync_steps, array('\Drupal\field\ConfigImporterFieldPurger', 'process'));
+ array_unshift($sync_steps, ['\Drupal\field\ConfigImporterFieldPurger', 'process']);
};
}
@@ -341,7 +341,7 @@ function field_form_config_admin_import_form_alter(&$form, FormStateInterface $f
count($field_storages),
'This synchronization will delete data from the field %fields.',
'This synchronization will delete data from the fields: %fields.',
- array('%fields' => implode(', ', $field_labels))
+ ['%fields' => implode(', ', $field_labels)]
), 'warning');
}
}
diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc
index ae3e26694fb..519c6af2740 100644
--- a/core/modules/field/field.purge.inc
+++ b/core/modules/field/field.purge.inc
@@ -73,10 +73,10 @@ use Drupal\field\FieldConfigInterface;
* (optional) Limit the purge to a specific field storage.
*/
function field_purge_batch($batch_size, $field_storage_uuid = NULL) {
- $properties = array(
+ $properties = [
'deleted' => TRUE,
'include_deleted' => TRUE,
- );
+ ];
if ($field_storage_uuid) {
$properties['field_storage_uuid'] = $field_storage_uuid;
}
@@ -106,7 +106,7 @@ function field_purge_batch($batch_size, $field_storage_uuid = NULL) {
}
// Retrieve all deleted field storages. Any that have no fields can be purged.
- $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
+ $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
foreach ($deleted_storages as $field_storage) {
$field_storage = new FieldStorageConfig($field_storage);
if ($field_storage_uuid && $field_storage->uuid() != $field_storage_uuid) {
@@ -121,7 +121,7 @@ function field_purge_batch($batch_size, $field_storage_uuid = NULL) {
continue;
}
- $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]);
if (empty($fields)) {
field_purge_field_storage($field_storage);
}
@@ -144,7 +144,7 @@ function field_purge_field(FieldConfigInterface $field) {
$state->set('field.field.deleted', $deleted_fields);
// Invoke external hooks after the cache is cleared for API consistency.
- \Drupal::moduleHandler()->invokeAll('field_purge_field', array($field));
+ \Drupal::moduleHandler()->invokeAll('field_purge_field', [$field]);
}
/**
@@ -159,9 +159,9 @@ function field_purge_field(FieldConfigInterface $field) {
* @throws Drupal\field\FieldException
*/
function field_purge_field_storage(FieldStorageConfigInterface $field_storage) {
- $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]);
if (count($fields) > 0) {
- throw new FieldException(t('Attempt to purge a field storage @field_name that still has fields.', array('@field_name' => $field_storage->getName())));
+ throw new FieldException(t('Attempt to purge a field storage @field_name that still has fields.', ['@field_name' => $field_storage->getName()]));
}
$state = \Drupal::state();
@@ -173,7 +173,7 @@ function field_purge_field_storage(FieldStorageConfigInterface $field_storage) {
\Drupal::entityManager()->getStorage($field_storage->getTargetEntityTypeId())->finalizePurge($field_storage);
// Invoke external hooks after the cache is cleared for API consistency.
- \Drupal::moduleHandler()->invokeAll('field_purge_field_storage', array($field_storage));
+ \Drupal::moduleHandler()->invokeAll('field_purge_field_storage', [$field_storage]);
}
/**
diff --git a/core/modules/field/src/ConfigImporterFieldPurger.php b/core/modules/field/src/ConfigImporterFieldPurger.php
index 4137294f6ff..3974511a66d 100644
--- a/core/modules/field/src/ConfigImporterFieldPurger.php
+++ b/core/modules/field/src/ConfigImporterFieldPurger.php
@@ -47,7 +47,7 @@ class ConfigImporterFieldPurger {
}
else {
$context['finished'] = $context['sandbox']['field']['current_progress'] / $context['sandbox']['field']['steps_to_delete'];
- $context['message'] = \Drupal::translation()->translate('Purging field @field_label', array('@field_label' => $field_storage->label()));
+ $context['message'] = \Drupal::translation()->translate('Purging field @field_label', ['@field_label' => $field_storage->label()]);
}
}
@@ -111,11 +111,11 @@ class ConfigImporterFieldPurger {
public static function getFieldStoragesToPurge(array $extensions, array $deletes) {
$providers = array_keys($extensions['module']);
$providers[] = 'core';
- $storages_to_delete = array();
+ $storages_to_delete = [];
// Gather fields that will be deleted during configuration synchronization
// where the module that provides the field type is also being uninstalled.
- $field_storage_ids = array();
+ $field_storage_ids = [];
foreach ($deletes as $config_name) {
$field_storage_config_prefix = \Drupal::entityManager()->getDefinition('field_storage_config')->getConfigPrefix();
if (strpos($config_name, $field_storage_config_prefix . '.') === 0) {
@@ -134,7 +134,7 @@ class ConfigImporterFieldPurger {
// Gather deleted fields from modules that are being uninstalled.
/** @var \Drupal\field\FieldStorageConfigInterface[] $field_storages */
- $field_storages = entity_load_multiple_by_properties('field_storage_config', array('deleted' => TRUE, 'include_deleted' => TRUE));
+ $field_storages = entity_load_multiple_by_properties('field_storage_config', ['deleted' => TRUE, 'include_deleted' => TRUE]);
foreach ($field_storages as $field_storage) {
if (!in_array($field_storage->getTypeProvider(), $providers)) {
$storages_to_delete[$field_storage->id()] = $field_storage;
diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php
index f5e8ab31fe5..af2fcca738e 100644
--- a/core/modules/field/src/Entity/FieldConfig.php
+++ b/core/modules/field/src/Entity/FieldConfig.php
@@ -193,7 +193,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
parent::preDelete($storage, $fields);
// Keep the field definitions in the state storage so we can use them
// later during field_purge_batch().
- $deleted_fields = $state->get('field.field.deleted') ?: array();
+ $deleted_fields = $state->get('field.field.deleted') ?: [];
foreach ($fields as $field) {
if (!$field->deleted) {
$config = $field->toArray();
@@ -228,7 +228,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
// Delete the associated field storages if they are not used anymore and are
// not persistent.
- $storages_to_delete = array();
+ $storages_to_delete = [];
foreach ($fields as $field) {
$storage_definition = $field->getFieldStorageDefinition();
if (!$field->deleted && !$field->isUninstalling() && $storage_definition->isDeletable()) {
@@ -306,7 +306,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
*/
public function getDisplayOptions($display_context) {
// Hide configurable fields by default.
- return array('region' => 'hidden');
+ return ['region' => 'hidden'];
}
/**
diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php
index 00883d61aa5..a63e54f98be 100644
--- a/core/modules/field/src/Entity/FieldStorageConfig.php
+++ b/core/modules/field/src/Entity/FieldStorageConfig.php
@@ -370,7 +370,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
// See if any module forbids the update by throwing an exception. This
// invokes hook_field_storage_config_update_forbid().
- $module_handler->invokeAll('field_storage_config_update_forbid', array($this, $this->original));
+ $module_handler->invokeAll('field_storage_config_update_forbid', [$this, $this->original]);
// Notify the entity manager. A listener can reject the definition
// update as invalid by raising an exception, which stops execution before
@@ -407,7 +407,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
// Keep the field definitions in the state storage so we can use them later
// during field_purge_batch().
- $deleted_storages = $state->get('field.storage.deleted') ?: array();
+ $deleted_storages = $state->get('field.storage.deleted') ?: [];
foreach ($field_storages as $field_storage) {
if (!$field_storage->deleted) {
$config = $field_storage->toArray();
@@ -444,12 +444,12 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
$class = $this->getFieldItemClass();
$schema = $class::schema($this);
// Fill in default values for optional entries.
- $schema += array(
- 'columns' => array(),
- 'unique keys' => array(),
- 'indexes' => array(),
- 'foreign keys' => array(),
- );
+ $schema += [
+ 'columns' => [],
+ 'unique keys' => [],
+ 'indexes' => [],
+ 'foreign keys' => [],
+ ];
// Merge custom indexes with those specified by the field type. Custom
// indexes prevail.
@@ -499,7 +499,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
return $map[$this->getTargetEntityTypeId()][$this->getName()]['bundles'];
}
}
- return array();
+ return [];
}
/**
@@ -719,7 +719,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
* {@inheritdoc}
*/
public function getConstraints() {
- return array();
+ return [];
}
/**
diff --git a/core/modules/field/src/FieldConfigStorage.php b/core/modules/field/src/FieldConfigStorage.php
index 0870cd422fc..42d96346123 100644
--- a/core/modules/field/src/FieldConfigStorage.php
+++ b/core/modules/field/src/FieldConfigStorage.php
@@ -95,12 +95,12 @@ class FieldConfigStorage extends FieldConfigStorageBase {
/**
* {@inheritdoc}
*/
- public function loadByProperties(array $conditions = array()) {
+ public function loadByProperties(array $conditions = []) {
// Include deleted fields if specified in the $conditions parameters.
$include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE;
unset($conditions['include_deleted']);
- $fields = array();
+ $fields = [];
// Get fields stored in configuration. If we are explicitly looking for
// deleted fields only, this can be skipped, because they will be
@@ -109,7 +109,7 @@ class FieldConfigStorage extends FieldConfigStorageBase {
if (isset($conditions['entity_type']) && isset($conditions['bundle']) && isset($conditions['field_name'])) {
// Optimize for the most frequent case where we do have a specific ID.
$id = $conditions['entity_type'] . '.' . $conditions['bundle'] . '.' . $conditions['field_name'];
- $fields = $this->loadMultiple(array($id));
+ $fields = $this->loadMultiple([$id]);
}
else {
// No specific ID, we need to examine all existing fields.
@@ -119,8 +119,8 @@ class FieldConfigStorage extends FieldConfigStorageBase {
// Merge deleted fields (stored in state) if needed.
if ($include_deleted || !empty($conditions['deleted'])) {
- $deleted_fields = $this->state->get('field.field.deleted') ?: array();
- $deleted_storages = $this->state->get('field.storage.deleted') ?: array();
+ $deleted_fields = $this->state->get('field.field.deleted') ?: [];
+ $deleted_storages = $this->state->get('field.storage.deleted') ?: [];
foreach ($deleted_fields as $id => $config) {
// If the field storage itself is deleted, inject it directly in the field.
if (isset($deleted_storages[$config['field_storage_uuid']])) {
@@ -131,7 +131,7 @@ class FieldConfigStorage extends FieldConfigStorageBase {
}
// Collect matching fields.
- $matching_fields = array();
+ $matching_fields = [];
foreach ($fields as $field) {
// Some conditions are checked against the field storage.
$field_storage = $field->getFieldStorageDefinition();
diff --git a/core/modules/field/src/FieldStorageConfigStorage.php b/core/modules/field/src/FieldStorageConfigStorage.php
index cce8412c05c..7a793f6829b 100644
--- a/core/modules/field/src/FieldStorageConfigStorage.php
+++ b/core/modules/field/src/FieldStorageConfigStorage.php
@@ -94,13 +94,13 @@ class FieldStorageConfigStorage extends ConfigEntityStorage {
/**
* {@inheritdoc}
*/
- public function loadByProperties(array $conditions = array()) {
+ public function loadByProperties(array $conditions = []) {
// Include deleted fields if specified in the $conditions parameters.
$include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE;
unset($conditions['include_deleted']);
/** @var \Drupal\field\FieldStorageConfigInterface[] $storages */
- $storages = array();
+ $storages = [];
// Get field storages living in configuration. If we are explicitly looking
// for deleted storages only, this can be skipped, because they will be
@@ -109,7 +109,7 @@ class FieldStorageConfigStorage extends ConfigEntityStorage {
if (isset($conditions['entity_type']) && isset($conditions['field_name'])) {
// Optimize for the most frequent case where we do have a specific ID.
$id = $conditions['entity_type'] . $conditions['field_name'];
- $storages = $this->loadMultiple(array($id));
+ $storages = $this->loadMultiple([$id]);
}
else {
// No specific ID, we need to examine all existing storages.
@@ -119,14 +119,14 @@ class FieldStorageConfigStorage extends ConfigEntityStorage {
// Merge deleted field storages (living in state) if needed.
if ($include_deleted || !empty($conditions['deleted'])) {
- $deleted_storages = $this->state->get('field.storage.deleted') ?: array();
+ $deleted_storages = $this->state->get('field.storage.deleted') ?: [];
foreach ($deleted_storages as $id => $config) {
$storages[$id] = $this->create($config);
}
}
// Collect matching fields.
- $matches = array();
+ $matches = [];
foreach ($storages as $field) {
foreach ($conditions as $key => $value) {
// Extract the actual value against which the condition is checked.
diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php
index 034ab0b9cdf..9a8e86abb73 100644
--- a/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php
+++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php
@@ -26,7 +26,7 @@ class FieldFormatterSettingsDefaults extends ProcessPluginBase {
if (isset($value[1])) {
$module = $row->getSourceProperty('module');
if ($module === 'date') {
- $value = array('format_type' => 'fallback');
+ $value = ['format_type' => 'fallback'];
}
elseif ($module === 'number') {
// We have to do the lookup here in the process plugin because for
@@ -35,7 +35,7 @@ class FieldFormatterSettingsDefaults extends ProcessPluginBase {
return $this->numberSettings($row->getDestinationProperty('options/type'), $value[1]);
}
else {
- $value = array();
+ $value = [];
}
}
return $value;
diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceDefaults.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceDefaults.php
index 3ff0d8cb6f2..748eca28962 100644
--- a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceDefaults.php
+++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceDefaults.php
@@ -20,7 +20,7 @@ class FieldInstanceDefaults extends ProcessPluginBase {
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($widget_type, $widget_settings) = $value;
- $default = array();
+ $default = [];
switch ($widget_type) {
case 'text_textfield':
@@ -58,7 +58,7 @@ class FieldInstanceDefaults extends ProcessPluginBase {
break;
}
if (!empty($default)) {
- $default = array($default);
+ $default = [$default];
}
return $default;
}
diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php
index 080a4d7355a..82f25b5b2d0 100644
--- a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php
+++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php
@@ -20,7 +20,7 @@ class FieldInstanceSettings extends ProcessPluginBase {
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($widget_type, $widget_settings, $field_settings) = $value;
- $settings = array();
+ $settings = [];
switch ($widget_type) {
case 'number':
$settings['min'] = $field_settings['min'];
@@ -33,7 +33,7 @@ class FieldInstanceSettings extends ProcessPluginBase {
// $settings['url'] = $widget_settings['default_value'][0]['url'];
// D6 has optional, required, value and none. D8 only has disabled (0)
// optional (1) and required (2).
- $map = array('disabled' => 0, 'optional' => 1, 'required' => 2);
+ $map = ['disabled' => 0, 'optional' => 1, 'required' => 2];
$settings['title'] = $map[$field_settings['title']];
break;
diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php
index 1c7ede64f06..62c982963f2 100644
--- a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php
+++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php
@@ -41,41 +41,41 @@ class FieldInstanceWidgetSettings extends ProcessPluginBase {
$size = isset($widget_settings['size']) ? $widget_settings['size'] : 60;
$rows = isset($widget_settings['rows']) ? $widget_settings['rows'] : 5;
- $settings = array(
- 'text_textfield' => array(
+ $settings = [
+ 'text_textfield' => [
'size' => $size,
'placeholder' => '',
- ),
- 'text_textarea' => array(
+ ],
+ 'text_textarea' => [
'rows' => $rows,
'placeholder' => '',
- ),
- 'number' => array(
+ ],
+ 'number' => [
'placeholder' => '',
- ),
- 'email_textfield' => array(
+ ],
+ 'email_textfield' => [
'placeholder' => '',
- ),
- 'link' => array(
+ ],
+ 'link' => [
'placeholder_url' => '',
'placeholder_title' => '',
- ),
- 'filefield_widget' => array(
+ ],
+ 'filefield_widget' => [
'progress_indicator' => $progress,
- ),
- 'imagefield_widget' => array(
+ ],
+ 'imagefield_widget' => [
'progress_indicator' => $progress,
'preview_image_style' => 'thumbnail',
- ),
- 'optionwidgets_onoff' => array(
+ ],
+ 'optionwidgets_onoff' => [
'display_label' => FALSE,
- ),
- 'phone_textfield' => array(
+ ],
+ 'phone_textfield' => [
'placeholder' => '',
- ),
- );
+ ],
+ ];
- return isset($settings[$widget_type]) ? $settings[$widget_type] : array();
+ return isset($settings[$widget_type]) ? $settings[$widget_type] : [];
}
}
diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php
index 018afe6151c..1bb5b77ae5c 100644
--- a/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php
+++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php
@@ -59,26 +59,26 @@ class FieldSettings extends ProcessPluginBase {
}
}
- $settings = array(
- 'text' => array(
+ $settings = [
+ 'text' => [
'max_length' => $max_length,
- ),
- 'datetime' => array('datetime_type' => 'datetime'),
- 'list_string' => array(
+ ],
+ 'datetime' => ['datetime_type' => 'datetime'],
+ 'list_string' => [
'allowed_values' => $allowed_values,
- ),
- 'list_integer' => array(
+ ],
+ 'list_integer' => [
'allowed_values' => $allowed_values,
- ),
- 'list_float' => array(
+ ],
+ 'list_float' => [
'allowed_values' => $allowed_values,
- ),
- 'boolean' => array(
+ ],
+ 'boolean' => [
'allowed_values' => $allowed_values,
- ),
- );
+ ],
+ ];
- return isset($settings[$field_type]) ? $settings[$field_type] : array();
+ return isset($settings[$field_type]) ? $settings[$field_type] : [];
}
}
diff --git a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php
index 08501abb94e..2a463811be8 100644
--- a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php
+++ b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php
@@ -20,7 +20,7 @@ class FieldInstanceDefaults extends ProcessPluginBase {
list($default_value, $widget_settings) = $value;
$widget_type = $widget_settings['type'];
- $default = array();
+ $default = [];
foreach ($default_value as $item) {
switch ($widget_type) {
diff --git a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php
index d28007986fc..70a9498c41e 100644
--- a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php
+++ b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php
@@ -52,13 +52,13 @@ class FieldInstanceSettings extends ProcessPluginBase {
switch ($widget_type) {
case 'image_image':
$settings = $instance_settings;
- $settings['default_image'] = array(
+ $settings['default_image'] = [
'alt' => '',
'title' => '',
'width' => NULL,
'height' => NULL,
'uuid' => '',
- );
+ ];
break;
default:
diff --git a/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php b/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php
index bec448a2c27..dc629a44828 100644
--- a/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php
+++ b/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php
@@ -22,7 +22,7 @@ class FieldSettings extends ProcessPluginBase {
switch ($row->getSourceProperty('type')) {
case 'image':
if (!is_array($value['default_image'])) {
- $value['default_image'] = array('uuid' => '');
+ $value['default_image'] = ['uuid' => ''];
}
break;
diff --git a/core/modules/field/src/Plugin/migrate/source/d6/Field.php b/core/modules/field/src/Plugin/migrate/source/d6/Field.php
index cb108d700c8..7c9e620dd80 100644
--- a/core/modules/field/src/Plugin/migrate/source/d6/Field.php
+++ b/core/modules/field/src/Plugin/migrate/source/d6/Field.php
@@ -20,7 +20,7 @@ class Field extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('content_node_field', 'cnf')
- ->fields('cnf', array(
+ ->fields('cnf', [
'field_name',
'type',
'global_settings',
@@ -31,7 +31,7 @@ class Field extends DrupalSqlBase {
'db_columns',
'active',
'locked',
- ))
+ ])
->distinct();
// Only import fields which are actually being used.
$query->innerJoin('content_node_field_instance', 'cnfi', 'cnfi.field_name = cnf.field_name');
@@ -43,7 +43,7 @@ class Field extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'field_name' => $this->t('Field name'),
'type' => $this->t('Type (text, integer, ....)'),
'widget_type' => $this->t('An instance-specific widget type'),
@@ -55,7 +55,7 @@ class Field extends DrupalSqlBase {
'db_columns' => $this->t('DB Columns'),
'active' => $this->t('Active'),
'locked' => $this->t('Locked'),
- );
+ ];
}
/**
@@ -96,10 +96,10 @@ class Field extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- $ids['field_name'] = array(
+ $ids['field_name'] = [
'type' => 'string',
'alias' => 'cnf',
- );
+ ];
return $ids;
}
diff --git a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php
index 5436df64a3c..dbea7a8e733 100644
--- a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php
+++ b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php
@@ -33,7 +33,7 @@ class FieldInstance extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'field_name' => $this->t('The machine name of field.'),
'type_name' => $this->t('Content type where this field is in use.'),
'weight' => $this->t('Weight.'),
@@ -45,7 +45,7 @@ class FieldInstance extends DrupalSqlBase {
'widget_module' => $this->t('Module that implements widget.'),
'widget_active' => $this->t('Status of widget'),
'module' => $this->t('The module that provides the field.'),
- );
+ ];
}
/**
@@ -66,15 +66,15 @@ class FieldInstance extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- $ids = array(
- 'field_name' => array(
+ $ids = [
+ 'field_name' => [
'type' => 'string',
'alias' => 'cnfi',
- ),
- 'type_name' => array(
+ ],
+ 'type_name' => [
'type' => 'string',
- ),
- );
+ ],
+ ];
return $ids;
}
diff --git a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerFormDisplay.php b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerFormDisplay.php
index 44bad618e95..21baa9ee211 100644
--- a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerFormDisplay.php
+++ b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerFormDisplay.php
@@ -18,7 +18,7 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
* {@inheritdoc}
*/
protected function initializeIterator() {
- $rows = array();
+ $rows = [];
$result = $this->prepareQuery()->execute();
while ($field_row = $result->fetchAssoc()) {
$bundle = $field_row['type_name'];
@@ -44,7 +44,7 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('content_node_field_instance', 'cnfi')
- ->fields('cnfi', array(
+ ->fields('cnfi', [
'field_name',
'type_name',
'weight',
@@ -55,11 +55,11 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
'description',
'widget_module',
'widget_active',
- ))
- ->fields('cnf', array(
+ ])
+ ->fields('cnf', [
'type',
'module',
- ));
+ ]);
$query->join('content_node_field', 'cnf', 'cnfi.field_name = cnf.field_name');
$query->orderBy('cnfi.weight');
@@ -70,7 +70,7 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'field_name' => $this->t('The machine name of field.'),
'type_name' => $this->t('Content type where this field is used.'),
'weight' => $this->t('Weight.'),
@@ -81,7 +81,7 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
'description' => $this->t('A description of field.'),
'widget_module' => $this->t('Module that implements widget.'),
'widget_active' => $this->t('Status of widget'),
- );
+ ];
}
/**
diff --git a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php
index 2e1832e1b0a..43d27820db0 100644
--- a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php
+++ b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php
@@ -18,7 +18,7 @@ class FieldInstancePerViewMode extends ViewModeBase {
* {@inheritdoc}
*/
protected function initializeIterator() {
- $rows = array();
+ $rows = [];
$result = $this->prepareQuery()->execute();
while ($field_row = $result->fetchAssoc()) {
// These are added to every view mode row.
@@ -52,18 +52,18 @@ class FieldInstancePerViewMode extends ViewModeBase {
*/
public function query() {
$query = $this->select('content_node_field_instance', 'cnfi')
- ->fields('cnfi', array(
+ ->fields('cnfi', [
'field_name',
'type_name',
'weight',
'label',
'display_settings',
'widget_settings',
- ))
- ->fields('cnf', array(
+ ])
+ ->fields('cnf', [
'type',
'module',
- ));
+ ]);
$query->join('content_node_field', 'cnf', 'cnfi.field_name = cnf.field_name');
$query->orderBy('cnfi.weight');
@@ -74,7 +74,7 @@ class FieldInstancePerViewMode extends ViewModeBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'field_name' => $this->t('The machine name of field.'),
'type_name' => $this->t('Content type where this field is used.'),
'weight' => $this->t('Weight.'),
@@ -85,7 +85,7 @@ class FieldInstancePerViewMode extends ViewModeBase {
'description' => $this->t('A description of field.'),
'widget_module' => $this->t('Module that implements widget.'),
'widget_active' => $this->t('Status of widget'),
- );
+ ];
}
/**
diff --git a/core/modules/field/src/Plugin/migrate/source/d7/Field.php b/core/modules/field/src/Plugin/migrate/source/d7/Field.php
index 2e8f74551ca..d9aef9162a6 100644
--- a/core/modules/field/src/Plugin/migrate/source/d7/Field.php
+++ b/core/modules/field/src/Plugin/migrate/source/d7/Field.php
@@ -21,7 +21,7 @@ class Field extends DrupalSqlBase {
$query = $this->select('field_config', 'fc')
->distinct()
->fields('fc')
- ->fields('fci', array('entity_type'))
+ ->fields('fci', ['entity_type'])
->condition('fc.active', 1)
->condition('fc.deleted', 0)
->condition('fc.storage_active', 1);
@@ -34,7 +34,7 @@ class Field extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'field_name' => $this->t('The name of this field.'),
'type' => $this->t('The type of this field.'),
'module' => $this->t('The module that implements the field type.'),
@@ -42,7 +42,7 @@ class Field extends DrupalSqlBase {
'locked' => $this->t('Locked'),
'cardinality' => $this->t('Cardinality'),
'translatable' => $this->t('Translatable'),
- );
+ ];
}
/**
@@ -59,16 +59,16 @@ class Field extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'field_name' => array(
+ return [
+ 'field_name' => [
'type' => 'string',
'alias' => 'fc',
- ),
- 'entity_type' => array(
+ ],
+ 'entity_type' => [
'type' => 'string',
'alias' => 'fci',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php
index 3da02b92a0c..d06336e1538 100644
--- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php
+++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php
@@ -25,7 +25,7 @@ class FieldInstance extends DrupalSqlBase {
->condition('fc.active', 1)
->condition('fc.deleted', 0)
->condition('fc.storage_active', 1)
- ->fields('fc', array('type'));
+ ->fields('fc', ['type']);
$query->innerJoin('field_config', 'fc', 'fci.field_id = fc.id');
$query->addField('fc', 'data', 'field_data');
@@ -46,7 +46,7 @@ class FieldInstance extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'field_name' => $this->t('The machine name of field.'),
'entity_type' => $this->t('The entity type.'),
'bundle' => $this->t('The entity bundle.'),
@@ -55,7 +55,7 @@ class FieldInstance extends DrupalSqlBase {
'widget_settings' => $this->t('Widget settings.'),
'display_settings' => $this->t('Display settings.'),
'field_settings' => $this->t('Field settings.'),
- );
+ ];
}
/**
@@ -68,7 +68,7 @@ class FieldInstance extends DrupalSqlBase {
$row->setSourceProperty('description', $data['description']);
$row->setSourceProperty('required', $data['required']);
- $default_value = !empty($data['default_value']) ? $data['default_value'] : array();
+ $default_value = !empty($data['default_value']) ? $data['default_value'] : [];
if ($data['widget']['type'] == 'email_textfield' && $default_value) {
$default_value[0]['value'] = $default_value[0]['email'];
unset($default_value[0]['email']);
@@ -112,20 +112,20 @@ class FieldInstance extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'entity_type' => array(
+ return [
+ 'entity_type' => [
'type' => 'string',
'alias' => 'fci',
- ),
- 'bundle' => array(
+ ],
+ 'bundle' => [
'type' => 'string',
'alias' => 'fci',
- ),
- 'field_name' => array(
+ ],
+ 'field_name' => [
'type' => 'string',
'alias' => 'fci',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
index 62de5d9d6b4..ac599ec0a51 100644
--- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
+++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
@@ -19,16 +19,16 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('field_config_instance', 'fci')
- ->fields('fci', array(
+ ->fields('fci', [
'field_name',
'bundle',
'data',
'entity_type'
- ))
- ->fields('fc', array(
+ ])
+ ->fields('fc', [
'type',
'module',
- ));
+ ]);
$query->join('field_config', 'fc', 'fci.field_id = fc.id');
return $query;
}
@@ -47,27 +47,27 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'field_name' => $this->t('The machine name of field.'),
'bundle' => $this->t('Content type where this field is used.'),
'data' => $this->t('Field configuration data.'),
'entity_type' => $this->t('The entity type.'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'bundle' => array(
+ return [
+ 'bundle' => [
'type' => 'string',
- ),
- 'field_name' => array(
+ ],
+ 'field_name' => [
'type' => 'string',
'alias' => 'fci',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php
index 72a845bcaf0..7339e764a88 100644
--- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php
+++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php
@@ -18,7 +18,7 @@ class FieldInstancePerViewMode extends DrupalSqlBase {
* {@inheritdoc}
*/
protected function initializeIterator() {
- $rows = array();
+ $rows = [];
$result = $this->prepareQuery()->execute();
foreach ($result as $field_instance) {
$data = unserialize($field_instance['data']);
@@ -53,7 +53,7 @@ class FieldInstancePerViewMode extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'entity_type' => $this->t('The entity type ID.'),
'bundle' => $this->t('The bundle ID.'),
'field_name' => $this->t('Machine name of the field.'),
@@ -64,27 +64,27 @@ class FieldInstancePerViewMode extends DrupalSqlBase {
'settings' => $this->t('Array of formatter-specific settings.'),
'module' => $this->t('The module providing the formatter.'),
'weight' => $this->t('Display weight of the field.'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'entity_type' => array(
+ return [
+ 'entity_type' => [
'type' => 'string',
- ),
- 'bundle' => array(
+ ],
+ 'bundle' => [
'type' => 'string',
- ),
- 'view_mode' => array(
+ ],
+ 'view_mode' => [
'type' => 'string',
- ),
- 'field_name' => array(
+ ],
+ 'field_name' => [
'type' => 'string',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
index 5fa491b20a9..17292e09d8d 100644
--- a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
+++ b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
@@ -47,12 +47,12 @@ class BooleanFieldTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array(
+ $this->drupalLogin($this->drupalCreateUser([
'view test entity',
'administer entity_test content',
'administer entity_test form display',
'administer entity_test fields',
- )));
+ ]));
}
/**
@@ -65,36 +65,36 @@ class BooleanFieldTest extends WebTestBase {
// Create a field with settings to validate.
$field_name = Unicode::strtolower($this->randomMachineName());
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'boolean',
- ));
+ ]);
$this->fieldStorage->save();
- $this->field = FieldConfig::create(array(
+ $this->field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'label' => $label,
'required' => TRUE,
- 'settings' => array(
+ 'settings' => [
'on_label' => $on,
'off_label' => $off,
- ),
- ));
+ ],
+ ]);
$this->field->save();
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'boolean_checkbox',
- ))
+ ])
->save();
// Create a display for the full view mode.
entity_get_display('entity_test', 'entity_test', 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'boolean',
- ))
+ ])
->save();
// Display creation form.
@@ -104,13 +104,13 @@ class BooleanFieldTest extends WebTestBase {
$this->assertNoRaw($on, 'Does not use the "On" label.');
// Submit and ensure it is accepted.
- $edit = array(
+ $edit = [
"{$field_name}[value]" => 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
// Verify that boolean value is displayed.
$entity = EntityTest::load($id);
@@ -121,12 +121,12 @@ class BooleanFieldTest extends WebTestBase {
// Test with "On" label option.
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'boolean_checkbox',
- 'settings' => array(
+ 'settings' => [
'display_label' => FALSE,
- )
- ))
+ ]
+ ])
->save();
$this->drupalGet('entity_test/add');
@@ -136,9 +136,9 @@ class BooleanFieldTest extends WebTestBase {
// Test if we can change the on label.
$on = $this->randomMachineName();
- $edit = array(
+ $edit = [
'settings[on_label]' => $on,
- );
+ ];
$this->drupalPostForm('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name, $edit, t('Save settings'));
// Check if we see the updated labels in the creation form.
$this->drupalGet('entity_test/add');
@@ -150,7 +150,7 @@ class BooleanFieldTest extends WebTestBase {
$this->drupalGet($fieldEditUrl);
// Click on the widget settings button to open the widget settings form.
- $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit");
$this->assertText(
'Use field label instead of the "On label" as label',
@@ -158,7 +158,7 @@ class BooleanFieldTest extends WebTestBase {
);
// Enable setting.
- $edit = array('fields[' . $field_name . '][settings_edit_form][settings][display_label]' => 1);
+ $edit = ['fields[' . $field_name . '][settings_edit_form][settings][display_label]' => 1];
$this->drupalPostAjaxForm(NULL, $edit, $field_name . "_plugin_settings_update");
$this->drupalPostForm(NULL, NULL, 'Save');
@@ -167,7 +167,7 @@ class BooleanFieldTest extends WebTestBase {
$this->drupalGet($fieldEditUrl);
$this->assertText('Use field label: Yes', 'Checking the display settings checkbox updated the value.');
- $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit");
$this->assertText(
'Use field label instead of the "On label" as label',
t('Display setting checkbox is available')
diff --git a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php
index 0d0c475f30b..f45442060bc 100644
--- a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php
+++ b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php
@@ -44,10 +44,10 @@ class BooleanFormatterSettingsTest extends WebTestBase {
// Create a content type. Use Node because it has Field UI pages that work.
$type_name = Unicode::strtolower($this->randomMachineName(8)) . '_test';
- $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
+ $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$this->bundle = $type->id();
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node display', 'bypass node access', 'administer nodes'));
+ $admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node display', 'bypass node access', 'administer nodes']);
$this->drupalLogin($admin_user);
$this->fieldName = Unicode::strtolower($this->randomMachineName(8));
@@ -81,14 +81,14 @@ class BooleanFormatterSettingsTest extends WebTestBase {
// List the options we expect to see on the settings form. Omit the one
// with the Unicode check/x characters, which does not appear to work
// well in WebTestBase.
- $options = array(
+ $options = [
'Yes / No',
'True / False',
'On / Off',
'Enabled / Disabled',
'1 / 0',
'Custom',
- );
+ ];
// Define what the "default" option should look like, depending on the
// field settings.
@@ -96,29 +96,29 @@ class BooleanFormatterSettingsTest extends WebTestBase {
// For several different values of the field settings, test that the
// options, including default, are shown correctly.
- $settings = array(
- array('Yes', 'No'),
- array('On', 'Off'),
- array('TRUE', 'FALSE'),
- );
+ $settings = [
+ ['Yes', 'No'],
+ ['On', 'Off'],
+ ['TRUE', 'FALSE'],
+ ];
foreach ($settings as $values) {
// Set up the field settings.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/fields/node.' . $this->bundle . '.' . $this->fieldName);
- $this->drupalPostForm(NULL, array(
+ $this->drupalPostForm(NULL, [
'settings[on_label]' => $values[0],
'settings[off_label]' => $values[1],
- ), 'Save settings');
+ ], 'Save settings');
// Open the Manage Display page and trigger the field settings form.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/display');
- $this->drupalPostAjaxForm(NULL, array(), $this->fieldName . '_settings_edit');
+ $this->drupalPostAjaxForm(NULL, [], $this->fieldName . '_settings_edit');
// Test that the settings options are present in the correct format.
foreach ($options as $string) {
$this->assertText($string);
}
- $this->assertText(SafeMarkup::format($default, array('@on' => $values[0], '@off' => $values[1])));
+ $this->assertText(SafeMarkup::format($default, ['@on' => $values[0], '@off' => $values[1]]));
}
foreach ($settings as $values) {
diff --git a/core/modules/field/src/Tests/Email/EmailFieldTest.php b/core/modules/field/src/Tests/Email/EmailFieldTest.php
index 7c22861e816..779870ced3d 100644
--- a/core/modules/field/src/Tests/Email/EmailFieldTest.php
+++ b/core/modules/field/src/Tests/Email/EmailFieldTest.php
@@ -20,7 +20,7 @@ class EmailFieldTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'entity_test', 'field_ui');
+ public static $modules = ['node', 'entity_test', 'field_ui'];
/**
* A field storage to use in this test class.
@@ -39,11 +39,11 @@ class EmailFieldTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array(
+ $this->drupalLogin($this->drupalCreateUser([
'view test entity',
'administer entity_test content',
'administer content types',
- )));
+ ]));
}
/**
@@ -52,11 +52,11 @@ class EmailFieldTest extends WebTestBase {
function testEmailField() {
// Create a field with settings to validate.
$field_name = Unicode::strtolower($this->randomMachineName());
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'email',
- ));
+ ]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
@@ -66,18 +66,18 @@ class EmailFieldTest extends WebTestBase {
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'email_default',
- 'settings' => array(
+ 'settings' => [
'placeholder' => 'example@example.com',
- ),
- ))
+ ],
+ ])
->save();
// Create a display for the full view mode.
entity_get_display('entity_test', 'entity_test', 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'email_mailto',
- ))
+ ])
->save();
// Display creation form.
@@ -87,13 +87,13 @@ class EmailFieldTest extends WebTestBase {
// Submit a valid email address and ensure it is accepted.
$value = 'test@example.com';
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($value);
// Verify that a mailto link is displayed.
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
index 3803029d773..fa68cb61509 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
@@ -46,18 +46,18 @@ class EntityReferenceAdminTest extends WebTestBase {
// Create a content type, with underscores.
$type_name = strtolower($this->randomMachineName(8)) . '_test';
- $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
+ $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$this->type = $type->id();
// Create test user.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'access content',
'administer node fields',
'administer node display',
'administer views',
'create ' . $type_name . ' content',
'edit own ' . $type_name . ' content',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
@@ -74,11 +74,11 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->assertOption('edit-new-storage-type', 'field_ui:entity_reference:node');
$this->assertOption('edit-new-storage-type', 'field_ui:entity_reference:user');
- $this->drupalPostForm(NULL, array(
+ $this->drupalPostForm(NULL, [
'label' => 'Test label',
'field_name' => 'test',
'new_storage_type' => 'entity_reference',
- ), t('Save and continue'));
+ ], t('Save and continue'));
// Node should be selected by default.
$this->assertFieldByName('settings[target_type]', 'node');
@@ -87,7 +87,7 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityManager()->getDefinitions()));
// Second step: 'Field settings' form.
- $this->drupalPostForm(NULL, array(), t('Save field settings'));
+ $this->drupalPostForm(NULL, [], t('Save field settings'));
// The base handler should be selected by default.
$this->assertFieldByName('settings[handler]', 'default:node');
@@ -106,7 +106,7 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->assertFieldByName('settings[handler_settings][sort][field]', '_none');
$this->assertNoFieldByName('settings[handler_settings][sort][direction]');
// Option 1: sort by field.
- $this->drupalPostAjaxForm(NULL, array('settings[handler_settings][sort][field]' => 'nid'), 'settings[handler_settings][sort][field]');
+ $this->drupalPostAjaxForm(NULL, ['settings[handler_settings][sort][field]' => 'nid'], 'settings[handler_settings][sort][field]');
$this->assertFieldByName('settings[handler_settings][sort][direction]', 'ASC');
// Test that a non-translatable base field is a sort option.
@@ -117,14 +117,14 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->assertFieldByXPath("//select[@name='settings[handler_settings][sort][field]']/option[@value='body.value']");
// Set back to no sort.
- $this->drupalPostAjaxForm(NULL, array('settings[handler_settings][sort][field]' => '_none'), 'settings[handler_settings][sort][field]');
+ $this->drupalPostAjaxForm(NULL, ['settings[handler_settings][sort][field]' => '_none'], 'settings[handler_settings][sort][field]');
$this->assertNoFieldByName('settings[handler_settings][sort][direction]');
// Third step: confirm.
- $this->drupalPostForm(NULL, array(
+ $this->drupalPostForm(NULL, [
'required' => '1',
'settings[handler_settings][target_bundles][' . key($bundles) . ']' => key($bundles),
- ), t('Save settings'));
+ ], t('Save settings'));
// Check that the field appears in the overview form.
$this->assertFieldByXPath('//table[@id="field-overview"]//tr[@id="field-test"]/td[1]', 'Test label', 'Field was created and appears in the overview page.');
@@ -133,14 +133,14 @@ class EntityReferenceAdminTest extends WebTestBase {
// field is required.
// The first 'Edit' link is for the Body field.
$this->clickLink(t('Edit'), 1);
- $this->drupalPostForm(NULL, array(), t('Save settings'));
+ $this->drupalPostForm(NULL, [], t('Save settings'));
// Switch the target type to 'taxonomy_term' and check that the settings
// specific to its selection handler are displayed.
$field_name = 'node.' . $this->type . '.field_test';
- $edit = array(
+ $edit = [
'settings[target_type]' => 'taxonomy_term',
- );
+ ];
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
$this->drupalGet($bundle_path . '/fields/' . $field_name);
$this->assertFieldByName('settings[handler_settings][auto_create]');
@@ -148,63 +148,63 @@ class EntityReferenceAdminTest extends WebTestBase {
// Switch the target type to 'user' and check that the settings specific to
// its selection handler are displayed.
$field_name = 'node.' . $this->type . '.field_test';
- $edit = array(
+ $edit = [
'settings[target_type]' => 'user',
- );
+ ];
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
$this->drupalGet($bundle_path . '/fields/' . $field_name);
$this->assertFieldByName('settings[handler_settings][filter][type]', '_none');
// Switch the target type to 'node'.
$field_name = 'node.' . $this->type . '.field_test';
- $edit = array(
+ $edit = [
'settings[target_type]' => 'node',
- );
+ ];
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
// Try to select the views handler.
- $edit = array(
+ $edit = [
'settings[handler]' => 'views',
- );
+ ];
$this->drupalPostAjaxForm($bundle_path . '/fields/' . $field_name, $edit, 'settings[handler]');
- $this->assertRaw(t('No eligible views were found. <a href=":create">Create a view</a> with an <em>Entity Reference</em> display, or add such a display to an <a href=":existing">existing view</a>.', array(
+ $this->assertRaw(t('No eligible views were found. <a href=":create">Create a view</a> with an <em>Entity Reference</em> display, or add such a display to an <a href=":existing">existing view</a>.', [
':create' => \Drupal::url('views_ui.add'),
':existing' => \Drupal::url('entity.view.collection'),
- )));
+ ]));
$this->drupalPostForm(NULL, $edit, t('Save settings'));
// If no eligible view is available we should see a message.
$this->assertText('The views entity selection mode requires a view.');
// Enable the entity_reference_test module which creates an eligible view.
- $this->container->get('module_installer')->install(array('entity_reference_test'));
+ $this->container->get('module_installer')->install(['entity_reference_test']);
$this->resetAll();
$this->drupalGet($bundle_path . '/fields/' . $field_name);
$this->drupalPostAjaxForm($bundle_path . '/fields/' . $field_name, $edit, 'settings[handler]');
- $edit = array(
+ $edit = [
'settings[handler_settings][view][view_and_display]' => 'test_entity_reference:entity_reference_1',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->assertResponse(200);
// Switch the target type to 'entity_test'.
- $edit = array(
+ $edit = [
'settings[target_type]' => 'entity_test',
- );
+ ];
$this->drupalPostForm($bundle_path . '/fields/' . $field_name . '/storage', $edit, t('Save field settings'));
$this->drupalGet($bundle_path . '/fields/' . $field_name);
- $edit = array(
+ $edit = [
'settings[handler]' => 'views',
- );
+ ];
$this->drupalPostAjaxForm($bundle_path . '/fields/' . $field_name, $edit, 'settings[handler]');
- $edit = array(
+ $edit = [
'required' => FALSE,
'settings[handler_settings][view][view_and_display]' => 'test_entity_reference_entity_test:entity_reference_1',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->assertResponse(200);
// Create a new view and display it as a entity reference.
- $edit = array(
+ $edit = [
'id' => 'node_test_view',
'label' => 'Node Test View',
'show[wizard_key]' => 'node',
@@ -214,13 +214,13 @@ class EntityReferenceAdminTest extends WebTestBase {
'page[path]' => 'test/node/view',
'page[style][style_plugin]' => 'default',
'page[style][row_plugin]' => 'fields',
- );
+ ];
$this->drupalPostForm('admin/structure/views/add', $edit, t('Save and edit'));
- $this->drupalPostForm(NULL, array(), t('Duplicate as Entity Reference'));
+ $this->drupalPostForm(NULL, [], t('Duplicate as Entity Reference'));
$this->clickLink(t('Settings'));
- $edit = array(
+ $edit = [
'style_options[search_fields][title]' => 'title',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply'));
// Set sort to NID ascending.
@@ -230,33 +230,33 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->drupalPostForm('admin/structure/views/nojs/add-handler/node_test_view/entity_reference_1/sort', $edit, t('Add and configure sort criteria'));
$this->drupalPostForm(NULL, NULL, t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/node_test_view/edit/entity_reference_1', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/view/node_test_view/edit/entity_reference_1', [], t('Save'));
$this->clickLink(t('Settings'));
// Create a test entity reference field.
$field_name = 'test_entity_ref_field';
- $edit = array(
+ $edit = [
'new_storage_type' => 'field_ui:entity_reference:node',
'label' => 'Test Entity Reference Field',
'field_name' => $field_name,
- );
+ ];
$this->drupalPostForm($bundle_path . '/fields/add-field', $edit, t('Save and continue'));
// Set to unlimited.
- $edit = array(
+ $edit = [
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save field settings'));
// Add the view to the test field.
- $edit = array(
+ $edit = [
'settings[handler]' => 'views',
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, 'settings[handler]');
- $edit = array(
+ $edit = [
'required' => FALSE,
'settings[handler_settings][view][view_and_display]' => 'node_test_view:entity_reference_1',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
// Create nodes.
@@ -275,34 +275,34 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->drupalGet('node/add/' . $this->type);
$result = $this->xpath('//input[@name="field_test_entity_ref_field[0][target_id]" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/node/views/")]');
$target_url = $this->getAbsoluteUrl($result[0]['data-autocomplete-path']);
- $this->drupalGet($target_url, array('query' => array('q' => 'Foo')));
+ $this->drupalGet($target_url, ['query' => ['q' => 'Foo']]);
$this->assertRaw($node1->getTitle() . ' (' . $node1->id() . ')');
$this->assertRaw($node2->getTitle() . ' (' . $node2->id() . ')');
// Try to add a new node, fill the entity reference field and submit the
// form.
$this->drupalPostForm('node/add/' . $this->type, [], t('Add another item'));
- $edit = array(
+ $edit = [
'title[0][value]' => 'Example',
'field_test_entity_ref_field[0][target_id]' => 'Foo Node (' . $node1->id() . ')',
'field_test_entity_ref_field[1][target_id]' => 'Foo Node (' . $node2->id() . ')',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertResponse(200);
- $edit = array(
+ $edit = [
'title[0][value]' => 'Example',
'field_test_entity_ref_field[0][target_id]' => 'Test'
- );
+ ];
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
// Assert that entity reference autocomplete field is validated.
$this->assertText(t('There are no entities matching "@entity"', ['@entity' => 'Test']));
- $edit = array(
+ $edit = [
'title[0][value]' => 'Test',
'field_test_entity_ref_field[0][target_id]' => $node1->getTitle()
- );
+ ];
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
// Assert the results multiple times to avoid sorting problem of nodes with
@@ -312,15 +312,15 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->assertText(t("@node2", ['@node2' => $node2->getTitle() . ' (' . $node2->id() . ')']));
$this->assertText(t('Specify the one you want by appending the id in parentheses, like "@example".', ['@example' => $node2->getTitle() . ' (' . $node2->id() . ')']));
- $edit = array(
+ $edit = [
'title[0][value]' => 'Test',
'field_test_entity_ref_field[0][target_id]' => $node1->getTitle() . ' (' . $node1->id() . ')'
- );
+ ];
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
$this->assertLink($node1->getTitle());
// Tests adding default values to autocomplete widgets.
- Vocabulary::create(array('vid' => 'tags', 'name' => 'tags'))->save();
+ Vocabulary::create(['vid' => 'tags', 'name' => 'tags'])->save();
$taxonomy_term_field_name = $this->createEntityReferenceField('taxonomy_term', ['tags']);
$field_path = 'node.' . $this->type . '.field_' . $taxonomy_term_field_name;
$this->drupalGet($bundle_path . '/fields/' . $field_path . '/storage');
@@ -351,7 +351,7 @@ class EntityReferenceAdminTest extends WebTestBase {
*/
public function testAvailableFormatters() {
// Create a new vocabulary.
- Vocabulary::create(array('vid' => 'tags', 'name' => 'tags'))->save();
+ Vocabulary::create(['vid' => 'tags', 'name' => 'tags'])->save();
// Create entity reference field with taxonomy term as a target.
$taxonomy_term_field_name = $this->createEntityReferenceField('taxonomy_term', ['tags']);
@@ -370,38 +370,38 @@ class EntityReferenceAdminTest extends WebTestBase {
// Check for Taxonomy Term select box values.
// Test if Taxonomy Term Entity Reference Field has the correct formatters.
- $this->assertFieldSelectOptions('fields[field_' . $taxonomy_term_field_name . '][type]', array(
+ $this->assertFieldSelectOptions('fields[field_' . $taxonomy_term_field_name . '][type]', [
'entity_reference_label',
'entity_reference_entity_id',
'entity_reference_rss_category',
'entity_reference_entity_view',
- ));
+ ]);
// Test if User Reference Field has the correct formatters.
// Author should be available for this field.
// RSS Category should not be available for this field.
- $this->assertFieldSelectOptions('fields[field_' . $user_field_name . '][type]', array(
+ $this->assertFieldSelectOptions('fields[field_' . $user_field_name . '][type]', [
'author',
'entity_reference_entity_id',
'entity_reference_entity_view',
'entity_reference_label',
- ));
+ ]);
// Test if Node Entity Reference Field has the correct formatters.
// RSS Category should not be available for this field.
- $this->assertFieldSelectOptions('fields[field_' . $node_field_name . '][type]', array(
+ $this->assertFieldSelectOptions('fields[field_' . $node_field_name . '][type]', [
'entity_reference_label',
'entity_reference_entity_id',
'entity_reference_entity_view',
- ));
+ ]);
// Test if Date Format Reference Field has the correct formatters.
// RSS Category & Entity View should not be available for this field.
// This could be any field without a ViewBuilder.
- $this->assertFieldSelectOptions('fields[field_' . $date_format_field_name . '][type]', array(
+ $this->assertFieldSelectOptions('fields[field_' . $date_format_field_name . '][type]', [
'entity_reference_label',
'entity_reference_entity_id',
- ));
+ ]);
}
/**
@@ -483,7 +483,7 @@ class EntityReferenceAdminTest extends WebTestBase {
// Generate a random field name, must be only lowercase characters.
$field_name = strtolower($this->randomMachineName());
- $storage_edit = $field_edit = array();
+ $storage_edit = $field_edit = [];
$storage_edit['settings[target_type]'] = $target_type;
foreach ($bundles as $bundle) {
$field_edit['settings[handler_settings][target_bundles][' . $bundle . ']'] = TRUE;
@@ -507,7 +507,7 @@ class EntityReferenceAdminTest extends WebTestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertFieldSelectOptions($name, array $expected_options) {
- $xpath = $this->buildXPathQuery('//select[@name=:name]', array(':name' => $name));
+ $xpath = $this->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$fields = $this->xpath($xpath);
if ($fields) {
$field = $fields[0];
@@ -533,7 +533,7 @@ class EntityReferenceAdminTest extends WebTestBase {
* An array of option values as strings.
*/
protected function getAllOptionsList(\SimpleXMLElement $element) {
- $options = array();
+ $options = [];
// Add all options items.
foreach ($element->option as $option) {
$options[] = (string) $option['value'];
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
index 6aef0f82835..19575840f29 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
@@ -14,7 +14,7 @@ use Drupal\field\Entity\FieldStorageConfig;
*/
class EntityReferenceFileUploadTest extends WebTestBase {
- public static $modules = array('entity_reference', 'node', 'file');
+ public static $modules = ['entity_reference', 'node', 'file'];
/**
* The name of a content type that will reference $referencedType.
@@ -46,19 +46,19 @@ class EntityReferenceFileUploadTest extends WebTestBase {
$referenced = $this->drupalCreateContentType();
$this->referencedType = $referenced->id();
- $this->nodeId = $this->drupalCreateNode(array('type' => $referenced->id()))->id();
+ $this->nodeId = $this->drupalCreateNode(['type' => $referenced->id()])->id();
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'node',
'translatable' => FALSE,
- 'entity_types' => array(),
- 'settings' => array(
+ 'entity_types' => [],
+ 'settings' => [
'target_type' => 'node',
- ),
+ ],
'type' => 'entity_reference',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
FieldConfig::create([
'label' => 'Entity reference field',
@@ -66,25 +66,25 @@ class EntityReferenceFileUploadTest extends WebTestBase {
'entity_type' => 'node',
'required' => TRUE,
'bundle' => $referencing->id(),
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
// Reference a single vocabulary.
- 'target_bundles' => array(
+ 'target_bundles' => [
$referenced->id(),
- ),
- ),
- ),
+ ],
+ ],
+ ],
])->save();
// Create a file field.
$file_field_name = 'file_field';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $file_field_name,
'entity_type' => 'node',
'type' => 'file'
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'entity_type' => 'node',
@@ -98,12 +98,12 @@ class EntityReferenceFileUploadTest extends WebTestBase {
->setComponent($file_field_name)
->save();
entity_get_form_display('node', $referencing->id(), 'default')
- ->setComponent('test_field', array(
+ ->setComponent('test_field', [
'type' => 'entity_reference_autocomplete',
- ))
- ->setComponent($file_field_name, array(
+ ])
+ ->setComponent($file_field_name, [
'type' => 'file_generic',
- ))
+ ])
->save();
}
@@ -111,17 +111,17 @@ class EntityReferenceFileUploadTest extends WebTestBase {
* Tests that the autocomplete input element does not cause ajax fatal.
*/
public function testFileUpload() {
- $user1 = $this->drupalCreateUser(array('access content', "create $this->referencingType content"));
+ $user1 = $this->drupalCreateUser(['access content', "create $this->referencingType content"]);
$this->drupalLogin($user1);
$test_file = current($this->drupalGetTestFiles('text'));
$edit['files[file_field_0]'] = drupal_realpath($test_file->uri);
$this->drupalPostForm('node/add/' . $this->referencingType, $edit, 'Upload');
$this->assertResponse(200);
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
'test_field[0][target_id]' => $this->nodeId,
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertResponse(200);
}
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceTestTrait.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceTestTrait.php
index 13e28da70fa..568cd4d5fcb 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceTestTrait.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceTestTrait.php
@@ -34,30 +34,30 @@ trait EntityReferenceTestTrait {
*
* @see \Drupal\Core\Entity\Plugin\EntityReferenceSelection\SelectionBase::buildConfigurationForm()
*/
- protected function createEntityReferenceField($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = array(), $cardinality = 1) {
+ protected function createEntityReferenceField($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = [], $cardinality = 1) {
// Look for or add the specified field to the requested entity bundle.
if (!FieldStorageConfig::loadByName($entity_type, $field_name)) {
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'type' => 'entity_reference',
'entity_type' => $entity_type,
'cardinality' => $cardinality,
- 'settings' => array(
+ 'settings' => [
'target_type' => $target_entity_type,
- ),
- ))->save();
+ ],
+ ])->save();
}
if (!FieldConfig::loadByName($entity_type, $bundle, $field_name)) {
- FieldConfig::create(array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
'label' => $field_label,
- 'settings' => array(
+ 'settings' => [
'handler' => $selection_handler,
'handler_settings' => $selection_handler_settings,
- ),
- ))->save();
+ ],
+ ])->save();
}
}
diff --git a/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php b/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php
index e7f5a4c5448..b6926ce7e29 100644
--- a/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php
+++ b/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php
@@ -18,7 +18,7 @@ class FieldDefaultValueCallbackTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_test', 'field_ui');
+ public static $modules = ['node', 'field_test', 'field_ui'];
/**
* The field name.
@@ -37,10 +37,10 @@ class FieldDefaultValueCallbackTest extends WebTestBase {
// Create Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
- ));
+ ]);
}
}
diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php
index e69e04f8c49..e35308603f9 100644
--- a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php
+++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php
@@ -22,12 +22,12 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
*
* @var array
*/
- public static $modules = array('entity_test', 'telephone', 'config', 'filter', 'datetime');
+ public static $modules = ['entity_test', 'telephone', 'config', 'filter', 'datetime'];
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array('synchronize configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['synchronize configuration']));
}
/**
@@ -35,11 +35,11 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
*/
public function testImportDeleteUninstall() {
// Create a telephone field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_tel',
'entity_type' => 'entity_test',
'type' => 'telephone',
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -47,11 +47,11 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
])->save();
// Create a text field.
- $date_field_storage = FieldStorageConfig::create(array(
+ $date_field_storage = FieldStorageConfig::create([
'field_name' => 'field_date',
'entity_type' => 'entity_test',
'type' => 'datetime',
- ));
+ ]);
$date_field_storage->save();
FieldConfig::create([
'field_storage' => $date_field_storage,
@@ -104,12 +104,12 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
// This will purge all the data, delete the field and uninstall the
// Telephone and Text modules.
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$this->assertNoText('Field data will be deleted by this synchronization.');
$this->rebuildContainer();
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone'));
$this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The telephone field has been deleted by the configuration synchronization');
- $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
+ $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.');
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Text field has been completed removed from the system.');
}
diff --git a/core/modules/field/src/Tests/FieldTestBase.php b/core/modules/field/src/Tests/FieldTestBase.php
index 30c80dfafdd..ce4161bc9b4 100644
--- a/core/modules/field/src/Tests/FieldTestBase.php
+++ b/core/modules/field/src/Tests/FieldTestBase.php
@@ -23,7 +23,7 @@ abstract class FieldTestBase extends WebTestBase {
* An array of random values, in the format expected for field values.
*/
function _generateTestFieldValues($cardinality) {
- $values = array();
+ $values = [];
for ($i = 0; $i < $cardinality; $i++) {
// field_test fields treat 0 as 'empty value'.
$values[$i]['value'] = mt_rand(1, 127);
@@ -61,7 +61,7 @@ abstract class FieldTestBase extends WebTestBase {
$values = $field->getValue();
$this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
foreach ($expected_values as $key => $value) {
- $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));
+ $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', ['@value' => $value]));
}
}
diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php
index 16625a9ab4f..77cc27441da 100644
--- a/core/modules/field/src/Tests/FormTest.php
+++ b/core/modules/field/src/Tests/FormTest.php
@@ -25,7 +25,7 @@ class FormTest extends FieldTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_test', 'options', 'entity_test', 'locale');
+ public static $modules = ['node', 'field_test', 'options', 'entity_test', 'locale'];
/**
* An array of values defining a field single.
@@ -58,37 +58,37 @@ class FormTest extends FieldTestBase {
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
+ $web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$this->drupalLogin($web_user);
- $this->fieldStorageSingle = array(
+ $this->fieldStorageSingle = [
'field_name' => 'field_single',
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
- $this->fieldStorageMultiple = array(
+ ];
+ $this->fieldStorageMultiple = [
'field_name' => 'field_multiple',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => 4,
- );
- $this->fieldStorageUnlimited = array(
+ ];
+ $this->fieldStorageUnlimited = [
'field_name' => 'field_unlimited',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- );
+ ];
- $this->field = array(
+ $this->field = [
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'label' => $this->randomMachineName() . '_label',
'description' => '[site:name]_description',
'weight' => mt_rand(0, 127),
- 'settings' => array(
+ 'settings' => [
'test_field_setting' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
}
function testFieldFormSingle() {
@@ -115,22 +115,22 @@ class FormTest extends FieldTestBase {
$this->assertNoText('From hook_field_widget_form_alter(): Default form is true.', 'Not default value form in hook_field_widget_form_alter().');
// Submit with invalid value (field-level validation).
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => -1
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name does not accept the value -1.', array('%name' => $this->field['label'])), 'Field validation fails with invalid input.');
+ $this->assertRaw(t('%name does not accept the value -1.', ['%name' => $this->field['label']]), 'Field validation fails with invalid input.');
// TODO : check that the correct field is flagged for error.
// Create an entity
$value = mt_rand(1, 127);
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was saved');
@@ -141,23 +141,23 @@ class FormTest extends FieldTestBase {
// Update the entity.
$value = mt_rand(1, 127);
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated');
- $this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
+ $this->assertText(t('entity_test @id has been updated.', ['@id' => $id]), 'Entity was updated');
+ $this->container->get('entity.manager')->getStorage('entity_test')->resetCache([$id]);
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated');
// Empty the field.
$value = '';
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value
- );
+ ];
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
- $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated');
- $this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
+ $this->assertText(t('entity_test @id has been updated.', ['@id' => $id]), 'Entity was updated');
+ $this->container->get('entity.manager')->getStorage('entity_test')->resetCache([$id]);
$entity = EntityTest::load($id);
$this->assertTrue($entity->{$field_name}->isEmpty(), 'Field was emptied');
}
@@ -170,7 +170,7 @@ class FormTest extends FieldTestBase {
$field_name = $field_storage['field_name'];
$this->field['field_name'] = $field_name;
$default = rand(1, 127);
- $this->field['default_value'] = array(array('value' => $default));
+ $this->field['default_value'] = [['value' => $default]];
FieldStorageConfig::create($field_storage)->save();
FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
@@ -183,13 +183,13 @@ class FormTest extends FieldTestBase {
$this->assertFieldByXpath("//input[@name='{$field_name}[0][value]' and @value='$default']");
// Try to submit an empty value.
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => '',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created.');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created.');
$entity = EntityTest::load($id);
$this->assertTrue($entity->{$field_name}->isEmpty(), 'Field is now empty.');
}
@@ -206,29 +206,29 @@ class FormTest extends FieldTestBase {
->save();
// Submit with missing required value.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('entity_test/add', $edit, t('Save'));
- $this->assertRaw(t('@name field is required.', array('@name' => $this->field['label'])), 'Required field with no value fails validation');
+ $this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]), 'Required field with no value fails validation');
// Create an entity
$value = mt_rand(1, 127);
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was saved');
// Edit with missing required value.
$value = '';
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
- $this->assertRaw(t('@name field is required.', array('@name' => $this->field['label'])), 'Required field with no value fails validation');
+ $this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]), 'Required field with no value fails validation');
}
function testFieldFormUnlimited() {
@@ -251,20 +251,20 @@ class FormTest extends FieldTestBase {
$this->assertTrue(isset($elements[0]), t('aria-describedby attribute is properly placed on multiple value widgets.'));
// Press 'add more' button -> 2 widgets.
- $this->drupalPostForm(NULL, array(), t('Add another item'));
+ $this->drupalPostForm(NULL, [], t('Add another item'));
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
$this->assertFieldByName("{$field_name}[1][value]", '', 'New widget is displayed');
$this->assertNoField("{$field_name}[2][value]", 'No extraneous widget is displayed');
// TODO : check that non-field inputs are preserved ('title'), etc.
// Yet another time so that we can play with more values -> 3 widgets.
- $this->drupalPostForm(NULL, array(), t('Add another item'));
+ $this->drupalPostForm(NULL, [], t('Add another item'));
// Prepare values and weights.
$count = 3;
$delta_range = $count - 1;
- $values = $weights = $pattern = $expected_values = array();
- $edit = array();
+ $values = $weights = $pattern = $expected_values = [];
+ $edit = [];
for ($delta = 0; $delta <= $delta_range; $delta++) {
// Assign unique random values and weights.
do {
@@ -299,7 +299,7 @@ class FormTest extends FieldTestBase {
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
$entity = EntityTest::load($id);
ksort($field_values);
$field_values = array_values($field_values);
@@ -330,11 +330,11 @@ class FormTest extends FieldTestBase {
// Display creation form -> 1 widget.
$this->drupalGet('entity_test/add');
// Check that the Required symbol is present for the multifield label.
- $element = $this->xpath('//h4[contains(@class, "label") and contains(@class, "js-form-required") and contains(text(), :value)]', array(':value' => $this->field['label']));
+ $element = $this->xpath('//h4[contains(@class, "label") and contains(@class, "js-form-required") and contains(text(), :value)]', [':value' => $this->field['label']]);
$this->assertTrue(isset($element[0]), 'Required symbol added field label.');
// Check that the label of the field input is visually hidden and contains
// the field title and an indication of the delta for a11y.
- $element = $this->xpath('//label[@for=:for and contains(@class, "visually-hidden") and contains(text(), :value)]', array(':for' => 'edit-field-unlimited-0-value', ':value' => $this->field['label'] . ' (value 1)'));
+ $element = $this->xpath('//label[@for=:for and contains(@class, "visually-hidden") and contains(text(), :value)]', [':for' => 'edit-field-unlimited-0-value', ':value' => $this->field['label'] . ' (value 1)']);
$this->assertTrue(isset($element[0]), 'Required symbol not added for field input.');
}
@@ -353,32 +353,32 @@ class FormTest extends FieldTestBase {
->save();
// Add a required radio field.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'required_radio_test',
'entity_type' => 'entity_test',
'type' => 'list_string',
- 'settings' => array(
- 'allowed_values' => array('yes' => 'yes', 'no' => 'no'),
- ),
- ))->save();
- $field = array(
+ 'settings' => [
+ 'allowed_values' => ['yes' => 'yes', 'no' => 'no'],
+ ],
+ ])->save();
+ $field = [
'field_name' => 'required_radio_test',
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'required' => TRUE,
- );
+ ];
FieldConfig::create($field)->save();
entity_get_form_display($field['entity_type'], $field['bundle'], 'default')
- ->setComponent($field['field_name'], array(
+ ->setComponent($field['field_name'], [
'type' => 'options_buttons',
- ))
+ ])
->save();
// Display creation form.
$this->drupalGet('entity_test/add');
// Press the 'Add more' button.
- $this->drupalPostForm(NULL, array(), t('Add another item'));
+ $this->drupalPostForm(NULL, [], t('Add another item'));
// Verify that no error is thrown by the radio element.
$this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, 'No error message is displayed.');
@@ -405,13 +405,13 @@ class FormTest extends FieldTestBase {
// Press 'add more' button a couple times -> 3 widgets.
// drupalPostAjaxForm() will not work iteratively, so we add those through
// non-JS submission.
- $this->drupalPostForm(NULL, array(), t('Add another item'));
- $this->drupalPostForm(NULL, array(), t('Add another item'));
+ $this->drupalPostForm(NULL, [], t('Add another item'));
+ $this->drupalPostForm(NULL, [], t('Add another item'));
// Prepare values and weights.
$count = 3;
$delta_range = $count - 1;
- $values = $weights = $pattern = $expected_values = $edit = array();
+ $values = $weights = $pattern = $expected_values = $edit = [];
for ($delta = 0; $delta <= $delta_range; $delta++) {
// Assign unique random values and weights.
do {
@@ -457,9 +457,9 @@ class FormTest extends FieldTestBase {
FieldStorageConfig::create($field_storage)->save();
FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'test_field_widget_multiple',
- ))
+ ])
->save();
// Display creation form.
@@ -467,27 +467,27 @@ class FormTest extends FieldTestBase {
$this->assertFieldByName($field_name, '', 'Widget is displayed.');
// Create entity with three values.
- $edit = array(
+ $edit = [
$field_name => '1, 2, 3',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
// Check that the values were saved.
$entity_init = EntityTest::load($id);
- $this->assertFieldValues($entity_init, $field_name, array(1, 2, 3));
+ $this->assertFieldValues($entity_init, $field_name, [1, 2, 3]);
// Display the form, check that the values are correctly filled in.
$this->drupalGet('entity_test/manage/' . $id . '/edit');
$this->assertFieldByName($field_name, '1, 2, 3', 'Widget is displayed.');
// Submit the form with more values than the field accepts.
- $edit = array($field_name => '1, 2, 3, 4, 5');
+ $edit = [$field_name => '1, 2, 3, 4, 5'];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertRaw('this field cannot hold more than 4 values', 'Form validation failed.');
// Check that the field values were not submitted.
- $this->assertFieldValues($entity_init, $field_name, array(1, 2, 3));
+ $this->assertFieldValues($entity_init, $field_name, [1, 2, 3]);
}
/**
@@ -511,18 +511,18 @@ class FormTest extends FieldTestBase {
// Create a field with no edit access. See
// field_test_entity_field_access().
- $field_storage_no_access = array(
+ $field_storage_no_access = [
'field_name' => 'field_no_edit_access',
'entity_type' => $entity_type,
'type' => 'test_field',
- );
+ ];
$field_name_no_access = $field_storage_no_access['field_name'];
- $field_no_access = array(
+ $field_no_access = [
'field_name' => $field_name_no_access,
'entity_type' => $entity_type,
'bundle' => $entity_type,
- 'default_value' => array(0 => array('value' => 99)),
- );
+ 'default_value' => [0 => ['value' => 99]],
+ ];
FieldStorageConfig::create($field_storage_no_access)->save();
FieldConfig::create($field_no_access)->save();
entity_get_form_display($field_no_access['entity_type'], $field_no_access['bundle'], 'default')
@@ -533,10 +533,10 @@ class FormTest extends FieldTestBase {
// apart from #access.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('id' => 0, 'revision_id' => 0));
+ ->create(['id' => 0, 'revision_id' => 0]);
$display = entity_get_form_display($entity_type, $entity_type, 'default');
- $form = array();
+ $form = [];
$form_state = new FormState();
$display->buildForm($entity, $form, $form_state);
@@ -547,9 +547,9 @@ class FormTest extends FieldTestBase {
$this->assertNoFieldByName("{$field_name_no_access}[0][value]", '', 'Widget is not displayed if field access is denied.');
// Create entity.
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match("|$entity_type/manage/(\d+)|", $this->url, $match);
$id = $match[1];
@@ -562,10 +562,10 @@ class FormTest extends FieldTestBase {
$this->assertEqual($entity->$field_name->value, 1, 'Entered value vas saved for the field with edit access.');
// Create a new revision.
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => 2,
'revision' => TRUE,
- );
+ ];
$this->drupalPostForm($entity_type . '/manage/' . $id . '/edit', $edit, t('Save'));
// Check that the new revision has the expected values.
@@ -591,7 +591,7 @@ class FormTest extends FieldTestBase {
$field_storage['entity_type'] = $entity_type;
$field_name = $field_storage['field_name'];
$this->field['field_name'] = $field_name;
- $this->field['default_value'] = array(0 => array('value' => 99));
+ $this->field['default_value'] = [0 => ['value' => 99]];
$this->field['entity_type'] = $entity_type;
$this->field['bundle'] = $entity_type;
FieldStorageConfig::create($field_storage)->save();
@@ -606,10 +606,10 @@ class FormTest extends FieldTestBase {
// Create an entity and test that the default value is assigned correctly to
// the field that uses the hidden widget.
$this->assertNoField("{$field_name}[0][value]", 'The field does not appear in the form');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
preg_match('|' . $entity_type . '/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test_rev @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test_rev @id has been created.', ['@id' => $id]), 'Entity was created');
$storage = $this->container->get('entity_type.manager')
->getStorage($entity_type);
@@ -618,12 +618,12 @@ class FormTest extends FieldTestBase {
// Update the field to remove the default value, and switch to the default
// widget.
- $this->field->setDefaultValue(array());
+ $this->field->setDefaultValue([]);
$this->field->save();
entity_get_form_display($entity_type, $this->field->getTargetBundle(), 'default')
- ->setComponent($this->field->getName(), array(
+ ->setComponent($this->field->getName(), [
'type' => 'test_field_widget',
- ))
+ ])
->save();
// Display edit form.
@@ -632,9 +632,9 @@ class FormTest extends FieldTestBase {
// Update the entity.
$value = mt_rand(1, 127);
- $edit = array("{$field_name}[0][value]" => $value);
+ $edit = ["{$field_name}[0][value]" => $value];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('entity_test_rev @id has been updated.', array('@id' => $id)), 'Entity was updated');
+ $this->assertText(t('entity_test_rev @id has been updated.', ['@id' => $id]), 'Entity was updated');
$storage->resetCache([$id]);
$entity = $storage->load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated');
@@ -645,11 +645,11 @@ class FormTest extends FieldTestBase {
->save();
// Create a new revision.
- $edit = array('revision' => TRUE);
+ $edit = ['revision' => TRUE];
$this->drupalPostForm($entity_type . '/manage/' . $id . '/edit', $edit, t('Save'));
// Check that the expected value has been carried over to the new revision.
- $storage->resetCache(array($id));
+ $storage->resetCache([$id]);
$entity = $storage->load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'New revision has the expected value for the field with the Hidden widget');
}
diff --git a/core/modules/field/src/Tests/NestedFormTest.php b/core/modules/field/src/Tests/NestedFormTest.php
index 8b3402d584f..530bb20f182 100644
--- a/core/modules/field/src/Tests/NestedFormTest.php
+++ b/core/modules/field/src/Tests/NestedFormTest.php
@@ -17,36 +17,36 @@ class NestedFormTest extends FieldTestBase {
*
* @var array
*/
- public static $modules = array('field_test', 'entity_test');
+ public static $modules = ['field_test', 'entity_test'];
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
+ $web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$this->drupalLogin($web_user);
- $this->fieldStorageSingle = array(
+ $this->fieldStorageSingle = [
'field_name' => 'field_single',
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
- $this->fieldStorageUnlimited = array(
+ ];
+ $this->fieldStorageUnlimited = [
'field_name' => 'field_unlimited',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- );
+ ];
- $this->field = array(
+ $this->field = [
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'label' => $this->randomMachineName() . '_label',
'description' => '[site:name]_description',
'weight' => mt_rand(0, 127),
- 'settings' => array(
+ 'settings' => [
'test_field_setting' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
}
/**
@@ -80,7 +80,7 @@ class NestedFormTest extends FieldTestBase {
$entity_1->field_unlimited->value = 1;
$entity_1->save();
- $entity_2 = $storage->create(array('id' => 2));
+ $entity_2 = $storage->create(['id' => 2]);
$entity_2->enforceIsNew();
$entity_2->field_single->value = 10;
$entity_2->field_unlimited->value = 11;
@@ -94,75 +94,75 @@ class NestedFormTest extends FieldTestBase {
$this->assertFieldByName('entity_2[field_unlimited][0][value]', 11, 'Entity 2: field_unlimited value 0 appears correctly is the form.');
// Submit the form and check that the entities are updated accordingly.
- $edit = array(
+ $edit = [
'field_single[0][value]' => 1,
'field_unlimited[0][value]' => 2,
'field_unlimited[1][value]' => 3,
'entity_2[field_single][0][value]' => 11,
'entity_2[field_unlimited][0][value]' => 12,
'entity_2[field_unlimited][1][value]' => 13,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$entity_1 = $storage->load(1);
$entity_2 = $storage->load(2);
- $this->assertFieldValues($entity_1, 'field_single', array(1));
- $this->assertFieldValues($entity_1, 'field_unlimited', array(2, 3));
- $this->assertFieldValues($entity_2, 'field_single', array(11));
- $this->assertFieldValues($entity_2, 'field_unlimited', array(12, 13));
+ $this->assertFieldValues($entity_1, 'field_single', [1]);
+ $this->assertFieldValues($entity_1, 'field_unlimited', [2, 3]);
+ $this->assertFieldValues($entity_2, 'field_single', [11]);
+ $this->assertFieldValues($entity_2, 'field_unlimited', [12, 13]);
// Submit invalid values and check that errors are reported on the
// correct widgets.
- $edit = array(
+ $edit = [
'field_unlimited[1][value]' => -1,
- );
+ ];
$this->drupalPostForm('test-entity/nested/1/2', $edit, t('Save'));
- $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), 'Entity 1: the field validation error was reported.');
- $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-field-unlimited-1-value'));
+ $this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']), 'Entity 1: the field validation error was reported.');
+ $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', [':id' => 'edit-field-unlimited-1-value']);
$this->assertTrue($error_field, 'Entity 1: the error was flagged on the correct element.');
- $edit = array(
+ $edit = [
'entity_2[field_unlimited][1][value]' => -1,
- );
+ ];
$this->drupalPostForm('test-entity/nested/1/2', $edit, t('Save'));
- $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), 'Entity 2: the field validation error was reported.');
- $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-entity-2-field-unlimited-1-value'));
+ $this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']), 'Entity 2: the field validation error was reported.');
+ $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', [':id' => 'edit-entity-2-field-unlimited-1-value']);
$this->assertTrue($error_field, 'Entity 2: the error was flagged on the correct element.');
// Test that reordering works on both entities.
- $edit = array(
+ $edit = [
'field_unlimited[0][_weight]' => 0,
'field_unlimited[1][_weight]' => -1,
'entity_2[field_unlimited][0][_weight]' => 0,
'entity_2[field_unlimited][1][_weight]' => -1,
- );
+ ];
$this->drupalPostForm('test-entity/nested/1/2', $edit, t('Save'));
- $this->assertFieldValues($entity_1, 'field_unlimited', array(3, 2));
- $this->assertFieldValues($entity_2, 'field_unlimited', array(13, 12));
+ $this->assertFieldValues($entity_1, 'field_unlimited', [3, 2]);
+ $this->assertFieldValues($entity_2, 'field_unlimited', [13, 12]);
// Test the 'add more' buttons. Only Ajax submission is tested, because
// the two 'add more' buttons present in the form have the same #value,
// which confuses drupalPostForm().
// 'Add more' button in the first entity:
$this->drupalGet('test-entity/nested/1/2');
- $this->drupalPostAjaxForm(NULL, array(), 'field_unlimited_add_more');
+ $this->drupalPostAjaxForm(NULL, [], 'field_unlimited_add_more');
$this->assertFieldByName('field_unlimited[0][value]', 3, 'Entity 1: field_unlimited value 0 appears correctly is the form.');
$this->assertFieldByName('field_unlimited[1][value]', 2, 'Entity 1: field_unlimited value 1 appears correctly is the form.');
$this->assertFieldByName('field_unlimited[2][value]', '', 'Entity 1: field_unlimited value 2 appears correctly is the form.');
$this->assertFieldByName('field_unlimited[3][value]', '', 'Entity 1: an empty widget was added for field_unlimited value 3.');
// 'Add more' button in the first entity (changing field values):
- $edit = array(
+ $edit = [
'entity_2[field_unlimited][0][value]' => 13,
'entity_2[field_unlimited][1][value]' => 14,
'entity_2[field_unlimited][2][value]' => 15,
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, 'entity_2_field_unlimited_add_more');
$this->assertFieldByName('entity_2[field_unlimited][0][value]', 13, 'Entity 2: field_unlimited value 0 appears correctly is the form.');
$this->assertFieldByName('entity_2[field_unlimited][1][value]', 14, 'Entity 2: field_unlimited value 1 appears correctly is the form.');
$this->assertFieldByName('entity_2[field_unlimited][2][value]', 15, 'Entity 2: field_unlimited value 2 appears correctly is the form.');
$this->assertFieldByName('entity_2[field_unlimited][3][value]', '', 'Entity 2: an empty widget was added for field_unlimited value 3.');
// Save the form and check values are saved correctly.
- $this->drupalPostForm(NULL, array(), t('Save'));
- $this->assertFieldValues($entity_1, 'field_unlimited', array(3, 2));
- $this->assertFieldValues($entity_2, 'field_unlimited', array(13, 14, 15));
+ $this->drupalPostForm(NULL, [], t('Save'));
+ $this->assertFieldValues($entity_1, 'field_unlimited', [3, 2]);
+ $this->assertFieldValues($entity_2, 'field_unlimited', [13, 14, 15]);
}
/**
diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php
index 14777ec3424..3fea6166b2f 100644
--- a/core/modules/field/src/Tests/Number/NumberFieldTest.php
+++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php
@@ -20,11 +20,11 @@ class NumberFieldTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'entity_test', 'field_ui');
+ public static $modules = ['node', 'entity_test', 'field_ui'];
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array(
+ $this->drupalLogin($this->drupalCreateUser([
'view test entity',
'administer entity_test content',
'administer content types',
@@ -32,7 +32,7 @@ class NumberFieldTest extends WebTestBase {
'administer node display',
'bypass node access',
'administer entity_test fields',
- )));
+ ]));
}
/**
@@ -41,14 +41,14 @@ class NumberFieldTest extends WebTestBase {
function testNumberDecimalField() {
// Create a field with settings to validate.
$field_name = Unicode::strtolower($this->randomMachineName());
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'decimal',
- 'settings' => array(
+ 'settings' => [
'precision' => 8, 'scale' => 4,
- )
- ))->save();
+ ]
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
@@ -56,17 +56,17 @@ class NumberFieldTest extends WebTestBase {
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'number',
- 'settings' => array(
+ 'settings' => [
'placeholder' => '0.00'
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'number_decimal',
- ))
+ ])
->save();
// Display creation form.
@@ -76,49 +76,49 @@ class NumberFieldTest extends WebTestBase {
// Submit a signed decimal value within the allowed precision and scale.
$value = '-1234.5678';
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
$this->assertRaw($value, 'Value is displayed.');
// Try to create entries with more than one decimal separator; assert fail.
- $wrong_entries = array(
+ $wrong_entries = [
'3.14.159',
'0..45469',
'..4589',
'6.459.52',
'6.3..25',
- );
+ ];
foreach ($wrong_entries as $wrong_entry) {
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $wrong_entry,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save decimal value with more than one decimal point.');
+ $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save decimal value with more than one decimal point.');
}
// Try to create entries with minus sign not in the first position.
- $wrong_entries = array(
+ $wrong_entries = [
'3-3',
'4-',
'1.3-',
'1.2-4',
'-10-10',
- );
+ ];
foreach ($wrong_entries as $wrong_entry) {
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $wrong_entry,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save decimal value with minus sign in the wrong position.');
+ $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save decimal value with minus sign in the wrong position.');
}
}
@@ -131,52 +131,52 @@ class NumberFieldTest extends WebTestBase {
// Create a field with settings to validate.
$field_name = Unicode::strtolower($this->randomMachineName());
- $storage = FieldStorageConfig::create(array(
+ $storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'integer',
- ));
+ ]);
$storage->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- 'settings' => array(
+ 'settings' => [
'min' => $minimum, 'max' => $maximum, 'prefix' => 'ThePrefix',
- )
+ ]
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'number',
- 'settings' => array(
+ 'settings' => [
'placeholder' => '4'
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'number_integer',
- 'settings' => array(
+ 'settings' => [
'prefix_suffix' => FALSE,
- ),
- ))
+ ],
+ ])
->save();
// Check the storage schema.
- $expected = array(
- 'columns' => array(
- 'value' => array(
+ $expected = [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
'unsigned' => '',
'size' => 'normal'
- ),
- ),
- 'unique keys' => array(),
- 'indexes' => array(),
- 'foreign keys' => array()
- );
+ ],
+ ],
+ 'unique keys' => [],
+ 'indexes' => [],
+ 'foreign keys' => []
+ ];
$this->assertEqual($storage->getSchema(), $expected);
// Display creation form.
@@ -186,84 +186,84 @@ class NumberFieldTest extends WebTestBase {
// Submit a valid integer
$value = rand($minimum, $maximum);
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
// Try to set a value below the minimum value
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $minimum - 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name must be higher than or equal to %minimum.', array('%name' => $field_name, '%minimum' => $minimum)), 'Correctly failed to save integer value less than minimum allowed value.');
+ $this->assertRaw(t('%name must be higher than or equal to %minimum.', ['%name' => $field_name, '%minimum' => $minimum]), 'Correctly failed to save integer value less than minimum allowed value.');
// Try to set a decimal value
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => 1.5,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name is not a valid number.', array('%name' => $field_name)), 'Correctly failed to save decimal value to integer field.');
+ $this->assertRaw(t('%name is not a valid number.', ['%name' => $field_name]), 'Correctly failed to save decimal value to integer field.');
// Try to set a value above the maximum value
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $maximum + 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name must be lower than or equal to %maximum.', array('%name' => $field_name, '%maximum' => $maximum)), 'Correctly failed to save integer value greater than maximum allowed value.');
+ $this->assertRaw(t('%name must be lower than or equal to %maximum.', ['%name' => $field_name, '%maximum' => $maximum]), 'Correctly failed to save integer value greater than maximum allowed value.');
// Try to set a wrong integer value.
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => '20-40',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save wrong integer value.');
+ $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save wrong integer value.');
// Test with valid entries.
- $valid_entries = array(
+ $valid_entries = [
'-1234',
'0',
'1234',
- );
+ ];
foreach ($valid_entries as $valid_entry) {
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $valid_entry,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
$this->assertRaw($valid_entry, 'Value is displayed.');
$this->assertNoFieldByXpath('//div[@content="' . $valid_entry . '"]', NULL, 'The "content" attribute is not present since the Prefix is not being displayed');
}
// Test for the content attribute when a Prefix is displayed. Presumably this also tests for the attribute when a Suffix is displayed.
entity_get_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'number_integer',
- 'settings' => array(
+ 'settings' => [
'prefix_suffix' => TRUE,
- ),
- ))
+ ],
+ ])
->save();
$integer_value = '123';
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $integer_value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
$this->drupalGet('entity_test/' . $id);
$this->assertFieldByXPath('//div[@content="' . $integer_value . '"]', 'ThePrefix' . $integer_value, 'The "content" attribute has been set to the value of the field, and the prefix is being displayed.');
}
@@ -274,11 +274,11 @@ class NumberFieldTest extends WebTestBase {
function testNumberFloatField() {
// Create a field with settings to validate.
$field_name = Unicode::strtolower($this->randomMachineName());
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'float',
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
@@ -287,18 +287,18 @@ class NumberFieldTest extends WebTestBase {
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'number',
- 'settings' => array(
+ 'settings' => [
'placeholder' => '0.00'
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'number_decimal',
- ))
+ ])
->save();
// Display creation form.
@@ -308,13 +308,13 @@ class NumberFieldTest extends WebTestBase {
// Submit a signed decimal value within the allowed precision and scale.
$value = '-1234.5678';
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
// Ensure that the 'number_decimal' formatter displays the number with the
// expected rounding.
@@ -322,39 +322,39 @@ class NumberFieldTest extends WebTestBase {
$this->assertRaw(round($value, 2));
// Try to create entries with more than one decimal separator; assert fail.
- $wrong_entries = array(
+ $wrong_entries = [
'3.14.159',
'0..45469',
'..4589',
'6.459.52',
'6.3..25',
- );
+ ];
foreach ($wrong_entries as $wrong_entry) {
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $wrong_entry,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save float value with more than one decimal point.');
+ $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save float value with more than one decimal point.');
}
// Try to create entries with minus sign not in the first position.
- $wrong_entries = array(
+ $wrong_entries = [
'3-3',
'4-',
'1.3-',
'1.2-4',
'-10-10',
- );
+ ];
foreach ($wrong_entries as $wrong_entry) {
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $wrong_entry,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save float value with minus sign in the wrong position.');
+ $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save float value with minus sign in the wrong position.');
}
}
@@ -365,70 +365,70 @@ class NumberFieldTest extends WebTestBase {
$type = Unicode::strtolower($this->randomMachineName());
$float_field = Unicode::strtolower($this->randomMachineName());
$integer_field = Unicode::strtolower($this->randomMachineName());
- $thousand_separators = array('', '.', ',', ' ', chr(8201), "'");
- $decimal_separators = array('.', ',');
+ $thousand_separators = ['', '.', ',', ' ', chr(8201), "'"];
+ $decimal_separators = ['.', ','];
$prefix = $this->randomMachineName();
$suffix = $this->randomMachineName();
$random_float = rand(0, pow(10, 6));
$random_integer = rand(0, pow(10, 6));
// Create a content type containing float and integer fields.
- $this->drupalCreateContentType(array('type' => $type));
+ $this->drupalCreateContentType(['type' => $type]);
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $float_field,
'entity_type' => 'node',
'type' => 'float',
- ))->save();
+ ])->save();
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $integer_field,
'entity_type' => 'node',
'type' => 'integer',
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $float_field,
'entity_type' => 'node',
'bundle' => $type,
- 'settings' => array(
+ 'settings' => [
'prefix' => $prefix,
'suffix' => $suffix
- ),
+ ],
])->save();
FieldConfig::create([
'field_name' => $integer_field,
'entity_type' => 'node',
'bundle' => $type,
- 'settings' => array(
+ 'settings' => [
'prefix' => $prefix,
'suffix' => $suffix
- ),
+ ],
])->save();
entity_get_form_display('node', $type, 'default')
- ->setComponent($float_field, array(
+ ->setComponent($float_field, [
'type' => 'number',
- 'settings' => array(
+ 'settings' => [
'placeholder' => '0.00'
- ),
- ))
- ->setComponent($integer_field, array(
+ ],
+ ])
+ ->setComponent($integer_field, [
'type' => 'number',
- 'settings' => array(
+ 'settings' => [
'placeholder' => '0.00'
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('node', $type, 'default')
- ->setComponent($float_field, array(
+ ->setComponent($float_field, [
'type' => 'number_decimal',
- ))
- ->setComponent($integer_field, array(
+ ])
+ ->setComponent($integer_field, [
'type' => 'number_unformatted',
- ))
+ ])
->save();
// Create a node to test formatters.
@@ -448,15 +448,15 @@ class NumberFieldTest extends WebTestBase {
$decimal_separator = $decimal_separators[array_rand($decimal_separators)];
$scale = rand(0, 10);
- $this->drupalPostAjaxForm(NULL, array(), "${float_field}_settings_edit");
- $edit = array(
+ $this->drupalPostAjaxForm(NULL, [], "${float_field}_settings_edit");
+ $edit = [
"fields[${float_field}][settings_edit_form][settings][prefix_suffix]" => TRUE,
"fields[${float_field}][settings_edit_form][settings][scale]" => $scale,
"fields[${float_field}][settings_edit_form][settings][decimal_separator]" => $decimal_separator,
"fields[${float_field}][settings_edit_form][settings][thousand_separator]" => $thousand_separator,
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, "${float_field}_plugin_settings_update");
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Check number_decimal and number_unformatted formatters behavior.
$this->drupalGet('node/' . $node->id());
@@ -466,21 +466,21 @@ class NumberFieldTest extends WebTestBase {
// Configure the number_decimal formatter.
entity_get_display('node', $type, 'default')
- ->setComponent($integer_field, array(
+ ->setComponent($integer_field, [
'type' => 'number_integer',
- ))
+ ])
->save();
$this->drupalGet("admin/structure/types/manage/$type/display");
$thousand_separator = $thousand_separators[array_rand($thousand_separators)];
- $this->drupalPostAjaxForm(NULL, array(), "${integer_field}_settings_edit");
- $edit = array(
+ $this->drupalPostAjaxForm(NULL, [], "${integer_field}_settings_edit");
+ $edit = [
"fields[${integer_field}][settings_edit_form][settings][prefix_suffix]" => FALSE,
"fields[${integer_field}][settings_edit_form][settings][thousand_separator]" => $thousand_separator,
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, "${integer_field}_plugin_settings_update");
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Check number_integer formatter behavior.
$this->drupalGet('node/' . $node->id());
@@ -495,11 +495,11 @@ class NumberFieldTest extends WebTestBase {
function testCreateNumberFloatField() {
// Create a float field.
$field_name = Unicode::strtolower($this->randomMachineName());
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'float',
- ))->save();
+ ])->save();
$field = FieldConfig::create([
'field_name' => $field_name,
@@ -520,11 +520,11 @@ class NumberFieldTest extends WebTestBase {
function testCreateNumberDecimalField() {
// Create a decimal field.
$field_name = Unicode::strtolower($this->randomMachineName());
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'decimal',
- ))->save();
+ ])->save();
$field = FieldConfig::create([
'field_name' => $field_name,
@@ -546,14 +546,14 @@ class NumberFieldTest extends WebTestBase {
$field_configuration_url = 'entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field->getName();
// Set the minimum value.
- $edit = array(
+ $edit = [
'settings[min]' => $minimum_value,
- );
+ ];
$this->drupalPostForm($field_configuration_url, $edit, t('Save settings'));
// Check if an error message is shown.
- $this->assertNoRaw(t('%name is not a valid number.', array('%name' => t('Minimum'))), 'Saved ' . gettype($minimum_value) . ' value as minimal value on a ' . $field->getType() . ' field');
+ $this->assertNoRaw(t('%name is not a valid number.', ['%name' => t('Minimum')]), 'Saved ' . gettype($minimum_value) . ' value as minimal value on a ' . $field->getType() . ' field');
// Check if a success message is shown.
- $this->assertRaw(t('Saved %label configuration.', array('%label' => $field->getLabel())));
+ $this->assertRaw(t('Saved %label configuration.', ['%label' => $field->getLabel()]));
// Check if the minimum value was actually set.
$this->drupalGet($field_configuration_url);
$this->assertFieldById('edit-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) . ' value was set on a ' . $field->getType() . ' field.');
diff --git a/core/modules/field/src/Tests/String/StringFieldTest.php b/core/modules/field/src/Tests/String/StringFieldTest.php
index 0ac57487759..6bd034d6130 100644
--- a/core/modules/field/src/Tests/String/StringFieldTest.php
+++ b/core/modules/field/src/Tests/String/StringFieldTest.php
@@ -20,7 +20,7 @@ class StringFieldTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('entity_test', 'file');
+ public static $modules = ['entity_test', 'file'];
/**
* A user without any special permissions.
@@ -32,7 +32,7 @@ class StringFieldTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->webUser = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
+ $this->webUser = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$this->drupalLogin($this->webUser);
}
@@ -52,11 +52,11 @@ class StringFieldTest extends WebTestBase {
function _testTextfieldWidgets($field_type, $widget_type) {
// Create a field.
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $field_type
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -64,12 +64,12 @@ class StringFieldTest extends WebTestBase {
'label' => $this->randomMachineName() . '_label',
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => $widget_type,
- 'settings' => array(
+ 'settings' => [
'placeholder' => 'A placeholder on ' . $widget_type,
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent($field_name)
@@ -79,17 +79,17 @@ class StringFieldTest extends WebTestBase {
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
$this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
- $this->assertRaw(format_string('placeholder="A placeholder on @widget_type"', array('@widget_type' => $widget_type)));
+ $this->assertRaw(format_string('placeholder="A placeholder on @widget_type"', ['@widget_type' => $widget_type]));
// Submit with some value.
$value = $this->randomMachineName();
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
// Display the entity.
$entity = EntityTest::load($id);
diff --git a/core/modules/field/src/Tests/Views/FieldTestBase.php b/core/modules/field/src/Tests/Views/FieldTestBase.php
index 0f977a82c73..cd579943757 100644
--- a/core/modules/field/src/Tests/Views/FieldTestBase.php
+++ b/core/modules/field/src/Tests/Views/FieldTestBase.php
@@ -25,7 +25,7 @@ abstract class FieldTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_test_views');
+ public static $modules = ['node', 'field_test_views'];
/**
* Stores the field definitions used by the test.
@@ -51,19 +51,19 @@ abstract class FieldTestBase extends ViewTestBase {
'name' => 'page',
])->save();
- ViewTestData::createTestViews(get_class($this), array('field_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['field_test_views']);
}
function setUpFieldStorages($amount = 3, $type = 'string') {
// Create three fields.
- $field_names = array();
+ $field_names = [];
for ($i = 0; $i < $amount; $i++) {
$field_names[$i] = 'field_name_' . $i;
- $this->fieldStorages[$i] = FieldStorageConfig::create(array(
+ $this->fieldStorages[$i] = FieldStorageConfig::create([
'field_name' => $field_names[$i],
'entity_type' => 'node',
'type' => $type,
- ));
+ ]);
$this->fieldStorages[$i]->save();
}
return $field_names;
diff --git a/core/modules/field/src/Tests/Views/FieldUITest.php b/core/modules/field/src/Tests/Views/FieldUITest.php
index c47bf1962fe..ce8208ba65d 100644
--- a/core/modules/field/src/Tests/Views/FieldUITest.php
+++ b/core/modules/field/src/Tests/Views/FieldUITest.php
@@ -19,14 +19,14 @@ class FieldUITest extends FieldTestBase {
*
* @var array
*/
- public static $testViews = array('test_view_fieldapi');
+ public static $testViews = ['test_view_fieldapi'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('views_ui');
+ public static $modules = ['views_ui'];
/**
* A user with the 'administer views' permission.
@@ -41,7 +41,7 @@ class FieldUITest extends FieldTestBase {
protected function setUp() {
parent::setUp();
- $this->account = $this->drupalCreateUser(array('administer views'));
+ $this->account = $this->drupalCreateUser(['administer views']);
$this->drupalLogin($this->account);
$this->setUpFieldStorages(1, 'text');
@@ -56,26 +56,26 @@ class FieldUITest extends FieldTestBase {
$this->drupalGet($url);
// Tests the available formatter options.
- $result = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-options-type'));
+ $result = $this->xpath('//select[@id=:id]/option', [':id' => 'edit-options-type']);
$options = array_map(function($item) {
return (string) $item->attributes()->value[0];
}, $result);
// @todo Replace this sort by assertArray once it's in.
sort($options, SORT_STRING);
- $this->assertEqual($options, array('text_default', 'text_trimmed'), 'The text formatters for a simple text field appear as expected.');
+ $this->assertEqual($options, ['text_default', 'text_trimmed'], 'The text formatters for a simple text field appear as expected.');
- $this->drupalPostForm(NULL, array('options[type]' => 'text_trimmed'), t('Apply'));
+ $this->drupalPostForm(NULL, ['options[type]' => 'text_trimmed'], t('Apply'));
$this->drupalGet($url);
$this->assertOptionSelected('edit-options-type', 'text_trimmed');
$random_number = rand(100, 400);
- $this->drupalPostForm(NULL, array('options[settings][trim_length]' => $random_number), t('Apply'));
+ $this->drupalPostForm(NULL, ['options[settings][trim_length]' => $random_number], t('Apply'));
$this->drupalGet($url);
$this->assertFieldByName('options[settings][trim_length]', $random_number, 'The formatter setting got saved.');
// Save the view and test whether the settings are saved.
- $this->drupalPostForm('admin/structure/views/view/test_view_fieldapi', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/view/test_view_fieldapi', [], t('Save'));
$view = Views::getView('test_view_fieldapi');
$view->initHandlers();
$this->assertEqual($view->field['field_name_0']->options['type'], 'text_trimmed');
@@ -101,7 +101,7 @@ class FieldUITest extends FieldTestBase {
*/
public function testHandlerUIAggregation() {
// Enable aggregation.
- $edit = array('group_by' => '1');
+ $edit = ['group_by' => '1'];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view_fieldapi/default/group_by', $edit, t('Apply'));
$url = "admin/structure/views/nojs/handler/test_view_fieldapi/default/field/field_name_0";
@@ -110,13 +110,13 @@ class FieldUITest extends FieldTestBase {
// Test the click sort column options.
// Tests the available formatter options.
- $result = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-options-click-sort-column'));
+ $result = $this->xpath('//select[@id=:id]/option', [':id' => 'edit-options-click-sort-column']);
$options = array_map(function($item) {
return (string) $item->attributes()->value[0];
}, $result);
sort($options, SORT_STRING);
- $this->assertEqual($options, array('format', 'value'), 'The expected sort field options were found.');
+ $this->assertEqual($options, ['format', 'value'], 'The expected sort field options were found.');
}
/**
@@ -138,7 +138,7 @@ class FieldUITest extends FieldTestBase {
$field->save();
$url = "admin/structure/views/nojs/add-handler/test_view_fieldapi/default/filter";
- $this->drupalPostForm($url, ['name[node__' . $field_name . '.' . $field_name . '_value]' => TRUE], t('Add and configure @handler', array('@handler' => t('filter criteria'))));
+ $this->drupalPostForm($url, ['name[node__' . $field_name . '.' . $field_name . '_value]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
$this->assertResponse(200);
// Verify that using a boolean field as a filter also results in using the
// boolean plugin.
diff --git a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
index 303eb2fd7e1..dfbb89bd209 100644
--- a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
+++ b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
@@ -22,14 +22,14 @@ class HandlerFieldFieldTest extends FieldTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('node', 'field_test');
+ public static $modules = ['node', 'field_test'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view_fieldapi');
+ public static $testViews = ['test_view_fieldapi'];
/**
* Test nodes.
@@ -48,47 +48,47 @@ class HandlerFieldFieldTest extends FieldTestBase {
$this->setUpFieldStorages(3);
// Setup a field with cardinality > 1.
- $this->fieldStorages[3] = FieldStorageConfig::create(array(
+ $this->fieldStorages[3] = FieldStorageConfig::create([
'field_name' => 'field_name_3',
'entity_type' => 'node',
'type' => 'string',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ));
+ ]);
$this->fieldStorages[3]->save();
// Setup a field that will have no value.
- $this->fieldStorages[4] = FieldStorageConfig::create(array(
+ $this->fieldStorages[4] = FieldStorageConfig::create([
'field_name' => 'field_name_4',
'entity_type' => 'node',
'type' => 'string',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ));
+ ]);
$this->fieldStorages[4]->save();
// Setup a text field.
- $this->fieldStorages[5] = FieldStorageConfig::create(array(
+ $this->fieldStorages[5] = FieldStorageConfig::create([
'field_name' => 'field_name_5',
'entity_type' => 'node',
'type' => 'text',
- ));
+ ]);
$this->fieldStorages[5]->save();
// Setup a text field with access control.
// @see field_test_entity_field_access()
- $this->fieldStorages[6] = FieldStorageConfig::create(array(
+ $this->fieldStorages[6] = FieldStorageConfig::create([
'field_name' => 'field_no_view_access',
'entity_type' => 'node',
'type' => 'text',
- ));
+ ]);
$this->fieldStorages[6]->save();
$this->setUpFields();
// Create some nodes.
- $this->nodes = array();
+ $this->nodes = [];
for ($i = 0; $i < 3; $i++) {
- $edit = array('type' => 'page');
+ $edit = ['type' => 'page'];
- foreach (array(0, 1, 2, 5) as $key) {
+ foreach ([0, 1, 2, 5] as $key) {
$field_storage = $this->fieldStorages[$key];
$edit[$field_storage->getName()][0]['value'] = $this->randomMachineName(8);
}
@@ -98,7 +98,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
$edit[$this->fieldStorages[3]->getName()][$j]['value'] = $this->randomMachineName(8);
}
// Set this field to be empty.
- $edit[$this->fieldStorages[4]->getName()] = array(array('value' => NULL));
+ $edit[$this->fieldStorages[4]->getName()] = [['value' => NULL]];
$this->nodes[$i] = $this->drupalCreateNode($edit);
}
@@ -171,9 +171,9 @@ class HandlerFieldFieldTest extends FieldTestBase {
$view = Views::getView('test_view_fieldapi');
$this->prepareView($view);
$view->displayHandlers->get('default')->options['fields'][$this->fieldStorages[5]->getName()]['type'] = 'text_trimmed';
- $view->displayHandlers->get('default')->options['fields'][$this->fieldStorages[5]->getName()]['settings'] = array(
+ $view->displayHandlers->get('default')->options['fields'][$this->fieldStorages[5]->getName()]['settings'] = [
'trim_length' => 3,
- );
+ ];
$this->executeView($view);
// Make sure that the formatter works as expected.
@@ -196,7 +196,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->getField($i, $field_name);
- $items = array();
+ $items = [];
$pure_items = $this->nodes[$i]->{$field_name}->getValue();
$pure_items = array_splice($pure_items, 0, 3);
foreach ($pure_items as $j => $item) {
@@ -218,7 +218,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->getField($i, $field_name);
- $items = array();
+ $items = [];
$pure_items = $this->nodes[$i]->{$field_name}->getValue();
$pure_items = array_splice($pure_items, 1, 3);
foreach ($pure_items as $j => $item) {
@@ -238,7 +238,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->getField($i, $field_name);
- $items = array();
+ $items = [];
$pure_items = $this->nodes[$i]->{$field_name}->getValue();
array_splice($pure_items, 0, -3);
$pure_items = array_reverse($pure_items);
@@ -259,7 +259,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->getField($i, $field_name);
- $items = array();
+ $items = [];
$pure_items = $this->nodes[$i]->{$field_name}->getValue();
$items[] = $pure_items[0]['value'];
$items[] = $pure_items[4]['value'];
@@ -277,7 +277,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->getField($i, $field_name);
- $items = array();
+ $items = [];
$pure_items = $this->nodes[$i]->{$field_name}->getValue();
$pure_items = array_splice($pure_items, 0, 3);
foreach ($pure_items as $j => $item) {
diff --git a/core/modules/field/src/Tests/reEnableModuleFieldTest.php b/core/modules/field/src/Tests/reEnableModuleFieldTest.php
index b718e75883c..141b5e12bad 100644
--- a/core/modules/field/src/Tests/reEnableModuleFieldTest.php
+++ b/core/modules/field/src/Tests/reEnableModuleFieldTest.php
@@ -18,22 +18,22 @@ class reEnableModuleFieldTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'field',
'node',
// We use telephone module instead of test_field because test_field is
// hidden and does not display on the admin/modules page.
'telephone'
- );
+ ];
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'article'));
- $this->drupalLogin($this->drupalCreateUser(array(
+ $this->drupalCreateContentType(['type' => 'article']);
+ $this->drupalLogin($this->drupalCreateUser([
'create article content',
'edit own article content',
- )));
+ ]));
}
/**
@@ -44,11 +44,11 @@ class reEnableModuleFieldTest extends WebTestBase {
function testReEnabledField() {
// Add a telephone field to the article content type.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_telephone',
'entity_type' => 'node',
'type' => 'telephone',
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -57,19 +57,19 @@ class reEnableModuleFieldTest extends WebTestBase {
])->save();
entity_get_form_display('node', 'article', 'default')
- ->setComponent('field_telephone', array(
+ ->setComponent('field_telephone', [
'type' => 'telephone_default',
- 'settings' => array(
+ 'settings' => [
'placeholder' => '123-456-7890',
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent('field_telephone', array(
+ ->setComponent('field_telephone', [
'type' => 'telephone_link',
'weight' => 1,
- ))
+ ])
->save();
// Display the article node form and verify the telephone widget is present.
@@ -78,16 +78,16 @@ class reEnableModuleFieldTest extends WebTestBase {
// Submit an article node with a telephone field so data exist for the
// field.
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
'field_telephone[0][value]' => "123456789",
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertRaw('<a href="tel:123456789">');
// Test that the module can't be uninstalled from the UI while there is data
// for it's fields.
- $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
+ $admin_user = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/modules/uninstall');
$this->assertText("The Telephone number field type is used in the following field: node.field_telephone");
@@ -95,11 +95,11 @@ class reEnableModuleFieldTest extends WebTestBase {
// Add another telephone field to a different entity type in order to test
// the message for the case when multiple fields are blocking the
// uninstallation of a module.
- $field_storage2 = entity_create('field_storage_config', array(
+ $field_storage2 = entity_create('field_storage_config', [
'field_name' => 'field_telephone_2',
'entity_type' => 'user',
'type' => 'telephone',
- ));
+ ]);
$field_storage2->save();
FieldConfig::create([
'field_storage' => $field_storage2,
diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc
index d5614acd8ea..ee831ff2b60 100644
--- a/core/modules/field/tests/modules/field_test/field_test.entity.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc
@@ -19,7 +19,7 @@ function field_test_entity_type_alter(array &$entity_types) {
* Helper function to enable entity translations.
*/
function field_test_entity_info_translatable($entity_type_id = NULL, $translatable = NULL) {
- $stored_value = &drupal_static(__FUNCTION__, array());
+ $stored_value = &drupal_static(__FUNCTION__, []);
if (isset($entity_type_id)) {
$entity_manager = \Drupal::entityManager();
$original = $entity_manager->getDefinition($entity_type_id);
diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc
index 9798fc745ac..5edd25d7636 100644
--- a/core/modules/field/tests/modules/field_test/field_test.field.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.field.inc
@@ -34,7 +34,7 @@ function field_test_field_storage_config_update_forbid(FieldStorageConfigInterfa
* Sample 'default value' callback.
*/
function field_test_default_value(FieldableEntityInterface $entity, FieldDefinitionInterface $definition) {
- return array(array('value' => 99));
+ return [['value' => 99]];
}
/**
diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module
index 7eda2885272..f81983637fb 100644
--- a/core/modules/field/tests/modules/field_test/field_test.module
+++ b/core/modules/field/tests/modules/field_test/field_test.module
@@ -66,7 +66,7 @@ function field_test_memorize($key = NULL, $value = NULL) {
if (!isset($key)) {
$return = $memorize;
- $memorize = array();
+ $memorize = [];
return $return;
}
if (is_array($memorize)) {
@@ -88,11 +88,11 @@ function field_test_field_storage_config_create(FieldStorageConfigInterface $fie
function field_test_entity_display_build_alter(&$output, $context) {
$display_options = $context['display']->getComponent('test_field');
if (isset($display_options['settings']['alter'])) {
- $output['test_field'][] = array('#markup' => 'field_test_entity_display_build_alter');
+ $output['test_field'][] = ['#markup' => 'field_test_entity_display_build_alter'];
}
if (isset($output['test_field'])) {
- $output['test_field'][] = array('#markup' => 'entity language is ' . $context['entity']->language()->getId());
+ $output['test_field'][] = ['#markup' => 'entity language is ' . $context['entity']->language()->getId()];
}
}
diff --git a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php
index d54c6836fdf..949ffda667d 100644
--- a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php
+++ b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php
@@ -54,11 +54,11 @@ class NestedEntityTestForm extends FormBase {
];
}
- $form['save'] = array(
+ $form['save'] = [
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 100,
- );
+ ];
return $form;
}
@@ -101,7 +101,7 @@ class NestedEntityTestForm extends FormBase {
$entity_2 = $form_state->get('entity_2');
$entity_2->save();
- drupal_set_message($this->t('test_entities @id_1 and @id_2 have been updated.', array('@id_1' => $entity_1->id(), '@id_2' => $entity_2->id())));
+ drupal_set_message($this->t('test_entities @id_1 and @id_2 have been updated.', ['@id_1' => $entity_1->id(), '@id_2' => $entity_2->id()]));
}
}
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php
index c2916f5d68c..418b4c6b245 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php
@@ -34,7 +34,7 @@ class TestFieldApplicableFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- return array('#markup' => 'Nothing to see here');
+ return ['#markup' => 'Nothing to see here'];
}
}
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php
index 5eb0354aefe..80f860bfafd 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php
@@ -26,22 +26,22 @@ class TestFieldDefaultFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'test_formatter_setting' => 'dummy test string',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['test_formatter_setting'] = array(
+ $element['test_formatter_setting'] = [
'#title' => t('Setting'),
'#type' => 'textfield',
'#size' => 20,
'#default_value' => $this->getSetting('test_formatter_setting'),
'#required' => TRUE,
- );
+ ];
return $element;
}
@@ -49,8 +49,8 @@ class TestFieldDefaultFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
- $summary[] = t('@setting: @value', array('@setting' => 'test_formatter_setting', '@value' => $this->getSetting('test_formatter_setting')));
+ $summary = [];
+ $summary[] = t('@setting: @value', ['@setting' => 'test_formatter_setting', '@value' => $this->getSetting('test_formatter_setting')]);
return $summary;
}
@@ -58,10 +58,10 @@ class TestFieldDefaultFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
- $elements[$delta] = array('#markup' => $this->getSetting('test_formatter_setting') . '|' . $item->value);
+ $elements[$delta] = ['#markup' => $this->getSetting('test_formatter_setting') . '|' . $item->value];
}
return $elements;
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php
index bbe0b308119..c8072177f16 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php
@@ -23,25 +23,25 @@ class TestFieldEmptyFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'test_empty_string' => '**EMPTY FIELD**',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
if ($items->isEmpty()) {
// For fields with no value, just add the configured "empty" value.
- $elements[0] = array('#markup' => $this->getSetting('test_empty_string'));
+ $elements[0] = ['#markup' => $this->getSetting('test_empty_string')];
}
else {
foreach ($items as $delta => $item) {
// This formatter only needs to output raw for testing.
- $elements[$delta] = array('#markup' => $item->value);
+ $elements[$delta] = ['#markup' => $item->value];
}
}
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php
index ca088610835..f36fea2c391 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php
@@ -24,22 +24,22 @@ class TestFieldEmptySettingFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'field_empty_setting' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['field_empty_setting'] = array(
+ $element['field_empty_setting'] = [
'#title' => t('Setting'),
'#type' => 'textfield',
'#size' => 20,
'#default_value' => $this->getSetting('field_empty_setting'),
'#required' => TRUE,
- );
+ ];
return $element;
}
@@ -47,7 +47,7 @@ class TestFieldEmptySettingFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$setting = $this->getSetting('field_empty_setting');
if (!empty($setting)) {
$summary[] = t('Default empty setting now has a value.');
@@ -59,11 +59,11 @@ class TestFieldEmptySettingFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
if (!empty($items)) {
foreach ($items as $delta => $item) {
- $elements[$delta] = array('#markup' => $this->getSetting('field_empty_setting'));
+ $elements[$delta] = ['#markup' => $this->getSetting('field_empty_setting')];
}
}
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php
index 97bb1e63622..978e18fbac6 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php
@@ -26,23 +26,23 @@ class TestFieldMultipleFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'test_formatter_setting_multiple' => 'dummy test string',
'alter' => FALSE,
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['test_formatter_setting_multiple'] = array(
+ $element['test_formatter_setting_multiple'] = [
'#title' => t('Setting'),
'#type' => 'textfield',
'#size' => 20,
'#default_value' => $this->getSetting('test_formatter_setting_multiple'),
'#required' => TRUE,
- );
+ ];
return $element;
}
@@ -50,8 +50,8 @@ class TestFieldMultipleFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
- $summary[] = t('@setting: @value', array('@setting' => 'test_formatter_setting_multiple', '@value' => $this->getSetting('test_formatter_setting_multiple')));
+ $summary = [];
+ $summary[] = t('@setting: @value', ['@setting' => 'test_formatter_setting_multiple', '@value' => $this->getSetting('test_formatter_setting_multiple')]);
return $summary;
}
@@ -59,14 +59,14 @@ class TestFieldMultipleFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
if (!empty($items)) {
- $array = array();
+ $array = [];
foreach ($items as $delta => $item) {
$array[] = $delta . ':' . $item->value;
}
- $elements[0] = array('#markup' => $this->getSetting('test_formatter_setting_multiple') . '|' . implode('|', $array));
+ $elements[0] = ['#markup' => $this->getSetting('test_formatter_setting_multiple') . '|' . implode('|', $array)];
}
return $elements;
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php
index 0ab66d5dd25..922207e51bd 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php
@@ -23,11 +23,11 @@ class TestFieldNoSettingsFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
// This formatter only needs to output raw for testing.
- $elements[$delta] = array('#markup' => $item->value);
+ $elements[$delta] = ['#markup' => $item->value];
}
return $elements;
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php
index f7df0c0c2f0..39bff8d8773 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php
@@ -25,22 +25,22 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'test_formatter_setting_additional' => 'dummy test string',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['test_formatter_setting_additional'] = array(
+ $element['test_formatter_setting_additional'] = [
'#title' => t('Setting'),
'#type' => 'textfield',
'#size' => 20,
'#default_value' => $this->getSetting('test_formatter_setting_additional'),
'#required' => TRUE,
- );
+ ];
return $element;
}
@@ -48,8 +48,8 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
- $summary[] = t('@setting: @value', array('@setting' => 'test_formatter_setting_additional', '@value' => $this->getSetting('test_formatter_setting_additional')));
+ $summary = [];
+ $summary[] = t('@setting: @value', ['@setting' => 'test_formatter_setting_additional', '@value' => $this->getSetting('test_formatter_setting_additional')]);
return $summary;
}
@@ -71,10 +71,10 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
- $elements[$delta] = array('#markup' => $this->getSetting('test_formatter_setting_additional') . '|' . $item->value . '|' . $item->additional_formatter_value);
+ $elements[$delta] = ['#markup' => $this->getSetting('test_formatter_setting_additional') . '|' . $item->value . '|' . $item->additional_formatter_value];
}
return $elements;
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php
index 1b8822f60f4..2f678798a2e 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php
@@ -24,22 +24,22 @@ class TestItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'test_field_storage_setting' => 'dummy test string',
'changeable' => 'a changeable field storage setting',
'unchangeable' => 'an unchangeable field storage setting',
'translatable_storage_setting' => 'a translatable field storage setting',
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'test_field_setting' => 'dummy test string',
'translatable_field_setting' => 'a translatable field setting',
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
@@ -57,30 +57,30 @@ class TestItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
'size' => 'medium',
- ),
- ),
- 'indexes' => array(
- 'value' => array('value'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'value' => ['value'],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $form['test_field_storage_setting'] = array(
+ $form['test_field_storage_setting'] = [
'#type' => 'textfield',
'#title' => t('Field test field storage setting'),
'#default_value' => $this->getSetting('test_field_storage_setting'),
'#required' => FALSE,
'#description' => t('A dummy form element to simulate field storage setting.'),
- );
+ ];
return $form;
}
@@ -89,13 +89,13 @@ class TestItem extends FieldItemBase {
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- $form['test_field_setting'] = array(
+ $form['test_field_setting'] = [
'#type' => 'textfield',
'#title' => t('Field test field setting'),
'#default_value' => $this->getSetting('test_field_setting'),
'#required' => FALSE,
'#description' => t('A dummy form element to simulate field setting.'),
- );
+ ];
return $form;
}
@@ -105,7 +105,7 @@ class TestItem extends FieldItemBase {
*/
public function delete() {
// Reports that delete() method is executed for testing purposes.
- field_test_memorize('field_test_field_delete', array($this->getEntity()));
+ field_test_memorize('field_test_field_delete', [$this->getEntity()]);
}
/**
@@ -115,14 +115,14 @@ class TestItem extends FieldItemBase {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'TestField' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'TestField' => [
'value' => -1,
- 'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1)),
- )
- ),
- ));
+ 'message' => t('%name does not accept the value @value.', ['%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1]),
+ ]
+ ],
+ ]);
return $constraints;
}
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
index 14a5b3ccf2a..9dd3387e5aa 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
@@ -27,24 +27,24 @@ class TestFieldWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'test_widget_setting' => 'dummy test string',
'role' => 'anonymous',
'role2' => 'anonymous',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['test_widget_setting'] = array(
+ $element['test_widget_setting'] = [
'#type' => 'textfield',
'#title' => t('Field test field widget setting'),
'#description' => t('A dummy form element to simulate field widget setting.'),
'#default_value' => $this->getSetting('test_widget_setting'),
'#required' => FALSE,
- );
+ ];
return $element;
}
@@ -52,8 +52,8 @@ class TestFieldWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
- $summary[] = t('@setting: @value', array('@setting' => 'test_widget_setting', '@value' => $this->getSetting('test_widget_setting')));
+ $summary = [];
+ $summary[] = t('@setting: @value', ['@setting' => 'test_widget_setting', '@value' => $this->getSetting('test_widget_setting')]);
return $summary;
}
@@ -61,11 +61,11 @@ class TestFieldWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element += array(
+ $element += [
'#type' => 'textfield',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : '',
- );
- return array('value' => $element);
+ ];
+ return ['value' => $element];
}
/**
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php
index 02f2d24cbe5..32cf6e4c5be 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php
@@ -29,22 +29,22 @@ class TestFieldWidgetMultiple extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'test_widget_setting_multiple' => 'dummy test string',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['test_widget_setting_multiple'] = array(
+ $element['test_widget_setting_multiple'] = [
'#type' => 'textfield',
'#title' => t('Field test field widget setting'),
'#description' => t('A dummy form element to simulate field widget setting.'),
'#default_value' => $this->getSetting('test_widget_setting_multiple'),
'#required' => FALSE,
- );
+ ];
return $element;
}
@@ -52,8 +52,8 @@ class TestFieldWidgetMultiple extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
- $summary[] = t('@setting: @value', array('@setting' => 'test_widget_setting_multiple', '@value' => $this->getSetting('test_widget_setting_multiple')));
+ $summary = [];
+ $summary[] = t('@setting: @value', ['@setting' => 'test_widget_setting_multiple', '@value' => $this->getSetting('test_widget_setting_multiple')]);
return $summary;
}
@@ -61,15 +61,15 @@ class TestFieldWidgetMultiple extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $values = array();
+ $values = [];
foreach ($items as $item) {
$values[] = $item->value;
}
- $element += array(
+ $element += [
'#type' => 'textfield',
'#default_value' => implode(', ', $values),
- '#element_validate' => array(array(get_class($this), 'multipleValidate')),
- );
+ '#element_validate' => [[get_class($this), 'multipleValidate']],
+ ];
return $element;
}
@@ -85,9 +85,9 @@ class TestFieldWidgetMultiple extends WidgetBase {
*/
public static function multipleValidate($element, FormStateInterface $form_state) {
$values = array_map('trim', explode(',', $element['#value']));
- $items = array();
+ $items = [];
foreach ($values as $value) {
- $items[] = array('value' => $value);
+ $items[] = ['value' => $value];
}
$form_state->setValueForElement($element, $items);
}
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php b/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php
index 8a511ed3e58..8105a22be78 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php
@@ -19,7 +19,7 @@ class TestFieldConstraint extends NotEqualTo {
* {@inheritdoc}
*/
public function getRequiredOptions() {
- return array('value');
+ return ['value'];
}
/**
diff --git a/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module b/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module
index 9dc2b193630..d59a0c036f9 100644
--- a/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module
+++ b/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module
@@ -14,11 +14,11 @@ use Drupal\Core\Form\FormStateInterface;
* Implements hook_field_widget_third_party_settings_form().
*/
function field_third_party_test_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
- $element['field_test_widget_third_party_settings_form'] = array(
+ $element['field_test_widget_third_party_settings_form'] = [
'#type' => 'textfield',
'#title' => t('3rd party widget settings form'),
'#default_value' => $plugin->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form'),
- );
+ ];
return $element;
}
@@ -34,11 +34,11 @@ function field_third_party_test_field_widget_settings_summary_alter(&$summary, $
* Implements hook_field_formatter_third_party_settings_form().
*/
function field_third_party_test_field_formatter_third_party_settings_form(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) {
- $element['field_test_field_formatter_third_party_settings_form'] = array(
+ $element['field_test_field_formatter_third_party_settings_form'] = [
'#type' => 'textfield',
'#title' => t('3rd party formatter settings form'),
'#default_value' => $plugin->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form'),
- );
+ ];
return $element;
}
diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php
index b2a165520e3..90895b186f0 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php
@@ -46,43 +46,43 @@ class EntityReferenceAutoCreateTest extends BrowserTestBase {
$referenced = $this->drupalCreateContentType();
$this->referencedType = $referenced->id();
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'node',
'translatable' => FALSE,
- 'entity_types' => array(),
- 'settings' => array(
+ 'entity_types' => [],
+ 'settings' => [
'target_type' => 'node',
- ),
+ ],
'type' => 'entity_reference',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
FieldConfig::create([
'label' => 'Entity reference field',
'field_name' => 'test_field',
'entity_type' => 'node',
'bundle' => $referencing->id(),
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
// Reference a single vocabulary.
- 'target_bundles' => array(
+ 'target_bundles' => [
$referenced->id(),
- ),
+ ],
// Enable auto-create.
'auto_create' => TRUE,
- ),
- ),
+ ],
+ ],
])->save();
entity_get_display('node', $referencing->id(), 'default')
->setComponent('test_field')
->save();
entity_get_form_display('node', $referencing->id(), 'default')
- ->setComponent('test_field', array(
+ ->setComponent('test_field', [
'type' => 'entity_reference_autocomplete',
- ))
+ ])
->save();
$account = $this->drupalCreateUser(['access content', "create $this->referencingType content"]);
@@ -109,10 +109,10 @@ class EntityReferenceAutoCreateTest extends BrowserTestBase {
$result = $query->execute();
$this->assertFalse($result, 'Referenced node does not exist yet.');
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
'test_field[0][target_id]' => $new_title,
- );
+ ];
$this->drupalPostForm("node/add/$this->referencingType", $edit, 'Save');
// Assert referenced node was created.
diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
index 5af26f12467..2f55cd54c30 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
@@ -36,11 +36,11 @@ class EntityReferenceFieldDefaultValueTest extends BrowserTestBase {
parent::setUp();
// Create default content type.
- $this->drupalCreateContentType(array('type' => 'reference_content'));
- $this->drupalCreateContentType(array('type' => 'referenced_content'));
+ $this->drupalCreateContentType(['type' => 'reference_content']);
+ $this->drupalCreateContentType(['type' => 'referenced_content']);
// Create admin user.
- $this->adminUser = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'bypass node access'));
+ $this->adminUser = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'bypass node access']);
$this->drupalLogin($this->adminUser);
}
@@ -49,33 +49,33 @@ class EntityReferenceFieldDefaultValueTest extends BrowserTestBase {
*/
function testEntityReferenceDefaultValue() {
// Create a node to be referenced.
- $referenced_node = $this->drupalCreateNode(array('type' => 'referenced_content'));
+ $referenced_node = $this->drupalCreateNode(['type' => 'referenced_content']);
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'entity_reference',
- 'settings' => array('target_type' => 'node'),
- ));
+ 'settings' => ['target_type' => 'node'],
+ ]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'reference_content',
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
- 'target_bundles' => array('referenced_content'),
- 'sort' => array('field' => '_none'),
- ),
- ),
+ 'handler_settings' => [
+ 'target_bundles' => ['referenced_content'],
+ 'sort' => ['field' => '_none'],
+ ],
+ ],
]);
$field->save();
// Set created node as default_value.
- $field_edit = array(
+ $field_edit = [
'default_value_input[' . $field_name . '][0][target_id]' => $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name, $field_edit, t('Save settings'));
// Check that default value is selected in default value form.
@@ -88,7 +88,7 @@ class EntityReferenceFieldDefaultValueTest extends BrowserTestBase {
$this->assertEqual($config_entity['default_value'][0]['target_uuid'], $referenced_node->uuid(), 'Content uuid and config entity uuid are the same');
// Ensure the configuration has the expected dependency on the entity that
// is being used a default value.
- $this->assertEqual(array($referenced_node->getConfigDependencyName()), $config_entity['dependencies']['content']);
+ $this->assertEqual([$referenced_node->getConfigDependencyName()], $config_entity['dependencies']['content']);
// Clear field definitions cache in order to avoid stale cache values.
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -111,35 +111,35 @@ class EntityReferenceFieldDefaultValueTest extends BrowserTestBase {
*/
function testEntityReferenceDefaultConfigValue() {
// Create a node to be referenced.
- $referenced_node_type = $this->drupalCreateContentType(array('type' => 'referenced_config_to_delete'));
- $referenced_node_type2 = $this->drupalCreateContentType(array('type' => 'referenced_config_to_preserve'));
+ $referenced_node_type = $this->drupalCreateContentType(['type' => 'referenced_config_to_delete']);
+ $referenced_node_type2 = $this->drupalCreateContentType(['type' => 'referenced_config_to_preserve']);
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'entity_reference',
- 'settings' => array('target_type' => 'node_type'),
+ 'settings' => ['target_type' => 'node_type'],
'cardinality' => FieldStorageConfig::CARDINALITY_UNLIMITED,
- ));
+ ]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'reference_content',
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
- 'sort' => array('field' => '_none'),
- ),
- ),
+ 'handler_settings' => [
+ 'sort' => ['field' => '_none'],
+ ],
+ ],
]);
$field->save();
// Set created node as default_value.
- $field_edit = array(
+ $field_edit = [
'default_value_input[' . $field_name . '][0][target_id]' => $referenced_node_type->label() . ' (' . $referenced_node_type->id() . ')',
'default_value_input[' . $field_name . '][1][target_id]' => $referenced_node_type2->label() . ' (' . $referenced_node_type2->id() . ')',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name, $field_edit, t('Save settings'));
// Check that the field has a dependency on the default value.
diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
index 52dde091ddd..889bd1aca0d 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
@@ -111,11 +111,11 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'language',
'content_translation',
'node',
- );
+ ];
protected function setUp() {
parent::setUp();
@@ -203,20 +203,20 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
* Adds term reference field for the article content type.
*/
protected function setUpEntityReferenceField() {
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->referenceFieldName,
'entity_type' => $this->testEntityTypeName,
'type' => 'entity_reference',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'translatable' => $this->translatable,
- 'settings' => array(
- 'allowed_values' => array(
- array(
+ 'settings' => [
+ 'allowed_values' => [
+ [
'target_type' => $this->testEntityTypeName,
- ),
- ),
- ),
- ))->save();
+ ],
+ ],
+ ],
+ ])->save();
FieldConfig::create([
'field_name' => $this->referenceFieldName,
@@ -225,14 +225,14 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
])
->save();
entity_get_form_display($this->testEntityTypeName, $this->referrerType->id(), 'default')
- ->setComponent($this->referenceFieldName, array(
+ ->setComponent($this->referenceFieldName, [
'type' => 'entity_reference_autocomplete',
- ))
+ ])
->save();
entity_get_display($this->testEntityTypeName, $this->referrerType->id(), 'default')
- ->setComponent($this->referenceFieldName, array(
+ ->setComponent($this->referenceFieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -240,14 +240,14 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
* Create content types.
*/
protected function setUpContentTypes() {
- $this->referrerType = $this->drupalCreateContentType(array(
+ $this->referrerType = $this->drupalCreateContentType([
'type' => 'referrer',
'name' => 'Referrer',
- ));
- $this->referencedType = $this->drupalCreateContentType(array(
+ ]);
+ $this->referencedType = $this->drupalCreateContentType([
'type' => 'referenced_page',
'name' => 'Referenced Page',
- ));
+ ]);
}
/**
@@ -255,19 +255,19 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
*/
protected function createReferencedEntityWithTranslation() {
/** @var \Drupal\node\Entity\Node $node */
- $node = entity_create($this->testEntityTypeName, array(
+ $node = entity_create($this->testEntityTypeName, [
'title' => $this->originalLabel,
'type' => $this->referencedType->id(),
- 'description' => array(
+ 'description' => [
'value' => $this->randomMachineName(),
'format' => 'basic_html',
- ),
+ ],
'langcode' => $this->baseLangcode,
- ));
+ ]);
$node->save();
- $node->addTranslation($this->translateToLangcode, array(
+ $node->addTranslation($this->translateToLangcode, [
'title' => $this->translatedLabel,
- ));
+ ]);
$node->save();
return $node;
@@ -279,15 +279,15 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
*/
protected function createNotTranslatedReferencedEntity() {
/** @var \Drupal\node\Entity\Node $node */
- $node = entity_create($this->testEntityTypeName, array(
+ $node = entity_create($this->testEntityTypeName, [
'title' => $this->labelOfNotTranslatedReference,
'type' => $this->referencedType->id(),
- 'description' => array(
+ 'description' => [
'value' => $this->randomMachineName(),
'format' => 'basic_html',
- ),
+ ],
'langcode' => $this->baseLangcode,
- ));
+ ]);
$node->save();
return $node;
@@ -298,19 +298,19 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
*/
protected function createReferrerEntity($translatable = TRUE) {
/** @var \Drupal\node\Entity\Node $node */
- $node = entity_create($this->testEntityTypeName, array(
+ $node = entity_create($this->testEntityTypeName, [
'title' => $this->randomMachineName(),
'type' => $this->referrerType->id(),
- 'description' => array(
+ 'description' => [
'value' => $this->randomMachineName(),
'format' => 'basic_html',
- ),
- $this->referenceFieldName => array(
- array('target_id' => $this->referencedEntityWithTranslation->id()),
- array('target_id' => $this->referencedEntityWithoutTranslation->id()),
- ),
+ ],
+ $this->referenceFieldName => [
+ ['target_id' => $this->referencedEntityWithTranslation->id()],
+ ['target_id' => $this->referencedEntityWithoutTranslation->id()],
+ ],
'langcode' => $this->baseLangcode,
- ));
+ ]);
if ($translatable) {
$node->addTranslation($this->translateToLangcode, $node->toArray());
}
diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php
index cb54d15545c..56484705e1b 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php
@@ -54,7 +54,7 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
parent::setUp();
// Create a test user.
- $web_user = $this->drupalCreateUser(array('administer entity_test content', 'administer entity_test fields', 'view test entity'));
+ $web_user = $this->drupalCreateUser(['administer entity_test content', 'administer entity_test fields', 'view test entity']);
$this->drupalLogin($web_user);
}
@@ -66,18 +66,18 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
$this->fieldName = 'field_test_' . $referenced_entities[0]->getEntityTypeId();
// Create an Entity reference field.
- $this->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, $this->fieldName, $referenced_entities[0]->getEntityTypeId(), 'default', array(), 2);
+ $this->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, $this->fieldName, $referenced_entities[0]->getEntityTypeId(), 'default', [], 2);
// Test the default 'entity_reference_autocomplete' widget.
entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName)->save();
$entity_name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'name[0][value]' => $entity_name,
$this->fieldName . '[0][target_id]' => $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')',
// Test an input of the entity label without a ' (entity_id)' suffix.
$this->fieldName . '[1][target_id]' => $referenced_entities[1]->label(),
- );
+ ];
$this->drupalPostForm($this->entityType . '/add', $edit, t('Save'));
$this->assertFieldValues($entity_name, $referenced_entities);
@@ -90,22 +90,22 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
$this->assertFieldByName($this->fieldName . '[0][target_id]', $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')');
$this->assertFieldByName($this->fieldName . '[1][target_id]', $referenced_entities[1]->label() . ' (' . $referenced_entities[1]->id() . ')');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertFieldValues($entity_name, $referenced_entities);
// Test the 'entity_reference_autocomplete_tags' widget.
- entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName, array(
+ entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName, [
'type' => 'entity_reference_autocomplete_tags',
- ))->save();
+ ])->save();
$entity_name = $this->randomMachineName();
$target_id = $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')';
// Test an input of the entity label without a ' (entity_id)' suffix.
$target_id .= ', ' . $referenced_entities[1]->label();
- $edit = array(
+ $edit = [
'name[0][value]' => $entity_name,
$this->fieldName . '[target_id]' => $target_id,
- );
+ ];
$this->drupalPostForm($this->entityType . '/add', $edit, t('Save'));
$this->assertFieldValues($entity_name, $referenced_entities);
@@ -115,23 +115,23 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
$this->drupalGet($this->entityType . '/manage/' . $entity->id() . '/edit');
$this->assertFieldByName($this->fieldName . '[target_id]', $target_id . ' (' . $referenced_entities[1]->id() . ')');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertFieldValues($entity_name, $referenced_entities);
// Test all the other widgets supported by the entity reference field.
// Since we don't know the form structure for these widgets, just test
// that editing and saving an already created entity works.
- $exclude = array('entity_reference_autocomplete', 'entity_reference_autocomplete_tags');
+ $exclude = ['entity_reference_autocomplete', 'entity_reference_autocomplete_tags'];
$entity = current($storage->loadByProperties(['name' => $entity_name]));
$supported_widgets = \Drupal::service('plugin.manager.field.widget')->getOptions('entity_reference');
$supported_widget_types = array_diff(array_keys($supported_widgets), $exclude);
foreach ($supported_widget_types as $widget_type) {
- entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName, array(
+ entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName, [
'type' => $widget_type,
- ))->save();
+ ])->save();
- $this->drupalPostForm($this->entityType . '/manage/' . $entity->id() . '/edit', array(), t('Save'));
+ $this->drupalPostForm($this->entityType . '/manage/' . $entity->id() . '/edit', [], t('Save'));
$this->assertFieldValues($entity_name, $referenced_entities);
}
@@ -139,9 +139,9 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
entity_get_form_display($this->entityType, $this->bundle, 'default')->setComponent($this->fieldName)->save();
// Set first entity as the default_value.
- $field_edit = array(
+ $field_edit = [
'default_value_input[' . $this->fieldName . '][0][target_id]' => $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')',
- );
+ ];
if ($key == 'content') {
$field_edit['settings[handler_settings][target_bundles][' . $referenced_entities[0]->getEntityTypeId() . ']'] = TRUE;
}
@@ -179,7 +179,7 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
$entity = current($this->container->get('entity_type.manager')->getStorage(
$this->entityType)->loadByProperties(['name' => $entity_name]));
- $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $this->entityType)));
+ $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', ['%entity_type' => $this->entityType]));
$this->assertEqual($entity->{$this->fieldName}->target_id, $referenced_entities[0]->id());
$this->assertEqual($entity->{$this->fieldName}->entity->id(), $referenced_entities[0]->id());
@@ -197,26 +197,26 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
* An array of entity objects.
*/
protected function getTestEntities() {
- $config_entity_1 = entity_create('config_test', array('id' => $this->randomMachineName(), 'label' => $this->randomMachineName()));
+ $config_entity_1 = entity_create('config_test', ['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]);
$config_entity_1->save();
- $config_entity_2 = entity_create('config_test', array('id' => $this->randomMachineName(), 'label' => $this->randomMachineName()));
+ $config_entity_2 = entity_create('config_test', ['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]);
$config_entity_2->save();
- $content_entity_1 = EntityTest::create(array('name' => $this->randomMachineName()));
+ $content_entity_1 = EntityTest::create(['name' => $this->randomMachineName()]);
$content_entity_1->save();
- $content_entity_2 = EntityTest::create(array('name' => $this->randomMachineName()));
+ $content_entity_2 = EntityTest::create(['name' => $this->randomMachineName()]);
$content_entity_2->save();
- return array(
- 'config' => array(
+ return [
+ 'config' => [
$config_entity_1,
$config_entity_2,
- ),
- 'content' => array(
+ ],
+ 'content' => [
$content_entity_1,
$content_entity_2,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php b/core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php
index 4ccf8cfcf69..cfb5ecf0845 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php
@@ -21,7 +21,7 @@ class SelectionTest extends BrowserTestBase {
*
* @var array
*/
- protected $nodes = array();
+ protected $nodes = [];
/**
* The entity reference field to test.
@@ -38,39 +38,39 @@ class SelectionTest extends BrowserTestBase {
// Create nodes.
$type = $this->drupalCreateContentType()->id();
- $node1 = $this->drupalCreateNode(array('type' => $type));
- $node2 = $this->drupalCreateNode(array('type' => $type));
+ $node1 = $this->drupalCreateNode(['type' => $type]);
+ $node2 = $this->drupalCreateNode(['type' => $type]);
$node3 = $this->drupalCreateNode();
- foreach (array($node1, $node2, $node3) as $node) {
+ foreach ([$node1, $node2, $node3] as $node) {
$this->nodes[$node->getType()][$node->id()] = $node->label();
}
// Create a field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'translatable' => FALSE,
- 'settings' => array(
+ 'settings' => [
'target_type' => 'node',
- ),
+ ],
'type' => 'entity_reference',
'cardinality' => '1',
- ));
+ ]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'test_bundle',
- 'settings' => array(
+ 'settings' => [
'handler' => 'views',
- 'handler_settings' => array(
- 'view' => array(
+ 'handler_settings' => [
+ 'view' => [
'view_name' => 'test_entity_reference',
'display_name' => 'entity_reference_1',
- 'arguments' => array(),
- ),
- ),
- ),
+ 'arguments' => [],
+ ],
+ ],
+ ],
]);
$field->save();
$this->field = $field;
@@ -112,23 +112,23 @@ class SelectionTest extends BrowserTestBase {
// Add a relationship to the view.
$view = Views::getView('test_entity_reference');
$view->setDisplay();
- $view->displayHandlers->get('default')->setOption('relationships', array(
- 'test_relationship' => array(
+ $view->displayHandlers->get('default')->setOption('relationships', [
+ 'test_relationship' => [
'id' => 'uid',
'table' => 'node_field_data',
'field' => 'uid',
- ),
- ));
+ ],
+ ]);
// Add a filter depending on the relationship to the test view.
- $view->displayHandlers->get('default')->setOption('filters', array(
- 'uid' => array(
+ $view->displayHandlers->get('default')->setOption('filters', [
+ 'uid' => [
'id' => 'uid',
'table' => 'users_field_data',
'field' => 'uid',
'relationship' => 'test_relationship',
- )
- ));
+ ]
+ ]);
// Set view to distinct so only one row per node is returned.
$query_options = $view->display_handler->getOption('query');
diff --git a/core/modules/field/tests/src/Functional/FieldAccessTest.php b/core/modules/field/tests/src/Functional/FieldAccessTest.php
index a9af8366863..36f0ef97997 100644
--- a/core/modules/field/tests/src/Functional/FieldAccessTest.php
+++ b/core/modules/field/tests/src/Functional/FieldAccessTest.php
@@ -17,7 +17,7 @@ class FieldAccessTest extends FieldTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_test');
+ public static $modules = ['node', 'field_test'];
/**
* Node entity to use in this test.
@@ -36,28 +36,28 @@ class FieldAccessTest extends FieldTestBase {
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('view test_view_field content'));
+ $web_user = $this->drupalCreateUser(['view test_view_field content']);
$this->drupalLogin($web_user);
// Create content type.
$content_type_info = $this->drupalCreateContentType();
$content_type = $content_type_info->id();
- $field_storage = array(
+ $field_storage = [
'field_name' => 'test_view_field',
'entity_type' => 'node',
'type' => 'text',
- );
+ ];
FieldStorageConfig::create($field_storage)->save();
- $field = array(
+ $field = [
'field_name' => $field_storage['field_name'],
'entity_type' => 'node',
'bundle' => $content_type,
- );
+ ];
FieldConfig::create($field)->save();
// Assign display properties for the 'default' and 'teaser' view modes.
- foreach (array('default', 'teaser') as $view_mode) {
+ foreach (['default', 'teaser'] as $view_mode) {
entity_get_display('node', $content_type, $view_mode)
->setComponent($field_storage['field_name'])
->save();
@@ -65,10 +65,10 @@ class FieldAccessTest extends FieldTestBase {
// Create test node.
$this->testViewFieldValue = 'This is some text';
- $settings = array();
+ $settings = [];
$settings['type'] = $content_type;
$settings['title'] = 'Field view access test';
- $settings['test_view_field'] = array(array('value' => $this->testViewFieldValue));
+ $settings['test_view_field'] = [['value' => $this->testViewFieldValue]];
$this->node = $this->drupalCreateNode($settings);
}
diff --git a/core/modules/field/tests/src/Functional/FieldHelpTest.php b/core/modules/field/tests/src/Functional/FieldHelpTest.php
index 76affaae356..9a6ff678209 100644
--- a/core/modules/field/tests/src/Functional/FieldHelpTest.php
+++ b/core/modules/field/tests/src/Functional/FieldHelpTest.php
@@ -16,7 +16,7 @@ class FieldHelpTest extends BrowserTestBase {
*
* @var array.
*/
- public static $modules = array('field', 'help');
+ public static $modules = ['field', 'help'];
// Tests field help implementation without optional core modules enabled.
protected $profile = 'minimal';
@@ -30,7 +30,7 @@ class FieldHelpTest extends BrowserTestBase {
parent::setUp();
// Create the admin user.
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'view the administration theme']);
}
/**
@@ -44,7 +44,7 @@ class FieldHelpTest extends BrowserTestBase {
$this->drupalGet('admin/help/field');
// Enable the Options, Email and Field API Test modules.
- \Drupal::service('module_installer')->install(array('options', 'field_test'));
+ \Drupal::service('module_installer')->install(['options', 'field_test']);
$this->resetAll();
\Drupal::service('plugin.manager.field.widget')->clearCachedDefinitions();
\Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
diff --git a/core/modules/field/tests/src/Functional/FieldTestBase.php b/core/modules/field/tests/src/Functional/FieldTestBase.php
index 40cffac225c..108d5f5d7cd 100644
--- a/core/modules/field/tests/src/Functional/FieldTestBase.php
+++ b/core/modules/field/tests/src/Functional/FieldTestBase.php
@@ -20,7 +20,7 @@ abstract class FieldTestBase extends BrowserTestBase {
* An array of random values, in the format expected for field values.
*/
function _generateTestFieldValues($cardinality) {
- $values = array();
+ $values = [];
for ($i = 0; $i < $cardinality; $i++) {
// field_test fields treat 0 as 'empty value'.
$values[$i]['value'] = mt_rand(1, 127);
@@ -58,7 +58,7 @@ abstract class FieldTestBase extends BrowserTestBase {
$values = $field->getValue();
$this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
foreach ($expected_values as $key => $value) {
- $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));
+ $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', ['@value' => $value]));
}
}
diff --git a/core/modules/field/tests/src/Functional/TranslationWebTest.php b/core/modules/field/tests/src/Functional/TranslationWebTest.php
index 3e0f849e312..e09e5851ba9 100644
--- a/core/modules/field/tests/src/Functional/TranslationWebTest.php
+++ b/core/modules/field/tests/src/Functional/TranslationWebTest.php
@@ -19,7 +19,7 @@ class TranslationWebTest extends FieldTestBase {
*
* @var array
*/
- public static $modules = array('language', 'field_test', 'entity_test');
+ public static $modules = ['language', 'field_test', 'entity_test'];
/**
* The name of the field to use in this test.
@@ -54,19 +54,19 @@ class TranslationWebTest extends FieldTestBase {
$this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name');
- $field_storage = array(
+ $field_storage = [
'field_name' => $this->fieldName,
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => 4,
- );
+ ];
FieldStorageConfig::create($field_storage)->save();
$this->fieldStorage = FieldStorageConfig::load($this->entityTypeId . '.' . $this->fieldName);
- $field = array(
+ $field = [
'field_storage' => $this->fieldStorage,
'bundle' => $this->entityTypeId,
- );
+ ];
FieldConfig::create($field)->save();
$this->field = FieldConfig::load($this->entityTypeId . '.' . $field['bundle'] . '.' . $this->fieldName);
@@ -75,10 +75,10 @@ class TranslationWebTest extends FieldTestBase {
->save();
for ($i = 0; $i < 3; ++$i) {
- ConfigurableLanguage::create(array(
+ ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this->randomString(),
- ))->save();
+ ])->save();
}
}
@@ -86,7 +86,7 @@ class TranslationWebTest extends FieldTestBase {
* Tests field translations when creating a new revision.
*/
function testFieldFormTranslationRevisions() {
- $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
+ $web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$this->drupalLogin($web_user);
// Prepare the field translations.
@@ -107,10 +107,10 @@ class TranslationWebTest extends FieldTestBase {
$entity->save();
// Create a new revision.
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $entity->{$field_name}->value,
'revision' => TRUE,
- );
+ ];
$this->drupalPostForm($this->entityTypeId . '/manage/' . $entity->id() . '/edit', $edit, t('Save'));
// Check translation revisions.
@@ -129,7 +129,7 @@ class TranslationWebTest extends FieldTestBase {
->loadRevision($revision_id);
foreach ($available_langcodes as $langcode => $value) {
$passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1;
- $this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->getRevisionId())));
+ $this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', ['@language' => $langcode, '@revision' => $entity->getRevisionId()]));
}
}
diff --git a/core/modules/field/tests/src/Kernel/Boolean/BooleanItemTest.php b/core/modules/field/tests/src/Kernel/Boolean/BooleanItemTest.php
index cb8b501a0e0..37acab86c2d 100644
--- a/core/modules/field/tests/src/Kernel/Boolean/BooleanItemTest.php
+++ b/core/modules/field/tests/src/Kernel/Boolean/BooleanItemTest.php
@@ -23,11 +23,11 @@ class BooleanItemTest extends FieldKernelTestBase {
parent::setUp();
// Create a boolean field and storage for validation.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_boolean',
'entity_type' => 'entity_test',
'type' => 'boolean',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_boolean',
@@ -36,9 +36,9 @@ class BooleanItemTest extends FieldKernelTestBase {
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent('field_boolean', array(
+ ->setComponent('field_boolean', [
'type' => 'boolean_checkbox',
- ))
+ ])
->save();
}
diff --git a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php
index b01926ad879..f0497d64a65 100644
--- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php
+++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php
@@ -90,31 +90,31 @@ class BulkDeleteTest extends FieldKernelTestBase {
protected function setUp() {
parent::setUp();
- $this->fieldStorages = array();
- $this->entities = array();
- $this->entitiesByBundles = array();
+ $this->fieldStorages = [];
+ $this->entities = [];
+ $this->entitiesByBundles = [];
// Create two bundles.
- $this->bundles = array('bb_1' => 'bb_1', 'bb_2' => 'bb_2');
+ $this->bundles = ['bb_1' => 'bb_1', 'bb_2' => 'bb_2'];
foreach ($this->bundles as $name => $desc) {
entity_test_create_bundle($name, $desc);
}
// Create two field storages.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'bf_1',
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => 1
- ));
+ ]);
$field_storage->save();
$this->fieldStorages[] = $field_storage;
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'bf_2',
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => 4
- ));
+ ]);
$field_storage->save();
$this->fieldStorages[] = $field_storage;
@@ -130,7 +130,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
for ($i = 0; $i < 10; $i++) {
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
- ->create(array('type' => $bundle));
+ ->create(['type' => $bundle]);
foreach ($this->fieldStorages as $field_storage) {
$entity->{$field_storage->getName()}->setValue($this->_generateTestFieldValues($field_storage->getCardinality()));
}
@@ -175,7 +175,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
$field->delete();
// The field still exists, deleted.
- $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]);
$this->assertEqual(count($fields), 1, 'There is one deleted field');
$field = $fields[$field->uuid()];
$this->assertEqual($field->getTargetBundle(), $bundle, 'The deleted field is for the correct bundle');
@@ -218,12 +218,12 @@ class BulkDeleteTest extends FieldKernelTestBase {
$bundle = reset($this->bundles);
// Create another field storage.
$field_name = 'bf_3';
- $deleted_field_storage = FieldStorageConfig::create(array(
+ $deleted_field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => 1
- ));
+ ]);
$deleted_field_storage->save();
// Create the field.
FieldConfig::create([
@@ -234,7 +234,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
for ($i = 0; $i < 20; $i++) {
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
- ->create(array('type' => $bundle));
+ ->create(['type' => $bundle]);
$entity->{$field_name}->setValue($this->_generateTestFieldValues(1));
$entity->save();
}
@@ -245,16 +245,16 @@ class BulkDeleteTest extends FieldKernelTestBase {
$deleted_field_uuid = $deleted_field->uuid();
// Reload the field storage.
- $field_storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $deleted_field_storage->uuid(), 'include_deleted' => TRUE));
+ $field_storages = entity_load_multiple_by_properties('field_storage_config', ['uuid' => $deleted_field_storage->uuid(), 'include_deleted' => TRUE]);
$deleted_field_storage = reset($field_storages);
// Create the field again.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => 1
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -262,14 +262,14 @@ class BulkDeleteTest extends FieldKernelTestBase {
])->save();
// The field still exists, deleted, with the same field name.
- $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $deleted_field_uuid, 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['uuid' => $deleted_field_uuid, 'include_deleted' => TRUE]);
$this->assertTrue(isset($fields[$deleted_field_uuid]) && $fields[$deleted_field_uuid]->isDeleted(), 'The field exists and is deleted');
$this->assertTrue(isset($fields[$deleted_field_uuid]) && $fields[$deleted_field_uuid]->getName() == $field_name);
for ($i = 0; $i < 10; $i++) {
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
- ->create(array('type' => $bundle));
+ ->create(['type' => $bundle]);
$entity->{$field_name}->setValue($this->_generateTestFieldValues(1));
$entity->save();
}
@@ -289,13 +289,13 @@ class BulkDeleteTest extends FieldKernelTestBase {
$this->assertFalse(\Drupal::database()->schema()->tableExists($deleted_table_name));
// The field has been removed from the system.
- $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $deleted_field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['field_storage_uuid' => $deleted_field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]);
$this->assertEqual(count($fields), 0, 'The field is gone');
// Verify there are still 10 entries in the main table.
$count = \Drupal::database()
->select('entity_test__' . $field_name, 'f')
- ->fields('f', array('entity_id'))
+ ->fields('f', ['entity_id'])
->condition('bundle', $bundle)
->countQuery()
->execute()
@@ -340,7 +340,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
// FieldItemInterface::delete() should have been called once for each entity in the
// bundle.
$actual_hooks = field_test_memorize();
- $hooks = array();
+ $hooks = [];
$entities = $this->entitiesByBundles[$bundle];
foreach ($entities as $id => $entity) {
$hooks['field_test_field_delete'][] = $entity;
@@ -348,19 +348,19 @@ class BulkDeleteTest extends FieldKernelTestBase {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The field still exists, deleted.
- $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]);
$this->assertEqual(count($fields), 1, 'There is one deleted field');
// Purge the field.
field_purge_batch($batch_size);
// The field is gone.
- $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]);
$this->assertEqual(count($fields), 0, 'The field is gone');
// The field storage still exists, not deleted, because it has a second
// field.
- $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
+ $storages = entity_load_multiple_by_properties('field_storage_config', ['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]);
$this->assertTrue(isset($storages[$field_storage->uuid()]), 'The field storage exists and is not deleted');
}
@@ -391,7 +391,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
// FieldItemInterface::delete() should have been called once for each entity in the
// bundle.
$actual_hooks = field_test_memorize();
- $hooks = array();
+ $hooks = [];
$entities = $this->entitiesByBundles[$bundle];
foreach ($entities as $id => $entity) {
$hooks['field_test_field_delete'][] = $entity;
@@ -399,17 +399,17 @@ class BulkDeleteTest extends FieldKernelTestBase {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The field still exists, deleted.
- $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['uuid' => $field->uuid(), 'include_deleted' => TRUE]);
$this->assertTrue(isset($fields[$field->uuid()]) && $fields[$field->uuid()]->isDeleted(), 'The field exists and is deleted');
// Purge again to purge the field.
field_purge_batch(0);
// The field is gone.
- $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['uuid' => $field->uuid(), 'include_deleted' => TRUE]);
$this->assertEqual(count($fields), 0, 'The field is purged.');
// The field storage still exists, not deleted.
- $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
+ $storages = entity_load_multiple_by_properties('field_storage_config', ['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]);
$this->assertTrue(isset($storages[$field_storage->uuid()]) && !$storages[$field_storage->uuid()]->isDeleted(), 'The field storage exists and is not deleted');
// Delete the second field.
@@ -426,7 +426,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
// Check hooks invocations (same as above, for the 2nd bundle).
$actual_hooks = field_test_memorize();
- $hooks = array();
+ $hooks = [];
$entities = $this->entitiesByBundles[$bundle];
foreach ($entities as $id => $entity) {
$hooks['field_test_field_delete'][] = $entity;
@@ -434,18 +434,18 @@ class BulkDeleteTest extends FieldKernelTestBase {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The field and the storage still exist, deleted.
- $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['uuid' => $field->uuid(), 'include_deleted' => TRUE]);
$this->assertTrue(isset($fields[$field->uuid()]) && $fields[$field->uuid()]->isDeleted(), 'The field exists and is deleted');
- $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
+ $storages = entity_load_multiple_by_properties('field_storage_config', ['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]);
$this->assertTrue(isset($storages[$field_storage->uuid()]) && $storages[$field_storage->uuid()]->isDeleted(), 'The field storage exists and is deleted');
// Purge again to purge the field and the storage.
field_purge_batch(0);
// The field and the storage are gone.
- $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE));
+ $fields = entity_load_multiple_by_properties('field_config', ['uuid' => $field->uuid(), 'include_deleted' => TRUE]);
$this->assertEqual(count($fields), 0, 'The field is purged.');
- $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
+ $storages = entity_load_multiple_by_properties('field_storage_config', ['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]);
$this->assertEqual(count($storages), 0, 'The field storage is purged.');
}
diff --git a/core/modules/field/tests/src/Kernel/DisplayApiTest.php b/core/modules/field/tests/src/Kernel/DisplayApiTest.php
index c1218a6805c..1072de19bc0 100644
--- a/core/modules/field/tests/src/Kernel/DisplayApiTest.php
+++ b/core/modules/field/tests/src/Kernel/DisplayApiTest.php
@@ -69,33 +69,33 @@ class DisplayApiTest extends FieldKernelTestBase {
$this->label = $this->randomMachineName();
$this->cardinality = 4;
- $field_storage = array(
+ $field_storage = [
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => $this->cardinality,
- );
- $field = array(
+ ];
+ $field = [
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'label' => $this->label,
- );
+ ];
- $this->displayOptions = array(
- 'default' => array(
+ $this->displayOptions = [
+ 'default' => [
'type' => 'field_test_default',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting' => $this->randomMachineName(),
- ),
- ),
- 'teaser' => array(
+ ],
+ ],
+ 'teaser' => [
'type' => 'field_test_default',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting' => $this->randomMachineName(),
- ),
- ),
- );
+ ],
+ ],
+ ];
FieldStorageConfig::create($field_storage)->save();
FieldConfig::create($field)->save();
@@ -104,7 +104,7 @@ class DisplayApiTest extends FieldKernelTestBase {
->setComponent($this->fieldName, $this->displayOptions['default'])
->save();
// Create a display for the teaser view mode.
- EntityViewMode::create(array('id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save();
+ EntityViewMode::create(['id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'])->save();
entity_get_display($field['entity_type'], $field['bundle'], 'teaser')
->setComponent($this->fieldName, $this->displayOptions['teaser'])
->save();
@@ -132,66 +132,66 @@ class DisplayApiTest extends FieldKernelTestBase {
$setting = $settings['test_formatter_setting'];
$this->assertText($this->label, 'Label was displayed.');
foreach ($this->values as $delta => $value) {
- $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
// Display settings: Check hidden field.
- $display = array(
+ $display = [
'label' => 'hidden',
'type' => 'field_test_multiple',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting_multiple' => $this->randomMachineName(),
'alter' => TRUE,
- ),
- );
+ ],
+ ];
$build = $items->view($display);
$this->render($build);
$setting = $display['settings']['test_formatter_setting_multiple'];
$this->assertNoText($this->label, 'Label was not displayed.');
$this->assertText('field_test_entity_display_build_alter', 'Alter fired, display passed.');
$this->assertText('entity language is en', 'Language is placed onto the context.');
- $array = array();
+ $array = [];
foreach ($this->values as $delta => $value) {
$array[] = $delta . ':' . $value['value'];
}
$this->assertText($setting . '|' . implode('|', $array), 'Values were displayed with expected setting.');
// Display settings: Check visually_hidden field.
- $display = array(
+ $display = [
'label' => 'visually_hidden',
'type' => 'field_test_multiple',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting_multiple' => $this->randomMachineName(),
'alter' => TRUE,
- ),
- );
+ ],
+ ];
$build = $items->view($display);
$this->render($build);
$setting = $display['settings']['test_formatter_setting_multiple'];
$this->assertRaw('visually-hidden', 'Label was visually hidden.');
$this->assertText('field_test_entity_display_build_alter', 'Alter fired, display passed.');
$this->assertText('entity language is en', 'Language is placed onto the context.');
- $array = array();
+ $array = [];
foreach ($this->values as $delta => $value) {
$array[] = $delta . ':' . $value['value'];
}
$this->assertText($setting . '|' . implode('|', $array), 'Values were displayed with expected setting.');
// Check the prepare_view steps are invoked.
- $display = array(
+ $display = [
'label' => 'hidden',
'type' => 'field_test_with_prepare_view',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting_additional' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$build = $items->view($display);
$this->render($build);
$setting = $display['settings']['test_formatter_setting_additional'];
$this->assertNoText($this->label, 'Label was not displayed.');
$this->assertNoText('field_test_entity_display_build_alter', 'Alter not fired.');
foreach ($this->values as $delta => $value) {
- $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
// View mode: check that display settings specified in the display object
@@ -201,7 +201,7 @@ class DisplayApiTest extends FieldKernelTestBase {
$setting = $this->displayOptions['teaser']['settings']['test_formatter_setting'];
$this->assertText($this->label, 'Label was displayed.');
foreach ($this->values as $delta => $value) {
- $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
// Unknown view mode: check that display settings for 'default' view mode
@@ -211,7 +211,7 @@ class DisplayApiTest extends FieldKernelTestBase {
$setting = $this->displayOptions['default']['settings']['test_formatter_setting'];
$this->assertText($this->label, 'Label was displayed.');
foreach ($this->values as $delta => $value) {
- $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
}
@@ -226,37 +226,37 @@ class DisplayApiTest extends FieldKernelTestBase {
$item = $this->entity->{$this->fieldName}[$delta];
$build = $item->view();
$this->render($build);
- $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
// Check that explicit display settings are used.
- $display = array(
+ $display = [
'type' => 'field_test_multiple',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting_multiple' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$setting = $display['settings']['test_formatter_setting_multiple'];
foreach ($this->values as $delta => $value) {
$item = $this->entity->{$this->fieldName}[$delta];
$build = $item->view($display);
$this->render($build);
- $this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
// Check that prepare_view steps are invoked.
- $display = array(
+ $display = [
'type' => 'field_test_with_prepare_view',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting_additional' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$setting = $display['settings']['test_formatter_setting_additional'];
foreach ($this->values as $delta => $value) {
$item = $this->entity->{$this->fieldName}[$delta];
$build = $item->view($display);
$this->render($build);
- $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
// View mode: check that display settings specified in the field are used.
@@ -265,7 +265,7 @@ class DisplayApiTest extends FieldKernelTestBase {
$item = $this->entity->{$this->fieldName}[$delta];
$build = $item->view('teaser');
$this->render($build);
- $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
// Unknown view mode: check that display settings for 'default' view mode
@@ -275,7 +275,7 @@ class DisplayApiTest extends FieldKernelTestBase {
$item = $this->entity->{$this->fieldName}[$delta];
$build = $item->view('unknown_view_mode');
$this->render($build);
- $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
+ $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', ['@delta' => $delta]));
}
}
@@ -284,13 +284,13 @@ class DisplayApiTest extends FieldKernelTestBase {
*/
function testFieldEmpty() {
// Uses \Drupal\field_test\Plugin\Field\FieldFormatter\TestFieldEmptyFormatter.
- $display = array(
+ $display = [
'label' => 'hidden',
'type' => 'field_empty_test',
- 'settings' => array(
+ 'settings' => [
'test_empty_string' => '**EMPTY FIELD**' . $this->randomMachineName(),
- ),
- );
+ ],
+ ];
// $this->entity is set by the setUp() method and by default contains 4
// numeric values. We only want to test the display of this one field.
$build = $this->entity->get($this->fieldName)->view($display);
@@ -300,7 +300,7 @@ class DisplayApiTest extends FieldKernelTestBase {
$this->assertNoText($display['settings']['test_empty_string']);
// Now remove the values from the test field and retest.
- $this->entity->{$this->fieldName} = array();
+ $this->entity->{$this->fieldName} = [];
$this->entity->save();
$build = $this->entity->get($this->fieldName)->view($display);
$this->render($build);
diff --git a/core/modules/field/tests/src/Kernel/Email/EmailItemTest.php b/core/modules/field/tests/src/Kernel/Email/EmailItemTest.php
index cd8b7acdd1b..10b44333e07 100644
--- a/core/modules/field/tests/src/Kernel/Email/EmailItemTest.php
+++ b/core/modules/field/tests/src/Kernel/Email/EmailItemTest.php
@@ -20,11 +20,11 @@ class EmailItemTest extends FieldKernelTestBase {
parent::setUp();
// Create an email field storage and field for validation.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_email',
'entity_type' => 'entity_test',
'type' => 'email',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_email',
@@ -33,9 +33,9 @@ class EmailItemTest extends FieldKernelTestBase {
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent('field_email', array(
+ ->setComponent('field_email', [
'type' => 'email_default',
- ))
+ ])
->save();
}
diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php
index da4481aefbc..9c94aca946f 100644
--- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php
+++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php
@@ -68,7 +68,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
$this->config('system.theme')->set('default', 'classy')->save();
$this->installEntitySchema('entity_test');
// Grant the 'view test entity' permission.
- $this->installConfig(array('user'));
+ $this->installConfig(['user']);
Role::load(RoleInterface::ANONYMOUS_ID)
->grantPermission('view test entity')
->save();
@@ -76,16 +76,16 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
// The label formatter rendering generates links, so build the router.
$this->container->get('router.builder')->rebuild();
- $this->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, 'Field test', $this->entityType, 'default', array(), FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
+ $this->createEntityReferenceField($this->entityType, $this->bundle, $this->fieldName, 'Field test', $this->entityType, 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
// Set up a field, so that the entity that'll be referenced bubbles up a
// cache tag when rendering it entirely.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'body',
'entity_type' => $this->entityType,
'type' => 'text',
- 'settings' => array(),
- ))->save();
+ 'settings' => [],
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entityType,
'bundle' => $this->bundle,
@@ -93,35 +93,35 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
'label' => 'Body',
])->save();
entity_get_display($this->entityType, $this->bundle, 'default')
- ->setComponent('body', array(
+ ->setComponent('body', [
'type' => 'text_default',
- 'settings' => array(),
- ))
+ 'settings' => [],
+ ])
->save();
- FilterFormat::create(array(
+ FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
- ))->save();
+ ])->save();
// Create the entity to be referenced.
$this->referencedEntity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => $this->randomMachineName()));
- $this->referencedEntity->body = array(
+ ->create(['name' => $this->randomMachineName()]);
+ $this->referencedEntity->body = [
'value' => '<p>Hello, world!</p>',
'format' => 'full_html',
- );
+ ];
$this->referencedEntity->save();
// Create another entity to be referenced but do not save it.
$this->unsavedReferencedEntity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => $this->randomMachineName()));
- $this->unsavedReferencedEntity->body = array(
+ ->create(['name' => $this->randomMachineName()]);
+ $this->unsavedReferencedEntity->body = [
'value' => '<p>Hello, unsaved world!</p>',
'format' => 'full_html',
- );
+ ];
}
/**
@@ -137,7 +137,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
$referencing_entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => $this->randomMachineName()));
+ ->create(['name' => $this->randomMachineName()]);
$referencing_entity->save();
$referencing_entity->{$field_name}->entity = $this->referencedEntity;
@@ -150,16 +150,16 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
foreach ($formatter_manager->getOptions('entity_reference') as $formatter => $name) {
// Set formatter type for the 'full' view mode.
entity_get_display($this->entityType, $this->bundle, 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => $formatter,
- ))
+ ])
->save();
// Invoke entity view.
entity_view($referencing_entity, 'default');
// Verify the un-accessible item still exists.
- $this->assertEqual($referencing_entity->{$field_name}->target_id, $this->referencedEntity->id(), format_string('The un-accessible item still exists after @name formatter was executed.', array('@name' => $name)));
+ $this->assertEqual($referencing_entity->{$field_name}->target_id, $this->referencedEntity->id(), format_string('The un-accessible item still exists after @name formatter was executed.', ['@name' => $name]));
}
}
@@ -198,7 +198,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
$this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
$expected_cache_tags = Cache::mergeTags(\Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags());
$expected_cache_tags = Cache::mergeTags($expected_cache_tags, FilterFormat::load('full_html')->getCacheTags());
- $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter)));
+ $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', ['@formatter' => $formatter]));
// Test the second field item.
$expected_rendered_name_field_2 = '
@@ -338,37 +338,37 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
'max-age' => Cache::PERMANENT,
];
$this->assertEqual($build['#cache'], $expected_field_cacheability, 'The field render array contains the entity access cacheability metadata');
- $expected_item_1 = array(
+ $expected_item_1 = [
'#type' => 'link',
'#title' => $this->referencedEntity->label(),
'#url' => $this->referencedEntity->urlInfo(),
'#options' => $this->referencedEntity->urlInfo()->getOptions(),
- '#cache' => array(
+ '#cache' => [
'contexts' => [
'user.permissions',
],
'tags' => $this->referencedEntity->getCacheTags(),
- ),
- );
+ ],
+ ];
$this->assertEqual($renderer->renderRoot($build[0]), $renderer->renderRoot($expected_item_1), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
$this->assertEqual(CacheableMetadata::createFromRenderArray($build[0]), CacheableMetadata::createFromRenderArray($expected_item_1));
// The second referenced entity is "autocreated", therefore not saved and
// lacking any URL info.
- $expected_item_2 = array(
+ $expected_item_2 = [
'#plain_text' => $this->unsavedReferencedEntity->label(),
- '#cache' => array(
+ '#cache' => [
'contexts' => [
'user.permissions',
],
'tags' => $this->unsavedReferencedEntity->getCacheTags(),
'max-age' => Cache::PERMANENT,
- ),
- );
+ ],
+ ];
$this->assertEqual($build[1], $expected_item_2, sprintf('The render array returned by the %s formatter is correct for an item with a unsaved entity.', $formatter));
// Test with the 'link' setting set to FALSE.
- $build = $this->buildRenderArray([$this->referencedEntity, $this->unsavedReferencedEntity], $formatter, array('link' => FALSE));
+ $build = $this->buildRenderArray([$this->referencedEntity, $this->unsavedReferencedEntity], $formatter, ['link' => FALSE]);
$this->assertEqual($build[0]['#plain_text'], $this->referencedEntity->label(), sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
$this->assertEqual($build[1]['#plain_text'], $this->unsavedReferencedEntity->label(), sprintf('The markup returned by the %s formatter is correct for an item with a unsaved entity.', $formatter));
@@ -379,12 +379,12 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
$field_storage_config->setSetting('target_type', 'entity_test_label');
$field_storage_config->save();
- $referenced_entity_with_no_link_template = EntityTestLabel::create(array(
+ $referenced_entity_with_no_link_template = EntityTestLabel::create([
'name' => $this->randomMachineName(),
- ));
+ ]);
$referenced_entity_with_no_link_template->save();
- $build = $this->buildRenderArray([$referenced_entity_with_no_link_template], $formatter, array('link' => TRUE));
+ $build = $this->buildRenderArray([$referenced_entity_with_no_link_template], $formatter, ['link' => TRUE]);
$this->assertEqual($build[0]['#plain_text'], $referenced_entity_with_no_link_template->label(), sprintf('The markup returned by the %s formatter is correct for an entity type with no valid link template.', $formatter));
}
@@ -403,11 +403,11 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
* @return array
* A render array.
*/
- protected function buildRenderArray(array $referenced_entities, $formatter, $formatter_options = array()) {
+ protected function buildRenderArray(array $referenced_entities, $formatter, $formatter_options = []) {
// Create the entity that will have the entity reference field.
$referencing_entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => $this->randomMachineName()));
+ ->create(['name' => $this->randomMachineName()]);
$items = $referencing_entity->get($this->fieldName);
@@ -417,7 +417,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
}
// Build the renderable array for the field.
- return $items->view(array('type' => $formatter, 'settings' => $formatter_options));
+ return $items->view(['type' => $formatter, 'settings' => $formatter_options]);
}
}
diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
index 90d4d1f774a..ded93b85603 100644
--- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
+++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
@@ -175,7 +175,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
// Delete terms so we have nothing to reference and try again
$term->delete();
$term2->delete();
- $entity = EntityTest::create(array('name' => $this->randomMachineName()));
+ $entity = EntityTest::create(['name' => $this->randomMachineName()]);
$entity->save();
// Test the generateSampleValue() method.
@@ -244,7 +244,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
// Delete terms so we have nothing to reference and try again
$this->vocabulary->delete();
$vocabulary2->delete();
- $entity = EntityTest::create(array('name' => $this->randomMachineName()));
+ $entity = EntityTest::create(['name' => $this->randomMachineName()]);
$entity->save();
}
@@ -253,11 +253,11 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
*/
public function testEntityAutoCreate() {
// The term entity is unsaved here.
- $term = Term::create(array(
+ $term = Term::create([
'name' => $this->randomMachineName(),
'vid' => $this->term->bundle(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
$entity = EntityTest::create();
// Now assign the unsaved term to the field.
$entity->field_test_taxonomy_term->entity = $term;
@@ -304,22 +304,22 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
*/
public function testSelectionHandlerSettings() {
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'entity_reference',
- 'settings' => array(
+ 'settings' => [
'target_type' => 'entity_test'
- ),
- ));
+ ],
+ ]);
$field_storage->save();
// Do not specify any value for the 'handler' setting in order to verify
// that the default handler with the correct derivative is used.
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
$field = FieldConfig::load($field->id());
$this->assertEqual($field->getSetting('handler'), 'default:entity_test');
@@ -350,11 +350,11 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
*/
public function testAutocreateValidation() {
// The term entity is unsaved here.
- $term = Term::create(array(
+ $term = Term::create([
'name' => $this->randomMachineName(),
'vid' => $this->term->bundle(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
$entity = EntityTest::create([
'field_test_taxonomy_term' => [
'entity' => $term,
diff --git a/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php b/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php
index d18d9f30bce..2b0be855dd8 100644
--- a/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php
+++ b/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php
@@ -27,14 +27,14 @@ class EntityReferenceRelationshipTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array(
+ public static $testViews = [
'test_entity_reference_entity_test_view',
'test_entity_reference_entity_test_view_long',
'test_entity_reference_reverse_entity_test_view',
'test_entity_reference_entity_test_mul_view',
'test_entity_reference_reverse_entity_test_mul_view',
'test_entity_reference_group_by_empty_relationships',
- );
+ ];
/**
* Modules to install.
@@ -48,7 +48,7 @@ class EntityReferenceRelationshipTest extends ViewsKernelTestBase {
*
* @var array
*/
- protected $entities = array();
+ protected $entities = [];
/**
* {@inheritdoc}
@@ -74,9 +74,9 @@ class EntityReferenceRelationshipTest extends ViewsKernelTestBase {
$this->createEntityReferenceField('entity_test_mul_changed', 'entity_test_mul_changed', 'field_test_data_with_a_long_name', 'field_test_data_with_a_long_name', 'entity_test');
// Create reference from entity_test_mul to entity_test cardinality: infinite.
- $this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test_unlimited', 'field_data_test_unlimited', 'entity_test', 'default', array(), FieldStorageConfig::CARDINALITY_UNLIMITED);
+ $this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test_unlimited', 'field_data_test_unlimited', 'entity_test', 'default', [], FieldStorageConfig::CARDINALITY_UNLIMITED);
- ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['entity_reference_test_views']);
}
/**
diff --git a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php
index ba96bc91522..c1e7ae1c51e 100644
--- a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php
@@ -42,23 +42,23 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
$display = entity_get_display($entity_type, $entity->bundle(), 'full');
$formatter_setting = $this->randomMachineName();
- $display_options = array(
+ $display_options = [
'label' => 'above',
'type' => 'field_test_default',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting' => $formatter_setting,
- ),
- );
+ ],
+ ];
$display->setComponent($this->fieldTestData->field_name, $display_options);
$formatter_setting_2 = $this->randomMachineName();
- $display_options_2 = array(
+ $display_options_2 = [
'label' => 'above',
'type' => 'field_test_default',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting' => $formatter_setting_2,
- ),
- );
+ ],
+ ];
$display->setComponent($this->fieldTestData->field_name_2, $display_options_2);
// View all fields.
@@ -94,13 +94,13 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
// Multiple formatter.
$entity = clone($entity_init);
$formatter_setting = $this->randomMachineName();
- $display->setComponent($this->fieldTestData->field_name, array(
+ $display->setComponent($this->fieldTestData->field_name, [
'label' => 'above',
'type' => 'field_test_multiple',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting_multiple' => $formatter_setting,
- ),
- ));
+ ],
+ ]);
$content = $display->build($entity);
$this->render($content);
$expected_output = $formatter_setting;
@@ -112,13 +112,13 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
// Test a formatter that uses hook_field_formatter_prepare_view().
$entity = clone($entity_init);
$formatter_setting = $this->randomMachineName();
- $display->setComponent($this->fieldTestData->field_name, array(
+ $display->setComponent($this->fieldTestData->field_name, [
'label' => 'above',
'type' => 'field_test_with_prepare_view',
- 'settings' => array(
+ 'settings' => [
'test_formatter_setting_additional' => $formatter_setting,
- ),
- ));
+ ],
+ ]);
$content = $display->build($entity);
$this->render($content);
foreach ($values as $delta => $value) {
@@ -136,18 +136,18 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
function testEntityDisplayViewMultiple() {
// Use a formatter that has a prepareView() step.
$display = entity_get_display('entity_test', 'entity_test', 'full')
- ->setComponent($this->fieldTestData->field_name, array(
+ ->setComponent($this->fieldTestData->field_name, [
'type' => 'field_test_with_prepare_view',
- ));
+ ]);
// Create two entities.
- $entity1 = EntityTest::create(array('id' => 1, 'type' => 'entity_test'));
+ $entity1 = EntityTest::create(['id' => 1, 'type' => 'entity_test']);
$entity1->{$this->fieldTestData->field_name}->setValue($this->_generateTestFieldValues(1));
- $entity2 = EntityTest::create(array('id' => 2, 'type' => 'entity_test'));
+ $entity2 = EntityTest::create(['id' => 2, 'type' => 'entity_test']);
$entity2->{$this->fieldTestData->field_name}->setValue($this->_generateTestFieldValues(1));
// Run buildMultiple(), and check that the entities come out as expected.
- $display->buildMultiple(array($entity1, $entity2));
+ $display->buildMultiple([$entity1, $entity2]);
$item1 = $entity1->{$this->fieldTestData->field_name}[0];
$this->assertEqual($item1->additional_formatter_value, $item1->value + 1, 'Entity 1 ran through the prepareView() formatter method.');
$item2 = $entity2->{$this->fieldTestData->field_name}[0];
@@ -162,7 +162,7 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
*/
function testEntityCache() {
// Initialize random values and a test entity.
- $entity_init = EntityTest::create(array('type' => $this->fieldTestData->field->getTargetBundle()));
+ $entity_init = EntityTest::create(['type' => $this->fieldTestData->field->getTargetBundle()]);
$values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality());
// Non-cacheable entity type.
@@ -185,9 +185,9 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
$entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'type' => $entity_type,
- ));
+ ]);
// Check that no initial cache entry is present.
$cid = "values:$entity_type:" . $entity->id();
@@ -247,11 +247,11 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
$this->createFieldWithStorage('_2');
$entity_type = 'entity_test';
- $entity = entity_create($entity_type, array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle()));
+ $entity = entity_create($entity_type, ['id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle()]);
// Test generating widgets for all fields.
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->getTargetBundle(), 'default');
- $form = array();
+ $form = [];
$form_state = new FormState();
$display->buildForm($entity, $form, $form_state);
@@ -273,7 +273,7 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
$display->removeComponent($name);
}
}
- $form = array();
+ $form = [];
$form_state = new FormState();
$display->buildForm($entity, $form, $form_state);
@@ -294,18 +294,18 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
$entity_type = 'entity_test';
$entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle()));
+ ->create(['id' => 1, 'revision_id' => 1, 'type' => $this->fieldTestData->field->getTargetBundle()]);
// Build the form for all fields.
$display = entity_get_form_display($entity_type, $this->fieldTestData->field->getTargetBundle(), 'default');
- $form = array();
+ $form = [];
$form_state = new FormState();
$display->buildForm($entity_init, $form, $form_state);
// Simulate incoming values.
// First field.
- $values = array();
- $weights = array();
+ $values = [];
+ $weights = [];
for ($delta = 0; $delta < $this->fieldTestData->field_storage->getCardinality(); $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
// Assign random weight.
@@ -318,8 +318,8 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
// Leave an empty value. 'field_test' fields are empty if empty().
$values[1]['value'] = 0;
// Second field.
- $values_2 = array();
- $weights_2 = array();
+ $values_2 = [];
+ $weights_2 = [];
for ($delta = 0; $delta < $this->fieldTestData->field_storage_2->getCardinality(); $delta++) {
$values_2[$delta]['value'] = mt_rand(1, 127);
// Assign random weight.
@@ -345,17 +345,17 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
asort($weights);
asort($weights_2);
- $expected_values = array();
- $expected_values_2 = array();
+ $expected_values = [];
+ $expected_values_2 = [];
foreach ($weights as $key => $value) {
if ($key != 1) {
- $expected_values[] = array('value' => $values[$key]['value']);
+ $expected_values[] = ['value' => $values[$key]['value']];
}
}
$this->assertIdentical($entity->{$this->fieldTestData->field_name}->getValue(), $expected_values, 'Submit filters empty values');
foreach ($weights_2 as $key => $value) {
if ($key != 1) {
- $expected_values_2[] = array('value' => $values_2[$key]['value']);
+ $expected_values_2[] = ['value' => $values_2[$key]['value']];
}
}
$this->assertIdentical($entity->{$this->fieldTestData->field_name_2}->getValue(), $expected_values_2, 'Submit filters empty values');
@@ -368,10 +368,10 @@ class FieldAttachOtherTest extends FieldKernelTestBase {
}
$entity = clone($entity_init);
$display->extractFormValues($entity, $form, $form_state);
- $expected_values_2 = array();
+ $expected_values_2 = [];
foreach ($weights_2 as $key => $value) {
if ($key != 1) {
- $expected_values_2[] = array('value' => $values_2[$key]['value']);
+ $expected_values_2[] = ['value' => $values_2[$key]['value']];
}
}
$this->assertTrue($entity->{$this->fieldTestData->field_name}->isEmpty(), 'The first field is empty in the entity object');
diff --git a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
index 8237ef4d8b9..9f0eef33d24 100644
--- a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
@@ -31,7 +31,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// TODO : test empty values filtering and "compression" (store consecutive deltas).
// Preparation: create three revisions and store them in $revision array.
- $values = array();
+ $values = [];
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create();
@@ -54,17 +54,17 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
$this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, 'Current revision: expected number of values');
for ($delta = 0; $delta < $cardinality; $delta++) {
// The field value loaded matches the one inserted or updated.
- $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$current_revision][$delta]['value'], format_string('Current revision: expected value %delta was found.', array('%delta' => $delta)));
+ $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$current_revision][$delta]['value'], format_string('Current revision: expected value %delta was found.', ['%delta' => $delta]));
}
// Confirm each revision loads the correct data.
foreach (array_keys($values) as $revision_id) {
$entity = $storage->loadRevision($revision_id);
// Number of values per field loaded equals the field cardinality.
- $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, format_string('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id)));
+ $this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, format_string('Revision %revision_id: expected number of values.', ['%revision_id' => $revision_id]));
for ($delta = 0; $delta < $cardinality; $delta++) {
// The field value loaded matches the one inserted or updated.
- $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$revision_id][$delta]['value'], format_string('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta)));
+ $this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$revision_id][$delta]['value'], format_string('Revision %revision_id: expected value %delta was found.', ['%revision_id' => $revision_id, '%delta' => $delta]));
}
}
}
@@ -76,28 +76,28 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
$entity_type = 'entity_test_rev';
// Define 2 bundles.
- $bundles = array(
+ $bundles = [
1 => 'test_bundle_1',
2 => 'test_bundle_2',
- );
+ ];
entity_test_create_bundle($bundles[1]);
entity_test_create_bundle($bundles[2]);
// Define 3 fields:
// - field_1 is in bundle_1 and bundle_2,
// - field_2 is in bundle_1,
// - field_3 is in bundle_2.
- $field_bundles_map = array(
- 1 => array(1, 2),
- 2 => array(1),
- 3 => array(2),
- );
+ $field_bundles_map = [
+ 1 => [1, 2],
+ 2 => [1],
+ 3 => [2],
+ ];
for ($i = 1; $i <= 3; $i++) {
$field_names[$i] = 'field_' . $i;
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
'type' => 'test_field',
- ));
+ ]);
$field_storage->save();
$field_ids[$i] = $field_storage->uuid();
foreach ($field_bundles_map[$i] as $bundle) {
@@ -113,14 +113,14 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
foreach ($bundles as $index => $bundle) {
$entities[$index] = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('id' => $index, 'revision_id' => $index, 'type' => $bundle));
+ ->create(['id' => $index, 'revision_id' => $index, 'type' => $bundle]);
$entity = clone($entities[$index]);
foreach ($field_names as $field_name) {
if (!$entity->hasField($field_name)) {
continue;
}
$values[$index][$field_name] = mt_rand(1, 127);
- $entity->$field_name->setValue(array('value' => $values[$index][$field_name]));
+ $entity->$field_name->setValue(['value' => $values[$index][$field_name]]);
}
$entity->enforceIsnew();
$entity->save();
@@ -136,7 +136,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
continue;
}
// The field value loaded matches the one inserted.
- $this->assertEqual($entity->{$field_name}->value, $values[$index][$field_name], format_string('Entity %index: expected value was found.', array('%index' => $index)));
+ $this->assertEqual($entity->{$field_name}->value, $values[$index][$field_name], format_string('Entity %index: expected value was found.', ['%index' => $index]));
}
}
}
@@ -150,7 +150,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
$entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('id' => 1));
+ ->create(['id' => 1]);
// Insert: Field is NULL.
$entity = clone $entity_init;
@@ -184,7 +184,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Update: Field is empty array. Data should be wiped.
$entity = clone($entity_init);
- $entity->{$this->fieldTestData->field_name} = array();
+ $entity->{$this->fieldTestData->field_name} = [];
$entity = $this->entitySaveReload($entity);
$this->assertTrue($entity->{$this->fieldTestData->field_name}->isEmpty(), 'Update: empty array removes existing values');
}
@@ -203,7 +203,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Verify that fields are populated with default values.
$entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('id' => 1, 'revision_id' => 1));
+ ->create(['id' => 1, 'revision_id' => 1]);
$default = field_test_default_value($entity_init, $this->fieldTestData->field);
$this->assertEqual($entity_init->{$this->fieldTestData->field_name}->getValue(), $default, 'Default field value correctly populated.');
@@ -215,10 +215,10 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
$this->assertTrue($entity->{$this->fieldTestData->field_name}->isEmpty(), 'Insert: NULL field results in no value saved');
// Verify that prepopulated field values are not overwritten by defaults.
- $value = array(array('value' => $default[0]['value'] - mt_rand(1, 127)));
+ $value = [['value' => $default[0]['value'] - mt_rand(1, 127)]];
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('type' => $entity_init->bundle(), $this->fieldTestData->field_name => $value));
+ ->create(['type' => $entity_init->bundle(), $this->fieldTestData->field_name => $value]);
$this->assertEqual($entity->{$this->fieldTestData->field_name}->getValue(), $value, 'Prepopulated field value correctly maintained.');
}
@@ -231,8 +231,8 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
$cardinality = $this->fieldTestData->field_storage->getCardinality();
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('type' => $this->fieldTestData->field->getTargetBundle()));
- $vids = array();
+ ->create(['type' => $this->fieldTestData->field->getTargetBundle()]);
+ $vids = [];
// Create revision 0
$values = $this->_generateTestFieldValues($cardinality);
@@ -261,7 +261,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Delete revision 1, confirm the other two still load.
$controller->deleteRevision($vids[1]);
$controller->resetCache();
- foreach (array(0, 2) as $key) {
+ foreach ([0, 2] as $key) {
$vid = $vids[$key];
$revision = $controller->loadRevision($vid);
$this->assertEqual(count($revision->{$this->fieldTestData->field_name}), $cardinality, "The test entity revision $vid has $cardinality values.");
@@ -275,7 +275,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Delete all field data, confirm nothing loads
$entity->delete();
$controller->resetCache();
- foreach (array(0, 1, 2) as $vid) {
+ foreach ([0, 1, 2] as $vid) {
$revision = $controller->loadRevision($vid);
$this->assertFalse($revision);
}
@@ -301,7 +301,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Save an entity with data in the field.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('type' => $this->fieldTestData->field->getTargetBundle()));
+ ->create(['type' => $this->fieldTestData->field->getTargetBundle()]);
$values = $this->_generateTestFieldValues($cardinality);
$entity->{$this->fieldTestData->field_name} = $values;
@@ -327,27 +327,27 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Create a second field for the test bundle
$field_name = Unicode::strtolower($this->randomMachineName() . '_field_name');
- $field_storage = array(
+ $field_storage = [
'field_name' => $field_name,
'entity_type' => $entity_type,
'type' => 'test_field',
'cardinality' => 1,
- );
+ ];
FieldStorageConfig::create($field_storage)->save();
- $field = array(
+ $field = [
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $this->fieldTestData->field->getTargetBundle(),
'label' => $this->randomMachineName() . '_label',
'description' => $this->randomMachineName() . '_description',
'weight' => mt_rand(0, 127),
- );
+ ];
FieldConfig::create($field)->save();
// Save an entity with data for both fields
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('type' => $this->fieldTestData->field->getTargetBundle()));
+ ->create(['type' => $this->fieldTestData->field->getTargetBundle()]);
$values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality());
$entity->{$this->fieldTestData->field_name} = $values;
$entity->{$field_name} = $this->_generateTestFieldValues(1);
diff --git a/core/modules/field/tests/src/Kernel/FieldCrudTest.php b/core/modules/field/tests/src/Kernel/FieldCrudTest.php
index a61d64565f7..85121c96e74 100644
--- a/core/modules/field/tests/src/Kernel/FieldCrudTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldCrudTest.php
@@ -40,18 +40,18 @@ class FieldCrudTest extends FieldKernelTestBase {
function setUp() {
parent::setUp();
- $this->fieldStorageDefinition = array(
+ $this->fieldStorageDefinition = [
'field_name' => Unicode::strtolower($this->randomMachineName()),
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
+ ];
$this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
$this->fieldStorage->save();
- $this->fieldDefinition = array(
+ $this->fieldDefinition = [
'field_name' => $this->fieldStorage->getName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- );
+ ];
}
// TODO : test creation with
@@ -223,12 +223,12 @@ class FieldCrudTest extends FieldKernelTestBase {
FieldConfig::create($another_field_definition)->save();
// Test that the first field is not deleted, and then delete it.
- $field = current(entity_load_multiple_by_properties('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldDefinition['field_name'], 'bundle' => $this->fieldDefinition['bundle'], 'include_deleted' => TRUE)));
+ $field = current(entity_load_multiple_by_properties('field_config', ['entity_type' => 'entity_test', 'field_name' => $this->fieldDefinition['field_name'], 'bundle' => $this->fieldDefinition['bundle'], 'include_deleted' => TRUE]));
$this->assertTrue(!empty($field) && empty($field->deleted), 'A new field is not marked for deletion.');
$field->delete();
// Make sure the field is marked as deleted when it is specifically loaded.
- $field = current(entity_load_multiple_by_properties('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldDefinition['field_name'], 'bundle' => $this->fieldDefinition['bundle'], 'include_deleted' => TRUE)));
+ $field = current(entity_load_multiple_by_properties('field_config', ['entity_type' => 'entity_test', 'field_name' => $this->fieldDefinition['field_name'], 'bundle' => $this->fieldDefinition['bundle'], 'include_deleted' => TRUE]));
$this->assertTrue($field->isDeleted(), 'A deleted field is marked for deletion.');
// Try to load the field normally and make sure it does not show up.
@@ -276,7 +276,7 @@ class FieldCrudTest extends FieldKernelTestBase {
$field->save();
$field_2 = FieldConfig::create($field_definition_2);
$field_2->save();
- $this->container->get('entity.manager')->getStorage('field_config')->delete(array($field, $field_2));
+ $this->container->get('entity.manager')->getStorage('field_config')->delete([$field, $field_2]);
$this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->getName()));
}
diff --git a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php
index e0ea6836903..2bbe24d68ca 100644
--- a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php
@@ -50,12 +50,12 @@ class FieldDataCountTest extends FieldKernelTestBase {
// Create a field with a cardinality of 2 to show that we are counting
// entities and not rows in a table.
/** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_int',
'entity_type' => 'entity_test',
'type' => 'integer',
'cardinality' => 2,
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -112,7 +112,7 @@ class FieldDataCountTest extends FieldKernelTestBase {
$entity_init = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('type' => $entity_type,));
+ ->create(['type' => $entity_type,]);
$cardinality = $this->fieldTestData->field_storage_2->getCardinality();
$this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), FALSE, 'There are no entities with field data.');
@@ -129,7 +129,7 @@ class FieldDataCountTest extends FieldKernelTestBase {
$this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), TRUE, 'There are entities with field data.');
$this->assertIdentical($this->storageRev->countFieldData($this->fieldTestData->field_storage_2), 1, 'There is 1 entity with field data.');
- $entity->{$this->fieldTestData->field_name_2} = array();
+ $entity->{$this->fieldTestData->field_name_2} = [];
$entity->setNewRevision();
$entity->save();
@@ -137,7 +137,7 @@ class FieldDataCountTest extends FieldKernelTestBase {
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
$entity = $storage->loadRevision($first_revision);
- $this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, format_string('Revision %revision_id: expected number of values.', array('%revision_id' => $first_revision)));
+ $this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, format_string('Revision %revision_id: expected number of values.', ['%revision_id' => $first_revision]));
}
/**
@@ -146,27 +146,27 @@ class FieldDataCountTest extends FieldKernelTestBase {
public function testCountWithIndex0() {
// Create a field that will require dedicated storage.
/** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_int',
'entity_type' => 'user',
'type' => 'integer',
'cardinality' => 2,
- ));
+ ]);
$field_storage->save();
- FieldConfig::create(array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'user',
- ))->save();
+ ])->save();
// Create an entry for the anonymous user, who has user ID 0.
$user = $this->storageUser
- ->create(array(
+ ->create([
'uid' => 0,
'name' => 'anonymous',
'mail' => NULL,
'status' => FALSE,
'field_int' => 42,
- ));
+ ]);
$user->save();
// Test shared table storage.
diff --git a/core/modules/field/tests/src/Kernel/FieldImportChangeTest.php b/core/modules/field/tests/src/Kernel/FieldImportChangeTest.php
index 8cd029188e8..10eff6d6eca 100644
--- a/core/modules/field/tests/src/Kernel/FieldImportChangeTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldImportChangeTest.php
@@ -20,7 +20,7 @@ class FieldImportChangeTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('field_test_config');
+ public static $modules = ['field_test_config'];
/**
* Tests importing an updated field.
diff --git a/core/modules/field/tests/src/Kernel/FieldImportCreateTest.php b/core/modules/field/tests/src/Kernel/FieldImportCreateTest.php
index 3478dd3bea2..007bb0f6e01 100644
--- a/core/modules/field/tests/src/Kernel/FieldImportCreateTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldImportCreateTest.php
@@ -37,7 +37,7 @@ class FieldImportCreateTest extends FieldKernelTestBase {
// Enable field_test_config module and check that the field and storage
// shipped in the module's default config were created.
- \Drupal::service('module_installer')->install(array('field_test_config'));
+ \Drupal::service('module_installer')->install(['field_test_config']);
// A field storage with one single field.
$field_storage = FieldStorageConfig::load($field_storage_id);
diff --git a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php
index b536fe8046a..0eef137165a 100644
--- a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php
@@ -22,7 +22,7 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('field_test_config');
+ public static $modules = ['field_test_config'];
/**
* Tests deleting field storages and fields as part of config import.
@@ -60,11 +60,11 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
$active = $this->container->get('config.storage');
$sync = $this->container->get('config.storage.sync');
$this->copyConfig($active, $sync);
- $this->assertTrue($sync->delete($field_storage_config_name), SafeMarkup::format('Deleted field storage: @field_storage', array('@field_storage' => $field_storage_config_name)));
- $this->assertTrue($sync->delete($field_storage_config_name_2), SafeMarkup::format('Deleted field storage: @field_storage', array('@field_storage' => $field_storage_config_name_2)));
- $this->assertTrue($sync->delete($field_config_name), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name)));
- $this->assertTrue($sync->delete($field_config_name_2a), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name_2a)));
- $this->assertTrue($sync->delete($field_config_name_2b), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name_2b)));
+ $this->assertTrue($sync->delete($field_storage_config_name), SafeMarkup::format('Deleted field storage: @field_storage', ['@field_storage' => $field_storage_config_name]));
+ $this->assertTrue($sync->delete($field_storage_config_name_2), SafeMarkup::format('Deleted field storage: @field_storage', ['@field_storage' => $field_storage_config_name_2]));
+ $this->assertTrue($sync->delete($field_config_name), SafeMarkup::format('Deleted field: @field', ['@field' => $field_config_name]));
+ $this->assertTrue($sync->delete($field_config_name_2a), SafeMarkup::format('Deleted field: @field', ['@field' => $field_config_name_2a]));
+ $this->assertTrue($sync->delete($field_config_name_2b), SafeMarkup::format('Deleted field: @field', ['@field' => $field_config_name_2b]));
$deletes = $this->configImporter()->getUnprocessedConfiguration('delete');
$this->assertEqual(count($deletes), 5, 'Importing configuration will delete 3 fields and 2 field storages.');
@@ -73,39 +73,39 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
$this->configImporter()->import();
// Check that the field storages and fields are gone.
- \Drupal::entityManager()->getStorage('field_storage_config')->resetCache(array($field_storage_id));
+ \Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id]);
$field_storage = FieldStorageConfig::load($field_storage_id);
$this->assertFalse($field_storage, 'The field storage was deleted.');
- \Drupal::entityManager()->getStorage('field_storage_config')->resetCache(array($field_storage_id_2));
+ \Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id_2]);
$field_storage_2 = FieldStorageConfig::load($field_storage_id_2);
$this->assertFalse($field_storage_2, 'The second field storage was deleted.');
- \Drupal::entityManager()->getStorage('field_config')->resetCache(array($field_id));
+ \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id]);
$field = FieldConfig::load($field_id);
$this->assertFalse($field, 'The field was deleted.');
- \Drupal::entityManager()->getStorage('field_config')->resetCache(array($field_id_2a));
+ \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2a]);
$field_2a = FieldConfig::load($field_id_2a);
$this->assertFalse($field_2a, 'The second field on test bundle was deleted.');
- \Drupal::entityManager()->getStorage('field_config')->resetCache(array($field_id_2b));
+ \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2b]);
$field_2b = FieldConfig::load($field_id_2b);
$this->assertFalse($field_2b, 'The second field on test bundle 2 was deleted.');
// Check that all config files are gone.
$active = $this->container->get('config.storage');
- $this->assertIdentical($active->listAll($field_storage_config_name), array());
- $this->assertIdentical($active->listAll($field_storage_config_name_2), array());
- $this->assertIdentical($active->listAll($field_config_name), array());
- $this->assertIdentical($active->listAll($field_config_name_2a), array());
- $this->assertIdentical($active->listAll($field_config_name_2b), array());
+ $this->assertIdentical($active->listAll($field_storage_config_name), []);
+ $this->assertIdentical($active->listAll($field_storage_config_name_2), []);
+ $this->assertIdentical($active->listAll($field_config_name), []);
+ $this->assertIdentical($active->listAll($field_config_name_2a), []);
+ $this->assertIdentical($active->listAll($field_config_name_2b), []);
// Check that the storage definition is preserved in state.
- $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
+ $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
$this->assertTrue(isset($deleted_storages[$field_storage_uuid]));
$this->assertTrue(isset($deleted_storages[$field_storage_uuid_2]));
// Purge field data, and check that the storage definition has been
// completely removed once the data is purged.
field_purge_batch(10);
- $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
+ $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
$this->assertTrue(empty($deleted_storages), 'Fields are deleted');
}
diff --git a/core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php b/core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php
index dab6e0d53f6..c3a4d3c1d54 100644
--- a/core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php
@@ -21,14 +21,14 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('telephone');
+ public static $modules = ['telephone'];
protected function setUp() {
parent::setUp();
// Module uninstall requires users_data tables.
// @see drupal_flush_all_caches()
// @see user_modules_uninstalled()
- $this->installSchema('user', array('users_data'));
+ $this->installSchema('user', ['users_data']);
}
/**
@@ -38,11 +38,11 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
// Create a field to delete to prove that
// \Drupal\field\ConfigImporterFieldPurger does not purge fields that are
// not related to the configuration synchronization.
- $unrelated_field_storage = FieldStorageConfig::create(array(
+ $unrelated_field_storage = FieldStorageConfig::create([
'field_name' => 'field_int',
'entity_type' => 'entity_test',
'type' => 'integer',
- ));
+ ]);
$unrelated_field_storage->save();
FieldConfig::create([
'field_storage' => $unrelated_field_storage,
@@ -50,11 +50,11 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
])->save();
// Create a telephone field for validation.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_test',
'entity_type' => 'entity_test',
'type' => 'telephone',
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -93,7 +93,7 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
$sync->delete('field.field.entity_test.entity_test.field_test');
$steps = $this->configImporter()->initialize();
- $this->assertIdentical($steps[0], array('\Drupal\field\ConfigImporterFieldPurger', 'process'), 'The additional process configuration synchronization step has been added.');
+ $this->assertIdentical($steps[0], ['\Drupal\field\ConfigImporterFieldPurger', 'process'], 'The additional process configuration synchronization step has been added.');
// This will purge all the data, delete the field and uninstall the
// Telephone module.
@@ -101,7 +101,7 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone'));
$this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The test field has been deleted by the configuration synchronization');
- $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
+ $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.');
$this->assertTrue(isset($deleted_storages[$unrelated_field_storage->uuid()]), 'Unrelated field not purged by configuration synchronization.');
}
@@ -112,11 +112,11 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
*/
public function testImportAlreadyDeletedUninstall() {
// Create a telephone field for validation.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_test',
'entity_type' => 'entity_test',
'type' => 'telephone',
- ));
+ ]);
$field_storage->save();
$field_storage_uuid = $field_storage->uuid();
FieldConfig::create([
@@ -150,18 +150,18 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
unset($core_extension['module']['telephone']);
$sync->write('core.extension', $core_extension);
- $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
+ $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
$this->assertTrue(isset($deleted_storages[$field_storage_uuid]), 'Field has been deleted and needs purging before configuration synchronization.');
$steps = $this->configImporter()->initialize();
- $this->assertIdentical($steps[0], array('\Drupal\field\ConfigImporterFieldPurger', 'process'), 'The additional process configuration synchronization step has been added.');
+ $this->assertIdentical($steps[0], ['\Drupal\field\ConfigImporterFieldPurger', 'process'], 'The additional process configuration synchronization step has been added.');
// This will purge all the data, delete the field and uninstall the
// Telephone module.
$this->configImporter()->import();
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone'));
- $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
+ $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: [];
$this->assertFalse(isset($deleted_storages[$field_storage_uuid]), 'Field has been completed removed from the system.');
}
diff --git a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php
index 4d6bd5111dc..6bc40cc3db8 100644
--- a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php
+++ b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php
@@ -43,24 +43,24 @@ abstract class FieldKernelTestBase extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->fieldTestData = new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS);
+ $this->fieldTestData = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
$this->installEntitySchema('entity_test');
$this->installEntitySchema('user');
$this->installSchema('system', ['sequences', 'key_value']);
// Set default storage backend and configure the theme system.
- $this->installConfig(array('field', 'system'));
+ $this->installConfig(['field', 'system']);
// Create user 1.
$storage = \Drupal::entityManager()->getStorage('user');
$storage
- ->create(array(
+ ->create([
'uid' => 1,
'name' => 'entity-test',
'mail' => 'entity@localhost',
'status' => TRUE,
- ))
+ ])
->save();
}
@@ -88,33 +88,33 @@ abstract class FieldKernelTestBase extends KernelTestBase {
$field_definition = 'field_definition' . $suffix;
$this->fieldTestData->$field_name = Unicode::strtolower($this->randomMachineName() . '_field_name' . $suffix);
- $this->fieldTestData->$field_storage = FieldStorageConfig::create(array(
+ $this->fieldTestData->$field_storage = FieldStorageConfig::create([
'field_name' => $this->fieldTestData->$field_name,
'entity_type' => $entity_type,
'type' => 'test_field',
'cardinality' => 4,
- ));
+ ]);
$this->fieldTestData->$field_storage->save();
$this->fieldTestData->$field_storage_uuid = $this->fieldTestData->$field_storage->uuid();
- $this->fieldTestData->$field_definition = array(
+ $this->fieldTestData->$field_definition = [
'field_storage' => $this->fieldTestData->$field_storage,
'bundle' => $bundle,
'label' => $this->randomMachineName() . '_label',
'description' => $this->randomMachineName() . '_description',
- 'settings' => array(
+ 'settings' => [
'test_field_setting' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$this->fieldTestData->$field = FieldConfig::create($this->fieldTestData->$field_definition);
$this->fieldTestData->$field->save();
entity_get_form_display($entity_type, $bundle, 'default')
- ->setComponent($this->fieldTestData->$field_name, array(
+ ->setComponent($this->fieldTestData->$field_name, [
'type' => 'test_field_widget',
- 'settings' => array(
+ 'settings' => [
'test_widget_setting' => $this->randomMachineName(),
- )
- ))
+ ]
+ ])
->save();
}
@@ -159,7 +159,7 @@ abstract class FieldKernelTestBase extends KernelTestBase {
* An array of random values, in the format expected for field values.
*/
protected function _generateTestFieldValues($cardinality) {
- $values = array();
+ $values = [];
for ($i = 0; $i < $cardinality; $i++) {
// field_test fields treat 0 as 'empty value'.
$values[$i]['value'] = mt_rand(1, 127);
@@ -197,7 +197,7 @@ abstract class FieldKernelTestBase extends KernelTestBase {
$values = $field->getValue();
$this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
foreach ($expected_values as $key => $value) {
- $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));
+ $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', ['@value' => $value]));
}
}
diff --git a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
index da1948c149b..13091c4dffe 100644
--- a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
@@ -21,7 +21,7 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array();
+ public static $modules = [];
// TODO : test creation with
// - a full fledged $field structure, check that all the values are there
@@ -32,11 +32,11 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
* Test the creation of a field storage.
*/
function testCreate() {
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => 'field_2',
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
+ ];
field_test_memorize();
$field_storage = FieldStorageConfig::create($field_storage_definition);
$field_storage->save();
@@ -86,10 +86,10 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// Check that field type is required.
try {
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => 'field_1',
'entity_type' => 'entity_type',
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with no type.'));
}
@@ -99,10 +99,10 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// Check that field name is required.
try {
- $field_storage_definition = array(
+ $field_storage_definition = [
'type' => 'test_field',
'entity_type' => 'entity_test',
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create an unnamed field.'));
}
@@ -111,10 +111,10 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
}
// Check that entity type is required.
try {
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => 'test_field',
'type' => 'test_field'
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail('Cannot create a field without an entity type.');
}
@@ -124,11 +124,11 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// Check that field name must start with a letter or _.
try {
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => '2field_2',
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with a name starting with a digit.'));
}
@@ -138,11 +138,11 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// Check that field name must only contain lowercase alphanumeric or _.
try {
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => 'field#_3',
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with a name containing an illegal character.'));
}
@@ -152,11 +152,11 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// Check that field name cannot be longer than 32 characters long.
try {
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => '_12345678901234567890123456789012',
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with a name longer than 32 characters.'));
}
@@ -167,11 +167,11 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// Check that field name can not be an entity key.
// "id" is known as an entity key from the "entity_test" type.
try {
- $field_storage_definition = array(
+ $field_storage_definition = [
'type' => 'test_field',
'field_name' => 'id',
'entity_type' => 'entity_test',
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field bearing the name of an entity key.'));
}
@@ -187,15 +187,15 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
* since plugin classes (and thus the field type schema) cannot be accessed.
*/
function testCreateWithExplicitSchema() {
- $schema = array(
+ $schema = [
'dummy' => 'foobar'
- );
- $field_storage = FieldStorageConfig::create(array(
+ ];
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_2',
'entity_type' => 'entity_test',
'type' => 'test_field',
'schema' => $schema,
- ));
+ ]);
$this->assertEqual($field_storage->getSchema(), $schema);
}
@@ -203,31 +203,31 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
* Tests reading field storage definitions.
*/
function testRead() {
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => 'field_1',
'entity_type' => 'entity_test',
'type' => 'test_field',
- );
+ ];
$field_storage = FieldStorageConfig::create($field_storage_definition);
$field_storage->save();
$id = $field_storage->id();
// Check that 'single column' criteria works.
- $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name']));
+ $fields = entity_load_multiple_by_properties('field_storage_config', ['field_name' => $field_storage_definition['field_name']]);
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
// Check that 'multi column' criteria works.
- $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name'], 'type' => $field_storage_definition['type']));
+ $fields = entity_load_multiple_by_properties('field_storage_config', ['field_name' => $field_storage_definition['field_name'], 'type' => $field_storage_definition['type']]);
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
- $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name'], 'type' => 'foo'));
+ $fields = entity_load_multiple_by_properties('field_storage_config', ['field_name' => $field_storage_definition['field_name'], 'type' => 'foo']);
$this->assertTrue(empty($fields), 'No field was found.');
// Create a field from the field storage.
- $field_definition = array(
+ $field_definition = [
'field_name' => $field_storage_definition['field_name'],
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- );
+ ];
FieldConfig::create($field_definition)->save();
}
@@ -236,48 +236,48 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
*/
function testIndexes() {
// Check that indexes specified by the field type are used by default.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_1',
'entity_type' => 'entity_test',
'type' => 'test_field',
- ));
+ ]);
$field_storage->save();
$field_storage = FieldStorageConfig::load($field_storage->id());
$schema = $field_storage->getSchema();
- $expected_indexes = array('value' => array('value'));
+ $expected_indexes = ['value' => ['value']];
$this->assertEqual($schema['indexes'], $expected_indexes, 'Field type indexes saved by default');
// Check that indexes specified by the field definition override the field
// type indexes.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_2',
'entity_type' => 'entity_test',
'type' => 'test_field',
- 'indexes' => array(
- 'value' => array(),
- ),
- ));
+ 'indexes' => [
+ 'value' => [],
+ ],
+ ]);
$field_storage->save();
$field_storage = FieldStorageConfig::load($field_storage->id());
$schema = $field_storage->getSchema();
- $expected_indexes = array('value' => array());
+ $expected_indexes = ['value' => []];
$this->assertEqual($schema['indexes'], $expected_indexes, 'Field definition indexes override field type indexes');
// Check that indexes specified by the field definition add to the field
// type indexes.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_3',
'entity_type' => 'entity_test',
'type' => 'test_field',
- 'indexes' => array(
- 'value_2' => array('value'),
- ),
- ));
+ 'indexes' => [
+ 'value_2' => ['value'],
+ ],
+ ]);
$field_storage->save();
$id = $field_storage->id();
$field_storage = FieldStorageConfig::load($id);
$schema = $field_storage->getSchema();
- $expected_indexes = array('value' => array('value'), 'value_2' => array('value'));
+ $expected_indexes = ['value' => ['value'], 'value_2' => ['value']];
$this->assertEqual($schema['indexes'], $expected_indexes, 'Field definition indexes are merged with field type indexes');
}
@@ -288,43 +288,43 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// TODO: Also test deletion of the data stored in the field ?
// Create two fields (so we can test that only one is deleted).
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => 'field_1',
'type' => 'test_field',
'entity_type' => 'entity_test',
- );
+ ];
FieldStorageConfig::create($field_storage_definition)->save();
- $another_field_storage_definition = array(
+ $another_field_storage_definition = [
'field_name' => 'field_2',
'type' => 'test_field',
'entity_type' => 'entity_test',
- );
+ ];
FieldStorageConfig::create($another_field_storage_definition)->save();
// Create fields for each.
- $field_definition = array(
+ $field_definition = [
'field_name' => $field_storage_definition['field_name'],
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- );
+ ];
FieldConfig::create($field_definition)->save();
$another_field_definition = $field_definition;
$another_field_definition['field_name'] = $another_field_storage_definition['field_name'];
FieldConfig::create($another_field_definition)->save();
// Test that the first field is not deleted, and then delete it.
- $field_storage = current(entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE)));
+ $field_storage = current(entity_load_multiple_by_properties('field_storage_config', ['field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE]));
$this->assertTrue(!empty($field_storage) && !$field_storage->isDeleted(), 'A new storage is not marked for deletion.');
FieldStorageConfig::loadByName('entity_test', $field_storage_definition['field_name'])->delete();
// Make sure that the field is marked as deleted when it is specifically
// loaded.
- $field_storage = current(entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE)));
+ $field_storage = current(entity_load_multiple_by_properties('field_storage_config', ['field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE]));
$this->assertTrue($field_storage->isDeleted(), 'A deleted storage is marked for deletion.');
// Make sure that this field is marked as deleted when it is
// specifically loaded.
- $field = current(entity_load_multiple_by_properties('field_config', array('entity_type' => 'entity_test', 'field_name' => $field_definition['field_name'], 'bundle' => $field_definition['bundle'], 'include_deleted' => TRUE)));
+ $field = current(entity_load_multiple_by_properties('field_config', ['entity_type' => 'entity_test', 'field_name' => $field_definition['field_name'], 'bundle' => $field_definition['bundle'], 'include_deleted' => TRUE]));
$this->assertTrue($field->isDeleted(), 'A field whose storage was deleted is marked for deletion.');
// Try to load the storage normally and make sure it does not show up.
@@ -364,11 +364,11 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
}
function testUpdateFieldType() {
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_type',
'entity_type' => 'entity_test',
'type' => 'decimal',
- ));
+ ]);
$field_storage->save();
try {
@@ -389,12 +389,12 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
// respected. Since cardinality enforcement is consistent across database
// systems, it makes a good test case.
$cardinality = 4;
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_update',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => $cardinality,
- ));
+ ]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
@@ -427,14 +427,14 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
* Test field type modules forbidding an update.
*/
function testUpdateForbid() {
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'forbidden',
'entity_type' => 'entity_test',
'type' => 'test_field',
- 'settings' => array(
+ 'settings' => [
'changeable' => 0,
'unchangeable' => 0
- )));
+ ]]);
$field_storage->save();
$field_storage->setSetting('changeable', $field_storage->getSetting('changeable') + 1);
try {
diff --git a/core/modules/field/tests/src/Kernel/FieldTypePluginManagerTest.php b/core/modules/field/tests/src/Kernel/FieldTypePluginManagerTest.php
index 6d443843acf..fe46a057f9f 100644
--- a/core/modules/field/tests/src/Kernel/FieldTypePluginManagerTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldTypePluginManagerTest.php
@@ -19,10 +19,10 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
*/
function testDefaultSettings() {
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
- foreach (array('test_field', 'shape', 'hidden_test_field') as $type) {
+ foreach (['test_field', 'shape', 'hidden_test_field'] as $type) {
$definition = $field_type_manager->getDefinition($type);
- $this->assertIdentical($field_type_manager->getDefaultStorageSettings($type), $definition['class']::defaultStorageSettings(), format_string("%type storage settings were returned", array('%type' => $type)));
- $this->assertIdentical($field_type_manager->getDefaultFieldSettings($type), $definition['class']::defaultFieldSettings(), format_string(" %type field settings were returned", array('%type' => $type)));
+ $this->assertIdentical($field_type_manager->getDefaultStorageSettings($type), $definition['class']::defaultStorageSettings(), format_string("%type storage settings were returned", ['%type' => $type]));
+ $this->assertIdentical($field_type_manager->getDefaultFieldSettings($type), $definition['class']::defaultFieldSettings(), format_string(" %type field settings were returned", ['%type' => $type]));
}
}
@@ -32,7 +32,7 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
public function testCreateInstance() {
/** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager */
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
- foreach (array('test_field', 'shape', 'hidden_test_field') as $type) {
+ foreach (['test_field', 'shape', 'hidden_test_field'] as $type) {
$definition = $field_type_manager->getDefinition($type);
$class = $definition['class'];
@@ -40,16 +40,16 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
$field_definition = BaseFieldDefinition::create($type);
- $configuration = array(
+ $configuration = [
'field_definition' => $field_definition,
'name' => $field_name,
'parent' => NULL,
- );
+ ];
$instance = $field_type_manager->createInstance($type, $configuration);
- $this->assertTrue($instance instanceof $class, SafeMarkup::format('Created a @class instance', array('@class' => $class)));
- $this->assertEqual($field_name, $instance->getName(), SafeMarkup::format('Instance name is @name', array('@name' => $field_name)));
+ $this->assertTrue($instance instanceof $class, SafeMarkup::format('Created a @class instance', ['@class' => $class]));
+ $this->assertEqual($field_name, $instance->getName(), SafeMarkup::format('Instance name is @name', ['@name' => $field_name]));
}
}
@@ -69,18 +69,18 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
->setLabel('Jenny')
->setDefaultValue(8675309);
- $configuration = array(
+ $configuration = [
'field_definition' => $field_definition,
'name' => $field_name,
'parent' => NULL,
- );
+ ];
$entity = EntityTest::create();
$instance = $field_type_manager->createInstance($type, $configuration);
- $this->assertTrue($instance instanceof $class, SafeMarkup::format('Created a @class instance', array('@class' => $class)));
- $this->assertEqual($field_name, $instance->getName(), SafeMarkup::format('Instance name is @name', array('@name' => $field_name)));
+ $this->assertTrue($instance instanceof $class, SafeMarkup::format('Created a @class instance', ['@class' => $class]));
+ $this->assertEqual($field_name, $instance->getName(), SafeMarkup::format('Instance name is @name', ['@name' => $field_name]));
$this->assertEqual($instance->getFieldDefinition()->getLabel(), 'Jenny', 'Instance label is Jenny');
$this->assertEqual($instance->getFieldDefinition()->getDefaultValue($entity), [['value' => 8675309]], 'Instance default_value is 8675309');
}
diff --git a/core/modules/field/tests/src/Kernel/FieldValidationTest.php b/core/modules/field/tests/src/Kernel/FieldValidationTest.php
index 3715832d532..5eac7734b93 100644
--- a/core/modules/field/tests/src/Kernel/FieldValidationTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldValidationTest.php
@@ -34,9 +34,9 @@ class FieldValidationTest extends FieldKernelTestBase {
$this->createFieldWithStorage('', $this->entityType, $this->bundle);
// Create an 'entity_test' entity.
- $this->entity = entity_create($this->entityType, array(
+ $this->entity = entity_create($this->entityType, [
'type' => $this->bundle,
- ));
+ ]);
}
/**
@@ -47,7 +47,7 @@ class FieldValidationTest extends FieldKernelTestBase {
$entity = $this->entity;
for ($delta = 0; $delta < $cardinality + 1; $delta++) {
- $entity->{$this->fieldTestData->field_name}[] = array('value' => 1);
+ $entity->{$this->fieldTestData->field_name}[] = ['value' => 1];
}
// Validate the field.
@@ -56,7 +56,7 @@ class FieldValidationTest extends FieldKernelTestBase {
// Check that the expected constraint violations are reported.
$this->assertEqual(count($violations), 1);
$this->assertEqual($violations[0]->getPropertyPath(), '');
- $this->assertEqual($violations[0]->getMessage(), t('%name: this field cannot hold more than @count values.', array('%name' => $this->fieldTestData->field->getLabel(), '@count' => $cardinality)));
+ $this->assertEqual($violations[0]->getMessage(), t('%name: this field cannot hold more than @count values.', ['%name' => $this->fieldTestData->field->getLabel(), '@count' => $cardinality]));
}
/**
@@ -70,7 +70,7 @@ class FieldValidationTest extends FieldKernelTestBase {
$this->assertTrue($cardinality >= 2);
// Set up values for the field.
- $expected_violations = array();
+ $expected_violations = [];
for ($delta = 0; $delta < $cardinality; $delta++) {
// All deltas except '1' have incorrect values.
if ($delta == 1) {
@@ -78,7 +78,7 @@ class FieldValidationTest extends FieldKernelTestBase {
}
else {
$value = -1;
- $expected_violations[$delta . '.value'][] = t('%name does not accept the value -1.', array('%name' => $this->fieldTestData->field->getLabel()));
+ $expected_violations[$delta . '.value'][] = t('%name does not accept the value -1.', ['%name' => $this->fieldTestData->field->getLabel()]);
}
$entity->{$this->fieldTestData->field_name}[] = $value;
}
@@ -87,7 +87,7 @@ class FieldValidationTest extends FieldKernelTestBase {
$violations = $entity->{$this->fieldTestData->field_name}->validate();
// Check that the expected constraint violations are reported.
- $violations_by_path = array();
+ $violations_by_path = [];
foreach ($violations as $violation) {
$violations_by_path[$violation->getPropertyPath()][] = $violation->getMessage();
}
diff --git a/core/modules/field/tests/src/Kernel/FormatterPluginManagerTest.php b/core/modules/field/tests/src/Kernel/FormatterPluginManagerTest.php
index 4425a44eb18..0b07e3ad9b8 100644
--- a/core/modules/field/tests/src/Kernel/FormatterPluginManagerTest.php
+++ b/core/modules/field/tests/src/Kernel/FormatterPluginManagerTest.php
@@ -24,13 +24,13 @@ class FormatterPluginManagerTest extends FieldKernelTestBase {
// Set a name that will make isApplicable() return TRUE.
->setName('field_test_field');
- $formatter_options = array(
+ $formatter_options = [
'field_definition' => $base_field_definition,
'view_mode' => 'default',
- 'configuration' => array(
+ 'configuration' => [
'type' => 'field_test_applicable',
- ),
- );
+ ],
+ ];
$instance = $formatter_plugin_manager->getInstance($formatter_options);
$this->assertEqual($instance->getPluginId(), 'field_test_applicable');
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php
index 2ee3c779bc0..edf6dc0b212 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php
@@ -26,14 +26,14 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
public function testEntityDisplaySettings() {
// Run tests.
$field_name = "field_test";
- $expected = array(
+ $expected = [
'label' => 'above',
'weight' => 1,
'type' => 'text_trimmed',
- 'settings' => array('trim_length' => 600),
- 'third_party_settings' => array(),
+ 'settings' => ['trim_length' => 600],
+ 'third_party_settings' => [],
'region' => 'content',
- );
+ ];
// Can we load any entity display.
$display = EntityViewDisplay::load('node.story.teaser');
@@ -51,7 +51,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
// Test the default format with text_default which comes from a static map.
$expected['type'] = 'text_default';
- $expected['settings'] = array();
+ $expected['settings'] = [];
$display = EntityViewDisplay::load('node.story.default');
$this->assertIdentical($expected, $display->getComponent($field_name));
@@ -66,40 +66,40 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
// Test the number field formatter settings are correct.
$expected['weight'] = 1;
$expected['type'] = 'number_integer';
- $expected['settings'] = array(
+ $expected['settings'] = [
'thousand_separator' => ',',
'prefix_suffix' => TRUE,
- );
+ ];
$component = $display->getComponent('field_test_two');
$this->assertIdentical($expected, $component);
$expected['weight'] = 2;
$expected['type'] = 'number_decimal';
- $expected['settings'] = array(
+ $expected['settings'] = [
'scale' => 2,
'decimal_separator' => '.',
'thousand_separator' => ',',
'prefix_suffix' => TRUE,
- );
+ ];
$component = $display->getComponent('field_test_three');
$this->assertIdentical($expected, $component);
// Test the email field formatter settings are correct.
$expected['weight'] = 6;
$expected['type'] = 'email_mailto';
- $expected['settings'] = array();
+ $expected['settings'] = [];
$component = $display->getComponent('field_test_email');
$this->assertIdentical($expected, $component);
// Test the link field formatter settings.
$expected['weight'] = 7;
$expected['type'] = 'link';
- $expected['settings'] = array(
+ $expected['settings'] = [
'trim_length' => 80,
'url_only' => TRUE,
'url_plain' => TRUE,
'rel' => '0',
'target' => '0',
- );
+ ];
$component = $display->getComponent('field_test_link');
$this->assertIdentical($expected, $component);
$expected['settings']['url_only'] = FALSE;
@@ -111,7 +111,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
// Test the file field formatter settings.
$expected['weight'] = 8;
$expected['type'] = 'file_default';
- $expected['settings'] = array();
+ $expected['settings'] = [];
$component = $display->getComponent('field_test_filefield');
$this->assertIdentical($expected, $component);
$display = EntityViewDisplay::load('node.story.default');
@@ -122,7 +122,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
// Test the image field formatter settings.
$expected['weight'] = 9;
$expected['type'] = 'image';
- $expected['settings'] = array('image_style' => '', 'image_link' => '');
+ $expected['settings'] = ['image_style' => '', 'image_link' => ''];
$component = $display->getComponent('field_test_imagefield');
$this->assertIdentical($expected, $component);
$display = EntityViewDisplay::load('node.story.teaser');
@@ -133,15 +133,15 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
// Test phone field.
$expected['weight'] = 13;
$expected['type'] = 'basic_string';
- $expected['settings'] = array();
+ $expected['settings'] = [];
$component = $display->getComponent('field_test_phone');
$this->assertIdentical($expected, $component);
// Test date field.
- $defaults = array('format_type' => 'fallback', 'timezone_override' => '',);
+ $defaults = ['format_type' => 'fallback', 'timezone_override' => '',];
$expected['weight'] = 10;
$expected['type'] = 'datetime_default';
- $expected['settings'] = array('format_type' => 'fallback') + $defaults;
+ $expected['settings'] = ['format_type' => 'fallback'] + $defaults;
$component = $display->getComponent('field_test_date');
$this->assertIdentical($expected, $component);
$display = EntityViewDisplay::load('node.story.default');
@@ -155,13 +155,13 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
$component = $display->getComponent('field_test_datestamp');
$this->assertIdentical($expected, $component);
$display = EntityViewDisplay::load('node.story.teaser');
- $expected['settings'] = array('format_type' => 'medium') + $defaults;
+ $expected['settings'] = ['format_type' => 'medium'] + $defaults;
$component = $display->getComponent('field_test_datestamp');
$this->assertIdentical($expected, $component);
// Test datetime field.
$expected['weight'] = 12;
- $expected['settings'] = array('format_type' => 'short') + $defaults;
+ $expected['settings'] = ['format_type' => 'short'] + $defaults;
$component = $display->getComponent('field_test_datetime');
$this->assertIdentical($expected, $component);
$display = EntityViewDisplay::load('node.story.default');
@@ -176,7 +176,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
$component = $display->getComponent('field_test_datetime');
$this->assertIdentical($expected, $component);
// Test that our Id map has the correct data.
- $this->assertIdentical(array('node', 'story', 'teaser', 'field_test'), $this->getMigration('d6_field_formatter_settings')->getIdMap()->lookupDestinationID(array('story', 'teaser', 'node', 'field_test')));
+ $this->assertIdentical(['node', 'story', 'teaser', 'field_test'], $this->getMigration('d6_field_formatter_settings')->getIdMap()->lookupDestinationID(['story', 'teaser', 'node', 'field_test']));
}
}
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php
index b3fac3fc585..b1eec356235 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldInstanceTest.php
@@ -32,24 +32,24 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
// Test a number field.
$field = FieldConfig::load('node.story.field_test_two');
$this->assertIdentical('Integer Field', $field->label());
- $expected = array(
+ $expected = [
'min' => 10,
'max' => 100,
'prefix' => 'pref',
'suffix' => 'suf',
'unsigned' => FALSE,
'size' => 'normal',
- );
+ ];
$this->assertIdentical($expected, $field->getSettings());
$field = FieldConfig::load('node.story.field_test_four');
$this->assertIdentical('Float Field', $field->label());
- $expected = array(
+ $expected = [
'min' => 100.0,
'max' => 200.0,
'prefix' => 'id-',
'suffix' => '',
- );
+ ];
$this->assertIdentical($expected, $field->getSettings());
// Test email field.
@@ -70,7 +70,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
// Test a filefield.
$field = FieldConfig::load('node.story.field_test_filefield');
$this->assertIdentical('File Field', $field->label());
- $expected = array(
+ $expected = [
'file_extensions' => 'txt pdf doc',
'file_directory' => 'images',
'description_field' => TRUE,
@@ -80,8 +80,8 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
'display_default' => FALSE,
'uri_scheme' => 'public',
'handler' => 'default:file',
- 'handler_settings' => array(),
- );
+ 'handler_settings' => [],
+ ];
$field_settings = $field->getSettings();
ksort($expected);
ksort($field_settings);
@@ -91,7 +91,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
// Test a link field.
$field = FieldConfig::load('node.story.field_test_link');
$this->assertIdentical('Link Field', $field->label());
- $expected = array('title' => 2, 'link_type' => LinkItemInterface::LINK_GENERIC);
+ $expected = ['title' => 2, 'link_type' => LinkItemInterface::LINK_GENERIC];
$this->assertIdentical($expected, $field->getSettings());
$this->assertIdentical('default link title', $entity->field_test_link->title, 'Field field_test_link default title is correct.');
$this->assertIdentical('https://www.drupal.org', $entity->field_test_link->url, 'Field field_test_link default title is correct.');
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php
index ea3fec8dd1c..690016172fe 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldTest.php
@@ -33,38 +33,38 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
// Integer field.
$field_storage = FieldStorageConfig::load('node.field_test_two');
- $this->assertIdentical("integer", $field_storage->getType(), t('Field type is @fieldtype. It should be integer.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("integer", $field_storage->getType(), t('Field type is @fieldtype. It should be integer.', ['@fieldtype' => $field_storage->getType()]));
// Float field.
$field_storage = FieldStorageConfig::load('node.field_test_three');
- $this->assertIdentical("decimal", $field_storage->getType(), t('Field type is @fieldtype. It should be decimal.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("decimal", $field_storage->getType(), t('Field type is @fieldtype. It should be decimal.', ['@fieldtype' => $field_storage->getType()]));
// Link field.
$field_storage = FieldStorageConfig::load('node.field_test_link');
- $this->assertIdentical("link", $field_storage->getType(), t('Field type is @fieldtype. It should be link.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("link", $field_storage->getType(), t('Field type is @fieldtype. It should be link.', ['@fieldtype' => $field_storage->getType()]));
// File field.
$field_storage = FieldStorageConfig::load('node.field_test_filefield');
- $this->assertIdentical("file", $field_storage->getType(), t('Field type is @fieldtype. It should be file.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("file", $field_storage->getType(), t('Field type is @fieldtype. It should be file.', ['@fieldtype' => $field_storage->getType()]));
$field_storage = FieldStorageConfig::load('node.field_test_imagefield');
- $this->assertIdentical("image", $field_storage->getType(), t('Field type is @fieldtype. It should be image.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("image", $field_storage->getType(), t('Field type is @fieldtype. It should be image.', ['@fieldtype' => $field_storage->getType()]));
$settings = $field_storage->getSettings();
$this->assertIdentical('file', $settings['target_type']);
$this->assertIdentical('public', $settings['uri_scheme']);
- $this->assertIdentical(array(), array_filter($settings['default_image']));
+ $this->assertIdentical([], array_filter($settings['default_image']));
// Phone field.
$field_storage = FieldStorageConfig::load('node.field_test_phone');
- $this->assertIdentical("telephone", $field_storage->getType(), t('Field type is @fieldtype. It should be telephone.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("telephone", $field_storage->getType(), t('Field type is @fieldtype. It should be telephone.', ['@fieldtype' => $field_storage->getType()]));
// Date field.
$field_storage = FieldStorageConfig::load('node.field_test_datetime');
- $this->assertIdentical("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', ['@fieldtype' => $field_storage->getType()]));
// Decimal field with radio buttons.
$field_storage = FieldStorageConfig::load('node.field_test_decimal_radio_buttons');
- $this->assertIdentical("list_float", $field_storage->getType(), t('Field type is @fieldtype. It should be list_float.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("list_float", $field_storage->getType(), t('Field type is @fieldtype. It should be list_float.', ['@fieldtype' => $field_storage->getType()]));
$this->assertNotNull($field_storage->getSetting('allowed_values')['1.2'], t('First allowed value key is set to 1.2'));
$this->assertNotNull($field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value key is set to 2.1'));
$this->assertIdentical('1.2', $field_storage->getSetting('allowed_values')['1.2'], t('First allowed value is set to 1.2'));
@@ -72,11 +72,11 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
// Float field with a single checkbox.
$field_storage = FieldStorageConfig::load('node.field_test_float_single_checkbox');
- $this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', ['@fieldtype' => $field_storage->getType()]));
// Integer field with a select list.
$field_storage = FieldStorageConfig::load('node.field_test_integer_selectlist');
- $this->assertIdentical("list_integer", $field_storage->getType(), t('Field type is @fieldtype. It should be list_integer.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("list_integer", $field_storage->getType(), t('Field type is @fieldtype. It should be list_integer.', ['@fieldtype' => $field_storage->getType()]));
$this->assertNotNull($field_storage->getSetting('allowed_values')['1234'], t('First allowed value key is set to 1234'));
$this->assertNotNull($field_storage->getSetting('allowed_values')['2341'], t('Second allowed value key is set to 2341'));
$this->assertNotNull($field_storage->getSetting('allowed_values')['3412'], t('Third allowed value key is set to 3412'));
@@ -88,7 +88,7 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
// Text field with a single checkbox.
$field_storage = FieldStorageConfig::load('node.field_test_text_single_checkbox');
- $this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
+ $this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', ['@fieldtype' => $field_storage->getType()]));
// Validate that the source count and processed count match up.
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php
index e7bb63621a0..2a9dd1baef2 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldWidgetSettingsTest.php
@@ -30,9 +30,9 @@ class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
// Text field.
$component = $form_display->getComponent('field_test');
- $expected = array('weight' => 1, 'type' => 'text_textfield');
- $expected['settings'] = array('size' => 60, 'placeholder' => '');
- $expected['third_party_settings'] = array();
+ $expected = ['weight' => 1, 'type' => 'text_textfield'];
+ $expected['settings'] = ['size' => 60, 'placeholder' => ''];
+ $expected['third_party_settings'] = [];
$expected['region'] = 'content';
$this->assertIdentical($expected, $component, 'Text field settings are correct.');
@@ -40,7 +40,7 @@ class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
$component = $form_display->getComponent('field_test_two');
$expected['type'] = 'number';
$expected['weight'] = 1;
- $expected['settings'] = array('placeholder' => '');
+ $expected['settings'] = ['placeholder' => ''];
$this->assertIdentical($expected, $component);
// Float field.
@@ -52,7 +52,7 @@ class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
$component = $form_display->getComponent('field_test_email');
$expected['type'] = 'email_default';
$expected['weight'] = 6;
- $expected['settings'] = array('placeholder' => '', 'size' => 60);
+ $expected['settings'] = ['placeholder' => '', 'size' => 60];
$this->assertIdentical($expected, $component);
// Link field.
@@ -65,28 +65,28 @@ class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
$component = $form_display->getComponent('field_test_filefield');
$expected['type'] = 'file_generic';
$expected['weight'] = 8;
- $expected['settings'] = array('progress_indicator' => 'bar');
+ $expected['settings'] = ['progress_indicator' => 'bar'];
$this->assertIdentical($expected, $component);
// Image field.
$component = $form_display->getComponent('field_test_imagefield');
$expected['type'] = 'image_image';
$expected['weight'] = 9;
- $expected['settings'] = array('progress_indicator' => 'bar', 'preview_image_style' => 'thumbnail');
+ $expected['settings'] = ['progress_indicator' => 'bar', 'preview_image_style' => 'thumbnail'];
$this->assertIdentical($expected, $component);
// Phone field.
$component = $form_display->getComponent('field_test_phone');
$expected['type'] = 'telephone_default';
$expected['weight'] = 13;
- $expected['settings'] = array('placeholder' => '');
+ $expected['settings'] = ['placeholder' => ''];
$this->assertIdentical($expected, $component);
// Date fields.
$component = $form_display->getComponent('field_test_date');
$expected['type'] = 'datetime_default';
$expected['weight'] = 10;
- $expected['settings'] = array();
+ $expected['settings'] = [];
$this->assertIdentical($expected, $component);
$component = $form_display->getComponent('field_test_datestamp');
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php
index 14f37cb4160..dd38569de14 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldFormatterSettingsTest.php
@@ -96,40 +96,40 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
// an "unsupported operand types" fatal).
Database::getConnection('default', 'migrate')
->update('field_config_instance')
- ->fields(array(
- 'data' => serialize(array (
+ ->fields([
+ 'data' => serialize( [
'label' => 'Body',
'widget' =>
- array (
+ [
'type' => 'text_textarea_with_summary',
'settings' =>
- array (
+ [
'rows' => 20,
'summary_rows' => 5,
- ),
+ ],
'weight' => -4,
'module' => 'text',
- ),
+ ],
'settings' =>
- array (
+ [
'display_summary' => TRUE,
'text_processing' => 1,
'user_register_form' => FALSE,
- ),
+ ],
'display' =>
- array (
+ [
'default' =>
- array (
+ [
'label' => 'hidden',
'type' => 'text_default',
'settings' =>
- array (
- ),
+ [
+ ],
'module' => 'text',
'weight' => 0,
- ),
+ ],
'teaser' =>
- array (
+ [
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
// settings is always expected to be an array. Making it NULL
@@ -137,12 +137,12 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
'settings' => NULL,
'module' => 'text',
'weight' => 0,
- ),
- ),
+ ],
+ ],
'required' => FALSE,
'description' => '',
- )),
- ))
+ ]),
+ ])
->condition('entity_type', 'node')
->condition('bundle', 'article')
->condition('field_name', 'body')
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php
index c50c3241fbb..1e3df9e4fc8 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php
@@ -21,7 +21,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'comment',
'datetime',
'file',
@@ -32,7 +32,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
'taxonomy',
'telephone',
'text',
- );
+ ];
/**
* {@inheritdoc}
@@ -57,16 +57,16 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
* The node type ID.
*/
protected function createType($id) {
- NodeType::create(array(
+ NodeType::create([
'type' => $id,
'label' => $this->randomString(),
- ))->save();
+ ])->save();
- CommentType::create(array(
+ CommentType::create([
'id' => 'comment_node_' . $id,
'label' => $this->randomString(),
'target_entity_type_id' => 'node',
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php
index 7f2e0244f82..5a47e38ef72 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceWidgetSettingsTest.php
@@ -18,7 +18,7 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'comment',
'datetime',
'field',
@@ -29,7 +29,7 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
'taxonomy',
'telephone',
'text',
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php
index 4a0f8cde569..ab2fe8e1258 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php
@@ -18,7 +18,7 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'comment',
'datetime',
'file',
@@ -29,7 +29,7 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
'taxonomy',
'telephone',
'text',
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php b/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php
index 25b99bbe7df..578eeda9c63 100644
--- a/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php
+++ b/core/modules/field/tests/src/Kernel/Number/NumberItemTest.php
@@ -21,18 +21,18 @@ class NumberItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array();
+ public static $modules = [];
protected function setUp() {
parent::setUp();
// Create number field storages and fields for validation.
- foreach (array('integer', 'float', 'decimal') as $type) {
- FieldStorageConfig::create(array(
+ foreach (['integer', 'float', 'decimal'] as $type) {
+ FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_' . $type,
'type' => $type,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_' . $type,
diff --git a/core/modules/field/tests/src/Kernel/ShapeItemTest.php b/core/modules/field/tests/src/Kernel/ShapeItemTest.php
index 644a15f1465..80ab04f3a9b 100644
--- a/core/modules/field/tests/src/Kernel/ShapeItemTest.php
+++ b/core/modules/field/tests/src/Kernel/ShapeItemTest.php
@@ -20,7 +20,7 @@ class ShapeItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('field_test');
+ public static $modules = ['field_test'];
/**
* The name of the field to use in this test.
@@ -33,11 +33,11 @@ class ShapeItemTest extends FieldKernelTestBase {
parent::setUp();
// Create a 'shape' field and storage for validation.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'shape',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
diff --git a/core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php b/core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php
index 02d72d04732..1000d640789 100644
--- a/core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php
+++ b/core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php
@@ -23,7 +23,7 @@ class RawStringFormatterTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('field', 'text', 'entity_test', 'system', 'filter', 'user');
+ public static $modules = ['field', 'text', 'entity_test', 'system', 'filter', 'user'];
/**
* @var string
@@ -52,7 +52,7 @@ class RawStringFormatterTest extends KernelTestBase {
parent::setUp();
// Configure the theme system.
- $this->installConfig(array('system', 'field'));
+ $this->installConfig(['system', 'field']);
\Drupal::service('router.builder')->rebuild();
$this->installEntitySchema('entity_test');
@@ -60,25 +60,25 @@ class RawStringFormatterTest extends KernelTestBase {
$this->bundle = $this->entityType;
$this->fieldName = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $this->entityType,
'type' => 'string_long',
- ));
+ ]);
$field_storage->save();
- $instance = FieldConfig::create(array(
+ $instance = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $this->bundle,
'label' => $this->randomMachineName(),
- ));
+ ]);
$instance->save();
$this->display = entity_get_display($this->entityType, $this->bundle, 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'string',
- 'settings' => array(),
- ));
+ 'settings' => [],
+ ]);
$this->display->save();
}
@@ -107,7 +107,7 @@ class RawStringFormatterTest extends KernelTestBase {
$value .= "\n\n<strong>" . $this->randomString() . '</strong>';
$value .= "\n\n" . $this->randomString();
- $entity = EntityTest::create(array());
+ $entity = EntityTest::create([]);
$entity->{$this->fieldName}->value = $value;
// Verify that all HTML is escaped and newlines are retained.
diff --git a/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php b/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php
index b52a92fd28f..b09eb58c091 100644
--- a/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php
+++ b/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php
@@ -23,7 +23,7 @@ class StringFormatterTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('field', 'text', 'entity_test', 'system', 'filter', 'user');
+ public static $modules = ['field', 'text', 'entity_test', 'system', 'filter', 'user'];
/**
* @var string
@@ -52,7 +52,7 @@ class StringFormatterTest extends KernelTestBase {
parent::setUp();
// Configure the theme system.
- $this->installConfig(array('system', 'field'));
+ $this->installConfig(['system', 'field']);
\Drupal::service('router.builder')->rebuild();
$this->installEntitySchema('entity_test_rev');
@@ -60,25 +60,25 @@ class StringFormatterTest extends KernelTestBase {
$this->bundle = $this->entityType;
$this->fieldName = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $this->entityType,
'type' => 'string',
- ));
+ ]);
$field_storage->save();
- $instance = FieldConfig::create(array(
+ $instance = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $this->bundle,
'label' => $this->randomMachineName(),
- ));
+ ]);
$instance->save();
$this->display = entity_get_display($this->entityType, $this->bundle, 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'string',
- 'settings' => array(),
- ));
+ 'settings' => [],
+ ]);
$this->display->save();
}
@@ -107,7 +107,7 @@ class StringFormatterTest extends KernelTestBase {
$value .= "\n\n<strong>" . $this->randomString() . '</strong>';
$value .= "\n\n" . $this->randomString();
- $entity = EntityTestRev::create(array());
+ $entity = EntityTestRev::create([]);
$entity->{$this->fieldName}->value = $value;
// Verify that all HTML is escaped and newlines are retained.
diff --git a/core/modules/field/tests/src/Kernel/TestItemTest.php b/core/modules/field/tests/src/Kernel/TestItemTest.php
index 6766b4099f2..73a99486b6c 100644
--- a/core/modules/field/tests/src/Kernel/TestItemTest.php
+++ b/core/modules/field/tests/src/Kernel/TestItemTest.php
@@ -21,7 +21,7 @@ class TestItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('field_test');
+ public static $modules = ['field_test'];
/**
* The name of the field to use in this test.
@@ -34,11 +34,11 @@ class TestItemTest extends FieldKernelTestBase {
parent::setUp();
// Create a 'test_field' field and storage for validation.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'test_field',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
@@ -76,19 +76,19 @@ class TestItemTest extends FieldKernelTestBase {
$this->assertEqual($entity->{$this->fieldName}->value, $new_value);
// Test the schema for this field type.
- $expected_schema = array(
- 'columns' => array(
- 'value' => array(
+ $expected_schema = [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
'size' => 'medium',
- ),
- ),
- 'unique keys' => array(),
- 'indexes' => array(
- 'value' => array('value'),
- ),
- 'foreign keys' => array(),
- );
+ ],
+ ],
+ 'unique keys' => [],
+ 'indexes' => [
+ 'value' => ['value'],
+ ],
+ 'foreign keys' => [],
+ ];
$field_schema = BaseFieldDefinition::create('test_field')->getSchema();
$this->assertEqual($field_schema, $expected_schema);
}
diff --git a/core/modules/field/tests/src/Kernel/TestItemWithDependenciesTest.php b/core/modules/field/tests/src/Kernel/TestItemWithDependenciesTest.php
index 9766a067fba..d1a269a6a26 100644
--- a/core/modules/field/tests/src/Kernel/TestItemWithDependenciesTest.php
+++ b/core/modules/field/tests/src/Kernel/TestItemWithDependenciesTest.php
@@ -17,7 +17,7 @@ class TestItemWithDependenciesTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('field_test');
+ public static $modules = ['field_test'];
/**
* The name of the field to use in this test.
@@ -31,11 +31,11 @@ class TestItemWithDependenciesTest extends FieldKernelTestBase {
*/
public function testTestItemWithDepenencies() {
// Create a 'test_field_with_dependencies' field and storage for validation.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'test_field_with_dependencies',
- ))->save();
+ ])->save();
$field = FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
diff --git a/core/modules/field/tests/src/Kernel/TestObjectItemTest.php b/core/modules/field/tests/src/Kernel/TestObjectItemTest.php
index 8a7875581c9..1ac87fc3b7f 100644
--- a/core/modules/field/tests/src/Kernel/TestObjectItemTest.php
+++ b/core/modules/field/tests/src/Kernel/TestObjectItemTest.php
@@ -18,7 +18,7 @@ class TestObjectItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('field_test');
+ public static $modules = ['field_test'];
/**
* {@inheritdoc}
@@ -27,11 +27,11 @@ class TestObjectItemTest extends FieldKernelTestBase {
parent::setUp();
// Create a 'test_field' field and storage for validation.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_test',
'entity_type' => 'entity_test',
'type' => 'test_object_field',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test',
diff --git a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php
index ee97cabbf8e..f71be314abf 100644
--- a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php
+++ b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php
@@ -140,7 +140,7 @@ class TimestampFormatterTest extends KernelTestBase {
public function testTimestampAgoFormatter() {
$data = [];
- foreach (array(1, 2, 3, 4, 5, 6) as $granularity) {
+ foreach ([1, 2, 3, 4, 5, 6] as $granularity) {
$data[] = [
'future_format' => '@interval hence',
'past_format' => '@interval ago',
diff --git a/core/modules/field/tests/src/Kernel/TranslationTest.php b/core/modules/field/tests/src/Kernel/TranslationTest.php
index 78172a38217..f1fffe60f7a 100644
--- a/core/modules/field/tests/src/Kernel/TranslationTest.php
+++ b/core/modules/field/tests/src/Kernel/TranslationTest.php
@@ -23,7 +23,7 @@ class TranslationTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('language', 'node');
+ public static $modules = ['language', 'node'];
/**
* The name of the field to use in this test.
@@ -73,33 +73,33 @@ class TranslationTest extends FieldKernelTestBase {
protected function setUp() {
parent::setUp();
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
$this->fieldName = Unicode::strtolower($this->randomMachineName());
$this->entityType = 'entity_test';
- $this->fieldStorageDefinition = array(
+ $this->fieldStorageDefinition = [
'field_name' => $this->fieldName,
'entity_type' => $this->entityType,
'type' => 'test_field',
'cardinality' => 4,
- );
+ ];
$this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
$this->fieldStorage->save();
- $this->fieldDefinition = array(
+ $this->fieldDefinition = [
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
- );
+ ];
$this->field = FieldConfig::create($this->fieldDefinition);
$this->field->save();
for ($i = 0; $i < 3; ++$i) {
- ConfigurableLanguage::create(array(
+ ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this->randomString(),
- ))->save();
+ ])->save();
}
}
@@ -117,8 +117,8 @@ class TranslationTest extends FieldKernelTestBase {
field_test_entity_info_translatable($entity_type_id, TRUE);
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type_id)
- ->create(array('type' => $this->field->getTargetBundle()));
- $field_translations = array();
+ ->create(['type' => $this->field->getTargetBundle()]);
+ $field_translations = [];
$available_langcodes = array_keys($this->container->get('language_manager')->getLanguages());
$entity->langcode->value = reset($available_langcodes);
foreach ($available_langcodes as $langcode) {
@@ -136,7 +136,7 @@ class TranslationTest extends FieldKernelTestBase {
foreach ($items as $delta => $item) {
$result = $result && $item['value'] == $entity->getTranslation($langcode)->{$this->fieldName}[$delta]->value;
}
- $this->assertTrue($result, format_string('%language translation correctly handled.', array('%language' => $langcode)));
+ $this->assertTrue($result, format_string('%language translation correctly handled.', ['%language' => $langcode]));
}
// Test default values.
@@ -148,7 +148,7 @@ class TranslationTest extends FieldKernelTestBase {
$field_definition = $this->fieldDefinition;
$field_definition['field_storage'] = $field_storage;
- $field_definition['default_value'] = array(array('value' => rand(1, 127)));
+ $field_definition['default_value'] = [['value' => rand(1, 127)]];
$field = FieldConfig::create($field_definition);
$field->save();
@@ -156,7 +156,7 @@ class TranslationTest extends FieldKernelTestBase {
asort($translation_langcodes);
$translation_langcodes = array_values($translation_langcodes);
- $values = array('type' => $field->getTargetBundle(), 'langcode' => $translation_langcodes[0]);
+ $values = ['type' => $field->getTargetBundle(), 'langcode' => $translation_langcodes[0]];
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type_id)
->create($values);
@@ -173,11 +173,11 @@ class TranslationTest extends FieldKernelTestBase {
// @todo Test every translation once the Entity Translation API allows for
// multilingual defaults.
$langcode = $entity->language()->getId();
- $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $field->getDefaultValueLiteral(), format_string('Default value correctly populated for language %language.', array('%language' => $langcode)));
+ $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $field->getDefaultValueLiteral(), format_string('Default value correctly populated for language %language.', ['%language' => $langcode]));
// Check that explicit empty values are not overridden with default values.
- foreach (array(NULL, array()) as $empty_items) {
- $values = array('type' => $field->getTargetBundle(), 'langcode' => $translation_langcodes[0]);
+ foreach ([NULL, []] as $empty_items) {
+ $values = ['type' => $field->getTargetBundle(), 'langcode' => $translation_langcodes[0]];
$entity = entity_create($entity_type_id, $values);
foreach ($translation_langcodes as $langcode) {
$values[$this->fieldName][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality());
@@ -188,7 +188,7 @@ class TranslationTest extends FieldKernelTestBase {
}
foreach ($entity->getTranslationLanguages() as $langcode => $language) {
- $this->assertEquals([], $entity->getTranslation($langcode)->{$field_name_default}->getValue(), format_string('Empty value correctly populated for language %language.', array('%language' => $langcode)));
+ $this->assertEquals([], $entity->getTranslation($langcode)->{$field_name_default}->getValue(), format_string('Empty value correctly populated for language %language.', ['%language' => $langcode]));
}
}
}
diff --git a/core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php b/core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php
index 3eff2ca248f..47edb9f7746 100644
--- a/core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php
+++ b/core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php
@@ -33,13 +33,13 @@ class WidgetPluginManagerTest extends FieldKernelTestBase {
// Set a name that will make isApplicable() return TRUE.
->setName('field_multiwidgetfield');
- $widget_options = array(
+ $widget_options = [
'field_definition' => $base_field_definition,
'form_mode' => 'default',
- 'configuration' => array(
+ 'configuration' => [
'type' => 'test_field_widget_multiple',
- ),
- );
+ ],
+ ];
$instance = $widget_plugin_manager->getInstance($widget_options);
$this->assertEqual($instance->getPluginId(), 'test_field_widget_multiple');
diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php
index 3f687d4b9fc..3a0c8aa75ce 100644
--- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php
+++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php
@@ -100,14 +100,14 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
->will($this->returnValue('field_test'));
$this->fieldStorage->expects($this->any())
->method('getSettings')
- ->willReturn(array());
+ ->willReturn([]);
// Place the field in the mocked entity manager's field registry.
$this->entityManager->expects($this->any())
->method('getFieldStorageDefinitions')
->with('test_entity_type')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
$this->fieldStorage->getName() => $this->fieldStorage,
- )));
+ ]));
}
/**
@@ -118,7 +118,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getBundleConfigDependency')
- ->will($this->returnValue(array('type' => 'config', 'name' => 'test.test_entity_type.id')));
+ ->will($this->returnValue(['type' => 'config', 'name' => 'test.test_entity_type.id']));
$this->entityManager->expects($this->at(0))
->method('getDefinition')
@@ -146,12 +146,12 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
->method('getConfigDependencyName')
->will($this->returnValue('field.storage.test_entity_type.test_field'));
- $field = new FieldConfig(array(
+ $field = new FieldConfig([
'field_name' => $this->fieldStorage->getName(),
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
'field_type' => 'test_field',
- ), $this->entityTypeId);
+ ], $this->entityTypeId);
$dependencies = $field->calculateDependencies()->getDependencies();
$this->assertContains('field.storage.test_entity_type.test_field', $dependencies['config']);
$this->assertContains('test.test_entity_type.id', $dependencies['config']);
@@ -176,10 +176,10 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
->with('bundle_entity_type')
->will($this->returnValue($storage));
- $target_entity_type = new EntityType(array(
+ $target_entity_type = new EntityType([
'id' => 'test_entity_type',
'bundle_entity_type' => 'bundle_entity_type',
- ));
+ ]);
$this->entityManager->expects($this->at(0))
->method('getDefinition')
@@ -203,12 +203,12 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
->with('test_field')
->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']);
- $field = new FieldConfig(array(
+ $field = new FieldConfig([
'field_name' => $this->fieldStorage->getName(),
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle_not_exists',
'field_type' => 'test_field',
- ), $this->entityTypeId);
+ ], $this->entityTypeId);
$field->calculateDependencies();
}
@@ -245,14 +245,14 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
* @covers ::toArray
*/
public function testToArray() {
- $field = new FieldConfig(array(
+ $field = new FieldConfig([
'field_name' => $this->fieldStorage->getName(),
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
'field_type' => 'test_field',
- ), $this->entityTypeId);
+ ], $this->entityTypeId);
- $expected = array(
+ $expected = [
'id' => 'test_entity_type.test_bundle.field_test',
'uuid' => NULL,
'status' => TRUE,
@@ -263,12 +263,12 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
'label' => '',
'description' => '',
'required' => FALSE,
- 'default_value' => array(),
+ 'default_value' => [],
'default_value_callback' => '',
- 'settings' => array(),
- 'dependencies' => array(),
+ 'settings' => [],
+ 'dependencies' => [],
'field_type' => 'test_field',
- );
+ ];
$this->entityManager->expects($this->any())
->method('getDefinition')
->with($this->entityTypeId)
@@ -279,7 +279,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
->will($this->returnValue('id'));
$this->typedConfigManager->expects($this->once())
->method('getDefinition')
- ->will($this->returnValue(array('mapping' => array_fill_keys(array_keys($expected), ''))));
+ ->will($this->returnValue(['mapping' => array_fill_keys(array_keys($expected), '')]));
$export = $field->toArray();
$this->assertEquals($expected, $export);
@@ -296,12 +296,12 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$this->fieldStorage->expects($this->never())
->method('getType');
- $field = new FieldConfig(array(
+ $field = new FieldConfig([
'field_name' => $this->fieldStorage->getName(),
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
'field_type' => 'test_field',
- ), $this->entityTypeId);
+ ], $this->entityTypeId);
$this->assertEquals('test_field', $field->getType());
}
diff --git a/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php
index edeef211224..df18fec0aad 100644
--- a/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php
+++ b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php
@@ -36,32 +36,32 @@ class FieldSettingsTest extends UnitTestCase {
* Provides field settings for testGetSettings().
*/
public function getSettingsProvider() {
- return array(
- array(
+ return [
+ [
'list_integer',
- array('allowed_values' => "1|One\n2|Two\n3"),
- array(
+ ['allowed_values' => "1|One\n2|Two\n3"],
+ [
'1' => 'One',
'2' => 'Two',
'3' => '3',
- ),
- ),
- array(
+ ],
+ ],
+ [
'list_string',
- array('allowed_values' => NULL),
- array(),
- ),
- array(
+ ['allowed_values' => NULL],
+ [],
+ ],
+ [
'list_float',
- array('allowed_values' => ""),
- array(),
- ),
- array(
+ ['allowed_values' => ""],
+ [],
+ ],
+ [
'boolean',
- array(),
- array(),
- ),
- );
+ [],
+ [],
+ ],
+ ];
}
}
diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php
index 28cb246e69e..92cbaf2700e 100644
--- a/core/modules/field_ui/field_ui.api.php
+++ b/core/modules/field_ui/field_ui.api.php
@@ -30,15 +30,15 @@
* @see \Drupal\field_ui\DisplayOverView
*/
function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
- $element = array();
+ $element = [];
// Add a 'my_setting' checkbox to the settings form for 'foo_formatter' field
// formatters.
if ($plugin->getPluginId() == 'foo_formatter') {
- $element['my_setting'] = array(
+ $element['my_setting'] = [
'#type' => 'checkbox',
'#title' => t('My setting'),
'#default_value' => $plugin->getThirdPartySetting('my_module', 'my_setting'),
- );
+ ];
}
return $element;
}
@@ -63,15 +63,15 @@ function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\Forma
* @see \Drupal\field_ui\FormDisplayOverView
*/
function hook_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
- $element = array();
+ $element = [];
// Add a 'my_setting' checkbox to the settings form for 'foo_widget' field
// widgets.
if ($plugin->getPluginId() == 'foo_widget') {
- $element['my_setting'] = array(
+ $element['my_setting'] = [
'#type' => 'checkbox',
'#title' => t('My setting'),
'#default_value' => $plugin->getThirdPartySetting('my_module', 'my_setting'),
- );
+ ];
}
return $element;
}
diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module
index 5134cad26ef..79b3f151a59 100644
--- a/core/modules/field_ui/field_ui.module
+++ b/core/modules/field_ui/field_ui.module
@@ -22,7 +22,7 @@ function field_ui_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.field_ui':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Field UI module provides an administrative user interface (UI) for managing and displaying fields. Fields can be attached to most content entity sub-types. Different field types, widgets, and formatters are provided by the modules enabled on your site, and managed by the Field module. For background information and terminology related to fields and entities, see the <a href=":field">Field module help page</a>. For more information about the Field UI, see the <a href=":field_ui_docs">online documentation for the Field UI module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui_docs' => 'https://www.drupal.org/documentation/modules/field-ui')) . '</p>';
+ $output .= '<p>' . t('The Field UI module provides an administrative user interface (UI) for managing and displaying fields. Fields can be attached to most content entity sub-types. Different field types, widgets, and formatters are provided by the modules enabled on your site, and managed by the Field module. For background information and terminology related to fields and entities, see the <a href=":field">Field module help page</a>. For more information about the Field UI, see the <a href=":field_ui_docs">online documentation for the Field UI module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui_docs' => 'https://www.drupal.org/documentation/modules/field-ui']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating a field') . '</dt>';
@@ -34,9 +34,9 @@ function field_ui_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dt>' . t('Configuring field display') . '</dt>';
$output .= '<dd>' . t('On the <em>Manage display</em> page of your entity type or sub-type, you can configure how each field is displayed by default and in each view mode. If your entity type has multiple view modes, you can toggle between the view modes at the top of the page, and you can toggle whether each view mode uses the default settings or custom settings in the <em>Custom display settings</em> section. For each field in each view mode, you can choose whether and how to display the label of the field from the <em>Label</em> drop-down list. You can also select the formatter to use for display; some formatters have configuration options, which you can edit using the Edit button (which looks like a wheel). You can also change the display order of fields. You can exclude a field from a specific view mode by choosing <em>Hidden</em> from the formatter drop-down list, or by dragging it into the <em>Disabled</em> section.') . '</dd>';
$output .= '<dt>' . t('Configuring view and form modes') . '</dt>';
- $output .= '<dd>' . t('You can add, edit, and delete view modes for entities on the <a href=":view_modes">View modes page</a>, and you can add, edit, and delete form modes for entities on the <a href=":form_modes">Form modes page</a>. Once you have defined a view mode or form mode for an entity type, it will be available on the Manage display or Manage form display page for each sub-type of that entity.', array(':view_modes' => \Drupal::url('entity.entity_view_mode.collection'), ':form_modes' => \Drupal::url('entity.entity_form_mode.collection'))) . '</dd>';
+ $output .= '<dd>' . t('You can add, edit, and delete view modes for entities on the <a href=":view_modes">View modes page</a>, and you can add, edit, and delete form modes for entities on the <a href=":form_modes">Form modes page</a>. Once you have defined a view mode or form mode for an entity type, it will be available on the Manage display or Manage form display page for each sub-type of that entity.', [':view_modes' => \Drupal::url('entity.entity_view_mode.collection'), ':form_modes' => \Drupal::url('entity.entity_form_mode.collection')]) . '</dd>';
$output .= '<dt>' . t('Listing fields') . '</dt>';
- $output .= '<dd>' . t('There are two reports available that list the fields defined on your site. The <a href=":entity-list" title="Entities field list report">Entities</a> report lists all your fields, showing the field machine names, types, and the entity types or sub-types they are used on (each sub-type links to the Manage fields page). If the <a href=":views">Views</a> and <a href=":views-ui">Views UI</a> modules are enabled, the <a href=":views-list" title="Used in views field list report">Used in views</a> report lists each field that is used in a view, with a link to edit that view.', array(':entity-list' => \Drupal::url('entity.field_storage_config.collection'), ':views-list' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('views_ui.reports_fields') : '#', ':views' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', array('name' => 'views')) : '#', ':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', array('name' => 'views_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('There are two reports available that list the fields defined on your site. The <a href=":entity-list" title="Entities field list report">Entities</a> report lists all your fields, showing the field machine names, types, and the entity types or sub-types they are used on (each sub-type links to the Manage fields page). If the <a href=":views">Views</a> and <a href=":views-ui">Views UI</a> modules are enabled, the <a href=":views-list" title="Used in views field list report">Used in views</a> report lists each field that is used in a view, with a link to edit that view.', [':entity-list' => \Drupal::url('entity.field_storage_config.collection'), ':views-list' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('views_ui.reports_fields') : '#', ':views' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', ['name' => 'views']) : '#', ':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', ['name' => 'views_ui']) : '#']) . '</dd>';
$output .= '</dl>';
return $output;
@@ -49,21 +49,21 @@ function field_ui_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function field_ui_theme() {
- return array(
- 'field_ui_table' => array(
- 'variables' => array(
+ return [
+ 'field_ui_table' => [
+ 'variables' => [
'header' => NULL,
'rows' => NULL,
'footer' => NULL,
- 'attributes' => array(),
+ 'attributes' => [],
'caption' => NULL,
- 'colgroups' => array(),
+ 'colgroups' => [],
'sticky' => FALSE,
'responsive' => TRUE,
'empty' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -138,38 +138,38 @@ function field_ui_form_node_type_form_alter(&$form, FormStateInterface $form_sta
* Implements hook_entity_operation().
*/
function field_ui_entity_operation(EntityInterface $entity) {
- $operations = array();
+ $operations = [];
$info = $entity->getEntityType();
// Add manage fields and display links if this entity type is the bundle
// of another and that type has field UI enabled.
if (($bundle_of = $info->getBundleOf()) && \Drupal::entityManager()->getDefinition($bundle_of)->get('field_ui_base_route')) {
$account = \Drupal::currentUser();
if ($account->hasPermission('administer ' . $bundle_of . ' fields')) {
- $operations['manage-fields'] = array(
+ $operations['manage-fields'] = [
'title' => t('Manage fields'),
'weight' => 15,
- 'url' => Url::fromRoute("entity.{$bundle_of}.field_ui_fields", array(
+ 'url' => Url::fromRoute("entity.{$bundle_of}.field_ui_fields", [
$entity->getEntityTypeId() => $entity->id(),
- )),
- );
+ ]),
+ ];
}
if ($account->hasPermission('administer ' . $bundle_of . ' form display')) {
- $operations['manage-form-display'] = array(
+ $operations['manage-form-display'] = [
'title' => t('Manage form display'),
'weight' => 20,
- 'url' => Url::fromRoute("entity.entity_form_display.{$bundle_of}.default", array(
+ 'url' => Url::fromRoute("entity.entity_form_display.{$bundle_of}.default", [
$entity->getEntityTypeId() => $entity->id(),
- )),
- );
+ ]),
+ ];
}
if ($account->hasPermission('administer ' . $bundle_of . ' display')) {
- $operations['manage-display'] = array(
+ $operations['manage-display'] = [
'title' => t('Manage display'),
'weight' => 25,
- 'url' => Url::fromRoute("entity.entity_view_display.{$bundle_of}.default", array(
+ 'url' => Url::fromRoute("entity.entity_view_display.{$bundle_of}.default", [
$entity->getEntityTypeId() => $entity->id(),
- )),
- );
+ ]),
+ ];
}
}
diff --git a/core/modules/field_ui/src/Controller/EntityDisplayModeController.php b/core/modules/field_ui/src/Controller/EntityDisplayModeController.php
index 545e1911ae0..b4a608acd5a 100644
--- a/core/modules/field_ui/src/Controller/EntityDisplayModeController.php
+++ b/core/modules/field_ui/src/Controller/EntityDisplayModeController.php
@@ -17,20 +17,20 @@ class EntityDisplayModeController extends ControllerBase {
* A list of entity types to add a view mode for.
*/
public function viewModeTypeSelection() {
- $entity_types = array();
+ $entity_types = [];
foreach ($this->entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->get('field_ui_base_route') && $entity_type->hasViewBuilderClass()) {
- $entity_types[$entity_type_id] = array(
+ $entity_types[$entity_type_id] = [
'title' => $entity_type->getLabel(),
- 'url' => Url::fromRoute('entity.entity_view_mode.add_form', array('entity_type_id' => $entity_type_id)),
- 'localized_options' => array(),
- );
+ 'url' => Url::fromRoute('entity.entity_view_mode.add_form', ['entity_type_id' => $entity_type_id]),
+ 'localized_options' => [],
+ ];
}
}
- return array(
+ return [
'#theme' => 'admin_block_content',
'#content' => $entity_types,
- );
+ ];
}
/**
@@ -40,20 +40,20 @@ class EntityDisplayModeController extends ControllerBase {
* A list of entity types to add a form mode for.
*/
public function formModeTypeSelection() {
- $entity_types = array();
+ $entity_types = [];
foreach ($this->entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->get('field_ui_base_route') && $entity_type->hasFormClasses()) {
- $entity_types[$entity_type_id] = array(
+ $entity_types[$entity_type_id] = [
'title' => $entity_type->getLabel(),
- 'url' => Url::fromRoute('entity.entity_form_mode.add_form', array('entity_type_id' => $entity_type_id)),
- 'localized_options' => array(),
- );
+ 'url' => Url::fromRoute('entity.entity_form_mode.add_form', ['entity_type_id' => $entity_type_id]),
+ 'localized_options' => [],
+ ];
}
}
- return array(
+ return [
'#theme' => 'admin_block_content',
'#content' => $entity_types,
- );
+ ];
}
}
diff --git a/core/modules/field_ui/src/Element/FieldUiTable.php b/core/modules/field_ui/src/Element/FieldUiTable.php
index 05d5d04e534..f8f3146759e 100644
--- a/core/modules/field_ui/src/Element/FieldUiTable.php
+++ b/core/modules/field_ui/src/Element/FieldUiTable.php
@@ -42,7 +42,7 @@ class FieldUiTable extends Table {
* @see \Drupal\Core\Render\Element\Table::preRenderTable()
*/
public static function tablePreRender($elements) {
- $js_settings = array();
+ $js_settings = [];
// For each region, build the tree structure from the weight and parenting
// data contained in the flat form structure, to determine row order and
diff --git a/core/modules/field_ui/src/EntityDisplayModeListBuilder.php b/core/modules/field_ui/src/EntityDisplayModeListBuilder.php
index d0250553688..c9d89662785 100644
--- a/core/modules/field_ui/src/EntityDisplayModeListBuilder.php
+++ b/core/modules/field_ui/src/EntityDisplayModeListBuilder.php
@@ -71,7 +71,7 @@ class EntityDisplayModeListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function load() {
- $entities = array();
+ $entities = [];
foreach (parent::load() as $entity) {
$entities[$entity->getTargetType()][] = $entity;
}
@@ -82,7 +82,7 @@ class EntityDisplayModeListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function render() {
- $build = array();
+ $build = [];
foreach ($this->load() as $entity_type => $entities) {
if (!isset($this->entityTypes[$entity_type])) {
continue;
@@ -93,12 +93,12 @@ class EntityDisplayModeListBuilder extends ConfigEntityListBuilder {
continue;
}
- $table = array(
+ $table = [
'#prefix' => '<h2>' . $this->entityTypes[$entity_type]->getLabel() . '</h2>',
'#type' => 'table',
'#header' => $this->buildHeader(),
- '#rows' => array(),
- );
+ '#rows' => [],
+ ];
foreach ($entities as $entity) {
if ($row = $this->buildRow($entity)) {
$table['#rows'][$entity->id()] = $row;
@@ -110,15 +110,15 @@ class EntityDisplayModeListBuilder extends ConfigEntityListBuilder {
$table['#weight'] = -10;
}
- $short_type = str_replace(array('entity_', '_mode'), '', $this->entityTypeId);
- $table['#rows']['_add_new'][] = array(
- 'data' => array(
+ $short_type = str_replace(['entity_', '_mode'], '', $this->entityTypeId);
+ $table['#rows']['_add_new'][] = [
+ 'data' => [
'#type' => 'link',
'#url' => Url::fromRoute($short_type == 'view' ? 'entity.entity_view_mode.add_form' : 'entity.entity_form_mode.add_form', ['entity_type_id' => $entity_type]),
- '#title' => $this->t('Add new %label @entity-type', array('%label' => $this->entityTypes[$entity_type]->getLabel(), '@entity-type' => $this->entityType->getLowercaseLabel())),
- ),
+ '#title' => $this->t('Add new %label @entity-type', ['%label' => $this->entityTypes[$entity_type]->getLabel(), '@entity-type' => $this->entityType->getLowercaseLabel()]),
+ ],
'colspan' => count($table['#header']),
- );
+ ];
$build[$entity_type] = $table;
}
return $build;
diff --git a/core/modules/field_ui/src/FieldConfigListBuilder.php b/core/modules/field_ui/src/FieldConfigListBuilder.php
index c8739daef92..7a6960e40ea 100644
--- a/core/modules/field_ui/src/FieldConfigListBuilder.php
+++ b/core/modules/field_ui/src/FieldConfigListBuilder.php
@@ -93,7 +93,7 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
// Sort the entities using the entity class's sort() method.
// See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
- uasort($entities, array($this->entityType->getClass(), 'sort'));
+ uasort($entities, [$this->entityType->getClass(), 'sort']);
return $entities;
}
@@ -101,14 +101,14 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function buildHeader() {
- $header = array(
+ $header = [
'label' => $this->t('Label'),
- 'field_name' => array(
+ 'field_name' => [
'data' => $this->t('Machine name'),
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
- ),
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+ ],
'field_type' => $this->t('Field type'),
- );
+ ];
return $header + parent::buildHeader();
}
@@ -118,31 +118,31 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
public function buildRow(EntityInterface $field_config) {
/** @var \Drupal\field\FieldConfigInterface $field_config */
$field_storage = $field_config->getFieldStorageDefinition();
- $route_parameters = array(
+ $route_parameters = [
'field_config' => $field_config->id(),
- ) + FieldUI::getRouteBundleParameter($this->entityManager->getDefinition($this->targetEntityTypeId), $this->targetBundle);
+ ] + FieldUI::getRouteBundleParameter($this->entityManager->getDefinition($this->targetEntityTypeId), $this->targetBundle);
- $row = array(
+ $row = [
'id' => Html::getClass($field_config->getName()),
- 'data' => array(
+ 'data' => [
'label' => $field_config->getLabel(),
'field_name' => $field_config->getName(),
- 'field_type' => array(
- 'data' => array(
+ 'field_type' => [
+ 'data' => [
'#type' => 'link',
'#title' => $this->fieldTypeManager->getDefinitions()[$field_storage->getType()]['label'],
'#url' => Url::fromRoute("entity.field_config.{$this->targetEntityTypeId}_storage_edit_form", $route_parameters),
- '#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))),
- ),
- ),
- ),
- );
+ '#options' => ['attributes' => ['title' => $this->t('Edit field settings.')]],
+ ],
+ ],
+ ],
+ ];
// Add the operations.
$row['data'] = $row['data'] + parent::buildRow($field_config);
if ($field_storage->isLocked()) {
- $row['data']['operations'] = array('data' => array('#markup' => $this->t('Locked')));
+ $row['data']['operations'] = ['data' => ['#markup' => $this->t('Locked')]];
$row['class'][] = 'menu-disabled';
}
@@ -157,26 +157,26 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
$operations = parent::getDefaultOperations($entity);
if ($entity->access('update') && $entity->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-edit-form")) {
- $operations['edit'] = array(
+ $operations['edit'] = [
'title' => $this->t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-edit-form"),
- );
+ ];
}
if ($entity->access('delete') && $entity->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-delete-form")) {
- $operations['delete'] = array(
+ $operations['delete'] = [
'title' => $this->t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-delete-form"),
- );
+ ];
}
- $operations['storage-settings'] = array(
+ $operations['storage-settings'] = [
'title' => $this->t('Storage settings'),
'weight' => 20,
- 'attributes' => array('title' => $this->t('Edit storage settings.')),
+ 'attributes' => ['title' => $this->t('Edit storage settings.')],
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-storage-edit-form"),
- );
+ ];
$operations['edit']['attributes']['title'] = $this->t('Edit field settings.');
$operations['delete']['attributes']['title'] = $this->t('Delete field.');
diff --git a/core/modules/field_ui/src/FieldStorageConfigListBuilder.php b/core/modules/field_ui/src/FieldStorageConfigListBuilder.php
index e39954c7b5b..f82bd9df1df 100644
--- a/core/modules/field_ui/src/FieldStorageConfigListBuilder.php
+++ b/core/modules/field_ui/src/FieldStorageConfigListBuilder.php
@@ -82,10 +82,10 @@ class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
*/
public function buildHeader() {
$header['id'] = $this->t('Field name');
- $header['type'] = array(
+ $header['type'] = [
'data' => $this->t('Field type'),
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
- );
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+ ];
$header['usage'] = $this->t('Used in');
return $header;
}
@@ -95,17 +95,17 @@ class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
*/
public function buildRow(EntityInterface $field_storage) {
if ($field_storage->isLocked()) {
- $row['class'] = array('menu-disabled');
- $row['data']['id'] = $this->t('@field_name (Locked)', array('@field_name' => $field_storage->getName()));
+ $row['class'] = ['menu-disabled'];
+ $row['data']['id'] = $this->t('@field_name (Locked)', ['@field_name' => $field_storage->getName()]);
}
else {
$row['data']['id'] = $field_storage->getName();
}
$field_type = $this->fieldTypes[$field_storage->getType()];
- $row['data']['type'] = $this->t('@type (module: @module)', array('@type' => $field_type['label'], '@module' => $field_type['provider']));
+ $row['data']['type'] = $this->t('@type (module: @module)', ['@type' => $field_type['label'], '@module' => $field_type['provider']]);
- $usage = array();
+ $usage = [];
foreach ($field_storage->getBundles() as $bundle) {
$entity_type_id = $field_storage->getTargetEntityTypeId();
if ($route_info = FieldUI::getOverviewRouteInfo($entity_type_id, $bundle)) {
diff --git a/core/modules/field_ui/src/FieldUI.php b/core/modules/field_ui/src/FieldUI.php
index b3416947788..b9351a4b77f 100644
--- a/core/modules/field_ui/src/FieldUI.php
+++ b/core/modules/field_ui/src/FieldUI.php
@@ -47,9 +47,9 @@ class FieldUI {
$next_destination = array_shift($destinations);
if (is_array($next_destination)) {
$next_destination['options']['query']['destinations'] = $destinations;
- $next_destination += array(
- 'route_parameters' => array(),
- );
+ $next_destination += [
+ 'route_parameters' => [],
+ ];
$next_destination = Url::fromRoute($next_destination['route_name'], $next_destination['route_parameters'], $next_destination['options']);
}
else {
@@ -77,7 +77,7 @@ class FieldUI {
*/
public static function getRouteBundleParameter(EntityTypeInterface $entity_type, $bundle) {
$bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle';
- return array($bundle_parameter_key => $bundle);
+ return [$bundle_parameter_key => $bundle];
}
}
diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
index 8908f659b6d..42a4e81d622 100644
--- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
+++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
@@ -90,17 +90,17 @@ abstract class EntityDisplayFormBase extends EntityForm {
* @endcode
*/
public function getRegions() {
- return array(
- 'content' => array(
+ return [
+ 'content' => [
'title' => $this->t('Content'),
'invisible' => TRUE,
'message' => $this->t('No field is displayed.')
- ),
- 'hidden' => array(
- 'title' => $this->t('Disabled', array(), array('context' => 'Plural')),
+ ],
+ 'hidden' => [
+ 'title' => $this->t('Disabled', [], ['context' => 'Plural']),
'message' => $this->t('No field is hidden.')
- ),
- );
+ ],
+ ];
}
/**
@@ -110,7 +110,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
* An array containing the region options.
*/
public function getRegionOptions() {
- $options = array();
+ $options = [];
foreach ($this->getRegions() as $region => $data) {
$options[$region] = $data['title'];
}
@@ -139,48 +139,48 @@ abstract class EntityDisplayFormBase extends EntityForm {
$field_definitions = $this->getFieldDefinitions();
$extra_fields = $this->getExtraFields();
- $form += array(
+ $form += [
'#entity_type' => $this->entity->getTargetEntityTypeId(),
'#bundle' => $this->entity->getTargetBundle(),
'#fields' => array_keys($field_definitions),
'#extra' => array_keys($extra_fields),
- );
+ ];
if (empty($field_definitions) && empty($extra_fields) && $route_info = FieldUI::getOverviewRouteInfo($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle())) {
- drupal_set_message($this->t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', array(':link' => $route_info->toString())), 'warning');
+ drupal_set_message($this->t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => $route_info->toString()]), 'warning');
return $form;
}
- $table = array(
+ $table = [
'#type' => 'field_ui_table',
'#header' => $this->getTableHeader(),
'#regions' => $this->getRegions(),
- '#attributes' => array(
- 'class' => array('field-ui-overview'),
+ '#attributes' => [
+ 'class' => ['field-ui-overview'],
'id' => 'field-display-overview',
- ),
- '#tabledrag' => array(
- array(
+ ],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'field-weight',
- ),
- array(
+ ],
+ [
'action' => 'match',
'relationship' => 'parent',
'group' => 'field-parent',
'subgroup' => 'field-parent',
'source' => 'field-name',
- ),
- array(
+ ],
+ [
'action' => 'match',
'relationship' => 'parent',
'group' => 'field-region',
'subgroup' => 'field-region',
'source' => 'field-name',
- ),
- ),
- );
+ ],
+ ],
+ ];
// Field rows.
foreach ($field_definitions as $field_name => $field_definition) {
@@ -201,21 +201,21 @@ abstract class EntityDisplayFormBase extends EntityForm {
// Unset default option.
unset($display_mode_options['default']);
if ($display_mode_options) {
- $form['modes'] = array(
+ $form['modes'] = [
'#type' => 'details',
'#title' => $this->t('Custom display settings'),
- );
+ ];
// Prepare default values for the 'Custom display settings' checkboxes.
- $default = array();
+ $default = [];
if ($enabled_displays = array_filter($this->getDisplayStatuses())) {
$default = array_keys(array_intersect_key($display_mode_options, $enabled_displays));
}
- $form['modes']['display_modes_custom'] = array(
+ $form['modes']['display_modes_custom'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Use custom display settings for the following @display_context modes', ['@display_context' => $this->displayContext]),
'#options' => $display_mode_options,
'#default_value' => $default,
- );
+ ];
// Provide link to manage display modes.
$form['modes']['display_modes_link'] = $this->getDisplayModesLink();
}
@@ -227,29 +227,29 @@ abstract class EntityDisplayFormBase extends EntityForm {
// the selects, but triggered by the client-side script through a hidden
// #ajax 'Refresh' button. A hidden 'refresh_rows' input tracks the name of
// affected rows.
- $form['refresh_rows'] = array('#type' => 'hidden');
- $form['refresh'] = array(
+ $form['refresh_rows'] = ['#type' => 'hidden'];
+ $form['refresh'] = [
'#type' => 'submit',
'#value' => $this->t('Refresh'),
'#op' => 'refresh_table',
- '#submit' => array('::multistepSubmit'),
- '#ajax' => array(
+ '#submit' => ['::multistepSubmit'],
+ '#ajax' => [
'callback' => '::multistepAjax',
'wrapper' => 'field-display-overview-wrapper',
'effect' => 'fade',
// The button stays hidden, so we hide the Ajax spinner too. Ad-hoc
// spinners will be added manually by the client-side script.
'progress' => 'none',
- ),
- '#attributes' => array('class' => array('visually-hidden'))
- );
+ ],
+ '#attributes' => ['class' => ['visually-hidden']]
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => $this->t('Save'),
- );
+ ];
$form['#attached']['library'][] = 'field_ui/drupal.field_ui';
@@ -281,82 +281,82 @@ abstract class EntityDisplayFormBase extends EntityForm {
}
$regions = array_keys($this->getRegions());
- $field_row = array(
- '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
+ $field_row = [
+ '#attributes' => ['class' => ['draggable', 'tabledrag-leaf']],
'#row_type' => 'field',
- '#region_callback' => array($this, 'getRowRegion'),
- '#js_settings' => array(
+ '#region_callback' => [$this, 'getRowRegion'],
+ '#js_settings' => [
'rowHandler' => 'field',
'defaultPlugin' => $this->getDefaultPlugin($field_definition->getType()),
- ),
- 'human_name' => array(
+ ],
+ 'human_name' => [
'#plain_text' => $label,
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'#type' => 'textfield',
- '#title' => $this->t('Weight for @title', array('@title' => $label)),
+ '#title' => $this->t('Weight for @title', ['@title' => $label]),
'#title_display' => 'invisible',
'#default_value' => $display_options ? $display_options['weight'] : '0',
'#size' => 3,
- '#attributes' => array('class' => array('field-weight')),
- ),
- 'parent_wrapper' => array(
- 'parent' => array(
+ '#attributes' => ['class' => ['field-weight']],
+ ],
+ 'parent_wrapper' => [
+ 'parent' => [
'#type' => 'select',
- '#title' => $this->t('Label display for @title', array('@title' => $label)),
+ '#title' => $this->t('Label display for @title', ['@title' => $label]),
'#title_display' => 'invisible',
'#options' => array_combine($regions, $regions),
'#empty_value' => '',
- '#attributes' => array('class' => array('js-field-parent', 'field-parent')),
- '#parents' => array('fields', $field_name, 'parent'),
- ),
- 'hidden_name' => array(
+ '#attributes' => ['class' => ['js-field-parent', 'field-parent']],
+ '#parents' => ['fields', $field_name, 'parent'],
+ ],
+ 'hidden_name' => [
'#type' => 'hidden',
'#default_value' => $field_name,
- '#attributes' => array('class' => array('field-name')),
- ),
- ),
- 'region' => array(
+ '#attributes' => ['class' => ['field-name']],
+ ],
+ ],
+ 'region' => [
'#type' => 'select',
- '#title' => $this->t('Region for @title', array('@title' => $label)),
+ '#title' => $this->t('Region for @title', ['@title' => $label]),
'#title_display' => 'invisible',
'#options' => $this->getRegionOptions(),
'#default_value' => $display_options ? $display_options['region'] : 'hidden',
- '#attributes' => array('class' => array('field-region')),
- ),
- );
+ '#attributes' => ['class' => ['field-region']],
+ ],
+ ];
- $field_row['plugin'] = array(
- 'type' => array(
+ $field_row['plugin'] = [
+ 'type' => [
'#type' => 'select',
- '#title' => $this->t('Plugin for @title', array('@title' => $label)),
+ '#title' => $this->t('Plugin for @title', ['@title' => $label]),
'#title_display' => 'invisible',
'#options' => $this->getApplicablePluginOptions($field_definition),
'#default_value' => $display_options ? $display_options['type'] : 'hidden',
- '#parents' => array('fields', $field_name, 'type'),
- '#attributes' => array('class' => array('field-plugin-type')),
- ),
- 'settings_edit_form' => array(),
- );
+ '#parents' => ['fields', $field_name, 'type'],
+ '#attributes' => ['class' => ['field-plugin-type']],
+ ],
+ 'settings_edit_form' => [],
+ ];
// Get the corresponding plugin object.
$plugin = $this->entity->getRenderer($field_name);
// Base button element for the various plugin settings actions.
- $base_button = array(
- '#submit' => array('::multistepSubmit'),
- '#ajax' => array(
+ $base_button = [
+ '#submit' => ['::multistepSubmit'],
+ '#ajax' => [
'callback' => '::multistepAjax',
'wrapper' => 'field-display-overview-wrapper',
'effect' => 'fade',
- ),
+ ],
'#field_name' => $field_name,
- );
+ ];
if ($form_state->get('plugin_settings_edit') == $field_name) {
// We are currently editing this field's plugin settings. Display the
// settings form and submit buttons.
- $field_row['plugin']['settings_edit_form'] = array();
+ $field_row['plugin']['settings_edit_form'] = [];
if ($plugin) {
// Generate the settings form and allow other modules to alter it.
@@ -364,43 +364,43 @@ abstract class EntityDisplayFormBase extends EntityForm {
$third_party_settings_form = $this->thirdPartySettingsForm($plugin, $field_definition, $form, $form_state);
if ($settings_form || $third_party_settings_form) {
- $field_row['plugin']['#cell_attributes'] = array('colspan' => 3);
- $field_row['plugin']['settings_edit_form'] = array(
+ $field_row['plugin']['#cell_attributes'] = ['colspan' => 3];
+ $field_row['plugin']['settings_edit_form'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('field-plugin-settings-edit-form')),
- '#parents' => array('fields', $field_name, 'settings_edit_form'),
- 'label' => array(
+ '#attributes' => ['class' => ['field-plugin-settings-edit-form']],
+ '#parents' => ['fields', $field_name, 'settings_edit_form'],
+ 'label' => [
'#markup' => $this->t('Plugin settings'),
- ),
+ ],
'settings' => $settings_form,
'third_party_settings' => $third_party_settings_form,
- 'actions' => array(
+ 'actions' => [
'#type' => 'actions',
- 'save_settings' => $base_button + array(
+ 'save_settings' => $base_button + [
'#type' => 'submit',
'#button_type' => 'primary',
'#name' => $field_name . '_plugin_settings_update',
'#value' => $this->t('Update'),
'#op' => 'update',
- ),
- 'cancel_settings' => $base_button + array(
+ ],
+ 'cancel_settings' => $base_button + [
'#type' => 'submit',
'#name' => $field_name . '_plugin_settings_cancel',
'#value' => $this->t('Cancel'),
'#op' => 'cancel',
// Do not check errors for the 'Cancel' button, but make sure we
// get the value of the 'plugin type' select.
- '#limit_validation_errors' => array(array('fields', $field_name, 'type')),
- ),
- ),
- );
+ '#limit_validation_errors' => [['fields', $field_name, 'type']],
+ ],
+ ],
+ ];
$field_row['#attributes']['class'][] = 'field-plugin-settings-editing';
}
}
}
else {
- $field_row['settings_summary'] = array();
- $field_row['settings_edit'] = array();
+ $field_row['settings_summary'] = [];
+ $field_row['settings_edit'] = [];
if ($plugin) {
// Display a summary of the current plugin settings, and (if the
@@ -411,30 +411,30 @@ abstract class EntityDisplayFormBase extends EntityForm {
$this->alterSettingsSummary($summary, $plugin, $field_definition);
if (!empty($summary)) {
- $field_row['settings_summary'] = array(
+ $field_row['settings_summary'] = [
'#type' => 'inline_template',
'#template' => '<div class="field-plugin-summary">{{ summary|safe_join("<br />") }}</div>',
- '#context' => array('summary' => $summary),
- '#cell_attributes' => array('class' => array('field-plugin-summary-cell')),
- );
+ '#context' => ['summary' => $summary],
+ '#cell_attributes' => ['class' => ['field-plugin-summary-cell']],
+ ];
}
// Check selected plugin settings to display edit link or not.
$settings_form = $plugin->settingsForm($form, $form_state);
$third_party_settings_form = $this->thirdPartySettingsForm($plugin, $field_definition, $form, $form_state);
if (!empty($settings_form) || !empty($third_party_settings_form)) {
- $field_row['settings_edit'] = $base_button + array(
+ $field_row['settings_edit'] = $base_button + [
'#type' => 'image_button',
'#name' => $field_name . '_settings_edit',
'#src' => 'core/misc/icons/787878/cog.svg',
- '#attributes' => array('class' => array('field-plugin-settings-edit'), 'alt' => $this->t('Edit')),
+ '#attributes' => ['class' => ['field-plugin-settings-edit'], 'alt' => $this->t('Edit')],
'#op' => 'edit',
// Do not check errors for the 'Edit' button, but make sure we get
// the value of the 'plugin type' select.
- '#limit_validation_errors' => array(array('fields', $field_name, 'type')),
+ '#limit_validation_errors' => [['fields', $field_name, 'type']],
'#prefix' => '<div class="field-plugin-settings-edit-wrapper">',
'#suffix' => '</div>',
- );
+ ];
}
}
}
@@ -457,50 +457,50 @@ abstract class EntityDisplayFormBase extends EntityForm {
$display_options = $this->entity->getComponent($field_id);
$regions = array_keys($this->getRegions());
- $extra_field_row = array(
- '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
+ $extra_field_row = [
+ '#attributes' => ['class' => ['draggable', 'tabledrag-leaf']],
'#row_type' => 'extra_field',
- '#region_callback' => array($this, 'getRowRegion'),
- '#js_settings' => array('rowHandler' => 'field'),
- 'human_name' => array(
+ '#region_callback' => [$this, 'getRowRegion'],
+ '#js_settings' => ['rowHandler' => 'field'],
+ 'human_name' => [
'#markup' => $extra_field['label'],
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'#type' => 'textfield',
- '#title' => $this->t('Weight for @title', array('@title' => $extra_field['label'])),
+ '#title' => $this->t('Weight for @title', ['@title' => $extra_field['label']]),
'#title_display' => 'invisible',
'#default_value' => $display_options ? $display_options['weight'] : 0,
'#size' => 3,
- '#attributes' => array('class' => array('field-weight')),
- ),
- 'parent_wrapper' => array(
- 'parent' => array(
+ '#attributes' => ['class' => ['field-weight']],
+ ],
+ 'parent_wrapper' => [
+ 'parent' => [
'#type' => 'select',
- '#title' => $this->t('Parents for @title', array('@title' => $extra_field['label'])),
+ '#title' => $this->t('Parents for @title', ['@title' => $extra_field['label']]),
'#title_display' => 'invisible',
'#options' => array_combine($regions, $regions),
'#empty_value' => '',
- '#attributes' => array('class' => array('js-field-parent', 'field-parent')),
- '#parents' => array('fields', $field_id, 'parent'),
- ),
- 'hidden_name' => array(
+ '#attributes' => ['class' => ['js-field-parent', 'field-parent']],
+ '#parents' => ['fields', $field_id, 'parent'],
+ ],
+ 'hidden_name' => [
'#type' => 'hidden',
'#default_value' => $field_id,
- '#attributes' => array('class' => array('field-name')),
- ),
- ),
- 'region' => array(
+ '#attributes' => ['class' => ['field-name']],
+ ],
+ ],
+ 'region' => [
'#type' => 'select',
- '#title' => $this->t('Region for @title', array('@title' => $extra_field['label'])),
+ '#title' => $this->t('Region for @title', ['@title' => $extra_field['label']]),
'#title_display' => 'invisible',
'#options' => $this->getRegionOptions(),
'#default_value' => $display_options ? $display_options['region'] : 'hidden',
- '#attributes' => array('class' => array('field-region')),
- ),
- 'plugin' => array(),
- 'settings_summary' => array(),
- 'settings_edit' => array(),
- );
+ '#attributes' => ['class' => ['field-region']],
+ ],
+ 'plugin' => [],
+ 'settings_summary' => [],
+ 'settings_edit' => [],
+ ];
return $extra_field_row;
}
@@ -524,7 +524,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
$display_modes = $this->getDisplayModes();
$current_statuses = $this->getDisplayStatuses();
- $statuses = array();
+ $statuses = [];
foreach ($form_values['display_modes_custom'] as $mode => $value) {
if (!empty($value) && empty($current_statuses[$mode])) {
// If no display exists for the newly enabled view mode, initialize
@@ -595,10 +595,10 @@ abstract class EntityDisplayFormBase extends EntityForm {
$entity->removeComponent($name);
}
else {
- $entity->setComponent($name, array(
+ $entity->setComponent($name, [
'weight' => $form_values['fields'][$name]['weight'],
'region' => $form_values['fields'][$name]['region'],
- ));
+ ]);
}
}
}
@@ -655,19 +655,19 @@ abstract class EntityDisplayFormBase extends EntityForm {
// Pick the elements that need to receive the ajax-new-content effect.
switch ($op) {
case 'edit':
- $updated_rows = array($trigger['#field_name']);
- $updated_columns = array('plugin');
+ $updated_rows = [$trigger['#field_name']];
+ $updated_columns = ['plugin'];
break;
case 'update':
case 'cancel':
- $updated_rows = array($trigger['#field_name']);
- $updated_columns = array('plugin', 'settings_summary', 'settings_edit');
+ $updated_rows = [$trigger['#field_name']];
+ $updated_columns = ['plugin', 'settings_summary', 'settings_edit'];
break;
case 'refresh_table':
$updated_rows = array_values(explode(' ', $form_state->getValue('refresh_rows')));
- $updated_columns = array('settings_summary', 'settings_edit');
+ $updated_columns = ['settings_summary', 'settings_edit'];
break;
}
@@ -727,7 +727,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
protected function getExtraFields() {
$context = $this->displayContext == 'view' ? 'display' : $this->displayContext;
$extra_fields = $this->entityManager->getExtraFields($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle());
- return isset($extra_fields[$context]) ? $extra_fields[$context] : array();
+ return isset($extra_fields[$context]) ? $extra_fields[$context] : [];
}
/**
@@ -756,7 +756,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
*/
protected function getApplicablePluginOptions(FieldDefinitionInterface $field_definition) {
$options = $this->pluginManager->getOptions($field_definition->getType());
- $applicable_options = array();
+ $applicable_options = [];
foreach ($options as $option => $label) {
$plugin_class = DefaultFactory::getPluginClass($option, $this->pluginManager->getDefinition($option));
if ($plugin_class::isApplicable($field_definition)) {
@@ -825,7 +825,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
* An array holding entity displays or entity form displays.
*/
protected function getDisplays() {
- $load_ids = array();
+ $load_ids = [];
$display_entity_type = $this->entity->getEntityTypeId();
$entity_type = $this->entityManager->getDefinition($display_entity_type);
$config_prefix = $entity_type->getConfigPrefix();
@@ -847,7 +847,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
* An array of form or view mode statuses.
*/
protected function getDisplayStatuses() {
- $display_statuses = array();
+ $display_statuses = [];
$displays = $this->getDisplays();
foreach ($displays as $display) {
$display_statuses[$display->get('mode')] = $display->status();
diff --git a/core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php b/core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php
index 141af84fffa..ed1c5fe1e55 100644
--- a/core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php
+++ b/core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php
@@ -26,7 +26,7 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase {
// Change replace_pattern to avoid undesired dots.
$form['id']['#machine_name']['replace_pattern'] = '[^a-z0-9_]+';
$definition = $this->entityManager->getDefinition($this->targetEntityTypeId);
- $form['#title'] = $this->t('Add new %label @entity-type', array('%label' => $definition->getLabel(), '@entity-type' => $this->entityType->getLowercaseLabel()));
+ $form['#title'] = $this->t('Add new %label @entity-type', ['%label' => $definition->getLabel(), '@entity-type' => $this->entityType->getLowercaseLabel()]);
return $form;
}
diff --git a/core/modules/field_ui/src/Form/EntityDisplayModeDeleteForm.php b/core/modules/field_ui/src/Form/EntityDisplayModeDeleteForm.php
index fa22a379dc1..f7d88046114 100644
--- a/core/modules/field_ui/src/Form/EntityDisplayModeDeleteForm.php
+++ b/core/modules/field_ui/src/Form/EntityDisplayModeDeleteForm.php
@@ -14,7 +14,7 @@ class EntityDisplayModeDeleteForm extends EntityDeleteForm {
*/
public function getDescription() {
$entity_type = $this->entity->getEntityType();
- return $this->t('Deleting a @entity-type will cause any output still requesting to use that @entity-type to use the default display settings.', array('@entity-type' => $entity_type->getLowercaseLabel()));
+ return $this->t('Deleting a @entity-type will cause any output still requesting to use that @entity-type to use the default display settings.', ['@entity-type' => $entity_type->getLowercaseLabel()]);
}
}
diff --git a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php
index 7a566418085..72a8a19643a 100644
--- a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php
+++ b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php
@@ -29,24 +29,24 @@ abstract class EntityDisplayModeFormBase extends EntityForm {
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 100,
'#default_value' => $this->entity->label(),
- );
+ ];
- $form['id'] = array(
+ $form['id'] = [
'#type' => 'machine_name',
'#description' => $this->t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
'#disabled' => !$this->entity->isNew(),
'#default_value' => $this->entity->id(),
'#field_prefix' => $this->entity->isNew() ? $this->entity->getTargetType() . '.' : '',
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
'replace_pattern' => '[^a-z0-9_.]+',
- ),
- );
+ ],
+ ];
return $form;
}
@@ -78,7 +78,7 @@ abstract class EntityDisplayModeFormBase extends EntityForm {
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
- drupal_set_message($this->t('Saved the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => $this->entityType->getLowercaseLabel())));
+ drupal_set_message($this->t('Saved the %label @entity-type.', ['%label' => $this->entity->label(), '@entity-type' => $this->entityType->getLowercaseLabel()]));
$this->entity->save();
\Drupal::entityManager()->clearCachedFieldDefinitions();
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
diff --git a/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php b/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php
index af8e2edfc30..2c3e3604605 100644
--- a/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php
+++ b/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php
@@ -38,7 +38,7 @@ class EntityFormDisplayEditForm extends EntityDisplayFormBase {
$field_name = $field_definition->getName();
// Update the (invisible) title of the 'plugin' column.
- $field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $field_definition->getLabel()));
+ $field_row['plugin']['#title'] = $this->t('Formatter for @title', ['@title' => $field_definition->getLabel()]);
if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $this->entity->getRenderer($field_name))) {
$plugin_type_info = $plugin->getPluginDefinition();
$field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Widget settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';
@@ -90,13 +90,13 @@ class EntityFormDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc}
*/
protected function getTableHeader() {
- return array(
+ return [
$this->t('Field'),
$this->t('Weight'),
$this->t('Parent'),
$this->t('Region'),
- array('data' => $this->t('Widget'), 'colspan' => 3),
- );
+ ['data' => $this->t('Widget'), 'colspan' => 3],
+ ];
}
/**
@@ -113,17 +113,17 @@ class EntityFormDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc}
*/
protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
- $settings_form = array();
+ $settings_form = [];
// Invoke hook_field_widget_third_party_settings_form(), keying resulting
// subforms by module name.
foreach ($this->moduleHandler->getImplementations('field_widget_third_party_settings_form') as $module) {
- $settings_form[$module] = $this->moduleHandler->invoke($module, 'field_widget_third_party_settings_form', array(
+ $settings_form[$module] = $this->moduleHandler->invoke($module, 'field_widget_third_party_settings_form', [
$plugin,
$field_definition,
$this->entity->getMode(),
$form,
$form_state,
- ));
+ ]);
}
return $settings_form;
}
@@ -132,11 +132,11 @@ class EntityFormDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc}
*/
protected function alterSettingsSummary(array &$summary, PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition) {
- $context = array(
+ $context = [
'widget' => $plugin,
'field_definition' => $field_definition,
'form_mode' => $this->entity->getMode(),
- );
+ ];
$this->moduleHandler->alter('field_widget_settings_summary', $summary, $context);
}
diff --git a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
index 174726f2c60..c27f3d4f524 100644
--- a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
+++ b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
@@ -39,21 +39,21 @@ class EntityViewDisplayEditForm extends EntityDisplayFormBase {
$display_options = $this->entity->getComponent($field_name);
// Insert the label column.
- $label = array(
- 'label' => array(
+ $label = [
+ 'label' => [
'#type' => 'select',
- '#title' => $this->t('Label display for @title', array('@title' => $field_definition->getLabel())),
+ '#title' => $this->t('Label display for @title', ['@title' => $field_definition->getLabel()]),
'#title_display' => 'invisible',
'#options' => $this->getFieldLabelOptions(),
'#default_value' => $display_options ? $display_options['label'] : 'above',
- ),
- );
+ ],
+ ];
$label_position = array_search('plugin', array_keys($field_row));
$field_row = array_slice($field_row, 0, $label_position, TRUE) + $label + array_slice($field_row, $label_position, count($field_row) - 1, TRUE);
// Update the (invisible) title of the 'plugin' column.
- $field_row['plugin']['#title'] = $this->t('Formatter for @title', array('@title' => $field_definition->getLabel()));
+ $field_row['plugin']['#title'] = $this->t('Formatter for @title', ['@title' => $field_definition->getLabel()]);
if (!empty($field_row['plugin']['settings_edit_form']) && ($plugin = $this->entity->getRenderer($field_name))) {
$plugin_type_info = $plugin->getPluginDefinition();
$field_row['plugin']['settings_edit_form']['label']['#markup'] = $this->t('Format settings:') . ' <span class="plugin-name">' . $plugin_type_info['label'] . '</span>';
@@ -69,11 +69,11 @@ class EntityViewDisplayEditForm extends EntityDisplayFormBase {
$extra_field_row = parent::buildExtraFieldRow($field_id, $extra_field);
// Insert an empty placeholder for the label column.
- $label = array(
- 'empty_cell' => array(
+ $label = [
+ 'empty_cell' => [
'#markup' => '&nbsp;'
- )
- );
+ ]
+ ];
$label_position = array_search('plugin', array_keys($extra_field_row));
$extra_field_row = array_slice($extra_field_row, 0, $label_position, TRUE) + $label + array_slice($extra_field_row, $label_position, count($extra_field_row) - 1, TRUE);
@@ -123,14 +123,14 @@ class EntityViewDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc}
*/
protected function getTableHeader() {
- return array(
+ return [
$this->t('Field'),
$this->t('Weight'),
$this->t('Parent'),
$this->t('Region'),
$this->t('Label'),
- array('data' => $this->t('Format'), 'colspan' => 3),
- );
+ ['data' => $this->t('Format'), 'colspan' => 3],
+ ];
}
/**
@@ -150,29 +150,29 @@ class EntityViewDisplayEditForm extends EntityDisplayFormBase {
* An array of visibility options.
*/
protected function getFieldLabelOptions() {
- return array(
+ return [
'above' => $this->t('Above'),
'inline' => $this->t('Inline'),
'hidden' => '- ' . $this->t('Hidden') . ' -',
'visually_hidden' => '- ' . $this->t('Visually Hidden') . ' -',
- );
+ ];
}
/**
* {@inheritdoc}
*/
protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
- $settings_form = array();
+ $settings_form = [];
// Invoke hook_field_formatter_third_party_settings_form(), keying resulting
// subforms by module name.
foreach ($this->moduleHandler->getImplementations('field_formatter_third_party_settings_form') as $module) {
- $settings_form[$module] = $this->moduleHandler->invoke($module, 'field_formatter_third_party_settings_form', array(
+ $settings_form[$module] = $this->moduleHandler->invoke($module, 'field_formatter_third_party_settings_form', [
$plugin,
$field_definition,
$this->entity->getMode(),
$form,
$form_state,
- ));
+ ]);
}
return $settings_form;
}
@@ -181,11 +181,11 @@ class EntityViewDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc}
*/
protected function alterSettingsSummary(array &$summary, PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition) {
- $context = array(
+ $context = [
'formatter' => $plugin,
'field_definition' => $field_definition,
'view_mode' => $this->entity->getMode(),
- );
+ ];
$this->moduleHandler->alter('field_formatter_settings_summary', $summary, $context);
}
diff --git a/core/modules/field_ui/src/Form/FieldConfigDeleteForm.php b/core/modules/field_ui/src/Form/FieldConfigDeleteForm.php
index f9c775561d4..67782311bc4 100644
--- a/core/modules/field_ui/src/Form/FieldConfigDeleteForm.php
+++ b/core/modules/field_ui/src/Form/FieldConfigDeleteForm.php
@@ -96,10 +96,10 @@ class FieldConfigDeleteForm extends EntityDeleteForm {
if ($field_storage && !$field_storage->isLocked()) {
$this->entity->delete();
- drupal_set_message($this->t('The field %field has been deleted from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label)));
+ drupal_set_message($this->t('The field %field has been deleted from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]));
}
else {
- drupal_set_message($this->t('There was a problem removing the %field from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label)), 'error');
+ drupal_set_message($this->t('There was a problem removing the %field from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]), 'error');
}
$form_state->setRedirectUrl($this->getCancelUrl());
diff --git a/core/modules/field_ui/src/Form/FieldConfigEditForm.php b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
index ff6d157117e..2895479b366 100644
--- a/core/modules/field_ui/src/Form/FieldConfigEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
@@ -33,75 +33,75 @@ class FieldConfigEditForm extends EntityForm {
$field_storage = $this->entity->getFieldStorageDefinition();
$bundles = $this->entityManager->getBundleInfo($this->entity->getTargetEntityTypeId());
- $form_title = $this->t('%field settings for %bundle', array(
+ $form_title = $this->t('%field settings for %bundle', [
'%field' => $this->entity->getLabel(),
'%bundle' => $bundles[$this->entity->getTargetBundle()]['label'],
- ));
+ ]);
$form['#title'] = $form_title;
if ($field_storage->isLocked()) {
- $form['locked'] = array(
- '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $this->entity->getLabel())),
- );
+ $form['locked'] = [
+ '#markup' => $this->t('The field %field is locked and cannot be edited.', ['%field' => $this->entity->getLabel()]),
+ ];
return $form;
}
// Build the configurable field values.
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#default_value' => $this->entity->getLabel() ?: $field_storage->getName(),
'#required' => TRUE,
'#weight' => -20,
- );
+ ];
- $form['description'] = array(
+ $form['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Help text'),
'#default_value' => $this->entity->getDescription(),
'#rows' => 5,
- '#description' => $this->t('Instructions to present to the user below this field on the editing form.<br />Allowed HTML tags: @tags', array('@tags' => FieldFilteredMarkup::displayAllowedTags())) . '<br />' . $this->t('This field supports tokens.'),
+ '#description' => $this->t('Instructions to present to the user below this field on the editing form.<br />Allowed HTML tags: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '<br />' . $this->t('This field supports tokens.'),
'#weight' => -10,
- );
+ ];
- $form['required'] = array(
+ $form['required'] = [
'#type' => 'checkbox',
'#title' => $this->t('Required field'),
'#default_value' => $this->entity->isRequired(),
'#weight' => -5,
- );
+ ];
// Create an arbitrary entity object (used by the 'default value' widget).
- $ids = (object) array(
+ $ids = (object) [
'entity_type' => $this->entity->getTargetEntityTypeId(),
'bundle' => $this->entity->getTargetBundle(),
'entity_id' => NULL
- );
+ ];
$form['#entity'] = _field_create_entity_from_ids($ids);
$items = $form['#entity']->get($this->entity->getName());
$item = $items->first() ?: $items->appendItem();
// Add field settings for the field type and a container for third party
// settings that modules can add to via hook_form_FORM_ID_alter().
- $form['settings'] = array(
+ $form['settings'] = [
'#tree' => TRUE,
'#weight' => 10,
- );
+ ];
$form['settings'] += $item->fieldSettingsForm($form, $form_state);
- $form['third_party_settings'] = array(
+ $form['third_party_settings'] = [
'#tree' => TRUE,
'#weight' => 11,
- );
+ ];
// Add handling for default value.
if ($element = $items->defaultValuesForm($form, $form_state)) {
- $element = array_merge($element, array(
+ $element = array_merge($element, [
'#type' => 'details',
'#title' => $this->t('Default value'),
'#open' => TRUE,
'#tree' => TRUE,
'#description' => $this->t('The default value for this field, used when creating new content.'),
- ));
+ ]);
$form['default_value'] = $element;
}
@@ -128,15 +128,15 @@ class FieldConfigEditForm extends EntityForm {
$query['destination'] = $this->getRequest()->query->get('destination');
$url->setOption('query', $query);
}
- $actions['delete'] = array(
+ $actions['delete'] = [
'#type' => 'link',
'#title' => $this->t('Delete'),
'#url' => $url,
'#access' => $this->entity->access('delete'),
- '#attributes' => array(
- 'class' => array('button', 'button--danger'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['button', 'button--danger'],
+ ],
+ ];
}
return $actions;
@@ -161,7 +161,7 @@ class FieldConfigEditForm extends EntityForm {
parent::submitForm($form, $form_state);
// Handle the default value.
- $default_value = array();
+ $default_value = [];
if (isset($form['default_value'])) {
$items = $form['#entity']->get($this->entity->getName());
$default_value = $items->defaultValuesFormSubmit($form['default_value'], $form, $form_state);
@@ -175,7 +175,7 @@ class FieldConfigEditForm extends EntityForm {
public function save(array $form, FormStateInterface $form_state) {
$this->entity->save();
- drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->entity->getLabel())));
+ drupal_set_message($this->t('Saved %label configuration.', ['%label' => $this->entity->getLabel()]));
$request = $this->getRequest();
if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) {
diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php
index 231fd63a179..5e5a842282c 100644
--- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php
+++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php
@@ -101,65 +101,65 @@ class FieldStorageAddForm extends FormBase {
$this->bundle = $form_state->get('bundle');
// Gather valid field types.
- $field_type_options = array();
+ $field_type_options = [];
foreach ($this->fieldTypePluginManager->getGroupedDefinitions($this->fieldTypePluginManager->getUiDefinitions()) as $category => $field_types) {
foreach ($field_types as $name => $field_type) {
$field_type_options[$category][$name] = $field_type['label'];
}
}
- $form['add'] = array(
+ $form['add'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('form--inline', 'clearfix')),
- );
+ '#attributes' => ['class' => ['form--inline', 'clearfix']],
+ ];
- $form['add']['new_storage_type'] = array(
+ $form['add']['new_storage_type'] = [
'#type' => 'select',
'#title' => $this->t('Add a new field'),
'#options' => $field_type_options,
'#empty_option' => $this->t('- Select a field type -'),
- );
+ ];
// Re-use existing field.
if ($existing_field_storage_options = $this->getExistingFieldStorageOptions()) {
- $form['add']['separator'] = array(
+ $form['add']['separator'] = [
'#type' => 'item',
'#markup' => $this->t('or'),
- );
- $form['add']['existing_storage_name'] = array(
+ ];
+ $form['add']['existing_storage_name'] = [
'#type' => 'select',
'#title' => $this->t('Re-use an existing field'),
'#options' => $existing_field_storage_options,
'#empty_option' => $this->t('- Select an existing field -'),
- );
+ ];
$form['#attached']['drupalSettings']['existingFieldLabels'] = $this->getExistingFieldLabels(array_keys($existing_field_storage_options));
}
else {
// Provide a placeholder form element to simplify the validation code.
- $form['add']['existing_storage_name'] = array(
+ $form['add']['existing_storage_name'] = [
'#type' => 'value',
'#value' => FALSE,
- );
+ ];
}
// Field label and field_name.
- $form['new_storage_wrapper'] = array(
+ $form['new_storage_wrapper'] = [
'#type' => 'container',
- '#states' => array(
- '!visible' => array(
- ':input[name="new_storage_type"]' => array('value' => ''),
- ),
- ),
- );
- $form['new_storage_wrapper']['label'] = array(
+ '#states' => [
+ '!visible' => [
+ ':input[name="new_storage_type"]' => ['value' => ''],
+ ],
+ ],
+ ];
+ $form['new_storage_wrapper']['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#size' => 15,
- );
+ ];
$field_prefix = $this->config('field_ui.settings')->get('field_prefix');
- $form['new_storage_wrapper']['field_name'] = array(
+ $form['new_storage_wrapper']['field_name'] = [
'#type' => 'machine_name',
// This field should stay LTR even for RTL languages.
'#field_prefix' => '<span dir="ltr">' . $field_prefix,
@@ -169,44 +169,44 @@ class FieldStorageAddForm extends FormBase {
// Calculate characters depending on the length of the field prefix
// setting. Maximum length is 32.
'#maxlength' => FieldStorageConfig::NAME_MAX_LENGTH - strlen($field_prefix),
- '#machine_name' => array(
- 'source' => array('new_storage_wrapper', 'label'),
- 'exists' => array($this, 'fieldNameExists'),
- ),
+ '#machine_name' => [
+ 'source' => ['new_storage_wrapper', 'label'],
+ 'exists' => [$this, 'fieldNameExists'],
+ ],
'#required' => FALSE,
- );
+ ];
// Provide a separate label element for the "Re-use existing field" case
// and place it outside the $form['add'] wrapper because those elements
// are displayed inline.
if ($existing_field_storage_options) {
- $form['existing_storage_label'] = array(
+ $form['existing_storage_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#size' => 15,
- '#states' => array(
- '!visible' => array(
- ':input[name="existing_storage_name"]' => array('value' => ''),
- ),
- ),
- );
+ '#states' => [
+ '!visible' => [
+ ':input[name="existing_storage_name"]' => ['value' => ''],
+ ],
+ ],
+ ];
}
// Place the 'translatable' property as an explicit value so that contrib
// modules can form_alter() the value for newly created fields. By default
// we create field storage as translatable so it will be possible to enable
// translation at field level.
- $form['translatable'] = array(
+ $form['translatable'] = [
'#type' => 'value',
'#value' => TRUE,
- );
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save and continue'),
'#button_type' => 'primary',
- );
+ ];
$form['#attached']['library'][] = 'field_ui/drupal.field_ui';
@@ -290,7 +290,7 @@ class FieldStorageAddForm extends FormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$error = FALSE;
$values = $form_state->getValues();
- $destinations = array();
+ $destinations = [];
$entity_type = $this->entityManager->getDefinition($this->entityTypeId);
// Create new field.
@@ -321,7 +321,7 @@ class FieldStorageAddForm extends FormBase {
// Merge in preconfigured field storage options.
if (isset($field_options['field_storage_config'])) {
- foreach (array('cardinality', 'settings') as $key) {
+ foreach (['cardinality', 'settings'] as $key) {
if (isset($field_options['field_storage_config'][$key])) {
$field_storage_values[$key] = $field_options['field_storage_config'][$key];
}
@@ -330,7 +330,7 @@ class FieldStorageAddForm extends FormBase {
// Merge in preconfigured field options.
if (isset($field_options['field_config'])) {
- foreach (array('required', 'settings') as $key) {
+ foreach (['required', 'settings'] as $key) {
if (isset($field_options['field_config'][$key])) {
$field_values[$key] = $field_options['field_config'][$key];
}
@@ -352,19 +352,19 @@ class FieldStorageAddForm extends FormBase {
// Always show the field settings step, as the cardinality needs to be
// configured for new fields.
- $route_parameters = array(
+ $route_parameters = [
'field_config' => $field->id(),
- ) + FieldUI::getRouteBundleParameter($entity_type, $this->bundle);
- $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_storage_edit_form", 'route_parameters' => $route_parameters);
- $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters);
- $destinations[] = array('route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters);
+ ] + FieldUI::getRouteBundleParameter($entity_type, $this->bundle);
+ $destinations[] = ['route_name' => "entity.field_config.{$this->entityTypeId}_storage_edit_form", 'route_parameters' => $route_parameters];
+ $destinations[] = ['route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters];
+ $destinations[] = ['route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters];
// Store new field information for any additional submit handlers.
$form_state->set(['fields_added', '_add_new_field'], $values['field_name']);
}
catch (\Exception $e) {
$error = TRUE;
- drupal_set_message($this->t('There was a problem creating field %label: @message', array('%label' => $values['label'], '@message' => $e->getMessage())), 'error');
+ drupal_set_message($this->t('There was a problem creating field %label: @message', ['%label' => $values['label'], '@message' => $e->getMessage()]), 'error');
}
}
@@ -373,29 +373,29 @@ class FieldStorageAddForm extends FormBase {
$field_name = $values['existing_storage_name'];
try {
- $field = $this->entityManager->getStorage('field_config')->create(array(
+ $field = $this->entityManager->getStorage('field_config')->create([
'field_name' => $field_name,
'entity_type' => $this->entityTypeId,
'bundle' => $this->bundle,
'label' => $values['existing_storage_label'],
- ));
+ ]);
$field->save();
$this->configureEntityFormDisplay($field_name);
$this->configureEntityViewDisplay($field_name);
- $route_parameters = array(
+ $route_parameters = [
'field_config' => $field->id(),
- ) + FieldUI::getRouteBundleParameter($entity_type, $this->bundle);
- $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters);
- $destinations[] = array('route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters);
+ ] + FieldUI::getRouteBundleParameter($entity_type, $this->bundle);
+ $destinations[] = ['route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters];
+ $destinations[] = ['route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters];
// Store new field information for any additional submit handlers.
$form_state->set(['fields_added', '_add_existing_field'], $field_name);
}
catch (\Exception $e) {
$error = TRUE;
- drupal_set_message($this->t('There was a problem creating field %label: @message', array('%label' => $values['label'], '@message' => $e->getMessage())), 'error');
+ drupal_set_message($this->t('There was a problem creating field %label: @message', ['%label' => $values['label'], '@message' => $e->getMessage()]), 'error');
}
}
@@ -452,7 +452,7 @@ class FieldStorageAddForm extends FormBase {
* An array of existing field storages keyed by name.
*/
protected function getExistingFieldStorageOptions() {
- $options = array();
+ $options = [];
// Load the field_storages and build the list of options.
$field_types = $this->fieldTypePluginManager->getDefinitions();
foreach ($this->entityManager->getFieldStorageDefinitions($this->entityTypeId) as $field_name => $field_storage) {
@@ -466,10 +466,10 @@ class FieldStorageAddForm extends FormBase {
&& !$field_storage->isLocked()
&& empty($field_types[$field_type]['no_ui'])
&& !in_array($this->bundle, $field_storage->getBundles(), TRUE)) {
- $options[$field_name] = $this->t('@type: @field', array(
+ $options[$field_name] = $this->t('@type: @field', [
'@type' => $field_types[$field_type]['label'],
'@field' => $field_name,
- ));
+ ]);
}
}
asort($options);
@@ -500,7 +500,7 @@ class FieldStorageAddForm extends FormBase {
$fields = $this->entityManager->getStorage('field_config')->loadMultiple($field_ids);
// Go through all the fields and use the label of the first encounter.
- $labels = array();
+ $labels = [];
foreach ($fields as $field) {
if (!isset($labels[$field->getName()])) {
$labels[$field->getName()] = $field->label();
diff --git a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
index bbaeb63322d..a0c1294d9da 100644
--- a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
@@ -62,7 +62,7 @@ class FieldStorageConfigEditForm extends EntityForm {
$field_label = $form_state->get('field_config')->label();
$form['#title'] = $field_label;
- $form['#prefix'] = '<p>' . $this->t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', array('%field' => $field_label)) . '</p>';
+ $form['#prefix'] = '<p>' . $this->t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', ['%field' => $field_label]) . '</p>';
// See if data already exists for this field.
// If so, prevent changes to the field settings.
@@ -73,17 +73,17 @@ class FieldStorageConfigEditForm extends EntityForm {
// Add settings provided by the field module. The field module is
// responsible for not returning settings that cannot be changed if
// the field already has data.
- $form['settings'] = array(
+ $form['settings'] = [
'#weight' => -10,
'#tree' => TRUE,
- );
+ ];
// Create an arbitrary entity object, so that we can have an instantiated
// FieldItem.
- $ids = (object) array(
+ $ids = (object) [
'entity_type' => $form_state->get('entity_type_id'),
'bundle' => $form_state->get('bundle'),
'entity_id' => NULL
- );
+ ];
$entity = _field_create_entity_from_ids($ids);
$items = $entity->get($this->entity->getName());
$item = $items->first() ?: $items->appendItem();
@@ -91,43 +91,43 @@ class FieldStorageConfigEditForm extends EntityForm {
// Build the configurable field values.
$cardinality = $this->entity->getCardinality();
- $form['cardinality_container'] = array(
+ $form['cardinality_container'] = [
// Reset #parents so the additional container does not appear.
- '#parents' => array(),
+ '#parents' => [],
'#type' => 'fieldset',
'#title' => $this->t('Allowed number of values'),
- '#attributes' => array('class' => array(
+ '#attributes' => ['class' => [
'container-inline',
'fieldgroup',
'form-composite'
- )),
- );
- $form['cardinality_container']['cardinality'] = array(
+ ]],
+ ];
+ $form['cardinality_container']['cardinality'] = [
'#type' => 'select',
'#title' => $this->t('Allowed number of values'),
'#title_display' => 'invisible',
- '#options' => array(
+ '#options' => [
'number' => $this->t('Limited'),
FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED => $this->t('Unlimited'),
- ),
+ ],
'#default_value' => ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 'number',
- );
- $form['cardinality_container']['cardinality_number'] = array(
+ ];
+ $form['cardinality_container']['cardinality_number'] = [
'#type' => 'number',
'#default_value' => $cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ? $cardinality : 1,
'#min' => 1,
'#title' => $this->t('Limit'),
'#title_display' => 'invisible',
'#size' => 2,
- '#states' => array(
- 'visible' => array(
- ':input[name="cardinality"]' => array('value' => 'number'),
- ),
- 'disabled' => array(
- ':input[name="cardinality"]' => array('value' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="cardinality"]' => ['value' => 'number'],
+ ],
+ 'disabled' => [
+ ':input[name="cardinality"]' => ['value' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED],
+ ],
+ ],
+ ];
return $form;
}
@@ -190,7 +190,7 @@ class FieldStorageConfigEditForm extends EntityForm {
$field_label = $form_state->get('field_config')->label();
try {
$this->entity->save();
- drupal_set_message($this->t('Updated field %label field settings.', array('%label' => $field_label)));
+ drupal_set_message($this->t('Updated field %label field settings.', ['%label' => $field_label]));
$request = $this->getRequest();
if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) {
$request->query->remove('destinations');
@@ -201,7 +201,7 @@ class FieldStorageConfigEditForm extends EntityForm {
}
}
catch (\Exception $e) {
- drupal_set_message($this->t('Attempt to update field %label failed: %message.', array('%label' => $field_label, '%message' => $e->getMessage())), 'error');
+ drupal_set_message($this->t('Attempt to update field %label failed: %message.', ['%label' => $field_label, '%message' => $e->getMessage()]), 'error');
}
}
diff --git a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php
index 4d81c8b5df1..b92d702590d 100644
--- a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php
+++ b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php
@@ -50,15 +50,15 @@ class FieldUiLocalAction extends DeriverBase implements ContainerDeriverInterfac
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $this->derivatives = array();
+ $this->derivatives = [];
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->get('field_ui_base_route')) {
- $this->derivatives["field_storage_config_add_$entity_type_id"] = array(
+ $this->derivatives["field_storage_config_add_$entity_type_id"] = [
'route_name' => "field_ui.field_storage_config_add_$entity_type_id",
'title' => $this->t('Add field'),
- 'appears_on' => array("entity.$entity_type_id.field_ui_fields"),
- );
+ 'appears_on' => ["entity.$entity_type_id.field_ui_fields"],
+ ];
}
}
diff --git a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php
index 3ebf95994b1..6d95abdd1a8 100644
--- a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php
+++ b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php
@@ -61,46 +61,46 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $this->derivatives = array();
+ $this->derivatives = [];
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->get('field_ui_base_route')) {
- $this->derivatives["overview_$entity_type_id"] = array(
+ $this->derivatives["overview_$entity_type_id"] = [
'route_name' => "entity.$entity_type_id.field_ui_fields",
'weight' => 1,
'title' => $this->t('Manage fields'),
'base_route' => "entity.$entity_type_id.field_ui_fields",
- );
+ ];
// 'Manage form display' tab.
- $this->derivatives["form_display_overview_$entity_type_id"] = array(
+ $this->derivatives["form_display_overview_$entity_type_id"] = [
'route_name' => "entity.entity_form_display.$entity_type_id.default",
'weight' => 2,
'title' => $this->t('Manage form display'),
'base_route' => "entity.$entity_type_id.field_ui_fields",
- );
+ ];
// 'Manage display' tab.
- $this->derivatives["display_overview_$entity_type_id"] = array(
+ $this->derivatives["display_overview_$entity_type_id"] = [
'route_name' => "entity.entity_view_display.$entity_type_id.default",
'weight' => 3,
'title' => $this->t('Manage display'),
'base_route' => "entity.$entity_type_id.field_ui_fields",
- );
+ ];
// Field edit tab.
- $this->derivatives["field_edit_$entity_type_id"] = array(
+ $this->derivatives["field_edit_$entity_type_id"] = [
'route_name' => "entity.field_config.{$entity_type_id}_field_edit_form",
'title' => $this->t('Edit'),
'base_route' => "entity.field_config.{$entity_type_id}_field_edit_form",
- );
+ ];
// Field settings tab.
- $this->derivatives["field_storage_$entity_type_id"] = array(
+ $this->derivatives["field_storage_$entity_type_id"] = [
'route_name' => "entity.field_config.{$entity_type_id}_storage_edit_form",
'title' => $this->t('Field settings'),
'base_route' => "entity.field_config.{$entity_type_id}_field_edit_form",
- );
+ ];
// View and form modes secondary tabs.
// The same base $path for the menu item (with a placeholder) can be
@@ -109,47 +109,47 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
// modes available for customisation. So we define menu items for all
// view modes, and use a route requirement to determine which ones are
// actually visible for a given bundle.
- $this->derivatives['field_form_display_default_' . $entity_type_id] = array(
+ $this->derivatives['field_form_display_default_' . $entity_type_id] = [
'title' => 'Default',
'route_name' => "entity.entity_form_display.$entity_type_id.default",
'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id",
'weight' => -1,
- );
- $this->derivatives['field_display_default_' . $entity_type_id] = array(
+ ];
+ $this->derivatives['field_display_default_' . $entity_type_id] = [
'title' => 'Default',
'route_name' => "entity.entity_view_display.$entity_type_id.default",
'parent_id' => "field_ui.fields:display_overview_$entity_type_id",
'weight' => -1,
- );
+ ];
// One local task for each form mode.
$weight = 0;
foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) {
- $this->derivatives['field_form_display_' . $form_mode . '_' . $entity_type_id] = array(
+ $this->derivatives['field_form_display_' . $form_mode . '_' . $entity_type_id] = [
'title' => $form_mode_info['label'],
'route_name' => "entity.entity_form_display.$entity_type_id.form_mode",
- 'route_parameters' => array(
+ 'route_parameters' => [
'form_mode_name' => $form_mode,
- ),
+ ],
'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id",
'weight' => $weight++,
'cache_tags' => $this->entityManager->getDefinition('entity_form_display')->getListCacheTags(),
- );
+ ];
}
// One local task for each view mode.
$weight = 0;
foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) {
- $this->derivatives['field_display_' . $view_mode . '_' . $entity_type_id] = array(
+ $this->derivatives['field_display_' . $view_mode . '_' . $entity_type_id] = [
'title' => $form_mode_info['label'],
'route_name' => "entity.entity_view_display.$entity_type_id.view_mode",
- 'route_parameters' => array(
+ 'route_parameters' => [
'view_mode_name' => $view_mode,
- ),
+ ],
'parent_id' => "field_ui.fields:display_overview_$entity_type_id",
'weight' => $weight++,
'cache_tags' => $this->entityManager->getDefinition('entity_view_display')->getListCacheTags(),
- );
+ ];
}
}
}
diff --git a/core/modules/field_ui/src/Routing/RouteSubscriber.php b/core/modules/field_ui/src/Routing/RouteSubscriber.php
index 696a0494f29..b08e7f8fe58 100644
--- a/core/modules/field_ui/src/Routing/RouteSubscriber.php
+++ b/core/modules/field_ui/src/Routing/RouteSubscriber.php
@@ -44,16 +44,16 @@ class RouteSubscriber extends RouteSubscriberBase {
$options = $entity_route->getOptions();
if ($bundle_entity_type = $entity_type->getBundleEntityType()) {
- $options['parameters'][$bundle_entity_type] = array(
+ $options['parameters'][$bundle_entity_type] = [
'type' => 'entity:' . $bundle_entity_type,
- );
+ ];
}
// Special parameter used to easily recognize all Field UI routes.
$options['_field_ui'] = TRUE;
- $defaults = array(
+ $defaults = [
'entity_type_id' => $entity_type_id,
- );
+ ];
// If the entity type has no bundles and it doesn't use {bundle} in its
// admin path, use the entity type.
if (strpos($path, '{bundle}') === FALSE) {
@@ -62,95 +62,95 @@ class RouteSubscriber extends RouteSubscriberBase {
$route = new Route(
"$path/fields/{field_config}",
- array(
+ [
'_entity_form' => 'field_config.edit',
'_title_callback' => '\Drupal\field_ui\Form\FieldConfigEditForm::getTitle',
- ) + $defaults,
- array('_entity_access' => 'field_config.update'),
+ ] + $defaults,
+ ['_entity_access' => 'field_config.update'],
$options
);
$collection->add("entity.field_config.{$entity_type_id}_field_edit_form", $route);
$route = new Route(
"$path/fields/{field_config}/storage",
- array('_entity_form' => 'field_storage_config.edit') + $defaults,
- array('_permission' => 'administer ' . $entity_type_id . ' fields'),
+ ['_entity_form' => 'field_storage_config.edit'] + $defaults,
+ ['_permission' => 'administer ' . $entity_type_id . ' fields'],
$options
);
$collection->add("entity.field_config.{$entity_type_id}_storage_edit_form", $route);
$route = new Route(
"$path/fields/{field_config}/delete",
- array('_entity_form' => 'field_config.delete') + $defaults,
- array('_entity_access' => 'field_config.delete'),
+ ['_entity_form' => 'field_config.delete'] + $defaults,
+ ['_entity_access' => 'field_config.delete'],
$options
);
$collection->add("entity.field_config.{$entity_type_id}_field_delete_form", $route);
$route = new Route(
"$path/fields",
- array(
+ [
'_controller' => '\Drupal\field_ui\Controller\FieldConfigListController::listing',
'_title' => 'Manage fields',
- ) + $defaults,
- array('_permission' => 'administer ' . $entity_type_id . ' fields'),
+ ] + $defaults,
+ ['_permission' => 'administer ' . $entity_type_id . ' fields'],
$options
);
$collection->add("entity.{$entity_type_id}.field_ui_fields", $route);
$route = new Route(
"$path/fields/add-field",
- array(
+ [
'_form' => '\Drupal\field_ui\Form\FieldStorageAddForm',
'_title' => 'Add field',
- ) + $defaults,
- array('_permission' => 'administer ' . $entity_type_id . ' fields'),
+ ] + $defaults,
+ ['_permission' => 'administer ' . $entity_type_id . ' fields'],
$options
);
$collection->add("field_ui.field_storage_config_add_$entity_type_id", $route);
$route = new Route(
"$path/form-display",
- array(
+ [
'_entity_form' => 'entity_form_display.edit',
'_title' => 'Manage form display',
'form_mode_name' => 'default',
- ) + $defaults,
- array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'),
+ ] + $defaults,
+ ['_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'],
$options
);
$collection->add("entity.entity_form_display.{$entity_type_id}.default", $route);
$route = new Route(
"$path/form-display/{form_mode_name}",
- array(
+ [
'_entity_form' => 'entity_form_display.edit',
'_title' => 'Manage form display',
- ) + $defaults,
- array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'),
+ ] + $defaults,
+ ['_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'],
$options
);
$collection->add("entity.entity_form_display.{$entity_type_id}.form_mode", $route);
$route = new Route(
"$path/display",
- array(
+ [
'_entity_form' => 'entity_view_display.edit',
'_title' => 'Manage display',
'view_mode_name' => 'default',
- ) + $defaults,
- array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
+ ] + $defaults,
+ ['_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'],
$options
);
$collection->add("entity.entity_view_display.{$entity_type_id}.default", $route);
$route = new Route(
"$path/display/{view_mode_name}",
- array(
+ [
'_entity_form' => 'entity_view_display.edit',
'_title' => 'Manage display',
- ) + $defaults,
- array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
+ ] + $defaults,
+ ['_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'],
$options
);
$collection->add("entity.entity_view_display.{$entity_type_id}.view_mode", $route);
@@ -163,7 +163,7 @@ class RouteSubscriber extends RouteSubscriberBase {
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
- $events[RoutingEvents::ALTER] = array('onAlterRoutes', -100);
+ $events[RoutingEvents::ALTER] = ['onAlterRoutes', -100];
return $events;
}
diff --git a/core/modules/field_ui/src/Tests/FieldUIDeleteTest.php b/core/modules/field_ui/src/Tests/FieldUIDeleteTest.php
index 59469ac9bda..542a99cfeee 100644
--- a/core/modules/field_ui/src/Tests/FieldUIDeleteTest.php
+++ b/core/modules/field_ui/src/Tests/FieldUIDeleteTest.php
@@ -21,14 +21,14 @@ class FieldUIDeleteTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_ui', 'field_test', 'block', 'field_test_views');
+ public static $modules = ['node', 'field_ui', 'field_test', 'block', 'field_test_views'];
/**
* Test views to enable
*
* @var string[]
*/
- public static $testViews = array('test_view_field_delete');
+ public static $testViews = ['test_view_field_delete'];
/**
* {@inheritdoc}
@@ -41,7 +41,7 @@ class FieldUIDeleteTest extends WebTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create a test user.
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access']);
$this->drupalLogin($admin_user);
}
@@ -55,7 +55,7 @@ class FieldUIDeleteTest extends WebTestBase {
// Create an additional node type.
$type_name1 = strtolower($this->randomMachineName(8)) . '_test';
- $type1 = $this->drupalCreateContentType(array('name' => $type_name1, 'type' => $type_name1));
+ $type1 = $this->drupalCreateContentType(['name' => $type_name1, 'type' => $type_name1]);
$type_name1 = $type1->id();
// Create a new field.
@@ -64,7 +64,7 @@ class FieldUIDeleteTest extends WebTestBase {
// Create an additional node type.
$type_name2 = strtolower($this->randomMachineName(8)) . '_test';
- $type2 = $this->drupalCreateContentType(array('name' => $type_name2, 'type' => $type_name2));
+ $type2 = $this->drupalCreateContentType(['name' => $type_name2, 'type' => $type_name2]);
$type_name2 = $type2->id();
// Add a field to the second node type.
@@ -72,7 +72,7 @@ class FieldUIDeleteTest extends WebTestBase {
$this->fieldUIAddExistingField($bundle_path2, $field_name, $field_label);
\Drupal::service('module_installer')->install(['views']);
- ViewTestData::createTestViews(get_class($this), array('field_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['field_test_views']);
// Check the config dependencies of the first field, the field storage must
// not be shown as being deleted yet.
diff --git a/core/modules/field_ui/src/Tests/FieldUiTestTrait.php b/core/modules/field_ui/src/Tests/FieldUiTestTrait.php
index 9bb0ecb0d1c..39c41a30273 100644
--- a/core/modules/field_ui/src/Tests/FieldUiTestTrait.php
+++ b/core/modules/field_ui/src/Tests/FieldUiTestTrait.php
@@ -26,13 +26,13 @@ trait FieldUiTestTrait {
* (optional) $edit parameter for drupalPostForm() on the third step ('Field
* settings' form).
*/
- public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $field_type = 'test_field', array $storage_edit = array(), array $field_edit = array()) {
+ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $field_type = 'test_field', array $storage_edit = [], array $field_edit = []) {
$label = $label ?: $this->randomString();
- $initial_edit = array(
+ $initial_edit = [
'new_storage_type' => $field_type,
'label' => $label,
'field_name' => $field_name,
- );
+ ];
// Allow the caller to set a NULL path in case they navigated to the right
// page before calling this method.
@@ -42,17 +42,17 @@ trait FieldUiTestTrait {
// First step: 'Add field' page.
$this->drupalPostForm($bundle_path, $initial_edit, t('Save and continue'));
- $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Storage settings page was displayed.');
+ $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', ['%label' => $label]), 'Storage settings page was displayed.');
// Test Breadcrumbs.
$this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
// Second step: 'Storage settings' form.
$this->drupalPostForm(NULL, $storage_edit, t('Save field settings'));
- $this->assertRaw(t('Updated field %label field settings.', array('%label' => $label)), 'Redirected to field settings page.');
+ $this->assertRaw(t('Updated field %label field settings.', ['%label' => $label]), 'Redirected to field settings page.');
// Third step: 'Field settings' form.
$this->drupalPostForm(NULL, $field_edit, t('Save settings'));
- $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), 'Redirected to "Manage fields" page.');
+ $this->assertRaw(t('Saved %label configuration.', ['%label' => $label]), 'Redirected to "Manage fields" page.');
// Check that the field appears in the overview form.
$this->assertFieldByXPath('//table[@id="field-overview"]//tr/td[1]', $label, 'Field was created and appears in the overview page.');
@@ -72,12 +72,12 @@ trait FieldUiTestTrait {
* (optional) $edit parameter for drupalPostForm() on the second step
* ('Field settings' form).
*/
- public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $label = NULL, array $field_edit = array()) {
+ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $label = NULL, array $field_edit = []) {
$label = $label ?: $this->randomString();
- $initial_edit = array(
+ $initial_edit = [
'existing_storage_name' => $existing_storage_name,
'existing_storage_label' => $label,
- );
+ ];
// First step: 'Re-use existing field' on the 'Add field' page.
$this->drupalPostForm("$bundle_path/fields/add-field", $initial_edit, t('Save and continue'));
@@ -90,7 +90,7 @@ trait FieldUiTestTrait {
// Second step: 'Field settings' form.
$this->drupalPostForm(NULL, $field_edit, t('Save settings'));
- $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), 'Redirected to "Manage fields" page.');
+ $this->assertRaw(t('Saved %label configuration.', ['%label' => $label]), 'Redirected to "Manage fields" page.');
// Check that the field appears in the overview form.
$this->assertFieldByXPath('//table[@id="field-overview"]//tr/td[1]', $label, 'Field was created and appears in the overview page.');
@@ -111,14 +111,14 @@ trait FieldUiTestTrait {
public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) {
// Display confirmation form.
$this->drupalGet("$bundle_path/fields/$field_name/delete");
- $this->assertRaw(t('Are you sure you want to delete the field %label', array('%label' => $label)), 'Delete confirmation was found.');
+ $this->assertRaw(t('Are you sure you want to delete the field %label', ['%label' => $label]), 'Delete confirmation was found.');
// Test Breadcrumbs.
$this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the field delete page.');
// Submit confirmation form.
- $this->drupalPostForm(NULL, array(), t('Delete'));
- $this->assertRaw(t('The field %label has been deleted from the %type content type.', array('%label' => $label, '%type' => $bundle_label)), 'Delete message was found.');
+ $this->drupalPostForm(NULL, [], t('Delete'));
+ $this->assertRaw(t('The field %label has been deleted from the %type content type.', ['%label' => $label, '%type' => $bundle_label]), 'Delete message was found.');
// Check that the field does not appear in the overview form.
$this->assertNoFieldByXPath('//table[@id="field-overview"]//span[@class="label-field"]', $label, 'Field does not appear in the overview page.');
diff --git a/core/modules/field_ui/src/Tests/ManageDisplayTest.php b/core/modules/field_ui/src/Tests/ManageDisplayTest.php
index 902a193c1e6..9c8798fe282 100644
--- a/core/modules/field_ui/src/Tests/ManageDisplayTest.php
+++ b/core/modules/field_ui/src/Tests/ManageDisplayTest.php
@@ -25,7 +25,7 @@ class ManageDisplayTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_ui', 'taxonomy', 'search', 'field_test', 'field_third_party_test', 'block');
+ public static $modules = ['node', 'field_ui', 'taxonomy', 'search', 'field_test', 'field_third_party_test', 'block'];
/**
* {@inheritdoc}
@@ -35,24 +35,24 @@ class ManageDisplayTest extends WebTestBase {
$this->drupalPlaceBlock('system_breadcrumb_block');
// Create a test user.
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access']);
$this->drupalLogin($admin_user);
// Create content type, with underscores.
$type_name = strtolower($this->randomMachineName(8)) . '_test';
- $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
+ $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$this->type = $type->id();
// Create a default vocabulary.
- $vocabulary = Vocabulary::create(array(
+ $vocabulary = Vocabulary::create([
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'vid' => Unicode::strtolower($this->randomMachineName()),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'help' => '',
- 'nodes' => array('article' => 'article'),
+ 'nodes' => ['article' => 'article'],
'weight' => mt_rand(0, 10),
- ));
+ ]);
$vocabulary->save();
$this->vocabulary = $vocabulary->id();
}
@@ -83,11 +83,11 @@ class ManageDisplayTest extends WebTestBase {
$this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.');
// Check whether formatter weights are respected.
- $result = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-fields-field-test-type'));
+ $result = $this->xpath('//select[@id=:id]/option', [':id' => 'edit-fields-field-test-type']);
$options = array_map(function($item) {
return (string) $item->attributes()->value[0];
}, $result);
- $expected_options = array (
+ $expected_options = [
'field_no_settings',
'field_empty_test',
'field_empty_setting',
@@ -95,7 +95,7 @@ class ManageDisplayTest extends WebTestBase {
'field_test_multiple',
'field_test_with_prepare_view',
'field_test_applicable',
- );
+ ];
$this->assertEqual($options, $expected_options, 'The expected formatter ordering is respected.');
// Ensure that fields can be hidden directly by changing the region.
@@ -115,12 +115,12 @@ class ManageDisplayTest extends WebTestBase {
$this->drupalPostForm($manage_display, $edit, t('Save'));
// Change the formatter and check that the summary is updated.
- $edit = array(
+ $edit = [
'fields[field_test][type]' => 'field_test_multiple',
'fields[field_test][region]' => 'content',
'refresh_rows' => 'field_test'
- );
- $this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh')));
+ ];
+ $this->drupalPostAjaxForm(NULL, $edit, ['op' => t('Refresh')]);
$format = 'field_test_multiple';
$default_settings = \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings($format);
$setting_name = key($default_settings);
@@ -129,7 +129,7 @@ class ManageDisplayTest extends WebTestBase {
$this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.');
// Submit the form and check that the display is updated.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$display = entity_get_display('node', $this->type, 'default');
$display_options = $display->getComponent('field_test');
$current_format = $display_options['type'];
@@ -142,17 +142,17 @@ class ManageDisplayTest extends WebTestBase {
// Click on the formatter settings button to open the formatter settings
// form.
- $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "field_test_settings_edit");
// Assert that the field added in
// field_test_field_formatter_third_party_settings_form() is present.
$fieldname = 'fields[field_test][settings_edit_form][third_party_settings][field_third_party_test][field_test_field_formatter_third_party_settings_form]';
$this->assertField($fieldname, 'The field added in hook_field_formatter_third_party_settings_form() is present on the settings form.');
- $edit = array($fieldname => 'foo');
+ $edit = [$fieldname => 'foo'];
$this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update");
// Save the form to save the third party settings.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
\Drupal::entityManager()->clearCachedFieldDefinitions();
$id = 'node.' . $this->type . '.default';
@@ -163,42 +163,42 @@ class ManageDisplayTest extends WebTestBase {
$this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()->getDependencies()['module']), 'The display has a dependency on field_third_party_test module.');
// Confirm that the third party settings are not updated on the settings form.
- $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "field_test_settings_edit");
$this->assertFieldByName($fieldname, '');
// Test the empty setting formatter.
- $edit = array(
+ $edit = [
'fields[field_test][type]' => 'field_empty_setting',
'fields[field_test][region]' => 'content',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertNoText('Default empty setting now has a value.');
$this->assertFieldById('edit-fields-field-test-settings-edit');
- $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "field_test_settings_edit");
$fieldname = 'fields[field_test][settings_edit_form][settings][field_empty_setting]';
- $edit = array($fieldname => 'non empty setting');
+ $edit = [$fieldname => 'non empty setting'];
$this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update");
$this->assertText('Default empty setting now has a value.');
// Test the settings form behavior. An edit button should be present since
// there are third party settings to configure.
- $edit = array(
+ $edit = [
'fields[field_test][type]' => 'field_no_settings',
'fields[field_test][region]' => 'content',
'refresh_rows' => 'field_test',
- );
- $this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh')));
+ ];
+ $this->drupalPostAjaxForm(NULL, $edit, ['op' => t('Refresh')]);
$this->assertFieldByName('field_test_settings_edit');
// Make sure we can save the third party settings when there are no settings available
- $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "field_test_settings_edit");
$this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update");
// When a module providing third-party settings to a formatter (or widget)
// is uninstalled, the formatter remains enabled but the provided settings,
// together with the corresponding form elements, are removed from the
// display component.
- \Drupal::service('module_installer')->uninstall(array('field_third_party_test'));
+ \Drupal::service('module_installer')->uninstall(['field_third_party_test']);
// Ensure the button is still there after the module has been disabled.
$this->drupalGet($manage_display);
@@ -206,7 +206,7 @@ class ManageDisplayTest extends WebTestBase {
$this->assertFieldByName('field_test_settings_edit');
// Ensure that third-party form elements are not present anymore.
- $this->drupalPostAjaxForm(NULL, array(), 'field_test_settings_edit');
+ $this->drupalPostAjaxForm(NULL, [], 'field_test_settings_edit');
$fieldname = 'fields[field_test][settings_edit_form][third_party_settings][field_third_party_test][field_test_field_formatter_third_party_settings_form]';
$this->assertNoField($fieldname);
@@ -245,23 +245,23 @@ class ManageDisplayTest extends WebTestBase {
$this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.');
// Check whether widget weights are respected.
- $result = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-fields-field-test-type'));
+ $result = $this->xpath('//select[@id=:id]/option', [':id' => 'edit-fields-field-test-type']);
$options = array_map(function($item) {
return (string) $item->attributes()->value[0];
}, $result);
- $expected_options = array (
+ $expected_options = [
'test_field_widget',
'test_field_widget_multiple',
- );
+ ];
$this->assertEqual($options, $expected_options, 'The expected widget ordering is respected.');
// Change the widget and check that the summary is updated.
- $edit = array(
+ $edit = [
'fields[field_test][type]' => 'test_field_widget_multiple',
'fields[field_test][region]' => 'content',
'refresh_rows' => 'field_test',
- );
- $this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh')));
+ ];
+ $this->drupalPostAjaxForm(NULL, $edit, ['op' => t('Refresh')]);
$widget_type = 'test_field_widget_multiple';
$default_settings = \Drupal::service('plugin.manager.field.widget')->getDefaultSettings($widget_type);
$setting_name = key($default_settings);
@@ -270,7 +270,7 @@ class ManageDisplayTest extends WebTestBase {
$this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.');
// Submit the form and check that the display is updated.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$display = entity_get_form_display('node', $this->type, 'default');
$display_options = $display->getComponent('field_test');
$current_widget = $display_options['type'];
@@ -282,26 +282,26 @@ class ManageDisplayTest extends WebTestBase {
$this->assertText('field_test_field_widget_settings_summary_alter');
// Click on the widget settings button to open the widget settings form.
- $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "field_test_settings_edit");
// Assert that the field added in
// field_test_field_widget_third_party_settings_form() is present.
$fieldname = 'fields[field_test][settings_edit_form][third_party_settings][field_third_party_test][field_test_widget_third_party_settings_form]';
$this->assertField($fieldname, 'The field added in hook_field_widget_third_party_settings_form() is present on the settings form.');
- $edit = array($fieldname => 'foo');
+ $edit = [$fieldname => 'foo'];
$this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update");
// Save the form to save the third party settings.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
\Drupal::entityManager()->clearCachedFieldDefinitions();
$storage = $this->container->get('entity_type.manager')->getStorage('entity_form_display');
- $storage->resetCache(array('node.' . $this->type . '.default'));
+ $storage->resetCache(['node.' . $this->type . '.default']);
$display = $storage->load('node.' . $this->type . '.default');
$this->assertEqual($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form'), 'foo');
$this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()->getDependencies()['module']), 'Form display does not have a dependency on field_third_party_test module.');
// Confirm that the third party settings are not updated on the settings form.
- $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "field_test_settings_edit");
$this->assertFieldByName($fieldname, '');
// Creates a new field that can not be used with the multiple formatter.
@@ -312,8 +312,8 @@ class ManageDisplayTest extends WebTestBase {
$this->drupalGet($manage_display);
// Checks if the select elements contain the specified options.
- $this->assertFieldSelectOptions('fields[field_test][type]', array('test_field_widget', 'test_field_widget_multiple'));
- $this->assertFieldSelectOptions('fields[field_onewidgetfield][type]', array('test_field_widget'));
+ $this->assertFieldSelectOptions('fields[field_test][type]', ['test_field_widget', 'test_field_widget_multiple']);
+ $this->assertFieldSelectOptions('fields[field_onewidgetfield][type]', ['test_field_widget']);
// Ensure that fields can be hidden directly by changing the region.
$this->assertFieldByName('fields[field_test][region]', 'content');
@@ -335,20 +335,20 @@ class ManageDisplayTest extends WebTestBase {
// to appear in a rendered node other than as part of the field being tested
// (for example, unlikely to be part of the "Submitted by ... on ..." line).
$value = 12345;
- $settings = array(
+ $settings = [
'type' => $this->type,
- 'field_test' => array(array('value' => $value)),
- );
+ 'field_test' => [['value' => $value]],
+ ];
$node = $this->drupalCreateNode($settings);
// Gather expected output values with the various formatters.
$formatter_plugin_manager = \Drupal::service('plugin.manager.field.formatter');
$field_test_default_settings = $formatter_plugin_manager->getDefaultSettings('field_test_default');
$field_test_with_prepare_view_settings = $formatter_plugin_manager->getDefaultSettings('field_test_with_prepare_view');
- $output = array(
+ $output = [
'field_test_default' => $field_test_default_settings['test_formatter_setting'] . '|' . $value,
'field_test_with_prepare_view' => $field_test_with_prepare_view_settings['test_formatter_setting_additional'] . '|' . $value . '|' . ($value + 1),
- );
+ ];
// Check that the field is displayed with the default formatter in 'rss'
// mode (uses 'default'), and hidden in 'teaser' mode (uses custom settings).
@@ -357,40 +357,40 @@ class ManageDisplayTest extends WebTestBase {
// Change formatter for 'default' mode, check that the field is displayed
// accordingly in 'rss' mode.
- $edit = array(
+ $edit = [
'fields[field_test][type]' => 'field_test_with_prepare_view',
'fields[field_test][region]' => 'content',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display', $edit, t('Save'));
$this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected in view modes that use 'default' settings.");
// Specialize the 'rss' mode, check that the field is displayed the same.
- $edit = array(
+ $edit = [
"display_modes_custom[rss]" => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display', $edit, t('Save'));
$this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected in newly specialized 'rss' mode.");
// Set the field to 'hidden' in the view mode, check that the field is
// hidden.
- $edit = array(
+ $edit = [
'fields[field_test][region]' => 'hidden',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display/rss', $edit, t('Save'));
$this->assertNodeViewNoText($node, 'rss', $value, "The field is hidden in 'rss' mode.");
// Set the view mode back to 'default', check that the field is displayed
// accordingly.
- $edit = array(
+ $edit = [
"display_modes_custom[rss]" => FALSE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display', $edit, t('Save'));
$this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected when 'rss' mode is set back to 'default' settings.");
// Specialize the view mode again.
- $edit = array(
+ $edit = [
"display_modes_custom[rss]" => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display', $edit, t('Save'));
// Check that the previous settings for the view mode have been kept.
$this->assertNodeViewNoText($node, 'rss', $value, "The previous settings are kept when 'rss' mode is specialized again.");
@@ -428,7 +428,7 @@ class ManageDisplayTest extends WebTestBase {
$this->assertNoText('Use custom display settings for the following view modes', 'Custom display settings fieldset found.');
// This may not trigger a notice when 'view_modes_custom' isn't available.
- $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary . '/overview/display', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary . '/overview/display', [], t('Save'));
}
/**
@@ -436,13 +436,13 @@ class ManageDisplayTest extends WebTestBase {
*/
function testNoFieldsDisplayOverview() {
// Create a fresh content type without any fields.
- NodeType::create(array(
+ NodeType::create([
'type' => 'no_fields',
'name' => 'No fields',
- ))->save();
+ ])->save();
$this->drupalGet('admin/structure/types/manage/no_fields/display');
- $this->assertRaw(t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', array(':link' => \Drupal::url('entity.node.field_ui_fields', array('node_type' => 'no_fields')))));
+ $this->assertRaw(t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => \Drupal::url('entity.node.field_ui_fields', ['node_type' => 'no_fields'])]));
}
/**
@@ -514,7 +514,7 @@ class ManageDisplayTest extends WebTestBase {
$clone = clone $node;
$element = node_view($clone, $view_mode);
$output = \Drupal::service('renderer')->renderRoot($element);
- $this->verbose(t('Rendered node - view mode: @view_mode', array('@view_mode' => $view_mode)) . '<hr />' . $output);
+ $this->verbose(t('Rendered node - view mode: @view_mode', ['@view_mode' => $view_mode]) . '<hr />' . $output);
// Assign content so that WebTestBase functions can be used.
$this->setRawContent($output);
@@ -539,7 +539,7 @@ class ManageDisplayTest extends WebTestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertFieldSelectOptions($name, array $expected_options) {
- $xpath = $this->buildXPathQuery('//select[@name=:name]', array(':name' => $name));
+ $xpath = $this->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$fields = $this->xpath($xpath);
if ($fields) {
$field = $fields[0];
@@ -565,7 +565,7 @@ class ManageDisplayTest extends WebTestBase {
* An array of option values as strings.
*/
protected function getAllOptionsList(\SimpleXMLElement $element) {
- $options = array();
+ $options = [];
// Add all options items.
foreach ($element->option as $option) {
$options[] = (string) $option['value'];
diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
index cbe9f53e9f5..6be13664e31 100644
--- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
@@ -26,7 +26,7 @@ class ManageFieldsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_ui', 'field_test', 'taxonomy', 'image', 'block');
+ public static $modules = ['node', 'field_ui', 'field_test', 'taxonomy', 'image', 'block'];
/**
* The ID of the custom content type created for testing.
@@ -68,12 +68,12 @@ class ManageFieldsTest extends WebTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create a test user.
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access']);
$this->drupalLogin($admin_user);
// Create content type, with underscores.
$type_name = strtolower($this->randomMachineName(8)) . '_test';
- $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
+ $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$this->contentType = $type->id();
// Create random field name with markup to test escaping.
@@ -82,22 +82,22 @@ class ManageFieldsTest extends WebTestBase {
$this->fieldName = 'field_' . $this->fieldNameInput;
// Create Basic page and Article node types.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Create a vocabulary named "Tags".
- $vocabulary = Vocabulary::create(array(
+ $vocabulary = Vocabulary::create([
'name' => 'Tags',
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
$vocabulary->save();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
- ),
- );
+ ],
+ ];
$this->createEntityReferenceField('node', 'article', 'field_' . $vocabulary->id(), 'Tags', 'taxonomy_term', 'default', $handler_settings);
entity_get_form_display('node', 'article', 'default')
@@ -132,15 +132,15 @@ class ManageFieldsTest extends WebTestBase {
$type = empty($type) ? $this->contentType : $type;
$this->drupalGet('admin/structure/types/manage/' . $type . '/fields');
// Check all table columns.
- $table_headers = array(
+ $table_headers = [
t('Label'),
t('Machine name'),
t('Field type'),
t('Operations'),
- );
+ ];
foreach ($table_headers as $table_header) {
// We check that the label appear in the table headings.
- $this->assertRaw($table_header . '</th>', format_string('%table_header table header was found.', array('%table_header' => $table_header)));
+ $this->assertRaw($table_header . '</th>', format_string('%table_header table header was found.', ['%table_header' => $table_header]));
}
// Test the "Add field" action link.
@@ -194,16 +194,16 @@ class ManageFieldsTest extends WebTestBase {
// Populate the field settings with new settings.
$string = 'updated dummy test string';
- $edit = array(
+ $edit = [
'settings[test_field_storage_setting]' => $string,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save field settings'));
// Go to the field edit page.
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
- $edit = array(
+ $edit = [
'settings[test_field_setting]' => $string,
- );
+ ];
$this->assertText(t('Default value'), 'Default value heading is shown');
$this->drupalPostForm(NULL, $edit, t('Save settings'));
@@ -226,7 +226,7 @@ class ManageFieldsTest extends WebTestBase {
// do not show up in the "Re-use existing field" list.
$this->assertFalse($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value="comment"]'), 'The list of options respects entity type restrictions.');
// Validate the FALSE assertion above by also testing a valid one.
- $this->assertTrue($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value=:field_name]', array(':field_name' => $this->fieldName)), 'The list of options shows a valid option.');
+ $this->assertTrue($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value=:field_name]', [':field_name' => $this->fieldName]), 'The list of options shows a valid option.');
// Add a new field based on an existing field.
$this->fieldUIAddExistingField("admin/structure/types/manage/page", $this->fieldName, $this->fieldLabel . '_2');
@@ -243,18 +243,18 @@ class ManageFieldsTest extends WebTestBase {
// Assert the cardinality other field cannot be empty when cardinality is
// set to 'number'.
- $edit = array(
+ $edit = [
'cardinality' => 'number',
'cardinality_number' => '',
- );
+ ];
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Number of values is required.');
// Submit a custom number.
- $edit = array(
+ $edit = [
'cardinality' => 'number',
'cardinality_number' => 6,
- );
+ ];
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Updated field Body field settings.');
$this->drupalGet($field_edit_path);
@@ -285,9 +285,9 @@ class ManageFieldsTest extends WebTestBase {
$this->drupalPostForm('node/add/article', $edit, 'Save');
// Set to unlimited.
- $edit = array(
+ $edit = [
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- );
+ ];
$this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
$this->assertText('Updated field Body field settings.');
$this->drupalGet($field_edit_path);
@@ -340,7 +340,7 @@ class ManageFieldsTest extends WebTestBase {
// Delete all the body field instances.
$this->drupalGet('admin/structure/types/manage/' . $node_type . '/fields/node.' . $node_type . '.' . $this->fieldName);
$this->clickLink(t('Delete'));
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
}
// Check "Re-use existing field" appears.
$this->drupalGet('admin/structure/types/manage/page/fields/add-field');
@@ -387,17 +387,17 @@ class ManageFieldsTest extends WebTestBase {
$field_exceed_max_length_input = $this->randomMachineName(23);
// Try to create the field.
- $edit = array(
+ $edit = [
'label' => $field_exceed_max_length_label,
'field_name' => $field_exceed_max_length_input,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $this->contentType . '/fields/add-field', $edit, t('Save and continue'));
$this->assertText('Machine-readable name cannot be longer than 22 characters but is currently 23 characters long.');
// Create a valid field.
$this->fieldUIAddNewField('admin/structure/types/manage/' . $this->contentType, $this->fieldNameInput, $this->fieldLabel);
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/node.' . $this->contentType . '.' . $field_prefix . $this->fieldNameInput);
- $this->assertText(format_string('@label settings for @type', array('@label' => $this->fieldLabel, '@type' => $this->contentType)));
+ $this->assertText(format_string('@label settings for @type', ['@label' => $this->fieldLabel, '@type' => $this->contentType]));
}
/**
@@ -406,16 +406,16 @@ class ManageFieldsTest extends WebTestBase {
function testDefaultValue() {
// Create a test field storage and field.
$field_name = 'test';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'test_field'
- ))->save();
- $field = FieldConfig::create(array(
+ ])->save();
+ $field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $this->contentType,
- ));
+ ]);
$field->save();
entity_get_form_display('node', $this->contentType, 'default')
@@ -429,23 +429,23 @@ class ManageFieldsTest extends WebTestBase {
$this->assertFieldById($element_id, '', 'The default value widget was empty.');
// Check that invalid default values are rejected.
- $edit = array($element_name => '-1');
+ $edit = [$element_name => '-1'];
$this->drupalPostForm($admin_path, $edit, t('Save settings'));
$this->assertText("$field_name does not accept the value -1", 'Form validation failed.');
// Check that the default value is saved.
- $edit = array($element_name => '1');
+ $edit = [$element_name => '1'];
$this->drupalPostForm($admin_path, $edit, t('Save settings'));
$this->assertText("Saved $field_name configuration", 'The form was successfully submitted.');
$field = FieldConfig::loadByName('node', $this->contentType, $field_name);
- $this->assertEqual($field->getDefaultValueLiteral(), array(array('value' => 1)), 'The default value was correctly saved.');
+ $this->assertEqual($field->getDefaultValueLiteral(), [['value' => 1]], 'The default value was correctly saved.');
// Check that the default value shows up in the form
$this->drupalGet($admin_path);
$this->assertFieldById($element_id, '1', 'The default value widget was displayed with the correct value.');
// Check that the default value can be emptied.
- $edit = array($element_name => '');
+ $edit = [$element_name => ''];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->assertText("Saved $field_name configuration", 'The form was successfully submitted.');
$field = FieldConfig::loadByName('node', $this->contentType, $field_name);
@@ -458,13 +458,13 @@ class ManageFieldsTest extends WebTestBase {
$field_storage->save();
$this->drupalGet($admin_path);
- $edit = array(
+ $edit = [
'required' => 1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->drupalGet($admin_path);
- $this->drupalPostForm(NULL, array(), t('Save settings'));
+ $this->drupalPostForm(NULL, [], t('Save settings'));
$this->assertText("Saved $field_name configuration", 'The form was successfully submitted.');
$field = FieldConfig::loadByName('node', $this->contentType, $field_name);
$this->assertEqual($field->getDefaultValueLiteral(), NULL, 'The default value was correctly saved.');
@@ -486,7 +486,7 @@ class ManageFieldsTest extends WebTestBase {
// Create an additional node type.
$type_name2 = strtolower($this->randomMachineName(8)) . '_test';
- $type2 = $this->drupalCreateContentType(array('name' => $type_name2, 'type' => $type_name2));
+ $type2 = $this->drupalCreateContentType(['name' => $type_name2, 'type' => $type_name2]);
$type_name2 = $type2->id();
// Add a field to the second node type.
@@ -518,10 +518,10 @@ class ManageFieldsTest extends WebTestBase {
$this->config('field_ui.settings')->set('field_prefix', '')->save();
$label = 'Disallowed field';
- $edit = array(
+ $edit = [
'label' => $label,
'new_storage_type' => 'test_field',
- );
+ ];
// Try with an entity key.
$edit['field_name'] = 'title';
@@ -543,31 +543,31 @@ class ManageFieldsTest extends WebTestBase {
// Create a locked field and attach it to a bundle. We need to do this
// programmatically as there's no way to create a locked field through UI.
$field_name = strtolower($this->randomMachineName(8));
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'test_field',
'cardinality' => 1,
'locked' => TRUE
- ));
+ ]);
$field_storage->save();
- FieldConfig::create(array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $this->contentType,
- ))->save();
+ ])->save();
entity_get_form_display('node', $this->contentType, 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'test_field_widget',
- ))
+ ])
->save();
// Check that the links for edit and delete are not present.
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields');
- $locked = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field_name));
+ $locked = $this->xpath('//tr[@id=:field_name]/td[4]', [':field_name' => $field_name]);
$this->assertTrue(in_array('Locked', $locked), 'Field is marked as Locked in the UI');
- $edit_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field_name));
+ $edit_link = $this->xpath('//tr[@id=:field_name]/td[4]', [':field_name' => $field_name]);
$this->assertFalse(in_array('edit', $edit_link), 'Edit option for locked field is not present the UI');
- $delete_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field_name));
+ $delete_link = $this->xpath('//tr[@id=:field_name]/td[4]', [':field_name' => $field_name]);
$this->assertFalse(in_array('delete', $delete_link), 'Delete option for locked field is not present the UI');
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/node.' . $this->contentType . '.' . $field_name . '/delete');
$this->assertResponse(403);
@@ -584,22 +584,22 @@ class ManageFieldsTest extends WebTestBase {
// Create a field storage and a field programmatically.
$field_name = 'hidden_test_field';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => $field_name,
- ))->save();
- $field = array(
+ ])->save();
+ $field = [
'field_name' => $field_name,
'bundle' => $this->contentType,
'entity_type' => 'node',
'label' => t('Hidden field'),
- );
+ ];
FieldConfig::create($field)->save();
entity_get_form_display('node', $this->contentType, 'default')
->setComponent($field_name)
->save();
- $this->assertTrue(FieldConfig::load('node.' . $this->contentType . '.' . $field_name), format_string('A field of the field storage %field was created programmatically.', array('%field' => $field_name)));
+ $this->assertTrue(FieldConfig::load('node.' . $this->contentType . '.' . $field_name), format_string('A field of the field storage %field was created programmatically.', ['%field' => $field_name]));
// Check that the newly added field appears on the 'Manage Fields'
// screen.
@@ -609,17 +609,17 @@ class ManageFieldsTest extends WebTestBase {
// Check that the field does not appear in the 're-use existing field' row
// on other bundles.
$this->drupalGet('admin/structure/types/manage/page/fields/add-field');
- $this->assertFalse($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), "The 're-use existing field' select respects field types 'no_ui' property.");
- $this->assertTrue($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value=:field_name]', array(':field_name' => 'field_tags')), "The 're-use existing field' select shows a valid option.");
+ $this->assertFalse($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value=:field_name]', [':field_name' => $field_name]), "The 're-use existing field' select respects field types 'no_ui' property.");
+ $this->assertTrue($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value=:field_name]', [':field_name' => 'field_tags']), "The 're-use existing field' select shows a valid option.");
// Check that non-configurable fields are not available.
$field_types = \Drupal::service('plugin.manager.field.field_type')->getDefinitions();
foreach ($field_types as $field_type => $definition) {
if (empty($definition['no_ui'])) {
- $this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), SafeMarkup::format('Configurable field type @field_type is available.', array('@field_type' => $field_type)));
+ $this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', [':field_type' => $field_type]), SafeMarkup::format('Configurable field type @field_type is available.', ['@field_type' => $field_type]));
}
else {
- $this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), SafeMarkup::format('Non-configurable field type @field_type is not available.', array('@field_type' => $field_type)));
+ $this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', [':field_type' => $field_type]), SafeMarkup::format('Non-configurable field type @field_type is not available.', ['@field_type' => $field_type]));
}
}
}
@@ -630,16 +630,16 @@ class ManageFieldsTest extends WebTestBase {
function testDuplicateFieldName() {
// field_tags already exists, so we're expecting an error when trying to
// create a new field with the same name.
- $edit = array(
+ $edit = [
'field_name' => 'tags',
'label' => $this->randomMachineName(),
'new_storage_type' => 'entity_reference',
- );
+ ];
$url = 'admin/structure/types/manage/' . $this->contentType . '/fields/add-field';
$this->drupalPostForm($url, $edit, t('Save and continue'));
$this->assertText(t('The machine-readable name is already in use. It must be unique.'));
- $this->assertUrl($url, array(), 'Stayed on the same page.');
+ $this->assertUrl($url, [], 'Stayed on the same page.');
}
/**
@@ -679,24 +679,24 @@ class ManageFieldsTest extends WebTestBase {
*/
function testHelpDescriptions() {
// Create an image field
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_image',
'entity_type' => 'node',
'type' => 'image',
- ))->save();
+ ])->save();
- FieldConfig::create(array(
+ FieldConfig::create([
'field_name' => 'field_image',
'entity_type' => 'node',
'label' => 'Image',
'bundle' => 'article',
- ))->save();
+ ])->save();
entity_get_form_display('node', 'article', 'default')->setComponent('field_image')->save();
- $edit = array(
+ $edit = [
'description' => '<strong>Test with an upload field.',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image', $edit, t('Save settings'));
// Check that hook_field_widget_form_alter() does believe this is the
@@ -704,9 +704,9 @@ class ManageFieldsTest extends WebTestBase {
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_tags');
$this->assertText('From hook_field_widget_form_alter(): Default form is true.', 'Default value form in hook_field_widget_form_alter().');
- $edit = array(
+ $edit = [
'description' => '<em>Test with a non upload field.',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags', $edit, t('Save settings'));
$this->drupalGet('node/add/article');
diff --git a/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module
index 5fb232b7c53..95234f1baab 100644
--- a/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module
+++ b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module
@@ -15,41 +15,41 @@ function field_ui_test_form_entity_view_display_edit_form_alter(&$form, FormStat
$table = &$form['fields'];
foreach (Element::children($table) as $name) {
- $table[$name]['parent_wrapper']['parent']['#options'] = array('indent' => 'Indent');
+ $table[$name]['parent_wrapper']['parent']['#options'] = ['indent' => 'Indent'];
$table[$name]['parent_wrapper']['parent']['#default_value'] = 'indent';
}
$table['indent'] = [
- '#attributes' => array('class' => array('draggable', 'field-group'), 'id' => 'indent-id'),
+ '#attributes' => ['class' => ['draggable', 'field-group'], 'id' => 'indent-id'],
'#row_type' => 'group',
'#region_callback' => 'field_ui_test_region_callback',
- '#js_settings' => array('rowHandler' => 'group'),
- 'human_name' => array(
+ '#js_settings' => ['rowHandler' => 'group'],
+ 'human_name' => [
'#markup' => 'Indent',
'#prefix' => '<span class="group-label">',
'#suffix' => '</span>',
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'#type' => 'textfield',
'#default_value' => 0,
'#size' => 3,
- '#attributes' => array('class' => array('field-weight')),
- ),
- 'parent_wrapper' => array(
- 'parent' => array(
+ '#attributes' => ['class' => ['field-weight']],
+ ],
+ 'parent_wrapper' => [
+ 'parent' => [
'#type' => 'select',
- '#options' => array('indent' => 'Indent'),
+ '#options' => ['indent' => 'Indent'],
'#empty_value' => '',
'#default_value' => '',
- '#attributes' => array('class' => array('field-parent')),
- '#parents' => array('fields', 'indent', 'parent'),
- ),
- 'hidden_name' => array(
+ '#attributes' => ['class' => ['field-parent']],
+ '#parents' => ['fields', 'indent', 'parent'],
+ ],
+ 'hidden_name' => [
'#type' => 'hidden',
'#default_value' => 'indent',
- '#attributes' => array('class' => array('field-name')),
- ),
- ),
+ '#attributes' => ['class' => ['field-name']],
+ ],
+ ],
];
}
diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
index 1d2cab0549d..3bb0b139d7b 100644
--- a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
+++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
@@ -35,7 +35,7 @@ class EntityDisplayModeTest extends BrowserTestBase {
// Test the listing page.
$this->drupalGet('admin/structure/display-modes/view');
$this->assertResponse(403);
- $this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
+ $this->drupalLogin($this->drupalCreateUser(['administer display modes']));
$this->drupalGet('admin/structure/display-modes/view');
$this->assertResponse(200);
$this->assertText(t('Add view mode'));
@@ -50,29 +50,29 @@ class EntityDisplayModeTest extends BrowserTestBase {
// Test adding a view mode including dots in machine_name.
$this->clickLink(t('Test entity'));
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName()) . '.' . strtolower($this->randomMachineName()),
'label' => $this->randomString(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
// Test adding a view mode.
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName()),
'label' => $this->randomString(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('Saved the %label view mode.', array('%label' => $edit['label'])));
+ $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
// Test editing the view mode.
$this->drupalGet('admin/structure/display-modes/view/manage/entity_test.' . $edit['id']);
// Test deleting the view mode.
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete the view mode %label?', array('%label' => $edit['label'])));
+ $this->assertRaw(t('Are you sure you want to delete the view mode %label?', ['%label' => $edit['label']]));
$this->drupalPostForm(NULL, NULL, t('Delete'));
- $this->assertRaw(t('The view mode %label has been deleted.', array('%label' => $edit['label'])));
+ $this->assertRaw(t('The view mode %label has been deleted.', ['%label' => $edit['label']]));
}
/**
@@ -82,7 +82,7 @@ class EntityDisplayModeTest extends BrowserTestBase {
// Test the listing page.
$this->drupalGet('admin/structure/display-modes/form');
$this->assertResponse(403);
- $this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
+ $this->drupalLogin($this->drupalCreateUser(['administer display modes']));
$this->drupalGet('admin/structure/display-modes/form');
$this->assertResponse(200);
$this->assertText(t('Add form mode'));
@@ -96,29 +96,29 @@ class EntityDisplayModeTest extends BrowserTestBase {
// Test adding a view mode including dots in machine_name.
$this->clickLink(t('Test entity'));
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName()) . '.' . strtolower($this->randomMachineName()),
'label' => $this->randomString(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
// Test adding a form mode.
- $edit = array(
+ $edit = [
'id' => strtolower($this->randomMachineName()),
'label' => $this->randomString(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('Saved the %label form mode.', array('%label' => $edit['label'])));
+ $this->assertRaw(t('Saved the %label form mode.', ['%label' => $edit['label']]));
// Test editing the form mode.
$this->drupalGet('admin/structure/display-modes/form/manage/entity_test.' . $edit['id']);
// Test deleting the form mode.
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete the form mode %label?', array('%label' => $edit['label'])));
+ $this->assertRaw(t('Are you sure you want to delete the form mode %label?', ['%label' => $edit['label']]));
$this->drupalPostForm(NULL, NULL, t('Delete'));
- $this->assertRaw(t('The form mode %label has been deleted.', array('%label' => $edit['label'])));
+ $this->assertRaw(t('The form mode %label has been deleted.', ['%label' => $edit['label']]));
}
}
diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
index 528f2c4d80c..3eb90d04d5f 100644
--- a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
+++ b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
@@ -16,7 +16,7 @@ class FieldUIIndentationTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_ui', 'field_ui_test');
+ public static $modules = ['node', 'field_ui', 'field_ui_test'];
/**
* {@inheritdoc}
@@ -25,11 +25,11 @@ class FieldUIIndentationTest extends BrowserTestBase {
parent::setUp();
// Create a test user.
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node display'));
+ $admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node display']);
$this->drupalLogin($admin_user);
// Create Basic page node type.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
}
diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php
index 1e954e5dfa3..fe7a27011ca 100644
--- a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php
+++ b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php
@@ -49,7 +49,7 @@ class FieldUIRouteTest extends BrowserTestBase {
$this->assertTitle('Manage display | Drupal');
$this->assertLocalTasks();
- $edit = array('display_modes_custom[compact]' => TRUE);
+ $edit = ['display_modes_custom[compact]' => TRUE];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->drupalGet('admin/config/people/accounts/display/compact');
$this->assertTitle('Manage display | Drupal');
@@ -63,37 +63,37 @@ class FieldUIRouteTest extends BrowserTestBase {
$this->assertTitle('Manage form display | Drupal');
$this->assertLocalTasks();
- $edit = array('display_modes_custom[register]' => TRUE);
+ $edit = ['display_modes_custom[register]' => TRUE];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertResponse(200);
$this->drupalGet('admin/config/people/accounts/form-display/register');
$this->assertTitle('Manage form display | Drupal');
$this->assertLocalTasks();
- $this->assert(count($this->xpath('//ul/li[1]/a[contains(text(), :text)]', array(':text' => 'Default'))) == 1, 'Default secondary tab is in first position.');
+ $this->assert(count($this->xpath('//ul/li[1]/a[contains(text(), :text)]', [':text' => 'Default'])) == 1, 'Default secondary tab is in first position.');
// Create new view mode and verify it's available on the Manage Display
// screen after enabling it.
- EntityViewMode::create(array(
+ EntityViewMode::create([
'id' => 'user.test',
'label' => 'Test',
'targetEntityType' => 'user',
- ))->save();
+ ])->save();
$this->container->get('router.builder')->rebuildIfNeeded();
- $edit = array('display_modes_custom[test]' => TRUE);
+ $edit = ['display_modes_custom[test]' => TRUE];
$this->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save'));
$this->assertLink('Test');
// Create new form mode and verify it's available on the Manage Form
// Display screen after enabling it.
- EntityFormMode::create(array(
+ EntityFormMode::create([
'id' => 'user.test',
'label' => 'Test',
'targetEntityType' => 'user',
- ))->save();
+ ])->save();
$this->container->get('router.builder')->rebuildIfNeeded();
- $edit = array('display_modes_custom[test]' => TRUE);
+ $edit = ['display_modes_custom[test]' => TRUE];
$this->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save'));
$this->assertLink('Test');
}
diff --git a/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php b/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php
index d0601639b87..9e46d82da9e 100644
--- a/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php
+++ b/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php
@@ -29,46 +29,46 @@ class EntityDisplayTest extends KernelTestBase {
*
* @var string[]
*/
- public static $modules = array('field_ui', 'field', 'entity_test', 'user', 'text', 'field_test', 'node', 'system');
+ public static $modules = ['field_ui', 'field', 'entity_test', 'user', 'text', 'field_test', 'node', 'system'];
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('user');
- $this->installConfig(array('field', 'node', 'user'));
+ $this->installConfig(['field', 'node', 'user']);
}
/**
* Tests basic CRUD operations on entity display objects.
*/
public function testEntityDisplayCRUD() {
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ));
+ ]);
- $expected = array();
+ $expected = [];
// Check that providing no 'weight' results in the highest current weight
// being assigned. The 'name' field's formatter has weight -5, therefore
// these follow.
- $expected['component_1'] = array('weight' => -4, 'settings' => array(), 'third_party_settings' => array());
- $expected['component_2'] = array('weight' => -3, 'settings' => array(), 'third_party_settings' => array());
+ $expected['component_1'] = ['weight' => -4, 'settings' => [], 'third_party_settings' => []];
+ $expected['component_2'] = ['weight' => -3, 'settings' => [], 'third_party_settings' => []];
$display->setComponent('component_1');
$display->setComponent('component_2');
$this->assertEqual($display->getComponent('component_1'), $expected['component_1']);
$this->assertEqual($display->getComponent('component_2'), $expected['component_2']);
// Check that arbitrary options are correctly stored.
- $expected['component_3'] = array('weight' => 10, 'third_party_settings' => array('field_test' => array('foo' => 'bar')), 'settings' => array());
+ $expected['component_3'] = ['weight' => 10, 'third_party_settings' => ['field_test' => ['foo' => 'bar']], 'settings' => []];
$display->setComponent('component_3', $expected['component_3']);
$this->assertEqual($display->getComponent('component_3'), $expected['component_3']);
// Check that the display can be properly saved and read back.
$display->save();
$display = EntityViewDisplay::load($display->id());
- foreach (array('component_1', 'component_2', 'component_3') as $name) {
+ foreach (['component_1', 'component_2', 'component_3'] as $name) {
$expected[$name]['region'] = 'content';
$this->assertEqual($display->getComponent($name), $expected[$name]);
}
@@ -79,16 +79,16 @@ class EntityDisplayTest extends KernelTestBase {
$this->assertEqual('bar', $display->getThirdPartySetting('entity_test', 'foo'), 'Third party settings were added to the entity view display.');
// Check that getComponents() returns options for all components.
- $expected['name'] = array(
+ $expected['name'] = [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
- 'settings' => array(
+ 'settings' => [
'link_to_entity' => FALSE,
- ),
- 'third_party_settings' => array(),
+ ],
+ 'third_party_settings' => [],
'region' => 'content'
- );
+ ];
$this->assertEqual($display->getComponents(), $expected);
// Check that a component can be removed.
@@ -102,12 +102,12 @@ class EntityDisplayTest extends KernelTestBase {
// Check that createCopy() creates a new component that can be correctly
// saved.
- EntityViewMode::create(array('id' => $display->getTargetEntityTypeId() . '.other_view_mode', 'targetEntityType' => $display->getTargetEntityTypeId()))->save();
+ EntityViewMode::create(['id' => $display->getTargetEntityTypeId() . '.other_view_mode', 'targetEntityType' => $display->getTargetEntityTypeId()])->save();
$new_display = $display->createCopy('other_view_mode');
$new_display->save();
$new_display = EntityViewDisplay::load($new_display->id());
$dependencies = $new_display->calculateDependencies()->getDependencies();
- $this->assertEqual(array('config' => array('core.entity_view_mode.entity_test.other_view_mode'), 'module' => array('entity_test')), $dependencies);
+ $this->assertEqual(['config' => ['core.entity_view_mode.entity_test.other_view_mode'], 'module' => ['entity_test']], $dependencies);
$this->assertEqual($new_display->getTargetEntityTypeId(), $display->getTargetEntityTypeId());
$this->assertEqual($new_display->getTargetBundle(), $display->getTargetBundle());
$this->assertEqual($new_display->getMode(), 'other_view_mode');
@@ -118,18 +118,18 @@ class EntityDisplayTest extends KernelTestBase {
* Test sorting of components by name on basic CRUD operations
*/
public function testEntityDisplayCRUDSort() {
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ));
+ ]);
$display->setComponent('component_3');
$display->setComponent('component_1');
$display->setComponent('component_2');
$display->save();
$components = array_keys($display->getComponents());
// The name field is not configurable so will be added automatically.
- $expected = array ( 0 => 'component_1', 1 => 'component_2', 2 => 'component_3', 'name');
+ $expected = [ 0 => 'component_1', 1 => 'component_2', 2 => 'component_3', 'name'];
$this->assertIdentical($components, $expected);
}
@@ -143,14 +143,14 @@ class EntityDisplayTest extends KernelTestBase {
$this->assertTrue($display->isNew());
// Add some components and save the display.
- $display->setComponent('component_1', array('weight' => 10, 'settings' => array()))
+ $display->setComponent('component_1', ['weight' => 10, 'settings' => []])
->save();
// Check that entity_get_display() returns the correct object.
$display = entity_get_display('entity_test', 'entity_test', 'default');
$this->assertFalse($display->isNew());
$this->assertEqual($display->id(), 'entity_test.entity_test.default');
- $this->assertEqual($display->getComponent('component_1'), array( 'weight' => 10, 'settings' => array(), 'third_party_settings' => array(), 'region' => 'content'));
+ $this->assertEqual($display->getComponent('component_1'), [ 'weight' => 10, 'settings' => [], 'third_party_settings' => [], 'region' => 'content']);
}
/**
@@ -158,22 +158,22 @@ class EntityDisplayTest extends KernelTestBase {
*/
public function testExtraFieldComponent() {
entity_test_create_bundle('bundle_with_extra_fields');
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'bundle_with_extra_fields',
'mode' => 'default',
- ));
+ ]);
// Check that the default visibility taken into account for extra fields
// unknown in the display.
- $this->assertEqual($display->getComponent('display_extra_field'), array('weight' => 5, 'region' => 'content'));
+ $this->assertEqual($display->getComponent('display_extra_field'), ['weight' => 5, 'region' => 'content']);
$this->assertNull($display->getComponent('display_extra_field_hidden'));
// Check that setting explicit options overrides the defaults.
$display->removeComponent('display_extra_field');
- $display->setComponent('display_extra_field_hidden', array('weight' => 10));
+ $display->setComponent('display_extra_field_hidden', ['weight' => 10]);
$this->assertNull($display->getComponent('display_extra_field'));
- $this->assertEqual($display->getComponent('display_extra_field_hidden'), array('weight' => 10, 'settings' => array(), 'third_party_settings' => array()));
+ $this->assertEqual($display->getComponent('display_extra_field_hidden'), ['weight' => 10, 'settings' => [], 'third_party_settings' => []]);
}
/**
@@ -181,7 +181,7 @@ class EntityDisplayTest extends KernelTestBase {
*/
public function testExtraFieldComponentInitialInvalidConfig() {
entity_test_create_bundle('bundle_with_extra_fields');
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'bundle_with_extra_fields',
'mode' => 'default',
@@ -191,18 +191,18 @@ class EntityDisplayTest extends KernelTestBase {
'weight' => 5,
],
],
- ));
+ ]);
// Check that the default visibility taken into account for extra fields
// unknown in the display that were included in the initial config.
- $this->assertEqual($display->getComponent('display_extra_field'), array('weight' => 5, 'region' => 'content'));
+ $this->assertEqual($display->getComponent('display_extra_field'), ['weight' => 5, 'region' => 'content']);
$this->assertNull($display->getComponent('display_extra_field_hidden'));
// Check that setting explicit options overrides the defaults.
$display->removeComponent('display_extra_field');
- $display->setComponent('display_extra_field_hidden', array('weight' => 10));
+ $display->setComponent('display_extra_field_hidden', ['weight' => 10]);
$this->assertNull($display->getComponent('display_extra_field'));
- $this->assertEqual($display->getComponent('display_extra_field_hidden'), array('weight' => 10, 'settings' => array(), 'third_party_settings' => array()));
+ $this->assertEqual($display->getComponent('display_extra_field_hidden'), ['weight' => 10, 'settings' => [], 'third_party_settings' => []]);
}
/**
@@ -211,36 +211,36 @@ class EntityDisplayTest extends KernelTestBase {
public function testFieldComponent() {
$field_name = 'test_field';
// Create a field storage and a field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ));
+ ]);
// Check that providing no options results in default values being used.
$display->setComponent($field_name);
$field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field_storage->getType());
$default_formatter = $field_type_info['default_formatter'];
$formatter_settings = \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings($default_formatter);
- $expected = array(
+ $expected = [
'weight' => -4,
'label' => 'above',
'type' => $default_formatter,
'settings' => $formatter_settings,
- 'third_party_settings' => array(),
- );
+ 'third_party_settings' => [],
+ ];
$this->assertEqual($display->getComponent($field_name), $expected);
// Check that the getFormatter() method returns the correct formatter plugin.
@@ -256,9 +256,9 @@ class EntityDisplayTest extends KernelTestBase {
$this->assertEqual($formatter->randomValue, $random_value);
// Check that changing the definition creates a new formatter.
- $display->setComponent($field_name, array(
+ $display->setComponent($field_name, [
'type' => 'field_test_multiple',
- ));
+ ]);
$formatter = $display->getRenderer($field_name);
$this->assertEqual($formatter->getPluginId(), 'field_test_multiple');
$this->assertFalse(isset($formatter->randomValue));
@@ -266,40 +266,40 @@ class EntityDisplayTest extends KernelTestBase {
// Check that the display has dependencies on the field and the module that
// provides the formatter.
$dependencies = $display->calculateDependencies()->getDependencies();
- $this->assertEqual(array('config' => array('field.field.entity_test.entity_test.test_field'), 'module' => array('entity_test', 'field_test')), $dependencies);
+ $this->assertEqual(['config' => ['field.field.entity_test.entity_test.test_field'], 'module' => ['entity_test', 'field_test']], $dependencies);
}
/**
* Tests the behavior of a field component for a base field.
*/
public function testBaseFieldComponent() {
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test_base_field_display',
'bundle' => 'entity_test_base_field_display',
'mode' => 'default',
- ));
+ ]);
// Check that default options are correctly filled in.
$formatter_settings = \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings('text_default');
- $expected = array(
+ $expected = [
'test_no_display' => NULL,
- 'test_display_configurable' => array(
+ 'test_display_configurable' => [
'label' => 'above',
'type' => 'text_default',
'settings' => $formatter_settings,
- 'third_party_settings' => array(),
+ 'third_party_settings' => [],
'weight' => 10,
'region' => 'content',
- ),
- 'test_display_non_configurable' => array(
+ ],
+ 'test_display_non_configurable' => [
'label' => 'above',
'type' => 'text_default',
'settings' => $formatter_settings,
- 'third_party_settings' => array(),
+ 'third_party_settings' => [],
'weight' => 11,
'region' => 'content',
- ),
- );
+ ],
+ ];
foreach ($expected as $field_name => $options) {
$this->assertEqual($display->getComponent($field_name), $options);
}
@@ -337,7 +337,7 @@ class EntityDisplayTest extends KernelTestBase {
*/
public function testDeleteBundle() {
// Create a node bundle, display and form display object.
- $type = NodeType::create(array('type' => 'article'));
+ $type = NodeType::create(['type' => 'article']);
$type->save();
node_add_body_field($type);
entity_get_display('node', 'article', 'default')->save();
@@ -357,30 +357,30 @@ class EntityDisplayTest extends KernelTestBase {
public function testDeleteField() {
$field_name = 'test_field';
// Create a field storage and a field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
// Create default and teaser entity display.
- EntityViewMode::create(array('id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save();
- EntityViewDisplay::create(array(
+ EntityViewMode::create(['id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'])->save();
+ EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ))->setComponent($field_name)->save();
- EntityViewDisplay::create(array(
+ ])->setComponent($field_name)->save();
+ EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'teaser',
- ))->setComponent($field_name)->save();
+ ])->setComponent($field_name)->save();
// Check the component exists.
$display = entity_get_display('entity_test', 'entity_test', 'default');
@@ -402,27 +402,27 @@ class EntityDisplayTest extends KernelTestBase {
* Tests \Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval().
*/
public function testOnDependencyRemoval() {
- $this->enableModules(array('field_plugins_test'));
+ $this->enableModules(['field_plugins_test']);
$field_name = 'test_field';
// Create a field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text'
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
- EntityViewDisplay::create(array(
+ EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ))->setComponent($field_name, array('type' => 'field_plugins_test_text_formatter'))->save();
+ ])->setComponent($field_name, ['type' => 'field_plugins_test_text_formatter'])->save();
// Check the component exists and is of the correct type.
$display = entity_get_display('entity_test', 'entity_test', 'default');
@@ -460,47 +460,47 @@ class EntityDisplayTest extends KernelTestBase {
* Test getDisplayModeOptions().
*/
public function testGetDisplayModeOptions() {
- NodeType::create(array('type' => 'article'))->save();
+ NodeType::create(['type' => 'article'])->save();
- EntityViewDisplay::create(array(
+ EntityViewDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'article',
'mode' => 'default',
- ))->setStatus(TRUE)->save();
+ ])->setStatus(TRUE)->save();
- $display_teaser = EntityViewDisplay::create(array(
+ $display_teaser = EntityViewDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'article',
'mode' => 'teaser',
- ));
+ ]);
$display_teaser->save();
- EntityFormDisplay::create(array(
+ EntityFormDisplay::create([
'targetEntityType' => 'user',
'bundle' => 'user',
'mode' => 'default',
- ))->setStatus(TRUE)->save();
+ ])->setStatus(TRUE)->save();
- $form_display_teaser = EntityFormDisplay::create(array(
+ $form_display_teaser = EntityFormDisplay::create([
'targetEntityType' => 'user',
'bundle' => 'user',
'mode' => 'register',
- ));
+ ]);
$form_display_teaser->save();
// Test getViewModeOptionsByBundle().
$view_modes = \Drupal::entityManager()->getViewModeOptionsByBundle('node', 'article');
- $this->assertEqual($view_modes, array('default' => 'Default'));
+ $this->assertEqual($view_modes, ['default' => 'Default']);
$display_teaser->setStatus(TRUE)->save();
$view_modes = \Drupal::entityManager()->getViewModeOptionsByBundle('node', 'article');
- $this->assertEqual($view_modes, array('default' => 'Default', 'teaser' => 'Teaser'));
+ $this->assertEqual($view_modes, ['default' => 'Default', 'teaser' => 'Teaser']);
// Test getFormModeOptionsByBundle().
$form_modes = \Drupal::entityManager()->getFormModeOptionsByBundle('user', 'user');
- $this->assertEqual($form_modes, array('default' => 'Default'));
+ $this->assertEqual($form_modes, ['default' => 'Default']);
$form_display_teaser->setStatus(TRUE)->save();
$form_modes = \Drupal::entityManager()->getFormModeOptionsByBundle('user', 'user');
- $this->assertEqual($form_modes, array('default' => 'Default', 'register' => 'Register'));
+ $this->assertEqual($form_modes, ['default' => 'Default', 'register' => 'Register']);
}
/**
diff --git a/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php b/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php
index 6f770d6fdf5..09d2a20114a 100644
--- a/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php
+++ b/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php
@@ -36,14 +36,14 @@ class EntityFormDisplayTest extends KernelTestBase {
$this->assertTrue($form_display->isNew());
// Add some components and save the display.
- $form_display->setComponent('component_1', array('weight' => 10))
+ $form_display->setComponent('component_1', ['weight' => 10])
->save();
// Check that entity_get_form_display() returns the correct object.
$form_display = entity_get_form_display('entity_test', 'entity_test', 'default');
$this->assertFalse($form_display->isNew());
$this->assertEqual($form_display->id(), 'entity_test.entity_test.default');
- $this->assertEqual($form_display->getComponent('component_1'), array('weight' => 10, 'settings' => array(), 'third_party_settings' => array(), 'region' => 'content'));
+ $this->assertEqual($form_display->getComponent('component_1'), ['weight' => 10, 'settings' => [], 'third_party_settings' => [], 'region' => 'content']);
}
/**
@@ -52,35 +52,35 @@ class EntityFormDisplayTest extends KernelTestBase {
public function testFieldComponent() {
// Create a field storage and a field.
$field_name = 'test_field';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
- $form_display = EntityFormDisplay::create(array(
+ $form_display = EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ));
+ ]);
// Check that providing no options results in default values being used.
$form_display->setComponent($field_name);
$field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field_storage->getType());
$default_widget = $field_type_info['default_widget'];
$widget_settings = \Drupal::service('plugin.manager.field.widget')->getDefaultSettings($default_widget);
- $expected = array(
+ $expected = [
'weight' => 3,
'type' => $default_widget,
'settings' => $widget_settings,
- 'third_party_settings' => array(),
- );
+ 'third_party_settings' => [],
+ ];
$this->assertEqual($form_display->getComponent($field_name), $expected);
// Check that the getWidget() method returns the correct widget plugin.
@@ -96,9 +96,9 @@ class EntityFormDisplayTest extends KernelTestBase {
$this->assertEqual($widget->randomValue, $random_value);
// Check that changing the definition creates a new widget.
- $form_display->setComponent($field_name, array(
+ $form_display->setComponent($field_name, [
'type' => 'field_test_multiple',
- ));
+ ]);
$widget = $form_display->getRenderer($field_name);
$this->assertEqual($widget->getPluginId(), 'test_field_widget');
$this->assertFalse(isset($widget->randomValue));
@@ -106,9 +106,9 @@ class EntityFormDisplayTest extends KernelTestBase {
// Check that specifying an unknown widget (e.g. case of a disabled module)
// gets stored as is in the display, but results in the default widget being
// used.
- $form_display->setComponent($field_name, array(
+ $form_display->setComponent($field_name, [
'type' => 'unknown_widget',
- ));
+ ]);
$options = $form_display->getComponent($field_name);
$this->assertEqual($options['type'], 'unknown_widget');
$widget = $form_display->getRenderer($field_name);
@@ -119,31 +119,31 @@ class EntityFormDisplayTest extends KernelTestBase {
* Tests the behavior of a field component for a base field.
*/
public function testBaseFieldComponent() {
- $display = EntityFormDisplay::create(array(
+ $display = EntityFormDisplay::create([
'targetEntityType' => 'entity_test_base_field_display',
'bundle' => 'entity_test_base_field_display',
'mode' => 'default',
- ));
+ ]);
// Check that default options are correctly filled in.
$formatter_settings = \Drupal::service('plugin.manager.field.widget')->getDefaultSettings('text_textfield');
- $expected = array(
+ $expected = [
'test_no_display' => NULL,
- 'test_display_configurable' => array(
+ 'test_display_configurable' => [
'type' => 'text_textfield',
'settings' => $formatter_settings,
- 'third_party_settings' => array(),
+ 'third_party_settings' => [],
'weight' => 10,
'region' => 'content',
- ),
- 'test_display_non_configurable' => array(
+ ],
+ 'test_display_non_configurable' => [
'type' => 'text_textfield',
'settings' => $formatter_settings,
- 'third_party_settings' => array(),
+ 'third_party_settings' => [],
'weight' => 11,
'region' => 'content',
- ),
- );
+ ],
+ ];
foreach ($expected as $field_name => $options) {
$this->assertEqual($display->getComponent($field_name), $options);
}
@@ -182,30 +182,30 @@ class EntityFormDisplayTest extends KernelTestBase {
public function testDeleteField() {
$field_name = 'test_field';
// Create a field storage and a field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
// Create default and compact entity display.
- EntityFormMode::create(array('id' => 'entity_test.compact', 'targetEntityType' => 'entity_test'))->save();
- EntityFormDisplay::create(array(
+ EntityFormMode::create(['id' => 'entity_test.compact', 'targetEntityType' => 'entity_test'])->save();
+ EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ))->setComponent($field_name)->save();
- EntityFormDisplay::create(array(
+ ])->setComponent($field_name)->save();
+ EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'compact',
- ))->setComponent($field_name)->save();
+ ])->setComponent($field_name)->save();
// Check the component exists.
$display = entity_get_form_display('entity_test', 'entity_test', 'default');
@@ -227,27 +227,27 @@ class EntityFormDisplayTest extends KernelTestBase {
* Tests \Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval().
*/
public function testOnDependencyRemoval() {
- $this->enableModules(array('field_plugins_test'));
+ $this->enableModules(['field_plugins_test']);
$field_name = 'test_field';
// Create a field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text'
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
- EntityFormDisplay::create(array(
+ EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ))->setComponent($field_name, array('type' => 'field_plugins_test_text_widget'))->save();
+ ])->setComponent($field_name, ['type' => 'field_plugins_test_text_widget'])->save();
// Check the component exists and is of the correct type.
$display = entity_get_form_display('entity_test', 'entity_test', 'default');
diff --git a/core/modules/file/file.api.php b/core/modules/file/file.api.php
index c7994ff7231..1fda717da7a 100644
--- a/core/modules/file/file.api.php
+++ b/core/modules/file/file.api.php
@@ -25,7 +25,7 @@
* @see file_validate()
*/
function hook_file_validate(Drupal\file\FileInterface $file) {
- $errors = array();
+ $errors = [];
if (!$file->getFilename()) {
$errors[] = t("The file's name is empty. Please give a name to the file.");
@@ -53,7 +53,7 @@ function hook_file_copy(Drupal\file\FileInterface $file, Drupal\file\FileInterfa
$file->setFilename($file->getOwner()->name . '_' . $file->getFilename());
$file->save();
- \Drupal::logger('file')->notice('Copied file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->getFilename()));
+ \Drupal::logger('file')->notice('Copied file %source has been renamed to %destination', ['%source' => $source->filename, '%destination' => $file->getFilename()]);
}
}
@@ -73,7 +73,7 @@ function hook_file_move(Drupal\file\FileInterface $file, Drupal\file\FileInterfa
$file->setFilename($file->getOwner()->name . '_' . $file->getFilename());
$file->save();
- \Drupal::logger('file')->notice('Moved file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->getFilename()));
+ \Drupal::logger('file')->notice('Moved file %source has been renamed to %destination', ['%source' => $source->filename, '%destination' => $file->getFilename()]);
}
}
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index bbfc2b23ea4..80ffbe99794 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -26,26 +26,26 @@ function template_preprocess_file_widget_multiple(&$variables) {
$table_id = $element['#id'] . '-table';
// Build up a table of applicable fields.
- $headers = array();
+ $headers = [];
$headers[] = t('File information');
if ($element['#display_field']) {
- $headers[] = array(
+ $headers[] = [
'data' => t('Display'),
- 'class' => array('checkbox'),
- );
+ 'class' => ['checkbox'],
+ ];
}
$headers[] = t('Weight');
$headers[] = t('Operations');
// Get our list of widgets in order (needed when the form comes back after
// preview or failed validation).
- $widgets = array();
+ $widgets = [];
foreach (Element::children($element) as $key) {
$widgets[] = &$element[$key];
}
usort($widgets, '_field_multiple_value_form_sort_helper');
- $rows = array();
+ $rows = [];
foreach ($widgets as $key => &$widget) {
// Save the uploading row for last.
if (empty($widget['#files'])) {
@@ -56,7 +56,7 @@ function template_preprocess_file_widget_multiple(&$variables) {
// Delay rendering of the buttons, so that they can be rendered later in the
// "operations" column.
- $operations_elements = array();
+ $operations_elements = [];
foreach (Element::children($widget) as $sub_key) {
if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] == 'submit') {
hide($widget[$sub_key]);
@@ -72,21 +72,21 @@ function template_preprocess_file_widget_multiple(&$variables) {
hide($widget['_weight']);
// Render everything else together in a column, without the normal wrappers.
- $widget['#theme_wrappers'] = array();
+ $widget['#theme_wrappers'] = [];
$information = drupal_render($widget);
$display = '';
if ($element['#display_field']) {
unset($widget['display']['#title']);
- $display = array(
+ $display = [
'data' => render($widget['display']),
- 'class' => array('checkbox'),
- );
+ 'class' => ['checkbox'],
+ ];
}
- $widget['_weight']['#attributes']['class'] = array($weight_class);
+ $widget['_weight']['#attributes']['class'] = [$weight_class];
$weight = render($widget['_weight']);
// Arrange the row with all of the rendered columns.
- $row = array();
+ $row = [];
$row[] = $information;
if ($element['#display_field']) {
$row[] = $display;
@@ -98,31 +98,31 @@ function template_preprocess_file_widget_multiple(&$variables) {
foreach (Element::children($operations_elements) as $key) {
show($operations_elements[$key]);
}
- $row[] = array(
+ $row[] = [
'data' => $operations_elements,
- );
- $rows[] = array(
+ ];
+ $rows[] = [
'data' => $row,
- 'class' => isset($widget['#attributes']['class']) ? array_merge($widget['#attributes']['class'], array('draggable')) : array('draggable'),
- );
+ 'class' => isset($widget['#attributes']['class']) ? array_merge($widget['#attributes']['class'], ['draggable']) : ['draggable'],
+ ];
}
- $variables['table'] = array(
+ $variables['table'] = [
'#type' => 'table',
'#header' => $headers,
'#rows' => $rows,
- '#attributes' => array(
+ '#attributes' => [
'id' => $table_id,
- ),
- '#tabledrag' => array(
- array(
+ ],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => $weight_class,
- ),
- ),
+ ],
+ ],
'#access' => !empty($rows),
- );
+ ];
$variables['element'] = $element;
}
@@ -144,7 +144,7 @@ function template_preprocess_file_upload_help(&$variables) {
$upload_validators = $variables['upload_validators'];
$cardinality = $variables['cardinality'];
- $descriptions = array();
+ $descriptions = [];
if (!empty($description)) {
$descriptions[] = FieldFilteredMarkup::create($description);
@@ -158,26 +158,26 @@ function template_preprocess_file_upload_help(&$variables) {
}
}
if (isset($upload_validators['file_validate_size'])) {
- $descriptions[] = t('@size limit.', array('@size' => format_size($upload_validators['file_validate_size'][0])));
+ $descriptions[] = t('@size limit.', ['@size' => format_size($upload_validators['file_validate_size'][0])]);
}
if (isset($upload_validators['file_validate_extensions'])) {
- $descriptions[] = t('Allowed types: @extensions.', array('@extensions' => $upload_validators['file_validate_extensions'][0]));
+ $descriptions[] = t('Allowed types: @extensions.', ['@extensions' => $upload_validators['file_validate_extensions'][0]]);
}
if (isset($upload_validators['file_validate_image_resolution'])) {
$max = $upload_validators['file_validate_image_resolution'][0];
$min = $upload_validators['file_validate_image_resolution'][1];
if ($min && $max && $min == $max) {
- $descriptions[] = t('Images must be exactly <strong>@size</strong> pixels.', array('@size' => $max));
+ $descriptions[] = t('Images must be exactly <strong>@size</strong> pixels.', ['@size' => $max]);
}
elseif ($min && $max) {
- $descriptions[] = t('Images must be larger than <strong>@min</strong> pixels. Images larger than <strong>@max</strong> pixels will be resized.', array('@min' => $min, '@max' => $max));
+ $descriptions[] = t('Images must be larger than <strong>@min</strong> pixels. Images larger than <strong>@max</strong> pixels will be resized.', ['@min' => $min, '@max' => $max]);
}
elseif ($min) {
- $descriptions[] = t('Images must be larger than <strong>@min</strong> pixels.', array('@min' => $min));
+ $descriptions[] = t('Images must be larger than <strong>@min</strong> pixels.', ['@min' => $min]);
}
elseif ($max) {
- $descriptions[] = t('Images larger than <strong>@max</strong> pixels will be resized.', array('@max' => $max));
+ $descriptions[] = t('Images larger than <strong>@max</strong> pixels will be resized.', ['@max' => $max]);
}
}
diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index d371384664e..9134a25e9e2 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -9,51 +9,51 @@
* Implements hook_schema().
*/
function file_schema() {
- $schema['file_usage'] = array(
+ $schema['file_usage'] = [
'description' => 'Track where a file is used.',
- 'fields' => array(
- 'fid' => array(
+ 'fields' => [
+ 'fid' => [
'description' => 'File ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'module' => array(
+ ],
+ 'module' => [
'description' => 'The name of the module that is using the file.',
'type' => 'varchar_ascii',
'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
'not null' => TRUE,
'default' => '',
- ),
- 'type' => array(
+ ],
+ 'type' => [
'description' => 'The name of the object type in which the file is used.',
'type' => 'varchar_ascii',
'length' => 64,
'not null' => TRUE,
'default' => '',
- ),
- 'id' => array(
+ ],
+ 'id' => [
'description' => 'The primary key of the object using the file.',
'type' => 'varchar_ascii',
'length' => 64,
'not null' => TRUE,
'default' => 0,
- ),
- 'count' => array(
+ ],
+ 'count' => [
'description' => 'The number of times this file is used by this object.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('fid', 'type', 'id', 'module'),
- 'indexes' => array(
- 'type_id' => array('type', 'id'),
- 'fid_count' => array('fid', 'count'),
- 'fid_module' => array('fid', 'module'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['fid', 'type', 'id', 'module'],
+ 'indexes' => [
+ 'type_id' => ['type', 'id'],
+ 'fid_count' => ['fid', 'count'],
+ 'fid_module' => ['fid', 'module'],
+ ],
+ ];
return $schema;
}
@@ -63,7 +63,7 @@ function file_schema() {
* Display information about getting upload progress bars working.
*/
function file_requirements($phase) {
- $requirements = array();
+ $requirements = [];
// Check the server's ability to indicate upload progress.
if ($phase == 'runtime') {
@@ -107,11 +107,11 @@ function file_requirements($phase) {
elseif ($implementation == 'uploadprogress') {
$value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
}
- $requirements['file_progress'] = array(
+ $requirements['file_progress'] = [
'title' => t('Upload progress'),
'value' => $value,
'description' => $description,
- );
+ ];
}
return $requirements;
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 687a62c70b2..a6fc3f6ebe0 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -30,15 +30,15 @@ function file_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.file':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The File module allows you to create fields that contain files. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":file_documentation">online documentation for the File module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':file_documentation' => 'https://www.drupal.org/documentation/modules/file')) . '</p>';
+ $output .= '<p>' . t('The File module allows you to create fields that contain files. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":file_documentation">online documentation for the File module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':file_documentation' => 'https://www.drupal.org/documentation/modules/file']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying file fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the file field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the file field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Allowing file extensions') . '</dt>';
$output .= '<dd>' . t('In the field settings, you can define the allowed file extensions (for example <em>pdf docx psd</em>) for the files that will be uploaded with the file field.') . '</dd>';
$output .= '<dt>' . t('Storing files') . '</dt>';
- $output .= '<dd>' . t('Uploaded files can either be stored as <em>public</em> or <em>private</em>, depending on the <a href=":file-system">File system settings</a>. For more information, see the <a href=":system-help">System module help page</a>.', array(':file-system' => \Drupal::url('system.file_system_settings'), ':system-help' => \Drupal::url('help.page', array('name' => 'system')))) . '</dd>';
+ $output .= '<dd>' . t('Uploaded files can either be stored as <em>public</em> or <em>private</em>, depending on the <a href=":file-system">File system settings</a>. For more information, see the <a href=":system-help">System module help page</a>.', [':file-system' => \Drupal::url('system.file_system_settings'), ':system-help' => \Drupal::url('help.page', ['name' => 'system'])]) . '</dd>';
$output .= '<dt>' . t('Restricting the maximum file size') . '</dt>';
$output .= '<dd>' . t('The maximum file size that users can upload is limited by PHP settings of the server, but you can restrict by entering the desired value as the <em>Maximum upload size</em> setting. The maximum file size is automatically displayed to users in the help text of the file field.') . '</dd>';
$output .= '<dt>' . t('Displaying files and descriptions') . '<dt>';
@@ -96,7 +96,7 @@ function file_load_multiple(array $fids = NULL, $reset = FALSE) {
*/
function file_load($fid, $reset = FALSE) {
if ($reset) {
- \Drupal::entityManager()->getStorage('file')->resetCache(array($fid));
+ \Drupal::entityManager()->getStorage('file')->resetCache([$fid]);
}
return File::load($fid);
}
@@ -141,12 +141,12 @@ function file_load($fid, $reset = FALSE) {
function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
if (!file_valid_uri($destination)) {
if (($realpath = drupal_realpath($source->getFileUri())) !== FALSE) {
- \Drupal::logger('file')->notice('File %file (%realpath) could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%realpath' => $realpath, '%destination' => $destination));
+ \Drupal::logger('file')->notice('File %file (%realpath) could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', ['%file' => $source->getFileUri(), '%realpath' => $realpath, '%destination' => $destination]);
}
else {
- \Drupal::logger('file')->notice('File %file could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%destination' => $destination));
+ \Drupal::logger('file')->notice('File %file could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', ['%file' => $source->getFileUri(), '%destination' => $destination]);
}
- drupal_set_message(t('The specified file %file could not be copied because the destination is invalid. More information is available in the system log.', array('%file' => $source->getFileUri())), 'error');
+ drupal_set_message(t('The specified file %file could not be copied because the destination is invalid. More information is available in the system log.', ['%file' => $source->getFileUri()]), 'error');
return FALSE;
}
@@ -158,7 +158,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
// @todo Do not create a new entity in order to update it. See
// https://www.drupal.org/node/2241865.
if ($replace == FILE_EXISTS_REPLACE) {
- $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri));
+ $existing_files = entity_load_multiple_by_properties('file', ['uri' => $uri]);
if (count($existing_files)) {
$existing = reset($existing_files);
$file->fid = $existing->id();
@@ -175,7 +175,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
$file->save();
// Inform modules that the file has been copied.
- \Drupal::moduleHandler()->invokeAll('file_copy', array($file, $source));
+ \Drupal::moduleHandler()->invokeAll('file_copy', [$file, $source]);
return $file;
}
@@ -216,12 +216,12 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
function file_move(FileInterface $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
if (!file_valid_uri($destination)) {
if (($realpath = drupal_realpath($source->getFileUri())) !== FALSE) {
- \Drupal::logger('file')->notice('File %file (%realpath) could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%realpath' => $realpath, '%destination' => $destination));
+ \Drupal::logger('file')->notice('File %file (%realpath) could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', ['%file' => $source->getFileUri(), '%realpath' => $realpath, '%destination' => $destination]);
}
else {
- \Drupal::logger('file')->notice('File %file could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%destination' => $destination));
+ \Drupal::logger('file')->notice('File %file could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', ['%file' => $source->getFileUri(), '%destination' => $destination]);
}
- drupal_set_message(t('The specified file %file could not be moved because the destination is invalid. More information is available in the system log.', array('%file' => $source->getFileUri())), 'error');
+ drupal_set_message(t('The specified file %file could not be moved because the destination is invalid. More information is available in the system log.', ['%file' => $source->getFileUri()]), 'error');
return FALSE;
}
@@ -232,7 +232,7 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E
$file->setFileUri($uri);
// If we are replacing an existing file re-use its database record.
if ($replace == FILE_EXISTS_REPLACE) {
- $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri));
+ $existing_files = entity_load_multiple_by_properties('file', ['uri' => $uri]);
if (count($existing_files)) {
$existing = reset($existing_files);
$delete_source = TRUE;
@@ -249,7 +249,7 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E
$file->save();
// Inform modules that the file has been moved.
- \Drupal::moduleHandler()->invokeAll('file_move', array($file, $source));
+ \Drupal::moduleHandler()->invokeAll('file_move', [$file, $source]);
// Delete the original if it's not in use elsewhere.
if ($delete_source && !\Drupal::service('file.usage')->listUsage($source)) {
@@ -283,9 +283,9 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E
*
* @see hook_file_validate()
*/
-function file_validate(FileInterface $file, $validators = array()) {
+function file_validate(FileInterface $file, $validators = []) {
// Call the validation functions specified by this function's caller.
- $errors = array();
+ $errors = [];
foreach ($validators as $function => $args) {
if (function_exists($function)) {
array_unshift($args, $file);
@@ -294,7 +294,7 @@ function file_validate(FileInterface $file, $validators = array()) {
}
// Let other modules perform validation on the new file.
- return array_merge($errors, \Drupal::moduleHandler()->invokeAll('file_validate', array($file)));
+ return array_merge($errors, \Drupal::moduleHandler()->invokeAll('file_validate', [$file]));
}
/**
@@ -308,7 +308,7 @@ function file_validate(FileInterface $file, $validators = array()) {
* array containing an error message if it's not or is empty.
*/
function file_validate_name_length(FileInterface $file) {
- $errors = array();
+ $errors = [];
if (!$file->getFilename()) {
$errors[] = t("The file's name is empty. Please give a name to the file.");
@@ -334,11 +334,11 @@ function file_validate_name_length(FileInterface $file) {
* @see hook_file_validate()
*/
function file_validate_extensions(FileInterface $file, $extensions) {
- $errors = array();
+ $errors = [];
$regex = '/\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i';
if (!preg_match($regex, $file->getFilename())) {
- $errors[] = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $extensions));
+ $errors[] = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => $extensions]);
}
return $errors;
}
@@ -363,15 +363,15 @@ function file_validate_extensions(FileInterface $file, $extensions) {
*/
function file_validate_size(FileInterface $file, $file_limit = 0, $user_limit = 0) {
$user = \Drupal::currentUser();
- $errors = array();
+ $errors = [];
if ($file_limit && $file->getSize() > $file_limit) {
- $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->getSize()), '%maxsize' => format_size($file_limit)));
+ $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', ['%filesize' => format_size($file->getSize()), '%maxsize' => format_size($file_limit)]);
}
// Save a query by only calling spaceUsed() when a limit is provided.
if ($user_limit && (\Drupal::entityManager()->getStorage('file')->spaceUsed($user->id()) + $file->getSize()) > $user_limit) {
- $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->getSize()), '%quota' => format_size($user_limit)));
+ $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', ['%filesize' => format_size($file->getSize()), '%quota' => format_size($user_limit)]);
}
return $errors;
@@ -390,13 +390,13 @@ function file_validate_size(FileInterface $file, $file_limit = 0, $user_limit =
* @see hook_file_validate()
*/
function file_validate_is_image(FileInterface $file) {
- $errors = array();
+ $errors = [];
$image_factory = \Drupal::service('image.factory');
$image = $image_factory->get($file->getFileUri());
if (!$image->isValid()) {
$supported_extensions = $image_factory->getSupportedExtensions();
- $errors[] = t('Image type not supported. Allowed types: %types', array('%types' => implode(' ', $supported_extensions)));
+ $errors[] = t('Image type not supported. Allowed types: %types', ['%types' => implode(' ', $supported_extensions)]);
}
return $errors;
@@ -429,7 +429,7 @@ function file_validate_is_image(FileInterface $file) {
* @see hook_file_validate()
*/
function file_validate_image_resolution(FileInterface $file, $maximum_dimensions = 0, $minimum_dimensions = 0) {
- $errors = array();
+ $errors = [];
// Check first that the file is an image.
$image_factory = \Drupal::service('image.factory');
@@ -443,13 +443,13 @@ function file_validate_image_resolution(FileInterface $file, $maximum_dimensions
if ($image->scale($width, $height)) {
$image->save();
if (!empty($width) && !empty($height)) {
- $message = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions));
+ $message = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', ['%dimensions' => $maximum_dimensions]);
}
elseif (empty($width)) {
- $message = t('The image was resized to fit within the maximum allowed height of %height pixels.', array('%height' => $height));
+ $message = t('The image was resized to fit within the maximum allowed height of %height pixels.', ['%height' => $height]);
}
elseif (empty($height)) {
- $message = t('The image was resized to fit within the maximum allowed width of %width pixels.', array('%width' => $width));
+ $message = t('The image was resized to fit within the maximum allowed width of %width pixels.', ['%width' => $width]);
}
drupal_set_message($message);
}
@@ -463,7 +463,7 @@ function file_validate_image_resolution(FileInterface $file, $maximum_dimensions
// Check that it is larger than the given dimensions.
list($width, $height) = explode('x', $minimum_dimensions);
if ($image->getWidth() < $width || $image->getHeight() < $height) {
- $errors[] = t('The image is too small; the minimum dimensions are %dimensions pixels.', array('%dimensions' => $minimum_dimensions));
+ $errors[] = t('The image is too small; the minimum dimensions are %dimensions pixels.', ['%dimensions' => $minimum_dimensions]);
}
}
}
@@ -503,7 +503,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
$destination = file_default_scheme() . '://';
}
if (!file_valid_uri($destination)) {
- \Drupal::logger('file')->notice('The data could not be saved because the destination %destination is invalid. This may be caused by improper use of file_save_data() or a missing stream wrapper.', array('%destination' => $destination));
+ \Drupal::logger('file')->notice('The data could not be saved because the destination %destination is invalid. This may be caused by improper use of file_save_data() or a missing stream wrapper.', ['%destination' => $destination]);
drupal_set_message(t('The data could not be saved because the destination is invalid. More information is available in the system log.'), 'error');
return FALSE;
}
@@ -519,7 +519,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
// @todo Do not create a new entity in order to update it. See
// https://www.drupal.org/node/2241865.
if ($replace == FILE_EXISTS_REPLACE) {
- $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri));
+ $existing_files = entity_load_multiple_by_properties('file', ['uri' => $uri]);
if (count($existing_files)) {
$existing = reset($existing_files);
$file->fid = $existing->id();
@@ -552,36 +552,36 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
function file_get_content_headers(FileInterface $file) {
$type = Unicode::mimeHeaderEncode($file->getMimeType());
- return array(
+ return [
'Content-Type' => $type,
'Content-Length' => $file->getSize(),
'Cache-Control' => 'private',
- );
+ ];
}
/**
* Implements hook_theme().
*/
function file_theme() {
- return array(
+ return [
// From file.module.
- 'file_link' => array(
- 'variables' => array('file' => NULL, 'description' => NULL, 'attributes' => array()),
- ),
- 'file_managed_file' => array(
+ 'file_link' => [
+ 'variables' => ['file' => NULL, 'description' => NULL, 'attributes' => []],
+ ],
+ 'file_managed_file' => [
'render element' => 'element',
- ),
+ ],
// From file.field.inc.
- 'file_widget_multiple' => array(
+ 'file_widget_multiple' => [
'render element' => 'element',
'file' => 'file.field.inc',
- ),
- 'file_upload_help' => array(
- 'variables' => array('description' => NULL, 'upload_validators' => NULL, 'cardinality' => NULL),
+ ],
+ 'file_upload_help' => [
+ 'variables' => ['description' => NULL, 'upload_validators' => NULL, 'cardinality' => NULL],
'file' => 'file.field.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -590,7 +590,7 @@ function file_theme() {
function file_file_download($uri) {
// Get the file record based on the URI. If not in the database just return.
/** @var \Drupal\file\FileInterface[] $files */
- $files = entity_load_multiple_by_properties('file', array('uri' => $uri));
+ $files = entity_load_multiple_by_properties('file', ['uri' => $uri]);
if (count($files)) {
foreach ($files as $item) {
// Since some database servers sometimes use a case-insensitive comparison
@@ -663,11 +663,11 @@ function file_cron() {
$file->delete();
}
else {
- \Drupal::logger('file system')->error('Could not delete temporary file "%path" during garbage collection', array('%path' => $file->getFileUri()));
+ \Drupal::logger('file system')->error('Could not delete temporary file "%path" during garbage collection', ['%path' => $file->getFileUri()]);
}
}
else {
- \Drupal::logger('file system')->info('Did not delete temporary file "%path" during garbage collection because it is in use by the following modules: %modules.', array('%path' => $file->getFileUri(), '%modules' => implode(', ', array_keys($references))));
+ \Drupal::logger('file system')->info('Did not delete temporary file "%path" during garbage collection because it is in use by the following modules: %modules.', ['%path' => $file->getFileUri(), '%modules' => implode(', ', array_keys($references))]);
}
}
}
@@ -711,11 +711,11 @@ function file_cron() {
* array element contains the file entity if the upload succeeded or FALSE if
* there was an error. Function returns NULL if no file was uploaded.
*/
-function file_save_upload($form_field_name, $validators = array(), $destination = FALSE, $delta = NULL, $replace = FILE_EXISTS_RENAME) {
+function file_save_upload($form_field_name, $validators = [], $destination = FALSE, $delta = NULL, $replace = FILE_EXISTS_RENAME) {
$user = \Drupal::currentUser();
static $upload_cache;
- $all_files = \Drupal::request()->files->get('files', array());
+ $all_files = \Drupal::request()->files->get('files', []);
// Make sure there's an upload to process.
if (empty($all_files[$form_field_name])) {
return NULL;
@@ -735,10 +735,10 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// for multiple uploads and we fix that here.
$uploaded_files = $file_upload;
if (!is_array($file_upload)) {
- $uploaded_files = array($file_upload);
+ $uploaded_files = [$file_upload];
}
- $files = array();
+ $files = [];
foreach ($uploaded_files as $i => $file_info) {
// Check for file upload errors and return FALSE for this file if a lower
// level system error occurred. For a complete list of errors:
@@ -746,13 +746,13 @@ function file_save_upload($form_field_name, $validators = array(), $destination
switch ($file_info->getError()) {
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
- drupal_set_message(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $file_info->getFilename(), '%maxsize' => format_size(file_upload_max_size()))), 'error');
+ drupal_set_message(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', ['%file' => $file_info->getFilename(), '%maxsize' => format_size(file_upload_max_size())]), 'error');
$files[$i] = FALSE;
continue;
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
- drupal_set_message(t('The file %file could not be saved because the upload did not complete.', array('%file' => $file_info->getFilename())), 'error');
+ drupal_set_message(t('The file %file could not be saved because the upload did not complete.', ['%file' => $file_info->getFilename()]), 'error');
$files[$i] = FALSE;
continue;
@@ -765,19 +765,19 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// Unknown error
default:
- drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $file_info->getFilename())), 'error');
+ drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', ['%file' => $file_info->getFilename()]), 'error');
$files[$i] = FALSE;
continue;
}
// Begin building file entity.
- $values = array(
+ $values = [
'uid' => $user->id(),
'status' => 0,
'filename' => $file_info->getClientOriginalName(),
'uri' => $file_info->getRealPath(),
'filesize' => $file_info->getSize(),
- );
+ ];
$values['filemime'] = \Drupal::service('file.mime_type.guesser')->guess($values['filename']);
$file = File::create($values);
@@ -798,7 +798,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// No validator was provided, so add one using the default list.
// Build a default non-munged safe list for file_munge_filename().
$extensions = 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
- $validators['file_validate_extensions'] = array();
+ $validators['file_validate_extensions'] = [];
$validators['file_validate_extensions'][0] = $extensions;
}
@@ -820,7 +820,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// to add it here or else the file upload will fail.
if (!empty($extensions)) {
$validators['file_validate_extensions'][0] .= ' txt';
- drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $file->getFilename())));
+ drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', ['%filename' => $file->getFilename()]));
}
}
@@ -832,7 +832,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// Assert that the destination contains a valid stream.
$destination_scheme = file_uri_scheme($destination);
if (!file_stream_wrapper_valid_scheme($destination_scheme)) {
- drupal_set_message(t('The file could not be uploaded because the destination %destination is invalid.', array('%destination' => $destination)), 'error');
+ drupal_set_message(t('The file could not be uploaded because the destination %destination is invalid.', ['%destination' => $destination]), 'error');
$files[$i] = FALSE;
continue;
}
@@ -846,28 +846,28 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// If file_destination() returns FALSE then $replace === FILE_EXISTS_ERROR and
// there's an existing file so we need to bail.
if ($file->destination === FALSE) {
- drupal_set_message(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', array('%source' => $form_field_name, '%directory' => $destination)), 'error');
+ drupal_set_message(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', ['%source' => $form_field_name, '%directory' => $destination]), 'error');
$files[$i] = FALSE;
continue;
}
// Add in our check of the file name length.
- $validators['file_validate_name_length'] = array();
+ $validators['file_validate_name_length'] = [];
// Call the validation functions specified by this function's caller.
$errors = file_validate($file, $validators);
// Check for errors.
if (!empty($errors)) {
- $message = array(
- 'error' => array(
- '#markup' => t('The specified file %name could not be uploaded.', array('%name' => $file->getFilename())),
- ),
- 'item_list' => array(
+ $message = [
+ 'error' => [
+ '#markup' => t('The specified file %name could not be uploaded.', ['%name' => $file->getFilename()]),
+ ],
+ 'item_list' => [
'#theme' => 'item_list',
'#items' => $errors,
- ),
- );
+ ],
+ ];
// @todo Add support for render arrays in drupal_set_message()? See
// https://www.drupal.org/node/2505497.
drupal_set_message(\Drupal::service('renderer')->renderPlain($message), 'error');
@@ -881,7 +881,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
$file->setFileUri($file->destination);
if (!drupal_move_uploaded_file($file_info->getRealPath(), $file->getFileUri())) {
drupal_set_message(t('File upload error. Could not move uploaded file.'), 'error');
- \Drupal::logger('file')->notice('Upload error. Could not move uploaded file %file to destination %destination.', array('%file' => $file->getFilename(), '%destination' => $file->getFileUri()));
+ \Drupal::logger('file')->notice('Upload error. Could not move uploaded file %file to destination %destination.', ['%file' => $file->getFilename(), '%destination' => $file->getFileUri()]);
$files[$i] = FALSE;
continue;
}
@@ -893,7 +893,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// @todo Do not create a new entity in order to update it. See
// https://www.drupal.org/node/2241865.
if ($replace == FILE_EXISTS_REPLACE) {
- $existing_files = entity_load_multiple_by_properties('file', array('uri' => $file->getFileUri()));
+ $existing_files = entity_load_multiple_by_properties('file', ['uri' => $file->getFileUri()]);
if (count($existing_files)) {
$existing = reset($existing_files);
$file->fid = $existing->id();
@@ -949,7 +949,7 @@ function file_file_predelete(File $file) {
function file_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@@ -958,7 +958,7 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta
$langcode = NULL;
}
- $replacements = array();
+ $replacements = [];
if ($type == 'file' && !empty($data['file'])) {
/** @var \Drupal\file\FileInterface $file */
@@ -1020,15 +1020,15 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta
}
if ($date_tokens = $token_service->findWithPrefix($tokens, 'created')) {
- $replacements += $token_service->generate('date', $date_tokens, array('date' => $file->getCreatedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $date_tokens, ['date' => $file->getCreatedTime()], $options, $bubbleable_metadata);
}
if ($date_tokens = $token_service->findWithPrefix($tokens, 'changed')) {
- $replacements += $token_service->generate('date', $date_tokens, array('date' => $file->getChangedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $date_tokens, ['date' => $file->getChangedTime()], $options, $bubbleable_metadata);
}
if (($owner_tokens = $token_service->findWithPrefix($tokens, 'owner')) && $file->getOwner()) {
- $replacements += $token_service->generate('user', $owner_tokens, array('user' => $file->getOwner()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('user', $owner_tokens, ['user' => $file->getOwner()], $options, $bubbleable_metadata);
}
}
@@ -1039,59 +1039,59 @@ function file_tokens($type, $tokens, array $data, array $options, BubbleableMeta
* Implements hook_token_info().
*/
function file_token_info() {
- $types['file'] = array(
+ $types['file'] = [
'name' => t("Files"),
'description' => t("Tokens related to uploaded files."),
'needs-data' => 'file',
- );
+ ];
// File related tokens.
- $file['fid'] = array(
+ $file['fid'] = [
'name' => t("File ID"),
'description' => t("The unique ID of the uploaded file."),
- );
- $file['name'] = array(
+ ];
+ $file['name'] = [
'name' => t("File name"),
'description' => t("The name of the file on disk."),
- );
- $file['path'] = array(
+ ];
+ $file['path'] = [
'name' => t("Path"),
'description' => t("The location of the file relative to Drupal root."),
- );
- $file['mime'] = array(
+ ];
+ $file['mime'] = [
'name' => t("MIME type"),
'description' => t("The MIME type of the file."),
- );
- $file['size'] = array(
+ ];
+ $file['size'] = [
'name' => t("File size"),
'description' => t("The size of the file."),
- );
- $file['url'] = array(
+ ];
+ $file['url'] = [
'name' => t("URL"),
'description' => t("The web-accessible URL for the file."),
- );
- $file['created'] = array(
+ ];
+ $file['created'] = [
'name' => t("Created"),
'description' => t("The date the file created."),
'type' => 'date',
- );
- $file['changed'] = array(
+ ];
+ $file['changed'] = [
'name' => t("Changed"),
'description' => t("The date the file was most recently changed."),
'type' => 'date',
- );
- $file['owner'] = array(
+ ];
+ $file['owner'] = [
'name' => t("Owner"),
'description' => t("The user who originally uploaded the file."),
'type' => 'user',
- );
+ ];
- return array(
+ return [
'types' => $types,
- 'tokens' => array(
+ 'tokens' => [
'file' => $file,
- ),
- );
+ ],
+ ];
}
/**
@@ -1115,7 +1115,7 @@ function file_managed_file_submit($form, FormStateInterface $form_state) {
$fids = array_keys($element['#files']);
// Get files that will be removed.
if ($element['#multiple']) {
- $remove_fids = array();
+ $remove_fids = [];
foreach (Element::children($element) as $name) {
if (strpos($name, 'file_') === 0 && $element[$name]['selected']['#value']) {
$remove_fids[] = (int) substr($name, 5);
@@ -1128,7 +1128,7 @@ function file_managed_file_submit($form, FormStateInterface $form_state) {
// element's value to empty array (file could not be removed from
// element if we don't do that).
$remove_fids = $fids;
- $fids = array();
+ $fids = [];
}
foreach ($remove_fids as $fid) {
@@ -1175,7 +1175,7 @@ function file_managed_file_submit($form, FormStateInterface $form_state) {
*/
function file_managed_file_save_upload($element, FormStateInterface $form_state) {
$upload_name = implode('_', $element['#parents']);
- $all_files = \Drupal::request()->files->get('files', array());
+ $all_files = \Drupal::request()->files->get('files', []);
if (empty($all_files[$upload_name])) {
return FALSE;
}
@@ -1183,7 +1183,7 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state)
$destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL;
if (isset($destination) && !file_prepare_directory($destination, FILE_CREATE_DIRECTORY)) {
- \Drupal::logger('file')->notice('The upload directory %directory for the file field %name could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', array('%directory' => $destination, '%name' => $element['#field_name']));
+ \Drupal::logger('file')->notice('The upload directory %directory for the file field %name could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', ['%directory' => $destination, '%name' => $element['#field_name']]);
$form_state->setError($element, t('The file could not be uploaded.'));
return FALSE;
}
@@ -1193,19 +1193,19 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state)
$files_uploaded |= !$element['#multiple'] && !empty($file_upload);
if ($files_uploaded) {
if (!$files = file_save_upload($upload_name, $element['#upload_validators'], $destination)) {
- \Drupal::logger('file')->notice('The file upload failed. %upload', array('%upload' => $upload_name));
- $form_state->setError($element, t('Files in the @name field were unable to be uploaded.', array('@name' => $element['#title'])));
- return array();
+ \Drupal::logger('file')->notice('The file upload failed. %upload', ['%upload' => $upload_name]);
+ $form_state->setError($element, t('Files in the @name field were unable to be uploaded.', ['@name' => $element['#title']]));
+ return [];
}
// Value callback expects FIDs to be keys.
$files = array_filter($files);
$fids = array_map(function($file) { return $file->id(); }, $files);
- return empty($files) ? array() : array_combine($fids, $files);
+ return empty($files) ? [] : array_combine($fids, $files);
}
- return array();
+ return [];
}
/**
@@ -1220,7 +1220,7 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state)
function template_preprocess_file_managed_file(&$variables) {
$element = $variables['element'];
- $variables['attributes'] = array();
+ $variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@@ -1244,7 +1244,7 @@ function template_preprocess_file_managed_file(&$variables) {
*/
function template_preprocess_file_link(&$variables) {
$file = $variables['file'];
- $options = array();
+ $options = [];
$file_entity = ($file instanceof File) ? $file : File::load($file->fid);
// @todo Wrap in file_url_transform_relative(). This is currently
@@ -1270,13 +1270,13 @@ function template_preprocess_file_link(&$variables) {
}
// Classes to add to the file field for icons.
- $classes = array(
+ $classes = [
'file',
// Add a specific class for each and every mime type.
- 'file--mime-' . strtr($mime_type, array('/' => '-', '.' => '-')),
+ 'file--mime-' . strtr($mime_type, ['/' => '-', '.' => '-']),
// Add a more general class for groups of well known MIME types.
'file--' . file_icon_class($mime_type),
- );
+ ];
// Set file classes to the options array.
$variables['attributes'] = new Attribute($variables['attributes']);
@@ -1302,7 +1302,7 @@ function file_icon_class($mime_type) {
}
// Use generic icons for each category that provides such icons.
- foreach (array('audio', 'image', 'text', 'video') as $category) {
+ foreach (['audio', 'image', 'text', 'video'] as $category) {
if (strpos($mime_type, $category) === 0) {
return $category;
}
@@ -1473,14 +1473,14 @@ function file_icon_map($mime_type) {
* @ingroup file
*/
function file_get_file_references(FileInterface $file, FieldDefinitionInterface $field = NULL, $age = EntityStorageInterface::FIELD_LOAD_REVISION, $field_type = 'file') {
- $references = &drupal_static(__FUNCTION__, array());
- $field_columns = &drupal_static(__FUNCTION__ . ':field_columns', array());
+ $references = &drupal_static(__FUNCTION__, []);
+ $field_columns = &drupal_static(__FUNCTION__ . ':field_columns', []);
// Fill the static cache, disregard $field and $field_type for now.
if (!isset($references[$file->id()][$age])) {
- $references[$file->id()][$age] = array();
+ $references[$file->id()][$age] = [];
$usage_list = \Drupal::service('file.usage')->listUsage($file);
- $file_usage_list = isset($usage_list['file']) ? $usage_list['file'] : array();
+ $file_usage_list = isset($usage_list['file']) ? $usage_list['file'] : [];
foreach ($file_usage_list as $entity_type_id => $entity_ids) {
$entities = \Drupal::entityTypeManager()
->getStorage($entity_type_id)->loadMultiple(array_keys($entity_ids));
@@ -1488,7 +1488,7 @@ function file_get_file_references(FileInterface $file, FieldDefinitionInterface
$bundle = $entity->bundle();
// We need to find file fields for this entity type and bundle.
if (!isset($file_fields[$entity_type_id][$bundle])) {
- $file_fields[$entity_type_id][$bundle] = array();
+ $file_fields[$entity_type_id][$bundle] = [];
// This contains the possible field names.
foreach ($entity->getFieldDefinitions() as $field_name => $field_definition) {
// If this is the first time this field type is seen, check
@@ -1549,10 +1549,10 @@ function file_get_file_references(FileInterface $file, FieldDefinitionInterface
* An array of file statuses or a specified status if $choice is set.
*/
function _views_file_status($choice = NULL) {
- $status = array(
+ $status = [
0 => t('Temporary'),
FILE_STATUS_PERMANENT => t('Permanent'),
- );
+ ];
if (isset($choice)) {
return isset($status[$choice]) ? $status[$choice] : t('Unknown');
diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc
index 7fb54b61362..8e45101bd84 100644
--- a/core/modules/file/file.views.inc
+++ b/core/modules/file/file.views.inc
@@ -19,13 +19,13 @@ function file_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the fid field.
- $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array(
+ $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = [
'id' => 'standard',
'base' => 'file_managed',
'entity type' => 'file',
'base field' => 'fid',
- 'label' => t('file from @field_name', array('@field_name' => $field_storage->getName())),
- );
+ 'label' => t('file from @field_name', ['@field_name' => $field_storage->getName()]),
+ ];
}
return $data;
@@ -47,11 +47,11 @@ function file_field_views_data_views_data_alter(array &$data, FieldStorageConfig
list($label) = views_entity_field_label($entity_type_id, $field_name);
- $data['file_managed'][$pseudo_field_name]['relationship'] = array(
- 'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
- 'label' => t('@field_name', array('@field_name' => $field_name)),
+ $data['file_managed'][$pseudo_field_name]['relationship'] = [
+ 'title' => t('@entity using @field', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
+ 'label' => t('@field_name', ['@field_name' => $field_name]),
'group' => $entity_type->getLabel(),
- 'help' => t('Relate each @entity with a @field set to the file.', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
+ 'help' => t('Relate each @entity with a @field set to the file.', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
'id' => 'entity_reverse',
'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(),
'entity_type' => $entity_type_id,
@@ -59,12 +59,12 @@ function file_field_views_data_views_data_alter(array &$data, FieldStorageConfig
'field_name' => $field_name,
'field table' => $table_mapping->getDedicatedDataTableName($field_storage),
'field field' => $field_name . '_target_id',
- 'join_extra' => array(
- 0 => array(
+ 'join_extra' => [
+ 0 => [
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
diff --git a/core/modules/file/src/Controller/FileWidgetAjaxController.php b/core/modules/file/src/Controller/FileWidgetAjaxController.php
index d5c6874528e..c9587504430 100644
--- a/core/modules/file/src/Controller/FileWidgetAjaxController.php
+++ b/core/modules/file/src/Controller/FileWidgetAjaxController.php
@@ -19,23 +19,23 @@ class FileWidgetAjaxController {
* A JsonResponse object.
*/
public function progress($key) {
- $progress = array(
+ $progress = [
'message' => t('Starting upload...'),
'percentage' => -1,
- );
+ ];
$implementation = file_progress_implementation();
if ($implementation == 'uploadprogress') {
$status = uploadprogress_get_info($key);
if (isset($status['bytes_uploaded']) && !empty($status['bytes_total'])) {
- $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['bytes_uploaded']), '@total' => format_size($status['bytes_total'])));
+ $progress['message'] = t('Uploading... (@current of @total)', ['@current' => format_size($status['bytes_uploaded']), '@total' => format_size($status['bytes_total'])]);
$progress['percentage'] = round(100 * $status['bytes_uploaded'] / $status['bytes_total']);
}
}
elseif ($implementation == 'apc') {
$status = apcu_fetch('upload_' . $key);
if (isset($status['current']) && !empty($status['total'])) {
- $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['current']), '@total' => format_size($status['total'])));
+ $progress['message'] = t('Uploading... (@current of @total)', ['@current' => format_size($status['current']), '@total' => format_size($status['total'])]);
$progress['percentage'] = round(100 * $status['current'] / $status['total']);
}
}
diff --git a/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php
index f465b181ac3..45c8aa7cec5 100644
--- a/core/modules/file/src/Element/ManagedFile.php
+++ b/core/modules/file/src/Element/ManagedFile.php
@@ -108,7 +108,7 @@ class ManagedFile extends FormElement {
// submissions of the same form, so to allow that, check for the
// token added by $this->processManagedFile().
elseif (\Drupal::currentUser()->isAnonymous()) {
- $token = NestedArray::getValue($form_state->getUserInput(), array_merge($element['#parents'], array('file_' . $file->id(), 'fid_token')));
+ $token = NestedArray::getValue($form_state->getUserInput(), array_merge($element['#parents'], ['file_' . $file->id(), 'fid_token']));
if ($token !== Crypt::hmacBase64('file-' . $file->id(), \Drupal::service('private_key')->get() . Settings::getHashSalt())) {
$force_default = TRUE;
break;
@@ -334,10 +334,10 @@ class ManagedFile extends FormElement {
// of the same form (for example, after an Ajax upload or form
// validation error).
if ($file->isTemporary() && \Drupal::currentUser()->isAnonymous()) {
- $element['file_' . $delta]['fid_token'] = array(
+ $element['file_' . $delta]['fid_token'] = [
'#type' => 'hidden',
'#value' => Crypt::hmacBase64('file-' . $delta, \Drupal::service('private_key')->get() . Settings::getHashSalt()),
- );
+ ];
}
}
}
diff --git a/core/modules/file/src/Entity/File.php b/core/modules/file/src/Entity/File.php
index cd7a65897f7..a68b9bae9bc 100644
--- a/core/modules/file/src/Entity/File.php
+++ b/core/modules/file/src/Entity/File.php
@@ -70,7 +70,7 @@ class File extends ContentEntityBase implements FileInterface {
*
* @see file_url_transform_relative()
*/
- public function url($rel = 'canonical', $options = array()) {
+ public function url($rel = 'canonical', $options = []) {
return file_create_url($this->getFileUri());
}
diff --git a/core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php b/core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php
index 12647b112f3..cfb0c447a68 100644
--- a/core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php
+++ b/core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php
@@ -44,14 +44,14 @@ class DatabaseFileUsageBackend extends FileUsageBase {
*/
public function add(FileInterface $file, $module, $type, $id, $count = 1) {
$this->connection->merge($this->tableName)
- ->keys(array(
+ ->keys([
'fid' => $file->id(),
'module' => $module,
'type' => $type,
'id' => $id,
- ))
- ->fields(array('count' => $count))
- ->expression('count', 'count + :count', array(':count' => $count))
+ ])
+ ->fields(['count' => $count])
+ ->expression('count', 'count + :count', [':count' => $count])
->execute();
parent::add($file, $module, $type, $id, $count);
@@ -85,7 +85,7 @@ class DatabaseFileUsageBackend extends FileUsageBase {
->condition('type', $type)
->condition('id', $id);
}
- $query->expression('count', 'count - :count', array(':count' => $count));
+ $query->expression('count', 'count - :count', [':count' => $count]);
$query->execute();
}
@@ -97,11 +97,11 @@ class DatabaseFileUsageBackend extends FileUsageBase {
*/
public function listUsage(FileInterface $file) {
$result = $this->connection->select($this->tableName, 'f')
- ->fields('f', array('module', 'type', 'id', 'count'))
+ ->fields('f', ['module', 'type', 'id', 'count'])
->condition('fid', $file->id())
->condition('count', 0, '>')
->execute();
- $references = array();
+ $references = [];
foreach ($result as $usage) {
$references[$usage->module][$usage->type][$usage->id] = $usage->count;
}
diff --git a/core/modules/file/src/FileViewsData.php b/core/modules/file/src/FileViewsData.php
index cf240622541..459a37eba30 100644
--- a/core/modules/file/src/FileViewsData.php
+++ b/core/modules/file/src/FileViewsData.php
@@ -20,13 +20,13 @@ class FileViewsData extends EntityViewsData {
$data['file_managed']['table']['base']['defaults']['field'] = 'filename';
$data['file_managed']['table']['wizard_id'] = 'file_managed';
- $data['file_managed']['fid']['argument'] = array(
+ $data['file_managed']['fid']['argument'] = [
'id' => 'file_fid',
// The field to display in the summary.
'name field' => 'filename',
'numeric' => TRUE,
- );
- $data['file_managed']['fid']['relationship'] = array(
+ ];
+ $data['file_managed']['fid']['relationship'] = [
'title' => $this->t('File usage'),
'help' => $this->t('Relate file entities to their usage.'),
'id' => 'standard',
@@ -34,24 +34,24 @@ class FileViewsData extends EntityViewsData {
'base field' => 'fid',
'field' => 'fid',
'label' => $this->t('File usage'),
- );
+ ];
$data['file_managed']['uri']['field']['default_formatter'] = 'file_uri';
$data['file_managed']['filemime']['field']['default_formatter'] = 'file_filemime';
- $data['file_managed']['extension'] = array(
+ $data['file_managed']['extension'] = [
'title' => $this->t('Extension'),
'help' => $this->t('The extension of the file.'),
'real field' => 'filename',
- 'field' => array(
+ 'field' => [
'entity_type' => 'file',
'field_name' => 'filename',
'default_formatter' => 'file_extension',
'id' => 'field',
'click sortable' => FALSE,
- ),
- );
+ ],
+ ];
$data['file_managed']['filesize']['field']['default_formatter'] = 'file_size';
@@ -71,40 +71,40 @@ class FileViewsData extends EntityViewsData {
// ("file_managed") so that we can create relationships from files to
// entities, and then on each core entity type base table so that we can
// provide general relationships between entities and files.
- $data['file_usage']['table']['join'] = array(
- 'file_managed' => array(
+ $data['file_usage']['table']['join'] = [
+ 'file_managed' => [
'field' => 'fid',
'left_field' => 'fid',
- ),
+ ],
// Link ourselves to the {node_field_data} table
// so we can provide node->file relationships.
- 'node_field_data' => array(
+ 'node_field_data' => [
'field' => 'id',
'left_field' => 'nid',
- 'extra' => array(array('field' => 'type', 'value' => 'node')),
- ),
+ 'extra' => [['field' => 'type', 'value' => 'node']],
+ ],
// Link ourselves to the {users_field_data} table
// so we can provide user->file relationships.
- 'users_field_data' => array(
+ 'users_field_data' => [
'field' => 'id',
'left_field' => 'uid',
- 'extra' => array(array('field' => 'type', 'value' => 'user')),
- ),
+ 'extra' => [['field' => 'type', 'value' => 'user']],
+ ],
// Link ourselves to the {comment_field_data} table
// so we can provide comment->file relationships.
- 'comment' => array(
+ 'comment' => [
'field' => 'id',
'left_field' => 'cid',
- 'extra' => array(array('field' => 'type', 'value' => 'comment')),
- ),
+ 'extra' => [['field' => 'type', 'value' => 'comment']],
+ ],
// Link ourselves to the {taxonomy_term_field_data} table
// so we can provide taxonomy_term->file relationships.
- 'taxonomy_term_data' => array(
+ 'taxonomy_term_data' => [
'field' => 'id',
'left_field' => 'tid',
- 'extra' => array(array('field' => 'type', 'value' => 'taxonomy_term')),
- ),
- );
+ 'extra' => [['field' => 'type', 'value' => 'taxonomy_term']],
+ ],
+ ];
// Provide a relationship between the files table and each entity type,
// and between each entity type and the files table. Entity->file
@@ -113,210 +113,210 @@ class FileViewsData extends EntityViewsData {
// declarations below.
// Describes relationships between files and nodes.
- $data['file_usage']['file_to_node'] = array(
+ $data['file_usage']['file_to_node'] = [
'title' => $this->t('Content'),
'help' => $this->t('Content that is associated with this file, usually because this file is in a field on the content.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
- 'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
+ 'skip base' => ['node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'],
'real field' => 'id',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('Content'),
'label' => $this->t('Content'),
'base' => 'node_field_data',
'base field' => 'nid',
'relationship field' => 'id',
- 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'node')),
- ),
- );
- $data['file_usage']['node_to_file'] = array(
+ 'extra' => [['table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'node']],
+ ],
+ ];
+ $data['file_usage']['node_to_file'] = [
'title' => $this->t('File'),
'help' => $this->t('A file that is associated with this node, usually because it is in a field on the node.'),
// Only provide this field/relationship/etc.,
// when the 'node' base table is present.
- 'skip base' => array('file_managed', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
+ 'skip base' => ['file_managed', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'],
'real field' => 'fid',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('File'),
'label' => $this->t('File'),
'base' => 'file_managed',
'base field' => 'fid',
'relationship field' => 'fid',
- ),
- );
+ ],
+ ];
// Describes relationships between files and users.
- $data['file_usage']['file_to_user'] = array(
+ $data['file_usage']['file_to_user'] = [
'title' => $this->t('User'),
'help' => $this->t('A user that is associated with this file, usually because this file is in a field on the user.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
- 'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
+ 'skip base' => ['node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'],
'real field' => 'id',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('User'),
'label' => $this->t('User'),
'base' => 'users',
'base field' => 'uid',
'relationship field' => 'id',
- 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'user')),
- ),
- );
- $data['file_usage']['user_to_file'] = array(
+ 'extra' => [['table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'user']],
+ ],
+ ];
+ $data['file_usage']['user_to_file'] = [
'title' => $this->t('File'),
'help' => $this->t('A file that is associated with this user, usually because it is in a field on the user.'),
// Only provide this field/relationship/etc.,
// when the 'users' base table is present.
- 'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'comment_field_data', 'taxonomy_term_field_data'),
+ 'skip base' => ['file_managed', 'node_field_data', 'node_field_revision', 'comment_field_data', 'taxonomy_term_field_data'],
'real field' => 'fid',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('File'),
'label' => $this->t('File'),
'base' => 'file_managed',
'base field' => 'fid',
'relationship field' => 'fid',
- ),
- );
+ ],
+ ];
// Describes relationships between files and comments.
- $data['file_usage']['file_to_comment'] = array(
+ $data['file_usage']['file_to_comment'] = [
'title' => $this->t('Comment'),
'help' => $this->t('A comment that is associated with this file, usually because this file is in a field on the comment.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
- 'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
+ 'skip base' => ['node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'],
'real field' => 'id',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('Comment'),
'label' => $this->t('Comment'),
'base' => 'comment_field_data',
'base field' => 'cid',
'relationship field' => 'id',
- 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'comment')),
- ),
- );
- $data['file_usage']['comment_to_file'] = array(
+ 'extra' => [['table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'comment']],
+ ],
+ ];
+ $data['file_usage']['comment_to_file'] = [
'title' => $this->t('File'),
'help' => $this->t('A file that is associated with this comment, usually because it is in a field on the comment.'),
// Only provide this field/relationship/etc.,
// when the 'comment' base table is present.
- 'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'taxonomy_term_field_data'),
+ 'skip base' => ['file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'taxonomy_term_field_data'],
'real field' => 'fid',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('File'),
'label' => $this->t('File'),
'base' => 'file_managed',
'base field' => 'fid',
'relationship field' => 'fid',
- ),
- );
+ ],
+ ];
// Describes relationships between files and taxonomy_terms.
- $data['file_usage']['file_to_taxonomy_term'] = array(
+ $data['file_usage']['file_to_taxonomy_term'] = [
'title' => $this->t('Taxonomy Term'),
'help' => $this->t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
- 'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
+ 'skip base' => ['node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'],
'real field' => 'id',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('Taxonomy Term'),
'label' => $this->t('Taxonomy Term'),
'base' => 'taxonomy_term_data',
'base field' => 'tid',
'relationship field' => 'id',
- 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_term')),
- ),
- );
- $data['file_usage']['taxonomy_term_to_file'] = array(
+ 'extra' => [['table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_term']],
+ ],
+ ];
+ $data['file_usage']['taxonomy_term_to_file'] = [
'title' => $this->t('File'),
'help' => $this->t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'),
// Only provide this field/relationship/etc.,
// when the 'taxonomy_term_data' base table is present.
- 'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data'),
+ 'skip base' => ['file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data'],
'real field' => 'fid',
- 'relationship' => array(
+ 'relationship' => [
'title' => $this->t('File'),
'label' => $this->t('File'),
'base' => 'file_managed',
'base field' => 'fid',
'relationship field' => 'fid',
- ),
- );
+ ],
+ ];
// Provide basic fields from the {file_usage} table to all of the base tables
// we've declared joins to, because there is no 'skip base' property on these
// fields.
- $data['file_usage']['module'] = array(
+ $data['file_usage']['module'] = [
'title' => $this->t('Module'),
'help' => $this->t('The module managing this file relationship.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['file_usage']['type'] = array(
+ ],
+ ];
+ $data['file_usage']['type'] = [
'title' => $this->t('Entity type'),
'help' => $this->t('The type of entity that is related to the file.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['file_usage']['id'] = array(
+ ],
+ ];
+ $data['file_usage']['id'] = [
'title' => $this->t('Entity ID'),
'help' => $this->t('The ID of the entity that is related to the file.'),
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['file_usage']['count'] = array(
+ ],
+ ];
+ $data['file_usage']['count'] = [
'title' => $this->t('Use count'),
'help' => $this->t('The number of times the file is used by this entity.'),
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['file_usage']['entity_label'] = array(
+ ],
+ ];
+ $data['file_usage']['entity_label'] = [
'title' => $this->t('Entity label'),
'help' => $this->t('The label of the entity that is related to the file.'),
'real field' => 'id',
- 'field' => array(
+ 'field' => [
'id' => 'entity_label',
'entity type field' => 'type',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/FileExtensionFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileExtensionFormatter.php
index bb6a770ca60..afe1b7efc0a 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/FileExtensionFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileExtensionFormatter.php
@@ -34,12 +34,12 @@ class FileExtensionFormatter extends BaseFieldFileFormatterBase {
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
- $form['extension_detect_tar'] = array(
+ $form['extension_detect_tar'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include tar in extension'),
'#description' => $this->t("If the part of the filename just before the extension is '.tar', include this in the extension output."),
'#default_value' => $this->getSetting('extension_detect_tar'),
- );
+ ];
return $form;
}
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php
index 6103239b6e8..631d94140ed 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FilemimeFormatter.php
@@ -43,12 +43,12 @@ class FilemimeFormatter extends BaseFieldFileFormatterBase {
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
- $form['filemime_image'] = array(
+ $form['filemime_image'] = [
'#title' => $this->t('Display an icon'),
'#description' => $this->t('The icon is representing the file type, instead of the MIME text (such as "image/jpeg")'),
'#type' => 'checkbox',
'#default_value' => $this->getSetting('filemime_image'),
- );
+ ];
return $form;
}
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/GenericFileFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/GenericFileFormatter.php
index a76d75a07af..daeb9f42c22 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/GenericFileFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/GenericFileFormatter.php
@@ -21,21 +21,21 @@ class GenericFileFormatter extends FileFormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
$item = $file->_referringItem;
- $elements[$delta] = array(
+ $elements[$delta] = [
'#theme' => 'file_link',
'#file' => $file,
'#description' => $item->description,
- '#cache' => array(
+ '#cache' => [
'tags' => $file->getCacheTags(),
- ),
- );
+ ],
+ ];
// Pass field item attributes to the theme function.
if (isset($item->_attributes)) {
- $elements[$delta] += array('#attributes' => array());
+ $elements[$delta] += ['#attributes' => []];
$elements[$delta]['#attributes'] += $item->_attributes;
// Unset field item attributes since they have been included in the
// formatter output and should not be rendered in the field template.
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php
index 46bbbde569a..a433d99b16e 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php
@@ -25,17 +25,17 @@ class RSSEnclosureFormatter extends FileFormatterBase {
// Add the first file as an enclosure to the RSS item. RSS allows only one
// enclosure per item. See: http://wikipedia.org/wiki/RSS_enclosure
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
- $entity->rss_elements[] = array(
+ $entity->rss_elements[] = [
'key' => 'enclosure',
- 'attributes' => array(
+ 'attributes' => [
// In RSS feeds, it is necessary to use absolute URLs. The 'url.site'
// cache context is already associated with RSS feed responses, so it
// does not need to be specified here.
'url' => file_create_url($file->getFileUri()),
'length' => $file->getSize(),
'type' => $file->getMimeType(),
- ),
- );
+ ],
+ ];
}
return [];
}
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
index 939329a595f..4da9e84366f 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
@@ -21,33 +21,33 @@ class TableFormatter extends FileFormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
if ($files = $this->getEntitiesToView($items, $langcode)) {
- $header = array(t('Attachment'), t('Size'));
- $rows = array();
+ $header = [t('Attachment'), t('Size')];
+ $rows = [];
foreach ($files as $delta => $file) {
- $rows[] = array(
- array(
- 'data' => array(
+ $rows[] = [
+ [
+ 'data' => [
'#theme' => 'file_link',
'#file' => $file,
- '#cache' => array(
+ '#cache' => [
'tags' => $file->getCacheTags(),
- ),
- ),
- ),
- array('data' => format_size($file->getSize())),
- );
+ ],
+ ],
+ ],
+ ['data' => format_size($file->getSize())],
+ ];
}
- $elements[0] = array();
+ $elements[0] = [];
if (!empty($rows)) {
- $elements[0] = array(
+ $elements[0] = [
'#theme' => 'table__file_formatter_table',
'#header' => $header,
'#rows' => $rows,
- );
+ ];
}
}
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php
index ccb97d5ef5d..d5e2a7c70a0 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/UrlPlainFormatter.php
@@ -21,15 +21,15 @@ class UrlPlainFormatter extends FileFormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
- $elements[$delta] = array(
+ $elements[$delta] = [
'#markup' => file_url_transform_relative(file_create_url($file->getFileUri())),
- '#cache' => array(
+ '#cache' => [
'tags' => $file->getCacheTags(),
- ),
- );
+ ],
+ ];
}
return $elements;
diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php
index 20f47975025..9a4dc8339b7 100644
--- a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php
+++ b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php
@@ -30,7 +30,7 @@ class FileFieldItemList extends EntityReferenceFieldItemList {
else {
// Get current target file entities and file IDs.
$files = $this->referencedEntities();
- $ids = array();
+ $ids = [];
/** @var \Drupal\file\FileInterface $file */
foreach ($files as $file) {
@@ -48,7 +48,7 @@ class FileFieldItemList extends EntityReferenceFieldItemList {
// Get the file IDs attached to the field before this update.
$field_name = $this->getFieldDefinition()->getName();
- $original_ids = array();
+ $original_ids = [];
$langcode = $this->getLangcode();
$original = $entity->original;
if ($original->hasTranslation($langcode)) {
diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
index 5ea2692ea1a..7373c4397fe 100644
--- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
+++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
@@ -32,59 +32,59 @@ class FileItem extends EntityReferenceItem {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'target_type' => 'file',
'display_field' => FALSE,
'display_default' => FALSE,
'uri_scheme' => file_default_scheme(),
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'file_extensions' => 'txt',
'file_directory' => '[date:custom:Y]-[date:custom:m]',
'max_filesize' => '',
'description_field' => 0,
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'target_id' => array(
+ return [
+ 'columns' => [
+ 'target_id' => [
'description' => 'The ID of the file entity.',
'type' => 'int',
'unsigned' => TRUE,
- ),
- 'display' => array(
+ ],
+ 'display' => [
'description' => 'Flag to control whether this file should be displayed when viewing content.',
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'default' => 1,
- ),
- 'description' => array(
+ ],
+ 'description' => [
'description' => 'A description of the file.',
'type' => 'text',
- ),
- ),
- 'indexes' => array(
- 'target_id' => array('target_id'),
- ),
- 'foreign keys' => array(
- 'target_id' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'target_id' => ['target_id'],
+ ],
+ 'foreign keys' => [
+ 'target_id' => [
'table' => 'file_managed',
- 'columns' => array('target_id' => 'fid'),
- ),
- ),
- );
+ 'columns' => ['target_id' => 'fid'],
+ ],
+ ],
+ ];
}
/**
@@ -107,37 +107,37 @@ class FileItem extends EntityReferenceItem {
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element = array();
+ $element = [];
$element['#attached']['library'][] = 'file/drupal.file';
- $element['display_field'] = array(
+ $element['display_field'] = [
'#type' => 'checkbox',
'#title' => t('Enable <em>Display</em> field'),
'#default_value' => $this->getSetting('display_field'),
'#description' => t('The display option allows users to choose if a file should be shown when viewing the content.'),
- );
- $element['display_default'] = array(
+ ];
+ $element['display_default'] = [
'#type' => 'checkbox',
'#title' => t('Files displayed by default'),
'#default_value' => $this->getSetting('display_default'),
'#description' => t('This setting only has an effect if the display option is enabled.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="settings[display_field]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="settings[display_field]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
$scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE);
- $element['uri_scheme'] = array(
+ $element['uri_scheme'] = [
'#type' => 'radios',
'#title' => t('Upload destination'),
'#options' => $scheme_options,
'#default_value' => $this->getSetting('uri_scheme'),
'#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
'#disabled' => $has_data,
- );
+ ];
return $element;
}
@@ -146,50 +146,50 @@ class FileItem extends EntityReferenceItem {
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- $element = array();
+ $element = [];
$settings = $this->getSettings();
- $element['file_directory'] = array(
+ $element['file_directory'] = [
'#type' => 'textfield',
'#title' => t('File directory'),
'#default_value' => $settings['file_directory'],
'#description' => t('Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes.'),
- '#element_validate' => array(array(get_class($this), 'validateDirectory')),
+ '#element_validate' => [[get_class($this), 'validateDirectory']],
'#weight' => 3,
- );
+ ];
// Make the extension list a little more human-friendly by comma-separation.
$extensions = str_replace(' ', ', ', $settings['file_extensions']);
- $element['file_extensions'] = array(
+ $element['file_extensions'] = [
'#type' => 'textfield',
'#title' => t('Allowed file extensions'),
'#default_value' => $extensions,
'#description' => t('Separate extensions with a space or comma and do not include the leading dot.'),
- '#element_validate' => array(array(get_class($this), 'validateExtensions')),
+ '#element_validate' => [[get_class($this), 'validateExtensions']],
'#weight' => 1,
'#maxlength' => 256,
// By making this field required, we prevent a potential security issue
// that would allow files of any type to be uploaded.
'#required' => TRUE,
- );
+ ];
- $element['max_filesize'] = array(
+ $element['max_filesize'] = [
'#type' => 'textfield',
'#title' => t('Maximum upload size'),
'#default_value' => $settings['max_filesize'],
- '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))),
+ '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', ['%limit' => format_size(file_upload_max_size())]),
'#size' => 10,
- '#element_validate' => array(array(get_class($this), 'validateMaxFilesize')),
+ '#element_validate' => [[get_class($this), 'validateMaxFilesize']],
'#weight' => 5,
- );
+ ];
- $element['description_field'] = array(
+ $element['description_field'] = [
'#type' => 'checkbox',
'#title' => t('Enable <em>Description</em> field'),
'#default_value' => isset($settings['description_field']) ? $settings['description_field'] : '',
'#description' => t('The description field allows users to enter a description about the uploaded file.'),
'#weight' => 11,
- );
+ ];
return $element;
}
@@ -245,7 +245,7 @@ class FileItem extends EntityReferenceItem {
*/
public static function validateMaxFilesize($element, FormStateInterface $form_state) {
if (!empty($element['#value']) && !is_numeric(Bytes::toInt($element['#value']))) {
- $form_state->setError($element, t('The "@name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('@name' => $element['title'])));
+ $form_state->setError($element, t('The "@name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', ['@name' => $element['title']]));
}
}
@@ -261,7 +261,7 @@ class FileItem extends EntityReferenceItem {
*
* @see \Drupal\Core\Utility\Token::replace()
*/
- public function getUploadLocation($data = array()) {
+ public function getUploadLocation($data = []) {
return static::doGetUploadLocation($this->getSettings(), $data);
}
@@ -296,7 +296,7 @@ class FileItem extends EntityReferenceItem {
* element's '#upload_validators' property.
*/
public function getUploadValidators() {
- $validators = array();
+ $validators = [];
$settings = $this->getSettings();
// Cap the upload size according to the PHP limit.
@@ -306,11 +306,11 @@ class FileItem extends EntityReferenceItem {
}
// There is always a file size limit due to the PHP server limit.
- $validators['file_validate_size'] = array($max_filesize);
+ $validators['file_validate_size'] = [$max_filesize];
// Add the extension check if necessary.
if (!empty($settings['file_extensions'])) {
- $validators['file_validate_extensions'] = array($settings['file_extensions']);
+ $validators['file_validate_extensions'] = [$settings['file_extensions']];
}
return $validators;
@@ -331,11 +331,11 @@ class FileItem extends EntityReferenceItem {
$destination = $dirname . '/' . $random->name(10, TRUE) . '.txt';
$data = $random->paragraphs(3);
$file = file_save_data($data, $destination, FILE_EXISTS_ERROR);
- $values = array(
+ $values = [
'target_id' => $file->id(),
'display' => (int)$settings['display_default'],
'description' => $random->sentences(10),
- );
+ ];
return $values;
}
diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
index 9a9dfe220f0..587a396fc60 100644
--- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
+++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
@@ -48,27 +48,27 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'progress_indicator' => 'throbber',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['progress_indicator'] = array(
+ $element['progress_indicator'] = [
'#type' => 'radios',
'#title' => t('Progress indicator'),
- '#options' => array(
+ '#options' => [
'throbber' => t('Throbber'),
'bar' => t('Bar with progress meter'),
- ),
+ ],
'#default_value' => $this->getSetting('progress_indicator'),
'#description' => t('The throbber display does not show the status of uploads but takes up less space. The progress bar is helpful for monitoring progress on large uploads.'),
'#weight' => 16,
'#access' => file_progress_implementation(),
- );
+ ];
return $element;
}
@@ -76,8 +76,8 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
- $summary[] = t('Progress indicator: @progress_indicator', array('@progress_indicator' => $this->getSetting('progress_indicator')));
+ $summary = [];
+ $summary[] = t('Progress indicator: @progress_indicator', ['@progress_indicator' => $this->getSetting('progress_indicator')]);
return $summary;
}
@@ -115,15 +115,15 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
$title = $this->fieldDefinition->getLabel();
$description = $this->getFilteredDescription();
- $elements = array();
+ $elements = [];
$delta = 0;
// Add an element for every existing item.
foreach ($items as $item) {
- $element = array(
+ $element = [
'#title' => $title,
'#description' => $description,
- );
+ ];
$element = $this->formSingleElement($items, $delta, $element, $form, $form_state);
if ($element) {
@@ -131,15 +131,15 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
if ($is_multiple) {
// We name the element '_weight' to avoid clashing with elements
// defined by widget.
- $element['_weight'] = array(
+ $element['_weight'] = [
'#type' => 'weight',
- '#title' => t('Weight for row @number', array('@number' => $delta + 1)),
+ '#title' => t('Weight for row @number', ['@number' => $delta + 1]),
'#title_display' => 'invisible',
// Note: this 'delta' is the FAPI #type 'weight' element's property.
'#delta' => $max,
'#default_value' => $item->_weight ?: $delta,
'#weight' => 100,
- );
+ ];
}
$elements[$delta] = $element;
@@ -155,10 +155,10 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
if ($empty_single_allowed || $empty_multiple_allowed) {
// Create a new empty item.
$items->appendItem();
- $element = array(
+ $element = [
'#title' => $title,
'#description' => $description,
- );
+ ];
$element = $this->formSingleElement($items, $delta, $element, $form, $form_state);
if ($element) {
$element['#required'] = ($element['#required'] && $delta == 0);
@@ -173,8 +173,8 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
$elements['#type'] = 'details';
$elements['#open'] = TRUE;
$elements['#theme'] = 'file_widget_multiple';
- $elements['#theme_wrappers'] = array('details');
- $elements['#process'] = array(array(get_class($this), 'processMultiple'));
+ $elements['#theme_wrappers'] = ['details'];
+ $elements['#process'] = [[get_class($this), 'processMultiple']];
$elements['#title'] = $title;
$elements['#description'] = $description;
@@ -183,19 +183,19 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
// The field settings include defaults for the field type. However, this
// widget is a base class for other widgets (e.g., ImageWidget) that may
// act on field types without these expected settings.
- $field_settings = $this->getFieldSettings() + array('display_field' => NULL);
+ $field_settings = $this->getFieldSettings() + ['display_field' => NULL];
$elements['#display_field'] = (bool) $field_settings['display_field'];
// Add some properties that will eventually be added to the file upload
// field. These are added here so that they may be referenced easily
// through a hook_form_alter().
$elements['#file_upload_title'] = t('Add a new file');
- $elements['#file_upload_description'] = array(
+ $elements['#file_upload_description'] = [
'#theme' => 'file_upload_help',
'#description' => '',
'#upload_validators' => $elements[0]['#upload_validators'],
'#cardinality' => $cardinality,
- );
+ ];
}
return $elements;
@@ -210,28 +210,28 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
// The field settings include defaults for the field type. However, this
// widget is a base class for other widgets (e.g., ImageWidget) that may act
// on field types without these expected settings.
- $field_settings += array(
+ $field_settings += [
'display_default' => NULL,
'display_field' => NULL,
'description_field' => NULL,
- );
+ ];
$cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
- $defaults = array(
- 'fids' => array(),
+ $defaults = [
+ 'fids' => [],
'display' => (bool) $field_settings['display_default'],
'description' => '',
- );
+ ];
// Essentially we use the managed_file type, extended with some
// enhancements.
$element_info = $this->elementInfo->getInfo('managed_file');
- $element += array(
+ $element += [
'#type' => 'managed_file',
'#upload_location' => $items[$delta]->getUploadLocation(),
'#upload_validators' => $items[$delta]->getUploadValidators(),
- '#value_callback' => array(get_class($this), 'value'),
- '#process' => array_merge($element_info['#process'], array(array(get_class($this), 'process'))),
+ '#value_callback' => [get_class($this), 'value'],
+ '#process' => array_merge($element_info['#process'], [[get_class($this), 'process']]),
'#progress_indicator' => $this->getSetting('progress_indicator'),
// Allows this field to return an array instead of a single value.
'#extended' => TRUE,
@@ -242,29 +242,29 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
'#display_default' => $field_settings['display_default'],
'#description_field' => $field_settings['description_field'],
'#cardinality' => $cardinality,
- );
+ ];
$element['#weight'] = $delta;
// Field stores FID value in a single mode, so we need to transform it for
// form element to recognize it correctly.
if (!isset($items[$delta]->fids) && isset($items[$delta]->target_id)) {
- $items[$delta]->fids = array($items[$delta]->target_id);
+ $items[$delta]->fids = [$items[$delta]->target_id];
}
$element['#default_value'] = $items[$delta]->getValue() + $defaults;
$default_fids = $element['#extended'] ? $element['#default_value']['fids'] : $element['#default_value'];
if (empty($default_fids)) {
- $file_upload_help = array(
+ $file_upload_help = [
'#theme' => 'file_upload_help',
'#description' => $element['#description'],
'#upload_validators' => $element['#upload_validators'],
'#cardinality' => $cardinality,
- );
+ ];
$element['#description'] = \Drupal::service('renderer')->renderPlain($file_upload_help);
$element['#multiple'] = $cardinality != 1 ? TRUE : FALSE;
if ($cardinality != 1 && $cardinality != -1) {
- $element['#element_validate'] = array(array(get_class($this), 'validateMultipleCount'));
+ $element['#element_validate'] = [[get_class($this), 'validateMultipleCount']];
}
}
@@ -278,7 +278,7 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
// Since file upload widget now supports uploads of more than one file at a
// time it always returns an array of fids. We have to translate this to a
// single fid, as field expects single value.
- $new_values = array();
+ $new_values = [];
foreach ($values as &$value) {
foreach ($value['fids'] as $fid) {
$new_value = $value;
@@ -324,11 +324,11 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
$return = ManagedFile::valueCallback($element, $input, $form_state);
// Ensure that all the required properties are returned even if empty.
- $return += array(
- 'fids' => array(),
+ $return += [
+ 'fids' => [],
'display' => 1,
'description' => '',
- );
+ ];
return $return;
}
@@ -353,7 +353,7 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
if ($total_uploaded_count > $field_storage->getCardinality()) {
$keep = $newly_uploaded_count - $total_uploaded_count + $field_storage->getCardinality();
$removed_files = array_slice($values['fids'], $keep);
- $removed_names = array();
+ $removed_names = [];
foreach ($removed_files as $fid) {
$file = File::load($fid);
$removed_names[] = $file->getFilename();
@@ -385,11 +385,11 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
// Add the display field if enabled.
if ($element['#display_field']) {
- $element['display'] = array(
+ $element['display'] = [
'#type' => empty($item['fids']) ? 'hidden' : 'checkbox',
'#title' => t('Include file in display'),
- '#attributes' => array('class' => array('file-display')),
- );
+ '#attributes' => ['class' => ['file-display']],
+ ];
if (isset($item['display'])) {
$element['display']['#value'] = $item['display'] ? '1' : '';
}
@@ -398,33 +398,33 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
}
}
else {
- $element['display'] = array(
+ $element['display'] = [
'#type' => 'hidden',
'#value' => '1',
- );
+ ];
}
// Add the description field if enabled.
if ($element['#description_field'] && $item['fids']) {
$config = \Drupal::config('file.settings');
- $element['description'] = array(
+ $element['description'] = [
'#type' => $config->get('description.type'),
'#title' => t('Description'),
'#value' => isset($item['description']) ? $item['description'] : '',
'#maxlength' => $config->get('description.length'),
'#description' => t('The description may be used as the label of the link to the file.'),
- );
+ ];
}
// Adjust the Ajax settings so that on upload and remove of any individual
// file, the entire group of file fields is updated together.
if ($element['#cardinality'] != 1) {
$parents = array_slice($element['#array_parents'], 0, -1);
- $new_options = array(
- 'query' => array(
+ $new_options = [
+ 'query' => [
'element_parents' => implode('/', $parents),
- ),
- );
+ ],
+ ];
$field_element = NestedArray::getValue($form, $parents);
$new_wrapper = $field_element['#id'] . '-ajax-wrapper';
foreach (Element::children($element) as $key) {
@@ -440,9 +440,9 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
// functionality needed by the field widget. This submit handler, along with
// the rebuild logic in file_field_widget_form() requires the entire field,
// not just the individual item, to be valid.
- foreach (array('upload_button', 'remove_button') as $key) {
- $element[$key]['#submit'][] = array(get_called_class(), 'submit');
- $element[$key]['#limit_validation_errors'] = array(array_slice($element['#parents'], 0, -1));
+ foreach (['upload_button', 'remove_button'] as $key) {
+ $element[$key]['#submit'][] = [get_called_class(), 'submit'];
+ $element[$key]['#limit_validation_errors'] = [array_slice($element['#parents'], 0, -1)];
}
return $element;
@@ -477,22 +477,22 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
foreach ($element_children as $delta => $key) {
if ($key != $element['#file_upload_delta']) {
$description = static::getDescriptionFromElement($element[$key]);
- $element[$key]['_weight'] = array(
+ $element[$key]['_weight'] = [
'#type' => 'weight',
- '#title' => $description ? t('Weight for @title', array('@title' => $description)) : t('Weight for new file'),
+ '#title' => $description ? t('Weight for @title', ['@title' => $description]) : t('Weight for new file'),
'#title_display' => 'invisible',
'#delta' => $count,
'#default_value' => $delta,
- );
+ ];
}
else {
// The title needs to be assigned to the upload field so that validation
// errors include the correct widget label.
$element[$key]['#title'] = $element['#title'];
- $element[$key]['_weight'] = array(
+ $element[$key]['_weight'] = [
'#type' => 'hidden',
'#default_value' => $delta,
- );
+ ];
}
}
@@ -559,12 +559,12 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
// If there are more files uploaded via the same widget, we have to separate
// them, as we display each file in its own widget.
- $new_values = array();
+ $new_values = [];
foreach ($submitted_values as $delta => $submitted_value) {
if (is_array($submitted_value['fids'])) {
foreach ($submitted_value['fids'] as $fid) {
$new_value = $submitted_value;
- $new_value['fids'] = array($fid);
+ $new_value['fids'] = [$fid];
$new_values[] = $new_value;
}
}
diff --git a/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php b/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php
index 7f47caa96e0..ad24ae24f1e 100644
--- a/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php
+++ b/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php
@@ -17,7 +17,7 @@ class ImageField extends CckFieldPluginBase {
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
- return array();
+ return [];
}
/**
diff --git a/core/modules/file/src/Plugin/migrate/source/d6/File.php b/core/modules/file/src/Plugin/migrate/source/d6/File.php
index 13aee57bf67..0564b6b7886 100644
--- a/core/modules/file/src/Plugin/migrate/source/d6/File.php
+++ b/core/modules/file/src/Plugin/migrate/source/d6/File.php
@@ -75,7 +75,7 @@ class File extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'fid' => $this->t('File ID'),
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
'filename' => $this->t('File name'),
@@ -85,7 +85,7 @@ class File extends DrupalSqlBase {
'timestamp' => $this->t('The time that the file was added.'),
'file_directory_path' => $this->t('The Drupal files path.'),
'is_public' => $this->t('TRUE if the files directory is public otherwise FALSE.'),
- );
+ ];
}
/**
* {@inheritdoc}
diff --git a/core/modules/file/src/Plugin/migrate/source/d6/Upload.php b/core/modules/file/src/Plugin/migrate/source/d6/Upload.php
index 5b7c3ae7402..4e07a236b5f 100644
--- a/core/modules/file/src/Plugin/migrate/source/d6/Upload.php
+++ b/core/modules/file/src/Plugin/migrate/source/d6/Upload.php
@@ -26,7 +26,7 @@ class Upload extends DrupalSqlBase {
public function query() {
$query = $this->select('upload', 'u')
->distinct()
- ->fields('u', array('nid', 'vid'));
+ ->fields('u', ['nid', 'vid']);
$query->innerJoin('node', 'n', static::JOIN);
$query->addField('n', 'type');
return $query;
@@ -37,7 +37,7 @@ class Upload extends DrupalSqlBase {
*/
public function prepareRow(Row $row) {
$query = $this->select('upload', 'u')
- ->fields('u', array('fid', 'description', 'list'))
+ ->fields('u', ['fid', 'description', 'list'])
->condition('u.nid', $row->getSourceProperty('nid'))
->orderBy('u.weight');
$query->innerJoin('node', 'n', static::JOIN);
@@ -49,7 +49,7 @@ class Upload extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'fid' => $this->t('The file Id.'),
'nid' => $this->t('The node Id.'),
'vid' => $this->t('The version Id.'),
@@ -57,7 +57,7 @@ class Upload extends DrupalSqlBase {
'description' => $this->t('The file description.'),
'list' => $this->t('Whether the list should be visible on the node page.'),
'weight' => $this->t('The file weight.'),
- );
+ ];
}
/**
diff --git a/core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php b/core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php
index c20ac03eb93..c1b3345d761 100644
--- a/core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php
+++ b/core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php
@@ -30,7 +30,7 @@ class UploadInstance extends DrupalSqlBase {
$max_filesize = $this->variableGet('upload_uploadsize_default', 1);
$max_filesize = $max_filesize ? $max_filesize . 'MB' : '';
$file_extensions = $this->variableGet('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
- $return = array();
+ $return = [];
$values = $this->select('variable', 'v')
->fields('v', ['name', 'value'])
->condition('v.name', $variables, 'IN')
@@ -55,22 +55,22 @@ class UploadInstance extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'node_type' => array(
+ return [
+ 'node_type' => [
'type' => 'string',
- ),
- );
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'node_type' => $this->t('Node type'),
'max_filesize' => $this->t('Max filesize'),
'file_extensions' => $this->t('File extensions'),
- );
+ ];
}
/**
diff --git a/core/modules/file/src/Plugin/migrate/source/d7/File.php b/core/modules/file/src/Plugin/migrate/source/d7/File.php
index 247a6cf0480..e418f825bb8 100644
--- a/core/modules/file/src/Plugin/migrate/source/d7/File.php
+++ b/core/modules/file/src/Plugin/migrate/source/d7/File.php
@@ -46,7 +46,7 @@ class File extends DrupalSqlBase {
// Filter by scheme(s), if configured.
if (isset($this->configuration['scheme'])) {
- $schemes = array();
+ $schemes = [];
// Accept either a single scheme, or a list.
foreach ((array) $this->configuration['scheme'] as $scheme) {
$schemes[] = rtrim($scheme) . '://';
@@ -93,7 +93,7 @@ class File extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'fid' => $this->t('File ID'),
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
'filename' => $this->t('File name'),
@@ -101,7 +101,7 @@ class File extends DrupalSqlBase {
'filemime' => $this->t('File MIME Type'),
'status' => $this->t('The published status of a file.'),
'timestamp' => $this->t('The time that the file was added.'),
- );
+ ];
}
/**
diff --git a/core/modules/file/src/Plugin/views/argument/Fid.php b/core/modules/file/src/Plugin/views/argument/Fid.php
index 832e85dad57..1654fcc2e3e 100644
--- a/core/modules/file/src/Plugin/views/argument/Fid.php
+++ b/core/modules/file/src/Plugin/views/argument/Fid.php
@@ -61,7 +61,7 @@ class Fid extends NumericArgument implements ContainerFactoryPluginInterface {
->condition('fid', $this->value, 'IN')
->execute();
$files = $storage->loadMultiple($fids);
- $titles = array();
+ $titles = [];
foreach ($files as $file) {
$titles[] = $file->getFilename();
}
diff --git a/core/modules/file/src/Plugin/views/field/File.php b/core/modules/file/src/Plugin/views/field/File.php
index 18bc1fc312a..57d8c60acca 100644
--- a/core/modules/file/src/Plugin/views/field/File.php
+++ b/core/modules/file/src/Plugin/views/field/File.php
@@ -33,7 +33,7 @@ class File extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['link_to_file'] = array('default' => FALSE);
+ $options['link_to_file'] = ['default' => FALSE];
return $options;
}
@@ -41,12 +41,12 @@ class File extends FieldPluginBase {
* Provide link to file option
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['link_to_file'] = array(
+ $form['link_to_file'] = [
'#title' => $this->t('Link this field to download the file'),
'#description' => $this->t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_file']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php
index e92cef3f2fc..bb871d4fb1c 100644
--- a/core/modules/file/src/Tests/DownloadTest.php
+++ b/core/modules/file/src/Tests/DownloadTest.php
@@ -63,7 +63,7 @@ class DownloadTest extends FileManagedTestBase {
$url = file_create_url($file->getFileUri());
// Set file_test access header to allow the download.
- file_test_set_return('download', array('x-foo' => 'Bar'));
+ file_test_set_return('download', ['x-foo' => 'Bar']);
$this->drupalGet($url);
$this->assertEqual($this->drupalGetHeader('x-foo'), 'Bar', 'Found header set by file_test module on private download.');
$this->assertFalse($this->drupalGetHeader('x-drupal-cache'), 'Page cache is disabled on private file download.');
@@ -102,10 +102,10 @@ class DownloadTest extends FileManagedTestBase {
// routed through Drupal, whereas private files should be served by Drupal,
// so they need to be. The difference is most apparent when $script_path
// is not empty (i.e., when not using clean URLs).
- $clean_url_settings = array(
+ $clean_url_settings = [
'clean' => '',
'unclean' => 'index.php/',
- );
+ ];
$public_directory_path = \Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath();
foreach ($clean_url_settings as $clean_url_setting => $script_path) {
$clean_urls = $clean_url_setting == 'clean';
@@ -158,7 +158,7 @@ class DownloadTest extends FileManagedTestBase {
if ($scheme == 'private') {
// Tell the implementation of hook_file_download() in file_test.module
// that this file may be downloaded.
- file_test_set_return('download', array('x-foo' => 'Bar'));
+ file_test_set_return('download', ['x-foo' => 'Bar']);
}
$this->drupalGet($url);
diff --git a/core/modules/file/src/Tests/FileFieldAnonymousSubmissionTest.php b/core/modules/file/src/Tests/FileFieldAnonymousSubmissionTest.php
index 2286473c038..b59b1bafd33 100644
--- a/core/modules/file/src/Tests/FileFieldAnonymousSubmissionTest.php
+++ b/core/modules/file/src/Tests/FileFieldAnonymousSubmissionTest.php
@@ -19,10 +19,10 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
protected function setUp() {
parent::setUp();
// Set up permissions for anonymous attacker user.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'create article content' => TRUE,
'access content' => TRUE,
- ));
+ ]);
}
/**
@@ -36,17 +36,17 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
$this->drupalLogout();
$this->drupalGet('node/add/article');
$this->assertResponse(200, 'Loaded the article node form.');
- $this->assertText(strip_tags(t('Create @name', array('@name' => $bundle_label))));
+ $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label])));
- $edit = array(
+ $edit = [
'title[0][value]' => $node_title,
'body[0][value]' => 'Test article',
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertResponse(200);
- $t_args = array('@type' => $bundle_label, '%title' => $node_title);
+ $t_args = ['@type' => $bundle_label, '%title' => $node_title];
$this->assertText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.');
- $matches = array();
+ $matches = [];
if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) {
$nid = end($matches);
$this->assertNotEqual($nid, 0, 'The node ID was extracted from the URL.');
@@ -61,28 +61,28 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
public function testAnonymousNodeWithFile() {
$bundle_label = 'Article';
$node_title = 'Test page';
- $this->createFileField('field_image', 'node', 'article', array(), array('file_extensions' => 'txt png'));
+ $this->createFileField('field_image', 'node', 'article', [], ['file_extensions' => 'txt png']);
// Load the node form.
$this->drupalLogout();
$this->drupalGet('node/add/article');
$this->assertResponse(200, 'Loaded the article node form.');
- $this->assertText(strip_tags(t('Create @name', array('@name' => $bundle_label))));
+ $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label])));
// Generate an image file.
$image = $this->getTestFile('image');
// Submit the form.
- $edit = array(
+ $edit = [
'title[0][value]' => $node_title,
'body[0][value]' => 'Test article',
'files[field_image_0]' => $this->container->get('file_system')->realpath($image->getFileUri()),
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertResponse(200);
- $t_args = array('@type' => $bundle_label, '%title' => $node_title);
+ $t_args = ['@type' => $bundle_label, '%title' => $node_title];
$this->assertText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.');
- $matches = array();
+ $matches = [];
if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) {
$nid = end($matches);
$this->assertNotEqual($nid, 0, 'The node ID was extracted from the URL.');
@@ -104,11 +104,11 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
* Tests file submission for an authenticated user with a missing node title.
*/
public function testAuthenticatedNodeWithFileWithoutTitle() {
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'bypass node access',
'access content overview',
'administer nodes',
- ));
+ ]);
$this->drupalLogin($admin_user);
$this->doTestNodeWithFileWithoutTitle();
}
@@ -119,21 +119,21 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
protected function doTestNodeWithFileWithoutTitle() {
$bundle_label = 'Article';
$node_title = 'Test page';
- $this->createFileField('field_image', 'node', 'article', array(), array('file_extensions' => 'txt png'));
+ $this->createFileField('field_image', 'node', 'article', [], ['file_extensions' => 'txt png']);
// Load the node form.
$this->drupalGet('node/add/article');
$this->assertResponse(200, 'Loaded the article node form.');
- $this->assertText(strip_tags(t('Create @name', array('@name' => $bundle_label))));
+ $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label])));
// Generate an image file.
$image = $this->getTestFile('image');
// Submit the form but exclude the title field.
- $edit = array(
+ $edit = [
'body[0][value]' => 'Test article',
'files[field_image_0]' => $this->container->get('file_system')->realpath($image->getFileUri()),
- );
+ ];
if (!$this->loggedInUser) {
$label = 'Save';
}
@@ -142,21 +142,21 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
}
$this->drupalPostForm(NULL, $edit, $label);
$this->assertResponse(200);
- $t_args = array('@type' => $bundle_label, '%title' => $node_title);
+ $t_args = ['@type' => $bundle_label, '%title' => $node_title];
$this->assertNoText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.');
$this->assertText('Title field is required.');
// Submit the form again but this time with the missing title field. This
// should still work.
- $edit = array(
+ $edit = [
'title[0][value]' => $node_title,
- );
+ ];
$this->drupalPostForm(NULL, $edit, $label);
// Confirm the final submission actually worked.
- $t_args = array('@type' => $bundle_label, '%title' => $node_title);
+ $t_args = ['@type' => $bundle_label, '%title' => $node_title];
$this->assertText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.');
- $matches = array();
+ $matches = [];
if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) {
$nid = end($matches);
$this->assertNotEqual($nid, 0, 'The node ID was extracted from the URL.');
diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php
index b25b5142bc6..f78cd7d6960 100644
--- a/core/modules/file/src/Tests/FileFieldDisplayTest.php
+++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php
@@ -18,23 +18,23 @@ class FileFieldDisplayTest extends FileFieldTestBase {
function testNodeDisplay() {
$field_name = strtolower($this->randomMachineName());
$type_name = 'article';
- $field_storage_settings = array(
+ $field_storage_settings = [
'display_field' => '1',
'display_default' => '1',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- );
- $field_settings = array(
+ ];
+ $field_settings = [
'description_field' => '1',
- );
- $widget_settings = array();
+ ];
+ $widget_settings = [];
$this->createFileField($field_name, 'node', $type_name, $field_storage_settings, $field_settings, $widget_settings);
// Create a new node *without* the file field set, and check that the field
// is not shown for each node display.
- $node = $this->drupalCreateNode(array('type' => $type_name));
+ $node = $this->drupalCreateNode(['type' => $type_name]);
// Check file_default last as the assertions below assume that this is the
// case.
- $file_formatters = array('file_table', 'file_url_plain', 'hidden', 'file_default');
+ $file_formatters = ['file_table', 'file_url_plain', 'hidden', 'file_default'];
foreach ($file_formatters as $formatter) {
if ($formatter === 'hidden') {
$edit = [
@@ -49,7 +49,7 @@ class FileFieldDisplayTest extends FileFieldTestBase {
}
$this->drupalPostForm("admin/structure/types/manage/$type_name/display", $edit, t('Save'));
$this->drupalGet('node/' . $node->id());
- $this->assertNoText($field_name, format_string('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter)));
+ $this->assertNoText($field_name, format_string('Field label is hidden when no file attached for formatter %formatter', ['%formatter' => $formatter]));
}
$test_file = $this->getTestFile('text');
@@ -65,28 +65,28 @@ class FileFieldDisplayTest extends FileFieldTestBase {
// Check that the default formatter is displaying with the file name.
$node_storage = $this->container->get('entity.manager')->getStorage('node');
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
- $file_link = array(
+ $file_link = [
'#theme' => 'file_link',
'#file' => $node_file,
- );
+ ];
$default_output = \Drupal::service('renderer')->renderRoot($file_link);
$this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.');
// Turn the "display" option off and check that the file is no longer displayed.
- $edit = array($field_name . '[0][display]' => FALSE);
+ $edit = [$field_name . '[0][display]' => FALSE];
$this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$this->assertNoRaw($default_output, 'Field is hidden when "display" option is unchecked.');
// Add a description and make sure that it is displayed.
$description = $this->randomMachineName();
- $edit = array(
+ $edit = [
$field_name . '[0][description]' => $description,
$field_name . '[0][display]' => TRUE,
- );
+ ];
$this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$this->assertText($description);
@@ -113,15 +113,15 @@ class FileFieldDisplayTest extends FileFieldTestBase {
function testDefaultFileFieldDisplay() {
$field_name = strtolower($this->randomMachineName());
$type_name = 'article';
- $field_storage_settings = array(
+ $field_storage_settings = [
'display_field' => '1',
'display_default' => '0',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- );
- $field_settings = array(
+ ];
+ $field_settings = [
'description_field' => '1',
- );
- $widget_settings = array();
+ ];
+ $widget_settings = [];
$this->createFileField($field_name, 'node', $type_name, $field_storage_settings, $field_settings, $widget_settings);
$test_file = $this->getTestFile('text');
@@ -142,31 +142,31 @@ class FileFieldDisplayTest extends FileFieldTestBase {
$field_type = 'file';
$field_name = strtolower($this->randomMachineName());
// Use the UI to add a new content type that also contains a file field.
- $edit = array(
+ $edit = [
'name' => $type_name,
'type' => $type_name,
- );
+ ];
$this->drupalPostForm('admin/structure/types/add', $edit, t('Save and manage fields'));
- $edit = array(
+ $edit = [
'new_storage_type' => $field_type,
'field_name' => $field_name,
'label' => $this->randomString(),
- );
+ ];
$this->drupalPostForm('/admin/structure/types/manage/' . $type_name . '/fields/add-field', $edit, t('Save and continue'));
- $this->drupalPostForm(NULL, array(), t('Save field settings'));
+ $this->drupalPostForm(NULL, [], t('Save field settings'));
// Ensure the description field is selected on the field instance settings
// form. That's what this test is all about.
- $edit = array(
+ $edit = [
'settings[description_field]' => TRUE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save settings'));
// Add a node of our new type and upload a file to it.
$file = current($this->drupalGetTestFiles('text'));
$title = $this->randomString();
- $edit = array(
+ $edit = [
'title[0][value]' => $title,
'files[field_' . $field_name . '_0]' => drupal_realpath($file->uri),
- );
+ ];
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$node = $this->drupalGetNodeByTitle($title);
$this->drupalGet('node/' . $node->id() . '/edit');
diff --git a/core/modules/file/src/Tests/FileFieldPathTest.php b/core/modules/file/src/Tests/FileFieldPathTest.php
index c9a15de812a..f2498b52ff2 100644
--- a/core/modules/file/src/Tests/FileFieldPathTest.php
+++ b/core/modules/file/src/Tests/FileFieldPathTest.php
@@ -26,7 +26,7 @@ class FileFieldPathTest extends FileFieldTestBase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Check that the file was uploaded to the correct location.
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
/** @var \Drupal\file\FileInterface $node_file */
$node_file = $node->{$field_name}->entity;
@@ -36,36 +36,36 @@ class FileFieldPathTest extends FileFieldTestBase {
$date_formatter->format(REQUEST_TIME, 'custom', 'Y') . '-' .
$date_formatter->format(REQUEST_TIME, 'custom', 'm') . '/' .
$test_file->getFilename();
- $this->assertPathMatch($expected_filename, $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
+ $this->assertPathMatch($expected_filename, $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', ['%file' => $node_file->getFileUri()]));
// Change the path to contain multiple subdirectories.
- $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz'));
+ $this->updateFileField($field_name, $type_name, ['file_directory' => 'foo/bar/baz']);
// Upload a new file into the subdirectories.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Check that the file was uploaded into the subdirectory.
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
- $this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
+ $this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', ['%file' => $node_file->getFileUri()]));
// Check the path when used with tokens.
// Change the path to contain multiple token directories.
- $this->updateFileField($field_name, $type_name, array('file_directory' => '[current-user:uid]/[current-user:name]'));
+ $this->updateFileField($field_name, $type_name, ['file_directory' => '[current-user:uid]/[current-user:name]']);
// Upload a new file into the token subdirectories.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Check that the file was uploaded into the subdirectory.
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
// Do token replacement using the same user which uploaded the file, not
// the user running the test case.
- $data = array('user' => $this->adminUser);
+ $data = ['user' => $this->adminUser];
$subdirectory = \Drupal::token()->replace('[user:uid]/[user:name]', $data);
- $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->getFileUri())));
+ $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path with token replacements.', ['%file' => $node_file->getFileUri()]));
}
/**
diff --git a/core/modules/file/src/Tests/FileFieldRSSContentTest.php b/core/modules/file/src/Tests/FileFieldRSSContentTest.php
index 4e18e715515..e16e82e6918 100644
--- a/core/modules/file/src/Tests/FileFieldRSSContentTest.php
+++ b/core/modules/file/src/Tests/FileFieldRSSContentTest.php
@@ -16,7 +16,7 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
*
* @var array
*/
- public static $modules = array('node', 'views');
+ public static $modules = ['node', 'views'];
/**
* Tests RSS enclosure formatter display for RSS feeds.
@@ -30,29 +30,29 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
// RSS display must be added manually.
$this->drupalGet("admin/structure/types/manage/$type_name/display");
- $edit = array(
+ $edit = [
"display_modes_custom[rss]" => '1',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Change the format to 'RSS enclosure'.
$this->drupalGet("admin/structure/types/manage/$type_name/display/rss");
- $edit = array(
+ $edit = [
"fields[$field_name][type]" => 'file_rss_enclosure',
"fields[$field_name][region]" => 'content',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Create a new node with a file field set. Promote to frontpage
// needs to be set so this node will appear in the RSS feed.
- $node = $this->drupalCreateNode(array('type' => $type_name, 'promote' => 1));
+ $node = $this->drupalCreateNode(['type' => $type_name, 'promote' => 1]);
$test_file = $this->getTestFile('text');
// Create a new node with the uploaded file.
$nid = $this->uploadNodeFile($test_file, $field_name, $node->id());
// Get the uploaded file from the node.
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
@@ -61,7 +61,7 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
$uploaded_filename = str_replace('public://', '', $node_file->getFileUri());
$selector = sprintf(
'enclosure[url="%s"][length="%s"][type="%s"]',
- file_create_url("public://$uploaded_filename", array('absolute' => TRUE)),
+ file_create_url("public://$uploaded_filename", ['absolute' => TRUE]),
$node_file->getSize(),
$node_file->getMimeType()
);
diff --git a/core/modules/file/src/Tests/FileFieldRevisionTest.php b/core/modules/file/src/Tests/FileFieldRevisionTest.php
index f5d00c7cb03..ef7904182f1 100644
--- a/core/modules/file/src/Tests/FileFieldRevisionTest.php
+++ b/core/modules/file/src/Tests/FileFieldRevisionTest.php
@@ -35,7 +35,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Check that the file exists on disk and in the database.
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file_r1 = File::load($node->{$field_name}->target_id);
$node_vid_r1 = $node->getRevisionId();
@@ -45,7 +45,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Upload another file to the same node in a new revision.
$this->replaceNodeFile($test_file, $field_name, $nid);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file_r2 = File::load($node->{$field_name}->target_id);
$node_vid_r2 = $node->getRevisionId();
@@ -63,8 +63,8 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Save a new version of the node without any changes.
// Check that the file is still the same as the previous revision.
- $this->drupalPostForm('node/' . $nid . '/edit', array('revision' => '1'), t('Save and keep published'));
- $node_storage->resetCache(array($nid));
+ $this->drupalPostForm('node/' . $nid . '/edit', ['revision' => '1'], t('Save and keep published'));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file_r3 = File::load($node->{$field_name}->target_id);
$node_vid_r3 = $node->getRevisionId();
@@ -72,8 +72,8 @@ class FileFieldRevisionTest extends FileFieldTestBase {
$this->assertFileIsPermanent($node_file_r3, 'New revision file is permanent.');
// Revert to the first revision and check that the original file is active.
- $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', array(), t('Revert'));
- $node_storage->resetCache(array($nid));
+ $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', [], t('Revert'));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file_r4 = File::load($node->{$field_name}->target_id);
$this->assertEqual($node_file_r1->id(), $node_file_r4->id(), 'Original revision file still in place after reverting to the original revision.');
@@ -81,7 +81,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Delete the second revision and check that the file is kept (since it is
// still being used by the third revision).
- $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r2 . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r2 . '/delete', [], t('Delete'));
$this->assertFileExists($node_file_r3, 'Second file is still available after deleting second revision, since it is being used by the third revision.');
$this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting second revision, since it is being used by the third revision.');
$this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting second revision, since it is being used by the third revision.');
@@ -94,7 +94,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
$this->drupalGet('user/' . $user->id() . '/edit');
// Delete the third revision and check that the file is not deleted yet.
- $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', [], t('Delete'));
$this->assertFileExists($node_file_r3, 'Second file is still available after deleting third revision, since it is being used by the user.');
$this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting third revision, since it is being used by the user.');
$this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting third revision, since it is being used by the user.');
@@ -113,9 +113,9 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// of the file is older than the system.file.temporary_maximum_age
// configuration value.
db_update('file_managed')
- ->fields(array(
+ ->fields([
'changed' => REQUEST_TIME - ($this->config('system.file')->get('temporary_maximum_age') + 1),
- ))
+ ])
->condition('fid', $node_file_r3->id())
->execute();
\Drupal::service('cron')->run();
@@ -124,14 +124,14 @@ class FileFieldRevisionTest extends FileFieldTestBase {
$this->assertFileEntryNotExists($node_file_r3, 'Second file entry is now deleted after deleting third revision, since it is no longer being used by any other nodes.');
// Delete the entire node and check that the original file is deleted.
- $this->drupalPostForm('node/' . $nid . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('node/' . $nid . '/delete', [], t('Delete'));
// Call file_cron() to clean up the file. Make sure the changed timestamp
// of the file is older than the system.file.temporary_maximum_age
// configuration value.
db_update('file_managed')
- ->fields(array(
+ ->fields([
'changed' => REQUEST_TIME - ($this->config('system.file')->get('temporary_maximum_age') + 1),
- ))
+ ])
->condition('fid', $node_file_r1->id())
->execute();
\Drupal::service('cron')->run();
diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php
index 9ec9c753770..a9c96f3a72a 100644
--- a/core/modules/file/src/Tests/FileFieldTestBase.php
+++ b/core/modules/file/src/Tests/FileFieldTestBase.php
@@ -21,7 +21,7 @@ abstract class FileFieldTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'file', 'file_module_test', 'field_ui');
+ public static $modules = ['node', 'file', 'file_module_test', 'field_ui'];
/**
* An user with administration permissions.
@@ -32,9 +32,9 @@ abstract class FileFieldTestBase extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer node fields', 'administer node display', 'administer nodes', 'bypass node access'));
+ $this->adminUser = $this->drupalCreateUser(['access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer node fields', 'administer node display', 'administer nodes', 'bypass node access']);
$this->drupalLogin($this->adminUser);
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
/**
@@ -76,14 +76,14 @@ abstract class FileFieldTestBase extends WebTestBase {
* @param array $widget_settings
* A list of widget settings that will be added to the widget defaults.
*/
- function createFileField($name, $entity_type, $bundle, $storage_settings = array(), $field_settings = array(), $widget_settings = array()) {
- $field_storage = FieldStorageConfig::create(array(
+ function createFileField($name, $entity_type, $bundle, $storage_settings = [], $field_settings = [], $widget_settings = []) {
+ $field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $name,
'type' => 'file',
'settings' => $storage_settings,
'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1,
- ));
+ ]);
$field_storage->save();
$this->attachFileField($name, $entity_type, $bundle, $field_settings, $widget_settings);
@@ -104,44 +104,44 @@ abstract class FileFieldTestBase extends WebTestBase {
* @param array $widget_settings
* A list of widget settings that will be added to the widget defaults.
*/
- function attachFileField($name, $entity_type, $bundle, $field_settings = array(), $widget_settings = array()) {
- $field = array(
+ function attachFileField($name, $entity_type, $bundle, $field_settings = [], $widget_settings = []) {
+ $field = [
'field_name' => $name,
'label' => $name,
'entity_type' => $entity_type,
'bundle' => $bundle,
'required' => !empty($field_settings['required']),
'settings' => $field_settings,
- );
+ ];
FieldConfig::create($field)->save();
entity_get_form_display($entity_type, $bundle, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'file_generic',
'settings' => $widget_settings,
- ))
+ ])
->save();
// Assign display settings.
entity_get_display($entity_type, $bundle, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'label' => 'hidden',
'type' => 'file_default',
- ))
+ ])
->save();
}
/**
* Updates an existing file field with new settings.
*/
- function updateFileField($name, $type_name, $field_settings = array(), $widget_settings = array()) {
+ function updateFileField($name, $type_name, $field_settings = [], $widget_settings = []) {
$field = FieldConfig::loadByName('node', $type_name, $name);
$field->setSettings(array_merge($field->getSettings(), $field_settings));
$field->save();
entity_get_form_display('node', $type_name, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'settings' => $widget_settings,
- ))
+ ])
->save();
}
@@ -163,7 +163,7 @@ abstract class FileFieldTestBase extends WebTestBase {
* @return int
* The node id.
*/
- function uploadNodeFile(FileInterface $file, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = array()) {
+ function uploadNodeFile(FileInterface $file, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = []) {
return $this->uploadNodeFiles([$file], $field_name, $nid_or_type, $new_revision, $extras);
}
@@ -185,16 +185,16 @@ abstract class FileFieldTestBase extends WebTestBase {
* @return int
* The node id.
*/
- function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = array()) {
- $edit = array(
+ function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = []) {
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
'revision' => (string) (int) $new_revision,
- );
+ ];
$node_storage = $this->container->get('entity.manager')->getStorage('node');
if (is_numeric($nid_or_type)) {
$nid = $nid_or_type;
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
}
else {
@@ -205,7 +205,7 @@ abstract class FileFieldTestBase extends WebTestBase {
// Save at least one revision to better simulate a real site.
$node->setNewRevision();
$node->save();
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertNotEqual($nid, $node->getRevisionId(), 'Node revision exists.');
}
@@ -238,11 +238,11 @@ abstract class FileFieldTestBase extends WebTestBase {
* Note that if replacing a file, it must first be removed then added again.
*/
function removeNodeFile($nid, $new_revision = TRUE) {
- $edit = array(
+ $edit = [
'revision' => (string) (int) $new_revision,
- );
+ ];
- $this->drupalPostForm('node/' . $nid . '/edit', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $nid . '/edit', [], t('Remove'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
}
@@ -250,12 +250,12 @@ abstract class FileFieldTestBase extends WebTestBase {
* Replaces a file within a node.
*/
function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) {
- $edit = array(
+ $edit = [
'files[' . $field_name . '_0]' => drupal_realpath($file->getFileUri()),
'revision' => (string) (int) $new_revision,
- );
+ ];
- $this->drupalPostForm('node/' . $nid . '/edit', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $nid . '/edit', [], t('Remove'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
}
@@ -263,7 +263,7 @@ abstract class FileFieldTestBase extends WebTestBase {
* Asserts that a file exists physically on disk.
*/
function assertFileExists($file, $message = NULL) {
- $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists on the disk.', ['%file' => $file->getFileUri()]);
$this->assertTrue(is_file($file->getFileUri()), $message);
}
@@ -273,7 +273,7 @@ abstract class FileFieldTestBase extends WebTestBase {
function assertFileEntryExists($file, $message = NULL) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
$db_file = File::load($file->id());
- $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message);
}
@@ -281,7 +281,7 @@ abstract class FileFieldTestBase extends WebTestBase {
* Asserts that a file does not exist on disk.
*/
function assertFileNotExists($file, $message = NULL) {
- $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists on the disk.', ['%file' => $file->getFileUri()]);
$this->assertFalse(is_file($file->getFileUri()), $message);
}
@@ -290,7 +290,7 @@ abstract class FileFieldTestBase extends WebTestBase {
*/
function assertFileEntryNotExists($file, $message) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
- $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertFalse(File::load($file->id()), $message);
}
@@ -298,7 +298,7 @@ abstract class FileFieldTestBase extends WebTestBase {
* Asserts that a file's status is set to permanent in the database.
*/
function assertFileIsPermanent(FileInterface $file, $message = NULL) {
- $message = isset($message) ? $message : format_string('File %file is permanent.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file is permanent.', ['%file' => $file->getFileUri()]);
$this->assertTrue($file->isPermanent(), $message);
}
diff --git a/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php
index 9d43060ccce..0f8b1f1de7f 100644
--- a/core/modules/file/src/Tests/FileFieldValidateTest.php
+++ b/core/modules/file/src/Tests/FileFieldValidateTest.php
@@ -21,22 +21,22 @@ class FileFieldValidateTest extends FileFieldTestBase {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
- $storage = $this->createFileField($field_name, 'node', $type_name, array(), array('required' => '1'));
+ $storage = $this->createFileField($field_name, 'node', $type_name, [], ['required' => '1']);
$field = FieldConfig::loadByName('node', $type_name, $field_name);
$test_file = $this->getTestFile('text');
// Try to post a new node without uploading a file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
- $this->assertRaw(t('@title field is required.', array('@title' => $field->getLabel())), 'Node save failed when required file field was empty.');
+ $this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]), 'Node save failed when required file field was empty.');
// Create a new node with the uploaded file.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
- $this->assertTrue($nid !== FALSE, format_string('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->getFileUri(), '@field_name' => $field_name, '@type_name' => $type_name)));
+ $this->assertTrue($nid !== FALSE, format_string('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', ['@test_file' => $test_file->getFileUri(), '@field_name' => $field_name, '@type_name' => $type_name]));
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
@@ -45,17 +45,17 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Try again with a multiple value field.
$storage->delete();
- $this->createFileField($field_name, 'node', $type_name, array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), array('required' => '1'));
+ $this->createFileField($field_name, 'node', $type_name, ['cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED], ['required' => '1']);
// Try to post a new node without uploading a file in the multivalue field.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
- $this->assertRaw(t('@title field is required.', array('@title' => $field->getLabel())), 'Node save failed when required multiple value file field was empty.');
+ $this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]), 'Node save failed when required multiple value file field was empty.');
// Create a new node with the uploaded file into the multivalue field.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
$this->assertFileExists($node_file, 'File exists after uploading to the required multiple value field.');
@@ -69,46 +69,46 @@ class FileFieldValidateTest extends FileFieldTestBase {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
- $this->createFileField($field_name, 'node', $type_name, array(), array('required' => '1'));
+ $this->createFileField($field_name, 'node', $type_name, [], ['required' => '1']);
$small_file = $this->getTestFile('text', 131072); // 128KB.
$large_file = $this->getTestFile('text', 1310720); // 1.2MB
// Test uploading both a large and small file with different increments.
- $sizes = array(
+ $sizes = [
'1M' => 1048576,
'1024K' => 1048576,
'1048576' => 1048576,
- );
+ ];
foreach ($sizes as $max_filesize => $file_limit) {
// Set the max file upload size.
- $this->updateFileField($field_name, $type_name, array('max_filesize' => $max_filesize));
+ $this->updateFileField($field_name, $type_name, ['max_filesize' => $max_filesize]);
// Create a new node with the small file, which should pass.
$nid = $this->uploadNodeFile($small_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
- $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize)));
- $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize)));
+ $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) under the max limit (%maxsize).', ['%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize]));
+ $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', ['%filesize' => format_size($small_file->getSize()), '%maxsize' => $max_filesize]));
// Check that uploading the large file fails (1M limit).
$this->uploadNodeFile($large_file, $field_name, $type_name);
- $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($large_file->getSize()), '%maxsize' => format_size($file_limit)));
- $this->assertRaw($error_message, format_string('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->getSize()), '%maxsize' => $max_filesize)));
+ $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', ['%filesize' => format_size($large_file->getSize()), '%maxsize' => format_size($file_limit)]);
+ $this->assertRaw($error_message, format_string('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', ['%filesize' => format_size($large_file->getSize()), '%maxsize' => $max_filesize]));
}
// Turn off the max filesize.
- $this->updateFileField($field_name, $type_name, array('max_filesize' => ''));
+ $this->updateFileField($field_name, $type_name, ['max_filesize' => '']);
// Upload the big file successfully.
$nid = $this->uploadNodeFile($large_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
- $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize()))));
- $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->getSize()))));
+ $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) with no max limit.', ['%filesize' => format_size($large_file->getSize())]));
+ $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) with no max limit.', ['%filesize' => format_size($large_file->getSize())]));
}
/**
@@ -124,30 +124,30 @@ class FileFieldValidateTest extends FileFieldTestBase {
list(, $test_file_extension) = explode('.', $test_file->getFilename());
// Disable extension checking.
- $this->updateFileField($field_name, $type_name, array('file_extensions' => ''));
+ $this->updateFileField($field_name, $type_name, ['file_extensions' => '']);
// Check that the file can be uploaded with no extension checking.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
$this->assertFileExists($node_file, 'File exists after uploading a file with no extension checking.');
$this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with no extension checking.');
// Enable extension checking for text files.
- $this->updateFileField($field_name, $type_name, array('file_extensions' => 'txt'));
+ $this->updateFileField($field_name, $type_name, ['file_extensions' => 'txt']);
// Check that the file with the wrong extension cannot be uploaded.
$this->uploadNodeFile($test_file, $field_name, $type_name);
- $error_message = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => 'txt'));
+ $error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
$this->assertRaw($error_message, 'Node save failed when file uploaded with the wrong extension.');
// Enable extension checking for text and image files.
- $this->updateFileField($field_name, $type_name, array('file_extensions' => "txt $test_file_extension"));
+ $this->updateFileField($field_name, $type_name, ['file_extensions' => "txt $test_file_extension"]);
// Check that the file can be uploaded with extension checking.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
$this->assertFileExists($node_file, 'File exists after uploading a file with extension checking.');
@@ -166,18 +166,18 @@ class FileFieldValidateTest extends FileFieldTestBase {
$test_file = $this->getTestFile('image');
// Disable extension checking.
- $this->updateFileField($field_name, $type_name, array('file_extensions' => ''));
+ $this->updateFileField($field_name, $type_name, ['file_extensions' => '']);
// Check that the file can be uploaded with no extension checking.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
$this->assertFileExists($node_file, 'File exists after uploading a file with no extension checking.');
$this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with no extension checking.');
// Enable extension checking for text files.
- $this->updateFileField($field_name, $type_name, array('file_extensions' => 'txt'));
+ $this->updateFileField($field_name, $type_name, ['file_extensions' => 'txt']);
// Check that the file can still be removed.
$this->removeNodeFile($nid);
diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php
index 414c86b55f3..f132d70d5f7 100644
--- a/core/modules/file/src/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php
@@ -38,7 +38,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
*
* @var array
*/
- public static $modules = array('comment', 'block');
+ public static $modules = ['comment', 'block'];
/**
* Creates a temporary file, for a specific user.
@@ -81,13 +81,13 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$test_file = $this->getTestFile('text');
- foreach (array('nojs', 'js') as $type) {
+ foreach (['nojs', 'js'] as $type) {
// Create a new node with the uploaded file and ensure it got uploaded
// successfully.
// @todo This only tests a 'nojs' submission, because drupalPostAjaxForm()
// does not yet support file uploads.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
$this->assertFileExists($node_file, 'New file saved to disk on node creation.');
@@ -104,11 +104,11 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// "Click" the remove button (emulating either a nojs or js submission).
switch ($type) {
case 'nojs':
- $this->drupalPostForm(NULL, array(), t('Remove'));
+ $this->drupalPostForm(NULL, [], t('Remove'));
break;
case 'js':
$button = $this->xpath('//input[@type="submit" and @value="' . t('Remove') . '"]');
- $this->drupalPostAjaxForm(NULL, array(), array((string) $button[0]['name'] => (string) $button[0]['value']));
+ $this->drupalPostAjaxForm(NULL, [], [(string) $button[0]['name'] => (string) $button[0]['value']]);
break;
}
@@ -121,8 +121,8 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$this->assertTrue(isset($label[0]), 'Label for upload found.');
// Save the node and ensure it does not have the file.
- $this->drupalPostForm(NULL, array(), t('Save and keep published'));
- $node_storage->resetCache(array($nid));
+ $this->drupalPostForm(NULL, [], t('Save and keep published'));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertTrue(empty($node->{$field_name}->target_id), 'File was successfully removed from the node.');
}
@@ -143,12 +143,12 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$field_name = 'test_file_field_1';
$field_name2 = 'test_file_field_2';
$cardinality = 3;
- $this->createFileField($field_name, 'node', $type_name, array('cardinality' => $cardinality));
- $this->createFileField($field_name2, 'node', $type_name, array('cardinality' => $cardinality));
+ $this->createFileField($field_name, 'node', $type_name, ['cardinality' => $cardinality]);
+ $this->createFileField($field_name2, 'node', $type_name, ['cardinality' => $cardinality]);
$test_file = $this->getTestFile('text');
- foreach (array('nojs', 'js') as $type) {
+ foreach (['nojs', 'js'] as $type) {
// Visit the node creation form, and upload 3 files for each field. Since
// the field has cardinality of 3, ensure the "Upload" button is displayed
// until after the 3rd file, and after that, isn't displayed. Because
@@ -158,9 +158,9 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// does not yet emulate jQuery's file upload.
//
$this->drupalGet("node/add/$type_name");
- foreach (array($field_name2, $field_name) as $each_field_name) {
+ foreach ([$field_name2, $field_name] as $each_field_name) {
for ($delta = 0; $delta < 3; $delta++) {
- $edit = array('files[' . $each_field_name . '_' . $delta . '][]' => drupal_realpath($test_file->getFileUri()));
+ $edit = ['files[' . $each_field_name . '_' . $delta . '][]' => drupal_realpath($test_file->getFileUri())];
// If the Upload button doesn't exist, drupalPostForm() will automatically
// fail with an assertion message.
$this->drupalPostForm(NULL, $edit, t('Upload'));
@@ -170,7 +170,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$num_expected_remove_buttons = 6;
- foreach (array($field_name, $field_name2) as $current_field_name) {
+ foreach ([$field_name, $field_name2] as $current_field_name) {
// How many uploaded files for the current field are remaining.
$remaining = 3;
// Test clicking each "Remove" button. For extra robustness, test them out
@@ -179,11 +179,11 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// - First remove the 2nd file.
// - Then remove what is then the 2nd file (was originally the 3rd file).
// - Then remove the first file.
- foreach (array(1, 1, 0) as $delta) {
+ foreach ([1, 1, 0] as $delta) {
// Ensure we have the expected number of Remove buttons, and that they
// are numbered sequentially.
$buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
- $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, format_string('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type)));
+ $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, format_string('There are %n "Remove" buttons displayed (JSMode=%type).', ['%n' => $num_expected_remove_buttons, '%type' => $type]));
foreach ($buttons as $i => $button) {
$key = $i >= $remaining ? $i - $remaining : $i;
$check_field_name = $field_name2;
@@ -210,12 +210,12 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$button['value'] = 'DUMMY';
}
}
- $this->drupalPostForm(NULL, array(), t('Remove'));
+ $this->drupalPostForm(NULL, [], t('Remove'));
break;
case 'js':
// drupalPostAjaxForm() lets us target the button precisely, so we don't
// require the workaround used above for nojs.
- $this->drupalPostAjaxForm(NULL, array(), array($button_name => t('Remove')));
+ $this->drupalPostAjaxForm(NULL, [], [$button_name => t('Remove')]);
break;
}
$num_expected_remove_buttons--;
@@ -224,38 +224,38 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Ensure an "Upload" button for the current field is displayed with the
// correct name.
$upload_button_name = $current_field_name . '_' . $remaining . '_upload_button';
- $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name));
- $this->assertTrue(is_array($buttons) && count($buttons) == 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type)));
+ $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', [':name' => $upload_button_name]);
+ $this->assertTrue(is_array($buttons) && count($buttons) == 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', ['%type' => $type]));
// Ensure only at most one button per field is displayed.
$buttons = $this->xpath('//input[@type="submit" and @value="Upload"]');
$expected = $current_field_name == $field_name ? 1 : 2;
- $this->assertTrue(is_array($buttons) && count($buttons) == $expected, format_string('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type)));
+ $this->assertTrue(is_array($buttons) && count($buttons) == $expected, format_string('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', ['%type' => $type]));
}
}
// Ensure the page now has no Remove buttons.
- $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), format_string('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type)));
+ $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), format_string('After removing all files, there is no "Remove" button displayed (JSMode=%type).', ['%type' => $type]));
// Save the node and ensure it does not have any files.
- $this->drupalPostForm(NULL, array('title[0][value]' => $this->randomMachineName()), t('Save and publish'));
- $matches = array();
+ $this->drupalPostForm(NULL, ['title[0][value]' => $this->randomMachineName()], t('Save and publish'));
+ $matches = [];
preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
$nid = $matches[1];
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertTrue(empty($node->{$field_name}->target_id), 'Node was successfully saved without any files.');
}
- $upload_files_node_creation = array($test_file, $test_file);
+ $upload_files_node_creation = [$test_file, $test_file];
// Try to upload multiple files, but fewer than the maximum.
$nid = $this->uploadNodeFiles($upload_files_node_creation, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertEqual(count($node->{$field_name}), count($upload_files_node_creation), 'Node was successfully saved with mulitple files.');
// Try to upload more files than allowed on revision.
- $upload_files_node_revision = array($test_file, $test_file, $test_file, $test_file);
+ $upload_files_node_revision = [$test_file, $test_file, $test_file, $test_file];
$this->uploadNodeFiles($upload_files_node_revision, $field_name, $nid, 1);
$args = [
'%field' => $field_name,
@@ -264,7 +264,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
'%list' => implode(', ', array_fill(0, 3, $test_file->getFilename())),
];
$this->assertRaw(t('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args));
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertEqual(count($node->{$field_name}), $cardinality, 'More files than allowed could not be saved to node.');
@@ -274,14 +274,14 @@ class FileFieldWidgetTest extends FileFieldTestBase {
'type' => $type_name
]);
$this->uploadNodeFile($test_file, $field_name, $node->id(), 1);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertEqual(count($node->{$field_name}), $cardinality, 'Node was successfully revised to maximum number of files.');
// Try to upload exactly the allowed number of files, new node.
$upload_files = array_fill(0, $cardinality, $test_file);
$nid = $this->uploadNodeFiles($upload_files, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertEqual(count($node->{$field_name}), $cardinality, 'Node was successfully saved with maximum number of files.');
@@ -304,7 +304,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
function testPrivateFileSetting() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
// Grant the admin user required permissions.
- user_role_grant_permissions($this->adminUser->roles[0]->target_id, array('administer node fields'));
+ user_role_grant_permissions($this->adminUser->roles[0]->target_id, ['administer node fields']);
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
@@ -315,10 +315,10 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$test_file = $this->getTestFile('text');
// Change the field setting to make its files private, and upload a file.
- $edit = array('settings[uri_scheme]' => 'private');
+ $edit = ['settings[uri_scheme]' => 'private'];
$this->drupalPostForm("admin/structure/types/manage/$type_name/fields/$field_id/storage", $edit, t('Save field settings'));
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
$this->assertFileExists($node_file, 'New file saved to disk on node creation.');
@@ -342,41 +342,41 @@ class FileFieldWidgetTest extends FileFieldTestBase {
* Tests that download restrictions on private files work on comments.
*/
function testPrivateFileComment() {
- $user = $this->drupalCreateUser(array('access comments'));
+ $user = $this->drupalCreateUser(['access comments']);
// Grant the admin user required comment permissions.
$roles = $this->adminUser->getRoles();
- user_role_grant_permissions($roles[1], array('administer comment fields', 'administer comments'));
+ user_role_grant_permissions($roles[1], ['administer comment fields', 'administer comments']);
// Revoke access comments permission from anon user, grant post to
// authenticated.
- user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access comments'));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('post comments', 'skip comment approval'));
+ user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['post comments', 'skip comment approval']);
// Create a new field.
$this->addDefaultCommentField('node', 'article');
$name = strtolower($this->randomMachineName());
$label = $this->randomMachineName();
- $storage_edit = array('settings[uri_scheme]' => 'private');
+ $storage_edit = ['settings[uri_scheme]' => 'private'];
$this->fieldUIAddNewField('admin/structure/comment/manage/comment', $name, $label, 'file', $storage_edit);
// Manually clear cache on the tester side.
\Drupal::entityManager()->clearCachedFieldDefinitions();
// Create node.
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
// Add a comment with a file.
$text_file = $this->getTestFile('text');
- $edit = array(
+ $edit = [
'files[field_' . $name . '_' . 0 . ']' => drupal_realpath($text_file->getFileUri()),
'comment_body[0][value]' => $comment_body = $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('node/' . $node->id(), $edit, t('Save'));
// Get the comment ID.
@@ -402,7 +402,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Unpublishes node.
$this->drupalLogin($this->adminUser);
- $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save and unpublish'));
+ $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and unpublish'));
// Ensures normal user can no longer download the file.
$this->drupalLogin($user);
@@ -417,11 +417,11 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
$this->createFileField($field_name, 'node', $type_name);
- $this->updateFileField($field_name, $type_name, array('file_extensions' => 'txt'));
+ $this->updateFileField($field_name, $type_name, ['file_extensions' => 'txt']);
- foreach (array('nojs', 'js') as $type) {
+ foreach (['nojs', 'js'] as $type) {
// Create node and prepare files for upload.
- $node = $this->drupalCreateNode(array('type' => 'article'));
+ $node = $this->drupalCreateNode(['type' => 'article']);
$nid = $node->id();
$this->drupalGet("node/$nid/edit");
$test_file_text = $this->getTestFile('text');
@@ -436,11 +436,11 @@ class FileFieldWidgetTest extends FileFieldTestBase {
break;
case 'js':
$button = $this->xpath('//input[@type="submit" and @value="' . t('Upload') . '"]');
- $this->drupalPostAjaxForm(NULL, $edit, array((string) $button[0]['name'] => (string) $button[0]['value']));
+ $this->drupalPostAjaxForm(NULL, $edit, [(string) $button[0]['name'] => (string) $button[0]['value']]);
break;
}
- $error_message = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => 'txt'));
- $this->assertRaw($error_message, t('Validation error when file with wrong extension uploaded (JSMode=%type).', array('%type' => $type)));
+ $error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
+ $this->assertRaw($error_message, t('Validation error when file with wrong extension uploaded (JSMode=%type).', ['%type' => $type]));
// Upload file with correct extension, check that error message is removed.
$edit[$name] = drupal_realpath($test_file_text->getFileUri());
@@ -450,10 +450,10 @@ class FileFieldWidgetTest extends FileFieldTestBase {
break;
case 'js':
$button = $this->xpath('//input[@type="submit" and @value="' . t('Upload') . '"]');
- $this->drupalPostAjaxForm(NULL, $edit, array((string) $button[0]['name'] => (string) $button[0]['value']));
+ $this->drupalPostAjaxForm(NULL, $edit, [(string) $button[0]['name'] => (string) $button[0]['value']]);
break;
}
- $this->assertNoRaw($error_message, t('Validation error removed when file with correct extension uploaded (JSMode=%type).', array('%type' => $type)));
+ $this->assertNoRaw($error_message, t('Validation error removed when file with correct extension uploaded (JSMode=%type).', ['%type' => $type]));
}
}
@@ -498,11 +498,11 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$victim_user = $this->drupalCreateUser();
// Create an attacker user.
- $attacker_user = $this->drupalCreateUser(array(
+ $attacker_user = $this->drupalCreateUser([
'access content',
'create article content',
'edit any article content',
- ));
+ ]);
// Log in as the attacker user.
$this->drupalLogin($attacker_user);
@@ -522,11 +522,11 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$attacker_user = User::getAnonymousUser();
// Set up permissions for anonymous attacker user.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access content' => TRUE,
'create article content' => TRUE,
'edit any article content' => TRUE,
- ));
+ ]);
// Log out so as to be the anonymous attacker user.
$this->drupalLogout();
@@ -549,7 +549,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$this->createFileField($field_name, 'node', $type_name);
$test_file = $this->getTestFile('text');
- foreach (array('nojs', 'js') as $type) {
+ foreach (['nojs', 'js'] as $type) {
// Create a temporary file owned by the victim user. This will be as if
// they had uploaded the file, but not saved the node they were editing
// or creating.
@@ -567,7 +567,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Attach a file to a node.
$edit['files[' . $field_name . '_0]'] = $this->container->get('file_system')->realpath($test_file->getFileUri());
- $this->drupalPostForm(Url::fromRoute('node.add', array('node_type' => $type_name)), $edit, t('Save'));
+ $this->drupalPostForm(Url::fromRoute('node.add', ['node_type' => $type_name]), $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
/** @var \Drupal\file\FileInterface $node_file */
diff --git a/core/modules/file/src/Tests/FileListingTest.php b/core/modules/file/src/Tests/FileListingTest.php
index 708f1385f94..e163529ed26 100644
--- a/core/modules/file/src/Tests/FileListingTest.php
+++ b/core/modules/file/src/Tests/FileListingTest.php
@@ -18,7 +18,7 @@ class FileListingTest extends FileFieldTestBase {
*
* @var array
*/
- public static $modules = array('views', 'file', 'image', 'entity_test');
+ public static $modules = ['views', 'file', 'image', 'entity_test'];
/**
* An authenticated user.
@@ -30,9 +30,9 @@ class FileListingTest extends FileFieldTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('access files overview', 'bypass node access'));
+ $this->adminUser = $this->drupalCreateUser(['access files overview', 'bypass node access']);
$this->baseUser = $this->drupalCreateUser();
- $this->createFileField('file', 'node', 'article', array(), array('file_extensions' => 'txt png'));
+ $this->createFileField('file', 'node', 'article', [], ['file_extensions' => 'txt png']);
}
/**
@@ -70,7 +70,7 @@ class FileListingTest extends FileFieldTestBase {
$this->drupalLogin($this->adminUser);
for ($i = 0; $i < 5; $i++) {
- $nodes[] = $this->drupalCreateNode(array('type' => 'article'));
+ $nodes[] = $this->drupalCreateNode(['type' => 'article']);
}
$this->drupalGet('admin/content/files');
@@ -84,15 +84,15 @@ class FileListingTest extends FileFieldTestBase {
$this->drupalGet('admin/content/files/usage/' . $file->id());
$this->assertResponse(200);
- $this->assertTitle(t('File usage information for @file | Drupal', array('@file' => $file->getFilename())));
+ $this->assertTitle(t('File usage information for @file | Drupal', ['@file' => $file->getFilename()]));
foreach ($nodes as &$node) {
$this->drupalGet('node/' . $node->id() . '/edit');
$file = $this->getTestFile('image');
- $edit = array(
+ $edit = [
'files[file_0]' => drupal_realpath($file->getFileUri()),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$node = Node::load($node->id());
}
@@ -122,7 +122,7 @@ class FileListingTest extends FileFieldTestBase {
$usage = $this->sumUsages($file_usage->listUsage($file));
$this->assertRaw('admin/content/files/usage/' . $file->id() . '">' . $usage);
- $result = $this->xpath("//td[contains(@class, 'views-field-status') and contains(text(), :value)]", array(':value' => t('Temporary')));
+ $result = $this->xpath("//td[contains(@class, 'views-field-status') and contains(text(), :value)]", [':value' => t('Temporary')]);
$this->assertEqual(1, count($result), 'Unused file marked as temporary.');
// Test file usage page.
@@ -155,7 +155,7 @@ class FileListingTest extends FileFieldTestBase {
// Create a bundle and attach a File field to the bundle.
$bundle = $this->randomMachineName();
entity_test_create_bundle($bundle, NULL, 'entity_test_constraints');
- $this->createFileField('field_test_file', 'entity_test_constraints', $bundle, array(), array('file_extensions' => 'txt png'));
+ $this->createFileField('field_test_file', 'entity_test_constraints', $bundle, [], ['file_extensions' => 'txt png']);
// Create file to attach to entity.
$file = File::create([
@@ -169,18 +169,18 @@ class FileListingTest extends FileFieldTestBase {
// Create entity and attach the created file.
$entity_name = $this->randomMachineName();
- $entity = EntityTestConstraints::create(array(
+ $entity = EntityTestConstraints::create([
'uid' => 1,
'name' => $entity_name,
'type' => $bundle,
- 'field_test_file' => array(
+ 'field_test_file' => [
'target_id' => $file->id(),
- ),
- ));
+ ],
+ ]);
$entity->save();
// Create node entity and attach the created file.
- $node = $this->drupalCreateNode(array('type' => 'article', 'file' => $file));
+ $node = $this->drupalCreateNode(['type' => 'article', 'file' => $file]);
$node->save();
// Load the file usage page for the created and attached file.
diff --git a/core/modules/file/src/Tests/FileManagedFileElementTest.php b/core/modules/file/src/Tests/FileManagedFileElementTest.php
index 07102a04df9..994803e0be6 100644
--- a/core/modules/file/src/Tests/FileManagedFileElementTest.php
+++ b/core/modules/file/src/Tests/FileManagedFileElementTest.php
@@ -21,16 +21,16 @@ class FileManagedFileElementTest extends FileFieldTestBase {
// Perform the tests with all permutations of $form['#tree'],
// $element['#extended'], and $element['#multiple'].
$test_file = $this->getTestFile('text');
- foreach (array(0, 1) as $tree) {
- foreach (array(0, 1) as $extended) {
- foreach (array(0, 1) as $multiple) {
+ foreach ([0, 1] as $tree) {
+ foreach ([0, 1] as $extended) {
+ foreach ([0, 1] as $multiple) {
$path = 'file/test/' . $tree . '/' . $extended . '/' . $multiple;
$input_base_name = $tree ? 'nested_file' : 'file';
$file_field_name = $multiple ? 'files[' . $input_base_name . '][]' : 'files[' . $input_base_name . ']';
// Submit without a file.
- $this->drupalPostForm($path, array(), t('Save'));
- $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array()))), 'Submitted without a file.');
+ $this->drupalPostForm($path, [], t('Save'));
+ $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [])]), 'Submitted without a file.');
// Submit with a file, but with an invalid form token. Ensure the file
// was not saved.
@@ -46,22 +46,22 @@ class FileManagedFileElementTest extends FileFieldTestBase {
// Submit a new file, without using the Upload button.
$last_fid_prior = $this->getLastFileId();
- $edit = array($file_field_name => drupal_realpath($test_file->getFileUri()));
+ $edit = [$file_field_name => drupal_realpath($test_file->getFileUri())];
$this->drupalPostForm($path, $edit, t('Save'));
$last_fid = $this->getLastFileId();
$this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.');
- $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array($last_fid)))), 'Submit handler has correct file info.');
+ $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Submit handler has correct file info.');
// Submit no new input, but with a default file.
- $this->drupalPostForm($path . '/' . $last_fid, array(), t('Save'));
- $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array($last_fid)))), 'Empty submission did not change an existing file.');
+ $this->drupalPostForm($path . '/' . $last_fid, [], t('Save'));
+ $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Empty submission did not change an existing file.');
// Now, test the Upload and Remove buttons, with and without Ajax.
- foreach (array(FALSE, TRUE) as $ajax) {
+ foreach ([FALSE, TRUE] as $ajax) {
// Upload, then Submit.
$last_fid_prior = $this->getLastFileId();
$this->drupalGet($path);
- $edit = array($file_field_name => drupal_realpath($test_file->getFileUri()));
+ $edit = [$file_field_name => drupal_realpath($test_file->getFileUri())];
if ($ajax) {
$this->drupalPostAjaxForm(NULL, $edit, $input_base_name . '_upload_button');
}
@@ -70,15 +70,15 @@ class FileManagedFileElementTest extends FileFieldTestBase {
}
$last_fid = $this->getLastFileId();
$this->assertTrue($last_fid > $last_fid_prior, 'New file got uploaded.');
- $this->drupalPostForm(NULL, array(), t('Save'));
- $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', array($last_fid)))), 'Submit handler has correct file info.');
+ $this->drupalPostForm(NULL, [], t('Save'));
+ $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Submit handler has correct file info.');
// Remove, then Submit.
$remove_button_title = $multiple ? t('Remove selected') : t('Remove');
- $remove_edit = array();
+ $remove_edit = [];
if ($multiple) {
$selected_checkbox = ($tree ? 'nested[file]' : 'file') . '[file_' . $last_fid . '][selected]';
- $remove_edit = array($selected_checkbox => '1');
+ $remove_edit = [$selected_checkbox => '1'];
}
$this->drupalGet($path . '/' . $last_fid);
if ($ajax) {
@@ -87,22 +87,22 @@ class FileManagedFileElementTest extends FileFieldTestBase {
else {
$this->drupalPostForm(NULL, $remove_edit, $remove_button_title);
}
- $this->drupalPostForm(NULL, array(), t('Save'));
- $this->assertRaw(t('The file ids are %fids.', array('%fids' => '')), 'Submission after file removal was successful.');
+ $this->drupalPostForm(NULL, [], t('Save'));
+ $this->assertRaw(t('The file ids are %fids.', ['%fids' => '']), 'Submission after file removal was successful.');
// Upload, then Remove, then Submit.
$this->drupalGet($path);
- $edit = array($file_field_name => drupal_realpath($test_file->getFileUri()));
+ $edit = [$file_field_name => drupal_realpath($test_file->getFileUri())];
if ($ajax) {
$this->drupalPostAjaxForm(NULL, $edit, $input_base_name . '_upload_button');
}
else {
$this->drupalPostForm(NULL, $edit, t('Upload'));
}
- $remove_edit = array();
+ $remove_edit = [];
if ($multiple) {
$selected_checkbox = ($tree ? 'nested[file]' : 'file') . '[file_' . $this->getLastFileId() . '][selected]';
- $remove_edit = array($selected_checkbox => '1');
+ $remove_edit = [$selected_checkbox => '1'];
}
if ($ajax) {
$this->drupalPostAjaxForm(NULL, $remove_edit, $input_base_name . '_remove_button');
@@ -111,8 +111,8 @@ class FileManagedFileElementTest extends FileFieldTestBase {
$this->drupalPostForm(NULL, $remove_edit, $remove_button_title);
}
- $this->drupalPostForm(NULL, array(), t('Save'));
- $this->assertRaw(t('The file ids are %fids.', array('%fids' => '')), 'Submission after file upload and removal was successful.');
+ $this->drupalPostForm(NULL, [], t('Save'));
+ $this->assertRaw(t('The file ids are %fids.', ['%fids' => '']), 'Submission after file upload and removal was successful.');
}
}
}
@@ -120,8 +120,8 @@ class FileManagedFileElementTest extends FileFieldTestBase {
// The multiple file upload has additional conditions that need checking.
$path = 'file/test/1/1/1';
- $edit = array('files[nested_file][]' => drupal_realpath($test_file->getFileUri()));
- $fid_list = array();
+ $edit = ['files[nested_file][]' => drupal_realpath($test_file->getFileUri())];
+ $fid_list = [];
$this->drupalGet($path);
@@ -136,13 +136,13 @@ class FileManagedFileElementTest extends FileFieldTestBase {
$this->assertFieldByXpath('//input[@name="nested[file][file_' . $fid_list[1] . '][selected]"]', NULL, 'Second file successfully uploaded to multiple file element.');
// Save the entire form.
- $this->drupalPostForm(NULL, array(), t('Save'));
- $this->assertRaw(t('The file ids are %fids.', array('%fids' => implode(',', $fid_list))), 'Two files saved into a single multiple file element.');
+ $this->drupalPostForm(NULL, [], t('Save'));
+ $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', $fid_list)]), 'Two files saved into a single multiple file element.');
// Delete only the first file.
- $edit = array(
+ $edit = [
'nested[file][file_' . $fid_list[0] . '][selected]' => '1',
- );
+ ];
$this->drupalPostForm($path . '/' . implode(',', $fid_list), $edit, t('Remove selected'));
// Check that the first file has been deleted but not the second.
@@ -181,7 +181,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
$edit = [$file_field_name => drupal_realpath($test_file->getFileUri())];
$this->drupalPostForm(NULL, $edit, t('Upload'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$fid = $this->getLastFileId();
/** @var $file \Drupal\file\FileInterface */
diff --git a/core/modules/file/src/Tests/FileManagedTestBase.php b/core/modules/file/src/Tests/FileManagedTestBase.php
index 711d8a41f02..8bd85bdc7ab 100644
--- a/core/modules/file/src/Tests/FileManagedTestBase.php
+++ b/core/modules/file/src/Tests/FileManagedTestBase.php
@@ -20,7 +20,7 @@ abstract class FileManagedTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('file_test', 'file');
+ public static $modules = ['file_test', 'file'];
protected function setUp() {
parent::setUp();
@@ -45,16 +45,16 @@ abstract class FileManagedTestBase extends WebTestBase {
// Determine if there were any expected that were not called.
$uncalled = array_diff($expected, $actual);
if (count($uncalled)) {
- $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
+ $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', ['%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)]));
}
else {
- $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected))));
+ $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', ['%expected' => empty($expected) ? '(none)' : implode(', ', $expected)]));
}
// Determine if there were any unexpected calls.
$unexpected = array_diff($actual, $expected);
if (count($unexpected)) {
- $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected))));
+ $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', ['%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected)]));
}
else {
$this->assertTrue(TRUE, 'No unexpected hooks were called.');
@@ -76,13 +76,13 @@ abstract class FileManagedTestBase extends WebTestBase {
if (!isset($message)) {
if ($actual_count == $expected_count) {
- $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook));
+ $message = format_string('hook_file_@name was called correctly.', ['@name' => $hook]);
}
elseif ($expected_count == 0) {
- $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count));
+ $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]);
}
else {
- $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count));
+ $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]);
}
}
$this->assertEqual($actual_count, $expected_count, $message);
@@ -97,13 +97,13 @@ abstract class FileManagedTestBase extends WebTestBase {
* File object to compare.
*/
function assertFileUnchanged(FileInterface $before, FileInterface $after) {
- $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged');
- $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged');
- $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged');
- $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', array('%file1' => $before->getFileUri(), '%file2' => $after->getFileUri())), 'File unchanged');
- $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', array('%file1' => $before->getMimeType(), '%file2' => $after->getMimeType())), 'File unchanged');
- $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', array('%file1' => $before->getSize(), '%file2' => $after->getSize())), 'File unchanged');
- $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', array('%file1' => $before->isPermanent(), '%file2' => $after->isPermanent())), 'File unchanged');
+ $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', ['%file1' => $before->id(), '%file2' => $after->id()]), 'File unchanged');
+ $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', ['%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id()]), 'File unchanged');
+ $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', ['%file1' => $before->getFilename(), '%file2' => $after->getFilename()]), 'File unchanged');
+ $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', ['%file1' => $before->getFileUri(), '%file2' => $after->getFileUri()]), 'File unchanged');
+ $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', ['%file1' => $before->getMimeType(), '%file2' => $after->getMimeType()]), 'File unchanged');
+ $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', ['%file1' => $before->getSize(), '%file2' => $after->getSize()]), 'File unchanged');
+ $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', ['%file1' => $before->isPermanent(), '%file2' => $after->isPermanent()]), 'File unchanged');
}
/**
@@ -115,8 +115,8 @@ abstract class FileManagedTestBase extends WebTestBase {
* File object to compare.
*/
function assertDifferentFile(FileInterface $file1, FileInterface $file2) {
- $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file');
- $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file');
+ $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', ['%file1' => $file1->id(), '%file2' => $file2->id()]), 'Different file');
+ $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()]), 'Different file');
}
/**
@@ -128,8 +128,8 @@ abstract class FileManagedTestBase extends WebTestBase {
* File object to compare.
*/
function assertSameFile(FileInterface $file1, FileInterface $file2) {
- $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file');
- $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file');
+ $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', ['%file1' => $file1->id(), '%file2-fid' => $file2->id()]), 'Same file');
+ $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()]), 'Same file');
}
/**
diff --git a/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php b/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php
index 7987bcf3420..5f1e7073df8 100644
--- a/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php
+++ b/core/modules/file/src/Tests/FileOnTranslatedEntityTest.php
@@ -14,7 +14,7 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language', 'content_translation');
+ public static $modules = ['language', 'content_translation'];
/**
* The name of the file field used in the test.
@@ -39,7 +39,7 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
$this->createFileField($this->fieldName, 'node', 'page');
// Create and log in user.
- $permissions = array(
+ $permissions = [
'access administration pages',
'administer content translation',
'administer content types',
@@ -49,25 +49,25 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
'edit any page content',
'translate any entity',
'delete any page content',
- );
+ ];
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Add a second and third language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'nl';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable translation for "Basic page" nodes.
- $edit = array(
+ $edit = [
'entity_types[node]' => 1,
'settings[node][page][translatable]' => 1,
"settings[node][page][fields][$this->fieldName]" => 1,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
}
@@ -81,20 +81,20 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
$this->assertTrue($definitions[$this->fieldName]->isTranslatable(), 'Node file field is translatable.');
// Create a default language node.
- $default_language_node = $this->drupalCreateNode(array('type' => 'page', 'title' => 'Lost in translation'));
+ $default_language_node = $this->drupalCreateNode(['type' => 'page', 'title' => 'Lost in translation']);
// Edit the node to upload a file.
- $edit = array();
+ $edit = [];
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('text')[0]->uri);
$this->drupalPostForm('node/' . $default_language_node->id() . '/edit', $edit, t('Save'));
$first_fid = $this->getLastFileId();
// Translate the node into French: remove the existing file.
- $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/fr', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/fr', [], t('Remove'));
// Upload a different file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = 'Bill Murray';
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('text')[1]->uri);
@@ -117,10 +117,10 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
$this->assertTrue($file->isPermanent());
// Translate the node into dutch: remove the existing file.
- $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/nl', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/nl', [], t('Remove'));
// Upload a different file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = 'Scarlett Johansson';
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('text')[2]->uri);
@@ -145,10 +145,10 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
$this->assertTrue($file->isPermanent());
// Edit the second translation: remove the existing file.
- $this->drupalPostForm('fr/node/' . $default_language_node->id() . '/edit', array(), t('Remove'));
+ $this->drupalPostForm('fr/node/' . $default_language_node->id() . '/edit', [], t('Remove'));
// Upload a different file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = 'David Bowie';
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('text')[3]->uri);
@@ -169,7 +169,7 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
$this->assertTrue($file->isPermanent());
// Delete the third translation.
- $this->drupalPostForm('nl/node/' . $default_language_node->id() . '/delete', array(), t('Delete Dutch translation'));
+ $this->drupalPostForm('nl/node/' . $default_language_node->id() . '/delete', [], t('Delete Dutch translation'));
\Drupal::entityTypeManager()->getStorage('file')->resetCache();
@@ -185,7 +185,7 @@ class FileOnTranslatedEntityTest extends FileFieldTestBase {
$this->assertTrue($file->isTemporary());
// Delete the all translations.
- $this->drupalPostForm('node/' . $default_language_node->id() . '/delete', array(), t('Delete all translations'));
+ $this->drupalPostForm('node/' . $default_language_node->id() . '/delete', [], t('Delete all translations'));
\Drupal::entityTypeManager()->getStorage('file')->resetCache();
diff --git a/core/modules/file/src/Tests/FilePrivateTest.php b/core/modules/file/src/Tests/FilePrivateTest.php
index 2705ef205b6..9ed4a9e68d5 100644
--- a/core/modules/file/src/Tests/FilePrivateTest.php
+++ b/core/modules/file/src/Tests/FilePrivateTest.php
@@ -19,7 +19,7 @@ class FilePrivateTest extends FileFieldTestBase {
*
* @var array
*/
- public static $modules = array('node_access_test', 'field_test');
+ public static $modules = ['node_access_test', 'field_test'];
protected function setUp() {
parent::setUp();
@@ -35,11 +35,11 @@ class FilePrivateTest extends FileFieldTestBase {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
- $this->createFileField($field_name, 'node', $type_name, array('uri_scheme' => 'private'));
+ $this->createFileField($field_name, 'node', $type_name, ['uri_scheme' => 'private']);
$test_file = $this->getTestFile('text');
- $nid = $this->uploadNodeFile($test_file, $field_name, $type_name, TRUE, array('private' => TRUE));
- \Drupal::entityManager()->getStorage('node')->resetCache(array($nid));
+ $nid = $this->uploadNodeFile($test_file, $field_name, $type_name, TRUE, ['private' => TRUE]);
+ \Drupal::entityManager()->getStorage('node')->resetCache([$nid]);
/* @var \Drupal\node\NodeInterface $node */
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
@@ -56,11 +56,11 @@ class FilePrivateTest extends FileFieldTestBase {
// Create a field with no view access. See
// field_test_entity_field_access().
$no_access_field_name = 'field_no_view_access';
- $this->createFileField($no_access_field_name, 'node', $type_name, array('uri_scheme' => 'private'));
+ $this->createFileField($no_access_field_name, 'node', $type_name, ['uri_scheme' => 'private']);
// Test with the field that should deny access through field access.
$this->drupalLogin($this->adminUser);
- $nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, array('private' => TRUE));
- \Drupal::entityManager()->getStorage('node')->resetCache(array($nid));
+ $nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, ['private' => TRUE]);
+ \Drupal::entityManager()->getStorage('node')->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$no_access_field_name}->target_id);
@@ -70,7 +70,7 @@ class FilePrivateTest extends FileFieldTestBase {
$this->assertResponse(403, 'Confirmed that access is denied for the file without view field access permission.');
// Attempt to reuse the file when editing a node.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
@@ -80,17 +80,17 @@ class FilePrivateTest extends FileFieldTestBase {
$this->assertUrl('node/' . $new_node->id() . '/edit');
// Check that we got the expected constraint form error.
$constraint = new ReferenceAccessConstraint();
- $this->assertRaw(SafeMarkup::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id())));
+ $this->assertRaw(SafeMarkup::format($constraint->message, ['%type' => 'file', '%id' => $node_file->id()]));
// Attempt to reuse the existing file when creating a new node, and confirm
// that access is still denied.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit[$field_name . '[0][fids]'] = $node_file->id();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertTrue(empty($new_node), 'Node was not created.');
$this->assertUrl('node/add/' . $type_name);
- $this->assertRaw(SafeMarkup::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id())));
+ $this->assertRaw(SafeMarkup::format($constraint->message, ['%type' => 'file', '%id' => $node_file->id()]));
// Now make file_test_file_download() return everything.
\Drupal::state()->set('file_test.allow_all', TRUE);
diff --git a/core/modules/file/src/Tests/FileTokenReplaceTest.php b/core/modules/file/src/Tests/FileTokenReplaceTest.php
index dfb9e51d49c..143ded4b603 100644
--- a/core/modules/file/src/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/src/Tests/FileTokenReplaceTest.php
@@ -35,12 +35,12 @@ class FileTokenReplaceTest extends FileFieldTestBase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Load the node and the file.
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$file = File::load($node->{$field_name}->target_id);
// Generate and test sanitized tokens.
- $tests = array();
+ $tests = [];
$tests['[file:fid]'] = $file->id();
$tests['[file:name]'] = Html::escape($file->getFilename());
$tests['[file:path]'] = Html::escape($file->getFileUri());
@@ -77,8 +77,8 @@ class FileTokenReplaceTest extends FileFieldTestBase {
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId()), $bubbleable_metadata);
- $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input)));
+ $output = $token_service->replace($input, ['file' => $file], ['langcode' => $language_interface->getId()], $bubbleable_metadata);
+ $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
@@ -89,8 +89,8 @@ class FileTokenReplaceTest extends FileFieldTestBase {
$tests['[file:size]'] = format_size($file->getSize());
foreach ($tests as $input => $expected) {
- $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
- $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input)));
+ $output = $token_service->replace($input, ['file' => $file], ['langcode' => $language_interface->getId(), 'sanitize' => FALSE]);
+ $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', ['%token' => $input]));
}
}
diff --git a/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php b/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php
index 15039edcbd7..da5abb5bd73 100644
--- a/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php
+++ b/core/modules/file/src/Tests/PrivateFileOnTranslatedEntityTest.php
@@ -15,7 +15,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language', 'content_translation');
+ public static $modules = ['language', 'content_translation'];
/**
* The name of the file field used in the test.
@@ -31,14 +31,14 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
parent::setUp();
// Create the "Basic page" node type.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create a file field on the "Basic page" node type.
$this->fieldName = strtolower($this->randomMachineName());
- $this->createFileField($this->fieldName, 'node', 'page', array('uri_scheme' => 'private'));
+ $this->createFileField($this->fieldName, 'node', 'page', ['uri_scheme' => 'private']);
// Create and log in user.
- $permissions = array(
+ $permissions = [
'access administration pages',
'administer content translation',
'administer content types',
@@ -47,21 +47,21 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
'create page content',
'edit any page content',
'translate any entity',
- );
+ ];
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Add a second language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable translation for "Basic page" nodes.
- $edit = array(
+ $edit = [
'entity_types[node]' => 1,
'settings[node][page][translatable]' => 1,
"settings[node][page][fields][$this->fieldName]" => 1,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
}
@@ -75,10 +75,10 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
$this->assertTrue($definitions[$this->fieldName]->isTranslatable(), 'Node file field is translatable.');
// Create a default language node.
- $default_language_node = $this->drupalCreateNode(array('type' => 'page'));
+ $default_language_node = $this->drupalCreateNode(['type' => 'page']);
// Edit the node to upload a file.
- $edit = array();
+ $edit = [];
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('text')[0]->uri);
$this->drupalPostForm('node/' . $default_language_node->id() . '/edit', $edit, t('Save'));
@@ -88,7 +88,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
$this->rebuildContainer();
// Ensure the file can be downloaded.
- \Drupal::entityManager()->getStorage('node')->resetCache(array($default_language_node->id()));
+ \Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]);
$node = Node::load($default_language_node->id());
$node_file = File::load($node->{$this->fieldName}->target_id);
$this->drupalGet(file_create_url($node_file->getFileUri()));
@@ -99,10 +99,10 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
$this->clickLink(t('Add'));
// Remove the existing file.
- $this->drupalPostForm(NULL, array(), t('Remove'));
+ $this->drupalPostForm(NULL, [], t('Remove'));
// Upload a different file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('text')[1]->uri);
@@ -110,7 +110,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
$last_fid = $this->getLastFileId();
// Verify the translation was created.
- \Drupal::entityManager()->getStorage('node')->resetCache(array($default_language_node->id()));
+ \Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]);
$default_language_node = Node::load($default_language_node->id());
$this->assertTrue($default_language_node->hasTranslation('fr'), 'Node found in database.');
$this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.');
diff --git a/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php b/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php
index b1ee6a65de1..d468ed326f5 100644
--- a/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php
+++ b/core/modules/file/src/Tests/RemoteFileSaveUploadTest.php
@@ -14,7 +14,7 @@ class RemoteFileSaveUploadTest extends SaveUploadTest {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
protected function setUp() {
parent::setUp();
diff --git a/core/modules/file/src/Tests/SaveUploadTest.php b/core/modules/file/src/Tests/SaveUploadTest.php
index 3aaa5cff049..14071737f0b 100644
--- a/core/modules/file/src/Tests/SaveUploadTest.php
+++ b/core/modules/file/src/Tests/SaveUploadTest.php
@@ -15,7 +15,7 @@ class SaveUploadTest extends FileManagedTestBase {
*
* @var array
*/
- public static $modules = array('dblog');
+ public static $modules = ['dblog'];
/**
* An image file path for uploading.
@@ -43,7 +43,7 @@ class SaveUploadTest extends FileManagedTestBase {
protected function setUp() {
parent::setUp();
- $account = $this->drupalCreateUser(array('access site reports'));
+ $account = $this->drupalCreateUser(['access site reports']);
$this->drupalLogin($account);
$image_files = $this->drupalGetTestFiles('image');
@@ -58,17 +58,17 @@ class SaveUploadTest extends FileManagedTestBase {
$this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField();
// Upload with replace to guarantee there's something there.
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_REPLACE,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()),
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called then clean out the hook
// counters.
- $this->assertFileHooksCalled(array('validate', 'insert'));
+ $this->assertFileHooksCalled(['validate', 'insert']);
file_test_reset();
}
@@ -88,14 +88,14 @@ class SaveUploadTest extends FileManagedTestBase {
// Upload a second file.
$image2 = current($this->drupalGetTestFiles('image'));
- $edit = array('files[file_test_upload]' => drupal_realpath($image2->uri));
+ $edit = ['files[file_test_upload]' => drupal_realpath($image2->uri)];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'));
$max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField();
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'insert'));
+ $this->assertFileHooksCalled(['validate', 'insert']);
$file2 = File::load($max_fid_after);
$this->assertTrue($file2, 'Loaded the file');
@@ -103,7 +103,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->assertEqual(substr($file2->getMimeType(), 0, 5), 'image', 'A MIME type was set.');
// Load both files using File::loadMultiple().
- $files = File::loadMultiple(array($file1->id(), $file2->id()));
+ $files = File::loadMultiple([$file1->id(), $file2->id()]);
$this->assertTrue(isset($files[$file1->id()]), 'File was loaded successfully');
$this->assertTrue(isset($files[$file2->id()]), 'File was loaded successfully');
@@ -111,10 +111,10 @@ class SaveUploadTest extends FileManagedTestBase {
$image3 = current($this->drupalGetTestFiles('image'));
$image3_realpath = drupal_realpath($image3->uri);
$dir = $this->randomMachineName();
- $edit = array(
+ $edit = [
'files[file_test_upload]' => $image3_realpath,
'file_subdir' => $dir,
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'));
@@ -130,11 +130,11 @@ class SaveUploadTest extends FileManagedTestBase {
// implicitly tested at the testNormal() test. Here we tell
// file_save_upload() to only allow ".foo".
$extensions = 'foo';
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_REPLACE,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()),
'extensions' => $extensions,
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
@@ -143,18 +143,18 @@ class SaveUploadTest extends FileManagedTestBase {
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate'));
+ $this->assertFileHooksCalled(['validate']);
// Reset the hook counters.
file_test_reset();
$extensions = 'foo ' . $this->imageExtension;
// Now tell file_save_upload() to allow the extension of our test image.
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_REPLACE,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()),
'extensions' => $extensions,
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
@@ -162,24 +162,24 @@ class SaveUploadTest extends FileManagedTestBase {
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'load', 'update'));
+ $this->assertFileHooksCalled(['validate', 'load', 'update']);
// Reset the hook counters.
file_test_reset();
// Now tell file_save_upload() to allow any extension.
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_REPLACE,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()),
'allow_all_extensions' => TRUE,
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'load', 'update'));
+ $this->assertFileHooksCalled(['validate', 'load', 'update']);
}
/**
@@ -189,12 +189,12 @@ class SaveUploadTest extends FileManagedTestBase {
$config = $this->config('system.file');
// Allow the .php extension and make sure it gets renamed to .txt for
// safety. Also check to make sure its MIME type was changed.
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_REPLACE,
'files[file_test_upload]' => drupal_realpath($this->phpfile->uri),
'is_image_file' => FALSE,
'extensions' => 'php',
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
@@ -204,7 +204,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'insert'));
+ $this->assertFileHooksCalled(['validate', 'insert']);
// Ensure dangerous files are not renamed when insecure uploads is TRUE.
// Turn on insecure uploads.
@@ -215,11 +215,11 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
- $this->assertRaw(t('File name is @filename', array('@filename' => $this->phpfile->filename)), 'Dangerous file was not renamed when insecure uploads is TRUE.');
+ $this->assertRaw(t('File name is @filename', ['@filename' => $this->phpfile->filename]), 'Dangerous file was not renamed when insecure uploads is TRUE.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'insert'));
+ $this->assertFileHooksCalled(['validate', 'insert']);
// Turn off insecure uploads.
$config->set('allow_insecure_uploads', 0)->save();
@@ -237,10 +237,10 @@ class SaveUploadTest extends FileManagedTestBase {
file_test_reset();
$extensions = $this->imageExtension;
- $edit = array(
+ $edit = [
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()),
'extensions' => $extensions,
- );
+ ];
$munged_filename = $this->image->getFilename();
$munged_filename = substr($munged_filename, 0, strrpos($munged_filename, '.'));
@@ -249,84 +249,84 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
- $this->assertRaw(t('File name is @filename', array('@filename' => $munged_filename)), 'File was successfully munged.');
+ $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'insert'));
+ $this->assertFileHooksCalled(['validate', 'insert']);
// Ensure we don't munge files if we're allowing any extension.
// Reset the hook counters.
file_test_reset();
- $edit = array(
+ $edit = [
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri()),
'allow_all_extensions' => TRUE,
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
- $this->assertRaw(t('File name is @filename', array('@filename' => $this->image->getFilename())), 'File was not munged when allowing any extension.');
+ $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'insert'));
+ $this->assertFileHooksCalled(['validate', 'insert']);
}
/**
* Test renaming when uploading over a file that already exists.
*/
function testExistingRename() {
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_RENAME,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri())
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'insert'));
+ $this->assertFileHooksCalled(['validate', 'insert']);
}
/**
* Test replacement when uploading over a file that already exists.
*/
function testExistingReplace() {
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_REPLACE,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri())
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('validate', 'load', 'update'));
+ $this->assertFileHooksCalled(['validate', 'load', 'update']);
}
/**
* Test for failure when uploading over a file that already exists.
*/
function testExistingError() {
- $edit = array(
+ $edit = [
'file_test_replace' => FILE_EXISTS_ERROR,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri())
- );
+ ];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
// Check that the no hooks were called while failing.
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
}
/**
* Test for no failures when not uploading a file.
*/
function testNoUpload() {
- $this->drupalPostForm('file-test/upload', array(), t('Submit'));
+ $this->drupalPostForm('file-test/upload', [], t('Submit'));
$this->assertNoRaw(t('Epic upload FAIL!'), 'Failure message not found.');
}
@@ -339,10 +339,10 @@ class SaveUploadTest extends FileManagedTestBase {
drupal_mkdir('temporary://' . $test_directory, 0000);
$this->assertTrue(is_dir('temporary://' . $test_directory));
- $edit = array(
+ $edit = [
'file_subdir' => $test_directory,
'files[file_test_upload]' => drupal_realpath($this->image->getFileUri())
- );
+ ];
\Drupal::state()->set('file_test.disable_error_collection', TRUE);
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
@@ -353,10 +353,10 @@ class SaveUploadTest extends FileManagedTestBase {
// Uploading failed. Now check the log.
$this->drupalGet('admin/reports/dblog');
$this->assertResponse(200);
- $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', array(
+ $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [
'@file' => $this->image->getFilename(),
'@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename()
- )), 'Found upload error log entry.');
+ ]), 'Found upload error log entry.');
}
}
diff --git a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
index db49ae1e1dd..6a5f53b5d36 100644
--- a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
+++ b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
@@ -21,25 +21,25 @@ class RelationshipUserFileDataTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('file', 'file_test_views', 'user');
+ public static $modules = ['file', 'file_test_views', 'user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_file_user_file_data');
+ public static $testViews = ['test_file_user_file_data'];
protected function setUp() {
parent::setUp();
// Create the user profile field and instance.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'user',
'field_name' => 'user_file',
'type' => 'file',
'translatable' => '0',
- ))->save();
+ ])->save();
FieldConfig::create([
'label' => 'User File',
'description' => '',
@@ -49,7 +49,7 @@ class RelationshipUserFileDataTest extends ViewTestBase {
'required' => 0,
])->save();
- ViewTestData::createTestViews(get_class($this), array('file_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['file_test_views']);
}
/**
@@ -84,12 +84,12 @@ class RelationshipUserFileDataTest extends ViewTestBase {
];
$this->assertIdentical($expected, $view->getDependencies());
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'file_managed_user__user_file_fid' => '2',
- ),
- );
- $column_map = array('file_managed_user__user_file_fid' => 'file_managed_user__user_file_fid');
+ ],
+ ];
+ $column_map = ['file_managed_user__user_file_fid' => 'file_managed_user__user_file_fid'];
$this->assertIdenticalResultset($view, $expected_result, $column_map);
}
diff --git a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php
index 760a4f4fd4e..9dc9d3595e6 100644
--- a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php
+++ b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php
@@ -36,7 +36,7 @@ class FileModuleTestForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state, $tree = TRUE, $extended = TRUE, $multiple = FALSE, $default_fids = NULL) {
$form['#tree'] = (bool) $tree;
- $form['nested']['file'] = array(
+ $form['nested']['file'] = [
'#type' => 'managed_file',
'#title' => $this->t('Managed <em>@type</em>', ['@type' => 'file & butter']),
'#upload_location' => 'public://test',
@@ -44,21 +44,21 @@ class FileModuleTestForm extends FormBase {
'#extended' => (bool) $extended,
'#size' => 13,
'#multiple' => (bool) $multiple,
- );
+ ];
if ($default_fids) {
$default_fids = explode(',', $default_fids);
- $form['nested']['file']['#default_value'] = $extended ? array('fids' => $default_fids) : $default_fids;
+ $form['nested']['file']['#default_value'] = $extended ? ['fids' => $default_fids] : $default_fids;
}
- $form['textfield'] = array(
+ $form['textfield'] = [
'#type' => 'textfield',
'#title' => $this->t('Type a value and ensure it stays'),
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
- );
+ ];
return $form;
}
@@ -68,7 +68,7 @@ class FileModuleTestForm extends FormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form['#tree']) {
- $uploads = $form_state->getValue(array('nested', 'file'));
+ $uploads = $form_state->getValue(['nested', 'file']);
}
else {
$uploads = $form_state->getValue('file');
@@ -78,12 +78,12 @@ class FileModuleTestForm extends FormBase {
$uploads = $uploads['fids'];
}
- $fids = array();
+ $fids = [];
foreach ($uploads as $fid) {
$fids[] = $fid;
}
- drupal_set_message($this->t('The file ids are %fids.', array('%fids' => implode(',', $fids))));
+ drupal_set_message($this->t('The file ids are %fids.', ['%fids' => implode(',', $fids)]));
}
}
diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module
index 4a6fbcbdbaf..0baa0cbd084 100644
--- a/core/modules/file/tests/file_test/file_test.module
+++ b/core/modules/file/tests/file_test/file_test.module
@@ -21,23 +21,23 @@ const FILE_URL_TEST_CDN_2 = 'http://cdn2.example.com';
*/
function file_test_reset() {
// Keep track of calls to these hooks
- $results = array(
- 'load' => array(),
- 'validate' => array(),
- 'download' => array(),
- 'insert' => array(),
- 'update' => array(),
- 'copy' => array(),
- 'move' => array(),
- 'delete' => array(),
- );
+ $results = [
+ 'load' => [],
+ 'validate' => [],
+ 'download' => [],
+ 'insert' => [],
+ 'update' => [],
+ 'copy' => [],
+ 'move' => [],
+ 'delete' => [],
+ ];
\Drupal::state()->set('file_test.results', $results);
// These hooks will return these values, see file_test_set_return().
- $return = array(
- 'validate' => array(),
+ $return = [
+ 'validate' => [],
'download' => NULL,
- );
+ ];
\Drupal::state()->set('file_test.return', $return);
}
@@ -56,7 +56,7 @@ function file_test_reset() {
* @see file_test_reset()
*/
function file_test_get_calls($op) {
- $results = \Drupal::state()->get('file_test.results') ?: array();
+ $results = \Drupal::state()->get('file_test.results') ?: [];
return $results[$op];
}
@@ -69,7 +69,7 @@ function file_test_get_calls($op) {
* passed to each call.
*/
function file_test_get_all_calls() {
- return \Drupal::state()->get('file_test.results') ?: array();
+ return \Drupal::state()->get('file_test.results') ?: [];
}
/**
@@ -86,7 +86,7 @@ function file_test_get_all_calls() {
*/
function _file_test_log_call($op, $args) {
if (\Drupal::state()->get('file_test.count_hook_invocations', TRUE)) {
- $results = \Drupal::state()->get('file_test.results') ?: array();
+ $results = \Drupal::state()->get('file_test.results') ?: [];
$results[$op][] = $args;
\Drupal::state()->set('file_test.results', $results);
}
@@ -105,7 +105,7 @@ function _file_test_log_call($op, $args) {
* @see file_test_reset()
*/
function _file_test_get_return($op) {
- $return = \Drupal::state()->get('file_test.return') ?: array($op => NULL);
+ $return = \Drupal::state()->get('file_test.return') ?: [$op => NULL];
return $return[$op];
}
@@ -121,7 +121,7 @@ function _file_test_get_return($op) {
* @see file_test_reset()
*/
function file_test_set_return($op, $value) {
- $return = \Drupal::state()->get('file_test.return') ?: array();
+ $return = \Drupal::state()->get('file_test.return') ?: [];
$return[$op] = $value;
\Drupal::state()->set('file_test.return', $return);
}
@@ -131,7 +131,7 @@ function file_test_set_return($op, $value) {
*/
function file_test_file_load($files) {
foreach ($files as $file) {
- _file_test_log_call('load', array($file->id()));
+ _file_test_log_call('load', [$file->id()]);
// Assign a value on the object so that we can test that the $file is passed
// by reference.
$file->file_test['loaded'] = TRUE;
@@ -142,7 +142,7 @@ function file_test_file_load($files) {
* Implements hook_file_validate().
*/
function file_test_file_validate(File $file) {
- _file_test_log_call('validate', array($file->id()));
+ _file_test_log_call('validate', [$file->id()]);
return _file_test_get_return('validate');
}
@@ -151,11 +151,11 @@ function file_test_file_validate(File $file) {
*/
function file_test_file_download($uri) {
if (\Drupal::state()->get('file_test.allow_all', FALSE)) {
- $files = entity_load_multiple_by_properties('file', array('uri' => $uri));
+ $files = entity_load_multiple_by_properties('file', ['uri' => $uri]);
$file = reset($files);
return file_get_content_headers($file);
}
- _file_test_log_call('download', array($uri));
+ _file_test_log_call('download', [$uri]);
return _file_test_get_return('download');
}
@@ -163,35 +163,35 @@ function file_test_file_download($uri) {
* Implements hook_ENTITY_TYPE_insert() for file entities.
*/
function file_test_file_insert(File $file) {
- _file_test_log_call('insert', array($file->id()));
+ _file_test_log_call('insert', [$file->id()]);
}
/**
* Implements hook_ENTITY_TYPE_update() for file entities.
*/
function file_test_file_update(File $file) {
- _file_test_log_call('update', array($file->id()));
+ _file_test_log_call('update', [$file->id()]);
}
/**
* Implements hook_file_copy().
*/
function file_test_file_copy(File $file, $source) {
- _file_test_log_call('copy', array($file->id(), $source->id()));
+ _file_test_log_call('copy', [$file->id(), $source->id()]);
}
/**
* Implements hook_file_move().
*/
function file_test_file_move(File $file, File $source) {
- _file_test_log_call('move', array($file->id(), $source->id()));
+ _file_test_log_call('move', [$file->id(), $source->id()]);
}
/**
* Implements hook_ENTITY_TYPE_predelete() for file entities.
*/
function file_test_file_predelete(File $file) {
- _file_test_log_call('delete', array($file->id()));
+ _file_test_log_call('delete', [$file->id()]);
}
/**
@@ -206,11 +206,11 @@ function file_test_file_url_alter(&$uri) {
}
// Test alteration of file URLs to use a CDN.
elseif ($alter_mode == 'cdn') {
- $cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png');
+ $cdn_extensions = ['css', 'js', 'gif', 'jpg', 'jpeg', 'png'];
// Most CDNs don't support private file transfers without a lot of hassle,
// so don't support this in the common case.
- $schemes = array('public');
+ $schemes = ['public'];
$scheme = file_uri_scheme($uri);
@@ -323,7 +323,7 @@ function file_test_validator(File $file, $errors) {
* If $filepath is NULL, an array of all previous $filepath parameters
*/
function file_test_file_scan_callback($filepath = NULL) {
- $files = &drupal_static(__FUNCTION__, array());
+ $files = &drupal_static(__FUNCTION__, []);
if (isset($filepath)) {
$files[] = $filepath;
}
diff --git a/core/modules/file/tests/file_test/src/Form/FileTestForm.php b/core/modules/file/tests/file_test/src/Form/FileTestForm.php
index 628bb55dba0..f43e20a8e90 100644
--- a/core/modules/file/tests/file_test/src/Form/FileTestForm.php
+++ b/core/modules/file/tests/file_test/src/Form/FileTestForm.php
@@ -21,48 +21,48 @@ class FileTestForm implements FormInterface {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['file_test_upload'] = array(
+ $form['file_test_upload'] = [
'#type' => 'file',
'#title' => t('Upload a file'),
- );
- $form['file_test_replace'] = array(
+ ];
+ $form['file_test_replace'] = [
'#type' => 'select',
'#title' => t('Replace existing image'),
- '#options' => array(
+ '#options' => [
FILE_EXISTS_RENAME => t('Appends number until name is unique'),
FILE_EXISTS_REPLACE => t('Replace the existing file'),
FILE_EXISTS_ERROR => t('Fail with an error'),
- ),
+ ],
'#default_value' => FILE_EXISTS_RENAME,
- );
- $form['file_subdir'] = array(
+ ];
+ $form['file_subdir'] = [
'#type' => 'textfield',
'#title' => t('Subdirectory for test file'),
'#default_value' => '',
- );
+ ];
- $form['extensions'] = array(
+ $form['extensions'] = [
'#type' => 'textfield',
'#title' => t('Allowed extensions.'),
'#default_value' => '',
- );
+ ];
- $form['allow_all_extensions'] = array(
+ $form['allow_all_extensions'] = [
'#type' => 'checkbox',
'#title' => t('Allow all extensions?'),
'#default_value' => FALSE,
- );
+ ];
- $form['is_image_file'] = array(
+ $form['is_image_file'] = [
'#type' => 'checkbox',
'#title' => t('Is this an image file?'),
'#default_value' => TRUE,
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
@@ -86,16 +86,16 @@ class FileTestForm implements FormInterface {
}
// Setup validators.
- $validators = array();
+ $validators = [];
if ($form_state->getValue('is_image_file')) {
- $validators['file_validate_is_image'] = array();
+ $validators['file_validate_is_image'] = [];
}
if ($form_state->getValue('allow_all_extensions')) {
- $validators['file_validate_extensions'] = array();
+ $validators['file_validate_extensions'] = [];
}
elseif (!$form_state->isValueEmpty('extensions')) {
- $validators['file_validate_extensions'] = array($form_state->getValue('extensions'));
+ $validators['file_validate_extensions'] = [$form_state->getValue('extensions')];
}
// The test for drupal_move_uploaded_file() triggering a warning is
@@ -108,9 +108,9 @@ class FileTestForm implements FormInterface {
$file = file_save_upload('file_test_upload', $validators, $destination, 0, $form_state->getValue('file_test_replace'));
if ($file) {
$form_state->setValue('file_test_upload', $file);
- drupal_set_message(t('File @filepath was uploaded.', array('@filepath' => $file->getFileUri())));
- drupal_set_message(t('File name is @filename.', array('@filename' => $file->getFilename())));
- drupal_set_message(t('File MIME type is @mimetype.', array('@mimetype' => $file->getMimeType())));
+ drupal_set_message(t('File @filepath was uploaded.', ['@filepath' => $file->getFileUri()]));
+ drupal_set_message(t('File name is @filename.', ['@filename' => $file->getFilename()]));
+ drupal_set_message(t('File MIME type is @mimetype.', ['@mimetype' => $file->getMimeType()]));
drupal_set_message(t('You WIN!'));
}
elseif ($file === FALSE) {
diff --git a/core/modules/file/tests/src/Functional/FileFieldTestBase.php b/core/modules/file/tests/src/Functional/FileFieldTestBase.php
index 9cc981bd46f..af3747bcc50 100644
--- a/core/modules/file/tests/src/Functional/FileFieldTestBase.php
+++ b/core/modules/file/tests/src/Functional/FileFieldTestBase.php
@@ -18,7 +18,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'file', 'file_module_test', 'field_ui');
+ public static $modules = ['node', 'file', 'file_module_test', 'field_ui'];
/**
* An user with administration permissions.
@@ -29,9 +29,9 @@ abstract class FileFieldTestBase extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer node fields', 'administer node display', 'administer nodes', 'bypass node access'));
+ $this->adminUser = $this->drupalCreateUser(['access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer node fields', 'administer node display', 'administer nodes', 'bypass node access']);
$this->drupalLogin($this->adminUser);
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
/**
@@ -73,14 +73,14 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* @param array $widget_settings
* A list of widget settings that will be added to the widget defaults.
*/
- function createFileField($name, $entity_type, $bundle, $storage_settings = array(), $field_settings = array(), $widget_settings = array()) {
- $field_storage = FieldStorageConfig::create(array(
+ function createFileField($name, $entity_type, $bundle, $storage_settings = [], $field_settings = [], $widget_settings = []) {
+ $field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $name,
'type' => 'file',
'settings' => $storage_settings,
'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1,
- ));
+ ]);
$field_storage->save();
$this->attachFileField($name, $entity_type, $bundle, $field_settings, $widget_settings);
@@ -101,44 +101,44 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* @param array $widget_settings
* A list of widget settings that will be added to the widget defaults.
*/
- function attachFileField($name, $entity_type, $bundle, $field_settings = array(), $widget_settings = array()) {
- $field = array(
+ function attachFileField($name, $entity_type, $bundle, $field_settings = [], $widget_settings = []) {
+ $field = [
'field_name' => $name,
'label' => $name,
'entity_type' => $entity_type,
'bundle' => $bundle,
'required' => !empty($field_settings['required']),
'settings' => $field_settings,
- );
+ ];
FieldConfig::create($field)->save();
entity_get_form_display($entity_type, $bundle, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'file_generic',
'settings' => $widget_settings,
- ))
+ ])
->save();
// Assign display settings.
entity_get_display($entity_type, $bundle, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'label' => 'hidden',
'type' => 'file_default',
- ))
+ ])
->save();
}
/**
* Updates an existing file field with new settings.
*/
- function updateFileField($name, $type_name, $field_settings = array(), $widget_settings = array()) {
+ function updateFileField($name, $type_name, $field_settings = [], $widget_settings = []) {
$field = FieldConfig::loadByName('node', $type_name, $name);
$field->setSettings(array_merge($field->getSettings(), $field_settings));
$field->save();
entity_get_form_display('node', $type_name, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'settings' => $widget_settings,
- ))
+ ])
->save();
}
@@ -160,7 +160,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* @return int
* The node id.
*/
- function uploadNodeFile(FileInterface $file, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = array()) {
+ function uploadNodeFile(FileInterface $file, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = []) {
return $this->uploadNodeFiles([$file], $field_name, $nid_or_type, $new_revision, $extras);
}
@@ -182,16 +182,16 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* @return int
* The node id.
*/
- function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = array()) {
- $edit = array(
+ function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = []) {
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
'revision' => (string) (int) $new_revision,
- );
+ ];
$node_storage = $this->container->get('entity.manager')->getStorage('node');
if (is_numeric($nid_or_type)) {
$nid = $nid_or_type;
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
}
else {
@@ -202,7 +202,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
// Save at least one revision to better simulate a real site.
$node->setNewRevision();
$node->save();
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$this->assertNotEqual($nid, $node->getRevisionId(), 'Node revision exists.');
}
@@ -235,11 +235,11 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* Note that if replacing a file, it must first be removed then added again.
*/
function removeNodeFile($nid, $new_revision = TRUE) {
- $edit = array(
+ $edit = [
'revision' => (string) (int) $new_revision,
- );
+ ];
- $this->drupalPostForm('node/' . $nid . '/edit', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $nid . '/edit', [], t('Remove'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
}
@@ -247,12 +247,12 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* Replaces a file within a node.
*/
function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) {
- $edit = array(
+ $edit = [
'files[' . $field_name . '_0]' => drupal_realpath($file->getFileUri()),
'revision' => (string) (int) $new_revision,
- );
+ ];
- $this->drupalPostForm('node/' . $nid . '/edit', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $nid . '/edit', [], t('Remove'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
}
@@ -268,7 +268,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* (optional) A message to display with the assertion.
*/
public static function assertFileExists($file, $message = NULL) {
- $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists on the disk.', ['%file' => $file->getFileUri()]);
$filename = $file instanceof FileInterface ? $file->getFileUri() : $file;
parent::assertFileExists($filename, $message);
}
@@ -279,7 +279,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
function assertFileEntryExists($file, $message = NULL) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
$db_file = File::load($file->id());
- $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message);
}
@@ -295,7 +295,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* (optional) A message to display with the assertion.
*/
public static function assertFileNotExists($file, $message = NULL) {
- $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists on the disk.', ['%file' => $file->getFileUri()]);
$filename = $file instanceof FileInterface ? $file->getFileUri() : $file;
parent::assertFileNotExists($filename, $message);
}
@@ -305,7 +305,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
*/
function assertFileEntryNotExists($file, $message) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
- $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertFalse(File::load($file->id()), $message);
}
@@ -313,7 +313,7 @@ abstract class FileFieldTestBase extends BrowserTestBase {
* Asserts that a file's status is set to permanent in the database.
*/
function assertFileIsPermanent(FileInterface $file, $message = NULL) {
- $message = isset($message) ? $message : format_string('File %file is permanent.', array('%file' => $file->getFileUri()));
+ $message = isset($message) ? $message : format_string('File %file is permanent.', ['%file' => $file->getFileUri()]);
$this->assertTrue($file->isPermanent(), $message);
}
diff --git a/core/modules/file/tests/src/Functional/FileManagedAccessTest.php b/core/modules/file/tests/src/Functional/FileManagedAccessTest.php
index 97f77b6837c..fc6d85cb36c 100644
--- a/core/modules/file/tests/src/Functional/FileManagedAccessTest.php
+++ b/core/modules/file/tests/src/Functional/FileManagedAccessTest.php
@@ -16,20 +16,20 @@ class FileManagedAccessTest extends FileManagedTestBase {
*/
function testFileAccess() {
// Create a new file entity.
- $file = File::create(array(
+ $file = File::create([
'uid' => 1,
'filename' => 'drupal.txt',
'uri' => 'public://drupal.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
file_put_contents($file->getFileUri(), 'hello world');
// Save it, inserting a new record.
$file->save();
// Create authenticated user to check file access.
- $account = $this->createUser(array('access site reports'));
+ $account = $this->createUser(['access site reports']);
$this->assertTrue($file->access('view', $account), 'Public file is viewable to authenticated user');
$this->assertTrue($file->access('download', $account), 'Public file is downloadable to authenticated user');
@@ -41,20 +41,20 @@ class FileManagedAccessTest extends FileManagedTestBase {
$this->assertTrue($file->access('download', $account), 'Public file is downloadable to anonymous user');
// Create a new file entity.
- $file = File::create(array(
+ $file = File::create([
'uid' => 1,
'filename' => 'drupal.txt',
'uri' => 'private://drupal.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
file_put_contents($file->getFileUri(), 'hello world');
// Save it, inserting a new record.
$file->save();
// Create authenticated user to check file access.
- $account = $this->createUser(array('access site reports'));
+ $account = $this->createUser(['access site reports']);
$this->assertFalse($file->access('view', $account), 'Private file is not viewable to authenticated user');
$this->assertFalse($file->access('download', $account), 'Private file is not downloadable to authenticated user');
diff --git a/core/modules/file/tests/src/Functional/FileManagedTestBase.php b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
index 6bd57dd39c6..0adbe2c36b4 100644
--- a/core/modules/file/tests/src/Functional/FileManagedTestBase.php
+++ b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
@@ -17,7 +17,7 @@ abstract class FileManagedTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('file_test', 'file');
+ public static $modules = ['file_test', 'file'];
protected function setUp() {
parent::setUp();
@@ -42,16 +42,16 @@ abstract class FileManagedTestBase extends BrowserTestBase {
// Determine if there were any expected that were not called.
$uncalled = array_diff($expected, $actual);
if (count($uncalled)) {
- $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
+ $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', ['%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)]));
}
else {
- $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected))));
+ $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', ['%expected' => empty($expected) ? '(none)' : implode(', ', $expected)]));
}
// Determine if there were any unexpected calls.
$unexpected = array_diff($actual, $expected);
if (count($unexpected)) {
- $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected))));
+ $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', ['%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected)]));
}
else {
$this->assertTrue(TRUE, 'No unexpected hooks were called.');
@@ -73,13 +73,13 @@ abstract class FileManagedTestBase extends BrowserTestBase {
if (!isset($message)) {
if ($actual_count == $expected_count) {
- $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook));
+ $message = format_string('hook_file_@name was called correctly.', ['@name' => $hook]);
}
elseif ($expected_count == 0) {
- $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count));
+ $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]);
}
else {
- $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count));
+ $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]);
}
}
$this->assertEqual($actual_count, $expected_count, $message);
@@ -94,13 +94,13 @@ abstract class FileManagedTestBase extends BrowserTestBase {
* File object to compare.
*/
function assertFileUnchanged(FileInterface $before, FileInterface $after) {
- $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged');
- $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged');
- $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged');
- $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', array('%file1' => $before->getFileUri(), '%file2' => $after->getFileUri())), 'File unchanged');
- $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', array('%file1' => $before->getMimeType(), '%file2' => $after->getMimeType())), 'File unchanged');
- $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', array('%file1' => $before->getSize(), '%file2' => $after->getSize())), 'File unchanged');
- $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', array('%file1' => $before->isPermanent(), '%file2' => $after->isPermanent())), 'File unchanged');
+ $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', ['%file1' => $before->id(), '%file2' => $after->id()]), 'File unchanged');
+ $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', ['%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id()]), 'File unchanged');
+ $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', ['%file1' => $before->getFilename(), '%file2' => $after->getFilename()]), 'File unchanged');
+ $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', ['%file1' => $before->getFileUri(), '%file2' => $after->getFileUri()]), 'File unchanged');
+ $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', ['%file1' => $before->getMimeType(), '%file2' => $after->getMimeType()]), 'File unchanged');
+ $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', ['%file1' => $before->getSize(), '%file2' => $after->getSize()]), 'File unchanged');
+ $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', ['%file1' => $before->isPermanent(), '%file2' => $after->isPermanent()]), 'File unchanged');
}
/**
@@ -112,8 +112,8 @@ abstract class FileManagedTestBase extends BrowserTestBase {
* File object to compare.
*/
function assertDifferentFile(FileInterface $file1, FileInterface $file2) {
- $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file');
- $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file');
+ $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', ['%file1' => $file1->id(), '%file2' => $file2->id()]), 'Different file');
+ $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()]), 'Different file');
}
/**
@@ -125,8 +125,8 @@ abstract class FileManagedTestBase extends BrowserTestBase {
* File object to compare.
*/
function assertSameFile(FileInterface $file1, FileInterface $file2) {
- $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file');
- $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file');
+ $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', ['%file1' => $file1->id(), '%file2-fid' => $file2->id()]), 'Same file');
+ $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()]), 'Same file');
}
/**
diff --git a/core/modules/file/tests/src/Kernel/AccessTest.php b/core/modules/file/tests/src/Kernel/AccessTest.php
index c2fa65bacb0..c71d7e80e75 100644
--- a/core/modules/file/tests/src/Kernel/AccessTest.php
+++ b/core/modules/file/tests/src/Kernel/AccessTest.php
@@ -49,7 +49,7 @@ class AccessTest extends KernelTestBase {
$this->installEntitySchema('file');
$this->installEntitySchema('user');
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('file', ['file_usage']);
$this->installSchema('system', 'sequences');
$this->user1 = User::create([
@@ -64,11 +64,11 @@ class AccessTest extends KernelTestBase {
]);
$this->user2->save();
- $this->file = File::create(array(
+ $this->file = File::create([
'uid' => $this->user1->id(),
'filename' => 'druplicon.txt',
'filemime' => 'text/plain',
- ));
+ ]);
}
/**
diff --git a/core/modules/file/tests/src/Kernel/CopyTest.php b/core/modules/file/tests/src/Kernel/CopyTest.php
index 8836bd48420..4c8d41fbec4 100644
--- a/core/modules/file/tests/src/Kernel/CopyTest.php
+++ b/core/modules/file/tests/src/Kernel/CopyTest.php
@@ -27,7 +27,7 @@ class CopyTest extends FileManagedUnitTestBase {
$this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file were copied correctly.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('copy', 'insert'));
+ $this->assertFileHooksCalled(['copy', 'insert']);
$this->assertDifferentFile($source, $result);
$this->assertEqual($result->getFileUri(), $desired_uri, 'The copied file entity has the desired filepath.');
@@ -59,7 +59,7 @@ class CopyTest extends FileManagedUnitTestBase {
$this->assertNotEqual($result->getFileUri(), $source->getFileUri(), 'Returned file path has changed from the original.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('copy', 'insert'));
+ $this->assertFileHooksCalled(['copy', 'insert']);
// Load all the affected files to check the changes that actually made it
// to the database.
@@ -99,7 +99,7 @@ class CopyTest extends FileManagedUnitTestBase {
$this->assertDifferentFile($source, $result);
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('load', 'copy', 'update'));
+ $this->assertFileHooksCalled(['load', 'copy', 'update']);
// Load all the affected files to check the changes that actually made it
// to the database.
@@ -136,7 +136,7 @@ class CopyTest extends FileManagedUnitTestBase {
$this->assertEqual($contents, file_get_contents($target->getFileUri()), 'Contents of file were not altered.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
$this->assertFileUnchanged($source, File::load($source->id()));
$this->assertFileUnchanged($target, File::load($target->id()));
diff --git a/core/modules/file/tests/src/Kernel/DeleteTest.php b/core/modules/file/tests/src/Kernel/DeleteTest.php
index b88057121d2..6d992a5423d 100644
--- a/core/modules/file/tests/src/Kernel/DeleteTest.php
+++ b/core/modules/file/tests/src/Kernel/DeleteTest.php
@@ -19,7 +19,7 @@ class DeleteTest extends FileManagedUnitTestBase {
// Check that deletion removes the file and database record.
$this->assertTrue(is_file($file->getFileUri()), 'File exists.');
$file->delete();
- $this->assertFileHooksCalled(array('delete'));
+ $this->assertFileHooksCalled(['delete']);
$this->assertFalse(file_exists($file->getFileUri()), 'Test file has actually been deleted.');
$this->assertFalse(File::load($file->id()), 'File was removed from the database.');
}
@@ -35,7 +35,7 @@ class DeleteTest extends FileManagedUnitTestBase {
$file_usage->delete($file, 'testing', 'test', 1);
$usage = $file_usage->listUsage($file);
- $this->assertEqual($usage['testing']['test'], array(1 => 1), 'Test file is still in use.');
+ $this->assertEqual($usage['testing']['test'], [1 => 1], 'Test file is still in use.');
$this->assertTrue(file_exists($file->getFileUri()), 'File still exists on the disk.');
$this->assertTrue(File::load($file->id()), 'File still exists in the database.');
@@ -44,7 +44,7 @@ class DeleteTest extends FileManagedUnitTestBase {
$file_usage->delete($file, 'testing', 'test', 1);
$usage = $file_usage->listUsage($file);
- $this->assertFileHooksCalled(array('load', 'update'));
+ $this->assertFileHooksCalled(['load', 'update']);
$this->assertTrue(empty($usage), 'File usage data was removed.');
$this->assertTrue(file_exists($file->getFileUri()), 'File still exists on the disk.');
$file = File::load($file->id());
@@ -56,15 +56,15 @@ class DeleteTest extends FileManagedUnitTestBase {
// of the file is older than the system.file.temporary_maximum_age
// configuration value.
db_update('file_managed')
- ->fields(array(
+ ->fields([
'changed' => REQUEST_TIME - ($this->config('system.file')->get('temporary_maximum_age') + 1),
- ))
+ ])
->condition('fid', $file->id())
->execute();
\Drupal::service('cron')->run();
// file_cron() loads
- $this->assertFileHooksCalled(array('delete'));
+ $this->assertFileHooksCalled(['delete']);
$this->assertFalse(file_exists($file->getFileUri()), 'File has been deleted after its last usage was removed.');
$this->assertFalse(File::load($file->id()), 'File was removed from the database.');
}
diff --git a/core/modules/file/tests/src/Kernel/FileItemTest.php b/core/modules/file/tests/src/Kernel/FileItemTest.php
index 747d5da703e..8219af15d9c 100644
--- a/core/modules/file/tests/src/Kernel/FileItemTest.php
+++ b/core/modules/file/tests/src/Kernel/FileItemTest.php
@@ -23,7 +23,7 @@ class FileItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('file');
+ public static $modules = ['file'];
/**
* Created file entity.
@@ -43,20 +43,20 @@ class FileItemTest extends FieldKernelTestBase {
parent::setUp();
$this->installEntitySchema('file');
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('file', ['file_usage']);
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'file_test',
'entity_type' => 'entity_test',
'type' => 'file',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
$this->directory = $this->getRandomGenerator()->name(8);
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'file_test',
'bundle' => 'entity_test',
- 'settings' => array('file_directory' => $this->directory),
+ 'settings' => ['file_directory' => $this->directory],
])->save();
file_put_contents('public://example.txt', $this->randomMachineName());
$this->file = File::create([
@@ -131,7 +131,7 @@ class FileItemTest extends FieldKernelTestBase {
'weight' => 1,
])->save();
$entity = EntityTest::create();
- $entity->file_test = array('entity' => $file3);
+ $entity->file_test = ['entity' => $file3];
$uri = $file3->getFileUri();
$output = entity_view($entity, 'default');
\Drupal::service('renderer')->renderRoot($output);
diff --git a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
index 4db377ded9b..3035b7cb218 100644
--- a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
+++ b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
@@ -18,17 +18,17 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('file_test', 'file', 'system', 'field', 'user');
+ public static $modules = ['file_test', 'file', 'system', 'field', 'user'];
protected function setUp() {
parent::setUp();
// Clear out any hook calls.
file_test_reset();
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
$this->installEntitySchema('file');
$this->installEntitySchema('user');
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('file', ['file_usage']);
// Make sure that a user with uid 1 exists, self::createFile() relies on
// it.
@@ -55,16 +55,16 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
// Determine if there were any expected that were not called.
$uncalled = array_diff($expected, $actual);
if (count($uncalled)) {
- $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
+ $this->assertTrue(FALSE, format_string('Expected hooks %expected to be called but %uncalled was not called.', ['%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)]));
}
else {
- $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', array('%expected' => empty($expected) ? '(none)' : implode(', ', $expected))));
+ $this->assertTrue(TRUE, format_string('All the expected hooks were called: %expected', ['%expected' => empty($expected) ? '(none)' : implode(', ', $expected)]));
}
// Determine if there were any unexpected calls.
$unexpected = array_diff($actual, $expected);
if (count($unexpected)) {
- $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', array('%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected))));
+ $this->assertTrue(FALSE, format_string('Unexpected hooks were called: %unexpected.', ['%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected)]));
}
else {
$this->assertTrue(TRUE, 'No unexpected hooks were called.');
@@ -86,13 +86,13 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
if (!isset($message)) {
if ($actual_count == $expected_count) {
- $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook));
+ $message = format_string('hook_file_@name was called correctly.', ['@name' => $hook]);
}
elseif ($expected_count == 0) {
- $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count));
+ $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]);
}
else {
- $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', array('@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count));
+ $message = format_string('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]);
}
}
$this->assertEqual($actual_count, $expected_count, $message);
@@ -107,13 +107,13 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
* File object to compare.
*/
function assertFileUnchanged(FileInterface $before, FileInterface $after) {
- $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged');
- $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged');
- $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged');
- $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', array('%file1' => $before->getFileUri(), '%file2' => $after->getFileUri())), 'File unchanged');
- $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', array('%file1' => $before->getMimeType(), '%file2' => $after->getMimeType())), 'File unchanged');
- $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', array('%file1' => $before->getSize(), '%file2' => $after->getSize())), 'File unchanged');
- $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', array('%file1' => $before->isPermanent(), '%file2' => $after->isPermanent())), 'File unchanged');
+ $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', ['%file1' => $before->id(), '%file2' => $after->id()]), 'File unchanged');
+ $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', ['%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id()]), 'File unchanged');
+ $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', ['%file1' => $before->getFilename(), '%file2' => $after->getFilename()]), 'File unchanged');
+ $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', ['%file1' => $before->getFileUri(), '%file2' => $after->getFileUri()]), 'File unchanged');
+ $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', ['%file1' => $before->getMimeType(), '%file2' => $after->getMimeType()]), 'File unchanged');
+ $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', ['%file1' => $before->getSize(), '%file2' => $after->getSize()]), 'File unchanged');
+ $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', ['%file1' => $before->isPermanent(), '%file2' => $after->isPermanent()]), 'File unchanged');
}
/**
@@ -125,8 +125,8 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
* File object to compare.
*/
function assertDifferentFile(FileInterface $file1, FileInterface $file2) {
- $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file');
- $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file');
+ $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', ['%file1' => $file1->id(), '%file2' => $file2->id()]), 'Different file');
+ $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()]), 'Different file');
}
/**
@@ -138,8 +138,8 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
* File object to compare.
*/
function assertSameFile(FileInterface $file1, FileInterface $file2) {
- $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file');
- $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file');
+ $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', ['%file1' => $file1->id(), '%file2-fid' => $file2->id()]), 'Same file');
+ $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', ['%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri()]), 'Same file');
}
/**
diff --git a/core/modules/file/tests/src/Kernel/LoadTest.php b/core/modules/file/tests/src/Kernel/LoadTest.php
index c523d43bfda..8cbaccc2c90 100644
--- a/core/modules/file/tests/src/Kernel/LoadTest.php
+++ b/core/modules/file/tests/src/Kernel/LoadTest.php
@@ -15,25 +15,25 @@ class LoadTest extends FileManagedUnitTestBase {
*/
function testLoadMissingFid() {
$this->assertFalse(File::load(-1), 'Try to load an invalid fid fails.');
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
}
/**
* Try to load a non-existent file by URI.
*/
function testLoadMissingFilepath() {
- $files = entity_load_multiple_by_properties('file', array('uri' => 'foobar://misc/druplicon.png'));
+ $files = entity_load_multiple_by_properties('file', ['uri' => 'foobar://misc/druplicon.png']);
$this->assertFalse(reset($files), "Try to load a file that doesn't exist in the database fails.");
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
}
/**
* Try to load a non-existent file by status.
*/
function testLoadInvalidStatus() {
- $files = entity_load_multiple_by_properties('file', array('status' => -99));
+ $files = entity_load_multiple_by_properties('file', ['status' => -99]);
$this->assertFalse(reset($files), 'Trying to load a file with an invalid status fails.');
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
}
/**
@@ -62,7 +62,7 @@ class LoadTest extends FileManagedUnitTestBase {
// Load by path.
file_test_reset();
- $by_path_files = entity_load_multiple_by_properties('file', array('uri' => $file->getFileUri()));
+ $by_path_files = entity_load_multiple_by_properties('file', ['uri' => $file->getFileUri()]);
$this->assertFileHookCalled('load');
$this->assertEqual(1, count($by_path_files), 'entity_load_multiple_by_properties() returned an array of the correct size.');
$by_path_file = reset($by_path_files);
@@ -71,8 +71,8 @@ class LoadTest extends FileManagedUnitTestBase {
// Load by fid.
file_test_reset();
- $by_fid_files = File::loadMultiple(array($file->id()));
- $this->assertFileHooksCalled(array());
+ $by_fid_files = File::loadMultiple([$file->id()]);
+ $this->assertFileHooksCalled([]);
$this->assertEqual(1, count($by_fid_files), '\Drupal\file\Entity\File::loadMultiple() returned an array of the correct size.');
$by_fid_file = reset($by_fid_files);
$this->assertTrue($by_fid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.');
diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateFileTest.php
index 7e1cff91b5b..024db2136e3 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateFileTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateFileTest.php
@@ -79,12 +79,12 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
// Update the file_directory_path.
Database::getConnection('default', 'migrate')
->update('variable')
- ->fields(array('value' => serialize('files/test')))
+ ->fields(['value' => serialize('files/test')])
->condition('name', 'file_directory_path')
->execute();
Database::getConnection('default', 'migrate')
->update('variable')
- ->fields(array('value' => serialize(file_directory_temp())))
+ ->fields(['value' => serialize(file_directory_temp())])
->condition('name', 'file_directory_temp')
->execute();
@@ -122,10 +122,10 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
$db->update('files')
->condition('fid', 6)
- ->fields(array(
+ ->fields([
'filename' => static::$tempFilename,
'filepath' => $file_path,
- ))
+ ])
->execute();
$file = (array) $db->select('files')
diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php
index a813b93cc76..c3b71ad4263 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php
@@ -38,7 +38,7 @@ class MigrateUploadEntityDisplayTest extends MigrateDrupal6TestBase {
$component = $display->getComponent('upload');
$this->assertTrue(is_null($component));
- $this->assertIdentical(array('node', 'page', 'default', 'upload'), $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationID(array('page')));
+ $this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationID(['page']));
}
}
diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php
index de0acbfd400..e9782aa9049 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php
@@ -38,7 +38,7 @@ class MigrateUploadEntityFormDisplayTest extends MigrateDrupal6TestBase {
$component = $display->getComponent('upload');
$this->assertTrue(is_null($component));
- $this->assertIdentical(array('node', 'page', 'default', 'upload'), $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationID(array('page')));
+ $this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationID(['page']));
}
}
diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadFieldTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadFieldTest.php
index 9d5c711d58b..918d6f3c55e 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadFieldTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadFieldTest.php
@@ -26,7 +26,7 @@ class MigrateUploadFieldTest extends MigrateDrupal6TestBase {
public function testUpload() {
$field_storage = FieldStorageConfig::load('node.upload');
$this->assertIdentical('node.upload', $field_storage->id());
- $this->assertIdentical(array('node', 'upload'), $this->getMigration('d6_upload_field')->getIdMap()->lookupDestinationID(array('')));
+ $this->assertIdentical(['node', 'upload'], $this->getMigration('d6_upload_field')->getIdMap()->lookupDestinationID(['']));
}
}
diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php
index a835006afdf..18c4a71bcf4 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadInstanceTest.php
@@ -38,7 +38,7 @@ class MigrateUploadInstanceTest extends MigrateDrupal6TestBase {
$field = FieldConfig::load('node.article.upload');
$this->assertTrue(is_null($field));
- $this->assertIdentical(array('node', 'page', 'upload'), $this->getMigration('d6_upload_field_instance')->getIdMap()->lookupDestinationID(array('page')));
+ $this->assertIdentical(['node', 'page', 'upload'], $this->getMigration('d6_upload_field_instance')->getIdMap()->lookupDestinationID(['page']));
}
}
diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadTest.php
index 463ce022d80..2ab104dae34 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadTest.php
@@ -24,10 +24,10 @@ class MigrateUploadTest extends MigrateDrupal6TestBase {
$this->installSchema('file', ['file_usage']);
$this->installSchema('node', ['node_access']);
- $id_mappings = array('d6_file' => array());
+ $id_mappings = ['d6_file' => []];
// Create new file entities.
for ($i = 1; $i <= 3; $i++) {
- $file = File::create(array(
+ $file = File::create([
'fid' => $i,
'uid' => 1,
'filename' => 'druplicon.txt',
@@ -36,13 +36,13 @@ class MigrateUploadTest extends MigrateDrupal6TestBase {
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), 'hello world');
// Save it, inserting a new record.
$file->save();
- $id_mappings['d6_file'][] = array(array($i), array($i));
+ $id_mappings['d6_file'][] = [[$i], [$i]];
}
$this->prepareMigrations($id_mappings);
diff --git a/core/modules/file/tests/src/Kernel/MoveTest.php b/core/modules/file/tests/src/Kernel/MoveTest.php
index a56caeaecea..f2f10342827 100644
--- a/core/modules/file/tests/src/Kernel/MoveTest.php
+++ b/core/modules/file/tests/src/Kernel/MoveTest.php
@@ -28,10 +28,10 @@ class MoveTest extends FileManagedUnitTestBase {
$this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file correctly written.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('move', 'load', 'update'));
+ $this->assertFileHooksCalled(['move', 'load', 'update']);
// Make sure we got the same file back.
- $this->assertEqual($source->id(), $result->id(), format_string("Source file id's' %fid is unchanged after move.", array('%fid' => $source->id())));
+ $this->assertEqual($source->id(), $result->id(), format_string("Source file id's' %fid is unchanged after move.", ['%fid' => $source->id()]));
// Reload the file from the database and check that the changes were
// actually saved.
@@ -60,7 +60,7 @@ class MoveTest extends FileManagedUnitTestBase {
$this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file correctly written.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('move', 'load', 'update'));
+ $this->assertFileHooksCalled(['move', 'load', 'update']);
// Compare the returned value to what made it into the database.
$this->assertFileUnchanged($result, File::load($result->id()));
@@ -95,7 +95,7 @@ class MoveTest extends FileManagedUnitTestBase {
$this->assertTrue($result, 'File moved successfully.');
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('move', 'update', 'delete', 'load'));
+ $this->assertFileHooksCalled(['move', 'update', 'delete', 'load']);
// Reload the file from the database and check that the changes were
// actually saved.
@@ -122,7 +122,7 @@ class MoveTest extends FileManagedUnitTestBase {
$this->assertEqual($contents, file_get_contents($source->getFileUri()), 'Contents of file were not altered.');
// Check that no hooks were called while failing.
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
// Load the file from the database and make sure it is identical to what
// was returned.
@@ -149,7 +149,7 @@ class MoveTest extends FileManagedUnitTestBase {
$this->assertEqual($contents, file_get_contents($target->getFileUri()), 'Contents of file were not altered.');
// Check that no hooks were called while failing.
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
// Load the file from the database and make sure it is identical to what
// was returned.
diff --git a/core/modules/file/tests/src/Kernel/SaveDataTest.php b/core/modules/file/tests/src/Kernel/SaveDataTest.php
index c5637d08d37..f92ef9a5cb7 100644
--- a/core/modules/file/tests/src/Kernel/SaveDataTest.php
+++ b/core/modules/file/tests/src/Kernel/SaveDataTest.php
@@ -26,7 +26,7 @@ class SaveDataTest extends FileManagedUnitTestBase {
$this->assertTrue($result->isPermanent(), "The file's status was set to permanent.");
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('insert'));
+ $this->assertFileHooksCalled(['insert']);
// Verify that what was returned is what's in the database.
$this->assertFileUnchanged($result, File::load($result->id()));
@@ -51,7 +51,7 @@ class SaveDataTest extends FileManagedUnitTestBase {
$this->assertTrue($result->isPermanent(), "The file's status was set to permanent.");
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('insert'));
+ $this->assertFileHooksCalled(['insert']);
// Verify that what was returned is what's in the database.
$this->assertFileUnchanged($result, File::load($result->id()));
@@ -75,7 +75,7 @@ class SaveDataTest extends FileManagedUnitTestBase {
$this->assertTrue($result->isPermanent(), "The file's status was set to permanent.");
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('insert'));
+ $this->assertFileHooksCalled(['insert']);
// Ensure that the existing file wasn't overwritten.
$this->assertDifferentFile($existing, $result);
@@ -103,7 +103,7 @@ class SaveDataTest extends FileManagedUnitTestBase {
$this->assertTrue($result->isPermanent(), "The file's status was set to permanent.");
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('load', 'update'));
+ $this->assertFileHooksCalled(['load', 'update']);
// Verify that the existing file was re-used.
$this->assertSameFile($existing, $result);
@@ -125,7 +125,7 @@ class SaveDataTest extends FileManagedUnitTestBase {
$this->assertEqual($contents, file_get_contents($existing->getFileUri()), 'Contents of existing file were unchanged.');
// Check that no hooks were called while failing.
- $this->assertFileHooksCalled(array());
+ $this->assertFileHooksCalled([]);
// Ensure that the existing file wasn't overwritten.
$this->assertFileUnchanged($existing, File::load($existing->id()));
diff --git a/core/modules/file/tests/src/Kernel/SaveTest.php b/core/modules/file/tests/src/Kernel/SaveTest.php
index 69c7f2b7afd..8d91d81aa99 100644
--- a/core/modules/file/tests/src/Kernel/SaveTest.php
+++ b/core/modules/file/tests/src/Kernel/SaveTest.php
@@ -12,20 +12,20 @@ use Drupal\file\Entity\File;
class SaveTest extends FileManagedUnitTestBase {
function testFileSave() {
// Create a new file entity.
- $file = File::create(array(
+ $file = File::create([
'uid' => 1,
'filename' => 'druplicon.txt',
'uri' => 'public://druplicon.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
file_put_contents($file->getFileUri(), 'hello world');
// Save it, inserting a new record.
$file->save();
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('insert'));
+ $this->assertFileHooksCalled(['insert']);
$this->assertTrue($file->id() > 0, 'A new file ID is set when saving a new file to the database.', 'File');
$loaded_file = File::load($file->id());
@@ -41,7 +41,7 @@ class SaveTest extends FileManagedUnitTestBase {
$file->save();
// Check that the correct hooks were called.
- $this->assertFileHooksCalled(array('load', 'update'));
+ $this->assertFileHooksCalled(['load', 'update']);
$this->assertEqual($file->id(), $file->id(), 'The file ID of an existing file is not changed when updating the database.', 'File');
$this->assertTrue($file->getChangedTime() >= $file->getChangedTime(), "Timestamp didn't go backwards.", 'File');
@@ -52,13 +52,13 @@ class SaveTest extends FileManagedUnitTestBase {
// Try to insert a second file with the same name apart from case insensitivity
// to ensure the 'uri' index allows for filenames with different cases.
- $uppercase_values = array(
+ $uppercase_values = [
'uid' => 1,
'filename' => 'DRUPLICON.txt',
'uri' => 'public://DRUPLICON.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
- );
+ ];
$uppercase_file = File::create($uppercase_values);
file_put_contents($uppercase_file->getFileUri(), 'hello world');
$violations = $uppercase_file->validate();
@@ -79,7 +79,7 @@ class SaveTest extends FileManagedUnitTestBase {
->execute();
$this->assertEqual(1, count($fids));
- $this->assertEqual(array($uppercase_file->id() => $uppercase_file->id()), $fids);
+ $this->assertEqual([$uppercase_file->id() => $uppercase_file->id()], $fids);
}
diff --git a/core/modules/file/tests/src/Kernel/UsageTest.php b/core/modules/file/tests/src/Kernel/UsageTest.php
index 8e2601510b8..6752247d941 100644
--- a/core/modules/file/tests/src/Kernel/UsageTest.php
+++ b/core/modules/file/tests/src/Kernel/UsageTest.php
@@ -21,22 +21,22 @@ class UsageTest extends FileManagedUnitTestBase {
function testGetUsage() {
$file = $this->createFile();
db_insert('file_usage')
- ->fields(array(
+ ->fields([
'fid' => $file->id(),
'module' => 'testing',
'type' => 'foo',
'id' => 1,
'count' => 1
- ))
+ ])
->execute();
db_insert('file_usage')
- ->fields(array(
+ ->fields([
'fid' => $file->id(),
'module' => 'testing',
'type' => 'bar',
'id' => 2,
'count' => 2
- ))
+ ])
->execute();
$usage = $this->container->get('file.usage')->listUsage($file);
@@ -81,19 +81,19 @@ class UsageTest extends FileManagedUnitTestBase {
$file = $this->createFile();
$file_usage = $this->container->get('file.usage');
db_insert('file_usage')
- ->fields(array(
+ ->fields([
'fid' => $file->id(),
'module' => 'testing',
'type' => 'bar',
'id' => 2,
'count' => 3,
- ))
+ ])
->execute();
// Normal decrement.
$file_usage->delete($file, 'testing', 'bar', 2);
$count = db_select('file_usage', 'f')
- ->fields('f', array('count'))
+ ->fields('f', ['count'])
->condition('f.fid', $file->id())
->execute()
->fetchField();
@@ -102,7 +102,7 @@ class UsageTest extends FileManagedUnitTestBase {
// Multiple decrement and removal.
$file_usage->delete($file, 'testing', 'bar', 2, 2);
$count = db_select('file_usage', 'f')
- ->fields('f', array('count'))
+ ->fields('f', ['count'])
->condition('f.fid', $file->id())
->execute()
->fetchField();
@@ -111,7 +111,7 @@ class UsageTest extends FileManagedUnitTestBase {
// Non-existent decrement.
$file_usage->delete($file, 'testing', 'bar', 2);
$count = db_select('file_usage', 'f')
- ->fields('f', array('count'))
+ ->fields('f', ['count'])
->condition('f.fid', $file->id())
->execute()
->fetchField();
@@ -128,10 +128,10 @@ class UsageTest extends FileManagedUnitTestBase {
// Temporary file that is old.
$temp_old = file_save_data('');
db_update('file_managed')
- ->fields(array(
+ ->fields([
'status' => 0,
'changed' => REQUEST_TIME - $this->config('system.file')->get('temporary_maximum_age') - 1,
- ))
+ ])
->condition('fid', $temp_old->id())
->execute();
$this->assertTrue(file_exists($temp_old->getFileUri()), 'Old temp file was created correctly.');
@@ -139,7 +139,7 @@ class UsageTest extends FileManagedUnitTestBase {
// Temporary file that is new.
$temp_new = file_save_data('');
db_update('file_managed')
- ->fields(array('status' => 0))
+ ->fields(['status' => 0])
->condition('fid', $temp_new->id())
->execute();
$this->assertTrue(file_exists($temp_new->getFileUri()), 'New temp file was created correctly.');
@@ -147,7 +147,7 @@ class UsageTest extends FileManagedUnitTestBase {
// Permanent file that is old.
$perm_old = file_save_data('');
db_update('file_managed')
- ->fields(array('changed' => REQUEST_TIME - $this->config('system.file')->get('temporary_maximum_age') - 1))
+ ->fields(['changed' => REQUEST_TIME - $this->config('system.file')->get('temporary_maximum_age') - 1])
->condition('fid', $temp_old->id())
->execute();
$this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was created correctly.');
@@ -155,7 +155,7 @@ class UsageTest extends FileManagedUnitTestBase {
// Permanent file that is new.
$perm_new = file_save_data('');
$this->assertTrue(file_exists($perm_new->getFileUri()), 'New permanent file was created correctly.');
- return array($temp_old, $temp_new, $perm_old, $perm_new);
+ return [$temp_old, $temp_new, $perm_old, $perm_new];
}
/**
diff --git a/core/modules/file/tests/src/Kernel/ValidateTest.php b/core/modules/file/tests/src/Kernel/ValidateTest.php
index 0bfcfddd43e..2fc88176a7c 100644
--- a/core/modules/file/tests/src/Kernel/ValidateTest.php
+++ b/core/modules/file/tests/src/Kernel/ValidateTest.php
@@ -16,23 +16,23 @@ class ValidateTest extends FileManagedUnitTestBase {
$file = $this->createFile();
// Empty validators.
- $this->assertEqual(file_validate($file, array()), array(), 'Validating an empty array works successfully.');
- $this->assertFileHooksCalled(array('validate'));
+ $this->assertEqual(file_validate($file, []), [], 'Validating an empty array works successfully.');
+ $this->assertFileHooksCalled(['validate']);
// Use the file_test.module's test validator to ensure that passing tests
// return correctly.
file_test_reset();
- file_test_set_return('validate', array());
- $passing = array('file_test_validator' => array(array()));
- $this->assertEqual(file_validate($file, $passing), array(), 'Validating passes.');
- $this->assertFileHooksCalled(array('validate'));
+ file_test_set_return('validate', []);
+ $passing = ['file_test_validator' => [[]]];
+ $this->assertEqual(file_validate($file, $passing), [], 'Validating passes.');
+ $this->assertFileHooksCalled(['validate']);
// Now test for failures in validators passed in and by hook_validate.
file_test_reset();
- file_test_set_return('validate', array('Epic fail'));
- $failing = array('file_test_validator' => array(array('Failed', 'Badly')));
- $this->assertEqual(file_validate($file, $failing), array('Failed', 'Badly', 'Epic fail'), 'Validating returns errors.');
- $this->assertFileHooksCalled(array('validate'));
+ file_test_set_return('validate', ['Epic fail']);
+ $failing = ['file_test_validator' => [['Failed', 'Badly']]];
+ $this->assertEqual(file_validate($file, $failing), ['Failed', 'Badly', 'Epic fail'], 'Validating returns errors.');
+ $this->assertFileHooksCalled(['validate']);
}
}
diff --git a/core/modules/file/tests/src/Kernel/Views/ExtensionViewsFieldTest.php b/core/modules/file/tests/src/Kernel/Views/ExtensionViewsFieldTest.php
index 221c011940b..867ab7aaa10 100644
--- a/core/modules/file/tests/src/Kernel/Views/ExtensionViewsFieldTest.php
+++ b/core/modules/file/tests/src/Kernel/Views/ExtensionViewsFieldTest.php
@@ -18,21 +18,21 @@ class ExtensionViewsFieldTest extends ViewsKernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('file', 'file_test_views', 'user');
+ public static $modules = ['file', 'file_test_views', 'user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('file_extension_view');
+ public static $testViews = ['file_extension_view'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('file_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['file_test_views']);
$this->installEntitySchema('file');
diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
index 1ee73a83eee..1cce9898e8c 100644
--- a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
+++ b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
@@ -25,26 +25,26 @@ class CckFileTest extends UnitTestCase {
$migration_plugin = $this->prophesize(MigrateProcessInterface::class);
$migration_plugin->transform(1, $executable, $row, 'foo')->willReturn(1);
- $plugin = new CckFile(array(), 'd6_cck_file', array(), $migration, $migration_plugin->reveal());
+ $plugin = new CckFile([], 'd6_cck_file', [], $migration, $migration_plugin->reveal());
- $options = array(
+ $options = [
'alt' => 'Foobaz',
'title' => 'Wambooli',
- );
- $value = array(
+ ];
+ $value = [
'fid' => 1,
'list' => TRUE,
'data' => serialize($options),
- );
+ ];
$transformed = $plugin->transform($value, $executable, $row, 'foo');
- $expected = array(
+ $expected = [
'target_id' => 1,
'display' => TRUE,
'description' => '',
'alt' => 'Foobaz',
'title' => 'Wambooli',
- );
+ ];
$this->assertSame($expected, $transformed);
}
diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php
index 5bf973f4e7b..bf4c52e83d2 100644
--- a/core/modules/filter/filter.api.php
+++ b/core/modules/filter/filter.api.php
@@ -18,9 +18,9 @@
*/
function hook_filter_info_alter(&$info) {
// Alter the default settings of the URL filter provided by core.
- $info['filter_url']['default_settings'] = array(
+ $info['filter_url']['default_settings'] = [
'filter_url_length' => 100,
- );
+ ];
}
/**
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index f52614a4254..e3095346dda 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -21,11 +21,11 @@ function filter_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.filter':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Filter module allows administrators to configure text formats. Text formats change how HTML tags and other text will be <em>processed and displayed</em> in the site. They are used to transform text, and also help to defend your web site against potentially damaging input from malicious users. Visual text editors can be associated with text formats by using the <a href=":editor_help">Text Editor module</a>. For more information, see the <a href=":filter_do">online documentation for the Filter module</a>.', array(':filter_do' => 'https://www.drupal.org/documentation/modules/filter/', ':editor_help' => (\Drupal::moduleHandler()->moduleExists('editor')) ? \Drupal::url('help.page', array('name' => 'editor')) : '#')) . '</p>';
+ $output .= '<p>' . t('The Filter module allows administrators to configure text formats. Text formats change how HTML tags and other text will be <em>processed and displayed</em> in the site. They are used to transform text, and also help to defend your web site against potentially damaging input from malicious users. Visual text editors can be associated with text formats by using the <a href=":editor_help">Text Editor module</a>. For more information, see the <a href=":filter_do">online documentation for the Filter module</a>.', [':filter_do' => 'https://www.drupal.org/documentation/modules/filter/', ':editor_help' => (\Drupal::moduleHandler()->moduleExists('editor')) ? \Drupal::url('help.page', ['name' => 'editor']) : '#']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing text formats') . '</dt>';
- $output .= '<dd>' . t('You can create and edit text formats on the <a href=":formats">Text formats page</a> (if the Text Editor module is enabled, this page is named Text formats and editors). One text format is included by default: Plain text (which removes all HTML tags). Additional text formats may be created during installation. You can create a text format by clicking "<a href=":add_format">Add text format</a>".', array(':formats' => \Drupal::url('filter.admin_overview'), ':add_format' => \Drupal::url('filter.format_add'))) . '</dd>';
+ $output .= '<dd>' . t('You can create and edit text formats on the <a href=":formats">Text formats page</a> (if the Text Editor module is enabled, this page is named Text formats and editors). One text format is included by default: Plain text (which removes all HTML tags). Additional text formats may be created during installation. You can create a text format by clicking "<a href=":add_format">Add text format</a>".', [':formats' => \Drupal::url('filter.admin_overview'), ':add_format' => \Drupal::url('filter.format_add')]) . '</dd>';
$output .= '<dt>' . t('Assigning roles to text formats') . '</dt>';
$output .= '<dd>' . t('You can define which users will be able to use each text format by selecting roles. To ensure security, anonymous and untrusted users should only have access to text formats that restrict them to either plain text or a safe set of HTML tags. This is because HTML tags can allow embedding malicious links or scripts in text. More trusted registered users may be granted permission to use less restrictive text formats in order to create rich text. <strong>Improper text format configuration is a security risk.</strong>') . '</dd>';
$output .= '<dt>' . t('Selecting filters') . '</dt>';
@@ -39,7 +39,7 @@ function filter_help($route_name, RouteMatchInterface $route_match) {
return $output;
case 'filter.admin_overview':
- $output = '<p>' . t('Text formats define how text is filtered for output and how HTML tags and other text is displayed, replaced, or removed. <strong>Improper text format configuration is a security risk.</strong> Learn more on the <a href=":filter_help">Filter module help page</a>.', array(':filter_help' => \Drupal::url('help.page', array('name' => 'filter')))) . '</p>';
+ $output = '<p>' . t('Text formats define how text is filtered for output and how HTML tags and other text is displayed, replaced, or removed. <strong>Improper text format configuration is a security risk.</strong> Learn more on the <a href=":filter_help">Filter module help page</a>.', [':filter_help' => \Drupal::url('help.page', ['name' => 'filter'])]) . '</p>';
$output .= '<p>' . t('Text formats are presented on content editing pages in the order defined on this page. The first format available to a user will be selected by default.') . '</p>';
return $output;
@@ -53,29 +53,29 @@ function filter_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function filter_theme() {
- return array(
- 'filter_tips' => array(
- 'variables' => array('tips' => NULL, 'long' => FALSE),
- ),
- 'text_format_wrapper' => array(
- 'variables' => array(
+ return [
+ 'filter_tips' => [
+ 'variables' => ['tips' => NULL, 'long' => FALSE],
+ ],
+ 'text_format_wrapper' => [
+ 'variables' => [
'children' => NULL,
'description' => NULL,
- 'attributes' => array(),
- ),
- ),
- 'filter_guidelines' => array(
- 'variables' => array('format' => NULL),
- ),
- 'filter_caption' => array(
- 'variables' => array(
+ 'attributes' => [],
+ ],
+ ],
+ 'filter_guidelines' => [
+ 'variables' => ['format' => NULL],
+ ],
+ 'filter_caption' => [
+ 'variables' => [
'node' => NULL,
'tag' => NULL,
'caption' => NULL,
'classes' => NULL,
- ),
- )
- );
+ ],
+ ]
+ ];
}
/**
@@ -93,7 +93,7 @@ function filter_theme() {
* @see filter_formats_reset()
*/
function filter_formats(AccountInterface $account = NULL) {
- $formats = &drupal_static(__FUNCTION__, array());
+ $formats = &drupal_static(__FUNCTION__, []);
// All available formats are cached for performance.
if (!isset($formats['all'])) {
@@ -102,7 +102,7 @@ function filter_formats(AccountInterface $account = NULL) {
$formats['all'] = $cache->data;
}
else {
- $formats['all'] = \Drupal::entityManager()->getStorage('filter_format')->loadByProperties(array('status' => TRUE));
+ $formats['all'] = \Drupal::entityManager()->getStorage('filter_format')->loadByProperties(['status' => TRUE]);
uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort');
\Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, \Drupal::entityManager()->getDefinition('filter_format')->getListCacheTags());
}
@@ -116,7 +116,7 @@ function filter_formats(AccountInterface $account = NULL) {
// Build a list of user-specific formats.
$account_id = $account->id();
if (!isset($formats['user'][$account_id])) {
- $formats['user'][$account_id] = array();
+ $formats['user'][$account_id] = [];
foreach ($formats['all'] as $format) {
if ($format->access('use', $account)) {
$formats['user'][$account_id][$format->id()] = $format;
@@ -152,7 +152,7 @@ function filter_get_roles_by_format(FilterFormatInterface $format) {
}
// Do not list any roles if the permission does not exist.
$permission = $format->getPermissionName();
- return !empty($permission) ? user_role_names(FALSE, $permission) : array();
+ return !empty($permission) ? user_role_names(FALSE, $permission) : [];
}
/**
@@ -166,7 +166,7 @@ function filter_get_roles_by_format(FilterFormatInterface $format) {
* the text format ID and ordered by weight.
*/
function filter_get_formats_by_role($rid) {
- $formats = array();
+ $formats = [];
foreach (filter_formats() as $format) {
$roles = filter_get_roles_by_format($format);
if (isset($roles[$rid])) {
@@ -291,14 +291,14 @@ function filter_fallback_format() {
*
* @ingroup sanitization
*/
-function check_markup($text, $format_id = NULL, $langcode = '', $filter_types_to_skip = array()) {
- $build = array(
+function check_markup($text, $format_id = NULL, $langcode = '', $filter_types_to_skip = []) {
+ $build = [
'#type' => 'processed_text',
'#text' => $text,
'#format' => $format_id,
'#filter_types_to_skip' => $filter_types_to_skip,
'#langcode' => $langcode,
- );
+ ];
return \Drupal::service('renderer')->renderPlain($build);
}
@@ -337,11 +337,11 @@ function filter_form_access_denied($element) {
function _filter_tips($format_id, $long = FALSE) {
$formats = filter_formats(\Drupal::currentUser());
- $tips = array();
+ $tips = [];
// If only listing one format, extract it from the $formats array.
if ($format_id != -1) {
- $formats = array($formats[$format_id]);
+ $formats = [$formats[$format_id]];
}
foreach ($formats as $format) {
@@ -349,10 +349,10 @@ function _filter_tips($format_id, $long = FALSE) {
if ($filter->status) {
$tip = $filter->tips($long);
if (isset($tip)) {
- $tips[$format->label()][$name] = array(
- 'tip' => array('#markup' => $tip),
+ $tips[$format->label()][$name] = [
+ 'tip' => ['#markup' => $tip],
'id' => $name,
- );
+ ];
}
}
}
@@ -372,10 +372,10 @@ function _filter_tips($format_id, $long = FALSE) {
*/
function template_preprocess_filter_guidelines(&$variables) {
$format = $variables['format'];
- $variables['tips'] = array(
+ $variables['tips'] = [
'#theme' => 'filter_tips',
'#tips' => _filter_tips($format->id(), FALSE),
- );
+ ];
}
/**
@@ -431,11 +431,11 @@ function template_preprocess_filter_tips(&$variables) {
$tiplist[$tip_key]['attributes'] = new Attribute();
}
- $variables['tips'][$name] = array(
+ $variables['tips'][$name] = [
'attributes' => new Attribute(),
'name' => $name,
'list' => $tiplist,
- );
+ ];
}
$variables['multiple'] = count($tips) > 1;
@@ -470,7 +470,7 @@ function _filter_url($text, $filter) {
// callback function to process matches of the regexp. The callback function
// is to return the replacement for the match. The array is used and
// matching/replacement done below inside some loops.
- $tasks = array();
+ $tasks = [];
// Prepare protocols pattern for absolute URLs.
// \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() will replace
@@ -643,12 +643,12 @@ function _filter_url_parse_partial_links($match) {
* cached $comments are reset.
*/
function _filter_url_escape_comments($match, $escape = NULL) {
- static $mode, $comments = array();
+ static $mode, $comments = [];
if (isset($escape)) {
$mode = $escape;
if ($escape) {
- $comments = array();
+ $comments = [];
}
return;
}
diff --git a/core/modules/filter/src/Annotation/Filter.php b/core/modules/filter/src/Annotation/Filter.php
index 9d7d1ccee32..4d90c584263 100644
--- a/core/modules/filter/src/Annotation/Filter.php
+++ b/core/modules/filter/src/Annotation/Filter.php
@@ -73,6 +73,6 @@ class Filter extends Plugin {
*
* @var array (optional)
*/
- public $settings = array();
+ public $settings = [];
}
diff --git a/core/modules/filter/src/Controller/FilterController.php b/core/modules/filter/src/Controller/FilterController.php
index f5ebe7991c6..09652b7d8cd 100644
--- a/core/modules/filter/src/Controller/FilterController.php
+++ b/core/modules/filter/src/Controller/FilterController.php
@@ -24,11 +24,11 @@ class FilterController {
function filterTips(FilterFormatInterface $filter_format = NULL) {
$tips = $filter_format ? $filter_format->id() : -1;
- $build = array(
+ $build = [
'#theme' => 'filter_tips',
'#long' => TRUE,
'#tips' => _filter_tips($tips, TRUE),
- );
+ ];
return $build;
}
diff --git a/core/modules/filter/src/Element/ProcessedText.php b/core/modules/filter/src/Element/ProcessedText.php
index 0d098703958..6e2b3ec43e8 100644
--- a/core/modules/filter/src/Element/ProcessedText.php
+++ b/core/modules/filter/src/Element/ProcessedText.php
@@ -21,15 +21,15 @@ class ProcessedText extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#text' => '',
'#format' => NULL,
- '#filter_types_to_skip' => array(),
+ '#filter_types_to_skip' => [],
'#langcode' => '',
- '#pre_render' => array(
- array($class, 'preRenderText'),
- ),
- );
+ '#pre_render' => [
+ [$class, 'preRenderText'],
+ ],
+ ];
}
/**
@@ -77,7 +77,7 @@ class ProcessedText extends RenderElement {
// cannot be filtered.
if (!$format || !$format->status()) {
$message = !$format ? 'Missing text format: %format.' : 'Disabled text format: %format.';
- static::logger('filter')->alert($message, array('%format' => $format_id));
+ static::logger('filter')->alert($message, ['%format' => $format_id]);
$element['#markup'] = '';
return $element;
}
@@ -92,7 +92,7 @@ class ProcessedText extends RenderElement {
// Convert all Windows and Mac newlines to a single newline, so filters only
// need to deal with one possibility.
- $text = str_replace(array("\r\n", "\r"), "\n", $text);
+ $text = str_replace(["\r\n", "\r"], "\n", $text);
// Get a complete list of filters, ordered properly.
/** @var \Drupal\filter\Plugin\FilterInterface[] $filters **/
diff --git a/core/modules/filter/src/Element/TextFormat.php b/core/modules/filter/src/Element/TextFormat.php
index 0a80b314b32..16b4cf5207d 100644
--- a/core/modules/filter/src/Element/TextFormat.php
+++ b/core/modules/filter/src/Element/TextFormat.php
@@ -40,13 +40,13 @@ class TextFormat extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#process' => array(
- array($class, 'processFormat'),
- ),
+ return [
+ '#process' => [
+ [$class, 'processFormat'],
+ ],
'#base_type' => 'textarea',
- '#theme_wrappers' => array('text_format_wrapper'),
- );
+ '#theme_wrappers' => ['text_format_wrapper'],
+ ];
}
/**
@@ -84,7 +84,7 @@ class TextFormat extends RenderElement {
// Ensure that children appear as subkeys of this element.
$element['#tree'] = TRUE;
- $blacklist = array(
+ $blacklist = [
// Make \Drupal::formBuilder()->doBuildForm() regenerate child properties.
'#parents',
'#id',
@@ -104,7 +104,7 @@ class TextFormat extends RenderElement {
'#attached',
'#processed',
'#theme_wrappers',
- );
+ ];
// Move this element into sub-element 'value'.
unset($element['value']);
foreach (Element::properties($element) as $key) {
@@ -116,16 +116,16 @@ class TextFormat extends RenderElement {
$element['value']['#type'] = $element['#base_type'];
$element['value'] += static::elementInfo()->getInfo($element['#base_type']);
// Make sure the #default_value key is set, so we can use it below.
- $element['value'] += array('#default_value' => '');
+ $element['value'] += ['#default_value' => ''];
// Turn original element into a text format wrapper.
$element['#attached']['library'][] = 'filter/drupal.filter';
// Setup child container for the text format widget.
- $element['format'] = array(
+ $element['format'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('filter-wrapper')),
- );
+ '#attributes' => ['class' => ['filter-wrapper']],
+ ];
// Get a list of formats that the current user has access to.
$formats = filter_formats($user);
@@ -162,30 +162,30 @@ class TextFormat extends RenderElement {
}
// Prepare text format guidelines.
- $element['format']['guidelines'] = array(
+ $element['format']['guidelines'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('filter-guidelines')),
+ '#attributes' => ['class' => ['filter-guidelines']],
'#weight' => 20,
- );
- $options = array();
+ ];
+ $options = [];
foreach ($formats as $format) {
$options[$format->id()] = $format->label();
- $element['format']['guidelines'][$format->id()] = array(
+ $element['format']['guidelines'][$format->id()] = [
'#theme' => 'filter_guidelines',
'#format' => $format,
- );
+ ];
}
- $element['format']['format'] = array(
+ $element['format']['format'] = [
'#type' => 'select',
'#title' => t('Text format'),
'#options' => $options,
'#default_value' => $element['#format'],
'#access' => count($formats) > 1,
'#weight' => 10,
- '#attributes' => array('class' => array('filter-list')),
- '#parents' => array_merge($element['#parents'], array('format')),
- );
+ '#attributes' => ['class' => ['filter-list']],
+ '#parents' => array_merge($element['#parents'], ['format']),
+ ];
$element['format']['help'] = [
'#type' => 'container',
@@ -225,7 +225,7 @@ class TextFormat extends RenderElement {
// Prepend #pre_render callback to replace field value with user notice
// prior to rendering.
- $element['value'] += array('#pre_render' => array());
+ $element['value'] += ['#pre_render' => []];
array_unshift($element['value']['#pre_render'], 'filter_form_access_denied');
// Cosmetic adjustments.
diff --git a/core/modules/filter/src/Entity/FilterFormat.php b/core/modules/filter/src/Entity/FilterFormat.php
index 8ae4d6032b7..9dbaa62fd2c 100644
--- a/core/modules/filter/src/Entity/FilterFormat.php
+++ b/core/modules/filter/src/Entity/FilterFormat.php
@@ -112,7 +112,7 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En
*
* @var array
*/
- protected $filters = array();
+ protected $filters = [];
/**
* Holds the collection of filters that are attached to this format.
@@ -146,7 +146,7 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En
* {@inheritdoc}
*/
public function getPluginCollections() {
- return array('filters' => $this->filters());
+ return ['filters' => $this->filters()];
}
/**
@@ -182,7 +182,7 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En
parent::disable();
// Allow modules to react on text format deletion.
- \Drupal::moduleHandler()->invokeAll('filter_format_disable', array($this));
+ \Drupal::moduleHandler()->invokeAll('filter_format_disable', [$this]);
// Clear the filter cache whenever a text format is disabled.
filter_formats_reset();
@@ -222,7 +222,7 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En
if (($roles = $this->get('roles')) && $permission = $this->getPermissionName()) {
foreach (user_roles() as $rid => $name) {
$enabled = in_array($rid, $roles, TRUE);
- user_role_change_permissions($rid, array($permission => $enabled));
+ user_role_change_permissions($rid, [$permission => $enabled]);
}
}
}
@@ -252,7 +252,7 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En
* {@inheritdoc}
*/
public function getFilterTypes() {
- $filter_types = array();
+ $filter_types = [];
$filters = $this->filters();
foreach ($filters as $filter) {
@@ -386,7 +386,7 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En
// whitelisting filters were used, then effectively nothing is allowed.
if (isset($restrictions['allowed'])) {
if (count($restrictions['allowed']) === 1 && array_key_exists('*', $restrictions['allowed']) && !isset($restrictions['forbidden_tags'])) {
- $restrictions['allowed'] = array();
+ $restrictions['allowed'] = [];
}
}
diff --git a/core/modules/filter/src/FilterFormatAccessControlHandler.php b/core/modules/filter/src/FilterFormatAccessControlHandler.php
index 0c411a72980..090944aa08d 100644
--- a/core/modules/filter/src/FilterFormatAccessControlHandler.php
+++ b/core/modules/filter/src/FilterFormatAccessControlHandler.php
@@ -41,7 +41,7 @@ class FilterFormatAccessControlHandler extends EntityAccessControlHandler {
return AccessResult::forbidden();
}
- if (in_array($operation, array('disable', 'update'))) {
+ if (in_array($operation, ['disable', 'update'])) {
return parent::checkAccess($filter_format, $operation, $account);
}
diff --git a/core/modules/filter/src/FilterFormatAddForm.php b/core/modules/filter/src/FilterFormatAddForm.php
index 1cc855f3f52..cb9b59881b9 100644
--- a/core/modules/filter/src/FilterFormatAddForm.php
+++ b/core/modules/filter/src/FilterFormatAddForm.php
@@ -21,7 +21,7 @@ class FilterFormatAddForm extends FilterFormatFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
- drupal_set_message($this->t('Added text format %format.', array('%format' => $this->entity->label())));
+ drupal_set_message($this->t('Added text format %format.', ['%format' => $this->entity->label()]));
return $this->entity;
}
diff --git a/core/modules/filter/src/FilterFormatEditForm.php b/core/modules/filter/src/FilterFormatEditForm.php
index ee2f7fb084e..9ffd8c86c77 100644
--- a/core/modules/filter/src/FilterFormatEditForm.php
+++ b/core/modules/filter/src/FilterFormatEditForm.php
@@ -29,7 +29,7 @@ class FilterFormatEditForm extends FilterFormatFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
- drupal_set_message($this->t('The text format %format has been updated.', array('%format' => $this->entity->label())));
+ drupal_set_message($this->t('The text format %format has been updated.', ['%format' => $this->entity->label()]));
return $this->entity;
}
diff --git a/core/modules/filter/src/FilterFormatFormBase.php b/core/modules/filter/src/FilterFormatFormBase.php
index c60171ca0bf..cbcb632189b 100644
--- a/core/modules/filter/src/FilterFormatFormBase.php
+++ b/core/modules/filter/src/FilterFormatFormBase.php
@@ -21,34 +21,34 @@ abstract class FilterFormatFormBase extends EntityForm {
$form['#tree'] = TRUE;
$form['#attached']['library'][] = 'filter/drupal.filter.admin';
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#default_value' => $format->label(),
'#required' => TRUE,
'#weight' => -30,
- );
- $form['format'] = array(
+ ];
+ $form['format'] = [
'#type' => 'machine_name',
'#required' => TRUE,
'#default_value' => $format->id(),
'#maxlength' => 255,
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
- 'source' => array('name'),
- ),
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
+ 'source' => ['name'],
+ ],
'#disabled' => !$format->isNew(),
'#weight' => -20,
- );
+ ];
// Add user role access selection.
- $form['roles'] = array(
+ $form['roles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Roles'),
'#options' => array_map('\Drupal\Component\Utility\Html::escape', user_role_names()),
'#disabled' => $is_fallback,
'#weight' => -10,
- );
+ ];
if ($is_fallback) {
$form['roles']['#description'] = $this->t('All roles for this text format must be enabled and cannot be changed.');
}
@@ -64,13 +64,13 @@ abstract class FilterFormatFormBase extends EntityForm {
// When a filter is missing, it is replaced by the null filter. Remove it
// here, so that saving the form will remove the missing filter.
if ($filter instanceof FilterNull) {
- drupal_set_message($this->t('The %filter filter is missing, and will be removed once this format is saved.', array('%filter' => $filter_id)), 'warning');
+ drupal_set_message($this->t('The %filter filter is missing, and will be removed once this format is saved.', ['%filter' => $filter_id]), 'warning');
$filters->removeInstanceID($filter_id);
}
}
// Filter status.
- $form['filters']['status'] = array(
+ $form['filters']['status'] = [
'#type' => 'item',
'#title' => $this->t('Enabled filters'),
'#prefix' => '<div id="filters-status-wrapper">',
@@ -79,72 +79,72 @@ abstract class FilterFormatFormBase extends EntityForm {
// value, since 'filters' should only contain filter definitions.
// See https://www.drupal.org/node/1829202.
'#input' => FALSE,
- );
+ ];
// Filter order (tabledrag).
- $form['filters']['order'] = array(
+ $form['filters']['order'] = [
'#type' => 'table',
// For filter.admin.js
- '#attributes' => array('id' => 'filter-order'),
+ '#attributes' => ['id' => 'filter-order'],
'#title' => $this->t('Filter processing order'),
- '#tabledrag' => array(
- array(
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'filter-order-weight',
- ),
- ),
+ ],
+ ],
'#tree' => FALSE,
'#input' => FALSE,
- '#theme_wrappers' => array('form_element'),
- );
+ '#theme_wrappers' => ['form_element'],
+ ];
// Filter settings.
- $form['filter_settings'] = array(
+ $form['filter_settings'] = [
'#type' => 'vertical_tabs',
'#title' => $this->t('Filter settings'),
- );
+ ];
foreach ($filters as $name => $filter) {
- $form['filters']['status'][$name] = array(
+ $form['filters']['status'][$name] = [
'#type' => 'checkbox',
'#title' => $filter->getLabel(),
'#default_value' => $filter->status,
- '#parents' => array('filters', $name, 'status'),
+ '#parents' => ['filters', $name, 'status'],
'#description' => $filter->getDescription(),
'#weight' => $filter->weight,
- );
+ ];
$form['filters']['order'][$name]['#attributes']['class'][] = 'draggable';
$form['filters']['order'][$name]['#weight'] = $filter->weight;
- $form['filters']['order'][$name]['filter'] = array(
+ $form['filters']['order'][$name]['filter'] = [
'#markup' => $filter->getLabel(),
- );
- $form['filters']['order'][$name]['weight'] = array(
+ ];
+ $form['filters']['order'][$name]['weight'] = [
'#type' => 'weight',
- '#title' => $this->t('Weight for @title', array('@title' => $filter->getLabel())),
+ '#title' => $this->t('Weight for @title', ['@title' => $filter->getLabel()]),
'#title_display' => 'invisible',
'#delta' => 50,
'#default_value' => $filter->weight,
- '#parents' => array('filters', $name, 'weight'),
- '#attributes' => array('class' => array('filter-order-weight')),
- );
+ '#parents' => ['filters', $name, 'weight'],
+ '#attributes' => ['class' => ['filter-order-weight']],
+ ];
// Retrieve the settings form of the filter plugin. The plugin should not be
// aware of the text format. Therefore, it only receives a set of minimal
// base properties to allow advanced implementations to work.
- $settings_form = array(
- '#parents' => array('filters', $name, 'settings'),
+ $settings_form = [
+ '#parents' => ['filters', $name, 'settings'],
'#tree' => TRUE,
- );
+ ];
$settings_form = $filter->settingsForm($settings_form, $form_state);
if (!empty($settings_form)) {
- $form['filters']['settings'][$name] = array(
+ $form['filters']['settings'][$name] = [
'#type' => 'details',
'#title' => $filter->getLabel(),
'#open' => TRUE,
'#weight' => $filter->weight,
- '#parents' => array('filters', $name, 'settings'),
+ '#parents' => ['filters', $name, 'settings'],
'#group' => 'filter_settings',
- );
+ ];
$form['filters']['settings'][$name] += $settings_form;
}
}
@@ -189,7 +189,7 @@ abstract class FilterFormatFormBase extends EntityForm {
->condition('name', $format_name)
->execute();
if ($format_exists) {
- $form_state->setErrorByName('name', $this->t('Text format names must be unique. A format named %name already exists.', array('%name' => $format_name)));
+ $form_state->setErrorByName('name', $this->t('Text format names must be unique. A format named %name already exists.', ['%name' => $format_name]));
}
}
@@ -216,7 +216,7 @@ abstract class FilterFormatFormBase extends EntityForm {
// Save user permissions.
if ($permission = $format->getPermissionName()) {
foreach ($form_state->getValue('roles') as $rid => $enabled) {
- user_role_change_permissions($rid, array($permission => $enabled));
+ user_role_change_permissions($rid, [$permission => $enabled]);
}
}
diff --git a/core/modules/filter/src/FilterPluginCollection.php b/core/modules/filter/src/FilterPluginCollection.php
index fc6ec06c301..81ebddf4728 100644
--- a/core/modules/filter/src/FilterPluginCollection.php
+++ b/core/modules/filter/src/FilterPluginCollection.php
@@ -114,7 +114,7 @@ class FilterPluginCollection extends DefaultLazyPluginCollection {
// Because filters are disabled by default, this will never remove the
// configuration of an enabled filter.
foreach ($configuration as $instance_id => $instance_config) {
- $default_config = array();
+ $default_config = [];
$default_config['id'] = $instance_id;
$default_config += $this->get($instance_id)->defaultConfiguration();
if ($default_config === $instance_config) {
diff --git a/core/modules/filter/src/FilterPluginManager.php b/core/modules/filter/src/FilterPluginManager.php
index d369a6ffa61..f41e016c0b5 100644
--- a/core/modules/filter/src/FilterPluginManager.php
+++ b/core/modules/filter/src/FilterPluginManager.php
@@ -38,7 +38,7 @@ class FilterPluginManager extends DefaultPluginManager implements FallbackPlugin
/**
* {@inheritdoc}
*/
- public function getFallbackPluginId($plugin_id, array $configuration = array()) {
+ public function getFallbackPluginId($plugin_id, array $configuration = []) {
return 'filter_null';
}
diff --git a/core/modules/filter/src/Form/FilterDisableForm.php b/core/modules/filter/src/Form/FilterDisableForm.php
index a4582fc3f69..c6e82949fd7 100644
--- a/core/modules/filter/src/Form/FilterDisableForm.php
+++ b/core/modules/filter/src/Form/FilterDisableForm.php
@@ -15,7 +15,7 @@ class FilterDisableForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to disable the text format %format?', array('%format' => $this->entity->label()));
+ return $this->t('Are you sure you want to disable the text format %format?', ['%format' => $this->entity->label()]);
}
/**
@@ -44,7 +44,7 @@ class FilterDisableForm extends EntityConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->disable()->save();
- drupal_set_message($this->t('Disabled text format %format.', array('%format' => $this->entity->label())));
+ drupal_set_message($this->t('Disabled text format %format.', ['%format' => $this->entity->label()]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/core/modules/filter/src/Plugin/Filter/FilterAlign.php b/core/modules/filter/src/Plugin/Filter/FilterAlign.php
index c0e431ae3e0..a3739ab8246 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterAlign.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterAlign.php
@@ -33,9 +33,9 @@ class FilterAlign extends FilterBase {
$node->removeAttribute('data-align');
// If one of the allowed alignments, add the corresponding class.
- if (in_array($align, array('left', 'center', 'right'))) {
+ if (in_array($align, ['left', 'center', 'right'])) {
$classes = $node->getAttribute('class');
- $classes = (strlen($classes) > 0) ? explode(' ', $classes) : array();
+ $classes = (strlen($classes) > 0) ? explode(' ', $classes) : [];
$classes[] = 'align-' . $align;
$node->setAttribute('class', implode(' ', $classes));
}
diff --git a/core/modules/filter/src/Plugin/Filter/FilterCaption.php b/core/modules/filter/src/Plugin/Filter/FilterCaption.php
index c23f1f784fa..62c83950369 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterCaption.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterCaption.php
@@ -40,7 +40,7 @@ class FilterCaption extends FilterBase {
// Sanitize caption: decode HTML encoding, limit allowed HTML tags; only
// allow inline tags that are allowed by default, plus <br>.
$caption = Html::decodeEntities($caption);
- $caption = FilteredMarkup::create(Xss::filter($caption, array('a', 'em', 'strong', 'cite', 'code', 'br')));
+ $caption = FilteredMarkup::create(Xss::filter($caption, ['a', 'em', 'strong', 'cite', 'code', 'br']));
// The caption must be non-empty.
if (Unicode::strlen($caption) === 0) {
@@ -54,7 +54,7 @@ class FilterCaption extends FilterBase {
$classes = $node->getAttribute('class');
$node->removeAttribute('class');
$node = ($node->parentNode->tagName === 'a') ? $node->parentNode : $node;
- $filter_caption = array(
+ $filter_caption = [
'#theme' => 'filter_caption',
// We pass the unsanitized string because this is a text format
// filter, and after filtering, we always assume the output is safe.
@@ -63,7 +63,7 @@ class FilterCaption extends FilterBase {
'#tag' => $tag,
'#caption' => $caption,
'#classes' => $classes,
- );
+ ];
$altered_html = drupal_render($filter_caption);
// Load the altered HTML into a new DOMDocument and retrieve the element.
@@ -82,11 +82,11 @@ class FilterCaption extends FilterBase {
}
$result->setProcessedText(Html::serialize($dom))
- ->addAttachments(array(
- 'library' => array(
+ ->addAttachments([
+ 'library' => [
'filter/caption',
- ),
- ));
+ ],
+ ]);
}
return $result;
diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
index 1dc71fba01e..882bcc0e166 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
@@ -40,27 +40,27 @@ class FilterHtml extends FilterBase {
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $form['allowed_html'] = array(
+ $form['allowed_html'] = [
'#type' => 'textarea',
'#title' => $this->t('Allowed HTML tags'),
'#default_value' => $this->settings['allowed_html'],
'#description' => $this->t('A list of HTML tags that can be used. By default only the <em>lang</em> and <em>dir</em> attributes are allowed for all HTML tags. Each HTML tag may have attributes which are treated as allowed attribute names for that HTML tag. Each attribute may allow all values, or only allow specific values. Attribute names or values may be written as a prefix and wildcard like <em>jump-*</em>. JavaScript event attributes, JavaScript URLs, and CSS are always stripped.'),
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'filter/drupal.filter.filter_html.admin',
- ),
- ),
- );
- $form['filter_html_help'] = array(
+ ],
+ ],
+ ];
+ $form['filter_html_help'] = [
'#type' => 'checkbox',
'#title' => $this->t('Display basic HTML help in long filter tips'),
'#default_value' => $this->settings['filter_html_help'],
- );
- $form['filter_html_nofollow'] = array(
+ ];
+ $form['filter_html_nofollow'] = [
'#type' => 'checkbox',
'#title' => $this->t('Add rel="nofollow" to all links'),
'#default_value' => $this->settings['filter_html_nofollow'],
- );
+ ];
return $form;
}
@@ -339,7 +339,7 @@ class FilterHtml extends FilterBase {
if (!($allowed_html = $this->settings['allowed_html'])) {
return;
}
- $output = $this->t('Allowed HTML tags: @tags', array('@tags' => $allowed_html));
+ $output = $this->t('Allowed HTML tags: @tags', ['@tags' => $allowed_html]);
if (!$long) {
return $output;
}
@@ -350,117 +350,117 @@ class FilterHtml extends FilterBase {
}
$output .= '<p>' . $this->t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '</p>';
- $output .= '<p>' . $this->t('For more information see W3C\'s <a href=":html-specifications">HTML Specifications</a> or use your favorite search engine to find other sites that explain HTML.', array(':html-specifications' => 'http://www.w3.org/TR/html/')) . '</p>';
- $tips = array(
- 'a' => array($this->t('Anchors are used to make links to other pages.'), '<a href="' . $base_url . '">' . Html::escape(\Drupal::config('system.site')->get('name')) . '</a>'),
- 'br' => array($this->t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), $this->t('Text with <br />line break')),
- 'p' => array($this->t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '<p>' . $this->t('Paragraph one.') . '</p> <p>' . $this->t('Paragraph two.') . '</p>'),
- 'strong' => array($this->t('Strong', array(), array('context' => 'Font weight')), '<strong>' . $this->t('Strong', array(), array('context' => 'Font weight')) . '</strong>'),
- 'em' => array($this->t('Emphasized'), '<em>' . $this->t('Emphasized') . '</em>'),
- 'cite' => array($this->t('Cited'), '<cite>' . $this->t('Cited') . '</cite>'),
- 'code' => array($this->t('Coded text used to show programming source code'), '<code>' . $this->t('Coded') . '</code>'),
- 'b' => array($this->t('Bolded'), '<b>' . $this->t('Bolded') . '</b>'),
- 'u' => array($this->t('Underlined'), '<u>' . $this->t('Underlined') . '</u>'),
- 'i' => array($this->t('Italicized'), '<i>' . $this->t('Italicized') . '</i>'),
- 'sup' => array($this->t('Superscripted'), $this->t('<sup>Super</sup>scripted')),
- 'sub' => array($this->t('Subscripted'), $this->t('<sub>Sub</sub>scripted')),
- 'pre' => array($this->t('Preformatted'), '<pre>' . $this->t('Preformatted') . '</pre>'),
- 'abbr' => array($this->t('Abbreviation'), $this->t('<abbr title="Abbreviation">Abbrev.</abbr>')),
- 'acronym' => array($this->t('Acronym'), $this->t('<acronym title="Three-Letter Acronym">TLA</acronym>')),
- 'blockquote' => array($this->t('Block quoted'), '<blockquote>' . $this->t('Block quoted') . '</blockquote>'),
- 'q' => array($this->t('Quoted inline'), '<q>' . $this->t('Quoted inline') . '</q>'),
+ $output .= '<p>' . $this->t('For more information see W3C\'s <a href=":html-specifications">HTML Specifications</a> or use your favorite search engine to find other sites that explain HTML.', [':html-specifications' => 'http://www.w3.org/TR/html/']) . '</p>';
+ $tips = [
+ 'a' => [$this->t('Anchors are used to make links to other pages.'), '<a href="' . $base_url . '">' . Html::escape(\Drupal::config('system.site')->get('name')) . '</a>'],
+ 'br' => [$this->t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), $this->t('Text with <br />line break')],
+ 'p' => [$this->t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '<p>' . $this->t('Paragraph one.') . '</p> <p>' . $this->t('Paragraph two.') . '</p>'],
+ 'strong' => [$this->t('Strong', [], ['context' => 'Font weight']), '<strong>' . $this->t('Strong', [], ['context' => 'Font weight']) . '</strong>'],
+ 'em' => [$this->t('Emphasized'), '<em>' . $this->t('Emphasized') . '</em>'],
+ 'cite' => [$this->t('Cited'), '<cite>' . $this->t('Cited') . '</cite>'],
+ 'code' => [$this->t('Coded text used to show programming source code'), '<code>' . $this->t('Coded') . '</code>'],
+ 'b' => [$this->t('Bolded'), '<b>' . $this->t('Bolded') . '</b>'],
+ 'u' => [$this->t('Underlined'), '<u>' . $this->t('Underlined') . '</u>'],
+ 'i' => [$this->t('Italicized'), '<i>' . $this->t('Italicized') . '</i>'],
+ 'sup' => [$this->t('Superscripted'), $this->t('<sup>Super</sup>scripted')],
+ 'sub' => [$this->t('Subscripted'), $this->t('<sub>Sub</sub>scripted')],
+ 'pre' => [$this->t('Preformatted'), '<pre>' . $this->t('Preformatted') . '</pre>'],
+ 'abbr' => [$this->t('Abbreviation'), $this->t('<abbr title="Abbreviation">Abbrev.</abbr>')],
+ 'acronym' => [$this->t('Acronym'), $this->t('<acronym title="Three-Letter Acronym">TLA</acronym>')],
+ 'blockquote' => [$this->t('Block quoted'), '<blockquote>' . $this->t('Block quoted') . '</blockquote>'],
+ 'q' => [$this->t('Quoted inline'), '<q>' . $this->t('Quoted inline') . '</q>'],
// Assumes and describes tr, td, th.
- 'table' => array($this->t('Table'), '<table> <tr><th>' . $this->t('Table header') . '</th></tr> <tr><td>' . $this->t('Table cell') . '</td></tr> </table>'),
+ 'table' => [$this->t('Table'), '<table> <tr><th>' . $this->t('Table header') . '</th></tr> <tr><td>' . $this->t('Table cell') . '</td></tr> </table>'],
'tr' => NULL, 'td' => NULL, 'th' => NULL,
- 'del' => array($this->t('Deleted'), '<del>' . $this->t('Deleted') . '</del>'),
- 'ins' => array($this->t('Inserted'), '<ins>' . $this->t('Inserted') . '</ins>'),
+ 'del' => [$this->t('Deleted'), '<del>' . $this->t('Deleted') . '</del>'],
+ 'ins' => [$this->t('Inserted'), '<ins>' . $this->t('Inserted') . '</ins>'],
// Assumes and describes li.
- 'ol' => array($this->t('Ordered list - use the &lt;li&gt; to begin each list item'), '<ol> <li>' . $this->t('First item') . '</li> <li>' . $this->t('Second item') . '</li> </ol>'),
- 'ul' => array($this->t('Unordered list - use the &lt;li&gt; to begin each list item'), '<ul> <li>' . $this->t('First item') . '</li> <li>' . $this->t('Second item') . '</li> </ul>'),
+ 'ol' => [$this->t('Ordered list - use the &lt;li&gt; to begin each list item'), '<ol> <li>' . $this->t('First item') . '</li> <li>' . $this->t('Second item') . '</li> </ol>'],
+ 'ul' => [$this->t('Unordered list - use the &lt;li&gt; to begin each list item'), '<ul> <li>' . $this->t('First item') . '</li> <li>' . $this->t('Second item') . '</li> </ul>'],
'li' => NULL,
// Assumes and describes dt and dd.
- 'dl' => array($this->t('Definition lists are similar to other HTML lists. &lt;dl&gt; begins the definition list, &lt;dt&gt; begins the definition term and &lt;dd&gt; begins the definition description.'), '<dl> <dt>' . $this->t('First term') . '</dt> <dd>' . $this->t('First definition') . '</dd> <dt>' . $this->t('Second term') . '</dt> <dd>' . $this->t('Second definition') . '</dd> </dl>'),
+ 'dl' => [$this->t('Definition lists are similar to other HTML lists. &lt;dl&gt; begins the definition list, &lt;dt&gt; begins the definition term and &lt;dd&gt; begins the definition description.'), '<dl> <dt>' . $this->t('First term') . '</dt> <dd>' . $this->t('First definition') . '</dd> <dt>' . $this->t('Second term') . '</dt> <dd>' . $this->t('Second definition') . '</dd> </dl>'],
'dt' => NULL, 'dd' => NULL,
- 'h1' => array($this->t('Heading'), '<h1>' . $this->t('Title') . '</h1>'),
- 'h2' => array($this->t('Heading'), '<h2>' . $this->t('Subtitle') . '</h2>'),
- 'h3' => array($this->t('Heading'), '<h3>' . $this->t('Subtitle three') . '</h3>'),
- 'h4' => array($this->t('Heading'), '<h4>' . $this->t('Subtitle four') . '</h4>'),
- 'h5' => array($this->t('Heading'), '<h5>' . $this->t('Subtitle five') . '</h5>'),
- 'h6' => array($this->t('Heading'), '<h6>' . $this->t('Subtitle six') . '</h6>')
- );
- $header = array($this->t('Tag Description'), $this->t('You Type'), $this->t('You Get'));
+ 'h1' => [$this->t('Heading'), '<h1>' . $this->t('Title') . '</h1>'],
+ 'h2' => [$this->t('Heading'), '<h2>' . $this->t('Subtitle') . '</h2>'],
+ 'h3' => [$this->t('Heading'), '<h3>' . $this->t('Subtitle three') . '</h3>'],
+ 'h4' => [$this->t('Heading'), '<h4>' . $this->t('Subtitle four') . '</h4>'],
+ 'h5' => [$this->t('Heading'), '<h5>' . $this->t('Subtitle five') . '</h5>'],
+ 'h6' => [$this->t('Heading'), '<h6>' . $this->t('Subtitle six') . '</h6>']
+ ];
+ $header = [$this->t('Tag Description'), $this->t('You Type'), $this->t('You Get')];
preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out);
foreach ($out[1] as $tag) {
if (!empty($tips[$tag])) {
- $rows[] = array(
- array('data' => $tips[$tag][0], 'class' => array('description')),
+ $rows[] = [
+ ['data' => $tips[$tag][0], 'class' => ['description']],
// The markup must be escaped because this is the example code for the
// user.
- array('data' =>
- array(
+ ['data' =>
+ [
'#prefix' => '<code>',
'#plain_text' => $tips[$tag][1],
'#suffix' => '</code>'
- ),
- 'class' => array('type')),
+ ],
+ 'class' => ['type']],
// The markup must not be escaped because this is the example output
// for the user.
- array('data' =>
- array('#markup' => $tips[$tag][1]),
- 'class' => array('get'),
- ),
- );
+ ['data' =>
+ ['#markup' => $tips[$tag][1]],
+ 'class' => ['get'],
+ ],
+ ];
}
else {
- $rows[] = array(
- array('data' => $this->t('No help provided for tag %tag.', array('%tag' => $tag)), 'class' => array('description'), 'colspan' => 3),
- );
+ $rows[] = [
+ ['data' => $this->t('No help provided for tag %tag.', ['%tag' => $tag]), 'class' => ['description'], 'colspan' => 3],
+ ];
}
}
- $table = array(
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- );
+ ];
$output .= drupal_render($table);
$output .= '<p>' . $this->t('Most unusual characters can be directly entered without any problems.') . '</p>';
- $output .= '<p>' . $this->t('If you do encounter problems, try using HTML character entities. A common example looks like &amp;amp; for an ampersand &amp; character. For a full list of entities see HTML\'s <a href=":html-entities">entities</a> page. Some of the available characters include:', array(':html-entities' => 'http://www.w3.org/TR/html4/sgml/entities.html')) . '</p>';
+ $output .= '<p>' . $this->t('If you do encounter problems, try using HTML character entities. A common example looks like &amp;amp; for an ampersand &amp; character. For a full list of entities see HTML\'s <a href=":html-entities">entities</a> page. Some of the available characters include:', [':html-entities' => 'http://www.w3.org/TR/html4/sgml/entities.html']) . '</p>';
- $entities = array(
- array($this->t('Ampersand'), '&amp;'),
- array($this->t('Greater than'), '&gt;'),
- array($this->t('Less than'), '&lt;'),
- array($this->t('Quotation mark'), '&quot;'),
- );
- $header = array($this->t('Character Description'), $this->t('You Type'), $this->t('You Get'));
+ $entities = [
+ [$this->t('Ampersand'), '&amp;'],
+ [$this->t('Greater than'), '&gt;'],
+ [$this->t('Less than'), '&lt;'],
+ [$this->t('Quotation mark'), '&quot;'],
+ ];
+ $header = [$this->t('Character Description'), $this->t('You Type'), $this->t('You Get')];
unset($rows);
foreach ($entities as $entity) {
- $rows[] = array(
- array('data' => $entity[0], 'class' => array('description')),
+ $rows[] = [
+ ['data' => $entity[0], 'class' => ['description']],
// The markup must be escaped because this is the example code for the
// user.
- array(
- 'data' => array(
+ [
+ 'data' => [
'#prefix' => '<code>',
'#plain_text' => $entity[1],
'#suffix' => '</code>',
- ),
- 'class' => array('type'),
- ),
+ ],
+ 'class' => ['type'],
+ ],
// The markup must not be escaped because this is the example output
// for the user.
- array(
- 'data' => array('#markup' => $entity[1]),
- 'class' => array('get'),
- ),
- );
+ [
+ 'data' => ['#markup' => $entity[1]],
+ 'class' => ['get'],
+ ],
+ ];
}
- $table = array(
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- );
+ ];
$output .= drupal_render($table);
return $output;
}
diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php b/core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php
index 24a37417ab9..a99945f5cc7 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php
@@ -29,7 +29,7 @@ class FilterHtmlEscape extends FilterBase {
*/
public function getHTMLRestrictions() {
// Nothing is allowed.
- return array('allowed' => array());
+ return ['allowed' => []];
}
/**
diff --git a/core/modules/filter/src/Plugin/Filter/FilterNull.php b/core/modules/filter/src/Plugin/Filter/FilterNull.php
index 032a6e040d6..afac124bdfe 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterNull.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterNull.php
@@ -35,7 +35,7 @@ class FilterNull extends FilterBase {
// Once per filter, log that a filter plugin was missing.
if (!$this->logged) {
$this->logged = TRUE;
- \Drupal::logger('filter')->alert('Missing filter plugin: %filter.', array('%filter' => $plugin_id));
+ \Drupal::logger('filter')->alert('Missing filter plugin: %filter.', ['%filter' => $plugin_id]);
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
@@ -52,7 +52,7 @@ class FilterNull extends FilterBase {
*/
public function getHTMLRestrictions() {
// Nothing is allowed.
- return array('allowed' => array());
+ return ['allowed' => []];
}
/**
diff --git a/core/modules/filter/src/Plugin/Filter/FilterUrl.php b/core/modules/filter/src/Plugin/Filter/FilterUrl.php
index 97c226a3596..d3d2c96b0e5 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterUrl.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterUrl.php
@@ -24,14 +24,14 @@ class FilterUrl extends FilterBase {
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $form['filter_url_length'] = array(
+ $form['filter_url_length'] = [
'#type' => 'number',
'#title' => $this->t('Maximum link text length'),
'#default_value' => $this->settings['filter_url_length'],
'#min' => 1,
'#field_suffix' => $this->t('characters'),
'#description' => $this->t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
- );
+ ];
return $form;
}
diff --git a/core/modules/filter/src/Plugin/FilterBase.php b/core/modules/filter/src/Plugin/FilterBase.php
index 6f7f5e344d8..11e385f27ad 100644
--- a/core/modules/filter/src/Plugin/FilterBase.php
+++ b/core/modules/filter/src/Plugin/FilterBase.php
@@ -41,7 +41,7 @@ abstract class FilterBase extends PluginBase implements FilterInterface {
*
* @var array
*/
- public $settings = array();
+ public $settings = [];
/**
* {@inheritdoc}
@@ -74,32 +74,32 @@ abstract class FilterBase extends PluginBase implements FilterInterface {
* {@inheritdoc}
*/
public function getConfiguration() {
- return array(
+ return [
'id' => $this->getPluginId(),
'provider' => $this->pluginDefinition['provider'],
'status' => $this->status,
'weight' => $this->weight,
'settings' => $this->settings,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'provider' => $this->pluginDefinition['provider'],
'status' => FALSE,
'weight' => $this->pluginDefinition['weight'] ?: 0,
'settings' => $this->pluginDefinition['settings'],
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
/**
@@ -130,7 +130,7 @@ abstract class FilterBase extends PluginBase implements FilterInterface {
// Implementations should work with and return $form. Returning an empty
// array here allows the text format administration form to identify whether
// the filter plugin has any settings form elements.
- return array();
+ return [];
}
/**
diff --git a/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php b/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php
index d0e6143fa09..8c7a160167c 100644
--- a/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php
+++ b/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php
@@ -45,7 +45,7 @@ class FilterFormatPermission extends ProcessPluginBase implements ContainerFacto
$plugin_id,
$plugin_definition,
$migration,
- $container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_filter_format'), $migration)
+ $container->get('plugin.manager.migrate.process')->createInstance('migration', ['migration' => 'd6_filter_format'], $migration)
);
}
diff --git a/core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php b/core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php
index 0932773561d..54b33d48dc7 100644
--- a/core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php
+++ b/core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php
@@ -25,37 +25,37 @@ class FilterFormat extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'format' => $this->t('Format ID.'),
'name' => $this->t('The name of the format.'),
'cache' => $this->t('Whether the format is cacheable.'),
'roles' => $this->t('The role IDs which can use the format.'),
'filters' => $this->t('The filters configured for the format.'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
- $filters = array();
+ $filters = [];
$roles = $row->getSourceProperty('roles');
$row->setSourceProperty('roles', array_values(array_filter(explode(',', $roles))));
$format = $row->getSourceProperty('format');
// Find filters for this row.
$results = $this->select('filters', 'f')
- ->fields('f', array('module', 'delta', 'weight'))
+ ->fields('f', ['module', 'delta', 'weight'])
->condition('format', $format)
->execute();
foreach ($results as $raw_filter) {
$module = $raw_filter['module'];
$delta = $raw_filter['delta'];
- $filter = array(
+ $filter = [
'module' => $module,
'delta' => $delta,
'weight' => $raw_filter['weight'],
- 'settings' => array(),
- );
+ 'settings' => [],
+ ];
// Load the filter settings for the filter module, modules can use
// hook_migration_d6_filter_formats_prepare_row() to add theirs.
if ($raw_filter['module'] == 'filter') {
diff --git a/core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php b/core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php
index c166dcded80..55c28111000 100644
--- a/core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php
+++ b/core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php
@@ -25,14 +25,14 @@ class FilterFormat extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'format' => $this->t('Format ID.'),
'name' => $this->t('The name of the format.'),
'cache' => $this->t('Whether the format is cacheable.'),
'status' => $this->t('The status of the format'),
'weight' => $this->t('The weight of the format'),
'filters' => $this->t('The filters configured for the format.'),
- );
+ ];
}
/**
diff --git a/core/modules/filter/src/Tests/FilterAdminTest.php b/core/modules/filter/src/Tests/FilterAdminTest.php
index 830cf18d776..b967101ec1f 100644
--- a/core/modules/filter/src/Tests/FilterAdminTest.php
+++ b/core/modules/filter/src/Tests/FilterAdminTest.php
@@ -42,67 +42,67 @@ class FilterAdminTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Set up the filter formats used by this test.
- $basic_html_format = FilterFormat::create(array(
+ $basic_html_format = FilterFormat::create([
'format' => 'basic_html',
'name' => 'Basic HTML',
- 'filters' => array(
- 'filter_html' => array(
+ 'filters' => [
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<p> <br> <strong> <a> <em>',
- ),
- ),
- ),
- ));
+ ],
+ ],
+ ],
+ ]);
$basic_html_format->save();
- $restricted_html_format = FilterFormat::create(array(
+ $restricted_html_format = FilterFormat::create([
'format' => 'restricted_html',
'name' => 'Restricted HTML',
- 'filters' => array(
- 'filter_html' => array(
+ 'filters' => [
+ 'filter_html' => [
'status' => TRUE,
'weight' => -10,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<p> <br> <strong> <a> <em> <h4>',
- ),
- ),
- 'filter_autop' => array(
+ ],
+ ],
+ 'filter_autop' => [
'status' => TRUE,
'weight' => 0,
- ),
- 'filter_url' => array(
+ ],
+ 'filter_url' => [
'status' => TRUE,
'weight' => 0,
- ),
- 'filter_htmlcorrector' => array(
+ ],
+ 'filter_htmlcorrector' => [
'status' => TRUE,
'weight' => 10,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$restricted_html_format->save();
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$full_html_format->save();
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer filters',
$basic_html_format->getPermissionName(),
$restricted_html_format->getPermissionName(),
$full_html_format->getPermissionName(),
'access site reports',
- ));
+ ]);
- $this->webUser = $this->drupalCreateUser(array('create page content', 'edit own page content'));
- user_role_grant_permissions('authenticated', array($basic_html_format->getPermissionName()));
- user_role_grant_permissions('anonymous', array($restricted_html_format->getPermissionName()));
+ $this->webUser = $this->drupalCreateUser(['create page content', 'edit own page content']);
+ user_role_grant_permissions('authenticated', [$basic_html_format->getPermissionName()]);
+ user_role_grant_permissions('anonymous', [$restricted_html_format->getPermissionName()]);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_actions_block');
}
@@ -116,10 +116,10 @@ class FilterAdminTest extends WebTestBase {
$this->clickLink('Add text format');
$format_id = Unicode::strtolower($this->randomMachineName());
$name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'format' => $format_id,
'name' => $name,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
// Verify default weight of the text format.
@@ -127,9 +127,9 @@ class FilterAdminTest extends WebTestBase {
$this->assertFieldByName("formats[$format_id][weight]", 0, 'Text format weight was saved.');
// Change the weight of the text format.
- $edit = array(
+ $edit = [
"formats[$format_id][weight]" => 5,
- );
+ ];
$this->drupalPostForm('admin/config/content/formats', $edit, t('Save'));
$this->assertFieldByName("formats[$format_id][weight]", 5, 'Text format weight was saved.');
@@ -139,14 +139,14 @@ class FilterAdminTest extends WebTestBase {
// and 'admin/config/content/formats/manage/' . $format_id . '/disable'
// exists.
// @todo: See https://www.drupal.org/node/2031223 for the above.
- $edit_link = $this->xpath('//a[@href=:href]', array(
+ $edit_link = $this->xpath('//a[@href=:href]', [
':href' => \Drupal::url('entity.filter_format.edit_form', ['filter_format' => $format_id])
- ));
+ ]);
$this->assertTrue($edit_link, format_string('Link href %href found.',
- array('%href' => 'admin/config/content/formats/manage/' . $format_id)
+ ['%href' => 'admin/config/content/formats/manage/' . $format_id]
));
$this->drupalGet('admin/config/content/formats/manage/' . $format_id);
- $this->drupalPostForm(NULL, array(), t('Save configuration'));
+ $this->drupalPostForm(NULL, [], t('Save configuration'));
// Verify that the custom weight of the text format has been retained.
$this->drupalGet('admin/config/content/formats');
@@ -155,7 +155,7 @@ class FilterAdminTest extends WebTestBase {
// Disable text format.
$this->assertLinkByHref('admin/config/content/formats/manage/' . $format_id . '/disable');
$this->drupalGet('admin/config/content/formats/manage/' . $format_id . '/disable');
- $this->drupalPostForm(NULL, array(), t('Disable'));
+ $this->drupalPostForm(NULL, [], t('Disable'));
// Verify that disabled text format no longer exists.
$this->drupalGet('admin/config/content/formats/manage/' . $format_id);
@@ -163,23 +163,23 @@ class FilterAdminTest extends WebTestBase {
// Attempt to create a format of the same machine name as the disabled
// format but with a different human readable name.
- $edit = array(
+ $edit = [
'format' => $format_id,
'name' => 'New format',
- );
+ ];
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->assertText('The machine-readable name is already in use. It must be unique.');
// Attempt to create a format of the same human readable name as the
// disabled format but with a different machine name.
- $edit = array(
+ $edit = [
'format' => 'new_format',
'name' => $name,
- );
+ ];
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
- $this->assertRaw(t('Text format names must be unique. A format named %name already exists.', array(
+ $this->assertRaw(t('Text format names must be unique. A format named %name already exists.', [
'%name' => $name,
- )));
+ ]));
}
/**
@@ -207,21 +207,21 @@ class FilterAdminTest extends WebTestBase {
$this->assertFalse($full_format->access('use', $this->webUser), 'Web user may not use Full HTML.');
// Add an additional tag and extra spaces and returns.
- $edit = array();
+ $edit = [];
$edit['filters[filter_html][settings][allowed_html]'] = "<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>\r\n<quote>";
$this->drupalPostForm('admin/config/content/formats/manage/' . $restricted, $edit, t('Save configuration'));
$this->assertUrl('admin/config/content/formats');
$this->drupalGet('admin/config/content/formats/manage/' . $restricted);
$this->assertFieldByName('filters[filter_html][settings][allowed_html]', "<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote>", 'Allowed HTML tag added.');
- $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array(
+ $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', [
':first' => 'filters[' . $first_filter . '][weight]',
':second' => 'filters[' . $second_filter . '][weight]',
- ));
+ ]);
$this->assertTrue(!empty($elements), 'Order confirmed in admin interface.');
// Reorder filters.
- $edit = array();
+ $edit = [];
$edit['filters[' . $second_filter . '][weight]'] = 1;
$edit['filters[' . $first_filter . '][weight]'] = 2;
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
@@ -230,10 +230,10 @@ class FilterAdminTest extends WebTestBase {
$this->assertFieldByName('filters[' . $second_filter . '][weight]', 1, 'Order saved successfully.');
$this->assertFieldByName('filters[' . $first_filter . '][weight]', 2, 'Order saved successfully.');
- $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array(
+ $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', [
':first' => 'filters[' . $second_filter . '][weight]',
':second' => 'filters[' . $first_filter . '][weight]',
- ));
+ ]);
$this->assertTrue(!empty($elements), 'Reorder confirmed in admin interface.');
$filter_format = FilterFormat::load($restricted);
@@ -246,7 +246,7 @@ class FilterAdminTest extends WebTestBase {
$this->assertEqual($filter_format->filters($second_filter)->weight + 1, $filter_format->filters($first_filter)->weight, 'Order confirmed in configuration.');
// Add format.
- $edit = array();
+ $edit = [];
$edit['format'] = Unicode::strtolower($this->randomMachineName());
$edit['name'] = $this->randomMachineName();
$edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
@@ -254,7 +254,7 @@ class FilterAdminTest extends WebTestBase {
$edit['filters[' . $first_filter . '][status]'] = TRUE;
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->assertUrl('admin/config/content/formats');
- $this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), 'New filter created.');
+ $this->assertRaw(t('Added text format %format.', ['%format' => $edit['name']]), 'New filter created.');
filter_formats_reset();
$format = FilterFormat::load($edit['format']);
@@ -265,18 +265,18 @@ class FilterAdminTest extends WebTestBase {
$this->assertFieldByName('filters[' . $first_filter . '][status]', '', 'URL filter found.');
// Disable new filter.
- $this->drupalPostForm('admin/config/content/formats/manage/' . $format->id() . '/disable', array(), t('Disable'));
+ $this->drupalPostForm('admin/config/content/formats/manage/' . $format->id() . '/disable', [], t('Disable'));
$this->assertUrl('admin/config/content/formats');
- $this->assertRaw(t('Disabled text format %format.', array('%format' => $edit['name'])), 'Format successfully disabled.');
+ $this->assertRaw(t('Disabled text format %format.', ['%format' => $edit['name']]), 'Format successfully disabled.');
// Allow authenticated users on full HTML.
$format = FilterFormat::load($full);
- $edit = array();
+ $edit = [];
$edit['roles[' . RoleInterface::ANONYMOUS_ID . ']'] = 0;
$edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
$this->drupalPostForm('admin/config/content/formats/manage/' . $full, $edit, t('Save configuration'));
$this->assertUrl('admin/config/content/formats');
- $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->label())), 'Full HTML format successfully updated.');
+ $this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]), 'Full HTML format successfully updated.');
// Switch user.
$this->drupalLogin($this->webUser);
@@ -289,15 +289,15 @@ class FilterAdminTest extends WebTestBase {
$extra_text = 'text';
$text = $body . '<random>' . $extra_text . '</random>';
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $text;
$edit['body[0][format]'] = $basic;
$this->drupalPostForm('node/add/page', $edit, t('Save'));
- $this->assertText(t('Basic page @title has been created.', array('@title' => $edit['title[0][value]'])), 'Filtered node created.');
+ $this->assertText(t('Basic page @title has been created.', ['@title' => $edit['title[0][value]']]), 'Filtered node created.');
// Verify that the creation message contains a link to a node.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']);
$this->assert(isset($view_link), 'The message area contains a link to a node');
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
@@ -312,7 +312,7 @@ class FilterAdminTest extends WebTestBase {
$this->config('filter.settings')
->set('always_show_fallback_choice', TRUE)
->save();
- $edit = array();
+ $edit = [];
$edit['body[0][format]'] = $plain;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->drupalGet('node/' . $node->id());
@@ -326,7 +326,7 @@ class FilterAdminTest extends WebTestBase {
// Clean up.
// Allowed tags.
- $edit = array();
+ $edit = [];
$edit['filters[filter_html][settings][allowed_html]'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>';
$this->drupalPostForm('admin/config/content/formats/manage/' . $basic, $edit, t('Save configuration'));
$this->assertUrl('admin/config/content/formats');
@@ -334,16 +334,16 @@ class FilterAdminTest extends WebTestBase {
$this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], 'Changes reverted.');
// Full HTML.
- $edit = array();
+ $edit = [];
$edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = FALSE;
$this->drupalPostForm('admin/config/content/formats/manage/' . $full, $edit, t('Save configuration'));
$this->assertUrl('admin/config/content/formats');
- $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->label())), 'Full HTML format successfully reverted.');
+ $this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]), 'Full HTML format successfully reverted.');
$this->drupalGet('admin/config/content/formats/manage/' . $full);
$this->assertFieldByName('roles[' . RoleInterface::AUTHENTICATED_ID . ']', $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'], 'Changes reverted.');
// Filter order.
- $edit = array();
+ $edit = [];
$edit['filters[' . $second_filter . '][weight]'] = 2;
$edit['filters[' . $first_filter . '][weight]'] = 1;
$this->drupalPostForm('admin/config/content/formats/manage/' . $basic, $edit, t('Save configuration'));
@@ -358,11 +358,11 @@ class FilterAdminTest extends WebTestBase {
*/
function testUrlFilterAdmin() {
// The form does not save with an invalid filter URL length.
- $edit = array(
+ $edit = [
'filters[filter_url][settings][filter_url_length]' => $this->randomMachineName(4),
- );
+ ];
$this->drupalPostForm('admin/config/content/formats/manage/basic_html', $edit, t('Save configuration'));
- $this->assertNoRaw(t('The text format %format has been updated.', array('%format' => 'Basic HTML')));
+ $this->assertNoRaw(t('The text format %format has been updated.', ['%format' => 'Basic HTML']));
}
/**
diff --git a/core/modules/filter/src/Tests/FilterFormTest.php b/core/modules/filter/src/Tests/FilterFormTest.php
index 24bbc158aeb..9d0641e41bd 100644
--- a/core/modules/filter/src/Tests/FilterFormTest.php
+++ b/core/modules/filter/src/Tests/FilterFormTest.php
@@ -18,7 +18,7 @@ class FilterFormTest extends WebTestBase {
*
* @var array
*/
- protected static $modules = array('filter', 'filter_test');
+ protected static $modules = ['filter', 'filter_test'];
/**
* An administrative user account that can administer text formats.
@@ -48,17 +48,17 @@ class FilterFormTest extends WebTestBase {
$full_html_format = FilterFormat::load('full_html');
// Create users.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer filters',
$filtered_html_format->getPermissionName(),
$full_html_format->getPermissionName(),
$filter_test_format->getPermissionName(),
- ));
+ ]);
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
$filtered_html_format->getPermissionName(),
$filter_test_format->getPermissionName(),
- ));
+ ]);
}
/**
@@ -83,7 +83,7 @@ class FilterFormTest extends WebTestBase {
$this->drupalGet('filter-test/text-format');
// Test a text format element with all formats.
- $formats = array('filtered_html', 'full_html', 'filter_test');
+ $formats = ['filtered_html', 'full_html', 'filter_test'];
$this->assertEnabledTextarea('edit-all-formats-no-default-value');
// If no default is given, the format with the lowest weight becomes the
// default.
@@ -98,7 +98,7 @@ class FilterFormTest extends WebTestBase {
$this->assertRequiredSelectAndOptions('edit-all-formats-default-missing-format--2', $formats);
// Test a text format element with a predefined list of formats.
- $formats = array('full_html', 'filter_test');
+ $formats = ['full_html', 'filter_test'];
$this->assertEnabledTextarea('edit-restricted-formats-no-default-value');
$this->assertOptions('edit-restricted-formats-no-default-format--2', $formats, 'full_html');
$this->assertEnabledTextarea('edit-restricted-formats-default-value');
@@ -109,7 +109,7 @@ class FilterFormTest extends WebTestBase {
$this->assertRequiredSelectAndOptions('edit-restricted-formats-default-disallowed-format--2', $formats);
// Test a text format element with a fixed format.
- $formats = array('filter_test');
+ $formats = ['filter_test'];
// When there is only a single option there is no point in choosing.
$this->assertEnabledTextarea('edit-single-format-no-default-value');
$this->assertNoSelect('edit-single-format-no-default-format--2');
@@ -132,7 +132,7 @@ class FilterFormTest extends WebTestBase {
// Test a text format element with all formats. Only formats the user has
// access to are shown.
- $formats = array('filtered_html', 'filter_test');
+ $formats = ['filtered_html', 'filter_test'];
$this->assertEnabledTextarea('edit-all-formats-no-default-value');
// If no default is given, the format with the lowest weight becomes the
// default. This happens to be 'filtered_html'.
@@ -178,10 +178,10 @@ class FilterFormTest extends WebTestBase {
* TRUE if the assertion passed; FALSE otherwise.
*/
protected function assertNoSelect($id) {
- $select = $this->xpath('//select[@id=:id]', array(':id' => $id));
- return $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', array(
+ $select = $this->xpath('//select[@id=:id]', [':id' => $id]);
+ return $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [
'@id' => $id,
- )));
+ ]));
}
/**
@@ -198,20 +198,20 @@ class FilterFormTest extends WebTestBase {
* TRUE if the assertion passed; FALSE otherwise.
*/
protected function assertOptions($id, array $expected_options, $selected) {
- $select = $this->xpath('//select[@id=:id]', array(':id' => $id));
+ $select = $this->xpath('//select[@id=:id]', [':id' => $id]);
$select = reset($select);
- $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Field @id exists.', array(
+ $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Field @id exists.', [
'@id' => $id,
- )));
+ ]));
$found_options = $this->getAllOptions($select);
foreach ($found_options as $found_key => $found_option) {
$expected_key = array_search($found_option->attributes()->value, $expected_options);
if ($expected_key !== FALSE) {
- $this->pass(SafeMarkup::format('Option @option for field @id exists.', array(
+ $this->pass(SafeMarkup::format('Option @option for field @id exists.', [
'@option' => $expected_options[$expected_key],
'@id' => $id,
- )));
+ ]));
unset($found_options[$found_key]);
unset($expected_options[$expected_key]);
}
@@ -220,17 +220,17 @@ class FilterFormTest extends WebTestBase {
// Make sure that all expected options were found and that there are no
// unexpected options.
foreach ($expected_options as $expected_option) {
- $this->fail(SafeMarkup::format('Option @option for field @id exists.', array(
+ $this->fail(SafeMarkup::format('Option @option for field @id exists.', [
'@option' => $expected_option,
'@id' => $id,
- )));
+ ]));
$passed = FALSE;
}
foreach ($found_options as $found_option) {
- $this->fail(SafeMarkup::format('Option @option for field @id does not exist.', array(
+ $this->fail(SafeMarkup::format('Option @option for field @id does not exist.', [
'@option' => $found_option->attributes()->value,
'@id' => $id,
- )));
+ ]));
$passed = FALSE;
}
@@ -250,13 +250,13 @@ class FilterFormTest extends WebTestBase {
* TRUE if the assertion passed; FALSE otherwise.
*/
protected function assertRequiredSelectAndOptions($id, array $options) {
- $select = $this->xpath('//select[@id=:id and contains(@required, "required")]', array(
+ $select = $this->xpath('//select[@id=:id and contains(@required, "required")]', [
':id' => $id,
- ));
+ ]);
$select = reset($select);
- $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Required field @id exists.', array(
+ $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Required field @id exists.', [
'@id' => $id,
- )));
+ ]));
// A required select element has a "- Select -" option whose key is an empty
// string.
$options[] = '';
@@ -273,13 +273,13 @@ class FilterFormTest extends WebTestBase {
* TRUE if the assertion passed; FALSE otherwise.
*/
protected function assertEnabledTextarea($id) {
- $textarea = $this->xpath('//textarea[@id=:id and not(contains(@disabled, "disabled"))]', array(
+ $textarea = $this->xpath('//textarea[@id=:id and not(contains(@disabled, "disabled"))]', [
':id' => $id,
- ));
+ ]);
$textarea = reset($textarea);
- return $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Enabled field @id exists.', array(
+ return $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Enabled field @id exists.', [
'@id' => $id,
- )));
+ ]));
}
/**
@@ -292,17 +292,17 @@ class FilterFormTest extends WebTestBase {
* TRUE if the assertion passed; FALSE otherwise.
*/
protected function assertDisabledTextarea($id) {
- $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', array(
+ $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [
':id' => $id,
- ));
+ ]);
$textarea = reset($textarea);
- $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', array(
+ $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', [
'@id' => $id,
- )));
+ ]));
$expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
- $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', array(
+ $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [
'@id' => $id,
- )));
+ ]));
// Make sure the text format select is not shown.
$select_id = str_replace('value', 'format--2', $id);
return $passed && $this->assertNoSelect($select_id);
diff --git a/core/modules/filter/src/Tests/FilterFormatAccessTest.php b/core/modules/filter/src/Tests/FilterFormatAccessTest.php
index 5f204046dcc..c306585b449 100644
--- a/core/modules/filter/src/Tests/FilterFormatAccessTest.php
+++ b/core/modules/filter/src/Tests/FilterFormatAccessTest.php
@@ -69,25 +69,25 @@ class FilterFormatAccessTest extends WebTestBase {
$this->drupalPlaceBlock('page_title_block');
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create a user who can administer text formats, but does not have
// specific permission to use any of them.
- $this->filterAdminUser = $this->drupalCreateUser(array(
+ $this->filterAdminUser = $this->drupalCreateUser([
'administer filters',
'create page content',
'edit any page content',
- ));
+ ]);
// Create three text formats. Two text formats are created for all users so
// that the drop-down list appears for all tests.
$this->drupalLogin($this->filterAdminUser);
- $formats = array();
+ $formats = [];
for ($i = 0; $i < 3; $i++) {
- $edit = array(
+ $edit = [
'format' => Unicode::strtolower($this->randomMachineName()),
'name' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->resetFilterCaches();
$formats[] = FilterFormat::load($edit['format']);
@@ -96,22 +96,22 @@ class FilterFormatAccessTest extends WebTestBase {
$this->drupalLogout();
// Create a regular user with access to two of the formats.
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'create page content',
'edit any page content',
$this->allowedFormat->getPermissionName(),
$this->secondAllowedFormat->getPermissionName(),
- ));
+ ]);
// Create an administrative user who has access to use all three formats.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer filters',
'create page content',
'edit any page content',
$this->allowedFormat->getPermissionName(),
$this->secondAllowedFormat->getPermissionName(),
$this->disallowedFormat->getPermissionName(),
- ));
+ ]);
$this->drupalPlaceBlock('local_tasks_block');
}
@@ -145,11 +145,11 @@ class FilterFormatAccessTest extends WebTestBase {
// the disallowed format does not.
$this->drupalLogin($this->webUser);
$this->drupalGet('node/add/page');
- $elements = $this->xpath('//select[@name=:name]/option', array(
+ $elements = $this->xpath('//select[@name=:name]/option', [
':name' => 'body[0][format]',
':option' => $this->allowedFormat->id(),
- ));
- $options = array();
+ ]);
+ $options = [];
foreach ($elements as $element) {
$options[(string) $element['value']] = $element;
}
@@ -218,7 +218,7 @@ class FilterFormatAccessTest extends WebTestBase {
// Create node to edit.
$this->drupalLogin($this->adminUser);
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit[$body_value_key] = $this->randomMachineName(16);
$edit[$body_format_key] = $this->disallowedFormat->id();
@@ -234,7 +234,7 @@ class FilterFormatAccessTest extends WebTestBase {
$this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.');
// Verify that title can be changed, but preview displays original body.
- $new_edit = array();
+ $new_edit = [];
$new_edit['title[0][value]'] = $this->randomMachineName(8);
$this->drupalPostForm(NULL, $new_edit, t('Preview'));
$this->assertText($edit[$body_value_key], 'Old body found in preview.');
@@ -276,10 +276,10 @@ class FilterFormatAccessTest extends WebTestBase {
// produces an error message, and does not result in the node being saved.
$old_title = $new_edit['title[0][value]'];
$new_title = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $new_title;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
- $this->assertText(t('@name field is required.', array('@name' => t('Text format'))), 'Error message is displayed.');
+ $this->assertText(t('@name field is required.', ['@name' => t('Text format')]), 'Error message is displayed.');
$this->drupalGet('node/' . $node->id());
$this->assertText($old_title, 'Old title found.');
$this->assertNoText($new_title, 'New title not found.');
@@ -294,7 +294,7 @@ class FilterFormatAccessTest extends WebTestBase {
// Switch the text format to a new one, then disable that format and all
// other formats on the site (leaving only the fallback format).
$this->drupalLogin($this->adminUser);
- $edit = array($body_format_key => $this->allowedFormat->id());
+ $edit = [$body_format_key => $this->allowedFormat->id()];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->assertUrl('node/' . $node->id());
foreach (filter_formats() as $format) {
@@ -311,10 +311,10 @@ class FilterFormatAccessTest extends WebTestBase {
$this->drupalLogin($this->filterAdminUser);
$old_title = $new_title;
$new_title = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $new_title;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
- $this->assertText(t('@name field is required.', array('@name' => t('Text format'))), 'Error message is displayed.');
+ $this->assertText(t('@name field is required.', ['@name' => t('Text format')]), 'Error message is displayed.');
$this->drupalGet('node/' . $node->id());
$this->assertText($old_title, 'Old title found.');
$this->assertNoText($new_title, 'New title not found.');
diff --git a/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php b/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php
index 5ce4e6d6b84..5cbdbb0b728 100644
--- a/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php
+++ b/core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php
@@ -21,7 +21,7 @@ class FilterHtmlImageSecureTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'node', 'comment');
+ public static $modules = ['filter', 'node', 'comment'];
/**
* An authenticated user.
@@ -34,38 +34,38 @@ class FilterHtmlImageSecureTest extends WebTestBase {
parent::setUp();
// Setup Filtered HTML text format.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
- 'filters' => array(
- 'filter_html' => array(
+ 'filters' => [
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<img src testattribute> <a>',
- ),
- ),
- 'filter_autop' => array(
+ ],
+ ],
+ 'filter_autop' => [
'status' => 1,
- ),
- 'filter_html_image_secure' => array(
+ ],
+ 'filter_html_image_secure' => [
'status' => 1,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$filtered_html_format->save();
// Setup users.
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'access content',
'access comments',
'post comments',
'skip comment approval',
$filtered_html_format->getPermissionName(),
- ));
+ ]);
$this->drupalLogin($this->webUser);
// Setup a node to comment and test on.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Add a comment field.
$this->addDefaultCommentField('node', 'page');
$this->node = $this->drupalCreateNode();
@@ -104,7 +104,7 @@ class FilterHtmlImageSecureTest extends WebTestBase {
// expected filter conversions.
$host = \Drupal::request()->getHost();
$host_pattern = '|^http\://' . $host . '(\:[0-9]{0,5})|';
- $images = array(
+ $images = [
$http_base_url . '/' . $druplicon => base_path() . $druplicon,
$https_base_url . '/' . $druplicon => base_path() . $druplicon,
// Test a url that includes a port.
@@ -123,8 +123,8 @@ class FilterHtmlImageSecureTest extends WebTestBase {
'https://example.com/' . $druplicon => $red_x_image,
'javascript:druplicon.png' => $red_x_image,
$csrf_path . '/logout' => $red_x_image,
- );
- $comment = array();
+ ];
+ $comment = [];
foreach ($images as $image => $converted) {
// Output the image source as plain text for debugging.
$comment[] = $image . ':';
@@ -132,9 +132,9 @@ class FilterHtmlImageSecureTest extends WebTestBase {
// contain characters that confuse XPath.
$comment[] = '<img src="' . $image . '" testattribute="' . hash('sha256', $image) . '" />';
}
- $edit = array(
+ $edit = [
'comment_body[0][value]' => implode("\n", $comment),
- );
+ ];
$this->drupalPostForm('node/' . $this->node->id(), $edit, t('Save'));
foreach ($images as $image => $converted) {
$found = FALSE;
@@ -151,7 +151,7 @@ class FilterHtmlImageSecureTest extends WebTestBase {
$this->assertEqual((string) $element['src'], $converted);
}
}
- $this->assertTrue($found, format_string('@image was found.', array('@image' => $image)));
+ $this->assertTrue($found, format_string('@image was found.', ['@image' => $image]));
}
}
diff --git a/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php b/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php
index 7f4ad57e8cf..a5049a1635e 100644
--- a/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php
+++ b/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php
@@ -25,80 +25,80 @@ class FilterTestFormatForm extends FormBase {
// form elements.
$form['#tree'] = TRUE;
- $form['all_formats'] = array(
+ $form['all_formats'] = [
'#type' => 'details',
'#title' => 'All text formats',
- );
- $form['all_formats']['no_default'] = array(
+ ];
+ $form['all_formats']['no_default'] = [
'#type' => 'text_format',
'#title' => 'No default value',
- );
- $form['all_formats']['default'] = array(
+ ];
+ $form['all_formats']['default'] = [
'#type' => 'text_format',
'#title' => 'Default value',
'#format' => 'filter_test',
- );
- $form['all_formats']['default_missing'] = array(
+ ];
+ $form['all_formats']['default_missing'] = [
'#type' => 'text_format',
'#title' => 'Missing default value',
'#format' => 'missing_format',
- );
+ ];
- $form['restricted_formats'] = array(
+ $form['restricted_formats'] = [
'#type' => 'details',
'#title' => 'Restricted text format list',
- );
- $form['restricted_formats']['no_default'] = array(
+ ];
+ $form['restricted_formats']['no_default'] = [
'#type' => 'text_format',
'#title' => 'No default value',
- '#allowed_formats' => array('full_html', 'filter_test'),
- );
- $form['restricted_formats']['default'] = array(
+ '#allowed_formats' => ['full_html', 'filter_test'],
+ ];
+ $form['restricted_formats']['default'] = [
'#type' => 'text_format',
'#title' => 'Default value',
'#format' => 'full_html',
- '#allowed_formats' => array('full_html', 'filter_test'),
- );
- $form['restricted_formats']['default_missing'] = array(
+ '#allowed_formats' => ['full_html', 'filter_test'],
+ ];
+ $form['restricted_formats']['default_missing'] = [
'#type' => 'text_format',
'#title' => 'Missing default value',
'#format' => 'missing_format',
- '#allowed_formats' => array('full_html', 'filter_test'),
- );
- $form['restricted_formats']['default_disallowed'] = array(
+ '#allowed_formats' => ['full_html', 'filter_test'],
+ ];
+ $form['restricted_formats']['default_disallowed'] = [
'#type' => 'text_format',
'#title' => 'Disallowed default value',
'#format' => 'filtered_html',
- '#allowed_formats' => array('full_html', 'filter_test'),
- );
+ '#allowed_formats' => ['full_html', 'filter_test'],
+ ];
- $form['single_format'] = array(
+ $form['single_format'] = [
'#type' => 'details',
'#title' => 'Single text format',
- );
- $form['single_format']['no_default'] = array(
+ ];
+ $form['single_format']['no_default'] = [
'#type' => 'text_format',
'#title' => 'No default value',
- '#allowed_formats' => array('filter_test'),
- );
- $form['single_format']['default'] = array(
+ '#allowed_formats' => ['filter_test'],
+ ];
+ $form['single_format']['default'] = [
'#type' => 'text_format',
'#title' => 'Default value',
'#format' => 'filter_test',
- '#allowed_formats' => array('filter_test'),
- );
- $form['single_format']['default_missing'] = array(
+ '#allowed_formats' => ['filter_test'],
+ ];
+ $form['single_format']['default_missing'] = [
'#type' => 'text_format',
'#title' => 'Missing default value',
'#format' => 'missing_format',
- '#allowed_formats' => array('filter_test'),
- );
- $form['single_format']['default_disallowed'] = array(
+ '#allowed_formats' => ['filter_test'],
+ ];
+ $form['single_format']['default_disallowed'] = [
'#type' => 'text_format',
'#title' => 'Disallowed default value',
'#format' => 'full_html',
- '#allowed_formats' => array('filter_test'),
- );
+ '#allowed_formats' => ['filter_test'],
+ ];
return $form;
}
diff --git a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php
index 700dec39a97..5f63a06b0a0 100644
--- a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php
+++ b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestAssets.php
@@ -22,11 +22,11 @@ class FilterTestAssets extends FilterBase {
*/
public function process($text, $langcode) {
$result = new FilterProcessResult($text);
- $result->addAttachments(array(
- 'library' => array(
+ $result->addAttachments([
+ 'library' => [
'filter/caption',
- ),
- ));
+ ],
+ ]);
return $result;
}
diff --git a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php
index fe1986c94b3..4b305053fb7 100644
--- a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php
+++ b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php
@@ -22,8 +22,8 @@ class FilterTestCacheTags extends FilterBase {
*/
public function process($text, $langcode) {
$result = new FilterProcessResult($text);
- $result->addCacheTags(array('foo:bar'));
- $result->addCacheTags(array('foo:baz'));
+ $result->addCacheTags(['foo:bar']);
+ $result->addCacheTags(['foo:baz']);
return $result;
}
diff --git a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPlaceholders.php b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPlaceholders.php
index 6b5e7241ac5..c6d03000f98 100644
--- a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPlaceholders.php
+++ b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPlaceholders.php
@@ -38,7 +38,7 @@ class FilterTestPlaceholders extends FilterBase {
*/
public static function renderDynamicThing($thing) {
return [
- '#markup' => format_string('This is a dynamic @thing.', array('@thing' => $thing)),
+ '#markup' => format_string('This is a dynamic @thing.', ['@thing' => $thing]),
];
}
diff --git a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php
index 0e6d85da5d4..c697e250816 100644
--- a/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php
+++ b/core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php
@@ -21,7 +21,7 @@ class FilterTestReplace extends FilterBase {
* {@inheritdoc}
*/
public function process($text, $langcode) {
- $text = array();
+ $text = [];
$text[] = 'Filter: ' . $this->getLabel() . ' (' . $this->getPluginId() . ')';
$text[] = 'Language: ' . $langcode;
return new FilterProcessResult(implode("<br />\n", $text));
diff --git a/core/modules/filter/tests/src/Functional/FilterDefaultFormatTest.php b/core/modules/filter/tests/src/Functional/FilterDefaultFormatTest.php
index 6014c10b3a4..4aee647f962 100644
--- a/core/modules/filter/tests/src/Functional/FilterDefaultFormatTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterDefaultFormatTest.php
@@ -18,7 +18,7 @@ class FilterDefaultFormatTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('filter');
+ public static $modules = ['filter'];
/**
* Tests if the default text format is accessible to users.
@@ -26,26 +26,26 @@ class FilterDefaultFormatTest extends BrowserTestBase {
function testDefaultTextFormats() {
// Create two text formats, and two users. The first user has access to
// both formats, but the second user only has access to the second one.
- $admin_user = $this->drupalCreateUser(array('administer filters'));
+ $admin_user = $this->drupalCreateUser(['administer filters']);
$this->drupalLogin($admin_user);
- $formats = array();
+ $formats = [];
for ($i = 0; $i < 2; $i++) {
- $edit = array(
+ $edit = [
'format' => Unicode::strtolower($this->randomMachineName()),
'name' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->resetFilterCaches();
$formats[] = FilterFormat::load($edit['format']);
}
list($first_format, $second_format) = $formats;
$second_format_permission = $second_format->getPermissionName();
- $first_user = $this->drupalCreateUser(array($first_format->getPermissionName(), $second_format_permission));
- $second_user = $this->drupalCreateUser(array($second_format_permission));
+ $first_user = $this->drupalCreateUser([$first_format->getPermissionName(), $second_format_permission]);
+ $second_user = $this->drupalCreateUser([$second_format_permission]);
// Adjust the weights so that the first and second formats (in that order)
// are the two lowest weighted formats available to any user.
- $edit = array();
+ $edit = [];
$edit['formats[' . $first_format->id() . '][weight]'] = -2;
$edit['formats[' . $second_format->id() . '][weight]'] = -1;
$this->drupalPostForm('admin/config/content/formats', $edit, t('Save'));
@@ -62,7 +62,7 @@ class FilterDefaultFormatTest extends BrowserTestBase {
// Reorder the two formats, and check that both users now have the same
// default.
- $edit = array();
+ $edit = [];
$edit['formats[' . $second_format->id() . '][weight]'] = -3;
$this->drupalPostForm('admin/config/content/formats', $edit, t('Save'));
$this->resetFilterCaches();
diff --git a/core/modules/filter/tests/src/Functional/FilterHooksTest.php b/core/modules/filter/tests/src/Functional/FilterHooksTest.php
index c499f235ec4..2ff3e4301e9 100644
--- a/core/modules/filter/tests/src/Functional/FilterHooksTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterHooksTest.php
@@ -18,7 +18,7 @@ class FilterHooksTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'filter_test');
+ public static $modules = ['node', 'filter_test'];
/**
* Tests hooks on format management.
@@ -29,43 +29,43 @@ class FilterHooksTest extends BrowserTestBase {
function testFilterHooks() {
// Create content type, with underscores.
$type_name = 'test_' . strtolower($this->randomMachineName());
- $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
+ $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$node_permission = "create $type_name content";
- $admin_user = $this->drupalCreateUser(array('administer filters', 'administer nodes', $node_permission));
+ $admin_user = $this->drupalCreateUser(['administer filters', 'administer nodes', $node_permission]);
$this->drupalLogin($admin_user);
// Add a text format.
$name = $this->randomMachineName();
- $edit = array();
+ $edit = [];
$edit['format'] = Unicode::strtolower($this->randomMachineName());
$edit['name'] = $name;
$edit['roles[' . RoleInterface::ANONYMOUS_ID . ']'] = 1;
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
- $this->assertRaw(t('Added text format %format.', array('%format' => $name)));
+ $this->assertRaw(t('Added text format %format.', ['%format' => $name]));
$this->assertText('hook_filter_format_insert invoked.');
$format_id = $edit['format'];
// Update text format.
- $edit = array();
+ $edit = [];
$edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
$this->drupalPostForm('admin/config/content/formats/manage/' . $format_id, $edit, t('Save configuration'));
- $this->assertRaw(t('The text format %format has been updated.', array('%format' => $name)));
+ $this->assertRaw(t('The text format %format has been updated.', ['%format' => $name]));
$this->assertText('hook_filter_format_update invoked.');
// Use the format created.
$title = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $title;
$edit['body[0][value]'] = $this->randomMachineName(32);
$edit['body[0][format]'] = $format_id;
$this->drupalPostForm("node/add/{$type->id()}", $edit, t('Save and publish'));
- $this->assertText(t('@type @title has been created.', array('@type' => $type_name, '@title' => $title)));
+ $this->assertText(t('@type @title has been created.', ['@type' => $type_name, '@title' => $title]));
// Disable the text format.
- $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', array(), t('Disable'));
- $this->assertRaw(t('Disabled text format %format.', array('%format' => $name)));
+ $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', [], t('Disable'));
+ $this->assertRaw(t('Disabled text format %format.', ['%format' => $name]));
$this->assertText('hook_filter_format_disable invoked.');
}
diff --git a/core/modules/filter/tests/src/Functional/FilterNoFormatTest.php b/core/modules/filter/tests/src/Functional/FilterNoFormatTest.php
index 1139947c710..22b3ac65b0a 100644
--- a/core/modules/filter/tests/src/Functional/FilterNoFormatTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterNoFormatTest.php
@@ -16,7 +16,7 @@ class FilterNoFormatTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('filter');
+ public static $modules = ['filter'];
/**
* Tests text without format.
diff --git a/core/modules/filter/tests/src/Functional/FilterSecurityTest.php b/core/modules/filter/tests/src/Functional/FilterSecurityTest.php
index 4055159f607..af1240e772a 100644
--- a/core/modules/filter/tests/src/Functional/FilterSecurityTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterSecurityTest.php
@@ -21,7 +21,7 @@ class FilterSecurityTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'filter_test');
+ public static $modules = ['node', 'filter_test'];
/**
* A user with administrative permissions.
@@ -34,14 +34,14 @@ class FilterSecurityTest extends BrowserTestBase {
parent::setUp();
// Create Basic page node type.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
/** @var \Drupal\filter\Entity\FilterFormat $filtered_html_format */
$filtered_html_format = FilterFormat::load('filtered_html');
$filtered_html_permission = $filtered_html_format->getPermissionName();
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array($filtered_html_permission));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [$filtered_html_permission]);
- $this->adminUser = $this->drupalCreateUser(array('administer modules', 'administer filters', 'administer site configuration'));
+ $this->adminUser = $this->drupalCreateUser(['administer modules', 'administer filters', 'administer site configuration']);
$this->drupalLogin($this->adminUser);
}
@@ -53,16 +53,16 @@ class FilterSecurityTest extends BrowserTestBase {
*/
function testDisableFilterModule() {
// Create a new node.
- $node = $this->drupalCreateNode(array('promote' => 1));
+ $node = $this->drupalCreateNode(['promote' => 1]);
$body_raw = $node->body->value;
$format_id = $node->body->format;
$this->drupalGet('node/' . $node->id());
$this->assertText($body_raw, 'Node body found.');
// Enable the filter_test_replace filter.
- $edit = array(
+ $edit = [
'filters[filter_test_replace][status]' => 1,
- );
+ ];
$this->drupalPostForm('admin/config/content/formats/manage/' . $format_id, $edit, t('Save configuration'));
// Verify that filter_test_replace filter replaced the content.
@@ -71,7 +71,7 @@ class FilterSecurityTest extends BrowserTestBase {
$this->assertText('Filter: Testing filter', 'Testing filter output found.');
// Disable the text format entirely.
- $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', array(), t('Disable'));
+ $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', [], t('Disable'));
// Verify that the content is empty, because the text format does not exist.
$this->drupalGet('node/' . $node->id());
@@ -84,8 +84,8 @@ class FilterSecurityTest extends BrowserTestBase {
function testSkipSecurityFilters() {
$text = "Text with some disallowed tags: <script />, <p><object>unicorn</object></p>, <i><table></i>.";
$expected_filtered_text = "Text with some disallowed tags: , <p>unicorn</p>, .";
- $this->assertEqual(check_markup($text, 'filtered_html', '', array()), $expected_filtered_text, 'Expected filter result.');
- $this->assertEqual(check_markup($text, 'filtered_html', '', array(FilterInterface::TYPE_HTML_RESTRICTOR)), $expected_filtered_text, 'Expected filter result, even when trying to disable filters of the FilterInterface::TYPE_HTML_RESTRICTOR type.');
+ $this->assertEqual(check_markup($text, 'filtered_html', '', []), $expected_filtered_text, 'Expected filter result.');
+ $this->assertEqual(check_markup($text, 'filtered_html', '', [FilterInterface::TYPE_HTML_RESTRICTOR]), $expected_filtered_text, 'Expected filter result, even when trying to disable filters of the FilterInterface::TYPE_HTML_RESTRICTOR type.');
}
}
diff --git a/core/modules/filter/tests/src/Kernel/FilterAPITest.php b/core/modules/filter/tests/src/Kernel/FilterAPITest.php
index 50189a6ab41..85ea05edf6d 100644
--- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php
+++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php
@@ -19,12 +19,12 @@ use Symfony\Component\Validator\ConstraintViolationListInterface;
*/
class FilterAPITest extends EntityKernelTestBase {
- public static $modules = array('system', 'filter', 'filter_test', 'user');
+ public static $modules = ['system', 'filter', 'filter_test', 'user'];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('system', 'filter', 'filter_test'));
+ $this->installConfig(['system', 'filter', 'filter_test']);
}
/**
@@ -32,24 +32,24 @@ class FilterAPITest extends EntityKernelTestBase {
*/
function testCheckMarkupFilterOrder() {
// Create crazy HTML format.
- $crazy_format = FilterFormat::create(array(
+ $crazy_format = FilterFormat::create([
'format' => 'crazy',
'name' => 'Crazy',
'weight' => 1,
- 'filters' => array(
- 'filter_html_escape' => array(
+ 'filters' => [
+ 'filter_html_escape' => [
'weight' => 10,
'status' => 1,
- ),
- 'filter_html' => array(
+ ],
+ 'filter_html' => [
'weight' => -10,
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<p>',
- ),
- ),
- )
- ));
+ ],
+ ],
+ ]
+ ]);
$crazy_format->save();
$text = "<p>Llamas are <not> awesome!</p>";
@@ -66,14 +66,14 @@ class FilterAPITest extends EntityKernelTestBase {
$expected_filtered_text = "Text with evil content and a URL: <a href=\"https://www.drupal.org\">https://www.drupal.org</a>!";
$expected_filter_text_without_html_generators = "Text with evil content and a URL: https://www.drupal.org!";
- $actual_filtered_text = check_markup($text, 'filtered_html', '', array());
+ $actual_filtered_text = check_markup($text, 'filtered_html', '', []);
$this->verbose("Actual:<pre>$actual_filtered_text</pre>Expected:<pre>$expected_filtered_text</pre>");
$this->assertEqual(
$actual_filtered_text,
$expected_filtered_text,
'Expected filter result.'
);
- $actual_filtered_text_without_html_generators = check_markup($text, 'filtered_html', '', array(FilterInterface::TYPE_MARKUP_LANGUAGE));
+ $actual_filtered_text_without_html_generators = check_markup($text, 'filtered_html', '', [FilterInterface::TYPE_MARKUP_LANGUAGE]);
$this->verbose("Actual:<pre>$actual_filtered_text_without_html_generators</pre>Expected:<pre>$expected_filter_text_without_html_generators</pre>");
$this->assertEqual(
$actual_filtered_text_without_html_generators,
@@ -84,7 +84,7 @@ class FilterAPITest extends EntityKernelTestBase {
// this check focuses on the ability to filter multiple filter types at once.
// Drupal core only ships with these two types of filters, so this is the
// most extensive test possible.
- $actual_filtered_text_without_html_generators = check_markup($text, 'filtered_html', '', array(FilterInterface::TYPE_HTML_RESTRICTOR, FilterInterface::TYPE_MARKUP_LANGUAGE));
+ $actual_filtered_text_without_html_generators = check_markup($text, 'filtered_html', '', [FilterInterface::TYPE_HTML_RESTRICTOR, FilterInterface::TYPE_MARKUP_LANGUAGE]);
$this->verbose("Actual:<pre>$actual_filtered_text_without_html_generators</pre>Expected:<pre>$expected_filter_text_without_html_generators</pre>");
$this->assertEqual(
$actual_filtered_text_without_html_generators,
@@ -103,20 +103,20 @@ class FilterAPITest extends EntityKernelTestBase {
$filtered_html_format = FilterFormat::load('filtered_html');
$this->assertIdentical(
$filtered_html_format->getHtmlRestrictions(),
- array(
- 'allowed' => array(
+ [
+ 'allowed' => [
'p' => FALSE,
'br' => FALSE,
'strong' => FALSE,
- 'a' => array('href' => TRUE, 'hreflang' => TRUE),
- '*' => array('style' => FALSE, 'on*' => FALSE, 'lang' => TRUE, 'dir' => array('ltr' => TRUE, 'rtl' => TRUE)),
- ),
- ),
+ 'a' => ['href' => TRUE, 'hreflang' => TRUE],
+ '*' => ['style' => FALSE, 'on*' => FALSE, 'lang' => TRUE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]],
+ ],
+ ],
'FilterFormatInterface::getHtmlRestrictions() works as expected for the filtered_html format.'
);
$this->assertIdentical(
$filtered_html_format->getFilterTypes(),
- array(FilterInterface::TYPE_HTML_RESTRICTOR, FilterInterface::TYPE_MARKUP_LANGUAGE),
+ [FilterInterface::TYPE_HTML_RESTRICTOR, FilterInterface::TYPE_MARKUP_LANGUAGE],
'FilterFormatInterface::getFilterTypes() works as expected for the filtered_html format.'
);
@@ -129,113 +129,113 @@ class FilterAPITest extends EntityKernelTestBase {
);
$this->assertIdentical(
$full_html_format->getFilterTypes(),
- array(),
+ [],
'FilterFormatInterface::getFilterTypes() works as expected for the full_html format.'
);
// Test on stupid_filtered_html, where nothing is allowed.
- $stupid_filtered_html_format = FilterFormat::create(array(
+ $stupid_filtered_html_format = FilterFormat::create([
'format' => 'stupid_filtered_html',
'name' => 'Stupid Filtered HTML',
- 'filters' => array(
- 'filter_html' => array(
+ 'filters' => [
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '', // Nothing is allowed.
- ),
- ),
- ),
- ));
+ ],
+ ],
+ ],
+ ]);
$stupid_filtered_html_format->save();
$this->assertIdentical(
$stupid_filtered_html_format->getHtmlRestrictions(),
- array('allowed' => array()), // No tag is allowed.
+ ['allowed' => []], // No tag is allowed.
'FilterFormatInterface::getHtmlRestrictions() works as expected for the stupid_filtered_html format.'
);
$this->assertIdentical(
$stupid_filtered_html_format->getFilterTypes(),
- array(FilterInterface::TYPE_HTML_RESTRICTOR),
+ [FilterInterface::TYPE_HTML_RESTRICTOR],
'FilterFormatInterface::getFilterTypes() works as expected for the stupid_filtered_html format.'
);
// Test on very_restricted_html, where there's two different filters of the
// FilterInterface::TYPE_HTML_RESTRICTOR type, each restricting in different ways.
- $very_restricted_html_format = FilterFormat::create(array(
+ $very_restricted_html_format = FilterFormat::create([
'format' => 'very_restricted_html',
'name' => 'Very Restricted HTML',
- 'filters' => array(
- 'filter_html' => array(
+ 'filters' => [
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<p> <br> <a href> <strong>',
- ),
- ),
- 'filter_test_restrict_tags_and_attributes' => array(
+ ],
+ ],
+ 'filter_test_restrict_tags_and_attributes' => [
'status' => 1,
- 'settings' => array(
- 'restrictions' => array(
- 'allowed' => array(
+ 'settings' => [
+ 'restrictions' => [
+ 'allowed' => [
'p' => TRUE,
'br' => FALSE,
- 'a' => array('href' => TRUE),
+ 'a' => ['href' => TRUE],
'em' => TRUE,
- ),
- )
- ),
- ),
- )
- ));
+ ],
+ ]
+ ],
+ ],
+ ]
+ ]);
$very_restricted_html_format->save();
$this->assertIdentical(
$very_restricted_html_format->getHtmlRestrictions(),
- array(
- 'allowed' => array(
+ [
+ 'allowed' => [
'p' => FALSE,
'br' => FALSE,
- 'a' => array('href' => TRUE),
- '*' => array('style' => FALSE, 'on*' => FALSE, 'lang' => TRUE, 'dir' => array('ltr' => TRUE, 'rtl' => TRUE)),
- ),
- ),
+ 'a' => ['href' => TRUE],
+ '*' => ['style' => FALSE, 'on*' => FALSE, 'lang' => TRUE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]],
+ ],
+ ],
'FilterFormatInterface::getHtmlRestrictions() works as expected for the very_restricted_html format.'
);
$this->assertIdentical(
$very_restricted_html_format->getFilterTypes(),
- array(FilterInterface::TYPE_HTML_RESTRICTOR),
+ [FilterInterface::TYPE_HTML_RESTRICTOR],
'FilterFormatInterface::getFilterTypes() works as expected for the very_restricted_html format.'
);
// Test on nonsensical_restricted_html, where the allowed attribute values
// contain asterisks, which do not have any meaning, but which we also
// cannot prevent because configuration can be modified outside of forms.
- $nonsensical_restricted_html = FilterFormat::create(array(
+ $nonsensical_restricted_html = FilterFormat::create([
'format' => 'nonsensical_restricted_html',
'name' => 'Nonsensical Restricted HTML',
- 'filters' => array(
- 'filter_html' => array(
+ 'filters' => [
+ 'filter_html' => [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<a> <b class> <c class="*"> <d class="foo bar-* *">',
- ),
- ),
- )
- ));
+ ],
+ ],
+ ]
+ ]);
$nonsensical_restricted_html->save();
$this->assertIdentical(
$nonsensical_restricted_html->getHtmlRestrictions(),
- array(
- 'allowed' => array(
+ [
+ 'allowed' => [
'a' => FALSE,
- 'b' => array('class' => TRUE),
- 'c' => array('class' => TRUE),
- 'd' => array('class' => array('foo' => TRUE, 'bar-*' => TRUE)),
- '*' => array('style' => FALSE, 'on*' => FALSE, 'lang' => TRUE, 'dir' => array('ltr' => TRUE, 'rtl' => TRUE)),
- ),
- ),
+ 'b' => ['class' => TRUE],
+ 'c' => ['class' => TRUE],
+ 'd' => ['class' => ['foo' => TRUE, 'bar-*' => TRUE]],
+ '*' => ['style' => FALSE, 'on*' => FALSE, 'lang' => TRUE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]],
+ ],
+ ],
'FilterFormatInterface::getHtmlRestrictions() works as expected for the nonsensical_restricted_html format.'
);
$this->assertIdentical(
$very_restricted_html_format->getFilterTypes(),
- array(FilterInterface::TYPE_HTML_RESTRICTOR),
+ [FilterInterface::TYPE_HTML_RESTRICTOR],
'FilterFormatInterface::getFilterTypes() works as expected for the very_restricted_html format.'
);
}
@@ -250,57 +250,57 @@ class FilterAPITest extends EntityKernelTestBase {
* This test focuses solely on those advanced features.
*/
function testProcessedTextElement() {
- FilterFormat::create(array(
+ FilterFormat::create([
'format' => 'element_test',
'name' => 'processed_text element test format',
- 'filters' => array(
- 'filter_test_assets' => array(
+ 'filters' => [
+ 'filter_test_assets' => [
'weight' => -1,
'status' => TRUE,
- ),
- 'filter_test_cache_tags' => array(
+ ],
+ 'filter_test_cache_tags' => [
'weight' => 0,
'status' => TRUE,
- ),
- 'filter_test_cache_contexts' => array(
+ ],
+ 'filter_test_cache_contexts' => [
'weight' => 0,
'status' => TRUE,
- ),
- 'filter_test_cache_merge' => array(
+ ],
+ 'filter_test_cache_merge' => [
'weight' => 0,
'status' => TRUE,
- ),
- 'filter_test_placeholders' => array(
+ ],
+ 'filter_test_placeholders' => [
'weight' => 1,
'status' => TRUE,
- ),
+ ],
// Run the HTML corrector filter last, because it has the potential to
// break the placeholders added by the filter_test_placeholders filter.
- 'filter_htmlcorrector' => array(
+ 'filter_htmlcorrector' => [
'weight' => 10,
'status' => TRUE,
- ),
- ),
- ))->save();
+ ],
+ ],
+ ])->save();
- $build = array(
+ $build = [
'#type' => 'processed_text',
'#text' => '<p>Hello, world!</p>',
'#format' => 'element_test',
- );
+ ];
drupal_render_root($build);
// Verify the attachments and cacheability metadata.
- $expected_attachments = array(
+ $expected_attachments = [
// The assets attached by the filter_test_assets filter.
- 'library' => array(
+ 'library' => [
'filter/caption',
- ),
+ ],
// The placeholders attached that still need to be processed.
'placeholders' => [],
- );
+ ];
$this->assertEqual($expected_attachments, $build['#attached'], 'Expected attachments present');
- $expected_cache_tags = array(
+ $expected_cache_tags = [
// The cache tag set by the processed_text element itself.
'config:filter.format.element_test',
// The cache tags set by the filter_test_cache_tags filter.
@@ -308,7 +308,7 @@ class FilterAPITest extends EntityKernelTestBase {
'foo:baz',
// The cache tags set by the filter_test_cache_merge filter.
'merge:tag',
- );
+ ];
$this->assertEqual($expected_cache_tags, $build['#cache']['tags'], 'Expected cache tags present.');
$expected_cache_contexts = [
// The cache context set by the filter_test_cache_contexts filter.
@@ -333,20 +333,20 @@ class FilterAPITest extends EntityKernelTestBase {
$this->assertTrue($data instanceof OptionsProviderInterface, 'Typed data object implements \Drupal\Core\TypedData\OptionsProviderInterface');
- $filtered_html_user = $this->createUser(array('uid' => 2), array(
+ $filtered_html_user = $this->createUser(['uid' => 2], [
FilterFormat::load('filtered_html')->getPermissionName(),
- ));
+ ]);
// Test with anonymous user.
$user = new AnonymousUserSession();
\Drupal::currentUser()->setAccount($user);
- $expected_available_options = array(
+ $expected_available_options = [
'filtered_html' => 'Filtered HTML',
'full_html' => 'Full HTML',
'filter_test' => 'Test format',
'plain_text' => 'Plain text',
- );
+ ];
$available_values = $data->getPossibleValues();
$this->assertEqual($available_values, array_keys($expected_available_options));
@@ -354,9 +354,9 @@ class FilterAPITest extends EntityKernelTestBase {
$this->assertEqual($available_options, $expected_available_options);
$allowed_values = $data->getSettableValues($user);
- $this->assertEqual($allowed_values, array('plain_text'));
+ $this->assertEqual($allowed_values, ['plain_text']);
$allowed_options = $data->getSettableOptions($user);
- $this->assertEqual($allowed_options, array('plain_text' => 'Plain text'));
+ $this->assertEqual($allowed_options, ['plain_text' => 'Plain text']);
$data->setValue('foo');
$violations = $data->validate();
@@ -383,12 +383,12 @@ class FilterAPITest extends EntityKernelTestBase {
$this->assertEqual(count($violations), 0, "No validation violation for accessible format 'filtered_html' found.");
$allowed_values = $data->getSettableValues($filtered_html_user);
- $this->assertEqual($allowed_values, array('filtered_html', 'plain_text'));
+ $this->assertEqual($allowed_values, ['filtered_html', 'plain_text']);
$allowed_options = $data->getSettableOptions($filtered_html_user);
- $expected_allowed_options = array(
+ $expected_allowed_options = [
'filtered_html' => 'Filtered HTML',
'plain_text' => 'Plain text',
- );
+ ];
$this->assertEqual($allowed_options, $expected_allowed_options);
}
@@ -397,43 +397,43 @@ class FilterAPITest extends EntityKernelTestBase {
*/
public function testFilterFormatPreSave() {
/** @var \Drupal\filter\FilterFormatInterface $crazy_format */
- $crazy_format = FilterFormat::create(array(
+ $crazy_format = FilterFormat::create([
'format' => 'crazy',
'name' => 'Crazy',
'weight' => 1,
- 'filters' => array(
- 'filter_html_escape' => array(
+ 'filters' => [
+ 'filter_html_escape' => [
'weight' => 10,
'status' => 1,
- ),
- 'filter_html' => array(
+ ],
+ 'filter_html' => [
'weight' => -10,
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'allowed_html' => '<p>',
- ),
- ),
- )
- ));
+ ],
+ ],
+ ]
+ ]);
$crazy_format->save();
// Use config to directly load the configuration and check that only enabled
// or customized plugins are saved to configuration.
$filters = $this->config('filter.format.crazy')->get('filters');
- $this->assertEqual(array('filter_html_escape', 'filter_html'), array_keys($filters));
+ $this->assertEqual(['filter_html_escape', 'filter_html'], array_keys($filters));
// Disable a plugin to ensure that disabled plugins with custom settings are
// stored in configuration.
- $crazy_format->setFilterConfig('filter_html_escape', array('status' => FALSE));
+ $crazy_format->setFilterConfig('filter_html_escape', ['status' => FALSE]);
$crazy_format->save();
$filters = $this->config('filter.format.crazy')->get('filters');
- $this->assertEqual(array('filter_html_escape', 'filter_html'), array_keys($filters));
+ $this->assertEqual(['filter_html_escape', 'filter_html'], array_keys($filters));
// Set the settings as per default to ensure that disable plugins in this
// state are not stored in configuration.
- $crazy_format->setFilterConfig('filter_html_escape', array('weight' => -10));
+ $crazy_format->setFilterConfig('filter_html_escape', ['weight' => -10]);
$crazy_format->save();
$filters = $this->config('filter.format.crazy')->get('filters');
- $this->assertEqual(array('filter_html'), array_keys($filters));
+ $this->assertEqual(['filter_html'], array_keys($filters));
}
/**
@@ -452,7 +452,7 @@ class FilterAPITest extends EntityKernelTestBase {
break;
}
}
- $this->assertTrue($filter_format_violation_found, format_string('Validation violation for invalid value "%invalid_value" found', array('%invalid_value' => $invalid_value)));
+ $this->assertTrue($filter_format_violation_found, format_string('Validation violation for invalid value "%invalid_value" found', ['%invalid_value' => $invalid_value]));
}
/**
@@ -467,7 +467,7 @@ class FilterAPITest extends EntityKernelTestBase {
* @see filter_system_info_alter()
*/
public function testDependencyRemoval() {
- $this->installSchema('user', array('users_data'));
+ $this->installSchema('user', ['users_data']);
$filter_format = FilterFormat::load('filtered_html');
// Disable the filter_test_restrict_tags_and_attributes filter plugin but
@@ -493,7 +493,7 @@ class FilterAPITest extends EntityKernelTestBase {
$this->assertEqual(['module' => ['filter_test']], $filter_format->getDependencies());
// Uninstall the module.
- \Drupal::service('module_installer')->uninstall(array('filter_test'));
+ \Drupal::service('module_installer')->uninstall(['filter_test']);
// Verify the filter format still exists but the dependency and filter is
// gone.
diff --git a/core/modules/filter/tests/src/Kernel/FilterCrudTest.php b/core/modules/filter/tests/src/Kernel/FilterCrudTest.php
index 0a9be183269..87ea076ad36 100644
--- a/core/modules/filter/tests/src/Kernel/FilterCrudTest.php
+++ b/core/modules/filter/tests/src/Kernel/FilterCrudTest.php
@@ -24,42 +24,42 @@ class FilterCrudTest extends KernelTestBase {
*/
function testTextFormatCrud() {
// Add a text format with minimum data only.
- $format = FilterFormat::create(array(
+ $format = FilterFormat::create([
'format' => 'empty_format',
'name' => 'Empty format',
- ));
+ ]);
$format->save();
$this->verifyTextFormat($format);
// Add another text format specifying all possible properties.
- $format = FilterFormat::create(array(
+ $format = FilterFormat::create([
'format' => 'custom_format',
'name' => 'Custom format',
- ));
- $format->setFilterConfig('filter_url', array(
+ ]);
+ $format->setFilterConfig('filter_url', [
'status' => 1,
- 'settings' => array(
+ 'settings' => [
'filter_url_length' => 30,
- ),
- ));
+ ],
+ ]);
$format->save();
$this->verifyTextFormat($format);
// Alter some text format properties and save again.
$format->set('name', 'Altered format');
- $format->setFilterConfig('filter_url', array(
+ $format->setFilterConfig('filter_url', [
'status' => 0,
- ));
- $format->setFilterConfig('filter_autop', array(
+ ]);
+ $format->setFilterConfig('filter_autop', [
'status' => 1,
- ));
+ ]);
$format->save();
$this->verifyTextFormat($format);
// Add a filter_test_replace filter and save again.
- $format->setFilterConfig('filter_test_replace', array(
+ $format->setFilterConfig('filter_test_replace', [
'status' => 1,
- ));
+ ]);
$format->save();
$this->verifyTextFormat($format);
@@ -89,7 +89,7 @@ class FilterCrudTest extends KernelTestBase {
* Verifies that a text format is properly stored.
*/
function verifyTextFormat($format) {
- $t_args = array('%format' => $format->label());
+ $t_args = ['%format' => $format->label()];
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
// Verify the loaded filter has all properties.
diff --git a/core/modules/filter/tests/src/Kernel/FilterDefaultConfigTest.php b/core/modules/filter/tests/src/Kernel/FilterDefaultConfigTest.php
index b4ce50cec31..eb8106c5255 100644
--- a/core/modules/filter/tests/src/Kernel/FilterDefaultConfigTest.php
+++ b/core/modules/filter/tests/src/Kernel/FilterDefaultConfigTest.php
@@ -13,7 +13,7 @@ use Drupal\user\RoleInterface;
*/
class FilterDefaultConfigTest extends KernelTestBase {
- public static $modules = array('system', 'user', 'filter', 'filter_test');
+ public static $modules = ['system', 'user', 'filter', 'filter_test'];
protected function setUp() {
parent::setUp();
@@ -24,7 +24,7 @@ class FilterDefaultConfigTest extends KernelTestBase {
$this->installEntitySchema('user');
// Install filter_test module, which ships with custom default format.
- $this->installConfig(array('user', 'filter_test'));
+ $this->installConfig(['user', 'filter_test']);
}
/**
@@ -44,27 +44,27 @@ class FilterDefaultConfigTest extends KernelTestBase {
// Verify that the loaded format does not contain any roles.
$this->assertEqual($format->get('roles'), NULL);
// Verify that the defined roles in the default config have been processed.
- $this->assertEqual(array_keys(filter_get_roles_by_format($format)), array(
+ $this->assertEqual(array_keys(filter_get_roles_by_format($format)), [
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID,
- ));
+ ]);
// Verify enabled filters.
$filters = $format->get('filters');
$this->assertEqual($filters['filter_html_escape']['status'], 1);
$this->assertEqual($filters['filter_html_escape']['weight'], -10);
$this->assertEqual($filters['filter_html_escape']['provider'], 'filter');
- $this->assertEqual($filters['filter_html_escape']['settings'], array());
+ $this->assertEqual($filters['filter_html_escape']['settings'], []);
$this->assertEqual($filters['filter_autop']['status'], 1);
$this->assertEqual($filters['filter_autop']['weight'], 0);
$this->assertEqual($filters['filter_autop']['provider'], 'filter');
- $this->assertEqual($filters['filter_autop']['settings'], array());
+ $this->assertEqual($filters['filter_autop']['settings'], []);
$this->assertEqual($filters['filter_url']['status'], 1);
$this->assertEqual($filters['filter_url']['weight'], 0);
$this->assertEqual($filters['filter_url']['provider'], 'filter');
- $this->assertEqual($filters['filter_url']['settings'], array(
+ $this->assertEqual($filters['filter_url']['settings'], [
'filter_url_length' => 72,
- ));
+ ]);
}
/**
@@ -73,23 +73,23 @@ class FilterDefaultConfigTest extends KernelTestBase {
function testUpdateRoles() {
// Verify role permissions declared in default config.
$format = FilterFormat::load('filter_test');
- $this->assertEqual(array_keys(filter_get_roles_by_format($format)), array(
+ $this->assertEqual(array_keys(filter_get_roles_by_format($format)), [
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID,
- ));
+ ]);
// Attempt to change roles.
- $format->set('roles', array(
+ $format->set('roles', [
RoleInterface::AUTHENTICATED_ID,
- ));
+ ]);
$format->save();
// Verify that roles have not been updated.
$format = FilterFormat::load('filter_test');
- $this->assertEqual(array_keys(filter_get_roles_by_format($format)), array(
+ $this->assertEqual(array_keys(filter_get_roles_by_format($format)), [
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID,
- ));
+ ]);
}
}
diff --git a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php
index 06c1e4b53fd..bbac9161520 100644
--- a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php
+++ b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php
@@ -22,7 +22,7 @@ class FilterKernelTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'filter');
+ public static $modules = ['system', 'filter'];
/**
* @var \Drupal\filter\Plugin\FilterInterface[]
@@ -31,10 +31,10 @@ class FilterKernelTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
$manager = $this->container->get('plugin.manager.filter');
- $bag = new FilterPluginCollection($manager, array());
+ $bag = new FilterPluginCollection($manager, []);
$this->filters = $bag->getAll();
}
@@ -107,11 +107,11 @@ class FilterKernelTest extends KernelTestBase {
});
};
- $attached_library = array(
- 'library' => array(
+ $attached_library = [
+ 'library' => [
'filter/caption',
- ),
- );
+ ],
+ ];
// No data-caption attribute.
$input = '<img src="llama.jpg" />';
@@ -190,13 +190,13 @@ class FilterKernelTest extends KernelTestBase {
// want to make sure that it works well in tandem with the "Limit allowed
// HTML tags" filter, which it is typically used with.
$html_filter = $this->filters['filter_html'];
- $html_filter->setConfiguration(array(
- 'settings' => array(
+ $html_filter->setConfiguration([
+ 'settings' => [
'allowed_html' => '<img src data-align data-caption>',
'filter_html_help' => 1,
'filter_html_nofollow' => 0,
- )
- ));
+ ]
+ ]);
$test_with_html_filter = function ($input) use ($filter, $html_filter, $renderer) {
return $renderer->executeInRenderContext(new RenderContext(), function () use ($input, $filter, $html_filter) {
// 1. Apply HTML filter's processing step.
@@ -272,11 +272,11 @@ class FilterKernelTest extends KernelTestBase {
});
};
- $attached_library = array(
- 'library' => array(
+ $attached_library = [
+ 'library' => [
'filter/caption',
- ),
- );
+ ],
+ ];
// Both data-caption and data-align attributes: all 3 allowed values for the
// data-align attribute.
@@ -322,60 +322,60 @@ class FilterKernelTest extends KernelTestBase {
// Since the line break filter naturally needs plenty of newlines in test
// strings and expectations, we're using "\n" instead of regular newlines
// here.
- $tests = array(
+ $tests = [
// Single line breaks should be changed to <br /> tags, while paragraphs
// separated with double line breaks should be enclosed with <p></p> tags.
- "aaa\nbbb\n\nccc" => array(
+ "aaa\nbbb\n\nccc" => [
"<p>aaa<br />\nbbb</p>\n<p>ccc</p>" => TRUE,
- ),
+ ],
// Skip contents of certain block tags entirely.
"<script>aaa\nbbb\n\nccc</script>
<style>aaa\nbbb\n\nccc</style>
<pre>aaa\nbbb\n\nccc</pre>
<object>aaa\nbbb\n\nccc</object>
<iframe>aaa\nbbb\n\nccc</iframe>
-" => array(
+" => [
"<script>aaa\nbbb\n\nccc</script>" => TRUE,
"<style>aaa\nbbb\n\nccc</style>" => TRUE,
"<pre>aaa\nbbb\n\nccc</pre>" => TRUE,
"<object>aaa\nbbb\n\nccc</object>" => TRUE,
"<iframe>aaa\nbbb\n\nccc</iframe>" => TRUE,
- ),
+ ],
// Skip comments entirely.
- "One. <!-- comment --> Two.\n<!--\nThree.\n-->\n" => array(
+ "One. <!-- comment --> Two.\n<!--\nThree.\n-->\n" => [
'<!-- comment -->' => TRUE,
"<!--\nThree.\n-->" => TRUE,
- ),
+ ],
// Resulting HTML should produce matching paragraph tags.
- '<p><div> </div></p>' => array(
+ '<p><div> </div></p>' => [
"<p>\n<div> </div>\n</p>" => TRUE,
- ),
- '<div><p> </p></div>' => array(
+ ],
+ '<div><p> </p></div>' => [
"<div>\n</div>" => TRUE,
- ),
- '<blockquote><pre>aaa</pre></blockquote>' => array(
+ ],
+ '<blockquote><pre>aaa</pre></blockquote>' => [
"<blockquote><pre>aaa</pre></blockquote>" => TRUE,
- ),
- "<pre>aaa\nbbb\nccc</pre>\nddd\neee" => array(
+ ],
+ "<pre>aaa\nbbb\nccc</pre>\nddd\neee" => [
"<pre>aaa\nbbb\nccc</pre>" => TRUE,
"<p>ddd<br />\neee</p>" => TRUE,
- ),
+ ],
// Comments remain unchanged and subsequent lines/paragraphs are
// transformed normally.
- "aaa<!--comment-->\n\nbbb\n\nccc\n\nddd<!--comment\nwith linebreak-->\n\neee\n\nfff" => array(
+ "aaa<!--comment-->\n\nbbb\n\nccc\n\nddd<!--comment\nwith linebreak-->\n\neee\n\nfff" => [
"<p>aaa</p>\n<!--comment--><p>\nbbb</p>\n<p>ccc</p>\n<p>ddd</p>" => TRUE,
"<!--comment\nwith linebreak--><p>\neee</p>\n<p>fff</p>" => TRUE,
- ),
+ ],
// Check that a comment in a PRE will result that the text after
// the comment, but still in PRE, is not transformed.
- "<pre>aaa\nbbb<!-- comment -->\n\nccc</pre>\nddd" => array(
+ "<pre>aaa\nbbb<!-- comment -->\n\nccc</pre>\nddd" => [
"<pre>aaa\nbbb<!-- comment -->\n\nccc</pre>" => TRUE,
- ),
+ ],
// Bug 810824, paragraphs were appearing around iframe tags.
- "<iframe>aaa</iframe>\n\n" => array(
+ "<iframe>aaa</iframe>\n\n" => [
"<p><iframe>aaa</iframe></p>" => FALSE,
- ),
- );
+ ],
+ ];
$this->assertFilteredString($filter, $tests);
// Very long string hitting PCRE limits.
@@ -406,13 +406,13 @@ class FilterKernelTest extends KernelTestBase {
function testHtmlFilter() {
// Get FilterHtml object.
$filter = $this->filters['filter_html'];
- $filter->setConfiguration(array(
- 'settings' => array(
+ $filter->setConfiguration([
+ 'settings' => [
'allowed_html' => '<a> <p> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <br>',
'filter_html_help' => 1,
'filter_html_nofollow' => 0,
- )
- ));
+ ]
+ ]);
// HTML filter is not able to secure some tags, these should never be
// allowed.
@@ -461,25 +461,25 @@ class FilterKernelTest extends KernelTestBase {
$this->assertNormalized($f, '<a>link</a>', 'HTML filter should remove attributes that are not explicitly allowed.');
// Now whitelist the "llama" attribute on <a>.
- $filter->setConfiguration(array(
- 'settings' => array(
+ $filter->setConfiguration([
+ 'settings' => [
'allowed_html' => '<a href llama> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <br>',
'filter_html_help' => 1,
'filter_html_nofollow' => 0,
- )
- ));
+ ]
+ ]);
$f = (string) $filter->process('<a kitten="cute" llama="awesome">link</a>', Language::LANGCODE_NOT_SPECIFIED);
$this->assertNormalized($f, '<a llama="awesome">link</a>', 'HTML filter keeps explicitly allowed attributes, and removes attributes that are not explicitly allowed.');
// Restrict the whitelisted "llama" attribute on <a> to only allow the value
// "majestical", or "epic".
- $filter->setConfiguration(array(
- 'settings' => array(
+ $filter->setConfiguration([
+ 'settings' => [
'allowed_html' => '<a href llama="majestical epic"> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <br>',
'filter_html_help' => 1,
'filter_html_nofollow' => 0,
- )
- ));
+ ]
+ ]);
$f = (string) $filter->process('<a kitten="cute" llama="awesome">link</a>', Language::LANGCODE_NOT_SPECIFIED);
$this->assertIdentical($f, '<a>link</a>', 'HTML filter removes allowed attributes that do not have an explicitly allowed value.');
$f = (string) $filter->process('<a kitten="cute" llama="majestical">link</a>', Language::LANGCODE_NOT_SPECIFIED);
@@ -496,13 +496,13 @@ class FilterKernelTest extends KernelTestBase {
function testNoFollowFilter() {
// Get FilterHtml object.
$filter = $this->filters['filter_html'];
- $filter->setConfiguration(array(
- 'settings' => array(
+ $filter->setConfiguration([
+ 'settings' => [
'allowed_html' => '<a href>',
'filter_html_help' => 1,
'filter_html_nofollow' => 1,
- )
- ));
+ ]
+ ]);
// Test if the rel="nofollow" attribute is added, even if we try to prevent
// it.
@@ -530,13 +530,13 @@ class FilterKernelTest extends KernelTestBase {
// Get FilterHtmlEscape object.
$filter = $this->filters['filter_html_escape'];
- $tests = array(
- " One. <!-- \"comment\" --> Two'.\n<p>Three.</p>\n " => array(
+ $tests = [
+ " One. <!-- \"comment\" --> Two'.\n<p>Three.</p>\n " => [
"One. &lt;!-- &quot;comment&quot; --&gt; Two&#039;.\n&lt;p&gt;Three.&lt;/p&gt;" => TRUE,
' One.' => FALSE,
"</p>\n " => FALSE,
- ),
- );
+ ],
+ ];
$this->assertFilteredString($filter, $tests);
}
@@ -546,11 +546,11 @@ class FilterKernelTest extends KernelTestBase {
function testUrlFilter() {
// Get FilterUrl object.
$filter = $this->filters['filter_url'];
- $filter->setConfiguration(array(
- 'settings' => array(
+ $filter->setConfiguration([
+ 'settings' => [
'filter_url_length' => 496,
- )
- ));
+ ]
+ ]);
// @todo Possible categories:
// - absolute, mail, partial
@@ -562,24 +562,24 @@ class FilterKernelTest extends KernelTestBase {
$email_with_plus_sign = 'one+two@example.com';
// Filter selection/pattern matching.
- $tests = array(
+ $tests = [
// HTTP URLs.
'
http://example.com or www.example.com
-' => array(
+' => [
'<a href="http://example.com">http://example.com</a>' => TRUE,
'<a href="http://www.example.com">www.example.com</a>' => TRUE,
- ),
+ ],
// MAILTO URLs.
'
person@example.com or mailto:person2@example.com or ' . $email_with_plus_sign . ' or ' . $long_email . ' but not ' . $too_long_email . '
-' => array(
+' => [
'<a href="mailto:person@example.com">person@example.com</a>' => TRUE,
'<a href="mailto:person2@example.com">mailto:person2@example.com</a>' => TRUE,
'<a href="mailto:' . $long_email . '">' . $long_email . '</a>' => TRUE,
'<a href="mailto:' . $too_long_email . '">' . $too_long_email . '</a>' => FALSE,
'<a href="mailto:' . $email_with_plus_sign . '">' . $email_with_plus_sign . '</a>' => TRUE,
- ),
+ ],
// URI parts and special characters.
'
http://trailingslash.com/ or www.trailingslash.com/
@@ -589,7 +589,7 @@ http://example.com/@user/
ftp://user:pass@ftp.example.com/~home/dir1
sftp://user@nonstandardport:222/dir
ssh://192.168.0.100/srv/git/drupal.git
-' => array(
+' => [
'<a href="http://trailingslash.com/">http://trailingslash.com/</a>' => TRUE,
'<a href="http://www.trailingslash.com/">www.trailingslash.com/</a>' => TRUE,
'<a href="http://host.com/some/path?query=foo&amp;bar[baz]=beer#fragment">http://host.com/some/path?query=foo&amp;bar[baz]=beer#fragment</a>' => TRUE,
@@ -599,7 +599,7 @@ ssh://192.168.0.100/srv/git/drupal.git
'<a href="ftp://user:pass@ftp.example.com/~home/dir1">ftp://user:pass@ftp.example.com/~home/dir1</a>' => TRUE,
'<a href="sftp://user@nonstandardport:222/dir">sftp://user@nonstandardport:222/dir</a>' => TRUE,
'<a href="ssh://192.168.0.100/srv/git/drupal.git">ssh://192.168.0.100/srv/git/drupal.git</a>' => TRUE,
- ),
+ ],
// International Unicode characters.
'
http://пример.испытание/
@@ -609,7 +609,7 @@ http://12345.中国/
http://例え.テスト/
http://dréißig-bücher.de/
http://méxico-mañana.es/
-' => array(
+' => [
'<a href="http://пример.испытание/">http://пример.испытание/</a>' => TRUE,
'<a href="http://مثال.إختبار/">http://مثال.إختبار/</a>' => TRUE,
'<a href="http://例子.測試/">http://例子.測試/</a>' => TRUE,
@@ -617,25 +617,25 @@ http://méxico-mañana.es/
'<a href="http://例え.テスト/">http://例え.テスト/</a>' => TRUE,
'<a href="http://dréißig-bücher.de/">http://dréißig-bücher.de/</a>' => TRUE,
'<a href="http://méxico-mañana.es/">http://méxico-mañana.es/</a>' => TRUE,
- ),
+ ],
// Encoding.
'
http://ampersand.com/?a=1&b=2
http://encoded.com/?a=1&amp;b=2
-' => array(
+' => [
'<a href="http://ampersand.com/?a=1&amp;b=2">http://ampersand.com/?a=1&amp;b=2</a>' => TRUE,
'<a href="http://encoded.com/?a=1&amp;b=2">http://encoded.com/?a=1&amp;b=2</a>' => TRUE,
- ),
+ ],
// Domain name length.
'
www.ex.ex or www.example.example or www.toolongdomainexampledomainexampledomainexampledomainexampledomain or
me@me.tv
-' => array(
+' => [
'<a href="http://www.ex.ex">www.ex.ex</a>' => TRUE,
'<a href="http://www.example.example">www.example.example</a>' => TRUE,
'http://www.toolong' => FALSE,
'<a href="mailto:me@me.tv">me@me.tv</a>' => TRUE,
- ),
+ ],
// Absolute URL protocols.
// The list to test is found in the beginning of _filter_url() at
// $protocols = \Drupal::getContainer()->getParameter('filter_protocols').
@@ -650,7 +650,7 @@ sftp://secure.host?,
webcal://calendar,
rtsp://127.0.0.1,
not foo://disallowed.com.
-' => array(
+' => [
'href="https://example.com"' => TRUE,
'href="ftp://ftp.example.com"' => TRUE,
'href="news://example.net"' => TRUE,
@@ -662,12 +662,12 @@ not foo://disallowed.com.
'href="rtsp://127.0.0.1"' => TRUE,
'href="foo://disallowed.com"' => FALSE,
'not foo://disallowed.com.' => TRUE,
- ),
- );
+ ],
+ ];
$this->assertFilteredString($filter, $tests);
// Surrounding text/punctuation.
- $tests = array(
+ $tests = [
'
Partial URL with trailing period www.partial.com.
Email with trailing comma person@example.com,
@@ -680,7 +680,7 @@ Partial URL with brackets in the URL as well as surrounded brackets (www.foo.com
Absolute URL with square brackets in the URL as well as surrounded brackets [https://www.drupal.org/?class[]=1]
Absolute URL with quotes "https://www.drupal.org/sample"
-' => array(
+' => [
'period <a href="http://www.partial.com">www.partial.com</a>.' => TRUE,
'comma <a href="mailto:person@example.com">person@example.com</a>,' => TRUE,
'question <a href="http://www.absolute.com">http://www.absolute.com</a>?' => TRUE,
@@ -691,45 +691,45 @@ Absolute URL with quotes "https://www.drupal.org/sample"
'brackets (<a href="http://www.foo.com/more_(than)_one_(parens)">www.foo.com/more_(than)_one_(parens)</a>).' => TRUE,
'brackets [<a href="https://www.drupal.org/?class[]=1">https://www.drupal.org/?class[]=1</a>]' => TRUE,
'quotes "<a href="https://www.drupal.org/sample">https://www.drupal.org/sample</a>"' => TRUE,
- ),
+ ],
'
(www.parenthesis.com/dir?a=1&b=2#a)
-' => array(
+' => [
'(<a href="http://www.parenthesis.com/dir?a=1&amp;b=2#a">www.parenthesis.com/dir?a=1&amp;b=2#a</a>)' => TRUE,
- ),
- );
+ ],
+ ];
$this->assertFilteredString($filter, $tests);
// Surrounding markup.
- $tests = array(
+ $tests = [
'
<p xmlns="www.namespace.com" />
<p xmlns="http://namespace.com">
An <a href="http://example.com" title="Read more at www.example.info...">anchor</a>.
</p>
-' => array(
+' => [
'<p xmlns="www.namespace.com" />' => TRUE,
'<p xmlns="http://namespace.com">' => TRUE,
'href="http://www.namespace.com"' => FALSE,
'href="http://namespace.com"' => FALSE,
'An <a href="http://example.com" title="Read more at www.example.info...">anchor</a>.' => TRUE,
- ),
+ ],
'
Not <a href="foo">www.relative.com</a> or <a href="http://absolute.com">www.absolute.com</a>
but <strong>http://www.strong.net</strong> or <em>www.emphasis.info</em>
-' => array(
+' => [
'<a href="foo">www.relative.com</a>' => TRUE,
'href="http://www.relative.com"' => FALSE,
'<a href="http://absolute.com">www.absolute.com</a>' => TRUE,
'<strong><a href="http://www.strong.net">http://www.strong.net</a></strong>' => TRUE,
'<em><a href="http://www.emphasis.info">www.emphasis.info</a></em>' => TRUE,
- ),
+ ],
'
Test <code>using www.example.com the code tag</code>.
-' => array(
+' => [
'href' => FALSE,
'http' => FALSE,
- ),
+ ],
'
Intro.
<blockquote>
@@ -737,7 +737,7 @@ Quoted text linking to www.example.com, written by person@example.com, originati
</blockquote>
Outro.
-' => array(
+' => [
'href="http://www.example.com"' => TRUE,
'href="mailto:person@example.com"' => TRUE,
'href="http://origin.example.com"' => TRUE,
@@ -745,18 +745,18 @@ Outro.
'http://www.example.info' => FALSE,
'Intro.' => TRUE,
'Outro.' => TRUE,
- ),
+ ],
'
Unknown tag <x>containing x and www.example.com</x>? And a tag <pooh>beginning with p and containing www.example.pooh with p?</pooh>
-' => array(
+' => [
'href="http://www.example.com"' => TRUE,
'href="http://www.example.pooh"' => TRUE,
- ),
+ ],
'
<p>Test &lt;br/&gt;: This is a www.example17.com example <strong>with</strong> various http://www.example18.com tags. *<br/>
It is important www.example19.com to *<br/>test different URLs and http://www.example20.com in the same paragraph. *<br>
HTML www.example21.com soup by person@example22.com can litererally http://www.example23.com contain *img*<img> anything. Just a www.example24.com with http://www.example25.com thrown in. www.example26.com from person@example27.com with extra http://www.example28.com.
-' => array(
+' => [
'href="http://www.example17.com"' => TRUE,
'href="http://www.example18.com"' => TRUE,
'href="http://www.example19.com"' => TRUE,
@@ -769,7 +769,7 @@ HTML www.example21.com soup by person@example22.com can litererally http://www.e
'href="http://www.example26.com"' => TRUE,
'href="mailto:person@example27.com"' => TRUE,
'href="http://www.example28.com"' => TRUE,
- ),
+ ],
'
<script>
<!--
@@ -781,33 +781,33 @@ HTML www.example21.com soup by person@example22.com can litererally http://www.e
var exampleurl = "http://example.net";
//--><!]]>
</script>
-' => array(
+' => [
'href="http://www.example.com"' => FALSE,
'href="http://example.net"' => FALSE,
- ),
+ ],
'
<style>body {
background: url(http://example.com/pixel.gif);
}</style>
-' => array(
+' => [
'href' => FALSE,
- ),
+ ],
'
<!-- Skip any URLs like www.example.com in comments -->
-' => array(
+' => [
'href' => FALSE,
- ),
+ ],
'
<!-- Skip any URLs like
www.example.com with a newline in comments -->
-' => array(
+' => [
'href' => FALSE,
- ),
+ ],
'
<!-- Skip any URLs like www.comment.com in comments. <p>Also ignore http://commented.out/markup.</p> -->
-' => array(
+' => [
'href' => FALSE,
- ),
+ ],
'
<dl>
<dt>www.example.com</dt>
@@ -816,39 +816,39 @@ www.example.com with a newline in comments -->
<dt>Check www.example.net</dt>
<dd>Some text around http://www.example.info by person@example.info?</dd>
</dl>
-' => array(
+' => [
'href="http://www.example.com"' => TRUE,
'href="http://example.com"' => TRUE,
'href="mailto:person@example.com"' => TRUE,
'href="http://www.example.net"' => TRUE,
'href="http://www.example.info"' => TRUE,
'href="mailto:person@example.info"' => TRUE,
- ),
+ ],
'
<div>www.div.com</div>
<ul>
<li>http://listitem.com</li>
<li class="odd">www.class.listitem.com</li>
</ul>
-' => array(
+' => [
'<div><a href="http://www.div.com">www.div.com</a></div>' => TRUE,
'<li><a href="http://listitem.com">http://listitem.com</a></li>' => TRUE,
'<li class="odd"><a href="http://www.class.listitem.com">www.class.listitem.com</a></li>' => TRUE,
- ),
- );
+ ],
+ ];
$this->assertFilteredString($filter, $tests);
// URL trimming.
- $filter->setConfiguration(array(
- 'settings' => array(
+ $filter->setConfiguration([
+ 'settings' => [
'filter_url_length' => 20,
- )
- ));
- $tests = array(
- 'www.trimmed.com/d/ff.ext?a=1&b=2#a1' => array(
+ ]
+ ]);
+ $tests = [
+ 'www.trimmed.com/d/ff.ext?a=1&b=2#a1' => [
'<a href="http://www.trimmed.com/d/ff.ext?a=1&amp;b=2#a1">www.trimmed.com/d/f…</a>' => TRUE,
- ),
- );
+ ],
+ ];
$this->assertFilteredString($filter, $tests);
}
@@ -877,18 +877,18 @@ www.example.com with a newline in comments -->
foreach ($tasks as $value => $is_expected) {
// Not using assertIdentical, since combination with strpos() is hard to grok.
if ($is_expected) {
- $success = $this->assertTrue(strpos($result, $value) !== FALSE, format_string('@source: @value found. Filtered result: @result.', array(
+ $success = $this->assertTrue(strpos($result, $value) !== FALSE, format_string('@source: @value found. Filtered result: @result.', [
'@source' => var_export($source, TRUE),
'@value' => var_export($value, TRUE),
'@result' => var_export($result, TRUE),
- )));
+ ]));
}
else {
- $success = $this->assertTrue(strpos($result, $value) === FALSE, format_string('@source: @value not found. Filtered result: @result.', array(
+ $success = $this->assertTrue(strpos($result, $value) === FALSE, format_string('@source: @value not found. Filtered result: @result.', [
'@source' => var_export($source, TRUE),
'@value' => var_export($value, TRUE),
'@result' => var_export($result, TRUE),
- )));
+ ]));
}
if (!$success) {
$this->verbose('Source:<pre>' . Html::escape(var_export($source, TRUE)) . '</pre>'
@@ -921,11 +921,11 @@ www.example.com with a newline in comments -->
function testUrlFilterContent() {
// Get FilterUrl object.
$filter = $this->filters['filter_url'];
- $filter->setConfiguration(array(
- 'settings' => array(
+ $filter->setConfiguration([
+ 'settings' => [
'filter_url_length' => 496,
- )
- ));
+ ]
+ ]);
$path = __DIR__ . '/../..';
$input = file_get_contents($path . '/filter.url-input.txt');
@@ -1067,7 +1067,7 @@ body {color:red}
/*--><!]]>*/
</style></p>',
- format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '/*<![CDATA[*/'))
+ format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '/*<![CDATA[*/'])
);
$filtered_data = Html::normalize('<p><style>
@@ -1086,7 +1086,7 @@ body {color:red}
/*--><!]]>*/
</style></p>',
- format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/'))
+ format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/'])
);
$filtered_data = Html::normalize('<p><script>
@@ -1103,7 +1103,7 @@ body {color:red}
//--><!]]>
</script></p>',
- format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--//--><![CDATA[// ><!--'))
+ format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '<!--//--><![CDATA[// ><!--'])
);
$filtered_data = Html::normalize('<p><script>
@@ -1120,7 +1120,7 @@ body {color:red}
//--><!]]>
</script></p>',
- format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '// <![CDATA['))
+ format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '// <![CDATA['])
);
}
diff --git a/core/modules/filter/tests/src/Kernel/FilterSettingsTest.php b/core/modules/filter/tests/src/Kernel/FilterSettingsTest.php
index dc77eb41689..829840c3194 100644
--- a/core/modules/filter/tests/src/Kernel/FilterSettingsTest.php
+++ b/core/modules/filter/tests/src/Kernel/FilterSettingsTest.php
@@ -17,7 +17,7 @@ class FilterSettingsTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('filter');
+ public static $modules = ['filter'];
/**
* Tests explicit and implicit default settings for filters.
@@ -26,21 +26,21 @@ class FilterSettingsTest extends KernelTestBase {
$filter_info = $this->container->get('plugin.manager.filter')->getDefinitions();
// Create text format using filter default settings.
- $filter_defaults_format = FilterFormat::create(array(
+ $filter_defaults_format = FilterFormat::create([
'format' => 'filter_defaults',
'name' => 'Filter defaults',
- ));
+ ]);
$filter_defaults_format->save();
// Verify that default weights defined in hook_filter_info() were applied.
- $saved_settings = array();
+ $saved_settings = [];
foreach ($filter_defaults_format->filters() as $name => $filter) {
$expected_weight = $filter_info[$name]['weight'];
- $this->assertEqual($filter->weight, $expected_weight, format_string('@name filter weight %saved equals %default', array(
+ $this->assertEqual($filter->weight, $expected_weight, format_string('@name filter weight %saved equals %default', [
'@name' => $name,
'%saved' => $filter->weight,
'%default' => $expected_weight,
- )));
+ ]));
$saved_settings[$name]['weight'] = $expected_weight;
}
@@ -51,11 +51,11 @@ class FilterSettingsTest extends KernelTestBase {
// Verify that saved filter settings have not been changed.
foreach ($filter_defaults_format->filters() as $name => $filter) {
- $this->assertEqual($filter->weight, $saved_settings[$name]['weight'], format_string('@name filter weight %saved equals %previous', array(
+ $this->assertEqual($filter->weight, $saved_settings[$name]['weight'], format_string('@name filter weight %saved equals %previous', [
'@name' => $name,
'%saved' => $filter->weight,
'%previous' => $saved_settings[$name]['weight'],
- )));
+ ]));
}
}
diff --git a/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php b/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php
index e4053ae18ce..0f54245c1af 100644
--- a/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php
+++ b/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php
@@ -16,7 +16,7 @@ class MigrateFilterFormatTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('filter');
+ public static $modules = ['filter'];
/**
* {@inheritdoc}
diff --git a/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php b/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php
index f68b9357931..2dc9ce7c51f 100644
--- a/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php
+++ b/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php
@@ -48,7 +48,7 @@ class FilterFormatTest extends MigrateSqlSourceTestBase {
'name' => 'filter_autop',
'weight' => 0,
'status' => 1,
- 'settings' => serialize(array()),
+ 'settings' => serialize([]),
],
[
'format' => 'custom_text_format',
@@ -56,7 +56,7 @@ class FilterFormatTest extends MigrateSqlSourceTestBase {
'name' => 'filter_html',
'weight' => 1,
'status' => 1,
- 'settings' => serialize(array()),
+ 'settings' => serialize([]),
],
[
'format' => 'full_html',
@@ -64,7 +64,7 @@ class FilterFormatTest extends MigrateSqlSourceTestBase {
'name' => 'filter_url',
'weight' => 0,
'status' => 1,
- 'settings' => serialize(array()),
+ 'settings' => serialize([]),
],
];
diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install
index 36c71e46b47..4a16a8939a8 100644
--- a/core/modules/forum/forum.install
+++ b/core/modules/forum/forum.install
@@ -21,13 +21,13 @@ function forum_install() {
if (!\Drupal::service('config.installer')->isSyncing()) {
// Create a default forum so forum posts can be created.
- $term = Term::create(array(
+ $term = Term::create([
'name' => t('General discussion'),
'description' => '',
- 'parent' => array(0),
+ 'parent' => [0],
'vid' => 'forums',
'forum_container' => 0,
- ));
+ ]);
$term->save();
}
}
@@ -61,117 +61,117 @@ function forum_uninstall() {
* Implements hook_schema().
*/
function forum_schema() {
- $schema['forum'] = array(
+ $schema['forum'] = [
'description' => 'Stores the relationship of nodes to forum terms.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {node}.nid of the node.',
- ),
- 'vid' => array(
+ ],
+ 'vid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: The {node}.vid of the node.',
- ),
- 'tid' => array(
+ ],
+ 'tid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {taxonomy_term_data}.tid of the forum term assigned to the node.',
- ),
- ),
- 'indexes' => array(
- 'forum_topic' => array('nid', 'tid'),
- 'tid' => array('tid'),
- ),
- 'primary key' => array('vid'),
- 'foreign keys' => array(
- 'forum_node' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'forum_topic' => ['nid', 'tid'],
+ 'tid' => ['tid'],
+ ],
+ 'primary key' => ['vid'],
+ 'foreign keys' => [
+ 'forum_node' => [
'table' => 'node',
- 'columns' => array(
+ 'columns' => [
'nid' => 'nid',
'vid' => 'vid',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
- $schema['forum_index'] = array(
+ $schema['forum_index'] = [
'description' => 'Maintains denormalized information about node/term relationships.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'title' => array(
+ ],
+ 'title' => [
'description' => 'The node title.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'tid' => array(
+ ],
+ 'tid' => [
'description' => 'The term ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'sticky' => array(
+ ],
+ 'sticky' => [
'description' => 'Boolean indicating whether the node is sticky.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
- ),
- 'created' => array(
+ ],
+ 'created' => [
'description' => 'The Unix timestamp when the node was created.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'last_comment_timestamp' => array(
+ ],
+ 'last_comment_timestamp' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.',
- ),
- 'comment_count' => array(
+ ],
+ 'comment_count' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The total number of comments on this node.',
- ),
- ),
- 'indexes' => array(
- 'forum_topics' => array('nid', 'tid', 'sticky', 'last_comment_timestamp'),
- 'created' => array('created'),
- 'last_comment_timestamp' => array('last_comment_timestamp'),
- ),
- 'foreign keys' => array(
- 'tracked_node' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'forum_topics' => ['nid', 'tid', 'sticky', 'last_comment_timestamp'],
+ 'created' => ['created'],
+ 'last_comment_timestamp' => ['last_comment_timestamp'],
+ ],
+ 'foreign keys' => [
+ 'tracked_node' => [
'table' => 'node',
- 'columns' => array('nid' => 'nid'),
- ),
- 'term' => array(
+ 'columns' => ['nid' => 'nid'],
+ ],
+ 'term' => [
'table' => 'taxonomy_term_data',
- 'columns' => array(
+ 'columns' => [
'tid' => 'tid',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index 8d4a9f459da..c2de3c9e0bd 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -24,7 +24,7 @@ function forum_help($route_name, RouteMatchInterface $route_match) {
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Forum module lets you create threaded discussion forums with functionality similar to other message board systems. In a forum, users post topics and threads in nested hierarchies, allowing discussions to be categorized and grouped.') . '</p>';
- $output .= '<p>' . t('The Forum module adds and uses a content type called <em>Forum topic</em>. For background information on content types, see the <a href=":node_help">Node module help page</a>.', array(':node_help' => \Drupal::url('help.page', array('name' => 'node')))) . '</p>';
+ $output .= '<p>' . t('The Forum module adds and uses a content type called <em>Forum topic</em>. For background information on content types, see the <a href=":node_help">Node module help page</a>.', [':node_help' => \Drupal::url('help.page', ['name' => 'node'])]) . '</p>';
$output .= '<p>' . t('A forum is represented by a hierarchical structure, consisting of:');
$output .= '<ul>';
$output .= '<li>' . t('<em>Forums</em> (for example, <em>Recipes for cooking vegetables</em>)') . '</li>';
@@ -33,15 +33,15 @@ function forum_help($route_name, RouteMatchInterface $route_match) {
$output .= '<li>' . t('Optional <em>containers</em>, used to group similar forums. Forums can be placed inside containers, and vice versa.') . '</li>';
$output .= '</ul>';
$output .= '</p>';
- $output .= '<p>' . t('For more information, see the <a href=":forum">online documentation for the Forum module</a>.', array(':forum' => 'https://www.drupal.org/documentation/modules/forum')) . '</p>';
+ $output .= '<p>' . t('For more information, see the <a href=":forum">online documentation for the Forum module</a>.', [':forum' => 'https://www.drupal.org/documentation/modules/forum']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Setting up the forum structure') . '</dt>';
- $output .= '<dd>' . t('Visit the <a href=":forums">Forums page</a> to set up containers and forums to hold your discussion topics.', array(':forums' => \Drupal::url('forum.overview'))) . '</dd>';
+ $output .= '<dd>' . t('Visit the <a href=":forums">Forums page</a> to set up containers and forums to hold your discussion topics.', [':forums' => \Drupal::url('forum.overview')]) . '</dd>';
$output .= '<dt>' . t('Starting a discussion') . '</dt>';
- $output .= '<dd>' . t('The <a href=":create-topic">Forum topic</a> link on the <a href=":content-add">Add content</a> page creates the first post of a new threaded discussion, or thread.', array(':create-topic' => \Drupal::url('node.add', array('node_type' => 'forum')), ':content-add' => \Drupal::url('node.add_page'))) . '</dd>';
+ $output .= '<dd>' . t('The <a href=":create-topic">Forum topic</a> link on the <a href=":content-add">Add content</a> page creates the first post of a new threaded discussion, or thread.', [':create-topic' => \Drupal::url('node.add', ['node_type' => 'forum']), ':content-add' => \Drupal::url('node.add_page')]) . '</dd>';
$output .= '<dt>' . t('Navigating in the forum') . '</dt>';
- $output .= '<dd>' . t('Enabling the Forum module provides a default <em>Forums</em> menu item in the Tools menu that links to the <a href=":forums">Forums page</a>.', array(':forums' => \Drupal::url('forum.index'))) . '</dd>';
+ $output .= '<dd>' . t('Enabling the Forum module provides a default <em>Forums</em> menu item in the Tools menu that links to the <a href=":forums">Forums page</a>.', [':forums' => \Drupal::url('forum.index')]) . '</dd>';
$output .= '<dt>' . t('Moving forum topics') . '</dt>';
$output .= '<dd>' . t('A forum topic (and all of its comments) may be moved between forums by selecting a different forum while editing a forum topic. When moving a forum topic between forums, the <em>Leave shadow copy</em> option creates a link in the original forum pointing to the new location.') . '</dd>';
$output .= '<dt>' . t('Locking and disabling comments') . '</dt>';
@@ -51,21 +51,21 @@ function forum_help($route_name, RouteMatchInterface $route_match) {
case 'forum.overview':
$output = '<p>' . t('Forums contain forum topics. Use containers to group related forums.') . '</p>';
- $more_help_link = array(
+ $more_help_link = [
'#type' => 'link',
'#url' => Url::fromRoute('help.page', ['name' => 'forum']),
'#title' => t('More help'),
- '#attributes' => array(
- 'class' => array('icon-help'),
- ),
- );
- $container = array(
+ '#attributes' => [
+ 'class' => ['icon-help'],
+ ],
+ ];
+ $container = [
'#theme' => 'container',
'#children' => $more_help_link,
- '#attributes' => array(
- 'class' => array('more-link'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['more-link'],
+ ],
+ ];
$output .= \Drupal::service('renderer')->renderPlain($container);
return $output;
@@ -76,7 +76,7 @@ function forum_help($route_name, RouteMatchInterface $route_match) {
return '<p>' . t('A forum holds related forum topics.') . '</p>';
case 'forum.settings':
- return '<p>' . t('Adjust the display of your forum topics. Organize the forums on the <a href=":forum-structure">forum structure page</a>.', array(':forum-structure' => \Drupal::url('forum.overview'))) . '</p>';
+ return '<p>' . t('Adjust the display of your forum topics. Organize the forums on the <a href=":forum-structure">forum structure page</a>.', [':forum-structure' => \Drupal::url('forum.overview')]) . '</p>';
}
}
@@ -84,20 +84,20 @@ function forum_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function forum_theme() {
- return array(
- 'forums' => array(
- 'variables' => array('forums' => array(), 'topics' => array(), 'topics_pager' => array(), 'parents' => NULL, 'term' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL, 'header' => array()),
- ),
- 'forum_list' => array(
- 'variables' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
- ),
- 'forum_icon' => array(
- 'variables' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0, 'first_new' => FALSE),
- ),
- 'forum_submitted' => array(
- 'variables' => array('topic' => NULL),
- ),
- );
+ return [
+ 'forums' => [
+ 'variables' => ['forums' => [], 'topics' => [], 'topics_pager' => [], 'parents' => NULL, 'term' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL, 'header' => []],
+ ],
+ 'forum_list' => [
+ 'variables' => ['forums' => NULL, 'parents' => NULL, 'tid' => NULL],
+ ],
+ 'forum_icon' => [
+ 'variables' => ['new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0, 'first_new' => FALSE],
+ ],
+ 'forum_submitted' => [
+ 'variables' => ['topic' => NULL],
+ ],
+ ];
}
/**
@@ -158,7 +158,7 @@ function forum_node_presave(EntityInterface $node) {
$old_tid = \Drupal::service('forum.index_storage')->getOriginalTermId($node);
if ($old_tid && isset($node->forum_tid) && ($node->forum_tid != $old_tid) && !empty($node->shadow)) {
// A shadow copy needs to be created. Retain new term and add old term.
- $node->taxonomy_forums[count($node->taxonomy_forums)] = array('target_id' => $old_tid);
+ $node->taxonomy_forums[count($node->taxonomy_forums)] = ['target_id' => $old_tid];
}
}
}
@@ -241,7 +241,7 @@ function forum_node_predelete(EntityInterface $node) {
* Implements hook_ENTITY_TYPE_storage_load() for node entities.
*/
function forum_node_storage_load($nodes) {
- $node_vids = array();
+ $node_vids = [];
foreach ($nodes as $node) {
if (\Drupal::service('forum_manager')->checkNodeType($node)) {
$node_vids[] = $node->getRevisionId();
@@ -289,10 +289,10 @@ function forum_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterface $f
$vid = \Drupal::config('forum.settings')->get('vocabulary');
$vocabulary = $form_state->getFormObject()->getEntity();
if ($vid == $vocabulary->id()) {
- $form['help_forum_vocab'] = array(
+ $form['help_forum_vocab'] = [
'#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
'#weight' => -1,
- );
+ ];
// Forum's vocabulary always has single hierarchy. Forums and containers
// have only one parent or no parent for root items. By default this value
// is 0.
@@ -324,13 +324,13 @@ function forum_form_node_form_alter(&$form, FormStateInterface $form_state, $for
$forum_terms = $node->taxonomy_forums;
// If editing, give option to leave shadows.
$shadow = (count($forum_terms) > 1);
- $form['shadow'] = array(
+ $form['shadow'] = [
'#type' => 'checkbox',
'#title' => t('Leave shadow copy'),
'#default_value' => $shadow,
'#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'),
- );
- $form['forum_tid'] = array('#type' => 'value', '#value' => $node->forum_tid);
+ ];
+ $form['forum_tid'] = ['#type' => 'value', '#value' => $node->forum_tid];
}
if (isset($form['taxonomy_forums'])) {
@@ -361,7 +361,7 @@ function forum_preprocess_block(&$variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function forum_theme_suggestions_forums(array $variables) {
- $suggestions = array();
+ $suggestions = [];
$tid = $variables['term']->id();
// Provide separate template suggestions based on what's being output. Topic
@@ -408,24 +408,24 @@ function template_preprocess_forums(&$variables) {
$variables['tid'] = $variables['term']->id();
if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
if (!empty($variables['forums'])) {
- $variables['forums'] = array(
+ $variables['forums'] = [
'#theme' => 'forum_list',
'#forums' => $variables['forums'],
'#parents' => $variables['parents'],
'#tid' => $variables['tid'],
- );
+ ];
}
if ($variables['term'] && empty($variables['term']->forum_container->value) && !empty($variables['topics'])) {
$forum_topic_list_header = $variables['header'];
- $table = array(
+ $table = [
'#theme' => 'table__forum_topic_list',
'#responsive' => FALSE,
- '#attributes' => array('id' => 'forum-topic-' . $variables['tid']),
- '#header' => array(),
- '#rows' => array(),
- );
+ '#attributes' => ['id' => 'forum-topic-' . $variables['tid']],
+ '#header' => [],
+ '#rows' => [],
+ ];
if (!empty($forum_topic_list_header)) {
$table['#header'] = $forum_topic_list_header;
@@ -433,14 +433,14 @@ function template_preprocess_forums(&$variables) {
/** @var \Drupal\node\NodeInterface $topic */
foreach ($variables['topics'] as $id => $topic) {
- $variables['topics'][$id]->icon = array(
+ $variables['topics'][$id]->icon = [
'#theme' => 'forum_icon',
'#new_posts' => $topic->new,
'#num_posts' => $topic->comment_count,
'#comment_mode' => $topic->comment_mode,
'#sticky' => $topic->isSticky(),
'#first_new' => $topic->first_new,
- );
+ ];
// We keep the actual tid in forum table, if it's different from the
// current tid then it means the topic appears in two forums, one of
@@ -455,16 +455,16 @@ function template_preprocess_forums(&$variables) {
$variables['topics'][$id]->title_link = \Drupal::l($topic->getTitle(), $topic->urlInfo());
$variables['topics'][$id]->message = '';
}
- $forum_submitted = array('#theme' => 'forum_submitted', '#topic' => (object) array(
+ $forum_submitted = ['#theme' => 'forum_submitted', '#topic' => (object) [
'uid' => $topic->getOwnerId(),
'name' => $topic->getOwner()->getDisplayName(),
'created' => $topic->getCreatedTime(),
- ));
+ ]];
$variables['topics'][$id]->submitted = drupal_render($forum_submitted);
- $forum_submitted = array(
+ $forum_submitted = [
'#theme' => 'forum_submitted',
'#topic' => isset($topic->last_reply) ? $topic->last_reply : NULL,
- );
+ ];
$variables['topics'][$id]->last_reply = drupal_render($forum_submitted);
$variables['topics'][$id]->new_text = '';
@@ -473,28 +473,28 @@ function template_preprocess_forums(&$variables) {
if ($topic->new_replies) {
$page_number = \Drupal::entityManager()->getStorage('comment')
->getNewCommentPageNumber($topic->comment_count, $topic->new_replies, $topic, 'comment_forum');
- $query = $page_number ? array('page' => $page_number) : NULL;
- $variables['topics'][$id]->new_text = \Drupal::translation()->formatPlural($topic->new_replies, '1 new post<span class="visually-hidden"> in topic %title</span>', '@count new posts<span class="visually-hidden"> in topic %title</span>', array('%title' => $variables['topics'][$id]->label()));
+ $query = $page_number ? ['page' => $page_number] : NULL;
+ $variables['topics'][$id]->new_text = \Drupal::translation()->formatPlural($topic->new_replies, '1 new post<span class="visually-hidden"> in topic %title</span>', '@count new posts<span class="visually-hidden"> in topic %title</span>', ['%title' => $variables['topics'][$id]->label()]);
$variables['topics'][$id]->new_url = \Drupal::url('entity.node.canonical', ['node' => $topic->id()], ['query' => $query, 'fragment' => 'new']);
}
// Build table rows from topics.
- $row = array();
- $row[] = array(
- 'data' => array(
+ $row = [];
+ $row[] = [
+ 'data' => [
$topic->icon,
- array(
+ [
'#markup' => '<div class="forum__title"><div>' . $topic->title_link . '</div><div>' . $topic->submitted . '</div></div>',
- ),
- ),
- 'class' => array('forum__topic'),
- );
+ ],
+ ],
+ 'class' => ['forum__topic'],
+ ];
if ($topic->moved) {
- $row[] = array(
+ $row[] = [
'data' => $topic->message,
'colspan' => '2',
- );
+ ];
}
else {
$new_replies = '';
@@ -502,27 +502,27 @@ function template_preprocess_forums(&$variables) {
$new_replies = '<br /><a href="' . $topic->new_url . '">' . $topic->new_text . '</a>';
}
- $row[] = array(
+ $row[] = [
'data' => [
[
'#prefix' => $topic->comment_count,
'#markup' => $new_replies,
],
],
- 'class' => array('forum__replies'),
- );
- $row[] = array(
+ 'class' => ['forum__replies'],
+ ];
+ $row[] = [
'data' => $topic->last_reply,
- 'class' => array('forum__last-reply'),
- );
+ 'class' => ['forum__last-reply'],
+ ];
}
$table['#rows'][] = $row;
}
$variables['topics'] = $table;
- $variables['topics_pager'] = array(
+ $variables['topics_pager'] = [
'#type' => 'pager',
- );
+ ];
}
}
}
@@ -545,7 +545,7 @@ function template_preprocess_forum_list(&$variables) {
$row = 0;
// Sanitize each forum so that the template can safely print the data.
foreach ($variables['forums'] as $id => $forum) {
- $variables['forums'][$id]->description = array('#markup' => $forum->description->value);
+ $variables['forums'][$id]->description = ['#markup' => $forum->description->value];
$variables['forums'][$id]->link = forum_uri($forum);
$variables['forums'][$id]->name = $forum->label();
$variables['forums'][$id]->is_container = !empty($forum->forum_container->value);
@@ -561,20 +561,20 @@ function template_preprocess_forum_list(&$variables) {
if ($user->isAuthenticated()) {
$variables['forums'][$id]->new_topics = \Drupal::service('forum_manager')->unreadTopics($forum->id(), $user->id());
if ($variables['forums'][$id]->new_topics) {
- $variables['forums'][$id]->new_text = \Drupal::translation()->formatPlural($variables['forums'][$id]->new_topics, '1 new post<span class="visually-hidden"> in forum %title</span>', '@count new posts<span class="visually-hidden"> in forum %title</span>', array('%title' => $variables['forums'][$id]->label()));
+ $variables['forums'][$id]->new_text = \Drupal::translation()->formatPlural($variables['forums'][$id]->new_topics, '1 new post<span class="visually-hidden"> in forum %title</span>', '@count new posts<span class="visually-hidden"> in forum %title</span>', ['%title' => $variables['forums'][$id]->label()]);
$variables['forums'][$id]->new_url = \Drupal::url('forum.page', ['taxonomy_term' => $forum->id()], ['fragment' => 'new']);
$variables['forums'][$id]->icon_class = 'new';
$variables['forums'][$id]->icon_title = t('New posts');
}
$variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics;
}
- $forum_submitted = array('#theme' => 'forum_submitted', '#topic' => $forum->last_post);
+ $forum_submitted = ['#theme' => 'forum_submitted', '#topic' => $forum->last_post];
$variables['forums'][$id]->last_reply = drupal_render($forum_submitted);
}
- $variables['pager'] = array(
+ $variables['pager'] = [
'#type' => 'pager',
- );
+ ];
// Give meaning to $tid for themers. $tid actually stands for term ID.
$variables['forum_id'] = $variables['tid'];
@@ -635,7 +635,7 @@ function template_preprocess_forum_icon(&$variables) {
function template_preprocess_forum_submitted(&$variables) {
$variables['author'] = '';
if (isset($variables['topic']->uid)) {
- $username = array('#theme' => 'username', '#account' => User::load($variables['topic']->uid));
+ $username = ['#theme' => 'username', '#account' => User::load($variables['topic']->uid)];
$variables['author'] = drupal_render($username);
}
$variables['time'] = isset($variables['topic']->created) ? \Drupal::service('date.formatter')->formatTimeDiffSince($variables['topic']->created) : '';
diff --git a/core/modules/forum/forum.views.inc b/core/modules/forum/forum.views.inc
index fa7174f0b29..6f2425912b5 100644
--- a/core/modules/forum/forum.views.inc
+++ b/core/modules/forum/forum.views.inc
@@ -11,147 +11,147 @@
function forum_views_data() {
$data['forum_index']['table']['group'] = t('Forum');
- $data['forum_index']['table']['base'] = array(
+ $data['forum_index']['table']['base'] = [
'field' => 'nid',
'title' => t('Forum content'),
'access query tag' => 'node_access',
- );
+ ];
- $data['forum_index']['nid'] = array(
+ $data['forum_index']['nid'] = [
'title' => t('Nid'),
'help' => t('The content ID of the forum index entry.'),
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- 'relationship' => array(
+ ],
+ 'relationship' => [
'base' => 'node',
'base field' => 'nid',
'label' => t('Node'),
- ),
- );
+ ],
+ ];
- $data['forum_index']['title'] = array(
+ $data['forum_index']['title'] = [
'title' => t('Title'),
'help' => t('The content title.'),
- 'field' => array(
+ 'field' => [
'id' => 'standard',
'link_to_node default' => TRUE,
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- );
+ ],
+ ];
- $data['forum_index']['tid'] = array(
+ $data['forum_index']['tid'] = [
'title' => t('Has taxonomy term ID'),
'help' => t('Display content if it has the selected taxonomy terms.'),
- 'argument' => array(
+ 'argument' => [
'id' => 'taxonomy_index_tid',
'name table' => 'taxonomy_term_data',
'name field' => 'name',
'empty field name' => t('Uncategorized'),
'numeric' => TRUE,
'skip base' => 'taxonomy_term_data',
- ),
- 'field' => array(
+ ],
+ 'field' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'title' => t('Has taxonomy term'),
'id' => 'taxonomy_index_tid',
'hierarchy table' => 'taxonomy_term_hierarchy',
'numeric' => TRUE,
'skip base' => 'taxonomy_term_data',
'allow empty' => TRUE,
- ),
- 'relationship' => array(
+ ],
+ 'relationship' => [
'base' => 'taxonomy_term',
'base field' => 'tid',
'label' => t('Term'),
- ),
- );
+ ],
+ ];
- $data['forum_index']['created'] = array(
+ $data['forum_index']['created'] = [
'title' => t('Post date'),
'help' => t('The date the content was posted.'),
- 'field' => array(
+ 'field' => [
'id' => 'date',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'date'
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- );
+ ],
+ ];
- $data['forum_index']['sticky'] = array(
+ $data['forum_index']['sticky'] = [
'title' => t('Sticky'),
'help' => t('Whether or not the content is sticky.'),
- 'field' => array(
+ 'field' => [
'id' => 'boolean',
'click sortable' => TRUE,
- 'output formats' => array(
- 'sticky' => array(t('Sticky'), t('Not sticky')),
- ),
- ),
- 'filter' => array(
+ 'output formats' => [
+ 'sticky' => [t('Sticky'), t('Not sticky')],
+ ],
+ ],
+ 'filter' => [
'id' => 'boolean',
'label' => t('Sticky'),
'type' => 'yes-no',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
'help' => t('Whether or not the content is sticky. To list sticky content first, set this to descending.'),
- ),
- );
+ ],
+ ];
- $data['forum_index']['last_comment_timestamp'] = array(
+ $data['forum_index']['last_comment_timestamp'] = [
'title' => t('Last comment time'),
'help' => t('Date and time of when the last comment was posted.'),
- 'field' => array(
+ 'field' => [
'id' => 'comment_last_timestamp',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'date',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- );
+ ],
+ ];
- $data['forum_index']['comment_count'] = array(
+ $data['forum_index']['comment_count'] = [
'title' => t('Comment count'),
'help' => t('The number of comments a node has.'),
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php b/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php
index 01e6c49a768..1a359010a85 100644
--- a/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php
+++ b/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php
@@ -32,9 +32,9 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
foreach ($parents as $parent) {
$breadcrumb->addCacheableDependency($parent);
$breadcrumb->addLink(Link::createFromRoute($parent->label(), 'forum.page',
- array(
+ [
'taxonomy_term' => $parent->id(),
- )
+ ]
));
}
}
diff --git a/core/modules/forum/src/Controller/ForumController.php b/core/modules/forum/src/Controller/ForumController.php
index 0e3d99562df..2348872b477 100644
--- a/core/modules/forum/src/Controller/ForumController.php
+++ b/core/modules/forum/src/Controller/ForumController.php
@@ -207,9 +207,9 @@ class ForumController extends ControllerBase {
* @return array
* A render array.
*/
- protected function build($forums, TermInterface $term, $topics = array(), $parents = array(), $header = array()) {
+ protected function build($forums, TermInterface $term, $topics = [], $parents = [], $header = []) {
$config = $this->config('forum.settings');
- $build = array(
+ $build = [
'#theme' => 'forums',
'#forums' => $forums,
'#topics' => $topics,
@@ -218,9 +218,9 @@ class ForumController extends ControllerBase {
'#term' => $term,
'#sortby' => $config->get('topics.order'),
'#forums_per_page' => $config->get('topics.page_limit'),
- );
+ ];
if (empty($term->forum_container->value)) {
- $build['#attached']['feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->getName());
+ $build['#attached']['feed'][] = ['taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->getName()];
}
$this->renderer->addCacheableDependency($build, $config);
@@ -252,10 +252,10 @@ class ForumController extends ControllerBase {
*/
public function addForum() {
$vid = $this->config('forum.settings')->get('vocabulary');
- $taxonomy_term = $this->termStorage->create(array(
+ $taxonomy_term = $this->termStorage->create([
'vid' => $vid,
'forum_controller' => 0,
- ));
+ ]);
return $this->entityFormBuilder()->getForm($taxonomy_term, 'forum');
}
@@ -267,10 +267,10 @@ class ForumController extends ControllerBase {
*/
public function addContainer() {
$vid = $this->config('forum.settings')->get('vocabulary');
- $taxonomy_term = $this->termStorage->create(array(
+ $taxonomy_term = $this->termStorage->create([
'vid' => $vid,
'forum_container' => 1,
- ));
+ ]);
return $this->entityFormBuilder()->getForm($taxonomy_term, 'container');
}
@@ -325,10 +325,10 @@ class ForumController extends ControllerBase {
$links['login'] = [
'#attributes' => ['class' => ['action-links']],
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => $this->t('Log in to post new content in the forum.'),
'url' => Url::fromRoute('user.login', [], ['query' => $this->getDestinationArray()]),
- ),
+ ],
];
}
}
diff --git a/core/modules/forum/src/Form/DeleteForm.php b/core/modules/forum/src/Form/DeleteForm.php
index 75201736781..5b3666a843b 100644
--- a/core/modules/forum/src/Form/DeleteForm.php
+++ b/core/modules/forum/src/Form/DeleteForm.php
@@ -30,7 +30,7 @@ class DeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete the forum %label?', array('%label' => $this->taxonomyTerm->label()));
+ return $this->t('Are you sure you want to delete the forum %label?', ['%label' => $this->taxonomyTerm->label()]);
}
/**
@@ -61,8 +61,8 @@ class DeleteForm extends ConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->taxonomyTerm->delete();
- drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label())));
- $this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()));
+ drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
+ $this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', ['%label' => $this->taxonomyTerm->label()]);
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/core/modules/forum/src/Form/ForumForm.php b/core/modules/forum/src/Form/ForumForm.php
index 30f0cf1466e..ed0a7683a5d 100644
--- a/core/modules/forum/src/Form/ForumForm.php
+++ b/core/modules/forum/src/Form/ForumForm.php
@@ -50,7 +50,7 @@ class ForumForm extends TermForm {
$form['parent']['#tree'] = TRUE;
$form['parent'][0] = $this->forumParentSelect($taxonomy_term->id(), $this->t('Parent'));
- $form['#theme_wrappers'] = array('form__forum');
+ $form['#theme_wrappers'] = ['form__forum'];
$this->forumFormType = $this->t('forum');
return $form;
}
@@ -62,7 +62,7 @@ class ForumForm extends TermForm {
$term = parent::buildEntity($form, $form_state);
// Assign parents from forum parent select field.
- $term->parent = array($form_state->getValue(array('parent', 0)));
+ $term->parent = [$form_state->getValue(['parent', 0])];
return $term;
}
@@ -81,14 +81,14 @@ class ForumForm extends TermForm {
$view_link = $term->link($term->getName());
switch ($status) {
case SAVED_NEW:
- drupal_set_message($this->t('Created new @type %term.', array('%term' => $view_link, '@type' => $this->forumFormType)));
- $this->logger('forum')->notice('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link));
+ drupal_set_message($this->t('Created new @type %term.', ['%term' => $view_link, '@type' => $this->forumFormType]));
+ $this->logger('forum')->notice('Created new @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
$form_state->setValue('tid', $term->id());
break;
case SAVED_UPDATED:
- drupal_set_message($this->t('The @type %term has been updated.', array('%term' => $term->getName(), '@type' => $this->forumFormType)));
- $this->logger('forum')->notice('Updated @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link));
+ drupal_set_message($this->t('The @type %term has been updated.', ['%term' => $term->getName(), '@type' => $this->forumFormType]));
+ $this->logger('forum')->notice('Updated @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
break;
}
@@ -155,14 +155,14 @@ class ForumForm extends TermForm {
$description = $this->t('Forums may be placed at the top (root) level, or inside another container or forum.');
- return array(
+ return [
'#type' => 'select',
'#title' => $title,
'#default_value' => $parent,
'#options' => $options,
'#description' => $description,
'#required' => TRUE,
- );
+ ];
}
}
diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php
index ba9c033de72..df6f94725a0 100644
--- a/core/modules/forum/src/Form/Overview.php
+++ b/core/modules/forum/src/Form/Overview.php
@@ -80,10 +80,10 @@ class Overview extends OverviewTerms {
unset($form['actions']['reset_alphabetical']);
// Use the existing taxonomy overview submit handler.
- $form['terms']['#empty'] = $this->t('No containers or forums available. <a href=":container">Add container</a> or <a href=":forum">Add forum</a>.', array(
+ $form['terms']['#empty'] = $this->t('No containers or forums available. <a href=":container">Add container</a> or <a href=":forum">Add forum</a>.', [
':container' => $this->url('forum.add_container'),
':forum' => $this->url('forum.add_forum')
- ));
+ ]);
return $form;
}
diff --git a/core/modules/forum/src/ForumIndexStorage.php b/core/modules/forum/src/ForumIndexStorage.php
index 35b2274b7e3..d644ca9fd41 100644
--- a/core/modules/forum/src/ForumIndexStorage.php
+++ b/core/modules/forum/src/ForumIndexStorage.php
@@ -31,7 +31,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
* {@inheritdoc}
*/
public function getOriginalTermId(NodeInterface $node) {
- return $this->database->queryRange("SELECT f.tid FROM {forum} f INNER JOIN {node} n ON f.vid = n.vid WHERE n.nid = :nid ORDER BY f.vid DESC", 0, 1, array(':nid' => $node->id()))->fetchField();
+ return $this->database->queryRange("SELECT f.tid FROM {forum} f INNER JOIN {node} n ON f.vid = n.vid WHERE n.nid = :nid ORDER BY f.vid DESC", 0, 1, [':nid' => $node->id()])->fetchField();
}
/**
@@ -39,11 +39,11 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
*/
public function create(NodeInterface $node) {
$this->database->insert('forum')
- ->fields(array(
+ ->fields([
'tid' => $node->forum_tid,
'vid' => $node->getRevisionId(),
'nid' => $node->id(),
- ))
+ ])
->execute();
}
@@ -52,7 +52,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
*/
public function read(array $vids) {
return $this->database->select('forum', 'f')
- ->fields('f', array('nid', 'tid'))
+ ->fields('f', ['nid', 'tid'])
->condition('f.vid', $vids, 'IN')
->execute();
}
@@ -81,7 +81,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
*/
public function update(NodeInterface $node) {
$this->database->update('forum')
- ->fields(array('tid' => $node->forum_tid))
+ ->fields(['tid' => $node->forum_tid])
->condition('vid', $node->getRevisionId())
->execute();
}
@@ -91,22 +91,22 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
*/
public function updateIndex(NodeInterface $node) {
$nid = $node->id();
- $count = $this->database->query("SELECT COUNT(cid) FROM {comment_field_data} c INNER JOIN {forum_index} i ON c.entity_id = i.nid WHERE c.entity_id = :nid AND c.field_name = 'comment_forum' AND c.entity_type = 'node' AND c.status = :status AND c.default_langcode = 1", array(
+ $count = $this->database->query("SELECT COUNT(cid) FROM {comment_field_data} c INNER JOIN {forum_index} i ON c.entity_id = i.nid WHERE c.entity_id = :nid AND c.field_name = 'comment_forum' AND c.entity_type = 'node' AND c.status = :status AND c.default_langcode = 1", [
':nid' => $nid,
':status' => CommentInterface::PUBLISHED,
- ))->fetchField();
+ ])->fetchField();
if ($count > 0) {
// Comments exist.
- $last_reply = $this->database->queryRange("SELECT cid, name, created, uid FROM {comment_field_data} WHERE entity_id = :nid AND field_name = 'comment_forum' AND entity_type = 'node' AND status = :status AND default_langcode = 1 ORDER BY cid DESC", 0, 1, array(
+ $last_reply = $this->database->queryRange("SELECT cid, name, created, uid FROM {comment_field_data} WHERE entity_id = :nid AND field_name = 'comment_forum' AND entity_type = 'node' AND status = :status AND default_langcode = 1 ORDER BY cid DESC", 0, 1, [
':nid' => $nid,
':status' => CommentInterface::PUBLISHED,
- ))->fetchObject();
+ ])->fetchObject();
$this->database->update('forum_index')
- ->fields( array(
+ ->fields( [
'comment_count' => $count,
'last_comment_timestamp' => $last_reply->created,
- ))
+ ])
->condition('nid', $nid)
->execute();
}
@@ -114,10 +114,10 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
// Comments do not exist.
// @todo This should be actually filtering on the desired node language
$this->database->update('forum_index')
- ->fields( array(
+ ->fields( [
'comment_count' => 0,
'last_comment_timestamp' => $node->getCreatedTime(),
- ))
+ ])
->condition('nid', $nid)
->execute();
}
@@ -128,11 +128,11 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
*/
public function createIndex(NodeInterface $node) {
$query = $this->database->insert('forum_index')
- ->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
+ ->fields(['nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp']);
foreach ($node->getTranslationLanguages() as $langcode => $language) {
$translation = $node->getTranslation($langcode);
foreach ($translation->taxonomy_forums as $item) {
- $query->values(array(
+ $query->values([
'nid' => $node->id(),
'title' => $translation->label(),
'tid' => $item->target_id,
@@ -140,7 +140,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
'created' => $node->getCreatedTime(),
'comment_count' => 0,
'last_comment_timestamp' => $node->getCreatedTime(),
- ));
+ ]);
}
}
$query->execute();
diff --git a/core/modules/forum/src/ForumManager.php b/core/modules/forum/src/ForumManager.php
index 9fe49a84138..05cd8607607 100644
--- a/core/modules/forum/src/ForumManager.php
+++ b/core/modules/forum/src/ForumManager.php
@@ -75,28 +75,28 @@ class ForumManager implements ForumManagerInterface {
*
* @var array
*/
- protected $lastPostData = array();
+ protected $lastPostData = [];
/**
* Array of forum statistics keyed by forum (term) id.
*
* @var array
*/
- protected $forumStatistics = array();
+ protected $forumStatistics = [];
/**
* Array of forum children keyed by parent forum (term) id.
*
* @var array
*/
- protected $forumChildren = array();
+ protected $forumChildren = [];
/**
* Array of history keyed by nid.
*
* @var array
*/
- protected $history = array();
+ protected $history = [];
/**
* Cached forum index.
@@ -135,11 +135,11 @@ class ForumManager implements ForumManagerInterface {
$forum_per_page = $config->get('topics.page_limit');
$sortby = $config->get('topics.order');
- $header = array(
- array('data' => $this->t('Topic'), 'field' => 'f.title'),
- array('data' => $this->t('Replies'), 'field' => 'f.comment_count'),
- array('data' => $this->t('Last reply'), 'field' => 'f.last_comment_timestamp'),
- );
+ $header = [
+ ['data' => $this->t('Topic'), 'field' => 'f.title'],
+ ['data' => $this->t('Replies'), 'field' => 'f.comment_count'],
+ ['data' => $this->t('Last reply'), 'field' => 'f.last_comment_timestamp'],
+ ];
$order = $this->getTopicOrder($sortby);
for ($i = 0; $i < count($header); $i++) {
@@ -168,7 +168,7 @@ class ForumManager implements ForumManagerInterface {
$query->setCountQuery($count_query);
$result = $query->execute();
- $nids = array();
+ $nids = [];
foreach ($result as $record) {
$nids[] = $record->nid;
}
@@ -177,15 +177,15 @@ class ForumManager implements ForumManagerInterface {
$query = $this->connection->select('node_field_data', 'n')
->extend('Drupal\Core\Database\Query\TableSortExtender');
- $query->fields('n', array('nid'));
+ $query->fields('n', ['nid']);
$query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_name = 'comment_forum' AND ces.entity_type = 'node'");
- $query->fields('ces', array(
+ $query->fields('ces', [
'cid',
'last_comment_uid',
'last_comment_timestamp',
'comment_count'
- ));
+ ]);
$query->join('forum_index', 'f', 'f.nid = n.nid');
$query->addField('f', 'tid', 'forum_tid');
@@ -205,7 +205,7 @@ class ForumManager implements ForumManagerInterface {
// and just fall back to the default language.
->condition('n.default_langcode', 1);
- $result = array();
+ $result = [];
foreach ($query->execute() as $row) {
$topic = $nodes[$row->nid];
$topic->comment_mode = $topic->comment_forum->status;
@@ -217,10 +217,10 @@ class ForumManager implements ForumManagerInterface {
}
}
else {
- $result = array();
+ $result = [];
}
- $topics = array();
+ $topics = [];
$first_new_found = FALSE;
foreach ($result as $topic) {
if ($account->isAuthenticated()) {
@@ -258,7 +258,7 @@ class ForumManager implements ForumManagerInterface {
$topics[$topic->id()] = $topic;
}
- return array('topics' => $topics, 'header' => $header);
+ return ['topics' => $topics, 'header' => $header];
}
@@ -280,16 +280,16 @@ class ForumManager implements ForumManagerInterface {
protected function getTopicOrder($sortby) {
switch ($sortby) {
case static::NEWEST_FIRST:
- return array('field' => 'f.last_comment_timestamp', 'sort' => 'desc');
+ return ['field' => 'f.last_comment_timestamp', 'sort' => 'desc'];
case static::OLDEST_FIRST:
- return array('field' => 'f.last_comment_timestamp', 'sort' => 'asc');
+ return ['field' => 'f.last_comment_timestamp', 'sort' => 'asc'];
case static::MOST_POPULAR_FIRST:
- return array('field' => 'f.comment_count', 'sort' => 'desc');
+ return ['field' => 'f.comment_count', 'sort' => 'desc'];
case static::LEAST_POPULAR_FIRST:
- return array('field' => 'f.comment_count', 'sort' => 'asc');
+ return ['field' => 'f.comment_count', 'sort' => 'asc'];
}
}
@@ -309,7 +309,7 @@ class ForumManager implements ForumManagerInterface {
protected function lastVisit($nid, AccountInterface $account) {
if (empty($this->history[$nid])) {
$result = $this->connection->select('history', 'h')
- ->fields('h', array('nid', 'timestamp'))
+ ->fields('h', ['nid', 'timestamp'])
->condition('uid', $account->id())
->execute();
foreach ($result as $t) {
@@ -334,13 +334,13 @@ class ForumManager implements ForumManagerInterface {
}
// Query "Last Post" information for this forum.
$query = $this->connection->select('node_field_data', 'n');
- $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $tid));
+ $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', [':tid' => $tid]);
$query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_name = 'comment_forum' AND ces.entity_type = 'node'");
$query->join('users_field_data', 'u', 'ces.last_comment_uid = u.uid AND u.default_langcode = 1');
$query->addExpression('CASE ces.last_comment_uid WHEN 0 THEN ces.last_comment_name ELSE u.name END', 'last_comment_name');
$topic = $query
- ->fields('ces', array('last_comment_timestamp', 'last_comment_uid'))
+ ->fields('ces', ['last_comment_timestamp', 'last_comment_uid'])
->condition('n.status', 1)
->orderBy('last_comment_timestamp', 'DESC')
->range(0, 1)
@@ -378,7 +378,7 @@ class ForumManager implements ForumManagerInterface {
$query->addExpression('COUNT(n.nid)', 'topic_count');
$query->addExpression('SUM(ces.comment_count)', 'comment_count');
$this->forumStatistics = $query
- ->fields('f', array('tid'))
+ ->fields('f', ['tid'])
->condition('n.status', 1)
->condition('n.default_langcode', 1)
->groupBy('tid')
@@ -399,7 +399,7 @@ class ForumManager implements ForumManagerInterface {
if (!empty($this->forumChildren[$tid])) {
return $this->forumChildren[$tid];
}
- $forums = array();
+ $forums = [];
$_forums = $this->entityManager->getStorage('taxonomy_term')->loadTree($vid, $tid, NULL, TRUE);
foreach ($_forums as $forum) {
// Merge in the topic and post counters.
@@ -430,13 +430,13 @@ class ForumManager implements ForumManagerInterface {
}
$vid = $this->configFactory->get('forum.settings')->get('vocabulary');
- $index = $this->entityManager->getStorage('taxonomy_term')->create(array(
+ $index = $this->entityManager->getStorage('taxonomy_term')->create([
'tid' => 0,
'container' => 1,
- 'parents' => array(),
+ 'parents' => [],
'isIndex' => TRUE,
'vid' => $vid
- ));
+ ]);
// Load the tree below.
$index->forums = $this->getChildren($vid, 0);
@@ -451,7 +451,7 @@ class ForumManager implements ForumManagerInterface {
// Reset the index.
$this->index = NULL;
// Reset history.
- $this->history = array();
+ $this->history = [];
}
/**
@@ -475,8 +475,8 @@ class ForumManager implements ForumManagerInterface {
*/
public function unreadTopics($term, $uid) {
$query = $this->connection->select('node_field_data', 'n');
- $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $term));
- $query->leftJoin('history', 'h', 'n.nid = h.nid AND h.uid = :uid', array(':uid' => $uid));
+ $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', [':tid' => $term]);
+ $query->leftJoin('history', 'h', 'n.nid = h.nid AND h.uid = :uid', [':uid' => $uid]);
$query->addExpression('COUNT(n.nid)', 'count');
return $query
->condition('status', 1)
@@ -506,10 +506,10 @@ class ForumManager implements ForumManagerInterface {
public function __wakeup() {
$this->defaultWakeup();
// Initialize static cache.
- $this->history = array();
- $this->lastPostData = array();
- $this->forumChildren = array();
- $this->forumStatistics = array();
+ $this->history = [];
+ $this->lastPostData = [];
+ $this->forumChildren = [];
+ $this->forumStatistics = [];
$this->index = NULL;
}
diff --git a/core/modules/forum/src/ForumSettingsForm.php b/core/modules/forum/src/ForumSettingsForm.php
index ac9b325cf25..12bb551ffa0 100644
--- a/core/modules/forum/src/ForumSettingsForm.php
+++ b/core/modules/forum/src/ForumSettingsForm.php
@@ -30,35 +30,35 @@ class ForumSettingsForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('forum.settings');
- $options = array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500);
- $form['forum_hot_topic'] = array(
+ $options = [5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500];
+ $form['forum_hot_topic'] = [
'#type' => 'select',
'#title' => $this->t('Hot topic threshold'),
'#default_value' => $config->get('topics.hot_threshold'),
'#options' => array_combine($options, $options),
'#description' => $this->t('The number of replies a topic must have to be considered "hot".'),
- );
- $options = array(10, 25, 50, 75, 100);
- $form['forum_per_page'] = array(
+ ];
+ $options = [10, 25, 50, 75, 100];
+ $form['forum_per_page'] = [
'#type' => 'select',
'#title' => $this->t('Topics per page'),
'#default_value' => $config->get('topics.page_limit'),
'#options' => array_combine($options, $options),
'#description' => $this->t('Default number of forum topics displayed per page.'),
- );
- $forder = array(
+ ];
+ $forder = [
1 => $this->t('Date - newest first'),
2 => $this->t('Date - oldest first'),
3 => $this->t('Posts - most active first'),
4 => $this->t('Posts - least active first')
- );
- $form['forum_order'] = array(
+ ];
+ $form['forum_order'] = [
'#type' => 'radios',
'#title' => $this->t('Default order'),
'#default_value' => $config->get('topics.order'),
'#options' => $forder,
'#description' => $this->t('Default display order for topics.'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
index e65f1df940e..8095ceffb8e 100644
--- a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
+++ b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
@@ -19,14 +19,14 @@ abstract class ForumBlockBase extends BlockBase {
*/
public function build() {
$result = $this->buildForumQuery()->execute();
- $elements = array();
+ $elements = [];
if ($node_title_list = node_title_list($result)) {
$elements['forum_list'] = $node_title_list;
- $elements['forum_more'] = array(
+ $elements['forum_more'] = [
'#type' => 'more_link',
'#url' => Url::fromRoute('forum.index'),
- '#attributes' => array('title' => $this->t('Read the latest forum topics.')),
- );
+ '#attributes' => ['title' => $this->t('Read the latest forum topics.')],
+ ];
}
return $elements;
}
@@ -43,12 +43,12 @@ abstract class ForumBlockBase extends BlockBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
- 'properties' => array(
+ return [
+ 'properties' => [
'administrative' => TRUE,
- ),
+ ],
'block_count' => 5,
- );
+ ];
}
/**
@@ -63,12 +63,12 @@ abstract class ForumBlockBase extends BlockBase {
*/
public function blockForm($form, FormStateInterface $form_state) {
$range = range(2, 20);
- $form['block_count'] = array(
+ $form['block_count'] = [
'#type' => 'select',
'#title' => $this->t('Number of topics'),
'#default_value' => $this->configuration['block_count'],
'#options' => array_combine($range, $range),
- );
+ ];
return $form;
}
diff --git a/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php b/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php
index 761dc0f7277..95603d8446b 100644
--- a/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php
+++ b/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php
@@ -26,7 +26,7 @@ class ForumLeafConstraintValidator extends ConstraintValidator {
// The forum_container flag must not be set.
if (!empty($item->entity->forum_container->value)) {
- $this->context->addViolation($constraint->noLeafMessage, array('%forum' => $item->entity->getName()));
+ $this->context->addViolation($constraint->noLeafMessage, ['%forum' => $item->entity->getName()]);
}
}
diff --git a/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php b/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php
index 99ed94569f4..f5677e41b6a 100644
--- a/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php
+++ b/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php
@@ -19,19 +19,19 @@ class ForumIntegrationTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('forum_test_views');
+ public static $modules = ['forum_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_forum_index');
+ public static $testViews = ['test_forum_index'];
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('forum_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['forum_test_views']);
}
@@ -41,25 +41,25 @@ class ForumIntegrationTest extends ViewTestBase {
public function testForumIntegration() {
// Create a forum.
$entity_manager = $this->container->get('entity.manager');
- $term = $entity_manager->getStorage('taxonomy_term')->create(array('vid' => 'forums', 'name' => $this->randomMachineName()));
+ $term = $entity_manager->getStorage('taxonomy_term')->create(['vid' => 'forums', 'name' => $this->randomMachineName()]);
$term->save();
$comment_storage = $entity_manager->getStorage('comment');
// Create some nodes which are part of this forum with some comments.
- $nodes = array();
+ $nodes = [];
for ($i = 0; $i < 3; $i++) {
$node = $this->drupalCreateNode(['type' => 'forum', 'taxonomy_forums' => [$term->id()], 'sticky' => $i == 0 ? NodeInterface::STICKY : NodeInterface::NOT_STICKY]);
$nodes[] = $node;
}
- $account = $this->drupalCreateUser(array('skip comment approval'));
+ $account = $this->drupalCreateUser(['skip comment approval']);
$this->drupalLogin($account);
- $comments = array();
+ $comments = [];
foreach ($nodes as $index => $node) {
for ($i = 0; $i <= $index; $i++) {
- $comment = $comment_storage->create(array('entity_type' => 'node', 'entity_id' => $node->id(), 'field_name' => 'comment_forum'));
+ $comment = $comment_storage->create(['entity_type' => 'node', 'entity_id' => $node->id(), 'field_name' => 'comment_forum']);
$comment->save();
$comments[$comment->get('entity_id')->target_id][$comment->id()] = $comment;
}
@@ -68,27 +68,27 @@ class ForumIntegrationTest extends ViewTestBase {
$view = Views::getView('test_forum_index');
$this->executeView($view);
- $expected_result = array();
- $expected_result[] = array(
+ $expected_result = [];
+ $expected_result[] = [
'nid' => $nodes[0]->id(),
'sticky' => NodeInterface::STICKY,
'comment_count' => 1.
- );
- $expected_result[] = array(
+ ];
+ $expected_result[] = [
'nid' => $nodes[1]->id(),
'sticky' => NodeInterface::NOT_STICKY,
'comment_count' => 2.
- );
- $expected_result[] = array(
+ ];
+ $expected_result[] = [
'nid' => $nodes[2]->id(),
'sticky' => NodeInterface::NOT_STICKY,
'comment_count' => 3.
- );
- $column_map = array(
+ ];
+ $column_map = [
'nid' => 'nid',
'forum_index_sticky' => 'sticky',
'forum_index_comment_count' => 'comment_count',
- );
+ ];
$this->assertIdenticalResultset($view, $expected_result, $column_map);
}
diff --git a/core/modules/forum/tests/src/Functional/ForumBlockTest.php b/core/modules/forum/tests/src/Functional/ForumBlockTest.php
index 0c426027c7b..6c412b71cdc 100644
--- a/core/modules/forum/tests/src/Functional/ForumBlockTest.php
+++ b/core/modules/forum/tests/src/Functional/ForumBlockTest.php
@@ -18,7 +18,7 @@ class ForumBlockTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('forum', 'block');
+ public static $modules = ['forum', 'block'];
/**
* A user with various administrative privileges.
@@ -29,14 +29,14 @@ class ForumBlockTest extends BrowserTestBase {
parent::setUp();
// Create users.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer blocks',
'administer nodes',
'create forum content',
'post comments',
'skip comment approval',
- ));
+ ]);
}
/**
@@ -58,7 +58,7 @@ class ForumBlockTest extends BrowserTestBase {
// We expect all 5 forum topics to appear in the "New forum topics" block.
foreach ($topics as $topic) {
- $this->assertLink($topic, 0, format_string('Forum topic @topic found in the "New forum topics" block.', array('@topic' => $topic)));
+ $this->assertLink($topic, 0, format_string('Forum topic @topic found in the "New forum topics" block.', ['@topic' => $topic]));
}
// Configure the new forum topics block to only show 2 topics.
@@ -69,11 +69,11 @@ class ForumBlockTest extends BrowserTestBase {
// We expect only the 2 most recent forum topics to appear in the "New forum
// topics" block.
for ($index = 0; $index < 5; $index++) {
- if (in_array($index, array(3, 4))) {
- $this->assertLink($topics[$index], 0, format_string('Forum topic @topic found in the "New forum topics" block.', array('@topic' => $topics[$index])));
+ if (in_array($index, [3, 4])) {
+ $this->assertLink($topics[$index], 0, format_string('Forum topic @topic found in the "New forum topics" block.', ['@topic' => $topics[$index]]));
}
else {
- $this->assertNoText($topics[$index], format_string('Forum topic @topic not found in the "New forum topics" block.', array('@topic' => $topics[$index])));
+ $this->assertNoText($topics[$index], format_string('Forum topic @topic not found in the "New forum topics" block.', ['@topic' => $topics[$index]]));
}
}
}
@@ -93,7 +93,7 @@ class ForumBlockTest extends BrowserTestBase {
// Get the node from the topic title.
$node = $this->drupalGetNodeByTitle($topics[$index]);
$date->modify('+1 minute');
- $comment = Comment::create(array(
+ $comment = Comment::create([
'entity_id' => $node->id(),
'field_name' => 'comment_forum',
'entity_type' => 'node',
@@ -101,7 +101,7 @@ class ForumBlockTest extends BrowserTestBase {
'subject' => $this->randomString(20),
'comment_body' => $this->randomString(256),
'created' => $date->getTimestamp(),
- ));
+ ]);
$comment->save();
}
@@ -116,10 +116,10 @@ class ForumBlockTest extends BrowserTestBase {
$this->drupalGet('<front>');
for ($index = 0; $index < 10; $index++) {
if ($index < 5) {
- $this->assertLink($topics[$index], 0, format_string('Forum topic @topic found in the "Active forum topics" block.', array('@topic' => $topics[$index])));
+ $this->assertLink($topics[$index], 0, format_string('Forum topic @topic found in the "Active forum topics" block.', ['@topic' => $topics[$index]]));
}
else {
- $this->assertNoText($topics[$index], format_string('Forum topic @topic not found in the "Active forum topics" block.', array('@topic' => $topics[$index])));
+ $this->assertNoText($topics[$index], format_string('Forum topic @topic not found in the "Active forum topics" block.', ['@topic' => $topics[$index]]));
}
}
@@ -132,7 +132,7 @@ class ForumBlockTest extends BrowserTestBase {
// We expect only the 2 forum topics with most recent comments to appear in
// the "Active forum topics" block.
for ($index = 0; $index < 10; $index++) {
- if (in_array($index, array(3, 4))) {
+ if (in_array($index, [3, 4])) {
$this->assertLink($topics[$index], 0, 'Forum topic found in the "Active forum topics" block.');
}
else {
@@ -148,7 +148,7 @@ class ForumBlockTest extends BrowserTestBase {
* The title of the newly generated topic.
*/
protected function createForumTopics($count = 5) {
- $topics = array();
+ $topics = [];
$date = new DrupalDateTime();
$date->modify('-24 hours');
@@ -160,17 +160,17 @@ class ForumBlockTest extends BrowserTestBase {
// changing the date.
$date->modify('+1 minute');
- $edit = array(
+ $edit = [
'title[0][value]' => $title,
'body[0][value]' => $body,
// Forum posts are ordered by timestamp, so force a unique timestamp by
// adding the index.
'created[0][value][date]' => $date->format('Y-m-d'),
'created[0][value][time]' => $date->format('H:i:s'),
- );
+ ];
// Create the forum topic, preselecting the forum ID via a URL parameter.
- $this->drupalPostForm('node/add/forum', $edit, t('Save and publish'), array('query' => array('forum_id' => 1)));
+ $this->drupalPostForm('node/add/forum', $edit, t('Save and publish'), ['query' => ['forum_id' => 1]]);
$topics[] = $title;
}
diff --git a/core/modules/forum/tests/src/Functional/ForumIndexTest.php b/core/modules/forum/tests/src/Functional/ForumIndexTest.php
index 8bcb4822c90..3fd74b6fce7 100644
--- a/core/modules/forum/tests/src/Functional/ForumIndexTest.php
+++ b/core/modules/forum/tests/src/Functional/ForumIndexTest.php
@@ -16,7 +16,7 @@ class ForumIndexTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'comment', 'forum');
+ public static $modules = ['taxonomy', 'comment', 'forum'];
protected function setUp() {
parent::setUp();
@@ -35,15 +35,15 @@ class ForumIndexTest extends BrowserTestBase {
// Create a test node.
$title = $this->randomMachineName(20);
- $edit = array(
+ $edit = [
'title[0][value]' => $title,
'body[0][value]' => $this->randomMachineName(200),
- );
+ ];
// Create the forum topic, preselecting the forum ID via a URL parameter.
$this->drupalGet("forum/$tid");
- $this->clickLink(t('Add new @node_type', array('@node_type' => 'Forum topic')));
- $this->assertUrl('node/add/forum', array('query' => array('forum_id' => $tid)));
+ $this->clickLink(t('Add new @node_type', ['@node_type' => 'Forum topic']));
+ $this->assertUrl('node/add/forum', ['query' => ['forum_id' => $tid]]);
$this->drupalPostForm(NULL, $edit, t('Save and publish'));
// Check that the node exists in the database.
@@ -51,11 +51,11 @@ class ForumIndexTest extends BrowserTestBase {
$this->assertTrue(!empty($node), 'New forum node found in database.');
// Create a child forum.
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(20),
'description[0][value]' => $this->randomMachineName(200),
'parent[0]' => $tid,
- );
+ ];
$this->drupalPostForm('admin/structure/forum/add/forum', $edit, t('Save'));
$tid_child = $tid + 1;
@@ -71,7 +71,7 @@ class ForumIndexTest extends BrowserTestBase {
// Unpublish the node.
- $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save and unpublish'));
+ $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and unpublish'));
$this->drupalGet('node/' . $node->id());
$this->assertText(t('Access denied'), 'Unpublished node is no longer accessible.');
diff --git a/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php b/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php
index 59a11921d65..83523e681dc 100644
--- a/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php
+++ b/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php
@@ -17,7 +17,7 @@ class ForumNodeAccessTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment', 'forum', 'taxonomy', 'tracker', 'node_access_test', 'block');
+ public static $modules = ['node', 'comment', 'forum', 'taxonomy', 'tracker', 'node_access_test', 'block'];
protected function setUp() {
parent::setUp();
@@ -34,30 +34,30 @@ class ForumNodeAccessTest extends BrowserTestBase {
*/
function testForumNodeAccess() {
// Create some users.
- $access_user = $this->drupalCreateUser(array('node test view'));
+ $access_user = $this->drupalCreateUser(['node test view']);
$no_access_user = $this->drupalCreateUser();
- $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules', 'administer blocks', 'create forum content'));
+ $admin_user = $this->drupalCreateUser(['access administration pages', 'administer modules', 'administer blocks', 'create forum content']);
$this->drupalLogin($admin_user);
// Create a private node.
$private_node_title = $this->randomMachineName(20);
- $edit = array(
+ $edit = [
'title[0][value]' => $private_node_title,
'body[0][value]' => $this->randomMachineName(200),
'private[0][value]' => TRUE,
- );
- $this->drupalPostForm('node/add/forum', $edit, t('Save'), array('query' => array('forum_id' => 1)));
+ ];
+ $this->drupalPostForm('node/add/forum', $edit, t('Save'), ['query' => ['forum_id' => 1]]);
$private_node = $this->drupalGetNodeByTitle($private_node_title);
$this->assertTrue(!empty($private_node), 'New private forum node found in database.');
// Create a public node.
$public_node_title = $this->randomMachineName(20);
- $edit = array(
+ $edit = [
'title[0][value]' => $public_node_title,
'body[0][value]' => $this->randomMachineName(200),
- );
- $this->drupalPostForm('node/add/forum', $edit, t('Save'), array('query' => array('forum_id' => 1)));
+ ];
+ $this->drupalPostForm('node/add/forum', $edit, t('Save'), ['query' => ['forum_id' => 1]]);
$public_node = $this->drupalGetNodeByTitle($public_node_title);
$this->assertTrue(!empty($public_node), 'New public forum node found in database.');
diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php
index 067e2bc5b16..25ecc9df4c5 100644
--- a/core/modules/forum/tests/src/Functional/ForumTest.php
+++ b/core/modules/forum/tests/src/Functional/ForumTest.php
@@ -25,7 +25,7 @@ class ForumTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'comment', 'forum', 'node', 'block', 'menu_ui', 'help');
+ public static $modules = ['taxonomy', 'comment', 'forum', 'node', 'block', 'menu_ui', 'help'];
/**
* A user with various administrative privileges.
@@ -81,7 +81,7 @@ class ForumTest extends BrowserTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create users.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer modules',
'administer blocks',
@@ -90,27 +90,27 @@ class ForumTest extends BrowserTestBase {
'administer taxonomy',
'create forum content',
'access comments',
- ));
- $this->editAnyTopicsUser = $this->drupalCreateUser(array(
+ ]);
+ $this->editAnyTopicsUser = $this->drupalCreateUser([
'access administration pages',
'create forum content',
'edit any forum content',
'delete any forum content',
- ));
- $this->editOwnTopicsUser = $this->drupalCreateUser(array(
+ ]);
+ $this->editOwnTopicsUser = $this->drupalCreateUser([
'create forum content',
'edit own forum content',
'delete own forum content',
- ));
+ ]);
$this->webUser = $this->drupalCreateUser();
- $this->postCommentUser = $this->drupalCreateUser(array(
+ $this->postCommentUser = $this->drupalCreateUser([
'administer content types',
'create forum content',
'post comments',
'skip comment approval',
'access comments',
- ));
- $this->drupalPlaceBlock('help_block', array('region' => 'help'));
+ ]);
+ $this->drupalPlaceBlock('help_block', ['region' => 'help']);
$this->drupalPlaceBlock('local_actions_block');
}
@@ -188,7 +188,7 @@ class ForumTest extends BrowserTestBase {
$this->drupalGet('forum');
// Verify row for testing forum.
- $forum_arg = array(':forum' => 'forum-list-' . $this->forum['tid']);
+ $forum_arg = [':forum' => 'forum-list-' . $this->forum['tid']];
// Topics cell contains number of topics and number of unread topics.
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="forum__topics"]', $forum_arg);
@@ -210,15 +210,15 @@ class ForumTest extends BrowserTestBase {
$this->assertEquals('6', $elements[0]->getText(), 'Number of posts found.');
// Test loading multiple forum nodes on the front page.
- $this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content', 'post comments')));
- $this->drupalPostForm('admin/structure/types/manage/forum', array('options[promote]' => 'promote'), t('Save content type'));
+ $this->drupalLogin($this->drupalCreateUser(['administer content types', 'create forum content', 'post comments']));
+ $this->drupalPostForm('admin/structure/types/manage/forum', ['options[promote]' => 'promote'], t('Save content type'));
$this->createForumTopic($this->forum, FALSE);
$this->createForumTopic($this->forum, FALSE);
$this->drupalGet('node');
// Test adding a comment to a forum topic.
$node = $this->createForumTopic($this->forum, FALSE);
- $edit = array();
+ $edit = [];
$edit['comment_body[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/' . $node->id(), $edit, t('Save'));
$this->assertResponse(200);
@@ -226,7 +226,7 @@ class ForumTest extends BrowserTestBase {
// Test editing a forum topic that has a comment.
$this->drupalLogin($this->editAnyTopicsUser);
$this->drupalGet('forum/' . $this->forum['tid']);
- $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save'));
+ $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save'));
$this->assertResponse(200);
// Test the root forum page title change.
@@ -260,7 +260,7 @@ class ForumTest extends BrowserTestBase {
entity_delete_multiple('taxonomy_term', $tids);
// Create an orphan forum item.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(10);
$edit['body[0][value]'] = $this->randomMachineName(120);
$this->drupalLogin($this->adminUser);
@@ -270,7 +270,7 @@ class ForumTest extends BrowserTestBase {
$this->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.');
// Reset the defaults for future tests.
- \Drupal::service('module_installer')->install(array('forum'));
+ \Drupal::service('module_installer')->install(['forum']);
}
/**
@@ -284,7 +284,7 @@ class ForumTest extends BrowserTestBase {
$this->drupalLogin($user);
// Add forum to the Tools menu.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/structure/menu/manage/tools', $edit, t('Save'));
$this->assertResponse(200);
@@ -313,7 +313,7 @@ class ForumTest extends BrowserTestBase {
// Create second forum in container, destined to be deleted below.
$delete_forum = $this->createForum('forum', $this->forumContainer['tid']);
// Save forum overview.
- $this->drupalPostForm('admin/structure/forum/', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/forum/', [], t('Save'));
$this->assertRaw(t('The configuration options have been saved.'));
// Delete this second forum.
$this->deleteForum($delete_forum['tid']);
@@ -362,15 +362,15 @@ class ForumTest extends BrowserTestBase {
$original_vocabulary = Vocabulary::load($vid);
// Generate a random name and description.
- $edit = array(
+ $edit = [
'name' => $this->randomMachineName(10),
'description' => $this->randomMachineName(100),
- );
+ ];
// Edit the vocabulary.
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $original_vocabulary->id(), $edit, t('Save'));
$this->assertResponse(200);
- $this->assertRaw(t('Updated vocabulary %name.', array('%name' => $edit['name'])), 'Vocabulary was edited');
+ $this->assertRaw(t('Updated vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary was edited');
// Grab the newly edited vocabulary.
$current_vocabulary = Vocabulary::load($vid);
@@ -404,12 +404,12 @@ class ForumTest extends BrowserTestBase {
$name = $this->randomMachineName(10);
$description = $this->randomMachineName(100);
- $edit = array(
+ $edit = [
'name[0][value]' => $name,
'description[0][value]' => $description,
'parent[0]' => $parent,
'weight' => '0',
- );
+ ];
// Create forum.
$this->drupalPostForm('admin/structure/forum/add/' . $type, $edit, t('Save'));
@@ -418,22 +418,22 @@ class ForumTest extends BrowserTestBase {
$this->assertText(
t(
'Created new @type @term.',
- array('@term' => $name, '@type' => t($type))
+ ['@term' => $name, '@type' => t($type)]
),
- format_string('@type was created', array('@type' => ucfirst($type)))
+ format_string('@type was created', ['@type' => ucfirst($type)])
);
// Verify that the creation message contains a link to a term.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
$this->assert(isset($view_link), 'The message area contains a link to a term');
// Verify forum.
- $term = db_query("SELECT * FROM {taxonomy_term_field_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc AND t.default_langcode = 1", array(':vid' => $this->config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc();
+ $term = db_query("SELECT * FROM {taxonomy_term_field_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc AND t.default_langcode = 1", [':vid' => $this->config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description])->fetchAssoc();
$this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database');
// Verify forum hierarchy.
$tid = $term['tid'];
- $parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", array(':tid' => $tid))->fetchField();
+ $parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", [':tid' => $tid])->fetchField();
$this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container');
$forum = $this->container->get('entity.manager')->getStorage('taxonomy_term')->load($tid);
@@ -454,7 +454,7 @@ class ForumTest extends BrowserTestBase {
$this->assertText('Are you sure you want to delete the forum');
$this->assertNoText('Add forum');
$this->assertNoText('Add forum container');
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
// Assert that the forum no longer exists.
$this->drupalGet('forum/' . $tid);
@@ -496,7 +496,7 @@ class ForumTest extends BrowserTestBase {
// Log in as a second user.
$this->drupalLogin($this->postCommentUser);
// Post a reply to the topic.
- $edit = array();
+ $edit = [];
$edit['subject[0][value]'] = $this->randomMachineName();
$edit['comment_body[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/' . $node->id(), $edit, t('Save'));
@@ -533,33 +533,33 @@ class ForumTest extends BrowserTestBase {
$title = $this->randomMachineName(20);
$body = $this->randomMachineName(200);
- $edit = array(
+ $edit = [
'title[0][value]' => $title,
'body[0][value]' => $body,
- );
+ ];
$tid = $forum['tid'];
// Create the forum topic, preselecting the forum ID via a URL parameter.
- $this->drupalPostForm('node/add/forum', $edit, t('Save'), array('query' => array('forum_id' => $tid)));
+ $this->drupalPostForm('node/add/forum', $edit, t('Save'), ['query' => ['forum_id' => $tid]]);
$type = t('Forum topic');
if ($container) {
- $this->assertNoText(t('@type @title has been created.', array('@type' => $type, '@title' => $title)), 'Forum topic was not created');
- $this->assertRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'Error message was shown');
+ $this->assertNoText(t('@type @title has been created.', ['@type' => $type, '@title' => $title]), 'Forum topic was not created');
+ $this->assertRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]), 'Error message was shown');
return;
}
else {
- $this->assertText(t('@type @title has been created.', array('@type' => $type, '@title' => $title)), 'Forum topic was created');
- $this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'No error message was shown');
+ $this->assertText(t('@type @title has been created.', ['@type' => $type, '@title' => $title]), 'Forum topic was created');
+ $this->assertNoRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]), 'No error message was shown');
// Verify that the creation message contains a link to a term.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
$this->assert(isset($view_link), 'The message area contains a link to a term');
}
// Retrieve node object, ensure that the topic was created and in the proper forum.
$node = $this->drupalGetNodeByTitle($title);
- $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
+ $this->assertTrue($node != NULL, format_string('Node @title was loaded', ['@title' => $title]));
$this->assertEqual($node->taxonomy_forums->target_id, $tid, 'Saved forum topic was in the expected forum');
// View forum topic.
@@ -602,16 +602,16 @@ class ForumTest extends BrowserTestBase {
$this->drupalGet('node/' . $node->id());
$this->assertResponse(200);
$this->assertTitle($node->label() . ' | Drupal', 'Forum node was displayed');
- $breadcrumb_build = array(
+ $breadcrumb_build = [
Link::createFromRoute(t('Home'), '<front>'),
Link::createFromRoute(t('Forums'), 'forum.index'),
- Link::createFromRoute($this->forumContainer['name'], 'forum.page', array('taxonomy_term' => $this->forumContainer['tid'])),
- Link::createFromRoute($this->forum['name'], 'forum.page', array('taxonomy_term' => $this->forum['tid'])),
- );
- $breadcrumb = array(
+ Link::createFromRoute($this->forumContainer['name'], 'forum.page', ['taxonomy_term' => $this->forumContainer['tid']]),
+ Link::createFromRoute($this->forum['name'], 'forum.page', ['taxonomy_term' => $this->forum['tid']]),
+ ];
+ $breadcrumb = [
'#theme' => 'breadcrumb',
'#links' => $breadcrumb_build,
- );
+ ];
$this->assertRaw(\Drupal::service('renderer')->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
// View forum edit node.
@@ -623,26 +623,26 @@ class ForumTest extends BrowserTestBase {
if ($response == 200) {
// Edit forum node (including moving it to another forum).
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = 'node/' . $node->id();
$edit['body[0][value]'] = $this->randomMachineName(256);
// Assume the topic is initially associated with $forum.
$edit['taxonomy_forums'] = $this->rootForum['tid'];
$edit['shadow'] = TRUE;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
- $this->assertText(t('Forum topic @title has been updated.', array('@title' => $edit['title[0][value]'])), 'Forum node was edited');
+ $this->assertText(t('Forum topic @title has been updated.', ['@title' => $edit['title[0][value]']]), 'Forum node was edited');
// Verify topic was moved to a different forum.
- $forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array(
+ $forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", [
':nid' => $node->id(),
':vid' => $node->getRevisionId(),
- ))->fetchField();
+ ])->fetchField();
$this->assertTrue($forum_tid == $this->rootForum['tid'], 'The forum topic is linked to a different forum');
// Delete forum node.
- $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete'));
$this->assertResponse($response);
- $this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit['title[0][value]'])), 'Forum node was deleted');
+ $this->assertRaw(t('Forum topic %title has been deleted.', ['%title' => $edit['title[0][value]']]), 'Forum node was deleted');
}
}
@@ -660,18 +660,18 @@ class ForumTest extends BrowserTestBase {
$this->assertResponse(200);
$this->assertTitle($forum['name'] . ' | Drupal');
- $breadcrumb_build = array(
+ $breadcrumb_build = [
Link::createFromRoute(t('Home'), '<front>'),
Link::createFromRoute(t('Forums'), 'forum.index'),
- );
+ ];
if (isset($parent)) {
- $breadcrumb_build[] = Link::createFromRoute($parent['name'], 'forum.page', array('taxonomy_term' => $parent['tid']));
+ $breadcrumb_build[] = Link::createFromRoute($parent['name'], 'forum.page', ['taxonomy_term' => $parent['tid']]);
}
- $breadcrumb = array(
+ $breadcrumb = [
'#theme' => 'breadcrumb',
'#links' => $breadcrumb_build,
- );
+ ];
$this->assertRaw(\Drupal::service('renderer')->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
}
@@ -679,7 +679,7 @@ class ForumTest extends BrowserTestBase {
* Generates forum topics.
*/
private function generateForumTopics() {
- $this->nids = array();
+ $this->nids = [];
for ($i = 0; $i < 5; $i++) {
$node = $this->createForumTopic($this->forum, FALSE);
$this->nids[] = $node->id();
diff --git a/core/modules/forum/tests/src/Functional/ForumUninstallTest.php b/core/modules/forum/tests/src/Functional/ForumUninstallTest.php
index 65038e9d90a..c2d3848ffca 100644
--- a/core/modules/forum/tests/src/Functional/ForumUninstallTest.php
+++ b/core/modules/forum/tests/src/Functional/ForumUninstallTest.php
@@ -21,7 +21,7 @@ class ForumUninstallTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('forum');
+ public static $modules = ['forum'];
/**
* Tests if forum module uninstallation properly deletes the field.
@@ -37,21 +37,21 @@ class ForumUninstallTest extends BrowserTestBase {
'name' => t('A term'),
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
'description' => '',
- 'parent' => array(0),
+ 'parent' => [0],
'vid' => 'forums',
'forum_container' => 0,
]);
$term->save();
// Create a forum node.
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'title' => 'A forum post',
'type' => 'forum',
- 'taxonomy_forums' => array(array('target_id' => $term->id())),
- ));
+ 'taxonomy_forums' => [['target_id' => $term->id()]],
+ ]);
// Create at least one comment against the forum node.
- $comment = Comment::create(array(
+ $comment = Comment::create([
'entity_id' => $node->nid->value,
'entity_type' => 'node',
'field_name' => 'comment_forum',
@@ -60,7 +60,7 @@ class ForumUninstallTest extends BrowserTestBase {
'status' => CommentInterface::PUBLISHED,
'subject' => $this->randomMachineName(),
'hostname' => '127.0.0.1',
- ));
+ ]);
$comment->save();
// Attempt to uninstall forum.
@@ -70,7 +70,7 @@ class ForumUninstallTest extends BrowserTestBase {
$this->assertText('To uninstall Forum, first delete all Forum content');
// Delete the node.
- $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete'));
// Attempt to uninstall forum.
$this->drupalGet('admin/modules/uninstall');
@@ -93,9 +93,9 @@ class ForumUninstallTest extends BrowserTestBase {
$this->drupalGet('admin/modules/uninstall');
// Assert forum is no longer required.
$this->assertFieldByName('uninstall[forum]');
- $this->drupalPostForm('admin/modules/uninstall', array(
+ $this->drupalPostForm('admin/modules/uninstall', [
'uninstall[forum]' => 1,
- ), t('Uninstall'));
+ ], t('Uninstall'));
$this->drupalPostForm(NULL, [], t('Uninstall'));
// Check that the field is now deleted.
@@ -104,16 +104,16 @@ class ForumUninstallTest extends BrowserTestBase {
// Check that a node type with a machine name of forum can be created after
// uninstalling the forum module and the node type is not locked.
- $edit = array(
+ $edit = [
'name' => 'Forum',
'title_label' => 'title for forum',
'type' => 'forum',
- );
+ ];
$this->drupalPostForm('admin/structure/types/add', $edit, t('Save content type'));
$this->assertTrue((bool) NodeType::load('forum'), 'Node type with machine forum created.');
$this->drupalGet('admin/structure/types/manage/forum');
$this->clickLink(t('Delete'));
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->assertResponse(200);
$this->assertFalse((bool) NodeType::load('forum'), 'Node type with machine forum deleted.');
@@ -137,14 +137,14 @@ class ForumUninstallTest extends BrowserTestBase {
// Delete all terms in the Forums vocabulary. Uninstalling the forum module
// will fail unless this is done.
- $terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => 'forums'));
+ $terms = entity_load_multiple_by_properties('taxonomy_term', ['vid' => 'forums']);
foreach ($terms as $term) {
$term->delete();
}
// Ensure that uninstallation succeeds even if the field has already been
// deleted manually beforehand.
- $this->container->get('module_installer')->uninstall(array('forum'));
+ $this->container->get('module_installer')->uninstall(['forum']);
}
}
diff --git a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php
index b0964a78747..bc0a9ffe972 100644
--- a/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php
+++ b/core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateForumConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('comment', 'forum', 'taxonomy');
+ public static $modules = ['comment', 'forum', 'taxonomy'];
/**
* {@inheritdoc}
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php
index 8001e579461..abc11227edb 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php
@@ -37,9 +37,9 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
// Make some test doubles.
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$config_factory = $this->getConfigFactoryStub(
- array(
- 'forum.settings' => array('IAmATestKey' => 'IAmATestValue'),
- )
+ [
+ 'forum.settings' => ['IAmATestKey' => 'IAmATestValue'],
+ ]
);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
@@ -48,20 +48,20 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
$builder = $this->getMockForAbstractClass(
'Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase',
// Constructor array.
- array(
+ [
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
- )
+ ]
);
// Reflect upon our properties, except for config which is a special case.
- $property_names = array(
+ $property_names = [
'entityManager' => $entity_manager,
'forumManager' => $forum_manager,
'stringTranslation' => $translation_manager,
- );
+ ];
foreach ($property_names as $property_name => $property_value) {
$this->assertAttributeEquals(
$property_value, $property_name, $builder
@@ -103,37 +103,37 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage->expects($this->any())
->method('load')
- ->will($this->returnValueMap(array(
- array('forums', $prophecy->reveal()),
- )));
+ ->will($this->returnValueMap([
+ ['forums', $prophecy->reveal()],
+ ]));
$entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManagerInterface')
->disableOriginalConstructor()
->getMock();
$entity_manager->expects($this->any())
->method('getStorage')
- ->will($this->returnValueMap(array(
- array('taxonomy_vocabulary', $vocab_storage),
- )));
+ ->will($this->returnValueMap([
+ ['taxonomy_vocabulary', $vocab_storage],
+ ]));
$config_factory = $this->getConfigFactoryStub(
- array(
- 'forum.settings' => array(
+ [
+ 'forum.settings' => [
'vocabulary' => 'forums',
- ),
- )
+ ],
+ ]
);
// Build a breadcrumb builder to test.
$breadcrumb_builder = $this->getMockForAbstractClass(
'Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase',
// Constructor array.
- array(
+ [
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
- )
+ ]
);
// Add a translation manager for t().
@@ -144,10 +144,10 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
// Expected result set.
- $expected = array(
+ $expected = [
Link::createFromRoute('Home', '<front>'),
Link::createFromRoute('Fora_is_the_plural_of_forum', 'forum.index'),
- );
+ ];
// And finally, the test.
$breadcrumb = $breadcrumb_builder->build($route_match);
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
index 4e5a6c4579b..45566f2afe6 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
@@ -41,21 +41,21 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
* @dataProvider providerTestApplies
* @covers ::applies
*/
- public function testApplies($expected, $route_name = NULL, $parameter_map = array()) {
+ public function testApplies($expected, $route_name = NULL, $parameter_map = []) {
// Make some test doubles.
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
- $config_factory = $this->getConfigFactoryStub(array());
+ $config_factory = $this->getConfigFactoryStub([]);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
// Make an object to test.
$builder = $this->getMockBuilder('Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder')
- ->setConstructorArgs(array(
+ ->setConstructorArgs([
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
- ))
+ ])
->setMethods(NULL)
->getMock();
@@ -84,29 +84,29 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- return array(
- array(
+ return [
+ [
FALSE,
- ),
- array(
+ ],
+ [
FALSE,
'NOT.forum.page',
- ),
- array(
+ ],
+ [
FALSE,
'forum.page',
- ),
- array(
+ ],
+ [
TRUE,
'forum.page',
- array(array('taxonomy_term', 'anything')),
- ),
- array(
+ [['taxonomy_term', 'anything']],
+ ],
+ [
TRUE,
'forum.page',
- array(array('taxonomy_term', $mock_term)),
- ),
- );
+ [['taxonomy_term', $mock_term]],
+ ],
+ ];
}
/**
@@ -141,10 +141,10 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$forum_manager->expects($this->at(0))
->method('getParents')
- ->will($this->returnValue(array($term1)));
+ ->will($this->returnValue([$term1]));
$forum_manager->expects($this->at(1))
->method('getParents')
- ->will($this->returnValue(array($term1, $term2)));
+ ->will($this->returnValue([$term1, $term2]));
// The root forum.
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
@@ -156,35 +156,35 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage->expects($this->any())
->method('load')
- ->will($this->returnValueMap(array(
- array('forums', $prophecy->reveal()),
- )));
+ ->will($this->returnValueMap([
+ ['forums', $prophecy->reveal()],
+ ]));
$entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManagerInterface')
->disableOriginalConstructor()
->getMock();
$entity_manager->expects($this->any())
->method('getStorage')
- ->will($this->returnValueMap(array(
- array('taxonomy_vocabulary', $vocab_storage),
- )));
+ ->will($this->returnValueMap([
+ ['taxonomy_vocabulary', $vocab_storage],
+ ]));
$config_factory = $this->getConfigFactoryStub(
- array(
- 'forum.settings' => array(
+ [
+ 'forum.settings' => [
'vocabulary' => 'forums',
- ),
- )
+ ],
+ ]
);
// Build a breadcrumb builder to test.
$breadcrumb_builder = $this->getMock(
- 'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, array(
+ 'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
- )
+ ]
);
// Add a translation manager for t().
@@ -208,11 +208,11 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
->will($this->returnValue($forum_listing));
// First test.
- $expected1 = array(
+ $expected1 = [
Link::createFromRoute('Home', '<front>'),
Link::createFromRoute('Fora_is_the_plural_of_forum', 'forum.index'),
- Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
- );
+ Link::createFromRoute('Something', 'forum.page', ['taxonomy_term' => 1]),
+ ];
$breadcrumb = $breadcrumb_builder->build($route_match);
$this->assertEquals($expected1, $breadcrumb->getLinks());
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
@@ -220,12 +220,12 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
// Second test.
- $expected2 = array(
+ $expected2 = [
Link::createFromRoute('Home', '<front>'),
Link::createFromRoute('Fora_is_the_plural_of_forum', 'forum.index'),
- Link::createFromRoute('Something else', 'forum.page', array('taxonomy_term' => 2)),
- Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
- );
+ Link::createFromRoute('Something else', 'forum.page', ['taxonomy_term' => 2]),
+ Link::createFromRoute('Something', 'forum.page', ['taxonomy_term' => 1]),
+ ];
$breadcrumb = $breadcrumb_builder->build($route_match);
$this->assertEquals($expected2, $breadcrumb->getLinks());
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
index 1998ffa2a19..f4d3797155d 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
@@ -41,10 +41,10 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
* @dataProvider providerTestApplies
* @covers ::applies
*/
- public function testApplies($expected, $route_name = NULL, $parameter_map = array()) {
+ public function testApplies($expected, $route_name = NULL, $parameter_map = []) {
// Make some test doubles.
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
- $config_factory = $this->getConfigFactoryStub(array());
+ $config_factory = $this->getConfigFactoryStub([]);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$forum_manager->expects($this->any())
@@ -56,12 +56,12 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
// Make an object to test.
$builder = $this->getMockBuilder('Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder')
->setConstructorArgs(
- array(
+ [
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
- )
+ ]
)
->setMethods(NULL)
->getMock();
@@ -93,29 +93,29 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- return array(
- array(
+ return [
+ [
FALSE,
- ),
- array(
+ ],
+ [
FALSE,
'NOT.entity.node.canonical',
- ),
- array(
+ ],
+ [
FALSE,
'entity.node.canonical',
- ),
- array(
+ ],
+ [
FALSE,
'entity.node.canonical',
- array(array('node', NULL)),
- ),
- array(
+ [['node', NULL]],
+ ],
+ [
TRUE,
'entity.node.canonical',
- array(array('node', $mock_node)),
- ),
- );
+ [['node', $mock_node]],
+ ],
+ ];
}
/**
@@ -151,10 +151,10 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
->getMock();
$forum_manager->expects($this->at(0))
->method('getParents')
- ->will($this->returnValue(array($term1)));
+ ->will($this->returnValue([$term1]));
$forum_manager->expects($this->at(1))
->method('getParents')
- ->will($this->returnValue(array($term1, $term2)));
+ ->will($this->returnValue([$term1, $term2]));
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
$prophecy->label()->willReturn('Forums');
@@ -165,35 +165,35 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage->expects($this->any())
->method('load')
- ->will($this->returnValueMap(array(
- array('forums', $prophecy->reveal()),
- )));
+ ->will($this->returnValueMap([
+ ['forums', $prophecy->reveal()],
+ ]));
$entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManagerInterface')
->disableOriginalConstructor()
->getMock();
$entity_manager->expects($this->any())
->method('getStorage')
- ->will($this->returnValueMap(array(
- array('taxonomy_vocabulary', $vocab_storage),
- )));
+ ->will($this->returnValueMap([
+ ['taxonomy_vocabulary', $vocab_storage],
+ ]));
$config_factory = $this->getConfigFactoryStub(
- array(
- 'forum.settings' => array(
+ [
+ 'forum.settings' => [
'vocabulary' => 'forums',
- ),
- )
+ ],
+ ]
);
// Build a breadcrumb builder to test.
$breadcrumb_builder = $this->getMock(
- 'Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder', NULL, array(
+ 'Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder', NULL, [
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
- )
+ ]
);
// Add a translation manager for t().
@@ -215,11 +215,11 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
->will($this->returnValue($forum_node));
// First test.
- $expected1 = array(
+ $expected1 = [
Link::createFromRoute('Home', '<front>'),
Link::createFromRoute('Forums', 'forum.index'),
- Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
- );
+ Link::createFromRoute('Something', 'forum.page', ['taxonomy_term' => 1]),
+ ];
$breadcrumb = $breadcrumb_builder->build($route_match);
$this->assertEquals($expected1, $breadcrumb->getLinks());
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
@@ -227,12 +227,12 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
// Second test.
- $expected2 = array(
+ $expected2 = [
Link::createFromRoute('Home', '<front>'),
Link::createFromRoute('Forums', 'forum.index'),
- Link::createFromRoute('Something else', 'forum.page', array('taxonomy_term' => 2)),
- Link::createFromRoute('Something', 'forum.page', array('taxonomy_term' => 1)),
- );
+ Link::createFromRoute('Something else', 'forum.page', ['taxonomy_term' => 2]),
+ Link::createFromRoute('Something', 'forum.page', ['taxonomy_term' => 1]),
+ ];
$breadcrumb = $breadcrumb_builder->build($route_match);
$this->assertEquals($expected2, $breadcrumb->getLinks());
$this->assertEquals(['route'], $breadcrumb->getCacheContexts());
diff --git a/core/modules/forum/tests/src/Unit/ForumManagerTest.php b/core/modules/forum/tests/src/Unit/ForumManagerTest.php
index 58735569471..ad59092138e 100644
--- a/core/modules/forum/tests/src/Unit/ForumManagerTest.php
+++ b/core/modules/forum/tests/src/Unit/ForumManagerTest.php
@@ -57,17 +57,17 @@ class ForumManagerTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- $manager = $this->getMock('\Drupal\forum\ForumManager', array('getChildren'), array(
+ $manager = $this->getMock('\Drupal\forum\ForumManager', ['getChildren'], [
$config_factory,
$entity_manager,
$connection,
$translation_manager,
$comment_manager,
- ));
+ ]);
$manager->expects($this->once())
->method('getChildren')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
// Get the index once.
$index1 = $manager->getIndex();
diff --git a/core/modules/hal/hal.api.php b/core/modules/hal/hal.api.php
index c1e3480fb6a..197785cbc39 100644
--- a/core/modules/hal/hal.api.php
+++ b/core/modules/hal/hal.api.php
@@ -26,7 +26,7 @@
* @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
* @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
*/
-function hook_hal_type_uri_alter(&$uri, $context = array()) {
+function hook_hal_type_uri_alter(&$uri, $context = []) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('hal.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
@@ -50,7 +50,7 @@ function hook_hal_type_uri_alter(&$uri, $context = array()) {
* @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
* @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
*/
-function hook_hal_relation_uri_alter(&$uri, $context = array()) {
+function hook_hal_relation_uri_alter(&$uri, $context = []) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('hal.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
diff --git a/core/modules/hal/hal.module b/core/modules/hal/hal.module
index eaf06c104f6..0833e477588 100644
--- a/core/modules/hal/hal.module
+++ b/core/modules/hal/hal.module
@@ -15,9 +15,9 @@ function hal_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.hal':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('<a href=":hal_spec">Hypertext Application Language (HAL)</a> is a format that supports the linking required for hypermedia APIs.', array(':hal_spec' => 'http://stateless.co/hal_specification.html')) . '</p>';
+ $output .= '<p>' . t('<a href=":hal_spec">Hypertext Application Language (HAL)</a> is a format that supports the linking required for hypermedia APIs.', [':hal_spec' => 'http://stateless.co/hal_specification.html']) . '</p>';
$output .= '<p>' . t('Hypermedia APIs are a style of Web API that uses URIs to identify resources and the <a href="http://wikipedia.org/wiki/Link_relation">link relations</a> between them, enabling API consumers to follow links to discover API functionality.') . '</p>';
- $output .= '<p>' . t('This module adds support for serializing entities (such as content items, taxonomy terms, etc.) to the JSON version of HAL. For more information, see the <a href=":hal_do">online documentation for the HAL module</a>.', array(':hal_do' => 'https://www.drupal.org/documentation/modules/hal')) . '</p>';
+ $output .= '<p>' . t('This module adds support for serializing entities (such as content items, taxonomy terms, etc.) to the JSON version of HAL. For more information, see the <a href=":hal_do">online documentation for the HAL module</a>.', [':hal_do' => 'https://www.drupal.org/documentation/modules/hal']) . '</p>';
return $output;
}
}
diff --git a/core/modules/hal/src/LinkManager/LinkManager.php b/core/modules/hal/src/LinkManager/LinkManager.php
index b78b7cf922c..66e68d05fc2 100644
--- a/core/modules/hal/src/LinkManager/LinkManager.php
+++ b/core/modules/hal/src/LinkManager/LinkManager.php
@@ -34,21 +34,21 @@ class LinkManager implements LinkManagerInterface {
/**
* {@inheritdoc}
*/
- public function getTypeUri($entity_type, $bundle, $context = array()) {
+ public function getTypeUri($entity_type, $bundle, $context = []) {
return $this->typeLinkManager->getTypeUri($entity_type, $bundle, $context);
}
/**
* {@inheritdoc}
*/
- public function getTypeInternalIds($type_uri, $context = array()) {
+ public function getTypeInternalIds($type_uri, $context = []) {
return $this->typeLinkManager->getTypeInternalIds($type_uri, $context);
}
/**
* {@inheritdoc}
*/
- public function getRelationUri($entity_type, $bundle, $field_name, $context = array()) {
+ public function getRelationUri($entity_type, $bundle, $field_name, $context = []) {
return $this->relationLinkManager->getRelationUri($entity_type, $bundle, $field_name, $context);
}
diff --git a/core/modules/hal/src/LinkManager/RelationLinkManager.php b/core/modules/hal/src/LinkManager/RelationLinkManager.php
index 55eb743b672..dc6486f203a 100644
--- a/core/modules/hal/src/LinkManager/RelationLinkManager.php
+++ b/core/modules/hal/src/LinkManager/RelationLinkManager.php
@@ -56,7 +56,7 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
/**
* {@inheritdoc}
*/
- public function getRelationUri($entity_type, $bundle, $field_name, $context = array()) {
+ public function getRelationUri($entity_type, $bundle, $field_name, $context = []) {
// Per the interface documentation of this method, the returned URI may
// optionally also serve as the URL of a documentation page about this
// field. However, Drupal does not currently implement such a documentation
@@ -79,7 +79,7 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
/**
* {@inheritdoc}
*/
- public function getRelationInternalIds($relation_uri, $context = array()) {
+ public function getRelationInternalIds($relation_uri, $context = []) {
$relations = $this->getRelations($context);
if (isset($relations[$relation_uri])) {
return $relations[$relation_uri];
@@ -103,7 +103,7 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
* An array of typed data ids (entity_type, bundle, and field name) keyed
* by corresponding relation URI.
*/
- protected function getRelations($context = array()) {
+ protected function getRelations($context = []) {
$cid = 'hal:links:relations';
$cache = $this->cache->get($cid);
if (!$cache) {
@@ -119,26 +119,26 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
* @param array $context
* Context from the normalizer/serializer operation.
*/
- protected function writeCache($context = array()) {
- $data = array();
+ protected function writeCache($context = []) {
+ $data = [];
foreach ($this->entityManager->getDefinitions() as $entity_type) {
if ($entity_type instanceof ContentEntityTypeInterface) {
foreach ($this->entityManager->getBundleInfo($entity_type->id()) as $bundle => $bundle_info) {
foreach ($this->entityManager->getFieldDefinitions($entity_type->id(), $bundle) as $field_definition) {
$relation_uri = $this->getRelationUri($entity_type->id(), $bundle, $field_definition->getName(), $context);
- $data[$relation_uri] = array(
+ $data[$relation_uri] = [
'entity_type' => $entity_type,
'bundle' => $bundle,
'field_name' => $field_definition->getName(),
- );
+ ];
}
}
}
}
// These URIs only change when field info changes, so cache it permanently
// and only clear it when the fields cache is cleared.
- $this->cache->set('hal:links:relations', $data, Cache::PERMANENT, array('entity_field_info'));
+ $this->cache->set('hal:links:relations', $data, Cache::PERMANENT, ['entity_field_info']);
}
}
diff --git a/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php b/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php
index 73ef535dbdd..9a9c83913cc 100644
--- a/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php
+++ b/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php
@@ -23,7 +23,7 @@ interface RelationLinkManagerInterface extends ConfigurableLinkManagerInterface
* @return string
* The corresponding URI for the field.
*/
- public function getRelationUri($entity_type, $bundle, $field_name, $context = array());
+ public function getRelationUri($entity_type, $bundle, $field_name, $context = []);
/**
* Translates a REST URI into internal IDs.
diff --git a/core/modules/hal/src/LinkManager/TypeLinkManager.php b/core/modules/hal/src/LinkManager/TypeLinkManager.php
index cc56652960a..c3a948ff86e 100644
--- a/core/modules/hal/src/LinkManager/TypeLinkManager.php
+++ b/core/modules/hal/src/LinkManager/TypeLinkManager.php
@@ -57,7 +57,7 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
/**
* {@inheritdoc}
*/
- public function getTypeUri($entity_type, $bundle, $context = array()) {
+ public function getTypeUri($entity_type, $bundle, $context = []) {
// Per the interface documentation of this method, the returned URI may
// optionally also serve as the URL of a documentation page about this
// bundle. However, Drupal does not currently implement such a documentation
@@ -80,7 +80,7 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
/**
* {@inheritdoc}
*/
- public function getTypeInternalIds($type_uri, $context = array()) {
+ public function getTypeInternalIds($type_uri, $context = []) {
$types = $this->getTypes($context);
if (isset($types[$type_uri])) {
return $types[$type_uri];
@@ -98,7 +98,7 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
* An array of typed data ids (entity_type and bundle) keyed by
* corresponding type URI.
*/
- protected function getTypes($context = array()) {
+ protected function getTypes($context = []) {
$cid = 'hal:links:types';
$cache = $this->cache->get($cid);
if (!$cache) {
@@ -120,8 +120,8 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
* An array of typed data ids (entity_type and bundle) keyed by
* corresponding type URI.
*/
- protected function writeCache($context = array()) {
- $data = array();
+ protected function writeCache($context = []) {
+ $data = [];
// Type URIs correspond to bundles. Iterate through the bundles to get the
// URI and data for them.
@@ -135,15 +135,15 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
foreach ($bundles as $bundle => $bundle_info) {
// Get a type URI for the bundle.
$bundle_uri = $this->getTypeUri($entity_type_id, $bundle, $context);
- $data[$bundle_uri] = array(
+ $data[$bundle_uri] = [
'entity_type' => $entity_type_id,
'bundle' => $bundle,
- );
+ ];
}
}
// These URIs only change when entity info changes, so cache it permanently
// and only clear it when entity_info is cleared.
- $this->cache->set('hal:links:types', $data, Cache::PERMANENT, array('entity_types'));
+ $this->cache->set('hal:links:types', $data, Cache::PERMANENT, ['entity_types']);
return $data;
}
diff --git a/core/modules/hal/src/LinkManager/TypeLinkManagerInterface.php b/core/modules/hal/src/LinkManager/TypeLinkManagerInterface.php
index 9d4e654befe..c3dabe419ab 100644
--- a/core/modules/hal/src/LinkManager/TypeLinkManagerInterface.php
+++ b/core/modules/hal/src/LinkManager/TypeLinkManagerInterface.php
@@ -21,7 +21,7 @@ interface TypeLinkManagerInterface extends ConfigurableLinkManagerInterface {
* @return string
* The corresponding URI for the bundle.
*/
- public function getTypeUri($entity_type, $bundle, $context = array());
+ public function getTypeUri($entity_type, $bundle, $context = []);
/**
* Get a bundle's Typed Data IDs based on a URI.
@@ -35,6 +35,6 @@ interface TypeLinkManagerInterface extends ConfigurableLinkManagerInterface {
* If the URI matches a bundle, returns an array containing entity_type and
* bundle. Otherwise, returns false.
*/
- public function getTypeInternalIds($type_uri, $context = array());
+ public function getTypeInternalIds($type_uri, $context = []);
}
diff --git a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php
index ff9d5e66155..1fc118dc5b5 100644
--- a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php
+++ b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php
@@ -53,28 +53,28 @@ class ContentEntityNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
- public function normalize($entity, $format = NULL, array $context = array()) {
- $context += array(
+ public function normalize($entity, $format = NULL, array $context = []) {
+ $context += [
'account' => NULL,
'included_fields' => NULL,
- );
+ ];
// Create the array of normalized fields, starting with the URI.
/** @var $entity \Drupal\Core\Entity\ContentEntityInterface */
- $normalized = array(
- '_links' => array(
- 'self' => array(
+ $normalized = [
+ '_links' => [
+ 'self' => [
'href' => $this->getEntityUri($entity),
- ),
- 'type' => array(
+ ],
+ 'type' => [
'href' => $this->linkManager->getTypeUri($entity->getEntityTypeId(), $entity->bundle(), $context),
- ),
- ),
- );
+ ],
+ ],
+ ];
// If the fields to use were specified, only output those field values.
if (isset($context['included_fields'])) {
- $fields = array();
+ $fields = [];
foreach ($context['included_fields'] as $field_name) {
$fields[] = $entity->get($field_name);
}
@@ -115,7 +115,7 @@ class ContentEntityNormalizer extends NormalizerBase {
*
* @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException
*/
- public function denormalize($data, $class, $format = NULL, array $context = array()) {
+ public function denormalize($data, $class, $format = NULL, array $context = []) {
// Get type, necessary for determining which bundle to create.
if (!isset($data['_links']['type'])) {
throw new UnexpectedValueException('The type link relation must be specified.');
@@ -126,7 +126,7 @@ class ContentEntityNormalizer extends NormalizerBase {
$entity_type = $this->getEntityTypeDefinition($typed_data_ids['entity_type']);
$default_langcode_key = $entity_type->getKey('default_langcode');
$langcode_key = $entity_type->getKey('langcode');
- $values = array();
+ $values = [];
// Figure out the language to use.
if (isset($data[$default_langcode_key])) {
@@ -154,7 +154,7 @@ class ContentEntityNormalizer extends NormalizerBase {
// Remove links from data array.
unset($data['_links']);
// Get embedded resources and remove from data array.
- $embedded = array();
+ $embedded = [];
if (isset($data['_embedded'])) {
$embedded = $data['_embedded'];
unset($data['_embedded']);
@@ -207,12 +207,12 @@ class ContentEntityNormalizer extends NormalizerBase {
* @return array
* The typed data IDs.
*/
- protected function getTypedDataIds($types, $context = array()) {
+ protected function getTypedDataIds($types, $context = []) {
// The 'type' can potentially contain an array of type objects. By default,
// Drupal only uses a single type in serializing, but allows for multiple
// types when deserializing.
if (isset($types['href'])) {
- $types = array($types);
+ $types = [$types];
}
if (empty($types)) {
diff --git a/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php b/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php
index 224915b8464..fbcae8c7583 100644
--- a/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php
+++ b/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php
@@ -49,7 +49,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
/**
* {@inheritdoc}
*/
- public function normalize($field_item, $format = NULL, array $context = array()) {
+ public function normalize($field_item, $format = NULL, array $context = []) {
/** @var $field_item \Drupal\Core\Field\FieldItemInterface */
$target_entity = $field_item->get('entity')->getValue();
@@ -64,7 +64,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
// will include the langcode.
$langcode = isset($context['langcode']) ? $context['langcode'] : NULL;
unset($context['langcode']);
- $context['included_fields'] = array('uuid');
+ $context['included_fields'] = ['uuid'];
// Normalize the target entity.
$embedded = $this->serializer->normalize($target_entity, $format, $context);
@@ -81,14 +81,14 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
$field_name = $field_item->getParent()->getName();
$entity = $field_item->getEntity();
$field_uri = $this->linkManager->getRelationUri($entity->getEntityTypeId(), $entity->bundle(), $field_name, $context);
- return array(
- '_links' => array(
- $field_uri => array($link),
- ),
- '_embedded' => array(
- $field_uri => array($embedded),
- ),
- );
+ return [
+ '_links' => [
+ $field_uri => [$link],
+ ],
+ '_embedded' => [
+ $field_uri => [$embedded],
+ ],
+ ];
}
/**
@@ -100,7 +100,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
$target_type = $field_definition->getSetting('target_type');
$id = $this->entityResolver->resolve($this, $data, $target_type);
if (isset($id)) {
- return array('target_id' => $id);
+ return ['target_id' => $id];
}
return NULL;
}
diff --git a/core/modules/hal/src/Normalizer/FieldItemNormalizer.php b/core/modules/hal/src/Normalizer/FieldItemNormalizer.php
index 238557af2dc..dc5aec98994 100644
--- a/core/modules/hal/src/Normalizer/FieldItemNormalizer.php
+++ b/core/modules/hal/src/Normalizer/FieldItemNormalizer.php
@@ -20,7 +20,7 @@ class FieldItemNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
- public function normalize($field_item, $format = NULL, array $context = array()) {
+ public function normalize($field_item, $format = NULL, array $context = []) {
$values = [];
// We normalize each individual property, so each can do their own casting,
// if needed.
@@ -38,15 +38,15 @@ class FieldItemNormalizer extends NormalizerBase {
// FieldNormalizer. This is necessary for the EntityReferenceItemNormalizer
// to be able to place values in the '_links' array.
$field = $field_item->getParent();
- return array(
- $field->getName() => array($values),
- );
+ return [
+ $field->getName() => [$values],
+ ];
}
/**
* {@inheritdoc}
*/
- public function denormalize($data, $class, $format = NULL, array $context = array()) {
+ public function denormalize($data, $class, $format = NULL, array $context = []) {
if (!isset($context['target_instance'])) {
throw new InvalidArgumentException('$context[\'target_instance\'] must be set to denormalize with the FieldItemNormalizer');
}
diff --git a/core/modules/hal/src/Normalizer/FieldNormalizer.php b/core/modules/hal/src/Normalizer/FieldNormalizer.php
index 0313221b403..a4e175323ac 100644
--- a/core/modules/hal/src/Normalizer/FieldNormalizer.php
+++ b/core/modules/hal/src/Normalizer/FieldNormalizer.php
@@ -20,8 +20,8 @@ class FieldNormalizer extends SerializationFieldNormalizer {
/**
* {@inheritdoc}
*/
- public function normalize($field, $format = NULL, array $context = array()) {
- $normalized_field_items = array();
+ public function normalize($field, $format = NULL, array $context = []) {
+ $normalized_field_items = [];
// Get the field definition.
$entity = $field->getEntity();
@@ -65,7 +65,7 @@ class FieldNormalizer extends SerializationFieldNormalizer {
* The array of normalized field items.
*/
protected function normalizeFieldItems($field, $format, $context) {
- $normalized_field_items = array();
+ $normalized_field_items = [];
if (!$field->isEmpty()) {
foreach ($field as $field_item) {
$normalized_field_items[] = $this->serializer->normalize($field_item, $format, $context);
diff --git a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php
index 2c94eb90742..ec870e9e14c 100644
--- a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php
+++ b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php
@@ -47,7 +47,7 @@ class FileEntityNormalizer extends ContentEntityNormalizer {
/**
* {@inheritdoc}
*/
- public function normalize($entity, $format = NULL, array $context = array()) {
+ public function normalize($entity, $format = NULL, array $context = []) {
$data = parent::normalize($entity, $format, $context);
// Replace the file url with a full url for the file.
$data['uri'][0]['value'] = $this->getEntityUri($entity);
@@ -58,7 +58,7 @@ class FileEntityNormalizer extends ContentEntityNormalizer {
/**
* {@inheritdoc}
*/
- public function denormalize($data, $class, $format = NULL, array $context = array()) {
+ public function denormalize($data, $class, $format = NULL, array $context = []) {
$file_data = (string) $this->httpClient->get($data['uri'][0]['value'])->getBody();
$path = 'temporary://' . drupal_basename($data['uri'][0]['value']);
diff --git a/core/modules/hal/src/Normalizer/NormalizerBase.php b/core/modules/hal/src/Normalizer/NormalizerBase.php
index a4b9af23fa2..43a5a07161f 100644
--- a/core/modules/hal/src/Normalizer/NormalizerBase.php
+++ b/core/modules/hal/src/Normalizer/NormalizerBase.php
@@ -15,7 +15,7 @@ abstract class NormalizerBase extends SerializationNormalizerBase implements Den
*
* @var array
*/
- protected $formats = array('hal_json');
+ protected $formats = ['hal_json'];
/**
* {@inheritdoc}
diff --git a/core/modules/hal/tests/modules/hal_test/hal_test.module b/core/modules/hal/tests/modules/hal_test/hal_test.module
index 5937984fce9..8788eaf41ea 100644
--- a/core/modules/hal/tests/modules/hal_test/hal_test.module
+++ b/core/modules/hal/tests/modules/hal_test/hal_test.module
@@ -8,7 +8,7 @@
/**
* Implements hook_hal_type_uri_alter().
*/
-function hal_test_hal_type_uri_alter(&$uri, $context = array()) {
+function hal_test_hal_type_uri_alter(&$uri, $context = []) {
if (!empty($context['hal_test'])) {
$uri = 'hal_test_type';
}
@@ -17,7 +17,7 @@ function hal_test_hal_type_uri_alter(&$uri, $context = array()) {
/**
* Implements hook_hal_relation_uri_alter().
*/
-function hal_test_hal_relation_uri_alter(&$uri, $context = array()) {
+function hal_test_hal_relation_uri_alter(&$uri, $context = []) {
if (!empty($context['hal_test'])) {
$uri = 'hal_test_relation';
}
@@ -28,7 +28,7 @@ function hal_test_hal_relation_uri_alter(&$uri, $context = array()) {
*
* @deprecated Kept only for BC test coverage, see \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testGetTypeUri().
*/
-function hal_test_rest_type_uri_alter(&$uri, $context = array()) {
+function hal_test_rest_type_uri_alter(&$uri, $context = []) {
if (!empty($context['rest_test'])) {
$uri = 'rest_test_type';
}
@@ -39,7 +39,7 @@ function hal_test_rest_type_uri_alter(&$uri, $context = array()) {
*
* @deprecated Kept only for BC test coverage, see \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testGetRelationUri().
*/
-function hal_test_rest_relation_uri_alter(&$uri, $context = array()) {
+function hal_test_rest_relation_uri_alter(&$uri, $context = []) {
if (!empty($context['rest_test'])) {
$uri = 'rest_test_relation';
}
diff --git a/core/modules/hal/tests/src/Functional/FileDenormalizeTest.php b/core/modules/hal/tests/src/Functional/FileDenormalizeTest.php
index 36f87627bc4..05ee2348939 100644
--- a/core/modules/hal/tests/src/Functional/FileDenormalizeTest.php
+++ b/core/modules/hal/tests/src/Functional/FileDenormalizeTest.php
@@ -18,18 +18,18 @@ class FileDenormalizeTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('hal', 'file', 'node');
+ public static $modules = ['hal', 'file', 'node'];
/**
* Tests file entity denormalization.
*/
public function testFileDenormalize() {
- $file_params = array(
+ $file_params = [
'filename' => 'test_1.txt',
'uri' => 'public://test_1.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
- );
+ ];
// Create a new file entity.
$file = File::create($file_params);
file_put_contents($file->getFileUri(), 'hello world');
@@ -56,11 +56,11 @@ class FileDenormalizeTest extends BrowserTestBase {
file_put_contents($file_path, 'hello world');
$file_uri = file_create_url($file_path);
- $data = array(
- 'uri' => array(
- array('value' => $file_uri),
- ),
- );
+ $data = [
+ 'uri' => [
+ ['value' => $file_uri],
+ ],
+ ];
$denormalized = $serializer->denormalize($data, 'Drupal\file\Entity\File', 'hal_json');
diff --git a/core/modules/hal/tests/src/Kernel/DenormalizeTest.php b/core/modules/hal/tests/src/Kernel/DenormalizeTest.php
index 3f9388bce4a..d3662cb597a 100644
--- a/core/modules/hal/tests/src/Kernel/DenormalizeTest.php
+++ b/core/modules/hal/tests/src/Kernel/DenormalizeTest.php
@@ -18,40 +18,40 @@ class DenormalizeTest extends NormalizerTestBase {
*/
public function testTypeHandling() {
// Valid type.
- $data_with_valid_type = array(
- '_links' => array(
- 'type' => array(
- 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', array('absolute' => TRUE))->toString(),
- ),
- ),
- );
+ $data_with_valid_type = [
+ '_links' => [
+ 'type' => [
+ 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', ['absolute' => TRUE])->toString(),
+ ],
+ ],
+ ];
$denormalized = $this->serializer->denormalize($data_with_valid_type, $this->entityClass, $this->format);
$this->assertEqual(get_class($denormalized), $this->entityClass, 'Request with valid type results in creation of correct bundle.');
// Multiple types.
- $data_with_multiple_types = array(
- '_links' => array(
- 'type' => array(
- array(
- 'href' => Url::fromUri('base:rest/types/foo', array('absolute' => TRUE))->toString(),
- ),
- array(
- 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', array('absolute' => TRUE))->toString(),
- ),
- ),
- ),
- );
+ $data_with_multiple_types = [
+ '_links' => [
+ 'type' => [
+ [
+ 'href' => Url::fromUri('base:rest/types/foo', ['absolute' => TRUE])->toString(),
+ ],
+ [
+ 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', ['absolute' => TRUE])->toString(),
+ ],
+ ],
+ ],
+ ];
$denormalized = $this->serializer->denormalize($data_with_multiple_types, $this->entityClass, $this->format);
$this->assertEqual(get_class($denormalized), $this->entityClass, 'Request with multiple types results in creation of correct bundle.');
// Invalid type.
- $data_with_invalid_type = array(
- '_links' => array(
- 'type' => array(
- 'href' => Url::fromUri('base:rest/types/foo', array('absolute' => TRUE))->toString(),
- ),
- ),
- );
+ $data_with_invalid_type = [
+ '_links' => [
+ 'type' => [
+ 'href' => Url::fromUri('base:rest/types/foo', ['absolute' => TRUE])->toString(),
+ ],
+ ],
+ ];
try {
$this->serializer->denormalize($data_with_invalid_type, $this->entityClass, $this->format);
$this->fail('Exception should be thrown when type is invalid.');
@@ -61,10 +61,10 @@ class DenormalizeTest extends NormalizerTestBase {
}
// No type.
- $data_with_no_type = array(
- '_links' => array(
- ),
- );
+ $data_with_no_type = [
+ '_links' => [
+ ],
+ ];
try {
$this->serializer->denormalize($data_with_no_type, $this->entityClass, $this->format);
$this->fail('Exception should be thrown when no type is provided.');
@@ -78,13 +78,13 @@ class DenormalizeTest extends NormalizerTestBase {
* Tests link relation handling with an invalid type.
*/
public function testTypeHandlingWithInvalidType() {
- $data_with_invalid_type = array(
- '_links' => array(
- 'type' => array(
- 'href' => Url::fromUri('base:rest/type/entity_test/entity_test_invalid', array('absolute' => TRUE))->toString(),
- ),
- ),
- );
+ $data_with_invalid_type = [
+ '_links' => [
+ 'type' => [
+ 'href' => Url::fromUri('base:rest/type/entity_test/entity_test_invalid', ['absolute' => TRUE])->toString(),
+ ],
+ ],
+ ];
$this->setExpectedException(UnexpectedValueException::class);
$this->serializer->denormalize($data_with_invalid_type, $this->entityClass, $this->format);
@@ -94,11 +94,11 @@ class DenormalizeTest extends NormalizerTestBase {
* Tests link relation handling with no types.
*/
public function testTypeHandlingWithNoTypes() {
- $data_with_no_types = array(
- '_links' => array(
- 'type' => array(),
- ),
- );
+ $data_with_no_types = [
+ '_links' => [
+ 'type' => [],
+ ],
+ ];
$this->setExpectedException(UnexpectedValueException::class);
$this->serializer->denormalize($data_with_no_types, $this->entityClass, $this->format);
@@ -110,32 +110,32 @@ class DenormalizeTest extends NormalizerTestBase {
public function testMarkFieldForDeletion() {
// Add a default value for a field.
$field = FieldConfig::loadByName('entity_test', 'entity_test', 'field_test_text');
- $field->setDefaultValue(array(array('value' => 'Llama')));
+ $field->setDefaultValue([['value' => 'Llama']]);
$field->save();
// Denormalize data that contains no entry for the field, and check that
// the default value is present in the resulting entity.
- $data = array(
- '_links' => array(
- 'type' => array(
- 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', array('absolute' => TRUE))->toString(),
- ),
- ),
- );
+ $data = [
+ '_links' => [
+ 'type' => [
+ 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', ['absolute' => TRUE])->toString(),
+ ],
+ ],
+ ];
$entity = $this->serializer->denormalize($data, $this->entityClass, $this->format);
$this->assertEqual($entity->field_test_text->count(), 1);
$this->assertEqual($entity->field_test_text->value, 'Llama');
// Denormalize data that contains an empty entry for the field, and check
// that the field is empty in the resulting entity.
- $data = array(
- '_links' => array(
- 'type' => array(
- 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', array('absolute' => TRUE))->toString(),
- ),
- ),
- 'field_test_text' => array(),
- );
+ $data = [
+ '_links' => [
+ 'type' => [
+ 'href' => Url::fromUri('base:rest/type/entity_test/entity_test', ['absolute' => TRUE])->toString(),
+ ],
+ ],
+ 'field_test_text' => [],
+ ];
$entity = $this->serializer->denormalize($data, get_class($entity), $this->format, [ 'target_instance' => $entity ]);
$this->assertEqual($entity->field_test_text->count(), 0);
}
diff --git a/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php b/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php
index 74f5104c2fd..5b752f7bb6a 100644
--- a/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php
+++ b/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php
@@ -19,14 +19,14 @@ class EntityTranslationNormalizeTest extends NormalizerTestBase {
*
* @var array
*/
- public static $modules = array('node', 'content_translation');
+ public static $modules = ['node', 'content_translation'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
$this->installConfig(['node', 'content_translation']);
}
diff --git a/core/modules/hal/tests/src/Kernel/FileNormalizeTest.php b/core/modules/hal/tests/src/Kernel/FileNormalizeTest.php
index d6978e656f4..8f535c52c90 100644
--- a/core/modules/hal/tests/src/Kernel/FileNormalizeTest.php
+++ b/core/modules/hal/tests/src/Kernel/FileNormalizeTest.php
@@ -16,7 +16,7 @@ class FileNormalizeTest extends NormalizerTestBase {
*
* @var array
*/
- public static $modules = array('file');
+ public static $modules = ['file'];
/**
* {@inheritdoc}
@@ -31,23 +31,23 @@ class FileNormalizeTest extends NormalizerTestBase {
* Tests the normalize function.
*/
public function testNormalize() {
- $file_params = array(
+ $file_params = [
'filename' => 'test_1.txt',
'uri' => 'public://test_1.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
- );
+ ];
// Create a new file entity.
$file = File::create($file_params);
file_put_contents($file->getFileUri(), 'hello world');
$file->save();
- $expected_array = array(
- 'uri' => array(
- array(
- 'value' => file_create_url($file->getFileUri())),
- ),
- );
+ $expected_array = [
+ 'uri' => [
+ [
+ 'value' => file_create_url($file->getFileUri())],
+ ],
+ ];
$normalized = $this->serializer->normalize($file, $this->format);
$this->assertEqual($normalized['uri'], $expected_array['uri'], 'URI is normalized.');
diff --git a/core/modules/hal/tests/src/Kernel/NormalizeTest.php b/core/modules/hal/tests/src/Kernel/NormalizeTest.php
index cfffb4a8652..d837b79a02e 100644
--- a/core/modules/hal/tests/src/Kernel/NormalizeTest.php
+++ b/core/modules/hal/tests/src/Kernel/NormalizeTest.php
@@ -26,135 +26,135 @@ class NormalizeTest extends NormalizerTestBase {
* Tests the normalize function.
*/
public function testNormalize() {
- $target_entity_de = EntityTest::create((array('langcode' => 'de', 'field_test_entity_reference' => NULL)));
+ $target_entity_de = EntityTest::create((['langcode' => 'de', 'field_test_entity_reference' => NULL]));
$target_entity_de->save();
- $target_entity_en = EntityTest::create((array('langcode' => 'en', 'field_test_entity_reference' => NULL)));
+ $target_entity_en = EntityTest::create((['langcode' => 'en', 'field_test_entity_reference' => NULL]));
$target_entity_en->save();
// Create a German entity.
- $values = array(
+ $values = [
'langcode' => 'de',
'name' => $this->randomMachineName(),
- 'field_test_text' => array(
+ 'field_test_text' => [
'value' => $this->randomMachineName(),
'format' => 'full_html',
- ),
- 'field_test_entity_reference' => array(
+ ],
+ 'field_test_entity_reference' => [
'target_id' => $target_entity_de->id(),
- ),
- );
+ ],
+ ];
// Array of translated values.
- $translation_values = array(
+ $translation_values = [
'name' => $this->randomMachineName(),
- 'field_test_entity_reference' => array(
+ 'field_test_entity_reference' => [
'target_id' => $target_entity_en->id(),
- )
- );
+ ]
+ ];
$entity = EntityTest::create($values);
$entity->save();
// Add an English value for name and entity reference properties.
- $entity->addTranslation('en')->set('name', array(0 => array('value' => $translation_values['name'])));
- $entity->getTranslation('en')->set('field_test_entity_reference', array(0 => $translation_values['field_test_entity_reference']));
+ $entity->addTranslation('en')->set('name', [0 => ['value' => $translation_values['name']]]);
+ $entity->getTranslation('en')->set('field_test_entity_reference', [0 => $translation_values['field_test_entity_reference']]);
$entity->save();
- $type_uri = Url::fromUri('base:rest/type/entity_test/entity_test', array('absolute' => TRUE))->toString();
- $relation_uri = Url::fromUri('base:rest/relation/entity_test/entity_test/field_test_entity_reference', array('absolute' => TRUE))->toString();
+ $type_uri = Url::fromUri('base:rest/type/entity_test/entity_test', ['absolute' => TRUE])->toString();
+ $relation_uri = Url::fromUri('base:rest/relation/entity_test/entity_test/field_test_entity_reference', ['absolute' => TRUE])->toString();
- $expected_array = array(
- '_links' => array(
- 'curies' => array(
- array(
+ $expected_array = [
+ '_links' => [
+ 'curies' => [
+ [
'href' => '/relations',
'name' => 'site',
'templated' => TRUE,
- ),
- ),
- 'self' => array(
+ ],
+ ],
+ 'self' => [
'href' => $this->getEntityUri($entity),
- ),
- 'type' => array(
+ ],
+ 'type' => [
'href' => $type_uri,
- ),
- $relation_uri => array(
- array(
+ ],
+ $relation_uri => [
+ [
'href' => $this->getEntityUri($target_entity_de),
'lang' => 'de',
- ),
- array(
+ ],
+ [
'href' => $this->getEntityUri($target_entity_en),
'lang' => 'en',
- ),
- ),
- ),
- '_embedded' => array(
- $relation_uri => array(
- array(
- '_links' => array(
- 'self' => array(
+ ],
+ ],
+ ],
+ '_embedded' => [
+ $relation_uri => [
+ [
+ '_links' => [
+ 'self' => [
'href' => $this->getEntityUri($target_entity_de),
- ),
- 'type' => array(
+ ],
+ 'type' => [
'href' => $type_uri,
- ),
- ),
- 'uuid' => array(
- array(
+ ],
+ ],
+ 'uuid' => [
+ [
'value' => $target_entity_de->uuid(),
- ),
- ),
+ ],
+ ],
'lang' => 'de',
- ),
- array(
- '_links' => array(
- 'self' => array(
+ ],
+ [
+ '_links' => [
+ 'self' => [
'href' => $this->getEntityUri($target_entity_en),
- ),
- 'type' => array(
+ ],
+ 'type' => [
'href' => $type_uri,
- ),
- ),
- 'uuid' => array(
- array(
+ ],
+ ],
+ 'uuid' => [
+ [
'value' => $target_entity_en->uuid(),
- ),
- ),
+ ],
+ ],
'lang' => 'en',
- ),
- ),
- ),
- 'id' => array(
- array(
+ ],
+ ],
+ ],
+ 'id' => [
+ [
'value' => $entity->id(),
- ),
- ),
- 'uuid' => array(
- array(
+ ],
+ ],
+ 'uuid' => [
+ [
'value' => $entity->uuid(),
- ),
- ),
- 'langcode' => array(
- array(
+ ],
+ ],
+ 'langcode' => [
+ [
'value' => 'de',
- ),
- ),
- 'name' => array(
- array(
+ ],
+ ],
+ 'name' => [
+ [
'value' => $values['name'],
'lang' => 'de',
- ),
- array(
+ ],
+ [
'value' => $translation_values['name'],
'lang' => 'en',
- ),
- ),
- 'field_test_text' => array(
- array(
+ ],
+ ],
+ 'field_test_text' => [
+ [
'value' => $values['field_test_text']['value'],
'format' => $values['field_test_text']['format'],
- ),
- ),
- );
+ ],
+ ],
+ ];
$normalized = $this->serializer->normalize($entity, $this->format);
$this->assertEqual($normalized['_links']['self'], $expected_array['_links']['self'], 'self link placed correctly.');
diff --git a/core/modules/hal/tests/src/Kernel/NormalizerTestBase.php b/core/modules/hal/tests/src/Kernel/NormalizerTestBase.php
index 9dac94c81f3..ef51a077c94 100644
--- a/core/modules/hal/tests/src/Kernel/NormalizerTestBase.php
+++ b/core/modules/hal/tests/src/Kernel/NormalizerTestBase.php
@@ -58,29 +58,29 @@ abstract class NormalizerTestBase extends KernelTestBase {
// Only check the modules, if the $modules property was not inherited.
$rp = new \ReflectionProperty($class, 'modules');
if ($rp->class == $class) {
- foreach (array_intersect(array('node', 'comment'), $class::$modules) as $module) {
+ foreach (array_intersect(['node', 'comment'], $class::$modules) as $module) {
$this->installEntitySchema($module);
}
}
}
$class = get_parent_class($class);
}
- $this->installConfig(array('field', 'language'));
+ $this->installConfig(['field', 'language']);
\Drupal::service('router.builder')->rebuild();
// Add German as a language.
- ConfigurableLanguage::create(array(
+ ConfigurableLanguage::create([
'id' => 'de',
'label' => 'Deutsch',
'weight' => -1,
- ))->save();
+ ])->save();
// Create the test text field.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_test_text',
'entity_type' => 'entity_test',
'type' => 'text',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test_text',
@@ -89,11 +89,11 @@ abstract class NormalizerTestBase extends KernelTestBase {
])->save();
// Create the test translatable field.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_test_translatable_text',
'entity_type' => 'entity_test',
'type' => 'text',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test_translatable_text',
@@ -102,14 +102,14 @@ abstract class NormalizerTestBase extends KernelTestBase {
])->save();
// Create the test entity reference field.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_test_entity_reference',
'entity_type' => 'entity_test',
'type' => 'entity_reference',
- 'settings' => array(
+ 'settings' => [
'target_type' => 'entity_test',
- ),
- ))->save();
+ ],
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test_entity_reference',
diff --git a/core/modules/hal/tests/src/Unit/FieldItemNormalizerDenormalizeExceptionsUnitTest.php b/core/modules/hal/tests/src/Unit/FieldItemNormalizerDenormalizeExceptionsUnitTest.php
index 550c185b401..6d876e61cae 100644
--- a/core/modules/hal/tests/src/Unit/FieldItemNormalizerDenormalizeExceptionsUnitTest.php
+++ b/core/modules/hal/tests/src/Unit/FieldItemNormalizerDenormalizeExceptionsUnitTest.php
@@ -21,8 +21,8 @@ class FieldItemNormalizerDenormalizeExceptionsUnitTest extends NormalizerDenorma
*/
public function testFieldItemNormalizerDenormalizeExceptions($context) {
$field_item_normalizer = new FieldItemNormalizer();
- $data = array();
- $class = array();
+ $data = [];
+ $class = [];
$field_item_normalizer->denormalize($data, $class, NULL, $context);
}
diff --git a/core/modules/hal/tests/src/Unit/FieldNormalizerDenormalizeExceptionsUnitTest.php b/core/modules/hal/tests/src/Unit/FieldNormalizerDenormalizeExceptionsUnitTest.php
index a257209e69d..7cc55bb4831 100644
--- a/core/modules/hal/tests/src/Unit/FieldNormalizerDenormalizeExceptionsUnitTest.php
+++ b/core/modules/hal/tests/src/Unit/FieldNormalizerDenormalizeExceptionsUnitTest.php
@@ -21,8 +21,8 @@ class FieldNormalizerDenormalizeExceptionsUnitTest extends NormalizerDenormalize
*/
public function testFieldNormalizerDenormalizeExceptions($context) {
$field_item_normalizer = new FieldNormalizer();
- $data = array();
- $class = array();
+ $data = [];
+ $class = [];
$field_item_normalizer->denormalize($data, $class, NULL, $context);
}
diff --git a/core/modules/hal/tests/src/Unit/NormalizerDenormalizeExceptionsUnitTestBase.php b/core/modules/hal/tests/src/Unit/NormalizerDenormalizeExceptionsUnitTestBase.php
index 52ba805b23d..d1a3b9b1d73 100644
--- a/core/modules/hal/tests/src/Unit/NormalizerDenormalizeExceptionsUnitTestBase.php
+++ b/core/modules/hal/tests/src/Unit/NormalizerDenormalizeExceptionsUnitTestBase.php
@@ -18,14 +18,14 @@ abstract class NormalizerDenormalizeExceptionsUnitTestBase extends UnitTestCase
* @return array Test data.
*/
public function providerNormalizerDenormalizeExceptions() {
- $mock = $this->getMock('\Drupal\Core\Field\Plugin\DataType\FieldItem', array('getParent'));
+ $mock = $this->getMock('\Drupal\Core\Field\Plugin\DataType\FieldItem', ['getParent']);
$mock->expects($this->any())
->method('getParent')
->will($this->returnValue(NULL));
- return array(
- array(array()),
- array(array('target_instance' => $mock)),
- );
+ return [
+ [[]],
+ [['target_instance' => $mock]],
+ ];
}
}
diff --git a/core/modules/help/help.api.php b/core/modules/help/help.api.php
index aff491c7ea1..8b4b1cca263 100644
--- a/core/modules/help/help.api.php
+++ b/core/modules/help/help.api.php
@@ -48,7 +48,7 @@ function hook_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_
switch ($route_name) {
// Main module help for the block module.
case 'help.page.block':
- return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Bartik, for example, implements the regions "Sidebar first", "Sidebar second", "Featured", "Content", "Header", "Footer", etc., and a block may appear in any one of these areas. The <a href=":blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', array(':blocks' => \Drupal::url('block.admin_display'))) . '</p>';
+ return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Bartik, for example, implements the regions "Sidebar first", "Sidebar second", "Featured", "Content", "Header", "Footer", etc., and a block may appear in any one of these areas. The <a href=":blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', [':blocks' => \Drupal::url('block.admin_display')]) . '</p>';
// Help for another path in the block module.
case 'block.admin_display':
diff --git a/core/modules/help/help.module b/core/modules/help/help.module
index c41cd98414a..ca49bee8d43 100644
--- a/core/modules/help/help.module
+++ b/core/modules/help/help.module
@@ -17,27 +17,27 @@ function help_help($route_name, RouteMatchInterface $route_match) {
$output = '<h2>' . t('Getting Started') . '</h2>';
$output .= '<p>' . t('Follow these steps to set up and start using your website:') . '</p>';
$output .= '<ol>';
- $output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href=":admin">Administration page</a>, where you may <a href=":config">customize and configure</a> all aspects of your website.', array(':admin' => \Drupal::url('system.admin'), ':config' => \Drupal::url('system.admin_config'))) . '</li>';
- $output .= '<li>' . t('<strong>Enable additional functionality</strong> Next, visit the <a href=":modules">Extend page</a> and enable modules that suit your specific needs. You can find additional modules at the <a href=":download_modules">Drupal.org modules page</a>.', array(':modules' => \Drupal::url('system.modules_list'), ':download_modules' => 'https://www.drupal.org/project/modules')) . '</li>';
- $output .= '<li>' . t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href=":themes">Appearance page</a>. You may choose from one of the included themes or download additional themes from the <a href=":download_themes">Drupal.org themes page</a>.', array(':themes' => \Drupal::url('system.themes_page'), ':download_themes' => 'https://www.drupal.org/project/themes')) . '</li>';
+ $output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href=":admin">Administration page</a>, where you may <a href=":config">customize and configure</a> all aspects of your website.', [':admin' => \Drupal::url('system.admin'), ':config' => \Drupal::url('system.admin_config')]) . '</li>';
+ $output .= '<li>' . t('<strong>Enable additional functionality</strong> Next, visit the <a href=":modules">Extend page</a> and enable modules that suit your specific needs. You can find additional modules at the <a href=":download_modules">Drupal.org modules page</a>.', [':modules' => \Drupal::url('system.modules_list'), ':download_modules' => 'https://www.drupal.org/project/modules']) . '</li>';
+ $output .= '<li>' . t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href=":themes">Appearance page</a>. You may choose from one of the included themes or download additional themes from the <a href=":download_themes">Drupal.org themes page</a>.', [':themes' => \Drupal::url('system.themes_page'), ':download_themes' => 'https://www.drupal.org/project/themes']) . '</li>';
// Display a link to the create content page if Node module is enabled.
if (\Drupal::moduleHandler()->moduleExists('node')) {
- $output .= '<li>' . t('<strong>Start posting content</strong> Finally, you may <a href=":content">add new content</a> to your website.', array(':content' => \Drupal::url('node.add_page'))) . '</li>';
+ $output .= '<li>' . t('<strong>Start posting content</strong> Finally, you may <a href=":content">add new content</a> to your website.', [':content' => \Drupal::url('node.add_page')]) . '</li>';
}
$output .= '</ol>';
- $output .= '<p>' . t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', array(':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org')) . '</p>';
+ $output .= '<p>' . t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']) . '</p>';
return ['#markup' => $output];
case 'help.page.help':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Help module generates <a href=":help-page">Help reference pages</a> to guide you through the use and configuration of modules, and provides a Help block with page-level help. The reference pages are a starting point for <a href=":handbook">Drupal.org online documentation</a> pages that contain more extensive and up-to-date information, are annotated with user-contributed comments, and serve as the definitive reference point for all Drupal documentation. For more information, see the <a href=":help">online documentation for the Help module</a>.', array(':help' => 'https://www.drupal.org/documentation/modules/help/', ':handbook' => 'https://www.drupal.org/documentation', ':help-page' => \Drupal::url('help.main'))) . '</p>';
+ $output .= '<p>' . t('The Help module generates <a href=":help-page">Help reference pages</a> to guide you through the use and configuration of modules, and provides a Help block with page-level help. The reference pages are a starting point for <a href=":handbook">Drupal.org online documentation</a> pages that contain more extensive and up-to-date information, are annotated with user-contributed comments, and serve as the definitive reference point for all Drupal documentation. For more information, see the <a href=":help">online documentation for the Help module</a>.', [':help' => 'https://www.drupal.org/documentation/modules/help/', ':handbook' => 'https://www.drupal.org/documentation', ':help-page' => \Drupal::url('help.main')]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Providing a help reference') . '</dt>';
- $output .= '<dd>' . t('The Help module displays explanations for using each module listed on the main <a href=":help">Help reference page</a>.', array(':help' => \Drupal::url('help.main'))) . '</dd>';
+ $output .= '<dd>' . t('The Help module displays explanations for using each module listed on the main <a href=":help">Help reference page</a>.', [':help' => \Drupal::url('help.main')]) . '</dd>';
$output .= '<dt>' . t('Providing page-specific help') . '</dt>';
- $output .= '<dd>' . t('Page-specific help text provided by modules is displayed in the Help block. This block can be placed and configured on the <a href=":blocks">Block layout page</a>.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
+ $output .= '<dd>' . t('Page-specific help text provided by modules is displayed in the Help block. This block can be placed and configured on the <a href=":blocks">Block layout page</a>.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
$output .= '</dl>';
return ['#markup' => $output];
}
diff --git a/core/modules/help/src/Controller/HelpController.php b/core/modules/help/src/Controller/HelpController.php
index 6c3f06142a6..74d46ecb056 100644
--- a/core/modules/help/src/Controller/HelpController.php
+++ b/core/modules/help/src/Controller/HelpController.php
@@ -112,7 +112,7 @@ class HelpController extends ControllerBase {
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function helpPage($name) {
- $build = array();
+ $build = [];
if ($this->moduleHandler()->implementsHook($name, 'help')) {
$module_name = $this->moduleHandler()->getName($name);
$build['#title'] = $module_name;
@@ -122,9 +122,9 @@ class HelpController extends ControllerBase {
drupal_set_message($this->t('This module is experimental. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', [':url' => 'https://www.drupal.org/core/experimental']), 'warning');
}
- $temp = $this->moduleHandler()->invoke($name, 'help', array("help.page.$name", $this->routeMatch));
+ $temp = $this->moduleHandler()->invoke($name, 'help', ["help.page.$name", $this->routeMatch]);
if (empty($temp)) {
- $build['top'] = ['#markup' => $this->t('No help is available for module %module.', array('%module' => $module_name))];
+ $build['top'] = ['#markup' => $this->t('No help is available for module %module.', ['%module' => $module_name])];
}
else {
if (!is_array($temp)) {
@@ -137,20 +137,20 @@ class HelpController extends ControllerBase {
// any such pages associated with it.
$admin_tasks = system_get_module_admin_tasks($name, system_get_info('module', $name));
if (!empty($admin_tasks)) {
- $links = array();
+ $links = [];
foreach ($admin_tasks as $task) {
$link['url'] = $task['url'];
$link['title'] = $task['title'];
$links[] = $link;
}
- $build['links'] = array(
+ $build['links'] = [
'#theme' => 'links__help',
- '#heading' => array(
+ '#heading' => [
'level' => 'h3',
- 'text' => $this->t('@module administration pages', array('@module' => $module_name)),
- ),
+ 'text' => $this->t('@module administration pages', ['@module' => $module_name]),
+ ],
'#links' => $links,
- );
+ ];
}
return $build;
}
diff --git a/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php b/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php
index a2d5e27db3a..9cdaa41858f 100644
--- a/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php
+++ b/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php
@@ -27,21 +27,21 @@ class SupernovaGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) {
+ public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) {
throw new \Exception();
}
/**
* {@inheritdoc}
*/
- public function getPathFromRoute($name, $parameters = array()) {
+ public function getPathFromRoute($name, $parameters = []) {
throw new \Exception();
}
/**
* {@inheritdoc}
*/
- public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
+ public function generateFromRoute($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) {
throw new \Exception();
}
@@ -55,7 +55,7 @@ class SupernovaGenerator implements UrlGeneratorInterface {
/**
* {@inheritdoc}
*/
- public function getRouteDebugMessage($name, array $parameters = array()) {
+ public function getRouteDebugMessage($name, array $parameters = []) {
throw new \Exception();
}
diff --git a/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php b/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php
index 9d1a74eecdf..0eabbda56ba 100644
--- a/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php
+++ b/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php
@@ -19,7 +19,7 @@ class ExperimentalHelpTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('help', 'experimental_module_test', 'help_page_test');
+ public static $modules = ['help', 'experimental_module_test', 'help_page_test'];
/**
* The admin user.
diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php
index 2e82499398a..e70eeb7665f 100644
--- a/core/modules/help/tests/src/Functional/HelpTest.php
+++ b/core/modules/help/tests/src/Functional/HelpTest.php
@@ -20,7 +20,7 @@ class HelpTest extends BrowserTestBase {
*
* @var array.
*/
- public static $modules = array('help_test', 'help_page_test');
+ public static $modules = ['help_test', 'help_page_test'];
/**
* Use the Standard profile to test help implementations of many core modules.
@@ -41,8 +41,8 @@ class HelpTest extends BrowserTestBase {
parent::setUp();
// Create users.
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer permissions'));
- $this->anyUser = $this->drupalCreateUser(array());
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'view the administration theme', 'administer permissions']);
+ $this->anyUser = $this->drupalCreateUser([]);
}
/**
@@ -61,7 +61,7 @@ class HelpTest extends BrowserTestBase {
// Verify that introductory help text exists, goes for 100% module coverage.
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/help');
- $this->assertRaw(t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', array(':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org')));
+ $this->assertRaw(t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']));
// Verify that hook_help() section title and description appear.
$this->assertRaw('<h2>' . t('Module overviews') . '</h2>');
@@ -74,13 +74,13 @@ class HelpTest extends BrowserTestBase {
// Make sure links are properly added for modules implementing hook_help().
foreach ($this->getModuleList() as $module => $name) {
- $this->assertLink($name, 0, format_string('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
+ $this->assertLink($name, 0, format_string('Link properly added to @name (admin/help/@module)', ['@module' => $module, '@name' => $name]));
}
// Ensure that module which does not provide an module overview page is
// handled correctly.
$this->clickLink(\Drupal::moduleHandler()->getName('help_test'));
- $this->assertRaw(t('No help is available for module %module.', array('%module' => \Drupal::moduleHandler()->getName('help_test'))));
+ $this->assertRaw(t('No help is available for module %module.', ['%module' => \Drupal::moduleHandler()->getName('help_test')]));
// Verify that the order of topics is alphabetical by displayed module
// name, by checking the order of some modules, including some that would
@@ -119,11 +119,11 @@ class HelpTest extends BrowserTestBase {
$this->drupalGet('admin/help/' . $module);
$this->assertResponse($response);
if ($response == 200) {
- $this->assertTitle($name . ' | Drupal', format_string('%module title was displayed', array('%module' => $module)));
+ $this->assertTitle($name . ' | Drupal', format_string('%module title was displayed', ['%module' => $module]));
$this->assertEquals($name, $this->cssSelect('h1.page-title')[0]->getText(), "$module heading was displayed");
$admin_tasks = system_get_module_admin_tasks($module, system_get_info('module', $module));
if (!empty($admin_tasks)) {
- $this->assertText(t('@module administration pages', array('@module' => $name)));
+ $this->assertText(t('@module administration pages', ['@module' => $name]));
}
foreach ($admin_tasks as $task) {
$this->assertLink($task['title']);
@@ -149,7 +149,7 @@ class HelpTest extends BrowserTestBase {
* A list of enabled modules.
*/
protected function getModuleList() {
- $modules = array();
+ $modules = [];
$module_data = system_rebuild_module_data();
foreach (\Drupal::moduleHandler()->getImplementations('help') as $module) {
$modules[$module] = $module_data[$module]->info['name'];
diff --git a/core/modules/help/tests/src/Functional/NoHelpTest.php b/core/modules/help/tests/src/Functional/NoHelpTest.php
index 49c768d7b6a..acb2563aee1 100644
--- a/core/modules/help/tests/src/Functional/NoHelpTest.php
+++ b/core/modules/help/tests/src/Functional/NoHelpTest.php
@@ -18,7 +18,7 @@ class NoHelpTest extends BrowserTestBase {
*
* @var array.
*/
- public static $modules = array('help', 'menu_test');
+ public static $modules = ['help', 'menu_test'];
/**
* The user who will be created.
@@ -27,7 +27,7 @@ class NoHelpTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('access administration pages'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages']);
}
/**
diff --git a/core/modules/history/history.install b/core/modules/history/history.install
index ede5255bc7b..8af53fe50dc 100644
--- a/core/modules/history/history.install
+++ b/core/modules/history/history.install
@@ -11,34 +11,34 @@ use Drupal\Core\Database\Database;
* Implements hook_schema().
*/
function history_schema() {
- $schema['history'] = array(
+ $schema['history'] = [
'description' => 'A record of which {users} have read which {node}s.',
- 'fields' => array(
- 'uid' => array(
+ 'fields' => [
+ 'uid' => [
'description' => 'The {users}.uid that read the {node} nid.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'nid' => array(
+ ],
+ 'nid' => [
'description' => 'The {node}.nid that was read.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'timestamp' => array(
+ ],
+ 'timestamp' => [
'description' => 'The Unix timestamp at which the read occurred.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('uid', 'nid'),
- 'indexes' => array(
- 'nid' => array('nid'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['uid', 'nid'],
+ 'indexes' => [
+ 'nid' => ['nid'],
+ ],
+ ];
return $schema;
}
@@ -56,43 +56,43 @@ function history_update_8101() {
$schema = Database::getConnection()->schema();
$schema->dropPrimaryKey('history');
$schema->dropIndex('history', 'nid');
- $schema->changeField('history', 'nid', 'nid', array(
+ $schema->changeField('history', 'nid', 'nid', [
'description' => 'The {node}.nid that was read.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ));
- $schema->addPrimaryKey('history', array('uid', 'nid'));
- $spec = array(
+ ]);
+ $schema->addPrimaryKey('history', ['uid', 'nid']);
+ $spec = [
'description' => 'A record of which {users} have read which {node}s.',
- 'fields' => array(
- 'uid' => array(
+ 'fields' => [
+ 'uid' => [
'description' => 'The {users}.uid that read the {node} nid.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'nid' => array(
+ ],
+ 'nid' => [
'description' => 'The {node}.nid that was read.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'timestamp' => array(
+ ],
+ 'timestamp' => [
'description' => 'The Unix timestamp at which the read occurred.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('uid', 'nid'),
- 'indexes' => array(
- 'nid' => array('nid'),
- ),
- );
- $schema->addIndex('history', 'nid', array('nid'), $spec);
+ ],
+ ],
+ 'primary key' => ['uid', 'nid'],
+ 'indexes' => [
+ 'nid' => ['nid'],
+ ],
+ ];
+ $schema->addIndex('history', 'nid', ['nid'], $spec);
}
/**
diff --git a/core/modules/history/history.module b/core/modules/history/history.module
index a31dd5befe0..58f40de3e77 100644
--- a/core/modules/history/history.module
+++ b/core/modules/history/history.module
@@ -28,7 +28,7 @@ function history_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.history':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The History module keeps track of which content a user has read. It marks content as <em>new</em> or <em>updated</em> depending on the last time the user viewed it. History records that are older than one month are removed during cron, which means that content older than one month is always considered <em>read</em>. The History module does not have a user interface but it provides a filter to <a href=":views-help">Views</a> to show new or updated content. For more information, see the <a href=":url">online documentation for the History module</a>.', array(':views-help' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', array ('name' => 'views')) : '#', ':url' => 'https://www.drupal.org/documentation/modules/history')) . '</p>';
+ $output .= '<p>' . t('The History module keeps track of which content a user has read. It marks content as <em>new</em> or <em>updated</em> depending on the last time the user viewed it. History records that are older than one month are removed during cron, which means that content older than one month is always considered <em>read</em>. The History module does not have a user interface but it provides a filter to <a href=":views-help">Views</a> to show new or updated content. For more information, see the <a href=":url">online documentation for the History module</a>.', [':views-help' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', ['name' => 'views']) : '#', ':url' => 'https://www.drupal.org/documentation/modules/history']) . '</p>';
return $output;
}
}
@@ -44,7 +44,7 @@ function history_help($route_name, RouteMatchInterface $route_match) {
* of when the last view occurred; otherwise, zero.
*/
function history_read($nid) {
- $history = history_read_multiple(array($nid));
+ $history = history_read_multiple([$nid]);
return $history[$nid];
}
@@ -60,11 +60,11 @@ function history_read($nid) {
* otherwise, zero.
*/
function history_read_multiple($nids) {
- $history = &drupal_static(__FUNCTION__, array());
+ $history = &drupal_static(__FUNCTION__, []);
- $return = array();
+ $return = [];
- $nodes_to_read = array();
+ $nodes_to_read = [];
foreach ($nids as $nid) {
if (isset($history[$nid])) {
$return[$nid] = $history[$nid];
@@ -79,10 +79,10 @@ function history_read_multiple($nids) {
return $return;
}
- $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = :uid AND nid IN ( :nids[] )', array(
+ $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = :uid AND nid IN ( :nids[] )', [
':uid' => \Drupal::currentUser()->id(),
':nids[]' => array_keys($nodes_to_read),
- ));
+ ]);
foreach ($result as $row) {
$nodes_to_read[$row->nid] = (int) $row->timestamp;
}
@@ -108,14 +108,14 @@ function history_write($nid, $account = NULL) {
if ($account->isAuthenticated()) {
db_merge('history')
- ->keys(array(
+ ->keys([
'uid' => $account->id(),
'nid' => $nid,
- ))
- ->fields(array('timestamp' => REQUEST_TIME))
+ ])
+ ->fields(['timestamp' => REQUEST_TIME])
->execute();
// Update static cache.
- $history = &drupal_static('history_read_multiple', array());
+ $history = &drupal_static('history_read_multiple', []);
$history[$nid] = REQUEST_TIME;
}
}
diff --git a/core/modules/history/history.views.inc b/core/modules/history/history.views.inc
index 4b9813645d5..a4dcd992753 100644
--- a/core/modules/history/history.views.inc
+++ b/core/modules/history/history.views.inc
@@ -17,29 +17,29 @@ function history_views_data() {
$data['history']['table']['group'] = t('Content');
// Explain how this table joins to others.
- $data['history']['table']['join'] = array(
+ $data['history']['table']['join'] = [
// Directly links to node table.
- 'node_field_data' => array(
+ 'node_field_data' => [
'table' => 'history',
'left_field' => 'nid',
'field' => 'nid',
- 'extra' => array(
- array('field' => 'uid', 'value' => '***CURRENT_USER***', 'numeric' => TRUE),
- ),
- ),
- );
+ 'extra' => [
+ ['field' => 'uid', 'value' => '***CURRENT_USER***', 'numeric' => TRUE],
+ ],
+ ],
+ ];
- $data['history']['timestamp'] = array(
+ $data['history']['timestamp'] = [
'title' => t('Has new content'),
- 'field' => array(
+ 'field' => [
'id' => 'history_user_timestamp',
'help' => t('Show a marker if the content is new or updated.'),
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'help' => t('Show only content that is new or updated.'),
'id' => 'history_user_timestamp',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php
index e6b0548f0a4..f33dab25aa5 100644
--- a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php
+++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php
@@ -34,10 +34,10 @@ class HistoryUserTimestamp extends Node {
parent::init($view, $display, $options);
if (\Drupal::currentUser()->isAuthenticated()) {
- $this->additional_fields['created'] = array('table' => 'node_field_data', 'field' => 'created');
- $this->additional_fields['changed'] = array('table' => 'node_field_data', 'field' => 'changed');
+ $this->additional_fields['created'] = ['table' => 'node_field_data', 'field' => 'created'];
+ $this->additional_fields['changed'] = ['table' => 'node_field_data', 'field' => 'changed'];
if (\Drupal::moduleHandler()->moduleExists('comment') && !empty($this->options['comments'])) {
- $this->additional_fields['last_comment'] = array('table' => 'comment_entity_statistics', 'field' => 'last_comment_timestamp');
+ $this->additional_fields['last_comment'] = ['table' => 'comment_entity_statistics', 'field' => 'last_comment_timestamp'];
}
}
}
@@ -45,7 +45,7 @@ class HistoryUserTimestamp extends Node {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['comments'] = array('default' => FALSE);
+ $options['comments'] = ['default' => FALSE];
return $options;
}
@@ -53,11 +53,11 @@ class HistoryUserTimestamp extends Node {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
if (\Drupal::moduleHandler()->moduleExists('comment')) {
- $form['comments'] = array(
+ $form['comments'] = [
'#type' => 'checkbox',
'#title' => $this->t('Check for new comments as well'),
'#default_value' => !empty($this->options['comments']),
- );
+ ];
}
}
@@ -92,10 +92,10 @@ class HistoryUserTimestamp extends Node {
elseif ($last_comment > $last_read && $last_comment > HISTORY_READ_LIMIT) {
$mark = MARK_UPDATED;
}
- $build = array(
+ $build = [
'#theme' => 'mark',
'#status' => $mark,
- );
+ ];
return $this->renderLink(drupal_render($build), $values);
}
}
diff --git a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
index 80d78bd6e7d..92a57991ca7 100644
--- a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
+++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
@@ -49,11 +49,11 @@ class HistoryUserTimestamp extends FilterPluginBase {
else {
$label = $this->t('Has new content');
}
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'checkbox',
'#title' => $label,
'#default_value' => $this->value,
- );
+ ];
}
}
diff --git a/core/modules/history/src/Tests/HistoryTest.php b/core/modules/history/src/Tests/HistoryTest.php
index 17bba34062b..d08d2112944 100644
--- a/core/modules/history/src/Tests/HistoryTest.php
+++ b/core/modules/history/src/Tests/HistoryTest.php
@@ -17,7 +17,7 @@ class HistoryTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'history');
+ public static $modules = ['node', 'history'];
/**
* The main user for testing.
@@ -36,11 +36,11 @@ class HistoryTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
- $this->user = $this->drupalCreateUser(array('create page content', 'access content'));
+ $this->user = $this->drupalCreateUser(['create page content', 'access content']);
$this->drupalLogin($this->user);
- $this->testNode = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->user->id()));
+ $this->testNode = $this->drupalCreateNode(['type' => 'page', 'uid' => $this->user->id()]);
}
/**
@@ -54,7 +54,7 @@ class HistoryTest extends WebTestBase {
*/
protected function getNodeReadTimestamps(array $node_ids) {
// Build POST values.
- $post = array();
+ $post = [];
for ($i = 0; $i < count($node_ids); $i++) {
$post['node_ids[' . $i . ']'] = $node_ids[$i];
}
@@ -69,15 +69,15 @@ class HistoryTest extends WebTestBase {
$post = implode('&', $post);
// Perform HTTP request.
- return $this->curlExec(array(
- CURLOPT_URL => \Drupal::url('history.get_last_node_view', array(), array('absolute' => TRUE)),
+ return $this->curlExec([
+ CURLOPT_URL => \Drupal::url('history.get_last_node_view', [], ['absolute' => TRUE]),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $post,
- CURLOPT_HTTPHEADER => array(
+ CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
- ),
- ));
+ ],
+ ]);
}
/**
@@ -90,12 +90,12 @@ class HistoryTest extends WebTestBase {
* The response body.
*/
protected function markNodeAsRead($node_id) {
- return $this->curlExec(array(
- CURLOPT_URL => \Drupal::url('history.read_node', array('node' => $node_id), array('absolute' => TRUE)),
- CURLOPT_HTTPHEADER => array(
+ return $this->curlExec([
+ CURLOPT_URL => \Drupal::url('history.read_node', ['node' => $node_id], ['absolute' => TRUE]),
+ CURLOPT_HTTPHEADER => [
'Accept: application/json',
- ),
- ));
+ ],
+ ]);
}
/**
@@ -105,10 +105,10 @@ class HistoryTest extends WebTestBase {
$nid = $this->testNode->id();
// Retrieve "last read" timestamp for test node, for the current user.
- $response = $this->getNodeReadTimestamps(array($nid));
+ $response = $this->getNodeReadTimestamps([$nid]);
$this->assertResponse(200);
$json = Json::decode($response);
- $this->assertIdentical(array(1 => 0), $json, 'The node has not yet been read.');
+ $this->assertIdentical([1 => 0], $json, 'The node has not yet been read.');
// View the node.
$this->drupalGet('node/' . $nid);
@@ -126,20 +126,20 @@ class HistoryTest extends WebTestBase {
$this->assertTrue(is_numeric($timestamp), 'Node has been marked as read. Timestamp received.');
// Retrieve "last read" timestamp for test node, for the current user.
- $response = $this->getNodeReadTimestamps(array($nid));
+ $response = $this->getNodeReadTimestamps([$nid]);
$this->assertResponse(200);
$json = Json::decode($response);
- $this->assertIdentical(array(1 => $timestamp), $json, 'The node has been read.');
+ $this->assertIdentical([1 => $timestamp], $json, 'The node has been read.');
// Failing to specify node IDs for the first endpoint should return a 404.
- $this->getNodeReadTimestamps(array());
+ $this->getNodeReadTimestamps([]);
$this->assertResponse(404);
// Accessing either endpoint as the anonymous user should return a 403.
$this->drupalLogout();
- $this->getNodeReadTimestamps(array($nid));
+ $this->getNodeReadTimestamps([$nid]);
$this->assertResponse(403);
- $this->getNodeReadTimestamps(array());
+ $this->getNodeReadTimestamps([]);
$this->assertResponse(403);
$this->markNodeAsRead($nid);
$this->assertResponse(403);
diff --git a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php
index 0f484014b0a..47665383928 100644
--- a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php
+++ b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php
@@ -19,20 +19,20 @@ class HistoryTimestampTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('history', 'node');
+ public static $modules = ['history', 'node'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_history');
+ public static $testViews = ['test_history'];
/**
* Tests the handlers.
*/
public function testHandlers() {
- $nodes = array();
+ $nodes = [];
$nodes[] = $this->drupalCreateNode();
$nodes[] = $this->drupalCreateNode();
@@ -41,23 +41,23 @@ class HistoryTimestampTest extends ViewTestBase {
\Drupal::currentUser()->setAccount($account);
db_insert('history')
- ->fields(array(
+ ->fields([
'uid' => $account->id(),
'nid' => $nodes[0]->id(),
'timestamp' => REQUEST_TIME - 100,
- ))->execute();
+ ])->execute();
db_insert('history')
- ->fields(array(
+ ->fields([
'uid' => $account->id(),
'nid' => $nodes[1]->id(),
'timestamp' => REQUEST_TIME + 100,
- ))->execute();
+ ])->execute();
- $column_map = array(
+ $column_map = [
'nid' => 'nid',
- );
+ ];
// Test the history field.
$view = Views::getView('test_history');
@@ -66,7 +66,7 @@ class HistoryTimestampTest extends ViewTestBase {
$this->assertEqual(count($view->result), 2);
$output = $view->preview();
$this->setRawContent(\Drupal::service('renderer')->renderRoot($output));
- $result = $this->xpath('//span[@class=:class]', array(':class' => 'marker'));
+ $result = $this->xpath('//span[@class=:class]', [':class' => 'marker']);
$this->assertEqual(count($result), 1, 'Just one node is marked as new');
// Test the history filter.
@@ -74,7 +74,7 @@ class HistoryTimestampTest extends ViewTestBase {
$view->setDisplay('page_2');
$this->executeView($view);
$this->assertEqual(count($view->result), 1);
- $this->assertIdenticalResultset($view, array(array('nid' => $nodes[0]->id())), $column_map);
+ $this->assertIdenticalResultset($view, [['nid' => $nodes[0]->id()]], $column_map);
// Install Comment module and make sure that content types without comment
// field will not break the view.
diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc
index 777e43855a4..e43bd48765f 100644
--- a/core/modules/image/image.admin.inc
+++ b/core/modules/image/image.admin.inc
@@ -33,11 +33,11 @@ function template_preprocess_image_style_preview(&$variables) {
// Set up original file information.
$original_path = \Drupal::config('image.settings')->get('preview_image');
$original_image = $image_factory->get($original_path);
- $variables['original'] = array(
+ $variables['original'] = [
'url' => file_url_transform_relative(file_create_url($original_path)),
'width' => $original_image->getWidth(),
'height' => $original_image->getHeight(),
- );
+ ];
if ($variables['original']['width'] > $variables['original']['height']) {
$variables['preview']['original']['width'] = min($variables['original']['width'], $sample_width);
$variables['preview']['original']['height'] = round($variables['preview']['original']['width'] / $variables['original']['width'] * $variables['original']['height']);
@@ -54,11 +54,11 @@ function template_preprocess_image_style_preview(&$variables) {
$style->createDerivative($original_path, $preview_file);
}
$preview_image = $image_factory->get($preview_file);
- $variables['derivative'] = array(
+ $variables['derivative'] = [
'url' => file_url_transform_relative(file_create_url($preview_file)),
'width' => $preview_image->getWidth(),
'height' => $preview_image->getHeight(),
- );
+ ];
if ($variables['derivative']['width'] > $variables['derivative']['height']) {
$variables['preview']['derivative']['width'] = min($variables['derivative']['width'], $sample_width);
$variables['preview']['derivative']['height'] = round($variables['preview']['derivative']['width'] / $variables['derivative']['width'] * $variables['derivative']['height']);
@@ -69,31 +69,31 @@ function template_preprocess_image_style_preview(&$variables) {
}
// Build the preview of the original image.
- $variables['original']['rendered'] = array(
+ $variables['original']['rendered'] = [
'#theme' => 'image',
'#uri' => $original_path,
'#alt' => t('Sample original image'),
'#title' => '',
- '#attributes' => array(
+ '#attributes' => [
'width' => $variables['original']['width'],
'height' => $variables['original']['height'],
'style' => 'width: ' . $variables['preview']['original']['width'] . 'px; height: ' . $variables['preview']['original']['height'] . 'px;',
- ),
- );
+ ],
+ ];
// Build the preview of the image style derivative. Timestamps are added
// to prevent caching of images on the client side.
- $variables['derivative']['rendered'] = array(
+ $variables['derivative']['rendered'] = [
'#theme' => 'image',
'#uri' => $variables['derivative']['url'] . '?cache_bypass=' . $variables['cache_bypass'],
'#alt' => t('Sample modified image'),
'#title' => '',
- '#attributes' => array(
+ '#attributes' => [
'width' => $variables['derivative']['width'],
'height' => $variables['derivative']['height'],
'style' => 'width: ' . $variables['preview']['derivative']['width'] . 'px; height: ' . $variables['preview']['derivative']['height'] . 'px;',
- ),
- );
+ ],
+ ];
}
@@ -109,26 +109,26 @@ function template_preprocess_image_style_preview(&$variables) {
function template_preprocess_image_anchor(&$variables) {
$element = $variables['element'];
- $rows = array();
- $row = array();
+ $rows = [];
+ $row = [];
foreach (Element::children($element) as $n => $key) {
$element[$key]['#attributes']['title'] = $element[$key]['#title'];
unset($element[$key]['#title']);
- $row[] = array(
+ $row[] = [
'data' => $element[$key],
- );
+ ];
if ($n % 3 == 3 - 1) {
$rows[] = $row;
- $row = array();
+ $row = [];
}
}
- $variables['table'] = array(
+ $variables['table'] = [
'#type' => 'table',
- '#header' => array(),
+ '#header' => [],
'#rows' => $rows,
- '#attributes' => array(
- 'class' => array('image-anchor'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['image-anchor'],
+ ],
+ ];
}
diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc
index 1bf4369e7bd..9fcdf69116c 100644
--- a/core/modules/image/image.field.inc
+++ b/core/modules/image/image.field.inc
@@ -20,14 +20,14 @@ use Drupal\Core\Render\Element;
function template_preprocess_image_widget(&$variables) {
$element = $variables['element'];
- $variables['attributes'] = array('class' => array('image-widget', 'js-form-managed-file', 'form-managed-file', 'clearfix'));
+ $variables['attributes'] = ['class' => ['image-widget', 'js-form-managed-file', 'form-managed-file', 'clearfix']];
if (!empty($element['fids']['#value'])) {
$file = reset($element['#files']);
$element['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file->getSize()) . ')</span> ';
}
- $variables['data'] = array();
+ $variables['data'] = [];
foreach (Element::children($element) as $child) {
$variables['data'][$child] = $element[$child];
}
@@ -49,15 +49,15 @@ function template_preprocess_image_widget(&$variables) {
*/
function template_preprocess_image_formatter(&$variables) {
if ($variables['image_style']) {
- $variables['image'] = array(
+ $variables['image'] = [
'#theme' => 'image_style',
'#style_name' => $variables['image_style'],
- );
+ ];
}
else {
- $variables['image'] = array(
+ $variables['image'] = [
'#theme' => 'image',
- );
+ ];
}
$variables['image']['#attributes'] = $variables['item_attributes'];
@@ -75,7 +75,7 @@ function template_preprocess_image_formatter(&$variables) {
$variables['image']['#uri'] = $item->uri;
}
- foreach (array('width', 'height', 'alt') as $key) {
+ foreach (['width', 'height', 'alt'] as $key) {
$variables['image']["#$key"] = $item->$key;
}
}
diff --git a/core/modules/image/image.install b/core/modules/image/image.install
index c044912ef1d..d7a2ce7dcaa 100644
--- a/core/modules/image/image.install
+++ b/core/modules/image/image.install
@@ -29,19 +29,19 @@ function image_uninstall() {
*/
function image_requirements($phase) {
if ($phase != 'runtime') {
- return array();
+ return [];
}
$toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit();
if ($toolkit) {
$plugin_definition = $toolkit->getPluginDefinition();
- $requirements = array(
- 'image.toolkit' => array(
+ $requirements = [
+ 'image.toolkit' => [
'title' => t('Image toolkit'),
'value' => $toolkit->getPluginId(),
'description' => $plugin_definition['title'],
- ),
- );
+ ],
+ ];
foreach ($toolkit->getRequirements() as $key => $requirement) {
$namespaced_key = 'image.toolkit.' . $toolkit->getPluginId() . '.' . $key;
@@ -49,14 +49,14 @@ function image_requirements($phase) {
}
}
else {
- $requirements = array(
- 'image.toolkit' => array(
+ $requirements = [
+ 'image.toolkit' => [
'title' => t('Image toolkit'),
'value' => t('None'),
'description' => t("No image toolkit is configured on the site. Check PHP installed extensions or add a contributed toolkit that doesn't require a PHP extension. Make sure that at least one valid image toolkit is enabled."),
'severity' => REQUIREMENT_ERROR,
- ),
- );
+ ],
+ ];
}
return $requirements;
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 33ecf2e9876..6107ecd909e 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -58,20 +58,20 @@ define('IMAGE_DERIVATIVE_TOKEN', 'itok');
function image_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.image':
- $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
+ $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Image module allows you to create fields that contain image files and to configure <a href=":image_styles">Image styles</a> that can be used to manipulate the display of images. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for terminology and general information on entities, fields, and how to create and manage fields. For more information, see the <a href=":image_documentation">online documentation for the Image module</a>.', array(':image_styles' => \Drupal::url('entity.image_style.collection'), ':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => $field_ui_url, ':image_documentation' => 'https://www.drupal.org/documentation/modules/image')) . '</p>';
+ $output .= '<p>' . t('The Image module allows you to create fields that contain image files and to configure <a href=":image_styles">Image styles</a> that can be used to manipulate the display of images. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for terminology and general information on entities, fields, and how to create and manage fields. For more information, see the <a href=":image_documentation">online documentation for the Image module</a>.', [':image_styles' => \Drupal::url('entity.image_style.collection'), ':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => $field_ui_url, ':image_documentation' => 'https://www.drupal.org/documentation/modules/image']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dt>' . t('Defining image styles') . '</dt>';
- $output .= '<dd>' . t('The concept of image styles is that you can upload a single image but display it in several ways; each display variation, or <em>image style</em>, is the result of applying one or more <em>effects</em> to the original image. As an example, you might upload a high-resolution image with a 4:3 aspect ratio, and display it scaled down, square cropped, or black-and-white (or any combination of these effects). The Image module provides a way to do this efficiently: you configure an image style with the desired effects on the <a href=":image">Image styles page</a>, and the first time a particular image is requested in that style, the effects are applied. The resulting image is saved, and the next time that same style is requested, the saved image is retrieved without the need to recalculate the effects. Drupal core provides several effects that you can use to define styles; others may be provided by contributed modules.', array(':image' => \Drupal::url('entity.image_style.collection')));
+ $output .= '<dd>' . t('The concept of image styles is that you can upload a single image but display it in several ways; each display variation, or <em>image style</em>, is the result of applying one or more <em>effects</em> to the original image. As an example, you might upload a high-resolution image with a 4:3 aspect ratio, and display it scaled down, square cropped, or black-and-white (or any combination of these effects). The Image module provides a way to do this efficiently: you configure an image style with the desired effects on the <a href=":image">Image styles page</a>, and the first time a particular image is requested in that style, the effects are applied. The resulting image is saved, and the next time that same style is requested, the saved image is retrieved without the need to recalculate the effects. Drupal core provides several effects that you can use to define styles; others may be provided by contributed modules.', [':image' => \Drupal::url('entity.image_style.collection')]);
$output .= '<dt>' . t('Naming image styles') . '</dt>';
$output .= '<dd>' . t('When you define an image style, you will need to choose a displayed name and a machine name. The displayed name is shown in administrative pages, and the machine name is used to generate the URL for accessing an image processed in that style. There are two common approaches to naming image styles: either based on the effects being applied (for example, <em>Square 85x85</em>), or based on where you plan to use it (for example, <em>Profile picture</em>).') . '</dd>';
$output .= '<dt>' . t('Configuring image fields') . '</dt>';
$output .= '<dd>' . t('A few of the settings for image fields are defined once when you create the field and cannot be changed later; these include the choice of public or private file storage and the number of images that can be stored in the field. The rest of the settings can be edited later; these settings include the field label, help text, allowed file extensions, image resolution restrictions, and the subdirectory in the public or private file storage where the images will be stored. The editable settings can also have different values for different entity sub-types; for instance, if your image field is used on both Page and Article content types, you can store the files in a different subdirectory for the two content types.') . '</dd>';
$output .= '<dd>' . t('For accessibility and search engine optimization, all images that convey meaning on web sites should have alternate text. Drupal also allows entry of title text for images, but it can lead to confusion for screen reader users and its use is not recommended. Image fields can be configured so that alternate and title text fields are enabled or disabled; if enabled, the fields can be set to be required. The recommended setting is to enable and require alternate text and disable title text.') . '</dd>';
- $output .= '<dd>' . t('When you create an image field, you will need to choose whether the uploaded images will be stored in the public or private file directory defined in your settings.php file and shown on the <a href=":file-system">File system page</a>. This choice cannot be changed later. You can also configure your field to store files in a subdirectory of the public or private directory; this setting can be changed later and can be different for each entity sub-type using the field. For more information on file storage, see the <a href=":system-help">System module help page</a>.', array(':file-system' => \Drupal::url('system.file_system_settings'), ':system-help' => \Drupal::url('help.page', array('name' => 'system')))) . '</dd>';
+ $output .= '<dd>' . t('When you create an image field, you will need to choose whether the uploaded images will be stored in the public or private file directory defined in your settings.php file and shown on the <a href=":file-system">File system page</a>. This choice cannot be changed later. You can also configure your field to store files in a subdirectory of the public or private directory; this setting can be changed later and can be different for each entity sub-type using the field. For more information on file storage, see the <a href=":system-help">System module help page</a>.', [':file-system' => \Drupal::url('system.file_system_settings'), ':system-help' => \Drupal::url('help.page', ['name' => 'system'])]) . '</dd>';
$output .= '<dd>' . t('The maximum file size that can be uploaded is limited by PHP settings of the server, but you can restrict it further by configuring a <em>Maximum upload size</em> in the field settings (this setting can be changed later). The maximum file size, either from PHP server settings or field configuration, is automatically displayed to users in the help text of the image field.') . '</dd>';
$output .= '<dd>' . t('You can also configure a minimum and/or maximum resolution for uploaded images. Images that are too small will be rejected. Images that are to large will be resized. During the resizing the <a href="http://wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image will be lost.') . '</dd>';
$output .= '<dd>' . t('You can also configure a default image that will be used if no image is uploaded in an image field. This default can be defined for all instances of the field in the field storage settings when you create a field, and the setting can be overridden for each entity sub-type that uses the field.') . '</dd>';
@@ -98,9 +98,9 @@ function image_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function image_theme() {
- return array(
+ return [
// Theme functions in image.module.
- 'image_style' => array(
+ 'image_style' => [
// HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
// allows the alt attribute to be omitted in some cases. Therefore,
// default the alt attribute to an empty string, but allow code using
@@ -113,49 +113,49 @@ function image_theme() {
// - http://dev.w3.org/html5/spec/Overview.html#alt
// The title attribute is optional in all cases, so it is omitted by
// default.
- 'variables' => array(
+ 'variables' => [
'style_name' => NULL,
'uri' => NULL,
'width' => NULL,
'height' => NULL,
'alt' => '',
'title' => NULL,
- 'attributes' => array(),
- ),
- ),
+ 'attributes' => [],
+ ],
+ ],
// Theme functions in image.admin.inc.
- 'image_style_preview' => array(
- 'variables' => array('style' => NULL),
+ 'image_style_preview' => [
+ 'variables' => ['style' => NULL],
'file' => 'image.admin.inc',
- ),
- 'image_anchor' => array(
+ ],
+ 'image_anchor' => [
'render element' => 'element',
'file' => 'image.admin.inc',
- ),
- 'image_resize_summary' => array(
- 'variables' => array('data' => NULL, 'effect' => array()),
- ),
- 'image_scale_summary' => array(
- 'variables' => array('data' => NULL, 'effect' => array()),
- ),
- 'image_crop_summary' => array(
- 'variables' => array('data' => NULL, 'effect' => array()),
- ),
- 'image_rotate_summary' => array(
- 'variables' => array('data' => NULL, 'effect' => array()),
- ),
+ ],
+ 'image_resize_summary' => [
+ 'variables' => ['data' => NULL, 'effect' => []],
+ ],
+ 'image_scale_summary' => [
+ 'variables' => ['data' => NULL, 'effect' => []],
+ ],
+ 'image_crop_summary' => [
+ 'variables' => ['data' => NULL, 'effect' => []],
+ ],
+ 'image_rotate_summary' => [
+ 'variables' => ['data' => NULL, 'effect' => []],
+ ],
// Theme functions in image.field.inc.
- 'image_widget' => array(
+ 'image_widget' => [
'render element' => 'element',
'file' => 'image.field.inc',
- ),
- 'image_formatter' => array(
- 'variables' => array('item' => NULL, 'item_attributes' => NULL, 'url' => NULL, 'image_style' => NULL),
+ ],
+ 'image_formatter' => [
+ 'variables' => ['item' => NULL, 'item_attributes' => NULL, 'url' => NULL, 'image_style' => NULL],
'file' => 'image.field.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -180,17 +180,17 @@ function image_file_download($uri) {
$image = \Drupal::service('image.factory')->get($uri);
if ($image->isValid()) {
// Check the permissions of the original to grant access to this image.
- $headers = \Drupal::moduleHandler()->invokeAll('file_download', array($original_uri));
+ $headers = \Drupal::moduleHandler()->invokeAll('file_download', [$original_uri]);
// Confirm there's at least one module granting access and none denying access.
if (!empty($headers) && !in_array(-1, $headers)) {
- return array(
+ return [
// Send headers describing the image's size, and MIME-type.
'Content-Type' => $image->getMimeType(),
'Content-Length' => $image->getFileSize(),
// By not explicitly setting them here, this uses normal Drupal
// Expires, Cache-Control and ETag headers to prevent proxy or
// browser caching of private images.
- );
+ ];
}
}
return -1;
@@ -236,7 +236,7 @@ function image_path_flush($path) {
*/
function image_style_options($include_empty = TRUE) {
$styles = ImageStyle::loadMultiple();
- $options = array();
+ $options = [];
if ($include_empty && !empty($styles)) {
$options[''] = t('- None -');
}
@@ -280,21 +280,21 @@ function template_preprocess_image_style(&$variables) {
$style = ImageStyle::load($variables['style_name']);
// Determine the dimensions of the styled image.
- $dimensions = array(
+ $dimensions = [
'width' => $variables['width'],
'height' => $variables['height'],
- );
+ ];
$style->transformDimensions($dimensions, $variables['uri']);
- $variables['image'] = array(
+ $variables['image'] = [
'#theme' => 'image',
'#width' => $dimensions['width'],
'#height' => $dimensions['height'],
'#attributes' => $variables['attributes'],
'#uri' => $style->buildUrl($variables['uri']),
'#style_name' => $variables['style_name'],
- );
+ ];
if (isset($variables['alt']) || array_key_exists('alt', $variables)) {
$variables['image']['#alt'] = $variables['alt'];
diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc
index 29e6b6a6bb2..cca0e3d904d 100644
--- a/core/modules/image/image.views.inc
+++ b/core/modules/image/image.views.inc
@@ -19,13 +19,13 @@ function image_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the target_id field.
- $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array(
+ $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = [
'id' => 'standard',
'base' => 'file_managed',
'entity type' => 'file',
'base field' => 'fid',
- 'label' => t('image from @field_name', array('@field_name' => $field_storage->getName())),
- );
+ 'label' => t('image from @field_name', ['@field_name' => $field_storage->getName()]),
+ ];
}
return $data;
@@ -47,10 +47,10 @@ function image_field_views_data_views_data_alter(array &$data, FieldStorageConfi
list($label) = views_entity_field_label($entity_type_id, $field_name);
- $data['file_managed'][$pseudo_field_name]['relationship'] = array(
- 'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
- 'label' => t('@field_name', array('@field_name' => $field_name)),
- 'help' => t('Relate each @entity with a @field set to the image.', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
+ $data['file_managed'][$pseudo_field_name]['relationship'] = [
+ 'title' => t('@entity using @field', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
+ 'label' => t('@field_name', ['@field_name' => $field_name]),
+ 'help' => t('Relate each @entity with a @field set to the image.', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
'group' => $entity_type->getLabel(),
'id' => 'entity_reverse',
'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(),
@@ -59,12 +59,12 @@ function image_field_views_data_views_data_alter(array &$data, FieldStorageConfi
'field_name' => $field_name,
'field table' => $table_mapping->getDedicatedDataTableName($field_storage),
'field field' => $field_name . '_target_id',
- 'join_extra' => array(
- 0 => array(
+ 'join_extra' => [
+ 0 => [
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
diff --git a/core/modules/image/src/Controller/ImageStyleDownloadController.php b/core/modules/image/src/Controller/ImageStyleDownloadController.php
index 8859bdd16a9..afc1edf75d1 100644
--- a/core/modules/image/src/Controller/ImageStyleDownloadController.php
+++ b/core/modules/image/src/Controller/ImageStyleDownloadController.php
@@ -108,12 +108,12 @@ class ImageStyleDownloadController extends FileDownloadController {
}
$derivative_uri = $image_style->buildUri($image_uri);
- $headers = array();
+ $headers = [];
// If using the private scheme, let other modules provide headers and
// control access to the file.
if ($scheme == 'private') {
- $headers = $this->moduleHandler()->invokeAll('file_download', array($image_uri));
+ $headers = $this->moduleHandler()->invokeAll('file_download', [$image_uri]);
if (in_array(-1, $headers) || empty($headers)) {
throw new AccessDeniedHttpException();
}
@@ -128,7 +128,7 @@ class ImageStyleDownloadController extends FileDownloadController {
$path_info = pathinfo($image_uri);
$converted_image_uri = $path_info['dirname'] . DIRECTORY_SEPARATOR . $path_info['filename'];
if (!file_exists($converted_image_uri)) {
- $this->logger->notice('Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.', array('%source_image_path' => $image_uri, '%derivative_path' => $derivative_uri));
+ $this->logger->notice('Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.', ['%source_image_path' => $image_uri, '%derivative_path' => $derivative_uri]);
return new Response($this->t('Error generating image, missing source file.'), 404);
}
else {
@@ -160,10 +160,10 @@ class ImageStyleDownloadController extends FileDownloadController {
if ($success) {
$image = $this->imageFactory->get($derivative_uri);
$uri = $image->getSource();
- $headers += array(
+ $headers += [
'Content-Type' => $image->getMimeType(),
'Content-Length' => $image->getFileSize(),
- );
+ ];
// \Drupal\Core\EventSubscriber\FinishResponseSubscriber::onRespond()
// sets response as not cacheable if the Cache-Control header is not
// already modified. We pass in FALSE for non-private schemes for the
@@ -171,7 +171,7 @@ class ImageStyleDownloadController extends FileDownloadController {
return new BinaryFileResponse($uri, 200, $headers, $scheme !== 'private');
}
else {
- $this->logger->notice('Unable to generate the derived image located at %path.', array('%path' => $derivative_uri));
+ $this->logger->notice('Unable to generate the derived image located at %path.', ['%path' => $derivative_uri]);
return new Response($this->t('Error generating image.'), 500);
}
}
diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php
index e72258da688..fb096a7fdb2 100644
--- a/core/modules/image/src/Entity/ImageStyle.php
+++ b/core/modules/image/src/Entity/ImageStyle.php
@@ -73,7 +73,7 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
*
* @var array
*/
- protected $effects = array();
+ protected $effects = [];
/**
* Holds the collection of image effects that are used by this image style.
@@ -200,11 +200,11 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
// that (if both are set, the security token will neither be emitted in the
// image derivative URL nor checked for in
// \Drupal\image\ImageStyleInterface::deliver()).
- $token_query = array();
+ $token_query = [];
if (!\Drupal::config('image.settings')->get('suppress_itok_output')) {
// The passed $path variable can be either a relative path or a full URI.
$original_uri = file_uri_scheme($path) ? file_stream_wrapper_uri_normalize($path) : file_build_uri($path);
- $token_query = array(IMAGE_DERIVATIVE_TOKEN => $this->getPathToken($original_uri));
+ $token_query = [IMAGE_DERIVATIVE_TOKEN => $this->getPathToken($original_uri)];
}
if ($clean_urls === NULL) {
@@ -225,7 +225,7 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
// built.
if ($clean_urls === FALSE && file_uri_scheme($uri) == 'public' && !file_exists($uri)) {
$directory_path = $this->getStreamWrapperManager()->getViaUri($uri)->getDirectoryPath();
- return Url::fromUri('base:' . $directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query))->toString();
+ return Url::fromUri('base:' . $directory_path . '/' . file_uri_target($uri), ['absolute' => TRUE, 'query' => $token_query])->toString();
}
$file_url = file_create_url($uri);
@@ -260,7 +260,7 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
// Let other modules update as necessary on flush.
$module_handler = \Drupal::moduleHandler();
- $module_handler->invokeAll('image_style_flush', array($this));
+ $module_handler->invokeAll('image_style_flush', [$this]);
// Clear caches so that formatters may be added for this style.
drupal_theme_rebuild();
@@ -286,7 +286,7 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
// Build the destination folder tree if it doesn't already exist.
if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
- \Drupal::logger('image')->error('Failed to create style directory: %directory', array('%directory' => $directory));
+ \Drupal::logger('image')->error('Failed to create style directory: %directory', ['%directory' => $directory]);
return FALSE;
}
@@ -296,7 +296,7 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
if (!$image->save($derivative_uri)) {
if (file_exists($derivative_uri)) {
- \Drupal::logger('image')->error('Cached image file %destination already exists. There may be an issue with your rewrite configuration.', array('%destination' => $derivative_uri));
+ \Drupal::logger('image')->error('Cached image file %destination already exists. There may be an issue with your rewrite configuration.', ['%destination' => $derivative_uri]);
}
return FALSE;
}
@@ -362,7 +362,7 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
* {@inheritdoc}
*/
public function getPluginCollections() {
- return array('effects' => $this->getEffects());
+ return ['effects' => $this->getEffects()];
}
/**
diff --git a/core/modules/image/src/Form/ImageEffectAddForm.php b/core/modules/image/src/Form/ImageEffectAddForm.php
index 5bf04b40ff6..ce304511b1f 100644
--- a/core/modules/image/src/Form/ImageEffectAddForm.php
+++ b/core/modules/image/src/Form/ImageEffectAddForm.php
@@ -44,7 +44,7 @@ class ImageEffectAddForm extends ImageEffectFormBase {
public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) {
$form = parent::buildForm($form, $form_state, $image_style, $image_effect);
- $form['#title'] = $this->t('Add %label effect', array('%label' => $this->imageEffect->label()));
+ $form['#title'] = $this->t('Add %label effect', ['%label' => $this->imageEffect->label()]);
$form['actions']['submit']['#value'] = $this->t('Add effect');
return $form;
diff --git a/core/modules/image/src/Form/ImageEffectDeleteForm.php b/core/modules/image/src/Form/ImageEffectDeleteForm.php
index e8c51625bb1..52cde33c694 100644
--- a/core/modules/image/src/Form/ImageEffectDeleteForm.php
+++ b/core/modules/image/src/Form/ImageEffectDeleteForm.php
@@ -29,7 +29,7 @@ class ImageEffectDeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $this->imageStyle->label(), '@effect' => $this->imageEffect->label()));
+ return $this->t('Are you sure you want to delete the @effect effect from the %style style?', ['%style' => $this->imageStyle->label(), '@effect' => $this->imageEffect->label()]);
}
/**
@@ -68,7 +68,7 @@ class ImageEffectDeleteForm extends ConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->imageStyle->deleteImageEffect($this->imageEffect);
- drupal_set_message($this->t('The image effect %name has been deleted.', array('%name' => $this->imageEffect->label())));
+ drupal_set_message($this->t('The image effect %name has been deleted.', ['%name' => $this->imageEffect->label()]));
$form_state->setRedirectUrl($this->imageStyle->urlInfo('edit-form'));
}
diff --git a/core/modules/image/src/Form/ImageEffectEditForm.php b/core/modules/image/src/Form/ImageEffectEditForm.php
index 7b54c529af5..390e4dc7b35 100644
--- a/core/modules/image/src/Form/ImageEffectEditForm.php
+++ b/core/modules/image/src/Form/ImageEffectEditForm.php
@@ -16,7 +16,7 @@ class ImageEffectEditForm extends ImageEffectFormBase {
public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) {
$form = parent::buildForm($form, $form_state, $image_style, $image_effect);
- $form['#title'] = $this->t('Edit %label effect', array('%label' => $this->imageEffect->label()));
+ $form['#title'] = $this->t('Edit %label effect', ['%label' => $this->imageEffect->label()]);
$form['actions']['submit']['#value'] = $this->t('Update effect');
return $form;
diff --git a/core/modules/image/src/Form/ImageEffectFormBase.php b/core/modules/image/src/Form/ImageEffectFormBase.php
index 9a69e05b3d2..74368d6082b 100644
--- a/core/modules/image/src/Form/ImageEffectFormBase.php
+++ b/core/modules/image/src/Form/ImageEffectFormBase.php
@@ -64,14 +64,14 @@ abstract class ImageEffectFormBase extends FormBase {
}
$form['#attached']['library'][] = 'image/admin';
- $form['uuid'] = array(
+ $form['uuid'] = [
'#type' => 'value',
'#value' => $this->imageEffect->getUuid(),
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'value',
'#value' => $this->imageEffect->getPluginId(),
- );
+ ];
$form['data'] = [];
$subform_state = SubformState::createForSubform($form['data'], $form, $form_state);
@@ -79,22 +79,22 @@ abstract class ImageEffectFormBase extends FormBase {
$form['data']['#tree'] = TRUE;
// Check the URL for a weight, then the image effect, otherwise use default.
- $form['weight'] = array(
+ $form['weight'] = [
'#type' => 'hidden',
'#value' => $request->query->has('weight') ? (int) $request->query->get('weight') : $this->imageEffect->getWeight(),
- );
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#button_type' => 'primary',
- );
- $form['actions']['cancel'] = array(
+ ];
+ $form['actions']['cancel'] = [
'#type' => 'link',
'#title' => $this->t('Cancel'),
'#url' => $this->imageStyle->urlInfo('edit-form'),
'#attributes' => ['class' => ['button']],
- );
+ ];
return $form;
}
diff --git a/core/modules/image/src/Form/ImageStyleAddForm.php b/core/modules/image/src/Form/ImageStyleAddForm.php
index eb6be7dbf8c..41261cac396 100644
--- a/core/modules/image/src/Form/ImageStyleAddForm.php
+++ b/core/modules/image/src/Form/ImageStyleAddForm.php
@@ -14,7 +14,7 @@ class ImageStyleAddForm extends ImageStyleFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
- drupal_set_message($this->t('Style %name was created.', array('%name' => $this->entity->label())));
+ drupal_set_message($this->t('Style %name was created.', ['%name' => $this->entity->label()]));
}
/**
diff --git a/core/modules/image/src/Form/ImageStyleDeleteForm.php b/core/modules/image/src/Form/ImageStyleDeleteForm.php
index 2d6801beb66..c02c803f6e2 100644
--- a/core/modules/image/src/Form/ImageStyleDeleteForm.php
+++ b/core/modules/image/src/Form/ImageStyleDeleteForm.php
@@ -21,7 +21,7 @@ class ImageStyleDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Optionally select a style before deleting %style', array('%style' => $this->entity->label()));
+ return $this->t('Optionally select a style before deleting %style', ['%style' => $this->entity->label()]);
}
/**
* {@inheritdoc}
diff --git a/core/modules/image/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php
index ecfcf6f3bbc..574d9145a8b 100644
--- a/core/modules/image/src/Form/ImageStyleEditForm.php
+++ b/core/modules/image/src/Form/ImageStyleEditForm.php
@@ -49,54 +49,54 @@ class ImageStyleEditForm extends ImageStyleFormBase {
*/
public function form(array $form, FormStateInterface $form_state) {
$user_input = $form_state->getUserInput();
- $form['#title'] = $this->t('Edit style %name', array('%name' => $this->entity->label()));
+ $form['#title'] = $this->t('Edit style %name', ['%name' => $this->entity->label()]);
$form['#tree'] = TRUE;
$form['#attached']['library'][] = 'image/admin';
// Show the thumbnail preview.
- $preview_arguments = array('#theme' => 'image_style_preview', '#style' => $this->entity);
- $form['preview'] = array(
+ $preview_arguments = ['#theme' => 'image_style_preview', '#style' => $this->entity];
+ $form['preview'] = [
'#type' => 'item',
'#title' => $this->t('Preview'),
'#markup' => drupal_render($preview_arguments),
// Render preview above parent elements.
'#weight' => -5,
- );
+ ];
// Build the list of existing image effects for this image style.
- $form['effects'] = array(
+ $form['effects'] = [
'#type' => 'table',
- '#header' => array(
+ '#header' => [
$this->t('Effect'),
$this->t('Weight'),
$this->t('Operations'),
- ),
- '#tabledrag' => array(
- array(
+ ],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'image-effect-order-weight',
- ),
- ),
- '#attributes' => array(
+ ],
+ ],
+ '#attributes' => [
'id' => 'image-style-effects',
- ),
+ ],
'#empty' => t('There are currently no effects in this style. Add one by selecting an option below.'),
// Render effects below parent elements.
'#weight' => 5,
- );
+ ];
foreach ($this->entity->getEffects() as $effect) {
$key = $effect->getUuid();
$form['effects'][$key]['#attributes']['class'][] = 'draggable';
$form['effects'][$key]['#weight'] = isset($user_input['effects']) ? $user_input['effects'][$key]['weight'] : NULL;
- $form['effects'][$key]['effect'] = array(
+ $form['effects'][$key]['effect'] = [
'#tree' => FALSE,
- 'data' => array(
- 'label' => array(
+ 'data' => [
+ 'label' => [
'#plain_text' => $effect->label(),
- ),
- ),
- );
+ ],
+ ],
+ ];
$summary = $effect->getSummary();
@@ -105,42 +105,42 @@ class ImageStyleEditForm extends ImageStyleFormBase {
$form['effects'][$key]['effect']['data']['summary'] = $summary;
}
- $form['effects'][$key]['weight'] = array(
+ $form['effects'][$key]['weight'] = [
'#type' => 'weight',
- '#title' => $this->t('Weight for @title', array('@title' => $effect->label())),
+ '#title' => $this->t('Weight for @title', ['@title' => $effect->label()]),
'#title_display' => 'invisible',
'#default_value' => $effect->getWeight(),
- '#attributes' => array(
- 'class' => array('image-effect-order-weight'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['image-effect-order-weight'],
+ ],
+ ];
- $links = array();
+ $links = [];
$is_configurable = $effect instanceof ConfigurableImageEffectInterface;
if ($is_configurable) {
- $links['edit'] = array(
+ $links['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute('image.effect_edit_form', [
'image_style' => $this->entity->id(),
'image_effect' => $key,
]),
- );
+ ];
}
- $links['delete'] = array(
+ $links['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('image.effect_delete', [
'image_style' => $this->entity->id(),
'image_effect' => $key,
]),
- );
- $form['effects'][$key]['operations'] = array(
+ ];
+ $form['effects'][$key]['operations'] = [
'#type' => 'operations',
'#links' => $links,
- );
+ ];
}
// Build the new image effect addition form and add it to the effect list.
- $new_effect_options = array();
+ $new_effect_options = [];
$effects = $this->imageEffectManager->getDefinitions();
uasort($effects, function ($a, $b) {
return strcasecmp($a['id'], $b['id']);
@@ -148,43 +148,43 @@ class ImageStyleEditForm extends ImageStyleFormBase {
foreach ($effects as $effect => $definition) {
$new_effect_options[$effect] = $definition['label'];
}
- $form['effects']['new'] = array(
+ $form['effects']['new'] = [
'#tree' => FALSE,
'#weight' => isset($user_input['weight']) ? $user_input['weight'] : NULL,
- '#attributes' => array('class' => array('draggable')),
- );
- $form['effects']['new']['effect'] = array(
- 'data' => array(
- 'new' => array(
+ '#attributes' => ['class' => ['draggable']],
+ ];
+ $form['effects']['new']['effect'] = [
+ 'data' => [
+ 'new' => [
'#type' => 'select',
'#title' => $this->t('Effect'),
'#title_display' => 'invisible',
'#options' => $new_effect_options,
'#empty_option' => $this->t('Select a new effect'),
- ),
- array(
- 'add' => array(
+ ],
+ [
+ 'add' => [
'#type' => 'submit',
'#value' => $this->t('Add'),
- '#validate' => array('::effectValidate'),
- '#submit' => array('::submitForm', '::effectSave'),
- ),
- ),
- ),
+ '#validate' => ['::effectValidate'],
+ '#submit' => ['::submitForm', '::effectSave'],
+ ],
+ ],
+ ],
'#prefix' => '<div class="image-style-new">',
'#suffix' => '</div>',
- );
+ ];
- $form['effects']['new']['weight'] = array(
+ $form['effects']['new']['weight'] = [
'#type' => 'weight',
'#title' => $this->t('Weight for new effect'),
'#title_display' => 'invisible',
'#default_value' => count($this->entity->getEffects()) + 1,
- '#attributes' => array('class' => array('image-effect-order-weight')),
- );
- $form['effects']['new']['operations'] = array(
- 'data' => array(),
- );
+ '#attributes' => ['class' => ['image-effect-order-weight']],
+ ];
+ $form['effects']['new']['operations'] = [
+ 'data' => [],
+ ];
return parent::form($form, $form_state);
}
@@ -211,20 +211,20 @@ class ImageStyleEditForm extends ImageStyleFormBase {
if (is_subclass_of($effect['class'], '\Drupal\image\ConfigurableImageEffectInterface')) {
$form_state->setRedirect(
'image.effect_add_form',
- array(
+ [
'image_style' => $this->entity->id(),
'image_effect' => $form_state->getValue('new'),
- ),
- array('query' => array('weight' => $form_state->getValue('weight')))
+ ],
+ ['query' => ['weight' => $form_state->getValue('weight')]]
);
}
// If there's no form, immediately add the image effect.
else {
- $effect = array(
+ $effect = [
'id' => $effect['id'],
- 'data' => array(),
+ 'data' => [],
'weight' => $form_state->getValue('weight'),
- );
+ ];
$effect_id = $this->entity->addImageEffect($effect);
$this->entity->save();
if (!empty($effect_id)) {
diff --git a/core/modules/image/src/Form/ImageStyleFlushForm.php b/core/modules/image/src/Form/ImageStyleFlushForm.php
index 5d4b2dc29a9..1326f888f67 100644
--- a/core/modules/image/src/Form/ImageStyleFlushForm.php
+++ b/core/modules/image/src/Form/ImageStyleFlushForm.php
@@ -14,7 +14,7 @@ class ImageStyleFlushForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to apply the updated %name image effect to all images?', array('%name' => $this->entity->label()));
+ return $this->t('Are you sure you want to apply the updated %name image effect to all images?', ['%name' => $this->entity->label()]);
}
/**
@@ -43,7 +43,7 @@ class ImageStyleFlushForm extends EntityConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->flush();
- drupal_set_message($this->t('The image style %name has been flushed.', array('%name' => $this->entity->label())));
+ drupal_set_message($this->t('The image style %name has been flushed.', ['%name' => $this->entity->label()]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/core/modules/image/src/Form/ImageStyleFormBase.php b/core/modules/image/src/Form/ImageStyleFormBase.php
index dfdcca4b953..bf3210a1d8e 100644
--- a/core/modules/image/src/Form/ImageStyleFormBase.php
+++ b/core/modules/image/src/Form/ImageStyleFormBase.php
@@ -50,20 +50,20 @@ abstract class ImageStyleFormBase extends EntityForm {
*/
public function form(array $form, FormStateInterface $form_state) {
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Image style name'),
'#default_value' => $this->entity->label(),
'#required' => TRUE,
- );
- $form['name'] = array(
+ ];
+ $form['name'] = [
'#type' => 'machine_name',
- '#machine_name' => array(
- 'exists' => array($this->imageStyleStorage, 'load'),
- ),
+ '#machine_name' => [
+ 'exists' => [$this->imageStyleStorage, 'load'],
+ ],
'#default_value' => $this->entity->id(),
'#required' => TRUE,
- );
+ ];
return parent::form($form, $form_state);
}
diff --git a/core/modules/image/src/ImageEffectBase.php b/core/modules/image/src/ImageEffectBase.php
index 8e0d9c2812d..58be370c1e6 100644
--- a/core/modules/image/src/ImageEffectBase.php
+++ b/core/modules/image/src/ImageEffectBase.php
@@ -85,14 +85,14 @@ abstract class ImageEffectBase extends PluginBase implements ImageEffectInterfac
* {@inheritdoc}
*/
public function getSummary() {
- return array(
+ return [
'#markup' => '',
- '#effect' => array(
+ '#effect' => [
'id' => $this->pluginDefinition['id'],
'label' => $this->label(),
'description' => $this->pluginDefinition['description'],
- ),
- );
+ ],
+ ];
}
/**
@@ -128,23 +128,23 @@ abstract class ImageEffectBase extends PluginBase implements ImageEffectInterfac
* {@inheritdoc}
*/
public function getConfiguration() {
- return array(
+ return [
'uuid' => $this->getUuid(),
'id' => $this->getPluginId(),
'weight' => $this->getWeight(),
'data' => $this->configuration,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
- $configuration += array(
- 'data' => array(),
+ $configuration += [
+ 'data' => [],
'uuid' => '',
'weight' => '',
- );
+ ];
$this->configuration = $configuration['data'] + $this->defaultConfiguration();
$this->uuid = $configuration['uuid'];
$this->weight = $configuration['weight'];
@@ -155,14 +155,14 @@ abstract class ImageEffectBase extends PluginBase implements ImageEffectInterfac
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
}
diff --git a/core/modules/image/src/ImageStyleListBuilder.php b/core/modules/image/src/ImageStyleListBuilder.php
index 140ed46b8cb..62651cd2f82 100644
--- a/core/modules/image/src/ImageStyleListBuilder.php
+++ b/core/modules/image/src/ImageStyleListBuilder.php
@@ -33,15 +33,15 @@ class ImageStyleListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function getDefaultOperations(EntityInterface $entity) {
- $flush = array(
+ $flush = [
'title' => t('Flush'),
'weight' => 200,
'url' => $entity->urlInfo('flush-form'),
- );
+ ];
- return parent::getDefaultOperations($entity) + array(
+ return parent::getDefaultOperations($entity) + [
'flush' => $flush,
- );
+ ];
}
/**
diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
index b24c6972685..a00d9e27f0c 100644
--- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
@@ -93,10 +93,10 @@ class ImageFormatter extends ImageFormatterBase implements ContainerFactoryPlugi
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'image_style' => '',
'image_link' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -118,17 +118,17 @@ class ImageFormatter extends ImageFormatterBase implements ContainerFactoryPlugi
'#access' => $this->currentUser->hasPermission('administer image styles')
],
];
- $link_types = array(
+ $link_types = [
'content' => t('Content'),
'file' => t('File'),
- );
- $element['image_link'] = array(
+ ];
+ $element['image_link'] = [
'#title' => t('Link image to'),
'#type' => 'select',
'#default_value' => $this->getSetting('image_link'),
'#empty_option' => t('Nothing'),
'#options' => $link_types,
- );
+ ];
return $element;
}
@@ -137,7 +137,7 @@ class ImageFormatter extends ImageFormatterBase implements ContainerFactoryPlugi
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$image_styles = image_style_options(FALSE);
// Unset possible 'No defined styles' option.
@@ -146,16 +146,16 @@ class ImageFormatter extends ImageFormatterBase implements ContainerFactoryPlugi
// their styles in code.
$image_style_setting = $this->getSetting('image_style');
if (isset($image_styles[$image_style_setting])) {
- $summary[] = t('Image style: @style', array('@style' => $image_styles[$image_style_setting]));
+ $summary[] = t('Image style: @style', ['@style' => $image_styles[$image_style_setting]]);
}
else {
$summary[] = t('Original image');
}
- $link_types = array(
+ $link_types = [
'content' => t('Linked to content'),
'file' => t('Linked to file'),
- );
+ ];
// Display this setting only if image is linked.
$image_link_setting = $this->getSetting('image_link');
if (isset($link_types[$image_link_setting])) {
@@ -169,7 +169,7 @@ class ImageFormatter extends ImageFormatterBase implements ContainerFactoryPlugi
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
$files = $this->getEntitiesToView($items, $langcode);
// Early opt-out if the field is empty.
@@ -219,17 +219,17 @@ class ImageFormatter extends ImageFormatterBase implements ContainerFactoryPlugi
$item_attributes = $item->_attributes;
unset($item->_attributes);
- $elements[$delta] = array(
+ $elements[$delta] = [
'#theme' => 'image_formatter',
'#item' => $item,
'#item_attributes' => $item_attributes,
'#image_style' => $image_style_setting,
'#url' => $url,
- '#cache' => array(
+ '#cache' => [
'tags' => $cache_tags,
'contexts' => $cache_contexts,
- ),
- );
+ ],
+ ];
}
return $elements;
diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php
index 19b89b13db0..335868ab6f6 100644
--- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php
+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatterBase.php
@@ -28,7 +28,7 @@ abstract class ImageFormatterBase extends FileFormatterBase {
// so that the fallback image can be rendered without affecting the
// field values in the entity being rendered.
$items = clone $items;
- $items->setValue(array(
+ $items->setValue([
'target_id' => $file->id(),
'alt' => $default_image['alt'],
'title' => $default_image['title'],
@@ -37,7 +37,7 @@ abstract class ImageFormatterBase extends FileFormatterBase {
'entity' => $file,
'_loaded' => TRUE,
'_is_default' => TRUE,
- ));
+ ]);
$file->_referringItem = $items[0];
}
}
diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
index d9011a850f2..7b8b2752165 100644
--- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
+++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
@@ -55,22 +55,22 @@ class ImageItem extends FileItem {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
- 'default_image' => array(
+ return [
+ 'default_image' => [
'uuid' => NULL,
'alt' => '',
'title' => '',
'width' => NULL,
'height' => NULL,
- ),
- ) + parent::defaultStorageSettings();
+ ],
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- $settings = array(
+ $settings = [
'file_extensions' => 'png gif jpg jpeg',
'alt_field' => 1,
'alt_field_required' => 1,
@@ -78,14 +78,14 @@ class ImageItem extends FileItem {
'title_field_required' => 0,
'max_resolution' => '',
'min_resolution' => '',
- 'default_image' => array(
+ 'default_image' => [
'uuid' => NULL,
'alt' => '',
'title' => '',
'width' => NULL,
'height' => NULL,
- ),
- ) + parent::defaultFieldSettings();
+ ],
+ ] + parent::defaultFieldSettings();
unset($settings['description_field']);
return $settings;
@@ -95,44 +95,44 @@ class ImageItem extends FileItem {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'target_id' => array(
+ return [
+ 'columns' => [
+ 'target_id' => [
'description' => 'The ID of the file entity.',
'type' => 'int',
'unsigned' => TRUE,
- ),
- 'alt' => array(
+ ],
+ 'alt' => [
'description' => "Alternative image text, for the image's 'alt' attribute.",
'type' => 'varchar',
'length' => 512,
- ),
- 'title' => array(
+ ],
+ 'title' => [
'description' => "Image title text, for the image's 'title' attribute.",
'type' => 'varchar',
'length' => 1024,
- ),
- 'width' => array(
+ ],
+ 'width' => [
'description' => 'The width of the image in pixels.',
'type' => 'int',
'unsigned' => TRUE,
- ),
- 'height' => array(
+ ],
+ 'height' => [
'description' => 'The height of the image in pixels.',
'type' => 'int',
'unsigned' => TRUE,
- ),
- ),
- 'indexes' => array(
- 'target_id' => array('target_id'),
- ),
- 'foreign keys' => array(
- 'target_id' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'target_id' => ['target_id'],
+ ],
+ 'foreign keys' => [
+ 'target_id' => [
'table' => 'file_managed',
- 'columns' => array('target_id' => 'fid'),
- ),
- ),
- );
+ 'columns' => ['target_id' => 'fid'],
+ ],
+ ],
+ ];
}
/**
@@ -167,7 +167,7 @@ class ImageItem extends FileItem {
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element = array();
+ $element = [];
// We need the field-level 'default_image' setting, and $this->getSettings()
// will only provide the instance-level one, so we need to explicitly fetch
@@ -175,13 +175,13 @@ class ImageItem extends FileItem {
$settings = $this->getFieldDefinition()->getFieldStorageDefinition()->getSettings();
$scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE);
- $element['uri_scheme'] = array(
+ $element['uri_scheme'] = [
'#type' => 'radios',
'#title' => t('Upload destination'),
'#options' => $scheme_options,
'#default_value' => $settings['uri_scheme'],
'#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
- );
+ ];
// Add default_image element.
static::defaultImageForm($element, $settings);
@@ -200,101 +200,101 @@ class ImageItem extends FileItem {
$settings = $this->getSettings();
// Add maximum and minimum resolution settings.
- $max_resolution = explode('x', $settings['max_resolution']) + array('', '');
- $element['max_resolution'] = array(
+ $max_resolution = explode('x', $settings['max_resolution']) + ['', ''];
+ $element['max_resolution'] = [
'#type' => 'item',
'#title' => t('Maximum image resolution'),
- '#element_validate' => array(array(get_class($this), 'validateResolution')),
+ '#element_validate' => [[get_class($this), 'validateResolution']],
'#weight' => 4.1,
'#field_prefix' => '<div class="container-inline">',
'#field_suffix' => '</div>',
'#description' => t('The maximum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height. Resizing images on upload will cause the loss of <a href="http://wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image.'),
- );
- $element['max_resolution']['x'] = array(
+ ];
+ $element['max_resolution']['x'] = [
'#type' => 'number',
'#title' => t('Maximum width'),
'#title_display' => 'invisible',
'#default_value' => $max_resolution[0],
'#min' => 1,
'#field_suffix' => ' × ',
- );
- $element['max_resolution']['y'] = array(
+ ];
+ $element['max_resolution']['y'] = [
'#type' => 'number',
'#title' => t('Maximum height'),
'#title_display' => 'invisible',
'#default_value' => $max_resolution[1],
'#min' => 1,
'#field_suffix' => ' ' . t('pixels'),
- );
+ ];
- $min_resolution = explode('x', $settings['min_resolution']) + array('', '');
- $element['min_resolution'] = array(
+ $min_resolution = explode('x', $settings['min_resolution']) + ['', ''];
+ $element['min_resolution'] = [
'#type' => 'item',
'#title' => t('Minimum image resolution'),
- '#element_validate' => array(array(get_class($this), 'validateResolution')),
+ '#element_validate' => [[get_class($this), 'validateResolution']],
'#weight' => 4.2,
'#field_prefix' => '<div class="container-inline">',
'#field_suffix' => '</div>',
'#description' => t('The minimum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a smaller image is uploaded, it will be rejected.'),
- );
- $element['min_resolution']['x'] = array(
+ ];
+ $element['min_resolution']['x'] = [
'#type' => 'number',
'#title' => t('Minimum width'),
'#title_display' => 'invisible',
'#default_value' => $min_resolution[0],
'#min' => 1,
'#field_suffix' => ' × ',
- );
- $element['min_resolution']['y'] = array(
+ ];
+ $element['min_resolution']['y'] = [
'#type' => 'number',
'#title' => t('Minimum height'),
'#title_display' => 'invisible',
'#default_value' => $min_resolution[1],
'#min' => 1,
'#field_suffix' => ' ' . t('pixels'),
- );
+ ];
// Remove the description option.
unset($element['description_field']);
// Add title and alt configuration options.
- $element['alt_field'] = array(
+ $element['alt_field'] = [
'#type' => 'checkbox',
'#title' => t('Enable <em>Alt</em> field'),
'#default_value' => $settings['alt_field'],
'#description' => t('The alt attribute may be used by search engines, screen readers, and when the image cannot be loaded. Enabling this field is recommended.'),
'#weight' => 9,
- );
- $element['alt_field_required'] = array(
+ ];
+ $element['alt_field_required'] = [
'#type' => 'checkbox',
'#title' => t('<em>Alt</em> field required'),
'#default_value' => $settings['alt_field_required'],
'#description' => t('Making this field required is recommended.'),
'#weight' => 10,
- '#states' => array(
- 'visible' => array(
- ':input[name="settings[alt_field]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $element['title_field'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="settings[alt_field]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $element['title_field'] = [
'#type' => 'checkbox',
'#title' => t('Enable <em>Title</em> field'),
'#default_value' => $settings['title_field'],
'#description' => t('The title attribute is used as a tooltip when the mouse hovers over the image. Enabling this field is not recommended as it can cause problems with screen readers.'),
'#weight' => 11,
- );
- $element['title_field_required'] = array(
+ ];
+ $element['title_field_required'] = [
'#type' => 'checkbox',
'#title' => t('<em>Title</em> field required'),
'#default_value' => $settings['title_field_required'],
'#weight' => 12,
- '#states' => array(
- 'visible' => array(
- ':input[name="settings[title_field]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="settings[title_field]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
// Add default_image element.
static::defaultImageForm($element, $settings);
@@ -328,11 +328,11 @@ class ImageItem extends FileItem {
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$random = new Random();
$settings = $field_definition->getSettings();
- static $images = array();
+ static $images = [];
$min_resolution = empty($settings['min_resolution']) ? '100x100' : $settings['min_resolution'];
$max_resolution = empty($settings['max_resolution']) ? '600x600' : $settings['max_resolution'];
- $extensions = array_intersect(explode(' ', $settings['file_extensions']), array('png', 'gif', 'jpg', 'jpeg'));
+ $extensions = array_intersect(explode(' ', $settings['file_extensions']), ['png', 'gif', 'jpg', 'jpeg']);
$extension = array_rand(array_combine($extensions, $extensions));
// Generate a max of 5 different images.
if (!isset($images[$extension][$min_resolution][$max_resolution]) || count($images[$extension][$min_resolution][$max_resolution]) <= 5) {
@@ -352,7 +352,7 @@ class ImageItem extends FileItem {
$images[$extension][$min_resolution][$max_resolution][$file->id()] = $file;
}
else {
- return array();
+ return [];
}
}
else {
@@ -362,13 +362,13 @@ class ImageItem extends FileItem {
}
list($width, $height) = getimagesize($file->getFileUri());
- $values = array(
+ $values = [
'target_id' => $file->id(),
'alt' => $random->sentences(4),
'title' => $random->sentences(4),
'width' => $width,
'height' => $height,
- );
+ ];
return $values;
}
@@ -377,11 +377,11 @@ class ImageItem extends FileItem {
*/
public static function validateResolution($element, FormStateInterface $form_state) {
if (!empty($element['x']['#value']) || !empty($element['y']['#value'])) {
- foreach (array('x', 'y') as $dimension) {
+ foreach (['x', 'y'] as $dimension) {
if (!$element[$dimension]['#value']) {
// We expect the field name placeholder value to be wrapped in t()
// here, so it won't be escaped again as it's already marked safe.
- $form_state->setError($element[$dimension], t('Both a height and width value must be specified in the @name field.', array('@name' => $element['#title'])));
+ $form_state->setError($element[$dimension], t('Both a height and width value must be specified in the @name field.', ['@name' => $element['#title']]));
return;
}
}
@@ -401,51 +401,51 @@ class ImageItem extends FileItem {
* The field settings array.
*/
protected function defaultImageForm(array &$element, array $settings) {
- $element['default_image'] = array(
+ $element['default_image'] = [
'#type' => 'details',
'#title' => t('Default image'),
'#open' => TRUE,
- );
+ ];
// Convert the stored UUID to a FID.
$fids = [];
$uuid = $settings['default_image']['uuid'];
if ($uuid && ($file = $this->getEntityManager()->loadEntityByUuid('file', $uuid))) {
$fids[0] = $file->id();
}
- $element['default_image']['uuid'] = array(
+ $element['default_image']['uuid'] = [
'#type' => 'managed_file',
'#title' => t('Image'),
'#description' => t('Image to be shown if no image is uploaded.'),
'#default_value' => $fids,
'#upload_location' => $settings['uri_scheme'] . '://default_images/',
- '#element_validate' => array(
+ '#element_validate' => [
'\Drupal\file\Element\ManagedFile::validateManagedFile',
- array(get_class($this), 'validateDefaultImageForm'),
- ),
+ [get_class($this), 'validateDefaultImageForm'],
+ ],
'#upload_validators' => $this->getUploadValidators(),
- );
- $element['default_image']['alt'] = array(
+ ];
+ $element['default_image']['alt'] = [
'#type' => 'textfield',
'#title' => t('Alternative text'),
'#description' => t('This text will be used by screen readers, search engines, and when the image cannot be loaded.'),
'#default_value' => $settings['default_image']['alt'],
'#maxlength' => 512,
- );
- $element['default_image']['title'] = array(
+ ];
+ $element['default_image']['title'] = [
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('The title attribute is used as a tooltip when the mouse hovers over the image.'),
'#default_value' => $settings['default_image']['title'],
'#maxlength' => 1024,
- );
- $element['default_image']['width'] = array(
+ ];
+ $element['default_image']['width'] = [
'#type' => 'value',
'#value' => $settings['default_image']['width'],
- );
- $element['default_image']['height'] = array(
+ ];
+ $element['default_image']['height'] = [
'#type' => 'value',
'#value' => $settings['default_image']['height'],
- );
+ ];
}
/**
diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
index f881419c0ed..735cfceebc4 100644
--- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -26,10 +26,10 @@ class ImageWidget extends FileWidget {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'progress_indicator' => 'throbber',
'preview_image_style' => 'thumbnail',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -38,7 +38,7 @@ class ImageWidget extends FileWidget {
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
- $element['preview_image_style'] = array(
+ $element['preview_image_style'] = [
'#title' => t('Preview image style'),
'#type' => 'select',
'#options' => image_style_options(FALSE),
@@ -46,7 +46,7 @@ class ImageWidget extends FileWidget {
'#default_value' => $this->getSetting('preview_image_style'),
'#description' => t('The preview image will be shown while editing the content.'),
'#weight' => 15,
- );
+ ];
return $element;
}
@@ -64,7 +64,7 @@ class ImageWidget extends FileWidget {
// their styles in code.
$image_style_setting = $this->getSetting('preview_image_style');
if (isset($image_styles[$image_style_setting])) {
- $preview_image_style = t('Preview image style: @style', array('@style' => $image_styles[$image_style_setting]));
+ $preview_image_style = t('Preview image style: @style', ['@style' => $image_styles[$image_style_setting]]);
}
else {
$preview_image_style = t('No preview');
@@ -84,12 +84,12 @@ class ImageWidget extends FileWidget {
$elements = parent::formMultipleElements($items, $form, $form_state);
$cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
- $file_upload_help = array(
+ $file_upload_help = [
'#theme' => 'file_upload_help',
'#description' => '',
'#upload_validators' => $elements[0]['#upload_validators'],
'#cardinality' => $cardinality,
- );
+ ];
if ($cardinality == 1) {
// If there's only one field, return it as delta 0.
if (empty($elements[0]['#default_value']['fids'])) {
@@ -114,11 +114,11 @@ class ImageWidget extends FileWidget {
// Add upload resolution validation.
if ($field_settings['max_resolution'] || $field_settings['min_resolution']) {
- $element['#upload_validators']['file_validate_image_resolution'] = array($field_settings['max_resolution'], $field_settings['min_resolution']);
+ $element['#upload_validators']['file_validate_image_resolution'] = [$field_settings['max_resolution'], $field_settings['min_resolution']];
}
// If not using custom extension validation, ensure this is an image.
- $supported_extensions = array('png', 'gif', 'jpg', 'jpeg');
+ $supported_extensions = ['png', 'gif', 'jpg', 'jpeg'];
$extensions = isset($element['#upload_validators']['file_validate_extensions'][0]) ? $element['#upload_validators']['file_validate_extensions'][0] : implode(' ', $supported_extensions);
$extensions = array_intersect(explode(' ', $extensions), $supported_extensions);
$element['#upload_validators']['file_validate_extensions'][0] = implode(' ', $extensions);
@@ -142,7 +142,7 @@ class ImageWidget extends FileWidget {
if (!empty($default_image['uuid']) && $entity = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid'])) {
$default_image['fid'] = $entity->id();
}
- $element['#default_image'] = !empty($default_image['fid']) ? $default_image : array();
+ $element['#default_image'] = !empty($default_image['fid']) ? $default_image : [];
return $element;
}
@@ -163,10 +163,10 @@ class ImageWidget extends FileWidget {
// Add the image preview.
if (!empty($element['#files']) && $element['#preview_image_style']) {
$file = reset($element['#files']);
- $variables = array(
+ $variables = [
'style_name' => $element['#preview_image_style'],
'uri' => $file->getFileUri(),
- );
+ ];
// Determine image dimensions.
if (isset($element['#value']['width']) && isset($element['#value']['height'])) {
@@ -184,43 +184,43 @@ class ImageWidget extends FileWidget {
}
}
- $element['preview'] = array(
+ $element['preview'] = [
'#weight' => -10,
'#theme' => 'image_style',
'#width' => $variables['width'],
'#height' => $variables['height'],
'#style_name' => $variables['style_name'],
'#uri' => $variables['uri'],
- );
+ ];
// Store the dimensions in the form so the file doesn't have to be
// accessed again. This is important for remote files.
- $element['width'] = array(
+ $element['width'] = [
'#type' => 'hidden',
'#value' => $variables['width'],
- );
- $element['height'] = array(
+ ];
+ $element['height'] = [
'#type' => 'hidden',
'#value' => $variables['height'],
- );
+ ];
}
elseif (!empty($element['#default_image'])) {
$default_image = $element['#default_image'];
$file = File::load($default_image['fid']);
if (!empty($file)) {
- $element['preview'] = array(
+ $element['preview'] = [
'#weight' => -10,
'#theme' => 'image_style',
'#width' => $default_image['width'],
'#height' => $default_image['height'],
'#style_name' => $element['#preview_image_style'],
'#uri' => $file->getFileUri(),
- );
+ ];
}
}
// Add the additional alt and title fields.
- $element['alt'] = array(
+ $element['alt'] = [
'#title' => t('Alternative text'),
'#type' => 'textfield',
'#default_value' => isset($item['alt']) ? $item['alt'] : '',
@@ -230,9 +230,9 @@ class ImageWidget extends FileWidget {
'#weight' => -12,
'#access' => (bool) $item['fids'] && $element['#alt_field'],
'#required' => $element['#alt_field_required'],
- '#element_validate' => $element['#alt_field_required'] == 1 ? array(array(get_called_class(), 'validateRequiredFields')) : array(),
- );
- $element['title'] = array(
+ '#element_validate' => $element['#alt_field_required'] == 1 ? [[get_called_class(), 'validateRequiredFields']] : [],
+ ];
+ $element['title'] = [
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => isset($item['title']) ? $item['title'] : '',
@@ -241,8 +241,8 @@ class ImageWidget extends FileWidget {
'#weight' => -11,
'#access' => (bool) $item['fids'] && $element['#title_field'],
'#required' => $element['#title_field_required'],
- '#element_validate' => $element['#title_field_required'] == 1 ? array(array(get_called_class(), 'validateRequiredFields')) : array(),
- );
+ '#element_validate' => $element['#title_field_required'] == 1 ? [[get_called_class(), 'validateRequiredFields']] : [],
+ ];
return parent::process($element, $form_state, $form);
}
diff --git a/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php
index a462b6705ea..28d51792c81 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php
@@ -23,7 +23,7 @@ class ConvertImageEffect extends ConfigurableImageEffectBase {
*/
public function applyEffect(ImageInterface $image) {
if (!$image->convert($this->configuration['extension'])) {
- $this->logger->error('Image convert failed using the %toolkit toolkit on %path (%mimetype)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType()));
+ $this->logger->error('Image convert failed using the %toolkit toolkit on %path (%mimetype)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType()]);
return FALSE;
}
return TRUE;
@@ -40,9 +40,9 @@ class ConvertImageEffect extends ConfigurableImageEffectBase {
* {@inheritdoc}
*/
public function getSummary() {
- $summary = array(
+ $summary = [
'#markup' => Unicode::strtoupper($this->configuration['extension']),
- );
+ ];
$summary += parent::getSummary();
return $summary;
@@ -52,9 +52,9 @@ class ConvertImageEffect extends ConfigurableImageEffectBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'extension' => NULL,
- );
+ ];
}
/**
@@ -64,15 +64,15 @@ class ConvertImageEffect extends ConfigurableImageEffectBase {
$extensions = \Drupal::service('image.toolkit.manager')->getDefaultToolkit()->getSupportedExtensions();
$options = array_combine(
$extensions,
- array_map(array('\Drupal\Component\Utility\Unicode', 'strtoupper'), $extensions)
+ array_map(['\Drupal\Component\Utility\Unicode', 'strtoupper'], $extensions)
);
- $form['extension'] = array(
+ $form['extension'] = [
'#type' => 'select',
'#title' => t('Extension'),
'#default_value' => $this->configuration['extension'],
'#required' => TRUE,
'#options' => $options,
- );
+ ];
return $form;
}
diff --git a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php
index 3f15a0e8479..87536e643d3 100644
--- a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php
@@ -24,7 +24,7 @@ class CropImageEffect extends ResizeImageEffect {
$x = image_filter_keyword($x, $image->getWidth(), $this->configuration['width']);
$y = image_filter_keyword($y, $image->getHeight(), $this->configuration['height']);
if (!$image->crop($x, $y, $this->configuration['width'], $this->configuration['height'])) {
- $this->logger->error('Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()));
+ $this->logger->error('Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
return FALSE;
}
return TRUE;
@@ -34,10 +34,10 @@ class CropImageEffect extends ResizeImageEffect {
* {@inheritdoc}
*/
public function getSummary() {
- $summary = array(
+ $summary = [
'#theme' => 'image_crop_summary',
'#data' => $this->configuration,
- );
+ ];
$summary += parent::getSummary();
return $summary;
@@ -47,9 +47,9 @@ class CropImageEffect extends ResizeImageEffect {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return parent::defaultConfiguration() + array(
+ return parent::defaultConfiguration() + [
'anchor' => 'center-center',
- );
+ ];
}
/**
@@ -57,10 +57,10 @@ class CropImageEffect extends ResizeImageEffect {
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
- $form['anchor'] = array(
+ $form['anchor'] = [
'#type' => 'radios',
'#title' => t('Anchor'),
- '#options' => array(
+ '#options' => [
'left-top' => t('Top left'),
'center-top' => t('Top center'),
'right-top' => t('Top right'),
@@ -70,11 +70,11 @@ class CropImageEffect extends ResizeImageEffect {
'left-bottom' => t('Bottom left'),
'center-bottom' => t('Bottom center'),
'right-bottom' => t('Bottom right'),
- ),
+ ],
'#theme' => 'image_anchor',
'#default_value' => $this->configuration['anchor'],
'#description' => t('The part of the image that will be retained during the crop.'),
- );
+ ];
return $form;
}
diff --git a/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php
index 26afce3695b..d34161ecc59 100644
--- a/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php
@@ -21,7 +21,7 @@ class DesaturateImageEffect extends ImageEffectBase {
*/
public function applyEffect(ImageInterface $image) {
if (!$image->desaturate()) {
- $this->logger->error('Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()));
+ $this->logger->error('Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php
index 04a59d6bee7..dba34298def 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php
@@ -22,7 +22,7 @@ class ResizeImageEffect extends ConfigurableImageEffectBase {
*/
public function applyEffect(ImageInterface $image) {
if (!$image->resize($this->configuration['width'], $this->configuration['height'])) {
- $this->logger->error('Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()));
+ $this->logger->error('Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
return FALSE;
}
return TRUE;
@@ -41,10 +41,10 @@ class ResizeImageEffect extends ConfigurableImageEffectBase {
* {@inheritdoc}
*/
public function getSummary() {
- $summary = array(
+ $summary = [
'#theme' => 'image_resize_summary',
'#data' => $this->configuration,
- );
+ ];
$summary += parent::getSummary();
return $summary;
@@ -54,32 +54,32 @@ class ResizeImageEffect extends ConfigurableImageEffectBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'width' => NULL,
'height' => NULL,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['width'] = array(
+ $form['width'] = [
'#type' => 'number',
'#title' => t('Width'),
'#default_value' => $this->configuration['width'],
'#field_suffix' => ' ' . t('pixels'),
'#required' => TRUE,
'#min' => 1,
- );
- $form['height'] = array(
+ ];
+ $form['height'] = [
'#type' => 'number',
'#title' => t('Height'),
'#default_value' => $this->configuration['height'],
'#field_suffix' => ' ' . t('pixels'),
'#required' => TRUE,
'#min' => 1,
- );
+ ];
return $form;
}
diff --git a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
index df2da77c9a1..7e394a3cce6 100644
--- a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
@@ -29,7 +29,7 @@ class RotateImageEffect extends ConfigurableImageEffectBase {
}
if (!$image->rotate($this->configuration['degrees'], $this->configuration['bgcolor'])) {
- $this->logger->error('Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()));
+ $this->logger->error('Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
return FALSE;
}
return TRUE;
@@ -56,10 +56,10 @@ class RotateImageEffect extends ConfigurableImageEffectBase {
* {@inheritdoc}
*/
public function getSummary() {
- $summary = array(
+ $summary = [
'#theme' => 'image_rotate_summary',
'#data' => $this->configuration,
- );
+ ];
$summary += parent::getSummary();
return $summary;
@@ -69,39 +69,39 @@ class RotateImageEffect extends ConfigurableImageEffectBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'degrees' => 0,
'bgcolor' => NULL,
'random' => FALSE,
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['degrees'] = array(
+ $form['degrees'] = [
'#type' => 'number',
'#default_value' => $this->configuration['degrees'],
'#title' => t('Rotation angle'),
'#description' => t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative are counter-clockwise.'),
'#field_suffix' => '°',
'#required' => TRUE,
- );
- $form['bgcolor'] = array(
+ ];
+ $form['bgcolor'] = [
'#type' => 'textfield',
'#default_value' => $this->configuration['bgcolor'],
'#title' => t('Background color'),
'#description' => t('The background color to use for exposed areas of the image. Use web-style hex colors (#FFFFFF for white, #000000 for black). Leave blank for transparency on image types that support it.'),
'#size' => 7,
'#maxlength' => 7,
- );
- $form['random'] = array(
+ ];
+ $form['random'] = [
'#type' => 'checkbox',
'#default_value' => $this->configuration['random'],
'#title' => t('Randomize'),
'#description' => t('Randomize the rotation angle for each image. The angle specified above is used as a maximum.'),
- );
+ ];
return $form;
}
diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php
index f2ab32329d5..57ea0b2c8cb 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php
@@ -20,7 +20,7 @@ class ScaleAndCropImageEffect extends ResizeImageEffect {
*/
public function applyEffect(ImageInterface $image) {
if (!$image->scaleAndCrop($this->configuration['width'], $this->configuration['height'])) {
- $this->logger->error('Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()));
+ $this->logger->error('Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
return FALSE;
}
return TRUE;
diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
index a035df68700..bfb6d942fb9 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
@@ -22,7 +22,7 @@ class ScaleImageEffect extends ResizeImageEffect {
*/
public function applyEffect(ImageInterface $image) {
if (!$image->scale($this->configuration['width'], $this->configuration['height'], $this->configuration['upscale'])) {
- $this->logger->error('Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()));
+ $this->logger->error('Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
return FALSE;
}
return TRUE;
@@ -41,10 +41,10 @@ class ScaleImageEffect extends ResizeImageEffect {
* {@inheritdoc}
*/
public function getSummary() {
- $summary = array(
+ $summary = [
'#theme' => 'image_scale_summary',
'#data' => $this->configuration,
- );
+ ];
$summary += parent::getSummary();
return $summary;
@@ -54,9 +54,9 @@ class ScaleImageEffect extends ResizeImageEffect {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return parent::defaultConfiguration() + array(
+ return parent::defaultConfiguration() + [
'upscale' => FALSE,
- );
+ ];
}
/**
@@ -66,12 +66,12 @@ class ScaleImageEffect extends ResizeImageEffect {
$form = parent::buildConfigurationForm($form, $form_state);
$form['width']['#required'] = FALSE;
$form['height']['#required'] = FALSE;
- $form['upscale'] = array(
+ $form['upscale'] = [
'#type' => 'checkbox',
'#default_value' => $this->configuration['upscale'],
'#title' => t('Allow Upscaling'),
'#description' => t('Let scale make images larger than their original size.'),
- );
+ ];
return $form;
}
diff --git a/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php b/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php
index 20dabe7a958..3fc1e7f4ed9 100644
--- a/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php
+++ b/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php
@@ -46,7 +46,7 @@ class EntityImageStyle extends EntityConfigBase {
$style->save();
- return array($style->id());
+ return [$style->id()];
}
}
diff --git a/core/modules/image/src/Plugin/migrate/source/d6/ImageCachePreset.php b/core/modules/image/src/Plugin/migrate/source/d6/ImageCachePreset.php
index 4266ff17977..aade9abdb4c 100644
--- a/core/modules/image/src/Plugin/migrate/source/d6/ImageCachePreset.php
+++ b/core/modules/image/src/Plugin/migrate/source/d6/ImageCachePreset.php
@@ -47,7 +47,7 @@ class ImageCachePreset extends DrupalSqlBase {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
- $actions = array();
+ $actions = [];
$results = $this->select('imagecache_action', 'ica')
->fields('ica')
diff --git a/core/modules/image/src/Plugin/migrate/source/d7/ImageStyles.php b/core/modules/image/src/Plugin/migrate/source/d7/ImageStyles.php
index d680c789e60..dab62f3a9ef 100644
--- a/core/modules/image/src/Plugin/migrate/source/d7/ImageStyles.php
+++ b/core/modules/image/src/Plugin/migrate/source/d7/ImageStyles.php
@@ -47,7 +47,7 @@ class ImageStyles extends DrupalSqlBase {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
- $effects = array();
+ $effects = [];
$results = $this->select('image_effects', 'ie')
->fields('ie')
diff --git a/core/modules/image/src/Routing/ImageStyleRoutes.php b/core/modules/image/src/Routing/ImageStyleRoutes.php
index 66f6bfa19ce..71960fec0ad 100644
--- a/core/modules/image/src/Routing/ImageStyleRoutes.php
+++ b/core/modules/image/src/Routing/ImageStyleRoutes.php
@@ -45,7 +45,7 @@ class ImageStyleRoutes implements ContainerInjectionInterface {
* An array of route objects.
*/
public function routes() {
- $routes = array();
+ $routes = [];
// Generate image derivatives of publicly available files. If clean URLs are
// disabled image derivatives will always be served through the menu system.
// If clean URLs are enabled and the image derivative already exists, PHP
@@ -54,12 +54,12 @@ class ImageStyleRoutes implements ContainerInjectionInterface {
$routes['image.style_public'] = new Route(
'/' . $directory_path . '/styles/{image_style}/{scheme}',
- array(
+ [
'_controller' => 'Drupal\image\Controller\ImageStyleDownloadController::deliver',
- ),
- array(
+ ],
+ [
'_access' => 'TRUE',
- )
+ ]
);
return $routes;
}
diff --git a/core/modules/image/src/Tests/FileMoveTest.php b/core/modules/image/src/Tests/FileMoveTest.php
index 195799446d2..ce28a0b372f 100644
--- a/core/modules/image/src/Tests/FileMoveTest.php
+++ b/core/modules/image/src/Tests/FileMoveTest.php
@@ -18,7 +18,7 @@ class FileMoveTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('image');
+ public static $modules = ['image'];
/**
* Tests moving a randomly generated image.
diff --git a/core/modules/image/src/Tests/ImageAdminStylesTest.php b/core/modules/image/src/Tests/ImageAdminStylesTest.php
index 4b7ff43e93c..c8e92d34488 100644
--- a/core/modules/image/src/Tests/ImageAdminStylesTest.php
+++ b/core/modules/image/src/Tests/ImageAdminStylesTest.php
@@ -47,14 +47,14 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
function testNumericStyleName() {
$style_name = rand();
$style_label = $this->randomString();
- $edit = array(
+ $edit = [
'name' => $style_name,
'label' => $style_label,
- );
+ ];
$this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style'));
- $this->assertRaw(t('Style %name was created.', array('%name' => $style_label)));
+ $this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
$options = image_style_options();
- $this->assertTrue(array_key_exists($style_name, $options), format_string('Array key %key exists.', array('%key' => $style_name)));
+ $this->assertTrue(array_key_exists($style_name, $options), format_string('Array key %key exists.', ['%key' => $style_name]));
}
/**
@@ -67,43 +67,43 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$style_name = strtolower($this->randomMachineName(10));
$style_label = $this->randomString();
$style_path = $admin_path . '/manage/' . $style_name;
- $effect_edits = array(
- 'image_resize' => array(
+ $effect_edits = [
+ 'image_resize' => [
'width' => 100,
'height' => 101,
- ),
- 'image_scale' => array(
+ ],
+ 'image_scale' => [
'width' => 110,
'height' => 111,
'upscale' => 1,
- ),
- 'image_scale_and_crop' => array(
+ ],
+ 'image_scale_and_crop' => [
'width' => 120,
'height' => 121,
- ),
- 'image_crop' => array(
+ ],
+ 'image_crop' => [
'width' => 130,
'height' => 131,
'anchor' => 'left-top',
- ),
- 'image_desaturate' => array(
+ ],
+ 'image_desaturate' => [
// No options for desaturate.
- ),
- 'image_rotate' => array(
+ ],
+ 'image_rotate' => [
'degrees' => 5,
'random' => 1,
'bgcolor' => '#FFFF00',
- ),
- );
+ ],
+ ];
// Add style form.
- $edit = array(
+ $edit = [
'name' => $style_name,
'label' => $style_label,
- );
+ ];
$this->drupalPostForm($admin_path . '/add', $edit, t('Create new style'));
- $this->assertRaw(t('Style %name was created.', array('%name' => $style_label)));
+ $this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
// Ensure that the expected entity operations are there.
$this->drupalGet($admin_path);
@@ -115,12 +115,12 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Add each sample effect to the style.
foreach ($effect_edits as $effect => $edit) {
- $edit_data = array();
+ $edit_data = [];
foreach ($edit as $field => $value) {
$edit_data['data[' . $field . ']'] = $value;
}
// Add the effect.
- $this->drupalPostForm($style_path, array('new' => $effect), t('Add'));
+ $this->drupalPostForm($style_path, ['new' => $effect], t('Add'));
if (!empty($edit)) {
$this->drupalPostForm(NULL, $edit_data, t('Add effect'));
}
@@ -140,13 +140,13 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Confirm that all effects on the image style have settings that match
// what was saved.
- $uuids = array();
+ $uuids = [];
foreach ($style->getEffects() as $uuid => $effect) {
// Store the uuid for later use.
$uuids[$effect->getPluginId()] = $uuid;
$effect_configuration = $effect->getConfiguration();
foreach ($effect_edits[$effect->getPluginId()] as $field => $value) {
- $this->assertEqual($value, $effect_configuration['data'][$field], SafeMarkup::format('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value)));
+ $this->assertEqual($value, $effect_configuration['data'][$field], SafeMarkup::format('The %field field in the %effect effect has the correct value of %value.', ['%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value]));
}
}
@@ -154,10 +154,10 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
foreach (array_keys($effect_edits) as $effect_name) {
$this->assertTrue(isset($uuids[$effect_name]), format_string(
'A %effect_name effect was saved with ID %uuid',
- array(
+ [
'%effect_name' => $effect_name,
'%uuid' => $uuids[$effect_name],
- )));
+ ]));
}
// Image style overview form (ordering and renaming).
@@ -180,10 +180,10 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$style_name = strtolower($this->randomMachineName(10));
$style_label = $this->randomMachineName();
$weight = count($effect_edits);
- $edit = array(
+ $edit = [
'name' => $style_name,
'label' => $style_label,
- );
+ ];
foreach ($style->getEffects() as $uuid => $effect) {
$edit['effects[' . $uuid . '][weight]'] = $weight;
$weight--;
@@ -191,7 +191,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Create an image to make sure it gets flushed after saving.
$image_path = $this->createSampleImage($style);
- $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+ $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
$this->drupalPostForm($style_path, $edit, t('Update style'));
@@ -200,13 +200,13 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Check that the URL was updated.
$this->drupalGet($style_path);
- $this->assertTitle(t('Edit style @name | Drupal', array('@name' => $style_label)));
- $this->assertResponse(200, format_string('Image style %original renamed to %new', array('%original' => $style->id(), '%new' => $style_name)));
+ $this->assertTitle(t('Edit style @name | Drupal', ['@name' => $style_label]));
+ $this->assertResponse(200, format_string('Image style %original renamed to %new', ['%original' => $style->id(), '%new' => $style_name]));
// Check that the image was flushed after updating the style.
// This is especially important when renaming the style. Make sure that
// the old image directory has been deleted.
- $this->assertEqual($this->getImageCount($style), 0, format_string('Image style %style was flushed after renaming the style and updating the order of effects.', array('%style' => $style->label())));
+ $this->assertEqual($this->getImageCount($style), 0, format_string('Image style %style was flushed after renaming the style and updating the order of effects.', ['%style' => $style->label()]));
// Load the style by the new name with the new weights.
$style = ImageStyle::load($style_name);
@@ -227,14 +227,14 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Create an image to make sure it gets flushed after deleting an effect.
$image_path = $this->createSampleImage($style);
- $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+ $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
// Delete the 'image_crop' effect from the style.
- $this->drupalPostForm($style_path . '/effects/' . $uuids['image_crop'] . '/delete', array(), t('Delete'));
+ $this->drupalPostForm($style_path . '/effects/' . $uuids['image_crop'] . '/delete', [], t('Delete'));
// Confirm that the form submission was successful.
$this->assertResponse(200);
$image_crop_effect = $style->getEffect($uuids['image_crop']);
- $this->assertRaw(t('The image effect %name has been deleted.', array('%name' => $image_crop_effect->label())));
+ $this->assertRaw(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()]));
// Confirm that there is no longer a link to the effect.
$this->assertNoLinkByHref($style_path . '/effects/' . $uuids['image_crop'] . '/delete');
// Refresh the image style information and verify that the effect was
@@ -243,18 +243,18 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$style = $entity_type_manager->getStorage('image_style')->loadUnchanged($style->id());
$this->assertFalse($style->getEffects()->has($uuids['image_crop']), format_string(
'Effect with ID %uuid no longer found on image style %style',
- array(
+ [
'%uuid' => $uuids['image_crop'],
'%style' => $style->label(),
- )));
+ ]));
// Additional test on Rotate effect, for transparent background.
- $edit = array(
+ $edit = [
'data[degrees]' => 5,
'data[random]' => 0,
'data[bgcolor]' => '',
- );
- $this->drupalPostForm($style_path, array('new' => 'image_rotate'), t('Add'));
+ ];
+ $this->drupalPostForm($style_path, ['new' => 'image_rotate'], t('Add'));
$this->drupalPostForm(NULL, $edit, t('Add effect'));
$entity_type_manager = $this->container->get('entity_type.manager');
$style = $entity_type_manager->getStorage('image_style')->loadUnchanged($style_name);
@@ -263,13 +263,13 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Style deletion form.
// Delete the style.
- $this->drupalPostForm($style_path . '/delete', array(), t('Delete'));
+ $this->drupalPostForm($style_path . '/delete', [], t('Delete'));
// Confirm the style directory has been removed.
$directory = file_default_scheme() . '://styles/' . $style_name;
- $this->assertFalse(is_dir($directory), format_string('Image style %style directory removed on style deletion.', array('%style' => $style->label())));
+ $this->assertFalse(is_dir($directory), format_string('Image style %style directory removed on style deletion.', ['%style' => $style->label()]));
- $this->assertFalse(ImageStyle::load($style_name), format_string('Image style %style successfully deleted.', array('%style' => $style->label())));
+ $this->assertFalse(ImageStyle::load($style_name), format_string('Image style %style successfully deleted.', ['%style' => $style->label()]));
// Test empty text when there are no image styles.
@@ -334,7 +334,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Create a new style.
$style_name = strtolower($this->randomMachineName(10));
$style_label = $this->randomString();
- $style = ImageStyle::create(array('name' => $style_name, 'label' => $style_label));
+ $style = ImageStyle::create(['name' => $style_name, 'label' => $style_label]);
$style->save();
$style_path = 'admin/config/media/image-styles/manage/';
@@ -342,10 +342,10 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$field_name = strtolower($this->randomMachineName(10));
$this->createImageField($field_name, 'article');
entity_get_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'image',
- 'settings' => array('image_style' => $style_name),
- ))
+ 'settings' => ['image_style' => $style_name],
+ ])
->save();
// Create a new node with an image attached.
@@ -359,17 +359,17 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Test that image is displayed using newly created style.
$this->drupalGet('node/' . $nid);
- $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), format_string('Image displayed using style @style.', array('@style' => $style_name)));
+ $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), format_string('Image displayed using style @style.', ['@style' => $style_name]));
// Rename the style and make sure the image field is updated.
$new_style_name = strtolower($this->randomMachineName(10));
$new_style_label = $this->randomString();
- $edit = array(
+ $edit = [
'name' => $new_style_name,
'label' => $new_style_label,
- );
+ ];
$this->drupalPostForm($style_path . $style_name, $edit, t('Update style'));
- $this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
+ $this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', ['%name' => $style_name, '%new_name' => $new_style_name]));
$this->drupalGet('node/' . $nid);
// Reload the image style using the new name.
@@ -377,11 +377,11 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), 'Image displayed using style replacement style.');
// Delete the style and choose a replacement style.
- $edit = array(
+ $edit = [
'replacement' => 'thumbnail',
- );
+ ];
$this->drupalPostForm($style_path . $new_style_name . '/delete', $edit, t('Delete'));
- $message = t('The image style %name has been deleted.', array('%name' => $new_style_label));
+ $message = t('The image style %name has been deleted.', ['%name' => $new_style_label]);
$this->assertRaw($message);
$replacement_style = ImageStyle::load('thumbnail');
@@ -396,14 +396,14 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Add a scale effect.
$style_name = 'test_style_effect_edit';
$this->drupalGet('admin/config/media/image-styles/add');
- $this->drupalPostForm(NULL, array('label' => 'Test style effect edit', 'name' => $style_name), t('Create new style'));
- $this->drupalPostForm(NULL, array('new' => 'image_scale_and_crop'), t('Add'));
- $this->drupalPostForm(NULL, array('data[width]' => '300', 'data[height]' => '200'), t('Add effect'));
+ $this->drupalPostForm(NULL, ['label' => 'Test style effect edit', 'name' => $style_name], t('Create new style'));
+ $this->drupalPostForm(NULL, ['new' => 'image_scale_and_crop'], t('Add'));
+ $this->drupalPostForm(NULL, ['data[width]' => '300', 'data[height]' => '200'], t('Add effect'));
$this->assertText(t('Scale and crop 300×200'));
// There should normally be only one edit link on this page initially.
$this->clickLink(t('Edit'));
- $this->drupalPostForm(NULL, array('data[width]' => '360', 'data[height]' => '240'), t('Update effect'));
+ $this->drupalPostForm(NULL, ['data[width]' => '360', 'data[height]' => '240'], t('Update effect'));
$this->assertText(t('Scale and crop 360×240'));
// Check that the previous effect is replaced.
@@ -411,17 +411,17 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Add another scale effect.
$this->drupalGet('admin/config/media/image-styles/add');
- $this->drupalPostForm(NULL, array('label' => 'Test style scale edit scale', 'name' => 'test_style_scale_edit_scale'), t('Create new style'));
- $this->drupalPostForm(NULL, array('new' => 'image_scale'), t('Add'));
- $this->drupalPostForm(NULL, array('data[width]' => '12', 'data[height]' => '19'), t('Add effect'));
+ $this->drupalPostForm(NULL, ['label' => 'Test style scale edit scale', 'name' => 'test_style_scale_edit_scale'], t('Create new style'));
+ $this->drupalPostForm(NULL, ['new' => 'image_scale'], t('Add'));
+ $this->drupalPostForm(NULL, ['data[width]' => '12', 'data[height]' => '19'], t('Add effect'));
// Edit the scale effect that was just added.
$this->clickLink(t('Edit'));
- $this->drupalPostForm(NULL, array('data[width]' => '24', 'data[height]' => '19'), t('Update effect'));
- $this->drupalPostForm(NULL, array('new' => 'image_scale'), t('Add'));
+ $this->drupalPostForm(NULL, ['data[width]' => '24', 'data[height]' => '19'], t('Update effect'));
+ $this->drupalPostForm(NULL, ['new' => 'image_scale'], t('Add'));
// Add another scale effect and make sure both exist.
- $this->drupalPostForm(NULL, array('data[width]' => '12', 'data[height]' => '19'), t('Add effect'));
+ $this->drupalPostForm(NULL, ['data[width]' => '12', 'data[height]' => '19'], t('Add effect'));
$this->assertText(t('Scale 24×19'));
$this->assertText(t('Scale 12×19'));
@@ -439,7 +439,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Create a new style.
$style_name = strtolower($this->randomMachineName(10));
- $style = ImageStyle::create(array('name' => $style_name, 'label' => $this->randomString()));
+ $style = ImageStyle::create(['name' => $style_name, 'label' => $this->randomString()]);
$style->save();
// Create an image to make sure it gets flushed.
@@ -456,7 +456,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$this->assertLinkByHref($flush_path);
// Flush the image style derivatives using the user interface.
- $this->drupalPostForm($flush_path, array(), t('Flush'));
+ $this->drupalPostForm($flush_path, [], t('Flush'));
// The derivative image file should have been deleted.
$this->assertEqual($this->getImageCount($style), 0);
@@ -469,17 +469,17 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Create a new style.
$style_name = strtolower($this->randomMachineName(10));
$style_label = $this->randomString();
- $style = ImageStyle::create(array('name' => $style_name, 'label' => $style_label));
+ $style = ImageStyle::create(['name' => $style_name, 'label' => $style_label]);
$style->save();
// Create an image field that uses the new style.
$field_name = strtolower($this->randomMachineName(10));
$this->createImageField($field_name, 'article');
entity_get_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'image',
- 'settings' => array('image_style' => $style_name),
- ))
+ 'settings' => ['image_style' => $style_name],
+ ])
->save();
// Create a new node with an image attached.
@@ -493,7 +493,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Test that image is displayed using newly created style.
$this->drupalGet('node/' . $nid);
- $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), format_string('Image displayed using style @style.', array('@style' => $style_name)));
+ $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), format_string('Image displayed using style @style.', ['@style' => $style_name]));
// Copy config to sync, and delete the image style.
$sync = $this->container->get('config.storage.sync');
@@ -515,7 +515,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
* Tests access for the image style listing.
*/
public function testImageStyleAccess() {
- $style = ImageStyle::create(array('name' => 'style_foo', 'label' => $this->randomString()));
+ $style = ImageStyle::create(['name' => 'style_foo', 'label' => $this->randomString()]);
$style->save();
$this->drupalGet('admin/config/media/image-styles');
diff --git a/core/modules/image/src/Tests/ImageDimensionsTest.php b/core/modules/image/src/Tests/ImageDimensionsTest.php
index 6f73042cc3d..365a6aa086e 100644
--- a/core/modules/image/src/Tests/ImageDimensionsTest.php
+++ b/core/modules/image/src/Tests/ImageDimensionsTest.php
@@ -17,7 +17,7 @@ class ImageDimensionsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('image', 'image_module_test');
+ public static $modules = ['image', 'image_module_test'];
protected $profile = 'testing';
@@ -33,33 +33,33 @@ class ImageDimensionsTest extends WebTestBase {
// Create a style.
/** @var $style \Drupal\image\ImageStyleInterface */
- $style = ImageStyle::create(array('name' => 'test', 'label' => 'Test'));
+ $style = ImageStyle::create(['name' => 'test', 'label' => 'Test']);
$style->save();
$generated_uri = 'public://styles/test/public/' . \Drupal::service('file_system')->basename($original_uri);
$url = file_url_transform_relative($style->buildUrl($original_uri));
- $variables = array(
+ $variables = [
'#theme' => 'image_style',
'#style_name' => 'test',
'#uri' => $original_uri,
'#width' => 40,
'#height' => 20,
- );
+ ];
// Verify that the original image matches the hard-coded values.
$image_file = $image_factory->get($original_uri);
$this->assertEqual($image_file->getWidth(), $variables['#width']);
$this->assertEqual($image_file->getHeight(), $variables['#height']);
// Scale an image that is wider than it is high.
- $effect = array(
+ $effect = [
'id' => 'image_scale',
- 'data' => array(
+ 'data' => [
'width' => 120,
'height' => 90,
'upscale' => TRUE,
- ),
+ ],
'weight' => 0,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
@@ -73,14 +73,14 @@ class ImageDimensionsTest extends WebTestBase {
$this->assertEqual($image_file->getHeight(), 60);
// Rotate 90 degrees anticlockwise.
- $effect = array(
+ $effect = [
'id' => 'image_rotate',
- 'data' => array(
+ 'data' => [
'degrees' => -90,
'random' => FALSE,
- ),
+ ],
'weight' => 1,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
@@ -94,15 +94,15 @@ class ImageDimensionsTest extends WebTestBase {
$this->assertEqual($image_file->getHeight(), 120);
// Scale an image that is higher than it is wide (rotated by previous effect).
- $effect = array(
+ $effect = [
'id' => 'image_scale',
- 'data' => array(
+ 'data' => [
'width' => 120,
'height' => 90,
'upscale' => TRUE,
- ),
+ ],
'weight' => 2,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
@@ -116,15 +116,15 @@ class ImageDimensionsTest extends WebTestBase {
$this->assertEqual($image_file->getHeight(), 90);
// Test upscale disabled.
- $effect = array(
+ $effect = [
'id' => 'image_scale',
- 'data' => array(
+ 'data' => [
'width' => 400,
'height' => 200,
'upscale' => FALSE,
- ),
+ ],
'weight' => 3,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
@@ -138,11 +138,11 @@ class ImageDimensionsTest extends WebTestBase {
$this->assertEqual($image_file->getHeight(), 90);
// Add a desaturate effect.
- $effect = array(
+ $effect = [
'id' => 'image_desaturate',
- 'data' => array(),
+ 'data' => [],
'weight' => 4,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
@@ -156,14 +156,14 @@ class ImageDimensionsTest extends WebTestBase {
$this->assertEqual($image_file->getHeight(), 90);
// Add a random rotate effect.
- $effect = array(
+ $effect = [
'id' => 'image_rotate',
- 'data' => array(
+ 'data' => [
'degrees' => 180,
'random' => TRUE,
- ),
+ ],
'weight' => 5,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
@@ -175,15 +175,15 @@ class ImageDimensionsTest extends WebTestBase {
// Add a crop effect.
- $effect = array(
+ $effect = [
'id' => 'image_crop',
- 'data' => array(
+ 'data' => [
'width' => 30,
'height' => 30,
'anchor' => 'center-center',
- ),
+ ],
'weight' => 6,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
@@ -197,14 +197,14 @@ class ImageDimensionsTest extends WebTestBase {
$this->assertEqual($image_file->getHeight(), 30);
// Rotate to a non-multiple of 90 degrees.
- $effect = array(
+ $effect = [
'id' => 'image_rotate',
- 'data' => array(
+ 'data' => [
'degrees' => 57,
'random' => FALSE,
- ),
+ ],
'weight' => 7,
- );
+ ];
$effect_id = $style->addImageEffect($effect);
$style->save();
@@ -221,11 +221,11 @@ class ImageDimensionsTest extends WebTestBase {
$style->deleteImageEffect($effect_plugin);
// Ensure that an effect can unset dimensions.
- $effect = array(
+ $effect = [
'id' => 'image_module_test_null',
- 'data' => array(),
+ 'data' => [],
'weight' => 8,
- );
+ ];
$style->addImageEffect($effect);
$style->save();
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index a0f0274973b..d04a1c4d702 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -19,7 +19,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
*
* @var array
*/
- public static $modules = array('field_ui');
+ public static $modules = ['field_ui'];
/**
* Tests CRUD for fields and fields fields with default images.
@@ -36,8 +36,8 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$file = File::create(['uri' => $desired_filepath, 'filename' => $filename, 'name' => $filename]);
$file->save();
}
- $default_images = array();
- foreach (array('field', 'field', 'field2', 'field_new', 'field_new') as $image_target) {
+ $default_images = [];
+ foreach (['field', 'field', 'field2', 'field_new', 'field_new'] as $image_target) {
$file = File::create((array) array_pop($files));
$file->save();
$default_images[$image_target] = $file;
@@ -45,23 +45,23 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
// Create an image field and add an field to the article content type.
$field_name = strtolower($this->randomMachineName());
- $storage_settings['default_image'] = array(
+ $storage_settings['default_image'] = [
'uuid' => $default_images['field']->uuid(),
'alt' => '',
'title' => '',
'width' => 0,
'height' => 0,
- );
- $field_settings['default_image'] = array(
+ ];
+ $field_settings['default_image'] = [
'uuid' => $default_images['field']->uuid(),
'alt' => '',
'title' => '',
'width' => 0,
'height' => 0,
- );
- $widget_settings = array(
+ ];
+ $widget_settings = [
'preview_image_style' => 'medium',
- );
+ ];
$field = $this->createImageField($field_name, 'article', $storage_settings, $field_settings, $widget_settings);
// The field default image id should be 2.
@@ -84,15 +84,15 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
'bundle' => 'page',
'label' => $field->label(),
'required' => $field->isRequired(),
- 'settings' => array(
- 'default_image' => array(
+ 'settings' => [
+ 'default_image' => [
'uuid' => $default_images['field2']->uuid(),
'alt' => '',
'title' => '',
'width' => 0,
'height' => 0,
- ),
- ),
+ ],
+ ],
]);
$field2->save();
@@ -112,7 +112,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field']->id(),
format_string(
'Article image field default equals expected file ID of @fid.',
- array('@fid' => $default_images['field']->id())
+ ['@fid' => $default_images['field']->id()]
)
);
// Confirm the defaults are present on the article field edit form.
@@ -122,7 +122,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field']->id(),
format_string(
'Article image field field default equals expected file ID of @fid.',
- array('@fid' => $default_images['field']->id())
+ ['@fid' => $default_images['field']->id()]
)
);
@@ -133,7 +133,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field']->id(),
format_string(
'Page image field default equals expected file ID of @fid.',
- array('@fid' => $default_images['field']->id())
+ ['@fid' => $default_images['field']->id()]
)
);
// Confirm the defaults are present on the page field edit form.
@@ -144,38 +144,38 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field2']->id(),
format_string(
'Page image field field default equals expected file ID of @fid.',
- array('@fid' => $default_images['field2']->id())
+ ['@fid' => $default_images['field2']->id()]
)
);
// Confirm that the image default is shown for a new article node.
- $article = $this->drupalCreateNode(array('type' => 'article'));
+ $article = $this->drupalCreateNode(['type' => 'article']);
$article_built = $this->drupalBuildEntityView($article);
$this->assertEqual(
$article_built[$field_name][0]['#item']->target_id,
$default_images['field']->id(),
format_string(
'A new article node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field']->id())
+ ['@fid' => $default_images['field']->id()]
)
);
// Also check that the field renders without warnings when the label is
// hidden.
EntityViewDisplay::load('node.article.default')
- ->setComponent($field_name, array('label' => 'hidden', 'type' => 'image'))
+ ->setComponent($field_name, ['label' => 'hidden', 'type' => 'image'])
->save();
$this->drupalGet('node/' . $article->id());
// Confirm that the image default is shown for a new page node.
- $page = $this->drupalCreateNode(array('type' => 'page'));
+ $page = $this->drupalCreateNode(['type' => 'page']);
$page_built = $this->drupalBuildEntityView($page);
$this->assertEqual(
$page_built[$field_name][0]['#item']->target_id,
$default_images['field2']->id(),
format_string(
'A new page node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field2']->id())
+ ['@fid' => $default_images['field2']->id()]
)
);
@@ -192,12 +192,12 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field_new']->id(),
format_string(
'Updated image field default equals expected file ID of @fid.',
- array('@fid' => $default_images['field_new']->id())
+ ['@fid' => $default_images['field_new']->id()]
)
);
// Reload the nodes and confirm the field field defaults are used.
- $node_storage->resetCache(array($article->id(), $page->id()));
+ $node_storage->resetCache([$article->id(), $page->id()]);
$article_built = $this->drupalBuildEntityView($article = $node_storage->load($article->id()));
$page_built = $this->drupalBuildEntityView($page = $node_storage->load($page->id()));
$this->assertEqual(
@@ -205,7 +205,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field']->id(),
format_string(
'An existing article node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field']->id())
+ ['@fid' => $default_images['field']->id()]
)
);
$this->assertEqual(
@@ -213,7 +213,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field2']->id(),
format_string(
'An existing page node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field2']->id())
+ ['@fid' => $default_images['field2']->id()]
)
);
@@ -231,12 +231,12 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field_new']->id(),
format_string(
'Updated article image field field default equals expected file ID of @fid.',
- array('@fid' => $default_images['field_new']->id())
+ ['@fid' => $default_images['field_new']->id()]
)
);
// Reload the nodes.
- $node_storage->resetCache(array($article->id(), $page->id()));
+ $node_storage->resetCache([$article->id(), $page->id()]);
$article_built = $this->drupalBuildEntityView($article = $node_storage->load($article->id()));
$page_built = $this->drupalBuildEntityView($page = $node_storage->load($page->id()));
@@ -246,7 +246,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field_new']->id(),
format_string(
'An existing article node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field_new']->id())
+ ['@fid' => $default_images['field_new']->id()]
)
);
// Confirm the page remains unchanged.
@@ -255,7 +255,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field2']->id(),
format_string(
'An existing page node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field2']->id())
+ ['@fid' => $default_images['field2']->id()]
)
);
@@ -279,7 +279,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
);
// Reload the nodes.
- $node_storage->resetCache(array($article->id(), $page->id()));
+ $node_storage->resetCache([$article->id(), $page->id()]);
$article_built = $this->drupalBuildEntityView($article = $node_storage->load($article->id()));
$page_built = $this->drupalBuildEntityView($page = $node_storage->load($page->id()));
// Confirm the article uses the new field (not field) default.
@@ -288,7 +288,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field_new']->id(),
format_string(
'An existing article node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field_new']->id())
+ ['@fid' => $default_images['field_new']->id()]
)
);
// Confirm the page remains unchanged.
@@ -297,12 +297,12 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$default_images['field2']->id(),
format_string(
'An existing page node without an image has the expected default image file ID of @fid.',
- array('@fid' => $default_images['field2']->id())
+ ['@fid' => $default_images['field2']->id()]
)
);
$non_image = $this->drupalGetTestFiles('text');
- $this->drupalPostForm(NULL, array('files[settings_default_image_uuid]' => drupal_realpath($non_image[0]->uri)), t("Upload"));
+ $this->drupalPostForm(NULL, ['files[settings_default_image_uuid]' => drupal_realpath($non_image[0]->uri)], t("Upload"));
$this->assertText('The specified file text-0.txt could not be uploaded.');
$this->assertText('Only files with the following extensions are allowed: png gif jpg jpeg.');
@@ -316,16 +316,16 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
* Tests image field and field having an invalid default image.
*/
public function testInvalidDefaultImage() {
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => Unicode::strtolower($this->randomMachineName()),
'entity_type' => 'node',
'type' => 'image',
- 'settings' => array(
- 'default_image' => array(
+ 'settings' => [
+ 'default_image' => [
'uuid' => 100000,
- )
- ),
- ));
+ ]
+ ],
+ ]);
$field_storage->save();
$settings = $field_storage->getSettings();
// The non-existent default image should not be saved.
@@ -335,11 +335,11 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
'field_storage' => $field_storage,
'bundle' => 'page',
'label' => $this->randomMachineName(),
- 'settings' => array(
- 'default_image' => array(
+ 'settings' => [
+ 'default_image' => [
'uuid' => 100000,
- )
- ),
+ ]
+ ],
]);
$field->save();
$settings = $field->getSettings();
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index f3ce8587435..d2b4ffea29a 100644
--- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
@@ -21,7 +21,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
*
* @var array
*/
- public static $modules = array('field_ui');
+ public static $modules = ['field_ui'];
/**
* Test image formatters on node display for public files.
@@ -35,7 +35,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
*/
function testImageFieldFormattersPrivate() {
// Remove access content permission from anonymous users.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array('access content' => FALSE));
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, ['access content' => FALSE]);
$this->_testImageFieldFormatters('private');
}
@@ -47,29 +47,29 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$renderer = $this->container->get('renderer');
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$field_name = strtolower($this->randomMachineName());
- $field_settings = array('alt_field_required' => 0);
- $instance = $this->createImageField($field_name, 'article', array('uri_scheme' => $scheme), $field_settings);
+ $field_settings = ['alt_field_required' => 0];
+ $instance = $this->createImageField($field_name, 'article', ['uri_scheme' => $scheme], $field_settings);
// Go to manage display page.
$this->drupalGet("admin/structure/types/manage/article/display");
// Test for existence of link to image styles configuration.
- $this->drupalPostAjaxForm(NULL, array(), "{$field_name}_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "{$field_name}_settings_edit");
$this->assertLinkByHref(\Drupal::url('entity.image_style.collection'), 0, 'Link to image styles configuration is found');
// Remove 'administer image styles' permission from testing admin user.
$admin_user_roles = $this->adminUser->getRoles(TRUE);
- user_role_change_permissions(reset($admin_user_roles), array('administer image styles' => FALSE));
+ user_role_change_permissions(reset($admin_user_roles), ['administer image styles' => FALSE]);
// Go to manage display page again.
$this->drupalGet("admin/structure/types/manage/article/display");
// Test for absence of link to image styles configuration.
- $this->drupalPostAjaxForm(NULL, array(), "{$field_name}_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "{$field_name}_settings_edit");
$this->assertNoLinkByHref(\Drupal::url('entity.image_style.collection'), 'Link to image styles configuration is absent when permissions are insufficient');
// Restore 'administer image styles' permission to testing admin user
- user_role_change_permissions(reset($admin_user_roles), array('administer image styles' => TRUE));
+ user_role_change_permissions(reset($admin_user_roles), ['administer image styles' => TRUE]);
// Create a new node with an image attached.
$test_image = current($this->drupalGetTestFiles('image'));
@@ -87,38 +87,38 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// Save node.
$nid = $this->uploadNodeImage($test_image, $field_name, 'article', $alt);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
// Test that the default formatter is being used.
$file = $node->{$field_name}->entity;
$image_uri = $file->getFileUri();
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => $image_uri,
'#width' => 40,
'#height' => 20,
'#alt' => $alt,
- );
+ ];
$default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
$this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.');
// Test the image linked to file formatter.
- $display_options = array(
+ $display_options = [
'type' => 'image',
- 'settings' => array('image_link' => 'file'),
- );
+ 'settings' => ['image_link' => 'file'],
+ ];
$display = entity_get_display('node', $node->getType(), 'default');
$display->setComponent($field_name, $display_options)
->save();
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => $image_uri,
'#width' => 40,
'#height' => 20,
'#alt' => $alt,
- );
+ ];
$default_output = '<a href="' . file_create_url($image_uri) . '">' . $renderer->renderRoot($image) . '</a>';
$this->drupalGet('node/' . $nid);
$this->assertCacheTag($file->getCacheTags()[0]);
@@ -148,25 +148,25 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$display_options['settings']['image_link'] = 'content';
$display->setComponent($field_name, $display_options)
->save();
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => $image_uri,
'#width' => 40,
'#height' => 20,
- );
+ ];
$this->drupalGet('node/' . $nid);
$this->assertCacheTag($file->getCacheTags()[0]);
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
$elements = $this->xpath(
'//a[@href=:path]/img[@src=:url and @alt=:alt and @width=:width and @height=:height]',
- array(
+ [
':path' => $node->url(),
':url' => file_url_transform_relative(file_create_url($image['#uri'])),
':width' => $image['#width'],
':height' => $image['#height'],
':alt' => $alt,
- )
+ ]
);
$this->assertEqual(count($elements), 1, 'Image linked to content formatter displaying correctly on full node view.');
@@ -179,14 +179,14 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// Ensure the derivative image is generated so we do not have to deal with
// image style callback paths.
$this->drupalGet(ImageStyle::load('thumbnail')->buildUrl($image_uri));
- $image_style = array(
+ $image_style = [
'#theme' => 'image_style',
'#uri' => $image_uri,
'#width' => 40,
'#height' => 20,
'#style_name' => 'thumbnail',
'#alt' => $alt,
- );
+ ];
$default_output = $renderer->renderRoot($image_style);
$this->drupalGet('node/' . $nid);
$image_style = ImageStyle::load('thumbnail');
@@ -224,18 +224,18 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$test_image = current($this->drupalGetTestFiles('image'));
list(, $test_image_extension) = explode('.', $test_image->filename);
$field_name = strtolower($this->randomMachineName());
- $field_settings = array(
+ $field_settings = [
'alt_field' => 1,
'file_extensions' => $test_image_extension,
'max_filesize' => '50 KB',
'max_resolution' => '100x100',
'min_resolution' => '10x10',
'title_field' => 1,
- );
- $widget_settings = array(
+ ];
+ $widget_settings = [
'preview_image_style' => 'medium',
- );
- $field = $this->createImageField($field_name, 'article', array(), $field_settings, $widget_settings);
+ ];
+ $field = $this->createImageField($field_name, 'article', [], $field_settings, $widget_settings);
// Verify that the min/max resolution set on the field are properly
// extracted, and displayed, on the image field's configuration form.
@@ -247,7 +247,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->drupalGet('node/add/article');
$this->assertText(t('50 KB limit.'), 'Image widget max file size is displayed on article form.');
- $this->assertText(t('Allowed types: @extensions.', array('@extensions' => $test_image_extension)), 'Image widget allowed file types displayed on article form.');
+ $this->assertText(t('Allowed types: @extensions.', ['@extensions' => $test_image_extension]), 'Image widget allowed file types displayed on article form.');
$this->assertText(t('Images must be larger than 10x10 pixels. Images larger than 100x100 pixels will be resized.'), 'Image widget allowed resolution displayed on article form.');
// We have to create the article first and then edit it because the alt
@@ -262,7 +262,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertFieldByName($field_name . '[0][title]', '', 'Title field displayed on article form.');
// Verify that the attached image is being previewed using the 'medium'
// style.
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$file = $node->{$field_name}->entity;
@@ -270,38 +270,38 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertTrue($this->cssSelect('img[width=40][height=20][class=image-style-medium][src="' . $url . '"]'));
// Add alt/title fields to the image and verify that they are displayed.
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => $file->getFileUri(),
'#alt' => $alt,
'#title' => $this->randomMachineName(),
'#width' => 40,
'#height' => 20,
- );
- $edit = array(
+ ];
+ $edit = [
$field_name . '[0][alt]' => $image['#alt'],
$field_name . '[0][title]' => $image['#title'],
- );
+ ];
$this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
$this->assertRaw($default_output, 'Image displayed using user supplied alt and title attributes.');
// Verify that alt/title longer than allowed results in a validation error.
$test_size = 2000;
- $edit = array(
+ $edit = [
$field_name . '[0][alt]' => $this->randomMachineName($test_size),
$field_name . '[0][title]' => $this->randomMachineName($test_size),
- );
+ ];
$this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$schema = $field->getFieldStorageDefinition()->getSchema();
- $this->assertRaw(t('Alternative text cannot be longer than %max characters but is currently %length characters long.', array(
+ $this->assertRaw(t('Alternative text cannot be longer than %max characters but is currently %length characters long.', [
'%max' => $schema['columns']['alt']['length'],
'%length' => $test_size,
- )));
- $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', array(
+ ]));
+ $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', [
'%max' => $schema['columns']['title']['length'],
'%length' => $test_size,
- )));
+ ]));
// Set cardinality to unlimited and add upload a second image.
// The image widget is extending on the file widget, but the image field
@@ -310,20 +310,20 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// 1, so we need to make sure the file widget prevents these notices by
// providing all settings, even if they are not used.
// @see FileWidget::formMultipleElements().
- $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings'));
- $edit = array(
+ $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', ['cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED], t('Save field settings'));
+ $edit = [
'files[' . $field_name . '_1][]' => drupal_realpath($test_image->uri),
- );
+ ];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
// Add the required alt text.
$this->drupalPostForm(NULL, [$field_name . '[1][alt]' => $alt], t('Save and keep published'));
- $this->assertText(format_string('Article @title has been updated.', array('@title' => $node->getTitle())));
+ $this->assertText(format_string('Article @title has been updated.', ['@title' => $node->getTitle()]));
// Assert ImageWidget::process() calls FieldWidget::process().
$this->drupalGet('node/' . $node->id() . '/edit');
- $edit = array(
+ $edit = [
'files[' . $field_name . '_2][]' => drupal_realpath($test_image->uri),
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, $field_name . '_2_upload_button');
$this->assertNoRaw('<input multiple type="file" id="edit-' . strtr($field_name, '_', '-') . '-2-upload" name="files[' . $field_name . '_2][]" size="22" class="js-form-file form-file">');
$this->assertRaw('<input multiple type="file" id="edit-' . strtr($field_name, '_', '-') . '-3-upload" name="files[' . $field_name . '_3][]" size="22" class="js-form-file form-file">');
@@ -343,7 +343,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// Create a new node, with no images and verify that no images are
// displayed.
- $node = $this->drupalCreateNode(array('type' => 'article'));
+ $node = $this->drupalCreateNode(['type' => 'article']);
$this->drupalGet('node/' . $node->id());
// Verify that no image is displayed on the page by checking for the class
// that would be used on the image field.
@@ -355,12 +355,12 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$images = $this->drupalGetTestFiles('image');
$alt = $this->randomString(512);
$title = $this->randomString(1024);
- $edit = array(
+ $edit = [
// Get the path of the 'image-test.png' file.
'files[settings_default_image_uuid]' => drupal_realpath($images[0]->uri),
'settings[default_image][alt]' => $alt,
'settings[default_image][title]' => $title,
- );
+ ];
$this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings'));
// Clear field definition cache so the new default image is detected.
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -368,14 +368,14 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$default_image = $field_storage->getSetting('default_image');
$file = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid']);
$this->assertTrue($file->isPermanent(), 'The default image status is permanent.');
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => $file->getFileUri(),
'#alt' => $alt,
'#title' => $title,
'#width' => 40,
'#height' => 20,
- );
+ ];
$default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
$this->drupalGet('node/' . $node->id());
$this->assertCacheTag($file->getCacheTags()[0]);
@@ -391,16 +391,16 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// Upload the 'image-test.gif' file.
$nid = $this->uploadNodeImage($images[2], $field_name, 'article', $alt);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$file = $node->{$field_name}->entity;
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => $file->getFileUri(),
'#width' => 40,
'#height' => 20,
'#alt' => $alt,
- );
+ ];
$image_output = str_replace("\n", NULL, $renderer->renderRoot($image));
$this->drupalGet('node/' . $nid);
$this->assertCacheTag($file->getCacheTags()[0]);
@@ -410,9 +410,9 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertRaw($image_output, 'User supplied image is displayed.');
// Remove default image from the field and make sure it is no longer used.
- $edit = array(
+ $edit = [
'settings[default_image][uuid][fids]' => 0,
- );
+ ];
$this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings'));
// Clear field definition cache so the new default image is detected.
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -422,14 +422,14 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// Create an image field that uses the private:// scheme and test that the
// default image works as expected.
$private_field_name = strtolower($this->randomMachineName());
- $this->createImageField($private_field_name, 'article', array('uri_scheme' => 'private'));
+ $this->createImageField($private_field_name, 'article', ['uri_scheme' => 'private']);
// Add a default image to the new field.
- $edit = array(
+ $edit = [
// Get the path of the 'image-test.gif' file.
'files[settings_default_image_uuid]' => drupal_realpath($images[2]->uri),
'settings[default_image][alt]' => $alt,
'settings[default_image][title]' => $title,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $private_field_name . '/storage', $edit, t('Save field settings'));
// Clear field definition cache so the new default image is detected.
\Drupal::entityManager()->clearCachedFieldDefinitions();
@@ -441,15 +441,15 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertTrue($file->isPermanent(), 'The default image status is permanent.');
// Create a new node with no image attached and ensure that default private
// image is displayed.
- $node = $this->drupalCreateNode(array('type' => 'article'));
- $image = array(
+ $node = $this->drupalCreateNode(['type' => 'article']);
+ $image = [
'#theme' => 'image',
'#uri' => $file->getFileUri(),
'#alt' => $alt,
'#title' => $title,
'#width' => 40,
'#height' => 20,
- );
+ ];
$default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
$this->drupalGet('node/' . $node->id());
$this->assertCacheTag($file->getCacheTags()[0]);
diff --git a/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php
index c17f53a8b68..ed452786462 100644
--- a/core/modules/image/src/Tests/ImageFieldTestBase.php
+++ b/core/modules/image/src/Tests/ImageFieldTestBase.php
@@ -33,7 +33,7 @@ abstract class ImageFieldTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'image', 'field_ui', 'image_module_test');
+ public static $modules = ['node', 'image', 'field_ui', 'image_module_test'];
/**
* An user with permissions to administer content types and image styles.
@@ -47,11 +47,11 @@ abstract class ImageFieldTestBase extends WebTestBase {
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
- $this->adminUser = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer node fields', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles', 'administer node display'));
+ $this->adminUser = $this->drupalCreateUser(['access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer node fields', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles', 'administer node display']);
$this->drupalLogin($this->adminUser);
}
@@ -66,9 +66,9 @@ abstract class ImageFieldTestBase extends WebTestBase {
* The type of node to create.
*/
function previewNodeImage($image, $field_name, $type) {
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
- );
+ ];
$edit['files[' . $field_name . '_0]'] = drupal_realpath($image->uri);
$this->drupalPostForm('node/add/' . $type, $edit, t('Preview'));
}
@@ -86,9 +86,9 @@ abstract class ImageFieldTestBase extends WebTestBase {
* The alt text for the image. Use if the field settings require alt text.
*/
function uploadNodeImage($image, $field_name, $type, $alt = '') {
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
- );
+ ];
$edit['files[' . $field_name . '_0]'] = drupal_realpath($image->uri);
$this->drupalPostForm('node/add/' . $type, $edit, t('Save and publish'));
if ($alt) {
@@ -97,7 +97,7 @@ abstract class ImageFieldTestBase extends WebTestBase {
}
// Retrieve ID of the newly created node from the current URL.
- $matches = array();
+ $matches = [];
preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
return isset($matches[1]) ? $matches[1] : FALSE;
}
diff --git a/core/modules/image/src/Tests/ImageFieldValidateTest.php b/core/modules/image/src/Tests/ImageFieldValidateTest.php
index 5f0bf213fae..4e8e0c1f1ac 100644
--- a/core/modules/image/src/Tests/ImageFieldValidateTest.php
+++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php
@@ -87,14 +87,14 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
*/
function testRequiredAttributes() {
$field_name = strtolower($this->randomMachineName());
- $field_settings = array(
+ $field_settings = [
'alt_field' => 1,
'alt_field_required' => 1,
'title_field' => 1,
'title_field_required' => 1,
'required' => 1,
- );
- $instance = $this->createImageField($field_name, 'article', array(), $field_settings);
+ ];
+ $instance = $this->createImageField($field_name, 'article', [], $field_settings);
$images = $this->drupalGetTestFiles('image');
// Let's just use the first image.
$image = $images[0];
@@ -116,9 +116,9 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
$instance->setSetting('title_field_required', 0);
$instance->save();
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$this->assertNoText(t('Alternative text field is required.'));
@@ -129,9 +129,9 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
$instance->setSetting('title_field_required', 1);
$instance->save();
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$this->assertNoText(t('Alternative text field is required.'));
diff --git a/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php b/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php
index a8985ce4c77..e1f70d78a9b 100644
--- a/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php
+++ b/core/modules/image/src/Tests/ImageOnTranslatedEntityTest.php
@@ -14,7 +14,7 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language', 'content_translation', 'field_ui');
+ public static $modules = ['language', 'content_translation', 'field_ui'];
/**
* The name of the image field used in the test.
@@ -39,7 +39,7 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
$this->createImageField($this->fieldName, 'basicpage', [], ['title_field' => 1]);
// Create and log in user.
- $permissions = array(
+ $permissions = [
'access administration pages',
'administer content translation',
'administer content types',
@@ -50,16 +50,16 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
'edit any basicpage content',
'translate any entity',
'delete any basicpage content',
- );
+ ];
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Add a second and third language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'nl';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
}
@@ -69,7 +69,7 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
*/
public function testSyncedImages() {
// Enable translation for "Basic page" nodes.
- $edit = array(
+ $edit = [
'entity_types[node]' => 1,
'settings[node][basicpage][translatable]' => 1,
"settings[node][basicpage][fields][$this->fieldName]" => 1,
@@ -78,7 +78,7 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
// checkboxes on the form.
"settings[node][basicpage][columns][$this->fieldName][alt]" => FALSE,
"settings[node][basicpage][columns][$this->fieldName][title]" => FALSE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, 'Save configuration');
// Verify that the image field on the "Basic basic" node type is
@@ -87,10 +87,10 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
$this->assertTrue($definitions[$this->fieldName]->isTranslatable(), 'Node image field is translatable.');
// Create a default language node.
- $default_language_node = $this->drupalCreateNode(array('type' => 'basicpage', 'title' => 'Lost in translation'));
+ $default_language_node = $this->drupalCreateNode(['type' => 'basicpage', 'title' => 'Lost in translation']);
// Edit the node to upload a file.
- $edit = array();
+ $edit = [];
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('image')[0]->uri);
$this->drupalPostForm('node/' . $default_language_node->id() . '/edit', $edit, t('Save'));
@@ -99,10 +99,10 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
$first_fid = $this->getLastFileId();
// Translate the node into French: remove the existing file.
- $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/fr', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/fr', [], t('Remove'));
// Upload a different file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = 'Scarlett Johansson';
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('image')[1]->uri);
@@ -131,10 +131,10 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
$this->assertTrue($file->isPermanent());
// Translate the node into dutch: remove the existing file.
- $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/nl', array(), t('Remove'));
+ $this->drupalPostForm('node/' . $default_language_node->id() . '/translations/add/en/nl', [], t('Remove'));
// Upload a different file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = 'Akiko Takeshita';
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('image')[2]->uri);
@@ -166,10 +166,10 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
$this->assertTrue($file->isPermanent());
// Edit the second translation: remove the existing file.
- $this->drupalPostForm('fr/node/' . $default_language_node->id() . '/edit', array(), t('Remove'));
+ $this->drupalPostForm('fr/node/' . $default_language_node->id() . '/edit', [], t('Remove'));
// Upload a different file.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = 'Giovanni Ribisi';
$name = 'files[' . $this->fieldName . '_0]';
$edit[$name] = drupal_realpath($this->drupalGetTestFiles('image')[3]->uri);
@@ -194,7 +194,7 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
$this->assertTrue($file->isPermanent());
// Delete the third translation.
- $this->drupalPostForm('nl/node/' . $default_language_node->id() . '/delete', array(), t('Delete Dutch translation'));
+ $this->drupalPostForm('nl/node/' . $default_language_node->id() . '/delete', [], t('Delete Dutch translation'));
\Drupal::entityTypeManager()->getStorage('file')->resetCache();
@@ -210,7 +210,7 @@ class ImageOnTranslatedEntityTest extends ImageFieldTestBase {
$this->assertTrue($file->isTemporary());
// Delete the all translations.
- $this->drupalPostForm('node/' . $default_language_node->id() . '/delete', array(), t('Delete all translations'));
+ $this->drupalPostForm('node/' . $default_language_node->id() . '/delete', [], t('Delete all translations'));
\Drupal::entityTypeManager()->getStorage('file')->resetCache();
diff --git a/core/modules/image/src/Tests/ImageStyleFlushTest.php b/core/modules/image/src/Tests/ImageStyleFlushTest.php
index 63c0d8093a8..ad837e88e41 100644
--- a/core/modules/image/src/Tests/ImageStyleFlushTest.php
+++ b/core/modules/image/src/Tests/ImageStyleFlushTest.php
@@ -47,29 +47,29 @@ class ImageStyleFlushTest extends ImageFieldTestBase {
$style_name = strtolower($this->randomMachineName(10));
$style_label = $this->randomString();
$style_path = 'admin/config/media/image-styles/manage/' . $style_name;
- $effect_edits = array(
- 'image_resize' => array(
+ $effect_edits = [
+ 'image_resize' => [
'data[width]' => 100,
'data[height]' => 101,
- ),
- 'image_scale' => array(
+ ],
+ 'image_scale' => [
'data[width]' => 110,
'data[height]' => 111,
'data[upscale]' => 1,
- ),
- );
+ ],
+ ];
// Add style form.
- $edit = array(
+ $edit = [
'name' => $style_name,
'label' => $style_label,
- );
+ ];
$this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style'));
// Add each sample effect to the style.
foreach ($effect_edits as $effect => $edit) {
// Add the effect.
- $this->drupalPostForm($style_path, array('new' => $effect), t('Add'));
+ $this->drupalPostForm($style_path, ['new' => $effect], t('Add'));
if (!empty($edit)) {
$this->drupalPostForm(NULL, $edit, t('Add effect'));
}
@@ -82,29 +82,29 @@ class ImageStyleFlushTest extends ImageFieldTestBase {
$image_path = $this->createSampleImage($style, 'public');
// Expecting to find 2 images, one is the sample.png image shown in
// image style preview.
- $this->assertEqual($this->getImageCount($style, 'public'), 2, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+ $this->assertEqual($this->getImageCount($style, 'public'), 2, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
// Create an image for the 'private' wrapper.
$image_path = $this->createSampleImage($style, 'private');
- $this->assertEqual($this->getImageCount($style, 'private'), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
+ $this->assertEqual($this->getImageCount($style, 'private'), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
// Remove the 'image_scale' effect and updates the style, which in turn
// forces an image style flush.
$style_path = 'admin/config/media/image-styles/manage/' . $style->id();
- $uuids = array();
+ $uuids = [];
foreach ($style->getEffects() as $uuid => $effect) {
$uuids[$effect->getPluginId()] = $uuid;
}
- $this->drupalPostForm($style_path . '/effects/' . $uuids['image_scale'] . '/delete', array(), t('Delete'));
+ $this->drupalPostForm($style_path . '/effects/' . $uuids['image_scale'] . '/delete', [], t('Delete'));
$this->assertResponse(200);
- $this->drupalPostForm($style_path, array(), t('Update style'));
+ $this->drupalPostForm($style_path, [], t('Update style'));
$this->assertResponse(200);
// Post flush, expected 1 image in the 'public' wrapper (sample.png).
- $this->assertEqual($this->getImageCount($style, 'public'), 1, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'public')));
+ $this->assertEqual($this->getImageCount($style, 'public'), 1, format_string('Image style %style flushed correctly for %wrapper wrapper.', ['%style' => $style->label(), '%wrapper' => 'public']));
// Post flush, expected no image in the 'private' wrapper.
- $this->assertEqual($this->getImageCount($style, 'private'), 0, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style->label(), '%wrapper' => 'private')));
+ $this->assertEqual($this->getImageCount($style, 'private'), 0, format_string('Image style %style flushed correctly for %wrapper wrapper.', ['%style' => $style->label(), '%wrapper' => 'private']));
}
}
diff --git a/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php b/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php
index d03bc3bc998..28a78cda79a 100644
--- a/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php
+++ b/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php
@@ -17,7 +17,7 @@ class ImageStylesPathAndUrlTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('image', 'image_module_test');
+ public static $modules = ['image', 'image_module_test'];
/**
* @var \Drupal\image\ImageStyleInterface
@@ -27,7 +27,7 @@ class ImageStylesPathAndUrlTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->style = ImageStyle::create(array('name' => 'style_foo', 'label' => $this->randomString()));
+ $this->style = ImageStyle::create(['name' => 'style_foo', 'label' => $this->randomString()]);
$this->style->save();
}
diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
index 52cf6c6e5df..b5b42ff6624 100644
--- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
@@ -23,7 +23,7 @@ class ImageThemeFunctionTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('image', 'entity_test');
+ public static $modules = ['image', 'entity_test'];
/**
* Created file entity.
@@ -40,12 +40,12 @@ class ImageThemeFunctionTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'image_test',
'type' => 'image',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'image_test',
@@ -72,7 +72,7 @@ class ImageThemeFunctionTest extends WebTestBase {
$original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME);
// Create a style.
- $style = ImageStyle::create(array('name' => 'test', 'label' => 'Test'));
+ $style = ImageStyle::create(['name' => 'test', 'label' => 'Test']);
$style->save();
$url = file_url_transform_relative($style->buildUrl($original_uri));
@@ -86,17 +86,17 @@ class ImageThemeFunctionTest extends WebTestBase {
// Create the base element that we'll use in the tests below.
$path = $this->randomMachineName();
- $base_element = array(
+ $base_element = [
'#theme' => 'image_formatter',
'#image_style' => 'test',
'#item' => $entity->image_test,
'#url' => Url::fromUri('base:' . $path),
- );
+ ];
// Test using theme_image_formatter() with a NULL value for the alt option.
$element = $base_element;
$this->setRawContent($renderer->renderRoot($element));
- $elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height]', array(':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()));
+ $elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height]', [':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()]);
$this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders with a NULL value for the alt option.');
// Test using theme_image_formatter() without an image title, alt text, or
@@ -104,7 +104,7 @@ class ImageThemeFunctionTest extends WebTestBase {
$element = $base_element;
$element['#item']->alt = '';
$this->setRawContent($renderer->renderRoot($element));
- $elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height and @alt=""]', array(':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()));
+ $elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height and @alt=""]', [':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()]);
$this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders without title, alt, or path options.');
// Link the image to a fragment on the page, and not a full URL.
@@ -112,12 +112,12 @@ class ImageThemeFunctionTest extends WebTestBase {
$element = $base_element;
$element['#url'] = Url::fromRoute('<none>', [], ['fragment' => $fragment]);
$this->setRawContent($renderer->renderRoot($element));
- $elements = $this->xpath('//a[@href=:fragment]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height and @alt=""]', array(
+ $elements = $this->xpath('//a[@href=:fragment]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height and @alt=""]', [
':fragment' => '#' . $fragment,
':url' => $url,
':width' => $image->getWidth(),
':height' => $image->getHeight()
- ));
+ ]);
$this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders a link fragment.');
}
@@ -134,27 +134,27 @@ class ImageThemeFunctionTest extends WebTestBase {
$original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME);
// Create a style.
- $style = ImageStyle::create(array('name' => 'image_test', 'label' => 'Test'));
+ $style = ImageStyle::create(['name' => 'image_test', 'label' => 'Test']);
$style->save();
$url = file_url_transform_relative($style->buildUrl($original_uri));
// Create the base element that we'll use in the tests below.
- $base_element = array(
+ $base_element = [
'#theme' => 'image_style',
'#style_name' => 'image_test',
'#uri' => $original_uri,
- );
+ ];
$element = $base_element;
$this->setRawContent($renderer->renderRoot($element));
- $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url and @alt=""]', array(':url' => $url));
+ $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url and @alt=""]', [':url' => $url]);
$this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly.');
// Test using theme_image_style() with a NULL value for the alt option.
$element = $base_element;
$element['#alt'] = NULL;
$this->setRawContent($renderer->renderRoot($element));
- $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url]', array(':url' => $url));
+ $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url]', [':url' => $url]);
$this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly with a NULL value for the alt option.');
}
@@ -166,55 +166,55 @@ class ImageThemeFunctionTest extends WebTestBase {
$renderer = $this->container->get('renderer');
// Test using alt directly with alt attribute.
- $image_with_alt_property = array(
+ $image_with_alt_property = [
'#theme' => 'image',
'#uri' => '/core/themes/bartik/logo.svg',
'#alt' => 'Regular alt',
'#title' => 'Test title',
'#width' => '50%',
'#height' => '50%',
- '#attributes' => array('class' => 'image-with-regular-alt', 'id' => 'my-img'),
- );
+ '#attributes' => ['class' => 'image-with-regular-alt', 'id' => 'my-img'],
+ ];
$this->setRawContent($renderer->renderRoot($image_with_alt_property));
- $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-regular-alt", ":alt" => "Regular alt"));
+ $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', [":class" => "image-with-regular-alt", ":alt" => "Regular alt"]);
$this->assertEqual(count($elements), 1, 'Regular alt displays correctly');
// Test using alt attribute inside attributes.
- $image_with_alt_attribute_alt_attribute = array(
+ $image_with_alt_attribute_alt_attribute = [
'#theme' => 'image',
'#uri' => '/core/themes/bartik/logo.svg',
'#width' => '50%',
'#height' => '50%',
- '#attributes' => array(
+ '#attributes' => [
'class' => 'image-with-attribute-alt',
'id' => 'my-img',
'title' => 'New test title',
'alt' => 'Attribute alt',
- ),
- );
+ ],
+ ];
$this->setRawContent($renderer->renderRoot($image_with_alt_attribute_alt_attribute));
- $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"));
+ $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', [":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"]);
$this->assertEqual(count($elements), 1, 'Attribute alt displays correctly');
// Test using alt attribute as property and inside attributes.
- $image_with_alt_attribute_both = array(
+ $image_with_alt_attribute_both = [
'#theme' => 'image',
'#uri' => '/core/themes/bartik/logo.svg',
'#width' => '50%',
'#height' => '50%',
'#alt' => 'Kitten sustainable',
- '#attributes' => array(
+ '#attributes' => [
'class' => 'image-with-attribute-alt',
'id' => 'my-img',
'title' => 'New test title',
'alt' => 'Attribute alt',
- ),
- );
+ ],
+ ];
$this->setRawContent($renderer->renderRoot($image_with_alt_attribute_both));
- $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"));
+ $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', [":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"]);
$this->assertEqual(count($elements), 1, 'Attribute alt overrides alt property if both set.');
}
diff --git a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
index f9381d4039b..55cecc0fc09 100644
--- a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
+++ b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
@@ -21,25 +21,25 @@ class RelationshipUserImageDataTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('image', 'image_test_views', 'user');
+ public static $modules = ['image', 'image_test_views', 'user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_image_user_image_data');
+ public static $testViews = ['test_image_user_image_data'];
protected function setUp() {
parent::setUp();
// Create the user profile field and instance.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'user',
'field_name' => 'user_picture',
'type' => 'image',
'translatable' => '0',
- ))->save();
+ ])->save();
FieldConfig::create([
'label' => 'User Picture',
'description' => '',
@@ -49,7 +49,7 @@ class RelationshipUserImageDataTest extends ViewTestBase {
'required' => 0,
])->save();
- ViewTestData::createTestViews(get_class($this), array('image_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['image_test_views']);
}
/**
@@ -84,12 +84,12 @@ class RelationshipUserImageDataTest extends ViewTestBase {
];
$this->assertIdentical($expected, $view->getDependencies());
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'file_managed_user__user_picture_fid' => '2',
- ),
- );
- $column_map = array('file_managed_user__user_picture_fid' => 'file_managed_user__user_picture_fid');
+ ],
+ ];
+ $column_map = ['file_managed_user__user_picture_fid' => 'file_managed_user__user_picture_fid'];
$this->assertIdenticalResultset($view, $expected_result, $column_map);
}
diff --git a/core/modules/image/tests/modules/image_module_test/image_module_test.module b/core/modules/image/tests/modules/image_module_test/image_module_test.module
index df713753568..20c515e9dad 100644
--- a/core/modules/image/tests/modules/image_module_test/image_module_test.module
+++ b/core/modules/image/tests/modules/image_module_test/image_module_test.module
@@ -10,7 +10,7 @@ use Drupal\image\ImageStyleInterface;
function image_module_test_file_download($uri) {
$default_uri = \Drupal::state()->get('image.test_file_download') ?: FALSE;
if ($default_uri == $uri) {
- return array('X-Image-Owned-By' => 'image_module_test');
+ return ['X-Image-Owned-By' => 'image_module_test'];
}
}
diff --git a/core/modules/image/tests/src/Functional/ImageEffectsTest.php b/core/modules/image/tests/src/Functional/ImageEffectsTest.php
index 17c343b1280..6e719d834bf 100644
--- a/core/modules/image/tests/src/Functional/ImageEffectsTest.php
+++ b/core/modules/image/tests/src/Functional/ImageEffectsTest.php
@@ -17,7 +17,7 @@ class ImageEffectsTest extends ToolkitTestBase {
*
* @var array
*/
- public static $modules = array('image', 'image_test', 'image_module_test');
+ public static $modules = ['image', 'image_test', 'image_module_test'];
/**
* The image effect manager.
@@ -35,11 +35,11 @@ class ImageEffectsTest extends ToolkitTestBase {
* Test the image_resize_effect() function.
*/
function testResizeEffect() {
- $this->assertImageEffect('image_resize', array(
+ $this->assertImageEffect('image_resize', [
'width' => 1,
'height' => 2,
- ));
- $this->assertToolkitOperationsCalled(array('resize'));
+ ]);
+ $this->assertToolkitOperationsCalled(['resize']);
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
@@ -52,11 +52,11 @@ class ImageEffectsTest extends ToolkitTestBase {
*/
function testScaleEffect() {
// @todo: need to test upscaling.
- $this->assertImageEffect('image_scale', array(
+ $this->assertImageEffect('image_scale', [
'width' => 10,
'height' => 10,
- ));
- $this->assertToolkitOperationsCalled(array('scale'));
+ ]);
+ $this->assertToolkitOperationsCalled(['scale']);
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
@@ -69,12 +69,12 @@ class ImageEffectsTest extends ToolkitTestBase {
*/
function testCropEffect() {
// @todo should test the keyword offsets.
- $this->assertImageEffect('image_crop', array(
+ $this->assertImageEffect('image_crop', [
'anchor' => 'top-1',
'width' => 3,
'height' => 4,
- ));
- $this->assertToolkitOperationsCalled(array('crop'));
+ ]);
+ $this->assertToolkitOperationsCalled(['crop']);
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
@@ -89,10 +89,10 @@ class ImageEffectsTest extends ToolkitTestBase {
*/
function testConvertEffect() {
// Test jpeg.
- $this->assertImageEffect('image_convert', array(
+ $this->assertImageEffect('image_convert', [
'extension' => 'jpeg',
- ));
- $this->assertToolkitOperationsCalled(array('convert'));
+ ]);
+ $this->assertToolkitOperationsCalled(['convert']);
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
@@ -103,11 +103,11 @@ class ImageEffectsTest extends ToolkitTestBase {
* Test the image_scale_and_crop_effect() function.
*/
function testScaleAndCropEffect() {
- $this->assertImageEffect('image_scale_and_crop', array(
+ $this->assertImageEffect('image_scale_and_crop', [
'width' => 5,
'height' => 10,
- ));
- $this->assertToolkitOperationsCalled(array('scale_and_crop'));
+ ]);
+ $this->assertToolkitOperationsCalled(['scale_and_crop']);
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
@@ -119,8 +119,8 @@ class ImageEffectsTest extends ToolkitTestBase {
* Test the image_desaturate_effect() function.
*/
function testDesaturateEffect() {
- $this->assertImageEffect('image_desaturate', array());
- $this->assertToolkitOperationsCalled(array('desaturate'));
+ $this->assertImageEffect('image_desaturate', []);
+ $this->assertToolkitOperationsCalled(['desaturate']);
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
@@ -132,11 +132,11 @@ class ImageEffectsTest extends ToolkitTestBase {
*/
function testRotateEffect() {
// @todo: need to test with 'random' => TRUE
- $this->assertImageEffect('image_rotate', array(
+ $this->assertImageEffect('image_rotate', [
'degrees' => 90,
'bgcolor' => '#fff',
- ));
- $this->assertToolkitOperationsCalled(array('rotate'));
+ ]);
+ $this->assertToolkitOperationsCalled(['rotate']);
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
@@ -195,7 +195,7 @@ class ImageEffectsTest extends ToolkitTestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertImageEffect($effect_name, array $data) {
- $effect = $this->manager->createInstance($effect_name, array('data' => $data));
+ $effect = $this->manager->createInstance($effect_name, ['data' => $data]);
return $this->assertTrue($effect->applyEffect($this->image), 'Function returned the expected value.');
}
diff --git a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php
index dfbc76ea876..0764954b33e 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php
@@ -30,7 +30,7 @@ abstract class ImageFieldTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'image', 'field_ui', 'image_module_test');
+ public static $modules = ['node', 'image', 'field_ui', 'image_module_test'];
/**
* An user with permissions to administer content types and image styles.
@@ -44,11 +44,11 @@ abstract class ImageFieldTestBase extends BrowserTestBase {
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
- $this->adminUser = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer node fields', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles', 'administer node display'));
+ $this->adminUser = $this->drupalCreateUser(['access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer node fields', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles', 'administer node display']);
$this->drupalLogin($this->adminUser);
}
@@ -63,9 +63,9 @@ abstract class ImageFieldTestBase extends BrowserTestBase {
* The type of node to create.
*/
function previewNodeImage($image, $field_name, $type) {
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
- );
+ ];
$edit['files[' . $field_name . '_0]'] = drupal_realpath($image->uri);
$this->drupalPostForm('node/add/' . $type, $edit, t('Preview'));
}
@@ -83,9 +83,9 @@ abstract class ImageFieldTestBase extends BrowserTestBase {
* The alt text for the image. Use if the field settings require alt text.
*/
function uploadNodeImage($image, $field_name, $type, $alt = '') {
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
- );
+ ];
$edit['files[' . $field_name . '_0]'] = drupal_realpath($image->uri);
$this->drupalPostForm('node/add/' . $type, $edit, t('Save and publish'));
if ($alt) {
@@ -94,7 +94,7 @@ abstract class ImageFieldTestBase extends BrowserTestBase {
}
// Retrieve ID of the newly created node from the current URL.
- $matches = array();
+ $matches = [];
preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
return isset($matches[1]) ? $matches[1] : FALSE;
}
diff --git a/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php b/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php
index 74743db49eb..7c3b94d494b 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php
@@ -17,12 +17,12 @@ class ImageFieldWidgetTest extends ImageFieldTestBase {
$field_name = strtolower($this->randomMachineName());
$min_resolution = 50;
$max_resolution = 100;
- $field_settings = array(
+ $field_settings = [
'max_resolution' => $max_resolution . 'x' . $max_resolution,
'min_resolution' => $min_resolution . 'x' . $min_resolution,
'alt_field' => 0,
- );
- $this->createImageField($field_name, 'article', array(), $field_settings, array(), array(), 'Image test on [site:name]');
+ ];
+ $this->createImageField($field_name, 'article', [], $field_settings, [], [], 'Image test on [site:name]');
$this->drupalGet('node/add/article');
$this->assertNotEqual(0, count($this->xpath('//div[contains(@class, "field--widget-image-image")]')), 'Image field widget found on add/node page', 'Browser');
$this->assertNotEqual(0, count($this->xpath('//input[contains(@accept, "image/*")]')), 'Image field widget limits accepted files.', 'Browser');
diff --git a/core/modules/image/tests/src/Kernel/ImageFieldCreationTrait.php b/core/modules/image/tests/src/Kernel/ImageFieldCreationTrait.php
index a8fe5895f59..851b424bfb6 100644
--- a/core/modules/image/tests/src/Kernel/ImageFieldCreationTrait.php
+++ b/core/modules/image/tests/src/Kernel/ImageFieldCreationTrait.php
@@ -30,14 +30,14 @@ trait ImageFieldCreationTrait {
* @param string $description
* (optional) A description for the field. Defaults to ''.
*/
- protected function createImageField($name, $type_name, $storage_settings = array(), $field_settings = array(), $widget_settings = array(), $formatter_settings = array(), $description = '') {
- FieldStorageConfig::create(array(
+ protected function createImageField($name, $type_name, $storage_settings = [], $field_settings = [], $widget_settings = [], $formatter_settings = [], $description = '') {
+ FieldStorageConfig::create([
'field_name' => $name,
'entity_type' => 'node',
'type' => 'image',
'settings' => $storage_settings,
'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1,
- ))->save();
+ ])->save();
$field_config = FieldConfig::create([
'field_name' => $name,
@@ -51,17 +51,17 @@ trait ImageFieldCreationTrait {
$field_config->save();
entity_get_form_display('node', $type_name, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'image_image',
'settings' => $widget_settings,
- ))
+ ])
->save();
entity_get_display('node', $type_name, 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'image',
'settings' => $formatter_settings,
- ))
+ ])
->save();
return $field_config;
diff --git a/core/modules/image/tests/src/Kernel/ImageFormatterTest.php b/core/modules/image/tests/src/Kernel/ImageFormatterTest.php
index d1b132eccb9..cd8a45b3e93 100644
--- a/core/modules/image/tests/src/Kernel/ImageFormatterTest.php
+++ b/core/modules/image/tests/src/Kernel/ImageFormatterTest.php
@@ -21,7 +21,7 @@ class ImageFormatterTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('file', 'image');
+ public static $modules = ['file', 'image'];
/**
* @var string
@@ -52,18 +52,18 @@ class ImageFormatterTest extends FieldKernelTestBase {
$this->installConfig(['field']);
$this->installEntitySchema('entity_test');
$this->installEntitySchema('file');
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('file', ['file_usage']);
$this->entityType = 'entity_test';
$this->bundle = $this->entityType;
$this->fieldName = Unicode::strtolower($this->randomMachineName());
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => $this->entityType,
'field_name' => $this->fieldName,
'type' => 'image',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entityType,
'field_name' => $this->fieldName,
diff --git a/core/modules/image/tests/src/Kernel/ImageItemTest.php b/core/modules/image/tests/src/Kernel/ImageItemTest.php
index dea453469f8..f7a13054508 100644
--- a/core/modules/image/tests/src/Kernel/ImageItemTest.php
+++ b/core/modules/image/tests/src/Kernel/ImageItemTest.php
@@ -23,7 +23,7 @@ class ImageItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('file', 'image');
+ public static $modules = ['file', 'image'];
/**
* Created file entity.
@@ -41,14 +41,14 @@ class ImageItemTest extends FieldKernelTestBase {
parent::setUp();
$this->installEntitySchema('file');
- $this->installSchema('file', array('file_usage'));
+ $this->installSchema('file', ['file_usage']);
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'image_test',
'type' => 'image',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'image_test',
@@ -114,11 +114,11 @@ class ImageItemTest extends FieldKernelTestBase {
// Delete the image and try to save the entity again.
$this->image->delete();
- $entity = EntityTest::create(array('mame' => $this->randomMachineName()));
+ $entity = EntityTest::create(['mame' => $this->randomMachineName()]);
$entity->save();
// Test image item properties.
- $expected = array('target_id', 'entity', 'alt', 'title', 'width', 'height');
+ $expected = ['target_id', 'entity', 'alt', 'title', 'width', 'height'];
$properties = $entity->getFieldDefinition('image_test')->getFieldStorageDefinition()->getPropertyDefinitions();
$this->assertEqual(array_keys($properties), $expected);
diff --git a/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php b/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php
index 10cc68df0a8..d9381407d90 100644
--- a/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php
+++ b/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php
@@ -28,9 +28,9 @@ class MigrateImageCacheTest extends MigrateDrupal6TestBase {
*/
public function testMissingTable() {
$this->sourceDatabase->update('system')
- ->fields(array(
+ ->fields([
'status' => 0,
- ))
+ ])
->condition('name', 'imagecache')
->condition('type', 'module')
->execute();
diff --git a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
index 0903218e02d..534a4120c4b 100644
--- a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
+++ b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
@@ -17,7 +17,7 @@ class MigrateImageStylesTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('image');
+ public static $modules = ['image'];
/**
* {@inheritdoc}
diff --git a/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php b/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php
index bb91de8a939..55251d1fb2d 100644
--- a/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php
+++ b/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php
@@ -38,7 +38,7 @@ class ImageStylesTest extends MigrateSqlSourceTestBase {
'isid' => 1,
'weight' => 1,
'name' => 'image_desaturate',
- 'data' => serialize(array()),
+ 'data' => serialize([]),
],
];
diff --git a/core/modules/image/tests/src/Kernel/Views/ImageViewsDataTest.php b/core/modules/image/tests/src/Kernel/Views/ImageViewsDataTest.php
index c2f8fd8e723..a324d5ead34 100644
--- a/core/modules/image/tests/src/Kernel/Views/ImageViewsDataTest.php
+++ b/core/modules/image/tests/src/Kernel/Views/ImageViewsDataTest.php
@@ -19,7 +19,7 @@ class ImageViewsDataTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('image', 'file', 'views', 'entity_test', 'user', 'field');
+ public static $modules = ['image', 'file', 'views', 'entity_test', 'user', 'field'];
/**
* Tests views data generated for image field relationship.
@@ -29,16 +29,16 @@ class ImageViewsDataTest extends ViewsKernelTestBase {
*/
public function testRelationshipViewsData() {
// Create image field to entity_test.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_base_image',
'type' => 'image',
- ))->save();
- FieldConfig::create(array(
+ ])->save();
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_base_image',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Check the generated views data.
$views_data = Views::viewsData()->get('entity_test__field_base_image');
$relationship = $views_data['field_base_image_target_id']['relationship'];
@@ -59,16 +59,16 @@ class ImageViewsDataTest extends ViewsKernelTestBase {
$this->assertEqual($relationship['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]);
// Create image field to entity_test_mul.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test_mul',
'field_name' => 'field_data_image',
'type' => 'image',
- ))->save();
- FieldConfig::create(array(
+ ])->save();
+ FieldConfig::create([
'entity_type' => 'entity_test_mul',
'field_name' => 'field_data_image',
'bundle' => 'entity_test_mul',
- ))->save();
+ ])->save();
// Check the generated views data.
$views_data = Views::viewsData()->get('entity_test_mul__field_data_image');
$relationship = $views_data['field_data_image_target_id']['relationship'];
diff --git a/core/modules/image/tests/src/Unit/ImageStyleTest.php b/core/modules/image/tests/src/Unit/ImageStyleTest.php
index 26dd2258a01..bc954b3cc46 100644
--- a/core/modules/image/tests/src/Unit/ImageStyleTest.php
+++ b/core/modules/image/tests/src/Unit/ImageStyleTest.php
@@ -44,7 +44,7 @@ class ImageStyleTest extends UnitTestCase {
* @return \Drupal\image\ImageStyleInterface
* The mocked image style.
*/
- protected function getImageStyleMock($image_effect_id, $image_effect, $stubs = array()) {
+ protected function getImageStyleMock($image_effect_id, $image_effect, $stubs = []) {
$effectManager = $this->getMockBuilder('\Drupal\image\ImageEffectManager')
->disableOriginalConstructor()
->getMock();
@@ -52,17 +52,17 @@ class ImageStyleTest extends UnitTestCase {
->method('createInstance')
->with($image_effect_id)
->will($this->returnValue($image_effect));
- $default_stubs = array(
+ $default_stubs = [
'getImageEffectPluginManager',
'fileUriScheme',
'fileUriTarget',
'fileDefaultScheme',
- );
+ ];
$image_style = $this->getMockBuilder('\Drupal\image\Entity\ImageStyle')
- ->setConstructorArgs(array(
- array('effects' => array($image_effect_id => array('id' => $image_effect_id))),
+ ->setConstructorArgs([
+ ['effects' => [$image_effect_id => ['id' => $image_effect_id]]],
$this->entityTypeId,
- ))
+ ])
->setMethods(array_merge($default_stubs, $stubs))
->getMock();
@@ -71,13 +71,13 @@ class ImageStyleTest extends UnitTestCase {
->will($this->returnValue($effectManager));
$image_style->expects($this->any())
->method('fileUriScheme')
- ->will($this->returnCallback(array($this, 'fileUriScheme')));
+ ->will($this->returnCallback([$this, 'fileUriScheme']));
$image_style->expects($this->any())
->method('fileUriTarget')
- ->will($this->returnCallback(array($this, 'fileUriTarget')));
+ ->will($this->returnCallback([$this, 'fileUriTarget']));
$image_style->expects($this->any())
->method('fileDefaultScheme')
- ->will($this->returnCallback(array($this, 'fileDefaultScheme')));
+ ->will($this->returnCallback([$this, 'fileDefaultScheme']));
return $image_style;
}
@@ -106,7 +106,7 @@ class ImageStyleTest extends UnitTestCase {
$image_effect_id = $this->randomMachineName();
$logger = $this->getMockBuilder('\Psr\Log\LoggerInterface')->getMock();
$image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
- ->setConstructorArgs(array(array(), $image_effect_id, array(), $logger))
+ ->setConstructorArgs([[], $image_effect_id, [], $logger])
->getMock();
$image_effect->expects($this->any())
->method('getDerivativeExtension')
@@ -114,7 +114,7 @@ class ImageStyleTest extends UnitTestCase {
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
- $extensions = array('jpeg', 'gif', 'png');
+ $extensions = ['jpeg', 'gif', 'png'];
foreach ($extensions as $extension) {
$extensionReturned = $image_style->getDerivativeExtension($extension);
$this->assertEquals($extensionReturned, 'png');
@@ -129,7 +129,7 @@ class ImageStyleTest extends UnitTestCase {
$image_effect_id = $this->randomMachineName();
$logger = $this->getMockBuilder('\Psr\Log\LoggerInterface')->getMock();
$image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
- ->setConstructorArgs(array(array(), $image_effect_id, array(), $logger))
+ ->setConstructorArgs([[], $image_effect_id, [], $logger])
->getMock();
$image_effect->expects($this->any())
->method('getDerivativeExtension')
@@ -141,7 +141,7 @@ class ImageStyleTest extends UnitTestCase {
// Image style that doesn't change the extension.
$image_effect_id = $this->randomMachineName();
$image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
- ->setConstructorArgs(array(array(), $image_effect_id, array(), $logger))
+ ->setConstructorArgs([[], $image_effect_id, [], $logger])
->getMock();
$image_effect->expects($this->any())
->method('getDerivativeExtension')
@@ -162,13 +162,13 @@ class ImageStyleTest extends UnitTestCase {
// Image style that changes the extension.
$image_effect_id = $this->randomMachineName();
$image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
- ->setConstructorArgs(array(array(), $image_effect_id, array(), $logger))
+ ->setConstructorArgs([[], $image_effect_id, [], $logger])
->getMock();
$image_effect->expects($this->any())
->method('getDerivativeExtension')
->will($this->returnValue('png'));
- $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, array('getPrivateKey', 'getHashSalt'));
+ $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
$image_style->expects($this->any())
->method('getPrivateKey')
->will($this->returnValue($private_key));
@@ -184,13 +184,13 @@ class ImageStyleTest extends UnitTestCase {
// Image style that doesn't change the extension.
$image_effect_id = $this->randomMachineName();
$image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
- ->setConstructorArgs(array(array(), $image_effect_id, array(), $logger))
+ ->setConstructorArgs([[], $image_effect_id, [], $logger])
->getMock();
$image_effect->expects($this->any())
->method('getDerivativeExtension')
->will($this->returnArgument(0));
- $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, array('getPrivateKey', 'getHashSalt'));
+ $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
$image_style->expects($this->any())
->method('getPrivateKey')
->will($this->returnValue($private_key));
diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index b5a8ec6fc63..a55e65a23cb 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -19,33 +19,33 @@ use Drupal\Core\Template\Attribute;
*/
function template_preprocess_language_negotiation_configure_form(&$variables) {
$form =& $variables['form'];
- $variables['language_types'] = array();
+ $variables['language_types'] = [];
foreach ($form['#language_types'] as $type) {
- $header = array(
+ $header = [
t('Detection method'),
t('Description'),
t('Enabled'),
t('Weight'),
- );
+ ];
// If there is at least one operation enabled show the operation column.
if ($form[$type]['#show_operations']) {
$header[] = t('Operations');
}
- $table = array(
+ $table = [
'#type' => 'table',
'#header' => $header,
- '#attributes' => array('id' => 'language-negotiation-methods-' . $type),
- '#tabledrag' => array(
- array(
+ '#attributes' => ['id' => 'language-negotiation-methods-' . $type],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'language-method-weight-' . $type,
- ),
- ),
- );
+ ],
+ ],
+ ];
foreach ($form[$type]['title'] as $id => $element) {
// Do not take form control structures.
@@ -53,11 +53,11 @@ function template_preprocess_language_negotiation_configure_form(&$variables) {
$table[$id]['#attributes']['class'][] = 'draggable';
$table[$id]['#weight'] = $element['#weight'];
- $table[$id]['title'] = array(
+ $table[$id]['title'] = [
'#prefix' => '<strong>',
$form[$type]['title'][$id],
'#suffix' => '</strong>',
- );
+ ];
$table[$id]['description'] = $form[$type]['description'][$id];
$table[$id]['enabled'] = $form[$type]['enabled'][$id];
$table[$id]['weight'] = $form[$type]['weight'][$id];
@@ -77,7 +77,7 @@ function template_preprocess_language_negotiation_configure_form(&$variables) {
$configurable = isset($form[$type]['configurable']) ? $form[$type]['configurable'] : NULL;
unset($form[$type]['configurable']);
- $variables['language_types'][] = array(
+ $variables['language_types'][] = [
'type' => $type,
'title' => $form[$type]['#title'],
'description' => $form[$type]['#description'],
@@ -85,7 +85,7 @@ function template_preprocess_language_negotiation_configure_form(&$variables) {
'table' => $table,
'children' => $form[$type],
'attributes' => new Attribute(),
- );
+ ];
// Prevent the type from rendering with the remaining form child elements.
unset($form[$type]);
}
@@ -107,42 +107,42 @@ function template_preprocess_language_content_settings_table(&$variables) {
// Add a render element representing the bundle language settings table.
$element = $variables['element'];
- $header = array(
- array(
+ $header = [
+ [
'data' => $element['#bundle_label'],
- 'class' => array('bundle'),
- ),
- array(
+ 'class' => ['bundle'],
+ ],
+ [
'data' => t('Configuration'),
- 'class' => array('operations'),
- ),
- );
+ 'class' => ['operations'],
+ ],
+ ];
- $rows = array();
+ $rows = [];
foreach (Element::children($element) as $bundle) {
- $rows[$bundle] = array(
- 'data' => array(
- array(
- 'data' => array(
+ $rows[$bundle] = [
+ 'data' => [
+ [
+ 'data' => [
'#prefix' => '<label>',
'#suffix' => '</label>',
'#plain_text' => $element[$bundle]['settings']['#label'],
- ),
- 'class' => array('bundle'),
- ),
- array(
+ ],
+ 'class' => ['bundle'],
+ ],
+ [
'data' => $element[$bundle]['settings'],
- 'class' => array('operations'),
- ),
- ),
- 'class' => array('bundle-settings'),
- );
+ 'class' => ['operations'],
+ ],
+ ],
+ 'class' => ['bundle-settings'],
+ ];
}
$variables['title'] = $element['#title'];
- $variables['build'] = array(
+ $variables['build'] = [
'#header' => $header,
'#rows' => $rows,
'#type' => 'table',
- );
+ ];
}
diff --git a/core/modules/language/language.api.php b/core/modules/language/language.api.php
index aaaa5a3dd6a..ff04a8e71c2 100644
--- a/core/modules/language/language.api.php
+++ b/core/modules/language/language.api.php
@@ -35,17 +35,17 @@
* @ingroup language_negotiation
*/
function hook_language_types_info() {
- return array(
- 'custom_language_type' => array(
+ return [
+ 'custom_language_type' => [
'name' => t('Custom language'),
'description' => t('A custom language type.'),
'locked' => FALSE,
- ),
- 'fixed_custom_language_type' => array(
+ ],
+ 'fixed_custom_language_type' => [
'locked' => TRUE,
- 'fixed' => array('custom_language_negotiation_method'),
- ),
- );
+ 'fixed' => ['custom_language_negotiation_method'],
+ ],
+ ];
}
/**
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 516f54fb7b1..8066aa9194c 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -29,42 +29,42 @@ function language_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.language':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Language module allows you to configure the languages used on your site, and provides information for the <a href=":content">Content Translation</a>, <a href=":interface">Interface Translation</a>, and <a href=":configuration">Configuration Translation</a> modules, if they are enabled. For more information, see the <a href=":doc_url">online documentation for the Language module</a>.', array(':doc_url' => 'https://www.drupal.org/documentation/modules/language', ':content' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', array('name' => 'content_translation')) : '#', ':interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', array('name' => 'locale')) : '#', ':configuration' => (\Drupal::moduleHandler()->moduleExists('config_translation')) ? \Drupal::url('help.page', array('name' => 'config_translation')) : '#')) . '</p>';
+ $output .= '<p>' . t('The Language module allows you to configure the languages used on your site, and provides information for the <a href=":content">Content Translation</a>, <a href=":interface">Interface Translation</a>, and <a href=":configuration">Configuration Translation</a> modules, if they are enabled. For more information, see the <a href=":doc_url">online documentation for the Language module</a>.', [':doc_url' => 'https://www.drupal.org/documentation/modules/language', ':content' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', ['name' => 'content_translation']) : '#', ':interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', ['name' => 'locale']) : '#', ':configuration' => (\Drupal::moduleHandler()->moduleExists('config_translation')) ? \Drupal::url('help.page', ['name' => 'config_translation']) : '#']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Adding languages') . '</dt>';
- $output .= '<dd>' . t('You can add languages on the <a href=":language_list">Languages</a> page by selecting <em>Add language</em> and choosing a language from the drop-down menu. This language is then displayed in the languages list, where it can be configured further. If the <a href=":interface">Interface translation module</a> is enabled, and the <em>translation server</em> is set as a translation source, then the interface translation for this language is automatically downloaded as well.', array(':language_list' => \Drupal::url('entity.configurable_language.collection'), ':interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', array('name' => 'locale')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('You can add languages on the <a href=":language_list">Languages</a> page by selecting <em>Add language</em> and choosing a language from the drop-down menu. This language is then displayed in the languages list, where it can be configured further. If the <a href=":interface">Interface translation module</a> is enabled, and the <em>translation server</em> is set as a translation source, then the interface translation for this language is automatically downloaded as well.', [':language_list' => \Drupal::url('entity.configurable_language.collection'), ':interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', ['name' => 'locale']) : '#']) . '</dd>';
$output .= '<dt>' . t('Adding custom languages') . '</dt>';
$output .= '<dd>' . t('You can add a language that is not provided in the drop-down list by choosing <em>Custom language</em> at the end of the list. You then have to configure its language code, name, and direction in the form provided.') . '</dd>';
$output .= '<dt>' . t('Configuring content languages') . '</dt>';
- $output .= '<dd>' . t('By default, content is created in the site\'s default language and no language selector is displayed on content creation pages. On the <a href=":content_language">Content language</a> page you can customize the language configuration for any supported content entity on your site (for example for content types or menu links). After choosing an entity, you are provided with a drop-down menu to set the default language and a check-box to display language selectors.', array(':content_language' => \Drupal::url('language.content_settings_page'))) . '</dd>';
+ $output .= '<dd>' . t('By default, content is created in the site\'s default language and no language selector is displayed on content creation pages. On the <a href=":content_language">Content language</a> page you can customize the language configuration for any supported content entity on your site (for example for content types or menu links). After choosing an entity, you are provided with a drop-down menu to set the default language and a check-box to display language selectors.', [':content_language' => \Drupal::url('language.content_settings_page')]) . '</dd>';
$output .= '<dt>' . t('Adding a language switcher block') . '</dt>';
- $output .= '<dd>' . t('If the Block module is enabled, then you can add a language switcher block on the <a href=":blocks">Block layout</a> page to allow users to switch between languages.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
+ $output .= '<dd>' . t('If the Block module is enabled, then you can add a language switcher block on the <a href=":blocks">Block layout</a> page to allow users to switch between languages.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
$output .= '<dt>' . t('Making a block visible per language') . '</dt>';
- $output .= '<dd>' . t('If the Block module is enabled, then the Language module allows you to set the visibility of a block based on selected languages on the <a href=":blocks">Block layout</a> page.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
+ $output .= '<dd>' . t('If the Block module is enabled, then the Language module allows you to set the visibility of a block based on selected languages on the <a href=":blocks">Block layout</a> page.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
$output .= '<dt>' . t('Choosing user languages') . '</dt>';
$output .= '<dd>' . t('Users can choose a <em>Site language</em> on their profile page. This language is used for email messages, and can be used by modules to determine a user\'s language. It can also be used for interface text, if the <em>User</em> method is enabled as a <em>Detection and selection</em> method (see below). Administrative users can choose a separate <em>Administration pages language</em> for the interface text on administration pages. This configuration is only available on the user\'s profile page if the <em>Account administration pages</em> method is enabled (see below).') . '</dd>';
$output .= '<dt>' . t('Language detection and selection') . '</dt>';
- $output .= '<dd>' . t('The <a href=":detection">Detection and selection</a> page provides several methods for deciding which language is used for displaying interface text. When a method detects and selects an interface language, then the following methods in the list are not applied. You can order them by importance, with your preferred method at the top of the list, followed by one or several fall-back methods.', array(':detection' => \Drupal::url('language.negotiation')));
+ $output .= '<dd>' . t('The <a href=":detection">Detection and selection</a> page provides several methods for deciding which language is used for displaying interface text. When a method detects and selects an interface language, then the following methods in the list are not applied. You can order them by importance, with your preferred method at the top of the list, followed by one or several fall-back methods.', [':detection' => \Drupal::url('language.negotiation')]);
$output .= '<ul><li>' . t('<em>URL</em> sets the interface language based on a path prefix or domain (for example specifying <em>de</em> for German would result in URLs like <em>example.com/de/contact</em>). The default language does not require a path prefix, but can have one assigned as well. If the language detection is done by domain name, a domain needs to be specified for each language.') . '</li>';
$output .= '<li>' . t('<em>Session</em> determines the interface language from a request or session parameter (for example <em>example.com?language=de</em> would set the interface language to German based on the use of <em>de</em> as the <em>language</em> parameter).') . '</li>';
$output .= '<li>' . t('<em>User</em> follows the language configuration set on the user\'s profile page.') . '</li>';
- $output .= '<li>' . t('<em>Browser</em> sets the interface language based on the browser\'s language settings. Since browsers use different language codes to refer to the same languages, you can add and edit languages codes to map the browser language codes to the <a href=":language_list">language codes</a> used on your site.', array(':language_list' => \Drupal::url('entity.configurable_language.collection'))) . '</li>';
+ $output .= '<li>' . t('<em>Browser</em> sets the interface language based on the browser\'s language settings. Since browsers use different language codes to refer to the same languages, you can add and edit languages codes to map the browser language codes to the <a href=":language_list">language codes</a> used on your site.', [':language_list' => \Drupal::url('entity.configurable_language.collection')]) . '</li>';
$output .= '<li>' . t('<em>Account administration pages</em> follows the configuration set as <em>Administration pages language</em> on the profile page of an administrative user. This method is similar to the <em>User</em> method, but only sets the interface text language on administration pages, independent of the interface text language on other pages.') . '</li>';
$output .= '<li>' . t('<em>Selected language</em> allows you to specify the site\'s default language or a specific language as the fall-back language. This method should be listed last.') . '</li></ul></dd>';
$output .= '</dl>';
return $output;
case 'entity.configurable_language.collection':
- $output = '<p>' . t('Reorder the configured languages to set their order in the language switcher block and, when editing content, in the list of selectable languages. This ordering does not impact <a href=":detection">detection and selection</a>.', array(':detection' => \Drupal::url('language.negotiation'))) . '</p>';
- $output .= '<p>' . t('The site default language can also be set. It is not recommended to change the default language on a working site. <a href=":language-detection">Configure the Selected language</a> setting on the detection and selection page to change the fallback language for language selection.', array(':language-detection' => \Drupal::url('language.negotiation'))) . '</p>';
+ $output = '<p>' . t('Reorder the configured languages to set their order in the language switcher block and, when editing content, in the list of selectable languages. This ordering does not impact <a href=":detection">detection and selection</a>.', [':detection' => \Drupal::url('language.negotiation')]) . '</p>';
+ $output .= '<p>' . t('The site default language can also be set. It is not recommended to change the default language on a working site. <a href=":language-detection">Configure the Selected language</a> setting on the detection and selection page to change the fallback language for language selection.', [':language-detection' => \Drupal::url('language.negotiation')]) . '</p>';
return $output;
case 'language.add':
return '<p>' . t('Add a language to be supported by your site. If your desired language is not available, pick <em>Custom language...</em> at the end and provide a language code and other details manually.') . '</p>';
case 'language.negotiation':
- $output = '<p>' . t('Define how to decide which language is used to display page elements (primarily text provided by modules, such as field labels and help text). This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used for that type of text. Be aware that some language detection methods are unreliable under certain conditions, such as browser detection when page-caching is enabled and a user is not currently logged in. Define the order of evaluation of language detection methods on this page. The default language can be changed in the <a href=":admin-change-language">list of languages</a>.', array(':admin-change-language' => \Drupal::url('entity.configurable_language.collection'))) . '</p>';
+ $output = '<p>' . t('Define how to decide which language is used to display page elements (primarily text provided by modules, such as field labels and help text). This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used for that type of text. Be aware that some language detection methods are unreliable under certain conditions, such as browser detection when page-caching is enabled and a user is not currently logged in. Define the order of evaluation of language detection methods on this page. The default language can be changed in the <a href=":admin-change-language">list of languages</a>.', [':admin-change-language' => \Drupal::url('entity.configurable_language.collection')]) . '</p>';
return $output;
case 'language.negotiation_session':
@@ -72,11 +72,11 @@ function language_help($route_name, RouteMatchInterface $route_match) {
return $output;
case 'language.negotiation_browser':
- $output = '<p>' . t('Browsers use different language codes to refer to the same languages. Internally, a best effort is made to determine the correct language based on the code that the browser sends. You can add and edit additional mappings from browser language codes to <a href=":configure-languages">site languages</a>.', array(':configure-languages' => \Drupal::url('entity.configurable_language.collection'))) . '</p>';
+ $output = '<p>' . t('Browsers use different language codes to refer to the same languages. Internally, a best effort is made to determine the correct language based on the code that the browser sends. You can add and edit additional mappings from browser language codes to <a href=":configure-languages">site languages</a>.', [':configure-languages' => \Drupal::url('entity.configurable_language.collection')]) . '</p>';
return $output;
case 'language.negotiation_selected':
- $output = '<p>' . t('Changing the selected language here (and leaving this option as the last among the detection and selection options) is the easiest way to change the fallback language for the website, if you need to change how your site works by default (e.g., when using an empty path prefix or using the default domain). <a href=":admin-change-language">Changing the site\'s default language</a> itself might have other undesired side effects.', array(':admin-change-language' => \Drupal::url('entity.configurable_language.collection'))) . '</p>';
+ $output = '<p>' . t('Changing the selected language here (and leaving this option as the last among the detection and selection options) is the easiest way to change the fallback language for the website, if you need to change how your site works by default (e.g., when using an empty path prefix or using the default domain). <a href=":admin-change-language">Changing the site\'s default language</a> itself might have other undesired side effects.', [':admin-change-language' => \Drupal::url('entity.configurable_language.collection')]) . '</p>';
return $output;
case 'entity.block.edit_form':
@@ -100,16 +100,16 @@ function language_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function language_theme() {
- return array(
- 'language_negotiation_configure_form' => array(
+ return [
+ 'language_negotiation_configure_form' => [
'render element' => 'form',
'file' => 'language.admin.inc',
- ),
- 'language_content_settings_table' => array(
+ ],
+ 'language_content_settings_table' => [
'render element' => 'element',
'file' => 'language.admin.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -123,18 +123,18 @@ function language_element_info_alter(&$type) {
// field.
if (isset($type['language_select'])) {
if (!isset($type['language_select']['#process'])) {
- $type['language_select']['#process'] = array();
+ $type['language_select']['#process'] = [];
}
if (!isset($type['language_select']['#theme_wrappers'])) {
- $type['language_select']['#theme_wrappers'] = array();
+ $type['language_select']['#theme_wrappers'] = [];
}
- $type['language_select']['#process'] = array_merge($type['language_select']['#process'], array(
+ $type['language_select']['#process'] = array_merge($type['language_select']['#process'], [
'language_process_language_select',
- array('Drupal\Core\Render\Element\Select', 'processSelect'),
- array('Drupal\Core\Render\Element\RenderElement', 'processAjaxForm'),
- ));
+ ['Drupal\Core\Render\Element\Select', 'processSelect'],
+ ['Drupal\Core\Render\Element\RenderElement', 'processAjaxForm'],
+ ]);
$type['language_select']['#theme'] = 'select';
- $type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], array('form_element'));
+ $type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], ['form_element']);
$type['language_select']['#languages'] = LanguageInterface::STATE_CONFIGURABLE;
$type['language_select']['#multiple'] = FALSE;
}
@@ -153,9 +153,9 @@ function language_process_language_select($element) {
// Don't set the options if another module (translation for example) already
// set the options.
if (!isset($element['#options'])) {
- $element['#options'] = array();
+ $element['#options'] = [];
foreach (\Drupal::languageManager()->getLanguages($element['#languages']) as $langcode => $language) {
- $element['#options'][$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
+ $element['#options'][$langcode] = $language->isLocked() ? t('- @name -', ['@name' => $language->getName()]) : $language->getName();
}
}
return $element;
@@ -168,7 +168,7 @@ function language_entity_base_field_info_alter(&$fields) {
foreach ($fields as $definition) {
// Set configurable form display for language fields with display options.
if ($definition->getType() == 'language') {
- foreach (array('form', 'view') as $type) {
+ foreach (['form', 'view'] as $type) {
if ($definition->getDisplayOptions($type)) {
// The related configurations will be purged manually on Language
// module uninstallation. @see language_modules_uninstalled().
@@ -201,8 +201,8 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_
}
}
$config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle);
- $config->setDefaultLangcode($form_state->getValue(array($element_name, 'langcode')));
- $config->setLanguageAlterable($form_state->getValue(array($element_name, 'language_alterable')));
+ $config->setDefaultLangcode($form_state->getValue([$element_name, 'langcode']));
+ $config->setLanguageAlterable($form_state->getValue([$element_name, 'language_alterable']));
$config->save();
// Set the form_state languaged with the updated bundle.
@@ -325,7 +325,7 @@ function language_modules_installed($modules) {
// display definitions to make language fields display configurable. Since
// this is not a hard dependency, and thus is not detected by the config
// system, we have to clean up the related values manually.
- foreach (array('entity_view_display', 'entity_form_display') as $key) {
+ foreach (['entity_view_display', 'entity_form_display'] as $key) {
$displays = \Drupal::entityManager()->getStorage($key)->loadMultiple();
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
foreach ($displays as $display) {
@@ -393,7 +393,7 @@ function language_preprocess_block(&$variables) {
function language_get_browser_drupal_langcode_mappings() {
$config = \Drupal::config('language.mappings');
if ($config->isNew()) {
- return array();
+ return [];
}
return $config->get('map');
}
@@ -462,7 +462,7 @@ function language_tour_tips_alter(array &$tour_tips, EntityInterface $entity) {
}
elseif ($tour_tip->get('id') == 'language-continue') {
$additional_continue = '';
- $additional_modules = array();
+ $additional_modules = [];
if (!Drupal::service('module_handler')->moduleExists('locale')) {
$additional_modules[] = Drupal::service('module_handler')->getName('locale');
}
diff --git a/core/modules/language/src/Config/LanguageConfigFactoryOverride.php b/core/modules/language/src/Config/LanguageConfigFactoryOverride.php
index d1dd753ee43..4c60a72a21f 100644
--- a/core/modules/language/src/Config/LanguageConfigFactoryOverride.php
+++ b/core/modules/language/src/Config/LanguageConfigFactoryOverride.php
@@ -88,7 +88,7 @@ class LanguageConfigFactoryOverride extends ConfigFactoryOverrideBase implements
$storage = $this->getStorage($this->language->getId());
return $storage->readMultiple($names);
}
- return array();
+ return [];
}
/**
diff --git a/core/modules/language/src/Config/LanguageConfigOverride.php b/core/modules/language/src/Config/LanguageConfigOverride.php
index 15e4fa60c2e..6effe238fa3 100644
--- a/core/modules/language/src/Config/LanguageConfigOverride.php
+++ b/core/modules/language/src/Config/LanguageConfigOverride.php
@@ -71,7 +71,7 @@ class LanguageConfigOverride extends StorableConfigBase {
* {@inheritdoc}
*/
public function delete() {
- $this->data = array();
+ $this->data = [];
$this->storage->delete($this->name);
Cache::invalidateTags($this->getCacheTags());
$this->isNew = TRUE;
diff --git a/core/modules/language/src/ConfigurableLanguageManager.php b/core/modules/language/src/ConfigurableLanguageManager.php
index 614cf7737cf..de64c4423a7 100644
--- a/core/modules/language/src/ConfigurableLanguageManager.php
+++ b/core/modules/language/src/ConfigurableLanguageManager.php
@@ -168,7 +168,7 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
*/
protected function loadLanguageTypesConfiguration() {
if (!$this->languageTypes) {
- $this->languageTypes = $this->configFactory->get('language.types')->get() ?: array('configurable' => array(), 'all' => parent::getLanguageTypes());
+ $this->languageTypes = $this->configFactory->get('language.types')->get() ?: ['configurable' => [], 'all' => parent::getLanguageTypes()];
}
return $this->languageTypes;
}
@@ -227,7 +227,7 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
// afterwards. This can happen for instance while parsing negotiation
// method definitions.
elseif ($type == LanguageInterface::TYPE_INTERFACE) {
- return new Language(array('id' => LanguageInterface::LANGCODE_SYSTEM));
+ return new Language(['id' => LanguageInterface::LANGCODE_SYSTEM]);
}
}
}
@@ -241,11 +241,11 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
public function reset($type = NULL) {
if (!isset($type)) {
$this->initialized = FALSE;
- $this->negotiatedLanguages = array();
- $this->negotiatedMethods = array();
+ $this->negotiatedLanguages = [];
+ $this->negotiatedMethods = [];
$this->languageTypes = NULL;
$this->languageTypesInfo = NULL;
- $this->languages = array();
+ $this->languages = [];
if ($this->negotiator) {
$this->negotiator->reset();
}
@@ -270,7 +270,7 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
public function setNegotiator(LanguageNegotiatorInterface $negotiator) {
$this->negotiator = $negotiator;
$this->initialized = FALSE;
- $this->negotiatedLanguages = array();
+ $this->negotiatedLanguages = [];
}
/**
@@ -292,7 +292,7 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
// and the configuration entities for languages are not yet fully
// imported.
$default = $this->getDefaultLanguage();
- $languages = array($default->getId() => $default);
+ $languages = [$default->getId() => $default];
$languages += $this->getDefaultLockedLanguages($default->getWeight());
// Load configurable languages on top of the defaults. Ideally this could
@@ -325,7 +325,7 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
*/
public function getNativeLanguages() {
$languages = $this->getLanguages(LanguageInterface::STATE_CONFIGURABLE);
- $natives = array();
+ $natives = [];
$original_language = $this->getConfigOverrideLanguage();
@@ -363,9 +363,9 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
/**
* {@inheritdoc}
*/
- public function getFallbackCandidates(array $context = array()) {
+ public function getFallbackCandidates(array $context = []) {
if ($this->isMultilingual()) {
- $candidates = array();
+ $candidates = [];
if (empty($context['operation']) || $context['operation'] != 'locale_lookup') {
// If the fallback context is not locale_lookup, initialize the
// candidates with languages ordered by weight and add
@@ -379,13 +379,13 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
// The first candidate should always be the desired language if
// specified.
if (!empty($context['langcode'])) {
- $candidates = array($context['langcode'] => $context['langcode']) + $candidates;
+ $candidates = [$context['langcode'] => $context['langcode']] + $candidates;
}
}
// Let other modules hook in and add/change candidates.
$type = 'language_fallback_candidates';
- $types = array();
+ $types = [];
if (!empty($context['operation'])) {
$types[] = $type . '_' . $context['operation'];
}
@@ -415,7 +415,7 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
if (!empty($result)) {
// Allow modules to provide translations for specific links.
$this->moduleHandler->alter('language_switch_links', $result, $type, $url);
- $links = (object) array('links' => $result, 'method_id' => $method_id);
+ $links = (object) ['links' => $result, 'method_id' => $method_id];
break;
}
}
diff --git a/core/modules/language/src/DefaultLanguageItem.php b/core/modules/language/src/DefaultLanguageItem.php
index 0e3889050a1..83deee0daa8 100644
--- a/core/modules/language/src/DefaultLanguageItem.php
+++ b/core/modules/language/src/DefaultLanguageItem.php
@@ -29,7 +29,7 @@ class DefaultLanguageItem extends LanguageItem {
$langcode = $this->getDefaultLangcode($entity);
}
// Always notify otherwise default langcode will not be set correctly.
- $this->setValue(array('value' => $langcode), TRUE);
+ $this->setValue(['value' => $langcode], TRUE);
return $this;
}
diff --git a/core/modules/language/src/Element/LanguageConfiguration.php b/core/modules/language/src/Element/LanguageConfiguration.php
index 07796934e53..63505bb4115 100644
--- a/core/modules/language/src/Element/LanguageConfiguration.php
+++ b/core/modules/language/src/Element/LanguageConfiguration.php
@@ -18,50 +18,50 @@ class LanguageConfiguration extends FormElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
+ return [
'#input' => TRUE,
'#tree' => TRUE,
- '#process' => array(
- array($class, 'processLanguageConfiguration'),
- ),
- );
+ '#process' => [
+ [$class, 'processLanguageConfiguration'],
+ ],
+ ];
}
/**
* Process handler for the language_configuration form element.
*/
public static function processLanguageConfiguration(&$element, FormStateInterface $form_state, &$form) {
- $options = isset($element['#options']) ? $element['#options'] : array();
+ $options = isset($element['#options']) ? $element['#options'] : [];
// Avoid validation failure since we are moving the '#options' key in the
// nested 'language' select element.
unset($element['#options']);
/** @var \Drupal\language\Entity\ContentLanguageSettings $default_config */
$default_config = $element['#default_value'];
- $element['langcode'] = array(
+ $element['langcode'] = [
'#type' => 'select',
'#title' => t('Default language'),
'#options' => $options + static::getDefaultOptions(),
- '#description' => t('Explanation of the language options is found on the <a href=":languages_list_page">languages list page</a>.', array(':languages_list_page' => \Drupal::url('entity.configurable_language.collection'))),
+ '#description' => t('Explanation of the language options is found on the <a href=":languages_list_page">languages list page</a>.', [':languages_list_page' => \Drupal::url('entity.configurable_language.collection')]),
'#default_value' => ($default_config != NULL) ? $default_config->getDefaultLangcode() : LanguageInterface::LANGCODE_SITE_DEFAULT,
- );
+ ];
- $element['language_alterable'] = array(
+ $element['language_alterable'] = [
'#type' => 'checkbox',
'#title' => t('Show language selector on create and edit pages'),
'#default_value' => ($default_config != NULL) ? $default_config->isLanguageAlterable() : FALSE,
- );
+ ];
// Add the entity type and bundle information to the form if they are set.
// They will be used, in the submit handler, to generate the names of the
// configuration entities that will store the settings and are a way to uniquely
// identify the entity.
$language = $form_state->get('language') ?: [];
- $language += array(
- $element['#name'] => array(
+ $language += [
+ $element['#name'] => [
'entity_type' => $element['#entity_information']['entity_type'],
'bundle' => $element['#entity_information']['bundle'],
- ),
- );
+ ],
+ ];
$form_state->set('language', $language);
// Do not add the submit callback for the language content settings page,
@@ -89,15 +89,15 @@ class LanguageConfiguration extends FormElement {
* An array containing the default options.
*/
protected static function getDefaultOptions() {
- $language_options = array(
- LanguageInterface::LANGCODE_SITE_DEFAULT => t("Site's default language (@language)", array('@language' => static::languageManager()->getDefaultLanguage()->getName())),
+ $language_options = [
+ LanguageInterface::LANGCODE_SITE_DEFAULT => t("Site's default language (@language)", ['@language' => static::languageManager()->getDefaultLanguage()->getName()]),
'current_interface' => t('Interface text language selected for page'),
'authors_default' => t("Author's preferred language"),
- );
+ ];
$languages = static::languageManager()->getLanguages(LanguageInterface::STATE_ALL);
foreach ($languages as $langcode => $language) {
- $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
+ $language_options[$langcode] = $language->isLocked() ? t('- @name -', ['@name' => $language->getName()]) : $language->getName();
}
return $language_options;
diff --git a/core/modules/language/src/Entity/ConfigurableLanguage.php b/core/modules/language/src/Entity/ConfigurableLanguage.php
index b19c328c890..c277a85bd76 100644
--- a/core/modules/language/src/Entity/ConfigurableLanguage.php
+++ b/core/modules/language/src/Entity/ConfigurableLanguage.php
@@ -246,18 +246,18 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
if (!isset($standard_languages[$langcode])) {
// Drupal does not know about this language, so we set its values with the
// best guess. The user will be able to edit afterwards.
- return static::create(array(
+ return static::create([
'id' => $langcode,
'label' => $langcode,
- ));
+ ]);
}
else {
// A known predefined language, details will be filled in properly.
- return static::create(array(
+ return static::create([
'id' => $langcode,
'label' => $standard_languages[$langcode][0],
'direction' => isset($standard_languages[$langcode][2]) ? $standard_languages[$langcode][2] : static::DIRECTION_LTR,
- ));
+ ]);
}
}
diff --git a/core/modules/language/src/EventSubscriber/ConfigSubscriber.php b/core/modules/language/src/EventSubscriber/ConfigSubscriber.php
index 4159c377bbe..103f9128d39 100644
--- a/core/modules/language/src/EventSubscriber/ConfigSubscriber.php
+++ b/core/modules/language/src/EventSubscriber/ConfigSubscriber.php
@@ -141,7 +141,7 @@ class ConfigSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[ConfigEvents::SAVE][] = array('onConfigSave', 0);
+ $events[ConfigEvents::SAVE][] = ['onConfigSave', 0];
return $events;
}
diff --git a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php
index 0656bdc6bc1..fd925dd8551 100644
--- a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php
+++ b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php
@@ -90,7 +90,7 @@ class LanguageRequestSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
- $events[KernelEvents::REQUEST][] = array('onKernelRequestLanguage', 255);
+ $events[KernelEvents::REQUEST][] = ['onKernelRequestLanguage', 255];
return $events;
}
diff --git a/core/modules/language/src/Form/ContentLanguageSettingsForm.php b/core/modules/language/src/Form/ContentLanguageSettingsForm.php
index b86f7bc5d2b..a11552993b4 100644
--- a/core/modules/language/src/Form/ContentLanguageSettingsForm.php
+++ b/core/modules/language/src/Form/ContentLanguageSettingsForm.php
@@ -52,11 +52,11 @@ class ContentLanguageSettingsForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$entity_types = $this->entityManager->getDefinitions();
- $labels = array();
- $default = array();
+ $labels = [];
+ $default = [];
$bundles = $this->entityManager->getAllBundleInfo();
- $language_configuration = array();
+ $language_configuration = [];
foreach ($entity_types as $entity_type_id => $entity_type) {
if (!$entity_type instanceof ContentEntityTypeInterface || !$entity_type->hasKey('langcode') || !isset($bundles[$entity_type_id])) {
continue;
@@ -76,65 +76,65 @@ class ContentLanguageSettingsForm extends FormBase {
asort($labels);
- $form = array(
+ $form = [
'#labels' => $labels,
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'language/drupal.language.admin',
- ),
- ),
- '#attributes' => array(
+ ],
+ ],
+ '#attributes' => [
'class' => 'language-content-settings-form',
- ),
- );
+ ],
+ ];
- $form['entity_types'] = array(
+ $form['entity_types'] = [
'#title' => $this->t('Custom language settings'),
'#type' => 'checkboxes',
'#options' => $labels,
'#default_value' => $default,
- );
+ ];
- $form['settings'] = array('#tree' => TRUE);
+ $form['settings'] = ['#tree' => TRUE];
foreach ($labels as $entity_type_id => $label) {
$entity_type = $entity_types[$entity_type_id];
- $form['settings'][$entity_type_id] = array(
+ $form['settings'][$entity_type_id] = [
'#title' => $label,
'#type' => 'container',
'#entity_type' => $entity_type_id,
'#theme' => 'language_content_settings_table',
'#bundle_label' => $entity_type->getBundleLabel() ?: $label,
- '#states' => array(
- 'visible' => array(
- ':input[name="entity_types[' . $entity_type_id . ']"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="entity_types[' . $entity_type_id . ']"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
- $form['settings'][$entity_type_id][$bundle]['settings'] = array(
+ $form['settings'][$entity_type_id][$bundle]['settings'] = [
'#type' => 'item',
'#label' => $bundle_info['label'],
- 'language' => array(
+ 'language' => [
'#type' => 'language_configuration',
- '#entity_information' => array(
+ '#entity_information' => [
'entity_type' => $entity_type_id,
'bundle' => $bundle,
- ),
+ ],
'#default_value' => $language_configuration[$entity_type_id][$bundle],
- ),
- );
+ ],
+ ];
}
}
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save configuration'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
diff --git a/core/modules/language/src/Form/LanguageAddForm.php b/core/modules/language/src/Form/LanguageAddForm.php
index ad5ed61aa6d..5b9f15c2e25 100644
--- a/core/modules/language/src/Form/LanguageAddForm.php
+++ b/core/modules/language/src/Form/LanguageAddForm.php
@@ -30,50 +30,50 @@ class LanguageAddForm extends LanguageFormBase {
$predefined_languages['custom'] = $this->t('Custom language...');
$predefined_default = $form_state->getValue('predefined_langcode', key($predefined_languages));
- $form['predefined_langcode'] = array(
+ $form['predefined_langcode'] = [
'#type' => 'select',
'#title' => $this->t('Language name'),
'#default_value' => $predefined_default,
'#options' => $predefined_languages,
- );
- $form['predefined_submit'] = array(
+ ];
+ $form['predefined_submit'] = [
'#type' => 'submit',
'#value' => $this->t('Add language'),
'#name' => 'add_language',
- '#limit_validation_errors' => array(array('predefined_langcode'), array('predefined_submit')),
- '#states' => array(
- 'invisible' => array(
- 'select#edit-predefined-langcode' => array('value' => 'custom'),
- ),
- ),
- '#validate' => array('::validatePredefined'),
- '#submit' => array('::submitForm', '::save'),
+ '#limit_validation_errors' => [['predefined_langcode'], ['predefined_submit']],
+ '#states' => [
+ 'invisible' => [
+ 'select#edit-predefined-langcode' => ['value' => 'custom'],
+ ],
+ ],
+ '#validate' => ['::validatePredefined'],
+ '#submit' => ['::submitForm', '::save'],
'#button_type' => 'primary',
- );
+ ];
- $custom_language_states_conditions = array(
- 'select#edit-predefined-langcode' => array('value' => 'custom'),
- );
- $form['custom_language'] = array(
+ $custom_language_states_conditions = [
+ 'select#edit-predefined-langcode' => ['value' => 'custom'],
+ ];
+ $form['custom_language'] = [
'#type' => 'container',
- '#states' => array(
+ '#states' => [
'visible' => $custom_language_states_conditions,
- ),
- );
+ ],
+ ];
$this->commonForm($form['custom_language']);
- $form['custom_language']['langcode']['#states'] = array(
+ $form['custom_language']['langcode']['#states'] = [
'required' => $custom_language_states_conditions,
- );
- $form['custom_language']['label']['#states'] = array(
+ ];
+ $form['custom_language']['label']['#states'] = [
'required' => $custom_language_states_conditions,
- );
- $form['custom_language']['submit'] = array(
+ ];
+ $form['custom_language']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Add custom language'),
'#name' => 'add_custom_language',
- '#validate' => array('::validateCustom'),
- '#submit' => array('::submitForm', '::save'),
- );
+ '#validate' => ['::validateCustom'],
+ '#submit' => ['::submitForm', '::save'],
+ ];
return $form;
}
@@ -84,14 +84,14 @@ class LanguageAddForm extends LanguageFormBase {
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
- $t_args = array('%language' => $this->entity->label(), '%langcode' => $this->entity->id());
+ $t_args = ['%language' => $this->entity->label(), '%langcode' => $this->entity->id()];
$this->logger('language')->notice('The %language (%langcode) language has been created.', $t_args);
drupal_set_message($this->t('The language %language has been created and can now be used.', $t_args));
if ($this->moduleHandler->moduleExists('block')) {
// Tell the user they have the option to add a language switcher block
// to their theme so they can switch between the languages.
- drupal_set_message($this->t('Use one of the language switcher blocks to allow site visitors to switch between languages. You can enable these blocks on the <a href=":block-admin">block administration page</a>.', array(':block-admin' => $this->url('block.admin_display'))));
+ drupal_set_message($this->t('Use one of the language switcher blocks to allow site visitors to switch between languages. You can enable these blocks on the <a href=":block-admin">block administration page</a>.', [':block-admin' => $this->url('block.admin_display')]));
}
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
}
@@ -101,7 +101,7 @@ class LanguageAddForm extends LanguageFormBase {
*/
public function actions(array $form, FormStateInterface $form_state) {
// No actions needed.
- return array();
+ return [];
}
/**
@@ -114,7 +114,7 @@ class LanguageAddForm extends LanguageFormBase {
$this->validateCommon($form['custom_language'], $form_state);
if ($language = $this->languageManager->getLanguage($langcode)) {
- $form_state->setErrorByName('langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode)));
+ $form_state->setErrorByName('langcode', $this->t('The language %language (%langcode) already exists.', ['%language' => $language->getName(), '%langcode' => $langcode]));
}
}
else {
@@ -132,7 +132,7 @@ class LanguageAddForm extends LanguageFormBase {
}
else {
if ($language = $this->languageManager->getLanguage($langcode)) {
- $form_state->setErrorByName('predefined_langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode)));
+ $form_state->setErrorByName('predefined_langcode', $this->t('The language %language (%langcode) already exists.', ['%language' => $language->getName(), '%langcode' => $langcode]));
}
}
}
diff --git a/core/modules/language/src/Form/LanguageDeleteForm.php b/core/modules/language/src/Form/LanguageDeleteForm.php
index d2226e8e13a..6113c1fe6b0 100644
--- a/core/modules/language/src/Form/LanguageDeleteForm.php
+++ b/core/modules/language/src/Form/LanguageDeleteForm.php
@@ -27,14 +27,14 @@ class LanguageDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
protected function getDeletionMessage() {
- return $this->t('The %language (%langcode) language has been removed.', array('%language' => $this->entity->label(), '%langcode' => $this->entity->id()));
+ return $this->t('The %language (%langcode) language has been removed.', ['%language' => $this->entity->label(), '%langcode' => $this->entity->id()]);
}
/**
* {@inheritdoc}
*/
public function logDeletionMessage() {
- $this->logger('language')->notice('The %language (%langcode) language has been removed.', array('%language' => $this->entity->label(), '%langcode' => $this->entity->id()));
+ $this->logger('language')->notice('The %language (%langcode) language has been removed.', ['%language' => $this->entity->label(), '%langcode' => $this->entity->id()]);
}
}
diff --git a/core/modules/language/src/Form/LanguageEditForm.php b/core/modules/language/src/Form/LanguageEditForm.php
index bb0b7d76d1f..234994dbb49 100644
--- a/core/modules/language/src/Form/LanguageEditForm.php
+++ b/core/modules/language/src/Form/LanguageEditForm.php
@@ -29,12 +29,12 @@ class LanguageEditForm extends LanguageFormBase {
* {@inheritdoc}
*/
public function actions(array $form, FormStateInterface $form_state) {
- $actions['submit'] = array(
+ $actions['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save language'),
- '#validate' => array('::validateCommon'),
- '#submit' => array('::submitForm', '::save'),
- );
+ '#validate' => ['::validateCommon'],
+ '#submit' => ['::submitForm', '::save'],
+ ];
return $actions;
}
@@ -44,7 +44,7 @@ class LanguageEditForm extends LanguageFormBase {
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
- $this->logger('language')->notice('The %language (%langcode) language has been updated.', array('%language' => $this->entity->label(), '%langcode' => $this->entity->id()));
+ $this->logger('language')->notice('The %language (%langcode) language has been updated.', ['%language' => $this->entity->label(), '%langcode' => $this->entity->id()]);
}
}
diff --git a/core/modules/language/src/Form/LanguageFormBase.php b/core/modules/language/src/Form/LanguageFormBase.php
index 00771621bee..8c8f5fac699 100644
--- a/core/modules/language/src/Form/LanguageFormBase.php
+++ b/core/modules/language/src/Form/LanguageFormBase.php
@@ -47,45 +47,45 @@ abstract class LanguageFormBase extends EntityForm {
/* @var $language \Drupal\language\ConfigurableLanguageInterface */
$language = $this->entity;
if ($language->getId()) {
- $form['langcode_view'] = array(
+ $form['langcode_view'] = [
'#type' => 'item',
'#title' => $this->t('Language code'),
'#markup' => $language->id()
- );
- $form['langcode'] = array(
+ ];
+ $form['langcode'] = [
'#type' => 'value',
'#value' => $language->id()
- );
+ ];
}
else {
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'textfield',
'#title' => $this->t('Language code'),
'#maxlength' => 12,
'#required' => TRUE,
'#default_value' => '',
'#disabled' => FALSE,
- '#description' => $this->t('Use language codes as <a href=":w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', array(':w3ctags' => 'http://www.w3.org/International/articles/language-tags/')),
- );
+ '#description' => $this->t('Use language codes as <a href=":w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', [':w3ctags' => 'http://www.w3.org/International/articles/language-tags/']),
+ ];
}
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Language name'),
'#maxlength' => 64,
'#default_value' => $language->label(),
'#required' => TRUE,
- );
- $form['direction'] = array(
+ ];
+ $form['direction'] = [
'#type' => 'radios',
'#title' => $this->t('Direction'),
'#required' => TRUE,
'#description' => $this->t('Direction that text in this language is presented.'),
'#default_value' => $language->getDirection(),
- '#options' => array(
+ '#options' => [
LanguageInterface::DIRECTION_LTR => $this->t('Left to right'),
LanguageInterface::DIRECTION_RTL => $this->t('Right to left'),
- ),
- );
+ ],
+ ];
return $form;
}
@@ -96,13 +96,13 @@ abstract class LanguageFormBase extends EntityForm {
public function validateCommon(array $form, FormStateInterface $form_state) {
// Ensure sane field values for langcode and name.
if (!isset($form['langcode_view']) && !preg_match('@^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$@', $form_state->getValue('langcode'))) {
- $form_state->setErrorByName('langcode', $this->t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', array(
+ $form_state->setErrorByName('langcode', $this->t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', [
'%field' => $form['langcode']['#title'],
':url' => 'http://www.w3.org/International/articles/language-tags/',
- )));
+ ]));
}
if ($form_state->getValue('label') != Html::escape($form_state->getValue('label'))) {
- $form_state->setErrorByName('label', $this->t('%field cannot contain any markup.', array('%field' => $form['label']['#title'])));
+ $form_state->setErrorByName('label', $this->t('%field cannot contain any markup.', ['%field' => $form['label']['#title']]));
}
}
diff --git a/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php b/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php
index df5052c0852..1a409462fd4 100644
--- a/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php
+++ b/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php
@@ -32,7 +32,7 @@ class NegotiationBrowserDeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete %browser_langcode?', array('%browser_langcode' => $this->browserLangcode));
+ return $this->t('Are you sure you want to delete %browser_langcode?', ['%browser_langcode' => $this->browserLangcode]);
}
/**
@@ -68,9 +68,9 @@ class NegotiationBrowserDeleteForm extends ConfirmFormBase {
->clear('map.' . $this->browserLangcode)
->save();
- $args = array(
+ $args = [
'%browser' => $this->browserLangcode,
- );
+ ];
$this->logger('language')->notice('The browser language detection mapping for the %browser browser language code has been deleted.', $args);
diff --git a/core/modules/language/src/Form/NegotiationBrowserForm.php b/core/modules/language/src/Form/NegotiationBrowserForm.php
index dfbdabbebea..5535fe07d0b 100644
--- a/core/modules/language/src/Form/NegotiationBrowserForm.php
+++ b/core/modules/language/src/Form/NegotiationBrowserForm.php
@@ -60,12 +60,12 @@ class NegotiationBrowserForm extends ConfigFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form = array();
+ $form = [];
// Initialize a language list to the ones available, including English.
$languages = $this->languageManager->getLanguages();
- $existing_languages = array();
+ $existing_languages = [];
foreach ($languages as $langcode => $language) {
$existing_languages[$langcode] = $language->getName();
}
@@ -77,10 +77,10 @@ class NegotiationBrowserForm extends ConfigFormBase {
$language_options = $this->languageManager->getStandardLanguageListWithoutConfigured();
}
else {
- $language_options = array(
+ $language_options = [
(string) $this->t('Existing languages') => $existing_languages,
(string) $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured(),
- );
+ ];
}
$form['mappings'] = [
@@ -96,24 +96,24 @@ class NegotiationBrowserForm extends ConfigFormBase {
$mappings = $this->language_get_browser_drupal_langcode_mappings();
foreach ($mappings as $browser_langcode => $drupal_langcode) {
- $form['mappings'][$browser_langcode] = array(
- 'browser_langcode' => array(
+ $form['mappings'][$browser_langcode] = [
+ 'browser_langcode' => [
'#title' => $this->t('Browser language code'),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#default_value' => $browser_langcode,
'#size' => 20,
'#required' => TRUE,
- ),
- 'drupal_langcode' => array(
+ ],
+ 'drupal_langcode' => [
'#title' => $this->t('Site language'),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => $language_options,
'#default_value' => $drupal_langcode,
'#required' => TRUE,
- ),
- );
+ ],
+ ];
// Operations column.
$form['mappings'][$browser_langcode]['operations'] = [
'#type' => 'operations',
@@ -126,22 +126,22 @@ class NegotiationBrowserForm extends ConfigFormBase {
}
// Add empty row.
- $form['new_mapping'] = array(
+ $form['new_mapping'] = [
'#type' => 'details',
'#title' => $this->t('Add a new mapping'),
'#tree' => TRUE,
- );
- $form['new_mapping']['browser_langcode'] = array(
+ ];
+ $form['new_mapping']['browser_langcode'] = [
'#type' => 'textfield',
'#title' => $this->t('Browser language code'),
- '#description' => $this->t('Use language codes as <a href=":w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', array(':w3ctags' => 'http://www.w3.org/International/articles/language-tags/')),
+ '#description' => $this->t('Use language codes as <a href=":w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', [':w3ctags' => 'http://www.w3.org/International/articles/language-tags/']),
'#size' => 20,
- );
- $form['new_mapping']['drupal_langcode'] = array(
+ ];
+ $form['new_mapping']['drupal_langcode'] = [
'#type' => 'select',
'#title' => $this->t('Site language'),
'#options' => $language_options,
- );
+ ];
return parent::buildForm($form, $form_state);
}
@@ -151,7 +151,7 @@ class NegotiationBrowserForm extends ConfigFormBase {
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
// Array to check if all browser language codes are unique.
- $unique_values = array();
+ $unique_values = [];
// Check all mappings.
if ($form_state->hasValue('mappings')) {
@@ -207,7 +207,7 @@ class NegotiationBrowserForm extends ConfigFormBase {
protected function language_get_browser_drupal_langcode_mappings() {
$config = $this->config('language.mappings');
if ($config->isNew()) {
- return array();
+ return [];
}
return $config->get('map');
}
diff --git a/core/modules/language/src/Form/NegotiationConfigureForm.php b/core/modules/language/src/Form/NegotiationConfigureForm.php
index 41f57a32f66..c1333e6a27a 100644
--- a/core/modules/language/src/Form/NegotiationConfigureForm.php
+++ b/core/modules/language/src/Form/NegotiationConfigureForm.php
@@ -124,12 +124,12 @@ class NegotiationConfigureForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$configurable = $this->languageTypes->get('configurable');
- $form = array(
+ $form = [
'#theme' => 'language_negotiation_configure_form',
'#language_types_info' => $this->languageManager->getDefinedLanguageTypesInfo(),
'#language_negotiation_info' => $this->negotiator->getNegotiationMethods(),
- );
- $form['#language_types'] = array();
+ ];
+ $form['#language_types'] = [];
foreach ($form['#language_types_info'] as $type => $info) {
// Show locked language types only if they are configurable.
@@ -142,12 +142,12 @@ class NegotiationConfigureForm extends ConfigFormBase {
$this->configureFormTable($form, $type);
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => $this->t('Save settings'),
- );
+ ];
return $form;
}
@@ -159,17 +159,17 @@ class NegotiationConfigureForm extends ConfigFormBase {
$configurable_types = $form['#language_types'];
$stored_values = $this->languageTypes->get('configurable');
- $customized = array();
- $method_weights_type = array();
+ $customized = [];
+ $method_weights_type = [];
foreach ($configurable_types as $type) {
$customized[$type] = in_array($type, $stored_values);
- $method_weights = array();
- $enabled_methods = $form_state->getValue(array($type, 'enabled'));
+ $method_weights = [];
+ $enabled_methods = $form_state->getValue([$type, 'enabled']);
$enabled_methods[LanguageNegotiationSelected::METHOD_ID] = TRUE;
- $method_weights_input = $form_state->getValue(array($type, 'weight'));
- if ($form_state->hasValue(array($type, 'configurable'))) {
- $customized[$type] = !$form_state->isValueEmpty(array($type, 'configurable'));
+ $method_weights_input = $form_state->getValue([$type, 'weight']);
+ if ($form_state->hasValue([$type, 'configurable'])) {
+ $customized[$type] = !$form_state->isValueEmpty([$type, 'configurable']);
}
foreach ($method_weights_input as $method_id => $weight) {
@@ -216,33 +216,33 @@ class NegotiationConfigureForm extends ConfigFormBase {
protected function configureFormTable(array &$form, $type) {
$info = $form['#language_types_info'][$type];
- $table_form = array(
- '#title' => $this->t('@type language detection', array('@type' => $info['name'])),
+ $table_form = [
+ '#title' => $this->t('@type language detection', ['@type' => $info['name']]),
'#tree' => TRUE,
'#description' => $info['description'],
- '#language_negotiation_info' => array(),
+ '#language_negotiation_info' => [],
'#show_operations' => FALSE,
- 'weight' => array('#tree' => TRUE),
- );
+ 'weight' => ['#tree' => TRUE],
+ ];
// Only show configurability checkbox for the unlocked language types.
if (empty($info['locked'])) {
$configurable = $this->languageTypes->get('configurable');
- $table_form['configurable'] = array(
+ $table_form['configurable'] = [
'#type' => 'checkbox',
- '#title' => $this->t('Customize %language_name language detection to differ from Interface text language detection settings', array('%language_name' => $info['name'])),
+ '#title' => $this->t('Customize %language_name language detection to differ from Interface text language detection settings', ['%language_name' => $info['name']]),
'#default_value' => in_array($type, $configurable),
- '#attributes' => array('class' => array('language-customization-checkbox')),
- '#attached' => array(
- 'library' => array(
+ '#attributes' => ['class' => ['language-customization-checkbox']],
+ '#attached' => [
+ 'library' => [
'language/drupal.language.admin'
- ),
- ),
- );
+ ],
+ ],
+ ];
}
$negotiation_info = $form['#language_negotiation_info'];
- $enabled_methods = $this->languageTypes->get('negotiation.' . $type . '.enabled') ?: array();
- $methods_weight = $this->languageTypes->get('negotiation.' . $type . '.method_weights') ?: array();
+ $enabled_methods = $this->languageTypes->get('negotiation.' . $type . '.enabled') ?: [];
+ $methods_weight = $this->languageTypes->get('negotiation.' . $type . '.method_weights') ?: [];
// Add missing data to the methods lists.
foreach ($negotiation_info as $method_id => $method) {
@@ -272,44 +272,44 @@ class NegotiationConfigureForm extends ConfigFormBase {
$table_form['#language_negotiation_info'][$method_id] = $method;
$method_name = $method['name'];
- $table_form['weight'][$method_id] = array(
+ $table_form['weight'][$method_id] = [
'#type' => 'weight',
- '#title' => $this->t('Weight for @title language detection method', array('@title' => Unicode::strtolower($method_name))),
+ '#title' => $this->t('Weight for @title language detection method', ['@title' => Unicode::strtolower($method_name)]),
'#title_display' => 'invisible',
'#default_value' => $weight,
- '#attributes' => array('class' => array("language-method-weight-$type")),
+ '#attributes' => ['class' => ["language-method-weight-$type"]],
'#delta' => 20,
- );
+ ];
- $table_form['title'][$method_id] = array('#plain_text' => $method_name);
+ $table_form['title'][$method_id] = ['#plain_text' => $method_name];
- $table_form['enabled'][$method_id] = array(
+ $table_form['enabled'][$method_id] = [
'#type' => 'checkbox',
- '#title' => $this->t('Enable @title language detection method', array('@title' => Unicode::strtolower($method_name))),
+ '#title' => $this->t('Enable @title language detection method', ['@title' => Unicode::strtolower($method_name)]),
'#title_display' => 'invisible',
'#default_value' => $enabled,
- );
+ ];
if ($method_id === LanguageNegotiationSelected::METHOD_ID) {
$table_form['enabled'][$method_id]['#default_value'] = TRUE;
- $table_form['enabled'][$method_id]['#attributes'] = array('disabled' => 'disabled');
+ $table_form['enabled'][$method_id]['#attributes'] = ['disabled' => 'disabled'];
}
- $table_form['description'][$method_id] = array('#markup' => $method['description']);
+ $table_form['description'][$method_id] = ['#markup' => $method['description']];
- $config_op = array();
+ $config_op = [];
if (isset($method['config_route_name'])) {
- $config_op['configure'] = array(
+ $config_op['configure'] = [
'title' => $this->t('Configure'),
'url' => Url::fromRoute($method['config_route_name']),
- );
+ ];
// If there is at least one operation enabled show the operation
// column.
$table_form['#show_operations'] = TRUE;
}
- $table_form['operation'][$method_id] = array(
+ $table_form['operation'][$method_id] = [
'#type' => 'operations',
'#links' => $config_op,
- );
+ ];
}
}
$form[$type] = $table_form;
@@ -324,7 +324,7 @@ class NegotiationConfigureForm extends ConfigFormBase {
*/
protected function disableLanguageSwitcher(array $language_types) {
$theme = $this->themeHandler->getDefault();
- $blocks = $this->blockStorage->loadByProperties(array('theme' => $theme));
+ $blocks = $this->blockStorage->loadByProperties(['theme' => $theme]);
foreach ($language_types as $language_type) {
foreach ($blocks as $block) {
if ($block->getPluginId() == 'language_block:' . $language_type) {
diff --git a/core/modules/language/src/Form/NegotiationSelectedForm.php b/core/modules/language/src/Form/NegotiationSelectedForm.php
index bba40ee87eb..d4f1191862b 100644
--- a/core/modules/language/src/Form/NegotiationSelectedForm.php
+++ b/core/modules/language/src/Form/NegotiationSelectedForm.php
@@ -30,12 +30,12 @@ class NegotiationSelectedForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('language.negotiation');
- $form['selected_langcode'] = array(
+ $form['selected_langcode'] = [
'#type' => 'language_select',
'#title' => $this->t('Language'),
'#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT,
'#default_value' => $config->get('selected_langcode'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/language/src/Form/NegotiationSessionForm.php b/core/modules/language/src/Form/NegotiationSessionForm.php
index 2e944727160..b7ec4508f54 100644
--- a/core/modules/language/src/Form/NegotiationSessionForm.php
+++ b/core/modules/language/src/Form/NegotiationSessionForm.php
@@ -29,12 +29,12 @@ class NegotiationSessionForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('language.negotiation');
- $form['language_negotiation_session_param'] = array(
+ $form['language_negotiation_session_param'] = [
'#title' => $this->t('Request/session parameter'),
'#type' => 'textfield',
'#default_value' => $config->get('session.parameter'),
'#description' => $this->t('Name of the request/session parameter used to determine the desired language.'),
- );
+ ];
$form_state->setRedirect('language.negotiation');
diff --git a/core/modules/language/src/Form/NegotiationUrlForm.php b/core/modules/language/src/Form/NegotiationUrlForm.php
index d5ad8639e0f..6f44f602033 100644
--- a/core/modules/language/src/Form/NegotiationUrlForm.php
+++ b/core/modules/language/src/Form/NegotiationUrlForm.php
@@ -66,63 +66,63 @@ class NegotiationUrlForm extends ConfigFormBase {
global $base_url;
$config = $this->config('language.negotiation');
- $form['language_negotiation_url_part'] = array(
+ $form['language_negotiation_url_part'] = [
'#title' => $this->t('Part of the URL that determines language'),
'#type' => 'radios',
- '#options' => array(
+ '#options' => [
LanguageNegotiationUrl::CONFIG_PATH_PREFIX => $this->t('Path prefix'),
LanguageNegotiationUrl::CONFIG_DOMAIN => $this->t('Domain'),
- ),
+ ],
'#default_value' => $config->get('url.source'),
- );
+ ];
- $form['prefix'] = array(
+ $form['prefix'] = [
'#type' => 'details',
'#tree' => TRUE,
'#title' => $this->t('Path prefix configuration'),
'#open' => TRUE,
'#description' => $this->t('Language codes or other custom text to use as a path prefix for URL language detection. For the selected fallback language, this value may be left blank. <strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "deutsch" as the path prefix code for German results in URLs like "example.com/deutsch/contact".'),
- '#states' => array(
- 'visible' => array(
- ':input[name="language_negotiation_url_part"]' => array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="language_negotiation_url_part"]' => [
'value' => (string) LanguageNegotiationUrl::CONFIG_PATH_PREFIX,
- ),
- ),
- ),
- );
- $form['domain'] = array(
+ ],
+ ],
+ ],
+ ];
+ $form['domain'] = [
'#type' => 'details',
'#tree' => TRUE,
'#title' => $this->t('Domain configuration'),
'#open' => TRUE,
'#description' => $this->t('The domain names to use for these languages. <strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "de.example.com" as language domain for German will result in a URL like "http://de.example.com/contact".'),
- '#states' => array(
- 'visible' => array(
- ':input[name="language_negotiation_url_part"]' => array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="language_negotiation_url_part"]' => [
'value' => (string) LanguageNegotiationUrl::CONFIG_DOMAIN,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$languages = $this->languageManager->getLanguages();
$prefixes = $config->get('url.prefixes');
$domains = $config->get('url.domains');
foreach ($languages as $langcode => $language) {
- $t_args = array('%language' => $language->getName(), '%langcode' => $language->getId());
- $form['prefix'][$langcode] = array(
+ $t_args = ['%language' => $language->getName(), '%langcode' => $language->getId()];
+ $form['prefix'][$langcode] = [
'#type' => 'textfield',
'#title' => $language->isDefault() ? $this->t('%language (%langcode) path prefix (Default language)', $t_args) : $this->t('%language (%langcode) path prefix', $t_args),
'#maxlength' => 64,
'#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '',
'#field_prefix' => $base_url . '/',
- );
- $form['domain'][$langcode] = array(
+ ];
+ $form['domain'][$langcode] = [
'#type' => 'textfield',
- '#title' => $this->t('%language (%langcode) domain', array('%language' => $language->getName(), '%langcode' => $language->getId())),
+ '#title' => $this->t('%language (%langcode) domain', ['%language' => $language->getName(), '%langcode' => $language->getId()]),
'#maxlength' => 128,
'#default_value' => isset($domains[$langcode]) ? $domains[$langcode] : '',
- );
+ ];
}
$form_state->setRedirect('language.negotiation');
@@ -143,7 +143,7 @@ class NegotiationUrlForm extends ConfigFormBase {
$default_langcode = $this->languageManager->getDefaultLanguage()->getId();
}
foreach ($languages as $langcode => $language) {
- $value = $form_state->getValue(array('prefix', $langcode));
+ $value = $form_state->getValue(['prefix', $langcode]);
if ($value === '') {
if (!($default_langcode == $langcode) && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
// Throw a form error if the prefix is blank for a non-default language,
@@ -161,35 +161,35 @@ class NegotiationUrlForm extends ConfigFormBase {
elseif (isset($count[$value]) && $count[$value] > 1) {
// Throw a form error if there are two languages with the same
// domain/prefix.
- $form_state->setErrorByName("prefix][$langcode", $this->t('The prefix for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value)));
+ $form_state->setErrorByName("prefix][$langcode", $this->t('The prefix for %language, %value, is not unique.', ['%language' => $language->getName(), '%value' => $value]));
}
}
// Count repeated values for uniqueness check.
$count = array_count_values($form_state->getValue('domain'));
foreach ($languages as $langcode => $language) {
- $value = $form_state->getValue(array('domain', $langcode));
+ $value = $form_state->getValue(['domain', $langcode]);
if ($value === '') {
if ($form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) {
// Throw a form error if the domain is blank for a non-default language,
// although it is required for selected negotiation type.
- $form_state->setErrorByName("domain][$langcode", $this->t('The domain may not be left blank for %language.', array('%language' => $language->getName())));
+ $form_state->setErrorByName("domain][$langcode", $this->t('The domain may not be left blank for %language.', ['%language' => $language->getName()]));
}
}
elseif (isset($count[$value]) && $count[$value] > 1) {
// Throw a form error if there are two languages with the same
// domain/domain.
- $form_state->setErrorByName("domain][$langcode", $this->t('The domain for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value)));
+ $form_state->setErrorByName("domain][$langcode", $this->t('The domain for %language, %value, is not unique.', ['%language' => $language->getName(), '%value' => $value]));
}
}
// Domain names should not contain protocol and/or ports.
foreach ($languages as $langcode => $language) {
- $value = $form_state->getValue(array('domain', $langcode));
+ $value = $form_state->getValue(['domain', $langcode]);
if (!empty($value)) {
// Ensure we have exactly one protocol when checking the hostname.
- $host = 'http://' . str_replace(array('http://', 'https://'), '', $value);
+ $host = 'http://' . str_replace(['http://', 'https://'], '', $value);
if (parse_url($host, PHP_URL_HOST) != $value) {
$form_state->setErrorByName("domain][$langcode", $this->t('The domain for %language may only contain the domain name, not a trailing slash, protocol and/or port.', ['%language' => $language->getName()]));
}
diff --git a/core/modules/language/src/HttpKernel/PathProcessorLanguage.php b/core/modules/language/src/HttpKernel/PathProcessorLanguage.php
index 2e91305e9a1..c4af20c71ed 100644
--- a/core/modules/language/src/HttpKernel/PathProcessorLanguage.php
+++ b/core/modules/language/src/HttpKernel/PathProcessorLanguage.php
@@ -102,7 +102,7 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
if (!isset($this->multilingual)) {
$this->multilingual = $this->languageManager->isMultilingual();
}
@@ -131,7 +131,7 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa
*/
protected function initProcessors($scope) {
$interface = '\Drupal\Core\PathProcessor\\' . Unicode::ucfirst($scope) . 'PathProcessorInterface';
- $this->processors[$scope] = array();
+ $this->processors[$scope] = [];
$weights = [];
foreach ($this->languageManager->getLanguageTypes() as $type) {
foreach ($this->negotiator->getNegotiationMethods($type) as $method_id => $method) {
@@ -174,7 +174,7 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa
* Resets the collected processors instances.
*/
public function reset() {
- $this->processors = array();
+ $this->processors = [];
}
}
diff --git a/core/modules/language/src/LanguageListBuilder.php b/core/modules/language/src/LanguageListBuilder.php
index 5d69f1ff9c2..8d151522043 100644
--- a/core/modules/language/src/LanguageListBuilder.php
+++ b/core/modules/language/src/LanguageListBuilder.php
@@ -71,11 +71,11 @@ class LanguageListBuilder extends DraggableListBuilder {
* {@inheritdoc}
*/
public function load() {
- $entities = $this->storage->loadByProperties(array('locked' => FALSE));
+ $entities = $this->storage->loadByProperties(['locked' => FALSE]);
// Sort the entities using the entity class's sort() method.
// See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
- uasort($entities, array($this->entityType->getClass(), 'sort'));
+ uasort($entities, [$this->entityType->getClass(), 'sort']);
return $entities;
}
@@ -90,10 +90,10 @@ class LanguageListBuilder extends DraggableListBuilder {
* {@inheritdoc}
*/
public function buildHeader() {
- $header = array(
+ $header = [
'label' => t('Name'),
'default' => t('Default'),
- ) + parent::buildHeader();
+ ] + parent::buildHeader();
return $header;
}
@@ -102,14 +102,14 @@ class LanguageListBuilder extends DraggableListBuilder {
*/
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity->label();
- $row['default'] = array(
+ $row['default'] = [
'#type' => 'radio',
- '#parents' => array('site_default_language'),
- '#title' => t('Set @title as default', array('@title' => $entity->label())),
+ '#parents' => ['site_default_language'],
+ '#title' => t('Set @title as default', ['@title' => $entity->label()]),
'#title_display' => 'invisible',
'#return_value' => $entity->id(),
'#id' => 'edit-site-default-language-' . $entity->id(),
- );
+ ];
// Mark the right language as default in the form.
if ($entity->id() == $this->languageManager->getDefaultLanguage()->getId()) {
$row['default']['#default_value'] = $entity->id();
@@ -157,7 +157,7 @@ class LanguageListBuilder extends DraggableListBuilder {
drupal_set_message(t('Configuration saved.'));
// Force the redirection to the page with the language we have just
// selected as default.
- $form_state->setRedirectUrl($this->entities[$new_id]->urlInfo('collection', array('language' => $this->entities[$new_id])));
+ $form_state->setRedirectUrl($this->entities[$new_id]->urlInfo('collection', ['language' => $this->entities[$new_id]]));
}
}
diff --git a/core/modules/language/src/LanguageNegotiator.php b/core/modules/language/src/LanguageNegotiator.php
index 2ae9032973a..d9d4c5deca8 100644
--- a/core/modules/language/src/LanguageNegotiator.php
+++ b/core/modules/language/src/LanguageNegotiator.php
@@ -68,7 +68,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
*
* @var \Drupal\Core\Language\LanguageInterface[]
*/
- protected $negotiatedLanguages = array();
+ protected $negotiatedLanguages = [];
/**
* Constructs a new LanguageNegotiator object.
@@ -105,8 +105,8 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
* {@inheritdoc}
*/
public function reset() {
- $this->negotiatedLanguages = array();
- $this->methods = array();
+ $this->negotiatedLanguages = [];
+ $this->methods = [];
}
/**
@@ -150,7 +150,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
$method_id = static::METHOD_ID;
}
- return array($method_id => $language);
+ return [$method_id => $language];
}
/**
@@ -163,7 +163,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
* An array of enabled detection methods for the provided language type.
*/
protected function getEnabledNegotiators($type) {
- return $this->configFactory->get('language.types')->get('negotiation.' . $type . '.enabled') ?: array();
+ return $this->configFactory->get('language.types')->get('negotiation.' . $type . '.enabled') ?: [];
}
/**
@@ -207,7 +207,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
*/
public function getNegotiationMethodInstance($method_id) {
if (!isset($this->methods[$method_id])) {
- $instance = $this->negotiatorManager->createInstance($method_id, array());
+ $instance = $this->negotiatorManager->createInstance($method_id, []);
$instance->setLanguageManager($this->languageManager);
$instance->setConfig($this->configFactory);
$instance->setCurrentUser($this->currentUser);
@@ -229,7 +229,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
*/
public function isNegotiationMethodEnabled($method_id, $type = NULL) {
$enabled = FALSE;
- $language_types = !empty($type) ? array($type) : $this->languageManager->getLanguageTypes();
+ $language_types = !empty($type) ? [$type] : $this->languageManager->getLanguageTypes();
foreach ($language_types as $type) {
$enabled_methods = $this->getEnabledNegotiators($type);
@@ -297,7 +297,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
$this->negotiatorManager->clearCachedDefinitions();
$this->languageManager->reset();
- $language_types = array();
+ $language_types = [];
$language_types_info = $this->languageManager->getDefinedLanguageTypesInfo();
$method_definitions = $this->getNegotiationMethods();
@@ -316,7 +316,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
// default language negotiation settings, we use the values
// negotiated for the interface language which, should always be
// available.
- $method_weights = array(LanguageNegotiationUI::METHOD_ID);
+ $method_weights = [LanguageNegotiationUI::METHOD_ID];
$method_weights = array_flip($method_weights);
$this->saveConfiguration($type, $method_weights);
}
@@ -330,7 +330,7 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
// If the language type is locked we can just store its default language
// negotiation settings if it has some, since it is not configurable.
if ($has_default_settings) {
- $method_weights = array();
+ $method_weights = [];
// Default settings are in $info['fixed'].
foreach ($info['fixed'] as $weight => $method_id) {
@@ -351,10 +351,10 @@ class LanguageNegotiator implements LanguageNegotiatorInterface {
}
// Store the language type configuration.
- $config = array(
+ $config = [
'configurable' => array_keys(array_filter($language_types)),
'all' => array_keys($language_types),
- );
+ ];
$this->languageManager->saveLanguageTypesConfiguration($config);
}
diff --git a/core/modules/language/src/LanguageServiceProvider.php b/core/modules/language/src/LanguageServiceProvider.php
index 2d2004f51d9..4060f75d371 100644
--- a/core/modules/language/src/LanguageServiceProvider.php
+++ b/core/modules/language/src/LanguageServiceProvider.php
@@ -29,8 +29,8 @@ class LanguageServiceProvider extends ServiceProviderBase {
->addArgument(new Reference('current_user'));
$container->register('path_processor_language', 'Drupal\language\HttpKernel\PathProcessorLanguage')
- ->addTag('path_processor_inbound', array('priority' => 300))
- ->addTag('path_processor_outbound', array('priority' => 100))
+ ->addTag('path_processor_inbound', ['priority' => 300])
+ ->addTag('path_processor_outbound', ['priority' => 100])
->addArgument(new Reference('config.factory'))
->addArgument(new Reference('language_manager'))
->addArgument(new Reference('language_negotiator'))
diff --git a/core/modules/language/src/Plugin/Block/LanguageBlock.php b/core/modules/language/src/Plugin/Block/LanguageBlock.php
index 5c58ac00aeb..8e7ee918d50 100644
--- a/core/modules/language/src/Plugin/Block/LanguageBlock.php
+++ b/core/modules/language/src/Plugin/Block/LanguageBlock.php
@@ -84,22 +84,22 @@ class LanguageBlock extends BlockBase implements ContainerFactoryPluginInterface
* {@inheritdoc}
*/
public function build() {
- $build = array();
+ $build = [];
$route_name = $this->pathMatcher->isFrontPage() ? '<front>' : '<current>';
$type = $this->getDerivativeId();
$links = $this->languageManager->getLanguageSwitchLinks($type, Url::fromRoute($route_name));
if (isset($links->links)) {
- $build = array(
+ $build = [
'#theme' => 'links__language_block',
'#links' => $links->links,
- '#attributes' => array(
- 'class' => array(
+ '#attributes' => [
+ 'class' => [
"language-switcher-{$links->method_id}",
- ),
- ),
+ ],
+ ],
'#set_active_class' => TRUE,
- );
+ ];
}
return $build;
}
diff --git a/core/modules/language/src/Plugin/Condition/Language.php b/core/modules/language/src/Plugin/Condition/Language.php
index d1f3c95cec4..a5b3d41e8c1 100644
--- a/core/modules/language/src/Plugin/Condition/Language.php
+++ b/core/modules/language/src/Plugin/Condition/Language.php
@@ -68,23 +68,23 @@ class Language extends ConditionPluginBase implements ContainerFactoryPluginInte
if ($this->languageManager->isMultilingual()) {
// Fetch languages.
$languages = $this->languageManager->getLanguages();
- $langcodes_options = array();
+ $langcodes_options = [];
foreach ($languages as $language) {
$langcodes_options[$language->getId()] = $language->getName();
}
- $form['langcodes'] = array(
+ $form['langcodes'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Language selection'),
'#default_value' => $this->configuration['langcodes'],
'#options' => $langcodes_options,
'#description' => $this->t('Select languages to enforce. If none are selected, all languages will be allowed.'),
- );
+ ];
}
else {
- $form['langcodes'] = array(
+ $form['langcodes'] = [
'#type' => 'value',
'#default_value' => $this->configuration['langcodes'],
- );
+ ];
}
return parent::buildConfigurationForm($form, $form_state);
}
@@ -111,7 +111,7 @@ class Language extends ConditionPluginBase implements ContainerFactoryPluginInte
$result[$item->getId()] = $item->getName();
}
return $result;
- }, array());
+ }, []);
// If we have more than one language selected, separate them by commas.
if (count($this->configuration['langcodes']) > 1) {
@@ -122,9 +122,9 @@ class Language extends ConditionPluginBase implements ContainerFactoryPluginInte
$languages = array_pop($language_names);
}
if (!empty($this->configuration['negate'])) {
- return t('The language is not @languages.', array('@languages' => $languages));
+ return t('The language is not @languages.', ['@languages' => $languages]);
}
- return t('The language is @languages.', array('@languages' => $languages));
+ return t('The language is @languages.', ['@languages' => $languages]);
}
/**
@@ -144,7 +144,7 @@ class Language extends ConditionPluginBase implements ContainerFactoryPluginInte
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array('langcodes' => array()) + parent::defaultConfiguration();
+ return ['langcodes' => []] + parent::defaultConfiguration();
}
}
diff --git a/core/modules/language/src/Plugin/Derivative/LanguageBlock.php b/core/modules/language/src/Plugin/Derivative/LanguageBlock.php
index 3c108695d00..93cc5b1c98e 100644
--- a/core/modules/language/src/Plugin/Derivative/LanguageBlock.php
+++ b/core/modules/language/src/Plugin/Derivative/LanguageBlock.php
@@ -21,7 +21,7 @@ class LanguageBlock extends DeriverBase {
$configurable_types = $language_manager->getLanguageTypes();
foreach ($configurable_types as $type) {
$this->derivatives[$type] = $base_plugin_definition;
- $this->derivatives[$type]['admin_label'] = t('Language switcher (@type)', array('@type' => $info[$type]['name']));
+ $this->derivatives[$type]['admin_label'] = t('Language switcher (@type)', ['@type' => $info[$type]['name']]);
}
// If there is just one configurable type then change the title of the
// block.
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php
index 6c83e41f6b5..971e907aae3 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php
@@ -81,7 +81,7 @@ class LanguageNegotiationSession extends LanguageNegotiationMethodBase implement
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
if ($request) {
// The following values are not supposed to change during a single page
// request processing.
@@ -124,24 +124,24 @@ class LanguageNegotiationSession extends LanguageNegotiationMethodBase implement
* {@inheritdoc}
*/
public function getLanguageSwitchLinks(Request $request, $type, Url $url) {
- $links = array();
+ $links = [];
$config = $this->config->get('language.negotiation')->get('session');
$param = $config['parameter'];
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $this->languageManager->getCurrentLanguage($type)->getId();
- $query = array();
+ $query = [];
parse_str($request->getQueryString(), $query);
foreach ($this->languageManager->getNativeLanguages() as $language) {
$langcode = $language->getId();
- $links[$langcode] = array(
+ $links[$langcode] = [
// We need to clone the $url object to avoid using the same one for all
// links. When the links are rendered, options are set on the $url
// object, so if we use the same one, they would be set for all links.
'url' => clone $url,
'title' => $language->getName(),
- 'attributes' => array('class' => array('language-link')),
+ 'attributes' => ['class' => ['language-link']],
'query' => $query,
- );
+ ];
if ($language_query != $langcode) {
$links[$langcode]['query'][$param] = $langcode;
}
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
index 25b5484a958..437273b5ce2 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
@@ -80,7 +80,7 @@ class LanguageNegotiationUrl extends LanguageNegotiationMethodBase implements In
if (!empty($config['domains'][$language->getId()])) {
// Ensure that there is exactly one protocol in the URL when
// checking the hostname.
- $host = 'http://' . str_replace(array('http://', 'https://'), '', $config['domains'][$language->getId()]);
+ $host = 'http://' . str_replace(['http://', 'https://'], '', $config['domains'][$language->getId()]);
$host = parse_url($host, PHP_URL_HOST);
if ($http_host == $host) {
$langcode = $language->getId();
@@ -118,7 +118,7 @@ class LanguageNegotiationUrl extends LanguageNegotiationMethodBase implements In
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
$url_scheme = 'http';
$port = 80;
if ($request) {
@@ -151,7 +151,7 @@ class LanguageNegotiationUrl extends LanguageNegotiationMethodBase implements In
// retain it below.
if (!empty($options['base_url'])) {
// The colon in the URL scheme messes up the port checking below.
- $normalized_base_url = str_replace(array('https://', 'http://'), '', $options['base_url']);
+ $normalized_base_url = str_replace(['https://', 'http://'], '', $options['base_url']);
}
// Ask for an absolute URL with our modified base URL.
@@ -191,20 +191,20 @@ class LanguageNegotiationUrl extends LanguageNegotiationMethodBase implements In
* {@inheritdoc}
*/
public function getLanguageSwitchLinks(Request $request, $type, Url $url) {
- $links = array();
+ $links = [];
$query = $request->query->all();
foreach ($this->languageManager->getNativeLanguages() as $language) {
- $links[$language->getId()] = array(
+ $links[$language->getId()] = [
// We need to clone the $url object to avoid using the same one for all
// links. When the links are rendered, options are set on the $url
// object, so if we use the same one, they would be set for all links.
'url' => clone $url,
'title' => $language->getName(),
'language' => $language,
- 'attributes' => array('class' => array('language-link')),
+ 'attributes' => ['class' => ['language-link']],
'query' => $query,
- );
+ ];
}
return $links;
diff --git a/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php b/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php
index a5a50a911da..4d13e9adb4b 100644
--- a/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php
+++ b/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php
@@ -19,7 +19,7 @@ class DefaultLangcode extends Config {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$destination = $row->getDestination();
$langcode = $destination['default_langcode'];
diff --git a/core/modules/language/src/Plugin/migrate/source/Language.php b/core/modules/language/src/Plugin/migrate/source/Language.php
index dc2e0ce38d7..fa6a1996034 100644
--- a/core/modules/language/src/Plugin/migrate/source/Language.php
+++ b/core/modules/language/src/Plugin/migrate/source/Language.php
@@ -17,7 +17,7 @@ class Language extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'language' => $this->t('The language code.'),
'name' => $this->t('The English name of the language.'),
'native' => $this->t('The native name of the language.'),
@@ -29,18 +29,18 @@ class Language extends DrupalSqlBase {
'prefix' => $this->t('Path prefix used for this language.'),
'weight' => $this->t('The language weight when listed.'),
'javascript' => $this->t('Location of the JavaScript translation file.'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'language' => array(
+ return [
+ 'language' => [
'type' => 'string',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettings.php b/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettings.php
index c41b635c3d6..ab9ba838137 100644
--- a/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettings.php
+++ b/core/modules/language/src/Plugin/migrate/source/d6/LanguageContentSettings.php
@@ -19,20 +19,20 @@ class LanguageContentSettings extends DrupalSqlBase {
*/
public function query() {
return $this->select('node_type', 't')
- ->fields('t', array(
+ ->fields('t', [
'type',
- ));
+ ]);
}
/**
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'type' => $this->t('Type'),
'language_content_type' => $this->t('Multilingual support.'),
'i18n_lock_node' => $this->t('Lock language.'),
- );
+ ];
return $fields;
}
diff --git a/core/modules/language/src/Plugin/migrate/source/d7/LanguageContentSettings.php b/core/modules/language/src/Plugin/migrate/source/d7/LanguageContentSettings.php
index 91ed020a3fe..cb748aec223 100644
--- a/core/modules/language/src/Plugin/migrate/source/d7/LanguageContentSettings.php
+++ b/core/modules/language/src/Plugin/migrate/source/d7/LanguageContentSettings.php
@@ -19,20 +19,20 @@ class LanguageContentSettings extends DrupalSqlBase {
*/
public function query() {
return $this->select('node_type', 't')
- ->fields('t', array(
+ ->fields('t', [
'type',
- ));
+ ]);
}
/**
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'type' => $this->t('Type'),
'language_content_type' => $this->t('Multilingual support.'),
'i18n_lock_node' => $this->t('Lock language.'),
- );
+ ];
return $fields;
}
diff --git a/core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php b/core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php
index 20a3532ecfb..97ccf2fd8cf 100644
--- a/core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php
+++ b/core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php
@@ -19,10 +19,10 @@ class EntityTypeWithoutLanguageFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'language',
'language_test',
- );
+ ];
/**
* {@inheritdoc}
@@ -31,9 +31,9 @@ class EntityTypeWithoutLanguageFormTest extends WebTestBase {
parent::setUp();
// Create and log in administrative user.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer languages',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
diff --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
index 93b821d183a..dc3eb260b6a 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
+++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
@@ -20,11 +20,11 @@ class LanguageConfigurationElementTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'node', 'language', 'language_elements_test', 'field_ui');
+ public static $modules = ['taxonomy', 'node', 'language', 'language_elements_test', 'field_ui'];
protected function setUp() {
parent::setUp();
- $user = $this->drupalCreateUser(array('access administration pages', 'administer languages', 'administer content types'));
+ $user = $this->drupalCreateUser(['access administration pages', 'administer languages', 'administer content types']);
$this->drupalLogin($user);
}
@@ -60,12 +60,12 @@ class LanguageConfigurationElementTest extends WebTestBase {
$this->assertFieldChecked('edit-lang-configuration-language-alterable');
// Test if content type settings have been saved.
- $edit = array(
+ $edit = [
'name' => 'Page',
'type' => 'page',
'language_configuration[langcode]' => 'authors_default',
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/add', $edit, 'Save and manage fields');
// Make sure the settings are saved when creating the content type.
@@ -80,11 +80,11 @@ class LanguageConfigurationElementTest extends WebTestBase {
*/
public function testDefaultLangcode() {
// Add some custom languages.
- foreach (array('aa', 'bb', 'cc') as $language_code) {
- ConfigurableLanguage::create(array(
+ foreach (['aa', 'bb', 'cc'] as $language_code) {
+ ConfigurableLanguage::create([
'id' => $language_code,
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
}
// Fixed language.
@@ -154,14 +154,14 @@ class LanguageConfigurationElementTest extends WebTestBase {
// Create the article content type first if the profile used is not the
// standard one.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
- $admin_user = $this->drupalCreateUser(array('administer content types'));
+ $admin_user = $this->drupalCreateUser(['administer content types']);
$this->drupalLogin($admin_user);
- $edit = array(
+ $edit = [
'language_configuration[langcode]' => 'current_interface',
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
// Check the language default configuration for the articles.
$configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article');
@@ -169,9 +169,9 @@ class LanguageConfigurationElementTest extends WebTestBase {
$this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been saved on the Article content type.');
$this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Article content type.');
// Update the article content type by changing the title label.
- $edit = array(
+ $edit = [
'title_label' => 'Name'
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
// Check that we still have the settings for the updated node type.
$configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article');
@@ -187,19 +187,19 @@ class LanguageConfigurationElementTest extends WebTestBase {
// Create the article content type first if the profile used is not the
// standard one.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article'
- ));
+ ]);
}
- $admin_user = $this->drupalCreateUser(array('administer content types'));
+ $admin_user = $this->drupalCreateUser(['administer content types']);
$this->drupalLogin($admin_user);
// Create language configuration for the articles.
- $edit = array(
+ $edit = [
'language_configuration[langcode]' => 'authors_default',
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
// Check the language default configuration for articles is present.
@@ -207,7 +207,7 @@ class LanguageConfigurationElementTest extends WebTestBase {
$this->assertTrue($configuration, 'The language configuration is present.');
// Delete 'article' bundle.
- $this->drupalPostForm('admin/structure/types/manage/article/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/structure/types/manage/article/delete', [], t('Delete'));
// Check that the language configuration has been deleted.
\Drupal::entityManager()->getStorage('language_content_settings')->resetCache();
@@ -225,12 +225,12 @@ class LanguageConfigurationElementTest extends WebTestBase {
]);
$vocabulary->save();
- $admin_user = $this->drupalCreateUser(array('administer taxonomy'));
+ $admin_user = $this->drupalCreateUser(['administer taxonomy']);
$this->drupalLogin($admin_user);
- $edit = array(
+ $edit = [
'default_language[langcode]' => 'current_interface',
'default_language[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save'));
// Check the language default configuration.
@@ -239,9 +239,9 @@ class LanguageConfigurationElementTest extends WebTestBase {
$this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been saved on the Country vocabulary.');
$this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Country vocabulary.');
// Update the vocabulary.
- $edit = array(
+ $edit = [
'name' => 'Nation'
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save'));
// Check that we still have the settings for the updated vocabulary.
$configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country');
diff --git a/core/modules/language/src/Tests/LanguageConfigurationTest.php b/core/modules/language/src/Tests/LanguageConfigurationTest.php
index cf049f1ea01..611b479c4d1 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationTest.php
+++ b/core/modules/language/src/Tests/LanguageConfigurationTest.php
@@ -18,7 +18,7 @@ class LanguageConfigurationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Functional tests for adding, editing and deleting languages.
@@ -29,7 +29,7 @@ class LanguageConfigurationTest extends WebTestBase {
$this->assertEqual(ConfigurableLanguage::load('en')->getWeight(), 0, 'The English language has a weight of 0.');
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
// Check if the Default English language has no path prefix.
@@ -41,9 +41,9 @@ class LanguageConfigurationTest extends WebTestBase {
$this->assertFieldByXPath('//input[contains(@class, "button--primary")]', 'Add language', 'Add language is a primary button');
// Add predefined language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Add language');
$this->assertText('French');
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
@@ -63,9 +63,9 @@ class LanguageConfigurationTest extends WebTestBase {
$this->assertFieldChecked('edit-site-default-language-en', 'English is the default language.');
// Change the default language.
- $edit = array(
+ $edit = [
'site_default_language' => 'fr',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->rebuildContainer();
$this->assertFieldChecked('edit-site-default-language-fr', 'Default language updated.');
@@ -80,16 +80,16 @@ class LanguageConfigurationTest extends WebTestBase {
$this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'fr', 'French still has a path prefix.');
// Check that prefix can be changed.
- $edit = array(
+ $edit = [
'prefix[fr]' => 'french',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'french', 'French path prefix has changed.');
// Check that the prefix can be removed.
- $edit = array(
+ $edit = [
'prefix[fr]' => '',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertNoText(t('The prefix may only be left blank for the selected detection fallback language.'), 'The path prefix can be removed for the default language');
@@ -97,24 +97,24 @@ class LanguageConfigurationTest extends WebTestBase {
$this->config('language.negotiation')->set('selected_langcode', 'fr')->save();
// Check that the prefix of a language that is not the negotiation one
// cannot be changed to empty string.
- $edit = array(
+ $edit = [
'prefix[en]' => '',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertText(t('The prefix may only be left blank for the selected detection fallback language.'));
// Check that prefix cannot be changed to contain a slash.
- $edit = array(
+ $edit = [
'prefix[en]' => 'foo/bar',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertText(t('The prefix may not contain a slash.'), 'English prefix cannot be changed to contain a slash.');
// Remove English language and add a new Language to check if langcode of
// Language entity is 'en'.
- $this->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
$this->rebuildContainer();
- $this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'English', '%langcode' => 'en')));
+ $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
// Ensure that French language has a weight of 1 after being created through
// the UI.
@@ -132,9 +132,9 @@ class LanguageConfigurationTest extends WebTestBase {
$arabic->setWeight(4)->save();
$this->assertEqual($arabic->getWeight(), 4, 'The Arabic language has a weight of 0.');
- $edit = array(
+ $edit = [
'predefined_langcode' => 'de',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
$language = $this->config('language.entity.de')->get();
$this->assertEqual($language['langcode'], 'fr');
@@ -150,28 +150,28 @@ class LanguageConfigurationTest extends WebTestBase {
*/
function testLanguageConfigurationWeight() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
$this->checkConfigurableLanguageWeight();
// Add predefined language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
$this->checkConfigurableLanguageWeight('after adding new language');
// Re-ordering languages.
- $edit = array(
+ $edit = [
'languages[en][weight]' => $this->getHighestConfigurableLanguageWeight() + 1,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language', $edit, 'Save configuration');
$this->checkConfigurableLanguageWeight('after re-ordering');
// Remove predefined language.
- $edit = array(
+ $edit = [
'confirm' => 1,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/delete/fr', $edit, 'Delete');
$this->checkConfigurableLanguageWeight('after deleting a language');
}
@@ -188,7 +188,7 @@ class LanguageConfigurationTest extends WebTestBase {
// Reset language list.
\Drupal::languageManager()->reset();
$max_configurable_language_weight = $this->getHighestConfigurableLanguageWeight();
- $replacements = array('@event' => $state);
+ $replacements = ['@event' => $state];
foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $locked_language) {
$replacements['%language'] = $locked_language->getName();
$this->assertTrue($locked_language->getWeight() > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements));
diff --git a/core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php
index dbd35cdf30d..2eb02df1973 100644
--- a/core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php
+++ b/core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php
@@ -18,7 +18,7 @@ class LanguageCustomLanguageConfigurationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Functional tests for adding, editing and deleting languages.
@@ -26,76 +26,76 @@ class LanguageCustomLanguageConfigurationTest extends WebTestBase {
public function testLanguageConfiguration() {
// Create user with permissions to add and remove languages.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
// Add custom language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Test validation on missing values.
- $this->assertText(t('@name field is required.', array('@name' => t('Language code'))));
- $this->assertText(t('@name field is required.', array('@name' => t('Language name'))));
+ $this->assertText(t('@name field is required.', ['@name' => t('Language code')]));
+ $this->assertText(t('@name field is required.', ['@name' => t('Language name')]));
$empty_language = new Language();
$this->assertFieldChecked('edit-direction-' . $empty_language->getDirection(), 'Consistent usage of language direction.');
- $this->assertUrl(\Drupal::url('language.add', array(), array('absolute' => TRUE)), [], 'Correct page redirection.');
+ $this->assertUrl(\Drupal::url('language.add', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
// Test validation of invalid values.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => 'white space',
'label' => '<strong>evil markup</strong>',
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
- $this->assertRaw(t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', array(
+ $this->assertRaw(t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', [
'%field' => t('Language code'),
':url' => 'http://www.w3.org/International/articles/language-tags/',
- )));
+ ]));
- $this->assertRaw(t('%field cannot contain any markup.', array('%field' => t('Language name'))));
- $this->assertUrl(\Drupal::url('language.add', array(), array('absolute' => TRUE)), [], 'Correct page redirection.');
+ $this->assertRaw(t('%field cannot contain any markup.', ['%field' => t('Language name')]));
+ $this->assertUrl(\Drupal::url('language.add', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
// Test adding a custom language with a numeric region code.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => 'es-419',
'label' => 'Latin American Spanish',
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertRaw(t(
'The language %language has been created and can now be used.',
- array('%language' => $edit['label'])
+ ['%language' => $edit['label']]
));
- $this->assertUrl(\Drupal::url('entity.configurable_language.collection', array(), array('absolute' => TRUE)), [], 'Correct page redirection.');
+ $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
// Test validation of existing language values.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => 'de',
'label' => 'German',
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
// Add the language the first time.
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertRaw(t(
'The language %language has been created and can now be used.',
- array('%language' => $edit['label'])
+ ['%language' => $edit['label']]
));
- $this->assertUrl(\Drupal::url('entity.configurable_language.collection', array(), array('absolute' => TRUE)), [], 'Correct page redirection.');
+ $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
// Add the language a second time and confirm that this is not allowed.
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertRaw(t(
'The language %language (%langcode) already exists.',
- array('%language' => $edit['label'], '%langcode' => $edit['langcode'])
+ ['%language' => $edit['label'], '%langcode' => $edit['langcode']]
));
- $this->assertUrl(\Drupal::url('language.add', array(), array('absolute' => TRUE)), [], 'Correct page redirection.');
+ $this->assertUrl(\Drupal::url('language.add', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
}
}
diff --git a/core/modules/language/src/Tests/LanguageListTest.php b/core/modules/language/src/Tests/LanguageListTest.php
index d407530603b..2ed4962e110 100644
--- a/core/modules/language/src/Tests/LanguageListTest.php
+++ b/core/modules/language/src/Tests/LanguageListTest.php
@@ -19,7 +19,7 @@ class LanguageListTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Functional tests for adding, editing and deleting languages.
@@ -27,7 +27,7 @@ class LanguageListTest extends WebTestBase {
function testLanguageList() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
// Get the weight of the last language.
@@ -35,9 +35,9 @@ class LanguageListTest extends WebTestBase {
$last_language_weight = end($languages)->getWeight();
// Add predefined language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->assertText('French', 'Language added successfully.');
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]));
@@ -53,12 +53,12 @@ class LanguageListTest extends WebTestBase {
// Add custom language.
$langcode = 'xx';
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => Language::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]));
$this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
@@ -72,9 +72,9 @@ class LanguageListTest extends WebTestBase {
$this->drupalGet($path);
$this->assertFieldChecked('edit-site-default-language-en', 'English is the default language.');
// Change the default language.
- $edit = array(
+ $edit = [
'site_default_language' => $langcode,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->rebuildContainer();
$this->assertNoFieldChecked('edit-site-default-language-en', 'Default language updated.');
@@ -90,17 +90,17 @@ class LanguageListTest extends WebTestBase {
$this->assertTitle(t('Edit language | Drupal'), 'Page title is "Edit language".');
// Edit a language.
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'label' => $name,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/edit/' . $langcode, $edit, t('Save language'));
$this->assertRaw($name, 'The language has been updated.');
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $language]));
// Change back the default language.
- $edit = array(
+ $edit = [
'site_default_language' => 'en',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save configuration'));
$this->rebuildContainer();
// Ensure 'delete' link works.
@@ -115,9 +115,9 @@ class LanguageListTest extends WebTestBase {
$this->assertRaw($name, 'The language was not deleted.');
// Delete the language for real. This a confirm form, we do not need any
// fields changed.
- $this->drupalPostForm('admin/config/regional/language/delete/' . $langcode, array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/' . $langcode, [], t('Delete'));
// We need raw here because %language and %langcode will add HTML.
- $t_args = array('%language' => $name, '%langcode' => $langcode);
+ $t_args = ['%language' => $name, '%langcode' => $langcode];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.');
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $english]));
// Verify that language is no longer found.
@@ -125,11 +125,11 @@ class LanguageListTest extends WebTestBase {
$this->assertResponse(404, 'Language no longer found.');
// Delete French.
- $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
// Make sure the "language_count" state has been updated correctly.
$this->rebuildContainer();
// We need raw here because %language and %langcode will add HTML.
- $t_args = array('%language' => 'French', '%langcode' => 'fr');
+ $t_args = ['%language' => 'French', '%langcode' => 'fr'];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The French language has been removed.');
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]));
// Verify that language is no longer found.
@@ -142,12 +142,12 @@ class LanguageListTest extends WebTestBase {
// deleting English.
$langcode = 'xx';
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => Language::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]));
$this->assertText($name, 'Name found.');
@@ -157,17 +157,17 @@ class LanguageListTest extends WebTestBase {
$this->drupalGet($path);
$this->assertFieldChecked('edit-site-default-language-en', 'English is the default language.');
// Change the default language.
- $edit = array(
+ $edit = [
'site_default_language' => $langcode,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->rebuildContainer();
$this->assertNoFieldChecked('edit-site-default-language-en', 'Default language updated.');
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $language]));
- $this->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
// We need raw here because %language and %langcode will add HTML.
- $t_args = array('%language' => 'English', '%langcode' => 'en');
+ $t_args = ['%language' => 'English', '%langcode' => 'en'];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The English language has been removed.');
$this->rebuildContainer();
@@ -178,7 +178,7 @@ class LanguageListTest extends WebTestBase {
// Ensure that NL cannot be set default when it's not available.
$this->drupalGet('admin/config/regional/language');
$extra_values = '&site_default_language=nl';
- $this->drupalPostForm(NULL, array(), t('Save configuration'), array(), array(), NULL, $extra_values);
+ $this->drupalPostForm(NULL, [], t('Save configuration'), [], [], NULL, $extra_values);
$this->assertText(t('Selected default language no longer exists.'));
$this->assertNoFieldChecked('edit-site-default-language-xx', 'The previous default language got deselected.');
}
@@ -188,22 +188,22 @@ class LanguageListTest extends WebTestBase {
*/
function testLanguageStates() {
// Add some languages, and also lock some of them.
- ConfigurableLanguage::create(array('label' => $this->randomMachineName(), 'id' => 'l1'))->save();
- ConfigurableLanguage::create(array('label' => $this->randomMachineName(), 'id' => 'l2', 'locked' => TRUE))->save();
- ConfigurableLanguage::create(array('label' => $this->randomMachineName(), 'id' => 'l3'))->save();
- ConfigurableLanguage::create(array('label' => $this->randomMachineName(), 'id' => 'l4', 'locked' => TRUE))->save();
- $expected_locked_languages = array('l4' => 'l4', 'l2' => 'l2', 'und' => 'und', 'zxx' => 'zxx');
- $expected_all_languages = array('l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx');
- $expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en');
+ ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'l1'])->save();
+ ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'l2', 'locked' => TRUE])->save();
+ ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'l3'])->save();
+ ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'l4', 'locked' => TRUE])->save();
+ $expected_locked_languages = ['l4' => 'l4', 'l2' => 'l2', 'und' => 'und', 'zxx' => 'zxx'];
+ $expected_all_languages = ['l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx'];
+ $expected_conf_languages = ['l3' => 'l3', 'l1' => 'l1', 'en' => 'en'];
$locked_languages = $this->container->get('language_manager')->getLanguages(LanguageInterface::STATE_LOCKED);
- $this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), 'Locked languages loaded correctly.');
+ $this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), [], 'Locked languages loaded correctly.');
$all_languages = $this->container->get('language_manager')->getLanguages(LanguageInterface::STATE_ALL);
- $this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), 'All languages loaded correctly.');
+ $this->assertEqual(array_diff_key($expected_all_languages, $all_languages), [], 'All languages loaded correctly.');
$conf_languages = $this->container->get('language_manager')->getLanguages();
- $this->assertEqual(array_diff_key($expected_conf_languages, $conf_languages), array(), 'Configurable languages loaded correctly.');
+ $this->assertEqual(array_diff_key($expected_conf_languages, $conf_languages), [], 'Configurable languages loaded correctly.');
}
}
diff --git a/core/modules/language/src/Tests/LanguageLocaleListTest.php b/core/modules/language/src/Tests/LanguageLocaleListTest.php
index dd3e02a1f38..022a072d1f7 100644
--- a/core/modules/language/src/Tests/LanguageLocaleListTest.php
+++ b/core/modules/language/src/Tests/LanguageLocaleListTest.php
@@ -16,7 +16,7 @@ class LanguageLocaleListTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language', 'locale');
+ public static $modules = ['language', 'locale'];
/**
* {@inheritdoc}
@@ -32,28 +32,28 @@ class LanguageLocaleListTest extends WebTestBase {
*/
function testLanguageLocaleList() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
// Add predefined language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->assertText('The language French has been created and can now be used');
$this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]));
$this->rebuildContainer();
// Translate Spanish language to French (Espagnol).
- $source = $this->storage->createString(array(
+ $source = $this->storage->createString([
'source' => 'Spanish',
'context' => '',
- ))->save();
- $this->storage->createTranslation(array(
+ ])->save();
+ $this->storage->createTranslation([
'lid' => $source->lid,
'language' => 'fr',
'translation' => 'Espagnol',
- ))->save();
+ ])->save();
// Get language list displayed in select list.
$this->drupalGet('fr/admin/config/regional/language/add');
diff --git a/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php b/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php
index 84d677911d6..d13626cc452 100644
--- a/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php
+++ b/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php
@@ -16,7 +16,7 @@ class LanguageSelectorTranslatableTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'language',
'content_translation',
'node',
@@ -24,7 +24,7 @@ class LanguageSelectorTranslatableTest extends WebTestBase {
'field_ui',
'entity_test',
'locale',
- );
+ ];
/**
* The user with administrator privileges.
@@ -49,13 +49,13 @@ class LanguageSelectorTranslatableTest extends WebTestBase {
*/
protected function getAdministratorPermissions() {
return array_filter(
- array('translate interface',
+ ['translate interface',
'administer content translation',
'create content translations',
'update content translations',
'delete content translations',
'administer languages',
- )
+ ]
);
}
@@ -64,7 +64,7 @@ class LanguageSelectorTranslatableTest extends WebTestBase {
*/
public function testLanguageStringSelector() {
// Add another language.
- $edit = array('predefined_langcode' => 'es');
+ $edit = ['predefined_langcode' => 'es'];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Translate the string English in Spanish (Inglés). Override config entity.
@@ -79,7 +79,7 @@ class LanguageSelectorTranslatableTest extends WebTestBase {
$this->drupalGet($path);
// Get en language from selector.
- $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => 'edit-settings-user-user-settings-language-langcode', ':option' => 'en'));
+ $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => 'edit-settings-user-user-settings-language-langcode', ':option' => 'en']);
// Check that the language text is translated.
$this->assertEqual((string) $elements[0], $name_translation, 'Checking the option string English is translated to Spanish.');
diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php
index 5d4469d3af6..3d04a648224 100644
--- a/core/modules/language/src/Tests/LanguageSwitchingTest.php
+++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php
@@ -20,13 +20,13 @@ class LanguageSwitchingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'locale_test', 'language', 'block', 'language_test', 'menu_ui');
+ public static $modules = ['locale', 'locale_test', 'language', 'block', 'language_test', 'menu_ui'];
protected function setUp() {
parent::setUp();
// Create and log in user.
- $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer blocks', 'administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
}
@@ -35,24 +35,24 @@ class LanguageSwitchingTest extends WebTestBase {
*/
function testLanguageBlock() {
// Add language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Set the native language name.
$this->saveNativeLanguageName('fr', 'français');
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => '1');
+ $edit = ['language_interface[enabled][language-url]' => '1'];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Enable the language switching block.
- $block = $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array(
+ $block = $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [
'id' => 'test_language_block',
// Ensure a 2-byte UTF-8 sequence is in the tested output.
'label' => $this->randomMachineName(8) . '×',
- ));
+ ]);
$this->doTestLanguageBlockAuthenticated($block->label());
$this->doTestLanguageBlockAnonymous($block->label());
@@ -73,38 +73,38 @@ class LanguageSwitchingTest extends WebTestBase {
// Assert that each list item and anchor element has the appropriate data-
// attributes.
- list($language_switcher) = $this->xpath('//div[@id=:id]', array(':id' => 'block-test-language-block'));
- $list_items = array();
- $anchors = array();
- $labels = array();
+ list($language_switcher) = $this->xpath('//div[@id=:id]', [':id' => 'block-test-language-block']);
+ $list_items = [];
+ $anchors = [];
+ $labels = [];
foreach ($language_switcher->ul->li as $list_item) {
$classes = explode(" ", (string) $list_item['class']);
- list($langcode) = array_intersect($classes, array('en', 'fr'));
- $list_items[] = array(
+ list($langcode) = array_intersect($classes, ['en', 'fr']);
+ $list_items[] = [
'langcode_class' => $langcode,
'data-drupal-link-system-path' => (string) $list_item['data-drupal-link-system-path'],
- );
- $anchors[] = array(
+ ];
+ $anchors[] = [
'hreflang' => (string) $list_item->a['hreflang'],
'data-drupal-link-system-path' => (string) $list_item->a['data-drupal-link-system-path'],
- );
+ ];
$labels[] = (string) $list_item->a;
}
- $expected_list_items = array(
- 0 => array('langcode_class' => 'en', 'data-drupal-link-system-path' => 'user/2'),
- 1 => array('langcode_class' => 'fr', 'data-drupal-link-system-path' => 'user/2'),
- );
+ $expected_list_items = [
+ 0 => ['langcode_class' => 'en', 'data-drupal-link-system-path' => 'user/2'],
+ 1 => ['langcode_class' => 'fr', 'data-drupal-link-system-path' => 'user/2'],
+ ];
$this->assertIdentical($list_items, $expected_list_items, 'The list items have the correct attributes that will allow the drupal.active-link library to mark them as active.');
- $expected_anchors = array(
- 0 => array('hreflang' => 'en', 'data-drupal-link-system-path' => 'user/2'),
- 1 => array('hreflang' => 'fr', 'data-drupal-link-system-path' => 'user/2'),
- );
+ $expected_anchors = [
+ 0 => ['hreflang' => 'en', 'data-drupal-link-system-path' => 'user/2'],
+ 1 => ['hreflang' => 'fr', 'data-drupal-link-system-path' => 'user/2'],
+ ];
$this->assertIdentical($anchors, $expected_anchors, 'The anchors have the correct attributes that will allow the drupal.active-link library to mark them as active.');
$settings = $this->getDrupalSettings();
$this->assertIdentical($settings['path']['currentPath'], 'user/2', 'drupalSettings.path.currentPath is set correctly to allow drupal.active-link to mark the correct links as active.');
$this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.');
$this->assertIdentical($settings['path']['currentLanguage'], 'en', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.');
- $this->assertIdentical($labels, array('English', 'français'), 'The language links labels are in their own language on the language switcher block.');
+ $this->assertIdentical($labels, ['English', 'français'], 'The language links labels are in their own language on the language switcher block.');
}
/**
@@ -124,19 +124,19 @@ class LanguageSwitchingTest extends WebTestBase {
$this->assertText($block_label, 'Language switcher block found.');
// Assert that only the current language is marked as active.
- list($language_switcher) = $this->xpath('//div[@id=:id]', array(':id' => 'block-test-language-block'));
- $links = array(
- 'active' => array(),
- 'inactive' => array(),
- );
- $anchors = array(
- 'active' => array(),
- 'inactive' => array(),
- );
- $labels = array();
+ list($language_switcher) = $this->xpath('//div[@id=:id]', [':id' => 'block-test-language-block']);
+ $links = [
+ 'active' => [],
+ 'inactive' => [],
+ ];
+ $anchors = [
+ 'active' => [],
+ 'inactive' => [],
+ ];
+ $labels = [];
foreach ($language_switcher->ul->li as $link) {
$classes = explode(" ", (string) $link['class']);
- list($langcode) = array_intersect($classes, array('en', 'fr'));
+ list($langcode) = array_intersect($classes, ['en', 'fr']);
if (in_array('is-active', $classes)) {
$links['active'][] = $langcode;
}
@@ -152,9 +152,9 @@ class LanguageSwitchingTest extends WebTestBase {
}
$labels[] = (string) $link->a;
}
- $this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language list item is marked as active on the language switcher block.');
- $this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language anchor is marked as active on the language switcher block.');
- $this->assertIdentical($labels, array('English', 'français'), 'The language links labels are in their own language on the language switcher block.');
+ $this->assertIdentical($links, ['active' => ['en'], 'inactive' => ['fr']], 'Only the current language list item is marked as active on the language switcher block.');
+ $this->assertIdentical($anchors, ['active' => ['en'], 'inactive' => ['fr']], 'Only the current language anchor is marked as active on the language switcher block.');
+ $this->assertIdentical($labels, ['English', 'français'], 'The language links labels are in their own language on the language switcher block.');
}
/**
@@ -171,31 +171,31 @@ class LanguageSwitchingTest extends WebTestBase {
$languages = $this->container->get('language_manager')->getLanguages();
// Enable browser and URL language detection.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-url]' => TRUE,
'language_interface[weight][language-url]' => -10,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Do not allow blank domain.
- $edit = array(
+ $edit = [
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => '',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
$this->assertText(t('The domain may not be left blank for English'), 'The form does not allow blank domains.');
// Change the domain for the Italian language.
- $edit = array(
+ $edit = [
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => \Drupal::request()->getHost(),
'domain[it]' => 'it.example.com',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved'), 'Domain configuration is saved.');
// Enable the language switcher block.
- $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array('id' => 'test_language_block'));
+ $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, ['id' => 'test_language_block']);
$this->drupalGet('');
@@ -203,19 +203,19 @@ class LanguageSwitchingTest extends WebTestBase {
$generator = $this->container->get('url_generator');
// Verify the English URL is correct
- list($english_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array(
+ list($english_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', [
':id' => 'block-test-language-block',
':hreflang' => 'en',
- ));
- $english_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['en']));
+ ]);
+ $english_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['en']]);
$this->assertEqual($english_url, (string) $english_link['href']);
// Verify the Italian URL is correct
- list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array(
+ list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', [
':id' => 'block-test-language-block',
':hreflang' => 'it',
- ));
- $italian_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['it']));
+ ]);
+ $italian_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['it']]);
$this->assertEqual($italian_url, (string) $italian_link['href']);
}
@@ -224,13 +224,13 @@ class LanguageSwitchingTest extends WebTestBase {
*/
function testLanguageLinkActiveClass() {
// Add language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => '1');
+ $edit = ['language_interface[enabled][language-url]' => '1'];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->doTestLanguageLinkActiveClassAuthenticated();
@@ -244,23 +244,23 @@ class LanguageSwitchingTest extends WebTestBase {
$searched_class = 'path-admin';
// Add language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => '1');
+ $edit = ['language_interface[enabled][language-url]' => '1'];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Check if the default (English) admin/config page has the right class.
$this->drupalGet('admin/config');
- $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class));
+ $class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]);
$this->assertTrue(isset($class[0]), t('The path-admin class appears on default language.'));
// Check if the French admin/config page has the right class.
$this->drupalGet('fr/admin/config');
- $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class));
+ $class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]);
$this->assertTrue(isset($class[0]), t('The path-admin class same as on default language.'));
// The testing profile sets the user/login page as the frontpage. That
@@ -270,12 +270,12 @@ class LanguageSwitchingTest extends WebTestBase {
// Check if the default (English) frontpage has the right class.
$this->drupalGet('<front>');
- $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => 'path-frontpage'));
+ $class = $this->xpath('//body[contains(@class, :class)]', [':class' => 'path-frontpage']);
$this->assertTrue(isset($class[0]), 'path-frontpage class found on the body tag');
// Check if the French frontpage has the right class.
$this->drupalGet('fr');
- $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => 'path-frontpage'));
+ $class = $this->xpath('//body[contains(@class, :class)]', [':class' => 'path-frontpage']);
$this->assertTrue(isset($class[0]), 'path-frontpage class found on the body tag with french as the active language');
}
@@ -295,18 +295,18 @@ class LanguageSwitchingTest extends WebTestBase {
// Language code 'none' link should be active.
$langcode = 'none';
- $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', array(':id' => 'no_lang_link', ':path' => $path));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'en' link should be active.
$langcode = 'en';
- $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', array(':id' => 'en_link', ':lang' => 'en', ':path' => $path));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'fr' link should not be active.
$langcode = 'fr';
- $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', array(':id' => 'fr_link', ':lang' => 'fr', ':path' => $path));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Verify that drupalSettings contains the correct values.
$settings = $this->getDrupalSettings();
@@ -320,18 +320,18 @@ class LanguageSwitchingTest extends WebTestBase {
// Language code 'none' link should be active.
$langcode = 'none';
- $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', array(':id' => 'no_lang_link', ':path' => $path));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'en' link should not be active.
$langcode = 'en';
- $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', array(':id' => 'en_link', ':lang' => 'en', ':path' => $path));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'fr' link should be active.
$langcode = 'fr';
- $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', array(':id' => 'fr_link', ':lang' => 'fr', ':path' => $path));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Verify that drupalSettings contains the correct values.
$settings = $this->getDrupalSettings();
@@ -356,18 +356,18 @@ class LanguageSwitchingTest extends WebTestBase {
// Language code 'none' link should be active.
$langcode = 'none';
- $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', array(':id' => 'no_lang_link', ':class' => 'is-active'));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'en' link should be active.
$langcode = 'en';
- $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', array(':id' => 'en_link', ':class' => 'is-active'));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'en_link', ':class' => 'is-active']);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'fr' link should not be active.
$langcode = 'fr';
- $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', array(':id' => 'fr_link', ':class' => 'is-active'));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'fr_link', ':class' => 'is-active']);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Test links generated by the link generator on a French page.
$current_language = 'French';
@@ -375,18 +375,18 @@ class LanguageSwitchingTest extends WebTestBase {
// Language code 'none' link should be active.
$langcode = 'none';
- $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', array(':id' => 'no_lang_link', ':class' => 'is-active'));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'en' link should not be active.
$langcode = 'en';
- $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', array(':id' => 'en_link', ':class' => 'is-active'));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'en_link', ':class' => 'is-active']);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
// Language code 'fr' link should be active.
$langcode = 'fr';
- $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', array(':id' => 'fr_link', ':class' => 'is-active'));
- $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
+ $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'fr_link', ':class' => 'is-active']);
+ $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode]));
}
/**
@@ -394,27 +394,27 @@ class LanguageSwitchingTest extends WebTestBase {
*/
public function testLanguageSessionSwitchLinks() {
// Add language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable session language detection and selection.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-url]' => FALSE,
'language_interface[enabled][language-session]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Enable the language switching block.
- $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array(
+ $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [
'id' => 'test_language_block',
- ));
+ ]);
// Enable the main menu block.
- $this->drupalPlaceBlock('system_menu_block:main', array(
+ $this->drupalPlaceBlock('system_menu_block:main', [
'id' => 'test_menu',
- ));
+ ]);
// Add a link to the homepage.
$link = MenuLinkContent::create([
diff --git a/core/modules/language/src/Tests/LanguageTourTest.php b/core/modules/language/src/Tests/LanguageTourTest.php
index 7778367385f..b11006ec3e9 100644
--- a/core/modules/language/src/Tests/LanguageTourTest.php
+++ b/core/modules/language/src/Tests/LanguageTourTest.php
@@ -30,7 +30,7 @@ class LanguageTourTest extends TourTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer languages', 'access tour'));
+ $this->adminUser = $this->drupalCreateUser(['administer languages', 'access tour']);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_actions_block');
}
diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
index 03dd8cbf026..0008186ed10 100644
--- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
@@ -48,12 +48,12 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'language_test', 'block', 'user', 'content_translation');
+ public static $modules = ['locale', 'language_test', 'block', 'user', 'content_translation'];
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages', 'administer blocks'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages', 'administer blocks']);
$this->drupalLogin($admin_user);
}
@@ -69,9 +69,9 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
// For testing path prefix.
$langcode = 'zh-hans';
// For setting browser language preference to 'vi'.
- $http_header_browser_fallback = array("Accept-Language: $langcode_browser_fallback;q=1");
+ $http_header_browser_fallback = ["Accept-Language: $langcode_browser_fallback;q=1"];
// For setting browser language preference to some unknown.
- $http_header_blah = array("Accept-Language: blah;q=1");
+ $http_header_blah = ["Accept-Language: blah;q=1"];
// Setup the site languages by installing two languages.
// Set the default language in order for the translated string to be registered
@@ -101,114 +101,114 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$language_browser_fallback_string = "In $langcode_browser_fallback In $langcode_browser_fallback In $langcode_browser_fallback";
$language_string = "In $langcode In $langcode In $langcode";
// Do a translate search of our target string.
- $search = array(
+ $search = [
'string' => $default_string,
'langcode' => $langcode_browser_fallback,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $language_browser_fallback_string,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
- $search = array(
+ $search = [
'string' => $default_string,
'langcode' => $langcode,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $language_string,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Configure selected language negotiation to use zh-hans.
- $edit = array('selected_langcode' => $langcode);
+ $edit = ['selected_langcode' => $langcode];
$this->drupalPostForm('admin/config/regional/language/detection/selected', $edit, t('Save configuration'));
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $language_string,
'expected_method_id' => LanguageNegotiationSelected::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'SELECTED: UI language is switched based on selected language.',
- );
+ ];
$this->doRunTest($test);
// An invalid language is selected.
$this->config('language.negotiation')->set('selected_langcode', NULL)->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'SELECTED > DEFAULT: UI language is switched based on selected language.',
- );
+ ];
$this->doRunTest($test);
// No selected language is available.
$this->config('language.negotiation')->set('selected_langcode', $langcode_unknown)->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'SELECTED > DEFAULT: UI language is switched based on selected language.',
- );
+ ];
$this->doRunTest($test);
- $tests = array(
+ $tests = [
// Default, browser preference should have no influence.
- array(
- 'language_negotiation' => array(LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ [
+ 'language_negotiation' => [LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (PATH) > DEFAULT: no language prefix, UI language is default and the browser language preference setting is not used.',
- ),
+ ],
// Language prefix.
- array(
- 'language_negotiation' => array(LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ [
+ 'language_negotiation' => [LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => "$langcode/admin/config",
'expect' => $language_string,
'expected_method_id' => LanguageNegotiationUrl::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (PATH) > DEFAULT: with language prefix, UI language is switched based on path prefix',
- ),
+ ],
// Default, go by browser preference.
- array(
- 'language_negotiation' => array(LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationBrowser::METHOD_ID),
+ [
+ 'language_negotiation' => [LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationBrowser::METHOD_ID],
'path' => 'admin/config',
'expect' => $language_browser_fallback_string,
'expected_method_id' => LanguageNegotiationBrowser::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (PATH) > BROWSER: no language prefix, UI language is determined by browser language preference',
- ),
+ ],
// Prefix, switch to the language.
- array(
- 'language_negotiation' => array(LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationBrowser::METHOD_ID),
+ [
+ 'language_negotiation' => [LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationBrowser::METHOD_ID],
'path' => "$langcode/admin/config",
'expect' => $language_string,
'expected_method_id' => LanguageNegotiationUrl::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (PATH) > BROWSER: with language prefix, UI language is based on path prefix',
- ),
+ ],
// Default, browser language preference is not one of site's lang.
- array(
- 'language_negotiation' => array(LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationBrowser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ [
+ 'language_negotiation' => [LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationBrowser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
'http_header' => $http_header_blah,
'message' => 'URL (PATH) > BROWSER > DEFAULT: no language prefix and browser language preference set to unknown language should use default language',
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$this->doRunTest($test);
@@ -224,7 +224,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$this->config('language.types')
->set('negotiation.' . LanguageInterface::TYPE_INTERFACE . '.enabled', array_flip(array_keys($language_interface_method_definitions)))
->save();
- $this->drupalGet("$langcode_unknown/admin/config", array(), $http_header_browser_fallback);
+ $this->drupalGet("$langcode_unknown/admin/config", [], $http_header_browser_fallback);
$this->assertResponse(404, "Unknown language path prefix should return 404");
// Set preferred langcode for user to NULL.
@@ -232,14 +232,14 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$account->preferred_langcode = NULL;
$account->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationUser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationUser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
- 'http_header' => array(),
+ 'http_header' => [],
'message' => 'USER > DEFAULT: no preferred user language setting, the UI language is default',
- );
+ ];
$this->doRunTest($test);
// Set preferred langcode for user to unknown language.
@@ -247,102 +247,102 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$account->preferred_langcode = $langcode_unknown;
$account->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationUser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationUser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
- 'http_header' => array(),
+ 'http_header' => [],
'message' => 'USER > DEFAULT: invalid preferred user language setting, the UI language is default',
- );
+ ];
$this->doRunTest($test);
// Set preferred langcode for user to non default.
$account->preferred_langcode = $langcode;
$account->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationUser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationUser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $language_string,
'expected_method_id' => LanguageNegotiationUser::METHOD_ID,
- 'http_header' => array(),
+ 'http_header' => [],
'message' => 'USER > DEFAULT: defined preferred user language setting, the UI language is based on user setting',
- );
+ ];
$this->doRunTest($test);
// Set preferred admin langcode for user to NULL.
$account->preferred_admin_langcode = NULL;
$account->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationUserAdmin::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationUserAdmin::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
- 'http_header' => array(),
+ 'http_header' => [],
'message' => 'USER ADMIN > DEFAULT: no preferred user admin language setting, the UI language is default',
- );
+ ];
$this->doRunTest($test);
// Set preferred admin langcode for user to unknown language.
$account->preferred_admin_langcode = $langcode_unknown;
$account->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationUserAdmin::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationUserAdmin::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
- 'http_header' => array(),
+ 'http_header' => [],
'message' => 'USER ADMIN > DEFAULT: invalid preferred user admin language setting, the UI language is default',
- );
+ ];
$this->doRunTest($test);
// Set preferred admin langcode for user to non default.
$account->preferred_admin_langcode = $langcode;
$account->save();
- $test = array(
- 'language_negotiation' => array(LanguageNegotiationUserAdmin::METHOD_ID, LanguageNegotiationSelected::METHOD_ID),
+ $test = [
+ 'language_negotiation' => [LanguageNegotiationUserAdmin::METHOD_ID, LanguageNegotiationSelected::METHOD_ID],
'path' => 'admin/config',
'expect' => $language_string,
'expected_method_id' => LanguageNegotiationUserAdmin::METHOD_ID,
- 'http_header' => array(),
+ 'http_header' => [],
'message' => 'USER ADMIN > DEFAULT: defined preferred user admin language setting, the UI language is based on user setting',
- );
+ ];
$this->doRunTest($test);
// Go by session preference.
$language_negotiation_session_param = $this->randomMachineName();
- $edit = array('language_negotiation_session_param' => $language_negotiation_session_param);
+ $edit = ['language_negotiation_session_param' => $language_negotiation_session_param];
$this->drupalPostForm('admin/config/regional/language/detection/session', $edit, t('Save configuration'));
- $tests = array(
- array(
- 'language_negotiation' => array(LanguageNegotiationSession::METHOD_ID),
+ $tests = [
+ [
+ 'language_negotiation' => [LanguageNegotiationSession::METHOD_ID],
'path' => "admin/config",
'expect' => $default_string,
'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'SESSION > DEFAULT: no language given, the UI language is default',
- ),
- array(
- 'language_negotiation' => array(LanguageNegotiationSession::METHOD_ID),
+ ],
+ [
+ 'language_negotiation' => [LanguageNegotiationSession::METHOD_ID],
'path' => 'admin/config',
'path_options' => ['query' => [$language_negotiation_session_param => $langcode]],
'expect' => $language_string,
'expected_method_id' => LanguageNegotiationSession::METHOD_ID,
'http_header' => $http_header_browser_fallback,
'message' => 'SESSION > DEFAULT: language given, UI language is determined by session language preference',
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$this->doRunTest($test);
}
}
protected function doRunTest($test) {
- $test += array('path_options' => []);
+ $test += ['path_options' => []];
if (!empty($test['language_negotiation'])) {
$method_weights = array_flip($test['language_negotiation']);
$this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_INTERFACE, $method_weights);
@@ -358,7 +358,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$this->container->get('language_manager')->reset();
$this->drupalGet($test['path'], $test['path_options'], $test['http_header']);
$this->assertText($test['expect'], $test['message']);
- $this->assertText(t('Language negotiation method: @name', array('@name' => $test['expected_method_id'])));
+ $this->assertText(t('Language negotiation method: @name', ['@name' => $test['expected_method_id']]));
}
/**
@@ -372,21 +372,21 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
// Enable the path prefix for the default language: this way any unprefixed
// URL must have a valid fallback value.
- $edit = array('prefix[en]' => 'en');
+ $edit = ['prefix[en]' => 'en'];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
// Enable browser and URL language detection.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-browser]' => TRUE,
'language_interface[enabled][language-url]' => TRUE,
'language_interface[weight][language-browser]' => -8,
'language_interface[weight][language-url]' => -10,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->drupalGet('admin/config/regional/language/detection');
// Enable the language switcher block.
- $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array('id' => 'test_language_block'));
+ $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, ['id' => 'test_language_block']);
// Log out, because for anonymous users, the "active" class is set by PHP
// (which means we can easily test it here), whereas for authenticated users
@@ -398,13 +398,13 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
// Access the front page without specifying any valid URL language prefix
// and having as browser language preference a non-default language.
- $http_header = array("Accept-Language: $langcode_browser_fallback;q=1");
- $language = new Language(array('id' => ''));
- $this->drupalGet('', array('language' => $language), $http_header);
+ $http_header = ["Accept-Language: $langcode_browser_fallback;q=1"];
+ $language = new Language(['id' => '']);
+ $this->drupalGet('', ['language' => $language], $http_header);
// Check that the language switcher active link matches the given browser
// language.
- $args = array(':id' => 'block-test-language-block', ':url' => \Drupal::url('<front>') . $langcode_browser_fallback);
+ $args = [':id' => 'block-test-language-block', ':url' => \Drupal::url('<front>') . $langcode_browser_fallback];
$fields = $this->xpath('//div[@id=:id]//a[@class="language-link is-active" and starts-with(@href, :url)]', $args);
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language');
@@ -428,27 +428,27 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$languages = $this->container->get('language_manager')->getLanguages();
// Enable browser and URL language detection.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-url]' => TRUE,
'language_interface[weight][language-url]' => -10,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Do not allow blank domain.
- $edit = array(
+ $edit = [
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => '',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
$this->assertText('The domain may not be left blank for English', 'The form does not allow blank domains.');
$this->rebuildContainer();
// Change the domain for the Italian language.
- $edit = array(
+ $edit = [
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => $base_url_host,
'domain[it]' => 'it.example.com',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
$this->assertText('The configuration options have been saved', 'Domain configuration is saved.');
$this->rebuildContainer();
@@ -471,19 +471,19 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$italian_url = Url::fromRoute('system.admin', [], ['language' => $languages['it']])->toString();
$url_scheme = \Drupal::request()->isSecure() ? 'https://' : 'http://';
$correct_link = $url_scheme . $link;
- $this->assertEqual($italian_url, $correct_link, format_string('The right URL (@url) in accordance with the chosen language', array('@url' => $italian_url)));
+ $this->assertEqual($italian_url, $correct_link, format_string('The right URL (@url) in accordance with the chosen language', ['@url' => $italian_url]));
// Test HTTPS via options.
$italian_url = Url::fromRoute('system.admin', [], ['https' => TRUE, 'language' => $languages['it']])->toString();
$correct_link = 'https://' . $link;
- $this->assertTrue($italian_url == $correct_link, format_string('The right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
+ $this->assertTrue($italian_url == $correct_link, format_string('The right HTTPS URL (via options) (@url) in accordance with the chosen language', ['@url' => $italian_url]));
// Test HTTPS via current URL scheme.
- $request = Request::create('', 'GET', array(), array(), array(), array('HTTPS' => 'on'));
+ $request = Request::create('', 'GET', [], [], [], ['HTTPS' => 'on']);
$this->container->get('request_stack')->push($request);
$italian_url = Url::fromRoute('system.admin', [], ['language' => $languages['it']])->toString();
$correct_link = 'https://' . $link;
- $this->assertTrue($italian_url == $correct_link, format_string('The right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url)));
+ $this->assertTrue($italian_url == $correct_link, format_string('The right URL (via current URL scheme) (@url) in accordance with the chosen language', ['@url' => $italian_url]));
}
/**
@@ -491,11 +491,11 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
*/
public function testContentCustomization() {
// Customize content language settings from their defaults.
- $edit = array(
+ $edit = [
'language_content[configurable]' => TRUE,
'language_content[enabled][language-url]' => FALSE,
'language_content[enabled][language-session]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Check if configurability persisted.
@@ -515,16 +515,16 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$block_id = 'test_language_block';
// Enable the language switcher block.
- $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_CONTENT, array('id' => $block_id));
+ $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_CONTENT, ['id' => $block_id]);
// Check if the language switcher block has been created.
$block = Block::load($block_id);
$this->assertTrue($block, 'Language switcher block was created.');
// Make sure language_content is not configurable.
- $edit = array(
+ $edit = [
'language_content[configurable]' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->assertResponse(200);
diff --git a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php
index 5cd80dc4a93..de1b1a36fdc 100644
--- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php
+++ b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php
@@ -21,7 +21,7 @@ class LanguageUrlRewritingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language', 'language_test');
+ public static $modules = ['language', 'language_test'];
/**
* An user with permissions to administer languages.
@@ -34,16 +34,16 @@ class LanguageUrlRewritingTest extends WebTestBase {
parent::setUp();
// Create and log in user.
- $this->webUser = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $this->webUser = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($this->webUser);
// Install French language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => 1);
+ $edit = ['language_interface[enabled][language-url]' => 1];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Check that drupalSettings contains path prefix.
@@ -56,7 +56,7 @@ class LanguageUrlRewritingTest extends WebTestBase {
*/
function testUrlRewritingEdgeCases() {
// Check URL rewriting with a non-installed language.
- $non_existing = new Language(array('id' => $this->randomMachineName()));
+ $non_existing = new Language(['id' => $this->randomMachineName()]);
$this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages');
// Check that URL rewriting is not applied to subrequests.
@@ -79,9 +79,9 @@ class LanguageUrlRewritingTest extends WebTestBase {
* The message to display confirming prefixed URL is not working.
*/
private function checkUrl(LanguageInterface $language, $message1, $message2) {
- $options = array('language' => $language, 'script' => '');
+ $options = ['language' => $language, 'script' => ''];
$base_path = trim(base_path(), '/');
- $rewritten_path = trim(str_replace($base_path, '', \Drupal::url('<front>', array(), $options)), '/');
+ $rewritten_path = trim(str_replace($base_path, '', \Drupal::url('<front>', [], $options)), '/');
$segments = explode('/', $rewritten_path, 2);
$prefix = $segments[0];
$path = isset($segments[1]) ? $segments[1] : $prefix;
@@ -106,11 +106,11 @@ class LanguageUrlRewritingTest extends WebTestBase {
$language_domain = 'example.fr';
// Get the current host URI we're running on.
$base_url_host = parse_url($base_url, PHP_URL_HOST);
- $edit = array(
+ $edit = [
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => $base_url_host,
'domain[fr]' => $language_domain
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
// Rebuild the container so that the new language gets picked up by services
// that hold the list of languages.
@@ -126,11 +126,11 @@ class LanguageUrlRewritingTest extends WebTestBase {
// In case index.php is part of the URLs, we need to adapt the asserted
// URLs as well.
- $index_php = strpos(\Drupal::url('<front>', array(), array('absolute' => TRUE)), 'index.php') !== FALSE;
+ $index_php = strpos(\Drupal::url('<front>', [], ['absolute' => TRUE]), 'index.php') !== FALSE;
$request = Request::createFromGlobals();
$server = $request->server->all();
- $request = $this->prepareRequestForGenerator(TRUE, array('HTTP_HOST' => $server['HTTP_HOST'] . ':88'));
+ $request = $this->prepareRequestForGenerator(TRUE, ['HTTP_HOST' => $server['HTTP_HOST'] . ':88']);
// Create an absolute French link.
$language = \Drupal::languageManager()->getLanguage('fr');
diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
index 99b2fff2770..4021667055d 100644
--- a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
+++ b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
@@ -24,19 +24,19 @@ class LanguageConfigurationElement extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$conf = ContentLanguageSettings::loadByEntityTypeBundle('entity_test', 'some_bundle');
- $form['lang_configuration'] = array(
+ $form['lang_configuration'] = [
'#type' => 'language_configuration',
- '#entity_information' => array(
+ '#entity_information' => [
'entity_type' => 'entity_test',
'bundle' => 'some_bundle',
- ),
+ ],
'#default_value' => $conf,
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- );
+ ];
$form['#submit'][] = 'language_configuration_element_submit';
return $form;
}
diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php
index 0aa6c4975b7..f0fe8c51e5a 100644
--- a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php
+++ b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php
@@ -21,11 +21,11 @@ class LanguageConfigurationElementTest extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['langcode'] = array(
+ $form['langcode'] = [
'#title' => t('Language select'),
'#type' => 'language_select',
'#default_value' => language_get_default_langcode('entity_test', 'some_bundle'),
- );
+ ];
return $form;
}
diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module
index 4803202f261..5ea9c360bd4 100644
--- a/core/modules/language/tests/language_test/language_test.module
+++ b/core/modules/language/tests/language_test/language_test.module
@@ -15,7 +15,7 @@ use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI;
function language_test_page_top() {
if (\Drupal::moduleHandler()->moduleExists('language')) {
language_test_store_language_negotiation();
- drupal_set_message(t('Language negotiation method: @name', array('@name' => \Drupal::languageManager()->getNegotiatedLanguageMethod())));
+ drupal_set_message(t('Language negotiation method: @name', ['@name' => \Drupal::languageManager()->getNegotiatedLanguageMethod()]));
}
}
@@ -24,16 +24,16 @@ function language_test_page_top() {
*/
function language_test_language_types_info() {
if (\Drupal::state()->get('language_test.language_types')) {
- return array(
- 'test_language_type' => array(
+ return [
+ 'test_language_type' => [
'name' => t('Test'),
'description' => t('A test language type.'),
- ),
- 'fixed_test_language_type' => array(
- 'fixed' => array('test_language_negotiation_method'),
+ ],
+ 'fixed_test_language_type' => [
+ 'fixed' => ['test_language_negotiation_method'],
'locked' => TRUE,
- ),
- );
+ ],
+ ];
}
}
@@ -68,7 +68,7 @@ function language_test_language_negotiation_info_alter(array &$negotiation_info)
* Store the last negotiated languages.
*/
function language_test_store_language_negotiation() {
- $last = array();
+ $last = [];
foreach (\Drupal::languageManager()->getDefinedLanguageTypes() as $type) {
$last[$type] = \Drupal::languageManager()->getCurrentLanguage($type)->getId();
}
diff --git a/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php b/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php
index 136d8eba60d..441b2eb8727 100644
--- a/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php
+++ b/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php
@@ -60,7 +60,7 @@ class LanguageTestController implements ContainerInjectionInterface {
* Testing feedback based on (translated) entity title.
*/
public function testEntity(ConfigurableLanguageInterface $configurable_language) {
- return array('#markup' => $this->t('Loaded %label.', array('%label' => $configurable_language->label())));
+ return ['#markup' => $this->t('Loaded %label.', ['%label' => $configurable_language->label()])];
}
/**
@@ -72,43 +72,43 @@ class LanguageTestController implements ContainerInjectionInterface {
public function typeLinkActiveClass() {
// We assume that 'en' and 'fr' have been configured.
$languages = $this->languageManager->getLanguages();
- return array(
- 'no_language' => array(
+ return [
+ 'no_language' => [
'#type' => 'link',
'#title' => t('Link to the current path with no langcode provided.'),
'#url' => Url::fromRoute('<current>'),
- '#options' => array(
- 'attributes' => array(
+ '#options' => [
+ 'attributes' => [
'id' => 'no_lang_link',
- ),
+ ],
'set_active_class' => TRUE,
- ),
- ),
- 'fr' => array(
+ ],
+ ],
+ 'fr' => [
'#type' => 'link',
'#title' => t('Link to a French version of the current path.'),
'#url' => Url::fromRoute('<current>'),
- '#options' => array(
+ '#options' => [
'language' => $languages['fr'],
- 'attributes' => array(
+ 'attributes' => [
'id' => 'fr_link',
- ),
+ ],
'set_active_class' => TRUE,
- ),
- ),
- 'en' => array(
+ ],
+ ],
+ 'en' => [
'#type' => 'link',
'#title' => t('Link to an English version of the current path.'),
'#url' => Url::fromRoute('<current>'),
- '#options' => array(
+ '#options' => [
'language' => $languages['en'],
- 'attributes' => array(
+ 'attributes' => [
'id' => 'en_link',
- ),
+ ],
'set_active_class' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -130,7 +130,7 @@ class LanguageTestController implements ContainerInjectionInterface {
else {
$base_path = $request->getBasePath();
}
- $sub_request = Request::create($base_path . '/user', 'GET', $request->query->all(), $request->cookies->all(), array(), $server);
+ $sub_request = Request::create($base_path . '/user', 'GET', $request->query->all(), $request->cookies->all(), [], $server);
return $this->httpKernel->handle($sub_request, HttpKernelInterface::SUB_REQUEST);
}
diff --git a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
index bd46a405733..f689a9233fe 100644
--- a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
+++ b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
@@ -12,14 +12,14 @@ use Drupal\Tests\BrowserTestBase;
*/
class AdminPathEntityConverterLanguageTest extends BrowserTestBase {
- public static $modules = array('language', 'language_test');
+ public static $modules = ['language', 'language_test'];
protected function setUp() {
parent::setUp();
- $permissions = array(
+ $permissions = [
'access administration pages',
'administer site configuration',
- );
+ ];
$this->drupalLogin($this->drupalCreateUser($permissions));
ConfigurableLanguage::createFromLangcode('es')->save();
}
@@ -34,12 +34,12 @@ class AdminPathEntityConverterLanguageTest extends BrowserTestBase {
->save();
$this->drupalGet('es/admin/language_test/entity_using_current_language/es');
- $this->assertNoRaw(t('Loaded %label.', array('%label' => 'Spanish')));
- $this->assertRaw(t('Loaded %label.', array('%label' => 'Español')));
+ $this->assertNoRaw(t('Loaded %label.', ['%label' => 'Spanish']));
+ $this->assertRaw(t('Loaded %label.', ['%label' => 'Español']));
$this->drupalGet('es/admin/language_test/entity_using_original_language/es');
- $this->assertRaw(t('Loaded %label.', array('%label' => 'Spanish')));
- $this->assertNoRaw(t('Loaded %label.', array('%label' => 'Español')));
+ $this->assertRaw(t('Loaded %label.', ['%label' => 'Spanish']));
+ $this->assertNoRaw(t('Loaded %label.', ['%label' => 'Español']));
}
}
diff --git a/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php b/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php
index 3090d5bf50c..003c5a63fa6 100644
--- a/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php
@@ -11,12 +11,12 @@ use Drupal\Tests\BrowserTestBase;
*/
class LanguageBlockSettingsVisibilityTest extends BrowserTestBase {
- public static $modules = array('block', 'language');
+ public static $modules = ['block', 'language'];
public function testUnnecessaryLanguageSettingsVisibility() {
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer blocks'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer blocks']);
$this->drupalLogin($admin_user);
- $this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language'));
+ $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'hu'], t('Add language'));
$this->drupalGet('admin/structure/block/add/system_menu_block:admin/stark');
$this->assertNoFieldByXPath('//input[@id="edit-visibility-language-langcodes-und"]', NULL, '\'Not specified\' option does not appear at block config, language settings section.');
$this->assertNoFieldByXpath('//input[@id="edit-visibility-language-langcodes-zxx"]', NULL, '\'Not applicable\' option does not appear at block config, language settings section.');
diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
index 1b1382afe13..b32909b9a50 100644
--- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
@@ -11,7 +11,7 @@ use Drupal\Tests\BrowserTestBase;
*/
class LanguageBrowserDetectionTest extends BrowserTestBase {
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Tests for adding, editing and deleting mappings between browser language
@@ -19,7 +19,7 @@ class LanguageBrowserDetectionTest extends BrowserTestBase {
*/
function testUIBrowserLanguageMappings() {
// User to manage languages.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
// Check that the configure link exists.
@@ -34,19 +34,19 @@ class LanguageBrowserDetectionTest extends BrowserTestBase {
// Delete zh-cn language code.
$browser_langcode = 'zh-cn';
$this->drupalGet('admin/config/regional/language/detection/browser/delete/' . $browser_langcode);
- $message = t('Are you sure you want to delete @browser_langcode?', array(
+ $message = t('Are you sure you want to delete @browser_langcode?', [
'@browser_langcode' => $browser_langcode,
- ));
+ ]);
$this->assertRaw($message);
// Confirm the delete.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/config/regional/language/detection/browser/delete/' . $browser_langcode, $edit, t('Confirm'));
// We need raw here because %browser will add HTML.
- $t_args = array(
+ $t_args = [
'%browser' => $browser_langcode,
- );
+ ];
$this->assertRaw(t('The mapping for the %browser browser language code has been deleted.', $t_args), 'The test browser language code has been deleted.');
// Check we went back to the browser negotiation mapping overview.
@@ -55,10 +55,10 @@ class LanguageBrowserDetectionTest extends BrowserTestBase {
$this->assertNoField('edit-mappings-zh-cn-browser-langcode', 'Chinese browser language code no longer exists.');
// Add a new custom mapping.
- $edit = array(
+ $edit = [
'new_mapping[browser_langcode]' => 'xx',
'new_mapping[drupal_langcode]' => 'en',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
$this->assertUrl(\Drupal::url('language.negotiation_browser', [], ['absolute' => TRUE]));
$this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.');
@@ -69,18 +69,18 @@ class LanguageBrowserDetectionTest extends BrowserTestBase {
$this->assertText('Browser language codes must be unique.');
// Change browser language code of our custom mapping to zh-sg.
- $edit = array(
+ $edit = [
'mappings[xx][browser_langcode]' => 'zh-sg',
'mappings[xx][drupal_langcode]' => 'en',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
$this->assertText(t('Browser language codes must be unique.'));
// Change Drupal language code of our custom mapping to zh-hans.
- $edit = array(
+ $edit = [
'mappings[xx][browser_langcode]' => 'xx',
'mappings[xx][drupal_langcode]' => 'zh-hans',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
$this->assertUrl(\Drupal::url('language.negotiation_browser', [], ['absolute' => TRUE]));
$this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.');
diff --git a/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php b/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php
index 76d97fb2919..2ddd4963ed3 100644
--- a/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php
@@ -17,7 +17,7 @@ class LanguageConfigOverrideImportTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('language', 'config', 'locale', 'config_translation');
+ public static $modules = ['language', 'config', 'locale', 'config_translation'];
/**
* Tests that language can be enabled and overrides are created during a sync.
@@ -31,7 +31,7 @@ class LanguageConfigOverrideImportTest extends BrowserTestBase {
// Uninstall the language module and its dependencies so we can test
// enabling the language module and creating overrides at the same time
// during a configuration synchronization.
- \Drupal::service('module_installer')->uninstall(array('language'));
+ \Drupal::service('module_installer')->uninstall(['language']);
// Ensure that the current site has no overrides registered to the
// ConfigFactory.
$this->rebuildContainer();
@@ -39,8 +39,8 @@ class LanguageConfigOverrideImportTest extends BrowserTestBase {
/* @var \Drupal\Core\Config\StorageInterface $override_sync */
$override_sync = $sync->createCollection('language.fr');
// Create some overrides in sync.
- $override_sync->write('system.site', array('name' => 'FR default site name'));
- $override_sync->write('system.maintenance', array('message' => 'FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience'));
+ $override_sync->write('system.site', ['name' => 'FR default site name']);
+ $override_sync->write('system.maintenance', ['message' => 'FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience']);
$this->configImporter()->import();
$this->rebuildContainer();
@@ -61,7 +61,7 @@ class LanguageConfigOverrideImportTest extends BrowserTestBase {
*/
public function testConfigOverrideImportEvents() {
// Enable the config_events_test module so we can record events occurring.
- \Drupal::service('module_installer')->install(array('config_events_test'));
+ \Drupal::service('module_installer')->install(['config_events_test']);
$this->rebuildContainer();
ConfigurableLanguage::createFromLangcode('fr')->save();
@@ -73,7 +73,7 @@ class LanguageConfigOverrideImportTest extends BrowserTestBase {
/* @var \Drupal\Core\Config\StorageInterface $override_sync */
$override_sync = $sync->createCollection('language.fr');
// Create some overrides in sync.
- $override_sync->write('system.site', array('name' => 'FR default site name'));
+ $override_sync->write('system.site', ['name' => 'FR default site name']);
\Drupal::state()->set('config_events_test.event', FALSE);
$this->configImporter()->import();
diff --git a/core/modules/language/tests/src/Functional/LanguageConfigSchemaTest.php b/core/modules/language/tests/src/Functional/LanguageConfigSchemaTest.php
index 12a6843ce27..200131a80c8 100644
--- a/core/modules/language/tests/src/Functional/LanguageConfigSchemaTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageConfigSchemaTest.php
@@ -19,7 +19,7 @@ class LanguageConfigSchemaTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('language', 'menu_link_content');
+ public static $modules = ['language', 'menu_link_content'];
/**
* A user with administrative permissions.
@@ -35,7 +35,7 @@ class LanguageConfigSchemaTest extends BrowserTestBase {
parent::setUp();
// Create user.
- $this->adminUser = $this->drupalCreateUser(array('administer languages'));
+ $this->adminUser = $this->drupalCreateUser(['administer languages']);
$this->drupalLogin($this->adminUser);
}
diff --git a/core/modules/language/tests/src/Functional/LanguageListModuleInstallTest.php b/core/modules/language/tests/src/Functional/LanguageListModuleInstallTest.php
index fccc200c61f..bcd664db9f4 100644
--- a/core/modules/language/tests/src/Functional/LanguageListModuleInstallTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageListModuleInstallTest.php
@@ -17,7 +17,7 @@ class LanguageListModuleInstallTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('language_test');
+ public static $modules = ['language_test'];
/**
* Tests enabling Language.
@@ -25,9 +25,9 @@ class LanguageListModuleInstallTest extends BrowserTestBase {
function testModuleInstallLanguageList() {
// Since LanguageManager::getLanguages() uses static caches we need to do
// this by enabling the module using the UI.
- $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
+ $admin_user = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$this->drupalLogin($admin_user);
- $edit = array();
+ $edit = [];
$edit['modules[language][enable]'] = 'language';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
diff --git a/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php b/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
index 89914378226..27785c09529 100644
--- a/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
@@ -25,7 +25,7 @@ class LanguageNegotiationContentEntityTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('language', 'language_test', 'entity_test', 'system');
+ public static $modules = ['language', 'language_test', 'entity_test', 'system'];
/**
* The entity being used for testing.
@@ -49,7 +49,7 @@ class LanguageNegotiationContentEntityTest extends BrowserTestBase {
$this->createTranslatableEntity();
- $user = $this->drupalCreateUser(array('view test entity'));
+ $user = $this->drupalCreateUser(['view test entity']);
$this->drupalLogin($user);
}
diff --git a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
index 3dd037464b3..ebcd5807186 100644
--- a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
@@ -27,7 +27,7 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
parent::setUp();
$admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'view the administration theme', 'administer modules']);
$this->drupalLogin($admin_user);
- $this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'it'), t('Add language'));
+ $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'it'], t('Add language'));
}
/**
@@ -62,15 +62,15 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
* Tests alterations to language types/negotiation info.
*/
function testInfoAlterations() {
- $this->stateSet(array(
+ $this->stateSet([
// Enable language_test type info.
'language_test.language_types' => TRUE,
// Enable language_test negotiation info (not altered yet).
'language_test.language_negotiation_info' => TRUE,
// Alter LanguageInterface::TYPE_CONTENT to be configurable.
'language_test.content_language_type' => TRUE,
- ));
- $this->container->get('module_installer')->install(array('language_test'));
+ ]);
+ $this->container->get('module_installer')->install(['language_test']);
$this->resetAll();
// Check that fixed language types are properly configured without the need
@@ -87,19 +87,19 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
$interface_method_id = LanguageNegotiationUI::METHOD_ID;
$test_method_id = 'test_language_negotiation_method';
$form_field = $type . '[enabled][' . $interface_method_id . ']';
- $edit = array(
+ $edit = [
$form_field => TRUE,
$type . '[enabled][' . $test_method_id . ']' => TRUE,
$test_type . '[enabled][' . $test_method_id . ']' => TRUE,
$test_type . '[configurable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Alter language negotiation info to remove interface language negotiation
// method.
- $this->stateSet(array(
+ $this->stateSet([
'language_test.language_negotiation_info_alter' => TRUE,
- ));
+ ]);
$negotiation = $this->config('language.types')->get('negotiation.' . $type . '.enabled');
$this->assertFalse(isset($negotiation[$interface_method_id]), 'Interface language negotiation method removed from the stored settings.');
@@ -112,10 +112,10 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
foreach ($this->languageManager()->getLanguageTypes() as $type) {
$form_field = $type . '[enabled][test_language_negotiation_method_ts]';
if ($type == $test_type) {
- $this->assertFieldByName($form_field, NULL, format_string('Type-specific test language negotiation method available for %type.', array('%type' => $type)));
+ $this->assertFieldByName($form_field, NULL, format_string('Type-specific test language negotiation method available for %type.', ['%type' => $type]));
}
else {
- $this->assertNoFieldByName($form_field, NULL, format_string('Type-specific test language negotiation method unavailable for %type.', array('%type' => $type)));
+ $this->assertNoFieldByName($form_field, NULL, format_string('Type-specific test language negotiation method unavailable for %type.', ['%type' => $type]));
}
}
@@ -125,17 +125,17 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
foreach ($this->languageManager()->getDefinedLanguageTypes() as $type) {
$langcode = $last[$type];
$value = $type == LanguageInterface::TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en';
- $this->assertEqual($langcode, $value, format_string('The negotiated language for %type is %language', array('%type' => $type, '%language' => $value)));
+ $this->assertEqual($langcode, $value, format_string('The negotiated language for %type is %language', ['%type' => $type, '%language' => $value]));
}
// Uninstall language_test and check that everything is set back to the
// original status.
- $this->container->get('module_installer')->uninstall(array('language_test'));
+ $this->container->get('module_installer')->uninstall(['language_test']);
$this->rebuildContainer();
// Check that only the core language types are available.
foreach ($this->languageManager()->getDefinedLanguageTypes() as $type) {
- $this->assertTrue(strpos($type, 'test') === FALSE, format_string('The %type language is still available', array('%type' => $type)));
+ $this->assertTrue(strpos($type, 'test') === FALSE, format_string('The %type language is still available', ['%type' => $type]));
}
// Check that fixed language types are properly configured, even those
@@ -165,7 +165,7 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
list(, $info_id) = each($info['fixed']);
$equal = $info_id == $id;
}
- $this->assertTrue($equal, format_string('language negotiation for %type is properly set up', array('%type' => $type)));
+ $this->assertTrue($equal, format_string('language negotiation for %type is properly set up', ['%type' => $type]));
}
}
}
diff --git a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php
index 681b378d692..952f748ba17 100644
--- a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php
+++ b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php
@@ -22,22 +22,22 @@ class LanguagePathMonolingualTest extends BrowserTestBase {
parent::setUp();
// Create and log in user.
- $web_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer site configuration'));
+ $web_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer site configuration']);
$this->drupalLogin($web_user);
// Enable French language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Make French the default language.
- $edit = array(
+ $edit = [
'site_default_language' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
// Delete English.
- $this->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
// Changing the default language causes a container rebuild. Therefore need
// to rebuild the container in the test environment.
@@ -49,7 +49,7 @@ class LanguagePathMonolingualTest extends BrowserTestBase {
$this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'fr', 'French is the default language');
// Set language detection to URL.
- $edit = array('language_interface[enabled][language-url]' => TRUE);
+ $edit = ['language_interface[enabled][language-url]' => TRUE];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->drupalPlaceBlock('local_actions_block');
}
diff --git a/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php b/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php
index 92b2a04f272..af7eed4b7f5 100644
--- a/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php
+++ b/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php
@@ -32,12 +32,12 @@ class LanguageConditionTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'language');
+ public static $modules = ['system', 'language'];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
// Setup Italian.
ConfigurableLanguage::createFromLangcode('it')->save();
@@ -52,14 +52,14 @@ class LanguageConditionTest extends KernelTestBase {
// language.
$language = \Drupal::languageManager()->getLanguage('en');
$condition = $this->manager->createInstance('language')
- ->setConfig('langcodes', array('en' => 'en', 'it' => 'it'))
+ ->setConfig('langcodes', ['en' => 'en', 'it' => 'it'])
->setContextValue('language', $language);
$this->assertTrue($condition->execute(), 'Language condition passes as expected.');
// Check for the proper summary.
$this->assertEqual($condition->summary(), 'The language is English, Italian.');
// Change to Italian only.
- $condition->setConfig('langcodes', array('it' => 'it'));
+ $condition->setConfig('langcodes', ['it' => 'it']);
$this->assertFalse($condition->execute(), 'Language condition fails as expected.');
// Check for the proper summary.
$this->assertEqual($condition->summary(), 'The language is Italian.');
@@ -74,7 +74,7 @@ class LanguageConditionTest extends KernelTestBase {
$language = \Drupal::languageManager()->getLanguage('it');
$condition = $this->manager->createInstance('language')
- ->setConfig('langcodes', array('en' => 'en', 'it' => 'it'))
+ ->setConfig('langcodes', ['en' => 'en', 'it' => 'it'])
->setContextValue('language', $language);
$this->assertTrue($condition->execute(), 'Language condition passes as expected.');
@@ -82,7 +82,7 @@ class LanguageConditionTest extends KernelTestBase {
$this->assertEqual($condition->summary(), 'The language is English, Italian.');
// Change to Italian only.
- $condition->setConfig('langcodes', array('it' => 'it'));
+ $condition->setConfig('langcodes', ['it' => 'it']);
$this->assertTrue($condition->execute(), 'Language condition passes as expected.');
// Check for the proper summary.
$this->assertEqual($condition->summary(), 'The language is Italian.');
diff --git a/core/modules/language/tests/src/Kernel/ConfigurableLanguageManagerTest.php b/core/modules/language/tests/src/Kernel/ConfigurableLanguageManagerTest.php
index dae3a585c83..92ab889ce8e 100644
--- a/core/modules/language/tests/src/Kernel/ConfigurableLanguageManagerTest.php
+++ b/core/modules/language/tests/src/Kernel/ConfigurableLanguageManagerTest.php
@@ -16,7 +16,7 @@ class ConfigurableLanguageManagerTest extends LanguageTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('user');
+ public static $modules = ['user'];
/**
* The language negotiator.
diff --git a/core/modules/language/tests/src/Kernel/ConfigurableLanguageTest.php b/core/modules/language/tests/src/Kernel/ConfigurableLanguageTest.php
index a87a6e3f9e3..00af14cbd37 100644
--- a/core/modules/language/tests/src/Kernel/ConfigurableLanguageTest.php
+++ b/core/modules/language/tests/src/Kernel/ConfigurableLanguageTest.php
@@ -18,7 +18,7 @@ class ConfigurableLanguageTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Tests configurable language name methods.
@@ -26,7 +26,7 @@ class ConfigurableLanguageTest extends KernelTestBase {
public function testName() {
$name = $this->randomMachineName();
$language_code = $this->randomMachineName(2);
- $configurableLanguage = new ConfigurableLanguage(array('label' => $name, 'id' => $language_code), 'configurable_language');
+ $configurableLanguage = new ConfigurableLanguage(['label' => $name, 'id' => $language_code], 'configurable_language');
$this->assertEqual($configurableLanguage->getName(), $name);
$this->assertEqual($configurableLanguage->setName('Test language')->getName(), 'Test language');
}
diff --git a/core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php b/core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php
index 84368b70f64..88abdd9006d 100644
--- a/core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php
+++ b/core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php
@@ -18,7 +18,7 @@ class EntityDefaultLanguageTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('language', 'node', 'field', 'text', 'user', 'system');
+ public static $modules = ['language', 'node', 'field', 'text', 'user', 'system'];
/**
* {@inheritdoc}
@@ -29,9 +29,9 @@ class EntityDefaultLanguageTest extends KernelTestBase {
$this->installEntitySchema('user');
// Activate Spanish language, so there are two languages activated.
- $language = $this->container->get('entity.manager')->getStorage('configurable_language')->create(array(
+ $language = $this->container->get('entity.manager')->getStorage('configurable_language')->create([
'id' => 'es',
- ));
+ ]);
$language->save();
// Create a new content type which has Undefined language by default.
@@ -67,7 +67,7 @@ class EntityDefaultLanguageTest extends KernelTestBase {
$this->assertEqual($node->langcode->value, 'en');
// Disable language module.
- $this->disableModules(array('language'));
+ $this->disableModules(['language']);
// With language module disabled, and a content type that is configured to
// have no language specified by default, a new node of this content type
@@ -101,12 +101,12 @@ class EntityDefaultLanguageTest extends KernelTestBase {
* Default language code of the nodes of this type.
*/
protected function createContentType($name, $langcode) {
- $content_type = $this->container->get('entity.manager')->getStorage('node_type')->create(array(
+ $content_type = $this->container->get('entity.manager')->getStorage('node_type')->create([
'name' => 'Test ' . $name,
'title_label' => 'Title',
'type' => $name,
'create_body' => FALSE,
- ));
+ ]);
$content_type->save();
ContentLanguageSettings::loadByEntityTypeBundle('node', $name)
->setLanguageAlterable(FALSE)
@@ -127,10 +127,10 @@ class EntityDefaultLanguageTest extends KernelTestBase {
* The node created.
*/
protected function createNode($type, $langcode = NULL) {
- $values = array(
+ $values = [
'type' => $type,
'title' => $this->randomString(),
- );
+ ];
if (!empty($langcode)) {
$values['langcode'] = $langcode;
}
diff --git a/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php b/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php
index b8b31a96b93..3082697b042 100644
--- a/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php
+++ b/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php
@@ -17,7 +17,7 @@ class LanguageConfigFactoryOverrideTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'language');
+ public static $modules = ['system', 'language'];
/**
* Tests language.config_factory_override service has the default language.
diff --git a/core/modules/language/tests/src/Kernel/LanguageConfigOverrideInstallTest.php b/core/modules/language/tests/src/Kernel/LanguageConfigOverrideInstallTest.php
index c01187c9e37..7d505baf78f 100644
--- a/core/modules/language/tests/src/Kernel/LanguageConfigOverrideInstallTest.php
+++ b/core/modules/language/tests/src/Kernel/LanguageConfigOverrideInstallTest.php
@@ -17,7 +17,7 @@ class LanguageConfigOverrideInstallTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('language', 'config_events_test');
+ public static $modules = ['language', 'config_events_test'];
/**
* Tests the configuration events are not fired during install of overrides.
@@ -26,9 +26,9 @@ class LanguageConfigOverrideInstallTest extends KernelTestBase {
ConfigurableLanguage::createFromLangcode('de')->save();
// Need to enable test module after creating the language otherwise saving
// the language will install the configuration.
- $this->enableModules(array('language_config_override_test'));
+ $this->enableModules(['language_config_override_test']);
\Drupal::state()->set('config_events_test.event', FALSE);
- $this->installConfig(array('language_config_override_test'));
+ $this->installConfig(['language_config_override_test']);
$event_recorder = \Drupal::state()->get('config_events_test.event', FALSE);
$this->assertFalse($event_recorder);
$config = \Drupal::service('language.config_factory_override')->getOverride('de', 'language_config_override_test.settings');
diff --git a/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php b/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php
index 74b167f3c4a..d41d19e2fef 100644
--- a/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php
+++ b/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php
@@ -22,7 +22,7 @@ class LanguageDependencyInjectionTest extends LanguageTestBase {
$expected = $this->languageManager->getDefaultLanguage();
$result = $this->languageManager->getCurrentLanguage();
foreach ($expected as $property => $value) {
- $this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property)));
+ $this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the new Language object %prop property.', ['%prop' => $property]));
}
}
@@ -45,7 +45,7 @@ class LanguageDependencyInjectionTest extends LanguageTestBase {
// Delete the language to check that we fallback to the default.
try {
- entity_delete_multiple('configurable_language', array('fr'));
+ entity_delete_multiple('configurable_language', ['fr']);
$this->fail('Expected DeleteDefaultLanguageException thrown.');
}
catch (DeleteDefaultLanguageException $e) {
@@ -55,7 +55,7 @@ class LanguageDependencyInjectionTest extends LanguageTestBase {
// Re-save the previous default language and the delete should work.
$this->config('system.site')->set('default_langcode', $default_language->getId())->save();
- entity_delete_multiple('configurable_language', array('fr'));
+ entity_delete_multiple('configurable_language', ['fr']);
$result = \Drupal::languageManager()->getCurrentLanguage();
$this->assertIdentical($result->getId(), $default_language->getId());
}
diff --git a/core/modules/language/tests/src/Kernel/LanguageFallbackTest.php b/core/modules/language/tests/src/Kernel/LanguageFallbackTest.php
index ab293bd5ba6..17f4ca396f7 100644
--- a/core/modules/language/tests/src/Kernel/LanguageFallbackTest.php
+++ b/core/modules/language/tests/src/Kernel/LanguageFallbackTest.php
@@ -19,7 +19,7 @@ class LanguageFallbackTest extends LanguageTestBase {
parent::setUp();
$i = 0;
- foreach (array('af', 'am', 'ar') as $langcode) {
+ foreach (['af', 'am', 'ar'] as $langcode) {
$language = ConfigurableLanguage::createFromLangcode($langcode);
$language->set('weight', $i--);
$language->save();
@@ -31,7 +31,7 @@ class LanguageFallbackTest extends LanguageTestBase {
*/
public function testCandidates() {
$language_list = $this->languageManager->getLanguages();
- $expected = array_keys($language_list + array(LanguageInterface::LANGCODE_NOT_SPECIFIED => NULL));
+ $expected = array_keys($language_list + [LanguageInterface::LANGCODE_NOT_SPECIFIED => NULL]);
// Check that language fallback candidates by default are all the available
// languages sorted by weight.
@@ -49,11 +49,11 @@ class LanguageFallbackTest extends LanguageTestBase {
$this->state->set('language_test.fallback_operation_alter.candidates', TRUE);
$expected[] = LanguageInterface::LANGCODE_NOT_SPECIFIED;
$expected[] = LanguageInterface::LANGCODE_NOT_APPLICABLE;
- $candidates = $this->languageManager->getFallbackCandidates(array('operation' => 'test'));
+ $candidates = $this->languageManager->getFallbackCandidates(['operation' => 'test']);
$this->assertEqual(array_values($candidates), $expected, 'Language fallback candidates are alterable for specific operations.');
// Check that when the site is monolingual no language fallback is applied.
- $langcodes_to_delete = array();
+ $langcodes_to_delete = [];
foreach ($language_list as $langcode => $language) {
if (!$language->isDefault()) {
$langcodes_to_delete[] = $langcode;
@@ -61,7 +61,7 @@ class LanguageFallbackTest extends LanguageTestBase {
}
entity_delete_multiple('configurable_language', $langcodes_to_delete);
$candidates = $this->languageManager->getFallbackCandidates();
- $this->assertEqual(array_values($candidates), array(LanguageInterface::LANGCODE_DEFAULT), 'Language fallback is not applied when the Language module is not enabled.');
+ $this->assertEqual(array_values($candidates), [LanguageInterface::LANGCODE_DEFAULT], 'Language fallback is not applied when the Language module is not enabled.');
}
}
diff --git a/core/modules/language/tests/src/Kernel/LanguageTestBase.php b/core/modules/language/tests/src/Kernel/LanguageTestBase.php
index eb4f0ef0055..f4dcbd2f9df 100644
--- a/core/modules/language/tests/src/Kernel/LanguageTestBase.php
+++ b/core/modules/language/tests/src/Kernel/LanguageTestBase.php
@@ -9,7 +9,7 @@ use Drupal\KernelTests\KernelTestBase;
*/
abstract class LanguageTestBase extends KernelTestBase {
- public static $modules = array('system', 'language', 'language_test');
+ public static $modules = ['system', 'language', 'language_test'];
/**
* The language manager.
*
@@ -30,7 +30,7 @@ abstract class LanguageTestBase extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
$this->state = $this->container->get('state');
diff --git a/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php b/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php
index 94bb02d3396..dd2e67ecfe5 100644
--- a/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php
+++ b/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php
@@ -24,9 +24,9 @@ trait MigrateDefaultLanguageTrait {
// default language is migrated.
$value = 'O:8:"stdClass":11:{s:8:"language";s:2:"' . $langcode . '";s:4:"name";s:6:"French";s:6:"native";s:6:"French";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"0";s:7:"formula";s:0:"";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:1:"0";s:10:"javascript";s:0:"";}';
$this->sourceDatabase->update('variable')
- ->fields(array(
+ ->fields([
'value' => $value
- ))
+ ])
->condition('name', 'language_default' )
->execute();
diff --git a/core/modules/language/tests/src/Kernel/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php b/core/modules/language/tests/src/Kernel/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php
index 0e74f494aa4..4a884274026 100644
--- a/core/modules/language/tests/src/Kernel/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php
+++ b/core/modules/language/tests/src/Kernel/Migrate/d6/MigrateLanguageNegotiationSettingsTest.php
@@ -56,7 +56,7 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal6TestBase {
*/
public function testLanguageNegotiationWithNoNegotiation() {
$this->sourceDatabase->update('variable')
- ->fields(array('value' => serialize(0)))
+ ->fields(['value' => serialize(0)])
->condition('name', 'language_negotiation')
->execute();
@@ -88,7 +88,7 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal6TestBase {
*/
public function testLanguageNegotiationWithPathPrefix() {
$this->sourceDatabase->update('variable')
- ->fields(array('value' => serialize(2)))
+ ->fields(['value' => serialize(2)])
->condition('name', 'language_negotiation')
->execute();
@@ -129,7 +129,7 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal6TestBase {
*/
public function testLanguageNegotiationWithDomain() {
$this->sourceDatabase->update('variable')
- ->fields(array('value' => serialize(3)))
+ ->fields(['value' => serialize(3)])
->condition('name', 'language_negotiation')
->execute();
diff --git a/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php b/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php
index 269bac697a2..09681dee652 100644
--- a/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php
+++ b/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php
@@ -75,7 +75,7 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal7TestBase {
*/
public function testLanguageNegotiationWithDomain() {
$this->sourceDatabase->update('variable')
- ->fields(array('value' => serialize(1)))
+ ->fields(['value' => serialize(1)])
->condition('name', 'locale_language_negotiation_url_part')
->execute();
diff --git a/core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php b/core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php
index 3a4e9cf7572..27c7410b9b6 100644
--- a/core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php
+++ b/core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php
@@ -17,28 +17,28 @@ class ArgumentLanguageTest extends LanguageTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the language argument.
*/
public function testArgument() {
$view = Views::getView('test_view');
- foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) {
+ foreach (['en' => 'John', 'xx-lolspeak' => 'George'] as $langcode => $name) {
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('arguments', array(
- 'langcode' => array(
+ $view->displayHandlers->get('default')->overrideOption('arguments', [
+ 'langcode' => [
'id' => 'langcode',
'table' => 'views_test_data',
'field' => 'langcode',
- ),
- ));
- $this->executeView($view, array($langcode));
+ ],
+ ]);
+ $this->executeView($view, [$langcode]);
- $expected = array(array(
+ $expected = [[
'name' => $name,
- ));
- $this->assertIdenticalResultset($view, $expected, array('views_test_data_name' => 'name'));
+ ]];
+ $this->assertIdenticalResultset($view, $expected, ['views_test_data_name' => 'name']);
$view->destroy();
}
}
diff --git a/core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php b/core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php
index 3dbbfe424df..5dc71240460 100644
--- a/core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php
+++ b/core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php
@@ -17,7 +17,7 @@ class FieldLanguageTest extends LanguageTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the language field.
@@ -25,13 +25,13 @@ class FieldLanguageTest extends LanguageTestBase {
public function testField() {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'langcode' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'langcode' => [
'id' => 'langcode',
'table' => 'views_test_data',
'field' => 'langcode',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
$this->assertEqual($view->field['langcode']->advancedRender($view->result[0]), 'English');
diff --git a/core/modules/language/tests/src/Kernel/Views/FilterLanguageTest.php b/core/modules/language/tests/src/Kernel/Views/FilterLanguageTest.php
index 0c6241a4ea8..c9dc98cbf38 100644
--- a/core/modules/language/tests/src/Kernel/Views/FilterLanguageTest.php
+++ b/core/modules/language/tests/src/Kernel/Views/FilterLanguageTest.php
@@ -17,29 +17,29 @@ class FilterLanguageTest extends LanguageTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the language filter.
*/
public function testFilter() {
$view = Views::getView('test_view');
- foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) {
+ foreach (['en' => 'John', 'xx-lolspeak' => 'George'] as $langcode => $name) {
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'langcode' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'langcode' => [
'id' => 'langcode',
'table' => 'views_test_data',
'field' => 'langcode',
- 'value' => array($langcode),
- ),
- ));
+ 'value' => [$langcode],
+ ],
+ ]);
$this->executeView($view);
- $expected = array(array(
+ $expected = [[
'name' => $name,
- ));
- $this->assertIdenticalResultset($view, $expected, array('views_test_data_name' => 'name'));
+ ]];
+ $this->assertIdenticalResultset($view, $expected, ['views_test_data_name' => 'name']);
$expected = [
'***LANGUAGE_site_default***',
diff --git a/core/modules/language/tests/src/Kernel/Views/LanguageTestBase.php b/core/modules/language/tests/src/Kernel/Views/LanguageTestBase.php
index cb5d4739db6..cab6fc84e0b 100644
--- a/core/modules/language/tests/src/Kernel/Views/LanguageTestBase.php
+++ b/core/modules/language/tests/src/Kernel/Views/LanguageTestBase.php
@@ -15,14 +15,14 @@ abstract class LanguageTestBase extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'language');
+ public static $modules = ['system', 'language'];
protected function setUp($import_test_views = TRUE) {
parent::setUp();
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
// Create another language beside English.
- ConfigurableLanguage::create(array('id' => 'xx-lolspeak', 'label' => 'Lolspeak'))->save();
+ ConfigurableLanguage::create(['id' => 'xx-lolspeak', 'label' => 'Lolspeak'])->save();
}
/**
@@ -30,12 +30,12 @@ abstract class LanguageTestBase extends ViewsKernelTestBase {
*/
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
- $schema['views_test_data']['fields']['langcode'] = array(
+ $schema['views_test_data']['fields']['langcode'] = [
'description' => 'The {language}.langcode of this beatle.',
'type' => 'varchar',
'length' => 12,
'default' => '',
- );
+ ];
return $schema;
}
@@ -45,19 +45,19 @@ abstract class LanguageTestBase extends ViewsKernelTestBase {
*/
protected function viewsData() {
$data = parent::viewsData();
- $data['views_test_data']['langcode'] = array(
+ $data['views_test_data']['langcode'] = [
'title' => t('Langcode'),
'help' => t('Langcode'),
- 'field' => array(
+ 'field' => [
'id' => 'language',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'language',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'language',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/language/tests/src/Unit/ConfigurableLanguageUnitTest.php b/core/modules/language/tests/src/Unit/ConfigurableLanguageUnitTest.php
index d5de7a63f5f..58670f0255a 100644
--- a/core/modules/language/tests/src/Unit/ConfigurableLanguageUnitTest.php
+++ b/core/modules/language/tests/src/Unit/ConfigurableLanguageUnitTest.php
@@ -21,11 +21,11 @@ class ConfigurableLanguageUnitTest extends UnitTestCase {
// Direction of language writing, an integer. Usually either
// ConfigurableLanguage::DIRECTION_LTR or
// ConfigurableLanguage::DIRECTION_RTL.
- $configurableLanguage = new ConfigurableLanguage(array('direction' => ConfigurableLanguage::DIRECTION_LTR), 'configurable_language');
+ $configurableLanguage = new ConfigurableLanguage(['direction' => ConfigurableLanguage::DIRECTION_LTR], 'configurable_language');
$this->assertEquals(ConfigurableLanguage::DIRECTION_LTR, $configurableLanguage->getDirection());
// Test direction again, setting direction to RTL.
- $configurableLanguage = new ConfigurableLanguage(array('direction' => ConfigurableLanguage::DIRECTION_RTL), 'configurable_language');
+ $configurableLanguage = new ConfigurableLanguage(['direction' => ConfigurableLanguage::DIRECTION_RTL], 'configurable_language');
$this->assertEquals(ConfigurableLanguage::DIRECTION_RTL, $configurableLanguage->getDirection());
}
@@ -36,7 +36,7 @@ class ConfigurableLanguageUnitTest extends UnitTestCase {
public function testWeight() {
// The weight, an integer. Used to order languages with larger positive
// weights sinking items toward the bottom of lists.
- $configurableLanguage = new ConfigurableLanguage(array('weight' => -5), 'configurable_language');
+ $configurableLanguage = new ConfigurableLanguage(['weight' => -5], 'configurable_language');
$this->assertEquals($configurableLanguage->getWeight(), -5);
$this->assertEquals($configurableLanguage->setWeight(13)->getWeight(), 13);
}
diff --git a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php
index b1a1487194e..06820d06318 100644
--- a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php
+++ b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php
@@ -86,17 +86,17 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getBundleConfigDependency')
- ->will($this->returnValue(array('type' => 'config', 'name' => 'test.test_entity_type.id')));
+ ->will($this->returnValue(['type' => 'config', 'name' => 'test.test_entity_type.id']));
$this->entityManager->expects($this->any())
->method('getDefinition')
->with('test_entity_type')
->will($this->returnValue($target_entity_type));
- $config = new ContentLanguageSettings(array(
+ $config = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$dependencies = $config->calculateDependencies()->getDependencies();
$this->assertContains('test.test_entity_type.id', $dependencies['config']);
}
@@ -105,10 +105,10 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
* @covers ::id
*/
public function testId() {
- $config = new ContentLanguageSettings(array(
+ $config = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$this->assertSame('test_entity_type.test_bundle', $config->id());
}
@@ -116,10 +116,10 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
* @covers ::getTargetEntityTypeId
*/
public function testTargetEntityTypeId() {
- $config = new ContentLanguageSettings(array(
+ $config = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$this->assertSame('test_entity_type', $config->getTargetEntityTypeId());
}
@@ -127,10 +127,10 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
* @covers ::getTargetBundle
*/
public function testTargetBundle() {
- $config = new ContentLanguageSettings(array(
+ $config = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$this->assertSame('test_bundle', $config->getTargetBundle());
}
@@ -146,16 +146,16 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
public function providerDefaultLangcode() {
$langcode = $this->randomMachineName();
- $config = new ContentLanguageSettings(array(
+ $config = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$config->setDefaultLangcode($langcode);
- $defaultConfig = new ContentLanguageSettings(array(
+ $defaultConfig = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_default_language_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
return [
[$config, $langcode],
@@ -174,22 +174,22 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
}
public function providerLanguageAlterable() {
- $alterableConfig = new ContentLanguageSettings(array(
+ $alterableConfig = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$alterableConfig->setLanguageAlterable(TRUE);
- $nonAlterableConfig = new ContentLanguageSettings(array(
+ $nonAlterableConfig = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_fixed_language_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$nonAlterableConfig->setLanguageAlterable(FALSE);
- $defaultConfig = new ContentLanguageSettings(array(
+ $defaultConfig = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_default_language_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
return [
[$alterableConfig, TRUE],
@@ -208,22 +208,22 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
}
public function providerIsDefaultConfiguration() {
- $alteredLanguage = new ContentLanguageSettings(array(
+ $alteredLanguage = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$alteredLanguage->setLanguageAlterable(TRUE);
- $alteredDefaultLangcode = new ContentLanguageSettings(array(
+ $alteredDefaultLangcode = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_fixed_language_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$alteredDefaultLangcode->setDefaultLangcode($this->randomMachineName());
- $defaultConfig = new ContentLanguageSettings(array(
+ $defaultConfig = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_default_language_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
return [
[$alteredLanguage, FALSE],
@@ -240,10 +240,10 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
public function testLoadByEntityTypeBundle($config_id, ContentLanguageSettings $existing_config = NULL, $expected_langcode, $expected_language_alterable) {
list($type, $bundle) = explode('.', $config_id);
- $nullConfig = new ContentLanguageSettings(array(
+ $nullConfig = new ContentLanguageSettings([
'target_entity_type_id' => $type,
'target_bundle' => $bundle,
- ), 'language_content_settings');
+ ], 'language_content_settings');
$this->configEntityStorageInterface
->expects($this->any())
->method('load')
@@ -271,23 +271,23 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
}
public function providerLoadByEntityTypeBundle() {
- $alteredLanguage = new ContentLanguageSettings(array(
+ $alteredLanguage = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$alteredLanguage->setLanguageAlterable(TRUE);
$langcode = $this->randomMachineName();
- $alteredDefaultLangcode = new ContentLanguageSettings(array(
+ $alteredDefaultLangcode = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_fixed_language_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
$alteredDefaultLangcode->setDefaultLangcode($langcode);
- $defaultConfig = new ContentLanguageSettings(array(
+ $defaultConfig = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type',
'target_bundle' => 'test_default_language_bundle',
- ), 'language_content_settings');
+ ], 'language_content_settings');
return [
['test_entity_type.test_bundle', $alteredLanguage, LanguageInterface::LANGCODE_SITE_DEFAULT, TRUE],
diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
index 735abd67b68..825ca7d863d 100644
--- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
+++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
@@ -33,10 +33,10 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
$language_en->expects($this->any())
->method('getId')
->will($this->returnValue('en'));
- $languages = array(
+ $languages = [
'de' => $language_de,
'en' => $language_en,
- );
+ ];
$this->languages = $languages;
// Create a language manager stub.
@@ -126,7 +126,7 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
// No configuration.
$path_prefix_configuration[] = [
'prefix' => 'de',
- 'prefixes' => array(),
+ 'prefixes' => [],
'expected_langcode' => FALSE,
];
// Non-matching prefix.
@@ -168,7 +168,7 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
],
]);
- $request = Request::create('', 'GET', array(), array(), array(), array('HTTP_HOST' => $http_host));
+ $request = Request::create('', 'GET', [], [], [], ['HTTP_HOST' => $http_host]);
$method = new LanguageNegotiationUrl();
$method->setLanguageManager($this->languageManager);
$method->setConfig($config);
@@ -193,60 +193,60 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
*/
public function providerTestDomain() {
- $domain_configuration[] = array(
+ $domain_configuration[] = [
'http_host' => 'example.de',
- 'domains' => array(
+ 'domains' => [
'de' => 'http://example.de',
- ),
+ ],
'expected_langcode' => 'de',
- );
+ ];
// No configuration.
- $domain_configuration[] = array(
+ $domain_configuration[] = [
'http_host' => 'example.de',
- 'domains' => array(),
+ 'domains' => [],
'expected_langcode' => FALSE,
- );
+ ];
// HTTP host with a port.
- $domain_configuration[] = array(
+ $domain_configuration[] = [
'http_host' => 'example.de:8080',
- 'domains' => array(
+ 'domains' => [
'de' => 'http://example.de',
- ),
+ ],
'expected_langcode' => 'de',
- );
+ ];
// Domain configuration with https://.
- $domain_configuration[] = array(
+ $domain_configuration[] = [
'http_host' => 'example.de',
- 'domains' => array(
+ 'domains' => [
'de' => 'https://example.de',
- ),
+ ],
'expected_langcode' => 'de',
- );
+ ];
// Non-matching HTTP host.
- $domain_configuration[] = array(
+ $domain_configuration[] = [
'http_host' => 'example.com',
- 'domains' => array(
+ 'domains' => [
'de' => 'http://example.com',
- ),
+ ],
'expected_langcode' => 'de',
- );
+ ];
// Testing a non-existing language.
- $domain_configuration[] = array(
+ $domain_configuration[] = [
'http_host' => 'example.com',
- 'domains' => array(
+ 'domains' => [
'it' => 'http://example.it',
- ),
+ ],
'expected_langcode' => FALSE,
- );
+ ];
// Multiple domain configurations.
- $domain_configuration[] = array(
+ $domain_configuration[] = [
'http_host' => 'example.com',
- 'domains' => array(
+ 'domains' => [
'de' => 'http://example.de',
'en' => 'http://example.com',
- ),
+ ],
'expected_langcode' => 'en',
- );
+ ];
return $domain_configuration;
}
diff --git a/core/modules/language/tests/src/Unit/Menu/LanguageLocalTasksTest.php b/core/modules/language/tests/src/Unit/Menu/LanguageLocalTasksTest.php
index 1f711ae78e1..a231e198b58 100644
--- a/core/modules/language/tests/src/Unit/Menu/LanguageLocalTasksTest.php
+++ b/core/modules/language/tests/src/Unit/Menu/LanguageLocalTasksTest.php
@@ -12,9 +12,9 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class LanguageLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array(
+ $this->directoryList = [
'language' => 'core/modules/language',
- );
+ ];
parent::setUp();
}
@@ -31,19 +31,19 @@ class LanguageLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getLanguageAdminOverviewRoutes() {
- return array(
- array('entity.configurable_language.collection', array(array('entity.configurable_language.collection', 'language.negotiation'))),
- array('language.negotiation', array(array('entity.configurable_language.collection', 'language.negotiation'))),
- );
+ return [
+ ['entity.configurable_language.collection', [['entity.configurable_language.collection', 'language.negotiation']]],
+ ['language.negotiation', [['entity.configurable_language.collection', 'language.negotiation']]],
+ ];
}
/**
* Tests language edit local tasks existence.
*/
public function testLanguageEditLocalTasks() {
- $this->assertLocalTasks('entity.configurable_language.edit_form', array(
- 0 => array('entity.configurable_language.edit_form'),
- ));
+ $this->assertLocalTasks('entity.configurable_language.edit_form', [
+ 0 => ['entity.configurable_language.edit_form'],
+ ]);
}
}
diff --git a/core/modules/link/link.module b/core/modules/link/link.module
index 46aeeba21f3..5a3527fc41b 100644
--- a/core/modules/link/link.module
+++ b/core/modules/link/link.module
@@ -15,11 +15,11 @@ function link_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.link':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Link module allows you to create fields that contain internal or external URLs and optional link text. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":link_documentation">online documentation for the Link module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':link_documentation' => 'https://www.drupal.org/documentation/modules/link')) . '</p>';
+ $output .= '<p>' . t('The Link module allows you to create fields that contain internal or external URLs and optional link text. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":link_documentation">online documentation for the Link module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':link_documentation' => 'https://www.drupal.org/documentation/modules/link']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying link fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the link field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the link field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Setting the allowed link type') . '</dt>';
$output .= '<dd>' . t('In the field settings you can define the allowed link type to be <em>internal links only</em>, <em>external links only</em>, or <em>both internal and external links</em>. <em>Internal links only</em> and <em>both internal and external links</em> options enable an autocomplete widget for internal links, so a user does not have to copy or remember a URL.') . '</dd>';
$output .= '<dt>' . t('Adding link text') . '</dt>';
@@ -39,11 +39,11 @@ function link_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function link_theme() {
- return array(
- 'link_formatter_link_separate' => array(
- 'variables' => array('title' => NULL, 'url_title' => NULL, 'url' => NULL),
- ),
- );
+ return [
+ 'link_formatter_link_separate' => [
+ 'variables' => ['title' => NULL, 'url_title' => NULL, 'url' => NULL],
+ ],
+ ];
}
/**
diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php
index 7d2d0eeabd3..30fcd8e260d 100644
--- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php
+++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php
@@ -78,13 +78,13 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'trim_length' => '80',
'url_only' => '',
'url_plain' => '',
'rel' => '',
'target' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -93,43 +93,43 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
- $elements['trim_length'] = array(
+ $elements['trim_length'] = [
'#type' => 'number',
'#title' => t('Trim link text length'),
'#field_suffix' => t('characters'),
'#default_value' => $this->getSetting('trim_length'),
'#min' => 1,
'#description' => t('Leave blank to allow unlimited link text lengths.'),
- );
- $elements['url_only'] = array(
+ ];
+ $elements['url_only'] = [
'#type' => 'checkbox',
'#title' => t('URL only'),
'#default_value' => $this->getSetting('url_only'),
'#access' => $this->getPluginId() == 'link',
- );
- $elements['url_plain'] = array(
+ ];
+ $elements['url_plain'] = [
'#type' => 'checkbox',
'#title' => t('Show URL as plain text'),
'#default_value' => $this->getSetting('url_plain'),
'#access' => $this->getPluginId() == 'link',
- '#states' => array(
- 'visible' => array(
- ':input[name*="url_only"]' => array('checked' => TRUE),
- ),
- ),
- );
- $elements['rel'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name*="url_only"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $elements['rel'] = [
'#type' => 'checkbox',
'#title' => t('Add rel="nofollow" to links'),
'#return_value' => 'nofollow',
'#default_value' => $this->getSetting('rel'),
- );
- $elements['target'] = array(
+ ];
+ $elements['target'] = [
'#type' => 'checkbox',
'#title' => t('Open link in new window'),
'#return_value' => '_blank',
'#default_value' => $this->getSetting('target'),
- );
+ ];
return $elements;
}
@@ -138,12 +138,12 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$settings = $this->getSettings();
if (!empty($settings['trim_length'])) {
- $summary[] = t('Link text trimmed to @limit characters', array('@limit' => $settings['trim_length']));
+ $summary[] = t('Link text trimmed to @limit characters', ['@limit' => $settings['trim_length']]);
}
else {
$summary[] = t('Link text not trimmed');
@@ -157,7 +157,7 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
}
}
if (!empty($settings['rel'])) {
- $summary[] = t('Add rel="@rel"', array('@rel' => $settings['rel']));
+ $summary[] = t('Add rel="@rel"', ['@rel' => $settings['rel']]);
}
if (!empty($settings['target'])) {
$summary[] = t('Open link in new window');
@@ -170,7 +170,7 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $element = array();
+ $element = [];
$entity = $items->getEntity();
$settings = $this->getSettings();
@@ -193,9 +193,9 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
}
if (!empty($settings['url_only']) && !empty($settings['url_plain'])) {
- $element[$delta] = array(
+ $element[$delta] = [
'#plain_text' => $link_title,
- );
+ ];
if (!empty($item->_attributes)) {
// Piggyback on the metadata attributes, which will be placed in the
@@ -204,19 +204,19 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
// @todo Does RDF need a URL rather than an internal URI here?
// @see \Drupal\Tests\rdf\Kernel\Field\LinkFieldRdfaTest.
$content = str_replace('internal:/', '', $item->uri);
- $item->_attributes += array('content' => $content);
+ $item->_attributes += ['content' => $content];
}
}
else {
- $element[$delta] = array(
+ $element[$delta] = [
'#type' => 'link',
'#title' => $link_title,
'#options' => $url->getOptions(),
- );
+ ];
$element[$delta]['#url'] = $url;
if (!empty($item->_attributes)) {
- $element[$delta]['#options'] += array ('attributes' => array());
+ $element[$delta]['#options'] += ['attributes' => []];
$element[$delta]['#options']['attributes'] += $item->_attributes;
// Unset field item attributes since they have been included in the
// formatter output and should not be rendered in the field template.
diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php
index f7370378e38..2598b55b6fb 100644
--- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php
+++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php
@@ -26,18 +26,18 @@ class LinkSeparateFormatter extends LinkFormatter {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'trim_length' => 80,
'rel' => '',
'target' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $element = array();
+ $element = [];
$entity = $items->getEntity();
$settings = $this->getSettings();
@@ -67,12 +67,12 @@ class LinkSeparateFormatter extends LinkFormatter {
$url_title = Unicode::truncate($url_title, $settings['trim_length'], FALSE, TRUE);
}
- $element[$delta] = array(
+ $element[$delta] = [
'#theme' => 'link_formatter_link_separate',
'#title' => $link_title,
'#url_title' => $url_title,
'#url' => $url,
- );
+ ];
if (!empty($item->_attributes)) {
// Set our RDFa attributes on the <a> element that is being built.
diff --git a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
index 6e98ae22545..e354f00871c 100644
--- a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
+++ b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
@@ -30,10 +30,10 @@ class LinkItem extends FieldItemBase implements LinkItemInterface {
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
@@ -56,58 +56,58 @@ class LinkItem extends FieldItemBase implements LinkItemInterface {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'uri' => array(
+ return [
+ 'columns' => [
+ 'uri' => [
'description' => 'The URI of the link.',
'type' => 'varchar',
'length' => 2048,
- ),
- 'title' => array(
+ ],
+ 'title' => [
'description' => 'The link text.',
'type' => 'varchar',
'length' => 255,
- ),
- 'options' => array(
+ ],
+ 'options' => [
'description' => 'Serialized array of options for the link.',
'type' => 'blob',
'size' => 'big',
'serialize' => TRUE,
- ),
- ),
- 'indexes' => array(
- 'uri' => array(array('uri', 30)),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'uri' => [['uri', 30]],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- $element = array();
+ $element = [];
- $element['link_type'] = array(
+ $element['link_type'] = [
'#type' => 'radios',
'#title' => t('Allowed link type'),
'#default_value' => $this->getSetting('link_type'),
- '#options' => array(
+ '#options' => [
static::LINK_INTERNAL => t('Internal links only'),
static::LINK_EXTERNAL => t('External links only'),
static::LINK_GENERIC => t('Both internal and external links'),
- ),
- );
+ ],
+ ];
- $element['title'] = array(
+ $element['title'] = [
'#type' => 'radios',
'#title' => t('Allow link text'),
'#default_value' => $this->getSetting('title'),
- '#options' => array(
+ '#options' => [
DRUPAL_DISABLED => t('Disabled'),
DRUPAL_OPTIONAL => t('Optional'),
DRUPAL_REQUIRED => t('Required'),
- ),
- );
+ ],
+ ];
return $element;
}
@@ -119,7 +119,7 @@ class LinkItem extends FieldItemBase implements LinkItemInterface {
$random = new Random();
if ($field_definition->getItemDefinition()->getSetting('link_type') & LinkItemInterface::LINK_EXTERNAL) {
// Set of possible top-level domains.
- $tlds = array('com', 'net', 'gov', 'org', 'edu', 'biz', 'info');
+ $tlds = ['com', 'net', 'gov', 'org', 'edu', 'biz', 'info'];
// Set random length for the domain name.
$domain_length = mt_rand(7, 15);
diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
index 9af176cb03f..e1b1c2a8f57 100644
--- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
+++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
@@ -27,10 +27,10 @@ class LinkWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'placeholder_url' => '',
'placeholder_title' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -74,7 +74,7 @@ class LinkWidget extends WidgetBase {
// Show the 'entity:' URI as the entity autocomplete would.
$entity_manager = \Drupal::entityManager();
if ($entity_manager->getDefinition($entity_type, FALSE) && $entity = \Drupal::entityManager()->getStorage($entity_type)->load($entity_id)) {
- $displayable_string = EntityAutocomplete::getEntityLabels(array($entity));
+ $displayable_string = EntityAutocomplete::getEntityLabels([$entity]);
}
}
@@ -153,7 +153,7 @@ class LinkWidget extends WidgetBase {
$element['title']['#required'] = TRUE;
// We expect the field name placeholder value to be wrapped in t() here,
// so it won't be escaped again as it's already marked safe.
- $form_state->setError($element['title'], t('@name field is required.', array('@name' => $element['title']['#title'])));
+ $form_state->setError($element['title'], t('@name field is required.', ['@name' => $element['title']['#title']]));
}
}
@@ -164,7 +164,7 @@ class LinkWidget extends WidgetBase {
/** @var \Drupal\link\LinkItemInterface $item */
$item = $items[$delta];
- $element['uri'] = array(
+ $element['uri'] = [
'#type' => 'url',
'#title' => $this->t('URL'),
'#placeholder' => $this->getSetting('placeholder_url'),
@@ -172,10 +172,10 @@ class LinkWidget extends WidgetBase {
// However, if it is inaccessible to the current user, do not display it
// to them.
'#default_value' => (!$item->isEmpty() && (\Drupal::currentUser()->hasPermission('link to any page') || $item->getUrl()->access())) ? static::getUriAsDisplayableString($item->uri) : NULL,
- '#element_validate' => array(array(get_called_class(), 'validateUriElement')),
+ '#element_validate' => [[get_called_class(), 'validateUriElement']],
'#maxlength' => 2048,
'#required' => $element['#required'],
- );
+ ];
// If the field is configured to support internal links, it cannot use the
// 'url' form element and we have to do the validation ourselves.
@@ -195,43 +195,43 @@ class LinkWidget extends WidgetBase {
// If the field is configured to allow only internal links, add a useful
// element prefix and description.
if (!$this->supportsExternalLinks()) {
- $element['uri']['#field_prefix'] = rtrim(\Drupal::url('<front>', array(), array('absolute' => TRUE)), '/');
- $element['uri']['#description'] = $this->t('This must be an internal path such as %add-node. You can also start typing the title of a piece of content to select it. Enter %front to link to the front page.', array('%add-node' => '/node/add', '%front' => '<front>'));
+ $element['uri']['#field_prefix'] = rtrim(\Drupal::url('<front>', [], ['absolute' => TRUE]), '/');
+ $element['uri']['#description'] = $this->t('This must be an internal path such as %add-node. You can also start typing the title of a piece of content to select it. Enter %front to link to the front page.', ['%add-node' => '/node/add', '%front' => '<front>']);
}
// If the field is configured to allow both internal and external links,
// show a useful description.
elseif ($this->supportsExternalLinks() && $this->supportsInternalLinks()) {
- $element['uri']['#description'] = $this->t('Start typing the title of a piece of content to select it. You can also enter an internal path such as %add-node or an external URL such as %url. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => '/node/add', '%url' => 'http://example.com'));
+ $element['uri']['#description'] = $this->t('Start typing the title of a piece of content to select it. You can also enter an internal path such as %add-node or an external URL such as %url. Enter %front to link to the front page.', ['%front' => '<front>', '%add-node' => '/node/add', '%url' => 'http://example.com']);
}
// If the field is configured to allow only external links, show a useful
// description.
elseif ($this->supportsExternalLinks() && !$this->supportsInternalLinks()) {
- $element['uri']['#description'] = $this->t('This must be an external URL such as %url.', array('%url' => 'http://example.com'));
+ $element['uri']['#description'] = $this->t('This must be an external URL such as %url.', ['%url' => 'http://example.com']);
}
- $element['title'] = array(
+ $element['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Link text'),
'#placeholder' => $this->getSetting('placeholder_title'),
'#default_value' => isset($items[$delta]->title) ? $items[$delta]->title : NULL,
'#maxlength' => 255,
'#access' => $this->getFieldSetting('title') != DRUPAL_DISABLED,
- );
+ ];
// Post-process the title field to make it conditionally required if URL is
// non-empty. Omit the validation on the field edit form, since the field
// settings cannot be saved otherwise.
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') == DRUPAL_REQUIRED) {
- $element['#element_validate'][] = array(get_called_class(), 'validateTitleElement');
+ $element['#element_validate'][] = [get_called_class(), 'validateTitleElement'];
}
// Exposing the attributes array in the widget is left for alternate and more
// advanced field widgets.
- $element['attributes'] = array(
+ $element['attributes'] = [
'#type' => 'value',
'#tree' => TRUE,
- '#value' => !empty($items[$delta]->options['attributes']) ? $items[$delta]->options['attributes'] : array(),
- '#attributes' => array('class' => array('link-field-widget-attributes')),
- );
+ '#value' => !empty($items[$delta]->options['attributes']) ? $items[$delta]->options['attributes'] : [],
+ '#attributes' => ['class' => ['link-field-widget-attributes']],
+ ];
// If cardinality is 1, ensure a proper label is output for the field.
if ($this->fieldDefinition->getFieldStorageDefinition()->getCardinality() == 1) {
@@ -242,9 +242,9 @@ class LinkWidget extends WidgetBase {
}
// Otherwise wrap everything in a details element.
else {
- $element += array(
+ $element += [
'#type' => 'fieldset',
- );
+ ];
}
}
@@ -281,23 +281,23 @@ class LinkWidget extends WidgetBase {
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
- $elements['placeholder_url'] = array(
+ $elements['placeholder_url'] = [
'#type' => 'textfield',
'#title' => $this->t('Placeholder for URL'),
'#default_value' => $this->getSetting('placeholder_url'),
'#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
- $elements['placeholder_title'] = array(
+ ];
+ $elements['placeholder_title'] = [
'#type' => 'textfield',
'#title' => $this->t('Placeholder for link text'),
'#default_value' => $this->getSetting('placeholder_title'),
'#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- '#states' => array(
- 'invisible' => array(
- ':input[name="instance[settings][title]"]' => array('value' => DRUPAL_DISABLED),
- ),
- ),
- );
+ '#states' => [
+ 'invisible' => [
+ ':input[name="instance[settings][title]"]' => ['value' => DRUPAL_DISABLED],
+ ],
+ ],
+ ];
return $elements;
}
@@ -306,7 +306,7 @@ class LinkWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$placeholder_title = $this->getSetting('placeholder_title');
$placeholder_url = $this->getSetting('placeholder_url');
@@ -315,10 +315,10 @@ class LinkWidget extends WidgetBase {
}
else {
if (!empty($placeholder_title)) {
- $summary[] = $this->t('Title placeholder: @placeholder_title', array('@placeholder_title' => $placeholder_title));
+ $summary[] = $this->t('Title placeholder: @placeholder_title', ['@placeholder_title' => $placeholder_title]);
}
if (!empty($placeholder_url)) {
- $summary[] = $this->t('URL placeholder: @placeholder_url', array('@placeholder_url' => $placeholder_url));
+ $summary[] = $this->t('URL placeholder: @placeholder_url', ['@placeholder_url' => $placeholder_url]);
}
}
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php
index 7d0e4fbee70..16ccae0fc7e 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php
@@ -55,7 +55,7 @@ class LinkAccessConstraintValidator extends ConstraintValidator implements Conta
// permission nor can access this URI.
$allowed = $this->current_user->hasPermission('link to any page') || $url->access();
if (!$allowed) {
- $this->context->addViolation($constraint->message, array('@uri' => $value->uri));
+ $this->context->addViolation($constraint->message, ['@uri' => $value->uri]);
}
}
}
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php
index 0bc178a7e08..94841739183 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php
@@ -26,7 +26,7 @@ class LinkExternalProtocolsConstraintValidator extends ConstraintValidator {
}
// Disallow external URLs using untrusted protocols.
if ($url->isExternal() && !in_array(parse_url($url->getUri(), PHP_URL_SCHEME), UrlHelper::getAllowedProtocols())) {
- $this->context->addViolation($constraint->message, array('@uri' => $value->uri));
+ $this->context->addViolation($constraint->message, ['@uri' => $value->uri]);
}
}
}
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php
index 46218133d5a..6e2f0cff655 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php
@@ -44,7 +44,7 @@ class LinkNotExistingInternalConstraintValidator extends ConstraintValidator {
$allowed = FALSE;
}
if (!$allowed) {
- $this->context->addViolation($constraint->message, array('@uri' => $value->uri));
+ $this->context->addViolation($constraint->message, ['@uri' => $value->uri]);
}
}
}
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php
index a67eb4dfc0b..817e934b0ff 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php
@@ -43,7 +43,7 @@ class LinkTypeConstraintValidator extends ConstraintValidator {
}
if (!$uri_is_valid) {
- $this->context->addViolation($constraint->message, array('@uri' => $link_item->uri));
+ $this->context->addViolation($constraint->message, ['@uri' => $link_item->uri]);
}
}
}
diff --git a/core/modules/link/src/Tests/LinkFieldTest.php b/core/modules/link/src/Tests/LinkFieldTest.php
index e85ad531879..f25066ffb95 100644
--- a/core/modules/link/src/Tests/LinkFieldTest.php
+++ b/core/modules/link/src/Tests/LinkFieldTest.php
@@ -55,33 +55,33 @@ class LinkFieldTest extends WebTestBase {
function testURLValidation() {
$field_name = Unicode::strtolower($this->randomMachineName());
// Create a field with settings to validate.
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
- ));
+ ]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
- 'settings' => array(
+ 'settings' => [
'title' => DRUPAL_DISABLED,
'link_type' => LinkItemInterface::LINK_GENERIC,
- ),
+ ],
]);
$this->field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'link_default',
- 'settings' => array(
+ 'settings' => [
'placeholder_url' => 'http://example.com',
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'link',
- ))
+ ])
->save();
// Display creation form.
@@ -103,14 +103,14 @@ class LinkFieldTest extends WebTestBase {
// Define some valid URLs (keys are the entered values, values are the
// strings displayed to the user).
- $valid_external_entries = array(
+ $valid_external_entries = [
'http://www.example.com/' => 'http://www.example.com/',
// Strings within parenthesis without leading space char.
'http://www.example.com/strings_(string_within_parenthesis)' => 'http://www.example.com/strings_(string_within_parenthesis)',
// Numbers within parenthesis without leading space char.
'http://www.example.com/numbers_(9999)' => 'http://www.example.com/numbers_(9999)',
- );
- $valid_internal_entries = array(
+ ];
+ $valid_internal_entries = [
'/entity_test/add' => '/entity_test/add',
'/a/path/alias' => '/a/path/alias',
@@ -137,24 +137,24 @@ class LinkFieldTest extends WebTestBase {
'entity:entity_test/' . $entity_test_no_label_access->id() => '- Restricted access - (' . $entity_test_no_label_access->id() . ')',
// URI for an entity that doesn't exist, but with a valid ID.
'entity:user/999999' => 'entity:user/999999',
- );
+ ];
// Define some invalid URLs.
$validation_error_1 = "The path '@link_path' is invalid.";
$validation_error_2 = 'Manually entered paths should start with /, ? or #.';
$validation_error_3 = "The path '@link_path' is inaccessible.";
- $invalid_external_entries = array(
+ $invalid_external_entries = [
// Invalid protocol
'invalid://not-a-valid-protocol' => $validation_error_1,
// Missing host name
'http://' => $validation_error_1,
- );
- $invalid_internal_entries = array(
+ ];
+ $invalid_internal_entries = [
'no-leading-slash' => $validation_error_2,
'entity:non_existing_entity_type/yar' => $validation_error_1,
// URI for an entity that doesn't exist, with an invalid ID.
'entity:user/invalid-parameter' => $validation_error_1,
- );
+ ];
// Test external and internal URLs for 'link_type' = LinkItemInterface::LINK_GENERIC.
$this->assertValidEntries($field_name, $valid_external_entries + $valid_internal_entries);
@@ -191,13 +191,13 @@ class LinkFieldTest extends WebTestBase {
*/
protected function assertValidEntries($field_name, array $valid_entries) {
foreach ($valid_entries as $uri => $string) {
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => $uri,
- );
+ ];
$this->drupalPostForm('entity_test/add', $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($string);
}
}
@@ -212,11 +212,11 @@ class LinkFieldTest extends WebTestBase {
*/
protected function assertInvalidEntries($field_name, array $invalid_entries) {
foreach ($invalid_entries as $invalid_value => $error_message) {
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => $invalid_value,
- );
+ ];
$this->drupalPostForm('entity_test/add', $edit, t('Save'));
- $this->assertText(t($error_message, array('@link_path' => $invalid_value)));
+ $this->assertText(t($error_message, ['@link_path' => $invalid_value]));
}
}
@@ -226,40 +226,40 @@ class LinkFieldTest extends WebTestBase {
function testLinkTitle() {
$field_name = Unicode::strtolower($this->randomMachineName());
// Create a field with settings to validate.
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
- ));
+ ]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'label' => 'Read more about this entity',
- 'settings' => array(
+ 'settings' => [
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC,
- ),
+ ],
]);
$this->field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'link_default',
- 'settings' => array(
+ 'settings' => [
'placeholder_url' => 'http://example.com',
'placeholder_title' => 'Enter the text for this link',
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'link',
'label' => 'hidden',
- ))
+ ])
->save();
// Verify that the link text field works according to the field setting.
- foreach (array(DRUPAL_DISABLED, DRUPAL_REQUIRED, DRUPAL_OPTIONAL) as $title_setting) {
+ foreach ([DRUPAL_DISABLED, DRUPAL_REQUIRED, DRUPAL_OPTIONAL] as $title_setting) {
// Update the link title field setting.
$this->field->setSetting('title', $title_setting);
$this->field->save();
@@ -281,41 +281,41 @@ class LinkFieldTest extends WebTestBase {
$this->assertFieldByName("{$field_name}[0][title]", '', 'Link text field found.');
if ($title_setting === DRUPAL_REQUIRED) {
// Verify that the link text is required, if the URL is non-empty.
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => 'http://www.example.com',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('@name field is required.', array('@name' => t('Link text'))));
+ $this->assertText(t('@name field is required.', ['@name' => t('Link text')]));
// Verify that the link text is not required, if the URL is empty.
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => '',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
+ $this->assertNoText(t('@name field is required.', ['@name' => t('Link text')]));
// Verify that a URL and link text meets requirements.
$this->drupalGet('entity_test/add');
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => 'http://www.example.com',
"{$field_name}[0][title]" => 'Example',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
+ $this->assertNoText(t('@name field is required.', ['@name' => t('Link text')]));
}
}
}
// Verify that a link without link text is rendered using the URL as text.
$value = 'http://www.example.com/';
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => $value,
"{$field_name}[0][title]" => '',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->renderTestEntity($id);
$expected_link = \Drupal::l($value, Url::fromUri($value));
@@ -323,11 +323,11 @@ class LinkFieldTest extends WebTestBase {
// Verify that a link with text is rendered using the link text.
$title = $this->randomMachineName();
- $edit = array(
+ $edit = [
"{$field_name}[0][title]" => $title,
- );
+ ];
$this->drupalPostForm("entity_test/manage/$id/edit", $edit, t('Save'));
- $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been updated.', ['@id' => $id]));
$this->renderTestEntity($id);
$expected_link = \Drupal::l($title, Url::fromUri($value));
@@ -340,31 +340,31 @@ class LinkFieldTest extends WebTestBase {
function testLinkFormatter() {
$field_name = Unicode::strtolower($this->randomMachineName());
// Create a field with settings to validate.
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
'cardinality' => 3,
- ));
+ ]);
$this->fieldStorage->save();
FieldConfig::create([
'field_storage' => $this->fieldStorage,
'label' => 'Read more about this entity',
'bundle' => 'entity_test',
- 'settings' => array(
+ 'settings' => [
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC,
- ),
+ ],
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'link_default',
- ))
+ ])
->save();
- $display_options = array(
+ $display_options = [
'type' => 'link',
'label' => 'hidden',
- );
+ ];
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent($field_name, $display_options)
->save();
@@ -383,7 +383,7 @@ class LinkFieldTest extends WebTestBase {
// Intentionally contains an ampersand that needs sanitization on output.
$title2 = 'A very long & strange example title that could break the nice layout of the site';
$title3 = 'Fragment only';
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => $url1,
// Note that $title1 is not submitted.
"{$field_name}[0][title]" => '',
@@ -391,35 +391,35 @@ class LinkFieldTest extends WebTestBase {
"{$field_name}[1][title]" => $title2,
"{$field_name}[2][uri]" => $url3,
"{$field_name}[2][title]" => $title3,
- );
+ ];
// Assert label is shown.
$this->assertText('Read more about this entity');
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
// Verify that the link is output according to the formatter settings.
// Not using generatePermutations(), since that leads to 32 cases, which
// would not test actual link field formatter functionality but rather
// the link generator and options/attributes. Only 'url_plain' has a
// dependency on 'url_only', so we have a total of ~10 cases.
- $options = array(
- 'trim_length' => array(NULL, 6),
- 'rel' => array(NULL, 'nofollow'),
- 'target' => array(NULL, '_blank'),
- 'url_only' => array(
- array('url_only' => FALSE),
- array('url_only' => FALSE, 'url_plain' => TRUE),
- array('url_only' => TRUE),
- array('url_only' => TRUE, 'url_plain' => TRUE),
- ),
- );
+ $options = [
+ 'trim_length' => [NULL, 6],
+ 'rel' => [NULL, 'nofollow'],
+ 'target' => [NULL, '_blank'],
+ 'url_only' => [
+ ['url_only' => FALSE],
+ ['url_only' => FALSE, 'url_plain' => TRUE],
+ ['url_only' => TRUE],
+ ['url_only' => TRUE, 'url_plain' => TRUE],
+ ],
+ ];
foreach ($options as $setting => $values) {
foreach ($values as $new_value) {
// Update the field formatter settings.
if (!is_array($new_value)) {
- $display_options['settings'] = array($setting => $new_value);
+ $display_options['settings'] = [$setting => $new_value];
}
else {
$display_options['settings'] = $new_value;
@@ -495,29 +495,29 @@ class LinkFieldTest extends WebTestBase {
function testLinkSeparateFormatter() {
$field_name = Unicode::strtolower($this->randomMachineName());
// Create a field with settings to validate.
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'link',
'cardinality' => 3,
- ));
+ ]);
$this->fieldStorage->save();
FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
- 'settings' => array(
+ 'settings' => [
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC,
- ),
+ ],
])->save();
- $display_options = array(
+ $display_options = [
'type' => 'link_separate',
'label' => 'hidden',
- );
+ ];
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'link_default',
- ))
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent($field_name, $display_options)
@@ -536,28 +536,28 @@ class LinkFieldTest extends WebTestBase {
// Intentionally contains an ampersand that needs sanitization on output.
$title2 = 'A very long & strange example title that could break the nice layout of the site';
$title3 = 'Fragment only';
- $edit = array(
+ $edit = [
"{$field_name}[0][uri]" => $url1,
"{$field_name}[1][uri]" => $url2,
"{$field_name}[1][title]" => $title2,
"{$field_name}[2][uri]" => $url3,
"{$field_name}[2][title]" => $title3,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
// Verify that the link is output according to the formatter settings.
- $options = array(
- 'trim_length' => array(NULL, 6),
- 'rel' => array(NULL, 'nofollow'),
- 'target' => array(NULL, '_blank'),
- );
+ $options = [
+ 'trim_length' => [NULL, 6],
+ 'rel' => [NULL, 'nofollow'],
+ 'target' => [NULL, '_blank'],
+ ];
foreach ($options as $setting => $values) {
foreach ($values as $new_value) {
// Update the field formatter settings.
- $display_options['settings'] = array($setting => $new_value);
+ $display_options['settings'] = [$setting => $new_value];
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent($field_name, $display_options)
->save();
@@ -622,7 +622,7 @@ class LinkFieldTest extends WebTestBase {
*/
protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
if ($reset) {
- $this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
+ $this->container->get('entity.manager')->getStorage('entity_test')->resetCache([$id]);
}
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), $view_mode);
diff --git a/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php b/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
index ec06ca614f9..80913ece8dd 100644
--- a/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
+++ b/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
@@ -40,27 +40,27 @@ class LinkViewsTokensTest extends ViewTestBase {
*/
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('link_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['link_test_views']);
// Create Basic page node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page'
- ));
+ ]);
// Create a field.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'type' => 'link',
'entity_type' => 'node',
'cardinality' => 1,
- ))->save();
- FieldConfig::create(array(
+ ])->save();
+ FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'link field',
- ))->save();
+ ])->save();
}
@@ -72,7 +72,7 @@ class LinkViewsTokensTest extends ViewTestBase {
// Add nodes with the URI's and titles.
foreach ($uris as $uri => $title) {
- $values = array('type' => 'page');
+ $values = ['type' => 'page'];
$values[$this->fieldName][] = ['uri' => $uri, 'title' => $title, 'options' => ['attributes' => ['class' => 'test-link-class']]];
$this->drupalCreateNode($values);
}
diff --git a/core/modules/link/tests/src/Functional/LinkFieldUITest.php b/core/modules/link/tests/src/Functional/LinkFieldUITest.php
index eeed78c4c0f..c990e6439dc 100644
--- a/core/modules/link/tests/src/Functional/LinkFieldUITest.php
+++ b/core/modules/link/tests/src/Functional/LinkFieldUITest.php
@@ -60,7 +60,7 @@ class LinkFieldUITest extends BrowserTestBase {
// generate warnings.
// @todo Mess with the formatter settings a bit here.
$this->drupalGet("$type_path/display");
- $this->assertText(t('Link text trimmed to @limit characters', array('@limit' => 80)));
+ $this->assertText(t('Link text trimmed to @limit characters', ['@limit' => 80]));
// Test the help text displays when the link field allows both internal and
// external links.
@@ -81,7 +81,7 @@ class LinkFieldUITest extends BrowserTestBase {
$label = $this->randomMachineName();
$field_name = Unicode::strtolower($label);
$field_edit = ['settings[link_type]' => LinkItemInterface::LINK_EXTERNAL];
- $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', array(), $field_edit);
+ $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', [], $field_edit);
// Test the help text displays when link allows only external links.
$this->drupalLogin($this->drupalCreateUser(['create ' . $type->id() . ' content']));
diff --git a/core/modules/link/tests/src/Kernel/LinkItemTest.php b/core/modules/link/tests/src/Kernel/LinkItemTest.php
index 5e2c45dbbb3..ff4f8405678 100644
--- a/core/modules/link/tests/src/Kernel/LinkItemTest.php
+++ b/core/modules/link/tests/src/Kernel/LinkItemTest.php
@@ -24,7 +24,7 @@ class LinkItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('link');
+ public static $modules = ['link'];
protected function setUp() {
parent::setUp();
@@ -78,7 +78,7 @@ class LinkItemTest extends FieldKernelTestBase {
$entity->field_test->uri = $parsed_url['path'];
$entity->field_test->title = $title;
$entity->field_test->first()->get('options')->set('query', $parsed_url['query']);
- $entity->field_test->first()->get('options')->set('attributes', array('class' => $class));
+ $entity->field_test->first()->get('options')->set('attributes', ['class' => $class]);
$this->assertEquals([
'query' => $parsed_url['query'],
'attributes' => [
@@ -118,7 +118,7 @@ class LinkItemTest extends FieldKernelTestBase {
$entity->field_test->uri = $new_url;
$entity->field_test->title = $new_title;
$entity->field_test->first()->get('options')->set('query', NULL);
- $entity->field_test->first()->get('options')->set('attributes', array('class' => $new_class));
+ $entity->field_test->first()->get('options')->set('attributes', ['class' => $new_class]);
$this->assertEqual($entity->field_test->uri, $new_url);
$this->assertEqual($entity->field_test->title, $new_title);
$this->assertEqual($entity->field_test->options['attributes']['class'], $new_class);
diff --git a/core/modules/locale/locale.api.php b/core/modules/locale/locale.api.php
index 56210e54f49..3cf1e12ea77 100644
--- a/core/modules/locale/locale.api.php
+++ b/core/modules/locale/locale.api.php
@@ -116,11 +116,11 @@
*/
function hook_locale_translation_projects_alter(&$projects) {
// The translations are located at a custom translation sever.
- $projects['existing_project'] = array(
- 'info' => array(
+ $projects['existing_project'] = [
+ 'info' => [
'interface translation server pattern' => 'http://example.com/files/translations/%core/%project/%project-%version.%language.po',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc
index 81ca9666713..a18f993f55f 100644
--- a/core/modules/locale/locale.batch.inc
+++ b/core/modules/locale/locale.batch.inc
@@ -38,11 +38,11 @@ require_once __DIR__ . '/locale.translation.inc';
*/
function locale_translation_batch_status_check($project, $langcode, array $options, &$context) {
$failure = $checked = FALSE;
- $options += array(
+ $options += [
'finish_feedback' => TRUE,
'use_remote' => TRUE,
- );
- $source = locale_translation_get_status(array($project), array($langcode));
+ ];
+ $source = locale_translation_get_status([$project], [$langcode]);
$source = $source[$project][$langcode];
// Check the status of local translation files.
@@ -82,7 +82,7 @@ function locale_translation_batch_status_check($project, $langcode, array $optio
if ($failure && !$checked) {
$context['results']['failed_files'][] = $source->name;
}
- $context['message'] = t('Checked translation for %project.', array('%project' => $source->project));
+ $context['message'] = t('Checked translation for %project.', ['%project' => $source->project]);
}
/**
@@ -99,7 +99,7 @@ function locale_translation_batch_status_finished($success, $results) {
if ($success) {
if (isset($results['failed_files'])) {
if (\Drupal::moduleHandler()->moduleExists('dblog') && \Drupal::currentUser()->hasPermission('access site reports')) {
- $message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation file could not be checked. <a href=":url">See the log</a> for details.', '@count translation files could not be checked. <a href=":url">See the log</a> for details.', array(':url' => \Drupal::url('dblog.overview')));
+ $message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation file could not be checked. <a href=":url">See the log</a> for details.', '@count translation files could not be checked. <a href=":url">See the log</a> for details.', [':url' => \Drupal::url('dblog.overview')]);
}
else {
$message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation files could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.');
@@ -139,12 +139,12 @@ function locale_translation_batch_status_finished($success, $results) {
* @see locale_translation_batch_fetch_import()
*/
function locale_translation_batch_fetch_download($project, $langcode, &$context) {
- $sources = locale_translation_get_status(array($project), array($langcode));
+ $sources = locale_translation_get_status([$project], [$langcode]);
if (isset($sources[$project][$langcode])) {
$source = $sources[$project][$langcode];
if (isset($source->type) && $source->type == LOCALE_TRANSLATION_REMOTE) {
if ($file = locale_translation_download_source($source->files[LOCALE_TRANSLATION_REMOTE], 'translations://')) {
- $context['message'] = t('Downloaded translation for %project.', array('%project' => $source->project));
+ $context['message'] = t('Downloaded translation for %project.', ['%project' => $source->project]);
locale_translation_status_save($source->name, $source->langcode, LOCALE_TRANSLATION_LOCAL, $file);
}
else {
@@ -173,16 +173,16 @@ function locale_translation_batch_fetch_download($project, $langcode, &$context)
* @see locale_translation_batch_fetch_download()
*/
function locale_translation_batch_fetch_import($project, $langcode, $options, &$context) {
- $sources = locale_translation_get_status(array($project), array($langcode));
+ $sources = locale_translation_get_status([$project], [$langcode]);
if (isset($sources[$project][$langcode])) {
$source = $sources[$project][$langcode];
if (isset($source->type)) {
if ($source->type == LOCALE_TRANSLATION_REMOTE || $source->type == LOCALE_TRANSLATION_LOCAL) {
$file = $source->files[LOCALE_TRANSLATION_LOCAL];
module_load_include('bulk.inc', 'locale');
- $options += array(
- 'message' => t('Importing translation for %project.', array('%project' => $source->project)),
- );
+ $options += [
+ 'message' => t('Importing translation for %project.', ['%project' => $source->project]),
+ ];
// Import the translation file. For large files the batch operations is
// progressive and will be called repeatedly until finished.
locale_translate_batch_import($file, $options, $context);
@@ -191,7 +191,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
if (isset($context['finished']) && $context['finished'] == 1) {
// The import is successful.
if (isset($context['results']['files'][$file->uri])) {
- $context['message'] = t('Imported translation for %project.', array('%project' => $source->project));
+ $context['message'] = t('Imported translation for %project.', ['%project' => $source->project]);
// Save the data of imported source into the {locale_file} table and
// update the current translation status.
@@ -243,7 +243,7 @@ function locale_translation_http_check($uri) {
$actual_uri = (string) $request_uri;
}
]])->head($uri);
- $result = array();
+ $result = [];
// Return the effective URL if it differs from the requested.
if ($actual_uri && $actual_uri !== $uri) {
@@ -262,10 +262,10 @@ function locale_translation_http_check($uri) {
// theme does not define the location of a translation file. By default
// the file is checked at the translation server, but it will not be
// found there.
- $logger->notice('Translation file not found: @uri.', array('@uri' => $uri));
+ $logger->notice('Translation file not found: @uri.', ['@uri' => $uri]);
return TRUE;
}
- $logger->notice('HTTP request to @url failed with error: @error.', array('@url' => $uri, '@error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase()));
+ $logger->notice('HTTP request to @url failed with error: @error.', ['@url' => $uri, '@error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase()]);
}
}
@@ -298,6 +298,6 @@ function locale_translation_download_source($source_file, $directory = 'temporar
$file->timestamp = filemtime($uri);
return $file;
}
- \Drupal::logger('locale')->error('Unable to download translation file @uri.', array('@uri' => $source_file->uri));
+ \Drupal::logger('locale')->error('Unable to download translation file @uri.', ['@uri' => $source_file->uri]);
return FALSE;
}
diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc
index 1181b50f270..81261e7aca4 100644
--- a/core/modules/locale/locale.bulk.inc
+++ b/core/modules/locale/locale.bulk.inc
@@ -37,14 +37,14 @@ use Drupal\locale\Locale;
* See https://www.drupal.org/node/1191488.
*/
function locale_translate_batch_import_files(array $options, $force = FALSE) {
- $options += array(
- 'overwrite_options' => array(),
+ $options += [
+ 'overwrite_options' => [],
'customized' => LOCALE_NOT_CUSTOMIZED,
'finish_feedback' => TRUE,
- );
+ ];
if (!empty($options['langcode'])) {
- $langcodes = array($options['langcode']);
+ $langcodes = [$options['langcode']];
}
else {
// If langcode was not provided, make sure to only import files for the
@@ -52,11 +52,11 @@ function locale_translate_batch_import_files(array $options, $force = FALSE) {
$langcodes = array_keys(\Drupal::languageManager()->getLanguages());
}
- $files = locale_translate_get_interface_translation_files(array(), $langcodes);
+ $files = locale_translate_get_interface_translation_files([], $langcodes);
if (!$force) {
$result = db_select('locale_file', 'lf')
- ->fields('lf', array('langcode', 'uri', 'timestamp'))
+ ->fields('lf', ['langcode', 'uri', 'timestamp'])
->condition('langcode', $langcodes)
->execute()
->fetchAllAssoc('uri');
@@ -84,9 +84,9 @@ function locale_translate_batch_import_files(array $options, $force = FALSE) {
* @return array
* An array of interface translation files keyed by their URI.
*/
-function locale_translate_get_interface_translation_files(array $projects = array(), array $langcodes = array()) {
+function locale_translate_get_interface_translation_files(array $projects = [], array $langcodes = []) {
module_load_include('compare.inc', 'locale');
- $files = array();
+ $files = [];
$projects = $projects ? $projects : array_keys(locale_translation_get_projects());
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
@@ -95,7 +95,7 @@ function locale_translate_get_interface_translation_files(array $projects = arra
// {project}-{version}.{langcode}.po.
// Only files of known projects and languages will be returned.
$directory = \Drupal::config('locale.settings')->get('translation.path');
- $result = file_scan_directory($directory, '![a-z_]+(\-[0-9a-z\.\-\+]+|)\.[^\./]+\.po$!', array('recurse' => FALSE));
+ $result = file_scan_directory($directory, '![a-z_]+(\-[0-9a-z\.\-\+]+|)\.[^\./]+\.po$!', ['recurse' => FALSE]);
foreach ($result as $file) {
// Update the file object with project name and version from the file name.
@@ -132,30 +132,30 @@ function locale_translate_get_interface_translation_files(array $projects = arra
* A batch structure or FALSE if $files was empty.
*/
function locale_translate_batch_build(array $files, array $options) {
- $options += array(
- 'overwrite_options' => array(),
+ $options += [
+ 'overwrite_options' => [],
'customized' => LOCALE_NOT_CUSTOMIZED,
'finish_feedback' => TRUE,
- );
+ ];
if (count($files)) {
- $operations = array();
+ $operations = [];
foreach ($files as $file) {
// We call locale_translate_batch_import for every batch operation.
- $operations[] = array('locale_translate_batch_import', array($file, $options));
+ $operations[] = ['locale_translate_batch_import', [$file, $options]];
}
// Save the translation status of all files.
- $operations[] = array('locale_translate_batch_import_save', array());
+ $operations[] = ['locale_translate_batch_import_save', []];
// Add a final step to refresh JavaScript and configuration strings.
- $operations[] = array('locale_translate_batch_refresh', array());
+ $operations[] = ['locale_translate_batch_refresh', []];
- $batch = array(
+ $batch = [
'operations' => $operations,
'title' => t('Importing interface translations'),
'progress_message' => '',
'error_message' => t('Error importing interface translations'),
'file' => drupal_get_path('module', 'locale') . '/locale.bulk.inc',
- );
+ ];
if ($options['finish_feedback']) {
$batch['finished'] = 'locale_translate_batch_finished';
}
@@ -190,20 +190,20 @@ function locale_translate_batch_build(array $files, array $options) {
*/
function locale_translate_batch_import($file, array $options, &$context) {
// Merge the default values in the $options array.
- $options += array(
- 'overwrite_options' => array(),
+ $options += [
+ 'overwrite_options' => [],
'customized' => LOCALE_NOT_CUSTOMIZED,
- );
+ ];
if (isset($file->langcode) && $file->langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
try {
if (empty($context['sandbox'])) {
- $context['sandbox']['parse_state'] = array(
+ $context['sandbox']['parse_state'] = [
'filesize' => filesize(drupal_realpath($file->uri)),
'chunk_size' => 200,
'seek' => 0,
- );
+ ];
}
// Update the seek and the number of items in the $options array().
$options['seek'] = $context['sandbox']['parse_state']['seek'];
@@ -220,10 +220,10 @@ function locale_translate_batch_import($file, array $options, &$context) {
// https://www.drupal.org/node/1089472.
$context['finished'] = min(0.95, $report['seek'] / filesize($file->uri));
if (isset($options['message'])) {
- $context['message'] = t('@message (@percent%).', array('@message' => $options['message'], '@percent' => (int) ($context['finished'] * 100)));
+ $context['message'] = t('@message (@percent%).', ['@message' => $options['message'], '@percent' => (int) ($context['finished'] * 100)]);
}
else {
- $context['message'] = t('Importing translation file: %filename (@percent%).', array('%filename' => $file->filename, '@percent' => (int) ($context['finished'] * 100)));
+ $context['message'] = t('Importing translation file: %filename (@percent%).', ['%filename' => $file->filename, '@percent' => (int) ($context['finished'] * 100)]);
}
}
else {
@@ -240,7 +240,7 @@ function locale_translate_batch_import($file, array $options, &$context) {
// Each import iteration reports statistics in an array. The results of
// each iteration are added and merged here and stored per file.
if (!isset($context['results']['stats']) || !isset($context['results']['stats'][$file->uri])) {
- $context['results']['stats'][$file->uri] = array();
+ $context['results']['stats'][$file->uri] = [];
}
foreach ($report as $key => $value) {
if (is_numeric($report[$key])) {
@@ -250,7 +250,7 @@ function locale_translate_batch_import($file, array $options, &$context) {
$context['results']['stats'][$file->uri][$key] += $report[$key];
}
elseif (is_array($value)) {
- $context['results']['stats'][$file->uri] += array($key => array());
+ $context['results']['stats'][$file->uri] += [$key => []];
$context['results']['stats'][$file->uri][$key] = array_merge($context['results']['stats'][$file->uri][$key], $value);
}
}
@@ -258,7 +258,7 @@ function locale_translate_batch_import($file, array $options, &$context) {
catch (Exception $exception) {
// Import failed. Store the data of the failing file.
$context['results']['failed_files'][] = $file;
- \Drupal::logger('locale')->notice('Unable to import translations file: @file', array('@file' => $file->uri));
+ \Drupal::logger('locale')->notice('Unable to import translations file: @file', ['@file' => $file->uri]);
}
}
}
@@ -298,7 +298,7 @@ function locale_translate_batch_import_save($context) {
*/
function locale_translate_batch_refresh(&$context) {
if (!isset($context['sandbox']['refresh'])) {
- $strings = $langcodes = array();
+ $strings = $langcodes = [];
if (isset($context['results']['stats'])) {
// Get list of unique string identifiers and language codes updated.
$langcodes = array_unique(array_values($context['results']['languages']));
@@ -311,7 +311,7 @@ function locale_translate_batch_refresh(&$context) {
$context['message'] = t('Updating translations for JavaScript and default configuration.');
$context['sandbox']['refresh']['strings'] = array_unique($strings);
$context['sandbox']['refresh']['languages'] = $langcodes;
- $context['sandbox']['refresh']['names'] = array();
+ $context['sandbox']['refresh']['names'] = [];
$context['results']['stats']['config'] = 0;
$context['sandbox']['refresh']['count'] = count($strings);
@@ -324,12 +324,12 @@ function locale_translate_batch_refresh(&$context) {
}
elseif ($name = array_shift($context['sandbox']['refresh']['names'])) {
// Refresh all languages for one object at a time.
- $count = Locale::config()->updateConfigTranslations(array($name), $context['sandbox']['refresh']['languages']);
+ $count = Locale::config()->updateConfigTranslations([$name], $context['sandbox']['refresh']['languages']);
$context['results']['stats']['config'] += $count;
// Inherit finished information from the "parent" string lookup step so
// visual display of status will make sense.
$context['finished'] = $context['sandbox']['refresh']['names_finished'];
- $context['message'] = t('Updating default configuration (@percent%).', array('@percent' => (int) ($context['finished'] * 100)));
+ $context['message'] = t('Updating default configuration (@percent%).', ['@percent' => (int) ($context['finished'] * 100)]);
}
elseif (!empty($context['sandbox']['refresh']['strings'])) {
// Not perfect but will give some indication of progress.
@@ -367,7 +367,7 @@ function locale_translate_batch_finished($success, array $results) {
$additions = $updates = $deletes = $skips = $config = 0;
if (isset($results['failed_files'])) {
if (\Drupal::moduleHandler()->moduleExists('dblog') && \Drupal::currentUser()->hasPermission('access site reports')) {
- $message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation file could not be imported. <a href=":url">See the log</a> for details.', '@count translation files could not be imported. <a href=":url">See the log</a> for details.', array(':url' => \Drupal::url('dblog.overview')));
+ $message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation file could not be imported. <a href=":url">See the log</a> for details.', '@count translation files could not be imported. <a href=":url">See the log</a> for details.', [':url' => \Drupal::url('dblog.overview')]);
}
else {
$message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation file could not be imported. See the log for details.', '@count translation files could not be imported. See the log for details.');
@@ -375,7 +375,7 @@ function locale_translate_batch_finished($success, array $results) {
drupal_set_message($message, 'error');
}
if (isset($results['files'])) {
- $skipped_files = array();
+ $skipped_files = [];
// If there are no results and/or no stats (eg. coping with an empty .po
// file), simply do nothing.
if ($results && isset($results['stats'])) {
@@ -392,19 +392,19 @@ function locale_translate_batch_finished($success, array $results) {
drupal_set_message(\Drupal::translation()->formatPlural(count($results['files']),
'One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
'@count translation files imported. %number translations were added, %update translations were updated and %delete translations were removed.',
- array('%number' => $additions, '%update' => $updates, '%delete' => $deletes)
+ ['%number' => $additions, '%update' => $updates, '%delete' => $deletes]
));
- $logger->notice('Translations imported: %number added, %update updated, %delete removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes));
+ $logger->notice('Translations imported: %number added, %update updated, %delete removed.', ['%number' => $additions, '%update' => $updates, '%delete' => $deletes]);
if ($skips) {
if (\Drupal::moduleHandler()->moduleExists('dblog') && \Drupal::currentUser()->hasPermission('access site reports')) {
- $message = \Drupal::translation()->formatPlural($skips, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', array(':url' => \Drupal::url('dblog.overview')));
+ $message = \Drupal::translation()->formatPlural($skips, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', [':url' => \Drupal::url('dblog.overview')]);
}
else {
$message = \Drupal::translation()->formatPlural($skips, 'One translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.');
}
drupal_set_message($message, 'warning');
- $logger->warning('@count disallowed HTML string(s) in files: @files.', array('@count' => $skips, '@files' => implode(',', $skipped_files)));
+ $logger->warning('@count disallowed HTML string(s) in files: @files.', ['@count' => $skips, '@files' => implode(',', $skipped_files)]);
}
}
}
@@ -448,13 +448,13 @@ function locale_translate_file_create($filepath) {
* @return object
* Modified file object.
*/
-function locale_translate_file_attach_properties($file, array $options = array()) {
+function locale_translate_file_attach_properties($file, array $options = []) {
// If $file is a file entity, convert it to a stdClass.
if ($file instanceof FileInterface) {
- $file = (object) array(
+ $file = (object) [
'filename' => $file->getFilename(),
'uri' => $file->getFileUri(),
- );
+ ];
}
// Extract project, version and language code from the file name. Supported:
@@ -499,7 +499,7 @@ function locale_translate_file_attach_properties($file, array $options = array()
* TRUE if files are removed successfully. FALSE if one or more files could
* not be deleted.
*/
-function locale_translate_delete_translation_files(array $projects = array(), array $langcodes = array()) {
+function locale_translate_delete_translation_files(array $projects = [], array $langcodes = []) {
$fail = FALSE;
locale_translation_file_history_delete($projects, $langcodes);
@@ -531,7 +531,7 @@ function locale_translate_delete_translation_files(array $projects = array(), ar
* @return array
* The batch definition.
*/
-function locale_config_batch_update_components(array $options, array $langcodes = array(), array $components = array()) {
+function locale_config_batch_update_components(array $options, array $langcodes = [], array $components = []) {
$langcodes = $langcodes ? $langcodes : array_keys(\Drupal::languageManager()->getLanguages());
if ($langcodes && $names = Locale::config()->getComponentNames($components)) {
return locale_config_batch_build($names, $langcodes, $options);
@@ -555,11 +555,11 @@ function locale_config_batch_update_components(array $options, array $langcodes
*
* @see locale_config_batch_refresh_name()
*/
-function locale_config_batch_build(array $names, array $langcodes, array $options = array()) {
- $options += array('finish_feedback' => TRUE);
+function locale_config_batch_build(array $names, array $langcodes, array $options = []) {
+ $options += ['finish_feedback' => TRUE];
$i = 0;
- $batch_names = array();
- $operations = array();
+ $batch_names = [];
+ $operations = [];
foreach ($names as $name) {
$batch_names[] = $name;
$i++;
@@ -568,20 +568,20 @@ function locale_config_batch_build(array $names, array $langcodes, array $option
// request. We batch a small number of configuration object upgrades
// together to improve the overall performance of the process.
if ($i % 20 == 0) {
- $operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes));
- $batch_names = array();
+ $operations[] = ['locale_config_batch_refresh_name', [$batch_names, $langcodes]];
+ $batch_names = [];
}
}
if (!empty($batch_names)) {
- $operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes));
+ $operations[] = ['locale_config_batch_refresh_name', [$batch_names, $langcodes]];
}
- $batch = array(
+ $batch = [
'operations' => $operations,
'title' => t('Updating configuration translations'),
'init_message' => t('Starting configuration update'),
'error_message' => t('Error updating configuration translations'),
'file' => drupal_get_path('module', 'locale') . '/locale.bulk.inc',
- );
+ ];
if (!empty($options['finish_feedback'])) {
$batch['completed'] = 'locale_config_batch_finished';
}
@@ -630,8 +630,8 @@ function locale_config_batch_finished($success, array $results) {
if ($success) {
$configuration = isset($results['stats']['config']) ? $results['stats']['config'] : 0;
if ($configuration) {
- drupal_set_message(t('The configuration was successfully updated. There are %number configuration objects updated.', array('%number' => $configuration)));
- \Drupal::logger('locale')->notice('The configuration was successfully updated. %number configuration objects updated.', array('%number' => $configuration));
+ drupal_set_message(t('The configuration was successfully updated. There are %number configuration objects updated.', ['%number' => $configuration]));
+ \Drupal::logger('locale')->notice('The configuration was successfully updated. %number configuration objects updated.', ['%number' => $configuration]);
}
else {
drupal_set_message(t('No configuration objects have been updated.'));
diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc
index e24490c3059..3821284bd70 100644
--- a/core/modules/locale/locale.compare.inc
+++ b/core/modules/locale/locale.compare.inc
@@ -66,7 +66,7 @@ function locale_translation_build_projects() {
}
// For every project store information.
- $data += array(
+ $data += [
'name' => $name,
'version' => isset($data['info']['version']) ? $data['info']['version'] : '',
'core' => isset($data['info']['core']) ? $data['info']['core'] : \Drupal::CORE_COMPATIBILITY,
@@ -74,7 +74,7 @@ function locale_translation_build_projects() {
// gettext file. Use the default if not.
'server_pattern' => isset($data['info']['interface translation server pattern']) && $data['info']['interface translation server pattern'] ? $data['info']['interface translation server pattern'] : $default_server['pattern'],
'status' => !empty($data['project_status']) ? 1 : 0,
- );
+ ];
$project = (object) $data;
$projects[$name] = $project;
@@ -95,14 +95,14 @@ function locale_translation_build_projects() {
* Array of project data including .info.yml file data.
*/
function locale_translation_project_list() {
- $projects = &drupal_static(__FUNCTION__, array());
+ $projects = &drupal_static(__FUNCTION__, []);
if (empty($projects)) {
- $projects = array();
+ $projects = [];
- $additional_whitelist = array(
+ $additional_whitelist = [
'interface translation project',
'interface translation server pattern',
- );
+ ];
$module_data = _locale_translation_prepare_project_list(system_rebuild_module_data(), 'module');
$theme_data = _locale_translation_prepare_project_list(\Drupal::service('theme_handler')->rebuildThemeData(), 'theme');
$project_info = new ProjectInfo();
@@ -163,9 +163,9 @@ function locale_translation_default_translation_server() {
// fallback.
$pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
- return array(
+ return [
'pattern' => $pattern,
- );
+ ];
}
/**
@@ -181,7 +181,7 @@ function locale_translation_default_translation_server() {
*
* @todo Return batch or NULL.
*/
-function locale_translation_check_projects($projects = array(), $langcodes = array()) {
+function locale_translation_check_projects($projects = [], $langcodes = []) {
if (locale_translation_use_remote_source()) {
// Retrieve the status of both remote and local translation sources by
// using a batch process.
@@ -207,7 +207,7 @@ function locale_translation_check_projects($projects = array(), $langcodes = arr
* @param string $langcodes
* Array of language codes. Defaults to all translatable languages.
*/
-function locale_translation_check_projects_batch($projects = array(), $langcodes = array()) {
+function locale_translation_check_projects_batch($projects = [], $langcodes = []) {
// Build and set the batch process.
$batch = locale_translation_batch_status_build($projects, $langcodes);
batch_set($batch);
@@ -231,21 +231,21 @@ function locale_translation_check_projects_batch($projects = array(), $langcodes
* @return array
* Batch definition array.
*/
-function locale_translation_batch_status_build($projects = array(), $langcodes = array()) {
+function locale_translation_batch_status_build($projects = [], $langcodes = []) {
$projects = $projects ? $projects : array_keys(locale_translation_get_projects());
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
$options = _locale_translation_default_update_options();
$operations = _locale_translation_batch_status_operations($projects, $langcodes, $options);
- $batch = array(
+ $batch = [
'operations' => $operations,
'title' => t('Checking translations'),
'progress_message' => '',
'finished' => 'locale_translation_batch_status_finished',
'error_message' => t('Error checking translation updates.'),
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
- );
+ ];
return $batch;
}
@@ -263,13 +263,13 @@ function locale_translation_batch_status_build($projects = array(), $langcodes =
* @return array
* Array of batch operations.
*/
-function _locale_translation_batch_status_operations($projects, $langcodes, $options = array()) {
- $operations = array();
+function _locale_translation_batch_status_operations($projects, $langcodes, $options = []) {
+ $operations = [];
foreach ($projects as $project) {
foreach ($langcodes as $langcode) {
// Check status of local and remote translation sources.
- $operations[] = array('locale_translation_batch_status_check', array($project, $langcode, $options));
+ $operations[] = ['locale_translation_batch_status_check', [$project, $langcode, $options]];
}
}
@@ -295,7 +295,7 @@ function _locale_translation_batch_status_operations($projects, $langcodes, $opt
* @param array $langcodes
* Array of language codes. Defaults to all translatable languages.
*/
-function locale_translation_check_projects_local($projects = array(), $langcodes = array()) {
+function locale_translation_check_projects_local($projects = [], $langcodes = []) {
$projects = locale_translation_get_projects($projects);
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
diff --git a/core/modules/locale/locale.fetch.inc b/core/modules/locale/locale.fetch.inc
index 32796a2bf27..1de69344734 100644
--- a/core/modules/locale/locale.fetch.inc
+++ b/core/modules/locale/locale.fetch.inc
@@ -26,7 +26,7 @@ require_once __DIR__ . '/locale.translation.inc';
* @return array
* Batch definition array.
*/
-function locale_translation_batch_update_build($projects = array(), $langcodes = array(), $options = array()) {
+function locale_translation_batch_update_build($projects = [], $langcodes = [], $options = []) {
module_load_include('compare.inc', 'locale');
$projects = $projects ? $projects : array_keys(locale_translation_get_projects());
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
@@ -38,14 +38,14 @@ function locale_translation_batch_update_build($projects = array(), $langcodes =
// Download and import translations.
$operations = array_merge($operations, _locale_translation_fetch_operations($projects, $langcodes, $options));
- $batch = array(
+ $batch = [
'operations' => $operations,
'title' => t('Updating translations'),
'progress_message' => '',
'error_message' => t('Error importing translation files'),
'finished' => 'locale_translation_batch_fetch_finished',
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
- );
+ ];
return $batch;
}
@@ -63,18 +63,18 @@ function locale_translation_batch_update_build($projects = array(), $langcodes =
* @return array
* Batch definition array.
*/
-function locale_translation_batch_fetch_build($projects = array(), $langcodes = array(), $options = array()) {
+function locale_translation_batch_fetch_build($projects = [], $langcodes = [], $options = []) {
$projects = $projects ? $projects : array_keys(locale_translation_get_projects());
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
- $batch = array(
+ $batch = [
'operations' => _locale_translation_fetch_operations($projects, $langcodes, $options),
'title' => t('Updating translations.'),
'progress_message' => '',
'error_message' => t('Error importing translation files'),
'finished' => 'locale_translation_batch_fetch_finished',
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
- );
+ ];
return $batch;
}
@@ -93,14 +93,14 @@ function locale_translation_batch_fetch_build($projects = array(), $langcodes =
* Array of batch operations.
*/
function _locale_translation_fetch_operations($projects, $langcodes, $options) {
- $operations = array();
+ $operations = [];
foreach ($projects as $project) {
foreach ($langcodes as $langcode) {
if (locale_translation_use_remote_source()) {
- $operations[] = array('locale_translation_batch_fetch_download', array($project, $langcode));
+ $operations[] = ['locale_translation_batch_fetch_download', [$project, $langcode]];
}
- $operations[] = array('locale_translation_batch_fetch_import', array($project, $langcode, $options));
+ $operations[] = ['locale_translation_batch_fetch_import', [$project, $langcode, $options]];
}
}
diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install
index a66a5337d6a..f225a6274fd 100644
--- a/core/modules/locale/locale.install
+++ b/core/modules/locale/locale.install
@@ -29,7 +29,7 @@ function locale_uninstall() {
$locale_js_directory = 'public://' . $config->get('javascript.directory');
if (is_dir($locale_js_directory)) {
- $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
+ $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: [];
foreach ($locale_javascripts as $langcode => $file_suffix) {
if (!empty($file_suffix)) {
file_unmanaged_delete($locale_js_directory . '/' . $langcode . '_' . $file_suffix . '.js');
@@ -51,183 +51,183 @@ function locale_uninstall() {
* Implements hook_schema().
*/
function locale_schema() {
- $schema['locales_source'] = array(
+ $schema['locales_source'] = [
'description' => 'List of English source strings.',
- 'fields' => array(
- 'lid' => array(
+ 'fields' => [
+ 'lid' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Unique identifier of this string.',
- ),
- 'source' => array(
+ ],
+ 'source' => [
'type' => 'text',
'mysql_type' => 'blob',
'not null' => TRUE,
'description' => 'The original string in English.',
- ),
- 'context' => array(
+ ],
+ 'context' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The context this string applies to.',
- ),
- 'version' => array(
+ ],
+ 'version' => [
'type' => 'varchar_ascii',
'length' => 20,
'not null' => TRUE,
'default' => 'none',
'description' => 'Version of Drupal where the string was last used (for locales optimization).',
- ),
- ),
- 'primary key' => array('lid'),
- 'indexes' => array(
- 'source_context' => array(array('source', 30), 'context'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['lid'],
+ 'indexes' => [
+ 'source_context' => [['source', 30], 'context'],
+ ],
+ ];
- $schema['locales_target'] = array(
+ $schema['locales_target'] = [
'description' => 'Stores translated versions of strings.',
- 'fields' => array(
- 'lid' => array(
+ 'fields' => [
+ 'lid' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Source string ID. References {locales_source}.lid.',
- ),
- 'translation' => array(
+ ],
+ 'translation' => [
'type' => 'text',
'mysql_type' => 'blob',
'not null' => TRUE,
'description' => 'Translation string value in this language.',
- ),
- 'language' => array(
+ ],
+ 'language' => [
'type' => 'varchar_ascii',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => 'Language code. References {language}.langcode.',
- ),
- 'customized' => array(
+ ],
+ 'customized' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0, // LOCALE_NOT_CUSTOMIZED
'description' => 'Boolean indicating whether the translation is custom to this site.',
- ),
- ),
- 'primary key' => array('language', 'lid'),
- 'foreign keys' => array(
- 'locales_source' => array(
+ ],
+ ],
+ 'primary key' => ['language', 'lid'],
+ 'foreign keys' => [
+ 'locales_source' => [
'table' => 'locales_source',
- 'columns' => array('lid' => 'lid'),
- ),
- ),
- 'indexes' => array(
- 'lid' => array('lid'),
- ),
- );
+ 'columns' => ['lid' => 'lid'],
+ ],
+ ],
+ 'indexes' => [
+ 'lid' => ['lid'],
+ ],
+ ];
- $schema['locales_location'] = array(
+ $schema['locales_location'] = [
'description' => 'Location information for source strings.',
- 'fields' => array(
- 'lid' => array(
+ 'fields' => [
+ 'lid' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Unique identifier of this location.',
- ),
- 'sid' => array(
+ ],
+ 'sid' => [
'type' => 'int',
'not null' => TRUE,
'description' => 'Unique identifier of this string.',
- ),
- 'type' => array(
+ ],
+ 'type' => [
'type' => 'varchar_ascii',
'length' => 50,
'not null' => TRUE,
'default' => '',
'description' => 'The location type (file, config, path, etc).',
- ),
- 'name' => array(
+ ],
+ 'name' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Type dependent location information (file name, path, etc).',
- ),
- 'version' => array(
+ ],
+ 'version' => [
'type' => 'varchar_ascii',
'length' => 20,
'not null' => TRUE,
'default' => 'none',
'description' => 'Version of Drupal where the location was found.',
- ),
- ),
- 'primary key' => array('lid'),
- 'foreign keys' => array(
- 'locales_source' => array(
+ ],
+ ],
+ 'primary key' => ['lid'],
+ 'foreign keys' => [
+ 'locales_source' => [
'table' => 'locales_source',
- 'columns' => array('sid' => 'lid'),
- ),
- ),
- 'indexes' => array(
- 'string_id' => array('sid'),
- 'string_type' => array('sid', 'type'),
- ),
- );
+ 'columns' => ['sid' => 'lid'],
+ ],
+ ],
+ 'indexes' => [
+ 'string_id' => ['sid'],
+ 'string_type' => ['sid', 'type'],
+ ],
+ ];
- $schema['locale_file'] = array(
+ $schema['locale_file'] = [
'description' => 'File import status information for interface translation files.',
- 'fields' => array(
- 'project' => array(
+ 'fields' => [
+ 'project' => [
'type' => 'varchar_ascii',
'length' => '255',
'not null' => TRUE,
'default' => '',
'description' => 'A unique short name to identify the project the file belongs to.',
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar_ascii',
'length' => '12',
'not null' => TRUE,
'default' => '',
'description' => 'Language code of this translation. References {language}.langcode.',
- ),
- 'filename' => array(
+ ],
+ 'filename' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Filename of the imported file.',
- ),
- 'version' => array(
+ ],
+ 'version' => [
'type' => 'varchar',
'length' => '128',
'not null' => TRUE,
'default' => '',
'description' => 'Version tag of the imported file.',
- ),
- 'uri' => array(
+ ],
+ 'uri' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'URI of the remote file, the resulting local file or the locally imported file.',
- ),
- 'timestamp' => array(
+ ],
+ 'timestamp' => [
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'description' => 'Unix timestamp of the imported file.',
- ),
- 'last_checked' => array(
+ ],
+ 'last_checked' => [
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'description' => 'Unix timestamp of the last time this translation was confirmed to be the most recent release available.',
- ),
- ),
- 'primary key' => array('project', 'langcode'),
- );
+ ],
+ ],
+ 'primary key' => ['project', 'langcode'],
+ ];
return $schema;
}
@@ -235,10 +235,10 @@ function locale_schema() {
* Implements hook_requirements().
*/
function locale_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if ($phase == 'runtime') {
- $available_updates = array();
- $untranslated = array();
+ $available_updates = [];
+ $untranslated = [];
$languages = locale_translatable_language_list();
if ($languages) {
@@ -258,37 +258,37 @@ function locale_requirements($phase) {
if ($available_updates || $untranslated) {
if ($available_updates) {
- $requirements['locale_translation'] = array(
+ $requirements['locale_translation'] = [
'title' => 'Translation update status',
'value' => \Drupal::l(t('Updates available'), new Url('locale.translate_status')),
'severity' => REQUIREMENT_WARNING,
- 'description' => t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array('@languages' => implode(', ', $available_updates), ':updates' => \Drupal::url('locale.translate_status'))),
- );
+ 'description' => t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => implode(', ', $available_updates), ':updates' => \Drupal::url('locale.translate_status')]),
+ ];
}
else {
- $requirements['locale_translation'] = array(
+ $requirements['locale_translation'] = [
'title' => 'Translation update status',
'value' => t('Missing translations'),
'severity' => REQUIREMENT_INFO,
- 'description' => t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array('@languages' => implode(', ', $untranslated), ':updates' => \Drupal::url('locale.translate_status'))),
- );
+ 'description' => t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => implode(', ', $untranslated), ':updates' => \Drupal::url('locale.translate_status')]),
+ ];
}
}
else {
- $requirements['locale_translation'] = array(
+ $requirements['locale_translation'] = [
'title' => 'Translation update status',
'value' => t('Up to date'),
'severity' => REQUIREMENT_OK,
- );
+ ];
}
}
else {
- $requirements['locale_translation'] = array(
+ $requirements['locale_translation'] = [
'title' => 'Translation update status',
'value' => \Drupal::l(t('Can not determine status'), new Url('locale.translate_status')),
'severity' => REQUIREMENT_WARNING,
- 'description' => t('No translation status is available. See the <a href=":updates">Available translation updates</a> page for more information.', array(':updates' => \Drupal::url('locale.translate_status'))),
- );
+ 'description' => t('No translation status is available. See the <a href=":updates">Available translation updates</a> page for more information.', [':updates' => \Drupal::url('locale.translate_status')]),
+ ];
}
}
}
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 5b59faaa706..b1298e4b679 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -146,30 +146,30 @@ function locale_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.locale':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Interface Translation module allows you to translate interface text (<em>strings</em>) into different languages, and to switch between them for the display of interface text. It uses the functionality provided by the <a href=":language">Language module</a>. For more information, see the <a href=":doc-url">online documentation for the Interface Translation module</a>.', array(':doc-url' => 'https://www.drupal.org/documentation/modules/locale/', ':language' => \Drupal::url('help.page', array('name' => 'language')))) . '</p>';
+ $output .= '<p>' . t('The Interface Translation module allows you to translate interface text (<em>strings</em>) into different languages, and to switch between them for the display of interface text. It uses the functionality provided by the <a href=":language">Language module</a>. For more information, see the <a href=":doc-url">online documentation for the Interface Translation module</a>.', [':doc-url' => 'https://www.drupal.org/documentation/modules/locale/', ':language' => \Drupal::url('help.page', ['name' => 'language'])]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Importing translation files') . '</dt>';
- $output .= '<dd>' . t('Translation files with translated interface text are imported automatically when languages are added on the <a href=":languages">Languages</a> page, or when modules or themes are enabled. On the <a href=":locale-settings">Interface translation settings</a> page, the <em>Translation source</em> can be restricted to local files only, or to include the <a href=":server">Drupal translation server</a>. Although modules and themes may not be fully translated in all languages, new translations become available frequently. You can specify whether and how often to check for translation file updates and whether to overwrite existing translations on the <a href=":locale-settings">Interface translation settings</a> page. You can also manually import a translation file on the <a href=":import">Interface translation import</a> page.', array(':import' => \Drupal::url('locale.translate_import'), ':locale-settings' => \Drupal::url('locale.settings'), ':languages' => \Drupal::url('entity.configurable_language.collection'), ':server' => 'https://localize.drupal.org')) . '</dd>';
+ $output .= '<dd>' . t('Translation files with translated interface text are imported automatically when languages are added on the <a href=":languages">Languages</a> page, or when modules or themes are enabled. On the <a href=":locale-settings">Interface translation settings</a> page, the <em>Translation source</em> can be restricted to local files only, or to include the <a href=":server">Drupal translation server</a>. Although modules and themes may not be fully translated in all languages, new translations become available frequently. You can specify whether and how often to check for translation file updates and whether to overwrite existing translations on the <a href=":locale-settings">Interface translation settings</a> page. You can also manually import a translation file on the <a href=":import">Interface translation import</a> page.', [':import' => \Drupal::url('locale.translate_import'), ':locale-settings' => \Drupal::url('locale.settings'), ':languages' => \Drupal::url('entity.configurable_language.collection'), ':server' => 'https://localize.drupal.org']) . '</dd>';
$output .= '<dt>' . t('Checking the translation status') . '</dt>';
- $output .= '<dd>' . t('You can check how much of the interface on your site is translated into which language on the <a href=":languages">Languages</a> page. On the <a href=":translation-updates">Available translation updates</a> page, you can check whether interface translation updates are available on the <a href=":server">Drupal translation server</a>.', array(':languages' => \Drupal::url('entity.configurable_language.collection'), ':translation-updates' => \Drupal::url('locale.translate_status'), ':server' => 'https://localize.drupal.org')) . '<dd>';
+ $output .= '<dd>' . t('You can check how much of the interface on your site is translated into which language on the <a href=":languages">Languages</a> page. On the <a href=":translation-updates">Available translation updates</a> page, you can check whether interface translation updates are available on the <a href=":server">Drupal translation server</a>.', [':languages' => \Drupal::url('entity.configurable_language.collection'), ':translation-updates' => \Drupal::url('locale.translate_status'), ':server' => 'https://localize.drupal.org']) . '<dd>';
$output .= '<dt>' . t('Translating individual strings') . '</dt>';
- $output .= '<dd>' . t('You can translate individual strings directly on the <a href=":translate">User interface translation</a> page, or download the currently-used translation file for a specific language on the <a href=":export">Interface translation export</a> page. Once you have edited the translation file, you can then import it again on the <a href=":import">Interface translation import</a> page.', array(':translate' => \Drupal::url('locale.translate_page'), ':export' => \Drupal::url('locale.translate_export'), ':import' => \Drupal::url('locale.translate_import'))) . '</dd>';
+ $output .= '<dd>' . t('You can translate individual strings directly on the <a href=":translate">User interface translation</a> page, or download the currently-used translation file for a specific language on the <a href=":export">Interface translation export</a> page. Once you have edited the translation file, you can then import it again on the <a href=":import">Interface translation import</a> page.', [':translate' => \Drupal::url('locale.translate_page'), ':export' => \Drupal::url('locale.translate_export'), ':import' => \Drupal::url('locale.translate_import')]) . '</dd>';
$output .= '<dt>' . t('Overriding default English strings') . '</dt>';
- $output .= '<dd>' . t('If translation is enabled for English, you can <em>override</em> the default English interface text strings in your site with other English text strings on the <a href=":translate">User interface translation</a> page. Translation is off by default for English, but you can turn it on by visiting the <em>Edit language</em> page for <em>English</em> from the <a href=":languages">Languages</a> page.', array(':translate' => \Drupal::url('locale.translate_page'), ':languages' => \Drupal::url('entity.configurable_language.collection'))) . '</dd>';
+ $output .= '<dd>' . t('If translation is enabled for English, you can <em>override</em> the default English interface text strings in your site with other English text strings on the <a href=":translate">User interface translation</a> page. Translation is off by default for English, but you can turn it on by visiting the <em>Edit language</em> page for <em>English</em> from the <a href=":languages">Languages</a> page.', [':translate' => \Drupal::url('locale.translate_page'), ':languages' => \Drupal::url('entity.configurable_language.collection')]) . '</dd>';
$output .= '</dl>';
return $output;
case 'entity.configurable_language.collection':
- return '<p>' . t('Interface translations are automatically imported when a language is added, or when new modules or themes are enabled. The report <a href=":update">Available translation updates</a> shows the status. Interface text can be customized in the <a href=":translate">user interface translation</a> page.', array(':update' => \Drupal::url('locale.translate_status'), ':translate' => \Drupal::url('locale.translate_page'))) . '</p>';
+ return '<p>' . t('Interface translations are automatically imported when a language is added, or when new modules or themes are enabled. The report <a href=":update">Available translation updates</a> shows the status. Interface text can be customized in the <a href=":translate">user interface translation</a> page.', [':update' => \Drupal::url('locale.translate_status'), ':translate' => \Drupal::url('locale.translate_page')]) . '</p>';
case 'locale.translate_page':
- $output = '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: Because translation tasks involve many strings, it may be more convenient to <a title="User interface translation export" href=":export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings in a specific language.', array(':export' => \Drupal::url('locale.translate_export'))) . '</p>';
+ $output = '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: Because translation tasks involve many strings, it may be more convenient to <a title="User interface translation export" href=":export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings in a specific language.', [':export' => \Drupal::url('locale.translate_export')]) . '</p>';
return $output;
case 'locale.translate_import':
- $output = '<p>' . t('Translation files are automatically downloaded and imported when <a title="Languages" href=":language">languages</a> are added, or when modules or themes are enabled.', array(':language' => \Drupal::url('entity.configurable_language.collection'))) . '</p>';
- $output .= '<p>' . t('This page allows translators to manually import translated strings contained in a Gettext Portable Object (.po) file. Manual import may be used for customized translations or for the translation of custom modules and themes. To customize translations you can download a translation file from the <a href=":url">Drupal translation server</a> or <a title="User interface translation export" href=":export">export</a> translations from the site, customize the translations using a Gettext translation editor, and import the result using this page.', array(':url' => 'https://localize.drupal.org', ':export' => \Drupal::url('locale.translate_export'))) . '</p>';
+ $output = '<p>' . t('Translation files are automatically downloaded and imported when <a title="Languages" href=":language">languages</a> are added, or when modules or themes are enabled.', [':language' => \Drupal::url('entity.configurable_language.collection')]) . '</p>';
+ $output .= '<p>' . t('This page allows translators to manually import translated strings contained in a Gettext Portable Object (.po) file. Manual import may be used for customized translations or for the translation of custom modules and themes. To customize translations you can download a translation file from the <a href=":url">Drupal translation server</a> or <a title="User interface translation export" href=":export">export</a> translations from the site, customize the translations using a Gettext translation editor, and import the result using this page.', [':url' => 'https://localize.drupal.org', ':export' => \Drupal::url('locale.translate_export')]) . '</p>';
$output .= '<p>' . t('Note that importing large .po files may take several minutes.') . '</p>';
return $output;
@@ -182,16 +182,16 @@ function locale_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function locale_theme() {
- return array(
- 'locale_translation_last_check' => array(
- 'variables' => array('last' => NULL),
+ return [
+ 'locale_translation_last_check' => [
+ 'variables' => ['last' => NULL],
'file' => 'locale.pages.inc',
- ),
- 'locale_translation_update_info' => array(
- 'variables' => array('updates' => array(), 'not_found' => array()),
+ ],
+ 'locale_translation_update_info' => [
+ 'variables' => ['updates' => [], 'not_found' => []],
'file' => 'locale.pages.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -223,11 +223,11 @@ function locale_configurable_language_update(ConfigurableLanguageInterface $lang
*/
function locale_configurable_language_delete(ConfigurableLanguageInterface $language) {
// Remove translations.
- \Drupal::service('locale.storage')->deleteTranslations(array('language' => $language->id()));
+ \Drupal::service('locale.storage')->deleteTranslations(['language' => $language->id()]);
// Remove interface translation files.
module_load_include('inc', 'locale', 'locale.bulk');
- locale_translate_delete_translation_files(array(), array($language->id()));
+ locale_translate_delete_translation_files([], [$language->id()]);
// Remove translated configuration objects.
Locale::config()->deleteLanguageTranslations($language->id());
@@ -237,7 +237,7 @@ function locale_configurable_language_delete(ConfigurableLanguageInterface $lang
\Drupal::cache('render')->deleteAll();
// Clear locale translation caches.
- locale_translation_status_delete_languages(array($language->id()));
+ locale_translation_status_delete_languages([$language->id()]);
\Drupal::cache()->delete('locale:' . $language->id());
}
@@ -277,7 +277,7 @@ function locale_get_plural($count, $langcode = NULL) {
// Used to store precomputed plural indexes corresponding to numbers
// individually for each language.
- $plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', array());
+ $plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', []);
$langcode = $langcode ? $langcode : $language_interface->getId();
@@ -323,7 +323,7 @@ function locale_modules_installed($modules) {
* Implements hook_module_preuninstall().
*/
function locale_module_preuninstall($module) {
- $components['module'] = array($module);
+ $components['module'] = [$module];
locale_system_remove($components);
}
@@ -399,7 +399,7 @@ function locale_system_set_config_langcodes() {
* translations for, indexed by type.
*/
function locale_system_update(array $components) {
- $components += array('module' => array(), 'theme' => array());
+ $components += ['module' => [], 'theme' => []];
$list = array_merge($components['module'], $components['theme']);
// Skip running the translation imports if in the installer,
@@ -446,7 +446,7 @@ function locale_system_update(array $components) {
* translations for, indexed by type.
*/
function locale_system_remove($components) {
- $components += array('module' => array(), 'theme' => array());
+ $components += ['module' => [], 'theme' => []];
$list = array_merge($components['module'], $components['theme']);
if ($language_list = locale_translatable_language_list()) {
module_load_include('compare.inc', 'locale');
@@ -460,7 +460,7 @@ function locale_system_remove($components) {
locale_translation_file_history_delete($list);
// Remove translation files.
- locale_translate_delete_translation_files($list, array());
+ locale_translate_delete_translation_files($list, []);
// Remove translatable projects.
// Follow-up issue https://www.drupal.org/node/1842362 to replace the
@@ -486,7 +486,7 @@ function locale_cache_flush() {
*/
function locale_js_alter(&$javascript, AttachedAssetsInterface $assets) {
// @todo Remove this in https://www.drupal.org/node/2421323.
- $files = array();
+ $files = [];
foreach ($javascript as $item) {
if (isset($item['type']) && $item['type'] == 'file') {
// Ignore the JS translation placeholder file.
@@ -529,11 +529,11 @@ function locale_js_alter(&$javascript, AttachedAssetsInterface $assets) {
* The filepath to the translation file or NULL if no translation is
* applicable.
*/
-function locale_js_translate(array $files = array()) {
+function locale_js_translate(array $files = []) {
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
$dir = 'public://' . \Drupal::config('locale.settings')->get('javascript.directory');
- $parsed = \Drupal::state()->get('system.javascript_parsed') ?: array();
+ $parsed = \Drupal::state()->get('system.javascript_parsed') ?: [];
$new_files = FALSE;
foreach ($files as $filepath) {
@@ -571,7 +571,7 @@ function locale_js_translate(array $files = array()) {
}
// Add the translation JavaScript file to the page.
- $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
+ $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: [];
$translation_file = NULL;
if (!empty($files) && !empty($locale_javascripts[$language_interface->getId()])) {
// Add the translation JavaScript file to the page.
@@ -624,7 +624,7 @@ function locale_form_language_admin_overview_form_alter(&$form, FormStateInterfa
$languages = $form['languages']['#languages'];
$total_strings = \Drupal::service('locale.storage')->countStrings();
- $stats = array_fill_keys(array_keys($languages), array());
+ $stats = array_fill_keys(array_keys($languages), []);
// If we have source strings, count translations and calculate progress.
if (!empty($total_strings)) {
@@ -640,26 +640,26 @@ function locale_form_language_admin_overview_form_alter(&$form, FormStateInterfa
array_splice($form['languages']['#header'], -1, 0, ['translation-interface' => t('Interface translation')]);
foreach ($languages as $langcode => $language) {
- $stats[$langcode] += array(
+ $stats[$langcode] += [
'translated' => 0,
'ratio' => 0,
- );
+ ];
if (!$language->isLocked() && locale_is_translatable($langcode)) {
- $form['languages'][$langcode]['locale_statistics'] = array(
+ $form['languages'][$langcode]['locale_statistics'] = [
'#markup' => \Drupal::l(
- t('@translated/@total (@ratio%)', array(
+ t('@translated/@total (@ratio%)', [
'@translated' => $stats[$langcode]['translated'],
'@total' => $total_strings,
'@ratio' => $stats[$langcode]['ratio'],
- )),
- new Url('locale.translate_page', array(), array('query' => array('langcode' => $langcode)))
+ ]),
+ new Url('locale.translate_page', [], ['query' => ['langcode' => $langcode]])
),
- );
+ ];
}
else {
- $form['languages'][$langcode]['locale_statistics'] = array(
+ $form['languages'][$langcode]['locale_statistics'] = [
'#markup' => t('not applicable'),
- );
+ ];
}
// #type = link doesn't work with #weight on table.
// reset and set it back after locale_statistics to get it at the right end.
@@ -695,7 +695,7 @@ function locale_form_language_admin_add_form_alter_submit($form, FormStateInterf
if (\Drupal::config('locale.settings')->get('translation.import_enabled')) {
// Download and import translations for the newly added language.
- $batch = locale_translation_batch_update_build(array(), array($langcode), $options);
+ $batch = locale_translation_batch_update_build([], [$langcode], $options);
batch_set($batch);
}
@@ -704,7 +704,7 @@ function locale_form_language_admin_add_form_alter_submit($form, FormStateInterf
// because then we extract English sources from shipped configuration.
if (\Drupal::config('locale.settings')->get('translation.import_enabled') || $langcode == 'en') {
\Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
- if ($batch = locale_config_batch_update_components($options, array($langcode))) {
+ if ($batch = locale_config_batch_update_components($options, [$langcode])) {
batch_set($batch);
}
}
@@ -715,11 +715,11 @@ function locale_form_language_admin_add_form_alter_submit($form, FormStateInterf
*/
function locale_form_language_admin_edit_form_alter(&$form, FormStateInterface $form_state) {
if ($form['langcode']['#type'] == 'value' && $form['langcode']['#value'] == 'en') {
- $form['locale_translate_english'] = array(
+ $form['locale_translate_english'] = [
'#title' => t('Enable interface translation to English'),
'#type' => 'checkbox',
'#default_value' => \Drupal::configFactory()->getEditable('locale.settings')->get('translate_english'),
- );
+ ];
$form['actions']['submit']['#submit'][] = 'locale_form_language_admin_edit_form_alter_submit';
}
}
@@ -750,16 +750,16 @@ function locale_is_translatable($langcode) {
* Add interface translation directory setting to directories configuration.
*/
function locale_form_system_file_system_settings_alter(&$form, FormStateInterface $form_state) {
- $form['translation_path'] = array(
+ $form['translation_path'] = [
'#type' => 'textfield',
'#title' => t('Interface translations directory'),
'#default_value' => \Drupal::configFactory()->getEditable('locale.settings')->get('translation.path'),
'#maxlength' => 255,
'#description' => t('A local file system path where interface translation files will be stored.'),
'#required' => TRUE,
- '#after_build' => array('system_check_directory'),
+ '#after_build' => ['system_check_directory'],
'#weight' => 10,
- );
+ ];
if ($form['file_default_scheme']) {
$form['file_default_scheme']['#weight'] = 20;
}
@@ -814,7 +814,7 @@ function locale_preprocess_node(&$variables) {
* Array of translation file objects.
*/
function locale_translation_get_file_history() {
- $history = &drupal_static(__FUNCTION__, array());
+ $history = &drupal_static(__FUNCTION__, []);
if (empty($history)) {
// Get file history from the database.
@@ -838,15 +838,15 @@ function locale_translation_get_file_history() {
*/
function locale_translation_update_file_history($file) {
$status = db_merge('locale_file')
- ->key(array(
+ ->key([
'project' => $file->project,
'langcode' => $file->langcode,
- ))
- ->fields(array(
+ ])
+ ->fields([
'version' => $file->version,
'timestamp' => $file->timestamp,
'last_checked' => $file->last_checked,
- ))
+ ])
->execute();
// The file history has changed, flush the static cache now.
// @todo Can we make this more fine grained?
@@ -863,7 +863,7 @@ function locale_translation_update_file_history($file) {
* @param array $langcodes
* Language code(s) to be deleted from the file history.
*/
-function locale_translation_file_history_delete($projects = array(), $langcodes = array()) {
+function locale_translation_file_history_delete($projects = [], $langcodes = []) {
$query = db_delete('locale_file');
if (!empty($projects)) {
$query->condition('project', $projects, 'IN');
@@ -880,7 +880,7 @@ function locale_translation_file_history_delete($projects = array(), $langcodes
* @todo What is 'translation status'?
*/
function locale_translation_get_status($projects = NULL, $langcodes = NULL) {
- $result = array();
+ $result = [];
$status = \Drupal::keyValue('locale.translation_status')->getAll();
module_load_include('translation.inc', 'locale');
$projects = $projects ? $projects : array_keys(locale_translation_get_projects());
@@ -894,7 +894,7 @@ function locale_translation_get_status($projects = NULL, $langcodes = NULL) {
$result[$project][$langcode] = $status[$project][$langcode];
}
else {
- $sources = locale_translation_build_sources(array($project), array($langcode));
+ $sources = locale_translation_build_sources([$project], [$langcode]);
if (isset($sources[$project][$langcode])) {
$result[$project][$langcode] = $sources[$project][$langcode];
}
@@ -921,7 +921,7 @@ function locale_translation_status_save($project, $langcode, $type, $data) {
module_load_include('translation.inc', 'locale');
$status = locale_translation_get_status();
if (empty($status)) {
- $projects = locale_translation_get_projects(array($project));
+ $projects = locale_translation_get_projects([$project]);
if (isset($projects[$project])) {
$status[$project][$langcode] = locale_translation_source_build($projects[$project], $langcode);
}
@@ -1049,7 +1049,7 @@ function locale_string_is_safe($string) {
// string. https://www.drupal.org/node/2372127
$string = preg_replace('/\[[a-z0-9_-]+(:[a-z0-9_-]+)+\]/i', '', $string);
- return Html::decodeEntities($string) == Html::decodeEntities(Xss::filter($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var')));
+ return Html::decodeEntities($string) == Html::decodeEntities(Xss::filter($string, ['a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var']));
}
/**
@@ -1066,11 +1066,11 @@ function locale_string_is_safe($string) {
* (optional) List of string identifiers that have been updated / created.
* If not provided, all caches for the affected languages are cleared.
*/
-function _locale_refresh_translations($langcodes, $lids = array()) {
+function _locale_refresh_translations($langcodes, $lids = []) {
if (!empty($langcodes)) {
// Update javascript translations if any of the strings has a javascript
// location, or if no string ids were provided, update all languages.
- if (empty($lids) || ($strings = \Drupal::service('locale.storage')->getStrings(array('lid' => $lids, 'type' => 'javascript')))) {
+ if (empty($lids) || ($strings = \Drupal::service('locale.storage')->getStrings(['lid' => $lids, 'type' => 'javascript']))) {
array_map('_locale_invalidate_js', $langcodes);
}
}
@@ -1175,22 +1175,22 @@ function _locale_parse_js_file($filepath) {
[,\)]
~sx', $file, $plural_matches);
- $matches = array();
+ $matches = [];
// Add strings from Drupal.t().
foreach ($t_matches[1] as $key => $string) {
- $matches[] = array(
+ $matches[] = [
'source' => _locale_strip_quotes($string),
'context' => _locale_strip_quotes($t_matches[2][$key]),
- );
+ ];
}
// Add string from Drupal.formatPlural().
foreach ($plural_matches[1] as $key => $string) {
- $matches[] = array(
+ $matches[] = [
'source' => _locale_strip_quotes($string) . LOCALE_PLURAL_DELIMITER . _locale_strip_quotes($plural_matches[2][$key]),
'context' => _locale_strip_quotes($plural_matches[3][$key]),
- );
+ ];
}
// Loop through all matches and process them.
@@ -1224,7 +1224,7 @@ function _locale_parse_js_file($filepath) {
* New content of the 'system.javascript_parsed' variable.
*/
function _locale_invalidate_js($langcode = NULL) {
- $parsed = \Drupal::state()->get('system.javascript_parsed') ?: array();
+ $parsed = \Drupal::state()->get('system.javascript_parsed') ?: [];
if (empty($langcode)) {
// Invalidate all languages.
@@ -1264,12 +1264,12 @@ function _locale_rebuild_js($langcode = NULL) {
// Construct the array for JavaScript translations.
// Only add strings with a translation to the translations array.
- $conditions = array(
+ $conditions = [
'type' => 'javascript',
'language' => $language->getId(),
'translated' => TRUE,
- );
- $translations = array();
+ ];
+ $translations = [];
foreach (\Drupal::service('locale.storage')->getTranslations($conditions) as $data) {
$translations[$data->context][$data->source] = $data->translation;
}
@@ -1278,9 +1278,9 @@ function _locale_rebuild_js($langcode = NULL) {
$data_hash = NULL;
$data = $status = '';
if (!empty($translations)) {
- $data = array(
+ $data = [
'strings' => $translations,
- );
+ ];
$locale_plurals = \Drupal::service('locale.plural.formula')->getFormula($language->getId());
if ($locale_plurals) {
@@ -1297,7 +1297,7 @@ function _locale_rebuild_js($langcode = NULL) {
// Delete old file, if we have no translations anymore, or a different file to
// be saved.
- $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
+ $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: [];
$changed_hash = !isset($locale_javascripts[$language->getId()]) || ($locale_javascripts[$language->getId()] != $data_hash);
if (!empty($locale_javascripts[$language->getId()]) && (!$data || $changed_hash)) {
file_unmanaged_delete($dir . '/' . $language->getId() . '_' . $locale_javascripts[$language->getId()] . '.js');
@@ -1348,24 +1348,24 @@ function _locale_rebuild_js($langcode = NULL) {
$logger = \Drupal::logger('locale');
switch ($status) {
case 'updated':
- $logger->notice('Updated JavaScript translation file for the language %language.', array('%language' => $language->getName()));
+ $logger->notice('Updated JavaScript translation file for the language %language.', ['%language' => $language->getName()]);
return TRUE;
case 'rebuilt':
- $logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->getId()]));
+ $logger->warning('JavaScript translation file %file.js was lost.', ['%file' => $locale_javascripts[$language->getId()]]);
// Proceed to the 'created' case as the JavaScript translation file has
// been created again.
case 'created':
- $logger->notice('Created JavaScript translation file for the language %language.', array('%language' => $language->getName()));
+ $logger->notice('Created JavaScript translation file for the language %language.', ['%language' => $language->getName()]);
return TRUE;
case 'deleted':
- $logger->notice('Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->getName()));
+ $logger->notice('Removed JavaScript translation file for the language %language because no translations currently exist for that language.', ['%language' => $language->getName()]);
return TRUE;
case 'error':
- $logger->error('An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->getName()));
+ $logger->error('An error occurred during creation of the JavaScript translation file for the language %language.', ['%language' => $language->getName()]);
return FALSE;
default:
@@ -1383,7 +1383,7 @@ function locale_translation_language_table($form_element) {
// Remove checkboxes of languages without updates.
if ($form_element['#not_found']) {
foreach ($form_element['#not_found'] as $langcode) {
- $form_element[$langcode] = array();
+ $form_element[$langcode] = [];
}
}
return $form_element;
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index 9b2be235fec..d8d7659bf9c 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -29,7 +29,7 @@ function locale_translation_manual_status() {
if (batch_get()) {
return batch_process('admin/reports/translations');
}
- return new RedirectResponse(\Drupal::url('locale.translate_status', array(), array('absolute' => TRUE)));
+ return new RedirectResponse(\Drupal::url('locale.translate_status', [], ['absolute' => TRUE]));
}
/**
@@ -72,5 +72,5 @@ function template_preprocess_locale_translation_last_check(array &$variables) {
$last = $variables['last'];
$variables['last_checked'] = ($last != NULL);
$variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
- $variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', array(), array('query' => \Drupal::destination()->getAsArray())));
+ $variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]));
}
diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc
index 0383aafd22b..571f7d2247f 100644
--- a/core/modules/locale/locale.translation.inc
+++ b/core/modules/locale/locale.translation.inc
@@ -52,8 +52,8 @@ const LOCALE_TRANSLATION_SOURCE_COMPARE_GT = 1;
*
* @see locale_translation_build_projects()
*/
-function locale_translation_get_projects(array $project_names = array()) {
- $projects = &drupal_static(__FUNCTION__, array());
+function locale_translation_get_projects(array $project_names = []) {
+ $projects = &drupal_static(__FUNCTION__, []);
if (empty($projects)) {
// Get project data from the database.
@@ -100,7 +100,7 @@ function locale_translation_clear_cache_projects() {
* @see locale_translation_source_build()
*/
function locale_translation_load_sources(array $projects = NULL, array $langcodes = NULL) {
- $sources = array();
+ $sources = [];
$projects = $projects ? $projects : array_keys(locale_translation_get_projects());
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
@@ -129,8 +129,8 @@ function locale_translation_load_sources(array $projects = NULL, array $langcode
*
* @see locale_translation_source_build()
*/
-function locale_translation_build_sources(array $projects = array(), array $langcodes = array()) {
- $sources = array();
+function locale_translation_build_sources(array $projects = [], array $langcodes = []) {
+ $sources = [];
$projects = locale_translation_get_projects($projects);
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
@@ -173,7 +173,7 @@ function locale_translation_source_check_file($source) {
$directory = $source_file->directory;
$filename = '/' . preg_quote($source_file->filename) . '$/';
- if ($files = file_scan_directory($directory, $filename, array('key' => 'name', 'recurse' => FALSE))) {
+ if ($files = file_scan_directory($directory, $filename, ['key' => 'name', 'recurse' => FALSE])) {
$file = current($files);
$source_file->uri = $file->uri;
$source_file->timestamp = filemtime($file->uri);
@@ -244,35 +244,35 @@ function locale_translation_source_build($project, $langcode, $filename = NULL)
// remote file. The local version of this file will only be checked if a
// translations directory has been defined. If the server_pattern is a local
// file path we will only check for a file in the local file system.
- $files = array();
+ $files = [];
if (_locale_translation_file_is_remote($source->server_pattern)) {
- $files[LOCALE_TRANSLATION_REMOTE] = (object) array(
+ $files[LOCALE_TRANSLATION_REMOTE] = (object) [
'project' => $project->name,
'langcode' => $langcode,
'version' => $project->version,
'type' => LOCALE_TRANSLATION_REMOTE,
'filename' => locale_translation_build_server_pattern($source, basename($source->server_pattern)),
'uri' => locale_translation_build_server_pattern($source, $source->server_pattern),
- );
- $files[LOCALE_TRANSLATION_LOCAL] = (object) array(
+ ];
+ $files[LOCALE_TRANSLATION_LOCAL] = (object) [
'project' => $project->name,
'langcode' => $langcode,
'version' => $project->version,
'type' => LOCALE_TRANSLATION_LOCAL,
'filename' => locale_translation_build_server_pattern($source, $filename),
'directory' => 'translations://',
- );
+ ];
$files[LOCALE_TRANSLATION_LOCAL]->uri = $files[LOCALE_TRANSLATION_LOCAL]->directory . $files[LOCALE_TRANSLATION_LOCAL]->filename;
}
else {
- $files[LOCALE_TRANSLATION_LOCAL] = (object) array(
+ $files[LOCALE_TRANSLATION_LOCAL] = (object) [
'project' => $project->name,
'langcode' => $langcode,
'version' => $project->version,
'type' => LOCALE_TRANSLATION_LOCAL,
'filename' => locale_translation_build_server_pattern($source, basename($source->server_pattern)),
'directory' => locale_translation_build_server_pattern($source, drupal_dirname($source->server_pattern)),
- );
+ ];
$files[LOCALE_TRANSLATION_LOCAL]->uri = $files[LOCALE_TRANSLATION_LOCAL]->directory . '/' . $files[LOCALE_TRANSLATION_LOCAL]->filename;
}
$source->files = $files;
@@ -310,12 +310,12 @@ function locale_translation_source_build($project, $langcode, $filename = NULL)
* String with replaced placeholders.
*/
function locale_translation_build_server_pattern($project, $template) {
- $variables = array(
+ $variables = [
'%project' => $project->name,
'%version' => $project->version,
'%core' => $project->core,
'%language' => isset($project->langcode) ? $project->langcode : '%language',
- );
+ ];
return strtr($template, $variables);
}
@@ -323,7 +323,7 @@ function locale_translation_build_server_pattern($project, $template) {
* Populate a queue with project to check for translation updates.
*/
function locale_cron_fill_queue() {
- $updates = array();
+ $updates = [];
$config = \Drupal::config('locale.settings');
// Determine which project+language should be updated.
@@ -335,7 +335,7 @@ function locale_cron_fill_queue() {
$files = db_select('locale_file', 'f')
->condition('f.project', array_keys($projects), 'IN')
->condition('f.last_checked', $last, '<')
- ->fields('f', array('project', 'langcode'))
+ ->fields('f', ['project', 'langcode'])
->execute()->fetchAll();
foreach ($files as $file) {
$updates[$file->project][] = $file->langcode;
@@ -343,7 +343,7 @@ function locale_cron_fill_queue() {
// Update the last_checked timestamp of the project+language that will
// be checked for updates.
db_update('locale_file')
- ->fields(array('last_checked' => REQUEST_TIME))
+ ->fields(['last_checked' => REQUEST_TIME])
->condition('project', $file->project)
->condition('langcode', $file->langcode)
->execute();
@@ -357,7 +357,7 @@ function locale_cron_fill_queue() {
$queue = \Drupal::queue('locale_translation', TRUE);
foreach ($updates as $project => $languages) {
- $batch = locale_translation_batch_update_build(array($project), $languages, $options);
+ $batch = locale_translation_batch_update_build([$project], $languages, $options);
foreach ($batch['operations'] as $item) {
$queue->createItem($item);
}
@@ -429,13 +429,13 @@ function _locale_translation_source_compare($source1, $source2) {
*/
function _locale_translation_default_update_options() {
$config = \Drupal::config('locale.settings');
- return array(
+ return [
'customized' => LOCALE_NOT_CUSTOMIZED,
- 'overwrite_options' => array(
+ 'overwrite_options' => [
'not_customized' => $config->get('translation.overwrite_not_customized'),
'customized' => $config->get('translation.overwrite_customized'),
- ),
+ ],
'finish_feedback' => TRUE,
'use_remote' => locale_translation_use_remote_source(),
- );
+ ];
}
diff --git a/core/modules/locale/src/Controller/LocaleController.php b/core/modules/locale/src/Controller/LocaleController.php
index 88cc6bd56fb..2617c61cffe 100644
--- a/core/modules/locale/src/Controller/LocaleController.php
+++ b/core/modules/locale/src/Controller/LocaleController.php
@@ -42,10 +42,10 @@ class LocaleController extends ControllerBase {
* The render array for the string search screen.
*/
public function translatePage() {
- return array(
+ return [
'filter' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateFilterForm'),
'form' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateEditForm'),
- );
+ ];
}
}
diff --git a/core/modules/locale/src/Form/ExportForm.php b/core/modules/locale/src/Form/ExportForm.php
index 47a3aeab129..7c6f9321dc7 100644
--- a/core/modules/locale/src/Form/ExportForm.php
+++ b/core/modules/locale/src/Form/ExportForm.php
@@ -66,7 +66,7 @@ class ExportForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$languages = $this->languageManager->getLanguages();
- $language_options = array();
+ $language_options = [];
foreach ($languages as $langcode => $language) {
if (locale_is_translatable($langcode)) {
$language_options[$langcode] = $language->getName();
@@ -75,59 +75,59 @@ class ExportForm extends FormBase {
$language_default = $this->languageManager->getDefaultLanguage();
if (empty($language_options)) {
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'value',
'#value' => LanguageInterface::LANGCODE_SYSTEM,
- );
- $form['langcode_text'] = array(
+ ];
+ $form['langcode_text'] = [
'#type' => 'item',
'#title' => $this->t('Language'),
'#markup' => $this->t('No language available. The export will only contain source strings.'),
- );
+ ];
}
else {
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'select',
'#title' => $this->t('Language'),
'#options' => $language_options,
'#default_value' => $language_default->getId(),
'#empty_option' => $this->t('Source text only, no translations'),
'#empty_value' => LanguageInterface::LANGCODE_SYSTEM,
- );
- $form['content_options'] = array(
+ ];
+ $form['content_options'] = [
'#type' => 'details',
'#title' => $this->t('Export options'),
'#tree' => TRUE,
- '#states' => array(
- 'invisible' => array(
- ':input[name="langcode"]' => array('value' => LanguageInterface::LANGCODE_SYSTEM),
- ),
- ),
- );
- $form['content_options']['not_customized'] = array(
+ '#states' => [
+ 'invisible' => [
+ ':input[name="langcode"]' => ['value' => LanguageInterface::LANGCODE_SYSTEM],
+ ],
+ ],
+ ];
+ $form['content_options']['not_customized'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include non-customized translations'),
'#default_value' => TRUE,
- );
- $form['content_options']['customized'] = array(
+ ];
+ $form['content_options']['customized'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include customized translations'),
'#default_value' => TRUE,
- );
- $form['content_options']['not_translated'] = array(
+ ];
+ $form['content_options']['not_translated'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include untranslated text'),
'#default_value' => TRUE,
- );
+ ];
}
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Export'),
- );
+ ];
return $form;
}
@@ -142,7 +142,7 @@ class ExportForm extends FormBase {
else {
$language = NULL;
}
- $content_options = $form_state->getValue('content_options', array());
+ $content_options = $form_state->getValue('content_options', []);
$reader = new PoDatabaseReader();
$language_name = '';
if ($language != NULL) {
diff --git a/core/modules/locale/src/Form/ImportForm.php b/core/modules/locale/src/Form/ImportForm.php
index 0ea71809bc1..f2bd45b8443 100644
--- a/core/modules/locale/src/Form/ImportForm.php
+++ b/core/modules/locale/src/Form/ImportForm.php
@@ -72,7 +72,7 @@ class ImportForm extends FormBase {
// Initialize a language list to the ones available, including English if we
// are to translate Drupal to English as well.
- $existing_languages = array();
+ $existing_languages = [];
foreach ($languages as $langcode => $language) {
if (locale_is_translatable($langcode)) {
$existing_languages[$langcode] = $language->getName();
@@ -88,65 +88,65 @@ class ImportForm extends FormBase {
}
else {
$default = key($existing_languages);
- $language_options = array(
+ $language_options = [
(string) $this->t('Existing languages') => $existing_languages,
(string) $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured(),
- );
+ ];
}
- $validators = array(
- 'file_validate_extensions' => array('po'),
- 'file_validate_size' => array(file_upload_max_size()),
- );
- $form['file'] = array(
+ $validators = [
+ 'file_validate_extensions' => ['po'],
+ 'file_validate_size' => [file_upload_max_size()],
+ ];
+ $form['file'] = [
'#type' => 'file',
'#title' => $this->t('Translation file'),
- '#description' => array(
+ '#description' => [
'#theme' => 'file_upload_help',
'#description' => $this->t('A Gettext Portable Object file.'),
'#upload_validators' => $validators,
- ),
+ ],
'#size' => 50,
'#upload_validators' => $validators,
- '#attributes' => array('class' => array('file-import-input')),
- );
- $form['langcode'] = array(
+ '#attributes' => ['class' => ['file-import-input']],
+ ];
+ $form['langcode'] = [
'#type' => 'select',
'#title' => $this->t('Language'),
'#options' => $language_options,
'#default_value' => $default,
- '#attributes' => array('class' => array('langcode-input')),
- );
+ '#attributes' => ['class' => ['langcode-input']],
+ ];
- $form['customized'] = array(
+ $form['customized'] = [
'#title' => $this->t('Treat imported strings as custom translations'),
'#type' => 'checkbox',
- );
- $form['overwrite_options'] = array(
+ ];
+ $form['overwrite_options'] = [
'#type' => 'container',
'#tree' => TRUE,
- );
- $form['overwrite_options']['not_customized'] = array(
+ ];
+ $form['overwrite_options']['not_customized'] = [
'#title' => $this->t('Overwrite non-customized translations'),
'#type' => 'checkbox',
- '#states' => array(
- 'checked' => array(
- ':input[name="customized"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['overwrite_options']['customized'] = array(
+ '#states' => [
+ 'checked' => [
+ ':input[name="customized"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['overwrite_options']['customized'] = [
'#title' => $this->t('Overwrite existing customized translations'),
'#type' => 'checkbox',
- );
+ ];
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Import'),
- );
+ ];
return $form;
}
@@ -172,21 +172,21 @@ class ImportForm extends FormBase {
if (empty($language)) {
$language = ConfigurableLanguage::createFromLangcode($form_state->getValue('langcode'));
$language->save();
- drupal_set_message($this->t('The language %language has been created.', array('%language' => $this->t($language->label()))));
+ drupal_set_message($this->t('The language %language has been created.', ['%language' => $this->t($language->label())]));
}
- $options = array_merge(_locale_translation_default_update_options(), array(
+ $options = array_merge(_locale_translation_default_update_options(), [
'langcode' => $form_state->getValue('langcode'),
'overwrite_options' => $form_state->getValue('overwrite_options'),
'customized' => $form_state->getValue('customized') ? LOCALE_CUSTOMIZED : LOCALE_NOT_CUSTOMIZED,
- ));
+ ]);
$this->moduleHandler->loadInclude('locale', 'bulk.inc');
$file = locale_translate_file_attach_properties($this->file, $options);
- $batch = locale_translate_batch_build(array($file->uri => $file), $options);
+ $batch = locale_translate_batch_build([$file->uri => $file], $options);
batch_set($batch);
// Create or update all configuration translations for this language.
\Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
- if ($batch = locale_config_batch_update_components($options, array($form_state->getValue('langcode')))) {
+ if ($batch = locale_config_batch_update_components($options, [$form_state->getValue('langcode')])) {
batch_set($batch);
}
diff --git a/core/modules/locale/src/Form/LocaleSettingsForm.php b/core/modules/locale/src/Form/LocaleSettingsForm.php
index 93662244b5c..e722cfb2b4f 100644
--- a/core/modules/locale/src/Form/LocaleSettingsForm.php
+++ b/core/modules/locale/src/Form/LocaleSettingsForm.php
@@ -30,35 +30,35 @@ class LocaleSettingsForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('locale.settings');
- $form['update_interval_days'] = array(
+ $form['update_interval_days'] = [
'#type' => 'radios',
'#title' => $this->t('Check for updates'),
'#default_value' => $config->get('translation.update_interval_days'),
- '#options' => array(
+ '#options' => [
'0' => $this->t('Never (manually)'),
'7' => $this->t('Weekly'),
'30' => $this->t('Monthly'),
- ),
- '#description' => $this->t('Select how frequently you want to check for new interface translations for your currently installed modules and themes. <a href=":url">Check updates now</a>.', array(':url' => $this->url('locale.check_translation'))),
- );
+ ],
+ '#description' => $this->t('Select how frequently you want to check for new interface translations for your currently installed modules and themes. <a href=":url">Check updates now</a>.', [':url' => $this->url('locale.check_translation')]),
+ ];
if ($directory = $config->get('translation.path')) {
- $description = $this->t('Translation files are stored locally in the %path directory. You can change this directory on the <a href=":url">File system</a> configuration page.', array('%path' => $directory, ':url' => $this->url('system.file_system_settings')));
+ $description = $this->t('Translation files are stored locally in the %path directory. You can change this directory on the <a href=":url">File system</a> configuration page.', ['%path' => $directory, ':url' => $this->url('system.file_system_settings')]);
}
else {
- $description = $this->t('Translation files will not be stored locally. Change the Interface translation directory on the <a href=":url">File system configuration</a> page.', array(':url' => $this->url('system.file_system_settings')));
+ $description = $this->t('Translation files will not be stored locally. Change the Interface translation directory on the <a href=":url">File system configuration</a> page.', [':url' => $this->url('system.file_system_settings')]);
}
$form['#translation_directory'] = $directory;
- $form['use_source'] = array(
+ $form['use_source'] = [
'#type' => 'radios',
'#title' => $this->t('Translation source'),
'#default_value' => $config->get('translation.use_source'),
- '#options' => array(
+ '#options' => [
LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL => $this->t('Drupal translation server and local files'),
LOCALE_TRANSLATION_USE_SOURCE_LOCAL => $this->t('Local files only'),
- ),
+ ],
'#description' => $this->t('The source of translation files for automatic interface translation.') . ' ' . $description,
- );
+ ];
if ($config->get('translation.overwrite_not_customized') == FALSE) {
$default = LOCALE_TRANSLATION_OVERWRITE_NONE;
@@ -69,17 +69,17 @@ class LocaleSettingsForm extends ConfigFormBase {
else {
$default = LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED;
}
- $form['overwrite'] = array(
+ $form['overwrite'] = [
'#type' => 'radios',
'#title' => $this->t('Import behavior'),
'#default_value' => $default,
- '#options' => array(
+ '#options' => [
LOCALE_TRANSLATION_OVERWRITE_NONE => $this->t("Don't overwrite existing translations."),
LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED => $this->t('Only overwrite imported translations, customized translations are kept.'),
LOCALE_TRANSLATION_OVERWRITE_ALL => $this->t('Overwrite existing translations.'),
- ),
+ ],
'#description' => $this->t('How to treat existing translations when automatically updating the interface translations.'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
@@ -91,7 +91,7 @@ class LocaleSettingsForm extends ConfigFormBase {
parent::validateForm($form, $form_state);
if (empty($form['#translation_directory']) && $form_state->getValue('use_source') == LOCALE_TRANSLATION_USE_SOURCE_LOCAL) {
- $form_state->setErrorByName('use_source', $this->t('You have selected local translation source, but no <a href=":url">Interface translation directory</a> was configured.', array(':url' => $this->url('system.file_system_settings'))));
+ $form_state->setErrorByName('use_source', $this->t('You have selected local translation source, but no <a href=":url">Interface translation directory</a> was configured.', [':url' => $this->url('system.file_system_settings')]));
}
}
diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php
index c559f800514..d629009cf85 100644
--- a/core/modules/locale/src/Form/TranslateEditForm.php
+++ b/core/modules/locale/src/Form/TranslateEditForm.php
@@ -32,12 +32,12 @@ class TranslateEditForm extends TranslateFormBase {
$form['#attached']['library'][] = 'locale/drupal.locale.admin';
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'value',
'#value' => $filter_values['langcode'],
- );
+ ];
- $form['strings'] = array(
+ $form['strings'] = [
'#type' => 'table',
'#tree' => TRUE,
'#language' => $langname,
@@ -47,7 +47,7 @@ class TranslateEditForm extends TranslateFormBase {
],
'#empty' => $this->t('No strings available.'),
'#attributes' => ['class' => ['locale-translate-edit-table']],
- );
+ ];
if (isset($langcode)) {
$strings = $this->translateFilterLoadStrings();
@@ -63,14 +63,14 @@ class TranslateEditForm extends TranslateFormBase {
if (count($source_array) == 1) {
// Add original string value and mark as non-plural.
$plural = FALSE;
- $form['strings'][$string->lid]['original'] = array(
+ $form['strings'][$string->lid]['original'] = [
'#type' => 'item',
- '#title' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))),
+ '#title' => $this->t('Source string (@language)', ['@language' => $this->t('Built-in English')]),
'#title_display' => 'invisible',
'#plain_text' => $source_array[0],
'#preffix' => '<span lang="en">',
'#suffix' => '</span>',
- );
+ ];
}
else {
// Add original string value and mark as plural.
@@ -79,7 +79,7 @@ class TranslateEditForm extends TranslateFormBase {
'#type' => 'item',
'#title' => $this->t('Singular form'),
'#plain_text' => $source_array[0],
- '#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '</span><span lang="en">',
+ '#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', ['@language' => $this->t('Built-in English')]) . '</span><span lang="en">',
'#suffix' => '</span>',
];
$original_plural = [
@@ -108,27 +108,27 @@ class TranslateEditForm extends TranslateFormBase {
// Approximate the number of rows to use in the default textarea.
$rows = min(ceil(str_word_count($source_array[0]) / 12), 10);
if (!$plural) {
- $form['strings'][$string->lid]['translations'][0] = array(
+ $form['strings'][$string->lid]['translations'][0] = [
'#type' => 'textarea',
- '#title' => $this->t('Translated string (@language)', array('@language' => $langname)),
+ '#title' => $this->t('Translated string (@language)', ['@language' => $langname]),
'#title_display' => 'invisible',
'#rows' => $rows,
'#default_value' => $translation_array[0],
- '#attributes' => array('lang' => $langcode),
- );
+ '#attributes' => ['lang' => $langcode],
+ ];
}
else {
// Add a textarea for each plural variant.
for ($i = 0; $i < $plurals; $i++) {
- $form['strings'][$string->lid]['translations'][$i] = array(
+ $form['strings'][$string->lid]['translations'][$i] = [
'#type' => 'textarea',
// @todo Should use better labels https://www.drupal.org/node/2499639
'#title' => ($i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form')),
'#rows' => $rows,
'#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '',
- '#attributes' => array('lang' => $langcode),
- '#prefix' => $i == 0 ? ('<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>') : '',
- );
+ '#attributes' => ['lang' => $langcode],
+ '#prefix' => $i == 0 ? ('<span class="visually-hidden">' . $this->t('Translated string (@language)', ['@language' => $langname]) . '</span>') : '',
+ ];
}
if ($plurals == 2) {
// Simplify interface text for the most common case.
@@ -137,11 +137,11 @@ class TranslateEditForm extends TranslateFormBase {
}
}
if (count(Element::children($form['strings']))) {
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save translations'),
- );
+ ];
}
}
$form['pager']['#type'] = 'pager';
@@ -156,9 +156,9 @@ class TranslateEditForm extends TranslateFormBase {
foreach ($form_state->getValue('strings') as $lid => $translations) {
foreach ($translations['translations'] as $key => $value) {
if (!locale_string_is_safe($value)) {
- $form_state->setErrorByName("strings][$lid][translations][$key", $this->t('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
- $form_state->setErrorByName("translations][$langcode][$key", $this->t('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
- $this->logger('locale')->warning('Attempted submission of a translation string with disallowed HTML: %string', array('%string' => $value));
+ $form_state->setErrorByName("strings][$lid][translations][$key", $this->t('The submitted string contains disallowed HTML: %string', ['%string' => $value]));
+ $form_state->setErrorByName("translations][$langcode][$key", $this->t('The submitted string contains disallowed HTML: %string', ['%string' => $value]));
+ $this->logger('locale')->warning('Attempted submission of a translation string with disallowed HTML: %string', ['%string' => $value]);
}
}
}
@@ -169,12 +169,12 @@ class TranslateEditForm extends TranslateFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$langcode = $form_state->getValue('langcode');
- $updated = array();
+ $updated = [];
// Preload all translations for strings in the form.
$lids = array_keys($form_state->getValue('strings'));
- $existing_translation_objects = array();
- foreach ($this->localeStorage->getTranslations(array('lid' => $lids, 'language' => $langcode, 'translated' => TRUE)) as $existing_translation_object) {
+ $existing_translation_objects = [];
+ foreach ($this->localeStorage->getTranslations(['lid' => $lids, 'language' => $langcode, 'translated' => TRUE]) as $existing_translation_object) {
$existing_translation_objects[$existing_translation_object->lid] = $existing_translation_object;
}
@@ -204,7 +204,7 @@ class TranslateEditForm extends TranslateFormBase {
if ($is_changed) {
// Only update or insert if we have a value to use.
- $target = isset($existing_translation_objects[$lid]) ? $existing_translation_objects[$lid] : $this->localeStorage->createTranslation(array('lid' => $lid, 'language' => $langcode));
+ $target = isset($existing_translation_objects[$lid]) ? $existing_translation_objects[$lid] : $this->localeStorage->createTranslation(['lid' => $lid, 'language' => $langcode]);
$target->setPlurals($new_translation['translations'])
->setCustomized()
->save();
@@ -224,15 +224,15 @@ class TranslateEditForm extends TranslateFormBase {
if (isset($page)) {
$form_state->setRedirect(
'locale.translate_page',
- array(),
- array('page' => $page)
+ [],
+ ['page' => $page]
);
}
if ($updated) {
// Clear cache and force refresh of JavaScript translations.
- _locale_refresh_translations(array($langcode), $updated);
- _locale_refresh_configuration(array($langcode), $updated);
+ _locale_refresh_translations([$langcode], $updated);
+ _locale_refresh_configuration([$langcode], $updated);
}
}
diff --git a/core/modules/locale/src/Form/TranslateFilterForm.php b/core/modules/locale/src/Form/TranslateFilterForm.php
index b3975b81ccd..aeef26f8ffb 100644
--- a/core/modules/locale/src/Form/TranslateFilterForm.php
+++ b/core/modules/locale/src/Form/TranslateFilterForm.php
@@ -25,24 +25,24 @@ class TranslateFilterForm extends TranslateFormBase {
$form['#attached']['library'][] = 'locale/drupal.locale.admin';
- $form['filters'] = array(
+ $form['filters'] = [
'#type' => 'details',
'#title' => $this->t('Filter translatable strings'),
'#open' => TRUE,
- );
+ ];
foreach ($filters as $key => $filter) {
// Special case for 'string' filter.
if ($key == 'string') {
- $form['filters']['status']['string'] = array(
+ $form['filters']['status']['string'] = [
'#type' => 'search',
'#title' => $filter['title'],
'#description' => $filter['description'],
'#default_value' => $filter_values[$key],
- );
+ ];
}
else {
$empty_option = isset($filter['options'][$filter['default']]) ? $filter['options'][$filter['default']] : '- None -';
- $form['filters']['status'][$key] = array(
+ $form['filters']['status'][$key] = [
'#title' => $filter['title'],
'#type' => 'select',
'#empty_value' => $filter['default'],
@@ -50,27 +50,27 @@ class TranslateFilterForm extends TranslateFormBase {
'#size' => 0,
'#options' => $filter['options'],
'#default_value' => $filter_values[$key],
- );
+ ];
if (isset($filter['states'])) {
$form['filters']['status'][$key]['#states'] = $filter['states'];
}
}
}
- $form['filters']['actions'] = array(
+ $form['filters']['actions'] = [
'#type' => 'actions',
- '#attributes' => array('class' => array('container-inline')),
- );
- $form['filters']['actions']['submit'] = array(
+ '#attributes' => ['class' => ['container-inline']],
+ ];
+ $form['filters']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Filter'),
- );
+ ];
if (!empty($_SESSION['locale_translate_filter'])) {
- $form['filters']['actions']['reset'] = array(
+ $form['filters']['actions']['reset'] = [
'#type' => 'submit',
'#value' => $this->t('Reset'),
- '#submit' => array('::resetForm'),
- );
+ '#submit' => ['::resetForm'],
+ ];
}
return $form;
@@ -93,7 +93,7 @@ class TranslateFilterForm extends TranslateFormBase {
* Provides a submit handler for the reset button.
*/
public function resetForm(array &$form, FormStateInterface $form_state) {
- $_SESSION['locale_translate_filter'] = array();
+ $_SESSION['locale_translate_filter'] = [];
$form_state->setRedirect('locale.translate_page');
}
diff --git a/core/modules/locale/src/Form/TranslateFormBase.php b/core/modules/locale/src/Form/TranslateFormBase.php
index ba5f7c316c1..9a7ad8bab8c 100644
--- a/core/modules/locale/src/Form/TranslateFormBase.php
+++ b/core/modules/locale/src/Form/TranslateFormBase.php
@@ -81,8 +81,8 @@ abstract class TranslateFormBase extends FormBase {
// Language is sanitized to be one of the possible options in
// translateFilterValues().
- $conditions = array('language' => $filter_values['langcode']);
- $options = array('pager limit' => 30, 'translated' => TRUE, 'untranslated' => TRUE);
+ $conditions = ['language' => $filter_values['langcode']];
+ $options = ['pager limit' => 30, 'translated' => TRUE, 'untranslated' => TRUE];
// Add translation status conditions and options.
switch ($filter_values['translation']) {
@@ -123,7 +123,7 @@ abstract class TranslateFormBase extends FormBase {
return static::$filterValues;
}
- $filter_values = array();
+ $filter_values = [];
$filters = $this->translateFilters();
foreach ($filters as $key => $filter) {
$filter_values[$key] = $filter['default'];
@@ -152,12 +152,12 @@ abstract class TranslateFormBase extends FormBase {
* Lists locale translation filters that can be applied.
*/
protected function translateFilters() {
- $filters = array();
+ $filters = [];
// Get all languages, except English.
$this->languageManager->reset();
$languages = $this->languageManager->getLanguages();
- $language_options = array();
+ $language_options = [];
foreach ($languages as $langcode => $language) {
if (locale_is_translatable($langcode)) {
$language_options[$langcode] = $language->getName();
@@ -171,42 +171,42 @@ abstract class TranslateFormBase extends FormBase {
$default_langcode = array_shift($available_langcodes);
}
- $filters['string'] = array(
+ $filters['string'] = [
'title' => $this->t('String contains'),
'description' => $this->t('Leave blank to show all strings. The search is case sensitive.'),
'default' => '',
- );
+ ];
- $filters['langcode'] = array(
+ $filters['langcode'] = [
'title' => $this->t('Translation language'),
'options' => $language_options,
'default' => $default_langcode,
- );
+ ];
- $filters['translation'] = array(
+ $filters['translation'] = [
'title' => $this->t('Search in'),
- 'options' => array(
+ 'options' => [
'all' => $this->t('Both translated and untranslated strings'),
'translated' => $this->t('Only translated strings'),
'untranslated' => $this->t('Only untranslated strings'),
- ),
+ ],
'default' => 'all',
- );
+ ];
- $filters['customized'] = array(
+ $filters['customized'] = [
'title' => $this->t('Translation type'),
- 'options' => array(
+ 'options' => [
'all' => $this->t('All'),
LOCALE_NOT_CUSTOMIZED => $this->t('Non-customized translation'),
LOCALE_CUSTOMIZED => $this->t('Customized translation'),
- ),
- 'states' => array(
- 'visible' => array(
- ':input[name=translation]' => array('value' => 'translated'),
- ),
- ),
+ ],
+ 'states' => [
+ 'visible' => [
+ ':input[name=translation]' => ['value' => 'translated'],
+ ],
+ ],
'default' => 'all',
- );
+ ];
return $filters;
}
diff --git a/core/modules/locale/src/Form/TranslationStatusForm.php b/core/modules/locale/src/Form/TranslationStatusForm.php
index 31f8bb958a3..cbf4d4a55ea 100644
--- a/core/modules/locale/src/Form/TranslationStatusForm.php
+++ b/core/modules/locale/src/Form/TranslationStatusForm.php
@@ -65,10 +65,10 @@ class TranslationStatusForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$languages = locale_translatable_language_list();
$status = locale_translation_get_status();
- $options = array();
- $languages_update = array();
- $languages_not_found = array();
- $projects_update = array();
+ $options = [];
+ $languages_update = [];
+ $languages_not_found = [];
+ $projects_update = [];
// Prepare information about projects which have available translation
// updates.
if ($languages && $status) {
@@ -77,24 +77,24 @@ class TranslationStatusForm extends FormBase {
// Build data options for the select table.
foreach ($updates as $langcode => $update) {
$title = $languages[$langcode]->getName();
- $locale_translation_update_info = array('#theme' => 'locale_translation_update_info');
- foreach (array('updates', 'not_found') as $update_status) {
+ $locale_translation_update_info = ['#theme' => 'locale_translation_update_info'];
+ foreach (['updates', 'not_found'] as $update_status) {
if (isset($update[$update_status])) {
$locale_translation_update_info['#' . $update_status] = $update[$update_status];
}
}
- $options[$langcode] = array(
- 'title' => array(
- 'data' => array(
+ $options[$langcode] = [
+ 'title' => [
+ 'data' => [
'#title' => $title,
'#plain_text' => $title,
- ),
- ),
- 'status' => array(
- 'class' => array('description', 'priority-low'),
+ ],
+ ],
+ 'status' => [
+ 'class' => ['description', 'priority-low'],
'data' => $locale_translation_update_info,
- ),
- );
+ ],
+ ];
if (!empty($update['not_found'])) {
$languages_not_found[$langcode] = $langcode;
}
@@ -110,43 +110,43 @@ class TranslationStatusForm extends FormBase {
}
$last_checked = $this->state->get('locale.translation_last_checked');
- $form['last_checked'] = array(
+ $form['last_checked'] = [
'#theme' => 'locale_translation_last_check',
'#last' => $last_checked,
- );
+ ];
- $header = array(
- 'title' => array(
+ $header = [
+ 'title' => [
'data' => $this->t('Language'),
- 'class' => array('title'),
- ),
- 'status' => array(
+ 'class' => ['title'],
+ ],
+ 'status' => [
'data' => $this->t('Status'),
- 'class' => array('status', 'priority-low'),
- ),
- );
+ 'class' => ['status', 'priority-low'],
+ ],
+ ];
if (!$languages) {
- $empty = $this->t('No translatable languages available. <a href=":add_language">Add a language</a> first.', array(
+ $empty = $this->t('No translatable languages available. <a href=":add_language">Add a language</a> first.', [
':add_language' => $this->url('entity.configurable_language.collection'),
- ));
+ ]);
}
elseif ($status) {
$empty = $this->t('All translations up to date.');
}
else {
- $empty = $this->t('No translation status available. <a href=":check">Check manually</a>.', array(
+ $empty = $this->t('No translation status available. <a href=":check">Check manually</a>.', [
':check' => $this->url('locale.check_translation'),
- ));
+ ]);
}
// The projects which require an update. Used by the _submit callback.
- $form['projects_update'] = array(
+ $form['projects_update'] = [
'#type' => 'value',
'#value' => $projects_update,
- );
+ ];
- $form['langcodes'] = array(
+ $form['langcodes'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
@@ -156,17 +156,17 @@ class TranslationStatusForm extends FormBase {
'#multiple' => TRUE,
'#required' => TRUE,
'#not_found' => $languages_not_found,
- '#after_build' => array('locale_translation_language_table'),
- );
+ '#after_build' => ['locale_translation_language_table'],
+ ];
$form['#attached']['library'][] = 'locale/drupal.locale.admin';
- $form['actions'] = array('#type' => 'actions');
+ $form['actions'] = ['#type' => 'actions'];
if ($languages_update) {
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Update translations'),
- );
+ ];
}
return $form;
@@ -183,7 +183,7 @@ class TranslationStatusForm extends FormBase {
* translation update status.
*/
protected function prepareUpdateData(array $status) {
- $updates = array();
+ $updates = [];
// @todo Calling locale_translation_build_projects() is an expensive way to
// get a module name. In follow-up issue
@@ -196,22 +196,22 @@ class TranslationStatusForm extends FormBase {
foreach ($project as $langcode => $project_info) {
// No translation file found for this project-language combination.
if (empty($project_info->type)) {
- $updates[$langcode]['not_found'][] = array(
+ $updates[$langcode]['not_found'][] = [
'name' => $project_info->name == 'drupal' ? $this->t('Drupal core') : $project_data[$project_info->name]->info['name'],
'version' => $project_info->version,
'info' => $this->createInfoString($project_info),
- );
+ ];
}
// Translation update found for this project-language combination.
elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
$local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : NULL;
$remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : NULL;
$recent = _locale_translation_source_compare($local, $remote) == LOCALE_TRANSLATION_SOURCE_COMPARE_LT ? $remote : $local;
- $updates[$langcode]['updates'][] = array(
+ $updates[$langcode]['updates'][] = [
'name' => $project_info->name == 'drupal' ? $this->t('Drupal core') : $project_data[$project_info->name]->info['name'],
'version' => $project_info->version,
'timestamp' => $recent->timestamp,
- );
+ ];
}
}
}
@@ -238,13 +238,13 @@ class TranslationStatusForm extends FormBase {
$local_path = isset($project_info->files['local']->uri) ? $project_info->files['local']->uri : FALSE;
if (locale_translation_use_remote_source() && $remote_path && $local_path) {
- return $this->t('File not found at %remote_path nor at %local_path', array(
+ return $this->t('File not found at %remote_path nor at %local_path', [
'%remote_path' => $remote_path,
'%local_path' => $local_path,
- ));
+ ]);
}
elseif ($local_path) {
- return $this->t('File not found at %local_path', array('%local_path' => $local_path));
+ return $this->t('File not found at %local_path', ['%local_path' => $local_path]);
}
return $this->t('Translation file location could not be determined.');
}
@@ -279,7 +279,7 @@ class TranslationStatusForm extends FormBase {
$last_checked = $this->state->get('locale.translation_last_checked');
if ($last_checked < REQUEST_TIME - LOCALE_TRANSLATION_STATUS_TTL) {
locale_translation_clear_status();
- $batch = locale_translation_batch_update_build(array(), $langcodes, $options);
+ $batch = locale_translation_batch_update_build([], $langcodes, $options);
batch_set($batch);
}
else {
diff --git a/core/modules/locale/src/Gettext.php b/core/modules/locale/src/Gettext.php
index 5573f43d6a3..44677aa28b6 100644
--- a/core/modules/locale/src/Gettext.php
+++ b/core/modules/locale/src/Gettext.php
@@ -41,12 +41,12 @@ class Gettext {
*/
public static function fileToDatabase($file, $options) {
// Add the default values to the options array.
- $options += array(
- 'overwrite_options' => array(),
+ $options += [
+ 'overwrite_options' => [],
'customized' => LOCALE_NOT_CUSTOMIZED,
'items' => -1,
'seek' => 0,
- );
+ ];
// Instantiate and initialize the stream reader for this file.
$reader = new PoStreamReader();
$reader->setLangcode($file->langcode);
@@ -67,10 +67,10 @@ class Gettext {
// Initialize the database writer.
$writer = new PoDatabaseWriter();
$writer->setLangcode($file->langcode);
- $writer_options = array(
+ $writer_options = [
'overwrite_options' => $options['overwrite_options'],
'customized' => $options['customized'],
- );
+ ];
$writer->setOptions($writer_options);
$writer->setHeader($header);
diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php
index bc598e21de7..e67f3bc4a27 100644
--- a/core/modules/locale/src/LocaleConfigManager.php
+++ b/core/modules/locale/src/LocaleConfigManager.php
@@ -147,7 +147,7 @@ class LocaleConfigManager {
return $this->getTranslatableData($typed_config);
}
}
- return array();
+ return [];
}
/**
@@ -163,7 +163,7 @@ class LocaleConfigManager {
* TranslatableMarkup.
*/
protected function getTranslatableData(TypedDataInterface $element) {
- $translatable = array();
+ $translatable = [];
if ($element instanceof TraversableTypedDataInterface) {
foreach ($element as $key => $property) {
$value = $this->getTranslatableData($property);
@@ -178,11 +178,11 @@ class LocaleConfigManager {
$value = $element->getValue();
$definition = $element->getDataDefinition();
if (!empty($definition['translatable']) && $value !== '' && $value !== NULL) {
- $options = array();
+ $options = [];
if (isset($definition['translation context'])) {
$options['context'] = $definition['translation context'];
}
- return new TranslatableMarkup($value, array(), $options);
+ return new TranslatableMarkup($value, [], $options);
}
}
return $translatable;
@@ -215,7 +215,7 @@ class LocaleConfigManager {
* @see self::getTranslatableData()
*/
protected function processTranslatableData($name, array $active, array $translatable, $langcode) {
- $translated = array();
+ $translated = [];
foreach ($translatable as $key => $item) {
if (!isset($active[$key])) {
continue;
@@ -296,10 +296,10 @@ class LocaleConfigManager {
* @return array
* Array of configuration object names.
*/
- public function getComponentNames(array $components = array()) {
+ public function getComponentNames(array $components = []) {
$components = array_filter($components);
if ($components) {
- $names = array();
+ $names = [];
foreach ($components as $type => $list) {
// InstallStorage::getComponentNames returns a list of folders keyed by
// config name.
@@ -322,8 +322,8 @@ class LocaleConfigManager {
* Array of configuration object names.
*/
public function getStringNames(array $lids) {
- $names = array();
- $locations = $this->localeStorage->getLocations(array('sid' => $lids, 'type' => 'configuration'));
+ $names = [];
+ $locations = $this->localeStorage->getLocations(['sid' => $lids, 'type' => 'configuration']);
foreach ($locations as $location) {
$names[$location->name] = $location->name;
}
@@ -370,15 +370,15 @@ class LocaleConfigManager {
// If translations for a language have not been loaded yet.
if (!isset($this->translations[$name][$langcode])) {
// Preload all translations for this configuration name and language.
- $this->translations[$name][$langcode] = array();
- foreach ($this->localeStorage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => $name)) as $string) {
+ $this->translations[$name][$langcode] = [];
+ foreach ($this->localeStorage->getTranslations(['language' => $langcode, 'type' => 'configuration', 'name' => $name]) as $string) {
$this->translations[$name][$langcode][$string->context][$string->source] = $string;
}
}
if (!isset($this->translations[$name][$langcode][$context][$source])) {
// There is no translation of the source string in this config location
// to this language for this context.
- if ($translation = $this->localeStorage->findTranslation(array('source' => $source, 'context' => $context, 'language' => $langcode))) {
+ if ($translation = $this->localeStorage->findTranslation(['source' => $source, 'context' => $context, 'language' => $langcode])) {
// Look for a translation of the string. It might have one, but not
// be saved in this configuration location yet.
// If the string has a translation for this context to this language,
@@ -393,7 +393,7 @@ class LocaleConfigManager {
// location so it can be translated, and the string is faster to look
// for next time.
$translation = $this->localeStorage
- ->createString(array('source' => $source, 'context' => $context))
+ ->createString(['source' => $source, 'context' => $context])
->addLocation('configuration', $name)
->save();
}
@@ -418,7 +418,7 @@ class LocaleConfigManager {
* @return $this
*/
public function reset() {
- $this->translations = array();
+ $this->translations = [];
return $this;
}
@@ -442,7 +442,7 @@ class LocaleConfigManager {
$this->translateString($name, $langcode, $source, $context);
if ($string = $this->translations[$name][$langcode][$context][$source]) {
if (!$string->isTranslation()) {
- $conditions = array('lid' => $string->lid, 'language' => $langcode);
+ $conditions = ['lid' => $string->lid, 'language' => $langcode];
$translation = $this->localeStorage->createTranslation($conditions);
$this->translations[$name][$langcode][$context][$source] = $translation;
return $translation;
@@ -564,7 +564,7 @@ class LocaleConfigManager {
* Total number of configuration override and active configuration objects
* updated (saved or removed).
*/
- public function updateConfigTranslations(array $names, array $langcodes = array()) {
+ public function updateConfigTranslations(array $names, array $langcodes = []) {
$langcodes = $langcodes ? $langcodes : array_keys($this->languageManager->getLanguages());
$count = 0;
foreach ($names as $name) {
@@ -589,7 +589,7 @@ class LocaleConfigManager {
$data = $this->filterOverride($override->get(), $translatable);
if (!empty($processed)) {
// Merge in the Locale managed translations with existing data.
- $data = NestedArray::mergeDeepArray(array($data, $processed), TRUE);
+ $data = NestedArray::mergeDeepArray([$data, $processed], TRUE);
}
if (empty($data) && !$override->isNew()) {
// The configuration override contains Locale overrides that no
@@ -607,7 +607,7 @@ class LocaleConfigManager {
// If the language code is the active storage language, we should
// update. If it is English, we should only update if English is also
// translatable.
- $active = NestedArray::mergeDeepArray(array($active, $processed), TRUE);
+ $active = NestedArray::mergeDeepArray([$active, $processed], TRUE);
$this->saveTranslationActive($name, $active);
$count++;
}
@@ -629,7 +629,7 @@ class LocaleConfigManager {
* also in $translatable.
*/
protected function filterOverride(array $override_data, array $translatable) {
- $filtered_data = array();
+ $filtered_data = [];
foreach ($override_data as $key => $value) {
if (isset($translatable[$key])) {
// If the translatable default configuration has this key, look further
diff --git a/core/modules/locale/src/LocaleConfigSubscriber.php b/core/modules/locale/src/LocaleConfigSubscriber.php
index 3542a06c645..d06cb34dec3 100644
--- a/core/modules/locale/src/LocaleConfigSubscriber.php
+++ b/core/modules/locale/src/LocaleConfigSubscriber.php
@@ -114,7 +114,7 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
* override. This allows us to update locale keys for data not in the
* override but still in the active configuration.
*/
- protected function updateLocaleStorage(StorableConfigBase $config, $langcode, array $reference_config = array()) {
+ protected function updateLocaleStorage(StorableConfigBase $config, $langcode, array $reference_config = []) {
$name = $config->getName();
if ($this->localeConfigManager->isSupported($name) && locale_is_translatable($langcode)) {
$translatables = $this->localeConfigManager->getTranslatableDefaultConfig($name);
@@ -139,7 +139,7 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
* override. This allows us to update locale keys for data not in the
* override but still in the active configuration.
*/
- protected function processTranslatableData($name, array $config, array $translatable, $langcode, array $reference_config = array()) {
+ protected function processTranslatableData($name, array $config, array $translatable, $langcode, array $reference_config = []) {
foreach ($translatable as $key => $item) {
if (!isset($config[$key])) {
if (isset($reference_config[$key])) {
@@ -148,7 +148,7 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
continue;
}
if (is_array($item)) {
- $reference_config = isset($reference_config[$key]) ? $reference_config[$key] : array();
+ $reference_config = isset($reference_config[$key]) ? $reference_config[$key] : [];
$this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config);
}
else {
diff --git a/core/modules/locale/src/LocaleEvent.php b/core/modules/locale/src/LocaleEvent.php
index 2a224774937..6e919a64209 100644
--- a/core/modules/locale/src/LocaleEvent.php
+++ b/core/modules/locale/src/LocaleEvent.php
@@ -31,7 +31,7 @@ class LocaleEvent extends Event {
* @param array $lids
* (optional) List of string identifiers that have been updated / created.
*/
- public function __construct(array $lang_codes, array $lids = array()) {
+ public function __construct(array $lang_codes, array $lids = []) {
$this->langCodes = $lang_codes;
$this->lids = $lids;
}
diff --git a/core/modules/locale/src/LocaleLookup.php b/core/modules/locale/src/LocaleLookup.php
index 6bcb88c22cd..9290efc3058 100644
--- a/core/modules/locale/src/LocaleLookup.php
+++ b/core/modules/locale/src/LocaleLookup.php
@@ -99,7 +99,7 @@ class LocaleLookup extends CacheCollector {
$this->cache = $cache;
$this->lock = $lock;
- $this->tags = array('locale');
+ $this->tags = ['locale'];
$this->requestStack = $request_stack;
}
@@ -123,7 +123,7 @@ class LocaleLookup extends CacheCollector {
// cache misses that need to be written into the cache. Prevent that by
// resetting that list. All that happens in such a case are a few uncached
// translation lookups.
- $this->keysToPersist = array();
+ $this->keysToPersist = [];
}
return $this->cid;
}
@@ -132,11 +132,11 @@ class LocaleLookup extends CacheCollector {
* {@inheritdoc}
*/
protected function resolveCacheMiss($offset) {
- $translation = $this->stringStorage->findTranslation(array(
+ $translation = $this->stringStorage->findTranslation([
'language' => $this->langcode,
'source' => $offset,
'context' => $this->context,
- ));
+ ]);
if ($translation) {
$value = !empty($translation->translation) ? $translation->translation : TRUE;
@@ -144,25 +144,25 @@ class LocaleLookup extends CacheCollector {
else {
// We don't have the source string, update the {locales_source} table to
// indicate the string is not translated.
- $this->stringStorage->createString(array(
+ $this->stringStorage->createString([
'source' => $offset,
'context' => $this->context,
'version' => \Drupal::VERSION,
- ))->addLocation('path', $this->requestStack->getCurrentRequest()->getRequestUri())->save();
+ ])->addLocation('path', $this->requestStack->getCurrentRequest()->getRequestUri())->save();
$value = TRUE;
}
// If there is no translation available for the current language then use
// language fallback to try other translations.
if ($value === TRUE) {
- $fallbacks = $this->languageManager->getFallbackCandidates(array('langcode' => $this->langcode, 'operation' => 'locale_lookup', 'data' => $offset));
+ $fallbacks = $this->languageManager->getFallbackCandidates(['langcode' => $this->langcode, 'operation' => 'locale_lookup', 'data' => $offset]);
if (!empty($fallbacks)) {
foreach ($fallbacks as $langcode) {
- $translation = $this->stringStorage->findTranslation(array(
+ $translation = $this->stringStorage->findTranslation([
'language' => $langcode,
'source' => $offset,
'context' => $this->context,
- ));
+ ]);
if ($translation && !empty($translation->translation)) {
$value = $translation->translation;
diff --git a/core/modules/locale/src/LocaleProjectStorage.php b/core/modules/locale/src/LocaleProjectStorage.php
index 907bd6cd7c3..5b352f2cdda 100644
--- a/core/modules/locale/src/LocaleProjectStorage.php
+++ b/core/modules/locale/src/LocaleProjectStorage.php
@@ -21,7 +21,7 @@ class LocaleProjectStorage implements LocaleProjectStorageInterface {
*
* @var array
*/
- protected $cache = array();
+ protected $cache = [];
/**
* Cache status flag.
@@ -44,7 +44,7 @@ class LocaleProjectStorage implements LocaleProjectStorageInterface {
* {@inheritdoc}
*/
public function get($key, $default = NULL) {
- $values = $this->getMultiple(array($key));
+ $values = $this->getMultiple([$key]);
return isset($values[$key]) ? $values[$key] : $default;
}
@@ -52,8 +52,8 @@ class LocaleProjectStorage implements LocaleProjectStorageInterface {
* {@inheritdoc}
*/
public function getMultiple(array $keys) {
- $values = array();
- $load = array();
+ $values = [];
+ $load = [];
foreach ($keys as $key) {
// Check if we have a value in the cache.
if (isset($this->cache[$key])) {
@@ -87,7 +87,7 @@ class LocaleProjectStorage implements LocaleProjectStorageInterface {
* {@inheritdoc}
*/
public function set($key, $value) {
- $this->setMultiple(array($key => $value));
+ $this->setMultiple([$key => $value]);
}
/**
@@ -104,7 +104,7 @@ class LocaleProjectStorage implements LocaleProjectStorageInterface {
* {@inheritdoc}
*/
public function delete($key) {
- $this->deleteMultiple(array($key));
+ $this->deleteMultiple([$key]);
}
/**
@@ -121,7 +121,7 @@ class LocaleProjectStorage implements LocaleProjectStorageInterface {
* {@inheritdoc}
*/
public function resetCache() {
- $this->cache = array();
+ $this->cache = [];
static::$all = FALSE;
}
diff --git a/core/modules/locale/src/LocaleTranslation.php b/core/modules/locale/src/LocaleTranslation.php
index 04f3d62ecfa..94125e91d85 100644
--- a/core/modules/locale/src/LocaleTranslation.php
+++ b/core/modules/locale/src/LocaleTranslation.php
@@ -40,7 +40,7 @@ class LocaleTranslation implements TranslatorInterface, DestructableInterface {
* Array of \Drupal\locale\LocaleLookup objects indexed by language code
* and context.
*/
- protected $translations = array();
+ protected $translations = [];
/**
* The cache backend that should be used.
@@ -137,7 +137,7 @@ class LocaleTranslation implements TranslatorInterface, DestructableInterface {
*/
public function reset() {
unset($this->translateEnglish);
- $this->translations = array();
+ $this->translations = [];
}
/**
diff --git a/core/modules/locale/src/PoDatabaseReader.php b/core/modules/locale/src/PoDatabaseReader.php
index d5c3cd72f1e..55c2b690ada 100644
--- a/core/modules/locale/src/PoDatabaseReader.php
+++ b/core/modules/locale/src/PoDatabaseReader.php
@@ -45,7 +45,7 @@ class PoDatabaseReader implements PoReaderInterface {
* Constructor, initializes with default options.
*/
public function __construct() {
- $this->setOptions(array());
+ $this->setOptions([]);
}
/**
@@ -73,11 +73,11 @@ class PoDatabaseReader implements PoReaderInterface {
* Set the options for the current reader.
*/
public function setOptions(array $options) {
- $options += array(
+ $options += [
'customized' => FALSE,
'not_customized' => FALSE,
'not_translated' => FALSE,
- );
+ ];
$this->options = $options;
}
@@ -104,7 +104,7 @@ class PoDatabaseReader implements PoReaderInterface {
private function loadStrings() {
$langcode = $this->langcode;
$options = $this->options;
- $conditions = array();
+ $conditions = [];
if (array_sum($options) == 0) {
// If user asked to not include anything in the translation files,
diff --git a/core/modules/locale/src/PoDatabaseWriter.php b/core/modules/locale/src/PoDatabaseWriter.php
index f0be23a569d..988f7f3be11 100644
--- a/core/modules/locale/src/PoDatabaseWriter.php
+++ b/core/modules/locale/src/PoDatabaseWriter.php
@@ -89,14 +89,14 @@ class PoDatabaseWriter implements PoWriterInterface {
* @param array $report
* Associative array with result information.
*/
- public function setReport($report = array()) {
- $report += array(
+ public function setReport($report = []) {
+ $report += [
'additions' => 0,
'updates' => 0,
'deletes' => 0,
'skips' => 0,
- 'strings' => array(),
- );
+ 'strings' => [],
+ ];
$this->report = $report;
}
@@ -112,15 +112,15 @@ class PoDatabaseWriter implements PoWriterInterface {
*/
public function setOptions(array $options) {
if (!isset($options['overwrite_options'])) {
- $options['overwrite_options'] = array();
+ $options['overwrite_options'] = [];
}
- $options['overwrite_options'] += array(
+ $options['overwrite_options'] += [
'not_customized' => FALSE,
'customized' => FALSE,
- );
- $options += array(
+ ];
+ $options += [
'customized' => LOCALE_NOT_CUSTOMIZED,
- );
+ ];
$this->options = $options;
}
@@ -148,7 +148,7 @@ class PoDatabaseWriter implements PoWriterInterface {
*/
public function setHeader(PoHeader $header) {
$this->header = $header;
- $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
+ $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: [];
// Check for options.
$options = $this->getOptions();
@@ -205,10 +205,10 @@ class PoDatabaseWriter implements PoWriterInterface {
*/
private function importString(PoItem $item) {
// Initialize overwrite options if not set.
- $this->options['overwrite_options'] += array(
+ $this->options['overwrite_options'] += [
'not_customized' => FALSE,
'customized' => FALSE,
- );
+ ];
$overwrite_options = $this->options['overwrite_options'];
$customized = $this->options['customized'];
@@ -217,17 +217,17 @@ class PoDatabaseWriter implements PoWriterInterface {
$translation = $item->getTranslation();
// Look up the source string and any existing translation.
- $strings = \Drupal::service('locale.storage')->getTranslations(array(
+ $strings = \Drupal::service('locale.storage')->getTranslations([
'language' => $this->langcode,
'source' => $source,
'context' => $context,
- ));
+ ]);
$string = reset($strings);
if (!empty($translation)) {
// Skip this string unless it passes a check for dangerous code.
if (!locale_string_is_safe($translation)) {
- \Drupal::logger('locale')->error('Import of string "%string" was skipped because of disallowed or malformed HTML.', array('%string' => $translation));
+ \Drupal::logger('locale')->error('Import of string "%string" was skipped because of disallowed or malformed HTML.', ['%string' => $translation]);
$this->report['skips']++;
return 0;
}
@@ -235,10 +235,10 @@ class PoDatabaseWriter implements PoWriterInterface {
$string->setString($translation);
if ($string->isNew()) {
// No translation in this language.
- $string->setValues(array(
+ $string->setValues([
'language' => $this->langcode,
'customized' => $customized,
- ));
+ ]);
$string->save();
$this->report['additions']++;
}
@@ -253,14 +253,14 @@ class PoDatabaseWriter implements PoWriterInterface {
}
else {
// No such source string in the database yet.
- $string = \Drupal::service('locale.storage')->createString(array('source' => $source, 'context' => $context))
+ $string = \Drupal::service('locale.storage')->createString(['source' => $source, 'context' => $context])
->save();
- \Drupal::service('locale.storage')->createTranslation(array(
+ \Drupal::service('locale.storage')->createTranslation([
'lid' => $string->getId(),
'language' => $this->langcode,
'translation' => $translation,
'customized' => $customized,
- ))->save();
+ ])->save();
$this->report['additions']++;
$this->report['strings'][] = $string->getId();
diff --git a/core/modules/locale/src/StringBase.php b/core/modules/locale/src/StringBase.php
index 2569289c227..63cd781a54a 100644
--- a/core/modules/locale/src/StringBase.php
+++ b/core/modules/locale/src/StringBase.php
@@ -57,7 +57,7 @@ abstract class StringBase implements StringInterface {
* @param object|array $values
* Object or array with initial values.
*/
- public function __construct($values = array()) {
+ public function __construct($values = []) {
$this->setValues((array) $values);
}
@@ -137,7 +137,7 @@ abstract class StringBase implements StringInterface {
* {@inheritdoc}
*/
public function getValues(array $fields) {
- $values = array();
+ $values = [];
foreach ($fields as $field) {
if (isset($this->$field)) {
$values[$field] = $this->$field;
@@ -151,12 +151,12 @@ abstract class StringBase implements StringInterface {
*/
public function getLocations($check_only = FALSE) {
if (!isset($this->locations) && !$check_only) {
- $this->locations = array();
- foreach ($this->getStorage()->getLocations(array('sid' => $this->getId())) as $location) {
+ $this->locations = [];
+ foreach ($this->getStorage()->getLocations(['sid' => $this->getId()]) as $location) {
$this->locations[$location->type][$location->name] = $location->lid;
}
}
- return isset($this->locations) ? $this->locations : array();
+ return isset($this->locations) ? $this->locations : [];
}
/**
diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php
index 8976224b05b..45bf41d1ff3 100644
--- a/core/modules/locale/src/StringDatabaseStorage.php
+++ b/core/modules/locale/src/StringDatabaseStorage.php
@@ -22,7 +22,7 @@ class StringDatabaseStorage implements StringStorageInterface {
*
* @var array
*/
- protected $options = array();
+ protected $options = [];
/**
* Constructs a new StringDatabaseStorage class.
@@ -32,7 +32,7 @@ class StringDatabaseStorage implements StringStorageInterface {
* @param array $options
* (optional) Any additional database connection options to use in queries.
*/
- public function __construct(Connection $connection, array $options = array()) {
+ public function __construct(Connection $connection, array $options = []) {
$this->connection = $connection;
$this->options = $options;
}
@@ -40,15 +40,15 @@ class StringDatabaseStorage implements StringStorageInterface {
/**
* {@inheritdoc}
*/
- public function getStrings(array $conditions = array(), array $options = array()) {
+ public function getStrings(array $conditions = [], array $options = []) {
return $this->dbStringLoad($conditions, $options, 'Drupal\locale\SourceString');
}
/**
* {@inheritdoc}
*/
- public function getTranslations(array $conditions = array(), array $options = array()) {
- return $this->dbStringLoad($conditions, array('translation' => TRUE) + $options, 'Drupal\locale\TranslationString');
+ public function getTranslations(array $conditions = [], array $options = []) {
+ return $this->dbStringLoad($conditions, ['translation' => TRUE] + $options, 'Drupal\locale\TranslationString');
}
/**
@@ -70,7 +70,7 @@ class StringDatabaseStorage implements StringStorageInterface {
* {@inheritdoc}
*/
public function findTranslation(array $conditions) {
- $values = $this->dbStringSelect($conditions, array('translation' => TRUE))
+ $values = $this->dbStringSelect($conditions, ['translation' => TRUE])
->execute()
->fetchAssoc();
@@ -85,7 +85,7 @@ class StringDatabaseStorage implements StringStorageInterface {
/**
* {@inheritdoc}
*/
- public function getLocations(array $conditions = array()) {
+ public function getLocations(array $conditions = []) {
$query = $this->connection->select('locales_location', 'l', $this->options)
->fields('l');
foreach ($conditions as $field => $value) {
@@ -143,14 +143,14 @@ class StringDatabaseStorage implements StringStorageInterface {
// Make sure that the name isn't longer than 255 characters.
$name = substr($name, 0, 255);
if (!$lid) {
- $this->dbDelete('locales_location', array('sid' => $string->getId(), 'type' => $type, 'name' => $name))
+ $this->dbDelete('locales_location', ['sid' => $string->getId(), 'type' => $type, 'name' => $name])
->execute();
}
elseif ($lid === TRUE) {
// This is a new location to add, take care not to duplicate.
$this->connection->merge('locales_location', $this->options)
- ->keys(array('sid' => $string->getId(), 'type' => $type, 'name' => $name))
- ->fields(array('version' => \Drupal::VERSION))
+ ->keys(['sid' => $string->getId(), 'type' => $type, 'name' => $name])
+ ->fields(['version' => \Drupal::VERSION])
->execute();
$created = TRUE;
}
@@ -177,7 +177,7 @@ class StringDatabaseStorage implements StringStorageInterface {
$string->setVersion($version);
$this->connection->update('locales_source', $this->options)
->condition('lid', $string->getId())
- ->fields(array('version' => $version))
+ ->fields(['version' => $version])
->execute();
}
}
@@ -204,11 +204,11 @@ class StringDatabaseStorage implements StringStorageInterface {
* {@inheritdoc}
*/
public function deleteStrings($conditions) {
- $lids = $this->dbStringSelect($conditions, array('fields' => array('lid')))->execute()->fetchCol();
+ $lids = $this->dbStringSelect($conditions, ['fields' => ['lid']])->execute()->fetchCol();
if ($lids) {
- $this->dbDelete('locales_target', array('lid' => $lids))->execute();
- $this->dbDelete('locales_source', array('lid' => $lids))->execute();
- $this->dbDelete('locales_location', array('sid' => $lids))->execute();
+ $this->dbDelete('locales_target', ['lid' => $lids])->execute();
+ $this->dbDelete('locales_source', ['lid' => $lids])->execute();
+ $this->dbDelete('locales_location', ['sid' => $lids])->execute();
}
}
@@ -222,18 +222,18 @@ class StringDatabaseStorage implements StringStorageInterface {
/**
* {@inheritdoc}
*/
- public function createString($values = array()) {
- return new SourceString($values + array('storage' => $this));
+ public function createString($values = []) {
+ return new SourceString($values + ['storage' => $this]);
}
/**
* {@inheritdoc}
*/
- public function createTranslation($values = array()) {
- return new TranslationString($values + array(
+ public function createTranslation($values = []) {
+ return new TranslationString($values + [
'storage' => $this,
'is_new' => TRUE,
- ));
+ ]);
}
/**
@@ -251,10 +251,10 @@ class StringDatabaseStorage implements StringStorageInterface {
* table fields)
*/
protected function dbFieldTable($field) {
- if (in_array($field, array('language', 'translation', 'customized'))) {
+ if (in_array($field, ['language', 'translation', 'customized'])) {
return 't';
}
- elseif (in_array($field, array('type', 'name'))) {
+ elseif (in_array($field, ['type', 'name'])) {
return 'l';
}
else {
@@ -291,16 +291,16 @@ class StringDatabaseStorage implements StringStorageInterface {
*/
protected function dbStringKeys($string) {
if ($string->isSource()) {
- $keys = array('lid');
+ $keys = ['lid'];
}
elseif ($string->isTranslation()) {
- $keys = array('lid', 'language');
+ $keys = ['lid', 'language'];
}
if (!empty($keys) && ($values = $string->getValues($keys)) && count($keys) == count($values)) {
return $values;
}
else {
- return array();
+ return [];
}
}
@@ -318,7 +318,7 @@ class StringDatabaseStorage implements StringStorageInterface {
* Array of objects of the class requested.
*/
protected function dbStringLoad(array $conditions, array $options, $class) {
- $strings = array();
+ $strings = [];
$result = $this->dbStringSelect($conditions, $options)->execute();
foreach ($result as $item) {
/** @var \Drupal\locale\StringInterface $string */
@@ -350,7 +350,7 @@ class StringDatabaseStorage implements StringStorageInterface {
* @return \Drupal\Core\Database\Query\Select
* Query object with all the tables, fields and conditions.
*/
- protected function dbStringSelect(array $conditions, array $options = array()) {
+ protected function dbStringSelect(array $conditions, array $options = []) {
// Start building the query with source table and check whether we need to
// join the target table too.
$query = $this->connection->select('locales_source', 's', $this->options)
@@ -377,9 +377,9 @@ class StringDatabaseStorage implements StringStorageInterface {
if ($join) {
if (isset($conditions['language'])) {
// If we've got a language condition, we use it for the join.
- $query->$join('locales_target', 't', "t.lid = s.lid AND t.language = :langcode", array(
+ $query->$join('locales_target', 't', "t.lid = s.lid AND t.language = :langcode", [
':langcode' => $conditions['language'],
- ));
+ ]);
unset($conditions['language']);
}
else {
@@ -388,7 +388,7 @@ class StringDatabaseStorage implements StringStorageInterface {
}
if (!empty($options['translation'])) {
// We cannot just add all fields because 'lid' may get null values.
- $query->fields('t', array('language', 'translation', 'customized'));
+ $query->fields('t', ['language', 'translation', 'customized']);
}
}
@@ -397,8 +397,8 @@ class StringDatabaseStorage implements StringStorageInterface {
// array so we can consistently use IN conditions.
if (isset($conditions['type']) || isset($conditions['name'])) {
$subquery = $this->connection->select('locales_location', 'l', $this->options)
- ->fields('l', array('sid'));
- foreach (array('type', 'name') as $field) {
+ ->fields('l', ['sid']);
+ foreach (['type', 'name'] as $field) {
if (isset($conditions[$field])) {
$subquery->condition('l.' . $field, (array) $conditions[$field], 'IN');
unset($conditions[$field]);
@@ -464,12 +464,12 @@ class StringDatabaseStorage implements StringStorageInterface {
*/
protected function dbStringInsert($string) {
if ($string->isSource()) {
- $string->setValues(array('context' => '', 'version' => 'none'), FALSE);
- $fields = $string->getValues(array('source', 'context', 'version'));
+ $string->setValues(['context' => '', 'version' => 'none'], FALSE);
+ $fields = $string->getValues(['source', 'context', 'version']);
}
elseif ($string->isTranslation()) {
- $string->setValues(array('customized' => 0), FALSE);
- $fields = $string->getValues(array('lid', 'language', 'translation', 'customized'));
+ $string->setValues(['customized' => 0], FALSE);
+ $fields = $string->getValues(['lid', 'language', 'translation', 'customized']);
}
if (!empty($fields)) {
return $this->connection->insert($this->dbStringTable($string), $this->options)
@@ -496,10 +496,10 @@ class StringDatabaseStorage implements StringStorageInterface {
*/
protected function dbStringUpdate($string) {
if ($string->isSource()) {
- $values = $string->getValues(array('source', 'context', 'version'));
+ $values = $string->getValues(['source', 'context', 'version']);
}
elseif ($string->isTranslation()) {
- $values = $string->getValues(array('translation', 'customized'));
+ $values = $string->getValues(['translation', 'customized']);
}
if (!empty($values) && $keys = $this->dbStringKeys($string)) {
return $this->connection->merge($this->dbStringTable($string), $this->options)
@@ -534,7 +534,7 @@ class StringDatabaseStorage implements StringStorageInterface {
/**
* Executes an arbitrary SELECT query string with the injected options.
*/
- protected function dbExecute($query, array $args = array()) {
+ protected function dbExecute($query, array $args = []) {
return $this->connection->query($query, $args, $this->options);
}
diff --git a/core/modules/locale/src/StringStorageInterface.php b/core/modules/locale/src/StringStorageInterface.php
index da1c8fb1f0a..18c5edc2b69 100644
--- a/core/modules/locale/src/StringStorageInterface.php
+++ b/core/modules/locale/src/StringStorageInterface.php
@@ -27,7 +27,7 @@ interface StringStorageInterface {
* @return array
* Array of \Drupal\locale\StringInterface objects matching the conditions.
*/
- public function getStrings(array $conditions = array(), array $options = array());
+ public function getStrings(array $conditions = [], array $options = []);
/**
* Loads multiple string translation objects.
@@ -44,7 +44,7 @@ interface StringStorageInterface {
*
* @see \Drupal\locale\StringStorageInterface::getStrings()
*/
- public function getTranslations(array $conditions = array(), array $options = array());
+ public function getTranslations(array $conditions = [], array $options = []);
/**
* Loads string location information.
@@ -61,7 +61,7 @@ interface StringStorageInterface {
*
* @see \Drupal\locale\StringStorageInterface::getStrings()
*/
- public function getLocations(array $conditions = array());
+ public function getLocations(array $conditions = []);
/**
* Loads a string source object, fast query.
@@ -164,7 +164,7 @@ interface StringStorageInterface {
* @return \Drupal\locale\SourceString
* New source string object.
*/
- public function createString($values = array());
+ public function createString($values = []);
/**
* Creates a string translation object bound to this storage but not saved.
@@ -175,6 +175,6 @@ interface StringStorageInterface {
* @return \Drupal\locale\TranslationString
* New string translation object.
*/
- public function createTranslation($values = array());
+ public function createTranslation($values = []);
}
diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php
index 9ad620fcf44..9e80c7bce42 100644
--- a/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php
+++ b/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php
@@ -18,13 +18,13 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language', 'locale_test_translate');
+ public static $modules = ['language', 'locale_test_translate'];
/**
* Test update changes configuration translations if enabled after language.
*/
public function testConfigTranslationImport() {
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions']);
$this->drupalLogin($admin_user);
// Add a language. The Afrikaans translation file of locale_test_translate
@@ -32,7 +32,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
ConfigurableLanguage::createFromLangcode('af')->save();
// Enable locale module.
- $this->container->get('module_installer')->install(array('locale'));
+ $this->container->get('module_installer')->install(['locale']);
$this->resetAll();
// Enable import of translations. By default this is disabled for automated
@@ -42,9 +42,9 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
->save();
// Add translation permissions now that the locale module has been enabled.
- $edit = array(
+ $edit = [
'authenticated[translate interface]' => 'translate interface',
- );
+ ];
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
// Check and update the translation status. This will import the Afrikaans
@@ -57,7 +57,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
$status['drupal']['af']->type = 'current';
\Drupal::state()->set('locale.translation_status', $status);
- $this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
+ $this->drupalPostForm('admin/reports/translations', [], t('Update translations'));
// Check if configuration translations have been imported.
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'system.maintenance');
@@ -77,7 +77,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
// import. Test that this override is in place.
$this->assertFalse($this->config('locale.settings')->get('translation.import_enabled'), 'Translations imports are disabled by default in the Testing profile.');
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate configuration'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate configuration']);
$this->drupalLogin($admin_user);
// Enable import of translations. By default this is disabled for automated
@@ -90,7 +90,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'af'], t('Add language'));
// Add the system branding block to the page.
- $this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'site-branding'));
+ $this->drupalPlaceBlock('system_branding_block', ['region' => 'header', 'id' => 'site-branding']);
$this->drupalPostForm('admin/config/system/site-information', ['site_slogan' => 'Test site slogan'], 'Save configuration');
$this->drupalPostForm('admin/config/system/site-information/translate/af/edit', ['translation[config_names][system.site][slogan]' => 'Test site slogan in Afrikaans'], 'Save translation');
@@ -135,7 +135,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
$this->container->get('module_installer')->install(['locale']);
$this->resetAll();
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate interface']);
$this->drupalLogin($admin_user);
// Enable import of translations. By default this is disabled for automated
@@ -153,7 +153,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
// Remove the string from translation to simulate a Locale removal. Note
// that is no current way of doing this in the UI.
$locale_storage = \Drupal::service('locale.storage');
- $string = $locale_storage->findString(array('source' => 'Locale can translate'));
+ $string = $locale_storage->findString(['source' => 'Locale can translate']);
\Drupal::service('locale.storage')->delete($string);
// Force a rebuild of config translations.
$count = Locale::config()->updateConfigTranslations(['locale_test_translate.settings'], ['af']);
@@ -172,7 +172,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
$this->container->get('module_installer')->install(['locale']);
$this->resetAll();
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate interface']);
$this->drupalLogin($admin_user);
// Enable import of translations. By default this is disabled for automated
@@ -198,18 +198,18 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
$this->assertEqual($expected, $override->get());
// Set the translated string to empty.
- $search = array(
+ $search = [
'string' => 'Locale can translate',
'langcode' => 'af',
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textareas = $this->xpath('//textarea');
$textarea = current($textareas);
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => '',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings');
diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php
index 271f6e2f373..a90dce0c54c 100644
--- a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php
+++ b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php
@@ -24,7 +24,7 @@ class LocaleConfigTranslationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'contact', 'contact_test');
+ public static $modules = ['locale', 'contact', 'contact_test'];
/**
* {@inheritdoc}
@@ -42,15 +42,15 @@ class LocaleConfigTranslationTest extends WebTestBase {
// Add custom language.
$this->langcode = 'xx';
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form', 'administer contact forms', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form', 'administer contact forms', 'administer site configuration']);
$this->drupalLogin($admin_user);
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $this->langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Set path prefix.
$edit = ["prefix[$this->langcode]" => $this->langcode];
@@ -63,23 +63,23 @@ class LocaleConfigTranslationTest extends WebTestBase {
public function testConfigTranslation() {
// Check that the maintenance message exists and create translation for it.
$source = '@site is currently under maintenance. We should be back shortly. Thank you for your patience.';
- $string = $this->storage->findString(array('source' => $source, 'context' => '', 'type' => 'configuration'));
+ $string = $this->storage->findString(['source' => $source, 'context' => '', 'type' => 'configuration']);
$this->assertTrue($string, 'Configuration strings have been created upon installation.');
// Translate using the UI so configuration is refreshed.
$message = $this->randomMachineName(20);
- $search = array(
+ $search = [
'string' => $string->source,
'langcode' => $this->langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textareas = $this->xpath('//textarea');
$textarea = current($textareas);
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $message,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Get translation and check we've only got the message.
@@ -88,22 +88,22 @@ class LocaleConfigTranslationTest extends WebTestBase {
$this->assertEqual($translation['message'], $message);
// Check default medium date format exists and create a translation for it.
- $string = $this->storage->findString(array('source' => 'D, m/d/Y - H:i', 'context' => 'PHP date format', 'type' => 'configuration'));
+ $string = $this->storage->findString(['source' => 'D, m/d/Y - H:i', 'context' => 'PHP date format', 'type' => 'configuration']);
$this->assertTrue($string, 'Configuration date formats have been created upon installation.');
// Translate using the UI so configuration is refreshed.
- $search = array(
+ $search = [
'string' => $string->source,
'langcode' => $this->langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textareas = $this->xpath('//textarea');
$textarea = current($textareas);
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => 'D',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$translation = \Drupal::languageManager()->getLanguageConfigOverride($this->langcode, 'core.date_format.medium')->get();
@@ -115,14 +115,14 @@ class LocaleConfigTranslationTest extends WebTestBase {
$this->assertEqual($formatted_date, 'Tue', 'Got the right formatted date using the date format translation pattern.');
// Assert strings from image module config are not available.
- $string = $this->storage->findString(array('source' => 'Medium (220×220)', 'context' => '', 'type' => 'configuration'));
+ $string = $this->storage->findString(['source' => 'Medium (220×220)', 'context' => '', 'type' => 'configuration']);
$this->assertFalse($string, 'Configuration strings have been created upon installation.');
// Enable the image module.
- $this->drupalPostForm('admin/modules', array('modules[image][enable]' => "1"), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[image][enable]' => "1"], t('Install'));
$this->rebuildContainer();
- $string = $this->storage->findString(array('source' => 'Medium (220×220)', 'context' => '', 'type' => 'configuration'));
+ $string = $this->storage->findString(['source' => 'Medium (220×220)', 'context' => '', 'type' => 'configuration']);
$this->assertTrue($string, 'Configuration strings have been created upon installation.');
$locations = $string->getLocations();
$this->assertTrue(isset($locations['configuration']) && isset($locations['configuration']['image.style.medium']), 'Configuration string has been created with the right location');
@@ -136,17 +136,17 @@ class LocaleConfigTranslationTest extends WebTestBase {
// Translate using the UI so configuration is refreshed.
$image_style_label = $this->randomMachineName(20);
- $search = array(
+ $search = [
'string' => $string->source,
'langcode' => $this->langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $image_style_label,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Check the right single translation has been created.
@@ -159,8 +159,8 @@ class LocaleConfigTranslationTest extends WebTestBase {
$this->assertEqual($translation['label'], $image_style_label, 'Got the right translation for image style name after translation');
// Uninstall the module.
- $this->drupalPostForm('admin/modules/uninstall', array('uninstall[image]' => "image"), t('Uninstall'));
- $this->drupalPostForm(NULL, array(), t('Uninstall'));
+ $this->drupalPostForm('admin/modules/uninstall', ['uninstall[image]' => "image"], t('Uninstall'));
+ $this->drupalPostForm(NULL, [], t('Uninstall'));
// Ensure that the translated configuration has been removed.
$override = \Drupal::languageManager()->getLanguageConfigOverride('xx', 'image.style.medium');
@@ -168,17 +168,17 @@ class LocaleConfigTranslationTest extends WebTestBase {
// Translate default category using the UI so configuration is refreshed.
$category_label = $this->randomMachineName(20);
- $search = array(
+ $search = [
'string' => 'Website feedback',
'langcode' => $this->langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $category_label,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Check if this category displayed in this language will use the
diff --git a/core/modules/locale/src/Tests/LocaleExportTest.php b/core/modules/locale/src/Tests/LocaleExportTest.php
index f9cd2ea7ce4..54d36e2bc80 100644
--- a/core/modules/locale/src/Tests/LocaleExportTest.php
+++ b/core/modules/locale/src/Tests/LocaleExportTest.php
@@ -16,7 +16,7 @@ class LocaleExportTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale');
+ public static $modules = ['locale'];
/**
* A user able to create languages and export translations.
@@ -29,7 +29,7 @@ class LocaleExportTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
+ $this->adminUser = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages']);
$this->drupalLogin($this->adminUser);
// Copy test po files to the translations directory.
@@ -45,16 +45,16 @@ class LocaleExportTest extends WebTestBase {
// This will also automatically add the 'fr' language.
$name = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po';
file_put_contents($name, $this->getPoFile());
- $this->drupalPostForm('admin/config/regional/translate/import', array(
+ $this->drupalPostForm('admin/config/regional/translate/import', [
'langcode' => 'fr',
'files[file]' => $name,
- ), t('Import'));
+ ], t('Import'));
drupal_unlink($name);
// Get the French translations.
- $this->drupalPostForm('admin/config/regional/translate/export', array(
+ $this->drupalPostForm('admin/config/regional/translate/export', [
'langcode' => 'fr',
- ), t('Export'));
+ ], t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', 'Exported French translation file.');
@@ -64,11 +64,11 @@ class LocaleExportTest extends WebTestBase {
// Import some more French translations which will be marked as customized.
$name = \Drupal::service('file_system')->tempnam('temporary://', "po2_") . '.po';
file_put_contents($name, $this->getCustomPoFile());
- $this->drupalPostForm('admin/config/regional/translate/import', array(
+ $this->drupalPostForm('admin/config/regional/translate/import', [
'langcode' => 'fr',
'files[file]' => $name,
'customized' => 1,
- ), t('Import'));
+ ], t('Import'));
drupal_unlink($name);
// Create string without translation in the locales_source table.
@@ -79,12 +79,12 @@ class LocaleExportTest extends WebTestBase {
->save();
// Export only customized French translations.
- $this->drupalPostForm('admin/config/regional/translate/export', array(
+ $this->drupalPostForm('admin/config/regional/translate/export', [
'langcode' => 'fr',
'content_options[not_customized]' => FALSE,
'content_options[customized]' => TRUE,
'content_options[not_translated]' => FALSE,
- ), t('Export'));
+ ], t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', 'Exported French translation file with only customized strings.');
@@ -94,12 +94,12 @@ class LocaleExportTest extends WebTestBase {
$this->assertNoRaw('msgid "February"', 'Untranslated string not present in exported file.');
// Export only untranslated French translations.
- $this->drupalPostForm('admin/config/regional/translate/export', array(
+ $this->drupalPostForm('admin/config/regional/translate/export', [
'langcode' => 'fr',
'content_options[not_customized]' => FALSE,
'content_options[customized]' => FALSE,
'content_options[not_translated]' => TRUE,
- ), t('Export'));
+ ], t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', 'Exported French translation file with only untranslated strings.');
@@ -118,7 +118,7 @@ class LocaleExportTest extends WebTestBase {
// the locales_source table gets populated with something.
$this->drupalGet('admin/config/regional/language');
// Get the translation template file.
- $this->drupalPostForm('admin/config/regional/translate/export', array(), t('Export'));
+ $this->drupalPostForm('admin/config/regional/translate/export', [], t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# LANGUAGE translation of PROJECT', 'Exported translation template file.');
}
diff --git a/core/modules/locale/src/Tests/LocaleFileSystemFormTest.php b/core/modules/locale/src/Tests/LocaleFileSystemFormTest.php
index 1e417552e15..e25ec4095f4 100644
--- a/core/modules/locale/src/Tests/LocaleFileSystemFormTest.php
+++ b/core/modules/locale/src/Tests/LocaleFileSystemFormTest.php
@@ -16,14 +16,14 @@ class LocaleFileSystemFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* {@inheritdoc}
*/
protected function setUp(){
parent::setUp();
- $account = $this->drupalCreateUser(array('administer site configuration'));
+ $account = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($account);
}
@@ -44,9 +44,9 @@ class LocaleFileSystemFormTest extends WebTestBase {
// The setting should persist.
$translation_path = $this->publicFilesDirectory . '/translations_changed';
- $fields = array(
+ $fields = [
'translation_path' => $translation_path
- );
+ ];
$this->drupalPostForm(NULL, $fields, t('Save configuration'));
$this->drupalGet('admin/config/media/file-system');
$this->assertFieldByName('translation_path', $translation_path);
diff --git a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
index 7fb93d9309f..c1d9a612a9c 100644
--- a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
@@ -17,7 +17,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'dblog');
+ public static $modules = ['locale', 'dblog'];
/**
* A user able to create languages and import translations.
@@ -44,8 +44,8 @@ class LocaleImportFunctionalTest extends WebTestBase {
file_unmanaged_copy(__DIR__ . '/../../tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
file_unmanaged_copy(__DIR__ . '/../../tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
- $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
- $this->adminUserAccessSiteReports = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages', 'access site reports'));
+ $this->adminUser = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages']);
+ $this->adminUserAccessSiteReports = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages', 'access site reports']);
$this->drupalLogin($this->adminUser);
// Enable import of translations. By default this is disabled for automated
@@ -60,15 +60,15 @@ class LocaleImportFunctionalTest extends WebTestBase {
*/
public function testStandalonePoFile() {
// Try importing a .po file.
- $this->importPoFile($this->getPoFile(), array(
+ $this->importPoFile($this->getPoFile(), [
'langcode' => 'fr',
- ));
+ ]);
$this->config('locale.settings');
// The import should automatically create the corresponding language.
- $this->assertRaw(t('The language %language has been created.', array('%language' => 'French')), 'The language has been automatically created.');
+ $this->assertRaw(t('The language %language has been created.', ['%language' => 'French']), 'The language has been automatically created.');
// The import should have created 8 strings.
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 8, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 8, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
// This import should have saved plural forms to have 2 variants.
$locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr');
@@ -78,14 +78,14 @@ class LocaleImportFunctionalTest extends WebTestBase {
$this->assertUrl(\Drupal::url('locale.translate_page', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
// Try importing a .po file with invalid tags.
- $this->importPoFile($this->getBadPoFile(), array(
+ $this->importPoFile($this->getBadPoFile(), [
'langcode' => 'fr',
- ));
+ ]);
// The import should have created 1 string and rejected 2.
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
- $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', array(':url' => \Drupal::url('dblog.overview')));
+ $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', [':url' => \Drupal::url('dblog.overview')]);
$this->assertRaw($skip_message, 'Unsafe strings were skipped.');
// Repeat the process with a user that can access site reports, and this
@@ -93,19 +93,19 @@ class LocaleImportFunctionalTest extends WebTestBase {
$this->drupalLogin($this->adminUserAccessSiteReports);
// Try importing a .po file with invalid tags.
- $this->importPoFile($this->getBadPoFile(), array(
+ $this->importPoFile($this->getBadPoFile(), [
'langcode' => 'fr',
- ));
+ ]);
- $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', array(':url' => \Drupal::url('dblog.overview')));
+ $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', [':url' => \Drupal::url('dblog.overview')]);
$this->assertRaw($skip_message, 'Unsafe strings were skipped.');
// Check empty files import with a user that cannot access site reports..
$this->drupalLogin($this->adminUser);
// Try importing a zero byte sized .po file.
- $this->importPoFile($this->getEmptyPoFile(), array(
+ $this->importPoFile($this->getEmptyPoFile(), [
'langcode' => 'fr',
- ));
+ ]);
// The import should have created 0 string and rejected 0.
$this->assertRaw(t('One translation file could not be imported. See the log for details.'), 'The empty translation file import reported no translations imported.');
@@ -113,35 +113,35 @@ class LocaleImportFunctionalTest extends WebTestBase {
// time the different warnings must contain links to the log.
$this->drupalLogin($this->adminUserAccessSiteReports);
// Try importing a zero byte sized .po file.
- $this->importPoFile($this->getEmptyPoFile(), array(
+ $this->importPoFile($this->getEmptyPoFile(), [
'langcode' => 'fr',
- ));
+ ]);
// The import should have created 0 string and rejected 0.
- $this->assertRaw(t('One translation file could not be imported. <a href=":url">See the log</a> for details.', array(':url' => \Drupal::url('dblog.overview'))), 'The empty translation file import reported no translations imported.');
+ $this->assertRaw(t('One translation file could not be imported. <a href=":url">See the log</a> for details.', [':url' => \Drupal::url('dblog.overview')]), 'The empty translation file import reported no translations imported.');
// Try importing a .po file which doesn't exist.
$name = $this->randomMachineName(16);
- $this->drupalPostForm('admin/config/regional/translate/import', array(
+ $this->drupalPostForm('admin/config/regional/translate/import', [
'langcode' => 'fr',
'files[file]' => $name,
- ), t('Import'));
+ ], t('Import'));
$this->assertUrl(\Drupal::url('locale.translate_import', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('File to import not found.'), 'File to import not found message.');
// Try importing a .po file with overriding strings, and ensure existing
// strings are kept.
- $this->importPoFile($this->getOverwritePoFile(), array(
+ $this->importPoFile($this->getOverwritePoFile(), [
'langcode' => 'fr',
- ));
+ ]);
// The import should have created 1 string.
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
// Ensure string wasn't overwritten.
- $search = array(
+ $search = [
'string' => 'Montag',
'langcode' => 'fr',
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), 'String not overwritten by imported string.');
@@ -151,19 +151,19 @@ class LocaleImportFunctionalTest extends WebTestBase {
// Try importing a .po file with overriding strings, and ensure existing
// strings are overwritten.
- $this->importPoFile($this->getOverwritePoFile(), array(
+ $this->importPoFile($this->getOverwritePoFile(), [
'langcode' => 'fr',
'overwrite_options[not_customized]' => TRUE,
- ));
+ ]);
// The import should have updated 2 strings.
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 0, '%update' => 2, '%delete' => 0)), 'The translation file was successfully imported.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]), 'The translation file was successfully imported.');
// Ensure string was overwritten.
- $search = array(
+ $search = [
'string' => 'Montag',
'langcode' => 'fr',
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), 'String overwritten by imported string.');
// This import should have changed number of plural forms.
@@ -171,54 +171,54 @@ class LocaleImportFunctionalTest extends WebTestBase {
$this->assertEqual(3, $locale_plurals, 'Plural numbers changed.');
// Importing a .po file and mark its strings as customized strings.
- $this->importPoFile($this->getCustomPoFile(), array(
+ $this->importPoFile($this->getCustomPoFile(), [
'langcode' => 'fr',
'customized' => TRUE,
- ));
+ ]);
// The import should have created 6 strings.
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 6, '%update' => 0, '%delete' => 0)), 'The customized translation file was successfully imported.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 6, '%update' => 0, '%delete' => 0]), 'The customized translation file was successfully imported.');
// The database should now contain 6 customized strings (two imported
// strings are not translated).
- $count = db_query('SELECT COUNT(*) FROM {locales_target} WHERE customized = :custom', array(':custom' => 1))->fetchField();
+ $count = db_query('SELECT COUNT(*) FROM {locales_target} WHERE customized = :custom', [':custom' => 1])->fetchField();
$this->assertEqual($count, 6, 'Customized translations successfully imported.');
// Try importing a .po file with overriding strings, and ensure existing
// customized strings are kept.
- $this->importPoFile($this->getCustomOverwritePoFile(), array(
+ $this->importPoFile($this->getCustomOverwritePoFile(), [
'langcode' => 'fr',
'overwrite_options[not_customized]' => TRUE,
'overwrite_options[customized]' => FALSE,
- ));
+ ]);
// The import should have created 1 string.
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The customized translation file was successfully imported.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The customized translation file was successfully imported.');
// Ensure string wasn't overwritten.
- $search = array(
+ $search = [
'string' => 'januari',
'langcode' => 'fr',
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), 'Customized string not overwritten by imported string.');
// Try importing a .po file with overriding strings, and ensure existing
// customized strings are overwritten.
- $this->importPoFile($this->getCustomOverwritePoFile(), array(
+ $this->importPoFile($this->getCustomOverwritePoFile(), [
'langcode' => 'fr',
'overwrite_options[not_customized]' => FALSE,
'overwrite_options[customized]' => TRUE,
- ));
+ ]);
// The import should have updated 2 strings.
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 0, '%update' => 2, '%delete' => 0)), 'The customized translation file was successfully imported.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]), 'The customized translation file was successfully imported.');
// Ensure string was overwritten.
- $search = array(
+ $search = [
'string' => 'januari',
'langcode' => 'fr',
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), 'Customized string overwritten by imported string.');
@@ -229,14 +229,14 @@ class LocaleImportFunctionalTest extends WebTestBase {
*/
public function testLanguageContext() {
// Try importing a .po file.
- $this->importPoFile($this->getPoFileWithContext(), array(
+ $this->importPoFile($this->getPoFileWithContext(), [
'langcode' => 'hr',
- ));
+ ]);
// We cast the return value of t() to string so as to retrieve the
// translated value, rendered as a string.
- $this->assertIdentical((string) t('May', array(), array('langcode' => 'hr', 'context' => 'Long month name')), 'Svibanj', 'Long month name context is working.');
- $this->assertIdentical((string) t('May', array(), array('langcode' => 'hr')), 'Svi.', 'Default context is working.');
+ $this->assertIdentical((string) t('May', [], ['langcode' => 'hr', 'context' => 'Long month name']), 'Svibanj', 'Long month name context is working.');
+ $this->assertIdentical((string) t('May', [], ['langcode' => 'hr']), 'Svi.', 'Default context is working.');
}
/**
@@ -246,26 +246,26 @@ class LocaleImportFunctionalTest extends WebTestBase {
$langcode = 'hu';
// Try importing a .po file.
- $this->importPoFile($this->getPoFileWithMsgstr(), array(
+ $this->importPoFile($this->getPoFileWithMsgstr(), [
'langcode' => $langcode,
- ));
+ ]);
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
- $this->assertIdentical((string) t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', 'String imported and translated.');
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
+ $this->assertIdentical((string) t('Operations', [], ['langcode' => $langcode]), 'Műveletek', 'String imported and translated.');
// Try importing a .po file.
- $this->importPoFile($this->getPoFileWithEmptyMsgstr(), array(
+ $this->importPoFile($this->getPoFileWithEmptyMsgstr(), [
'langcode' => $langcode,
'overwrite_options[not_customized]' => TRUE,
- ));
- $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 0, '%update' => 0, '%delete' => 1)), 'The translation file was successfully imported.');
+ ]);
+ $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 0, '%delete' => 1]), 'The translation file was successfully imported.');
$str = "Operations";
- $search = array(
+ $search = [
'string' => $str,
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText($str, 'Search found the string as untranslated.');
}
@@ -276,27 +276,27 @@ class LocaleImportFunctionalTest extends WebTestBase {
public function testConfigPoFile() {
// Values for translations to assert. Config key, original string,
// translation and config property name.
- $config_strings = array(
- 'system.maintenance' => array(
+ $config_strings = [
+ 'system.maintenance' => [
'@site is currently under maintenance. We should be back shortly. Thank you for your patience.',
'@site karbantartás alatt áll. Rövidesen visszatérünk. Köszönjük a türelmet.',
'message',
- ),
- 'user.role.anonymous' => array(
+ ],
+ 'user.role.anonymous' => [
'Anonymous user',
'Névtelen felhasználó',
'label',
- ),
- );
+ ],
+ ];
// Add custom language for testing.
$langcode = 'xx';
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $this->randomMachineName(16),
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Check for the source strings we are going to translate. Adding the
@@ -304,24 +304,24 @@ class LocaleImportFunctionalTest extends WebTestBase {
// strings to interface translation executed.
$locale_storage = $this->container->get('locale.storage');
foreach ($config_strings as $config_string) {
- $string = $locale_storage->findString(array('source' => $config_string[0], 'context' => '', 'type' => 'configuration'));
+ $string = $locale_storage->findString(['source' => $config_string[0], 'context' => '', 'type' => 'configuration']);
$this->assertTrue($string, 'Configuration strings have been created upon installation.');
}
// Import a .po file to translate.
- $this->importPoFile($this->getPoFileWithConfig(), array(
+ $this->importPoFile($this->getPoFileWithConfig(), [
'langcode' => $langcode,
- ));
+ ]);
// Translations got recorded in the interface translation system.
foreach ($config_strings as $config_string) {
- $search = array(
+ $search = [
'string' => $config_string[0],
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
- $this->assertText($config_string[1], format_string('Translation of @string found.', array('@string' => $config_string[0])));
+ $this->assertText($config_string[1], format_string('Translation of @string found.', ['@string' => $config_string[0]]));
}
// Test that translations got recorded in the config system.
@@ -340,8 +340,8 @@ class LocaleImportFunctionalTest extends WebTestBase {
$langcode = 'de';
// Import a .po file to translate.
- $this->importPoFile($this->getPoFileWithConfigDe(), array(
- 'langcode' => $langcode));
+ $this->importPoFile($this->getPoFileWithConfigDe(), [
+ 'langcode' => $langcode]);
// Check that the 'Anonymous' string is translated.
$config = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'user.settings');
@@ -353,7 +353,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
*/
public function testCreatedLanguageTranslation() {
// Import a .po file to add de language.
- $this->importPoFile($this->getPoFileWithConfigDe(), array('langcode' => 'de'));
+ $this->importPoFile($this->getPoFileWithConfigDe(), ['langcode' => 'de']);
// Get the language.entity.de label and check it's been translated.
$override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'language.entity.de');
@@ -368,7 +368,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
* @param array $options
* (optional) Additional options to pass to the translation import form.
*/
- public function importPoFile($contents, array $options = array()) {
+ public function importPoFile($contents, array $options = []) {
$name = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po';
file_put_contents($name, $contents);
$options['files[file]'] = $name;
diff --git a/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php b/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php
index b16ba1889b0..fe99ce2f37c 100644
--- a/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php
+++ b/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php
@@ -18,7 +18,7 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'locale_test');
+ public static $modules = ['locale', 'locale_test'];
public function testFileParsing() {
$filename = __DIR__ . '/../../tests/locale_test.js';
@@ -29,19 +29,19 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
// Get all of the source strings that were found.
$strings = $this->container
->get('locale.storage')
- ->getStrings(array(
+ ->getStrings([
'type' => 'javascript',
'name' => $filename,
- ));
+ ]);
- $source_strings = array();
+ $source_strings = [];
foreach ($strings as $string) {
$source_strings[$string->source] = $string->context;
}
$etx = LOCALE_PLURAL_DELIMITER;
// List of all strings that should be in the file.
- $test_strings = array(
+ $test_strings = [
'Standard Call t' => '',
'Whitespace Call t' => '',
@@ -73,11 +73,11 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
"Context Unquoted plural{$etx}Context Unquoted @count plural" => 'Context string unquoted',
"Context Single Quoted plural{$etx}Context Single Quoted @count plural" => 'Context string single quoted',
"Context Double Quoted plural{$etx}Context Double Quoted @count plural" => 'Context string double quoted',
- );
+ ];
// Assert that all strings were found properly.
foreach ($test_strings as $str => $context) {
- $args = array('%source' => $str, '%context' => $context);
+ $args = ['%source' => $str, '%context' => $context];
// Make sure that the string was found in the file.
$this->assertTrue(isset($source_strings[$str]), SafeMarkup::format('Found source string: %source', $args));
@@ -95,7 +95,7 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
*/
public function testLocaleTranslationJsDependencies() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'translate interface']);
// Add custom language.
$this->drupalLogin($admin_user);
@@ -105,16 +105,16 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
$name = $this->randomMachineName(16);
// The domain prefix.
$prefix = $langcode;
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Set path prefix.
- $edit = array("prefix[$langcode]" => $prefix);
+ $edit = ["prefix[$langcode]" => $prefix];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
// This forces locale.admin.js string sources to be imported, which contains
@@ -123,11 +123,11 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
// Translate a string in locale.admin.js to our new language.
$strings = \Drupal::service('locale.storage')
- ->getStrings(array(
+ ->getStrings([
'source' => 'Show description',
'type' => 'javascript',
'name' => 'core/modules/locale/locale.admin.js',
- ));
+ ]);
$string = $strings[0];
$this->drupalPostForm(NULL, ['string' => 'Show description'], t('Filter'));
diff --git a/core/modules/locale/src/Tests/LocaleLibraryAlterTest.php b/core/modules/locale/src/Tests/LocaleLibraryAlterTest.php
index e84e3dd488c..68996f44a20 100644
--- a/core/modules/locale/src/Tests/LocaleLibraryAlterTest.php
+++ b/core/modules/locale/src/Tests/LocaleLibraryAlterTest.php
@@ -19,7 +19,7 @@ class LocaleLibraryAlterTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale');
+ public static $modules = ['locale'];
/**
* Verifies that the datepicker can be localized.
diff --git a/core/modules/locale/src/Tests/LocalePluralFormatTest.php b/core/modules/locale/src/Tests/LocalePluralFormatTest.php
index c0e9041f051..2315dbd22b4 100644
--- a/core/modules/locale/src/Tests/LocalePluralFormatTest.php
+++ b/core/modules/locale/src/Tests/LocalePluralFormatTest.php
@@ -24,7 +24,7 @@ class LocalePluralFormatTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale');
+ public static $modules = ['locale'];
/**
* {@inheritdoc}
@@ -32,7 +32,7 @@ class LocalePluralFormatTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
+ $this->adminUser = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages']);
$this->drupalLogin($this->adminUser);
}
@@ -43,23 +43,23 @@ class LocalePluralFormatTest extends WebTestBase {
public function testGetPluralFormat() {
// Import some .po files with formulas to set up the environment.
// These will also add the languages to the system.
- $this->importPoFile($this->getPoFileWithSimplePlural(), array(
+ $this->importPoFile($this->getPoFileWithSimplePlural(), [
'langcode' => 'fr',
- ));
- $this->importPoFile($this->getPoFileWithComplexPlural(), array(
+ ]);
+ $this->importPoFile($this->getPoFileWithComplexPlural(), [
'langcode' => 'hr',
- ));
+ ]);
// Attempt to import some broken .po files as well to prove that these
// will not overwrite the proper plural formula imported above.
- $this->importPoFile($this->getPoFileWithMissingPlural(), array(
+ $this->importPoFile($this->getPoFileWithMissingPlural(), [
'langcode' => 'fr',
'overwrite_options[not_customized]' => TRUE,
- ));
- $this->importPoFile($this->getPoFileWithBrokenPlural(), array(
+ ]);
+ $this->importPoFile($this->getPoFileWithBrokenPlural(), [
'langcode' => 'hr',
'overwrite_options[not_customized]' => TRUE,
- ));
+ ]);
// Reset static caches from locale_get_plural() to ensure we get fresh data.
drupal_static_reset('locale_get_plural');
@@ -67,49 +67,49 @@ class LocalePluralFormatTest extends WebTestBase {
drupal_static_reset('locale');
// Expected plural translation strings for each plural index.
- $plural_strings = array(
+ $plural_strings = [
// English is not imported in this case, so we assume built-in text
// and formulas.
- 'en' => array(
+ 'en' => [
0 => '1 hour',
1 => '@count hours',
- ),
- 'fr' => array(
+ ],
+ 'fr' => [
0 => '@count heure',
1 => '@count heures',
- ),
- 'hr' => array(
+ ],
+ 'hr' => [
0 => '@count sat',
1 => '@count sata',
2 => '@count sati',
- ),
+ ],
// Hungarian is not imported, so it should assume the same text as
// English, but it will always pick the plural form as per the built-in
// logic, so only index -1 is relevant with the plural value.
- 'hu' => array(
+ 'hu' => [
0 => '1 hour',
-1 => '@count hours',
- ),
- );
+ ],
+ ];
// Expected plural indexes precomputed base on the plural formulas with
// given $count value.
- $plural_tests = array(
- 'en' => array(
+ $plural_tests = [
+ 'en' => [
1 => 0,
0 => 1,
5 => 1,
123 => 1,
235 => 1,
- ),
- 'fr' => array(
+ ],
+ 'fr' => [
1 => 0,
0 => 0,
5 => 1,
123 => 1,
235 => 1,
- ),
- 'hr' => array(
+ ],
+ 'hr' => [
1 => 0,
21 => 0,
0 => 2,
@@ -117,13 +117,13 @@ class LocalePluralFormatTest extends WebTestBase {
8 => 2,
123 => 1,
235 => 2,
- ),
- 'hu' => array(
+ ],
+ 'hu' => [
1 => -1,
21 => -1,
0 => -1,
- ),
- );
+ ],
+ ];
foreach ($plural_tests as $langcode => $tests) {
foreach ($tests as $count => $expected_plural_index) {
@@ -133,14 +133,14 @@ class LocalePluralFormatTest extends WebTestBase {
// expected index as per the logic for translation lookups.
$expected_plural_index = ($count == 1) ? 0 : $expected_plural_index;
$expected_plural_string = str_replace('@count', $count, $plural_strings[$langcode][$expected_plural_index]);
- $this->assertIdentical(\Drupal::translation()->formatPlural($count, '1 hour', '@count hours', array(), array('langcode' => $langcode))->render(), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string);
+ $this->assertIdentical(\Drupal::translation()->formatPlural($count, '1 hour', '@count hours', [], ['langcode' => $langcode])->render(), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string);
// DO NOT use translation to pass translated strings into
// PluralTranslatableMarkup::createFromTranslatedString() this way. It
// is designed to be used with *already* translated text like settings
// from configuration. We use PHP translation here just because we have
// the expected result data in that format.
- $translated_string = \Drupal::translation()->translate('1 hour' . PluralTranslatableMarkup::DELIMITER . '@count hours', array(), array('langcode' => $langcode));
- $plural = PluralTranslatableMarkup::createFromTranslatedString($count, $translated_string, array(), array('langcode' => $langcode));
+ $translated_string = \Drupal::translation()->translate('1 hour' . PluralTranslatableMarkup::DELIMITER . '@count hours', [], ['langcode' => $langcode]);
+ $plural = PluralTranslatableMarkup::createFromTranslatedString($count, $translated_string, [], ['langcode' => $langcode]);
$this->assertIdentical($plural->render(), $expected_plural_string);
}
}
@@ -153,9 +153,9 @@ class LocalePluralFormatTest extends WebTestBase {
// Import some .po files with formulas to set up the environment.
// These will also add the languages to the system.
- $this->importPoFile($this->getPoFileWithSimplePlural(), array(
+ $this->importPoFile($this->getPoFileWithSimplePlural(), [
'langcode' => 'fr',
- ));
+ ]);
// Set French as the site default language.
$this->config('system.site')->set('default_langcode', 'fr')->save();
@@ -170,12 +170,12 @@ class LocalePluralFormatTest extends WebTestBase {
$this->assertText("seconde", "'Member for' text is translated.");
$path = 'admin/config/regional/translate/';
- $search = array(
+ $search = [
'langcode' => 'fr',
// Limit to only translated strings to ensure that database ordering does
// not break the test.
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm($path, $search, t('Filter'));
// Plural values for the langcode fr.
$this->assertText('@count seconde');
@@ -185,20 +185,20 @@ class LocalePluralFormatTest extends WebTestBase {
// langcode here because the language will be English by default and will
// not save our source string for performance optimization if we do not ask
// specifically for a language.
- \Drupal::translation()->formatPlural(1, '1 second', '@count seconds', array(), array('langcode' => 'fr'))->render();
- $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", array(':source' => "1 second" . LOCALE_PLURAL_DELIMITER . "@count seconds"))->fetchField();
+ \Drupal::translation()->formatPlural(1, '1 second', '@count seconds', [], ['langcode' => 'fr'])->render();
+ $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 second" . LOCALE_PLURAL_DELIMITER . "@count seconds"])->fetchField();
// Look up editing page for this plural string and check fields.
- $search = array(
+ $search = [
'string' => '1 second',
'langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Save complete translations for the string in langcode fr.
- $edit = array(
+ $edit = [
"strings[$lid][translations][0]" => '1 seconde updated',
"strings[$lid][translations][1]" => '@count secondes updated',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save translations'));
// User interface input for translating seconds should not be duplicated
@@ -218,17 +218,17 @@ class LocalePluralFormatTest extends WebTestBase {
public function testPluralEditExport() {
// Import some .po files with formulas to set up the environment.
// These will also add the languages to the system.
- $this->importPoFile($this->getPoFileWithSimplePlural(), array(
+ $this->importPoFile($this->getPoFileWithSimplePlural(), [
'langcode' => 'fr',
- ));
- $this->importPoFile($this->getPoFileWithComplexPlural(), array(
+ ]);
+ $this->importPoFile($this->getPoFileWithComplexPlural(), [
'langcode' => 'hr',
- ));
+ ]);
// Get the French translations.
- $this->drupalPostForm('admin/config/regional/translate/export', array(
+ $this->drupalPostForm('admin/config/regional/translate/export', [
'langcode' => 'fr',
- ), t('Export'));
+ ], t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# French translation of Drupal', 'Exported French translation file.');
// Ensure our imported translations exist in the file.
@@ -237,9 +237,9 @@ class LocalePluralFormatTest extends WebTestBase {
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure\"\nmsgstr[1] \"@count heures\"", 'Plural translations exported properly.');
// Get the Croatian translations.
- $this->drupalPostForm('admin/config/regional/translate/export', array(
+ $this->drupalPostForm('admin/config/regional/translate/export', [
'langcode' => 'hr',
- ), t('Export'));
+ ], t('Export'));
// Ensure we have a translation file.
$this->assertRaw('# Croatian translation of Drupal', 'Exported Croatian translation file.');
// Ensure our imported translations exist in the file.
@@ -254,9 +254,9 @@ class LocalePluralFormatTest extends WebTestBase {
// Look up editing page for this plural string and check fields.
$path = 'admin/config/regional/translate/';
- $search = array(
+ $search = [
'langcode' => 'hr',
- );
+ ];
$this->drupalPostForm($path, $search, t('Filter'));
// Labels for plural editing elements.
$this->assertText('Singular form');
@@ -270,15 +270,15 @@ class LocalePluralFormatTest extends WebTestBase {
$this->assertText('@count sati');
// Edit langcode hr translations and see if that took effect.
- $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", array(':source' => "1 hour" . LOCALE_PLURAL_DELIMITER . "@count hours"))->fetchField();
- $edit = array(
+ $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 hour" . LOCALE_PLURAL_DELIMITER . "@count hours"])->fetchField();
+ $edit = [
"strings[$lid][translations][1]" => '@count sata edited',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save translations'));
- $search = array(
+ $search = [
'langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Plural values for the langcode fr.
$this->assertText('@count heure');
@@ -286,57 +286,57 @@ class LocalePluralFormatTest extends WebTestBase {
$this->assertNoText('2. plural form');
// Edit langcode fr translations and see if that took effect.
- $edit = array(
+ $edit = [
"strings[$lid][translations][0]" => '@count heure edited',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save translations'));
// Inject a plural source string to the database. We need to use a specific
// langcode here because the language will be English by default and will
// not save our source string for performance optimization if we do not ask
// specifically for a language.
- \Drupal::translation()->formatPlural(1, '1 day', '@count days', array(), array('langcode' => 'fr'))->render();
- $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", array(':source' => "1 day" . LOCALE_PLURAL_DELIMITER . "@count days"))->fetchField();
+ \Drupal::translation()->formatPlural(1, '1 day', '@count days', [], ['langcode' => 'fr'])->render();
+ $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", [':source' => "1 day" . LOCALE_PLURAL_DELIMITER . "@count days"])->fetchField();
// Look up editing page for this plural string and check fields.
- $search = array(
+ $search = [
'string' => '1 day',
'langcode' => 'fr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Save complete translations for the string in langcode fr.
- $edit = array(
+ $edit = [
"strings[$lid][translations][0]" => '1 jour',
"strings[$lid][translations][1]" => '@count jours',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save translations'));
// Save complete translations for the string in langcode hr.
- $search = array(
+ $search = [
'string' => '1 day',
'langcode' => 'hr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
- $edit = array(
+ $edit = [
"strings[$lid][translations][0]" => '@count dan',
"strings[$lid][translations][1]" => '@count dana',
"strings[$lid][translations][2]" => '@count dana',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save translations'));
// Get the French translations.
- $this->drupalPostForm('admin/config/regional/translate/export', array(
+ $this->drupalPostForm('admin/config/regional/translate/export', [
'langcode' => 'fr',
- ), t('Export'));
+ ], t('Export'));
// Check for plural export specifically.
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure edited\"\nmsgstr[1] \"@count heures\"", 'Edited French plural translations for hours exported properly.');
$this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"1 jour\"\nmsgstr[1] \"@count jours\"", 'Added French plural translations for days exported properly.');
// Get the Croatian translations.
- $this->drupalPostForm('admin/config/regional/translate/export', array(
+ $this->drupalPostForm('admin/config/regional/translate/export', [
'langcode' => 'hr',
- ), t('Export'));
+ ], t('Export'));
// Check for plural export specifically.
$this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata edited\"\nmsgstr[2] \"@count sati\"", 'Edited Croatian plural translations exported properly.');
$this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"@count dan\"\nmsgstr[1] \"@count dana\"\nmsgstr[2] \"@count dana\"", 'Added Croatian plural translations exported properly.');
@@ -350,7 +350,7 @@ class LocalePluralFormatTest extends WebTestBase {
* @param array $options
* Additional options to pass to the translation import form.
*/
- public function importPoFile($contents, array $options = array()) {
+ public function importPoFile($contents, array $options = []) {
$name = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po';
file_put_contents($name, $contents);
$options['files[file]'] = $name;
diff --git a/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php b/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php
index 5c642f2c2cc..a4b1656655b 100644
--- a/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php
+++ b/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php
@@ -23,14 +23,14 @@ class LocaleTranslateStringTourTest extends TourTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'tour');
+ public static $modules = ['locale', 'tour'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('translate interface', 'access tour', 'administer languages'));
+ $this->adminUser = $this->drupalCreateUser(['translate interface', 'access tour', 'administer languages']);
$this->drupalLogin($this->adminUser);
}
@@ -39,7 +39,7 @@ class LocaleTranslateStringTourTest extends TourTestBase {
*/
public function testTranslateStringTourTips() {
// Add another language so there are no missing form items.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'es';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
diff --git a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php
index aad0119fa23..53f77c19fd2 100644
--- a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php
+++ b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php
@@ -20,16 +20,16 @@ class LocaleTranslationUiTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale');
+ public static $modules = ['locale'];
/**
* Enable interface translation to English.
*/
public function testEnglishTranslation() {
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
$this->drupalLogin($admin_user);
- $this->drupalPostForm('admin/config/regional/language/edit/en', array('locale_translate_english' => TRUE), t('Save language'));
+ $this->drupalPostForm('admin/config/regional/language/edit/en', ['locale_translate_english' => TRUE], t('Save language'));
$this->assertLinkByHref('/admin/config/regional/translate?langcode=en', 0, 'Enabled interface translation to English.');
}
@@ -38,9 +38,9 @@ class LocaleTranslationUiTest extends WebTestBase {
*/
public function testStringTranslation() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
// User to translate and delete string.
- $translate_user = $this->drupalCreateUser(array('translate interface', 'access administration pages'));
+ $translate_user = $this->drupalCreateUser(['translate interface', 'access administration pages']);
// Code for the language.
$langcode = 'xx';
// The English name for the language. This will be translated.
@@ -51,15 +51,15 @@ class LocaleTranslationUiTest extends WebTestBase {
// Add custom language.
$this->drupalLogin($admin_user);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Add string.
- t($name, array(), array('langcode' => $langcode))->render();
+ t($name, [], ['langcode' => $langcode])->render();
// Reset locale cache.
$this->container->get('string_translation')->reset();
$this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
@@ -68,11 +68,11 @@ class LocaleTranslationUiTest extends WebTestBase {
// Search for the name and translate it.
$this->drupalLogin($translate_user);
- $search = array(
+ $search = [
'string' => $name,
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText($name, 'Search found the string as untranslated.');
@@ -81,7 +81,7 @@ class LocaleTranslationUiTest extends WebTestBase {
$this->assertNoOption('edit-langcode', 'en', 'No way to translate the string to English.');
$this->drupalLogout();
$this->drupalLogin($admin_user);
- $this->drupalPostForm('admin/config/regional/language/edit/en', array('locale_translate_english' => TRUE), t('Save language'));
+ $this->drupalPostForm('admin/config/regional/language/edit/en', ['locale_translate_english' => TRUE], t('Save language'));
$this->drupalLogout();
$this->drupalLogin($translate_user);
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
@@ -90,55 +90,55 @@ class LocaleTranslationUiTest extends WebTestBase {
// Assume this is the only result, given the random name.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $translation,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$this->assertText(t('The strings have been saved.'), 'The strings have been saved.');
$url_bits = explode('?', $this->getUrl());
- $this->assertEqual($url_bits[0], \Drupal::url('locale.translate_page', array(), array('absolute' => TRUE)), 'Correct page redirection.');
- $search = array(
+ $this->assertEqual($url_bits[0], \Drupal::url('locale.translate_page', [], ['absolute' => TRUE]), 'Correct page redirection.');
+ $search = [
'string' => $name,
'langcode' => $langcode,
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertRaw($translation, 'Non-English translation properly saved.');
- $search = array(
+ $search = [
'string' => $name,
'langcode' => 'en',
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $translation_to_en,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
- $search = array(
+ $search = [
'string' => $name,
'langcode' => 'en',
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertRaw($translation_to_en, 'English translation properly saved.');
- $this->assertTrue($name != $translation && t($name, array(), array('langcode' => $langcode)) == $translation, 't() works for non-English.');
+ $this->assertTrue($name != $translation && t($name, [], ['langcode' => $langcode]) == $translation, 't() works for non-English.');
// Refresh the locale() cache to get fresh data from t() below. We are in
// the same HTTP request and therefore t() is not refreshed by saving the
// translation above.
$this->container->get('string_translation')->reset();
// Now we should get the proper fresh translation from t().
- $this->assertTrue($name != $translation_to_en && t($name, array(), array('langcode' => 'en')) == $translation_to_en, 't() works for English.');
- $this->assertTrue(t($name, array(), array('langcode' => LanguageInterface::LANGCODE_SYSTEM)) == $name, 't() works for LanguageInterface::LANGCODE_SYSTEM.');
+ $this->assertTrue($name != $translation_to_en && t($name, [], ['langcode' => 'en']) == $translation_to_en, 't() works for English.');
+ $this->assertTrue(t($name, [], ['langcode' => LanguageInterface::LANGCODE_SYSTEM]) == $name, 't() works for LanguageInterface::LANGCODE_SYSTEM.');
- $search = array(
+ $search = [
'string' => $name,
'langcode' => 'en',
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), 'String is translated.');
@@ -148,17 +148,17 @@ class LocaleTranslationUiTest extends WebTestBase {
$this->assertText('Enter the password that accompanies your username.');
$this->drupalLogin($translate_user);
- $search = array(
+ $search = [
'string' => 'accompanies your username',
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => 'Please enter your Llama username.',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$this->drupalLogout();
@@ -169,9 +169,9 @@ class LocaleTranslationUiTest extends WebTestBase {
$this->drupalLogin($admin_user);
$path = 'admin/config/regional/language/delete/' . $langcode;
// This a confirm form, we do not need any fields changed.
- $this->drupalPostForm($path, array(), t('Delete'));
+ $this->drupalPostForm($path, [], t('Delete'));
// We need raw here because %language and %langcode will add HTML.
- $t_args = array('%language' => $name, '%langcode' => $langcode);
+ $t_args = ['%language' => $name, '%langcode' => $langcode];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.');
// Reload to remove $name.
$this->drupalGet($path);
@@ -181,26 +181,26 @@ class LocaleTranslationUiTest extends WebTestBase {
// Delete the string.
$this->drupalLogin($translate_user);
- $search = array(
+ $search = [
'string' => $name,
'langcode' => 'en',
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Assume this is the only result, given the random name.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => '',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$this->assertRaw($name, 'The strings have been saved.');
$this->drupalLogin($translate_user);
- $search = array(
+ $search = [
'string' => $name,
'langcode' => 'en',
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), 'The translation has been removed');
}
@@ -210,7 +210,7 @@ class LocaleTranslationUiTest extends WebTestBase {
* properly created and rebuilt on deletion.
*/
public function testJavaScriptTranslation() {
- $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages'));
+ $user = $this->drupalCreateUser(['translate interface', 'administer languages', 'access administration pages']);
$this->drupalLogin($user);
$config = $this->config('locale.settings');
@@ -219,12 +219,12 @@ class LocaleTranslationUiTest extends WebTestBase {
$name = $this->randomMachineName(16);
// Add custom language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->container->get('language_manager')->reset();
@@ -234,38 +234,38 @@ class LocaleTranslationUiTest extends WebTestBase {
// {locales_source} table and translate it.
$query = db_select('locales_source', 's');
$query->addJoin('INNER', 'locales_location', 'l', 's.lid = l.lid');
- $source = $query->fields('s', array('source'))
+ $source = $query->fields('s', ['source'])
->condition('l.type', 'javascript')
->range(0, 1)
->execute()
->fetchField();
- $search = array(
+ $search = [
'string' => $source,
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Trigger JavaScript translation parsing and building.
_locale_rebuild_js($langcode);
- $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
+ $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: [];
$js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js';
- $this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file created: %file', array('%file' => $result ? $js_file : 'not found')));
+ $this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file created: %file', ['%file' => $result ? $js_file : 'not found']));
// Test JavaScript translation rebuilding.
file_unmanaged_delete($js_file);
- $this->assertTrue($result = !file_exists($js_file), SafeMarkup::format('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
+ $this->assertTrue($result = !file_exists($js_file), SafeMarkup::format('JavaScript file deleted: %file', ['%file' => $result ? $js_file : 'found']));
_locale_rebuild_js($langcode);
- $this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : 'not found')));
+ $this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file rebuilt: %file', ['%file' => $result ? $js_file : 'not found']));
}
/**
@@ -273,7 +273,7 @@ class LocaleTranslationUiTest extends WebTestBase {
*/
public function testStringValidation() {
// User to add language and strings.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'translate interface']);
$this->drupalLogin($admin_user);
$langcode = 'xx';
// The English name for the language. This will be translated.
@@ -290,30 +290,30 @@ class LocaleTranslationUiTest extends WebTestBase {
$bad_translations[$key] = "<BODY ONLOAD=alert('xss')>" . $key;
// Add custom language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Add string.
- t($name, array(), array('langcode' => $langcode))->render();
+ t($name, [], ['langcode' => $langcode])->render();
// Reset locale cache.
- $search = array(
+ $search = [
'string' => $name,
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Find the edit path.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
foreach ($bad_translations as $translation) {
- $edit = array(
+ $edit = [
$lid => $translation,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Check for a form error on the textarea.
$form_class = $this->xpath('//form[@id="locale-translate-edit-form"]//textarea/@class');
@@ -327,9 +327,9 @@ class LocaleTranslationUiTest extends WebTestBase {
*/
public function testStringSearch() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
// User to translate and delete string.
- $translate_user = $this->drupalCreateUser(array('translate interface', 'access administration pages'));
+ $translate_user = $this->drupalCreateUser(['translate interface', 'access administration pages']);
// Code for the language.
$langcode = 'xx';
@@ -340,35 +340,35 @@ class LocaleTranslationUiTest extends WebTestBase {
// Add custom language.
$this->drupalLogin($admin_user);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => 'yy',
'label' => $this->randomMachineName(16),
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Add string.
- t($name, array(), array('langcode' => $langcode))->render();
+ t($name, [], ['langcode' => $langcode])->render();
// Reset locale cache.
$this->container->get('string_translation')->reset();
$this->drupalLogout();
// Search for the name.
$this->drupalLogin($translate_user);
- $search = array(
+ $search = [
'string' => $name,
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// assertText() seems to remove the input field where $name always could be
// found, so this is not a false assert. See how assertNoText succeeds
@@ -377,21 +377,21 @@ class LocaleTranslationUiTest extends WebTestBase {
// Ensure untranslated string doesn't appear if searching on 'only
// translated strings'.
- $search = array(
+ $search = [
'string' => $name,
'langcode' => $langcode,
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), "Search didn't find the string.");
// Ensure untranslated string appears if searching on 'only untranslated
// strings'.
- $search = array(
+ $search = [
'string' => $name,
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), 'Search found the string.');
@@ -400,66 +400,66 @@ class LocaleTranslationUiTest extends WebTestBase {
// We save the lid from the path.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $translation,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Ensure translated string does appear if searching on 'only
// translated strings'.
- $search = array(
+ $search = [
'string' => $translation,
'langcode' => $langcode,
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), 'Search found the translation.');
// Ensure translated source string doesn't appear if searching on 'only
// untranslated strings'.
- $search = array(
+ $search = [
'string' => $name,
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), "Search didn't find the source string.");
// Ensure translated string doesn't appear if searching on 'only
// untranslated strings'.
- $search = array(
+ $search = [
'string' => $translation,
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), "Search didn't find the translation.");
// Ensure translated string does appear if searching on the custom language.
- $search = array(
+ $search = [
'string' => $translation,
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), 'Search found the translation.');
// Ensure translated string doesn't appear if searching in System (English).
- $search = array(
+ $search = [
'string' => $translation,
'langcode' => 'yy',
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), "Search didn't find the translation.");
// Search for a string that isn't in the system.
$unavailable_string = $this->randomMachineName(16);
- $search = array(
+ $search = [
'string' => $unavailable_string,
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText(t('No strings available.'), "Search didn't find the invalid string.");
}
@@ -468,35 +468,35 @@ class LocaleTranslationUiTest extends WebTestBase {
* Tests that only changed strings are saved customized when edited.
*/
public function testUICustomizedStrings() {
- $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages'));
+ $user = $this->drupalCreateUser(['translate interface', 'administer languages', 'access administration pages']);
$this->drupalLogin($user);
ConfigurableLanguage::createFromLangcode('de')->save();
// Create test source string.
- $string = $this->container->get('locale.storage')->createString(array(
+ $string = $this->container->get('locale.storage')->createString([
'source' => $this->randomMachineName(100),
'context' => $this->randomMachineName(20),
- ))->save();
+ ])->save();
// Create translation for new string and save it as non-customized.
- $translation = $this->container->get('locale.storage')->createTranslation(array(
+ $translation = $this->container->get('locale.storage')->createTranslation([
'lid' => $string->lid,
'language' => 'de',
'translation' => $this->randomMachineName(100),
'customized' => 0,
- ))->save();
+ ])->save();
// Reset locale cache.
$this->container->get('string_translation')->reset();
// Ensure non-customized translation string does appear if searching
// non-customized translation.
- $search = array(
+ $search = [
'string' => $string->getString(),
'langcode' => 'de',
'translation' => 'translated',
'customized' => '0',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText($translation->getString(), 'Translation is found in search result.');
@@ -504,38 +504,38 @@ class LocaleTranslationUiTest extends WebTestBase {
// Submit the translations without changing the translation.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $translation->getString(),
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Ensure unchanged translation string does appear if searching
// non-customized translation.
- $search = array(
+ $search = [
'string' => $string->getString(),
'langcode' => 'de',
'translation' => 'translated',
'customized' => '0',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText($string->getString(), 'Translation is not marked as customized.');
// Submit the translations with a new translation.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $this->randomMachineName(100),
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Ensure changed translation string does appear if searching customized
// translation.
- $search = array(
+ $search = [
'string' => $string->getString(),
'langcode' => 'de',
'translation' => 'translated',
'customized' => '1',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText($string->getString(), "Translation is marked as customized.");
}
diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php
index 85196ad7cca..b228a962de5 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateBase.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php
@@ -45,7 +45,7 @@ abstract class LocaleUpdateBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'locale_test');
+ public static $modules = ['locale', 'locale_test'];
/**
* {@inheritdoc}
@@ -85,10 +85,10 @@ abstract class LocaleUpdateBase extends WebTestBase {
* The language code of the language to add.
*/
protected function addLanguage($langcode) {
- $edit = array('predefined_langcode' => $langcode);
+ $edit = ['predefined_langcode' => $langcode];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->container->get('language_manager')->reset();
- $this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), SafeMarkup::format('Language %langcode added.', array('%langcode' => $langcode)));
+ $this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), SafeMarkup::format('Language %langcode added.', ['%langcode' => $langcode]));
}
/**
@@ -105,7 +105,7 @@ abstract class LocaleUpdateBase extends WebTestBase {
* singular strings are supported, no plurals. No double quotes are allowed
* in source and translations strings.
*/
- protected function makePoFile($path, $filename, $timestamp = NULL, array $translations = array()) {
+ protected function makePoFile($path, $filename, $timestamp = NULL, array $translations = []) {
$timestamp = $timestamp ? $timestamp : REQUEST_TIME;
$path = 'public://' . $path;
$text = '';
@@ -184,9 +184,9 @@ EOF;
$config->set('translation.default_filename', '%project-%version.%language._po')->save();
// Setting up sets of translations for the translation files.
- $translations_one = array('January' => 'Januar_1', 'February' => 'Februar_1', 'March' => 'Marz_1');
- $translations_two = array('February' => 'Februar_2', 'March' => 'Marz_2', 'April' => 'April_2');
- $translations_three = array('April' => 'April_3', 'May' => 'Mai_3', 'June' => 'Juni_3');
+ $translations_one = ['January' => 'Januar_1', 'February' => 'Februar_1', 'March' => 'Marz_1'];
+ $translations_two = ['February' => 'Februar_2', 'March' => 'Marz_2', 'April' => 'April_2'];
+ $translations_three = ['April' => 'April_3', 'May' => 'Mai_3', 'June' => 'Juni_3'];
// Add a number of files to the local file system to serve as remote
// translation server and match the project definitions set in
@@ -212,71 +212,71 @@ EOF;
// Add non customized translations to the database.
$langcode = 'de';
$context = '';
- $non_customized_translations = array(
+ $non_customized_translations = [
'March' => 'Marz',
'June' => 'Juni',
- );
+ ];
foreach ($non_customized_translations as $source => $translation) {
- $string = $this->container->get('locale.storage')->createString(array(
+ $string = $this->container->get('locale.storage')->createString([
'source' => $source,
'context' => $context,
- ))
+ ])
->save();
- $this->container->get('locale.storage')->createTranslation(array(
+ $this->container->get('locale.storage')->createTranslation([
'lid' => $string->getId(),
'language' => $langcode,
'translation' => $translation,
'customized' => LOCALE_NOT_CUSTOMIZED,
- ))->save();
+ ])->save();
}
// Add customized translations to the database.
- $customized_translations = array(
+ $customized_translations = [
'January' => 'Januar_customized',
'February' => 'Februar_customized',
'May' => 'Mai_customized',
- );
+ ];
foreach ($customized_translations as $source => $translation) {
- $string = $this->container->get('locale.storage')->createString(array(
+ $string = $this->container->get('locale.storage')->createString([
'source' => $source,
'context' => $context,
- ))
+ ])
->save();
- $this->container->get('locale.storage')->createTranslation(array(
+ $this->container->get('locale.storage')->createTranslation([
'lid' => $string->getId(),
'language' => $langcode,
'translation' => $translation,
'customized' => LOCALE_CUSTOMIZED,
- ))->save();
+ ])->save();
}
// Add a state of current translations in locale_files.
- $default = array(
+ $default = [
'langcode' => $langcode,
'uri' => '',
'timestamp' => $this->timestampMedium,
'last_checked' => $this->timestampMedium,
- );
- $data[] = array(
+ ];
+ $data[] = [
'project' => 'contrib_module_one',
'filename' => 'contrib_module_one-8.x-1.1.de._po',
'version' => '8.x-1.1',
- );
- $data[] = array(
+ ];
+ $data[] = [
'project' => 'contrib_module_two',
'filename' => 'contrib_module_two-8.x-2.0-beta4.de._po',
'version' => '8.x-2.0-beta4',
- );
- $data[] = array(
+ ];
+ $data[] = [
'project' => 'contrib_module_three',
'filename' => 'contrib_module_three-8.x-1.0.de._po',
'version' => '8.x-1.0',
- );
- $data[] = array(
+ ];
+ $data[] = [
'project' => 'custom_module_one',
'filename' => 'custom_module_one.de.po',
'version' => '',
- );
+ ];
foreach ($data as $file) {
$file = array_merge($default, $file);
db_insert('locale_file')->fields($file)->execute();
@@ -297,9 +297,9 @@ EOF;
* (optional) A message to display with the assertion.
*/
protected function assertTranslation($source, $translation, $langcode, $message = '') {
- $db_translation = db_query('SELECT translation FROM {locales_target} lt INNER JOIN {locales_source} ls ON ls.lid = lt.lid WHERE ls.source = :source AND lt.language = :langcode', array(':source' => $source, ':langcode' => $langcode))->fetchField();
+ $db_translation = db_query('SELECT translation FROM {locales_target} lt INNER JOIN {locales_source} ls ON ls.lid = lt.lid WHERE ls.source = :source AND lt.language = :langcode', [':source' => $source, ':langcode' => $langcode])->fetchField();
$db_translation = $db_translation == FALSE ? '' : $db_translation;
- $this->assertEqual($translation, $db_translation, $message ? $message : format_string('Correct translation of %source (%language)', array('%source' => $source, '%language' => $langcode)));
+ $this->assertEqual($translation, $db_translation, $message ? $message : format_string('Correct translation of %source (%language)', ['%source' => $source, '%language' => $langcode]));
}
}
diff --git a/core/modules/locale/src/Tests/LocaleUpdateCronTest.php b/core/modules/locale/src/Tests/LocaleUpdateCronTest.php
index 569b818bd2a..78a14ecac85 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateCronTest.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateCronTest.php
@@ -9,14 +9,14 @@ namespace Drupal\locale\Tests;
*/
class LocaleUpdateCronTest extends LocaleUpdateBase {
- protected $batchOutput = array();
+ protected $batchOutput = [];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface']);
$this->drupalLogin($admin_user);
$this->addLanguage('de');
}
@@ -35,7 +35,7 @@ class LocaleUpdateCronTest extends LocaleUpdateBase {
// Update translations using batch to ensure a clean test starting point.
$this->drupalGet('admin/reports/translations/check');
- $this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
+ $this->drupalPostForm('admin/reports/translations', [], t('Update translations'));
// Store translation status for comparison.
$initial_history = locale_translation_get_file_history();
@@ -48,16 +48,16 @@ class LocaleUpdateCronTest extends LocaleUpdateBase {
// Prepare for test: Simulate that the file has not been checked for a long
// time. Set the last_check timestamp to zero.
$query = db_update('locale_file');
- $query->fields(array('last_checked' => 0));
+ $query->fields(['last_checked' => 0]);
$query->condition('project', 'contrib_module_two');
$query->condition('langcode', 'de');
$query->execute();
// Test: Disable cron update and verify that no tasks are added to the
// queue.
- $edit = array(
+ $edit = [
'update_interval_days' => 0,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Execute locale cron tasks to add tasks to the queue.
@@ -70,9 +70,9 @@ class LocaleUpdateCronTest extends LocaleUpdateBase {
// Test: Enable cron update and check if update tasks are added to the
// queue.
// Set cron update to Weekly.
- $edit = array(
+ $edit = [
'update_interval_days' => 7,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Execute locale cron tasks to add tasks to the queue.
diff --git a/core/modules/locale/src/Tests/LocaleUpdateDevelopmentReleaseTest.php b/core/modules/locale/src/Tests/LocaleUpdateDevelopmentReleaseTest.php
index cfd2446fc7f..3d7970bb984 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateDevelopmentReleaseTest.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateDevelopmentReleaseTest.php
@@ -11,14 +11,14 @@ use Drupal\simpletest\WebTestBase;
*/
class LocaleUpdateDevelopmentReleaseTest extends WebTestBase {
- public static $modules = array('locale', 'locale_test_development_release');
+ public static $modules = ['locale', 'locale_test_development_release'];
protected function setUp() {
parent::setUp();
module_load_include('compare.inc', 'locale');
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer languages', 'access administration pages', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer languages', 'access administration pages', 'translate interface']);
$this->drupalLogin($admin_user);
- $this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language'));
+ $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'hu'], t('Add language'));
}
public function testLocaleUpdateDevelopmentRelease() {
diff --git a/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php b/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php
index 45740acbc31..32928b1d8bf 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php
@@ -17,14 +17,14 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
*
* @var array
*/
- public static $modules = array('locale_test_translate');
+ public static $modules = ['locale_test_translate'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface']);
$this->drupalLogin($admin_user);
}
@@ -41,7 +41,7 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
$this->assertNoText(t('Translation update status'), 'No status message');
$this->drupalGet('admin/reports/translations');
- $this->assertRaw(t('No translatable languages available. <a href=":add_language">Add a language</a> first.', array(':add_language' => \Drupal::url('entity.configurable_language.collection'))), 'Language message');
+ $this->assertRaw(t('No translatable languages available. <a href=":add_language">Add a language</a> first.', [':add_language' => \Drupal::url('entity.configurable_language.collection')]), 'Language message');
// Add German language.
$this->addLanguage('de');
@@ -66,9 +66,9 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
// Check if updates are available for German.
$this->drupalGet('admin/reports/status');
$this->assertText(t('Translation update status'), 'Status message');
- $this->assertRaw(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), ':updates' => \Drupal::url('locale.translate_status'))), 'Updates available message');
+ $this->assertRaw(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => \Drupal::url('locale.translate_status')]), 'Updates available message');
$this->drupalGet('admin/reports/translations');
- $this->assertText(t('Updates for: @modules', array('@modules' => 'Locale test translate')), 'Translations available');
+ $this->assertText(t('Updates for: @modules', ['@modules' => 'Locale test translate']), 'Translations available');
// Set locale_test_translate module to have a dev release and no
// translation found.
@@ -80,13 +80,13 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
// Check if no updates were found.
$this->drupalGet('admin/reports/status');
$this->assertText(t('Translation update status'), 'Status message');
- $this->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), ':updates' => \Drupal::url('locale.translate_status'))), 'Missing translations message');
+ $this->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => \Drupal::url('locale.translate_status')]), 'Missing translations message');
$this->drupalGet('admin/reports/translations');
$this->assertText(t('Missing translations for one project'), 'No translations found');
$release_details = new FormattableMarkup('@module (@version). @info', [
'@module' => 'Locale test translate',
'@version' => '1.3-dev',
- '@info' => t('File not found at %local_path', array('%local_path' => 'core/modules/locale/tests/test.de.po'))
+ '@info' => t('File not found at %local_path', ['%local_path' => 'core/modules/locale/tests/test.de.po'])
]);
$this->assertRaw($release_details->__toString(), 'Release details');
@@ -100,7 +100,7 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
// Check if Drupal core is not translated.
$this->drupalGet('admin/reports/translations');
$this->assertText(t('Missing translations for 2 projects'), 'No translations found');
- $this->assertText(t('@module (@version).', array('@module' => t('Drupal core'), '@version' => '8.1.1')), 'Release details');
+ $this->assertText(t('@module (@version).', ['@module' => t('Drupal core'), '@version' => '8.1.1']), 'Release details');
// Override Drupal core translation status as 'translations available'.
$status = locale_translation_get_status();
@@ -111,8 +111,8 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
// Check if translations are available for Drupal core.
$this->drupalGet('admin/reports/translations');
- $this->assertText(t('Updates for: @project', array('@project' => t('Drupal core'))), 'Translations found');
- $this->assertText(SafeMarkup::format('@module (@date)', array('@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date'))), 'Core translation update');
+ $this->assertText(t('Updates for: @project', ['@project' => t('Drupal core')]), 'Translations found');
+ $this->assertText(SafeMarkup::format('@module (@date)', ['@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date')]), 'Core translation update');
$update_button = $this->xpath('//input[@type="submit"][@value="' . t('Update translations') . '"]');
$this->assertTrue($update_button, 'Update translations button');
}
diff --git a/core/modules/locale/src/Tests/LocaleUpdateTest.php b/core/modules/locale/src/Tests/LocaleUpdateTest.php
index 999f01bb0e1..957419b7215 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateTest.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateTest.php
@@ -18,7 +18,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
parent::setUp();
module_load_include('compare.inc', 'locale');
module_load_include('fetch.inc', 'locale');
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface']);
$this->drupalLogin($admin_user);
// We use German as test language. This language must match the translation
// file that come with the locale_test module (test.de.po) and can therefore
@@ -42,7 +42,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$projects = locale_translation_project_list();
$this->assertFalse(isset($projects['locale_test_translate']), 'Hidden module not found');
$this->assertEqual($projects['locale_test']['info']['interface translation server pattern'], 'core/modules/locale/test/test.%language.po', 'Interface translation parameter found in project info.');
- $this->assertEqual($projects['locale_test']['name'], 'locale_test', format_string('%key found in project info.', array('%key' => 'interface translation project')));
+ $this->assertEqual($projects['locale_test']['name'], 'locale_test', format_string('%key found in project info.', ['%key' => 'interface translation project']));
}
/**
@@ -74,9 +74,9 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$config->set('translation.default_filename', '%project-%version.%language._po')->save();
// Set the test conditions.
- $edit = array(
+ $edit = [
'use_source' => LOCALE_TRANSLATION_USE_SOURCE_LOCAL,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Get status of translation sources at local file system.
@@ -90,9 +90,9 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertEqual($result['custom_module_one']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of custom_module_one found');
// Set the test conditions.
- $edit = array(
+ $edit = [
'use_source' => LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Get status of translation sources at both local and remote locations.
@@ -124,10 +124,10 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$config->set('translation.default_filename', '%project-%version.%language._po');
// Set the update conditions for this test.
- $edit = array(
+ $edit = [
'use_source' => LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL,
'overwrite' => LOCALE_TRANSLATION_OVERWRITE_ALL,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Get the translation status.
@@ -140,7 +140,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertText('Contributed module two (' . format_date($this->timestampNew, 'html_date') . ')', 'Updates for Contrib module two');
// Execute the translation update.
- $this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
+ $this->drupalPostForm('admin/reports/translations', [], t('Update translations'));
// Check if the translation has been updated, using the status cache.
$status = locale_translation_get_status();
@@ -161,13 +161,13 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_three is not updated');
// Check whether existing translations have (not) been overwritten.
- $this->assertEqual(t('January', array(), array('langcode' => 'de')), 'Januar_1', 'Translation of January');
- $this->assertEqual(t('February', array(), array('langcode' => 'de')), 'Februar_2', 'Translation of February');
- $this->assertEqual(t('March', array(), array('langcode' => 'de')), 'Marz_2', 'Translation of March');
- $this->assertEqual(t('April', array(), array('langcode' => 'de')), 'April_2', 'Translation of April');
- $this->assertEqual(t('May', array(), array('langcode' => 'de')), 'Mai_customized', 'Translation of May');
- $this->assertEqual(t('June', array(), array('langcode' => 'de')), 'Juni', 'Translation of June');
- $this->assertEqual(t('Monday', array(), array('langcode' => 'de')), 'Montag', 'Translation of Monday');
+ $this->assertEqual(t('January', [], ['langcode' => 'de']), 'Januar_1', 'Translation of January');
+ $this->assertEqual(t('February', [], ['langcode' => 'de']), 'Februar_2', 'Translation of February');
+ $this->assertEqual(t('March', [], ['langcode' => 'de']), 'Marz_2', 'Translation of March');
+ $this->assertEqual(t('April', [], ['langcode' => 'de']), 'April_2', 'Translation of April');
+ $this->assertEqual(t('May', [], ['langcode' => 'de']), 'Mai_customized', 'Translation of May');
+ $this->assertEqual(t('June', [], ['langcode' => 'de']), 'Juni', 'Translation of June');
+ $this->assertEqual(t('Monday', [], ['langcode' => 'de']), 'Montag', 'Translation of Monday');
}
/**
@@ -186,15 +186,15 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$config->set('translation.default_filename', '%project-%version.%language._po');
// Set the update conditions for this test.
- $edit = array(
+ $edit = [
'use_source' => LOCALE_TRANSLATION_USE_SOURCE_LOCAL,
'overwrite' => LOCALE_TRANSLATION_OVERWRITE_ALL,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Execute the translation update.
$this->drupalGet('admin/reports/translations/check');
- $this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
+ $this->drupalPostForm('admin/reports/translations', [], t('Update translations'));
// Check if the translation has been updated, using the status cache.
$status = locale_translation_get_status();
@@ -215,13 +215,13 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_three is not updated');
// Check whether existing translations have (not) been overwritten.
- $this->assertEqual(t('January', array(), array('langcode' => 'de')), 'Januar_customized', 'Translation of January');
- $this->assertEqual(t('February', array(), array('langcode' => 'de')), 'Februar_2', 'Translation of February');
- $this->assertEqual(t('March', array(), array('langcode' => 'de')), 'Marz_2', 'Translation of March');
- $this->assertEqual(t('April', array(), array('langcode' => 'de')), 'April_2', 'Translation of April');
- $this->assertEqual(t('May', array(), array('langcode' => 'de')), 'Mai_customized', 'Translation of May');
- $this->assertEqual(t('June', array(), array('langcode' => 'de')), 'Juni', 'Translation of June');
- $this->assertEqual(t('Monday', array(), array('langcode' => 'de')), 'Montag', 'Translation of Monday');
+ $this->assertEqual(t('January', [], ['langcode' => 'de']), 'Januar_customized', 'Translation of January');
+ $this->assertEqual(t('February', [], ['langcode' => 'de']), 'Februar_2', 'Translation of February');
+ $this->assertEqual(t('March', [], ['langcode' => 'de']), 'Marz_2', 'Translation of March');
+ $this->assertEqual(t('April', [], ['langcode' => 'de']), 'April_2', 'Translation of April');
+ $this->assertEqual(t('May', [], ['langcode' => 'de']), 'Mai_customized', 'Translation of May');
+ $this->assertEqual(t('June', [], ['langcode' => 'de']), 'Juni', 'Translation of June');
+ $this->assertEqual(t('Monday', [], ['langcode' => 'de']), 'Montag', 'Translation of Monday');
}
/**
@@ -240,24 +240,24 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$config->set('translation.default_filename', '%project-%version.%language._po');
// Set the test conditions.
- $edit = array(
+ $edit = [
'use_source' => LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL,
'overwrite' => LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Execute translation update.
$this->drupalGet('admin/reports/translations/check');
- $this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
+ $this->drupalPostForm('admin/reports/translations', [], t('Update translations'));
// Check whether existing translations have (not) been overwritten.
- $this->assertEqual(t('January', array(), array('langcode' => 'de')), 'Januar_customized', 'Translation of January');
- $this->assertEqual(t('February', array(), array('langcode' => 'de')), 'Februar_customized', 'Translation of February');
- $this->assertEqual(t('March', array(), array('langcode' => 'de')), 'Marz_2', 'Translation of March');
- $this->assertEqual(t('April', array(), array('langcode' => 'de')), 'April_2', 'Translation of April');
- $this->assertEqual(t('May', array(), array('langcode' => 'de')), 'Mai_customized', 'Translation of May');
- $this->assertEqual(t('June', array(), array('langcode' => 'de')), 'Juni', 'Translation of June');
- $this->assertEqual(t('Monday', array(), array('langcode' => 'de')), 'Montag', 'Translation of Monday');
+ $this->assertEqual(t('January', [], ['langcode' => 'de']), 'Januar_customized', 'Translation of January');
+ $this->assertEqual(t('February', [], ['langcode' => 'de']), 'Februar_customized', 'Translation of February');
+ $this->assertEqual(t('March', [], ['langcode' => 'de']), 'Marz_2', 'Translation of March');
+ $this->assertEqual(t('April', [], ['langcode' => 'de']), 'April_2', 'Translation of April');
+ $this->assertEqual(t('May', [], ['langcode' => 'de']), 'Mai_customized', 'Translation of May');
+ $this->assertEqual(t('June', [], ['langcode' => 'de']), 'Juni', 'Translation of June');
+ $this->assertEqual(t('Monday', [], ['langcode' => 'de']), 'Montag', 'Translation of Monday');
}
/**
@@ -276,15 +276,15 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$config->set('translation.default_filename', '%project-%version.%language._po');
// Set the test conditions.
- $edit = array(
+ $edit = [
'use_source' => LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL,
'overwrite' => LOCALE_TRANSLATION_OVERWRITE_NONE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));
// Execute translation update.
$this->drupalGet('admin/reports/translations/check');
- $this->drupalPostForm('admin/reports/translations', array(), t('Update translations'));
+ $this->drupalPostForm('admin/reports/translations', [], t('Update translations'));
// Check whether existing translations have (not) been overwritten.
$this->assertTranslation('January', 'Januar_customized', 'de');
@@ -307,21 +307,21 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertTranslation('Tuesday', '', 'de');
// Enable a module.
- $edit = array(
+ $edit = [
'modules[locale_test_translate][enable]' => 'locale_test_translate',
- );
+ ];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Check if translations have been imported.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
- array('%number' => 7, '%update' => 0, '%delete' => 0)), 'One translation file imported.');
+ ['%number' => 7, '%update' => 0, '%delete' => 0]), 'One translation file imported.');
$this->assertTranslation('Tuesday', 'Dienstag', 'de');
- $edit = array(
+ $edit = [
'uninstall[locale_test_translate]' => 1,
- );
+ ];
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
- $this->drupalPostForm(NULL, array(), t('Uninstall'));
+ $this->drupalPostForm(NULL, [], t('Uninstall'));
// Check if the file data is removed from the database.
$history = locale_translation_get_file_history();
@@ -342,9 +342,9 @@ class LocaleUpdateTest extends LocaleUpdateBase {
\Drupal::state()->set('locale.test_system_info_alter', TRUE);
// Enable a module.
- $edit = array(
+ $edit = [
'modules[locale_test_translate][enable]' => 'locale_test_translate',
- );
+ ];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Check if there is no Dutch translation yet.
@@ -352,14 +352,14 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertTranslation('Tuesday', 'Dienstag', 'de');
// Add a language.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'nl',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Check if the right number of translations are added.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
- array('%number' => 8, '%update' => 0, '%delete' => 0)), 'One language added.');
+ ['%number' => 8, '%update' => 0, '%delete' => 0]), 'One language added.');
$this->assertTranslation('Extraday', 'extra dag', 'nl');
// Check if the language data is added to the database.
@@ -367,7 +367,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertTrue($result, 'Files added to file history');
// Remove a language.
- $this->drupalPostForm('admin/config/regional/language/delete/nl', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/nl', [], t('Delete'));
// Check if the language data is removed from the database.
$result = db_query("SELECT project FROM {locale_file} WHERE langcode='nl'")->fetchField();
@@ -386,21 +386,21 @@ class LocaleUpdateTest extends LocaleUpdateBase {
\Drupal::state()->set('locale.test_system_info_alter', TRUE);
// Enable a module.
- $edit = array(
+ $edit = [
'modules[locale_test_translate][enable]' => 'locale_test_translate',
- );
+ ];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Create a custom language with language code 'xx' and a random
// name.
$langcode = 'xx';
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Ensure the translation file is automatically imported when the language
@@ -409,31 +409,31 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->assertText(t('One translation string was skipped because of disallowed or malformed HTML'), 'Language file automatically imported.');
// Ensure the strings were successfully imported.
- $search = array(
+ $search = [
'string' => 'lundi',
'langcode' => $langcode,
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available.'), 'String successfully imported.');
// Ensure the multiline string was imported.
- $search = array(
+ $search = [
'string' => 'Source string for multiline translation',
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText('Multiline translation string to make sure that import works with it.', 'String successfully imported.');
// Ensure 'Allowed HTML source string' was imported but the translation for
// 'Another allowed HTML source string' was not because it contains invalid
// HTML.
- $search = array(
+ $search = [
'string' => 'HTML source string',
'langcode' => $langcode,
'translation' => 'all',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertText('Allowed HTML source string', 'String successfully imported.');
$this->assertNoText('Another allowed HTML source string', 'String with disallowed translation not imported.');
diff --git a/core/modules/locale/src/TranslationString.php b/core/modules/locale/src/TranslationString.php
index 917e874335b..63f4543cb5d 100644
--- a/core/modules/locale/src/TranslationString.php
+++ b/core/modules/locale/src/TranslationString.php
@@ -42,7 +42,7 @@ class TranslationString extends StringBase {
/**
* {@inheritdoc}
*/
- public function __construct($values = array()) {
+ public function __construct($values = []) {
parent::__construct($values);
if (!isset($this->isNew)) {
// We mark the string as not new if it is a complete translation.
diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.module b/core/modules/locale/tests/modules/locale_test/locale_test.module
index b59dfee8bf9..89ba2bae9a3 100644
--- a/core/modules/locale/tests/modules/locale_test/locale_test.module
+++ b/core/modules/locale/tests/modules/locale_test/locale_test.module
@@ -57,10 +57,10 @@ function locale_test_locale_translation_projects_alter(&$projects) {
$remote_url = $url . PublicStream::basePath() . '/remote/';
// Completely replace the project data with a set of test projects.
- $projects = array(
- 'contrib_module_one' => array(
+ $projects = [
+ 'contrib_module_one' => [
'name' => 'contrib_module_one',
- 'info' => array(
+ 'info' => [
'name' => 'Contributed module one',
'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po',
'package' => 'Other',
@@ -68,14 +68,14 @@ function locale_test_locale_translation_projects_alter(&$projects) {
'project' => 'contrib_module_one',
'datestamp' => '1344471537',
'_info_file_ctime' => 1348767306,
- ),
+ ],
'datestamp' => '1344471537',
'project_type' => 'module',
'project_status' => TRUE,
- ),
- 'contrib_module_two' => array(
+ ],
+ 'contrib_module_two' => [
'name' => 'contrib_module_two',
- 'info' => array(
+ 'info' => [
'name' => 'Contributed module two',
'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po',
'package' => 'Other',
@@ -83,14 +83,14 @@ function locale_test_locale_translation_projects_alter(&$projects) {
'project' => 'contrib_module_two',
'datestamp' => '1344471537',
'_info_file_ctime' => 1348767306,
- ),
+ ],
'datestamp' => '1344471537',
'project_type' => 'module',
'project_status' => TRUE,
- ),
- 'contrib_module_three' => array(
+ ],
+ 'contrib_module_three' => [
'name' => 'contrib_module_three',
- 'info' => array(
+ 'info' => [
'name' => 'Contributed module three',
'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po',
'package' => 'Other',
@@ -98,14 +98,14 @@ function locale_test_locale_translation_projects_alter(&$projects) {
'project' => 'contrib_module_three',
'datestamp' => '1344471537',
'_info_file_ctime' => 1348767306,
- ),
+ ],
'datestamp' => '1344471537',
'project_type' => 'module',
'project_status' => TRUE,
- ),
- 'locale_test' => array(
+ ],
+ 'locale_test' => [
'name' => 'locale_test',
- 'info' => array(
+ 'info' => [
'name' => 'Locale test',
'interface translation project' => 'locale_test',
'interface translation server pattern' => 'core/modules/locale/tests/test.%language.po',
@@ -114,14 +114,14 @@ function locale_test_locale_translation_projects_alter(&$projects) {
'project' => 'locale_test',
'_info_file_ctime' => 1348767306,
'datestamp' => 0,
- ),
+ ],
'datestamp' => 0,
'project_type' => 'module',
'project_status' => TRUE,
- ),
- 'custom_module_one' => array(
+ ],
+ 'custom_module_one' => [
'name' => 'custom_module_one',
- 'info' => array(
+ 'info' => [
'name' => 'Custom module one',
'interface translation project' => 'custom_module_one',
'interface translation server pattern' => 'translations://custom_module_one.%language.po',
@@ -130,12 +130,12 @@ function locale_test_locale_translation_projects_alter(&$projects) {
'project' => 'custom_module_one',
'_info_file_ctime' => 1348767306,
'datestamp' => 0,
- ),
+ ],
'datestamp' => 0,
'project_type' => 'module',
'project_status' => TRUE,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/locale/tests/modules/locale_test_development_release/locale_test_development_release.module b/core/modules/locale/tests/modules/locale_test_development_release/locale_test_development_release.module
index deedf075b1d..248d9e472ed 100644
--- a/core/modules/locale/tests/modules/locale_test_development_release/locale_test_development_release.module
+++ b/core/modules/locale/tests/modules/locale_test_development_release/locale_test_development_release.module
@@ -27,14 +27,14 @@ function locale_test_development_release_system_info_alter(&$info, Extension $fi
function locale_test_development_release_locale_translation_projects_alter(&$projects) {
$projects['contrib'] = [
'name' => 'contrib',
- 'info' => array(
+ 'info' => [
'name' => 'Contributed module',
'package' => 'Other',
'version' => '12.x-10.4-unstable11+14-dev',
'project' => 'contrib_module',
'datestamp' => '0',
'_info_file_ctime' => 1442933959,
- ),
+ ],
'datestamp' => '0',
'project_type' => 'module',
'project_status' => TRUE,
diff --git a/core/modules/locale/tests/src/Functional/LocaleContentTest.php b/core/modules/locale/tests/src/Functional/LocaleContentTest.php
index d4561b91a7b..e7955503a43 100644
--- a/core/modules/locale/tests/src/Functional/LocaleContentTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleContentTest.php
@@ -19,14 +19,14 @@ class LocaleContentTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'locale');
+ public static $modules = ['node', 'locale'];
/**
* Verifies that machine name fields are always LTR.
*/
public function testMachineNameLTR() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'administer content types', 'access administration pages', 'administer site configuration']);
// Log in as admin.
$this->drupalLogin($admin_user);
@@ -36,13 +36,13 @@ class LocaleContentTest extends BrowserTestBase {
$this->assertFieldByXpath('//input[@name="type" and @dir="ltr"]', NULL, 'The machine name field is LTR when no additional language is configured.');
// Install the Arabic language (which is RTL) and configure as the default.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'ar';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
- $edit = array(
+ $edit = [
'site_default_language' => 'ar',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
// Verify that the machine name field is still LTR for a new content type.
@@ -58,9 +58,9 @@ class LocaleContentTest extends BrowserTestBase {
$type2 = $this->drupalCreateContentType();
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'administer content types', 'access administration pages']);
// User to create a node.
- $web_user = $this->drupalCreateUser(array("create {$type1->id()} content", "create {$type2->id()} content", "edit any {$type2->id()} content"));
+ $web_user = $this->drupalCreateUser(["create {$type1->id()} content", "create {$type2->id()} content", "edit any {$type2->id()} content"]);
// Add custom language.
$this->drupalLogin($admin_user);
@@ -68,22 +68,22 @@ class LocaleContentTest extends BrowserTestBase {
$langcode = 'xx';
// The English name for the language.
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Set the content type to use multilingual support.
$this->drupalGet("admin/structure/types/manage/{$type2->id()}");
$this->assertText(t('Language settings'), 'Multilingual support widget present on content type configuration form.');
- $edit = array(
+ $edit = [
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm("admin/structure/types/manage/{$type2->id()}", $edit, t('Save content type'));
- $this->assertRaw(t('The content type %type has been updated.', array('%type' => $type2->label())));
+ $this->assertRaw(t('The content type %type has been updated.', ['%type' => $type2->label()]));
$this->drupalLogout();
\Drupal::languageManager()->reset();
@@ -103,26 +103,26 @@ class LocaleContentTest extends BrowserTestBase {
// Create a node.
$node_title = $this->randomMachineName();
$node_body = $this->randomMachineName();
- $edit = array(
+ $edit = [
'type' => $type2->id(),
'title' => $node_title,
- 'body' => array(array('value' => $node_body)),
+ 'body' => [['value' => $node_body]],
'langcode' => $langcode,
- );
+ ];
$node = $this->drupalCreateNode($edit);
// Edit the content and ensure correct language is selected.
$path = 'node/' . $node->id() . '/edit';
$this->drupalGet($path);
$this->assertRaw('<option value="' . $langcode . '" selected="selected">' . $name . '</option>', 'Correct language selected.');
// Ensure we can change the node language.
- $edit = array(
+ $edit = [
'langcode[0][value]' => 'en',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save'));
- $this->assertText(t('@title has been updated.', array('@title' => $node_title)));
+ $this->assertText(t('@title has been updated.', ['@title' => $node_title]));
// Verify that the creation message contains a link to a node.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/' . $node->id()));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/' . $node->id()]);
$this->assert(isset($view_link), 'The message area contains the link to the edited node');
$this->drupalLogout();
@@ -135,44 +135,44 @@ class LocaleContentTest extends BrowserTestBase {
$type = $this->drupalCreateContentType();
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'administer content types', 'access administration pages']);
// User to create a node.
- $web_user = $this->drupalCreateUser(array("create {$type->id()} content", "edit own {$type->id()} content"));
+ $web_user = $this->drupalCreateUser(["create {$type->id()} content", "edit own {$type->id()} content"]);
// Log in as admin.
$this->drupalLogin($admin_user);
// Install Arabic language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'ar';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Install Spanish language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'es';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
\Drupal::languageManager()->reset();
// Set the content type to use multilingual support.
$this->drupalGet("admin/structure/types/manage/{$type->id()}");
- $edit = array(
+ $edit = [
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm("admin/structure/types/manage/{$type->id()}", $edit, t('Save content type'));
- $this->assertRaw(t('The content type %type has been updated.', array('%type' => $type->label())));
+ $this->assertRaw(t('The content type %type has been updated.', ['%type' => $type->label()]));
$this->drupalLogout();
// Log in as web user to add new node.
$this->drupalLogin($web_user);
// Create three nodes: English, Arabic and Spanish.
- $nodes = array();
- foreach (array('en', 'es', 'ar') as $langcode) {
- $nodes[$langcode] = $this->drupalCreateNode(array(
+ $nodes = [];
+ foreach (['en', 'es', 'ar'] as $langcode) {
+ $nodes[$langcode] = $this->drupalCreateNode([
'langcode' => $langcode,
'type' => $type->id(),
'promote' => NodeInterface::PROMOTED,
- ));
+ ]);
}
// Check if English node does not have lang tag.
diff --git a/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php b/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php
index 2eeb2242fb2..5f3e5f7e800 100644
--- a/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php
@@ -17,7 +17,7 @@ class LocaleLocaleLookupTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('locale', 'locale_test');
+ public static $modules = ['locale', 'locale_test'];
/**
* {@inheritdoc}
@@ -37,7 +37,7 @@ class LocaleLocaleLookupTest extends BrowserTestBase {
*/
public function testCircularDependency() {
// Ensure that we can enable early_translation_test on a non-english site.
- $this->drupalPostForm('admin/modules', array('modules[early_translation_test][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[early_translation_test][enable]' => TRUE], t('Install'));
$this->assertResponse(200);
}
@@ -48,7 +48,7 @@ class LocaleLocaleLookupTest extends BrowserTestBase {
$this->drupalGet('');
// Ensure state of fallback languages persisted by
// locale_test_language_fallback_candidates_locale_lookup_alter() is empty.
- $this->assertEqual(\Drupal::state()->get('locale.test_language_fallback_candidates_locale_lookup_alter_candidates'), array());
+ $this->assertEqual(\Drupal::state()->get('locale.test_language_fallback_candidates_locale_lookup_alter_candidates'), []);
// Make sure there is enough information provided for alter hooks.
$context = \Drupal::state()->get('locale.test_language_fallback_candidates_locale_lookup_alter_context');
$this->assertEqual($context['langcode'], 'fr');
diff --git a/core/modules/locale/tests/src/Functional/LocalePathTest.php b/core/modules/locale/tests/src/Functional/LocalePathTest.php
index fd263203a7e..16cc26865e1 100644
--- a/core/modules/locale/tests/src/Functional/LocalePathTest.php
+++ b/core/modules/locale/tests/src/Functional/LocalePathTest.php
@@ -18,7 +18,7 @@ class LocalePathTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'locale', 'path', 'views');
+ public static $modules = ['node', 'locale', 'path', 'views'];
/**
* {@inheritdoc}
@@ -26,7 +26,7 @@ class LocalePathTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->config('system.site')->set('page.front', '/node')->save();
}
@@ -35,7 +35,7 @@ class LocalePathTest extends BrowserTestBase {
*/
public function testPathLanguageConfiguration() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'create page content', 'administer url aliases', 'create url aliases', 'access administration pages', 'access content overview'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'create page content', 'administer url aliases', 'create url aliases', 'access administration pages', 'access content overview']);
// Add custom language.
$this->drupalLogin($admin_user);
@@ -45,16 +45,16 @@ class LocalePathTest extends BrowserTestBase {
$name = $this->randomMachineName(16);
// The domain prefix.
$prefix = $langcode;
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Set path prefix.
- $edit = array("prefix[$langcode]" => $prefix);
+ $edit = ["prefix[$langcode]" => $prefix];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
// Check that the "xx" front page is readily available because path prefix
@@ -63,25 +63,25 @@ class LocalePathTest extends BrowserTestBase {
$this->assertText(t('Welcome to Drupal'), 'The "xx" front page is readibly available.');
// Create a node.
- $node = $this->drupalCreateNode(array('type' => 'page'));
+ $node = $this->drupalCreateNode(['type' => 'page']);
// Create a path alias in default language (English).
$path = 'admin/config/search/path/add';
$english_path = $this->randomMachineName(8);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node->id(),
'alias' => '/' . $english_path,
'langcode' => 'en',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save'));
// Create a path alias in new custom language.
$custom_language_path = $this->randomMachineName(8);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node->id(),
'alias' => '/' . $custom_language_path,
'langcode' => $langcode,
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save'));
// Confirm English language path alias works.
@@ -96,11 +96,11 @@ class LocalePathTest extends BrowserTestBase {
$custom_path = $this->randomMachineName(8);
// Check priority of language for alias by source path.
- $edit = array(
+ $edit = [
'source' => '/node/' . $node->id(),
'alias' => '/' . $custom_path,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- );
+ ];
$this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']);
$lookup_path = $this->container->get('path.alias_manager')->getAliasByPath('/node/' . $node->id(), 'en');
$this->assertEqual('/' . $english_path, $lookup_path, 'English language alias has priority.');
@@ -110,32 +110,32 @@ class LocalePathTest extends BrowserTestBase {
$this->container->get('path.alias_storage')->delete($edit);
// Create language nodes to check priority of aliases.
- $first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => 'en'));
- $second_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
+ $first_node = $this->drupalCreateNode(['type' => 'page', 'promote' => 1, 'langcode' => 'en']);
+ $second_node = $this->drupalCreateNode(['type' => 'page', 'promote' => 1, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]);
// Assign a custom path alias to the first node with the English language.
- $edit = array(
+ $edit = [
'source' => '/node/' . $first_node->id(),
'alias' => '/' . $custom_path,
'langcode' => $first_node->language()->getId(),
- );
+ ];
$this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']);
// Assign a custom path alias to second node with
// LanguageInterface::LANGCODE_NOT_SPECIFIED.
- $edit = array(
+ $edit = [
'source' => '/node/' . $second_node->id(),
'alias' => '/' . $custom_path,
'langcode' => $second_node->language()->getId(),
- );
+ ];
$this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']);
// Test that both node titles link to our path alias.
$this->drupalGet('admin/content');
$custom_path_url = Url::fromUserInput('/' . $custom_path)->toString();
- $elements = $this->xpath('//a[@href=:href and normalize-space(text())=:title]', array(':href' => $custom_path_url, ':title' => $first_node->label()));
+ $elements = $this->xpath('//a[@href=:href and normalize-space(text())=:title]', [':href' => $custom_path_url, ':title' => $first_node->label()]);
$this->assertTrue(!empty($elements), 'First node links to the path alias.');
- $elements = $this->xpath('//a[@href=:href and normalize-space(text())=:title]', array(':href' => $custom_path_url, ':title' => $second_node->label()));
+ $elements = $this->xpath('//a[@href=:href and normalize-space(text())=:title]', [':href' => $custom_path_url, ':title' => $second_node->label()]);
$this->assertTrue(!empty($elements), 'Second node links to the path alias.');
// Confirm that the custom path leads to the first node.
diff --git a/core/modules/locale/tests/src/Functional/LocaleStringTest.php b/core/modules/locale/tests/src/Functional/LocaleStringTest.php
index 082515fbb63..601b7388e61 100644
--- a/core/modules/locale/tests/src/Functional/LocaleStringTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleStringTest.php
@@ -17,7 +17,7 @@ class LocaleStringTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('locale');
+ public static $modules = ['locale'];
/**
* The locale storage.
@@ -34,7 +34,7 @@ class LocaleStringTest extends BrowserTestBase {
// Add a default locale storage for all these tests.
$this->storage = $this->container->get('locale.storage');
// Create two languages: Spanish and German.
- foreach (array('es', 'de') as $langcode) {
+ foreach (['es', 'de'] as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)->save();
}
}
@@ -46,51 +46,51 @@ class LocaleStringTest extends BrowserTestBase {
// Create source string.
$source = $this->buildSourceString();
$source->save();
- $this->assertTrue($source->lid, format_string('Successfully created string %string', array('%string' => $source->source)));
+ $this->assertTrue($source->lid, format_string('Successfully created string %string', ['%string' => $source->source]));
// Load strings by lid and source.
- $string1 = $this->storage->findString(array('lid' => $source->lid));
+ $string1 = $this->storage->findString(['lid' => $source->lid]);
$this->assertEqual($source, $string1, 'Successfully retrieved string by identifier.');
- $string2 = $this->storage->findString(array('source' => $source->source, 'context' => $source->context));
+ $string2 = $this->storage->findString(['source' => $source->source, 'context' => $source->context]);
$this->assertEqual($source, $string2, 'Successfully retrieved string by source and context.');
- $string3 = $this->storage->findString(array('source' => $source->source, 'context' => ''));
+ $string3 = $this->storage->findString(['source' => $source->source, 'context' => '']);
$this->assertFalse($string3, 'Cannot retrieve string with wrong context.');
// Check version handling and updating.
$this->assertEqual($source->version, 'none', 'String originally created without version.');
- $string = $this->storage->findTranslation(array('lid' => $source->lid));
+ $string = $this->storage->findTranslation(['lid' => $source->lid]);
$this->assertEqual($string->version, \Drupal::VERSION, 'Checked and updated string version to Drupal version.');
// Create translation and find it by lid and source.
$langcode = 'es';
$translation = $this->createTranslation($source, $langcode);
$this->assertEqual($translation->customized, LOCALE_NOT_CUSTOMIZED, 'Translation created as not customized by default.');
- $string1 = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid));
+ $string1 = $this->storage->findTranslation(['language' => $langcode, 'lid' => $source->lid]);
$this->assertEqual($string1->translation, $translation->translation, 'Successfully loaded translation by string identifier.');
- $string2 = $this->storage->findTranslation(array('language' => $langcode, 'source' => $source->source, 'context' => $source->context));
+ $string2 = $this->storage->findTranslation(['language' => $langcode, 'source' => $source->source, 'context' => $source->context]);
$this->assertEqual($string2->translation, $translation->translation, 'Successfully loaded translation by source and context.');
$translation
->setCustomized()
->save();
- $translation = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid));
+ $translation = $this->storage->findTranslation(['language' => $langcode, 'lid' => $source->lid]);
$this->assertEqual($translation->customized, LOCALE_CUSTOMIZED, 'Translation successfully marked as customized.');
// Delete translation.
$translation->delete();
- $deleted = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid));
+ $deleted = $this->storage->findTranslation(['language' => $langcode, 'lid' => $source->lid]);
$this->assertFalse(isset($deleted->translation), 'Successfully deleted translation string.');
// Create some translations and then delete string and all of its
// translations.
$lid = $source->lid;
$this->createAllTranslations($source);
- $search = $this->storage->getTranslations(array('lid' => $source->lid));
+ $search = $this->storage->getTranslations(['lid' => $source->lid]);
$this->assertEqual(count($search), 3, 'Created and retrieved all translations for our source string.');
$source->delete();
- $string = $this->storage->findString(array('lid' => $lid));
+ $string = $this->storage->findString(['lid' => $lid]);
$this->assertFalse($string, 'Successfully deleted source string.');
- $deleted = $search = $this->storage->getTranslations(array('lid' => $lid));
+ $deleted = $search = $this->storage->getTranslations(['lid' => $lid]);
$this->assertFalse($deleted, 'Successfully deleted all translation strings.');
// Tests that locations of different types and arbitrary lengths can be
@@ -102,7 +102,7 @@ class LocaleStringTest extends BrowserTestBase {
$source_string->addLocation('path', $location = $this->randomString(300));
$source_string->save();
- $rows = db_query('SELECT * FROM {locales_location} WHERE sid = :sid', array(':sid' => $source_string->lid))->fetchAllAssoc('type');
+ $rows = db_query('SELECT * FROM {locales_location} WHERE sid = :sid', [':sid' => $source_string->lid])->fetchAllAssoc('type');
$this->assertEqual(count($rows), 4, '4 source locations have been persisted.');
$this->assertEqual($rows['path']->name, substr($location, 0, 255), 'Too long location has been limited to 255 characters.');
}
@@ -117,50 +117,50 @@ class LocaleStringTest extends BrowserTestBase {
// Source 2 will have all translations, customized.
// Source 3 will have no translations.
$prefix = $this->randomMachineName(100);
- $source1 = $this->buildSourceString(array('source' => $prefix . $this->randomMachineName(100)))->save();
- $source2 = $this->buildSourceString(array('source' => $prefix . $this->randomMachineName(100)))->save();
+ $source1 = $this->buildSourceString(['source' => $prefix . $this->randomMachineName(100)])->save();
+ $source2 = $this->buildSourceString(['source' => $prefix . $this->randomMachineName(100)])->save();
$source3 = $this->buildSourceString()->save();
// Load all source strings.
- $strings = $this->storage->getStrings(array());
+ $strings = $this->storage->getStrings([]);
$this->assertEqual(count($strings), 3, 'Found 3 source strings in the database.');
// Load all source strings matching a given string.
- $filter_options['filters'] = array('source' => $prefix);
- $strings = $this->storage->getStrings(array(), $filter_options);
+ $filter_options['filters'] = ['source' => $prefix];
+ $strings = $this->storage->getStrings([], $filter_options);
$this->assertEqual(count($strings), 2, 'Found 2 strings using some string filter.');
// Not customized translations.
$translate1 = $this->createAllTranslations($source1);
// Customized translations.
- $this->createAllTranslations($source2, array('customized' => LOCALE_CUSTOMIZED));
+ $this->createAllTranslations($source2, ['customized' => LOCALE_CUSTOMIZED]);
// Try quick search function with different field combinations.
$langcode = 'es';
- $found = $this->storage->findTranslation(array('language' => $langcode, 'source' => $source1->source, 'context' => $source1->context));
+ $found = $this->storage->findTranslation(['language' => $langcode, 'source' => $source1->source, 'context' => $source1->context]);
$this->assertTrue($found && isset($found->language) && isset($found->translation) && !$found->isNew(), 'Translation found searching by source and context.');
$this->assertEqual($found->translation, $translate1[$langcode]->translation, 'Found the right translation.');
// Now try a translation not found.
- $found = $this->storage->findTranslation(array('language' => $langcode, 'source' => $source3->source, 'context' => $source3->context));
+ $found = $this->storage->findTranslation(['language' => $langcode, 'source' => $source3->source, 'context' => $source3->context]);
$this->assertTrue($found && $found->lid == $source3->lid && !isset($found->translation) && $found->isNew(), 'Translation not found but source string found.');
// Load all translations. For next queries we'll be loading only translated
// strings.
- $translations = $this->storage->getTranslations(array('translated' => TRUE));
+ $translations = $this->storage->getTranslations(['translated' => TRUE]);
$this->assertEqual(count($translations), 2 * $language_count, 'Created and retrieved all translations for source strings.');
// Load all customized translations.
- $translations = $this->storage->getTranslations(array('customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE));
+ $translations = $this->storage->getTranslations(['customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE]);
$this->assertEqual(count($translations), $language_count, 'Retrieved all customized translations for source strings.');
// Load all Spanish customized translations.
- $translations = $this->storage->getTranslations(array('language' => 'es', 'customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE));
+ $translations = $this->storage->getTranslations(['language' => 'es', 'customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE]);
$this->assertEqual(count($translations), 1, 'Found only Spanish and customized translations.');
// Load all source strings without translation (1).
- $translations = $this->storage->getStrings(array('translated' => FALSE));
+ $translations = $this->storage->getStrings(['translated' => FALSE]);
$this->assertEqual(count($translations), 1, 'Found 1 source string without translations.');
// Load Spanish translations using string filter.
- $filter_options['filters'] = array('source' => $prefix);
- $translations = $this->storage->getTranslations(array('language' => 'es'), $filter_options);
+ $filter_options['filters'] = ['source' => $prefix];
+ $translations = $this->storage->getTranslations(['language' => 'es'], $filter_options);
$this->assertEqual(count($translations), 2, 'Found 2 translations using some string filter.');
}
@@ -171,18 +171,18 @@ class LocaleStringTest extends BrowserTestBase {
* @return \Drupal\locale\StringInterface
* A locale string.
*/
- public function buildSourceString($values = array()) {
- return $this->storage->createString($values += array(
+ public function buildSourceString($values = []) {
+ return $this->storage->createString($values += [
'source' => $this->randomMachineName(100),
'context' => $this->randomMachineName(20),
- ));
+ ]);
}
/**
* Creates translations for source string and all languages.
*/
- public function createAllTranslations($source, $values = array()) {
- $list = array();
+ public function createAllTranslations($source, $values = []) {
+ $list = [];
/* @var $language_manager \Drupal\Core\Language\LanguageManagerInterface */
$language_manager = $this->container->get('language_manager');
foreach ($language_manager->getLanguages() as $language) {
@@ -194,12 +194,12 @@ class LocaleStringTest extends BrowserTestBase {
/**
* Creates single translation for source string.
*/
- public function createTranslation($source, $langcode, $values = array()) {
- return $this->storage->createTranslation($values + array(
+ public function createTranslation($source, $langcode, $values = []) {
+ return $this->storage->createTranslation($values + [
'lid' => $source->lid,
'language' => $langcode,
'translation' => $this->randomMachineName(100),
- ))->save();
+ ])->save();
}
}
diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
index 4b1eb0a6402..7efb73aad6b 100644
--- a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
@@ -17,7 +17,7 @@ class LocaleTranslatedSchemaDefinitionTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('language', 'locale', 'node');
+ public static $modules = ['language', 'locale', 'node'];
/**
* {@inheritdoc}
@@ -40,15 +40,15 @@ class LocaleTranslatedSchemaDefinitionTest extends BrowserTestBase {
/** @var \Drupal\locale\StringDatabaseStorage $stringStorage */
$stringStorage = \Drupal::service('locale.storage');
- $source = $stringStorage->createString(array(
+ $source = $stringStorage->createString([
'source' => 'Revision ID',
- ))->save();
+ ])->save();
- $stringStorage->createTranslation(array(
+ $stringStorage->createTranslation([
'lid' => $source->lid,
'language' => 'fr',
'translation' => 'Translated Revision ID',
- ))->save();
+ ])->save();
// Ensure that the field is translated when access through the API.
$this->assertEqual('Translated Revision ID', \Drupal::entityManager()->getBaseFieldDefinitions('node')['vid']->getLabel());
@@ -62,10 +62,10 @@ class LocaleTranslatedSchemaDefinitionTest extends BrowserTestBase {
*/
function testTranslatedUpdate() {
// Visit the update page to collect any strings that may be translatable.
- $user = $this->drupalCreateUser(array('administer software updates'));
+ $user = $this->drupalCreateUser(['administer software updates']);
$this->drupalLogin($user);
$update_url = $GLOBALS['base_url'] . '/update.php';
- $this->drupalGet($update_url, array('external' => TRUE));
+ $this->drupalGet($update_url, ['external' => TRUE]);
/** @var \Drupal\locale\StringDatabaseStorage $stringStorage */
$stringStorage = \Drupal::service('locale.storage');
@@ -73,17 +73,17 @@ class LocaleTranslatedSchemaDefinitionTest extends BrowserTestBase {
// Translate all source strings found.
foreach ($sources as $source) {
- $stringStorage->createTranslation(array(
+ $stringStorage->createTranslation([
'lid' => $source->lid,
'language' => 'fr',
'translation' => $this->randomMachineName(100),
- ))->save();
+ ])->save();
}
// Ensure that there are no updates just due to translations. Check for
// markup and a link instead of specific text because text may be
// translated.
- $this->drupalGet($update_url . '/selection', array('external' => TRUE));
+ $this->drupalGet($update_url . '/selection', ['external' => TRUE]);
$this->assertRaw('messages--status', 'No pending updates.');
$this->assertNoLinkByHref('fr/update.php/run', 'No link to run updates.');
}
diff --git a/core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php b/core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php
index c1ce1b78039..8389b6e9736 100644
--- a/core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php
+++ b/core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php
@@ -18,7 +18,7 @@ class LocaleConfigManagerTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'language', 'locale', 'locale_test', 'block');
+ public static $modules = ['system', 'language', 'locale', 'locale_test', 'block'];
/**
* This test creates simple config on the fly breaking schema checking.
@@ -31,8 +31,8 @@ class LocaleConfigManagerTest extends KernelTestBase {
* Tests hasTranslation().
*/
public function testHasTranslation() {
- $this->installSchema('locale', array('locales_location', 'locales_source', 'locales_target'));
- $this->installConfig(array('locale_test'));
+ $this->installSchema('locale', ['locales_location', 'locales_source', 'locales_target']);
+ $this->installConfig(['locale_test']);
$locale_config_manager = \Drupal::service('locale.config_manager');
$language = ConfigurableLanguage::createFromLangcode('de');
@@ -48,8 +48,8 @@ class LocaleConfigManagerTest extends KernelTestBase {
* Tests getStringTranslation().
*/
public function testGetStringTranslation() {
- $this->installSchema('locale', array('locales_location', 'locales_source', 'locales_target'));
- $this->installConfig(array('locale_test'));
+ $this->installSchema('locale', ['locales_location', 'locales_source', 'locales_target']);
+ $this->installConfig(['locale_test']);
$locale_config_manager = \Drupal::service('locale.config_manager');
@@ -80,7 +80,7 @@ class LocaleConfigManagerTest extends KernelTestBase {
$simple_config->set('foo', 'bar')->save();
$this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode($simple_config->getName()), 'Simple config created through the API is not treated as shipped configuration.');
- $block = Block::create(array(
+ $block = Block::create([
'id' => 'test_default_config',
'theme' => 'classy',
'status' => TRUE,
@@ -94,7 +94,7 @@ class LocaleConfigManagerTest extends KernelTestBase {
'primary' => TRUE,
'secondary' => TRUE,
],
- ));
+ ]);
$block->save();
// Install the theme after creating the block as installing the theme will
diff --git a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php
index a53c3cf8124..e7a13fc713c 100644
--- a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php
+++ b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php
@@ -124,7 +124,7 @@ class LocaleConfigSubscriberForeignTest extends LocaleConfigSubscriberTest {
$config_name = 'locale_test.translation';
ConfigurableLanguage::createFromLangcode('en')->save();
// Adding a language on the UI would normally call updateConfigTranslations.
- $this->localeConfigManager->updateConfigTranslations(array($config_name), array('en'));
+ $this->localeConfigManager->updateConfigTranslations([$config_name], ['en']);
$this->assertConfigOverride($config_name, 'test', 'English test', 'en');
$this->configFactory->getEditable('locale.settings')->set('translate_english', TRUE)->save();
diff --git a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php
index 013a9ea2174..3a12efdf247 100644
--- a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php
+++ b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php
@@ -182,7 +182,7 @@ class LocaleConfigSubscriberTest extends KernelTestBase {
* The language code.
*/
protected function setUpNoTranslation($config_name, $key, $source, $langcode) {
- $this->localeConfigManager->updateConfigTranslations(array($config_name), array($langcode));
+ $this->localeConfigManager->updateConfigTranslations([$config_name], [$langcode]);
$this->assertNoConfigOverride($config_name, $key, $source, $langcode);
$this->assertNoTranslation($config_name, $langcode);
}
@@ -222,7 +222,7 @@ class LocaleConfigSubscriberTest extends KernelTestBase {
->save();
$this->configFactory->reset($config_name);
$this->localeConfigManager->reset();
- $this->localeConfigManager->updateConfigTranslations(array($config_name), array($langcode));
+ $this->localeConfigManager->updateConfigTranslations([$config_name], [$langcode]);
if ($is_active) {
$this->assertActiveConfig($config_name, $key, $translation, $langcode);
@@ -291,7 +291,7 @@ class LocaleConfigSubscriberTest extends KernelTestBase {
->setString($translation)
->save();
$this->localeConfigManager->reset();
- $this->localeConfigManager->updateConfigTranslations(array($config_name), array($langcode));
+ $this->localeConfigManager->updateConfigTranslations([$config_name], [$langcode]);
$this->configFactory->reset($config_name);
if ($is_active) {
@@ -356,7 +356,7 @@ class LocaleConfigSubscriberTest extends KernelTestBase {
->getStringTranslation($config_name, $langcode, $source_value, '')
->delete();
$this->localeConfigManager->reset();
- $this->localeConfigManager->updateConfigTranslations(array($config_name), array($langcode));
+ $this->localeConfigManager->updateConfigTranslations([$config_name], [$langcode]);
$this->configFactory->reset($config_name);
$this->assertNoConfigOverride($config_name, $key, $source_value, $langcode);
diff --git a/core/modules/locale/tests/src/Kernel/Migrate/MigrateLocaleConfigsTest.php b/core/modules/locale/tests/src/Kernel/Migrate/MigrateLocaleConfigsTest.php
index 6216f78e494..b4449184a32 100644
--- a/core/modules/locale/tests/src/Kernel/Migrate/MigrateLocaleConfigsTest.php
+++ b/core/modules/locale/tests/src/Kernel/Migrate/MigrateLocaleConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateLocaleConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('locale', 'language');
+ public static $modules = ['locale', 'language'];
/**
* {@inheritdoc}
diff --git a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
index 28487462348..cbdd6deabb5 100644
--- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
+++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
@@ -76,9 +76,9 @@ class LocaleLookupTest extends UnitTestCase {
$this->user = $this->getMock('Drupal\Core\Session\AccountInterface');
$this->user->expects($this->any())
->method('getRoles')
- ->will($this->returnValue(array('anonymous')));
+ ->will($this->returnValue(['anonymous']));
- $this->configFactory = $this->getConfigFactoryStub(array('locale.settings' => array('cache_strings' => FALSE)));
+ $this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => FALSE]]);
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->requestStack = new RequestStack();
@@ -94,15 +94,15 @@ class LocaleLookupTest extends UnitTestCase {
* @covers ::resolveCacheMiss
*/
public function testResolveCacheMissWithoutFallback() {
- $args = array(
+ $args = [
'language' => 'en',
'source' => 'test',
'context' => 'irrelevant',
- );
+ ];
- $result = (object) array(
+ $result = (object) [
'translation' => 'test',
- );
+ ];
$this->cache->expects($this->once())
->method('get')
@@ -114,8 +114,8 @@ class LocaleLookupTest extends UnitTestCase {
->will($this->returnValue($result));
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
- ->setConstructorArgs(array('en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack))
- ->setMethods(array('persist'))
+ ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
+ ->setMethods(['persist'])
->getMock();
$locale_lookup->expects($this->never())
->method('persist');
@@ -133,46 +133,46 @@ class LocaleLookupTest extends UnitTestCase {
*/
public function testResolveCacheMissWithFallback($langcode, $string, $context, $expected) {
// These are fake words!
- $translations = array(
- 'en' => array(
+ $translations = [
+ 'en' => [
'test' => 'test',
'fake' => 'fake',
'missing pl' => 'missing pl',
'missing cs' => 'missing cs',
'missing both' => 'missing both',
- ),
- 'pl' => array(
+ ],
+ 'pl' => [
'test' => 'test po polsku',
'fake' => 'ściema',
'missing cs' => 'zaginiony czech',
- ),
- 'cs' => array(
+ ],
+ 'cs' => [
'test' => 'test v české',
'fake' => 'falešný',
'missing pl' => 'chybějící pl',
- ),
- );
+ ],
+ ];
$this->storage->expects($this->any())
->method('findTranslation')
->will($this->returnCallback(function ($argument) use ($translations) {
if (isset($translations[$argument['language']][$argument['source']])) {
- return (object) array('translation' => $translations[$argument['language']][$argument['source']]);
+ return (object) ['translation' => $translations[$argument['language']][$argument['source']]];
}
return TRUE;
}));
$this->languageManager->expects($this->any())
->method('getFallbackCandidates')
- ->will($this->returnCallback(function (array $context = array()) {
+ ->will($this->returnCallback(function (array $context = []) {
switch ($context['langcode']) {
case 'pl':
- return array('cs', 'en');
+ return ['cs', 'en'];
case 'cs':
- return array('en');
+ return ['en'];
default:
- return array();
+ return [];
}
}));
@@ -188,20 +188,20 @@ class LocaleLookupTest extends UnitTestCase {
* Provides test data for testResolveCacheMissWithFallback().
*/
public function resolveCacheMissWithFallbackProvider() {
- return array(
- array('cs', 'test', 'irrelevant', 'test v české'),
- array('cs', 'fake', 'irrelevant', 'falešný'),
- array('cs', 'missing pl', 'irrelevant', 'chybějící pl'),
- array('cs', 'missing cs', 'irrelevant', 'missing cs'),
- array('cs', 'missing both', 'irrelevant', 'missing both'),
+ return [
+ ['cs', 'test', 'irrelevant', 'test v české'],
+ ['cs', 'fake', 'irrelevant', 'falešný'],
+ ['cs', 'missing pl', 'irrelevant', 'chybějící pl'],
+ ['cs', 'missing cs', 'irrelevant', 'missing cs'],
+ ['cs', 'missing both', 'irrelevant', 'missing both'],
// Testing PL with fallback to cs, en.
- array('pl', 'test', 'irrelevant', 'test po polsku'),
- array('pl', 'fake', 'irrelevant', 'ściema'),
- array('pl', 'missing pl', 'irrelevant', 'chybějící pl'),
- array('pl', 'missing cs', 'irrelevant', 'zaginiony czech'),
- array('pl', 'missing both', 'irrelevant', 'missing both'),
- );
+ ['pl', 'test', 'irrelevant', 'test po polsku'],
+ ['pl', 'fake', 'irrelevant', 'ściema'],
+ ['pl', 'missing pl', 'irrelevant', 'chybějící pl'],
+ ['pl', 'missing cs', 'irrelevant', 'zaginiony czech'],
+ ['pl', 'missing both', 'irrelevant', 'missing both'],
+ ];
}
/**
@@ -210,25 +210,25 @@ class LocaleLookupTest extends UnitTestCase {
* @covers ::resolveCacheMiss
*/
public function testResolveCacheMissWithPersist() {
- $args = array(
+ $args = [
'language' => 'en',
'source' => 'test',
'context' => 'irrelevant',
- );
+ ];
- $result = (object) array(
+ $result = (object) [
'translation' => 'test',
- );
+ ];
$this->storage->expects($this->once())
->method('findTranslation')
->with($this->equalTo($args))
->will($this->returnValue($result));
- $this->configFactory = $this->getConfigFactoryStub(array('locale.settings' => array('cache_strings' => TRUE)));
+ $this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => TRUE]]);
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
- ->setConstructorArgs(array('en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack))
- ->setMethods(array('persist'))
+ ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
+ ->setMethods(['persist'])
->getMock();
$locale_lookup->expects($this->once())
->method('persist');
@@ -257,8 +257,8 @@ class LocaleLookupTest extends UnitTestCase {
$this->requestStack->push($request);
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
- ->setConstructorArgs(array('en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack))
- ->setMethods(array('persist'))
+ ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
+ ->setMethods(['persist'])
->getMock();
$locale_lookup->expects($this->never())
->method('persist');
diff --git a/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php b/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php
index b6e4b59747a..fced5cd66d5 100644
--- a/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php
+++ b/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php
@@ -15,9 +15,9 @@ class LocaleLocalTasksTest extends LocalTaskIntegrationTestBase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->directoryList = array(
+ $this->directoryList = [
'locale' => 'core/modules/locale',
- );
+ ];
parent::setUp();
}
@@ -27,9 +27,9 @@ class LocaleLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getLocalePageRoutes
*/
public function testLocalePageLocalTasks($route) {
- $tasks = array(
- 0 => array('locale.translate_page', 'locale.translate_import', 'locale.translate_export', 'locale.settings'),
- );
+ $tasks = [
+ 0 => ['locale.translate_page', 'locale.translate_import', 'locale.translate_export', 'locale.settings'],
+ ];
$this->assertLocalTasks($route, $tasks);
}
@@ -37,12 +37,12 @@ class LocaleLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getLocalePageRoutes() {
- return array(
- array('locale.translate_page'),
- array('locale.translate_import'),
- array('locale.translate_export'),
- array('locale.settings'),
- );
+ return [
+ ['locale.translate_page'],
+ ['locale.translate_import'],
+ ['locale.translate_export'],
+ ['locale.settings'],
+ ];
}
}
diff --git a/core/modules/menu_link_content/menu_link_content.module b/core/modules/menu_link_content/menu_link_content.module
index 98357c6cd50..0e02ba948b5 100644
--- a/core/modules/menu_link_content/menu_link_content.module
+++ b/core/modules/menu_link_content/menu_link_content.module
@@ -18,10 +18,10 @@ function menu_link_content_help($route_name, RouteMatchInterface $route_match) {
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Custom Menu Links module allows users to create menu links. These links can be translated if multiple languages are used for the site.');
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
- $output .= ' ' . t('It is required by the Menu UI module, which provides an interface for managing menus and menu links. For more information, see the <a href=":menu-help">Menu UI module help page</a> and the <a href=":drupal-org-help">online documentation for the Custom Menu Links module</a>.', array(':menu-help' => \Drupal::url('help.page', array('name' => 'menu_ui')), ':drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link'));
+ $output .= ' ' . t('It is required by the Menu UI module, which provides an interface for managing menus and menu links. For more information, see the <a href=":menu-help">Menu UI module help page</a> and the <a href=":drupal-org-help">online documentation for the Custom Menu Links module</a>.', [':menu-help' => \Drupal::url('help.page', ['name' => 'menu_ui']), ':drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link']);
}
else {
- $output .= ' ' . t('For more information, see the <a href=":drupal-org-help">online documentation for the Custom Menu Links module</a>. If you enable the Menu UI module, it provides an interface for managing menus and menu links.', array(':drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link'));
+ $output .= ' ' . t('For more information, see the <a href=":drupal-org-help">online documentation for the Custom Menu Links module</a>. If you enable the Menu UI module, it provides an interface for managing menus and menu links.', [':drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link']);
}
$output .= '</p>';
return $output;
@@ -33,7 +33,7 @@ function menu_link_content_help($route_name, RouteMatchInterface $route_match) {
*/
function menu_link_content_menu_delete(MenuInterface $menu) {
$storage = \Drupal::entityManager()->getStorage('menu_link_content');
- $menu_links = $storage->loadByProperties(array('menu_name' => $menu->id()));
+ $menu_links = $storage->loadByProperties(['menu_name' => $menu->id()]);
$storage->delete($menu_links);
}
diff --git a/core/modules/menu_link_content/src/Controller/MenuController.php b/core/modules/menu_link_content/src/Controller/MenuController.php
index 6aaae646cbc..be7879f983e 100644
--- a/core/modules/menu_link_content/src/Controller/MenuController.php
+++ b/core/modules/menu_link_content/src/Controller/MenuController.php
@@ -20,12 +20,12 @@ class MenuController extends ControllerBase {
* Returns the menu link creation form.
*/
public function addLink(MenuInterface $menu) {
- $menu_link = $this->entityManager()->getStorage('menu_link_content')->create(array(
+ $menu_link = $this->entityManager()->getStorage('menu_link_content')->create([
'id' => '',
'parent' => '',
'menu_name' => $menu->id(),
'bundle' => 'menu_link_content',
- ));
+ ]);
return $this->entityFormBuilder()->getForm($menu_link);
}
diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
index d23f876bea4..d53ba492659 100644
--- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
+++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
@@ -133,7 +133,7 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
* {@inheritdoc}
*/
public function getPluginDefinition() {
- $definition = array();
+ $definition = [];
$definition['class'] = 'Drupal\menu_link_content\Plugin\Menu\MenuLinkContent';
$definition['menu_name'] = $this->getMenuName();
@@ -155,7 +155,7 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
$definition['description'] = $this->getDescription();
$definition['weight'] = $this->getWeight();
$definition['id'] = $this->getPluginId();
- $definition['metadata'] = array('entity_id' => $this->id());
+ $definition['metadata'] = ['entity_id' => $this->id()];
$definition['form_class'] = '\Drupal\menu_link_content\Form\MenuLinkContentForm';
$definition['enabled'] = $this->isEnabled() ? 1 : 0;
$definition['expanded'] = $this->isExpanded() ? 1 : 0;
@@ -256,15 +256,15 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
->setRequired(TRUE)
->setTranslatable(TRUE)
->setSetting('max_length', 255)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['description'] = BaseFieldDefinition::create('string')
@@ -272,15 +272,15 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
->setDescription(t('Shown when hovering over the menu link.'))
->setTranslatable(TRUE)
->setSetting('max_length', 255)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 0,
- ));
+ ]);
$fields['menu_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Menu name'))
@@ -292,14 +292,14 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
->setLabel(t('Link'))
->setDescription(t('The location this menu link points to.'))
->setRequired(TRUE)
- ->setSettings(array(
+ ->setSettings([
'link_type' => LinkItemInterface::LINK_GENERIC,
'title' => DRUPAL_DISABLED,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'link_default',
'weight' => -2,
- ));
+ ]);
$fields['external'] = BaseFieldDefinition::create('boolean')
->setLabel(t('External'))
@@ -314,43 +314,43 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
->setLabel(t('Weight'))
->setDescription(t('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.'))
->setDefaultValue(0)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'integer',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'number',
'weight' => 20,
- ));
+ ]);
$fields['expanded'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Show as expanded'))
->setDescription(t('If selected and this menu link has children, the menu will always appear expanded.'))
->setDefaultValue(FALSE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'boolean',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
- 'settings' => array('display_label' => TRUE),
+ ])
+ ->setDisplayOptions('form', [
+ 'settings' => ['display_label' => TRUE],
'weight' => 0,
- ));
+ ]);
$fields['enabled'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Enabled'))
->setDescription(t('A flag for whether the link should be enabled in menus or hidden.'))
->setDefaultValue(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'boolean',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
- 'settings' => array('display_label' => TRUE),
+ ])
+ ->setDisplayOptions('form', [
+ 'settings' => ['display_label' => TRUE],
'weight' => -1,
- ));
+ ]);
$fields['parent'] = BaseFieldDefinition::create('string')
->setLabel(t('Parent plugin ID'))
diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php
index b4caaff467f..2b780c9e029 100644
--- a/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php
+++ b/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php
@@ -15,7 +15,7 @@ class MenuLinkContentDeleteForm extends ContentEntityDeleteForm {
*/
public function getCancelUrl() {
if ($this->moduleHandler->moduleExists('menu_ui')) {
- return new Url('entity.menu.edit_form', array('menu' => $this->entity->getMenuName()));
+ return new Url('entity.menu.edit_form', ['menu' => $this->entity->getMenuName()]);
}
return $this->entity->urlInfo();
}
@@ -31,7 +31,7 @@ class MenuLinkContentDeleteForm extends ContentEntityDeleteForm {
* {@inheritdoc}
*/
protected function getDeletionMessage() {
- return $this->t('The menu link %title has been deleted.', array('%title' => $this->entity->label()));
+ return $this->t('The menu link %title has been deleted.', ['%title' => $this->entity->label()]);
}
}
diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
index 8a708ce52b2..4bdd6b9cfe0 100644
--- a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
+++ b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
@@ -113,8 +113,8 @@ class MenuLinkContentForm extends ContentEntityForm {
$entity->parent->value = $parent;
$entity->menu_name->value = $menu_name;
- $entity->enabled->value = (!$form_state->isValueEmpty(array('enabled', 'value')));
- $entity->expanded->value = (!$form_state->isValueEmpty(array('expanded', 'value')));
+ $entity->enabled->value = (!$form_state->isValueEmpty(['enabled', 'value']));
+ $entity->expanded->value = (!$form_state->isValueEmpty(['expanded', 'value']));
return $entity;
}
@@ -131,7 +131,7 @@ class MenuLinkContentForm extends ContentEntityForm {
drupal_set_message($this->t('The menu link has been saved.'));
$form_state->setRedirect(
'entity.menu_link_content.canonical',
- array('menu_link_content' => $menu_link->id())
+ ['menu_link_content' => $menu_link->id()]
);
}
else {
diff --git a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
index fea02112165..98e8cdfcb03 100644
--- a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
+++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
@@ -21,12 +21,12 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
*
* @var array
*/
- protected static $entityIdsToLoad = array();
+ protected static $entityIdsToLoad = [];
/**
* {@inheritdoc}
*/
- protected $overrideAllowed = array(
+ protected $overrideAllowed = [
'menu_name' => 1,
'parent' => 1,
'weight' => 1,
@@ -38,7 +38,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
'route_parameters' => 1,
'url' => 1,
'options' => 1,
- );
+ ];
/**
* The menu link content entity connected to this plugin instance.
@@ -123,12 +123,12 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
static::$entityIdsToLoad[$entity_id] = $entity_id;
$entities = $storage->loadMultiple(array_values(static::$entityIdsToLoad));
$entity = isset($entities[$entity_id]) ? $entities[$entity_id] : NULL;
- static::$entityIdsToLoad = array();
+ static::$entityIdsToLoad = [];
}
if (!$entity) {
// Fallback to the loading by the UUID.
$uuid = $this->getUuid();
- $loaded_entities = $storage->loadByProperties(array('uuid' => $uuid));
+ $loaded_entities = $storage->loadByProperties(['uuid' => $uuid]);
$entity = reset($loaded_entities);
}
if (!$entity) {
diff --git a/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
index 067b13313e2..338d3ecef9c 100644
--- a/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
+++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
@@ -39,7 +39,7 @@ class MenuLink extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'menu_name' => t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."),
'mlid' => t('The menu link ID (mlid) is the integer primary key.'),
'plid' => t('The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.'),
@@ -65,7 +65,7 @@ class MenuLink extends DrupalSqlBase {
'p8' => t('The eighth mlid in the materialized path. See p1.'),
'p9' => t('The ninth mlid in the materialized path. See p1.'),
'updated' => t('Flag that indicates that this link was generated during the update from Drupal 5.'),
- );
+ ];
}
/**
diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php
index 1bdc927f7e4..c8244fe089c 100644
--- a/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php
+++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php
@@ -16,16 +16,16 @@ class MenuLinkContentFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'menu_link_content',
- );
+ ];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('administer menu'));
+ $web_user = $this->drupalCreateUser(['administer menu']);
$this->drupalLogin($web_user);
}
@@ -34,16 +34,16 @@ class MenuLinkContentFormTest extends WebTestBase {
*/
public function testMenuLinkContentForm() {
$this->drupalGet('admin/structure/menu/manage/admin/add');
- $element = $this->xpath('//select[@id = :id]/option[@selected]', array(':id' => 'edit-menu-parent'));
+ $element = $this->xpath('//select[@id = :id]/option[@selected]', [':id' => 'edit-menu-parent']);
$this->assertTrue($element, 'A default menu parent was found.');
$this->assertEqual('admin:', $element[0]['value'], '<Administration> menu is the parent.');
$this->drupalPostForm(
NULL,
- array(
+ [
'title[0][value]' => t('Front page'),
'link[0][uri]' => '<front>',
- ),
+ ],
t('Save')
);
$this->assertText(t('The menu link has been saved.'));
@@ -56,10 +56,10 @@ class MenuLinkContentFormTest extends WebTestBase {
$this->drupalGet('admin/structure/menu/manage/admin/add');
$this->drupalPostForm(
NULL,
- array(
+ [
'title[0][value]' => t('Test page'),
'link[0][uri]' => '<test>',
- ),
+ ],
t('Save')
);
$this->assertText(t('Manually entered paths should start with /, ? or #.'));
diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php
index cf802b706bb..4aeb6373530 100644
--- a/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php
+++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php
@@ -22,12 +22,12 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'language',
'content_translation',
'menu_link_content',
'menu_ui',
- );
+ ];
/**
* {@inheritdoc}
@@ -42,14 +42,14 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('administer menu'));
+ return array_merge(parent::getTranslatorPermissions(), ['administer menu']);
}
/**
* {@inheritdoc}
*/
protected function getAdministratorPermissions() {
- return array_merge(parent::getAdministratorPermissions(), array('administer themes', 'view the administration theme'));
+ return array_merge(parent::getAdministratorPermissions(), ['administer themes', 'view the administration theme']);
}
/**
@@ -81,11 +81,11 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
*/
function testTranslationLinkTheme() {
$this->drupalLogin($this->administrator);
- $entityId = $this->createEntity(array(), 'en');
+ $entityId = $this->createEntity([], 'en');
// Set up Seven as the admin theme to test.
- $this->container->get('theme_handler')->install(array('seven'));
- $edit = array();
+ $this->container->get('theme_handler')->install(['seven']);
+ $edit = [];
$edit['admin_theme'] = 'seven';
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('admin/structure/menu/item/' . $entityId . '/edit');
@@ -107,14 +107,14 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('@title [%language translation]', array(
+ $title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
diff --git a/core/modules/menu_link_content/tests/src/Functional/LinksTest.php b/core/modules/menu_link_content/tests/src/Functional/LinksTest.php
index 9047ac8839d..14aa4f2d6c2 100644
--- a/core/modules/menu_link_content/tests/src/Functional/LinksTest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/LinksTest.php
@@ -19,7 +19,7 @@ class LinksTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('router_test', 'menu_link_content');
+ public static $modules = ['router_test', 'menu_link_content'];
/**
* The menu link plugin manager.
@@ -36,11 +36,11 @@ class LinksTest extends BrowserTestBase {
$this->menuLinkManager = \Drupal::service('plugin.manager.menu.link');
- Menu::create(array(
+ Menu::create([
'id' => 'menu_test',
'label' => 'Test menu',
'description' => 'Description text',
- ))->save();
+ ])->save();
}
/**
@@ -56,47 +56,47 @@ class LinksTest extends BrowserTestBase {
// - child-1-1
// - child-1-2
// - child-2
- $base_options = array(
+ $base_options = [
'title' => 'Menu link test',
'provider' => $module,
'menu_name' => 'menu_test',
- );
+ ];
- $parent = $base_options + array(
+ $parent = $base_options + [
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent'],
- );
+ ];
$link = MenuLinkContent::create($parent);
$link->save();
$links['parent'] = $link->getPluginId();
- $child_1 = $base_options + array(
+ $child_1 = $base_options + [
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child'],
'parent' => $links['parent'],
- );
+ ];
$link = MenuLinkContent::create($child_1);
$link->save();
$links['child-1'] = $link->getPluginId();
- $child_1_1 = $base_options + array(
+ $child_1_1 = $base_options + [
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child2/child'],
'parent' => $links['child-1'],
- );
+ ];
$link = MenuLinkContent::create($child_1_1);
$link->save();
$links['child-1-1'] = $link->getPluginId();
- $child_1_2 = $base_options + array(
+ $child_1_2 = $base_options + [
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child2/child'],
'parent' => $links['child-1'],
- );
+ ];
$link = MenuLinkContent::create($child_1_2);
$link->save();
$links['child-1-2'] = $link->getPluginId();
- $child_2 = $base_options + array(
+ $child_2 = $base_options + [
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child'],
'parent' => $links['parent'],
- );
+ ];
$link = MenuLinkContent::create($child_2);
$link->save();
$links['child-2'] = $link->getPluginId();
@@ -113,7 +113,7 @@ class LinksTest extends BrowserTestBase {
$menu_link_plugin = $this->menuLinkManager->createInstance($links[$id]);
$expected_parent = isset($links[$parent]) ? $links[$parent] : '';
- $this->assertEqual($menu_link_plugin->getParent(), $expected_parent, SafeMarkup::format('Menu link %id has parent of %parent, expected %expected_parent.', array('%id' => $id, '%parent' => $menu_link_plugin->getParent(), '%expected_parent' => $expected_parent)));
+ $this->assertEqual($menu_link_plugin->getParent(), $expected_parent, SafeMarkup::format('Menu link %id has parent of %parent, expected %expected_parent.', ['%id' => $id, '%parent' => $menu_link_plugin->getParent(), '%expected_parent' => $expected_parent]));
}
}
@@ -121,18 +121,18 @@ class LinksTest extends BrowserTestBase {
* Assert that a link entity's created timestamp is set.
*/
public function testCreateLink() {
- $options = array(
+ $options = [
'menu_name' => 'menu_test',
'bundle' => 'menu_link_content',
'link' => [['uri' => 'internal:/']],
- );
+ ];
$link = MenuLinkContent::create($options);
$link->save();
// Make sure the changed timestamp is set.
$this->assertEqual($link->getChangedTime(), REQUEST_TIME, 'Creating a menu link sets the "changed" timestamp.');
- $options = array(
+ $options = [
'title' => 'Test Link',
- );
+ ];
$link->link->options = $options;
$link->changed->value = 0;
$link->save();
@@ -147,32 +147,32 @@ class LinksTest extends BrowserTestBase {
// Check the initial hierarchy.
$links = $this->createLinkHierarchy($module);
- $expected_hierarchy = array(
+ $expected_hierarchy = [
'parent' => '',
'child-1' => 'parent',
'child-1-1' => 'child-1',
'child-1-2' => 'child-1',
'child-2' => 'parent',
- );
+ ];
$this->assertMenuLinkParents($links, $expected_hierarchy);
// Start over, and move child-1 under child-2, and check that all the
// children of child-1 have been moved too.
$links = $this->createLinkHierarchy($module);
/* @var \Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin */
- $this->menuLinkManager->updateDefinition($links['child-1'], array('parent' => $links['child-2']));
+ $this->menuLinkManager->updateDefinition($links['child-1'], ['parent' => $links['child-2']]);
// Verify that the entity was updated too.
$menu_link_plugin = $this->menuLinkManager->createInstance($links['child-1']);
$entity = \Drupal::entityManager()->loadEntityByUuid('menu_link_content', $menu_link_plugin->getDerivativeId());
$this->assertEqual($entity->getParentId(), $links['child-2']);
- $expected_hierarchy = array(
+ $expected_hierarchy = [
'parent' => '',
'child-1' => 'child-2',
'child-1-1' => 'child-1',
'child-1-2' => 'child-1',
'child-2' => 'parent',
- );
+ ];
$this->assertMenuLinkParents($links, $expected_hierarchy);
// Start over, and delete child-1, and check that the children of child-1
@@ -180,12 +180,12 @@ class LinksTest extends BrowserTestBase {
$links = $this->createLinkHierarchy($module);
$this->menuLinkManager->removeDefinition($links['child-1']);
- $expected_hierarchy = array(
+ $expected_hierarchy = [
'parent' => FALSE,
'child-1-1' => 'parent',
'child-1-2' => 'parent',
'child-2' => 'parent',
- );
+ ];
$this->assertMenuLinkParents($links, $expected_hierarchy);
// Try changing the parent at the entity level.
@@ -194,12 +194,12 @@ class LinksTest extends BrowserTestBase {
$entity->parent->value = '';
$entity->save();
- $expected_hierarchy = array(
+ $expected_hierarchy = [
'parent' => '',
'child-1-1' => 'parent',
'child-1-2' => '',
'child-2' => 'parent',
- );
+ ];
$this->assertMenuLinkParents($links, $expected_hierarchy);
// @todo Figure out what makes sense to test in terms of automatic
@@ -210,7 +210,7 @@ class LinksTest extends BrowserTestBase {
* Tests uninstalling a module providing default links.
*/
public function testModuleUninstalledMenuLinks() {
- \Drupal::service('module_installer')->install(array('menu_test'));
+ \Drupal::service('module_installer')->install(['menu_test']);
\Drupal::service('router.builder')->rebuild();
\Drupal::service('plugin.manager.menu.link')->rebuild();
$menu_links = $this->menuLinkManager->loadLinksByRoute('menu_test.menu_test');
@@ -219,7 +219,7 @@ class LinksTest extends BrowserTestBase {
$this->assertEqual($menu_link->getPluginId(), 'menu_test');
// Uninstall the module and ensure the menu link got removed.
- \Drupal::service('module_installer')->uninstall(array('menu_test'));
+ \Drupal::service('module_installer')->uninstall(['menu_test']);
\Drupal::service('plugin.manager.menu.link')->rebuild();
$menu_links = $this->menuLinkManager->loadLinksByRoute('menu_test.menu_test');
$this->assertEqual(count($menu_links), 0);
diff --git a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php
index eea87dbabee..f1368ed43bf 100644
--- a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php
+++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php
@@ -15,7 +15,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('menu_ui', 'menu_link_content');
+ public static $modules = ['menu_ui', 'menu_link_content'];
/**
* {@inheritdoc}
diff --git a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php
index 1d757a51346..dc17ce3b396 100644
--- a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php
+++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php
@@ -19,7 +19,7 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('link', 'menu_ui', 'menu_link_content', 'node');
+ public static $modules = ['link', 'menu_ui', 'menu_link_content', 'node'];
/**
* {@inheritdoc}
diff --git a/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php b/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php
index db6c5472c27..7fb3a918f83 100644
--- a/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php
+++ b/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php
@@ -35,7 +35,7 @@ class MenuLinkTest extends MigrateSqlSourceTestBase {
'link_path' => 'admin/config/system/cron',
'router_path' => 'admin/config/system/cron',
'link_title' => 'Cron',
- 'options' => array(),
+ 'options' => [],
'module' => 'system',
'hidden' => 0,
'external' => 0,
@@ -64,7 +64,7 @@ class MenuLinkTest extends MigrateSqlSourceTestBase {
'link_path' => 'node/141',
'router_path' => 'node/%',
'link_title' => 'Node 141',
- 'options' => array(),
+ 'options' => [],
'module' => 'menu',
'hidden' => 0,
'external' => 0,
@@ -93,7 +93,7 @@ class MenuLinkTest extends MigrateSqlSourceTestBase {
'link_path' => 'node/142',
'router_path' => 'node/%',
'link_title' => 'Node 142',
- 'options' => array(),
+ 'options' => [],
'module' => 'menu',
'hidden' => 0,
'external' => 0,
@@ -121,7 +121,7 @@ class MenuLinkTest extends MigrateSqlSourceTestBase {
'link_path' => 'admin',
'router_path' => 'admin',
'link_title' => 'Test 1',
- 'options' => array('attributes' => array('title' => 'Test menu link 1')),
+ 'options' => ['attributes' => ['title' => 'Test menu link 1']],
'module' => 'menu',
'hidden' => 0,
'external' => 0,
@@ -149,7 +149,7 @@ class MenuLinkTest extends MigrateSqlSourceTestBase {
'link_path' => 'admin/modules',
'router_path' => 'admin/modules',
'link_title' => 'Test 2',
- 'options' => array('attributes' => array('title' => 'Test menu link 2')),
+ 'options' => ['attributes' => ['title' => 'Test menu link 2']],
'module' => 'menu',
'hidden' => 0,
'external' => 0,
@@ -177,7 +177,7 @@ class MenuLinkTest extends MigrateSqlSourceTestBase {
'link_path' => 'admin/build/menu-customize/navigation',
'router_path' => 'admin/build/menu-customize/%',
'link_title' => 'Navigation',
- 'options' => array(),
+ 'options' => [],
'module' => 'menu',
'hidden' => 0,
'external' => 0,
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index bb3ec23dfb4..cffccde7680 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -38,21 +38,21 @@ function menu_ui_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.menu_ui':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Menu UI module provides an interface for managing menus. A menu is a hierarchical collection of links, which can be within or external to the site, generally used for navigation. For more information, see the <a href=":menu">online documentation for the Menu UI module</a>.', array(':menu' => 'https://www.drupal.org/documentation/modules/menu/')) . '</p>';
+ $output .= '<p>' . t('The Menu UI module provides an interface for managing menus. A menu is a hierarchical collection of links, which can be within or external to the site, generally used for navigation. For more information, see the <a href=":menu">online documentation for the Menu UI module</a>.', [':menu' => 'https://www.drupal.org/documentation/modules/menu/']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing menus') . '</dt>';
- $output .= '<dd>' . t('Users with the <em>Administer menus and menu items</em> permission can add, edit, and delete custom menus on the <a href=":menu">Menus page</a>. Custom menus can be special site menus, menus of external links, or any combination of internal and external links. You may create an unlimited number of additional menus, each of which will automatically have an associated block (if you have the <a href=":block_help">Block module</a> installed). By selecting <em>Edit menu</em>, you can add, edit, or delete links for a given menu. The links listing page provides a drag-and-drop interface for controlling the order of links, and creating a hierarchy within the menu.', array(':block_help' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('help.page', array('name' => 'block')) : '#', ':menu' => \Drupal::url('entity.menu.collection'))) . '</dd>';
+ $output .= '<dd>' . t('Users with the <em>Administer menus and menu items</em> permission can add, edit, and delete custom menus on the <a href=":menu">Menus page</a>. Custom menus can be special site menus, menus of external links, or any combination of internal and external links. You may create an unlimited number of additional menus, each of which will automatically have an associated block (if you have the <a href=":block_help">Block module</a> installed). By selecting <em>Edit menu</em>, you can add, edit, or delete links for a given menu. The links listing page provides a drag-and-drop interface for controlling the order of links, and creating a hierarchy within the menu.', [':block_help' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('help.page', ['name' => 'block']) : '#', ':menu' => \Drupal::url('entity.menu.collection')]) . '</dd>';
$output .= '<dt>' . t('Displaying menus') . '</dt>';
- $output .= '<dd>' . t('If you have the Block module enabled, then each menu that you create is rendered in a block that you enable and position on the <a href=":blocks">Block layout page</a>. In some <a href=":themes">themes</a>, the main menu and possibly the secondary menu will be output automatically; you may be able to disable this behavior on the <a href=":themes">theme\'s settings page</a>.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':themes' => \Drupal::url('system.themes_page'), ':theme_settings' => \Drupal::url('system.theme_settings'))) . '</dd>';
+ $output .= '<dd>' . t('If you have the Block module enabled, then each menu that you create is rendered in a block that you enable and position on the <a href=":blocks">Block layout page</a>. In some <a href=":themes">themes</a>, the main menu and possibly the secondary menu will be output automatically; you may be able to disable this behavior on the <a href=":themes">theme\'s settings page</a>.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':themes' => \Drupal::url('system.themes_page'), ':theme_settings' => \Drupal::url('system.theme_settings')]) . '</dd>';
$output .= '</dl>';
return $output;
}
if ($route_name == 'entity.menu.add_form' && \Drupal::moduleHandler()->moduleExists('block') && \Drupal::currentUser()->hasPermission('administer blocks')) {
- return '<p>' . t('You can enable the newly-created block for this menu on the <a href=":blocks">Block layout page</a>.', array(':blocks' => \Drupal::url('block.admin_display'))) . '</p>';
+ return '<p>' . t('You can enable the newly-created block for this menu on the <a href=":blocks">Block layout page</a>.', [':blocks' => \Drupal::url('block.admin_display')]) . '</p>';
}
elseif ($route_name == 'entity.menu.collection' && \Drupal::moduleHandler()->moduleExists('block') && \Drupal::currentUser()->hasPermission('administer blocks')) {
- return '<p>' . t('Each menu has a corresponding block that is managed on the <a href=":blocks">Block layout page</a>.', array(':blocks' => \Drupal::url('block.admin_display'))) . '</p>';
+ return '<p>' . t('Each menu has a corresponding block that is managed on the <a href=":blocks">Block layout page</a>.', [':blocks' => \Drupal::url('block.admin_display')]) . '</p>';
}
}
@@ -123,9 +123,9 @@ function menu_ui_menu_delete(Menu $menu) {
function menu_ui_block_view_system_menu_block_alter(array &$build, BlockPluginInterface $block) {
if ($block->getBaseId() == 'system_menu_block') {
$menu_name = $block->getDerivativeId();
- $build['#contextual_links']['menu'] = array(
- 'route_parameters' => array('menu' => $menu_name),
- );
+ $build['#contextual_links']['menu'] = [
+ 'route_parameters' => ['menu' => $menu_name],
+ ];
}
}
@@ -152,10 +152,10 @@ function _menu_ui_node_save(NodeInterface $node, array $values) {
}
else {
// Create a new menu_link_content entity.
- $entity = MenuLinkContent::create(array(
+ $entity = MenuLinkContent::create([
'link' => ['uri' => 'entity:node/' . $node->id()],
'langcode' => $node->language()->getId(),
- ));
+ ]);
$entity->enabled->value = 1;
}
$entity->title->value = trim($values['title']);
@@ -173,7 +173,7 @@ function menu_ui_node_predelete(EntityInterface $node) {
// Delete all MenuLinkContent links that point to this node.
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
- $result = $menu_link_manager->loadLinksByRoute('entity.node.canonical', array('node' => $node->id()));
+ $result = $menu_link_manager->loadLinksByRoute('entity.node.canonical', ['node' => $node->id()]);
if (!empty($result)) {
foreach ($result as $id => $instance) {
@@ -202,7 +202,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
if ($node->id()) {
$id = FALSE;
// Give priority to the default menu
- $type_menus = $node_type->getThirdPartySetting('menu_ui', 'available_menus', array('main'));
+ $type_menus = $node_type->getThirdPartySetting('menu_ui', 'available_menus', ['main']);
if (in_array($menu_name, $type_menus)) {
$query = \Drupal::entityQuery('menu_link_content')
->condition('link.uri', 'node/' . $node->id())
@@ -227,7 +227,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
if ($id) {
$menu_link = MenuLinkContent::load($id);
$menu_link = \Drupal::service('entity.repository')->getTranslationFromContext($menu_link);
- $defaults = array(
+ $defaults = [
'entity_id' => $menu_link->id(),
'id' => $menu_link->getPluginId(),
'title' => $menu_link->getTitle(),
@@ -236,7 +236,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
'menu_name' => $menu_link->getMenuName(),
'parent' => $menu_link->getParentId(),
'weight' => $menu_link->getWeight(),
- );
+ ];
}
}
@@ -245,7 +245,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
// definition.
$field_definitions = \Drupal::entityManager()->getBaseFieldDefinitions('menu_link_content');
$max_length = $field_definitions['title']->getSetting('max_length');
- $defaults = array(
+ $defaults = [
'entity_id' => 0,
'id' => '',
'title' => '',
@@ -254,7 +254,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) {
'menu_name' => $menu_name,
'parent' => '',
'weight' => 0,
- );
+ ];
}
return $defaults;
}
@@ -276,8 +276,8 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\Core\Menu\MenuParentFormSelectorInterface $menu_parent_selector */
$menu_parent_selector = \Drupal::service('menu.parent_form_selector');
$menu_names = menu_ui_get_menus();
- $type_menus = $node_type->getThirdPartySetting('menu_ui', 'available_menus', array('main'));
- $available_menus = array();
+ $type_menus = $node_type->getThirdPartySetting('menu_ui', 'available_menus', ['main']);
+ $available_menus = [];
foreach ($type_menus as $menu) {
$available_menus[$menu] = $menu_names[$menu];
}
@@ -293,64 +293,64 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) {
return;
}
- $form['menu'] = array(
+ $form['menu'] = [
'#type' => 'details',
'#title' => t('Menu settings'),
'#access' => \Drupal::currentUser()->hasPermission('administer menu'),
'#open' => (bool) $defaults['id'],
'#group' => 'advanced',
- '#attached' => array(
- 'library' => array('menu_ui/drupal.menu_ui'),
- ),
+ '#attached' => [
+ 'library' => ['menu_ui/drupal.menu_ui'],
+ ],
'#tree' => TRUE,
'#weight' => -2,
- '#attributes' => array('class' => array('menu-link-form')),
- );
- $form['menu']['enabled'] = array(
+ '#attributes' => ['class' => ['menu-link-form']],
+ ];
+ $form['menu']['enabled'] = [
'#type' => 'checkbox',
'#title' => t('Provide a menu link'),
'#default_value' => (int) (bool) $defaults['id'],
- );
- $form['menu']['link'] = array(
+ ];
+ $form['menu']['link'] = [
'#type' => 'container',
- '#parents' => array('menu'),
- '#states' => array(
- 'invisible' => array(
- 'input[name="menu[enabled]"]' => array('checked' => FALSE),
- ),
- ),
- );
+ '#parents' => ['menu'],
+ '#states' => [
+ 'invisible' => [
+ 'input[name="menu[enabled]"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
// Populate the element with the link data.
- foreach (array('id', 'entity_id') as $key) {
- $form['menu']['link'][$key] = array('#type' => 'value', '#value' => $defaults[$key]);
+ foreach (['id', 'entity_id'] as $key) {
+ $form['menu']['link'][$key] = ['#type' => 'value', '#value' => $defaults[$key]];
}
- $form['menu']['link']['title'] = array(
+ $form['menu']['link']['title'] = [
'#type' => 'textfield',
'#title' => t('Menu link title'),
'#default_value' => $defaults['title'],
'#maxlength' => $defaults['title_max_length'],
- );
+ ];
- $form['menu']['link']['description'] = array(
+ $form['menu']['link']['description'] = [
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $defaults['description'],
'#rows' => 1,
'#description' => t('Shown when hovering over the menu link.'),
- );
+ ];
$form['menu']['link']['menu_parent'] = $parent_element;
$form['menu']['link']['menu_parent']['#title'] = t('Parent item');
$form['menu']['link']['menu_parent']['#attributes']['class'][] = 'menu-parent-select';
- $form['menu']['link']['weight'] = array(
+ $form['menu']['link']['weight'] = [
'#type' => 'number',
'#title' => t('Weight'),
'#default_value' => $defaults['weight'],
'#description' => t('Menu links with lower weights are displayed before links with higher weights.'),
- );
+ ];
foreach (array_keys($form['actions']) as $action) {
if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
@@ -401,21 +401,21 @@ function menu_ui_form_node_type_form_alter(&$form, FormStateInterface $form_stat
$menu_options = menu_ui_get_menus();
/** @var \Drupal\node\NodeTypeInterface $type */
$type = $form_state->getFormObject()->getEntity();
- $form['menu'] = array(
+ $form['menu'] = [
'#type' => 'details',
'#title' => t('Menu settings'),
- '#attached' => array(
- 'library' => array('menu_ui/drupal.menu_ui.admin'),
- ),
+ '#attached' => [
+ 'library' => ['menu_ui/drupal.menu_ui.admin'],
+ ],
'#group' => 'additional_settings',
- );
- $form['menu']['menu_options'] = array(
+ ];
+ $form['menu']['menu_options'] = [
'#type' => 'checkboxes',
'#title' => t('Available menus'),
- '#default_value' => $type->getThirdPartySetting('menu_ui', 'available_menus', array('main')),
+ '#default_value' => $type->getThirdPartySetting('menu_ui', 'available_menus', ['main']),
'#options' => $menu_options,
'#description' => t('The menus available to place links in for this content type.'),
- );
+ ];
// @todo See if we can avoid pre-loading all options by changing the form or
// using a #process callback. https://www.drupal.org/node/2310319
// To avoid an 'illegal option' error after saving the form we have to load
@@ -423,14 +423,14 @@ function menu_ui_form_node_type_form_alter(&$form, FormStateInterface $form_stat
// add options to the list using ajax.
$options_cacheability = new CacheableMetadata();
$options = $menu_parent_selector->getParentSelectOptions('', NULL, $options_cacheability);
- $form['menu']['menu_parent'] = array(
+ $form['menu']['menu_parent'] = [
'#type' => 'select',
'#title' => t('Default parent item'),
'#default_value' => $type->getThirdPartySetting('menu_ui', 'parent', 'main:'),
'#options' => $options,
'#description' => t('Choose the menu item to be the default parent for a new link in the content authoring form.'),
- '#attributes' => array('class' => array('menu-title-select')),
- );
+ '#attributes' => ['class' => ['menu-title-select']],
+ ];
$options_cacheability->applyTo($form['menu']['menu_parent']);
$form['#validate'][] = 'menu_ui_form_node_type_form_validate';
diff --git a/core/modules/menu_ui/src/Controller/MenuController.php b/core/modules/menu_ui/src/Controller/MenuController.php
index 39b0a32a9e9..7958c101ace 100644
--- a/core/modules/menu_ui/src/Controller/MenuController.php
+++ b/core/modules/menu_ui/src/Controller/MenuController.php
@@ -49,7 +49,7 @@ class MenuController extends ControllerBase {
* The available menu and menu items.
*/
public function getParentOptions(Request $request) {
- $available_menus = array();
+ $available_menus = [];
if ($menus = $request->request->get('menus')) {
foreach ($menus as $menu) {
$available_menus[$menu] = $menu;
diff --git a/core/modules/menu_ui/src/Form/MenuDeleteForm.php b/core/modules/menu_ui/src/Form/MenuDeleteForm.php
index 22bfb0ac3b0..1cebd9091c2 100644
--- a/core/modules/menu_ui/src/Form/MenuDeleteForm.php
+++ b/core/modules/menu_ui/src/Form/MenuDeleteForm.php
@@ -57,7 +57,7 @@ class MenuDeleteForm extends EntityDeleteForm {
$caption = '';
$num_links = $this->menuLinkManager->countMenuLinks($this->entity->id());
if ($num_links) {
- $caption .= '<p>' . $this->formatPlural($num_links, '<strong>Warning:</strong> There is currently 1 menu link in %title. It will be deleted (system-defined items will be reset).', '<strong>Warning:</strong> There are currently @count menu links in %title. They will be deleted (system-defined links will be reset).', array('%title' => $this->entity->label())) . '</p>';
+ $caption .= '<p>' . $this->formatPlural($num_links, '<strong>Warning:</strong> There is currently 1 menu link in %title. It will be deleted (system-defined items will be reset).', '<strong>Warning:</strong> There are currently @count menu links in %title. They will be deleted (system-defined links will be reset).', ['%title' => $this->entity->label()]) . '</p>';
}
$caption .= '<p>' . t('This action cannot be undone.') . '</p>';
return $caption;
@@ -67,7 +67,7 @@ class MenuDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
protected function logDeletionMessage() {
- $this->logger('menu')->notice('Deleted custom menu %title and all its menu links.', array('%title' => $this->entity->label()));
+ $this->logger('menu')->notice('Deleted custom menu %title and all its menu links.', ['%title' => $this->entity->label()]);
}
/**
@@ -85,7 +85,7 @@ class MenuDeleteForm extends EntityDeleteForm {
// parameter that is being removed. Also, consider moving this to
// menu_ui.module as part of a generic response to entity deletion.
// https://www.drupal.org/node/2310329
- $menu_links = $this->menuLinkManager->loadLinksByRoute('entity.menu.edit_form', array('menu' => $this->entity->id()), TRUE);
+ $menu_links = $this->menuLinkManager->loadLinksByRoute('entity.menu.edit_form', ['menu' => $this->entity->id()], TRUE);
foreach ($menu_links as $id => $link) {
$this->menuLinkManager->removeDefinition($id);
}
diff --git a/core/modules/menu_ui/src/Form/MenuLinkEditForm.php b/core/modules/menu_ui/src/Form/MenuLinkEditForm.php
index cf133cd53d6..2dbd6a5e8ad 100644
--- a/core/modules/menu_ui/src/Form/MenuLinkEditForm.php
+++ b/core/modules/menu_ui/src/Form/MenuLinkEditForm.php
@@ -57,22 +57,22 @@ class MenuLinkEditForm extends FormBase {
* The plugin instance to use for this form.
*/
public function buildForm(array $form, FormStateInterface $form_state, MenuLinkInterface $menu_link_plugin = NULL) {
- $form['menu_link_id'] = array(
+ $form['menu_link_id'] = [
'#type' => 'value',
'#value' => $menu_link_plugin->getPluginId(),
- );
+ ];
$class_name = $menu_link_plugin->getFormClass();
$form['#plugin_form'] = $this->classResolver->getInstanceFromDefinition($class_name);
$form['#plugin_form']->setMenuLinkInstance($menu_link_plugin);
$form += $form['#plugin_form']->buildConfigurationForm($form, $form_state);
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -92,7 +92,7 @@ class MenuLinkEditForm extends FormBase {
drupal_set_message($this->t('The menu link has been saved.'));
$form_state->setRedirect(
'entity.menu.edit_form',
- array('menu' => $link->getMenuName())
+ ['menu' => $link->getMenuName()]
);
}
diff --git a/core/modules/menu_ui/src/Form/MenuLinkResetForm.php b/core/modules/menu_ui/src/Form/MenuLinkResetForm.php
index 6fbf6228d3c..e37b16b0721 100644
--- a/core/modules/menu_ui/src/Form/MenuLinkResetForm.php
+++ b/core/modules/menu_ui/src/Form/MenuLinkResetForm.php
@@ -59,16 +59,16 @@ class MenuLinkResetForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->link->getTitle()));
+ return $this->t('Are you sure you want to reset the link %item to its default values?', ['%item' => $this->link->getTitle()]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
- return new Url('entity.menu.edit_form', array(
+ return new Url('entity.menu.edit_form', [
'menu' => $this->link->getMenuName(),
- ));
+ ]);
}
/**
diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php
index 105875f727a..0bee996755e 100644
--- a/core/modules/menu_ui/src/MenuForm.php
+++ b/core/modules/menu_ui/src/MenuForm.php
@@ -48,7 +48,7 @@ class MenuForm extends EntityForm {
*
* @var array
*/
- protected $overviewTreeForm = array('#tree' => TRUE);
+ protected $overviewTreeForm = ['#tree' => TRUE];
/**
* Constructs a MenuForm object.
@@ -84,43 +84,43 @@ class MenuForm extends EntityForm {
$menu = $this->entity;
if ($this->operation == 'edit') {
- $form['#title'] = $this->t('Edit menu %label', array('%label' => $menu->label()));
+ $form['#title'] = $this->t('Edit menu %label', ['%label' => $menu->label()]);
}
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Title'),
'#default_value' => $menu->label(),
'#required' => TRUE,
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#title' => $this->t('Menu name'),
'#default_value' => $menu->id(),
'#maxlength' => MENU_MAX_MENU_NAME_LENGTH_UI,
'#description' => $this->t('A unique name to construct the URL for the menu. It must only contain lowercase letters, numbers and hyphens.'),
- '#machine_name' => array(
- 'exists' => array($this, 'menuNameExists'),
- 'source' => array('label'),
+ '#machine_name' => [
+ 'exists' => [$this, 'menuNameExists'],
+ 'source' => ['label'],
'replace_pattern' => '[^a-z0-9-]+',
'replace' => '-',
- ),
+ ],
// A menu's machine name cannot be changed.
'#disabled' => !$menu->isNew() || $menu->isLocked(),
- );
- $form['description'] = array(
+ ];
+ $form['description'] = [
'#type' => 'textfield',
'#title' => t('Administrative summary'),
'#maxlength' => 512,
'#default_value' => $menu->getDescription(),
- );
+ ];
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'language_select',
'#title' => t('Menu language'),
'#languages' => LanguageInterface::STATE_ALL,
'#default_value' => $menu->language()->getId(),
- );
+ ];
// Add menu links administration form for existing menus.
if (!$menu->isNew() || $menu->isLocked()) {
@@ -130,7 +130,7 @@ class MenuForm extends EntityForm {
// the parents of the form section.
// @see self::submitOverviewForm()
$form_state->set('menu_overview_form_parents', ['links']);
- $form['links'] = array();
+ $form['links'] = [];
$form['links'] = $this->buildOverviewForm($form['links'], $form_state);
}
@@ -164,12 +164,12 @@ class MenuForm extends EntityForm {
$status = $menu->save();
$edit_link = $this->entity->link($this->t('Edit'));
if ($status == SAVED_UPDATED) {
- drupal_set_message($this->t('Menu %label has been updated.', array('%label' => $menu->label())));
- $this->logger('menu')->notice('Menu %label has been updated.', array('%label' => $menu->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Menu %label has been updated.', ['%label' => $menu->label()]));
+ $this->logger('menu')->notice('Menu %label has been updated.', ['%label' => $menu->label(), 'link' => $edit_link]);
}
else {
- drupal_set_message($this->t('Menu %label has been added.', array('%label' => $menu->label())));
- $this->logger('menu')->notice('Menu %label has been added.', array('%label' => $menu->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Menu %label has been added.', ['%label' => $menu->label()]));
+ $this->logger('menu')->notice('Menu %label has been added.', ['%label' => $menu->label(), 'link' => $edit_link]);
}
$form_state->setRedirectUrl($this->entity->urlInfo('edit-form'));
@@ -213,10 +213,10 @@ class MenuForm extends EntityForm {
// We indicate that a menu administrator is running the menu access check.
$this->getRequest()->attributes->set('_menu_admin', TRUE);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ];
$tree = $this->menuTree->transform($tree, $manipulators);
$this->getRequest()->attributes->set('_menu_admin', FALSE);
@@ -229,26 +229,26 @@ class MenuForm extends EntityForm {
};
$delta = max($count($tree), 50);
- $form['links'] = array(
+ $form['links'] = [
'#type' => 'table',
'#theme' => 'table__menu_overview',
- '#header' => array(
+ '#header' => [
$this->t('Menu link'),
- array(
+ [
'data' => $this->t('Enabled'),
- 'class' => array('checkbox'),
- ),
+ 'class' => ['checkbox'],
+ ],
$this->t('Weight'),
- array(
+ [
'data' => $this->t('Operations'),
'colspan' => 3,
- ),
- ),
- '#attributes' => array(
+ ],
+ ],
+ '#attributes' => [
'id' => 'menu-overview',
- ),
- '#tabledrag' => array(
- array(
+ ],
+ '#tabledrag' => [
+ [
'action' => 'match',
'relationship' => 'parent',
'group' => 'menu-parent',
@@ -256,14 +256,14 @@ class MenuForm extends EntityForm {
'source' => 'menu-id',
'hidden' => TRUE,
'limit' => \Drupal::menuTree()->maxDepth() - 1,
- ),
- array(
+ ],
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'menu-weight',
- ),
- ),
- );
+ ],
+ ],
+ ];
$form['links']['#empty'] = $this->t('There are no menu links yet. <a href=":url">Add link</a>.', [
':url' => $this->url('entity.menu.add_link_form', ['menu' => $this->entity->id()], [
@@ -285,19 +285,19 @@ class MenuForm extends EntityForm {
$form['links'][$id]['#weight'] = $element['#item']->link->getWeight();
// Add special classes to be used for tabledrag.js.
- $element['parent']['#attributes']['class'] = array('menu-parent');
- $element['weight']['#attributes']['class'] = array('menu-weight');
- $element['id']['#attributes']['class'] = array('menu-id');
+ $element['parent']['#attributes']['class'] = ['menu-parent'];
+ $element['weight']['#attributes']['class'] = ['menu-weight'];
+ $element['id']['#attributes']['class'] = ['menu-id'];
- $form['links'][$id]['title'] = array(
- array(
+ $form['links'][$id]['title'] = [
+ [
'#theme' => 'indentation',
'#size' => $element['#item']->depth - 1,
- ),
+ ],
$element['title'],
- );
+ ];
$form['links'][$id]['enabled'] = $element['enabled'];
- $form['links'][$id]['enabled']['#wrapper_attributes']['class'] = array('checkbox', 'menu-enabled');
+ $form['links'][$id]['enabled']['#wrapper_attributes']['class'] = ['checkbox', 'menu-enabled'];
$form['links'][$id]['weight'] = $element['weight'];
@@ -339,7 +339,7 @@ class MenuForm extends EntityForm {
if ($link) {
$id = 'menu_plugin_id:' . $link->getPluginId();
$form[$id]['#item'] = $element;
- $form[$id]['#attributes'] = $link->isEnabled() ? array('class' => array('menu-enabled')) : array('class' => array('menu-disabled'));
+ $form[$id]['#attributes'] = $link->isEnabled() ? ['class' => ['menu-enabled']] : ['class' => ['menu-disabled']];
$form[$id]['title'] = Link::fromTextAndUrl($link->getTitle(), $link->getUrlObject())->toRenderable();
if (!$link->isEnabled()) {
$form[$id]['title']['#suffix'] = ' (' . $this->t('disabled') . ')';
@@ -353,32 +353,32 @@ class MenuForm extends EntityForm {
$form[$id]['title']['#suffix'] = ' (' . $this->t('logged in users only') . ')';
}
- $form[$id]['enabled'] = array(
+ $form[$id]['enabled'] = [
'#type' => 'checkbox',
- '#title' => $this->t('Enable @title menu link', array('@title' => $link->getTitle())),
+ '#title' => $this->t('Enable @title menu link', ['@title' => $link->getTitle()]),
'#title_display' => 'invisible',
'#default_value' => $link->isEnabled(),
- );
- $form[$id]['weight'] = array(
+ ];
+ $form[$id]['weight'] = [
'#type' => 'weight',
'#delta' => $delta,
'#default_value' => $link->getWeight(),
- '#title' => $this->t('Weight for @title', array('@title' => $link->getTitle())),
+ '#title' => $this->t('Weight for @title', ['@title' => $link->getTitle()]),
'#title_display' => 'invisible',
- );
- $form[$id]['id'] = array(
+ ];
+ $form[$id]['id'] = [
'#type' => 'hidden',
'#value' => $link->getPluginId(),
- );
- $form[$id]['parent'] = array(
+ ];
+ $form[$id]['parent'] = [
'#type' => 'hidden',
'#default_value' => $link->getParent(),
- );
+ ];
// Build a list of operations.
- $operations = array();
- $operations['edit'] = array(
+ $operations = [];
+ $operations['edit'] = [
'title' => $this->t('Edit'),
- );
+ ];
// Allow for a custom edit link per plugin.
$edit_route = $link->getEditRoute();
if ($edit_route) {
@@ -388,16 +388,16 @@ class MenuForm extends EntityForm {
}
else {
// Fall back to the standard edit link.
- $operations['edit'] += array(
+ $operations['edit'] += [
'url' => Url::fromRoute('menu_ui.link_edit', ['menu_link_plugin' => $link->getPluginId()]),
- );
+ ];
}
// Links can either be reset or deleted, not both.
if ($link->isResettable()) {
- $operations['reset'] = array(
+ $operations['reset'] = [
'title' => $this->t('Reset'),
'url' => Url::fromRoute('menu_ui.link_reset', ['menu_link_plugin' => $link->getPluginId()]),
- );
+ ];
}
elseif ($delete_link = $link->getDeleteRoute()) {
$operations['delete']['url'] = $delete_link;
@@ -405,15 +405,15 @@ class MenuForm extends EntityForm {
$operations['delete']['title'] = $this->t('Delete');
}
if ($link->isTranslatable()) {
- $operations['translate'] = array(
+ $operations['translate'] = [
'title' => $this->t('Translate'),
'url' => $link->getTranslateRoute(),
- );
+ ];
}
- $form[$id]['operations'] = array(
+ $form[$id]['operations'] = [
'#type' => 'operations',
'#links' => $operations,
- );
+ ];
}
if ($element->subtree) {
@@ -449,16 +449,16 @@ class MenuForm extends EntityForm {
// parent. To prevent this, save items in the form in the same order they
// are sent, ensuring parents are saved first, then their children.
// See https://www.drupal.org/node/181126#comment-632270.
- $order = is_array($input) ? array_flip(array_keys($input)) : array();
+ $order = is_array($input) ? array_flip(array_keys($input)) : [];
// Update our original form with the new order.
$form = array_intersect_key(array_merge($order, $form), $form);
- $fields = array('weight', 'parent', 'enabled');
+ $fields = ['weight', 'parent', 'enabled'];
$form_links = $form['links'];
foreach (Element::children($form_links) as $id) {
if (isset($form_links[$id]['#item'])) {
$element = $form_links[$id];
- $updated_values = array();
+ $updated_values = [];
// Update any fields that have changed in this menu item.
foreach ($fields as $field) {
if ($element[$field]['#value'] != $element[$field]['#default_value']) {
diff --git a/core/modules/menu_ui/src/MenuListBuilder.php b/core/modules/menu_ui/src/MenuListBuilder.php
index 15342727717..b694c8b9372 100644
--- a/core/modules/menu_ui/src/MenuListBuilder.php
+++ b/core/modules/menu_ui/src/MenuListBuilder.php
@@ -18,10 +18,10 @@ class MenuListBuilder extends ConfigEntityListBuilder {
*/
public function buildHeader() {
$header['title'] = t('Title');
- $header['description'] = array(
+ $header['description'] = [
'data' => t('Description'),
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
- );
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+ ];
return $header + parent::buildHeader();
}
@@ -29,10 +29,10 @@ class MenuListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
- $row['title'] = array(
+ $row['title'] = [
'data' => $entity->label(),
- 'class' => array('menu-label'),
- );
+ 'class' => ['menu-label'],
+ ];
$row['description']['data'] = ['#markup' => $entity->getDescription()];
return $row + parent::buildRow($entity);
}
@@ -45,11 +45,11 @@ class MenuListBuilder extends ConfigEntityListBuilder {
if (isset($operations['edit'])) {
$operations['edit']['title'] = t('Edit menu');
- $operations['add'] = array(
+ $operations['add'] = [
'title' => t('Add link'),
'weight' => 20,
'url' => $entity->urlInfo('add-link-form'),
- );
+ ];
}
if (isset($operations['delete'])) {
$operations['delete']['title'] = t('Delete menu');
diff --git a/core/modules/menu_ui/src/Tests/MenuLanguageTest.php b/core/modules/menu_ui/src/Tests/MenuLanguageTest.php
index 72865ea0104..856f4088b6e 100644
--- a/core/modules/menu_ui/src/Tests/MenuLanguageTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuLanguageTest.php
@@ -21,19 +21,19 @@ class MenuLanguageTest extends MenuWebTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer menu')));
+ $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer menu']));
// Add some custom languages.
- foreach (array('aa', 'bb', 'cc', 'cs') as $language_code) {
- ConfigurableLanguage::create(array(
+ foreach (['aa', 'bb', 'cc', 'cs'] as $language_code) {
+ ConfigurableLanguage::create([
'id' => $language_code,
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
}
}
@@ -45,12 +45,12 @@ class MenuLanguageTest extends MenuWebTestBase {
// Machine name has to be lowercase.
$menu_name = Unicode::strtolower($this->randomMachineName(16));
$label = $this->randomString();
- $edit = array(
+ $edit = [
'id' => $menu_name,
'description' => '',
'label' => $label,
'langcode' => 'aa',
- );
+ ];
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
ContentLanguageSettings::loadByEntityTypeBundle('menu_link_content', 'menu_link_content')
->setDefaultLangcode('bb')
@@ -65,19 +65,19 @@ class MenuLanguageTest extends MenuWebTestBase {
// Add a menu link.
$link_title = $this->randomString();
- $edit = array(
+ $edit = [
'title[0][value]' => $link_title,
'link[0][uri]' => $link_path,
- );
+ ];
$this->drupalPostForm("admin/structure/menu/manage/$menu_name/add", $edit, t('Save'));
// Check the link was added with the correct menu link default language.
- $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $link_title));
+ $menu_links = entity_load_multiple_by_properties('menu_link_content', ['title' => $link_title]);
$menu_link = reset($menu_links);
- $this->assertMenuLink($menu_link->getPluginId(), array(
+ $this->assertMenuLink($menu_link->getPluginId(), [
'menu_name' => $menu_name,
'route_name' => '<front>',
'langcode' => 'bb',
- ));
+ ]);
// Edit menu link default, changing it to cc.
ContentLanguageSettings::loadByEntityTypeBundle('menu_link_content', 'menu_link_content')
@@ -87,30 +87,30 @@ class MenuLanguageTest extends MenuWebTestBase {
// Add a menu link.
$link_title = $this->randomString();
- $edit = array(
+ $edit = [
'title[0][value]' => $link_title,
'link[0][uri]' => $link_path,
- );
+ ];
$this->drupalPostForm("admin/structure/menu/manage/$menu_name/add", $edit, t('Save'));
// Check the link was added with the correct new menu link default language.
- $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $link_title));
+ $menu_links = entity_load_multiple_by_properties('menu_link_content', ['title' => $link_title]);
$menu_link = reset($menu_links);
- $this->assertMenuLink($menu_link->getPluginId(), array(
+ $this->assertMenuLink($menu_link->getPluginId(), [
'menu_name' => $menu_name,
'route_name' => '<front>',
'langcode' => 'cc',
- ));
+ ]);
// Now change the language of the new link to 'bb'.
- $edit = array(
+ $edit = [
'langcode[0][value]' => 'bb',
- );
+ ];
$this->drupalPostForm('admin/structure/menu/item/' . $menu_link->id() . '/edit', $edit, t('Save'));
- $this->assertMenuLink($menu_link->getPluginId(), array(
+ $this->assertMenuLink($menu_link->getPluginId(), [
'menu_name' => $menu_name,
'route_name' => '<front>',
'langcode' => 'bb',
- ));
+ ]);
// Saving menu link items ends up on the edit menu page. To check the menu
// link has the correct language default on edit, go to the menu link edit
diff --git a/core/modules/menu_ui/src/Tests/MenuNodeTest.php b/core/modules/menu_ui/src/Tests/MenuNodeTest.php
index 3fc8423fefb..26f6e4f9385 100644
--- a/core/modules/menu_ui/src/Tests/MenuNodeTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuNodeTest.php
@@ -26,7 +26,7 @@ class MenuNodeTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('menu_ui', 'test_page_test', 'node', 'block', 'locale', 'language', 'content_translation');
+ public static $modules = ['menu_ui', 'test_page_test', 'node', 'block', 'locale', 'language', 'content_translation'];
protected function setUp() {
parent::setUp();
@@ -34,9 +34,9 @@ class MenuNodeTest extends WebTestBase {
$this->drupalPlaceBlock('system_menu_block:main');
$this->drupalPlaceBlock('page_title_block');
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
- $this->editor = $this->drupalCreateUser(array(
+ $this->editor = $this->drupalCreateUser([
'access administration pages',
'administer content types',
'administer menu',
@@ -47,7 +47,7 @@ class MenuNodeTest extends WebTestBase {
'update content translations',
'delete content translations',
'translate any entity',
- ));
+ ]);
$this->drupalLogin($this->editor);
}
@@ -68,9 +68,9 @@ class MenuNodeTest extends WebTestBase {
$this->assertPattern('/<input .* id="edit-menu-title" .* maxlength="' . $max_length . '" .* \/>/', 'Menu link title field has correct maxlength in node add form.');
// Disable the default main menu, so that no menus are enabled.
- $edit = array(
+ $edit = [
'menu_options[main]' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
// Verify that no menu settings are displayed and nodes can be created.
@@ -78,47 +78,47 @@ class MenuNodeTest extends WebTestBase {
$this->assertText(t('Create Basic page'));
$this->assertNoText(t('Menu settings'));
$node_title = $this->randomMachineName();
- $edit = array(
+ $edit = [
'title[0][value]' => $node_title,
'body[0][value]' => $this->randomString(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($node_title);
$this->assertEqual($node->getTitle(), $edit['title[0][value]']);
// Test that we cannot set a menu item from a menu that is not set as
// available.
- $edit = array(
+ $edit = [
'menu_options[tools]' => 1,
'menu_parent' => 'main:',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
$this->assertText(t('The selected menu item is not under one of the selected menus.'));
- $this->assertNoRaw(t('The content type %name has been updated.', array('%name' => 'Basic page')));
+ $this->assertNoRaw(t('The content type %name has been updated.', ['%name' => 'Basic page']));
// Enable Tools menu as available menu.
- $edit = array(
+ $edit = [
'menu_options[main]' => 1,
'menu_options[tools]' => 1,
'menu_parent' => 'main:',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
- $this->assertRaw(t('The content type %name has been updated.', array('%name' => 'Basic page')));
+ $this->assertRaw(t('The content type %name has been updated.', ['%name' => 'Basic page']));
// Test that we can preview a node that will create a menu item.
- $edit = array(
+ $edit = [
'title[0][value]' => $node_title,
'menu[enabled]' => 1,
'menu[title]' => 'Test preview',
- );
+ ];
$this->drupalPostForm('node/add/page', $edit, t('Preview'));
// Create a node.
$node_title = $this->randomMachineName();
- $edit = array(
+ $edit = [
'title[0][value]' => $node_title,
'body[0][value]' => $this->randomString(),
- );
+ ];
$this->drupalPostForm('node/add/page', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($node_title);
// Assert that there is no link for the node.
@@ -126,9 +126,9 @@ class MenuNodeTest extends WebTestBase {
$this->assertNoLink($node_title);
// Edit the node, enable the menu link setting, but skip the link title.
- $edit = array(
+ $edit = [
'menu[enabled]' => 1,
- );
+ ];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Assert that there is no link for the node.
$this->drupalGet('test-page');
@@ -165,11 +165,11 @@ class MenuNodeTest extends WebTestBase {
// Log back in as normal user.
$this->drupalLogin($this->editor);
// Edit the node and create a menu link.
- $edit = array(
+ $edit = [
'menu[enabled]' => 1,
'menu[title]' => $node_title,
'menu[weight]' => 17,
- );
+ ];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Assert that the link exists.
$this->drupalGet('test-page');
@@ -190,20 +190,20 @@ class MenuNodeTest extends WebTestBase {
$this->assertFalse($link->isEnabled(), 'Saving a node with a disabled menu link keeps the menu link disabled.');
// Edit the node and remove the menu link.
- $edit = array(
+ $edit = [
'menu[enabled]' => FALSE,
- );
+ ];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Assert that there is no link for the node.
$this->drupalGet('test-page');
$this->assertNoLink($node_title);
// Add a menu link to the Administration menu.
- $item = MenuLinkContent::create(array(
+ $item = MenuLinkContent::create([
'link' => [['uri' => 'entity:node/' . $node->id()]],
'title' => $this->randomMachineName(16),
'menu_name' => 'admin',
- ));
+ ]);
$item->save();
// Assert that disabled Administration menu is not shown on the
@@ -219,14 +219,14 @@ class MenuNodeTest extends WebTestBase {
$item->menu_name->value = 'tools';
$item->save();
// Create a second node.
- $child_node = $this->drupalCreateNode(array('type' => 'article'));
+ $child_node = $this->drupalCreateNode(['type' => 'article']);
// Assign a menu link to the second node, being a child of the first one.
- $child_item = MenuLinkContent::create(array(
+ $child_item = MenuLinkContent::create([
'link' => [['uri' => 'entity:node/' . $child_node->id()]],
'title' => $this->randomMachineName(16),
'parent' => $item->getPluginId(),
'menu_name' => $item->getMenuName(),
- ));
+ ]);
$child_item->save();
// Edit the first node.
$this->drupalGet('node/' . $node->id() . '/edit');
@@ -242,7 +242,7 @@ class MenuNodeTest extends WebTestBase {
*/
function testMultilingualMenuNodeFormWidget() {
// Setup languages.
- $langcodes = array('de');
+ $langcodes = ['de'];
foreach ($langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)->save();
}
@@ -257,7 +257,7 @@ class MenuNodeTest extends WebTestBase {
$this->rebuildContainer();
- $languages = array();
+ $languages = [];
foreach ($langcodes as $langcode) {
$languages[$langcode] = ConfigurableLanguage::load($langcode);
}
@@ -265,14 +265,14 @@ class MenuNodeTest extends WebTestBase {
// Use a UI form submission to make the node type and menu link content entity translatable.
$this->drupalLogout();
$this->drupalLogin($this->rootUser);
- $edit = array(
+ $edit = [
'entity_types[node]' => TRUE,
'entity_types[menu_link_content]' => TRUE,
'settings[node][page][settings][language][language_alterable]' => TRUE,
'settings[node][page][translatable]' => TRUE,
'settings[node][page][fields][title]' => TRUE,
'settings[menu_link_content][menu_link_content][translatable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
// Log out and back in as normal user.
@@ -297,42 +297,42 @@ class MenuNodeTest extends WebTestBase {
$node->save();
// Edit the node and create a menu link.
- $edit = array(
+ $edit = [
'menu[enabled]' => 1,
'menu[title]' => $node_title,
'menu[weight]' => 17,
- );
- $options = array('language' => $languages[$langcodes[0]]);
+ ];
+ $options = ['language' => $languages[$langcodes[0]]];
$url = $node->toUrl('edit-form', $options);
$this->drupalPostForm($url, $edit, t('Save') . ' ' . t('(this translation)'));
// Edit the node in a different language and translate the menu link.
- $edit = array(
+ $edit = [
'menu[enabled]' => 1,
'menu[title]' => $translated_node_title,
'menu[weight]' => 17,
- );
- $options = array('language' => $languages[$langcodes[1]]);
+ ];
+ $options = ['language' => $languages[$langcodes[1]]];
$url = $node->toUrl('edit-form', $options);
$this->drupalPostForm($url, $edit, t('Save') . ' ' . t('(this translation)'));
// Assert that the original link exists in the frontend.
- $this->drupalGet('node/' . $node->id(), array('language' => $languages[$langcodes[0]]));
+ $this->drupalGet('node/' . $node->id(), ['language' => $languages[$langcodes[0]]]);
$this->assertLink($node_title);
// Assert that the translated link exists in the frontend.
- $this->drupalGet('node/' . $node->id(), array('language' => $languages[$langcodes[1]]));
+ $this->drupalGet('node/' . $node->id(), ['language' => $languages[$langcodes[1]]]);
$this->assertLink($translated_node_title);
// Revisit the edit page in original language, check the loaded menu item title and save.
- $options = array('language' => $languages[$langcodes[0]]);
+ $options = ['language' => $languages[$langcodes[0]]];
$url = $node->toUrl('edit-form', $options);
$this->drupalGet($url);
$this->assertFieldById('edit-menu-title', $node_title);
$this->drupalPostForm(NULL, [], t('Save') . ' ' . t('(this translation)'));
// Revisit the edit page of the translation and check the loaded menu item title.
- $options = array('language' => $languages[$langcodes[1]]);
+ $options = ['language' => $languages[$langcodes[1]]];
$url = $node->toUrl('edit-form', $options);
$this->drupalGet($url);
$this->assertFieldById('edit-menu-title', $translated_node_title);
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index 9c4e1ce779a..c9df569be30 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -25,7 +25,7 @@ class MenuTest extends MenuWebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'block', 'contextual', 'help', 'path', 'test_page_test');
+ public static $modules = ['node', 'block', 'contextual', 'help', 'path', 'test_page_test'];
/**
* A user with administration rights.
@@ -67,11 +67,11 @@ class MenuTest extends MenuWebTestBase {
$this->drupalPlaceBlock('page_title_block');
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Create users.
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer blocks', 'administer menu', 'create article content'));
- $this->authenticatedUser = $this->drupalCreateUser(array());
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer blocks', 'administer menu', 'create article content']);
+ $this->authenticatedUser = $this->drupalCreateUser([]);
}
/**
@@ -80,7 +80,7 @@ class MenuTest extends MenuWebTestBase {
function testMenu() {
// Log in the user.
$this->drupalLogin($this->adminUser);
- $this->items = array();
+ $this->items = [];
$this->menu = $this->addCustomMenu();
$this->doMenuTests();
@@ -132,7 +132,7 @@ class MenuTest extends MenuWebTestBase {
$instance = $this->getStandardMenuLink();
$old_weight = $instance->getWeight();
// Edit the static menu link.
- $edit = array();
+ $edit = [];
$edit['weight'] = 10;
$id = $instance->getPluginId();
$this->drupalPostForm("admin/structure/menu/link/$id/edit", $edit, t('Save'));
@@ -153,11 +153,11 @@ class MenuTest extends MenuWebTestBase {
$menu_name = substr(hash('sha256', $this->randomMachineName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
$label = $this->randomMachineName(16);
- $menu = Menu::create(array(
+ $menu = Menu::create([
'id' => $menu_name,
'label' => $label,
'description' => 'Description text',
- ));
+ ]);
$menu->save();
// Assert the new menu.
@@ -183,20 +183,20 @@ class MenuTest extends MenuWebTestBase {
$this->drupalGet('admin/structure/menu/add');
$menu_name = substr(hash('sha256', $this->randomMachineName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI + 1);
$label = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'id' => $menu_name,
'description' => '',
'label' => $label,
- );
+ ];
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
// Verify that using a menu_name that is too long results in a validation
// message.
- $this->assertRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', array(
+ $this->assertRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', [
'@name' => t('Menu name'),
'%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
'%length' => Unicode::strlen($menu_name),
- )));
+ ]));
// Change the menu_name so it no longer exceeds the maximum length.
$menu_name = substr(hash('sha256', $this->randomMachineName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
@@ -204,13 +204,13 @@ class MenuTest extends MenuWebTestBase {
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
// Verify that no validation error is given for menu_name length.
- $this->assertNoRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', array(
+ $this->assertNoRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', [
'@name' => t('Menu name'),
'%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
'%length' => Unicode::strlen($menu_name),
- )));
+ ]));
// Verify that the confirmation message is displayed.
- $this->assertRaw(t('Menu %label has been added.', array('%label' => $label)));
+ $this->assertRaw(t('Menu %label has been added.', ['%label' => $label]));
$this->drupalGet('admin/structure/menu');
$this->assertText($label, 'Menu created');
@@ -236,13 +236,13 @@ class MenuTest extends MenuWebTestBase {
$label = $this->menu->label();
// Delete custom menu.
- $this->drupalPostForm("admin/structure/menu/manage/$menu_name/delete", array(), t('Delete'));
+ $this->drupalPostForm("admin/structure/menu/manage/$menu_name/delete", [], t('Delete'));
$this->assertResponse(200);
- $this->assertRaw(t('The menu %title has been deleted.', array('%title' => $label)), 'Custom menu was deleted');
+ $this->assertRaw(t('The menu %title has been deleted.', ['%title' => $label]), 'Custom menu was deleted');
$this->assertNull(Menu::load($menu_name), 'Custom menu was deleted');
// Test if all menu links associated with the menu were removed from
// database.
- $result = entity_load_multiple_by_properties('menu_link_content', array('menu_name' => $menu_name));
+ $result = entity_load_multiple_by_properties('menu_link_content', ['menu_name' => $menu_name]);
$this->assertFalse($result, 'All menu links associated with the custom menu were deleted.');
// Make sure there's no delete button on system menus.
@@ -265,32 +265,32 @@ class MenuTest extends MenuWebTestBase {
$this->clickLink(t('Add link'));
$link_title = $this->randomString();
- $this->drupalPostForm(NULL, array('link[0][uri]' => '/', 'title[0][value]' => $link_title), t('Save'));
+ $this->drupalPostForm(NULL, ['link[0][uri]' => '/', 'title[0][value]' => $link_title], t('Save'));
$this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
// Test the 'Edit' operation.
$this->clickLink(t('Edit'));
$this->assertFieldByName('title[0][value]', $link_title);
$link_title = $this->randomString();
- $this->drupalPostForm(NULL, array('title[0][value]' => $link_title), t('Save'));
+ $this->drupalPostForm(NULL, ['title[0][value]' => $link_title], t('Save'));
$this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
// Test the 'Delete' operation.
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete the custom menu link %item?', array('%item' => $link_title)));
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->assertRaw(t('Are you sure you want to delete the custom menu link %item?', ['%item' => $link_title]));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
// Add nodes to use as links for menu links.
- $node1 = $this->drupalCreateNode(array('type' => 'article'));
- $node2 = $this->drupalCreateNode(array('type' => 'article'));
- $node3 = $this->drupalCreateNode(array('type' => 'article'));
- $node4 = $this->drupalCreateNode(array('type' => 'article'));
+ $node1 = $this->drupalCreateNode(['type' => 'article']);
+ $node2 = $this->drupalCreateNode(['type' => 'article']);
+ $node3 = $this->drupalCreateNode(['type' => 'article']);
+ $node4 = $this->drupalCreateNode(['type' => 'article']);
// Create a node with an alias.
- $node5 = $this->drupalCreateNode(array(
+ $node5 = $this->drupalCreateNode([
'type' => 'article',
- 'path' => array(
+ 'path' => [
'alias' => '/node5',
- ),
- ));
+ ],
+ ]);
// Verify add link button.
$this->drupalGet('admin/structure/menu');
@@ -310,25 +310,25 @@ class MenuTest extends MenuWebTestBase {
// -- item2
// --- item3
- $this->assertMenuLink($item1->getPluginId(), array(
- 'children' => array($item2->getPluginId(), $item3->getPluginId()),
- 'parents' => array($item1->getPluginId()),
+ $this->assertMenuLink($item1->getPluginId(), [
+ 'children' => [$item2->getPluginId(), $item3->getPluginId()],
+ 'parents' => [$item1->getPluginId()],
// We assert the language code here to make sure that the language
// selection element degrades gracefully without the Language module.
'langcode' => 'en',
- ));
- $this->assertMenuLink($item2->getPluginId(), array(
- 'children' => array($item3->getPluginId()),
- 'parents' => array($item2->getPluginId(), $item1->getPluginId()),
+ ]);
+ $this->assertMenuLink($item2->getPluginId(), [
+ 'children' => [$item3->getPluginId()],
+ 'parents' => [$item2->getPluginId(), $item1->getPluginId()],
// See above.
'langcode' => 'en',
- ));
- $this->assertMenuLink($item3->getPluginId(), array(
- 'children' => array(),
- 'parents' => array($item3->getPluginId(), $item2->getPluginId(), $item1->getPluginId()),
+ ]);
+ $this->assertMenuLink($item3->getPluginId(), [
+ 'children' => [],
+ 'parents' => [$item3->getPluginId(), $item2->getPluginId(), $item1->getPluginId()],
// See above.
'langcode' => 'en',
- ));
+ ]);
// Verify menu links.
$this->verifyMenuLink($item1, $node1);
@@ -350,26 +350,26 @@ class MenuTest extends MenuWebTestBase {
// -- item5
// -- item6
- $this->assertMenuLink($item4->getPluginId(), array(
- 'children' => array($item5->getPluginId(), $item6->getPluginId()),
- 'parents' => array($item4->getPluginId()),
+ $this->assertMenuLink($item4->getPluginId(), [
+ 'children' => [$item5->getPluginId(), $item6->getPluginId()],
+ 'parents' => [$item4->getPluginId()],
// See above.
'langcode' => 'en',
- ));
- $this->assertMenuLink($item5->getPluginId(), array(
- 'children' => array(),
- 'parents' => array($item5->getPluginId(), $item4->getPluginId()),
+ ]);
+ $this->assertMenuLink($item5->getPluginId(), [
+ 'children' => [],
+ 'parents' => [$item5->getPluginId(), $item4->getPluginId()],
'langcode' => 'en',
- ));
- $this->assertMenuLink($item6->getPluginId(), array(
- 'children' => array(),
- 'parents' => array($item6->getPluginId(), $item4->getPluginId()),
+ ]);
+ $this->assertMenuLink($item6->getPluginId(), [
+ 'children' => [],
+ 'parents' => [$item6->getPluginId(), $item4->getPluginId()],
'route_name' => 'entity.node.canonical',
- 'route_parameters' => array('node' => $node5->id()),
+ 'route_parameters' => ['node' => $node5->id()],
'url' => '',
// See above.
'langcode' => 'en',
- ));
+ ]);
// Modify menu links.
$this->modifyMenuLink($item1);
@@ -390,49 +390,49 @@ class MenuTest extends MenuWebTestBase {
// ---- item3
// -- item6
- $this->assertMenuLink($item1->getPluginId(), array(
- 'children' => array(),
- 'parents' => array($item1->getPluginId()),
+ $this->assertMenuLink($item1->getPluginId(), [
+ 'children' => [],
+ 'parents' => [$item1->getPluginId()],
// See above.
'langcode' => 'en',
- ));
- $this->assertMenuLink($item4->getPluginId(), array(
- 'children' => array($item5->getPluginId(), $item6->getPluginId(), $item2->getPluginId(), $item3->getPluginId()),
- 'parents' => array($item4->getPluginId()),
+ ]);
+ $this->assertMenuLink($item4->getPluginId(), [
+ 'children' => [$item5->getPluginId(), $item6->getPluginId(), $item2->getPluginId(), $item3->getPluginId()],
+ 'parents' => [$item4->getPluginId()],
// See above.
'langcode' => 'en',
- ));
+ ]);
- $this->assertMenuLink($item5->getPluginId(), array(
- 'children' => array($item2->getPluginId(), $item3->getPluginId()),
- 'parents' => array($item5->getPluginId(), $item4->getPluginId()),
+ $this->assertMenuLink($item5->getPluginId(), [
+ 'children' => [$item2->getPluginId(), $item3->getPluginId()],
+ 'parents' => [$item5->getPluginId(), $item4->getPluginId()],
// See above.
'langcode' => 'en',
- ));
- $this->assertMenuLink($item2->getPluginId(), array(
- 'children' => array($item3->getPluginId()),
- 'parents' => array($item2->getPluginId(), $item5->getPluginId(), $item4->getPluginId()),
+ ]);
+ $this->assertMenuLink($item2->getPluginId(), [
+ 'children' => [$item3->getPluginId()],
+ 'parents' => [$item2->getPluginId(), $item5->getPluginId(), $item4->getPluginId()],
// See above.
'langcode' => 'en',
- ));
- $this->assertMenuLink($item3->getPluginId(), array(
- 'children' => array(),
- 'parents' => array($item3->getPluginId(), $item2->getPluginId(), $item5->getPluginId(), $item4->getPluginId()),
+ ]);
+ $this->assertMenuLink($item3->getPluginId(), [
+ 'children' => [],
+ 'parents' => [$item3->getPluginId(), $item2->getPluginId(), $item5->getPluginId(), $item4->getPluginId()],
// See above.
'langcode' => 'en',
- ));
+ ]);
// Add 102 menu links with increasing weights, then make sure the last-added
// item's weight doesn't get changed because of the old hardcoded delta=50.
- $items = array();
+ $items = [];
for ($i = -50; $i <= 51; $i++) {
$items[$i] = $this->addMenuLink('', '/node/' . $node1->id(), $menu_name, TRUE, strval($i));
}
- $this->assertMenuLink($items[51]->getPluginId(), array('weight' => '51'));
+ $this->assertMenuLink($items[51]->getPluginId(), ['weight' => '51']);
// Disable a link and then re-enable the link via the overview form.
$this->disableMenuLink($item1);
- $edit = array();
+ $edit = [];
$edit['links[menu_plugin_id:' . $item1->getPluginId() . '][enabled]'] = TRUE;
$this->drupalPostForm('admin/structure/menu/manage/' . $item1->getMenuName(), $edit, t('Save'));
@@ -446,15 +446,15 @@ class MenuTest extends MenuWebTestBase {
$item5->save();
// Verify in the database.
- $this->assertMenuLink($item1->getPluginId(), array('enabled' => 1));
+ $this->assertMenuLink($item1->getPluginId(), ['enabled' => 1]);
// Add an external link.
$item7 = $this->addMenuLink('', 'https://www.drupal.org', $menu_name);
- $this->assertMenuLink($item7->getPluginId(), array('url' => 'https://www.drupal.org'));
+ $this->assertMenuLink($item7->getPluginId(), ['url' => 'https://www.drupal.org']);
// Add <front> menu item.
$item8 = $this->addMenuLink('', '/', $menu_name);
- $this->assertMenuLink($item8->getPluginId(), array('route_name' => '<front>'));
+ $this->assertMenuLink($item8->getPluginId(), ['route_name' => '<front>']);
$this->drupalGet('');
$this->assertResponse(200);
// Make sure we get routed correctly.
@@ -501,7 +501,7 @@ class MenuTest extends MenuWebTestBase {
// Now change the path to something without query and fragment.
$path = '/test-page';
- $this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', array('link[0][uri]' => $path), t('Save'));
+ $this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', ['link[0][uri]' => $path], t('Save'));
$this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
$this->assertFieldByName('link[0][uri]', $path, 'Path no longer has query or fragment.');
@@ -512,7 +512,7 @@ class MenuTest extends MenuWebTestBase {
$this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
$this->assertFieldByName('link[0][uri]', $path, 'Path is found with both query and fragment.');
- $this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', [], t('Save'));
$this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
$this->assertFieldByName('link[0][uri]', $path, 'Path is found with both query and fragment.');
@@ -523,9 +523,9 @@ class MenuTest extends MenuWebTestBase {
*/
function testSystemMenuRename() {
$this->drupalLogin($this->adminUser);
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(16),
- );
+ ];
$this->drupalPostForm('admin/structure/menu/manage/main', $edit, t('Save'));
// Make sure menu shows up with new name in block addition.
@@ -539,12 +539,12 @@ class MenuTest extends MenuWebTestBase {
* Tests that menu items pointing to unpublished nodes are editable.
*/
function testUnpublishedNodeMenuItem() {
- $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer blocks', 'administer menu', 'create article content', 'bypass node access')));
+ $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer blocks', 'administer menu', 'create article content', 'bypass node access']));
// Create an unpublished node.
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'type' => 'article',
'status' => NodeInterface::NOT_PUBLISHED,
- ));
+ ]);
$item = $this->addMenuLink('', '/node/' . $node->id());
$this->modifyMenuLink($item);
@@ -564,20 +564,20 @@ class MenuTest extends MenuWebTestBase {
* Tests the contextual links on a menu block.
*/
public function testBlockContextualLinks() {
- $this->drupalLogin($this->drupalCreateUser(array('administer menu', 'access contextual links', 'administer blocks')));
+ $this->drupalLogin($this->drupalCreateUser(['administer menu', 'access contextual links', 'administer blocks']));
$custom_menu = $this->addCustomMenu();
$this->addMenuLink('', '/', $custom_menu->id());
- $block = $this->drupalPlaceBlock('system_menu_block:' . $custom_menu->id(), array('label' => 'Custom menu', 'provider' => 'system'));
+ $block = $this->drupalPlaceBlock('system_menu_block:' . $custom_menu->id(), ['label' => 'Custom menu', 'provider' => 'system']);
$this->drupalGet('test-page');
$id = 'block:block=' . $block->id() . ':langcode=en|menu:menu=' . $custom_menu->id() . ':langcode=en';
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
- $this->assertRaw('<div data-contextual-id="' . $id . '"></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+ $this->assertRaw('<div data-contextual-id="' . $id . '"></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
// Get server-rendered contextual links.
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
- $post = array('ids[0]' => $id);
- $response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-page')));
+ $post = ['ids[0]' => $id];
+ $response = $this->drupalPost('contextual/render', 'application/json', $post, ['query' => ['destination' => 'test-page']]);
$this->assertResponse(200);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entitymenuedit-form"><a href="' . base_path() . 'admin/structure/menu/manage/' . $custom_menu->id() . '">Edit menu</a></li></ul>');
@@ -608,7 +608,7 @@ class MenuTest extends MenuWebTestBase {
$this->assertResponse(200);
$title = '!link_' . $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'link[0][uri]' => $path,
'title[0][value]' => $title,
'description[0][value]' => '',
@@ -616,18 +616,18 @@ class MenuTest extends MenuWebTestBase {
'expanded[value]' => $expanded,
'menu_parent' => $menu_name . ':' . $parent,
'weight[0][value]' => $weight,
- );
+ ];
// Add menu link.
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertResponse(200);
$this->assertText('The menu link has been saved.');
- $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $title));
+ $menu_links = entity_load_multiple_by_properties('menu_link_content', ['title' => $title]);
$menu_link = reset($menu_links);
$this->assertTrue($menu_link, 'Menu link was found in database.');
- $this->assertMenuLink($menu_link->getPluginId(), array('menu_name' => $menu_name, 'children' => array(), 'parent' => $parent));
+ $this->assertMenuLink($menu_link->getPluginId(), ['menu_name' => $menu_name, 'children' => [], 'parent' => $parent]);
return $menu_link;
}
@@ -636,13 +636,13 @@ class MenuTest extends MenuWebTestBase {
* Attempts to add menu link with invalid path or no access permission.
*/
function addInvalidMenuLink() {
- foreach (array('access' => '/admin/people/permissions') as $type => $link_path) {
- $edit = array(
+ foreach (['access' => '/admin/people/permissions'] as $type => $link_path) {
+ $edit = [
'link[0][uri]' => $link_path,
'title[0][value]' => 'title',
- );
+ ];
$this->drupalPostForm("admin/structure/menu/manage/{$this->menu->id()}/add", $edit, t('Save'));
- $this->assertRaw(t("The path '@link_path' is inaccessible.", array('@link_path' => $link_path)), 'Menu link was not created');
+ $this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => $link_path]), 'Menu link was not created');
}
}
@@ -651,7 +651,7 @@ class MenuTest extends MenuWebTestBase {
*/
function checkInvalidParentMenuLinks() {
$last_link = NULL;
- $created_links = array();
+ $created_links = [];
// Get the max depth of the tree.
$menu_link_tree = \Drupal::service('menu.link_tree');
@@ -661,7 +661,7 @@ class MenuTest extends MenuWebTestBase {
for ($i = 0; $i <= $max_depth - 1; $i++) {
$parent = $last_link ? 'tools:' . $last_link->getPluginId() : 'tools:';
$title = 'title' . $i;
- $edit = array(
+ $edit = [
'link[0][uri]' => '/',
'title[0][value]' => $title,
'menu_parent' => $parent,
@@ -669,9 +669,9 @@ class MenuTest extends MenuWebTestBase {
'enabled[value]' => 1,
'expanded[value]' => FALSE,
'weight[0][value]' => '0',
- );
+ ];
$this->drupalPostForm("admin/structure/menu/manage/{$this->menu->id()}/add", $edit, t('Save'));
- $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $title));
+ $menu_links = entity_load_multiple_by_properties('menu_link_content', ['title' => $title]);
$last_link = reset($menu_links);
$created_links[] = 'tools:' . $last_link->getPluginId();
}
@@ -714,7 +714,7 @@ class MenuTest extends MenuWebTestBase {
// Verify menu link link.
$this->clickLink($title);
$title = $parent_node->label();
- $this->assertTitle(t("@title | Drupal", array('@title' => $title)), 'Parent menu link link target was correct');
+ $this->assertTitle(t("@title | Drupal", ['@title' => $title]), 'Parent menu link link target was correct');
}
// Verify menu link.
@@ -724,7 +724,7 @@ class MenuTest extends MenuWebTestBase {
// Verify menu link link.
$this->clickLink($title);
$title = $item_node->label();
- $this->assertTitle(t("@title | Drupal", array('@title' => $title)), 'Menu link link target was correct');
+ $this->assertTitle(t("@title | Drupal", ['@title' => $title]), 'Menu link link target was correct');
}
/**
@@ -740,9 +740,9 @@ class MenuTest extends MenuWebTestBase {
function moveMenuLink(MenuLinkContent $item, $parent, $menu_name) {
$mlid = $item->id();
- $edit = array(
+ $edit = [
'menu_parent' => $menu_name . ':' . $parent,
- );
+ ];
$this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
$this->assertResponse(200);
}
@@ -760,7 +760,7 @@ class MenuTest extends MenuWebTestBase {
$title = $item->getTitle();
// Edit menu link.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $title;
$this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
$this->assertResponse(200);
@@ -780,7 +780,7 @@ class MenuTest extends MenuWebTestBase {
*/
function resetMenuLink(MenuLinkInterface $menu_link, $old_weight) {
// Reset menu link.
- $this->drupalPostForm("admin/structure/menu/link/{$menu_link->getPluginId()}/reset", array(), t('Reset'));
+ $this->drupalPostForm("admin/structure/menu/link/{$menu_link->getPluginId()}/reset", [], t('Reset'));
$this->assertResponse(200);
$this->assertRaw(t('The menu link was reset to its default settings.'), 'Menu link was reset');
@@ -800,9 +800,9 @@ class MenuTest extends MenuWebTestBase {
$title = $item->getTitle();
// Delete menu link.
- $this->drupalPostForm("admin/structure/menu/item/$mlid/delete", array(), t('Delete'));
+ $this->drupalPostForm("admin/structure/menu/item/$mlid/delete", [], t('Delete'));
$this->assertResponse(200);
- $this->assertRaw(t('The menu link %title has been deleted.', array('%title' => $title)), 'Menu link was deleted');
+ $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $title]), 'Menu link was deleted');
// Verify deletion.
$this->drupalGet('');
@@ -841,7 +841,7 @@ class MenuTest extends MenuWebTestBase {
// Unlike most other modules, there is no confirmation message displayed.
// Verify in the database.
- $this->assertMenuLink($item->getPluginId(), array('enabled' => 0));
+ $this->assertMenuLink($item->getPluginId(), ['enabled' => 0]);
}
/**
@@ -856,7 +856,7 @@ class MenuTest extends MenuWebTestBase {
$this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
// Verify in the database.
- $this->assertMenuLink($item->getPluginId(), array('enabled' => 1));
+ $this->assertMenuLink($item->getPluginId(), ['enabled' => 1]);
}
/**
@@ -864,7 +864,7 @@ class MenuTest extends MenuWebTestBase {
* AJAX callback.
*/
public function testMenuParentsJsAccess() {
- $admin = $this->drupalCreateUser(array('administer menu'));
+ $admin = $this->drupalCreateUser(['administer menu']);
$this->drupalLogin($admin);
// Just check access to the callback overall, the POST data is irrelevant.
$this->drupalGetAjax('admin/structure/menu/parents');
diff --git a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php
index c08fc142199..bda38ba5717 100644
--- a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php
+++ b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php
@@ -14,7 +14,7 @@ abstract class MenuWebTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('menu_ui', 'menu_link_content');
+ public static $modules = ['menu_ui', 'menu_link_content'];
/**
* Fetches the menu item from the database and compares it to expected item.
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php b/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php
index 03ff031e5f2..f7bf7f88d40 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php
@@ -17,7 +17,7 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('menu_ui', 'block', 'test_page_test');
+ public static $modules = ['menu_ui', 'block', 'test_page_test'];
/**
* Tests cache tags presence and invalidation of the Menu entity.
@@ -29,23 +29,23 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
$url = Url::fromRoute('test_page_test.test_page');
// Create a Llama menu, add a link to it and place the corresponding block.
- $menu = Menu::create(array(
+ $menu = Menu::create([
'id' => 'llama',
'label' => 'Llama',
'description' => 'Description text',
- ));
+ ]);
$menu->save();
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
// Move a link into the new menu.
- $menu_link = $menu_link_manager->updateDefinition('test_page_test.test_page', array('menu_name' => 'llama', 'parent' => ''));
- $block = $this->drupalPlaceBlock('system_menu_block:llama', array('label' => 'Llama', 'provider' => 'system', 'region' => 'footer'));
+ $menu_link = $menu_link_manager->updateDefinition('test_page_test.test_page', ['menu_name' => 'llama', 'parent' => '']);
+ $block = $this->drupalPlaceBlock('system_menu_block:llama', ['label' => 'Llama', 'provider' => 'system', 'region' => 'footer']);
// Prime the page cache.
$this->verifyPageCache($url, 'MISS');
// Verify a cache hit, but also the presence of the correct cache tags.
- $expected_tags = array(
+ $expected_tags = [
'http_response',
'rendered',
'block_view',
@@ -55,7 +55,7 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
// The cache contexts associated with the (in)accessible menu links are
// bubbled.
'config:user.role.anonymous',
- );
+ ];
$this->verifyPageCache($url, 'HIT', $expected_tags);
// Verify that after modifying the menu, there is a cache miss.
@@ -68,7 +68,7 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
$this->verifyPageCache($url, 'HIT');
// Verify that after modifying the menu link weight, there is a cache miss.
- $menu_link_manager->updateDefinition('test_page_test.test_page', array('weight' => -10));
+ $menu_link_manager->updateDefinition('test_page_test.test_page', ['weight' => -10]);
$this->pass('Test modification of menu link.', 'Debug');
$this->verifyPageCache($url, 'MISS');
@@ -77,7 +77,7 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
// Verify that after adding a menu link, there is a cache miss.
$this->pass('Test addition of menu link.', 'Debug');
- $menu_link_2 = MenuLinkContent::create(array(
+ $menu_link_2 = MenuLinkContent::create([
'id' => '',
'parent' => '',
'title' => 'Alpaca',
@@ -86,7 +86,7 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
'uri' => 'internal:/',
]],
'bundle' => 'menu_name',
- ));
+ ]);
$menu_link_2->save();
$this->verifyPageCache($url, 'MISS');
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php b/core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php
index e0f7cc874f7..163853dc39f 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php
@@ -23,7 +23,7 @@ class MenuLinkReorderTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('menu_ui', 'test_page_test', 'node', 'block');
+ public static $modules = ['menu_ui', 'test_page_test', 'node', 'block'];
/**
* Test creating, editing, deleting menu links via node form widget.
@@ -38,17 +38,17 @@ class MenuLinkReorderTest extends BrowserTestBase {
$this->assertLink('Home');
// The administrator user that can re-order menu links.
- $this->administrator = $this->drupalCreateUser(array(
+ $this->administrator = $this->drupalCreateUser([
'administer site configuration',
'access administration pages',
'administer menu',
- ));
+ ]);
$this->drupalLogin($this->administrator);
// Change the weight of the link to a non default value.
- $edit = array(
+ $edit = [
'links[menu_plugin_id:test_page_test.front_page][weight]' => -10,
- );
+ ];
$this->drupalPostForm('admin/structure/menu/manage/main', $edit, t('Save'));
// The link is still there.
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php
index 269454e30fb..a0320f44b0f 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php
@@ -17,15 +17,15 @@ class MenuUninstallTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('menu_ui');
+ public static $modules = ['menu_ui'];
/**
* Tests Menu uninstall.
*/
public function testMenuUninstall() {
- \Drupal::service('module_installer')->uninstall(array('menu_ui'));
+ \Drupal::service('module_installer')->uninstall(['menu_ui']);
- \Drupal::entityManager()->getStorage('menu')->resetCache(array('admin'));
+ \Drupal::entityManager()->getStorage('menu')->resetCache(['admin']);
$this->assertTrue(Menu::load('admin'), 'The \'admin\' menu still exists after uninstalling Menu UI module.');
}
diff --git a/core/modules/migrate/migrate.api.php b/core/modules/migrate/migrate.api.php
index aea0d77c476..eefda3c3847 100644
--- a/core/modules/migrate/migrate.api.php
+++ b/core/modules/migrate/migrate.api.php
@@ -103,7 +103,7 @@ use Drupal\migrate\Row;
*/
function hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
if ($migration->id() == 'd6_filter_formats') {
- $value = $source->getDatabase()->query('SELECT value FROM {variable} WHERE name = :name', array(':name' => 'mymodule_filter_foo_' . $row->getSourceProperty('format')))->fetchField();
+ $value = $source->getDatabase()->query('SELECT value FROM {variable} WHERE name = :name', [':name' => 'mymodule_filter_foo_' . $row->getSourceProperty('format')])->fetchField();
if ($value) {
$row->setSourceProperty('settings:mymodule:foo', unserialize($value));
}
diff --git a/core/modules/migrate/migrate.module b/core/modules/migrate/migrate.module
index 9cec273cdd1..3b92463928d 100644
--- a/core/modules/migrate/migrate.module
+++ b/core/modules/migrate/migrate.module
@@ -15,7 +15,7 @@ function migrate_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.migrate':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>';
- $output .= t('The Migrate module provides a framework for migrating data, usually from an external source into your site. It does not provide a user interface. For more information, see the <a href=":migrate">online documentation for the Migrate module</a>.', array(':migrate' => 'https://www.drupal.org/documentation/modules/migrate'));
+ $output .= t('The Migrate module provides a framework for migrating data, usually from an external source into your site. It does not provide a user interface. For more information, see the <a href=":migrate">online documentation for the Migrate module</a>.', [':migrate' => 'https://www.drupal.org/documentation/modules/migrate']);
$output .= '</p>';
return $output;
}
diff --git a/core/modules/migrate/src/Exception/RequirementsException.php b/core/modules/migrate/src/Exception/RequirementsException.php
index 4c17dd6172a..93da7ee4bcc 100644
--- a/core/modules/migrate/src/Exception/RequirementsException.php
+++ b/core/modules/migrate/src/Exception/RequirementsException.php
@@ -56,7 +56,7 @@ class RequirementsException extends \RuntimeException {
$output = '';
foreach ($this->requirements as $requirement_type => $requirements) {
if (!is_array($requirements)) {
- $requirements = array($requirements);
+ $requirements = [$requirements];
}
foreach ($requirements as $value) {
diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php
index ff05dfecf43..9d48618f58c 100644
--- a/core/modules/migrate/src/MigrateExecutable.php
+++ b/core/modules/migrate/src/MigrateExecutable.php
@@ -65,7 +65,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
*
* @var array
*/
- protected $counts = array();
+ protected $counts = [];
/**
* The source.
@@ -151,10 +151,10 @@ class MigrateExecutable implements MigrateExecutableInterface {
// Only begin the import operation if the migration is currently idle.
if ($this->migration->getStatus() !== MigrationInterface::STATUS_IDLE) {
$this->message->display($this->t('Migration @id is busy with another operation: @status',
- array(
+ [
'@id' => $this->migration->id(),
'@status' => $this->t($this->migration->getStatusLabel()),
- )), 'error');
+ ]), 'error');
return MigrationInterface::RESULT_FAILED;
}
$this->getEventDispatcher()->dispatch(MigrateEvents::PRE_IMPORT, new MigrateImportEvent($this->migration, $this->message));
@@ -167,11 +167,11 @@ class MigrateExecutable implements MigrateExecutableInterface {
$this->message->display(
$this->t(
'Migration @id did not meet the requirements. @message @requirements',
- array(
+ [
'@id' => $this->migration->id(),
'@message' => $e->getMessage(),
'@requirements' => $e->getRequirementsString(),
- )
+ ]
),
'error'
);
@@ -189,7 +189,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
}
catch (\Exception $e) {
$this->message->display(
- $this->t('Migration failed with source plugin exception: @e', array('@e' => $e->getMessage())), 'error');
+ $this->t('Migration failed with source plugin exception: @e', ['@e' => $e->getMessage()]), 'error');
$this->migration->setStatus(MigrationInterface::STATUS_IDLE);
return MigrationInterface::RESULT_FAILED;
}
@@ -204,7 +204,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
$save = TRUE;
}
catch (MigrateException $e) {
- $this->migration->getIdMap()->saveIdMapping($row, array(), $e->getStatus());
+ $this->migration->getIdMap()->saveIdMapping($row, [], $e->getStatus());
$this->saveMessage($e->getMessage(), $e->getLevel());
$save = FALSE;
}
@@ -230,7 +230,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
}
}
else {
- $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED);
+ $id_map->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_FAILED);
if (!$id_map->messageCount()) {
$message = $this->t('New object was not saved, no error provided');
$this->saveMessage($message);
@@ -239,11 +239,11 @@ class MigrateExecutable implements MigrateExecutableInterface {
}
}
catch (MigrateException $e) {
- $this->migration->getIdMap()->saveIdMapping($row, array(), $e->getStatus());
+ $this->migration->getIdMap()->saveIdMapping($row, [], $e->getStatus());
$this->saveMessage($e->getMessage(), $e->getLevel());
}
catch (\Exception $e) {
- $this->migration->getIdMap()->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED);
+ $this->migration->getIdMap()->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_FAILED);
$this->handleException($e);
}
}
@@ -268,7 +268,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
catch (\Exception $e) {
$this->message->display(
$this->t('Migration failed with source plugin exception: @e',
- array('@e' => $e->getMessage())), 'error');
+ ['@e' => $e->getMessage()]), 'error');
$this->migration->setStatus(MigrationInterface::STATUS_IDLE);
return MigrationInterface::RESULT_FAILED;
}
@@ -356,7 +356,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
// plugin) and in this case the current value needs to be iterated
// and each scalar separately transformed.
if ($multiple && !$definition['handle_multiples']) {
- $new_value = array();
+ $new_value = [];
if (!is_array($value)) {
throw new MigrateException(sprintf('Pipeline failed for destination %s: %s got instead of an array,', $destination, $value));
}
@@ -460,11 +460,11 @@ class MigrateExecutable implements MigrateExecutableInterface {
$this->message->display(
$this->t(
'Memory usage is @usage (@pct% of limit @limit), reclaiming memory.',
- array(
+ [
'@pct' => round($pct_memory * 100),
'@usage' => $this->formatSize($usage),
'@limit' => $this->formatSize($this->memoryLimit),
- )
+ ]
),
'warning'
);
@@ -476,11 +476,11 @@ class MigrateExecutable implements MigrateExecutableInterface {
$this->message->display(
$this->t(
'Memory usage is now @usage (@pct% of limit @limit), not enough reclaimed, starting new batch',
- array(
+ [
'@pct' => round($pct_memory * 100),
'@usage' => $this->formatSize($usage),
'@limit' => $this->formatSize($this->memoryLimit),
- )
+ ]
),
'warning'
);
@@ -490,11 +490,11 @@ class MigrateExecutable implements MigrateExecutableInterface {
$this->message->display(
$this->t(
'Memory usage is now @usage (@pct% of limit @limit), reclaimed enough, continuing',
- array(
+ [
'@pct' => round($pct_memory * 100),
'@usage' => $this->formatSize($usage),
'@limit' => $this->formatSize($this->memoryLimit),
- )
+ ]
),
'warning');
return FALSE;
diff --git a/core/modules/migrate/src/MigrateMessage.php b/core/modules/migrate/src/MigrateMessage.php
index b3c7634b72b..4cc166c81c5 100644
--- a/core/modules/migrate/src/MigrateMessage.php
+++ b/core/modules/migrate/src/MigrateMessage.php
@@ -14,10 +14,10 @@ class MigrateMessage implements MigrateMessageInterface {
*
* @var array
*/
- protected $map = array(
+ protected $map = [
'status' => RfcLogLevel::INFO,
'error' => RfcLogLevel::ERROR,
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php b/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php
index ef7c0b63e74..0babe2fc743 100644
--- a/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php
+++ b/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php
@@ -12,7 +12,7 @@ class MigrateEntity implements ContainerDeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* The entity definitions
@@ -59,12 +59,12 @@ class MigrateEntity implements ContainerDeriverInterface {
$class = is_subclass_of($entity_info->getClass(), 'Drupal\Core\Config\Entity\ConfigEntityInterface') ?
'Drupal\migrate\Plugin\migrate\destination\EntityConfigBase' :
'Drupal\migrate\Plugin\migrate\destination\EntityContentBase';
- $this->derivatives[$entity_type] = array(
+ $this->derivatives[$entity_type] = [
'id' => "entity:$entity_type",
'class' => $class,
'requirements_met' => 1,
'provider' => $entity_info->getProvider(),
- );
+ ];
}
return $this->derivatives;
}
diff --git a/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php b/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php
index 2925bd4296f..cee3b3985ed 100644
--- a/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php
+++ b/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php
@@ -12,7 +12,7 @@ class MigrateEntityRevision implements ContainerDeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* The entity definitions
@@ -57,12 +57,12 @@ class MigrateEntityRevision implements ContainerDeriverInterface {
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityDefinitions as $entity_type => $entity_info) {
if ($entity_info->getKey('revision')) {
- $this->derivatives[$entity_type] = array(
+ $this->derivatives[$entity_type] = [
'id' => "entity_revision:$entity_type",
'class' => 'Drupal\migrate\Plugin\migrate\destination\EntityRevision',
'requirements_met' => 1,
'provider' => $entity_info->getProvider(),
- );
+ ];
}
}
return $this->derivatives;
diff --git a/core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php b/core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php
index c102bb890ef..180be0a3aae 100644
--- a/core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php
+++ b/core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php
@@ -73,7 +73,7 @@ class AnnotatedClassDiscoveryAutomatedProviders extends AnnotatedClassDiscovery
* {@inheritdoc}
*/
public function getDefinitions() {
- $definitions = array();
+ $definitions = [];
$reader = $this->getAnnotationReader();
diff --git a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php
index 9c83baf295c..866e80cbe05 100644
--- a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php
+++ b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php
@@ -106,7 +106,7 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
* @return mixed
* The entity ID or an indication of success.
*/
- public function import(Row $row, array $old_destination_id_values = array());
+ public function import(Row $row, array $old_destination_id_values = []);
/**
* Delete the specified destination object from the target Drupal.
diff --git a/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php b/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php
index 74100cf4f23..090efd042a2 100644
--- a/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php
+++ b/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php
@@ -54,7 +54,7 @@ class MigrateDestinationPluginManager extends MigratePluginManager {
*
* A specific createInstance method is necessary to pass the migration on.
*/
- public function createInstance($plugin_id, array $configuration = array(), MigrationInterface $migration = NULL) {
+ public function createInstance($plugin_id, array $configuration = [], MigrationInterface $migration = NULL) {
if (substr($plugin_id, 0, 7) == 'entity:' && !$this->entityManager->getDefinition(substr($plugin_id, 7), FALSE)) {
$plugin_id = 'null';
}
diff --git a/core/modules/migrate/src/Plugin/MigratePluginManager.php b/core/modules/migrate/src/Plugin/MigratePluginManager.php
index 94c59859e62..b3645dbdd0e 100644
--- a/core/modules/migrate/src/Plugin/MigratePluginManager.php
+++ b/core/modules/migrate/src/Plugin/MigratePluginManager.php
@@ -49,7 +49,7 @@ class MigratePluginManager extends DefaultPluginManager implements MigratePlugin
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array(), MigrationInterface $migration = NULL) {
+ public function createInstance($plugin_id, array $configuration = [], MigrationInterface $migration = NULL) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
// If the plugin provides a factory method, pass the container to it.
diff --git a/core/modules/migrate/src/Plugin/Migration.php b/core/modules/migrate/src/Plugin/Migration.php
index be79d0df3b5..13092e77758 100644
--- a/core/modules/migrate/src/Plugin/Migration.php
+++ b/core/modules/migrate/src/Plugin/Migration.php
@@ -346,9 +346,9 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
}
$index = serialize($process);
if (!isset($this->processPlugins[$index])) {
- $this->processPlugins[$index] = array();
+ $this->processPlugins[$index] = [];
foreach ($this->getProcessNormalized($process) as $property => $configurations) {
- $this->processPlugins[$index][$property] = array();
+ $this->processPlugins[$index][$property] = [];
foreach ($configurations as $configuration) {
if (isset($configuration['source'])) {
$this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance('get', $configuration, $this);
@@ -376,16 +376,16 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
* The normalized process configuration.
*/
protected function getProcessNormalized(array $process) {
- $normalized_configurations = array();
+ $normalized_configurations = [];
foreach ($process as $destination => $configuration) {
if (is_string($configuration)) {
- $configuration = array(
+ $configuration = [
'plugin' => 'get',
'source' => $configuration,
- );
+ ];
}
if (isset($configuration['plugin'])) {
- $configuration = array($configuration);
+ $configuration = [$configuration];
}
$normalized_configurations[$destination] = $configuration;
}
diff --git a/core/modules/migrate/src/Plugin/MigrationPluginManager.php b/core/modules/migrate/src/Plugin/MigrationPluginManager.php
index 3ea5727d025..f3b75bc89cb 100644
--- a/core/modules/migrate/src/Plugin/MigrationPluginManager.php
+++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php
@@ -24,9 +24,9 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
*
* @var array
*/
- protected $defaults = array(
+ protected $defaults = [
'class' => '\Drupal\migrate\Plugin\Migration',
- );
+ ];
/**
* The interface the plugins should implement.
@@ -55,7 +55,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager) {
$this->factory = new ContainerFactory($this, $this->pluginInterface);
$this->alterInfo('migration_plugins');
- $this->setCacheBackend($cache_backend, 'migration_plugins', array('migration_plugins'));
+ $this->setCacheBackend($cache_backend, 'migration_plugins', ['migration_plugins']);
$this->moduleHandler = $module_handler;
}
@@ -85,7 +85,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$instances = $this->createInstances([$plugin_id], [$plugin_id => $configuration]);
return reset($instances);
}
@@ -93,7 +93,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
/**
* {@inheritdoc}
*/
- public function createInstances($migration_id, array $configuration = array()) {
+ public function createInstances($migration_id, array $configuration = []) {
if (empty($migration_id)) {
$migration_id = array_keys($this->getDefinitions());
}
@@ -222,9 +222,9 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
* The dynamic ID mapping.
*/
protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids) {
- $dependencies = isset($dynamic_ids[$dependency]) ? $dynamic_ids[$dependency] : array($dependency);
+ $dependencies = isset($dynamic_ids[$dependency]) ? $dynamic_ids[$dependency] : [$dependency];
if (!isset($graph[$id]['edges'])) {
- $graph[$id]['edges'] = array();
+ $graph[$id]['edges'] = [];
}
$graph[$id]['edges'] += array_combine($dependencies, $dependencies);
}
diff --git a/core/modules/migrate/src/Plugin/MigrationPluginManagerInterface.php b/core/modules/migrate/src/Plugin/MigrationPluginManagerInterface.php
index 0f97768229e..a0f648862dd 100644
--- a/core/modules/migrate/src/Plugin/MigrationPluginManagerInterface.php
+++ b/core/modules/migrate/src/Plugin/MigrationPluginManagerInterface.php
@@ -26,7 +26,7 @@ interface MigrationPluginManagerInterface extends PluginManagerInterface {
* @throws \Drupal\Component\Plugin\Exception\PluginException
* If an instance cannot be created, such as if the ID is invalid.
*/
- public function createInstances($id, array $configuration = array());
+ public function createInstances($id, array $configuration = []);
/**
* Creates a stub migration plugin from a definition array.
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php b/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php
index a3b174a9d00..660248494e1 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php
@@ -15,8 +15,8 @@ abstract class ComponentEntityDisplayBase extends DestinationBase {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
- $values = array();
+ public function import(Row $row, array $old_destination_id_values = []) {
+ $values = [];
// array_intersect_key() won't work because the order is important because
// this is also the return value.
foreach (array_keys($this->getIds()) as $id) {
@@ -24,7 +24,7 @@ abstract class ComponentEntityDisplayBase extends DestinationBase {
}
$entity = $this->getEntity($values['entity_type'], $values['bundle'], $values[static::MODE_NAME]);
if (!$row->getDestinationProperty('hidden')) {
- $entity->setComponent($values['field_name'], $row->getDestinationProperty('options') ?: array());
+ $entity->setComponent($values['field_name'], $row->getDestinationProperty('options') ?: []);
}
else {
$entity->removeComponent($values['field_name']);
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Config.php b/core/modules/migrate/src/Plugin/migrate/destination/Config.php
index 422037be5e2..cb1c1c0579c 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/Config.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/Config.php
@@ -83,7 +83,7 @@ class Config extends DestinationBase implements ContainerFactoryPluginInterface,
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
if ($this->isTranslationDestination()) {
$this->config = $this->language_manager->getLanguageConfigOverride($row->getDestinationProperty('langcode'), $this->config->getName());
}
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
index f59b8c7be0f..2829032cbfc 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
@@ -86,7 +86,7 @@ class EntityConfigBase extends Entity {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
if ($row->isStub()) {
throw new MigrateException('Config entities can not be stubbed.');
}
@@ -214,7 +214,7 @@ class EntityConfigBase extends Entity {
* The generated entity ID.
*/
protected function generateId(Row $row, array $ids) {
- $id_values = array();
+ $id_values = [];
foreach ($ids as $id) {
if ($this->isTranslationDestination() && $id == 'langcode') {
continue;
@@ -230,7 +230,7 @@ class EntityConfigBase extends Entity {
public function rollback(array $destination_identifier) {
if ($this->isTranslationDestination()) {
// The entity id does not include the langcode.
- $id_values = array();
+ $id_values = [];
foreach ($destination_identifier as $key => $value) {
if ($this->isTranslationDestination() && $key == 'langcode') {
continue;
@@ -247,7 +247,7 @@ class EntityConfigBase extends Entity {
}
else {
$destination_identifier = implode('.', $destination_identifier);
- parent::rollback(array($destination_identifier));
+ parent::rollback([$destination_identifier]);
}
}
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
index 9da3de6f905..d4f9bd72ecc 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
@@ -80,7 +80,7 @@ class EntityContentBase extends Entity {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$this->rollbackAction = MigrateIdMapInterface::ROLLBACK_DELETE;
$entity = $this->getEntity($row, $old_destination_id_values);
if (!$entity) {
@@ -105,9 +105,9 @@ class EntityContentBase extends Entity {
* @return array
* An array containing the entity ID.
*/
- protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {
+ protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) {
$entity->save();
- return array($entity->id());
+ return [$entity->id()];
}
/**
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
index 7ad01045a61..9b781a3f9ab 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
@@ -25,7 +25,7 @@ class EntityFieldStorageConfig extends EntityConfigBase {
*/
public function rollback(array $destination_identifier) {
$destination_identifier = implode('.', $destination_identifier);
- parent::rollback(array($destination_identifier));
+ parent::rollback([$destination_identifier]);
}
}
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
index 381974291ee..b0db4769877 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
@@ -63,9 +63,9 @@ class EntityRevision extends EntityContentBase {
/**
* {@inheritdoc}
*/
- protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {
+ protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) {
$entity->save();
- return array($entity->getRevisionId());
+ return [$entity->getRevisionId()];
}
/**
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php
index fad171b5904..d7c2e80e136 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php
@@ -25,7 +25,7 @@ class EntityViewMode extends EntityConfigBase {
*/
public function rollback(array $destination_identifier) {
$destination_identifier = implode('.', $destination_identifier);
- parent::rollback(array($destination_identifier));
+ parent::rollback([$destination_identifier]);
}
}
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php b/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php
index 878a1838be1..cfe47eada8b 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php
@@ -19,20 +19,20 @@ class NullDestination extends DestinationBase {
* {@inheritdoc}
*/
public function getIds() {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function fields(MigrationInterface $migration = NULL) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
}
}
diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
index 1ff5ee4c176..14a0a7abe5a 100644
--- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -115,14 +115,14 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*
* @var array
*/
- protected $sourceIds = array();
+ protected $sourceIds = [];
/**
* The destination identifiers.
*
* @var array
*/
- protected $destinationIds = array();
+ protected $destinationIds = [];
/**
* The current row.
@@ -136,7 +136,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*
* @var array
*/
- protected $currentKey = array();
+ protected $currentKey = [];
/**
* Constructs an SQL object.
@@ -208,7 +208,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
protected function sourceIdFields() {
if (!isset($this->sourceIdFields)) {
// Build the source and destination identifier maps.
- $this->sourceIdFields = array();
+ $this->sourceIdFields = [];
$count = 1;
foreach ($this->migration->getSourcePlugin()->getIds() as $field => $schema) {
$this->sourceIdFields[$field] = 'sourceid' . $count++;
@@ -225,7 +225,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
protected function destinationIdFields() {
if (!isset($this->destinationIdFields)) {
- $this->destinationIdFields = array();
+ $this->destinationIdFields = [];
$count = 1;
foreach ($this->migration->getDestinationPlugin()->getIds() as $field => $schema) {
$this->destinationIdFields[$field] = 'destid' . $count++;
@@ -312,7 +312,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
// Generate appropriate schema info for the map and message tables,
// and map from the source field names to the map/msg field names.
$count = 1;
- $source_id_schema = array();
+ $source_id_schema = [];
$indexes = [];
foreach ($this->migration->getSourcePlugin()->getIds() as $id_definition) {
$mapkey = 'sourceid' . $count++;
@@ -321,12 +321,12 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$source_id_schema[$mapkey]['not null'] = TRUE;
}
- $source_ids_hash[static::SOURCE_IDS_HASH] = array(
+ $source_ids_hash[static::SOURCE_IDS_HASH] = [
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'description' => 'Hash of source ids. Used as primary key',
- );
+ ];
$fields = $source_ids_hash + $source_id_schema;
// Add destination identifiers to map table.
@@ -338,69 +338,69 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$fields[$mapkey] = $this->getFieldSchema($id_definition);
$fields[$mapkey]['not null'] = FALSE;
}
- $fields['source_row_status'] = array(
+ $fields['source_row_status'] = [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => MigrateIdMapInterface::STATUS_IMPORTED,
'description' => 'Indicates current status of the source row',
- );
- $fields['rollback_action'] = array(
+ ];
+ $fields['rollback_action'] = [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => MigrateIdMapInterface::ROLLBACK_DELETE,
'description' => 'Flag indicating what to do for this item on rollback',
- );
- $fields['last_imported'] = array(
+ ];
+ $fields['last_imported'] = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'UNIX timestamp of the last time this row was imported',
- );
- $fields['hash'] = array(
+ ];
+ $fields['hash'] = [
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
- );
- $schema = array(
+ ];
+ $schema = [
'description' => 'Mappings from source identifier value(s) to destination identifier value(s).',
'fields' => $fields,
- 'primary key' => array(static::SOURCE_IDS_HASH),
+ 'primary key' => [static::SOURCE_IDS_HASH],
'indexes' => $indexes,
- );
+ ];
$this->getDatabase()->schema()->createTable($this->mapTableName, $schema);
// Now do the message table.
if (!$this->getDatabase()->schema()->tableExists($this->messageTableName())) {
- $fields = array();
- $fields['msgid'] = array(
+ $fields = [];
+ $fields['msgid'] = [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- );
+ ];
$fields += $source_ids_hash;
- $fields['level'] = array(
+ $fields['level'] = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
- );
- $fields['message'] = array(
+ ];
+ $fields['message'] = [
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
- );
- $schema = array(
+ ];
+ $schema = [
'description' => 'Messages generated during a migration process',
'fields' => $fields,
- 'primary key' => array('msgid'),
- );
+ 'primary key' => ['msgid'],
+ ];
$this->getDatabase()->schema()->createTable($this->messageTableName(), $schema);
}
}
@@ -409,33 +409,33 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName,
'rollback_action')) {
$this->getDatabase()->schema()->addField($this->mapTableName, 'rollback_action',
- array(
+ [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating what to do for this item on rollback',
- )
+ ]
);
}
if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName, 'hash')) {
$this->getDatabase()->schema()->addField($this->mapTableName, 'hash',
- array(
+ [
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
- )
+ ]
);
}
if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName, static::SOURCE_IDS_HASH)) {
- $this->getDatabase()->schema()->addField($this->mapTableName, static::SOURCE_IDS_HASH, array(
+ $this->getDatabase()->schema()->addField($this->mapTableName, static::SOURCE_IDS_HASH, [
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'description' => 'Hash of source ids. Used as primary key',
- ));
+ ]);
}
}
}
@@ -508,7 +508,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
* {@inheritdoc}
*/
public function getRowsNeedingUpdate($count) {
- $rows = array();
+ $rows = [];
$result = $this->getDatabase()->select($this->mapTableName(), 'map')
->fields('map')
->condition('source_row_status', MigrateIdMapInterface::STATUS_NEEDS_UPDATE)
@@ -541,7 +541,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function lookupDestinationId(array $source_id_values) {
$results = $this->lookupDestinationIds($source_id_values);
- return $results ? reset($results) : array();
+ return $results ? reset($results) : [];
}
/**
@@ -549,7 +549,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function lookupDestinationIds(array $source_id_values) {
if (empty($source_id_values)) {
- return array();
+ return [];
}
// Canonicalize the keys into a hash of DB-field => value.
@@ -605,7 +605,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
if (!isset($source_id_values[$field_name])) {
$this->message->display($this->t(
'Did not save to map table due to NULL value for key field @field',
- array('@field' => $field_name)), 'error');
+ ['@field' => $field_name]), 'error');
return;
}
$fields[$key_name] = $source_id_values[$field_name];
@@ -615,11 +615,11 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
return;
}
- $fields += array(
+ $fields += [
'source_row_status' => (int) $source_row_status,
'rollback_action' => (int) $rollback_action,
'hash' => $row->getHash(),
- );
+ ];
$count = 0;
foreach ($destination_id_values as $dest_id) {
$fields['destid' . ++$count] = $dest_id;
@@ -683,7 +683,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function prepareUpdate() {
$this->getDatabase()->update($this->mapTableName())
- ->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
+ ->fields(['source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE])
->execute();
}
@@ -702,7 +702,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function importedCount() {
return $this->getDatabase()->select($this->mapTableName())
- ->condition('source_row_status', array(MigrateIdMapInterface::STATUS_IMPORTED, MigrateIdMapInterface::STATUS_NEEDS_UPDATE), 'IN')
+ ->condition('source_row_status', [MigrateIdMapInterface::STATUS_IMPORTED, MigrateIdMapInterface::STATUS_NEEDS_UPDATE], 'IN')
->countQuery()
->execute()
->fetchField();
@@ -797,7 +797,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
}
$query = $this->getDatabase()
->update($this->mapTableName())
- ->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE));
+ ->fields(['source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE]);
foreach ($this->sourceIdFields() as $field_name => $source_id) {
$query->condition($source_id, $source_id_values[$field_name]);
@@ -827,7 +827,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function rewind() {
$this->currentRow = NULL;
- $fields = array();
+ $fields = [];
foreach ($this->sourceIdFields() as $field) {
$fields[] = $field;
}
@@ -866,7 +866,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function currentDestination() {
if ($this->valid()) {
- $result = array();
+ $result = [];
foreach ($this->destinationIdFields() as $destination_field_name => $idmap_field_name) {
if (!is_null($this->currentRow[$idmap_field_name])) {
$result[$destination_field_name] = $this->currentRow[$idmap_field_name];
@@ -884,7 +884,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function currentSource() {
if ($this->valid()) {
- $result = array();
+ $result = [];
foreach ($this->sourceIdFields() as $field_name => $source_id) {
$result[$field_name] = $this->currentKey[$source_id];
}
@@ -903,7 +903,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function next() {
$this->currentRow = $this->result->fetchAssoc();
- $this->currentKey = array();
+ $this->currentKey = [];
if ($this->currentRow) {
foreach ($this->sourceIdFields() as $map_field) {
$this->currentKey[$map_field] = $this->currentRow[$map_field];
diff --git a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php
index 58aa463500e..f24131244f9 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php
@@ -89,11 +89,11 @@ class FileCopy extends ProcessPluginBase implements ContainerFactoryPluginInterf
* An instance of the download plugin for handling remote URIs.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, StreamWrapperManagerInterface $stream_wrappers, FileSystemInterface $file_system, MigrateProcessInterface $download_plugin) {
- $configuration += array(
+ $configuration += [
'move' => FALSE,
'rename' => FALSE,
'reuse' => FALSE,
- );
+ ];
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->streamWrapperManager = $stream_wrappers;
$this->fileSystem = $file_system;
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Get.php b/core/modules/migrate/src/Plugin/migrate/process/Get.php
index f6b3c34e859..21f42652db4 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Get.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Get.php
@@ -29,8 +29,8 @@ class Get extends ProcessPluginBase {
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$source = $this->configuration['source'];
- $properties = is_string($source) ? array($source) : $source;
- $return = array();
+ $properties = is_string($source) ? [$source] : $source;
+ $return = [];
foreach ($properties as $property) {
if ($property || (string) $property === '0') {
$is_source = TRUE;
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php
index 2a41c4a9a8a..d85abfdb3b8 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php
@@ -51,7 +51,7 @@ class Iterator extends ProcessPluginBase {
* The transformed key.
*/
protected function transformKey($key, MigrateExecutableInterface $migrate_executable, Row $row) {
- $process = array('key' => $this->configuration['key']);
+ $process = ['key' => $this->configuration['key']];
$migrate_executable->processRow($row, $process, $key);
return $row->getDestinationProperty('key');
}
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Migration.php b/core/modules/migrate/src/Plugin/migrate/process/Migration.php
index 8520a5ec3d0..e07505ff597 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Migration.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Migration.php
@@ -75,23 +75,23 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$migration_ids = $this->configuration['migration'];
if (!is_array($migration_ids)) {
- $migration_ids = array($migration_ids);
+ $migration_ids = [$migration_ids];
}
if (!is_array($value)) {
- $value = array($value);
+ $value = [$value];
}
$this->skipOnEmpty($value);
$self = FALSE;
/** @var \Drupal\migrate\Plugin\MigrationInterface[] $migrations */
$destination_ids = NULL;
- $source_id_values = array();
+ $source_id_values = [];
$migrations = $this->migrationPluginManager->createInstances($migration_ids);
foreach ($migrations as $migration_id => $migration) {
if ($migration_id == $this->migration->id()) {
$self = TRUE;
}
if (isset($this->configuration['source_ids'][$migration_id])) {
- $configuration = array('source' => $this->configuration['source_ids'][$migration_id]);
+ $configuration = ['source' => $this->configuration['source_ids'][$migration_id]];
$source_id_values[$migration_id] = $this->processPluginManager
->createInstance('get', $configuration, $this->migration)
->transform(NULL, $migrate_executable, $row, $destination_property);
@@ -128,7 +128,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
// We already have the source ID values but need to key them for the Row
// constructor.
$source_ids = $migration->getSourcePlugin()->getIds();
- $values = array();
+ $values = [];
foreach (array_keys($source_ids) as $index => $source_id) {
$values[$source_id] = $source_id_values[$migration->id()][$index];
}
@@ -137,7 +137,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
// Do a normal migration with the stub row.
$migrate_executable->processRow($stub_row, $process);
- $destination_ids = array();
+ $destination_ids = [];
try {
$destination_ids = $destination_plugin->import($stub_row);
}
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Route.php b/core/modules/migrate/src/Plugin/migrate/process/Route.php
index 7ff4720488a..515db978a4d 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Route.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Route.php
@@ -64,12 +64,12 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
}
$extracted = $this->pathValidator->getUrlIfValidWithoutAccessCheck($link_path);
- $route = array();
+ $route = [];
if ($extracted) {
if ($extracted->isExternal()) {
$route['route_name'] = NULL;
- $route['route_parameters'] = array();
+ $route['route_parameters'] = [];
$route['options'] = $options;
$route['url'] = $extracted->getUri();
}
diff --git a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php
index 769da3b7eb2..d3c93ed5944 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php
@@ -31,7 +31,7 @@ class StaticMap extends ProcessPluginBase {
}
}
else {
- $new_value = array($value);
+ $new_value = [$value];
}
$new_value = NestedArray::getValue($this->configuration['map'], $new_value, $key_exists);
if (!$key_exists) {
diff --git a/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php b/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php
index eab6918f481..4e385602f46 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/UrlEncode.php
@@ -44,7 +44,7 @@ class UrlEncode extends ProcessPluginBase {
throw new MigrateException("Value '$value' is not a valid URL");
}
// Iterate over specific pieces of the URL rawurlencoding each one.
- $url_parts_to_encode = array('path', 'query', 'fragment');
+ $url_parts_to_encode = ['path', 'query', 'fragment'];
foreach ($parsed_url as $parsed_url_key => $parsed_url_value) {
if (in_array($parsed_url_key, $url_parts_to_encode)) {
// urlencode() would convert spaces to + signs.
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
index 64b3201bbe8..2391b0a2514 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
@@ -17,16 +17,16 @@ class EmptySource extends SourcePluginBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'id' => t('ID'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function initializeIterator() {
- return new \ArrayIterator(array(array('id' => '')));
+ return new \ArrayIterator([['id' => '']]);
}
/**
diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
index 23d03cfd032..e35585034e5 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
@@ -198,8 +198,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
public function prepareRow(Row $row) {
$result = TRUE;
try {
- $result_hook = $this->getModuleHandler()->invokeAll('migrate_prepare_row', array($row, $this, $this->migration));
- $result_named_hook = $this->getModuleHandler()->invokeAll('migrate_' . $this->migration->id() . '_prepare_row', array($row, $this, $this->migration));
+ $result_hook = $this->getModuleHandler()->invokeAll('migrate_prepare_row', [$row, $this, $this->migration]);
+ $result_named_hook = $this->getModuleHandler()->invokeAll('migrate_' . $this->migration->id() . '_prepare_row', [$row, $this, $this->migration]);
// We will skip if any hook returned FALSE.
$skip = ($result_hook && in_array(FALSE, $result_hook)) || ($result_named_hook && in_array(FALSE, $result_named_hook));
$save_to_map = TRUE;
@@ -217,7 +217,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
// Make sure we replace any previous messages for this item with any
// new ones.
if ($save_to_map) {
- $this->idMap->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_IGNORED);
+ $this->idMap->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_IGNORED);
$this->currentRow = NULL;
$this->currentSourceIds = NULL;
}
diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
index b78df3b2dca..380814c6fd8 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
@@ -180,7 +180,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
/**
* Wrapper for database select.
*/
- protected function select($table, $alias = NULL, array $options = array()) {
+ protected function select($table, $alias = NULL, array $options = []) {
$options['fetch'] = \PDO::FETCH_ASSOC;
return $this->getDatabase()->select($table, $alias, $options);
}
@@ -220,7 +220,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
$this->prepareQuery();
// Get the key values, for potential use in joining to the map table.
- $keys = array();
+ $keys = [];
// The rules for determining what conditions to add to the query are as
// follows (applying first applicable rule):
@@ -356,7 +356,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
return FALSE;
}
- foreach (array('username', 'password', 'host', 'port', 'namespace', 'driver') as $key) {
+ foreach (['username', 'password', 'host', 'port', 'namespace', 'driver'] as $key) {
if (isset($source_database_options[$key])) {
if ($id_map_database_options[$key] != $source_database_options[$key]) {
return FALSE;
diff --git a/core/modules/migrate/src/Row.php b/core/modules/migrate/src/Row.php
index ea70acdf04a..2824dd92bcb 100644
--- a/core/modules/migrate/src/Row.php
+++ b/core/modules/migrate/src/Row.php
@@ -15,21 +15,21 @@ class Row {
*
* @var array
*/
- protected $source = array();
+ protected $source = [];
/**
* The source identifiers.
*
* @var array
*/
- protected $sourceIds = array();
+ protected $sourceIds = [];
/**
* The destination values.
*
* @var array
*/
- protected $destination = array();
+ protected $destination = [];
/**
* Level separator of destination and source properties.
@@ -41,11 +41,11 @@ class Row {
*
* @var array
*/
- protected $idMap = array(
+ protected $idMap = [
'original_hash' => '',
'hash' => '',
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
- );
+ ];
/**
* Whether the source has been frozen already.
diff --git a/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php b/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php
index 45420d3d8b7..415d000b9c0 100644
--- a/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php
+++ b/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php
@@ -32,7 +32,7 @@ class DummyDestination extends DestinationBase {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
return ['value' => $row->getDestinationProperty('value')];
}
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateEventsTest.php b/core/modules/migrate/tests/src/Kernel/MigrateEventsTest.php
index b332cbdbfdc..4de21fde02a 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateEventsTest.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateEventsTest.php
@@ -40,17 +40,17 @@ class MigrateEventsTest extends KernelTestBase {
parent::setUp();
$this->state = \Drupal::state();
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::MAP_SAVE,
- array($this, 'mapSaveEventRecorder'));
+ [$this, 'mapSaveEventRecorder']);
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::MAP_DELETE,
- array($this, 'mapDeleteEventRecorder'));
+ [$this, 'mapDeleteEventRecorder']);
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::PRE_IMPORT,
- array($this, 'preImportEventRecorder'));
+ [$this, 'preImportEventRecorder']);
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::POST_IMPORT,
- array($this, 'postImportEventRecorder'));
+ [$this, 'postImportEventRecorder']);
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::PRE_ROW_SAVE,
- array($this, 'preRowSaveEventRecorder'));
+ [$this, 'preRowSaveEventRecorder']);
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::POST_ROW_SAVE,
- array($this, 'postRowSaveEventRecorder'));
+ [$this, 'postRowSaveEventRecorder']);
}
/**
@@ -129,11 +129,11 @@ class MigrateEventsTest extends KernelTestBase {
* The event name.
*/
public function mapSaveEventRecorder(MigrateMapSaveEvent $event, $name) {
- $this->state->set('migrate_events_test.map_save_event', array(
+ $this->state->set('migrate_events_test.map_save_event', [
'event_name' => $name,
'map' => $event->getMap(),
'fields' => $event->getFields(),
- ));
+ ]);
}
/**
@@ -145,11 +145,11 @@ class MigrateEventsTest extends KernelTestBase {
* The event name.
*/
public function mapDeleteEventRecorder(MigrateMapDeleteEvent $event, $name) {
- $this->state->set('migrate_events_test.map_delete_event', array(
+ $this->state->set('migrate_events_test.map_delete_event', [
'event_name' => $name,
'map' => $event->getMap(),
'source_id' => $event->getSourceId(),
- ));
+ ]);
}
/**
@@ -161,10 +161,10 @@ class MigrateEventsTest extends KernelTestBase {
* The event name.
*/
public function preImportEventRecorder(MigrateImportEvent $event, $name) {
- $this->state->set('migrate_events_test.pre_import_event', array(
+ $this->state->set('migrate_events_test.pre_import_event', [
'event_name' => $name,
'migration' => $event->getMigration(),
- ));
+ ]);
}
/**
@@ -176,10 +176,10 @@ class MigrateEventsTest extends KernelTestBase {
* The event name.
*/
public function postImportEventRecorder(MigrateImportEvent $event, $name) {
- $this->state->set('migrate_events_test.post_import_event', array(
+ $this->state->set('migrate_events_test.post_import_event', [
'event_name' => $name,
'migration' => $event->getMigration(),
- ));
+ ]);
}
/**
@@ -191,11 +191,11 @@ class MigrateEventsTest extends KernelTestBase {
* The event name.
*/
public function preRowSaveEventRecorder(MigratePreRowSaveEvent $event, $name) {
- $this->state->set('migrate_events_test.pre_row_save_event', array(
+ $this->state->set('migrate_events_test.pre_row_save_event', [
'event_name' => $name,
'migration' => $event->getMigration(),
'row' => $event->getRow(),
- ));
+ ]);
}
/**
@@ -207,12 +207,12 @@ class MigrateEventsTest extends KernelTestBase {
* The event name.
*/
public function postRowSaveEventRecorder(MigratePostRowSaveEvent $event, $name) {
- $this->state->set('migrate_events_test.post_row_save_event', array(
+ $this->state->set('migrate_events_test.post_row_save_event', [
'event_name' => $name,
'migration' => $event->getMigration(),
'row' => $event->getRow(),
'destination_id_values' => $event->getDestinationIdValues(),
- ));
+ ]);
}
}
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateExternalTranslatedTest.php b/core/modules/migrate/tests/src/Kernel/MigrateExternalTranslatedTest.php
index 384b8067111..d9728f587e0 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateExternalTranslatedTest.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateExternalTranslatedTest.php
@@ -27,7 +27,7 @@ class MigrateExternalTranslatedTest extends MigrateTestBase {
public function setUp() {
parent::setUp();
$this->installSchema('system', ['sequences']);
- $this->installSchema('node', array('node_access'));
+ $this->installSchema('node', ['node_access']);
$this->installEntitySchema('user');
$this->installEntitySchema('node');
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php b/core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php
index 9ff76f6a486..d99329e1818 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php
@@ -29,7 +29,7 @@ class MigrateInterruptionTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::POST_ROW_SAVE,
- array($this, 'postRowSaveEventRecorder'));
+ [$this, 'postRowSaveEventRecorder']);
}
/**
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php b/core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php
index 4f4af7dac56..33013367e9b 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateMessageTest.php
@@ -89,7 +89,7 @@ class MigrateMessageTest extends KernelTestBase implements MigrateMessageInterfa
public function testMessagesTeed() {
// Ask to receive any messages sent to the idmap.
\Drupal::service('event_dispatcher')->addListener(MigrateEvents::IDMAP_MESSAGE,
- array($this, 'mapMessageRecorder'));
+ [$this, 'mapMessageRecorder']);
$executable = new MigrateExecutable($this->migration, $this);
$executable->import();
$this->assertIdentical(count($this->messages), 1);
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateStatusTest.php b/core/modules/migrate/tests/src/Kernel/MigrateStatusTest.php
index b31a67ee8a2..7dc0b5b9b63 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateStatusTest.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateStatusTest.php
@@ -33,13 +33,13 @@ class MigrateStatusTest extends MigrateTestBase {
$this->assertIdentical($status, MigrationInterface::STATUS_IDLE);
// Test setting and retrieving all known status values.
- $status_list = array(
+ $status_list = [
MigrationInterface::STATUS_IDLE,
MigrationInterface::STATUS_IMPORTING,
MigrationInterface::STATUS_ROLLING_BACK,
MigrationInterface::STATUS_STOPPING,
MigrationInterface::STATUS_DISABLED,
- );
+ ];
foreach ($status_list as $status) {
$migration->setStatus($status);
$this->assertIdentical($migration->getStatus(), $status);
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php b/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php
index 8494dc6a450..b0fc0b8aada 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateTestBase.php
@@ -47,7 +47,7 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
*/
protected $sourceDatabase;
- public static $modules = array('migrate');
+ public static $modules = ['migrate'];
/**
* {@inheritdoc}
@@ -201,7 +201,7 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
*/
public function startCollectingMessages() {
$this->collectMessages = TRUE;
- $this->migrateMessages = array();
+ $this->migrateMessages = [];
}
/**
diff --git a/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php b/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php
index a7b0dac1022..ef15bd575a2 100644
--- a/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php
+++ b/core/modules/migrate/tests/src/Kernel/SqlBaseTest.php
@@ -30,7 +30,7 @@ class SqlBaseTest extends MigrateTestBase {
$target = 'test_db_target';
$key = 'test_migrate_connection';
- $config = array('target' => $target, 'key' => $key);
+ $config = ['target' => $target, 'key' => $key];
$sql_base->setConfiguration($config);
Database::addConnectionInfo($key, $target, Database::getConnectionInfo('default')['default']);
@@ -44,7 +44,7 @@ class SqlBaseTest extends MigrateTestBase {
$target = 'test_db_target2';
$key = 'test_migrate_connection2';
$database = Database::getConnectionInfo('default')['default'];
- $config = array('target' => $target, 'key' => $key, 'database' => $database);
+ $config = ['target' => $target, 'key' => $key, 'database' => $database];
$sql_base->setConfiguration($config);
// Call getDatabase() to get the connection defined.
diff --git a/core/modules/migrate/tests/src/Unit/Exception/RequirementsExceptionTest.php b/core/modules/migrate/tests/src/Unit/Exception/RequirementsExceptionTest.php
index 72d37ed73f2..b3fafc8ec1b 100644
--- a/core/modules/migrate/tests/src/Unit/Exception/RequirementsExceptionTest.php
+++ b/core/modules/migrate/tests/src/Unit/Exception/RequirementsExceptionTest.php
@@ -34,18 +34,18 @@ class RequirementsExceptionTest extends UnitTestCase {
* Provides a list of requirements to test.
*/
public function getRequirementsProvider() {
- return array(
- array(
+ return [
+ [
'requirements: random_jackson_pivot.',
'Single Requirement',
- array('requirements' => $this->missingRequirements[0]),
- ),
- array(
+ ['requirements' => $this->missingRequirements[0]],
+ ],
+ [
'requirements: random_jackson_pivot. requirements: 51_Eridani_b.',
'Multiple Requirements',
- array('requirements' => $this->missingRequirements),
- ),
- );
+ ['requirements' => $this->missingRequirements],
+ ],
+ ];
}
}
diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php
index 42d500d81c7..d14e54a4278 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php
@@ -35,9 +35,9 @@ class MigrateExecutableMemoryExceededTest extends MigrateTestCase {
*
* @var array
*/
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- );
+ ];
/**
* The php.ini memory_limit value.
diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
index 60809a90d76..ff320df6c4e 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
@@ -40,9 +40,9 @@ class MigrateExecutableTest extends MigrateTestCase {
*
* @var array
*/
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- );
+ ];
/**
* {@inheritdoc}
@@ -91,12 +91,12 @@ class MigrateExecutableTest extends MigrateTestCase {
$row->expects($this->once())
->method('getSourceIdValues')
- ->will($this->returnValue(array('id' => 'test')));
+ ->will($this->returnValue(['id' => 'test']));
$this->idMap->expects($this->once())
->method('lookupDestinationId')
- ->with(array('id' => 'test'))
- ->will($this->returnValue(array('test')));
+ ->with(['id' => 'test'])
+ ->will($this->returnValue(['test']));
$source->expects($this->once())
->method('current')
@@ -106,13 +106,13 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once())
->method('getProcessPlugins')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
- ->with($row, array('test'))
- ->will($this->returnValue(array('id' => 'test')));
+ ->with($row, ['test'])
+ ->will($this->returnValue(['id' => 'test']));
$this->migration
->method('getDestinationPlugin')
@@ -133,12 +133,12 @@ class MigrateExecutableTest extends MigrateTestCase {
$row->expects($this->once())
->method('getSourceIdValues')
- ->will($this->returnValue(array('id' => 'test')));
+ ->will($this->returnValue(['id' => 'test']));
$this->idMap->expects($this->once())
->method('lookupDestinationId')
- ->with(array('id' => 'test'))
- ->will($this->returnValue(array('test')));
+ ->with(['id' => 'test'])
+ ->will($this->returnValue(['test']));
$source->expects($this->once())
->method('current')
@@ -148,12 +148,12 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once())
->method('getProcessPlugins')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
- ->with($row, array('test'))
+ ->with($row, ['test'])
->will($this->returnValue(TRUE));
$this->migration
@@ -178,7 +178,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$row->expects($this->once())
->method('getSourceIdValues')
- ->will($this->returnValue(array('id' => 'test')));
+ ->will($this->returnValue(['id' => 'test']));
$source->expects($this->once())
->method('current')
@@ -188,13 +188,13 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once())
->method('getProcessPlugins')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
- ->with($row, array('test'))
- ->will($this->returnValue(array()));
+ ->with($row, ['test'])
+ ->will($this->returnValue([]));
$this->migration
->method('getDestinationPlugin')
@@ -202,7 +202,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->idMap->expects($this->once())
->method('saveIdMapping')
- ->with($row, array(), MigrateIdMapInterface::STATUS_FAILED, NULL);
+ ->with($row, [], MigrateIdMapInterface::STATUS_FAILED, NULL);
$this->idMap->expects($this->once())
->method('messageCount')
@@ -213,8 +213,8 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->idMap->expects($this->once())
->method('lookupDestinationId')
- ->with(array('id' => 'test'))
- ->will($this->returnValue(array('test')));
+ ->with(['id' => 'test'])
+ ->will($this->returnValue(['test']));
$this->message->expects($this->once())
->method('display')
@@ -238,7 +238,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$row->expects($this->once())
->method('getSourceIdValues')
- ->will($this->returnValue(array('id' => 'test')));
+ ->will($this->returnValue(['id' => 'test']));
$source->expects($this->once())
->method('current')
@@ -248,12 +248,12 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once())
->method('getProcessPlugins')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
- ->with($row, array('test'))
+ ->with($row, ['test'])
->will($this->throwException(new MigrateException($exception_message)));
$this->migration
@@ -262,15 +262,15 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->idMap->expects($this->once())
->method('saveIdMapping')
- ->with($row, array(), MigrateIdMapInterface::STATUS_FAILED, NULL);
+ ->with($row, [], MigrateIdMapInterface::STATUS_FAILED, NULL);
$this->idMap->expects($this->once())
->method('saveMessage');
$this->idMap->expects($this->once())
->method('lookupDestinationId')
- ->with(array('id' => 'test'))
- ->will($this->returnValue(array('test')));
+ ->with(['id' => 'test'])
+ ->will($this->returnValue(['test']));
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
}
@@ -290,7 +290,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$row->expects($this->once())
->method('getSourceIdValues')
- ->willReturn(array('id' => 'test'));
+ ->willReturn(['id' => 'test']);
$source->expects($this->once())
->method('current')
@@ -312,7 +312,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->idMap->expects($this->once())
->method('saveIdMapping')
- ->with($row, array(), MigrateIdMapInterface::STATUS_FAILED, NULL);
+ ->with($row, [], MigrateIdMapInterface::STATUS_FAILED, NULL);
$this->idMap->expects($this->once())
->method('saveMessage');
@@ -336,7 +336,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$row->expects($this->once())
->method('getSourceIdValues')
- ->will($this->returnValue(array('id' => 'test')));
+ ->will($this->returnValue(['id' => 'test']));
$source->expects($this->once())
->method('current')
@@ -346,12 +346,12 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once())
->method('getProcessPlugins')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
- ->with($row, array('test'))
+ ->with($row, ['test'])
->will($this->throwException(new \Exception($exception_message)));
$this->migration
@@ -360,15 +360,15 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->idMap->expects($this->once())
->method('saveIdMapping')
- ->with($row, array(), MigrateIdMapInterface::STATUS_FAILED, NULL);
+ ->with($row, [], MigrateIdMapInterface::STATUS_FAILED, NULL);
$this->idMap->expects($this->once())
->method('saveMessage');
$this->idMap->expects($this->once())
->method('lookupDestinationId')
- ->with(array('id' => 'test'))
- ->will($this->returnValue(array('test')));
+ ->with(['id' => 'test'])
+ ->will($this->returnValue(['test']));
$this->message->expects($this->once())
->method('display')
@@ -381,15 +381,15 @@ class MigrateExecutableTest extends MigrateTestCase {
* Tests the processRow method.
*/
public function testProcessRow() {
- $expected = array(
+ $expected = [
'test' => 'test destination',
'test1' => 'test1 destination'
- );
+ ];
foreach ($expected as $key => $value) {
$plugins[$key][0] = $this->getMock('Drupal\migrate\Plugin\MigrateProcessInterface');
$plugins[$key][0]->expects($this->once())
->method('getPluginDefinition')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$plugins[$key][0]->expects($this->once())
->method('transform')
->will($this->returnValue($value));
@@ -413,10 +413,10 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once())
->method('getProcessPlugins')
->with(NULL)
- ->will($this->returnValue(array('test' => array())));
+ ->will($this->returnValue(['test' => []]));
$row = new Row();
$this->executable->processRow($row);
- $this->assertSame($row->getDestination(), array());
+ $this->assertSame($row->getDestination(), []);
}
/**
diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
index 3c9aa4234a6..3c3cba8859d 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
@@ -16,70 +16,70 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
*
* @var array
*/
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'sql_idmap_test',
- );
+ ];
/**
* Tests the ensureTables method when the tables do not exist.
*/
public function testEnsureTablesNotExist() {
- $fields['source_ids_hash'] = Array(
+ $fields['source_ids_hash'] = [
'type' => 'varchar',
'length' => 64,
'not null' => 1,
'description' => 'Hash of source ids. Used as primary key'
- );
- $fields['sourceid1'] = array(
+ ];
+ $fields['sourceid1'] = [
'type' => 'int',
'not null' => TRUE,
- );
- $fields['sourceid2'] = array(
+ ];
+ $fields['sourceid2'] = [
'type' => 'int',
'not null' => TRUE,
- );
- $fields['destid1'] = array(
+ ];
+ $fields['destid1'] = [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
- );
- $fields['source_row_status'] = array(
+ ];
+ $fields['source_row_status'] = [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => MigrateIdMapInterface::STATUS_IMPORTED,
'description' => 'Indicates current status of the source row',
- );
- $fields['rollback_action'] = array(
+ ];
+ $fields['rollback_action'] = [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => MigrateIdMapInterface::ROLLBACK_DELETE,
'description' => 'Flag indicating what to do for this item on rollback',
- );
- $fields['last_imported'] = array(
+ ];
+ $fields['last_imported'] = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'UNIX timestamp of the last time this row was imported',
- );
- $fields['hash'] = array(
+ ];
+ $fields['hash'] = [
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
- );
- $map_table_schema = array(
+ ];
+ $map_table_schema = [
'description' => 'Mappings from source identifier value(s) to destination identifier value(s).',
'fields' => $fields,
- 'primary key' => array('source_ids_hash'),
+ 'primary key' => ['source_ids_hash'],
'indexes' => [
'source' => ['sourceid1', 'sourceid2'],
],
- );
+ ];
$schema = $this->getMockBuilder('Drupal\Core\Database\Schema')
->disableOriginalConstructor()
->getMock();
@@ -91,34 +91,34 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
->method('createTable')
->with('migrate_map_sql_idmap_test', $map_table_schema);
// Now do the message table.
- $fields = array();
- $fields['msgid'] = array(
+ $fields = [];
+ $fields['msgid'] = [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- );
- $fields['source_ids_hash'] = Array(
+ ];
+ $fields['source_ids_hash'] = [
'type' => 'varchar',
'length' => 64,
'not null' => 1,
'description' => 'Hash of source ids. Used as primary key'
- );
- $fields['level'] = array(
+ ];
+ $fields['level'] = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
- );
- $fields['message'] = array(
+ ];
+ $fields['message'] = [
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
- );
- $table_schema = array(
+ ];
+ $table_schema = [
'description' => 'Messages generated during a migration process',
'fields' => $fields,
- 'primary key' => array('msgid'),
- );
+ 'primary key' => ['msgid'],
+ ];
$schema->expects($this->at(2))
->method('tableExists')
@@ -147,14 +147,14 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
->method('fieldExists')
->with('migrate_map_sql_idmap_test', 'rollback_action')
->will($this->returnValue(FALSE));
- $field_schema = array(
+ $field_schema = [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating what to do for this item on rollback',
- );
+ ];
$schema->expects($this->at(2))
->method('addField')
->with('migrate_map_sql_idmap_test', 'rollback_action', $field_schema);
@@ -162,12 +162,12 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
->method('fieldExists')
->with('migrate_map_sql_idmap_test', 'hash')
->will($this->returnValue(FALSE));
- $field_schema = array(
+ $field_schema = [
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
- );
+ ];
$schema->expects($this->at(4))
->method('addField')
->with('migrate_map_sql_idmap_test', 'hash', $field_schema);
@@ -175,12 +175,12 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
->method('fieldExists')
->with('migrate_map_sql_idmap_test', 'source_ids_hash')
->will($this->returnValue(FALSE));
- $field_schema = array(
+ $field_schema = [
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'description' => 'Hash of source ids. Used as primary key',
- );
+ ];
$schema->expects($this->at(6))
->method('addField')
->with('migrate_map_sql_idmap_test', 'source_ids_hash', $field_schema);
@@ -208,31 +208,31 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
$plugin = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin->expects($this->any())
->method('getIds')
- ->willReturn(array(
- 'source_id_property' => array(
+ ->willReturn([
+ 'source_id_property' => [
'type' => 'integer',
- ),
- 'source_id_property_2' => array(
+ ],
+ 'source_id_property_2' => [
'type' => 'integer',
- ),
- ));
+ ],
+ ]);
$migration->expects($this->any())
->method('getSourcePlugin')
->willReturn($plugin);
$plugin = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin->expects($this->any())
->method('getIds')
- ->willReturn(array(
- 'destination_id_property' => array(
+ ->willReturn([
+ 'destination_id_property' => [
'type' => 'string',
- ),
- ));
+ ],
+ ]);
$migration->expects($this->any())
->method('getDestinationPlugin')
->willReturn($plugin);
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */
$event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
- $map = new TestSqlIdMap($database, array(), 'sql', array(), $migration, $event_dispatcher);
+ $map = new TestSqlIdMap($database, [], 'sql', [], $migration, $event_dispatcher);
$map->getDatabase();
}
diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
index e38e971be3b..2ad2b3dc518 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
@@ -130,11 +130,11 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
* - hash
*/
protected function idMapDefaults() {
- $defaults = array(
+ $defaults = [
'source_row_status' => MigrateIdMapInterface::STATUS_IMPORTED,
'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
'hash' => '',
- );
+ ];
// By default, the PDO SQLite driver strongly prefers to return strings
// from SELECT queries. Even for columns that don't store strings. Even
// if the connection's STRINGIFY_FETCHES attribute is FALSE. This can cause
@@ -157,9 +157,9 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
* - updating work.
*/
public function testSaveIdMapping() {
- $source = array(
+ $source = [
'source_id_property' => 'source_value',
- );
+ ];
$row = new Row($source, ['source_id_property' => []]);
$id_map = $this->getIdMap();
$id_map->saveIdMapping($row, ['destination_id_property' => 2]);
diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php b/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
index 962a75dca62..be600c8d4f4 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
@@ -33,7 +33,7 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
*
* @var array
*/
- protected $databaseContents = array();
+ protected $databaseContents = [];
/**
* The plugin class under test.
@@ -60,7 +60,7 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
*
* @var array
*/
- protected $expectedResults = array();
+ protected $expectedResults = [];
/**
* Expected count of source rows.
@@ -112,7 +112,7 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
// Setup the plugin.
$plugin_class = static::PLUGIN_CLASS;
- $plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], array(), $migration, $state, $entity_manager);
+ $plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], [], $migration, $state, $entity_manager);
// Do some reflection to set the database and moduleHandler.
$plugin_reflection = new \ReflectionClass($plugin);
@@ -122,7 +122,7 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
$module_handler_property->setAccessible(TRUE);
// Set the database and the module handler onto our plugin.
- $database_property->setValue($plugin, $this->getDatabase($this->databaseContents + array('test_map' => array())));
+ $database_property->setValue($plugin, $this->getDatabase($this->databaseContents + ['test_map' => []]));
$module_handler_property->setValue($plugin, $module_handler);
$plugin->setStringTranslation($this->getStringTranslationStub());
diff --git a/core/modules/migrate/tests/src/Unit/RowTest.php b/core/modules/migrate/tests/src/Unit/RowTest.php
index ec04f826b37..aa3a7d927b5 100644
--- a/core/modules/migrate/tests/src/Unit/RowTest.php
+++ b/core/modules/migrate/tests/src/Unit/RowTest.php
@@ -17,19 +17,19 @@ class RowTest extends UnitTestCase {
*
* @var array
*/
- protected $testSourceIds = array(
+ protected $testSourceIds = [
'nid' => 'Node ID',
- );
+ ];
/**
* The test values.
*
* @var array
*/
- protected $testValues = array(
+ protected $testValues = [
'nid' => 1,
'title' => 'node 1',
- );
+ ];
/**
* The test hash.
@@ -50,7 +50,7 @@ class RowTest extends UnitTestCase {
*/
public function testRowWithoutData() {
$row = new Row();
- $this->assertSame(array(), $row->getSource(), 'Empty row');
+ $this->assertSame([], $row->getSource(), 'Empty row');
}
/**
@@ -65,8 +65,8 @@ class RowTest extends UnitTestCase {
* Tests object creation: multiple source IDs.
*/
public function testRowWithMultipleSourceIds() {
- $multi_source_ids = $this->testSourceIds + array('vid' => 'Node revision');
- $multi_source_ids_values = $this->testValues + array('vid' => 1);
+ $multi_source_ids = $this->testSourceIds + ['vid' => 'Node revision'];
+ $multi_source_ids_values = $this->testValues + ['vid' => 1];
$row = new Row($multi_source_ids_values, $multi_source_ids);
$this->assertSame($multi_source_ids_values, $row->getSource(), 'Row with data, multifield id.');
}
@@ -77,9 +77,9 @@ class RowTest extends UnitTestCase {
* @expectedException \Exception
*/
public function testRowWithInvalidData() {
- $invalid_values = array(
+ $invalid_values = [
'title' => 'node X',
- );
+ ];
$row = new Row($invalid_values, $this->testSourceIds);
}
@@ -123,11 +123,11 @@ class RowTest extends UnitTestCase {
$this->assertSame($this->testHash, $row->getHash(), 'Correct hash even doing it twice.');
// Set the map to needs update.
- $test_id_map = array(
+ $test_id_map = [
'original_hash' => '',
'hash' => '',
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
- );
+ ];
$row->setIdMap($test_id_map);
$this->assertTrue($row->needsUpdate());
@@ -143,30 +143,30 @@ class RowTest extends UnitTestCase {
$this->assertSame(64, strlen($row->getHash()));
// Set the map to successfully imported.
- $test_id_map = array(
+ $test_id_map = [
'original_hash' => '',
'hash' => '',
'source_row_status' => MigrateIdMapInterface::STATUS_IMPORTED,
- );
+ ];
$row->setIdMap($test_id_map);
$this->assertFalse($row->needsUpdate());
// Set the same hash value and ensure it was not changed.
$random = $this->randomMachineName();
- $test_id_map = array(
+ $test_id_map = [
'original_hash' => $random,
'hash' => $random,
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
- );
+ ];
$row->setIdMap($test_id_map);
$this->assertFalse($row->changed());
// Set different has values to ensure it is marked as changed.
- $test_id_map = array(
+ $test_id_map = [
'original_hash' => $this->randomMachineName(),
'hash' => $this->randomMachineName(),
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
- );
+ ];
$row->setIdMap($test_id_map);
$this->assertTrue($row->changed());
}
@@ -179,11 +179,11 @@ class RowTest extends UnitTestCase {
*/
public function testGetSetIdMap() {
$row = new Row($this->testValues, $this->testSourceIds);
- $test_id_map = array(
+ $test_id_map = [
'original_hash' => '',
'hash' => '',
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
- );
+ ];
$row->setIdMap($test_id_map);
$this->assertEquals($test_id_map, $row->getIdMap());
}
@@ -193,7 +193,7 @@ class RowTest extends UnitTestCase {
*/
public function testSourceIdValues() {
$row = new Row($this->testValues, $this->testSourceIds);
- $this->assertSame(array('nid' => $this->testValues['nid']), $row->getSourceIdValues());
+ $this->assertSame(['nid' => $this->testValues['nid']], $row->getSourceIdValues());
}
/**
@@ -219,7 +219,7 @@ class RowTest extends UnitTestCase {
// Set a destination.
$row->setDestinationProperty('nid', 2);
$this->assertTrue($row->hasDestinationProperty('nid'));
- $this->assertEquals(array('nid' => 2), $row->getDestination());
+ $this->assertEquals(['nid' => 2], $row->getDestination());
}
/**
diff --git a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
index b64ca9b1caf..6d3333848f2 100644
--- a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
+++ b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
@@ -55,21 +55,21 @@ class TestSqlIdMap extends Sql implements \Iterator {
*/
protected function getFieldSchema(array $id_definition) {
if (!isset($id_definition['type'])) {
- return array();
+ return [];
}
switch ($id_definition['type']) {
case 'integer':
- return array(
+ return [
'type' => 'int',
'not null' => TRUE,
- );
+ ];
case 'string':
- return array(
+ return [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
- );
+ ];
default:
throw new MigrateException($id_definition['type'] . ' not supported');
diff --git a/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php b/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php
index 25eeebb1802..b57cffea49d 100644
--- a/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php
+++ b/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php
@@ -16,9 +16,9 @@ class ConfigTest extends UnitTestCase {
* Test the import method.
*/
public function testImport() {
- $source = array(
+ $source = [
'test' => 'x',
- );
+ ];
$migration = $this->getMockBuilder('Drupal\migrate\Plugin\Migration')
->disableOriginalConstructor()
->getMock();
@@ -54,7 +54,7 @@ class ConfigTest extends UnitTestCase {
->method('getLanguageConfigOverride')
->with('fr', 'd8_config')
->will($this->returnValue($config));
- $destination = new Config(array('config_name' => 'd8_config'), 'd8_config', array('pluginId' => 'd8_config'), $migration, $config_factory, $language_manager);
+ $destination = new Config(['config_name' => 'd8_config'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row);
$this->assertEquals($destination_id, ['d8_config']);
}
@@ -63,9 +63,9 @@ class ConfigTest extends UnitTestCase {
* Test the import method.
*/
public function testLanguageImport() {
- $source = array(
+ $source = [
'langcode' => 'mi',
- );
+ ];
$migration = $this->getMockBuilder(MigrationInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -104,7 +104,7 @@ class ConfigTest extends UnitTestCase {
->method('getLanguageConfigOverride')
->with('mi', 'd8_config')
->will($this->returnValue($config));
- $destination = new Config(array('config_name' => 'd8_config', 'translations' => 'true'), 'd8_config', array('pluginId' => 'd8_config'), $migration, $config_factory, $language_manager);
+ $destination = new Config(['config_name' => 'd8_config', 'translations' => 'true'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row);
$this->assertEquals($destination_id, ['d8_config', 'mi']);
}
diff --git a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
index 1886914b5ed..f68c2bea1fb 100644
--- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
+++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
@@ -212,7 +212,7 @@ class EntityRevision extends RealEntityRevision {
/**
* Allow public access for testing.
*/
- public function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {
+ public function save(ContentEntityInterface $entity, array $old_destination_id_values = []) {
return parent::save($entity, $old_destination_id_values);
}
diff --git a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php
index 4782dc0f4ad..6deaec88249 100644
--- a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php
+++ b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php
@@ -22,13 +22,13 @@ class PerComponentEntityDisplayTest extends MigrateTestCase {
* Tests the entity display import method.
*/
public function testImport() {
- $values = array(
+ $values = [
'entity_type' => 'entity_type_test',
'bundle' => 'bundle_test',
'view_mode' => 'view_mode_test',
'field_name' => 'field_name_test',
- 'options' => array('test setting'),
- );
+ 'options' => ['test setting'],
+ ];
$row = new Row();
foreach ($values as $key => $value) {
$row->setDestinationProperty($key, $value);
@@ -38,14 +38,14 @@ class PerComponentEntityDisplayTest extends MigrateTestCase {
->getMock();
$entity->expects($this->once())
->method('setComponent')
- ->with('field_name_test', array('test setting'))
+ ->with('field_name_test', ['test setting'])
->will($this->returnSelf());
$entity->expects($this->once())
->method('save')
->with();
$plugin = new TestPerComponentEntityDisplay($entity);
- $this->assertSame($plugin->import($row), array('entity_type_test', 'bundle_test', 'view_mode_test', 'field_name_test'));
- $this->assertSame($plugin->getTestValues(), array('entity_type_test', 'bundle_test', 'view_mode_test'));
+ $this->assertSame($plugin->import($row), ['entity_type_test', 'bundle_test', 'view_mode_test', 'field_name_test']);
+ $this->assertSame($plugin->getTestValues(), ['entity_type_test', 'bundle_test', 'view_mode_test']);
}
}
diff --git a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php
index 50cdbf6dc62..0424cebf07f 100644
--- a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php
+++ b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php
@@ -22,13 +22,13 @@ class PerComponentEntityFormDisplayTest extends MigrateTestCase {
* Tests the entity display import method.
*/
public function testImport() {
- $values = array(
+ $values = [
'entity_type' => 'entity_type_test',
'bundle' => 'bundle_test',
'form_mode' => 'form_mode_test',
'field_name' => 'field_name_test',
- 'options' => array('test setting'),
- );
+ 'options' => ['test setting'],
+ ];
$row = new Row();
foreach ($values as $key => $value) {
$row->setDestinationProperty($key, $value);
@@ -38,14 +38,14 @@ class PerComponentEntityFormDisplayTest extends MigrateTestCase {
->getMock();
$entity->expects($this->once())
->method('setComponent')
- ->with('field_name_test', array('test setting'))
+ ->with('field_name_test', ['test setting'])
->will($this->returnSelf());
$entity->expects($this->once())
->method('save')
->with();
$plugin = new TestPerComponentEntityFormDisplay($entity);
- $this->assertSame($plugin->import($row), array('entity_type_test', 'bundle_test', 'form_mode_test', 'field_name_test'));
- $this->assertSame($plugin->getTestValues(), array('entity_type_test', 'bundle_test', 'form_mode_test'));
+ $this->assertSame($plugin->import($row), ['entity_type_test', 'bundle_test', 'form_mode_test', 'field_name_test']);
+ $this->assertSame($plugin->getTestValues(), ['entity_type_test', 'bundle_test', 'form_mode_test']);
}
}
diff --git a/core/modules/migrate/tests/src/Unit/process/CallbackTest.php b/core/modules/migrate/tests/src/Unit/process/CallbackTest.php
index 92d1f7c3418..e3b8f27708b 100644
--- a/core/modules/migrate/tests/src/Unit/process/CallbackTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/CallbackTest.php
@@ -37,7 +37,7 @@ class CallbackTest extends MigrateProcessTestCase {
* Test callback with a class method as callable.
*/
public function testCallbackWithClassMethod() {
- $this->plugin->setCallable(array('\Drupal\Component\Utility\Unicode', 'strtolower'));
+ $this->plugin->setCallable(['\Drupal\Component\Utility\Unicode', 'strtolower']);
$value = $this->plugin->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($value, 'foobar');
}
diff --git a/core/modules/migrate/tests/src/Unit/process/ConcatTest.php b/core/modules/migrate/tests/src/Unit/process/ConcatTest.php
index 1d0d4c3772c..cae7cc090f5 100644
--- a/core/modules/migrate/tests/src/Unit/process/ConcatTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/ConcatTest.php
@@ -28,7 +28,7 @@ class ConcatTest extends MigrateProcessTestCase {
* Test concat works without a delimiter.
*/
public function testConcatWithoutDelimiter() {
- $value = $this->plugin->transform(array('foo', 'bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($value, 'foobar');
}
@@ -46,7 +46,7 @@ class ConcatTest extends MigrateProcessTestCase {
*/
public function testConcatWithDelimiter() {
$this->plugin->setDelimiter('_');
- $value = $this->plugin->transform(array('foo', 'bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($value, 'foo_bar');
}
diff --git a/core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php b/core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php
index 2aec300f369..8f412fd055f 100644
--- a/core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php
@@ -34,9 +34,9 @@ class DedupeEntityTest extends MigrateProcessTestCase {
*
* @var array
*/
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- );
+ ];
/**
* {@inheritdoc}
@@ -64,16 +64,16 @@ class DedupeEntityTest extends MigrateProcessTestCase {
* @dataProvider providerTestDedupe
*/
public function testDedupe($count, $postfix = '', $start = NULL, $length = NULL) {
- $configuration = array(
+ $configuration = [
'entity_type' => 'test_entity_type',
'field' => 'test_field',
- );
+ ];
if ($postfix) {
$configuration['postfix'] = $postfix;
}
$configuration['start'] = isset($start) ? $start : NULL;
$configuration['length'] = isset($length) ? $length : NULL;
- $plugin = new DedupeEntity($configuration, 'dedupe_entity', array(), $this->getMigration(), $this->entityTypeManager);
+ $plugin = new DedupeEntity($configuration, 'dedupe_entity', [], $this->getMigration(), $this->entityTypeManager);
$this->entityQueryExpects($count);
$value = $this->randomMachineName(32);
$actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'testproperty');
@@ -86,12 +86,12 @@ class DedupeEntityTest extends MigrateProcessTestCase {
* Tests that invalid start position throws an exception.
*/
public function testDedupeEntityInvalidStart() {
- $configuration = array(
+ $configuration = [
'entity_type' => 'test_entity_type',
'field' => 'test_field',
'start' => 'foobar',
- );
- $plugin = new DedupeEntity($configuration, 'dedupe_entity', array(), $this->getMigration(), $this->entityTypeManager);
+ ];
+ $plugin = new DedupeEntity($configuration, 'dedupe_entity', [], $this->getMigration(), $this->entityTypeManager);
$this->setExpectedException('Drupal\migrate\MigrateException', 'The start position configuration key should be an integer. Omit this key to capture from the beginning of the string.');
$plugin->transform('test_start', $this->migrateExecutable, $this->row, 'testproperty');
}
@@ -100,12 +100,12 @@ class DedupeEntityTest extends MigrateProcessTestCase {
* Tests that invalid length option throws an exception.
*/
public function testDedupeEntityInvalidLength() {
- $configuration = array(
+ $configuration = [
'entity_type' => 'test_entity_type',
'field' => 'test_field',
'length' => 'foobar',
- );
- $plugin = new DedupeEntity($configuration, 'dedupe_entity', array(), $this->getMigration(), $this->entityTypeManager);
+ ];
+ $plugin = new DedupeEntity($configuration, 'dedupe_entity', [], $this->getMigration(), $this->entityTypeManager);
$this->setExpectedException('Drupal\migrate\MigrateException', 'The character length configuration key should be an integer. Omit this key to capture the entire string.');
$plugin->transform('test_length', $this->migrateExecutable, $this->row, 'testproperty');
}
@@ -114,40 +114,40 @@ class DedupeEntityTest extends MigrateProcessTestCase {
* Data provider for testDedupe().
*/
public function providerTestDedupe() {
- return array(
+ return [
// Tests no duplication.
- array(0),
+ [0],
// Tests no duplication and start position.
- array(0, NULL, 10),
+ [0, NULL, 10],
// Tests no duplication, start position, and length.
- array(0, NULL, 5, 10),
+ [0, NULL, 5, 10],
// Tests no duplication and length.
- array(0, NULL, NULL, 10),
+ [0, NULL, NULL, 10],
// Tests duplication.
- array(3),
+ [3],
// Tests duplication and start position.
- array(3, NULL, 10),
+ [3, NULL, 10],
// Tests duplication, start position, and length.
- array(3, NULL, 5, 10),
+ [3, NULL, 5, 10],
// Tests duplication and length.
- array(3, NULL, NULL, 10),
+ [3, NULL, NULL, 10],
// Tests no duplication and postfix.
- array(0, '_'),
+ [0, '_'],
// Tests no duplication, postfix, and start position.
- array(0, '_', 5),
+ [0, '_', 5],
// Tests no duplication, postfix, start position, and length.
- array(0, '_', 5, 10),
+ [0, '_', 5, 10],
// Tests no duplication, postfix, and length.
- array(0, '_', NULL, 10),
+ [0, '_', NULL, 10],
// Tests duplication and postfix.
- array(2, '_'),
+ [2, '_'],
// Tests duplication, postfix, and start position.
- array(2, '_', 5),
+ [2, '_', 5],
// Tests duplication, postfix, start position, and length.
- array(2, '_', 5, 10),
+ [2, '_', 5, 10],
// Tests duplication, postfix, and length.
- array(2, '_', NULL, 10),
- );
+ [2, '_', NULL, 10],
+ ];
}
/**
@@ -172,12 +172,12 @@ class DedupeEntityTest extends MigrateProcessTestCase {
* Test deduplicating only migrated entities.
*/
public function testDedupeMigrated() {
- $configuration = array(
+ $configuration = [
'entity_type' => 'test_entity_type',
'field' => 'test_field',
'migrated' => TRUE,
- );
- $plugin = new DedupeEntity($configuration, 'dedupe_entity', array(), $this->getMigration(), $this->entityTypeManager);
+ ];
+ $plugin = new DedupeEntity($configuration, 'dedupe_entity', [], $this->getMigration(), $this->entityTypeManager);
// Setup the entityQuery used in DedupeEntity::exists. The map, $map, is
// an array consisting of the four input parameters to the query condition
diff --git a/core/modules/migrate/tests/src/Unit/process/ExtractTest.php b/core/modules/migrate/tests/src/Unit/process/ExtractTest.php
index 26c2cfe2539..d030a07aef7 100644
--- a/core/modules/migrate/tests/src/Unit/process/ExtractTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/ExtractTest.php
@@ -14,8 +14,8 @@ class ExtractTest extends MigrateProcessTestCase {
* {@inheritdoc}
*/
protected function setUp() {
- $configuration['index'] = array('foo');
- $this->plugin = new Extract($configuration, 'map', array());
+ $configuration['index'] = ['foo'];
+ $this->plugin = new Extract($configuration, 'map', []);
parent::setUp();
}
@@ -23,7 +23,7 @@ class ExtractTest extends MigrateProcessTestCase {
* Tests successful extraction.
*/
public function testExtract() {
- $value = $this->plugin->transform(array('foo' => 'bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $value = $this->plugin->transform(['foo' => 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($value, 'bar');
}
@@ -44,7 +44,7 @@ class ExtractTest extends MigrateProcessTestCase {
* @expectedExceptionMessage Array index missing, extraction failed.
*/
public function testExtractFail() {
- $this->plugin->transform(array('bar' => 'foo'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $this->plugin->transform(['bar' => 'foo'], $this->migrateExecutable, $this->row, 'destinationproperty');
}
/**
diff --git a/core/modules/migrate/tests/src/Unit/process/FlattenTest.php b/core/modules/migrate/tests/src/Unit/process/FlattenTest.php
index 52c19be2932..484cfc78d25 100644
--- a/core/modules/migrate/tests/src/Unit/process/FlattenTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/FlattenTest.php
@@ -15,9 +15,9 @@ class FlattenTest extends MigrateProcessTestCase {
* Test that various array flatten operations work properly.
*/
public function testFlatten() {
- $plugin = new Flatten(array(), 'flatten', array());
- $flattened = $plugin->transform(array(1, 2, array(3, 4, array(5)), array(), array(7, 8)), $this->migrateExecutable, $this->row, 'destinationproperty');
- $this->assertSame($flattened, array(1, 2, 3, 4, 5, 7, 8));
+ $plugin = new Flatten([], 'flatten', []);
+ $flattened = $plugin->transform([1, 2, [3, 4, [5]], [], [7, 8]], $this->migrateExecutable, $this->row, 'destinationproperty');
+ $this->assertSame($flattened, [1, 2, 3, 4, 5, 7, 8]);
}
}
diff --git a/core/modules/migrate/tests/src/Unit/process/GetTest.php b/core/modules/migrate/tests/src/Unit/process/GetTest.php
index ae24d98c7ee..01ab2da74d2 100644
--- a/core/modules/migrate/tests/src/Unit/process/GetTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/GetTest.php
@@ -41,16 +41,16 @@ class GetTest extends MigrateProcessTestCase {
* Tests the Get plugin when source is an array.
*/
public function testTransformSourceArray() {
- $map = array(
+ $map = [
'test1' => 'source_value1',
'test2' => 'source_value2',
- );
- $this->plugin->setSource(array('test1', 'test2'));
+ ];
+ $this->plugin->setSource(['test1', 'test2']);
$this->row->expects($this->exactly(2))
->method('getSourceProperty')
->will($this->returnCallback(function ($argument) use ($map) { return $map[$argument]; } ));
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
- $this->assertSame($value, array('source_value1', 'source_value2'));
+ $this->assertSame($value, ['source_value1', 'source_value2']);
}
/**
@@ -70,18 +70,18 @@ class GetTest extends MigrateProcessTestCase {
* Tests the Get plugin when source is an array pointing to destination.
*/
public function testTransformSourceArrayAt() {
- $map = array(
+ $map = [
'test1' => 'source_value1',
'@test2' => 'source_value2',
'@test3' => 'source_value3',
'test4' => 'source_value4',
- );
- $this->plugin->setSource(array('test1', '@@test2', '@@test3', 'test4'));
+ ];
+ $this->plugin->setSource(['test1', '@@test2', '@@test3', 'test4']);
$this->row->expects($this->exactly(4))
->method('getSourceProperty')
->will($this->returnCallback(function ($argument) use ($map) { return $map[$argument]; } ));
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
- $this->assertSame($value, array('source_value1', 'source_value2', 'source_value3', 'source_value4'));
+ $this->assertSame($value, ['source_value1', 'source_value2', 'source_value3', 'source_value4']);
}
/**
diff --git a/core/modules/migrate/tests/src/Unit/process/IteratorTest.php b/core/modules/migrate/tests/src/Unit/process/IteratorTest.php
index cdffac07ae8..993fb928497 100644
--- a/core/modules/migrate/tests/src/Unit/process/IteratorTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/IteratorTest.php
@@ -25,9 +25,9 @@ class IteratorTest extends MigrateTestCase {
/**
* @var array
*/
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- );
+ ];
/**
* Tests the iterator process plugin.
@@ -35,24 +35,24 @@ class IteratorTest extends MigrateTestCase {
public function testIterator() {
$migration = $this->getMigration();
// Set up the properties for the iterator.
- $configuration = array(
- 'process' => array(
+ $configuration = [
+ 'process' => [
'foo' => 'source_foo',
'id' => 'source_id',
- ),
+ ],
'key' => '@id',
- );
- $plugin = new Iterator($configuration, 'iterator', array());
+ ];
+ $plugin = new Iterator($configuration, 'iterator', []);
// Manually create the plugins. Migration::getProcessPlugins does this
// normally but the plugin system is not available.
foreach ($configuration['process'] as $destination => $source) {
- $iterator_plugins[$destination][] = new Get(array('source' => $source), 'get', array());
+ $iterator_plugins[$destination][] = new Get(['source' => $source], 'get', []);
}
$migration->expects($this->at(1))
->method('getProcessPlugins')
->will($this->returnValue($iterator_plugins));
// Set up the key plugins.
- $key_plugin['key'][] = new Get(array('source' => '@id'), 'get', array());
+ $key_plugin['key'][] = new Get(['source' => '@id'], 'get', []);
$migration->expects($this->at(2))
->method('getProcessPlugins')
->will($this->returnValue($key_plugin));
@@ -60,12 +60,12 @@ class IteratorTest extends MigrateTestCase {
$migrate_executable = new MigrateExecutable($migration, $this->getMock('Drupal\migrate\MigrateMessageInterface'), $event_dispatcher);
// The current value of the pipeline.
- $current_value = array(
- array(
+ $current_value = [
+ [
'source_foo' => 'test',
'source_id' => 42,
- ),
- );
+ ],
+ ];
// This is not used but the interface requires it, so create an empty row.
$row = new Row();
diff --git a/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php b/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php
index 7f44157f37f..5bc91587bba 100644
--- a/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php
@@ -53,7 +53,7 @@ class MachineNameTest extends MigrateProcessTestCase {
->with($human_name)
->will($this->returnValue($human_name_ascii . 'aeo'));
- $plugin = new MachineName(array(), 'machine_name', array(), $this->transliteration);
+ $plugin = new MachineName([], 'machine_name', [], $this->transliteration);
$value = $plugin->transform($human_name, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertEquals($expected_result, $value);
}
diff --git a/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php b/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php
index 59db2e5780d..5a8de135f2b 100644
--- a/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php
@@ -16,7 +16,7 @@ class StaticMapTest extends MigrateProcessTestCase {
*/
protected function setUp() {
$configuration['map']['foo']['bar'] = 'baz';
- $this->plugin = new StaticMap($configuration, 'map', array());
+ $this->plugin = new StaticMap($configuration, 'map', []);
parent::setUp();
}
@@ -25,14 +25,14 @@ class StaticMapTest extends MigrateProcessTestCase {
*/
public function testMapWithSourceString() {
$value = $this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
- $this->assertSame($value, array('bar' => 'baz'));
+ $this->assertSame($value, ['bar' => 'baz']);
}
/**
* Tests map when the source is a list.
*/
public function testMapWithSourceList() {
- $value = $this->plugin->transform(array('foo', 'bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($value, 'baz');
}
@@ -42,7 +42,7 @@ class StaticMapTest extends MigrateProcessTestCase {
* @expectedException \Drupal\migrate\MigrateException
*/
public function testMapwithEmptySource() {
- $this->plugin->transform(array(), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $this->plugin->transform([], $this->migrateExecutable, $this->row, 'destinationproperty');
}
/**
@@ -51,7 +51,7 @@ class StaticMapTest extends MigrateProcessTestCase {
* @expectedException \Drupal\migrate\MigrateSkipRowException
*/
public function testMapwithInvalidSource() {
- $this->plugin->transform(array('bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
}
/**
@@ -60,8 +60,8 @@ class StaticMapTest extends MigrateProcessTestCase {
public function testMapWithInvalidSourceWithADefaultValue() {
$configuration['map']['foo']['bar'] = 'baz';
$configuration['default_value'] = 'test';
- $this->plugin = new StaticMap($configuration, 'map', array());
- $value = $this->plugin->transform(array('bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $this->plugin = new StaticMap($configuration, 'map', []);
+ $value = $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($value, 'test');
}
@@ -72,7 +72,7 @@ class StaticMapTest extends MigrateProcessTestCase {
$configuration['map']['foo']['bar'] = 'baz';
$configuration['default_value'] = NULL;
$this->plugin = new StaticMap($configuration, 'map', []);
- $value = $this->plugin->transform(array('bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $value = $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertNull($value);
}
@@ -86,8 +86,8 @@ class StaticMapTest extends MigrateProcessTestCase {
$configuration['map']['foo']['bar'] = 'baz';
$configuration['default_value'] = 'test';
$configuration['bypass'] = TRUE;
- $this->plugin = new StaticMap($configuration, 'map', array());
- $this->plugin->transform(array('bar'), $this->migrateExecutable, $this->row, 'destinationproperty');
+ $this->plugin = new StaticMap($configuration, 'map', []);
+ $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
}
}
diff --git a/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php b/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php
index 78d89a16e11..1f7d94ae0d5 100644
--- a/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php
@@ -28,14 +28,14 @@ class UrlEncodeTest extends MigrateTestCase {
* An array of URLs to test.
*/
public function urlDataProvider() {
- return array(
- 'A URL with no characters requiring encoding' => array('http://example.com/normal_url.html', 'http://example.com/normal_url.html'),
- 'The definitive use case - encoding spaces in URLs' => array('http://example.com/url with spaces.html', 'http://example.com/url%20with%20spaces.html'),
- 'Definitive use case 2 - spaces in directories' => array('http://example.com/dir with spaces/foo.html', 'http://example.com/dir%20with%20spaces/foo.html'),
- 'Local filespecs without spaces should not be transformed' => array('/tmp/normal.txt', '/tmp/normal.txt'),
- 'Local filespecs with spaces should not be transformed' => array('/tmp/with spaces.txt', '/tmp/with spaces.txt'),
- 'Make sure URL characters (:, ?, &) are not encoded but others are.' => array('https://example.com/?a=b@c&d=e+f%', 'https://example.com/?a%3Db%40c&d%3De%2Bf%25'),
- );
+ return [
+ 'A URL with no characters requiring encoding' => ['http://example.com/normal_url.html', 'http://example.com/normal_url.html'],
+ 'The definitive use case - encoding spaces in URLs' => ['http://example.com/url with spaces.html', 'http://example.com/url%20with%20spaces.html'],
+ 'Definitive use case 2 - spaces in directories' => ['http://example.com/dir with spaces/foo.html', 'http://example.com/dir%20with%20spaces/foo.html'],
+ 'Local filespecs without spaces should not be transformed' => ['/tmp/normal.txt', '/tmp/normal.txt'],
+ 'Local filespecs with spaces should not be transformed' => ['/tmp/with spaces.txt', '/tmp/with spaces.txt'],
+ 'Make sure URL characters (:, ?, &) are not encoded but others are.' => ['https://example.com/?a=b@c&d=e+f%', 'https://example.com/?a%3Db%40c&d%3De%2Bf%25'],
+ ];
}
/**
diff --git a/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module
index dc3ab4ee75a..9b00e07eb11 100644
--- a/core/modules/migrate_drupal/migrate_drupal.module
+++ b/core/modules/migrate_drupal/migrate_drupal.module
@@ -20,7 +20,7 @@ function migrate_drupal_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.migrate_drupal':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Migrate Drupal module provides a framework based on the <a href=":migrate">Migrate module</a> to facilitate migration from a Drupal (6, 7, or 8) site to your website. It does not provide a user interface. For more information, see the <a href=":migrate_drupal">online documentation for the Migrate Drupal module</a>.', array(':migrate' => \Drupal::url('help.page', array('name' => 'migrate')), ':migrate_drupal' => 'https://www.drupal.org/documentation/modules/migrate_drupal')) . '</p>';
+ $output .= '<p>' . t('The Migrate Drupal module provides a framework based on the <a href=":migrate">Migrate module</a> to facilitate migration from a Drupal (6, 7, or 8) site to your website. It does not provide a user interface. For more information, see the <a href=":migrate_drupal">online documentation for the Migrate Drupal module</a>.', [':migrate' => \Drupal::url('help.page', ['name' => 'migrate']), ':migrate_drupal' => 'https://www.drupal.org/documentation/modules/migrate_drupal']) . '</p>';
return $output;
}
}
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
index 3c3624d1979..ffff6269cd6 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
@@ -59,7 +59,7 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
*/
public function getSystemData() {
if (!isset($this->systemData)) {
- $this->systemData = array();
+ $this->systemData = [];
try {
$results = $this->select('system', 's')
->fields('s')
@@ -149,7 +149,7 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
protected function variableGet($name, $default) {
try {
$result = $this->select('variable', 'v')
- ->fields('v', array('value'))
+ ->fields('v', ['value'])
->condition('name', $name)
->execute()
->fetchField();
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
index 2d8c3ccd8fb..410acec229c 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
@@ -37,7 +37,7 @@ class Variable extends DrupalSqlBase {
* {@inheritdoc}
*/
protected function initializeIterator() {
- return new \ArrayIterator(array($this->values()));
+ return new \ArrayIterator([$this->values()]);
}
/**
@@ -75,7 +75,7 @@ class Variable extends DrupalSqlBase {
public function query() {
return $this->getDatabase()
->select('variable', 'v')
- ->fields('v', array('name', 'value'))
+ ->fields('v', ['name', 'value'])
->condition('name', $this->variables, 'IN');
}
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php
index 2ecea8d22ab..61da5eb30a1 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php
@@ -21,7 +21,7 @@ class VariableMultiRow extends DrupalSqlBase {
*/
public function query() {
return $this->select('variable', 'v')
- ->fields('v', array('name', 'value'))
+ ->fields('v', ['name', 'value'])
// Cast scalars to array so we can consistently use an IN condition.
->condition('name', (array) $this->configuration['variables'], 'IN');
}
@@ -30,10 +30,10 @@ class VariableMultiRow extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'name' => $this->t('Name'),
'value' => $this->t('Value'),
- );
+ ];
}
/**
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php
index df3311f5fcd..8d8338776db 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php
@@ -19,7 +19,7 @@ class Config extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('config', 'c')
- ->fields('c', array('collection', 'name', 'data'));
+ ->fields('c', ['collection', 'name', 'data']);
if (!empty($this->configuration['collections'])) {
$query->condition('collection', (array) $this->configuration['collections'], 'IN');
}
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/MigrateCckFieldPluginManagerTest.php b/core/modules/migrate_drupal/tests/src/Kernel/MigrateCckFieldPluginManagerTest.php
index 1754cfef517..9e30795be1e 100644
--- a/core/modules/migrate_drupal/tests/src/Kernel/MigrateCckFieldPluginManagerTest.php
+++ b/core/modules/migrate_drupal/tests/src/Kernel/MigrateCckFieldPluginManagerTest.php
@@ -14,7 +14,7 @@ class MigrateCckFieldPluginManagerTest extends MigrateDrupalTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'migrate_cckfield_plugin_manager_test');
+ public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'migrate_cckfield_plugin_manager_test'];
/**
* Tests that the correct MigrateCckField plugins are used.
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php b/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
index 2cf4eb14aaa..063c99cb364 100644
--- a/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
+++ b/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
@@ -15,7 +15,7 @@ abstract class MigrateDrupalTestBase extends MigrateTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field', 'migrate_drupal', 'options', 'file');
+ public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file'];
/**
* {@inheritdoc}
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php
index 5074473cecb..9c5ee58f2c2 100644
--- a/core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php
+++ b/core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php
@@ -44,12 +44,12 @@ class EntityContentBaseTest extends MigrateDrupal6TestBase {
'uid' => 2,
'name' => 'Ford Prefect',
'mail' => 'ford.prefect@localhost',
- 'signature' => array(
- array(
+ 'signature' => [
+ [
'value' => 'Bring a towel.',
'format' => 'filtered_html',
- ),
- ),
+ ],
+ ],
'init' => 'proto@zo.an',
])->save();
diff --git a/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php b/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php
index 1b5736d9216..ba0dc5a470b 100644
--- a/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php
+++ b/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php
@@ -22,11 +22,11 @@ class MigrateDependenciesTest extends MigrateDrupal6TestBase {
* Tests that the order is correct when loading several migrations.
*/
public function testMigrateDependenciesOrder() {
- $migration_items = array('d6_comment', 'd6_filter_format', 'd6_node:page');
+ $migration_items = ['d6_comment', 'd6_filter_format', 'd6_node:page'];
$migrations = $this->container->get('plugin.manager.migration')->createInstances($migration_items);
- $expected_order = array('d6_filter_format', 'd6_node:page', 'd6_comment');
+ $expected_order = ['d6_filter_format', 'd6_node:page', 'd6_comment'];
$this->assertIdentical(array_keys($migrations), $expected_order);
- $expected_requirements = array(
+ $expected_requirements = [
// d6_comment depends on d6_node:*, which the deriver expands into every
// variant of d6_node.
'd6_node:article',
@@ -47,7 +47,7 @@ class MigrateDependenciesTest extends MigrateDrupal6TestBase {
'd6_comment_type',
'd6_comment_entity_display',
'd6_comment_entity_form_display',
- );
+ ];
// Migration dependencies for comment include dependencies for node
// migration as well.
$actual_requirements = $migrations['d6_comment']->get('requirements');
@@ -66,7 +66,7 @@ class MigrateDependenciesTest extends MigrateDrupal6TestBase {
$executable = new MigrateExecutable($migration, $this);
$this->startCollectingMessages();
$executable->import();
- $this->assertEqual($this->migrateMessages['error'], array(SafeMarkup::format('Migration @id did not meet the requirements. Missing migrations d6_aggregator_feed. requirements: d6_aggregator_feed.', array('@id' => $migration->id()))));
+ $this->assertEqual($this->migrateMessages['error'], [SafeMarkup::format('Migration @id did not meet the requirements. Missing migrations d6_aggregator_feed. requirements: d6_aggregator_feed.', ['@id' => $migration->id()])]);
$this->collectMessages = FALSE;
}
diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
index f2254dc4ac8..6dd59257488 100644
--- a/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
+++ b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
@@ -14,9 +14,9 @@ class DrupalSqlBaseTest extends MigrateTestCase {
/**
* Define bare minimum migration configuration.
*/
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'DrupalSqlBase',
- );
+ ];
/**
* @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
@@ -26,17 +26,17 @@ class DrupalSqlBaseTest extends MigrateTestCase {
/**
* Minimum database contents needed to test DrupalSqlBase.
*/
- protected $databaseContents = array(
- 'system' => array(
- array(
+ protected $databaseContents = [
+ 'system' => [
+ [
'filename' => 'sites/all/modules/module1',
'name' => 'module1',
'type' => 'module',
'status' => 0,
'schema_version' => -1,
- ),
- ),
- );
+ ],
+ ],
+ ];
/**
* @covers ::checkRequirements
diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php b/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php
index c9af613c9cd..5710436221d 100644
--- a/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php
+++ b/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php
@@ -14,27 +14,27 @@ abstract class VariableMultiRowTestBase extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow';
// The fake Migration configuration entity.
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- 'source' => array(
+ 'source' => [
'plugin' => 'd6_variable_multirow',
- 'variables' => array(
+ 'variables' => [
'foo',
'bar',
- ),
- ),
- );
-
- protected $expectedResults = array(
- array('name' => 'foo', 'value' => 1),
- array('name' => 'bar', 'value' => FALSE),
- );
-
- protected $databaseContents = array(
- 'variable' => array(
- array('name' => 'foo', 'value' => 'i:1;'),
- array('name' => 'bar', 'value' => 'b:0;'),
- ),
- );
+ ],
+ ],
+ ];
+
+ protected $expectedResults = [
+ ['name' => 'foo', 'value' => 1],
+ ['name' => 'bar', 'value' => FALSE],
+ ];
+
+ protected $databaseContents = [
+ 'variable' => [
+ ['name' => 'foo', 'value' => 'i:1;'],
+ ['name' => 'bar', 'value' => 'b:0;'],
+ ],
+ ];
}
diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php
index 18a30333e32..1b5abc36b01 100644
--- a/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php
+++ b/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php
@@ -13,31 +13,31 @@ class VariableTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\Variable';
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'test',
- 'highWaterProperty' => array('field' => 'test'),
- 'source' => array(
+ 'highWaterProperty' => ['field' => 'test'],
+ 'source' => [
'plugin' => 'd6_variable',
- 'variables' => array(
+ 'variables' => [
'foo',
'bar',
- ),
- ),
- );
+ ],
+ ],
+ ];
- protected $expectedResults = array(
- array(
+ protected $expectedResults = [
+ [
'id' => 'foo',
'foo' => 1,
'bar' => FALSE,
- ),
- );
-
- protected $databaseContents = array(
- 'variable' => array(
- array('name' => 'foo', 'value' => 'i:1;'),
- array('name' => 'bar', 'value' => 'b:0;'),
- ),
- );
+ ],
+ ];
+
+ protected $databaseContents = [
+ 'variable' => [
+ ['name' => 'foo', 'value' => 'i:1;'],
+ ['name' => 'bar', 'value' => 'b:0;'],
+ ],
+ ];
}
diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php
index 845ce786363..55d128227d0 100644
--- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php
+++ b/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php
@@ -19,9 +19,9 @@ class Drupal6SqlBaseTest extends MigrateTestCase {
/**
* Define bare minimum migration configuration.
*/
- protected $migrationConfiguration = array(
+ protected $migrationConfiguration = [
'id' => 'Drupal6SqlBase',
- );
+ ];
/**
* @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
@@ -31,37 +31,37 @@ class Drupal6SqlBaseTest extends MigrateTestCase {
/**
* Minimum database contents needed to test Drupal6SqlBase.
*/
- protected $databaseContents = array(
- 'system' => array(
- array(
+ protected $databaseContents = [
+ 'system' => [
+ [
'filename' => 'sites/all/modules/module1',
'name' => 'module1',
'type' => 'module',
'status' => 1,
'schema_version' => -1,
- ),
- array(
+ ],
+ [
'filename' => 'sites/all/modules/module2',
'name' => 'module2',
'type' => 'module',
'status' => 0,
'schema_version' => 7201,
- ),
- array(
+ ],
+ [
'filename' => 'sites/all/modules/test2',
'name' => 'test2',
'type' => 'theme',
'status' => 1,
'schema_version' => -1,
- ),
- ),
- 'variable' => array(
- array(
+ ],
+ ],
+ 'variable' => [
+ [
'name' => 'my_variable',
'value' => 'b:1;',
- ),
- ),
- );
+ ],
+ ],
+ ];
/**
* {@inheritdoc}
@@ -72,7 +72,7 @@ class Drupal6SqlBaseTest extends MigrateTestCase {
$state = $this->getMock('Drupal\Core\State\StateInterface');
/** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
- $this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, array(), $this->getMigration(), $state, $entity_manager);
+ $this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, [], $this->getMigration(), $state, $entity_manager);
$this->base->setDatabase($this->getDatabase($this->databaseContents));
}
@@ -143,7 +143,7 @@ class TestDrupal6SqlBase extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'filename' => t('The path of the primary file for this item.'),
'name' => t('The name of the item; e.g. node.'),
'type' => t('The type of the item, either module, theme, or theme_engine.'),
@@ -154,7 +154,7 @@ class TestDrupal6SqlBase extends DrupalSqlBase {
'schema_version' => t('The module\'s database schema version number.'),
'weight' => t('The order in which this module\'s hooks should be invoked.'),
'info' => t('A serialized array containing information from the module\'s .info file.'),
- );
+ ];
}
/**
@@ -163,7 +163,7 @@ class TestDrupal6SqlBase extends DrupalSqlBase {
public function query() {
$query = $this->database
->select('system', 's')
- ->fields('s', array('filename', 'name', 'schema_version'));
+ ->fields('s', ['filename', 'name', 'schema_version']);
return $query;
}
@@ -216,7 +216,7 @@ class TestDrupal6SqlBase extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- return array();
+ return [];
}
}
diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php
index bcfb6c2027e..06059cfd534 100644
--- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php
+++ b/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php
@@ -20,7 +20,7 @@ class i18nVariableTest extends MigrateSqlSourceTestCase {
*/
protected $migrationConfiguration = [
'id' => 'test',
- 'highWaterProperty' => array('field' => 'test'),
+ 'highWaterProperty' => ['field' => 'test'],
'source' => [
'plugin' => 'i18n_variable',
'variables' => [
@@ -51,10 +51,10 @@ class i18nVariableTest extends MigrateSqlSourceTestCase {
*/
protected $databaseContents = [
'i18n_variable' => [
- array('name' => 'site_slogan', 'language' => 'fr', 'value' => 's:19:"Migrate est génial";'),
- array('name' => 'site_name', 'language' => 'fr', 'value' => 's:11:"nom de site";'),
- array('name' => 'site_slogan', 'language' => 'mi', 'value' => 's:19:"Ko whakamataku heke";'),
- array('name' => 'site_name', 'language' => 'mi', 'value' => 's:9:"ingoa_pae";'),
+ ['name' => 'site_slogan', 'language' => 'fr', 'value' => 's:19:"Migrate est génial";'],
+ ['name' => 'site_name', 'language' => 'fr', 'value' => 's:11:"nom de site";'],
+ ['name' => 'site_slogan', 'language' => 'mi', 'value' => 's:19:"Ko whakamataku heke";'],
+ ['name' => 'site_name', 'language' => 'mi', 'value' => 's:9:"ingoa_pae";'],
],
];
diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
index 212a044c2dd..6b1fc1b398c 100644
--- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
+++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
@@ -1058,7 +1058,7 @@ class MigrateUpgradeForm extends ConfirmFormBase {
$form['missing_module_list_title'] = [
'#type' => 'item',
'#title' => $this->t('Missing upgrade paths'),
- '#description' => $this->t('The following items will not be upgraded. For more information see <a href=":migrate">Upgrading from Drupal 6 or 7 to Drupal 8</a>.', array(':migrate' => 'https://www.drupal.org/upgrade/migrate')),
+ '#description' => $this->t('The following items will not be upgraded. For more information see <a href=":migrate">Upgrading from Drupal 6 or 7 to Drupal 8</a>.', [':migrate' => 'https://www.drupal.org/upgrade/migrate']),
];
$form['missing_module_list'] = [
'#type' => 'table',
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index dc1be652653..fc637bd39f1 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -33,10 +33,10 @@ function node_mass_update(array $nodes, array $updates, $langcode = NULL, $load
// We use batch processing to prevent timeout when updating a large number
// of nodes.
if (count($nodes) > 10) {
- $batch = array(
- 'operations' => array(
- array('_node_mass_update_batch_process', array($nodes, $updates, $langcode, $load, $revisions))
- ),
+ $batch = [
+ 'operations' => [
+ ['_node_mass_update_batch_process', [$nodes, $updates, $langcode, $load, $revisions]]
+ ],
'finished' => '_node_mass_update_batch_finished',
'title' => t('Processing'),
// We use a single multi-pass operation, so the default
@@ -46,7 +46,7 @@ function node_mass_update(array $nodes, array $updates, $langcode = NULL, $load
// The operations do not live in the .module file, so we need to
// tell the batch engine which file to load before calling them.
'file' => drupal_get_path('module', 'node') . '/node.admin.inc',
- );
+ ];
batch_set($batch);
}
else {
@@ -81,7 +81,7 @@ function node_mass_update(array $nodes, array $updates, $langcode = NULL, $load
* @see node_mass_update()
*/
function _node_mass_update_helper(NodeInterface $node, array $updates, $langcode = NULL) {
- $langcodes = isset($langcode) ? array($langcode) : array_keys($node->getTranslationLanguages());
+ $langcodes = isset($langcode) ? [$langcode] : array_keys($node->getTranslationLanguages());
// For efficiency manually save the original node before applying any changes.
$node->original = clone $node;
foreach ($langcodes as $langcode) {
@@ -169,10 +169,10 @@ function _node_mass_update_batch_finished($success, $results, $operations) {
else {
drupal_set_message(t('An error occurred and processing did not complete.'), 'error');
$message = \Drupal::translation()->formatPlural(count($results), '1 item successfully processed:', '@count items successfully processed:');
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#items' => $results,
- );
+ ];
$message .= drupal_render($item_list);
drupal_set_message($message);
}
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index a4937f74214..604187406bb 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -81,10 +81,10 @@ use Drupal\Core\Access\AccessResult;
*/
function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) {
if ($account->hasPermission('access private content')) {
- $grants['example'] = array(1);
+ $grants['example'] = [1];
}
if ($account->id()) {
- $grants['example_author'] = array($account->id());
+ $grants['example_author'] = [$account->id()];
}
return $grants;
}
@@ -158,33 +158,33 @@ function hook_node_access_records(\Drupal\node\NodeInterface $node) {
// We only care about the node if it has been marked private. If not, it is
// treated just like any other node and we completely ignore it.
if ($node->private->value) {
- $grants = array();
+ $grants = [];
// Only published Catalan translations of private nodes should be viewable
// to all users. If we fail to check $node->isPublished(), all users would be able
// to view an unpublished node.
if ($node->isPublished()) {
- $grants[] = array(
+ $grants[] = [
'realm' => 'example',
'gid' => 1,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'langcode' => 'ca'
- );
+ ];
}
// For the example_author array, the GID is equivalent to a UID, which
// means there are many groups of just 1 user.
// Note that an author can always view his or her nodes, even if they
// have status unpublished.
if ($node->getOwnerId()) {
- $grants[] = array(
+ $grants[] = [
'realm' => 'example_author',
'gid' => $node->getOwnerId(),
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'langcode' => 'ca'
- );
+ ];
}
return $grants;
@@ -231,7 +231,7 @@ function hook_node_access_records_alter(&$grants, Drupal\node\NodeInterface $nod
// Our module grants are set in $grants['example'].
$temp = $grants['example'];
// Now remove all module grants but our own.
- $grants = array('example' => $temp);
+ $grants = ['example' => $temp];
}
}
@@ -280,7 +280,7 @@ function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface
// Now check the roles for this account against the restrictions.
foreach ($account->getRoles() as $rid) {
if (in_array($rid, $restricted)) {
- $grants = array();
+ $grants = [];
}
}
}
@@ -374,8 +374,8 @@ function hook_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
* @ingroup entity_crud
*/
function hook_node_search_result(\Drupal\node\NodeInterface $node) {
- $rating = db_query('SELECT SUM(points) FROM {my_rating} WHERE nid = :nid', array('nid' => $node->id()))->fetchField();
- return array('rating' => \Drupal::translation()->formatPlural($rating, '1 point', '@count points'));
+ $rating = db_query('SELECT SUM(points) FROM {my_rating} WHERE nid = :nid', ['nid' => $node->id()])->fetchField();
+ return ['rating' => \Drupal::translation()->formatPlural($rating, '1 point', '@count points')];
}
/**
@@ -394,7 +394,7 @@ function hook_node_search_result(\Drupal\node\NodeInterface $node) {
*/
function hook_node_update_index(\Drupal\node\NodeInterface $node) {
$text = '';
- $ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', array(':nid' => $node->id()));
+ $ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', [':nid' => $node->id()]);
foreach ($ratings as $rating) {
$text .= '<h2>' . Html::escape($rating->title) . '</h2>' . Xss::filter($rating->description);
}
@@ -447,24 +447,24 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node) {
function hook_ranking() {
// If voting is disabled, we can avoid returning the array, no hard feelings.
if (\Drupal::config('vote.settings')->get('node_enabled')) {
- return array(
- 'vote_average' => array(
+ return [
+ 'vote_average' => [
'title' => t('Average vote'),
// Note that we use i.sid, the search index's search item id, rather than
// n.nid.
- 'join' => array(
+ 'join' => [
'type' => 'LEFT',
'table' => 'vote_node_data',
'alias' => 'vote_node_data',
'on' => 'vote_node_data.nid = i.sid',
- ),
+ ],
// The highest possible score should be 1, and the lowest possible score,
// always 0, should be 0.
'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
// Pass in the highest possible voting score as a decimal argument.
- 'arguments' => array(\Drupal::config('vote.settings')->get('score_max')),
- ),
- );
+ 'arguments' => [\Drupal::config('vote.settings')->get('score_max')],
+ ],
+ ];
}
}
@@ -486,16 +486,16 @@ function hook_ranking() {
* @see entity_crud
*/
function hook_node_links_alter(array &$links, NodeInterface $entity, array &$context) {
- $links['mymodule'] = array(
+ $links['mymodule'] = [
'#theme' => 'links__node__mymodule',
- '#attributes' => array('class' => array('links', 'inline')),
- '#links' => array(
- 'node-report' => array(
+ '#attributes' => ['class' => ['links', 'inline']],
+ '#links' => [
+ 'node-report' => [
'title' => t('Report'),
'url' => Url::fromRoute('node_test.report', ['node' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("node/{$entity->id()}/report")]]),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/modules/node/node.install b/core/modules/node/node.install
index 0582459da38..3aeff410bc3 100644
--- a/core/modules/node/node.install
+++ b/core/modules/node/node.install
@@ -13,26 +13,26 @@ use Drupal\user\RoleInterface;
* Implements hook_requirements().
*/
function node_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if ($phase === 'runtime') {
// Only show rebuild button if there are either 0, or 2 or more, rows
// in the {node_access} table, or if there are modules that
// implement hook_node_grants().
$grant_count = \Drupal::entityManager()->getAccessControlHandler('node')->countGrants();
if ($grant_count != 1 || count(\Drupal::moduleHandler()->getImplementations('node_grants')) > 0) {
- $value = \Drupal::translation()->formatPlural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count));
+ $value = \Drupal::translation()->formatPlural($grant_count, 'One permission in use', '@count permissions in use', ['@count' => $grant_count]);
}
else {
$value = t('Disabled');
}
- $requirements['node_access'] = array(
+ $requirements['node_access'] = [
'title' => t('Node Access Permissions'),
'value' => $value,
- 'description' => t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Rebuilding will remove all privileges to content and replace them with permissions based on the current modules and settings. Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed, content will automatically use the new permissions. <a href=":rebuild">Rebuild permissions</a>', array(
+ 'description' => t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Rebuilding will remove all privileges to content and replace them with permissions based on the current modules and settings. Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed, content will automatically use the new permissions. <a href=":rebuild">Rebuild permissions</a>', [
':rebuild' => \Drupal::url('node.configure_rebuild_confirm'),
- )),
- );
+ ]),
+ ];
}
return $requirements;
}
@@ -41,78 +41,78 @@ function node_requirements($phase) {
* Implements hook_schema().
*/
function node_schema() {
- $schema['node_access'] = array(
+ $schema['node_access'] = [
'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The {node}.nid this record affects.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'description' => 'The {language}.langcode of this node.',
'type' => 'varchar_ascii',
'length' => 12,
'not null' => TRUE,
'default' => '',
- ),
- 'fallback' => array(
+ ],
+ 'fallback' => [
'description' => 'Boolean indicating whether this record should be used as a fallback if a language condition is not provided.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
- ),
- 'gid' => array(
+ ],
+ 'gid' => [
'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'realm' => array(
+ ],
+ 'realm' => [
'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'grant_view' => array(
+ ],
+ 'grant_view' => [
'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
- ),
- 'grant_update' => array(
+ ],
+ 'grant_update' => [
'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
- ),
- 'grant_delete' => array(
+ ],
+ 'grant_delete' => [
'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
- ),
- ),
- 'primary key' => array('nid', 'gid', 'realm', 'langcode'),
- 'foreign keys' => array(
- 'affected_node' => array(
+ ],
+ ],
+ 'primary key' => ['nid', 'gid', 'realm', 'langcode'],
+ 'foreign keys' => [
+ 'affected_node' => [
'table' => 'node',
- 'columns' => array('nid' => 'nid'),
- ),
- ),
- );
+ 'columns' => ['nid' => 'nid'],
+ ],
+ ],
+ ];
return $schema;
}
@@ -129,20 +129,20 @@ function node_install() {
// these permissions. Doing so also allows tests to continue to operate as
// expected without first having to manually grant these default permissions.
if (\Drupal::moduleHandler()->moduleExists('user')) {
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access content'));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access content'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access content']);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access content']);
}
// Populate the node access table.
db_insert('node_access')
- ->fields(array(
+ ->fields([
'nid' => 0,
'gid' => 0,
'realm' => 'all',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
- ))
+ ])
->execute();
}
@@ -216,7 +216,7 @@ function node_update_8003() {
// changes. SqlContentEntityStorageSchema::onEntityTypeUpdate() should be
// fixed to automatically handle this.
// See https://www.drupal.org/node/2554245.
- foreach (array('status', 'uid') as $field_name) {
+ foreach (['status', 'uid'] as $field_name) {
$manager->updateFieldStorageDefinition($manager->getFieldStorageDefinition($field_name, 'node'));
}
}
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 7d7247b75b2..40e5b4e2938 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -90,7 +90,7 @@ function node_help($route_name, RouteMatchInterface $route_match) {
$message = t('The content access permissions need to be rebuilt.');
}
else {
- $message = t('The content access permissions need to be rebuilt. <a href=":node_access_rebuild">Rebuild permissions</a>.', array(':node_access_rebuild' => \Drupal::url('node.configure_rebuild_confirm')));
+ $message = t('The content access permissions need to be rebuilt. <a href=":node_access_rebuild">Rebuild permissions</a>.', [':node_access_rebuild' => \Drupal::url('node.configure_rebuild_confirm')]);
}
drupal_set_message($message, 'error');
}
@@ -99,19 +99,19 @@ function node_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.node':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Node module manages the creation, editing, deletion, settings, and display of the main site content. Content items managed by the Node module are typically displayed as pages on your site, and include a title, some meta-data (author, creation time, content type, etc.), and optional fields containing text or other data (fields are managed by the <a href=":field">Field module</a>). For more information, see the <a href=":node">online documentation for the Node module</a>.', array(':node' => 'https://www.drupal.org/documentation/modules/node', ':field' => \Drupal::url('help.page', array('name' => 'field')))) . '</p>';
+ $output .= '<p>' . t('The Node module manages the creation, editing, deletion, settings, and display of the main site content. Content items managed by the Node module are typically displayed as pages on your site, and include a title, some meta-data (author, creation time, content type, etc.), and optional fields containing text or other data (fields are managed by the <a href=":field">Field module</a>). For more information, see the <a href=":node">online documentation for the Node module</a>.', [':node' => 'https://www.drupal.org/documentation/modules/node', ':field' => \Drupal::url('help.page', ['name' => 'field'])]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating content') . '</dt>';
- $output .= '<dd>' . t('When new content is created, the Node module records basic information about the content, including the author, date of creation, and the <a href=":content-type">Content type</a>. It also manages the <em>publishing options</em>, which define whether or not the content is published, promoted to the front page of the site, and/or sticky at the top of content lists. Default settings can be configured for each <a href=":content-type">type of content</a> on your site.', array(':content-type' => \Drupal::url('entity.node_type.collection'))) . '</dd>';
+ $output .= '<dd>' . t('When new content is created, the Node module records basic information about the content, including the author, date of creation, and the <a href=":content-type">Content type</a>. It also manages the <em>publishing options</em>, which define whether or not the content is published, promoted to the front page of the site, and/or sticky at the top of content lists. Default settings can be configured for each <a href=":content-type">type of content</a> on your site.', [':content-type' => \Drupal::url('entity.node_type.collection')]) . '</dd>';
$output .= '<dt>' . t('Creating custom content types') . '</dt>';
- $output .= '<dd>' . t('The Node module gives users with the <em>Administer content types</em> permission the ability to <a href=":content-new">create new content types</a> in addition to the default ones already configured. Creating custom content types gives you the flexibility to add <a href=":field">fields</a> and configure default settings that suit the differing needs of various site content.', array(':content-new' => \Drupal::url('node.type_add'), ':field' => \Drupal::url('help.page', array('name' => 'field')))) . '</dd>';
+ $output .= '<dd>' . t('The Node module gives users with the <em>Administer content types</em> permission the ability to <a href=":content-new">create new content types</a> in addition to the default ones already configured. Creating custom content types gives you the flexibility to add <a href=":field">fields</a> and configure default settings that suit the differing needs of various site content.', [':content-new' => \Drupal::url('node.type_add'), ':field' => \Drupal::url('help.page', ['name' => 'field'])]) . '</dd>';
$output .= '<dt>' . t('Administering content') . '</dt>';
- $output .= '<dd>' . t('The <a href=":content">Content</a> page lists your content, allowing you add new content, filter, edit or delete existing content, or perform bulk operations on existing content.', array(':content' => \Drupal::url('system.admin_content'))) . '</dd>';
+ $output .= '<dd>' . t('The <a href=":content">Content</a> page lists your content, allowing you add new content, filter, edit or delete existing content, or perform bulk operations on existing content.', [':content' => \Drupal::url('system.admin_content')]) . '</dd>';
$output .= '<dt>' . t('Creating revisions') . '</dt>';
$output .= '<dd>' . t('The Node module also enables you to create multiple versions of any content, and revert to older versions using the <em>Revision information</em> settings.') . '</dd>';
$output .= '<dt>' . t('User permissions') . '</dt>';
- $output .= '<dd>' . t('The Node module makes a number of permissions available for each content type, which can be set by role on the <a href=":permissions">permissions page</a>.', array(':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-node')))) . '</dd>';
+ $output .= '<dd>' . t('The Node module makes a number of permissions available for each content type, which can be set by role on the <a href=":permissions">permissions page</a>.', [':permissions' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-node'])]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -121,13 +121,13 @@ function node_help($route_name, RouteMatchInterface $route_match) {
case 'entity.entity_form_display.node.default':
case 'entity.entity_form_display.node.form_mode':
$type = $route_match->getParameter('node_type');
- return '<p>' . t('Content items can be edited using different form modes. Here, you can define which fields are shown and hidden when %type content is edited in each form mode, and define how the field form widgets are displayed in each form mode.', array('%type' => $type->label())) . '</p>' ;
+ return '<p>' . t('Content items can be edited using different form modes. Here, you can define which fields are shown and hidden when %type content is edited in each form mode, and define how the field form widgets are displayed in each form mode.', ['%type' => $type->label()]) . '</p>' ;
case 'entity.entity_view_display.node.default':
case 'entity.entity_view_display.node.view_mode':
$type = $route_match->getParameter('node_type');
return '<p>' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. <em>Teaser</em> is a short format that is typically used in lists of multiple content items. <em>Full content</em> is typically used when the content is displayed on its own page.') . '</p>' .
- '<p>' . t('Here, you can define which fields are shown and hidden when %type content is displayed in each view mode, and define how the fields are displayed in each view mode.', array('%type' => $type->label())) . '</p>';
+ '<p>' . t('Here, you can define which fields are shown and hidden when %type content is displayed in each view mode, and define how the fields are displayed in each view mode.', ['%type' => $type->label()]) . '</p>';
case 'entity.node.version_history':
return '<p>' . t('Revisions allow you to track differences between multiple versions of your content, and revert to older versions.') . '</p>';
@@ -149,26 +149,26 @@ function node_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function node_theme() {
- return array(
- 'node' => array(
+ return [
+ 'node' => [
'render element' => 'elements',
- ),
- 'node_add_list' => array(
- 'variables' => array('content' => NULL),
- ),
- 'node_edit_form' => array(
+ ],
+ 'node_add_list' => [
+ 'variables' => ['content' => NULL],
+ ],
+ 'node_edit_form' => [
'render element' => 'form',
- ),
- 'field__node__title' => array(
+ ],
+ 'field__node__title' => [
'base hook' => 'field',
- ),
- 'field__node__uid' => array(
+ ],
+ 'field__node__uid' => [
'base hook' => 'field',
- ),
- 'field__node__created' => array(
+ ],
+ 'field__node__created' => [
'base hook' => 'field',
- ),
- );
+ ],
+ ];
}
/**
@@ -204,19 +204,19 @@ function node_entity_view_display_alter(EntityViewDisplayInterface $display, $co
* $result, or FALSE if there are no rows in $result.
*/
function node_title_list(StatementInterface $result, $title = NULL) {
- $items = array();
+ $items = [];
$num_rows = FALSE;
$nids = [];
foreach ($result as $row) {
// Do not use $node->label() or $node->urlInfo() here, because we only have
// database rows, not actual nodes.
$nids[] = $row->nid;
- $options = !empty($row->comment_count) ? array('attributes' => array('title' => \Drupal::translation()->formatPlural($row->comment_count, '1 comment', '@count comments'))) : array();
+ $options = !empty($row->comment_count) ? ['attributes' => ['title' => \Drupal::translation()->formatPlural($row->comment_count, '1 comment', '@count comments')]] : [];
$items[] = \Drupal::l($row->title, new Url('entity.node.canonical', ['node' => $row->nid], $options));
$num_rows = TRUE;
}
- return $num_rows ? array('#theme' => 'item_list__node', '#items' => $items, '#title' => $title, '#cache' => ['tags' => Cache::mergeTags(['node_list'], Cache::buildTags('node', $nids))]) : FALSE;
+ return $num_rows ? ['#theme' => 'item_list__node', '#items' => $items, '#title' => $title, '#cache' => ['tags' => Cache::mergeTags(['node_list'], Cache::buildTags('node', $nids))]] : FALSE;
}
/**
@@ -232,7 +232,7 @@ function node_title_list(StatementInterface $result, $title = NULL) {
*/
function node_mark($nid, $timestamp) {
- $cache = &drupal_static(__FUNCTION__, array());
+ $cache = &drupal_static(__FUNCTION__, []);
if (\Drupal::currentUser()->isAnonymous() || !\Drupal::moduleHandler()->moduleExists('history')) {
return MARK_READ;
@@ -346,23 +346,23 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
'field_storage' => $field_storage,
'bundle' => $type->id(),
'label' => $label,
- 'settings' => array('display_summary' => TRUE),
+ 'settings' => ['display_summary' => TRUE],
]);
$field->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('node', $type->id(), 'default')
- ->setComponent('body', array(
+ ->setComponent('body', [
'type' => 'text_textarea_with_summary',
- ))
+ ])
->save();
// Assign display settings for the 'default' and 'teaser' view modes.
entity_get_display('node', $type->id(), 'default')
- ->setComponent('body', array(
+ ->setComponent('body', [
'label' => 'hidden',
'type' => 'text_default',
- ))
+ ])
->save();
// The teaser view mode is created by the Standard profile and therefore
@@ -370,10 +370,10 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
$view_modes = \Drupal::entityManager()->getViewModes('node');
if (isset($view_modes['teaser'])) {
entity_get_display('node', $type->id(), 'teaser')
- ->setComponent('body', array(
+ ->setComponent('body', [
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
- ))
+ ])
->save();
}
}
@@ -385,15 +385,15 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
* Implements hook_entity_extra_field_info().
*/
function node_entity_extra_field_info() {
- $extra = array();
+ $extra = [];
$description = t('Node module element');
foreach (NodeType::loadMultiple() as $bundle) {
- $extra['node'][$bundle->id()]['display']['links'] = array(
+ $extra['node'][$bundle->id()]['display']['links'] = [
'label' => t('Links'),
'description' => $description,
'weight' => 100,
'visible' => TRUE,
- );
+ ];
}
return $extra;
@@ -460,7 +460,7 @@ function node_load_multiple(array $nids = NULL, $reset = FALSE) {
*/
function node_load($nid = NULL, $reset = FALSE) {
if ($reset) {
- \Drupal::entityManager()->getStorage('node')->resetCache(array($nid));
+ \Drupal::entityManager()->getStorage('node')->resetCache([$nid]);
}
return Node::load($nid);
}
@@ -517,16 +517,16 @@ function node_is_page(NodeInterface $node) {
* @see node_add_page()
*/
function template_preprocess_node_add_list(&$variables) {
- $variables['types'] = array();
+ $variables['types'] = [];
if (!empty($variables['content'])) {
foreach ($variables['content'] as $type) {
- $variables['types'][$type->id()] = array(
+ $variables['types'][$type->id()] = [
'type' => $type->id(),
- 'add_link' => \Drupal::l($type->label(), new Url('node.add', array('node_type' => $type->id()))),
- 'description' => array(
+ 'add_link' => \Drupal::l($type->label(), new Url('node.add', ['node_type' => $type->id()])),
+ 'description' => [
'#markup' => $type->getDescription(),
- ),
- );
+ ],
+ ];
}
}
}
@@ -558,7 +558,7 @@ function node_preprocess_block(&$variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function node_theme_suggestions_node(array $variables) {
- $suggestions = array();
+ $suggestions = [];
$node = $variables['elements']['#node'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
@@ -598,18 +598,18 @@ function template_preprocess_node(&$variables) {
$variables['author_name'] = drupal_render($variables['elements']['uid']);
unset($variables['elements']['uid']);
- $variables['url'] = $node->url('canonical', array(
+ $variables['url'] = $node->url('canonical', [
'language' => $node->language(),
- ));
+ ]);
$variables['label'] = $variables['elements']['title'];
unset($variables['elements']['title']);
// The 'page' variable is set to TRUE in two occasions:
// - The view mode is 'full' and we are on the 'node.view' route.
// - The node is in preview and view mode is either 'full' or 'default'.
- $variables['page'] = ($variables['view_mode'] == 'full' && (node_is_page($node)) || (isset($node->in_preview) && in_array($node->preview_view_mode, array('full', 'default'))));
+ $variables['page'] = ($variables['view_mode'] == 'full' && (node_is_page($node)) || (isset($node->in_preview) && in_array($node->preview_view_mode, ['full', 'default'])));
// Helpful $content variable for templates.
- $variables += array('content' => array());
+ $variables += ['content' => []];
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
@@ -648,10 +648,10 @@ function node_cron() {
->execute();
if (isset($result[0])) {
// Make an array with definite keys and store it in the state system.
- $array = array(
+ $array = [
'min_created' => $result[0][$min_alias],
'max_created' => $result[0][$max_alias],
- );
+ ];
\Drupal::state()->set('node.min_max_update_time', $array);
}
}
@@ -662,35 +662,35 @@ function node_cron() {
*/
function node_ranking() {
// Create the ranking array and add the basic ranking options.
- $ranking = array(
- 'relevance' => array(
+ $ranking = [
+ 'relevance' => [
'title' => t('Keyword relevance'),
// Average relevance values hover around 0.15
'score' => 'i.relevance',
- ),
- 'sticky' => array(
+ ],
+ 'sticky' => [
'title' => t('Content is sticky at top of lists'),
// The sticky flag is either 0 or 1, which is automatically normalized.
'score' => 'n.sticky',
- ),
- 'promote' => array(
+ ],
+ 'promote' => [
'title' => t('Content is promoted to the front page'),
// The promote flag is either 0 or 1, which is automatically normalized.
'score' => 'n.promote',
- ),
- );
+ ],
+ ];
// Add relevance based on updated date, but only if it the scale values have
// been calculated in node_cron().
if ($node_min_max = \Drupal::state()->get('node.min_max_update_time')) {
- $ranking['recent'] = array(
+ $ranking['recent'] = [
'title' => t('Recently created'),
// Exponential decay with half life of 14% of the age range of nodes.
'score' => 'EXP(-5 * (1 - (n.created - :node_oldest) / :node_range))',
- 'arguments' => array(
+ 'arguments' => [
':node_oldest' => $node_min_max['min_created'],
':node_range' => max($node_min_max['max_created'] - $node_min_max['min_created'], 1),
- ),
- );
+ ],
+ ];
}
return $ranking;
}
@@ -706,17 +706,17 @@ function node_user_cancel($edit, $account, $method) {
->condition('uid', $account->id())
->execute();
module_load_include('inc', 'node', 'node.admin');
- node_mass_update($nids, array('status' => 0), NULL, TRUE);
+ node_mass_update($nids, ['status' => 0], NULL, TRUE);
break;
case 'user_cancel_reassign':
// Anonymize all of the nodes for this old account.
module_load_include('inc', 'node', 'node.admin');
$vids = \Drupal::entityManager()->getStorage('node')->userRevisionIds($account);
- node_mass_update($vids, array(
+ node_mass_update($vids, [
'uid' => 0,
'revision_uid' => 0,
- ), NULL, TRUE, TRUE);
+ ], NULL, TRUE, TRUE);
break;
}
}
@@ -779,7 +779,7 @@ function node_get_recent($number = 10) {
$nodes = Node::loadMultiple($nids);
- return $nodes ? $nodes : array();
+ return $nodes ? $nodes : [];
}
/**
@@ -825,12 +825,12 @@ function node_page_top(array &$page) {
// Add 'Back to content editing' link on preview page.
$route_match = \Drupal::routeMatch();
if ($route_match->getRouteName() == 'entity.node.preview') {
- $page['page_top']['node_preview'] = array(
+ $page['page_top']['node_preview'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('node-preview-container', 'container-inline')
- ),
- );
+ '#attributes' => [
+ 'class' => ['node-preview-container', 'container-inline']
+ ],
+ ];
$form = \Drupal::formBuilder()->getForm('\Drupal\node\Form\NodePreviewForm', $route_match->getParameter('node_preview'));
$page['page_top']['node_preview']['view_mode'] = $form;
@@ -845,12 +845,12 @@ function node_page_top(array &$page) {
* @see node_form_system_themes_admin_form_submit()
*/
function node_form_system_themes_admin_form_alter(&$form, FormStateInterface $form_state, $form_id) {
- $form['admin_theme']['use_admin_theme'] = array(
+ $form['admin_theme']['use_admin_theme'] = [
'#type' => 'checkbox',
'#title' => t('Use the administration theme when editing or creating content'),
- '#description' => t('Control which roles can "View the administration theme" on the <a href=":permissions">Permissions page</a>.', array(':permissions' => Url::fromRoute('user.admin_permissions')->toString())),
+ '#description' => t('Control which roles can "View the administration theme" on the <a href=":permissions">Permissions page</a>.', [':permissions' => Url::fromRoute('user.admin_permissions')->toString()]),
'#default_value' => \Drupal::configFactory()->getEditable('node.settings')->get('use_admin_theme'),
- );
+ ];
$form['#submit'][] = 'node_form_system_themes_admin_form_submit';
}
@@ -970,11 +970,11 @@ function node_node_access(NodeInterface $node, $op, $account) {
*/
function node_access_grants($op, AccountInterface $account) {
// Fetch node access grants from other modules.
- $grants = \Drupal::moduleHandler()->invokeAll('node_grants', array($account, $op));
+ $grants = \Drupal::moduleHandler()->invokeAll('node_grants', [$account, $op]);
// Allow modules to alter the assigned grants.
\Drupal::moduleHandler()->alter('node_grants', $grants, $account, $op);
- return array_merge(array('all' => array(0)), $grants);
+ return array_merge(['all' => [0]], $grants);
}
/**
@@ -1168,13 +1168,13 @@ function node_access_rebuild($batch_mode = FALSE) {
// Only recalculate if the site is using a node_access module.
if (count(\Drupal::moduleHandler()->getImplementations('node_grants'))) {
if ($batch_mode) {
- $batch = array(
+ $batch = [
'title' => t('Rebuilding content access permissions'),
- 'operations' => array(
- array('_node_access_rebuild_batch_operation', array()),
- ),
+ 'operations' => [
+ ['_node_access_rebuild_batch_operation', []],
+ ],
'finished' => '_node_access_rebuild_batch_finished'
- );
+ ];
batch_set($batch);
}
else {
@@ -1192,7 +1192,7 @@ function node_access_rebuild($batch_mode = FALSE) {
$entity_query->accessCheck(FALSE);
$nids = $entity_query->execute();
foreach ($nids as $nid) {
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = Node::load($nid);
// To preserve database integrity, only write grants if the node
// loads successfully.
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index 81fa3f088e0..2fcf0ddfa8f 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -14,71 +14,71 @@ use Drupal\user\Entity\User;
* Implements hook_token_info().
*/
function node_token_info() {
- $type = array(
+ $type = [
'name' => t('Nodes'),
'description' => t('Tokens related to individual content items, or "nodes".'),
'needs-data' => 'node',
- );
+ ];
// Core tokens for nodes.
- $node['nid'] = array(
+ $node['nid'] = [
'name' => t("Content ID"),
'description' => t('The unique ID of the content item, or "node".'),
- );
- $node['vid'] = array(
+ ];
+ $node['vid'] = [
'name' => t("Revision ID"),
'description' => t("The unique ID of the node's latest revision."),
- );
- $node['type'] = array(
+ ];
+ $node['type'] = [
'name' => t("Content type"),
- );
- $node['type-name'] = array(
+ ];
+ $node['type-name'] = [
'name' => t("Content type name"),
'description' => t("The human-readable name of the node type."),
- );
- $node['title'] = array(
+ ];
+ $node['title'] = [
'name' => t("Title"),
- );
- $node['body'] = array(
+ ];
+ $node['body'] = [
'name' => t("Body"),
'description' => t("The main body text of the node."),
- );
- $node['summary'] = array(
+ ];
+ $node['summary'] = [
'name' => t("Summary"),
'description' => t("The summary of the node's main body text."),
- );
- $node['langcode'] = array(
+ ];
+ $node['langcode'] = [
'name' => t('Language code'),
'description' => t('The language code of the language the node is written in.'),
- );
- $node['url'] = array(
+ ];
+ $node['url'] = [
'name' => t("URL"),
'description' => t("The URL of the node."),
- );
- $node['edit-url'] = array(
+ ];
+ $node['edit-url'] = [
'name' => t("Edit URL"),
'description' => t("The URL of the node's edit page."),
- );
+ ];
// Chained tokens for nodes.
- $node['created'] = array(
+ $node['created'] = [
'name' => t("Date created"),
'type' => 'date',
- );
- $node['changed'] = array(
+ ];
+ $node['changed'] = [
'name' => t("Date changed"),
'description' => t("The date the node was most recently updated."),
'type' => 'date',
- );
- $node['author'] = array(
+ ];
+ $node['author'] = [
'name' => t("Author"),
'type' => 'user',
- );
+ ];
- return array(
- 'types' => array('node' => $type),
- 'tokens' => array('node' => $node),
- );
+ return [
+ 'types' => ['node' => $type],
+ 'tokens' => ['node' => $node],
+ ];
}
/**
@@ -87,7 +87,7 @@ function node_token_info() {
function node_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@@ -95,7 +95,7 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
else {
$langcode = LanguageInterface::LANGCODE_DEFAULT;
}
- $replacements = array();
+ $replacements = [];
if ($type == 'node' && !empty($data['node'])) {
/** @var \Drupal\node\NodeInterface $node */
@@ -127,7 +127,7 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
case 'body':
case 'summary':
- $translation = \Drupal::entityManager()->getTranslationFromContext($node, $langcode, array('operation' => 'node_tokens'));
+ $translation = \Drupal::entityManager()->getTranslationFromContext($node, $langcode, ['operation' => 'node_tokens']);
if ($translation->hasField('body') && ($items = $translation->get('body')) && !$items->isEmpty()) {
$item = $items[0];
// If the summary was requested and is not empty, use it.
@@ -195,15 +195,15 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
}
if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) {
- $replacements += $token_service->generate('user', $author_tokens, array('user' => $node->getOwner()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('user', $author_tokens, ['user' => $node->getOwner()], $options, $bubbleable_metadata);
}
if ($created_tokens = $token_service->findWithPrefix($tokens, 'created')) {
- $replacements += $token_service->generate('date', $created_tokens, array('date' => $node->getCreatedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $created_tokens, ['date' => $node->getCreatedTime()], $options, $bubbleable_metadata);
}
if ($changed_tokens = $token_service->findWithPrefix($tokens, 'changed')) {
- $replacements += $token_service->generate('date', $changed_tokens, array('date' => $node->getChangedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $changed_tokens, ['date' => $node->getChangedTime()], $options, $bubbleable_metadata);
}
}
diff --git a/core/modules/node/node.views_execution.inc b/core/modules/node/node.views_execution.inc
index 193e47994d7..4d834a11e35 100644
--- a/core/modules/node/node.views_execution.inc
+++ b/core/modules/node/node.views_execution.inc
@@ -14,18 +14,18 @@ use Drupal\user\Entity\Role;
*/
function node_views_query_substitutions(ViewExecutable $view) {
$account = \Drupal::currentUser();
- return array(
+ return [
'***ADMINISTER_NODES***' => intval($account->hasPermission('administer nodes')),
'***VIEW_OWN_UNPUBLISHED_NODES***' => intval($account->hasPermission('view own unpublished content')),
'***BYPASS_NODE_ACCESS***' => intval($account->hasPermission('bypass node access')),
- );
+ ];
}
/**
* Implements hook_views_analyze().
*/
function node_views_analyze(ViewExecutable $view) {
- $ret = array();
+ $ret = [];
// Check for something other than the default display:
if ($view->storage->get('base_table') == 'node') {
foreach ($view->displayHandlers as $display) {
@@ -38,7 +38,7 @@ function node_views_analyze(ViewExecutable $view) {
$authenticated_role = Role::load(RoleInterface::AUTHENTICATED_ID);
$authenticated_has_access = $authenticated_role && $authenticated_role->hasPermission('access content');
if (!$anonymous_has_access || !$authenticated_has_access) {
- $ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', array('%display' => $display->display['display_title'])), 'warning');
+ $ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', ['%display' => $display->display['display_title']]), 'warning');
}
$filters = $display->getOption('filters');
foreach ($filters as $filter) {
@@ -46,7 +46,7 @@ function node_views_analyze(ViewExecutable $view) {
continue 2;
}
}
- $ret[] = Analyzer::formatMessage(t('Display %display has no access control but does not contain a filter for published nodes.', array('%display' => $display->display['display_title'])), 'warning');
+ $ret[] = Analyzer::formatMessage(t('Display %display has no access control but does not contain a filter for published nodes.', ['%display' => $display->display['display_title']]), 'warning');
}
}
}
@@ -54,7 +54,7 @@ function node_views_analyze(ViewExecutable $view) {
foreach ($view->displayHandlers as $display) {
if ($display->getPluginId() == 'page') {
if ($display->getOption('path') == 'node/%') {
- $ret[] = Analyzer::formatMessage(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.', array('%display' => $display->display['display_title'])), 'warning');
+ $ret[] = Analyzer::formatMessage(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.', ['%display' => $display->display['display_title']]), 'warning');
}
}
}
diff --git a/core/modules/node/src/Access/NodeRevisionAccessCheck.php b/core/modules/node/src/Access/NodeRevisionAccessCheck.php
index 2005ec7e74b..b85d783a1d1 100644
--- a/core/modules/node/src/Access/NodeRevisionAccessCheck.php
+++ b/core/modules/node/src/Access/NodeRevisionAccessCheck.php
@@ -35,7 +35,7 @@ class NodeRevisionAccessCheck implements AccessInterface {
*
* @var array
*/
- protected $access = array();
+ protected $access = [];
/**
* Constructs a new NodeRevisionAccessCheck.
@@ -90,17 +90,17 @@ class NodeRevisionAccessCheck implements AccessInterface {
* TRUE if the operation may be performed, FALSE otherwise.
*/
public function checkAccess(NodeInterface $node, AccountInterface $account, $op = 'view') {
- $map = array(
+ $map = [
'view' => 'view all revisions',
'update' => 'revert all revisions',
'delete' => 'delete all revisions',
- );
+ ];
$bundle = $node->bundle();
- $type_map = array(
+ $type_map = [
'view' => "view $bundle revisions",
'update' => "revert $bundle revisions",
'delete' => "delete $bundle revisions",
- );
+ ];
if (!$node || !isset($map[$op]) || !isset($type_map[$op])) {
// If there was no node to check against, or the $op was not one of the
diff --git a/core/modules/node/src/ContextProvider/NodeRouteContext.php b/core/modules/node/src/ContextProvider/NodeRouteContext.php
index 2b745e9e6e8..2e10a8a643c 100644
--- a/core/modules/node/src/ContextProvider/NodeRouteContext.php
+++ b/core/modules/node/src/ContextProvider/NodeRouteContext.php
@@ -48,7 +48,7 @@ class NodeRouteContext implements ContextProviderInterface {
}
elseif ($this->routeMatch->getRouteName() == 'node.add') {
$node_type = $this->routeMatch->getParameter('node_type');
- $value = Node::create(array('type' => $node_type->id()));
+ $value = Node::create(['type' => $node_type->id()]);
}
$cacheability = new CacheableMetadata();
diff --git a/core/modules/node/src/Controller/NodeController.php b/core/modules/node/src/Controller/NodeController.php
index 048b949c4bd..48401475fcd 100644
--- a/core/modules/node/src/Controller/NodeController.php
+++ b/core/modules/node/src/Controller/NodeController.php
@@ -74,7 +74,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
],
];
- $content = array();
+ $content = [];
// Only use node types the user has access to.
foreach ($this->entityManager()->getStorage('node_type')->loadMultiple() as $type) {
@@ -88,7 +88,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
// Bypass the node/add listing if only one content type is available.
if (count($content) == 1) {
$type = array_shift($content);
- return $this->redirect('node.add', array('node_type' => $type->id()));
+ return $this->redirect('node.add', ['node_type' => $type->id()]);
}
$build['#content'] = $content;
@@ -106,9 +106,9 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
* A node submission form.
*/
public function add(NodeTypeInterface $node_type) {
- $node = $this->entityManager()->getStorage('node')->create(array(
+ $node = $this->entityManager()->getStorage('node')->create([
'type' => $node_type->id(),
- ));
+ ]);
$form = $this->entityFormBuilder()->getForm($node);
@@ -144,7 +144,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
*/
public function revisionPageTitle($node_revision) {
$node = $this->entityManager()->getStorage('node')->loadRevision($node_revision);
- return $this->t('Revision of %title from %date', array('%title' => $node->label(), '%date' => format_date($node->getRevisionCreationTime())));
+ return $this->t('Revision of %title from %date', ['%title' => $node->label(), '%date' => format_date($node->getRevisionCreationTime())]);
}
/**
@@ -166,12 +166,12 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
$type = $node->getType();
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $node->label()]) : $this->t('Revisions for %title', ['%title' => $node->label()]);
- $header = array($this->t('Revision'), $this->t('Operations'));
+ $header = [$this->t('Revision'), $this->t('Operations')];
$revert_permission = (($account->hasPermission("revert $type revisions") || $account->hasPermission('revert all revisions') || $account->hasPermission('administer nodes')) && $node->access('update'));
$delete_permission = (($account->hasPermission("delete $type revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes')) && $node->access('delete'));
- $rows = array();
+ $rows = [];
$default_revision = $node->getRevisionId();
foreach ($this->getRevisionIds($node, $node_storage) as $vid) {
@@ -254,17 +254,17 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
}
}
- $build['node_revisions_table'] = array(
+ $build['node_revisions_table'] = [
'#theme' => 'table',
'#rows' => $rows,
'#header' => $header,
- '#attached' => array(
- 'library' => array('node/drupal.node.admin'),
- ),
+ '#attached' => [
+ 'library' => ['node/drupal.node.admin'],
+ ],
'#attributes' => ['class' => 'node-revision-table'],
- );
+ ];
- $build['pager'] = array('#type' => 'pager');
+ $build['pager'] = ['#type' => 'pager'];
return $build;
}
@@ -279,7 +279,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
* The page title.
*/
public function addPageTitle(NodeTypeInterface $node_type) {
- return $this->t('Create @name', array('@name' => $node_type->label()));
+ return $this->t('Create @name', ['@name' => $node_type->label()]);
}
/**
diff --git a/core/modules/node/src/Controller/NodeViewController.php b/core/modules/node/src/Controller/NodeViewController.php
index fce50e144ab..b8aa1e5a977 100644
--- a/core/modules/node/src/Controller/NodeViewController.php
+++ b/core/modules/node/src/Controller/NodeViewController.php
@@ -68,24 +68,24 @@ class NodeViewController extends EntityViewController {
// metadata if we have to check access.
if ($this->currentUser->isAuthenticated() || $url->access($this->currentUser)) {
// Set the node path as the canonical URL to prevent duplicate content.
- $build['#attached']['html_head_link'][] = array(
- array(
+ $build['#attached']['html_head_link'][] = [
+ [
'rel' => $rel,
'href' => $url->toString(),
- ),
+ ],
TRUE,
- );
+ ];
}
if ($rel == 'canonical') {
// Set the non-aliased canonical path as a default shortlink.
- $build['#attached']['html_head_link'][] = array(
- array(
+ $build['#attached']['html_head_link'][] = [
+ [
'rel' => 'shortlink',
'href' => $url->setOption('alias', TRUE)->toString(),
- ),
+ ],
TRUE,
- );
+ ];
}
}
diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php
index 263f7c8f733..c11a18889a3 100644
--- a/core/modules/node/src/Entity/Node.php
+++ b/core/modules/node/src/Entity/Node.php
@@ -371,15 +371,15 @@ class Node extends ContentEntityBase implements NodeInterface {
->setTranslatable(TRUE)
->setRevisionable(TRUE)
->setSetting('max_length', 255)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
@@ -389,20 +389,20 @@ class Node extends ContentEntityBase implements NodeInterface {
->setSetting('target_type', 'user')
->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId')
->setTranslatable(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
- 'settings' => array(
+ 'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'placeholder' => '',
- ),
- ))
+ ],
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
@@ -410,15 +410,15 @@ class Node extends ContentEntityBase implements NodeInterface {
->setDescription(t('The time that the node was created.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'datetime_timestamp',
'weight' => 10,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')
@@ -432,13 +432,13 @@ class Node extends ContentEntityBase implements NodeInterface {
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
- 'settings' => array(
+ 'settings' => [
'display_label' => TRUE,
- ),
+ ],
'weight' => 15,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['sticky'] = BaseFieldDefinition::create('boolean')
@@ -446,13 +446,13 @@ class Node extends ContentEntityBase implements NodeInterface {
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(FALSE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
- 'settings' => array(
+ 'settings' => [
'display_label' => TRUE,
- ),
+ ],
'weight' => 16,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['revision_timestamp'] = BaseFieldDefinition::create('created')
@@ -471,13 +471,13 @@ class Node extends ContentEntityBase implements NodeInterface {
->setDescription(t('Briefly describe the changes you have made.'))
->setRevisionable(TRUE)
->setDefaultValue('')
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textarea',
'weight' => 25,
- 'settings' => array(
+ 'settings' => [
'rows' => 4,
- ),
- ));
+ ],
+ ]);
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected'))
@@ -498,7 +498,7 @@ class Node extends ContentEntityBase implements NodeInterface {
* An array of default values.
*/
public static function getCurrentUserId() {
- return array(\Drupal::currentUser()->id());
+ return [\Drupal::currentUser()->id()];
}
}
diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php
index 23f24a468bb..e4a4c3b6c14 100644
--- a/core/modules/node/src/Entity/NodeType.php
+++ b/core/modules/node/src/Entity/NodeType.php
@@ -182,10 +182,10 @@ class NodeType extends ConfigEntityBundleBase implements NodeTypeInterface {
drupal_set_message(\Drupal::translation()->formatPlural($update_count,
'Changed the content type of 1 post from %old-type to %type.',
'Changed the content type of @count posts from %old-type to %type.',
- array(
+ [
'%old-type' => $this->getOriginalId(),
'%type' => $this->id(),
- )));
+ ]));
}
}
if ($update) {
diff --git a/core/modules/node/src/Form/DeleteMultiple.php b/core/modules/node/src/Form/DeleteMultiple.php
index 7066b94c3df..91d8ad4a9ea 100644
--- a/core/modules/node/src/Form/DeleteMultiple.php
+++ b/core/modules/node/src/Form/DeleteMultiple.php
@@ -20,7 +20,7 @@ class DeleteMultiple extends ConfirmFormBase {
*
* @var string[][]
*/
- protected $nodeInfo = array();
+ protected $nodeInfo = [];
/**
* The tempstore factory.
@@ -130,10 +130,10 @@ class DeleteMultiple extends ConfirmFormBase {
}
}
- $form['nodes'] = array(
+ $form['nodes'] = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
$form = parent::buildForm($form, $form_state);
return $form;
@@ -167,7 +167,7 @@ class DeleteMultiple extends ConfirmFormBase {
if ($delete_nodes) {
$this->storage->delete($delete_nodes);
- $this->logger('content')->notice('Deleted @count posts.', array('@count' => count($delete_nodes)));
+ $this->logger('content')->notice('Deleted @count posts.', ['@count' => count($delete_nodes)]);
}
if ($delete_translations) {
@@ -182,7 +182,7 @@ class DeleteMultiple extends ConfirmFormBase {
}
if ($count) {
$total_count += $count;
- $this->logger('content')->notice('Deleted @count content translations.', array('@count' => $count));
+ $this->logger('content')->notice('Deleted @count content translations.', ['@count' => $count]);
}
}
diff --git a/core/modules/node/src/Form/NodeDeleteForm.php b/core/modules/node/src/Form/NodeDeleteForm.php
index 7afac867f6b..da8c2025c11 100644
--- a/core/modules/node/src/Form/NodeDeleteForm.php
+++ b/core/modules/node/src/Form/NodeDeleteForm.php
@@ -27,10 +27,10 @@ class NodeDeleteForm extends ContentEntityDeleteForm {
]);
}
- return $this->t('The @type %title has been deleted.', array(
+ return $this->t('The @type %title has been deleted.', [
'@type' => $node_type,
'%title' => $this->getEntity()->label(),
- ));
+ ]);
}
/**
diff --git a/core/modules/node/src/Form/NodePreviewForm.php b/core/modules/node/src/Form/NodePreviewForm.php
index 829fee100a8..8b6125b87a8 100644
--- a/core/modules/node/src/Form/NodePreviewForm.php
+++ b/core/modules/node/src/Form/NodePreviewForm.php
@@ -72,18 +72,18 @@ class NodePreviewForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $node = NULL) {
$view_mode = $node->preview_view_mode;
- $query_options = array('query' => array('uuid' => $node->uuid()));
+ $query_options = ['query' => ['uuid' => $node->uuid()]];
$query = $this->getRequest()->query;
if ($query->has('destination')) {
$query_options['query']['destination'] = $query->get('destination');
}
- $form['backlink'] = array(
+ $form['backlink'] = [
'#type' => 'link',
'#title' => $this->t('Back to content editing'),
'#url' => $node->isNew() ? Url::fromRoute('node.add', ['node_type' => $node->bundle()]) : $node->urlInfo('edit-form'),
- '#options' => array('attributes' => array('class' => array('node-preview-backlink'))) + $query_options,
- );
+ '#options' => ['attributes' => ['class' => ['node-preview-backlink']]] + $query_options,
+ ];
// Always show full as an option, even if the display is not enabled.
$view_mode_options = ['full' => $this->t('Full')] + $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle());
@@ -93,28 +93,28 @@ class NodePreviewForm extends FormBase {
unset($view_mode_options['rss']);
unset($view_mode_options['search_index']);
- $form['uuid'] = array(
+ $form['uuid'] = [
'#type' => 'value',
'#value' => $node->uuid(),
- );
+ ];
- $form['view_mode'] = array(
+ $form['view_mode'] = [
'#type' => 'select',
'#title' => $this->t('View mode'),
'#options' => $view_mode_options,
'#default_value' => $view_mode,
- '#attributes' => array(
+ '#attributes' => [
'data-drupal-autosubmit' => TRUE,
- )
- );
+ ]
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Switch'),
- '#attributes' => array(
- 'class' => array('js-hide'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['js-hide'],
+ ],
+ ];
return $form;
}
diff --git a/core/modules/node/src/Form/NodeRevisionDeleteForm.php b/core/modules/node/src/Form/NodeRevisionDeleteForm.php
index 27eec48e563..86e5b59c125 100644
--- a/core/modules/node/src/Form/NodeRevisionDeleteForm.php
+++ b/core/modules/node/src/Form/NodeRevisionDeleteForm.php
@@ -81,14 +81,14 @@ class NodeRevisionDeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($this->revision->getRevisionCreationTime())));
+ return t('Are you sure you want to delete the revision from %revision-date?', ['%revision-date' => format_date($this->revision->getRevisionCreationTime())]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
- return new Url('entity.node.version_history', array('node' => $this->revision->id()));
+ return new Url('entity.node.version_history', ['node' => $this->revision->id()]);
}
/**
@@ -114,17 +114,17 @@ class NodeRevisionDeleteForm extends ConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->nodeStorage->deleteRevision($this->revision->getRevisionId());
- $this->logger('content')->notice('@type: deleted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
+ $this->logger('content')->notice('@type: deleted %title revision %revision.', ['@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
$node_type = $this->nodeTypeStorage->load($this->revision->bundle())->label();
- drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()), '@type' => $node_type, '%title' => $this->revision->label())));
+ drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '@type' => $node_type, '%title' => $this->revision->label()]));
$form_state->setRedirect(
'entity.node.canonical',
- array('node' => $this->revision->id())
+ ['node' => $this->revision->id()]
);
- if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $this->revision->id()))->fetchField() > 1) {
+ if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {node_field_revision} WHERE nid = :nid', [':nid' => $this->revision->id()])->fetchField() > 1) {
$form_state->setRedirect(
'entity.node.version_history',
- array('node' => $this->revision->id())
+ ['node' => $this->revision->id()]
);
}
}
diff --git a/core/modules/node/src/Form/NodeRevisionRevertForm.php b/core/modules/node/src/Form/NodeRevisionRevertForm.php
index 275d55ba223..09aab6f543f 100644
--- a/core/modules/node/src/Form/NodeRevisionRevertForm.php
+++ b/core/modules/node/src/Form/NodeRevisionRevertForm.php
@@ -77,7 +77,7 @@ class NodeRevisionRevertForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getCancelUrl() {
- return new Url('entity.node.version_history', array('node' => $this->revision->id()));
+ return new Url('entity.node.version_history', ['node' => $this->revision->id()]);
}
/**
@@ -120,7 +120,7 @@ class NodeRevisionRevertForm extends ConfirmFormBase {
drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', ['@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)]));
$form_state->setRedirect(
'entity.node.version_history',
- array('node' => $this->revision->id())
+ ['node' => $this->revision->id()]
);
}
diff --git a/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php b/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php
index 05a4f6c41c7..fd20dadce13 100644
--- a/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php
+++ b/core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php
@@ -82,11 +82,11 @@ class NodeRevisionRevertTranslationForm extends NodeRevisionRevertForm {
$this->langcode = $langcode;
$form = parent::buildForm($form, $form_state, $node_revision);
- $form['revert_untranslated_fields'] = array(
+ $form['revert_untranslated_fields'] = [
'#type' => 'checkbox',
'#title' => $this->t('Revert content shared among translations'),
'#default_value' => FALSE,
- );
+ ];
return $form;
}
diff --git a/core/modules/node/src/Form/NodeTypeDeleteConfirm.php b/core/modules/node/src/Form/NodeTypeDeleteConfirm.php
index 50abec1ad96..e4bea83fcb5 100644
--- a/core/modules/node/src/Form/NodeTypeDeleteConfirm.php
+++ b/core/modules/node/src/Form/NodeTypeDeleteConfirm.php
@@ -19,9 +19,9 @@ class NodeTypeDeleteConfirm extends EntityDeleteForm {
->count()
->execute();
if ($num_nodes) {
- $caption = '<p>' . $this->formatPlural($num_nodes, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', array('%type' => $this->entity->label())) . '</p>';
+ $caption = '<p>' . $this->formatPlural($num_nodes, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', ['%type' => $this->entity->label()]) . '</p>';
$form['#title'] = $this->getQuestion();
- $form['description'] = array('#markup' => $caption);
+ $form['description'] = ['#markup' => $caption];
return $form;
}
diff --git a/core/modules/node/src/NodeAccessControlHandler.php b/core/modules/node/src/NodeAccessControlHandler.php
index 89b816922d7..a8a0bc6241e 100644
--- a/core/modules/node/src/NodeAccessControlHandler.php
+++ b/core/modules/node/src/NodeAccessControlHandler.php
@@ -73,7 +73,7 @@ class NodeAccessControlHandler extends EntityAccessControlHandler implements Nod
/**
* {@inheritdoc}
*/
- public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE) {
+ public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE) {
$account = $this->prepareUser($account);
if ($account->hasPermission('bypass node access')) {
@@ -121,13 +121,13 @@ class NodeAccessControlHandler extends EntityAccessControlHandler implements Nod
protected function checkFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
// Only users with the administer nodes permission can edit administrative
// fields.
- $administrative_fields = array('uid', 'status', 'created', 'promote', 'sticky');
+ $administrative_fields = ['uid', 'status', 'created', 'promote', 'sticky'];
if ($operation == 'edit' && in_array($field_definition->getName(), $administrative_fields, TRUE)) {
return AccessResult::allowedIfHasPermission($account, 'administer nodes');
}
// No user can change read only fields.
- $read_only_fields = array('revision_timestamp', 'revision_uid');
+ $read_only_fields = ['revision_timestamp', 'revision_uid'];
if ($operation == 'edit' && in_array($field_definition->getName(), $read_only_fields, TRUE)) {
return AccessResult::forbidden();
}
@@ -147,12 +147,12 @@ class NodeAccessControlHandler extends EntityAccessControlHandler implements Nod
* {@inheritdoc}
*/
public function acquireGrants(NodeInterface $node) {
- $grants = $this->moduleHandler->invokeAll('node_access_records', array($node));
+ $grants = $this->moduleHandler->invokeAll('node_access_records', [$node]);
// Let modules alter the grants.
$this->moduleHandler->alter('node_access_records', $grants, $node);
// If no grants are set and the node is published, then use the default grant.
if (empty($grants) && $node->isPublished()) {
- $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0);
+ $grants[] = ['realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0];
}
return $grants;
}
diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php
index bb58377d770..9d2ce6d70f6 100644
--- a/core/modules/node/src/NodeForm.php
+++ b/core/modules/node/src/NodeForm.php
@@ -86,33 +86,33 @@ class NodeForm extends ContentEntityForm {
$node = $this->entity;
if ($this->operation == 'edit') {
- $form['#title'] = $this->t('<em>Edit @type</em> @title', array('@type' => node_get_type_label($node), '@title' => $node->label()));
+ $form['#title'] = $this->t('<em>Edit @type</em> @title', ['@type' => node_get_type_label($node), '@title' => $node->label()]);
}
// Changed must be sent to the client, for later overwrite error checking.
- $form['changed'] = array(
+ $form['changed'] = [
'#type' => 'hidden',
'#default_value' => $node->getChangedTime(),
- );
+ ];
$form = parent::form($form, $form_state);
$form['advanced']['#attributes']['class'][] = 'entity-meta';
// Node author information for administrators.
- $form['author'] = array(
+ $form['author'] = [
'#type' => 'details',
'#title' => t('Authoring information'),
'#group' => 'advanced',
- '#attributes' => array(
- 'class' => array('node-form-author'),
- ),
- '#attached' => array(
- 'library' => array('node/drupal.node'),
- ),
+ '#attributes' => [
+ 'class' => ['node-form-author'],
+ ],
+ '#attached' => [
+ 'library' => ['node/drupal.node'],
+ ],
'#weight' => 90,
'#optional' => TRUE,
- );
+ ];
if (isset($form['uid'])) {
$form['uid']['#group'] = 'author';
@@ -123,19 +123,19 @@ class NodeForm extends ContentEntityForm {
}
// Node options for administrators.
- $form['options'] = array(
+ $form['options'] = [
'#type' => 'details',
'#title' => t('Promotion options'),
'#group' => 'advanced',
- '#attributes' => array(
- 'class' => array('node-form-options'),
- ),
- '#attached' => array(
- 'library' => array('node/drupal.node'),
- ),
+ '#attributes' => [
+ 'class' => ['node-form-options'],
+ ],
+ '#attached' => [
+ 'library' => ['node/drupal.node'],
+ ],
'#weight' => 95,
'#optional' => TRUE,
- );
+ ];
if (isset($form['promote'])) {
$form['promote']['#group'] = 'options';
@@ -236,13 +236,13 @@ class NodeForm extends ContentEntityForm {
$element['submit']['#access'] = FALSE;
}
- $element['preview'] = array(
+ $element['preview'] = [
'#type' => 'submit',
'#access' => $preview_mode != DRUPAL_DISABLED && ($node->access('create') || $node->access('update')),
'#value' => t('Preview'),
'#weight' => 20,
- '#submit' => array('::submitForm', '::preview'),
- );
+ '#submit' => ['::submitForm', '::preview'],
+ ];
$element['delete']['#access'] = $node->access('delete');
$element['delete']['#weight'] = 100;
@@ -285,8 +285,8 @@ class NodeForm extends ContentEntityForm {
$insert = $node->isNew();
$node->save();
$node_link = $node->link($this->t('View'));
- $context = array('@type' => $node->getType(), '%title' => $node->label(), 'link' => $node_link);
- $t_args = array('@type' => node_get_type_label($node), '%title' => $node->link($node->label()));
+ $context = ['@type' => $node->getType(), '%title' => $node->label(), 'link' => $node_link];
+ $t_args = ['@type' => node_get_type_label($node), '%title' => $node->link($node->label())];
if ($insert) {
$this->logger('content')->notice('@type: added %title.', $context);
@@ -303,7 +303,7 @@ class NodeForm extends ContentEntityForm {
if ($node->access('view')) {
$form_state->setRedirect(
'entity.node.canonical',
- array('node' => $node->id())
+ ['node' => $node->id()]
);
}
else {
diff --git a/core/modules/node/src/NodeGrantDatabaseStorage.php b/core/modules/node/src/NodeGrantDatabaseStorage.php
index a0a13371a3d..993d0950d1a 100644
--- a/core/modules/node/src/NodeGrantDatabaseStorage.php
+++ b/core/modules/node/src/NodeGrantDatabaseStorage.php
@@ -161,7 +161,7 @@ class NodeGrantDatabaseStorage implements NodeGrantDatabaseStorageInterface {
if (!($table instanceof SelectInterface) && $table == $base_table) {
// Set the subquery.
$subquery = $this->database->select('node_access', 'na')
- ->fields('na', array('nid'));
+ ->fields('na', ['nid']);
// If any grant exists for the specified user, then user has access to the
// node for the specified operation.
@@ -202,13 +202,13 @@ class NodeGrantDatabaseStorage implements NodeGrantDatabaseStorageInterface {
if ($delete) {
$query = $this->database->delete('node_access')->condition('nid', $node->id());
if ($realm) {
- $query->condition('realm', array($realm, 'all'), 'IN');
+ $query->condition('realm', [$realm, 'all'], 'IN');
}
$query->execute();
}
// Only perform work when node_access modules are active.
if (!empty($grants) && count($this->moduleHandler->getImplementations('node_grants'))) {
- $query = $this->database->insert('node_access')->fields(array('nid', 'langcode', 'fallback', 'realm', 'gid', 'grant_view', 'grant_update', 'grant_delete'));
+ $query = $this->database->insert('node_access')->fields(['nid', 'langcode', 'fallback', 'realm', 'gid', 'grant_view', 'grant_update', 'grant_delete']);
// If we have defined a granted langcode, use it. But if not, add a grant
// for every language this node is translated to.
foreach ($grants as $grant) {
@@ -216,7 +216,7 @@ class NodeGrantDatabaseStorage implements NodeGrantDatabaseStorageInterface {
continue;
}
if (isset($grant['langcode'])) {
- $grant_languages = array($grant['langcode'] => $this->languageManager->getLanguage($grant['langcode']));
+ $grant_languages = [$grant['langcode'] => $this->languageManager->getLanguage($grant['langcode'])];
}
else {
$grant_languages = $node->getTranslationLanguages(TRUE);
@@ -253,14 +253,14 @@ class NodeGrantDatabaseStorage implements NodeGrantDatabaseStorageInterface {
*/
public function writeDefault() {
$this->database->insert('node_access')
- ->fields(array(
+ ->fields([
'nid' => 0,
'realm' => 'all',
'gid' => 0,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
- ))
+ ])
->execute();
}
diff --git a/core/modules/node/src/NodeListBuilder.php b/core/modules/node/src/NodeListBuilder.php
index 921ac9f3709..62666497e87 100644
--- a/core/modules/node/src/NodeListBuilder.php
+++ b/core/modules/node/src/NodeListBuilder.php
@@ -68,27 +68,27 @@ class NodeListBuilder extends EntityListBuilder {
*/
public function buildHeader() {
// Enable language column and filter if multiple languages are added.
- $header = array(
+ $header = [
'title' => $this->t('Title'),
- 'type' => array(
+ 'type' => [
'data' => $this->t('Content type'),
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
- ),
- 'author' => array(
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+ ],
+ 'author' => [
'data' => $this->t('Author'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
'status' => $this->t('Status'),
- 'changed' => array(
+ 'changed' => [
'data' => $this->t('Updated'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
- );
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
+ ];
if (\Drupal::languageManager()->isMultilingual()) {
- $header['language_name'] = array(
+ $header['language_name'] = [
'data' => $this->t('Language'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- );
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ];
}
return $header + parent::buildHeader();
}
@@ -98,26 +98,26 @@ class NodeListBuilder extends EntityListBuilder {
*/
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\node\NodeInterface $entity */
- $mark = array(
+ $mark = [
'#theme' => 'mark',
'#mark_type' => node_mark($entity->id(), $entity->getChangedTime()),
- );
+ ];
$langcode = $entity->language()->getId();
$uri = $entity->urlInfo();
$options = $uri->getOptions();
- $options += ($langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array());
+ $options += ($langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? ['language' => $languages[$langcode]] : []);
$uri->setOptions($options);
- $row['title']['data'] = array(
+ $row['title']['data'] = [
'#type' => 'link',
'#title' => $entity->label(),
'#suffix' => ' ' . drupal_render($mark),
'#url' => $uri,
- );
+ ];
$row['type'] = node_get_type_label($entity);
- $row['author']['data'] = array(
+ $row['author']['data'] = [
'#theme' => 'username',
'#account' => $entity->getOwner(),
- );
+ ];
$row['status'] = $entity->isPublished() ? $this->t('published') : $this->t('not published');
$row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short');
$language_manager = \Drupal::languageManager();
diff --git a/core/modules/node/src/NodePermissions.php b/core/modules/node/src/NodePermissions.php
index 0bc0cde4117..1996360ae1f 100644
--- a/core/modules/node/src/NodePermissions.php
+++ b/core/modules/node/src/NodePermissions.php
@@ -22,7 +22,7 @@ class NodePermissions {
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function nodeTypePermissions() {
- $perms = array();
+ $perms = [];
// Generate node permissions for all node types.
foreach (NodeType::loadMultiple() as $type) {
$perms += $this->buildPermissions($type);
@@ -42,37 +42,37 @@ class NodePermissions {
*/
protected function buildPermissions(NodeType $type) {
$type_id = $type->id();
- $type_params = array('%type_name' => $type->label());
+ $type_params = ['%type_name' => $type->label()];
- return array(
- "create $type_id content" => array(
+ return [
+ "create $type_id content" => [
'title' => $this->t('%type_name: Create new content', $type_params),
- ),
- "edit own $type_id content" => array(
+ ],
+ "edit own $type_id content" => [
'title' => $this->t('%type_name: Edit own content', $type_params),
- ),
- "edit any $type_id content" => array(
+ ],
+ "edit any $type_id content" => [
'title' => $this->t('%type_name: Edit any content', $type_params),
- ),
- "delete own $type_id content" => array(
+ ],
+ "delete own $type_id content" => [
'title' => $this->t('%type_name: Delete own content', $type_params),
- ),
- "delete any $type_id content" => array(
+ ],
+ "delete any $type_id content" => [
'title' => $this->t('%type_name: Delete any content', $type_params),
- ),
- "view $type_id revisions" => array(
+ ],
+ "view $type_id revisions" => [
'title' => $this->t('%type_name: View revisions', $type_params),
'description' => t('To view a revision, you also need permission to view the content item.'),
- ),
- "revert $type_id revisions" => array(
+ ],
+ "revert $type_id revisions" => [
'title' => $this->t('%type_name: Revert revisions', $type_params),
'description' => t('To revert a revision, you also need permission to edit the content item.'),
- ),
- "delete $type_id revisions" => array(
+ ],
+ "delete $type_id revisions" => [
'title' => $this->t('%type_name: Delete revisions', $type_params),
'description' => $this->t('To delete a revision, you also need permission to delete the content item.'),
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/node/src/NodeStorage.php b/core/modules/node/src/NodeStorage.php
index 3c7209307ed..af85a067d99 100644
--- a/core/modules/node/src/NodeStorage.php
+++ b/core/modules/node/src/NodeStorage.php
@@ -20,7 +20,7 @@ class NodeStorage extends SqlContentEntityStorage implements NodeStorageInterfac
public function revisionIds(NodeInterface $node) {
return $this->database->query(
'SELECT vid FROM {node_revision} WHERE nid=:nid ORDER BY vid',
- array(':nid' => $node->id())
+ [':nid' => $node->id()]
)->fetchCol();
}
@@ -30,7 +30,7 @@ class NodeStorage extends SqlContentEntityStorage implements NodeStorageInterfac
public function userRevisionIds(AccountInterface $account) {
return $this->database->query(
'SELECT vid FROM {node_field_revision} WHERE uid = :uid ORDER BY vid',
- array(':uid' => $account->id())
+ [':uid' => $account->id()]
)->fetchCol();
}
@@ -38,7 +38,7 @@ class NodeStorage extends SqlContentEntityStorage implements NodeStorageInterfac
* {@inheritdoc}
*/
public function countDefaultLanguageRevisions(NodeInterface $node) {
- return $this->database->query('SELECT COUNT(*) FROM {node_field_revision} WHERE nid = :nid AND default_langcode = 1', array(':nid' => $node->id()))->fetchField();
+ return $this->database->query('SELECT COUNT(*) FROM {node_field_revision} WHERE nid = :nid AND default_langcode = 1', [':nid' => $node->id()])->fetchField();
}
/**
@@ -46,7 +46,7 @@ class NodeStorage extends SqlContentEntityStorage implements NodeStorageInterfac
*/
public function updateType($old_type, $new_type) {
return $this->database->update('node')
- ->fields(array('type' => $new_type))
+ ->fields(['type' => $new_type])
->condition('type', $old_type)
->execute();
}
@@ -56,7 +56,7 @@ class NodeStorage extends SqlContentEntityStorage implements NodeStorageInterfac
*/
public function clearRevisionsLanguage(LanguageInterface $language) {
return $this->database->update('node_revision')
- ->fields(array('langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED))
+ ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])
->condition('langcode', $language->getId())
->execute();
}
diff --git a/core/modules/node/src/NodeStorageSchema.php b/core/modules/node/src/NodeStorageSchema.php
index 18d6303458a..ac45bb5d1ef 100644
--- a/core/modules/node/src/NodeStorageSchema.php
+++ b/core/modules/node/src/NodeStorageSchema.php
@@ -17,10 +17,10 @@ class NodeStorageSchema extends SqlContentEntityStorageSchema {
protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
$schema = parent::getEntitySchema($entity_type, $reset);
- $schema['node_field_data']['indexes'] += array(
- 'node__frontpage' => array('promote', 'status', 'sticky', 'created'),
- 'node__title_type' => array('title', array('type', 4)),
- );
+ $schema['node_field_data']['indexes'] += [
+ 'node__frontpage' => ['promote', 'status', 'sticky', 'created'],
+ 'node__title_type' => ['title', ['type', 4]],
+ ];
return $schema;
}
diff --git a/core/modules/node/src/NodeTranslationHandler.php b/core/modules/node/src/NodeTranslationHandler.php
index 2f6d2abfd93..ead0d5d5faf 100644
--- a/core/modules/node/src/NodeTranslationHandler.php
+++ b/core/modules/node/src/NodeTranslationHandler.php
@@ -39,7 +39,7 @@ class NodeTranslationHandler extends ContentTranslationHandler {
}
}
if (isset($status_translatable)) {
- foreach (array('publish', 'unpublish', 'submit') as $button) {
+ foreach (['publish', 'unpublish', 'submit'] as $button) {
if (isset($form['actions'][$button])) {
$form['actions'][$button]['#value'] .= ' ' . ($status_translatable ? t('(this translation)') : t('(all translations)'));
}
@@ -53,7 +53,7 @@ class NodeTranslationHandler extends ContentTranslationHandler {
*/
protected function entityFormTitle(EntityInterface $entity) {
$type_name = node_get_type_label($entity);
- return t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $entity->label()));
+ return t('<em>Edit @type</em> @title', ['@type' => $type_name, '@title' => $entity->label()]);
}
/**
diff --git a/core/modules/node/src/NodeTypeForm.php b/core/modules/node/src/NodeTypeForm.php
index d5fb99822e3..abef502e1e5 100644
--- a/core/modules/node/src/NodeTypeForm.php
+++ b/core/modules/node/src/NodeTypeForm.php
@@ -54,134 +54,134 @@ class NodeTypeForm extends BundleEntityFormBase {
// get the default values for workflow settings.
// @todo Make it possible to get default values without an entity.
// https://www.drupal.org/node/2318187
- $node = $this->entityManager->getStorage('node')->create(array('type' => $type->uuid()));
+ $node = $this->entityManager->getStorage('node')->create(['type' => $type->uuid()]);
}
else {
- $form['#title'] = $this->t('Edit %label content type', array('%label' => $type->label()));
+ $form['#title'] = $this->t('Edit %label content type', ['%label' => $type->label()]);
$fields = $this->entityManager->getFieldDefinitions('node', $type->id());
// Create a node to get the current values for workflow settings fields.
- $node = $this->entityManager->getStorage('node')->create(array('type' => $type->id()));
+ $node = $this->entityManager->getStorage('node')->create(['type' => $type->id()]);
}
- $form['name'] = array(
+ $form['name'] = [
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $type->label(),
'#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>Add content</em> page. This name must be unique.'),
'#required' => TRUE,
'#size' => 30,
- );
+ ];
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'machine_name',
'#default_value' => $type->id(),
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
'#disabled' => $type->isLocked(),
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => ['Drupal\node\Entity\NodeType', 'load'],
- 'source' => array('name'),
- ),
- '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %node-add page, in which underscores will be converted into hyphens.', array(
+ 'source' => ['name'],
+ ],
+ '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %node-add page, in which underscores will be converted into hyphens.', [
'%node-add' => t('Add content'),
- )),
- );
+ ]),
+ ];
- $form['description'] = array(
+ $form['description'] = [
'#title' => t('Description'),
'#type' => 'textarea',
'#default_value' => $type->getDescription(),
'#description' => t('This text will be displayed on the <em>Add new content</em> page.'),
- );
+ ];
- $form['additional_settings'] = array(
+ $form['additional_settings'] = [
'#type' => 'vertical_tabs',
- '#attached' => array(
- 'library' => array('node/drupal.content_types'),
- ),
- );
+ '#attached' => [
+ 'library' => ['node/drupal.content_types'],
+ ],
+ ];
- $form['submission'] = array(
+ $form['submission'] = [
'#type' => 'details',
'#title' => t('Submission form settings'),
'#group' => 'additional_settings',
'#open' => TRUE,
- );
- $form['submission']['title_label'] = array(
+ ];
+ $form['submission']['title_label'] = [
'#title' => t('Title field label'),
'#type' => 'textfield',
'#default_value' => $fields['title']->getLabel(),
'#required' => TRUE,
- );
- $form['submission']['preview_mode'] = array(
+ ];
+ $form['submission']['preview_mode'] = [
'#type' => 'radios',
'#title' => t('Preview before submitting'),
'#default_value' => $type->getPreviewMode(),
- '#options' => array(
+ '#options' => [
DRUPAL_DISABLED => t('Disabled'),
DRUPAL_OPTIONAL => t('Optional'),
DRUPAL_REQUIRED => t('Required'),
- ),
- );
- $form['submission']['help'] = array(
+ ],
+ ];
+ $form['submission']['help'] = [
'#type' => 'textarea',
'#title' => t('Explanation or submission guidelines'),
'#default_value' => $type->getHelp(),
'#description' => t('This text will be displayed at the top of the page when creating or editing content of this type.'),
- );
- $form['workflow'] = array(
+ ];
+ $form['workflow'] = [
'#type' => 'details',
'#title' => t('Publishing options'),
'#group' => 'additional_settings',
- );
- $workflow_options = array(
+ ];
+ $workflow_options = [
'status' => $node->status->value,
'promote' => $node->promote->value,
'sticky' => $node->sticky->value,
'revision' => $type->isNewRevision(),
- );
+ ];
// Prepare workflow options to be used for 'checkboxes' form element.
$keys = array_keys(array_filter($workflow_options));
$workflow_options = array_combine($keys, $keys);
- $form['workflow']['options'] = array(
+ $form['workflow']['options'] = [
'#type' => 'checkboxes',
'#title' => t('Default options'),
'#default_value' => $workflow_options,
- '#options' => array(
+ '#options' => [
'status' => t('Published'),
'promote' => t('Promoted to front page'),
'sticky' => t('Sticky at top of lists'),
'revision' => t('Create new revision'),
- ),
+ ],
'#description' => t('Users with the <em>Administer content</em> permission will be able to override these options.'),
- );
+ ];
if ($this->moduleHandler->moduleExists('language')) {
- $form['language'] = array(
+ $form['language'] = [
'#type' => 'details',
'#title' => t('Language settings'),
'#group' => 'additional_settings',
- );
+ ];
$language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $type->id());
- $form['language']['language_configuration'] = array(
+ $form['language']['language_configuration'] = [
'#type' => 'language_configuration',
- '#entity_information' => array(
+ '#entity_information' => [
'entity_type' => 'node',
'bundle' => $type->id(),
- ),
+ ],
'#default_value' => $language_configuration,
- );
+ ];
}
- $form['display'] = array(
+ $form['display'] = [
'#type' => 'details',
'#title' => t('Display settings'),
'#group' => 'additional_settings',
- );
- $form['display']['display_submitted'] = array(
+ ];
+ $form['display']['display_submitted'] = [
'#type' => 'checkbox',
'#title' => t('Display author and date information'),
'#default_value' => $type->displaySubmitted(),
'#description' => t('Author username and publish date will be displayed.'),
- );
+ ];
return $this->protectBundleIdElement($form);
}
@@ -205,7 +205,7 @@ class NodeTypeForm extends BundleEntityFormBase {
$id = trim($form_state->getValue('type'));
// '0' is invalid, since elsewhere we check it using empty().
if ($id == '0') {
- $form_state->setErrorByName('type', $this->t("Invalid machine-readable name. Enter a name other than %invalid.", array('%invalid' => $id)));
+ $form_state->setErrorByName('type', $this->t("Invalid machine-readable name. Enter a name other than %invalid.", ['%invalid' => $id]));
}
}
@@ -214,13 +214,13 @@ class NodeTypeForm extends BundleEntityFormBase {
*/
public function save(array $form, FormStateInterface $form_state) {
$type = $this->entity;
- $type->setNewRevision($form_state->getValue(array('options', 'revision')));
+ $type->setNewRevision($form_state->getValue(['options', 'revision']));
$type->set('type', trim($type->id()));
$type->set('name', trim($type->label()));
$status = $type->save();
- $t_args = array('%name' => $type->label());
+ $t_args = ['%name' => $type->label()];
if ($status == SAVED_UPDATED) {
drupal_set_message(t('The content type %name has been updated.', $t_args));
@@ -228,7 +228,7 @@ class NodeTypeForm extends BundleEntityFormBase {
elseif ($status == SAVED_NEW) {
node_add_body_field($type);
drupal_set_message(t('The content type %name has been added.', $t_args));
- $context = array_merge($t_args, array('link' => $type->link($this->t('View'), 'collection')));
+ $context = array_merge($t_args, ['link' => $type->link($this->t('View'), 'collection')]);
$this->logger('node')->notice('Added content type %name.', $context);
}
@@ -242,8 +242,8 @@ class NodeTypeForm extends BundleEntityFormBase {
// Update workflow options.
// @todo Make it possible to get default values without an entity.
// https://www.drupal.org/node/2318187
- $node = $this->entityManager->getStorage('node')->create(array('type' => $type->id()));
- foreach (array('status', 'promote', 'sticky') as $field_name) {
+ $node = $this->entityManager->getStorage('node')->create(['type' => $type->id()]);
+ foreach (['status', 'promote', 'sticky'] as $field_name) {
$value = (bool) $form_state->getValue(['options', $field_name]);
if ($node->$field_name->value != $value) {
$fields[$field_name]->getConfig($type->id())->setDefaultValue($value)->save();
diff --git a/core/modules/node/src/NodeTypeListBuilder.php b/core/modules/node/src/NodeTypeListBuilder.php
index bdd08745b27..be6e5f638b9 100644
--- a/core/modules/node/src/NodeTypeListBuilder.php
+++ b/core/modules/node/src/NodeTypeListBuilder.php
@@ -18,10 +18,10 @@ class NodeTypeListBuilder extends ConfigEntityListBuilder {
*/
public function buildHeader() {
$header['title'] = t('Name');
- $header['description'] = array(
+ $header['description'] = [
'data' => t('Description'),
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
- );
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+ ];
return $header + parent::buildHeader();
}
@@ -29,10 +29,10 @@ class NodeTypeListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
- $row['title'] = array(
+ $row['title'] = [
'data' => $entity->label(),
- 'class' => array('menu-label'),
- );
+ 'class' => ['menu-label'],
+ ];
$row['description']['data'] = ['#markup' => $entity->getDescription()];
return $row + parent::buildRow($entity);
}
diff --git a/core/modules/node/src/NodeViewBuilder.php b/core/modules/node/src/NodeViewBuilder.php
index c65250ee908..f96302bef3b 100644
--- a/core/modules/node/src/NodeViewBuilder.php
+++ b/core/modules/node/src/NodeViewBuilder.php
@@ -28,25 +28,25 @@ class NodeViewBuilder extends EntityViewBuilder {
$display = $displays[$bundle];
if ($display->getComponent('links')) {
- $build[$id]['links'] = array(
+ $build[$id]['links'] = [
'#lazy_builder' => [get_called_class() . '::renderLinks', [
$entity->id(),
$view_mode,
$entity->language()->getId(),
!empty($entity->in_preview),
]],
- );
+ ];
}
// Add Language field text element to node render array.
if ($display->getComponent('langcode')) {
- $build[$id]['langcode'] = array(
+ $build[$id]['langcode'] = [
'#type' => 'item',
'#title' => t('Language'),
'#markup' => $entity->language()->getName(),
'#prefix' => '<div id="field-language-display">',
'#suffix' => '</div>'
- );
+ ];
}
}
}
@@ -81,21 +81,21 @@ class NodeViewBuilder extends EntityViewBuilder {
* A renderable array representing the node links.
*/
public static function renderLinks($node_entity_id, $view_mode, $langcode, $is_in_preview) {
- $links = array(
+ $links = [
'#theme' => 'links__node',
- '#pre_render' => array('drupal_pre_render_links'),
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#pre_render' => ['drupal_pre_render_links'],
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
if (!$is_in_preview) {
$entity = Node::load($node_entity_id)->getTranslation($langcode);
$links['node'] = static::buildLinks($entity, $view_mode);
// Allow other modules to alter the node links.
- $hook_context = array(
+ $hook_context = [
'view_mode' => $view_mode,
'langcode' => $langcode,
- );
+ ];
\Drupal::moduleHandler()->alter('node_links', $links, $entity, $hook_context);
}
return $links;
@@ -113,30 +113,30 @@ class NodeViewBuilder extends EntityViewBuilder {
* An array that can be processed by drupal_pre_render_links().
*/
protected static function buildLinks(NodeInterface $entity, $view_mode) {
- $links = array();
+ $links = [];
// Always display a read more link on teasers because we have no way
// to know when a teaser view is different than a full view.
if ($view_mode == 'teaser') {
$node_title_stripped = strip_tags($entity->label());
- $links['node-readmore'] = array(
- 'title' => t('Read more<span class="visually-hidden"> about @title</span>', array(
+ $links['node-readmore'] = [
+ 'title' => t('Read more<span class="visually-hidden"> about @title</span>', [
'@title' => $node_title_stripped,
- )),
+ ]),
'url' => $entity->urlInfo(),
'language' => $entity->language(),
- 'attributes' => array(
+ 'attributes' => [
'rel' => 'tag',
'title' => $node_title_stripped,
- ),
- );
+ ],
+ ];
}
- return array(
+ return [
'#theme' => 'links__node__node',
'#links' => $links,
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
}
/**
diff --git a/core/modules/node/src/NodeViewsData.php b/core/modules/node/src/NodeViewsData.php
index 21e1e44b2d5..b5aebf48fa2 100644
--- a/core/modules/node/src/NodeViewsData.php
+++ b/core/modules/node/src/NodeViewsData.php
@@ -39,15 +39,15 @@ class NodeViewsData extends EntityViewsData {
// Use status = 1 instead of status <> 0 in WHERE statement.
$data['node_field_data']['status']['filter']['use_equal'] = TRUE;
- $data['node_field_data']['status_extra'] = array(
+ $data['node_field_data']['status_extra'] = [
'title' => $this->t('Published status or admin user'),
'help' => $this->t('Filters out unpublished content if the current user cannot view it.'),
- 'filter' => array(
+ 'filter' => [
'field' => 'status',
'id' => 'node_status',
'label' => $this->t('Published status or admin user'),
- ),
- );
+ ],
+ ];
$data['node_field_data']['promote']['help'] = $this->t('A boolean indicating whether the node is visible on the front page.');
$data['node_field_data']['promote']['filter']['label'] = $this->t('Promoted to front page status');
@@ -58,133 +58,133 @@ class NodeViewsData extends EntityViewsData {
$data['node_field_data']['sticky']['filter']['type'] = 'yes-no';
$data['node_field_data']['sticky']['sort']['help'] = $this->t('Whether or not the content is sticky. To list sticky content first, set this to descending.');
- $data['node']['path'] = array(
- 'field' => array(
+ $data['node']['path'] = [
+ 'field' => [
'title' => $this->t('Path'),
'help' => $this->t('The aliased path to this content.'),
'id' => 'node_path',
- ),
- );
+ ],
+ ];
- $data['node']['node_bulk_form'] = array(
+ $data['node']['node_bulk_form'] = [
'title' => $this->t('Node operations bulk form'),
'help' => $this->t('Add a form element that lets you run operations on multiple nodes.'),
- 'field' => array(
+ 'field' => [
'id' => 'node_bulk_form',
- ),
- );
+ ],
+ ];
// Bogus fields for aliasing purposes.
// @todo Add similar support to any date field
// @see https://www.drupal.org/node/2337507
- $data['node_field_data']['created_fulldate'] = array(
+ $data['node_field_data']['created_fulldate'] = [
'title' => $this->t('Created date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['created_year_month'] = array(
+ $data['node_field_data']['created_year_month'] = [
'title' => $this->t('Created year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['created_year'] = array(
+ $data['node_field_data']['created_year'] = [
'title' => $this->t('Created year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['created_month'] = array(
+ $data['node_field_data']['created_month'] = [
'title' => $this->t('Created month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['created_day'] = array(
+ $data['node_field_data']['created_day'] = [
'title' => $this->t('Created day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['created_week'] = array(
+ $data['node_field_data']['created_week'] = [
'title' => $this->t('Created week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['changed_fulldate'] = array(
+ $data['node_field_data']['changed_fulldate'] = [
'title' => $this->t('Updated date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['changed_year_month'] = array(
+ $data['node_field_data']['changed_year_month'] = [
'title' => $this->t('Updated year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['changed_year'] = array(
+ $data['node_field_data']['changed_year'] = [
'title' => $this->t('Updated year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['changed_month'] = array(
+ $data['node_field_data']['changed_month'] = [
'title' => $this->t('Updated month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['changed_day'] = array(
+ $data['node_field_data']['changed_day'] = [
'title' => $this->t('Updated day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['changed_week'] = array(
+ $data['node_field_data']['changed_week'] = [
'title' => $this->t('Updated week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
$data['node_field_data']['uid']['help'] = $this->t('The user authoring the content. If you need more fields than the uid add the content: author relationship');
$data['node_field_data']['uid']['filter']['id'] = 'user_name';
@@ -192,13 +192,13 @@ class NodeViewsData extends EntityViewsData {
$data['node_field_data']['uid']['relationship']['help'] = $this->t('Relate content to the user who created it.');
$data['node_field_data']['uid']['relationship']['label'] = $this->t('author');
- $data['node']['node_listing_empty'] = array(
+ $data['node']['node_listing_empty'] = [
'title' => $this->t('Empty Node Frontpage behavior'),
'help' => $this->t('Provides a link to the node add overview page.'),
- 'area' => array(
+ 'area' => [
'id' => 'node_listing_empty',
- ),
- );
+ ],
+ ];
$data['node_field_data']['uid_revision']['title'] = $this->t('User has a revision');
$data['node_field_data']['uid_revision']['help'] = $this->t('All nodes where a certain user has a revision');
@@ -225,19 +225,19 @@ class NodeViewsData extends EntityViewsData {
$data['node_field_revision']['nid']['relationship']['title'] = $this->t('Content');
$data['node_field_revision']['nid']['relationship']['label'] = $this->t('Get the actual content from a content revision.');
- $data['node_field_revision']['vid'] = array(
- 'argument' => array(
+ $data['node_field_revision']['vid'] = [
+ 'argument' => [
'id' => 'node_vid',
'numeric' => TRUE,
- ),
- 'relationship' => array(
+ ],
+ 'relationship' => [
'id' => 'standard',
'base' => 'node_field_data',
'base field' => 'vid',
'title' => $this->t('Content'),
'label' => $this->t('Get the actual content from a content revision.'),
- ),
- ) + $data['node_field_revision']['vid'];
+ ],
+ ] + $data['node_field_revision']['vid'];
$data['node_field_revision']['langcode']['help'] = $this->t('The language the original content is in.');
@@ -259,52 +259,52 @@ class NodeViewsData extends EntityViewsData {
$data['node_field_revision']['langcode']['help'] = $this->t('The language of the content or translation.');
- $data['node_field_revision']['link_to_revision'] = array(
- 'field' => array(
+ $data['node_field_revision']['link_to_revision'] = [
+ 'field' => [
'title' => $this->t('Link to revision'),
'help' => $this->t('Provide a simple link to the revision.'),
'id' => 'node_revision_link',
'click sortable' => FALSE,
- ),
- );
+ ],
+ ];
- $data['node_field_revision']['revert_revision'] = array(
- 'field' => array(
+ $data['node_field_revision']['revert_revision'] = [
+ 'field' => [
'title' => $this->t('Link to revert revision'),
'help' => $this->t('Provide a simple link to revert to the revision.'),
'id' => 'node_revision_link_revert',
'click sortable' => FALSE,
- ),
- );
+ ],
+ ];
- $data['node_field_revision']['delete_revision'] = array(
- 'field' => array(
+ $data['node_field_revision']['delete_revision'] = [
+ 'field' => [
'title' => $this->t('Link to delete revision'),
'help' => $this->t('Provide a simple link to delete the content revision.'),
'id' => 'node_revision_link_delete',
'click sortable' => FALSE,
- ),
- );
+ ],
+ ];
// Define the base group of this table. Fields that don't have a group defined
// will go into this field by default.
$data['node_access']['table']['group'] = $this->t('Content access');
// For other base tables, explain how we join.
- $data['node_access']['table']['join'] = array(
- 'node_field_data' => array(
+ $data['node_access']['table']['join'] = [
+ 'node_field_data' => [
'left_field' => 'nid',
'field' => 'nid',
- ),
- );
- $data['node_access']['nid'] = array(
+ ],
+ ];
+ $data['node_access']['nid'] = [
'title' => $this->t('Access'),
'help' => $this->t('Filter by access.'),
- 'filter' => array(
+ 'filter' => [
'id' => 'node_access',
'help' => $this->t('Filter for content by view access. <strong>Not necessary if you are using node as your base table.</strong>'),
- ),
- );
+ ],
+ ];
// Add search table, fields, filters, etc., but only if a page using the
// node_search plugin is enabled.
@@ -324,61 +324,61 @@ class NodeViewsData extends EntityViewsData {
// Automatically join to the node table (or actually, node_field_data).
// Use a Views table alias to allow other modules to use this table too,
// if they use the search index.
- $data['node_search_index']['table']['join'] = array(
- 'node_field_data' => array(
+ $data['node_search_index']['table']['join'] = [
+ 'node_field_data' => [
'left_field' => 'nid',
'field' => 'sid',
'table' => 'search_index',
'extra' => "node_search_index.type = 'node_search' AND node_search_index.langcode = node_field_data.langcode",
- )
- );
+ ]
+ ];
- $data['node_search_total']['table']['join'] = array(
- 'node_search_index' => array(
+ $data['node_search_total']['table']['join'] = [
+ 'node_search_index' => [
'left_field' => 'word',
'field' => 'word',
- ),
- );
+ ],
+ ];
- $data['node_search_dataset']['table']['join'] = array(
- 'node_field_data' => array(
+ $data['node_search_dataset']['table']['join'] = [
+ 'node_field_data' => [
'left_field' => 'sid',
'left_table' => 'node_search_index',
'field' => 'sid',
'table' => 'search_dataset',
'extra' => 'node_search_index.type = node_search_dataset.type AND node_search_index.langcode = node_search_dataset.langcode',
'type' => 'INNER',
- ),
- );
+ ],
+ ];
- $data['node_search_index']['score'] = array(
+ $data['node_search_index']['score'] = [
'title' => $this->t('Score'),
'help' => $this->t('The score of the search item. This will not be used if the search filter is not also present.'),
- 'field' => array(
+ 'field' => [
'id' => 'search_score',
'float' => TRUE,
'no group by' => TRUE,
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'search_score',
'no group by' => TRUE,
- ),
- );
+ ],
+ ];
- $data['node_search_index']['keys'] = array(
+ $data['node_search_index']['keys'] = [
'title' => $this->t('Search Keywords'),
'help' => $this->t('The keywords to search for.'),
- 'filter' => array(
+ 'filter' => [
'id' => 'search_keywords',
'no group by' => TRUE,
'search_type' => 'node_search',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'search',
'no group by' => TRUE,
'search_type' => 'node_search',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
index 7c4412d0c66..d9a9a4355da 100644
--- a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
+++ b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
@@ -67,9 +67,9 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'owner_uid' => '',
- );
+ ];
}
/**
@@ -81,34 +81,34 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
// Use dropdown for fewer than 200 users; textbox for more than that.
if (intval($count) < 200) {
- $options = array();
+ $options = [];
$result = $this->connection->query("SELECT uid, name FROM {users_field_data} WHERE uid > 0 AND default_langcode = 1 ORDER BY name");
foreach ($result as $data) {
$options[$data->uid] = $data->name;
}
- $form['owner_uid'] = array(
+ $form['owner_uid'] = [
'#type' => 'select',
'#title' => t('Username'),
'#default_value' => $this->configuration['owner_uid'],
'#options' => $options,
'#description' => $description,
- );
+ ];
}
else {
- $form['owner_uid'] = array(
+ $form['owner_uid'] = [
'#type' => 'entity_autocomplete',
'#title' => t('Username'),
'#target_type' => 'user',
- '#selection_setttings' => array(
+ '#selection_setttings' => [
'include_anonymous' => FALSE,
- ),
+ ],
'#default_value' => User::load($this->configuration['owner_uid']),
// Validation is done in static::validateConfigurationForm().
'#validate_reference' => FALSE,
'#size' => '6',
'#maxlength' => '60',
'#description' => $description,
- );
+ ];
}
return $form;
}
@@ -117,7 +117,7 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
- $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', 0, 1, array(':uid' => $form_state->getValue('owner_uid')))->fetchField();
+ $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', 0, 1, [':uid' => $form_state->getValue('owner_uid')])->fetchField();
if (!$exists) {
$form_state->setErrorByName('owner_uid', t('Enter a valid username.'));
}
diff --git a/core/modules/node/src/Plugin/Action/DeleteNode.php b/core/modules/node/src/Plugin/Action/DeleteNode.php
index 83124f11687..5bf5d9ec38e 100644
--- a/core/modules/node/src/Plugin/Action/DeleteNode.php
+++ b/core/modules/node/src/Plugin/Action/DeleteNode.php
@@ -85,7 +85,7 @@ class DeleteNode extends ActionBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public function execute($object = NULL) {
- $this->executeMultiple(array($object));
+ $this->executeMultiple([$object]);
}
/**
diff --git a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php
index 6ec835eb4c3..c0081882ce7 100644
--- a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php
+++ b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php
@@ -36,21 +36,21 @@ class UnpublishByKeywordNode extends ConfigurableActionBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
- 'keywords' => array(),
- );
+ return [
+ 'keywords' => [],
+ ];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['keywords'] = array(
+ $form['keywords'] = [
'#title' => t('Keywords'),
'#type' => 'textarea',
'#description' => t('The content will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
'#default_value' => Tags::implode($this->configuration['keywords']),
- );
+ ];
return $form;
}
diff --git a/core/modules/node/src/Plugin/Block/SyndicateBlock.php b/core/modules/node/src/Plugin/Block/SyndicateBlock.php
index 07b969b5078..bcc98d04baf 100644
--- a/core/modules/node/src/Plugin/Block/SyndicateBlock.php
+++ b/core/modules/node/src/Plugin/Block/SyndicateBlock.php
@@ -21,9 +21,9 @@ class SyndicateBlock extends BlockBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'block_count' => 10,
- );
+ ];
}
/**
@@ -37,10 +37,10 @@ class SyndicateBlock extends BlockBase {
* {@inheritdoc}
*/
public function build() {
- return array(
+ return [
'#theme' => 'feed_icon',
'#url' => 'rss.xml',
- );
+ ];
}
}
diff --git a/core/modules/node/src/Plugin/Condition/NodeType.php b/core/modules/node/src/Plugin/Condition/NodeType.php
index ace42e6208e..dcd2dc7d306 100644
--- a/core/modules/node/src/Plugin/Condition/NodeType.php
+++ b/core/modules/node/src/Plugin/Condition/NodeType.php
@@ -64,17 +64,17 @@ class NodeType extends ConditionPluginBase implements ContainerFactoryPluginInte
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $options = array();
+ $options = [];
$node_types = $this->entityStorage->loadMultiple();
foreach ($node_types as $type) {
$options[$type->id()] = $type->label();
}
- $form['bundles'] = array(
+ $form['bundles'] = [
'#title' => $this->t('Node types'),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => $this->configuration['bundles'],
- );
+ ];
return parent::buildConfigurationForm($form, $form_state);
}
@@ -94,10 +94,10 @@ class NodeType extends ConditionPluginBase implements ContainerFactoryPluginInte
$bundles = $this->configuration['bundles'];
$last = array_pop($bundles);
$bundles = implode(', ', $bundles);
- return $this->t('The node bundle is @bundles or @last', array('@bundles' => $bundles, '@last' => $last));
+ return $this->t('The node bundle is @bundles or @last', ['@bundles' => $bundles, '@last' => $last]);
}
$bundle = reset($this->configuration['bundles']);
- return $this->t('The node bundle is @bundle', array('@bundle' => $bundle));
+ return $this->t('The node bundle is @bundle', ['@bundle' => $bundle]);
}
/**
@@ -115,7 +115,7 @@ class NodeType extends ConditionPluginBase implements ContainerFactoryPluginInte
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array('bundles' => array()) + parent::defaultConfiguration();
+ return ['bundles' => []] + parent::defaultConfiguration();
}
}
diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php
index ef61064e026..6d7c8eb7d47 100644
--- a/core/modules/node/src/Plugin/Search/NodeSearch.php
+++ b/core/modules/node/src/Plugin/Search/NodeSearch.php
@@ -102,12 +102,12 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
*
* @var array
*/
- protected $advanced = array(
- 'type' => array('column' => 'n.type'),
- 'language' => array('column' => 'i.langcode'),
- 'author' => array('column' => 'n.uid'),
- 'term' => array('column' => 'ti.tid', 'join' => array('table' => 'taxonomy_index', 'alias' => 'ti', 'condition' => 'n.nid = ti.nid')),
- );
+ protected $advanced = [
+ 'type' => ['column' => 'n.type'],
+ 'language' => ['column' => 'i.langcode'],
+ 'author' => ['column' => 'n.uid'],
+ 'term' => ['column' => 'ti.tid', 'join' => ['table' => 'taxonomy_index', 'alias' => 'ti', 'condition' => 'n.nid = ti.nid']],
+ ];
/**
* A constant for setting and checking the query string.
@@ -207,7 +207,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
}
}
- return array();
+ return [];
}
/**
@@ -225,7 +225,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
// Build matching conditions.
$query = $this->database
- ->select('search_index', 'i', array('target' => 'replica'))
+ ->select('search_index', 'i', ['target' => 'replica'])
->extend('Drupal\search\SearchQuery')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->join('node_field_data', 'n', 'n.nid = i.sid AND n.langcode = i.langcode');
@@ -242,7 +242,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
// the keywords string, and some of which are separate conditions.
$parameters = $this->getParameters();
if (!empty($parameters['f']) && is_array($parameters['f'])) {
- $filters = array();
+ $filters = [];
// Match any query value that is an expected option and a value
// separated by ':' like 'term:27'.
$pattern = '/^(' . implode('|', array_keys($this->advanced)) . '):([^ ]*)/i';
@@ -277,7 +277,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$find = $query
// Add the language code of the indexed item to the result of the query,
// since the node will be rendered using the respective language.
- ->fields('i', array('langcode'))
+ ->fields('i', ['langcode'])
// And since SearchQuery makes these into GROUP BY queries, if we add
// a field, for PostgreSQL we also need to make it an aggregate or a
// GROUP BY. In this case, we want GROUP BY.
@@ -289,7 +289,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$status = $query->getStatus();
if ($status & SearchQuery::EXPRESSIONS_IGNORED) {
- drupal_set_message($this->t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => $this->searchSettings->get('and_or_limit'))), 'warning');
+ drupal_set_message($this->t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', ['@count' => $this->searchSettings->get('and_or_limit')]), 'warning');
}
if ($status & SearchQuery::LOWER_CASE_OR) {
@@ -313,7 +313,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
* Array of search result item render arrays (empty array if no results).
*/
protected function prepareResults(StatementInterface $found) {
- $results = array();
+ $results = [];
$node_storage = $this->entityManager->getStorage('node');
$node_render = $this->entityManager->getViewBuilder('node');
@@ -329,7 +329,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$type = $this->entityManager->getStorage('node_type')->load($node->bundle());
unset($build['#theme']);
- $build['#pre_render'][] = array($this, 'removeSubmittedInfo');
+ $build['#pre_render'][] = [$this, 'removeSubmittedInfo'];
// Fetch comments for snippet.
$rendered = $this->renderer->renderPlain($build);
@@ -339,13 +339,13 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$extra = $this->moduleHandler->invokeAll('node_search_result', [$node]);
$language = $this->languageManager->getLanguage($item->langcode);
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $node->getOwner(),
- );
+ ];
- $result = array(
- 'link' => $node->url('canonical', array('absolute' => TRUE, 'language' => $language)),
+ $result = [
+ 'link' => $node->url('canonical', ['absolute' => TRUE, 'language' => $language]),
'type' => $type->label(),
'title' => $node->label(),
'node' => $node,
@@ -353,7 +353,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
'score' => $item->calculated_score,
'snippet' => search_excerpt($keys, $rendered, $item->langcode),
'langcode' => $node->language()->getId(),
- );
+ ];
$this->addCacheableDependency($node);
@@ -364,10 +364,10 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$this->addCacheableDependency($node->getOwner());
if ($type->displaySubmitted()) {
- $result += array(
+ $result += [
'user' => $this->renderer->renderPlain($username),
'date' => $node->getChangedTime(),
- );
+ ];
}
$results[] = $result;
@@ -411,7 +411,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
if (isset($values['join']) && !isset($tables[$values['join']['alias']])) {
$query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']);
}
- $arguments = isset($values['arguments']) ? $values['arguments'] : array();
+ $arguments = isset($values['arguments']) ? $values['arguments'] : [];
$query->addScore($values['score'], $arguments, $node_rank);
}
}
@@ -426,9 +426,9 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
// per cron run.
$limit = (int) $this->searchSettings->get('index.cron_limit');
- $query = db_select('node', 'n', array('target' => 'replica'));
+ $query = db_select('node', 'n', ['target' => 'replica']);
$query->addField('n', 'nid');
- $query->leftJoin('search_dataset', 'sd', 'sd.sid = n.nid AND sd.type = :type', array(':type' => $this->getPluginId()));
+ $query->leftJoin('search_dataset', 'sd', 'sd.sid = n.nid AND sd.type = :type', [':type' => $this->getPluginId()]);
$query->addExpression('CASE MAX(sd.reindex) WHEN NULL THEN 0 ELSE 1 END', 'ex');
$query->addExpression('MAX(sd.reindex)', 'ex2');
$query->condition(
@@ -513,9 +513,9 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
*/
public function indexStatus() {
$total = $this->database->query('SELECT COUNT(*) FROM {node}')->fetchField();
- $remaining = $this->database->query("SELECT COUNT(DISTINCT n.nid) FROM {node} n LEFT JOIN {search_dataset} sd ON sd.sid = n.nid AND sd.type = :type WHERE sd.sid IS NULL OR sd.reindex <> 0", array(':type' => $this->getPluginId()))->fetchField();
+ $remaining = $this->database->query("SELECT COUNT(DISTINCT n.nid) FROM {node} n LEFT JOIN {search_dataset} sd ON sd.sid = n.nid AND sd.type = :type WHERE sd.sid IS NULL OR sd.reindex <> 0", [':type' => $this->getPluginId()])->fetchField();
- return array('remaining' => $remaining, 'total' => $total);
+ return ['remaining' => $remaining, 'total' => $total];
}
/**
@@ -526,100 +526,100 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$keys = $this->getKeywords();
$used_advanced = !empty($parameters[self::ADVANCED_FORM]);
if ($used_advanced) {
- $f = isset($parameters['f']) ? (array) $parameters['f'] : array();
+ $f = isset($parameters['f']) ? (array) $parameters['f'] : [];
$defaults = $this->parseAdvancedDefaults($f, $keys);
}
else {
- $defaults = array('keys' => $keys);
+ $defaults = ['keys' => $keys];
}
$form['basic']['keys']['#default_value'] = $defaults['keys'];
// Add advanced search keyword-related boxes.
- $form['advanced'] = array(
+ $form['advanced'] = [
'#type' => 'details',
'#title' => t('Advanced search'),
- '#attributes' => array('class' => array('search-advanced')),
+ '#attributes' => ['class' => ['search-advanced']],
'#access' => $this->account && $this->account->hasPermission('use advanced search'),
'#open' => $used_advanced,
- );
- $form['advanced']['keywords-fieldset'] = array(
+ ];
+ $form['advanced']['keywords-fieldset'] = [
'#type' => 'fieldset',
'#title' => t('Keywords'),
- );
+ ];
- $form['advanced']['keywords'] = array(
+ $form['advanced']['keywords'] = [
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
- );
+ ];
- $form['advanced']['keywords-fieldset']['keywords']['or'] = array(
+ $form['advanced']['keywords-fieldset']['keywords']['or'] = [
'#type' => 'textfield',
'#title' => t('Containing any of the words'),
'#size' => 30,
'#maxlength' => 255,
'#default_value' => isset($defaults['or']) ? $defaults['or'] : '',
- );
+ ];
- $form['advanced']['keywords-fieldset']['keywords']['phrase'] = array(
+ $form['advanced']['keywords-fieldset']['keywords']['phrase'] = [
'#type' => 'textfield',
'#title' => t('Containing the phrase'),
'#size' => 30,
'#maxlength' => 255,
'#default_value' => isset($defaults['phrase']) ? $defaults['phrase'] : '',
- );
+ ];
- $form['advanced']['keywords-fieldset']['keywords']['negative'] = array(
+ $form['advanced']['keywords-fieldset']['keywords']['negative'] = [
'#type' => 'textfield',
'#title' => t('Containing none of the words'),
'#size' => 30,
'#maxlength' => 255,
'#default_value' => isset($defaults['negative']) ? $defaults['negative'] : '',
- );
+ ];
// Add node types.
- $types = array_map(array('\Drupal\Component\Utility\Html', 'escape'), node_type_get_names());
- $form['advanced']['types-fieldset'] = array(
+ $types = array_map(['\Drupal\Component\Utility\Html', 'escape'], node_type_get_names());
+ $form['advanced']['types-fieldset'] = [
'#type' => 'fieldset',
'#title' => t('Types'),
- );
- $form['advanced']['types-fieldset']['type'] = array(
+ ];
+ $form['advanced']['types-fieldset']['type'] = [
'#type' => 'checkboxes',
'#title' => t('Only of the type(s)'),
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
'#options' => $types,
- '#default_value' => isset($defaults['type']) ? $defaults['type'] : array(),
- );
+ '#default_value' => isset($defaults['type']) ? $defaults['type'] : [],
+ ];
- $form['advanced']['submit'] = array(
+ $form['advanced']['submit'] = [
'#type' => 'submit',
'#value' => t('Advanced search'),
'#prefix' => '<div class="action">',
'#suffix' => '</div>',
'#weight' => 100,
- );
+ ];
// Add languages.
- $language_options = array();
+ $language_options = [];
$language_list = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL);
foreach ($language_list as $langcode => $language) {
// Make locked languages appear special in the list.
- $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
+ $language_options[$langcode] = $language->isLocked() ? t('- @name -', ['@name' => $language->getName()]) : $language->getName();
}
if (count($language_options) > 1) {
- $form['advanced']['lang-fieldset'] = array(
+ $form['advanced']['lang-fieldset'] = [
'#type' => 'fieldset',
'#title' => t('Languages'),
- );
- $form['advanced']['lang-fieldset']['language'] = array(
+ ];
+ $form['advanced']['lang-fieldset']['language'] = [
'#type' => 'checkboxes',
'#title' => t('Languages'),
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
'#options' => $language_options,
- '#default_value' => isset($defaults['language']) ? $defaults['language'] : array(),
- );
+ '#default_value' => isset($defaults['language']) ? $defaults['language'] : [],
+ ];
}
}
@@ -633,7 +633,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$advanced = FALSE;
// Collect extra filters.
- $filters = array();
+ $filters = [];
if ($form_state->hasValue('type') && is_array($form_state->getValue('type'))) {
// Retrieve selected types - Form API sets the value of unselected
// checkboxes to 0.
@@ -680,7 +680,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
// Put the keywords and advanced parameters into GET parameters. Make sure
// to put keywords into the query even if it is empty, because the page
// controller uses that to decide it's time to check for search results.
- $query = array('keys' => $keys);
+ $query = ['keys' => $keys];
if ($filters) {
$query['f'] = $filters;
}
@@ -707,13 +707,13 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
* a modified 'keys' element for the bare search keywords.
*/
protected function parseAdvancedDefaults($f, $keys) {
- $defaults = array();
+ $defaults = [];
// Split out the advanced search parameters.
foreach ($f as $advanced) {
list($key, $value) = explode(':', $advanced, 2);
if (!isset($defaults[$key])) {
- $defaults[$key] = array();
+ $defaults[$key] = [];
}
$defaults[$key][] = $value;
}
@@ -721,7 +721,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
// Split out the negative, phrase, and OR parts of keywords.
// For phrases, the form only supports one phrase.
- $matches = array();
+ $matches = [];
$keys = ' ' . $keys . ' ';
if (preg_match('/ "([^"]+)" /', $keys, $matches)) {
$keys = str_replace($matches[0], ' ', $keys);
@@ -764,9 +764,9 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
* {@inheritdoc}
*/
public function defaultConfiguration() {
- $configuration = array(
- 'rankings' => array(),
- );
+ $configuration = [
+ 'rankings' => [],
+ ];
return $configuration;
}
@@ -775,34 +775,34 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Output form for defining rank factor weights.
- $form['content_ranking'] = array(
+ $form['content_ranking'] = [
'#type' => 'details',
'#title' => t('Content ranking'),
'#open' => TRUE,
- );
- $form['content_ranking']['info'] = array(
+ ];
+ $form['content_ranking']['info'] = [
'#markup' => '<p><em>' . $this->t('Influence is a numeric multiplier used in ordering search results. A higher number means the corresponding factor has more influence on search results; zero means the factor is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em></p>'
- );
+ ];
// Prepare table.
$header = [$this->t('Factor'), $this->t('Influence')];
- $form['content_ranking']['rankings'] = array(
+ $form['content_ranking']['rankings'] = [
'#type' => 'table',
'#header' => $header,
- );
+ ];
// Note: reversed to reflect that higher number = higher ranking.
$range = range(0, 10);
$options = array_combine($range, $range);
foreach ($this->getRankings() as $var => $values) {
- $form['content_ranking']['rankings'][$var]['name'] = array(
+ $form['content_ranking']['rankings'][$var]['name'] = [
'#markup' => $values['title'],
- );
- $form['content_ranking']['rankings'][$var]['value'] = array(
+ ];
+ $form['content_ranking']['rankings'][$var]['value'] = [
'#type' => 'select',
'#options' => $options,
'#attributes' => ['aria-label' => $this->t("Influence of '@title'", ['@title' => $values['title']])],
'#default_value' => isset($this->configuration['rankings'][$var]) ? $this->configuration['rankings'][$var] : 0,
- );
+ ];
}
return $form;
}
diff --git a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php
index 9b2c3cd7399..6d9b67af1f9 100644
--- a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php
+++ b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php
@@ -101,7 +101,7 @@ class D6NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
}
// Read all CCK field instance definitions in the source database.
- $fields = array();
+ $fields = [];
try {
$source_plugin = static::getSourcePlugin('d6_field_instance');
$source_plugin->checkRequirements();
diff --git a/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php b/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php
index 820364c6a6e..c26f3b9f1c3 100644
--- a/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php
+++ b/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php
@@ -15,7 +15,7 @@ class EntityNodeType extends EntityConfigBase {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$entity_ids = parent::import($row, $old_destination_id_values);
if ($row->getDestinationProperty('create_body')) {
$node_type = $this->storage->load(reset($entity_ids));
diff --git a/core/modules/node/src/Plugin/migrate/process/d6/NodeUpdate7008.php b/core/modules/node/src/Plugin/migrate/process/d6/NodeUpdate7008.php
index cf0b4adef8a..f6da2eb5dcc 100644
--- a/core/modules/node/src/Plugin/migrate/process/d6/NodeUpdate7008.php
+++ b/core/modules/node/src/Plugin/migrate/process/d6/NodeUpdate7008.php
@@ -22,7 +22,7 @@ class NodeUpdate7008 extends ProcessPluginBase {
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if ($value === 'administer nodes') {
- return array($value, 'access content overview');
+ return [$value, 'access content overview'];
}
return $value;
}
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/Node.php b/core/modules/node/src/Plugin/migrate/source/d6/Node.php
index 2e4d1a60573..ffa26595f1c 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/Node.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/Node.php
@@ -77,7 +77,7 @@ class Node extends DrupalSqlBase {
$query->innerJoin('node', 'n', static::JOIN);
$this->handleTranslations($query);
- $query->fields('n', array(
+ $query->fields('n', [
'nid',
'type',
'language',
@@ -90,8 +90,8 @@ class Node extends DrupalSqlBase {
'sticky',
'tnid',
'translate',
- ))
- ->fields('nr', array(
+ ])
+ ->fields('nr', [
'title',
'body',
'teaser',
@@ -99,7 +99,7 @@ class Node extends DrupalSqlBase {
'timestamp',
'format',
'vid',
- ));
+ ]);
$query->addField('n', 'uid', 'node_uid');
$query->addField('nr', 'uid', 'revision_uid');
@@ -129,7 +129,7 @@ class Node extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'nid' => $this->t('Node ID'),
'type' => $this->t('Type'),
'title' => $this->t('Title'),
@@ -147,7 +147,7 @@ class Node extends DrupalSqlBase {
'language' => $this->t('Language (fr, en, ...)'),
'tnid' => $this->t('The translation set id for this node'),
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
- );
+ ];
return $fields;
}
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php b/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php
index 3f9a5808fc9..f3296c234d5 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php
@@ -22,11 +22,11 @@ class NodeRevision extends Node {
*/
public function fields() {
// Use all the node fields plus the vid that identifies the version.
- return parent::fields() + array(
+ return parent::fields() + [
'vid' => t('The primary identifier for this version.'),
'log' => $this->t('Revision Log message'),
'timestamp' => $this->t('Revision timestamp'),
- );
+ ];
}
/**
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php b/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php
index 0653d59c57c..6a6a32b3e55 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php
@@ -40,7 +40,7 @@ class NodeType extends DrupalSqlBase {
*/
public function query() {
return $this->select('node_type', 't')
- ->fields('t', array(
+ ->fields('t', [
'type',
'name',
'module',
@@ -54,7 +54,7 @@ class NodeType extends DrupalSqlBase {
'modified',
'locked',
'orig_type',
- ))
+ ])
->orderBy('t.type');
}
@@ -62,7 +62,7 @@ class NodeType extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'type' => $this->t('Machine name of the node type.'),
'name' => $this->t('Human name of the node type.'),
'module' => $this->t('The module providing the node type.'),
@@ -77,7 +77,7 @@ class NodeType extends DrupalSqlBase {
'locked' => $this->t('Flag.'),
'orig_type' => $this->t('The original type.'),
'teaser_length' => $this->t('Teaser length'),
- );
+ ];
}
/**
@@ -86,7 +86,7 @@ class NodeType extends DrupalSqlBase {
protected function initializeIterator() {
$this->teaserLength = $this->variableGet('teaser_length', 600);
$this->nodePreview = $this->variableGet('node_preview', 0);
- $this->themeSettings = $this->variableGet('theme_settings', array());
+ $this->themeSettings = $this->variableGet('theme_settings', []);
return parent::initializeIterator();
}
@@ -98,9 +98,9 @@ class NodeType extends DrupalSqlBase {
$row->setSourceProperty('node_preview', $this->nodePreview);
$type = $row->getSourceProperty('type');
- $source_options = $this->variableGet('node_options_' . $type, array('promote', 'sticky'));
- $options = array();
- foreach (array('promote', 'sticky', 'status', 'revision') as $item) {
+ $source_options = $this->variableGet('node_options_' . $type, ['promote', 'sticky']);
+ $options = [];
+ foreach (['promote', 'sticky', 'status', 'revision'] as $item) {
$options[$item] = in_array($item, $source_options);
}
$row->setSourceProperty('options', $options);
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php b/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
index a4503984048..8e7b8ae15e4 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
@@ -16,7 +16,7 @@ class ViewMode extends ViewModeBase {
* {@inheritdoc}
*/
protected function initializeIterator() {
- $rows = array();
+ $rows = [];
$result = $this->prepareQuery()->execute();
while ($field_row = $result->fetchAssoc()) {
$field_row['display_settings'] = unserialize($field_row['display_settings']);
@@ -38,9 +38,9 @@ class ViewMode extends ViewModeBase {
*/
public function query() {
$query = $this->select('content_node_field_instance', 'cnfi')
- ->fields('cnfi', array(
+ ->fields('cnfi', [
'display_settings',
- ));
+ ]);
return $query;
}
@@ -49,9 +49,9 @@ class ViewMode extends ViewModeBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'display_settings' => $this->t('Serialize data with display settings.'),
- );
+ ];
}
/**
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/ViewModeBase.php b/core/modules/node/src/Plugin/migrate/source/d6/ViewModeBase.php
index 54abcb0f42b..315f069a619 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/ViewModeBase.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/ViewModeBase.php
@@ -33,7 +33,7 @@ abstract class ViewModeBase extends DrupalSqlBase {
* The view mode names.
*/
public function getViewModes() {
- return array(
+ return [
0,
1,
2,
@@ -42,7 +42,7 @@ abstract class ViewModeBase extends DrupalSqlBase {
5,
'teaser',
'full',
- );
+ ];
}
}
diff --git a/core/modules/node/src/Plugin/migrate/source/d7/Node.php b/core/modules/node/src/Plugin/migrate/source/d7/Node.php
index 0de4c968523..451905cd96a 100644
--- a/core/modules/node/src/Plugin/migrate/source/d7/Node.php
+++ b/core/modules/node/src/Plugin/migrate/source/d7/Node.php
@@ -62,7 +62,7 @@ class Node extends FieldableEntity {
public function query() {
// Select node in its last revision.
$query = $this->select('node_revision', 'nr')
- ->fields('n', array(
+ ->fields('n', [
'nid',
'type',
'language',
@@ -74,13 +74,13 @@ class Node extends FieldableEntity {
'sticky',
'tnid',
'translate',
- ))
- ->fields('nr', array(
+ ])
+ ->fields('nr', [
'vid',
'title',
'log',
'timestamp',
- ));
+ ]);
$query->addField('n', 'uid', 'node_uid');
$query->addField('nr', 'uid', 'revision_uid');
$query->innerJoin('node', 'n', static::JOIN);
@@ -122,7 +122,7 @@ class Node extends FieldableEntity {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'nid' => $this->t('Node ID'),
'type' => $this->t('Type'),
'title' => $this->t('Title'),
@@ -137,7 +137,7 @@ class Node extends FieldableEntity {
'language' => $this->t('Language (fr, en, ...)'),
'tnid' => $this->t('The translation set id for this node'),
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
- );
+ ];
return $fields;
}
diff --git a/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php b/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php
index b88359abe77..89c1bcca5e7 100644
--- a/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php
+++ b/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php
@@ -22,11 +22,11 @@ class NodeRevision extends Node {
*/
public function fields() {
// Use all the node fields plus the vid that identifies the version.
- return parent::fields() + array(
+ return parent::fields() + [
'vid' => t('The primary identifier for this version.'),
'log' => $this->t('Revision Log message'),
'timestamp' => $this->t('Revision timestamp'),
- );
+ ];
}
/**
diff --git a/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php b/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php
index b8a8519accc..85c0d325815 100644
--- a/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php
+++ b/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php
@@ -40,7 +40,7 @@ class NodeType extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'type' => $this->t('Machine name of the node type.'),
'name' => $this->t('Human name of the node type.'),
'description' => $this->t('Description of the node type.'),
@@ -53,7 +53,7 @@ class NodeType extends DrupalSqlBase {
'locked' => $this->t('Flag.'),
'orig_type' => $this->t('The original type.'),
'teaser_length' => $this->t('Teaser length'),
- );
+ ];
}
/**
@@ -73,9 +73,9 @@ class NodeType extends DrupalSqlBase {
$row->setSourceProperty('node_preview', $this->nodePreview);
$type = $row->getSourceProperty('type');
- $source_options = $this->variableGet('node_options_' . $type, array('promote', 'sticky'));
- $options = array();
- foreach (array('promote', 'sticky', 'status', 'revision') as $item) {
+ $source_options = $this->variableGet('node_options_' . $type, ['promote', 'sticky']);
+ $options = [];
+ foreach (['promote', 'sticky', 'status', 'revision'] as $item) {
$options[$item] = in_array($item, $source_options);
}
$row->setSourceProperty('options', $options);
@@ -86,7 +86,7 @@ class NodeType extends DrupalSqlBase {
if ($this->moduleExists('field')) {
// Find body field for this node type.
$body = $this->select('field_config_instance', 'fci')
- ->fields('fci', array('data'))
+ ->fields('fci', ['data'])
->condition('entity_type', 'node')
->condition('bundle', $row->getSourceProperty('type'))
->condition('field_name', 'body')
diff --git a/core/modules/node/src/Plugin/views/area/ListingEmpty.php b/core/modules/node/src/Plugin/views/area/ListingEmpty.php
index e52ca1bf67d..08e1d272232 100644
--- a/core/modules/node/src/Plugin/views/area/ListingEmpty.php
+++ b/core/modules/node/src/Plugin/views/area/ListingEmpty.php
@@ -59,19 +59,19 @@ class ListingEmpty extends AreaPluginBase {
public function render($empty = FALSE) {
$account = \Drupal::currentUser();
if (!$empty || !empty($this->options['empty'])) {
- $element = array(
+ $element = [
'#theme' => 'links',
- '#links' => array(
- array(
+ '#links' => [
+ [
'url' => Url::fromRoute('node.add_page'),
'title' => $this->t('Add content'),
- ),
- ),
- '#access' => $this->accessManager->checkNamedRoute('node.add_page', array(), $account),
- );
+ ],
+ ],
+ '#access' => $this->accessManager->checkNamedRoute('node.add_page', [], $account),
+ ];
return $element;
}
- return array();
+ return [];
}
}
diff --git a/core/modules/node/src/Plugin/views/argument/Nid.php b/core/modules/node/src/Plugin/views/argument/Nid.php
index 8f846bc6a13..3b0f8df9598 100644
--- a/core/modules/node/src/Plugin/views/argument/Nid.php
+++ b/core/modules/node/src/Plugin/views/argument/Nid.php
@@ -52,7 +52,7 @@ class Nid extends NumericArgument {
* Override the behavior of title(). Get the title of the node.
*/
public function titleQuery() {
- $titles = array();
+ $titles = [];
$nodes = $this->nodeStorage->loadMultiple($this->value);
foreach ($nodes as $node) {
diff --git a/core/modules/node/src/Plugin/views/argument/UidRevision.php b/core/modules/node/src/Plugin/views/argument/UidRevision.php
index 9a19fe36f3e..9e2fb810c2c 100644
--- a/core/modules/node/src/Plugin/views/argument/UidRevision.php
+++ b/core/modules/node/src/Plugin/views/argument/UidRevision.php
@@ -15,7 +15,7 @@ class UidRevision extends Uid {
public function query($group_by = FALSE) {
$this->ensureMyTable();
$placeholder = $this->placeholder();
- $this->query->addWhereExpression(0, "$this->tableAlias.revision_uid = $placeholder OR ((SELECT COUNT(DISTINCT vid) FROM {node_revision} nr WHERE nfr.revision_uid = $placeholder AND nr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $this->argument));
+ $this->query->addWhereExpression(0, "$this->tableAlias.revision_uid = $placeholder OR ((SELECT COUNT(DISTINCT vid) FROM {node_revision} nr WHERE nfr.revision_uid = $placeholder AND nr.nid = $this->tableAlias.nid) > 0)", [$placeholder => $this->argument]);
}
}
diff --git a/core/modules/node/src/Plugin/views/argument/Vid.php b/core/modules/node/src/Plugin/views/argument/Vid.php
index 8788b67a30e..1cad35c71b7 100644
--- a/core/modules/node/src/Plugin/views/argument/Vid.php
+++ b/core/modules/node/src/Plugin/views/argument/Vid.php
@@ -66,10 +66,10 @@ class Vid extends NumericArgument {
* Override the behavior of title(). Get the title of the revision.
*/
public function titleQuery() {
- $titles = array();
+ $titles = [];
- $results = $this->database->query('SELECT nr.vid, nr.nid, npr.title FROM {node_revision} nr WHERE nr.vid IN ( :vids[] )', array(':vids[]' => $this->value))->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
- $nids = array();
+ $results = $this->database->query('SELECT nr.vid, nr.nid, npr.title FROM {node_revision} nr WHERE nr.vid IN ( :vids[] )', [':vids[]' => $this->value])->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
+ $nids = [];
foreach ($results as $result) {
$nids[] = $result['nid'];
}
diff --git a/core/modules/node/src/Plugin/views/field/Node.php b/core/modules/node/src/Plugin/views/field/Node.php
index d721414f1e1..e5cd9d70252 100644
--- a/core/modules/node/src/Plugin/views/field/Node.php
+++ b/core/modules/node/src/Plugin/views/field/Node.php
@@ -28,7 +28,7 @@ class Node extends FieldPluginBase {
// Don't add the additional fields to groupby
if (!empty($this->options['link_to_node'])) {
- $this->additional_fields['nid'] = array('table' => 'node_field_data', 'field' => 'nid');
+ $this->additional_fields['nid'] = ['table' => 'node_field_data', 'field' => 'nid'];
}
}
@@ -37,7 +37,7 @@ class Node extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['link_to_node'] = array('default' => isset($this->definition['link_to_node default']) ? $this->definition['link_to_node default'] : FALSE);
+ $options['link_to_node'] = ['default' => isset($this->definition['link_to_node default']) ? $this->definition['link_to_node default'] : FALSE];
return $options;
}
@@ -45,12 +45,12 @@ class Node extends FieldPluginBase {
* Provide link to node option
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['link_to_node'] = array(
+ $form['link_to_node'] = [
'#title' => $this->t('Link this field to the original piece of content'),
'#description' => $this->t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_node']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/core/modules/node/src/Plugin/views/field/Path.php b/core/modules/node/src/Plugin/views/field/Path.php
index 5fb07cd771a..c1c74ab658a 100644
--- a/core/modules/node/src/Plugin/views/field/Path.php
+++ b/core/modules/node/src/Plugin/views/field/Path.php
@@ -31,7 +31,7 @@ class Path extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['absolute'] = array('default' => FALSE);
+ $options['absolute'] = ['default' => FALSE];
return $options;
}
@@ -41,13 +41,13 @@ class Path extends FieldPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['absolute'] = array(
+ $form['absolute'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use absolute link (begins with "http://")'),
'#default_value' => $this->options['absolute'],
'#description' => $this->t('Enable this option to output an absolute link. Required if you want to use the path as a link destination (as in "output this field as a link" above).'),
'#fieldset' => 'alter',
- );
+ ];
}
/**
@@ -63,9 +63,9 @@ class Path extends FieldPluginBase {
*/
public function render(ResultRow $values) {
$nid = $this->getValue($values, 'nid');
- return array(
+ return [
'#markup' => \Drupal::url('entity.node.canonical', ['node' => $nid], ['absolute' => $this->options['absolute']]),
- );
+ ];
}
}
diff --git a/core/modules/node/src/Plugin/views/filter/UidRevision.php b/core/modules/node/src/Plugin/views/filter/UidRevision.php
index ce588b7b9cf..0968480f223 100644
--- a/core/modules/node/src/Plugin/views/filter/UidRevision.php
+++ b/core/modules/node/src/Plugin/views/filter/UidRevision.php
@@ -21,7 +21,7 @@ class UidRevision extends Name {
$args = array_values($this->value);
$this->query->addWhereExpression($this->options['group'], "$this->tableAlias.uid IN($placeholder) OR
- ((SELECT COUNT(DISTINCT vid) FROM {node_revision} nr WHERE nr.revision_uid IN ($placeholder) AND nr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $args),
+ ((SELECT COUNT(DISTINCT vid) FROM {node_revision} nr WHERE nr.revision_uid IN ($placeholder) AND nr.nid = $this->tableAlias.nid) > 0)", [$placeholder => $args],
$args);
}
diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php
index 097655a2041..96838796a16 100644
--- a/core/modules/node/src/Plugin/views/row/Rss.php
+++ b/core/modules/node/src/Plugin/views/row/Rss.php
@@ -27,7 +27,7 @@ class Rss extends RssPluginBase {
public $base_field = 'nid';
// Stores the nodes loaded with preRender.
- public $nodes = array();
+ public $nodes = [];
/**
* {@inheritdoc}
@@ -74,7 +74,7 @@ class Rss extends RssPluginBase {
}
public function preRender($values) {
- $nids = array();
+ $nids = [];
foreach ($values as $row) {
$nids[] = $row->{$this->field_alias};
}
@@ -103,23 +103,23 @@ class Rss extends RssPluginBase {
return;
}
- $node->link = $node->url('canonical', array('absolute' => TRUE));
- $node->rss_namespaces = array();
- $node->rss_elements = array(
- array(
+ $node->link = $node->url('canonical', ['absolute' => TRUE]);
+ $node->rss_namespaces = [];
+ $node->rss_elements = [
+ [
'key' => 'pubDate',
'value' => gmdate('r', $node->getCreatedTime()),
- ),
- array(
+ ],
+ [
'key' => 'dc:creator',
'value' => $node->getOwner()->getDisplayName(),
- ),
- array(
+ ],
+ [
'key' => 'guid',
'value' => $node->id() . ' at ' . $base_url,
- 'attributes' => array('isPermaLink' => 'false'),
- ),
- );
+ 'attributes' => ['isPermaLink' => 'false'],
+ ],
+ ];
// The node gets built and modules add to or modify $node->rss_elements
// and $node->rss_namespaces.
@@ -135,7 +135,7 @@ class Rss extends RssPluginBase {
elseif (function_exists('rdf_get_namespaces')) {
// Merge RDF namespaces in the XML namespaces in case they are used
// further in the RSS content.
- $xml_rdf_namespaces = array();
+ $xml_rdf_namespaces = [];
foreach (rdf_get_namespaces() as $prefix => $uri) {
$xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
}
@@ -153,12 +153,12 @@ class Rss extends RssPluginBase {
// template_preprocess_views_view_row_rss() can still access it.
$item->elements = &$node->rss_elements;
$item->nid = $node->id();
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $item,
- );
+ ];
return $build;
}
diff --git a/core/modules/node/src/Plugin/views/wizard/Node.php b/core/modules/node/src/Plugin/views/wizard/Node.php
index ce267e662e9..34d4bcf6c5e 100644
--- a/core/modules/node/src/Plugin/views/wizard/Node.php
+++ b/core/modules/node/src/Plugin/views/wizard/Node.php
@@ -28,16 +28,16 @@ class Node extends WizardPluginBase {
/**
* Set default values for the filters.
*/
- protected $filters = array(
- 'status' => array(
+ protected $filters = [
+ 'status' => [
'value' => TRUE,
'table' => 'node_field_data',
'field' => 'status',
'plugin_id' => 'boolean',
'entity_type' => 'node',
'entity_field' => 'status',
- )
- );
+ ]
+ ];
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::getAvailableSorts().
@@ -48,16 +48,16 @@ class Node extends WizardPluginBase {
*/
public function getAvailableSorts() {
// You can't execute functions in properties, so override the method
- return array(
+ return [
'node_field_data-title:ASC' => $this->t('Title')
- );
+ ];
}
/**
* {@inheritdoc}
*/
protected function rowStyleOptions() {
- $options = array();
+ $options = [];
$options['teasers'] = $this->t('teasers');
$options['full_posts'] = $this->t('full posts');
$options['titles'] = $this->t('titles');
@@ -110,22 +110,22 @@ class Node extends WizardPluginBase {
protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) {
$filters = parent::defaultDisplayFiltersUser($form, $form_state);
- $tids = array();
- if ($values = $form_state->getValue(array('show', 'tagged_with'))) {
+ $tids = [];
+ if ($values = $form_state->getValue(['show', 'tagged_with'])) {
foreach ($values as $value) {
$tids[] = $value['target_id'];
}
}
if (!empty($tids)) {
$vid = reset($form['displays']['show']['tagged_with']['#selection_settings']['target_bundles']);
- $filters['tid'] = array(
+ $filters['tid'] = [
'id' => 'tid',
'table' => 'taxonomy_index',
'field' => 'tid',
'value' => $tids,
'vid' => $vid,
'plugin_id' => 'taxonomy_index_tid',
- );
+ ];
// If the user entered more than one valid term in the autocomplete
// field, they probably intended both of them to be applied.
if (count($tids) > 1) {
@@ -144,8 +144,8 @@ class Node extends WizardPluginBase {
*/
protected function pageDisplayOptions(array $form, FormStateInterface $form_state) {
$display_options = parent::pageDisplayOptions($form, $form_state);
- $row_plugin = $form_state->getValue(array('page', 'style', 'row_plugin'));
- $row_options = $form_state->getValue(array('page', 'style', 'row_options'), array());
+ $row_plugin = $form_state->getValue(['page', 'style', 'row_plugin']);
+ $row_options = $form_state->getValue(['page', 'style', 'row_options'], []);
$this->display_options_row($display_options, $row_plugin, $row_options);
return $display_options;
}
@@ -155,8 +155,8 @@ class Node extends WizardPluginBase {
*/
protected function blockDisplayOptions(array $form, FormStateInterface $form_state) {
$display_options = parent::blockDisplayOptions($form, $form_state);
- $row_plugin = $form_state->getValue(array('block', 'style', 'row_plugin'));
- $row_options = $form_state->getValue(array('block', 'style', 'row_options'), array());
+ $row_plugin = $form_state->getValue(['block', 'style', 'row_plugin']);
+ $row_options = $form_state->getValue(['block', 'style', 'row_options'], []);
$this->display_options_row($display_options, $row_plugin, $row_options);
return $display_options;
}
@@ -195,7 +195,7 @@ class Node extends WizardPluginBase {
parent::buildFilters($form, $form_state);
if (isset($form['displays']['show']['type'])) {
- $selected_bundle = static::getSelected($form_state, array('show', 'type'), 'all', $form['displays']['show']['type']);
+ $selected_bundle = static::getSelected($form_state, ['show', 'type'], 'all', $form['displays']['show']['type']);
}
// Add the "tagged with" filter to the view.
@@ -221,9 +221,9 @@ class Node extends WizardPluginBase {
// Double check that this is a real bundle before using it (since above
// we added a dummy option 'all' to the bundle list on the form).
if (isset($selected_bundle) && in_array($selected_bundle, $bundles)) {
- $bundles = array($selected_bundle);
+ $bundles = [$selected_bundle];
}
- $tag_fields = array();
+ $tag_fields = [];
foreach ($bundles as $bundle) {
$display = entity_get_form_display($this->entityTypeId, $bundle, 'default');
$taxonomy_fields = array_filter(\Drupal::entityManager()->getFieldDefinitions($this->entityTypeId, $bundle), function ($field_definition) {
@@ -253,7 +253,7 @@ class Node extends WizardPluginBase {
}
// Add the autocomplete textfield to the wizard.
$target_bundles = $tag_fields[$tag_field_name]->getSetting('handler_settings')['target_bundles'];
- $form['displays']['show']['tagged_with'] = array(
+ $form['displays']['show']['tagged_with'] = [
'#type' => 'entity_autocomplete',
'#title' => $this->t('tagged with'),
'#target_type' => 'taxonomy_term',
@@ -261,7 +261,7 @@ class Node extends WizardPluginBase {
'#tags' => TRUE,
'#size' => 30,
'#maxlength' => 1024,
- );
+ ];
}
}
diff --git a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
index 64bc7beda39..9c3465d2ba4 100644
--- a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
+++ b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
@@ -27,16 +27,16 @@ class NodeRevision extends WizardPluginBase {
/**
* Set default values for the filters.
*/
- protected $filters = array(
- 'status' => array(
+ protected $filters = [
+ 'status' => [
'value' => TRUE,
'table' => 'node_field_revision',
'field' => 'status',
'plugin_id' => 'boolean',
'entity_type' => 'node',
'entity_field' => 'status',
- )
- );
+ ]
+ ];
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::rowStyleOptions().
diff --git a/core/modules/node/src/Routing/RouteSubscriber.php b/core/modules/node/src/Routing/RouteSubscriber.php
index 23bd0f8f42a..66d83c12365 100644
--- a/core/modules/node/src/Routing/RouteSubscriber.php
+++ b/core/modules/node/src/Routing/RouteSubscriber.php
@@ -19,13 +19,13 @@ class RouteSubscriber extends RouteSubscriberBase {
// a node listing instead of the path's child links.
$route = $collection->get('system.admin_content');
if ($route) {
- $route->setDefaults(array(
+ $route->setDefaults([
'_title' => 'Content',
'_entity_list' => 'node',
- ));
- $route->setRequirements(array(
+ ]);
+ $route->setRequirements([
'_permission' => 'access content overview',
- ));
+ ]);
}
}
diff --git a/core/modules/node/src/Tests/NodeAccessBaseTableTest.php b/core/modules/node/src/Tests/NodeAccessBaseTableTest.php
index 74e2340ca1f..ef3ea909240 100644
--- a/core/modules/node/src/Tests/NodeAccessBaseTableTest.php
+++ b/core/modules/node/src/Tests/NodeAccessBaseTableTest.php
@@ -16,7 +16,7 @@ class NodeAccessBaseTableTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_access_test', 'views');
+ public static $modules = ['node_access_test', 'views'];
/**
* The installation profile to use with this test.
@@ -85,23 +85,23 @@ class NodeAccessBaseTableTest extends NodeTestBase {
*/
function testNodeAccessBasic() {
$num_simple_users = 2;
- $simple_users = array();
+ $simple_users = [];
// Nodes keyed by uid and nid: $nodes[$uid][$nid] = $is_private;
- $this->nodesByUser = array();
+ $this->nodesByUser = [];
// Titles keyed by nid.
$titles = [];
// Array of nids marked private.
$private_nodes = [];
for ($i = 0; $i < $num_simple_users; $i++) {
- $simple_users[$i] = $this->drupalCreateUser(array('access content', 'create article content'));
+ $simple_users[$i] = $this->drupalCreateUser(['access content', 'create article content']);
}
foreach ($simple_users as $this->webUser) {
$this->drupalLogin($this->webUser);
- foreach (array(0 => 'Public', 1 => 'Private') as $is_private => $type) {
- $edit = array(
- 'title[0][value]' => t('@private_public Article created by @user', array('@private_public' => $type, '@user' => $this->webUser->getUsername())),
- );
+ foreach ([0 => 'Public', 1 => 'Private'] as $is_private => $type) {
+ $edit = [
+ 'title[0][value]' => t('@private_public Article created by @user', ['@private_public' => $type, '@user' => $this->webUser->getUsername()]),
+ ];
if ($is_private) {
$edit['private[0][value]'] = TRUE;
$edit['body[0][value]'] = 'private node';
@@ -122,8 +122,8 @@ class NodeAccessBaseTableTest extends NodeTestBase {
$this->nodesByUser[$this->webUser->id()][$node->id()] = $is_private;
}
}
- $this->publicTid = db_query('SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1', array(':name' => 'public'))->fetchField();
- $this->privateTid = db_query('SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1', array(':name' => 'private'))->fetchField();
+ $this->publicTid = db_query('SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1', [':name' => 'public'])->fetchField();
+ $this->privateTid = db_query('SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1', [':name' => 'private'])->fetchField();
$this->assertTrue($this->publicTid, 'Public tid was found');
$this->assertTrue($this->privateTid, 'Private tid was found');
foreach ($simple_users as $this->webUser) {
@@ -138,12 +138,12 @@ class NodeAccessBaseTableTest extends NodeTestBase {
else {
$should_be_visible = TRUE;
}
- $this->assertResponse($should_be_visible ? 200 : 403, strtr('A %private node by user %uid is %visible for user %current_uid.', array(
+ $this->assertResponse($should_be_visible ? 200 : 403, strtr('A %private node by user %uid is %visible for user %current_uid.', [
'%private' => $is_private ? 'private' : 'public',
'%uid' => $uid,
'%visible' => $should_be_visible ? 'visible' : 'not visible',
'%current_uid' => $this->webUser->id(),
- )));
+ ]));
}
}
@@ -153,7 +153,7 @@ class NodeAccessBaseTableTest extends NodeTestBase {
}
// Now test that a user with 'node test view' permissions can view content.
- $access_user = $this->drupalCreateUser(array('access content', 'create article content', 'node test view', 'search content'));
+ $access_user = $this->drupalCreateUser(['access content', 'create article content', 'node test view', 'search content']);
$this->drupalLogin($access_user);
foreach ($this->nodesByUser as $private_status) {
@@ -193,7 +193,7 @@ class NodeAccessBaseTableTest extends NodeTestBase {
* user's own private nodes should be listed.
*/
protected function assertTaxonomyPage($is_admin) {
- foreach (array($this->publicTid, $this->privateTid) as $tid_is_private => $tid) {
+ foreach ([$this->publicTid, $this->privateTid] as $tid_is_private => $tid) {
$this->drupalGet("taxonomy/term/$tid");
$this->nidsVisible = [];
foreach ($this->xpath("//a[text()='Read more']") as $link) {
@@ -211,13 +211,13 @@ class NodeAccessBaseTableTest extends NodeTestBase {
if (!$is_admin && $tid_is_private) {
$should_be_visible = $should_be_visible && $uid == $this->webUser->id();
}
- $this->assertIdentical(isset($this->nidsVisible[$nid]), $should_be_visible, strtr('A %private node by user %uid is %visible for user %current_uid on the %tid_is_private page.', array(
+ $this->assertIdentical(isset($this->nidsVisible[$nid]), $should_be_visible, strtr('A %private node by user %uid is %visible for user %current_uid on the %tid_is_private page.', [
'%private' => $is_private ? 'private' : 'public',
'%uid' => $uid,
'%visible' => isset($this->nidsVisible[$nid]) ? 'visible' : 'not visible',
'%current_uid' => $this->webUser->id(),
'%tid_is_private' => $tid_is_private ? 'private' : 'public',
- )));
+ ]));
}
}
}
diff --git a/core/modules/node/src/Tests/NodeAccessPagerTest.php b/core/modules/node/src/Tests/NodeAccessPagerTest.php
index 7db264cd931..b4fe8302e9b 100644
--- a/core/modules/node/src/Tests/NodeAccessPagerTest.php
+++ b/core/modules/node/src/Tests/NodeAccessPagerTest.php
@@ -21,15 +21,15 @@ class NodeAccessPagerTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node_access_test', 'comment', 'forum');
+ public static $modules = ['node_access_test', 'comment', 'forum'];
protected function setUp() {
parent::setUp();
node_access_rebuild();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page')));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
$this->addDefaultCommentField('node', 'page');
- $this->webUser = $this->drupalCreateUser(array('access content', 'access comments', 'node test view'));
+ $this->webUser = $this->drupalCreateUser(['access content', 'access comments', 'node test view']);
}
/**
@@ -41,16 +41,16 @@ class NodeAccessPagerTest extends WebTestBase {
// Create 60 comments.
for ($i = 0; $i < 60; $i++) {
- $comment = Comment::create(array(
+ $comment = Comment::create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'subject' => $this->randomMachineName(),
- 'comment_body' => array(
- array('value' => $this->randomMachineName()),
- ),
+ 'comment_body' => [
+ ['value' => $this->randomMachineName()],
+ ],
'status' => CommentInterface::PUBLISHED,
- ));
+ ]);
$comment->save();
}
@@ -80,13 +80,13 @@ class NodeAccessPagerTest extends WebTestBase {
// Create 30 nodes.
for ($i = 0; $i < 30; $i++) {
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'nid' => NULL,
'type' => 'forum',
- 'taxonomy_forums' => array(
- array('target_id' => $tid),
- ),
- ));
+ 'taxonomy_forums' => [
+ ['target_id' => $tid],
+ ],
+ ]);
}
// View the general discussion forum page. With the default 25 nodes per
diff --git a/core/modules/node/src/Tests/NodeAccessRebuildNodeGrantsTest.php b/core/modules/node/src/Tests/NodeAccessRebuildNodeGrantsTest.php
index d151aadc366..251aa882683 100644
--- a/core/modules/node/src/Tests/NodeAccessRebuildNodeGrantsTest.php
+++ b/core/modules/node/src/Tests/NodeAccessRebuildNodeGrantsTest.php
@@ -32,7 +32,7 @@ class NodeAccessRebuildNodeGrantsTest extends NodeTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access site reports'));
+ $this->adminUser = $this->drupalCreateUser(['administer site configuration', 'access administration pages', 'access site reports']);
$this->drupalLogin($this->adminUser);
$this->webUser = $this->drupalCreateUser();
@@ -50,10 +50,10 @@ class NodeAccessRebuildNodeGrantsTest extends NodeTestBase {
// Create 30 nodes so that _node_access_rebuild_batch_operation() has to run
// more than once.
for ($i = 0; $i < 30; $i++) {
- $nodes[] = $this->drupalCreateNode(array(
+ $nodes[] = $this->drupalCreateNode([
'uid' => $this->webUser->id(),
'private' => [['value' => 1]]
- ));
+ ]);
}
/** @var \Drupal\node\NodeGrantDatabaseStorageInterface $grant_storage */
@@ -71,7 +71,7 @@ class NodeAccessRebuildNodeGrantsTest extends NodeTestBase {
// Rebuild permissions.
$this->drupalGet('admin/reports/status');
$this->clickLink(t('Rebuild permissions'));
- $this->drupalPostForm(NULL, array(), t('Rebuild permissions'));
+ $this->drupalPostForm(NULL, [], t('Rebuild permissions'));
$this->assertText(t('The content access permissions have been rebuilt.'));
// Test if the rebuild by user that cannot bypass node access and does not
@@ -107,7 +107,7 @@ class NodeAccessRebuildNodeGrantsTest extends NodeTestBase {
// Rebuild permissions.
$this->drupalGet('admin/reports/status');
$this->clickLink(t('Rebuild permissions'));
- $this->drupalPostForm(NULL, array(), t('Rebuild permissions'));
+ $this->drupalPostForm(NULL, [], t('Rebuild permissions'));
$this->assertText(t('Content permissions have been rebuilt.'));
$this->assertNull(\Drupal::state()->get('node.node_access_needs_rebuild'), 'Node access permissions have been rebuilt');
diff --git a/core/modules/node/src/Tests/NodeAdminTest.php b/core/modules/node/src/Tests/NodeAdminTest.php
index 1717bb19c89..7357d2330dd 100644
--- a/core/modules/node/src/Tests/NodeAdminTest.php
+++ b/core/modules/node/src/Tests/NodeAdminTest.php
@@ -43,7 +43,7 @@ class NodeAdminTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('views');
+ public static $modules = ['views'];
protected function setUp() {
parent::setUp();
@@ -51,9 +51,9 @@ class NodeAdminTest extends NodeTestBase {
// Remove the "view own unpublished content" permission which is set
// by default for authenticated users so we can test this permission
// correctly.
- user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, array('view own unpublished content'));
+ user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, ['view own unpublished content']);
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'access content overview', 'administer nodes', 'bypass node access'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'access content overview', 'administer nodes', 'bypass node access']);
$this->baseUser1 = $this->drupalCreateUser(['access content overview']);
$this->baseUser2 = $this->drupalCreateUser(['access content overview', 'view own unpublished content']);
$this->baseUser3 = $this->drupalCreateUser(['access content overview', 'bypass node access']);
@@ -66,39 +66,39 @@ class NodeAdminTest extends NodeTestBase {
$this->drupalLogin($this->adminUser);
$changed = REQUEST_TIME;
- foreach (array('dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB') as $prefix) {
+ foreach (['dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB'] as $prefix) {
$changed += 1000;
- $node = $this->drupalCreateNode(array('title' => $prefix . $this->randomMachineName(6)));
+ $node = $this->drupalCreateNode(['title' => $prefix . $this->randomMachineName(6)]);
db_update('node_field_data')
- ->fields(array('changed' => $changed))
+ ->fields(['changed' => $changed])
->condition('nid', $node->id())
->execute();
}
// Test that the default sort by node.changed DESC actually fires properly.
$nodes_query = db_select('node_field_data', 'n')
- ->fields('n', array('title'))
+ ->fields('n', ['title'])
->orderBy('changed', 'DESC')
->execute()
->fetchCol();
$this->drupalGet('admin/content');
foreach ($nodes_query as $delta => $string) {
- $elements = $this->xpath('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', array(':class' => 'views-table', ':label' => $string));
+ $elements = $this->xpath('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', [':class' => 'views-table', ':label' => $string]);
$this->assertTrue(!empty($elements), 'The node was found in the correct order.');
}
// Compare the rendered HTML node list to a query for the nodes ordered by
// title to account for possible database-dependent sort order.
$nodes_query = db_select('node_field_data', 'n')
- ->fields('n', array('title'))
+ ->fields('n', ['title'])
->orderBy('title')
->execute()
->fetchCol();
- $this->drupalGet('admin/content', array('query' => array('sort' => 'asc', 'order' => 'title')));
+ $this->drupalGet('admin/content', ['query' => ['sort' => 'asc', 'order' => 'title']]);
foreach ($nodes_query as $delta => $string) {
- $elements = $this->xpath('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', array(':class' => 'views-table', ':label' => $string));
+ $elements = $this->xpath('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', [':class' => 'views-table', ':label' => $string]);
$this->assertTrue(!empty($elements), 'The node was found in the correct order.');
}
}
@@ -118,10 +118,10 @@ class NodeAdminTest extends NodeTestBase {
// they appear in the following code, and the 'content' View has a table
// style configuration with a default sort on the 'changed' field DESC.
$time = time();
- $nodes['published_page'] = $this->drupalCreateNode(array('type' => 'page', 'changed' => $time--));
- $nodes['published_article'] = $this->drupalCreateNode(array('type' => 'article', 'changed' => $time--));
- $nodes['unpublished_page_1'] = $this->drupalCreateNode(array('type' => 'page', 'changed' => $time--, 'uid' => $this->baseUser1->id(), 'status' => 0));
- $nodes['unpublished_page_2'] = $this->drupalCreateNode(array('type' => 'page', 'changed' => $time, 'uid' => $this->baseUser2->id(), 'status' => 0));
+ $nodes['published_page'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time--]);
+ $nodes['published_article'] = $this->drupalCreateNode(['type' => 'article', 'changed' => $time--]);
+ $nodes['unpublished_page_1'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time--, 'uid' => $this->baseUser1->id(), 'status' => 0]);
+ $nodes['unpublished_page_2'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time, 'uid' => $this->baseUser2->id(), 'status' => 0]);
// Verify view, edit, and delete links for any content.
$this->drupalGet('admin/content');
@@ -139,14 +139,14 @@ class NodeAdminTest extends NodeTestBase {
}
// Verify filtering by publishing status.
- $this->drupalGet('admin/content', array('query' => array('status' => TRUE)));
+ $this->drupalGet('admin/content', ['query' => ['status' => TRUE]]);
$this->assertLinkByHref('node/' . $nodes['published_page']->id() . '/edit');
$this->assertLinkByHref('node/' . $nodes['published_article']->id() . '/edit');
$this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/edit');
// Verify filtering by status and content type.
- $this->drupalGet('admin/content', array('query' => array('status' => TRUE, 'type' => 'page')));
+ $this->drupalGet('admin/content', ['query' => ['status' => TRUE, 'type' => 'page']]);
$this->assertLinkByHref('node/' . $nodes['published_page']->id() . '/edit');
$this->assertNoLinkByHref('node/' . $nodes['published_article']->id() . '/edit');
diff --git a/core/modules/node/src/Tests/NodeBlockFunctionalTest.php b/core/modules/node/src/Tests/NodeBlockFunctionalTest.php
index 9579045a60f..5a2e40a30dc 100644
--- a/core/modules/node/src/Tests/NodeBlockFunctionalTest.php
+++ b/core/modules/node/src/Tests/NodeBlockFunctionalTest.php
@@ -35,14 +35,14 @@ class NodeBlockFunctionalTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('block', 'views');
+ public static $modules = ['block', 'views'];
protected function setUp() {
parent::setUp();
// Create users and test node.
- $this->adminUser = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'administer blocks', 'access content overview'));
- $this->webUser = $this->drupalCreateUser(array('access content', 'create article content'));
+ $this->adminUser = $this->drupalCreateUser(['administer content types', 'administer nodes', 'administer blocks', 'access content overview']);
+ $this->webUser = $this->drupalCreateUser(['access content', 'create article content']);
}
/**
@@ -52,34 +52,34 @@ class NodeBlockFunctionalTest extends NodeTestBase {
$this->drupalLogin($this->adminUser);
// Disallow anonymous users to view content.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access content' => FALSE,
- ));
+ ]);
// Enable the recent content block with two items.
- $block = $this->drupalPlaceBlock('views_block:content_recent-block_1', array('id' => 'test_block', 'items_per_page' => 2));
+ $block = $this->drupalPlaceBlock('views_block:content_recent-block_1', ['id' => 'test_block', 'items_per_page' => 2]);
// Test that block is not visible without nodes.
$this->drupalGet('');
$this->assertText(t('No content available.'), 'Block with "No content available." found.');
// Add some test nodes.
- $default_settings = array('uid' => $this->webUser->id(), 'type' => 'article');
+ $default_settings = ['uid' => $this->webUser->id(), 'type' => 'article'];
$node1 = $this->drupalCreateNode($default_settings);
$node2 = $this->drupalCreateNode($default_settings);
$node3 = $this->drupalCreateNode($default_settings);
// Change the changed time for node so that we can test ordering.
db_update('node_field_data')
- ->fields(array(
+ ->fields([
'changed' => $node1->getChangedTime() + 100,
- ))
+ ])
->condition('nid', $node2->id())
->execute();
db_update('node_field_data')
- ->fields(array(
+ ->fields([
'changed' => $node1->getChangedTime() + 200,
- ))
+ ])
->condition('nid', $node3->id())
->execute();
@@ -131,7 +131,7 @@ class NodeBlockFunctionalTest extends NodeTestBase {
$this->assertTrue(isset($visibility['node_type']['bundles']['article']), 'Visibility settings were saved to configuration');
// Create a page node.
- $node5 = $this->drupalCreateNode(array('uid' => $this->adminUser->id(), 'type' => 'page'));
+ $node5 = $this->drupalCreateNode(['uid' => $this->adminUser->id(), 'type' => 'page']);
$this->drupalLogout();
$this->drupalLogin($this->webUser);
diff --git a/core/modules/node/src/Tests/NodeEditFormTest.php b/core/modules/node/src/Tests/NodeEditFormTest.php
index bef0252cc02..ed8b34a475d 100644
--- a/core/modules/node/src/Tests/NodeEditFormTest.php
+++ b/core/modules/node/src/Tests/NodeEditFormTest.php
@@ -43,8 +43,8 @@ class NodeEditFormTest extends NodeTestBase {
protected function setUp() {
parent::setUp();
- $this->webUser = $this->drupalCreateUser(array('edit own page content', 'create page content'));
- $this->adminUser = $this->drupalCreateUser(array('bypass node access', 'administer nodes'));
+ $this->webUser = $this->drupalCreateUser(['edit own page content', 'create page content']);
+ $this->adminUser = $this->drupalCreateUser(['bypass node access', 'administer nodes']);
$this->drupalPlaceBlock('local_tasks_block');
$this->nodeStorage = $this->container->get('entity.manager')->getStorage('node');
@@ -59,7 +59,7 @@ class NodeEditFormTest extends NodeTestBase {
$title_key = 'title[0][value]';
$body_key = 'body[0][value]';
// Create node to edit.
- $edit = array();
+ $edit = [];
$edit[$title_key] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save'));
@@ -79,7 +79,7 @@ class NodeEditFormTest extends NodeTestBase {
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
// Edit the content of the node.
- $edit = array();
+ $edit = [];
$edit[$title_key] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
// Stay on the current page, without reloading.
@@ -90,11 +90,11 @@ class NodeEditFormTest extends NodeTestBase {
$this->assertText($edit[$body_key], 'Body displayed.');
// Log in as a second administrator user.
- $second_web_user = $this->drupalCreateUser(array('administer nodes', 'edit any page content'));
+ $second_web_user = $this->drupalCreateUser(['administer nodes', 'edit any page content']);
$this->drupalLogin($second_web_user);
// Edit the same node, creating a new revision.
$this->drupalGet("node/" . $node->id() . "/edit");
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
$edit['revision'] = TRUE;
@@ -140,7 +140,7 @@ class NodeEditFormTest extends NodeTestBase {
// Create node to edit.
$body_key = 'body[0][value]';
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save and publish'));
@@ -173,7 +173,7 @@ class NodeEditFormTest extends NodeTestBase {
// Save the node without making any changes.
$this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and keep published'));
- $this->nodeStorage->resetCache(array($node->id()));
+ $this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$this->assertIdentical($this->webUser->id(), $node->getOwner()->id());
@@ -185,7 +185,7 @@ class NodeEditFormTest extends NodeTestBase {
// Check that saving the node without making any changes keeps the proper
// author ID.
$this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and keep published'));
- $this->nodeStorage->resetCache(array($node->id()));
+ $this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$this->assertIdentical($this->webUser->id(), $node->getOwner()->id());
}
@@ -200,17 +200,17 @@ class NodeEditFormTest extends NodeTestBase {
*/
protected function checkVariousAuthoredByValues(NodeInterface $node, $form_element_name) {
// Try to change the 'authored by' field to an invalid user name.
- $edit = array(
+ $edit = [
$form_element_name => 'invalid-name',
- );
+ ];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
- $this->assertRaw(t('There are no entities matching "%name".', array('%name' => 'invalid-name')));
+ $this->assertRaw(t('There are no entities matching "%name".', ['%name' => 'invalid-name']));
// Change the authored by field to an empty string, which should assign
// authorship to the anonymous user (uid 0).
$edit[$form_element_name] = '';
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
- $this->nodeStorage->resetCache(array($node->id()));
+ $this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$uid = $node->getOwnerId();
// Most SQL database drivers stringify fetches but entities are not
@@ -229,7 +229,7 @@ class NodeEditFormTest extends NodeTestBase {
// logged in).
$edit[$form_element_name] = $this->webUser->getUsername();
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
- $this->nodeStorage->resetCache(array($node->id()));
+ $this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$this->assertIdentical($node->getOwnerId(), $this->webUser->id(), 'Node authored by normal user.');
}
diff --git a/core/modules/node/src/Tests/NodeEntityViewModeAlterTest.php b/core/modules/node/src/Tests/NodeEntityViewModeAlterTest.php
index 25ae6b68b1b..79baf9bb772 100644
--- a/core/modules/node/src/Tests/NodeEntityViewModeAlterTest.php
+++ b/core/modules/node/src/Tests/NodeEntityViewModeAlterTest.php
@@ -14,17 +14,17 @@ class NodeEntityViewModeAlterTest extends NodeTestBase {
/**
* Enable dummy module that implements hook_ENTITY_TYPE_view() for nodes.
*/
- public static $modules = array('node_test');
+ public static $modules = ['node_test'];
/**
* Create a "Basic page" node and verify its consistency in the database.
*/
function testNodeViewModeChange() {
- $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit own page content']);
$this->drupalLogin($web_user);
// Create a node.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = t('Data that should appear only in the body for the node.');
$edit['body[0][summary]'] = t('Extra data that should appear only in the teaser for the node.');
diff --git a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php
index 3bd1a51ef6d..ff01deed294 100644
--- a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php
+++ b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php
@@ -20,31 +20,31 @@ class NodeFieldMultilingualTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'language');
+ public static $modules = ['node', 'language'];
protected function setUp() {
parent::setUp();
// Create Basic page node type.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Setup users.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages', 'create page content', 'edit own page content'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'administer content types', 'access administration pages', 'create page content', 'edit own page content']);
$this->drupalLogin($admin_user);
// Add a new language.
ConfigurableLanguage::createFromLangcode('it')->save();
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => '1');
+ $edit = ['language_interface[enabled][language-url]' => '1'];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Set "Basic page" content type to use multilingual support.
- $edit = array(
+ $edit = [
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
- $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.');
+ $this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']), 'Basic page content type has been updated.');
// Make node body translatable.
$field_storage = FieldStorageConfig::loadByName('node', 'body');
@@ -64,7 +64,7 @@ class NodeFieldMultilingualTest extends WebTestBase {
$body_value = $this->randomMachineName(16);
// Create node to edit.
- $edit = array();
+ $edit = [];
$edit[$title_key] = $title_value;
$edit[$body_key] = $body_value;
$this->drupalPostForm('node/add/page', $edit, t('Save'));
@@ -77,17 +77,17 @@ class NodeFieldMultilingualTest extends WebTestBase {
// Change node language.
$langcode = 'it';
$this->drupalGet("node/{$node->id()}/edit");
- $edit = array(
+ $edit = [
$title_key => $this->randomMachineName(8),
'langcode[0][value]' => $langcode,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE);
$this->assertTrue($node, 'Node found in database.');
$this->assertTrue($node->language()->getId() == $langcode && $node->body->value == $body_value, 'Field language correctly changed.');
// Enable content language URL detection.
- $this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0));
+ $this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_CONTENT, [LanguageNegotiationUrl::METHOD_ID => 0]);
// Test multilingual field language fallback logic.
$this->drupalGet("it/node/{$node->id()}");
@@ -108,7 +108,7 @@ class NodeFieldMultilingualTest extends WebTestBase {
$body_value = $this->randomMachineName(16);
// Create node to edit.
- $edit = array();
+ $edit = [];
$edit[$title_key] = $title_value;
$edit[$body_key] = $body_value;
$this->drupalPostForm('node/add/page', $edit, t('Save'));
@@ -119,10 +119,10 @@ class NodeFieldMultilingualTest extends WebTestBase {
// Check if node body is showed.
$this->drupalGet('node/' . $node->id());
- $body = $this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]//div[contains(concat(" ", normalize-space(@class), " "), :content-class)]/descendant::p', array(
+ $body = $this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]//div[contains(concat(" ", normalize-space(@class), " "), :content-class)]/descendant::p', [
':node-class' => ' node ',
':content-class' => 'node__content',
- ));
+ ]);
$this->assertEqual(current($body), $node->body->value, 'Node body found.');
}
diff --git a/core/modules/node/src/Tests/NodeFormButtonsTest.php b/core/modules/node/src/Tests/NodeFormButtonsTest.php
index 9f6732bfc20..9f98007cb9d 100644
--- a/core/modules/node/src/Tests/NodeFormButtonsTest.php
+++ b/core/modules/node/src/Tests/NodeFormButtonsTest.php
@@ -29,9 +29,9 @@ class NodeFormButtonsTest extends NodeTestBase {
parent::setUp();
// Create a user that has no access to change the state of the node.
- $this->webUser = $this->drupalCreateUser(array('create article content', 'edit own article content'));
+ $this->webUser = $this->drupalCreateUser(['create article content', 'edit own article content']);
// Create a user that has access to change the state of the node.
- $this->adminUser = $this->drupalCreateUser(array('administer nodes', 'bypass node access'));
+ $this->adminUser = $this->drupalCreateUser(['administer nodes', 'bypass node access']);
}
/**
@@ -44,11 +44,11 @@ class NodeFormButtonsTest extends NodeTestBase {
// Verify the buttons on a node add form.
$this->drupalGet('node/add/article');
- $this->assertButtons(array(t('Save and publish'), t('Save as unpublished')));
+ $this->assertButtons([t('Save and publish'), t('Save as unpublished')]);
// Save the node and assert it's published after clicking
// 'Save and publish'.
- $edit = array('title[0][value]' => $this->randomString());
+ $edit = ['title[0][value]' => $this->randomString()];
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
// Get the node.
@@ -57,25 +57,25 @@ class NodeFormButtonsTest extends NodeTestBase {
// Verify the buttons on a node edit form.
$this->drupalGet('node/' . $node_1->id() . '/edit');
- $this->assertButtons(array(t('Save and keep published'), t('Save and unpublish')));
+ $this->assertButtons([t('Save and keep published'), t('Save and unpublish')]);
// Save the node and verify it's still published after clicking
// 'Save and keep published'.
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
- $node_storage->resetCache(array(1));
+ $node_storage->resetCache([1]);
$node_1 = $node_storage->load(1);
$this->assertTrue($node_1->isPublished(), 'Node is published');
// Save the node and verify it's unpublished after clicking
// 'Save and unpublish'.
$this->drupalPostForm('node/' . $node_1->id() . '/edit', $edit, t('Save and unpublish'));
- $node_storage->resetCache(array(1));
+ $node_storage->resetCache([1]);
$node_1 = $node_storage->load(1);
$this->assertFalse($node_1->isPublished(), 'Node is unpublished');
// Verify the buttons on an unpublished node edit screen.
$this->drupalGet('node/' . $node_1->id() . '/edit');
- $this->assertButtons(array(t('Save and keep unpublished'), t('Save and publish')));
+ $this->assertButtons([t('Save and keep unpublished'), t('Save and publish')]);
// Create a node as a normal user.
$this->drupalLogout();
@@ -83,10 +83,10 @@ class NodeFormButtonsTest extends NodeTestBase {
// Verify the buttons for a normal user.
$this->drupalGet('node/add/article');
- $this->assertButtons(array(t('Save')), FALSE);
+ $this->assertButtons([t('Save')], FALSE);
// Create the node.
- $edit = array('title[0][value]' => $this->randomString());
+ $edit = ['title[0][value]' => $this->randomString()];
$this->drupalPostForm('node/add/article', $edit, t('Save'));
$node_2 = $node_storage->load(2);
$this->assertTrue($node_2->isPublished(), 'Node is published');
@@ -95,8 +95,8 @@ class NodeFormButtonsTest extends NodeTestBase {
// was created by the normal user.
$this->drupalLogout();
$this->drupalLogin($this->adminUser);
- $this->drupalPostForm('node/' . $node_2->id() . '/edit', array(), t('Save and unpublish'));
- $node_storage->resetCache(array(2));
+ $this->drupalPostForm('node/' . $node_2->id() . '/edit', [], t('Save and unpublish'));
+ $node_storage->resetCache([2]);
$node_2 = $node_storage->load(2);
$this->assertFalse($node_2->isPublished(), 'Node is unpublished');
@@ -104,8 +104,8 @@ class NodeFormButtonsTest extends NodeTestBase {
// it's still unpublished.
$this->drupalLogout();
$this->drupalLogin($this->webUser);
- $this->drupalPostForm('node/' . $node_2->id() . '/edit', array(), t('Save'));
- $node_storage->resetCache(array(2));
+ $this->drupalPostForm('node/' . $node_2->id() . '/edit', [], t('Save'));
+ $node_storage->resetCache([2]);
$node_2 = $node_storage->load(2);
$this->assertFalse($node_2->isPublished(), 'Node is still unpublished');
$this->drupalLogout();
@@ -121,12 +121,12 @@ class NodeFormButtonsTest extends NodeTestBase {
// Verify the buttons on a node add form for an administrator.
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/add/article');
- $this->assertButtons(array(t('Save as unpublished'), t('Save and publish')));
+ $this->assertButtons([t('Save as unpublished'), t('Save and publish')]);
// Verify the node is unpublished by default for a normal user.
$this->drupalLogout();
$this->drupalLogin($this->webUser);
- $edit = array('title[0][value]' => $this->randomString());
+ $edit = ['title[0][value]' => $this->randomString()];
$this->drupalPostForm('node/add/article', $edit, t('Save'));
$node_3 = $node_storage->load(3);
$this->assertFalse($node_3->isPublished(), 'Node is unpublished');
diff --git a/core/modules/node/src/Tests/NodeQueryAlterTest.php b/core/modules/node/src/Tests/NodeQueryAlterTest.php
index 022625bdcb0..ad63d6bc574 100644
--- a/core/modules/node/src/Tests/NodeQueryAlterTest.php
+++ b/core/modules/node/src/Tests/NodeQueryAlterTest.php
@@ -14,7 +14,7 @@ class NodeQueryAlterTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_access_test');
+ public static $modules = ['node_access_test'];
/**
* User with permission to view content.
@@ -39,9 +39,9 @@ class NodeQueryAlterTest extends NodeTestBase {
// Create user with simple node access permission. The 'node test view'
// permission is implemented and granted by the node_access_test module.
- $this->accessUser = $this->drupalCreateUser(array('access content overview', 'access content', 'node test view'));
- $this->noAccessUser = $this->drupalCreateUser(array('access content overview', 'access content'));
- $this->noAccessUser2 = $this->drupalCreateUser(array('access content overview', 'access content'));
+ $this->accessUser = $this->drupalCreateUser(['access content overview', 'access content', 'node test view']);
+ $this->noAccessUser = $this->drupalCreateUser(['access content overview', 'access content']);
+ $this->noAccessUser2 = $this->drupalCreateUser(['access content overview', 'access content']);
}
/**
@@ -143,14 +143,14 @@ class NodeQueryAlterTest extends NodeTestBase {
* hook_node_grants().
*/
function testNodeQueryAlterOverride() {
- $record = array(
+ $record = [
'nid' => 0,
'gid' => 0,
'realm' => 'node_access_all',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
- );
+ ];
db_insert('node_access')->fields($record)->execute();
// Test that the noAccessUser still doesn't have the 'view'
diff --git a/core/modules/node/src/Tests/NodeRevisionPermissionsTest.php b/core/modules/node/src/Tests/NodeRevisionPermissionsTest.php
index e000fb808f9..6f1409dcaa2 100644
--- a/core/modules/node/src/Tests/NodeRevisionPermissionsTest.php
+++ b/core/modules/node/src/Tests/NodeRevisionPermissionsTest.php
@@ -21,30 +21,30 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
*
* @var array
*/
- protected $accounts = array();
+ protected $accounts = [];
// Map revision permission names to node revision access ops.
- protected $map = array(
+ protected $map = [
'view' => 'view all revisions',
'update' => 'revert all revisions',
'delete' => 'delete all revisions',
- );
+ ];
// Map revision permission names to node type revision access ops.
- protected $typeMap = array(
+ protected $typeMap = [
'view' => 'view page revisions',
'update' => 'revert page revisions',
'delete' => 'delete page revisions',
- );
+ ];
protected function setUp() {
parent::setUp();
- $types = array('page', 'article');
+ $types = ['page', 'article'];
foreach ($types as $type) {
// Create a node with several revisions.
- $nodes[$type] = $this->drupalCreateNode(array('type' => $type));
+ $nodes[$type] = $this->drupalCreateNode(['type' => $type]);
$this->nodeRevisions[$type][] = $nodes[$type];
for ($i = 0; $i < 3; $i++) {
@@ -66,19 +66,19 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
foreach ($this->map as $op => $permission) {
// Create the user.
$account = $this->drupalCreateUser(
- array(
+ [
'access content',
'edit any page content',
'delete any page content',
$permission,
- )
+ ]
);
$account->op = $op;
$this->accounts[] = $account;
}
// Create an admin account (returns TRUE for all revision permissions).
- $admin_account = $this->drupalCreateUser(array('access content', 'administer nodes'));
+ $admin_account = $this->drupalCreateUser(['access content', 'administer nodes']);
$admin_account->is_admin = TRUE;
$this->accounts['admin'] = $admin_account;
$accounts['admin'] = $admin_account;
@@ -90,17 +90,17 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
$accounts[] = $normal_account;
$revision = $this->nodeRevisions['page'][1];
- $parameters = array(
+ $parameters = [
'op' => array_keys($this->map),
'account' => $this->accounts,
- );
+ ];
$permutations = $this->generatePermutations($parameters);
$node_revision_access = \Drupal::service('access_check.node.revision');
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
- if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->id()))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
+ if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', [':nid' => $revision->id()])->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || $case['account']->hasPermission($this->map[$case['op']])) {
$this->assertTrue($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->map[$case['op']]} granted.");
}
@@ -124,21 +124,21 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
foreach ($this->typeMap as $op => $permission) {
// Create the user.
$account = $this->drupalCreateUser(
- array(
+ [
'access content',
'edit any page content',
'delete any page content',
$permission,
- )
+ ]
);
$account->op = $op;
$accounts[] = $account;
}
- $parameters = array(
+ $parameters = [
'op' => array_keys($this->typeMap),
'account' => $accounts,
- );
+ ];
// Test that the accounts have access to the corresponding page revision
// permissions.
@@ -148,7 +148,7 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
$node_revision_access = \Drupal::service('access_check.node.revision');
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
- if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->id()))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
+ if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', [':nid' => $revision->id()])->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || $case['account']->hasPermission($this->typeMap[$case['op']], $case['account'])) {
$this->assertTrue($node_revision_access->checkAccess($revision, $case['account'], $case['op']), "{$this->typeMap[$case['op']]} granted.");
}
diff --git a/core/modules/node/src/Tests/NodeRevisionsTest.php b/core/modules/node/src/Tests/NodeRevisionsTest.php
index bfdd213f410..19798631f5b 100644
--- a/core/modules/node/src/Tests/NodeRevisionsTest.php
+++ b/core/modules/node/src/Tests/NodeRevisionsTest.php
@@ -47,26 +47,26 @@ class NodeRevisionsTest extends NodeTestBase {
ConfigurableLanguage::createFromLangcode('de')->save();
ConfigurableLanguage::createFromLangcode('it')->save();
- $field_storage_definition = array(
+ $field_storage_definition = [
'field_name' => 'untranslatable_string_field',
'entity_type' => 'node',
'type' => 'string',
'cardinality' => 1,
'translatable' => FALSE,
- );
+ ];
$field_storage = FieldStorageConfig::create($field_storage_definition);
$field_storage->save();
- $field_definition = array(
+ $field_definition = [
'field_storage' => $field_storage,
'bundle' => 'page',
- );
+ ];
$field = FieldConfig::create($field_definition);
$field->save();
// Create and log in user.
$web_user = $this->drupalCreateUser(
- array(
+ [
'view page revisions',
'revert page revisions',
'delete page revisions',
@@ -75,7 +75,7 @@ class NodeRevisionsTest extends NodeTestBase {
'access contextual links',
'translate any entity',
'administer content types',
- )
+ ]
);
$this->drupalLogin($web_user);
@@ -86,8 +86,8 @@ class NodeRevisionsTest extends NodeTestBase {
$settings['revision'] = 1;
$settings['isDefaultRevision'] = TRUE;
- $nodes = array();
- $logs = array();
+ $nodes = [];
+ $logs = [];
// Get original node.
$nodes[] = clone $node;
@@ -99,10 +99,10 @@ class NodeRevisionsTest extends NodeTestBase {
// Create revision with a random title and body and update variables.
$node->title = $this->randomMachineName();
- $node->body = array(
+ $node->body = [
'value' => $this->randomMachineName(32),
'format' => filter_default_format(),
- );
+ ];
$node->untranslatable_string_field->value = $this->randomString();
$node->setNewRevision();
@@ -167,11 +167,11 @@ class NodeRevisionsTest extends NodeTestBase {
// Confirm that revisions revert properly.
- $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionid() . "/revert", array(), t('Revert'));
+ $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionid() . "/revert", [], t('Revert'));
$this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.',
- array('@type' => 'Basic page', '%title' => $nodes[1]->label(),
- '%revision-date' => format_date($nodes[1]->getRevisionCreationTime()))), 'Revision reverted.');
- $node_storage->resetCache(array($node->id()));
+ ['@type' => 'Basic page', '%title' => $nodes[1]->label(),
+ '%revision-date' => format_date($nodes[1]->getRevisionCreationTime())]), 'Revision reverted.');
+ $node_storage->resetCache([$node->id()]);
$reverted_node = $node_storage->load($node->id());
$this->assertTrue(($nodes[1]->body->value == $reverted_node->body->value), 'Node reverted correctly.');
@@ -190,27 +190,27 @@ class NodeRevisionsTest extends NodeTestBase {
// Confirm revisions delete properly.
- $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", array(), t('Delete'));
+ $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", [], t('Delete'));
$this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.',
- array('%revision-date' => format_date($nodes[1]->getRevisionCreationTime()),
- '@type' => 'Basic page', '%title' => $nodes[1]->label())), 'Revision deleted.');
- $this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid and vid = :vid', array(':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()))->fetchField() == 0, 'Revision not found.');
+ ['%revision-date' => format_date($nodes[1]->getRevisionCreationTime()),
+ '@type' => 'Basic page', '%title' => $nodes[1]->label()]), 'Revision deleted.');
+ $this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid and vid = :vid', [':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()])->fetchField() == 0, 'Revision not found.');
// Set the revision timestamp to an older date to make sure that the
// confirmation message correctly displays the stored revision date.
$old_revision_date = REQUEST_TIME - 86400;
db_update('node_revision')
->condition('vid', $nodes[2]->getRevisionId())
- ->fields(array(
+ ->fields([
'revision_timestamp' => $old_revision_date,
- ))
+ ])
->execute();
- $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", array(), t('Revert'));
- $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', array(
+ $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", [], t('Revert'));
+ $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
'@type' => 'Basic page',
'%title' => $nodes[2]->label(),
'%revision-date' => format_date($old_revision_date),
- )));
+ ]));
// Make a new revision and set it to not be default.
// This will create a new revision that is not "front facing".
@@ -232,7 +232,7 @@ class NodeRevisionsTest extends NodeTestBase {
// Verify that the non-default revision vid is greater than the default
// revision vid.
$default_revision = db_select('node', 'n')
- ->fields('n', array('vid'))
+ ->fields('n', ['vid'])
->condition('nid', $node->id())
->execute()
->fetchCol();
@@ -301,7 +301,7 @@ class NodeRevisionsTest extends NodeTestBase {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
// Create a node with an initial log message.
$revision_log = $this->randomMachineName(10);
- $node = $this->drupalCreateNode(array('revision_log' => $revision_log));
+ $node = $this->drupalCreateNode(['revision_log' => $revision_log]);
// Save over the same revision and explicitly provide an empty log message
// (for example, to mimic the case of a node form submitted with no text in
@@ -317,12 +317,12 @@ class NodeRevisionsTest extends NodeTestBase {
$node->save();
$this->drupalGet('node/' . $node->id());
$this->assertText($new_title, 'New node title appears on the page.');
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$node_revision = $node_storage->load($node->id());
$this->assertEqual($node_revision->revision_log->value, $revision_log, 'After an existing node revision is re-saved without a log message, the original log message is preserved.');
// Create another node with an initial revision log message.
- $node = $this->drupalCreateNode(array('revision_log' => $revision_log));
+ $node = $this->drupalCreateNode(['revision_log' => $revision_log]);
// Save a new node revision without providing a log message, and check that
// this revision has an empty log message.
@@ -336,7 +336,7 @@ class NodeRevisionsTest extends NodeTestBase {
$node->save();
$this->drupalGet('node/' . $node->id());
$this->assertText($new_title, 'New node title appears on the page.');
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$node_revision = $node_storage->load($node->id());
$this->assertTrue(empty($node_revision->revision_log->value), 'After a new node revision is saved with an empty log message, the log message for the node is empty.');
}
@@ -353,7 +353,7 @@ class NodeRevisionsTest extends NodeTestBase {
* The decoded JSON response body.
*/
protected function renderContextualLinks(array $ids, $current_path) {
- $post = array();
+ $post = [];
for ($i = 0; $i < count($ids); $i++) {
$post['ids[' . $i . ']'] = $ids[$i];
}
diff --git a/core/modules/node/src/Tests/NodeSyndicateBlockTest.php b/core/modules/node/src/Tests/NodeSyndicateBlockTest.php
index 31b216f5696..23c3d881a7c 100644
--- a/core/modules/node/src/Tests/NodeSyndicateBlockTest.php
+++ b/core/modules/node/src/Tests/NodeSyndicateBlockTest.php
@@ -14,13 +14,13 @@ class NodeSyndicateBlockTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('block');
+ public static $modules = ['block'];
protected function setUp() {
parent::setUp();
// Create a user and log in.
- $admin_user = $this->drupalCreateUser(array('administer blocks'));
+ $admin_user = $this->drupalCreateUser(['administer blocks']);
$this->drupalLogin($admin_user);
}
@@ -29,7 +29,7 @@ class NodeSyndicateBlockTest extends NodeTestBase {
*/
public function testSyndicateBlock() {
// Place the "Syndicate" block and confirm that it is rendered.
- $this->drupalPlaceBlock('node_syndicate_block', array('id' => 'test_syndicate_block'));
+ $this->drupalPlaceBlock('node_syndicate_block', ['id' => 'test_syndicate_block']);
$this->drupalGet('');
$this->assertFieldByXPath('//div[@id="block-test-syndicate-block"]/*', NULL, 'Syndicate block found.');
}
diff --git a/core/modules/node/src/Tests/NodeTestBase.php b/core/modules/node/src/Tests/NodeTestBase.php
index a5da2b4f5bf..d5a349de1aa 100644
--- a/core/modules/node/src/Tests/NodeTestBase.php
+++ b/core/modules/node/src/Tests/NodeTestBase.php
@@ -19,7 +19,7 @@ abstract class NodeTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'datetime');
+ public static $modules = ['node', 'datetime'];
/**
* The node access control handler.
@@ -36,12 +36,12 @@ abstract class NodeTestBase extends WebTestBase {
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
'display_submitted' => FALSE,
- ));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ ]);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
$this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node');
}
@@ -79,9 +79,9 @@ abstract class NodeTestBase extends WebTestBase {
* to check. If NULL, the untranslated (fallback) access is checked.
*/
function assertNodeCreateAccess($bundle, $result, AccountInterface $account, $langcode = NULL) {
- $this->assertEqual($result, $this->accessHandler->createAccess($bundle, $account, array(
+ $this->assertEqual($result, $this->accessHandler->createAccess($bundle, $account, [
'langcode' => $langcode,
- )), $this->nodeAccessAssertMessage('create', $result, $langcode));
+ ]), $this->nodeAccessAssertMessage('create', $result, $langcode));
}
/**
@@ -102,11 +102,11 @@ abstract class NodeTestBase extends WebTestBase {
function nodeAccessAssertMessage($operation, $result, $langcode = NULL) {
return format_string(
'Node access returns @result with operation %op, language code %langcode.',
- array(
+ [
'@result' => $result ? 'true' : 'false',
'%op' => $operation,
'%langcode' => !empty($langcode) ? $langcode : 'empty'
- )
+ ]
);
}
diff --git a/core/modules/node/src/Tests/NodeTitleTest.php b/core/modules/node/src/Tests/NodeTitleTest.php
index 59ee0214940..986be794380 100644
--- a/core/modules/node/src/Tests/NodeTitleTest.php
+++ b/core/modules/node/src/Tests/NodeTitleTest.php
@@ -19,7 +19,7 @@ class NodeTitleTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('comment', 'views', 'block');
+ public static $modules = ['comment', 'views', 'block'];
/**
* A user with permission to bypass access content.
@@ -35,7 +35,7 @@ class NodeTitleTest extends NodeTestBase {
parent::setUp();
$this->drupalPlaceBlock('system_breadcrumb_block');
- $this->adminUser = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content', 'post comments'));
+ $this->adminUser = $this->drupalCreateUser(['administer nodes', 'create article content', 'create page content', 'post comments']);
$this->drupalLogin($this->adminUser);
$this->addDefaultCommentField('node', 'page');
}
@@ -47,10 +47,10 @@ class NodeTitleTest extends NodeTestBase {
// Create "Basic page" content with title.
// Add the node to the frontpage so we can test if teaser links are
// clickable.
- $settings = array(
+ $settings = [
'title' => $this->randomMachineName(8),
'promote' => 1,
- );
+ ];
$node = $this->drupalCreateNode($settings);
// Test <title> tag.
@@ -64,16 +64,16 @@ class NodeTitleTest extends NodeTestBase {
$this->assertEqual(current($this->xpath($xpath)), $node->label(), 'Node breadcrumb is equal to node title.', 'Node');
// Test node title in comment preview.
- $this->assertEqual(current($this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]/h2/a/span', array(':node-class' => ' node--type-' . $node->bundle() . ' '))), $node->label(), 'Node preview title is equal to node title.', 'Node');
+ $this->assertEqual(current($this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]/h2/a/span', [':node-class' => ' node--type-' . $node->bundle() . ' '])), $node->label(), 'Node preview title is equal to node title.', 'Node');
// Test node title is clickable on teaser list (/node).
$this->drupalGet('node');
$this->clickLink($node->label());
// Test edge case where node title is set to 0.
- $settings = array(
+ $settings = [
'title' => 0,
- );
+ ];
$node = $this->drupalCreateNode($settings);
// Test that 0 appears as <title>.
$this->drupalGet('node/' . $node->id());
@@ -84,9 +84,9 @@ class NodeTitleTest extends NodeTestBase {
// Test edge case where node title contains special characters.
$edge_case_title = 'article\'s "title".';
- $settings = array(
+ $settings = [
'title' => $edge_case_title,
- );
+ ];
$node = $this->drupalCreateNode($settings);
// Test that the title appears as <title>. The title will be escaped on the
// the page.
diff --git a/core/modules/node/src/Tests/NodeTitleXSSTest.php b/core/modules/node/src/Tests/NodeTitleXSSTest.php
index c41027514a3..7b4890eb0c5 100644
--- a/core/modules/node/src/Tests/NodeTitleXSSTest.php
+++ b/core/modules/node/src/Tests/NodeTitleXSSTest.php
@@ -16,18 +16,18 @@ class NodeTitleXSSTest extends NodeTestBase {
*/
function testNodeTitleXSS() {
// Prepare a user to do the stuff.
- $web_user = $this->drupalCreateUser(array('create page content', 'edit any page content'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit any page content']);
$this->drupalLogin($web_user);
$xss = '<script>alert("xss")</script>';
$title = $xss . $this->randomMachineName();
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $title;
$this->drupalPostForm('node/add/page', $edit, t('Preview'));
$this->assertNoRaw($xss, 'Harmful tags are escaped when previewing a node.');
- $settings = array('title' => $title);
+ $settings = ['title' => $title];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php
index 063469d38ab..a01c4d5c39a 100644
--- a/core/modules/node/src/Tests/NodeTranslationUITest.php
+++ b/core/modules/node/src/Tests/NodeTranslationUITest.php
@@ -35,7 +35,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array('block', 'language', 'content_translation', 'node', 'datetime', 'field_ui', 'help');
+ public static $modules = ['block', 'language', 'content_translation', 'node', 'datetime', 'field_ui', 'help'];
/**
* The profile to install as a basis for testing.
@@ -50,11 +50,11 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
parent::setUp();
// Ensure the help message is shown even with prefixed paths.
- $this->drupalPlaceBlock('help_block', array('region' => 'content'));
+ $this->drupalPlaceBlock('help_block', ['region' => 'content']);
// Display the language selector.
$this->drupalLogin($this->administrator);
- $edit = array('language_configuration[language_alterable]' => TRUE);
+ $edit = ['language_configuration[language_alterable]' => TRUE];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->drupalLogin($this->translator);
}
@@ -75,13 +75,13 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$this->drupalLogin($this->administrator);
// Delete all fields.
$this->drupalGet('admin/structure/types/manage/article/fields');
- $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $this->fieldName . '/delete', array(), t('Delete'));
- $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags/delete', array(), t('Delete'));
- $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $this->fieldName . '/delete', [], t('Delete'));
+ $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags/delete', [], t('Delete'));
+ $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image/delete', [], t('Delete'));
// Add a node.
$default_langcode = $this->langcodes[0];
- $values[$default_langcode] = array('title' => array(array('value' => $this->randomMachineName())));
+ $values[$default_langcode] = ['title' => [['value' => $this->randomMachineName()]]];
$entity_id = $this->createEntity($values[$default_langcode], $default_langcode);
$storage = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId);
@@ -91,14 +91,14 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
// Add a content translation.
$langcode = 'fr';
$language = ConfigurableLanguage::load($langcode);
- $values[$langcode] = array('title' => array(array('value' => $this->randomMachineName())));
+ $values[$langcode] = ['title' => [['value' => $this->randomMachineName()]]];
$entity_type_id = $entity->getEntityTypeId();
$add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [
$entity->getEntityTypeId() => $entity->id(),
'source' => $default_langcode,
'target' => $langcode
- ], array('language' => $language));
+ ], ['language' => $language]);
$this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), t('Save and unpublish (this translation)'));
$storage->resetCache([$this->entityId]);
@@ -112,28 +112,28 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('administer nodes', "edit any $this->bundle content"));
+ return array_merge(parent::getTranslatorPermissions(), ['administer nodes', "edit any $this->bundle content"]);
}
/**
* {@inheritdoc}
*/
protected function getEditorPermissions() {
- return array('administer nodes', 'create article content');
+ return ['administer nodes', 'create article content'];
}
/**
* {@inheritdoc}
*/
protected function getAdministratorPermissions() {
- return array_merge(parent::getAdministratorPermissions(), array('access administration pages', 'administer content types', 'administer node fields', 'access content overview', 'bypass node access', 'administer languages', 'administer themes', 'view the administration theme'));
+ return array_merge(parent::getAdministratorPermissions(), ['access administration pages', 'administer content types', 'administer node fields', 'access content overview', 'bypass node access', 'administer languages', 'administer themes', 'view the administration theme']);
}
/**
* {@inheritdoc}
*/
protected function getNewEntityValues($langcode) {
- return array('title' => array(array('value' => $this->randomMachineName()))) + parent::getNewEntityValues($langcode);
+ return ['title' => [['value' => $this->randomMachineName()]]] + parent::getNewEntityValues($langcode);
}
/**
@@ -158,18 +158,18 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$entity = $storage->load($this->entityId);
$languages = $this->container->get('language_manager')->getLanguages();
- $actions = array(
+ $actions = [
t('Save and keep published'),
t('Save and unpublish'),
- );
+ ];
foreach ($actions as $index => $action) {
// (Un)publish the node translations and check that the translation
// statuses are (un)published accordingly.
foreach ($this->langcodes as $langcode) {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
- $this->drupalPostForm($url, array(), $action . $this->getFormSubmitSuffix($entity, $langcode), $options);
+ $this->drupalPostForm($url, [], $action . $this->getFormSubmitSuffix($entity, $langcode), $options);
}
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
@@ -192,25 +192,25 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
$languages = $this->container->get('language_manager')->getLanguages();
- $values = array();
+ $values = [];
// Post different base field information for each translation.
foreach ($this->langcodes as $langcode) {
$user = $this->drupalCreateUser();
- $values[$langcode] = array(
+ $values[$langcode] = [
'uid' => $user->id(),
'created' => REQUEST_TIME - mt_rand(0, 1000),
'sticky' => (bool) mt_rand(0, 1),
'promote' => (bool) mt_rand(0, 1),
- );
- $edit = array(
+ ];
+ $edit = [
'uid[0][target_id]' => $user->getUsername(),
'created[0][value][date]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d'),
'created[0][value][time]' => format_date($values[$langcode]['created'], 'custom', 'H:i:s'),
'sticky[value]' => $values[$langcode]['sticky'],
'promote[value]' => $values[$langcode]['promote'],
- );
- $options = array('language' => $languages[$langcode]);
+ ];
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode), $options);
}
@@ -232,11 +232,11 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
*/
public function testTranslationLinkTheme() {
$this->drupalLogin($this->administrator);
- $article = $this->drupalCreateNode(array('type' => 'article', 'langcode' => $this->langcodes[0]));
+ $article = $this->drupalCreateNode(['type' => 'article', 'langcode' => $this->langcodes[0]]);
// Set up Seven as the admin theme and use it for node editing.
- $this->container->get('theme_handler')->install(array('seven'));
- $edit = array();
+ $this->container->get('theme_handler')->install(['seven']);
+ $edit = [];
$edit['admin_theme'] = 'seven';
$edit['use_admin_theme'] = TRUE;
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
@@ -259,16 +259,16 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
public function testDisabledBundle() {
// Create a bundle that does not have translation enabled.
$disabledBundle = $this->randomMachineName();
- $this->drupalCreateContentType(array('type' => $disabledBundle, 'name' => $disabledBundle));
+ $this->drupalCreateContentType(['type' => $disabledBundle, 'name' => $disabledBundle]);
// Create a node for each bundle.
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'type' => $this->bundle,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
// Make sure that nothing was inserted into the {content_translation} table.
- $rows = db_query('SELECT nid, count(nid) AS count FROM {node_field_data} WHERE type <> :type GROUP BY nid HAVING count(nid) >= 2', array(':type' => $this->bundle))->fetchAll();
+ $rows = db_query('SELECT nid, count(nid) AS count FROM {node_field_data} WHERE type <> :type GROUP BY nid HAVING count(nid) >= 2', [':type' => $this->bundle])->fetchAll();
$this->assertEqual(0, count($rows));
// Ensure the translation tab is not accessible.
@@ -287,7 +287,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$node->setPromoted(TRUE);
// Create translations.
- foreach (array_diff($this->langcodes, array($default_langcode)) as $langcode) {
+ foreach (array_diff($this->langcodes, [$default_langcode]) as $langcode) {
$values[$langcode] = $this->getNewEntityValues($langcode);
$translation = $node->addTranslation($langcode, $values[$langcode]);
// Publish and promote the translation to frontpage.
@@ -297,7 +297,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$node->save();
// Test that the frontpage view displays the correct translations.
- \Drupal::service('module_installer')->install(array('views'), TRUE);
+ \Drupal::service('module_installer')->install(['views'], TRUE);
$this->rebuildContainer();
$this->doTestTranslations('node', $values);
@@ -316,7 +316,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
// See also assertTaxonomyPage() in NodeAccessBaseTableTest.
$node_href = 'node/' . $node->id();
foreach ($this->langcodes as $langcode) {
- $this->drupalGet('node', array('language' => \Drupal::languageManager()->getLanguage($langcode)));
+ $this->drupalGet('node', ['language' => \Drupal::languageManager()->getLanguage($langcode)]);
$num_match_found = 0;
if ($langcode == 'en') {
// Site default language does not have langcode prefix in the URL.
@@ -338,7 +338,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
// language.
$comment_form_href = 'node/' . $node->id() . '#comment-form';
foreach ($this->langcodes as $langcode) {
- $this->drupalGet('node', array('language' => \Drupal::languageManager()->getLanguage($langcode)));
+ $this->drupalGet('node', ['language' => \Drupal::languageManager()->getLanguage($langcode)]);
$num_match_found = 0;
if ($langcode == 'en') {
// Site default language does not have langcode prefix in the URL.
@@ -374,8 +374,8 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
protected function doTestTranslations($path, array $values) {
$languages = $this->container->get('language_manager')->getLanguages();
foreach ($this->langcodes as $langcode) {
- $this->drupalGet($path, array('language' => $languages[$langcode]));
- $this->assertText($values[$langcode]['title'][0]['value'], format_string('The %langcode node translation is correctly displayed.', array('%langcode' => $langcode)));
+ $this->drupalGet($path, ['language' => $languages[$langcode]]);
+ $this->assertText($values[$langcode]['title'][0]['value'], format_string('The %langcode node translation is correctly displayed.', ['%langcode' => $langcode]));
}
}
@@ -398,8 +398,8 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
foreach ($urls as $alternate_langcode => $language_url) {
// Retrieve desired link elements from the HTML head.
$links = $this->xpath('head/link[@rel = "alternate" and @href = :href and @hreflang = :hreflang]',
- array(':href' => $language_url->toString(), ':hreflang' => $alternate_langcode));
- $this->assert(isset($links[0]), format_string('The %langcode node translation has the correct alternate hreflang link for %alternate_langcode: %link.', array('%langcode' => $langcode, '%alternate_langcode' => $alternate_langcode, '%link' => $url->toString())));
+ [':href' => $language_url->toString(), ':hreflang' => $alternate_langcode]);
+ $this->assert(isset($links[0]), format_string('The %langcode node translation has the correct alternate hreflang link for %alternate_langcode: %link.', ['%langcode' => $langcode, '%alternate_langcode' => $alternate_langcode, '%link' => $url->toString()]));
}
}
}
@@ -446,15 +446,15 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('<em>Edit @type</em> @title [%language translation]', array(
+ $title = t('<em>Edit @type</em> @title [%language translation]', [
'@type' => $type_name,
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
diff --git a/core/modules/node/src/Tests/NodeTypeTest.php b/core/modules/node/src/Tests/NodeTypeTest.php
index 0d2d8deabf0..bc4285276ca 100644
--- a/core/modules/node/src/Tests/NodeTypeTest.php
+++ b/core/modules/node/src/Tests/NodeTypeTest.php
@@ -50,14 +50,14 @@ class NodeTypeTest extends NodeTestBase {
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
// Log in a test user.
- $web_user = $this->drupalCreateUser(array('create ' . $type->label() . ' content'));
+ $web_user = $this->drupalCreateUser(['create ' . $type->label() . ' content']);
$this->drupalLogin($web_user);
$this->drupalGet('node/add/' . $type->id());
$this->assertResponse(200, 'The new content type can be accessed at node/add.');
// Create a content type via the user interface.
- $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types'));
+ $web_user = $this->drupalCreateUser(['bypass node access', 'administer content types']);
$this->drupalLogin($web_user);
$this->drupalGet('node/add');
@@ -66,11 +66,11 @@ class NodeTypeTest extends NodeTestBase {
$elements = $this->cssSelect('dl.node-type-list dt');
$this->assertEqual(3, count($elements));
- $edit = array(
+ $edit = [
'name' => 'foo',
'title_label' => 'title for foo',
'type' => 'foo',
- );
+ ];
$this->drupalPostForm('admin/structure/types/add', $edit, t('Save and manage fields'));
$type_exists = (bool) NodeType::load('foo');
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
@@ -84,7 +84,7 @@ class NodeTypeTest extends NodeTestBase {
* Tests editing a node type using the UI.
*/
function testNodeTypeEditing() {
- $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types', 'administer node fields'));
+ $web_user = $this->drupalCreateUser(['bypass node access', 'administer content types', 'administer node fields']);
$this->drupalLogin($web_user);
$field = FieldConfig::loadByName('node', 'page', 'body');
@@ -96,9 +96,9 @@ class NodeTypeTest extends NodeTestBase {
$this->assertRaw('Body', 'Body field was found.');
// Rename the title field.
- $edit = array(
+ $edit = [
'title_label' => 'Foo',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
$this->drupalGet('node/add/page');
@@ -106,10 +106,10 @@ class NodeTypeTest extends NodeTestBase {
$this->assertNoRaw('Title', 'Old title label was not displayed.');
// Change the name and the description.
- $edit = array(
+ $edit = [
'name' => 'Bar',
'description' => 'Lorem ipsum.',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
$this->drupalGet('node/add');
@@ -131,9 +131,9 @@ class NodeTypeTest extends NodeTestBase {
$this->assertEqual($node_bundles['page']['label'], 'NewBar', 'Node type bundle cache is updated');
// Remove the body field.
- $this->drupalPostForm('admin/structure/types/manage/page/fields/node.page.body/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/structure/types/manage/page/fields/node.page.body/delete', [], t('Delete'));
// Resave the settings for this type.
- $this->drupalPostForm('admin/structure/types/manage/page', array(), t('Save content type'));
+ $this->drupalPostForm('admin/structure/types/manage/page', [], t('Save content type'));
// Check that the body field doesn't exist.
$this->drupalGet('node/add/page');
$this->assertNoRaw('Body', 'Body field was not found.');
@@ -147,18 +147,18 @@ class NodeTypeTest extends NodeTestBase {
$type = $this->drupalCreateContentType();
// Log in a test user.
- $web_user = $this->drupalCreateUser(array(
+ $web_user = $this->drupalCreateUser([
'bypass node access',
'administer content types',
- ));
+ ]);
$this->drupalLogin($web_user);
// Add a new node of this type.
- $node = $this->drupalCreateNode(array('type' => $type->id()));
+ $node = $this->drupalCreateNode(['type' => $type->id()]);
// Attempt to delete the content type, which should not be allowed.
$this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
$this->assertRaw(
- t('%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', array('%type' => $type->label())),
+ t('%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', ['%type' => $type->label()]),
'The content type will not be deleted until all nodes of that type are removed.'
);
$this->assertNoText(t('This action cannot be undone.'), 'The node type deletion confirmation form is not available.');
@@ -168,13 +168,13 @@ class NodeTypeTest extends NodeTestBase {
// Attempt to delete the content type, which should now be allowed.
$this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
$this->assertRaw(
- t('Are you sure you want to delete the content type %type?', array('%type' => $type->label())),
+ t('Are you sure you want to delete the content type %type?', ['%type' => $type->label()]),
'The content type is available for deletion.'
);
$this->assertText(t('This action cannot be undone.'), 'The node type deletion confirmation form is available.');
// Test that a locked node type could not be deleted.
- $this->container->get('module_installer')->install(array('node_test_config'));
+ $this->container->get('module_installer')->install(['node_test_config']);
// Lock the default node type.
$locked = \Drupal::state()->get('node.type.locked');
$locked['default'] = 'default';
@@ -186,14 +186,14 @@ class NodeTypeTest extends NodeTestBase {
$this->assertNoLink(t('Delete'));
$this->drupalGet('admin/structure/types/manage/default/delete');
$this->assertResponse(403);
- $this->container->get('module_installer')->uninstall(array('node_test_config'));
+ $this->container->get('module_installer')->uninstall(['node_test_config']);
$this->container = \Drupal::getContainer();
unset($locked['default']);
\Drupal::state()->set('node.type.locked', $locked);
$this->drupalGet('admin/structure/types/manage/default');
$this->clickLink(t('Delete'));
$this->assertResponse(200);
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->assertFalse((bool) NodeType::load('default'), 'Node type with machine default deleted.');
}
@@ -202,7 +202,7 @@ class NodeTypeTest extends NodeTestBase {
*/
public function testNodeTypeFieldUiPermissions() {
// Create an admin user who can only manage node fields.
- $admin_user_1 = $this->drupalCreateUser(array('administer content types', 'administer node fields'));
+ $admin_user_1 = $this->drupalCreateUser(['administer content types', 'administer node fields']);
$this->drupalLogin($admin_user_1);
// Test that the user only sees the actions available to him.
@@ -211,7 +211,7 @@ class NodeTypeTest extends NodeTestBase {
$this->assertNoLinkByHref('admin/structure/types/manage/article/display');
// Create another admin user who can manage node fields display.
- $admin_user_2 = $this->drupalCreateUser(array('administer content types', 'administer node display'));
+ $admin_user_2 = $this->drupalCreateUser(['administer content types', 'administer node display']);
$this->drupalLogin($admin_user_2);
// Test that the user only sees the actions available to him.
diff --git a/core/modules/node/src/Tests/NodeViewTest.php b/core/modules/node/src/Tests/NodeViewTest.php
index 3a27ade0d9e..a01cb25a574 100644
--- a/core/modules/node/src/Tests/NodeViewTest.php
+++ b/core/modules/node/src/Tests/NodeViewTest.php
@@ -89,7 +89,7 @@ class NodeViewTest extends NodeTestBase {
public function testMultiByteUtf8() {
$title = '🐝';
$this->assertTrue(mb_strlen($title, 'utf-8') < strlen($title), 'Title has multi-byte characters.');
- $node = $this->drupalCreateNode(array('title' => $title));
+ $node = $this->drupalCreateNode(['title' => $title]);
$this->drupalGet($node->urlInfo());
$result = $this->xpath('//span[contains(@class, "field--name-title")]');
$this->assertEqual((string) $result[0], $title, 'The passed title was returned.');
diff --git a/core/modules/node/src/Tests/PagePreviewTest.php b/core/modules/node/src/Tests/PagePreviewTest.php
index 086ae827090..aa4bcdb7aef 100644
--- a/core/modules/node/src/Tests/PagePreviewTest.php
+++ b/core/modules/node/src/Tests/PagePreviewTest.php
@@ -29,7 +29,7 @@ class PagePreviewTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node', 'taxonomy', 'comment', 'image', 'file', 'text', 'node_test', 'menu_ui');
+ public static $modules = ['node', 'taxonomy', 'comment', 'image', 'file', 'text', 'node_test', 'menu_ui'];
/**
* The name of the created field.
@@ -42,7 +42,7 @@ class PagePreviewTest extends NodeTestBase {
parent::setUp();
$this->addDefaultCommentField('node', 'page');
- $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content', 'administer menu'));
+ $web_user = $this->drupalCreateUser(['edit own page content', 'create page content', 'administer menu']);
$this->drupalLogin($web_user);
// Add a vocabulary so we can test different view modes.
@@ -89,37 +89,37 @@ class PagePreviewTest extends NodeTestBase {
// Create a field.
$this->fieldName = Unicode::strtolower($this->randomMachineName());
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'page', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'page', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
// Show on default display and teaser.
entity_get_display('node', 'page', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
entity_get_display('node', 'page', 'teaser')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
entity_get_form_display('node', 'page', 'default')
- ->setComponent('field_image', array(
+ ->setComponent('field_image', [
'type' => 'image_image',
'settings' => [],
- ))
+ ])
->save();
entity_get_display('node', 'page', 'default')
@@ -143,15 +143,15 @@ class PagePreviewTest extends NodeTestBase {
])->save();
entity_get_form_display('node', 'page', 'default')
- ->setComponent('field_test_multi', array(
+ ->setComponent('field_test_multi', [
'type' => 'text_textfield',
- ))
+ ])
->save();
entity_get_display('node', 'page', 'default')
- ->setComponent('field_test_multi', array(
+ ->setComponent('field_test_multi', [
'type' => 'string',
- ))
+ ])
->save();
}
@@ -164,7 +164,7 @@ class PagePreviewTest extends NodeTestBase {
$term_key = $this->fieldName . '[target_id]';
// Fill in node creation form and preview node.
- $edit = array();
+ $edit = [];
$edit[$title_key] = '<em>' . $this->randomMachineName(8) . '</em>';
$edit[$body_key] = $this->randomMachineName(16);
$edit[$term_key] = $this->term->getName();
@@ -178,7 +178,7 @@ class PagePreviewTest extends NodeTestBase {
$this->drupalPostForm(NULL, ['field_image[0][alt]' => 'Picture of llamas'], t('Preview'));
// Check that the preview is displaying the title, body and term.
- $this->assertTitle(t('@title | Drupal', array('@title' => $edit[$title_key])), 'Basic page title is preview.');
+ $this->assertTitle(t('@title | Drupal', ['@title' => $edit[$title_key]]), 'Basic page title is preview.');
$this->assertEscaped($edit[$title_key], 'Title displayed and escaped.');
$this->assertText($edit[$body_key], 'Body displayed.');
$this->assertText($edit[$term_key], 'Term displayed.');
@@ -195,7 +195,7 @@ class PagePreviewTest extends NodeTestBase {
->removeComponent('body')
->save();
- $view_mode_edit = array('view_mode' => 'teaser');
+ $view_mode_edit = ['view_mode' => 'teaser'];
$this->drupalPostForm('node/preview/' . $uuid . '/full', $view_mode_edit, t('Switch'));
$this->assertRaw('view-mode-teaser', 'View mode teaser class found.');
$this->assertNoText($edit[$body_key], 'Body not displayed.');
@@ -207,20 +207,20 @@ class PagePreviewTest extends NodeTestBase {
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
$this->assertFieldByName('field_image[0][alt]', 'Picture of llamas');
- $this->drupalPostAjaxForm(NULL, array(), array('field_test_multi_add_more' => t('Add another item')), NULL, array(), array(), 'node-page-form');
+ $this->drupalPostAjaxForm(NULL, [], ['field_test_multi_add_more' => t('Add another item')], NULL, [], [], 'node-page-form');
$this->assertFieldByName('field_test_multi[0][value]');
$this->assertFieldByName('field_test_multi[1][value]');
// Return to page preview to check everything is as expected.
- $this->drupalPostForm(NULL, array(), t('Preview'));
- $this->assertTitle(t('@title | Drupal', array('@title' => $edit[$title_key])), 'Basic page title is preview.');
+ $this->drupalPostForm(NULL, [], t('Preview'));
+ $this->assertTitle(t('@title | Drupal', ['@title' => $edit[$title_key]]), 'Basic page title is preview.');
$this->assertEscaped($edit[$title_key], 'Title displayed and escaped.');
$this->assertText($edit[$body_key], 'Body displayed.');
$this->assertText($edit[$term_key], 'Term displayed.');
$this->assertLink(t('Back to content editing'));
// Assert the content is kept when reloading the page.
- $this->drupalGet('node/add/page', array('query' => array('uuid' => $uuid)));
+ $this->drupalGet('node/add/page', ['query' => ['uuid' => $uuid]]);
$this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
@@ -240,7 +240,7 @@ class PagePreviewTest extends NodeTestBase {
// Check with two new terms on the edit form, additionally to the existing
// one.
- $edit = array();
+ $edit = [];
$newterm1 = $this->randomMachineName(8);
$newterm2 = $this->randomMachineName(8);
$edit[$term_key] = $this->term->getName() . ', ' . $newterm1 . ', ' . $newterm2;
@@ -256,7 +256,7 @@ class PagePreviewTest extends NodeTestBase {
// Check with one more new term, keeping old terms, removing the existing
// one.
- $edit = array();
+ $edit = [];
$newterm3 = $this->randomMachineName(8);
$edit[$term_key] = $newterm1 . ', ' . $newterm3 . ', ' . $newterm2;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
@@ -270,9 +270,9 @@ class PagePreviewTest extends NodeTestBase {
// Check that editing an existing node after it has been previewed and not
// saved doesn't remember the previous changes.
- $edit = array(
+ $edit = [
$title_key => $this->randomMachineName(8),
- );
+ ];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
$this->assertText($edit[$title_key], 'New title displayed.');
$this->clickLink(t('Back to content editing'));
@@ -289,7 +289,7 @@ class PagePreviewTest extends NodeTestBase {
$node_type->save();
$this->drupalGet('node/add/page');
$this->assertNoRaw('edit-submit');
- $this->drupalPostForm('node/add/page', array($title_key => 'Preview'), t('Preview'));
+ $this->drupalPostForm('node/add/page', [$title_key => 'Preview'], t('Preview'));
$this->clickLink(t('Back to content editing'));
$this->assertRaw('edit-submit');
@@ -348,8 +348,8 @@ class PagePreviewTest extends NodeTestBase {
$this->assertText('Basic page ' . $title . ' has been created.');
$node = $this->drupalGetNodeByTitle($title);
$this->drupalGet('node/' . $node->id() . '/edit');
- $this->drupalPostAjaxForm(NULL, [], array('field_test_multi_add_more' => t('Add another item')));
- $this->drupalPostAjaxForm(NULL, [], array('field_test_multi_add_more' => t('Add another item')));
+ $this->drupalPostAjaxForm(NULL, [], ['field_test_multi_add_more' => t('Add another item')]);
+ $this->drupalPostAjaxForm(NULL, [], ['field_test_multi_add_more' => t('Add another item')]);
$edit = [
'field_test_multi[1][value]' => $example_text_2,
'field_test_multi[2][value]' => $example_text_3,
@@ -404,7 +404,7 @@ class PagePreviewTest extends NodeTestBase {
$node_type->save();
// Fill in node creation form and preview node.
- $edit = array();
+ $edit = [];
$edit[$title_key] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
$edit[$term_key] = $this->term->id();
@@ -412,7 +412,7 @@ class PagePreviewTest extends NodeTestBase {
$this->drupalPostForm('node/add/page', $edit, t('Preview'));
// Check that the preview is displaying the title, body and term.
- $this->assertTitle(t('@title | Drupal', array('@title' => $edit[$title_key])), 'Basic page title is preview.');
+ $this->assertTitle(t('@title | Drupal', ['@title' => $edit[$title_key]]), 'Basic page title is preview.');
$this->assertText($edit[$title_key], 'Title displayed.');
$this->assertText($edit[$body_key], 'Body displayed.');
$this->assertText($edit[$term_key], 'Term displayed.');
@@ -450,18 +450,18 @@ class PagePreviewTest extends NodeTestBase {
*/
public function testSimultaneousPreview() {
$title_key = 'title[0][value]';
- $node = $this->drupalCreateNode(array());
+ $node = $this->drupalCreateNode([]);
- $edit = array($title_key => 'New page title');
+ $edit = [$title_key => 'New page title'];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
$this->assertText($edit[$title_key]);
- $user2 = $this->drupalCreateUser(array('edit any page content'));
+ $user2 = $this->drupalCreateUser(['edit any page content']);
$this->drupalLogin($user2);
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertFieldByName($title_key, $node->label(), 'No title leaked from previous user.');
- $edit2 = array($title_key => 'Another page title');
+ $edit2 = [$title_key => 'Another page title'];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit2, t('Preview'));
$this->assertUrl(\Drupal::url('entity.node.preview', ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'], ['absolute' => TRUE]));
$this->assertText($edit2[$title_key]);
diff --git a/core/modules/node/src/Tests/SummaryLengthTest.php b/core/modules/node/src/Tests/SummaryLengthTest.php
index 35eb0ddd44e..e953882e41b 100644
--- a/core/modules/node/src/Tests/SummaryLengthTest.php
+++ b/core/modules/node/src/Tests/SummaryLengthTest.php
@@ -18,10 +18,10 @@ class SummaryLengthTest extends NodeTestBase {
$renderer = $this->container->get('renderer');
// Create a node to view.
- $settings = array(
- 'body' => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.')),
+ $settings = [
+ 'body' => [['value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.']],
'promote' => 1,
- );
+ ];
$node = $this->drupalCreateNode($settings);
$this->assertTrue(Node::load($node->id()), 'Node created.');
diff --git a/core/modules/node/src/Tests/Views/BulkFormAccessTest.php b/core/modules/node/src/Tests/Views/BulkFormAccessTest.php
index 6dada72cf74..938e456ce55 100644
--- a/core/modules/node/src/Tests/Views/BulkFormAccessTest.php
+++ b/core/modules/node/src/Tests/Views/BulkFormAccessTest.php
@@ -22,14 +22,14 @@ class BulkFormAccessTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_test_views', 'node_access_test');
+ public static $modules = ['node_test_views', 'node_access_test'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_node_bulk_form');
+ public static $testViews = ['test_node_bulk_form'];
/**
* The node access control handler.
@@ -45,7 +45,7 @@ class BulkFormAccessTest extends NodeTestBase {
parent::setUp();
// Create Article node type.
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
$this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node');
@@ -65,15 +65,15 @@ class BulkFormAccessTest extends NodeTestBase {
// Create an account who will be the author of a private node.
$author = $this->drupalCreateUser();
// Create a private node (author may view, edit and delete, others may not).
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'type' => 'article',
- 'private' => array(array(
+ 'private' => [[
'value' => TRUE,
- )),
+ ]],
'uid' => $author->id(),
- ));
+ ]);
// Create an account that may view the private node, but not edit it.
- $account = $this->drupalCreateUser(array('node test view'));
+ $account = $this->drupalCreateUser(['node test view']);
$this->drupalLogin($account);
// Ensure the node is published.
@@ -83,10 +83,10 @@ class BulkFormAccessTest extends NodeTestBase {
$this->assertEqual(FALSE, $this->accessHandler->access($node, 'update', $account), 'The node may not be edited.');
// Test editing the node using the bulk form.
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_unpublish_action',
- );
+ ];
$this->drupalPostForm('test-node-bulk-form', $edit, t('Apply to selected items'));
$this->assertRaw(SafeMarkup::format('No access to execute %action on the @entity_type_label %entity_label.', [
'%action' => 'Unpublish content',
@@ -100,7 +100,7 @@ class BulkFormAccessTest extends NodeTestBase {
// Create an account that may view the private node, but can update the
// status.
- $account = $this->drupalCreateUser(array('administer nodes', 'node test view'));
+ $account = $this->drupalCreateUser(['administer nodes', 'node test view']);
$this->drupalLogin($account);
// Ensure the node is published.
@@ -111,10 +111,10 @@ class BulkFormAccessTest extends NodeTestBase {
$this->assertEqual(TRUE, $node->status->access('edit', $account), 'The node status can be edited.');
// Test editing the node using the bulk form.
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_unpublish_action',
- );
+ ];
$this->drupalPostForm('test-node-bulk-form', $edit, t('Apply to selected items'));
// Test that the action message isn't shown.
$this->assertNoRaw(SafeMarkup::format('%action was applied to 1 item.', [
@@ -132,25 +132,25 @@ class BulkFormAccessTest extends NodeTestBase {
// Create an account who will be the author of a private node.
$author = $this->drupalCreateUser();
// Create a private node (author may view, edit and delete, others may not).
- $private_node = $this->drupalCreateNode(array(
+ $private_node = $this->drupalCreateNode([
'type' => 'article',
- 'private' => array(array(
+ 'private' => [[
'value' => TRUE,
- )),
+ ]],
'uid' => $author->id(),
- ));
+ ]);
// Create an account that may view the private node, but not delete it.
- $account = $this->drupalCreateUser(array('access content', 'administer nodes', 'delete own article content', 'node test view'));
+ $account = $this->drupalCreateUser(['access content', 'administer nodes', 'delete own article content', 'node test view']);
// Create a node that may be deleted too, to ensure the delete confirmation
// page is shown later. In node_access_test.module, nodes may only be
// deleted by the author.
- $own_node = $this->drupalCreateNode(array(
+ $own_node = $this->drupalCreateNode([
'type' => 'article',
- 'private' => array(array(
+ 'private' => [[
'value' => TRUE,
- )),
+ ]],
'uid' => $account->id(),
- ));
+ ]);
$this->drupalLogin($account);
// Ensure that the private node can not be deleted.
@@ -159,13 +159,13 @@ class BulkFormAccessTest extends NodeTestBase {
$this->assertEqual(TRUE, $this->accessHandler->access($own_node, 'delete', $account), 'The own node may be deleted.');
// Try to delete the node using the bulk form.
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'node_bulk_form[1]' => TRUE,
'action' => 'node_delete_action',
- );
+ ];
$this->drupalPostForm('test-node-bulk-form', $edit, t('Apply to selected items'));
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
// Ensure the private node still exists.
$private_node = Node::load($private_node->id());
$this->assertNotNull($private_node, 'The private node has not been deleted.');
diff --git a/core/modules/node/src/Tests/Views/BulkFormTest.php b/core/modules/node/src/Tests/Views/BulkFormTest.php
index 677c9d83a1b..2e7b6ff4281 100644
--- a/core/modules/node/src/Tests/Views/BulkFormTest.php
+++ b/core/modules/node/src/Tests/Views/BulkFormTest.php
@@ -19,14 +19,14 @@ class BulkFormTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_test_views', 'language');
+ public static $modules = ['node_test_views', 'language'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_node_bulk_form');
+ public static $testViews = ['test_node_bulk_form'];
/**
* The test nodes.
@@ -86,7 +86,7 @@ class BulkFormTest extends NodeTestBase {
$this->assertEqual(count($view->result), 10, 'All created translations are selected.');
// Check the operations are accessible to the logged in user.
- $this->drupalLogin($this->drupalCreateUser(array('administer nodes', 'access content overview', 'bypass node access')));
+ $this->drupalLogin($this->drupalCreateUser(['administer nodes', 'access content overview', 'bypass node access']));
$this->drupalGet('test-node-bulk-form');
$elements = $this->xpath('//select[@id="edit-action"]//option');
$this->assertIdentical(count($elements), 8, 'All node operations are found.');
@@ -101,10 +101,10 @@ class BulkFormTest extends NodeTestBase {
$this->assertTrue($node->isPublished(), 'Node is initially published');
$this->assertTrue($node->getTranslation('en-gb')->isPublished(), 'Node translation is published');
$this->assertTrue($node->getTranslation('it')->isPublished(), 'Node translation is published');
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_unpublish_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$node = $this->loadNode($node->id());
$this->assertFalse($node->isPublished(), 'Node has been unpublished');
@@ -112,10 +112,10 @@ class BulkFormTest extends NodeTestBase {
$this->assertTrue($node->getTranslation('it')->isPublished(), 'Node translation has not been unpublished');
// Publish action.
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_publish_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$node = $this->loadNode($node->id());
$this->assertTrue($node->isPublished(), 'Node has been published again');
@@ -124,10 +124,10 @@ class BulkFormTest extends NodeTestBase {
$this->assertFalse($node->isSticky(), 'Node is not sticky');
$this->assertFalse($node->getTranslation('en-gb')->isSticky(), 'Node translation is not sticky');
$this->assertFalse($node->getTranslation('it')->isSticky(), 'Node translation is not sticky');
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_make_sticky_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$node = $this->loadNode($node->id());
$this->assertTrue($node->isSticky(), 'Node has been made sticky');
@@ -135,10 +135,10 @@ class BulkFormTest extends NodeTestBase {
$this->assertFalse($node->getTranslation('it')->isSticky(), 'Node translation has not been made sticky');
// Make unsticky action.
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_make_unsticky_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$node = $this->loadNode($node->id());
$this->assertFalse($node->isSticky(), 'Node is not sticky anymore');
@@ -147,10 +147,10 @@ class BulkFormTest extends NodeTestBase {
$this->assertFalse($node->isPromoted(), 'Node is not promoted to the front page');
$this->assertFalse($node->getTranslation('en-gb')->isPromoted(), 'Node translation is not promoted to the front page');
$this->assertFalse($node->getTranslation('it')->isPromoted(), 'Node translation is not promoted to the front page');
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_promote_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$node = $this->loadNode($node->id());
$this->assertTrue($node->isPromoted(), 'Node has been promoted to the front page');
@@ -158,17 +158,17 @@ class BulkFormTest extends NodeTestBase {
$this->assertFalse($node->getTranslation('it')->isPromoted(), 'Node translation has not been promoted to the front page');
// Demote from front page.
- $edit = array(
+ $edit = [
'node_bulk_form[0]' => TRUE,
'action' => 'node_unpromote_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$node = $this->loadNode($node->id());
$this->assertFalse($node->isPromoted(), 'Node has been demoted');
// Select a bunch of translated and untranslated nodes and check that
// operations are always applied to individual translations.
- $edit = array(
+ $edit = [
// Original and all translations.
'node_bulk_form[0]' => TRUE, // Node 1, English, original.
'node_bulk_form[1]' => TRUE, // Node 1, British English.
@@ -184,7 +184,7 @@ class BulkFormTest extends NodeTestBase {
'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
'action' => 'node_unpublish_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$node = $this->loadNode(1);
$this->assertFalse($node->getTranslation('en')->isPublished(), '1: English translation has been unpublished');
@@ -209,7 +209,7 @@ class BulkFormTest extends NodeTestBase {
public function testBulkDeletion() {
// Select a bunch of translated and untranslated nodes and check that
// nodes and individual translations are properly deleted.
- $edit = array(
+ $edit = [
// Original and all translations.
'node_bulk_form[0]' => TRUE, // Node 1, English, original.
'node_bulk_form[1]' => TRUE, // Node 1, British English.
@@ -225,7 +225,7 @@ class BulkFormTest extends NodeTestBase {
'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
'action' => 'node_delete_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$label = $this->loadNode(1)->label();
@@ -239,7 +239,7 @@ class BulkFormTest extends NodeTestBase {
$this->assertText($label);
$this->assertNoText("$label (Original translation) - The following content translations will be deleted:");
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$node = $this->loadNode(1);
$this->assertNull($node, '1: Node has been deleted');
diff --git a/core/modules/node/src/Tests/Views/FilterUidRevisionTest.php b/core/modules/node/src/Tests/Views/FilterUidRevisionTest.php
index 017d5eb3969..18273003ae9 100644
--- a/core/modules/node/src/Tests/Views/FilterUidRevisionTest.php
+++ b/core/modules/node/src/Tests/Views/FilterUidRevisionTest.php
@@ -16,7 +16,7 @@ class FilterUidRevisionTest extends NodeTestBase {
*
* @var array
*/
- public static $testViews = array('test_filter_node_uid_revision');
+ public static $testViews = ['test_filter_node_uid_revision'];
/**
* Tests the node_uid_revision filter.
@@ -25,14 +25,14 @@ class FilterUidRevisionTest extends NodeTestBase {
$author = $this->drupalCreateUser();
$no_author = $this->drupalCreateUser();
- $expected_result = array();
+ $expected_result = [];
// Create one node, with the author as the node author.
- $node = $this->drupalCreateNode(array('uid' => $author->id()));
- $expected_result[] = array('nid' => $node->id());
+ $node = $this->drupalCreateNode(['uid' => $author->id()]);
+ $expected_result[] = ['nid' => $node->id()];
// Create one node of which an additional revision author will be the
// author.
- $node = $this->drupalCreateNode(array('revision_uid' => $no_author->id()));
- $expected_result[] = array('nid' => $node->id());
+ $node = $this->drupalCreateNode(['revision_uid' => $no_author->id()]);
+ $expected_result[] = ['nid' => $node->id()];
$revision = clone $node;
// Force to add a new revision.
$revision->set('vid', NULL);
@@ -41,14 +41,14 @@ class FilterUidRevisionTest extends NodeTestBase {
// Create one node on which the author has neither authorship of revisions
// or the main node.
- $this->drupalCreateNode(array('uid' => $no_author->id()));
+ $this->drupalCreateNode(['uid' => $no_author->id()]);
$view = Views::getView('test_filter_node_uid_revision');
$view->initHandlers();
- $view->filter['uid_revision']->value = array($author->id());
+ $view->filter['uid_revision']->value = [$author->id()];
$this->executeView($view);
- $this->assertIdenticalResultset($view, $expected_result, array('nid' => 'nid'), 'Make sure that the view only returns nodes which match either the node or the revision author.');
+ $this->assertIdenticalResultset($view, $expected_result, ['nid' => 'nid'], 'Make sure that the view only returns nodes which match either the node or the revision author.');
}
}
diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/src/Tests/Views/FrontPageTest.php
index 19cb659da24..1c6003a740c 100644
--- a/core/modules/node/src/Tests/Views/FrontPageTest.php
+++ b/core/modules/node/src/Tests/Views/FrontPageTest.php
@@ -37,7 +37,7 @@ class FrontPageTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'contextual');
+ public static $modules = ['node', 'contextual'];
protected function setUp() {
parent::setUp();
@@ -74,14 +74,14 @@ class FrontPageTest extends ViewTestBase {
$this->executeView($view);
$view->preview();
- $this->assertEqual($view->getTitle(), format_string('Welcome to @site_name', array('@site_name' => $site_name)), 'The welcome title is used for the empty view.');
+ $this->assertEqual($view->getTitle(), format_string('Welcome to @site_name', ['@site_name' => $site_name]), 'The welcome title is used for the empty view.');
$view->destroy();
// Create some nodes on the frontpage view. Add more than 10 nodes in order
// to enable paging.
- $expected = array();
+ $expected = [];
for ($i = 0; $i < 20; $i++) {
- $values = array();
+ $values = [];
$values['type'] = 'article';
$values['title'] = $this->randomMachineName();
$values['promote'] = TRUE;
@@ -94,21 +94,21 @@ class FrontPageTest extends ViewTestBase {
$node = $this->nodeStorage->create($values);
$node->save();
// Put the sticky on at the front.
- array_unshift($expected, array('nid' => $node->id()));
+ array_unshift($expected, ['nid' => $node->id()]);
}
else {
$values['sticky'] = FALSE;
$node = $this->nodeStorage->create($values);
$node->save();
- array_push($expected, array('nid' => $node->id()));
+ array_push($expected, ['nid' => $node->id()]);
}
}
// Create some nodes which aren't on the frontpage, either because they
// aren't promoted or because they aren't published.
- $not_expected_nids = array();
+ $not_expected_nids = [];
- $values = array();
+ $values = [];
$values['type'] = 'article';
$values['title'] = $this->randomMachineName();
$values['status'] = TRUE;
@@ -132,7 +132,7 @@ class FrontPageTest extends ViewTestBase {
$node->save();
$not_expected_nids[] = $node->id();
- $column_map = array('nid' => 'nid');
+ $column_map = ['nid' => 'nid'];
$view->setDisplay('page_1');
$this->executeView($view);
@@ -171,7 +171,7 @@ class FrontPageTest extends ViewTestBase {
public function testAdminFrontPage() {
// When a user with sufficient permissions is logged in, views_ui adds
// contextual links to the homepage view. This verifies there are no errors.
- \Drupal::service('module_installer')->install(array('views_ui'));
+ \Drupal::service('module_installer')->install(['views_ui']);
// Log in root user with sufficient permissions.
$this->drupalLogin($this->rootUser);
// Test frontpage view.
diff --git a/core/modules/node/src/Tests/Views/NodeContextualLinksTest.php b/core/modules/node/src/Tests/Views/NodeContextualLinksTest.php
index acd7d7b91a3..dc23d0ce55f 100644
--- a/core/modules/node/src/Tests/Views/NodeContextualLinksTest.php
+++ b/core/modules/node/src/Tests/Views/NodeContextualLinksTest.php
@@ -17,27 +17,27 @@ class NodeContextualLinksTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('contextual');
+ public static $modules = ['contextual'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_contextual_links');
+ public static $testViews = ['test_contextual_links'];
/**
* Tests contextual links.
*/
public function testNodeContextualLinks() {
- $this->drupalCreateContentType(array('type' => 'page'));
- $this->drupalCreateNode(array('promote' => 1));
+ $this->drupalCreateContentType(['type' => 'page']);
+ $this->drupalCreateNode(['promote' => 1]);
$this->drupalGet('node');
- $user = $this->drupalCreateUser(array('administer nodes', 'access contextual links'));
+ $user = $this->drupalCreateUser(['administer nodes', 'access contextual links']);
$this->drupalLogin($user);
- $response = $this->renderContextualLinks(array('node:node=1:'), 'node');
+ $response = $this->renderContextualLinks(['node:node=1:'], 'node');
$this->assertResponse(200);
$json = Json::decode($response);
$this->setRawContent($json['node:node=1:']);
@@ -63,7 +63,7 @@ class NodeContextualLinksTest extends NodeTestBase {
*/
protected function renderContextualLinks($ids, $current_path) {
// Build POST values.
- $post = array();
+ $post = [];
for ($i = 0; $i < count($ids); $i++) {
$post['ids[' . $i . ']'] = $ids[$i];
}
@@ -78,15 +78,15 @@ class NodeContextualLinksTest extends NodeTestBase {
$post = implode('&', $post);
// Perform HTTP request.
- return $this->curlExec(array(
- CURLOPT_URL => \Drupal::url('contextual.render', [], ['absolute' => TRUE, 'query' => array('destination' => $current_path)]),
+ return $this->curlExec([
+ CURLOPT_URL => \Drupal::url('contextual.render', [], ['absolute' => TRUE, 'query' => ['destination' => $current_path]]),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $post,
- CURLOPT_HTTPHEADER => array(
+ CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
- ),
- ));
+ ],
+ ]);
}
/**
@@ -108,8 +108,8 @@ class NodeContextualLinksTest extends NodeTestBase {
$admin_user->pass_raw = 'new_password';
$admin_user->save();
- $this->drupalCreateContentType(array('type' => 'page'));
- $this->drupalCreateNode(array('promote' => 1));
+ $this->drupalCreateContentType(['type' => 'page']);
+ $this->drupalCreateNode(['promote' => 1]);
$this->drupalLogin($admin_user);
$this->drupalGet('node');
diff --git a/core/modules/node/src/Tests/Views/NodeFieldFilterTest.php b/core/modules/node/src/Tests/Views/NodeFieldFilterTest.php
index 6b6d5e246ef..048c7a905ee 100644
--- a/core/modules/node/src/Tests/Views/NodeFieldFilterTest.php
+++ b/core/modules/node/src/Tests/Views/NodeFieldFilterTest.php
@@ -14,14 +14,14 @@ class NodeFieldFilterTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_field_filters');
+ public static $testViews = ['test_field_filters'];
/**
* List of node titles by language.
@@ -35,7 +35,7 @@ class NodeFieldFilterTest extends NodeTestBase {
// Create Page content type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
}
// Add two new languages.
@@ -43,15 +43,15 @@ class NodeFieldFilterTest extends NodeTestBase {
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up node titles.
- $this->nodeTitles = array(
+ $this->nodeTitles = [
'en' => 'Food in Paris',
'es' => 'Comida en Paris',
'fr' => 'Nouriture en Paris',
- );
+ ];
// Create node with translations.
$node = $this->drupalCreateNode(['title' => $this->nodeTitles['en'], 'langcode' => 'en', 'type' => 'page', 'body' => [['value' => $this->nodeTitles['en']]]]);
- foreach (array('es', 'fr') as $langcode) {
+ foreach (['es', 'fr'] as $langcode) {
$translation = $node->addTranslation($langcode, ['title' => $this->nodeTitles[$langcode]]);
$translation->body->value = $this->nodeTitles[$langcode];
}
@@ -64,19 +64,19 @@ class NodeFieldFilterTest extends NodeTestBase {
public function testFilters() {
// Test the title filter page, which filters for title contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-title-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida title filter');
+ $this->assertPageCounts('test-title-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida title filter');
// Test the body filter page, which filters for body contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-body-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida body filter');
+ $this->assertPageCounts('test-body-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida body filter');
// Test the title Paris filter page, which filters for title contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-title-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris title filter');
+ $this->assertPageCounts('test-title-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris title filter');
// Test the body Paris filter page, which filters for body contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-body-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris body filter');
+ $this->assertPageCounts('test-body-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris body filter');
}
/**
diff --git a/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php b/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php
index 9c124467a23..a5b1910130d 100644
--- a/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php
+++ b/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php
@@ -17,7 +17,7 @@ class NodeFieldTokensTest extends NodeTestBase {
*
* @var array
*/
- public static $testViews = array('test_node_tokens');
+ public static $testViews = ['test_node_tokens'];
/**
* Tests token replacement for Views tokens supplied by the Node module.
diff --git a/core/modules/node/src/Tests/Views/NodeIntegrationTest.php b/core/modules/node/src/Tests/Views/NodeIntegrationTest.php
index 26909af8408..c6791381996 100644
--- a/core/modules/node/src/Tests/Views/NodeIntegrationTest.php
+++ b/core/modules/node/src/Tests/Views/NodeIntegrationTest.php
@@ -14,22 +14,22 @@ class NodeIntegrationTest extends NodeTestBase {
*
* @var array
*/
- public static $testViews = array('test_node_view');
+ public static $testViews = ['test_node_view'];
/**
* Tests basic node view with a node type argument.
*/
public function testNodeViewTypeArgument() {
// Create two content types with three nodes each.
- $types = array();
- $all_nids = array();
+ $types = [];
+ $all_nids = [];
for ($i = 0; $i < 2; $i++) {
$type = $this->drupalCreateContentType(['name' => '<em>' . $this->randomMachineName() . '</em>']);
$types[] = $type;
for ($j = 0; $j < 5; $j++) {
// Ensure the right order of the nodes.
- $node = $this->drupalCreateNode(array('type' => $type->id(), 'created' => REQUEST_TIME - ($i * 5 + $j)));
+ $node = $this->drupalCreateNode(['type' => $type->id(), 'created' => REQUEST_TIME - ($i * 5 + $j)]);
$nodes[$type->id()][$node->id()] = $node;
$all_nids[] = $node->id();
}
@@ -55,9 +55,9 @@ class NodeIntegrationTest extends NodeTestBase {
* @param array $expected_nids
* An array of node IDs.
*/
- protected function assertNids(array $expected_nids = array()) {
+ protected function assertNids(array $expected_nids = []) {
$result = $this->xpath('//span[@class="field-content"]');
- $nids = array();
+ $nids = [];
foreach ($result as $element) {
$nids[] = (int) $element;
}
diff --git a/core/modules/node/src/Tests/Views/NodeLanguageTest.php b/core/modules/node/src/Tests/Views/NodeLanguageTest.php
index 4561508e57f..bdd26c0caf6 100644
--- a/core/modules/node/src/Tests/Views/NodeLanguageTest.php
+++ b/core/modules/node/src/Tests/Views/NodeLanguageTest.php
@@ -19,14 +19,14 @@ class NodeLanguageTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language', 'node_test_views');
+ public static $modules = ['language', 'node_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_language');
+ public static $testViews = ['test_language'];
/**
* List of node titles by language.
@@ -43,8 +43,8 @@ class NodeLanguageTest extends NodeTestBase {
// Create Page content type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- ViewTestData::createTestViews(get_class($this), array('node_test_views'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
// Add two new languages.
@@ -60,30 +60,30 @@ class NodeLanguageTest extends NodeTestBase {
// Set up node titles. They should not include the words "French",
// "English", or "Spanish", as there is a language field in the view
// that prints out those words.
- $this->nodeTitles = array(
- LanguageInterface::LANGCODE_NOT_SPECIFIED => array(
+ $this->nodeTitles = [
+ LanguageInterface::LANGCODE_NOT_SPECIFIED => [
'First node und',
- ),
- 'es' => array(
+ ],
+ 'es' => [
'Primero nodo es',
'Segundo nodo es',
'Tercera nodo es',
- ),
- 'en' => array(
+ ],
+ 'en' => [
'First node en',
'Second node en',
- ),
- 'fr' => array(
+ ],
+ 'fr' => [
'Premier nœud fr',
- )
- );
+ ]
+ ];
// Create nodes with translations.
foreach ($this->nodeTitles['es'] as $index => $title) {
- $node = $this->drupalCreateNode(array('title' => $title, 'langcode' => 'es', 'type' => 'page', 'promote' => 1));
- foreach (array('en', 'fr') as $langcode) {
+ $node = $this->drupalCreateNode(['title' => $title, 'langcode' => 'es', 'type' => 'page', 'promote' => 1]);
+ foreach (['en', 'fr'] as $langcode) {
if (isset($this->nodeTitles[$langcode][$index])) {
- $translation = $node->addTranslation($langcode, array('title' => $this->nodeTitles[$langcode][$index]));
+ $translation = $node->addTranslation($langcode, ['title' => $this->nodeTitles[$langcode][$index]]);
$translation->body->value = $this->randomMachineName(32);
}
}
@@ -91,14 +91,14 @@ class NodeLanguageTest extends NodeTestBase {
}
// Create non-translatable nodes.
foreach ($this->nodeTitles[LanguageInterface::LANGCODE_NOT_SPECIFIED] as $index => $title) {
- $node = $this->drupalCreateNode(array('title' => $title, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'type' => 'page', 'promote' => 1));
+ $node = $this->drupalCreateNode(['title' => $title, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'type' => 'page', 'promote' => 1]);
$node->body->value = $this->randomMachineName(32);
$node->save();
}
$this->container->get('router.builder')->rebuild();
- $user = $this->drupalCreateUser(array('access content overview', 'access content'));
+ $user = $this->drupalCreateUser(['access content overview', 'access content']);
$this->drupalLogin($user);
}
@@ -178,7 +178,7 @@ class NodeLanguageTest extends NodeTestBase {
}
// When filtered, only the specific languages should show.
foreach ($this->nodeTitles as $langcode => $titles) {
- $this->drupalGet('admin/content', array('query' => array('langcode' => $langcode)));
+ $this->drupalGet('admin/content', ['query' => ['langcode' => $langcode]]);
foreach ($titles as $title) {
$this->assertText($title);
}
@@ -195,7 +195,7 @@ class NodeLanguageTest extends NodeTestBase {
// filter is set to the site default language instead. This should just
// show the English nodes, no matter what the content language is.
$config = $this->config('views.view.frontpage');
- $config->set('display.default.display_options.filters.langcode.value', array(PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT));
+ $config->set('display.default.display_options.filters.langcode.value', [PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT]);
$config->save();
foreach ($this->nodeTitles as $langcode => $titles) {
if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) {
@@ -219,10 +219,10 @@ class NodeLanguageTest extends NodeTestBase {
//
// IMPORTANT: Make sure this part of the test is last -- it is changing
// language configuration!
- $config->set('display.default.display_options.filters.langcode.value', array('***LANGUAGE_language_interface***' => '***LANGUAGE_language_interface***'));
+ $config->set('display.default.display_options.filters.langcode.value', ['***LANGUAGE_language_interface***' => '***LANGUAGE_language_interface***']);
$config->save();
$language_config = $this->config('language.types');
- $language_config->set('negotiation.language_interface.enabled', array('language-selected' => 1));
+ $language_config->set('negotiation.language_interface.enabled', ['language-selected' => 1]);
$language_config->save();
$language_config = $this->config('language.negotiation');
$language_config->set('selected_langcode', 'es');
diff --git a/core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php b/core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php
index 109cdc4dd28..6a774f33f72 100644
--- a/core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php
+++ b/core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php
@@ -17,11 +17,11 @@ class NodeRevisionWizardTest extends WizardTestBase {
* Tests creating a node revision view.
*/
public function testViewAdd() {
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
// Create two nodes with two revision.
$node_storage = \Drupal::entityManager()->getStorage('node');
/** @var \Drupal\node\NodeInterface $node */
- $node = $node_storage->create(array('title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 40));
+ $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 40]);
$node->save();
$node = $node->createDuplicate();
@@ -29,7 +29,7 @@ class NodeRevisionWizardTest extends WizardTestBase {
$node->created->value = REQUEST_TIME + 20;
$node->save();
- $node = $node_storage->create(array('title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 30));
+ $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 30]);
$node->save();
$node = $node->createDuplicate();
@@ -37,7 +37,7 @@ class NodeRevisionWizardTest extends WizardTestBase {
$node->created->value = REQUEST_TIME + 10;
$node->save();
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['description'] = $this->randomMachineName(16);
@@ -54,8 +54,8 @@ class NodeRevisionWizardTest extends WizardTestBase {
$executable = Views::executableFactory()->get($view);
$this->executeView($executable);
- $this->assertIdenticalResultset($executable, array(array('vid' => 1), array('vid' => 3), array('vid' => 2), array('vid' => 4)),
- array('vid' => 'vid'));
+ $this->assertIdenticalResultset($executable, [['vid' => 1], ['vid' => 3], ['vid' => 2], ['vid' => 4]],
+ ['vid' => 'vid']);
}
}
diff --git a/core/modules/node/src/Tests/Views/NodeTestBase.php b/core/modules/node/src/Tests/Views/NodeTestBase.php
index 6701b417d2e..661ad91ba80 100644
--- a/core/modules/node/src/Tests/Views/NodeTestBase.php
+++ b/core/modules/node/src/Tests/Views/NodeTestBase.php
@@ -15,13 +15,13 @@ abstract class NodeTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node_test_views');
+ public static $modules = ['node_test_views'];
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
if ($import_test_views) {
- ViewTestData::createTestViews(get_class($this), array('node_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
}
diff --git a/core/modules/node/src/Tests/Views/PathPluginTest.php b/core/modules/node/src/Tests/Views/PathPluginTest.php
index 1ee6272d34e..6558f00da9f 100644
--- a/core/modules/node/src/Tests/Views/PathPluginTest.php
+++ b/core/modules/node/src/Tests/Views/PathPluginTest.php
@@ -16,14 +16,14 @@ class PathPluginTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_node_path_plugin');
+ public static $testViews = ['test_node_path_plugin'];
/**
* Contains all nodes used by this test.
@@ -35,21 +35,21 @@ class PathPluginTest extends NodeTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
// Create two nodes.
for ($i = 0; $i < 2; $i++) {
$this->nodes[] = $this->drupalCreateNode(
- array(
+ [
'type' => 'article',
- 'body' => array(
- array(
+ 'body' => [
+ [
'value' => $this->randomMachineName(42),
'format' => filter_default_format(),
'summary' => $this->randomMachineName(),
- ),
- ),
- )
+ ],
+ ],
+ ]
);
}
}
diff --git a/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php b/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php
index f4b34f169dc..51e200c020e 100644
--- a/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php
+++ b/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php
@@ -18,12 +18,12 @@ class RevisionRelationshipsTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node' , 'node_test_views');
+ public static $modules = ['node' , 'node_test_views'];
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('node_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
/**
@@ -31,7 +31,7 @@ class RevisionRelationshipsTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_node_revision_nid', 'test_node_revision_vid');
+ public static $testViews = ['test_node_revision_nid', 'test_node_revision_vid'];
/**
* Create a node with revision and rest result count for both views.
@@ -42,40 +42,40 @@ class RevisionRelationshipsTest extends ViewTestBase {
$node_revision = clone $node;
$node_revision->setNewRevision();
$node_revision->save();
- $column_map = array(
+ $column_map = [
'vid' => 'vid',
'node_field_data_node_field_revision_nid' => 'node_node_revision_nid',
'nid_1' => 'nid_1',
- );
+ ];
// Here should be two rows.
$view_nid = Views::getView('test_node_revision_nid');
- $this->executeView($view_nid, array($node->id()));
- $resultset_nid = array(
- array(
+ $this->executeView($view_nid, [$node->id()]);
+ $resultset_nid = [
+ [
'vid' => '1',
'node_node_revision_nid' => '1',
'nid_1' => '1',
- ),
- array(
+ ],
+ [
'vid' => '2',
'node_revision_nid' => '1',
'node_node_revision_nid' => '1',
'nid_1' => '1',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map);
// There should be only one row with active revision 2.
$view_vid = Views::getView('test_node_revision_vid');
- $this->executeView($view_vid, array($node->id()));
- $resultset_vid = array(
- array(
+ $this->executeView($view_vid, [$node->id()]);
+ $resultset_vid = [
+ [
'vid' => '2',
'node_node_revision_nid' => '1',
'nid_1' => '1',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view_vid, $resultset_vid, $column_map);
}
diff --git a/core/modules/node/src/Tests/Views/RowPluginTest.php b/core/modules/node/src/Tests/Views/RowPluginTest.php
index d13e526eeb8..160640fd233 100644
--- a/core/modules/node/src/Tests/Views/RowPluginTest.php
+++ b/core/modules/node/src/Tests/Views/RowPluginTest.php
@@ -17,14 +17,14 @@ class RowPluginTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_node_row_plugin');
+ public static $testViews = ['test_node_row_plugin'];
/**
* Contains all nodes used by this test.
@@ -36,21 +36,21 @@ class RowPluginTest extends NodeTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
// Create two nodes.
for ($i = 0; $i < 2; $i++) {
$this->nodes[] = $this->drupalCreateNode(
- array(
+ [
'type' => 'article',
- 'body' => array(
- array(
+ 'body' => [
+ [
'value' => $this->randomMachineName(42),
'format' => filter_default_format(),
'summary' => $this->randomMachineName(),
- ),
- ),
- )
+ ],
+ ],
+ ]
);
}
}
diff --git a/core/modules/node/src/Tests/Views/StatusExtraTest.php b/core/modules/node/src/Tests/Views/StatusExtraTest.php
index d8ae016eee2..9e41f5beca0 100644
--- a/core/modules/node/src/Tests/Views/StatusExtraTest.php
+++ b/core/modules/node/src/Tests/Views/StatusExtraTest.php
@@ -17,19 +17,19 @@ class StatusExtraTest extends NodeTestBase {
*
* @var array
*/
- public static $testViews = array('test_status_extra');
+ public static $testViews = ['test_status_extra'];
/**
* Tests the status extra filter.
*/
public function testStatusExtra() {
- $node_author = $this->drupalCreateUser(array('view own unpublished content'));
+ $node_author = $this->drupalCreateUser(['view own unpublished content']);
$node_author_not_unpublished = $this->drupalCreateUser();
$normal_user = $this->drupalCreateUser();
- $admin_user = $this->drupalCreateUser(array('bypass node access'));
+ $admin_user = $this->drupalCreateUser(['bypass node access']);
// Create one published and one unpublished node by the admin.
- $node_published = $this->drupalCreateNode(array('uid' => $admin_user->id()));
+ $node_published = $this->drupalCreateNode(['uid' => $admin_user->id()]);
$node_unpublished = $this->drupalCreateNode(['uid' => $admin_user->id(), 'status' => NodeInterface::NOT_PUBLISHED]);
// Create one unpublished node by a certain author user.
diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module
index 56b53a92bd3..40baeb53ede 100644
--- a/core/modules/node/tests/modules/node_access_test/node_access_test.module
+++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module
@@ -50,15 +50,15 @@ use Drupal\node\NodeInterface;
* @see node_access_test_node_access_records()
*/
function node_access_test_node_grants($account, $op) {
- $grants = array();
- $grants['node_access_test_author'] = array($account->id());
+ $grants = [];
+ $grants['node_access_test_author'] = [$account->id()];
if ($op == 'view' && $account->hasPermission('node test view', $account)) {
- $grants['node_access_test'] = array(8888, 8889);
+ $grants['node_access_test'] = [8888, 8889];
}
$no_access_uid = \Drupal::state()->get('node_access_test.no_access_uid') ?: 0;
if ($op == 'view' && $account->id() == $no_access_uid) {
- $grants['node_access_all'] = array(0);
+ $grants['node_access_all'] = [0];
}
return $grants;
}
@@ -77,37 +77,37 @@ function node_access_test_node_grants($account, $op) {
* @see node_access_test.permissions.yml
*/
function node_access_test_node_access_records(NodeInterface $node) {
- $grants = array();
+ $grants = [];
// For NodeAccessBaseTableTestCase, only set records for private nodes.
if (!\Drupal::state()->get('node_access_test.private') || $node->private->value) {
// Groups 8888 and 8889 for the node_access_test realm both receive a view
// grant for all controlled nodes. See node_access_test_node_grants().
- $grants[] = array(
+ $grants[] = [
'realm' => 'node_access_test',
'gid' => 8888,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
- );
- $grants[] = array(
+ ];
+ $grants[] = [
'realm' => 'node_access_test',
'gid' => 8889,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
- );
+ ];
// For the author realm, the group ID is equivalent to a user ID, which
// means there are many many groups of just 1 user.
- $grants[] = array(
+ $grants[] = [
'realm' => 'node_access_test_author',
'gid' => $node->getOwnerId(),
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 0,
- );
+ ];
}
return $grants;
@@ -120,25 +120,25 @@ function node_access_test_node_access_records(NodeInterface $node) {
* A node type entity.
*/
function node_access_test_add_field(NodeTypeInterface $type) {
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'private',
'entity_type' => 'node',
'type' => 'integer',
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_name' => 'private',
'entity_type' => 'node',
'bundle' => $type->id(),
'label' => 'Private',
- ));
+ ]);
$field->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('node', $type->id(), 'default')
- ->setComponent('private', array(
+ ->setComponent('private', [
'type' => 'number',
- ))
+ ])
->save();
}
diff --git a/core/modules/node/tests/modules/node_access_test_empty/node_access_test_empty.module b/core/modules/node/tests/modules/node_access_test_empty/node_access_test_empty.module
index 67558e6133a..d67365a40f3 100644
--- a/core/modules/node/tests/modules/node_access_test_empty/node_access_test_empty.module
+++ b/core/modules/node/tests/modules/node_access_test_empty/node_access_test_empty.module
@@ -11,12 +11,12 @@ use Drupal\node\NodeInterface;
* Implements hook_node_grants().
*/
function node_access_test_empty_node_grants($account, $op) {
- return array();
+ return [];
}
/**
* Implements hook_node_access_records().
*/
function node_access_test_empty_node_access_records(NodeInterface $node) {
- return array();
+ return [];
}
diff --git a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
index ece18d824ec..565c100e78c 100644
--- a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
+++ b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
@@ -16,7 +16,7 @@ use Drupal\node\NodeInterface;
* This module defines a single grant realm. All users belong to this group.
*/
function node_access_test_language_node_grants($account, $op) {
- $grants['node_access_language_test'] = array(7888);
+ $grants['node_access_language_test'] = [7888];
return $grants;
}
@@ -24,13 +24,13 @@ function node_access_test_language_node_grants($account, $op) {
* Implements hook_node_access_records().
*/
function node_access_test_language_node_access_records(NodeInterface $node) {
- $grants = array();
+ $grants = [];
// Create grants for each translation of the node.
foreach ($node->getTranslationLanguages() as $langcode => $language) {
// If the translation is not marked as private, grant access.
$translation = $node->getTranslation($langcode);
- $grants[] = array(
+ $grants[] = [
'realm' => 'node_access_language_test',
'gid' => 7888,
'grant_view' => empty($translation->field_private->value) ? 1 : 0,
@@ -38,7 +38,7 @@ function node_access_test_language_node_access_records(NodeInterface $node) {
'grant_delete' => 0,
'priority' => 0,
'langcode' => $langcode,
- );
+ ];
}
return $grants;
}
diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module
index 866be199c75..c852b441102 100644
--- a/core/modules/node/tests/modules/node_test/node_test.module
+++ b/core/modules/node/tests/modules/node_test/node_test.module
@@ -21,23 +21,23 @@ use Drupal\node\NodeInterface;
function node_test_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
if ($view_mode == 'rss') {
// Add RSS elements and namespaces when building the RSS feed.
- $node->rss_elements[] = array(
+ $node->rss_elements[] = [
'key' => 'testElement',
- 'value' => t('Value of testElement RSS element for node @nid.', array('@nid' => $node->id())),
- );
+ 'value' => t('Value of testElement RSS element for node @nid.', ['@nid' => $node->id()]),
+ ];
// Add content that should be displayed only in the RSS feed.
- $build['extra_feed_content'] = array(
- '#markup' => '<p>' . t('Extra data that should appear only in the RSS feed for node @nid.', array('@nid' => $node->id())) . '</p>',
+ $build['extra_feed_content'] = [
+ '#markup' => '<p>' . t('Extra data that should appear only in the RSS feed for node @nid.', ['@nid' => $node->id()]) . '</p>',
'#weight' => 10,
- );
+ ];
}
if ($view_mode != 'rss') {
// Add content that should NOT be displayed in the RSS feed.
- $build['extra_non_feed_content'] = array(
- '#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for node @nid.', array('@nid' => $node->id())) . '</p>',
- );
+ $build['extra_non_feed_content'] = [
+ '#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for node @nid.', ['@nid' => $node->id()]) . '</p>',
+ ];
}
}
@@ -57,11 +57,11 @@ function node_test_node_grants(AccountInterface $account, $op) {
// Give everyone full grants so we don't break other node tests.
// Our node access tests asserts three realms of access.
// See testGrantAlter().
- return array(
- 'test_article_realm' => array(1),
- 'test_page_realm' => array(1),
- 'test_alter_realm' => array(2),
- );
+ return [
+ 'test_article_realm' => [1],
+ 'test_page_realm' => [1],
+ 'test_alter_realm' => [2],
+ ];
}
/**
@@ -72,28 +72,28 @@ function node_test_node_access_records(NodeInterface $node) {
if (!empty($node->disable_node_access)) {
return;
}
- $grants = array();
+ $grants = [];
if ($node->getType() == 'article') {
// Create grant in arbitrary article_realm for article nodes.
- $grants[] = array(
+ $grants[] = [
'realm' => 'test_article_realm',
'gid' => 1,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
- );
+ ];
}
elseif ($node->getType() == 'page') {
// Create grant in arbitrary page_realm for page nodes.
- $grants[] = array(
+ $grants[] = [
'realm' => 'test_page_realm',
'gid' => 1,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
- );
+ ];
}
return $grants;
}
@@ -118,7 +118,7 @@ function node_test_node_access_records_alter(&$grants, NodeInterface $node) {
*/
function node_test_node_grants_alter(&$grants, AccountInterface $account, $op) {
// Return an empty array of grants to prove that we can alter by reference.
- $grants = array();
+ $grants = [];
}
/**
diff --git a/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php
index 36ac5190ee5..2712c0cbff7 100644
--- a/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php
+++ b/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php
@@ -24,17 +24,17 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
*/
function testMultiStepNodeFormBasicOptions() {
// Prepare a user to create the node.
- $web_user = $this->drupalCreateUser(array('administer nodes', 'create page content'));
+ $web_user = $this->drupalCreateUser(['administer nodes', 'create page content']);
$this->drupalLogin($web_user);
// Create an unlimited cardinality field.
$this->fieldName = Unicode::strtolower($this->randomMachineName());
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text',
'cardinality' => -1,
- ))->save();
+ ])->save();
// Attach an instance of the field to the page content type.
FieldConfig::create([
@@ -44,17 +44,17 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
'label' => $this->randomMachineName() . '_label',
])->save();
entity_get_form_display('node', 'page', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'text_textfield',
- ))
+ ])
->save();
- $edit = array(
+ $edit = [
'title[0][value]' => 'a',
'promote[value]' => FALSE,
'sticky[value]' => 1,
"{$this->fieldName}[0][value]" => $this->randomString(32),
- );
+ ];
$this->drupalPostForm('node/add/page', $edit, t('Add another item'));
$this->assertNoFieldChecked('edit-promote-value', 'Promote stayed unchecked');
$this->assertFieldChecked('edit-sticky-value', 'Sticky stayed checked');
diff --git a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
index a84b7b61dec..af14546fdc9 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
@@ -17,7 +17,7 @@ class NodeAccessFieldTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_access_test', 'field_ui');
+ public static $modules = ['node_access_test', 'field_ui'];
/**
* A user with permission to bypass access content.
@@ -46,16 +46,16 @@ class NodeAccessFieldTest extends NodeTestBase {
node_access_rebuild();
// Create some users.
- $this->adminUser = $this->drupalCreateUser(array('access content', 'bypass node access'));
- $this->contentAdminUser = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields'));
+ $this->adminUser = $this->drupalCreateUser(['access content', 'bypass node access']);
+ $this->contentAdminUser = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields']);
// Add a custom field to the page content type.
$this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name');
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text'
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
@@ -74,9 +74,9 @@ class NodeAccessFieldTest extends NodeTestBase {
*/
function testNodeAccessAdministerField() {
// Create a page node.
- $fieldData = array();
+ $fieldData = [];
$value = $fieldData[0]['value'] = $this->randomMachineName();
- $node = $this->drupalCreateNode(array($this->fieldName => $fieldData));
+ $node = $this->drupalCreateNode([$this->fieldName => $fieldData]);
// Log in as the administrator and confirm that the field value is present.
$this->drupalLogin($this->adminUser);
@@ -89,7 +89,7 @@ class NodeAccessFieldTest extends NodeTestBase {
$this->assertText('Access denied', 'Access is denied for the content admin.');
// Modify the field default as the content admin.
- $edit = array();
+ $edit = [];
$default = 'Sometimes words have two meanings';
$edit["default_value_input[{$this->fieldName}][0][value]"] = $default;
$this->drupalPostForm(
diff --git a/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php b/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
index 7963e870a04..fa2116ab875 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
@@ -15,7 +15,7 @@ class NodeAccessGrantsCacheContextTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_access_test');
+ public static $modules = ['node_access_test'];
/**
* User with permission to view content.
@@ -43,9 +43,9 @@ class NodeAccessGrantsCacheContextTest extends NodeTestBase {
// Create user with simple node access permission. The 'node test view'
// permission is implemented and granted by the node_access_test module.
- $this->accessUser = $this->drupalCreateUser(array('access content overview', 'access content', 'node test view'));
- $this->noAccessUser = $this->drupalCreateUser(array('access content overview', 'access content'));
- $this->noAccessUser2 = $this->drupalCreateUser(array('access content overview', 'access content'));
+ $this->accessUser = $this->drupalCreateUser(['access content overview', 'access content', 'node test view']);
+ $this->noAccessUser = $this->drupalCreateUser(['access content overview', 'access content']);
+ $this->noAccessUser2 = $this->drupalCreateUser(['access content overview', 'access content']);
$this->userMapping = [
1 => $this->rootUser,
@@ -84,14 +84,14 @@ class NodeAccessGrantsCacheContextTest extends NodeTestBase {
// Grant view to all nodes (because nid = 0) for users in the
// 'node_access_all' realm.
- $record = array(
+ $record = [
'nid' => 0,
'gid' => 0,
'realm' => 'node_access_all',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
- );
+ ];
db_insert('node_access')->fields($record)->execute();
// Put user accessUser (uid 0) in the realm.
diff --git a/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareCombinationTest.php
index 860bebee286..ff4d1a248af 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareCombinationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareCombinationTest.php
@@ -22,14 +22,14 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('language', 'node_access_test_language', 'node_access_test');
+ public static $modules = ['language', 'node_access_test_language', 'node_access_test'];
/**
* A set of nodes to use in testing.
*
* @var \Drupal\node\NodeInterface[]
*/
- protected $nodes = array();
+ protected $nodes = [];
/**
* A normal authenticated user.
@@ -52,24 +52,24 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Create the 'private' field, which allows the node to be marked as private
// (restricted access) in a given translation.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_private',
'entity_type' => 'node',
'type' => 'boolean',
'cardinality' => 1,
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
- 'widget' => array(
+ 'widget' => [
'type' => 'options_buttons',
- ),
- 'settings' => array(
+ ],
+ 'settings' => [
'on_label' => 'Private',
'off_label' => 'Not private',
- ),
+ ],
])->save();
// After enabling a node access module, the access table has to be rebuild.
@@ -80,7 +80,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
ConfigurableLanguage::createFromLangcode('ca')->save();
// Create a normal authenticated user.
- $this->webUser = $this->drupalCreateUser(array('access content'));
+ $this->webUser = $this->drupalCreateUser(['access content']);
// Load the user 1 user for later use as an admin user with permission to
// see everything.
@@ -101,92 +101,92 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// 4. One public with only the Catalan translation private.
// 5. One public with both the Hungarian and Catalan translations private.
// 6. One private with both the Hungarian and Catalan translations private.
- $this->nodes['public_both_public'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['public_both_public'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 0)),
+ 'field_private' => [['value' => 0]],
'private' => FALSE,
- ));
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 0;
$node->save();
- $this->nodes['private_both_public'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['private_both_public'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 0)),
+ 'field_private' => [['value' => 0]],
'private' => TRUE,
- ));
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 0;
$node->save();
- $this->nodes['public_hu_private'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['public_hu_private'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 1)),
+ 'field_private' => [['value' => 1]],
'private' => FALSE,
- ));
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 0;
$node->save();
- $this->nodes['public_ca_private'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['public_ca_private'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 0)),
+ 'field_private' => [['value' => 0]],
'private' => FALSE,
- ));
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 1;
$node->save();
- $this->nodes['public_both_private'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['public_both_private'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 1)),
+ 'field_private' => [['value' => 1]],
'private' => FALSE,
- ));
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 1;
$node->save();
- $this->nodes['private_both_private'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['private_both_private'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 1)),
+ 'field_private' => [['value' => 1]],
'private' => TRUE,
- ));
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 1;
$node->save();
- $this->nodes['public_no_language_private'] = $this->drupalCreateNode(array(
- 'field_private' => array(array('value' => 1)),
+ $this->nodes['public_no_language_private'] = $this->drupalCreateNode([
+ 'field_private' => [['value' => 1]],
'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
- $this->nodes['public_no_language_public'] = $this->drupalCreateNode(array(
- 'field_private' => array(array('value' => 0)),
+ ]);
+ $this->nodes['public_no_language_public'] = $this->drupalCreateNode([
+ 'field_private' => [['value' => 0]],
'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
- $this->nodes['private_no_language_private'] = $this->drupalCreateNode(array(
- 'field_private' => array(array('value' => 1)),
+ ]);
+ $this->nodes['private_no_language_private'] = $this->drupalCreateNode([
+ 'field_private' => [['value' => 1]],
'private' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
- $this->nodes['private_no_language_public'] = $this->drupalCreateNode(array(
- 'field_private' => array(array('value' => 1)),
+ ]);
+ $this->nodes['private_no_language_public'] = $this->drupalCreateNode([
+ 'field_private' => [['value' => 1]],
'private' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
}
/**
@@ -194,8 +194,8 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
*/
function testNodeAccessLanguageAwareCombination() {
- $expected_node_access = array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE);
- $expected_node_access_no_access = array('view' => FALSE, 'update' => FALSE, 'delete' => FALSE);
+ $expected_node_access = ['view' => TRUE, 'update' => FALSE, 'delete' => FALSE];
+ $expected_node_access_no_access = ['view' => FALSE, 'update' => FALSE, 'delete' => FALSE];
// When the node and both translations are public, access should always be
// granted.
@@ -254,7 +254,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Query with no language specified. The fallback (hu or und) will be used.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addTag('node_access');
$nids = $select->execute()->fetchAllAssoc('nid');
@@ -269,7 +269,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Query with Hungarian (hu) specified.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addMetaData('langcode', 'hu')
->addTag('node_access');
@@ -283,7 +283,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Query with Catalan (ca) specified.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addMetaData('langcode', 'ca')
->addTag('node_access');
@@ -297,7 +297,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Query with German (de) specified.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addMetaData('langcode', 'de')
->addTag('node_access');
@@ -309,7 +309,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Query the nodes table as admin user (full access) with the node access
// tag and no specific langcode.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->adminUser)
->addTag('node_access');
$nids = $select->execute()->fetchAllAssoc('nid');
@@ -320,7 +320,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Query the nodes table as admin user (full access) with the node access
// tag and langcode de.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->adminUser)
->addMetaData('langcode', 'de')
->addTag('node_access');
diff --git a/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareTest.php b/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareTest.php
index 90e040b27ad..9338e5de6a4 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessLanguageAwareTest.php
@@ -21,14 +21,14 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('language', 'node_access_test_language');
+ public static $modules = ['language', 'node_access_test_language'];
/**
* A set of nodes to use in testing.
*
* @var \Drupal\node\NodeInterface[]
*/
- protected $nodes = array();
+ protected $nodes = [];
/**
* A user with permission to bypass access content.
@@ -49,31 +49,31 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Create the 'private' field, which allows the node to be marked as private
// (restricted access) in a given translation.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_private',
'entity_type' => 'node',
'type' => 'boolean',
'cardinality' => 1,
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
- 'widget' => array(
+ 'widget' => [
'type' => 'options_buttons',
- ),
- 'settings' => array(
+ ],
+ 'settings' => [
'on_label' => 'Private',
'off_label' => 'Not private',
- ),
+ ],
])->save();
// After enabling a node access module, the access table has to be rebuild.
node_access_rebuild();
// Create a normal authenticated user.
- $this->webUser = $this->drupalCreateUser(array('access content'));
+ $this->webUser = $this->drupalCreateUser(['access content']);
// Load the user 1 user for later use as an admin user with permission to
// see everything.
@@ -95,54 +95,54 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// 2. Two nodes with no language specified.
// - One public.
// - One private.
- $this->nodes['both_public'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['both_public'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 0)),
- ));
+ 'field_private' => [['value' => 0]],
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 0;
$node->save();
- $this->nodes['ca_private'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['ca_private'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 0)),
- ));
+ 'field_private' => [['value' => 0]],
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 1;
$node->save();
- $this->nodes['hu_private'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['hu_private'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 1)),
- ));
+ 'field_private' => [['value' => 1]],
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 0;
$node->save();
- $this->nodes['both_private'] = $node = $this->drupalCreateNode(array(
- 'body' => array(array()),
+ $this->nodes['both_private'] = $node = $this->drupalCreateNode([
+ 'body' => [[]],
'langcode' => 'hu',
- 'field_private' => array(array('value' => 1)),
- ));
+ 'field_private' => [['value' => 1]],
+ ]);
$translation = $node->addTranslation('ca');
$translation->title->value = $this->randomString();
$translation->field_private->value = 1;
$node->save();
- $this->nodes['no_language_public'] = $this->drupalCreateNode(array(
- 'field_private' => array(array('value' => 0)),
+ $this->nodes['no_language_public'] = $this->drupalCreateNode([
+ 'field_private' => [['value' => 0]],
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
- $this->nodes['no_language_private'] = $this->drupalCreateNode(array(
- 'field_private' => array(array('value' => 1)),
+ ]);
+ $this->nodes['no_language_private'] = $this->drupalCreateNode([
+ 'field_private' => [['value' => 1]],
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
}
/**
@@ -150,8 +150,8 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
*/
function testNodeAccessLanguageAware() {
// The node_access_test_language module only grants view access.
- $expected_node_access = array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE);
- $expected_node_access_no_access = array('view' => FALSE, 'update' => FALSE, 'delete' => FALSE);
+ $expected_node_access = ['view' => TRUE, 'update' => FALSE, 'delete' => FALSE];
+ $expected_node_access_no_access = ['view' => FALSE, 'update' => FALSE, 'delete' => FALSE];
// When both Hungarian and Catalan are marked as public, access to the
// Hungarian translation should be granted with the default entity object or
@@ -195,7 +195,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Query with no language specified. The fallback (hu) will be used.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addTag('node_access');
$nids = $select->execute()->fetchAllAssoc('nid');
@@ -211,7 +211,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Query with Hungarian (hu) specified.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addMetaData('langcode', 'hu')
->addTag('node_access');
@@ -225,7 +225,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Query with Catalan (ca) specified.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addMetaData('langcode', 'ca')
->addTag('node_access');
@@ -239,7 +239,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Query with German (de) specified.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->webUser)
->addMetaData('langcode', 'de')
->addTag('node_access');
@@ -251,7 +251,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Query the nodes table as admin user (full access) with the node access
// tag and no specific langcode.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->adminUser)
->addTag('node_access');
$nids = $select->execute()->fetchAllAssoc('nid');
@@ -262,7 +262,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Query the nodes table as admin user (full access) with the node access
// tag and langcode de.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $this->adminUser)
->addMetaData('langcode', 'de')
->addTag('node_access');
diff --git a/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php b/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php
index e7586763bf7..2c9bcc3a74b 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php
@@ -20,7 +20,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('language', 'node_access_test');
+ public static $modules = ['language', 'node_access_test'];
protected function setUp() {
parent::setUp();
@@ -43,14 +43,14 @@ class NodeAccessLanguageTest extends NodeTestBase {
* Tests node access with multiple node languages and no private nodes.
*/
function testNodeAccess() {
- $web_user = $this->drupalCreateUser(array('access content'));
+ $web_user = $this->drupalCreateUser(['access content']);
- $expected_node_access = array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE);
- $expected_node_access_no_access = array('view' => FALSE, 'update' => FALSE, 'delete' => FALSE);
+ $expected_node_access = ['view' => TRUE, 'update' => FALSE, 'delete' => FALSE];
+ $expected_node_access_no_access = ['view' => FALSE, 'update' => FALSE, 'delete' => FALSE];
// Creating a public node with langcode Hungarian, will be saved as the
// fallback in node access table.
- $node_public_hu = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE));
+ $node_public_hu = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'hu', 'private' => FALSE]);
$this->assertTrue($node_public_hu->language()->getId() == 'hu', 'Node created as Hungarian.');
// Tests the default access is provided for the public Hungarian node.
@@ -61,10 +61,10 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Creating a public node with no special langcode, like when no language
// module enabled.
- $node_public_no_language = $this->drupalCreateNode(array(
+ $node_public_no_language = $this->drupalCreateNode([
'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
$this->assertTrue($node_public_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Tests that access is granted if requested with no language.
@@ -73,7 +73,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Reset the node access cache and turn on our test node access code.
\Drupal::entityManager()->getAccessControlHandler('node')->resetCache();
\Drupal::state()->set('node_access_test_secret_catalan', 1);
- $node_public_ca = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'ca', 'private' => FALSE));
+ $node_public_ca = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'ca', 'private' => FALSE]);
$this->assertTrue($node_public_ca->language()->getId() == 'ca', 'Node created as Catalan.');
// Tests that access is granted if requested with no language.
@@ -113,13 +113,13 @@ class NodeAccessLanguageTest extends NodeTestBase {
* Tests node access with multiple node languages and private nodes.
*/
function testNodeAccessPrivate() {
- $web_user = $this->drupalCreateUser(array('access content'));
- $expected_node_access = array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE);
- $expected_node_access_no_access = array('view' => FALSE, 'update' => FALSE, 'delete' => FALSE);
+ $web_user = $this->drupalCreateUser(['access content']);
+ $expected_node_access = ['view' => TRUE, 'update' => FALSE, 'delete' => FALSE];
+ $expected_node_access_no_access = ['view' => FALSE, 'update' => FALSE, 'delete' => FALSE];
// Creating a private node with langcode Hungarian, will be saved as the
// fallback in node access table.
- $node_private_hu = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE));
+ $node_private_hu = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'hu', 'private' => TRUE]);
$this->assertTrue($node_private_hu->language()->getId() == 'hu', 'Node created as Hungarian.');
// Tests the default access is not provided for the private Hungarian node.
@@ -130,10 +130,10 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Creating a private node with no special langcode, like when no language
// module enabled.
- $node_private_no_language = $this->drupalCreateNode(array(
+ $node_private_no_language = $this->drupalCreateNode([
'private' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
$this->assertTrue($node_private_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Tests that access is not granted if requested with no language.
@@ -148,8 +148,8 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Creating a private node with langcode Catalan to test that the
// node_access_test_secret_catalan flag works.
- $private_ca_user = $this->drupalCreateUser(array('access content', 'node test view'));
- $node_private_ca = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'ca', 'private' => TRUE));
+ $private_ca_user = $this->drupalCreateUser(['access content', 'node test view']);
+ $node_private_ca = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'ca', 'private' => TRUE]);
$this->assertTrue($node_private_ca->language()->getId() == 'ca', 'Node created as Catalan.');
// Tests that Catalan is still not accessible to either user.
@@ -177,7 +177,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
*/
function testNodeAccessQueryTag() {
// Create a normal authenticated user.
- $web_user = $this->drupalCreateUser(array('access content'));
+ $web_user = $this->drupalCreateUser(['access content']);
// Load the user 1 user for later use as an admin user with permission to
// see everything.
@@ -185,26 +185,26 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Creating a private node with langcode Hungarian, will be saved as
// the fallback in node access table.
- $node_private = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE));
+ $node_private = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'hu', 'private' => TRUE]);
$this->assertTrue($node_private->language()->getId() == 'hu', 'Node created as Hungarian.');
// Creating a public node with langcode Hungarian, will be saved as
// the fallback in node access table.
- $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE));
+ $node_public = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'hu', 'private' => FALSE]);
$this->assertTrue($node_public->language()->getId() == 'hu', 'Node created as Hungarian.');
// Creating a public node with no special langcode, like when no language
// module enabled.
- $node_no_language = $this->drupalCreateNode(array(
+ $node_no_language = $this->drupalCreateNode([
'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
$this->assertTrue($node_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Query the nodes table as the web user with the node access tag and no
// specific langcode.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $web_user)
->addTag('node_access');
$nids = $select->execute()->fetchAllAssoc('nid');
@@ -218,7 +218,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Query the nodes table as the web user with the node access tag and
// langcode de.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $web_user)
->addMetaData('langcode', 'de')
->addTag('node_access');
@@ -230,7 +230,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Query the nodes table as admin user (full access) with the node access
// tag and no specific langcode.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $admin_user)
->addTag('node_access');
$nids = $select->execute()->fetchAllAssoc('nid');
@@ -241,7 +241,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Query the nodes table as admin user (full access) with the node access
// tag and langcode de.
$select = db_select('node', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->addMetaData('account', $admin_user)
->addMetaData('langcode', 'de')
->addTag('node_access');
diff --git a/core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php b/core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php
index 9d12098b870..ce6326d54b9 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessMenuLinkTest.php
@@ -16,7 +16,7 @@ class NodeAccessMenuLinkTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('menu_ui', 'block');
+ public static $modules = ['menu_ui', 'block'];
/**
* A user with permission to manage menu links and create nodes.
@@ -30,13 +30,13 @@ class NodeAccessMenuLinkTest extends NodeTestBase {
$this->drupalPlaceBlock('system_menu_block:main');
- $this->contentAdminUser = $this->drupalCreateUser(array(
+ $this->contentAdminUser = $this->drupalCreateUser([
'access content',
'administer content types',
'administer menu'
- ));
+ ]);
- $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', array())->save();
+ $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', [])->save();
}
/**
@@ -64,7 +64,7 @@ class NodeAccessMenuLinkTest extends NodeTestBase {
// Ensure anonymous users with "access content" permission see this menu
// link.
- $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', array('access content'))->save();
+ $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', ['access content'])->save();
$this->drupalGet('');
$this->assertLink($menu_link_title);
}
diff --git a/core/modules/node/tests/src/Functional/NodeAccessRecordsTest.php b/core/modules/node/tests/src/Functional/NodeAccessRecordsTest.php
index ce16bee6b88..13ec1117053 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessRecordsTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessRecordsTest.php
@@ -16,68 +16,68 @@ class NodeAccessRecordsTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_test');
+ public static $modules = ['node_test'];
/**
* Creates a node and tests the creation of node access rules.
*/
function testNodeAccessRecords() {
// Create an article node.
- $node1 = $this->drupalCreateNode(array('type' => 'article'));
+ $node1 = $this->drupalCreateNode(['type' => 'article']);
$this->assertTrue(Node::load($node1->id()), 'Article node created.');
// Check to see if grants added by node_test_node_access_records made it in.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node1->id()))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', [':nid' => $node1->id()])->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_article_realm', 'Grant with article_realm acquired for node without alteration.');
$this->assertEqual($records[0]->gid, 1, 'Grant with gid = 1 acquired for node without alteration.');
// Create an unpromoted "Basic page" node.
- $node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 0));
+ $node2 = $this->drupalCreateNode(['type' => 'page', 'promote' => 0]);
$this->assertTrue(Node::load($node2->id()), 'Unpromoted basic page node created.');
// Check to see if grants added by node_test_node_access_records made it in.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node2->id()))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', [':nid' => $node2->id()])->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_page_realm', 'Grant with page_realm acquired for node without alteration.');
$this->assertEqual($records[0]->gid, 1, 'Grant with gid = 1 acquired for node without alteration.');
// Create an unpromoted, unpublished "Basic page" node.
- $node3 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 0, 'status' => 0));
+ $node3 = $this->drupalCreateNode(['type' => 'page', 'promote' => 0, 'status' => 0]);
$this->assertTrue(Node::load($node3->id()), 'Unpromoted, unpublished basic page node created.');
// Check to see if grants added by node_test_node_access_records made it in.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node3->id()))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', [':nid' => $node3->id()])->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_page_realm', 'Grant with page_realm acquired for node without alteration.');
$this->assertEqual($records[0]->gid, 1, 'Grant with gid = 1 acquired for node without alteration.');
// Create a promoted "Basic page" node.
- $node4 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
+ $node4 = $this->drupalCreateNode(['type' => 'page', 'promote' => 1]);
$this->assertTrue(Node::load($node4->id()), 'Promoted basic page node created.');
// Check to see if grant added by node_test_node_access_records was altered
// by node_test_node_access_records_alter.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node4->id()))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', [':nid' => $node4->id()])->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_alter_realm', 'Altered grant with alter_realm acquired for node.');
$this->assertEqual($records[0]->gid, 2, 'Altered grant with gid = 2 acquired for node.');
// Check to see if we can alter grants with hook_node_grants_alter().
- $operations = array('view', 'update', 'delete');
+ $operations = ['view', 'update', 'delete'];
// Create a user that is allowed to access content.
- $web_user = $this->drupalCreateUser(array('access content'));
+ $web_user = $this->drupalCreateUser(['access content']);
foreach ($operations as $op) {
$grants = node_test_node_grants($web_user, $op);
$altered_grants = $grants;
\Drupal::moduleHandler()->alter('node_grants', $altered_grants, $web_user, $op);
- $this->assertNotEqual($grants, $altered_grants, format_string('Altered the %op grant for a user.', array('%op' => $op)));
+ $this->assertNotEqual($grants, $altered_grants, format_string('Altered the %op grant for a user.', ['%op' => $op]));
}
// Check that core does not grant access to an unpublished node when an
// empty $grants array is returned.
- $node6 = $this->drupalCreateNode(array('status' => 0, 'disable_node_access' => TRUE));
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node6->id()))->fetchAll();
+ $node6 = $this->drupalCreateNode(['status' => 0, 'disable_node_access' => TRUE]);
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', [':nid' => $node6->id()])->fetchAll();
$this->assertEqual(count($records), 0, 'Returned no records for unpublished node.');
}
diff --git a/core/modules/node/tests/src/Functional/NodeCacheTagsTest.php b/core/modules/node/tests/src/Functional/NodeCacheTagsTest.php
index d0007a13cfe..ca5a0a99127 100644
--- a/core/modules/node/tests/src/Functional/NodeCacheTagsTest.php
+++ b/core/modules/node/tests/src/Functional/NodeCacheTagsTest.php
@@ -17,7 +17,7 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* {@inheritdoc}
@@ -61,7 +61,7 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
* Each node must have an author.
*/
protected function getAdditionalCacheTagsForEntity(EntityInterface $node) {
- return array('user:' . $node->getOwnerId(), 'user_view');
+ return ['user:' . $node->getOwnerId(), 'user_view'];
}
/**
diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php
index 57fd746d69d..8f5fb3500cd 100644
--- a/core/modules/node/tests/src/Functional/NodeCreationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php
@@ -21,12 +21,12 @@ class NodeCreationTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_test_exception', 'dblog', 'test_page_test');
+ public static $modules = ['node_test_exception', 'dblog', 'test_page_test'];
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit own page content']);
$this->drupalLogin($web_user);
}
@@ -42,16 +42,16 @@ class NodeCreationTest extends NodeTestBase {
$this->assertResponse(200);
$this->assertUrl('node/add/page');
// Create a node.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the Basic page has been created.
- $this->assertText(t('@post @title has been created.', array('@post' => 'Basic page', '@title' => $edit['title[0][value]'])), 'Basic page created.');
+ $this->assertText(t('@post @title has been created.', ['@post' => 'Basic page', '@title' => $edit['title[0][value]']]), 'Basic page created.');
// Verify that the creation message contains a link to a node.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']);
$this->assert(isset($view_link), 'The message area contains a link to a node');
// Check that the node exists in the database.
@@ -74,7 +74,7 @@ class NodeCreationTest extends NodeTestBase {
$this->assertText(format_date($node->getCreatedTime()));
// Check if the node revision checkbox is not rendered on node creation form.
- $admin_user = $this->drupalCreateUser(array('administer nodes', 'create page content'));
+ $admin_user = $this->drupalCreateUser(['administer nodes', 'create page content']);
$this->drupalLogin($admin_user);
$this->drupalGet('node/add/page');
$this->assertNoFieldById('edit-revision', NULL, 'The revision checkbox is not present.');
@@ -85,13 +85,13 @@ class NodeCreationTest extends NodeTestBase {
*/
function testFailedPageCreation() {
// Create a node.
- $edit = array(
+ $edit = [
'uid' => $this->loggedInUser->id(),
'name' => $this->loggedInUser->name,
'type' => 'page',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'title' => 'testing_transaction_exception',
- );
+ ];
try {
// An exception is generated by node_test_exception_node_insert() if the
@@ -137,7 +137,7 @@ class NodeCreationTest extends NodeTestBase {
->save();
// Create a node.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save'));
@@ -147,10 +147,10 @@ class NodeCreationTest extends NodeTestBase {
$this->assertText(t('Test page text'));
// Confirm that the node was created.
- $this->assertText(t('@post @title has been created.', array('@post' => 'Basic page', '@title' => $edit['title[0][value]'])));
+ $this->assertText(t('@post @title has been created.', ['@post' => 'Basic page', '@title' => $edit['title[0][value]']]));
// Verify that the creation message contains a link to a node.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']);
$this->assert(isset($view_link), 'The message area contains a link to a node');
}
@@ -158,7 +158,7 @@ class NodeCreationTest extends NodeTestBase {
* Tests the author autocompletion textfield.
*/
public function testAuthorAutocomplete() {
- $admin_user = $this->drupalCreateUser(array('administer nodes', 'create page content'));
+ $admin_user = $this->drupalCreateUser(['administer nodes', 'create page content']);
$this->drupalLogin($admin_user);
$this->drupalGet('node/add/page');
@@ -166,7 +166,7 @@ class NodeCreationTest extends NodeTestBase {
$result = $this->xpath('//input[@id="edit-uid-0-value" and contains(@data-autocomplete-path, "user/autocomplete")]');
$this->assertEqual(count($result), 0, 'No autocompletion without access user profiles.');
- $admin_user = $this->drupalCreateUser(array('administer nodes', 'create page content', 'access user profiles'));
+ $admin_user = $this->drupalCreateUser(['administer nodes', 'create page content', 'access user profiles']);
$this->drupalLogin($admin_user);
$this->drupalGet('node/add/page');
@@ -191,7 +191,7 @@ class NodeCreationTest extends NodeTestBase {
$this->drupalGet('node/add');
$this->assertResponse(403);
- $admin_content_types = $this->drupalCreateUser(array('administer content types'));
+ $admin_content_types = $this->drupalCreateUser(['administer content types']);
$this->drupalLogin($admin_content_types);
$this->drupalGet('node/add');
@@ -209,7 +209,7 @@ class NodeCreationTest extends NodeTestBase {
protected static function getWatchdogIdsForTestExceptionRollback() {
// PostgreSQL doesn't support bytea LIKE queries, so we need to unserialize
// first to check for the rollback exception message.
- $matches = array();
+ $matches = [];
$query = db_query("SELECT wid, variables FROM {watchdog}");
foreach ($query as $row) {
$variables = (array) unserialize($row->variables);
diff --git a/core/modules/node/tests/src/Functional/NodeFormSaveChangedTimeTest.php b/core/modules/node/tests/src/Functional/NodeFormSaveChangedTimeTest.php
index 918a2e7d54c..607e68cf0d2 100644
--- a/core/modules/node/tests/src/Functional/NodeFormSaveChangedTimeTest.php
+++ b/core/modules/node/tests/src/Functional/NodeFormSaveChangedTimeTest.php
@@ -16,9 +16,9 @@ class NodeFormSaveChangedTimeTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'node',
- );
+ ];
/**
* An user with permissions to create and edit articles.
@@ -34,18 +34,18 @@ class NodeFormSaveChangedTimeTest extends BrowserTestBase {
parent::setUp();
// Create a node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
- ));
+ ]);
$this->authorUser = $this->drupalCreateUser(['access content', 'create article content', 'edit any article content'], 'author');
$this->drupalLogin($this->authorUser);
// Create one node of the above node type .
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'type' => 'article',
- ));
+ ]);
}
/**
@@ -65,7 +65,7 @@ class NodeFormSaveChangedTimeTest extends BrowserTestBase {
sleep(1);
// Save the node on the regular node edit form.
- $this->drupalPostForm('node/1/edit', array(), t('Save'));
+ $this->drupalPostForm('node/1/edit', [], t('Save'));
$storage->resetCache([1]);
$node = $storage->load(1);
diff --git a/core/modules/node/tests/src/Functional/NodeHelpTest.php b/core/modules/node/tests/src/Functional/NodeHelpTest.php
index ffeee08c2c5..c4b71392148 100644
--- a/core/modules/node/tests/src/Functional/NodeHelpTest.php
+++ b/core/modules/node/tests/src/Functional/NodeHelpTest.php
@@ -16,7 +16,7 @@ class NodeHelpTest extends BrowserTestBase {
*
* @var array.
*/
- public static $modules = array('block', 'node', 'help');
+ public static $modules = ['block', 'node', 'help'];
/**
* The name of the test node type to create.
@@ -39,11 +39,11 @@ class NodeHelpTest extends BrowserTestBase {
parent::setUp();
// Create user.
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer content types',
'administer nodes',
'bypass node access',
- ));
+ ]);
$this->drupalLogin($admin_user);
$this->drupalPlaceBlock('help_block');
@@ -52,10 +52,10 @@ class NodeHelpTest extends BrowserTestBase {
$this->testText = t('Help text to find on node forms.');
// Create content type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => $this->testType,
'help' => $this->testText,
- ));
+ ]);
}
/**
@@ -68,7 +68,7 @@ class NodeHelpTest extends BrowserTestBase {
$this->assertText($this->testText);
// Create node and check the node edit form.
- $node = $this->drupalCreateNode(array('type' => $this->testType));
+ $node = $this->drupalCreateNode(['type' => $this->testType]);
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertResponse(200);
$this->assertText($this->testText);
diff --git a/core/modules/node/tests/src/Functional/NodeLinksTest.php b/core/modules/node/tests/src/Functional/NodeLinksTest.php
index f1e2629d3ad..7bd725b46bf 100644
--- a/core/modules/node/tests/src/Functional/NodeLinksTest.php
+++ b/core/modules/node/tests/src/Functional/NodeLinksTest.php
@@ -16,16 +16,16 @@ class NodeLinksTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('views');
+ public static $modules = ['views'];
/**
* Tests that the links can be hidden in the view display settings.
*/
public function testHideLinks() {
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
- ));
+ ]);
// Links are displayed by default.
$this->drupalGet('node');
diff --git a/core/modules/node/tests/src/Functional/NodeLoadMultipleTest.php b/core/modules/node/tests/src/Functional/NodeLoadMultipleTest.php
index 92440caf611..b5d991bcd0a 100644
--- a/core/modules/node/tests/src/Functional/NodeLoadMultipleTest.php
+++ b/core/modules/node/tests/src/Functional/NodeLoadMultipleTest.php
@@ -16,11 +16,11 @@ class NodeLoadMultipleTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('views');
+ public static $modules = ['views'];
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('create article content', 'create page content'));
+ $web_user = $this->drupalCreateUser(['create article content', 'create page content']);
$this->drupalLogin($web_user);
}
@@ -28,10 +28,10 @@ class NodeLoadMultipleTest extends NodeTestBase {
* Creates four nodes and ensures that they are loaded correctly.
*/
function testNodeMultipleLoad() {
- $node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
- $node2 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
- $node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 0));
- $node4 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 0));
+ $node1 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
+ $node2 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
+ $node3 = $this->drupalCreateNode(['type' => 'article', 'promote' => 0]);
+ $node4 = $this->drupalCreateNode(['type' => 'page', 'promote' => 0]);
// Confirm that promoted nodes appear in the default node listing.
$this->drupalGet('node');
@@ -41,16 +41,16 @@ class NodeLoadMultipleTest extends NodeTestBase {
$this->assertNoText($node4->label(), 'Node title does not appear in the default listing.');
// Load nodes with only a condition. Nodes 3 and 4 will be loaded.
$nodes = $this->container->get('entity_type.manager')->getStorage('node')
- ->loadByProperties(array('promote' => 0));
+ ->loadByProperties(['promote' => 0]);
$this->assertEqual($node3->label(), $nodes[$node3->id()]->label(), 'Node was loaded.');
$this->assertEqual($node4->label(), $nodes[$node4->id()]->label(), 'Node was loaded.');
$count = count($nodes);
- $this->assertTrue($count == 2, format_string('@count nodes loaded.', array('@count' => $count)));
+ $this->assertTrue($count == 2, format_string('@count nodes loaded.', ['@count' => $count]));
// Load nodes by nid. Nodes 1, 2 and 4 will be loaded.
- $nodes = Node::loadMultiple(array(1, 2, 4));
+ $nodes = Node::loadMultiple([1, 2, 4]);
$count = count($nodes);
- $this->assertTrue(count($nodes) == 3, format_string('@count nodes loaded', array('@count' => $count)));
+ $this->assertTrue(count($nodes) == 3, format_string('@count nodes loaded', ['@count' => $count]));
$this->assertTrue(isset($nodes[$node1->id()]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node2->id()]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node4->id()]), 'Node is correctly keyed in the array');
diff --git a/core/modules/node/tests/src/Functional/NodePostSettingsTest.php b/core/modules/node/tests/src/Functional/NodePostSettingsTest.php
index c59c42db934..96992615628 100644
--- a/core/modules/node/tests/src/Functional/NodePostSettingsTest.php
+++ b/core/modules/node/tests/src/Functional/NodePostSettingsTest.php
@@ -13,7 +13,7 @@ class NodePostSettingsTest extends NodeTestBase {
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('create page content', 'administer content types', 'access user profiles'));
+ $web_user = $this->drupalCreateUser(['create page content', 'administer content types', 'access user profiles']);
$this->drupalLogin($web_user);
}
@@ -23,35 +23,35 @@ class NodePostSettingsTest extends NodeTestBase {
function testPagePostInfo() {
// Set "Basic page" content type to display post information.
- $edit = array();
+ $edit = [];
$edit['display_submitted'] = TRUE;
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
// Create a node.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
- $elements = $this->xpath('//div[contains(@class, :class)]', array(':class' => 'node__submitted'));
+ $elements = $this->xpath('//div[contains(@class, :class)]', [':class' => 'node__submitted']);
$this->assertEqual(count($elements), 1, 'Post information is displayed.');
$node->delete();
// Set "Basic page" content type to display post information.
- $edit = array();
+ $edit = [];
$edit['display_submitted'] = FALSE;
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
// Create a node.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
- $elements = $this->xpath('//div[contains(@class, :class)]', array(':class' => 'node__submitted'));
+ $elements = $this->xpath('//div[contains(@class, :class)]', [':class' => 'node__submitted']);
$this->assertEqual(count($elements), 0, 'Post information is not displayed.');
}
diff --git a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
index de77927a78a..2d154e29cff 100644
--- a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
@@ -20,7 +20,7 @@ class NodeRSSContentTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_test', 'views');
+ public static $modules = ['node_test', 'views'];
protected function setUp() {
parent::setUp();
@@ -28,7 +28,7 @@ class NodeRSSContentTest extends NodeTestBase {
// Use bypass node access permission here, because the test class uses
// hook_grants_alter() to deny access to everyone on node_access
// queries.
- $user = $this->drupalCreateUser(array('bypass node access', 'access content', 'create article content'));
+ $user = $this->drupalCreateUser(['bypass node access', 'access content', 'create article content']);
$this->drupalLogin($user);
}
@@ -37,21 +37,21 @@ class NodeRSSContentTest extends NodeTestBase {
*/
function testNodeRSSContent() {
// Create a node.
- $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
+ $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
$this->drupalGet('rss.xml');
// Check that content added in 'rss' view mode appear in RSS feed.
- $rss_only_content = t('Extra data that should appear only in the RSS feed for node @nid.', array('@nid' => $node->id()));
+ $rss_only_content = t('Extra data that should appear only in the RSS feed for node @nid.', ['@nid' => $node->id()]);
$this->assertText($rss_only_content, 'Node content designated for RSS appear in RSS feed.');
// Check that content added in view modes other than 'rss' doesn't
// appear in RSS feed.
- $non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node @nid.', array('@nid' => $node->id()));
+ $non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node @nid.', ['@nid' => $node->id()]);
$this->assertNoText($non_rss_content, 'Node content not designed for RSS does not appear in RSS feed.');
// Check that extra RSS elements and namespaces are added to RSS feed.
- $test_element = '<testElement>' . t('Value of testElement RSS element for node @nid.', array('@nid' => $node->id())) . '</testElement>';
+ $test_element = '<testElement>' . t('Value of testElement RSS element for node @nid.', ['@nid' => $node->id()]) . '</testElement>';
$test_ns = 'xmlns:drupaltest="http://example.com/test-namespace"';
$this->assertRaw($test_element, 'Extra RSS elements appear in RSS feed.');
$this->assertRaw($test_ns, 'Extra namespaces appear in RSS feed.');
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
index 9f3949ebceb..85d33cd684c 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
@@ -20,13 +20,13 @@ class NodeRevisionsAllTest extends NodeTestBase {
// Create and log in user.
$web_user = $this->drupalCreateUser(
- array(
+ [
'view page revisions',
'revert page revisions',
'delete page revisions',
'edit any page content',
'delete any page content'
- )
+ ]
);
$this->drupalLogin($web_user);
@@ -36,8 +36,8 @@ class NodeRevisionsAllTest extends NodeTestBase {
$settings = get_object_vars($node);
$settings['revision'] = 1;
- $nodes = array();
- $logs = array();
+ $nodes = [];
+ $logs = [];
// Get the original node.
$nodes[] = clone $node;
@@ -67,10 +67,10 @@ class NodeRevisionsAllTest extends NodeTestBase {
protected function createNodeRevision(NodeInterface $node) {
// Create revision with a random title and body and update variables.
$node->title = $this->randomMachineName();
- $node->body = array(
+ $node->body = [
'value' => $this->randomMachineName(32),
'format' => filter_default_format(),
- );
+ ];
$node->setNewRevision();
$node->save();
@@ -90,13 +90,13 @@ class NodeRevisionsAllTest extends NodeTestBase {
// Create and log in user.
$content_admin = $this->drupalCreateUser(
- array(
+ [
'view all revisions',
'revert all revisions',
'delete all revisions',
'edit any page content',
'delete any page content'
- )
+ ]
);
$this->drupalLogin($content_admin);
@@ -115,15 +115,15 @@ class NodeRevisionsAllTest extends NodeTestBase {
$this->assertTrue($node->isDefaultRevision(), 'Third node revision is the current one.');
// Confirm that revisions revert properly.
- $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/revert", array(), t('Revert'));
+ $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/revert", [], t('Revert'));
$this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.',
- array(
+ [
'@type' => 'Basic page',
'%title' => $nodes[1]->getTitle(),
'%revision-date' => format_date($nodes[1]->getRevisionCreationTime())
- )),
+ ]),
'Revision reverted.');
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$reverted_node = $node_storage->load($node->id());
$this->assertTrue(($nodes[1]->body->value == $reverted_node->body->value), 'Node reverted correctly.');
@@ -132,16 +132,16 @@ class NodeRevisionsAllTest extends NodeTestBase {
$this->assertFalse($node->isDefaultRevision(), 'Third node revision is not the current one.');
// Confirm revisions delete properly.
- $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", array(), t('Delete'));
+ $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", [], t('Delete'));
$this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.',
- array(
+ [
'%revision-date' => format_date($nodes[1]->getRevisionCreationTime()),
'@type' => 'Basic page',
'%title' => $nodes[1]->getTitle(),
- )),
+ ]),
'Revision deleted.');
$this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid and vid = :vid',
- array(':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()))->fetchField() == 0,
+ [':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()])->fetchField() == 0,
'Revision not found.');
// Set the revision timestamp to an older date to make sure that the
@@ -149,16 +149,16 @@ class NodeRevisionsAllTest extends NodeTestBase {
$old_revision_date = REQUEST_TIME - 86400;
db_update('node_revision')
->condition('vid', $nodes[2]->getRevisionId())
- ->fields(array(
+ ->fields([
'revision_timestamp' => $old_revision_date,
- ))
+ ])
->execute();
- $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", array(), t('Revert'));
- $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', array(
+ $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", [], t('Revert'));
+ $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
'@type' => 'Basic page',
'%title' => $nodes[2]->getTitle(),
'%revision-date' => format_date($old_revision_date),
- )));
+ ]));
// Create 50 more revisions in order to trigger paging on the revisions
// overview screen.
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php
index f2c750c3663..d1cbfb80d9f 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php
@@ -66,7 +66,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase {
$this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked");
// Uncheck the create new revision checkbox and save the node.
- $edit = array('revision' => FALSE);
+ $edit = ['revision' => FALSE];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save and keep published');
$this->assertUrl($node->toUrl());
@@ -77,7 +77,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase {
$this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked");
// Submit the form without changing the checkbox.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save and keep published');
$this->assertUrl($node->toUrl());
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
index 673a83685ac..443f75f7488 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
@@ -54,11 +54,11 @@ class NodeRevisionsUiTest extends NodeTestBase {
$this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked");
// Uncheck the create new revision checkbox and save the node.
- $edit = array('revision' => FALSE);
+ $edit = ['revision' => FALSE];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
// Load the node again and check the revision is the same as before.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$node_revision = $node_storage->load($node->id(), TRUE);
$this->assertEqual($node_revision->getRevisionId(), $node->getRevisionId(), "After an existing node is saved with 'Create new revision' unchecked, a new revision is not created.");
@@ -67,11 +67,11 @@ class NodeRevisionsUiTest extends NodeTestBase {
$this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked");
// Submit the form without changing the checkbox.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
// Load the node again and check the revision is different from before.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$node_revision = $node_storage->load($node->id());
$this->assertNotEqual($node_revision->getRevisionId(), $node->getRevisionId(), "After an existing node is saved with 'Create new revision' checked, a new revision is created.");
}
diff --git a/core/modules/node/tests/src/Functional/NodeSaveTest.php b/core/modules/node/tests/src/Functional/NodeSaveTest.php
index 2d35ac029a9..9f57a5e8ae6 100644
--- a/core/modules/node/tests/src/Functional/NodeSaveTest.php
+++ b/core/modules/node/tests/src/Functional/NodeSaveTest.php
@@ -23,13 +23,13 @@ class NodeSaveTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node_test');
+ public static $modules = ['node_test'];
protected function setUp() {
parent::setUp();
// Create a user that is allowed to post; we'll use this to test the submission.
- $web_user = $this->drupalCreateUser(array('create article content'));
+ $web_user = $this->drupalCreateUser(['create article content']);
$this->drupalLogin($web_user);
$this->webUser = $web_user;
}
@@ -51,13 +51,13 @@ class NodeSaveTest extends NodeTestBase {
$max_nid = reset($nids);
$test_nid = $max_nid + mt_rand(1000, 1000000);
$title = $this->randomMachineName(8);
- $node = array(
+ $node = [
'title' => $title,
- 'body' => array(array('value' => $this->randomMachineName(32))),
+ 'body' => [['value' => $this->randomMachineName(32)]],
'uid' => $this->webUser->id(),
'type' => 'article',
'nid' => $test_nid,
- );
+ ];
/** @var \Drupal\node\NodeInterface $node */
$node = Node::create($node);
$node->enforceIsNew();
@@ -78,11 +78,11 @@ class NodeSaveTest extends NodeTestBase {
*/
function testTimestamps() {
// Use the default timestamps.
- $edit = array(
+ $edit = [
'uid' => $this->webUser->id(),
'type' => 'article',
'title' => $this->randomMachineName(8),
- );
+ ];
Node::create($edit)->save();
$node = $this->drupalGetNodeByTitle($edit['title']);
@@ -105,13 +105,13 @@ class NodeSaveTest extends NodeTestBase {
$this->assertEqual($node->getChangedTime(), 979534800, 'Saving a node uses "changed" timestamp set in presave hook.');
// Programmatically set the timestamps on the node.
- $edit = array(
+ $edit = [
'uid' => $this->webUser->id(),
'type' => 'article',
'title' => $this->randomMachineName(8),
'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT
'changed' => 979534800, // Drupal 1.0 release.
- );
+ ];
Node::create($edit)->save();
$node = $this->drupalGetNodeByTitle($edit['title']);
@@ -175,7 +175,7 @@ class NodeSaveTest extends NodeTestBase {
function testNodeSaveOnInsert() {
// node_test_node_insert() triggers a save on insert if the title equals
// 'new'.
- $node = $this->drupalCreateNode(array('title' => 'new'));
+ $node = $this->drupalCreateNode(['title' => 'new']);
$this->assertEqual($node->getTitle(), 'Node ' . $node->id(), 'Node saved on node insert.');
}
diff --git a/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php b/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php
index 16dee4350d7..7b99338b967 100644
--- a/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php
@@ -21,18 +21,18 @@ class NodeTemplateSuggestionsTest extends NodeTestBase {
$build = \Drupal::entityManager()->getViewBuilder('node')->view($node, $view_mode);
$variables['elements'] = $build;
- $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', array($variables));
+ $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]);
- $this->assertEqual($suggestions, array('node__full', 'node__page', 'node__page__full', 'node__' . $node->id(), 'node__' . $node->id() . '__full'), 'Found expected node suggestions.');
+ $this->assertEqual($suggestions, ['node__full', 'node__page', 'node__page__full', 'node__' . $node->id(), 'node__' . $node->id() . '__full'], 'Found expected node suggestions.');
// Change the view mode.
$view_mode = 'node.my_custom_view_mode';
$build = \Drupal::entityManager()->getViewBuilder('node')->view($node, $view_mode);
$variables['elements'] = $build;
- $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', array($variables));
+ $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]);
- $this->assertEqual($suggestions, array('node__node_my_custom_view_mode', 'node__page', 'node__page__node_my_custom_view_mode', 'node__' . $node->id(), 'node__' . $node->id() . '__node_my_custom_view_mode'), 'Found expected node suggestions.');
+ $this->assertEqual($suggestions, ['node__node_my_custom_view_mode', 'node__page', 'node__page__node_my_custom_view_mode', 'node__' . $node->id(), 'node__' . $node->id() . '__node_my_custom_view_mode'], 'Found expected node suggestions.');
}
}
diff --git a/core/modules/node/tests/src/Functional/NodeTestBase.php b/core/modules/node/tests/src/Functional/NodeTestBase.php
index c3b269ecfe8..2341b9eeb61 100644
--- a/core/modules/node/tests/src/Functional/NodeTestBase.php
+++ b/core/modules/node/tests/src/Functional/NodeTestBase.php
@@ -16,7 +16,7 @@ abstract class NodeTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'datetime');
+ public static $modules = ['node', 'datetime'];
/**
* The node access control handler.
@@ -33,12 +33,12 @@ abstract class NodeTestBase extends BrowserTestBase {
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
'display_submitted' => FALSE,
- ));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ ]);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
$this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node');
}
@@ -76,9 +76,9 @@ abstract class NodeTestBase extends BrowserTestBase {
* to check. If NULL, the untranslated (fallback) access is checked.
*/
function assertNodeCreateAccess($bundle, $result, AccountInterface $account, $langcode = NULL) {
- $this->assertEqual($result, $this->accessHandler->createAccess($bundle, $account, array(
+ $this->assertEqual($result, $this->accessHandler->createAccess($bundle, $account, [
'langcode' => $langcode,
- )), $this->nodeAccessAssertMessage('create', $result, $langcode));
+ ]), $this->nodeAccessAssertMessage('create', $result, $langcode));
}
/**
@@ -99,11 +99,11 @@ abstract class NodeTestBase extends BrowserTestBase {
function nodeAccessAssertMessage($operation, $result, $langcode = NULL) {
return format_string(
'Node access returns @result with operation %op, language code %langcode.',
- array(
+ [
'@result' => $result ? 'true' : 'false',
'%op' => $operation,
'%langcode' => !empty($langcode) ? $langcode : 'empty'
- )
+ ]
);
}
diff --git a/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php b/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php
index c1ef6aec3f7..3295e2b20b1 100644
--- a/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php
@@ -16,12 +16,12 @@ class NodeTypeInitialLanguageTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('language', 'field_ui');
+ public static $modules = ['language', 'field_ui'];
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer languages'));
+ $web_user = $this->drupalCreateUser(['bypass node access', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer languages']);
$this->drupalLogin($web_user);
}
@@ -45,20 +45,20 @@ class NodeTypeInitialLanguageTest extends NodeTestBase {
$this->assertNoField('langcode', 'Language is not selectable on node add/edit page by default.');
// Adds a new language and set it as default.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'hu',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
- $edit = array(
+ $edit = [
'site_default_language' => 'hu',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
// Tests the initial language after changing the site default language.
// First unhide the language selector.
- $edit = array(
+ $edit = [
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->drupalGet('node/add/article');
$this->assertField('langcode[0][value]', 'Language is selectable on node add/edit page when language not hidden.');
@@ -78,9 +78,9 @@ class NodeTypeInitialLanguageTest extends NodeTestBase {
$this->assertOptionSelected('edit-fields-langcode-region', 'hidden', 'Language is hidden by default on manage display tab.');
// Changes the initial language settings.
- $edit = array(
+ $edit = [
'language_configuration[langcode]' => 'en',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->drupalGet('node/add/article');
$this->assertOptionSelected('edit-langcode-0-value', 'en', 'The initial language is the defined language.');
@@ -91,35 +91,35 @@ class NodeTypeInitialLanguageTest extends NodeTestBase {
*/
function testLanguageFieldVisibility() {
// Creates a node to test Language field visibility feature.
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(8),
'body[0][value]' => $this->randomMachineName(16),
- );
+ ];
$this->drupalPostForm('node/add/article', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertTrue($node, 'Node found in database.');
// Loads node page and check if Language field is hidden by default.
$this->drupalGet('node/' . $node->id());
- $language_field = $this->xpath('//div[@id=:id]/div', array(
+ $language_field = $this->xpath('//div[@id=:id]/div', [
':id' => 'field-language-display',
- ));
+ ]);
$this->assertTrue(empty($language_field), 'Language field value is not shown by default on node page.');
// Configures Language field formatter and check if it is saved.
- $edit = array(
+ $edit = [
'fields[langcode][type]' => 'language',
'fields[langcode][region]' => 'content',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/article/display', $edit, t('Save'));
$this->drupalGet('admin/structure/types/manage/article/display');
$this->assertOptionSelected('edit-fields-langcode-type', 'language', 'Language field has been set to visible.');
// Loads node page and check if Language field is shown.
$this->drupalGet('node/' . $node->id());
- $language_field = $this->xpath('//div[@id=:id]/div', array(
+ $language_field = $this->xpath('//div[@id=:id]/div', [
':id' => 'field-language-display',
- ));
+ ]);
$this->assertFalse(empty($language_field), 'Language field value is shown on node page.');
}
diff --git a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
index 067decaf93d..07e61a036dd 100644
--- a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
@@ -22,12 +22,12 @@ class NodeTypeTranslationTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'block',
'config_translation',
'field_ui',
'node',
- );
+ ];
/**
* The default language code to use in this test.
@@ -53,14 +53,14 @@ class NodeTypeTranslationTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $admin_permissions = array(
+ $admin_permissions = [
'administer content types',
'administer node fields',
'administer languages',
'administer site configuration',
'administer themes',
'translate configuration',
- );
+ ];
// Create and log in user.
$this->adminUser = $this->drupalCreateUser($admin_permissions);
@@ -93,31 +93,31 @@ class NodeTypeTranslationTest extends BrowserTestBase {
$type = Unicode::strtolower($this->randomMachineName(16));
$name = $this->randomString();
$this->drupalLogin($this->adminUser);
- $this->drupalCreateContentType(array('type' => $type, 'name' => $name));
+ $this->drupalCreateContentType(['type' => $type, 'name' => $name]);
// Translate the node type name.
$langcode = $this->additionalLangcodes[0];
$translated_name = $langcode . '-' . $name;
- $edit = array(
+ $edit = [
"translation[config_names][node.type.$type][name]" => $translated_name,
- );
+ ];
// Edit the title label to avoid having an exception when we save the translation.
$this->drupalPostForm("admin/structure/types/manage/$type/translate/$langcode/add", $edit, t('Save translation'));
// Check the name is translated without admin theme for editing.
- $this->drupalPostForm('admin/appearance', array('use_admin_theme' => '0'), t('Save configuration'));
+ $this->drupalPostForm('admin/appearance', ['use_admin_theme' => '0'], t('Save configuration'));
$this->drupalGet("$langcode/node/add/$type");
// This is a Spanish page, so ensure the text asserted is translated in
// Spanish and not French by adding the langcode option.
- $this->assertRaw(t('Create @name', array('@name' => $translated_name), array('langcode' => $langcode)));
+ $this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
// Check the name is translated with admin theme for editing.
- $this->drupalPostForm('admin/appearance', array('use_admin_theme' => '1'), t('Save configuration'));
+ $this->drupalPostForm('admin/appearance', ['use_admin_theme' => '1'], t('Save configuration'));
$this->drupalGet("$langcode/node/add/$type");
// This is a Spanish page, so ensure the text asserted is translated in
// Spanish and not French by adding the langcode option.
- $this->assertRaw(t('Create @name', array('@name' => $translated_name), array('langcode' => $langcode)));
+ $this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
}
/**
@@ -127,18 +127,18 @@ class NodeTypeTranslationTest extends BrowserTestBase {
$type = Unicode::strtolower($this->randomMachineName(16));
$name = $this->randomString();
$this->drupalLogin($this->adminUser);
- $this->drupalCreateContentType(array('type' => $type, 'name' => $name));
+ $this->drupalCreateContentType(['type' => $type, 'name' => $name]);
$langcode = $this->additionalLangcodes[0];
// Edit the title label for it to be displayed on the translation form.
- $this->drupalPostForm("admin/structure/types/manage/$type", array('title_label' => 'Edited title'), t('Save content type'));
+ $this->drupalPostForm("admin/structure/types/manage/$type", ['title_label' => 'Edited title'], t('Save content type'));
// Assert that the title label is displayed on the translation form with the right value.
$this->drupalGet("admin/structure/types/manage/$type/translate/$langcode/add");
$this->assertText('Edited title');
// Translate the title label.
- $this->drupalPostForm(NULL, array("translation[config_names][core.base_field_override.node.$type.title][label]" => 'Translated title'), t('Save translation'));
+ $this->drupalPostForm(NULL, ["translation[config_names][core.base_field_override.node.$type.title][label]" => 'Translated title'], t('Save translation'));
// Assert that the right title label is displayed on the node add form. The
// translations are created in this test; therefore, the assertions do not
@@ -150,23 +150,23 @@ class NodeTypeTranslationTest extends BrowserTestBase {
$this->assertText('Translated title');
// Add an e-mail field.
- $this->drupalPostForm("admin/structure/types/manage/$type/fields/add-field", array('new_storage_type' => 'email', 'label' => 'Email', 'field_name' => 'email'), 'Save and continue');
- $this->drupalPostForm(NULL, array(), 'Save field settings');
- $this->drupalPostForm(NULL, array(), 'Save settings');
+ $this->drupalPostForm("admin/structure/types/manage/$type/fields/add-field", ['new_storage_type' => 'email', 'label' => 'Email', 'field_name' => 'email'], 'Save and continue');
+ $this->drupalPostForm(NULL, [], 'Save field settings');
+ $this->drupalPostForm(NULL, [], 'Save settings');
$type = Unicode::strtolower($this->randomMachineName(16));
$name = $this->randomString();
- $this->drupalCreateContentType(array('type' => $type, 'name' => $name));
+ $this->drupalCreateContentType(['type' => $type, 'name' => $name]);
// Set tabs.
- $this->drupalPlaceBlock('local_tasks_block', array('primary' => TRUE));
+ $this->drupalPlaceBlock('local_tasks_block', ['primary' => TRUE]);
// Change default language.
- $this->drupalPostForm('admin/config/regional/language', array('site_default_language' => 'es'), 'Save configuration');
+ $this->drupalPostForm('admin/config/regional/language', ['site_default_language' => 'es'], 'Save configuration');
// Try re-using the email field.
$this->drupalGet("es/admin/structure/types/manage/$type/fields/add-field");
- $this->drupalPostForm(NULL, array('existing_storage_name' => 'field_email', 'existing_storage_label' => 'Email'), 'Save and continue');
+ $this->drupalPostForm(NULL, ['existing_storage_name' => 'field_email', 'existing_storage_label' => 'Email'], 'Save and continue');
$this->assertResponse(200);
$this->drupalGet("es/admin/structure/types/manage/$type/fields/node.$type.field_email/translate");
$this->assertResponse(200);
diff --git a/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php b/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php
index 518d5fb6ef8..47304275601 100644
--- a/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php
+++ b/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php
@@ -16,7 +16,7 @@ class NodeViewLanguageTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('node', 'datetime', 'language');
+ public static $modules = ['node', 'datetime', 'language'];
/**
* Tests the language extra field display.
@@ -31,7 +31,7 @@ class NodeViewLanguageTest extends NodeTestBase {
->save();
// Create a node in Spanish.
- $node = $this->drupalCreateNode(array('langcode' => 'es'));
+ $node = $this->drupalCreateNode(['langcode' => 'es']);
$this->drupalGet($node->urlInfo());
$this->assertText('Spanish', 'The language field is displayed properly.');
diff --git a/core/modules/node/tests/src/Functional/PageViewTest.php b/core/modules/node/tests/src/Functional/PageViewTest.php
index ec6dabaedc1..1c6231f7d28 100644
--- a/core/modules/node/tests/src/Functional/PageViewTest.php
+++ b/core/modules/node/tests/src/Functional/PageViewTest.php
@@ -23,7 +23,7 @@ class PageViewTest extends NodeTestBase {
$this->assertResponse(403);
// Create a user without permission to edit node.
- $web_user = $this->drupalCreateUser(array('access content'));
+ $web_user = $this->drupalCreateUser(['access content']);
$this->drupalLogin($web_user);
// Attempt to access edit page.
@@ -31,7 +31,7 @@ class PageViewTest extends NodeTestBase {
$this->assertResponse(403);
// Create user with permission to edit node.
- $web_user = $this->drupalCreateUser(array('bypass node access'));
+ $web_user = $this->drupalCreateUser(['bypass node access']);
$this->drupalLogin($web_user);
// Attempt to access edit page.
diff --git a/core/modules/node/tests/src/Kernel/Config/NodeImportChangeTest.php b/core/modules/node/tests/src/Kernel/Config/NodeImportChangeTest.php
index edb9ae08d62..e1b17f2c1c9 100644
--- a/core/modules/node/tests/src/Kernel/Config/NodeImportChangeTest.php
+++ b/core/modules/node/tests/src/Kernel/Config/NodeImportChangeTest.php
@@ -26,7 +26,7 @@ class NodeImportChangeTest extends KernelTestBase {
parent::setUp();
// Set default storage backend.
- $this->installConfig(array('field', 'node_test_config'));
+ $this->installConfig(['field', 'node_test_config']);
}
/**
diff --git a/core/modules/node/tests/src/Kernel/Config/NodeImportCreateTest.php b/core/modules/node/tests/src/Kernel/Config/NodeImportCreateTest.php
index f4fd1e198c1..cb985173ae9 100644
--- a/core/modules/node/tests/src/Kernel/Config/NodeImportCreateTest.php
+++ b/core/modules/node/tests/src/Kernel/Config/NodeImportCreateTest.php
@@ -18,7 +18,7 @@ class NodeImportCreateTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field', 'text', 'system', 'user');
+ public static $modules = ['node', 'field', 'text', 'system', 'user'];
/**
* Set the default field storage backend for fields created during tests.
@@ -28,7 +28,7 @@ class NodeImportCreateTest extends KernelTestBase {
$this->installEntitySchema('user');
// Set default storage backend.
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
}
/**
@@ -42,7 +42,7 @@ class NodeImportCreateTest extends KernelTestBase {
// Enable node_test_config module and check that the content type
// shipped in the module's default config is created.
- $this->container->get('module_installer')->install(array('node_test_config'));
+ $this->container->get('module_installer')->install(['node_test_config']);
$node_type = NodeType::load($node_type_id);
$this->assertTrue($node_type, 'The default content type was created.');
}
diff --git a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php
index 15b6d77ecd9..1409648536a 100644
--- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php
+++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php
@@ -172,11 +172,11 @@ class MigrateNodeTest extends MigrateNodeTestBase {
$this->assertIdentical('full_html', $node->body->format);
// Now insert a row indicating a failure and set to update later.
- $title = $this->rerunMigration(array(
+ $title = $this->rerunMigration([
'sourceid1' => 2,
'destid1' => NULL,
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
- ));
+ ]);
$node = Node::load(2);
$this->assertIdentical($title, $node->getTitle());
}
@@ -194,10 +194,10 @@ class MigrateNodeTest extends MigrateNodeTestBase {
$title = $this->randomString();
$source_connection = Database::getConnection('default', 'migrate');
$source_connection->update('node_revisions')
- ->fields(array(
+ ->fields([
'title' => $title,
'format' => 2,
- ))
+ ])
->condition('vid', 3)
->execute();
$migration = $this->getMigration('d6_node:story');
diff --git a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTypeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTypeTest.php
index b9845625cce..c9cb341aae2 100644
--- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTypeTest.php
+++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTypeTest.php
@@ -33,7 +33,7 @@ class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
$this->assertIdentical(TRUE, $node_type_page->displaySubmitted());
$this->assertIdentical(FALSE, $node_type_page->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_page->getPreviewMode());
- $this->assertIdentical($id_map->lookupDestinationID(array('test_page')), array('test_page'));
+ $this->assertIdentical($id_map->lookupDestinationID(['test_page']), ['test_page']);
// Test we have a body field.
$field = FieldConfig::loadByName('node', 'test_page', 'body');
@@ -46,7 +46,7 @@ class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
$this->assertIdentical(TRUE, $node_type_story->displaySubmitted());
$this->assertIdentical(FALSE, $node_type_story->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_story->getPreviewMode());
- $this->assertIdentical($id_map->lookupDestinationID(array('test_story')), array('test_story'));
+ $this->assertIdentical($id_map->lookupDestinationID(['test_story']), ['test_story']);
// Test we don't have a body field.
$field = FieldConfig::loadByName('node', 'test_story', 'body');
@@ -59,7 +59,7 @@ class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
$this->assertIdentical(TRUE, $node_type_event->displaySubmitted());
$this->assertIdentical(TRUE, $node_type_event->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_event->getPreviewMode());
- $this->assertIdentical($id_map->lookupDestinationID(array('test_event')), array('test_event'));
+ $this->assertIdentical($id_map->lookupDestinationID(['test_event']), ['test_event']);
// Test we have a body field.
$field = FieldConfig::loadByName('node', 'test_event', 'body');
diff --git a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php
index 5e8eb0a671b..f47559275cd 100644
--- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php
+++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php
@@ -29,7 +29,7 @@ class MigrateViewModesTest extends MigrateDrupal6TestBase {
$this->assertIdentical(FALSE, is_null($view_mode), 'Preview view mode loaded.');
$this->assertIdentical('Preview', $view_mode->label(), 'View mode has correct label.');
// Test the ID map.
- $this->assertIdentical(array('node', 'preview'), $this->getMigration('d6_view_modes')->getIdMap()->lookupDestinationID(array(1)));
+ $this->assertIdentical(['node', 'preview'], $this->getMigration('d6_view_modes')->getIdMap()->lookupDestinationID([1]));
}
}
diff --git a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php
index 8a962e77e56..f7855e8774d 100644
--- a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php
+++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php
@@ -16,7 +16,7 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array(
+ public static $modules = [
'content_translation',
'comment',
'datetime',
@@ -28,7 +28,7 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
'taxonomy',
'telephone',
'text',
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTypeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTypeTest.php
index 8b98ec3048c..549021f0ef6 100644
--- a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTypeTest.php
+++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTypeTest.php
@@ -20,14 +20,14 @@ class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
*
* @var array
*/
- public static $modules = array('node', 'text', 'filter');
+ public static $modules = ['node', 'text', 'filter'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('node'));
+ $this->installConfig(['node']);
$this->executeMigration('d7_node_type');
}
diff --git a/core/modules/node/tests/src/Kernel/NodeAccessTest.php b/core/modules/node/tests/src/Kernel/NodeAccessTest.php
index b8e2251e622..539edcb09b5 100644
--- a/core/modules/node/tests/src/Kernel/NodeAccessTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeAccessTest.php
@@ -73,11 +73,11 @@ class NodeAccessTest extends KernelTestBase {
$this->drupalCreateUser();
// Create a node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
'display_submitted' => FALSE,
- ));
+ ]);
}
/**
diff --git a/core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php b/core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php
index 6c1faf37094..3dd13496d65 100644
--- a/core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php
@@ -28,7 +28,7 @@ class NodeBodyFieldStorageTest extends KernelTestBase {
$this->installSchema('user', 'users_data');
$this->installEntitySchema('user');
$this->installEntitySchema('node');
- $this->installConfig(array('field', 'node'));
+ $this->installConfig(['field', 'node']);
}
/**
@@ -46,7 +46,7 @@ class NodeBodyFieldStorageTest extends KernelTestBase {
$field->delete();
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$this->assertTrue(count($field_storage->getBundles()) == 0, 'Node body field storage exists after deleting the only instance of a field.');
- \Drupal::service('module_installer')->uninstall(array('node'));
+ \Drupal::service('module_installer')->uninstall(['node']);
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$this->assertFalse($field_storage, 'Node body field storage does not exist after uninstalling the Node module.');
}
diff --git a/core/modules/node/tests/src/Kernel/NodeConditionTest.php b/core/modules/node/tests/src/Kernel/NodeConditionTest.php
index 7636d529876..5bf7c731db8 100644
--- a/core/modules/node/tests/src/Kernel/NodeConditionTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeConditionTest.php
@@ -13,7 +13,7 @@ use Drupal\node\Entity\NodeType;
*/
class NodeConditionTest extends EntityKernelTestBase {
- public static $modules = array('node');
+ public static $modules = ['node'];
protected function setUp() {
parent::setUp();
@@ -45,20 +45,20 @@ class NodeConditionTest extends EntityKernelTestBase {
// Grab the node type condition and configure it to check against node type
// of 'article' and set the context to the page type node.
$condition = $manager->createInstance('node_type')
- ->setConfig('bundles', array('article' => 'article'))
+ ->setConfig('bundles', ['article' => 'article'])
->setContextValue('node', $page);
$this->assertFalse($condition->execute(), 'Page type nodes fail node type checks for articles.');
// Check for the proper summary.
$this->assertEqual('The node bundle is article', $condition->summary());
// Set the node type check to page.
- $condition->setConfig('bundles', array('page' => 'page'));
+ $condition->setConfig('bundles', ['page' => 'page']);
$this->assertTrue($condition->execute(), 'Page type nodes pass node type checks for pages');
// Check for the proper summary.
$this->assertEqual('The node bundle is page', $condition->summary());
// Set the node type check to page or article.
- $condition->setConfig('bundles', array('page' => 'page', 'article' => 'article'));
+ $condition->setConfig('bundles', ['page' => 'page', 'article' => 'article']);
$this->assertTrue($condition->execute(), 'Page type nodes pass node type checks for pages or articles');
// Check for the proper summary.
$this->assertEqual('The node bundle is page or article', $condition->summary());
@@ -72,11 +72,11 @@ class NodeConditionTest extends EntityKernelTestBase {
$this->assertFalse($condition->execute(), 'Test type nodes pass node type checks for pages or articles');
// Check a greater than 2 bundles summary scenario.
- $condition->setConfig('bundles', array('page' => 'page', 'article' => 'article', 'test' => 'test'));
+ $condition->setConfig('bundles', ['page' => 'page', 'article' => 'article', 'test' => 'test']);
$this->assertEqual('The node bundle is page, article or test', $condition->summary());
// Test Constructor injection.
- $condition = $manager->createInstance('node_type', array('bundles' => array('article' => 'article'), 'context' => array('node' => $article)));
+ $condition = $manager->createInstance('node_type', ['bundles' => ['article' => 'article'], 'context' => ['node' => $article]]);
$this->assertTrue($condition->execute(), 'Constructor injection of context and configuration working as anticipated.');
}
diff --git a/core/modules/node/tests/src/Kernel/NodeFieldAccessTest.php b/core/modules/node/tests/src/Kernel/NodeFieldAccessTest.php
index f88e45e4aaf..f57768e48df 100644
--- a/core/modules/node/tests/src/Kernel/NodeFieldAccessTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeFieldAccessTest.php
@@ -19,27 +19,27 @@ class NodeFieldAccessTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Fields that only users with administer nodes permissions can change.
*
* @var array
*/
- protected $administrativeFields = array(
+ protected $administrativeFields = [
'status',
'promote',
'sticky',
'created',
'uid',
- );
+ ];
/**
* These fields are automatically managed and can not be changed by any user.
*
* @var array
*/
- protected $readOnlyFields = array('changed', 'revision_uid', 'revision_timestamp');
+ protected $readOnlyFields = ['changed', 'revision_uid', 'revision_timestamp'];
/**
* Test permissions on nodes status field.
@@ -62,74 +62,74 @@ class NodeFieldAccessTest extends EntityKernelTestBase {
// An administrator user. No user exists yet, ensure that the first user
// does not have UID 1.
- $content_admin_user = $this->createUser(array('uid' => 2), array('administer nodes'));
+ $content_admin_user = $this->createUser(['uid' => 2], ['administer nodes']);
// Two different editor users.
- $page_creator_user = $this->createUser(array(), array('create page content', 'edit own page content', 'delete own page content'));
- $page_manager_user = $this->createUser(array(), array('create page content', 'edit any page content', 'delete any page content'));
+ $page_creator_user = $this->createUser([], ['create page content', 'edit own page content', 'delete own page content']);
+ $page_manager_user = $this->createUser([], ['create page content', 'edit any page content', 'delete any page content']);
// An unprivileged user.
- $page_unrelated_user = $this->createUser(array(), array('access content'));
+ $page_unrelated_user = $this->createUser([], ['access content']);
// List of all users
- $test_users = array(
+ $test_users = [
$content_admin_user,
$page_creator_user,
$page_manager_user,
$page_unrelated_user,
- );
+ ];
// Create three "Basic pages". One is owned by our test-user
// "page_creator", one by "page_manager", and one by someone else.
- $node1 = Node::create(array(
+ $node1 = Node::create([
'title' => $this->randomMachineName(8),
'uid' => $page_creator_user->id(),
'type' => 'page',
- ));
- $node2 = Node::create(array(
+ ]);
+ $node2 = Node::create([
'title' => $this->randomMachineName(8),
'uid' => $page_manager_user->id(),
'type' => 'article',
- ));
- $node3 = Node::create(array(
+ ]);
+ $node3 = Node::create([
'title' => $this->randomMachineName(8),
'type' => 'page',
- ));
+ ]);
foreach ($this->administrativeFields as $field) {
// Checks on view operations.
foreach ($test_users as $account) {
$may_view = $node1->{$field}->access('view', $account);
- $this->assertTrue($may_view, SafeMarkup::format('Any user may view the field @name.', array('@name' => $field)));
+ $this->assertTrue($may_view, SafeMarkup::format('Any user may view the field @name.', ['@name' => $field]));
}
// Checks on edit operations.
$may_update = $node1->{$field}->access('edit', $page_creator_user);
- $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit own page content" is not allowed to the field @name.', array('@name' => $field)));
+ $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit own page content" is not allowed to the field @name.', ['@name' => $field]));
$may_update = $node2->{$field}->access('edit', $page_creator_user);
- $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit own page content" is not allowed to the field @name.', array('@name' => $field)));
+ $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit own page content" is not allowed to the field @name.', ['@name' => $field]));
$may_update = $node2->{$field}->access('edit', $page_manager_user);
- $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
+ $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit any page content" is not allowed to the field @name.', ['@name' => $field]));
$may_update = $node1->{$field}->access('edit', $page_manager_user);
- $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
+ $this->assertFalse($may_update, SafeMarkup::format('Users with permission "edit any page content" is not allowed to the field @name.', ['@name' => $field]));
$may_update = $node2->{$field}->access('edit', $page_unrelated_user);
- $this->assertFalse($may_update, SafeMarkup::format('Users not having permission "edit any page content" is not allowed to the field @name.', array('@name' => $field)));
+ $this->assertFalse($may_update, SafeMarkup::format('Users not having permission "edit any page content" is not allowed to the field @name.', ['@name' => $field]));
$may_update = $node1->{$field}->access('edit', $content_admin_user) && $node3->status->access('edit', $content_admin_user);
- $this->assertTrue($may_update, SafeMarkup::format('Users with permission "administer nodes" may edit @name fields on all nodes.', array('@name' => $field)));
+ $this->assertTrue($may_update, SafeMarkup::format('Users with permission "administer nodes" may edit @name fields on all nodes.', ['@name' => $field]));
}
foreach ($this->readOnlyFields as $field) {
// Check view operation.
foreach ($test_users as $account) {
$may_view = $node1->{$field}->access('view', $account);
- $this->assertTrue($may_view, SafeMarkup::format('Any user may view the field @name.', array('@name' => $field)));
+ $this->assertTrue($may_view, SafeMarkup::format('Any user may view the field @name.', ['@name' => $field]));
}
// Check edit operation.
foreach ($test_users as $account) {
$may_view = $node1->{$field}->access('edit', $account);
- $this->assertFalse($may_view, SafeMarkup::format('No user is not allowed to edit the field @name.', array('@name' => $field)));
+ $this->assertFalse($may_view, SafeMarkup::format('No user is not allowed to edit the field @name.', ['@name' => $field]));
}
}
diff --git a/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php b/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php
index aee02728ec8..7c7bc033488 100644
--- a/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php
@@ -27,14 +27,14 @@ class NodeFieldOverridesTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('user', 'system', 'field', 'node');
+ public static $modules = ['user', 'system', 'field', 'node'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('user'));
+ $this->installConfig(['user']);
$this->user = $this->createUser();
\Drupal::service('current_user')->setAccount($this->user);
}
diff --git a/core/modules/node/tests/src/Kernel/NodeOwnerTest.php b/core/modules/node/tests/src/Kernel/NodeOwnerTest.php
index d21d5ad046d..c12f3115c16 100644
--- a/core/modules/node/tests/src/Kernel/NodeOwnerTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeOwnerTest.php
@@ -19,16 +19,16 @@ class NodeOwnerTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('node', 'language');
+ public static $modules = ['node', 'language'];
protected function setUp() {
parent::setUp();
// Create the node bundles required for testing.
- $type = NodeType::create(array(
+ $type = NodeType::create([
'type' => 'page',
'name' => 'page',
- ));
+ ]);
$type->save();
// Enable two additional languages.
@@ -48,11 +48,11 @@ class NodeOwnerTest extends EntityKernelTestBase {
$container->get('current_user')->setAccount($user);
// Create a test node.
- $english = Node::create(array(
+ $english = Node::create([
'type' => 'page',
'title' => $this->randomMachineName(),
'language' => 'en',
- ));
+ ]);
$english->save();
$this->assertEqual($user->id(), $english->getOwnerId());
diff --git a/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php b/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php
index c496c83b292..829bf4d4f07 100644
--- a/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php
@@ -22,14 +22,14 @@ class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
*
* @var array
*/
- public static $modules = array('node', 'filter');
+ public static $modules = ['node', 'filter'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('filter', 'node'));
+ $this->installConfig(['filter', 'node']);
$node_type = NodeType::create(['type' => 'article', 'name' => 'Article']);
$node_type->save();
@@ -40,10 +40,10 @@ class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
* Creates a node, then tests the tokens generated from it.
*/
function testNodeTokenReplacement() {
- $url_options = array(
+ $url_options = [
'absolute' => TRUE,
'language' => $this->interfaceLanguage,
- );
+ ];
// Create a user and a node.
$account = $this->createUser();
@@ -58,7 +58,7 @@ class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
$node->save();
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$tests['[node:nid]'] = $node->id();
$tests['[node:vid]'] = $node->getRevisionId();
$tests['[node:type]'] = 'article';
@@ -72,8 +72,8 @@ class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
$tests['[node:author]'] = $account->getUsername();
$tests['[node:author:uid]'] = $node->getOwnerId();
$tests['[node:author:name]'] = $account->getUsername();
- $tests['[node:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($node->getCreatedTime(), array('langcode' => $this->interfaceLanguage->getId()));
- $tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($node->getChangedTime(), array('langcode' => $this->interfaceLanguage->getId()));
+ $tests['[node:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($node->getCreatedTime(), ['langcode' => $this->interfaceLanguage->getId()]);
+ $tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($node->getChangedTime(), ['langcode' => $this->interfaceLanguage->getId()]);
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($node);
@@ -101,7 +101,7 @@ class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata);
+ $output = $this->tokenService->replace($input, ['node' => $node], ['langcode' => $this->interfaceLanguage->getId()], $bubbleable_metadata);
$this->assertEqual($output, $expected, format_string('Node token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
@@ -116,14 +116,14 @@ class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
$node->save();
// Generate and test token - use full body as expected value.
- $tests = array();
+ $tests = [];
$tests['[node:summary]'] = $node->body->processed;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.');
foreach ($tests as $input => $expected) {
- $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage));
+ $output = $this->tokenService->replace($input, ['node' => $node], ['language' => $this->interfaceLanguage]);
$this->assertEqual($output, $expected, new FormattableMarkup('Node token %token replaced for node without a summary.', ['%token' => $input]));
}
}
diff --git a/core/modules/node/tests/src/Kernel/NodeValidationTest.php b/core/modules/node/tests/src/Kernel/NodeValidationTest.php
index 9fd646e61a9..e111faeaef7 100644
--- a/core/modules/node/tests/src/Kernel/NodeValidationTest.php
+++ b/core/modules/node/tests/src/Kernel/NodeValidationTest.php
@@ -18,7 +18,7 @@ class NodeValidationTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Set the default field storage backend for fields created during tests.
diff --git a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php
index 6b28409e92d..eb92f8cb0a9 100644
--- a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php
+++ b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php
@@ -25,7 +25,7 @@ class NodeBulkFormTest extends UnitTestCase {
* Tests the constructor assignment of actions.
*/
public function testConstructor() {
- $actions = array();
+ $actions = [];
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
@@ -60,7 +60,7 @@ class NodeBulkFormTest extends UnitTestCase {
$views_data->expects($this->any())
->method('get')
->with('node')
- ->will($this->returnValue(array('table' => array('entity type' => 'node'))));
+ ->will($this->returnValue(['table' => ['entity type' => 'node']]));
$container = new ContainerBuilder();
$container->set('views.views_data', $views_data);
$container->set('string_translation', $this->getStringTranslationStub());
@@ -82,9 +82,9 @@ class NodeBulkFormTest extends UnitTestCase {
->getMock();
$definition['title'] = '';
- $options = array();
+ $options = [];
- $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_manager, $language_manager);
+ $node_bulk_form = new NodeBulkForm([], 'node_bulk_form', $definition, $entity_manager, $language_manager);
$node_bulk_form->init($executable, $display, $options);
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
diff --git a/core/modules/options/options.api.php b/core/modules/options/options.api.php
index 28ac77114ed..0f52b2befa9 100644
--- a/core/modules/options/options.api.php
+++ b/core/modules/options/options.api.php
@@ -81,21 +81,21 @@ function hook_options_list_alter(array &$options, array $context) {
*/
function callback_allowed_values_function(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = TRUE) {
if (isset($entity) && ($entity->bundle() == 'not_a_programmer')) {
- $values = array(
+ $values = [
1 => 'One',
2 => 'Two',
- );
+ ];
}
else {
- $values = array(
- 'Group 1' => array(
+ $values = [
+ 'Group 1' => [
0 => 'Zero',
1 => 'One',
- ),
- 'Group 2' => array(
+ ],
+ 'Group 2' => [
2 => 'Two',
- ),
- );
+ ],
+ ];
}
return $values;
diff --git a/core/modules/options/options.module b/core/modules/options/options.module
index 2041607654e..7cf36355293 100644
--- a/core/modules/options/options.module
+++ b/core/modules/options/options.module
@@ -19,11 +19,11 @@ function options_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.options':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Options module allows you to create fields where data values are selected from a fixed list of options. Usually these items are entered through a select list, checkboxes, or radio buttons. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":options_do">online documentation for the Options module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':options_do' => 'https://www.drupal.org/documentation/modules/options')) . '</p>';
+ $output .= '<p>' . t('The Options module allows you to create fields where data values are selected from a fixed list of options. Usually these items are entered through a select list, checkboxes, or radio buttons. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":options_do">online documentation for the Options module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':options_do' => 'https://www.drupal.org/documentation/modules/options']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying list fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the list fields can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the list fields can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Defining option keys and labels') . '</dt>';
$output .= '<dd>' . t('When you define the list options you can define a key and a label for each option in the list. The label will be shown to the users while the key gets stored in the database.') . '</dd>';
$output .= '<dt>' . t('Choosing list field type') . '</dt>';
@@ -70,9 +70,9 @@ function options_field_storage_config_delete(FieldStorageConfigInterface $field_
* @see callback_allowed_values_function()
*/
function options_allowed_values(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL) {
- $allowed_values = &drupal_static(__FUNCTION__, array());
+ $allowed_values = &drupal_static(__FUNCTION__, []);
- $cache_keys = array($definition->getTargetEntityTypeId(), $definition->getName());
+ $cache_keys = [$definition->getTargetEntityTypeId(), $definition->getName()];
if ($entity) {
$cache_keys[] = 'entity';
}
@@ -112,7 +112,7 @@ function options_field_storage_config_update_forbid(FieldStorageConfigInterface
$prior_allowed_values = $prior_field_storage->getSetting('allowed_values');
$lost_keys = array_keys(array_diff_key($prior_allowed_values, $allowed_values));
if (_options_values_in_use($field_storage->getTargetEntityTypeId(), $field_storage->getName(), $lost_keys)) {
- throw new FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
+ throw new FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', ['@field_name' => $field_storage->getName()]));
}
}
}
diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php
index bc1dba19c29..ba1ba9c2b3c 100644
--- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php
+++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php
@@ -29,7 +29,7 @@ class OptionsDefaultFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
// Only collect allowed options if there are actually items to display.
if ($items->count()) {
@@ -44,10 +44,10 @@ class OptionsDefaultFormatter extends FormatterBase {
// If the stored value is in the current set of allowed values, display
// the associated label, otherwise just display the raw value.
$output = isset($options[$value]) ? $options[$value] : $value;
- $elements[$delta] = array(
+ $elements[$delta] = [
'#markup' => $output,
'#allowed_tags' => FieldFilteredMarkup::allowedTags(),
- );
+ ];
}
}
diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php
index 2b83b15066c..64f22e9b442 100644
--- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php
+++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php
@@ -28,13 +28,13 @@ class OptionsKeyFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($items as $delta => $item) {
- $elements[$delta] = array(
+ $elements[$delta] = [
'#markup' => $item->value,
'#allowed_tags' => FieldFilteredMarkup::allowedTags(),
- );
+ ];
}
return $elements;
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
index 254207d5eb4..416f7dc2ec6 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
@@ -34,16 +34,16 @@ class ListFloatItem extends ListItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'float',
- ),
- ),
- 'indexes' => array(
- 'value' => array('value'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'value' => ['value'],
+ ],
+ ];
}
/**
@@ -55,7 +55,7 @@ class ListFloatItem extends ListItemBase {
$description .= '<br/>' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
$description .= '<br/>' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
$description .= '</p>';
- $description .= '<p>' . t('Allowed HTML tags in labels: @tags', array('@tags' => $this->displayAllowedTags())) . '</p>';
+ $description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '</p>';
return $description;
}
@@ -90,7 +90,7 @@ class ListFloatItem extends ListItemBase {
* {@inheritdoc}
*/
public static function simplifyAllowedValues(array $structured_values) {
- $values = array();
+ $values = [];
foreach ($structured_values as $item) {
// Nested elements are embedded in the label.
if (is_array($item['label'])) {
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php
index 719ae487153..b8a4204806b 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php
@@ -34,16 +34,16 @@ class ListIntegerItem extends ListItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
- ),
- ),
- 'indexes' => array(
- 'value' => array('value'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'value' => ['value'],
+ ],
+ ];
}
/**
@@ -55,7 +55,7 @@ class ListIntegerItem extends ListItemBase {
$description .= '<br/>' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
$description .= '<br/>' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
$description .= '</p>';
- $description .= '<p>' . t('Allowed HTML tags in labels: @tags', array('@tags' => $this->displayAllowedTags())) . '</p>';
+ $description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '</p>';
return $description;
}
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
index 4527ca361ca..c7c2b16e9b5 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
@@ -21,10 +21,10 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
- 'allowed_values' => array(),
+ return [
+ 'allowed_values' => [],
'allowed_values_function' => '',
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
@@ -85,28 +85,28 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
$allowed_values = $this->getSetting('allowed_values');
$allowed_values_function = $this->getSetting('allowed_values_function');
- $element['allowed_values'] = array(
+ $element['allowed_values'] = [
'#type' => 'textarea',
'#title' => t('Allowed values list'),
'#default_value' => $this->allowedValuesString($allowed_values),
'#rows' => 10,
'#access' => empty($allowed_values_function),
- '#element_validate' => array(array(get_class($this), 'validateAllowedValues')),
+ '#element_validate' => [[get_class($this), 'validateAllowedValues']],
'#field_has_data' => $has_data,
'#field_name' => $this->getFieldDefinition()->getName(),
'#entity_type' => $this->getEntity()->getEntityTypeId(),
'#allowed_values' => $allowed_values,
- );
+ ];
$element['allowed_values']['#description'] = $this->allowedValuesDescription();
- $element['allowed_values_function'] = array(
+ $element['allowed_values_function'] = [
'#type' => 'item',
'#title' => t('Allowed values list'),
- '#markup' => t('The value of this field is being determined by the %function function and may not be changed.', array('%function' => $allowed_values_function)),
+ '#markup' => t('The value of this field is being determined by the %function function and may not be changed.', ['%function' => $allowed_values_function]),
'#access' => !empty($allowed_values_function),
'#value' => $allowed_values_function,
- );
+ ];
return $element;
}
@@ -171,7 +171,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
* @see \Drupal\options\Plugin\Field\FieldType\ListItemBase::allowedValuesString()
*/
protected static function extractAllowedValues($string, $has_data) {
- $values = array();
+ $values = [];
$list = explode("\n", $string);
$list = array_map('trim', $list);
@@ -180,7 +180,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
$generated_keys = $explicit_keys = FALSE;
foreach ($list as $position => $text) {
// Check for an explicit key.
- $matches = array();
+ $matches = [];
if (preg_match('/(.*)\|(.*)/', $text, $matches)) {
// Trim key and value to avoid unwanted spaces issues.
$key = trim($matches[1]);
@@ -239,7 +239,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
* - Each value is in the format "value|label" or "value".
*/
protected function allowedValuesString($values) {
- $lines = array();
+ $lines = [];
foreach ($values as $key => $value) {
$lines[] = "$key|$value";
}
@@ -280,7 +280,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
* @see \Drupal\options\Plugin\Field\FieldType\ListItemBase::structureAllowedValues()
*/
protected static function simplifyAllowedValues(array $structured_values) {
- $values = array();
+ $values = [];
foreach ($structured_values as $item) {
if (is_array($item['label'])) {
// Nested elements are embedded in the label.
@@ -305,15 +305,15 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
* @see \Drupal\options\Plugin\Field\FieldType\ListItemBase::simplifyAllowedValues()
*/
protected static function structureAllowedValues(array $values) {
- $structured_values = array();
+ $structured_values = [];
foreach ($values as $value => $label) {
if (is_array($label)) {
$label = static::structureAllowedValues($label);
}
- $structured_values[] = array(
+ $structured_values[] = [
'value' => static::castAllowedValue($value),
'label' => $label,
- );
+ ];
}
return $structured_values;
}
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
index f5440ab312e..1f8caeaf361 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
@@ -26,7 +26,7 @@ class ListStringItem extends ListItemBase {
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['value'] = DataDefinition::create('string')
->setLabel(t('Text value'))
- ->addConstraint('Length', array('max' => 255))
+ ->addConstraint('Length', ['max' => 255])
->setRequired(TRUE);
return $properties;
@@ -36,17 +36,17 @@ class ListStringItem extends ListItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => 255,
- ),
- ),
- 'indexes' => array(
- 'value' => array('value'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'value' => ['value'],
+ ],
+ ];
}
/**
@@ -57,7 +57,7 @@ class ListStringItem extends ListItemBase {
$description .= '<br/>' . t('The key is the stored value. The label will be used in displayed values and edit forms.');
$description .= '<br/>' . t('The label is optional: if a line contains a single string, it will be used as key and label.');
$description .= '</p>';
- $description .= '<p>' . t('Allowed HTML tags in labels: @tags', array('@tags' => $this->displayAllowedTags())) . '</p>';
+ $description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '</p>';
return $description;
}
diff --git a/core/modules/options/src/Tests/OptionsDynamicValuesApiTest.php b/core/modules/options/src/Tests/OptionsDynamicValuesApiTest.php
index 081696a696e..c4215835fd6 100644
--- a/core/modules/options/src/Tests/OptionsDynamicValuesApiTest.php
+++ b/core/modules/options/src/Tests/OptionsDynamicValuesApiTest.php
@@ -21,12 +21,12 @@ class OptionsDynamicValuesApiTest extends OptionsDynamicValuesTestBase {
$values = options_allowed_values($this->fieldStorage, $this->entity);
- $expected_values = array(
+ $expected_values = [
$this->entity->label(),
$this->entity->url(),
$this->entity->uuid(),
$this->entity->bundle(),
- );
+ ];
$expected_values = array_combine($expected_values, $expected_values);
$this->assertEqual($expected_values, $values);
}
diff --git a/core/modules/options/src/Tests/OptionsFieldUITest.php b/core/modules/options/src/Tests/OptionsFieldUITest.php
index ee6cf2ef77a..76e076e5867 100644
--- a/core/modules/options/src/Tests/OptionsFieldUITest.php
+++ b/core/modules/options/src/Tests/OptionsFieldUITest.php
@@ -18,7 +18,7 @@ class OptionsFieldUITest extends FieldTestBase {
*
* @var array
*/
- public static $modules = array('node', 'options', 'field_test', 'taxonomy', 'field_ui');
+ public static $modules = ['node', 'options', 'field_test', 'taxonomy', 'field_ui'];
/**
* The name of the created content type.
@@ -70,15 +70,15 @@ class OptionsFieldUITest extends FieldTestBase {
// Flat list of textual values.
$string = "Zero\nOne";
- $array = array('0' => 'Zero', '1' => 'One');
+ $array = ['0' => 'Zero', '1' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
// Explicit integer keys.
$string = "0|Zero\n2|Two";
- $array = array('0' => 'Zero', '2' => 'Two');
+ $array = ['0' => 'Zero', '2' => 'Two'];
$this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.');
// Check that values can be added and removed.
$string = "0|Zero\n1|One";
- $array = array('0' => 'Zero', '1' => 'One');
+ $array = ['0' => 'Zero', '1' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
// Non-integer keys.
$this->assertAllowedValuesInput("1.1|One", 'keys must be integers', 'Non integer keys are rejected.');
@@ -87,10 +87,10 @@ class OptionsFieldUITest extends FieldTestBase {
$this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', 'Mixed lists are rejected.');
// Create a node with actual data for the field.
- $settings = array(
+ $settings = [
'type' => $this->type,
- $this->fieldName => array(array('value' => 1)),
- );
+ $this->fieldName => [['value' => 1]],
+ ];
$node = $this->drupalCreateNode($settings);
// Check that a flat list of values is rejected once the field has data.
@@ -98,22 +98,22 @@ class OptionsFieldUITest extends FieldTestBase {
// Check that values can be added but values in use cannot be removed.
$string = "0|Zero\n1|One\n2|Two";
- $array = array('0' => 'Zero', '1' => 'One', '2' => 'Two');
+ $array = ['0' => 'Zero', '1' => 'One', '2' => 'Two'];
$this->assertAllowedValuesInput($string, $array, 'Values can be added.');
$string = "0|Zero\n1|One";
- $array = array('0' => 'Zero', '1' => 'One');
+ $array = ['0' => 'Zero', '1' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
// Delete the node, remove the value.
$node->delete();
$string = "0|Zero";
- $array = array('0' => 'Zero');
+ $array = ['0' => 'Zero'];
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
// Check that the same key can only be used once.
$string = "0|Zero\n0|One";
- $array = array('0' => 'One');
+ $array = ['0' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Same value cannot be used multiple times.');
}
@@ -126,15 +126,15 @@ class OptionsFieldUITest extends FieldTestBase {
// Flat list of textual values.
$string = "Zero\nOne";
- $array = array('0' => 'Zero', '1' => 'One');
+ $array = ['0' => 'Zero', '1' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
// Explicit numeric keys.
$string = "0|Zero\n.5|Point five";
- $array = array('0' => 'Zero', '0.5' => 'Point five');
+ $array = ['0' => 'Zero', '0.5' => 'Point five'];
$this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.');
// Check that values can be added and removed.
$string = "0|Zero\n.5|Point five\n1.0|One";
- $array = array('0' => 'Zero', '0.5' => 'Point five', '1' => 'One');
+ $array = ['0' => 'Zero', '0.5' => 'Point five', '1' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
// Non-numeric keys.
$this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', 'Non numeric keys are rejected.');
@@ -142,10 +142,10 @@ class OptionsFieldUITest extends FieldTestBase {
$this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', 'Mixed lists are rejected.');
// Create a node with actual data for the field.
- $settings = array(
+ $settings = [
'type' => $this->type,
- $this->fieldName => array(array('value' => .5)),
- );
+ $this->fieldName => [['value' => .5]],
+ ];
$node = $this->drupalCreateNode($settings);
// Check that a flat list of values is rejected once the field has data.
@@ -153,27 +153,27 @@ class OptionsFieldUITest extends FieldTestBase {
// Check that values can be added but values in use cannot be removed.
$string = "0|Zero\n.5|Point five\n2|Two";
- $array = array('0' => 'Zero', '0.5' => 'Point five', '2' => 'Two');
+ $array = ['0' => 'Zero', '0.5' => 'Point five', '2' => 'Two'];
$this->assertAllowedValuesInput($string, $array, 'Values can be added.');
$string = "0|Zero\n.5|Point five";
- $array = array('0' => 'Zero', '0.5' => 'Point five');
+ $array = ['0' => 'Zero', '0.5' => 'Point five'];
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
// Delete the node, remove the value.
$node->delete();
$string = "0|Zero";
- $array = array('0' => 'Zero');
+ $array = ['0' => 'Zero'];
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
// Check that the same key can only be used once.
$string = "0.5|Point five\n0.5|Half";
- $array = array('0.5' => 'Half');
+ $array = ['0.5' => 'Half'];
$this->assertAllowedValuesInput($string, $array, 'Same value cannot be used multiple times.');
// Check that different forms of the same float value cannot be used.
$string = "0|Zero\n.5|Point five\n0.5|Half";
- $array = array('0' => 'Zero', '0.5' => 'Half');
+ $array = ['0' => 'Zero', '0.5' => 'Half'];
$this->assertAllowedValuesInput($string, $array, 'Different forms of the same value cannot be used.');
}
@@ -186,59 +186,59 @@ class OptionsFieldUITest extends FieldTestBase {
// Flat list of textual values.
$string = "Zero\nOne";
- $array = array('Zero' => 'Zero', 'One' => 'One');
+ $array = ['Zero' => 'Zero', 'One' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
// Explicit keys.
$string = "zero|Zero\none|One";
- $array = array('zero' => 'Zero', 'one' => 'One');
+ $array = ['zero' => 'Zero', 'one' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Explicit keys are accepted.');
// Check that values can be added and removed.
$string = "zero|Zero\ntwo|Two";
- $array = array('zero' => 'Zero', 'two' => 'Two');
+ $array = ['zero' => 'Zero', 'two' => 'Two'];
$this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
// Mixed list of keyed and unkeyed values.
$string = "zero|Zero\nOne\n";
- $array = array('zero' => 'Zero', 'One' => 'One');
+ $array = ['zero' => 'Zero', 'One' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Mixed lists are accepted.');
// Overly long keys.
$this->assertAllowedValuesInput("zero|Zero\n" . $this->randomMachineName(256) . "|One", 'each key must be a string at most 255 characters long', 'Overly long keys are rejected.');
// Create a node with actual data for the field.
- $settings = array(
+ $settings = [
'type' => $this->type,
- $this->fieldName => array(array('value' => 'One')),
- );
+ $this->fieldName => [['value' => 'One']],
+ ];
$node = $this->drupalCreateNode($settings);
// Check that flat lists of values are still accepted once the field has
// data.
$string = "Zero\nOne";
- $array = array('Zero' => 'Zero', 'One' => 'One');
+ $array = ['Zero' => 'Zero', 'One' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are still accepted once the field has data.');
// Check that values can be added but values in use cannot be removed.
$string = "Zero\nOne\nTwo";
- $array = array('Zero' => 'Zero', 'One' => 'One', 'Two' => 'Two');
+ $array = ['Zero' => 'Zero', 'One' => 'One', 'Two' => 'Two'];
$this->assertAllowedValuesInput($string, $array, 'Values can be added.');
$string = "Zero\nOne";
- $array = array('Zero' => 'Zero', 'One' => 'One');
+ $array = ['Zero' => 'Zero', 'One' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
$this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
// Delete the node, remove the value.
$node->delete();
$string = "Zero";
- $array = array('Zero' => 'Zero');
+ $array = ['Zero' => 'Zero'];
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
// Check that string values with dots can be used.
$string = "Zero\nexample.com|Example";
- $array = array('Zero' => 'Zero', 'example.com' => 'Example');
+ $array = ['Zero' => 'Zero', 'example.com' => 'Example'];
$this->assertAllowedValuesInput($string, $array, 'String value with dot is supported.');
// Check that the same key can only be used once.
$string = "zero|Zero\nzero|One";
- $array = array('zero' => 'One');
+ $array = ['zero' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Same value cannot be used multiple times.');
}
@@ -251,7 +251,7 @@ class OptionsFieldUITest extends FieldTestBase {
// Explicit keys.
$string = "zero |Zero\none | One";
- $array = array('zero' => 'Zero', 'one' => 'One');
+ $array = ['zero' => 'Zero', 'one' => 'One'];
$this->assertAllowedValuesInput($string, $array, 'Explicit keys are accepted and trimmed.');
}
@@ -263,11 +263,11 @@ class OptionsFieldUITest extends FieldTestBase {
*/
protected function createOptionsField($type) {
// Create a field.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => $type,
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
@@ -292,7 +292,7 @@ class OptionsFieldUITest extends FieldTestBase {
* Message to display.
*/
function assertAllowedValuesInput($input_string, $result, $message) {
- $edit = array('settings[allowed_values]' => $input_string);
+ $edit = ['settings[allowed_values]' => $input_string];
$this->drupalPostForm($this->adminPath, $edit, t('Save field settings'));
$this->assertNoRaw('&amp;lt;', 'The page does not have double escaped HTML tags.');
@@ -311,32 +311,32 @@ class OptionsFieldUITest extends FieldTestBase {
function testNodeDisplay() {
$this->fieldName = strtolower($this->randomMachineName());
$this->createOptionsField('list_integer');
- $node = $this->drupalCreateNode(array('type' => $this->type));
+ $node = $this->drupalCreateNode(['type' => $this->type]);
$on = $this->randomMachineName();
$off = $this->randomMachineName();
- $edit = array(
+ $edit = [
'settings[allowed_values]' =>
"1|$on
0|$off",
- );
+ ];
$this->drupalPostForm($this->adminPath, $edit, t('Save field settings'));
- $this->assertText(format_string('Updated field @field_name field settings.', array('@field_name' => $this->fieldName)), "The 'On' and 'Off' form fields work for boolean fields.");
+ $this->assertText(format_string('Updated field @field_name field settings.', ['@field_name' => $this->fieldName]), "The 'On' and 'Off' form fields work for boolean fields.");
// Select a default value.
- $edit = array(
+ $edit = [
$this->fieldName => '1',
- );
+ ];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
// Check the node page and see if the values are correct.
- $file_formatters = array('list_default', 'list_key');
+ $file_formatters = ['list_default', 'list_key'];
foreach ($file_formatters as $formatter) {
- $edit = array(
+ $edit = [
"fields[$this->fieldName][type]" => $formatter,
"fields[$this->fieldName][region]" => 'content',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $this->typeName . '/display', $edit, t('Save'));
$this->drupalGet('node/' . $node->id());
diff --git a/core/modules/options/src/Tests/OptionsFloatFieldImportTest.php b/core/modules/options/src/Tests/OptionsFloatFieldImportTest.php
index 7b642e8f18f..5a2f20b24ad 100644
--- a/core/modules/options/src/Tests/OptionsFloatFieldImportTest.php
+++ b/core/modules/options/src/Tests/OptionsFloatFieldImportTest.php
@@ -18,13 +18,13 @@ class OptionsFloatFieldImportTest extends FieldTestBase {
*
* @var array
*/
- public static $modules = array('node', 'options', 'field_ui', 'config', 'options_config_install_test');
+ public static $modules = ['node', 'options', 'field_ui', 'config', 'options_config_install_test'];
protected function setUp() {
parent::setUp();
// Create test user.
- $admin_user = $this->drupalCreateUser(array('synchronize configuration', 'access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'bypass node access', 'administer node fields', 'administer node display'));
+ $admin_user = $this->drupalCreateUser(['synchronize configuration', 'access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'bypass node access', 'administer node fields', 'administer node display']);
$this->drupalLogin($admin_user);
}
@@ -39,7 +39,7 @@ class OptionsFloatFieldImportTest extends FieldTestBase {
// necessary configuration for this test is created by installing that
// module.
$field_storage = FieldStorageConfig::loadByName('node', $field_name);
- $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = array('0' => 'Zero', '0.5' => 'Point five'));
+ $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = ['0' => 'Zero', '0.5' => 'Point five']);
$admin_path = 'admin/structure/types/manage/' . $type . '/fields/node.' . $type . '.' . $field_name . '/storage';
@@ -47,26 +47,26 @@ class OptionsFloatFieldImportTest extends FieldTestBase {
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
// Set the active to not use dots in the allowed values key names.
- $edit = array('settings[allowed_values]' => "0|Zero\n1|One");
+ $edit = ['settings[allowed_values]' => "0|Zero\n1|One"];
$this->drupalPostForm($admin_path, $edit, t('Save field settings'));
$field_storage = FieldStorageConfig::loadByName('node', $field_name);
- $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = array('0' => 'Zero', '1' => 'One'));
+ $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = ['0' => 'Zero', '1' => 'One']);
// Import configuration with dots in the allowed values key names. This
// tests \Drupal\Core\Config\Entity\ConfigEntityStorage::importUpdate().
$this->drupalGet('admin/config/development/configuration');
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$field_storage = FieldStorageConfig::loadByName('node', $field_name);
- $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = array('0' => 'Zero', '0.5' => 'Point five'));
+ $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = ['0' => 'Zero', '0.5' => 'Point five']);
// Delete field to test creation. This tests
// \Drupal\Core\Config\Entity\ConfigEntityStorage::importCreate().
FieldConfig::loadByName('node', $type, $field_name)->delete();
$this->drupalGet('admin/config/development/configuration');
- $this->drupalPostForm(NULL, array(), t('Import all'));
+ $this->drupalPostForm(NULL, [], t('Import all'));
$field_storage = FieldStorageConfig::loadByName('node', $field_name);
- $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = array('0' => 'Zero', '0.5' => 'Point five'));
+ $this->assertIdentical($field_storage->getSetting('allowed_values'), $array = ['0' => 'Zero', '0.5' => 'Point five']);
}
}
diff --git a/core/modules/options/src/Tests/OptionsSelectDynamicValuesTest.php b/core/modules/options/src/Tests/OptionsSelectDynamicValuesTest.php
index df3365ca075..72c0d55fdc6 100644
--- a/core/modules/options/src/Tests/OptionsSelectDynamicValuesTest.php
+++ b/core/modules/options/src/Tests/OptionsSelectDynamicValuesTest.php
@@ -16,7 +16,7 @@ class OptionsSelectDynamicValuesTest extends OptionsDynamicValuesTestBase {
$this->entity->save();
// Create a web user.
- $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content'));
+ $web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$this->drupalLogin($web_user);
// Display form.
diff --git a/core/modules/options/src/Tests/OptionsWidgetsTest.php b/core/modules/options/src/Tests/OptionsWidgetsTest.php
index 23f0f0da2dc..8a907c20603 100644
--- a/core/modules/options/src/Tests/OptionsWidgetsTest.php
+++ b/core/modules/options/src/Tests/OptionsWidgetsTest.php
@@ -114,9 +114,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertRaw('Some HTML encoded markup with &lt; &amp; &gt;');
// Select first option.
- $edit = array('card_1' => 0);
+ $edit = ['card_1' => 0];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_1', array(0));
+ $this->assertFieldValues($entity_init, 'card_1', [0]);
// Check that the selected button is checked.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
@@ -125,9 +125,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertNoFieldChecked('edit-card-1-2');
// Unselect option.
- $edit = array('card_1' => '_none');
+ $edit = ['card_1' => '_none'];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_1', array());
+ $this->assertFieldValues($entity_init, 'card_1', []);
// Check that required radios with one option is auto-selected.
$this->card1->setSetting('allowed_values', [99 => 'Only allowed value']);
@@ -149,16 +149,16 @@ class OptionsWidgetsTest extends FieldTestBase {
]);
$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($this->card2->getName(), array(
+ ->setComponent($this->card2->getName(), [
'type' => 'options_buttons',
- ))
+ ])
->save();
// Create an entity.
- $entity = EntityTest::create(array(
+ $entity = EntityTest::create([
'user_id' => 1,
'name' => $this->randomMachineName(),
- ));
+ ]);
$entity->save();
$entity_init = clone $entity;
@@ -170,13 +170,13 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
// Submit form: select first and third options.
- $edit = array(
+ $edit = [
'card_2[0]' => TRUE,
'card_2[1]' => FALSE,
'card_2[2]' => TRUE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array(0, 2));
+ $this->assertFieldValues($entity_init, 'card_2', [0, 2]);
// Display form: check that the right options are selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
@@ -185,13 +185,13 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertFieldChecked('edit-card-2-2');
// Submit form: select only first option.
- $edit = array(
+ $edit = [
'card_2[0]' => TRUE,
'card_2[1]' => FALSE,
'card_2[2]' => FALSE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array(0));
+ $this->assertFieldValues($entity_init, 'card_2', [0]);
// Display form: check that the right options are selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
@@ -200,23 +200,23 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertNoFieldChecked('edit-card-2-2');
// Submit form: select the three options while the field accepts only 2.
- $edit = array(
+ $edit = [
'card_2[0]' => TRUE,
'card_2[1]' => TRUE,
'card_2[2]' => TRUE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
// Submit form: uncheck all options.
- $edit = array(
+ $edit = [
'card_2[0]' => FALSE,
'card_2[1]' => FALSE,
'card_2[2]' => FALSE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Check that the value was saved.
- $this->assertFieldValues($entity_init, 'card_2', array());
+ $this->assertFieldValues($entity_init, 'card_2', []);
// Required checkbox with one option is auto-selected.
$this->card2->setSetting('allowed_values', [99 => 'Only allowed value']);
@@ -239,23 +239,23 @@ class OptionsWidgetsTest extends FieldTestBase {
]);
$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($this->card1->getName(), array(
+ ->setComponent($this->card1->getName(), [
'type' => 'options_select',
- ))
+ ])
->save();
// Create an entity.
- $entity = EntityTest::create(array(
+ $entity = EntityTest::create([
'user_id' => 1,
'name' => $this->randomMachineName(),
- ));
+ ]);
$entity->save();
$entity_init = clone $entity;
// Display form.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
// A required field without any value has a "none" option.
- $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1', ':label' => t('- Select a value -'))), 'A required select list has a "Select a value" choice.');
+ $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => t('- Select a value -')]), 'A required select list has a "Select a value" choice.');
// With no field data, nothing is selected.
$this->assertNoOptionSelected('edit-card-1', '_none');
@@ -265,19 +265,19 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
// Submit form: select invalid 'none' option.
- $edit = array('card_1' => '_none');
+ $edit = ['card_1' => '_none'];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('@title field is required.', array('@title' => $field->getName())), 'Cannot save a required field when selecting "none" from the select list.');
+ $this->assertRaw(t('@title field is required.', ['@title' => $field->getName()]), 'Cannot save a required field when selecting "none" from the select list.');
// Submit form: select first option.
- $edit = array('card_1' => 0);
+ $edit = ['card_1' => 0];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_1', array(0));
+ $this->assertFieldValues($entity_init, 'card_1', [0]);
// Display form: check that the right options are selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
// A required field with a value has no 'none' option.
- $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1')), 'A required select list with an actual value has no "none" choice.');
+ $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', [':id' => 'edit-card-1']), 'A required select list with an actual value has no "none" choice.');
$this->assertOptionSelected('edit-card-1', 0);
$this->assertNoOptionSelected('edit-card-1', 1);
$this->assertNoOptionSelected('edit-card-1', 2);
@@ -289,11 +289,11 @@ class OptionsWidgetsTest extends FieldTestBase {
// Display form.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
// A non-required field has a 'none' option.
- $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1', ':label' => t('- None -'))), 'A non-required select list has a "None" choice.');
+ $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => t('- None -')]), 'A non-required select list has a "None" choice.');
// Submit form: Unselect the option.
- $edit = array('card_1' => '_none');
+ $edit = ['card_1' => '_none'];
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_1', array());
+ $this->assertFieldValues($entity_init, 'card_1', []);
// Test optgroups.
@@ -311,9 +311,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertRaw('Group 1', 'Option groups are displayed.');
// Submit form: select first option.
- $edit = array('card_1' => 0);
+ $edit = ['card_1' => 0];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_1', array(0));
+ $this->assertFieldValues($entity_init, 'card_1', [0]);
// Display form: check that the right options are selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
@@ -322,9 +322,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertNoOptionSelected('edit-card-1', 2);
// Submit form: Unselect the option.
- $edit = array('card_1' => '_none');
+ $edit = ['card_1' => '_none'];
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_1', array());
+ $this->assertFieldValues($entity_init, 'card_1', []);
}
/**
@@ -338,16 +338,16 @@ class OptionsWidgetsTest extends FieldTestBase {
]);
$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($this->card2->getName(), array(
+ ->setComponent($this->card2->getName(), [
'type' => 'options_select',
- ))
+ ])
->save();
// Create an entity.
- $entity = EntityTest::create(array(
+ $entity = EntityTest::create([
'user_id' => 1,
'name' => $this->randomMachineName(),
- ));
+ ]);
$entity->save();
$entity_init = clone $entity;
@@ -360,9 +360,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
// Submit form: select first and third options.
- $edit = array('card_2[]' => array(0 => 0, 2 => 2));
+ $edit = ['card_2[]' => [0 => 0, 2 => 2]];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array(0, 2));
+ $this->assertFieldValues($entity_init, 'card_2', [0, 2]);
// Display form: check that the right options are selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
@@ -371,9 +371,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertOptionSelected('edit-card-2', 2);
// Submit form: select only first option.
- $edit = array('card_2[]' => array(0 => 0));
+ $edit = ['card_2[]' => [0 => 0]];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array(0));
+ $this->assertFieldValues($entity_init, 'card_2', [0]);
// Display form: check that the right options are selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
@@ -382,33 +382,33 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertNoOptionSelected('edit-card-2', 2);
// Submit form: select the three options while the field accepts only 2.
- $edit = array('card_2[]' => array(0 => 0, 1 => 1, 2 => 2));
+ $edit = ['card_2[]' => [0 => 0, 1 => 1, 2 => 2]];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
// Submit form: uncheck all options.
- $edit = array('card_2[]' => array());
+ $edit = ['card_2[]' => []];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array());
+ $this->assertFieldValues($entity_init, 'card_2', []);
// Test the 'None' option.
// Check that the 'none' option has no effect if actual options are selected
// as well.
- $edit = array('card_2[]' => array('_none' => '_none', 0 => 0));
+ $edit = ['card_2[]' => ['_none' => '_none', 0 => 0]];
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array(0));
+ $this->assertFieldValues($entity_init, 'card_2', [0]);
// Check that selecting the 'none' option empties the field.
- $edit = array('card_2[]' => array('_none' => '_none'));
+ $edit = ['card_2[]' => ['_none' => '_none']];
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array());
+ $this->assertFieldValues($entity_init, 'card_2', []);
// A required select list does not have an empty key.
$field->setRequired(TRUE);
$field->save();
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
- $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2')), 'A required select list does not have an empty key.');
+ $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', [':id' => 'edit-card-2']), 'A required select list does not have an empty key.');
// We do not have to test that a required select list with one option is
// auto-selected because the browser does it for us.
@@ -432,9 +432,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertRaw('Group 1', 'Option groups are displayed.');
// Submit form: select first option.
- $edit = array('card_2[]' => array(0 => 0));
+ $edit = ['card_2[]' => [0 => 0]];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array(0));
+ $this->assertFieldValues($entity_init, 'card_2', [0]);
// Display form: check that the right options are selected.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
@@ -443,9 +443,9 @@ class OptionsWidgetsTest extends FieldTestBase {
$this->assertNoOptionSelected('edit-card-2', 2);
// Submit form: Unselect the option.
- $edit = array('card_2[]' => array('_none' => '_none'));
+ $edit = ['card_2[]' => ['_none' => '_none']];
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
- $this->assertFieldValues($entity_init, 'card_2', array());
+ $this->assertFieldValues($entity_init, 'card_2', []);
}
/**
@@ -475,20 +475,20 @@ class OptionsWidgetsTest extends FieldTestBase {
// Display form: check that _none options are present and has label.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
- $this->assertTrue($this->xpath('//div[@id=:id]//input[@value=:value]', array(':id' => 'edit-card-1', ':value' => '_none')), 'A test radio button has a "None" choice.');
- $this->assertTrue($this->xpath('//div[@id=:id]//label[@for=:for and text()=:label]', array(':id' => 'edit-card-1', ':for' => 'edit-card-1-none', ':label' => 'N/A')), 'A test radio button has a "N/A" choice.');
+ $this->assertTrue($this->xpath('//div[@id=:id]//input[@value=:value]', [':id' => 'edit-card-1', ':value' => '_none']), 'A test radio button has a "None" choice.');
+ $this->assertTrue($this->xpath('//div[@id=:id]//label[@for=:for and text()=:label]', [':id' => 'edit-card-1', ':for' => 'edit-card-1-none', ':label' => 'N/A']), 'A test radio button has a "N/A" choice.');
// Change it to the select widget.
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($this->card1->getName(), array(
+ ->setComponent($this->card1->getName(), [
'type' => 'options_select',
- ))
+ ])
->save();
// Display form: check that _none options are present and has label.
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
// A required field without any value has a "none" option.
- $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1', ':label' => t('- None -'))), 'A test select has a "None" choice.');
+ $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => t('- None -')]), 'A test select has a "None" choice.');
}
}
diff --git a/core/modules/options/tests/options_test/options_test.module b/core/modules/options/tests/options_test/options_test.module
index d20401af695..dbb474b4937 100644
--- a/core/modules/options/tests/options_test/options_test.module
+++ b/core/modules/options/tests/options_test/options_test.module
@@ -14,18 +14,18 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
* @see options_allowed_values()
*/
function options_test_allowed_values_callback(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL) {
- $values = array(
- 'Group 1' => array(
+ $values = [
+ 'Group 1' => [
0 => 'Zero',
- ),
+ ],
1 => 'One',
- 'Group 2' => array(
+ 'Group 2' => [
2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>',
- ),
- 'More <script>dangerous</script> markup' => array(
+ ],
+ 'More <script>dangerous</script> markup' => [
3 => 'Three',
- ),
- );
+ ],
+ ];
return $values;
}
@@ -41,15 +41,15 @@ function options_test_allowed_values_callback(FieldStorageDefinitionInterface $d
* @see options_allowed_values()
*/
function options_test_dynamic_values_callback(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = NULL) {
- $values = array();
+ $values = [];
if (isset($entity)) {
$cacheable = FALSE;
- $values = array(
+ $values = [
$entity->label(),
$entity->url(),
$entity->uuid(),
$entity->bundle(),
- );
+ ];
}
// We need the values of the entity as keys.
return array_combine($values, $values);
diff --git a/core/modules/options/tests/src/Kernel/OptionsFieldTest.php b/core/modules/options/tests/src/Kernel/OptionsFieldTest.php
index 89ac127160e..d3912a29ecd 100644
--- a/core/modules/options/tests/src/Kernel/OptionsFieldTest.php
+++ b/core/modules/options/tests/src/Kernel/OptionsFieldTest.php
@@ -19,7 +19,7 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
*
* @var array
*/
- public static $modules = array('options');
+ public static $modules = ['options'];
/**
* Test that allowed values can be updated.
@@ -81,9 +81,9 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
'required' => TRUE,
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'options_buttons',
- ))
+ ])
->save();
$entity = EntityTest::create();
$form = \Drupal::service('entity.form_builder')->getForm($entity);
diff --git a/core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php b/core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php
index 7dd7cbeecd7..9098b818b70 100644
--- a/core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php
+++ b/core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php
@@ -16,7 +16,7 @@ abstract class OptionsFieldUnitTestBase extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('options');
+ public static $modules = ['options'];
/**
* The field name used in the test.
@@ -53,15 +53,15 @@ abstract class OptionsFieldUnitTestBase extends FieldKernelTestBase {
parent::setUp();
$this->container->get('router.builder')->rebuild();
- $this->fieldStorageDefinition = array(
+ $this->fieldStorageDefinition = [
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'list_integer',
'cardinality' => 1,
- 'settings' => array(
- 'allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three'),
- ),
- );
+ 'settings' => [
+ 'allowed_values' => [1 => 'One', 2 => 'Two', 3 => 'Three'],
+ ],
+ ];
$this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
$this->fieldStorage->save();
@@ -72,9 +72,9 @@ abstract class OptionsFieldUnitTestBase extends FieldKernelTestBase {
$this->field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'options_buttons',
- ))
+ ])
->save();
}
diff --git a/core/modules/options/tests/src/Kernel/OptionsFormattersTest.php b/core/modules/options/tests/src/Kernel/OptionsFormattersTest.php
index 632900e99c7..93607f6f9d7 100644
--- a/core/modules/options/tests/src/Kernel/OptionsFormattersTest.php
+++ b/core/modules/options/tests/src/Kernel/OptionsFormattersTest.php
@@ -33,7 +33,7 @@ class OptionsFormattersTest extends OptionsFieldUnitTestBase {
$this->assertEqual($build['#formatter'], 'list_default', 'Ensure to fall back to the default formatter.');
$this->assertEqual($build[0]['#markup'], 'One');
- $build = $items->view(array('type' => 'list_key'));
+ $build = $items->view(['type' => 'list_key']);
$this->assertEqual($build['#formatter'], 'list_key', 'The chosen formatter is used.');
$this->assertEqual((string) $build[0]['#markup'], 1);
}
diff --git a/core/modules/options/tests/src/Kernel/Views/FileViewsDataTest.php b/core/modules/options/tests/src/Kernel/Views/FileViewsDataTest.php
index 060c05ec815..c5f2902d055 100644
--- a/core/modules/options/tests/src/Kernel/Views/FileViewsDataTest.php
+++ b/core/modules/options/tests/src/Kernel/Views/FileViewsDataTest.php
@@ -19,7 +19,7 @@ class FileViewsDataTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('file', 'views', 'entity_test', 'user', 'field');
+ public static $modules = ['file', 'views', 'entity_test', 'user', 'field'];
/**
* Tests views data generated for file field relationship.
@@ -29,16 +29,16 @@ class FileViewsDataTest extends ViewsKernelTestBase {
*/
public function testRelationshipViewsData() {
// Create file field to entity_test.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_base_file',
'type' => 'file',
- ))->save();
- FieldConfig::create(array(
+ ])->save();
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_base_file',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Check the generated views data.
$views_data = Views::viewsData()->get('entity_test__field_base_file');
$relationship = $views_data['field_base_file_target_id']['relationship'];
@@ -59,16 +59,16 @@ class FileViewsDataTest extends ViewsKernelTestBase {
$this->assertEqual($relationship['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]);
// Create file field to entity_test_mul.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test_mul',
'field_name' => 'field_data_file',
'type' => 'file',
- ))->save();
- FieldConfig::create(array(
+ ])->save();
+ FieldConfig::create([
'entity_type' => 'entity_test_mul',
'field_name' => 'field_data_file',
'bundle' => 'entity_test_mul',
- ))->save();
+ ])->save();
// Check the generated views data.
$views_data = Views::viewsData()->get('entity_test_mul__field_data_file');
$relationship = $views_data['field_data_file_target_id']['relationship'];
diff --git a/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php b/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php
index b1dd9ac5301..d8ba9f4fc5f 100644
--- a/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php
+++ b/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php
@@ -81,7 +81,7 @@ class SystemMenuOffCanvasForm extends PluginFormBase implements ContainerInjecti
$form['entity_form'] = [
'#type' => 'details',
- '#title' => $this->t('Edit menu %label', array('%label' => $this->entity->label())),
+ '#title' => $this->t('Edit menu %label', ['%label' => $this->entity->label()]),
'#open' => TRUE,
];
$form['entity_form'] += $this->getEntityForm($this->entity)->buildForm([], $form_state);
diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php
index 8cdeec0312a..325aec7ff2c 100644
--- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php
+++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php
@@ -12,7 +12,7 @@ abstract class OutsideInJavascriptTestBase extends JavascriptTestBase {
/**
* {@inheritdoc}
*/
- protected function drupalGet($path, array $options = array(), array $headers = array()) {
+ protected function drupalGet($path, array $options = [], array $headers = []) {
$return = parent::drupalGet($path, $options, $headers);
// After the page loaded we need to additionally wait until the settings
diff --git a/core/modules/page_cache/page_cache.module b/core/modules/page_cache/page_cache.module
index 3b8baf4ca3b..ff7286199d7 100644
--- a/core/modules/page_cache/page_cache.module
+++ b/core/modules/page_cache/page_cache.module
@@ -15,7 +15,7 @@ function page_cache_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.page_cache':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Internal Page Cache module caches pages for anonymous users in the database. For more information, see the <a href=":pagecache-documentation">online documentation for the Internal Page Cache module</a>.', array(':pagecache-documentation' => 'https://www.drupal.org/documentation/modules/internal_page_cache')) . '</p>';
+ $output .= '<p>' . t('The Internal Page Cache module caches pages for anonymous users in the database. For more information, see the <a href=":pagecache-documentation">online documentation for the Internal Page Cache module</a>.', [':pagecache-documentation' => 'https://www.drupal.org/documentation/modules/internal_page_cache']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Speeding up your site') . '</dt>';
@@ -23,7 +23,7 @@ function page_cache_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dd>' . t('Pages are usually identical for all anonymous users, while they can be personalized for each authenticated user. This is why entire pages can be cached for anonymous users, whereas they will have to be rebuilt for every authenticated user.') . '</dd>';
$output .= '<dd>' . t('To speed up your site for authenticated users, see the <a href=":dynamic_page_cache-help">Dynamic Page Cache module</a>.', [':dynamic_page_cache-help' => (\Drupal::moduleHandler()->moduleExists('dynamic_page_cache')) ? Url::fromRoute('help.page', ['name' => 'dynamic_page_cache'])->toString() : '#']) . '</p>';
$output .= '<dt>' . t('Configuring the internal page cache') . '</dt>';
- $output .= '<dd>' . t('On the <a href=":cache-settings">Performance page</a>, you can configure how long browsers and proxies may cache pages; that setting is also respected by the Internal Page Cache module. There is no other configuration.', array(':cache-settings' => \Drupal::url('system.performance_settings'))) . '</dd>';
+ $output .= '<dd>' . t('On the <a href=":cache-settings">Performance page</a>, you can configure how long browsers and proxies may cache pages; that setting is also respected by the Internal Page Cache module. There is no other configuration.', [':cache-settings' => \Drupal::url('system.performance_settings')]) . '</dd>';
$output .= '</dl>';
return $output;
diff --git a/core/modules/page_cache/src/StackMiddleware/PageCache.php b/core/modules/page_cache/src/StackMiddleware/PageCache.php
index 3a031db48ef..97d53c6029b 100644
--- a/core/modules/page_cache/src/StackMiddleware/PageCache.php
+++ b/core/modules/page_cache/src/StackMiddleware/PageCache.php
@@ -168,7 +168,7 @@ class PageCache implements HttpKernelInterface {
// In the case of a 304 response, certain headers must be sent, and the
// remaining may not (see RFC 2616, section 10.3.5).
foreach (array_keys($response->headers->all()) as $name) {
- if (!in_array($name, array('content-location', 'expires', 'cache-control', 'vary'))) {
+ if (!in_array($name, ['content-location', 'expires', 'cache-control', 'vary'])) {
$response->headers->remove($name);
}
}
@@ -357,10 +357,10 @@ class PageCache implements HttpKernelInterface {
* The cache ID for this request.
*/
protected function getCacheId(Request $request) {
- $cid_parts = array(
+ $cid_parts = [
$request->getUri(),
$request->getRequestFormat(),
- );
+ ];
return implode(':', $cid_parts);
}
diff --git a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
index 2c945fdb3d7..c3aeb84a762 100644
--- a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
+++ b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
@@ -39,32 +39,32 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
function testPageCacheTags() {
// Create two nodes.
$author_1 = $this->drupalCreateUser();
- $node_1 = $this->drupalCreateNode(array(
+ $node_1 = $this->drupalCreateNode([
'uid' => $author_1->id(),
'title' => 'Node 1',
- 'body' => array(
- 0 => array('value' => 'Body 1', 'format' => 'basic_html'),
- ),
+ 'body' => [
+ 0 => ['value' => 'Body 1', 'format' => 'basic_html'],
+ ],
'promote' => NodeInterface::PROMOTED,
- ));
+ ]);
$author_2 = $this->drupalCreateUser();
- $node_2 = $this->drupalCreateNode(array(
+ $node_2 = $this->drupalCreateNode([
'uid' => $author_2->id(),
'title' => 'Node 2',
- 'body' => array(
- 0 => array('value' => 'Body 2', 'format' => 'full_html'),
- ),
+ 'body' => [
+ 0 => ['value' => 'Body 2', 'format' => 'full_html'],
+ ],
'promote' => NodeInterface::PROMOTED,
- ));
+ ]);
// Place a block, but only make it visible on full node page 2.
- $block = $this->drupalPlaceBlock('views_block:comments_recent-block_1', array(
- 'visibility' => array(
- 'request_path' => array(
+ $block = $this->drupalPlaceBlock('views_block:comments_recent-block_1', [
+ 'visibility' => [
+ 'request_path' => [
'pages' => '/node/' . $node_2->id(),
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$cache_contexts = [
'languages:' . LanguageInterface::TYPE_INTERFACE,
@@ -79,7 +79,7 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
];
// Full node page 1.
- $this->assertPageCacheContextsAndTags($node_1->urlInfo(), $cache_contexts, array(
+ $this->assertPageCacheContextsAndTags($node_1->urlInfo(), $cache_contexts, [
'http_response',
'rendered',
'block_view',
@@ -114,13 +114,13 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
// FinishResponseSubscriber adds this cache tag to responses that have the
// 'user.permissions' cache context for anonymous users.
'config:user.role.anonymous',
- ));
+ ]);
// Render the view block adds the languages cache context.
$cache_contexts[] = 'languages:' . LanguageInterface::TYPE_CONTENT;
// Full node page 2.
- $this->assertPageCacheContextsAndTags($node_2->urlInfo(), $cache_contexts, array(
+ $this->assertPageCacheContextsAndTags($node_2->urlInfo(), $cache_contexts, [
'http_response',
'rendered',
'block_view',
@@ -158,7 +158,7 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
// 'user.permissions' cache context for anonymous users.
'config:user.role.anonymous',
'user:0',
- ));
+ ]);
}
}
diff --git a/core/modules/page_cache/src/Tests/PageCacheTest.php b/core/modules/page_cache/src/Tests/PageCacheTest.php
index d4fae54a5fc..aec0451120a 100644
--- a/core/modules/page_cache/src/Tests/PageCacheTest.php
+++ b/core/modules/page_cache/src/Tests/PageCacheTest.php
@@ -24,7 +24,7 @@ class PageCacheTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('test_page_test', 'system_test', 'entity_test');
+ public static $modules = ['test_page_test', 'system_test', 'entity_test'];
/**
* {@inheritdoc}
@@ -50,24 +50,24 @@ class PageCacheTest extends WebTestBase {
$config->save();
$path = 'system-test/cache_tags_page';
- $tags = array('system_test_cache_tags_page');
+ $tags = ['system_test_cache_tags_page'];
$this->drupalGet($path);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
// Verify a cache hit, but also the presence of the correct cache tags.
$this->drupalGet($path);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
- $cid_parts = array(\Drupal::url('system_test.cache_tags_page', array(), array('absolute' => TRUE)), 'html');
+ $cid_parts = [\Drupal::url('system_test.cache_tags_page', [], ['absolute' => TRUE]), 'html'];
$cid = implode(':', $cid_parts);
$cache_entry = \Drupal::cache('render')->get($cid);
sort($cache_entry->tags);
- $expected_tags = array(
+ $expected_tags = [
'config:user.role.anonymous',
'http_response',
'pre_render',
'rendered',
'system_test_cache_tags_page',
- );
+ ];
$this->assertIdentical($cache_entry->tags, $expected_tags);
Cache::invalidateTags($tags);
@@ -82,24 +82,24 @@ class PageCacheTest extends WebTestBase {
$this->setHttpResponseDebugCacheabilityHeaders(FALSE);
$path = 'system-test/cache_tags_page';
- $tags = array('system_test_cache_tags_page');
+ $tags = ['system_test_cache_tags_page'];
$this->drupalGet($path);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
// Verify a cache hit, but also the presence of the correct cache tags.
$this->drupalGet($path);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
- $cid_parts = array(\Drupal::url('system_test.cache_tags_page', array(), array('absolute' => TRUE)), 'html');
+ $cid_parts = [\Drupal::url('system_test.cache_tags_page', [], ['absolute' => TRUE]), 'html'];
$cid = implode(':', $cid_parts);
$cache_entry = \Drupal::cache('render')->get($cid);
sort($cache_entry->tags);
- $expected_tags = array(
+ $expected_tags = [
'config:user.role.anonymous',
'http_response',
'pre_render',
'rendered',
'system_test_cache_tags_page',
- );
+ ];
$this->assertIdentical($cache_entry->tags, $expected_tags);
Cache::invalidateTags($tags);
@@ -190,28 +190,28 @@ class PageCacheTest extends WebTestBase {
$etag = $this->drupalGetHeader('ETag');
$last_modified = $this->drupalGetHeader('Last-Modified');
- $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag));
+ $this->drupalGet('', [], ['If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag]);
$this->assertResponse(304, 'Conditional request returned 304 Not Modified.');
- $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match: ' . $etag));
+ $this->drupalGet('', [], ['If-Modified-Since: ' . gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match: ' . $etag]);
$this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.');
- $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match: ' . $etag));
+ $this->drupalGet('', [], ['If-Modified-Since: ' . gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match: ' . $etag]);
$this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.');
- $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified));
+ $this->drupalGet('', [], ['If-Modified-Since: ' . $last_modified]);
// Verify the page is not printed twice when the cache is warm.
$this->assertNoPattern('#<html.*<html#');
$this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
- $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag));
+ $this->drupalGet('', [], ['If-Modified-Since: ' . gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag]);
$this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
- $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag));
+ $this->drupalGet('', [], ['If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag]);
$this->assertResponse(200, 'Conditional request returned 200 OK for authenticated user.');
$this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Absence of Page was not cached.');
}
@@ -226,7 +226,7 @@ class PageCacheTest extends WebTestBase {
$config->save();
// Fill the cache.
- $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
+ $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
$this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'cookie,accept-encoding', 'Vary header was sent.');
// Symfony's Response logic determines a specific order for the subvalues
@@ -237,7 +237,7 @@ class PageCacheTest extends WebTestBase {
$this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
// Check cache.
- $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
+ $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
$this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'cookie,accept-encoding', 'Vary: Cookie header was sent.');
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.');
@@ -245,15 +245,15 @@ class PageCacheTest extends WebTestBase {
$this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
// Check replacing default headers.
- $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT')));
+ $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT']]);
$this->assertEqual($this->drupalGetHeader('Expires'), 'Fri, 19 Nov 2008 05:00:00 GMT', 'Default header was replaced.');
- $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Vary', 'value' => 'User-Agent')));
+ $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Vary', 'value' => 'User-Agent']]);
$this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'user-agent,accept-encoding', 'Default header was replaced.');
// Check that authenticated users bypass the cache.
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
- $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
+ $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]);
$this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Caching was bypassed.');
$this->assertTrue(strpos(strtolower($this->drupalGetHeader('Vary')), 'cookie') === FALSE, 'Vary: Cookie header was not sent.');
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Cache-Control header was sent.');
@@ -349,16 +349,16 @@ class PageCacheTest extends WebTestBase {
$this->drupalGet($content_url);
$this->assertResponse($code);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
- $entity_values = array(
+ $entity_values = [
'name' => $this->randomMachineName(),
'user_id' => 1,
- 'field_test_text' => array(
- 0 => array(
+ 'field_test_text' => [
+ 0 => [
'value' => $this->randomString(),
'format' => 'plain_text',
- )
- ),
- );
+ ]
+ ],
+ ];
$entity = EntityTest::create($entity_values);
$entity->save();
// Saving an entity clears 4xx cache tag.
@@ -389,10 +389,10 @@ class PageCacheTest extends WebTestBase {
}
// Disable 403 and 404 caching.
- $settings['settings']['cache_ttl_4xx'] = (object) array(
+ $settings['settings']['cache_ttl_4xx'] = (object) [
'value' => 0,
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
\Drupal::service('cache.render')->deleteAll();
@@ -413,10 +413,10 @@ class PageCacheTest extends WebTestBase {
$config->set('cache.page.max_age', 300);
$config->save();
- $settings['settings']['omit_vary_cookie'] = (object) array(
+ $settings['settings']['omit_vary_cookie'] = (object) [
'value' => TRUE,
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
// Fill the cache.
diff --git a/core/modules/path/path.api.php b/core/modules/path/path.api.php
index 04e1fb31679..df20b95e906 100644
--- a/core/modules/path/path.api.php
+++ b/core/modules/path/path.api.php
@@ -21,10 +21,10 @@
*/
function hook_path_insert($path) {
db_insert('mytable')
- ->fields(array(
+ ->fields([
'alias' => $path['alias'],
'pid' => $path['pid'],
- ))
+ ])
->execute();
}
@@ -40,7 +40,7 @@ function hook_path_insert($path) {
function hook_path_update($path) {
if ($path['alias'] != $path['original']['alias']) {
db_update('mytable')
- ->fields(array('alias' => $path['alias']))
+ ->fields(['alias' => $path['alias']])
->condition('pid', $path['pid'])
->execute();
}
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index 182c6a9dd09..a724b773d6e 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -18,13 +18,13 @@ function path_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.path':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Path module allows you to specify an alias, or custom URL, for any existing internal system path. Aliases should not be confused with URL redirects, which allow you to forward a changed or inactive URL to a new URL. In addition to making URLs more readable, aliases also help search engines index content more effectively. Multiple aliases may be used for a single internal system path. To automate the aliasing of paths, you can install the contributed module <a href=":pathauto">Pathauto</a>. For more information, see the <a href=":path">online documentation for the Path module</a>.', array(':path' => 'https://www.drupal.org/documentation/modules/path', ':pathauto' => 'https://www.drupal.org/project/pathauto')) . '</p>';
+ $output .= '<p>' . t('The Path module allows you to specify an alias, or custom URL, for any existing internal system path. Aliases should not be confused with URL redirects, which allow you to forward a changed or inactive URL to a new URL. In addition to making URLs more readable, aliases also help search engines index content more effectively. Multiple aliases may be used for a single internal system path. To automate the aliasing of paths, you can install the contributed module <a href=":pathauto">Pathauto</a>. For more information, see the <a href=":path">online documentation for the Path module</a>.', [':path' => 'https://www.drupal.org/documentation/modules/path', ':pathauto' => 'https://www.drupal.org/project/pathauto']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating aliases') . '</dt>';
- $output .= '<dd>' . t('If you create or edit a taxonomy term you can add an alias (for example <em>music/jazz</em>) in the field "URL alias". When creating or editing content you can add an alias (for example <em>about-us/team</em>) under the section "URL path settings" in the field "URL alias". Aliases for any other path can be added through the page <a href=":aliases">URL aliases</a>. To add aliases a user needs the permission <a href=":permissions">Create and edit URL aliases</a>.', array(':aliases' => \Drupal::url('path.admin_overview'), ':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-path')))) . '</dd>';
+ $output .= '<dd>' . t('If you create or edit a taxonomy term you can add an alias (for example <em>music/jazz</em>) in the field "URL alias". When creating or editing content you can add an alias (for example <em>about-us/team</em>) under the section "URL path settings" in the field "URL alias". Aliases for any other path can be added through the page <a href=":aliases">URL aliases</a>. To add aliases a user needs the permission <a href=":permissions">Create and edit URL aliases</a>.', [':aliases' => \Drupal::url('path.admin_overview'), ':permissions' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-path'])]) . '</dd>';
$output .= '<dt>' . t('Managing aliases') . '</dt>';
- $output .= '<dd>' . t('The Path module provides a way to search and view a <a href=":aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', array(':aliases' => \Drupal::url('path.admin_overview'))) . '</dd>';
+ $output .= '<dd>' . t('The Path module provides a way to search and view a <a href=":aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', [':aliases' => \Drupal::url('path.admin_overview')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -41,20 +41,20 @@ function path_help($route_name, RouteMatchInterface $route_match) {
*/
function path_form_node_form_alter(&$form, FormStateInterface $form_state) {
$node = $form_state->getFormObject()->getEntity();
- $form['path_settings'] = array(
+ $form['path_settings'] = [
'#type' => 'details',
'#title' => t('URL path settings'),
'#open' => !empty($form['path']['widget'][0]['alias']['#value']),
'#group' => 'advanced',
'#access' => !empty($form['path']['#access']) && $node->hasField('path') && $node->get('path')->access('edit'),
- '#attributes' => array(
- 'class' => array('path-form'),
- ),
- '#attached' => array(
- 'library' => array('path/drupal.path'),
- ),
+ '#attributes' => [
+ 'class' => ['path-form'],
+ ],
+ '#attached' => [
+ 'library' => ['path/drupal.path'],
+ ],
'#weight' => 30,
- );
+ ];
$form['path']['#group'] = 'path_settings';
}
@@ -66,10 +66,10 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields['path'] = BaseFieldDefinition::create('path')
->setLabel(t('URL alias'))
->setTranslatable(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'path',
'weight' => 30,
- ))
+ ])
->setDisplayConfigurable('form', TRUE)
->setComputed(TRUE);
diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php
index 26b5d769476..51f88dd674e 100644
--- a/core/modules/path/src/Controller/PathController.php
+++ b/core/modules/path/src/Controller/PathController.php
@@ -69,63 +69,63 @@ class PathController extends ControllerBase {
// alias with a language.
$multilanguage = ($this->moduleHandler()->moduleExists('language') || $this->aliasStorage->languageAliasExists());
- $header = array();
- $header[] = array('data' => $this->t('Alias'), 'field' => 'alias', 'sort' => 'asc');
- $header[] = array('data' => $this->t('System'), 'field' => 'source');
+ $header = [];
+ $header[] = ['data' => $this->t('Alias'), 'field' => 'alias', 'sort' => 'asc'];
+ $header[] = ['data' => $this->t('System'), 'field' => 'source'];
if ($multilanguage) {
- $header[] = array('data' => $this->t('Language'), 'field' => 'langcode');
+ $header[] = ['data' => $this->t('Language'), 'field' => 'langcode'];
}
$header[] = $this->t('Operations');
- $rows = array();
+ $rows = [];
$destination = $this->getDestinationArray();
foreach ($this->aliasStorage->getAliasesForAdminListing($header, $keys) as $data) {
- $row = array();
+ $row = [];
// @todo Should Path module store leading slashes? See
// https://www.drupal.org/node/2430593.
- $row['data']['alias'] = $this->l(Unicode::truncate($data->alias, 50, FALSE, TRUE), Url::fromUserInput($data->source, array(
- 'attributes' => array('title' => $data->alias),
- )));
- $row['data']['source'] = $this->l(Unicode::truncate($data->source, 50, FALSE, TRUE), Url::fromUserInput($data->source, array(
+ $row['data']['alias'] = $this->l(Unicode::truncate($data->alias, 50, FALSE, TRUE), Url::fromUserInput($data->source, [
+ 'attributes' => ['title' => $data->alias],
+ ]));
+ $row['data']['source'] = $this->l(Unicode::truncate($data->source, 50, FALSE, TRUE), Url::fromUserInput($data->source, [
'alias' => TRUE,
- 'attributes' => array('title' => $data->source),
- )));
+ 'attributes' => ['title' => $data->source],
+ ]));
if ($multilanguage) {
$row['data']['language_name'] = $this->languageManager()->getLanguageName($data->langcode);
}
- $operations = array();
- $operations['edit'] = array(
+ $operations = [];
+ $operations['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute('path.admin_edit', ['pid' => $data->pid], ['query' => $destination]),
- );
- $operations['delete'] = array(
+ ];
+ $operations['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('path.delete', ['pid' => $data->pid], ['query' => $destination]),
- );
- $row['data']['operations'] = array(
- 'data' => array(
+ ];
+ $row['data']['operations'] = [
+ 'data' => [
'#type' => 'operations',
'#links' => $operations,
- ),
- );
+ ],
+ ];
// If the system path maps to a different URL alias, highlight this table
// row to let the user know of old aliases.
if ($data->alias != $this->aliasManager->getAliasByPath($data->source, $data->langcode)) {
- $row['class'] = array('warning');
+ $row['class'] = ['warning'];
}
$rows[] = $row;
}
- $build['path_table'] = array(
+ $build['path_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- '#empty' => $this->t('No URL aliases available. <a href=":link">Add URL alias</a>.', array(':link' => $this->url('path.admin_add'))),
- );
- $build['path_pager'] = array('#type' => 'pager');
+ '#empty' => $this->t('No URL aliases available. <a href=":link">Add URL alias</a>.', [':link' => $this->url('path.admin_add')]),
+ ];
+ $build['path_pager'] = ['#type' => 'pager'];
return $build;
}
diff --git a/core/modules/path/src/Form/AddForm.php b/core/modules/path/src/Form/AddForm.php
index 5b7acef8bb2..8f8d4f6b143 100644
--- a/core/modules/path/src/Form/AddForm.php
+++ b/core/modules/path/src/Form/AddForm.php
@@ -20,12 +20,12 @@ class AddForm extends PathFormBase {
* {@inheritdoc}
*/
protected function buildPath($pid) {
- return array(
+ return [
'source' => '',
'alias' => '',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'pid' => NULL,
- );
+ ];
}
}
diff --git a/core/modules/path/src/Form/DeleteForm.php b/core/modules/path/src/Form/DeleteForm.php
index 45cd9a28031..b28fdc04eda 100644
--- a/core/modules/path/src/Form/DeleteForm.php
+++ b/core/modules/path/src/Form/DeleteForm.php
@@ -57,7 +57,7 @@ class DeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return t('Are you sure you want to delete path alias %title?', array('%title' => $this->pathAlias['alias']));
+ return t('Are you sure you want to delete path alias %title?', ['%title' => $this->pathAlias['alias']]);
}
/**
@@ -71,7 +71,7 @@ class DeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) {
- $this->pathAlias = $this->aliasStorage->load(array('pid' => $pid));
+ $this->pathAlias = $this->aliasStorage->load(['pid' => $pid]);
$form = parent::buildForm($form, $form_state);
@@ -82,7 +82,7 @@ class DeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $this->aliasStorage->delete(array('pid' => $this->pathAlias['pid']));
+ $this->aliasStorage->delete(['pid' => $this->pathAlias['pid']]);
$form_state->setRedirect('path.admin_overview');
}
diff --git a/core/modules/path/src/Form/EditForm.php b/core/modules/path/src/Form/EditForm.php
index aeb285dad22..7d4a3693022 100644
--- a/core/modules/path/src/Form/EditForm.php
+++ b/core/modules/path/src/Form/EditForm.php
@@ -21,7 +21,7 @@ class EditForm extends PathFormBase {
* {@inheritdoc}
*/
protected function buildPath($pid) {
- return $this->aliasStorage->load(array('pid' => $pid));
+ return $this->aliasStorage->load(['pid' => $pid]);
}
/**
@@ -31,27 +31,27 @@ class EditForm extends PathFormBase {
$form = parent::buildForm($form, $form_state, $pid);
$form['#title'] = $this->path['alias'];
- $form['pid'] = array(
+ $form['pid'] = [
'#type' => 'hidden',
'#value' => $this->path['pid'],
- );
+ ];
- $url = new Url('path.delete', array(
+ $url = new Url('path.delete', [
'pid' => $this->path['pid'],
- ));
+ ]);
if ($this->getRequest()->query->has('destination')) {
$url->setOption('query', $this->getDestinationArray());
}
- $form['actions']['delete'] = array(
+ $form['actions']['delete'] = [
'#type' => 'link',
'#title' => $this->t('Delete'),
'#url' => $url,
- '#attributes' => array(
- 'class' => array('button', 'button--danger'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['button', 'button--danger'],
+ ],
+ ];
return $form;
}
diff --git a/core/modules/path/src/Form/PathFilterForm.php b/core/modules/path/src/Form/PathFilterForm.php
index 6ac15855aa5..f7829061ecb 100644
--- a/core/modules/path/src/Form/PathFilterForm.php
+++ b/core/modules/path/src/Form/PathFilterForm.php
@@ -21,31 +21,31 @@ class PathFilterForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $keys = NULL) {
- $form['#attributes'] = array('class' => array('search-form'));
- $form['basic'] = array(
+ $form['#attributes'] = ['class' => ['search-form']];
+ $form['basic'] = [
'#type' => 'details',
'#title' => $this->t('Filter aliases'),
'#open' => TRUE,
- '#attributes' => array('class' => array('container-inline')),
- );
- $form['basic']['filter'] = array(
+ '#attributes' => ['class' => ['container-inline']],
+ ];
+ $form['basic']['filter'] = [
'#type' => 'search',
'#title' => 'Path alias',
'#title_display' => 'invisible',
'#default_value' => $keys,
'#maxlength' => 128,
'#size' => 25,
- );
- $form['basic']['submit'] = array(
+ ];
+ $form['basic']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Filter'),
- );
+ ];
if ($keys) {
- $form['basic']['reset'] = array(
+ $form['basic']['reset'] = [
'#type' => 'submit',
'#value' => $this->t('Reset'),
- '#submit' => array('::resetForm'),
- );
+ '#submit' => ['::resetForm'],
+ ];
}
return $form;
}
@@ -54,9 +54,9 @@ class PathFilterForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $form_state->setRedirect('path.admin_overview_filter', array(), array(
- 'query' => array('search' => trim($form_state->getValue('filter'))),
- ));
+ $form_state->setRedirect('path.admin_overview_filter', [], [
+ 'query' => ['search' => trim($form_state->getValue('filter'))],
+ ]);
}
/**
diff --git a/core/modules/path/src/Form/PathFormBase.php b/core/modules/path/src/Form/PathFormBase.php
index dba3a3fa5d7..884d24fb8ac 100644
--- a/core/modules/path/src/Form/PathFormBase.php
+++ b/core/modules/path/src/Form/PathFormBase.php
@@ -95,7 +95,7 @@ abstract class PathFormBase extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) {
$this->path = $this->buildPath($pid);
- $form['source'] = array(
+ $form['source'] = [
'#type' => 'textfield',
'#title' => $this->t('Existing system path'),
'#default_value' => $this->path['source'],
@@ -104,8 +104,8 @@ abstract class PathFormBase extends FormBase {
'#description' => $this->t('Specify the existing path you wish to alias. For example: /node/28, /forum/1, /taxonomy/term/1.'),
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
'#required' => TRUE,
- );
- $form['alias'] = array(
+ ];
+ $form['alias'] = [
'#type' => 'textfield',
'#title' => $this->t('Path alias'),
'#default_value' => $this->path['alias'],
@@ -114,17 +114,17 @@ abstract class PathFormBase extends FormBase {
'#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.'),
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
'#required' => TRUE,
- );
+ ];
// A hidden value unless language.module is enabled.
if (\Drupal::moduleHandler()->moduleExists('language')) {
$languages = \Drupal::languageManager()->getLanguages();
- $language_options = array();
+ $language_options = [];
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->getName();
}
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'select',
'#title' => $this->t('Language'),
'#options' => $language_options,
@@ -133,21 +133,21 @@ abstract class PathFormBase extends FormBase {
'#default_value' => $this->path['langcode'],
'#weight' => -10,
'#description' => $this->t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set as <em>- None -</em>.'),
- );
+ ];
}
else {
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'value',
'#value' => $this->path['langcode']
- );
+ ];
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -193,7 +193,7 @@ abstract class PathFormBase extends FormBase {
if (!$this->pathValidator->isValid(trim($source, '/'))) {
- $form_state->setErrorByName('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
+ $form_state->setErrorByName('source', t("The path '@link_path' is either invalid or you do not have access to it.", ['@link_path' => $source]));
}
}
diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php
index 239588fd515..4d8da7a8ad7 100644
--- a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php
+++ b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php
@@ -37,7 +37,7 @@ class PathItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array();
+ return [];
}
/**
@@ -62,7 +62,7 @@ class PathItem extends FieldItemBase {
else {
// Delete old alias if user erased it.
if ($this->pid && !$this->alias) {
- \Drupal::service('path.alias_storage')->delete(array('pid' => $this->pid));
+ \Drupal::service('path.alias_storage')->delete(['pid' => $this->pid]);
}
// Only save a non-empty alias.
elseif ($this->alias) {
diff --git a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
index 366db885a69..b31af4694b7 100644
--- a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
+++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
@@ -26,47 +26,47 @@ class PathWidget extends WidgetBase {
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$entity = $items->getEntity();
- $path = array();
+ $path = [];
if (!$entity->isNew()) {
- $conditions = array('source' => '/' . $entity->urlInfo()->getInternalPath());
+ $conditions = ['source' => '/' . $entity->urlInfo()->getInternalPath()];
if ($items->getLangcode() != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
$conditions['langcode'] = $items->getLangcode();
}
$path = \Drupal::service('path.alias_storage')->load($conditions);
if ($path === FALSE) {
- $path = array();
+ $path = [];
}
}
- $path += array(
+ $path += [
'pid' => NULL,
'source' => !$entity->isNew() ? '/' . $entity->urlInfo()->getInternalPath() : NULL,
'alias' => '',
'langcode' => $items->getLangcode(),
- );
+ ];
- $element += array(
- '#element_validate' => array(array(get_class($this), 'validateFormElement')),
- );
- $element['alias'] = array(
+ $element += [
+ '#element_validate' => [[get_class($this), 'validateFormElement']],
+ ];
+ $element['alias'] = [
'#type' => 'textfield',
'#title' => $element['#title'],
'#default_value' => $path['alias'],
'#required' => $element['#required'],
'#maxlength' => 255,
'#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.'),
- );
- $element['pid'] = array(
+ ];
+ $element['pid'] = [
'#type' => 'value',
'#value' => $path['pid'],
- );
- $element['source'] = array(
+ ];
+ $element['source'] = [
'#type' => 'value',
'#value' => $path['source'],
- );
- $element['langcode'] = array(
+ ];
+ $element['langcode'] = [
'#type' => 'value',
'#value' => $path['langcode'],
- );
+ ];
return $element;
}
diff --git a/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php b/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php
index a71bcc9cbba..385ee4ba465 100644
--- a/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php
+++ b/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php
@@ -58,7 +58,7 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$source = $row->getDestinationProperty('source');
$alias = $row->getDestinationProperty('alias');
$langcode = $row->getDestinationProperty('langcode');
@@ -75,7 +75,7 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
$path = $this->aliasStorage->save($source, $alias, $langcode, $pid);
- return array($path['pid']);
+ return [$path['pid']];
}
/**
diff --git a/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php b/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
index 3529ce28330..7714cbd1c4f 100644
--- a/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
+++ b/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
@@ -24,10 +24,10 @@ abstract class UrlAliasBase extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'pid' => $this->t('The numeric identifier of the path alias.'),
'language' => $this->t('The language code of the URL alias.'),
- );
+ ];
}
/**
diff --git a/core/modules/path/src/Tests/PathAdminTest.php b/core/modules/path/src/Tests/PathAdminTest.php
index 906ce643341..67f41bd2edb 100644
--- a/core/modules/path/src/Tests/PathAdminTest.php
+++ b/core/modules/path/src/Tests/PathAdminTest.php
@@ -14,13 +14,13 @@ class PathAdminTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path');
+ public static $modules = ['path'];
protected function setUp() {
parent::setUp();
// Create test user and log in.
- $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit own page content', 'administer url aliases', 'create url aliases']);
$this->drupalLogin($web_user);
}
@@ -35,63 +35,63 @@ class PathAdminTest extends PathTestBase {
// Create aliases.
$alias1 = '/' . $this->randomMachineName(8);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node1->id(),
'alias' => $alias1,
- );
+ ];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$alias2 = '/' . $this->randomMachineName(8);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node2->id(),
'alias' => $alias2,
- );
+ ];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$alias3 = '/' . $this->randomMachineName(4) . '/' . $this->randomMachineName(4);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node3->id(),
'alias' => $alias3,
- );
+ ];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
// Filter by the first alias.
- $edit = array(
+ $edit = [
'filter' => $alias1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertLinkByHref($alias1);
$this->assertNoLinkByHref($alias2);
$this->assertNoLinkByHref($alias3);
// Filter by the second alias.
- $edit = array(
+ $edit = [
'filter' => $alias2,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertNoLinkByHref($alias1);
$this->assertLinkByHref($alias2);
$this->assertNoLinkByHref($alias3);
// Filter by the third alias which has a slash.
- $edit = array(
+ $edit = [
'filter' => $alias3,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertNoLinkByHref($alias1);
$this->assertNoLinkByHref($alias2);
$this->assertLinkByHref($alias3);
// Filter by a random string with a different length.
- $edit = array(
+ $edit = [
'filter' => $this->randomMachineName(10),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertNoLinkByHref($alias1);
$this->assertNoLinkByHref($alias2);
// Reset the filter.
- $edit = array();
+ $edit = [];
$this->drupalPostForm(NULL, $edit, t('Reset'));
$this->assertLinkByHref($alias1);
$this->assertLinkByHref($alias2);
diff --git a/core/modules/path/src/Tests/PathNodeFormTest.php b/core/modules/path/src/Tests/PathNodeFormTest.php
index 79b43a77307..016ae04f287 100644
--- a/core/modules/path/src/Tests/PathNodeFormTest.php
+++ b/core/modules/path/src/Tests/PathNodeFormTest.php
@@ -14,13 +14,13 @@ class PathNodeFormTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('node', 'path');
+ public static $modules = ['node', 'path'];
protected function setUp() {
parent::setUp();
// Create test user and log in.
- $web_user = $this->drupalCreateUser(array('create page content', 'create url aliases'));
+ $web_user = $this->drupalCreateUser(['create page content', 'create url aliases']);
$this->drupalLogin($web_user);
}
diff --git a/core/modules/path/src/Tests/PathTaxonomyTermTest.php b/core/modules/path/src/Tests/PathTaxonomyTermTest.php
index f62fb6c4c7c..b6a853e97a6 100644
--- a/core/modules/path/src/Tests/PathTaxonomyTermTest.php
+++ b/core/modules/path/src/Tests/PathTaxonomyTermTest.php
@@ -16,7 +16,7 @@ class PathTaxonomyTermTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
protected function setUp() {
parent::setUp();
@@ -29,7 +29,7 @@ class PathTaxonomyTermTest extends PathTestBase {
$vocabulary->save();
// Create and log in user.
- $web_user = $this->drupalCreateUser(array('administer url aliases', 'administer taxonomy', 'access administration pages'));
+ $web_user = $this->drupalCreateUser(['administer url aliases', 'administer taxonomy', 'access administration pages']);
$this->drupalLogin($web_user);
}
@@ -40,13 +40,13 @@ class PathTaxonomyTermTest extends PathTestBase {
// Create a term in the default 'Tags' vocabulary with URL alias.
$vocabulary = Vocabulary::load('tags');
$description = $this->randomMachineName();
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(),
'description[0][value]' => $description,
'path[0][alias]' => '/' . $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add', $edit, t('Save'));
- $tid = db_query("SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1", array(':name' => $edit['name[0][value]']))->fetchField();
+ $tid = db_query("SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1", [':name' => $edit['name[0][value]']])->fetchField();
// Confirm that the alias works.
$this->drupalGet($edit['path[0][alias]']);
@@ -59,7 +59,7 @@ class PathTaxonomyTermTest extends PathTestBase {
$this->assertTrue(!empty($elements), 'Term page contains shortlink URL.');
// Change the term's URL alias.
- $edit2 = array();
+ $edit2 = [];
$edit2['path[0][alias]'] = '/' . $this->randomMachineName();
$this->drupalPostForm('taxonomy/term/' . $tid . '/edit', $edit2, t('Save'));
@@ -73,7 +73,7 @@ class PathTaxonomyTermTest extends PathTestBase {
$this->assertResponse(404, 'Old URL alias returns 404.');
// Remove the term's URL alias.
- $edit3 = array();
+ $edit3 = [];
$edit3['path[0][alias]'] = '';
$this->drupalPostForm('taxonomy/term/' . $tid . '/edit', $edit3, t('Save'));
diff --git a/core/modules/path/src/Tests/PathTestBase.php b/core/modules/path/src/Tests/PathTestBase.php
index 53496768a8d..33cf5aba9dc 100644
--- a/core/modules/path/src/Tests/PathTestBase.php
+++ b/core/modules/path/src/Tests/PathTestBase.php
@@ -17,15 +17,15 @@ abstract class PathTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'path');
+ public static $modules = ['node', 'path'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
diff --git a/core/modules/path/tests/src/Functional/PathAliasTest.php b/core/modules/path/tests/src/Functional/PathAliasTest.php
index 5127853ea44..9684aa95ffc 100644
--- a/core/modules/path/tests/src/Functional/PathAliasTest.php
+++ b/core/modules/path/tests/src/Functional/PathAliasTest.php
@@ -19,13 +19,13 @@ class PathAliasTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path');
+ public static $modules = ['path'];
protected function setUp() {
parent::setUp();
// Create test user and log in.
- $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit own page content', 'administer url aliases', 'create url aliases']);
$this->drupalLogin($web_user);
}
@@ -37,7 +37,7 @@ class PathAliasTest extends PathTestBase {
$node1 = $this->drupalCreateNode();
// Create alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node1->id();
$edit['alias'] = '/' . $this->randomMachineName(8);
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
@@ -51,7 +51,7 @@ class PathAliasTest extends PathTestBase {
// created.
\Drupal::cache('data')->deleteAll();
// Make sure the path is not converted to the alias.
- $this->drupalGet(trim($edit['source'], '/'), array('alias' => TRUE));
+ $this->drupalGet(trim($edit['source'], '/'), ['alias' => TRUE]);
$this->assertTrue(\Drupal::cache('data')->get('preload-paths:' . $edit['source']), 'Cache entry was created.');
// Visit the alias for the node and confirm a cache entry is created.
@@ -70,7 +70,7 @@ class PathAliasTest extends PathTestBase {
$node1 = $this->drupalCreateNode();
// Create alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node1->id();
$edit['alias'] = '/' . $this->getRandomGenerator()->word(8);
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
@@ -129,7 +129,7 @@ class PathAliasTest extends PathTestBase {
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
// Confirm no duplicate was created.
- $this->assertRaw(t('The alias %alias is already in use in this language.', array('%alias' => $edit['alias'])), 'Attempt to move alias was rejected.');
+ $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias']]), 'Attempt to move alias was rejected.');
$edit_upper = $edit;
$edit_upper['alias'] = Unicode::strtoupper($edit['alias']);
@@ -142,8 +142,8 @@ class PathAliasTest extends PathTestBase {
// Delete alias.
$this->drupalGet('admin/config/search/path/edit/' . $pid);
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete path alias %name?', array('%name' => $edit['alias'])));
- $this->drupalPostForm(NULL, array(), t('Confirm'));
+ $this->assertRaw(t('Are you sure you want to delete path alias %name?', ['%name' => $edit['alias']]));
+ $this->drupalPostForm(NULL, [], t('Confirm'));
// Confirm that the alias no longer works.
$this->drupalGet($edit['alias']);
@@ -151,7 +151,7 @@ class PathAliasTest extends PathTestBase {
$this->assertResponse(404);
// Create a really long alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node1->id();
$alias = '/' . $this->randomMachineName(128);
$edit['alias'] = $alias;
@@ -166,7 +166,7 @@ class PathAliasTest extends PathTestBase {
$node3 = $this->drupalCreateNode();
// Create absolute path alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node3->id();
$node3_alias = '/' . $this->randomMachineName(8);
$edit['alias'] = $node3_alias;
@@ -176,7 +176,7 @@ class PathAliasTest extends PathTestBase {
$node4 = $this->drupalCreateNode();
// Create alias with trailing slash.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node4->id();
$node4_alias = '/' . $this->randomMachineName(8);
$edit['alias'] = $node4_alias . '/';
@@ -205,12 +205,12 @@ class PathAliasTest extends PathTestBase {
$edit['alias'] = $node4_alias;
$edit['source'] = '/node/' . $node3->id();
$this->drupalPostForm('admin/config/search/path/edit/' . $pid, $edit, t('Save'));
- $this->assertRaw(t('The alias %alias is already in use in this language.', array('%alias' => $edit['alias'])));
+ $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias']]));
// Create an alias without a starting slash.
$node5 = $this->drupalCreateNode();
- $edit = array();
+ $edit = [];
$edit['source'] = 'node/' . $node5->id();
$node5_alias = $this->randomMachineName(8);
$edit['alias'] = $node5_alias . '/';
@@ -229,7 +229,7 @@ class PathAliasTest extends PathTestBase {
$node1 = $this->drupalCreateNode();
// Create alias.
- $edit = array();
+ $edit = [];
$edit['path[0][alias]'] = '/' . $this->randomMachineName(8);
$this->drupalPostForm('node/' . $node1->id() . '/edit', $edit, t('Save'));
@@ -284,7 +284,7 @@ class PathAliasTest extends PathTestBase {
$this->assertText(t('The alias is already in use.'), 'Attempt to moved alias was rejected.');
// Delete alias.
- $this->drupalPostForm('node/' . $node1->id() . '/edit', array('path[0][alias]' => ''), t('Save'));
+ $this->drupalPostForm('node/' . $node1->id() . '/edit', ['path[0][alias]' => ''], t('Save'));
// Confirm that the alias no longer works.
$this->drupalGet($edit['path[0][alias]']);
@@ -295,7 +295,7 @@ class PathAliasTest extends PathTestBase {
$node3 = $this->drupalCreateNode();
// Set its path alias to an absolute path.
- $edit = array('path[0][alias]' => '/' . $this->randomMachineName(8));
+ $edit = ['path[0][alias]' => '/' . $this->randomMachineName(8)];
$this->drupalPostForm('node/' . $node3->id() . '/edit', $edit, t('Save'));
// Confirm that the alias was converted to a relative path.
@@ -307,7 +307,7 @@ class PathAliasTest extends PathTestBase {
$node4 = $this->drupalCreateNode();
// Set its path alias to have a trailing slash.
- $edit = array('path[0][alias]' => '/' . $this->randomMachineName(8) . '/');
+ $edit = ['path[0][alias]' => '/' . $this->randomMachineName(8) . '/'];
$this->drupalPostForm('node/' . $node4->id() . '/edit', $edit, t('Save'));
// Confirm that the alias was converted to a relative path.
@@ -319,7 +319,7 @@ class PathAliasTest extends PathTestBase {
$node5 = $this->drupalCreateNode();
// Set a path alias.
- $edit = array('path[0][alias]' => '/' . $this->randomMachineName(8));
+ $edit = ['path[0][alias]' => '/' . $this->randomMachineName(8)];
$this->drupalPostForm('node/' . $node5->id() . '/edit', $edit, t('Save'));
// Delete the node and check that the path alias is also deleted.
@@ -338,7 +338,7 @@ class PathAliasTest extends PathTestBase {
* Integer representing the path ID.
*/
function getPID($alias) {
- return db_query("SELECT pid FROM {url_alias} WHERE alias = :alias", array(':alias' => $alias))->fetchField();
+ return db_query("SELECT pid FROM {url_alias} WHERE alias = :alias", [':alias' => $alias])->fetchField();
}
/**
@@ -347,7 +347,7 @@ class PathAliasTest extends PathTestBase {
function testDuplicateNodeAlias() {
// Create one node with a random alias.
$node_one = $this->drupalCreateNode();
- $edit = array();
+ $edit = [];
$edit['path[0][alias]'] = '/' . $this->randomMachineName();
$this->drupalPostForm('node/' . $node_one->id() . '/edit', $edit, t('Save'));
diff --git a/core/modules/path/tests/src/Functional/PathLanguageTest.php b/core/modules/path/tests/src/Functional/PathLanguageTest.php
index 08fe7a4ad24..cd56557ea79 100644
--- a/core/modules/path/tests/src/Functional/PathLanguageTest.php
+++ b/core/modules/path/tests/src/Functional/PathLanguageTest.php
@@ -14,7 +14,7 @@ class PathLanguageTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path', 'locale', 'locale_test', 'content_translation');
+ public static $modules = ['path', 'locale', 'locale_test', 'content_translation'];
/**
* An user with permissions to administer content types.
@@ -26,7 +26,7 @@ class PathLanguageTest extends PathTestBase {
protected function setUp() {
parent::setUp();
- $permissions = array(
+ $permissions = [
'access administration pages',
'administer content translation',
'administer content types',
@@ -37,29 +37,29 @@ class PathLanguageTest extends PathTestBase {
'create url aliases',
'edit any page content',
'translate any entity',
- );
+ ];
// Create and log in user.
$this->webUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->webUser);
// Enable French language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => 1);
+ $edit = ['language_interface[enabled][language-url]' => 1];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Enable translation for page node.
- $edit = array(
+ $edit = [
'entity_types[node]' => 1,
'settings[node][page][translatable]' => 1,
'settings[node][page][fields][path]' => 1,
'settings[node][page][fields][body]' => 1,
'settings[node][page][settings][language][language_alterable]' => 1,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
@@ -73,11 +73,11 @@ class PathLanguageTest extends PathTestBase {
*/
function testAliasTranslation() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
- $english_node = $this->drupalCreateNode(array('type' => 'page', 'langcode' => 'en'));
+ $english_node = $this->drupalCreateNode(['type' => 'page', 'langcode' => 'en']);
$english_alias = $this->randomMachineName();
// Edit the node to set language and path.
- $edit = array();
+ $edit = [];
$edit['path[0][alias]'] = '/' . $english_alias;
$this->drupalPostForm('node/' . $english_node->id() . '/edit', $edit, t('Save'));
@@ -89,7 +89,7 @@ class PathLanguageTest extends PathTestBase {
$this->drupalGet('node/' . $english_node->id() . '/translations');
$this->clickLink(t('Add'));
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$french_alias = $this->randomMachineName();
@@ -105,7 +105,7 @@ class PathLanguageTest extends PathTestBase {
$languages = $this->container->get('language_manager')->getLanguages();
// Ensure the node was created.
- $node_storage->resetCache(array($english_node->id()));
+ $node_storage->resetCache([$english_node->id()]);
$english_node = $node_storage->load($english_node->id());
$english_node_french_translation = $english_node->getTranslation('fr');
$this->assertTrue($english_node->hasTranslation('fr'), 'Node found in database.');
@@ -118,22 +118,22 @@ class PathLanguageTest extends PathTestBase {
// many levels, and we need to clear those caches.
$this->container->get('language_manager')->reset();
$languages = $this->container->get('language_manager')->getLanguages();
- $url = $english_node_french_translation->url('canonical', array('language' => $languages['fr']));
+ $url = $english_node_french_translation->url('canonical', ['language' => $languages['fr']]);
$this->assertTrue(strpos($url, $edit['path[0][alias]']), 'URL contains the path alias.');
// Confirm that the alias works even when changing language negotiation
// options. Enable User language detection and selection over URL one.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-user]' => 1,
'language_interface[weight][language-user]' => -9,
'language_interface[enabled][language-url]' => 1,
'language_interface[weight][language-url]' => -8,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Change user language preference.
- $edit = array('preferred_langcode' => 'fr');
+ $edit = ['preferred_langcode' => 'fr'];
$this->drupalPostForm("user/" . $this->webUser->id() . "/edit", $edit, t('Save'));
// Check that the English alias works. In this situation French is the
@@ -152,7 +152,7 @@ class PathLanguageTest extends PathTestBase {
$this->assertText($english_node_french_translation->body->value, 'Alias for French translation works.');
// Disable URL language negotiation.
- $edit = array('language_interface[enabled][language-url]' => FALSE);
+ $edit = ['language_interface[enabled][language-url]' => FALSE];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Check that the English alias still works.
diff --git a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php
index f17bb600856..9bad3485e28 100644
--- a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php
+++ b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php
@@ -14,23 +14,23 @@ class PathLanguageUiTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path', 'locale', 'locale_test');
+ public static $modules = ['path', 'locale', 'locale_test'];
protected function setUp() {
parent::setUp();
// Create and log in user.
- $web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages'));
+ $web_user = $this->drupalCreateUser(['edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages']);
$this->drupalLogin($web_user);
// Enable French language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => 1);
+ $edit = ['language_interface[enabled][language-url]' => 1];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
}
@@ -39,7 +39,7 @@ class PathLanguageUiTest extends PathTestBase {
*/
function testLanguageNeutralUrl() {
$name = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['source'] = '/admin/config/search/path';
$edit['alias'] = '/' . $name;
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
@@ -53,7 +53,7 @@ class PathLanguageUiTest extends PathTestBase {
*/
function testDefaultLanguageUrl() {
$name = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['source'] = '/admin/config/search/path';
$edit['alias'] = '/' . $name;
$edit['langcode'] = 'en';
@@ -68,7 +68,7 @@ class PathLanguageUiTest extends PathTestBase {
*/
function testNonDefaultUrl() {
$name = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['source'] = '/admin/config/search/path';
$edit['alias'] = '/' . $name;
$edit['langcode'] = 'fr';
diff --git a/core/modules/path/tests/src/Functional/PathTestBase.php b/core/modules/path/tests/src/Functional/PathTestBase.php
index ef83396fd11..d4b8826d58d 100644
--- a/core/modules/path/tests/src/Functional/PathTestBase.php
+++ b/core/modules/path/tests/src/Functional/PathTestBase.php
@@ -14,15 +14,15 @@ abstract class PathTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'path');
+ public static $modules = ['node', 'path'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
diff --git a/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php b/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
index 8df5392fc4d..0580b830cc2 100644
--- a/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
+++ b/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
@@ -61,46 +61,46 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
public function testUrlAlias() {
$id_map = $this->getMigration('d6_url_alias')->getIdMap();
// Test that the field exists.
- $conditions = array(
+ $conditions = [
'source' => '/node/1',
'alias' => '/alias-one',
'langcode' => 'af',
- );
+ ];
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('1', $conditions, $path);
- $this->assertIdentical($id_map->lookupDestinationID(array($path['pid'])), array('1'), "Test IdMap");
+ $this->assertIdentical($id_map->lookupDestinationID([$path['pid']]), ['1'], "Test IdMap");
- $conditions = array(
+ $conditions = [
'source' => '/node/2',
'alias' => '/alias-two',
'langcode' => 'en',
- );
+ ];
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('2', $conditions, $path);
// Test that we can re-import using the UrlAlias destination.
Database::getConnection('default', 'migrate')
->update('url_alias')
- ->fields(array('dst' => 'new-url-alias'))
+ ->fields(['dst' => 'new-url-alias'])
->condition('src', 'node/2')
->execute();
\Drupal::database()
->update($id_map->mapTableName())
- ->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
+ ->fields(['source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE])
->execute();
$migration = $this->getMigration('d6_url_alias');
$this->executeMigration($migration);
- $path = \Drupal::service('path.alias_storage')->load(array('pid' => $path['pid']));
+ $path = \Drupal::service('path.alias_storage')->load(['pid' => $path['pid']]);
$conditions['alias'] = '/new-url-alias';
$this->assertPath('2', $conditions, $path);
- $conditions = array(
+ $conditions = [
'source' => '/node/3',
'alias' => '/alias-three',
'langcode' => 'und',
- );
+ ];
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('3', $conditions, $path);
}
diff --git a/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php b/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
index df64a5c2e8b..602e84f42f6 100644
--- a/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
+++ b/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
@@ -18,7 +18,7 @@ class PathNoCanonicalLinkTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('path', 'content_translation_test', 'language', 'entity_test', 'user', 'system');
+ public static $modules = ['path', 'content_translation_test', 'language', 'entity_test', 'user', 'system'];
protected function setUp() {
parent::setUp();
diff --git a/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php b/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
index 0bb55ae5e8d..7ef7c2f37cf 100644
--- a/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
+++ b/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
@@ -21,7 +21,7 @@ class PathFieldDefinitionTest extends BaseFieldDefinitionTestBase {
* {@inheritdoc}
*/
protected function getModuleAndPath() {
- return array('path', dirname(dirname(dirname(dirname(__DIR__)))));
+ return ['path', dirname(dirname(dirname(dirname(__DIR__))))];
}
/**
@@ -29,7 +29,7 @@ class PathFieldDefinitionTest extends BaseFieldDefinitionTestBase {
* @covers ::getSchema
*/
public function testGetColumns() {
- $this->assertSame(array(), $this->definition->getColumns());
+ $this->assertSame([], $this->definition->getColumns());
}
}
diff --git a/core/modules/quickedit/quickedit.api.php b/core/modules/quickedit/quickedit.api.php
index 8e6a2a8eef9..581b5616ead 100644
--- a/core/modules/quickedit/quickedit.api.php
+++ b/core/modules/quickedit/quickedit.api.php
@@ -70,11 +70,11 @@ function hook_quickedit_editor_alter(&$editors) {
* @see \Drupal\Core\Field\FieldItemListInterface::view()
*/
function hook_quickedit_render_field(Drupal\Core\Entity\EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
- return array(
+ return [
'#prefix' => '<div class="example-markup">',
'field' => $entity->getTranslation($langcode)->get($field_name)->view($view_mode_id),
'#suffix' => '</div>',
- );
+ ];
}
/**
diff --git a/core/modules/quickedit/quickedit.module b/core/modules/quickedit/quickedit.module
index be401158d17..051b94834ae 100644
--- a/core/modules/quickedit/quickedit.module
+++ b/core/modules/quickedit/quickedit.module
@@ -22,12 +22,12 @@ function quickedit_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.quickedit':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Quick Edit module allows users with the <a href=":quickedit_permission">Access in-place editing</a> and <a href=":contextual_permission">Use contextual links</a> permissions to edit field content without visiting a separate page. For more information, see the <a href=":handbook_url">online documentation for the Quick Edit module</a>.', array(':handbook_url' => 'https://www.drupal.org/documentation/modules/edit', ':quickedit_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-quickedit')), ':contextual_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-contextual')))) . '</p>';
+ $output .= '<p>' . t('The Quick Edit module allows users with the <a href=":quickedit_permission">Access in-place editing</a> and <a href=":contextual_permission">Use contextual links</a> permissions to edit field content without visiting a separate page. For more information, see the <a href=":handbook_url">online documentation for the Quick Edit module</a>.', [':handbook_url' => 'https://www.drupal.org/documentation/modules/edit', ':quickedit_permission' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-quickedit']), ':contextual_permission' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-contextual'])]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Editing content in-place') . '</dt>';
$output .= '<dd>';
- $output .= '<p>' . t('To edit content in place, you need to activate quick edit mode for a content item. Activate quick edit mode by choosing Quick edit from the contextual links for an area displaying the content (see the <a href=":contextual">Contextual Links module help</a> for more information about how to use contextual links).', array(':contextual' => \Drupal::url('help.page', array('name' => 'contextual')))) . '</p>';
+ $output .= '<p>' . t('To edit content in place, you need to activate quick edit mode for a content item. Activate quick edit mode by choosing Quick edit from the contextual links for an area displaying the content (see the <a href=":contextual">Contextual Links module help</a> for more information about how to use contextual links).', [':contextual' => \Drupal::url('help.page', ['name' => 'contextual'])]) . '</p>';
$output .= '<p>' . t('Once quick edit mode is activated, you will be able to edit the individual fields of your content. In the default theme, with a JavaScript-enabled browser and a mouse, the output of different fields in your content is outlined in blue, a pop-up gives the field name as you hover over the field output, and clicking on a field activates the editor. Closing the pop-up window ends quick edit mode.') . '</p>';
$output .= '</dd>';
$output .= '</dl>';
@@ -108,7 +108,7 @@ function quickedit_field_formatter_info_alter(&$info) {
foreach ($info as $key => $settings) {
// Set in-place editor to 'form' if none is supplied.
if (empty($settings['quickedit'])) {
- $info[$key]['quickedit'] = array('editor' => 'form');
+ $info[$key]['quickedit'] = ['editor' => 'form'];
}
}
}
diff --git a/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php b/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php
index 7ea42b43447..1e84b0eb191 100644
--- a/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php
+++ b/core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php
@@ -27,7 +27,7 @@ class FieldFormSavedCommand extends BaseCommand {
* The same re-rendered edited field, but in different view modes, for other
* instances of the same field on the user's page. Keyed by view mode.
*/
- public function __construct($data, $other_view_modes = array()) {
+ public function __construct($data, $other_view_modes = []) {
parent::__construct('quickeditFieldFormSaved', $data);
$this->other_view_modes = $other_view_modes;
@@ -37,11 +37,11 @@ class FieldFormSavedCommand extends BaseCommand {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => $this->command,
'data' => $this->data,
'other_view_modes' => $this->other_view_modes,
- );
+ ];
}
}
diff --git a/core/modules/quickedit/src/EditorSelector.php b/core/modules/quickedit/src/EditorSelector.php
index a531b1a49a5..9149786f04e 100644
--- a/core/modules/quickedit/src/EditorSelector.php
+++ b/core/modules/quickedit/src/EditorSelector.php
@@ -65,7 +65,7 @@ class EditorSelector implements EditorSelectorInterface {
}
// No early return, so create a list of all choices.
- $editor_choices = array($editor_id);
+ $editor_choices = [$editor_id];
if (isset($this->alternatives[$editor_id])) {
$editor_choices = array_merge($editor_choices, $this->alternatives[$editor_id]);
}
@@ -86,7 +86,7 @@ class EditorSelector implements EditorSelectorInterface {
* {@inheritdoc}
*/
public function getEditorAttachments(array $editor_ids) {
- $attachments = array();
+ $attachments = [];
$editor_ids = array_unique($editor_ids);
// Editor plugins' attachments.
diff --git a/core/modules/quickedit/src/Form/QuickEditFieldForm.php b/core/modules/quickedit/src/Form/QuickEditFieldForm.php
index e64f3f2d143..ba2dac38eb1 100644
--- a/core/modules/quickedit/src/Form/QuickEditFieldForm.php
+++ b/core/modules/quickedit/src/Form/QuickEditFieldForm.php
@@ -100,19 +100,19 @@ class QuickEditFieldForm extends FormBase {
// Add a dummy changed timestamp field to attach form errors to.
if ($entity instanceof EntityChangedInterface) {
- $form['changed_field'] = array(
+ $form['changed_field'] = [
'#type' => 'hidden',
'#value' => $entity->getChangedTime(),
- );
+ ];
}
// Add a submit button. Give it a class for easy JavaScript targeting.
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
- '#attributes' => array('class' => array('quickedit-form-submit')),
- );
+ '#attributes' => ['class' => ['quickedit-form-submit']],
+ ];
// Simplify it for optimal in-place use.
$this->simplify($form, $form_state);
@@ -183,7 +183,7 @@ class QuickEditFieldForm extends FormBase {
// @todo Refine automated log messages and abstract them to all entity
// types: https://www.drupal.org/node/1678002.
if ($entity->getEntityTypeId() == 'node' && $entity->isNewRevision() && $entity->revision_log->isEmpty()) {
- $entity->revision_log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
+ $entity->revision_log = t('Updated the %field-name field through in-place editing.', ['%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()]);
}
return $entity;
diff --git a/core/modules/quickedit/src/MetadataGenerator.php b/core/modules/quickedit/src/MetadataGenerator.php
index 06f0dafe500..f01256fcbbf 100644
--- a/core/modules/quickedit/src/MetadataGenerator.php
+++ b/core/modules/quickedit/src/MetadataGenerator.php
@@ -54,9 +54,9 @@ class MetadataGenerator implements MetadataGeneratorInterface {
* {@inheritdoc}
*/
public function generateEntityMetadata(EntityInterface $entity) {
- return array(
+ return [
'label' => $entity->label(),
- );
+ ];
}
/**
@@ -69,24 +69,24 @@ class MetadataGenerator implements MetadataGeneratorInterface {
// Early-return if user does not have access.
$access = $this->accessChecker->accessEditEntityField($entity, $field_name);
if (!$access) {
- return array('access' => FALSE);
+ return ['access' => FALSE];
}
// Early-return if no editor is available.
$formatter_id = EntityViewDisplay::collectRenderDisplay($entity, $view_mode)->getRenderer($field_name)->getPluginId();
$editor_id = $this->editorSelector->getEditor($formatter_id, $items);
if (!isset($editor_id)) {
- return array('access' => FALSE);
+ return ['access' => FALSE];
}
// Gather metadata, allow the editor to add additional metadata of its own.
$label = $items->getFieldDefinition()->getLabel();
$editor = $this->editorManager->createInstance($editor_id);
- $metadata = array(
+ $metadata = [
'label' => $label,
'access' => TRUE,
'editor' => $editor_id,
- );
+ ];
$custom_metadata = $editor->getMetadata($items);
if (count($custom_metadata)) {
$metadata['custom'] = $custom_metadata;
diff --git a/core/modules/quickedit/src/Plugin/InPlaceEditor/FormEditor.php b/core/modules/quickedit/src/Plugin/InPlaceEditor/FormEditor.php
index 6a9907086e7..83ab1b46364 100644
--- a/core/modules/quickedit/src/Plugin/InPlaceEditor/FormEditor.php
+++ b/core/modules/quickedit/src/Plugin/InPlaceEditor/FormEditor.php
@@ -25,11 +25,11 @@ class FormEditor extends InPlaceEditorBase {
* {@inheritdoc}
*/
public function getAttachments() {
- return array(
- 'library' => array(
+ return [
+ 'library' => [
'quickedit/quickedit.inPlaceEditor.form',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
index 1f61a5621cc..5217c20f4a1 100644
--- a/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
+++ b/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
@@ -28,11 +28,11 @@ class PlainTextEditor extends InPlaceEditorBase {
* {@inheritdoc}
*/
public function getAttachments() {
- return array(
- 'library' => array(
+ return [
+ 'library' => [
'quickedit/quickedit.inPlaceEditor.plainText',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/quickedit/src/Plugin/InPlaceEditorBase.php b/core/modules/quickedit/src/Plugin/InPlaceEditorBase.php
index d09c38e188a..c7b54aa1a07 100644
--- a/core/modules/quickedit/src/Plugin/InPlaceEditorBase.php
+++ b/core/modules/quickedit/src/Plugin/InPlaceEditorBase.php
@@ -19,7 +19,7 @@ abstract class InPlaceEditorBase extends PluginBase implements InPlaceEditorInte
* {@inheritdoc}
*/
function getMetadata(FieldItemListInterface $items) {
- return array();
+ return [];
}
}
diff --git a/core/modules/quickedit/src/QuickEditController.php b/core/modules/quickedit/src/QuickEditController.php
index a42bcd09396..2b1e4b230a2 100644
--- a/core/modules/quickedit/src/QuickEditController.php
+++ b/core/modules/quickedit/src/QuickEditController.php
@@ -98,7 +98,7 @@ class QuickEditController extends ControllerBase {
}
$entities = $request->request->get('entities');
- $metadata = array();
+ $metadata = [];
foreach ($fields as $field) {
list($entity_type, $entity_id, $field_name, $langcode, $view_mode) = explode('/', $field);
@@ -205,7 +205,7 @@ class QuickEditController extends ControllerBase {
// Re-render the updated field for other view modes (i.e. for other
// instances of the same logical field on the user's page).
- $other_view_mode_ids = $request->request->get('other_view_modes') ?: array();
+ $other_view_mode_ids = $request->request->get('other_view_modes') ?: [];
$other_view_modes = array_map($render_field_in_view_mode, array_combine($other_view_mode_ids, $other_view_mode_ids));
$response->addCommand(new FieldFormSavedCommand($output, $other_view_modes));
@@ -220,9 +220,9 @@ class QuickEditController extends ControllerBase {
$errors = $form_state->getErrors();
if (count($errors)) {
- $status_messages = array(
+ $status_messages = [
'#type' => 'status_messages'
- );
+ ];
$response->addCommand(new FieldFormValidationErrorsCommand($this->renderer->renderRoot($status_messages)));
}
}
@@ -266,7 +266,7 @@ class QuickEditController extends ControllerBase {
// by a dash; the first part must be the module name.
$mode_id_parts = explode('-', $view_mode_id, 2);
$module = reset($mode_id_parts);
- $args = array($entity, $field_name, $view_mode_id, $langcode);
+ $args = [$entity, $field_name, $view_mode_id, $langcode];
$output = $this->moduleHandler()->invoke($module, 'quickedit_render_field', $args);
}
@@ -291,10 +291,10 @@ class QuickEditController extends ControllerBase {
// Return information about the entity that allows a front end application
// to identify it.
- $output = array(
+ $output = [
'entity_type' => $entity->getEntityTypeId(),
'entity_id' => $entity->id()
- );
+ ];
// Respond to client that the entity was saved properly.
$response = new AjaxResponse();
diff --git a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
index 1eedb1c665c..a1ef6cd2e8b 100644
--- a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
+++ b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php
@@ -25,7 +25,7 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'taxonomy', 'quickedit');
+ public static $modules = ['node', 'taxonomy', 'quickedit'];
/**
* Stores the node used for the tests.
@@ -72,9 +72,9 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
- ));
+ ]);
// Create the vocabulary for the tag field.
$this->vocabulary = Vocabulary::create([
'name' => 'quickedit testing tags',
@@ -83,12 +83,12 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
$this->vocabulary->save();
$this->fieldName = 'field_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
@@ -114,7 +114,7 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
$this->term1 = $this->createTerm();
$this->term2 = $this->createTerm();
- $node = array();
+ $node = [];
$node['type'] = 'article';
$node[$this->fieldName][]['target_id'] = $this->term1->id();
$node[$this->fieldName][]['target_id'] = $this->term2->id();
@@ -130,7 +130,7 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
$this->drupalLogin($this->editorUser);
$quickedit_uri = 'quickedit/form/node/' . $this->node->id() . '/' . $this->fieldName . '/' . $this->node->language()->getId() . '/full';
- $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost($quickedit_uri, '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$ajax_commands = Json::decode($response);
@@ -140,13 +140,13 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
$this->assertTrue($form_tokens_found, 'Form tokens found in output.');
if ($form_tokens_found) {
- $post = array(
+ $post = [
'form_id' => 'quickedit_field_form',
'form_token' => $token_match[1],
'form_build_id' => $build_id_match[1],
- $this->fieldName . '[target_id]' => implode(', ', array($this->term1->getName(), 'new term', $this->term2->getName())),
+ $this->fieldName . '[target_id]' => implode(', ', [$this->term1->getName(), 'new term', $this->term2->getName()]),
'op' => t('Save'),
- );
+ ];
// Submit field form and check response. Should render back all the terms.
$response = $this->drupalPost($quickedit_uri, '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
@@ -161,7 +161,7 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
// Load the form again, which should now get it back from
// PrivateTempStore.
$quickedit_uri = 'quickedit/form/node/' . $this->node->id() . '/' . $this->fieldName . '/' . $this->node->language()->getId() . '/full';
- $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost($quickedit_uri, '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$ajax_commands = Json::decode($response);
@@ -170,15 +170,15 @@ class QuickEditAutocompleteTermTest extends WebTestBase {
// taxonomy terms, including the one that has just been newly created and
// which is not yet stored.
$this->setRawContent($ajax_commands[0]['data']);
- $expected = array(
+ $expected = [
$this->term1->getName() . ' (' . $this->term1->id() . ')',
'new term',
$this->term2->getName() . ' (' . $this->term2->id() . ')',
- );
+ ];
$this->assertFieldByName($this->fieldName . '[target_id]', implode(', ', $expected));
// Save the entity.
- $post = array('nocssjs' => 'true');
+ $post = ['nocssjs' => 'true'];
$response = $this->drupalPostWithFormat('quickedit/entity/node/' . $this->node->id(), 'json', $post);
$this->assertResponse(200);
diff --git a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
index 1570a27ad7d..41f26a841fc 100644
--- a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
+++ b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
@@ -27,13 +27,13 @@ class QuickEditLoadingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'contextual',
'quickedit',
'filter',
'node',
'image',
- );
+ ];
/**
* An user with permissions to create and edit articles.
@@ -53,19 +53,19 @@ class QuickEditLoadingTest extends WebTestBase {
parent::setUp();
// Create a text format.
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$filtered_html_format->save();
// Create a node type.
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
- ));
+ ]);
// Set the node type to initially not have revisions.
// Testing with revisions will be done later.
@@ -74,22 +74,22 @@ class QuickEditLoadingTest extends WebTestBase {
$node_type->save();
// Create one node of the above node type using the above text format.
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'type' => 'article',
- 'body' => array(
- 0 => array(
+ 'body' => [
+ 0 => [
'value' => '<p>How are you?</p>',
'format' => 'filtered_html',
- )
- ),
+ ]
+ ],
'revision_log' => $this->randomString(),
- ));
+ ]);
// Create 2 users, the only difference being the ability to use in-place
// editing
- $basic_permissions = array('access content', 'create article content', 'edit any article content', 'use text format filtered_html', 'access contextual links');
+ $basic_permissions = ['access content', 'create article content', 'edit any article content', 'use text format filtered_html', 'access contextual links'];
$this->authorUser = $this->drupalCreateUser($basic_permissions);
- $this->editorUser = $this->drupalCreateUser(array_merge($basic_permissions, array('access in-place editing')));
+ $this->editorUser = $this->drupalCreateUser(array_merge($basic_permissions, ['access in-place editing']));
}
/**
@@ -110,7 +110,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertNoFieldByXPath('//h1[contains(@class, "js-quickedit-page-title")]');
// Retrieving the metadata should result in an empty 403 response.
- $post = array('fields[0]' => 'node/1/body/en/full');
+ $post = ['fields[0]' => 'node/1/body/en/full'];
$response = $this->drupalPostWithFormat(Url::fromRoute('quickedit.metadata'), 'json', $post);
$this->assertIdentical(Json::encode(['message' => "The 'access in-place editing' permission is required."]), $response);
$this->assertResponse(403);
@@ -118,16 +118,16 @@ class QuickEditLoadingTest extends WebTestBase {
// Quick Edit's JavaScript would never hit these endpoints if the metadata
// was empty as above, but we need to make sure that malicious users aren't
// able to use any of the other endpoints either.
- $post = array('editors[0]' => 'form') + $this->getAjaxPageStatePostData();
+ $post = ['editors[0]' => 'form'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/attachments', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$message = Json::encode(['message' => "The 'access in-place editing' permission is required."]);
$this->assertIdentical($message, $response);
$this->assertResponse(403);
- $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertIdentical($message, $response);
$this->assertResponse(403);
- $edit = array();
+ $edit = [];
$edit['form_id'] = 'quickedit_field_form';
$edit['form_token'] = 'xIOzMjuc-PULKsRn_KxFn7xzNk5Bx7XKXLfQfw1qOnA';
$edit['form_build_id'] = 'form-kVmovBpyX-SJfTT5kY0pjTV35TV-znor--a64dEnMR8';
@@ -138,7 +138,7 @@ class QuickEditLoadingTest extends WebTestBase {
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', '', $edit, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertIdentical($message, $response);
$this->assertResponse(403);
- $post = array('nocssjs' => 'true');
+ $post = ['nocssjs' => 'true'];
$response = $this->drupalPostWithFormat('quickedit/entity/' . 'node/1', 'json', $post);
$this->assertIdentical(Json::encode(['message' => "The 'access in-place editing' permission is required."]), $response);
$this->assertResponse(403);
@@ -173,16 +173,16 @@ class QuickEditLoadingTest extends WebTestBase {
// Retrieving the metadata should result in a 200 JSON response.
$htmlPageDrupalSettings = $this->drupalSettings;
- $post = array('fields[0]' => 'node/1/body/en/full');
+ $post = ['fields[0]' => 'node/1/body/en/full'];
$response = $this->drupalPostWithFormat('quickedit/metadata', 'json', $post);
$this->assertResponse(200);
- $expected = array(
- 'node/1/body/en/full' => array(
+ $expected = [
+ 'node/1/body/en/full' => [
'label' => 'Body',
'access' => TRUE,
'editor' => 'form',
- )
- );
+ ]
+ ];
$this->assertIdentical(Json::decode($response), $expected, 'The metadata HTTP request answers with the correct JSON response.');
// Restore drupalSettings to build the next requests; simpletest wipes them
// after a JSON response.
@@ -191,7 +191,7 @@ class QuickEditLoadingTest extends WebTestBase {
// Retrieving the attachments should result in a 200 response, containing:
// 1. a settings command with useless metadata: AjaxController is dumb
// 2. an insert command that loads the required in-place editors
- $post = array('editors[0]' => 'form') + $this->getAjaxPageStatePostData();
+ $post = ['editors[0]' => 'form'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/attachments', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$ajax_commands = Json::decode($response);
$this->assertIdentical(2, count($ajax_commands), 'The attachments HTTP request results in two AJAX commands.');
@@ -203,7 +203,7 @@ class QuickEditLoadingTest extends WebTestBase {
// Retrieving the form for this field should result in a 200 response,
// containing only a quickeditFieldForm command.
- $post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['nocssjs' => 'true', 'reset' => 'true'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
@@ -217,17 +217,17 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertTrue($form_tokens_found, 'Form tokens found in output.');
if ($form_tokens_found) {
- $edit = array(
+ $edit = [
'body[0][summary]' => '',
'body[0][value]' => '<p>Fine thanks.</p>',
'body[0][format]' => 'filtered_html',
'op' => t('Save'),
- );
- $post = array(
+ ];
+ $post = [
'form_id' => 'quickedit_field_form',
'form_token' => $token_match[1],
'form_build_id' => $build_id_match[1],
- );
+ ];
$post += $edit + $this->getAjaxPageStatePostData();
// Submit field form and check response. This should store the updated
@@ -238,14 +238,14 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
$this->assertIdentical('quickeditFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldFormSaved command.');
$this->assertTrue(strpos($ajax_commands[0]['data'], 'Fine thanks.'), 'Form value saved and printed back.');
- $this->assertIdentical($ajax_commands[0]['other_view_modes'], array(), 'Field was not rendered in any other view mode.');
+ $this->assertIdentical($ajax_commands[0]['other_view_modes'], [], 'Field was not rendered in any other view mode.');
// Ensure the text on the original node did not change yet.
$this->drupalGet('node/1');
$this->assertText('How are you?');
// Save the entity by moving the PrivateTempStore values to entity storage.
- $post = array('nocssjs' => 'true');
+ $post = ['nocssjs' => 'true'];
$response = $this->drupalPostWithFormat('quickedit/entity/' . 'node/1', 'json', $post);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
@@ -273,7 +273,7 @@ class QuickEditLoadingTest extends WebTestBase {
$node_type->save();
// Retrieve field form.
- $post = array('nocssjs' => 'true', 'reset' => 'true');
+ $post = ['nocssjs' => 'true', 'reset' => 'true'];
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
@@ -285,11 +285,11 @@ class QuickEditLoadingTest extends WebTestBase {
preg_match('/\sname="form_token" value="([^"]+)"/', $ajax_commands[0]['data'], $token_match);
preg_match('/\sname="form_build_id" value="([^"]+)"/', $ajax_commands[0]['data'], $build_id_match);
$edit['body[0][value]'] = '<p>kthxbye</p>';
- $post = array(
+ $post = [
'form_id' => 'quickedit_field_form',
'form_token' => $token_match[1],
'form_build_id' => $build_id_match[1],
- );
+ ];
$post += $edit + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(200);
@@ -299,7 +299,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertTrue(strpos($ajax_commands[0]['data'], 'kthxbye'), 'Form value saved and printed back.');
// Save the entity.
- $post = array('nocssjs' => 'true');
+ $post = ['nocssjs' => 'true'];
$response = $this->drupalPostWithFormat('quickedit/entity/' . 'node/1', 'json', $post);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
@@ -326,21 +326,21 @@ class QuickEditLoadingTest extends WebTestBase {
// Ensure that the full page title is actually in-place editable
$node = Node::load(1);
- $elements = $this->xpath('//h1/span[@data-quickedit-field-id="node/1/title/en/full" and normalize-space(text())=:title]', array(':title' => $node->label()));
+ $elements = $this->xpath('//h1/span[@data-quickedit-field-id="node/1/title/en/full" and normalize-space(text())=:title]', [':title' => $node->label()]);
$this->assertTrue(!empty($elements), 'Title with data-quickedit-field-id attribute found.');
// Retrieving the metadata should result in a 200 JSON response.
$htmlPageDrupalSettings = $this->drupalSettings;
- $post = array('fields[0]' => 'node/1/title/en/full');
+ $post = ['fields[0]' => 'node/1/title/en/full'];
$response = $this->drupalPostWithFormat('quickedit/metadata', 'json', $post);
$this->assertResponse(200);
- $expected = array(
- 'node/1/title/en/full' => array(
+ $expected = [
+ 'node/1/title/en/full' => [
'label' => 'Title',
'access' => TRUE,
'editor' => 'plain_text',
- )
- );
+ ]
+ ];
$this->assertIdentical(Json::decode($response), $expected, 'The metadata HTTP request answers with the correct JSON response.');
// Restore drupalSettings to build the next requests; simpletest wipes them
// after a JSON response.
@@ -348,7 +348,7 @@ class QuickEditLoadingTest extends WebTestBase {
// Retrieving the form for this field should result in a 200 response,
// containing only a quickeditFieldForm command.
- $post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['nocssjs' => 'true', 'reset' => 'true'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/title/en/full', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
@@ -363,15 +363,15 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertTrue($form_tokens_found, 'Form tokens found in output.');
if ($form_tokens_found) {
- $edit = array(
+ $edit = [
'title[0][value]' => 'Obligatory question',
'op' => t('Save'),
- );
- $post = array(
+ ];
+ $post = [
'form_id' => 'quickedit_field_form',
'form_token' => $token_match[1],
'form_build_id' => $build_id_match[1],
- );
+ ];
$post += $edit + $this->getAjaxPageStatePostData();
// Submit field form and check response. This should store the
@@ -388,7 +388,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertNoText('Obligatory question');
// Save the entity by moving the PrivateTempStore values to entity storage.
- $post = array('nocssjs' => 'true');
+ $post = ['nocssjs' => 'true'];
$response = $this->drupalPostWithFormat('quickedit/entity/' . 'node/1', 'json', $post);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
@@ -409,9 +409,9 @@ class QuickEditLoadingTest extends WebTestBase {
*/
public function testDisplayOptions() {
$node = Node::load('1');
- $display_settings = array(
+ $display_settings = [
'label' => 'inline',
- );
+ ];
$build = $node->body->view($display_settings);
$output = \Drupal::service('renderer')->renderRoot($build);
$this->assertFalse(strpos($output, 'data-quickedit-field-id'), 'data-quickedit-field-id attribute not added when rendering field using dynamic display options.');
@@ -421,13 +421,13 @@ class QuickEditLoadingTest extends WebTestBase {
* Tests that Quick Edit works with custom render pipelines.
*/
public function testCustomPipeline() {
- \Drupal::service('module_installer')->install(array('quickedit_test'));
+ \Drupal::service('module_installer')->install(['quickedit_test']);
$custom_render_url = 'quickedit/form/node/1/body/en/quickedit_test-custom-render-data';
$this->drupalLogin($this->editorUser);
// Request editing to render results with the custom render pipeline.
- $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost($custom_render_url, '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$ajax_commands = Json::decode($response);
@@ -437,7 +437,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertTrue($form_tokens_found, 'Form tokens found in output.');
if ($form_tokens_found) {
- $post = array(
+ $post = [
'form_id' => 'quickedit_field_form',
'form_token' => $token_match[1],
'form_build_id' => $build_id_match[1],
@@ -445,10 +445,10 @@ class QuickEditLoadingTest extends WebTestBase {
'body[0][value]' => '<p>Fine thanks.</p>',
'body[0][format]' => 'filtered_html',
'op' => t('Save'),
- );
+ ];
// Assume there is another field on this page, which doesn't use a custom
// render pipeline, but the default one, and it uses the "full" view mode.
- $post += array('other_view_modes[]' => 'full');
+ $post += ['other_view_modes[]' => 'full'];
// Submit field form and check response. Should render with the custom
// render pipeline.
@@ -459,7 +459,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertIdentical('quickeditFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldFormSaved command.');
$this->assertTrue(strpos($ajax_commands[0]['data'], 'Fine thanks.'), 'Form value saved and printed back.');
$this->assertTrue(strpos($ajax_commands[0]['data'], '<div class="quickedit-test-wrapper">') !== FALSE, 'Custom render pipeline used to render the value.');
- $this->assertIdentical(array_keys($ajax_commands[0]['other_view_modes']), array('full'), 'Field was also rendered in the "full" view mode.');
+ $this->assertIdentical(array_keys($ajax_commands[0]['other_view_modes']), ['full'], 'Field was also rendered in the "full" view mode.');
$this->assertTrue(strpos($ajax_commands[0]['other_view_modes']['full'], 'Fine thanks.'), '"full" version of field contains the form value.');
}
}
@@ -471,7 +471,7 @@ class QuickEditLoadingTest extends WebTestBase {
public function testConcurrentEdit() {
$this->drupalLogin($this->editorUser);
- $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
@@ -482,7 +482,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->assertTrue($form_tokens_found, 'Form tokens found in output.');
if ($form_tokens_found) {
- $post = array(
+ $post = [
'nocssjs' => 'true',
'form_id' => 'quickedit_field_form',
'form_token' => $token_match[1],
@@ -491,10 +491,10 @@ class QuickEditLoadingTest extends WebTestBase {
'body[0][value]' => '<p>Fine thanks.</p>',
'body[0][format]' => 'filtered_html',
'op' => t('Save'),
- );
+ ];
// Save the node on the regular node edit form.
- $this->drupalPostForm('node/1/edit', array(), t('Save'));
+ $this->drupalPostForm('node/1/edit', [], t('Save'));
// Ensure different save timestamps for field editing.
sleep(2);
@@ -513,7 +513,7 @@ class QuickEditLoadingTest extends WebTestBase {
* Tests that Quick Edit's data- attributes are present for content blocks.
*/
public function testContentBlock() {
- \Drupal::service('module_installer')->install(array('block_content'));
+ \Drupal::service('module_installer')->install(['block_content']);
// Create and place a content_block block.
$block = BlockContent::create([
diff --git a/core/modules/quickedit/tests/modules/quickedit_test.module b/core/modules/quickedit/tests/modules/quickedit_test.module
index 3d2106d31ea..b6199a6e8c9 100644
--- a/core/modules/quickedit/tests/modules/quickedit_test.module
+++ b/core/modules/quickedit/tests/modules/quickedit_test.module
@@ -12,11 +12,11 @@ use Drupal\Core\Entity\EntityInterface;
*/
function quickedit_test_quickedit_render_field(EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
$entity = \Drupal::entityManager()->getTranslationFromContext($entity, $langcode);
- return array(
+ return [
'#prefix' => '<div class="quickedit-test-wrapper">',
'field' => $entity->get($field_name)->view($view_mode_id),
'#suffix' => '</div>',
- );
+ ];
}
/**
diff --git a/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php b/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php
index 596df75a5c2..c26bf909dec 100644
--- a/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php
+++ b/core/modules/quickedit/tests/modules/src/Plugin/InPlaceEditor/WysiwygEditor.php
@@ -42,11 +42,11 @@ class WysiwygEditor extends InPlaceEditorBase {
* {@inheritdoc}
*/
public function getAttachments() {
- return array(
- 'library' => array(
+ return [
+ 'library' => [
'quickedit_test/not-existing-wysiwyg',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php b/core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php
index 0b3820cedf3..08a8fe04add 100644
--- a/core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php
+++ b/core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php
@@ -53,13 +53,13 @@ class EditorSelectionTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'string', 1, 'Simple text field',
// Instance settings.
- array(),
+ [],
// Widget type & settings.
'string_textfield',
- array('size' => 42),
+ ['size' => 42],
// 'default' formatter type & settings.
'string',
- array()
+ []
);
// Create an entity with values for this text field.
@@ -84,7 +84,7 @@ class EditorSelectionTest extends QuickEditTestBase {
*/
public function testTextWysiwyg() {
// Enable edit_test module so that the 'wysiwyg' editor becomes available.
- $this->enableModules(array('quickedit_test'));
+ $this->enableModules(['quickedit_test']);
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
@@ -92,13 +92,13 @@ class EditorSelectionTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'text', 1, 'Long text field',
// Instance settings.
- array(),
+ [],
// Widget type & settings.
'text_textarea',
- array('size' => 42),
+ ['size' => 42],
// 'default' formatter type & settings.
'text_default',
- array()
+ []
);
// Create an entity with values for this text field.
@@ -129,13 +129,13 @@ class EditorSelectionTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'integer', 1, 'Simple number field',
// Instance settings.
- array(),
+ [],
// Widget type & settings.
'number',
- array(),
+ [],
// 'default' formatter type & settings.
'number_integer',
- array()
+ []
);
// Create an entity with values for this text field.
diff --git a/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php b/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php
index 28480f4b64f..9a453fb7ab5 100644
--- a/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php
+++ b/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php
@@ -18,7 +18,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('quickedit_test');
+ public static $modules = ['quickedit_test'];
/**
* The manager for editor plugins.
@@ -66,26 +66,26 @@ class MetadataGeneratorTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_1_name, 'string', 1, $field_1_label,
// Instance settings.
- array(),
+ [],
// Widget type & settings.
'string_textfield',
- array('size' => 42),
+ ['size' => 42],
// 'default' formatter type & settings.
'string',
- array()
+ []
);
$field_2_name = 'field_nr';
$field_2_label = 'Simple number field';
$this->createFieldWithStorage(
$field_2_name, 'integer', 1, $field_2_label,
// Instance settings.
- array(),
+ [],
// Widget type & settings.
'number',
- array(),
+ [],
// 'default' formatter type & settings.
'number_integer',
- array()
+ []
);
// Create an entity with values for this text field.
@@ -98,21 +98,21 @@ class MetadataGeneratorTest extends QuickEditTestBase {
// Verify metadata for field 1.
$items_1 = $entity->get($field_1_name);
$metadata_1 = $this->metadataGenerator->generateFieldMetadata($items_1, 'default');
- $expected_1 = array(
+ $expected_1 = [
'access' => TRUE,
'label' => 'Plain text field',
'editor' => 'plain_text',
- );
+ ];
$this->assertEqual($expected_1, $metadata_1, 'The correct metadata is generated for the first field.');
// Verify metadata for field 2.
$items_2 = $entity->get($field_2_name);
$metadata_2 = $this->metadataGenerator->generateFieldMetadata($items_2, 'default');
- $expected_2 = array(
+ $expected_2 = [
'access' => TRUE,
'label' => 'Simple number field',
'editor' => 'form',
- );
+ ];
$this->assertEqual($expected_2, $metadata_2, 'The correct metadata is generated for the second field.');
}
@@ -134,24 +134,24 @@ class MetadataGeneratorTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'text', 1, $field_label,
// Instance settings.
- array(),
+ [],
// Widget type & settings.
'text_textfield',
- array('size' => 42),
+ ['size' => 42],
// 'default' formatter type & settings.
'text_default',
- array()
+ []
);
// Create a text format.
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
- 'filters' => array(
- 'filter_htmlcorrector' => array('status' => 1),
- ),
- ));
+ 'filters' => [
+ 'filter_htmlcorrector' => ['status' => 1],
+ ],
+ ]);
$full_html_format->save();
// Create an entity with values for this rich text field.
@@ -164,14 +164,14 @@ class MetadataGeneratorTest extends QuickEditTestBase {
// Verify metadata.
$items = $entity->get($field_name);
$metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default');
- $expected = array(
+ $expected = [
'access' => TRUE,
'label' => 'Rich text field',
'editor' => 'wysiwyg',
- 'custom' => array(
+ 'custom' => [
'format' => 'full_html'
- ),
- );
+ ],
+ ];
$this->assertEqual($expected, $metadata); //, 'The correct metadata (including custom metadata) is generated.');
}
diff --git a/core/modules/quickedit/tests/src/Kernel/QuickEditTestBase.php b/core/modules/quickedit/tests/src/Kernel/QuickEditTestBase.php
index bfdb229f68e..29437485878 100644
--- a/core/modules/quickedit/tests/src/Kernel/QuickEditTestBase.php
+++ b/core/modules/quickedit/tests/src/Kernel/QuickEditTestBase.php
@@ -37,11 +37,11 @@ abstract class QuickEditTestBase extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->fields = new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS);
+ $this->fields = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
- $this->installConfig(array('field', 'filter'));
+ $this->installConfig(['field', 'filter']);
}
/**
@@ -67,12 +67,12 @@ abstract class QuickEditTestBase extends KernelTestBase {
*/
protected function createFieldWithStorage($field_name, $type, $cardinality, $label, $field_settings, $widget_type, $widget_settings, $formatter_type, $formatter_settings) {
$field_storage = $field_name . '_field_storage';
- $this->fields->$field_storage = FieldStorageConfig::create(array(
+ $this->fields->$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $type,
'cardinality' => $cardinality,
- ));
+ ]);
$this->fields->$field_storage->save();
$field = $field_name . '_field';
@@ -87,18 +87,18 @@ abstract class QuickEditTestBase extends KernelTestBase {
$this->fields->$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => $widget_type,
'settings' => $widget_settings,
- ))
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'label' => 'above',
'type' => $formatter_type,
'settings' => $formatter_settings
- ))
+ ])
->save();
}
diff --git a/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php b/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php
index 9f350576d99..0827436982f 100644
--- a/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php
+++ b/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php
@@ -43,11 +43,11 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
* @see \Drupal\Tests\edit\Unit\quickedit\Access\QuickEditEntityFieldAccessCheckTest::testAccess()
*/
public function providerTestAccess() {
- $data = array();
- $data[] = array(TRUE, TRUE, AccessResult::allowed());
- $data[] = array(FALSE, TRUE, AccessResult::neutral());
- $data[] = array(TRUE, FALSE, AccessResult::neutral());
- $data[] = array(FALSE, FALSE, AccessResult::neutral());
+ $data = [];
+ $data[] = [TRUE, TRUE, AccessResult::allowed()];
+ $data[] = [FALSE, TRUE, AccessResult::neutral()];
+ $data[] = [TRUE, FALSE, AccessResult::neutral()];
+ $data[] = [FALSE, FALSE, AccessResult::neutral()];
return $data;
}
@@ -108,15 +108,15 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
* Provides test data for testAccessForbidden.
*/
public function providerTestAccessForbidden() {
- $data = array();
+ $data = [];
// Tests the access method without a field_name.
- $data[] = array(NULL, LanguageInterface::LANGCODE_NOT_SPECIFIED);
+ $data[] = [NULL, LanguageInterface::LANGCODE_NOT_SPECIFIED];
// Tests the access method with a non-existent field.
- $data[] = array('not_valid', LanguageInterface::LANGCODE_NOT_SPECIFIED);
+ $data[] = ['not_valid', LanguageInterface::LANGCODE_NOT_SPECIFIED];
// Tests the access method without a langcode.
- $data[] = array('valid', NULL);
+ $data[] = ['valid', NULL];
// Tests the access method with an invalid langcode.
- $data[] = array('valid', 'xx-lolspeak');
+ $data[] = ['valid', 'xx-lolspeak'];
return $data;
}
@@ -132,16 +132,16 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
$entity->expects($this->any())
->method('hasTranslation')
- ->will($this->returnValueMap(array(
- array(LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE),
- array('xx-lolspeak', FALSE),
- )));
+ ->will($this->returnValueMap([
+ [LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE],
+ ['xx-lolspeak', FALSE],
+ ]));
$entity->expects($this->any())
->method('hasField')
- ->will($this->returnValueMap(array(
- array('valid', TRUE),
- array('not_valid', FALSE),
- )));
+ ->will($this->returnValueMap([
+ ['valid', TRUE],
+ ['not_valid', FALSE],
+ ]));
return $entity;
}
diff --git a/core/modules/rdf/rdf.api.php b/core/modules/rdf/rdf.api.php
index 3dbe7d1e267..dd7ae222721 100644
--- a/core/modules/rdf/rdf.api.php
+++ b/core/modules/rdf/rdf.api.php
@@ -25,7 +25,7 @@
* @ingroup rdf
*/
function hook_rdf_namespaces() {
- return array(
+ return [
'content' => 'http://purl.org/rss/1.0/modules/content/',
'dc' => 'http://purl.org/dc/terms/',
'foaf' => 'http://xmlns.com/foaf/0.1/',
@@ -35,7 +35,7 @@ function hook_rdf_namespaces() {
'sioct' => 'http://rdfs.org/sioc/types#',
'skos' => 'http://www.w3.org/2004/02/skos/core#',
'xsd' => 'http://www.w3.org/2001/XMLSchema#',
- );
+ ];
}
/**
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 3108ee12745..0afcb09186c 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -17,7 +17,7 @@ function rdf_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.rdf':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The RDF module enriches your content with metadata to let other applications (e.g., search engines, aggregators, and so on) better understand its relationships and attributes. This semantically enriched, machine-readable output for your website uses the <a href=":rdfa">RDFa specification</a>, which allows RDF data to be embedded in HTML markup. Other modules can define mappings of their data to RDF terms, and the RDF module makes this RDF data available to the theme. The core modules define RDF mappings for their data model, and the core themes output this RDF metadata information along with the human-readable visual information. For more information, see the <a href=":rdf">online documentation for the RDF module</a>.', array(':rdfa' => 'http://www.w3.org/TR/xhtml-rdfa-primer/', ':rdf' => 'https://www.drupal.org/documentation/modules/rdf')) . '</p>';
+ $output .= '<p>' . t('The RDF module enriches your content with metadata to let other applications (e.g., search engines, aggregators, and so on) better understand its relationships and attributes. This semantically enriched, machine-readable output for your website uses the <a href=":rdfa">RDFa specification</a>, which allows RDF data to be embedded in HTML markup. Other modules can define mappings of their data to RDF terms, and the RDF module makes this RDF data available to the theme. The core modules define RDF mappings for their data model, and the core themes output this RDF metadata information along with the human-readable visual information. For more information, see the <a href=":rdf">online documentation for the RDF module</a>.', [':rdfa' => 'http://www.w3.org/TR/xhtml-rdfa-primer/', ':rdf' => 'https://www.drupal.org/documentation/modules/rdf']) . '</p>';
return $output;
}
}
@@ -74,10 +74,10 @@ function rdf_get_mapping($entity_type, $bundle) {
// If not found, create a fresh mapping object.
if (!$mapping) {
- $mapping = RdfMapping::create(array(
+ $mapping = RdfMapping::create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
- ));
+ ]);
}
return $mapping;
@@ -87,7 +87,7 @@ function rdf_get_mapping($entity_type, $bundle) {
* Implements hook_rdf_namespaces().
*/
function rdf_rdf_namespaces() {
- return array(
+ return [
'content' => 'http://purl.org/rss/1.0/modules/content/',
'dc' => 'http://purl.org/dc/terms/',
'foaf' => 'http://xmlns.com/foaf/0.1/',
@@ -98,7 +98,7 @@ function rdf_rdf_namespaces() {
'sioct' => 'http://rdfs.org/sioc/types#',
'skos' => 'http://www.w3.org/2004/02/skos/core#',
'xsd' => 'http://www.w3.org/2001/XMLSchema#',
- );
+ ];
}
/**
@@ -108,14 +108,14 @@ function rdf_rdf_namespaces() {
* implement it.
*/
function rdf_get_namespaces() {
- $namespaces = array();
+ $namespaces = [];
// In order to resolve duplicate namespaces by using the earliest defined
// namespace, do not use \Drupal::moduleHandler()->invokeAll().
foreach (\Drupal::moduleHandler()->getImplementations('rdf_namespaces') as $module) {
$function = $module . '_rdf_namespaces';
foreach ($function() as $prefix => $namespace) {
if (array_key_exists($prefix, $namespaces) && $namespace !== $namespaces[$prefix]) {
- throw new Exception(t('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', array('@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix])));
+ throw new Exception(t('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', ['@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix]]));
}
else {
$namespaces[$prefix] = $namespace;
@@ -165,7 +165,7 @@ function rdf_get_namespaces() {
* RDFa attributes suitable for Drupal\Core\Template\Attribute.
*/
function rdf_rdfa_attributes($mapping, $data = NULL) {
- $attributes = array();
+ $attributes = [];
// The type of mapping defaults to 'property'.
$type = isset($mapping['mapping_type']) ? $mapping['mapping_type'] : 'property';
@@ -249,14 +249,14 @@ function rdf_comment_storage_load($comments) {
* Implements hook_theme().
*/
function rdf_theme() {
- return array(
- 'rdf_wrapper' => array(
- 'variables' => array('attributes' => array(), 'content' => NULL),
- ),
- 'rdf_metadata' => array(
- 'variables' => array('metadata' => array()),
- ),
- );
+ return [
+ 'rdf_wrapper' => [
+ 'variables' => ['attributes' => [], 'content' => NULL],
+ ],
+ 'rdf_metadata' => [
+ 'variables' => ['metadata' => []],
+ ],
+ ];
}
/**
@@ -266,7 +266,7 @@ function rdf_preprocess_html(&$variables) {
// Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
// attribute inside the html element.
if (!isset($variables['html_attributes']['prefix'])) {
- $variables['html_attributes']['prefix'] = array();
+ $variables['html_attributes']['prefix'] = [];
}
foreach (rdf_get_namespaces() as $prefix => $uri) {
$variables['html_attributes']['prefix'][] = $prefix . ': ' . $uri . " ";
@@ -315,20 +315,20 @@ function rdf_preprocess_node(&$variables) {
if ($title_mapping) {
$title_attributes['property'] = empty($title_mapping['properties']) ? NULL : $title_mapping['properties'];
$title_attributes['content'] = $variables['node']->label();
- $variables['title_suffix']['rdf_meta_title'] = array(
+ $variables['title_suffix']['rdf_meta_title'] = [
'#theme' => 'rdf_metadata',
- '#metadata' => array($title_attributes),
- );
+ '#metadata' => [$title_attributes],
+ ];
}
// Adds RDFa markup for the date.
$created_mapping = $mapping->getPreparedFieldMapping('created');
if (!empty($created_mapping) && $variables['display_submitted']) {
$date_attributes = rdf_rdfa_attributes($created_mapping, $variables['node']->get('created')->first()->toArray());
- $rdf_metadata = array(
+ $rdf_metadata = [
'#theme' => 'rdf_metadata',
- '#metadata' => array($date_attributes),
- );
+ '#metadata' => [$date_attributes],
+ ];
$variables['metadata'] = drupal_render($rdf_metadata);
}
@@ -345,10 +345,10 @@ function rdf_preprocess_node(&$variables) {
// Adds RDFa markup for the comment count near the node title as
// metadata.
$comment_count_attributes = rdf_rdfa_attributes($comment_count_mapping, $variables['node']->get($field_name)->comment_count);
- $variables['title_suffix']['rdf_meta_comment_count'] = array(
+ $variables['title_suffix']['rdf_meta_comment_count'] = [
'#theme' => 'rdf_metadata',
- '#metadata' => array($comment_count_attributes),
- );
+ '#metadata' => [$comment_count_attributes],
+ ];
}
}
}
@@ -377,15 +377,15 @@ function rdf_preprocess_user(&$variables) {
// rdf_preprocess_username().
$name_mapping = $mapping->getPreparedFieldMapping('name');
if (!empty($name_mapping['properties'])) {
- $username_meta = array(
+ $username_meta = [
'#tag' => 'meta',
- '#attributes' => array(
+ '#attributes' => [
'about' => $account->url(),
'property' => $name_mapping['properties'],
'content' => $account->getDisplayName(),
'lang' => '',
- ),
- );
+ ],
+ ];
$variables['#attached']['html_head'][] = [$username_meta, 'rdf_user_username'];
}
}
@@ -482,10 +482,10 @@ function rdf_preprocess_comment(&$variables) {
// cached as part of the entity.
$date_attributes = $comment->rdf_data['date'];
- $rdf_metadata = array(
+ $rdf_metadata = [
'#theme' => 'rdf_metadata',
- '#metadata' => array($date_attributes),
- );
+ '#metadata' => [$date_attributes],
+ ];
// Ensure the original variable is represented as a render array.
$created = !is_array($variables['created']) ? ['#markup' => $variables['created']] : $variables['created'];
$submitted = !is_array($variables['submitted']) ? ['#markup' => $variables['submitted']] : $variables['submitted'];
@@ -527,10 +527,10 @@ function rdf_preprocess_comment(&$variables) {
}
// Adds RDF metadata markup above comment body if any.
if (!empty($variables['rdf_metadata_attributes']) && isset($variables['content']['comment_body'])) {
- $rdf_metadata = array(
+ $rdf_metadata = [
'#theme' => 'rdf_metadata',
'#metadata' => $variables['rdf_metadata_attributes'],
- );
+ ];
if (!empty($variables['content']['comment_body']['#prefix'])) {
$rdf_metadata['#suffix'] = $variables['content']['comment_body']['#prefix'];
}
@@ -555,14 +555,14 @@ function rdf_preprocess_taxonomy_term(&$variables) {
// Add RDFa markup for the taxonomy term name as metadata, if present.
$name_field_mapping = $mapping->getPreparedFieldMapping('name');
if (!empty($name_field_mapping) && !empty($name_field_mapping['properties'])) {
- $name_attributes = array(
+ $name_attributes = [
'property' => $name_field_mapping['properties'],
'content' => $term->getName(),
- );
- $variables['title_suffix']['taxonomy_term_rdfa'] = array(
+ ];
+ $variables['title_suffix']['taxonomy_term_rdfa'] = [
'#theme' => 'rdf_metadata',
- '#metadata' => array($name_attributes),
- );
+ '#metadata' => [$name_attributes],
+ ];
}
}
@@ -573,7 +573,7 @@ function rdf_preprocess_image(&$variables) {
// Adds the RDF type for image. We cannot use the usual entity-based mapping
// to get 'foaf:Image' because image does not have its own entity type or
// bundle.
- $variables['attributes']['typeof'] = array('foaf:Image');
+ $variables['attributes']['typeof'] = ['foaf:Image'];
}
/**
diff --git a/core/modules/rdf/src/Entity/RdfMapping.php b/core/modules/rdf/src/Entity/RdfMapping.php
index 83fc4767d7b..076587fd241 100644
--- a/core/modules/rdf/src/Entity/RdfMapping.php
+++ b/core/modules/rdf/src/Entity/RdfMapping.php
@@ -59,20 +59,20 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
*
* @var array
*/
- protected $types = array();
+ protected $types = [];
/**
* The mappings for fields on this bundle.
*
* @var array
*/
- protected $fieldMappings = array();
+ protected $fieldMappings = [];
/**
* {@inheritdoc}
*/
public function getPreparedBundleMapping() {
- return array('types' => $this->types);
+ return ['types' => $this->types];
}
/**
@@ -80,9 +80,9 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
*/
public function getBundleMapping() {
if (!empty($this->types)) {
- return array('types' => $this->types);
+ return ['types' => $this->types];
}
- return array();
+ return [];
}
/**
@@ -100,16 +100,16 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
* {@inheritdoc}
*/
public function getPreparedFieldMapping($field_name) {
- $field_mapping = array(
+ $field_mapping = [
'properties' => NULL,
'datatype' => NULL,
'datatype_callback' => NULL,
'mapping_type' => NULL,
- );
+ ];
if (isset($this->fieldMappings[$field_name])) {
$field_mapping = array_merge($field_mapping, $this->fieldMappings[$field_name]);
}
- return empty($field_mapping['properties']) ? array() : $field_mapping;
+ return empty($field_mapping['properties']) ? [] : $field_mapping;
}
/**
@@ -119,13 +119,13 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
if (isset($this->fieldMappings[$field_name])) {
return $this->fieldMappings[$field_name];
}
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
- public function setFieldMapping($field_name, array $mapping = array()) {
+ public function setFieldMapping($field_name, array $mapping = []) {
$this->fieldMappings[$field_name] = $mapping;
return $this;
}
diff --git a/core/modules/rdf/src/RdfMappingInterface.php b/core/modules/rdf/src/RdfMappingInterface.php
index fa8def268e5..ce0128848a4 100644
--- a/core/modules/rdf/src/RdfMappingInterface.php
+++ b/core/modules/rdf/src/RdfMappingInterface.php
@@ -102,6 +102,6 @@ interface RdfMappingInterface extends ConfigEntityInterface {
* @return \Drupal\rdf\Entity\RdfMapping
* The RdfMapping object.
*/
- public function setFieldMapping($field_name, array $mapping = array());
+ public function setFieldMapping($field_name, array $mapping = []);
}
diff --git a/core/modules/rdf/src/Tests/CommentAttributesTest.php b/core/modules/rdf/src/Tests/CommentAttributesTest.php
index 5febcb98855..f05d9c1de7b 100644
--- a/core/modules/rdf/src/Tests/CommentAttributesTest.php
+++ b/core/modules/rdf/src/Tests/CommentAttributesTest.php
@@ -20,7 +20,7 @@ class CommentAttributesTest extends CommentTestBase {
*
* @var array
*/
- public static $modules = array('views', 'node', 'comment', 'rdf');
+ public static $modules = ['views', 'node', 'comment', 'rdf'];
/**
* URI of the front page of the Drupal site.
@@ -40,11 +40,11 @@ class CommentAttributesTest extends CommentTestBase {
parent::setUp();
// Enables anonymous user comments.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => TRUE,
- ));
+ ]);
// Allows anonymous to leave their contact information.
$this->setCommentAnonymous(COMMENT_ANONYMOUS_MAY_CONTACT);
$this->setCommentPreview(DRUPAL_OPTIONAL);
@@ -58,53 +58,53 @@ class CommentAttributesTest extends CommentTestBase {
// Set relation between node and comment.
$article_mapping = rdf_get_mapping('node', 'article');
- $comment_count_mapping = array(
- 'properties' => array('sioc:num_replies'),
+ $comment_count_mapping = [
+ 'properties' => ['sioc:num_replies'],
'datatype' => 'xsd:integer',
- 'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::rawValue'),
- );
+ 'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::rawValue'],
+ ];
$article_mapping->setFieldMapping('comment_count', $comment_count_mapping)->save();
// Save user mapping.
$user_mapping = rdf_get_mapping('user', 'user');
- $username_mapping = array(
- 'properties' => array('foaf:name'),
- );
+ $username_mapping = [
+ 'properties' => ['foaf:name'],
+ ];
$user_mapping->setFieldMapping('name', $username_mapping)->save();
- $user_mapping->setFieldMapping('homepage', array('properties' => array('foaf:page'), 'mapping_type' => 'rel'))->save();
+ $user_mapping->setFieldMapping('homepage', ['properties' => ['foaf:page'], 'mapping_type' => 'rel'])->save();
// Save comment mapping.
$mapping = rdf_get_mapping('comment', 'comment');
- $mapping->setBundleMapping(array('types' => array('sioc:Post', 'sioct:Comment')))->save();
- $field_mappings = array(
- 'subject' => array(
- 'properties' => array('dc:title'),
- ),
- 'created' => array(
- 'properties' => array('dc:date', 'dc:created'),
+ $mapping->setBundleMapping(['types' => ['sioc:Post', 'sioct:Comment']])->save();
+ $field_mappings = [
+ 'subject' => [
+ 'properties' => ['dc:title'],
+ ],
+ 'created' => [
+ 'properties' => ['dc:date', 'dc:created'],
'datatype' => 'xsd:dateTime',
- 'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
- ),
- 'changed' => array(
- 'properties' => array('dc:modified'),
+ 'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
+ ],
+ 'changed' => [
+ 'properties' => ['dc:modified'],
'datatype' => 'xsd:dateTime',
- 'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
- ),
- 'comment_body' => array(
- 'properties' => array('content:encoded'),
- ),
- 'pid' => array(
- 'properties' => array('sioc:reply_of'),
+ 'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
+ ],
+ 'comment_body' => [
+ 'properties' => ['content:encoded'],
+ ],
+ 'pid' => [
+ 'properties' => ['sioc:reply_of'],
'mapping_type' => 'rel',
- ),
- 'uid' => array(
- 'properties' => array('sioc:has_creator'),
+ ],
+ 'uid' => [
+ 'properties' => ['sioc:has_creator'],
'mapping_type' => 'rel',
- ),
- 'name' => array(
- 'properties' => array('foaf:name'),
- ),
- );
+ ],
+ 'name' => [
+ 'properties' => ['foaf:name'],
+ ],
+ ];
// Iterate over shared field mappings and save.
foreach ($field_mappings as $field_name => $field_mapping) {
$mapping->setFieldMapping($field_name, $field_mapping)->save();
@@ -126,11 +126,11 @@ class CommentAttributesTest extends CommentTestBase {
$parser->parse($graph, $this->drupalGet('node'), 'rdfa', $this->baseUri);
// Number of comments.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => 2,
'datatype' => 'http://www.w3.org/2001/XMLSchema#integer',
- );
+ ];
$this->assertTrue($graph->hasProperty($this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).');
// Tests number of comments in full node view, expected value is the same.
@@ -183,7 +183,7 @@ class CommentAttributesTest extends CommentTestBase {
$this->_testBasicCommentRdfaMarkup($graph, $comment1);
// Posts comment #2 as anonymous user.
- $anonymous_user = array();
+ $anonymous_user = [];
$anonymous_user['name'] = $this->randomMachineName();
$anonymous_user['mail'] = 'tester@simpletest.org';
$anonymous_user['homepage'] = 'http://example.org/';
@@ -222,22 +222,22 @@ class CommentAttributesTest extends CommentTestBase {
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
// Tests the reply_of relationship of a first level comment.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $this->nodeUri,
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_1_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
// Tests the reply_of relationship of a second level comment.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $this->nodeUri,
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $comment_1_uri,
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its parent comment found in RDF output (sioc:reply_of).');
}
@@ -251,61 +251,61 @@ class CommentAttributesTest extends CommentTestBase {
* @param $account
* An array containing information about an anonymous user.
*/
- function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = array()) {
- $comment_uri = $comment->url('canonical', array('absolute' => TRUE));
+ function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = []) {
+ $comment_uri = $comment->url('canonical', ['absolute' => TRUE]);
// Comment type.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://rdfs.org/sioc/types#Comment',
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioct:Comment).');
// Comment type.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://rdfs.org/sioc/ns#Post',
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioc:Post).');
// Comment title.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $comment->getSubject(),
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Comment subject found in RDF output (dc:title).');
// Comment date.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Comment date found in RDF output (dc:date).');
// Comment date.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Comment date found in RDF output (dc:created).');
// Comment body.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $comment->comment_body->value . "\n",
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/rss/1.0/modules/content/encoded', $expected_value), 'Comment body found in RDF output (content:encoded).');
// The comment author can be a registered user or an anonymous user.
if ($comment->getOwnerId() > 0) {
- $author_uri = \Drupal::url('entity.user.canonical', ['user' => $comment->getOwnerId()], array('absolute' => TRUE));
+ $author_uri = \Drupal::url('entity.user.canonical', ['user' => $comment->getOwnerId()], ['absolute' => TRUE]);
// Comment relation to author.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $author_uri,
- );
+ ];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://rdfs.org/sioc/ns#has_creator', $expected_value), 'Comment relation to author found in RDF output (sioc:has_creator).');
}
else {
@@ -321,18 +321,18 @@ class CommentAttributesTest extends CommentTestBase {
// Author name.
$name = empty($account["name"]) ? $this->webUser->getUsername() : $account["name"] . " (not verified)";
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $name,
- );
+ ];
$this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'Comment author name found in RDF output (foaf:name).');
// Comment author homepage (only for anonymous authors).
if ($comment->getOwnerId() == 0) {
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://example.org/',
- );
+ ];
$this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/page', $expected_value), 'Comment author link found in RDF output (foaf:page).');
}
}
@@ -354,7 +354,7 @@ class CommentAttributesTest extends CommentTestBase {
* The saved comment.
*/
function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
- $values = array(
+ $values = [
'entity_id' => $nid,
'entity_type' => 'node',
'field_name' => 'comment',
@@ -363,7 +363,7 @@ class CommentAttributesTest extends CommentTestBase {
'subject' => $this->randomMachineName(),
'comment_body' => $this->randomMachineName(),
'status' => 1,
- );
+ ];
if ($contact) {
$values += $contact;
}
diff --git a/core/modules/rdf/src/Tests/GetNamespacesTest.php b/core/modules/rdf/src/Tests/GetNamespacesTest.php
index 8aeaf7992b8..0b192775062 100644
--- a/core/modules/rdf/src/Tests/GetNamespacesTest.php
+++ b/core/modules/rdf/src/Tests/GetNamespacesTest.php
@@ -17,7 +17,7 @@ class GetNamespacesTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('rdf', 'rdf_test_namespaces');
+ public static $modules = ['rdf', 'rdf_test_namespaces'];
/**
* Tests RDF namespaces.
@@ -26,24 +26,24 @@ class GetNamespacesTest extends WebTestBase {
// Fetches the front page and extracts RDFa 1.1 prefixes.
$this->drupalGet('');
- $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
- ));
+ ]);
$this->assertTrue(!empty($element), 'A prefix declared once is displayed.');
- $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
- ));
+ ]);
$this->assertTrue(!empty($element), 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
- $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
- ));
+ ]);
$this->assertTrue(!empty($element), 'Two prefixes can be assigned the same namespace.');
- $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
+ $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'dc: http://purl.org/dc/terms/',
- ));
+ ]);
$this->assertTrue(!empty($element), 'When a prefix has conflicting namespaces, the first declared one is used.');
}
diff --git a/core/modules/rdf/src/Tests/ImageFieldAttributesTest.php b/core/modules/rdf/src/Tests/ImageFieldAttributesTest.php
index cce663bae56..2944b8fcabc 100644
--- a/core/modules/rdf/src/Tests/ImageFieldAttributesTest.php
+++ b/core/modules/rdf/src/Tests/ImageFieldAttributesTest.php
@@ -19,7 +19,7 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
*
* @var array
*/
- public static $modules = array('rdf', 'image');
+ public static $modules = ['rdf', 'image'];
/**
* The name of the image field used in the test.
@@ -52,11 +52,11 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
// Set the RDF mapping for the new field.
rdf_get_mapping('node', 'article')
- ->setFieldMapping($this->fieldName, array(
- 'properties' => array('og:image'),
+ ->setFieldMapping($this->fieldName, [
+ 'properties' => ['og:image'],
'mapping_type' => 'rel',
- ))
- ->setBundleMapping(array('types' => array()))
+ ])
+ ->setBundleMapping(['types' => []])
->save();
// Get the test image that simpletest provides.
@@ -73,10 +73,10 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
*/
function testNodeTeaser() {
// Set the display options for the teaser.
- $display_options = array(
+ $display_options = [
'type' => 'image',
- 'settings' => array('image_style' => 'medium', 'image_link' => 'content'),
- );
+ 'settings' => ['image_style' => 'medium', 'image_link' => 'content'],
+ ];
$display = entity_get_display('node', 'article', 'teaser');
$display->setComponent($this->fieldName, $display_options)
->save();
@@ -96,17 +96,17 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
$image_uri = ImageStyle::load('medium')->buildUrl($this->file->getFileUri());
// Test relations from node to image.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $image_uri,
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://ogp.me/ns#image', $expected_value), 'Node to file relation found in RDF output (og:image).');
// Test image type.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://xmlns.com/foaf/0.1/Image',
- );
+ ];
$this->assertTrue($graph->hasProperty($image_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Image type found in RDF output (foaf:Image).');
}
diff --git a/core/modules/rdf/tests/rdf_conflicting_namespaces/rdf_conflicting_namespaces.module b/core/modules/rdf/tests/rdf_conflicting_namespaces/rdf_conflicting_namespaces.module
index 2fbdba4a666..ddaf5cbe981 100644
--- a/core/modules/rdf/tests/rdf_conflicting_namespaces/rdf_conflicting_namespaces.module
+++ b/core/modules/rdf/tests/rdf_conflicting_namespaces/rdf_conflicting_namespaces.module
@@ -9,7 +9,7 @@
* Implements hook_rdf_namespaces().
*/
function rdf_conflicting_namespaces_rdf_namespaces() {
- return array(
+ return [
'dc' => 'http://purl.org/conflicting/namespace',
- );
+ ];
}
diff --git a/core/modules/rdf/tests/rdf_test_namespaces/rdf_test_namespaces.module b/core/modules/rdf/tests/rdf_test_namespaces/rdf_test_namespaces.module
index d44c51977e7..327bd5bc841 100644
--- a/core/modules/rdf/tests/rdf_test_namespaces/rdf_test_namespaces.module
+++ b/core/modules/rdf/tests/rdf_test_namespaces/rdf_test_namespaces.module
@@ -9,8 +9,8 @@
* Implements hook_rdf_namespaces().
*/
function rdf_test_namespaces_rdf_namespaces() {
- return array(
+ return [
'foaf' => 'http://xmlns.com/foaf/0.1/',
'foaf1' => 'http://xmlns.com/foaf/0.1/',
- );
+ ];
}
diff --git a/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php b/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php
index 4aaeb7ea0a2..82789d6d058 100644
--- a/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php
+++ b/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php
@@ -17,7 +17,7 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('rdf', 'field_test', 'file', 'image');
+ public static $modules = ['rdf', 'field_test', 'file', 'image'];
/**
* The name of the taxonomy term reference field used in the test.
@@ -36,38 +36,38 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('bypass node access', 'administer taxonomy'));
+ $web_user = $this->drupalCreateUser(['bypass node access', 'administer taxonomy']);
$this->drupalLogin($web_user);
$this->vocabulary = $this->createVocabulary();
// Create the field.
$this->fieldName = 'field_taxonomy_test';
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName, array('type' => 'options_select'))
+ ->setComponent($this->fieldName, ['type' => 'options_select'])
->save();
entity_get_display('node', 'article', 'full')
- ->setComponent($this->fieldName, array('type' => 'entity_reference_label'))
+ ->setComponent($this->fieldName, ['type' => 'entity_reference_label'])
->save();
// Set the RDF mapping for the new field.
rdf_get_mapping('node', 'article')
- ->setFieldMapping($this->fieldName, array(
- 'properties' => array('dc:subject'),
+ ->setFieldMapping($this->fieldName, [
+ 'properties' => ['dc:subject'],
'mapping_type' => 'rel',
- ))
+ ])
->save();
rdf_get_mapping('taxonomy_term', $this->vocabulary->id())
- ->setBundleMapping(array('types' => array('skos:Concept')))
- ->setFieldMapping('name', array('properties' => array('rdfs:label')))
+ ->setBundleMapping(['types' => ['skos:Concept']])
+ ->setFieldMapping('name', ['properties' => ['rdfs:label']])
->save();
}
@@ -80,7 +80,7 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
function testNodeTeaser() {
// Set the teaser display to show this field.
entity_get_display('node', 'article', 'teaser')
- ->setComponent($this->fieldName, array('type' => 'entity_reference_label'))
+ ->setComponent($this->fieldName, ['type' => 'entity_reference_label'])
->save();
// Create a term in each vocabulary.
@@ -90,14 +90,14 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
$taxonomy_term_2_uri = $term2->url('canonical', ['absolute' => TRUE]);
// Create the node.
- $node = $this->drupalCreateNode(array('type' => 'article'));
- $node->set($this->fieldName, array(
- array('target_id' => $term1->id()),
- array('target_id' => $term2->id()),
- ));
+ $node = $this->drupalCreateNode(['type' => 'article']);
+ $node->set($this->fieldName, [
+ ['target_id' => $term1->id()],
+ ['target_id' => $term2->id()],
+ ]);
// Render the node.
- $node_render_array = entity_view_multiple(array($node), 'teaser');
+ $node_render_array = entity_view_multiple([$node], 'teaser');
$html = \Drupal::service('renderer')->renderRoot($node_render_array);
// Parse the teaser.
@@ -108,39 +108,39 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
// Node relations to taxonomy terms.
$node_uri = $node->url('canonical', ['absolute' => TRUE]);
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $taxonomy_term_1_uri,
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/subject', $expected_value), 'Node to term relation found in RDF output (dc:subject).');
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $taxonomy_term_2_uri,
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/subject', $expected_value), 'Node to term relation found in RDF output (dc:subject).');
// Taxonomy terms triples.
// Term 1.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://www.w3.org/2004/02/skos/core#Concept',
- );
+ ];
// @todo Enable with https://www.drupal.org/node/2072791.
//$this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $term1->getName(),
- );
+ ];
//$this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
// Term 2.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://www.w3.org/2004/02/skos/core#Concept',
- );
+ ];
//$this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $term2->getName(),
- );
+ ];
//$this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
}
diff --git a/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php b/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php
index b0be9224ffc..e3e45bad3e6 100644
--- a/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php
+++ b/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php
@@ -17,7 +17,7 @@ class FileFieldAttributesTest extends FileFieldTestBase {
*
* @var array
*/
- public static $modules = array('rdf', 'file');
+ public static $modules = ['rdf', 'file'];
/**
* The name of the file field used in the test.
@@ -50,19 +50,19 @@ class FileFieldAttributesTest extends FileFieldTestBase {
// Set the teaser display to show this field.
entity_get_display('node', 'article', 'teaser')
- ->setComponent($this->fieldName, array('type' => 'file_default'))
+ ->setComponent($this->fieldName, ['type' => 'file_default'])
->save();
// Set the RDF mapping for the new field.
$mapping = rdf_get_mapping('node', 'article');
- $mapping->setFieldMapping($this->fieldName, array('properties' => array('rdfs:seeAlso'), 'mapping_type' => 'rel'))->save();
+ $mapping->setFieldMapping($this->fieldName, ['properties' => ['rdfs:seeAlso'], 'mapping_type' => 'rel'])->save();
$test_file = $this->getTestFile('text');
// Create a new node with the uploaded file.
$nid = $this->uploadNodeFile($test_file, $this->fieldName, $type_name);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$this->node = $node_storage->load($nid);
$this->file = File::load($this->node->{$this->fieldName}->target_id);
}
@@ -75,7 +75,7 @@ class FileFieldAttributesTest extends FileFieldTestBase {
*/
function testNodeTeaser() {
// Render the teaser.
- $node_render_array = entity_view_multiple(array($this->node), 'teaser');
+ $node_render_array = entity_view_multiple([$this->node], 'teaser');
$html = \Drupal::service('renderer')->renderRoot($node_render_array);
// Parses front page where the node is displayed in its teaser form.
@@ -88,10 +88,10 @@ class FileFieldAttributesTest extends FileFieldTestBase {
$file_uri = file_create_url($this->file->getFileUri());
// Node relation to attached file.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $file_uri,
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://www.w3.org/2000/01/rdf-schema#seeAlso', $expected_value), 'Node to file relation found in RDF output (rdfs:seeAlso).');
$this->drupalGet('node');
}
diff --git a/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php b/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
index 544b598f807..c316f3fb076 100644
--- a/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
+++ b/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
@@ -16,7 +16,7 @@ class GetRdfNamespacesTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('rdf', 'rdf_test_namespaces');
+ public static $modules = ['rdf', 'rdf_test_namespaces'];
/**
* Tests getting RDF namespaces.
@@ -31,7 +31,7 @@ class GetRdfNamespacesTest extends BrowserTestBase {
// Enable rdf_conflicting_namespaces to ensure that an exception is thrown
// when RDF namespaces are conflicting.
- \Drupal::service('module_installer')->install(array('rdf_conflicting_namespaces'), TRUE);
+ \Drupal::service('module_installer')->install(['rdf_conflicting_namespaces'], TRUE);
try {
$ns = rdf_get_namespaces();
$this->fail('Expected exception not thrown for conflicting namespace declaration.');
diff --git a/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php b/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php
index e0b8bdf30d7..bf65f1b9005 100644
--- a/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php
+++ b/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php
@@ -16,23 +16,23 @@ class NodeAttributesTest extends NodeTestBase {
*
* @var array
*/
- public static $modules = array('rdf');
+ public static $modules = ['rdf'];
protected function setUp() {
parent::setUp();
rdf_get_mapping('node', 'article')
- ->setBundleMapping(array(
- 'types' => array('sioc:Item', 'foaf:Document'),
- ))
- ->setFieldMapping('title', array(
- 'properties' => array('dc:title'),
- ))
- ->setFieldMapping('created', array(
- 'properties' => array('dc:date', 'dc:created'),
+ ->setBundleMapping([
+ 'types' => ['sioc:Item', 'foaf:Document'],
+ ])
+ ->setFieldMapping('title', [
+ 'properties' => ['dc:title'],
+ ])
+ ->setFieldMapping('created', [
+ 'properties' => ['dc:date', 'dc:created'],
'datatype' => 'xsd:dateTime',
- 'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
- ))
+ 'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
+ ])
->save();
}
@@ -42,10 +42,10 @@ class NodeAttributesTest extends NodeTestBase {
function testNodeAttributes() {
// Create node with single quotation mark title to ensure it does not get
// escaped more than once.
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'type' => 'article',
'title' => $this->randomMachineName(8) . "'",
- ));
+ ]);
$node_uri = $node->url('canonical', ['absolute' => TRUE]);
$base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
@@ -57,37 +57,37 @@ class NodeAttributesTest extends NodeTestBase {
// Inspects RDF graph output.
// Node type.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://rdfs.org/sioc/ns#Item',
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Node type found in RDF output (sioc:Item).');
// Node type.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://xmlns.com/foaf/0.1/Document',
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Node type found in RDF output (foaf:Document).');
// Node title.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $node->getTitle(),
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Node title found in RDF output (dc:title).');
// Node date (date format must be UTC).
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => \Drupal::service('date.formatter')->format($node->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Node date found in RDF output (dc:date).');
// Node date (date format must be UTC).
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => \Drupal::service('date.formatter')->format($node->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
- );
+ ];
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Node date found in RDF output (dc:created).');
}
diff --git a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php
index 7d299051d89..76ae39bc8a0 100644
--- a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php
+++ b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php
@@ -112,18 +112,18 @@ class StandardProfileTest extends BrowserTestBase {
$this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
// Create two test users.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer content types',
'administer comments',
'access comments',
'access content',
- ));
- $this->webUser = $this->drupalCreateUser(array(
+ ]);
+ $this->webUser = $this->drupalCreateUser([
'access comments',
'post comments',
'skip comment approval',
'access content',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
@@ -141,20 +141,20 @@ class StandardProfileTest extends BrowserTestBase {
$this->image->save();
// Create article.
- $article_settings = array(
+ $article_settings = [
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
- 'field_image' => array(
- array(
+ 'field_image' => [
+ [
'target_id' => $this->image->id(),
- ),
- ),
- 'field_tags' => array(
- array(
+ ],
+ ],
+ 'field_tags' => [
+ [
'target_id' => $this->term->id(),
- ),
- ),
- );
+ ],
+ ],
+ ];
$this->article = $this->drupalCreateNode($article_settings);
// Create second article to test teaser list.
$this->drupalCreateNode(['type' => 'article', 'promote' => NodeInterface::PROMOTED]);
@@ -163,24 +163,24 @@ class StandardProfileTest extends BrowserTestBase {
$this->articleComment = $this->saveComment($this->article->id(), $this->webUser->id(), NULL, 0);
// Create page.
- $this->page = $this->drupalCreateNode(array('type' => 'page'));
+ $this->page = $this->drupalCreateNode(['type' => 'page']);
// Set URIs.
// Image.
$image_file = $this->article->get('field_image')->entity;
$this->imageUri = ImageStyle::load('large')->buildUrl($image_file->getFileUri());
// Term.
- $this->termUri = $this->term->url('canonical', array('absolute' => TRUE));
+ $this->termUri = $this->term->url('canonical', ['absolute' => TRUE]);
// Article.
- $this->articleUri = $this->article->url('canonical', array('absolute' => TRUE));
+ $this->articleUri = $this->article->url('canonical', ['absolute' => TRUE]);
// Page.
- $this->pageUri = $this->page->url('canonical', array('absolute' => TRUE));
+ $this->pageUri = $this->page->url('canonical', ['absolute' => TRUE]);
// Author.
- $this->authorUri = $this->adminUser->url('canonical', array('absolute' => TRUE));
+ $this->authorUri = $this->adminUser->url('canonical', ['absolute' => TRUE]);
// Comment.
- $this->articleCommentUri = $this->articleComment->url('canonical', array('absolute' => TRUE));
+ $this->articleCommentUri = $this->articleComment->url('canonical', ['absolute' => TRUE]);
// Commenter.
- $this->commenterUri = $this->webUser->url('canonical', array('absolute' => TRUE));
+ $this->commenterUri = $this->webUser->url('canonical', ['absolute' => TRUE]);
$this->drupalLogout();
}
@@ -211,11 +211,11 @@ class StandardProfileTest extends BrowserTestBase {
$this->assertEqual(2, count($graph->allOfType('http://schema.org/Article')), 'Two articles found on front page.');
// Test interaction count.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => 'UserComments:1',
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/interactionCount', $expected_value), "Teaser comment count was found (schema:interactionCount).");
// Test the properties that are common between pages and articles and are
@@ -228,10 +228,10 @@ class StandardProfileTest extends BrowserTestBase {
// image, move this to testArticleProperties().
$image_file = $this->article->get('field_image')->entity;
$image_uri = ImageStyle::load('medium')->buildUrl($image_file->getFileUri());
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $image_uri,
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/image', $expected_value), "Teaser image was found (schema:image).");
}
@@ -258,10 +258,10 @@ class StandardProfileTest extends BrowserTestBase {
// @todo Once the image points to the original instead of the processed
// image, move this to testArticleProperties().
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $this->imageUri,
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/image', $expected_value), "Article image was found (schema:image).");
}
@@ -303,10 +303,10 @@ class StandardProfileTest extends BrowserTestBase {
$this->assertEqual($graph->type($this->authorUri), 'schema:Person', "User type was found (schema:Person) on user page.");
// User name.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $this->adminUser->label(),
- );
+ ];
$this->assertTrue($graph->hasProperty($this->authorUri, 'http://schema.org/name', $expected_value), "User name was found (schema:name) on user page.");
$this->drupalLogout();
@@ -323,11 +323,11 @@ class StandardProfileTest extends BrowserTestBase {
$this->assertEqual($graph->type($this->termUri), 'schema:Thing', "Term type was found (schema:Thing) on term page.");
// Term name.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $this->term->getName(),
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($this->termUri, 'http://schema.org/name', $expected_value), "Term name was found (schema:name) on term page.");
// @todo Add test for term description once it is a field:
@@ -345,47 +345,47 @@ class StandardProfileTest extends BrowserTestBase {
* The word to use in the test assertion message.
*/
protected function assertRdfaCommonNodeProperties($graph, NodeInterface $node, $message_prefix) {
- $uri = $node->url('canonical', array('absolute' => TRUE));
+ $uri = $node->url('canonical', ['absolute' => TRUE]);
// Title.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $node->get('title')->value,
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/name', $expected_value), "$message_prefix title was found (schema:name).");
// Created date.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => format_date($node->get('created')->value, 'custom', 'c', 'UTC'),
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/dateCreated', $expected_value), "$message_prefix created date was found (schema:dateCreated) in teaser.");
// Body.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $node->get('body')->value,
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/text', $expected_value), "$message_prefix body was found (schema:text) in teaser.");
// Author.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $this->authorUri,
- );
+ ];
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/author', $expected_value), "$message_prefix author was found (schema:author) in teaser.");
// Author type.
$this->assertEqual($graph->type($this->authorUri), 'schema:Person', "$message_prefix author type was found (schema:Person).");
// Author name.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $this->adminUser->label(),
- );
+ ];
$this->assertTrue($graph->hasProperty($this->authorUri, 'http://schema.org/name', $expected_value), "$message_prefix author name was found (schema:name).");
}
@@ -399,10 +399,10 @@ class StandardProfileTest extends BrowserTestBase {
*/
protected function assertRdfaArticleProperties($graph, $message_prefix) {
// Tags.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $this->termUri,
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/about', $expected_value), "$message_prefix tag was found (schema:about).");
// Tag type.
@@ -410,11 +410,11 @@ class StandardProfileTest extends BrowserTestBase {
//$this->assertEqual($graph->type($this->termUri), 'schema:Thing', 'Tag type was found (schema:Thing).');
// Tag name.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $this->term->getName(),
'lang' => 'en',
- );
+ ];
// @todo Enable with https://www.drupal.org/node/2072791.
//$this->assertTrue($graph->hasProperty($this->termUri, 'http://schema.org/name', $expected_value), "$message_prefix name was found (schema:name).");
}
@@ -427,58 +427,58 @@ class StandardProfileTest extends BrowserTestBase {
*/
protected function assertRdfaNodeCommentProperties($graph) {
// Relationship between node and comment.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $this->articleCommentUri,
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/comment', $expected_value), 'Relationship between node and comment found (schema:comment).');
// Comment type.
$this->assertEqual($graph->type($this->articleCommentUri), 'schema:Comment', 'Comment type was found (schema:Comment).');
// Comment title.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $this->articleComment->get('subject')->value,
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/name', $expected_value), 'Article comment title was found (schema:name).');
// Comment created date.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => format_date($this->articleComment->get('created')->value, 'custom', 'c', 'UTC'),
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/dateCreated', $expected_value), 'Article comment created date was found (schema:dateCreated).');
// Comment body.
$text = $this->articleComment->get('comment_body')->value;
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
// There is an extra carriage return in the when parsing comments as
// output by Bartik, so it must be added to the expected value.
'value' => "$text
",
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/text', $expected_value), 'Article comment body was found (schema:text).');
// Comment uid.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => $this->commenterUri,
- );
+ ];
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/author', $expected_value), 'Article comment author was found (schema:author).');
// Comment author type.
$this->assertEqual($graph->type($this->commenterUri), 'schema:Person', 'Comment author type was found (schema:Person).');
// Comment author name.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $this->webUser->getUsername(),
- );
+ ];
$this->assertTrue($graph->hasProperty($this->commenterUri, 'http://schema.org/name', $expected_value), 'Comment author name was found (schema:name).');
}
@@ -499,7 +499,7 @@ class StandardProfileTest extends BrowserTestBase {
* The saved comment.
*/
protected function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
- $values = array(
+ $values = [
'entity_id' => $nid,
'entity_type' => 'node',
'field_name' => 'comment',
@@ -508,7 +508,7 @@ class StandardProfileTest extends BrowserTestBase {
'subject' => $this->randomMachineName(),
'comment_body' => $this->randomMachineName(),
'status' => 1,
- );
+ ];
if ($contact) {
$values += $contact;
}
diff --git a/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php b/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php
index 799b764c048..b21098e6efd 100644
--- a/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php
+++ b/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php
@@ -16,7 +16,7 @@ class TaxonomyAttributesTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('rdf', 'views');
+ public static $modules = ['rdf', 'views'];
/**
* Vocabulary created for testing purposes.
@@ -32,10 +32,10 @@ class TaxonomyAttributesTest extends TaxonomyTestBase {
// RDF mapping - term bundle.
rdf_get_mapping('taxonomy_term', $this->vocabulary->id())
- ->setBundleMapping(array('types' => array('skos:Concept')))
- ->setFieldMapping('name', array(
- 'properties' => array('rdfs:label', 'skos:prefLabel'),
- ))
+ ->setBundleMapping(['types' => ['skos:Concept']])
+ ->setFieldMapping('name', [
+ 'properties' => ['rdfs:label', 'skos:prefLabel'],
+ ])
->save();
}
@@ -54,24 +54,24 @@ class TaxonomyAttributesTest extends TaxonomyTestBase {
// Inspects RDF graph output.
// Term type.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://www.w3.org/2004/02/skos/core#Concept',
- );
+ ];
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Term type found in RDF output (skos:Concept).');
// Term label.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $term->getName(),
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Term label found in RDF output (rdfs:label).');
// Term label.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $term->getName(),
'lang' => 'en',
- );
+ ];
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2004/02/skos/core#prefLabel', $expected_value), 'Term label found in RDF output (skos:prefLabel).');
// @todo Add test for term description once it is a field:
diff --git a/core/modules/rdf/tests/src/Functional/UserAttributesTest.php b/core/modules/rdf/tests/src/Functional/UserAttributesTest.php
index 82c70d9dbaf..7c16a18fef5 100644
--- a/core/modules/rdf/tests/src/Functional/UserAttributesTest.php
+++ b/core/modules/rdf/tests/src/Functional/UserAttributesTest.php
@@ -16,17 +16,17 @@ class UserAttributesTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('rdf', 'node');
+ public static $modules = ['rdf', 'node'];
protected function setUp() {
parent::setUp();
rdf_get_mapping('user', 'user')
- ->setBundleMapping(array(
- 'types' => array('sioc:UserAccount'),
- ))
- ->setFieldMapping('name', array(
- 'properties' => array('foaf:name'),
- ))
+ ->setBundleMapping([
+ 'types' => ['sioc:UserAccount'],
+ ])
+ ->setFieldMapping('name', [
+ 'properties' => ['foaf:name'],
+ ])
->save();
}
@@ -40,17 +40,17 @@ class UserAttributesTest extends BrowserTestBase {
// Creates users that should and should not be truncated
// by template_preprocess_username (20 characters)
// one of these users tests right on the cusp (20).
- $user1 = $this->drupalCreateUser(array('access user profiles'));
+ $user1 = $this->drupalCreateUser(['access user profiles']);
- $authors = array(
- $this->drupalCreateUser(array(), $this->randomMachineName(30)),
- $this->drupalCreateUser(array(), $this->randomMachineName(20)),
- $this->drupalCreateUser(array(), $this->randomMachineName(5))
- );
+ $authors = [
+ $this->drupalCreateUser([], $this->randomMachineName(30)),
+ $this->drupalCreateUser([], $this->randomMachineName(20)),
+ $this->drupalCreateUser([], $this->randomMachineName(5))
+ ];
$this->drupalLogin($user1);
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
/** @var \Drupal\user\UserInterface[] $authors */
foreach ($authors as $author) {
@@ -65,21 +65,21 @@ class UserAttributesTest extends BrowserTestBase {
// Inspects RDF graph output.
// User type.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://rdfs.org/sioc/ns#UserAccount',
- );
+ ];
$this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).');
// User name.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $author->getUsername(),
- );
+ ];
$this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
// User creates a node.
$this->drupalLogin($author);
- $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
+ $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
$this->drupalLogin($user1);
// Parses the node created by the user.
@@ -90,16 +90,16 @@ class UserAttributesTest extends BrowserTestBase {
// Ensures the default bundle mapping for user is used on the Authored By
// information on the node.
- $expected_value = array(
+ $expected_value = [
'type' => 'uri',
'value' => 'http://rdfs.org/sioc/ns#UserAccount',
- );
+ ];
$this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).');
// User name.
- $expected_value = array(
+ $expected_value = [
'type' => 'literal',
'value' => $author->getUsername(),
- );
+ ];
$this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
}
diff --git a/core/modules/rdf/tests/src/Kernel/CrudTest.php b/core/modules/rdf/tests/src/Kernel/CrudTest.php
index 60b4208d00b..1dbb505c193 100644
--- a/core/modules/rdf/tests/src/Kernel/CrudTest.php
+++ b/core/modules/rdf/tests/src/Kernel/CrudTest.php
@@ -16,7 +16,7 @@ class CrudTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('entity_test', 'rdf', 'system');
+ public static $modules = ['entity_test', 'rdf', 'system'];
/**
* @var string
@@ -57,18 +57,18 @@ class CrudTest extends KernelTestBase {
*/
function testBundleMapping() {
// Test that the bundle mapping can be saved.
- $types = array('sioc:Post', 'foaf:Document');
+ $types = ['sioc:Post', 'foaf:Document'];
rdf_get_mapping($this->entityType, $this->bundle)
- ->setBundleMapping(array('types' => $types))
+ ->setBundleMapping(['types' => $types])
->save();
$bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getBundleMapping();
$this->assertEqual($types, $bundle_mapping['types'], 'Bundle mapping saved.');
// Test that the bundle mapping can be edited.
- $types = array('schema:BlogPosting');
+ $types = ['schema:BlogPosting'];
rdf_get_mapping($this->entityType, $this->bundle)
- ->setBundleMapping(array('types' => $types))
+ ->setBundleMapping(['types' => $types])
->save();
$bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getBundleMapping();
@@ -82,11 +82,11 @@ class CrudTest extends KernelTestBase {
$field_name = 'created';
// Test that the field mapping can be saved.
- $mapping = array(
- 'properties' => array('dc:created'),
+ $mapping = [
+ 'properties' => ['dc:created'],
'datatype' => 'xsd:dateTime',
- 'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
- );
+ 'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
+ ];
rdf_get_mapping($this->entityType, $this->bundle)
->setFieldMapping($field_name, $mapping)
->save();
@@ -95,11 +95,11 @@ class CrudTest extends KernelTestBase {
$this->assertEqual($mapping, $field_mapping, 'Field mapping saved.');
// Test that the field mapping can be edited.
- $mapping = array(
- 'properties' => array('dc:date'),
+ $mapping = [
+ 'properties' => ['dc:date'],
'datatype' => 'foo:bar',
- 'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
- );
+ 'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
+ ];
rdf_get_mapping($this->entityType, $this->bundle)
->setFieldMapping($field_name, $mapping)
->save();
diff --git a/core/modules/rdf/tests/src/Kernel/Field/DateTimeFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/DateTimeFieldRdfaTest.php
index a35a9c43ad0..fc78691b964 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/DateTimeFieldRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/DateTimeFieldRdfaTest.php
@@ -26,7 +26,7 @@ class DateTimeFieldRdfaTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('datetime');
+ public static $modules = ['datetime'];
protected function setUp() {
parent::setUp();
@@ -35,12 +35,12 @@ class DateTimeFieldRdfaTest extends FieldRdfaTestBase {
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:dateCreated'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:dateCreated'],
+ ])->save();
// Set up test entity.
- $this->entity = EntityTest::create(array());
+ $this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->value = $this->testValue;
}
@@ -48,7 +48,7 @@ class DateTimeFieldRdfaTest extends FieldRdfaTestBase {
* Tests the default formatter.
*/
public function testDefaultFormatter() {
- $this->assertFormatterRdfa(array('type' => 'datetime_default'), 'http://schema.org/dateCreated', array('value' => $this->testValue . 'Z', 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime'));
+ $this->assertFormatterRdfa(['type' => 'datetime_default'], 'http://schema.org/dateCreated', ['value' => $this->testValue . 'Z', 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime']);
}
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/EmailFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/EmailFieldRdfaTest.php
index c121751655a..85ae888103b 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/EmailFieldRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/EmailFieldRdfaTest.php
@@ -19,7 +19,7 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('text');
+ public static $modules = ['text'];
protected function setUp() {
parent::setUp();
@@ -28,13 +28,13 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:email'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:email'],
+ ])->save();
// Set up test values.
$this->testValue = 'test@example.com';
- $this->entity = EntityTest::create(array());
+ $this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->value = $this->testValue;
}
@@ -43,9 +43,9 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
*/
public function testAllFormatters() {
// Test the plain formatter.
- $this->assertFormatterRdfa(array('type' => 'string'), 'http://schema.org/email', array('value' => $this->testValue));
+ $this->assertFormatterRdfa(['type' => 'string'], 'http://schema.org/email', ['value' => $this->testValue]);
// Test the mailto formatter.
- $this->assertFormatterRdfa(array('type' => 'email_mailto'), 'http://schema.org/email', array('value' => $this->testValue));
+ $this->assertFormatterRdfa(['type' => 'email_mailto'], 'http://schema.org/email', ['value' => $this->testValue]);
}
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/EntityReferenceRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/EntityReferenceRdfaTest.php
index cefa7e0fdb7..9312fbc9295 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/EntityReferenceRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/EntityReferenceRdfaTest.php
@@ -52,7 +52,7 @@ class EntityReferenceRdfaTest extends FieldRdfaTestBase {
$this->installEntitySchema('entity_test_rev');
// Give anonymous users permission to view test entities.
- $this->installConfig(array('user'));
+ $this->installConfig(['user']);
Role::load(RoleInterface::ANONYMOUS_ID)
->grantPermission('view test entity')
->save();
@@ -61,20 +61,20 @@ class EntityReferenceRdfaTest extends FieldRdfaTestBase {
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:knows'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:knows'],
+ ])->save();
// Create the entity to be referenced.
$this->targetEntity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => $this->randomMachineName()));
+ ->create(['name' => $this->randomMachineName()]);
$this->targetEntity->save();
// Create the entity that will have the entity reference field.
$this->entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => $this->randomMachineName()));
+ ->create(['name' => $this->randomMachineName()]);
$this->entity->save();
$this->entity->{$this->fieldName}->entity = $this->targetEntity;
$this->uri = $this->getAbsoluteUri($this->entity);
@@ -87,9 +87,9 @@ class EntityReferenceRdfaTest extends FieldRdfaTestBase {
$entity_uri = $this->getAbsoluteUri($this->targetEntity);
// Tests the label formatter.
- $this->assertFormatterRdfa(array('type' => 'entity_reference_label'), 'http://schema.org/knows', array('value' => $entity_uri, 'type' => 'uri'));
+ $this->assertFormatterRdfa(['type' => 'entity_reference_label'], 'http://schema.org/knows', ['value' => $entity_uri, 'type' => 'uri']);
// Tests the entity formatter.
- $this->assertFormatterRdfa(array('type' => 'entity_reference_entity_view'), 'http://schema.org/knows', array('value' => $entity_uri, 'type' => 'uri'));
+ $this->assertFormatterRdfa(['type' => 'entity_reference_entity_view'], 'http://schema.org/knows', ['value' => $entity_uri, 'type' => 'uri']);
}
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaDatatypeCallbackTest.php b/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaDatatypeCallbackTest.php
index 1e1a809f6be..94f7f24dac1 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaDatatypeCallbackTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaDatatypeCallbackTest.php
@@ -19,23 +19,23 @@ class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('text', 'filter');
+ public static $modules = ['text', 'filter'];
protected function setUp() {
parent::setUp();
$this->createTestField();
- $this->installConfig(array('filter'));
+ $this->installConfig(['filter']);
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:interactionCount'),
- 'datatype_callback' => array(
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:interactionCount'],
+ 'datatype_callback' => [
'callable' => 'Drupal\rdf\Tests\Field\TestDataConverter::convertFoo',
- ),
- ))->save();
+ ],
+ ])->save();
// Set up test values.
$this->testValue = $this->randomMachineName();
@@ -51,7 +51,7 @@ class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
*/
public function testDefaultFormatter() {
// Expected value is the output of the datatype callback, not the raw value.
- $this->assertFormatterRdfa(array('type' => 'text_default'), 'http://schema.org/interactionCount', array('value' => 'foo' . $this->testValue));
+ $this->assertFormatterRdfa(['type' => 'text_default'], 'http://schema.org/interactionCount', ['value' => 'foo' . $this->testValue]);
}
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php b/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php
index 74311850a9b..82ea9efdcc0 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php
@@ -48,7 +48,7 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('rdf');
+ public static $modules = ['rdf'];
/**
* @var string
@@ -83,7 +83,7 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
* - datatype: (optional) The datatype of the value (e.g. xsd:dateTime).
*/
protected function assertFormatterRdfa($formatter, $property, $expected_rdf_value) {
- $expected_rdf_value += array('type' => 'literal');
+ $expected_rdf_value += ['type' => 'literal'];
// The field formatter will be rendered inside the entity. Set the field
// formatter in the entity display options before rendering the entity.
@@ -111,12 +111,12 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
* @param array $field_settings
* (optional) An array of field settings.
*/
- protected function createTestField($field_settings = array()) {
- FieldStorageConfig::create(array(
+ protected function createTestField($field_settings = []) {
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => $this->fieldType,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
@@ -135,7 +135,7 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
* The absolute URI.
*/
protected function getAbsoluteUri($entity) {
- return $entity->url('canonical', array('absolute' => TRUE));
+ return $entity->url('canonical', ['absolute' => TRUE]);
}
/**
@@ -172,14 +172,14 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
* format and return values see the SimpleXML documentation,
* http://php.net/manual/function.simplexml-element-xpath.php.
*/
- protected function xpathContent($content, $xpath, array $arguments = array()) {
+ protected function xpathContent($content, $xpath, array $arguments = []) {
if ($elements = $this->parseContent($content)) {
$xpath = $this->buildXPathQuery($xpath, $arguments);
$result = $elements->xpath($xpath);
// Some combinations of PHP / libxml versions return an empty array
// instead of the documented FALSE. Forcefully convert any falsish values
// to an empty array to allow foreach(...) constructions.
- return $result ? $result : array();
+ return $result ? $result : [];
}
else {
return FALSE;
diff --git a/core/modules/rdf/tests/src/Kernel/Field/LinkFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/LinkFieldRdfaTest.php
index d4e1cf0fbb7..30735e3a8b6 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/LinkFieldRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/LinkFieldRdfaTest.php
@@ -19,7 +19,7 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('link', 'text');
+ public static $modules = ['link', 'text'];
/**
* {@inheritdoc}
@@ -31,9 +31,9 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:link'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:link'],
+ ])->save();
}
@@ -43,14 +43,14 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
public function testAllFormattersExternal() {
// Set up test values.
$this->testValue = 'http://test.me/foo/bar/neque/porro/quisquam/est/qui-dolorem?foo/bar/neque/porro/quisquam/est/qui-dolorem';
- $this->entity = EntityTest::create(array());
+ $this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->uri = $this->testValue;
// Set up the expected result.
- $expected_rdf = array(
+ $expected_rdf = [
'value' => $this->testValue,
'type' => 'uri',
- );
+ ];
$this->runTestAllFormatters($expected_rdf, 'external');
}
@@ -61,15 +61,15 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
public function testAllFormattersInternal() {
// Set up test values.
$this->testValue = 'admin';
- $this->entity = EntityTest::create(array());
+ $this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->uri = 'internal:/admin';
// Set up the expected result.
// AssertFormatterRdfa looks for a full path.
- $expected_rdf = array(
+ $expected_rdf = [
'value' => $this->uri . '/' . $this->testValue,
'type' => 'uri',
- );
+ ];
$this->runTestAllFormatters($expected_rdf, 'internal');
}
@@ -80,14 +80,14 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
public function testAllFormattersFront() {
// Set up test values.
$this->testValue = '/';
- $this->entity = EntityTest::create(array());
+ $this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->uri = 'internal:/';
// Set up the expected result.
- $expected_rdf = array(
+ $expected_rdf = [
'value' => $this->uri . '/',
'type' => 'uri',
- );
+ ];
$this->runTestAllFormatters($expected_rdf, 'front');
}
@@ -98,86 +98,86 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
public function runTestAllFormatters($expected_rdf, $type = NULL) {
// Test the link formatter: trim at 80, no other settings.
- $formatter = array(
+ $formatter = [
'type' => 'link',
- 'settings' => array(
+ 'settings' => [
'trim_length' => 80,
'url_only' => FALSE,
'url_plain' => FALSE,
'rel' => '',
'target' => '',
- ),
- );
+ ],
+ ];
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
// Test the link formatter: trim at 40, nofollow, new window.
- $formatter = array(
+ $formatter = [
'type' => 'link',
- 'settings' => array(
+ 'settings' => [
'trim_length' => 40,
'url_only' => FALSE,
'url_plain' => FALSE,
'rel' => 'nofollow',
'target' => '_blank',
- ),
- );
+ ],
+ ];
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
// Test the link formatter: trim at 40, URL only (not plaintext) nofollow,
// new window.
- $formatter = array(
+ $formatter = [
'type' => 'link',
- 'settings' => array(
+ 'settings' => [
'trim_length' => 40,
'url_only' => TRUE,
'url_plain' => FALSE,
'rel' => 'nofollow',
'target' => '_blank',
- ),
- );
+ ],
+ ];
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
// Test the link_separate formatter: trim at 40, nofollow, new window.
- $formatter = array(
+ $formatter = [
'type' => 'link_separate',
- 'settings' => array(
+ 'settings' => [
'trim_length' => 40,
'rel' => 'nofollow',
'target' => '_blank',
- ),
- );
+ ],
+ ];
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
// Change the expected value here to literal. When formatted as plaintext
// then the RDF is expecting a 'literal' not a 'uri'.
- $expected_rdf = array(
+ $expected_rdf = [
'value' => $this->testValue,
'type' => 'literal',
- );
+ ];
// Test the link formatter: trim at 20, url only (as plaintext.)
- $formatter = array(
+ $formatter = [
'type' => 'link',
- 'settings' => array(
+ 'settings' => [
'trim_length' => 20,
'url_only' => TRUE,
'url_plain' => TRUE,
'rel' => '0',
'target' => '0',
- ),
- );
+ ],
+ ];
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
// Test the link formatter: do not trim, url only (as plaintext.)
- $formatter = array(
+ $formatter = [
'type' => 'link',
- 'settings' => array(
+ 'settings' => [
'trim_length' => 0,
'url_only' => TRUE,
'url_plain' => TRUE,
'rel' => '0',
'target' => '0',
- ),
- );
+ ],
+ ];
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php
index c0652ec8ccd..5c7d3856905 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php
@@ -19,7 +19,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$testValue = 3;
$this->createTestField();
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa(array('type' => 'number_integer'), 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa(['type' => 'number_integer'], 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is not created.
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
@@ -33,24 +33,24 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
\Drupal::service('theme_handler')->install(['classy']);
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'integer';
- $formatter = array(
+ $formatter = [
'type' => 'number_integer',
- 'settings' => array(
+ 'settings' => [
'thousand_separator' => '.',
'prefix_suffix' => TRUE,
- ),
- );
+ ],
+ ];
$testValue = 3333333.33;
- $field_settings = array(
+ $field_settings = [
'prefix' => '#',
'suffix' => ' llamas.',
- );
+ ];
$this->createTestField($field_settings);
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
$this->assertTrue($result);
}
@@ -62,7 +62,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$testValue = 3.33;
$this->createTestField();
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa(array('type' => 'number_unformatted'), 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa(['type' => 'number_unformatted'], 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is not created.
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
@@ -76,25 +76,25 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
\Drupal::service('theme_handler')->install(['classy']);
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'float';
- $formatter = array(
+ $formatter = [
'type' => 'number_decimal',
- 'settings' => array(
+ 'settings' => [
'thousand_separator' => '.',
'decimal_separator' => ',',
'prefix_suffix' => TRUE,
- ),
- );
+ ],
+ ];
$testValue = 3333333.33;
- $field_settings = array(
+ $field_settings = [
'prefix' => '$',
'suffix' => ' more.',
- );
+ ];
$this->createTestField($field_settings);
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
$this->assertTrue($result);
}
@@ -103,16 +103,16 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
*/
public function testFloatFormatterWithScale() {
$this->fieldType = 'float';
- $formatter = array(
+ $formatter = [
'type' => 'number_decimal',
- 'settings' => array(
+ 'settings' => [
'scale' => 5,
- ),
- );
+ ],
+ ];
$testValue = 3.33;
$this->createTestField();
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is not created.
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
@@ -126,19 +126,19 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
\Drupal::service('theme_handler')->install(['classy']);
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'float';
- $formatter = array(
+ $formatter = [
'type' => 'number_decimal',
- 'settings' => array(
+ 'settings' => [
'scale' => 5,
- ),
- );
+ ],
+ ];
$testValue = 3.1234567;
$this->createTestField();
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
$this->assertTrue($result);
}
@@ -150,7 +150,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$testValue = 3.33;
$this->createTestField();
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa(array('type' => 'number_decimal'), 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa(['type' => 'number_decimal'], 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is not created.
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
@@ -164,25 +164,25 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
\Drupal::service('theme_handler')->install(['classy']);
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'decimal';
- $formatter = array(
+ $formatter = [
'type' => 'number_decimal',
- 'settings' => array(
+ 'settings' => [
'thousand_separator' => 't',
'decimal_separator' => '#',
'prefix_suffix' => TRUE,
- ),
- );
+ ],
+ ];
$testValue = 3333333.33;
- $field_settings = array(
+ $field_settings = [
'prefix' => '$',
'suffix' => ' more.',
- );
+ ];
$this->createTestField($field_settings);
$this->createTestEntity($testValue);
- $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
+ $this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
$this->assertTrue($result);
}
@@ -192,12 +192,12 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
protected function createTestEntity($testValue) {
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:baseSalary'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:baseSalary'],
+ ])->save();
// Set up test entity.
- $this->entity = EntityTest::create(array());
+ $this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->value = $testValue;
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php
index a0b28e94d1c..738e40c0372 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php
@@ -37,9 +37,9 @@ class StringFieldRdfaTest extends FieldRdfaTestBase {
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:text'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:text'],
+ ])->save();
// Set up test entity.
$this->entity = EntityTest::create();
@@ -52,7 +52,7 @@ class StringFieldRdfaTest extends FieldRdfaTestBase {
*/
public function testStringFormatters() {
// Tests the string formatter.
- $this->assertFormatterRdfa(array('type' => 'string'), 'http://schema.org/text', array('value' => $this->testValue));
+ $this->assertFormatterRdfa(['type' => 'string'], 'http://schema.org/text', ['value' => $this->testValue]);
}
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php
index 9741256080e..d705b2106d0 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php
@@ -26,7 +26,7 @@ class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('telephone', 'text');
+ public static $modules = ['telephone', 'text'];
protected function setUp() {
parent::setUp();
@@ -35,13 +35,13 @@ class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:telephone'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:telephone'],
+ ])->save();
// Set up test values.
$this->testValue = '555-555-5555';
- $this->entity = EntityTest::create(array());
+ $this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->value = $this->testValue;
}
@@ -50,18 +50,18 @@ class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
*/
public function testAllFormatters() {
// Tests the plain formatter.
- $this->assertFormatterRdfa(array('type' => 'string'), 'http://schema.org/telephone', array('value' => $this->testValue));
+ $this->assertFormatterRdfa(['type' => 'string'], 'http://schema.org/telephone', ['value' => $this->testValue]);
// Tests the telephone link formatter.
- $this->assertFormatterRdfa(array('type' => 'telephone_link'), 'http://schema.org/telephone', array('value' => 'tel:' . $this->testValue, 'type' => 'uri'));
+ $this->assertFormatterRdfa(['type' => 'telephone_link'], 'http://schema.org/telephone', ['value' => 'tel:' . $this->testValue, 'type' => 'uri']);
- $formatter = array(
+ $formatter = [
'type' => 'telephone_link',
- 'settings' => array('title' => 'Contact us'),
- );
- $expected_rdf_value = array(
+ 'settings' => ['title' => 'Contact us'],
+ ];
+ $expected_rdf_value = [
'value' => 'tel:' . $this->testValue,
'type' => 'uri',
- );
+ ];
// Tests the telephone link formatter with custom title.
$this->assertFormatterRdfa($formatter, 'http://schema.org/telephone', $expected_rdf_value);
}
diff --git a/core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php
index cce3499576c..48bc5b8f6bc 100644
--- a/core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php
+++ b/core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php
@@ -33,20 +33,20 @@ class TextFieldRdfaTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('text', 'filter');
+ public static $modules = ['text', 'filter'];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('filter'));
+ $this->installConfig(['filter']);
$this->createTestField();
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping($this->fieldName, array(
- 'properties' => array('schema:text'),
- ))->save();
+ $mapping->setFieldMapping($this->fieldName, [
+ 'properties' => ['schema:text'],
+ ])->save();
// Set up test entity.
$this->entity = EntityTest::create();
@@ -63,11 +63,11 @@ class TextFieldRdfaTest extends FieldRdfaTestBase {
$formatted_value = strip_tags($this->entity->{$this->fieldName}->processed);
// Tests the default formatter.
- $this->assertFormatterRdfa(array('type' => 'text_default'), 'http://schema.org/text', array('value' => $formatted_value));
+ $this->assertFormatterRdfa(['type' => 'text_default'], 'http://schema.org/text', ['value' => $formatted_value]);
// Tests the summary formatter.
- $this->assertFormatterRdfa(array('type' => 'text_summary_or_trimmed'), 'http://schema.org/text', array('value' => $formatted_value));
+ $this->assertFormatterRdfa(['type' => 'text_summary_or_trimmed'], 'http://schema.org/text', ['value' => $formatted_value]);
// Tests the trimmed formatter.
- $this->assertFormatterRdfa(array('type' => 'text_trimmed'), 'http://schema.org/text', array('value' => $formatted_value));
+ $this->assertFormatterRdfa(['type' => 'text_trimmed'], 'http://schema.org/text', ['value' => $formatted_value]);
}
}
diff --git a/core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php b/core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php
index 42a4dc44864..e67e78b788c 100644
--- a/core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php
+++ b/core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php
@@ -16,16 +16,16 @@ class RdfaAttributesTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('rdf');
+ public static $modules = ['rdf'];
/**
* Test attribute creation for mappings which use 'property'.
*/
function testProperty() {
- $properties = array('dc:title');
+ $properties = ['dc:title'];
- $mapping = array('properties' => $properties);
- $expected_attributes = array('property' => $properties);
+ $mapping = ['properties' => $properties];
+ $expected_attributes = ['property' => $properties];
$this->_testAttributes($expected_attributes, $mapping);
}
@@ -34,17 +34,17 @@ class RdfaAttributesTest extends KernelTestBase {
* Test attribute creation for mappings which use 'datatype'.
*/
function testDatatype() {
- $properties = array('foo:bar1');
+ $properties = ['foo:bar1'];
$datatype = 'foo:bar1type';
- $mapping = array(
+ $mapping = [
'datatype' => $datatype,
'properties' => $properties,
- );
- $expected_attributes = array(
+ ];
+ $expected_attributes = [
'datatype' => $datatype,
'property' => $properties,
- );
+ ];
$this->_testAttributes($expected_attributes, $mapping);
}
@@ -53,22 +53,22 @@ class RdfaAttributesTest extends KernelTestBase {
* Test attribute creation for mappings which override human-readable content.
*/
function testDatatypeCallback() {
- $properties = array('dc:created');
+ $properties = ['dc:created'];
$datatype = 'xsd:dateTime';
$date = 1252750327;
$iso_date = date('c', $date);
- $mapping = array(
+ $mapping = [
'datatype' => $datatype,
'properties' => $properties,
- 'datatype_callback' => array('callable' => 'date_iso8601'),
- );
- $expected_attributes = array(
+ 'datatype_callback' => ['callable' => 'date_iso8601'],
+ ];
+ $expected_attributes = [
'datatype' => $datatype,
'property' => $properties,
'content' => $iso_date,
- );
+ ];
$this->_testAttributes($expected_attributes, $mapping, $date);
}
@@ -78,22 +78,22 @@ class RdfaAttributesTest extends KernelTestBase {
* Test attribute creation for mappings which use data converters.
*/
function testDatatypeCallbackWithConverter() {
- $properties = array('schema:interactionCount');
+ $properties = ['schema:interactionCount'];
$data = "23";
$content = "UserComments:23";
- $mapping = array(
+ $mapping = [
'properties' => $properties,
- 'datatype_callback' => array(
+ 'datatype_callback' => [
'callable' => 'Drupal\rdf\SchemaOrgDataConverter::interactionCount',
- 'arguments' => array('interaction_type' => 'UserComments'),
- ),
- );
- $expected_attributes = array(
+ 'arguments' => ['interaction_type' => 'UserComments'],
+ ],
+ ];
+ $expected_attributes = [
'property' => $properties,
'content' => $content,
- );
+ ];
$this->_testAttributes($expected_attributes, $mapping, $data);
}
@@ -102,13 +102,13 @@ class RdfaAttributesTest extends KernelTestBase {
* Test attribute creation for mappings which use 'rel'.
*/
function testRel() {
- $properties = array('sioc:has_creator', 'dc:creator');
+ $properties = ['sioc:has_creator', 'dc:creator'];
- $mapping = array(
+ $mapping = [
'properties' => $properties,
'mapping_type' => 'rel',
- );
- $expected_attributes = array('rel' => $properties);
+ ];
+ $expected_attributes = ['rel' => $properties];
$this->_testAttributes($expected_attributes, $mapping);
}
diff --git a/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php b/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php
index d245a817088..5908ee72621 100644
--- a/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php
+++ b/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php
@@ -72,7 +72,7 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
$target_entity_type->expects($this->any())
->method('getProvider')
->will($this->returnValue('test_module'));
- $values = array('targetEntityType' => $target_entity_type_id);
+ $values = ['targetEntityType' => $target_entity_type_id];
$target_entity_type->expects($this->any())
->method('getBundleEntityType')
->will($this->returnValue(NULL));
@@ -102,11 +102,11 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
->method('getProvider')
->will($this->returnValue('test_module'));
$bundle_id = $this->randomMachineName(10);
- $values = array('targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id);
+ $values = ['targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id];
$target_entity_type->expects($this->any())
->method('getBundleConfigDependency')
- ->will($this->returnValue(array('type' => 'config', 'name' => 'test_module.type.' . $bundle_id)));
+ ->will($this->returnValue(['type' => 'config', 'name' => 'test_module.type.' . $bundle_id]));
$this->entityManager->expects($this->at(0))
->method('getDefinition')
diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module
index 359368d5b0c..4388e896354 100644
--- a/core/modules/responsive_image/responsive_image.module
+++ b/core/modules/responsive_image/responsive_image.module
@@ -40,25 +40,25 @@ function responsive_image_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.responsive_image':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Responsive Image module provides an image formatter that allows browsers to select which image file to display based on media queries or which image file types the browser supports, using the HTML 5 picture and source elements and/or the sizes, srcset and type attributes. For more information, see the <a href=":responsive_image">online documentation for the Responsive Image module</a>.', array( ':responsive_image' => 'https://www.drupal.org/documentation/modules/responsive_image')) . '</p>';
+ $output .= '<p>' . t('The Responsive Image module provides an image formatter that allows browsers to select which image file to display based on media queries or which image file types the browser supports, using the HTML 5 picture and source elements and/or the sizes, srcset and type attributes. For more information, see the <a href=":responsive_image">online documentation for the Responsive Image module</a>.', [ ':responsive_image' => 'https://www.drupal.org/documentation/modules/responsive_image']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Defining responsive image styles') . '</dt>';
- $output .= '<dd>' . t('By creating responsive image styles you define which options the browser has in selecting which image file to display. In most cases this means providing different image sizes based on the viewport size. On the <a href=":responsive_image_style">Responsive image styles</a> page, click <em>Add responsive image style</em> to create a new style. First choose a label, a fallback image style and a breakpoint group and click Save.', array(':responsive_image_style' => \Drupal::url('entity.responsive_image_style.collection'))) . '</dd>';
+ $output .= '<dd>' . t('By creating responsive image styles you define which options the browser has in selecting which image file to display. In most cases this means providing different image sizes based on the viewport size. On the <a href=":responsive_image_style">Responsive image styles</a> page, click <em>Add responsive image style</em> to create a new style. First choose a label, a fallback image style and a breakpoint group and click Save.', [':responsive_image_style' => \Drupal::url('entity.responsive_image_style.collection')]) . '</dd>';
$output .= '<dl>';
$output .= '<dt>' . t('Fallback image style') . '</dt>';
$output .= '<dd>' . t('The fallback image style is typically the smallest size image you expect to appear in this space. Because the responsive images module uses the Picturefill library so that responsive images can work in older browsers, the fallback image should only appear on a site if an error occurs.') . '</dd>';
$output .= '<dt>' . t('Breakpoint groups: viewport sizing vs art direction') . '</dt>';
- $output .= '<dd>' . t('The breakpoint group typically only needs a single breakpoint with an empty media query in order to do <em>viewport sizing.</em> Multiple breakpoints are used for changing the crop or aspect ratio of images at different viewport sizes, which is often referred to as <em>art direction.</em> Once you select a breakpoint group, you can choose which breakpoints to use for the responsive image style. By default, the option <em>do not use this breakpoint</em> is selected for each breakpoint. See the <a href=":breakpoint_help">help page of the Breakpoint module</a> for more information.', array(':breakpoint_help' => \Drupal::url('help.page', array('name' => 'breakpoint')))) . '</dd>';
+ $output .= '<dd>' . t('The breakpoint group typically only needs a single breakpoint with an empty media query in order to do <em>viewport sizing.</em> Multiple breakpoints are used for changing the crop or aspect ratio of images at different viewport sizes, which is often referred to as <em>art direction.</em> Once you select a breakpoint group, you can choose which breakpoints to use for the responsive image style. By default, the option <em>do not use this breakpoint</em> is selected for each breakpoint. See the <a href=":breakpoint_help">help page of the Breakpoint module</a> for more information.', [':breakpoint_help' => \Drupal::url('help.page', ['name' => 'breakpoint'])]) . '</dd>';
$output .= '<dt>' . t('Breakpoint settings: sizes vs image styles') . '</dt>';
$output .= '<dd>' . t('While you have the option to provide only one image style per breakpoint, the sizes option allows you to provide more options to browsers as to which image file it can display, even when using multiple breakpoints for art direction. Breakpoints are defined in the configuration files of the theme.') . '</dd>';
$output .= '<dt>' . t('Sizes field') . '</dt>';
$output .= '<dd>' . t('Once the sizes option is selected, you can let the browser know the size of this image in relation to the site layout, using the <em>Sizes</em> field. For a hero image that always fills the entire screen, you could simply enter 100vw, which means 100% of the viewport width. For an image that fills 90% of the screen for small viewports, but only fills 40% of the screen when the viewport is larger than 40em (typically 640px), you could enter "(min-width: 40em) 40vw, 90vw" in the Sizes field. The last item in the comma-separated list is the smallest viewport size: other items in the comma-separated list should have a media condition paired with an image width. <em>Media conditions</em> are similar to a media query, often a min-width paired with a viewport width using em or px units: e.g. (min-width: 640px) or (min-width: 40em). This is paired with the <em>image width</em> at that viewport size using px, em or vw units. The vw unit is viewport width and is used instead of a percentage because the percentage always refers to the width of the entire viewport.') . '</dd>';
$output .= '<dt>' . t('Image styles for sizes') . '</dt>';
- $output .= '<dd>' . t('Below the Sizes field you can choose multiple image styles so the browser can choose the best image file size to fill the space defined in the Sizes field. Typically you will want to use image styles that resize your image to have options that range from the smallest px width possible for the space the image will appear in to the largest px width possible, with a variety of widths in between. You may want to provide image styles with widths that are 1.5x to 2x the space available in the layout to account for high resolution screens. Image styles can be defined on the <a href=":image_styles">Image styles page</a> that is provided by the <a href=":image_help">Image module</a>.', array(':image_styles' => \Drupal::url('entity.image_style.collection'), ':image_help' => \Drupal::url('help.page', array('name' => 'image')))) . '</dd>';
+ $output .= '<dd>' . t('Below the Sizes field you can choose multiple image styles so the browser can choose the best image file size to fill the space defined in the Sizes field. Typically you will want to use image styles that resize your image to have options that range from the smallest px width possible for the space the image will appear in to the largest px width possible, with a variety of widths in between. You may want to provide image styles with widths that are 1.5x to 2x the space available in the layout to account for high resolution screens. Image styles can be defined on the <a href=":image_styles">Image styles page</a> that is provided by the <a href=":image_help">Image module</a>.', [':image_styles' => \Drupal::url('entity.image_style.collection'), ':image_help' => \Drupal::url('help.page', ['name' => 'image'])]) . '</dd>';
$output .= '</dl></dd>';
$output .= '<dt>' . t('Using responsive image styles in Image fields') . '</dt>';
- $output .= '<dd>' . t('After defining responsive image styles, you can use them in the display settings for your Image fields, so that the site displays responsive images using the HTML5 picture tag. Open the Manage display page for the entity type (content type, taxonomy vocabulary, etc.) that the Image field is attached to. Choose the format <em>Responsive image</em>, click the Edit icon, and select one of the responsive image styles that you have created. For general information on how to manage fields and their display see the <a href=":field_ui">Field UI module help page</a>. For background information about entities and fields see the <a href=":field_help">Field module help page</a>.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':field_help' => \Drupal::url('help.page', array('name' => 'field')))) . '</dd>';
+ $output .= '<dd>' . t('After defining responsive image styles, you can use them in the display settings for your Image fields, so that the site displays responsive images using the HTML5 picture tag. Open the Manage display page for the entity type (content type, taxonomy vocabulary, etc.) that the Image field is attached to. Choose the format <em>Responsive image</em>, click the Edit icon, and select one of the responsive image styles that you have created. For general information on how to manage fields and their display see the <a href=":field_ui">Field UI module help page</a>. For background information about entities and fields see the <a href=":field_help">Field module help page</a>.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':field_help' => \Drupal::url('help.page', ['name' => 'field'])]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -71,25 +71,25 @@ function responsive_image_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function responsive_image_theme() {
- return array(
- 'responsive_image' => array(
- 'variables' => array(
+ return [
+ 'responsive_image' => [
+ 'variables' => [
'uri' => NULL,
- 'attributes' => array(),
- 'responsive_image_style_id' => array(),
+ 'attributes' => [],
+ 'responsive_image_style_id' => [],
'height' => NULL,
'width' => NULL,
- ),
- ),
- 'responsive_image_formatter' => array(
- 'variables' => array(
+ ],
+ ],
+ 'responsive_image_formatter' => [
+ 'variables' => [
'item' => NULL,
'item_attributes' => NULL,
'url' => NULL,
'responsive_image_style_id' => NULL,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -110,18 +110,18 @@ function template_preprocess_responsive_image_formatter(&$variables) {
// provided in the responsive image formatter.
$responsive_image_style = ResponsiveImageStyle::load($variables['responsive_image_style_id']);
if ($responsive_image_style) {
- $variables['responsive_image'] = array(
+ $variables['responsive_image'] = [
'#type' => 'responsive_image',
'#responsive_image_style_id' => $variables['responsive_image_style_id'],
- );
+ ];
}
else {
- $variables['responsive_image'] = array(
+ $variables['responsive_image'] = [
'#theme' => 'image',
- );
+ ];
}
$item = $variables['item'];
- $attributes = array();
+ $attributes = [];
// Do not output an empty 'title' attribute.
if (Unicode::strlen($item->title) != 0) {
$attributes['title'] = $item->title;
@@ -138,7 +138,7 @@ function template_preprocess_responsive_image_formatter(&$variables) {
$variables['responsive_image']['#uri'] = $item->uri;
}
- foreach (array('width', 'height') as $key) {
+ foreach (['width', 'height'] as $key) {
$variables['responsive_image']["#$key"] = $item->$key;
}
$variables['responsive_image']['#attributes'] = $attributes;
@@ -201,10 +201,10 @@ function template_preprocess_responsive_image(&$variables) {
$variables['attributes'][$attribute] = $value;
}
}
- $variables['img_element'] = array(
+ $variables['img_element'] = [
'#theme' => 'image',
'#uri' => _responsive_image_image_style_url($responsive_image_style->getFallbackImageStyle(), $variables['uri']),
- );
+ ];
}
else {
$variables['output_image_tag'] = FALSE;
@@ -212,10 +212,10 @@ function template_preprocess_responsive_image(&$variables) {
// double downloads in browsers that don't support the picture tag (might,
// because when picturefill kicks in, it cancels the download and triggers
// the download for the correct image).
- $variables['img_element'] = array(
+ $variables['img_element'] = [
'#theme' => 'image',
'#uri' => _responsive_image_image_style_url($responsive_image_style->getFallbackImageStyle(), $variables['uri']),
- );
+ ];
}
if (isset($variables['attributes'])) {
@@ -405,9 +405,9 @@ function _responsive_image_build_source_attributes(array $variables, BreakpointI
$height = $variables['height'];
}
$extension = pathinfo($variables['uri'], PATHINFO_EXTENSION);
- $sizes = array();
- $srcset = array();
- $derivative_mime_types = array();
+ $sizes = [];
+ $srcset = [];
+ $derivative_mime_types = [];
foreach ($multipliers as $multiplier => $image_style_mapping) {
switch ($image_style_mapping['image_mapping_type']) {
// Create a <source> tag with the 'sizes' attribute.
@@ -415,7 +415,7 @@ function _responsive_image_build_source_attributes(array $variables, BreakpointI
// Loop through the image styles for this breakpoint and multiplier.
foreach ($image_style_mapping['image_mapping']['sizes_image_styles'] as $image_style_name) {
// Get the dimensions.
- $dimensions = responsive_image_get_image_dimensions($image_style_name, array('width' => $width, 'height' => $height), $variables['uri']);
+ $dimensions = responsive_image_get_image_dimensions($image_style_name, ['width' => $width, 'height' => $height], $variables['uri']);
// Get MIME type.
$derivative_mime_type = responsive_image_get_mime_type($image_style_name, $extension);
$derivative_mime_types[] = $derivative_mime_type;
@@ -451,9 +451,9 @@ function _responsive_image_build_source_attributes(array $variables, BreakpointI
}
// Sort the srcset from small to large image width or multiplier.
ksort($srcset);
- $source_attributes = new Attribute(array(
+ $source_attributes = new Attribute([
'srcset' => implode(', ', array_unique($srcset)),
- ));
+ ]);
$media_query = trim($breakpoint->getMediaQuery());
if (!empty($media_query)) {
$source_attributes->setAttribute('media', $media_query);
@@ -486,10 +486,10 @@ function _responsive_image_build_source_attributes(array $variables, BreakpointI
function responsive_image_get_image_dimensions($image_style_name, array $dimensions, $uri) {
// Determine the dimensions of the styled image.
if ($image_style_name == RESPONSIVE_IMAGE_EMPTY_IMAGE) {
- $dimensions = array(
+ $dimensions = [
'width' => 1,
'height' => 1,
- );
+ ];
}
elseif ($entity = ImageStyle::load($image_style_name)) {
$entity->transformDimensions($dimensions, $uri);
diff --git a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php
index fabfc60db4c..5ad9d9530b6 100644
--- a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php
+++ b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php
@@ -68,7 +68,7 @@ class ResponsiveImageStyle extends ConfigEntityBase implements ResponsiveImageSt
*
* @var array
*/
- protected $image_style_mappings = array();
+ protected $image_style_mappings = [];
/**
* @var array
@@ -103,18 +103,18 @@ class ResponsiveImageStyle extends ConfigEntityBase implements ResponsiveImageSt
// If there is an existing mapping, overwrite it.
foreach ($this->image_style_mappings as &$mapping) {
if ($mapping['breakpoint_id'] === $breakpoint_id && $mapping['multiplier'] === $multiplier) {
- $mapping = array(
+ $mapping = [
'breakpoint_id' => $breakpoint_id,
'multiplier' => $multiplier,
- ) + $image_style_mapping;
+ ] + $image_style_mapping;
$this->keyedImageStyleMappings = NULL;
return $this;
}
}
- $this->image_style_mappings[] = array(
+ $this->image_style_mappings[] = [
'breakpoint_id' => $breakpoint_id,
'multiplier' => $multiplier,
- ) + $image_style_mapping;
+ ] + $image_style_mapping;
$this->keyedImageStyleMappings = NULL;
return $this;
}
@@ -132,7 +132,7 @@ class ResponsiveImageStyle extends ConfigEntityBase implements ResponsiveImageSt
*/
public function getKeyedImageStyleMappings() {
if (!$this->keyedImageStyleMappings) {
- $this->keyedImageStyleMappings = array();
+ $this->keyedImageStyleMappings = [];
foreach ($this->image_style_mappings as $mapping) {
if (!static::isEmptyImageStyleMapping($mapping)) {
$this->keyedImageStyleMappings[$mapping['breakpoint_id']][$mapping['multiplier']] = $mapping;
@@ -188,7 +188,7 @@ class ResponsiveImageStyle extends ConfigEntityBase implements ResponsiveImageSt
* {@inheritdoc}
*/
public function removeImageStyleMappings() {
- $this->image_style_mappings = array();
+ $this->image_style_mappings = [];
$this->keyedImageStyleMappings = NULL;
return $this;
}
diff --git a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php
index 3ec1a199872..6d9b7fa2fa3 100644
--- a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php
+++ b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php
@@ -115,17 +115,17 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'responsive_image_style' => '',
'image_link' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $responsive_image_options = array();
+ $responsive_image_options = [];
$responsive_image_styles = $this->responsiveImageStyleStorage->loadMultiple();
if ($responsive_image_styles && !empty($responsive_image_styles)) {
foreach ($responsive_image_styles as $machine_name => $responsive_image_style) {
@@ -135,29 +135,29 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa
}
}
- $elements['responsive_image_style'] = array(
+ $elements['responsive_image_style'] = [
'#title' => t('Responsive image style'),
'#type' => 'select',
'#default_value' => $this->getSetting('responsive_image_style'),
'#required' => TRUE,
'#options' => $responsive_image_options,
- '#description' => array(
+ '#description' => [
'#markup' => $this->linkGenerator->generate($this->t('Configure Responsive Image Styles'), new Url('entity.responsive_image_style.collection')),
'#access' => $this->currentUser->hasPermission('administer responsive image styles'),
- ),
- );
+ ],
+ ];
- $link_types = array(
+ $link_types = [
'content' => t('Content'),
'file' => t('File'),
- );
- $elements['image_link'] = array(
+ ];
+ $elements['image_link'] = [
'#title' => t('Link image to'),
'#type' => 'select',
'#default_value' => $this->getSetting('image_link'),
'#empty_option' => t('Nothing'),
'#options' => $link_types,
- );
+ ];
return $elements;
}
@@ -166,16 +166,16 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$responsive_image_style = $this->responsiveImageStyleStorage->load($this->getSetting('responsive_image_style'));
if ($responsive_image_style) {
- $summary[] = t('Responsive image style: @responsive_image_style', array('@responsive_image_style' => $responsive_image_style->label()));
+ $summary[] = t('Responsive image style: @responsive_image_style', ['@responsive_image_style' => $responsive_image_style->label()]);
- $link_types = array(
+ $link_types = [
'content' => t('Linked to content'),
'file' => t('Linked to file'),
- );
+ ];
// Display this setting only if image is linked.
if (isset($link_types[$this->getSetting('image_link')])) {
$summary[] = $link_types[$this->getSetting('image_link')];
@@ -192,7 +192,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
$files = $this->getEntitiesToView($items, $langcode);
// Early opt-out if the field is empty.
@@ -214,7 +214,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa
// Collect cache tags to be added for each item in the field.
$responsive_image_style = $this->responsiveImageStyleStorage->load($this->getSetting('responsive_image_style'));
- $image_styles_to_load = array();
+ $image_styles_to_load = [];
$cache_tags = [];
if ($responsive_image_style) {
$cache_tags = Cache::mergeTags($cache_tags, $responsive_image_style->getCacheTags());
@@ -237,16 +237,16 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa
$item_attributes = $item->_attributes;
unset($item->_attributes);
- $elements[$delta] = array(
+ $elements[$delta] = [
'#theme' => 'responsive_image_formatter',
'#item' => $item,
'#item_attributes' => $item_attributes,
'#responsive_image_style_id' => $responsive_image_style ? $responsive_image_style->id() : '',
'#url' => $url,
- '#cache' => array(
+ '#cache' => [
'tags' => $cache_tags,
- ),
- );
+ ],
+ ];
}
return $elements;
}
diff --git a/core/modules/responsive_image/src/ResponsiveImageStyleForm.php b/core/modules/responsive_image/src/ResponsiveImageStyleForm.php
index 3e5b051ade9..8ad0e6a6c87 100644
--- a/core/modules/responsive_image/src/ResponsiveImageStyleForm.php
+++ b/core/modules/responsive_image/src/ResponsiveImageStyleForm.php
@@ -51,32 +51,32 @@ class ResponsiveImageStyleForm extends EntityForm {
*/
public function form(array $form, FormStateInterface $form_state) {
if ($this->operation == 'duplicate') {
- $form['#title'] = $this->t('<em>Duplicate responsive image style</em> @label', array('@label' => $this->entity->label()));
+ $form['#title'] = $this->t('<em>Duplicate responsive image style</em> @label', ['@label' => $this->entity->label()]);
$this->entity = $this->entity->createDuplicate();
}
if ($this->operation == 'edit') {
- $form['#title'] = $this->t('<em>Edit responsive image style</em> @label', array('@label' => $this->entity->label()));
+ $form['#title'] = $this->t('<em>Edit responsive image style</em> @label', ['@label' => $this->entity->label()]);
}
/** @var \Drupal\responsive_image\ResponsiveImageStyleInterface $responsive_image_style */
$responsive_image_style = $this->entity;
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $responsive_image_style->label(),
'#description' => $this->t("Example: 'Hero image' or 'Author image'."),
'#required' => TRUE,
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $responsive_image_style->id(),
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\responsive_image\Entity\ResponsiveImageStyle::load',
- 'source' => array('label'),
- ),
+ 'source' => ['label'],
+ ],
'#disabled' => (bool) $responsive_image_style->id() && $this->operation != 'duplicate',
- );
+ ];
$image_styles = image_style_options(TRUE);
$image_styles[RESPONSIVE_IMAGE_ORIGINAL_IMAGE] = $this->t('- None (original image) -');
@@ -89,25 +89,25 @@ class ResponsiveImageStyleForm extends EntityForm {
$description = $this->t('Select a breakpoint group from the installed themes and modules.');
}
- $form['breakpoint_group'] = array(
+ $form['breakpoint_group'] = [
'#type' => 'select',
'#title' => $this->t('Breakpoint group'),
'#default_value' => $responsive_image_style->getBreakpointGroup() ?: 'responsive_image',
'#options' => $this->breakpointManager->getGroups(),
'#required' => TRUE,
'#description' => $description,
- '#ajax' => array(
+ '#ajax' => [
'callback' => '::breakpointMappingFormAjax',
'wrapper' => 'responsive-image-style-breakpoints-wrapper',
- ),
- );
+ ],
+ ];
- $form['keyed_styles'] = array(
+ $form['keyed_styles'] = [
'#type' => 'container',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'responsive-image-style-breakpoints-wrapper',
- ),
- );
+ ],
+ ];
// By default, breakpoints are ordered from smallest weight to largest:
// the smallest weight is expected to have the smallest breakpoint width,
@@ -119,69 +119,69 @@ class ResponsiveImageStyleForm extends EntityForm {
foreach ($breakpoints as $breakpoint_id => $breakpoint) {
foreach ($breakpoint->getMultipliers() as $multiplier) {
$label = $multiplier . ' ' . $breakpoint->getLabel() . ' [' . $breakpoint->getMediaQuery() . ']';
- $form['keyed_styles'][$breakpoint_id][$multiplier] = array(
+ $form['keyed_styles'][$breakpoint_id][$multiplier] = [
'#type' => 'details',
'#title' => $label,
- );
+ ];
$image_style_mapping = $responsive_image_style->getImageStyleMapping($breakpoint_id, $multiplier);
if (\Drupal::moduleHandler()->moduleExists('help')) {
- $description = $this->t('See the <a href=":responsive_image_help">Responsive Image help page</a> for information on the sizes attribute.', array(':responsive_image_help' => \Drupal::url('help.page', array('name' => 'responsive_image'))));
+ $description = $this->t('See the <a href=":responsive_image_help">Responsive Image help page</a> for information on the sizes attribute.', [':responsive_image_help' => \Drupal::url('help.page', ['name' => 'responsive_image'])]);
}
else {
$description = $this->t('Enable the Help module for more information on the sizes attribute.');
}
- $form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type'] = array(
+ $form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type'] = [
'#title' => $this->t('Type'),
'#type' => 'radios',
- '#options' => array(
+ '#options' => [
'sizes' => $this->t('Select multiple image styles and use the sizes attribute.'),
'image_style' => $this->t('Select a single image style.'),
'_none' => $this->t('Do not use this breakpoint.'),
- ),
+ ],
'#default_value' => isset($image_style_mapping['image_mapping_type']) ? $image_style_mapping['image_mapping_type'] : '_none',
'#description' => $description,
- );
- $form['keyed_styles'][$breakpoint_id][$multiplier]['image_style'] = array(
+ ];
+ $form['keyed_styles'][$breakpoint_id][$multiplier]['image_style'] = [
'#type' => 'select',
'#title' => $this->t('Image style'),
'#options' => $image_styles,
'#default_value' => isset($image_style_mapping['image_mapping']) && is_string($image_style_mapping['image_mapping']) ? $image_style_mapping['image_mapping'] : '',
'#description' => $this->t('Select an image style for this breakpoint.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'image_style'),
- ),
- ),
- );
- $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => ['value' => 'image_style'],
+ ],
+ ],
+ ];
+ $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes'] = [
'#type' => 'textfield',
'#title' => $this->t('Sizes'),
'#default_value' => isset($image_style_mapping['image_mapping']['sizes']) ? $image_style_mapping['image_mapping']['sizes'] : '100vw',
'#description' => $this->t('Enter the value for the sizes attribute, for example: %example_sizes.', ['%example_sizes' => '(min-width:700px) 700px, 100vw']),
- '#states' => array(
- 'visible' => array(
- ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'),
- ),
- 'required' => array(
- ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'),
- ),
- ),
- );
- $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes_image_styles'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => ['value' => 'sizes'],
+ ],
+ 'required' => [
+ ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => ['value' => 'sizes'],
+ ],
+ ],
+ ];
+ $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes_image_styles'] = [
'#title' => $this->t('Image styles'),
'#type' => 'checkboxes',
- '#options' => array_diff_key($image_styles, array('' => '')),
+ '#options' => array_diff_key($image_styles, ['' => '']),
'#description' => $this->t('Select image styles with widths that range from the smallest amount of space this image will take up in the layout to the largest, bearing in mind that high resolution screens will need images 1.5x to 2x larger.'),
- '#default_value' => isset($image_style_mapping['image_mapping']['sizes_image_styles']) ? $image_style_mapping['image_mapping']['sizes_image_styles'] : array(),
- '#states' => array(
- 'visible' => array(
- ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'),
- ),
- 'required' => array(
- ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'),
- ),
- ),
- );
+ '#default_value' => isset($image_style_mapping['image_mapping']['sizes_image_styles']) ? $image_style_mapping['image_mapping']['sizes_image_styles'] : [],
+ '#states' => [
+ 'visible' => [
+ ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => ['value' => 'sizes'],
+ ],
+ 'required' => [
+ ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => ['value' => 'sizes'],
+ ],
+ ],
+ ];
// Expand the details if "do not use this breakpoint" was not selected.
if ($form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type']['#default_value'] != '_none') {
@@ -190,14 +190,14 @@ class ResponsiveImageStyleForm extends EntityForm {
}
}
- $form['fallback_image_style'] = array(
+ $form['fallback_image_style'] = [
'#title' => $this->t('Fallback image style'),
'#type' => 'select',
'#default_value' => $responsive_image_style->getFallbackImageStyle(),
'#options' => $image_styles,
'#required' => TRUE,
'#description' => t('Select the smallest image style you expect to appear in this space. The fallback image style should only appear on the site if an error occurs.'),
- );
+ ];
$form['#tree'] = TRUE;
@@ -252,20 +252,20 @@ class ResponsiveImageStyleForm extends EntityForm {
foreach ($form_state->getValue('keyed_styles') as $breakpoint_id => $multipliers) {
foreach ($multipliers as $multiplier => $image_style_mapping) {
if ($image_style_mapping['image_mapping_type'] === 'sizes') {
- $mapping = array(
+ $mapping = [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => $image_style_mapping['sizes'],
'sizes_image_styles' => array_keys(array_filter($image_style_mapping['sizes_image_styles'])),
- )
- );
+ ]
+ ];
$responsive_image_style->addImageStyleMapping($breakpoint_id, $multiplier, $mapping);
}
elseif ($image_style_mapping['image_mapping_type'] === 'image_style') {
- $mapping = array(
+ $mapping = [
'image_mapping_type' => 'image_style',
'image_mapping' => $image_style_mapping['image_style'],
- );
+ ];
$responsive_image_style->addImageStyleMapping($breakpoint_id, $multiplier, $mapping);
}
}
@@ -273,15 +273,15 @@ class ResponsiveImageStyleForm extends EntityForm {
}
$responsive_image_style->save();
- $this->logger('responsive_image')->notice('Responsive image style @label saved.', array('@label' => $responsive_image_style->label()));
- drupal_set_message($this->t('Responsive image style %label saved.', array('%label' => $responsive_image_style->label())));
+ $this->logger('responsive_image')->notice('Responsive image style @label saved.', ['@label' => $responsive_image_style->label()]);
+ drupal_set_message($this->t('Responsive image style %label saved.', ['%label' => $responsive_image_style->label()]));
// Redirect to edit form after creating a new responsive image style or
// after selecting another breakpoint group.
if (!$responsive_image_style->hasImageStyleMappings()) {
$form_state->setRedirect(
'entity.responsive_image_style.edit_form',
- array('responsive_image_style' => $responsive_image_style->id())
+ ['responsive_image_style' => $responsive_image_style->id()]
);
}
else {
diff --git a/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php b/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php
index 648a171bf30..1b4ded009d7 100644
--- a/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php
+++ b/core/modules/responsive_image/src/ResponsiveImageStyleListBuilder.php
@@ -33,11 +33,11 @@ class ResponsiveImageStyleListBuilder extends ConfigEntityListBuilder {
*/
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
- $operations['duplicate'] = array(
+ $operations['duplicate'] = [
'title' => t('Duplicate'),
'weight' => 15,
'url' => $entity->urlInfo('duplicate-form'),
- );
+ ];
return $operations;
}
diff --git a/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php b/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php
index 8f8b5058e95..0439771b192 100644
--- a/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php
+++ b/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php
@@ -16,7 +16,7 @@ class ResponsiveImageAdminUITest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('responsive_image', 'responsive_image_test_module');
+ public static $modules = ['responsive_image', 'responsive_image_test_module'];
/**
* Drupal\simpletest\WebTestBase\setUp().
@@ -43,12 +43,12 @@ class ResponsiveImageAdminUITest extends WebTestBase {
$this->assertFieldByName('breakpoint_group', 'responsive_image');
// Create a new group.
- $edit = array(
+ $edit = [
'label' => 'Style One',
'id' => 'style_one',
'breakpoint_group' => 'responsive_image_test_module',
'fallback_image_style' => 'thumbnail',
- );
+ ];
$this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
// Check if the new group is created.
@@ -64,14 +64,14 @@ class ResponsiveImageAdminUITest extends WebTestBase {
$this->assertFieldByName('breakpoint_group', 'responsive_image_test_module');
$this->assertFieldByName('fallback_image_style', 'thumbnail');
- $cases = array(
- array('mobile', '1x'),
- array('mobile', '2x'),
- array('narrow', '1x'),
- array('narrow', '2x'),
- array('wide', '1x'),
- array('wide', '2x'),
- );
+ $cases = [
+ ['mobile', '1x'],
+ ['mobile', '2x'],
+ ['narrow', '1x'],
+ ['narrow', '2x'],
+ ['wide', '1x'],
+ ['wide', '2x'],
+ ];
$image_styles = array_merge(
[RESPONSIVE_IMAGE_EMPTY_IMAGE, RESPONSIVE_IMAGE_ORIGINAL_IMAGE],
array_keys(image_style_options(FALSE))
@@ -99,7 +99,7 @@ class ResponsiveImageAdminUITest extends WebTestBase {
}
// Save styles for 1x variant only.
- $edit = array(
+ $edit = [
'label' => 'Style One',
'breakpoint_group' => 'responsive_image_test_module',
'fallback_image_style' => 'thumbnail',
@@ -111,7 +111,7 @@ class ResponsiveImageAdminUITest extends WebTestBase {
'keyed_styles[responsive_image_test_module.narrow][1x][sizes_image_styles][medium]' => 'medium',
'keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]' => 'image_style',
'keyed_styles[responsive_image_test_module.wide][1x][image_style]' => 'large',
- );
+ ];
$this->drupalPostForm('admin/config/media/responsive-image-style/style_one', $edit, t('Save'));
$this->drupalGet('admin/config/media/responsive-image-style/style_one');
@@ -135,7 +135,7 @@ class ResponsiveImageAdminUITest extends WebTestBase {
// Delete the style.
$this->drupalGet('admin/config/media/responsive-image-style/style_one/delete');
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->drupalGet('admin/config/media/responsive-image-style');
$this->assertText('There is no Responsive image style yet.');
}
diff --git a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
index aef5ec016e0..b50d71be651 100644
--- a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
+++ b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
@@ -32,7 +32,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
*
* @var array
*/
- public static $modules = array('field_ui', 'responsive_image', 'responsive_image_test_module');
+ public static $modules = ['field_ui', 'responsive_image', 'responsive_image_test_module'];
/**
* Drupal\simpletest\WebTestBase\setUp().
@@ -41,7 +41,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
parent::setUp();
// Create user.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer responsive images',
'access content',
'access administration pages',
@@ -53,15 +53,15 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
'edit any article content',
'delete any article content',
'administer image styles'
- ));
+ ]);
$this->drupalLogin($this->adminUser);
// Add responsive image style.
- $this->responsiveImgStyle = ResponsiveImageStyle::create(array(
+ $this->responsiveImgStyle = ResponsiveImageStyle::create([
'id' => 'style_one',
'label' => 'Style One',
'breakpoint_group' => 'responsive_image_test_module',
'fallback_image_style' => 'large',
- ));
+ ]);
}
/**
@@ -78,7 +78,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
public function testResponsiveImageFieldFormattersPrivate() {
$this->addTestImageStyleMappings();
// Remove access content permission from anonymous users.
- user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array('access content' => FALSE));
+ user_role_change_permissions(RoleInterface::ANONYMOUS_ID, ['access content' => FALSE]);
$this->doTestResponsiveImageFieldFormatters('private');
}
@@ -99,56 +99,56 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
protected function addTestImageStyleMappings($empty_styles = FALSE) {
if ($empty_styles) {
$this->responsiveImgStyle
- ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => '',
- ))
- ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', array(
+ ])
+ ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width: 700px) 700px, 100vw',
- 'sizes_image_styles' => array(),
- ),
- ))
- ->addImageStyleMapping('responsive_image_test_module.wide', '1x', array(
+ 'sizes_image_styles' => [],
+ ],
+ ])
+ ->addImageStyleMapping('responsive_image_test_module.wide', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => '',
- ))
+ ])
->save();
}
else {
$this->responsiveImgStyle
// Test the output of an empty image.
- ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => RESPONSIVE_IMAGE_EMPTY_IMAGE,
- ))
+ ])
// Test the output with a 1.5x multiplier.
- ->addImageStyleMapping('responsive_image_test_module.mobile', '1.5x', array(
+ ->addImageStyleMapping('responsive_image_test_module.mobile', '1.5x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ))
+ ])
// Test the output of the 'sizes' attribute.
- ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width: 700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large',
'medium',
- ),
- ),
- ))
+ ],
+ ],
+ ])
// Test the normal output of mapping to an image style.
- ->addImageStyleMapping('responsive_image_test_module.wide', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.wide', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ))
+ ])
// Test the output of the original image.
- ->addImageStyleMapping('responsive_image_test_module.wide', '3x', array(
+ ->addImageStyleMapping('responsive_image_test_module.wide', '3x', [
'image_mapping_type' => 'image_style',
'image_mapping' => RESPONSIVE_IMAGE_ORIGINAL_IMAGE,
- ))
+ ])
->save();
}
}
@@ -169,7 +169,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$renderer = $this->container->get('renderer');
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$field_name = Unicode::strtolower($this->randomMachineName());
- $this->createImageField($field_name, 'article', array('uri_scheme' => $scheme));
+ $this->createImageField($field_name, 'article', ['uri_scheme' => $scheme]);
// Create a new node with an image attached. Make sure we use a large image
// so the scale effects of the image styles always have an effect.
$test_image = current($this->drupalGetTestFiles('image', 39325));
@@ -178,26 +178,26 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$alt = $this->randomMachineName();
$nid = $this->uploadNodeImage($test_image, $field_name, 'article', $alt);
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
// Test that the default formatter is being used.
$image_uri = File::load($node->{$field_name}->target_id)->getFileUri();
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => $image_uri,
'#width' => 360,
'#height' => 240,
'#alt' => $alt,
- );
+ ];
$default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
$this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.');
// Test field not being configured. This should not cause a fatal error.
- $display_options = array(
+ $display_options = [
'type' => 'responsive_image_test',
'settings' => ResponsiveImageFormatter::defaultSettings(),
- );
+ ];
$display = $this->container->get('entity.manager')
->getStorage('entity_view_display')
->load('node.article.default');
@@ -215,13 +215,13 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$this->drupalGet('node/' . $nid);
// Test theme function for responsive image, but using the test formatter.
- $display_options = array(
+ $display_options = [
'type' => 'responsive_image_test',
- 'settings' => array(
+ 'settings' => [
'image_link' => 'file',
'responsive_image_style' => 'style_one',
- ),
- );
+ ],
+ ];
$display = entity_get_display('node', 'article', 'default');
$display->setComponent($field_name, $display_options)
->save();
@@ -229,13 +229,13 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$this->drupalGet('node/' . $nid);
// Use the responsive image formatter linked to file formatter.
- $display_options = array(
+ $display_options = [
'type' => 'responsive_image',
- 'settings' => array(
+ 'settings' => [
'image_link' => 'file',
'responsive_image_style' => 'style_one',
- ),
- );
+ ],
+ ];
$display = entity_get_display('node', 'article', 'default');
$display->setComponent($field_name, $display_options)
->save();
@@ -312,11 +312,11 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
// Test the fallback image style.
$image = \Drupal::service('image.factory')->get($image_uri);
- $fallback_image = array(
+ $fallback_image = [
'#theme' => 'image',
'#alt' => $alt,
'#uri' => file_url_transform_relative($large_style->buildUrl($image->getSource())),
- );
+ ];
// The image.html.twig template has a newline after the <img> tag but
// responsive-image.html.twig doesn't have one after the fallback image, so
// we remove it here.
@@ -355,32 +355,32 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
public function testResponsiveImageFieldFormattersEmptyMediaQuery() {
$this->responsiveImgStyle
// Test the output of an empty media query.
- ->addImageStyleMapping('responsive_image_test_module.empty', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.empty', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => RESPONSIVE_IMAGE_EMPTY_IMAGE,
- ))
+ ])
// Test the output with a 1.5x multiplier.
- ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ))
+ ])
->save();
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$field_name = Unicode::strtolower($this->randomMachineName());
- $this->createImageField($field_name, 'article', array('uri_scheme' => 'public'));
+ $this->createImageField($field_name, 'article', ['uri_scheme' => 'public']);
// Create a new node with an image attached.
$test_image = current($this->drupalGetTestFiles('image'));
$nid = $this->uploadNodeImage($test_image, $field_name, 'article', $this->randomMachineName());
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
// Use the responsive image formatter linked to file formatter.
- $display_options = array(
+ $display_options = [
'type' => 'responsive_image',
- 'settings' => array(
+ 'settings' => [
'image_link' => '',
'responsive_image_style' => 'style_one',
- ),
- );
+ ],
+ ];
$display = entity_get_display('node', 'article', 'default');
$display->setComponent($field_name, $display_options)
->save();
@@ -404,31 +404,31 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
public function testResponsiveImageFieldFormattersOneSource() {
$this->responsiveImgStyle
// Test the output of an empty media query.
- ->addImageStyleMapping('responsive_image_test_module.empty', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.empty', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'medium',
- ))
- ->addImageStyleMapping('responsive_image_test_module.empty', '2x', array(
+ ])
+ ->addImageStyleMapping('responsive_image_test_module.empty', '2x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ))
+ ])
->save();
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$field_name = Unicode::strtolower($this->randomMachineName());
- $this->createImageField($field_name, 'article', array('uri_scheme' => 'public'));
+ $this->createImageField($field_name, 'article', ['uri_scheme' => 'public']);
// Create a new node with an image attached.
$test_image = current($this->drupalGetTestFiles('image'));
$nid = $this->uploadNodeImage($test_image, $field_name, 'article', $this->randomMachineName());
- $node_storage->resetCache(array($nid));
+ $node_storage->resetCache([$nid]);
// Use the responsive image formatter linked to file formatter.
- $display_options = array(
+ $display_options = [
'type' => 'responsive_image',
- 'settings' => array(
+ 'settings' => [
'image_link' => '',
'responsive_image_style' => 'style_one',
- ),
- );
+ ],
+ ];
$display = entity_get_display('node', 'article', 'default');
$display->setComponent($field_name, $display_options)
->save();
@@ -452,19 +452,19 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
*/
private function assertResponsiveImageFieldFormattersLink($link_type) {
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_settings = array('alt_field_required' => 0);
- $this->createImageField($field_name, 'article', array('uri_scheme' => 'public'), $field_settings);
+ $field_settings = ['alt_field_required' => 0];
+ $this->createImageField($field_name, 'article', ['uri_scheme' => 'public'], $field_settings);
// Create a new node with an image attached.
$test_image = current($this->drupalGetTestFiles('image'));
// Test the image linked to file formatter.
- $display_options = array(
+ $display_options = [
'type' => 'responsive_image',
- 'settings' => array(
+ 'settings' => [
'image_link' => $link_type,
'responsive_image_style' => 'style_one',
- ),
- );
+ ],
+ ];
entity_get_display('node', 'article', 'default')
->setComponent($field_name, $display_options)
->save();
@@ -475,17 +475,17 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertPattern('/picture/');
$nid = $this->uploadNodeImage($test_image, $field_name, 'article');
- $this->container->get('entity.manager')->getStorage('node')->resetCache(array($nid));
+ $this->container->get('entity.manager')->getStorage('node')->resetCache([$nid]);
$node = Node::load($nid);
// Use the responsive image formatter linked to file formatter.
- $display_options = array(
+ $display_options = [
'type' => 'responsive_image',
- 'settings' => array(
+ 'settings' => [
'image_link' => $link_type,
'responsive_image_style' => 'style_one',
- ),
- );
+ ],
+ ];
entity_get_display('node', 'article', 'default')
->setComponent($field_name, $display_options)
->save();
diff --git a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldUiTest.php b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldUiTest.php
index 3d0e32ee6b1..a091504fcc6 100644
--- a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldUiTest.php
+++ b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldUiTest.php
@@ -21,7 +21,7 @@ class ResponsiveImageFieldUiTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_ui', 'image', 'responsive_image', 'responsive_image_test_module', 'block');
+ public static $modules = ['node', 'field_ui', 'image', 'responsive_image', 'responsive_image_test_module', 'block'];
/**
* {@inheritdoc}
@@ -30,12 +30,12 @@ class ResponsiveImageFieldUiTest extends WebTestBase {
parent::setUp();
$this->drupalPlaceBlock('system_breadcrumb_block');
// Create a test user.
- $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'bypass node access']);
$this->drupalLogin($admin_user);
// Create content type, with underscores.
$type_name = strtolower($this->randomMachineName(8)) . '_test';
- $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
+ $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$this->type = $type->id();
}
@@ -52,39 +52,39 @@ class ResponsiveImageFieldUiTest extends WebTestBase {
$this->drupalGet($manage_display);
// Change the formatter and check that the summary is updated.
- $edit = array(
+ $edit = [
'fields[field_image][type]' => 'responsive_image',
'fields[field_image][region]' => 'content',
'refresh_rows' => 'field_image',
- );
- $this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh')));
+ ];
+ $this->drupalPostAjaxForm(NULL, $edit, ['op' => t('Refresh')]);
$this->assertText("Select a responsive image style.", 'The expected summary is displayed.');
// Submit the form.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText("Select a responsive image style.", 'The expected summary is displayed.');
// Create responsive image styles.
- $responsive_image_style = ResponsiveImageStyle::create(array(
+ $responsive_image_style = ResponsiveImageStyle::create([
'id' => 'style_one',
'label' => 'Style One',
'breakpoint_group' => 'responsive_image_test_module',
'fallback_image_style' => 'thumbnail',
- ));
+ ]);
$responsive_image_style
- ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ))
- ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', array(
+ ])
+ ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'medium'
- ))
+ ])
// Test the normal output of mapping to an image style.
- ->addImageStyleMapping('responsive_image_test_module.wide', '1x', array(
+ ->addImageStyleMapping('responsive_image_test_module.wide', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ))
+ ])
->save();
\Drupal::entityManager()->clearCachedFieldDefinitions();
// Refresh the page.
@@ -93,38 +93,38 @@ class ResponsiveImageFieldUiTest extends WebTestBase {
// Click on the formatter settings button to open the formatter settings
// form.
- $this->drupalPostAjaxForm(NULL, array(), "field_image_settings_edit");
+ $this->drupalPostAjaxForm(NULL, [], "field_image_settings_edit");
// Assert that the correct fields are present.
- $fieldnames = array(
+ $fieldnames = [
'fields[field_image][settings_edit_form][settings][responsive_image_style]',
'fields[field_image][settings_edit_form][settings][image_link]',
- );
+ ];
foreach ($fieldnames as $fieldname) {
$this->assertField($fieldname);
}
- $edit = array(
+ $edit = [
'fields[field_image][settings_edit_form][settings][responsive_image_style]' => 'style_one',
'fields[field_image][settings_edit_form][settings][image_link]' => 'content',
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, "field_image_plugin_settings_update");
// Save the form to save the settings.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText('Responsive image style: Style One');
$this->assertText('Linked to content');
// Click on the formatter settings button to open the formatter settings
// form.
- $this->drupalPostAjaxForm(NULL, array(), "field_image_settings_edit");
- $edit = array(
+ $this->drupalPostAjaxForm(NULL, [], "field_image_settings_edit");
+ $edit = [
'fields[field_image][settings_edit_form][settings][responsive_image_style]' => 'style_one',
'fields[field_image][settings_edit_form][settings][image_link]' => 'file',
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, "field_image_plugin_settings_update");
// Save the form to save the third party settings.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText('Responsive image style: Style One');
$this->assertText('Linked to file');
}
diff --git a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php
index c3f45e9d4ff..bc9663dcf26 100644
--- a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php
+++ b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php
@@ -101,7 +101,7 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
$this->breakpointManager->expects($this->any())
->method('getGroupProviders')
->with('test_group')
- ->willReturn(array('bartik' => 'theme', 'toolbar' => 'module'));
+ ->willReturn(['bartik' => 'theme', 'toolbar' => 'module']);
$dependencies = $entity->calculateDependencies()->getDependencies();
$this->assertEquals(['toolbar'], $dependencies['module']);
@@ -114,49 +114,49 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
* @covers ::hasImageStyleMappings
*/
public function testHasImageStyleMappings() {
- $entity = new ResponsiveImageStyle(array());
+ $entity = new ResponsiveImageStyle([]);
$this->assertFalse($entity->hasImageStyleMappings());
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => '',
- ));
+ ]);
$this->assertFalse($entity->hasImageStyleMappings());
$entity->removeImageStyleMappings();
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(),
- ),
- ));
+ 'sizes_image_styles' => [],
+ ],
+ ]);
$this->assertFalse($entity->hasImageStyleMappings());
$entity->removeImageStyleMappings();
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->assertFalse($entity->hasImageStyleMappings());
$entity->removeImageStyleMappings();
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ));
+ ]);
$this->assertTrue($entity->hasImageStyleMappings());
$entity->removeImageStyleMappings();
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->assertTrue($entity->hasImageStyleMappings());
}
@@ -165,17 +165,17 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
* @covers ::getImageStyleMapping
*/
public function testGetImageStyleMapping() {
- $entity = new ResponsiveImageStyle(array(''));
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity = new ResponsiveImageStyle(['']);
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ));
- $expected = array(
+ ]);
+ $expected = [
'breakpoint_id' => 'test_breakpoint',
'multiplier' => '1x',
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- );
+ ];
$this->assertEquals($expected, $entity->getImageStyleMapping('test_breakpoint', '1x'));
$this->assertNull($entity->getImageStyleMapping('test_unknown_breakpoint', '1x'));
}
@@ -185,90 +185,90 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
* @covers ::getKeyedImageStyleMappings
*/
public function testGetKeyedImageStyleMappings() {
- $entity = new ResponsiveImageStyle(array(''));
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity = new ResponsiveImageStyle(['']);
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ));
- $entity->addImageStyleMapping('test_breakpoint', '2x', array(
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint', '2x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ));
- $entity->addImageStyleMapping('test_breakpoint2', '1x', array(
+ ],
+ ],
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint2', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ));
- $entity->addImageStyleMapping('test_breakpoint2', '2x', array(
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint2', '2x', [
'image_mapping_type' => 'image_style',
'image_mapping' => '_original image_',
- ));
+ ]);
- $expected = array(
- 'test_breakpoint' => array(
- '1x' => array(
+ $expected = [
+ 'test_breakpoint' => [
+ '1x' => [
'breakpoint_id' => 'test_breakpoint',
'multiplier' => '1x',
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ),
- '2x' => array(
+ ],
+ '2x' => [
'breakpoint_id' => 'test_breakpoint',
'multiplier' => '2x',
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ),
- ),
- 'test_breakpoint2' => array(
- '1x' => array(
+ ],
+ ],
+ ],
+ ],
+ 'test_breakpoint2' => [
+ '1x' => [
'breakpoint_id' => 'test_breakpoint2',
'multiplier' => '1x',
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ),
- '2x' => array(
+ ],
+ '2x' => [
'breakpoint_id' => 'test_breakpoint2',
'multiplier' => '2x',
'image_mapping_type' => 'image_style',
'image_mapping' => '_original image_',
- ),
- )
- );
+ ],
+ ]
+ ];
$this->assertEquals($expected, $entity->getKeyedImageStyleMappings());
// Add another mapping to ensure keyed mapping static cache is rebuilt.
- $entity->addImageStyleMapping('test_breakpoint2', '2x', array(
+ $entity->addImageStyleMapping('test_breakpoint2', '2x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'medium',
- ));
- $expected['test_breakpoint2']['2x'] = array(
+ ]);
+ $expected['test_breakpoint2']['2x'] = [
'breakpoint_id' => 'test_breakpoint2',
'multiplier' => '2x',
'image_mapping_type' => 'image_style',
'image_mapping' => 'medium',
- );
+ ];
$this->assertEquals($expected, $entity->getKeyedImageStyleMappings());
// Overwrite a mapping to ensure keyed mapping static cache is rebuilt.
- $entity->addImageStyleMapping('test_breakpoint2', '2x', array(
+ $entity->addImageStyleMapping('test_breakpoint2', '2x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ));
- $expected['test_breakpoint2']['2x'] = array(
+ ]);
+ $expected['test_breakpoint2']['2x'] = [
'breakpoint_id' => 'test_breakpoint2',
'multiplier' => '2x',
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- );
+ ];
$this->assertEquals($expected, $entity->getKeyedImageStyleMappings());
}
@@ -277,50 +277,50 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
* @covers ::getImageStyleMappings
*/
public function testGetImageStyleMappings() {
- $entity = new ResponsiveImageStyle(array(''));
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity = new ResponsiveImageStyle(['']);
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ));
- $entity->addImageStyleMapping('test_breakpoint', '2x', array(
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint', '2x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ));
- $entity->addImageStyleMapping('test_breakpoint2', '1x', array(
+ ],
+ ],
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint2', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ));
+ ]);
- $expected = array(
- array(
+ $expected = [
+ [
'breakpoint_id' => 'test_breakpoint',
'multiplier' => '1x',
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ),
- array(
+ ],
+ [
'breakpoint_id' => 'test_breakpoint',
'multiplier' => '2x',
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ),
- array(
+ ],
+ ],
+ ],
+ [
'breakpoint_id' => 'test_breakpoint2',
'multiplier' => '1x',
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ),
- );
+ ],
+ ];
$this->assertEquals($expected, $entity->getImageStyleMappings());
}
@@ -329,24 +329,24 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
* @covers ::removeImageStyleMappings
*/
public function testRemoveImageStyleMappings() {
- $entity = new ResponsiveImageStyle(array(''));
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity = new ResponsiveImageStyle(['']);
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ));
- $entity->addImageStyleMapping('test_breakpoint', '2x', array(
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint', '2x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ));
- $entity->addImageStyleMapping('test_breakpoint2', '1x', array(
+ ],
+ ],
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint2', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ));
+ ]);
$this->assertTrue($entity->hasImageStyleMappings());
$entity->removeImageStyleMappings();
@@ -360,24 +360,24 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
* @covers ::getBreakpointGroup
*/
public function testSetBreakpointGroup() {
- $entity = new ResponsiveImageStyle(array('breakpoint_group' => 'test_group'));
- $entity->addImageStyleMapping('test_breakpoint', '1x', array(
+ $entity = new ResponsiveImageStyle(['breakpoint_group' => 'test_group']);
+ $entity->addImageStyleMapping('test_breakpoint', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
- ));
- $entity->addImageStyleMapping('test_breakpoint', '2x', array(
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint', '2x', [
'image_mapping_type' => 'sizes',
- 'image_mapping' => array(
+ 'image_mapping' => [
'sizes' => '(min-width:700px) 700px, 100vw',
- 'sizes_image_styles' => array(
+ 'sizes_image_styles' => [
'large' => 'large',
- ),
- ),
- ));
- $entity->addImageStyleMapping('test_breakpoint2', '1x', array(
+ ],
+ ],
+ ]);
+ $entity->addImageStyleMapping('test_breakpoint2', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
- ));
+ ]);
// Ensure that setting to same group does not remove mappings.
$entity->setBreakpointGroup('test_group');
diff --git a/core/modules/rest/rest.api.php b/core/modules/rest/rest.api.php
index 9bf6921c09b..ac601072bea 100644
--- a/core/modules/rest/rest.api.php
+++ b/core/modules/rest/rest.api.php
@@ -47,7 +47,7 @@ function hook_rest_resource_alter(&$definitions) {
* @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
* @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
*/
-function hook_rest_type_uri_alter(&$uri, $context = array()) {
+function hook_rest_type_uri_alter(&$uri, $context = []) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('serialization.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
@@ -74,7 +74,7 @@ function hook_rest_type_uri_alter(&$uri, $context = array()) {
* @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
* @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
*/
-function hook_rest_relation_uri_alter(&$uri, $context = array()) {
+function hook_rest_relation_uri_alter(&$uri, $context = []) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('serialization.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
diff --git a/core/modules/rest/rest.install b/core/modules/rest/rest.install
index e7b539417c5..ca507ceb188 100644
--- a/core/modules/rest/rest.install
+++ b/core/modules/rest/rest.install
@@ -12,15 +12,15 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
* Implements hook_requirements().
*/
function rest_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if (version_compare(PHP_VERSION, '5.6.0', '>=') && version_compare(PHP_VERSION, '7', '<') && ini_get('always_populate_raw_post_data') != -1) {
- $requirements['always_populate_raw_post_data'] = array(
+ $requirements['always_populate_raw_post_data'] = [
'title' => t('always_populate_raw_post_data PHP setting'),
'value' => t('Not set to -1.'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The always_populate_raw_post_data PHP setting should be set to -1 in PHP version 5.6. Please check the <a href="https://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data">PHP manual</a> for information on how to correct this.'),
- );
+ ];
}
return $requirements;
}
diff --git a/core/modules/rest/rest.module b/core/modules/rest/rest.module
index 24e1c5f7024..afdb9ffe3c3 100644
--- a/core/modules/rest/rest.module
+++ b/core/modules/rest/rest.module
@@ -15,13 +15,13 @@ function rest_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.rest':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The RESTful Web Services module provides a framework for exposing REST resources on your site. It provides support for content entities (see the <a href=":field">Field module help page</a> for more information about entities) such as content, users, taxonomy terms, etc.; REST support for content items of the Node module is enabled by default, and support for other types of content entities can be enabled. Other modules may add support for other types of REST resources. For more information, see the <a href=":rest">online documentation for the RESTful Web Services module</a>.', array(':rest' => 'https://www.drupal.org/documentation/modules/rest', ':field' => (\Drupal::moduleHandler()->moduleExists('field')) ? \Drupal::url('help.page', array('name' => 'field')) : '#')) . '</p>';
+ $output .= '<p>' . t('The RESTful Web Services module provides a framework for exposing REST resources on your site. It provides support for content entities (see the <a href=":field">Field module help page</a> for more information about entities) such as content, users, taxonomy terms, etc.; REST support for content items of the Node module is enabled by default, and support for other types of content entities can be enabled. Other modules may add support for other types of REST resources. For more information, see the <a href=":rest">online documentation for the RESTful Web Services module</a>.', [':rest' => 'https://www.drupal.org/documentation/modules/rest', ':field' => (\Drupal::moduleHandler()->moduleExists('field')) ? \Drupal::url('help.page', ['name' => 'field']) : '#']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Installing supporting modules') . '</dt>';
- $output .= '<dd>' . t('In order to use REST on a web site, you need to install modules that provide serialization and authentication services. You can use the Core module <a href=":hal">HAL</a> for serialization and <a href=":basic_auth">HTTP Basic Authentication</a> for authentication, or install a contributed or custom module.', array(':hal' => (\Drupal::moduleHandler()->moduleExists('hal')) ? \Drupal::url('help.page', array('name' => 'hal')) : '#', ':basic_auth' => (\Drupal::moduleHandler()->moduleExists('basic_auth')) ? \Drupal::url('help.page', array('name' => 'basic_auth')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('In order to use REST on a web site, you need to install modules that provide serialization and authentication services. You can use the Core module <a href=":hal">HAL</a> for serialization and <a href=":basic_auth">HTTP Basic Authentication</a> for authentication, or install a contributed or custom module.', [':hal' => (\Drupal::moduleHandler()->moduleExists('hal')) ? \Drupal::url('help.page', ['name' => 'hal']) : '#', ':basic_auth' => (\Drupal::moduleHandler()->moduleExists('basic_auth')) ? \Drupal::url('help.page', ['name' => 'basic_auth']) : '#']) . '</dd>';
$output .= '<dt>' . t('Enabling REST support for an entity type') . '</dt>';
- $output .= '<dd>' . t('REST support for content items of the Node module is enabled by default, and support for other types of content entities can be enabled. To enable support, you can use a <a href=":config">process based on configuration editing</a> or the contributed <a href=":restui">Rest UI module</a>.', array(':config' => 'https://www.drupal.org/documentation/modules/rest', ':restui' => 'https://www.drupal.org/project/restui')) . '</dd>';
+ $output .= '<dd>' . t('REST support for content items of the Node module is enabled by default, and support for other types of content entities can be enabled. To enable support, you can use a <a href=":config">process based on configuration editing</a> or the contributed <a href=":restui">Rest UI module</a>.', [':config' => 'https://www.drupal.org/documentation/modules/rest', ':restui' => 'https://www.drupal.org/project/restui']) . '</dd>';
$output .= '<dd>' . t('You will also need to grant anonymous users permission to perform each of the REST operations you want to be available, and set up authentication properly to authorize web requests.') . '</dd>';
$output .= '</dl>';
return $output;
diff --git a/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php b/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php
index 6a6ddae9672..010fad7363e 100644
--- a/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php
+++ b/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php
@@ -65,17 +65,17 @@ class EntityDeriver implements ContainerDeriverInterface {
if (!isset($this->derivatives)) {
// Add in the default plugin configuration and the resource type.
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
- $this->derivatives[$entity_type_id] = array(
+ $this->derivatives[$entity_type_id] = [
'id' => 'entity:' . $entity_type_id,
'entity_type' => $entity_type_id,
'serialization_class' => $entity_type->getClass(),
'label' => $entity_type->getLabel(),
- );
+ ];
- $default_uris = array(
+ $default_uris = [
'canonical' => "/entity/$entity_type_id/" . '{' . $entity_type_id . '}',
'https://www.drupal.org/link-relations/create' => "/entity/$entity_type_id",
- );
+ ];
foreach ($default_uris as $link_relation => $default_uri) {
// Check if there are link templates defined for the entity type and
diff --git a/core/modules/rest/src/Plugin/ResourceBase.php b/core/modules/rest/src/Plugin/ResourceBase.php
index 93684dbbc41..3062aa29ed8 100644
--- a/core/modules/rest/src/Plugin/ResourceBase.php
+++ b/core/modules/rest/src/Plugin/ResourceBase.php
@@ -31,7 +31,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
*
* @var array
*/
- protected $serializerFormats = array();
+ protected $serializerFormats = [];
/**
* A logger instance.
@@ -81,13 +81,13 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
* resource".
*/
public function permissions() {
- $permissions = array();
+ $permissions = [];
$definition = $this->getPluginDefinition();
foreach ($this->availableMethods() as $method) {
$lowered_method = strtolower($method);
- $permissions["restful $lowered_method $this->pluginId"] = array(
- 'title' => $this->t('Access @method on %label resource', array('@method' => $method, '%label' => $definition['label'])),
- );
+ $permissions["restful $lowered_method $this->pluginId"] = [
+ 'title' => $this->t('Access @method on %label resource', ['@method' => $method, '%label' => $definition['label']]),
+ ];
}
return $permissions;
}
@@ -113,14 +113,14 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
$route->setPath($create_path);
// Restrict the incoming HTTP Content-type header to the known
// serialization formats.
- $route->addRequirements(array('_content_type_format' => implode('|', $this->serializerFormats)));
+ $route->addRequirements(['_content_type_format' => implode('|', $this->serializerFormats)]);
$collection->add("$route_name.$method", $route);
break;
case 'PATCH':
// Restrict the incoming HTTP Content-type header to the known
// serialization formats.
- $route->addRequirements(array('_content_type_format' => implode('|', $this->serializerFormats)));
+ $route->addRequirements(['_content_type_format' => implode('|', $this->serializerFormats)]);
$collection->add("$route_name.$method", $route);
break;
@@ -131,7 +131,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
foreach ($this->serializerFormats as $format_name) {
// Expose one route per available format.
$format_route = clone $route;
- $format_route->addRequirements(array('_format' => $format_name));
+ $format_route->addRequirements(['_format' => $format_name]);
$collection->add("$route_name.$method.$format_name", $format_route);
}
break;
@@ -155,7 +155,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
* The list of allowed HTTP request method strings.
*/
protected function requestMethods() {
- return array(
+ return [
'HEAD',
'GET',
'POST',
@@ -165,7 +165,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
'OPTIONS',
'CONNECT',
'PATCH',
- );
+ ];
}
/**
@@ -173,7 +173,7 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
*/
public function availableMethods() {
$methods = $this->requestMethods();
- $available = array();
+ $available = [];
foreach ($methods as $method) {
// Only expose methods where the HTTP request method exists on the plugin.
if (method_exists($this, strtolower($method))) {
@@ -195,15 +195,15 @@ abstract class ResourceBase extends PluginBase implements ContainerFactoryPlugin
* The created base route.
*/
protected function getBaseRoute($canonical_path, $method) {
- return new Route($canonical_path, array(
+ return new Route($canonical_path, [
'_controller' => 'Drupal\rest\RequestHandler::handle',
- ),
+ ],
$this->getBaseRouteRequirements($method),
- array(),
+ [],
'',
- array(),
+ [],
// The HTTP method is a requirement for this route.
- array($method)
+ [$method]
);
}
diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
index a66d5ab9948..a4162b511cf 100644
--- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
+++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
@@ -184,7 +184,7 @@ class EntityResource extends ResourceBase implements DependentPluginInterface {
$this->validate($entity);
try {
$entity->save();
- $this->logger->notice('Created entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id()));
+ $this->logger->notice('Created entity %type with ID %id.', ['%type' => $entity->getEntityTypeId(), '%id' => $entity->id()]);
// 201 Created responses return the newly created entity in the response
// body. These responses are not cacheable, so we add no cacheability
@@ -296,7 +296,7 @@ class EntityResource extends ResourceBase implements DependentPluginInterface {
$this->validate($original_entity);
try {
$original_entity->save();
- $this->logger->notice('Updated entity %type with ID %id.', array('%type' => $original_entity->getEntityTypeId(), '%id' => $original_entity->id()));
+ $this->logger->notice('Updated entity %type with ID %id.', ['%type' => $original_entity->getEntityTypeId(), '%id' => $original_entity->id()]);
// Return the updated entity in the response body.
return new ModifiedResourceResponse($original_entity, 200);
@@ -324,7 +324,7 @@ class EntityResource extends ResourceBase implements DependentPluginInterface {
}
try {
$entity->delete();
- $this->logger->notice('Deleted entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id()));
+ $this->logger->notice('Deleted entity %type with ID %id.', ['%type' => $entity->getEntityTypeId(), '%id' => $entity->id()]);
// DELETE responses have an empty body.
return new ModifiedResourceResponse(NULL, 204);
@@ -376,7 +376,7 @@ class EntityResource extends ResourceBase implements DependentPluginInterface {
$route = parent::getBaseRoute($canonical_path, $method);
$definition = $this->getPluginDefinition();
- $parameters = $route->getOption('parameters') ?: array();
+ $parameters = $route->getOption('parameters') ?: [];
$parameters[$definition['entity_type']]['type'] = 'entity:' . $definition['entity_type'];
$route->setOption('parameters', $parameters);
diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php
index 65bce232571..cd961954a4d 100644
--- a/core/modules/rest/src/Plugin/views/display/RestExport.php
+++ b/core/modules/rest/src/Plugin/views/display/RestExport.php
@@ -266,21 +266,21 @@ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterfac
// Hide some settings, as they aren't useful for pure data output.
unset($options['show_admin_links'], $options['analyze-theme']);
- $categories['path'] = array(
+ $categories['path'] = [
'title' => $this->t('Path settings'),
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -10,
- ),
- );
+ ],
+ ];
$options['path']['category'] = 'path';
$options['path']['title'] = $this->t('Path');
- $options['auth'] = array(
+ $options['auth'] = [
'category' => 'path',
'title' => $this->t('Authentication'),
'value' => views_ui_truncate($auth, 24),
- );
+ ];
// Remove css/exposed form settings, as they are not used for the data
// display.
@@ -296,13 +296,13 @@ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterfac
parent::buildOptionsForm($form, $form_state);
if ($form_state->get('section') === 'auth') {
$form['#title'] .= $this->t('The supported authentication methods for this view');
- $form['auth'] = array(
+ $form['auth'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Authentication methods'),
'#description' => $this->t('These are the supported authentication providers for this view. When this view is requested, the client will be forced to authenticate with one of the selected providers. Make sure you set the appropriate requirements at the <em>Access</em> section since the Authentication System will fallback to the anonymous user if it fails to authenticate. For example: require Access: Role | Authenticated User.'),
'#options' => $this->getAuthOptions(),
'#default_value' => $this->getOption('auth'),
- );
+ ];
}
}
@@ -406,7 +406,7 @@ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterfac
* {@inheritdoc}
*/
public function render() {
- $build = array();
+ $build = [];
$build['#markup'] = $this->renderer->executeInRenderContext(new RenderContext(), function() {
return $this->view->style_plugin->render();
});
diff --git a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
index 8cebb738d11..175db17b5c0 100644
--- a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
+++ b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
@@ -31,14 +31,14 @@ class DataFieldRow extends RowPluginBase {
*
* @var array
*/
- protected $replacementAliases = array();
+ protected $replacementAliases = [];
/**
* Stores an array of options to determine if the raw field output is used.
*
* @var array
*/
- protected $rawOutputOptions = array();
+ protected $rawOutputOptions = [];
/**
* {@inheritdoc}
@@ -61,7 +61,7 @@ class DataFieldRow extends RowPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['field_options'] = array('default' => array());
+ $options['field_options'] = ['default' => []];
return $options;
}
@@ -72,12 +72,12 @@ class DataFieldRow extends RowPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['field_options'] = array(
+ $form['field_options'] = [
'#type' => 'table',
- '#header' => array($this->t('Field'), $this->t('Alias'), $this->t('Raw output')),
+ '#header' => [$this->t('Field'), $this->t('Alias'), $this->t('Raw output')],
'#empty' => $this->t('You have no fields. Add some to your view.'),
'#tree' => TRUE,
- );
+ ];
$options = $this->options['field_options'];
@@ -87,22 +87,22 @@ class DataFieldRow extends RowPluginBase {
if (!empty($field['exclude'])) {
continue;
}
- $form['field_options'][$id]['field'] = array(
+ $form['field_options'][$id]['field'] = [
'#markup' => $id,
- );
- $form['field_options'][$id]['alias'] = array(
- '#title' => $this->t('Alias for @id', array('@id' => $id)),
+ ];
+ $form['field_options'][$id]['alias'] = [
+ '#title' => $this->t('Alias for @id', ['@id' => $id]),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#default_value' => isset($options[$id]['alias']) ? $options[$id]['alias'] : '',
- '#element_validate' => array(array($this, 'validateAliasName')),
- );
- $form['field_options'][$id]['raw_output'] = array(
- '#title' => $this->t('Raw output for @id', array('@id' => $id)),
+ '#element_validate' => [[$this, 'validateAliasName']],
+ ];
+ $form['field_options'][$id]['raw_output'] = [
+ '#title' => $this->t('Raw output for @id', ['@id' => $id]),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#default_value' => isset($options[$id]['raw_output']) ? $options[$id]['raw_output'] : '',
- );
+ ];
}
}
}
@@ -121,7 +121,7 @@ class DataFieldRow extends RowPluginBase {
*/
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
// Collect an array of aliases to validate.
- $aliases = static::extractFromOptionsArray('alias', $form_state->getValue(array('row_options', 'field_options')));
+ $aliases = static::extractFromOptionsArray('alias', $form_state->getValue(['row_options', 'field_options']));
// If array filter returns empty, no values have been entered. Unique keys
// should only be validated if we have some.
@@ -134,7 +134,7 @@ class DataFieldRow extends RowPluginBase {
* {@inheritdoc}
*/
public function render($row) {
- $output = array();
+ $output = [];
foreach ($this->view->field as $id => $field) {
// If the raw output option has been set, just get the raw value.
diff --git a/core/modules/rest/src/Plugin/views/style/Serializer.php b/core/modules/rest/src/Plugin/views/style/Serializer.php
index 7e9b4331ef0..895b9fe1ae9 100644
--- a/core/modules/rest/src/Plugin/views/style/Serializer.php
+++ b/core/modules/rest/src/Plugin/views/style/Serializer.php
@@ -45,7 +45,7 @@ class Serializer extends StylePluginBase implements CacheableDependencyInterface
*
* @var array
*/
- protected $formats = array();
+ protected $formats = [];
/**
* The serialization format providers, keyed by format.
@@ -85,7 +85,7 @@ class Serializer extends StylePluginBase implements CacheableDependencyInterface
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['formats'] = array('default' => array());
+ $options['formats'] = ['default' => []];
return $options;
}
@@ -96,13 +96,13 @@ class Serializer extends StylePluginBase implements CacheableDependencyInterface
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['formats'] = array(
+ $form['formats'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Accepted request formats'),
'#description' => $this->t('Request formats that will be allowed in responses. If none are selected all formats will be allowed.'),
'#options' => $this->getFormatOptions(),
'#default_value' => $this->options['formats'],
- );
+ ];
}
/**
@@ -111,15 +111,15 @@ class Serializer extends StylePluginBase implements CacheableDependencyInterface
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
parent::submitOptionsForm($form, $form_state);
- $formats = $form_state->getValue(array('style_options', 'formats'));
- $form_state->setValue(array('style_options', 'formats'), array_filter($formats));
+ $formats = $form_state->getValue(['style_options', 'formats']);
+ $form_state->setValue(['style_options', 'formats'], array_filter($formats));
}
/**
* {@inheritdoc}
*/
public function render() {
- $rows = array();
+ $rows = [];
// If the Data Entity row plugin is used, this will be an array of entities
// which will pass through Serializer to one of the registered Normalizers,
// which will transform it to arrays/scalars. If the Data field row plugin
diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php
index 494b438cdbb..9f5137905b2 100644
--- a/core/modules/rest/src/RequestHandler.php
+++ b/core/modules/rest/src/RequestHandler.php
@@ -131,7 +131,7 @@ class RequestHandler implements ContainerAwareInterface, ContainerInjectionInter
// Determine the request parameters that should be passed to the resource
// plugin.
$route_parameters = $route_match->getParameters();
- $parameters = array();
+ $parameters = [];
// Filter out all internal parameters starting with "_".
foreach ($route_parameters as $key => $parameter) {
if ($key{0} !== '_') {
@@ -140,7 +140,7 @@ class RequestHandler implements ContainerAwareInterface, ContainerInjectionInter
}
// Invoke the operation on the resource plugin.
- $response = call_user_func_array(array($resource, $method), array_merge($parameters, array($unserialized, $request)));
+ $response = call_user_func_array([$resource, $method], array_merge($parameters, [$unserialized, $request]));
if ($response instanceof CacheableResponseInterface) {
// Add rest config's cache tags.
diff --git a/core/modules/rest/src/ResourceResponse.php b/core/modules/rest/src/ResourceResponse.php
index d4279a4c97c..eb955c293c2 100644
--- a/core/modules/rest/src/ResourceResponse.php
+++ b/core/modules/rest/src/ResourceResponse.php
@@ -31,7 +31,7 @@ class ResourceResponse extends Response implements CacheableResponseInterface, R
* @param array $headers
* An array of response headers.
*/
- public function __construct($data = NULL, $status = 200, $headers = array()) {
+ public function __construct($data = NULL, $status = 200, $headers = []) {
$this->responseData = $data;
parent::__construct('', $status, $headers);
}
diff --git a/core/modules/rest/src/Routing/ResourceRoutes.php b/core/modules/rest/src/Routing/ResourceRoutes.php
index 8aedfba59eb..3151420201b 100644
--- a/core/modules/rest/src/Routing/ResourceRoutes.php
+++ b/core/modules/rest/src/Routing/ResourceRoutes.php
@@ -95,13 +95,13 @@ class ResourceRoutes extends RouteSubscriberBase {
// Check that authentication providers are defined.
if (empty($rest_resource_config->getAuthenticationProviders($method))) {
- $this->logger->error('At least one authentication provider must be defined for resource @id', array(':id' => $rest_resource_config->id()));
+ $this->logger->error('At least one authentication provider must be defined for resource @id', [':id' => $rest_resource_config->id()]);
continue;
}
// Check that formats are defined.
if (empty($rest_resource_config->getFormats($method))) {
- $this->logger->error('At least one format must be defined for resource @id', array(':id' => $rest_resource_config->id()));
+ $this->logger->error('At least one format must be defined for resource @id', [':id' => $rest_resource_config->id()]);
continue;
}
diff --git a/core/modules/rest/src/Tests/RESTTestBase.php b/core/modules/rest/src/Tests/RESTTestBase.php
index 405493bccb7..40a9fe2f30e 100644
--- a/core/modules/rest/src/Tests/RESTTestBase.php
+++ b/core/modules/rest/src/Tests/RESTTestBase.php
@@ -65,7 +65,7 @@ abstract class RESTTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('rest', 'entity_test');
+ public static $modules = ['rest', 'entity_test'];
/**
* The last response.
@@ -78,11 +78,11 @@ abstract class RESTTestBase extends WebTestBase {
parent::setUp();
$this->defaultFormat = 'hal_json';
$this->defaultMimeType = 'application/hal+json';
- $this->defaultAuth = array('cookie');
+ $this->defaultAuth = ['cookie'];
$this->resourceConfigStorage = $this->container->get('entity_type.manager')->getStorage('rest_resource_config');
// Create a test content type for node testing.
if (in_array('node', static::$modules)) {
- $this->drupalCreateContentType(array('name' => 'resttest', 'type' => 'resttest'));
+ $this->drupalCreateContentType(['name' => 'resttest', 'type' => 'resttest']);
}
$this->cookieFile = $this->publicFilesDirectory . '/cookie.jar';
@@ -142,7 +142,7 @@ abstract class RESTTestBase extends WebTestBase {
if (!isset($mime_type)) {
$mime_type = $this->defaultMimeType;
}
- if (!in_array($method, array('GET', 'HEAD', 'OPTIONS', 'TRACE'))) {
+ if (!in_array($method, ['GET', 'HEAD', 'OPTIONS', 'TRACE'])) {
// GET the CSRF token first for writing requests.
$requested_token = $this->drupalGet('session/token');
}
@@ -303,28 +303,28 @@ abstract class RESTTestBase extends WebTestBase {
protected function entityValues($entity_type_id) {
switch ($entity_type_id) {
case 'entity_test':
- return array(
+ return [
'name' => $this->randomMachineName(),
'user_id' => 1,
- 'field_test_text' => array(0 => array(
+ 'field_test_text' => [0 => [
'value' => $this->randomString(),
'format' => 'plain_text',
- )),
- );
+ ]],
+ ];
case 'config_test':
return [
'id' => $this->randomMachineName(),
'label' => 'Test label',
];
case 'node':
- return array('title' => $this->randomString(), 'type' => 'resttest');
+ return ['title' => $this->randomString(), 'type' => 'resttest'];
case 'node_type':
- return array(
+ return [
'type' => 'article',
'name' => $this->randomMachineName(),
- );
+ ];
case 'user':
- return array('name' => $this->randomMachineName());
+ return ['name' => $this->randomMachineName()];
case 'comment':
return [
@@ -353,7 +353,7 @@ abstract class RESTTestBase extends WebTestBase {
if ($this->isConfigEntity($entity_type_id)) {
return $this->configEntityValues($entity_type_id);
}
- return array();
+ return [];
}
}
@@ -460,22 +460,22 @@ abstract class RESTTestBase extends WebTestBase {
case 'entity_test':
switch ($operation) {
case 'view':
- return array('view test entity');
+ return ['view test entity'];
case 'create':
case 'update':
case 'delete':
- return array('administer entity_test content');
+ return ['administer entity_test content'];
}
case 'node':
switch ($operation) {
case 'view':
- return array('access content');
+ return ['access content'];
case 'create':
- return array('create resttest content');
+ return ['create resttest content'];
case 'update':
- return array('edit any resttest content');
+ return ['edit any resttest content'];
case 'delete':
- return array('delete any resttest content');
+ return ['delete any resttest content'];
}
case 'comment':
@@ -573,7 +573,7 @@ abstract class RESTTestBase extends WebTestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertResponseBody($expected, $message = '', $group = 'REST Response') {
- return $this->assertIdentical($expected, $this->responseBody, $message ? $message : strtr('Response body @expected (expected) is equal to @response (actual).', array('@expected' => var_export($expected, TRUE), '@response' => var_export($this->responseBody, TRUE))), $group);
+ return $this->assertIdentical($expected, $this->responseBody, $message ? $message : strtr('Response body @expected (expected) is equal to @response (actual).', ['@expected' => var_export($expected, TRUE), '@response' => var_export($this->responseBody, TRUE)]), $group);
}
/**
diff --git a/core/modules/rest/src/Tests/ResourceTest.php b/core/modules/rest/src/Tests/ResourceTest.php
index 72bed0f4ee7..baf91e9aef3 100644
--- a/core/modules/rest/src/Tests/ResourceTest.php
+++ b/core/modules/rest/src/Tests/ResourceTest.php
@@ -19,7 +19,7 @@ class ResourceTest extends RESTTestBase {
*
* @var array
*/
- public static $modules = array('hal', 'rest', 'entity_test', 'rest_test');
+ public static $modules = ['hal', 'rest', 'entity_test', 'rest_test'];
/**
* The entity.
diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
index 4c004fcafcd..3c751b651a3 100644
--- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
+++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
@@ -40,14 +40,14 @@ class StyleSerializerTest extends PluginTestBase {
*
* @var array
*/
- public static $modules = array('views_ui', 'entity_test', 'hal', 'rest_test_views', 'node', 'text', 'field', 'language', 'basic_auth');
+ public static $modules = ['views_ui', 'entity_test', 'hal', 'rest_test_views', 'node', 'text', 'field', 'language', 'basic_auth'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_serializer_display_field', 'test_serializer_display_entity', 'test_serializer_display_entity_translated', 'test_serializer_node_display_field', 'test_serializer_node_exposed_filter');
+ public static $testViews = ['test_serializer_display_field', 'test_serializer_display_entity', 'test_serializer_display_entity_translated', 'test_serializer_node_display_field', 'test_serializer_node_exposed_filter'];
/**
* A user with administrative privileges to look at test entity and configure views.
@@ -57,13 +57,13 @@ class StyleSerializerTest extends PluginTestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('rest_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['rest_test_views']);
- $this->adminUser = $this->drupalCreateUser(array('administer views', 'administer entity_test content', 'access user profiles', 'view test entity'));
+ $this->adminUser = $this->drupalCreateUser(['administer views', 'administer entity_test content', 'access user profiles', 'view test entity']);
// Save some entity_test entities.
for ($i = 1; $i <= 10; $i++) {
- EntityTest::create(array('name' => 'test_' . $i, 'user_id' => $this->adminUser->id()))->save();
+ EntityTest::create(['name' => 'test_' . $i, 'user_id' => $this->adminUser->id()])->save();
}
$this->enableViewsTestModule();
@@ -122,9 +122,9 @@ class StyleSerializerTest extends PluginTestBase {
$headers = $this->drupalGetHeaders();
$this->assertEqual($headers['content-type'], 'application/json', 'The header Content-type is correct.');
- $expected = array();
+ $expected = [];
foreach ($view->result as $row) {
- $expected_row = array();
+ $expected_row = [];
foreach ($view->field as $id => $field) {
$expected_row[$id] = $field->render($row);
}
@@ -154,7 +154,7 @@ class StyleSerializerTest extends PluginTestBase {
// Get the serializer service.
$serializer = $this->container->get('serializer');
- $entities = array();
+ $entities = [];
foreach ($view->result as $row) {
$entities[] = $row->_entity;
}
@@ -180,15 +180,15 @@ class StyleSerializerTest extends PluginTestBase {
// Change the default format to xml.
$view->setDisplay('rest_export_1');
- $view->getDisplay()->setOption('style', array(
+ $view->getDisplay()->setOption('style', [
'type' => 'serializer',
- 'options' => array(
+ 'options' => [
'uses_fields' => FALSE,
- 'formats' => array(
+ 'formats' => [
'xml' => 'xml',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$view->save();
$expected = $serializer->serialize($entities, 'xml');
$actual_xml = $this->drupalGet('test/serialize/entity');
@@ -197,16 +197,16 @@ class StyleSerializerTest extends PluginTestBase {
// Allow multiple formats.
$view->setDisplay('rest_export_1');
- $view->getDisplay()->setOption('style', array(
+ $view->getDisplay()->setOption('style', [
'type' => 'serializer',
- 'options' => array(
+ 'options' => [
'uses_fields' => FALSE,
- 'formats' => array(
+ 'formats' => [
'xml' => 'xml',
'json' => 'json',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$view->save();
$expected = $serializer->serialize($entities, 'json');
$actual_json = $this->drupalGetWithFormat('test/serialize/entity', 'json');
@@ -346,8 +346,8 @@ class StyleSerializerTest extends PluginTestBase {
$style_options = 'admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/style_options';
// Select only 'xml' as an accepted format.
- $this->drupalPostForm($style_options, array('style_options[formats][xml]' => 'xml'), t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm($style_options, ['style_options[formats][xml]' => 'xml'], t('Apply'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Should return a 406.
$this->drupalGetWithFormat('test/serialize/field', 'json');
@@ -359,8 +359,8 @@ class StyleSerializerTest extends PluginTestBase {
$this->assertResponse(200, 'A 200 response was returned when XML was requested.');
// Add 'json' as an accepted format, so we have multiple.
- $this->drupalPostForm($style_options, array('style_options[formats][json]' => 'json'), t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm($style_options, ['style_options[formats][json]' => 'json'], t('Apply'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Should return a 200.
// @todo This should be fixed when we have better content negotiation.
@@ -369,7 +369,7 @@ class StyleSerializerTest extends PluginTestBase {
$this->assertResponse(200, 'A 200 response was returned when any format was requested.');
// Should return a 200. Emulates a sample Firefox header.
- $this->drupalGet('test/serialize/field', array(), array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'));
+ $this->drupalGet('test/serialize/field', [], ['Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8']);
$this->assertHeader('content-type', 'application/json');
$this->assertResponse(200, 'A 200 response was returned when a browser accept header was requested.');
@@ -393,7 +393,7 @@ class StyleSerializerTest extends PluginTestBase {
$this->assertResponse(200, 'A 200 response was returned when HTML was requested.');
// Now configure now format, so all of them should be allowed.
- $this->drupalPostForm($style_options, array('style_options[formats][json]' => '0', 'style_options[formats][xml]' => '0'), t('Apply'));
+ $this->drupalPostForm($style_options, ['style_options[formats][json]' => '0', 'style_options[formats][xml]' => '0'], t('Apply'));
// Should return a 200.
$this->drupalGetWithFormat('test/serialize/field', 'json');
@@ -424,16 +424,16 @@ class StyleSerializerTest extends PluginTestBase {
// Test an empty string for an alias, this should not be used. This also
// tests that the form can be submitted with no aliases.
- $this->drupalPostForm($row_options, array('row_options[field_options][name][alias]' => ''), t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm($row_options, ['row_options[field_options][name][alias]' => ''], t('Apply'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView('test_serializer_display_field');
$view->setDisplay('rest_export_1');
$this->executeView($view);
- $expected = array();
+ $expected = [];
foreach ($view->result as $row) {
- $expected_row = array();
+ $expected_row = [];
foreach ($view->field as $id => $field) {
$expected_row[$id] = $field->render($row);
}
@@ -443,32 +443,32 @@ class StyleSerializerTest extends PluginTestBase {
$this->assertIdentical($this->drupalGetJSON('test/serialize/field'), $this->castSafeStrings($expected));
// Test a random aliases for fields, they should be replaced.
- $alias_map = array(
+ $alias_map = [
'name' => $this->randomMachineName(),
// Use # to produce an invalid character for the validation.
'nothing' => '#' . $this->randomMachineName(),
'created' => 'created',
- );
+ ];
- $edit = array('row_options[field_options][name][alias]' => $alias_map['name'], 'row_options[field_options][nothing][alias]' => $alias_map['nothing']);
+ $edit = ['row_options[field_options][name][alias]' => $alias_map['name'], 'row_options[field_options][nothing][alias]' => $alias_map['nothing']];
$this->drupalPostForm($row_options, $edit, t('Apply'));
$this->assertText(t('The machine-readable name must contain only letters, numbers, dashes and underscores.'));
// Change the map alias value to a valid one.
$alias_map['nothing'] = $this->randomMachineName();
- $edit = array('row_options[field_options][name][alias]' => $alias_map['name'], 'row_options[field_options][nothing][alias]' => $alias_map['nothing']);
+ $edit = ['row_options[field_options][name][alias]' => $alias_map['name'], 'row_options[field_options][nothing][alias]' => $alias_map['nothing']];
$this->drupalPostForm($row_options, $edit, t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView('test_serializer_display_field');
$view->setDisplay('rest_export_1');
$this->executeView($view);
- $expected = array();
+ $expected = [];
foreach ($view->result as $row) {
- $expected_row = array();
+ $expected_row = [];
foreach ($view->field as $id => $field) {
$expected_row[$alias_map[$id]] = $field->render($row);
}
@@ -491,12 +491,12 @@ class StyleSerializerTest extends PluginTestBase {
// Test an empty string for an alias, this should not be used. This also
// tests that the form can be submitted with no aliases.
- $values = array(
+ $values = [
'row_options[field_options][created][raw_output]' => '1',
'row_options[field_options][name][raw_output]' => '1',
- );
+ ];
$this->drupalPostForm($row_options, $values, t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView('test_serializer_display_field');
$view->setDisplay('rest_export_1');
@@ -562,7 +562,7 @@ class StyleSerializerTest extends PluginTestBase {
// Get the serializer service.
$serializer = $this->container->get('serializer');
- $entities = array();
+ $entities = [];
foreach ($view->result as $row) {
$entities[] = $row->_entity;
}
@@ -580,15 +580,15 @@ class StyleSerializerTest extends PluginTestBase {
// Change the request format to xml.
$view->setDisplay('rest_export_1');
- $view->getDisplay()->setOption('style', array(
+ $view->getDisplay()->setOption('style', [
'type' => 'serializer',
- 'options' => array(
+ 'options' => [
'uses_fields' => FALSE,
- 'formats' => array(
+ 'formats' => [
'xml' => 'xml',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->executeView($view);
$build = $view->preview();
@@ -602,7 +602,7 @@ class StyleSerializerTest extends PluginTestBase {
public function testSerializerViewsUI() {
$this->drupalLogin($this->adminUser);
// Click the "Update preview button".
- $this->drupalPostForm('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1', $edit = array(), t('Update preview'));
+ $this->drupalPostForm('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1', $edit = [], t('Update preview'));
$this->assertResponse(200);
// Check if we receive the expected result.
$result = $this->xpath('//div[@id="views-live-preview"]/pre');
@@ -613,7 +613,7 @@ class StyleSerializerTest extends PluginTestBase {
* Tests the field row style using fieldapi fields.
*/
public function testFieldapiField() {
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
$node = $this->drupalCreateNode();
$result = $this->drupalGetJSON('test/serialize/node-field');
@@ -749,44 +749,44 @@ class StyleSerializerTest extends PluginTestBase {
* the value provided.
*/
public function testRestViewExposedFilter() {
- $this->drupalCreateContentType(array('type' => 'page'));
- $node0 = $this->drupalCreateNode(array('title' => 'Node 1'));
- $node1 = $this->drupalCreateNode(array('title' => 'Node 11'));
- $node2 = $this->drupalCreateNode(array('title' => 'Node 111'));
+ $this->drupalCreateContentType(['type' => 'page']);
+ $node0 = $this->drupalCreateNode(['title' => 'Node 1']);
+ $node1 = $this->drupalCreateNode(['title' => 'Node 11']);
+ $node2 = $this->drupalCreateNode(['title' => 'Node 111']);
// Test that no filter brings back all three nodes.
$result = $this->drupalGetJSON('test/serialize/node-exposed-filter');
- $expected = array(
- 0 => array(
+ $expected = [
+ 0 => [
'nid' => $node0->id(),
'body' => $node0->body->processed,
- ),
- 1 => array(
+ ],
+ 1 => [
'nid' => $node1->id(),
'body' => $node1->body->processed,
- ),
- 2 => array(
+ ],
+ 2 => [
'nid' => $node2->id(),
'body' => $node2->body->processed,
- ),
- );
+ ],
+ ];
$this->assertEqual($result, $expected, 'Querying a view with no exposed filter returns all nodes.');
// Test that title starts with 'Node 11' query finds 2 of the 3 nodes.
$result = $this->drupalGetJSON('test/serialize/node-exposed-filter', ['query' => ['title' => 'Node 11']]);
- $expected = array(
- 0 => array(
+ $expected = [
+ 0 => [
'nid' => $node1->id(),
'body' => $node1->body->processed,
- ),
- 1 => array(
+ ],
+ 1 => [
'nid' => $node2->id(),
'body' => $node2->body->processed,
- ),
- );
+ ],
+ ];
$cache_contexts = [
'languages:language_content',
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
index 8b3ea643f30..b46eec9eac4 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
@@ -87,10 +87,10 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
$this->addDefaultCommentField('entity_test', 'bar', 'comment');
// Create a "Camelids" test entity that the comment will be assigned to.
- $commented_entity = EntityTest::create(array(
+ $commented_entity = EntityTest::create([
'name' => 'Camelids',
'type' => 'bar',
- ));
+ ]);
$commented_entity->save();
// Create a "Llama" comment.
diff --git a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
index c55ea3bbf34..3ed6545316d 100644
--- a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
+++ b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
@@ -39,18 +39,18 @@ class CollectRoutesTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- $this->view = $this->getMock('\Drupal\views\Entity\View', array('initHandlers'), array(
- array('id' => 'test_view'),
+ $this->view = $this->getMock('\Drupal\views\Entity\View', ['initHandlers'], [
+ ['id' => 'test_view'],
'view',
- ));
+ ]);
- $view_executable = $this->getMock('\Drupal\views\ViewExecutable', array('initHandlers', 'getTitle'), array(), '', FALSE);
+ $view_executable = $this->getMock('\Drupal\views\ViewExecutable', ['initHandlers', 'getTitle'], [], '', FALSE);
$view_executable->expects($this->any())
->method('getTitle')
->willReturn('View title');
$view_executable->storage = $this->view;
- $view_executable->argument = array();
+ $view_executable->argument = [];
$display_manager = $this->getMockBuilder('\Drupal\views\Plugin\ViewsPluginManager')
->disableOriginalConstructor()
@@ -86,21 +86,21 @@ class CollectRoutesTest extends UnitTestCase {
\Drupal::setContainer($container);
- $this->restExport = RestExport::create($container, array(), "test_routes", array());
+ $this->restExport = RestExport::create($container, [], "test_routes", []);
$this->restExport->view = $view_executable;
// Initialize a display.
- $this->restExport->display = array('id' => 'page_1');
+ $this->restExport->display = ['id' => 'page_1'];
// Set the style option.
- $this->restExport->setOption('style', array('type' => 'serializer'));
+ $this->restExport->setOption('style', ['type' => 'serializer']);
// Set the auth option.
$this->restExport->setOption('auth', ['basic_auth']);
$display_manager->expects($this->once())
->method('getDefinition')
- ->will($this->returnValue(array('id' => 'test', 'provider' => 'test')));
+ ->will($this->returnValue(['id' => 'test', 'provider' => 'test']));
$none = $this->getMockBuilder('\Drupal\views\Plugin\views\access\None')
->disableOriginalConstructor()
@@ -110,11 +110,11 @@ class CollectRoutesTest extends UnitTestCase {
->method('createInstance')
->will($this->returnValue($none));
- $style_plugin = $this->getMock('\Drupal\rest\Plugin\views\style\Serializer', array('getFormats', 'init'), array(), '', FALSE);
+ $style_plugin = $this->getMock('\Drupal\rest\Plugin\views\style\Serializer', ['getFormats', 'init'], [], '', FALSE);
$style_plugin->expects($this->once())
->method('getFormats')
- ->will($this->returnValue(array('json')));
+ ->will($this->returnValue(['json']));
$style_plugin->expects($this->once())
->method('init')
diff --git a/core/modules/search/search.install b/core/modules/search/search.install
index f920aa5ae99..d55c4d2f03a 100644
--- a/core/modules/search/search.install
+++ b/core/modules/search/search.install
@@ -9,116 +9,116 @@
* Implements hook_schema().
*/
function search_schema() {
- $schema['search_dataset'] = array(
+ $schema['search_dataset'] = [
'description' => 'Stores items that will be searched.',
- 'fields' => array(
- 'sid' => array(
+ 'fields' => [
+ 'sid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Search item ID, e.g. node ID for nodes.',
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar_ascii',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
- ),
- 'type' => array(
+ ],
+ 'type' => [
'type' => 'varchar_ascii',
'length' => 64,
'not null' => TRUE,
'description' => 'Type of item, e.g. node.',
- ),
- 'data' => array(
+ ],
+ 'data' => [
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'List of space-separated words from the item.',
- ),
- 'reindex' => array(
+ ],
+ 'reindex' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Set to force node reindexing.',
- ),
- ),
- 'primary key' => array('sid', 'langcode', 'type'),
- );
+ ],
+ ],
+ 'primary key' => ['sid', 'langcode', 'type'],
+ ];
- $schema['search_index'] = array(
+ $schema['search_index'] = [
'description' => 'Stores the search index, associating words, items and scores.',
- 'fields' => array(
- 'word' => array(
+ 'fields' => [
+ 'word' => [
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
'description' => 'The {search_total}.word that is associated with the search item.',
- ),
- 'sid' => array(
+ ],
+ 'sid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.',
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar_ascii',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
- ),
- 'type' => array(
+ ],
+ 'type' => [
'type' => 'varchar_ascii',
'length' => 64,
'not null' => TRUE,
'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
- ),
- 'score' => array(
+ ],
+ 'score' => [
'type' => 'float',
'not null' => FALSE,
'description' => 'The numeric score of the word, higher being more important.',
- ),
- ),
- 'indexes' => array(
- 'sid_type' => array('sid', 'langcode', 'type'),
- ),
- 'foreign keys' => array(
- 'search_dataset' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'sid_type' => ['sid', 'langcode', 'type'],
+ ],
+ 'foreign keys' => [
+ 'search_dataset' => [
'table' => 'search_dataset',
- 'columns' => array(
+ 'columns' => [
'sid' => 'sid',
'langcode' => 'langcode',
'type' => 'type',
- ),
- ),
- ),
- 'primary key' => array('word', 'sid', 'langcode', 'type'),
- );
+ ],
+ ],
+ ],
+ 'primary key' => ['word', 'sid', 'langcode', 'type'],
+ ];
- $schema['search_total'] = array(
+ $schema['search_total'] = [
'description' => 'Stores search totals for words.',
- 'fields' => array(
- 'word' => array(
+ 'fields' => [
+ 'word' => [
'description' => 'Primary Key: Unique word in the search index.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
- ),
- 'count' => array(
+ ],
+ 'count' => [
'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.",
'type' => 'float',
'not null' => FALSE,
- ),
- ),
- 'primary key' => array('word'),
- );
+ ],
+ ],
+ 'primary key' => ['word'],
+ ];
return $schema;
}
@@ -129,7 +129,7 @@ function search_schema() {
* For the Status Report, return information about search index status.
*/
function search_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if ($phase == 'runtime') {
$remaining = 0;
@@ -145,11 +145,11 @@ function search_requirements($phase) {
// Use floor() to calculate the percentage, so if it is not quite 100%, it
// will show as 99%, to indicate "almost done".
$percent = ($total > 0 ? floor(100 * $done / $total) : 100);
- $requirements['search_status'] = array(
+ $requirements['search_status'] = [
'title' => t('Search index progress'),
- 'value' => t('@percent% (@remaining remaining)', array('@percent' => $percent, '@remaining' => $remaining)),
+ 'value' => t('@percent% (@remaining remaining)', ['@percent' => $percent, '@remaining' => $remaining]),
'severity' => REQUIREMENT_INFO,
- );
+ ];
}
return $requirements;
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index 215a6c8d108..ae99a8731ef 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -75,20 +75,20 @@ function search_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.search':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Search module provides the ability to set up search pages based on plugins provided by other modules. In Drupal core, there are two page-type plugins: the Content page type provides keyword searching for content managed by the Node module, and the Users page type provides keyword searching for registered users. Contributed modules may provide other page-type plugins. For more information, see the <a href=":search-module">online documentation for the Search module</a>.', array(':search-module' => 'https://www.drupal.org/documentation/modules/search')) . '</p>';
+ $output .= '<p>' . t('The Search module provides the ability to set up search pages based on plugins provided by other modules. In Drupal core, there are two page-type plugins: the Content page type provides keyword searching for content managed by the Node module, and the Users page type provides keyword searching for registered users. Contributed modules may provide other page-type plugins. For more information, see the <a href=":search-module">online documentation for the Search module</a>.', [':search-module' => 'https://www.drupal.org/documentation/modules/search']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Configuring search pages') . '</dt>';
- $output .= '<dd>' . t('To configure search pages, visit the <a href=":search-settings">Search pages page</a>. In the Search pages section, you can add a new search page, edit the configuration of existing search pages, enable and disable search pages, and choose the default search page. Each enabled search page has a URL path starting with <em>search</em>, and each will appear as a tab or local task link on the <a href=":search-url">search page</a>; you can configure the text that is shown in the tab. In addition, some search page plugins have additional settings that you can configure for each search page.', array(':search-settings' => \Drupal::url('entity.search_page.collection'), ':search-url' => \Drupal::url('search.view'))) . '</dd>';
+ $output .= '<dd>' . t('To configure search pages, visit the <a href=":search-settings">Search pages page</a>. In the Search pages section, you can add a new search page, edit the configuration of existing search pages, enable and disable search pages, and choose the default search page. Each enabled search page has a URL path starting with <em>search</em>, and each will appear as a tab or local task link on the <a href=":search-url">search page</a>; you can configure the text that is shown in the tab. In addition, some search page plugins have additional settings that you can configure for each search page.', [':search-settings' => \Drupal::url('entity.search_page.collection'), ':search-url' => \Drupal::url('search.view')]) . '</dd>';
$output .= '<dt>' . t('Managing the search index') . '</dt>';
- $output .= '<dd>' . t('Some search page plugins, such as the core Content search page, index searchable text using the Drupal core search index, and will not work unless content is indexed. Indexing is done during <em>cron</em> runs, so it requires a <a href=":cron">cron maintenance task</a> to be set up. There are also several settings affecting indexing that can be configured on the <a href=":search-settings">Search pages page</a>: the number of items to index per cron run, the minimum word length to index, and how to handle Chinese, Japanese, and Korean characters.', array(':cron' => \Drupal::url('system.cron_settings'), ':search-settings' => \Drupal::url('entity.search_page.collection'))) . '</dd>';
- $output .= '<dd>' . t('Modules providing search page plugins generally ensure that content-related actions on your site (creating, editing, or deleting content and comments) automatically cause affected content items to be marked for indexing or reindexing at the next cron run. When content is marked for reindexing, the previous content remains in the index until cron runs, at which time it is replaced by the new content. However, there are some actions related to the structure of your site that do not cause affected content to be marked for reindexing. Examples of structure-related actions that affect content include deleting or editing taxonomy terms, enabling or disabling modules that add text to content (such as Taxonomy, Comment, and field-providing modules), and modifying the fields or display parameters of your content types. If you take one of these actions and you want to ensure that the search index is updated to reflect your changed site structure, you can mark all content for reindexing by clicking the "Re-index site" button on the <a href=":search-settings">Search pages page</a>. If you have a lot of content on your site, it may take several cron runs for the content to be reindexed.', array(':search-settings' => \Drupal::url('entity.search_page.collection'))) . '</dd>';
+ $output .= '<dd>' . t('Some search page plugins, such as the core Content search page, index searchable text using the Drupal core search index, and will not work unless content is indexed. Indexing is done during <em>cron</em> runs, so it requires a <a href=":cron">cron maintenance task</a> to be set up. There are also several settings affecting indexing that can be configured on the <a href=":search-settings">Search pages page</a>: the number of items to index per cron run, the minimum word length to index, and how to handle Chinese, Japanese, and Korean characters.', [':cron' => \Drupal::url('system.cron_settings'), ':search-settings' => \Drupal::url('entity.search_page.collection')]) . '</dd>';
+ $output .= '<dd>' . t('Modules providing search page plugins generally ensure that content-related actions on your site (creating, editing, or deleting content and comments) automatically cause affected content items to be marked for indexing or reindexing at the next cron run. When content is marked for reindexing, the previous content remains in the index until cron runs, at which time it is replaced by the new content. However, there are some actions related to the structure of your site that do not cause affected content to be marked for reindexing. Examples of structure-related actions that affect content include deleting or editing taxonomy terms, enabling or disabling modules that add text to content (such as Taxonomy, Comment, and field-providing modules), and modifying the fields or display parameters of your content types. If you take one of these actions and you want to ensure that the search index is updated to reflect your changed site structure, you can mark all content for reindexing by clicking the "Re-index site" button on the <a href=":search-settings">Search pages page</a>. If you have a lot of content on your site, it may take several cron runs for the content to be reindexed.', [':search-settings' => \Drupal::url('entity.search_page.collection')]) . '</dd>';
$output .= '<dt>' . t('Displaying the Search block') . '</dt>';
- $output .= '<dd>' . t('The Search module includes a block, which can be enabled and configured on the <a href=":blocks">Block layout page</a>, if you have the Block module enabled; the default block title is Search, and it is the Search form block in the Forms category, if you wish to add another instance. The block is available to users with the <a href=":search_permission">Use search</a> permission, and it performs a search using the configured default search page.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':search_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-search')))) . '</dd>';
+ $output .= '<dd>' . t('The Search module includes a block, which can be enabled and configured on the <a href=":blocks">Block layout page</a>, if you have the Block module enabled; the default block title is Search, and it is the Search form block in the Forms category, if you wish to add another instance. The block is available to users with the <a href=":search_permission">Use search</a> permission, and it performs a search using the configured default search page.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':search_permission' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-search'])]) . '</dd>';
$output .= '<dt>' . t('Searching your site') . '</dt>';
- $output .= '<dd>' . t('Users with <a href=":search_permission">Use search</a> permission can use the Search block and <a href=":search">Search page</a>. Users with the <a href=":node_permission">View published content</a> permission can use configured search pages of type <em>Content</em> to search for content containing exact keywords; in addition, users with <a href=":search_permission">Use advanced search</a> permission can use more complex search filtering. Users with the <a href=":user_permission">View user information</a> permission can use configured search pages of type <em>Users</em> to search for active users containing the keyword anywhere in the username, and users with the <a href=":user_permission">Administer users</a> permission can search for active and blocked users, by email address or username keyword.', array(':search' => \Drupal::url('search.view'), ':search_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-search')), ':node_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-node')), ':user_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-user')))) . '</dd>';
+ $output .= '<dd>' . t('Users with <a href=":search_permission">Use search</a> permission can use the Search block and <a href=":search">Search page</a>. Users with the <a href=":node_permission">View published content</a> permission can use configured search pages of type <em>Content</em> to search for content containing exact keywords; in addition, users with <a href=":search_permission">Use advanced search</a> permission can use more complex search filtering. Users with the <a href=":user_permission">View user information</a> permission can use configured search pages of type <em>Users</em> to search for active users containing the keyword anywhere in the username, and users with the <a href=":user_permission">Administer users</a> permission can search for active and blocked users, by email address or username keyword.', [':search' => \Drupal::url('search.view'), ':search_permission' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-search']), ':node_permission' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-node']), ':user_permission' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-user'])]) . '</dd>';
$output .= '<dt>' . t('Extending the Search module') . '</dt>';
- $output .= '<dd>' . t('By default, the Search module only supports exact keyword matching in content searches. You can modify this behavior by installing a language-specific stemming module for your language (such as <a href=":porterstemmer_url">Porter Stemmer</a> for American English), which allows words such as walk, walking, and walked to be matched in the Search module. Another approach is to use a third-party search technology with stemming or partial word matching features built in, such as <a href=":solr_url">Apache Solr</a> or <a href=":sphinx_url">Sphinx</a>. There are also contributed modules that provide additional search pages. These and other <a href=":contrib-search">search-related contributed modules</a> can be downloaded by visiting Drupal.org.', array(':contrib-search' => 'https://www.drupal.org/project/project_module?f[2]=im_vid_3%3A105', ':porterstemmer_url' => 'https://www.drupal.org/project/porterstemmer', ':solr_url' => 'https://www.drupal.org/project/apachesolr', ':sphinx_url' => 'https://www.drupal.org/project/sphinx')) . '</dd>';
+ $output .= '<dd>' . t('By default, the Search module only supports exact keyword matching in content searches. You can modify this behavior by installing a language-specific stemming module for your language (such as <a href=":porterstemmer_url">Porter Stemmer</a> for American English), which allows words such as walk, walking, and walked to be matched in the Search module. Another approach is to use a third-party search technology with stemming or partial word matching features built in, such as <a href=":solr_url">Apache Solr</a> or <a href=":sphinx_url">Sphinx</a>. There are also contributed modules that provide additional search pages. These and other <a href=":contrib-search">search-related contributed modules</a> can be downloaded by visiting Drupal.org.', [':contrib-search' => 'https://www.drupal.org/project/project_module?f[2]=im_vid_3%3A105', ':porterstemmer_url' => 'https://www.drupal.org/project/porterstemmer', ':solr_url' => 'https://www.drupal.org/project/apachesolr', ':sphinx_url' => 'https://www.drupal.org/project/sphinx']) . '</dd>';
$output .= '</dl>';
return $output;
}
@@ -98,12 +98,12 @@ function search_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function search_theme() {
- return array(
- 'search_result' => array(
- 'variables' => array('result' => NULL, 'plugin_id' => NULL),
+ return [
+ 'search_result' => [
+ 'variables' => ['result' => NULL, 'plugin_id' => NULL],
'file' => 'search.pages.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -168,7 +168,7 @@ function search_index_clear($type = NULL, $sid = NULL, $langcode = NULL) {
* total counts in the search_total table, and need to be recounted.
*/
function search_dirty($word = NULL) {
- $dirty = &drupal_static(__FUNCTION__, array());
+ $dirty = &drupal_static(__FUNCTION__, []);
if ($word !== NULL) {
$dirty[$word] = TRUE;
}
@@ -207,18 +207,18 @@ function search_update_totals() {
// Update word IDF (Inverse Document Frequency) counts for new/changed words.
foreach (search_dirty() as $word => $dummy) {
// Get total count
- $total = db_query("SELECT SUM(score) FROM {search_index} WHERE word = :word", array(':word' => $word), array('target' => 'replica'))->fetchField();
+ $total = db_query("SELECT SUM(score) FROM {search_index} WHERE word = :word", [':word' => $word], ['target' => 'replica'])->fetchField();
// Apply Zipf's law to equalize the probability distribution.
$total = log10(1 + 1 / (max(1, $total)));
db_merge('search_total')
->key('word', $word)
- ->fields(array('count' => $total))
+ ->fields(['count' => $total])
->execute();
}
// Find words that were deleted from search_index, but are still in
// search_total. We use a LEFT JOIN between the two tables and keep only the
// rows which fail to join.
- $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", array(), array('target' => 'replica'));
+ $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", [], ['target' => 'replica']);
$or = new Condition('OR');
foreach ($result as $word) {
$or->condition('word', $word->realword);
@@ -330,7 +330,7 @@ function search_expand_cjk($matches) {
}
$tokens = ' ';
// Build a FIFO queue of characters.
- $chars = array();
+ $chars = [];
for ($i = 0; $i < $length; $i++) {
// Add the next character off the beginning of the string to the queue.
$current = Unicode::substr($str, 0, 1);
@@ -383,7 +383,7 @@ function search_index_split($text, $langcode = NULL) {
function _search_index_truncate(&$text) {
// Use a static array to avoid re-truncating text we've done before.
// The same words may often be passed in during excerpt generation.
- static $truncated = array();
+ static $truncated = [];
if (isset($truncated[$text])) {
$text = $truncated[$text];
return;
@@ -409,7 +409,7 @@ function _search_index_truncate(&$text) {
*/
function search_invoke_preprocess(&$text, $langcode = NULL) {
foreach (\Drupal::moduleHandler()->getImplementations('search_preprocess') as $module) {
- $text = \Drupal::moduleHandler()->invoke($module, 'search_preprocess', array($text, $langcode));
+ $text = \Drupal::moduleHandler()->invoke($module, 'search_preprocess', [$text, $langcode]);
}
}
@@ -438,7 +438,7 @@ function search_index($type, $sid, $langcode, $text) {
// Strip off all ignored tags to speed up processing, but insert space before
// and after them to keep word boundaries.
- $text = str_replace(array('<', '>'), array(' <', '> '), $text);
+ $text = str_replace(['<', '>'], [' <', '> '], $text);
$text = strip_tags($text, '<' . implode('><', array_keys($tags)) . '>');
// Split HTML tags from plain text.
@@ -449,11 +449,11 @@ function search_index($type, $sid, $langcode, $text) {
$tag = FALSE; // Odd/even counter. Tag or no tag.
$score = 1; // Starting score per word
$accum = ' '; // Accumulator for cleaned up data
- $tagstack = array(); // Stack with open tags
+ $tagstack = []; // Stack with open tags
$tagwords = 0; // Counter for consecutive words
$focus = 1; // Focus state
- $scored_words = array(); // Accumulator for words for index
+ $scored_words = []; // Accumulator for words for index
foreach ($split as $value) {
if ($tag) {
@@ -465,7 +465,7 @@ function search_index($type, $sid, $langcode, $text) {
$tagname = substr($tagname, 1);
// If we encounter unexpected tags, reset score to avoid incorrect boosting.
if (!count($tagstack) || $tagstack[0] != $tagname) {
- $tagstack = array();
+ $tagstack = [];
$score = 1;
}
else {
@@ -477,7 +477,7 @@ function search_index($type, $sid, $langcode, $text) {
if (isset($tagstack[0]) && $tagstack[0] == $tagname) {
// None of the tags we look for make sense when nested identically.
// If they are, it's probably broken HTML.
- $tagstack = array();
+ $tagstack = [];
$score = 1;
}
else {
@@ -509,7 +509,7 @@ function search_index($type, $sid, $langcode, $text) {
$tagwords++;
// Too many words inside a single tag probably mean a tag was accidentally left open.
if (count($tagstack) && $tagwords >= 15) {
- $tagstack = array();
+ $tagstack = [];
$score = 1;
}
}
@@ -524,13 +524,13 @@ function search_index($type, $sid, $langcode, $text) {
// Insert cleaned up data into dataset
db_insert('search_dataset')
- ->fields(array(
+ ->fields([
'sid' => $sid,
'langcode' => $langcode,
'type' => $type,
'data' => $accum,
'reindex' => 0,
- ))
+ ])
->execute();
// Insert results into search index
@@ -539,14 +539,14 @@ function search_index($type, $sid, $langcode, $text) {
// appropriately. If not, we create a new record with the appropriate
// starting score.
db_merge('search_index')
- ->keys(array(
+ ->keys([
'word' => $word,
'sid' => $sid,
'langcode' => $langcode,
'type' => $type,
- ))
- ->fields(array('score' => $score))
- ->expression('score', 'score + :score', array(':score' => $score))
+ ])
+ ->fields(['score' => $score])
+ ->expression('score', 'score + :score', [':score' => $score])
->execute();
search_dirty($word);
}
@@ -572,7 +572,7 @@ function search_index($type, $sid, $langcode, $text) {
*/
function search_mark_for_reindex($type = NULL, $sid = NULL, $langcode = NULL) {
$query = db_update('search_dataset')
- ->fields(array('reindex' => REQUEST_TIME))
+ ->fields(['reindex' => REQUEST_TIME])
// Only mark items that were not previously marked for reindex, so that
// marked items maintain their priority by request time.
->condition('reindex', 0);
@@ -651,14 +651,14 @@ function search_excerpt($keys, $text, $langcode = NULL) {
$keys = array_merge($matches[2], $matches[3]);
// Prepare text by stripping HTML tags and decoding HTML entities.
- $text = strip_tags(str_replace(array('<', '>'), array(' <', '> '), $text));
+ $text = strip_tags(str_replace(['<', '>'], [' <', '> '], $text));
$text = Html::decodeEntities($text);
$text_length = strlen($text);
// Make a list of unique keywords that are actually found in the text,
// which could be items in $keys or replacements that are equivalent through
// search_simplify().
- $temp_keys = array();
+ $temp_keys = [];
foreach ($keys as $key) {
$key = _search_find_match_with_simplify($key, $text, $boundary_character, $langcode);
if (isset($key)) {
@@ -673,13 +673,13 @@ function search_excerpt($keys, $text, $langcode = NULL) {
// Extract fragments of about 60 characters around keywords, bounded by word
// boundary characters. Try to reach 256 characters, using second occurrences
// if necessary.
- $ranges = array();
+ $ranges = [];
$length = 0;
- $look_start = array();
+ $look_start = [];
$remaining_keys = $keys;
while ($length < 256 && !empty($remaining_keys)) {
- $found_keys = array();
+ $found_keys = [];
foreach ($remaining_keys as $key) {
if ($length >= 256) {
break;
@@ -694,7 +694,7 @@ function search_excerpt($keys, $text, $langcode = NULL) {
// See if we can find $key after where we found it the last time. Since
// we are requiring a match on a word boundary, make sure $text starts
// and ends with a space.
- $matches = array();
+ $matches = [];
if (preg_match('/' . $preceded_by_boundary . $key . $followed_by_boundary . '/iu', ' ' . $text . ' ', $matches, PREG_OFFSET_CAPTURE, $look_start[$key])) {
$found_position = $matches[0][1];
$look_start[$key] = $found_position + 1;
@@ -742,7 +742,7 @@ function search_excerpt($keys, $text, $langcode = NULL) {
ksort($ranges);
// Collapse overlapping text ranges into one. The sorting makes it O(n).
- $new_ranges = array();
+ $new_ranges = [];
$max_end = 0;
foreach ($ranges as $this_from => $this_to) {
$max_end = max($max_end, $this_to);
@@ -767,7 +767,7 @@ function search_excerpt($keys, $text, $langcode = NULL) {
$new_ranges[$working_from] = $working_to;
// Fetch text within the combined ranges we found.
- $out = array();
+ $out = [];
foreach ($new_ranges as $from => $to) {
$out[] = substr($text, $from, $to - $from);
}
@@ -847,7 +847,7 @@ function _search_find_match_with_simplify($key, $text, $boundary, $langcode = NU
// Split $text into words, keeping track of where the word boundaries are.
$words = preg_split('/' . $boundary . '+/u', $text, NULL, PREG_SPLIT_OFFSET_CAPTURE);
// Add an entry pointing to the end of the string, for the loop below.
- $words[] = array('', strlen($text));
+ $words[] = ['', strlen($text)];
// Using a binary search, find the earliest possible ending position in
// $text where it will still match the keyword after applying
diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc
index a161a9bfae2..9467dd82501 100644
--- a/core/modules/search/search.pages.inc
+++ b/core/modules/search/search.pages.inc
@@ -12,7 +12,7 @@ use Drupal\Core\Language\LanguageInterface;
* Implements hook_theme_suggestions_HOOK().
*/
function search_theme_suggestions_search_result(array $variables) {
- return array('search_result__' . $variables['plugin_id']);
+ return ['search_result__' . $variables['plugin_id']];
}
/**
@@ -42,7 +42,7 @@ function template_preprocess_search_result(&$variables) {
$variables['content_attributes']['lang'] = $result['language'];
}
- $info = array();
+ $info = [];
if (!empty($result['plugin_id'])) {
$info['plugin_id'] = $result['plugin_id'];
}
@@ -59,9 +59,9 @@ function template_preprocess_search_result(&$variables) {
$variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : '';
// Provide separated and grouped meta information..
$variables['info_split'] = $info;
- $variables['info'] = array(
+ $variables['info'] = [
'#type' => 'inline_template',
'#template' => '{{ info|safe_join(" - ") }}',
- '#context' => array('info' => $info),
- );
+ '#context' => ['info' => $info],
+ ];
}
diff --git a/core/modules/search/src/Controller/SearchController.php b/core/modules/search/src/Controller/SearchController.php
index 3460c32068c..ac078e18eb5 100644
--- a/core/modules/search/src/Controller/SearchController.php
+++ b/core/modules/search/src/Controller/SearchController.php
@@ -72,7 +72,7 @@ class SearchController extends ControllerBase {
* The search form and search results build array.
*/
public function view(Request $request, SearchPageInterface $entity) {
- $build = array();
+ $build = [];
$plugin = $entity->getPlugin();
// Build the form first, because it may redirect during the submit,
@@ -89,12 +89,12 @@ class SearchController extends ControllerBase {
// Build search results, if keywords or other search parameters are in the
// GET parameters. Note that we need to try the search if 'keys' is in
// there at all, vs. being empty, due to advanced search.
- $results = array();
+ $results = [];
if ($request->query->has('keys')) {
if ($plugin->isSearchExecutable()) {
// Log the search.
if ($this->config('search.settings')->get('logging')) {
- $this->logger->notice('Searched %type for %keys.', array('%keys' => $keys, '%type' => $entity->label()));
+ $this->logger->notice('Searched %type for %keys.', ['%keys' => $keys, '%type' => $entity->label()]);
}
// Collect the search results.
@@ -108,22 +108,22 @@ class SearchController extends ControllerBase {
}
if (count($results)) {
- $build['search_results_title'] = array(
+ $build['search_results_title'] = [
'#markup' => '<h2>' . $this->t('Search results') . '</h2>',
- );
+ ];
}
- $build['search_results'] = array(
- '#theme' => array('item_list__search_results__' . $plugin->getPluginId(), 'item_list__search_results'),
+ $build['search_results'] = [
+ '#theme' => ['item_list__search_results__' . $plugin->getPluginId(), 'item_list__search_results'],
'#items' => $results,
- '#empty' => array(
+ '#empty' => [
'#markup' => '<h3>' . $this->t('Your search yielded no results.') . '</h3>',
- ),
+ ],
'#list_type' => 'ol',
- '#context' => array(
+ '#context' => [
'plugin' => $plugin->getPluginId(),
- ),
- );
+ ],
+ ];
$this->renderer->addCacheableDependency($build, $entity);
if ($plugin instanceof CacheableDependencyInterface) {
@@ -138,9 +138,9 @@ class SearchController extends ControllerBase {
$build['search_results']['#cache']['tags'][] = 'search_index:' . $plugin->getType();
}
- $build['pager'] = array(
+ $build['pager'] = [
'#type' => 'pager',
- );
+ ];
return $build;
}
@@ -157,7 +157,7 @@ class SearchController extends ControllerBase {
* The search help page.
*/
public function searchHelp(SearchPageInterface $entity) {
- $build = array();
+ $build = [];
$build['search_help'] = $entity->getPlugin()->getHelp();
@@ -189,7 +189,7 @@ class SearchController extends ControllerBase {
* The title for the search page edit form.
*/
public function editTitle(SearchPageInterface $search_page) {
- return $this->t('Edit %label search page', array('%label' => $search_page->label()));
+ return $this->t('Edit %label search page', ['%label' => $search_page->label()]);
}
/**
@@ -207,10 +207,10 @@ class SearchController extends ControllerBase {
$search_page->$op()->save();
if ($op == 'enable') {
- drupal_set_message($this->t('The %label search page has been enabled.', array('%label' => $search_page->label())));
+ drupal_set_message($this->t('The %label search page has been enabled.', ['%label' => $search_page->label()]));
}
elseif ($op == 'disable') {
- drupal_set_message($this->t('The %label search page has been disabled.', array('%label' => $search_page->label())));
+ drupal_set_message($this->t('The %label search page has been disabled.', ['%label' => $search_page->label()]));
}
$url = $search_page->urlInfo('collection');
@@ -230,7 +230,7 @@ class SearchController extends ControllerBase {
// Set the default page to this search page.
$this->searchPageRepository->setDefaultSearchPage($search_page);
- drupal_set_message($this->t('The default search page is now %label. Be sure to check the ordering of your search pages.', array('%label' => $search_page->label())));
+ drupal_set_message($this->t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $search_page->label()]));
return $this->redirect('entity.search_page.collection');
}
diff --git a/core/modules/search/src/Entity/SearchPage.php b/core/modules/search/src/Entity/SearchPage.php
index 1cb2f892fbd..298331fdf0c 100644
--- a/core/modules/search/src/Entity/SearchPage.php
+++ b/core/modules/search/src/Entity/SearchPage.php
@@ -73,7 +73,7 @@ class SearchPage extends ConfigEntityBase implements SearchPageInterface, Entity
*
* @var array
*/
- protected $configuration = array();
+ protected $configuration = [];
/**
* The search plugin ID.
@@ -129,7 +129,7 @@ class SearchPage extends ConfigEntityBase implements SearchPageInterface, Entity
* {@inheritdoc}
*/
public function getPluginCollections() {
- return array('configuration' => $this->getPluginCollection());
+ return ['configuration' => $this->getPluginCollection()];
}
/**
diff --git a/core/modules/search/src/Form/SearchBlockForm.php b/core/modules/search/src/Form/SearchBlockForm.php
index cd198fd7944..5d77b7c3bfb 100644
--- a/core/modules/search/src/Form/SearchBlockForm.php
+++ b/core/modules/search/src/Form/SearchBlockForm.php
@@ -76,9 +76,9 @@ class SearchBlockForm extends FormBase {
// Set up the form to submit using GET to the correct search page.
$entity_id = $this->searchPageRepository->getDefaultSearchPage();
if (!$entity_id) {
- $form['message'] = array(
+ $form['message'] = [
'#markup' => $this->t('Search is currently disabled'),
- );
+ ];
return $form;
}
@@ -86,22 +86,22 @@ class SearchBlockForm extends FormBase {
$form['#action'] = $this->url($route);
$form['#method'] = 'get';
- $form['keys'] = array(
+ $form['keys'] = [
'#type' => 'search',
'#title' => $this->t('Search'),
'#title_display' => 'invisible',
'#size' => 15,
'#default_value' => '',
- '#attributes' => array('title' => $this->t('Enter the terms you wish to search for.')),
- );
+ '#attributes' => ['title' => $this->t('Enter the terms you wish to search for.')],
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Search'),
// Prevent op from showing up in the query string.
'#name' => '',
- );
+ ];
// SearchPageRepository::getDefaultSearchPage() depends on search.settings.
$this->renderer->addCacheableDependency($form, $this->configFactory->get('search.settings'));
diff --git a/core/modules/search/src/Form/SearchPageAddForm.php b/core/modules/search/src/Form/SearchPageAddForm.php
index a97f1fa5eff..d5bc7850ec7 100644
--- a/core/modules/search/src/Form/SearchPageAddForm.php
+++ b/core/modules/search/src/Form/SearchPageAddForm.php
@@ -39,7 +39,7 @@ class SearchPageAddForm extends SearchPageFormBase {
parent::save($form, $form_state);
- drupal_set_message($this->t('The %label search page has been added.', array('%label' => $this->entity->label())));
+ drupal_set_message($this->t('The %label search page has been added.', ['%label' => $this->entity->label()]));
}
}
diff --git a/core/modules/search/src/Form/SearchPageEditForm.php b/core/modules/search/src/Form/SearchPageEditForm.php
index 694b8567b08..9d082eb5520 100644
--- a/core/modules/search/src/Form/SearchPageEditForm.php
+++ b/core/modules/search/src/Form/SearchPageEditForm.php
@@ -24,7 +24,7 @@ class SearchPageEditForm extends SearchPageFormBase {
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
- drupal_set_message($this->t('The %label search page has been updated.', array('%label' => $this->entity->label())));
+ drupal_set_message($this->t('The %label search page has been updated.', ['%label' => $this->entity->label()]));
}
}
diff --git a/core/modules/search/src/Form/SearchPageForm.php b/core/modules/search/src/Form/SearchPageForm.php
index 1521beb6da7..88b99e55eba 100644
--- a/core/modules/search/src/Form/SearchPageForm.php
+++ b/core/modules/search/src/Form/SearchPageForm.php
@@ -38,37 +38,37 @@ class SearchPageForm extends EntityForm {
$plugin = $this->entity->getPlugin();
$form_state->set('search_page_id', $this->entity->id());
- $form['basic'] = array(
+ $form['basic'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('container-inline'),
- ),
- );
- $form['basic']['keys'] = array(
+ '#attributes' => [
+ 'class' => ['container-inline'],
+ ],
+ ];
+ $form['basic']['keys'] = [
'#type' => 'search',
'#title' => $this->t('Enter your keywords'),
'#default_value' => $plugin->getKeywords(),
'#size' => 30,
'#maxlength' => 255,
- );
+ ];
// processed_keys is used to coordinate keyword passing between other forms
// that hook into the basic search form.
- $form['basic']['processed_keys'] = array(
+ $form['basic']['processed_keys'] = [
'#type' => 'value',
'#value' => '',
- );
- $form['basic']['submit'] = array(
+ ];
+ $form['basic']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Search'),
- );
+ ];
- $form['help_link'] = array(
+ $form['help_link'] = [
'#type' => 'link',
'#url' => new Url('search.help_' . $this->entity->id()),
'#title' => $this->t('Search help'),
- '#options' => array('attributes' => array('class' => 'search-help-link')),
- );
+ '#options' => ['attributes' => ['class' => 'search-help-link']],
+ ];
// Allow the plugin to add to or alter the search form.
$plugin->searchFormAlter($form, $form_state);
@@ -81,7 +81,7 @@ class SearchPageForm extends EntityForm {
*/
protected function actions(array $form, FormStateInterface $form_state) {
// The submit button is added in the form directly.
- return array();
+ return [];
}
/**
@@ -97,8 +97,8 @@ class SearchPageForm extends EntityForm {
$route = 'search.view_' . $form_state->get('search_page_id');
$form_state->setRedirect(
$route,
- array(),
- array('query' => $query)
+ [],
+ ['query' => $query]
);
}
diff --git a/core/modules/search/src/Form/SearchPageFormBase.php b/core/modules/search/src/Form/SearchPageFormBase.php
index bc7032f428a..1638f90a86b 100644
--- a/core/modules/search/src/Form/SearchPageFormBase.php
+++ b/core/modules/search/src/Form/SearchPageFormBase.php
@@ -72,35 +72,35 @@ abstract class SearchPageFormBase extends EntityForm {
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#description' => $this->t('The label for this search page.'),
'#default_value' => $this->entity->label(),
'#maxlength' => '255',
- );
+ ];
- $form['id'] = array(
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $this->entity->id(),
'#disabled' => !$this->entity->isNew(),
'#maxlength' => 64,
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
- ),
- );
- $form['path'] = array(
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
+ ],
+ ];
+ $form['path'] = [
'#type' => 'textfield',
'#title' => $this->t('Path'),
'#field_prefix' => 'search/',
'#default_value' => $this->entity->getPath(),
'#maxlength' => '255',
'#required' => TRUE,
- );
- $form['plugin'] = array(
+ ];
+ $form['plugin'] = [
'#type' => 'value',
'#value' => $this->entity->get('plugin'),
- );
+ ];
if ($this->plugin instanceof PluginFormInterface) {
$form += $this->plugin->buildConfigurationForm($form, $form_state);
diff --git a/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php b/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php
index 4f259831d0c..7ad95f16823 100644
--- a/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php
+++ b/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php
@@ -30,7 +30,7 @@ abstract class ConfigurableSearchPluginBase extends SearchPluginBase implements
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array();
+ return [];
}
/**
@@ -57,7 +57,7 @@ abstract class ConfigurableSearchPluginBase extends SearchPluginBase implements
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
/**
diff --git a/core/modules/search/src/Plugin/Derivative/SearchLocalTask.php b/core/modules/search/src/Plugin/Derivative/SearchLocalTask.php
index adc356e954a..9f62a375ea7 100644
--- a/core/modules/search/src/Plugin/Derivative/SearchLocalTask.php
+++ b/core/modules/search/src/Plugin/Derivative/SearchLocalTask.php
@@ -42,17 +42,17 @@ class SearchLocalTask extends DeriverBase implements ContainerDeriverInterface {
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $this->derivatives = array();
+ $this->derivatives = [];
if ($default = $this->searchPageRepository->getDefaultSearchPage()) {
$active_search_pages = $this->searchPageRepository->getActiveSearchPages();
foreach ($this->searchPageRepository->sortSearchPages($active_search_pages) as $entity_id => $entity) {
- $this->derivatives[$entity_id] = array(
+ $this->derivatives[$entity_id] = [
'title' => $entity->label(),
'route_name' => 'search.view_' . $entity_id,
'base_route' => 'search.plugins:' . $default,
'weight' => $entity->getWeight(),
- );
+ ];
}
}
return $this->derivatives;
diff --git a/core/modules/search/src/Plugin/SearchPluginBase.php b/core/modules/search/src/Plugin/SearchPluginBase.php
index d253972ce16..7bf4f0f4e35 100644
--- a/core/modules/search/src/Plugin/SearchPluginBase.php
+++ b/core/modules/search/src/Plugin/SearchPluginBase.php
@@ -97,13 +97,13 @@ abstract class SearchPluginBase extends PluginBase implements ContainerFactoryPl
public function buildResults() {
$results = $this->execute();
- $built = array();
+ $built = [];
foreach ($results as $result) {
- $built[] = array(
+ $built[] = [
'#theme' => 'search_result',
'#result' => $result,
'#plugin_id' => $this->getPluginId(),
- );
+ ];
}
return $built;
@@ -123,7 +123,7 @@ abstract class SearchPluginBase extends PluginBase implements ContainerFactoryPl
// If the user entered a search string, truncate it and append it to the
// title.
if (!empty($this->keywords)) {
- return $this->t('Search for @keywords', array('@keywords' => Unicode::truncate($this->keywords, 60, TRUE, TRUE)));
+ return $this->t('Search for @keywords', ['@keywords' => Unicode::truncate($this->keywords, 60, TRUE, TRUE)]);
}
// Use the default 'Search' title.
return $this->t('Search');
@@ -135,7 +135,7 @@ abstract class SearchPluginBase extends PluginBase implements ContainerFactoryPl
public function buildSearchUrlQuery(FormStateInterface $form_state) {
// Grab the keywords entered in the form and put them as 'keys' in the GET.
$keys = trim($form_state->getValue('keys'));
- $query = array('keys' => $keys);
+ $query = ['keys' => $keys];
return $query;
}
@@ -146,16 +146,16 @@ abstract class SearchPluginBase extends PluginBase implements ContainerFactoryPl
public function getHelp() {
// This default search help is appropriate for plugins like NodeSearch
// that use the SearchQuery class.
- $help = array('list' => array(
+ $help = ['list' => [
'#theme' => 'item_list',
- '#items' => array(
+ '#items' => [
$this->t('Search looks for exact, case-insensitive keywords; keywords shorter than a minimum length are ignored.'),
$this->t('Use upper-case OR to get more results. Example: cat OR dog (content contains either "cat" or "dog").'),
$this->t('You can use upper-case AND to require all words, but this is the same as the default behavior. Example: cat AND dog (same as cat dog, content must contain both "cat" and "dog").'),
$this->t('Use quotes to search for a phrase. Example: "the cat eats mice".'),
$this->t('You can precede keywords by - to exclude them; you must still have at least one "positive" keyword. Example: cat -dog (content must contain cat and cannot contain dog).'),
- ),
- ));
+ ],
+ ]];
return $help;
}
diff --git a/core/modules/search/src/Plugin/migrate/process/SearchConfigurationRankings.php b/core/modules/search/src/Plugin/migrate/process/SearchConfigurationRankings.php
index f021df68be1..8199215c327 100644
--- a/core/modules/search/src/Plugin/migrate/process/SearchConfigurationRankings.php
+++ b/core/modules/search/src/Plugin/migrate/process/SearchConfigurationRankings.php
@@ -21,7 +21,7 @@ class SearchConfigurationRankings extends ProcessPluginBase {
* Generate the configuration rankings.
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
- $return = array();
+ $return = [];
foreach ($row->getSource() as $name => $rank) {
if (substr($name, 0, 10) == 'node_rank_' && is_numeric($rank)) {
$return[substr($name, 10)] = $rank;
diff --git a/core/modules/search/src/Plugin/migrate/process/d6/SearchConfigurationRankings.php b/core/modules/search/src/Plugin/migrate/process/d6/SearchConfigurationRankings.php
index 6c1d16b0409..206f1f8060b 100644
--- a/core/modules/search/src/Plugin/migrate/process/d6/SearchConfigurationRankings.php
+++ b/core/modules/search/src/Plugin/migrate/process/d6/SearchConfigurationRankings.php
@@ -21,7 +21,7 @@ class SearchConfigurationRankings extends ProcessPluginBase {
* Generate the configuration rankings.
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
- $return = array();
+ $return = [];
foreach ($row->getSource() as $name => $rank) {
if (substr($name, 0, 10) == 'node_rank_' && $rank) {
$return[substr($name, 10)] = $rank;
diff --git a/core/modules/search/src/Plugin/views/argument/Search.php b/core/modules/search/src/Plugin/views/argument/Search.php
index c56cd09982a..7e9f00d4bd8 100644
--- a/core/modules/search/src/Plugin/views/argument/Search.php
+++ b/core/modules/search/src/Plugin/views/argument/Search.php
@@ -48,7 +48,7 @@ class Search extends ArgumentPluginBase {
*/
protected function queryParseSearchExpression($input) {
if (!isset($this->searchQuery)) {
- $this->searchQuery = db_select('search_index', 'i', array('target' => 'replica'))->extend('Drupal\search\ViewsSearchQuery');
+ $this->searchQuery = db_select('search_index', 'i', ['target' => 'replica'])->extend('Drupal\search\ViewsSearchQuery');
$this->searchQuery->searchExpression($input, $this->searchType);
$this->searchQuery->publicParseSearchExpression();
}
@@ -80,17 +80,17 @@ class Search extends ArgumentPluginBase {
$search_condition = new Condition('AND');
// Create a new join to relate the 'search_total' table to our current 'search_index' table.
- $definition = array(
+ $definition = [
'table' => 'search_total',
'field' => 'word',
'left_table' => $search_index,
'left_field' => 'word',
- );
+ ];
$join = Views::pluginManager('join')->createInstance('standard', $definition);
$search_total = $this->query->addRelationship('search_total', $join, $search_index);
// Add the search score field to the query.
- $this->search_score = $this->query->addField('', "$search_index.score * $search_total.count", 'score', array('function' => 'sum'));
+ $this->search_score = $this->query->addField('', "$search_index.score * $search_total.count", 'score', ['function' => 'sum']);
// Add the conditions set up by the search query to the views query.
$search_condition->condition("$search_index.type", $this->searchType);
@@ -121,7 +121,7 @@ class Search extends ArgumentPluginBase {
$this->query->addGroupBy("$search_index.sid");
$matches = $this->searchQuery->matches();
$placeholder = $this->placeholder();
- $this->query->addHavingExpression(0, "COUNT(*) >= $placeholder", array($placeholder => $matches));
+ $this->query->addHavingExpression(0, "COUNT(*) >= $placeholder", [$placeholder => $matches]);
}
// Set to NULL to prevent PDO exception when views object is cached
diff --git a/core/modules/search/src/Plugin/views/filter/Search.php b/core/modules/search/src/Plugin/views/filter/Search.php
index 14b14da5acc..ac0f671ae21 100644
--- a/core/modules/search/src/Plugin/views/filter/Search.php
+++ b/core/modules/search/src/Plugin/views/filter/Search.php
@@ -68,28 +68,28 @@ class Search extends FilterPluginBase {
* {@inheritdoc}
*/
protected function operatorForm(&$form, FormStateInterface $form_state) {
- $form['operator'] = array(
+ $form['operator'] = [
'#type' => 'radios',
'#title' => $this->t('On empty input'),
'#default_value' => $this->operator,
- '#options' => array(
+ '#options' => [
'optional' => $this->t('Show All'),
'required' => $this->t('Show None'),
- ),
- );
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
protected function valueForm(&$form, FormStateInterface $form_state) {
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'textfield',
'#size' => 15,
'#default_value' => $this->value,
- '#attributes' => array('title' => $this->t('Search keywords')),
+ '#attributes' => ['title' => $this->t('Search keywords')],
'#title' => !$form_state->get('exposed') ? $this->t('Keywords') : '',
- );
+ ];
}
/**
@@ -118,7 +118,7 @@ class Search extends FilterPluginBase {
protected function queryParseSearchExpression($input) {
if (!isset($this->searchQuery)) {
$this->parsed = TRUE;
- $this->searchQuery = db_select('search_index', 'i', array('target' => 'replica'))->extend('Drupal\search\ViewsSearchQuery');
+ $this->searchQuery = db_select('search_index', 'i', ['target' => 'replica'])->extend('Drupal\search\ViewsSearchQuery');
$this->searchQuery->searchExpression($input, $this->searchType);
$this->searchQuery->publicParseSearchExpression();
}
@@ -155,17 +155,17 @@ class Search extends FilterPluginBase {
// Create a new join to relate the 'search_total' table to our current
// 'search_index' table.
- $definition = array(
+ $definition = [
'table' => 'search_total',
'field' => 'word',
'left_table' => $search_index,
'left_field' => 'word',
- );
+ ];
$join = Views::pluginManager('join')->createInstance('standard', $definition);
$search_total = $this->query->addRelationship('search_total', $join, $search_index);
// Add the search score field to the query.
- $this->search_score = $this->query->addField('', "$search_index.score * $search_total.count", 'score', array('function' => 'sum'));
+ $this->search_score = $this->query->addField('', "$search_index.score * $search_total.count", 'score', ['function' => 'sum']);
// Add the conditions set up by the search query to the views query.
$search_condition->condition("$search_index.type", $this->searchType);
@@ -197,7 +197,7 @@ class Search extends FilterPluginBase {
$this->query->addGroupBy("$search_index.sid");
$matches = $this->searchQuery->matches();
$placeholder = $this->placeholder();
- $this->query->addHavingExpression($this->options['group'], "COUNT(*) >= $placeholder", array($placeholder => $matches));
+ $this->query->addHavingExpression($this->options['group'], "COUNT(*) >= $placeholder", [$placeholder => $matches]);
}
// Set to NULL to prevent PDO exception when views object is cached.
$this->searchQuery = NULL;
diff --git a/core/modules/search/src/Plugin/views/row/SearchRow.php b/core/modules/search/src/Plugin/views/row/SearchRow.php
index 51f78536846..29e150d557b 100644
--- a/core/modules/search/src/Plugin/views/row/SearchRow.php
+++ b/core/modules/search/src/Plugin/views/row/SearchRow.php
@@ -22,7 +22,7 @@ class SearchRow extends RowPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['score'] = array('default' => TRUE);
+ $options['score'] = ['default' => TRUE];
return $options;
}
@@ -31,23 +31,23 @@ class SearchRow extends RowPluginBase {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['score'] = array(
+ $form['score'] = [
'#type' => 'checkbox',
'#title' => $this->t('Display score'),
'#default_value' => $this->options['score'],
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function render($row) {
- return array(
+ return [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $row,
- );
+ ];
}
}
diff --git a/core/modules/search/src/Plugin/views/sort/Score.php b/core/modules/search/src/Plugin/views/sort/Score.php
index 7a7bbf0f7be..f5910f0d56e 100644
--- a/core/modules/search/src/Plugin/views/sort/Score.php
+++ b/core/modules/search/src/Plugin/views/sort/Score.php
@@ -21,7 +21,7 @@ class Score extends SortPluginBase {
// Our filter stores it as $handler->search_score -- and we also
// need to check its relationship to make sure that we're using the same
// one or obviously this won't work.
- foreach (array('filter', 'argument') as $type) {
+ foreach (['filter', 'argument'] as $type) {
foreach ($this->view->{$type} as $handler) {
if (isset($handler->search_score) && $handler->relationship == $this->relationship) {
$this->query->addOrderBy(NULL, NULL, $this->options['order'], $handler->search_score);
diff --git a/core/modules/search/src/Routing/SearchPageRoutes.php b/core/modules/search/src/Routing/SearchPageRoutes.php
index b85cbe8f293..6e199d3dfc9 100644
--- a/core/modules/search/src/Routing/SearchPageRoutes.php
+++ b/core/modules/search/src/Routing/SearchPageRoutes.php
@@ -45,70 +45,70 @@ class SearchPageRoutes implements ContainerInjectionInterface {
* An array of route objects.
*/
public function routes() {
- $routes = array();
+ $routes = [];
// @todo Decide if /search should continue to redirect to /search/$default,
// or just perform the appropriate search.
if ($default_page = $this->searchPageRepository->getDefaultSearchPage()) {
$routes['search.view'] = new Route(
'/search',
- array(
+ [
'_controller' => 'Drupal\search\Controller\SearchController::redirectSearchPage',
'_title' => 'Search',
'entity' => $default_page,
- ),
- array(
+ ],
+ [
'_entity_access' => 'entity.view',
'_permission' => 'search content',
- ),
- array(
- 'parameters' => array(
- 'entity' => array(
+ ],
+ [
+ 'parameters' => [
+ 'entity' => [
'type' => 'entity:search_page',
- ),
- ),
- )
+ ],
+ ],
+ ]
);
}
$active_pages = $this->searchPageRepository->getActiveSearchPages();
foreach ($active_pages as $entity_id => $entity) {
$routes["search.view_$entity_id"] = new Route(
'/search/' . $entity->getPath(),
- array(
+ [
'_controller' => 'Drupal\search\Controller\SearchController::view',
'_title' => 'Search',
'entity' => $entity_id,
- ),
- array(
+ ],
+ [
'_entity_access' => 'entity.view',
'_permission' => 'search content',
- ),
- array(
- 'parameters' => array(
- 'entity' => array(
+ ],
+ [
+ 'parameters' => [
+ 'entity' => [
'type' => 'entity:search_page',
- ),
- ),
- )
+ ],
+ ],
+ ]
);
$routes["search.help_$entity_id"] = new Route(
'/search/' . $entity->getPath() . '/help',
- array(
+ [
'_controller' => 'Drupal\search\Controller\SearchController::searchHelp',
'_title' => 'Search help',
'entity' => $entity_id,
- ),
- array(
+ ],
+ [
'_entity_access' => 'entity.view',
'_permission' => 'search content',
- ),
- array(
- 'parameters' => array(
- 'entity' => array(
+ ],
+ [
+ 'parameters' => [
+ 'entity' => [
'type' => 'entity:search_page',
- ),
- ),
- )
+ ],
+ ],
+ ]
);
}
return $routes;
diff --git a/core/modules/search/src/SearchPageAccessControlHandler.php b/core/modules/search/src/SearchPageAccessControlHandler.php
index be135bc892a..2627f51e0e4 100644
--- a/core/modules/search/src/SearchPageAccessControlHandler.php
+++ b/core/modules/search/src/SearchPageAccessControlHandler.php
@@ -20,7 +20,7 @@ class SearchPageAccessControlHandler extends EntityAccessControlHandler {
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var $entity \Drupal\search\SearchPageInterface */
- if (in_array($operation, array('delete', 'disable'))) {
+ if (in_array($operation, ['delete', 'disable'])) {
if ($entity->isDefaultSearch()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
diff --git a/core/modules/search/src/SearchPageListBuilder.php b/core/modules/search/src/SearchPageListBuilder.php
index c76a999aa91..9a8f6deb302 100644
--- a/core/modules/search/src/SearchPageListBuilder.php
+++ b/core/modules/search/src/SearchPageListBuilder.php
@@ -26,7 +26,7 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
*
* @var \Drupal\search\SearchPageInterface[]
*/
- protected $entities = array();
+ protected $entities = [];
/**
* Stores the configuration factory.
@@ -90,24 +90,24 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
* {@inheritdoc}
*/
public function buildHeader() {
- $header['label'] = array(
+ $header['label'] = [
'data' => $this->t('Label'),
- );
- $header['url'] = array(
+ ];
+ $header['url'] = [
'data' => $this->t('URL'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- );
- $header['plugin'] = array(
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ];
+ $header['plugin'] = [
'data' => $this->t('Type'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- );
- $header['status'] = array(
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ];
+ $header['status'] = [
'data' => $this->t('Status'),
- );
- $header['progress'] = array(
+ ];
+ $header['progress'] = [
'data' => $this->t('Indexing progress'),
- 'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
- );
+ 'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+ ];
return $header + parent::buildHeader();
}
@@ -120,11 +120,11 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
$row['url']['#markup'] = 'search/' . $entity->getPath();
// If the search page is active, link to it.
if ($entity->status()) {
- $row['url'] = array(
+ $row['url'] = [
'#type' => 'link',
'#title' => $row['url'],
'#url' => Url::fromRoute('search.view_' . $entity->id()),
- );
+ ];
}
$definition = $entity->getPlugin()->getPluginDefinition();
@@ -143,10 +143,10 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
if ($entity->isIndexable()) {
$status = $entity->getPlugin()->indexStatus();
- $row['progress']['#markup'] = $this->t('%num_indexed of %num_total indexed', array(
+ $row['progress']['#markup'] = $this->t('%num_indexed of %num_total indexed', [
'%num_indexed' => $status['total'] - $status['remaining'],
'%num_total' => $status['total']
- ));
+ ]);
}
else {
$row['progress']['#markup'] = $this->t('Does not use index');
@@ -178,102 +178,102 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
// will show as 99%, to indicate "almost done".
$percentage = $total > 0 ? floor(100 * $done / $total) : 100;
$percentage .= '%';
- $status = '<p><strong>' . $this->t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '</strong></p>';
- $form['status'] = array(
+ $status = '<p><strong>' . $this->t('%percentage of the site has been indexed.', ['%percentage' => $percentage]) . ' ' . $count . '</strong></p>';
+ $form['status'] = [
'#type' => 'details',
'#title' => $this->t('Indexing progress'),
'#open' => TRUE,
- '#description' => $this->t('Only items in the index will appear in search results. To build and maintain the index, a correctly configured <a href=":cron">cron maintenance task</a> is required.', array(':cron' => \Drupal::url('system.cron_settings'))),
- );
- $form['status']['status'] = array('#markup' => $status);
- $form['status']['wipe'] = array(
+ '#description' => $this->t('Only items in the index will appear in search results. To build and maintain the index, a correctly configured <a href=":cron">cron maintenance task</a> is required.', [':cron' => \Drupal::url('system.cron_settings')]),
+ ];
+ $form['status']['status'] = ['#markup' => $status];
+ $form['status']['wipe'] = [
'#type' => 'submit',
'#value' => $this->t('Re-index site'),
- '#submit' => array('::searchAdminReindexSubmit'),
- );
+ '#submit' => ['::searchAdminReindexSubmit'],
+ ];
- $items = array(10, 20, 50, 100, 200, 500);
+ $items = [10, 20, 50, 100, 200, 500];
$items = array_combine($items, $items);
// Indexing throttle:
- $form['indexing_throttle'] = array(
+ $form['indexing_throttle'] = [
'#type' => 'details',
'#title' => $this->t('Indexing throttle'),
'#open' => TRUE,
- );
- $form['indexing_throttle']['cron_limit'] = array(
+ ];
+ $form['indexing_throttle']['cron_limit'] = [
'#type' => 'select',
'#title' => $this->t('Number of items to index per cron run'),
'#default_value' => $search_settings->get('index.cron_limit'),
'#options' => $items,
- '#description' => $this->t('The maximum number of items indexed in each run of the <a href=":cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing. Some search page types may have their own setting for this.', array(':cron' => \Drupal::url('system.cron_settings'))),
- );
+ '#description' => $this->t('The maximum number of items indexed in each run of the <a href=":cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing. Some search page types may have their own setting for this.', [':cron' => \Drupal::url('system.cron_settings')]),
+ ];
// Indexing settings:
- $form['indexing_settings'] = array(
+ $form['indexing_settings'] = [
'#type' => 'details',
'#title' => $this->t('Default indexing settings'),
'#open' => TRUE,
- );
- $form['indexing_settings']['info'] = array(
+ ];
+ $form['indexing_settings']['info'] = [
'#markup' => $this->t("<p>Search pages that use an index may use the default index provided by the Search module, or they may use a different indexing mechanism. These settings are for the default index. <em>Changing these settings will cause the default search index to be rebuilt to reflect the new settings. Searching will continue to work, based on the existing index, but new content won't be indexed until all existing content has been re-indexed.</em></p><p><em>The default settings should be appropriate for the majority of sites.</em></p>")
- );
- $form['indexing_settings']['minimum_word_size'] = array(
+ ];
+ $form['indexing_settings']['minimum_word_size'] = [
'#type' => 'number',
'#title' => $this->t('Minimum word length to index'),
'#default_value' => $search_settings->get('index.minimum_word_size'),
'#min' => 1,
'#max' => 1000,
'#description' => $this->t('The minimum character length for a word to be added to the index. Searches must include a keyword of at least this length.'),
- );
- $form['indexing_settings']['overlap_cjk'] = array(
+ ];
+ $form['indexing_settings']['overlap_cjk'] = [
'#type' => 'checkbox',
'#title' => $this->t('Simple CJK handling'),
'#default_value' => $search_settings->get('index.overlap_cjk'),
'#description' => $this->t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.')
- );
+ ];
// Indexing settings:
- $form['logging'] = array(
+ $form['logging'] = [
'#type' => 'details',
'#title' => $this->t('Logging'),
'#open' => TRUE,
- );
+ ];
- $form['logging']['logging'] = array(
+ $form['logging']['logging'] = [
'#type' => 'checkbox',
'#title' => $this->t('Log searches'),
'#default_value' => $search_settings->get('logging'),
'#description' => $this->t('If checked, all searches will be logged. Uncheck to skip logging. Logging may affect performance.'),
- );
+ ];
- $form['search_pages'] = array(
+ $form['search_pages'] = [
'#type' => 'details',
'#title' => $this->t('Search pages'),
'#open' => TRUE,
- );
- $form['search_pages']['add_page'] = array(
+ ];
+ $form['search_pages']['add_page'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('container-inline'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['container-inline'],
+ ],
+ ];
// In order to prevent validation errors for the parent form, this cannot be
// required, see self::validateAddSearchPage().
- $form['search_pages']['add_page']['search_type'] = array(
+ $form['search_pages']['add_page']['search_type'] = [
'#type' => 'select',
'#title' => $this->t('Search page type'),
'#empty_option' => $this->t('- Choose page type -'),
'#options' => array_map(function ($definition) {
return $definition['title'];
}, $this->searchManager->getDefinitions()),
- );
- $form['search_pages']['add_page']['add_search_submit'] = array(
+ ];
+ $form['search_pages']['add_page']['add_search_submit'] = [
'#type' => 'submit',
'#value' => $this->t('Add search page'),
- '#validate' => array('::validateAddSearchPage'),
- '#submit' => array('::submitAddSearchPage'),
- '#limit_validation_errors' => array(array('search_type')),
- );
+ '#validate' => ['::validateAddSearchPage'],
+ '#submit' => ['::submitAddSearchPage'],
+ '#limit_validation_errors' => [['search_type']],
+ ];
// Move the listing into the search_pages element.
$form['search_pages'][$this->entitiesKey] = $form[$this->entitiesKey];
@@ -281,11 +281,11 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
unset($form[$this->entitiesKey]);
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save configuration'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -302,13 +302,13 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
unset($operations['disable'], $operations['delete']);
}
else {
- $operations['default'] = array(
+ $operations['default'] = [
'title' => $this->t('Set as default'),
'url' => Url::fromRoute('entity.search_page.set_default', [
'search_page' => $entity->id(),
]),
'weight' => 50,
- );
+ ];
}
return $operations;
@@ -369,7 +369,7 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
public function submitAddSearchPage(array &$form, FormStateInterface $form_state) {
$form_state->setRedirect(
'search.add_type',
- array('search_plugin_id' => $form_state->getValue('search_type'))
+ ['search_plugin_id' => $form_state->getValue('search_type')]
);
}
diff --git a/core/modules/search/src/SearchPageRepository.php b/core/modules/search/src/SearchPageRepository.php
index 459ea5782c8..6f4dc64d5c3 100644
--- a/core/modules/search/src/SearchPageRepository.php
+++ b/core/modules/search/src/SearchPageRepository.php
@@ -105,7 +105,7 @@ class SearchPageRepository implements SearchPageRepositoryInterface {
*/
public function sortSearchPages($search_pages) {
$entity_type = $this->storage->getEntityType();
- uasort($search_pages, array($entity_type->getClass(), 'sort'));
+ uasort($search_pages, [$entity_type->getClass(), 'sort']);
return $search_pages;
}
diff --git a/core/modules/search/src/SearchQuery.php b/core/modules/search/src/SearchQuery.php
index 77ae8ff7361..dbd0534235c 100644
--- a/core/modules/search/src/SearchQuery.php
+++ b/core/modules/search/src/SearchQuery.php
@@ -97,7 +97,7 @@ class SearchQuery extends SelectExtender {
*
* @var array
*/
- protected $keys = array('positive' => array(), 'negative' => array());
+ protected $keys = ['positive' => [], 'negative' => []];
/**
* Indicates whether the query conditions are simple or complex (LIKE).
@@ -130,7 +130,7 @@ class SearchQuery extends SelectExtender {
*
* @var array
*/
- protected $words = array();
+ protected $words = [];
/**
* Multiplier to normalize the keyword score.
@@ -165,14 +165,14 @@ class SearchQuery extends SelectExtender {
*
* @see SearchQuery::addScore()
*/
- protected $scores = array();
+ protected $scores = [];
/**
* Arguments for the score expressions.
*
* @var array
*/
- protected $scoresArguments = array();
+ protected $scoresArguments = [];
/**
* The number of 'i.relevance' occurrences in score expressions.
@@ -186,7 +186,7 @@ class SearchQuery extends SelectExtender {
*
* @var array
*/
- protected $multiply = array();
+ protected $multiply = [];
/**
* Sets the search query expression.
@@ -259,7 +259,7 @@ class SearchQuery extends SelectExtender {
$words = search_simplify($match[2]);
// Re-explode in case simplification added more words, except when
// matching a phrase.
- $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
+ $words = $phrase ? [$words] : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
// Negative matches.
if ($match[1] == '-') {
$this->keys['negative'] = array_merge($this->keys['negative'], $words);
@@ -270,7 +270,7 @@ class SearchQuery extends SelectExtender {
$last = array_pop($this->keys['positive']);
// Starting a new OR?
if (!is_array($last)) {
- $last = array($last);
+ $last = [$last];
}
$this->keys['positive'][] = $last;
$in_or = TRUE;
@@ -374,7 +374,7 @@ class SearchQuery extends SelectExtender {
}
// Return matching snippet and number of added words.
- return array($num_new_scores, $num_valid_words);
+ return [$num_new_scores, $num_valid_words];
}
/**
@@ -420,7 +420,7 @@ class SearchQuery extends SelectExtender {
// simple queries, this condition could lead to incorrectly deciding not
// to continue with the full query.
if ($this->simple) {
- $this->having('COUNT(*) >= :matches', array(':matches' => $this->matches));
+ $this->having('COUNT(*) >= :matches', [':matches' => $this->matches]);
}
// Clone the query object to calculate normalization.
@@ -499,7 +499,7 @@ class SearchQuery extends SelectExtender {
*
* @return $this
*/
- public function addScore($score, $arguments = array(), $multiply = FALSE) {
+ public function addScore($score, $arguments = [], $multiply = FALSE) {
if ($multiply) {
$i = count($this->multiply);
// Modify the score expression so it is multiplied by the multiplier,
@@ -590,7 +590,7 @@ class SearchQuery extends SelectExtender {
// Add query metadata.
$this
->addMetaData('normalize', $this->normalize)
- ->fields('i', array('type', 'sid'));
+ ->fields('i', ['type', 'sid']);
return $this->query->execute();
}
@@ -618,12 +618,12 @@ class SearchQuery extends SelectExtender {
// Remove existing fields and expressions, they are not needed for a count
// query.
$fields =& $inner->getFields();
- $fields = array();
+ $fields = [];
$expressions =& $inner->getExpressions();
- $expressions = array();
+ $expressions = [];
// Add sid as the only field and count them as a subquery.
- $count = db_select($inner->fields('i', array('sid')), NULL, array('target' => 'replica'));
+ $count = db_select($inner->fields('i', ['sid']), NULL, ['target' => 'replica']);
// Add the COUNT() expression.
$count->addExpression('COUNT(*)');
diff --git a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php b/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php
index 9bd13bdc13e..af12df61e45 100644
--- a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php
+++ b/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php
@@ -19,7 +19,7 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
// Create and log in user.
- $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes'));
+ $test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes']);
$this->drupalLogin($test_user);
// Create initial node.
@@ -44,23 +44,23 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
$this->assertNotEqual($dummy_title, $this->node->label(), "Dummy title doesn't equal node title.");
// Search for the dummy title with a GET query.
- $this->drupalGet('search/node', array('query' => array('keys' => $dummy_title)));
+ $this->drupalGet('search/node', ['query' => ['keys' => $dummy_title]]);
$this->assertNoText($this->node->label(), 'Basic page node is not found with dummy title.');
// Search for the title of the node with a GET query.
- $this->drupalGet('search/node', array('query' => array('keys' => $this->node->label())));
+ $this->drupalGet('search/node', ['query' => ['keys' => $this->node->label()]]);
$this->assertText($this->node->label(), 'Basic page node is found with GET query.');
// Search for the title of the node with a POST query.
- $edit = array('or' => $this->node->label());
+ $edit = ['or' => $this->node->label()];
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
$this->assertText($this->node->label(), 'Basic page node is found with POST query.');
// Search by node type.
- $this->drupalPostForm('search/node', array_merge($edit, array('type[page]' => 'page')), t('Advanced search'));
+ $this->drupalPostForm('search/node', array_merge($edit, ['type[page]' => 'page']), t('Advanced search'));
$this->assertText($this->node->label(), 'Basic page node is found with POST query and type:page.');
- $this->drupalPostForm('search/node', array_merge($edit, array('type[article]' => 'article')), t('Advanced search'));
+ $this->drupalPostForm('search/node', array_merge($edit, ['type[article]' => 'article']), t('Advanced search'));
$this->assertText('search yielded no results', 'Article node is not found with POST query and type:article.');
}
@@ -68,13 +68,13 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
* Tests that after submitting the advanced search form, the form is refilled.
*/
function testFormRefill() {
- $edit = array(
+ $edit = [
'keys' => 'cat',
'or' => 'dog gerbil',
'phrase' => 'pets are nice',
'negative' => 'fish snake',
'type[page]' => 'page',
- );
+ ];
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Test that the encoded query appears in the page title. Only test the
@@ -85,11 +85,11 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
// Verify that all of the form fields are filled out.
foreach ($edit as $key => $value) {
if ($key != 'type[page]') {
- $elements = $this->xpath('//input[@name=:name]', array(':name' => $key));
+ $elements = $this->xpath('//input[@name=:name]', [':name' => $key]);
$this->assertTrue(isset($elements[0]) && $elements[0]['value'] == $value, "Field $key is set to $value");
}
else {
- $elements = $this->xpath('//input[@name=:name]', array(':name' => $key));
+ $elements = $this->xpath('//input[@name=:name]', [':name' => $key]);
$this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), "Field $key is checked");
}
}
@@ -97,12 +97,12 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
// Now test by submitting the or/not part of the query in the main
// search box, and verify that the advanced form is not filled out.
// (It shouldn't be filled out unless you submit values in those fields.)
- $edit2 = array('keys' => 'cat dog OR gerbil -fish -snake');
+ $edit2 = ['keys' => 'cat dog OR gerbil -fish -snake'];
$this->drupalPostForm('search/node', $edit2, t('Advanced search'));
$this->assertText('Search for cat dog OR gerbil -fish -snake');
foreach ($edit as $key => $value) {
if ($key != 'type[page]') {
- $elements = $this->xpath('//input[@name=:name]', array(':name' => $key));
+ $elements = $this->xpath('//input[@name=:name]', [':name' => $key]);
$this->assertFalse(isset($elements[0]) && $elements[0]['value'] == $value, "Field $key is not set to $value");
}
}
diff --git a/core/modules/search/src/Tests/SearchBlockTest.php b/core/modules/search/src/Tests/SearchBlockTest.php
index 7d42a85a4b6..21afda7f05f 100644
--- a/core/modules/search/src/Tests/SearchBlockTest.php
+++ b/core/modules/search/src/Tests/SearchBlockTest.php
@@ -14,13 +14,13 @@ class SearchBlockTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('block');
+ public static $modules = ['block'];
protected function setUp() {
parent::setUp();
// Create and log in user.
- $admin_user = $this->drupalCreateUser(array('administer blocks', 'search content'));
+ $admin_user = $this->drupalCreateUser(['administer blocks', 'search content']);
$this->drupalLogin($admin_user);
}
@@ -46,7 +46,7 @@ class SearchBlockTest extends SearchTestBase {
$this->assertTrue(empty($elements), 'The search input field does not have empty name attribute.');
// Test a normal search via the block form, from the front page.
- $terms = array('keys' => 'test');
+ $terms = ['keys' => 'test'];
$this->submitGetForm('', $terms, t('Search'));
$this->assertResponse(200);
$this->assertText('Your search yielded no results');
@@ -72,12 +72,12 @@ class SearchBlockTest extends SearchTestBase {
$entity_id = $search_page_repository->getDefaultSearchPage();
$this->assertEqual(
$this->getUrl(),
- \Drupal::url('search.view_' . $entity_id, array(), array('query' => array('keys' => $terms['keys']), 'absolute' => TRUE)),
+ \Drupal::url('search.view_' . $entity_id, [], ['query' => ['keys' => $terms['keys']], 'absolute' => TRUE]),
'Submitted to correct URL.'
);
// Test an empty search via the block form, from the front page.
- $terms = array('keys' => '');
+ $terms = ['keys' => ''];
$this->submitGetForm('', $terms, t('Search'));
$this->assertResponse(200);
$this->assertText('Please enter some keywords');
@@ -86,22 +86,22 @@ class SearchBlockTest extends SearchTestBase {
// submitted empty.
$this->assertEqual(
$this->getUrl(),
- \Drupal::url('search.view_' . $entity_id, array(), array('query' => array('keys' => ''), 'absolute' => TRUE)),
+ \Drupal::url('search.view_' . $entity_id, [], ['query' => ['keys' => ''], 'absolute' => TRUE]),
'Redirected to correct URL.'
);
// Test that after entering a too-short keyword in the form, you can then
// search again with a longer keyword. First test using the block form.
- $this->submitGetForm('node', array('keys' => $this->randomMachineName(1)), t('Search'));
+ $this->submitGetForm('node', ['keys' => $this->randomMachineName(1)], t('Search'));
$this->assertText('You must include at least one keyword to match in the content', 'Keyword message is displayed when searching for short word');
$this->assertNoText(t('Please enter some keywords'), 'With short word entered, no keywords message is not displayed');
- $this->submitGetForm(NULL, array('keys' => $this->randomMachineName()), t('Search'), 'search-block-form');
+ $this->submitGetForm(NULL, ['keys' => $this->randomMachineName()], t('Search'), 'search-block-form');
$this->assertNoText('You must include at least one keyword to match in the content', 'Keyword message is not displayed when searching for long word after short word search');
// Same test again, using the search page form for the second search this
// time.
- $this->submitGetForm('node', array('keys' => $this->randomMachineName(1)), t('Search'));
- $this->drupalPostForm(NULL, array('keys' => $this->randomMachineName()), t('Search'), array(), array(), 'search-form');
+ $this->submitGetForm('node', ['keys' => $this->randomMachineName(1)], t('Search'));
+ $this->drupalPostForm(NULL, ['keys' => $this->randomMachineName()], t('Search'), [], [], 'search-form');
$this->assertNoText('You must include at least one keyword to match in the content', 'Keyword message is not displayed when searching for long word after short word search');
}
diff --git a/core/modules/search/src/Tests/SearchCommentTest.php b/core/modules/search/src/Tests/SearchCommentTest.php
index f67637ffc80..b0377b796c0 100644
--- a/core/modules/search/src/Tests/SearchCommentTest.php
+++ b/core/modules/search/src/Tests/SearchCommentTest.php
@@ -22,7 +22,7 @@ class SearchCommentTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'node', 'comment');
+ public static $modules = ['filter', 'node', 'comment'];
/**
* Test subject for comments.
@@ -55,17 +55,17 @@ class SearchCommentTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
- 'filters' => array(),
- ));
+ 'filters' => [],
+ ]);
$full_html_format->save();
// Create and log in an administrative user having access to the Full HTML
// text format.
- $permissions = array(
+ $permissions = [
'administer filters',
$full_html_format->getPermissionName(),
'administer permissions',
@@ -73,7 +73,7 @@ class SearchCommentTest extends SearchTestBase {
'post comments',
'skip comment approval',
'access comments',
- );
+ ];
$this->adminUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->adminUser);
// Add a comment field.
@@ -86,15 +86,15 @@ class SearchCommentTest extends SearchTestBase {
function testSearchResultsComment() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
// Create basic_html format that escapes all HTML.
- $basic_html_format = FilterFormat::create(array(
+ $basic_html_format = FilterFormat::create([
'format' => 'basic_html',
'name' => 'Basic HTML',
'weight' => 1,
- 'filters' => array(
- 'filter_html_escape' => array('status' => 1),
- ),
- 'roles' => array(RoleInterface::AUTHENTICATED_ID),
- ));
+ 'filters' => [
+ 'filter_html_escape' => ['status' => 1],
+ ],
+ 'roles' => [RoleInterface::AUTHENTICATED_ID],
+ ]);
$basic_html_format->save();
$comment_body = 'Test comment body';
@@ -105,17 +105,17 @@ class SearchCommentTest extends SearchTestBase {
$field->save();
// Allow anonymous users to search content.
- $edit = array(
+ $edit = [
RoleInterface::ANONYMOUS_ID . '[search content]' => 1,
RoleInterface::ANONYMOUS_ID . '[access comments]' => 1,
RoleInterface::ANONYMOUS_ID . '[post comments]' => 1,
- );
+ ];
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
// Create a node.
- $node = $this->drupalCreateNode(array('type' => 'article'));
+ $node = $this->drupalCreateNode(['type' => 'article']);
// Post a comment using 'Full HTML' text format.
- $edit_comment = array();
+ $edit_comment = [];
$edit_comment['subject[0][value]'] = 'Test comment subject';
$edit_comment['comment_body[0][value]'] = '<h1>' . $comment_body . '</h1>';
$full_html_format_id = 'full_html';
@@ -125,7 +125,7 @@ class SearchCommentTest extends SearchTestBase {
// Post a comment with an evil script tag in the comment subject and a
// script tag nearby a keyword in the comment body. Use the 'FULL HTML' text
// format so the script tag stored.
- $edit_comment2 = array();
+ $edit_comment2 = [];
$edit_comment2['subject[0][value]'] = "<script>alert('subjectkeyword');</script>";
$edit_comment2['comment_body[0][value]'] = "nearbykeyword<script>alert('somethinggeneric');</script>";
$edit_comment2['comment_body[0][format]'] = $full_html_format_id;
@@ -133,7 +133,7 @@ class SearchCommentTest extends SearchTestBase {
// Post a comment with a keyword inside an evil script tag in the comment
// body. Use the 'FULL HTML' text format so the script tag is stored.
- $edit_comment3 = array();
+ $edit_comment3 = [];
$edit_comment3['subject[0][value]'] = 'asubject';
$edit_comment3['comment_body[0][value]'] = "<script>alert('insidekeyword');</script>";
$edit_comment3['comment_body[0][format]'] = $full_html_format_id;
@@ -144,19 +144,19 @@ class SearchCommentTest extends SearchTestBase {
$this->cronRun();
// Search for the comment subject.
- $edit = array(
+ $edit = [
'keys' => "'" . $edit_comment['subject[0][value]'] . "'",
- );
+ ];
$this->drupalPostForm('search/node', $edit, t('Search'));
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$node2 = $node_storage->load($node->id());
$this->assertText($node2->label(), 'Node found in search results.');
$this->assertText($edit_comment['subject[0][value]'], 'Comment subject found in search results.');
// Search for the comment body.
- $edit = array(
+ $edit = [
'keys' => "'" . $comment_body . "'",
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Search'));
$this->assertText($node2->label(), 'Node found in search results.');
@@ -166,9 +166,9 @@ class SearchCommentTest extends SearchTestBase {
$this->assertNoEscaped($edit_comment['comment_body[0][value]'], 'HTML in comment body is not escaped.');
// Search for the evil script comment subject.
- $edit = array(
+ $edit = [
'keys' => 'subjectkeyword',
- );
+ ];
$this->drupalPostForm('search/node', $edit, t('Search'));
// Verify the evil comment subject is escaped in search results.
@@ -226,10 +226,10 @@ class SearchCommentTest extends SearchTestBase {
$field = FieldConfig::loadByName('node', 'article', 'comment');
$field->setSetting('preview', DRUPAL_OPTIONAL);
$field->save();
- $this->node = $this->drupalCreateNode(array('type' => 'article'));
+ $this->node = $this->drupalCreateNode(['type' => 'article']);
// Post a comment using 'Full HTML' text format.
- $edit_comment = array();
+ $edit_comment = [];
$edit_comment['subject[0][value]'] = $this->commentSubject;
$edit_comment['comment_body[0][value]'] = '<h1>' . $comment_body . '</h1>';
$this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit_comment, t('Save'));
@@ -277,10 +277,10 @@ class SearchCommentTest extends SearchTestBase {
* Set permissions for role.
*/
function setRolePermissions($rid, $access_comments = FALSE, $search_content = TRUE) {
- $permissions = array(
+ $permissions = [
'access comments' => $access_comments,
'search content' => $search_content,
- );
+ ];
user_role_change_permissions($rid, $permissions);
}
@@ -293,9 +293,9 @@ class SearchCommentTest extends SearchTestBase {
$this->cronRun();
// Search for the comment subject.
- $edit = array(
+ $edit = [
'keys' => "'" . $this->commentSubject . "'",
- );
+ ];
$this->drupalPostForm('search/node', $edit, t('Search'));
if ($assume_access) {
@@ -314,19 +314,19 @@ class SearchCommentTest extends SearchTestBase {
*/
function testAddNewComment() {
// Create a node with a short body.
- $settings = array(
+ $settings = [
'type' => 'article',
'title' => 'short title',
- 'body' => array(array('value' => 'short body text')),
- );
+ 'body' => [['value' => 'short body text']],
+ ];
- $user = $this->drupalCreateUser(array(
+ $user = $this->drupalCreateUser([
'search content',
'create article content',
'access content',
'post comments',
'access comments',
- ));
+ ]);
$this->drupalLogin($user);
$node = $this->drupalCreateNode($settings);
@@ -341,12 +341,12 @@ class SearchCommentTest extends SearchTestBase {
// Search for 'comment'. Should be no results.
$this->drupalLogin($user);
- $this->drupalPostForm('search/node', array('keys' => 'comment'), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => 'comment'], t('Search'));
$this->assertText(t('Your search yielded no results'));
// Search for the node title. Should be found, and 'Add new comment' should
// not be part of the search snippet.
- $this->drupalPostForm('search/node', array('keys' => 'short'), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => 'short'], t('Search'));
$this->assertText($node->label(), 'Search for keyword worked');
$this->assertNoText(t('Add new comment'));
}
diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
index 9ca87d61987..c95b6093659 100644
--- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
@@ -17,7 +17,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('block', 'search_extra_type', 'test_page_test');
+ public static $modules = ['block', 'search_extra_type', 'test_page_test'];
/**
* User who can search and administer search.
@@ -37,7 +37,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
parent::setUp();
// Log in as a user that can create and search content.
- $this->searchUser = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks', 'access site reports'));
+ $this->searchUser = $this->drupalCreateUser(['search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks', 'access site reports']);
$this->drupalLogin($this->searchUser);
// Add a single piece of content and index it.
@@ -65,38 +65,38 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Test that the settings form displays the correct count of items left to index.
$this->drupalGet('admin/config/search/pages');
- $this->assertText(t('There are @count items left to index.', array('@count' => 0)));
+ $this->assertText(t('There are @count items left to index.', ['@count' => 0]));
// Test the re-index button.
- $this->drupalPostForm('admin/config/search/pages', array(), t('Re-index site'));
+ $this->drupalPostForm('admin/config/search/pages', [], t('Re-index site'));
$this->assertText(t('Are you sure you want to re-index the site'));
- $this->drupalPostForm('admin/config/search/pages/reindex', array(), t('Re-index site'));
+ $this->drupalPostForm('admin/config/search/pages/reindex', [], t('Re-index site'));
$this->assertText(t('All search indexes will be rebuilt'));
$this->drupalGet('admin/config/search/pages');
$this->assertText(t('There is 1 item left to index.'));
// Test that the form saves with the default values.
- $this->drupalPostForm('admin/config/search/pages', array(), t('Save configuration'));
+ $this->drupalPostForm('admin/config/search/pages', [], t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'), 'Form saves with the default values.');
// Test that the form does not save with an invalid word length.
- $edit = array(
+ $edit = [
'minimum_word_size' => $this->randomMachineName(3),
- );
+ ];
$this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration'));
$this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.');
// Test logging setting. It should be off by default.
$text = $this->randomMachineName(5);
- $this->drupalPostForm('search/node', array('keys' => $text), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => $text], t('Search'));
$this->drupalGet('admin/reports/dblog');
$this->assertNoLink('Searched Content for ' . $text . '.', 'Search was not logged');
// Turn on logging.
- $edit = array('logging' => TRUE);
+ $edit = ['logging' => TRUE];
$this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration'));
$text = $this->randomMachineName(5);
- $this->drupalPostForm('search/node', array('keys' => $text), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => $text], t('Search'));
$this->drupalGet('admin/reports/dblog');
$this->assertLink('Searched Content for ' . $text . '.', 0, 'Search was logged');
@@ -113,13 +113,13 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
$this->assertTrue($this->xpath('//select[@id="edit-extra-type-settings-boost"]//option[@value="bi" and @selected="selected"]'), 'Module specific settings are picked up from the default config');
// Change extra type setting and also modify a common search setting.
- $edit = array(
+ $edit = [
'extra_type_settings[boost]' => 'ii',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save search page'));
// Ensure that the modifications took effect.
- $this->assertRaw(t('The %label search page has been updated.', array('%label' => 'Dummy search type')));
+ $this->assertRaw(t('The %label search page has been updated.', ['%label' => 'Dummy search type']));
$this->drupalGet('admin/config/search/pages/manage/dummy_search_type');
$this->assertTrue($this->xpath('//select[@id="edit-extra-type-settings-boost"]//option[@value="ii" and @selected="selected"]'), 'Module specific settings can be changed');
}
@@ -130,20 +130,20 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
function testSearchModuleDisabling() {
// Array of search plugins to test: 'keys' are the keywords to search for,
// and 'text' is the text to assert is on the results page.
- $plugin_info = array(
- 'node_search' => array(
+ $plugin_info = [
+ 'node_search' => [
'keys' => 'pizza',
'text' => $this->searchNode->label(),
- ),
- 'user_search' => array(
+ ],
+ 'user_search' => [
'keys' => $this->searchUser->getUsername(),
'text' => $this->searchUser->getEmail(),
- ),
- 'dummy_search_type' => array(
+ ],
+ 'dummy_search_type' => [
'keys' => 'foo',
'text' => 'Dummy search snippet to display',
- ),
- );
+ ],
+ ];
$plugins = array_keys($plugin_info);
/** @var $entities \Drupal\search\SearchPageInterface[] */
$entities = SearchPage::loadMultiple();
@@ -159,7 +159,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Run a search from the correct search URL.
$info = $plugin_info[$entity_id];
- $this->drupalGet('search/' . $entity->getPath(), array('query' => array('keys' => $info['keys'])));
+ $this->drupalGet('search/' . $entity->getPath(), ['query' => ['keys' => $info['keys']]]);
$this->assertResponse(200);
$this->assertNoText('no results', $entity->label() . ' search found results');
$this->assertText($info['text'], 'Correct search text found');
@@ -174,10 +174,10 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Run a search from the search block on the node page. Verify you get
// to this plugin's search results page.
- $terms = array('keys' => $info['keys']);
+ $terms = ['keys' => $info['keys']];
$this->submitGetForm('node', $terms, t('Search'));
$current = $this->getURL();
- $expected = \Drupal::url('search.view_' . $entity->id(), array(), array('query' => array('keys' => $info['keys']), 'absolute' => TRUE));
+ $expected = \Drupal::url('search.view_' . $entity->id(), [], ['query' => ['keys' => $info['keys']], 'absolute' => TRUE]);
$this->assertEqual( $current, $expected, 'Block redirected to right search page');
// Try an invalid search path, which should 404.
@@ -195,16 +195,16 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Set the node search as default.
$this->drupalGet('admin/config/search/pages/manage/node_search/set-default');
- $paths = array(
- array('path' => 'search/node', 'options' => array('query' => array('keys' => 'pizza'))),
- array('path' => 'search/node', 'options' => array()),
- );
+ $paths = [
+ ['path' => 'search/node', 'options' => ['query' => ['keys' => 'pizza']]],
+ ['path' => 'search/node', 'options' => []],
+ ];
foreach ($paths as $item) {
$this->drupalGet($item['path'], $item['options']);
foreach ($plugins as $entity_id) {
$label = $entities[$entity_id]->label();
- $this->assertText($label, format_string('%label search tab is shown', array('%label' => $label)));
+ $this->assertText($label, format_string('%label search tab is shown', ['%label' => $label]));
}
}
}
@@ -214,7 +214,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
*/
public function testDefaultSearchPageOrdering() {
$this->drupalGet('search');
- $elements = $this->xpath('//*[contains(@class, :class)]//a', array(':class' => 'tabs primary'));
+ $elements = $this->xpath('//*[contains(@class, :class)]//a', [':class' => 'tabs primary']);
$this->assertIdentical((string) $elements[0]['href'], \Drupal::url('search.view_node_search'));
$this->assertIdentical((string) $elements[1]['href'], \Drupal::url('search.view_dummy_search_type'));
$this->assertIdentical((string) $elements[2]['href'], \Drupal::url('search.view_user_search'));
@@ -235,24 +235,24 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
$this->assertText(t('No search pages have been configured.'));
// Add a search page.
- $edit = array();
+ $edit = [];
$edit['search_type'] = 'search_extra_type_search';
$this->drupalPostForm(NULL, $edit, t('Add search page'));
$this->assertTitle('Add new search page | Drupal');
- $first = array();
+ $first = [];
$first['label'] = $this->randomString();
$first_id = $first['id'] = strtolower($this->randomMachineName(8));
$first['path'] = strtolower($this->randomMachineName(8));
$this->drupalPostForm(NULL, $first, t('Save'));
$this->assertDefaultSearch($first_id, 'The default page matches the only search page.');
- $this->assertRaw(t('The %label search page has been added.', array('%label' => $first['label'])));
+ $this->assertRaw(t('The %label search page has been added.', ['%label' => $first['label']]));
// Attempt to add a search page with an existing path.
- $edit = array();
+ $edit = [];
$edit['search_type'] = 'search_extra_type_search';
$this->drupalPostForm(NULL, $edit, t('Add search page'));
- $edit = array();
+ $edit = [];
$edit['label'] = $this->randomString();
$edit['id'] = strtolower($this->randomMachineName(8));
$edit['path'] = $first['path'];
@@ -260,7 +260,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
$this->assertText(t('The search page path must be unique.'));
// Add a second search page.
- $second = array();
+ $second = [];
$second['label'] = $this->randomString();
$second_id = $second['id'] = strtolower($this->randomMachineName(8));
$second['path'] = strtolower($this->randomMachineName(8));
@@ -269,18 +269,18 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Ensure both search pages have their tabs displayed.
$this->drupalGet('search');
- $elements = $this->xpath('//*[contains(@class, :class)]//a', array(':class' => 'tabs primary'));
+ $elements = $this->xpath('//*[contains(@class, :class)]//a', [':class' => 'tabs primary']);
$this->assertIdentical((string) $elements[0]['href'], Url::fromRoute('search.view_' . $first_id)->toString());
$this->assertIdentical((string) $elements[1]['href'], Url::fromRoute('search.view_' . $second_id)->toString());
// Switch the weight of the search pages and check the order of the tabs.
- $edit = array(
+ $edit = [
'entities[' . $first_id . '][weight]' => 10,
'entities[' . $second_id . '][weight]' => -10,
- );
+ ];
$this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration'));
$this->drupalGet('search');
- $elements = $this->xpath('//*[contains(@class, :class)]//a', array(':class' => 'tabs primary'));
+ $elements = $this->xpath('//*[contains(@class, :class)]//a', [':class' => 'tabs primary']);
$this->assertIdentical((string) $elements[0]['href'], Url::fromRoute('search.view_' . $second_id)->toString());
$this->assertIdentical((string) $elements[1]['href'], Url::fromRoute('search.view_' . $first_id)->toString());
@@ -291,7 +291,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Change the default search page.
$this->clickLink(t('Set as default'));
- $this->assertRaw(t('The default search page is now %label. Be sure to check the ordering of your search pages.', array('%label' => $second['label'])));
+ $this->assertRaw(t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $second['label']]));
$this->verifySearchPageOperations($first_id, TRUE, TRUE, TRUE, FALSE);
$this->verifySearchPageOperations($second_id, TRUE, FALSE, FALSE, FALSE);
@@ -310,9 +310,9 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Test deleting.
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete the search page %label?', array('%label' => $first['label'])));
- $this->drupalPostForm(NULL, array(), t('Delete'));
- $this->assertRaw(t('The search page %label has been deleted.', array('%label' => $first['label'])));
+ $this->assertRaw(t('Are you sure you want to delete the search page %label?', ['%label' => $first['label']]));
+ $this->drupalPostForm(NULL, [], t('Delete'));
+ $this->assertRaw(t('The search page %label has been deleted.', ['%label' => $first['label']]));
$this->verifySearchPageOperations($first_id, FALSE, FALSE, FALSE, FALSE);
}
diff --git a/core/modules/search/src/Tests/SearchEmbedFormTest.php b/core/modules/search/src/Tests/SearchEmbedFormTest.php
index 22da9b611e6..df5fdfc6c55 100644
--- a/core/modules/search/src/Tests/SearchEmbedFormTest.php
+++ b/core/modules/search/src/Tests/SearchEmbedFormTest.php
@@ -14,7 +14,7 @@ class SearchEmbedFormTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('search_embedded_form');
+ public static $modules = ['search_embedded_form'];
/**
* Node used for testing.
@@ -34,7 +34,7 @@ class SearchEmbedFormTest extends SearchTestBase {
parent::setUp();
// Create a user and a node, and update the search index.
- $test_user = $this->drupalCreateUser(array('access content', 'search content', 'administer nodes'));
+ $test_user = $this->drupalCreateUser(['access content', 'search content', 'administer nodes']);
$this->drupalLogin($test_user);
$this->node = $this->drupalCreateNode();
@@ -53,7 +53,7 @@ class SearchEmbedFormTest extends SearchTestBase {
function testEmbeddedForm() {
// First verify we can submit the form from the module's page.
$this->drupalPostForm('search_embedded_form',
- array('name' => 'John'),
+ ['name' => 'John'],
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
@@ -61,10 +61,10 @@ class SearchEmbedFormTest extends SearchTestBase {
$this->submitCount = $count;
// Now verify that we can see and submit the form from the search results.
- $this->drupalGet('search/node', array('query' => array('keys' => $this->node->label())));
+ $this->drupalGet('search/node', ['query' => ['keys' => $this->node->label()]]);
$this->assertText(t('Your name'), 'Form is visible');
$this->drupalPostForm(NULL,
- array('name' => 'John'),
+ ['name' => 'John'],
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
@@ -74,7 +74,7 @@ class SearchEmbedFormTest extends SearchTestBase {
// Now verify that if we submit the search form, it doesn't count as
// our form being submitted.
$this->drupalPostForm('search',
- array('keys' => 'foo'),
+ ['keys' => 'foo'],
t('Search'));
$this->assertNoText(t('Test form was submitted'), 'Form message does not appear');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
diff --git a/core/modules/search/src/Tests/SearchLanguageTest.php b/core/modules/search/src/Tests/SearchLanguageTest.php
index cdd0bd4c6ca..25f269d870a 100644
--- a/core/modules/search/src/Tests/SearchLanguageTest.php
+++ b/core/modules/search/src/Tests/SearchLanguageTest.php
@@ -17,7 +17,7 @@ class SearchLanguageTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Array of nodes available to search.
@@ -30,7 +30,7 @@ class SearchLanguageTest extends SearchTestBase {
parent::setUp();
// Create and log in user.
- $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration'));
+ $test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration']);
$this->drupalLogin($test_user);
// Add a new language.
@@ -45,38 +45,38 @@ class SearchLanguageTest extends SearchTestBase {
// Create a few page nodes with multilingual body values.
$default_format = filter_default_format();
- $nodes = array(
- array(
+ $nodes = [
+ [
'title' => 'First node en',
'type' => 'page',
- 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)),
+ 'body' => [['value' => $this->randomMachineName(32), 'format' => $default_format]],
'langcode' => 'en',
- ),
- array(
+ ],
+ [
'title' => 'Second node this is the Spanish title',
'type' => 'page',
- 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)),
+ 'body' => [['value' => $this->randomMachineName(32), 'format' => $default_format]],
'langcode' => 'es',
- ),
- array(
+ ],
+ [
'title' => 'Third node en',
'type' => 'page',
- 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)),
+ 'body' => [['value' => $this->randomMachineName(32), 'format' => $default_format]],
'langcode' => 'en',
- ),
- );
+ ],
+ ];
$this->searchableNodes = [];
foreach ($nodes as $setting) {
$this->searchableNodes[] = $this->drupalCreateNode($setting);
}
// Add English translation to the second node.
- $translation = $this->searchableNodes[1]->addTranslation('en', array('title' => 'Second node en'));
+ $translation = $this->searchableNodes[1]->addTranslation('en', ['title' => 'Second node en']);
$translation->body->value = $this->randomMachineName(32);
$this->searchableNodes[1]->save();
// Add Spanish translation to the third node.
- $translation = $this->searchableNodes[2]->addTranslation('es', array('title' => 'Third node es'));
+ $translation = $this->searchableNodes[2]->addTranslation('es', ['title' => 'Third node es']);
$translation->body->value = $this->randomMachineName(32);
$this->searchableNodes[2]->save();
@@ -88,7 +88,7 @@ class SearchLanguageTest extends SearchTestBase {
function testLanguages() {
// Add predefined language.
- $edit = array('predefined_langcode' => 'fr');
+ $edit = ['predefined_langcode' => 'fr'];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->assertText('French', 'Language added successfully.');
@@ -99,11 +99,11 @@ class SearchLanguageTest extends SearchTestBase {
$this->assertText(t('French'), 'French is a possible choice.');
// Ensure selecting no language does not make the query different.
- $this->drupalPostForm('search/node', array(), t('Advanced search'));
+ $this->drupalPostForm('search/node', [], t('Advanced search'));
$this->assertUrl(\Drupal::url('search.view_node_search', [], ['query' => ['keys' => ''], 'absolute' => TRUE]), [], 'Correct page redirection, no language filtering.');
// Pick French and ensure it is selected.
- $edit = array('language[fr]' => TRUE);
+ $edit = ['language[fr]' => TRUE];
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Get the redirected URL.
$url = $this->getUrl();
@@ -112,7 +112,7 @@ class SearchLanguageTest extends SearchTestBase {
$this->assertTrue(strpos($query_string, '=language:fr') !== FALSE, 'Language filter language:fr add to the query string.');
// Search for keyword node and language filter as Spanish.
- $edit = array('keys' => 'node', 'language[es]' => TRUE);
+ $edit = ['keys' => 'node', 'language[es]' => TRUE];
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Check for Spanish results.
$this->assertLink('Second node this is the Spanish title', 0, 'Second node Spanish title found in search results');
@@ -126,12 +126,12 @@ class SearchLanguageTest extends SearchTestBase {
$path = 'admin/config/regional/language';
$this->drupalGet($path);
$this->assertFieldChecked('edit-site-default-language-en', 'Default language updated.');
- $edit = array(
+ $edit = [
'site_default_language' => 'fr',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-site-default-language-en', 'Default language updated.');
- $this->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
}
}
diff --git a/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php b/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php
index e73ca8623ac..0f053d24bc8 100644
--- a/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php
+++ b/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php
@@ -14,7 +14,7 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array();
+ public static $modules = [];
/**
* A user with permission to access and search content.
@@ -27,7 +27,7 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
parent::setUp();
// Create a test user and log in.
- $this->testUser = $this->drupalCreateUser(array('access content', 'search content'));
+ $this->testUser = $this->drupalCreateUser(['access content', 'search content']);
$this->drupalLogin($this->testUser);
}
@@ -36,10 +36,10 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
*/
function testSearchIndexUpdateOnNodeChange() {
// Create a node.
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'title' => 'Someone who says Ni!',
- 'body' => array(array('value' => "We are the knights who say Ni!")),
- 'type' => 'page'));
+ 'body' => [['value' => "We are the knights who say Ni!"]],
+ 'type' => 'page']);
$node_search_plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
// Update the search index.
@@ -47,7 +47,7 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
search_update_totals();
// Search the node to verify it appears in search results
- $edit = array('keys' => 'knights');
+ $edit = ['keys' => 'knights'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText($node->label());
@@ -60,7 +60,7 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
search_update_totals();
// Search again to verify the new text appears in test results.
- $edit = array('keys' => 'shrubbery');
+ $edit = ['keys' => 'shrubbery'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText($node->label());
}
@@ -70,10 +70,10 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
*/
function testSearchIndexUpdateOnNodeDeletion() {
// Create a node.
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'title' => 'No dragons here',
- 'body' => array(array('value' => 'Again: No dragons here')),
- 'type' => 'page'));
+ 'body' => [['value' => 'Again: No dragons here']],
+ 'type' => 'page']);
$node_search_plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
// Update the search index.
@@ -81,12 +81,12 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
search_update_totals();
// Search the node to verify it appears in search results
- $edit = array('keys' => 'dragons');
+ $edit = ['keys' => 'dragons'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText($node->label());
// Get the node info from the search index tables.
- $search_index_dataset = db_query("SELECT sid FROM {search_index} WHERE type = 'node_search' AND word = :word", array(':word' => 'dragons'))
+ $search_index_dataset = db_query("SELECT sid FROM {search_index} WHERE type = 'node_search' AND word = :word", [':word' => 'dragons'])
->fetchField();
$this->assertNotEqual($search_index_dataset, FALSE, t('Node info found on the search_index'));
@@ -94,7 +94,7 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
$node->delete();
// Check if the node info is gone from the search table.
- $search_index_dataset = db_query("SELECT sid FROM {search_index} WHERE type = 'node_search' AND word = :word", array(':word' => 'dragons'))
+ $search_index_dataset = db_query("SELECT sid FROM {search_index} WHERE type = 'node_search' AND word = :word", [':word' => 'dragons'])
->fetchField();
$this->assertFalse($search_index_dataset, t('Node info successfully removed from search_index'));
diff --git a/core/modules/search/src/Tests/SearchNumberMatchingTest.php b/core/modules/search/src/Tests/SearchNumberMatchingTest.php
index a6ad0572868..de627e80f04 100644
--- a/core/modules/search/src/Tests/SearchNumberMatchingTest.php
+++ b/core/modules/search/src/Tests/SearchNumberMatchingTest.php
@@ -27,7 +27,7 @@ class SearchNumberMatchingTest extends SearchTestBase {
*
* @var string[]
*/
- protected $numbers = array(
+ protected $numbers = [
'123456789',
'12/34/56789',
'12.3456789',
@@ -35,7 +35,7 @@ class SearchNumberMatchingTest extends SearchTestBase {
'123,456,789',
'-123456789',
'0123456789',
- );
+ ];
/**
* An array of nodes created for testing purposes.
@@ -47,15 +47,15 @@ class SearchNumberMatchingTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
- $this->testUser = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports'));
+ $this->testUser = $this->drupalCreateUser(['search content', 'access content', 'administer nodes', 'access site reports']);
$this->drupalLogin($this->testUser);
foreach ($this->numbers as $num) {
- $info = array(
- 'body' => array(array('value' => $num)),
+ $info = [
+ 'body' => [['value' => $num]],
'type' => 'page',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- );
+ ];
$this->nodes[] = $this->drupalCreateNode($info);
}
@@ -75,9 +75,9 @@ class SearchNumberMatchingTest extends SearchTestBase {
// Verify that the node title does not appear on the search page
// with a dummy search.
$this->drupalPostForm('search/node',
- array('keys' => 'foo'),
+ ['keys' => 'foo'],
t('Search'));
- $this->assertNoText($node->label(), format_string('%number: node title not shown in dummy search', array('%number' => $i)));
+ $this->assertNoText($node->label(), format_string('%number: node title not shown in dummy search', ['%number' => $i]));
// Now verify that we can find node i by searching for any of the
// numbers.
@@ -88,9 +88,9 @@ class SearchNumberMatchingTest extends SearchTestBase {
$number = ltrim($number, '-');
$this->drupalPostForm('search/node',
- array('keys' => $number),
+ ['keys' => $number],
t('Search'));
- $this->assertText($node->label(), format_string('%i: node title shown (search found the node) in search for number %number', array('%i' => $i, '%number' => $number)));
+ $this->assertText($node->label(), format_string('%i: node title shown (search found the node) in search for number %number', ['%i' => $i, '%number' => $number]));
}
}
diff --git a/core/modules/search/src/Tests/SearchNumbersTest.php b/core/modules/search/src/Tests/SearchNumbersTest.php
index 30d3906f813..7034c5e7e3d 100644
--- a/core/modules/search/src/Tests/SearchNumbersTest.php
+++ b/core/modules/search/src/Tests/SearchNumbersTest.php
@@ -26,7 +26,7 @@ class SearchNumbersTest extends SearchTestBase {
*
* @var string[]
*/
- protected $numbers = array(
+ protected $numbers = [
'ISBN' => '978-0446365383',
'UPC' => '036000 291452',
'EAN bar code' => '5901234123457',
@@ -41,7 +41,7 @@ class SearchNumbersTest extends SearchTestBase {
'over fifty characters' => '666666666666666666666666666666666666666666666666666666666666',
'date' => '01/02/2009',
'commas' => '987,654,321',
- );
+ ];
/**
* An array of nodes created for testing purposes.
@@ -53,16 +53,16 @@ class SearchNumbersTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
- $this->testUser = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports'));
+ $this->testUser = $this->drupalCreateUser(['search content', 'access content', 'administer nodes', 'access site reports']);
$this->drupalLogin($this->testUser);
foreach ($this->numbers as $doc => $num) {
- $info = array(
- 'body' => array(array('value' => $num)),
+ $info = [
+ 'body' => [['value' => $num]],
'type' => 'page',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'title' => $doc . ' number',
- );
+ ];
$this->nodes[$doc] = $this->drupalCreateNode($info);
}
@@ -88,16 +88,16 @@ class SearchNumbersTest extends SearchTestBase {
// Verify that the node title does not appear on the search page
// with a dummy search.
$this->drupalPostForm('search/node',
- array('keys' => 'foo'),
+ ['keys' => 'foo'],
t('Search'));
$this->assertNoText($node->label(), $type . ': node title not shown in dummy search');
// Verify that the node title does appear as a link on the search page
// when searching for the number.
$this->drupalPostForm('search/node',
- array('keys' => $number),
+ ['keys' => $number],
t('Search'));
- $this->assertText($node->label(), format_string('%type: node title shown (search found the node) in search for number %number.', array('%type' => $type, '%number' => $number)));
+ $this->assertText($node->label(), format_string('%type: node title shown (search found the node) in search for number %number.', ['%type' => $type, '%number' => $number]));
}
}
diff --git a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
index 667b2135f86..5eafa27f99b 100644
--- a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
+++ b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
@@ -37,7 +37,7 @@ class SearchPageCacheTagsTest extends SearchTestBase {
parent::setUp();
// Create user.
- $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles'));
+ $this->searchingUser = $this->drupalCreateUser(['search content', 'access user profiles']);
// Create a node and update the search index.
$this->node = $this->drupalCreateNode(['title' => 'bike shed shop']);
@@ -60,7 +60,7 @@ class SearchPageCacheTagsTest extends SearchTestBase {
$this->assertCacheTag('node_list');
// Node search results.
- $edit = array();
+ $edit = [];
$edit['keys'] = 'bike shed';
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText('bike shed shop');
@@ -182,7 +182,7 @@ class SearchPageCacheTagsTest extends SearchTestBase {
// Node search results for shop, should return node:1 (bike shed shop) and
// node:2 (Llama shop). The related authors cache tags should be visible as
// well.
- $edit = array();
+ $edit = [];
$edit['keys'] = 'shop';
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText('bike shed shop');
@@ -200,7 +200,7 @@ class SearchPageCacheTagsTest extends SearchTestBase {
// Only get the new node in the search results, should result in node:1,
// node:2 and user:3 as cache tags even though only node:1 is shown. This is
// because node:2 is reference in node:1 as an entity reference.
- $edit = array();
+ $edit = [];
$edit['keys'] = 'Llama';
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText('Llama shop');
diff --git a/core/modules/search/src/Tests/SearchPageTextTest.php b/core/modules/search/src/Tests/SearchPageTextTest.php
index db33d85c0b3..9815e307ce9 100644
--- a/core/modules/search/src/Tests/SearchPageTextTest.php
+++ b/core/modules/search/src/Tests/SearchPageTextTest.php
@@ -32,7 +32,7 @@ class SearchPageTextTest extends SearchTestBase {
parent::setUp();
// Create user.
- $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles', 'use advanced search'));
+ $this->searchingUser = $this->drupalCreateUser(['search content', 'access user profiles', 'use advanced search']);
$this->drupalPlaceBlock('local_tasks_block');
$this->drupalPlaceBlock('page_title_block');
}
@@ -43,7 +43,7 @@ class SearchPageTextTest extends SearchTestBase {
* This is a regression test for https://www.drupal.org/node/2338081
*/
function testSearchLabelXSS() {
- $this->drupalLogin($this->drupalCreateUser(array('administer search')));
+ $this->drupalLogin($this->drupalCreateUser(['administer search']));
$keys['label'] = '<script>alert("Dont Panic");</script>';
$this->drupalPostForm('admin/config/search/pages/manage/node_search', $keys, t('Save search page'));
@@ -63,14 +63,14 @@ class SearchPageTextTest extends SearchTestBase {
$this->assertText(t('Search'));
$this->assertTitle(t('Search') . ' | Drupal', 'Search page title is correct');
- $edit = array();
+ $edit = [];
$search_terms = 'bike shed ' . $this->randomMachineName();
$edit['keys'] = $search_terms;
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText('search yielded no results');
$this->assertText(t('Search'));
$title_source = 'Search for @keywords | Drupal';
- $this->assertTitle(t($title_source, array('@keywords' => Unicode::truncate($search_terms, 60, TRUE, TRUE))), 'Search page title is correct');
+ $this->assertTitle(t($title_source, ['@keywords' => Unicode::truncate($search_terms, 60, TRUE, TRUE)]), 'Search page title is correct');
$this->assertNoText('Node', 'Erroneous tab and breadcrumb text is not present');
$this->assertNoText(t('Node'), 'Erroneous translated tab and breadcrumb text is not present');
$this->assertText(t('Content'), 'Tab and breadcrumb text is present');
@@ -80,23 +80,23 @@ class SearchPageTextTest extends SearchTestBase {
$this->assertText('Use upper-case OR to get more results', 'Correct text is on content search help page');
// Search for a longer text, and see that it is in the title, truncated.
- $edit = array();
+ $edit = [];
$search_terms = 'Every word is like an unnecessary stain on silence and nothingness.';
$edit['keys'] = $search_terms;
$this->drupalPostForm('search/node', $edit, t('Search'));
- $this->assertTitle(t($title_source, array('@keywords' => 'Every word is like an unnecessary stain on silence and…')), 'Search page title is correct');
+ $this->assertTitle(t($title_source, ['@keywords' => 'Every word is like an unnecessary stain on silence and…']), 'Search page title is correct');
// Search for a string with a lot of special characters.
$search_terms = 'Hear nothing > "see nothing" `feel' . " '1982.";
$edit['keys'] = $search_terms;
$this->drupalPostForm('search/node', $edit, t('Search'));
$actual_title = (string) current($this->xpath('//title'));
- $this->assertEqual($actual_title, Html::decodeEntities(t($title_source, array('@keywords' => Unicode::truncate($search_terms, 60, TRUE, TRUE)))), 'Search page title is correct');
+ $this->assertEqual($actual_title, Html::decodeEntities(t($title_source, ['@keywords' => Unicode::truncate($search_terms, 60, TRUE, TRUE)])), 'Search page title is correct');
$edit['keys'] = $this->searchingUser->getUsername();
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText(t('Search'));
- $this->assertTitle(t($title_source, array('@keywords' => Unicode::truncate($this->searchingUser->getUsername(), 60, TRUE, TRUE))));
+ $this->assertTitle(t($title_source, ['@keywords' => Unicode::truncate($this->searchingUser->getUsername(), 60, TRUE, TRUE)]));
$this->clickLink('Search help');
$this->assertText('Search help', 'Correct title is on search help page');
@@ -105,14 +105,14 @@ class SearchPageTextTest extends SearchTestBase {
// Test that search keywords containing slashes are correctly loaded
// from the GET params and displayed in the search form.
$arg = $this->randomMachineName() . '/' . $this->randomMachineName();
- $this->drupalGet('search/node', array('query' => array('keys' => $arg)));
+ $this->drupalGet('search/node', ['query' => ['keys' => $arg]]);
$input = $this->xpath("//input[@id='edit-keys' and @value='{$arg}']");
$this->assertFalse(empty($input), 'Search keys with a / are correctly set as the default value in the search box.');
// Test a search input exceeding the limit of AND/OR combinations to test
// the Denial-of-Service protection.
$limit = $this->config('search.settings')->get('and_or_limit');
- $keys = array();
+ $keys = [];
for ($i = 0; $i < $limit + 1; $i++) {
// Use a key of 4 characters to ensure we never generate 'AND' or 'OR'.
$keys[] = $this->randomMachineName(4);
@@ -122,40 +122,40 @@ class SearchPageTextTest extends SearchTestBase {
}
$edit['keys'] = implode(' ', $keys);
$this->drupalPostForm('search/node', $edit, t('Search'));
- $this->assertRaw(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => $limit)));
+ $this->assertRaw(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', ['@count' => $limit]));
// Test that a search on Node or User with no keywords entered generates
// the "Please enter some keywords" message.
- $this->drupalPostForm('search/node', array(), t('Search'));
+ $this->drupalPostForm('search/node', [], t('Search'));
$this->assertText(t('Please enter some keywords'), 'With no keywords entered, message is displayed on node page');
- $this->drupalPostForm('search/user', array(), t('Search'));
+ $this->drupalPostForm('search/user', [], t('Search'));
$this->assertText(t('Please enter some keywords'), 'With no keywords entered, message is displayed on user page');
// Make sure the "Please enter some keywords" message is NOT displayed if
// you use "or" words or phrases in Advanced Search.
- $this->drupalPostForm('search/node', array('or' => $this->randomMachineName() . ' ' . $this->randomMachineName()), t('Advanced search'));
+ $this->drupalPostForm('search/node', ['or' => $this->randomMachineName() . ' ' . $this->randomMachineName()], t('Advanced search'));
$this->assertNoText(t('Please enter some keywords'), 'With advanced OR keywords entered, no keywords message is not displayed on node page');
- $this->drupalPostForm('search/node', array('phrase' => '"' . $this->randomMachineName() . '" "' . $this->randomMachineName() . '"'), t('Advanced search'));
+ $this->drupalPostForm('search/node', ['phrase' => '"' . $this->randomMachineName() . '" "' . $this->randomMachineName() . '"'], t('Advanced search'));
$this->assertNoText(t('Please enter some keywords'), 'With advanced phrase entered, no keywords message is not displayed on node page');
// Verify that if you search for a too-short keyword, you get the right
// message, and that if after that you search for a longer keyword, you
// do not still see the message.
- $this->drupalPostForm('search/node', array('keys' => $this->randomMachineName(1)), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => $this->randomMachineName(1)], t('Search'));
$this->assertText('You must include at least one keyword', 'Keyword message is displayed when searching for short word');
$this->assertNoText(t('Please enter some keywords'), 'With short word entered, no keywords message is not displayed');
- $this->drupalPostForm(NULL, array('keys' => $this->randomMachineName()), t('Search'));
+ $this->drupalPostForm(NULL, ['keys' => $this->randomMachineName()], t('Search'));
$this->assertNoText('You must include at least one keyword', 'Keyword message is not displayed when searching for long word after short word search');
// Test that if you search for a URL with .. in it, you still end up at
// the search page. See issue https://www.drupal.org/node/890058.
- $this->drupalPostForm('search/node', array('keys' => '../../admin'), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => '../../admin'], t('Search'));
$this->assertResponse(200, 'Searching for ../../admin with non-admin user does not lead to a 403 error');
$this->assertText('no results', 'Searching for ../../admin with non-admin user gives you a no search results page');
// Test that if you search for a URL starting with "./", you still end up
// at the search page. See issue https://www.drupal.org/node/1421560.
- $this->drupalPostForm('search/node', array('keys' => '.something'), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => '.something'], t('Search'));
$this->assertResponse(200, 'Searching for .something does not lead to a 403 error');
$this->assertText('no results', 'Searching for .something gives you a no search results page');
}
diff --git a/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php b/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php
index 38cb3508e0e..322ba228898 100644
--- a/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php
+++ b/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php
@@ -14,7 +14,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('search_langcode_test');
+ public static $modules = ['search_langcode_test'];
/**
* Test node for searching.
@@ -26,12 +26,12 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array(
+ $web_user = $this->drupalCreateUser([
'create page content',
'edit own page content',
'search content',
'use advanced search',
- ));
+ ]);
$this->drupalLogin($web_user);
}
@@ -40,7 +40,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
*/
function testPreprocessLangcode() {
// Create a node.
- $this->node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'en'));
+ $this->node = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'en']);
// First update the index. This does the initial processing.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
@@ -53,7 +53,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
// Search for the additional text that is added by the preprocess
// function. If you search for text that is in the node, preprocess is
// not invoked on the node during the search excerpt generation.
- $edit = array('or' => 'Additional text');
+ $edit = ['or' => 'Additional text'];
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Checks if the langcode message has been set by hook_search_preprocess().
@@ -65,11 +65,11 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
*/
function testPreprocessStemming() {
// Create a node.
- $this->node = $this->drupalCreateNode(array(
+ $this->node = $this->drupalCreateNode([
'title' => 'we are testing',
- 'body' => array(array()),
+ 'body' => [[]],
'langcode' => 'en',
- ));
+ ]);
// First update the index. This does the initial processing.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
@@ -80,7 +80,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
search_update_totals();
// Search for the title of the node with a POST query.
- $edit = array('or' => 'testing');
+ $edit = ['or' => 'testing'];
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Check if the node has been found.
@@ -88,7 +88,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
$this->assertText('we are testing');
// Search for the same node using a different query.
- $edit = array('or' => 'test');
+ $edit = ['or' => 'test'];
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Check if the node has been found.
diff --git a/core/modules/search/src/Tests/SearchQueryAlterTest.php b/core/modules/search/src/Tests/SearchQueryAlterTest.php
index 0cb473f5f0b..133b0f3d7ed 100644
--- a/core/modules/search/src/Tests/SearchQueryAlterTest.php
+++ b/core/modules/search/src/Tests/SearchQueryAlterTest.php
@@ -13,22 +13,22 @@ class SearchQueryAlterTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('search_query_alter');
+ public static $modules = ['search_query_alter'];
/**
* Tests that the query alter works.
*/
function testQueryAlter() {
// Log in with sufficient privileges.
- $this->drupalLogin($this->drupalCreateUser(array('create page content', 'search content')));
+ $this->drupalLogin($this->drupalCreateUser(['create page content', 'search content']));
// Create a node and an article with the same keyword. The query alter
// test module will alter the query so only articles should be returned.
- $data = array(
+ $data = [
'type' => 'page',
'title' => 'test page',
- 'body' => array(array('value' => 'pizza')),
- );
+ 'body' => [['value' => 'pizza']],
+ ];
$this->drupalCreateNode($data);
$data['type'] = 'article';
@@ -40,7 +40,7 @@ class SearchQueryAlterTest extends SearchTestBase {
search_update_totals();
// Search for the body keyword 'pizza'.
- $this->drupalPostForm('search/node', array('keys' => 'pizza'), t('Search'));
+ $this->drupalPostForm('search/node', ['keys' => 'pizza'], t('Search'));
// The article should be there but not the page.
$this->assertText('article', 'Article is in search results');
$this->assertNoText('page', 'Page is not in search results');
diff --git a/core/modules/search/src/Tests/SearchRankingTest.php b/core/modules/search/src/Tests/SearchRankingTest.php
index 2045233e16d..28241d2af27 100644
--- a/core/modules/search/src/Tests/SearchRankingTest.php
+++ b/core/modules/search/src/Tests/SearchRankingTest.php
@@ -29,7 +29,7 @@ class SearchRankingTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('statistics', 'comment');
+ public static $modules = ['statistics', 'comment'];
protected function setUp() {
parent::setUp();
@@ -38,7 +38,7 @@ class SearchRankingTest extends SearchTestBase {
$this->nodeSearch = SearchPage::load('node_search');
// Log in with sufficient privileges.
- $this->drupalLogin($this->drupalCreateUser(array('post comments', 'skip comment approval', 'create page content', 'administer search')));
+ $this->drupalLogin($this->drupalCreateUser(['post comments', 'skip comment approval', 'create page content', 'administer search']));
}
public function testRankings() {
@@ -46,24 +46,24 @@ class SearchRankingTest extends SearchTestBase {
$this->addDefaultCommentField('node', 'page');
// Build a list of the rankings to test.
- $node_ranks = array('sticky', 'promote', 'relevance', 'recent', 'comments', 'views');
+ $node_ranks = ['sticky', 'promote', 'relevance', 'recent', 'comments', 'views'];
// Create nodes for testing.
- $nodes = array();
+ $nodes = [];
foreach ($node_ranks as $node_rank) {
- $settings = array(
+ $settings = [
'type' => 'page',
- 'comment' => array(array(
+ 'comment' => [[
'status' => CommentItemInterface::HIDDEN,
- )),
+ ]],
'title' => 'Drupal rocks',
- 'body' => array(array('value' => "Drupal's search rocks")),
+ 'body' => [['value' => "Drupal's search rocks"]],
// Node is one day old.
'created' => REQUEST_TIME - 24 * 3600,
'sticky' => 0,
'promote' => 0,
- );
- foreach (array(0, 1) as $num) {
+ ];
+ foreach ([0, 1] as $num) {
if ($num == 1) {
switch ($node_rank) {
case 'sticky':
@@ -87,7 +87,7 @@ class SearchRankingTest extends SearchTestBase {
}
// Add a comment to one of the nodes.
- $edit = array();
+ $edit = [];
$edit['subject[0][value]'] = 'my comment title';
$edit['comment_body[0][value]'] = 'some random comment';
$this->drupalGet('comment/reply/node/' . $nodes['comments'][1]->id() . '/comment');
@@ -102,7 +102,7 @@ class SearchRankingTest extends SearchTestBase {
// counter for this node.
$nid = $nodes['views'][1]->id();
db_insert('node_counter')
- ->fields(array('totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid))
+ ->fields(['totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid])
->execute();
// Run cron to update the search index and comment/statistics totals.
@@ -118,7 +118,7 @@ class SearchRankingTest extends SearchTestBase {
}
// Test each of the possible rankings.
- $edit = array();
+ $edit = [];
foreach ($node_ranks as $node_rank) {
// Enable the ranking we are testing.
$edit['rankings[' . $node_rank . '][value]'] = 10;
@@ -129,7 +129,7 @@ class SearchRankingTest extends SearchTestBase {
// Reload the plugin to get the up-to-date values.
$this->nodeSearch = SearchPage::load('node_search');
// Do the search and assert the results.
- $this->nodeSearch->getPlugin()->setSearch('rocks', array(), array());
+ $this->nodeSearch->getPlugin()->setSearch('rocks', [], []);
$set = $this->nodeSearch->getPlugin()->execute();
$this->assertEqual($set[0]['node']->id(), $nodes[$node_rank][1]->id(), 'Search ranking "' . $node_rank . '" order.');
@@ -147,14 +147,14 @@ class SearchRankingTest extends SearchTestBase {
// Try with sticky, then promoted. This is a test for issue
// https://www.drupal.org/node/771596.
- $node_ranks = array(
+ $node_ranks = [
'sticky' => 10,
'promote' => 1,
'relevance' => 0,
'recent' => 0,
'comments' => 0,
'views' => 0,
- );
+ ];
$configuration = $this->nodeSearch->getPlugin()->getConfiguration();
foreach ($node_ranks as $var => $value) {
$configuration['rankings'][$var] = $value;
@@ -164,7 +164,7 @@ class SearchRankingTest extends SearchTestBase {
// Do the search and assert the results. The sticky node should show up
// first, then the promoted node, then all the rest.
- $this->nodeSearch->getPlugin()->setSearch('rocks', array(), array());
+ $this->nodeSearch->getPlugin()->setSearch('rocks', [], []);
$set = $this->nodeSearch->getPlugin()->execute();
$this->assertEqual($set[0]['node']->id(), $nodes['sticky'][1]->id(), 'Search ranking for sticky first worked.');
$this->assertEqual($set[1]['node']->id(), $nodes['promote'][1]->id(), 'Search ranking for promoted second worked.');
@@ -172,14 +172,14 @@ class SearchRankingTest extends SearchTestBase {
// Try with recent, then comments. This is a test for issues
// https://www.drupal.org/node/771596 and
// https://www.drupal.org/node/303574.
- $node_ranks = array(
+ $node_ranks = [
'sticky' => 0,
'promote' => 0,
'relevance' => 0,
'recent' => 10,
'comments' => 1,
'views' => 0,
- );
+ ];
$configuration = $this->nodeSearch->getPlugin()->getConfiguration();
foreach ($node_ranks as $var => $value) {
$configuration['rankings'][$var] = $value;
@@ -189,7 +189,7 @@ class SearchRankingTest extends SearchTestBase {
// Do the search and assert the results. The recent node should show up
// first, then the commented node, then all the rest.
- $this->nodeSearch->getPlugin()->setSearch('rocks', array(), array());
+ $this->nodeSearch->getPlugin()->setSearch('rocks', [], []);
$set = $this->nodeSearch->getPlugin()->execute();
$this->assertEqual($set[0]['node']->id(), $nodes['recent'][1]->id(), 'Search ranking for recent first worked.');
$this->assertEqual($set[1]['node']->id(), $nodes['comments'][1]->id(), 'Search ranking for comments second worked.');
@@ -200,33 +200,33 @@ class SearchRankingTest extends SearchTestBase {
* Test rankings of HTML tags.
*/
public function testHTMLRankings() {
- $full_html_format = FilterFormat::create(array(
+ $full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
- ));
+ ]);
$full_html_format->save();
// Test HTML tags with different weights.
- $sorted_tags = array('h1', 'h2', 'h3', 'h4', 'a', 'h5', 'h6', 'notag');
+ $sorted_tags = ['h1', 'h2', 'h3', 'h4', 'a', 'h5', 'h6', 'notag'];
$shuffled_tags = $sorted_tags;
// Shuffle tags to ensure HTML tags are ranked properly.
shuffle($shuffled_tags);
- $settings = array(
+ $settings = [
'type' => 'page',
'title' => 'Simple node',
- );
- $nodes = array();
+ ];
+ $nodes = [];
foreach ($shuffled_tags as $tag) {
switch ($tag) {
case 'a':
- $settings['body'] = array(array('value' => \Drupal::l('Drupal Rocks', new Url('<front>')), 'format' => 'full_html'));
+ $settings['body'] = [['value' => \Drupal::l('Drupal Rocks', new Url('<front>')), 'format' => 'full_html']];
break;
case 'notag':
- $settings['body'] = array(array('value' => 'Drupal Rocks'));
+ $settings['body'] = [['value' => 'Drupal Rocks']];
break;
default:
- $settings['body'] = array(array('value' => "<$tag>Drupal Rocks</$tag>", 'format' => 'full_html'));
+ $settings['body'] = [['value' => "<$tag>Drupal Rocks</$tag>", 'format' => 'full_html']];
break;
}
$nodes[$tag] = $this->drupalCreateNode($settings);
@@ -236,7 +236,7 @@ class SearchRankingTest extends SearchTestBase {
$this->nodeSearch->getPlugin()->updateIndex();
search_update_totals();
- $this->nodeSearch->getPlugin()->setSearch('rocks', array(), array());
+ $this->nodeSearch->getPlugin()->setSearch('rocks', [], []);
// Do the search and assert the results.
$set = $this->nodeSearch->getPlugin()->execute();
@@ -252,16 +252,16 @@ class SearchRankingTest extends SearchTestBase {
}
// Test tags with the same weight against the sorted tags.
- $unsorted_tags = array('u', 'b', 'i', 'strong', 'em');
+ $unsorted_tags = ['u', 'b', 'i', 'strong', 'em'];
foreach ($unsorted_tags as $tag) {
- $settings['body'] = array(array('value' => "<$tag>Drupal Rocks</$tag>", 'format' => 'full_html'));
+ $settings['body'] = [['value' => "<$tag>Drupal Rocks</$tag>", 'format' => 'full_html']];
$node = $this->drupalCreateNode($settings);
// Update the search index.
$this->nodeSearch->getPlugin()->updateIndex();
search_update_totals();
- $this->nodeSearch->getPlugin()->setSearch('rocks', array(), array());
+ $this->nodeSearch->getPlugin()->setSearch('rocks', [], []);
// Do the search and assert the results.
$set = $this->nodeSearch->getPlugin()->execute();
diff --git a/core/modules/search/src/Tests/SearchTestBase.php b/core/modules/search/src/Tests/SearchTestBase.php
index 59f6c456d69..1c157b6d0d5 100644
--- a/core/modules/search/src/Tests/SearchTestBase.php
+++ b/core/modules/search/src/Tests/SearchTestBase.php
@@ -18,15 +18,15 @@ abstract class SearchTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'search', 'dblog');
+ public static $modules = ['node', 'search', 'dblog'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
@@ -71,13 +71,13 @@ abstract class SearchTestBase extends WebTestBase {
foreach ($forms as $form) {
// Try to set the fields of this form as specified in $edit.
$edit = $edit_save;
- $post = array();
- $upload = array();
+ $post = [];
+ $upload = [];
$submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form);
if (!$edit && $submit_matches) {
// Everything matched, so "submit" the form.
$action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : NULL;
- $this->drupalGet($action, array('query' => $post));
+ $this->drupalGet($action, ['query' => $post]);
return;
}
}
@@ -85,10 +85,10 @@ abstract class SearchTestBase extends WebTestBase {
// We have not found a form which contained all fields of $edit and
// the submit button.
foreach ($edit as $name => $value) {
- $this->fail(SafeMarkup::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
+ $this->fail(SafeMarkup::format('Failed to set field @name to @value', ['@name' => $name, '@value' => $value]));
}
- $this->assertTrue($submit_matches, format_string('Found the @submit button', array('@submit' => $submit)));
- $this->fail(format_string('Found the requested form fields at @path', array('@path' => $path)));
+ $this->assertTrue($submit_matches, format_string('Found the @submit button', ['@submit' => $submit]));
+ $this->fail(format_string('Found the requested form fields at @path', ['@path' => $path]));
}
}
diff --git a/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php b/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php
index 29c047d05f1..64d9418fb5b 100644
--- a/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php
+++ b/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php
@@ -23,20 +23,20 @@ class SearchEmbeddedForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$count = \Drupal::state()->get('search_embedded_form.submit_count');
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Your name'),
'#maxlength' => 255,
'#default_value' => '',
'#required' => TRUE,
- '#description' => $this->t('Times form has been submitted: %count', array('%count' => $count)),
- );
+ '#description' => $this->t('Times form has been submitted: %count', ['%count' => $count]),
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Send away'),
- );
+ ];
return $form;
}
diff --git a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php
index d02fd81a3c8..d18ff1c9254 100644
--- a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php
+++ b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php
@@ -50,18 +50,18 @@ class SearchExtraTypeSearch extends ConfigurableSearchPluginBase {
* A structured list of search results
*/
public function execute() {
- $results = array();
+ $results = [];
if (!$this->isSearchExecutable()) {
return $results;
}
- return array(
- array(
+ return [
+ [
'link' => Url::fromRoute('test_page_test.test_page')->toString(),
'type' => 'Dummy result type',
'title' => 'Dummy title',
'snippet' => SafeMarkup::format("Dummy search snippet to display. Keywords: @keywords\n\nConditions: @search_parameters", ['@keywords' => $this->keywords, '@search_parameters' => print_r($this->searchParameters, TRUE)]),
- ),
- );
+ ],
+ ];
}
/**
@@ -72,15 +72,15 @@ class SearchExtraTypeSearch extends ConfigurableSearchPluginBase {
$output['prefix']['#markup'] = '<h2>Test page text is here</h2> <ol class="search-results">';
foreach ($results as $entry) {
- $output[] = array(
+ $output[] = [
'#theme' => 'search_result',
'#result' => $entry,
'#plugin_id' => 'search_extra_type_search',
- );
+ ];
}
- $pager = array(
+ $pager = [
'#type' => 'pager',
- );
+ ];
$output['suffix']['#markup'] = '</ol>' . drupal_render($pager);
return $output;
@@ -91,21 +91,21 @@ class SearchExtraTypeSearch extends ConfigurableSearchPluginBase {
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Output form for defining rank factor weights.
- $form['extra_type_settings'] = array(
+ $form['extra_type_settings'] = [
'#type' => 'fieldset',
'#title' => t('Extra type settings'),
'#tree' => TRUE,
- );
+ ];
- $form['extra_type_settings']['boost'] = array(
+ $form['extra_type_settings']['boost'] = [
'#type' => 'select',
'#title' => t('Boost method'),
- '#options' => array(
+ '#options' => [
'bi' => t('Bistromathic'),
'ii' => t('Infinite Improbability'),
- ),
+ ],
'#default_value' => $this->configuration['boost'],
- );
+ ];
return $form;
}
@@ -113,16 +113,16 @@ class SearchExtraTypeSearch extends ConfigurableSearchPluginBase {
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
- $this->configuration['boost'] = $form_state->getValue(array('extra_type_settings', 'boost'));
+ $this->configuration['boost'] = $form_state->getValue(['extra_type_settings', 'boost']);
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'boost' => 'bi',
- );
+ ];
}
}
diff --git a/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php b/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php
index a6bf35ec690..14ae5572e46 100644
--- a/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php
+++ b/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php
@@ -26,7 +26,7 @@ class SearchCommentCountToggleTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment');
+ public static $modules = ['node', 'comment'];
/**
* A user with permission to search and post comments.
@@ -46,7 +46,7 @@ class SearchCommentCountToggleTest extends SearchTestBase {
parent::setUp();
// Create searching user.
- $this->searchingUser = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'post comments', 'skip comment approval'));
+ $this->searchingUser = $this->drupalCreateUser(['search content', 'access content', 'access comments', 'post comments', 'skip comment approval']);
// Log in with sufficient privileges.
$this->drupalLogin($this->searchingUser);
@@ -54,13 +54,13 @@ class SearchCommentCountToggleTest extends SearchTestBase {
// Add a comment field.
$this->addDefaultCommentField('node', 'article');
// Create initial nodes.
- $node_params = array('type' => 'article', 'body' => array(array('value' => 'SearchCommentToggleTestCase')));
+ $node_params = ['type' => 'article', 'body' => [['value' => 'SearchCommentToggleTestCase']]];
$this->searchableNodes['1 comment'] = $this->drupalCreateNode($node_params);
$this->searchableNodes['0 comments'] = $this->drupalCreateNode($node_params);
// Create a comment array
- $edit_comment = array();
+ $edit_comment = [];
$edit_comment['subject[0][value]'] = $this->randomMachineName();
$edit_comment['comment_body[0][value]'] = $this->randomMachineName();
@@ -81,9 +81,9 @@ class SearchCommentCountToggleTest extends SearchTestBase {
*/
function testSearchCommentCountToggle() {
// Search for the nodes by string in the node body.
- $edit = array(
+ $edit = [
'keys' => "'SearchCommentToggleTestCase'",
- );
+ ];
$this->drupalGet('search/node');
// Test comment count display for nodes with comment status set to Open
diff --git a/core/modules/search/tests/src/Functional/SearchExactTest.php b/core/modules/search/tests/src/Functional/SearchExactTest.php
index 6280364513b..ca876ae2926 100644
--- a/core/modules/search/tests/src/Functional/SearchExactTest.php
+++ b/core/modules/search/tests/src/Functional/SearchExactTest.php
@@ -13,25 +13,25 @@ class SearchExactTest extends SearchTestBase {
*/
function testExactQuery() {
// Log in with sufficient privileges.
- $user = $this->drupalCreateUser(array('create page content', 'search content'));
+ $user = $this->drupalCreateUser(['create page content', 'search content']);
$this->drupalLogin($user);
- $settings = array(
+ $settings = [
'type' => 'page',
'title' => 'Simple Node',
- );
+ ];
// Create nodes with exact phrase.
for ($i = 0; $i <= 17; $i++) {
- $settings['body'] = array(array('value' => 'love pizza'));
+ $settings['body'] = [['value' => 'love pizza']];
$this->drupalCreateNode($settings);
}
// Create nodes containing keywords.
for ($i = 0; $i <= 17; $i++) {
- $settings['body'] = array(array('value' => 'love cheesy pizza'));
+ $settings['body'] = [['value' => 'love cheesy pizza']];
$this->drupalCreateNode($settings);
}
// Create another node and save it for later.
- $settings['body'] = array(array('value' => 'Druplicon'));
+ $settings['body'] = [['value' => 'Druplicon']];
$node = $this->drupalCreateNode($settings);
// Update the search index.
@@ -42,7 +42,7 @@ class SearchExactTest extends SearchTestBase {
$this->refreshVariables();
// Test that the correct number of pager links are found for keyword search.
- $edit = array('keys' => 'love pizza');
+ $edit = ['keys' => 'love pizza'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertLinkByHref('page=1', 0, '2nd page link is found for keyword search.');
$this->assertLinkByHref('page=2', 0, '3rd page link is found for keyword search.');
@@ -50,7 +50,7 @@ class SearchExactTest extends SearchTestBase {
$this->assertNoLinkByHref('page=4', '5th page link is not found for keyword search.');
// Test that the correct number of pager links are found for exact phrase search.
- $edit = array('keys' => '"love pizza"');
+ $edit = ['keys' => '"love pizza"'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertLinkByHref('page=1', 0, '2nd page link is found for exact phrase search.');
$this->assertNoLinkByHref('page=2', '3rd page link is not found for exact phrase search.');
@@ -60,7 +60,7 @@ class SearchExactTest extends SearchTestBase {
$node_type_config->set('display_submitted', TRUE);
$node_type_config->save();
- $edit = array('keys' => 'Druplicon');
+ $edit = ['keys' => 'Druplicon'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText($user->getUsername(), 'Basic page node displays author name when post settings are on.');
$this->assertText(format_date($node->getChangedTime(), 'short'), 'Basic page node displays post date when post settings are on.');
@@ -69,7 +69,7 @@ class SearchExactTest extends SearchTestBase {
// information is not displayed.
$node_type_config->set('display_submitted', FALSE);
$node_type_config->save();
- $edit = array('keys' => 'Druplicon');
+ $edit = ['keys' => 'Druplicon'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertNoText($user->getUsername(), 'Basic page node does not display author name when post settings are off.');
$this->assertNoText(format_date($node->getChangedTime(), 'short'), 'Basic page node does not display post date when post settings are off.');
diff --git a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
index a75fcb5ddbd..287596ab3e3 100644
--- a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
+++ b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
@@ -20,7 +20,7 @@ class SearchKeywordsConditionsTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('comment', 'search_extra_type', 'test_page_test');
+ public static $modules = ['comment', 'search_extra_type', 'test_page_test'];
/**
* A user with permission to search and post comments.
@@ -33,7 +33,7 @@ class SearchKeywordsConditionsTest extends SearchTestBase {
parent::setUp();
// Create searching user.
- $this->searchingUser = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval'));
+ $this->searchingUser = $this->drupalCreateUser(['search content', 'access content', 'access comments', 'skip comment approval']);
// Log in with sufficient privileges.
$this->drupalLogin($this->searchingUser);
}
@@ -47,16 +47,16 @@ class SearchKeywordsConditionsTest extends SearchTestBase {
$this->assertNoText('Dummy search snippet to display');
// With keys - get results.
$keys = 'bike shed ' . $this->randomMachineName();
- $this->drupalGet("search/dummy_path", array('query' => array('keys' => $keys)));
+ $this->drupalGet("search/dummy_path", ['query' => ['keys' => $keys]]);
$this->assertText("Dummy search snippet to display. Keywords: {$keys}");
$keys = 'blue drop ' . $this->randomMachineName();
- $this->drupalGet("search/dummy_path", array('query' => array('keys' => $keys)));
+ $this->drupalGet("search/dummy_path", ['query' => ['keys' => $keys]]);
$this->assertText("Dummy search snippet to display. Keywords: {$keys}");
// Add some conditions and keys.
$keys = 'moving drop ' . $this->randomMachineName();
- $this->drupalGet("search/dummy_path", array('query' => array('keys' => 'bike', 'search_conditions' => $keys)));
+ $this->drupalGet("search/dummy_path", ['query' => ['keys' => 'bike', 'search_conditions' => $keys]]);
$this->assertText("Dummy search snippet to display.");
- $this->assertRaw(Html::escape(print_r(array('keys' => 'bike', 'search_conditions' => $keys), TRUE)));
+ $this->assertRaw(Html::escape(print_r(['keys' => 'bike', 'search_conditions' => $keys], TRUE)));
}
}
diff --git a/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php b/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php
index faaa93f6c13..717ffc51957 100644
--- a/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php
+++ b/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php
@@ -17,7 +17,7 @@ class SearchMultilingualEntityTest extends SearchTestBase {
*
* @var \Drupal\node\NodeInterface[]
*/
- protected $searchableNodes = array();
+ protected $searchableNodes = [];
/**
* Node search plugin.
@@ -26,14 +26,14 @@ class SearchMultilingualEntityTest extends SearchTestBase {
*/
protected $plugin;
- public static $modules = array('language', 'locale', 'comment');
+ public static $modules = ['language', 'locale', 'comment'];
protected function setUp() {
parent::setUp();
// Create a user who can administer search, do searches, see the status
// report, and administer cron. Log in.
- $user = $this->drupalCreateUser(array('administer search', 'search content', 'use advanced search', 'access content', 'access site reports', 'administer site configuration'));
+ $user = $this->drupalCreateUser(['administer search', 'search content', 'use advanced search', 'access content', 'access site reports', 'administer site configuration']);
$this->drupalLogin($user);
// Set up the search plugin.
@@ -56,53 +56,53 @@ class SearchMultilingualEntityTest extends SearchTestBase {
// Create a few page nodes with multilingual body values.
$default_format = filter_default_format();
- $nodes = array(
- array(
+ $nodes = [
+ [
'title' => 'First node en',
'type' => 'page',
- 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)),
+ 'body' => [['value' => $this->randomMachineName(32), 'format' => $default_format]],
'langcode' => 'en',
- ),
- array(
+ ],
+ [
'title' => 'Second node this is the English title',
'type' => 'page',
- 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)),
+ 'body' => [['value' => $this->randomMachineName(32), 'format' => $default_format]],
'langcode' => 'en',
- ),
- array(
+ ],
+ [
'title' => 'Third node en',
'type' => 'page',
- 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)),
+ 'body' => [['value' => $this->randomMachineName(32), 'format' => $default_format]],
'langcode' => 'en',
- ),
+ ],
// After the third node, we don't care what the settings are. But we
// need to have at least 5 to make sure the throttling is working
// correctly. So, let's make 8 total.
- array(
- ),
- array(
- ),
- array(
- ),
- array(
- ),
- array(
- ),
- );
- $this->searchableNodes = array();
+ [
+ ],
+ [
+ ],
+ [
+ ],
+ [
+ ],
+ [
+ ],
+ ];
+ $this->searchableNodes = [];
foreach ($nodes as $setting) {
$this->searchableNodes[] = $this->drupalCreateNode($setting);
}
// Add a single translation to the second node.
- $translation = $this->searchableNodes[1]->addTranslation('hu', array('title' => 'Second node hu'));
+ $translation = $this->searchableNodes[1]->addTranslation('hu', ['title' => 'Second node hu']);
$translation->body->value = $this->randomMachineName(32);
$this->searchableNodes[1]->save();
// Add two translations to the third node.
- $translation = $this->searchableNodes[2]->addTranslation('hu', array('title' => 'Third node this is the Hungarian title'));
+ $translation = $this->searchableNodes[2]->addTranslation('hu', ['title' => 'Third node this is the Hungarian title']);
$translation->body->value = $this->randomMachineName(32);
- $translation = $this->searchableNodes[2]->addTranslation('sv', array('title' => 'Third node sv'));
+ $translation = $this->searchableNodes[2]->addTranslation('sv', ['title' => 'Third node sv']);
$translation->body->value = $this->randomMachineName(32);
$this->searchableNodes[2]->save();
@@ -132,7 +132,7 @@ class SearchMultilingualEntityTest extends SearchTestBase {
// Now index the rest of the nodes.
// Make sure index throttle is high enough, via the UI.
- $this->drupalPostForm('admin/config/search/pages', array('cron_limit' => 20), t('Save configuration'));
+ $this->drupalPostForm('admin/config/search/pages', ['cron_limit' => 20], t('Save configuration'));
$this->assertEqual(20, $this->config('search.settings')->get('index.cron_limit', 100), 'Config setting was saved correctly');
// Get a new search plugin, to make sure it has this setting.
$this->plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
@@ -143,8 +143,8 @@ class SearchMultilingualEntityTest extends SearchTestBase {
$this->assertDatabaseCounts(8, 0, 'after updating fully');
// Click the reindex button on the admin page, verify counts, and reindex.
- $this->drupalPostForm('admin/config/search/pages', array(), t('Re-index site'));
- $this->drupalPostForm(NULL, array(), t('Re-index site'));
+ $this->drupalPostForm('admin/config/search/pages', [], t('Re-index site'));
+ $this->drupalPostForm(NULL, [], t('Re-index site'));
$this->assertIndexCounts(8, 8, 'after reindex');
$this->assertDatabaseCounts(8, 0, 'after reindex');
$this->plugin->updateIndex();
@@ -153,30 +153,30 @@ class SearchMultilingualEntityTest extends SearchTestBase {
// Test search results.
// This should find two results for the second and third node.
- $this->plugin->setSearch('English OR Hungarian', array(), array());
+ $this->plugin->setSearch('English OR Hungarian', [], []);
$search_result = $this->plugin->execute();
$this->assertEqual(count($search_result), 2, 'Found two results.');
// Nodes are saved directly after each other and have the same created time
// so testing for the order is not possible.
- $results = array($search_result[0]['title'], $search_result[1]['title']);
+ $results = [$search_result[0]['title'], $search_result[1]['title']];
$this->assertTrue(in_array('Third node this is the Hungarian title', $results), 'The search finds the correct Hungarian title.');
$this->assertTrue(in_array('Second node this is the English title', $results), 'The search finds the correct English title.');
// Now filter for Hungarian results only.
- $this->plugin->setSearch('English OR Hungarian', array('f' => array('language:hu')), array());
+ $this->plugin->setSearch('English OR Hungarian', ['f' => ['language:hu']], []);
$search_result = $this->plugin->execute();
$this->assertEqual(count($search_result), 1, 'The search found only one result');
$this->assertEqual($search_result[0]['title'], 'Third node this is the Hungarian title', 'The search finds the correct Hungarian title.');
// Test for search with common key word across multiple languages.
- $this->plugin->setSearch('node', array(), array());
+ $this->plugin->setSearch('node', [], []);
$search_result = $this->plugin->execute();
$this->assertEqual(count($search_result), 6, 'The search found total six results');
// Test with language filters and common key word.
- $this->plugin->setSearch('node', array('f' => array('language:hu')), array());
+ $this->plugin->setSearch('node', ['f' => ['language:hu']], []);
$search_result = $this->plugin->execute();
$this->assertEqual(count($search_result), 2, 'The search found 2 results');
@@ -207,14 +207,14 @@ class SearchMultilingualEntityTest extends SearchTestBase {
$current = REQUEST_TIME;
$old = $current - 10;
db_update('search_dataset')
- ->fields(array('reindex' => $old))
+ ->fields(['reindex' => $old])
->condition('reindex', $current, '>=')
->execute();
// Save the node again. Verify that the request time on it is not updated.
$this->searchableNodes[1]->save();
$result = db_select('search_dataset', 'd')
- ->fields('d', array('reindex'))
+ ->fields('d', ['reindex'])
->condition('type', 'node_search')
->condition('sid', $this->searchableNodes[1]->id())
->execute()
@@ -302,7 +302,7 @@ class SearchMultilingualEntityTest extends SearchTestBase {
protected function assertDatabaseCounts($count_node, $count_foo, $message) {
// Count number of distinct nodes by ID.
$results = db_select('search_dataset', 'i')
- ->fields('i', array('sid'))
+ ->fields('i', ['sid'])
->condition('type', 'node_search')
->groupBy('sid')
->execute()
@@ -311,7 +311,7 @@ class SearchMultilingualEntityTest extends SearchTestBase {
// Count number of "foo" records.
$results = db_select('search_dataset', 'i')
- ->fields('i', array('sid'))
+ ->fields('i', ['sid'])
->condition('type', 'foo')
->execute()
->fetchCol();
diff --git a/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php b/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
index 27baa4b3433..32aa102de69 100644
--- a/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
+++ b/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
@@ -21,7 +21,7 @@ class SearchNodeDiacriticsTest extends SearchTestBase {
node_access_rebuild();
// Create a test user and log in.
- $this->testUser = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'access user profiles'));
+ $this->testUser = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'access user profiles']);
$this->drupalLogin($this->testUser);
}
@@ -31,7 +31,7 @@ class SearchNodeDiacriticsTest extends SearchTestBase {
function testPhraseSearchPunctuation() {
$body_text = 'The Enricþment Center is cómmīŦŧęđ to the well BɆĬŇĜ of æll påŔťıçȉpǎǹţș. ';
$body_text .= 'Also meklēt (see #731298)';
- $this->drupalCreateNode(array('body' => array(array('value' => $body_text))));
+ $this->drupalCreateNode(['body' => [['value' => $body_text]]]);
// Update the search index.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
@@ -40,39 +40,39 @@ class SearchNodeDiacriticsTest extends SearchTestBase {
// Refresh variables after the treatment.
$this->refreshVariables();
- $edit = array('keys' => 'meklet');
+ $edit = ['keys' => 'meklet'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertRaw('<strong>meklēt</strong>');
- $edit = array('keys' => 'meklēt');
+ $edit = ['keys' => 'meklēt'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertRaw('<strong>meklēt</strong>');
- $edit = array('keys' => 'cómmīŦŧęđ BɆĬŇĜ påŔťıçȉpǎǹţș');
+ $edit = ['keys' => 'cómmīŦŧęđ BɆĬŇĜ påŔťıçȉpǎǹţș'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertRaw('<strong>cómmīŦŧęđ</strong>');
$this->assertRaw('<strong>BɆĬŇĜ</strong>');
$this->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
- $edit = array('keys' => 'committed being participants');
+ $edit = ['keys' => 'committed being participants'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertRaw('<strong>cómmīŦŧęđ</strong>');
$this->assertRaw('<strong>BɆĬŇĜ</strong>');
$this->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
- $edit = array('keys' => 'Enricþment');
+ $edit = ['keys' => 'Enricþment'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertRaw('<strong>Enricþment</strong>');
- $edit = array('keys' => 'Enritchment');
+ $edit = ['keys' => 'Enritchment'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertNoRaw('<strong>Enricþment</strong>');
- $edit = array('keys' => 'æll');
+ $edit = ['keys' => 'æll'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertRaw('<strong>æll</strong>');
- $edit = array('keys' => 'all');
+ $edit = ['keys' => 'all'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertNoRaw('<strong>æll</strong>');
}
diff --git a/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php b/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php
index 0d0a129807c..8c8958cea85 100644
--- a/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php
+++ b/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php
@@ -21,7 +21,7 @@ class SearchNodePunctuationTest extends SearchTestBase {
node_access_rebuild();
// Create a test user and log in.
- $this->testUser = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'access user profiles'));
+ $this->testUser = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'access user profiles']);
$this->drupalLogin($this->testUser);
}
@@ -29,8 +29,8 @@ class SearchNodePunctuationTest extends SearchTestBase {
* Tests that search works with punctuation and HTML entities.
*/
function testPhraseSearchPunctuation() {
- $node = $this->drupalCreateNode(array('body' => array(array('value' => "The bunny's ears were fluffy."))));
- $node2 = $this->drupalCreateNode(array('body' => array(array('value' => 'Dignissim Aliquam &amp; Quieligo meus natu quae quia te. Damnum&copy; erat&mdash; neo pneum. Facilisi feugiat ibidem ratis.'))));
+ $node = $this->drupalCreateNode(['body' => [['value' => "The bunny's ears were fluffy."]]]);
+ $node2 = $this->drupalCreateNode(['body' => [['value' => 'Dignissim Aliquam &amp; Quieligo meus natu quae quia te. Damnum&copy; erat&mdash; neo pneum. Facilisi feugiat ibidem ratis.']]]);
// Update the search index.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
@@ -40,7 +40,7 @@ class SearchNodePunctuationTest extends SearchTestBase {
$this->refreshVariables();
// Submit a phrase wrapped in double quotes to include the punctuation.
- $edit = array('keys' => '"bunny\'s"');
+ $edit = ['keys' => '"bunny\'s"'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertText($node->label());
@@ -49,12 +49,12 @@ class SearchNodePunctuationTest extends SearchTestBase {
$this->assertLink($username);
// Search for "&" and verify entities are not broken up in the output.
- $edit = array('keys' => '&');
+ $edit = ['keys' => '&'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertNoRaw('<strong>&</strong>amp;');
$this->assertText('You must include at least one keyword');
- $edit = array('keys' => '&amp;');
+ $edit = ['keys' => '&amp;'];
$this->drupalPostForm('search/node', $edit, t('Search'));
$this->assertNoRaw('<strong>&</strong>amp;');
$this->assertText('You must include at least one keyword');
diff --git a/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php b/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php
index 88edab177bd..fe6e9805e70 100644
--- a/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php
+++ b/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php
@@ -17,7 +17,7 @@ class SearchPageOverrideTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('search_extra_type');
+ public static $modules = ['search_extra_type'];
/**
* A user with permission to administer search.
@@ -30,13 +30,13 @@ class SearchPageOverrideTest extends SearchTestBase {
parent::setUp();
// Log in as a user that can create and search content.
- $this->searchUser = $this->drupalCreateUser(array('search content', 'administer search'));
+ $this->searchUser = $this->drupalCreateUser(['search content', 'administer search']);
$this->drupalLogin($this->searchUser);
}
function testSearchPageHook() {
$keys = 'bike shed ' . $this->randomMachineName();
- $this->drupalGet("search/dummy_path", array('query' => array('keys' => $keys)));
+ $this->drupalGet("search/dummy_path", ['query' => ['keys' => $keys]]);
$this->assertText('Dummy search snippet', 'Dummy search snippet is shown');
$this->assertText('Test page text is here', 'Page override is working');
}
diff --git a/core/modules/search/tests/src/Functional/SearchSetLocaleTest.php b/core/modules/search/tests/src/Functional/SearchSetLocaleTest.php
index 4291598c948..f6923f4320b 100644
--- a/core/modules/search/tests/src/Functional/SearchSetLocaleTest.php
+++ b/core/modules/search/tests/src/Functional/SearchSetLocaleTest.php
@@ -14,7 +14,7 @@ class SearchSetLocaleTest extends SearchTestBase {
*
* @var array
*/
- public static $modules = array('comment');
+ public static $modules = ['comment'];
/**
* A node search plugin instance.
@@ -29,7 +29,7 @@ class SearchSetLocaleTest extends SearchTestBase {
// Create a plugin instance.
$this->nodeSearchPlugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
// Create a node with a very simple body.
- $this->drupalCreateNode(array('body' => array(array('value' => 'tapir'))));
+ $this->drupalCreateNode(['body' => [['value' => 'tapir']]]);
// Update the search index.
$this->nodeSearchPlugin->updateIndex();
search_update_totals();
@@ -41,7 +41,7 @@ class SearchSetLocaleTest extends SearchTestBase {
public function testSearchWithNumericLocale() {
// French decimal point is comma.
setlocale(LC_NUMERIC, 'fr_FR');
- $this->nodeSearchPlugin->setSearch('tapir', array(), array());
+ $this->nodeSearchPlugin->setSearch('tapir', [], []);
// The call to execute will throw an exception if a float in the wrong
// format is passed in the query to the database, so an assertion is not
// necessary here.
diff --git a/core/modules/search/tests/src/Functional/SearchSimplifyTest.php b/core/modules/search/tests/src/Functional/SearchSimplifyTest.php
index 6e7bb849478..a70b65e4d33 100644
--- a/core/modules/search/tests/src/Functional/SearchSimplifyTest.php
+++ b/core/modules/search/tests/src/Functional/SearchSimplifyTest.php
@@ -22,7 +22,7 @@ class SearchSimplifyTest extends SearchTestBase {
// verify that simplification doesn't lose any characters.
$input = file_get_contents(\Drupal::root() . '/core/modules/search/tests/UnicodeTest.txt');
$basestrings = explode(chr(10), $input);
- $strings = array();
+ $strings = [];
foreach ($basestrings as $key => $string) {
if ($key % 2) {
// Even line - should simplify down to a space.
@@ -65,12 +65,12 @@ class SearchSimplifyTest extends SearchTestBase {
* Tests that search_simplify() does the right thing with punctuation.
*/
function testSearchSimplifyPunctuation() {
- $cases = array(
- array('20.03/94-28,876', '20039428876', 'Punctuation removed from numbers'),
- array('great...drupal--module', 'great drupal module', 'Multiple dot and dashes are word boundaries'),
- array('very_great-drupal.module', 'verygreatdrupalmodule', 'Single dot, dash, underscore are removed'),
- array('regular,punctuation;word', 'regular punctuation word', 'Punctuation is a word boundary'),
- );
+ $cases = [
+ ['20.03/94-28,876', '20039428876', 'Punctuation removed from numbers'],
+ ['great...drupal--module', 'great drupal module', 'Multiple dot and dashes are word boundaries'],
+ ['very_great-drupal.module', 'verygreatdrupalmodule', 'Single dot, dash, underscore are removed'],
+ ['regular,punctuation;word', 'regular punctuation word', 'Punctuation is a word boundary'],
+ ];
foreach ($cases as $case) {
$out = trim(search_simplify($case[0]));
diff --git a/core/modules/search/tests/src/Functional/SearchTestBase.php b/core/modules/search/tests/src/Functional/SearchTestBase.php
index 93e0ee26eb6..3739b570fa1 100644
--- a/core/modules/search/tests/src/Functional/SearchTestBase.php
+++ b/core/modules/search/tests/src/Functional/SearchTestBase.php
@@ -15,15 +15,15 @@ abstract class SearchTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'search', 'dblog');
+ public static $modules = ['node', 'search', 'dblog'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
@@ -68,13 +68,13 @@ abstract class SearchTestBase extends BrowserTestBase {
foreach ($forms as $form) {
// Try to set the fields of this form as specified in $edit.
$edit = $edit_save;
- $post = array();
- $upload = array();
+ $post = [];
+ $upload = [];
$submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form);
if (!$edit && $submit_matches) {
// Everything matched, so "submit" the form.
$action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : NULL;
- $this->drupalGet($action, array('query' => $post));
+ $this->drupalGet($action, ['query' => $post]);
return;
}
}
@@ -82,10 +82,10 @@ abstract class SearchTestBase extends BrowserTestBase {
// We have not found a form which contained all fields of $edit and
// the submit button.
foreach ($edit as $name => $value) {
- $this->fail(SafeMarkup::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
+ $this->fail(SafeMarkup::format('Failed to set field @name to @value', ['@name' => $name, '@value' => $value]));
}
- $this->assertTrue($submit_matches, format_string('Found the @submit button', array('@submit' => $submit)));
- $this->fail(format_string('Found the requested form fields at @path', array('@path' => $path)));
+ $this->assertTrue($submit_matches, format_string('Found the @submit button', ['@submit' => $submit]));
+ $this->fail(format_string('Found the requested form fields at @path', ['@path' => $path]));
}
}
diff --git a/core/modules/search/tests/src/Functional/SearchTokenizerTest.php b/core/modules/search/tests/src/Functional/SearchTokenizerTest.php
index e25bfc4028f..03667bc77b4 100644
--- a/core/modules/search/tests/src/Functional/SearchTokenizerTest.php
+++ b/core/modules/search/tests/src/Functional/SearchTokenizerTest.php
@@ -31,7 +31,7 @@ class SearchTokenizerTest extends SearchTestBase {
// the Unicode tables.
// Beginnings of the character ranges.
- $starts = array(
+ $starts = [
'CJK unified' => 0x4e00,
'CJK Ext A' => 0x3400,
'CJK Compat' => 0xf900,
@@ -52,10 +52,10 @@ class SearchTokenizerTest extends SearchTestBase {
'Bomofo Ext' => 0x31a0,
'Lisu' => 0xa4d0,
'Yi' => 0xa000,
- );
+ ];
// Ends of the character ranges.
- $ends = array(
+ $ends = [
'CJK unified' => 0x9fcf,
'CJK Ext A' => 0x4dbf,
'CJK Compat' => 0xfaff,
@@ -76,11 +76,11 @@ class SearchTokenizerTest extends SearchTestBase {
'Bomofo Ext' => 0x31b7,
'Lisu' => 0xa4fd,
'Yi' => 0xa48f,
- );
+ ];
// Generate characters consisting of starts, midpoints, and ends.
- $chars = array();
- $charcodes = array();
+ $chars = [];
+ $charcodes = [];
foreach ($starts as $key => $value) {
$charcodes[] = $starts[$key];
$chars[] = $this->code2utf($starts[$key]);
diff --git a/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php b/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php
index bcbc40e0dc7..a70114a6a92 100644
--- a/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php
+++ b/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php
@@ -35,20 +35,20 @@ class MigrateSearchPageTest extends MigrateDrupal6TestBase {
$search_page = SearchPage::load($id);
$this->assertIdentical($id, $search_page->id());
$configuration = $search_page->getPlugin()->getConfiguration();
- $this->assertIdentical($configuration['rankings'], array(
+ $this->assertIdentical($configuration['rankings'], [
'comments' => 5,
'promote' => 0,
'recent' => 0,
'relevance' => 2,
'sticky' => 8,
'views' => 1,
- ));
+ ]);
$this->assertIdentical('node', $search_page->getPath());
// Test that we can re-import using the EntitySearchPage destination.
Database::getConnection('default', 'migrate')
->update('variable')
- ->fields(array('value' => serialize(4)))
+ ->fields(['value' => serialize(4)])
->condition('name', 'node_rank_comments')
->execute();
diff --git a/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php b/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php
index d7dae3e8542..86d3b220092 100644
--- a/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php
+++ b/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php
@@ -18,7 +18,7 @@ class MigrateSearchPageTest extends MigrateDrupal7TestBase {
*
* {@inheritdoc}
*/
- public static $modules = array('node', 'search');
+ public static $modules = ['node', 'search'];
/**
* {@inheritdoc}
@@ -37,20 +37,20 @@ class MigrateSearchPageTest extends MigrateDrupal7TestBase {
$search_page = SearchPage::load($id);
$this->assertIdentical($id, $search_page->id());
$configuration = $search_page->getPlugin()->getConfiguration();
- $expected_rankings = array(
+ $expected_rankings = [
'comments' => 0,
'promote' => 0,
'relevance' => 2,
'sticky' => 0,
'views' => 0,
- );
+ ];
$this->assertIdentical($expected_rankings, $configuration['rankings']);
$this->assertIdentical('node', $search_page->getPath());
// Test that we can re-import using the EntitySearchPage destination.
Database::getConnection('default', 'migrate')
->update('variable')
- ->fields(array('value' => serialize(4)))
+ ->fields(['value' => serialize(4)])
->condition('name', 'node_rank_comments')
->execute();
diff --git a/core/modules/search/tests/src/Kernel/SearchExcerptTest.php b/core/modules/search/tests/src/Kernel/SearchExcerptTest.php
index 85c09174aaa..02844b01114 100644
--- a/core/modules/search/tests/src/Kernel/SearchExcerptTest.php
+++ b/core/modules/search/tests/src/Kernel/SearchExcerptTest.php
@@ -16,7 +16,7 @@ class SearchExcerptTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('search', 'search_langcode_test');
+ public static $modules = ['search', 'search_langcode_test'];
/**
* Tests search_excerpt() with several simulated search keywords.
diff --git a/core/modules/search/tests/src/Kernel/SearchMatchTest.php b/core/modules/search/tests/src/Kernel/SearchMatchTest.php
index 0a17f7173e6..13c926765e8 100644
--- a/core/modules/search/tests/src/Kernel/SearchMatchTest.php
+++ b/core/modules/search/tests/src/Kernel/SearchMatchTest.php
@@ -55,11 +55,11 @@ class SearchMatchTest extends KernelTestBase {
search_index(static::SEARCH_TYPE_2, $i + 7, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText2($i));
}
// No getText builder function for Japanese text; just a simple array.
- foreach (array(
+ foreach ([
13 => '以呂波耳・ほへとち。リヌルヲ。',
14 => 'ドルーパルが大好きよ!',
15 => 'コーヒーとケーキ',
- ) as $i => $jpn) {
+ ] as $i => $jpn) {
search_index(static::SEARCH_TYPE_JPN, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $jpn);
}
search_update_totals();
@@ -108,106 +108,106 @@ class SearchMatchTest extends KernelTestBase {
// is good, and
// dolore OR ut = (dolore) OR (ut)
// is bad. This is a design limitation to avoid full table scans.
- $queries = array(
+ $queries = [
// Simple AND queries.
- 'ipsum' => array(1),
- 'enim' => array(4, 5, 6),
- 'xxxxx' => array(),
- 'enim minim' => array(5, 6),
- 'enim xxxxx' => array(),
- 'dolore eu' => array(7),
- 'dolore xx' => array(),
- 'ut minim' => array(5),
- 'xx minim' => array(),
- 'enim veniam am minim ut' => array(5),
+ 'ipsum' => [1],
+ 'enim' => [4, 5, 6],
+ 'xxxxx' => [],
+ 'enim minim' => [5, 6],
+ 'enim xxxxx' => [],
+ 'dolore eu' => [7],
+ 'dolore xx' => [],
+ 'ut minim' => [5],
+ 'xx minim' => [],
+ 'enim veniam am minim ut' => [5],
// Simple OR and AND/OR queries.
- 'dolore OR ipsum' => array(1, 2, 7),
- 'dolore OR xxxxx' => array(2, 7),
- 'dolore OR ipsum OR enim' => array(1, 2, 4, 5, 6, 7),
- 'ipsum OR dolore sit OR cillum' => array(2, 7),
- 'minim dolore OR ipsum' => array(7),
- 'dolore OR ipsum veniam' => array(7),
- 'minim dolore OR ipsum OR enim' => array(5, 6, 7),
- 'dolore xx OR yy' => array(),
- 'xxxxx dolore OR ipsum' => array(),
+ 'dolore OR ipsum' => [1, 2, 7],
+ 'dolore OR xxxxx' => [2, 7],
+ 'dolore OR ipsum OR enim' => [1, 2, 4, 5, 6, 7],
+ 'ipsum OR dolore sit OR cillum' => [2, 7],
+ 'minim dolore OR ipsum' => [7],
+ 'dolore OR ipsum veniam' => [7],
+ 'minim dolore OR ipsum OR enim' => [5, 6, 7],
+ 'dolore xx OR yy' => [],
+ 'xxxxx dolore OR ipsum' => [],
// Sequence of OR queries.
- 'minim' => array(5, 6, 7),
- 'minim OR xxxx' => array(5, 6, 7),
- 'minim OR xxxx OR minim' => array(5, 6, 7),
- 'minim OR xxxx minim' => array(5, 6, 7),
- 'minim OR xxxx minim OR yyyy' => array(5, 6, 7),
- 'minim OR xxxx minim OR cillum' => array(6, 7, 5),
- 'minim OR xxxx minim OR xxxx' => array(5, 6, 7),
+ 'minim' => [5, 6, 7],
+ 'minim OR xxxx' => [5, 6, 7],
+ 'minim OR xxxx OR minim' => [5, 6, 7],
+ 'minim OR xxxx minim' => [5, 6, 7],
+ 'minim OR xxxx minim OR yyyy' => [5, 6, 7],
+ 'minim OR xxxx minim OR cillum' => [6, 7, 5],
+ 'minim OR xxxx minim OR xxxx' => [5, 6, 7],
// Negative queries.
- 'dolore -sit' => array(7),
- 'dolore -eu' => array(2),
- 'dolore -xxxxx' => array(2, 7),
- 'dolore -xx' => array(2, 7),
+ 'dolore -sit' => [7],
+ 'dolore -eu' => [2],
+ 'dolore -xxxxx' => [2, 7],
+ 'dolore -xx' => [2, 7],
// Phrase queries.
- '"dolore sit"' => array(2),
- '"sit dolore"' => array(),
- '"am minim veniam es"' => array(6, 7),
- '"minim am veniam es"' => array(),
+ '"dolore sit"' => [2],
+ '"sit dolore"' => [],
+ '"am minim veniam es"' => [6, 7],
+ '"minim am veniam es"' => [],
// Mixed queries.
- '"am minim veniam es" OR dolore' => array(2, 6, 7),
- '"minim am veniam es" OR "dolore sit"' => array(2),
- '"minim am veniam es" OR "sit dolore"' => array(),
- '"am minim veniam es" -eu' => array(6),
- '"am minim veniam" -"cillum dolore"' => array(5, 6),
- '"am minim veniam" -"dolore cillum"' => array(5, 6, 7),
- 'xxxxx "minim am veniam es" OR dolore' => array(),
- 'xx "minim am veniam es" OR dolore' => array()
- );
+ '"am minim veniam es" OR dolore' => [2, 6, 7],
+ '"minim am veniam es" OR "dolore sit"' => [2],
+ '"minim am veniam es" OR "sit dolore"' => [],
+ '"am minim veniam es" -eu' => [6],
+ '"am minim veniam" -"cillum dolore"' => [5, 6],
+ '"am minim veniam" -"dolore cillum"' => [5, 6, 7],
+ 'xxxxx "minim am veniam es" OR dolore' => [],
+ 'xx "minim am veniam es" OR dolore' => []
+ ];
foreach ($queries as $query => $results) {
$result = db_select('search_index', 'i')
->extend('Drupal\search\SearchQuery')
->searchExpression($query, static::SEARCH_TYPE)
->execute();
- $set = $result ? $result->fetchAll() : array();
+ $set = $result ? $result->fetchAll() : [];
$this->_testQueryMatching($query, $set, $results);
$this->_testQueryScores($query, $set, $results);
}
// These queries are run against the second index type, SEARCH_TYPE_2.
- $queries = array(
+ $queries = [
// Simple AND queries.
- 'ipsum' => array(),
- 'enim' => array(),
- 'enim minim' => array(),
- 'dear' => array(8),
- 'germany' => array(11, 12),
- );
+ 'ipsum' => [],
+ 'enim' => [],
+ 'enim minim' => [],
+ 'dear' => [8],
+ 'germany' => [11, 12],
+ ];
foreach ($queries as $query => $results) {
$result = db_select('search_index', 'i')
->extend('Drupal\search\SearchQuery')
->searchExpression($query, static::SEARCH_TYPE_2)
->execute();
- $set = $result ? $result->fetchAll() : array();
+ $set = $result ? $result->fetchAll() : [];
$this->_testQueryMatching($query, $set, $results);
$this->_testQueryScores($query, $set, $results);
}
// These queries are run against the third index type, SEARCH_TYPE_JPN.
- $queries = array(
+ $queries = [
// Simple AND queries.
- '呂波耳' => array(13),
- '以呂波耳' => array(13),
- 'ほへと ヌルヲ' => array(13),
- 'とちリ' => array(),
- 'ドルーパル' => array(14),
- 'パルが大' => array(14),
- 'コーヒー' => array(15),
- 'ヒーキ' => array(),
- );
+ '呂波耳' => [13],
+ '以呂波耳' => [13],
+ 'ほへと ヌルヲ' => [13],
+ 'とちリ' => [],
+ 'ドルーパル' => [14],
+ 'パルが大' => [14],
+ 'コーヒー' => [15],
+ 'ヒーキ' => [],
+ ];
foreach ($queries as $query => $results) {
$result = db_select('search_index', 'i')
->extend('Drupal\search\SearchQuery')
->searchExpression($query, static::SEARCH_TYPE_JPN)
->execute();
- $set = $result ? $result->fetchAll() : array();
+ $set = $result ? $result->fetchAll() : [];
$this->_testQueryMatching($query, $set, $results);
$this->_testQueryScores($query, $set, $results);
}
@@ -220,7 +220,7 @@ class SearchMatchTest extends KernelTestBase {
*/
function _testQueryMatching($query, $set, $results) {
// Get result IDs.
- $found = array();
+ $found = [];
foreach ($set as $item) {
$found[] = $item->sid;
}
@@ -238,7 +238,7 @@ class SearchMatchTest extends KernelTestBase {
*/
function _testQueryScores($query, $set, $results) {
// Get result scores.
- $scores = array();
+ $scores = [];
foreach ($set as $item) {
$scores[] = $item->calculated_score;
}
diff --git a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php
index d634207ba02..69dffd87cc8 100644
--- a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php
+++ b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php
@@ -75,14 +75,14 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue($this->query));
$this->query->expects($this->once())
->method('execute')
- ->will($this->returnValue(array('test' => 'test', 'other_test' => 'other_test')));
+ ->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
- $entities = array();
+ $entities = [];
$entities['test'] = $this->getMock('Drupal\search\SearchPageInterface');
$entities['other_test'] = $this->getMock('Drupal\search\SearchPageInterface');
$this->storage->expects($this->once())
->method('loadMultiple')
- ->with(array('test' => 'test', 'other_test' => 'other_test'))
+ ->with(['test' => 'test', 'other_test' => 'other_test'])
->will($this->returnValue($entities));
$result = $this->searchPageRepository->getActiveSearchPages();
@@ -103,7 +103,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue($this->query));
$this->query->expects($this->once())
->method('execute')
- ->will($this->returnValue(array('test' => 'test')));
+ ->will($this->returnValue(['test' => 'test']));
$this->assertSame(TRUE, $this->searchPageRepository->isSearchActive());
}
@@ -118,9 +118,9 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue($this->query));
$this->query->expects($this->once())
->method('execute')
- ->will($this->returnValue(array('test' => 'test', 'other_test' => 'other_test')));
+ ->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
- $entities = array();
+ $entities = [];
$entities['test'] = $this->getMock('Drupal\search\SearchPageInterface');
$entities['test']->expects($this->once())
->method('isIndexable')
@@ -131,7 +131,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue(FALSE));
$this->storage->expects($this->once())
->method('loadMultiple')
- ->with(array('test' => 'test', 'other_test' => 'other_test'))
+ ->with(['test' => 'test', 'other_test' => 'other_test'])
->will($this->returnValue($entities));
$result = $this->searchPageRepository->getIndexableSearchPages();
@@ -167,7 +167,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue($this->query));
$this->query->expects($this->once())
->method('execute')
- ->will($this->returnValue(array('test' => 'test', 'other_test' => 'other_test')));
+ ->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
$config = $this->getMockBuilder('Drupal\Core\Config\Config')
->disableOriginalConstructor()
@@ -194,7 +194,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue($this->query));
$this->query->expects($this->once())
->method('execute')
- ->will($this->returnValue(array('test' => 'test')));
+ ->will($this->returnValue(['test' => 'test']));
$config = $this->getMockBuilder('Drupal\Core\Config\Config')
->disableOriginalConstructor()
@@ -259,10 +259,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
// Declare entities out of their expected order so we can be sure they were
// sorted. We cannot mock these because of uasort(), see
// https://bugs.php.net/bug.php?id=50688.
- $unsorted_entities['test4'] = new TestSearchPage(array('weight' => 0, 'status' => FALSE, 'label' => 'Test4'));
- $unsorted_entities['test3'] = new TestSearchPage(array('weight' => 10, 'status' => TRUE, 'label' => 'Test3'));
- $unsorted_entities['test2'] = new TestSearchPage(array('weight' => 0, 'status' => TRUE, 'label' => 'Test2'));
- $unsorted_entities['test1'] = new TestSearchPage(array('weight' => 0, 'status' => TRUE, 'label' => 'Test1'));
+ $unsorted_entities['test4'] = new TestSearchPage(['weight' => 0, 'status' => FALSE, 'label' => 'Test4']);
+ $unsorted_entities['test3'] = new TestSearchPage(['weight' => 10, 'status' => TRUE, 'label' => 'Test3']);
+ $unsorted_entities['test2'] = new TestSearchPage(['weight' => 0, 'status' => TRUE, 'label' => 'Test2']);
+ $unsorted_entities['test1'] = new TestSearchPage(['weight' => 0, 'status' => TRUE, 'label' => 'Test1']);
$expected = $unsorted_entities;
ksort($expected);
diff --git a/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php b/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php
index 19221f26f13..25ab8735a61 100644
--- a/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php
+++ b/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php
@@ -37,7 +37,7 @@ class SearchPluginCollectionTest extends UnitTestCase {
*/
protected function setUp() {
$this->pluginManager = $this->getMock('Drupal\Component\Plugin\PluginManagerInterface');
- $this->searchPluginCollection = new SearchPluginCollection($this->pluginManager, 'banana', array('id' => 'banana', 'color' => 'yellow'), 'fruit_stand');
+ $this->searchPluginCollection = new SearchPluginCollection($this->pluginManager, 'banana', ['id' => 'banana', 'color' => 'yellow'], 'fruit_stand');
}
/**
diff --git a/core/modules/serialization/serialization.install b/core/modules/serialization/serialization.install
index 9f7c71eb135..6d45f3c9dae 100644
--- a/core/modules/serialization/serialization.install
+++ b/core/modules/serialization/serialization.install
@@ -12,10 +12,10 @@ function serialization_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
- $requirements['serialization_as_strings'] = array(
+ $requirements['serialization_as_strings'] = [
'title' => t('Serialized data types'),
'severity' => REQUIREMENT_INFO,
- );
+ ];
if (\Drupal::config('serialization.settings')->get('bc_primitives_as_strings')) {
$requirements['serialization_as_strings']['value'] = t('Enabled');
diff --git a/core/modules/serialization/serialization.module b/core/modules/serialization/serialization.module
index 39c5fbfa08f..4b2db100ba7 100644
--- a/core/modules/serialization/serialization.module
+++ b/core/modules/serialization/serialization.module
@@ -18,8 +18,8 @@ function serialization_help($route_name, RouteMatchInterface $route_match) {
$output .= '<p>' . t('The Serialization module provides a service for serializing and deserializing data to and from formats such as JSON and XML.') . '</p>';
$output .= '<p>' . t('Serialization is the process of converting data structures like arrays and objects into a string. This allows the data to be represented in a way that is easy to exchange and store (for example, for transmission over the Internet or for storage in a local file system). These representations can then be deserialized to get back to the original data structures.') . '</p>';
$output .= '<p>' . t('The serializer splits this process into two parts. Normalization converts an object to a normalized array structure. Encoding takes that array and converts it to a string.') . '</p>';
- $output .= '<p>' . t('This module does not have a user interface. It is used by other modules which need to serialize data, such as <a href=":rest">REST</a>.', array(':rest' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', array('name' => 'rest')) : '#')) . '</p>';
- $output .= '<p>' . t('For more information, see the <a href=":doc_url">online documentation for the Serialization module</a>.', array(':doc_url' => 'https://www.drupal.org/documentation/modules/serialization')) . '</p>';
+ $output .= '<p>' . t('This module does not have a user interface. It is used by other modules which need to serialize data, such as <a href=":rest">REST</a>.', [':rest' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', ['name' => 'rest']) : '#']) . '</p>';
+ $output .= '<p>' . t('For more information, see the <a href=":doc_url">online documentation for the Serialization module</a>.', [':doc_url' => 'https://www.drupal.org/documentation/modules/serialization']) . '</p>';
return $output;
}
}
diff --git a/core/modules/serialization/src/Encoder/JsonEncoder.php b/core/modules/serialization/src/Encoder/JsonEncoder.php
index 4a16a97eb6f..ad085ac00aa 100644
--- a/core/modules/serialization/src/Encoder/JsonEncoder.php
+++ b/core/modules/serialization/src/Encoder/JsonEncoder.php
@@ -18,7 +18,7 @@ class JsonEncoder extends BaseJsonEncoder implements EncoderInterface, DecoderIn
*
* @var array
*/
- protected static $format = array('json', 'ajax');
+ protected static $format = ['json', 'ajax'];
/**
* {@inheritdoc}
diff --git a/core/modules/serialization/src/Encoder/XmlEncoder.php b/core/modules/serialization/src/Encoder/XmlEncoder.php
index abd78968a36..5582713565a 100644
--- a/core/modules/serialization/src/Encoder/XmlEncoder.php
+++ b/core/modules/serialization/src/Encoder/XmlEncoder.php
@@ -19,7 +19,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface {
*
* @var array
*/
- static protected $format = array('xml');
+ static protected $format = ['xml'];
/**
* An instance of the Symfony XmlEncoder to perform the actual encoding.
@@ -54,7 +54,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface {
/**
* {@inheritdoc}
*/
- public function encode($data, $format, array $context = array()){
+ public function encode($data, $format, array $context = []){
return $this->getBaseEncoder()->encode($data, $format, $context);
}
@@ -68,7 +68,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface {
/**
* {@inheritdoc}
*/
- public function decode($data, $format, array $context = array()){
+ public function decode($data, $format, array $context = []){
return $this->getBaseEncoder()->decode($data, $format, $context);
}
diff --git a/core/modules/serialization/src/EntityResolver/ChainEntityResolver.php b/core/modules/serialization/src/EntityResolver/ChainEntityResolver.php
index 6ab879450bc..7f24901f7f6 100644
--- a/core/modules/serialization/src/EntityResolver/ChainEntityResolver.php
+++ b/core/modules/serialization/src/EntityResolver/ChainEntityResolver.php
@@ -14,7 +14,7 @@ class ChainEntityResolver implements ChainEntityResolverInterface {
*
* @var \Drupal\serialization\EntityResolver\EntityResolverInterface[]
*/
- protected $resolvers = array();
+ protected $resolvers = [];
/**
* Constructs a ChainEntityResolver object.
@@ -22,7 +22,7 @@ class ChainEntityResolver implements ChainEntityResolverInterface {
* @param \Drupal\serialization\EntityResolver\EntityResolverInterface[] $resolvers
* The array of concrete resolvers.
*/
- public function __construct(array $resolvers = array()) {
+ public function __construct(array $resolvers = []) {
$this->resolvers = $resolvers;
}
diff --git a/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php b/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php
index ef07d1185cb..3d2031218f1 100644
--- a/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php
@@ -24,8 +24,8 @@ class ComplexDataNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
- $attributes = array();
+ public function normalize($object, $format = NULL, array $context = []) {
+ $attributes = [];
/** @var \Drupal\Core\TypedData\TypedDataInterface $field */
foreach ($object as $name => $field) {
$attributes[$name] = $this->serializer->normalize($field, $format, $context);
diff --git a/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php b/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php
index d17005c172c..344bcc3387b 100644
--- a/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php
@@ -12,12 +12,12 @@ class ConfigEntityNormalizer extends EntityNormalizer {
*
* @var array
*/
- protected $supportedInterfaceOrClass = array('Drupal\Core\Config\Entity\ConfigEntityInterface');
+ protected $supportedInterfaceOrClass = ['Drupal\Core\Config\Entity\ConfigEntityInterface'];
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
+ public function normalize($object, $format = NULL, array $context = []) {
return $object->toArray();
}
diff --git a/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php
index b47eeef6cc9..f1ca82d5497 100644
--- a/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php
@@ -15,10 +15,10 @@ class ContentEntityNormalizer extends EntityNormalizer {
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
- $context += array(
+ public function normalize($object, $format = NULL, array $context = []) {
+ $context += [
'account' => NULL,
- );
+ ];
$attributes = [];
foreach ($object as $name => $field) {
diff --git a/core/modules/serialization/src/Normalizer/FieldItemNormalizer.php b/core/modules/serialization/src/Normalizer/FieldItemNormalizer.php
index a3cfcf206f5..decca432278 100644
--- a/core/modules/serialization/src/Normalizer/FieldItemNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/FieldItemNormalizer.php
@@ -19,7 +19,7 @@ class FieldItemNormalizer extends ComplexDataNormalizer implements DenormalizerI
/**
* {@inheritdoc}
*/
- public function denormalize($data, $class, $format = NULL, array $context = array()) {
+ public function denormalize($data, $class, $format = NULL, array $context = []) {
if (!isset($context['target_instance'])) {
throw new InvalidArgumentException('$context[\'target_instance\'] must be set to denormalize with the FieldItemNormalizer');
}
diff --git a/core/modules/serialization/src/Normalizer/FieldNormalizer.php b/core/modules/serialization/src/Normalizer/FieldNormalizer.php
index 6a0ad8f5ae2..a5051cfb414 100644
--- a/core/modules/serialization/src/Normalizer/FieldNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/FieldNormalizer.php
@@ -26,7 +26,7 @@ class FieldNormalizer extends ListNormalizer implements DenormalizerInterface {
/**
* {@inheritdoc}
*/
- public function denormalize($data, $class, $format = NULL, array $context = array()) {
+ public function denormalize($data, $class, $format = NULL, array $context = []) {
if (!isset($context['target_instance'])) {
throw new InvalidArgumentException('$context[\'target_instance\'] must be set to denormalize with the FieldNormalizer');
}
diff --git a/core/modules/serialization/src/Normalizer/ListNormalizer.php b/core/modules/serialization/src/Normalizer/ListNormalizer.php
index 1729cfce849..471886e872d 100644
--- a/core/modules/serialization/src/Normalizer/ListNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/ListNormalizer.php
@@ -23,8 +23,8 @@ class ListNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
- $attributes = array();
+ public function normalize($object, $format = NULL, array $context = []) {
+ $attributes = [];
foreach ($object as $fieldItem) {
$attributes[] = $this->serializer->normalize($fieldItem, $format, $context);
}
diff --git a/core/modules/serialization/src/Normalizer/MarkupNormalizer.php b/core/modules/serialization/src/Normalizer/MarkupNormalizer.php
index 9cb3cd9ca78..f4c197b6920 100644
--- a/core/modules/serialization/src/Normalizer/MarkupNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/MarkupNormalizer.php
@@ -12,12 +12,12 @@ class MarkupNormalizer extends NormalizerBase {
*
* @var array
*/
- protected $supportedInterfaceOrClass = array('Drupal\Component\Render\MarkupInterface');
+ protected $supportedInterfaceOrClass = ['Drupal\Component\Render\MarkupInterface'];
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
+ public function normalize($object, $format = NULL, array $context = []) {
return (string) $object;
}
diff --git a/core/modules/serialization/src/Normalizer/NullNormalizer.php b/core/modules/serialization/src/Normalizer/NullNormalizer.php
index c6a8de5ff52..dbc61f78100 100644
--- a/core/modules/serialization/src/Normalizer/NullNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/NullNormalizer.php
@@ -20,7 +20,7 @@ class NullNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
+ public function normalize($object, $format = NULL, array $context = []) {
return NULL;
}
diff --git a/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php b/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php
index 53a62df4e92..60ce7d08f69 100644
--- a/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php
+++ b/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php
@@ -17,7 +17,7 @@ class TypedDataNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
+ public function normalize($object, $format = NULL, array $context = []) {
return $object->getValue();
}
diff --git a/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php b/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php
index 90a2c26a0f6..47c2be03446 100644
--- a/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php
+++ b/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php
@@ -19,7 +19,7 @@ class RegisterEntityResolversCompilerPass implements CompilerPassInterface {
*/
public function process(ContainerBuilder $container) {
$definition = $container->getDefinition('serializer.entity_resolver');
- $resolvers = array();
+ $resolvers = [];
// Retrieve registered Normalizers and Encoders from the container.
foreach ($container->findTaggedServiceIds('entity_resolver') as $id => $attributes) {
@@ -29,7 +29,7 @@ class RegisterEntityResolversCompilerPass implements CompilerPassInterface {
// Add the registered concrete EntityResolvers to the ChainEntityResolver.
foreach ($this->sort($resolvers) as $resolver) {
- $definition->addMethodCall('addResolver', array($resolver));
+ $definition->addMethodCall('addResolver', [$resolver]);
}
}
@@ -48,7 +48,7 @@ class RegisterEntityResolversCompilerPass implements CompilerPassInterface {
* to low priority.
*/
protected function sort($services) {
- $sorted = array();
+ $sorted = [];
krsort($services);
// Flatten the array.
diff --git a/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php b/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php
index 7110056f60f..10474d17e33 100644
--- a/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php
+++ b/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php
@@ -46,7 +46,7 @@ class RegisterSerializationClassesCompilerPass implements CompilerPassInterface
}
// Find all serialization formats known.
- $formats = array();
+ $formats = [];
$format_providers = [];
foreach ($container->findTaggedServiceIds('encoder') as $service_id => $attributes) {
$format = $attributes[0]['format'];
@@ -87,7 +87,7 @@ class RegisterSerializationClassesCompilerPass implements CompilerPassInterface
* to low priority.
*/
protected function sort($services) {
- $sorted = array();
+ $sorted = [];
krsort($services);
// Flatten the array.
diff --git a/core/modules/serialization/tests/modules/field_normalization_test/src/Normalization/TextItemSillyNormalizer.php b/core/modules/serialization/tests/modules/field_normalization_test/src/Normalization/TextItemSillyNormalizer.php
index 7187bdf2673..45438f4074d 100644
--- a/core/modules/serialization/tests/modules/field_normalization_test/src/Normalization/TextItemSillyNormalizer.php
+++ b/core/modules/serialization/tests/modules/field_normalization_test/src/Normalization/TextItemSillyNormalizer.php
@@ -18,7 +18,7 @@ class TextItemSillyNormalizer extends FieldItemNormalizer {
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
+ public function normalize($object, $format = NULL, array $context = []) {
$data = parent::normalize($object, $format, $context);
$data['value'] .= '::silly_suffix';
return $data;
diff --git a/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php b/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php
index 0eb9aa5d9d4..165e978580e 100644
--- a/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php
+++ b/core/modules/serialization/tests/serialization_test/src/SerializationTestEncoder.php
@@ -16,7 +16,7 @@ class SerializationTestEncoder implements EncoderInterface {
/**
* {@inheritdoc}
*/
- public function encode($data, $format, array $context = array()) {
+ public function encode($data, $format, array $context = []) {
// @see \Drupal\serialization_test\SerializationTestNormalizer::normalize().
return 'Normalized by ' . $data['normalized_by'] . ', Encoded by SerializationTestEncoder';
}
diff --git a/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php b/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php
index 16775534f6b..2105adf5981 100644
--- a/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php
+++ b/core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php
@@ -25,7 +25,7 @@ class SerializationTestNormalizer implements NormalizerInterface {
* An array containing a normalized representation of $object, appropriate
* for encoding to the requested format.
*/
- public function normalize($object, $format = NULL, array $context = array()) {
+ public function normalize($object, $format = NULL, array $context = []) {
$normalized = (array) $object;
// Add identifying value that can be used to verify that the expected
// normalizer was invoked.
diff --git a/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php b/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php
index ec94028f390..a470d98a740 100644
--- a/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php
+++ b/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php
@@ -34,14 +34,14 @@ class EntityResolverTest extends NormalizerTestBase {
\Drupal::service('router.builder')->rebuild();
// Create the test field storage.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_entity_reference',
'type' => 'entity_reference',
- 'settings' => array(
+ 'settings' => [
'target_type' => 'entity_test_mulrev',
- ),
- ))->save();
+ ],
+ ])->save();
// Create the test field.
FieldConfig::create([
@@ -56,39 +56,39 @@ class EntityResolverTest extends NormalizerTestBase {
*/
function testUuidEntityResolver() {
// Create an entity to get the UUID from.
- $entity = EntityTestMulRev::create(array('type' => 'entity_test_mulrev'));
+ $entity = EntityTestMulRev::create(['type' => 'entity_test_mulrev']);
$entity->set('name', 'foobar');
- $entity->set('field_test_entity_reference', array(array('target_id' => 1)));
+ $entity->set('field_test_entity_reference', [['target_id' => 1]]);
$entity->save();
- $field_uri = Url::fromUri('base:rest/relation/entity_test_mulrev/entity_test_mulrev/field_test_entity_reference', array('absolute' => TRUE))->toString();
+ $field_uri = Url::fromUri('base:rest/relation/entity_test_mulrev/entity_test_mulrev/field_test_entity_reference', ['absolute' => TRUE])->toString();
- $data = array(
- '_links' => array(
- 'type' => array(
- 'href' => Url::fromUri('base:rest/type/entity_test_mulrev/entity_test_mulrev', array('absolute' => TRUE))->toString(),
- ),
- $field_uri => array(
- array(
+ $data = [
+ '_links' => [
+ 'type' => [
+ 'href' => Url::fromUri('base:rest/type/entity_test_mulrev/entity_test_mulrev', ['absolute' => TRUE])->toString(),
+ ],
+ $field_uri => [
+ [
'href' => $entity->url(),
- ),
- ),
- ),
- '_embedded' => array(
- $field_uri => array(
- array(
- '_links' => array(
+ ],
+ ],
+ ],
+ '_embedded' => [
+ $field_uri => [
+ [
+ '_links' => [
'self' => $entity->url(),
- ),
- 'uuid' => array(
- array(
+ ],
+ 'uuid' => [
+ [
'value' => $entity->uuid(),
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
$denormalized = $this->container->get('serializer')->denormalize($data, 'Drupal\entity_test\Entity\EntityTestMulRev', $this->format);
$field_value = $denormalized->get('field_test_entity_reference')->getValue();
diff --git a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
index d29f4937f02..71fa6b3ec58 100644
--- a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
+++ b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
@@ -17,7 +17,7 @@ class EntitySerializationTest extends NormalizerTestBase {
*
* @var array
*/
- public static $modules = array('serialization', 'system', 'field', 'entity_test', 'text', 'filter', 'user', 'entity_serialization_test');
+ public static $modules = ['serialization', 'system', 'field', 'entity_test', 'text', 'filter', 'user', 'entity_serialization_test'];
/**
* The test values.
@@ -58,7 +58,7 @@ class EntitySerializationTest extends NormalizerTestBase {
parent::setUp();
// User create needs sequence table.
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
// Create a test user to use as the entity owner.
$this->user = \Drupal::entityManager()->getStorage('user')->create([
@@ -69,75 +69,75 @@ class EntitySerializationTest extends NormalizerTestBase {
$this->user->save();
// Create a test entity to serialize.
- $this->values = array(
+ $this->values = [
'name' => $this->randomMachineName(),
'user_id' => $this->user->id(),
- 'field_test_text' => array(
+ 'field_test_text' => [
'value' => $this->randomMachineName(),
'format' => 'full_html',
- ),
- );
+ ],
+ ];
$this->entity = EntityTestMulRev::create($this->values);
$this->entity->save();
$this->serializer = $this->container->get('serializer');
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
}
/**
* Test the normalize function.
*/
public function testNormalize() {
- $expected = array(
- 'id' => array(
- array('value' => 1),
- ),
- 'uuid' => array(
- array('value' => $this->entity->uuid()),
- ),
- 'langcode' => array(
- array('value' => 'en'),
- ),
- 'name' => array(
- array('value' => $this->values['name']),
- ),
- 'type' => array(
- array('value' => 'entity_test_mulrev'),
- ),
- 'created' => array(
- array('value' => $this->entity->created->value),
- ),
- 'user_id' => array(
- array(
+ $expected = [
+ 'id' => [
+ ['value' => 1],
+ ],
+ 'uuid' => [
+ ['value' => $this->entity->uuid()],
+ ],
+ 'langcode' => [
+ ['value' => 'en'],
+ ],
+ 'name' => [
+ ['value' => $this->values['name']],
+ ],
+ 'type' => [
+ ['value' => 'entity_test_mulrev'],
+ ],
+ 'created' => [
+ ['value' => $this->entity->created->value],
+ ],
+ 'user_id' => [
+ [
// id() will return the string value as it comes from the database.
'target_id' => (int) $this->user->id(),
'target_type' => $this->user->getEntityTypeId(),
'target_uuid' => $this->user->uuid(),
'url' => $this->user->url(),
- ),
- ),
- 'revision_id' => array(
- array('value' => 1),
- ),
- 'default_langcode' => array(
- array('value' => TRUE),
- ),
- 'non_rev_field' => array(),
- 'field_test_text' => array(
- array(
+ ],
+ ],
+ 'revision_id' => [
+ ['value' => 1],
+ ],
+ 'default_langcode' => [
+ ['value' => TRUE],
+ ],
+ 'non_rev_field' => [],
+ 'field_test_text' => [
+ [
'value' => $this->values['field_test_text']['value'],
'format' => $this->values['field_test_text']['format'],
- ),
- ),
- );
+ ],
+ ],
+ ];
$normalized = $this->serializer->normalize($this->entity);
foreach (array_keys($expected) as $fieldName) {
$this->assertSame($expected[$fieldName], $normalized[$fieldName], "Normalization produces expected array for $fieldName.");
}
- $this->assertEqual(array_diff_key($normalized, $expected), array(), 'No unexpected data is added to the normalized array.');
+ $this->assertEqual(array_diff_key($normalized, $expected), [], 'No unexpected data is added to the normalized array.');
}
/**
@@ -182,7 +182,7 @@ class EntitySerializationTest extends NormalizerTestBase {
// Generate the expected xml in a way that allows changes to entity property
// order.
- $expected = array(
+ $expected = [
'id' => '<id><value>' . $this->entity->id() . '</value></id>',
'uuid' => '<uuid><value>' . $this->entity->uuid() . '</value></uuid>',
'langcode' => '<langcode><value>en</value></langcode>',
@@ -194,7 +194,7 @@ class EntitySerializationTest extends NormalizerTestBase {
'default_langcode' => '<default_langcode><value>1</value></default_langcode>',
'non_rev_field' => '<non_rev_field/>',
'field_test_text' => '<field_test_text><value>' . $this->values['field_test_text']['value'] . '</value><format>' . $this->values['field_test_text']['format'] . '</format></field_test_text>',
- );
+ ];
// Sort it in the same order as normalised.
$expected = array_merge($normalized, $expected);
// Add header and footer.
@@ -215,9 +215,9 @@ class EntitySerializationTest extends NormalizerTestBase {
public function testDenormalize() {
$normalized = $this->serializer->normalize($this->entity);
- foreach (array('json', 'xml') as $type) {
- $denormalized = $this->serializer->denormalize($normalized, $this->entityClass, $type, array('entity_type' => 'entity_test_mulrev'));
- $this->assertTrue($denormalized instanceof $this->entityClass, SafeMarkup::format('Denormalized entity is an instance of @class', array('@class' => $this->entityClass)));
+ foreach (['json', 'xml'] as $type) {
+ $denormalized = $this->serializer->denormalize($normalized, $this->entityClass, $type, ['entity_type' => 'entity_test_mulrev']);
+ $this->assertTrue($denormalized instanceof $this->entityClass, SafeMarkup::format('Denormalized entity is an instance of @class', ['@class' => $this->entityClass]));
$this->assertIdentical($denormalized->getEntityTypeId(), $this->entity->getEntityTypeId(), 'Expected entity type found.');
$this->assertIdentical($denormalized->bundle(), $this->entity->bundle(), 'Expected entity bundle found.');
$this->assertIdentical($denormalized->uuid(), $this->entity->uuid(), 'Expected entity UUID found.');
diff --git a/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php b/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php
index b9f0425fae3..3e41d630374 100644
--- a/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php
+++ b/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php
@@ -17,7 +17,7 @@ class FieldItemSerializationTest extends NormalizerTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('serialization', 'system', 'field', 'entity_test', 'text', 'filter', 'user', 'field_normalization_test');
+ public static $modules = ['serialization', 'system', 'field', 'entity_test', 'text', 'filter', 'user', 'field_normalization_test'];
/**
* The class name of the test class.
@@ -54,14 +54,14 @@ class FieldItemSerializationTest extends NormalizerTestBase {
parent::setUp();
// Auto-create a field for testing default field values.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_text_default',
'type' => 'text',
'cardinality' => 1,
'translatable' => FALSE,
- ))->save();
- FieldConfig::create(array(
+ ])->save();
+ FieldConfig::create([
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_text_default',
'bundle' => 'entity_test_mulrev',
@@ -72,26 +72,26 @@ class FieldItemSerializationTest extends NormalizerTestBase {
'format' => 'full_html',
],
],
- 'widget' => array(
+ 'widget' => [
'type' => 'text_textfield',
'weight' => 0,
- ),
- ))->save();
+ ],
+ ])->save();
// Create a test entity to serialize.
- $this->values = array(
+ $this->values = [
'name' => $this->randomMachineName(),
- 'field_test_text' => array(
+ 'field_test_text' => [
'value' => $this->randomMachineName(),
'format' => 'full_html',
- ),
- );
+ ],
+ ];
$this->entity = EntityTestMulRev::create($this->values);
$this->entity->save();
$this->serializer = $this->container->get('serializer');
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
}
/**
diff --git a/core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php b/core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php
index 7706b6d1781..25299b16f02 100644
--- a/core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php
+++ b/core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php
@@ -16,35 +16,35 @@ abstract class NormalizerTestBase extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('serialization', 'system', 'field', 'entity_test', 'text', 'filter', 'user');
+ public static $modules = ['serialization', 'system', 'field', 'entity_test', 'text', 'filter', 'user'];
protected function setUp() {
parent::setUp();
$this->installEntitySchema('entity_test_mulrev');
$this->installEntitySchema('user');
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
\Drupal::service('router.builder')->rebuild();
\Drupal::moduleHandler()->invoke('rest', 'install');
// Auto-create a field for testing.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_text',
'type' => 'text',
'cardinality' => 1,
'translatable' => FALSE,
- ))->save();
- FieldConfig::create(array(
+ ])->save();
+ FieldConfig::create([
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_text',
'bundle' => 'entity_test_mulrev',
'label' => 'Test text-field',
- 'widget' => array(
+ 'widget' => [
'type' => 'text_textfield',
'weight' => 0,
- ),
- ))->save();
+ ],
+ ])->save();
}
}
diff --git a/core/modules/serialization/tests/src/Kernel/SerializationTest.php b/core/modules/serialization/tests/src/Kernel/SerializationTest.php
index 8b700a32813..a7ad145e657 100644
--- a/core/modules/serialization/tests/src/Kernel/SerializationTest.php
+++ b/core/modules/serialization/tests/src/Kernel/SerializationTest.php
@@ -17,7 +17,7 @@ class SerializationTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('serialization', 'serialization_test');
+ public static $modules = ['serialization', 'serialization_test'];
/**
* The serializer service to test.
diff --git a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
index ea38aa991cc..88c7a1d8ea1 100644
--- a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
+++ b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
@@ -28,7 +28,7 @@ class XmlEncoderTest extends UnitTestCase {
*
* @var array
*/
- protected $testArray = array('test' => 'test');
+ protected $testArray = ['test' => 'test'];
protected function setUp() {
$this->baseEncoder = $this->getMock('Symfony\Component\Serializer\Encoder\XmlEncoder');
@@ -58,7 +58,7 @@ class XmlEncoderTest extends UnitTestCase {
public function testEncode() {
$this->baseEncoder->expects($this->once())
->method('encode')
- ->with($this->testArray, 'test', array())
+ ->with($this->testArray, 'test', [])
->will($this->returnValue('test'));
$this->assertEquals('test', $this->encoder->encode($this->testArray, 'test'));
@@ -70,7 +70,7 @@ class XmlEncoderTest extends UnitTestCase {
public function testDecode() {
$this->baseEncoder->expects($this->once())
->method('decode')
- ->with('test', 'test', array())
+ ->with('test', 'test', [])
->will($this->returnValue($this->testArray));
$this->assertEquals($this->testArray, $this->encoder->decode('test', 'test'));
diff --git a/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php b/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
index 38819e11e54..64e73b693d3 100644
--- a/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
+++ b/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
@@ -47,10 +47,10 @@ class ChainEntityResolverTest extends UnitTestCase {
* @covers ::resolve
*/
public function testResolverWithNoneResolved() {
- $resolvers = array(
+ $resolvers = [
$this->createEntityResolverMock(),
$this->createEntityResolverMock(),
- );
+ ];
$resolver = new ChainEntityResolver($resolvers);
@@ -78,10 +78,10 @@ class ChainEntityResolverTest extends UnitTestCase {
* @covers ::resolve
*/
public function testResolverWithFirstResolved() {
- $resolvers = array(
+ $resolvers = [
$this->createEntityResolverMock(10),
$this->createEntityResolverMock(NULL, FALSE),
- );
+ ];
$resolver = new ChainEntityResolver($resolvers);
@@ -95,10 +95,10 @@ class ChainEntityResolverTest extends UnitTestCase {
* @covers ::resolve
*/
public function testResolverWithLastResolved() {
- $resolvers = array(
+ $resolvers = [
$this->createEntityResolverMock(),
$this->createEntityResolverMock(10),
- );
+ ];
$resolver = new ChainEntityResolver($resolvers);
@@ -112,10 +112,10 @@ class ChainEntityResolverTest extends UnitTestCase {
* @covers ::resolve
*/
public function testResolverWithResolvedToZero() {
- $resolvers = array(
+ $resolvers = [
$this->createEntityResolverMock(0),
$this->createEntityResolverMock(NULL, FALSE),
- );
+ ];
$resolver = new ChainEntityResolver($resolvers);
diff --git a/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php b/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php
index a05d417a9b7..812392568a6 100644
--- a/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php
+++ b/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php
@@ -44,7 +44,7 @@ class UuidResolverTest extends UnitTestCase {
->method('loadEntityByUuid');
$normalizer = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
- $this->assertNull($this->resolver->resolve($normalizer, array(), 'test_type'));
+ $this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
}
/**
@@ -57,9 +57,9 @@ class UuidResolverTest extends UnitTestCase {
$normalizer = $this->getMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once())
->method('getUuid')
- ->with(array())
+ ->with([])
->will($this->returnValue(NULL));
- $this->assertNull($this->resolver->resolve($normalizer, array(), 'test_type'));
+ $this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
}
/**
@@ -76,10 +76,10 @@ class UuidResolverTest extends UnitTestCase {
$normalizer = $this->getMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once())
->method('getUuid')
- ->with(array())
+ ->with([])
->will($this->returnValue($uuid));
- $this->assertNull($this->resolver->resolve($normalizer, array(), 'test_type'));
+ $this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
}
/**
@@ -101,9 +101,9 @@ class UuidResolverTest extends UnitTestCase {
$normalizer = $this->getMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once())
->method('getUuid')
- ->with(array())
+ ->with([])
->will($this->returnValue($uuid));
- $this->assertSame(1, $this->resolver->resolve($normalizer, array(), 'test_type'));
+ $this->assertSame(1, $this->resolver->resolve($normalizer, [], 'test_type'));
}
}
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php
index ec9a4d07ce2..371450a5025 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php
@@ -17,7 +17,7 @@ class ConfigEntityNormalizerTest extends UnitTestCase {
* @covers ::normalize
*/
public function testNormalize() {
- $test_export_properties = array('test' => 'test');
+ $test_export_properties = ['test' => 'test'];
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$normalizer = new ConfigEntityNormalizer($entity_manager);
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
index 9613fdbb9ed..4beecf420db 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
@@ -40,7 +40,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
$this->contentEntityNormalizer = new ContentEntityNormalizer($this->entityManager);
$this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')
->disableOriginalConstructor()
- ->setMethods(array('normalize'))
+ ->setMethods(['normalize'])
->getMock();
$this->contentEntityNormalizer->setSerializer($this->serializer);
}
@@ -66,10 +66,10 @@ class ContentEntityNormalizerTest extends UnitTestCase {
->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', ['account' => NULL])
->will($this->returnValue('test'));
- $definitions = array(
+ $definitions = [
'field_1' => $this->createMockFieldListItem(),
'field_2' => $this->createMockFieldListItem(FALSE),
- );
+ ];
$content_entity_mock = $this->createMockForContentEntity($definitions);
$normalized = $this->contentEntityNormalizer->normalize($content_entity_mock, 'test_format');
@@ -98,10 +98,10 @@ class ContentEntityNormalizerTest extends UnitTestCase {
// The mock account should get passed directly into the access() method on
// field items from $context['account'].
- $definitions = array(
+ $definitions = [
'field_1' => $this->createMockFieldListItem(TRUE, $mock_account),
'field_2' => $this->createMockFieldListItem(FALSE, $mock_account),
- );
+ ];
$content_entity_mock = $this->createMockForContentEntity($definitions);
$normalized = $this->contentEntityNormalizer->normalize($content_entity_mock, 'test_format', $context);
@@ -121,7 +121,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
public function createMockForContentEntity($definitions) {
$content_entity_mock = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
->disableOriginalConstructor()
- ->setMethods(array('getFields'))
+ ->setMethods(['getFields'])
->getMockForAbstractClass();
$content_entity_mock->expects($this->once())
->method('getFields')
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
index b3b2780fd01..eb894cafc0f 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
@@ -51,14 +51,14 @@ class EntityNormalizerTest extends UnitTestCase {
$list_item_1 = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$list_item_2 = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
- $definitions = array(
+ $definitions = [
'field_1' => $list_item_1,
'field_2' => $list_item_2,
- );
+ ];
$content_entity = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
->disableOriginalConstructor()
- ->setMethods(array('getFields'))
+ ->setMethods(['getFields'])
->getMockForAbstractClass();
$content_entity->expects($this->once())
->method('getFields')
@@ -66,7 +66,7 @@ class EntityNormalizerTest extends UnitTestCase {
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')
->disableOriginalConstructor()
- ->setMethods(array('normalize'))
+ ->setMethods(['normalize'])
->getMock();
$serializer->expects($this->at(0))
->method('normalize')
@@ -88,7 +88,7 @@ class EntityNormalizerTest extends UnitTestCase {
* @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
*/
public function testDenormalizeWithNoEntityType() {
- $this->entityNormalizer->denormalize(array(), 'Drupal\Core\Entity\ContentEntityBase');
+ $this->entityNormalizer->denormalize([], 'Drupal\Core\Entity\ContentEntityBase');
}
/**
@@ -180,9 +180,9 @@ class EntityNormalizerTest extends UnitTestCase {
$storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
// Create should only be called with the bundle property at first.
- $expected_test_data = array(
+ $expected_test_data = [
'test_type' => 'test_bundle',
- );
+ ];
$storage->expects($this->once())
->method('create')
@@ -198,7 +198,7 @@ class EntityNormalizerTest extends UnitTestCase {
// item.
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')
->disableOriginalConstructor()
- ->setMethods(array('denormalize'))
+ ->setMethods(['denormalize'])
->getMock();
$serializer->expects($this->at(0))
->method('denormalize')
@@ -297,10 +297,10 @@ class EntityNormalizerTest extends UnitTestCase {
* @covers ::denormalize
*/
public function testDenormalizeWithNoBundle() {
- $test_data = array(
+ $test_data = [
'key_1' => 'value_1',
'key_2' => 'value_2',
- );
+ ];
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->once())
@@ -329,7 +329,7 @@ class EntityNormalizerTest extends UnitTestCase {
$this->entityManager->expects($this->never())
->method('getBaseFieldDefinitions');
- $this->assertNotNull($this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, array('entity_type' => 'test')));
+ $this->assertNotNull($this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, ['entity_type' => 'test']));
}
}
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php
index bbc7c110309..fccc6dbaa0d 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php
@@ -34,7 +34,7 @@ class ListNormalizerTest extends UnitTestCase {
*
* @var array
*/
- protected $expectedListValues = array('test', 'test', 'test');
+ protected $expectedListValues = ['test', 'test', 'test'];
/**
* The mocked typed data.
@@ -54,7 +54,7 @@ class ListNormalizerTest extends UnitTestCase {
// Set up a mock container as ItemList() will call for the 'typed_data_manager'
// service.
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
- ->setMethods(array('get'))
+ ->setMethods(['get'])
->getMock();
$container->expects($this->any())
->method('get')
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php
index e77882ace90..f5e8f0f7b5e 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php
@@ -45,20 +45,20 @@ class NormalizerBaseTest extends UnitTestCase {
* An array of provider data for testSupportsNormalization.
*/
public function providerTestSupportsNormalization() {
- return array(
+ return [
// Something that is not an object should return FALSE immediately.
- array(FALSE, array()),
+ [FALSE, []],
// An object with no class set should return FALSE.
- array(FALSE, new \stdClass()),
+ [FALSE, new \stdClass()],
// Set a supported Class.
- array(TRUE, new \stdClass(), 'stdClass'),
+ [TRUE, new \stdClass(), 'stdClass'],
// Set a supported interface.
- array(TRUE, new \RecursiveArrayIterator(), 'RecursiveIterator'),
+ [TRUE, new \RecursiveArrayIterator(), 'RecursiveIterator'],
// Set a different class.
- array(FALSE, new \stdClass(), 'ArrayIterator'),
+ [FALSE, new \stdClass(), 'ArrayIterator'],
// Set a different interface.
- array(FALSE, new \stdClass(), 'RecursiveIterator'),
- );
+ [FALSE, new \stdClass(), 'RecursiveIterator'],
+ ];
}
}
diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install
index 8df408fe914..21ebf519422 100644
--- a/core/modules/shortcut/shortcut.install
+++ b/core/modules/shortcut/shortcut.install
@@ -9,39 +9,39 @@
* Implements hook_schema().
*/
function shortcut_schema() {
- $schema['shortcut_set_users'] = array(
+ $schema['shortcut_set_users'] = [
'description' => 'Maps users to shortcut sets.',
- 'fields' => array(
- 'uid' => array(
+ 'fields' => [
+ 'uid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid for this set.',
- ),
- 'set_name' => array(
+ ],
+ 'set_name' => [
'type' => 'varchar_ascii',
'length' => 32,
'not null' => TRUE,
'default' => '',
'description' => "The {shortcut_set}.set_name that will be displayed for this user.",
- ),
- ),
- 'primary key' => array('uid'),
- 'indexes' => array(
- 'set_name' => array('set_name'),
- ),
- 'foreign keys' => array(
- 'set_user' => array(
+ ],
+ ],
+ 'primary key' => ['uid'],
+ 'indexes' => [
+ 'set_name' => ['set_name'],
+ ],
+ 'foreign keys' => [
+ 'set_user' => [
'table' => 'users',
- 'columns' => array('uid' => 'uid'),
- ),
- 'set_name' => array(
+ 'columns' => ['uid' => 'uid'],
+ ],
+ 'set_name' => [
'table' => 'shortcut_set',
- 'columns' => array('set_name' => 'set_name'),
- ),
- ),
- );
+ 'columns' => ['set_name' => 'set_name'],
+ ],
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index b7294ad65ff..156b4914c55 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -20,16 +20,16 @@ function shortcut_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.shortcut':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href=":shortcut">online documentation for the Shortcut module</a>.', array(':shortcut' => 'https://www.drupal.org/documentation/modules/shortcut')) . '</p>';
+ $output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href=":shortcut">online documentation for the Shortcut module</a>.', [':shortcut' => 'https://www.drupal.org/documentation/modules/shortcut']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>';
- $output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href=":shortcuts">Shortcuts administration page</a>.', array(':shortcuts' => \Drupal::url('entity.shortcut_set.collection'))) . '</dd>';
+ $output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href=":shortcuts">Shortcuts administration page</a>.', [':shortcuts' => \Drupal::url('entity.shortcut_set.collection')]) . '</dd>';
$output .= '<dt>' . t('Choosing shortcut sets') . '</dt>';
$output .= '<dd>' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '</dd>';
$output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>';
$output .= '<dd>' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Seven administration theme displays this link next to the page title, as a grey or yellow star. If you click on the grey star, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a yellow star, and will allow you to remove the current page from your shortcut set.') . '</dd>';
$output .= '<dt>' . t('Displaying shortcuts') . '</dt>';
- $output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href=":blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href=":toolbar-help">Toolbar module</a> provides a corresponding menu item.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':toolbar-help' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', array('name' => 'toolbar')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href=":blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href=":toolbar-help">Toolbar module</a> provides a corresponding menu item.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':toolbar-help' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', ['name' => 'toolbar']) : '#']) . '</dd>';
$output .= '</dl>';
return $output;
@@ -38,7 +38,7 @@ function shortcut_help($route_name, RouteMatchInterface $route_match) {
case 'entity.shortcut_set.edit_form':
$user = \Drupal::currentUser();
if ($user->hasPermission('access shortcuts') && $user->hasPermission('switch shortcut sets')) {
- $output = '<p>' . t('Define which shortcut set you are using on the <a href=":shortcut-link">Shortcuts tab</a> of your account page.', array(':shortcut-link' => \Drupal::url('shortcut.set_switch', array('user' => $user->id())))) . '</p>';
+ $output = '<p>' . t('Define which shortcut set you are using on the <a href=":shortcut-link">Shortcuts tab</a> of your account page.', [':shortcut-link' => \Drupal::url('shortcut.set_switch', ['user' => $user->id()])]) . '</p>';
return $output;
}
}
@@ -162,7 +162,7 @@ function shortcut_set_unassign_user($account) {
* the default set is returned.
*/
function shortcut_current_displayed_set($account = NULL) {
- $shortcut_sets = &drupal_static(__FUNCTION__, array());
+ $shortcut_sets = &drupal_static(__FUNCTION__, []);
$user = \Drupal::currentUser();
if (!isset($account)) {
$account = $user;
@@ -209,7 +209,7 @@ function shortcut_default_set($account = NULL) {
// have one, we allow the last module which returns a valid result to take
// precedence. If no module returns a valid set, fall back on the site-wide
// default, which is the lowest-numbered shortcut set.
- $suggestions = array_reverse(\Drupal::moduleHandler()->invokeAll('shortcut_default_set', array($account)));
+ $suggestions = array_reverse(\Drupal::moduleHandler()->invokeAll('shortcut_default_set', [$account]));
$suggestions[] = 'default';
foreach ($suggestions as $name) {
if ($shortcut_set = ShortcutSet::load($name)) {
@@ -252,37 +252,37 @@ function shortcut_set_title_exists($title) {
* An array of shortcut links, in the format returned by the menu system.
*/
function shortcut_renderable_links($shortcut_set = NULL) {
- $shortcut_links = array();
+ $shortcut_links = [];
if (!isset($shortcut_set)) {
$shortcut_set = shortcut_current_displayed_set();
}
- $cache_tags = array();
+ $cache_tags = [];
foreach ($shortcut_set->getShortcuts() as $shortcut) {
$shortcut = \Drupal::entityManager()->getTranslationFromContext($shortcut);
$url = $shortcut->getUrl();
if ($url->access()) {
- $links[$shortcut->id()] = array(
+ $links[$shortcut->id()] = [
'type' => 'link',
'title' => $shortcut->label(),
'url' => $shortcut->getUrl(),
- );
+ ];
$cache_tags = Cache::mergeTags($cache_tags, $shortcut->getCacheTags());
}
}
if (!empty($links)) {
- $shortcut_links = array(
+ $shortcut_links = [
'#theme' => 'links__toolbar_shortcuts',
'#links' => $links,
- '#attributes' => array(
- 'class' => array('toolbar-menu'),
- ),
- '#cache' => array(
+ '#attributes' => [
+ 'class' => ['toolbar-menu'],
+ ],
+ '#cache' => [
'tags' => $cache_tags,
- ),
- );
+ ],
+ ];
}
return $shortcut_links;
@@ -313,15 +313,15 @@ function shortcut_preprocess_page_title(&$variables) {
// string form, so we can set the default name for the shortcut.
// Strip HTML tags from the title.
$name = trim(strip_tags(render($variables['title'])));
- $query = array(
+ $query = [
'link' => $link,
'name' => $name,
- );
+ ];
$shortcut_set = shortcut_current_displayed_set();
// Check if $link is already a shortcut and set $link_mode accordingly.
- $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id()));
+ $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $shortcut_set->id()]);
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */
foreach ($shortcuts as $shortcut) {
if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName() && $shortcut_url->getRouteParameters() == $route_match->getRawParameters()->all()) {
@@ -332,36 +332,36 @@ function shortcut_preprocess_page_title(&$variables) {
$link_mode = isset($shortcut_id) ? "remove" : "add";
if ($link_mode == "add") {
- $link_text = shortcut_set_switch_access()->isAllowed() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->label())) : t('Add to shortcuts');
+ $link_text = shortcut_set_switch_access()->isAllowed() ? t('Add to %shortcut_set shortcuts', ['%shortcut_set' => $shortcut_set->label()]) : t('Add to shortcuts');
$route_name = 'shortcut.link_add_inline';
- $route_parameters = array('shortcut_set' => $shortcut_set->id());
+ $route_parameters = ['shortcut_set' => $shortcut_set->id()];
}
else {
$query['id'] = $shortcut_id;
- $link_text = shortcut_set_switch_access()->isAllowed() ? t('Remove from %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->label())) : t('Remove from shortcuts');
+ $link_text = shortcut_set_switch_access()->isAllowed() ? t('Remove from %shortcut_set shortcuts', ['%shortcut_set' => $shortcut_set->label()]) : t('Remove from shortcuts');
$route_name = 'entity.shortcut.link_delete_inline';
- $route_parameters = array('shortcut' => $shortcut_id);
+ $route_parameters = ['shortcut' => $shortcut_id];
}
if (theme_get_setting('third_party_settings.shortcut.module_link')) {
$query += \Drupal::destination()->getAsArray();
- $variables['title_suffix']['add_or_remove_shortcut'] = array(
- '#attached' => array(
- 'library' => array(
+ $variables['title_suffix']['add_or_remove_shortcut'] = [
+ '#attached' => [
+ 'library' => [
'shortcut/drupal.shortcut',
- ),
- ),
+ ],
+ ],
'#type' => 'link',
- '#title' => SafeMarkup::format('<span class="shortcut-action__icon"></span><span class="shortcut-action__message">@text</span>', array('@text' => $link_text)),
+ '#title' => SafeMarkup::format('<span class="shortcut-action__icon"></span><span class="shortcut-action__message">@text</span>', ['@text' => $link_text]),
'#url' => Url::fromRoute($route_name, $route_parameters),
- '#options' => array('query' => $query),
- '#attributes' => array(
- 'class' => array(
+ '#options' => ['query' => $query],
+ '#attributes' => [
+ 'class' => [
'shortcut-action',
'shortcut-action--' . $link_mode,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
}
@@ -390,37 +390,37 @@ function shortcut_toolbar() {
\Drupal::service('renderer')->addCacheableDependency($items['shortcuts'], $shortcut_set);
$configure_link = NULL;
if (shortcut_set_edit_access($shortcut_set)->isAllowed()) {
- $configure_link = array(
+ $configure_link = [
'#type' => 'link',
'#title' => t('Edit shortcuts'),
'#url' => Url::fromRoute('entity.shortcut_set.customize_form', ['shortcut_set' => $shortcut_set->id()]),
- '#options' => array('attributes' => array('class' => array('edit-shortcuts'))),
- );
+ '#options' => ['attributes' => ['class' => ['edit-shortcuts']]],
+ ];
}
if (!empty($links) || !empty($configure_link)) {
- $items['shortcuts'] += array(
+ $items['shortcuts'] += [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#title' => t('Shortcuts'),
'#url' => $shortcut_set->urlInfo('collection'),
- '#attributes' => array(
+ '#attributes' => [
'title' => t('Shortcuts'),
- 'class' => array('toolbar-icon', 'toolbar-icon-shortcut'),
- ),
- ),
- 'tray' => array(
+ 'class' => ['toolbar-icon', 'toolbar-icon-shortcut'],
+ ],
+ ],
+ 'tray' => [
'#heading' => t('User-defined shortcuts'),
'shortcuts' => $links,
'configure' => $configure_link,
- ),
+ ],
'#weight' => -10,
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'shortcut/drupal.shortcut',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
diff --git a/core/modules/shortcut/src/Controller/ShortcutController.php b/core/modules/shortcut/src/Controller/ShortcutController.php
index ff0e184c91c..4f33b0b5557 100644
--- a/core/modules/shortcut/src/Controller/ShortcutController.php
+++ b/core/modules/shortcut/src/Controller/ShortcutController.php
@@ -21,7 +21,7 @@ class ShortcutController extends ControllerBase {
* The shortcut add form.
*/
public function addForm(ShortcutSetInterface $shortcut_set) {
- $shortcut = $this->entityManager()->getStorage('shortcut')->create(array('shortcut_set' => $shortcut_set->id()));
+ $shortcut = $this->entityManager()->getStorage('shortcut')->create(['shortcut_set' => $shortcut_set->id()]);
return $this->entityFormBuilder()->getForm($shortcut, 'add');
}
@@ -40,10 +40,10 @@ class ShortcutController extends ControllerBase {
try {
$shortcut->delete();
- drupal_set_message($this->t('The shortcut %title has been deleted.', array('%title' => $label)));
+ drupal_set_message($this->t('The shortcut %title has been deleted.', ['%title' => $label]));
}
catch (\Exception $e) {
- drupal_set_message($this->t('Unable to delete the shortcut for %title.', array('%title' => $label)), 'error');
+ drupal_set_message($this->t('Unable to delete the shortcut for %title.', ['%title' => $label]), 'error');
}
return $this->redirect('<front>');
diff --git a/core/modules/shortcut/src/Controller/ShortcutSetController.php b/core/modules/shortcut/src/Controller/ShortcutSetController.php
index 8d84f9abe3c..58a68d70e0d 100644
--- a/core/modules/shortcut/src/Controller/ShortcutSetController.php
+++ b/core/modules/shortcut/src/Controller/ShortcutSetController.php
@@ -55,20 +55,20 @@ class ShortcutSetController extends ControllerBase {
$link = $request->query->get('link');
$name = $request->query->get('name');
if (parse_url($link, PHP_URL_SCHEME) === NULL && $this->pathValidator->isValid($link)) {
- $shortcut = $this->entityManager()->getStorage('shortcut')->create(array(
+ $shortcut = $this->entityManager()->getStorage('shortcut')->create([
'title' => $name,
'shortcut_set' => $shortcut_set->id(),
- 'link' => array(
+ 'link' => [
'uri' => 'internal:/' . $link,
- ),
- ));
+ ],
+ ]);
try {
$shortcut->save();
- drupal_set_message($this->t('Added a shortcut for %title.', array('%title' => $shortcut->label())));
+ drupal_set_message($this->t('Added a shortcut for %title.', ['%title' => $shortcut->label()]));
}
catch (\Exception $e) {
- drupal_set_message($this->t('Unable to add a shortcut for %title.', array('%title' => $shortcut->label())), 'error');
+ drupal_set_message($this->t('Unable to add a shortcut for %title.', ['%title' => $shortcut->label()]), 'error');
}
return $this->redirect('<front>');
diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php
index 6ddaf053746..87e2ccb91b0 100644
--- a/core/modules/shortcut/src/Entity/Shortcut.php
+++ b/core/modules/shortcut/src/Entity/Shortcut.php
@@ -123,13 +123,13 @@ class Shortcut extends ContentEntityBase implements ShortcutInterface {
->setRequired(TRUE)
->setTranslatable(TRUE)
->setSetting('max_length', 255)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -10,
- 'settings' => array(
+ 'settings' => [
'size' => 40,
- ),
- ));
+ ],
+ ]);
$fields['weight'] = BaseFieldDefinition::create('integer')
->setLabel(t('Weight'))
@@ -139,14 +139,14 @@ class Shortcut extends ContentEntityBase implements ShortcutInterface {
->setLabel(t('Path'))
->setDescription(t('The location this shortcut points to.'))
->setRequired(TRUE)
- ->setSettings(array(
+ ->setSettings([
'link_type' => LinkItemInterface::LINK_INTERNAL,
'title' => DRUPAL_DISABLED,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'link_default',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
return $fields;
diff --git a/core/modules/shortcut/src/Entity/ShortcutSet.php b/core/modules/shortcut/src/Entity/ShortcutSet.php
index 7b42310e5b6..3d3815db792 100644
--- a/core/modules/shortcut/src/Entity/ShortcutSet.php
+++ b/core/modules/shortcut/src/Entity/ShortcutSet.php
@@ -116,8 +116,8 @@ class ShortcutSet extends ConfigEntityBundleBase implements ShortcutSetInterface
* {@inheritdoc}
*/
public function getShortcuts() {
- $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $this->id()));
- uasort($shortcuts, array('\Drupal\shortcut\Entity\Shortcut', 'sort'));
+ $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $this->id()]);
+ uasort($shortcuts, ['\Drupal\shortcut\Entity\Shortcut', 'sort']);
return $shortcuts;
}
diff --git a/core/modules/shortcut/src/Form/SetCustomize.php b/core/modules/shortcut/src/Form/SetCustomize.php
index 89e51232070..6c975778293 100644
--- a/core/modules/shortcut/src/Form/SetCustomize.php
+++ b/core/modules/shortcut/src/Form/SetCustomize.php
@@ -23,24 +23,24 @@ class SetCustomize extends EntityForm {
*/
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
- $form['shortcuts'] = array(
+ $form['shortcuts'] = [
'#tree' => TRUE,
'#weight' => -20,
- );
+ ];
- $form['shortcuts']['links'] = array(
+ $form['shortcuts']['links'] = [
'#type' => 'table',
- '#header' => array(t('Name'), t('Weight'), t('Operations')),
- '#empty' => $this->t('No shortcuts available. <a href=":link">Add a shortcut</a>', array(':link' => $this->url('shortcut.link_add', array('shortcut_set' => $this->entity->id())))),
- '#attributes' => array('id' => 'shortcuts'),
- '#tabledrag' => array(
- array(
+ '#header' => [t('Name'), t('Weight'), t('Operations')],
+ '#empty' => $this->t('No shortcuts available. <a href=":link">Add a shortcut</a>', [':link' => $this->url('shortcut.link_add', ['shortcut_set' => $this->entity->id()])]),
+ '#attributes' => ['id' => 'shortcuts'],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'shortcut-weight',
- ),
- ),
- );
+ ],
+ ],
+ ];
foreach ($this->entity->getShortcuts() as $shortcut) {
$id = $shortcut->id();
@@ -49,33 +49,33 @@ class SetCustomize extends EntityForm {
continue;
}
$form['shortcuts']['links'][$id]['#attributes']['class'][] = 'draggable';
- $form['shortcuts']['links'][$id]['name'] = array(
+ $form['shortcuts']['links'][$id]['name'] = [
'#type' => 'link',
'#title' => $shortcut->getTitle(),
- ) + $url->toRenderArray();
+ ] + $url->toRenderArray();
unset($form['shortcuts']['links'][$id]['name']['#access_callback']);
$form['shortcuts']['links'][$id]['#weight'] = $shortcut->getWeight();
- $form['shortcuts']['links'][$id]['weight'] = array(
+ $form['shortcuts']['links'][$id]['weight'] = [
'#type' => 'weight',
- '#title' => t('Weight for @title', array('@title' => $shortcut->getTitle())),
+ '#title' => t('Weight for @title', ['@title' => $shortcut->getTitle()]),
'#title_display' => 'invisible',
'#default_value' => $shortcut->getWeight(),
- '#attributes' => array('class' => array('shortcut-weight')),
- );
+ '#attributes' => ['class' => ['shortcut-weight']],
+ ];
- $links['edit'] = array(
+ $links['edit'] = [
'title' => t('Edit'),
'url' => $shortcut->urlInfo(),
- );
- $links['delete'] = array(
+ ];
+ $links['delete'] = [
'title' => t('Delete'),
'url' => $shortcut->urlInfo('delete-form'),
- );
- $form['shortcuts']['links'][$id]['operations'] = array(
+ ];
+ $form['shortcuts']['links'][$id]['operations'] = [
'#type' => 'operations',
'#links' => $links,
'#access' => $url->access(),
- );
+ ];
}
return $form;
}
@@ -85,14 +85,14 @@ class SetCustomize extends EntityForm {
*/
protected function actions(array $form, FormStateInterface $form_state) {
// Only includes a Save action for the entity, no direct Delete button.
- return array(
- 'submit' => array(
+ return [
+ 'submit' => [
'#type' => 'submit',
'#value' => t('Save'),
'#access' => (bool) Element::getVisibleChildren($form['shortcuts']['links']),
- '#submit' => array('::submitForm', '::save'),
- ),
- );
+ '#submit' => ['::submitForm', '::save'],
+ ],
+ ];
}
/**
@@ -100,7 +100,7 @@ class SetCustomize extends EntityForm {
*/
public function save(array $form, FormStateInterface $form_state) {
foreach ($this->entity->getShortcuts() as $shortcut) {
- $weight = $form_state->getValue(array('shortcuts', 'links', $shortcut->id(), 'weight'));
+ $weight = $form_state->getValue(['shortcuts', 'links', $shortcut->id(), 'weight']);
$shortcut->setWeight($weight);
$shortcut->save();
}
diff --git a/core/modules/shortcut/src/Form/ShortcutDeleteForm.php b/core/modules/shortcut/src/Form/ShortcutDeleteForm.php
index aee67880182..fcabeec7ec2 100644
--- a/core/modules/shortcut/src/Form/ShortcutDeleteForm.php
+++ b/core/modules/shortcut/src/Form/ShortcutDeleteForm.php
@@ -21,9 +21,9 @@ class ShortcutDeleteForm extends ContentEntityDeleteForm {
* {@inheritdoc}
*/
public function getCancelUrl() {
- return new Url('entity.shortcut_set.customize_form', array(
+ return new Url('entity.shortcut_set.customize_form', [
'shortcut_set' => $this->entity->bundle(),
- ));
+ ]);
}
/**
diff --git a/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php b/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php
index 3c732d6bc8c..c383627b878 100644
--- a/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php
+++ b/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php
@@ -65,9 +65,9 @@ class ShortcutSetDeleteForm extends EntityDeleteForm {
$info .= '<p>' . t('If you have chosen this shortcut set as the default for some or all users, they may also be affected by deleting it.') . '</p>';
}
- $form['info'] = array(
+ $form['info'] = [
'#markup' => $info,
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/shortcut/src/Form/SwitchShortcutSet.php b/core/modules/shortcut/src/Form/SwitchShortcutSet.php
index 220f49b9f35..649cef765b7 100644
--- a/core/modules/shortcut/src/Form/SwitchShortcutSet.php
+++ b/core/modules/shortcut/src/Form/SwitchShortcutSet.php
@@ -77,60 +77,60 @@ class SwitchShortcutSet extends FormBase {
$account_is_user = $this->user->id() == $account->id();
if (count($options) > 1) {
- $form['set'] = array(
+ $form['set'] = [
'#type' => 'radios',
'#title' => $account_is_user ? $this->t('Choose a set of shortcuts to use') : $this->t('Choose a set of shortcuts for this user'),
'#options' => $options,
'#default_value' => $current_set->id(),
- );
+ ];
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#description' => $this->t('The new set is created by copying items from your default shortcut set.'),
'#access' => $add_access,
- '#states' => array(
- 'visible' => array(
- ':input[name="set"]' => array('value' => 'new'),
- ),
- 'required' => array(
- ':input[name="set"]' => array('value' => 'new'),
- ),
- ),
- );
- $form['id'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="set"]' => ['value' => 'new'],
+ ],
+ 'required' => [
+ ':input[name="set"]' => ['value' => 'new'],
+ ],
+ ],
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
'replace_pattern' => '[^a-z0-9-]+',
'replace' => '-',
- ),
+ ],
// This ID could be used for menu name.
'#maxlength' => 23,
- '#states' => array(
- 'required' => array(
- ':input[name="set"]' => array('value' => 'new'),
- ),
- ),
+ '#states' => [
+ 'required' => [
+ ':input[name="set"]' => ['value' => 'new'],
+ ],
+ ],
'#required' => FALSE,
- );
+ ];
if (!$account_is_user) {
$default_set = $this->shortcutSetStorage->getDefaultSet($this->user);
- $form['new']['#description'] = $this->t('The new set is created by copying items from the %default set.', array('%default' => $default_set->label()));
+ $form['new']['#description'] = $this->t('The new set is created by copying items from the %default set.', ['%default' => $default_set->label()]);
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Change set'),
- );
+ ];
}
else {
// There is only 1 option, so output a message in the $form array.
- $form['info'] = array(
- '#markup' => '<p>' . $this->t('You are currently using the %set-name shortcut set.', array('%set-name' => $current_set->label())) . '</p>',
- );
+ $form['info'] = [
+ '#markup' => '<p>' . $this->t('You are currently using the %set-name shortcut set.', ['%set-name' => $current_set->label()]) . '</p>',
+ ];
}
return $form;
@@ -173,16 +173,16 @@ class SwitchShortcutSet extends FormBase {
if ($form_state->getValue('set') == 'new') {
// Save a new shortcut set with links copied from the user's default set.
/* @var \Drupal\shortcut\Entity\ShortcutSet $set */
- $set = $this->shortcutSetStorage->create(array(
+ $set = $this->shortcutSetStorage->create([
'id' => $form_state->getValue('id'),
'label' => $form_state->getValue('label'),
- ));
+ ]);
$set->save();
- $replacements = array(
+ $replacements = [
'%user' => $this->user->label(),
'%set_name' => $set->label(),
':switch-url' => $this->url('<current>'),
- );
+ ];
if ($account_is_user) {
// Only administrators can create new shortcut sets, so we know they have
// access to switch back.
@@ -193,17 +193,17 @@ class SwitchShortcutSet extends FormBase {
}
$form_state->setRedirect(
'entity.shortcut_set.customize_form',
- array('shortcut_set' => $set->id())
+ ['shortcut_set' => $set->id()]
);
}
else {
// Switch to a different shortcut set.
/* @var \Drupal\shortcut\Entity\ShortcutSet $set */
$set = $this->shortcutSetStorage->load($form_state->getValue('set'));
- $replacements = array(
+ $replacements = [
'%user' => $this->user->getDisplayName(),
'%set_name' => $set->label(),
- );
+ ];
drupal_set_message($account_is_user ? $this->t('You are now using the %set_name shortcut set.', $replacements) : $this->t('%user is now using the %set_name shortcut set.', $replacements));
}
diff --git a/core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php b/core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php
index 1678f6aaea5..ab2d57e414d 100644
--- a/core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php
+++ b/core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php
@@ -21,9 +21,9 @@ class ShortcutsBlock extends BlockBase {
* {@inheritdoc}
*/
public function build() {
- return array(
+ return [
shortcut_renderable_links(shortcut_current_displayed_set()),
- );
+ ];
}
/**
diff --git a/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php b/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php
index cd86f0f5e1b..0cb843be76c 100644
--- a/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php
+++ b/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php
@@ -60,14 +60,14 @@ class ShortcutSetUsers extends DestinationBase implements ContainerFactoryPlugin
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'set_name' => array(
+ return [
+ 'set_name' => [
'type' => 'string',
- ),
- 'uid' => array(
+ ],
+ 'uid' => [
'type' => 'integer',
- ),
- );
+ ],
+ ];
}
/**
@@ -83,14 +83,14 @@ class ShortcutSetUsers extends DestinationBase implements ContainerFactoryPlugin
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
/** @var \Drupal\shortcut\ShortcutSetInterface $set */
$set = $this->shortcutSetStorage->load($row->getDestinationProperty('set_name'));
/** @var \Drupal\user\UserInterface $account */
$account = User::load($row->getDestinationProperty('uid'));
$this->shortcutSetStorage->assignUser($set, $account);
- return array($set->id(), $account->id());
+ return [$set->id(), $account->id()];
}
}
diff --git a/core/modules/shortcut/src/Plugin/migrate/source/d7/Shortcut.php b/core/modules/shortcut/src/Plugin/migrate/source/d7/Shortcut.php
index c964e5c46f6..444c38feb92 100644
--- a/core/modules/shortcut/src/Plugin/migrate/source/d7/Shortcut.php
+++ b/core/modules/shortcut/src/Plugin/migrate/source/d7/Shortcut.php
@@ -19,7 +19,7 @@ class Shortcut extends DrupalSqlBase {
*/
public function query() {
return $this->select('menu_links', 'ml')
- ->fields('ml', array('mlid', 'menu_name', 'link_path', 'link_title', 'weight'))
+ ->fields('ml', ['mlid', 'menu_name', 'link_path', 'link_title', 'weight'])
->condition('hidden', '0')
->condition('menu_name', 'shortcut-set-%', 'LIKE')
->orderBy('ml.mlid');
@@ -29,13 +29,13 @@ class Shortcut extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'mlid' => $this->t("The menu.mlid primary key for this menu item (= shortcut link)."),
'menu_name' => $this->t("The menu_name (= set name) for this shortcut link."),
'link_path' => $this->t("The link for this shortcut."),
'link_title' => $this->t("The title for this shortcut."),
'weight' => $this->t("The weight for this shortcut"),
- );
+ ];
}
/**
diff --git a/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSet.php b/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSet.php
index 75f145433f3..a088ca8efb1 100644
--- a/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSet.php
+++ b/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSet.php
@@ -25,10 +25,10 @@ class ShortcutSet extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'set_name' => $this->t("The name under which the set's links are stored."),
'title' => $this->t("The title of the set."),
- );
+ ];
}
/**
diff --git a/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSetUsers.php b/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSetUsers.php
index dd5a13fc8cf..b86dccde168 100644
--- a/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSetUsers.php
+++ b/core/modules/shortcut/src/Plugin/migrate/source/d7/ShortcutSetUsers.php
@@ -25,24 +25,24 @@ class ShortcutSetUsers extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'uid' => $this->t('The users.uid for this set.'),
'set_name' => $this->t('The shortcut_set.set_name that will be displayed for this user.'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'set_name' => array(
+ return [
+ 'set_name' => [
'type' => 'string',
- ),
- 'uid' => array(
+ ],
+ 'uid' => [
'type' => 'integer',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/shortcut/src/ShortcutForm.php b/core/modules/shortcut/src/ShortcutForm.php
index b87db1bce89..bfe3133e47d 100644
--- a/core/modules/shortcut/src/ShortcutForm.php
+++ b/core/modules/shortcut/src/ShortcutForm.php
@@ -35,16 +35,16 @@ class ShortcutForm extends ContentEntityForm {
}
if ($status == SAVED_UPDATED) {
- $message = $this->t('The shortcut %link has been updated.', array('%link' => $view_link));
+ $message = $this->t('The shortcut %link has been updated.', ['%link' => $view_link]);
}
else {
- $message = $this->t('Added a shortcut for %title.', array('%title' => $view_link));
+ $message = $this->t('Added a shortcut for %title.', ['%title' => $view_link]);
}
drupal_set_message($message);
$form_state->setRedirect(
'entity.shortcut_set.customize_form',
- array('shortcut_set' => $entity->bundle())
+ ['shortcut_set' => $entity->bundle()]
);
}
diff --git a/core/modules/shortcut/src/ShortcutSetForm.php b/core/modules/shortcut/src/ShortcutSetForm.php
index 012de5fa6f6..721d2517d41 100644
--- a/core/modules/shortcut/src/ShortcutSetForm.php
+++ b/core/modules/shortcut/src/ShortcutSetForm.php
@@ -17,25 +17,25 @@ class ShortcutSetForm extends BundleEntityFormBase {
$form = parent::form($form, $form_state);
$entity = $this->entity;
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => t('Set name'),
'#description' => t('The new set is created by copying items from your default shortcut set.'),
'#required' => TRUE,
'#default_value' => $entity->label(),
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\shortcut\Entity\ShortcutSet::load',
- 'source' => array('label'),
+ 'source' => ['label'],
'replace_pattern' => '[^a-z0-9-]+',
'replace' => '-',
- ),
+ ],
'#default_value' => $entity->id(),
// This id could be used for menu name.
'#maxlength' => 23,
- );
+ ];
$form['actions']['submit']['#value'] = t('Create new set');
@@ -51,10 +51,10 @@ class ShortcutSetForm extends BundleEntityFormBase {
$entity->save();
if ($is_new) {
- drupal_set_message(t('The %set_name shortcut set has been created. You can edit it from this page.', array('%set_name' => $entity->label())));
+ drupal_set_message(t('The %set_name shortcut set has been created. You can edit it from this page.', ['%set_name' => $entity->label()]));
}
else {
- drupal_set_message(t('Updated set name to %set-name.', array('%set-name' => $entity->label())));
+ drupal_set_message(t('Updated set name to %set-name.', ['%set-name' => $entity->label()]));
}
$form_state->setRedirectUrl($this->entity->urlInfo('customize-form'));
}
diff --git a/core/modules/shortcut/src/ShortcutSetListBuilder.php b/core/modules/shortcut/src/ShortcutSetListBuilder.php
index 0e5d81d8b09..2cc582e9445 100644
--- a/core/modules/shortcut/src/ShortcutSetListBuilder.php
+++ b/core/modules/shortcut/src/ShortcutSetListBuilder.php
@@ -30,10 +30,10 @@ class ShortcutSetListBuilder extends ConfigEntityListBuilder {
$operations['edit']['title'] = t('Edit shortcut set');
}
- $operations['list'] = array(
+ $operations['list'] = [
'title' => t('List links'),
'url' => $entity->urlInfo('customize-form'),
- );
+ ];
return $operations;
}
diff --git a/core/modules/shortcut/src/ShortcutSetStorage.php b/core/modules/shortcut/src/ShortcutSetStorage.php
index d76c0c46c1e..b136c2fb07d 100644
--- a/core/modules/shortcut/src/ShortcutSetStorage.php
+++ b/core/modules/shortcut/src/ShortcutSetStorage.php
@@ -73,7 +73,7 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora
public function assignUser(ShortcutSetInterface $shortcut_set, $account) {
db_merge('shortcut_set_users')
->key('uid', $account->id())
- ->fields(array('set_name' => $shortcut_set->id()))
+ ->fields(['set_name' => $shortcut_set->id()])
->execute();
drupal_static_reset('shortcut_current_displayed_set');
}
@@ -93,7 +93,7 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora
*/
public function getAssignedToUser($account) {
$query = db_select('shortcut_set_users', 'ssu');
- $query->fields('ssu', array('set_name'));
+ $query->fields('ssu', ['set_name']);
$query->condition('ssu.uid', $account->id());
return $query->execute()->fetchField();
}
@@ -102,7 +102,7 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora
* {@inheritdoc}
*/
public function countAssignedUsers(ShortcutSetInterface $shortcut_set) {
- return db_query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', array(':name' => $shortcut_set->id()))->fetchField();
+ return db_query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', [':name' => $shortcut_set->id()])->fetchField();
}
/**
@@ -113,7 +113,7 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora
// have one, we allow the last module which returns a valid result to take
// precedence. If no module returns a valid set, fall back on the site-wide
// default, which is the lowest-numbered shortcut set.
- $suggestions = array_reverse($this->moduleHandler->invokeAll('shortcut_default_set', array($account)));
+ $suggestions = array_reverse($this->moduleHandler->invokeAll('shortcut_default_set', [$account]));
$suggestions[] = 'default';
$shortcut_set = NULL;
foreach ($suggestions as $name) {
diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
index 679f89bbecd..cf4ae0fbe5b 100644
--- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
@@ -22,7 +22,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
*
* @var array
*/
- public static $modules = array('router_test', 'views', 'block');
+ public static $modules = ['router_test', 'views', 'block'];
/**
* {@inheritdoc}
@@ -40,10 +40,10 @@ class ShortcutLinksTest extends ShortcutTestBase {
$set = $this->set;
// Create an alias for the node so we can test aliases.
- $path = array(
+ $path = [
'source' => '/node/' . $this->node->id(),
'alias' => '/' . $this->randomMachineName(8),
- );
+ ];
$this->container->get('path.alias_storage')->save($path['source'], $path['alias']);
// Create some paths to test.
@@ -65,13 +65,13 @@ class ShortcutLinksTest extends ShortcutTestBase {
// Check that each new shortcut links where it should.
foreach ($test_cases as $test_path) {
$title = $this->randomMachineName();
- $form_data = array(
+ $form_data = [
'title[0][value]' => $title,
'link[0][uri]' => $test_path,
- );
+ ];
$this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
$this->assertResponse(200);
- $this->assertText(t('Added a shortcut for @title.', array('@title' => $title)));
+ $this->assertText(t('Added a shortcut for @title.', ['@title' => $title]));
$saved_set = ShortcutSet::load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'link');
$this->assertTrue(in_array('internal:' . $test_path, $paths), 'Shortcut created: ' . $test_path);
@@ -115,10 +115,10 @@ class ShortcutLinksTest extends ShortcutTestBase {
// Create a new shortcut set and add a link to it.
$this->drupalLogin($this->adminUser);
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(),
'id' => strtolower($this->randomMachineName()),
- );
+ ];
$this->drupalPostForm('admin/config/user-interface/shortcut/add-set', $edit, t('Save'));
$title = $this->randomMachineName();
$form_data = [
@@ -133,7 +133,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
* Tests that the "add to shortcut" and "remove from shortcut" links work.
*/
public function testShortcutQuickLink() {
- \Drupal::service('theme_handler')->install(array('seven'));
+ \Drupal::service('theme_handler')->install(['seven']);
$this->config('system.theme')->set('admin', 'seven')->save();
$this->config('node.settings')->set('use_admin_theme', '1')->save();
$this->container->get('router.builder')->rebuild();
@@ -177,7 +177,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$this->assertText('Added a shortcut for Create Basic page.');
// Assure that Article does not have its shortcut indicated as set.
$this->drupalGet('node/add/article');
- $link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Remove from Default shortcuts'));
+ $link = $this->xpath('//a[normalize-space()=:label]', [':label' => 'Remove from Default shortcuts']);
$this->assertTrue(empty($link), 'Link Remove to Default shortcuts not found for Create Article page.');
// Add Shortcut for Article.
$this->clickLink('Add to Default shortcuts');
@@ -198,11 +198,11 @@ class ShortcutLinksTest extends ShortcutTestBase {
$this->assertShortcutQuickLink('Add to Default shortcuts');
\Drupal::service('module_installer')->install(['block_content']);
- BlockContentType::create(array(
+ BlockContentType::create([
'id' => 'basic',
'label' => 'Basic block',
'revision' => FALSE,
- ))->save();
+ ])->save();
// Test page with HTML tags in title.
$this->drupalGet('admin/structure/block/block-content/manage/basic');
$page_title = new FormattableMarkup('Edit %label custom block type', ['%label' => 'Basic block']);
@@ -226,12 +226,12 @@ class ShortcutLinksTest extends ShortcutTestBase {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
- $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $new_link_name), t('Save'));
+ $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), ['title[0][value]' => $new_link_name], t('Save'));
$saved_set = ShortcutSet::load($set->id());
$titles = $this->getShortcutInformation($saved_set, 'title');
$this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name);
$this->assertLink($new_link_name, 0, 'Renamed shortcut link appears on the page.');
- $this->assertText(t('The shortcut @link has been updated.', array('@link' => $new_link_name)));
+ $this->assertText(t('The shortcut @link has been updated.', ['@link' => $new_link_name]));
}
/**
@@ -245,12 +245,12 @@ class ShortcutLinksTest extends ShortcutTestBase {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
- $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $shortcut->getTitle(), 'link[0][uri]' => $new_link_path), t('Save'));
+ $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), ['title[0][value]' => $shortcut->getTitle(), 'link[0][uri]' => $new_link_path], t('Save'));
$saved_set = ShortcutSet::load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'link');
$this->assertTrue(in_array('internal:' . $new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
$this->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.');
- $this->assertText(t('The shortcut @link has been updated.', array('@link' => $shortcut->getTitle())));
+ $this->assertText(t('The shortcut @link has been updated.', ['@link' => $shortcut->getTitle()]));
}
/**
@@ -277,7 +277,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
- $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id() . '/delete', array(), 'Delete');
+ $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id() . '/delete', [], 'Delete');
$saved_set = ShortcutSet::load($set->id());
$ids = $this->getShortcutInformation($saved_set, 'id');
$this->assertFalse(in_array($shortcut->id(), $ids), 'Successfully deleted a shortcut.');
@@ -297,7 +297,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
*/
public function testNoShortcutLink() {
// Change to a theme that displays shortcuts.
- \Drupal::service('theme_handler')->install(array('seven'));
+ \Drupal::service('theme_handler')->install(['seven']);
$this->config('system.theme')
->set('default', 'seven')
->save();
@@ -328,7 +328,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
*/
public function testAccessShortcutsPermission() {
// Change to a theme that displays shortcuts.
- \Drupal::service('theme_handler')->install(array('seven'));
+ \Drupal::service('theme_handler')->install(['seven']);
$this->config('system.theme')
->set('default', 'seven')
->save();
@@ -340,20 +340,20 @@ class ShortcutLinksTest extends ShortcutTestBase {
// Verify that users without the 'access shortcuts' permission can't see the
// shortcuts.
- $this->drupalLogin($this->drupalCreateUser(array('access toolbar')));
+ $this->drupalLogin($this->drupalCreateUser(['access toolbar']));
$this->assertNoLink('Shortcuts', 'Shortcut link not found on page.');
// Verify that users without the 'administer site configuration' permission
// can't see the cron shortcuts.
- $this->drupalLogin($this->drupalCreateUser(array('access toolbar', 'access shortcuts')));
+ $this->drupalLogin($this->drupalCreateUser(['access toolbar', 'access shortcuts']));
$this->assertNoLink('Shortcuts', 'Shortcut link not found on page.');
$this->assertNoLink('Cron', 'Cron shortcut link not found on page.');
// Verify that users with the 'access shortcuts' permission can see the
// shortcuts.
- $this->drupalLogin($this->drupalCreateUser(array(
+ $this->drupalLogin($this->drupalCreateUser([
'access toolbar', 'access shortcuts', 'administer site configuration',
- )));
+ ]));
$this->clickLink('Shortcuts', 0, 'Shortcut link found on page.');
$this->assertLink('Cron', 0, 'Cron shortcut link found on page.');
@@ -365,7 +365,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
*/
public function testShortcutLinkOrder() {
// Ensure to give permissions to access the shortcuts.
- $this->drupalLogin($this->drupalCreateUser(array('access toolbar', 'access shortcuts', 'access content overview', 'administer content types')));
+ $this->drupalLogin($this->drupalCreateUser(['access toolbar', 'access shortcuts', 'access content overview', 'administer content types']));
$this->drupalGet(Url::fromRoute('<front>'));
$shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .toolbar-menu a');
$this->assertEqual((string) $shortcuts[0], 'Add content');
@@ -386,24 +386,24 @@ class ShortcutLinksTest extends ShortcutTestBase {
private function verifyAccessShortcutsPermissionForEditPages() {
// Create a user with customize links and switch sets permissions but
// without the 'access shortcuts' permission.
- $test_permissions = array(
+ $test_permissions = [
'customize shortcut links',
'switch shortcut sets',
- );
+ ];
$noaccess_user = $this->drupalCreateUser($test_permissions);
$this->drupalLogin($noaccess_user);
// Verify that set administration pages are inaccessible without the
// 'access shortcuts' permission.
- $edit_paths = array(
+ $edit_paths = [
'admin/config/user-interface/shortcut/manage/default/customize',
'admin/config/user-interface/shortcut/manage/default',
'user/' . $noaccess_user->id() . '/shortcuts',
- );
+ ];
foreach ($edit_paths as $path) {
$this->drupalGet($path);
- $message = format_string('Access is denied on %s', array('%s' => $path));
+ $message = format_string('Access is denied on %s', ['%s' => $path]);
$this->assertResponse(403, $message);
}
}
@@ -426,7 +426,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
// Verify that users without the 'access shortcuts' permission can see the
// shortcut block.
- $this->drupalLogin($this->drupalCreateUser(array()));
+ $this->drupalLogin($this->drupalCreateUser([]));
$this->drupalGet('');
$this->assertNoBlockAppears($block);
}
@@ -454,8 +454,8 @@ class ShortcutLinksTest extends ShortcutTestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertShortcutQuickLink($label, $index = 0, $message = '', $group = 'Other') {
- $links = $this->xpath('//a[normalize-space()=:label]', array(':label' => $label));
- $message = ($message ? $message : SafeMarkup::format('Shortcut quick link with label %label found.', array('%label' => $label)));
+ $links = $this->xpath('//a[normalize-space()=:label]', [':label' => $label]);
+ $message = ($message ? $message : SafeMarkup::format('Shortcut quick link with label %label found.', ['%label' => $label]));
return $this->assert(isset($links[$index]), $message, $group);
}
diff --git a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php
index 3a047573505..e4c7fb77a16 100644
--- a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php
@@ -33,10 +33,10 @@ class ShortcutSetsTest extends ShortcutTestBase {
function testShortcutSetAdd() {
$this->drupalGet('admin/config/user-interface/shortcut');
$this->clickLink(t('Add shortcut set'));
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(),
'id' => strtolower($this->randomMachineName()),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$new_set = $this->container->get('entity.manager')->getStorage('shortcut_set')->load($edit['id']);
$this->assertIdentical($new_set->id(), $edit['id'], 'Successfully created a shortcut set.');
@@ -66,14 +66,14 @@ class ShortcutSetsTest extends ShortcutTestBase {
$this->assertEqual(count($elements), 3, 'Correct number of table header cells found.');
// Test the contents of each th cell.
- $expected_items = array(t('Name'), t('Weight'), t('Operations'));
+ $expected_items = [t('Name'), t('Weight'), t('Operations')];
foreach ($elements as $key => $element) {
$this->assertEqual((string) $element[0], $expected_items[$key]);
}
// Look for test shortcuts in the table.
$weight = count($shortcuts);
- $edit = array();
+ $edit = [];
foreach ($shortcuts as $shortcut) {
$title = $shortcut->getTitle();
@@ -105,7 +105,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
// Attempt to switch the default shortcut set to the newly created shortcut
// set.
- $this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', array('set' => $new_set->id()), t('Change set'));
+ $this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', ['set' => $new_set->id()], t('Change set'));
$this->assertResponse(200);
$current_set = shortcut_current_displayed_set($this->adminUser);
$this->assertTrue($new_set->id() == $current_set->id(), 'Successfully switched own shortcut set.');
@@ -126,11 +126,11 @@ class ShortcutSetsTest extends ShortcutTestBase {
* Tests switching a user's shortcut set and creating one at the same time.
*/
function testShortcutSetSwitchCreate() {
- $edit = array(
+ $edit = [
'set' => 'new',
'id' => strtolower($this->randomMachineName()),
'label' => $this->randomString(),
- );
+ ];
$this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', $edit, t('Change set'));
$current_set = shortcut_current_displayed_set($this->adminUser);
$this->assertNotEqual($current_set->id(), $this->set->id(), 'A shortcut set can be switched to at the same time as it is created.');
@@ -141,7 +141,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
* Tests switching a user's shortcut set without providing a new set name.
*/
function testShortcutSetSwitchNoSetName() {
- $edit = array('set' => 'new');
+ $edit = ['set' => 'new'];
$this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', $edit, t('Change set'));
$this->assertText(t('The new set label is required.'));
$current_set = shortcut_current_displayed_set($this->adminUser);
@@ -158,7 +158,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
$new_label = $this->randomMachineName();
$this->drupalGet('admin/config/user-interface/shortcut');
$this->clickLink(t('Edit shortcut set'));
- $this->drupalPostForm(NULL, array('label' => $new_label), t('Save'));
+ $this->drupalPostForm(NULL, ['label' => $new_label], t('Save'));
$set = ShortcutSet::load($set->id());
$this->assertTrue($set->label() == $new_label, 'Shortcut set has been successfully renamed.');
}
@@ -183,7 +183,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
function testShortcutSetDelete() {
$new_set = $this->generateShortcutSet($this->randomMachineName());
- $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $new_set->id() . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $new_set->id() . '/delete', [], t('Delete'));
$sets = ShortcutSet::loadMultiple();
$this->assertFalse(isset($sets[$new_set->id()]), 'Successfully deleted a shortcut set.');
}
diff --git a/core/modules/shortcut/src/Tests/ShortcutTestBase.php b/core/modules/shortcut/src/Tests/ShortcutTestBase.php
index b32afb29d53..7fd5a4535d9 100644
--- a/core/modules/shortcut/src/Tests/ShortcutTestBase.php
+++ b/core/modules/shortcut/src/Tests/ShortcutTestBase.php
@@ -17,7 +17,7 @@ abstract class ShortcutTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'toolbar', 'shortcut');
+ public static $modules = ['node', 'toolbar', 'shortcut'];
/**
* User with permission to administer shortcuts.
@@ -52,37 +52,37 @@ abstract class ShortcutTestBase extends WebTestBase {
if ($this->profile != 'standard') {
// Create Basic page and Article node types.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Populate the default shortcut set.
- $shortcut = Shortcut::create(array(
+ $shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
- 'link' => array(
+ 'link' => [
'uri' => 'internal:/node/add',
- ),
- ));
+ ],
+ ]);
$shortcut->save();
- $shortcut = Shortcut::create(array(
+ $shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
- 'link' => array(
+ 'link' => [
'uri' => 'internal:/admin/content',
- ),
- ));
+ ],
+ ]);
$shortcut->save();
}
// Create users.
- $this->adminUser = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview', 'administer users', 'link to any page', 'edit any article content'));
- $this->shortcutUser = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets', 'access shortcuts', 'access content'));
+ $this->adminUser = $this->drupalCreateUser(['access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview', 'administer users', 'link to any page', 'edit any article content']);
+ $this->shortcutUser = $this->drupalCreateUser(['customize shortcut links', 'switch shortcut sets', 'access shortcuts', 'access content']);
// Create a node.
- $this->node = $this->drupalCreateNode(array('type' => 'article'));
+ $this->node = $this->drupalCreateNode(['type' => 'article']);
// Log in as admin and grab the default shortcut set.
$this->drupalLogin($this->adminUser);
@@ -94,10 +94,10 @@ abstract class ShortcutTestBase extends WebTestBase {
* Creates a generic shortcut set.
*/
function generateShortcutSet($label = '', $id = NULL) {
- $set = ShortcutSet::create(array(
+ $set = ShortcutSet::create([
'id' => isset($id) ? $id : strtolower($this->randomMachineName()),
'label' => empty($label) ? $this->randomString() : $label,
- ));
+ ]);
$set->save();
return $set;
}
@@ -117,7 +117,7 @@ abstract class ShortcutTestBase extends WebTestBase {
* Array of the requested information from each link.
*/
function getShortcutInformation(ShortcutSetInterface $set, $key) {
- $info = array();
+ $info = [];
\Drupal::entityManager()->getStorage('shortcut')->resetCache();
foreach ($set->getShortcuts() as $shortcut) {
if ($key == 'link') {
diff --git a/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php b/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php
index 4be41c36dcb..300ca3b7220 100644
--- a/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php
@@ -23,13 +23,13 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'language',
'content_translation',
'link',
'shortcut',
'toolbar'
- );
+ ];
/**
* {@inheritdoc}
@@ -44,7 +44,7 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('access shortcuts', 'administer shortcuts', 'access toolbar'));
+ return array_merge(parent::getTranslatorPermissions(), ['access shortcuts', 'administer shortcuts', 'access toolbar']);
}
/**
@@ -59,7 +59,7 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getNewEntityValues($langcode) {
- return array('title' => array(array('value' => $this->randomMachineName()))) + parent::getNewEntityValues($langcode);
+ return ['title' => [['value' => $this->randomMachineName()]]] + parent::getNewEntityValues($langcode);
}
protected function doTestBasicTranslation() {
@@ -71,14 +71,14 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
$entity = $storage->load($this->entityId);
foreach ($this->langcodes as $langcode) {
if ($entity->hasTranslation($langcode)) {
- $language = new Language(array('id' => $langcode));
+ $language = new Language(['id' => $langcode]);
// Request the front page in this language and assert that the right
// translation shows up in the shortcut list with the right path.
- $this->drupalGet('<front>', array('language' => $language));
- $expected_path = \Drupal::urlGenerator()->generateFromRoute('user.page', array(), array('language' => $language));
+ $this->drupalGet('<front>', ['language' => $language]);
+ $expected_path = \Drupal::urlGenerator()->generateFromRoute('user.page', [], ['language' => $language]);
$label = $entity->getTranslation($langcode)->label();
- $elements = $this->xpath('//nav[contains(@class, "toolbar-lining")]/ul[@class="toolbar-menu"]/li/a[contains(@href, :href) and normalize-space(text())=:label]', array(':href' => $expected_path, ':label' => $label));
- $this->assertTrue(!empty($elements), format_string('Translated @language shortcut link @label found.', array('@label' => $label, '@language' => $language->getName())));
+ $elements = $this->xpath('//nav[contains(@class, "toolbar-lining")]/ul[@class="toolbar-menu"]/li/a[contains(@href, :href) and normalize-space(text())=:label]', [':href' => $expected_path, ':label' => $label]);
+ $this->assertTrue(!empty($elements), format_string('Translated @language shortcut link @label found.', ['@label' => $label, '@language' => $language->getName()]));
}
}
}
@@ -96,14 +96,14 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('@title [%language translation]', array(
+ $title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
@@ -120,7 +120,7 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
$this->assertFalse(
$entity instanceof EntityChangedInterface,
- format_string('%entity is not implementing EntityChangedInterface.', array('%entity' => $this->entityTypeId))
+ format_string('%entity is not implementing EntityChangedInterface.', ['%entity' => $this->entityTypeId])
);
}
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php
index 23f01459a36..e2d6a226f22 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php
@@ -18,7 +18,7 @@ class ShortcutCacheTagsTest extends EntityCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('shortcut');
+ public static $modules = ['shortcut'];
/**
* {@inheritdoc}
@@ -39,12 +39,12 @@ class ShortcutCacheTagsTest extends EntityCacheTagsTestBase {
*/
protected function createEntity() {
// Create a "Llama" shortcut.
- $shortcut = Shortcut::create(array(
+ $shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Llama'),
'weight' => 0,
'link' => [['uri' => 'internal:/admin']],
- ));
+ ]);
$shortcut->save();
return $shortcut;
diff --git a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
index 86582864143..b6543723db6 100644
--- a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
+++ b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
@@ -18,12 +18,12 @@ class MigrateShortcutSetTest extends MigrateDrupal7TestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'link',
'field',
'shortcut',
'menu_link_content',
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php
index 1b15dcdef8c..ae939569cfe 100644
--- a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php
+++ b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php
@@ -17,12 +17,12 @@ class MigrateShortcutSetUsersTest extends MigrateDrupal7TestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'link',
'field',
'shortcut',
'menu_link_content',
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php
index 18f55170a93..e685151a5bc 100644
--- a/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php
+++ b/core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php
@@ -18,12 +18,12 @@ class MigrateShortcutTest extends MigrateDrupal7TestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'link',
'field',
'shortcut',
'menu_link_content',
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php b/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php
index f85a2cf4cab..ee9a6559e4e 100644
--- a/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php
+++ b/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php
@@ -12,10 +12,10 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class ShortcutLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array(
+ $this->directoryList = [
'shortcut' => 'core/modules/shortcut',
'user' => 'core/modules/user',
- );
+ ];
parent::setUp();
}
@@ -25,9 +25,9 @@ class ShortcutLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getShortcutPageRoutes
*/
public function testShortcutPageLocalTasks($route) {
- $tasks = array(
- 0 => array('shortcut.set_switch', 'entity.user.canonical', 'entity.user.edit_form',),
- );
+ $tasks = [
+ 0 => ['shortcut.set_switch', 'entity.user.canonical', 'entity.user.edit_form',],
+ ];
$this->assertLocalTasks($route, $tasks);
}
@@ -35,11 +35,11 @@ class ShortcutLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getShortcutPageRoutes() {
- return array(
- array('entity.user.canonical'),
- array('entity.user.edit_form'),
- array('shortcut.set_switch'),
- );
+ return [
+ ['entity.user.canonical'],
+ ['entity.user.edit_form'],
+ ['shortcut.set_switch'],
+ ];
}
}
diff --git a/core/modules/simpletest/simpletest.install b/core/modules/simpletest/simpletest.install
index 9b3ad90b01b..b6cfc80e100 100644
--- a/core/modules/simpletest/simpletest.install
+++ b/core/modules/simpletest/simpletest.install
@@ -16,25 +16,25 @@ const SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT = '128M';
* Implements hook_requirements().
*/
function simpletest_requirements($phase) {
- $requirements = array();
+ $requirements = [];
$has_phpunit = class_exists('\PHPUnit_Framework_TestCase');
$has_curl = function_exists('curl_init');
$open_basedir = ini_get('open_basedir');
- $requirements['phpunit'] = array(
+ $requirements['phpunit'] = [
'title' => t('PHPUnit dependency'),
'value' => $has_phpunit ? t('Found') : t('Not found'),
- );
+ ];
if (!$has_phpunit) {
$requirements['phpunit']['severity'] = REQUIREMENT_ERROR;
$requirements['phpunit']['description'] = t("The testing framework requires the PHPUnit package. Please run 'composer install --dev' to ensure it is present.");
}
- $requirements['curl'] = array(
+ $requirements['curl'] = [
'title' => t('cURL'),
'value' => $has_curl ? t('Enabled') : t('Not found'),
- );
+ ];
if (!$has_curl) {
$requirements['curl']['severity'] = REQUIREMENT_ERROR;
$requirements['curl']['description'] = t('The testing framework requires the <a href="https://secure.php.net/manual/en/curl.setup.php">PHP cURL library</a>. For more information, see the <a href="https://www.drupal.org/requirements/php/curl">online information on installing the PHP cURL extension</a>.');
@@ -43,10 +43,10 @@ function simpletest_requirements($phase) {
// SimpleTest currently needs 2 cURL options which are incompatible with
// having PHP's open_basedir restriction set.
// See https://www.drupal.org/node/674304.
- $requirements['php_open_basedir'] = array(
+ $requirements['php_open_basedir'] = [
'title' => t('PHP open_basedir restriction'),
'value' => $open_basedir ? t('Enabled') : t('Disabled'),
- );
+ ];
if ($open_basedir) {
$requirements['php_open_basedir']['severity'] = REQUIREMENT_ERROR;
$requirements['php_open_basedir']['description'] = t('The testing framework requires the PHP <a href="http://php.net/manual/ini.core.php#ini.open-basedir">open_basedir</a> restriction to be disabled. Check your webserver configuration or contact your web host.');
@@ -57,29 +57,29 @@ function simpletest_requirements($phase) {
$memory_limit = ini_get('memory_limit');
if (!Environment::checkMemoryLimit(SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
$requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
- $requirements['php_memory_limit']['description'] = t('The testing framework requires the PHP memory limit to be at least %memory_minimum_limit. The current value is %memory_limit. <a href=":url">Follow these steps to continue</a>.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, ':url' => 'https://www.drupal.org/node/207036'));
+ $requirements['php_memory_limit']['description'] = t('The testing framework requires the PHP memory limit to be at least %memory_minimum_limit. The current value is %memory_limit. <a href=":url">Follow these steps to continue</a>.', ['%memory_limit' => $memory_limit, '%memory_minimum_limit' => SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, ':url' => 'https://www.drupal.org/node/207036']);
}
$site_directory = 'sites/simpletest';
if (!drupal_verify_install_file(\Drupal::root() . '/' . $site_directory, FILE_EXIST | FILE_READABLE | FILE_WRITABLE | FILE_EXECUTABLE, 'dir')) {
- $requirements['simpletest_site_directory'] = array(
+ $requirements['simpletest_site_directory'] = [
'title' => t('Simpletest site directory'),
'value' => is_dir(\Drupal::root() . '/' . $site_directory) ? t('Not writable') : t('Missing'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The testing framework requires the %sites-simpletest directory to exist and be writable in order to run tests.', array(
+ 'description' => t('The testing framework requires the %sites-simpletest directory to exist and be writable in order to run tests.', [
'%sites-simpletest' => $site_directory,
- )),
- );
+ ]),
+ ];
}
elseif (!file_save_htaccess(\Drupal::root() . '/' . $site_directory, FALSE)) {
- $requirements['simpletest_site_directory'] = array(
+ $requirements['simpletest_site_directory'] = [
'title' => t('Simpletest site directory'),
'value' => t('Not protected'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The file %file does not exist and could not be created automatically, which poses a security risk. Ensure that the directory is writable.', array(
+ 'description' => t('The file %file does not exist and could not be created automatically, which poses a security risk. Ensure that the directory is writable.', [
'%file' => $site_directory . '/.htaccess',
- )),
- );
+ ]),
+ ];
}
return $requirements;
@@ -89,91 +89,91 @@ function simpletest_requirements($phase) {
* Implements hook_schema().
*/
function simpletest_schema() {
- $schema['simpletest'] = array(
+ $schema['simpletest'] = [
'description' => 'Stores simpletest messages',
- 'fields' => array(
- 'message_id' => array(
+ 'fields' => [
+ 'message_id' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique simpletest message ID.',
- ),
- 'test_id' => array(
+ ],
+ 'test_id' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Test ID, messages belonging to the same ID are reported together',
- ),
- 'test_class' => array(
+ ],
+ 'test_class' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The name of the class that created this message.',
- ),
- 'status' => array(
+ ],
+ 'status' => [
'type' => 'varchar',
'length' => 9,
'not null' => TRUE,
'default' => '',
'description' => 'Message status. Core understands pass, fail, exception.',
- ),
- 'message' => array(
+ ],
+ 'message' => [
'type' => 'text',
'not null' => TRUE,
'description' => 'The message itself.',
- ),
- 'message_group' => array(
+ ],
+ 'message_group' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The message group this message belongs to. For example: warning, browser, user.',
- ),
- 'function' => array(
+ ],
+ 'function' => [
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Name of the assertion function or method that created this message.',
- ),
- 'line' => array(
+ ],
+ 'line' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Line number on which the function is called.',
- ),
- 'file' => array(
+ ],
+ 'file' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Name of the file where the function is called.',
- ),
- ),
- 'primary key' => array('message_id'),
- 'indexes' => array(
- 'reporter' => array('test_class', 'message_id'),
- ),
- );
- $schema['simpletest_test_id'] = array(
+ ],
+ ],
+ 'primary key' => ['message_id'],
+ 'indexes' => [
+ 'reporter' => ['test_class', 'message_id'],
+ ],
+ ];
+ $schema['simpletest_test_id'] = [
'description' => 'Stores simpletest test IDs, used to auto-increment the test ID so that a fresh test ID is used.',
- 'fields' => array(
- 'test_id' => array(
+ 'fields' => [
+ 'test_id' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique simpletest ID used to group test results together. Each time a set of tests
are run a new test ID is used.',
- ),
- 'last_prefix' => array(
+ ],
+ 'last_prefix' => [
'type' => 'varchar',
'length' => 60,
'not null' => FALSE,
'default' => '',
'description' => 'The last database prefix used during testing.',
- ),
- ),
- 'primary key' => array('test_id'),
- );
+ ],
+ ],
+ 'primary key' => ['test_id'],
+ ];
return $schema;
}
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index c9eed3be57d..aa1088f2c1e 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -24,11 +24,11 @@ function simpletest_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.simpletest':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Testing module provides a framework for running automated tests. It can be used to verify a working state of Drupal before and after any code changes, or as a means for developers to write and execute tests for their modules. For more information, see the <a href=":simpletest">online documentation for the Testing module</a>.', array(':simpletest' => 'https://www.drupal.org/documentation/modules/simpletest')) . '</p>';
+ $output .= '<p>' . t('The Testing module provides a framework for running automated tests. It can be used to verify a working state of Drupal before and after any code changes, or as a means for developers to write and execute tests for their modules. For more information, see the <a href=":simpletest">online documentation for the Testing module</a>.', [':simpletest' => 'https://www.drupal.org/documentation/modules/simpletest']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Running tests') . '</dt>';
- $output .= '<dd><p>' . t('Visit the <a href=":admin-simpletest">Testing page</a> to display a list of available tests. For comprehensive testing, select <em>all</em> tests, or individually select tests for more targeted testing. Note that it might take several minutes for all tests to complete.', array(':admin-simpletest' => \Drupal::url('simpletest.test_form'))) . '</p>';
+ $output .= '<dd><p>' . t('Visit the <a href=":admin-simpletest">Testing page</a> to display a list of available tests. For comprehensive testing, select <em>all</em> tests, or individually select tests for more targeted testing. Note that it might take several minutes for all tests to complete.', [':admin-simpletest' => \Drupal::url('simpletest.test_form')]) . '</p>';
$output .= '<p>' . t('After the tests run, a message will be displayed next to each test group indicating whether tests within it passed, failed, or had exceptions. A pass means that the test returned the expected results, while fail means that it did not. An exception normally indicates an error outside of the test, such as a PHP warning or notice. If there were failures or exceptions, the results will be expanded to show details, and the tests that had failures or exceptions will be indicated in red or pink rows. You can then use these results to refine your code and tests, until all tests pass.') . '</p></dd>';
$output .= '</dl>';
return $output;
@@ -43,11 +43,11 @@ function simpletest_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function simpletest_theme() {
- return array(
- 'simpletest_result_summary' => array(
- 'variables' => array('label' => NULL, 'items' => array(), 'pass' => 0, 'fail' => 0, 'exception' => 0, 'debug' => 0),
- ),
- );
+ return [
+ 'simpletest_result_summary' => [
+ 'variables' => ['label' => NULL, 'items' => [], 'pass' => 0, 'fail' => 0, 'exception' => 0, 'debug' => 0],
+ ],
+ ];
}
/**
@@ -138,7 +138,7 @@ function simpletest_run_tests($test_list) {
}
$test_id = db_insert('simpletest_test_id')
- ->useDefaults(array('test_id'))
+ ->useDefaults(['test_id'])
->execute();
// Clear out the previous verbose files.
@@ -148,16 +148,16 @@ function simpletest_run_tests($test_list) {
$first_test = reset($test_list);
$info = TestDiscovery::getTestInfo($first_test);
- $batch = array(
+ $batch = [
'title' => t('Running tests'),
- 'operations' => array(
- array('_simpletest_batch_operation', array($test_list, $test_id)),
- ),
+ 'operations' => [
+ ['_simpletest_batch_operation', [$test_list, $test_id]],
+ ],
'finished' => '_simpletest_batch_finished',
'progress_message' => '',
- 'library' => array('simpletest/drupal.simpletest'),
- 'init_message' => t('Processing test @num of @max - %test.', array('%test' => $info['name'], '@num' => '1', '@max' => count($test_list))),
- );
+ 'library' => ['simpletest/drupal.simpletest'],
+ 'init_message' => t('Processing test @num of @max - %test.', ['%test' => $info['name'], '@num' => '1', '@max' => count($test_list)]),
+ ];
batch_set($batch);
\Drupal::moduleHandler()->invokeAll('test_group_started');
@@ -237,12 +237,12 @@ function simpletest_summarize_phpunit_result($results) {
$summaries = [];
foreach ($results as $result) {
if (!isset($summaries[$result['test_class']])) {
- $summaries[$result['test_class']] = array(
+ $summaries[$result['test_class']] = [
'#pass' => 0,
'#fail' => 0,
'#exception' => 0,
'#debug' => 0,
- );
+ ];
}
switch ($result['status']) {
@@ -322,13 +322,13 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun
}
$phpunit_bin = simpletest_phpunit_command();
- $command = array(
+ $command = [
$phpunit_bin,
'--log-junit',
escapeshellarg($phpunit_file),
'--printer',
escapeshellarg(SimpletestUiPrinter::class),
- );
+ ];
// Optimized for running a single test.
if (count($unescaped_test_classnames) == 1) {
@@ -342,10 +342,10 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun
}, $unescaped_test_classnames);
$filter_string = implode("|", $escaped_test_classnames);
- $command = array_merge($command, array(
+ $command = array_merge($command, [
'--filter',
escapeshellarg($filter_string),
- ));
+ ]);
}
// Need to change directories before running the command so that we can use
@@ -401,7 +401,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
// First iteration: initialize working values.
$test_list = $test_list_init;
$context['sandbox']['max'] = count($test_list);
- $test_results = array('#pass' => 0, '#fail' => 0, '#exception' => 0, '#debug' => 0);
+ $test_results = ['#pass' => 0, '#fail' => 0, '#exception' => 0, '#debug' => 0];
}
else {
// Nth iteration: get the current values where we last stored them.
@@ -420,7 +420,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
else {
$test = new $test_class($test_id);
$test->run();
- \Drupal::moduleHandler()->invokeAll('test_finished', array($test->results));
+ \Drupal::moduleHandler()->invokeAll('test_finished', [$test->results]);
$test_results[$test_class] = $test->results;
}
$size = count($test_list);
@@ -431,25 +431,25 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
$test_results[$key] += $value;
}
$test_results[$test_class]['#name'] = $info['name'];
- $items = array();
+ $items = [];
foreach (Element::children($test_results) as $class) {
- $class_test_result = $test_results[$class] + array(
+ $class_test_result = $test_results[$class] + [
'#theme' => 'simpletest_result_summary',
'#label' => t($test_results[$class]['#name'] . ':'),
- );
+ ];
array_unshift($items, drupal_render($class_test_result));
}
- $context['message'] = t('Processed test @num of @max - %test.', array('%test' => $info['name'], '@num' => $max - $size, '@max' => $max));
- $overall_results = $test_results + array(
+ $context['message'] = t('Processed test @num of @max - %test.', ['%test' => $info['name'], '@num' => $max - $size, '@max' => $max]);
+ $overall_results = $test_results + [
'#theme' => 'simpletest_result_summary',
'#label' => t('Overall results:'),
- );
+ ];
$context['message'] .= drupal_render($overall_results);
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
$context['message'] .= drupal_render($item_list);
// Save working values for the next iteration.
@@ -467,7 +467,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
*/
function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
if ($success) {
- drupal_set_message(t('The test run finished in @elapsed.', array('@elapsed' => $elapsed)));
+ drupal_set_message(t('The test run finished in @elapsed.', ['@elapsed' => $elapsed]));
}
else {
// Use the test_id passed as a parameter to _simpletest_batch_operation().
@@ -496,16 +496,16 @@ function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
*/
function simpletest_last_test_get($test_id) {
$last_prefix = TestDatabase::getConnection()
- ->queryRange('SELECT last_prefix FROM {simpletest_test_id} WHERE test_id = :test_id', 0, 1, array(
+ ->queryRange('SELECT last_prefix FROM {simpletest_test_id} WHERE test_id = :test_id', 0, 1, [
':test_id' => $test_id,
- ))
+ ])
->fetchField();
$last_test_class = TestDatabase::getConnection()
- ->queryRange('SELECT test_class FROM {simpletest} WHERE test_id = :test_id ORDER BY message_id DESC', 0, 1, array(
+ ->queryRange('SELECT test_class FROM {simpletest} WHERE test_id = :test_id ORDER BY message_id DESC', 0, 1, [
':test_id' => $test_id,
- ))
+ ])
->fetchField();
- return array($last_prefix, $last_test_class);
+ return [$last_prefix, $last_test_class];
}
/**
@@ -533,10 +533,10 @@ function simpletest_log_read($test_id, $database_prefix, $test_class) {
if (preg_match('/\[.*?\] (.*?): (.*?) in (.*) on line (\d+)/', $line, $match)) {
// Parse PHP fatal errors for example: PHP Fatal error: Call to
// undefined function break_me() in /path/to/file.php on line 17
- $caller = array(
+ $caller = [
'line' => $match[4],
'file' => $match[3],
- );
+ ];
TestBase::insertAssert($test_id, $test_class, FALSE, $match[2], $match[1], $caller);
}
else {
@@ -692,7 +692,7 @@ function simpletest_clean_temporary_directories() {
foreach ($files as $file) {
if ($file[0] != '.') {
$path = DRUPAL_ROOT . '/sites/simpletest/' . $file;
- file_unmanaged_delete_recursive($path, array('Drupal\simpletest\TestBase', 'filePreDeleteCallback'));
+ file_unmanaged_delete_recursive($path, ['Drupal\simpletest\TestBase', 'filePreDeleteCallback']);
$count++;
}
}
@@ -719,7 +719,7 @@ function simpletest_clean_results_table($test_id = NULL) {
if (\Drupal::config('simpletest.settings')->get('clear_results')) {
$connection = TestDatabase::getConnection();
if ($test_id) {
- $count = $connection->query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))->fetchField();
+ $count = $connection->query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', [':test_id' => $test_id])->fetchField();
$connection->delete('simpletest')
->condition('test_id', $test_id)
@@ -771,7 +771,7 @@ function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
if (!$contents) {
return;
}
- $records = array();
+ $records = [];
$testcases = simpletest_phpunit_find_testcases(new SimpleXMLElement($contents));
foreach ($testcases as $testcase) {
$records[] = simpletest_phpunit_testcase_to_row($test_id, $testcase);
@@ -791,7 +791,7 @@ function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
* A list of all test cases.
*/
function simpletest_phpunit_find_testcases(\SimpleXMLElement $element, \SimpleXMLElement $parent = NULL) {
- $testcases = array();
+ $testcases = [];
if (!isset($parent)) {
$parent = $element;
@@ -845,7 +845,7 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas
$attributes = $testcase->attributes();
- $record = array(
+ $record = [
'test_id' => $test_id,
'test_class' => (string) $attributes->class,
'status' => $pass ? 'pass' : 'fail',
@@ -855,6 +855,6 @@ function simpletest_phpunit_testcase_to_row($test_id, \SimpleXMLElement $testcas
'function' => $attributes->class . '->' . $attributes->name . '()',
'line' => $attributes->line ?: 0,
'file' => $attributes->file,
- );
+ ];
return $record;
}
diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php
index e19f319c7ce..5a6c8c06ef5 100644
--- a/core/modules/simpletest/src/AssertContentTrait.php
+++ b/core/modules/simpletest/src/AssertContentTrait.php
@@ -61,7 +61,7 @@ trait AssertContentTrait {
$this->content = $content;
$this->plainTextContent = NULL;
$this->elements = NULL;
- $this->drupalSettings = array();
+ $this->drupalSettings = [];
if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $content, $matches)) {
$this->drupalSettings = Json::decode($matches[1]);
}
@@ -75,7 +75,7 @@ trait AssertContentTrait {
$raw_content = $this->getRawContent();
// Strip everything between the HEAD tags.
$raw_content = preg_replace('@<head>(.+?)</head>@si', '', $raw_content);
- $this->plainTextContent = Xss::filter($raw_content, array());
+ $this->plainTextContent = Xss::filter($raw_content, []);
}
return $this->plainTextContent;
}
@@ -127,7 +127,7 @@ trait AssertContentTrait {
$html_dom = new \DOMDocument();
@$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent());
if ($html_dom) {
- $this->pass(SafeMarkup::format('Valid HTML found on "@path"', array('@path' => $this->getUrl())), 'Browser');
+ $this->pass(SafeMarkup::format('Valid HTML found on "@path"', ['@path' => $this->getUrl()]), 'Browser');
// It's much easier to work with simplexml than DOM, luckily enough
// we can just simply import our DOM tree.
$this->elements = simplexml_import_dom($html_dom);
@@ -170,7 +170,7 @@ trait AssertContentTrait {
* @return string
* An XPath query with arguments replaced.
*/
- protected function buildXPathQuery($xpath, array $args = array()) {
+ protected function buildXPathQuery($xpath, array $args = []) {
// Replace placeholders.
foreach ($args as $placeholder => $value) {
// Cast MarkupInterface objects to string.
@@ -260,7 +260,7 @@ trait AssertContentTrait {
* Option elements in select.
*/
protected function getAllOptions(\SimpleXMLElement $element) {
- $options = array();
+ $options = [];
// Add all options items.
foreach ($element->option as $option) {
$options[] = $option;
@@ -300,8 +300,8 @@ trait AssertContentTrait {
protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {
// Cast MarkupInterface objects to string.
$label = (string) $label;
- $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
- $message = ($message ? $message : strtr('Link with label %label found.', array('%label' => $label)));
+ $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
+ $message = ($message ? $message : strtr('Link with label %label found.', ['%label' => $label]));
return $this->assert(isset($links[$index]), $message, $group);
}
@@ -327,8 +327,8 @@ trait AssertContentTrait {
protected function assertNoLink($label, $message = '', $group = 'Other') {
// Cast MarkupInterface objects to string.
$label = (string) $label;
- $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
- $message = ($message ? $message : SafeMarkup::format('Link with label %label not found.', array('%label' => $label)));
+ $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
+ $message = ($message ? $message : SafeMarkup::format('Link with label %label not found.', ['%label' => $label]));
return $this->assert(empty($links), $message, $group);
}
@@ -354,8 +354,8 @@ trait AssertContentTrait {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other') {
- $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
- $message = ($message ? $message : SafeMarkup::format('Link containing href %href found.', array('%href' => $href)));
+ $links = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
+ $message = ($message ? $message : SafeMarkup::format('Link containing href %href found.', ['%href' => $href]));
return $this->assert(isset($links[$index]), $message, $group);
}
@@ -379,8 +379,8 @@ trait AssertContentTrait {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
- $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
- $message = ($message ? $message : SafeMarkup::format('No link containing href %href found.', array('%href' => $href)));
+ $links = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
+ $message = ($message ? $message : SafeMarkup::format('No link containing href %href found.', ['%href' => $href]));
return $this->assert(empty($links), $message, $group);
}
@@ -404,8 +404,8 @@ trait AssertContentTrait {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertNoLinkByHrefInMainRegion($href, $message = '', $group = 'Other') {
- $links = $this->xpath('//main//a[contains(@href, :href)]', array(':href' => $href));
- $message = ($message ? $message : SafeMarkup::format('No link containing href %href found.', array('%href' => $href)));
+ $links = $this->xpath('//main//a[contains(@href, :href)]', [':href' => $href]);
+ $message = ($message ? $message : SafeMarkup::format('No link containing href %href found.', ['%href' => $href]));
return $this->assert(empty($links), $message, $group);
}
@@ -604,7 +604,7 @@ trait AssertContentTrait {
*/
protected function assertTextHelper($text, $message = '', $group = 'Other', $not_exists = TRUE) {
if (!$message) {
- $message = !$not_exists ? SafeMarkup::format('"@text" found', array('@text' => $text)) : SafeMarkup::format('"@text" not found', array('@text' => $text));
+ $message = !$not_exists ? SafeMarkup::format('"@text" found', ['@text' => $text]) : SafeMarkup::format('"@text" not found', ['@text' => $text]);
}
return $this->assert($not_exists == (strpos($this->getTextContent(), (string) $text) === FALSE), $message, $group);
}
@@ -723,7 +723,7 @@ trait AssertContentTrait {
*/
protected function assertPattern($pattern, $message = '', $group = 'Other') {
if (!$message) {
- $message = SafeMarkup::format('Pattern "@pattern" found', array('@pattern' => $pattern));
+ $message = SafeMarkup::format('Pattern "@pattern" found', ['@pattern' => $pattern]);
}
return $this->assert((bool) preg_match($pattern, $this->getRawContent()), $message, $group);
}
@@ -749,7 +749,7 @@ trait AssertContentTrait {
*/
protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
if (!$message) {
- $message = SafeMarkup::format('Pattern "@pattern" not found', array('@pattern' => $pattern));
+ $message = SafeMarkup::format('Pattern "@pattern" not found', ['@pattern' => $pattern]);
}
return $this->assert(!preg_match($pattern, $this->getRawContent()), $message, $group);
}
@@ -772,7 +772,7 @@ trait AssertContentTrait {
*/
protected function assertTextPattern($pattern, $message = NULL, $group = 'Other') {
if (!isset($message)) {
- $message = SafeMarkup::format('Pattern "@pattern" found', array('@pattern' => $pattern));
+ $message = SafeMarkup::format('Pattern "@pattern" found', ['@pattern' => $pattern]);
}
return $this->assert((bool) preg_match($pattern, $this->getTextContent()), $message, $group);
}
@@ -804,10 +804,10 @@ trait AssertContentTrait {
$actual = $this->castSafeStrings($actual);
$title = $this->castSafeStrings($title);
if (!$message) {
- $message = SafeMarkup::format('Page title @actual is equal to @expected.', array(
+ $message = SafeMarkup::format('Page title @actual is equal to @expected.', [
'@actual' => var_export($actual, TRUE),
'@expected' => var_export($title, TRUE),
- ));
+ ]);
}
return $this->assertEqual($actual, $title, $message, $group);
}
@@ -836,10 +836,10 @@ trait AssertContentTrait {
protected function assertNoTitle($title, $message = '', $group = 'Other') {
$actual = (string) current($this->xpath('//title'));
if (!$message) {
- $message = SafeMarkup::format('Page title @actual is not equal to @unexpected.', array(
+ $message = SafeMarkup::format('Page title @actual is not equal to @unexpected.', [
'@actual' => var_export($actual, TRUE),
'@unexpected' => var_export($title, TRUE),
- ));
+ ]);
}
return $this->assertNotEqual($actual, $title, $message, $group);
}
@@ -867,7 +867,7 @@ trait AssertContentTrait {
* @return bool
* TRUE on pass, FALSE on fail.
*/
- protected function assertThemeOutput($callback, array $variables = array(), $expected = '', $message = '', $group = 'Other') {
+ protected function assertThemeOutput($callback, array $variables = [], $expected = '', $message = '', $group = 'Other') {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
@@ -885,7 +885,7 @@ trait AssertContentTrait {
if (!$message) {
$message = '%callback rendered correctly.';
}
- $message = format_string($message, array('%callback' => 'theme_' . $callback . '()'));
+ $message = format_string($message, ['%callback' => 'theme_' . $callback . '()']);
return $this->assertIdentical($output, $expected, $message, $group);
}
@@ -1064,15 +1064,15 @@ trait AssertContentTrait {
protected function assertFieldByName($name, $value = NULL, $message = NULL, $group = 'Browser') {
if (!isset($message)) {
if (!isset($value)) {
- $message = SafeMarkup::format('Found field with name @name', array(
+ $message = SafeMarkup::format('Found field with name @name', [
'@name' => var_export($name, TRUE),
- ));
+ ]);
}
else {
- $message = SafeMarkup::format('Found field with name @name and value @value', array(
+ $message = SafeMarkup::format('Found field with name @name and value @value', [
'@name' => var_export($name, TRUE),
'@value' => var_export($value, TRUE),
- ));
+ ]);
}
}
return $this->assertFieldByXPath($this->constructFieldXpath('name', $name), $value, $message, $group);
@@ -1103,7 +1103,7 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertNoFieldByName($name, $value = '', $message = '', $group = 'Browser') {
- return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : SafeMarkup::format('Did not find field by name @name', array('@name' => $name)), $group);
+ return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : SafeMarkup::format('Did not find field by name @name', ['@name' => $name]), $group);
}
/**
@@ -1136,7 +1136,7 @@ trait AssertContentTrait {
$value = (string) $value;
}
$message = (string) $message;
- return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : SafeMarkup::format('Found field by id @id', array('@id' => $id)), $group);
+ return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : SafeMarkup::format('Found field by id @id', ['@id' => $id]), $group);
}
/**
@@ -1164,7 +1164,7 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertNoFieldById($id, $value = '', $message = '', $group = 'Browser') {
- return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : SafeMarkup::format('Did not find field by id @id', array('@id' => $id)), $group);
+ return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : SafeMarkup::format('Did not find field by id @id', ['@id' => $id]), $group);
}
/**
@@ -1187,8 +1187,8 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
- $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
- return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : SafeMarkup::format('Checkbox field @id is checked.', array('@id' => $id)), $group);
+ $elements = $this->xpath('//input[@id=:id]', [':id' => $id]);
+ return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : SafeMarkup::format('Checkbox field @id is checked.', ['@id' => $id]), $group);
}
/**
@@ -1211,8 +1211,8 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertNoFieldChecked($id, $message = '', $group = 'Browser') {
- $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
- return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : SafeMarkup::format('Checkbox field @id is not checked.', array('@id' => $id)), $group);
+ $elements = $this->xpath('//input[@id=:id]', [':id' => $id]);
+ return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : SafeMarkup::format('Checkbox field @id is not checked.', ['@id' => $id]), $group);
}
/**
@@ -1237,8 +1237,8 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertOption($id, $option, $message = '', $group = 'Browser') {
- $options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
- return $this->assertTrue(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id exists.', array('@option' => $option, '@id' => $id)), $group);
+ $options = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
+ return $this->assertTrue(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id exists.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1281,8 +1281,8 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertOptionWithDrupalSelector($drupal_selector, $option, $message = '', $group = 'Browser') {
- $options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', array(':data_drupal_selector' => $drupal_selector, ':option' => $option));
- return $this->assertTrue(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector exists.', array('@option' => $option, '@data_drupal_selector' => $drupal_selector)), $group);
+ $options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', [':data_drupal_selector' => $drupal_selector, ':option' => $option]);
+ return $this->assertTrue(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector exists.', ['@option' => $option, '@data_drupal_selector' => $drupal_selector]), $group);
}
/**
@@ -1307,9 +1307,9 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertNoOption($id, $option, $message = '', $group = 'Browser') {
- $selects = $this->xpath('//select[@id=:id]', array(':id' => $id));
- $options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
- return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), $group);
+ $selects = $this->xpath('//select[@id=:id]', [':id' => $id]);
+ $options = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
+ return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id does not exist.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1336,8 +1336,8 @@ trait AssertContentTrait {
* @todo $id is unusable. Replace with $name.
*/
protected function assertOptionSelected($id, $option, $message = '', $group = 'Browser') {
- $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
- return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id)), $group);
+ $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
+ return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is selected.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1364,8 +1364,8 @@ trait AssertContentTrait {
* @todo $id is unusable. Replace with $name.
*/
protected function assertOptionSelectedWithDrupalSelector($drupal_selector, $option, $message = '', $group = 'Browser') {
- $elements = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', array(':data_drupal_selector' => $drupal_selector, ':option' => $option));
- return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector is selected.', array('@option' => $option, '@data_drupal_selector' => $drupal_selector)), $group);
+ $elements = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', [':data_drupal_selector' => $drupal_selector, ':option' => $option]);
+ return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector is selected.', ['@option' => $option, '@data_drupal_selector' => $drupal_selector]), $group);
}
/**
@@ -1390,8 +1390,8 @@ trait AssertContentTrait {
* TRUE on pass, FALSE on fail.
*/
protected function assertNoOptionSelected($id, $option, $message = '', $group = 'Browser') {
- $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
- return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is not selected.', array('@option' => $option, '@id' => $id)), $group);
+ $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
+ return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is not selected.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1464,12 +1464,12 @@ trait AssertContentTrait {
* @return bool
* TRUE on pass, FALSE on fail.
*/
- protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to_skip = array()) {
+ protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to_skip = []) {
$status = TRUE;
foreach ($this->xpath('//*[@id]') as $element) {
$id = (string) $element['id'];
if (isset($seen_ids[$id]) && !in_array($id, $ids_to_skip)) {
- $this->fail(SafeMarkup::format('The HTML ID %id is unique.', array('%id' => $id)), $group);
+ $this->fail(SafeMarkup::format('The HTML ID %id is unique.', ['%id' => $id]), $group);
$status = FALSE;
}
$seen_ids[$id] = TRUE;
@@ -1490,7 +1490,7 @@ trait AssertContentTrait {
*/
protected function constructFieldXpath($attribute, $value) {
$xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]';
- return $this->buildXPathQuery($xpath, array(':value' => $value));
+ return $this->buildXPathQuery($xpath, [':value' => $value]);
}
}
diff --git a/core/modules/simpletest/src/BlockCreationTrait.php b/core/modules/simpletest/src/BlockCreationTrait.php
index 4b36f787d95..b252d9e9e65 100644
--- a/core/modules/simpletest/src/BlockCreationTrait.php
+++ b/core/modules/simpletest/src/BlockCreationTrait.php
@@ -38,19 +38,19 @@ trait BlockCreationTrait {
* @todo
* Add support for creating custom block instances.
*/
- protected function placeBlock($plugin_id, array $settings = array()) {
+ protected function placeBlock($plugin_id, array $settings = []) {
$config = \Drupal::configFactory();
- $settings += array(
+ $settings += [
'plugin' => $plugin_id,
'region' => 'sidebar_first',
'id' => strtolower($this->randomMachineName(8)),
'theme' => $config->get('system.theme')->get('default'),
'label' => $this->randomMachineName(8),
- 'visibility' => array(),
+ 'visibility' => [],
'weight' => 0,
- );
+ ];
$values = [];
- foreach (array('region', 'id', 'theme', 'plugin', 'weight', 'visibility') as $key) {
+ foreach (['region', 'id', 'theme', 'plugin', 'weight', 'visibility'] as $key) {
$values[$key] = $settings[$key];
// Remove extra values that do not belong in the settings array.
unset($settings[$key]);
diff --git a/core/modules/simpletest/src/ContentTypeCreationTrait.php b/core/modules/simpletest/src/ContentTypeCreationTrait.php
index 54712df0bd1..9ad0a217921 100644
--- a/core/modules/simpletest/src/ContentTypeCreationTrait.php
+++ b/core/modules/simpletest/src/ContentTypeCreationTrait.php
@@ -22,7 +22,7 @@ trait ContentTypeCreationTrait {
* @return \Drupal\node\Entity\NodeType
* Created content type.
*/
- protected function createContentType(array $values = array()) {
+ protected function createContentType(array $values = []) {
// Find a non-existent random type name.
if (!isset($values['type'])) {
do {
@@ -32,19 +32,19 @@ trait ContentTypeCreationTrait {
else {
$id = $values['type'];
}
- $values += array(
+ $values += [
'type' => $id,
'name' => $id,
- );
+ ];
$type = NodeType::create($values);
$status = $type->save();
node_add_body_field($type);
if ($this instanceof \PHPUnit_Framework_TestCase) {
- $this->assertSame($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', array('%type' => $type->id())))->__toString());
+ $this->assertSame($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString());
}
else {
- $this->assertEqual($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', array('%type' => $type->id())))->__toString());
+ $this->assertEqual($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString());
}
return $type;
diff --git a/core/modules/simpletest/src/Form/SimpletestResultsForm.php b/core/modules/simpletest/src/Form/SimpletestResultsForm.php
index c22c0a7d0cb..090ae0276ea 100644
--- a/core/modules/simpletest/src/Form/SimpletestResultsForm.php
+++ b/core/modules/simpletest/src/Form/SimpletestResultsForm.php
@@ -59,40 +59,40 @@ class SimpletestResultsForm extends FormBase {
* Builds the status image map.
*/
protected static function buildStatusImageMap() {
- $image_pass = array(
+ $image_pass = [
'#theme' => 'image',
'#uri' => 'core/misc/icons/73b355/check.svg',
'#width' => 18,
'#height' => 18,
'#alt' => 'Pass',
- );
- $image_fail = array(
+ ];
+ $image_fail = [
'#theme' => 'image',
'#uri' => 'core/misc/icons/e32700/error.svg',
'#width' => 18,
'#height' => 18,
'#alt' => 'Fail',
- );
- $image_exception = array(
+ ];
+ $image_exception = [
'#theme' => 'image',
'#uri' => 'core/misc/icons/e29700/warning.svg',
'#width' => 18,
'#height' => 18,
'#alt' => 'Exception',
- );
- $image_debug = array(
+ ];
+ $image_debug = [
'#theme' => 'image',
'#uri' => 'core/misc/icons/e29700/warning.svg',
'#width' => 18,
'#height' => 18,
'#alt' => 'Debug',
- );
- return array(
+ ];
+ return [
'pass' => $image_pass,
'fail' => $image_fail,
'exception' => $image_exception,
'debug' => $image_debug,
- );
+ ];
}
/**
@@ -108,10 +108,10 @@ class SimpletestResultsForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state, $test_id = NULL) {
// Make sure there are test results to display and a re-run is not being
// performed.
- $results = array();
+ $results = [];
if (is_numeric($test_id) && !$results = $this->getResults($test_id)) {
drupal_set_message($this->t('No test results to display.'), 'error');
- return new RedirectResponse($this->url('simpletest.test_form', array(), array('absolute' => TRUE)));
+ return new RedirectResponse($this->url('simpletest.test_form', [], ['absolute' => TRUE]));
}
// Load all classes and include CSS.
@@ -120,45 +120,45 @@ class SimpletestResultsForm extends FormBase {
$filter = static::addResultForm($form, $results, $this->getStringTranslation());
// Actions.
- $form['#action'] = $this->url('simpletest.result_form', array('test_id' => 're-run'));
- $form['action'] = array(
+ $form['#action'] = $this->url('simpletest.result_form', ['test_id' => 're-run']);
+ $form['action'] = [
'#type' => 'fieldset',
'#title' => $this->t('Actions'),
- '#attributes' => array('class' => array('container-inline')),
+ '#attributes' => ['class' => ['container-inline']],
'#weight' => -11,
- );
+ ];
- $form['action']['filter'] = array(
+ $form['action']['filter'] = [
'#type' => 'select',
'#title' => 'Filter',
- '#options' => array(
- 'all' => $this->t('All (@count)', array('@count' => count($filter['pass']) + count($filter['fail']))),
- 'pass' => $this->t('Pass (@count)', array('@count' => count($filter['pass']))),
- 'fail' => $this->t('Fail (@count)', array('@count' => count($filter['fail']))),
- ),
- );
+ '#options' => [
+ 'all' => $this->t('All (@count)', ['@count' => count($filter['pass']) + count($filter['fail'])]),
+ 'pass' => $this->t('Pass (@count)', ['@count' => count($filter['pass'])]),
+ 'fail' => $this->t('Fail (@count)', ['@count' => count($filter['fail'])]),
+ ],
+ ];
$form['action']['filter']['#default_value'] = ($filter['fail'] ? 'fail' : 'all');
// Categorized test classes for to be used with selected filter value.
- $form['action']['filter_pass'] = array(
+ $form['action']['filter_pass'] = [
'#type' => 'hidden',
'#default_value' => implode(',', $filter['pass']),
- );
- $form['action']['filter_fail'] = array(
+ ];
+ $form['action']['filter_fail'] = [
'#type' => 'hidden',
'#default_value' => implode(',', $filter['fail']),
- );
+ ];
- $form['action']['op'] = array(
+ $form['action']['op'] = [
'#type' => 'submit',
'#value' => $this->t('Run tests'),
- );
+ ];
- $form['action']['return'] = array(
+ $form['action']['return'] = [
'#type' => 'link',
'#title' => $this->t('Return to list'),
'#url' => Url::fromRoute('simpletest.test_form'),
- );
+ ];
if (is_numeric($test_id)) {
simpletest_clean_results_table($test_id);
@@ -171,8 +171,8 @@ class SimpletestResultsForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $pass = $form_state->getValue('filter_pass') ? explode(',', $form_state->getValue('filter_pass')) : array();
- $fail = $form_state->getValue('filter_fail') ? explode(',', $form_state->getValue('filter_fail')) : array();
+ $pass = $form_state->getValue('filter_pass') ? explode(',', $form_state->getValue('filter_pass')) : [];
+ $fail = $form_state->getValue('filter_fail') ? explode(',', $form_state->getValue('filter_fail')) : [];
if ($form_state->getValue('filter') == 'all') {
$classes = array_merge($pass, $fail);
@@ -189,7 +189,7 @@ class SimpletestResultsForm extends FormBase {
return;
}
- $form_execute = array();
+ $form_execute = [];
$form_state_execute = new FormState();
foreach ($classes as $class) {
$form_state_execute->setValue(['tests', $class], $class);
@@ -247,10 +247,10 @@ class SimpletestResultsForm extends FormBase {
*/
public static function addResultForm(array &$form, array $results) {
// Transform the test results to be grouped by test class.
- $test_results = array();
+ $test_results = [];
foreach ($results as $result) {
if (!isset($test_results[$result->test_class])) {
- $test_results[$result->test_class] = array();
+ $test_results[$result->test_class] = [];
}
$test_results[$result->test_class][] = $result;
}
@@ -258,55 +258,55 @@ class SimpletestResultsForm extends FormBase {
$image_status_map = static::buildStatusImageMap();
// Keep track of which test cases passed or failed.
- $filter = array(
- 'pass' => array(),
- 'fail' => array(),
- );
+ $filter = [
+ 'pass' => [],
+ 'fail' => [],
+ ];
// Summary result widget.
- $form['result'] = array(
+ $form['result'] = [
'#type' => 'fieldset',
'#title' => 'Results',
// Because this is used in a theme-less situation need to provide a
// default.
- '#attributes' => array(),
- );
- $form['result']['summary'] = $summary = array(
+ '#attributes' => [],
+ ];
+ $form['result']['summary'] = $summary = [
'#theme' => 'simpletest_result_summary',
'#pass' => 0,
'#fail' => 0,
'#exception' => 0,
'#debug' => 0,
- );
+ ];
\Drupal::service('test_discovery')->registerTestNamespaces();
// Cycle through each test group.
- $header = array(
+ $header = [
'Message',
'Group',
'Filename',
'Line',
'Function',
- array('colspan' => 2, 'data' => 'Status')
- );
- $form['result']['results'] = array();
+ ['colspan' => 2, 'data' => 'Status']
+ ];
+ $form['result']['results'] = [];
foreach ($test_results as $group => $assertions) {
// Create group details with summary information.
$info = TestDiscovery::getTestInfo($group);
- $form['result']['results'][$group] = array(
+ $form['result']['results'][$group] = [
'#type' => 'details',
'#title' => $info['name'],
'#open' => TRUE,
'#description' => $info['description'],
- );
+ ];
$form['result']['results'][$group]['summary'] = $summary;
$group_summary =& $form['result']['results'][$group]['summary'];
// Create table of assertions for the group.
- $rows = array();
+ $rows = [];
foreach ($assertions as $assertion) {
- $row = array();
+ $row = [];
$row[] = ['data' => ['#markup' => $assertion->message]];
$row[] = $assertion->message_group;
$row[] = \Drupal::service('file_system')->basename(($assertion->file));
@@ -318,16 +318,16 @@ class SimpletestResultsForm extends FormBase {
if ($assertion->message_group == 'Debug') {
$class = 'simpletest-debug';
}
- $rows[] = array('data' => $row, 'class' => array($class));
+ $rows[] = ['data' => $row, 'class' => [$class]];
$group_summary['#' . $assertion->status]++;
$form['result']['summary']['#' . $assertion->status]++;
}
- $form['result']['results'][$group]['table'] = array(
+ $form['result']['results'][$group]['table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- );
+ ];
// Set summary information.
$group_summary['#ok'] = $group_summary['#fail'] + $group_summary['#exception'] == 0;
diff --git a/core/modules/simpletest/src/Form/SimpletestSettingsForm.php b/core/modules/simpletest/src/Form/SimpletestSettingsForm.php
index 744915fbea2..d1ee436c805 100644
--- a/core/modules/simpletest/src/Form/SimpletestSettingsForm.php
+++ b/core/modules/simpletest/src/Form/SimpletestSettingsForm.php
@@ -29,56 +29,56 @@ class SimpletestSettingsForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('simpletest.settings');
- $form['general'] = array(
+ $form['general'] = [
'#type' => 'details',
'#title' => $this->t('General'),
'#open' => TRUE,
- );
- $form['general']['simpletest_clear_results'] = array(
+ ];
+ $form['general']['simpletest_clear_results'] = [
'#type' => 'checkbox',
'#title' => $this->t('Clear results after each complete test suite run'),
'#description' => $this->t('By default SimpleTest will clear the results after they have been viewed on the results page, but in some cases it may be useful to leave the results in the database. The results can then be viewed at <em>admin/config/development/testing/results/[test_id]</em>. The test ID can be found in the database, simpletest table, or kept track of when viewing the results the first time. Additionally, some modules may provide more analysis or features that require this setting to be disabled.'),
'#default_value' => $config->get('clear_results'),
- );
- $form['general']['simpletest_verbose'] = array(
+ ];
+ $form['general']['simpletest_verbose'] = [
'#type' => 'checkbox',
'#title' => $this->t('Provide verbose information when running tests'),
'#description' => $this->t('The verbose data will be printed along with the standard assertions and is useful for debugging. The verbose data will be erased between each test suite run. The verbose data output is very detailed and should only be used when debugging.'),
'#default_value' => $config->get('verbose'),
- );
+ ];
- $form['httpauth'] = array(
+ $form['httpauth'] = [
'#type' => 'details',
'#title' => $this->t('HTTP authentication'),
'#description' => $this->t('HTTP auth settings to be used by the SimpleTest browser during testing. Useful when the site requires basic HTTP authentication.'),
- );
- $form['httpauth']['simpletest_httpauth_method'] = array(
+ ];
+ $form['httpauth']['simpletest_httpauth_method'] = [
'#type' => 'select',
'#title' => $this->t('Method'),
- '#options' => array(
+ '#options' => [
CURLAUTH_BASIC => $this->t('Basic'),
CURLAUTH_DIGEST => $this->t('Digest'),
CURLAUTH_GSSNEGOTIATE => $this->t('GSS negotiate'),
CURLAUTH_NTLM => $this->t('NTLM'),
CURLAUTH_ANY => $this->t('Any'),
CURLAUTH_ANYSAFE => $this->t('Any safe'),
- ),
+ ],
'#default_value' => $config->get('httpauth.method'),
- );
+ ];
$username = $config->get('httpauth.username');
$password = $config->get('httpauth.password');
- $form['httpauth']['simpletest_httpauth_username'] = array(
+ $form['httpauth']['simpletest_httpauth_username'] = [
'#type' => 'textfield',
'#title' => $this->t('Username'),
'#default_value' => $username,
- );
+ ];
if (!empty($username) && !empty($password)) {
$form['httpauth']['simpletest_httpauth_username']['#description'] = $this->t('Leave this blank to delete both the existing username and password.');
}
- $form['httpauth']['simpletest_httpauth_password'] = array(
+ $form['httpauth']['simpletest_httpauth_password'] = [
'#type' => 'password',
'#title' => $this->t('Password'),
- );
+ ];
if ($password) {
$form['httpauth']['simpletest_httpauth_password']['#description'] = $this->t('To change the password, enter the new password here.');
}
diff --git a/core/modules/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php
index ccd8fe8a3bf..f954546eb16 100644
--- a/core/modules/simpletest/src/Form/SimpletestTestForm.php
+++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php
@@ -61,24 +61,24 @@ class SimpletestTestForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Run tests'),
'#tableselect' => TRUE,
'#button_type' => 'primary',
- );
- $form['clean'] = array(
+ ];
+ $form['clean'] = [
'#type' => 'fieldset',
'#title' => $this->t('Clean test environment'),
'#description' => $this->t('Remove tables with the prefix "simpletest" and temporary directories that are left over from tests that crashed. This is intended for developers when creating tests.'),
'#weight' => 200,
- );
- $form['clean']['op'] = array(
+ ];
+ $form['clean']['op'] = [
'#type' => 'submit',
'#value' => $this->t('Clean environment'),
- '#submit' => array('simpletest_clean_environment'),
- );
+ '#submit' => ['simpletest_clean_environment'],
+ ];
// Do not needlessly re-execute a full test discovery if the user input
// already contains an explicit list of test classes to run.
@@ -88,43 +88,43 @@ class SimpletestTestForm extends FormBase {
}
// JavaScript-only table filters.
- $form['filters'] = array(
+ $form['filters'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('table-filter', 'js-show'),
- ),
- );
- $form['filters']['text'] = array(
+ '#attributes' => [
+ 'class' => ['table-filter', 'js-show'],
+ ],
+ ];
+ $form['filters']['text'] = [
'#type' => 'search',
'#title' => $this->t('Search'),
'#size' => 30,
'#placeholder' => $this->t('Enter test name…'),
- '#attributes' => array(
- 'class' => array('table-filter-text'),
+ '#attributes' => [
+ 'class' => ['table-filter-text'],
'data-table' => '#simpletest-test-form',
'autocomplete' => 'off',
'title' => $this->t('Enter at least 3 characters of the test name or description to filter by.'),
- ),
- );
+ ],
+ ];
- $form['tests'] = array(
+ $form['tests'] = [
'#type' => 'table',
'#id' => 'simpletest-form-table',
'#tableselect' => TRUE,
- '#header' => array(
- array('data' => $this->t('Test'), 'class' => array('simpletest-test-label')),
- array('data' => $this->t('Description'), 'class' => array('simpletest-test-description')),
- ),
+ '#header' => [
+ ['data' => $this->t('Test'), 'class' => ['simpletest-test-label']],
+ ['data' => $this->t('Description'), 'class' => ['simpletest-test-description']],
+ ],
'#empty' => $this->t('No tests to display.'),
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'simpletest/drupal.simpletest',
- ),
- ),
- );
+ ],
+ ],
+ ];
// Define the images used to expand/collapse the test groups.
- $image_collapsed = array(
+ $image_collapsed = [
'#theme' => 'image',
'#uri' => 'core/misc/menu-collapsed.png',
'#width' => '7',
@@ -132,8 +132,8 @@ class SimpletestTestForm extends FormBase {
'#alt' => $this->t('Expand'),
'#title' => $this->t('Expand'),
'#suffix' => '<a href="#" class="simpletest-collapse">(' . $this->t('Expand') . ')</a>',
- );
- $image_extended = array(
+ ];
+ $image_extended = [
'#theme' => 'image',
'#uri' => 'core/misc/menu-expanded.png',
'#width' => '7',
@@ -141,7 +141,7 @@ class SimpletestTestForm extends FormBase {
'#alt' => $this->t('Collapse'),
'#title' => $this->t('Collapse'),
'#suffix' => '<a href="#" class="simpletest-collapse">(' . $this->t('Collapse') . ')</a>',
- );
+ ];
$form['tests']['#attached']['drupalSettings']['simpleTest']['images'] = [
(string) $this->renderer->renderPlain($image_collapsed),
(string) $this->renderer->renderPlain($image_extended),
@@ -150,9 +150,9 @@ class SimpletestTestForm extends FormBase {
// Generate the list of tests arranged by group.
$groups = $this->testDiscovery->getTestClasses();
foreach ($groups as $group => $tests) {
- $form['tests'][$group] = array(
- '#attributes' => array('class' => array('simpletest-group')),
- );
+ $form['tests'][$group] = [
+ '#attributes' => ['class' => ['simpletest-group']],
+ ];
// Make the class name safe for output on the page by replacing all
// non-word/decimal characters with a dash (-).
@@ -160,47 +160,47 @@ class SimpletestTestForm extends FormBase {
// Override tableselect column with custom selector for this group.
// This group-select-all checkbox is injected via JavaScript.
- $form['tests'][$group]['select'] = array(
- '#wrapper_attributes' => array(
+ $form['tests'][$group]['select'] = [
+ '#wrapper_attributes' => [
'id' => $group_class,
- 'class' => array('simpletest-group-select-all'),
- ),
- );
- $form['tests'][$group]['title'] = array(
+ 'class' => ['simpletest-group-select-all'],
+ ],
+ ];
+ $form['tests'][$group]['title'] = [
// Expand/collapse image.
'#prefix' => '<div class="simpletest-image" id="simpletest-test-group-' . $group_class . '"></div>',
'#markup' => '<label for="' . $group_class . '-group-select-all">' . $group . '</label>',
- '#wrapper_attributes' => array(
- 'class' => array('simpletest-group-label'),
- ),
- );
- $form['tests'][$group]['description'] = array(
+ '#wrapper_attributes' => [
+ 'class' => ['simpletest-group-label'],
+ ],
+ ];
+ $form['tests'][$group]['description'] = [
'#markup' => '&nbsp;',
- '#wrapper_attributes' => array(
- 'class' => array('simpletest-group-description'),
- ),
- );
+ '#wrapper_attributes' => [
+ 'class' => ['simpletest-group-description'],
+ ],
+ ];
// Cycle through each test within the current group.
foreach ($tests as $class => $info) {
- $form['tests'][$class] = array(
- '#attributes' => array('class' => array($group_class . '-test', 'js-hide')),
- );
- $form['tests'][$class]['title'] = array(
+ $form['tests'][$class] = [
+ '#attributes' => ['class' => [$group_class . '-test', 'js-hide']],
+ ];
+ $form['tests'][$class]['title'] = [
'#type' => 'label',
'#title' => '\\' . $info['name'],
- '#wrapper_attributes' => array(
- 'class' => array('simpletest-test-label', 'table-filter-text-source'),
- ),
- );
- $form['tests'][$class]['description'] = array(
+ '#wrapper_attributes' => [
+ 'class' => ['simpletest-test-label', 'table-filter-text-source'],
+ ],
+ ];
+ $form['tests'][$class]['description'] = [
'#prefix' => '<div class="description">',
'#plain_text' => $info['description'],
'#suffix' => '</div>',
- '#wrapper_attributes' => array(
- 'class' => array('simpletest-test-description', 'table-filter-text-source'),
- ),
- );
+ '#wrapper_attributes' => [
+ 'class' => ['simpletest-test-description', 'table-filter-text-source'],
+ ],
+ ];
}
}
@@ -233,7 +233,7 @@ class SimpletestTestForm extends FormBase {
$test_id = simpletest_run_tests($tests_list, 'drupal');
$form_state->setRedirect(
'simpletest.result_form',
- array('test_id' => $test_id)
+ ['test_id' => $test_id]
);
}
}
diff --git a/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php
index f1f3a11bfd3..92f33dcf5fb 100644
--- a/core/modules/simpletest/src/InstallerTestBase.php
+++ b/core/modules/simpletest/src/InstallerTestBase.php
@@ -23,7 +23,7 @@ abstract class InstallerTestBase extends WebTestBase {
* An array of settings to write out, in the format expected by
* drupal_rewrite_settings().
*/
- protected $settings = array();
+ protected $settings = [];
/**
* The language code in which to install Drupal.
@@ -46,7 +46,7 @@ abstract class InstallerTestBase extends WebTestBase {
*
* @var array
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* A string translation map used for translated installer screens.
@@ -55,9 +55,9 @@ abstract class InstallerTestBase extends WebTestBase {
*
* @var array
*/
- protected $translations = array(
+ protected $translations = [
'Save and continue' => 'Save and continue',
- );
+ ];
/**
* Whether the installer has completed.
@@ -73,12 +73,12 @@ abstract class InstallerTestBase extends WebTestBase {
$this->isInstalled = FALSE;
// Define information about the user 1 account.
- $this->rootUser = new UserSession(array(
+ $this->rootUser = new UserSession([
'uid' => 1,
'name' => 'admin',
'mail' => 'admin@example.com',
'pass_raw' => $this->randomMachineName(),
- ));
+ ]);
// If any $settings are defined for this test, copy and prepare an actual
// settings.php, so as to resemble a regular installation.
@@ -171,9 +171,9 @@ abstract class InstallerTestBase extends WebTestBase {
* Installer step: Select language.
*/
protected function setUpLanguage() {
- $edit = array(
+ $edit = [
'langcode' => $this->langcode,
- );
+ ];
$this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
}
@@ -181,9 +181,9 @@ abstract class InstallerTestBase extends WebTestBase {
* Installer step: Select installation profile.
*/
protected function setUpProfile() {
- $edit = array(
+ $edit = [
'profile' => $this->profile,
- );
+ ];
$this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
}
diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php
index c804218af60..9b7495af29a 100644
--- a/core/modules/simpletest/src/KernelTestBase.php
+++ b/core/modules/simpletest/src/KernelTestBase.php
@@ -61,7 +61,7 @@ abstract class KernelTestBase extends TestBase {
*
* @var array
*/
- public static $modules = array();
+ public static $modules = [];
private $moduleFiles;
private $themeFiles;
@@ -71,7 +71,7 @@ abstract class KernelTestBase extends TestBase {
*
* @var array
*/
- protected $configDirectories = array();
+ protected $configDirectories = [];
/**
* A KeyValueMemoryFactory instance to use when building the container.
@@ -85,7 +85,7 @@ abstract class KernelTestBase extends TestBase {
*
* @var array
*/
- protected $streamWrappers = array();
+ protected $streamWrappers = [];
/**
* {@inheritdoc}
@@ -101,8 +101,8 @@ abstract class KernelTestBase extends TestBase {
protected function beforePrepareEnvironment() {
// Copy/prime extension file lists once to avoid filesystem scans.
if (!isset($this->moduleFiles)) {
- $this->moduleFiles = \Drupal::state()->get('system.module.files') ?: array();
- $this->themeFiles = \Drupal::state()->get('system.theme.files') ?: array();
+ $this->moduleFiles = \Drupal::state()->get('system.module.files') ?: [];
+ $this->themeFiles = \Drupal::state()->get('system.theme.files') ?: [];
}
}
@@ -115,7 +115,7 @@ abstract class KernelTestBase extends TestBase {
* Thrown when CONFIG_SYNC_DIRECTORY cannot be created or made writable.
*/
protected function prepareConfigDirectories() {
- $this->configDirectories = array();
+ $this->configDirectories = [];
include_once DRUPAL_ROOT . '/core/includes/install.inc';
// Assign the relative path to the global variable.
$path = $this->siteDirectory . '/config_' . CONFIG_SYNC_DIRECTORY;
@@ -232,11 +232,11 @@ EOD;
// \Drupal\Core\Config\ConfigInstaller::installDefaultConfig() to work.
// Write directly to active storage to avoid early instantiation of
// the event dispatcher which can prevent modules from registering events.
- \Drupal::service('config.storage')->write('core.extension', array('module' => array(), 'theme' => array(), 'profile' => ''));
+ \Drupal::service('config.storage')->write('core.extension', ['module' => [], 'theme' => [], 'profile' => '']);
// Collect and set a fixed module list.
$class = get_class($this);
- $modules = array();
+ $modules = [];
while ($class) {
if (property_exists($class, 'modules')) {
// Only add the modules, if the $modules property was not inherited.
@@ -262,7 +262,7 @@ EOD;
// @see https://www.drupal.org/node/2028109
file_prepare_directory($this->publicFilesDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
$this->settingsSet('file_public_path', $this->publicFilesDirectory);
- $this->streamWrappers = array();
+ $this->streamWrappers = [];
$this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream');
// The temporary stream wrapper is able to operate both with and without
// configuration.
@@ -328,7 +328,7 @@ EOD;
->addTag('event_subscriber');
}
- $keyvalue_options = $container->getParameter('factory.keyvalue') ?: array();
+ $keyvalue_options = $container->getParameter('factory.keyvalue') ?: [];
$keyvalue_options['default'] = 'keyvalue.memory';
$container->setParameter('factory.keyvalue', $keyvalue_options);
$container->set('keyvalue.memory', $this->keyValueFactory);
@@ -366,14 +366,14 @@ EOD;
}
if ($container->hasDefinition('password')) {
- $container->getDefinition('password')->setArguments(array(1));
+ $container->getDefinition('password')->setArguments([1]);
}
// Register the stream wrapper manager.
$container
->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager')
->addArgument(new Reference('module_handler'))
- ->addMethodCall('setContainer', array(new Reference('service_container')));
+ ->addMethodCall('setContainer', [new Reference('service_container')]);
$request = Request::create('/');
$container->get('request_stack')->push($request);
@@ -405,9 +405,9 @@ EOD;
}
\Drupal::service('config.installer')->installDefaultConfig('module', $module);
}
- $this->pass(format_string('Installed default config: %modules.', array(
+ $this->pass(format_string('Installed default config: %modules.', [
'%modules' => implode(', ', $modules),
- )));
+ ]));
}
/**
@@ -447,10 +447,10 @@ EOD;
}
$this->container->get('database')->schema()->createTable($table, $schema);
}
- $this->pass(format_string('Installed %module tables: %tables.', array(
+ $this->pass(format_string('Installed %module tables: %tables.', [
'%tables' => '{' . implode('}, {', $tables) . '}',
'%module' => $module,
- )));
+ ]));
}
@@ -476,18 +476,18 @@ EOD;
$all_tables_exist = TRUE;
foreach ($tables as $table) {
if (!$db_schema->tableExists($table)) {
- $this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', array(
+ $this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', [
'%entity_type' => $entity_type_id,
'%table' => $table,
- )));
+ ]));
$all_tables_exist = FALSE;
}
}
if ($all_tables_exist) {
- $this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', array(
+ $this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', [
'%entity_type' => $entity_type_id,
'%tables' => '{' . implode('}, {', $tables) . '}',
- )));
+ ]));
}
}
}
@@ -539,9 +539,9 @@ EOD;
// Note that the kernel has rebuilt the container; this $module_handler is
// no longer the $module_handler instance from above.
$this->container->get('module_handler')->reload();
- $this->pass(format_string('Enabled modules: %modules.', array(
+ $this->pass(format_string('Enabled modules: %modules.', [
'%modules' => implode(', ', $modules),
- )));
+ ]));
}
/**
@@ -574,9 +574,9 @@ EOD;
// no longer the $module_handler instance from above.
$module_handler = $this->container->get('module_handler');
$module_handler->reload();
- $this->pass(format_string('Disabled modules: %modules.', array(
+ $this->pass(format_string('Disabled modules: %modules.', [
'%modules' => implode(', ', $modules),
- )));
+ ]));
}
/**
diff --git a/core/modules/simpletest/src/NodeCreationTrait.php b/core/modules/simpletest/src/NodeCreationTrait.php
index 9ed55d8093f..86321a2b99a 100644
--- a/core/modules/simpletest/src/NodeCreationTrait.php
+++ b/core/modules/simpletest/src/NodeCreationTrait.php
@@ -64,17 +64,17 @@ trait NodeCreationTrait {
* @return \Drupal\node\NodeInterface
* The created node entity.
*/
- protected function createNode(array $settings = array()) {
+ protected function createNode(array $settings = []) {
// Populate defaults array.
- $settings += array(
- 'body' => array(array(
+ $settings += [
+ 'body' => [[
'value' => $this->randomMachineName(32),
'format' => filter_default_format(),
- )),
+ ]],
'title' => $this->randomMachineName(8),
'type' => 'page',
'uid' => \Drupal::currentUser()->id(),
- );
+ ];
$node = Node::create($settings);
$node->save();
diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php
index 14d79099bc3..1491cc2af14 100644
--- a/core/modules/simpletest/src/TestBase.php
+++ b/core/modules/simpletest/src/TestBase.php
@@ -50,19 +50,19 @@ abstract class TestBase {
*
* @var Array
*/
- public $results = array(
+ public $results = [
'#pass' => 0,
'#fail' => 0,
'#exception' => 0,
'#debug' => 0,
- );
+ ];
/**
* Assertions thrown in that test case.
*
* @var Array
*/
- protected $assertions = array();
+ protected $assertions = [];
/**
* This class is skipped when looking for the source of an assertion.
@@ -72,7 +72,7 @@ abstract class TestBase {
* that called it. So we need to skip the classes defining these helper
* methods.
*/
- protected $skipClasses = array(__CLASS__ => TRUE);
+ protected $skipClasses = [__CLASS__ => TRUE];
/**
* TRUE if verbose debugging is enabled.
@@ -255,7 +255,7 @@ abstract class TestBase {
* Array of errors containing a list of unmet requirements.
*/
protected function checkRequirements() {
- return array();
+ return [];
}
/**
@@ -319,7 +319,7 @@ abstract class TestBase {
}
// Creation assertion array that can be displayed while tests are running.
- $assertion = array(
+ $assertion = [
'test_id' => $this->testId,
'test_class' => get_class($this),
'status' => $status,
@@ -328,7 +328,7 @@ abstract class TestBase {
'function' => $caller['function'],
'line' => $caller['line'],
'file' => $caller['file'],
- );
+ ];
// Store assertion for display after the test has completed.
$message_id = $this->storeAssertion($assertion);
@@ -364,19 +364,19 @@ abstract class TestBase {
* @see \Drupal\simpletest\TestBase::assert()
* @see \Drupal\simpletest\TestBase::deleteAssert()
*/
- public static function insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = array()) {
+ public static function insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = []) {
// Convert boolean status to string status.
if (is_bool($status)) {
$status = $status ? 'pass' : 'fail';
}
- $caller += array(
+ $caller += [
'function' => 'Unknown',
'line' => 0,
'file' => 'Unknown',
- );
+ ];
- $assertion = array(
+ $assertion = [
'test_id' => $test_id,
'test_class' => $test_class,
'status' => $status,
@@ -385,7 +385,7 @@ abstract class TestBase {
'function' => $caller['function'],
'line' => $caller['line'],
'file' => $caller['file'],
- );
+ ];
// We can't use storeAssertion() because this method is static.
return self::getDatabaseConnection()
@@ -457,7 +457,7 @@ abstract class TestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertTrue($value, $message = '', $group = 'Other') {
- return $this->assert((bool) $value, $message ? $message : SafeMarkup::format('Value @value is TRUE.', array('@value' => var_export($value, TRUE))), $group);
+ return $this->assert((bool) $value, $message ? $message : SafeMarkup::format('Value @value is TRUE.', ['@value' => var_export($value, TRUE)]), $group);
}
/**
@@ -482,7 +482,7 @@ abstract class TestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertFalse($value, $message = '', $group = 'Other') {
- return $this->assert(!$value, $message ? $message : SafeMarkup::format('Value @value is FALSE.', array('@value' => var_export($value, TRUE))), $group);
+ return $this->assert(!$value, $message ? $message : SafeMarkup::format('Value @value is FALSE.', ['@value' => var_export($value, TRUE)]), $group);
}
/**
@@ -505,7 +505,7 @@ abstract class TestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertNull($value, $message = '', $group = 'Other') {
- return $this->assert(!isset($value), $message ? $message : SafeMarkup::format('Value @value is NULL.', array('@value' => var_export($value, TRUE))), $group);
+ return $this->assert(!isset($value), $message ? $message : SafeMarkup::format('Value @value is NULL.', ['@value' => var_export($value, TRUE)]), $group);
}
/**
@@ -528,7 +528,7 @@ abstract class TestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertNotNull($value, $message = '', $group = 'Other') {
- return $this->assert(isset($value), $message ? $message : SafeMarkup::format('Value @value is not NULL.', array('@value' => var_export($value, TRUE))), $group);
+ return $this->assert(isset($value), $message ? $message : SafeMarkup::format('Value @value is not NULL.', ['@value' => var_export($value, TRUE)]), $group);
}
/**
@@ -560,7 +560,7 @@ abstract class TestBase {
$second = $this->castSafeStrings($second);
$is_equal = $first == $second;
if (!$is_equal || !$message) {
- $default_message = SafeMarkup::format('Value @first is equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)));
+ $default_message = SafeMarkup::format('Value @first is equal to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
}
return $this->assert($is_equal, $message, $group);
@@ -595,7 +595,7 @@ abstract class TestBase {
$second = $this->castSafeStrings($second);
$not_equal = $first != $second;
if (!$not_equal || !$message) {
- $default_message = SafeMarkup::format('Value @first is not equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)));
+ $default_message = SafeMarkup::format('Value @first is not equal to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
}
return $this->assert($not_equal, $message, $group);
@@ -625,7 +625,7 @@ abstract class TestBase {
protected function assertIdentical($first, $second, $message = '', $group = 'Other') {
$is_identical = $first === $second;
if (!$is_identical || !$message) {
- $default_message = SafeMarkup::format('Value @first is identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)));
+ $default_message = SafeMarkup::format('Value @first is identical to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
}
return $this->assert($is_identical, $message, $group);
@@ -655,7 +655,7 @@ abstract class TestBase {
protected function assertNotIdentical($first, $second, $message = '', $group = 'Other') {
$not_identical = $first !== $second;
if (!$not_identical || !$message) {
- $default_message = SafeMarkup::format('Value @first is not identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)));
+ $default_message = SafeMarkup::format('Value @first is not identical to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
}
return $this->assert($not_identical, $message, $group);
@@ -683,10 +683,10 @@ abstract class TestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertIdenticalObject($object1, $object2, $message = '', $group = 'Other') {
- $message = $message ?: SafeMarkup::format('@object1 is identical to @object2', array(
+ $message = $message ?: SafeMarkup::format('@object1 is identical to @object2', [
'@object1' => var_export($object1, TRUE),
'@object2' => var_export($object2, TRUE),
- ));
+ ]);
$identical = TRUE;
foreach ($object1 as $key => $value) {
$identical = $identical && isset($object2->$key) && $object2->$key === $value;
@@ -858,14 +858,14 @@ abstract class TestBase {
* taken into account, but it can be useful to only run a few selected test
* methods during debugging.
*/
- public function run(array $methods = array()) {
+ public function run(array $methods = []) {
$class = get_class($this);
if ($missing_requirements = $this->checkRequirements()) {
$object_info = new \ReflectionObject($this);
- $caller = array(
+ $caller = [
'file' => $object_info->getFileName(),
- );
+ ];
foreach ($missing_requirements as $missing_requirement) {
TestBase::insertAssert($this->testId, $class, FALSE, $missing_requirement, 'Requirements check', $caller);
}
@@ -903,7 +903,7 @@ abstract class TestBase {
// compatibility.
Handle::register();
- set_error_handler(array($this, 'errorHandler'));
+ set_error_handler([$this, 'errorHandler']);
// Iterate through all the methods in this class, unless a specific list of
// methods to run was passed.
$test_methods = array_filter(get_class_methods($class), function ($method) {
@@ -912,7 +912,7 @@ abstract class TestBase {
if (empty($test_methods)) {
// Call $this->assert() here because we need to pass along custom caller
// information, lest the wrong originating code file/line be identified.
- $this->assert(FALSE, 'No test methods found.', 'Requirements', array('function' => __METHOD__ . '()', 'file' => __FILE__, 'line' => __LINE__));
+ $this->assert(FALSE, 'No test methods found.', 'Requirements', ['function' => __METHOD__ . '()', 'file' => __FILE__, 'line' => __LINE__]);
}
if ($methods) {
$test_methods = array_intersect($test_methods, $methods);
@@ -921,11 +921,11 @@ abstract class TestBase {
// Insert a fail record. This will be deleted on completion to ensure
// that testing completed.
$method_info = new \ReflectionMethod($class, $method);
- $caller = array(
+ $caller = [
'file' => $method_info->getFileName(),
'line' => $method_info->getStartLine(),
'function' => $class . '->' . $method . '()',
- );
+ ];
$test_completion_check_id = TestBase::insertAssert($this->testId, $class, FALSE, 'The test did not complete due to a fatal error.', 'Completion check', $caller);
try {
@@ -1014,7 +1014,7 @@ abstract class TestBase {
// All assertions as well as the SimpleTest batch operations are associated
// with the testId, so the database prefix has to be associated with it.
$affected_rows = self::getDatabaseConnection()->update('simpletest_test_id')
- ->fields(array('last_prefix' => $this->databasePrefix))
+ ->fields(['last_prefix' => $this->databasePrefix])
->condition('test_id', $this->testId)
->execute();
if (!$affected_rows) {
@@ -1103,7 +1103,7 @@ abstract class TestBase {
// handlers defined by the original one.
$callbacks = &drupal_register_shutdown_function();
$this->originalShutdownCallbacks = $callbacks;
- $callbacks = array();
+ $callbacks = [];
// Create test directory ahead of installation so fatal errors and debug
// information can be logged during installation process.
@@ -1153,11 +1153,11 @@ abstract class TestBase {
drupal_valid_test_ua($this->databasePrefix);
// Reset settings.
- new Settings(array(
+ new Settings([
// For performance, simply use the database prefix as hash salt.
'hash_salt' => $this->databasePrefix,
'container_yamls' => [],
- ));
+ ]);
drupal_set_time_limit($this->timeLimit);
}
@@ -1181,7 +1181,7 @@ abstract class TestBase {
*/
private function restoreEnvironment() {
// Destroy the session if one was started during the test-run.
- $_SESSION = array();
+ $_SESSION = [];
if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_ACTIVE) {
session_destroy();
$params = session_get_cookie_params();
@@ -1197,7 +1197,7 @@ abstract class TestBase {
drupal_static_reset();
if ($this->container && $this->container->has('state') && $state = $this->container->get('state')) {
- $captured_emails = $state->get('system.test_mail_collector') ?: array();
+ $captured_emails = $state->get('system.test_mail_collector') ?: [];
$emailCount = count($captured_emails);
if ($emailCount) {
$message = $emailCount == 1 ? '1 email was sent during this test.' : $emailCount . ' emails were sent during this test.';
@@ -1232,7 +1232,7 @@ abstract class TestBase {
\Drupal::setContainer($this->originalContainer);
// Delete test site directory.
- file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback'));
+ file_unmanaged_delete_recursive($this->siteDirectory, [$this, 'filePreDeleteCallback']);
// Restore original database connection.
Database::removeConnection('default');
@@ -1278,7 +1278,7 @@ abstract class TestBase {
*/
public function errorHandler($severity, $message, $file = NULL, $line = NULL) {
if ($severity & error_reporting()) {
- $error_map = array(
+ $error_map = [
E_STRICT => 'Run-time notice',
E_WARNING => 'Warning',
E_NOTICE => 'Notice',
@@ -1290,7 +1290,7 @@ abstract class TestBase {
E_RECOVERABLE_ERROR => 'Recoverable error',
E_DEPRECATED => 'Deprecated',
E_USER_DEPRECATED => 'User deprecated',
- );
+ ];
$backtrace = debug_backtrace();
@@ -1315,15 +1315,15 @@ abstract class TestBase {
$backtrace = $exception->getTrace();
$verbose_backtrace = $backtrace;
// Push on top of the backtrace the call that generated the exception.
- array_unshift($backtrace, array(
+ array_unshift($backtrace, [
'line' => $exception->getLine(),
'file' => $exception->getFile(),
- ));
+ ]);
$decoded_exception = Error::decodeException($exception);
unset($decoded_exception['backtrace']);
- $message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decoded_exception + array(
+ $message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decoded_exception + [
'@backtrace' => Error::formatBacktrace($verbose_backtrace),
- ));
+ ]);
$this->error($message, 'Uncaught exception', Error::getLastCaller($backtrace));
}
@@ -1375,15 +1375,15 @@ abstract class TestBase {
* single value only.
*/
public static function generatePermutations($parameters) {
- $all_permutations = array(array());
+ $all_permutations = [[]];
foreach ($parameters as $parameter => $values) {
- $new_permutations = array();
+ $new_permutations = [];
// Iterate over all values of the parameter.
foreach ($values as $value) {
// Iterate over all existing permutations.
foreach ($all_permutations as $permutation) {
// Add the new parameter value to existing permutations.
- $new_permutations[] = $permutation + array($parameter => $value);
+ $new_permutations[] = $permutation + [$parameter => $value];
}
}
// Replace the old permutations with the new permutations.
diff --git a/core/modules/simpletest/src/TestDiscovery.php b/core/modules/simpletest/src/TestDiscovery.php
index 02bf7071fbc..d5d7d8a5769 100644
--- a/core/modules/simpletest/src/TestDiscovery.php
+++ b/core/modules/simpletest/src/TestDiscovery.php
@@ -91,7 +91,7 @@ class TestDiscovery {
if (isset($this->testNamespaces)) {
return $this->testNamespaces;
}
- $this->testNamespaces = array();
+ $this->testNamespaces = [];
$existing = $this->classLoader->getPrefixesPsr4();
@@ -101,7 +101,7 @@ class TestDiscovery {
$this->testNamespaces['Drupal\\FunctionalTests\\'] = [$this->root . '/core/tests/Drupal/FunctionalTests'];
$this->testNamespaces['Drupal\\FunctionalJavascriptTests\\'] = [$this->root . '/core/tests/Drupal/FunctionalJavascriptTests'];
- $this->availableExtensions = array();
+ $this->availableExtensions = [];
foreach ($this->getExtensions() as $name => $extension) {
$this->availableExtensions[$extension->getType()][$name] = $name;
@@ -164,7 +164,7 @@ class TestDiscovery {
return $cache->data;
}
}
- $list = array();
+ $list = [];
$classmap = $this->findAllClassFiles($extension);
@@ -238,7 +238,7 @@ class TestDiscovery {
* fully-qualified classnames to pathnames.
*/
public function findAllClassFiles($extension = NULL) {
- $classmap = array();
+ $classmap = [];
$namespaces = $this->registerTestNamespaces();
if (isset($extension)) {
// Include tests in the \Drupal\Tests\{$extension} namespace.
@@ -294,7 +294,7 @@ class TestDiscovery {
return $current->isFile() && $current->getExtension() === 'php';
});
$files = new \RecursiveIteratorIterator($filter);
- $classes = array();
+ $classes = [];
foreach ($files as $fileinfo) {
$class = $namespace_prefix;
if ('' !== $subpath = $fileinfo->getSubPath()) {
@@ -332,10 +332,10 @@ class TestDiscovery {
$reflection = new \ReflectionClass($classname);
$doc_comment = $reflection->getDocComment();
}
- $info = array(
+ $info = [
'name' => $classname,
- );
- $annotations = array();
+ ];
+ $annotations = [];
// Look for annotations, allow an arbitrary amount of spaces before the
// * but nothing else.
preg_match_all('/^[ ]*\* \@([^\s]*) (.*$)/m', $doc_comment, $matches);
@@ -479,7 +479,7 @@ class TestDiscovery {
protected function getExtensions() {
$listing = new ExtensionDiscovery($this->root);
// Ensure that tests in all profiles are discovered.
- $listing->setProfileDirectories(array());
+ $listing->setProfileDirectories([]);
$extensions = $listing->scan('module', TRUE);
$extensions += $listing->scan('profile', TRUE);
$extensions += $listing->scan('theme', TRUE);
diff --git a/core/modules/simpletest/src/Tests/BrokenSetUpTest.php b/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
index e988f4d3da4..673d5b9a8a0 100644
--- a/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
+++ b/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
@@ -22,7 +22,7 @@ class BrokenSetUpTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('simpletest');
+ public static $modules = ['simpletest'];
/**
* The path to the shared trigger file.
@@ -39,7 +39,7 @@ class BrokenSetUpTest extends WebTestBase {
$this->sharedTriggerFile = $this->publicFilesDirectory . '/trigger';
// Create and log in user.
- $admin_user = $this->drupalCreateUser(array('administer unit tests'));
+ $admin_user = $this->drupalCreateUser(['administer unit tests']);
$this->drupalLogin($admin_user);
}
// If the test is being run from within simpletest, set up the broken test.
diff --git a/core/modules/simpletest/src/Tests/BrowserTest.php b/core/modules/simpletest/src/Tests/BrowserTest.php
index f98fe48c29b..be9e006978e 100644
--- a/core/modules/simpletest/src/Tests/BrowserTest.php
+++ b/core/modules/simpletest/src/Tests/BrowserTest.php
@@ -41,16 +41,16 @@ class BrowserTest extends WebTestBase {
$url = 'user/login';
$this->drupalGet($url);
- $absolute = \Drupal::url('user.login', array(), array('absolute' => TRUE));
+ $absolute = \Drupal::url('user.login', [], ['absolute' => TRUE]);
$this->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
- $this->drupalPostForm(NULL, array(), t('Log in'));
+ $this->drupalPostForm(NULL, [], t('Log in'));
$this->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
$this->clickLink('Create new account');
- $absolute = \Drupal::url('user.register', array(), array('absolute' => TRUE));
+ $absolute = \Drupal::url('user.register', [], ['absolute' => TRUE]);
$this->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this->assertEqual($this->url, $this->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
}
@@ -72,16 +72,16 @@ EOF;
$this->setRawContent($testpage);
// Matches the first link.
- $urls = $this->xpath('//a[text()=:text]', array(':text' => 'A "weird" link, just to bother the dumb "XPath 1.0"'));
+ $urls = $this->xpath('//a[text()=:text]', [':text' => 'A "weird" link, just to bother the dumb "XPath 1.0"']);
$this->assertEqual($urls[0]['href'], 'link1', 'Match with quotes.');
- $urls = $this->xpath('//a[text()=:text]', array(':text' => 'A second "even more weird" link, in memory of George O\'Malley'));
+ $urls = $this->xpath('//a[text()=:text]', [':text' => 'A second "even more weird" link, in memory of George O\'Malley']);
$this->assertEqual($urls[0]['href'], 'link2', 'Match with mixed single and double quotes.');
- $urls = $this->xpath('//a[text()=:text]', array(':text' => 'A $third$ link, so weird it\'s worth $1 million'));
+ $urls = $this->xpath('//a[text()=:text]', [':text' => 'A $third$ link, so weird it\'s worth $1 million']);
$this->assertEqual($urls[0]['href'], 'link3', 'Match with a regular expression back reference symbol (dollar sign).');
- $urls = $this->xpath('//a[text()=:text]', array(':text' => 'A fourth link, containing alternative \\1 regex backreferences \\2'));
+ $urls = $this->xpath('//a[text()=:text]', [':text' => 'A fourth link, containing alternative \\1 regex backreferences \\2']);
$this->assertEqual($urls[0]['href'], 'link4', 'Match with another regular expression back reference symbol (double backslash).');
}
diff --git a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
index a1063e7b2f4..a4365f810e6 100644
--- a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
+++ b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
@@ -16,7 +16,7 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('simpletest');
+ public static $modules = ['simpletest'];
/**
* An administrative user with permission to adminsiter unit tests.
@@ -42,7 +42,7 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
+ $this->adminUser = $this->drupalCreateUser(['administer unit tests']);
$this->drupalLogin($this->adminUser);
}
@@ -52,9 +52,9 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
function testInstallationProfileTests() {
$this->drupalGet('admin/config/development/testing');
$this->assertText('Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest');
- $edit = array(
+ $edit = [
'tests[Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest]' => TRUE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Run tests'));
$this->assertText('SystemListingCompatibleTest test executed.');
}
diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
index 472fdf9e45b..2ed63b3af40 100644
--- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
+++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
@@ -20,7 +20,7 @@ class KernelTestBaseTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('entity_test');
+ public static $modules = ['entity_test'];
/**
* {@inheritdoc}
@@ -51,7 +51,7 @@ EOS;
* Tests expected behavior of setUp().
*/
function testSetUp() {
- $modules = array('entity_test');
+ $modules = ['entity_test'];
$table = 'entity_test';
// Verify that specified $modules have been loaded.
@@ -90,7 +90,7 @@ EOS;
$this->assertFalse(in_array($module, $list), "{$module}_entity_display_build_alter() in \Drupal::moduleHandler()->getImplementations() not found.");
// Enable the module.
- $this->enableModules(array($module));
+ $this->enableModules([$module]);
// Verify that the module exists.
$this->assertTrue(\Drupal::moduleHandler()->moduleExists($module), "$module module found.");
@@ -117,7 +117,7 @@ EOS;
$this->assertFalse(db_table_exists($table), "'$table' database table not found.");
// Install the module.
- \Drupal::service('module_installer')->install(array($module));
+ \Drupal::service('module_installer')->install([$module]);
// Verify that the enabled module exists.
$this->assertTrue(\Drupal::moduleHandler()->moduleExists($module), "$module module found.");
@@ -136,9 +136,9 @@ EOS;
*/
function testEnableModulesInstallContainer() {
// Install Node module.
- $this->enableModules(array('user', 'field', 'node'));
+ $this->enableModules(['user', 'field', 'node']);
- $this->installEntitySchema('node', array('node', 'node_field_data'));
+ $this->installEntitySchema('node', ['node', 'node_field_data']);
// Perform an entity query against node.
$query = \Drupal::entityQuery('node');
// Disable node access checks, since User module is not enabled.
@@ -190,7 +190,7 @@ EOS;
$this->assertTrue($schema, "'$table' table schema found.");
// Verify that the same table can be installed after enabling the module.
- $this->enableModules(array($module));
+ $this->enableModules([$module]);
$this->installSchema($module, $table);
$this->assertTrue(db_table_exists($table), "'$table' database table found.");
$schema = drupal_get_module_schema($module, $table);
@@ -203,7 +203,7 @@ EOS;
function testInstallEntitySchema() {
$entity = 'entity_test';
// The entity_test Entity has a field that depends on the User module.
- $this->enableModules(array('user'));
+ $this->enableModules(['user']);
// Verity that the entity schema is created properly.
$this->installEntitySchema($entity);
$this->assertTrue(db_table_exists($entity), "'$entity' database table found.");
@@ -214,12 +214,12 @@ EOS;
*/
function testInstallConfig() {
// The user module has configuration that depends on system.
- $this->enableModules(array('system'));
+ $this->enableModules(['system']);
$module = 'user';
// Verify that default config can only be installed for enabled modules.
try {
- $this->installConfig(array($module));
+ $this->installConfig([$module]);
$this->fail('Exception for non-enabled module found.');
}
catch (\Exception $e) {
@@ -228,8 +228,8 @@ EOS;
$this->assertFalse($this->container->get('config.storage')->exists('user.settings'));
// Verify that default config can be installed.
- $this->enableModules(array('user'));
- $this->installConfig(array('user'));
+ $this->enableModules(['user']);
+ $this->installConfig(['user']);
$this->assertTrue($this->container->get('config.storage')->exists('user.settings'));
$this->assertTrue($this->config('user.settings')->get('register'));
}
@@ -239,7 +239,7 @@ EOS;
*/
function testEnableModulesFixedList() {
// Install system module.
- $this->container->get('module_installer')->install(array('system', 'menu_link_content'));
+ $this->container->get('module_installer')->install(['system', 'menu_link_content']);
$entity_manager = \Drupal::entityManager();
// entity_test is loaded via $modules; its entity type should exist.
@@ -247,17 +247,17 @@ EOS;
$this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
// Load some additional modules; entity_test should still exist.
- $this->enableModules(array('field', 'text', 'entity_test'));
+ $this->enableModules(['field', 'text', 'entity_test']);
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
// Install some other modules; entity_test should still exist.
- $this->container->get('module_installer')->install(array('user', 'field', 'field_test'), FALSE);
+ $this->container->get('module_installer')->install(['user', 'field', 'field_test'], FALSE);
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
// Uninstall one of those modules; entity_test should still exist.
- $this->container->get('module_installer')->uninstall(array('field_test'));
+ $this->container->get('module_installer')->uninstall(['field_test']);
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
@@ -267,19 +267,19 @@ EOS;
$this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
// Reactivate the previously uninstalled module.
- $this->enableModules(array('field_test'));
+ $this->enableModules(['field_test']);
// Create a field.
- $display = EntityViewDisplay::create(array(
+ $display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
- ));
- $field_storage = FieldStorageConfig::create(array(
+ ]);
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'type' => 'test_field'
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -293,18 +293,18 @@ EOS;
function testEnableModulesTheme() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
- $original_element = $element = array(
+ $original_element = $element = [
'#type' => 'container',
'#markup' => 'Foo',
- '#attributes' => array(),
- );
- $this->enableModules(array('system'));
+ '#attributes' => [],
+ ];
+ $this->enableModules(['system']);
// \Drupal\Core\Theme\ThemeManager::render() throws an exception if modules
// are not loaded yet.
$this->assertTrue($renderer->renderRoot($element));
$element = $original_element;
- $this->disableModules(array('entity_test'));
+ $this->disableModules(['entity_test']);
$this->assertTrue($renderer->renderRoot($element));
}
@@ -313,10 +313,10 @@ EOS;
*/
function testNoThemeByDefault() {
$themes = $this->config('core.extension')->get('theme');
- $this->assertEqual($themes, array());
+ $this->assertEqual($themes, []);
$extensions = $this->container->get('config.storage')->read('core.extension');
- $this->assertEqual($extensions['theme'], array());
+ $this->assertEqual($extensions['theme'], []);
$active_theme = $this->container->get('theme.manager')->getActiveTheme();
$this->assertEqual($active_theme->getName(), 'core');
@@ -335,7 +335,7 @@ EOS;
/**
* {@inheritdoc}
*/
- public function run(array $methods = array()) {
+ public function run(array $methods = []) {
parent::run($methods);
// Check that all tables of the test instance have been deleted. At this
@@ -357,11 +357,11 @@ EOS;
':prefix' => $this->databasePrefix
]);
- $result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", array(
+ $result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [
':type' => 'table',
':table_name' => '%',
':pattern' => 'sqlite_%',
- ))->fetchAllKeyed(0, 0);
+ ])->fetchAllKeyed(0, 0);
$this->assertTrue(empty($result), 'All test tables have been removed.');
}
diff --git a/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php b/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php
index 0b21d546dba..d62cc48a3ea 100644
--- a/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php
+++ b/core/modules/simpletest/src/Tests/MissingCheckedRequirementsTest.php
@@ -16,11 +16,11 @@ class MissingCheckedRequirementsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('simpletest');
+ public static $modules = ['simpletest'];
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer unit tests'));
+ $admin_user = $this->drupalCreateUser(['administer unit tests']);
$this->drupalLogin($admin_user);
}
@@ -29,9 +29,9 @@ class MissingCheckedRequirementsTest extends WebTestBase {
*/
protected function checkRequirements() {
if ($this->isInChildSite()) {
- return array(
+ return [
'Test is not allowed to run.'
- );
+ ];
}
return parent::checkRequirements();
}
diff --git a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
index 3b2061ec4b3..7e4f9125b2b 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
@@ -18,12 +18,12 @@ class SimpleTestBrowserTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('simpletest', 'test_page_test');
+ public static $modules = ['simpletest', 'test_page_test'];
protected function setUp() {
parent::setUp();
// Create and log in an admin user.
- $this->drupalLogin($this->drupalCreateUser(array('administer unit tests')));
+ $this->drupalLogin($this->drupalCreateUser(['administer unit tests']));
}
/**
@@ -33,9 +33,9 @@ class SimpleTestBrowserTest extends WebTestBase {
// Retrieve the test page and check its title and headers.
$this->drupalGet('test-page');
$this->assertTrue($this->drupalGetHeader('Date'), 'An HTTP header was received.');
- $this->assertTitle(t('Test page | @site-name', array(
+ $this->assertTitle(t('Test page | @site-name', [
'@site-name' => $this->config('system.site')->get('name'),
- )));
+ ]));
$this->assertNoTitle('Foo');
$old_user_id = $this->container->get('current_user')->id();
@@ -57,13 +57,13 @@ class SimpleTestBrowserTest extends WebTestBase {
// Test the maximum redirection option.
$this->maximumRedirects = 1;
- $edit = array(
+ $edit = [
'name' => $user->getUsername(),
'pass' => $user->pass_raw
- );
- $this->drupalPostForm('user/login', $edit, t('Log in'), array(
- 'query' => array('destination' => 'user/logout'),
- ));
+ ];
+ $this->drupalPostForm('user/login', $edit, t('Log in'), [
+ 'query' => ['destination' => 'user/logout'],
+ ]);
$headers = $this->drupalGetHeaders(TRUE);
$this->assertEqual(count($headers), 2, 'Simpletest stopped following redirects after the first one.');
@@ -73,7 +73,7 @@ class SimpleTestBrowserTest extends WebTestBase {
// @see drupal_valid_test_ua()
// Not using File API; a potential error must trigger a PHP warning.
unlink($this->siteDirectory . '/.htkey');
- $this->drupalGet(Url::fromUri('base:core/install.php', array('external' => TRUE, 'absolute' => TRUE))->toString());
+ $this->drupalGet(Url::fromUri('base:core/install.php', ['external' => TRUE, 'absolute' => TRUE])->toString());
$this->assertResponse(403, 'Cannot access install.php.');
}
@@ -92,7 +92,7 @@ class SimpleTestBrowserTest extends WebTestBase {
// Generate a valid simpletest User-Agent to pass validation.
$this->assertTrue(preg_match('/test\d+/', $this->databasePrefix, $matches), 'Database prefix contains test prefix.');
$test_ua = drupal_generate_test_ua($matches[0]);
- $this->additionalCurlOptions = array(CURLOPT_USERAGENT => $test_ua);
+ $this->additionalCurlOptions = [CURLOPT_USERAGENT => $test_ua];
// Test pages only available for testing.
$this->drupalGet($HTTP_path);
@@ -101,7 +101,7 @@ class SimpleTestBrowserTest extends WebTestBase {
$this->assertResponse(200, 'Requesting https.php with a legitimate simpletest User-Agent returns OK.');
// Now slightly modify the HMAC on the header, which should not validate.
- $this->additionalCurlOptions = array(CURLOPT_USERAGENT => $test_ua . 'X');
+ $this->additionalCurlOptions = [CURLOPT_USERAGENT => $test_ua . 'X'];
$this->drupalGet($HTTP_path);
$this->assertResponse(403, 'Requesting http.php with a bad simpletest User-Agent fails.');
$this->drupalGet($https_path);
@@ -109,7 +109,7 @@ class SimpleTestBrowserTest extends WebTestBase {
// Use a real User-Agent and verify that the special files http.php and
// https.php can't be accessed.
- $this->additionalCurlOptions = array(CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12');
+ $this->additionalCurlOptions = [CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'];
$this->drupalGet($HTTP_path);
$this->assertResponse(403, 'Requesting http.php with a normal User-Agent fails.');
$this->drupalGet($https_path);
@@ -126,20 +126,20 @@ class SimpleTestBrowserTest extends WebTestBase {
// to be created. However this scenario is covered by the testception of
// \Drupal\simpletest\Tests\SimpleTestTest.
- $tests = array(
+ $tests = [
// A KernelTestBase test.
'Drupal\KernelTests\KernelTestBaseTest',
// A PHPUnit unit test.
'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest',
// A PHPUnit functional test.
ThroughUITest::class,
- );
+ ];
foreach ($tests as $test) {
$this->drupalGet('admin/config/development/testing');
- $edit = array(
+ $edit = [
"tests[$test]" => TRUE,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Run tests'));
$this->assertText('0 fails, 0 exceptions');
}
diff --git a/core/modules/simpletest/src/Tests/SimpleTestInstallBatchTest.php b/core/modules/simpletest/src/Tests/SimpleTestInstallBatchTest.php
index 72cb74c6151..5663ad9cdc7 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestInstallBatchTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestInstallBatchTest.php
@@ -20,7 +20,7 @@ class SimpleTestInstallBatchTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('simpletest', 'simpletest_test', 'entity_test');
+ public static $modules = ['simpletest', 'simpletest_test', 'entity_test'];
/**
* Tests loading entities created in a batch in simpletest_test_install().
diff --git a/core/modules/simpletest/src/Tests/SimpleTestTest.php b/core/modules/simpletest/src/Tests/SimpleTestTest.php
index ff20f5e9680..d1f2a20cfda 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestTest.php
@@ -34,7 +34,7 @@ class SimpleTestTest extends WebTestBase {
*
* Used to ensure they are incrementing.
*/
- protected $testIds = array();
+ protected $testIds = [];
/**
* Translated fail message.
@@ -97,12 +97,12 @@ EOD;
parent::setUp();
$this->assertNotIdentical(\Drupal::getContainer(), $original_container, 'WebTestBase test creates a new container.');
// Create and log in an admin user.
- $this->drupalLogin($this->drupalCreateUser(array('administer unit tests')));
+ $this->drupalLogin($this->drupalCreateUser(['administer unit tests']));
}
else {
// This causes three of the five fails that are asserted in
// confirmStubResults().
- self::$modules = array('non_existent_module');
+ self::$modules = ['non_existent_module'];
parent::setUp();
}
}
@@ -127,7 +127,7 @@ EOD;
// Run this test from web interface.
$this->drupalGet('admin/config/development/testing');
- $edit = array();
+ $edit = [];
$edit['tests[Drupal\simpletest\Tests\SimpleTestTest]'] = TRUE;
$this->drupalPostForm(NULL, $edit, t('Run tests'));
@@ -192,10 +192,10 @@ EOD;
// This causes the third to fifth of the sixteen passes asserted in
// confirmStubResults().
- $user = $this->drupalCreateUser(array($this->validPermission), 'SimpleTestTest');
+ $user = $this->drupalCreateUser([$this->validPermission], 'SimpleTestTest');
// This causes the fifth of the five fails asserted in confirmStubResults().
- $this->drupalCreateUser(array($this->invalidPermission));
+ $this->drupalCreateUser([$this->invalidPermission]);
// Test logging in as a user.
// This causes the sixth to tenth of the sixteen passes asserted in
@@ -204,7 +204,7 @@ EOD;
// This causes the eleventh of the sixteen passes asserted in
// confirmStubResults().
- $this->pass(t('Test ID is @id.', array('@id' => $this->testId)));
+ $this->pass(t('Test ID is @id.', ['@id' => $this->testId]));
// These cause the twelfth to fifteenth of the sixteen passes asserted in
// confirmStubResults().
@@ -240,13 +240,13 @@ EOD;
* Confirm that the stub test produced the desired results.
*/
function confirmStubTestResults() {
- $this->assertAssertion(t('Unable to install modules %modules due to missing modules %missing.', array('%modules' => 'non_existent_module', '%missing' => 'non_existent_module')), 'Other', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->setUp()');
+ $this->assertAssertion(t('Unable to install modules %modules due to missing modules %missing.', ['%modules' => 'non_existent_module', '%missing' => 'non_existent_module']), 'Other', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->setUp()');
$this->assertAssertion($this->passMessage, 'Other', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
$this->assertAssertion($this->failMessage, 'Other', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
- $this->assertAssertion(t('Created permissions: @perms', array('@perms' => $this->validPermission)), 'Role', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
- $this->assertAssertion(t('Invalid permission %permission.', array('%permission' => $this->invalidPermission)), 'Role', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
+ $this->assertAssertion(t('Created permissions: @perms', ['@perms' => $this->validPermission]), 'Role', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
+ $this->assertAssertion(t('Invalid permission %permission.', ['%permission' => $this->invalidPermission]), 'Role', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
// Check that the user was logged in successfully.
$this->assertAssertion('User SimpleTestTest successfully logged in.', 'User login', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
@@ -312,24 +312,24 @@ EOD;
break;
}
}
- return $this->assertTrue($found, format_string('Found assertion {"@message", "@type", "@status", "@file", "@function"}.', array('@message' => $message, '@type' => $type, '@status' => $status, "@file" => $file, "@function" => $function)));
+ return $this->assertTrue($found, format_string('Found assertion {"@message", "@type", "@status", "@file", "@function"}.', ['@message' => $message, '@type' => $type, '@status' => $status, "@file" => $file, "@function" => $function]));
}
/**
* Get the results from a test and store them in the class array $results.
*/
function getTestResults() {
- $results = array();
+ $results = [];
if ($this->parse()) {
if ($details = $this->getResultFieldSet()) {
// Code assumes this is the only test in group.
$results['summary'] = $this->asText($details->div->div[1]);
$results['name'] = $this->asText($details->summary);
- $results['assertions'] = array();
+ $results['assertions'] = [];
$tbody = $details->div->table->tbody;
foreach ($tbody->tr as $row) {
- $assertion = array();
+ $assertion = [];
$assertion['message'] = $this->asText($row->td[0]);
$assertion['type'] = $this->asText($row->td[1]);
$assertion['file'] = $this->asText($row->td[2]);
diff --git a/core/modules/simpletest/src/UserCreationTrait.php b/core/modules/simpletest/src/UserCreationTrait.php
index f6665b4c022..4b4d0ec9566 100644
--- a/core/modules/simpletest/src/UserCreationTrait.php
+++ b/core/modules/simpletest/src/UserCreationTrait.php
@@ -43,7 +43,7 @@ trait UserCreationTrait {
* A fully loaded user object with pass_raw property, or FALSE if account
* creation fails.
*/
- protected function createUser(array $permissions = array(), $name = NULL, $admin = FALSE) {
+ protected function createUser(array $permissions = [], $name = NULL, $admin = FALSE) {
// Create a role with the given permission set, if any.
$rid = FALSE;
if ($permissions) {
@@ -54,13 +54,13 @@ trait UserCreationTrait {
}
// Create a user assigned to that role.
- $edit = array();
+ $edit = [];
$edit['name'] = !empty($name) ? $name : $this->randomMachineName();
$edit['mail'] = $edit['name'] . '@example.com';
$edit['pass'] = user_password();
$edit['status'] = 1;
if ($rid) {
- $edit['roles'] = array($rid);
+ $edit['roles'] = [$rid];
}
if ($admin) {
@@ -70,7 +70,7 @@ trait UserCreationTrait {
$account = User::create($edit);
$account->save();
- $this->assertTrue($account->id(), SafeMarkup::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), 'User login');
+ $this->assertTrue($account->id(), SafeMarkup::format('User created with name %name and pass %pass', ['%name' => $edit['name'], '%pass' => $edit['pass']]), 'User login');
if (!$account->id()) {
return FALSE;
}
@@ -141,19 +141,19 @@ trait UserCreationTrait {
}
// Create new role.
- $role = Role::create(array(
+ $role = Role::create([
'id' => $rid,
'label' => $name,
- ));
+ ]);
if (isset($weight)) {
$role->set('weight', $weight);
}
$result = $role->save();
- $this->assertIdentical($result, SAVED_NEW, SafeMarkup::format('Created role ID @rid with name @name.', array(
+ $this->assertIdentical($result, SAVED_NEW, SafeMarkup::format('Created role ID @rid with name @name.', [
'@name' => var_export($role->label(), TRUE),
'@rid' => var_export($role->id(), TRUE),
- )), 'Role');
+ ]), 'Role');
if ($result === SAVED_NEW) {
// Grant the specified permissions to the role, if any.
@@ -162,10 +162,10 @@ trait UserCreationTrait {
$assigned_permissions = Role::load($role->id())->getPermissions();
$missing_permissions = array_diff($permissions, $assigned_permissions);
if (!$missing_permissions) {
- $this->pass(SafeMarkup::format('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
+ $this->pass(SafeMarkup::format('Created permissions: @perms', ['@perms' => implode(', ', $permissions)]), 'Role');
}
else {
- $this->fail(SafeMarkup::format('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions))), 'Role');
+ $this->fail(SafeMarkup::format('Failed to create permissions: @perms', ['@perms' => implode(', ', $missing_permissions)]), 'Role');
}
}
return $role->id();
@@ -189,7 +189,7 @@ trait UserCreationTrait {
$valid = TRUE;
foreach ($permissions as $permission) {
if (!in_array($permission, $available)) {
- $this->fail(SafeMarkup::format('Invalid permission %permission.', array('%permission' => $permission)), 'Role');
+ $this->fail(SafeMarkup::format('Invalid permission %permission.', ['%permission' => $permission]), 'Role');
$valid = FALSE;
}
}
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 6ff76aee613..b1a0258b571 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -100,7 +100,7 @@ abstract class WebTestBase extends TestBase {
*
* @var array
*/
- protected $cookies = array();
+ protected $cookies = [];
/**
* Indicates that headers should be dumped if verbose output is enabled.
@@ -133,7 +133,7 @@ abstract class WebTestBase extends TestBase {
* \Drupal\simpletest\WebTestBase itself never sets this but always obeys what
* is set.
*/
- protected $additionalCurlOptions = array();
+ protected $additionalCurlOptions = [];
/**
* The original batch, before it was changed for testing purposes.
@@ -154,7 +154,7 @@ abstract class WebTestBase extends TestBase {
*
* @var array
*/
- protected $originalShutdownCallbacks = array();
+ protected $originalShutdownCallbacks = [];
/**
* The current session ID, if available.
@@ -191,7 +191,7 @@ abstract class WebTestBase extends TestBase {
*
* @var array
*/
- protected $curlCookies = array();
+ protected $curlCookies = [];
/**
* An array of custom translations suitable for drupal_rewrite_settings().
@@ -259,7 +259,7 @@ abstract class WebTestBase extends TestBase {
$render_controller = $this->container->get('entity.manager')->getViewBuilder($entity->getEntityTypeId());
if ($reset) {
- $render_controller->resetCache(array($entity->id()));
+ $render_controller->resetCache([$entity->id()]);
}
$build = $render_controller->view($entity, $view_mode, $langcode);
$ensure_fully_built($build);
@@ -275,7 +275,7 @@ abstract class WebTestBase extends TestBase {
*/
protected function assertBlockAppears(Block $block) {
$result = $this->findBlockInstance($block);
- $this->assertTrue(!empty($result), format_string('Ensure the block @id appears on the page', array('@id' => $block->id())));
+ $this->assertTrue(!empty($result), format_string('Ensure the block @id appears on the page', ['@id' => $block->id()]));
}
/**
@@ -286,7 +286,7 @@ abstract class WebTestBase extends TestBase {
*/
protected function assertNoBlockAppears(Block $block) {
$result = $this->findBlockInstance($block);
- $this->assertFalse(!empty($result), format_string('Ensure the block @id does not appear on the page', array('@id' => $block->id())));
+ $this->assertFalse(!empty($result), format_string('Ensure the block @id does not appear on the page', ['@id' => $block->id()]));
}
/**
@@ -299,7 +299,7 @@ abstract class WebTestBase extends TestBase {
* The result from the xpath query.
*/
protected function findBlockInstance(Block $block) {
- return $this->xpath('//div[@id = :id]', array(':id' => 'block-' . $block->id()));
+ return $this->xpath('//div[@id = :id]', [':id' => 'block-' . $block->id()]);
}
/**
@@ -334,17 +334,17 @@ abstract class WebTestBase extends TestBase {
$this->drupalLogout();
}
- $edit = array(
+ $edit = [
'name' => $account->getUsername(),
'pass' => $account->pass_raw
- );
+ ];
$this->drupalPostForm('user/login', $edit, t('Log in'));
// @see WebTestBase::drupalUserIsLoggedIn()
if (isset($this->sessionId)) {
$account->session_id = $this->sessionId;
}
- $pass = $this->assert($this->drupalUserIsLoggedIn($account), format_string('User %name successfully logged in.', array('%name' => $account->getUsername())), 'User login');
+ $pass = $this->assert($this->drupalUserIsLoggedIn($account), format_string('User %name successfully logged in.', ['%name' => $account->getUsername()]), 'User login');
if ($pass) {
$this->loggedInUser = $account;
$this->container->get('current_user')->setAccount($account);
@@ -377,7 +377,7 @@ abstract class WebTestBase extends TestBase {
// Make a request to the logout page, and redirect to the user page, the
// idea being if you were properly logged out you should be seeing a login
// screen.
- $this->drupalGet('user/logout', array('query' => array('destination' => 'user/login')));
+ $this->drupalGet('user/logout', ['query' => ['destination' => 'user/login']]);
$this->assertResponse(200, 'User was logged out.');
$pass = $this->assertField('name', 'Username field found.', 'Logout');
$pass = $pass && $this->assertField('pass', 'Password field found.', 'Logout');
@@ -469,36 +469,36 @@ abstract class WebTestBase extends TestBase {
unset($connection_info['default']['host']);
unset($connection_info['default']['port']);
}
- $parameters = array(
+ $parameters = [
'interactive' => FALSE,
- 'parameters' => array(
+ 'parameters' => [
'profile' => $this->profile,
'langcode' => 'en',
- ),
- 'forms' => array(
- 'install_settings_form' => array(
+ ],
+ 'forms' => [
+ 'install_settings_form' => [
'driver' => $driver,
$driver => $connection_info['default'],
- ),
- 'install_configure_form' => array(
+ ],
+ 'install_configure_form' => [
'site_name' => 'Drupal',
'site_mail' => 'simpletest@example.com',
- 'account' => array(
+ 'account' => [
'name' => $this->rootUser->name,
'mail' => $this->rootUser->getEmail(),
- 'pass' => array(
+ 'pass' => [
'pass1' => $this->rootUser->pass_raw,
'pass2' => $this->rootUser->pass_raw,
- ),
- ),
+ ],
+ ],
// \Drupal\Core\Render\Element\Checkboxes::valueCallback() requires
// NULL instead of FALSE values for programmatic form submissions to
// disable a checkbox.
'enable_update_status_module' => NULL,
'enable_update_status_emails' => NULL,
- ),
- ),
- );
+ ],
+ ],
+ ];
// If we only have one db driver available, we cannot set the driver.
include_once DRUPAL_ROOT . '/core/includes/install.inc';
@@ -574,7 +574,7 @@ abstract class WebTestBase extends TestBase {
// If $values is empty, then the test expects all custom translations to be
// cleared.
if (empty($values)) {
- $this->customTranslations[$langcode] = array();
+ $this->customTranslations[$langcode] = [];
}
// Otherwise, $values are expected to be merged into previously passed
// values, while retaining keys that are not explicitly set.
@@ -594,17 +594,17 @@ abstract class WebTestBase extends TestBase {
* calling this method.
*/
protected function writeCustomTranslations() {
- $settings = array();
+ $settings = [];
foreach ($this->customTranslations as $langcode => $values) {
$settings_key = 'locale_custom_strings_' . $langcode;
// Update in-memory settings directly.
$this->settingsSet($settings_key, $values);
- $settings['settings'][$settings_key] = (object) array(
+ $settings['settings'][$settings_key] = (object) [
'value' => $values,
'required' => TRUE,
- );
+ ];
}
// Only rewrite settings if there are any translation changes to write.
if (!empty($settings)) {
@@ -630,13 +630,13 @@ abstract class WebTestBase extends TestBase {
// Ensure that internal logged in variable and cURL options are reset.
$this->loggedInUser = FALSE;
- $this->additionalCurlOptions = array();
+ $this->additionalCurlOptions = [];
// Close the CURL handler and reset the cookies array used for upgrade
// testing so test classes containing multiple tests are not polluted.
$this->curlClose();
- $this->curlCookies = array();
- $this->cookies = array();
+ $this->curlCookies = [];
+ $this->cookies = [];
}
/**
@@ -659,7 +659,7 @@ abstract class WebTestBase extends TestBase {
$this->cookieFile = $this->publicFilesDirectory . '/cookie.jar';
}
- $curl_options = array(
+ $curl_options = [
CURLOPT_COOKIEJAR => $this->cookieFile,
CURLOPT_URL => $base_url,
CURLOPT_FOLLOWLOCATION => FALSE,
@@ -668,11 +668,11 @@ abstract class WebTestBase extends TestBase {
CURLOPT_SSL_VERIFYPEER => FALSE,
// Required to make the tests run on HTTPS.
CURLOPT_SSL_VERIFYHOST => FALSE,
- CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
+ CURLOPT_HEADERFUNCTION => [&$this, 'curlHeaderCallback'],
CURLOPT_USERAGENT => $this->databasePrefix,
// Disable support for the @ prefix for uploading files.
CURLOPT_SAFE_UPLOAD => TRUE,
- );
+ ];
if (isset($this->httpAuthCredentials)) {
$curl_options[CURLOPT_HTTPAUTH] = $this->httpAuthMethod;
$curl_options[CURLOPT_USERPWD] = $this->httpAuthCredentials;
@@ -731,7 +731,7 @@ abstract class WebTestBase extends TestBase {
$curl_options[CURLOPT_HTTPHEADER][] = 'Expect:';
}
- $cookies = array();
+ $cookies = [];
if (!empty($this->curlCookies)) {
$cookies = $this->curlCookies;
}
@@ -744,9 +744,9 @@ abstract class WebTestBase extends TestBase {
// Merge additional cookies in.
if (!empty($cookies)) {
- $curl_options += array(
+ $curl_options += [
CURLOPT_COOKIE => '',
- );
+ ];
// Ensure any existing cookie data string ends with the correct separator.
if (!empty($curl_options[CURLOPT_COOKIE])) {
$curl_options[CURLOPT_COOKIE] = rtrim($curl_options[CURLOPT_COOKIE], '; ') . '; ';
@@ -759,7 +759,7 @@ abstract class WebTestBase extends TestBase {
if (!$redirect) {
// Reset headers, the session ID and the redirect counter.
$this->sessionId = NULL;
- $this->headers = array();
+ $this->headers = [];
$this->redirectCount = 0;
}
@@ -771,10 +771,10 @@ abstract class WebTestBase extends TestBase {
// to prevent fragments being sent to the web server as part
// of the request.
// TODO: Remove this for Drupal 8, since fixed in curl 7.20.0.
- if (in_array($status, array(300, 301, 302, 303, 305, 307)) && $this->redirectCount < $this->maximumRedirects) {
+ if (in_array($status, [300, 301, 302, 303, 305, 307]) && $this->redirectCount < $this->maximumRedirects) {
if ($this->drupalGetHeader('location')) {
$this->redirectCount++;
- $curl_options = array();
+ $curl_options = [];
$curl_options[CURLOPT_URL] = $this->drupalGetHeader('location');
$curl_options[CURLOPT_HTTPGET] = TRUE;
return $this->curlExec($curl_options, TRUE);
@@ -784,12 +784,12 @@ abstract class WebTestBase extends TestBase {
$this->setRawContent($content);
$this->url = isset($original_url) ? $original_url : curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL);
- $message_vars = array(
+ $message_vars = [
'@method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
'@url' => isset($original_url) ? $original_url : $url,
'@status' => $status,
'@length' => format_size(strlen($this->getRawContent()))
- );
+ ];
$message = SafeMarkup::format('@method @url returned @status (@length).', $message_vars);
$this->assertTrue($this->getRawContent() !== FALSE, $message, 'Browser');
return $this->getRawContent();
@@ -823,7 +823,7 @@ abstract class WebTestBase extends TestBase {
if (preg_match('/^X-Drupal-Assertion-[0-9]+: (.*)$/', $header, $matches)) {
// Call \Drupal\simpletest\WebTestBase::error() with the parameters from
// the header.
- call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1])));
+ call_user_func_array([&$this, 'error'], unserialize(urldecode($matches[1])));
}
// Save cookies.
@@ -831,7 +831,7 @@ abstract class WebTestBase extends TestBase {
$name = $matches[1];
$parts = array_map('trim', explode(';', $matches[2]));
$value = array_shift($parts);
- $this->cookies[$name] = array('value' => $value, 'secure' => in_array('secure', $parts));
+ $this->cookies[$name] = ['value' => $value, 'secure' => in_array('secure', $parts)];
if ($name === $this->getSessionName()) {
if ($value != 'deleted') {
$this->sessionId = $value;
@@ -885,11 +885,11 @@ abstract class WebTestBase extends TestBase {
* @return string
* The retrieved HTML string, also available as $this->getRawContent()
*/
- protected function drupalGet($path, array $options = array(), array $headers = array()) {
+ protected function drupalGet($path, array $options = [], array $headers = []) {
// We re-using a CURL connection here. If that connection still has certain
// options set, it might change the GET into a POST. Make sure we clear out
// previous options.
- $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => $this->buildUrl($path, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => $headers));
+ $out = $this->curlExec([CURLOPT_HTTPGET => TRUE, CURLOPT_URL => $this->buildUrl($path, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => $headers]);
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
@@ -928,7 +928,7 @@ abstract class WebTestBase extends TestBase {
* @return array
* Decoded json.
*/
- protected function drupalGetJSON($path, array $options = array(), array $headers = array()) {
+ protected function drupalGetJSON($path, array $options = [], array $headers = []) {
return Json::decode($this->drupalGetWithFormat($path, 'json', $options, $headers));
}
@@ -965,7 +965,7 @@ abstract class WebTestBase extends TestBase {
* @return array
* Decoded JSON.
*/
- protected function drupalGetAjax($path, array $options = array(), array $headers = array()) {
+ protected function drupalGetAjax($path, array $options = [], array $headers = []) {
if (!isset($options['query'][MainContentViewSubscriber::WRAPPER_FORMAT])) {
$options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax';
}
@@ -985,7 +985,7 @@ abstract class WebTestBase extends TestBase {
* @return string
* The retrieved content.
*/
- protected function drupalGetXHR($path, array $options = array(), array $headers = array()) {
+ protected function drupalGetXHR($path, array $options = [], array $headers = []) {
$headers[] = 'X-Requested-With: XMLHttpRequest';
return $this->drupalGet($path, $options, $headers);
}
@@ -1074,7 +1074,7 @@ abstract class WebTestBase extends TestBase {
* POST data, so it must already be urlencoded and contain a leading "&"
* (e.g., "&extra_var1=hello+world&extra_var2=you%26me").
*/
- protected function drupalPostForm($path, $edit, $submit, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) {
+ protected function drupalPostForm($path, $edit, $submit, array $options = [], array $headers = [], $form_html_id = NULL, $extra_post = NULL) {
if (is_object($submit)) {
// Cast MarkupInterface objects to string.
$submit = (string) $submit;
@@ -1100,8 +1100,8 @@ abstract class WebTestBase extends TestBase {
foreach ($forms as $form) {
// We try to set the fields of this form as specified in $edit.
$edit = $edit_save;
- $post = array();
- $upload = array();
+ $post = [];
+ $upload = [];
$submit_matches = $this->handleForm($post, $edit, $upload, $ajax ? NULL : $submit, $form);
$action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : $this->getUrl();
if ($ajax) {
@@ -1141,7 +1141,7 @@ abstract class WebTestBase extends TestBase {
else {
$post = $this->serializePostValues($post) . $extra_post;
}
- $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers));
+ $out = $this->curlExec([CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers]);
// Ensure that any changes to variables in the other thread are picked
// up.
$this->refreshVariables();
@@ -1169,12 +1169,12 @@ abstract class WebTestBase extends TestBase {
}
// We have not found a form which contained all fields of $edit.
foreach ($edit as $name => $value) {
- $this->fail(SafeMarkup::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
+ $this->fail(SafeMarkup::format('Failed to set field @name to @value', ['@name' => $name, '@value' => $value]));
}
if (!$ajax && isset($submit)) {
- $this->assertTrue($submit_matches, format_string('Found the @submit button', array('@submit' => $submit)));
+ $this->assertTrue($submit_matches, format_string('Found the @submit button', ['@submit' => $submit]));
}
- $this->fail(format_string('Found the requested form fields at @path', array('@path' => ($path instanceof Url) ? $path->toString() : $path)));
+ $this->fail(format_string('Found the requested form fields at @path', ['@path' => ($path instanceof Url) ? $path->toString() : $path]));
}
}
@@ -1220,7 +1220,7 @@ abstract class WebTestBase extends TestBase {
* @see drupalProcessAjaxResponse()
* @see ajax.js
*/
- protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_path = NULL, array $options = array(), array $headers = array(), $form_html_id = NULL, $ajax_settings = NULL) {
+ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_path = NULL, array $options = [], array $headers = [], $form_html_id = NULL, $ajax_settings = NULL) {
// Get the content of the initial page prior to calling drupalPostForm(),
// since drupalPostForm() replaces $this->content.
@@ -1257,7 +1257,7 @@ abstract class WebTestBase extends TestBase {
}
// Add extra information to the POST data as ajax.js does.
- $extra_post = array();
+ $extra_post = [];
if (isset($ajax_settings['submit'])) {
foreach ($ajax_settings['submit'] as $key => $value) {
$extra_post[$key] = $value;
@@ -1295,7 +1295,7 @@ abstract class WebTestBase extends TestBase {
$ajax_path = $this->container->get('unrouted_url_assembler')->assemble('base://' . $ajax_path, $options);
// Submit the POST request.
- $return = Json::decode($this->drupalPostForm(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post));
+ $return = Json::decode($this->drupalPostForm(NULL, $edit, ['path' => $ajax_path, 'triggering_element' => $triggering_element], $options, $headers, $form_html_id, $extra_post));
if ($this->assertAjaxHeader) {
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Ajax-Token'), '1', 'Ajax response header found.');
}
@@ -1341,9 +1341,9 @@ abstract class WebTestBase extends TestBase {
// ajax.js applies some defaults to the settings object, so do the same
// for what's used by this function.
- $ajax_settings += array(
+ $ajax_settings += [
'method' => 'replaceWith',
- );
+ ];
// DOM can load HTML soup. But, HTML soup can throw warnings, suppress
// them.
$dom = new \DOMDocument();
@@ -1370,7 +1370,7 @@ abstract class WebTestBase extends TestBase {
// @todo Ajax commands can target any jQuery selector, but these are
// hard to fully emulate with XPath. For now, just handle 'head'
// and 'body', since these are used by the Ajax renderer.
- elseif (in_array($command['selector'], array('head', 'body'))) {
+ elseif (in_array($command['selector'], ['head', 'body'])) {
$wrapperNode = $xpath->query('//' . $command['selector'])->item(0);
}
if ($wrapperNode) {
@@ -1464,16 +1464,16 @@ abstract class WebTestBase extends TestBase {
* @see WebTestBase::getAjaxPageStatePostData()
* @see WebTestBase::curlExec()
*/
- protected function drupalPost($path, $accept, array $post, $options = array()) {
- return $this->curlExec(array(
+ protected function drupalPost($path, $accept, array $post, $options = []) {
+ return $this->curlExec([
CURLOPT_URL => $this->buildUrl($path, $options),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $this->serializePostValues($post),
- CURLOPT_HTTPHEADER => array(
+ CURLOPT_HTTPHEADER => [
'Accept: ' . $accept,
'Content-Type: application/x-www-form-urlencoded',
- ),
- ));
+ ],
+ ]);
}
/**
@@ -1510,7 +1510,7 @@ abstract class WebTestBase extends TestBase {
* The Ajax page state POST data.
*/
protected function getAjaxPageStatePostData() {
- $post = array();
+ $post = [];
$drupal_settings = $this->drupalSettings;
if (isset($drupal_settings['ajaxPageState']['theme'])) {
$post['ajax_page_state[theme]'] = $drupal_settings['ajaxPageState']['theme'];
@@ -1537,7 +1537,7 @@ abstract class WebTestBase extends TestBase {
* @return string
* The serialized result.
*/
- protected function serializePostValues($post = array()) {
+ protected function serializePostValues($post = []) {
foreach ($post as $key => $value) {
$post[$key] = urlencode($key) . '=' . urlencode($value);
}
@@ -1554,7 +1554,7 @@ abstract class WebTestBase extends TestBase {
* The flattened $edit array suitable for WebTestBase::drupalPostForm().
*/
protected function translatePostValues(array $values) {
- $edit = array();
+ $edit = [];
// The easiest and most straightforward way to translate values suitable for
// WebTestBase::drupalPostForm() is to actually build the POST data string
// and convert the resulting key/value pairs back into a flat array.
@@ -1604,10 +1604,10 @@ abstract class WebTestBase extends TestBase {
* @return
* The retrieved headers, also available as $this->getRawContent()
*/
- protected function drupalHead($path, array $options = array(), array $headers = array()) {
+ protected function drupalHead($path, array $options = [], array $headers = []) {
$options['absolute'] = TRUE;
$url = $this->buildUrl($path, $options);
- $out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => $url, CURLOPT_HTTPHEADER => $headers));
+ $out = $this->curlExec([CURLOPT_NOBODY => TRUE, CURLOPT_URL => $url, CURLOPT_HTTPHEADER => $headers]);
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
@@ -1838,13 +1838,13 @@ abstract class WebTestBase extends TestBase {
// Cast MarkupInterface objects to string.
$label = (string) $label;
$url_before = $this->getUrl();
- $urls = $this->xpath($pattern, array(':label' => $label));
+ $urls = $this->xpath($pattern, [':label' => $label]);
if (isset($urls[$index])) {
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
- $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
+ $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', ['%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before]), 'Browser');
return $this->drupalGet($url_target);
}
- $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', array('%label' => $label, '@url_before' => $url_before)), 'Browser');
+ $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', ['%label' => $label, '@url_before' => $url_before]), 'Browser');
return FALSE;
}
@@ -1921,7 +1921,7 @@ abstract class WebTestBase extends TestBase {
*/
protected function drupalGetHeaders($all_requests = FALSE) {
$request = 0;
- $headers = array($request => array());
+ $headers = [$request => []];
foreach ($this->headers as $header) {
$header = trim($header);
if ($header === '') {
@@ -2032,7 +2032,7 @@ abstract class WebTestBase extends TestBase {
* @return
* TRUE on pass, FALSE on fail.
*/
- protected function assertUrl($path, array $options = array(), $message = '', $group = 'Other') {
+ protected function assertUrl($path, array $options = [], $message = '', $group = 'Other') {
if ($path instanceof Url) {
$url_obj = $path;
}
@@ -2047,10 +2047,10 @@ abstract class WebTestBase extends TestBase {
}
$url = $url_obj->setAbsolute()->toString();
if (!$message) {
- $message = SafeMarkup::format('Expected @url matches current URL (@current_url).', array(
+ $message = SafeMarkup::format('Expected @url matches current URL (@current_url).', [
'@url' => var_export($url, TRUE),
'@current_url' => $this->getUrl(),
- ));
+ ]);
}
// Paths in query strings can be encoded or decoded with no functional
// difference, decode them for comparison purposes.
@@ -2082,7 +2082,7 @@ abstract class WebTestBase extends TestBase {
protected function assertResponse($code, $message = '', $group = 'Browser') {
$curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
$match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
- return $this->assertTrue($match, $message ? $message : SafeMarkup::format('HTTP response expected @code, actual @curl_code', array('@code' => $code, '@curl_code' => $curl_code)), $group);
+ return $this->assertTrue($match, $message ? $message : SafeMarkup::format('HTTP response expected @code, actual @curl_code', ['@code' => $code, '@curl_code' => $curl_code]), $group);
}
/**
@@ -2108,7 +2108,7 @@ abstract class WebTestBase extends TestBase {
protected function assertNoResponse($code, $message = '', $group = 'Browser') {
$curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
$match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
- return $this->assertFalse($match, $message ? $message : SafeMarkup::format('HTTP response not expected @code, actual @curl_code', array('@code' => $code, '@curl_code' => $curl_code)), $group);
+ return $this->assertFalse($match, $message ? $message : SafeMarkup::format('HTTP response not expected @code, actual @curl_code', ['@code' => $code, '@curl_code' => $curl_code]), $group);
}
/**
@@ -2122,7 +2122,7 @@ abstract class WebTestBase extends TestBase {
* @return string
* An absolute URL string.
*/
- protected function buildUrl($path, array $options = array()) {
+ protected function buildUrl($path, array $options = []) {
if ($path instanceof Url) {
$url_options = $path->getOptions();
$options = $url_options + $options;
diff --git a/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install b/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install
index 447a192f411..aabe921f590 100644
--- a/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install
+++ b/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install
@@ -12,13 +12,13 @@ use Drupal\entity_test\Entity\EntityTest;
*/
function simpletest_test_install() {
$total = 2;
- $operations = array();
+ $operations = [];
for ($i = 1; $i <= $total; $i++) {
- $operations[] = array('_simpletest_test_callback', array($i));
+ $operations[] = ['_simpletest_test_callback', [$i]];
}
- $batch = array(
+ $batch = [
'operations' => $operations,
- );
+ ];
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
@@ -29,6 +29,6 @@ function simpletest_test_install() {
* Callback for batch operations.
*/
function _simpletest_test_callback($id) {
- $entity = EntityTest::create(array('id' => $id));
+ $entity = EntityTest::create(['id' => $id]);
$entity->save();
}
diff --git a/core/modules/simpletest/tests/src/Functional/FolderTest.php b/core/modules/simpletest/tests/src/Functional/FolderTest.php
index 4055976a679..92844d8ed9f 100644
--- a/core/modules/simpletest/tests/src/Functional/FolderTest.php
+++ b/core/modules/simpletest/tests/src/Functional/FolderTest.php
@@ -17,7 +17,7 @@ class FolderTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('image');
+ public static $modules = ['image'];
function testFolderSetup() {
$directory = file_default_scheme() . '://styles';
diff --git a/core/modules/simpletest/tests/src/Functional/MailCaptureTest.php b/core/modules/simpletest/tests/src/Functional/MailCaptureTest.php
index b79db8d3fb7..1193e478ed8 100644
--- a/core/modules/simpletest/tests/src/Functional/MailCaptureTest.php
+++ b/core/modules/simpletest/tests/src/Functional/MailCaptureTest.php
@@ -22,20 +22,20 @@ class MailCaptureTest extends BrowserTestBase {
// Create an email.
$subject = $this->randomString(64);
$body = $this->randomString(128);
- $message = array(
+ $message = [
'id' => 'drupal_mail_test',
- 'headers' => array('Content-type' => 'text/html'),
+ 'headers' => ['Content-type' => 'text/html'],
'subject' => $subject,
'to' => 'foobar@example.com',
'body' => $body,
- );
+ ];
// Before we send the email, drupalGetMails should return an empty array.
$captured_emails = $this->drupalGetMails();
$this->assertEqual(count($captured_emails), 0, 'The captured emails queue is empty.', 'Email');
// Send the email.
- \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'simpletest', 'key' => 'drupal_mail_test'))->mail($message);
+ \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'simpletest', 'key' => 'drupal_mail_test'])->mail($message);
// Ensure that there is one email in the captured emails array.
$captured_emails = $this->drupalGetMails();
@@ -44,19 +44,19 @@ class MailCaptureTest extends BrowserTestBase {
// Assert that the email was sent by iterating over the message properties
// and ensuring that they are captured intact.
foreach ($message as $field => $value) {
- $this->assertMail($field, $value, format_string('The email was sent and the value for property @field is intact.', array('@field' => $field)), 'Email');
+ $this->assertMail($field, $value, format_string('The email was sent and the value for property @field is intact.', ['@field' => $field]), 'Email');
}
// Send additional emails so more than one email is captured.
for ($index = 0; $index < 5; $index++) {
- $message = array(
+ $message = [
'id' => 'drupal_mail_test_' . $index,
- 'headers' => array('Content-type' => 'text/html'),
+ 'headers' => ['Content-type' => 'text/html'],
'subject' => $this->randomString(64),
'to' => $this->randomMachineName(32) . '@example.com',
'body' => $this->randomString(512),
- );
- \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'drupal_mail_test', 'key' => $index))->mail($message);
+ ];
+ \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'drupal_mail_test', 'key' => $index])->mail($message);
}
// There should now be 6 emails captured.
@@ -64,18 +64,18 @@ class MailCaptureTest extends BrowserTestBase {
$this->assertEqual(count($captured_emails), 6, 'All emails were captured.', 'Email');
// Test different ways of getting filtered emails via drupalGetMails().
- $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test'));
+ $captured_emails = $this->drupalGetMails(['id' => 'drupal_mail_test']);
$this->assertEqual(count($captured_emails), 1, 'Only one email is returned when filtering by id.', 'Email');
- $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject));
+ $captured_emails = $this->drupalGetMails(['id' => 'drupal_mail_test', 'subject' => $subject]);
$this->assertEqual(count($captured_emails), 1, 'Only one email is returned when filtering by id and subject.', 'Email');
- $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject, 'from' => 'this_was_not_used@example.com'));
+ $captured_emails = $this->drupalGetMails(['id' => 'drupal_mail_test', 'subject' => $subject, 'from' => 'this_was_not_used@example.com']);
$this->assertEqual(count($captured_emails), 0, 'No emails are returned when querying with an unused from address.', 'Email');
// Send the last email again, so we can confirm that the
// drupalGetMails-filter correctly returns all emails with a given
// property/value.
- \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'drupal_mail_test', 'key' => $index))->mail($message);
- $captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test_4'));
+ \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'drupal_mail_test', 'key' => $index])->mail($message);
+ $captured_emails = $this->drupalGetMails(['id' => 'drupal_mail_test_4']);
$this->assertEqual(count($captured_emails), 2, 'All emails with the same id are returned when filtering by id.', 'Email');
}
diff --git a/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php b/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php
index 71601e2792b..04736ec0ed2 100644
--- a/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php
+++ b/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php
@@ -17,7 +17,7 @@ class OtherInstallationProfileTestsTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('simpletest');
+ public static $modules = ['simpletest'];
/**
* Use the Minimal profile.
@@ -43,7 +43,7 @@ class OtherInstallationProfileTestsTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
+ $this->adminUser = $this->drupalCreateUser(['administer unit tests']);
$this->drupalLogin($this->adminUser);
}
diff --git a/core/modules/simpletest/tests/src/Kernel/Migrate/d6/MigrateSimpletestConfigsTest.php b/core/modules/simpletest/tests/src/Kernel/Migrate/d6/MigrateSimpletestConfigsTest.php
index b45f9ab3ada..f8f9ffb02ce 100644
--- a/core/modules/simpletest/tests/src/Kernel/Migrate/d6/MigrateSimpletestConfigsTest.php
+++ b/core/modules/simpletest/tests/src/Kernel/Migrate/d6/MigrateSimpletestConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateSimpletestConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('simpletest');
+ public static $modules = ['simpletest'];
/**
* {@inheritdoc}
diff --git a/core/modules/simpletest/tests/src/Unit/TestBaseTest.php b/core/modules/simpletest/tests/src/Unit/TestBaseTest.php
index 6643eb666fb..cdfe9869b59 100644
--- a/core/modules/simpletest/tests/src/Unit/TestBaseTest.php
+++ b/core/modules/simpletest/tests/src/Unit/TestBaseTest.php
@@ -25,8 +25,8 @@ class TestBaseTest extends UnitTestCase {
*/
public function getTestBaseForAssertionTests($test_id) {
$mock_test_base = $this->getMockBuilder('Drupal\simpletest\TestBase')
- ->setConstructorArgs(array($test_id))
- ->setMethods(array('storeAssertion'))
+ ->setConstructorArgs([$test_id])
+ ->setMethods(['storeAssertion'])
->getMockForAbstractClass();
// Override storeAssertion() so we don't need a database.
$mock_test_base->expects($this->any())
@@ -62,16 +62,16 @@ class TestBaseTest extends UnitTestCase {
* - The string to validate.
*/
public function providerRandomStringValidate() {
- return array(
- array(FALSE, ' curry paste'),
- array(FALSE, 'curry paste '),
- array(FALSE, 'curry paste'),
- array(FALSE, 'curry paste'),
- array(TRUE, 'curry paste'),
- array(TRUE, 'thai green curry paste'),
- array(TRUE, '@startswithat'),
- array(TRUE, 'contains@at'),
- );
+ return [
+ [FALSE, ' curry paste'],
+ [FALSE, 'curry paste '],
+ [FALSE, 'curry paste'],
+ [FALSE, 'curry paste'],
+ [TRUE, 'curry paste'],
+ [TRUE, 'thai green curry paste'],
+ [TRUE, '@startswithat'],
+ [TRUE, 'contains@at'],
+ ];
}
/**
@@ -136,7 +136,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertInternalType(
'array',
- $this->invokeProtectedMethod($test_base, 'checkRequirements', array())
+ $this->invokeProtectedMethod($test_base, 'checkRequirements', [])
);
}
@@ -153,14 +153,14 @@ class TestBaseTest extends UnitTestCase {
* - Caller, passed to assert().
*/
public function providerAssert() {
- return array(
- array(TRUE, 'pass', TRUE, 'Yay pass', 'test', array()),
- array(FALSE, 'fail', FALSE, 'Boo fail', 'test', array()),
- array(TRUE, 'pass', 'pass', 'Yay pass', 'test', array()),
- array(FALSE, 'fail', 'fail', 'Boo fail', 'test', array()),
- array(FALSE, 'exception', 'exception', 'Boo fail', 'test', array()),
- array(FALSE, 'debug', 'debug', 'Boo fail', 'test', array()),
- );
+ return [
+ [TRUE, 'pass', TRUE, 'Yay pass', 'test', []],
+ [FALSE, 'fail', FALSE, 'Boo fail', 'test', []],
+ [TRUE, 'pass', 'pass', 'Yay pass', 'test', []],
+ [FALSE, 'fail', 'fail', 'Boo fail', 'test', []],
+ [FALSE, 'exception', 'exception', 'Boo fail', 'test', []],
+ [FALSE, 'debug', 'debug', 'Boo fail', 'test', []],
+ ];
}
/**
@@ -185,7 +185,7 @@ class TestBaseTest extends UnitTestCase {
$this->assertEquals(
$expected,
$ref_assert->invokeArgs($test_base,
- array($status, $message, $group, $caller)
+ [$status, $message, $group, $caller]
)
);
@@ -211,10 +211,10 @@ class TestBaseTest extends UnitTestCase {
* Data provider for assertTrue().
*/
public function providerAssertTrue() {
- return array(
- array(TRUE, TRUE),
- array(FALSE, FALSE),
- );
+ return [
+ [TRUE, TRUE],
+ [FALSE, FALSE],
+ ];
}
/**
@@ -225,7 +225,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
$expected,
- $this->invokeProtectedMethod($test_base, 'assertTrue', array($value))
+ $this->invokeProtectedMethod($test_base, 'assertTrue', [$value])
);
}
@@ -237,7 +237,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
(!$expected),
- $this->invokeProtectedMethod($test_base, 'assertFalse', array($value))
+ $this->invokeProtectedMethod($test_base, 'assertFalse', [$value])
);
}
@@ -245,10 +245,10 @@ class TestBaseTest extends UnitTestCase {
* Data provider for assertNull().
*/
public function providerAssertNull() {
- return array(
- array(TRUE, NULL),
- array(FALSE, ''),
- );
+ return [
+ [TRUE, NULL],
+ [FALSE, ''],
+ ];
}
/**
@@ -259,7 +259,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
$expected,
- $this->invokeProtectedMethod($test_base, 'assertNull', array($value))
+ $this->invokeProtectedMethod($test_base, 'assertNull', [$value])
);
}
@@ -271,7 +271,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
(!$expected),
- $this->invokeProtectedMethod($test_base, 'assertNotNull', array($value))
+ $this->invokeProtectedMethod($test_base, 'assertNotNull', [$value])
);
}
@@ -325,7 +325,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
$expected_identical,
- $this->invokeProtectedMethod($test_base, 'assertIdentical', array($first, $second))
+ $this->invokeProtectedMethod($test_base, 'assertIdentical', [$first, $second])
);
}
@@ -337,7 +337,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
(!$expected_identical),
- $this->invokeProtectedMethod($test_base, 'assertNotIdentical', array($first, $second))
+ $this->invokeProtectedMethod($test_base, 'assertNotIdentical', [$first, $second])
);
}
@@ -349,7 +349,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
$expected_equal,
- $this->invokeProtectedMethod($test_base, 'assertEqual', array($first, $second))
+ $this->invokeProtectedMethod($test_base, 'assertEqual', [$first, $second])
);
}
@@ -361,7 +361,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
(!$expected_equal),
- $this->invokeProtectedMethod($test_base, 'assertNotEqual', array($first, $second))
+ $this->invokeProtectedMethod($test_base, 'assertNotEqual', [$first, $second])
);
}
@@ -374,11 +374,11 @@ class TestBaseTest extends UnitTestCase {
$obj2 = $obj1;
$obj3 = clone $obj1;
$obj4 = new \stdClass();
- return array(
- array(TRUE, $obj1, $obj2),
- array(TRUE, $obj1, $obj3),
- array(FALSE, $obj1, $obj4),
- );
+ return [
+ [TRUE, $obj1, $obj2],
+ [TRUE, $obj1, $obj3],
+ [FALSE, $obj1, $obj4],
+ ];
}
/**
@@ -389,7 +389,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
$expected,
- $this->invokeProtectedMethod($test_base, 'assertIdenticalObject', array($first, $second))
+ $this->invokeProtectedMethod($test_base, 'assertIdenticalObject', [$first, $second])
);
}
@@ -400,7 +400,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
TRUE,
- $this->invokeProtectedMethod($test_base, 'pass', array())
+ $this->invokeProtectedMethod($test_base, 'pass', [])
);
}
@@ -411,7 +411,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertEquals(
FALSE,
- $this->invokeProtectedMethod($test_base, 'fail', array())
+ $this->invokeProtectedMethod($test_base, 'fail', [])
);
}
@@ -423,10 +423,10 @@ class TestBaseTest extends UnitTestCase {
* - Group for use in assert().
*/
public function providerError() {
- return array(
- array('debug', 'User notice'),
- array('exception', 'Not User notice'),
- );
+ return [
+ ['debug', 'User notice'],
+ ['exception', 'Not User notice'],
+ ];
}
/**
@@ -436,7 +436,7 @@ class TestBaseTest extends UnitTestCase {
public function testError($status, $group) {
// Mock up a TestBase object.
$mock_test_base = $this->getMockBuilder('Drupal\simpletest\TestBase')
- ->setMethods(array('assert'))
+ ->setMethods(['assert'])
->getMockForAbstractClass();
// Set expectations for assert().
@@ -451,7 +451,7 @@ class TestBaseTest extends UnitTestCase {
// Invoke error().
$this->assertEquals(
"$status:$group",
- $this->invokeProtectedMethod($mock_test_base, 'error', array('msg', $group))
+ $this->invokeProtectedMethod($mock_test_base, 'error', ['msg', $group])
);
}
@@ -462,7 +462,7 @@ class TestBaseTest extends UnitTestCase {
$test_base = $this->getTestBaseForAssertionTests('test_id');
$this->assertInstanceOf(
'Drupal\Component\Utility\Random',
- $this->invokeProtectedMethod($test_base, 'getRandomGenerator', array())
+ $this->invokeProtectedMethod($test_base, 'getRandomGenerator', [])
);
}
diff --git a/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php b/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php
index 1c087a6fd75..df909560a11 100644
--- a/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php
+++ b/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php
@@ -18,12 +18,12 @@ class WebTestBaseTest extends UnitTestCase {
* An array of values passed to the test method.
*/
public function providerAssertFieldByName() {
- $data = array();
- $data[] = array('select_2nd_selected', 'test', '1', FALSE);
- $data[] = array('select_2nd_selected', 'test', '2', TRUE);
- $data[] = array('select_none_selected', 'test', '', FALSE);
- $data[] = array('select_none_selected', 'test', '1', TRUE);
- $data[] = array('select_none_selected', 'test', NULL, TRUE);
+ $data = [];
+ $data[] = ['select_2nd_selected', 'test', '1', FALSE];
+ $data[] = ['select_2nd_selected', 'test', '2', TRUE];
+ $data[] = ['select_none_selected', 'test', '', FALSE];
+ $data[] = ['select_none_selected', 'test', '1', TRUE];
+ $data[] = ['select_none_selected', 'test', NULL, TRUE];
return $data;
}
@@ -50,7 +50,7 @@ class WebTestBaseTest extends UnitTestCase {
$web_test = $this->getMockBuilder('Drupal\simpletest\WebTestBase')
->disableOriginalConstructor()
- ->setMethods(array('getRawContent', 'assertTrue', 'pass'))
+ ->setMethods(['getRawContent', 'assertTrue', 'pass'])
->getMock();
$web_test->expects($this->any())
@@ -65,7 +65,7 @@ class WebTestBaseTest extends UnitTestCase {
$test_method = new \ReflectionMethod('Drupal\simpletest\WebTestBase', 'assertFieldByName');
$test_method->setAccessible(TRUE);
- $test_method->invokeArgs($web_test, array($name, $value, 'message'));
+ $test_method->invokeArgs($web_test, [$name, $value, 'message']);
}
/**
@@ -87,32 +87,32 @@ class WebTestBaseTest extends UnitTestCase {
* to mock no link found on the page.
*/
public function providerTestClickLink() {
- return array(
+ return [
// Test for a non-existent label.
- array(
+ [
FALSE,
'does_not_exist',
0,
- array(),
- ),
+ [],
+ ],
// Test for an existing label.
- array(
+ [
'This Text Returned By drupalGet()',
'exists',
0,
- array(0 => array('href' => 'this_is_a_url')),
- ),
+ [0 => ['href' => 'this_is_a_url']],
+ ],
// Test for an existing label that isn't the first one.
- array(
+ [
'This Text Returned By drupalGet()',
'exists',
1,
- array(
- 0 => array('href' => 'this_is_a_url'),
- 1 => array('href' => 'this_is_another_url'),
- ),
- ),
- );
+ [
+ 0 => ['href' => 'this_is_a_url'],
+ 1 => ['href' => 'this_is_another_url'],
+ ],
+ ],
+ ];
}
/**
@@ -134,14 +134,14 @@ class WebTestBaseTest extends UnitTestCase {
// Mock a WebTestBase object and some of its methods.
$web_test = $this->getMockBuilder('Drupal\simpletest\WebTestBase')
->disableOriginalConstructor()
- ->setMethods(array(
+ ->setMethods([
'pass',
'fail',
'getUrl',
'xpath',
'drupalGet',
'getAbsoluteUrl',
- ))
+ ])
->getMock();
// Mocked getUrl() is only used for reporting so we just return a string.
diff --git a/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php b/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php
index 32d28726181..0cccb1700b6 100644
--- a/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php
+++ b/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php
@@ -83,7 +83,7 @@ class NodeStatisticsDatabaseStorage implements StatisticsStorageInterface {
* {@inheritdoc}
*/
public function fetchView($id) {
- $views = $this->fetchViews(array($id));
+ $views = $this->fetchViews([$id]);
return reset($views);
}
diff --git a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php
index 8bd84b2b78c..1802a4569c3 100644
--- a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php
+++ b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php
@@ -92,11 +92,11 @@ class StatisticsPopularBlock extends BlockBase implements ContainerFactoryPlugin
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'top_day_num' => 0,
'top_all_num' => 0,
'top_last_num' => 0
- );
+ ];
}
/**
@@ -111,29 +111,29 @@ class StatisticsPopularBlock extends BlockBase implements ContainerFactoryPlugin
*/
public function blockForm($form, FormStateInterface $form_state) {
// Popular content block settings.
- $numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40);
- $numbers = array('0' => $this->t('Disabled')) + array_combine($numbers, $numbers);
- $form['statistics_block_top_day_num'] = array(
+ $numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40];
+ $numbers = ['0' => $this->t('Disabled')] + array_combine($numbers, $numbers);
+ $form['statistics_block_top_day_num'] = [
'#type' => 'select',
'#title' => $this->t("Number of day's top views to display"),
'#default_value' => $this->configuration['top_day_num'],
'#options' => $numbers,
'#description' => $this->t('How many content items to display in "day" list.'),
- );
- $form['statistics_block_top_all_num'] = array(
+ ];
+ $form['statistics_block_top_all_num'] = [
'#type' => 'select',
'#title' => $this->t('Number of all time views to display'),
'#default_value' => $this->configuration['top_all_num'],
'#options' => $numbers,
'#description' => $this->t('How many content items to display in "all time" list.'),
- );
- $form['statistics_block_top_last_num'] = array(
+ ];
+ $form['statistics_block_top_last_num'] = [
'#type' => 'select',
'#title' => $this->t('Number of most recent views to display'),
'#default_value' => $this->configuration['top_last_num'],
'#options' => $numbers,
'#description' => $this->t('How many content items to display in "recently viewed" list.'),
- );
+ ];
return $form;
}
@@ -150,7 +150,7 @@ class StatisticsPopularBlock extends BlockBase implements ContainerFactoryPlugin
* {@inheritdoc}
*/
public function build() {
- $content = array();
+ $content = [];
if ($this->configuration['top_day_num'] > 0) {
$nids = $this->statisticsStorage->fetchAll('daycount', $this->configuration['top_day_num']);
diff --git a/core/modules/statistics/src/StatisticsSettingsForm.php b/core/modules/statistics/src/StatisticsSettingsForm.php
index 2abb5642a49..71a1764b80f 100644
--- a/core/modules/statistics/src/StatisticsSettingsForm.php
+++ b/core/modules/statistics/src/StatisticsSettingsForm.php
@@ -65,17 +65,17 @@ class StatisticsSettingsForm extends ConfigFormBase {
$config = $this->config('statistics.settings');
// Content counter settings.
- $form['content'] = array(
+ $form['content'] = [
'#type' => 'details',
'#title' => t('Content viewing counter settings'),
'#open' => TRUE,
- );
- $form['content']['statistics_count_content_views'] = array(
+ ];
+ $form['content']['statistics_count_content_views'] = [
'#type' => 'checkbox',
'#title' => t('Count content views'),
'#default_value' => $config->get('count_content_views'),
'#description' => t('Increment a counter each time content is viewed.'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/statistics/src/Tests/StatisticsAdminTest.php b/core/modules/statistics/src/Tests/StatisticsAdminTest.php
index 6d87fd97574..35af86b2687 100644
--- a/core/modules/statistics/src/Tests/StatisticsAdminTest.php
+++ b/core/modules/statistics/src/Tests/StatisticsAdminTest.php
@@ -16,7 +16,7 @@ class StatisticsAdminTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'statistics');
+ public static $modules = ['node', 'statistics'];
/**
* A user that has permission to administer statistics.
@@ -47,11 +47,11 @@ class StatisticsAdminTest extends WebTestBase {
// Create Basic page node type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
}
- $this->privilegedUser = $this->drupalCreateUser(array('administer statistics', 'view post access counter', 'create page content'));
+ $this->privilegedUser = $this->drupalCreateUser(['administer statistics', 'view post access counter', 'create page content']);
$this->drupalLogin($this->privilegedUser);
- $this->testNode = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privilegedUser->id()));
+ $this->testNode = $this->drupalCreateNode(['type' => 'page', 'uid' => $this->privilegedUser->id()]);
$this->client = \Drupal::httpClient();
}
@@ -72,19 +72,19 @@ class StatisticsAdminTest extends WebTestBase {
$this->drupalGet('node/' . $this->testNode->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->testNode->id();
- $post = array('nid' => $nid);
+ $post = ['nid' => $nid];
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
- $this->client->post($stats_path, array('form_params' => $post));
+ $this->client->post($stats_path, ['form_params' => $post]);
// Hit the node again (the counter is incremented after the hit, so
// "1 view" will actually be shown when the node is hit the second time).
$this->drupalGet('node/' . $this->testNode->id());
- $this->client->post($stats_path, array('form_params' => $post));
+ $this->client->post($stats_path, ['form_params' => $post]);
$this->assertText('1 view', 'Node is viewed once.');
$this->drupalGet('node/' . $this->testNode->id());
- $this->client->post($stats_path, array('form_params' => $post));
+ $this->client->post($stats_path, ['form_params' => $post]);
$this->assertText('2 views', 'Node is viewed 2 times.');
// Increase the max age to test that nodes are no longer immediately
@@ -93,7 +93,7 @@ class StatisticsAdminTest extends WebTestBase {
$this->drupalGet('node/' . $this->testNode->id());
$this->assertText('3 views', 'Node is viewed 3 times.');
- $this->client->post($stats_path, array('form_params' => $post));
+ $this->client->post($stats_path, ['form_params' => $post]);
$this->drupalGet('node/' . $this->testNode->id());
$this->assertText('3 views', 'Views counter was not updated.');
}
@@ -107,13 +107,13 @@ class StatisticsAdminTest extends WebTestBase {
$this->drupalGet('node/' . $this->testNode->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->testNode->id();
- $post = array('nid' => $nid);
+ $post = ['nid' => $nid];
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
- $this->client->post($stats_path, array('form_params' => $post));
+ $this->client->post($stats_path, ['form_params' => $post]);
$result = db_select('node_counter', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->condition('n.nid', $this->testNode->id())
->execute()
->fetchAssoc();
@@ -122,7 +122,7 @@ class StatisticsAdminTest extends WebTestBase {
$this->testNode->delete();
$result = db_select('node_counter', 'n')
- ->fields('n', array('nid'))
+ ->fields('n', ['nid'])
->condition('n.nid', $this->testNode->id())
->execute()
->fetchAssoc();
@@ -141,12 +141,12 @@ class StatisticsAdminTest extends WebTestBase {
$this->drupalGet('node/' . $this->testNode->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->testNode->id();
- $post = array('nid' => $nid);
+ $post = ['nid' => $nid];
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
- $this->client->post($stats_path, array('form_params' => $post));
+ $this->client->post($stats_path, ['form_params' => $post]);
$this->drupalGet('node/' . $this->testNode->id());
- $this->client->post($stats_path, array('form_params' => $post));
+ $this->client->post($stats_path, ['form_params' => $post]);
$this->assertText('1 view', 'Node is viewed once.');
// statistics_cron() will subtract
@@ -160,7 +160,7 @@ class StatisticsAdminTest extends WebTestBase {
$this->assertNoText('node/' . $this->testNode->id(), 'No hit URL found.');
$result = db_select('node_counter', 'nc')
- ->fields('nc', array('daycount'))
+ ->fields('nc', ['daycount'])
->condition('nid', $this->testNode->id(), '=')
->execute()
->fetchField();
diff --git a/core/modules/statistics/src/Tests/StatisticsLoggingTest.php b/core/modules/statistics/src/Tests/StatisticsLoggingTest.php
index 9aa3cc3f9b6..a7ed5ba0a40 100644
--- a/core/modules/statistics/src/Tests/StatisticsLoggingTest.php
+++ b/core/modules/statistics/src/Tests/StatisticsLoggingTest.php
@@ -19,7 +19,7 @@ class StatisticsLoggingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'statistics', 'block', 'locale');
+ public static $modules = ['node', 'statistics', 'block', 'locale'];
/**
* User with permissions to create and edit pages.
@@ -47,10 +47,10 @@ class StatisticsLoggingTest extends WebTestBase {
// Create Basic page node type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
}
- $this->authUser = $this->drupalCreateUser(array(
+ $this->authUser = $this->drupalCreateUser([
// For node creation.
'access content',
'create page content',
@@ -58,21 +58,21 @@ class StatisticsLoggingTest extends WebTestBase {
// For language negotiation administration.
'administer languages',
'access administration pages',
- ));
+ ]);
// Ensure we have a node page to access.
- $this->node = $this->drupalCreateNode(array('title' => $this->randomMachineName(255), 'uid' => $this->authUser->id()));
+ $this->node = $this->drupalCreateNode(['title' => $this->randomMachineName(255), 'uid' => $this->authUser->id()]);
// Add a custom language and enable path-based language negotiation.
$this->drupalLogin($this->authUser);
- $this->language = array(
+ $this->language = [
'predefined_langcode' => 'custom',
'langcode' => 'xx',
'label' => $this->randomMachineName(16),
'direction' => 'ltr',
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $this->language, t('Add custom language'));
- $this->drupalPostForm('admin/config/regional/language/detection', array('language_interface[enabled][language-url]' => 1), t('Save settings'));
+ $this->drupalPostForm('admin/config/regional/language/detection', ['language_interface[enabled][language-url]' => 1], t('Save settings'));
$this->drupalLogout();
// Enable access logging.
@@ -121,8 +121,8 @@ class StatisticsLoggingTest extends WebTestBase {
// Manually call statistics.php to simulate ajax data collection behavior.
global $base_root;
- $post = array('nid' => $this->node->id());
- $this->client->post($base_root . $stats_path, array('form_params' => $post));
+ $post = ['nid' => $this->node->id()];
+ $this->client->post($base_root . $stats_path, ['form_params' => $post]);
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '1');
}
diff --git a/core/modules/statistics/src/Tests/StatisticsReportsTest.php b/core/modules/statistics/src/Tests/StatisticsReportsTest.php
index 3851207b115..1524623eee2 100644
--- a/core/modules/statistics/src/Tests/StatisticsReportsTest.php
+++ b/core/modules/statistics/src/Tests/StatisticsReportsTest.php
@@ -22,24 +22,24 @@ class StatisticsReportsTest extends StatisticsTestBase {
$this->container->get('plugin.manager.block')->clearCachedDefinitions();
// Visit a node to have something show up in the block.
- $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->blockingUser->id()));
+ $node = $this->drupalCreateNode(['type' => 'page', 'uid' => $this->blockingUser->id()]);
$this->drupalGet('node/' . $node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $node->id();
- $post = http_build_query(array('nid' => $nid));
- $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
+ $post = http_build_query(['nid' => $nid]);
+ $headers = ['Content-Type' => 'application/x-www-form-urlencoded'];
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
$client = \Drupal::httpClient();
- $client->post($stats_path, array('headers' => $headers, 'body' => $post));
+ $client->post($stats_path, ['headers' => $headers, 'body' => $post]);
// Configure and save the block.
- $block = $this->drupalPlaceBlock('statistics_popular_block', array(
+ $block = $this->drupalPlaceBlock('statistics_popular_block', [
'label' => 'Popular content',
'top_day_num' => 3,
'top_all_num' => 3,
'top_last_num' => 3,
- ));
+ ]);
// Get some page and check if the block is displayed.
$this->drupalGet('user');
diff --git a/core/modules/statistics/src/Tests/StatisticsTestBase.php b/core/modules/statistics/src/Tests/StatisticsTestBase.php
index 27fe836528d..4f530cf9cd4 100644
--- a/core/modules/statistics/src/Tests/StatisticsTestBase.php
+++ b/core/modules/statistics/src/Tests/StatisticsTestBase.php
@@ -17,7 +17,7 @@ abstract class StatisticsTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'block', 'ban', 'statistics');
+ public static $modules = ['node', 'block', 'ban', 'statistics'];
/**
* User with permissions to ban IP's.
@@ -31,18 +31,18 @@ abstract class StatisticsTestBase extends WebTestBase {
// Create Basic page node type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
}
// Create user.
- $this->blockingUser = $this->drupalCreateUser(array(
+ $this->blockingUser = $this->drupalCreateUser([
'access administration pages',
'access site reports',
'ban IP addresses',
'administer blocks',
'administer statistics',
'administer users',
- ));
+ ]);
$this->drupalLogin($this->blockingUser);
// Enable logging.
diff --git a/core/modules/statistics/src/Tests/Views/IntegrationTest.php b/core/modules/statistics/src/Tests/Views/IntegrationTest.php
index 601aa6cc38b..18f55815879 100644
--- a/core/modules/statistics/src/Tests/Views/IntegrationTest.php
+++ b/core/modules/statistics/src/Tests/Views/IntegrationTest.php
@@ -19,7 +19,7 @@ class IntegrationTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('statistics', 'statistics_test_views', 'node');
+ public static $modules = ['statistics', 'statistics_test_views', 'node'];
/**
* Stores the user object that accesses the page.
@@ -40,21 +40,21 @@ class IntegrationTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_statistics_integration');
+ public static $testViews = ['test_statistics_integration'];
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('statistics_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['statistics_test_views']);
// Create a new user for viewing nodes and statistics.
- $this->webUser = $this->drupalCreateUser(array('access content', 'view post access counter'));
+ $this->webUser = $this->drupalCreateUser(['access content', 'view post access counter']);
// Create a new user for viewing nodes only.
- $this->deniedUser = $this->drupalCreateUser(array('access content'));
+ $this->deniedUser = $this->drupalCreateUser(['access content']);
- $this->drupalCreateContentType(array('type' => 'page'));
- $this->node = $this->drupalCreateNode(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
+ $this->node = $this->drupalCreateNode(['type' => 'page']);
// Enable counting of content views.
$this->config('statistics.settings')
@@ -75,7 +75,7 @@ class IntegrationTest extends ViewTestBase {
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
$client = \Drupal::httpClient();
- $client->post($stats_path, array('form_params' => array('nid' => $this->node->id())));
+ $client->post($stats_path, ['form_params' => ['nid' => $this->node->id()]]);
$this->drupalGet('test_statistics_integration');
$expected = statistics_get($this->node->id());
diff --git a/core/modules/statistics/statistics.install b/core/modules/statistics/statistics.install
index f232e1d376a..deac9010a4a 100644
--- a/core/modules/statistics/statistics.install
+++ b/core/modules/statistics/statistics.install
@@ -18,42 +18,42 @@ function statistics_uninstall() {
* Implements hook_schema().
*/
function statistics_schema() {
- $schema['node_counter'] = array(
+ $schema['node_counter'] = [
'description' => 'Access statistics for {node}s.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The {node}.nid for these statistics.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'totalcount' => array(
+ ],
+ 'totalcount' => [
'description' => 'The total number of times the {node} has been viewed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
- ),
- 'daycount' => array(
+ ],
+ 'daycount' => [
'description' => 'The total number of times the {node} has been viewed today.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'medium',
- ),
- 'timestamp' => array(
+ ],
+ 'timestamp' => [
'description' => 'The most recent time the {node} has been viewed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('nid'),
- );
+ ],
+ ],
+ 'primary key' => ['nid'],
+ ];
return $schema;
}
@@ -63,7 +63,7 @@ function statistics_schema() {
*/
function statistics_update_8001() {
if (!\Drupal::moduleHandler()->moduleExists('node')) {
- if (\Drupal::service('module_installer')->uninstall(array('statistics'), TRUE)) {
+ if (\Drupal::service('module_installer')->uninstall(['statistics'], TRUE)) {
return 'The statistics module depends on the node module and has therefore been uninstalled.';
}
else {
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 922ed57c37c..a7f1e10601e 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -19,13 +19,13 @@ function statistics_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.statistics':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Statistics module shows you how often content is viewed. This is useful in determining which pages of your site are most popular. For more information, see the <a href=":statistics_do">online documentation for the Statistics module</a>.', array(':statistics_do' => 'https://www.drupal.org/documentation/modules/statistics/')) . '</p>';
+ $output .= '<p>' . t('The Statistics module shows you how often content is viewed. This is useful in determining which pages of your site are most popular. For more information, see the <a href=":statistics_do">online documentation for the Statistics module</a>.', [':statistics_do' => 'https://www.drupal.org/documentation/modules/statistics/']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Displaying popular content') . '</dt>';
- $output .= '<dd>' . t('The module includes a <em>Popular content</em> block that displays the most viewed pages today and for all time, and the last content viewed. To use the block, enable <em>Count content views</em> on the <a href=":statistics-settings">Statistics page</a>, and then you can enable and configure the block on the <a href=":blocks">Block layout page</a>.', array(':statistics-settings' => \Drupal::url('statistics.settings'), ':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
+ $output .= '<dd>' . t('The module includes a <em>Popular content</em> block that displays the most viewed pages today and for all time, and the last content viewed. To use the block, enable <em>Count content views</em> on the <a href=":statistics-settings">Statistics page</a>, and then you can enable and configure the block on the <a href=":blocks">Block layout page</a>.', [':statistics-settings' => \Drupal::url('statistics.settings'), ':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
$output .= '<dt>' . t('Page view counter') . '</dt>';
- $output .= '<dd>' . t('The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, enable <em>Count content views</em> on the <a href=":statistics-settings">Statistics page</a>, and set the necessary <a href=":permissions">permissions</a> (<em>View content hits</em>) so that the counter is visible to the users.', array(':statistics-settings' => \Drupal::url('statistics.settings'), ':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-statistics')))) . '</dd>';
+ $output .= '<dd>' . t('The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, enable <em>Count content views</em> on the <a href=":statistics-settings">Statistics page</a>, and set the necessary <a href=":permissions">permissions</a> (<em>View content hits</em>) so that the counter is visible to the users.', [':statistics-settings' => \Drupal::url('statistics.settings'), ':permissions' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-statistics'])]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -40,7 +40,7 @@ function statistics_help($route_name, RouteMatchInterface $route_match) {
function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
$build['#attached']['library'][] = 'statistics/drupal.statistics';
- $settings = array('data' => array('nid' => $node->id()), 'url' => Url::fromUri('base:' . drupal_get_path('module', 'statistics') . '/statistics.php')->toString());
+ $settings = ['data' => ['nid' => $node->id()], 'url' => Url::fromUri('base:' . drupal_get_path('module', 'statistics') . '/statistics.php')->toString()];
$build['#attached']['drupalSettings']['statistics'] = $settings;
}
}
@@ -55,11 +55,11 @@ function statistics_node_links_alter(array &$links, NodeInterface $entity, array
$statistics = \Drupal::service('statistics.storage.node')->fetchView($entity->id());
if ($statistics) {
$statistics_links['statistics_counter']['title'] = \Drupal::translation()->formatPlural($statistics->getTotalCount(), '1 view', '@count views');
- $links['statistics'] = array(
+ $links['statistics'] = [
'#theme' => 'links__node__statistics',
'#links' => $statistics_links,
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
}
$links['#cache']['max-age'] = \Drupal::config('statistics.settings')->get('display_max_age');
}
@@ -93,15 +93,15 @@ function statistics_cron() {
* be executed correctly.
*/
function statistics_title_list($dbfield, $dbrows) {
- if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) {
+ if (in_array($dbfield, ['totalcount', 'daycount', 'timestamp'])) {
$query = db_select('node_field_data', 'n');
$query->addTag('node_access');
$query->join('node_counter', 's', 'n.nid = s.nid');
$query->join('users_field_data', 'u', 'n.uid = u.uid');
return $query
- ->fields('n', array('nid', 'title'))
- ->fields('u', array('uid', 'name'))
+ ->fields('n', ['nid', 'title'])
+ ->fields('u', ['uid', 'name'])
->condition($dbfield, 0, '<>')
->condition('n.status', 1)
// @todo This should be actually filtering on the desired node status
@@ -147,15 +147,15 @@ function statistics_node_predelete(EntityInterface $node) {
*/
function statistics_ranking() {
if (\Drupal::config('statistics.settings')->get('count_content_views')) {
- return array(
- 'views' => array(
+ return [
+ 'views' => [
'title' => t('Number of views'),
- 'join' => array(
+ 'join' => [
'type' => 'LEFT',
'table' => 'node_counter',
'alias' => 'node_counter',
'on' => 'node_counter.nid = i.sid',
- ),
+ ],
// Inverse law that maps the highest view count on the site to 1 and 0
// to 0. Note that the ROUND here is necessary for PostgreSQL and SQLite
// in order to ensure that the :statistics_scale argument is treated as
@@ -163,9 +163,9 @@ function statistics_ranking() {
// values in as strings instead of numbers in complex expressions like
// this.
'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * (ROUND(:statistics_scale, 4)))',
- 'arguments' => array(':statistics_scale' => \Drupal::state()->get('statistics.node_counter_scale') ?: 0),
- ),
- );
+ 'arguments' => [':statistics_scale' => \Drupal::state()->get('statistics.node_counter_scale') ?: 0],
+ ],
+ ];
}
}
diff --git a/core/modules/statistics/statistics.tokens.inc b/core/modules/statistics/statistics.tokens.inc
index e9d8ded4392..96500b89827 100644
--- a/core/modules/statistics/statistics.tokens.inc
+++ b/core/modules/statistics/statistics.tokens.inc
@@ -11,23 +11,23 @@ use Drupal\Core\Render\BubbleableMetadata;
* Implements hook_token_info().
*/
function statistics_token_info() {
- $node['total-count'] = array(
+ $node['total-count'] = [
'name' => t("Number of views"),
'description' => t("The number of visitors who have read the node."),
- );
- $node['day-count'] = array(
+ ];
+ $node['day-count'] = [
'name' => t("Views today"),
'description' => t("The number of visitors who have read the node today."),
- );
- $node['last-view'] = array(
+ ];
+ $node['last-view'] = [
'name' => t("Last view"),
'description' => t("The date on which a visitor last read the node."),
'type' => 'date',
- );
+ ];
- return array(
- 'tokens' => array('node' => $node),
- );
+ return [
+ 'tokens' => ['node' => $node],
+ ];
}
/**
@@ -36,7 +36,7 @@ function statistics_token_info() {
function statistics_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $replacements = array();
+ $replacements = [];
if ($type == 'node' & !empty($data['node'])) {
$node = $data['node'];
@@ -58,7 +58,7 @@ function statistics_tokens($type, $tokens, array $data, array $options, Bubbleab
if ($created_tokens = $token_service->findWithPrefix($tokens, 'last-view')) {
$statistics = statistics_get($node->id());
- $replacements += $token_service->generate('date', $created_tokens, array('date' => $statistics['timestamp']), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $created_tokens, ['date' => $statistics['timestamp']], $options, $bubbleable_metadata);
}
}
diff --git a/core/modules/statistics/statistics.views.inc b/core/modules/statistics/statistics.views.inc
index e8512518819..03e73ffcfa5 100644
--- a/core/modules/statistics/statistics.views.inc
+++ b/core/modules/statistics/statistics.views.inc
@@ -11,66 +11,66 @@
function statistics_views_data() {
$data['node_counter']['table']['group'] = t('Content statistics');
- $data['node_counter']['table']['join'] = array(
- 'node_field_data' => array(
+ $data['node_counter']['table']['join'] = [
+ 'node_field_data' => [
'left_field' => 'nid',
'field' => 'nid',
- ),
- );
+ ],
+ ];
- $data['node_counter']['totalcount'] = array(
+ $data['node_counter']['totalcount'] = [
'title' => t('Total views'),
'help' => t('The total number of times the node has been viewed.'),
- 'field' => array(
+ 'field' => [
'id' => 'statistics_numeric',
'click sortable' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['node_counter']['daycount'] = array(
+ $data['node_counter']['daycount'] = [
'title' => t('Views today'),
'help' => t('The total number of times the node has been viewed today.'),
- 'field' => array(
+ 'field' => [
'id' => 'statistics_numeric',
'click sortable' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
- $data['node_counter']['timestamp'] = array(
+ $data['node_counter']['timestamp'] = [
'title' => t('Most recent view'),
'help' => t('The most recent time the node has been viewed.'),
- 'field' => array(
+ 'field' => [
'id' => 'node_counter_timestamp',
'click sortable' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'date',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php b/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
index 9ea6e942aa4..787c35bff2a 100644
--- a/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
+++ b/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
@@ -17,7 +17,7 @@ class StatisticsAttachedTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'statistics');
+ public static $modules = ['node', 'statistics'];
/**
* {@inheritdoc}
@@ -29,7 +29,7 @@ class StatisticsAttachedTest extends BrowserTestBase {
// Install "statistics_test_attached" and set it as the default theme.
$theme = 'statistics_test_attached';
- \Drupal::service('theme_handler')->install(array($theme));
+ \Drupal::service('theme_handler')->install([$theme]);
$this->config('system.theme')
->set('default', $theme)
->save();
diff --git a/core/modules/statistics/tests/src/Functional/StatisticsTestBase.php b/core/modules/statistics/tests/src/Functional/StatisticsTestBase.php
index 97d90820c25..3be95e2ab6e 100644
--- a/core/modules/statistics/tests/src/Functional/StatisticsTestBase.php
+++ b/core/modules/statistics/tests/src/Functional/StatisticsTestBase.php
@@ -14,7 +14,7 @@ abstract class StatisticsTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'block', 'ban', 'statistics');
+ public static $modules = ['node', 'block', 'ban', 'statistics'];
/**
* User with permissions to ban IP's.
@@ -28,18 +28,18 @@ abstract class StatisticsTestBase extends BrowserTestBase {
// Create Basic page node type.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
}
// Create user.
- $this->blockingUser = $this->drupalCreateUser(array(
+ $this->blockingUser = $this->drupalCreateUser([
'access administration pages',
'access site reports',
'ban IP addresses',
'administer blocks',
'administer statistics',
'administer users',
- ));
+ ]);
$this->drupalLogin($this->blockingUser);
// Enable logging.
diff --git a/core/modules/statistics/tests/src/Functional/StatisticsTokenReplaceTest.php b/core/modules/statistics/tests/src/Functional/StatisticsTokenReplaceTest.php
index cc36e470cb2..8cf95adb4f7 100644
--- a/core/modules/statistics/tests/src/Functional/StatisticsTokenReplaceTest.php
+++ b/core/modules/statistics/tests/src/Functional/StatisticsTokenReplaceTest.php
@@ -16,24 +16,24 @@ class StatisticsTokenReplaceTest extends StatisticsTestBase {
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
// Create user and node.
- $user = $this->drupalCreateUser(array('create page content'));
+ $user = $this->drupalCreateUser(['create page content']);
$this->drupalLogin($user);
- $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $user->id()));
+ $node = $this->drupalCreateNode(['type' => 'page', 'uid' => $user->id()]);
// Hit the node.
$this->drupalGet('node/' . $node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $node->id();
- $post = http_build_query(array('nid' => $nid));
- $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
+ $post = http_build_query(['nid' => $nid]);
+ $headers = ['Content-Type' => 'application/x-www-form-urlencoded'];
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
$client = \Drupal::httpClient();
- $client->post($stats_path, array('headers' => $headers, 'body' => $post));
+ $client->post($stats_path, ['headers' => $headers, 'body' => $post]);
$statistics = statistics_get($node->id());
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$tests['[node:total-count]'] = 1;
$tests['[node:day-count]'] = 1;
$tests['[node:last-view]'] = format_date($statistics['timestamp']);
@@ -43,8 +43,8 @@ class StatisticsTokenReplaceTest extends StatisticsTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
- $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->getId()));
- $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input)));
+ $output = \Drupal::token()->replace($input, ['node' => $node], ['langcode' => $language_interface->getId()]);
+ $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', ['%token' => $input]));
}
}
diff --git a/core/modules/statistics/tests/src/Kernel/Migrate/d6/MigrateStatisticsConfigsTest.php b/core/modules/statistics/tests/src/Kernel/Migrate/d6/MigrateStatisticsConfigsTest.php
index 6bd53948a09..da6ab300e73 100644
--- a/core/modules/statistics/tests/src/Kernel/Migrate/d6/MigrateStatisticsConfigsTest.php
+++ b/core/modules/statistics/tests/src/Kernel/Migrate/d6/MigrateStatisticsConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateStatisticsConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('statistics');
+ public static $modules = ['statistics'];
/**
* {@inheritdoc}
diff --git a/core/modules/statistics/tests/src/Kernel/Migrate/d7/MigrateStatisticsConfigsTest.php b/core/modules/statistics/tests/src/Kernel/Migrate/d7/MigrateStatisticsConfigsTest.php
index e5f915b1448..36e270d8f66 100644
--- a/core/modules/statistics/tests/src/Kernel/Migrate/d7/MigrateStatisticsConfigsTest.php
+++ b/core/modules/statistics/tests/src/Kernel/Migrate/d7/MigrateStatisticsConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateStatisticsConfigsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('statistics');
+ public static $modules = ['statistics'];
/**
* {@inheritdoc}
diff --git a/core/modules/syslog/src/Logger/SysLog.php b/core/modules/syslog/src/Logger/SysLog.php
index 002ecde5e89..c2b73dee3d0 100644
--- a/core/modules/syslog/src/Logger/SysLog.php
+++ b/core/modules/syslog/src/Logger/SysLog.php
@@ -63,7 +63,7 @@ class SysLog implements LoggerInterface {
/**
* {@inheritdoc}
*/
- public function log($level, $message, array $context = array()) {
+ public function log($level, $message, array $context = []) {
global $base_url;
// Ensure we have a connection available.
@@ -73,7 +73,7 @@ class SysLog implements LoggerInterface {
$message_placeholders = $this->parser->parseMessagePlaceholders($message, $context);
$message = empty($message_placeholders) ? $message : strtr($message, $message_placeholders);
- $entry = strtr($this->config->get('format'), array(
+ $entry = strtr($this->config->get('format'), [
'!base_url' => $base_url,
'!timestamp' => $context['timestamp'],
'!type' => $context['channel'],
@@ -83,7 +83,7 @@ class SysLog implements LoggerInterface {
'!uid' => $context['uid'],
'!link' => strip_tags($context['link']),
'!message' => strip_tags($message),
- ));
+ ]);
syslog($level, $entry);
}
diff --git a/core/modules/syslog/src/Tests/SyslogTest.php b/core/modules/syslog/src/Tests/SyslogTest.php
index a40847c2aeb..f4ab7080eee 100644
--- a/core/modules/syslog/src/Tests/SyslogTest.php
+++ b/core/modules/syslog/src/Tests/SyslogTest.php
@@ -16,23 +16,23 @@ class SyslogTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('syslog');
+ public static $modules = ['syslog'];
/**
* Tests the syslog settings page.
*/
function testSettings() {
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
// If we're on Windows, there is no configuration form.
if (defined('LOG_LOCAL6')) {
- $this->drupalPostForm('admin/config/development/logging', array('syslog_facility' => LOG_LOCAL6), t('Save configuration'));
+ $this->drupalPostForm('admin/config/development/logging', ['syslog_facility' => LOG_LOCAL6], t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->drupalGet('admin/config/development/logging');
if ($this->parse()) {
- $field = $this->xpath('//option[@value=:value]', array(':value' => LOG_LOCAL6)); // Should be one field.
+ $field = $this->xpath('//option[@value=:value]', [':value' => LOG_LOCAL6]); // Should be one field.
$this->assertTrue($field[0]['selected'] == 'selected', 'Facility value saved.');
}
}
diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module
index 68fe6145262..2722702d8b2 100644
--- a/core/modules/syslog/syslog.module
+++ b/core/modules/syslog/syslog.module
@@ -17,7 +17,7 @@ function syslog_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.syslog':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Syslog module logs events by sending messages to the logging facility of your web server\'s operating system. Syslog is an operating system administrative logging tool that provides valuable information for use in system management and security auditing. Most suited to medium and large sites, Syslog provides filtering tools that allow messages to be routed by type and severity. For more information, see the <a href=":syslog">online documentation for the Syslog module</a>, as well as PHP\'s documentation pages for the <a href="http://php.net/manual/function.openlog.php">openlog</a> and <a href="http://php.net/manual/function.syslog.php">syslog</a> functions.', array(':syslog' => 'https://www.drupal.org/documentation/modules/syslog')) . '</p>';
+ $output .= '<p>' . t('The Syslog module logs events by sending messages to the logging facility of your web server\'s operating system. Syslog is an operating system administrative logging tool that provides valuable information for use in system management and security auditing. Most suited to medium and large sites, Syslog provides filtering tools that allow messages to be routed by type and severity. For more information, see the <a href=":syslog">online documentation for the Syslog module</a>, as well as PHP\'s documentation pages for the <a href="http://php.net/manual/function.openlog.php">openlog</a> and <a href="http://php.net/manual/function.syslog.php">syslog</a> functions.', [':syslog' => 'https://www.drupal.org/documentation/modules/syslog']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Logging for UNIX, Linux, and Mac OS X') . '</dt>';
@@ -35,27 +35,27 @@ function syslog_help($route_name, RouteMatchInterface $route_match) {
function syslog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) {
$config = \Drupal::configFactory()->getEditable('syslog.settings');
$help = \Drupal::moduleHandler()->moduleExists('help') ? ' ' . \Drupal::l(t('More information'), new Url('help.page', ['name' => 'syslog'])) . '.' : NULL;
- $form['syslog_identity'] = array(
+ $form['syslog_identity'] = [
'#type' => 'textfield',
'#title' => t('Syslog identity'),
'#default_value' => $config->get('identity'),
'#description' => t('A string that will be prepended to every message logged to Syslog. If you have multiple sites logging to the same Syslog log file, a unique identity per site makes it easy to tell the log entries apart.') . $help,
- );
+ ];
if (defined('LOG_LOCAL0')) {
- $form['syslog_facility'] = array(
+ $form['syslog_facility'] = [
'#type' => 'select',
'#title' => t('Syslog facility'),
'#default_value' => $config->get('facility'),
'#options' => syslog_facility_list(),
'#description' => t('Depending on the system configuration, Syslog and other logging tools use this code to identify or filter messages from within the entire system log.') . $help,
- );
+ ];
}
- $form['syslog_format'] = array(
+ $form['syslog_format'] = [
'#type' => 'textarea',
'#title' => t('Syslog format'),
'#default_value' => $config->get('format'),
'#description' => t('Specify the format of the syslog entry. Available variables are: <dl><dt><code>!base_url</code></dt><dd>Base URL of the site.</dd><dt><code>!timestamp</code></dt><dd>Unix timestamp of the log entry.</dd><dt><code>!type</code></dt><dd>The category to which this message belongs.</dd><dt><code>!ip</code></dt><dd>IP address of the user triggering the message.</dd><dt><code>!request_uri</code></dt><dd>The requested URI.</dd><dt><code>!referer</code></dt><dd>HTTP Referer if available.</dd><dt><code>!uid</code></dt><dd>User ID.</dd><dt><code>!link</code></dt><dd>A link to associate with the message.</dd><dt><code>!message</code></dt><dd>The message to store in the log.</dd></dl>'),
- );
+ ];
$form['#submit'][] = 'syslog_logging_settings_submit';
}
@@ -80,7 +80,7 @@ function syslog_logging_settings_submit($form, FormStateInterface $form_state) {
* An array of syslog facilities for UNIX/Linux.
*/
function syslog_facility_list() {
- return array(
+ return [
LOG_LOCAL0 => 'LOG_LOCAL0',
LOG_LOCAL1 => 'LOG_LOCAL1',
LOG_LOCAL2 => 'LOG_LOCAL2',
@@ -89,5 +89,5 @@ function syslog_facility_list() {
LOG_LOCAL5 => 'LOG_LOCAL5',
LOG_LOCAL6 => 'LOG_LOCAL6',
LOG_LOCAL7 => 'LOG_LOCAL7',
- );
+ ];
}
diff --git a/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php b/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php
index 39a71a30c83..aa66203113d 100644
--- a/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php
+++ b/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateSyslogConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('syslog');
+ public static $modules = ['syslog'];
/**
* {@inheritdoc}
diff --git a/core/modules/system/src/Controller/AdminController.php b/core/modules/system/src/Controller/AdminController.php
index 57c13f653d4..3da4b0901dc 100644
--- a/core/modules/system/src/Controller/AdminController.php
+++ b/core/modules/system/src/Controller/AdminController.php
@@ -23,13 +23,13 @@ class AdminController extends ControllerBase {
}
uasort($module_info, 'system_sort_modules_by_info_name');
- $menu_items = array();
+ $menu_items = [];
foreach ($module_info as $module => $info) {
// Only display a section if there are any available tasks.
if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) {
// Sort links by title.
- uasort($admin_tasks, array('\Drupal\Component\Utility\SortArray', 'sortByTitleElement'));
+ uasort($admin_tasks, ['\Drupal\Component\Utility\SortArray', 'sortByTitleElement']);
// Move 'Configure permissions' links to the bottom of each section.
$permission_key = "user.admin_permissions.$module";
if (isset($admin_tasks[$permission_key])) {
@@ -38,14 +38,14 @@ class AdminController extends ControllerBase {
$admin_tasks[$permission_key] = $permission_task;
}
- $menu_items[$info->info['name']] = array($info->info['description'], $admin_tasks);
+ $menu_items[$info->info['name']] = [$info->info['description'], $admin_tasks];
}
}
- $output = array(
+ $output = [
'#theme' => 'system_admin_index',
'#menu_items' => $menu_items,
- );
+ ];
return $output;
}
diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php
index fdedcc652e8..9e0a374a4a8 100644
--- a/core/modules/system/src/Controller/DbUpdateController.php
+++ b/core/modules/system/src/Controller/DbUpdateController.php
@@ -150,7 +150,7 @@ class DbUpdateController extends ControllerBase {
$_SESSION['update_ignore_warnings'] = TRUE;
}
- $regions = array();
+ $regions = [];
$requirements = update_check_requirements();
$severity = drupal_requirements_severity($requirements);
if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($_SESSION['update_ignore_warnings']))) {
@@ -212,32 +212,32 @@ class DbUpdateController extends ControllerBase {
$this->keyValueExpirableFactory->get('update')->deleteAll();
$this->keyValueExpirableFactory->get('update_available_release')->deleteAll();
- $build['info_header'] = array(
+ $build['info_header'] = [
'#markup' => '<p>' . $this->t('Use this utility to update your database whenever a new release of Drupal or a module is installed.') . '</p><p>' . $this->t('For more detailed information, see the <a href="https://www.drupal.org/upgrade">upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.') . '</p>',
- );
+ ];
$info[] = $this->t("<strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.");
- $info[] = $this->t('Put your site into <a href=":url">maintenance mode</a>.', array(
+ $info[] = $this->t('Put your site into <a href=":url">maintenance mode</a>.', [
':url' => Url::fromRoute('system.site_maintenance_mode')->toString(TRUE)->getGeneratedUrl(),
- ));
+ ]);
$info[] = $this->t('<strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.');
$info[] = $this->t('Install your new files in the appropriate location, as described in the handbook.');
- $build['info'] = array(
+ $build['info'] = [
'#theme' => 'item_list',
'#list_type' => 'ol',
'#items' => $info,
- );
- $build['info_footer'] = array(
+ ];
+ $build['info_footer'] = [
'#markup' => '<p>' . $this->t('When you have performed the steps above, you may proceed.') . '</p>',
- );
+ ];
- $build['link'] = array(
+ $build['link'] = [
'#type' => 'link',
'#title' => $this->t('Continue'),
- '#attributes' => array('class' => array('button', 'button--primary')),
+ '#attributes' => ['class' => ['button', 'button--primary']],
// @todo Revisit once https://www.drupal.org/node/2548095 is in.
'#url' => Url::fromUri('base://selection'),
- );
+ ];
return $build;
}
@@ -256,15 +256,15 @@ class DbUpdateController extends ControllerBase {
$count = 0;
$incompatible_count = 0;
- $build['start'] = array(
+ $build['start'] = [
'#tree' => TRUE,
'#type' => 'details',
- );
+ ];
// Ensure system.module's updates appear first.
- $build['start']['system'] = array();
+ $build['start']['system'] = [];
- $starting_updates = array();
+ $starting_updates = [];
$incompatible_updates_exist = FALSE;
$updates_per_module = [];
foreach (['update', 'post_update'] as $update_type) {
@@ -278,30 +278,30 @@ class DbUpdateController extends ControllerBase {
}
foreach ($updates as $module => $update) {
if (!isset($update['start'])) {
- $build['start'][$module] = array(
+ $build['start'][$module] = [
'#type' => 'item',
'#title' => $module . ' module',
'#markup' => $update['warning'],
'#prefix' => '<div class="messages messages--warning">',
'#suffix' => '</div>',
- );
+ ];
$incompatible_updates_exist = TRUE;
continue;
}
if (!empty($update['pending'])) {
$updates_per_module += [$module => []];
$updates_per_module[$module] = array_merge($updates_per_module[$module], $update['pending']);
- $build['start'][$module] = array(
+ $build['start'][$module] = [
'#type' => 'hidden',
'#value' => $update['start'],
- );
+ ];
// Store the previous items in order to merge normal updates and
// post_update functions together.
- $build['start'][$module] = array(
+ $build['start'][$module] = [
'#theme' => 'item_list',
'#items' => $updates_per_module[$module],
'#title' => $module . ' module',
- );
+ ];
if ($update_type === 'update') {
$starting_updates[$module] = $update['start'];
@@ -329,7 +329,7 @@ class DbUpdateController extends ControllerBase {
$build['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>';
}
// Move the module containing this update to the top of the list.
- $build['start'] = array($module_update_key => $build['start'][$module_update_key]) + $build['start'];
+ $build['start'] = [$module_update_key => $build['start'][$module_update_key]] + $build['start'];
}
}
@@ -341,25 +341,25 @@ class DbUpdateController extends ControllerBase {
if (empty($count)) {
drupal_set_message($this->t('No pending updates.'));
unset($build);
- $build['links'] = array(
+ $build['links'] = [
'#theme' => 'links',
'#links' => $this->helpfulLinks($request),
- );
+ ];
// No updates to run, so caches won't get flushed later. Clear them now.
drupal_flush_all_caches();
}
else {
- $build['help'] = array(
+ $build['help'] = [
'#markup' => '<p>' . $this->t('The version of Drupal you are updating from has been automatically detected.') . '</p>',
'#weight' => -5,
- );
+ ];
if ($incompatible_count) {
$build['start']['#title'] = $this->formatPlural(
$count,
'1 pending update (@number_applied to be applied, @number_incompatible skipped)',
'@count pending updates (@number_applied to be applied, @number_incompatible skipped)',
- array('@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count)
+ ['@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count]
);
}
else {
@@ -367,15 +367,15 @@ class DbUpdateController extends ControllerBase {
}
// @todo Simplify with https://www.drupal.org/node/2548095
$base_url = str_replace('/update.php', '', $request->getBaseUrl());
- $url = (new Url('system.db_update', array('op' => 'run')))->setOption('base_url', $base_url);
- $build['link'] = array(
+ $url = (new Url('system.db_update', ['op' => 'run']))->setOption('base_url', $base_url);
+ $build['link'] = [
'#type' => 'link',
'#title' => $this->t('Apply pending updates'),
- '#attributes' => array('class' => array('button', 'button--primary')),
+ '#attributes' => ['class' => ['button', 'button--primary']],
'#weight' => 5,
'#url' => $url,
'#access' => $url->access($this->currentUser()),
- );
+ ];
}
return $build;
@@ -397,24 +397,24 @@ class DbUpdateController extends ControllerBase {
// Report end result.
$dblog_exists = $this->moduleHandler->moduleExists('dblog');
if ($dblog_exists && $this->account->hasPermission('access site reports')) {
- $log_message = $this->t('All errors have been <a href=":url">logged</a>.', array(
+ $log_message = $this->t('All errors have been <a href=":url">logged</a>.', [
':url' => Url::fromRoute('dblog.overview')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl(),
- ));
+ ]);
}
else {
$log_message = $this->t('All errors have been logged.');
}
if (!empty($_SESSION['update_success'])) {
- $message = '<p>' . $this->t('Updates were attempted. If you see no failures below, you may proceed happily back to your <a href=":url">site</a>. Otherwise, you may need to update your database manually.', array(':url' => Url::fromRoute('<front>')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl())) . ' ' . $log_message . '</p>';
+ $message = '<p>' . $this->t('Updates were attempted. If you see no failures below, you may proceed happily back to your <a href=":url">site</a>. Otherwise, you may need to update your database manually.', [':url' => Url::fromRoute('<front>')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl()]) . ' ' . $log_message . '</p>';
}
else {
$last = reset($_SESSION['updates_remaining']);
list($module, $version) = array_pop($last);
- $message = '<p class="error">' . $this->t('The update process was aborted prematurely while running <strong>update #@version in @module.module</strong>.', array(
+ $message = '<p class="error">' . $this->t('The update process was aborted prematurely while running <strong>update #@version in @module.module</strong>.', [
'@version' => $version,
'@module' => $module,
- )) . ' ' . $log_message;
+ ]) . ' ' . $log_message;
if ($dblog_exists) {
$message .= ' ' . $this->t('You may need to check the <code>watchdog</code> database table manually.');
}
@@ -425,23 +425,23 @@ class DbUpdateController extends ControllerBase {
$message .= '<p>' . $this->t("<strong>Reminder: don't forget to set the <code>\$settings['update_free_access']</code> value in your <code>settings.php</code> file back to <code>FALSE</code>.</strong>") . '</p>';
}
- $build['message'] = array(
+ $build['message'] = [
'#markup' => $message,
- );
- $build['links'] = array(
+ ];
+ $build['links'] = [
'#theme' => 'links',
'#links' => $this->helpfulLinks($request),
- );
+ ];
// Output a list of info messages.
if (!empty($_SESSION['update_results'])) {
- $all_messages = array();
+ $all_messages = [];
foreach ($_SESSION['update_results'] as $module => $updates) {
if ($module != '#abort') {
$module_has_message = FALSE;
- $info_messages = array();
+ $info_messages = [];
foreach ($updates as $name => $queries) {
- $messages = array();
+ $messages = [];
foreach ($queries as $query) {
// If there is no message for this update, don't show anything.
if (empty($query['query'])) {
@@ -449,16 +449,16 @@ class DbUpdateController extends ControllerBase {
}
if ($query['success']) {
- $messages[] = array(
- '#wrapper_attributes' => array('class' => array('success')),
+ $messages[] = [
+ '#wrapper_attributes' => ['class' => ['success']],
'#markup' => $query['query'],
- );
+ ];
}
else {
- $messages[] = array(
- '#wrapper_attributes' => array('class' => array('failure')),
+ $messages[] = [
+ '#wrapper_attributes' => ['class' => ['failure']],
'#markup' => '<strong>' . $this->t('Failed:') . '</strong> ' . $query['query'],
- );
+ ];
}
}
@@ -470,32 +470,32 @@ class DbUpdateController extends ControllerBase {
else {
$title = $this->t('Update @name', ['@name' => trim($name, '_')]);
}
- $info_messages[] = array(
+ $info_messages[] = [
'#theme' => 'item_list',
'#items' => $messages,
'#title' => $title,
- );
+ ];
}
}
// If there were any messages then prefix them with the module name
// and add it to the global message list.
if ($module_has_message) {
- $all_messages[] = array(
+ $all_messages[] = [
'#type' => 'container',
- '#prefix' => '<h3>' . $this->t('@module module', array('@module' => $module)) . '</h3>',
+ '#prefix' => '<h3>' . $this->t('@module module', ['@module' => $module]) . '</h3>',
'#children' => $info_messages,
- );
+ ];
}
}
}
if ($all_messages) {
- $build['query_messages'] = array(
+ $build['query_messages'] = [
'#type' => 'container',
'#children' => $all_messages,
- '#attributes' => array('class' => array('update-results')),
+ '#attributes' => ['class' => ['update-results']],
'#prefix' => '<h2>' . $this->t('The following updates returned messages:') . '</h2>',
- );
+ ];
}
}
unset($_SESSION['update_results']);
@@ -515,17 +515,17 @@ class DbUpdateController extends ControllerBase {
* A render array.
*/
public function requirements($severity, array $requirements, Request $request) {
- $options = $severity == REQUIREMENT_WARNING ? array('continue' => 1) : array();
+ $options = $severity == REQUIREMENT_WARNING ? ['continue' => 1] : [];
// @todo Revisit once https://www.drupal.org/node/2548095 is in. Something
// like Url::fromRoute('system.db_update')->setOptions() should then be
// possible.
$try_again_url = Url::fromUri($request->getUriForPath(''))->setOptions(['query' => $options])->toString(TRUE)->getGeneratedUrl();
- $build['status_report'] = array(
+ $build['status_report'] = [
'#type' => 'status_report',
'#requirements' => $requirements,
- '#suffix' => $this->t('Check the messages and <a href=":url">try again</a>.', array(':url' => $try_again_url))
- );
+ '#suffix' => $this->t('Check the messages and <a href=":url">try again</a>.', [':url' => $try_again_url])
+ ];
$build['#title'] = $this->t('Requirements problem');
return $build;
@@ -543,19 +543,19 @@ class DbUpdateController extends ControllerBase {
*/
protected function updateTasksList($active = NULL) {
// Default list of tasks.
- $tasks = array(
+ $tasks = [
'requirements' => $this->t('Verify requirements'),
'info' => $this->t('Overview'),
'selection' => $this->t('Review updates'),
'run' => $this->t('Run updates'),
'results' => $this->t('Review log'),
- );
+ ];
- $task_list = array(
+ $task_list = [
'#theme' => 'maintenance_task_list',
'#items' => $tasks,
'#active' => $active,
- );
+ ];
return $task_list;
}
@@ -576,7 +576,7 @@ class DbUpdateController extends ControllerBase {
$this->state->set('system.maintenance_mode', TRUE);
}
- $operations = array();
+ $operations = [];
// Resolve any update dependencies to determine the actual updates that will
// be run and the order they will be run in.
@@ -587,9 +587,9 @@ class DbUpdateController extends ControllerBase {
// batch API can pass in to the batch operation each time it is called. (We
// do not store the entire update dependency array here because it is
// potentially very large.)
- $dependency_map = array();
+ $dependency_map = [];
foreach ($updates as $function => $update) {
- $dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
+ $dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : [];
}
// Determine updates to be performed.
@@ -602,7 +602,7 @@ class DbUpdateController extends ControllerBase {
drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
unset($start[$update['module']]);
}
- $operations[] = array('update_do_one', array($update['module'], $update['number'], $dependency_map[$function]));
+ $operations[] = ['update_do_one', [$update['module'], $update['number'], $dependency_map[$function]]];
}
}
@@ -618,12 +618,12 @@ class DbUpdateController extends ControllerBase {
}
$batch['operations'] = $operations;
- $batch += array(
+ $batch += [
'title' => $this->t('Updating'),
'init_message' => $this->t('Starting updates'),
'error_message' => $this->t('An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.'),
- 'finished' => array('\Drupal\system\Controller\DbUpdateController', 'batchFinished'),
- );
+ 'finished' => ['\Drupal\system\Controller\DbUpdateController', 'batchFinished'],
+ ];
batch_set($batch);
// @todo Revisit once https://www.drupal.org/node/2548095 is in.
@@ -673,15 +673,15 @@ class DbUpdateController extends ControllerBase {
protected function helpfulLinks(Request $request) {
// @todo Simplify with https://www.drupal.org/node/2548095
$base_url = str_replace('/update.php', '', $request->getBaseUrl());
- $links['front'] = array(
+ $links['front'] = [
'title' => $this->t('Front page'),
'url' => Url::fromRoute('<front>')->setOption('base_url', $base_url),
- );
+ ];
if ($this->account->hasPermission('access administration pages')) {
- $links['admin-pages'] = array(
+ $links['admin-pages'] = [
'title' => $this->t('Administration pages'),
'url' => Url::fromRoute('system.admin')->setOption('base_url', $base_url),
- );
+ ];
}
return $links;
}
@@ -693,7 +693,7 @@ class DbUpdateController extends ControllerBase {
* The module updates that can be performed.
*/
protected function getModuleUpdates() {
- $return = array();
+ $return = [];
$updates = update_get_update_list();
foreach ($updates as $module => $update) {
$return[$module] = $update['start'];
diff --git a/core/modules/system/src/Controller/EntityAutocompleteController.php b/core/modules/system/src/Controller/EntityAutocompleteController.php
index 53ec818f300..974c2ded337 100644
--- a/core/modules/system/src/Controller/EntityAutocompleteController.php
+++ b/core/modules/system/src/Controller/EntityAutocompleteController.php
@@ -77,7 +77,7 @@ class EntityAutocompleteController extends ControllerBase {
* or if it does not match the stored data.
*/
public function handleAutocomplete(Request $request, $target_type, $selection_handler, $selection_settings_key) {
- $matches = array();
+ $matches = [];
// Get the typed string from the URL, if it exists.
if ($input = $request->query->get('q')) {
$typed_string = Tags::explode($input);
diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php
index f25e8322171..4af1dcb856f 100644
--- a/core/modules/system/src/Controller/SystemController.php
+++ b/core/modules/system/src/Controller/SystemController.php
@@ -100,19 +100,19 @@ class SystemController extends ControllerBase {
public function overview($link_id) {
// Check for status report errors.
if ($this->systemManager->checkRequirements() && $this->currentUser()->hasPermission('administer site configuration')) {
- drupal_set_message($this->t('One or more problems were detected with your Drupal installation. Check the <a href=":status">status report</a> for more information.', array(':status' => $this->url('system.status'))), 'error');
+ drupal_set_message($this->t('One or more problems were detected with your Drupal installation. Check the <a href=":status">status report</a> for more information.', [':status' => $this->url('system.status')]), 'error');
}
// Load all menu links below it.
$parameters = new MenuTreeParameters();
$parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
$tree = $this->menuLinkTree->load(NULL, $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ];
$tree = $this->menuLinkTree->transform($tree, $manipulators);
$tree_access_cacheability = new CacheableMetadata();
- $blocks = array();
+ $blocks = [];
foreach ($tree as $key => $element) {
$tree_access_cacheability = $tree_access_cacheability->merge(CacheableMetadata::createFromObject($element->access));
@@ -124,10 +124,10 @@ class SystemController extends ControllerBase {
$link = $element->link;
$block['title'] = $link->getTitle();
$block['description'] = $link->getDescription();
- $block['content'] = array(
+ $block['content'] = [
'#theme' => 'admin_block_content',
'#content' => $this->systemManager->getAdminBlock($link),
- );
+ ];
if (!empty($block['content']['#content'])) {
$blocks[$key] = $block;
@@ -161,7 +161,7 @@ class SystemController extends ControllerBase {
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function compactPage($mode) {
- user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
+ user_cookie_save(['admin_compact_mode' => ($mode == 'on')]);
return $this->redirect('<front>');
}
@@ -187,9 +187,9 @@ class SystemController extends ControllerBase {
uasort($themes, 'system_sort_modules_by_info_name');
$theme_default = $config->get('default');
- $theme_groups = array('installed' => array(), 'uninstalled' => array());
+ $theme_groups = ['installed' => [], 'uninstalled' => []];
$admin_theme = $config->get('admin');
- $admin_theme_options = array();
+ $admin_theme_options = [];
foreach ($themes as &$theme) {
if (!empty($theme->info['hidden'])) {
@@ -206,17 +206,17 @@ class SystemController extends ControllerBase {
$theme_keys[] = $theme->getName();
}
else {
- $theme_keys = array($theme->getName());
+ $theme_keys = [$theme->getName()];
}
// Look for a screenshot in the current theme or in its closest ancestor.
foreach (array_reverse($theme_keys) as $theme_key) {
if (isset($themes[$theme_key]) && file_exists($themes[$theme_key]->info['screenshot'])) {
- $theme->screenshot = array(
+ $theme->screenshot = [
'uri' => $themes[$theme_key]->info['screenshot'],
- 'alt' => $this->t('Screenshot for @theme theme', array('@theme' => $theme->info['name'])),
- 'title' => $this->t('Screenshot for @theme theme', array('@theme' => $theme->info['name'])),
- 'attributes' => array('class' => array('screenshot')),
- );
+ 'alt' => $this->t('Screenshot for @theme theme', ['@theme' => $theme->info['name']]),
+ 'title' => $this->t('Screenshot for @theme theme', ['@theme' => $theme->info['name']]),
+ 'attributes' => ['class' => ['screenshot']],
+ ];
break;
}
}
@@ -233,16 +233,16 @@ class SystemController extends ControllerBase {
// Confirm that the theme engine is available.
$theme->incompatible_engine = isset($theme->info['engine']) && !isset($theme->owner);
}
- $theme->operations = array();
+ $theme->operations = [];
if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) {
// Create the operations links.
$query['theme'] = $theme->getName();
if ($this->themeAccess->checkAccess($theme->getName())) {
- $theme->operations[] = array(
+ $theme->operations[] = [
'title' => $this->t('Settings'),
'url' => Url::fromRoute('system.theme_settings_theme', ['theme' => $theme->getName()]),
- 'attributes' => array('title' => $this->t('Settings for @theme theme', array('@theme' => $theme->info['name']))),
- );
+ 'attributes' => ['title' => $this->t('Settings for @theme theme', ['@theme' => $theme->info['name']])],
+ ];
}
if (!empty($theme->status)) {
if (!$theme->is_default) {
@@ -257,40 +257,40 @@ class SystemController extends ControllerBase {
}
}
if ($theme_uninstallable) {
- $theme->operations[] = array(
+ $theme->operations[] = [
'title' => $this->t('Uninstall'),
'url' => Url::fromRoute('system.theme_uninstall'),
'query' => $query,
- 'attributes' => array('title' => $this->t('Uninstall @theme theme', array('@theme' => $theme->info['name']))),
- );
+ 'attributes' => ['title' => $this->t('Uninstall @theme theme', ['@theme' => $theme->info['name']])],
+ ];
}
- $theme->operations[] = array(
+ $theme->operations[] = [
'title' => $this->t('Set as default'),
'url' => Url::fromRoute('system.theme_set_default'),
'query' => $query,
- 'attributes' => array('title' => $this->t('Set @theme as default theme', array('@theme' => $theme->info['name']))),
- );
+ 'attributes' => ['title' => $this->t('Set @theme as default theme', ['@theme' => $theme->info['name']])],
+ ];
}
$admin_theme_options[$theme->getName()] = $theme->info['name'];
}
else {
- $theme->operations[] = array(
+ $theme->operations[] = [
'title' => $this->t('Install'),
'url' => Url::fromRoute('system.theme_install'),
'query' => $query,
- 'attributes' => array('title' => $this->t('Install @theme theme', array('@theme' => $theme->info['name']))),
- );
- $theme->operations[] = array(
+ 'attributes' => ['title' => $this->t('Install @theme theme', ['@theme' => $theme->info['name']])],
+ ];
+ $theme->operations[] = [
'title' => $this->t('Install and set as default'),
'url' => Url::fromRoute('system.theme_set_default'),
'query' => $query,
- 'attributes' => array('title' => $this->t('Install @theme as default theme', array('@theme' => $theme->info['name']))),
- );
+ 'attributes' => ['title' => $this->t('Install @theme as default theme', ['@theme' => $theme->info['name']])],
+ ];
}
}
// Add notes to default and administration theme.
- $theme->notes = array();
+ $theme->notes = [];
if ($theme->is_default) {
$theme->notes[] = $this->t('default theme');
}
@@ -303,9 +303,9 @@ class SystemController extends ControllerBase {
}
// There are two possible theme groups.
- $theme_group_titles = array(
+ $theme_group_titles = [
'installed' => $this->formatPlural(count($theme_groups['installed']), 'Installed theme', 'Installed themes'),
- );
+ ];
if (!empty($theme_groups['uninstalled'])) {
$theme_group_titles['uninstalled'] = $this->formatPlural(count($theme_groups['uninstalled']), 'Uninstalled theme', 'Uninstalled themes');
}
@@ -313,12 +313,12 @@ class SystemController extends ControllerBase {
uasort($theme_groups['installed'], 'system_sort_themes');
$this->moduleHandler()->alter('system_themes_page', $theme_groups);
- $build = array();
- $build[] = array(
+ $build = [];
+ $build[] = [
'#theme' => 'system_themes_page',
'#theme_groups' => $theme_groups,
'#theme_group_titles' => $theme_group_titles,
- );
+ ];
$build[] = $this->formBuilder->getForm('Drupal\system\Form\ThemeAdminForm', $admin_theme_options);
return $build;
diff --git a/core/modules/system/src/Controller/SystemInfoController.php b/core/modules/system/src/Controller/SystemInfoController.php
index 829d1fef55b..76c2c7a3775 100644
--- a/core/modules/system/src/Controller/SystemInfoController.php
+++ b/core/modules/system/src/Controller/SystemInfoController.php
@@ -63,7 +63,7 @@ class SystemInfoController implements ContainerInjectionInterface {
$output = ob_get_clean();
}
else {
- $output = t('The phpinfo() function has been disabled for security reasons. For more information, visit <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', array(':phpinfo' => 'https://www.drupal.org/node/243993'));
+ $output = t('The phpinfo() function has been disabled for security reasons. For more information, visit <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [':phpinfo' => 'https://www.drupal.org/node/243993']);
}
return new Response($output);
}
diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php
index e1353561ddb..9160085bee6 100644
--- a/core/modules/system/src/Controller/ThemeController.php
+++ b/core/modules/system/src/Controller/ThemeController.php
@@ -71,15 +71,15 @@ class ThemeController extends ControllerBase {
if (!empty($themes[$theme])) {
// Do not uninstall the default or admin theme.
if ($theme === $config->get('default') || $theme === $config->get('admin')) {
- drupal_set_message($this->t('%theme is the default theme and cannot be uninstalled.', array('%theme' => $themes[$theme]->info['name'])), 'error');
+ drupal_set_message($this->t('%theme is the default theme and cannot be uninstalled.', ['%theme' => $themes[$theme]->info['name']]), 'error');
}
else {
- $this->themeHandler->uninstall(array($theme));
- drupal_set_message($this->t('The %theme theme has been uninstalled.', array('%theme' => $themes[$theme]->info['name'])));
+ $this->themeHandler->uninstall([$theme]);
+ drupal_set_message($this->t('The %theme theme has been uninstalled.', ['%theme' => $themes[$theme]->info['name']]));
}
}
else {
- drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
+ drupal_set_message($this->t('The %theme theme was not found.', ['%theme' => $theme]), 'error');
}
return $this->redirect('system.themes_page');
@@ -106,12 +106,12 @@ class ThemeController extends ControllerBase {
if (isset($theme)) {
try {
- if ($this->themeHandler->install(array($theme))) {
+ if ($this->themeHandler->install([$theme])) {
$themes = $this->themeHandler->listInfo();
- drupal_set_message($this->t('The %theme theme has been installed.', array('%theme' => $themes[$theme]->info['name'])));
+ drupal_set_message($this->t('The %theme theme has been installed.', ['%theme' => $themes[$theme]->info['name']]));
}
else {
- drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
+ drupal_set_message($this->t('The %theme theme was not found.', ['%theme' => $theme]), 'error');
}
}
catch (PreExistingConfigException $e) {
@@ -121,10 +121,10 @@ class ThemeController extends ControllerBase {
count($config_objects),
'Unable to install @extension, %config_names already exists in active configuration.',
'Unable to install @extension, %config_names already exist in active configuration.',
- array(
+ [
'%config_names' => implode(', ', $config_objects),
'@extension' => $theme,
- )),
+ ]),
'error'
);
}
@@ -160,7 +160,7 @@ class ThemeController extends ControllerBase {
// Check if the specified theme is one recognized by the system.
// Or try to install the theme.
- if (isset($themes[$theme]) || $this->themeHandler->install(array($theme))) {
+ if (isset($themes[$theme]) || $this->themeHandler->install([$theme])) {
$themes = $this->themeHandler->listInfo();
// Set the default theme.
@@ -171,17 +171,17 @@ class ThemeController extends ControllerBase {
// theme.
$admin_theme = $config->get('admin');
if ($admin_theme != 0 && $admin_theme != $theme) {
- drupal_set_message($this->t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
+ drupal_set_message($this->t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', [
'%admin_theme' => $themes[$admin_theme]->info['name'],
'%selected_theme' => $themes[$theme]->info['name'],
- )));
+ ]));
}
else {
- drupal_set_message($this->t('%theme is now the default theme.', array('%theme' => $themes[$theme]->info['name'])));
+ drupal_set_message($this->t('%theme is now the default theme.', ['%theme' => $themes[$theme]->info['name']]));
}
}
else {
- drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
+ drupal_set_message($this->t('The %theme theme was not found.', ['%theme' => $theme]), 'error');
}
return $this->redirect('system.themes_page');
diff --git a/core/modules/system/src/DateFormatAccessControlHandler.php b/core/modules/system/src/DateFormatAccessControlHandler.php
index 597d6cdbb5b..c9cee601ec3 100644
--- a/core/modules/system/src/DateFormatAccessControlHandler.php
+++ b/core/modules/system/src/DateFormatAccessControlHandler.php
@@ -23,7 +23,7 @@ class DateFormatAccessControlHandler extends EntityAccessControlHandler {
return AccessResult::allowed();
}
// Locked date formats cannot be updated or deleted.
- elseif (in_array($operation, array('update', 'delete'))) {
+ elseif (in_array($operation, ['update', 'delete'])) {
if ($entity->isLocked()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
diff --git a/core/modules/system/src/Entity/Action.php b/core/modules/system/src/Entity/Action.php
index 9b27616eb95..a4128384e2c 100644
--- a/core/modules/system/src/Entity/Action.php
+++ b/core/modules/system/src/Entity/Action.php
@@ -57,7 +57,7 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En
*
* @var array
*/
- protected $configuration = array();
+ protected $configuration = [];
/**
* The plugin ID of the action.
@@ -90,7 +90,7 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En
* {@inheritdoc}
*/
public function getPluginCollections() {
- return array('configuration' => $this->getPluginCollection());
+ return ['configuration' => $this->getPluginCollection()];
}
/**
diff --git a/core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php b/core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php
index 33eab022354..b83fe7e1305 100644
--- a/core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php
+++ b/core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php
@@ -31,7 +31,7 @@ class AdminRouteSubscriber extends RouteSubscriberBase {
// Use a lower priority than \Drupal\field_ui\Routing\RouteSubscriber or
// \Drupal\views\EventSubscriber\RouteSubscriber to ensure we add the option
// to their routes.
- $events[RoutingEvents::ALTER] = array('onAlterRoutes', -200);
+ $events[RoutingEvents::ALTER] = ['onAlterRoutes', -200];
return $events;
}
diff --git a/core/modules/system/src/FileDownloadController.php b/core/modules/system/src/FileDownloadController.php
index 8c95de2c9aa..08b1632b28b 100644
--- a/core/modules/system/src/FileDownloadController.php
+++ b/core/modules/system/src/FileDownloadController.php
@@ -45,7 +45,7 @@ class FileDownloadController extends ControllerBase {
if (file_stream_wrapper_valid_scheme($scheme) && file_exists($uri)) {
// Let other modules provide headers and controls access to the file.
- $headers = $this->moduleHandler()->invokeAll('file_download', array($uri));
+ $headers = $this->moduleHandler()->invokeAll('file_download', [$uri]);
foreach ($headers as $result) {
if ($result == -1) {
diff --git a/core/modules/system/src/Form/CronForm.php b/core/modules/system/src/Form/CronForm.php
index d19915dced2..d4726aac575 100644
--- a/core/modules/system/src/Form/CronForm.php
+++ b/core/modules/system/src/Form/CronForm.php
@@ -98,27 +98,27 @@ class CronForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['description'] = array(
+ $form['description'] = [
'#markup' => '<p>' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '</p>',
- );
- $form['run'] = array(
+ ];
+ $form['run'] = [
'#type' => 'submit',
'#value' => t('Run cron'),
- );
- $status = '<p>' . $this->t('Last run: %time ago.', array('%time' => $this->dateFormatter->formatTimeDiffSince($this->state->get('system.cron_last')))) . '</p>';
- $form['status'] = array(
+ ];
+ $status = '<p>' . $this->t('Last run: %time ago.', ['%time' => $this->dateFormatter->formatTimeDiffSince($this->state->get('system.cron_last'))]) . '</p>';
+ $form['status'] = [
'#markup' => $status,
- );
+ ];
- $cron_url = $this->url('system.cron', array('key' => $this->state->get('system.cron_key')), array('absolute' => TRUE));
- $form['cron_url'] = array(
- '#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron">@cron</a>', array(':cron' => $cron_url, '@cron' => $cron_url)) . '</p>',
- );
+ $cron_url = $this->url('system.cron', ['key' => $this->state->get('system.cron_key')], ['absolute' => TRUE]);
+ $form['cron_url'] = [
+ '#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron">@cron</a>', [':cron' => $cron_url, '@cron' => $cron_url]) . '</p>',
+ ];
if (!$this->moduleHandler->moduleExists('automated_cron')) {
- $form['automated_cron'] = array(
+ $form['automated_cron'] = [
'#markup' => $this->t('Enable the <em>Automated Cron</em> module to allow cron execution at the end of a server response.'),
- );
+ ];
}
$form['cron'] = [
@@ -127,12 +127,12 @@ class CronForm extends FormBase {
'#open' => TRUE,
];
- $form['cron']['logging'] = array(
+ $form['cron']['logging'] = [
'#type' => 'checkbox',
'#title' => t('Detailed cron logging'),
'#default_value' => $this->config('system.cron')->get('logging'),
'#description' => 'Run times of individual cron jobs will be written to watchdog',
- );
+ ];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
diff --git a/core/modules/system/src/Form/DateFormatDeleteForm.php b/core/modules/system/src/Form/DateFormatDeleteForm.php
index a8e1c04136f..901c34b1abf 100644
--- a/core/modules/system/src/Form/DateFormatDeleteForm.php
+++ b/core/modules/system/src/Form/DateFormatDeleteForm.php
@@ -41,9 +41,9 @@ class DateFormatDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
public function getQuestion() {
- return t('Are you sure you want to delete the format %name : %format?', array(
+ return t('Are you sure you want to delete the format %name : %format?', [
'%name' => $this->entity->label(),
- '%format' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id()))
+ '%format' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())]
);
}
diff --git a/core/modules/system/src/Form/DateFormatEditForm.php b/core/modules/system/src/Form/DateFormatEditForm.php
index cec00208ae1..c63c0d7ac9f 100644
--- a/core/modules/system/src/Form/DateFormatEditForm.php
+++ b/core/modules/system/src/Form/DateFormatEditForm.php
@@ -15,7 +15,7 @@ class DateFormatEditForm extends DateFormatFormBase {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
- $now = t('Displayed as %date', array('%date' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())));
+ $now = t('Displayed as %date', ['%date' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())]);
$form['date_format_pattern']['#field_suffix'] = ' <small data-drupal-date-formatter="preview">' . $now . '</small>';
$form['date_format_pattern']['#default_value'] = $this->entity->getPattern();
diff --git a/core/modules/system/src/Form/DateFormatFormBase.php b/core/modules/system/src/Form/DateFormatFormBase.php
index adb24fa42dd..ed6714fc683 100644
--- a/core/modules/system/src/Form/DateFormatFormBase.php
+++ b/core/modules/system/src/Form/DateFormatFormBase.php
@@ -76,26 +76,26 @@ abstract class DateFormatFormBase extends EntityForm {
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => 'Name',
'#maxlength' => 100,
'#description' => t('Name of the date format'),
'#default_value' => $this->entity->label(),
- );
+ ];
- $form['id'] = array(
+ $form['id'] = [
'#type' => 'machine_name',
'#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
'#disabled' => !$this->entity->isNew(),
'#default_value' => $this->entity->id(),
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
'error' => $this->t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'),
- ),
- );
- $form['date_format_pattern'] = array(
+ ],
+ ];
+ $form['date_format_pattern'] = [
'#type' => 'textfield',
'#title' => t('Format string'),
'#maxlength' => 100,
@@ -105,14 +105,14 @@ abstract class DateFormatFormBase extends EntityForm {
'data-drupal-date-formatter' => 'source',
],
'#field_suffix' => ' <small class="js-hide" data-drupal-date-formatter="preview">' . $this->t('Displayed as %date_format', ['%date_format' => '']) . '</small>',
- );
+ ];
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'language_select',
'#title' => t('Language'),
'#languages' => LanguageInterface::STATE_ALL,
'#default_value' => $this->entity->language()->getId(),
- );
+ ];
$form['#attached']['drupalSettings']['dateFormats'] = $this->dateFormatter->getSampleDateFormats();
$form['#attached']['library'][] = 'system/drupal.system.date';
return parent::form($form, $form_state);
diff --git a/core/modules/system/src/Form/FileSystemForm.php b/core/modules/system/src/Form/FileSystemForm.php
index 9271bf45352..ff0b7924337 100644
--- a/core/modules/system/src/Form/FileSystemForm.php
+++ b/core/modules/system/src/Form/FileSystemForm.php
@@ -77,59 +77,59 @@ class FileSystemForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('system.file');
- $form['file_public_path'] = array(
+ $form['file_public_path'] = [
'#type' => 'item',
'#title' => t('Public file system path'),
'#markup' => PublicStream::basePath(),
'#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web. This must be changed in settings.php'),
- );
+ ];
- $form['file_public_base_url'] = array(
+ $form['file_public_base_url'] = [
'#type' => 'item',
'#title' => t('Public file base URL'),
'#markup' => PublicStream::baseUrl(),
'#description' => t('The base URL that will be used for public file URLs. This can be changed in settings.php'),
- );
+ ];
- $form['file_private_path'] = array(
+ $form['file_private_path'] = [
'#type' => 'item',
'#title' => t('Private file system path'),
'#markup' => (PrivateStream::basePath() ? PrivateStream::basePath() : t('Not set')),
'#description' => t('An existing local file system path for storing private files. It should be writable by Drupal and not accessible over the web. This must be changed in settings.php'),
- );
+ ];
- $form['file_temporary_path'] = array(
+ $form['file_temporary_path'] = [
'#type' => 'textfield',
'#title' => t('Temporary directory'),
'#default_value' => $config->get('path.temporary'),
'#maxlength' => 255,
'#description' => t('A local file system path where temporary files will be stored. This directory should not be accessible over the web.'),
- '#after_build' => array('system_check_directory'),
- );
+ '#after_build' => ['system_check_directory'],
+ ];
// Any visible, writeable wrapper can potentially be used for the files
// directory, including a remote file system that integrates with a CDN.
$options = $this->streamWrapperManager->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE);
if (!empty($options)) {
- $form['file_default_scheme'] = array(
+ $form['file_default_scheme'] = [
'#type' => 'radios',
'#title' => t('Default download method'),
'#default_value' => $config->get('default_scheme'),
'#options' => $options,
'#description' => t('This setting is used as the preferred download method. The use of public files is more efficient, but does not provide any access control.'),
- );
+ ];
}
- $intervals = array(0, 21600, 43200, 86400, 604800, 2419200, 7776000);
- $period = array_combine($intervals, array_map(array($this->dateFormatter, 'formatInterval'), $intervals));
+ $intervals = [0, 21600, 43200, 86400, 604800, 2419200, 7776000];
+ $period = array_combine($intervals, array_map([$this->dateFormatter, 'formatInterval'], $intervals));
$period[0] = t('Never');
- $form['temporary_maximum_age'] = array(
+ $form['temporary_maximum_age'] = [
'#type' => 'select',
'#title' => t('Delete orphaned files after'),
'#default_value' => $config->get('temporary_maximum_age'),
'#options' => $period,
'#description' => t('Orphaned files are not referenced from any content but remain in the file system and may appear in administrative listings. <strong>Warning:</strong> If enabled, orphaned files will be permanently deleted and may not be recoverable.'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/system/src/Form/ImageToolkitForm.php b/core/modules/system/src/Form/ImageToolkitForm.php
index 39634aeaa98..0e70b47a3b5 100644
--- a/core/modules/system/src/Form/ImageToolkitForm.php
+++ b/core/modules/system/src/Form/ImageToolkitForm.php
@@ -18,7 +18,7 @@ class ImageToolkitForm extends ConfigFormBase {
*
* @var \Drupal\Core\ImageToolkit\ImageToolkitInterface[]
*/
- protected $availableToolkits = array();
+ protected $availableToolkits = [];
/**
* Constructs a ImageToolkitForm object.
@@ -66,30 +66,30 @@ class ImageToolkitForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$current_toolkit = $this->config('system.image')->get('toolkit');
- $form['image_toolkit'] = array(
+ $form['image_toolkit'] = [
'#type' => 'radios',
'#title' => $this->t('Select an image processing toolkit'),
'#default_value' => $current_toolkit,
- '#options' => array(),
- );
+ '#options' => [],
+ ];
// If we have more than one image toolkit, allow the user to select the one
// to use, and load each of the toolkits' settings form.
foreach ($this->availableToolkits as $id => $toolkit) {
$definition = $toolkit->getPluginDefinition();
$form['image_toolkit']['#options'][$id] = $definition['title'];
- $form['image_toolkit_settings'][$id] = array(
+ $form['image_toolkit_settings'][$id] = [
'#type' => 'details',
- '#title' => $this->t('@toolkit settings', array('@toolkit' => $definition['title'])),
+ '#title' => $this->t('@toolkit settings', ['@toolkit' => $definition['title']]),
'#open' => TRUE,
'#tree' => TRUE,
- '#states' => array(
- 'visible' => array(
- ':radio[name="image_toolkit"]' => array('value' => $id),
- ),
- ),
- );
- $form['image_toolkit_settings'][$id] += $toolkit->buildConfigurationForm(array(), $form_state);
+ '#states' => [
+ 'visible' => [
+ ':radio[name="image_toolkit"]' => ['value' => $id],
+ ],
+ ],
+ ];
+ $form['image_toolkit_settings'][$id] += $toolkit->buildConfigurationForm([], $form_state);
}
return parent::buildForm($form, $form_state);
diff --git a/core/modules/system/src/Form/LoggingForm.php b/core/modules/system/src/Form/LoggingForm.php
index 22135e18ee5..a305a4ff1d5 100644
--- a/core/modules/system/src/Form/LoggingForm.php
+++ b/core/modules/system/src/Form/LoggingForm.php
@@ -29,18 +29,18 @@ class LoggingForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('system.logging');
- $form['error_level'] = array(
+ $form['error_level'] = [
'#type' => 'radios',
'#title' => t('Error messages to display'),
'#default_value' => $config->get('error_level'),
- '#options' => array(
+ '#options' => [
ERROR_REPORTING_HIDE => t('None'),
ERROR_REPORTING_DISPLAY_SOME => t('Errors and warnings'),
ERROR_REPORTING_DISPLAY_ALL => t('All messages'),
ERROR_REPORTING_DISPLAY_VERBOSE => t('All messages, with backtrace information'),
- ),
+ ],
'#description' => t('It is recommended that sites running on production environments do not display any errors.'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/system/src/Form/ModulesListConfirmForm.php b/core/modules/system/src/Form/ModulesListConfirmForm.php
index 88452e06bf8..50026606d29 100644
--- a/core/modules/system/src/Form/ModulesListConfirmForm.php
+++ b/core/modules/system/src/Form/ModulesListConfirmForm.php
@@ -36,7 +36,7 @@ class ModulesListConfirmForm extends ConfirmFormBase {
*
* @var array
*/
- protected $modules = array();
+ protected $modules = [];
/**
* The module installer.
@@ -120,10 +120,10 @@ class ModulesListConfirmForm extends ConfirmFormBase {
}
$items = $this->buildMessageList();
- $form['message'] = array(
+ $form['message'] = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
return parent::buildForm($form, $form_state);
}
@@ -177,10 +177,10 @@ class ModulesListConfirmForm extends ConfirmFormBase {
count($config_objects),
'Unable to install @extension, %config_names already exists in active configuration.',
'Unable to install @extension, %config_names already exist in active configuration.',
- array(
+ [
'%config_names' => implode(', ', $config_objects),
'@extension' => $this->modules['install'][$e->getExtension()]
- )),
+ ]),
'error'
);
return;
@@ -194,10 +194,10 @@ class ModulesListConfirmForm extends ConfirmFormBase {
}
$module_names = array_values($this->modules['install']);
- drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', array(
+ drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', [
'%name' => $module_names[0],
'%names' => implode(', ', $module_names),
- )));
+ ]));
}
$form_state->setRedirectUrl($this->getCancelUrl());
diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php
index d98b8a1251f..28ff7ef4cc2 100644
--- a/core/modules/system/src/Form/ModulesListForm.php
+++ b/core/modules/system/src/Form/ModulesListForm.php
@@ -119,26 +119,26 @@ class ModulesListForm extends FormBase {
// Include system.admin.inc so we can use the sort callbacks.
$this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
- $form['filters'] = array(
+ $form['filters'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('table-filter', 'js-show'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['table-filter', 'js-show'],
+ ],
+ ];
- $form['filters']['text'] = array(
+ $form['filters']['text'] = [
'#type' => 'search',
'#title' => $this->t('Filter modules'),
'#title_display' => 'invisible',
'#size' => 30,
'#placeholder' => $this->t('Filter by name or description'),
'#description' => $this->t('Enter a part of the module name or description'),
- '#attributes' => array(
- 'class' => array('table-filter-text'),
+ '#attributes' => [
+ 'class' => ['table-filter-text'],
'data-table' => '#system-modules',
'autocomplete' => 'off',
- ),
- );
+ ],
+ ];
// Sort all modules by their names.
$modules = system_rebuild_module_data();
@@ -156,15 +156,15 @@ class ModulesListForm extends FormBase {
// Add a wrapper around every package.
foreach (Element::children($form['modules']) as $package) {
- $form['modules'][$package] += array(
+ $form['modules'][$package] += [
'#type' => 'details',
'#title' => $this->t($package),
'#open' => TRUE,
'#theme' => 'system_modules_details',
- '#attributes' => array('class' => array('package-listing')),
+ '#attributes' => ['class' => ['package-listing']],
// Ensure that the "Core" package comes first.
'#weight' => $package == 'Core' ? -10 : NULL,
- );
+ ];
}
// If testing modules are shown, collapse the corresponding package by
@@ -174,15 +174,15 @@ class ModulesListForm extends FormBase {
}
// Lastly, sort all packages by title.
- uasort($form['modules'], array('\Drupal\Component\Utility\SortArray', 'sortByTitleProperty'));
+ uasort($form['modules'], ['\Drupal\Component\Utility\SortArray', 'sortByTitleProperty']);
$form['#attached']['library'][] = 'system/drupal.system.modules';
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Install'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -201,9 +201,9 @@ class ModulesListForm extends FormBase {
*/
protected function buildRow(array $modules, Extension $module, $distribution) {
// Set the basic properties.
- $row['#required'] = array();
- $row['#requires'] = array();
- $row['#required_by'] = array();
+ $row['#required'] = [];
+ $row['#requires'] = [];
+ $row['#required_by'] = [];
$row['name']['#markup'] = $module->info['name'];
$row['description']['#markup'] = $this->t($module->info['description']);
@@ -213,48 +213,48 @@ class ModulesListForm extends FormBase {
// implementation exists then the module provides an overview page, rather
// than checking to see if the page exists, which is costly.
if ($this->moduleHandler->moduleExists('help') && $module->status && in_array($module->getName(), $this->moduleHandler->getImplementations('help'))) {
- $row['links']['help'] = array(
+ $row['links']['help'] = [
'#type' => 'link',
'#title' => $this->t('Help'),
'#url' => Url::fromRoute('help.page', ['name' => $module->getName()]),
- '#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->t('Help'))),
- );
+ '#options' => ['attributes' => ['class' => ['module-link', 'module-link-help'], 'title' => $this->t('Help')]],
+ ];
}
// Generate link for module's permission, if the user has access to it.
if ($module->status && $this->currentUser->hasPermission('administer permissions') && $this->permissionHandler->moduleProvidesPermissions($module->getName())) {
- $row['links']['permissions'] = array(
+ $row['links']['permissions'] = [
'#type' => 'link',
'#title' => $this->t('Permissions'),
'#url' => Url::fromRoute('user.admin_permissions'),
- '#options' => array('fragment' => 'module-' . $module->getName(), 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => $this->t('Configure permissions'))),
- );
+ '#options' => ['fragment' => 'module-' . $module->getName(), 'attributes' => ['class' => ['module-link', 'module-link-permissions'], 'title' => $this->t('Configure permissions')]],
+ ];
}
// Generate link for module's configuration page, if it has one.
if ($module->status && isset($module->info['configure'])) {
- $route_parameters = isset($module->info['configure_parameters']) ? $module->info['configure_parameters'] : array();
+ $route_parameters = isset($module->info['configure_parameters']) ? $module->info['configure_parameters'] : [];
if ($this->accessManager->checkNamedRoute($module->info['configure'], $route_parameters, $this->currentUser)) {
- $row['links']['configure'] = array(
+ $row['links']['configure'] = [
'#type' => 'link',
'#title' => $this->t('Configure <span class="visually-hidden">the @module module</span>', ['@module' => $module->info['name']]),
'#url' => Url::fromRoute($module->info['configure'], $route_parameters),
- '#options' => array(
- 'attributes' => array(
- 'class' => array('module-link', 'module-link-configure'),
- ),
- ),
- );
+ '#options' => [
+ 'attributes' => [
+ 'class' => ['module-link', 'module-link-configure'],
+ ],
+ ],
+ ];
}
}
// Present a checkbox for installing and indicating the status of a module.
- $row['enable'] = array(
+ $row['enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Install'),
'#default_value' => (bool) $module->status,
'#disabled' => (bool) $module->status,
- );
+ ];
// Disable the checkbox for required modules.
if (!empty($module->info['required'])) {
@@ -268,24 +268,24 @@ class ModulesListForm extends FormBase {
// Initialize an empty array of reasons why the module is incompatible. Add
// each reason as a separate element of the array.
- $reasons = array();
+ $reasons = [];
// Check the core compatibility.
if ($module->info['core'] != \Drupal::CORE_COMPATIBILITY) {
$compatible = FALSE;
- $reasons[] = $this->t('This version is not compatible with Drupal @core_version and should be replaced.', array(
+ $reasons[] = $this->t('This version is not compatible with Drupal @core_version and should be replaced.', [
'@core_version' => \Drupal::CORE_COMPATIBILITY,
- ));
+ ]);
}
// Ensure this module is compatible with the currently installed version of PHP.
if (version_compare(phpversion(), $module->info['php']) < 0) {
$compatible = FALSE;
$required = $module->info['php'] . (substr_count($module->info['php'], '.') < 2 ? '.*' : '');
- $reasons[] = $this->t('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', array(
+ $reasons[] = $this->t('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', [
'@php_required' => $required,
'@php_version' => phpversion(),
- ));
+ ]);
}
// If this module is not compatible, disable the checkbox.
@@ -299,7 +299,7 @@ class ModulesListForm extends FormBase {
// If this module requires other modules, add them to the array.
foreach ($module->requires as $dependency => $version) {
if (!isset($modules[$dependency])) {
- $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst($dependency)));
+ $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst($dependency)]);
$row['enable']['#disabled'] = TRUE;
}
// Only display visible modules.
@@ -308,25 +308,25 @@ class ModulesListForm extends FormBase {
// Disable the module's checkbox if it is incompatible with the
// dependency's version.
if ($incompatible_version = drupal_check_incompatibility($version, str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) {
- $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
+ $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> version @version)', [
'@module' => $name . $incompatible_version,
'@version' => $modules[$dependency]->info['version'],
- ));
+ ]);
$row['enable']['#disabled'] = TRUE;
}
// Disable the checkbox if the dependency is incompatible with this
// version of Drupal core.
elseif ($modules[$dependency]->info['core'] != \Drupal::CORE_COMPATIBILITY) {
- $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
+ $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
'@module' => $name,
- ));
+ ]);
$row['enable']['#disabled'] = TRUE;
}
elseif ($modules[$dependency]->status) {
- $row['#requires'][$dependency] = $this->t('@module', array('@module' => $name));
+ $row['#requires'][$dependency] = $this->t('@module', ['@module' => $name]);
}
else {
- $row['#requires'][$dependency] = $this->t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $name));
+ $row['#requires'][$dependency] = $this->t('@module (<span class="admin-disabled">disabled</span>)', ['@module' => $name]);
}
}
}
@@ -336,11 +336,11 @@ class ModulesListForm extends FormBase {
foreach ($module->required_by as $dependent => $version) {
if (isset($modules[$dependent]) && empty($modules[$dependent]->info['hidden'])) {
if ($modules[$dependent]->status == 1 && $module->status == 1) {
- $row['#required_by'][$dependent] = $this->t('@module', array('@module' => $modules[$dependent]->info['name']));
+ $row['#required_by'][$dependent] = $this->t('@module', ['@module' => $modules[$dependent]->info['name']]);
$row['enable']['#disabled'] = TRUE;
}
else {
- $row['#required_by'][$dependent] = $this->t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $modules[$dependent]->info['name']));
+ $row['#required_by'][$dependent] = $this->t('@module (<span class="admin-disabled">disabled</span>)', ['@module' => $modules[$dependent]->info['name']]);
}
}
}
@@ -359,11 +359,11 @@ class ModulesListForm extends FormBase {
*/
protected function buildModuleList(FormStateInterface $form_state) {
// Build a list of modules to install.
- $modules = array(
- 'install' => array(),
- 'dependencies' => array(),
+ $modules = [
+ 'install' => [],
+ 'dependencies' => [],
'experimental' => [],
- );
+ ];
$data = system_rebuild_module_data();
foreach ($data as $name => $module) {
@@ -447,10 +447,10 @@ class ModulesListForm extends FormBase {
try {
$this->moduleInstaller->install(array_keys($modules['install']));
$module_names = array_values($modules['install']);
- drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', array(
+ drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', [
'%name' => $module_names[0],
'%names' => implode(', ', $module_names),
- )));
+ ]));
}
catch (PreExistingConfigException $e) {
$config_objects = $e->flattenConfigObjects($e->getConfigObjects());
@@ -459,10 +459,10 @@ class ModulesListForm extends FormBase {
count($config_objects),
'Unable to install @extension, %config_names already exists in active configuration.',
'Unable to install @extension, %config_names already exist in active configuration.',
- array(
+ [
'%config_names' => implode(', ', $config_objects),
'@extension' => $modules['install'][$e->getExtension()]
- )),
+ ]),
'error'
);
return;
diff --git a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php
index f4a48230747..c72f240acc7 100644
--- a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php
+++ b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php
@@ -51,7 +51,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
*
* @var array
*/
- protected $modules = array();
+ protected $modules = [];
/**
* Constructs a ModulesUninstallConfirmForm object.
@@ -135,12 +135,12 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
$data = system_rebuild_module_data();
$form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
- $form['modules'] = array(
+ $form['modules'] = [
'#theme' => 'item_list',
'#items' => array_map(function ($module) use ($data) {
return $data[$module]->info['name'];
}, $this->modules),
- );
+ ];
// List the dependent entities.
$this->addDependencyListsToForm($form, 'module', $this->modules, $this->configManager, $this->entityManager);
diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php
index 92a15a78a58..80348c59f13 100644
--- a/core/modules/system/src/Form/ModulesUninstallForm.php
+++ b/core/modules/system/src/Form/ModulesUninstallForm.php
@@ -85,28 +85,28 @@ class ModulesUninstallForm extends FormBase {
// Include system.admin.inc so we can use the sort callbacks.
$this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
- $form['filters'] = array(
+ $form['filters'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('table-filter', 'js-show'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['table-filter', 'js-show'],
+ ],
+ ];
- $form['filters']['text'] = array(
+ $form['filters']['text'] = [
'#type' => 'search',
'#title' => $this->t('Filter modules'),
'#title_display' => 'invisible',
'#size' => 30,
'#placeholder' => $this->t('Filter by name or description'),
'#description' => $this->t('Enter a part of the module name or description'),
- '#attributes' => array(
- 'class' => array('table-filter-text'),
+ '#attributes' => [
+ 'class' => ['table-filter-text'],
'data-table' => '#system-modules-uninstall',
'autocomplete' => 'off',
- ),
- );
+ ],
+ ];
- $form['modules'] = array();
+ $form['modules'] = [];
// Only build the rest of the form if there are any modules available to
// uninstall;
@@ -120,18 +120,18 @@ class ModulesUninstallForm extends FormBase {
uasort($uninstallable, 'system_sort_modules_by_info_name');
$validation_reasons = $this->moduleInstaller->validateUninstall(array_keys($uninstallable));
- $form['uninstall'] = array('#tree' => TRUE);
+ $form['uninstall'] = ['#tree' => TRUE];
foreach ($uninstallable as $module_key => $module) {
$name = $module->info['name'] ?: $module->getName();
$form['modules'][$module->getName()]['#module_name'] = $name;
$form['modules'][$module->getName()]['name']['#markup'] = $name;
$form['modules'][$module->getName()]['description']['#markup'] = $this->t($module->info['description']);
- $form['uninstall'][$module->getName()] = array(
+ $form['uninstall'][$module->getName()] = [
'#type' => 'checkbox',
- '#title' => $this->t('Uninstall @module module', array('@module' => $name)),
+ '#title' => $this->t('Uninstall @module module', ['@module' => $name]),
'#title_display' => 'invisible',
- );
+ ];
// If a validator returns reasons not to uninstall a module,
// list the reasons and disable the check box.
@@ -152,11 +152,11 @@ class ModulesUninstallForm extends FormBase {
}
$form['#attached']['library'][] = 'system/drupal.system.modules';
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Uninstall'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/src/Form/PerformanceForm.php b/core/modules/system/src/Form/PerformanceForm.php
index d9e0917991a..a2e85927d52 100644
--- a/core/modules/system/src/Form/PerformanceForm.php
+++ b/core/modules/system/src/Form/PerformanceForm.php
@@ -100,64 +100,64 @@ class PerformanceForm extends ConfigFormBase {
$config = $this->config('system.performance');
- $form['clear_cache'] = array(
+ $form['clear_cache'] = [
'#type' => 'details',
'#title' => t('Clear cache'),
'#open' => TRUE,
- );
+ ];
- $form['clear_cache']['clear'] = array(
+ $form['clear_cache']['clear'] = [
'#type' => 'submit',
'#value' => t('Clear all caches'),
- '#submit' => array('::submitCacheClear'),
- );
+ '#submit' => ['::submitCacheClear'],
+ ];
- $form['caching'] = array(
+ $form['caching'] = [
'#type' => 'details',
'#title' => t('Caching'),
'#open' => TRUE,
'#description' => $this->t('Note: Drupal provides an internal page cache module that is recommended for small to medium-sized websites.'),
- );
+ ];
// Identical options to the ones for block caching.
// @see \Drupal\Core\Block\BlockBase::buildConfigurationForm()
- $period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
- $period = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($period, $period));
+ $period = [0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400];
+ $period = array_map([$this->dateFormatter, 'formatInterval'], array_combine($period, $period));
$period[0] = '<' . t('no caching') . '>';
- $form['caching']['page_cache_maximum_age'] = array(
+ $form['caching']['page_cache_maximum_age'] = [
'#type' => 'select',
'#title' => t('Page cache maximum age'),
'#default_value' => $config->get('cache.page.max_age'),
'#options' => $period,
'#description' => t('The maximum time a page can be cached by browsers and proxies. This is used as the value for max-age in Cache-Control headers.'),
- );
+ ];
$directory = 'public://';
$is_writable = is_dir($directory) && is_writable($directory);
$disabled = !$is_writable;
$disabled_message = '';
if (!$is_writable) {
- $disabled_message = ' ' . t('<strong class="error">Set up the <a href=":file-system">public files directory</a> to make these optimizations available.</strong>', array(':file-system' => $this->url('system.file_system_settings')));
+ $disabled_message = ' ' . t('<strong class="error">Set up the <a href=":file-system">public files directory</a> to make these optimizations available.</strong>', [':file-system' => $this->url('system.file_system_settings')]);
}
- $form['bandwidth_optimization'] = array(
+ $form['bandwidth_optimization'] = [
'#type' => 'details',
'#title' => t('Bandwidth optimization'),
'#open' => TRUE,
'#description' => t('External resources can be optimized automatically, which can reduce both the size and number of requests made to your website.') . $disabled_message,
- );
+ ];
- $form['bandwidth_optimization']['preprocess_css'] = array(
+ $form['bandwidth_optimization']['preprocess_css'] = [
'#type' => 'checkbox',
'#title' => t('Aggregate CSS files'),
'#default_value' => $config->get('css.preprocess'),
'#disabled' => $disabled,
- );
- $form['bandwidth_optimization']['preprocess_js'] = array(
+ ];
+ $form['bandwidth_optimization']['preprocess_js'] = [
'#type' => 'checkbox',
'#title' => t('Aggregate JavaScript files'),
'#default_value' => $config->get('js.preprocess'),
'#disabled' => $disabled,
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/system/src/Form/RegionalForm.php b/core/modules/system/src/Form/RegionalForm.php
index 9472a4cb726..c365fc0551c 100644
--- a/core/modules/system/src/Form/RegionalForm.php
+++ b/core/modules/system/src/Form/RegionalForm.php
@@ -67,76 +67,76 @@ class RegionalForm extends ConfigFormBase {
// Date settings:
$zones = system_time_zones();
- $form['locale'] = array(
+ $form['locale'] = [
'#type' => 'details',
'#title' => t('Locale'),
'#open' => TRUE,
- );
+ ];
- $form['locale']['site_default_country'] = array(
+ $form['locale']['site_default_country'] = [
'#type' => 'select',
'#title' => t('Default country'),
'#empty_value' => '',
'#default_value' => $system_date->get('country.default'),
'#options' => $countries,
- '#attributes' => array('class' => array('country-detect')),
- );
+ '#attributes' => ['class' => ['country-detect']],
+ ];
- $form['locale']['date_first_day'] = array(
+ $form['locale']['date_first_day'] = [
'#type' => 'select',
'#title' => t('First day of week'),
'#default_value' => $system_date->get('first_day'),
- '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
- );
+ '#options' => [0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')],
+ ];
- $form['timezone'] = array(
+ $form['timezone'] = [
'#type' => 'details',
'#title' => t('Time zones'),
'#open' => TRUE,
- );
+ ];
- $form['timezone']['date_default_timezone'] = array(
+ $form['timezone']['date_default_timezone'] = [
'#type' => 'select',
'#title' => t('Default time zone'),
'#default_value' => $system_date->get('timezone.default') ?: date_default_timezone_get(),
'#options' => $zones,
- );
+ ];
$configurable_timezones = $system_date->get('timezone.user.configurable');
- $form['timezone']['configurable_timezones'] = array(
+ $form['timezone']['configurable_timezones'] = [
'#type' => 'checkbox',
'#title' => t('Users may set their own time zone'),
'#default_value' => $configurable_timezones,
- );
+ ];
- $form['timezone']['configurable_timezones_wrapper'] = array(
+ $form['timezone']['configurable_timezones_wrapper'] = [
'#type' => 'container',
- '#states' => array(
+ '#states' => [
// Hide the user configured timezone settings when users are forced to use
// the default setting.
- 'invisible' => array(
- 'input[name="configurable_timezones"]' => array('checked' => FALSE),
- ),
- ),
- );
- $form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = array(
+ 'invisible' => [
+ 'input[name="configurable_timezones"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+ $form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = [
'#type' => 'checkbox',
'#title' => t('Remind users at login if their time zone is not set'),
'#default_value' => $system_date->get('timezone.user.warn'),
'#description' => t('Only applied if users may set their own time zone.')
- );
+ ];
- $form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = array(
+ $form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = [
'#type' => 'radios',
'#title' => t('Time zone for new users'),
'#default_value' => $system_date->get('timezone.user.default'),
- '#options' => array(
+ '#options' => [
DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone'),
DRUPAL_USER_TIMEZONE_EMPTY => t('Empty time zone'),
DRUPAL_USER_TIMEZONE_SELECT => t('Users may set their own time zone at registration'),
- ),
+ ],
'#description' => t('Only applied if users may set their own time zone.')
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/system/src/Form/RssFeedsForm.php b/core/modules/system/src/Form/RssFeedsForm.php
index 79aa69ba4ba..986ff114971 100644
--- a/core/modules/system/src/Form/RssFeedsForm.php
+++ b/core/modules/system/src/Form/RssFeedsForm.php
@@ -29,31 +29,31 @@ class RssFeedsForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$rss_config = $this->config('system.rss');
- $form['feed_description'] = array(
+ $form['feed_description'] = [
'#type' => 'textarea',
'#title' => t('Feed description'),
'#default_value' => $rss_config->get('channel.description'),
'#description' => t('Description of your site, included in each feed.')
- );
- $options = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30);
- $form['feed_default_items'] = array(
+ ];
+ $options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30];
+ $form['feed_default_items'] = [
'#type' => 'select',
'#title' => t('Number of items in each feed'),
'#default_value' => $rss_config->get('items.limit'),
'#options' => array_combine($options, $options),
'#description' => t('Default number of items to include in each feed.')
- );
- $form['feed_view_mode'] = array(
+ ];
+ $form['feed_view_mode'] = [
'#type' => 'select',
'#title' => t('Feed content'),
'#default_value' => $rss_config->get('items.view_mode'),
- '#options' => array(
+ '#options' => [
'title' => t('Titles only'),
'teaser' => t('Titles plus teaser'),
'fulltext' => t('Full text'),
- ),
+ ],
'#description' => t('Global setting for the default display of content items in each feed.')
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/system/src/Form/SiteInformationForm.php b/core/modules/system/src/Form/SiteInformationForm.php
index 92986d6d69e..7173ebe9427 100644
--- a/core/modules/system/src/Form/SiteInformationForm.php
+++ b/core/modules/system/src/Form/SiteInformationForm.php
@@ -92,63 +92,63 @@ class SiteInformationForm extends ConfigFormBase {
$site_mail = ini_get('sendmail_from');
}
- $form['site_information'] = array(
+ $form['site_information'] = [
'#type' => 'details',
'#title' => t('Site details'),
'#open' => TRUE,
- );
- $form['site_information']['site_name'] = array(
+ ];
+ $form['site_information']['site_name'] = [
'#type' => 'textfield',
'#title' => t('Site name'),
'#default_value' => $site_config->get('name'),
'#required' => TRUE,
- );
- $form['site_information']['site_slogan'] = array(
+ ];
+ $form['site_information']['site_slogan'] = [
'#type' => 'textfield',
'#title' => t('Slogan'),
'#default_value' => $site_config->get('slogan'),
'#description' => t("How this is used depends on your site's theme."),
- );
- $form['site_information']['site_mail'] = array(
+ ];
+ $form['site_information']['site_mail'] = [
'#type' => 'email',
'#title' => t('Email address'),
'#default_value' => $site_mail,
'#description' => t("The <em>From</em> address in automated emails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this email being flagged as spam.)"),
'#required' => TRUE,
- );
- $form['front_page'] = array(
+ ];
+ $form['front_page'] = [
'#type' => 'details',
'#title' => t('Front page'),
'#open' => TRUE,
- );
+ ];
$front_page = $site_config->get('page.front') != '/user/login' ? $this->aliasManager->getAliasByPath($site_config->get('page.front')) : '';
- $form['front_page']['site_frontpage'] = array(
+ $form['front_page']['site_frontpage'] = [
'#type' => 'textfield',
'#title' => t('Default front page'),
'#default_value' => $front_page,
'#size' => 40,
'#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default front page.'),
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
- );
- $form['error_page'] = array(
+ ];
+ $form['error_page'] = [
'#type' => 'details',
'#title' => t('Error pages'),
'#open' => TRUE,
- );
- $form['error_page']['site_403'] = array(
+ ];
+ $form['error_page']['site_403'] = [
'#type' => 'textfield',
'#title' => t('Default 403 (access denied) page'),
'#default_value' => $site_config->get('page.403'),
'#size' => 40,
'#description' => t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'),
- );
- $form['error_page']['site_404'] = array(
+ ];
+ $form['error_page']['site_404'] = [
'#type' => 'textfield',
'#title' => t('Default 404 (not found) page'),
'#default_value' => $site_config->get('page.404'),
'#size' => 40,
'#description' => t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
@@ -172,7 +172,7 @@ class SiteInformationForm extends ConfigFormBase {
}
if (!$this->pathValidator->isValid($form_state->getValue('site_frontpage'))) {
- $form_state->setErrorByName('site_frontpage', $this->t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state->getValue('site_frontpage'))));
+ $form_state->setErrorByName('site_frontpage', $this->t("The path '%path' is either invalid or you do not have access to it.", ['%path' => $form_state->getValue('site_frontpage')]));
}
// Get the normal paths of both error pages.
if (!$form_state->isValueEmpty('site_403')) {
@@ -189,11 +189,11 @@ class SiteInformationForm extends ConfigFormBase {
}
// Validate 403 error path.
if (!$form_state->isValueEmpty('site_403') && !$this->pathValidator->isValid($form_state->getValue('site_403'))) {
- $form_state->setErrorByName('site_403', $this->t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state->getValue('site_403'))));
+ $form_state->setErrorByName('site_403', $this->t("The path '%path' is either invalid or you do not have access to it.", ['%path' => $form_state->getValue('site_403')]));
}
// Validate 404 error path.
if (!$form_state->isValueEmpty('site_404') && !$this->pathValidator->isValid($form_state->getValue('site_404'))) {
- $form_state->setErrorByName('site_404', $this->t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state->getValue('site_404'))));
+ $form_state->setErrorByName('site_404', $this->t("The path '%path' is either invalid or you do not have access to it.", ['%path' => $form_state->getValue('site_404')]));
}
parent::validateForm($form, $form_state);
diff --git a/core/modules/system/src/Form/SiteMaintenanceModeForm.php b/core/modules/system/src/Form/SiteMaintenanceModeForm.php
index 0d0b2afe0ce..fb509aafe6d 100644
--- a/core/modules/system/src/Form/SiteMaintenanceModeForm.php
+++ b/core/modules/system/src/Form/SiteMaintenanceModeForm.php
@@ -75,17 +75,17 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
$config = $this->config('system.maintenance');
$permissions = $this->permissionHandler->getPermissions();
$permission_label = $permissions['access site in maintenance mode']['title'];
- $form['maintenance_mode'] = array(
+ $form['maintenance_mode'] = [
'#type' => 'checkbox',
'#title' => t('Put site into maintenance mode'),
'#default_value' => $this->state->get('system.maintenance_mode'),
- '#description' => t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array('@permission-label' => $permission_label, ':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login'))),
- );
- $form['maintenance_mode_message'] = array(
+ '#description' => t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', ['@permission-label' => $permission_label, ':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login')]),
+ ];
+ $form['maintenance_mode_message'] = [
'#type' => 'textarea',
'#title' => t('Message to display when in maintenance mode'),
'#default_value' => $config->get('message'),
- );
+ ];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/system/src/Form/ThemeAdminForm.php b/core/modules/system/src/Form/ThemeAdminForm.php
index a3ec4191c71..e8d17edd257 100644
--- a/core/modules/system/src/Form/ThemeAdminForm.php
+++ b/core/modules/system/src/Form/ThemeAdminForm.php
@@ -29,24 +29,24 @@ class ThemeAdminForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, array $theme_options = NULL) {
// Administration theme settings.
- $form['admin_theme'] = array(
+ $form['admin_theme'] = [
'#type' => 'details',
'#title' => $this->t('Administration theme'),
'#open' => TRUE,
- );
- $form['admin_theme']['admin_theme'] = array(
+ ];
+ $form['admin_theme']['admin_theme'] = [
'#type' => 'select',
- '#options' => array(0 => $this->t('Default theme')) + $theme_options,
+ '#options' => [0 => $this->t('Default theme')] + $theme_options,
'#title' => $this->t('Administration theme'),
'#description' => $this->t('Choose "Default theme" to always use the same theme as the rest of the site.'),
'#default_value' => $this->config('system.theme')->get('admin'),
- );
- $form['admin_theme']['actions'] = array('#type' => 'actions');
- $form['admin_theme']['actions']['submit'] = array(
+ ];
+ $form['admin_theme']['actions'] = ['#type' => 'actions'];
+ $form['admin_theme']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save configuration'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php
index 37b5ea1364e..f5cfb090826 100644
--- a/core/modules/system/src/Form/ThemeSettingsForm.php
+++ b/core/modules/system/src/Form/ThemeSettingsForm.php
@@ -132,25 +132,25 @@ class ThemeSettingsForm extends ConfigFormBase {
// by https://www.drupal.org/node/2402467.
$this->editableConfig = [$config_key];
- $form['var'] = array(
+ $form['var'] = [
'#type' => 'hidden',
'#value' => $var
- );
- $form['config_key'] = array(
+ ];
+ $form['config_key'] = [
'#type' => 'hidden',
'#value' => $config_key
- );
+ ];
// Toggle settings
- $toggles = array(
+ $toggles = [
'node_user_picture' => t('User pictures in posts'),
'comment_user_picture' => t('User pictures in comments'),
'comment_user_verification' => t('User verification status in comments'),
'favicon' => t('Shortcut icon'),
- );
+ ];
// Some features are not always available
- $disabled = array();
+ $disabled = [];
if (!user_picture_enabled()) {
$disabled['toggle_node_user_picture'] = TRUE;
$disabled['toggle_comment_user_picture'] = TRUE;
@@ -160,14 +160,14 @@ class ThemeSettingsForm extends ConfigFormBase {
$disabled['toggle_comment_user_verification'] = TRUE;
}
- $form['theme_settings'] = array(
+ $form['theme_settings'] = [
'#type' => 'details',
'#title' => t('Page element display'),
'#open' => TRUE,
- );
+ ];
foreach ($toggles as $name => $title) {
if ((!$theme) || in_array($name, $features)) {
- $form['theme_settings']['toggle_' . $name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => theme_get_setting('features.' . $name, $theme));
+ $form['theme_settings']['toggle_' . $name] = ['#type' => 'checkbox', '#title' => $title, '#default_value' => theme_get_setting('features.' . $name, $theme)];
// Disable checkboxes for features not supported in the current configuration.
if (isset($disabled['toggle_' . $name])) {
$form['theme_settings']['toggle_' . $name]['#disabled'] = TRUE;
@@ -183,82 +183,82 @@ class ThemeSettingsForm extends ConfigFormBase {
// Logo settings, only available when file.module is enabled.
if ((!$theme || in_array('logo', $features)) && $this->moduleHandler->moduleExists('file')) {
- $form['logo'] = array(
+ $form['logo'] = [
'#type' => 'details',
'#title' => t('Logo image'),
'#open' => TRUE,
- );
- $form['logo']['default_logo'] = array(
+ ];
+ $form['logo']['default_logo'] = [
'#type' => 'checkbox',
'#title' => t('Use the logo supplied by the theme'),
'#default_value' => theme_get_setting('logo.use_default', $theme),
'#tree' => FALSE,
- );
- $form['logo']['settings'] = array(
+ ];
+ $form['logo']['settings'] = [
'#type' => 'container',
- '#states' => array(
+ '#states' => [
// Hide the logo settings when using the default logo.
- 'invisible' => array(
- 'input[name="default_logo"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['logo']['settings']['logo_path'] = array(
+ 'invisible' => [
+ 'input[name="default_logo"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['logo']['settings']['logo_path'] = [
'#type' => 'textfield',
'#title' => t('Path to custom logo'),
'#default_value' => theme_get_setting('logo.path', $theme),
- );
- $form['logo']['settings']['logo_upload'] = array(
+ ];
+ $form['logo']['settings']['logo_upload'] = [
'#type' => 'file',
'#title' => t('Upload logo image'),
'#maxlength' => 40,
'#description' => t("If you don't have direct file access to the server, use this field to upload your logo.")
- );
+ ];
}
if (((!$theme) || in_array('favicon', $features)) && $this->moduleHandler->moduleExists('file')) {
- $form['favicon'] = array(
+ $form['favicon'] = [
'#type' => 'details',
'#title' => t('Favicon'),
'#open' => TRUE,
'#description' => t("Your shortcut icon, or favicon, is displayed in the address bar and bookmarks of most browsers."),
- '#states' => array(
+ '#states' => [
// Hide the shortcut icon settings fieldset when shortcut icon display
// is disabled.
- 'invisible' => array(
- 'input[name="toggle_favicon"]' => array('checked' => FALSE),
- ),
- ),
- );
- $form['favicon']['default_favicon'] = array(
+ 'invisible' => [
+ 'input[name="toggle_favicon"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+ $form['favicon']['default_favicon'] = [
'#type' => 'checkbox',
'#title' => t('Use the favicon supplied by the theme'),
'#default_value' => theme_get_setting('favicon.use_default', $theme),
- );
- $form['favicon']['settings'] = array(
+ ];
+ $form['favicon']['settings'] = [
'#type' => 'container',
- '#states' => array(
+ '#states' => [
// Hide the favicon settings when using the default favicon.
- 'invisible' => array(
- 'input[name="default_favicon"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['favicon']['settings']['favicon_path'] = array(
+ 'invisible' => [
+ 'input[name="default_favicon"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['favicon']['settings']['favicon_path'] = [
'#type' => 'textfield',
'#title' => t('Path to custom icon'),
'#default_value' => theme_get_setting('favicon.path', $theme),
- );
- $form['favicon']['settings']['favicon_upload'] = array(
+ ];
+ $form['favicon']['settings']['favicon_upload'] = [
'#type' => 'file',
'#title' => t('Upload favicon image'),
'#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")
- );
+ ];
}
// Inject human-friendly values and form element descriptions for logo and
// favicon.
- foreach (array('logo' => 'logo.svg', 'favicon' => 'favicon.ico') as $type => $default) {
+ foreach (['logo' => 'logo.svg', 'favicon' => 'favicon.ico'] as $type => $default) {
if (isset($form[$type]['settings'][$type . '_path'])) {
$element = &$form[$type]['settings'][$type . '_path'];
@@ -273,7 +273,7 @@ class ThemeSettingsForm extends ConfigFormBase {
// Prepare local file path for description.
if ($original_path && isset($friendly_path)) {
- $local_file = strtr($original_path, array('public:/' => PublicStream::basePath()));
+ $local_file = strtr($original_path, ['public:/' => PublicStream::basePath()]);
}
elseif ($theme) {
$local_file = drupal_get_path('theme', $theme) . '/' . $default;
@@ -282,11 +282,11 @@ class ThemeSettingsForm extends ConfigFormBase {
$local_file = $this->themeManager->getActiveTheme()->getPath() . '/' . $default;
}
- $element['#description'] = t('Examples: <code>@implicit-public-file</code> (for a file in the public filesystem), <code>@explicit-file</code>, or <code>@local-file</code>.', array(
+ $element['#description'] = t('Examples: <code>@implicit-public-file</code> (for a file in the public filesystem), <code>@explicit-file</code>, or <code>@local-file</code>.', [
'@implicit-public-file' => isset($friendly_path) ? $friendly_path : $default,
'@explicit-file' => file_uri_scheme($original_path) !== FALSE ? $original_path : 'public://' . $default,
'@local-file' => $local_file,
- ));
+ ]);
}
}
@@ -294,12 +294,12 @@ class ThemeSettingsForm extends ConfigFormBase {
// Call engine-specific settings.
$function = $themes[$theme]->prefix . '_engine_settings';
if (function_exists($function)) {
- $form['engine_specific'] = array(
+ $form['engine_specific'] = [
'#type' => 'details',
'#title' => t('Theme-engine-specific settings'),
'#open' => TRUE,
- '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$theme]->prefix)),
- );
+ '#description' => t('These settings only exist for the themes based on the %engine theme engine.', ['%engine' => $themes[$theme]->prefix]),
+ ];
$function($form, $form_state);
}
@@ -309,7 +309,7 @@ class ThemeSettingsForm extends ConfigFormBase {
$theme_keys[] = $theme;
}
else {
- $theme_keys = array($theme);
+ $theme_keys = [$theme];
}
// Save the name of the current theme (if any), so that we can temporarily
@@ -356,7 +356,7 @@ class ThemeSettingsForm extends ConfigFormBase {
if ($this->moduleHandler->moduleExists('file')) {
// Handle file uploads.
- $validators = array('file_validate_is_image' => array());
+ $validators = ['file_validate_is_image' => []];
// Check for a new uploaded logo.
$file = file_save_upload('logo_upload', $validators, FALSE, 0);
@@ -372,7 +372,7 @@ class ThemeSettingsForm extends ConfigFormBase {
}
}
- $validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg'));
+ $validators = ['file_validate_extensions' => ['ico png gif jpg jpeg apng svg']];
// Check for a new uploaded favicon.
$file = file_save_upload('favicon_upload', $validators, FALSE, 0);
diff --git a/core/modules/system/src/PathBasedBreadcrumbBuilder.php b/core/modules/system/src/PathBasedBreadcrumbBuilder.php
index dcfc0732f3f..4a96d1195a2 100644
--- a/core/modules/system/src/PathBasedBreadcrumbBuilder.php
+++ b/core/modules/system/src/PathBasedBreadcrumbBuilder.php
@@ -122,14 +122,14 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
- $links = array();
+ $links = [];
// General path-based breadcrumbs. Use the actual request path, prior to
// resolving path aliases, so the breadcrumb can be defined by simply
// creating a hierarchy of path aliases.
$path = trim($this->context->getPathInfo(), '/');
$path_elements = explode('/', $path);
- $exclude = array();
+ $exclude = [];
// Don't show a link to the front-page path.
$front = $this->config->get('page.front');
$exclude[$front] = TRUE;
@@ -154,7 +154,7 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
if (!isset($title)) {
// Fallback to using the raw path component as the title if the
// route is missing a _title or _title_callback attribute.
- $title = str_replace(array('-', '_'), ' ', Unicode::ucfirst(end($path_elements)));
+ $title = str_replace(['-', '_'], ' ', Unicode::ucfirst(end($path_elements)));
}
$url = Url::fromRouteMatch($route_match);
$links[] = new Link($title, $url);
diff --git a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
index f6b0958c68c..330528528d6 100644
--- a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
+++ b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
@@ -60,12 +60,12 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'use_site_logo' => TRUE,
'use_site_name' => TRUE,
'use_site_slogan' => TRUE,
'label_display' => FALSE,
- );
+ ];
}
/**
@@ -77,15 +77,15 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
// Get permissions.
$url_system_theme_settings = new Url('system.theme_settings');
- $url_system_theme_settings_theme = new Url('system.theme_settings_theme', array('theme' => $theme));
+ $url_system_theme_settings_theme = new Url('system.theme_settings_theme', ['theme' => $theme]);
if ($url_system_theme_settings->access() && $url_system_theme_settings_theme->access()) {
// Provide links to the Appearance Settings and Theme Settings pages
// if the user has access to administer themes.
- $site_logo_description = $this->t('Defined on the <a href=":appearance">Appearance Settings</a> or <a href=":theme">Theme Settings</a> page.', array(
+ $site_logo_description = $this->t('Defined on the <a href=":appearance">Appearance Settings</a> or <a href=":theme">Theme Settings</a> page.', [
':appearance' => $url_system_theme_settings->toString(),
':theme' => $url_system_theme_settings_theme->toString(),
- ));
+ ]);
}
else {
// Explain that the user does not have access to the Appearance and Theme
@@ -99,8 +99,8 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
// Provide link to Site Information page if the user has access to
// administer site configuration.
- $site_name_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', array(':information' => $site_information_url));
- $site_slogan_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', array(':information' => $site_information_url));
+ $site_name_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', [':information' => $site_information_url]);
+ $site_slogan_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', [':information' => $site_information_url]);
}
else {
// Explain that the user does not have access to the Site Information
@@ -109,30 +109,30 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
$site_slogan_description = $this->t('Defined on the Site Information page. You do not have the appropriate permissions to change the site logo.');
}
- $form['block_branding'] = array(
+ $form['block_branding'] = [
'#type' => 'fieldset',
'#title' => $this->t('Toggle branding elements'),
'#description' => $this->t('Choose which branding elements you want to show in this block instance.'),
- );
- $form['block_branding']['use_site_logo'] = array(
+ ];
+ $form['block_branding']['use_site_logo'] = [
'#type' => 'checkbox',
'#title' => $this->t('Site logo'),
'#description' => $site_logo_description,
'#default_value' => $this->configuration['use_site_logo'],
- );
+ ];
- $form['block_branding']['use_site_name'] = array(
+ $form['block_branding']['use_site_name'] = [
'#type' => 'checkbox',
'#title' => $this->t('Site name'),
'#description' => $site_name_description,
'#default_value' => $this->configuration['use_site_name'],
- );
- $form['block_branding']['use_site_slogan'] = array(
+ ];
+ $form['block_branding']['use_site_slogan'] = [
'#type' => 'checkbox',
'#title' => $this->t('Site slogan'),
'#description' => $site_slogan_description,
'#default_value' => $this->configuration['use_site_slogan'],
- );
+ ];
return $form;
}
@@ -150,25 +150,25 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
* {@inheritdoc}
*/
public function build() {
- $build = array();
+ $build = [];
$site_config = $this->configFactory->get('system.site');
- $build['site_logo'] = array(
+ $build['site_logo'] = [
'#theme' => 'image',
'#uri' => theme_get_setting('logo.url'),
'#alt' => $this->t('Home'),
'#access' => $this->configuration['use_site_logo'],
- );
+ ];
- $build['site_name'] = array(
+ $build['site_name'] = [
'#markup' => $site_config->get('name'),
'#access' => $this->configuration['use_site_name'],
- );
+ ];
- $build['site_slogan'] = array(
+ $build['site_slogan'] = [
'#markup' => $site_config->get('slogan'),
'#access' => $this->configuration['use_site_slogan'],
- );
+ ];
return $build;
}
diff --git a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php
index e9e1b33d2ae..52daa098e4b 100644
--- a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php
+++ b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php
@@ -64,36 +64,36 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa
$config = $this->configuration;
$defaults = $this->defaultConfiguration();
- $form['menu_levels'] = array(
+ $form['menu_levels'] = [
'#type' => 'details',
'#title' => $this->t('Menu levels'),
// Open if not set to defaults.
'#open' => $defaults['level'] !== $config['level'] || $defaults['depth'] !== $config['depth'],
'#process' => [[get_class(), 'processMenuLevelParents']],
- );
+ ];
$options = range(0, $this->menuTree->maxDepth());
unset($options[0]);
- $form['menu_levels']['level'] = array(
+ $form['menu_levels']['level'] = [
'#type' => 'select',
'#title' => $this->t('Initial visibility level'),
'#default_value' => $config['level'],
'#options' => $options,
'#description' => $this->t('The menu is only visible if the menu item for the current page is at this level or below it. Use level 1 to always display this menu.'),
'#required' => TRUE,
- );
+ ];
$options[0] = $this->t('Unlimited');
- $form['menu_levels']['depth'] = array(
+ $form['menu_levels']['depth'] = [
'#type' => 'select',
'#title' => $this->t('Number of levels to display'),
'#default_value' => $config['depth'],
'#options' => $options,
'#description' => $this->t('This maximum number includes the initial level.'),
'#required' => TRUE,
- );
+ ];
return $form;
}
@@ -136,10 +136,10 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa
}
$tree = $this->menuTree->load($menu_name, $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ];
$tree = $this->menuTree->transform($tree, $manipulators);
return $this->menuTree->build($tree);
}
diff --git a/core/modules/system/src/Plugin/Block/SystemMessagesBlock.php b/core/modules/system/src/Plugin/Block/SystemMessagesBlock.php
index bbfb03695cb..0b6638f43be 100644
--- a/core/modules/system/src/Plugin/Block/SystemMessagesBlock.php
+++ b/core/modules/system/src/Plugin/Block/SystemMessagesBlock.php
@@ -22,9 +22,9 @@ class SystemMessagesBlock extends BlockBase implements MessagesBlockPluginInterf
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'label_display' => FALSE,
- );
+ ];
}
/**
diff --git a/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php b/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php
index 132b00030ab..c1e0ba8b8c1 100644
--- a/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php
+++ b/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php
@@ -25,7 +25,7 @@ class SystemPoweredByBlock extends BlockBase {
* {@inheritdoc}
*/
public function build() {
- return array('#markup' => '<span>' . $this->t('Powered by <a href=":poweredby">Drupal</a>', array(':poweredby' => 'https://www.drupal.org')) . '</span>');
+ return ['#markup' => '<span>' . $this->t('Powered by <a href=":poweredby">Drupal</a>', [':poweredby' => 'https://www.drupal.org']) . '</span>'];
}
}
diff --git a/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php b/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
index 2f7375dce89..d282963aa6f 100644
--- a/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
+++ b/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php
@@ -70,21 +70,21 @@ class CurrentThemeCondition extends ConditionPluginBase implements ContainerFact
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array('theme' => '') + parent::defaultConfiguration();
+ return ['theme' => ''] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['theme'] = array(
+ $form['theme'] = [
'#type' => 'select',
'#title' => $this->t('Theme'),
'#default_value' => $this->configuration['theme'],
'#options' => array_map(function ($theme_info) {
return $theme_info->info['name'];
}, $this->themeHandler->listInfo()),
- );
+ ];
return parent::buildConfigurationForm($form, $form_state);
}
@@ -112,10 +112,10 @@ class CurrentThemeCondition extends ConditionPluginBase implements ContainerFact
*/
public function summary() {
if ($this->isNegated()) {
- return $this->t('The current theme is not @theme', array('@theme' => $this->configuration['theme']));
+ return $this->t('The current theme is not @theme', ['@theme' => $this->configuration['theme']]);
}
- return $this->t('The current theme is @theme', array('@theme' => $this->configuration['theme']));
+ return $this->t('The current theme is @theme', ['@theme' => $this->configuration['theme']]);
}
/**
diff --git a/core/modules/system/src/Plugin/Condition/RequestPath.php b/core/modules/system/src/Plugin/Condition/RequestPath.php
index 17373cef7e9..ae9d77da21a 100644
--- a/core/modules/system/src/Plugin/Condition/RequestPath.php
+++ b/core/modules/system/src/Plugin/Condition/RequestPath.php
@@ -94,22 +94,22 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array('pages' => '') + parent::defaultConfiguration();
+ return ['pages' => ''] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['pages'] = array(
+ $form['pages'] = [
'#type' => 'textarea',
'#title' => $this->t('Pages'),
'#default_value' => $this->configuration['pages'],
- '#description' => $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. An example path is %user-wildcard for every user page. %front is the front page.", array(
+ '#description' => $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. An example path is %user-wildcard for every user page. %front is the front page.", [
'%user-wildcard' => '/user/*',
'%front' => '<front>',
- )),
- );
+ ]),
+ ];
return parent::buildConfigurationForm($form, $form_state);
}
@@ -128,9 +128,9 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
$pages = array_map('trim', explode("\n", $this->configuration['pages']));
$pages = implode(', ', $pages);
if (!empty($this->configuration['negate'])) {
- return $this->t('Do not return true on the following pages: @pages', array('@pages' => $pages));
+ return $this->t('Do not return true on the following pages: @pages', ['@pages' => $pages]);
}
- return $this->t('Return true on the following pages: @pages', array('@pages' => $pages));
+ return $this->t('Return true on the following pages: @pages', ['@pages' => $pages]);
}
/**
diff --git a/core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php b/core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php
index 2f802e65098..5da50271720 100644
--- a/core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php
+++ b/core/modules/system/src/Plugin/Derivative/SystemMenuBlock.php
@@ -47,7 +47,7 @@ class SystemMenuBlock extends DeriverBase implements ContainerDeriverInterface {
foreach ($this->menuStorage->loadMultiple() as $menu => $entity) {
$this->derivatives[$menu] = $base_plugin_definition;
$this->derivatives[$menu]['admin_label'] = $entity->label();
- $this->derivatives[$menu]['config_dependencies']['config'] = array($entity->getConfigDependencyName());
+ $this->derivatives[$menu]['config_dependencies']['config'] = [$entity->getConfigDependencyName()];
}
return $this->derivatives;
}
diff --git a/core/modules/system/src/Plugin/Derivative/ThemeLocalTask.php b/core/modules/system/src/Plugin/Derivative/ThemeLocalTask.php
index 3ff29dcb386..ab9f87d9496 100644
--- a/core/modules/system/src/Plugin/Derivative/ThemeLocalTask.php
+++ b/core/modules/system/src/Plugin/Derivative/ThemeLocalTask.php
@@ -46,7 +46,7 @@ class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface {
if ($this->themeHandler->hasUi($theme_name)) {
$this->derivatives[$theme_name] = $base_plugin_definition;
$this->derivatives[$theme_name]['title'] = $theme->info['name'];
- $this->derivatives[$theme_name]['route_parameters'] = array('theme' => $theme_name);
+ $this->derivatives[$theme_name]['route_parameters'] = ['theme' => $theme_name];
}
}
return $this->derivatives;
diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
index 7b195cc9b29..818c5b5cf0e 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
@@ -143,7 +143,7 @@ class GDToolkit extends ImageToolkitBase {
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['image_jpeg_quality'] = array(
+ $form['image_jpeg_quality'] = [
'#type' => 'number',
'#title' => t('JPEG quality'),
'#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
@@ -151,7 +151,7 @@ class GDToolkit extends ImageToolkitBase {
'#max' => 100,
'#default_value' => $this->configFactory->getEditable('system.image.gd')->get('jpeg_quality', FALSE),
'#field_suffix' => t('%'),
- );
+ ];
return $form;
}
@@ -160,7 +160,7 @@ class GDToolkit extends ImageToolkitBase {
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configFactory->getEditable('system.image.gd')
- ->set('jpeg_quality', $form_state->getValue(array('gd', 'image_jpeg_quality')))
+ ->set('jpeg_quality', $form_state->getValue(['gd', 'image_jpeg_quality']))
->save();
}
@@ -186,13 +186,13 @@ class GDToolkit extends ImageToolkitBase {
// Convert indexed images to truecolor, copying the image to a new
// truecolor resource, so that filters work correctly and don't result
// in unnecessary dither.
- $data = array(
+ $data = [
'width' => imagesx($resource),
'height' => imagesy($resource),
'extension' => image_type_to_extension($this->getType(), FALSE),
'transparent_color' => $this->getTransparentColor(),
'is_temp' => TRUE,
- );
+ ];
if ($this->apply('create_new', $data)) {
imagecopy($this->getResource(), $resource, 0, 0, 0, 0, imagesx($resource), imagesy($resource));
imagedestroy($resource);
@@ -362,13 +362,13 @@ class GDToolkit extends ImageToolkitBase {
* {@inheritdoc}
*/
public function getRequirements() {
- $requirements = array();
+ $requirements = [];
$info = gd_info();
- $requirements['version'] = array(
+ $requirements['version'] = [
'title' => t('GD library'),
'value' => $info['GD Version'],
- );
+ ];
// Check for filter and rotate support.
if (!function_exists('imagefilter') || !function_exists('imagerotate')) {
@@ -391,7 +391,7 @@ class GDToolkit extends ImageToolkitBase {
* {@inheritdoc}
*/
public static function getSupportedExtensions() {
- $extensions = array();
+ $extensions = [];
foreach (static::supportedTypes() as $image_type) {
// @todo Automatically fetch possible extensions for each mime type.
// @see https://www.drupal.org/node/2311679
@@ -440,7 +440,7 @@ class GDToolkit extends ImageToolkitBase {
* IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
*/
protected static function supportedTypes() {
- return array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF);
+ return [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
}
}
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php
index 7c5fca146d7..5404e2e0035 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php
@@ -19,11 +19,11 @@ class Convert extends GDImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function arguments() {
- return array(
- 'extension' => array(
+ return [
+ 'extension' => [
'description' => 'The new extension of the converted image',
- ),
- );
+ ],
+ ];
}
/**
@@ -47,13 +47,13 @@ class Convert extends GDImageToolkitOperationBase {
$height = $this->getToolkit()->getHeight();
$original_resource = $this->getToolkit()->getResource();
$original_type = $this->getToolkit()->getType();
- $data = array(
+ $data = [
'width' => $width,
'height' => $height,
'extension' => $arguments['extension'],
'transparent_color' => $this->getToolkit()->getTransparentColor(),
'is_temp' => TRUE,
- );
+ ];
if ($this->getToolkit()->apply('create_new', $data)) {
if (imagecopyresampled($this->getToolkit()->getResource(), $original_resource, 0, 0, 0, 0, $width, $height, $width, $height)) {
imagedestroy($original_resource);
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php
index 0d1c5a61114..cb57cc48986 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/CreateNew.php
@@ -21,29 +21,29 @@ class CreateNew extends GDImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function arguments() {
- return array(
- 'width' => array(
+ return [
+ 'width' => [
'description' => 'The width of the image, in pixels',
- ),
- 'height' => array(
+ ],
+ 'height' => [
'description' => 'The height of the image, in pixels',
- ),
- 'extension' => array(
+ ],
+ 'extension' => [
'description' => 'The extension of the image file (e.g. png, gif, etc.)',
'required' => FALSE,
'default' => 'png',
- ),
- 'transparent_color' => array(
+ ],
+ 'transparent_color' => [
'description' => 'The RGB hex color for GIF transparency',
'required' => FALSE,
'default' => '#ffffff',
- ),
- 'is_temp' => array(
+ ],
+ 'is_temp' => [
'description' => 'If TRUE, this operation is being used to create a temporary image by another GD operation. After performing its function, the caller is responsible for destroying the original GD resource.',
'required' => FALSE,
'default' => FALSE,
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php
index e5ca672f0bd..07a112b9108 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php
@@ -19,24 +19,24 @@ class Crop extends GDImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function arguments() {
- return array(
- 'x' => array(
+ return [
+ 'x' => [
'description' => 'The starting x offset at which to start the crop, in pixels',
- ),
- 'y' => array(
+ ],
+ 'y' => [
'description' => 'The starting y offset at which to start the crop, in pixels',
- ),
- 'width' => array(
+ ],
+ 'width' => [
'description' => 'The width of the cropped area, in pixels',
'required' => FALSE,
'default' => NULL,
- ),
- 'height' => array(
+ ],
+ 'height' => [
'description' => 'The height of the cropped area, in pixels',
'required' => FALSE,
'default' => NULL,
- ),
- );
+ ],
+ ];
}
/**
@@ -54,7 +54,7 @@ class Crop extends GDImageToolkitOperationBase {
$arguments['width'] = empty($arguments['width']) ? $arguments['height'] / $aspect : $arguments['width'];
// Assure integers for all arguments.
- foreach (array('x', 'y', 'width', 'height') as $key) {
+ foreach (['x', 'y', 'width', 'height'] as $key) {
$arguments[$key] = (int) round($arguments[$key]);
}
@@ -77,13 +77,13 @@ class Crop extends GDImageToolkitOperationBase {
// the original resource on it with resampling. Destroy the original
// resource upon success.
$original_resource = $this->getToolkit()->getResource();
- $data = array(
+ $data = [
'width' => $arguments['width'],
'height' => $arguments['height'],
'extension' => image_type_to_extension($this->getToolkit()->getType(), FALSE),
'transparent_color' => $this->getToolkit()->getTransparentColor(),
'is_temp' => TRUE,
- );
+ ];
if ($this->getToolkit()->apply('create_new', $data)) {
if (imagecopyresampled($this->getToolkit()->getResource(), $original_resource, 0, 0, $arguments['x'], $arguments['y'], $arguments['width'], $arguments['height'], $arguments['width'], $arguments['height'])) {
imagedestroy($original_resource);
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php
index bae8483ef50..54ed29b9be9 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php
@@ -20,7 +20,7 @@ class Desaturate extends GDImageToolkitOperationBase {
*/
protected function arguments() {
// This operation does not use any parameters.
- return array();
+ return [];
}
/**
@@ -29,7 +29,7 @@ class Desaturate extends GDImageToolkitOperationBase {
protected function execute(array $arguments) {
// PHP installations using non-bundled GD do not have imagefilter.
if (!function_exists('imagefilter')) {
- $this->logger->notice("The image '@file' could not be desaturated because the imagefilter() function is not available in this PHP installation.", array('@file' => $this->getToolkit()->getSource()));
+ $this->logger->notice("The image '@file' could not be desaturated because the imagefilter() function is not available in this PHP installation.", ['@file' => $this->getToolkit()->getSource()]);
return FALSE;
}
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php
index 51c5f53a7d8..155bef24641 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php
@@ -19,14 +19,14 @@ class Resize extends GDImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function arguments() {
- return array(
- 'width' => array(
+ return [
+ 'width' => [
'description' => 'The new width of the resized image, in pixels',
- ),
- 'height' => array(
+ ],
+ 'height' => [
'description' => 'The new height of the resized image, in pixels',
- ),
- );
+ ],
+ ];
}
/**
@@ -51,18 +51,18 @@ class Resize extends GDImageToolkitOperationBase {
/**
* {@inheritdoc}
*/
- protected function execute(array $arguments = array()) {
+ protected function execute(array $arguments = []) {
// Create a new resource of the required dimensions, and copy and resize
// the original resource on it with resampling. Destroy the original
// resource upon success.
$original_resource = $this->getToolkit()->getResource();
- $data = array(
+ $data = [
'width' => $arguments['width'],
'height' => $arguments['height'],
'extension' => image_type_to_extension($this->getToolkit()->getType(), FALSE),
'transparent_color' => $this->getToolkit()->getTransparentColor(),
'is_temp' => TRUE,
- );
+ ];
if ($this->getToolkit()->apply('create_new', $data)) {
if (imagecopyresampled($this->getToolkit()->getResource(), $original_resource, 0, 0, 0, 0, $arguments['width'], $arguments['height'], imagesx($original_resource), imagesy($original_resource))) {
imagedestroy($original_resource);
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php
index 62a5405d7e8..43356125310 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php
@@ -21,16 +21,16 @@ class Rotate extends GDImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function arguments() {
- return array(
- 'degrees' => array(
+ return [
+ 'degrees' => [
'description' => 'The number of (clockwise) degrees to rotate the image',
- ),
- 'background' => array(
+ ],
+ 'background' => [
'description' => "A string specifying the hexadecimal color code to use as background for the uncovered area of the image after the rotation. E.g. '#000000' for black, '#ff00ff' for magenta, and '#ffffff' for white. For images that support transparency, this will default to transparent white",
'required' => FALSE,
'default' => NULL,
- ),
- );
+ ],
+ ];
}
/**
@@ -45,11 +45,11 @@ class Rotate extends GDImageToolkitOperationBase {
// Validate or set background color argument.
if (!empty($arguments['background'])) {
// Validate the background color: Color::hexToRgb does so for us.
- $background = Color::hexToRgb($arguments['background']) + array( 'alpha' => 0 );
+ $background = Color::hexToRgb($arguments['background']) + [ 'alpha' => 0 ];
}
else {
// Background color is not specified: use transparent white as background.
- $background = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127);
+ $background = ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127];
}
// Store the color index for the background as that is what GD uses.
$arguments['background_idx'] = imagecolorallocatealpha($this->getToolkit()->getResource(), $background['red'], $background['green'], $background['blue'], $background['alpha']);
@@ -89,7 +89,7 @@ class Rotate extends GDImageToolkitOperationBase {
protected function execute(array $arguments) {
// PHP installations using non-bundled GD do not have imagerotate.
if (!function_exists('imagerotate')) {
- $this->logger->notice('The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $this->getToolkit()->getSource()));
+ $this->logger->notice('The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', ['%file' => $this->getToolkit()->getSource()]);
return FALSE;
}
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php
index bd7a95278ba..37097d864ee 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php
@@ -19,23 +19,23 @@ class Scale extends Resize {
* {@inheritdoc}
*/
protected function arguments() {
- return array(
- 'width' => array(
+ return [
+ 'width' => [
'description' => 'The target width, in pixels. This value is omitted then the scaling will based only on the height value',
'required' => FALSE,
'default' => NULL,
- ),
- 'height' => array(
+ ],
+ 'height' => [
'description' => 'The target height, in pixels. This value is omitted then the scaling will based only on the width value',
'required' => FALSE,
'default' => NULL,
- ),
- 'upscale' => array(
+ ],
+ 'upscale' => [
'description' => 'Boolean indicating that files smaller than the dimensions will be scaled up. This generally results in a low quality image',
'required' => FALSE,
'default' => FALSE,
- ),
- );
+ ],
+ ];
}
/**
@@ -78,7 +78,7 @@ class Scale extends Resize {
/**
* {@inheritdoc}
*/
- protected function execute(array $arguments = array()) {
+ protected function execute(array $arguments = []) {
// Don't scale if we don't change the dimensions at all.
if ($arguments['width'] !== $this->getToolkit()->getWidth() || $arguments['height'] !== $this->getToolkit()->getHeight()) {
// Don't upscale if the option isn't enabled.
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
index 8568823bf04..510020f8d8c 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
@@ -19,14 +19,14 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
* {@inheritdoc}
*/
protected function arguments() {
- return array(
- 'width' => array(
+ return [
+ 'width' => [
'description' => 'The target width, in pixels',
- ),
- 'height' => array(
+ ],
+ 'height' => [
'description' => 'The target height, in pixels',
- ),
- );
+ ],
+ ];
}
/**
@@ -40,10 +40,10 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
$arguments['x'] = (int) round(($actualWidth * $scaleFactor - $arguments['width']) / 2);
$arguments['y'] = (int) round(($actualHeight * $scaleFactor - $arguments['height']) / 2);
- $arguments['resize'] = array(
+ $arguments['resize'] = [
'width' => (int) round($actualWidth * $scaleFactor),
'height' => (int) round($actualHeight * $scaleFactor),
- );
+ ];
// Fail when width or height are 0 or negative.
if ($arguments['width'] <= 0) {
@@ -59,7 +59,7 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
/**
* {@inheritdoc}
*/
- protected function execute(array $arguments = array()) {
+ protected function execute(array $arguments = []) {
return $this->getToolkit()->apply('resize', $arguments['resize'])
&& $this->getToolkit()->apply('crop', $arguments);
}
diff --git a/core/modules/system/src/Plugin/migrate/source/Menu.php b/core/modules/system/src/Plugin/migrate/source/Menu.php
index 6dbf2e7a4c3..c55bc4bb7fd 100644
--- a/core/modules/system/src/Plugin/migrate/source/Menu.php
+++ b/core/modules/system/src/Plugin/migrate/source/Menu.php
@@ -25,11 +25,11 @@ class Menu extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'menu_name' => $this->t('The menu name. Primary key.'),
'title' => $this->t('The human-readable name of the menu.'),
'description' => $this->t('A description of the menu'),
- );
+ ];
}
/**
diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php
index 8e38c2b7326..65fdc51cc73 100644
--- a/core/modules/system/src/Plugin/views/field/BulkForm.php
+++ b/core/modules/system/src/Plugin/views/field/BulkForm.php
@@ -49,7 +49,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
*
* @var \Drupal\system\ActionConfigEntityInterface[]
*/
- protected $actions = array();
+ protected $actions = [];
/**
* The language manager.
@@ -162,13 +162,13 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['action_title'] = array('default' => $this->t('Action'));
- $options['include_exclude'] = array(
+ $options['action_title'] = ['default' => $this->t('Action')];
+ $options['include_exclude'] = [
'default' => 'exclude',
- );
- $options['selected_actions'] = array(
- 'default' => array(),
- );
+ ];
+ $options['selected_actions'] = [
+ 'default' => [],
+ ];
return $options;
}
@@ -176,28 +176,28 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['action_title'] = array(
+ $form['action_title'] = [
'#type' => 'textfield',
'#title' => $this->t('Action title'),
'#default_value' => $this->options['action_title'],
'#description' => $this->t('The title shown above the actions dropdown.'),
- );
+ ];
- $form['include_exclude'] = array(
+ $form['include_exclude'] = [
'#type' => 'radios',
'#title' => $this->t('Available actions'),
- '#options' => array(
+ '#options' => [
'exclude' => $this->t('All actions, except selected'),
'include' => $this->t('Only selected actions'),
- ),
+ ],
'#default_value' => $this->options['include_exclude'],
- );
- $form['selected_actions'] = array(
+ ];
+ $form['selected_actions'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Selected actions'),
'#options' => $this->getBulkOptions(FALSE),
'#default_value' => $this->options['selected_actions'],
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -208,8 +208,8 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
parent::validateOptionsForm($form, $form_state);
- $selected_actions = $form_state->getValue(array('options', 'selected_actions'));
- $form_state->setValue(array('options', 'selected_actions'), array_values(array_filter($selected_actions)));
+ $selected_actions = $form_state->getValue(['options', 'selected_actions']);
+ $form_state->setValue(['options', 'selected_actions'], array_values(array_filter($selected_actions)));
}
/**
@@ -259,7 +259,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
foreach ($this->view->result as $row_index => $row) {
$entity = $this->getEntityTranslation($this->getEntity($row), $row);
- $form[$this->options['id']][$row_index] = array(
+ $form[$this->options['id']][$row_index] = [
'#type' => 'checkbox',
// We are not able to determine a main "title" for each row, so we can
// only output a generic label.
@@ -267,28 +267,28 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
'#title_display' => 'invisible',
'#default_value' => !empty($form_state->getValue($this->options['id'])[$row_index]) ? 1 : NULL,
'#return_value' => $this->calculateEntityBulkFormKey($entity, $use_revision),
- );
+ ];
}
// Replace the form submit button label.
$form['actions']['submit']['#value'] = $this->t('Apply to selected items');
// Ensure a consistent container for filters/operations in the view header.
- $form['header'] = array(
+ $form['header'] = [
'#type' => 'container',
'#weight' => -100,
- );
+ ];
// Build the bulk operations action widget for the header.
// Allow themes to apply .container-inline on this separate container.
- $form['header'][$this->options['id']] = array(
+ $form['header'][$this->options['id']] = [
'#type' => 'container',
- );
- $form['header'][$this->options['id']]['action'] = array(
+ ];
+ $form['header'][$this->options['id']]['action'] = [
'#type' => 'select',
'#title' => $this->options['action_title'],
'#options' => $this->getBulkOptions(),
- );
+ ];
// Duplicate the form actions into the action container in the header.
$form['header'][$this->options['id']]['actions'] = $form['actions'];
@@ -308,7 +308,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
* An associative array of operations, suitable for a select element.
*/
protected function getBulkOptions($filtered = TRUE) {
- $options = array();
+ $options = [];
// Filter the action list.
foreach ($this->actions as $id => $action) {
if ($filtered) {
@@ -349,7 +349,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
// bulk form is submitted, which can lead to data loss.
$user_input = $form_state->getUserInput();
$selected = array_filter($user_input[$this->options['id']]);
- $entities = array();
+ $entities = [];
$action = $this->actions[$form_state->getValue('action')];
$count = 0;
@@ -375,18 +375,18 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
$operation_definition = $action->getPluginDefinition();
if (!empty($operation_definition['confirm_form_route_name'])) {
- $options = array(
+ $options = [
'query' => $this->getDestinationArray(),
- );
- $form_state->setRedirect($operation_definition['confirm_form_route_name'], array(), $options);
+ ];
+ $form_state->setRedirect($operation_definition['confirm_form_route_name'], [], $options);
}
else {
// Don't display the message unless there are some elements affected and
// there is no confirmation form.
if ($count) {
- drupal_set_message($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', array(
+ drupal_set_message($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', [
'%action' => $action->label(),
- )));
+ ]));
}
}
}
diff --git a/core/modules/system/src/SystemConfigSubscriber.php b/core/modules/system/src/SystemConfigSubscriber.php
index 3c0de5fa43c..ddd37be37a6 100644
--- a/core/modules/system/src/SystemConfigSubscriber.php
+++ b/core/modules/system/src/SystemConfigSubscriber.php
@@ -81,11 +81,11 @@ class SystemConfigSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events[ConfigEvents::SAVE][] = array('onConfigSave', 0);
+ $events[ConfigEvents::SAVE][] = ['onConfigSave', 0];
// The empty check has a high priority so that it can stop propagation if
// there is no configuration to import.
- $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateNotEmpty', 512);
- $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateSiteUUID', 256);
+ $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidateNotEmpty', 512];
+ $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidateSiteUUID', 256];
return $events;
}
diff --git a/core/modules/system/src/SystemManager.php b/core/modules/system/src/SystemManager.php
index b9fcebb12dd..d2e03443db4 100644
--- a/core/modules/system/src/SystemManager.php
+++ b/core/modules/system/src/SystemManager.php
@@ -109,7 +109,7 @@ class SystemManager {
drupal_load_updates();
// Check run-time requirements and status information.
- $requirements = $this->moduleHandler->invokeAll('requirements', array('runtime'));
+ $requirements = $this->moduleHandler->invokeAll('requirements', ['runtime']);
uasort($requirements, function($a, $b) {
if (!isset($a['weight'])) {
if (!isset($b['weight'])) {
@@ -159,15 +159,15 @@ class SystemManager {
// or elsewhere could give us a blank block.
$link = $this->menuActiveTrail->getActiveLink('admin');
if ($link && $content = $this->getAdminBlock($link)) {
- $output = array(
+ $output = [
'#theme' => 'admin_block_content',
'#content' => $content,
- );
+ ];
}
else {
- $output = array(
+ $output = [
'#markup' => t('You do not have any administrative items.'),
- );
+ ];
}
return $output;
}
@@ -182,16 +182,16 @@ class SystemManager {
* An array of menu items, as expected by admin-block-content.html.twig.
*/
public function getAdminBlock(MenuLinkInterface $instance) {
- $content = array();
+ $content = [];
// Only find the children of this link.
$link_id = $instance->getPluginId();
$parameters = new MenuTreeParameters();
$parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
$tree = $this->menuTree->load(NULL, $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ];
$tree = $this->menuTree->transform($tree, $manipulators);
foreach ($tree as $key => $element) {
// Only render accessible links.
diff --git a/core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php b/core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php
index 4ca7390a1cb..cb45e2dcf0b 100644
--- a/core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php
+++ b/core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php
@@ -11,7 +11,7 @@ class AjaxInGroupTest extends AjaxTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array('access content')));
+ $this->drupalLogin($this->drupalCreateUser(['access content']));
}
/**
diff --git a/core/modules/system/src/Tests/Ajax/AjaxTestBase.php b/core/modules/system/src/Tests/Ajax/AjaxTestBase.php
index e4db3bd9c2e..66e06c88a46 100644
--- a/core/modules/system/src/Tests/Ajax/AjaxTestBase.php
+++ b/core/modules/system/src/Tests/Ajax/AjaxTestBase.php
@@ -14,7 +14,7 @@ abstract class AjaxTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'ajax_test', 'ajax_forms_test');
+ public static $modules = ['node', 'ajax_test', 'ajax_forms_test'];
/**
* Asserts the array of Ajax commands contains the searched command.
diff --git a/core/modules/system/src/Tests/Ajax/CommandsTest.php b/core/modules/system/src/Tests/Ajax/CommandsTest.php
index 7e26fa39d7f..b09d42a0447 100644
--- a/core/modules/system/src/Tests/Ajax/CommandsTest.php
+++ b/core/modules/system/src/Tests/Ajax/CommandsTest.php
@@ -34,89 +34,89 @@ class CommandsTest extends AjaxTestBase {
*/
function testAjaxCommands() {
$form_path = 'ajax_forms_test_ajax_commands_form';
- $web_user = $this->drupalCreateUser(array('access content'));
+ $web_user = $this->drupalCreateUser(['access content']);
$this->drupalLogin($web_user);
- $edit = array();
+ $edit = [];
// Tests the 'add_css' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'add_css' command")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'add_css' command")]);
$expected = new AddCssCommand('my/file.css');
$this->assertCommand($commands, $expected->render(), "'add_css' AJAX command issued with correct data.");
// Tests the 'after' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'After': Click to put something after the div")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'After': Click to put something after the div")]);
$expected = new AfterCommand('#after_div', 'This will be placed after');
$this->assertCommand($commands, $expected->render(), "'after' AJAX command issued with correct data.");
// Tests the 'alert' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'Alert': Click to alert")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'Alert': Click to alert")]);
$expected = new AlertCommand(t('Alert'));
$this->assertCommand($commands, $expected->render(), "'alert' AJAX Command issued with correct text.");
// Tests the 'append' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'Append': Click to append something")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'Append': Click to append something")]);
$expected = new AppendCommand('#append_div', 'Appended text');
$this->assertCommand($commands, $expected->render(), "'append' AJAX command issued with correct data.");
// Tests the 'before' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'before': Click to put something before the div")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'before': Click to put something before the div")]);
$expected = new BeforeCommand('#before_div', 'Before text');
$this->assertCommand($commands, $expected->render(), "'before' AJAX command issued with correct data.");
// Tests the 'changed' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX changed: Click to mark div changed.")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX changed: Click to mark div changed.")]);
$expected = new ChangedCommand('#changed_div');
$this->assertCommand($commands, $expected->render(), "'changed' AJAX command issued with correct selector.");
// Tests the 'changed' command using the second argument.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX changed: Click to mark div changed with asterisk.")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX changed: Click to mark div changed with asterisk.")]);
$expected = new ChangedCommand('#changed_div', '#changed_div_mark_this');
$this->assertCommand($commands, $expected->render(), "'changed' AJAX command (with asterisk) issued with correct selector.");
// Tests the 'css' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("Set the '#box' div to be blue.")));
- $expected = new CssCommand('#css_div', array('background-color' => 'blue'));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("Set the '#box' div to be blue.")]);
+ $expected = new CssCommand('#css_div', ['background-color' => 'blue']);
$this->assertCommand($commands, $expected->render(), "'css' AJAX command issued with correct selector.");
// Tests the 'data' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX data command: Issue command.")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX data command: Issue command.")]);
$expected = new DataCommand('#data_div', 'testkey', 'testvalue');
$this->assertCommand($commands, $expected->render(), "'data' AJAX command issued with correct key and value.");
// Tests the 'html' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX html: Replace the HTML in a selector.")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX html: Replace the HTML in a selector.")]);
$expected = new HtmlCommand('#html_div', 'replacement text');
$this->assertCommand($commands, $expected->render(), "'html' AJAX command issued with correct data.");
// Tests the 'insert' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX insert: Let client insert based on #ajax['method'].")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX insert: Let client insert based on #ajax['method'].")]);
$expected = new InsertCommand('#insert_div', 'insert replacement text');
$this->assertCommand($commands, $expected->render(), "'insert' AJAX command issued with correct data.");
// Tests the 'invoke' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX invoke command: Invoke addClass() method.")));
- $expected = new InvokeCommand('#invoke_div', 'addClass', array('error'));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX invoke command: Invoke addClass() method.")]);
+ $expected = new InvokeCommand('#invoke_div', 'addClass', ['error']);
$this->assertCommand($commands, $expected->render(), "'invoke' AJAX command issued with correct method and argument.");
// Tests the 'prepend' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'prepend': Click to prepend something")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'prepend': Click to prepend something")]);
$expected = new PrependCommand('#prepend_div', 'prepended text');
$this->assertCommand($commands, $expected->render(), "'prepend' AJAX command issued with correct data.");
// Tests the 'remove' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'remove': Click to remove text")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'remove': Click to remove text")]);
$expected = new RemoveCommand('#remove_text');
$this->assertCommand($commands, $expected->render(), "'remove' AJAX command issued with correct command and selector.");
// Tests the 'restripe' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'restripe' command")));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'restripe' command")]);
$expected = new RestripeCommand('#restripe_table');
$this->assertCommand($commands, $expected->render(), "'restripe' AJAX command issued with correct selector.");
// Tests the 'settings' command.
- $commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'settings' command")));
- $expected = new SettingsCommand(array('ajax_forms_test' => array('foo' => 42)));
+ $commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'settings' command")]);
+ $expected = new SettingsCommand(['ajax_forms_test' => ['foo' => 42]]);
$this->assertCommand($commands, $expected->render(), "'settings' AJAX command issued with correct data.");
}
diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php
index 254f01d33ae..ec947825fe2 100644
--- a/core/modules/system/src/Tests/Ajax/DialogTest.php
+++ b/core/modules/system/src/Tests/Ajax/DialogTest.php
@@ -19,72 +19,72 @@ class DialogTest extends AjaxTestBase {
*
* @var array
*/
- public static $modules = array('ajax_test', 'ajax_forms_test', 'contact');
+ public static $modules = ['ajax_test', 'ajax_forms_test', 'contact'];
/**
* Test sending non-JS and AJAX requests to open and manipulate modals.
*/
public function testDialog() {
- $this->drupalLogin($this->drupalCreateUser(array('administer contact forms')));
+ $this->drupalLogin($this->drupalCreateUser(['administer contact forms']));
// Ensure the elements render without notices or exceptions.
$this->drupalGet('ajax-test/dialog');
// Set up variables for this test.
$dialog_renderable = AjaxTestController::dialogContents();
$dialog_contents = \Drupal::service('renderer')->renderRoot($dialog_renderable);
- $modal_expected_response = array(
+ $modal_expected_response = [
'command' => 'openDialog',
'selector' => '#drupal-modal',
'settings' => NULL,
'data' => $dialog_contents,
- 'dialogOptions' => array(
+ 'dialogOptions' => [
'modal' => TRUE,
'title' => 'AJAX Dialog & contents',
- ),
- );
- $form_expected_response = array(
+ ],
+ ];
+ $form_expected_response = [
'command' => 'openDialog',
'selector' => '#drupal-modal',
'settings' => NULL,
- 'dialogOptions' => array(
+ 'dialogOptions' => [
'modal' => TRUE,
'title' => 'Ajax Form contents',
- ),
- );
- $entity_form_expected_response = array(
+ ],
+ ];
+ $entity_form_expected_response = [
'command' => 'openDialog',
'selector' => '#drupal-modal',
'settings' => NULL,
- 'dialogOptions' => array(
+ 'dialogOptions' => [
'modal' => TRUE,
'title' => 'Add contact form',
- ),
- );
- $normal_expected_response = array(
+ ],
+ ];
+ $normal_expected_response = [
'command' => 'openDialog',
'selector' => '#ajax-test-dialog-wrapper-1',
'settings' => NULL,
'data' => $dialog_contents,
- 'dialogOptions' => array(
+ 'dialogOptions' => [
'modal' => FALSE,
'title' => 'AJAX Dialog & contents',
- ),
- );
- $no_target_expected_response = array(
+ ],
+ ];
+ $no_target_expected_response = [
'command' => 'openDialog',
'selector' => '#drupal-dialog-ajax-testdialog-contents',
'settings' => NULL,
'data' => $dialog_contents,
- 'dialogOptions' => array(
+ 'dialogOptions' => [
'modal' => FALSE,
'title' => 'AJAX Dialog & contents',
- ),
- );
- $close_expected_response = array(
+ ],
+ ];
+ $close_expected_response = [
'command' => 'closeDialog',
'selector' => '#ajax-test-dialog-wrapper-1',
'persist' => FALSE,
- );
+ ];
// Check that requesting a modal dialog without JS goes to a page.
$this->drupalGet('ajax-test/dialog-contents');
@@ -95,7 +95,7 @@ class DialogTest extends AjaxTestBase {
$this->assertRaw($dialog_contents, 'Modal dialog page on XMLHttpRequest present.');
// Emulate going to the JS version of the page and check the JSON response.
- $ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
+ $ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
$this->assertEqual($modal_expected_response, $ajax_result[3], 'Modal dialog JSON response matches.');
// Test the HTML escaping of & character.
$this->assertEqual($ajax_result[3]['dialogOptions']['title'], 'AJAX Dialog & contents');
@@ -108,26 +108,26 @@ class DialogTest extends AjaxTestBase {
// Emulate going to the JS version of the page and check the JSON response.
// This needs to use WebTestBase::drupalPostAjaxForm() so that the correct
// dialog options are sent.
- $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(
+ $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [
// We have to mock a form element to make drupalPost submit from a link.
'textfield' => 'test',
- ), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog')), array(), NULL, array(
- 'submit' => array(
+ ], [], 'ajax-test/dialog-contents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']], [], NULL, [
+ 'submit' => [
'dialogOptions[target]' => 'ajax-test-dialog-wrapper-1',
- )
- ));
+ ]
+ ]);
$this->assertEqual($normal_expected_response, $ajax_result[3], 'Normal dialog JSON response matches.');
// Emulate going to the JS version of the page and check the JSON response.
// This needs to use WebTestBase::drupalPostAjaxForm() so that the correct
// dialog options are sent.
- $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(
+ $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [
// We have to mock a form element to make drupalPost submit from a link.
'textfield' => 'test',
- ), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog')), array(), NULL, array(
+ ], [], 'ajax-test/dialog-contents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']], [], NULL, [
// Don't send a target.
- 'submit' => array()
- ));
+ 'submit' => []
+ ]);
// Make sure the selector ID starts with the right string.
$this->assert(strpos($ajax_result[3]['selector'], $no_target_expected_response['selector']) === 0, 'Selector starts with right string.');
unset($ajax_result[3]['selector']);
@@ -142,7 +142,7 @@ class DialogTest extends AjaxTestBase {
// Test submitting via a POST request through the button for modals. This
// approach more accurately reflects the real responses by Drupal because
// all of the necessary page variables are emulated.
- $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(), 'button1');
+ $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [], 'button1');
// Check that CSS and JavaScript are "added" to the page dynamically.
$this->assertTrue(in_array('core/drupal.dialog.ajax', explode(',', $ajax_result[0]['settings']['ajaxPageState']['libraries'])), 'core/drupal.dialog.ajax library is added to the page.');
@@ -159,7 +159,7 @@ class DialogTest extends AjaxTestBase {
$this->assertNotEqual($ajax_result[4]['dialogOptions']['title'], 'AJAX Dialog &amp; contents');
// Abbreviated test for "normal" dialogs, testing only the difference.
- $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(), 'button2');
+ $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [], 'button2');
$this->assertEqual($normal_expected_response, $ajax_result[4], 'POST request normal dialog JSON response matches.');
// Check that requesting a form dialog without JS goes to a page.
@@ -170,7 +170,7 @@ class DialogTest extends AjaxTestBase {
$this->assertTrue(!empty($form), 'Non-JS form page present.');
// Emulate going to the JS version of the form and check the JSON response.
- $ajax_result = $this->drupalGetAjax('ajax-test/dialog-form', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
+ $ajax_result = $this->drupalGetAjax('ajax-test/dialog-form', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
$expected_ajax_settings = [
'edit-preview' => [
'callback' => '::preview',
@@ -202,7 +202,7 @@ class DialogTest extends AjaxTestBase {
$this->assertTrue(!empty($form), 'Non-JS entity form page present.');
// Emulate going to the JS version of the form and check the JSON response.
- $ajax_result = $this->drupalGetAjax('admin/structure/contact/add', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
+ $ajax_result = $this->drupalGetAjax('admin/structure/contact/add', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
$this->setRawContent($ajax_result[3]['data']);
// Remove the data, the form build id and token will never match.
unset($ajax_result[3]['data']);
diff --git a/core/modules/system/src/Tests/Ajax/ElementValidationTest.php b/core/modules/system/src/Tests/Ajax/ElementValidationTest.php
index 5133ce3767e..ceb5405c167 100644
--- a/core/modules/system/src/Tests/Ajax/ElementValidationTest.php
+++ b/core/modules/system/src/Tests/Ajax/ElementValidationTest.php
@@ -17,7 +17,7 @@ class ElementValidationTest extends AjaxTestBase {
* Ajax-enabled field fails due to the required field being empty.
*/
function testAjaxElementValidation() {
- $edit = array('drivertext' => t('some dumb text'));
+ $edit = ['drivertext' => t('some dumb text')];
// Post with 'drivertext' as the triggering element.
$this->drupalPostAjaxForm('ajax_validation_test', $edit, 'drivertext');
@@ -26,7 +26,7 @@ class ElementValidationTest extends AjaxTestBase {
$this->assertText('ajax_forms_test_validation_form_callback invoked', 'The correct callback was invoked');
$this->drupalGet('ajax_validation_test');
- $edit = array('drivernumber' => 12345);
+ $edit = ['drivernumber' => 12345];
// Post with 'drivernumber' as the triggering element.
$this->drupalPostAjaxForm('ajax_validation_test', $edit, 'drivernumber');
diff --git a/core/modules/system/src/Tests/Ajax/FormValuesTest.php b/core/modules/system/src/Tests/Ajax/FormValuesTest.php
index 0a23db18432..3d7bc91bced 100644
--- a/core/modules/system/src/Tests/Ajax/FormValuesTest.php
+++ b/core/modules/system/src/Tests/Ajax/FormValuesTest.php
@@ -13,7 +13,7 @@ class FormValuesTest extends AjaxTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array('access content')));
+ $this->drupalLogin($this->drupalCreateUser(['access content']));
}
/**
@@ -21,20 +21,20 @@ class FormValuesTest extends AjaxTestBase {
*/
function testSimpleAjaxFormValue() {
// Verify form values of a select element.
- foreach (array('red', 'green', 'blue') as $item) {
- $edit = array(
+ foreach (['red', 'green', 'blue'] as $item) {
+ $edit = [
'select' => $item,
- );
+ ];
$commands = $this->drupalPostAjaxForm('ajax_forms_test_get_form', $edit, 'select');
$expected = new DataCommand('#ajax_selected_color', 'form_state_value_select', $item);
$this->assertCommand($commands, $expected->render(), 'Verification of AJAX form values from a selectbox issued with a correct value.');
}
// Verify form values of a checkbox element.
- foreach (array(FALSE, TRUE) as $item) {
- $edit = array(
+ foreach ([FALSE, TRUE] as $item) {
+ $edit = [
'checkbox' => $item,
- );
+ ];
$commands = $this->drupalPostAjaxForm('ajax_forms_test_get_form', $edit, 'checkbox');
$expected = new DataCommand('#ajax_checkbox_value', 'form_state_value_select', (int) $item);
$this->assertCommand($commands, $expected->render(), 'Verification of AJAX form values from a checkbox issued with a correct value.');
@@ -46,11 +46,11 @@ class FormValuesTest extends AjaxTestBase {
// We don't need to check for the X-Drupal-Ajax-Token header with these
// invalid requests.
$this->assertAjaxHeader = FALSE;
- foreach (array('null', 'empty', 'nonexistent') as $key) {
+ foreach (['null', 'empty', 'nonexistent'] as $key) {
$element_name = 'select_' . $key . '_callback';
- $edit = array(
+ $edit = [
$element_name => 'red',
- );
+ ];
$commands = $this->drupalPostAjaxForm('ajax_forms_test_get_form', $edit, $element_name);
$this->assertResponse(500);
}
diff --git a/core/modules/system/src/Tests/Ajax/FrameworkTest.php b/core/modules/system/src/Tests/Ajax/FrameworkTest.php
index fb59bcc5887..14bae064429 100644
--- a/core/modules/system/src/Tests/Ajax/FrameworkTest.php
+++ b/core/modules/system/src/Tests/Ajax/FrameworkTest.php
@@ -22,7 +22,7 @@ class FrameworkTest extends AjaxTestBase {
public function testAJAXRender() {
// Verify that settings command is generated if JavaScript settings exist.
$commands = $this->drupalGetAjax('ajax-test/render');
- $expected = new SettingsCommand(array('ajax' => 'test'), TRUE);
+ $expected = new SettingsCommand(['ajax' => 'test'], TRUE);
$this->assertCommand($commands, $expected->render(), 'JavaScript settings command is present.');
}
@@ -30,14 +30,14 @@ class FrameworkTest extends AjaxTestBase {
* Tests AjaxResponse::prepare() AJAX commands ordering.
*/
public function testOrder() {
- $expected_commands = array();
+ $expected_commands = [];
// Expected commands, in a very specific order.
$asset_resolver = \Drupal::service('asset.resolver');
$css_collection_renderer = \Drupal::service('asset.css.collection_renderer');
$js_collection_renderer = \Drupal::service('asset.js.collection_renderer');
$renderer = \Drupal::service('renderer');
- $expected_commands[0] = new SettingsCommand(array('ajax' => 'test'), TRUE);
+ $expected_commands[0] = new SettingsCommand(['ajax' => 'test'], TRUE);
$build['#attached']['library'][] = 'ajax_test/order-css-command';
$assets = AttachedAssets::createFromRenderArray($build);
$css_render_array = $css_collection_renderer->render($asset_resolver->getCssAssets($assets, FALSE));
@@ -65,7 +65,7 @@ class FrameworkTest extends AjaxTestBase {
// 3. JavaScript files in the header
// 4. JavaScript files in the footer
// 5. Any other AJAX commands, in whatever order they were added.
- $commands = $this->drupalPostAjaxForm(NULL, array(), NULL, 'ajax-test/order', array(), array(), NULL, array());
+ $commands = $this->drupalPostAjaxForm(NULL, [], NULL, 'ajax-test/order', [], [], NULL, []);
$this->assertCommand(array_slice($commands, 0, 1), $expected_commands[0]->render(), 'Settings command is first.');
$this->assertCommand(array_slice($commands, 1, 1), $expected_commands[1]->render(), 'CSS command is second (and CSS files are ordered correctly).');
$this->assertCommand(array_slice($commands, 2, 1), $expected_commands[2]->render(), 'Header JS command is third.');
@@ -78,10 +78,10 @@ class FrameworkTest extends AjaxTestBase {
*/
public function testAJAXRenderError() {
// Verify custom error message.
- $edit = array(
+ $edit = [
'message' => 'Custom error message.',
- );
- $commands = $this->drupalGetAjax('ajax-test/render-error', array('query' => $edit));
+ ];
+ $commands = $this->drupalGetAjax('ajax-test/render-error', ['query' => $edit]);
$expected = new AlertCommand($edit['message']);
$this->assertCommand($commands, $expected->render(), 'Custom error message is output.');
}
@@ -95,12 +95,12 @@ class FrameworkTest extends AjaxTestBase {
$js_collection_renderer = \Drupal::service('asset.js.collection_renderer');
$renderer = \Drupal::service('renderer');
- $expected = array(
+ $expected = [
'setting_name' => 'ajax_forms_test_lazy_load_form_submit',
'setting_value' => 'executed',
'library_1' => 'system/admin',
'library_2' => 'system/drupal.system',
- );
+ ];
// Get the base page.
$this->drupalGet('ajax_forms_test_lazy_load_form');
@@ -109,9 +109,9 @@ class FrameworkTest extends AjaxTestBase {
// Verify that the base page doesn't have the settings and files that are to
// be lazy loaded as part of the next requests.
- $this->assertTrue(!isset($original_settings[$expected['setting_name']]), format_string('Page originally lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
- $this->assertTrue(!in_array($expected['library_1'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
- $this->assertTrue(!in_array($expected['library_2'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
+ $this->assertTrue(!isset($original_settings[$expected['setting_name']]), format_string('Page originally lacks the %setting, as expected.', ['%setting' => $expected['setting_name']]));
+ $this->assertTrue(!in_array($expected['library_1'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_1']]));
+ $this->assertTrue(!in_array($expected['library_2'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_2']]));
// Calculate the expected CSS and JS.
$assets = new AttachedAssets();
@@ -128,14 +128,14 @@ class FrameworkTest extends AjaxTestBase {
$expected_js_html = $renderer->renderRoot($js_render_array);
// Submit the AJAX request without triggering files getting added.
- $commands = $this->drupalPostAjaxForm(NULL, array('add_files' => FALSE), array('op' => t('Submit')));
+ $commands = $this->drupalPostAjaxForm(NULL, ['add_files' => FALSE], ['op' => t('Submit')]);
$new_settings = $this->getDrupalSettings();
$new_libraries = explode(',', $new_settings['ajaxPageState']['libraries']);
// Verify the setting was not added when not expected.
- $this->assertTrue(!isset($new_settings[$expected['setting_name']]), format_string('Page still lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
- $this->assertTrue(!in_array($expected['library_1'], $new_libraries), format_string('Page still lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
- $this->assertTrue(!in_array($expected['library_2'], $new_libraries), format_string('Page still lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
+ $this->assertTrue(!isset($new_settings[$expected['setting_name']]), format_string('Page still lacks the %setting, as expected.', ['%setting' => $expected['setting_name']]));
+ $this->assertTrue(!in_array($expected['library_1'], $new_libraries), format_string('Page still lacks the %library library, as expected.', ['%library' => $expected['library_1']]));
+ $this->assertTrue(!in_array($expected['library_2'], $new_libraries), format_string('Page still lacks the %library library, as expected.', ['%library' => $expected['library_2']]));
// Verify a settings command does not add CSS or scripts to drupalSettings
// and no command inserts the corresponding tags on the page.
$found_settings_command = FALSE;
@@ -148,24 +148,24 @@ class FrameworkTest extends AjaxTestBase {
$found_markup_command = TRUE;
}
}
- $this->assertFalse($found_settings_command, format_string('Page state still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
- $this->assertFalse($found_markup_command, format_string('Page still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
+ $this->assertFalse($found_settings_command, format_string('Page state still lacks the %library_1 and %library_2 libraries, as expected.', ['%library_1' => $expected['library_1'], '%library_2' => $expected['library_2']]));
+ $this->assertFalse($found_markup_command, format_string('Page still lacks the %library_1 and %library_2 libraries, as expected.', ['%library_1' => $expected['library_1'], '%library_2' => $expected['library_2']]));
// Submit the AJAX request and trigger adding files.
- $commands = $this->drupalPostAjaxForm(NULL, array('add_files' => TRUE), array('op' => t('Submit')));
+ $commands = $this->drupalPostAjaxForm(NULL, ['add_files' => TRUE], ['op' => t('Submit')]);
$new_settings = $this->getDrupalSettings();
$new_libraries = explode(',', $new_settings['ajaxPageState']['libraries']);
// Verify the expected setting was added, both to drupalSettings, and as
// the first AJAX command.
- $this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], format_string('Page now has the %setting.', array('%setting' => $expected['setting_name'])));
- $expected_command = new SettingsCommand(array($expected['setting_name'] => $expected['setting_value']), TRUE);
+ $this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], format_string('Page now has the %setting.', ['%setting' => $expected['setting_name']]));
+ $expected_command = new SettingsCommand([$expected['setting_name'] => $expected['setting_value']], TRUE);
$this->assertCommand(array_slice($commands, 0, 1), $expected_command->render(), 'The settings command was first.');
// Verify the expected CSS file was added, both to drupalSettings, and as
// the second AJAX command for inclusion into the HTML.
- $this->assertTrue(in_array($expected['library_1'], $new_libraries), format_string('Page state now has the %library library.', array('%library' => $expected['library_1'])));
- $this->assertCommand(array_slice($commands, 1, 1), array('data' => $expected_css_html), format_string('Page now has the %library library.', array('%library' => $expected['library_1'])));
+ $this->assertTrue(in_array($expected['library_1'], $new_libraries), format_string('Page state now has the %library library.', ['%library' => $expected['library_1']]));
+ $this->assertCommand(array_slice($commands, 1, 1), ['data' => $expected_css_html], format_string('Page now has the %library library.', ['%library' => $expected['library_1']]));
// Verify the expected JS file was added, both to drupalSettings, and as
// the third AJAX command for inclusion into the HTML. By testing for an
@@ -173,15 +173,15 @@ class FrameworkTest extends AjaxTestBase {
// unexpected JavaScript code, such as a jQuery.extend() that would
// potentially clobber rather than properly merge settings, didn't
// accidentally get added.
- $this->assertTrue(in_array($expected['library_2'], $new_libraries), format_string('Page state now has the %library library.', array('%library' => $expected['library_2'])));
- $this->assertCommand(array_slice($commands, 2, 1), array('data' => $expected_js_html), format_string('Page now has the %library library.', array('%library' => $expected['library_2'])));
+ $this->assertTrue(in_array($expected['library_2'], $new_libraries), format_string('Page state now has the %library library.', ['%library' => $expected['library_2']]));
+ $this->assertCommand(array_slice($commands, 2, 1), ['data' => $expected_js_html], format_string('Page now has the %library library.', ['%library' => $expected['library_2']]));
}
/**
* Tests that drupalSettings.currentPath is not updated on AJAX requests.
*/
public function testCurrentPathChange() {
- $commands = $this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', array('add_files' => FALSE), array('op' => t('Submit')));
+ $commands = $this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', ['add_files' => FALSE], ['op' => t('Submit')]);
foreach ($commands as $command) {
if ($command['command'] == 'settings') {
$this->assertFalse(isset($command['settings']['currentPath']), 'Value of drupalSettings.currentPath is not updated after an AJAX request.');
@@ -195,14 +195,14 @@ class FrameworkTest extends AjaxTestBase {
public function testLazyLoadOverriddenCSS() {
// The test theme overrides js.module.css without an implementation,
// thereby removing it.
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
$this->config('system.theme')
->set('default', 'test_theme')
->save();
// This gets the form, and emulates an Ajax submission on it, including
// adding markup to the HEAD and BODY for any lazy loaded JS/CSS files.
- $this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', array('add_files' => TRUE), array('op' => t('Submit')));
+ $this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', ['add_files' => TRUE], ['op' => t('Submit')]);
// Verify that the resulting HTML does not load the overridden CSS file.
// We add a "?" to the assertion, because drupalSettings may include
diff --git a/core/modules/system/src/Tests/Ajax/MultiFormTest.php b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
index e07204cc7fd..59f60bf5719 100644
--- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php
+++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
@@ -19,32 +19,32 @@ class MultiFormTest extends AjaxTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Page']);
// Create a multi-valued field for 'page' nodes to use for Ajax testing.
$field_name = 'field_ajax_test';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'node',
'field_name' => $field_name,
'type' => 'text',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
])->save();
entity_get_form_display('node', 'page', 'default')
- ->setComponent($field_name, array('type' => 'text_textfield'))
+ ->setComponent($field_name, ['type' => 'text_textfield'])
->save();
// Log in a user who can create 'page' nodes.
- $this->drupalLogin ($this->drupalCreateUser(array('create page content')));
+ $this->drupalLogin ($this->drupalCreateUser(['create page content']));
}
/**
@@ -84,7 +84,7 @@ class MultiFormTest extends AjaxTestBase {
$forms = $this->xpath($form_xpath);
foreach ($forms as $offset => $form) {
$form_html_id = (string) $form['id'];
- $this->drupalPostAjaxForm(NULL, array(), array($button_name => $button_value), NULL, array(), array(), $form_html_id);
+ $this->drupalPostAjaxForm(NULL, [], [$button_name => $button_value], NULL, [], [], $form_html_id);
$form = $this->xpath($form_xpath)[$offset];
$field = $form->xpath('.' . $field_xpath);
diff --git a/core/modules/system/src/Tests/Batch/PageTest.php b/core/modules/system/src/Tests/Batch/PageTest.php
index f9948ed5e3c..0f24c0fd807 100644
--- a/core/modules/system/src/Tests/Batch/PageTest.php
+++ b/core/modules/system/src/Tests/Batch/PageTest.php
@@ -16,7 +16,7 @@ class PageTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('batch_test');
+ public static $modules = ['batch_test'];
/**
* Tests that the batch API progress page uses the correct theme.
@@ -24,14 +24,14 @@ class PageTest extends WebTestBase {
function testBatchProgressPageTheme() {
// Make sure that the page which starts the batch (an administrative page)
// is using a different theme than would normally be used by the batch API.
- $this->container->get('theme_handler')->install(array('seven', 'bartik'));
+ $this->container->get('theme_handler')->install(['seven', 'bartik']);
$this->config('system.theme')
->set('default', 'bartik')
->set('admin', 'seven')
->save();
// Log in as an administrator who can see the administrative theme.
- $admin_user = $this->drupalCreateUser(array('view the administration theme'));
+ $admin_user = $this->drupalCreateUser(['view the administration theme']);
$this->drupalLogin($admin_user);
// Visit an administrative page that runs a test batch, and check that the
// theme that was used during batch execution (which the batch callback
@@ -40,7 +40,7 @@ class PageTest extends WebTestBase {
$this->drupalGet('admin/batch-test/test-theme');
// The stack should contain the name of the theme used on the progress
// page.
- $this->assertEqual(batch_test_stack(), array('seven'), 'A progressive batch correctly uses the theme of the page that started the batch.');
+ $this->assertEqual(batch_test_stack(), ['seven'], 'A progressive batch correctly uses the theme of the page that started the batch.');
}
/**
diff --git a/core/modules/system/src/Tests/Batch/ProcessingTest.php b/core/modules/system/src/Tests/Batch/ProcessingTest.php
index fcdb98cc863..53557ed7a82 100644
--- a/core/modules/system/src/Tests/Batch/ProcessingTest.php
+++ b/core/modules/system/src/Tests/Batch/ProcessingTest.php
@@ -17,7 +17,7 @@ class ProcessingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('batch_test', 'test_page_test');
+ public static $modules = ['batch_test', 'test_page_test'];
/**
* Tests batches triggered outside of form submission.
@@ -47,14 +47,14 @@ class ProcessingTest extends WebTestBase {
*/
function testBatchForm() {
// Batch 0: no operation.
- $edit = array('batch' => 'batch_0');
+ $edit = ['batch' => 'batch_0'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
$this->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_0'), 'Batch with no operation performed successfully.');
$this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 1: several simple operations.
- $edit = array('batch' => 'batch_1');
+ $edit = ['batch' => 'batch_1'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
$this->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch with simple operations performed successfully.');
@@ -62,7 +62,7 @@ class ProcessingTest extends WebTestBase {
$this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 2: one multistep operation.
- $edit = array('batch' => 'batch_2');
+ $edit = ['batch' => 'batch_2'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
$this->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch with multistep operation performed successfully.');
@@ -70,7 +70,7 @@ class ProcessingTest extends WebTestBase {
$this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 3: simple + multistep combined.
- $edit = array('batch' => 'batch_3');
+ $edit = ['batch' => 'batch_3'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
$this->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_3'), 'Batch with simple and multistep operations performed successfully.');
@@ -78,7 +78,7 @@ class ProcessingTest extends WebTestBase {
$this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 4: nested batch.
- $edit = array('batch' => 'batch_4');
+ $edit = ['batch' => 'batch_4'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
$this->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_4'), 'Nested batch performed successfully.');
@@ -95,14 +95,14 @@ class ProcessingTest extends WebTestBase {
$this->assertText('step 1', 'Form is displayed in step 1.');
// First step triggers batch 1.
- $this->drupalPostForm(NULL, array(), 'Submit');
+ $this->drupalPostForm(NULL, [], 'Submit');
$this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch for step 1 performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.');
$this->assertText('step 2', 'Form is displayed in step 2.');
$this->assertNoEscaped('<', 'No escaped markup is present.');
// Second step triggers batch 2.
- $this->drupalPostForm(NULL, array(), 'Submit');
+ $this->drupalPostForm(NULL, [], 'Submit');
$this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch for step 2 performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_2'), 'Execution order was correct.');
$this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
@@ -111,7 +111,7 @@ class ProcessingTest extends WebTestBase {
// Extra query arguments will trigger logic that will add them to the
// redirect URL. Make sure they are persisted.
$this->drupalGet('batch-test/multistep', ['query' => ['big_tree' => 'small_axe']]);
- $this->drupalPostForm(NULL, array(), 'Submit');
+ $this->drupalPostForm(NULL, [], 'Submit');
$this->assertText('step 2', 'Form is displayed in step 2.');
$this->assertTrue(strpos($this->getUrl(), 'batch-test/multistep?big_tree=small_axe'), 'Query argument was persisted and another extra argument was added.');
}
@@ -123,7 +123,7 @@ class ProcessingTest extends WebTestBase {
// Batches 1, 2 and 3 are triggered in sequence by different submit
// handlers. Each submit handler modify the submitted 'value'.
$value = rand(0, 255);
- $edit = array('value' => $value);
+ $edit = ['value' => $value];
$this->drupalPostForm('batch-test/chained', $edit, 'Submit');
// Check that result messages are present and in the correct order.
$this->assertBatchMessages($this->_resultMessages('chained'), 'Batches defined in separate submit handlers performed successfully.');
@@ -159,7 +159,7 @@ class ProcessingTest extends WebTestBase {
// form.
$value = rand(0, 255);
$this->drupalGet('batch-test/nested-programmatic/' . $value);
- $this->assertEqual(batch_test_stack(), array('mock form submitted with value = ' . $value), '\Drupal::formBuilder()->submitForm() ran successfully within a batch operation.');
+ $this->assertEqual(batch_test_stack(), ['mock form submitted with value = ' . $value], '\Drupal::formBuilder()->submitForm() ran successfully within a batch operation.');
}
/**
@@ -196,7 +196,7 @@ class ProcessingTest extends WebTestBase {
* Returns expected execution stacks for the test batches.
*/
function _resultStack($id, $value = 0) {
- $stack = array();
+ $stack = [];
switch ($id) {
case 'batch_1':
for ($i = 1; $i <= 10; $i++) {
@@ -263,7 +263,7 @@ class ProcessingTest extends WebTestBase {
* Returns expected result messages for the test batches.
*/
function _resultMessages($id) {
- $messages = array();
+ $messages = [];
switch ($id) {
case 'batch_0':
diff --git a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
index c216e9bcfd5..6bea791e910 100644
--- a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
+++ b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
@@ -89,7 +89,7 @@ trait AssertPageCacheContextsAndTagsTrait {
$this->assertCacheContexts($expected_contexts);
// Assert page cache item + expected cache tags.
- $cid_parts = array($url->setAbsolute()->toString(), 'html');
+ $cid_parts = [$url->setAbsolute()->toString(), 'html'];
$cid = implode(':', $cid_parts);
$cache_entry = \Drupal::cache('render')->get($cid);
sort($cache_entry->tags);
diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
index 6c3d98f7138..c30ceffa91e 100644
--- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
+++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
@@ -105,7 +105,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
}
protected function setUp() {
- $this->cachebackends = array();
+ $this->cachebackends = [];
$this->defaultValue = $this->randomMachineName(10);
parent::setUp();
@@ -134,7 +134,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend = $this->getCacheBackend();
$this->assertIdentical(FALSE, $backend->get('test1'), "Backend does not contain data for cache id test1.");
- $with_backslash = array('foo' => '\Drupal\foo\Bar');
+ $with_backslash = ['foo' => '\Drupal\foo\Bar'];
$backend->set('test1', $with_backslash);
$cached = $backend->get('test1');
$this->assert(is_object($cached), "Backend returned an object for cache id test1.");
@@ -145,10 +145,10 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
$this->assertIdentical(FALSE, $backend->get('test2'), "Backend does not contain data for cache id test2.");
- $backend->set('test2', array('value' => 3), REQUEST_TIME + 3);
+ $backend->set('test2', ['value' => 3], REQUEST_TIME + 3);
$cached = $backend->get('test2');
$this->assert(is_object($cached), "Backend returned an object for cache id test2.");
- $this->assertIdentical(array('value' => 3), $cached->data);
+ $this->assertIdentical(['value' => 3], $cached->data);
$this->assertTrue($cached->valid, 'Item is marked as valid.');
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
$this->assertEqual($cached->expire, REQUEST_TIME + 3, 'Expire time is correct.');
@@ -162,7 +162,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertEqual($cached->expire, REQUEST_TIME - 3, 'Expire time is correct.');
$this->assertIdentical(FALSE, $backend->get('test4'), "Backend does not contain data for cache id test4.");
- $with_eof = array('foo' => "\nEOF\ndata");
+ $with_eof = ['foo' => "\nEOF\ndata"];
$backend->set('test4', $with_eof);
$cached = $backend->get('test4');
$this->assert(is_object($cached), "Backend returned an object for cache id test4.");
@@ -172,7 +172,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
$this->assertIdentical(FALSE, $backend->get('test5'), "Backend does not contain data for cache id test5.");
- $with_eof_and_semicolon = array('foo' => "\nEOF;\ndata");
+ $with_eof_and_semicolon = ['foo' => "\nEOF;\ndata"];
$backend->set('test5', $with_eof_and_semicolon);
$cached = $backend->get('test5');
$this->assert(is_object($cached), "Backend returned an object for cache id test5.");
@@ -181,7 +181,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
- $with_variable = array('foo' => '$bar');
+ $with_variable = ['foo' => '$bar'];
$backend->set('test6', $with_variable);
$cached = $backend->get('test6');
$this->assert(is_object($cached), "Backend returned an object for cache id test6.");
@@ -260,14 +260,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
public function testValueTypeIsKept() {
$backend = $this->getCacheBackend();
- $variables = array(
+ $variables = [
'test1' => 1,
'test2' => '0',
'test3' => '',
'test4' => 12.64,
'test5' => FALSE,
- 'test6' => array(1, 2, 3),
- );
+ 'test6' => [1, 2, 3],
+ ];
// Create cache entries.
foreach ($variables as $cid => $data) {
@@ -300,14 +300,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend->set($long_cid, 300);
// Mismatch order for harder testing.
- $reference = array(
+ $reference = [
'test3',
'test7',
'test21', // Cid does not exist.
'test6',
'test19', // Cid does not exist until added before second getMultiple().
'test2',
- );
+ ];
$cids = $reference;
$ret = $backend->getMultiple($cids);
@@ -367,7 +367,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertFalse(in_array('test19', $cids), "Added cache id test19 is not in cids array.");
// Test with a long $cid and non-numeric array key.
- $cids = array('key:key' => $long_cid);
+ $cids = ['key:key' => $long_cid];
$return = $backend->getMultiple($cids);
$this->assertEqual(300, $return[$long_cid]->data);
$this->assertTrue(empty($cids));
@@ -383,13 +383,13 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
// Set multiple testing keys.
$backend->set('cid_1', 'Some other value');
- $items = array(
- 'cid_1' => array('data' => 1),
- 'cid_2' => array('data' => 2),
- 'cid_3' => array('data' => array(1, 2)),
- 'cid_4' => array('data' => 1, 'expire' => $future_expiration),
- 'cid_5' => array('data' => 1, 'tags' => array('test:a', 'test:b')),
- );
+ $items = [
+ 'cid_1' => ['data' => 1],
+ 'cid_2' => ['data' => 2],
+ 'cid_3' => ['data' => [1, 2]],
+ 'cid_4' => ['data' => 1, 'expire' => $future_expiration],
+ 'cid_5' => ['data' => 1, 'tags' => ['test:a', 'test:b']],
+ ];
$backend->setMultiple($items);
$cids = array_keys($items);
$cached = $backend->getMultiple($cids);
@@ -414,9 +414,9 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
// assertion.
try {
$items = [
- 'exception_test_1' => array('data' => 1, 'tags' => []),
- 'exception_test_2' => array('data' => 2, 'tags' => ['valid']),
- 'exception_test_3' => array('data' => 3, 'tags' => ['node' => [3, 5, 7]]),
+ 'exception_test_1' => ['data' => 1, 'tags' => []],
+ 'exception_test_2' => ['data' => 2, 'tags' => ['valid']],
+ 'exception_test_3' => ['data' => 3, 'tags' => ['node' => [3, 5, 7]]],
];
$backend->setMultiple($items);
$this->fail('::setMultiple() was called with invalid cache tags, runtime assertion did not fail.');
@@ -444,13 +444,13 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend->delete('test1');
$backend->delete('test23'); // Nonexistent key should not cause an error.
- $backend->deleteMultiple(array(
+ $backend->deleteMultiple([
'test3',
'test5',
'test7',
'test19', // Nonexistent key should not cause an error.
'test21', // Nonexistent key should not cause an error.
- ));
+ ]);
// Test if expected keys have been deleted.
$this->assertIdentical(FALSE, $backend->get('test1'), "Cache id test1 deleted.");
@@ -468,7 +468,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertIdentical(FALSE, $backend->get('test21'), "Cache id test21 does not exist.");
// Calling deleteMultiple() with an empty array should not cause an error.
- $this->assertFalse($backend->deleteMultiple(array()));
+ $this->assertFalse($backend->deleteMultiple([]));
}
/**
@@ -501,14 +501,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend->set('test3', 2);
$backend->set('test4', 2);
- $reference = array('test1', 'test2', 'test3', 'test4');
+ $reference = ['test1', 'test2', 'test3', 'test4'];
$cids = $reference;
$ret = $backend->getMultiple($cids);
$this->assertEqual(count($ret), 4, 'Four items returned.');
$backend->invalidate('test1');
- $backend->invalidateMultiple(array('test2', 'test3'));
+ $backend->invalidateMultiple(['test2', 'test3']);
$cids = $reference;
$ret = $backend->getMultiple($cids);
@@ -520,7 +520,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
// Calling invalidateMultiple() with an empty array should not cause an
// error.
- $this->assertFalse($backend->invalidateMultiple(array()));
+ $this->assertFalse($backend->invalidateMultiple([]));
}
/**
@@ -530,45 +530,45 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend = $this->getCacheBackend();
// Create two cache entries with the same tag and tag value.
- $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
- $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
+ $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
+ $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
// Invalidate test_tag of value 1. This should invalidate both entries.
- Cache::invalidateTags(array('test_tag:2'));
+ Cache::invalidateTags(['test_tag:2']);
$this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two cache items invalidated after invalidating a cache tag.');
$this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
// Create two cache entries with the same tag and an array tag value.
- $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
- $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
+ $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
+ $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
// Invalidate test_tag of value 1. This should invalidate both entries.
- Cache::invalidateTags(array('test_tag:1'));
+ Cache::invalidateTags(['test_tag:1']);
$this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two caches removed after invalidating a cache tag.');
$this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
// Create three cache entries with a mix of tags and tag values.
- $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
- $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
- $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, array('test_tag_foo:3'));
+ $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
+ $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
+ $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, ['test_tag_foo:3']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2') && $backend->get('test_cid_invalidate3'), 'Three cached items were created.');
- Cache::invalidateTags(array('test_tag_foo:3'));
+ Cache::invalidateTags(['test_tag_foo:3']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Cache items not matching the tag were not invalidated.');
$this->assertFalse($backend->get('test_cid_invalidated3'), 'Cached item matching the tag was removed.');
// Create cache entry in multiple bins. Two cache entries
// (test_cid_invalidate1 and test_cid_invalidate2) still exist from previous
// tests.
- $tags = array('test_tag:1', 'test_tag:2', 'test_tag:3');
- $bins = array('path', 'bootstrap', 'page');
+ $tags = ['test_tag:1', 'test_tag:2', 'test_tag:3'];
+ $bins = ['path', 'bootstrap', 'page'];
foreach ($bins as $bin) {
$this->getCacheBackend($bin)->set('test', $this->defaultValue, Cache::PERMANENT, $tags);
$this->assertTrue($this->getCacheBackend($bin)->get('test'), 'Cache item was set in bin.');
}
- Cache::invalidateTags(array('test_tag:2'));
+ Cache::invalidateTags(['test_tag:2']);
// Test that the cache entry has been invalidated in multiple bins.
foreach ($bins as $bin) {
diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php
index fcfb02380f2..582a2f4f067 100644
--- a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php
@@ -47,12 +47,12 @@ abstract class PageCacheTagsTestBase extends WebTestBase {
*/
protected function verifyPageCache(Url $url, $hit_or_miss, $tags = FALSE) {
$this->drupalGet($url);
- $message = SafeMarkup::format('Page cache @hit_or_miss for %path.', array('@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()));
+ $message = SafeMarkup::format('Page cache @hit_or_miss for %path.', ['@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()]);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message);
if ($hit_or_miss === 'HIT' && is_array($tags)) {
$absolute_url = $url->setAbsolute()->toString();
- $cid_parts = array($absolute_url, 'html');
+ $cid_parts = [$absolute_url, 'html'];
$cid = implode(':', $cid_parts);
$cache_entry = \Drupal::cache('render')->get($cid);
sort($cache_entry->tags);
diff --git a/core/modules/system/src/Tests/Common/AddFeedTest.php b/core/modules/system/src/Tests/Common/AddFeedTest.php
index b539281629b..b959d42524d 100644
--- a/core/modules/system/src/Tests/Common/AddFeedTest.php
+++ b/core/modules/system/src/Tests/Common/AddFeedTest.php
@@ -18,38 +18,38 @@ class AddFeedTest extends WebTestBase {
function testBasicFeedAddNoTitle() {
$path = $this->randomMachineName(12);
$external_url = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12);
- $fully_qualified_local_url = Url::fromUri('base:' . $this->randomMachineName(12), array('absolute' => TRUE))->toString();
+ $fully_qualified_local_url = Url::fromUri('base:' . $this->randomMachineName(12), ['absolute' => TRUE])->toString();
$path_for_title = $this->randomMachineName(12);
$external_for_title = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12);
- $fully_qualified_for_title = Url::fromUri('base:' . $this->randomMachineName(12), array('absolute' => TRUE))->toString();
+ $fully_qualified_for_title = Url::fromUri('base:' . $this->randomMachineName(12), ['absolute' => TRUE])->toString();
- $urls = array(
- 'path without title' => array(
- 'url' => Url::fromUri('base:' . $path, array('absolute' => TRUE))->toString(),
+ $urls = [
+ 'path without title' => [
+ 'url' => Url::fromUri('base:' . $path, ['absolute' => TRUE])->toString(),
'title' => '',
- ),
- 'external URL without title' => array(
+ ],
+ 'external URL without title' => [
'url' => $external_url,
'title' => '',
- ),
- 'local URL without title' => array(
+ ],
+ 'local URL without title' => [
'url' => $fully_qualified_local_url,
'title' => '',
- ),
- 'path with title' => array(
- 'url' => Url::fromUri('base:' . $path_for_title, array('absolute' => TRUE))->toString(),
+ ],
+ 'path with title' => [
+ 'url' => Url::fromUri('base:' . $path_for_title, ['absolute' => TRUE])->toString(),
'title' => $this->randomMachineName(12),
- ),
- 'external URL with title' => array(
+ ],
+ 'external URL with title' => [
'url' => $external_for_title,
'title' => $this->randomMachineName(12),
- ),
- 'local URL with title' => array(
+ ],
+ 'local URL with title' => [
'url' => $fully_qualified_for_title,
'title' => $this->randomMachineName(12),
- ),
- );
+ ],
+ ];
$build = [];
foreach ($urls as $feed_info) {
@@ -63,7 +63,7 @@ class AddFeedTest extends WebTestBase {
$this->setRawContent($response->getContent());
// Assert that the content contains the RSS links we specified.
foreach ($urls as $description => $feed_info) {
- $this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), format_string('Found correct feed header for %description', array('%description' => $description)));
+ $this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), format_string('Found correct feed header for %description', ['%description' => $description]));
}
}
@@ -83,11 +83,11 @@ class AddFeedTest extends WebTestBase {
* @see https://www.drupal.org/node/1211668
*/
function testFeedIconEscaping() {
- $variables = array(
+ $variables = [
'#theme' => 'feed_icon',
'#url' => 'node',
'#title' => '<>&"\'',
- );
+ ];
$text = \Drupal::service('renderer')->renderRoot($variables);
$this->assertEqual(trim(strip_tags($text)), 'Subscribe to &lt;&gt;&amp;&quot;&#039;', 'feed_icon template escapes reserved HTML characters.');
}
diff --git a/core/modules/system/src/Tests/Common/AlterTest.php b/core/modules/system/src/Tests/Common/AlterTest.php
index 86bed7d24a2..2f19ab298f5 100644
--- a/core/modules/system/src/Tests/Common/AlterTest.php
+++ b/core/modules/system/src/Tests/Common/AlterTest.php
@@ -16,7 +16,7 @@ class AlterTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'common_test');
+ public static $modules = ['block', 'common_test'];
/**
* Tests if the theme has been altered.
@@ -24,16 +24,16 @@ class AlterTest extends WebTestBase {
function testDrupalAlter() {
// This test depends on Bartik, so make sure that it is always the current
// active theme.
- \Drupal::service('theme_handler')->install(array('bartik'));
+ \Drupal::service('theme_handler')->install(['bartik']);
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('bartik'));
- $array = array('foo' => 'bar');
+ $array = ['foo' => 'bar'];
$entity = new \stdClass();
$entity->foo = 'bar';
// Verify alteration of a single argument.
$array_copy = $array;
- $array_expected = array('foo' => 'Drupal theme');
+ $array_expected = ['foo' => 'Drupal theme'];
\Drupal::moduleHandler()->alter('drupal_alter', $array_copy);
\Drupal::theme()->alter('drupal_alter', $array_copy);
$this->assertEqual($array_copy, $array_expected, 'Single array was altered.');
@@ -47,12 +47,12 @@ class AlterTest extends WebTestBase {
// Verify alteration of multiple arguments.
$array_copy = $array;
- $array_expected = array('foo' => 'Drupal theme');
+ $array_expected = ['foo' => 'Drupal theme'];
$entity_copy = clone $entity;
$entity_expected = clone $entity;
$entity_expected->foo = 'Drupal theme';
$array2_copy = $array;
- $array2_expected = array('foo' => 'Drupal theme');
+ $array2_expected = ['foo' => 'Drupal theme'];
\Drupal::moduleHandler()->alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
\Drupal::theme()->alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
$this->assertEqual($array_copy, $array_expected, 'First argument to \Drupal::moduleHandler->alter() was altered.');
@@ -63,9 +63,9 @@ class AlterTest extends WebTestBase {
// common_test_module_implements_alter() places 'block' implementation after
// other modules.
$array_copy = $array;
- $array_expected = array('foo' => 'Drupal block theme');
- \Drupal::moduleHandler()->alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
- \Drupal::theme()->alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
+ $array_expected = ['foo' => 'Drupal block theme'];
+ \Drupal::moduleHandler()->alter(['drupal_alter', 'drupal_alter_foo'], $array_copy);
+ \Drupal::theme()->alter(['drupal_alter', 'drupal_alter_foo'], $array_copy);
$this->assertEqual($array_copy, $array_expected, 'hook_TYPE_alter() implementations ran in correct order.');
}
diff --git a/core/modules/system/src/Tests/Common/FormatDateTest.php b/core/modules/system/src/Tests/Common/FormatDateTest.php
index cddf0a3fae2..c6a57c96b8d 100644
--- a/core/modules/system/src/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/src/Tests/Common/FormatDateTest.php
@@ -17,7 +17,7 @@ class FormatDateTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Arbitrary langcode for a custom language.
@@ -32,16 +32,16 @@ class FormatDateTest extends WebTestBase {
->save();
$formats = $this->container->get('entity.manager')
->getStorage('date_format')
- ->loadMultiple(array('long', 'medium', 'short'));
+ ->loadMultiple(['long', 'medium', 'short']);
$formats['long']->setPattern('l, j. F Y - G:i')->save();
$formats['medium']->setPattern('j. F Y - G:i')->save();
$formats['short']->setPattern('Y M j - g:ia')->save();
$this->refreshVariables();
- $this->settingsSet('locale_custom_strings_' . self::LANGCODE, array(
- '' => array('Sunday' => 'domingo'),
- 'Long month name' => array('March' => 'marzo'),
- ));
+ $this->settingsSet('locale_custom_strings_' . self::LANGCODE, [
+ '' => ['Sunday' => 'domingo'],
+ 'Long month name' => ['March' => 'marzo'],
+ ]);
ConfigurableLanguage::createFromLangcode(static::LANGCODE)->save();
$this->resetAll();
@@ -52,22 +52,22 @@ class FormatDateTest extends WebTestBase {
*/
function testAdminDefinedFormatDate() {
// Create and log in an admin user.
- $this->drupalLogin($this->drupalCreateUser(array('administer site configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
// Add new date format.
- $edit = array(
+ $edit = [
'id' => 'example_style',
'label' => 'Example Style',
'date_format_pattern' => 'j M y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
// Add a second date format with a different case than the first.
- $edit = array(
+ $edit = [
'id' => 'example_style_uppercase',
'label' => 'Example Style Uppercase',
'date_format_pattern' => 'j M Y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('Custom date format added.'));
diff --git a/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php b/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php
index 9c9f070d5ee..e671f872130 100644
--- a/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php
+++ b/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php
@@ -19,7 +19,7 @@ class NoJavaScriptAnonymousTest extends WebTestBase {
parent::setUp();
// Grant the anonymous user the permission to look at user profiles.
- user_role_grant_permissions('anonymous', array('access user profiles'));
+ user_role_grant_permissions('anonymous', ['access user profiles']);
}
/**
@@ -27,9 +27,9 @@ class NoJavaScriptAnonymousTest extends WebTestBase {
*/
public function testNoJavaScript() {
// Create a node that is listed on the frontpage.
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'promote' => NodeInterface::PROMOTED,
- ));
+ ]);
$user = $this->drupalCreateUser();
// Test frontpage.
diff --git a/core/modules/system/src/Tests/Common/RenderWebTest.php b/core/modules/system/src/Tests/Common/RenderWebTest.php
index fde7fa6835f..49449d47798 100644
--- a/core/modules/system/src/Tests/Common/RenderWebTest.php
+++ b/core/modules/system/src/Tests/Common/RenderWebTest.php
@@ -19,7 +19,7 @@ class RenderWebTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('common_test');
+ public static $modules = ['common_test'];
/**
* Asserts the cache context for the wrapper format is always present.
@@ -45,133 +45,133 @@ class RenderWebTest extends WebTestBase {
*/
function testDrupalRenderFormElements() {
// Define a series of form elements.
- $element = array(
+ $element = [
'#type' => 'button',
'#value' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'submit'));
+ ];
+ $this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'submit']);
- $element = array(
+ $element = [
'#type' => 'textfield',
'#title' => $this->randomMachineName(),
'#value' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'text'));
+ ];
+ $this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'text']);
- $element = array(
+ $element = [
'#type' => 'password',
'#title' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'password'));
+ ];
+ $this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'password']);
- $element = array(
+ $element = [
'#type' => 'textarea',
'#title' => $this->randomMachineName(),
'#value' => $this->randomMachineName(),
- );
+ ];
$this->assertRenderedElement($element, '//textarea');
- $element = array(
+ $element = [
'#type' => 'radio',
'#title' => $this->randomMachineName(),
'#value' => FALSE,
- );
- $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'radio'));
+ ];
+ $this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'radio']);
- $element = array(
+ $element = [
'#type' => 'checkbox',
'#title' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'checkbox'));
+ ];
+ $this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'checkbox']);
- $element = array(
+ $element = [
'#type' => 'select',
'#title' => $this->randomMachineName(),
- '#options' => array(
+ '#options' => [
0 => $this->randomMachineName(),
1 => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$this->assertRenderedElement($element, '//select');
- $element = array(
+ $element = [
'#type' => 'file',
'#title' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'file'));
+ ];
+ $this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'file']);
- $element = array(
+ $element = [
'#type' => 'item',
'#title' => $this->randomMachineName(),
'#markup' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//div[contains(@class, :class) and contains(., :markup)]/label[contains(., :label)]', array(
+ ];
+ $this->assertRenderedElement($element, '//div[contains(@class, :class) and contains(., :markup)]/label[contains(., :label)]', [
':class' => 'js-form-type-item',
':markup' => $element['#markup'],
':label' => $element['#title'],
- ));
+ ]);
- $element = array(
+ $element = [
'#type' => 'hidden',
'#title' => $this->randomMachineName(),
'#value' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'hidden'));
+ ];
+ $this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'hidden']);
- $element = array(
+ $element = [
'#type' => 'link',
'#title' => $this->randomMachineName(),
'#url' => Url::fromRoute('common_test.destination'),
- '#options' => array(
+ '#options' => [
'absolute' => TRUE,
- ),
- );
- $this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array(
+ ],
+ ];
+ $this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', [
':href' => URL::fromRoute('common_test.destination')->setAbsolute()->toString(),
':title' => $element['#title'],
- ));
+ ]);
- $element = array(
+ $element = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//details/summary[contains(., :title)]', array(
+ ];
+ $this->assertRenderedElement($element, '//details/summary[contains(., :title)]', [
':title' => $element['#title'],
- ));
+ ]);
- $element = array(
+ $element = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this->randomMachineName(),
- );
+ ];
$this->assertRenderedElement($element, '//details');
- $element['item'] = array(
+ $element['item'] = [
'#type' => 'item',
'#title' => $this->randomMachineName(),
'#markup' => $this->randomMachineName(),
- );
- $this->assertRenderedElement($element, '//details/div/div[contains(@class, :class) and contains(., :markup)]', array(
+ ];
+ $this->assertRenderedElement($element, '//details/div/div[contains(@class, :class) and contains(., :markup)]', [
':class' => 'js-form-type-item',
':markup' => $element['item']['#markup'],
- ));
+ ]);
}
/**
* Tests that elements are rendered properly.
*/
- protected function assertRenderedElement(array $element, $xpath, array $xpath_args = array()) {
+ protected function assertRenderedElement(array $element, $xpath, array $xpath_args = []) {
$original_element = $element;
$this->setRawContent(drupal_render_root($element));
$this->verbose('<hr />' . $this->getRawContent());
// @see \Drupal\simpletest\WebTestBase::xpath()
$xpath = $this->buildXPathQuery($xpath, $xpath_args);
- $element += array('#value' => NULL);
- $this->assertFieldByXPath($xpath, $element['#value'], format_string('#type @type was properly rendered.', array(
+ $element += ['#value' => NULL];
+ $this->assertFieldByXPath($xpath, $element['#value'], format_string('#type @type was properly rendered.', [
'@type' => var_export($element['#type'], TRUE),
- )));
+ ]));
}
}
diff --git a/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php b/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php
index 1be7e948266..016d23c3ad5 100644
--- a/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php
+++ b/core/modules/system/src/Tests/Common/SimpleTestErrorCollectorTest.php
@@ -16,7 +16,7 @@ class SimpleTestErrorCollectorTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('system_test', 'error_test');
+ public static $modules = ['system_test', 'error_test'];
/**
* Errors triggered during the test.
@@ -26,13 +26,13 @@ class SimpleTestErrorCollectorTest extends WebTestBase {
*
* @var Array
*/
- protected $collectedErrors = array();
+ protected $collectedErrors = [];
/**
* Tests that simpletest collects errors from the tested site.
*/
function testErrorCollect() {
- $this->collectedErrors = array();
+ $this->collectedErrors = [];
$this->drupalGet('error-test/generate-warnings-with-report');
$this->assertEqual(count($this->collectedErrors), 3, 'Three errors were collected');
@@ -71,11 +71,11 @@ class SimpleTestErrorCollectorTest extends WebTestBase {
}
// Everything else should be collected but not propagated.
else {
- $this->collectedErrors[] = array(
+ $this->collectedErrors[] = [
'message' => $message,
'group' => $group,
'caller' => $caller
- );
+ ];
}
}
@@ -83,11 +83,11 @@ class SimpleTestErrorCollectorTest extends WebTestBase {
* Asserts that a collected error matches what we are expecting.
*/
function assertError($error, $group, $function, $file, $message = NULL) {
- $this->assertEqual($error['group'], $group, format_string("Group was %group", array('%group' => $group)));
- $this->assertEqual($error['caller']['function'], $function, format_string("Function was %function", array('%function' => $function)));
- $this->assertEqual(drupal_basename($error['caller']['file']), $file, format_string("File was %file", array('%file' => $file)));
+ $this->assertEqual($error['group'], $group, format_string("Group was %group", ['%group' => $group]));
+ $this->assertEqual($error['caller']['function'], $function, format_string("Function was %function", ['%function' => $function]));
+ $this->assertEqual(drupal_basename($error['caller']['file']), $file, format_string("File was %file", ['%file' => $file]));
if (isset($message)) {
- $this->assertEqual($error['message'], $message, format_string("Message was %message", array('%message' => $message)));
+ $this->assertEqual($error['message'], $message, format_string("Message was %message", ['%message' => $message]));
}
}
diff --git a/core/modules/system/src/Tests/Common/UrlTest.php b/core/modules/system/src/Tests/Common/UrlTest.php
index 062e3e42d5e..da839869764 100644
--- a/core/modules/system/src/Tests/Common/UrlTest.php
+++ b/core/modules/system/src/Tests/Common/UrlTest.php
@@ -20,7 +20,7 @@ use Drupal\simpletest\WebTestBase;
*/
class UrlTest extends WebTestBase {
- public static $modules = array('common_test', 'url_alter_test');
+ public static $modules = ['common_test', 'url_alter_test'];
/**
* Confirms that invalid URLs are filtered in link generating functions.
@@ -32,7 +32,7 @@ class UrlTest extends WebTestBase {
$encoded_path = "3CSCRIPT%3Ealert%28%27XSS%27%29%3C/SCRIPT%3E";
$link = \Drupal::l($text, Url::fromUserInput('/' . $path));
- $this->assertTrue(strpos($link, $encoded_path) !== FALSE && strpos($link, $path) === FALSE, format_string('XSS attack @path was filtered by \Drupal\Core\Utility\LinkGeneratorInterface::generate().', array('@path' => $path)));
+ $this->assertTrue(strpos($link, $encoded_path) !== FALSE && strpos($link, $path) === FALSE, format_string('XSS attack @path was filtered by \Drupal\Core\Utility\LinkGeneratorInterface::generate().', ['@path' => $path]));
// Test \Drupal\Core\Url.
$link = Url::fromUri('base:' . $path)->toString();
@@ -76,15 +76,15 @@ class UrlTest extends WebTestBase {
$renderer = $this->container->get('renderer');
// Test that hreflang is added when a link has a known language.
- $language = new Language(array('id' => 'fr', 'name' => 'French'));
- $hreflang_link = array(
+ $language = new Language(['id' => 'fr', 'name' => 'French']);
+ $hreflang_link = [
'#type' => 'link',
- '#options' => array(
+ '#options' => [
'language' => $language,
- ),
+ ],
'#url' => Url::fromUri('https://www.drupal.org'),
'#title' => 'bar',
- );
+ ];
$langcode = $language->getId();
// Test that the default hreflang handling for links does not override a
@@ -93,45 +93,45 @@ class UrlTest extends WebTestBase {
$hreflang_override_link['#options']['attributes']['hreflang'] = 'foo';
$rendered = $renderer->renderRoot($hreflang_link);
- $this->assertTrue($this->hasAttribute('hreflang', $rendered, $langcode), format_string('hreflang attribute with value @langcode is present on a rendered link when langcode is provided in the render array.', array('@langcode' => $langcode)));
+ $this->assertTrue($this->hasAttribute('hreflang', $rendered, $langcode), format_string('hreflang attribute with value @langcode is present on a rendered link when langcode is provided in the render array.', ['@langcode' => $langcode]));
$rendered = $renderer->renderRoot($hreflang_override_link);
- $this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), format_string('hreflang attribute with value @hreflang is present on a rendered link when @hreflang is provided in the render array.', array('@hreflang' => 'foo')));
+ $this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), format_string('hreflang attribute with value @hreflang is present on a rendered link when @hreflang is provided in the render array.', ['@hreflang' => 'foo']));
// Test the active class in links produced by
// \Drupal\Core\Utility\LinkGeneratorInterface::generate() and #type 'link'.
- $options_no_query = array();
- $options_query = array(
- 'query' => array(
+ $options_no_query = [];
+ $options_query = [
+ 'query' => [
'foo' => 'bar',
'one' => 'two',
- ),
- );
- $options_query_reverse = array(
- 'query' => array(
+ ],
+ ];
+ $options_query_reverse = [
+ 'query' => [
'one' => 'two',
'foo' => 'bar',
- ),
- );
+ ],
+ ];
// Test #type link.
$path = 'common-test/type-link-active-class';
$this->drupalGet($path, $options_no_query);
- $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => Url::fromRoute('common_test.l_active_class', [], $options_no_query)->toString(), ':class' => 'is-active'));
+ $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', [':href' => Url::fromRoute('common_test.l_active_class', [], $options_no_query)->toString(), ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), 'A link generated by the link generator to the current page is marked active.');
- $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => Url::fromRoute('common_test.l_active_class', [], $options_query)->toString(), ':class' => 'is-active'));
+ $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', [':href' => Url::fromRoute('common_test.l_active_class', [], $options_query)->toString(), ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), 'A link generated by the link generator to the current page with a query string when the current page has no query string is not marked active.');
$this->drupalGet($path, $options_query);
- $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => Url::fromRoute('common_test.l_active_class', [], $options_query)->toString(), ':class' => 'is-active'));
+ $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', [':href' => Url::fromRoute('common_test.l_active_class', [], $options_query)->toString(), ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), 'A link generated by the link generator to the current page with a query string that matches the current query string is marked active.');
- $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => Url::fromRoute('common_test.l_active_class', [], $options_query_reverse)->toString(), ':class' => 'is-active'));
+ $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', [':href' => Url::fromRoute('common_test.l_active_class', [], $options_query_reverse)->toString(), ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), 'A link generated by the link generator to the current page with a query string that has matching parameters to the current query string but in a different order is marked active.');
- $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => Url::fromRoute('common_test.l_active_class', [], $options_no_query)->toString(), ':class' => 'is-active'));
+ $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', [':href' => Url::fromRoute('common_test.l_active_class', [], $options_no_query)->toString(), ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), 'A link generated by the link generator to the current page without a query string when the current page has a query string is not marked active.');
// Test adding a custom class in links produced by
@@ -139,22 +139,22 @@ class UrlTest extends WebTestBase {
// Test the link generator.
$class_l = $this->randomMachineName();
$link_l = \Drupal::l($this->randomMachineName(), new Url('<current>', [], ['attributes' => ['class' => [$class_l]]]));
- $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), format_string('Custom class @class is present on link when requested by l()', array('@class' => $class_l)));
+ $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), format_string('Custom class @class is present on link when requested by l()', ['@class' => $class_l]));
// Test #type.
$class_theme = $this->randomMachineName();
- $type_link = array(
+ $type_link = [
'#type' => 'link',
'#title' => $this->randomMachineName(),
'#url' => Url::fromRoute('<current>'),
- '#options' => array(
- 'attributes' => array(
- 'class' => array($class_theme),
- ),
- ),
- );
+ '#options' => [
+ 'attributes' => [
+ 'class' => [$class_theme],
+ ],
+ ],
+ ];
$link_theme = $renderer->renderRoot($type_link);
- $this->assertTrue($this->hasAttribute('class', $link_theme, $class_theme), format_string('Custom class @class is present on link when requested by #type', array('@class' => $class_theme)));
+ $this->assertTrue($this->hasAttribute('class', $link_theme, $class_theme), format_string('Custom class @class is present on link when requested by #type', ['@class' => $class_theme]));
}
/**
@@ -169,26 +169,26 @@ class UrlTest extends WebTestBase {
// Test a renderable array passed to the link generator.
$renderer->executeInRenderContext(new RenderContext(), function() use ($renderer, $l) {
- $renderable_text = array('#markup' => 'foo');
+ $renderable_text = ['#markup' => 'foo'];
$l_renderable_text = \Drupal::l($renderable_text, Url::fromUri('https://www.drupal.org'));
$this->assertEqual($l_renderable_text, $l);
});
// Test a themed link with plain text 'text'.
- $type_link_plain_array = array(
+ $type_link_plain_array = [
'#type' => 'link',
'#title' => 'foo',
'#url' => Url::fromUri('https://www.drupal.org'),
- );
+ ];
$type_link_plain = $renderer->renderRoot($type_link_plain_array);
$this->assertEqual($type_link_plain, $l);
// Build a themed link with renderable 'text'.
- $type_link_nested_array = array(
+ $type_link_nested_array = [
'#type' => 'link',
- '#title' => array('#markup' => 'foo'),
+ '#title' => ['#markup' => 'foo'],
'#url' => Url::fromUri('https://www.drupal.org'),
- );
+ ];
$type_link_nested = $renderer->renderRoot($type_link_nested_array);
$this->assertEqual($type_link_nested, $l);
}
@@ -212,36 +212,36 @@ class UrlTest extends WebTestBase {
* Tests UrlHelper::filterQueryParameters().
*/
function testDrupalGetQueryParameters() {
- $original = array(
+ $original = [
'a' => 1,
- 'b' => array(
+ 'b' => [
'd' => 4,
- 'e' => array(
+ 'e' => [
'f' => 5,
- ),
- ),
+ ],
+ ],
'c' => 3,
- );
+ ];
// First-level exclusion.
$result = $original;
unset($result['b']);
- $this->assertEqual(UrlHelper::filterQueryParameters($original, array('b')), $result, "'b' was removed.");
+ $this->assertEqual(UrlHelper::filterQueryParameters($original, ['b']), $result, "'b' was removed.");
// Second-level exclusion.
$result = $original;
unset($result['b']['d']);
- $this->assertEqual(UrlHelper::filterQueryParameters($original, array('b[d]')), $result, "'b[d]' was removed.");
+ $this->assertEqual(UrlHelper::filterQueryParameters($original, ['b[d]']), $result, "'b[d]' was removed.");
// Third-level exclusion.
$result = $original;
unset($result['b']['e']['f']);
- $this->assertEqual(UrlHelper::filterQueryParameters($original, array('b[e][f]')), $result, "'b[e][f]' was removed.");
+ $this->assertEqual(UrlHelper::filterQueryParameters($original, ['b[e][f]']), $result, "'b[e][f]' was removed.");
// Multiple exclusions.
$result = $original;
unset($result['a'], $result['b']['e'], $result['c']);
- $this->assertEqual(UrlHelper::filterQueryParameters($original, array('a', 'b[e]', 'c')), $result, "'a', 'b[e]', 'c' were removed.");
+ $this->assertEqual(UrlHelper::filterQueryParameters($original, ['a', 'b[e]', 'c']), $result, "'a', 'b[e]', 'c' were removed.");
}
/**
@@ -250,15 +250,15 @@ class UrlTest extends WebTestBase {
function testDrupalParseUrl() {
// Relative, absolute, and external URLs, without/with explicit script path,
// without/with Drupal path.
- foreach (array('', '/', 'https://www.drupal.org/') as $absolute) {
- foreach (array('', 'index.php/') as $script) {
- foreach (array('', 'foo/bar') as $path) {
+ foreach (['', '/', 'https://www.drupal.org/'] as $absolute) {
+ foreach (['', 'index.php/'] as $script) {
+ foreach (['', 'foo/bar'] as $path) {
$url = $absolute . $script . $path . '?foo=bar&bar=baz&baz#foo';
- $expected = array(
+ $expected = [
'path' => $absolute . $script . $path,
- 'query' => array('foo' => 'bar', 'bar' => 'baz', 'baz' => ''),
+ 'query' => ['foo' => 'bar', 'bar' => 'baz', 'baz' => ''],
'fragment' => 'foo',
- );
+ ];
$this->assertEqual(UrlHelper::parse($url), $expected, 'URL parsed correctly.');
}
}
@@ -266,11 +266,11 @@ class UrlTest extends WebTestBase {
// Relative URL that is known to confuse parse_url().
$url = 'foo/bar:1';
- $result = array(
+ $result = [
'path' => 'foo/bar:1',
- 'query' => array(),
+ 'query' => [],
'fragment' => '',
- );
+ ];
$this->assertEqual(UrlHelper::parse($url), $result, 'Relative URL parsed correctly.');
// Test that drupal can recognize an absolute URL. Used to prevent attack vectors.
@@ -296,7 +296,7 @@ class UrlTest extends WebTestBase {
// Verify fragment can be overridden in an external URL.
$url = $test_url . '#drupal';
$fragment = $this->randomMachineName(10);
- $result = Url::fromUri($url, array('fragment' => $fragment))->toString();
+ $result = Url::fromUri($url, ['fragment' => $fragment])->toString();
$this->assertEqual($test_url . '#' . $fragment, $result, 'External URL fragment is overridden with a custom fragment in $options.');
// Verify external URL can contain a query string.
@@ -306,14 +306,14 @@ class UrlTest extends WebTestBase {
// Verify external URL can be extended with a query string.
$url = $test_url;
- $query = array($this->randomMachineName(5) => $this->randomMachineName(5));
- $result = Url::fromUri($url, array('query' => $query))->toString();
+ $query = [$this->randomMachineName(5) => $this->randomMachineName(5)];
+ $result = Url::fromUri($url, ['query' => $query])->toString();
$this->assertEqual($url . '?' . http_build_query($query, '', '&'), $result, 'External URL can be extended with a query string in $options.');
// Verify query string can be extended in an external URL.
$url = $test_url . '?drupal=awesome';
- $query = array($this->randomMachineName(5) => $this->randomMachineName(5));
- $result = Url::fromUri($url, array('query' => $query))->toString();
+ $query = [$this->randomMachineName(5) => $this->randomMachineName(5)];
+ $result = Url::fromUri($url, ['query' => $query])->toString();
$this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result);
}
diff --git a/core/modules/system/src/Tests/Condition/ConditionFormTest.php b/core/modules/system/src/Tests/Condition/ConditionFormTest.php
index 21d0fcb9e6d..8d2ea6d330b 100644
--- a/core/modules/system/src/Tests/Condition/ConditionFormTest.php
+++ b/core/modules/system/src/Tests/Condition/ConditionFormTest.php
@@ -16,14 +16,14 @@ use Drupal\simpletest\WebTestBase;
*/
class ConditionFormTest extends WebTestBase {
- public static $modules = array('node', 'condition_test');
+ public static $modules = ['node', 'condition_test'];
/**
* Submit the condition_node_type_test_form to test condition forms.
*/
function testConfigForm() {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
$article = Node::create([
'type' => 'article',
@@ -34,7 +34,7 @@ class ConditionFormTest extends WebTestBase {
$this->drupalGet('condition_test');
$this->assertField('bundles[article]', 'There is an article bundle selector.');
$this->assertField('bundles[page]', 'There is a page bundle selector.');
- $this->drupalPostForm(NULL, array('bundles[page]' => 'page', 'bundles[article]' => 'article'), t('Submit'));
+ $this->drupalPostForm(NULL, ['bundles[page]' => 'page', 'bundles[article]' => 'article'], t('Submit'));
// @see \Drupal\condition_test\FormController::submitForm()
$this->assertText('Bundle: page');
$this->assertText('Bundle: article');
diff --git a/core/modules/system/src/Tests/Database/DatabaseWebTestBase.php b/core/modules/system/src/Tests/Database/DatabaseWebTestBase.php
index d484d68fd20..8fb369a3761 100644
--- a/core/modules/system/src/Tests/Database/DatabaseWebTestBase.php
+++ b/core/modules/system/src/Tests/Database/DatabaseWebTestBase.php
@@ -15,7 +15,7 @@ abstract class DatabaseWebTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('database_test');
+ public static $modules = ['database_test'];
protected function setUp() {
parent::setUp();
diff --git a/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php b/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php
index cdfeab8d0a1..e56c19f91f1 100644
--- a/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php
+++ b/core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php
@@ -33,14 +33,14 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
}
for ($page = 0; $page <= $num_pages; ++$page) {
- $this->drupalGet('database_test/pager_query_even/' . $limit, array('query' => array('page' => $page)));
+ $this->drupalGet('database_test/pager_query_even/' . $limit, ['query' => ['page' => $page]]);
$data = json_decode($this->getRawContent());
if ($page == $num_pages) {
$correct_number = $count - ($limit * $page);
}
- $this->assertEqual(count($data->names), $correct_number, format_string('Correct number of records returned by pager: @number', array('@number' => $correct_number)));
+ $this->assertEqual(count($data->names), $correct_number, format_string('Correct number of records returned by pager: @number', ['@number' => $correct_number]));
}
}
@@ -67,14 +67,14 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
}
for ($page = 0; $page <= $num_pages; ++$page) {
- $this->drupalGet('database_test/pager_query_odd/' . $limit, array('query' => array('page' => $page)));
+ $this->drupalGet('database_test/pager_query_odd/' . $limit, ['query' => ['page' => $page]]);
$data = json_decode($this->getRawContent());
if ($page == $num_pages) {
$correct_number = $count - ($limit * $page);
}
- $this->assertEqual(count($data->names), $correct_number, format_string('Correct number of records returned by pager: @number', array('@number' => $correct_number)));
+ $this->assertEqual(count($data->names), $correct_number, format_string('Correct number of records returned by pager: @number', ['@number' => $correct_number]));
}
}
@@ -87,7 +87,7 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
$query = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query
- ->fields('t', array('age'))
+ ->fields('t', ['age'])
->orderBy('age')
->limit(5);
@@ -97,7 +97,7 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
$ages = $outer_query
->execute()
->fetchCol();
- $this->assertEqual($ages, array(25, 26, 27, 28), 'Inner pager query returned the correct ages.');
+ $this->assertEqual($ages, [25, 26, 27, 28], 'Inner pager query returned the correct ages.');
}
/**
@@ -109,16 +109,16 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
$query = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->orderBy('name')
->groupBy('name')
- ->having('MAX(age) > :count', array(':count' => 26))
+ ->having('MAX(age) > :count', [':count' => 26])
->limit(5);
$ages = $query
->execute()
->fetchCol();
- $this->assertEqual($ages, array('George', 'Ringo'), 'Pager query with having expression returned the correct ages.');
+ $this->assertEqual($ages, ['George', 'Ringo'], 'Pager query with having expression returned the correct ages.');
}
/**
@@ -127,15 +127,15 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
function testElementNumbers() {
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
'page' => '3, 2, 1, 0',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
$name = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->element(2)
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->orderBy('age')
->limit(1)
->execute()
@@ -147,7 +147,7 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
$name = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->element(1)
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->orderBy('age')
->limit(1)
->execute()
@@ -156,7 +156,7 @@ class SelectPagerDefaultTest extends DatabaseWebTestBase {
$name = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->orderBy('age')
->limit(1)
->execute()
diff --git a/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php b/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php
index 7ccbbb5efbf..8ed05bd5c1f 100644
--- a/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php
+++ b/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php
@@ -16,17 +16,17 @@ class SelectTableSortDefaultTest extends DatabaseWebTestBase {
* because the pager depends on GET parameters.
*/
function testTableSortQuery() {
- $sorts = array(
- array('field' => t('Task ID'), 'sort' => 'desc', 'first' => 'perform at superbowl', 'last' => 'eat'),
- array('field' => t('Task ID'), 'sort' => 'asc', 'first' => 'eat', 'last' => 'perform at superbowl'),
- array('field' => t('Task'), 'sort' => 'asc', 'first' => 'code', 'last' => 'sleep'),
- array('field' => t('Task'), 'sort' => 'desc', 'first' => 'sleep', 'last' => 'code'),
+ $sorts = [
+ ['field' => t('Task ID'), 'sort' => 'desc', 'first' => 'perform at superbowl', 'last' => 'eat'],
+ ['field' => t('Task ID'), 'sort' => 'asc', 'first' => 'eat', 'last' => 'perform at superbowl'],
+ ['field' => t('Task'), 'sort' => 'asc', 'first' => 'code', 'last' => 'sleep'],
+ ['field' => t('Task'), 'sort' => 'desc', 'first' => 'sleep', 'last' => 'code'],
// more elements here
- );
+ ];
foreach ($sorts as $sort) {
- $this->drupalGet('database_test/tablesort/', array('query' => array('order' => $sort['field'], 'sort' => $sort['sort'])));
+ $this->drupalGet('database_test/tablesort/', ['query' => ['order' => $sort['field'], 'sort' => $sort['sort']]]);
$data = json_decode($this->getRawContent());
$first = array_shift($data->tasks);
@@ -44,24 +44,24 @@ class SelectTableSortDefaultTest extends DatabaseWebTestBase {
* header happens first.
*/
function testTableSortQueryFirst() {
- $sorts = array(
- array('field' => t('Task ID'), 'sort' => 'desc', 'first' => 'perform at superbowl', 'last' => 'eat'),
- array('field' => t('Task ID'), 'sort' => 'asc', 'first' => 'eat', 'last' => 'perform at superbowl'),
- array('field' => t('Task'), 'sort' => 'asc', 'first' => 'code', 'last' => 'sleep'),
- array('field' => t('Task'), 'sort' => 'desc', 'first' => 'sleep', 'last' => 'code'),
+ $sorts = [
+ ['field' => t('Task ID'), 'sort' => 'desc', 'first' => 'perform at superbowl', 'last' => 'eat'],
+ ['field' => t('Task ID'), 'sort' => 'asc', 'first' => 'eat', 'last' => 'perform at superbowl'],
+ ['field' => t('Task'), 'sort' => 'asc', 'first' => 'code', 'last' => 'sleep'],
+ ['field' => t('Task'), 'sort' => 'desc', 'first' => 'sleep', 'last' => 'code'],
// more elements here
- );
+ ];
foreach ($sorts as $sort) {
- $this->drupalGet('database_test/tablesort_first/', array('query' => array('order' => $sort['field'], 'sort' => $sort['sort'])));
+ $this->drupalGet('database_test/tablesort_first/', ['query' => ['order' => $sort['field'], 'sort' => $sort['sort']]]);
$data = json_decode($this->getRawContent());
$first = array_shift($data->tasks);
$last = array_pop($data->tasks);
- $this->assertEqual($first->task, $sort['first'], format_string('Items appear in the correct order sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort'])));
- $this->assertEqual($last->task, $sort['last'], format_string('Items appear in the correct order sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort'])));
+ $this->assertEqual($first->task, $sort['first'], format_string('Items appear in the correct order sorting by @field @sort.', ['@field' => $sort['field'], '@sort' => $sort['sort']]));
+ $this->assertEqual($last->task, $sort['last'], format_string('Items appear in the correct order sorting by @field @sort.', ['@field' => $sort['field'], '@sort' => $sort['sort']]));
}
}
diff --git a/core/modules/system/src/Tests/Database/TemporaryQueryTest.php b/core/modules/system/src/Tests/Database/TemporaryQueryTest.php
index 1bfa75466e2..fd75df3655b 100644
--- a/core/modules/system/src/Tests/Database/TemporaryQueryTest.php
+++ b/core/modules/system/src/Tests/Database/TemporaryQueryTest.php
@@ -14,7 +14,7 @@ class TemporaryQueryTest extends DatabaseWebTestBase {
*
* @var array
*/
- public static $modules = array('database_test');
+ public static $modules = ['database_test'];
/**
* Returns the number of rows of a table.
@@ -38,8 +38,8 @@ class TemporaryQueryTest extends DatabaseWebTestBase {
}
// Now try to run two db_query_temporary() in the same request.
- $table_name_test = db_query_temporary('SELECT name FROM {test}', array());
- $table_name_task = db_query_temporary('SELECT pid FROM {test_task}', array());
+ $table_name_test = db_query_temporary('SELECT name FROM {test}', []);
+ $table_name_task = db_query_temporary('SELECT pid FROM {test_task}', []);
$this->assertEqual($this->countTableRows($table_name_test), $this->countTableRows('test'), 'A temporary table was created successfully in this request.');
$this->assertEqual($this->countTableRows($table_name_task), $this->countTableRows('test_task'), 'A second temporary table was created successfully in this request.');
@@ -50,7 +50,7 @@ class TemporaryQueryTest extends DatabaseWebTestBase {
-- Let's select some rows into a temporary table
SELECT name FROM {test}
";
- $table_name_test = db_query_temporary($sql, array());
+ $table_name_test = db_query_temporary($sql, []);
$this->assertEqual($this->countTableRows($table_name_test), $this->countTableRows('test'), 'Leading white space and comments do not interfere with temporary table creation.');
}
diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
index a26350e5a57..7f5c5e340ff 100644
--- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
@@ -71,18 +71,18 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
if ($this->entity->getEntityType()->get('field_ui_base_route')) {
// Add field, so we can modify the field storage and field entities to
// verify that changes to those indeed clear cache tags.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'configurable_field',
'entity_type' => $this->entity->getEntityTypeId(),
'type' => 'test_field',
- 'settings' => array(),
- ))->save();
+ 'settings' => [],
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entity->getEntityTypeId(),
'bundle' => $this->entity->bundle(),
'field_name' => 'configurable_field',
'label' => 'Configurable field',
- 'settings' => array(),
+ 'settings' => [],
])->save();
// Reload the entity now that a new field has been added to it.
@@ -113,11 +113,11 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
* @see \Drupal\simpletest\TestBase::getInfo()
*/
protected static function generateStandardizedInfo($entity_type_label, $group) {
- return array(
+ return [
'name' => "$entity_type_label entity cache tags",
'description' => "Test the $entity_type_label entity's cache tags.",
'group' => $group,
- );
+ ];
}
/**
@@ -173,7 +173,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
* @see \Drupal\system\Tests\Entity\EntityCacheTagsTestBase::createEntity()
*/
protected function getAdditionalCacheTagsForEntity(EntityInterface $entity) {
- return array();
+ return [];
}
/**
@@ -208,7 +208,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
protected function selectViewMode($entity_type) {
$view_modes = \Drupal::entityManager()
->getStorage('entity_view_mode')
- ->loadByProperties(array('targetEntityType' => $entity_type));
+ ->loadByProperties(['targetEntityType' => $entity_type]);
if (empty($view_modes)) {
return 'default';
@@ -244,46 +244,46 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
// Add a field of the given type to the given entity type's "foo" bundle.
$field_name = $referenced_entity->getEntityTypeId() . '_reference';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'type' => 'entity_reference',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- 'settings' => array(
+ 'settings' => [
'target_type' => $referenced_entity->getEntityTypeId(),
- ),
- ))->save();
+ ],
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
- 'target_bundles' => array(
+ 'handler_settings' => [
+ 'target_bundles' => [
$referenced_entity->bundle() => $referenced_entity->bundle(),
- ),
- 'sort' => array('field' => '_none'),
+ ],
+ 'sort' => ['field' => '_none'],
'auto_create' => FALSE,
- ),
- ),
+ ],
+ ],
])->save();
if (!$this->entity->getEntityType()->hasHandlerClass('view_builder')) {
entity_get_display($entity_type, $bundle, 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
else {
$referenced_entity_view_mode = $this->selectViewMode($this->entity->getEntityTypeId());
entity_get_display($entity_type, $bundle, 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_entity_view',
- 'settings' => array(
+ 'settings' => [
'view_mode' => $referenced_entity_view_mode,
- ),
- ))
+ ],
+ ])
->save();
}
@@ -291,28 +291,28 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
$label_key = \Drupal::entityManager()->getDefinition($entity_type)->getKey('label');
$referencing_entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
$label_key => 'Referencing ' . $entity_type,
'status' => 1,
'type' => $bundle,
- $field_name => array('target_id' => $referenced_entity->id()),
- ));
+ $field_name => ['target_id' => $referenced_entity->id()],
+ ]);
$referencing_entity->save();
// Create an entity that does not reference the entity being tested.
$non_referencing_entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
$label_key => 'Non-referencing ' . $entity_type,
'status' => 1,
'type' => $bundle,
- ));
+ ]);
$non_referencing_entity->save();
- return array(
+ return [
$referencing_entity,
$non_referencing_entity,
- );
+ ];
}
/**
@@ -353,7 +353,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
$page_cache_tags_referencing_entity = in_array('user.permissions', $this->getAccessCacheContextsForEntity($this->referencingEntity)) ? ['config:user.role.anonymous'] : [];
- $view_cache_tag = array();
+ $view_cache_tag = [];
if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) {
$view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)
->getCacheTags();
diff --git a/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php b/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php
index 0123597e7df..7fcabd7e8d6 100644
--- a/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php
+++ b/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php
@@ -202,9 +202,9 @@ trait EntityDefinitionTestTrait {
* @see \Drupal\entity_test\EntityTestStorageSchema::getEntitySchema()
*/
protected function addEntityIndex() {
- $indexes = array(
- 'entity_test_update__new_index' => array('name', 'user_id'),
- );
+ $indexes = [
+ 'entity_test_update__new_index' => ['name', 'user_id'],
+ ];
$this->state->set('entity_test_update.additional_entity_indexes', $indexes);
}
diff --git a/core/modules/system/src/Tests/Entity/EntityFormTest.php b/core/modules/system/src/Tests/Entity/EntityFormTest.php
index 4e0ced5126a..8bcb0c591cd 100644
--- a/core/modules/system/src/Tests/Entity/EntityFormTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityFormTest.php
@@ -17,11 +17,11 @@ class EntityFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('entity_test', 'language');
+ public static $modules = ['entity_test', 'language'];
protected function setUp() {
parent::setUp();
- $web_user = $this->drupalCreateUser(array('administer entity_test content', 'view test entity'));
+ $web_user = $this->drupalCreateUser(['administer entity_test content', 'view test entity']);
$this->drupalLogin($web_user);
// Add a language.
@@ -69,28 +69,28 @@ class EntityFormTest extends WebTestBase {
$name1 = $this->randomMachineName(8);
$name2 = $this->randomMachineName(10);
- $edit = array(
+ $edit = [
'name[0][value]' => $name1,
'field_test_text[0][value]' => $this->randomMachineName(16),
- );
+ ];
$this->drupalPostForm($entity_type . '/add', $edit, t('Save'));
$entity = $this->loadEntityByName($entity_type, $name1);
- $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', ['%entity_type' => $entity_type]));
$edit['name[0][value]'] = $name2;
$this->drupalPostForm($entity_type . '/manage/' . $entity->id() . '/edit', $edit, t('Save'));
$entity = $this->loadEntityByName($entity_type, $name1);
- $this->assertFalse($entity, format_string('%entity_type: The entity has been modified.', array('%entity_type' => $entity_type)));
+ $this->assertFalse($entity, format_string('%entity_type: The entity has been modified.', ['%entity_type' => $entity_type]));
$entity = $this->loadEntityByName($entity_type, $name2);
- $this->assertTrue($entity, format_string('%entity_type: Modified entity found in the database.', array('%entity_type' => $entity_type)));
- $this->assertNotEqual($entity->name->value, $name1, format_string('%entity_type: The entity name has been modified.', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity, format_string('%entity_type: Modified entity found in the database.', ['%entity_type' => $entity_type]));
+ $this->assertNotEqual($entity->name->value, $name1, format_string('%entity_type: The entity name has been modified.', ['%entity_type' => $entity_type]));
$this->drupalGet($entity_type . '/manage/' . $entity->id() . '/edit');
$this->clickLink(t('Delete'));
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$entity = $this->loadEntityByName($entity_type, $name2);
- $this->assertFalse($entity, format_string('%entity_type: Entity not found in the database.', array('%entity_type' => $entity_type)));
+ $this->assertFalse($entity, format_string('%entity_type: Entity not found in the database.', ['%entity_type' => $entity_type]));
}
/**
@@ -104,33 +104,33 @@ class EntityFormTest extends WebTestBase {
$name1_ro = $this->randomMachineName(9);
$name2_ro = $this->randomMachineName(11);
- $edit = array(
+ $edit = [
'name[0][value]' => $name1,
'field_test_text[0][value]' => $this->randomMachineName(16),
- );
+ ];
$this->drupalPostForm($entity_type_id . '/add', $edit, t('Save'));
$entity = $this->loadEntityByName($entity_type_id, $name1);
- $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array('%entity_type' => $entity_type_id)));
+ $this->assertTrue($entity, format_string('%entity_type: Entity found in the database.', ['%entity_type' => $entity_type_id]));
// Add a translation to the newly created entity without using the Content
// translation module.
$entity->addTranslation('ro', ['name' => $name1_ro])->save();
$translated_entity = $this->loadEntityByName($entity_type_id, $name1)->getTranslation('ro');
- $this->assertEqual($translated_entity->name->value, $name1_ro, format_string('%entity_type: The translation has been added.', array('%entity_type' => $entity_type_id)));
+ $this->assertEqual($translated_entity->name->value, $name1_ro, format_string('%entity_type: The translation has been added.', ['%entity_type' => $entity_type_id]));
$edit['name[0][value]'] = $name2_ro;
$this->drupalPostForm('ro/' . $entity_type_id . '/manage/' . $entity->id() . '/edit', $edit, t('Save'));
$translated_entity = $this->loadEntityByName($entity_type_id, $name1)->getTranslation('ro');
- $this->assertTrue($translated_entity, format_string('%entity_type: Modified translation found in the database.', array('%entity_type' => $entity_type_id)));
- $this->assertEqual($translated_entity->name->value, $name2_ro, format_string('%entity_type: The name of the translation has been modified.', array('%entity_type' => $entity_type_id)));
+ $this->assertTrue($translated_entity, format_string('%entity_type: Modified translation found in the database.', ['%entity_type' => $entity_type_id]));
+ $this->assertEqual($translated_entity->name->value, $name2_ro, format_string('%entity_type: The name of the translation has been modified.', ['%entity_type' => $entity_type_id]));
$this->drupalGet('ro/' . $entity_type_id . '/manage/' . $entity->id() . '/edit');
$this->clickLink(t('Delete'));
- $this->drupalPostForm(NULL, array(), t('Delete Romanian translation'));
+ $this->drupalPostForm(NULL, [], t('Delete Romanian translation'));
$entity = $this->loadEntityByName($entity_type_id, $name1);
- $this->assertNotNull($entity, format_string('%entity_type: The original entity still exists.', array('%entity_type' => $entity_type_id)));
- $this->assertFalse($entity->hasTranslation('ro'), format_string('%entity_type: Entity translation does not exist anymore.', array('%entity_type' => $entity_type_id)));
+ $this->assertNotNull($entity, format_string('%entity_type: The original entity still exists.', ['%entity_type' => $entity_type_id]));
+ $this->assertFalse($entity->hasTranslation('ro'), format_string('%entity_type: Entity translation does not exist anymore.', ['%entity_type' => $entity_type_id]));
}
/**
@@ -141,7 +141,7 @@ class EntityFormTest extends WebTestBase {
// correctly picked up.
$entity_storage = $this->container->get('entity.manager')->getStorage($entity_type);
$entity_storage->resetCache();
- $entities = $entity_storage->loadByProperties(array('name' => $name));
+ $entities = $entity_storage->loadByProperties(['name' => $name]);
return $entities ? current($entities) : NULL;
}
diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php
index d64e0192f35..e2854d27211 100644
--- a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php
@@ -19,7 +19,7 @@ class EntityTranslationFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('entity_test', 'language', 'node');
+ public static $modules = ['entity_test', 'language', 'node'];
protected $langcodes;
@@ -29,12 +29,12 @@ class EntityTranslationFormTest extends WebTestBase {
\Drupal::state()->set('entity_test.translation', TRUE);
// Create test languages.
- $this->langcodes = array();
+ $this->langcodes = [];
for ($i = 0; $i < 2; ++$i) {
- $language = ConfigurableLanguage::create(array(
+ $language = ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this->randomString(),
- ));
+ ]);
$this->langcodes[$i] = $language->id();
$language->save();
}
@@ -44,13 +44,13 @@ class EntityTranslationFormTest extends WebTestBase {
* Tests entity form language.
*/
function testEntityFormLanguage() {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
- $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer content types'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit own page content', 'administer content types']);
$this->drupalLogin($web_user);
// Create a node with language LanguageInterface::LANGCODE_NOT_SPECIFIED.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalGet('node/add/page');
@@ -75,21 +75,21 @@ class EntityTranslationFormTest extends WebTestBase {
// Enable language selector.
$this->drupalGet('admin/structure/types/manage/page');
- $edit = array('language_configuration[language_alterable]' => TRUE, 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED);
+ $edit = ['language_configuration[language_alterable]' => TRUE, 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED];
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
- $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.');
+ $this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']), 'Basic page content type has been updated.');
// Create a node with language.
- $edit = array();
+ $edit = [];
$langcode = $this->langcodes[0];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$edit['langcode[0][value]'] = $langcode;
$this->drupalPostForm('node/add/page', $edit, t('Save'));
- $this->assertText(t('Basic page @title has been created.', array('@title' => $edit['title[0][value]'])), 'Basic page created.');
+ $this->assertText(t('Basic page @title has been created.', ['@title' => $edit['title[0][value]']]), 'Basic page created.');
// Verify that the creation message contains a link to a node.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']);
$this->assert(isset($view_link), 'The message area contains a link to a node');
// Check to make sure the node was created.
diff --git a/core/modules/system/src/Tests/Entity/EntityUnitTestBase.php b/core/modules/system/src/Tests/Entity/EntityUnitTestBase.php
index 2ec64e8da8e..5d7dc6fd5d8 100644
--- a/core/modules/system/src/Tests/Entity/EntityUnitTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityUnitTestBase.php
@@ -34,7 +34,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
*
* @var array
*/
- protected $generatedIds = array();
+ protected $generatedIds = [];
/**
* The state service.
@@ -65,7 +65,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
// Only check the modules, if the $modules property was not inherited.
$rp = new \ReflectionProperty($class, 'modules');
if ($rp->class == $class) {
- foreach (array_intersect(array('node', 'comment'), $class::$modules) as $module) {
+ foreach (array_intersect(['node', 'comment'], $class::$modules) as $module) {
$this->installEntitySchema($module);
}
if (in_array('forum', $class::$modules, TRUE)) {
@@ -82,7 +82,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
$class = get_parent_class($class);
}
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
}
/**
@@ -96,13 +96,13 @@ abstract class EntityUnitTestBase extends KernelTestBase {
* @return \Drupal\user\Entity\User
* The created user entity.
*/
- protected function createUser($values = array(), $permissions = array()) {
+ protected function createUser($values = [], $permissions = []) {
if ($permissions) {
// Create a new role and apply permissions to it.
- $role = Role::create(array(
+ $role = Role::create([
'id' => strtolower($this->randomMachineName(8)),
'label' => $this->randomMachineName(8),
- ));
+ ]);
$role->save();
user_role_grant_permissions($role->id(), $permissions);
$values['roles'][] = $role->id();
@@ -128,7 +128,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
*/
protected function reloadEntity(EntityInterface $entity) {
$controller = $this->entityManager->getStorage($entity->getEntityTypeId());
- $controller->resetCache(array($entity->id()));
+ $controller->resetCache([$entity->id()]);
return $controller->load($entity->id());
}
@@ -141,7 +141,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
protected function getHooksInfo() {
$key = 'entity_test.hooks';
$hooks = $this->state->get($key);
- $this->state->set($key, array());
+ $this->state->set($key, []);
return $hooks;
}
@@ -152,7 +152,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
* The module to install.
*/
protected function installModule($module) {
- $this->enableModules(array($module));
+ $this->enableModules([$module]);
$this->refreshServices();
}
@@ -163,7 +163,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
* The module to uninstall.
*/
protected function uninstallModule($module) {
- $this->disableModules(array($module));
+ $this->disableModules([$module]);
$this->refreshServices();
}
diff --git a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php
index f6da0a2d2b5..74c11038069 100644
--- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php
@@ -53,7 +53,7 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase {
}
$expected_cache_tags = Cache::mergeTags($cache_tag, $view_cache_tag);
$expected_cache_tags = Cache::mergeTags($expected_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity));
- $expected_cache_tags = Cache::mergeTags($expected_cache_tags, array($render_cache_tag));
+ $expected_cache_tags = Cache::mergeTags($expected_cache_tags, [$render_cache_tag]);
$this->verifyRenderCache($cid, $expected_cache_tags, $redirected_cid);
}
diff --git a/core/modules/system/src/Tests/Form/AlterTest.php b/core/modules/system/src/Tests/Form/AlterTest.php
index ae307224cbc..e77cf301376 100644
--- a/core/modules/system/src/Tests/Form/AlterTest.php
+++ b/core/modules/system/src/Tests/Form/AlterTest.php
@@ -17,7 +17,7 @@ class AlterTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'form_test');
+ public static $modules = ['block', 'form_test'];
/**
* Tests execution order of hook_form_alter() and hook_form_FORM_ID_alter().
@@ -26,13 +26,13 @@ class AlterTest extends WebTestBase {
$this->drupalGet('form-test/alter');
// Ensure that the order is first by module, then for a given module, the
// id-specific one after the generic one.
- $expected = array(
+ $expected = [
'block_form_form_test_alter_form_alter() executed.',
'form_test_form_alter() executed.',
'form_test_form_form_test_alter_form_alter() executed.',
'system_form_form_test_alter_form_alter() executed.',
- );
- $content = preg_replace('/\s+/', ' ', Xss::filter($this->content, array()));
+ ];
+ $content = preg_replace('/\s+/', ' ', Xss::filter($this->content, []));
$this->assert(strpos($content, implode(' ', $expected)) !== FALSE, 'Form alter hooks executed in the expected order.');
}
diff --git a/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php b/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php
index 3702d35eb34..95324c96da3 100644
--- a/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php
+++ b/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php
@@ -18,19 +18,19 @@ class ArbitraryRebuildTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('text', 'form_test');
+ public static $modules = ['text', 'form_test'];
protected function setUp() {
parent::setUp();
// Auto-create a field for testing.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => 'user',
'field_name' => 'test_multiple',
'type' => 'text',
'cardinality' => -1,
'translatable' => FALSE,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'user',
'field_name' => 'test_multiple',
@@ -38,10 +38,10 @@ class ArbitraryRebuildTest extends WebTestBase {
'label' => 'Test a multiple valued field',
])->save();
entity_get_form_display('user', 'user', 'register')
- ->setComponent('test_multiple', array(
+ ->setComponent('test_multiple', [
'type' => 'text_textfield',
'weight' => 0,
- ))
+ ])
->save();
}
@@ -49,10 +49,10 @@ class ArbitraryRebuildTest extends WebTestBase {
* Tests a basic rebuild with the user registration form.
*/
function testUserRegistrationRebuild() {
- $edit = array(
+ $edit = [
'name' => 'foo',
'mail' => 'bar@example.com',
- );
+ ];
$this->drupalPostForm('user/register', $edit, 'Rebuild');
$this->assertText('Form rebuilt.');
$this->assertFieldByName('name', 'foo', 'Entered username has been kept.');
@@ -63,10 +63,10 @@ class ArbitraryRebuildTest extends WebTestBase {
* Tests a rebuild caused by a multiple value field.
*/
function testUserRegistrationMultipleField() {
- $edit = array(
+ $edit = [
'name' => 'foo',
'mail' => 'bar@example.com',
- );
+ ];
$this->drupalPostForm('user/register', $edit, t('Add another item'));
$this->assertText('Test a multiple valued field', 'Form has been rebuilt.');
$this->assertFieldByName('name', 'foo', 'Entered username has been kept.');
diff --git a/core/modules/system/src/Tests/Form/CheckboxTest.php b/core/modules/system/src/Tests/Form/CheckboxTest.php
index ebeeeeae183..0e17309d0fe 100644
--- a/core/modules/system/src/Tests/Form/CheckboxTest.php
+++ b/core/modules/system/src/Tests/Form/CheckboxTest.php
@@ -17,16 +17,16 @@ class CheckboxTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
function testFormCheckbox() {
// Ensure that the checked state is determined and rendered correctly for
// tricky combinations of default and return values.
- foreach (array(FALSE, NULL, TRUE, 0, '0', '', 1, '1', 'foobar', '1foobar') as $default_value) {
+ foreach ([FALSE, NULL, TRUE, 0, '0', '', 1, '1', 'foobar', '1foobar'] as $default_value) {
// Only values that can be used for array indices are supported for
// #return_value, with the exception of integer 0, which is not supported.
// @see \Drupal\Core\Render\Element\Checkbox::processCheckbox().
- foreach (array('0', '', 1, '1', 'foobar', '1foobar') as $return_value) {
+ foreach (['0', '', 1, '1', 'foobar', '1foobar'] as $return_value) {
$form_array = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestCheckboxTypeJugglingForm', $default_value, $return_value);
$form = \Drupal::service('renderer')->renderRoot($form_array);
if ($default_value === TRUE) {
@@ -48,33 +48,33 @@ class CheckboxTest extends WebTestBase {
$checked = ($default_value === '1foobar');
}
$checked_in_html = strpos($form, 'checked') !== FALSE;
- $message = format_string('#default_value is %default_value #return_value is %return_value.', array('%default_value' => var_export($default_value, TRUE), '%return_value' => var_export($return_value, TRUE)));
+ $message = format_string('#default_value is %default_value #return_value is %return_value.', ['%default_value' => var_export($default_value, TRUE), '%return_value' => var_export($return_value, TRUE)]);
$this->assertIdentical($checked, $checked_in_html, $message);
}
}
// Ensure that $form_state->getValues() is populated correctly for a
// checkboxes group that includes a 0-indexed array of options.
- $results = json_decode($this->drupalPostForm('form-test/checkboxes-zero/1', array(), 'Save'));
- $this->assertIdentical($results->checkbox_off, array(0, 0, 0), 'All three in checkbox_off are zeroes: off.');
- $this->assertIdentical($results->checkbox_zero_default, array('0', 0, 0), 'The first choice is on in checkbox_zero_default');
- $this->assertIdentical($results->checkbox_string_zero_default, array('0', 0, 0), 'The first choice is on in checkbox_string_zero_default');
- $edit = array('checkbox_off[0]' => '0');
+ $results = json_decode($this->drupalPostForm('form-test/checkboxes-zero/1', [], 'Save'));
+ $this->assertIdentical($results->checkbox_off, [0, 0, 0], 'All three in checkbox_off are zeroes: off.');
+ $this->assertIdentical($results->checkbox_zero_default, ['0', 0, 0], 'The first choice is on in checkbox_zero_default');
+ $this->assertIdentical($results->checkbox_string_zero_default, ['0', 0, 0], 'The first choice is on in checkbox_string_zero_default');
+ $edit = ['checkbox_off[0]' => '0'];
$results = json_decode($this->drupalPostForm('form-test/checkboxes-zero/1', $edit, 'Save'));
- $this->assertIdentical($results->checkbox_off, array('0', 0, 0), 'The first choice is on in checkbox_off but the rest is not');
+ $this->assertIdentical($results->checkbox_off, ['0', 0, 0], 'The first choice is on in checkbox_off but the rest is not');
// Ensure that each checkbox is rendered correctly for a checkboxes group
// that includes a 0-indexed array of options.
- $this->drupalPostForm('form-test/checkboxes-zero/0', array(), 'Save');
+ $this->drupalPostForm('form-test/checkboxes-zero/0', [], 'Save');
$checkboxes = $this->xpath('//input[@type="checkbox"]');
$this->assertIdentical(count($checkboxes), 9, 'Correct number of checkboxes found.');
foreach ($checkboxes as $checkbox) {
$checked = isset($checkbox['checked']);
$name = (string) $checkbox['name'];
- $this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', array('%name' => $name)));
+ $this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', ['%name' => $name]));
}
- $edit = array('checkbox_off[0]' => '0');
+ $edit = ['checkbox_off[0]' => '0'];
$this->drupalPostForm('form-test/checkboxes-zero/0', $edit, 'Save');
$checkboxes = $this->xpath('//input[@type="checkbox"]');
@@ -82,7 +82,7 @@ class CheckboxTest extends WebTestBase {
foreach ($checkboxes as $checkbox) {
$checked = isset($checkbox['checked']);
$name = (string) $checkbox['name'];
- $this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', array('%name' => $name)));
+ $this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', ['%name' => $name]));
}
}
diff --git a/core/modules/system/src/Tests/Form/ConfirmFormTest.php b/core/modules/system/src/Tests/Form/ConfirmFormTest.php
index 312aa2ef7c5..a26d493e6bb 100644
--- a/core/modules/system/src/Tests/Form/ConfirmFormTest.php
+++ b/core/modules/system/src/Tests/Form/ConfirmFormTest.php
@@ -18,33 +18,33 @@ class ConfirmFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
function testConfirmForm() {
// Test the building of the form.
$this->drupalGet('form-test/confirm-form');
$site_name = $this->config('system.site')->get('name');
- $this->assertTitle(t('ConfirmFormTestForm::getQuestion(). | @site-name', array('@site-name' => $site_name)), 'The question was found as the page title.');
+ $this->assertTitle(t('ConfirmFormTestForm::getQuestion(). | @site-name', ['@site-name' => $site_name]), 'The question was found as the page title.');
$this->assertText(t('ConfirmFormTestForm::getDescription().'), 'The description was used.');
$this->assertFieldByXPath('//input[@id="edit-submit"]', t('ConfirmFormTestForm::getConfirmText().'), 'The confirm text was used.');
// Test cancelling the form.
$this->clickLink(t('ConfirmFormTestForm::getCancelText().'));
- $this->assertUrl('form-test/autocomplete', array(), "The form's cancel link was followed.");
+ $this->assertUrl('form-test/autocomplete', [], "The form's cancel link was followed.");
// Test submitting the form.
$this->drupalPostForm('form-test/confirm-form', NULL, t('ConfirmFormTestForm::getConfirmText().'));
$this->assertText('The ConfirmFormTestForm::submitForm() method was used for this form.');
- $this->assertUrl('', array(), "The form's redirect was followed.");
+ $this->assertUrl('', [], "The form's redirect was followed.");
// Test submitting the form with a destination.
- $this->drupalPostForm('form-test/confirm-form', NULL, t('ConfirmFormTestForm::getConfirmText().'), array('query' => array('destination' => 'admin/config')));
- $this->assertUrl('admin/config', array(), "The form's redirect was not followed, the destination query string was followed.");
+ $this->drupalPostForm('form-test/confirm-form', NULL, t('ConfirmFormTestForm::getConfirmText().'), ['query' => ['destination' => 'admin/config']]);
+ $this->assertUrl('admin/config', [], "The form's redirect was not followed, the destination query string was followed.");
// Test cancelling the form with a complex destination.
$this->drupalGet('form-test/confirm-form-array-path');
$this->clickLink(t('ConfirmFormArrayPathTestForm::getCancelText().'));
- $this->assertUrl('form-test/confirm-form', array('query' => array('destination' => 'admin/config')), "The form's complex cancel link was followed.");
+ $this->assertUrl('form-test/confirm-form', ['query' => ['destination' => 'admin/config']], "The form's complex cancel link was followed.");
}
/**
@@ -53,14 +53,14 @@ class ConfirmFormTest extends WebTestBase {
public function testConfirmFormWithExternalDestination() {
$this->drupalGet('form-test/confirm-form');
$this->assertCancelLinkUrl(Url::fromRoute('form_test.route8'));
- $this->drupalGet('form-test/confirm-form', array('query' => array('destination' => 'node')));
+ $this->drupalGet('form-test/confirm-form', ['query' => ['destination' => 'node']]);
$this->assertCancelLinkUrl(Url::fromUri('internal:/node'));
- $this->drupalGet('form-test/confirm-form', array('query' => array('destination' => 'http://example.com')));
+ $this->drupalGet('form-test/confirm-form', ['query' => ['destination' => 'http://example.com']]);
$this->assertCancelLinkUrl(Url::fromRoute('form_test.route8'));
- $this->drupalGet('form-test/confirm-form', array('query' => array('destination' => '<front>')));
+ $this->drupalGet('form-test/confirm-form', ['query' => ['destination' => '<front>']]);
$this->assertCancelLinkUrl(Url::fromRoute('<front>'));
// Other invalid destinations, should fall back to the form default.
- $this->drupalGet('form-test/confirm-form', array('query' => array('destination' => '/http://example.com')));
+ $this->drupalGet('form-test/confirm-form', ['query' => ['destination' => '/http://example.com']]);
$this->assertCancelLinkUrl(Url::fromRoute('form_test.route8'));
}
diff --git a/core/modules/system/src/Tests/Form/ElementTest.php b/core/modules/system/src/Tests/Form/ElementTest.php
index 0ae2edc4959..5b63c6b11e9 100644
--- a/core/modules/system/src/Tests/Form/ElementTest.php
+++ b/core/modules/system/src/Tests/Form/ElementTest.php
@@ -16,7 +16,7 @@ class ElementTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Tests placeholder text for elements that support placeholders.
@@ -25,19 +25,19 @@ class ElementTest extends WebTestBase {
$this->drupalGet('form-test/placeholder-text');
$expected = 'placeholder-text';
// Test to make sure non-textarea elements have the proper placeholder text.
- foreach (array('textfield', 'tel', 'url', 'password', 'email', 'number') as $type) {
- $element = $this->xpath('//input[@id=:id and @placeholder=:expected]', array(
+ foreach (['textfield', 'tel', 'url', 'password', 'email', 'number'] as $type) {
+ $element = $this->xpath('//input[@id=:id and @placeholder=:expected]', [
':id' => 'edit-' . $type,
':expected' => $expected,
- ));
- $this->assertTrue(!empty($element), format_string('Placeholder text placed in @type.', array('@type' => $type)));
+ ]);
+ $this->assertTrue(!empty($element), format_string('Placeholder text placed in @type.', ['@type' => $type]));
}
// Test to make sure textarea has the proper placeholder text.
- $element = $this->xpath('//textarea[@id=:id and @placeholder=:expected]', array(
+ $element = $this->xpath('//textarea[@id=:id and @placeholder=:expected]', [
':id' => 'edit-textarea',
':expected' => $expected,
- ));
+ ]);
$this->assertTrue(!empty($element), 'Placeholder text placed in textarea.');
}
@@ -48,9 +48,9 @@ class ElementTest extends WebTestBase {
$this->drupalGet('form-test/checkboxes-radios');
// Verify that all options appear in their defined order.
- foreach (array('checkbox', 'radio') as $type) {
- $elements = $this->xpath('//input[@type=:type]', array(':type' => $type));
- $expected_values = array('0', 'foo', '1', 'bar', '>');
+ foreach (['checkbox', 'radio'] as $type) {
+ $elements = $this->xpath('//input[@type=:type]', [':type' => $type]);
+ $expected_values = ['0', 'foo', '1', 'bar', '>'];
foreach ($elements as $element) {
$expected = array_shift($expected_values);
$this->assertIdentical((string) $element['value'], $expected);
@@ -68,23 +68,23 @@ class ElementTest extends WebTestBase {
// Verify that all options appear in their defined order, taking a custom
// #weight into account.
- foreach (array('checkbox', 'radio') as $type) {
- $elements = $this->xpath('//input[@type=:type]', array(':type' => $type));
- $expected_values = array('0', 'foo', 'bar', '>', '1');
+ foreach (['checkbox', 'radio'] as $type) {
+ $elements = $this->xpath('//input[@type=:type]', [':type' => $type]);
+ $expected_values = ['0', 'foo', 'bar', '>', '1'];
foreach ($elements as $element) {
$expected = array_shift($expected_values);
$this->assertIdentical((string) $element['value'], $expected);
}
}
// Verify that custom #description properties are output.
- foreach (array('checkboxes', 'radios') as $type) {
- $elements = $this->xpath('//input[@id=:id]/following-sibling::div[@class=:class]', array(
+ foreach (['checkboxes', 'radios'] as $type) {
+ $elements = $this->xpath('//input[@id=:id]/following-sibling::div[@class=:class]', [
':id' => 'edit-' . $type . '-foo',
':class' => 'description',
- ));
- $this->assertTrue(count($elements), format_string('Custom %type option description found.', array(
+ ]);
+ $this->assertTrue(count($elements), format_string('Custom %type option description found.', [
'%type' => $type,
- )));
+ ]));
}
}
@@ -95,11 +95,11 @@ class ElementTest extends WebTestBase {
$this->drupalGet('form-test/checkboxes-radios');
// Verify that wrapper id is different from element id.
- foreach (array('checkboxes', 'radios') as $type) {
- $element_ids = $this->xpath('//div[@id=:id]', array(':id' => 'edit-' . $type));
- $wrapper_ids = $this->xpath('//fieldset[@id=:id]', array(':id' => 'edit-' . $type . '--wrapper'));
- $this->assertTrue(count($element_ids) == 1, format_string('A single element id found for type %type', array('%type' => $type)));
- $this->assertTrue(count($wrapper_ids) == 1, format_string('A single wrapper id found for type %type', array('%type' => $type)));
+ foreach (['checkboxes', 'radios'] as $type) {
+ $element_ids = $this->xpath('//div[@id=:id]', [':id' => 'edit-' . $type]);
+ $wrapper_ids = $this->xpath('//fieldset[@id=:id]', [':id' => 'edit-' . $type . '--wrapper']);
+ $this->assertTrue(count($element_ids) == 1, format_string('A single element id found for type %type', ['%type' => $type]));
+ $this->assertTrue(count($wrapper_ids) == 1, format_string('A single wrapper id found for type %type', ['%type' => $type]));
}
}
@@ -162,7 +162,7 @@ class ElementTest extends WebTestBase {
$result = $this->xpath('//input[@id="edit-autocomplete-2" and contains(@data-autocomplete-path, "form-test/autocomplete-2/value")]');
$this->assertEqual(count($result), 0, 'Ensure that the user does not have access to the autocompletion');
- $user = $this->drupalCreateUser(array('access autocomplete test'));
+ $user = $this->drupalCreateUser(['access autocomplete test']);
$this->drupalLogin($user);
$this->drupalGet('form-test/autocomplete');
diff --git a/core/modules/system/src/Tests/Form/ElementsLabelsTest.php b/core/modules/system/src/Tests/Form/ElementsLabelsTest.php
index 5965dc2552d..02f4659f120 100644
--- a/core/modules/system/src/Tests/Form/ElementsLabelsTest.php
+++ b/core/modules/system/src/Tests/Form/ElementsLabelsTest.php
@@ -16,7 +16,7 @@ class ElementsLabelsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Test form elements, labels, title attributes and required marks output
@@ -137,12 +137,12 @@ class ElementsLabelsTest extends WebTestBase {
* Return a form with element with not all properties defined.
*/
protected function getFormWithLimitedProperties() {
- $form = array();
+ $form = [];
- $form['fieldset'] = array(
+ $form['fieldset'] = [
'#type' => 'fieldset',
'#title' => 'Fieldset',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php b/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php
index 34a558cb0d4..e09ba776aeb 100644
--- a/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php
+++ b/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php
@@ -17,7 +17,7 @@ class ElementsTableSelectTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Test the display of checkboxes when #multiple is TRUE.
@@ -31,9 +31,9 @@ class ElementsTableSelectTest extends WebTestBase {
// Test for the presence of the Select all rows tableheader.
$this->assertFieldByXPath('//th[@class="select-all"]', NULL, 'Presence of the "Select all" checkbox.');
- $rows = array('row1', 'row2', 'row3');
+ $rows = ['row1', 'row2', 'row3'];
foreach ($rows as $row) {
- $this->assertFieldByXPath('//input[@type="checkbox"]', $row, format_string('Checkbox for value @row.', array('@row' => $row)));
+ $this->assertFieldByXPath('//input[@type="checkbox"]', $row, format_string('Checkbox for value @row.', ['@row' => $row]));
}
}
@@ -41,20 +41,20 @@ class ElementsTableSelectTest extends WebTestBase {
* Test the presence of ajax functionality for all options.
*/
function testAjax() {
- $rows = array('row1', 'row2', 'row3');
+ $rows = ['row1', 'row2', 'row3'];
// Test checkboxes (#multiple == TRUE).
foreach ($rows as $row) {
$element = 'tableselect[' . $row . ']';
- $edit = array($element => TRUE);
+ $edit = [$element => TRUE];
$result = $this->drupalPostAjaxForm('form_test/tableselect/multiple-true', $edit, $element);
- $this->assertFalse(empty($result), t('Ajax triggers on checkbox for @row.', array('@row' => $row)));
+ $this->assertFalse(empty($result), t('Ajax triggers on checkbox for @row.', ['@row' => $row]));
}
// Test radios (#multiple == FALSE).
$element = 'tableselect';
foreach ($rows as $row) {
- $edit = array($element => $row);
+ $edit = [$element => $row];
$result = $this->drupalPostAjaxForm('form_test/tableselect/multiple-false', $edit, $element);
- $this->assertFalse(empty($result), t('Ajax triggers on radio for @row.', array('@row' => $row)));
+ $this->assertFalse(empty($result), t('Ajax triggers on radio for @row.', ['@row' => $row]));
}
}
@@ -69,9 +69,9 @@ class ElementsTableSelectTest extends WebTestBase {
// Test for the absence of the Select all rows tableheader.
$this->assertNoFieldByXPath('//th[@class="select-all"]', '', 'Absence of the "Select all" checkbox.');
- $rows = array('row1', 'row2', 'row3');
+ $rows = ['row1', 'row2', 'row3'];
foreach ($rows as $row) {
- $this->assertFieldByXPath('//input[@type="radio"]', $row, format_string('Radio button for value @row.', array('@row' => $row)));
+ $this->assertFieldByXPath('//input[@type="radio"]', $row, format_string('Radio button for value @row.', ['@row' => $row]));
}
}
@@ -93,7 +93,7 @@ class ElementsTableSelectTest extends WebTestBase {
// radio, one cell in the first column, one cell in the second column,
// and two cells in the third column which has colspan 2.
for ( $i = 0; $i <= 1; $i++) {
- $this->assertEqual(count($table_body[0]->tr[$i]->td), 5, format_string('There are five cells in row @row.', array('@row' => $i)));
+ $this->assertEqual(count($table_body[0]->tr[$i]->td), 5, format_string('There are five cells in row @row.', ['@row' => $i]));
}
// The third row should have 3 cells, one for the radio, one spanning the
// first and second column, and a third in column 3 (which has colspan 3).
@@ -114,7 +114,7 @@ class ElementsTableSelectTest extends WebTestBase {
function testMultipleTrueSubmit() {
// Test a submission with one checkbox checked.
- $edit = array();
+ $edit = [];
$edit['tableselect[row1]'] = TRUE;
$this->drupalPostForm('form_test/tableselect/multiple-true', $edit, 'Submit');
@@ -170,18 +170,18 @@ class ElementsTableSelectTest extends WebTestBase {
list($header, $options) = _form_test_tableselect_get_data();
- $form['tableselect'] = array(
+ $form['tableselect'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
- );
+ ];
// Test with a valid value.
- list(, , $errors) = $this->formSubmitHelper($form, array('tableselect' => array('row1' => 'row1')));
+ list(, , $errors) = $this->formSubmitHelper($form, ['tableselect' => ['row1' => 'row1']]);
$this->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for checkboxes.');
// Test with an invalid value.
- list(, , $errors) = $this->formSubmitHelper($form, array('tableselect' => array('non_existing_value' => 'non_existing_value')));
+ list(, , $errors) = $this->formSubmitHelper($form, ['tableselect' => ['non_existing_value' => 'non_existing_value']]);
$this->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for checkboxes.');
}
@@ -194,19 +194,19 @@ class ElementsTableSelectTest extends WebTestBase {
list($header, $options) = _form_test_tableselect_get_data();
- $form['tableselect'] = array(
+ $form['tableselect'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#multiple' => FALSE,
- );
+ ];
// Test with a valid value.
- list(, , $errors) = $this->formSubmitHelper($form, array('tableselect' => 'row1'));
+ list(, , $errors) = $this->formSubmitHelper($form, ['tableselect' => 'row1']);
$this->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for radio buttons.');
// Test with an invalid value.
- list(, , $errors) = $this->formSubmitHelper($form, array('tableselect' => 'non_existing_value'));
+ list(, , $errors) = $this->formSubmitHelper($form, ['tableselect' => 'non_existing_value']);
$this->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for radio buttons.');
}
@@ -226,7 +226,7 @@ class ElementsTableSelectTest extends WebTestBase {
$form_id = $this->randomMachineName();
$form_state = new FormState();
- $form['op'] = array('#type' => 'submit', '#value' => t('Submit'));
+ $form['op'] = ['#type' => 'submit', '#value' => t('Submit')];
// The form token CSRF protection should not interfere with this test, so we
// bypass it by setting the token to FALSE.
$form['#token'] = FALSE;
@@ -252,7 +252,7 @@ class ElementsTableSelectTest extends WebTestBase {
// Return the processed form together with form_state and errors
// to allow the caller lowlevel access to the form.
- return array($form, $form_state, $errors);
+ return [$form, $form_state, $errors];
}
}
diff --git a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php
index 2e630cccae0..73d5dfabb70 100644
--- a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php
+++ b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php
@@ -18,7 +18,7 @@ class ElementsVerticalTabsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* A user with permission to access vertical_tab_test_tabs.
@@ -37,7 +37,7 @@ class ElementsVerticalTabsTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('access vertical_tab_test tabs'));
+ $this->adminUser = $this->drupalCreateUser(['access vertical_tab_test tabs']);
$this->webUser = $this->drupalCreateUser();
$this->drupalLogin($this->adminUser);
}
diff --git a/core/modules/system/src/Tests/Form/EmailTest.php b/core/modules/system/src/Tests/Form/EmailTest.php
index e53247f3c0e..ae925a996d6 100644
--- a/core/modules/system/src/Tests/Form/EmailTest.php
+++ b/core/modules/system/src/Tests/Form/EmailTest.php
@@ -17,7 +17,7 @@ class EmailTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
protected $profile = 'testing';
@@ -25,20 +25,20 @@ class EmailTest extends WebTestBase {
* Tests that #type 'email' fields are properly validated.
*/
function testFormEmail() {
- $edit = array();
+ $edit = [];
$edit['email'] = 'invalid';
$edit['email_required'] = ' ';
$this->drupalPostForm('form-test/email', $edit, 'Submit');
- $this->assertRaw(t('The email address %mail is not valid.', array('%mail' => 'invalid')));
- $this->assertRaw(t('@name field is required.', array('@name' => 'Address')));
+ $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
+ $this->assertRaw(t('@name field is required.', ['@name' => 'Address']));
- $edit = array();
+ $edit = [];
$edit['email_required'] = ' foo.bar@example.com ';
$values = Json::decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
$this->assertIdentical($values['email'], '');
$this->assertEqual($values['email_required'], 'foo.bar@example.com');
- $edit = array();
+ $edit = [];
$edit['email'] = 'foo@example.com';
$edit['email_required'] = 'example@drupal.org';
$values = Json::decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
diff --git a/core/modules/system/src/Tests/Form/FormStoragePageCacheTest.php b/core/modules/system/src/Tests/Form/FormStoragePageCacheTest.php
index 0ef62e865c1..b6c66865832 100644
--- a/core/modules/system/src/Tests/Form/FormStoragePageCacheTest.php
+++ b/core/modules/system/src/Tests/Form/FormStoragePageCacheTest.php
@@ -14,7 +14,7 @@ class FormStoragePageCacheTest extends WebTestBase {
/**
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* {@inheritdoc}
diff --git a/core/modules/system/src/Tests/Form/FormTest.php b/core/modules/system/src/Tests/Form/FormTest.php
index cf738369bd0..fc6c648d124 100644
--- a/core/modules/system/src/Tests/Form/FormTest.php
+++ b/core/modules/system/src/Tests/Form/FormTest.php
@@ -25,19 +25,19 @@ class FormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'form_test', 'file', 'datetime');
+ public static $modules = ['filter', 'form_test', 'file', 'datetime'];
protected function setUp() {
parent::setUp();
- $filtered_html_format = FilterFormat::create(array(
+ $filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
- ));
+ ]);
$filtered_html_format->save();
$filtered_html_permission = $filtered_html_format->getPermissionName();
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array($filtered_html_permission));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [$filtered_html_permission]);
}
/**
@@ -51,47 +51,47 @@ class FormTest extends WebTestBase {
function testRequiredFields() {
// Originates from https://www.drupal.org/node/117748.
// Sets of empty strings and arrays.
- $empty_strings = array('""' => "", '"\n"' => "\n", '" "' => " ", '"\t"' => "\t", '" \n\t "' => " \n\t ", '"\n\n\n\n\n"' => "\n\n\n\n\n");
- $empty_arrays = array('array()' => array());
- $empty_checkbox = array(NULL);
+ $empty_strings = ['""' => "", '"\n"' => "\n", '" "' => " ", '"\t"' => "\t", '" \n\t "' => " \n\t ", '"\n\n\n\n\n"' => "\n\n\n\n\n"];
+ $empty_arrays = ['array()' => []];
+ $empty_checkbox = [NULL];
- $elements['textfield']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'textfield');
+ $elements['textfield']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'textfield'];
$elements['textfield']['empty_values'] = $empty_strings;
- $elements['telephone']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'tel');
+ $elements['telephone']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'tel'];
$elements['telephone']['empty_values'] = $empty_strings;
- $elements['url']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'url');
+ $elements['url']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'url'];
$elements['url']['empty_values'] = $empty_strings;
- $elements['search']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'search');
+ $elements['search']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'search'];
$elements['search']['empty_values'] = $empty_strings;
- $elements['password']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'password');
+ $elements['password']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'password'];
$elements['password']['empty_values'] = $empty_strings;
- $elements['password_confirm']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'password_confirm');
+ $elements['password_confirm']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'password_confirm'];
// Provide empty values for both password fields.
foreach ($empty_strings as $key => $value) {
- $elements['password_confirm']['empty_values'][$key] = array('pass1' => $value, 'pass2' => $value);
+ $elements['password_confirm']['empty_values'][$key] = ['pass1' => $value, 'pass2' => $value];
}
- $elements['textarea']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'textarea');
+ $elements['textarea']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'textarea'];
$elements['textarea']['empty_values'] = $empty_strings;
- $elements['radios']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'radios', '#options' => array('' => t('None'), $this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()));
+ $elements['radios']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'radios', '#options' => ['' => t('None'), $this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()]];
$elements['radios']['empty_values'] = $empty_arrays;
- $elements['checkbox']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'checkbox', '#required' => TRUE);
+ $elements['checkbox']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'checkbox', '#required' => TRUE];
$elements['checkbox']['empty_values'] = $empty_checkbox;
- $elements['checkboxes']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'checkboxes', '#options' => array($this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()));
+ $elements['checkboxes']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'checkboxes', '#options' => [$this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()]];
$elements['checkboxes']['empty_values'] = $empty_arrays;
- $elements['select']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'select', '#options' => array('' => t('None'), $this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()));
+ $elements['select']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'select', '#options' => ['' => t('None'), $this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()]];
$elements['select']['empty_values'] = $empty_strings;
- $elements['file']['element'] = array('#title' => $this->randomMachineName(), '#type' => 'file');
+ $elements['file']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'file'];
$elements['file']['empty_values'] = $empty_strings;
// Regular expression to find the expected marker on required elements.
@@ -99,11 +99,11 @@ class FormTest extends WebTestBase {
// Go through all the elements and all the empty values for them.
foreach ($elements as $type => $data) {
foreach ($data['empty_values'] as $key => $empty) {
- foreach (array(TRUE, FALSE) as $required) {
+ foreach ([TRUE, FALSE] as $required) {
$form_id = $this->randomMachineName();
- $form = array();
+ $form = [];
$form_state = new FormState();
- $form['op'] = array('#type' => 'submit', '#value' => t('Submit'));
+ $form['op'] = ['#type' => 'submit', '#value' => t('Submit')];
$element = $data['element']['#title'];
$form[$element] = $data['element'];
$form[$element]['#required'] = $required;
@@ -167,13 +167,13 @@ class FormTest extends WebTestBase {
$form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestValidateRequiredForm');
// Attempt to submit the form with no required fields set.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('form-test/validate-required', $edit, 'Submit');
// The only error messages that should appear are the relevant 'required'
// messages for each field.
- $expected = array();
- foreach (array('textfield', 'checkboxes', 'select', 'radios') as $key) {
+ $expected = [];
+ foreach (['textfield', 'checkboxes', 'select', 'radios'] as $key) {
if (isset($form[$key]['#required_error'])) {
$expected[] = $form[$key]['#required_error'];
}
@@ -181,7 +181,7 @@ class FormTest extends WebTestBase {
$expected[] = $form[$key]['#form_test_required_error'];
}
else {
- $expected[] = t('@name field is required.', array('@name' => $form[$key]['#title']));
+ $expected[] = t('@name field is required.', ['@name' => $form[$key]['#title']]);
}
}
@@ -191,7 +191,7 @@ class FormTest extends WebTestBase {
$expected_key = array_search($error[0], $expected);
// If the error message is not one of the expected messages, fail.
if ($expected_key === FALSE) {
- $this->fail(format_string("Unexpected error message: @error", array('@error' => $error[0])));
+ $this->fail(format_string("Unexpected error message: @error", ['@error' => $error[0]]));
}
// Remove the expected message from the list once it is found.
else {
@@ -201,7 +201,7 @@ class FormTest extends WebTestBase {
// Fail if any expected messages were not found.
foreach ($expected as $not_found) {
- $this->fail(format_string("Found error message: @error", array('@error' => $not_found)));
+ $this->fail(format_string("Found error message: @error", ['@error' => $not_found]));
}
// Verify that input elements are still empty.
@@ -218,12 +218,12 @@ class FormTest extends WebTestBase {
// Submit again with required fields set and verify that there are no
// error messages.
- $edit = array(
+ $edit = [
'textfield' => $this->randomString(),
'checkboxes[foo]' => TRUE,
'select' => 'foo',
'radios' => 'bar',
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Submit');
$this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, 'No error message is displayed when all required fields are filled.');
$this->assertRaw("The form_test_validate_required_form form was submitted successfully.", 'Validation form submitted successfully.');
@@ -240,13 +240,13 @@ class FormTest extends WebTestBase {
$this->drupalLogin($account);
// Submit again with required fields set but an invalid form token and
// verify that all the values are retained.
- $edit = array(
+ $edit = [
'textfield' => $this->randomString(),
'checkboxes[bar]' => TRUE,
'select' => 'bar',
'radios' => 'foo',
'form_token' => 'invalid token',
- );
+ ];
$this->drupalPostForm(Url::fromRoute('form_test.validate_required'), $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
@@ -258,11 +258,11 @@ class FormTest extends WebTestBase {
$this->assertFieldChecked('edit-radios-foo');
// Check another form that has a textarea input.
- $edit = array(
+ $edit = [
'textfield' => $this->randomString(),
'textarea' => $this->randomString() . "\n",
'form_token' => 'invalid token',
- );
+ ];
$this->drupalPostForm(Url::fromRoute('form_test.required'), $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
@@ -270,20 +270,20 @@ class FormTest extends WebTestBase {
$this->assertFieldByName('textarea', $edit['textarea']);
// Check another form that has a number input.
- $edit = array(
+ $edit = [
'integer_step' => mt_rand(1, 100),
'form_token' => 'invalid token',
- );
+ ];
$this->drupalPostForm(Url::fromRoute('form_test.number'), $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
$this->assertFieldByName('integer_step', $edit['integer_step']);
// Check a form with a Url field
- $edit = array(
+ $edit = [
'url' => $this->randomString(),
'form_token' => 'invalid token',
- );
+ ];
$this->drupalPostForm(Url::fromRoute('form_test.url'), $edit, 'Submit');
$this->assertFieldByXpath('//div[contains(@class, "error")]', NULL, 'Error message is displayed with invalid token even when required fields are filled.');
$this->assertText('The form has become outdated. Copy any unsaved work in the form below');
@@ -314,7 +314,7 @@ class FormTest extends WebTestBase {
*/
function testRequiredTextfieldNoTitle() {
// Attempt to submit the form with no required field set.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('form-test/validate-required-no-title', $edit, 'Submit');
$this->assertNoRaw("The form_test_validate_required_form_no_title form was submitted successfully.", 'Validation form submitted successfully.');
@@ -326,9 +326,9 @@ class FormTest extends WebTestBase {
// Submit again with required fields set and verify that there are no
// error messages.
- $edit = array(
+ $edit = [
'textfield' => $this->randomString(),
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Submit');
$this->assertNoFieldByXpath('//input[contains(@class, "error")]', FALSE, 'No error input form element class found.');
$this->assertRaw("The form_test_validate_required_form_no_title form was submitted successfully.", 'Validation form submitted successfully.');
@@ -341,26 +341,26 @@ class FormTest extends WebTestBase {
*/
function testCheckboxProcessing() {
// First, try to submit without the required checkbox.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('form-test/checkbox', $edit, t('Submit'));
- $this->assertRaw(t('@name field is required.', array('@name' => 'required_checkbox')), 'A required checkbox is actually mandatory');
+ $this->assertRaw(t('@name field is required.', ['@name' => 'required_checkbox']), 'A required checkbox is actually mandatory');
// Now try to submit the form correctly.
- $values = Json::decode($this->drupalPostForm(NULL, array('required_checkbox' => 1), t('Submit')));
- $expected_values = array(
+ $values = Json::decode($this->drupalPostForm(NULL, ['required_checkbox' => 1], t('Submit')));
+ $expected_values = [
'disabled_checkbox_on' => 'disabled_checkbox_on',
'disabled_checkbox_off' => '',
'checkbox_on' => 'checkbox_on',
'checkbox_off' => '',
'zero_checkbox_on' => '0',
'zero_checkbox_off' => '',
- );
+ ];
foreach ($expected_values as $widget => $expected_value) {
- $this->assertEqual($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', array(
+ $this->assertEqual($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', [
'%widget' => var_export($widget, TRUE),
'%expected' => var_export($expected_value, TRUE),
'%value' => var_export($values[$widget], TRUE),
- )));
+ ]));
}
}
@@ -376,8 +376,8 @@ class FormTest extends WebTestBase {
$this->assertNoRaw('<strong>four</strong>');
// Posting without any values should throw validation errors.
- $this->drupalPostForm(NULL, array(), 'Submit');
- $no_errors = array(
+ $this->drupalPostForm(NULL, [], 'Submit');
+ $no_errors = [
'select',
'select_required',
'select_optional',
@@ -388,35 +388,35 @@ class FormTest extends WebTestBase {
'no_default_empty_value_optional',
'multiple',
'multiple_no_default',
- );
+ ];
foreach ($no_errors as $key) {
- $this->assertNoText(t('@name field is required.', array('@name' => $form[$key]['#title'])));
+ $this->assertNoText(t('@name field is required.', ['@name' => $form[$key]['#title']]));
}
- $expected_errors = array(
+ $expected_errors = [
'no_default',
'no_default_empty_option',
'no_default_empty_value',
'no_default_empty_value_one',
'multiple_no_default_required',
- );
+ ];
foreach ($expected_errors as $key) {
- $this->assertText(t('@name field is required.', array('@name' => $form[$key]['#title'])));
+ $this->assertText(t('@name field is required.', ['@name' => $form[$key]['#title']]));
}
// Post values for required fields.
- $edit = array(
+ $edit = [
'no_default' => 'three',
'no_default_empty_option' => 'three',
'no_default_empty_value' => 'three',
'no_default_empty_value_one' => 'three',
'multiple_no_default_required[]' => 'three',
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Submit');
$values = Json::decode($this->getRawContent());
// Verify expected values.
- $expected = array(
+ $expected = [
'select' => 'one',
'empty_value' => 'one',
'empty_value_one' => 'one',
@@ -428,16 +428,16 @@ class FormTest extends WebTestBase {
'no_default_empty_value' => 'three',
'no_default_empty_value_one' => 'three',
'no_default_empty_value_optional' => 0,
- 'multiple' => array('two' => 'two'),
- 'multiple_no_default' => array(),
- 'multiple_no_default_required' => array('three' => 'three'),
- );
+ 'multiple' => ['two' => 'two'],
+ 'multiple_no_default' => [],
+ 'multiple_no_default_required' => ['three' => 'three'],
+ ];
foreach ($expected as $key => $value) {
- $this->assertIdentical($values[$key], $value, format_string('@name: @actual is equal to @expected.', array(
+ $this->assertIdentical($values[$key], $value, format_string('@name: @actual is equal to @expected.', [
'@name' => $key,
'@actual' => var_export($values[$key], TRUE),
'@expected' => var_export($value, TRUE),
- )));
+ ]));
}
}
@@ -457,15 +457,15 @@ class FormTest extends WebTestBase {
$form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestNumberForm');
// Array with all the error messages to be checked.
- $error_messages = array(
+ $error_messages = [
'no_number' => '%name must be a number.',
'too_low' => '%name must be higher than or equal to %min.',
'too_high' => '%name must be lower than or equal to %max.',
'step_mismatch' => '%name is not a valid number.',
- );
+ ];
// The expected errors.
- $expected = array(
+ $expected = [
'integer_no_number' => 'no_number',
'integer_no_step' => 0,
'integer_no_step_step_error' => 'step_mismatch',
@@ -485,20 +485,20 @@ class FormTest extends WebTestBase {
'float_step_hard_no_error' => 0,
'float_step_hard_error' => 'step_mismatch',
'float_step_any_no_error' => 0,
- );
+ ];
// First test the number element type, then range.
- foreach (array('form-test/number', 'form-test/number/range') as $path) {
+ foreach (['form-test/number', 'form-test/number/range'] as $path) {
// Post form and show errors.
- $this->drupalPostForm($path, array(), 'Submit');
+ $this->drupalPostForm($path, [], 'Submit');
foreach ($expected as $element => $error) {
// Create placeholder array.
- $placeholders = array(
+ $placeholders = [
'%name' => $form[$element]['#title'],
'%min' => isset($form[$element]['#min']) ? $form[$element]['#min'] : '0',
'%max' => isset($form[$element]['#max']) ? $form[$element]['#max'] : '0',
- );
+ ];
foreach ($error_messages as $id => $message) {
// Check if the error exists on the page, if the current message ID is
@@ -518,13 +518,13 @@ class FormTest extends WebTestBase {
* Tests default value handling of #type 'range' elements.
*/
function testRange() {
- $values = json_decode($this->drupalPostForm('form-test/range', array(), 'Submit'));
+ $values = json_decode($this->drupalPostForm('form-test/range', [], 'Submit'));
$this->assertEqual($values->with_default_value, 18);
$this->assertEqual($values->float, 10.5);
$this->assertEqual($values->integer, 6);
$this->assertEqual($values->offset, 6.9);
- $this->drupalPostForm('form-test/range/invalid', array(), 'Submit');
+ $this->drupalPostForm('form-test/range/invalid', [], 'Submit');
$this->assertFieldByXPath('//input[@type="range" and contains(@class, "error")]', NULL, 'Range element has the error class.');
}
@@ -533,7 +533,7 @@ class FormTest extends WebTestBase {
*/
function testColorValidation() {
// Keys are inputs, values are expected results.
- $values = array(
+ $values = [
'' => '#000000',
'#000' => '#000000',
'AAA' => '#aaaaaa',
@@ -541,25 +541,25 @@ class FormTest extends WebTestBase {
'#99ccBc' => '#99ccbc',
'#aabbcc' => '#aabbcc',
'123456' => '#123456',
- );
+ ];
// Tests that valid values are properly normalized.
foreach ($values as $input => $expected) {
- $edit = array(
+ $edit = [
'color' => $input,
- );
+ ];
$result = json_decode($this->drupalPostForm('form-test/color', $edit, 'Submit'));
$this->assertEqual($result->color, $expected);
}
// Tests invalid values are rejected.
- $values = array('#0008', '#1234', '#fffffg', '#abcdef22', '17', '#uaa');
+ $values = ['#0008', '#1234', '#fffffg', '#abcdef22', '17', '#uaa'];
foreach ($values as $input) {
- $edit = array(
+ $edit = [
'color' => $input,
- );
+ ];
$this->drupalPostForm('form-test/color', $edit, 'Submit');
- $this->assertRaw(t('%name must be a valid color.', array('%name' => 'Color')));
+ $this->assertRaw(t('%name must be a valid color.', ['%name' => 'Color']));
}
}
@@ -571,11 +571,11 @@ class FormTest extends WebTestBase {
function testDisabledElements() {
// Get the raw form in its original state.
$form_state = new FormState();
- $form = (new FormTestDisabledElementsForm())->buildForm(array(), $form_state);
+ $form = (new FormTestDisabledElementsForm())->buildForm([], $form_state);
// Build a submission that tries to hijack the form by submitting input for
// elements that are disabled.
- $edit = array();
+ $edit = [];
foreach (Element::children($form) as $key) {
if (isset($form[$key]['#test_hijack_value'])) {
if (is_array($form[$key]['#test_hijack_value'])) {
@@ -591,14 +591,14 @@ class FormTest extends WebTestBase {
// Submit the form with no input, as the browser does for disabled elements,
// and fetch the $form_state->getValues() that is passed to the submit handler.
- $this->drupalPostForm('form-test/disabled-elements', array(), t('Submit'));
+ $this->drupalPostForm('form-test/disabled-elements', [], t('Submit'));
$returned_values['normal'] = Json::decode($this->content);
// Do the same with input, as could happen if JavaScript un-disables an
// element. drupalPostForm() emulates a browser by not submitting input for
// disabled elements, so we need to un-disable those elements first.
$this->drupalGet('form-test/disabled-elements');
- $disabled_elements = array();
+ $disabled_elements = [];
foreach ($this->xpath('//*[@disabled]') as $element) {
$disabled_elements[] = (string) $element['name'];
unset($element['disabled']);
@@ -608,10 +608,10 @@ class FormTest extends WebTestBase {
// the disabled container.
$actual_count = count($disabled_elements);
$expected_count = 42;
- $this->assertEqual($actual_count, $expected_count, SafeMarkup::format('Found @actual elements with disabled property (expected @expected).', array(
+ $this->assertEqual($actual_count, $expected_count, SafeMarkup::format('Found @actual elements with disabled property (expected @expected).', [
'@actual' => count($disabled_elements),
'@expected' => $expected_count,
- )));
+ ]));
$this->drupalPostForm(NULL, $edit, t('Submit'));
$returned_values['hijacked'] = Json::decode($this->content);
@@ -640,7 +640,7 @@ class FormTest extends WebTestBase {
// Checkboxes values are not filtered out.
$values[$key] = array_filter($values[$key]);
}
- $this->assertIdentical($expected_value, $values[$key], format_string('Default value for %type: expected %expected, returned %returned.', array('%type' => $key, '%expected' => var_export($expected_value, TRUE), '%returned' => var_export($values[$key], TRUE))));
+ $this->assertIdentical($expected_value, $values[$key], format_string('Default value for %type: expected %expected, returned %returned.', ['%type' => $key, '%expected' => var_export($expected_value, TRUE), '%returned' => var_export($values[$key], TRUE)]));
}
// Recurse children.
@@ -656,24 +656,24 @@ class FormTest extends WebTestBase {
function testDisabledMarkup() {
$this->drupalGet('form-test/disabled-elements');
$form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestDisabledElementsForm');
- $type_map = array(
+ $type_map = [
'textarea' => 'textarea',
'select' => 'select',
'weight' => 'select',
'datetime' => 'datetime',
- );
+ ];
foreach ($form as $name => $item) {
// Skip special #types.
- if (!isset($item['#type']) || in_array($item['#type'], array('hidden', 'text_format'))) {
+ if (!isset($item['#type']) || in_array($item['#type'], ['hidden', 'text_format'])) {
continue;
}
// Setup XPath and CSS class depending on #type.
- if (in_array($item['#type'], array('button', 'submit'))) {
+ if (in_array($item['#type'], ['button', 'submit'])) {
$path = "//!type[contains(@class, :div-class) and @value=:value]";
$class = 'is-disabled';
}
- elseif (in_array($item['#type'], array('image_button'))) {
+ elseif (in_array($item['#type'], ['image_button'])) {
$path = "//!type[contains(@class, :div-class) and @value=:value]";
$class = 'is-disabled';
}
@@ -687,27 +687,27 @@ class FormTest extends WebTestBase {
if (isset($type_map[$item['#type']])) {
$type = $type_map[$item['#type']];
}
- $path = strtr($path, array('!type' => $type));
+ $path = strtr($path, ['!type' => $type]);
// Verify that the element exists.
- $element = $this->xpath($path, array(
+ $element = $this->xpath($path, [
':name' => Html::escape($name),
':div-class' => $class,
':value' => isset($item['#value']) ? $item['#value'] : '',
- ));
- $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => $item['#type'])));
+ ]);
+ $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', ['%type' => $item['#type']]));
}
// Verify special element #type text-format.
- $element = $this->xpath('//div[contains(@class, :div-class)]/descendant::textarea[@name=:name]', array(
+ $element = $this->xpath('//div[contains(@class, :div-class)]/descendant::textarea[@name=:name]', [
':name' => 'text_format[value]',
':div-class' => 'form-disabled',
- ));
- $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => 'text_format[value]')));
- $element = $this->xpath('//div[contains(@class, :div-class)]/descendant::select[@name=:name]', array(
+ ]);
+ $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', ['%type' => 'text_format[value]']));
+ $element = $this->xpath('//div[contains(@class, :div-class)]/descendant::select[@name=:name]', [
':name' => 'text_format[format]',
':div-class' => 'form-disabled',
- ));
- $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => 'text_format[format]')));
+ ]);
+ $this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', ['%type' => 'text_format[format]']));
}
/**
@@ -719,7 +719,7 @@ class FormTest extends WebTestBase {
$this->drupalGet('form-test/input-forgery');
$checkbox = $this->xpath('//input[@name="checkboxes[two]"]');
$checkbox[0]['value'] = 'FORGERY';
- $this->drupalPostForm(NULL, array('checkboxes[one]' => TRUE, 'checkboxes[two]' => TRUE), t('Submit'));
+ $this->drupalPostForm(NULL, ['checkboxes[one]' => TRUE, 'checkboxes[two]' => TRUE], t('Submit'));
$this->assertText('An illegal choice has been detected.', 'Input forgery was detected.');
}
@@ -730,19 +730,19 @@ class FormTest extends WebTestBase {
$this->drupalGet('form-test/required-attribute');
$expected = 'required';
// Test to make sure the elements have the proper required attribute.
- foreach (array('textfield', 'password') as $type) {
- $element = $this->xpath('//input[@id=:id and @required=:expected]', array(
+ foreach (['textfield', 'password'] as $type) {
+ $element = $this->xpath('//input[@id=:id and @required=:expected]', [
':id' => 'edit-' . $type,
':expected' => $expected,
- ));
- $this->assertTrue(!empty($element), format_string('The @type has the proper required attribute.', array('@type' => $type)));
+ ]);
+ $this->assertTrue(!empty($element), format_string('The @type has the proper required attribute.', ['@type' => $type]));
}
// Test to make sure textarea has the proper required attribute.
- $element = $this->xpath('//textarea[@id=:id and @required=:expected]', array(
+ $element = $this->xpath('//textarea[@id=:id and @required=:expected]', [
':id' => 'edit-textarea',
':expected' => $expected,
- ));
+ ]);
$this->assertTrue(!empty($element), 'The textarea has the proper required attribute.');
}
diff --git a/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php
index 7b3d73cb0f4..d52eab49b13 100644
--- a/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php
+++ b/core/modules/system/src/Tests/Form/LanguageSelectElementTest.php
@@ -20,47 +20,47 @@ class LanguageSelectElementTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test', 'language');
+ public static $modules = ['form_test', 'language'];
/**
* Tests that the options printed by the language select element are correct.
*/
function testLanguageSelectElementOptions() {
// Add some languages.
- ConfigurableLanguage::create(array(
+ ConfigurableLanguage::create([
'id' => 'aaa',
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
- ConfigurableLanguage::create(array(
+ ConfigurableLanguage::create([
'id' => 'bbb',
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
\Drupal::languageManager()->reset();
$this->drupalGet('form-test/language_select');
// Check that the language fields were rendered on the page.
- $ids = array(
+ $ids = [
'edit-languages-all' => LanguageInterface::STATE_ALL,
'edit-languages-configurable' => LanguageInterface::STATE_CONFIGURABLE,
'edit-languages-locked' => LanguageInterface::STATE_LOCKED,
'edit-languages-config-and-locked' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED
- );
+ ];
foreach ($ids as $id => $flags) {
- $this->assertField($id, format_string('The @id field was found on the page.', array('@id' => $id)));
- $options = array();
+ $this->assertField($id, format_string('The @id field was found on the page.', ['@id' => $id]));
+ $options = [];
/* @var $language_manager \Drupal\Core\Language\LanguageManagerInterface */
$language_manager = $this->container->get('language_manager');
foreach ($language_manager->getLanguages($flags) as $langcode => $language) {
- $options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
+ $options[$langcode] = $language->isLocked() ? t('- @name -', ['@name' => $language->getName()]) : $language->getName();
}
$this->_testLanguageSelectElementOptions($id, $options);
}
// Test that the #options were not altered by #languages.
- $this->assertField('edit-language-custom-options', format_string('The @id field was found on the page.', array('@id' => 'edit-language-custom-options')));
- $this->_testLanguageSelectElementOptions('edit-language-custom-options', array('opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'));
+ $this->assertField('edit-language-custom-options', format_string('The @id field was found on the page.', ['@id' => 'edit-language-custom-options']));
+ $this->_testLanguageSelectElementOptions('edit-language-custom-options', ['opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option']);
}
/**
@@ -71,17 +71,17 @@ class LanguageSelectElementTest extends WebTestBase {
function testHiddenLanguageSelectElement() {
// Disable the language module, so that the language select field will not
// be rendered.
- $this->container->get('module_installer')->uninstall(array('language'));
+ $this->container->get('module_installer')->uninstall(['language']);
$this->drupalGet('form-test/language_select');
// Check that the language fields were rendered on the page.
- $ids = array('edit-languages-all', 'edit-languages-configurable', 'edit-languages-locked', 'edit-languages-config-and-locked');
+ $ids = ['edit-languages-all', 'edit-languages-configurable', 'edit-languages-locked', 'edit-languages-config-and-locked'];
foreach ($ids as $id) {
- $this->assertNoField($id, format_string('The @id field was not found on the page.', array('@id' => $id)));
+ $this->assertNoField($id, format_string('The @id field was not found on the page.', ['@id' => $id]));
}
// Check that the submitted values were the default values of the language
// field elements.
- $edit = array();
+ $edit = [];
$this->drupalPostForm(NULL, $edit, t('Submit'));
$values = Json::decode($this->getRawContent());
$this->assertEqual($values['languages_all'], 'xx');
@@ -111,7 +111,7 @@ class LanguageSelectElementTest extends WebTestBase {
$this->assertEqual((string) $option, $option_title);
next($options);
}
- $this->assertEqual($count, count($options), format_string('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', array('@languages' => count($options), '@number' => $count)));
+ $this->assertEqual($count, count($options), format_string('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', ['@languages' => count($options), '@number' => $count]));
}
}
diff --git a/core/modules/system/src/Tests/Form/ProgrammaticTest.php b/core/modules/system/src/Tests/Form/ProgrammaticTest.php
index 5fbefb5e582..5f6eac07ac4 100644
--- a/core/modules/system/src/Tests/Form/ProgrammaticTest.php
+++ b/core/modules/system/src/Tests/Form/ProgrammaticTest.php
@@ -17,7 +17,7 @@ class ProgrammaticTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Test the programmatic form submission workflow.
@@ -26,30 +26,30 @@ class ProgrammaticTest extends WebTestBase {
// Backup the current batch status and reset it to avoid conflicts while
// processing the dummy form submit handler.
$current_batch = $batch =& batch_get();
- $batch = array();
+ $batch = [];
// Test that a programmatic form submission is rejected when a required
// textfield is omitted and correctly processed when it is provided.
- $this->submitForm(array(), FALSE);
- $this->submitForm(array('textfield' => 'test 1'), TRUE);
- $this->submitForm(array(), FALSE);
- $this->submitForm(array('textfield' => 'test 2'), TRUE);
+ $this->submitForm([], FALSE);
+ $this->submitForm(['textfield' => 'test 1'], TRUE);
+ $this->submitForm([], FALSE);
+ $this->submitForm(['textfield' => 'test 2'], TRUE);
// Test that a programmatic form submission can turn on and off checkboxes
// which are, by default, checked.
- $this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => 1, 2 => 2)), TRUE);
- $this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => 1, 2 => NULL)), TRUE);
- $this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => 2)), TRUE);
- $this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => NULL)), TRUE);
+ $this->submitForm(['textfield' => 'dummy value', 'checkboxes' => [1 => 1, 2 => 2]], TRUE);
+ $this->submitForm(['textfield' => 'dummy value', 'checkboxes' => [1 => 1, 2 => NULL]], TRUE);
+ $this->submitForm(['textfield' => 'dummy value', 'checkboxes' => [1 => NULL, 2 => 2]], TRUE);
+ $this->submitForm(['textfield' => 'dummy value', 'checkboxes' => [1 => NULL, 2 => NULL]], TRUE);
// Test that a programmatic form submission can correctly click a button
// that limits validation errors based on user input. Since we do not
// submit any values for "textfield" here and the textfield is required, we
// only expect form validation to pass when validation is limited to a
// different field.
- $this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'all'), FALSE);
- $this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'textfield'), FALSE);
- $this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'field_to_validate'), TRUE);
+ $this->submitForm(['op' => 'Submit with limited validation', 'field_to_validate' => 'all'], FALSE);
+ $this->submitForm(['op' => 'Submit with limited validation', 'field_to_validate' => 'textfield'], FALSE);
+ $this->submitForm(['op' => 'Submit with limited validation', 'field_to_validate' => 'field_to_validate'], TRUE);
// Restore the current batch status.
$batch = $current_batch;
@@ -73,10 +73,10 @@ class ProgrammaticTest extends WebTestBase {
// Check that the form returns an error when expected, and vice versa.
$errors = $form_state->getErrors();
$valid_form = empty($errors);
- $args = array(
+ $args = [
'%values' => print_r($values, TRUE),
'%errors' => $valid_form ? t('None') : implode(' ', $errors),
- );
+ ];
$this->assertTrue($valid_input == $valid_form, format_string('Input values: %values<br />Validation handler errors: %errors', $args));
// We check submitted values only if we have a valid input.
@@ -84,7 +84,7 @@ class ProgrammaticTest extends WebTestBase {
// Fetching the values that were set in the submission handler.
$stored_values = $form_state->get('programmatic_form_submit');
foreach ($values as $key => $value) {
- $this->assertEqual($stored_values[$key], $value, format_string('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
+ $this->assertEqual($stored_values[$key], $value, format_string('Submission handler correctly executed: %stored_key is %stored_value', ['%stored_key' => $key, '%stored_value' => print_r($value, TRUE)]));
}
}
}
diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php
index bee15fe1d7c..e759ff6c540 100644
--- a/core/modules/system/src/Tests/Form/RebuildTest.php
+++ b/core/modules/system/src/Tests/Form/RebuildTest.php
@@ -21,7 +21,7 @@ class RebuildTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'form_test');
+ public static $modules = ['node', 'form_test'];
/**
* A user for testing.
@@ -33,9 +33,9 @@ class RebuildTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
- $this->webUser = $this->drupalCreateUser(array('access content'));
+ $this->webUser = $this->drupalCreateUser(['access content']);
$this->drupalLogin($this->webUser);
}
@@ -43,11 +43,11 @@ class RebuildTest extends WebTestBase {
* Tests preservation of values.
*/
function testRebuildPreservesValues() {
- $edit = array(
+ $edit = [
'checkbox_1_default_off' => TRUE,
'checkbox_1_default_on' => FALSE,
'text_1' => 'foo',
- );
+ ];
$this->drupalPostForm('form-test/form-rebuild-preserve-values', $edit, 'Add more');
// Verify that initial elements retained their submitted values.
@@ -70,30 +70,30 @@ class RebuildTest extends WebTestBase {
function testPreserveFormActionAfterAJAX() {
// Create a multi-valued field for 'page' nodes to use for Ajax testing.
$field_name = 'field_ajax_test';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'text',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
])->save();
entity_get_form_display('node', 'page', 'default')
- ->setComponent($field_name, array('type' => 'text_textfield'))
+ ->setComponent($field_name, ['type' => 'text_textfield'])
->save();
// Log in a user who can create 'page' nodes.
- $this->webUser = $this->drupalCreateUser(array('create page content'));
+ $this->webUser = $this->drupalCreateUser(['create page content']);
$this->drupalLogin($this->webUser);
// Get the form for adding a 'page' node. Submit an "add another item" Ajax
// submission and verify it worked by ensuring the updated page has two text
// field items in the field for which we just added an item.
$this->drupalGet('node/add/page');
- $this->drupalPostAjaxForm(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), NULL, array(), array(), 'node-page-form');
+ $this->drupalPostAjaxForm(NULL, [], ['field_ajax_test_add_more' => t('Add another item')], NULL, [], [], 'node-page-form');
$this->assert(count($this->xpath('//div[contains(@class, "field--name-field-ajax-test")]//input[@type="text"]')) == 2, 'AJAX submission succeeded.');
// Submit the form with the non-Ajax "Save" button, leaving the title field
@@ -101,7 +101,7 @@ class RebuildTest extends WebTestBase {
// occurred, because this test is for testing what happens when a form is
// re-rendered without being re-built, which is what happens when there's
// a validation error.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText('Title field is required.', 'Non-AJAX submission correctly triggered a validation error.');
// Ensure that the form contains two items in the multi-valued field, so we
diff --git a/core/modules/system/src/Tests/Form/ResponseTest.php b/core/modules/system/src/Tests/Form/ResponseTest.php
index 658b6726718..e3064a5511a 100644
--- a/core/modules/system/src/Tests/Form/ResponseTest.php
+++ b/core/modules/system/src/Tests/Form/ResponseTest.php
@@ -17,7 +17,7 @@ class ResponseTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Tests that enforced responses propagate through subscribers and middleware.
diff --git a/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php b/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php
index eb53244a900..39fed3bea3a 100644
--- a/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php
+++ b/core/modules/system/src/Tests/Form/StateValuesCleanAdvancedTest.php
@@ -18,7 +18,7 @@ class StateValuesCleanAdvancedTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('file', 'form_test');
+ public static $modules = ['file', 'form_test'];
/**
* An image file path for uploading.
@@ -38,7 +38,7 @@ class StateValuesCleanAdvancedTest extends WebTestBase {
$this->assertTrue(is_file($this->image->uri), "The image file we're going to upload exists.");
// "Browse" for the desired file.
- $edit = array('files[image]' => drupal_realpath($this->image->uri));
+ $edit = ['files[image]' => drupal_realpath($this->image->uri)];
// Post the form.
$this->drupalPostForm('form_test/form-state-values-clean-advanced', $edit, t('Submit'));
diff --git a/core/modules/system/src/Tests/Form/StateValuesCleanTest.php b/core/modules/system/src/Tests/Form/StateValuesCleanTest.php
index 7761bd8ad06..4e1da614325 100644
--- a/core/modules/system/src/Tests/Form/StateValuesCleanTest.php
+++ b/core/modules/system/src/Tests/Form/StateValuesCleanTest.php
@@ -19,31 +19,31 @@ class StateValuesCleanTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Tests \Drupal\Core\Form\FormState::cleanValues().
*/
function testFormStateValuesClean() {
- $values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', array(), t('Submit')));
+ $values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', [], t('Submit')));
// Setup the expected result.
- $result = array(
+ $result = [
'beer' => 1000,
- 'baz' => array('beer' => 2000),
- );
+ 'baz' => ['beer' => 2000],
+ ];
// Verify that all internal Form API elements were removed.
- $this->assertFalse(isset($values['form_id']), format_string('%element was removed.', array('%element' => 'form_id')));
- $this->assertFalse(isset($values['form_token']), format_string('%element was removed.', array('%element' => 'form_token')));
- $this->assertFalse(isset($values['form_build_id']), format_string('%element was removed.', array('%element' => 'form_build_id')));
- $this->assertFalse(isset($values['op']), format_string('%element was removed.', array('%element' => 'op')));
+ $this->assertFalse(isset($values['form_id']), format_string('%element was removed.', ['%element' => 'form_id']));
+ $this->assertFalse(isset($values['form_token']), format_string('%element was removed.', ['%element' => 'form_token']));
+ $this->assertFalse(isset($values['form_build_id']), format_string('%element was removed.', ['%element' => 'form_build_id']));
+ $this->assertFalse(isset($values['op']), format_string('%element was removed.', ['%element' => 'op']));
// Verify that all buttons were removed.
- $this->assertFalse(isset($values['foo']), format_string('%element was removed.', array('%element' => 'foo')));
- $this->assertFalse(isset($values['bar']), format_string('%element was removed.', array('%element' => 'bar')));
- $this->assertFalse(isset($values['baz']['foo']), format_string('%element was removed.', array('%element' => 'foo')));
- $this->assertFalse(isset($values['baz']['baz']), format_string('%element was removed.', array('%element' => 'baz')));
+ $this->assertFalse(isset($values['foo']), format_string('%element was removed.', ['%element' => 'foo']));
+ $this->assertFalse(isset($values['bar']), format_string('%element was removed.', ['%element' => 'bar']));
+ $this->assertFalse(isset($values['baz']['foo']), format_string('%element was removed.', ['%element' => 'foo']));
+ $this->assertFalse(isset($values['baz']['baz']), format_string('%element was removed.', ['%element' => 'baz']));
// Verify values manually added for cleaning were removed.
$this->assertFalse(isset($values['wine']), SafeMarkup::format('%element was removed.', ['%element' => 'wine']));
diff --git a/core/modules/system/src/Tests/Form/StorageTest.php b/core/modules/system/src/Tests/Form/StorageTest.php
index d29f36b6141..4d6f3a73d59 100644
--- a/core/modules/system/src/Tests/Form/StorageTest.php
+++ b/core/modules/system/src/Tests/Form/StorageTest.php
@@ -23,7 +23,7 @@ class StorageTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test', 'dblog');
+ public static $modules = ['form_test', 'dblog'];
protected function setUp() {
parent::setUp();
@@ -38,7 +38,7 @@ class StorageTest extends WebTestBase {
$this->drupalGet('form_test/form-storage');
$this->assertText('Form constructions: 1');
- $edit = array('title' => 'new', 'value' => 'value_is_set');
+ $edit = ['title' => 'new', 'value' => 'value_is_set'];
// Use form rebuilding triggered by a submit button.
$this->drupalPostForm(NULL, $edit, 'Continue submit');
@@ -47,7 +47,7 @@ class StorageTest extends WebTestBase {
// Reset the form to the values of the storage, using a form rebuild
// triggered by button of type button.
- $this->drupalPostForm(NULL, array('title' => 'changed'), 'Reset');
+ $this->drupalPostForm(NULL, ['title' => 'changed'], 'Reset');
$this->assertFieldByName('title', 'new', 'Values have been reset.');
// After rebuilding, the form has been cached.
$this->assertText('Form constructions: 4');
@@ -61,10 +61,10 @@ class StorageTest extends WebTestBase {
* Tests using the form after calling $form_state->setCached().
*/
function testFormCached() {
- $this->drupalGet('form_test/form-storage', array('query' => array('cache' => 1)));
+ $this->drupalGet('form_test/form-storage', ['query' => ['cache' => 1]]);
$this->assertText('Form constructions: 1');
- $edit = array('title' => 'new', 'value' => 'value_is_set');
+ $edit = ['title' => 'new', 'value' => 'value_is_set'];
// Use form rebuilding triggered by a submit button.
$this->drupalPostForm(NULL, $edit, 'Continue submit');
@@ -75,7 +75,7 @@ class StorageTest extends WebTestBase {
// Reset the form to the values of the storage, using a form rebuild
// triggered by button of type button.
- $this->drupalPostForm(NULL, array('title' => 'changed'), 'Reset');
+ $this->drupalPostForm(NULL, ['title' => 'changed'], 'Reset');
$this->assertFieldByName('title', 'new', 'Values have been reset.');
$this->assertText('Form constructions: 4');
@@ -88,7 +88,7 @@ class StorageTest extends WebTestBase {
* Tests validation when form storage is used.
*/
function testValidation() {
- $this->drupalPostForm('form_test/form-storage', array('title' => '', 'value' => 'value_is_set'), 'Continue submit');
+ $this->drupalPostForm('form_test/form-storage', ['title' => '', 'value' => 'value_is_set'], 'Continue submit');
$this->assertPattern('/value_is_set/', 'The input values have been kept.');
}
@@ -104,26 +104,26 @@ class StorageTest extends WebTestBase {
*/
function testCachedFormStorageValidation() {
// Request the form with 'cache' query parameter to enable form caching.
- $this->drupalGet('form_test/form-storage', array('query' => array('cache' => 1)));
+ $this->drupalGet('form_test/form-storage', ['query' => ['cache' => 1]]);
// Skip step 1 of the multi-step form, since the first step copies over
// 'title' into form storage, but we want to verify that changes in the form
// storage are updated in the cache during form validation.
- $edit = array('title' => 'foo');
+ $edit = ['title' => 'foo'];
$this->drupalPostForm(NULL, $edit, 'Continue submit');
// In step 2, trigger a validation error for the required 'title' field, and
// post the special 'change_title' value for the 'value' field, which
// conditionally invokes the #element_validate handler to update the form
// storage.
- $edit = array('title' => '', 'value' => 'change_title');
+ $edit = ['title' => '', 'value' => 'change_title'];
$this->drupalPostForm(NULL, $edit, 'Save');
// At this point, the form storage should contain updated values, but we do
// not see them, because the form has not been rebuilt yet due to the
// validation error. Post again and verify that the rebuilt form contains
// the values of the updated form storage.
- $this->drupalPostForm(NULL, array('title' => 'foo', 'value' => 'bar'), 'Save');
+ $this->drupalPostForm(NULL, ['title' => 'foo', 'value' => 'bar'], 'Save');
$this->assertText("The thing has been changed.", 'The altered form storage value was updated in cache and taken over.');
}
diff --git a/core/modules/system/src/Tests/Form/SystemConfigFormTest.php b/core/modules/system/src/Tests/Form/SystemConfigFormTest.php
index 69a7f7e66b1..88687d90db3 100644
--- a/core/modules/system/src/Tests/Form/SystemConfigFormTest.php
+++ b/core/modules/system/src/Tests/Form/SystemConfigFormTest.php
@@ -16,16 +16,16 @@ class SystemConfigFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Tests the SystemConfigFormTestBase class.
*/
function testSystemConfigForm() {
$this->drupalGet('form-test/system-config-form');
- $element = $this->xpath('//div[@id = :id]/input[contains(@class, :class)]', array(':id' => 'edit-actions', ':class' => 'button--primary'));
+ $element = $this->xpath('//div[@id = :id]/input[contains(@class, :class)]', [':id' => 'edit-actions', ':class' => 'button--primary']);
$this->assertTrue($element, 'The primary action submit button was found.');
- $this->drupalPostForm(NULL, array(), t('Save configuration'));
+ $this->drupalPostForm(NULL, [], t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
}
diff --git a/core/modules/system/src/Tests/Form/TriggeringElementTest.php b/core/modules/system/src/Tests/Form/TriggeringElementTest.php
index 5d8a18082c7..6bd8d2e8b59 100644
--- a/core/modules/system/src/Tests/Form/TriggeringElementTest.php
+++ b/core/modules/system/src/Tests/Form/TriggeringElementTest.php
@@ -16,7 +16,7 @@ class TriggeringElementTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Test the determination of the triggering element when no button
@@ -25,27 +25,27 @@ class TriggeringElementTest extends WebTestBase {
*/
function testNoButtonInfoInPost() {
$path = 'form-test/clicked-button';
- $edit = array();
+ $edit = [];
$form_html_id = 'form-test-clicked-button';
// Ensure submitting a form with no buttons results in no triggering element
// and the form submit handler not running.
- $this->drupalPostForm($path, $edit, NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm($path, $edit, NULL, [], [], $form_html_id);
$this->assertText('There is no clicked button.', '$form_state->getTriggeringElement() set to NULL.');
$this->assertNoText('Submit handler for form_test_clicked_button executed.', 'Form submit handler did not execute.');
// Ensure submitting a form with one or more submit buttons results in the
// triggering element being set to the first one the user has access to. An
// argument with 'r' in it indicates a restricted (#access=FALSE) button.
- $this->drupalPostForm($path . '/s', $edit, NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm($path . '/s', $edit, NULL, [], [], $form_html_id);
$this->assertText('The clicked button is button1.', '$form_state->getTriggeringElement() set to only button.');
$this->assertText('Submit handler for form_test_clicked_button executed.', 'Form submit handler executed.');
- $this->drupalPostForm($path . '/s/s', $edit, NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm($path . '/s/s', $edit, NULL, [], [], $form_html_id);
$this->assertText('The clicked button is button1.', '$form_state->getTriggeringElement() set to first button.');
$this->assertText('Submit handler for form_test_clicked_button executed.', 'Form submit handler executed.');
- $this->drupalPostForm($path . '/rs/s', $edit, NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm($path . '/rs/s', $edit, NULL, [], [], $form_html_id);
$this->assertText('The clicked button is button2.', '$form_state->getTriggeringElement() set to first available button.');
$this->assertText('Submit handler for form_test_clicked_button executed.', 'Form submit handler executed.');
@@ -53,15 +53,15 @@ class TriggeringElementTest extends WebTestBase {
// triggering element being set to the first button, regardless of type. For
// the FAPI 'button' type, this should result in the submit handler not
// executing. The types are 's'(ubmit), 'b'(utton), and 'i'(mage_button).
- $this->drupalPostForm($path . '/s/b/i', $edit, NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm($path . '/s/b/i', $edit, NULL, [], [], $form_html_id);
$this->assertText('The clicked button is button1.', '$form_state->getTriggeringElement() set to first button.');
$this->assertText('Submit handler for form_test_clicked_button executed.', 'Form submit handler executed.');
- $this->drupalPostForm($path . '/b/s/i', $edit, NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm($path . '/b/s/i', $edit, NULL, [], [], $form_html_id);
$this->assertText('The clicked button is button1.', '$form_state->getTriggeringElement() set to first button.');
$this->assertNoText('Submit handler for form_test_clicked_button executed.', 'Form submit handler did not execute.');
- $this->drupalPostForm($path . '/i/s/b', $edit, NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm($path . '/i/s/b', $edit, NULL, [], [], $form_html_id);
$this->assertText('The clicked button is button1.', '$form_state->getTriggeringElement() set to first button.');
$this->assertText('Submit handler for form_test_clicked_button executed.', 'Form submit handler executed.');
}
@@ -84,7 +84,7 @@ class TriggeringElementTest extends WebTestBase {
// data we want into \Drupal::request()->request.
$elements = $this->xpath('//form[@id="' . $form_html_id . '"]//input[@name="text"]');
$elements[0]['name'] = 'button1';
- $this->drupalPostForm(NULL, array('button1' => 'button1'), NULL, array(), array(), $form_html_id);
+ $this->drupalPostForm(NULL, ['button1' => 'button1'], NULL, [], [], $form_html_id);
// Ensure that the triggering element was not set to the restricted button.
// Do this with both a negative and positive assertion, because negative
diff --git a/core/modules/system/src/Tests/Form/UrlTest.php b/core/modules/system/src/Tests/Form/UrlTest.php
index 4bf6f608f37..69452cb397d 100644
--- a/core/modules/system/src/Tests/Form/UrlTest.php
+++ b/core/modules/system/src/Tests/Form/UrlTest.php
@@ -17,7 +17,7 @@ class UrlTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
protected $profile = 'testing';
@@ -25,21 +25,21 @@ class UrlTest extends WebTestBase {
* Tests that #type 'url' fields are properly validated and trimmed.
*/
function testFormUrl() {
- $edit = array();
+ $edit = [];
$edit['url'] = 'http://';
$edit['url_required'] = ' ';
$this->drupalPostForm('form-test/url', $edit, 'Submit');
- $this->assertRaw(t('The URL %url is not valid.', array('%url' => 'http://')));
- $this->assertRaw(t('@name field is required.', array('@name' => 'Required URL')));
+ $this->assertRaw(t('The URL %url is not valid.', ['%url' => 'http://']));
+ $this->assertRaw(t('@name field is required.', ['@name' => 'Required URL']));
- $edit = array();
+ $edit = [];
$edit['url'] = "\n";
$edit['url_required'] = 'http://example.com/ ';
$values = Json::decode($this->drupalPostForm('form-test/url', $edit, 'Submit'));
$this->assertIdentical($values['url'], '');
$this->assertEqual($values['url_required'], 'http://example.com/');
- $edit = array();
+ $edit = [];
$edit['url'] = 'http://foo.bar.example.com/';
$edit['url_required'] = 'https://www.drupal.org/node/1174630?page=0&foo=bar#new';
$values = Json::decode($this->drupalPostForm('form-test/url', $edit, 'Submit'));
diff --git a/core/modules/system/src/Tests/Form/ValidationTest.php b/core/modules/system/src/Tests/Form/ValidationTest.php
index 35b340b5e42..46781edd118 100644
--- a/core/modules/system/src/Tests/Form/ValidationTest.php
+++ b/core/modules/system/src/Tests/Form/ValidationTest.php
@@ -17,7 +17,7 @@ class ValidationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Tests #element_validate and #validate.
@@ -26,43 +26,43 @@ class ValidationTest extends WebTestBase {
$this->drupalGet('form-test/validate');
// Verify that #element_validate handlers can alter the form and submitted
// form values.
- $edit = array(
+ $edit = [
'name' => 'element_validate',
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertFieldByName('name', '#value changed by #element_validate', 'Form element #value was altered.');
$this->assertText('Name value: value changed by setValueForElement() in #element_validate', 'Form element value in $form_state was altered.');
// Verify that #validate handlers can alter the form and submitted
// form values.
- $edit = array(
+ $edit = [
'name' => 'validate',
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertFieldByName('name', '#value changed by #validate', 'Form element #value was altered.');
$this->assertText('Name value: value changed by setValueForElement() in #validate', 'Form element value in $form_state was altered.');
// Verify that #element_validate handlers can make form elements
// inaccessible, but values persist.
- $edit = array(
+ $edit = [
'name' => 'element_validate_access',
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertNoFieldByName('name', 'Form element was hidden.');
$this->assertText('Name value: element_validate_access', 'Value for inaccessible form element exists.');
// Verify that value for inaccessible form element persists.
- $this->drupalPostForm(NULL, array(), 'Save');
+ $this->drupalPostForm(NULL, [], 'Save');
$this->assertNoFieldByName('name', 'Form element was hidden.');
$this->assertText('Name value: element_validate_access', 'Value for inaccessible form element exists.');
// Verify that #validate handlers don't run if the CSRF token is invalid.
$this->drupalLogin($this->drupalCreateUser());
$this->drupalGet('form-test/validate');
- $edit = array(
+ $edit = [
'name' => 'validate',
'form_token' => 'invalid token'
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertNoFieldByName('name', '#value changed by #validate', 'Form element #value was not altered.');
$this->assertNoText('Name value: value changed by setValueForElement() in #validate', 'Form element value in $form_state was not altered.');
@@ -81,11 +81,11 @@ class ValidationTest extends WebTestBase {
* Tests partial form validation through #limit_validation_errors.
*/
function testValidateLimitErrors() {
- $edit = array(
+ $edit = [
'test' => 'invalid',
'test_numeric_index[0]' => 'invalid',
'test_substring[foo]' => 'invalid',
- );
+ ];
$path = 'form-test/limit-validation-errors';
// Render the form, and verify that the buttons with limited server-side
@@ -93,18 +93,18 @@ class ValidationTest extends WebTestBase {
// client-side validation by the browser).
$this->drupalGet($path);
$expected = 'formnovalidate';
- foreach (array('partial', 'partial-numeric-index', 'substring') as $type) {
- $element = $this->xpath('//input[@id=:id and @formnovalidate=:expected]', array(
+ foreach (['partial', 'partial-numeric-index', 'substring'] as $type) {
+ $element = $this->xpath('//input[@id=:id and @formnovalidate=:expected]', [
':id' => 'edit-' . $type,
':expected' => $expected,
- ));
- $this->assertTrue(!empty($element), format_string('The @type button has the proper formnovalidate attribute.', array('@type' => $type)));
+ ]);
+ $this->assertTrue(!empty($element), format_string('The @type button has the proper formnovalidate attribute.', ['@type' => $type]));
}
// The button with full server-side validation should not have the
// 'formnovalidate' attribute.
- $element = $this->xpath('//input[@id=:id and not(@formnovalidate)]', array(
+ $element = $this->xpath('//input[@id=:id and not(@formnovalidate)]', [
':id' => 'edit-full',
- ));
+ ]);
$this->assertTrue(!empty($element), 'The button with full server-side validation does not have the formnovalidate attribute.');
// Submit the form by pressing the 'Partial validate' button (uses
@@ -112,29 +112,29 @@ class ValidationTest extends WebTestBase {
// validated, but the #element_validate handler for the 'test' field
// is triggered.
$this->drupalPostForm($path, $edit, t('Partial validate'));
- $this->assertNoText(t('@name field is required.', array('@name' => 'Title')));
+ $this->assertNoText(t('@name field is required.', ['@name' => 'Title']));
$this->assertText('Test element is invalid');
// Edge case of #limit_validation_errors containing numeric indexes: same
// thing with the 'Partial validate (numeric index)' button and the
// 'test_numeric_index' field.
$this->drupalPostForm($path, $edit, t('Partial validate (numeric index)'));
- $this->assertNoText(t('@name field is required.', array('@name' => 'Title')));
+ $this->assertNoText(t('@name field is required.', ['@name' => 'Title']));
$this->assertText('Test (numeric index) element is invalid');
// Ensure something like 'foobar' isn't considered "inside" 'foo'.
$this->drupalPostForm($path, $edit, t('Partial validate (substring)'));
- $this->assertNoText(t('@name field is required.', array('@name' => 'Title')));
+ $this->assertNoText(t('@name field is required.', ['@name' => 'Title']));
$this->assertText('Test (substring) foo element is invalid');
// Ensure not validated values are not available to submit handlers.
- $this->drupalPostForm($path, array('title' => '', 'test' => 'valid'), t('Partial validate'));
+ $this->drupalPostForm($path, ['title' => '', 'test' => 'valid'], t('Partial validate'));
$this->assertText('Only validated values appear in the form values.');
// Now test full form validation and ensure that the #element_validate
// handler is still triggered.
$this->drupalPostForm($path, $edit, t('Full validate'));
- $this->assertText(t('@name field is required.', array('@name' => 'Title')));
+ $this->assertText(t('@name field is required.', ['@name' => 'Title']));
$this->assertText('Test element is invalid');
}
@@ -142,45 +142,45 @@ class ValidationTest extends WebTestBase {
* Tests #pattern validation.
*/
function testPatternValidation() {
- $textfield_error = t('%name field is not in the right format.', array('%name' => 'One digit followed by lowercase letters'));
- $tel_error = t('%name field is not in the right format.', array('%name' => 'Everything except numbers'));
- $password_error = t('%name field is not in the right format.', array('%name' => 'Password'));
+ $textfield_error = t('%name field is not in the right format.', ['%name' => 'One digit followed by lowercase letters']);
+ $tel_error = t('%name field is not in the right format.', ['%name' => 'Everything except numbers']);
+ $password_error = t('%name field is not in the right format.', ['%name' => 'Password']);
// Invalid textfield, valid tel.
- $edit = array(
+ $edit = [
'textfield' => 'invalid',
'tel' => 'valid',
- );
+ ];
$this->drupalPostForm('form-test/pattern', $edit, 'Submit');
$this->assertRaw($textfield_error);
$this->assertNoRaw($tel_error);
$this->assertNoRaw($password_error);
// Valid textfield, invalid tel, valid password.
- $edit = array(
+ $edit = [
'textfield' => '7seven',
'tel' => '818937',
'password' => '0100110',
- );
+ ];
$this->drupalPostForm('form-test/pattern', $edit, 'Submit');
$this->assertNoRaw($textfield_error);
$this->assertRaw($tel_error);
$this->assertNoRaw($password_error);
// Non required fields are not validated if empty.
- $edit = array(
+ $edit = [
'textfield' => '',
'tel' => '',
- );
+ ];
$this->drupalPostForm('form-test/pattern', $edit, 'Submit');
$this->assertNoRaw($textfield_error);
$this->assertNoRaw($tel_error);
$this->assertNoRaw($password_error);
// Invalid password.
- $edit = array(
+ $edit = [
'password' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('form-test/pattern', $edit, 'Submit');
$this->assertNoRaw($textfield_error);
$this->assertNoRaw($tel_error);
@@ -188,13 +188,13 @@ class ValidationTest extends WebTestBase {
// The pattern attribute overrides #pattern and is not validated on the
// server side.
- $edit = array(
+ $edit = [
'textfield' => '',
'tel' => '',
'url' => 'http://www.example.com/',
- );
+ ];
$this->drupalPostForm('form-test/pattern', $edit, 'Submit');
- $this->assertNoRaw(t('%name field is not in the right format.', array('%name' => 'Client side validation')));
+ $this->assertNoRaw(t('%name field is not in the right format.', ['%name' => 'Client side validation']));
}
/**
@@ -206,36 +206,36 @@ class ValidationTest extends WebTestBase {
$form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestValidateRequiredForm');
// Verify that a custom #required error can be set.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('form-test/validate-required', $edit, 'Submit');
foreach (Element::children($form) as $key) {
if (isset($form[$key]['#required_error'])) {
- $this->assertNoText(t('@name field is required.', array('@name' => $form[$key]['#title'])));
+ $this->assertNoText(t('@name field is required.', ['@name' => $form[$key]['#title']]));
$this->assertText($form[$key]['#required_error']);
}
elseif (isset($form[$key]['#form_test_required_error'])) {
- $this->assertNoText(t('@name field is required.', array('@name' => $form[$key]['#title'])));
+ $this->assertNoText(t('@name field is required.', ['@name' => $form[$key]['#title']]));
$this->assertText($form[$key]['#form_test_required_error']);
}
}
$this->assertNoText(t('An illegal choice has been detected. Please contact the site administrator.'));
// Verify that no custom validation error appears with valid values.
- $edit = array(
+ $edit = [
'textfield' => $this->randomString(),
'checkboxes[foo]' => TRUE,
'select' => 'foo',
- );
+ ];
$this->drupalPostForm('form-test/validate-required', $edit, 'Submit');
foreach (Element::children($form) as $key) {
if (isset($form[$key]['#required_error'])) {
- $this->assertNoText(t('@name field is required.', array('@name' => $form[$key]['#title'])));
+ $this->assertNoText(t('@name field is required.', ['@name' => $form[$key]['#title']]));
$this->assertNoText($form[$key]['#required_error']);
}
elseif (isset($form[$key]['#form_test_required_error'])) {
- $this->assertNoText(t('@name field is required.', array('@name' => $form[$key]['#title'])));
+ $this->assertNoText(t('@name field is required.', ['@name' => $form[$key]['#title']]));
$this->assertNoText($form[$key]['#form_test_required_error']);
}
}
diff --git a/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php b/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php
index 66989de0b57..64b306d5622 100644
--- a/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php
+++ b/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php
@@ -23,16 +23,16 @@ class ToolkitSetupFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('system', 'image_test');
+ public static $modules = ['system', 'image_test'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer site configuration',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
}
@@ -47,26 +47,26 @@ class ToolkitSetupFormTest extends WebTestBase {
$this->assertFieldByName('image_toolkit', 'gd', 'The default image toolkit is GD.');
// Test changing the jpeg image quality.
- $edit = array('gd[image_jpeg_quality]' => '70');
+ $edit = ['gd[image_jpeg_quality]' => '70'];
$this->drupalPostForm(NULL, $edit, 'Save configuration');
$this->assertEqual($this->config('system.image.gd')->get('jpeg_quality'), '70');
// Test changing the toolkit.
- $edit = array('image_toolkit' => 'test');
+ $edit = ['image_toolkit' => 'test'];
$this->drupalPostForm(NULL, $edit, 'Save configuration');
$this->assertEqual($this->config('system.image')->get('toolkit'), 'test');
$this->assertFieldByName('test[test_parameter]', '10');
// Test changing the test toolkit parameter.
- $edit = array('test[test_parameter]' => '0');
+ $edit = ['test[test_parameter]' => '0'];
$this->drupalPostForm(NULL, $edit, 'Save configuration');
$this->assertText(t('Test parameter should be different from 0.'), 'Validation error displayed.');
- $edit = array('test[test_parameter]' => '20');
+ $edit = ['test[test_parameter]' => '20'];
$this->drupalPostForm(NULL, $edit, 'Save configuration');
$this->assertEqual($this->config('system.image.test_toolkit')->get('test_parameter'), '20');
// Test access without the permission 'administer site configuration'.
- $this->drupalLogin($this->drupalCreateUser(array('access administration pages')));
+ $this->drupalLogin($this->drupalCreateUser(['access administration pages']));
$this->drupalGet('admin/config/media/image-toolkit');
$this->assertResponse(403);
}
diff --git a/core/modules/system/src/Tests/Image/ToolkitTest.php b/core/modules/system/src/Tests/Image/ToolkitTest.php
index 88483238613..be8e3e3add4 100644
--- a/core/modules/system/src/Tests/Image/ToolkitTest.php
+++ b/core/modules/system/src/Tests/Image/ToolkitTest.php
@@ -18,7 +18,7 @@ class ToolkitTest extends ToolkitTestBase {
$this->assertTrue(isset($toolkits['test']), 'The working toolkit was returned.');
$this->assertTrue(isset($toolkits['test:derived_toolkit']), 'The derived toolkit was returned.');
$this->assertFalse(isset($toolkits['broken']), 'The toolkit marked unavailable was not returned');
- $this->assertToolkitOperationsCalled(array());
+ $this->assertToolkitOperationsCalled([]);
}
/**
@@ -28,7 +28,7 @@ class ToolkitTest extends ToolkitTestBase {
$image = $this->getImage();
$this->assertTrue(is_object($image), 'Returned an object.');
$this->assertEqual($image->getToolkitId(), 'test', 'Image had toolkit set.');
- $this->assertToolkitOperationsCalled(array('parseFile'));
+ $this->assertToolkitOperationsCalled(['parseFile']);
}
/**
@@ -36,18 +36,18 @@ class ToolkitTest extends ToolkitTestBase {
*/
function testSave() {
$this->assertFalse($this->image->save(), 'Function returned the expected value.');
- $this->assertToolkitOperationsCalled(array('save'));
+ $this->assertToolkitOperationsCalled(['save']);
}
/**
* Test the image_apply() function.
*/
function testApply() {
- $data = array('p1' => 1, 'p2' => TRUE, 'p3' => 'text');
+ $data = ['p1' => 1, 'p2' => TRUE, 'p3' => 'text'];
$this->assertTrue($this->image->apply('my_operation', $data), 'Function returned the expected value.');
// Check that apply was called and with the correct parameters.
- $this->assertToolkitOperationsCalled(array('apply'));
+ $this->assertToolkitOperationsCalled(['apply']);
$calls = $this->imageTestGetAllCalls();
$this->assertEqual($calls['apply'][0][0], 'my_operation', "'my_operation' was passed correctly as operation");
$this->assertEqual($calls['apply'][0][1]['p1'], 1, 'integer parameter p1 was passed correctly');
@@ -62,10 +62,10 @@ class ToolkitTest extends ToolkitTestBase {
$this->assertTrue($this->image->apply('my_operation'), 'Function returned the expected value.');
// Check that apply was called and with the correct parameters.
- $this->assertToolkitOperationsCalled(array('apply'));
+ $this->assertToolkitOperationsCalled(['apply']);
$calls = $this->imageTestGetAllCalls();
$this->assertEqual($calls['apply'][0][0], 'my_operation', "'my_operation' was passed correctly as operation");
- $this->assertEqual($calls['apply'][0][1], array(), 'passing no parameters was handled correctly');
+ $this->assertEqual($calls['apply'][0][1], [], 'passing no parameters was handled correctly');
}
/**
diff --git a/core/modules/system/src/Tests/Image/ToolkitTestBase.php b/core/modules/system/src/Tests/Image/ToolkitTestBase.php
index 53ede0dc7c8..af0b253592f 100644
--- a/core/modules/system/src/Tests/Image/ToolkitTestBase.php
+++ b/core/modules/system/src/Tests/Image/ToolkitTestBase.php
@@ -15,7 +15,7 @@ abstract class ToolkitTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('image_test');
+ public static $modules = ['image_test'];
/**
* The URI for the file.
@@ -78,7 +78,7 @@ abstract class ToolkitTestBase extends WebTestBase {
function assertToolkitOperationsCalled(array $expected) {
// If one of the image operations is expected, apply should be expected as
// well.
- $operations = array(
+ $operations = [
'resize',
'rotate',
'crop',
@@ -88,7 +88,7 @@ abstract class ToolkitTestBase extends WebTestBase {
'scale_and_crop',
'my_operation',
'convert',
- );
+ ];
if (count(array_intersect($expected, $operations)) > 0 && !in_array('apply', $expected)) {
$expected[] = 'apply';
}
@@ -99,10 +99,10 @@ abstract class ToolkitTestBase extends WebTestBase {
// Determine if there were any expected that were not called.
$uncalled = array_diff($expected, $actual);
if (count($uncalled)) {
- $this->assertTrue(FALSE, SafeMarkup::format('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled))));
+ $this->assertTrue(FALSE, SafeMarkup::format('Expected operations %expected to be called but %uncalled was not called.', ['%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)]));
}
else {
- $this->assertTrue(TRUE, SafeMarkup::format('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected))));
+ $this->assertTrue(TRUE, SafeMarkup::format('All the expected operations were called: %expected', ['%expected' => implode(', ', $expected)]));
}
// Determine if there were any unexpected calls.
@@ -110,7 +110,7 @@ abstract class ToolkitTestBase extends WebTestBase {
// count it as an error.
$unexpected = array_diff($actual, $expected);
if (count($unexpected) && (!in_array('apply', $expected) || count(array_intersect($unexpected, $operations)) !== count($unexpected))) {
- $this->assertTrue(FALSE, SafeMarkup::format('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected))));
+ $this->assertTrue(FALSE, SafeMarkup::format('Unexpected operations were called: %unexpected.', ['%unexpected' => implode(', ', $unexpected)]));
}
else {
$this->assertTrue(TRUE, 'No unexpected operations were called.');
@@ -122,20 +122,20 @@ abstract class ToolkitTestBase extends WebTestBase {
*/
function imageTestReset() {
// Keep track of calls to these operations
- $results = array(
- 'parseFile' => array(),
- 'save' => array(),
- 'settings' => array(),
- 'apply' => array(),
- 'resize' => array(),
- 'rotate' => array(),
- 'crop' => array(),
- 'desaturate' => array(),
- 'create_new' => array(),
- 'scale' => array(),
- 'scale_and_crop' => array(),
- 'convert' => array(),
- );
+ $results = [
+ 'parseFile' => [],
+ 'save' => [],
+ 'settings' => [],
+ 'apply' => [],
+ 'resize' => [],
+ 'rotate' => [],
+ 'crop' => [],
+ 'desaturate' => [],
+ 'create_new' => [],
+ 'scale' => [],
+ 'scale_and_crop' => [],
+ 'convert' => [],
+ ];
\Drupal::state()->set('image_test.results', $results);
}
@@ -148,7 +148,7 @@ abstract class ToolkitTestBase extends WebTestBase {
* parameters passed to each call.
*/
function imageTestGetAllCalls() {
- return \Drupal::state()->get('image_test.results') ?: array();
+ return \Drupal::state()->get('image_test.results') ?: [];
}
}
diff --git a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
index 569fe36212c..e52b0469bbf 100644
--- a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
@@ -21,17 +21,17 @@ class DistributionProfileTest extends InstallerTestBase {
protected $info;
protected function setUp() {
- $this->info = array(
+ $this->info = [
'type' => 'profile',
'core' => \Drupal::CORE_COMPATIBILITY,
'name' => 'Distribution profile',
- 'distribution' => array(
+ 'distribution' => [
'name' => 'My Distribution',
- 'install' => array(
+ 'install' => [
'theme' => 'bartik',
- ),
- ),
- );
+ ],
+ ],
+ ];
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/mydistro';
mkdir($path, 0777, TRUE);
diff --git a/core/modules/system/src/Tests/Installer/DistributionProfileTranslationQueryTest.php b/core/modules/system/src/Tests/Installer/DistributionProfileTranslationQueryTest.php
index b8658fbb8ca..1b6868351d2 100644
--- a/core/modules/system/src/Tests/Installer/DistributionProfileTranslationQueryTest.php
+++ b/core/modules/system/src/Tests/Installer/DistributionProfileTranslationQueryTest.php
@@ -30,18 +30,18 @@ class DistributionProfileTranslationQueryTest extends InstallerTestBase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->info = array(
+ $this->info = [
'type' => 'profile',
'core' => \Drupal::CORE_COMPATIBILITY,
'name' => 'Distribution profile',
- 'distribution' => array(
+ 'distribution' => [
'name' => 'My Distribution',
'langcode' => $this->langcode,
- 'install' => array(
+ 'install' => [
'theme' => 'bartik',
- ),
- ),
- );
+ ],
+ ],
+ ];
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/mydistro';
mkdir($path, 0777, TRUE);
diff --git a/core/modules/system/src/Tests/Installer/DistributionProfileTranslationTest.php b/core/modules/system/src/Tests/Installer/DistributionProfileTranslationTest.php
index 29b9b3ccdf9..799affe37bd 100644
--- a/core/modules/system/src/Tests/Installer/DistributionProfileTranslationTest.php
+++ b/core/modules/system/src/Tests/Installer/DistributionProfileTranslationTest.php
@@ -30,18 +30,18 @@ class DistributionProfileTranslationTest extends InstallerTestBase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->info = array(
+ $this->info = [
'type' => 'profile',
'core' => \Drupal::CORE_COMPATIBILITY,
'name' => 'Distribution profile',
- 'distribution' => array(
+ 'distribution' => [
'name' => 'My Distribution',
'langcode' => $this->langcode,
- 'install' => array(
+ 'install' => [
'theme' => 'bartik',
- ),
- ),
- );
+ ],
+ ],
+ ];
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/mydistro';
mkdir($path, 0777, TRUE);
diff --git a/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php b/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php
index eb50a0d88b3..2ab980feadd 100644
--- a/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php
@@ -24,10 +24,10 @@ class InstallerConfigDirectorySetNoDirectoryErrorTest extends InstallerTestBase
*/
protected function setUp() {
$this->configDirectory = $this->publicFilesDirectory . '/config_' . Crypt::randomBytesBase64();
- $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) array(
+ $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
'value' => $this->configDirectory . '/sync',
'required' => TRUE,
- );
+ ];
// Create the files directory early so we can test the error case.
mkdir($this->publicFilesDirectory);
// Create a file so the directory can not be created.
diff --git a/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php b/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php
index 4daa45cc448..11febf2d6f0 100644
--- a/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php
@@ -24,15 +24,15 @@ class InstallerConfigDirectorySetNoDirectoryTest extends InstallerTestBase {
*/
protected function setUp() {
$this->syncDirectory = $this->publicFilesDirectory . '/config_' . Crypt::randomBytesBase64() . '/sync';
- $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) array(
+ $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
'value' => $this->syncDirectory,
'required' => TRUE,
- );
+ ];
// Other directories will be created too.
- $this->settings['config_directories']['custom'] = (object) array(
+ $this->settings['config_directories']['custom'] = (object) [
'value' => $this->publicFilesDirectory . '/config_custom',
'required' => TRUE,
- );
+ ];
parent::setUp();
}
diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingConfigDirectoryTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingConfigDirectoryTest.php
index ae6b6069e40..b06b4caf6ec 100644
--- a/core/modules/system/src/Tests/Installer/InstallerExistingConfigDirectoryTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerExistingConfigDirectoryTest.php
@@ -24,10 +24,10 @@ class InstallerExistingConfigDirectoryTest extends InstallerTestBase {
protected function setUp() {
mkdir($this->siteDirectory . '/config_read_only', 0444);
$this->expectedFilePerms = fileperms($this->siteDirectory . '/config_read_only');
- $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) array(
+ $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
'value' => $this->siteDirectory . '/config_read_only',
'required' => TRUE,
- );
+ ];
parent::setUp();
}
diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php
index 733f6bc4f22..63d3ce407a2 100644
--- a/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerExistingDatabaseSettingsTest.php
@@ -22,10 +22,10 @@ class InstallerExistingDatabaseSettingsTest extends InstallerTestBase {
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
- $this->settings['databases']['default'] = (object) array(
+ $this->settings['databases']['default'] = (object) [
'value' => $connection_info,
'required' => TRUE,
- );
+ ];
parent::setUp();
}
@@ -40,13 +40,13 @@ class InstallerExistingDatabaseSettingsTest extends InstallerTestBase {
// All database settings should be pre-configured, except password.
$values = $this->parameters['forms']['install_settings_form'];
$driver = $values['driver'];
- $edit = array();
+ $edit = [];
if (isset($values[$driver]['password']) && $values[$driver]['password'] !== '') {
- $edit = $this->translatePostValues(array(
- $driver => array(
+ $edit = $this->translatePostValues([
+ $driver => [
'password' => $values[$driver]['password'],
- ),
- ));
+ ],
+ ]);
}
$this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
}
diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsMismatchProfileTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsMismatchProfileTest.php
index a179039d0f9..0349fe51524 100644
--- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsMismatchProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsMismatchProfileTest.php
@@ -24,20 +24,20 @@ class InstallerExistingSettingsMismatchProfileTest extends InstallerTestBase {
protected function setUp() {
// Pre-configure hash salt.
// Any string is valid, so simply use the class name of this test.
- $this->settings['settings']['hash_salt'] = (object) array(
+ $this->settings['settings']['hash_salt'] = (object) [
'value' => __CLASS__,
'required' => TRUE,
- );
+ ];
// Pre-configure database credentials.
$connection_info = Database::getConnectionInfo();
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
- $this->settings['databases']['default'] = (object) array(
+ $this->settings['databases']['default'] = (object) [
'value' => $connection_info,
'required' => TRUE,
- );
+ ];
// During interactive install we'll change this to a different profile and
// this test will ensure that the new value is written to settings.php.
@@ -47,12 +47,12 @@ class InstallerExistingSettingsMismatchProfileTest extends InstallerTestBase {
];
// Pre-configure config directories.
- $this->settings['config_directories'] = array(
- CONFIG_SYNC_DIRECTORY => (object) array(
+ $this->settings['config_directories'] = [
+ CONFIG_SYNC_DIRECTORY => (object) [
'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync',
'required' => TRUE,
- ),
- );
+ ],
+ ];
mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
parent::setUp();
diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php
index 95173085ff9..3405cb598ae 100644
--- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsNoProfileTest.php
@@ -23,28 +23,28 @@ class InstallerExistingSettingsNoProfileTest extends InstallerTestBase {
protected function setUp() {
// Pre-configure hash salt.
// Any string is valid, so simply use the class name of this test.
- $this->settings['settings']['hash_salt'] = (object) array(
+ $this->settings['settings']['hash_salt'] = (object) [
'value' => __CLASS__,
'required' => TRUE,
- );
+ ];
// Pre-configure database credentials.
$connection_info = Database::getConnectionInfo();
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
- $this->settings['databases']['default'] = (object) array(
+ $this->settings['databases']['default'] = (object) [
'value' => $connection_info,
'required' => TRUE,
- );
+ ];
// Pre-configure config directories.
- $this->settings['config_directories'] = array(
- CONFIG_SYNC_DIRECTORY => (object) array(
+ $this->settings['config_directories'] = [
+ CONFIG_SYNC_DIRECTORY => (object) [
'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync',
'required' => TRUE,
- ),
- );
+ ],
+ ];
mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
parent::setUp();
diff --git a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php
index eaca8fa3a4d..4f09b6b7c01 100644
--- a/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php
@@ -24,38 +24,38 @@ class InstallerExistingSettingsTest extends InstallerTestBase {
protected function setUp() {
// Pre-configure hash salt.
// Any string is valid, so simply use the class name of this test.
- $this->settings['settings']['hash_salt'] = (object) array(
+ $this->settings['settings']['hash_salt'] = (object) [
'value' => __CLASS__,
'required' => TRUE,
- );
+ ];
// During interactive install we'll change this to a different profile and
// this test will ensure that the new value is written to settings.php.
- $this->settings['settings']['install_profile'] = (object) array(
+ $this->settings['settings']['install_profile'] = (object) [
'value' => 'minimal',
'required' => TRUE,
- );
+ ];
// Pre-configure database credentials.
$connection_info = Database::getConnectionInfo();
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
- $this->settings['databases']['default'] = (object) array(
+ $this->settings['databases']['default'] = (object) [
'value' => $connection_info,
'required' => TRUE,
- );
+ ];
// Use the kernel to find the site path because the site.path service should
// not be available at this point in the install process.
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
// Pre-configure config directories.
- $this->settings['config_directories'] = array(
- CONFIG_SYNC_DIRECTORY => (object) array(
+ $this->settings['config_directories'] = [
+ CONFIG_SYNC_DIRECTORY => (object) [
'value' => $site_path . '/files/config_sync',
'required' => TRUE,
- ),
- );
+ ],
+ ];
mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
parent::setUp();
diff --git a/core/modules/system/src/Tests/Installer/InstallerTest.php b/core/modules/system/src/Tests/Installer/InstallerTest.php
index 7a145f86018..01422a5cbbc 100644
--- a/core/modules/system/src/Tests/Installer/InstallerTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerTest.php
@@ -22,9 +22,9 @@ class InstallerTest extends InstallerTestBase {
// Verify that the confirmation message appears.
require_once \Drupal::root() . '/core/includes/install.inc';
- $this->assertRaw(t('Congratulations, you installed @drupal!', array(
+ $this->assertRaw(t('Congratulations, you installed @drupal!', [
'@drupal' => drupal_install_profile_distribution_name(),
- )));
+ ]));
}
/**
@@ -48,7 +48,7 @@ class InstallerTest extends InstallerTestBase {
protected function setUpProfile() {
// Assert that the expected title is present.
$this->assertEqual('Select an installation profile', $this->cssSelect('main h2')[0]);
- $result = $this->xpath('//span[contains(@class, :class) and contains(text(), :text)]', array(':class' => 'visually-hidden', ':text' => 'Select an installation profile'));
+ $result = $this->xpath('//span[contains(@class, :class) and contains(text(), :text)]', [':class' => 'visually-hidden', ':text' => 'Select an installation profile']);
$this->assertEqual(count($result), 1, "Title/Label not displayed when '#title_display' => 'invisible' attribute is set");
parent::setUpProfile();
diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php
index a89a3cb7a2b..a608cada77f 100644
--- a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php
@@ -116,10 +116,10 @@ ENDPO;
// Activate a module, to make sure that config is not overridden by module
// installation.
- $edit = array(
+ $edit = [
'modules[views][enable]' => TRUE,
'modules[filter][enable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Verify the strings from the translation are still as expected.
@@ -149,7 +149,7 @@ ENDPO;
foreach ($test_samples as $sample) {
foreach ($langcodes as $langcode) {
- $edit = array();
+ $edit = [];
$edit['langcode'] = $langcode;
$edit['translation'] = 'translated';
$edit['string'] = $sample;
diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php
index ade71834b5a..7a803e700b5 100644
--- a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php
@@ -84,11 +84,11 @@ class InstallerTranslationTest extends InstallerTestBase {
$this->assertEqual($account->language()->getId(), 'de', 'New user is German.');
// Ensure that we can enable basic_auth on a non-english site.
- $this->drupalPostForm('admin/modules', array('modules[basic_auth][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[basic_auth][enable]' => TRUE], t('Install'));
$this->assertResponse(200);
// Assert that the theme CSS was added to the page.
- $edit = array('preprocess_css' => FALSE);
+ $edit = ['preprocess_css' => FALSE];
$this->drupalPostForm('admin/config/development/performance', $edit, t('Save configuration'));
$this->drupalGet('<front>');
$this->assertRaw('classy/css/components/action-links.css');
@@ -96,7 +96,7 @@ class InstallerTranslationTest extends InstallerTestBase {
// Verify the strings from the translation files were imported.
$test_samples = ['Save and continue', 'Anonymous'];
foreach ($test_samples as $sample) {
- $edit = array();
+ $edit = [];
$edit['langcode'] = 'de';
$edit['translation'] = 'translated';
$edit['string'] = $sample;
diff --git a/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php b/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
index b54c4113ba9..91af34a2d16 100644
--- a/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
@@ -29,12 +29,12 @@ class SingleVisibleProfileTest extends InstallerTestBase {
protected $info;
protected function setUp() {
- $this->info = array(
+ $this->info = [
'type' => 'profile',
'core' => \Drupal::CORE_COMPATIBILITY,
'name' => 'Override standard',
'hidden' => TRUE,
- );
+ ];
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/standard';
mkdir($path, 0777, TRUE);
diff --git a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php
index 61e7c84db20..b0ceef9427a 100644
--- a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php
+++ b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php
@@ -20,9 +20,9 @@ class StandardInstallerTest extends ConfigAfterInstallerTestBase {
public function testInstaller() {
// Verify that the confirmation message appears.
require_once \Drupal::root() . '/core/includes/install.inc';
- $this->assertRaw(t('Congratulations, you installed @drupal!', array(
+ $this->assertRaw(t('Congratulations, you installed @drupal!', [
'@drupal' => drupal_install_profile_distribution_name(),
- )));
+ ]));
}
/**
diff --git a/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php b/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
index f9c35eec3a8..a18f45cd3f4 100644
--- a/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
+++ b/core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php
@@ -32,7 +32,7 @@ trait AssertBreadcrumbTrait {
* (optional) Whether the last link in $tree is expected to be active (TRUE)
* or just to be in the active trail (FALSE).
*/
- protected function assertBreadcrumb($goto, array $trail, $page_title = NULL, array $tree = array(), $last_active = TRUE) {
+ protected function assertBreadcrumb($goto, array $trail, $page_title = NULL, array $tree = [], $last_active = TRUE) {
if (isset($goto)) {
$this->drupalGet($goto);
}
@@ -40,7 +40,7 @@ trait AssertBreadcrumbTrait {
// Additionally assert page title, if given.
if (isset($page_title)) {
- $this->assertTitle(strtr('@title | Drupal', array('@title' => $page_title)));
+ $this->assertTitle(strtr('@title | Drupal', ['@title' => $page_title]));
}
// Additionally assert active trail in a menu tree output, if given.
@@ -84,25 +84,25 @@ trait AssertBreadcrumbTrait {
// No parts must be left, or an expected "Home" will always pass.
$pass = ($pass && empty($parts));
- $this->assertTrue($pass, format_string('Breadcrumb %parts found on @path.', array(
+ $this->assertTrue($pass, format_string('Breadcrumb %parts found on @path.', [
'%parts' => implode(' » ', $trail),
'@path' => $this->getUrl(),
- )));
+ ]));
}
/**
* Returns the breadcrumb contents of the current page in the internal browser.
*/
protected function getBreadcrumbParts() {
- $parts = array();
+ $parts = [];
$elements = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
if (!empty($elements)) {
foreach ($elements as $element) {
- $parts[] = array(
+ $parts[] = [
'text' => (string) $element,
'href' => (string) $element['href'],
'title' => (string) $element['title'],
- );
+ ];
}
}
return $parts;
diff --git a/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php b/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php
index 4313b4cf292..05e0268c20e 100644
--- a/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php
+++ b/core/modules/system/src/Tests/Menu/AssertMenuActiveTrailTrait.php
@@ -30,11 +30,11 @@ trait AssertMenuActiveTrailTrait {
foreach ($tree as $link_path => $link_title) {
$part_xpath = (!$i ? '//' : '/following-sibling::ul/descendant::');
$part_xpath .= 'li[contains(@class, :class)]/a[contains(@href, :href) and contains(text(), :title)]';
- $part_args = array(
+ $part_args = [
':class' => 'menu-item--active-trail',
':href' => Url::fromUri('base:' . $link_path)->toString(),
':title' => $link_title,
- );
+ ];
$xpath .= $this->buildXPathQuery($part_xpath, $part_args);
$i++;
}
@@ -49,17 +49,17 @@ trait AssertMenuActiveTrailTrait {
}
$xpath_last_active = ($last_active ? 'and contains(@class, :class-active)' : '');
$xpath .= 'li[contains(@class, :class-trail)]/a[contains(@href, :href) ' . $xpath_last_active . 'and contains(text(), :title)]';
- $args = array(
+ $args = [
':class-trail' => 'menu-item--active-trail',
':class-active' => 'is-active',
':href' => Url::fromUri('base:' . $active_link_path)->toString(),
':title' => $active_link_title,
- );
+ ];
$elements = $this->xpath($xpath, $args);
- $this->assertTrue(!empty($elements), format_string('Active link %title was found in menu tree, including active trail links %tree.', array(
+ $this->assertTrue(!empty($elements), format_string('Active link %title was found in menu tree, including active trail links %tree.', [
'%title' => $active_link_title,
'%tree' => implode(' » ', $tree),
- )));
+ ]));
}
}
diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
index f756300e355..f158f272bf4 100644
--- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
@@ -18,7 +18,7 @@ class BreadcrumbTest extends MenuTestBase {
*
* @var array
*/
- public static $modules = array('menu_test', 'block');
+ public static $modules = ['menu_test', 'block'];
/**
* An administrative user.
@@ -49,10 +49,10 @@ class BreadcrumbTest extends MenuTestBase {
// This test puts menu links in the Tools menu and then tests for their
// presence on the page, so we need to ensure that the Tools block will be
// displayed in the admin theme.
- $this->drupalPlaceBlock('system_menu_block:tools', array(
+ $this->drupalPlaceBlock('system_menu_block:tools', [
'region' => 'content',
'theme' => $this->config('system.theme')->get('admin'),
- ));
+ ]);
}
/**
@@ -60,85 +60,85 @@ class BreadcrumbTest extends MenuTestBase {
*/
function testBreadCrumbs() {
// Prepare common base breadcrumb elements.
- $home = array('' => 'Home');
- $admin = $home + array('admin' => t('Administration'));
- $config = $admin + array('admin/config' => t('Configuration'));
+ $home = ['' => 'Home'];
+ $admin = $home + ['admin' => t('Administration')];
+ $config = $admin + ['admin/config' => t('Configuration')];
$type = 'article';
// Verify Taxonomy administration breadcrumbs.
- $trail = $admin + array(
+ $trail = $admin + [
'admin/structure' => t('Structure'),
- );
+ ];
$this->assertBreadcrumb('admin/structure/taxonomy', $trail);
- $trail += array(
+ $trail += [
'admin/structure/taxonomy' => t('Taxonomy'),
- );
+ ];
$this->assertBreadcrumb('admin/structure/taxonomy/manage/tags', $trail);
- $trail += array(
+ $trail += [
'admin/structure/taxonomy/manage/tags' => t('Tags'),
- );
+ ];
$this->assertBreadcrumb('admin/structure/taxonomy/manage/tags/overview', $trail);
$this->assertBreadcrumb('admin/structure/taxonomy/manage/tags/add', $trail);
// Verify Menu administration breadcrumbs.
- $trail = $admin + array(
+ $trail = $admin + [
'admin/structure' => t('Structure'),
- );
+ ];
$this->assertBreadcrumb('admin/structure/menu', $trail);
- $trail += array(
+ $trail += [
'admin/structure/menu' => t('Menus'),
- );
+ ];
$this->assertBreadcrumb('admin/structure/menu/manage/tools', $trail);
- $trail += array(
+ $trail += [
'admin/structure/menu/manage/tools' => t('Tools'),
- );
+ ];
$this->assertBreadcrumb("admin/structure/menu/link/node.add_page/edit", $trail);
$this->assertBreadcrumb('admin/structure/menu/manage/tools/add', $trail);
// Verify Node administration breadcrumbs.
- $trail = $admin + array(
+ $trail = $admin + [
'admin/structure' => t('Structure'),
'admin/structure/types' => t('Content types'),
- );
+ ];
$this->assertBreadcrumb('admin/structure/types/add', $trail);
$this->assertBreadcrumb("admin/structure/types/manage/$type", $trail);
- $trail += array(
+ $trail += [
"admin/structure/types/manage/$type" => t('Article'),
- );
+ ];
$this->assertBreadcrumb("admin/structure/types/manage/$type/fields", $trail);
$this->assertBreadcrumb("admin/structure/types/manage/$type/display", $trail);
- $trail_teaser = $trail + array(
+ $trail_teaser = $trail + [
"admin/structure/types/manage/$type/display" => t('Manage display'),
- );
+ ];
$this->assertBreadcrumb("admin/structure/types/manage/$type/display/teaser", $trail_teaser);
$this->assertBreadcrumb("admin/structure/types/manage/$type/delete", $trail);
- $trail += array(
+ $trail += [
"admin/structure/types/manage/$type/fields" => t('Manage fields'),
- );
+ ];
$this->assertBreadcrumb("admin/structure/types/manage/$type/fields/node.$type.body", $trail);
// Verify Filter text format administration breadcrumbs.
$filter_formats = filter_formats();
$format = reset($filter_formats);
$format_id = $format->id();
- $trail = $config + array(
+ $trail = $config + [
'admin/config/content' => t('Content authoring'),
- );
+ ];
$this->assertBreadcrumb('admin/config/content/formats', $trail);
- $trail += array(
+ $trail += [
'admin/config/content/formats' => t('Text formats and editors'),
- );
+ ];
$this->assertBreadcrumb('admin/config/content/formats/add', $trail);
$this->assertBreadcrumb("admin/config/content/formats/manage/$format_id", $trail);
// @todo Remove this part once we have a _title_callback, see
// https://www.drupal.org/node/2076085.
- $trail += array(
+ $trail += [
"admin/config/content/formats/manage/$format_id" => $format->label(),
- );
+ ];
$this->assertBreadcrumb("admin/config/content/formats/manage/$format_id/disable", $trail);
// Verify node breadcrumbs (without menu link).
@@ -151,13 +151,13 @@ class BreadcrumbTest extends MenuTestBase {
// Also verify that the node does not appear elsewhere (e.g., menu trees).
$this->assertNoLink($node1->getTitle());
- $trail += array(
+ $trail += [
"node/$nid1" => $node1->getTitle(),
- );
+ ];
$this->assertBreadcrumb("node/$nid1/edit", $trail);
// Verify that breadcrumb on node listing page contains "Home" only.
- $trail = array();
+ $trail = [];
$this->assertBreadcrumb('node', $trail);
// Verify node breadcrumbs (in menu).
@@ -165,7 +165,7 @@ class BreadcrumbTest extends MenuTestBase {
// latter is a preferred menu by default.
// @todo Also test all themes? Manually testing led to the suspicion that
// breadcrumbs may differ, possibly due to theme overrides.
- $menus = array('main', 'tools');
+ $menus = ['main', 'tools'];
// Alter node type menu settings.
$node_type = NodeType::load($type);
$node_type->setThirdPartySetting('menu_ui', 'available_menus', $menus);
@@ -175,17 +175,17 @@ class BreadcrumbTest extends MenuTestBase {
foreach ($menus as $menu) {
// Create a parent node in the current menu.
$title = $this->randomMachineName();
- $node2 = $this->drupalCreateNode(array(
+ $node2 = $this->drupalCreateNode([
'type' => $type,
'title' => $title,
- 'menu' => array(
+ 'menu' => [
'enabled' => 1,
'title' => 'Parent ' . $title,
'description' => '',
'menu_name' => $menu,
'parent' => '',
- ),
- ));
+ ],
+ ]);
if ($menu == 'tools') {
$parent = $node2;
@@ -195,38 +195,38 @@ class BreadcrumbTest extends MenuTestBase {
// Create a Tools menu link for 'node', move the last parent node menu
// link below it, and verify a full breadcrumb for the last child node.
$menu = 'tools';
- $edit = array(
+ $edit = [
'title[0][value]' => 'Root',
'link[0][uri]' => '/node',
- );
+ ];
$this->drupalPostForm("admin/structure/menu/manage/$menu/add", $edit, t('Save'));
- $menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => 'Root'));
+ $menu_links = entity_load_multiple_by_properties('menu_link_content', ['title' => 'Root']);
$link = reset($menu_links);
- $edit = array(
+ $edit = [
'menu[menu_parent]' => $link->getMenuName() . ':' . $link->getPluginId(),
- );
+ ];
$this->drupalPostForm('node/' . $parent->id() . '/edit', $edit, t('Save and keep published'));
- $expected = array(
+ $expected = [
"node" => $link->getTitle(),
- );
+ ];
$trail = $home + $expected;
- $tree = $expected + array(
+ $tree = $expected + [
'node/' . $parent->id() => $parent->menu['title'],
- );
- $trail += array(
+ ];
+ $trail += [
'node/' . $parent->id() => $parent->menu['title'],
- );
+ ];
// Add a taxonomy term/tag to last node, and add a link for that term to the
// Tools menu.
- $tags = array(
- 'Drupal' => array(),
- 'Breadcrumbs' => array(),
- );
- $edit = array(
+ $tags = [
+ 'Drupal' => [],
+ 'Breadcrumbs' => [],
+ ];
+ $edit = [
'field_tags[target_id]' => implode(',', array_keys($tags)),
- );
+ ];
$this->drupalPostForm('node/' . $parent->id() . '/edit', $edit, t('Save and keep published'));
// Put both terms into a hierarchy Drupal » Breadcrumbs. Required for both
@@ -234,13 +234,13 @@ class BreadcrumbTest extends MenuTestBase {
// the breadcrumb based on taxonomy term hierarchy.
$parent_tid = 0;
foreach ($tags as $name => $null) {
- $terms = entity_load_multiple_by_properties('taxonomy_term', array('name' => $name));
+ $terms = entity_load_multiple_by_properties('taxonomy_term', ['name' => $name]);
$term = reset($terms);
$tags[$name]['term'] = $term;
if ($parent_tid) {
- $edit = array(
- 'parent[]' => array($parent_tid),
- );
+ $edit = [
+ 'parent[]' => [$parent_tid],
+ ];
$this->drupalPostForm("taxonomy/term/{$term->id()}/edit", $edit, t('Save'));
}
$parent_tid = $term->id();
@@ -248,24 +248,24 @@ class BreadcrumbTest extends MenuTestBase {
$parent_mlid = '';
foreach ($tags as $name => $data) {
$term = $data['term'];
- $edit = array(
+ $edit = [
'title[0][value]' => "$name link",
'link[0][uri]' => "/taxonomy/term/{$term->id()}",
'menu_parent' => "$menu:{$parent_mlid}",
'enabled[value]' => 1,
- );
+ ];
$this->drupalPostForm("admin/structure/menu/manage/$menu/add", $edit, t('Save'));
- $menu_links = entity_load_multiple_by_properties('menu_link_content', array(
+ $menu_links = entity_load_multiple_by_properties('menu_link_content', [
'title' => $edit['title[0][value]'],
'link.uri' => 'internal:/taxonomy/term/' . $term->id(),
- ));
+ ]);
$tags[$name]['link'] = reset($menu_links);
$parent_mlid = $tags[$name]['link']->getPluginId();
}
// Verify expected breadcrumbs for menu links.
$trail = $home;
- $tree = array();
+ $tree = [];
// Logout the user because we want to check the active class as well, which
// is just rendered as anonymous user.
$this->drupalLogout();
@@ -275,9 +275,9 @@ class BreadcrumbTest extends MenuTestBase {
$link = $data['link'];
$link_path = $link->getUrlObject()->getInternalPath();
- $tree += array(
+ $tree += [
$link_path => $link->getTitle(),
- );
+ ];
$this->assertBreadcrumb($link_path, $trail, $term->getName(), $tree);
$this->assertEscaped($parent->getTitle(), 'Tagged node found.');
@@ -285,28 +285,28 @@ class BreadcrumbTest extends MenuTestBase {
// untranslated menu links automatically generated from menu router items
// ('taxonomy/term/%') should never be translated and appear in any menu
// other than the breadcrumb trail.
- $elements = $this->xpath('//nav[@id=:menu]/descendant::a[@href=:href]', array(
+ $elements = $this->xpath('//nav[@id=:menu]/descendant::a[@href=:href]', [
':menu' => 'block-bartik-tools',
':href' => Url::fromUri('base:' . $link_path)->toString(),
- ));
+ ]);
$this->assertTrue(count($elements) == 1, "Link to {$link_path} appears only once.");
// Next iteration should expect this tag as parent link.
// Note: Term name, not link name, due to taxonomy_term_page().
- $trail += array(
+ $trail += [
$link_path => $term->getName(),
- );
+ ];
}
// Verify breadcrumbs on user and user/%.
// We need to log back in and out below, and cannot simply grant the
// 'administer users' permission, since user_page() makes your head explode.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
'access user profiles',
- ));
+ ]);
// Verify breadcrumb on front page.
- $this->assertBreadcrumb('<front>', array());
+ $this->assertBreadcrumb('<front>', []);
// Verify breadcrumb on user pages (without menu link) for anonymous user.
$trail = $home;
@@ -318,39 +318,39 @@ class BreadcrumbTest extends MenuTestBase {
$trail = $home;
$this->assertBreadcrumb('user', $trail, $this->adminUser->getUsername());
$this->assertBreadcrumb('user/' . $this->adminUser->id(), $trail, $this->adminUser->getUsername());
- $trail += array(
+ $trail += [
'user/' . $this->adminUser->id() => $this->adminUser->getUsername(),
- );
+ ];
$this->assertBreadcrumb('user/' . $this->adminUser->id() . '/edit', $trail, $this->adminUser->getUsername());
// Create a second user to verify breadcrumb on user pages again.
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'administer users',
'access user profiles',
- ));
+ ]);
$this->drupalLogin($this->webUser);
// Verify correct breadcrumb and page title on another user's account pages.
$trail = $home;
$this->assertBreadcrumb('user/' . $this->adminUser->id(), $trail, $this->adminUser->getUsername());
- $trail += array(
+ $trail += [
'user/' . $this->adminUser->id() => $this->adminUser->getUsername(),
- );
+ ];
$this->assertBreadcrumb('user/' . $this->adminUser->id() . '/edit', $trail, $this->adminUser->getUsername());
// Verify correct breadcrumb and page title when viewing own user account.
$trail = $home;
$this->assertBreadcrumb('user/' . $this->webUser->id(), $trail, $this->webUser->getUsername());
- $trail += array(
+ $trail += [
'user/' . $this->webUser->id() => $this->webUser->getUsername(),
- );
+ ];
$this->assertBreadcrumb('user/' . $this->webUser->id() . '/edit', $trail, $this->webUser->getUsername());
// Create an only slightly privileged user being able to access site reports
// but not administration pages.
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'access site reports',
- ));
+ ]);
$this->drupalLogin($this->webUser);
// Verify that we can access recent log entries, there is a corresponding
@@ -366,7 +366,7 @@ class BreadcrumbTest extends MenuTestBase {
$this->assertNoResponse(403);
// Since the Reports page is accessible, that will show.
- $trail += array('admin/reports' => t('Reports'));
+ $trail += ['admin/reports' => t('Reports')];
$this->assertBreadcrumb('admin/reports/dblog', $trail, t('Recent log messages'));
$this->assertNoResponse(403);
diff --git a/core/modules/system/src/Tests/Menu/LocalActionTest.php b/core/modules/system/src/Tests/Menu/LocalActionTest.php
index 40dc744fb3c..3886cb80956 100644
--- a/core/modules/system/src/Tests/Menu/LocalActionTest.php
+++ b/core/modules/system/src/Tests/Menu/LocalActionTest.php
@@ -68,9 +68,9 @@ class LocalActionTest extends WebTestBase {
* A list of expected action link titles, keyed by the hrefs.
*/
protected function assertLocalAction(array $actions) {
- $elements = $this->xpath('//a[contains(@class, :class)]', array(
+ $elements = $this->xpath('//a[contains(@class, :class)]', [
':class' => 'button-action',
- ));
+ ]);
$index = 0;
foreach ($actions as $action) {
/** @var \Drupal\Core\Url $url */
diff --git a/core/modules/system/src/Tests/Menu/LocalTasksTest.php b/core/modules/system/src/Tests/Menu/LocalTasksTest.php
index 522e12b286b..7171d3e541c 100644
--- a/core/modules/system/src/Tests/Menu/LocalTasksTest.php
+++ b/core/modules/system/src/Tests/Menu/LocalTasksTest.php
@@ -48,19 +48,19 @@ class LocalTasksTest extends WebTestBase {
* secondary. Defaults to 0.
*/
protected function assertLocalTasks(array $routes, $level = 0) {
- $elements = $this->xpath('//*[contains(@class, :class)]//a', array(
+ $elements = $this->xpath('//*[contains(@class, :class)]//a', [
':class' => $level == 0 ? 'tabs primary' : 'tabs secondary',
- ));
+ ]);
$this->assertTrue(count($elements), 'Local tasks found.');
foreach ($routes as $index => $route_info) {
list($route_name, $route_parameters) = $route_info;
$expected = Url::fromRoute($route_name, $route_parameters)->toString();
$method = ($elements[$index]['href'] == $expected ? 'pass' : 'fail');
- $this->{$method}(format_string('Task @number href @value equals @expected.', array(
+ $this->{$method}(format_string('Task @number href @value equals @expected.', [
'@number' => $index + 1,
'@value' => (string) $elements[$index]['href'],
'@expected' => $expected,
- )));
+ ]));
}
}
@@ -89,9 +89,9 @@ class LocalTasksTest extends WebTestBase {
* secondary. Defaults to 0.
*/
protected function assertNoLocalTasks($level = 0) {
- $elements = $this->xpath('//*[contains(@class, :class)]//a', array(
+ $elements = $this->xpath('//*[contains(@class, :class)]//a', [
':class' => $level == 0 ? 'tabs primary' : 'tabs secondary',
- ));
+ ]);
$this->assertFalse(count($elements), 'Local tasks not found.');
}
@@ -176,7 +176,7 @@ class LocalTasksTest extends WebTestBase {
// Test that we we correctly apply the active class to tabs where one of the
// request attributes is upcast to an entity object.
- $entity = \Drupal::entityManager()->getStorage('entity_test')->create(array('bundle' => 'test'));
+ $entity = \Drupal::entityManager()->getStorage('entity_test')->create(['bundle' => 'test']);
$entity->save();
$this->drupalGet(Url::fromRoute('menu_test.local_task_test_upcasting_sub1', ['entity_test' => '1']));
diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php
index e7328d927b3..521a691537d 100644
--- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php
+++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php
@@ -82,7 +82,7 @@ class MenuRouterTest extends WebTestBase {
protected function doTestTitleCallbackFalse() {
$this->drupalGet('test-page');
$this->assertText('A title with @placeholder', 'Raw text found on the page');
- $this->assertNoText(t('A title with @placeholder', array('@placeholder' => 'some other text')), 'Text with placeholder substitutions not found.');
+ $this->assertNoText(t('A title with @placeholder', ['@placeholder' => 'some other text']), 'Text with placeholder substitutions not found.');
}
/**
@@ -110,7 +110,7 @@ class MenuRouterTest extends WebTestBase {
* Tests for menu_name parameter for default menu links.
*/
protected function doTestMenuName() {
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
@@ -179,7 +179,7 @@ class MenuRouterTest extends WebTestBase {
* Tests a menu on a router page.
*/
protected function doTestMenuOnRoute() {
- \Drupal::service('module_installer')->install(array('router_test'));
+ \Drupal::service('module_installer')->install(['router_test']);
\Drupal::service('router.builder')->rebuild();
$this->resetAll();
@@ -210,7 +210,7 @@ class MenuRouterTest extends WebTestBase {
public function testMaintenanceModeLoginPaths() {
$this->container->get('state')->set('system.maintenance_mode', TRUE);
- $offline_message = t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => $this->config('system.site')->get('name')));
+ $offline_message = t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', ['@site' => $this->config('system.site')->get('name')]);
$this->drupalGet('test-page');
$this->assertText($offline_message);
$this->drupalGet('menu_login_callback');
@@ -224,7 +224,7 @@ class MenuRouterTest extends WebTestBase {
* 'user' and 'user/register' gets redirected to the user edit page.
*/
public function testAuthUserUserLogin() {
- $web_user = $this->drupalCreateUser(array());
+ $web_user = $this->drupalCreateUser([]);
$this->drupalLogin($web_user);
$this->drupalGet('user/login');
@@ -282,7 +282,7 @@ class MenuRouterTest extends WebTestBase {
$this->assertRaw('bartik/css/base/elements.css', "The maintenance theme's CSS appears on the page.");
// An administrator, however, should continue to see the requested theme.
- $admin_user = $this->drupalCreateUser(array('access site in maintenance mode'));
+ $admin_user = $this->drupalCreateUser(['access site in maintenance mode']);
$this->drupalLogin($admin_user);
$this->drupalGet('menu-test/theme-callback/use-admin-theme');
$this->assertText('Active theme: seven. Actual theme: seven.', 'The theme negotiation system is correctly triggered for an administrator when the site is in maintenance mode.');
@@ -302,13 +302,13 @@ class MenuRouterTest extends WebTestBase {
// Now install the theme and request it again.
$theme_handler = $this->container->get('theme_handler');
- $theme_handler->install(array('test_theme'));
+ $theme_handler->install(['test_theme']);
$this->drupalGet('menu-test/theme-callback/use-test-theme');
$this->assertText('Active theme: test_theme. Actual theme: test_theme.', 'The theme negotiation system uses an optional theme once it has been installed.');
$this->assertRaw('test_theme/kitten.css', "The optional theme's CSS appears on the page.");
- $theme_handler->uninstall(array('test_theme'));
+ $theme_handler->uninstall(['test_theme']);
}
/**
diff --git a/core/modules/system/src/Tests/Module/DependencyTest.php b/core/modules/system/src/Tests/Module/DependencyTest.php
index 6160ef46489..1e297de0aac 100644
--- a/core/modules/system/src/Tests/Module/DependencyTest.php
+++ b/core/modules/system/src/Tests/Module/DependencyTest.php
@@ -13,16 +13,16 @@ class DependencyTest extends ModuleTestBase {
* Checks functionality of project namespaces for dependencies.
*/
function testProjectNamespaceForDependencies() {
- $edit = array(
+ $edit = [
'modules[filter][enable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Enable module with project namespace to ensure nothing breaks.
- $edit = array(
+ $edit = [
'modules[system_project_namespace_test][enable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
- $this->assertModules(array('system_project_namespace_test'), TRUE);
+ $this->assertModules(['system_project_namespace_test'], TRUE);
}
/**
@@ -30,19 +30,19 @@ class DependencyTest extends ModuleTestBase {
*/
function testEnableWithoutDependency() {
// Attempt to enable Content Translation without Language enabled.
- $edit = array();
+ $edit = [];
$edit['modules[content_translation][enable]'] = 'content_translation';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText(t('Some required modules must be enabled'), 'Dependency required.');
- $this->assertModules(array('content_translation', 'language'), FALSE);
+ $this->assertModules(['content_translation', 'language'], FALSE);
// Assert that the language tables weren't enabled.
$this->assertTableCount('language', FALSE);
$this->drupalPostForm(NULL, NULL, t('Continue'));
$this->assertText(t('2 modules have been enabled: Content Translation, Language.'), 'Modules status has been updated.');
- $this->assertModules(array('content_translation', 'language'), TRUE);
+ $this->assertModules(['content_translation', 'language'], TRUE);
// Assert that the language YAML files were created.
$storage = $this->container->get('config.storage');
@@ -56,7 +56,7 @@ class DependencyTest extends ModuleTestBase {
// Test that the system_dependencies_test module is marked
// as missing a dependency.
$this->drupalGet('admin/modules');
- $this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst('_missing_dependency'))), 'A module with missing dependencies is marked as such.');
+ $this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst('_missing_dependency')]), 'A module with missing dependencies is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
}
@@ -68,10 +68,10 @@ class DependencyTest extends ModuleTestBase {
// Test that the system_incompatible_module_version_dependencies_test is
// marked as having an incompatible dependency.
$this->drupalGet('admin/modules');
- $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
+ $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> version @version)', [
'@module' => 'System incompatible module version test (>2.0)',
'@version' => '1.0',
- )), 'A module that depends on an incompatible version of a module is marked as such.');
+ ]), 'A module that depends on an incompatible version of a module is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_module_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
}
@@ -83,9 +83,9 @@ class DependencyTest extends ModuleTestBase {
// Test that the system_incompatible_core_version_dependencies_test is
// marked as having an incompatible dependency.
$this->drupalGet('admin/modules');
- $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
+ $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
'@module' => 'System incompatible core version test',
- )), 'A module that depends on a module with an incompatible core version is marked as such.');
+ ]), 'A module that depends on a module with an incompatible core version is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_core_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
}
@@ -94,25 +94,25 @@ class DependencyTest extends ModuleTestBase {
* Tests enabling a module that depends on a module which fails hook_requirements().
*/
function testEnableRequirementsFailureDependency() {
- \Drupal::service('module_installer')->install(array('comment'));
+ \Drupal::service('module_installer')->install(['comment']);
- $this->assertModules(array('requirements1_test'), FALSE);
- $this->assertModules(array('requirements2_test'), FALSE);
+ $this->assertModules(['requirements1_test'], FALSE);
+ $this->assertModules(['requirements2_test'], FALSE);
// Attempt to install both modules at the same time.
- $edit = array();
+ $edit = [];
$edit['modules[requirements1_test][enable]'] = 'requirements1_test';
$edit['modules[requirements2_test][enable]'] = 'requirements2_test';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Makes sure the modules were NOT installed.
$this->assertText(t('Requirements 1 Test failed requirements'), 'Modules status has been updated.');
- $this->assertModules(array('requirements1_test'), FALSE);
- $this->assertModules(array('requirements2_test'), FALSE);
+ $this->assertModules(['requirements1_test'], FALSE);
+ $this->assertModules(['requirements2_test'], FALSE);
// Makes sure that already enabled modules the failing modules depend on
// were not disabled.
- $this->assertModules(array('comment'), TRUE);
+ $this->assertModules(['comment'], TRUE);
}
/**
@@ -121,21 +121,21 @@ class DependencyTest extends ModuleTestBase {
* Dependencies should be enabled before their dependents.
*/
function testModuleEnableOrder() {
- \Drupal::service('module_installer')->install(array('module_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_test'], FALSE);
$this->resetAll();
- $this->assertModules(array('module_test'), TRUE);
+ $this->assertModules(['module_test'], TRUE);
\Drupal::state()->set('module_test.dependency', 'dependency');
// module_test creates a dependency chain:
// - color depends on config
// - config depends on help
- $expected_order = array('help', 'config', 'color');
+ $expected_order = ['help', 'config', 'color'];
// Enable the modules through the UI, verifying that the dependency chain
// is correct.
- $edit = array();
+ $edit = [];
$edit['modules[color][enable]'] = 'color';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
- $this->assertModules(array('color'), FALSE);
+ $this->assertModules(['color'], FALSE);
// Note that dependencies are sorted alphabetically in the confirmation
// message.
$this->assertText(t('You must enable the Configuration Manager, Help modules to install Color.'));
@@ -143,10 +143,10 @@ class DependencyTest extends ModuleTestBase {
$edit['modules[config][enable]'] = 'config';
$edit['modules[help][enable]'] = 'help';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
- $this->assertModules(array('color', 'config', 'help'), TRUE);
+ $this->assertModules(['color', 'config', 'help'], TRUE);
// Check the actual order which is saved by module_test_modules_enabled().
- $module_order = \Drupal::state()->get('module_test.install_order') ?: array();
+ $module_order = \Drupal::state()->get('module_test.install_order') ?: [];
$this->assertIdentical($module_order, $expected_order);
}
@@ -155,10 +155,10 @@ class DependencyTest extends ModuleTestBase {
*/
function testUninstallDependents() {
// Enable the forum module.
- $edit = array('modules[forum][enable]' => 'forum');
+ $edit = ['modules[forum][enable]' => 'forum'];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
- $this->drupalPostForm(NULL, array(), t('Continue'));
- $this->assertModules(array('forum'), TRUE);
+ $this->drupalPostForm(NULL, [], t('Continue'));
+ $this->assertModules(['forum'], TRUE);
// Check that the comment module cannot be uninstalled.
$this->drupalGet('admin/modules/uninstall');
@@ -176,13 +176,13 @@ class DependencyTest extends ModuleTestBase {
}
// Uninstall the forum module, and check that taxonomy now can also be
// uninstalled.
- $edit = array('uninstall[forum]' => 'forum');
+ $edit = ['uninstall[forum]' => 'forum'];
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
$this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
// Uninstall comment module.
- $edit = array('uninstall[comment]' => 'comment');
+ $edit = ['uninstall[comment]' => 'comment'];
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
$this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
diff --git a/core/modules/system/src/Tests/Module/HookRequirementsTest.php b/core/modules/system/src/Tests/Module/HookRequirementsTest.php
index 2f4fccad82c..75813c6118f 100644
--- a/core/modules/system/src/Tests/Module/HookRequirementsTest.php
+++ b/core/modules/system/src/Tests/Module/HookRequirementsTest.php
@@ -12,16 +12,16 @@ class HookRequirementsTest extends ModuleTestBase {
* Assert that a module cannot be installed if it fails hook_requirements().
*/
function testHookRequirementsFailure() {
- $this->assertModules(array('requirements1_test'), FALSE);
+ $this->assertModules(['requirements1_test'], FALSE);
// Attempt to install the requirements1_test module.
- $edit = array();
+ $edit = [];
$edit['modules[requirements1_test][enable]'] = 'requirements1_test';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Makes sure the module was NOT installed.
$this->assertText(t('Requirements 1 Test failed requirements'), 'Modules status has been updated.');
- $this->assertModules(array('requirements1_test'), FALSE);
+ $this->assertModules(['requirements1_test'], FALSE);
}
}
diff --git a/core/modules/system/src/Tests/Module/InstallUninstallTest.php b/core/modules/system/src/Tests/Module/InstallUninstallTest.php
index 3882013ab6a..f4db81e18e0 100644
--- a/core/modules/system/src/Tests/Module/InstallUninstallTest.php
+++ b/core/modules/system/src/Tests/Module/InstallUninstallTest.php
@@ -15,7 +15,7 @@ class InstallUninstallTest extends ModuleTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system_test', 'dblog', 'taxonomy', 'update_test_postupdate');
+ public static $modules = ['system_test', 'dblog', 'taxonomy', 'update_test_postupdate'];
/**
* Tests that a fixed set of modules can be installed and uninstalled.
@@ -27,9 +27,9 @@ class InstallUninstallTest extends ModuleTestBase {
// Install and uninstall module_test to ensure hook_preinstall_module and
// hook_preuninstall_module are fired as expected.
- $this->container->get('module_installer')->install(array('module_test'));
+ $this->container->get('module_installer')->install(['module_test']);
$this->assertEqual($this->container->get('state')->get('system_test_preinstall_module'), 'module_test');
- $this->container->get('module_installer')->uninstall(array('module_test'));
+ $this->container->get('module_installer')->uninstall(['module_test']);
$this->assertEqual($this->container->get('state')->get('system_test_preuninstall_module'), 'module_test');
$this->resetAll();
@@ -58,7 +58,7 @@ class InstallUninstallTest extends ModuleTestBase {
// Install the Help module, and verify it installed successfully.
unset($all_modules['help']);
$this->assertModuleNotInstalled('help');
- $edit = array();
+ $edit = [];
$edit["modules[help][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText('has been enabled', 'Modules status has been updated.');
@@ -76,7 +76,7 @@ class InstallUninstallTest extends ModuleTestBase {
$was_installed_list = \Drupal::moduleHandler()->getModuleList();
// Start a list of modules that we expect to be installed this time.
- $modules_to_install = array($name);
+ $modules_to_install = [$name];
foreach (array_keys($module->requires) as $dependency) {
if (isset($all_modules[$dependency])) {
$modules_to_install[] = $dependency;
@@ -90,7 +90,7 @@ class InstallUninstallTest extends ModuleTestBase {
}
// Install the module.
- $edit = array();
+ $edit = [];
$package = $module->info['package'];
$edit['modules[' . $name . '][enable]'] = TRUE;
$this->drupalPostForm('admin/modules', $edit, t('Install'));
@@ -104,7 +104,7 @@ class InstallUninstallTest extends ModuleTestBase {
// indicating they need to be enabled.
$this->assertText('You must enable');
}
- $this->drupalPostForm(NULL, array(), t('Continue'));
+ $this->drupalPostForm(NULL, [], t('Continue'));
}
// Handle the case where modules were installed along with this one and
// where we therefore hit a confirmation screen.
@@ -113,26 +113,26 @@ class InstallUninstallTest extends ModuleTestBase {
// about enabling dependencies appears.
$this->assertText('Some required modules must be enabled');
$this->assertText('You must enable');
- $this->drupalPostForm(NULL, array(), t('Continue'));
+ $this->drupalPostForm(NULL, [], t('Continue'));
}
// List the module display names to check the confirmation message.
- $module_names = array();
+ $module_names = [];
foreach ($modules_to_install as $module_to_install) {
$module_names[] = $all_modules[$module_to_install]->info['name'];
}
- $expected_text = \Drupal::translation()->formatPlural(count($module_names), 'Module @name has been enabled.', '@count modules have been enabled: @names.', array(
+ $expected_text = \Drupal::translation()->formatPlural(count($module_names), 'Module @name has been enabled.', '@count modules have been enabled: @names.', [
'@name' => $module_names[0],
'@names' => implode(', ', $module_names),
- ));
+ ]);
$this->assertText($expected_text, 'Modules status has been updated.');
// Check that hook_modules_installed() was invoked with the expected list
// of modules, that each module's database tables now exist, and that
// appropriate messages appear in the logs.
foreach ($modules_to_install as $module_to_install) {
- $this->assertText(t('hook_modules_installed fired for @module', array('@module' => $module_to_install)));
- $this->assertLogMessage('system', "%module module installed.", array('%module' => $module_to_install), RfcLogLevel::INFO);
+ $this->assertText(t('hook_modules_installed fired for @module', ['@module' => $module_to_install]));
+ $this->assertLogMessage('system', "%module module installed.", ['%module' => $module_to_install], RfcLogLevel::INFO);
$this->assertInstallModuleUpdates($module_to_install);
$this->assertModuleSuccessfullyInstalled($module_to_install);
}
@@ -163,7 +163,7 @@ class InstallUninstallTest extends ModuleTestBase {
// This one is eligible for being uninstalled.
$package = $all_modules[$to_uninstall]->info['package'];
$this->assertSuccessfulUninstall($to_uninstall, $package);
- $added_modules = array_diff($added_modules, array($to_uninstall));
+ $added_modules = array_diff($added_modules, [$to_uninstall]);
}
}
@@ -187,7 +187,7 @@ class InstallUninstallTest extends ModuleTestBase {
// uninstalled.
// - That enabling more than one module at the same time does not lead to
// any errors.
- $edit = array();
+ $edit = [];
$experimental = FALSE;
foreach ($all_modules as $name => $module) {
$edit['modules[' . $name . '][enable]'] = TRUE;
@@ -201,12 +201,12 @@ class InstallUninstallTest extends ModuleTestBase {
// If there are experimental modules, click the confirm form.
if ($experimental) {
$this->assertText('Are you sure you wish to enable experimental modules?');
- $this->drupalPostForm(NULL, array(), t('Continue'));
+ $this->drupalPostForm(NULL, [], t('Continue'));
}
// The string tested here is translatable but we are only using a part of it
// so using a translated string is wrong. Doing so would create a new string
// to translate.
- $this->assertText(new FormattableMarkup('@count modules have been enabled: ', array('@count' => count($all_modules))), 'Modules status has been updated.');
+ $this->assertText(new FormattableMarkup('@count modules have been enabled: ', ['@count' => count($all_modules)]), 'Modules status has been updated.');
}
/**
@@ -216,7 +216,7 @@ class InstallUninstallTest extends ModuleTestBase {
* Name of the module to check.
*/
protected function assertModuleNotInstalled($name) {
- $this->assertModules(array($name), FALSE);
+ $this->assertModules([$name], FALSE);
$this->assertModuleTablesDoNotExist($name);
}
@@ -227,7 +227,7 @@ class InstallUninstallTest extends ModuleTestBase {
* Name of the module to check.
*/
protected function assertModuleSuccessfullyInstalled($name) {
- $this->assertModules(array($name), TRUE);
+ $this->assertModules([$name], TRUE);
$this->assertModuleTablesExist($name);
$this->assertModuleConfig($name);
}
@@ -242,19 +242,19 @@ class InstallUninstallTest extends ModuleTestBase {
* to 'Core'.
*/
protected function assertSuccessfulUninstall($module, $package = 'Core') {
- $edit = array();
+ $edit = [];
$edit['uninstall[' . $module . ']'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
$this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
- $this->assertModules(array($module), FALSE);
+ $this->assertModules([$module], FALSE);
// Check that the appropriate hook was fired and the appropriate log
// message appears. (But don't check for the log message if the dblog
// module was just uninstalled, since the {watchdog} table won't be there
// anymore.)
- $this->assertText(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
- $this->assertLogMessage('system', "%module module uninstalled.", array('%module' => $module), RfcLogLevel::INFO);
+ $this->assertText(t('hook_modules_uninstalled fired for @module', ['@module' => $module]));
+ $this->assertLogMessage('system', "%module module uninstalled.", ['%module' => $module], RfcLogLevel::INFO);
// Check that the module's database tables no longer exist.
$this->assertModuleTablesDoNotExist($module);
diff --git a/core/modules/system/src/Tests/Module/ModuleTestBase.php b/core/modules/system/src/Tests/Module/ModuleTestBase.php
index ccf8cd56dcc..8d669caa7d2 100644
--- a/core/modules/system/src/Tests/Module/ModuleTestBase.php
+++ b/core/modules/system/src/Tests/Module/ModuleTestBase.php
@@ -21,14 +21,14 @@ abstract class ModuleTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('system_test');
+ public static $modules = ['system_test'];
protected $adminUser;
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$this->drupalLogin($this->adminUser);
}
@@ -45,9 +45,9 @@ abstract class ModuleTestBase extends WebTestBase {
$tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
if ($count) {
- return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
+ return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));
}
- return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', array('@base_table' => $base_table)));
+ return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', ['@base_table' => $base_table]));
}
/**
@@ -64,7 +64,7 @@ abstract class ModuleTestBase extends WebTestBase {
$tables_exist = FALSE;
}
}
- return $this->assertTrue($tables_exist, format_string('All database tables defined by the @module module exist.', array('@module' => $module)));
+ return $this->assertTrue($tables_exist, format_string('All database tables defined by the @module module exist.', ['@module' => $module]));
}
/**
@@ -81,7 +81,7 @@ abstract class ModuleTestBase extends WebTestBase {
$tables_exist = TRUE;
}
}
- return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', array('@module' => $module)));
+ return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', ['@module' => $module]));
}
/**
@@ -123,7 +123,7 @@ abstract class ModuleTestBase extends WebTestBase {
}
// Verify that all configuration has been installed (which means that $names
// is empty).
- return $this->assertFalse($names, format_string('All default configuration of @module module found.', array('@module' => $module)));
+ return $this->assertFalse($names, format_string('All default configuration of @module module found.', ['@module' => $module]));
}
/**
@@ -137,7 +137,7 @@ abstract class ModuleTestBase extends WebTestBase {
*/
function assertNoModuleConfig($module) {
$names = \Drupal::configFactory()->listAll($module . '.');
- return $this->assertFalse($names, format_string('No configuration found for @module module.', array('@module' => $module)));
+ return $this->assertFalse($names, format_string('No configuration found for @module module.', ['@module' => $module]));
}
/**
@@ -157,7 +157,7 @@ abstract class ModuleTestBase extends WebTestBase {
else {
$message = 'Module "@module" is not enabled.';
}
- $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, format_string($message, array('@module' => $module)));
+ $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, format_string($message, ['@module' => $module]));
}
}
@@ -181,7 +181,7 @@ abstract class ModuleTestBase extends WebTestBase {
* @param $link
* A link to associate with the message.
*/
- function assertLogMessage($type, $message, $variables = array(), $severity = RfcLogLevel::NOTICE, $link = '') {
+ function assertLogMessage($type, $message, $variables = [], $severity = RfcLogLevel::NOTICE, $link = '') {
$count = db_select('watchdog', 'w')
->condition('type', $type)
->condition('message', $message)
@@ -191,7 +191,7 @@ abstract class ModuleTestBase extends WebTestBase {
->countQuery()
->execute()
->fetchField();
- $this->assertTrue($count > 0, format_string('watchdog table contains @count rows for @message', array('@count' => $count, '@message' => format_string($message, $variables))));
+ $this->assertTrue($count > 0, format_string('watchdog table contains @count rows for @message', ['@count' => $count, '@message' => format_string($message, $variables)]));
}
}
diff --git a/core/modules/system/src/Tests/Module/RequiredTest.php b/core/modules/system/src/Tests/Module/RequiredTest.php
index a1e648b4a25..b5f17305e5f 100644
--- a/core/modules/system/src/Tests/Module/RequiredTest.php
+++ b/core/modules/system/src/Tests/Module/RequiredTest.php
@@ -20,7 +20,7 @@ class RequiredTest extends ModuleTestBase {
if (!empty($info['required'])) {
$field_name = 'modules[' . $module . '][enable]';
if (empty($info['hidden'])) {
- $this->assertFieldByXPath("//input[@name='$field_name' and @disabled='disabled' and @checked='checked']", '', format_string('Field @name was disabled and checked.', array('@name' => $field_name)));
+ $this->assertFieldByXPath("//input[@name='$field_name' and @disabled='disabled' and @checked='checked']", '', format_string('Field @name was disabled and checked.', ['@name' => $field_name]));
}
else {
$this->assertNoFieldByName($field_name);
diff --git a/core/modules/system/src/Tests/Module/VersionTest.php b/core/modules/system/src/Tests/Module/VersionTest.php
index fee684cc62e..1e33f11d43e 100644
--- a/core/modules/system/src/Tests/Module/VersionTest.php
+++ b/core/modules/system/src/Tests/Module/VersionTest.php
@@ -13,7 +13,7 @@ class VersionTest extends ModuleTestBase {
* Test version dependencies.
*/
function testModuleVersions() {
- $dependencies = array(
+ $dependencies = [
// Alternating between being compatible and incompatible with 8.x-2.4-beta3.
// The first is always a compatible.
'common_test',
@@ -43,7 +43,7 @@ class VersionTest extends ModuleTestBase {
'common_test (>2.4-beta2)',
// Testing extra version. Incompatible.
'common_test (>2.4-rc0)',
- );
+ ];
\Drupal::state()->set('system_test.dependencies', $dependencies);
$n = count($dependencies);
for ($i = 0; $i < $n; $i++) {
diff --git a/core/modules/system/src/Tests/Pager/PagerTest.php b/core/modules/system/src/Tests/Pager/PagerTest.php
index 4c13c0fa1ca..9aae6dec11d 100644
--- a/core/modules/system/src/Tests/Pager/PagerTest.php
+++ b/core/modules/system/src/Tests/Pager/PagerTest.php
@@ -16,7 +16,7 @@ class PagerTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('dblog', 'pager_test');
+ public static $modules = ['dblog', 'pager_test'];
/**
* A user with permission to access site reports.
@@ -36,9 +36,9 @@ class PagerTest extends WebTestBase {
$logger->debug($this->randomString());
}
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'access site reports',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
}
@@ -53,14 +53,14 @@ class PagerTest extends WebTestBase {
// Verify any page but first/last.
$current_page++;
- $this->drupalGet('admin/reports/dblog', array('query' => array('page' => $current_page)));
+ $this->drupalGet('admin/reports/dblog', ['query' => ['page' => $current_page]]);
$this->assertPagerItems($current_page);
// Verify last page.
- $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--last'));
+ $elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--last']);
preg_match('@page=(\d+)@', $elements[0]['href'], $matches);
$current_page = (int) $matches[1];
- $this->drupalGet($GLOBALS['base_root'] . parse_url($this->getUrl())['path'] . $elements[0]['href'], array('external' => TRUE));
+ $this->drupalGet($GLOBALS['base_root'] . parse_url($this->getUrl())['path'] . $elements[0]['href'], ['external' => TRUE]);
$this->assertPagerItems($current_page);
}
@@ -75,16 +75,16 @@ class PagerTest extends WebTestBase {
$this->assertCacheContext('url.query_args');
// Go to last page, the count of pager calls need to go to 1.
- $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--last'));
+ $elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--last']);
$this->drupalGet($this->getAbsoluteUrl($elements[0]['href']));
$this->assertText(t('Pager calls: 1'), 'First link call to pager shows 1 calls.');
$this->assertText('[url.query_args.pagers:0]=0.60');
$this->assertCacheContext('url.query_args');
// Go back to first page, the count of pager calls need to go to 2.
- $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--first'));
+ $elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--first']);
$this->drupalGet($this->getAbsoluteUrl($elements[0]['href']));
- $this->drupalGet($GLOBALS['base_root'] . parse_url($this->getUrl())['path'] . $elements[0]['href'], array('external' => TRUE));
+ $this->drupalGet($GLOBALS['base_root'] . parse_url($this->getUrl())['path'] . $elements[0]['href'], ['external' => TRUE]);
$this->assertText(t('Pager calls: 2'), 'Second link call to pager shows 2 calls.');
$this->assertText('[url.query_args.pagers:0]=0.0');
$this->assertCacheContext('url.query_args');
@@ -203,7 +203,7 @@ class PagerTest extends WebTestBase {
* The current pager page the internal browser is on.
*/
protected function assertPagerItems($current_page) {
- $elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
+ $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Pager found.');
// Make current page 1-based.
diff --git a/core/modules/system/src/Tests/Path/UrlAliasFixtures.php b/core/modules/system/src/Tests/Path/UrlAliasFixtures.php
index a527fc5fc56..71cd736380e 100644
--- a/core/modules/system/src/Tests/Path/UrlAliasFixtures.php
+++ b/core/modules/system/src/Tests/Path/UrlAliasFixtures.php
@@ -47,28 +47,28 @@ class UrlAliasFixtures {
* @return array of URL alias definitions.
*/
public function sampleUrlAliases() {
- return array(
- array(
+ return [
+ [
'source' => '/node/1',
'alias' => '/alias_for_node_1_en',
'langcode' => 'en'
- ),
- array(
+ ],
+ [
'source' => '/node/2',
'alias' => '/alias_for_node_2_en',
'langcode' => 'en'
- ),
- array(
+ ],
+ [
'source' => '/node/1',
'alias' => '/alias_for_node_1_fr',
'langcode' => 'fr'
- ),
- array(
+ ],
+ [
'source' => '/node/1',
'alias' => '/alias_for_node_1_und',
'langcode' => 'und'
- )
- );
+ ]
+ ];
}
@@ -79,7 +79,7 @@ class UrlAliasFixtures {
* Table definitions.
*/
public function tableDefinition() {
- $tables = array();
+ $tables = [];
// Prime the drupal_get_filename() cache with the location of the system
// module as its location is known and shouldn't change.
diff --git a/core/modules/system/src/Tests/Routing/MockAliasManager.php b/core/modules/system/src/Tests/Routing/MockAliasManager.php
index 7c7920f4afd..09f36366fc6 100644
--- a/core/modules/system/src/Tests/Routing/MockAliasManager.php
+++ b/core/modules/system/src/Tests/Routing/MockAliasManager.php
@@ -14,21 +14,21 @@ class MockAliasManager implements AliasManagerInterface {
*
* @var array
*/
- protected $aliases = array();
+ protected $aliases = [];
/**
* Array of mocked aliases. Keys are aliases, followed by language.
*
* @var array
*/
- protected $systemPaths = array();
+ protected $systemPaths = [];
/**
* An index of aliases that have been requested.
*
* @var array
*/
- protected $lookedUp = array();
+ protected $lookedUp = [];
/**
* The language to assume a path alias is for if not specified.
diff --git a/core/modules/system/src/Tests/Routing/MockRouteProvider.php b/core/modules/system/src/Tests/Routing/MockRouteProvider.php
index 689fc06806f..37f8812225a 100644
--- a/core/modules/system/src/Tests/Routing/MockRouteProvider.php
+++ b/core/modules/system/src/Tests/Routing/MockRouteProvider.php
@@ -43,7 +43,7 @@ class MockRouteProvider implements RouteProviderInterface {
* {@inheritdoc}
*/
public function getRouteByName($name) {
- $routes = $this->getRoutesByNames(array($name));
+ $routes = $this->getRoutesByNames([$name]);
if (empty($routes)) {
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
}
@@ -62,7 +62,7 @@ class MockRouteProvider implements RouteProviderInterface {
* {@inheritdoc}
*/
public function getRoutesByNames($names) {
- $routes = array();
+ $routes = [];
foreach ($names as $name) {
$routes[] = $this->routes->get($name);
}
@@ -88,7 +88,7 @@ class MockRouteProvider implements RouteProviderInterface {
* {@inheritdoc}
*/
public function reset() {
- $this->routes = array();
+ $this->routes = [];
}
}
diff --git a/core/modules/system/src/Tests/Routing/RouterTest.php b/core/modules/system/src/Tests/Routing/RouterTest.php
index 8ff515436d9..38d7ecbe04c 100644
--- a/core/modules/system/src/Tests/Routing/RouterTest.php
+++ b/core/modules/system/src/Tests/Routing/RouterTest.php
@@ -21,7 +21,7 @@ class RouterTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('router_test');
+ public static $modules = ['router_test'];
/**
* Confirms that our FinishResponseSubscriber logic works properly.
@@ -133,7 +133,7 @@ class RouterTest extends WebTestBase {
*/
public function testControllerPlaceholders() {
// Test with 0 and a random value.
- $values = array("0", $this->randomMachineName());
+ $values = ["0", $this->randomMachineName()];
foreach ($values as $value) {
$this->drupalGet('router_test/test3/' . $value);
$this->assertResponse(200);
@@ -289,7 +289,7 @@ class RouterTest extends WebTestBase {
* Tests that routes no longer exist for a module that has been uninstalled.
*/
public function testRouterUninstallInstall() {
- \Drupal::service('module_installer')->uninstall(array('router_test'));
+ \Drupal::service('module_installer')->uninstall(['router_test']);
\Drupal::service('router.builder')->rebuild();
try {
\Drupal::service('router.route_provider')->getRouteByName('router_test.1');
@@ -299,7 +299,7 @@ class RouterTest extends WebTestBase {
$this->pass('Route was delete on uninstall.');
}
// Install the module again.
- \Drupal::service('module_installer')->install(array('router_test'));
+ \Drupal::service('module_installer')->install(['router_test']);
\Drupal::service('router.builder')->rebuild();
$route = \Drupal::service('router.route_provider')->getRouteByName('router_test.1');
$this->assertNotNull($route, 'Route exists after module installation');
diff --git a/core/modules/system/src/Tests/Session/SessionHttpsTest.php b/core/modules/system/src/Tests/Session/SessionHttpsTest.php
index 8e25fd26357..6ba70da52bb 100644
--- a/core/modules/system/src/Tests/Session/SessionHttpsTest.php
+++ b/core/modules/system/src/Tests/Session/SessionHttpsTest.php
@@ -33,7 +33,7 @@ class SessionHttpsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('session_test');
+ public static $modules = ['session_test'];
protected function setUp() {
parent::setUp();
@@ -50,7 +50,7 @@ class SessionHttpsTest extends WebTestBase {
}
public function testHttpsSession() {
- $user = $this->drupalCreateUser(array('access administration pages'));
+ $user = $this->drupalCreateUser(['access administration pages']);
// Test HTTPS session handling by altering the form action to submit the
// login form through https.php, which creates a mock HTTPS request.
@@ -58,7 +58,7 @@ class SessionHttpsTest extends WebTestBase {
// Test a second concurrent session.
$this->curlClose();
- $this->curlCookies = array();
+ $this->curlCookies = [];
$this->loginHttps($user);
// Check secure cookie on secure page.
@@ -80,7 +80,7 @@ class SessionHttpsTest extends WebTestBase {
// Verify that empty SID cannot be used on the non-secure site.
$this->curlClose();
- $this->curlCookies = array($this->insecureSessionName . '=');
+ $this->curlCookies = [$this->insecureSessionName . '='];
$this->drupalGet($this->httpUrl('admin/config'));
$this->assertResponse(403);
@@ -88,7 +88,7 @@ class SessionHttpsTest extends WebTestBase {
// login form through http.php, which creates a mock HTTP request on HTTPS
// test environments.
$this->curlClose();
- $this->curlCookies = array();
+ $this->curlCookies = [];
$this->loginHttp($user);
$this->drupalGet($this->httpUrl('admin/config'));
$this->assertResponse(200);
@@ -97,12 +97,12 @@ class SessionHttpsTest extends WebTestBase {
// Verify that empty secure SID cannot be used on the secure site.
$this->curlClose();
- $this->curlCookies = array($this->secureSessionName . '=');
+ $this->curlCookies = [$this->secureSessionName . '='];
$this->drupalGet($this->httpsUrl('admin/config'));
$this->assertResponse(403);
// Clear browser cookie jar.
- $this->cookies = array();
+ $this->cookies = [];
}
/**
@@ -117,7 +117,7 @@ class SessionHttpsTest extends WebTestBase {
// creates a mock HTTP request on HTTPS test environments.
$form = $this->xpath('//form[@id="user-login-form"]');
$form[0]['action'] = $this->httpUrl('user/login');
- $edit = array('name' => $account->getUsername(), 'pass' => $account->pass_raw);
+ $edit = ['name' => $account->getUsername(), 'pass' => $account->pass_raw];
// When posting directly to the HTTP or HTTPS mock front controller, the
// location header on the returned response is an absolute URL. That URL
@@ -148,7 +148,7 @@ class SessionHttpsTest extends WebTestBase {
// creates a mock HTTPS request on HTTP test environments.
$form = $this->xpath('//form[@id="user-login-form"]');
$form[0]['action'] = $this->httpsUrl('user/login');
- $edit = array('name' => $account->getUsername(), 'pass' => $account->pass_raw);
+ $edit = ['name' => $account->getUsername(), 'pass' => $account->pass_raw];
// When posting directly to the HTTP or HTTPS mock front controller, the
// location header on the returned response is an absolute URL. That URL
@@ -168,7 +168,7 @@ class SessionHttpsTest extends WebTestBase {
// necessary to manually collect the session cookie and add it to the
// curlCookies property such that it will be used on subsequent requests via
// the HTTPS mock.
- $this->curlCookies = array($this->secureSessionName . '=' . $this->cookies[$this->secureSessionName]['value']);
+ $this->curlCookies = [$this->secureSessionName . '=' . $this->cookies[$this->secureSessionName]['value']];
// Follow the location header.
$path = $this->getPathFromLocationHeader(TRUE);
@@ -215,9 +215,9 @@ class SessionHttpsTest extends WebTestBase {
* has the given insecure and secure session IDs.
*/
protected function assertSessionIds($sid, $assertion_text) {
- $args = array(
+ $args = [
':sid' => Crypt::hashBase64($sid),
- );
+ ];
return $this->assertTrue(db_query('SELECT timestamp FROM {sessions} WHERE sid = :sid', $args)->fetchField(), $assertion_text);
}
diff --git a/core/modules/system/src/Tests/Session/SessionTest.php b/core/modules/system/src/Tests/Session/SessionTest.php
index 139fba517f4..9b2dc88aa7d 100644
--- a/core/modules/system/src/Tests/Session/SessionTest.php
+++ b/core/modules/system/src/Tests/Session/SessionTest.php
@@ -16,7 +16,7 @@ class SessionTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('session_test');
+ public static $modules = ['session_test'];
protected $dumpHeaders = TRUE;
@@ -48,24 +48,24 @@ class SessionTest extends WebTestBase {
$user->name = 'session_test_user';
$user->save();
$this->drupalGet('session-test/id');
- $matches = array();
+ $matches = [];
preg_match('/\s*session_id:(.*)\n/', $this->getRawContent(), $matches);
$this->assertTrue(!empty($matches[1]), 'Found session ID before logging in.');
$original_session = $matches[1];
// We cannot use $this->drupalLogin($user); because we exit in
// session_test_user_login() which breaks a normal assertion.
- $edit = array(
+ $edit = [
'name' => $user->getUsername(),
'pass' => $user->pass_raw
- );
+ ];
$this->drupalPostForm('user/login', $edit, t('Log in'));
$this->drupalGet('user');
- $pass = $this->assertText($user->getUsername(), format_string('Found name: %name', array('%name' => $user->getUsername())), 'User login');
+ $pass = $this->assertText($user->getUsername(), format_string('Found name: %name', ['%name' => $user->getUsername()]), 'User login');
$this->_logged_in = $pass;
$this->drupalGet('session-test/id');
- $matches = array();
+ $matches = [];
preg_match('/\s*session_id:(.*)\n/', $this->getRawContent(), $matches);
$this->assertTrue(!empty($matches[1]), 'Found session ID after logging in.');
$this->assertTrue($matches[1] != $original_session, 'Session ID changed after login.');
@@ -75,7 +75,7 @@ class SessionTest extends WebTestBase {
* Test data persistence via the session_test module callbacks.
*/
function testDataPersistence() {
- $user = $this->drupalCreateUser(array());
+ $user = $this->drupalCreateUser([]);
// Enable sessions.
$this->sessionReset($user->id());
@@ -127,7 +127,7 @@ class SessionTest extends WebTestBase {
$this->assertNoText($value_1, 'Session has persisted for an authenticated user after logging out and then back in.', 'Session');
// Change session and create another user.
- $user2 = $this->drupalCreateUser(array());
+ $user2 = $this->drupalCreateUser([]);
$this->sessionReset($user2->id());
$this->drupalLogin($user2);
}
@@ -211,11 +211,11 @@ class SessionTest extends WebTestBase {
* Test that sessions are only saved when necessary.
*/
function testSessionWrite() {
- $user = $this->drupalCreateUser(array());
+ $user = $this->drupalCreateUser([]);
$this->drupalLogin($user);
$sql = 'SELECT u.access, s.timestamp FROM {users_field_data} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE u.uid = :uid';
- $times1 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
+ $times1 = db_query($sql, [':uid' => $user->id()])->fetchObject();
// Before every request we sleep one second to make sure that if the session
// is saved, its timestamp will change.
@@ -223,34 +223,34 @@ class SessionTest extends WebTestBase {
// Modify the session.
sleep(1);
$this->drupalGet('session-test/set/foo');
- $times2 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
+ $times2 = db_query($sql, [':uid' => $user->id()])->fetchObject();
$this->assertEqual($times2->access, $times1->access, 'Users table was not updated.');
$this->assertNotEqual($times2->timestamp, $times1->timestamp, 'Sessions table was updated.');
// Write the same value again, i.e. do not modify the session.
sleep(1);
$this->drupalGet('session-test/set/foo');
- $times3 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
+ $times3 = db_query($sql, [':uid' => $user->id()])->fetchObject();
$this->assertEqual($times3->access, $times1->access, 'Users table was not updated.');
$this->assertEqual($times3->timestamp, $times2->timestamp, 'Sessions table was not updated.');
// Do not change the session.
sleep(1);
$this->drupalGet('');
- $times4 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
+ $times4 = db_query($sql, [':uid' => $user->id()])->fetchObject();
$this->assertEqual($times4->access, $times3->access, 'Users table was not updated.');
$this->assertEqual($times4->timestamp, $times3->timestamp, 'Sessions table was not updated.');
// Force updating of users and sessions table once per second.
$this->settingsSet('session_write_interval', 0);
// Write that value also into the test settings.php file.
- $settings['settings']['session_write_interval'] = (object) array(
+ $settings['settings']['session_write_interval'] = (object) [
'value' => 0,
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
$this->drupalGet('');
- $times5 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
+ $times5 = db_query($sql, [':uid' => $user->id()])->fetchObject();
$this->assertNotEqual($times5->access, $times4->access, 'Users table was updated.');
$this->assertNotEqual($times5->timestamp, $times4->timestamp, 'Sessions table was updated.');
}
@@ -259,14 +259,14 @@ class SessionTest extends WebTestBase {
* Test that empty session IDs are not allowed.
*/
function testEmptySessionID() {
- $user = $this->drupalCreateUser(array());
+ $user = $this->drupalCreateUser([]);
$this->drupalLogin($user);
$this->drupalGet('session-test/is-logged-in');
$this->assertResponse(200, 'User is logged in.');
// Reset the sid in {sessions} to a blank string. This may exist in the
// wild in some cases, although we normally prevent it from happening.
- db_query("UPDATE {sessions} SET sid = '' WHERE uid = :uid", array(':uid' => $user->id()));
+ db_query("UPDATE {sessions} SET sid = '' WHERE uid = :uid", [':uid' => $user->id()]);
// Send a blank sid in the session cookie, and the session should no longer
// be valid. Closing the curl handler will stop the previous session ID
// from persisting.
diff --git a/core/modules/system/src/Tests/Session/StackSessionHandlerIntegrationTest.php b/core/modules/system/src/Tests/Session/StackSessionHandlerIntegrationTest.php
index af962fa5cda..ac368685db0 100644
--- a/core/modules/system/src/Tests/Session/StackSessionHandlerIntegrationTest.php
+++ b/core/modules/system/src/Tests/Session/StackSessionHandlerIntegrationTest.php
@@ -16,7 +16,7 @@ class StackSessionHandlerIntegrationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('session_test');
+ public static $modules = ['session_test'];
/**
* Tests a request.
diff --git a/core/modules/system/src/Tests/System/AccessDeniedTest.php b/core/modules/system/src/Tests/System/AccessDeniedTest.php
index e7f17d78b36..f06cf1f0f8b 100644
--- a/core/modules/system/src/Tests/System/AccessDeniedTest.php
+++ b/core/modules/system/src/Tests/System/AccessDeniedTest.php
@@ -32,8 +32,8 @@ class AccessDeniedTest extends WebTestBase {
$this->adminUser->roles[] = 'administrator';
$this->adminUser->save();
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user profiles'));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access user profiles'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access user profiles']);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access user profiles']);
}
function testAccessDenied() {
@@ -65,7 +65,7 @@ class AccessDeniedTest extends WebTestBase {
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
// Enable the user login block.
- $block = $this->drupalPlaceBlock('user_login_block', array('id' => 'login'));
+ $block = $this->drupalPlaceBlock('user_login_block', ['id' => 'login']);
// Log out and check that the user login block is shown on custom 403 pages.
$this->drupalLogout();
@@ -94,10 +94,10 @@ class AccessDeniedTest extends WebTestBase {
// Check that we can log in from the 403 page.
$this->drupalLogout();
- $edit = array(
+ $edit = [
'name' => $this->adminUser->getUsername(),
'pass' => $this->adminUser->pass_raw,
- );
+ ];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Log in'));
// Check that we're still on the same page.
diff --git a/core/modules/system/src/Tests/System/AdminTest.php b/core/modules/system/src/Tests/System/AdminTest.php
index 8921ad0a871..222a4027797 100644
--- a/core/modules/system/src/Tests/System/AdminTest.php
+++ b/core/modules/system/src/Tests/System/AdminTest.php
@@ -31,7 +31,7 @@ class AdminTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('locale');
+ public static $modules = ['locale'];
protected function setUp() {
// testAdminPages() requires Locale module.
@@ -41,10 +41,10 @@ class AdminTest extends WebTestBase {
// who can only access administration pages and perform some Locale module
// administrative tasks, but not all of them.
$this->adminUser = $this->drupalCreateUser(array_keys(\Drupal::service('user.permissions')->getPermissions()));
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'access administration pages',
'translate interface',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
}
@@ -69,11 +69,11 @@ class AdminTest extends WebTestBase {
// but no links to its individual sub-configuration pages. Also verify that
// a user with access to only some Locale module administration pages only
// sees links to the pages they have access to.
- $admin_list_pages = array(
+ $admin_list_pages = [
'admin/index',
'admin/config',
'admin/config/regional',
- );
+ ];
foreach ($admin_list_pages as $page) {
// For the administrator, verify that there are links to Locale's primary
@@ -125,14 +125,14 @@ class AdminTest extends WebTestBase {
$parameters = new MenuTreeParameters();
$parameters->setRoot('system.admin')->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
$tree = $menu_tree->load(NULL, $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:flatten'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:flatten'],
+ ];
$tree = $menu_tree->transform($tree, $manipulators);
// Transform the tree to a list of menu links.
- $menu_links = array();
+ $menu_links = [];
foreach ($tree as $element) {
$menu_links[] = $element->link;
}
@@ -151,7 +151,7 @@ class AdminTest extends WebTestBase {
$this->drupalGet('admin/compact/on');
$this->assertResponse(200, 'A valid page is returned after turning on compact mode.');
- $this->assertUrl($frontpage_url, array(), 'The user is redirected to the front page after turning on compact mode.');
+ $this->assertUrl($frontpage_url, [], 'The user is redirected to the front page after turning on compact mode.');
$this->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode turns on.');
$this->drupalGet('admin/compact/on');
$this->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode remains on after a repeat call.');
@@ -160,7 +160,7 @@ class AdminTest extends WebTestBase {
$this->drupalGet('admin/compact/off');
$this->assertResponse(200, 'A valid page is returned after turning off compact mode.');
- $this->assertUrl($frontpage_url, array(), 'The user is redirected to the front page after turning off compact mode.');
+ $this->assertUrl($frontpage_url, [], 'The user is redirected to the front page after turning off compact mode.');
$this->assertEqual($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'deleted', 'Compact mode turns off.');
$this->drupalGet('admin/compact/off');
$this->assertEqual($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'deleted', 'Compact mode remains off after a repeat call.');
diff --git a/core/modules/system/src/Tests/System/CronRunTest.php b/core/modules/system/src/Tests/System/CronRunTest.php
index 26a56a32c11..d11a51616cf 100644
--- a/core/modules/system/src/Tests/System/CronRunTest.php
+++ b/core/modules/system/src/Tests/System/CronRunTest.php
@@ -47,7 +47,7 @@ class CronRunTest extends WebTestBase {
// Test with a logged in user; anonymous users likely don't cause Drupal to
// fully bootstrap, because of the internal page cache or an external
// reverse proxy. Reuse this user for disabling cron later in the test.
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
// Ensure cron does not run when a non-zero cron interval is specified and
@@ -97,7 +97,7 @@ class CronRunTest extends WebTestBase {
* Make sure the cron UI reads from the state storage.
*/
function testCronUI() {
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/config/system/cron');
// Don't use REQUEST to calculate the exact time, because that will
@@ -114,7 +114,7 @@ class CronRunTest extends WebTestBase {
* Ensure that the manual cron run is working.
*/
public function testManualCron() {
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/reports/status/run-cron');
diff --git a/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php b/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php
index 98d82d36b9d..3edfb7bb769 100644
--- a/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php
+++ b/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php
@@ -20,9 +20,9 @@ class DefaultMobileMetaTagsTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->defaultMetaTags = array(
+ $this->defaultMetaTags = [
'viewport' => '<meta name="viewport" content="width=device-width, initial-scale=1.0" />',
- );
+ ];
}
/**
@@ -31,7 +31,7 @@ class DefaultMobileMetaTagsTest extends WebTestBase {
public function testDefaultMetaTagsExist() {
$this->drupalGet('');
foreach ($this->defaultMetaTags as $name => $metatag) {
- $this->assertRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" displayed properly.', array('@name' => $name)), 'System');
+ $this->assertRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" displayed properly.', ['@name' => $name]), 'System');
}
}
@@ -39,10 +39,10 @@ class DefaultMobileMetaTagsTest extends WebTestBase {
* Verifies that the default mobile meta tags can be removed.
*/
public function testRemovingDefaultMetaTags() {
- \Drupal::service('module_installer')->install(array('system_module_test'));
+ \Drupal::service('module_installer')->install(['system_module_test']);
$this->drupalGet('');
foreach ($this->defaultMetaTags as $name => $metatag) {
- $this->assertNoRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" removed properly.', array('@name' => $name)), 'System');
+ $this->assertNoRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" removed properly.', ['@name' => $name]), 'System');
}
}
diff --git a/core/modules/system/src/Tests/System/ErrorHandlerTest.php b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
index 113d4955170..e2a7eb5f99d 100644
--- a/core/modules/system/src/Tests/System/ErrorHandlerTest.php
+++ b/core/modules/system/src/Tests/System/ErrorHandlerTest.php
@@ -17,36 +17,36 @@ class ErrorHandlerTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('error_test');
+ public static $modules = ['error_test'];
/**
* Test the error handler.
*/
function testErrorHandler() {
$config = $this->config('system.logging');
- $error_notice = array(
+ $error_notice = [
'%type' => 'Notice',
'@message' => 'Undefined variable: bananas',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->generateWarnings()',
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
- );
- $error_warning = array(
+ ];
+ $error_warning = [
'%type' => 'Warning',
'@message' => 'Division by zero',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->generateWarnings()',
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
- );
- $error_user_notice = array(
+ ];
+ $error_user_notice = [
'%type' => 'User warning',
'@message' => 'Drupal & awesome',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->generateWarnings()',
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
- );
- $fatal_error = array(
+ ];
+ $fatal_error = [
'%type' => 'Recoverable fatal error',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
'@message' => 'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 62 and defined',
- );
+ ];
if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0) {
// In PHP 7, instead of a recoverable fatal error we get a TypeError.
$fatal_error['%type'] = 'TypeError';
@@ -125,27 +125,27 @@ class ErrorHandlerTest extends WebTestBase {
// Ensure the test error log is empty before these tests.
$this->assertNoErrorsLogged();
- $error_exception = array(
+ $error_exception = [
'%type' => 'Exception',
'@message' => 'Drupal & awesome',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->triggerException()',
'%line' => 56,
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
- );
- $error_pdo_exception = array(
+ ];
+ $error_pdo_exception = [
'%type' => 'DatabaseExceptionWrapper',
'@message' => 'SELECT * FROM bananas_are_awesome',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->triggerPDOException()',
'%line' => 64,
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
- );
- $error_renderer_exception = array(
+ ];
+ $error_renderer_exception = [
'%type' => 'Exception',
'@message' => 'This is an exception that occurs during rendering',
'%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
'%line' => 82,
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
- );
+ ];
$this->drupalGet('error-test/trigger-exception');
$this->assertTrue(strpos($this->drupalGetHeader(':status'), '500 Service unavailable (with message)'), 'Received expected HTTP status line.');
@@ -158,7 +158,7 @@ class ErrorHandlerTest extends WebTestBase {
$this->assertText($error_pdo_exception['%type'], format_string('Found %type in error page.', $error_pdo_exception));
$this->assertText($error_pdo_exception['@message'], format_string('Found @message in error page.', $error_pdo_exception));
$error_details = format_string('in %function (line ', $error_pdo_exception);
- $this->assertRaw($error_details, format_string("Found '@message' in error page.", array('@message' => $error_details)));
+ $this->assertRaw($error_details, format_string("Found '@message' in error page.", ['@message' => $error_details]));
$this->drupalGet('error-test/trigger-renderer-exception');
$this->assertTrue(strpos($this->drupalGetHeader(':status'), '500 Service unavailable (with message)'), 'Received expected HTTP status line.');
@@ -185,7 +185,7 @@ class ErrorHandlerTest extends WebTestBase {
*/
function assertErrorMessage(array $error) {
$message = new FormattableMarkup('%type: @message in %function (line ', $error);
- $this->assertRaw($message, format_string('Found error message: @message.', array('@message' => $message)));
+ $this->assertRaw($message, format_string('Found error message: @message.', ['@message' => $message]));
}
/**
@@ -193,7 +193,7 @@ class ErrorHandlerTest extends WebTestBase {
*/
function assertNoErrorMessage(array $error) {
$message = new FormattableMarkup('%type: @message in %function (line ', $error);
- $this->assertNoRaw($message, format_string('Did not find error message: @message.', array('@message' => $message)));
+ $this->assertNoRaw($message, format_string('Did not find error message: @message.', ['@message' => $message]));
}
/**
diff --git a/core/modules/system/src/Tests/System/FrontPageTest.php b/core/modules/system/src/Tests/System/FrontPageTest.php
index 03666fdf1e2..f5782b708b6 100644
--- a/core/modules/system/src/Tests/System/FrontPageTest.php
+++ b/core/modules/system/src/Tests/System/FrontPageTest.php
@@ -17,7 +17,7 @@ class FrontPageTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'system_test', 'views');
+ public static $modules = ['node', 'system_test', 'views'];
/**
* The path to a node that is created for testing.
@@ -30,12 +30,12 @@ class FrontPageTest extends WebTestBase {
parent::setUp();
// Create admin user, log in admin user, and create one node.
- $this->drupalLogin ($this->drupalCreateUser(array(
+ $this->drupalLogin ($this->drupalCreateUser([
'access content',
'administer site configuration',
- )));
- $this->drupalCreateContentType(array('type' => 'page'));
- $this->nodePath = "node/" . $this->drupalCreateNode(array('promote' => 1))->id();
+ ]));
+ $this->drupalCreateContentType(['type' => 'page']);
+ $this->nodePath = "node/" . $this->drupalCreateNode(['promote' => 1])->id();
// Configure 'node' as front page.
$this->config('system.site')->set('page.front', '/node')->save();
@@ -48,10 +48,10 @@ class FrontPageTest extends WebTestBase {
*/
public function testDrupalFrontPage() {
// Create a promoted node to test the <title> tag on the front page view.
- $settings = array(
+ $settings = [
'title' => $this->randomMachineName(8),
'promote' => 1,
- );
+ ];
$this->drupalCreateNode($settings);
$this->drupalGet('');
$this->assertTitle('Home | Drupal');
@@ -63,9 +63,9 @@ class FrontPageTest extends WebTestBase {
$this->assertNoText(t('On front page.'), 'Path is not the front page.');
// Change the front page to an invalid path.
- $edit = array('site_frontpage' => '/kittens');
+ $edit = ['site_frontpage' => '/kittens'];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
- $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $edit['site_frontpage'])));
+ $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", ['@path' => $edit['site_frontpage']]));
// Change the front page to a path without a starting slash.
$edit = ['site_frontpage' => $this->nodePath];
diff --git a/core/modules/system/src/Tests/System/HtaccessTest.php b/core/modules/system/src/Tests/System/HtaccessTest.php
index ad6e09ee596..fab7a37a34d 100644
--- a/core/modules/system/src/Tests/System/HtaccessTest.php
+++ b/core/modules/system/src/Tests/System/HtaccessTest.php
@@ -16,7 +16,7 @@ class HtaccessTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'path');
+ public static $modules = ['node', 'path'];
/**
* Get an array of file paths for access testing.
diff --git a/core/modules/system/src/Tests/System/PageNotFoundTest.php b/core/modules/system/src/Tests/System/PageNotFoundTest.php
index f289f0e405b..d4cd861b88a 100644
--- a/core/modules/system/src/Tests/System/PageNotFoundTest.php
+++ b/core/modules/system/src/Tests/System/PageNotFoundTest.php
@@ -26,12 +26,12 @@ class PageNotFoundTest extends WebTestBase {
parent::setUp();
// Create an administrative user.
- $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'link to any page'));
+ $this->adminUser = $this->drupalCreateUser(['administer site configuration', 'link to any page']);
$this->adminUser->roles[] = 'administrator';
$this->adminUser->save();
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user profiles'));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access user profiles'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access user profiles']);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access user profiles']);
}
function testPageNotFound() {
@@ -47,9 +47,9 @@ class PageNotFoundTest extends WebTestBase {
$this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_404']]));
// Use a custom 404 page.
- $edit = array(
+ $edit = [
'site_404' => '/user/' . $this->adminUser->id(),
- );
+ ];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this->drupalGet($this->randomMachineName(10));
diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php
index 848eacc8c70..213339809d1 100644
--- a/core/modules/system/src/Tests/System/PageTitleTest.php
+++ b/core/modules/system/src/Tests/System/PageTitleTest.php
@@ -29,11 +29,11 @@ class PageTitleTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->drupalPlaceBlock('page_title_block');
- $this->contentUser = $this->drupalCreateUser(array('create page content', 'access content', 'administer themes', 'administer site configuration', 'link to any page'));
+ $this->contentUser = $this->drupalCreateUser(['create page content', 'access content', 'administer themes', 'administer site configuration', 'link to any page']);
$this->drupalLogin($this->contentUser);
}
@@ -43,10 +43,10 @@ class PageTitleTest extends WebTestBase {
function testTitleTags() {
$title = "string with <em>HTML</em>";
// Generate node content.
- $edit = array(
+ $edit = [
'title[0][value]' => '!SimpleTest! ' . $title . $this->randomMachineName(20),
'body[0][value]' => '!SimpleTest! test body' . $this->randomMachineName(200),
- );
+ ];
// Create the node with HTML in the title.
$this->drupalPostForm('node/add/page', $edit, t('Save'));
@@ -69,10 +69,10 @@ class PageTitleTest extends WebTestBase {
$slogan_filtered = Xss::filterAdmin($slogan);
// Set title and slogan.
- $edit = array(
+ $edit = [
'site_name' => $title,
'site_slogan' => $slogan,
- );
+ ];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
// Place branding block with site name and slogan into header region.
@@ -113,9 +113,9 @@ class PageTitleTest extends WebTestBase {
$this->assertEqual('Test dynamic title', (string) $result[0]);
// Set some custom translated strings.
- $this->addCustomTranslations('en', array('' => array(
+ $this->addCustomTranslations('en', ['' => [
'Static title' => 'Static title translated'
- )));
+ ]]);
$this->writeCustomTranslations();
// Ensure that the title got translated.
diff --git a/core/modules/system/src/Tests/System/ResponseGeneratorTest.php b/core/modules/system/src/Tests/System/ResponseGeneratorTest.php
index f54c6516e84..6197d1d40ae 100644
--- a/core/modules/system/src/Tests/System/ResponseGeneratorTest.php
+++ b/core/modules/system/src/Tests/System/ResponseGeneratorTest.php
@@ -16,14 +16,14 @@ class ResponseGeneratorTest extends RESTTestBase {
*
* @var array
*/
- public static $modules = array('hal', 'rest', 'node', 'basic_auth');
+ public static $modules = ['hal', 'rest', 'node', 'basic_auth'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$permissions = $this->entityPermissions('node', 'view');
$account = $this->drupalCreateUser($permissions);
diff --git a/core/modules/system/src/Tests/System/ShutdownFunctionsTest.php b/core/modules/system/src/Tests/System/ShutdownFunctionsTest.php
index 99839abaf48..3a6b3dbf9a2 100644
--- a/core/modules/system/src/Tests/System/ShutdownFunctionsTest.php
+++ b/core/modules/system/src/Tests/System/ShutdownFunctionsTest.php
@@ -16,7 +16,7 @@ class ShutdownFunctionsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('system_test');
+ public static $modules = ['system_test'];
protected function tearDown() {
// This test intentionally throws an exception in a PHP shutdown function.
@@ -42,8 +42,8 @@ class ShutdownFunctionsTest extends WebTestBase {
// We need to wait to ensure that the shutdown functions have fired.
sleep(1);
}
- $this->assertEqual(\Drupal::state()->get('_system_test_first_shutdown_function'), array($arg1, $arg2));
- $this->assertEqual(\Drupal::state()->get('_system_test_second_shutdown_function'), array($arg1, $arg2));
+ $this->assertEqual(\Drupal::state()->get('_system_test_first_shutdown_function'), [$arg1, $arg2]);
+ $this->assertEqual(\Drupal::state()->get('_system_test_second_shutdown_function'), [$arg1, $arg2]);
if (!$server_using_fastcgi) {
// Make sure exceptions displayed through
diff --git a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php
index 84e34921b4c..7f955925db4 100644
--- a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php
+++ b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php
@@ -17,7 +17,7 @@ class SiteMaintenanceTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
protected $adminUser;
@@ -29,9 +29,9 @@ class SiteMaintenanceTest extends WebTestBase {
$this->config('system.performance')->set('js.preprocess', 1)->save();
// Create a user allowed to access site in maintenance mode.
- $this->user = $this->drupalCreateUser(array('access site in maintenance mode'));
+ $this->user = $this->drupalCreateUser(['access site in maintenance mode']);
// Create an administrative user.
- $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access site in maintenance mode'));
+ $this->adminUser = $this->drupalCreateUser(['administer site configuration', 'access site in maintenance mode']);
$this->drupalLogin($this->adminUser);
}
@@ -44,27 +44,27 @@ class SiteMaintenanceTest extends WebTestBase {
$permission_handler = $this->container->get('user.permissions');
$permissions = $permission_handler->getPermissions();
$permission_label = $permissions['access site in maintenance mode']['title'];
- $permission_message = t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array('@permission-label' => $permission_label, ':permissions-url' => \Drupal::url('user.admin_permissions'), ':user-login' => \Drupal::url('user.login')));
+ $permission_message = t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', ['@permission-label' => $permission_label, ':permissions-url' => \Drupal::url('user.admin_permissions'), ':user-login' => \Drupal::url('user.login')]);
$this->drupalGet(Url::fromRoute('system.site_maintenance_mode'));
$this->assertRaw($permission_message, 'Found the permission message.');
$this->drupalGet(Url::fromRoute('user.page'));
// JS should be aggregated, so drupal.js is not in the page source.
- $links = $this->xpath('//script[contains(@src, :href)]', array(':href' => '/core/misc/drupal.js'));
+ $links = $this->xpath('//script[contains(@src, :href)]', [':href' => '/core/misc/drupal.js']);
$this->assertFalse(isset($links[0]), 'script /core/misc/drupal.js not in page');
// Turn on maintenance mode.
- $edit = array(
+ $edit = [
'maintenance_mode' => 1,
- );
+ ];
$this->drupalPostForm('admin/config/development/maintenance', $edit, t('Save configuration'));
- $admin_message = t('Operating in maintenance mode. <a href=":url">Go online.</a>', array(':url' => \Drupal::url('system.site_maintenance_mode')));
+ $admin_message = t('Operating in maintenance mode. <a href=":url">Go online.</a>', [':url' => \Drupal::url('system.site_maintenance_mode')]);
$user_message = t('Operating in maintenance mode.');
- $offline_message = t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => $this->config('system.site')->get('name')));
+ $offline_message = t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', ['@site' => $this->config('system.site')->get('name')]);
$this->drupalGet(Url::fromRoute('user.page'));
// JS should not be aggregated, so drupal.js is expected in the page source.
- $links = $this->xpath('//script[contains(@src, :href)]', array(':href' => '/core/misc/drupal.js'));
+ $links = $this->xpath('//script[contains(@src, :href)]', [':href' => '/core/misc/drupal.js']);
$this->assertTrue(isset($links[0]), 'script /core/misc/drupal.js in page');
$this->assertRaw($admin_message, 'Found the site maintenance mode message.');
@@ -88,10 +88,10 @@ class SiteMaintenanceTest extends WebTestBase {
// Log in user and verify that maintenance mode message is displayed
// directly after login.
- $edit = array(
+ $edit = [
'name' => $this->user->getUsername(),
'pass' => $this->user->pass_raw,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Log in'));
$this->assertText($user_message);
@@ -102,9 +102,9 @@ class SiteMaintenanceTest extends WebTestBase {
$this->assertNoRaw($admin_message, 'Site maintenance mode message not displayed.');
$offline_message = 'Sorry, not online.';
- $edit = array(
+ $edit = [
'maintenance_mode_message' => $offline_message,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
// Logout and verify that custom site offline message is displayed.
@@ -118,20 +118,20 @@ class SiteMaintenanceTest extends WebTestBase {
$this->assertText(t('Username or email address'), 'Anonymous users can access user/password');
// Submit password reset form.
- $edit = array(
+ $edit = [
'name' => $this->user->getUsername(),
- );
+ ];
$this->drupalPostForm('user/password', $edit, t('Submit'));
$mails = $this->drupalGetMails();
$start = strpos($mails[0]['body'], 'user/reset/' . $this->user->id());
$path = substr($mails[0]['body'], $start, 66 + strlen($this->user->id()));
// Log in with temporary login link.
- $this->drupalPostForm($path, array(), t('Log in'));
+ $this->drupalPostForm($path, [], t('Log in'));
$this->assertText($user_message);
// Regression test to check if title displays in Bartik on maintenance page.
- \Drupal::service('theme_handler')->install(array('bartik'));
+ \Drupal::service('theme_handler')->install(['bartik']);
$this->config('system.theme')->set('default', 'bartik')->save();
// Logout and verify that offline message is displayed in Bartik.
diff --git a/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php b/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php
index 08f741d8c24..a14fd3107e0 100644
--- a/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php
+++ b/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php
@@ -43,7 +43,7 @@ abstract class SystemConfigFormTestBase extends WebTestBase {
*/
public function testConfigForm() {
// Programmatically submit the given values.
- $values = array();
+ $values = [];
foreach ($this->values as $form_key => $data) {
$values[$form_key] = $data['#value'];
}
@@ -53,10 +53,10 @@ abstract class SystemConfigFormTestBase extends WebTestBase {
// Check that the form returns an error when expected, and vice versa.
$errors = $form_state->getErrors();
$valid_form = empty($errors);
- $args = array(
+ $args = [
'%values' => print_r($values, TRUE),
'%errors' => $valid_form ? t('None') : implode(' ', $errors),
- );
+ ];
$this->assertTrue($valid_form, format_string('Input values: %values<br/>Validation handler errors: %errors', $args));
foreach ($this->values as $data) {
diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php
index 667c97a5220..b75ede9a211 100644
--- a/core/modules/system/src/Tests/System/ThemeTest.php
+++ b/core/modules/system/src/Tests/System/ThemeTest.php
@@ -30,9 +30,9 @@ class ThemeTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks']);
$this->drupalLogin($this->adminUser);
$this->node = $this->drupalCreateNode();
$this->drupalPlaceBlock('local_tasks_block');
@@ -53,50 +53,50 @@ class ThemeTest extends WebTestBase {
// Specify a filesystem path to be used for the logo.
$file = current($this->drupalGetTestFiles('image'));
- $file_relative = strtr($file->uri, array('public:/' => PublicStream::basePath()));
+ $file_relative = strtr($file->uri, ['public:/' => PublicStream::basePath()]);
$default_theme_path = 'core/themes/classy';
- $supported_paths = array(
+ $supported_paths = [
// Raw stream wrapper URI.
- $file->uri => array(
+ $file->uri => [
'form' => file_uri_target($file->uri),
'src' => file_url_transform_relative(file_create_url($file->uri)),
- ),
+ ],
// Relative path within the public filesystem.
- file_uri_target($file->uri) => array(
+ file_uri_target($file->uri) => [
'form' => file_uri_target($file->uri),
'src' => file_url_transform_relative(file_create_url($file->uri)),
- ),
+ ],
// Relative path to a public file.
- $file_relative => array(
+ $file_relative => [
'form' => $file_relative,
'src' => file_url_transform_relative(file_create_url($file->uri)),
- ),
+ ],
// Relative path to an arbitrary file.
- 'core/misc/druplicon.png' => array(
+ 'core/misc/druplicon.png' => [
'form' => 'core/misc/druplicon.png',
'src' => base_path() . 'core/misc/druplicon.png',
- ),
+ ],
// Relative path to a file in a theme.
- $default_theme_path . '/logo.svg' => array(
+ $default_theme_path . '/logo.svg' => [
'form' => $default_theme_path . '/logo.svg',
'src' => base_path() . $default_theme_path . '/logo.svg',
- ),
- );
+ ],
+ ];
foreach ($supported_paths as $input => $expected) {
- $edit = array(
+ $edit = [
'default_logo' => FALSE,
'logo_path' => $input,
- );
+ ];
$this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
$this->assertNoText('The custom logo path is invalid.');
$this->assertFieldByName('logo_path', $expected['form']);
// Verify logo path examples.
- $elements = $this->xpath('//div[contains(@class, :item)]/div[@class=:description]/code', array(
+ $elements = $this->xpath('//div[contains(@class, :item)]/div[@class=:description]/code', [
':item' => 'js-form-item-logo-path',
':description' => 'description',
- ));
+ ]);
// Expected default values (if all else fails).
$implicit_public_file = 'logo.svg';
$explicit_file = 'public://logo.svg';
@@ -105,7 +105,7 @@ class ThemeTest extends WebTestBase {
if (file_uri_scheme($input) == 'public') {
$implicit_public_file = file_uri_target($input);
$explicit_file = $input;
- $local_file = strtr($input, array('public:/' => PublicStream::basePath()));
+ $local_file = strtr($input, ['public:/' => PublicStream::basePath()]);
}
// Adjust for fully qualified stream wrapper URI elsewhere.
elseif (file_uri_scheme($input) !== FALSE) {
@@ -125,13 +125,13 @@ class ThemeTest extends WebTestBase {
// branding block.
$this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
$this->drupalGet('');
- $elements = $this->xpath('//header//a[@rel=:rel]/img', array(
+ $elements = $this->xpath('//header//a[@rel=:rel]/img', [
':rel' => 'home',
- )
+ ]
);
$this->assertEqual((string) $elements[0]['src'], $expected['src']);
}
- $unsupported_paths = array(
+ $unsupported_paths = [
// Stream wrapper URI to non-existing file.
'public://whatever.png',
'private://whatever.png',
@@ -153,23 +153,23 @@ class ThemeTest extends WebTestBase {
'/core/misc/whatever.png',
// Absolute paths to any local file (even if it exists).
drupal_realpath($file->uri),
- );
+ ];
$this->drupalGet('admin/appearance/settings');
foreach ($unsupported_paths as $path) {
- $edit = array(
+ $edit = [
'default_logo' => FALSE,
'logo_path' => $path,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertText('The custom logo path is invalid.');
}
// Upload a file to use for the logo.
- $edit = array(
+ $edit = [
'default_logo' => FALSE,
'logo_path' => '',
'files[logo_upload]' => drupal_realpath($file->uri),
- );
+ ];
$this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
$fields = $this->xpath($this->constructFieldXpath('name', 'logo_path'));
@@ -177,13 +177,13 @@ class ThemeTest extends WebTestBase {
$this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
$this->drupalGet('');
- $elements = $this->xpath('//header//a[@rel=:rel]/img', array(
+ $elements = $this->xpath('//header//a[@rel=:rel]/img', [
':rel' => 'home',
- )
+ ]
);
$this->assertEqual($elements[0]['src'], file_url_transform_relative(file_create_url($uploaded_filename)));
- $this->container->get('theme_handler')->install(array('bartik'));
+ $this->container->get('theme_handler')->install(['bartik']);
// Ensure only valid themes are listed in the local tasks.
$this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']);
@@ -242,13 +242,13 @@ class ThemeTest extends WebTestBase {
* Test the administration theme functionality.
*/
function testAdministrationTheme() {
- $this->container->get('theme_handler')->install(array('seven'));
+ $this->container->get('theme_handler')->install(['seven']);
// Install an administration theme and show it on the node admin pages.
- $edit = array(
+ $edit = [
'admin_theme' => 'seven',
'use_admin_theme' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('admin/config');
@@ -264,9 +264,9 @@ class ThemeTest extends WebTestBase {
$this->assertRaw('core/themes/seven', 'Administration theme used on the edit content page.');
// Disable the admin theme on the node admin pages.
- $edit = array(
+ $edit = [
'use_admin_theme' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('admin/config');
@@ -284,10 +284,10 @@ class ThemeTest extends WebTestBase {
$this->assertRaw('core/themes/classy', 'Site default theme used on the add content page.');
// Reset to the default theme settings.
- $edit = array(
+ $edit = [
'admin_theme' => '0',
'use_admin_theme' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('admin');
@@ -304,11 +304,11 @@ class ThemeTest extends WebTestBase {
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
$theme_handler = \Drupal::service('theme_handler');
// First, install Stark and set it as the default theme programmatically.
- $theme_handler->install(array('stark'));
+ $theme_handler->install(['stark']);
$this->config('system.theme')->set('default', 'stark')->save();
// Install Bartik and set it as the default theme.
- $theme_handler->install(array('bartik'));
+ $theme_handler->install(['bartik']);
$this->drupalGet('admin/appearance');
$this->clickLink(t('Set as default'));
$this->assertEqual($this->config('system.theme')->get('default'), 'bartik');
@@ -332,13 +332,13 @@ class ThemeTest extends WebTestBase {
*/
function testInvalidTheme() {
// theme_page_test_system_info_alter() un-hides all hidden themes.
- $this->container->get('module_installer')->install(array('theme_page_test'));
+ $this->container->get('module_installer')->install(['theme_page_test']);
// Clear the system_list() and theme listing cache to pick up the change.
$this->container->get('theme_handler')->reset();
$this->drupalGet('admin/appearance');
- $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'not_real_test_basetheme')));
- $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'test_invalid_basetheme')));
- $this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => 'not_real_engine')));
+ $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', ['@base_theme' => 'not_real_test_basetheme']));
+ $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', ['@base_theme' => 'test_invalid_basetheme']));
+ $this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', ['@theme_engine' => 'not_real_engine']));
// Check for the error text of a theme with the wrong core version.
$this->assertText("This theme is not compatible with Drupal 8.x. Check that the .info.yml file contains the correct 'core' value.");
// Check for the error text of a theme without a content region.
@@ -350,13 +350,13 @@ class ThemeTest extends WebTestBase {
*/
function testUninstallingThemes() {
// Install Bartik and set it as the default theme.
- \Drupal::service('theme_handler')->install(array('bartik'));
+ \Drupal::service('theme_handler')->install(['bartik']);
// Set up seven as the admin theme.
- \Drupal::service('theme_handler')->install(array('seven'));
- $edit = array(
+ \Drupal::service('theme_handler')->install(['seven']);
+ $edit = [
'admin_theme' => 'seven',
'use_admin_theme' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this->drupalGet('admin/appearance');
$this->clickLink(t('Set as default'));
@@ -370,12 +370,12 @@ class ThemeTest extends WebTestBase {
$this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
// Install Stark and set it as the default theme.
- \Drupal::service('theme_handler')->install(array('stark'));
+ \Drupal::service('theme_handler')->install(['stark']);
- $edit = array(
+ $edit = [
'admin_theme' => 'stark',
'use_admin_theme' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
// Check that seven can be uninstalled now.
diff --git a/core/modules/system/src/Tests/System/UncaughtExceptionTest.php b/core/modules/system/src/Tests/System/UncaughtExceptionTest.php
index c3ef82dceb1..b66837e1c7b 100644
--- a/core/modules/system/src/Tests/System/UncaughtExceptionTest.php
+++ b/core/modules/system/src/Tests/System/UncaughtExceptionTest.php
@@ -24,7 +24,7 @@ class UncaughtExceptionTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('error_service_test');
+ public static $modules = ['error_service_test'];
/**
* {@inheritdoc}
@@ -224,14 +224,14 @@ class UncaughtExceptionTest extends WebTestBase {
// We simulate a broken database connection by rewrite settings.php to no
// longer have the proper data.
- $settings['databases']['default']['default']['username'] = (object) array(
+ $settings['databases']['default']['default']['username'] = (object) [
'value' => $incorrect_username,
'required' => TRUE,
- );
- $settings['databases']['default']['default']['password'] = (object) array(
+ ];
+ $settings['databases']['default']['default']['password'] = (object) [
'value' => $this->randomMachineName(16),
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
diff --git a/core/modules/system/src/Tests/Theme/EngineTwigTest.php b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
index 58661d185f8..9327c9426c1 100644
--- a/core/modules/system/src/Tests/Theme/EngineTwigTest.php
+++ b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
@@ -18,11 +18,11 @@ class EngineTwigTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('theme_test', 'twig_theme_test');
+ public static $modules = ['theme_test', 'twig_theme_test'];
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
}
/**
@@ -45,13 +45,13 @@ class EngineTwigTest extends WebTestBase {
$this->drupalGet('twig-theme-test/url-generator');
// Find the absolute URL of the current site.
$url_generator = $this->container->get('url_generator');
- $expected = array(
+ $expected = [
'path (as route) not absolute: ' . $url_generator->generateFromRoute('user.register'),
- 'url (as route) absolute: ' . $url_generator->generateFromRoute('user.register', array(), array('absolute' => TRUE)),
- 'path (as route) not absolute with fragment: ' . $url_generator->generateFromRoute('user.register', array(), array('fragment' => 'bottom')),
- 'url (as route) absolute despite option: ' . $url_generator->generateFromRoute('user.register', array(), array('absolute' => TRUE)),
- 'url (as route) absolute with fragment: ' . $url_generator->generateFromRoute('user.register', array(), array('absolute' => TRUE, 'fragment' => 'bottom')),
- );
+ 'url (as route) absolute: ' . $url_generator->generateFromRoute('user.register', [], ['absolute' => TRUE]),
+ 'path (as route) not absolute with fragment: ' . $url_generator->generateFromRoute('user.register', [], ['fragment' => 'bottom']),
+ 'url (as route) absolute despite option: ' . $url_generator->generateFromRoute('user.register', [], ['absolute' => TRUE]),
+ 'url (as route) absolute with fragment: ' . $url_generator->generateFromRoute('user.register', [], ['absolute' => TRUE, 'fragment' => 'bottom']),
+ ];
// Verify that url() has the ability to bubble cacheability metadata:
// absolute URLs should bubble the 'url.site' cache context. (This only
diff --git a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php
index 2e55df8a102..f7ebd71e88d 100644
--- a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php
@@ -85,7 +85,7 @@ class EntityFilteringThemeTest extends WebTestBase {
\Drupal::service('theme_handler')->install(array_keys($this->themes));
// Create a test user.
- $this->user = $this->drupalCreateUser(array('access content', 'access user profiles'));
+ $this->user = $this->drupalCreateUser(['access content', 'access user profiles']);
$this->user->name = $this->xssLabel;
$this->user->save();
$this->drupalLogin($this->user);
@@ -100,22 +100,22 @@ class EntityFilteringThemeTest extends WebTestBase {
// Add a comment field.
$this->addDefaultCommentField('node', 'article', 'comment', CommentItemInterface::OPEN);
// Create a test node tagged with the test term.
- $this->node = $this->drupalCreateNode(array(
+ $this->node = $this->drupalCreateNode([
'title' => $this->xssLabel,
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
- 'field_tags' => array(array('target_id' => $this->term->id())),
- ));
+ 'field_tags' => [['target_id' => $this->term->id()]],
+ ]);
// Create a test comment on the test node.
- $this->comment = Comment::create(array(
+ $this->comment = Comment::create([
'entity_id' => $this->node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'status' => CommentInterface::PUBLISHED,
'subject' => $this->xssLabel,
- 'comment_body' => array($this->randomMachineName()),
- ));
+ 'comment_body' => [$this->randomMachineName()],
+ ]);
$this->comment->save();
}
@@ -124,12 +124,12 @@ class EntityFilteringThemeTest extends WebTestBase {
*/
function testThemedEntity() {
// Check paths where various view modes of the entities are rendered.
- $paths = array(
+ $paths = [
'user',
'node',
'node/' . $this->node->id(),
'taxonomy/term/' . $this->term->id(),
- );
+ ];
// Check each path in all available themes.
foreach ($this->themes as $name => $theme) {
diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php
index fa5a2ac48f6..a8fec41f214 100644
--- a/core/modules/system/src/Tests/Theme/FunctionsTest.php
+++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php
@@ -21,117 +21,117 @@ class FunctionsTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('router_test');
+ public static $modules = ['router_test'];
/**
* Tests item-list.html.twig.
*/
function testItemList() {
// Verify that empty items produce no output.
- $variables = array();
+ $variables = [];
$expected = '';
$this->assertThemeOutput('item_list', $variables, $expected, 'Empty %callback generates no output.');
// Verify that empty items with title produce no output.
- $variables = array();
+ $variables = [];
$variables['title'] = 'Some title';
$expected = '';
$this->assertThemeOutput('item_list', $variables, $expected, 'Empty %callback with title generates no output.');
// Verify that empty items produce the empty string.
- $variables = array();
+ $variables = [];
$variables['empty'] = 'No items found.';
$expected = '<div class="item-list">No items found.</div>';
$this->assertThemeOutput('item_list', $variables, $expected, 'Empty %callback generates empty string.');
// Verify that empty items produce the empty string with title.
- $variables = array();
+ $variables = [];
$variables['title'] = 'Some title';
$variables['empty'] = 'No items found.';
$expected = '<div class="item-list"><h3>Some title</h3>No items found.</div>';
$this->assertThemeOutput('item_list', $variables, $expected, 'Empty %callback generates empty string with title.');
// Verify that title set to 0 is output.
- $variables = array();
+ $variables = [];
$variables['title'] = 0;
$variables['empty'] = 'No items found.';
$expected = '<div class="item-list"><h3>0</h3>No items found.</div>';
$this->assertThemeOutput('item_list', $variables, $expected, '%callback with title set to 0 generates a title.');
// Verify that title set to a render array is output.
- $variables = array();
- $variables['title'] = array(
+ $variables = [];
+ $variables['title'] = [
'#markup' => '<span>Render array</span>',
- );
+ ];
$variables['empty'] = 'No items found.';
$expected = '<div class="item-list"><h3><span>Render array</span></h3>No items found.</div>';
$this->assertThemeOutput('item_list', $variables, $expected, '%callback with title set to a render array generates a title.');
// Verify that empty text is not displayed when there are list items.
- $variables = array();
+ $variables = [];
$variables['title'] = 'Some title';
$variables['empty'] = 'No items found.';
- $variables['items'] = array('Un', 'Deux', 'Trois');
+ $variables['items'] = ['Un', 'Deux', 'Trois'];
$expected = '<div class="item-list"><h3>Some title</h3><ul><li>Un</li><li>Deux</li><li>Trois</li></ul></div>';
$this->assertThemeOutput('item_list', $variables, $expected, '%callback does not print empty text when there are list items.');
// Verify nested item lists.
- $variables = array();
+ $variables = [];
$variables['title'] = 'Some title';
- $variables['attributes'] = array(
+ $variables['attributes'] = [
'id' => 'parentlist',
- );
- $variables['items'] = array(
+ ];
+ $variables['items'] = [
// A plain string value forms an own item.
'a',
// Items can be fully-fledged render arrays with their own attributes.
- array(
- '#wrapper_attributes' => array(
+ [
+ '#wrapper_attributes' => [
'id' => 'item-id-b',
- ),
+ ],
'#markup' => 'b',
- 'childlist' => array(
+ 'childlist' => [
'#theme' => 'item_list',
- '#attributes' => array('id' => 'blist'),
+ '#attributes' => ['id' => 'blist'],
'#list_type' => 'ol',
- '#items' => array(
+ '#items' => [
'ba',
- array(
+ [
'#markup' => 'bb',
- '#wrapper_attributes' => array('class' => array('item-class-bb')),
- ),
- ),
- ),
- ),
+ '#wrapper_attributes' => ['class' => ['item-class-bb']],
+ ],
+ ],
+ ],
+ ],
// However, items can also be child #items.
- array(
+ [
'#markup' => 'c',
- 'childlist' => array(
- '#attributes' => array('id' => 'clist'),
+ 'childlist' => [
+ '#attributes' => ['id' => 'clist'],
'ca',
- array(
+ [
'#markup' => 'cb',
- '#wrapper_attributes' => array('class' => array('item-class-cb')),
- 'children' => array(
+ '#wrapper_attributes' => ['class' => ['item-class-cb']],
+ 'children' => [
'cba',
'cbb',
- ),
- ),
+ ],
+ ],
'cc',
- ),
- ),
+ ],
+ ],
// Use #markup to be able to specify #wrapper_attributes.
- array(
+ [
'#markup' => 'd',
- '#wrapper_attributes' => array('id' => 'item-id-d'),
- ),
+ '#wrapper_attributes' => ['id' => 'item-id-d'],
+ ],
// An empty item with attributes.
- array(
- '#wrapper_attributes' => array('id' => 'item-id-e'),
- ),
+ [
+ '#wrapper_attributes' => ['id' => 'item-id-e'],
+ ],
// Lastly, another plain string item.
'f',
- );
+ ];
$inner_b = '<div class="item-list"><ol id="blist">';
$inner_b .= '<li>ba</li>';
@@ -171,47 +171,47 @@ class FunctionsTest extends WebTestBase {
// \Drupal\Core\Utility\LinkGeneratorInterface::generate() method to compare
// the active link correctly.
$original_query = \Drupal::request()->query->all();
- \Drupal::request()->query->replace(array());
+ \Drupal::request()->query->replace([]);
// Verify that empty variables produce no output.
- $variables = array();
+ $variables = [];
$expected = '';
$this->assertThemeOutput('links', $variables, $expected, 'Empty %callback generates no output.');
- $variables = array();
+ $variables = [];
$variables['heading'] = 'Some title';
$expected = '';
$this->assertThemeOutput('links', $variables, $expected, 'Empty %callback with heading generates no output.');
// Verify that a list of links is properly rendered.
- $variables = array();
- $variables['attributes'] = array('id' => 'somelinks');
- $variables['links'] = array(
- 'a link' => array(
+ $variables = [];
+ $variables['attributes'] = ['id' => 'somelinks'];
+ $variables['links'] = [
+ 'a link' => [
'title' => 'A <link>',
'url' => Url::fromUri('base:a/link'),
- ),
- 'plain text' => array(
+ ],
+ 'plain text' => [
'title' => 'Plain "text"',
- ),
- 'html text' => array(
- 'title' => SafeMarkup::format('<span class="unescaped">@text</span>', array('@text' => 'potentially unsafe text that <should> be escaped')),
- ),
- 'front page' => array(
+ ],
+ 'html text' => [
+ 'title' => SafeMarkup::format('<span class="unescaped">@text</span>', ['@text' => 'potentially unsafe text that <should> be escaped']),
+ ],
+ 'front page' => [
'title' => 'Front page',
'url' => Url::fromRoute('<front>'),
- ),
- 'router-test' => array(
+ ],
+ 'router-test' => [
'title' => 'Test route',
'url' => Url::fromRoute('router_test.1'),
- ),
- 'query-test' => array(
+ ],
+ 'query-test' => [
'title' => 'Query test route',
'url' => Url::fromRoute('router_test.1'),
- 'query' => array(
+ 'query' => [
'key' => 'value',
- )
- ),
- );
+ ]
+ ],
+ ];
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
@@ -220,7 +220,7 @@ class FunctionsTest extends WebTestBase {
$expected_links .= '<li class="html-text"><span class="unescaped">' . Html::escape('potentially unsafe text that <should> be escaped') . '</span></li>';
$expected_links .= '<li class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '">' . Html::escape('Front page') . '</a></li>';
$expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . Html::escape('Test route') . '</a></li>';
- $query = array('key' => 'value');
+ $query = ['key' => 'value'];
$expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . Html::escape('Query test route') . '</a></li>';
$expected_links .= '</ul>';
@@ -234,25 +234,25 @@ class FunctionsTest extends WebTestBase {
\Drupal::request()->query->replace($original_query);
// Verify that passing an array as heading works (core support).
- $variables['heading'] = array(
+ $variables['heading'] = [
'text' => 'Links heading',
'level' => 'h3',
- 'attributes' => array('class' => array('heading')),
- );
+ 'attributes' => ['class' => ['heading']],
+ ];
$expected_heading = '<h3 class="heading">Links heading</h3>';
$expected = $expected_heading . $expected_links;
$this->assertThemeOutput('links', $variables, $expected);
// Verify that passing attributes for the heading works.
- $variables['heading'] = array('text' => 'Links heading', 'level' => 'h3', 'attributes' => array('id' => 'heading'));
+ $variables['heading'] = ['text' => 'Links heading', 'level' => 'h3', 'attributes' => ['id' => 'heading']];
$expected_heading = '<h3 id="heading">Links heading</h3>';
$expected = $expected_heading . $expected_links;
$this->assertThemeOutput('links', $variables, $expected);
// Verify that passing attributes for the links work.
- $variables['links']['plain text']['attributes'] = array(
- 'class' => array('a/class'),
- );
+ $variables['links']['plain text']['attributes'] = [
+ 'class' => ['a/class'],
+ ];
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
$expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . Html::escape('A <link>') . '</a></li>';
@@ -260,14 +260,14 @@ class FunctionsTest extends WebTestBase {
$expected_links .= '<li class="html-text"><span class="unescaped">' . Html::escape('potentially unsafe text that <should> be escaped') . '</span></li>';
$expected_links .= '<li class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '">' . Html::escape('Front page') . '</a></li>';
$expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . Html::escape('Test route') . '</a></li>';
- $query = array('key' => 'value');
+ $query = ['key' => 'value'];
$expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . Html::escape('Query test route') . '</a></li>';
$expected_links .= '</ul>';
$expected = $expected_heading . $expected_links;
$this->assertThemeOutput('links', $variables, $expected);
// Verify the data- attributes for setting the "active" class on links.
- \Drupal::currentUser()->setAccount(new UserSession(array('uid' => 1)));
+ \Drupal::currentUser()->setAccount(new UserSession(['uid' => 1]));
$variables['set_active_class'] = TRUE;
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
@@ -276,7 +276,7 @@ class FunctionsTest extends WebTestBase {
$expected_links .= '<li class="html-text"><span class="unescaped">' . Html::escape('potentially unsafe text that <should> be escaped') . '</span></li>';
$expected_links .= '<li data-drupal-link-system-path="&lt;front&gt;" class="front-page"><a href="' . Url::fromRoute('<front>')->toString() . '" data-drupal-link-system-path="&lt;front&gt;">' . Html::escape('Front page') . '</a></li>';
$expected_links .= '<li data-drupal-link-system-path="router_test/test1" class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" data-drupal-link-system-path="router_test/test1">' . Html::escape('Test route') . '</a></li>';
- $query = array('key' => 'value');
+ $query = ['key' => 'value'];
$encoded_query = Html::escape(Json::encode($query));
$expected_links .= '<li data-drupal-link-query="' . $encoded_query . '" data-drupal-link-system-path="router_test/test1" class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '" data-drupal-link-query="' . $encoded_query . '" data-drupal-link-system-path="router_test/test1">' . Html::escape('Query test route') . '</a></li>';
$expected_links .= '</ul>';
@@ -306,33 +306,33 @@ class FunctionsTest extends WebTestBase {
// Verify that a list of links is properly rendered.
$variables = [];
$variables['attributes'] = ['id' => 'somelinks'];
- $variables['links'] = array(
- array(
+ $variables['links'] = [
+ [
'title' => 'A <link>',
'url' => Url::fromUri('base:a/link'),
- ),
- array(
+ ],
+ [
'title' => 'Plain "text"',
- ),
- array(
- 'title' => SafeMarkup::format('<span class="unescaped">@text</span>', array('@text' => 'potentially unsafe text that <should> be escaped')),
- ),
- array(
+ ],
+ [
+ 'title' => SafeMarkup::format('<span class="unescaped">@text</span>', ['@text' => 'potentially unsafe text that <should> be escaped']),
+ ],
+ [
'title' => 'Front page',
'url' => Url::fromRoute('<front>'),
- ),
- array(
+ ],
+ [
'title' => 'Test route',
'url' => Url::fromRoute('router_test.1'),
- ),
- array(
+ ],
+ [
'title' => 'Query test route',
'url' => Url::fromRoute('router_test.1'),
- 'query' => array(
+ 'query' => [
'key' => 'value',
- )
- ),
- );
+ ]
+ ],
+ ];
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
@@ -388,7 +388,7 @@ class FunctionsTest extends WebTestBase {
$this->assertThemeOutput('links', $variables, $expected);
// Verify the data- attributes for setting the "active" class on links.
- \Drupal::currentUser()->setAccount(new UserSession(array('uid' => 1)));
+ \Drupal::currentUser()->setAccount(new UserSession(['uid' => 1]));
$variables['set_active_class'] = TRUE;
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
@@ -411,55 +411,55 @@ class FunctionsTest extends WebTestBase {
function testDrupalPreRenderLinks() {
// Define the base array to be rendered, containing a variety of different
// kinds of links.
- $base_array = array(
+ $base_array = [
'#theme' => 'links',
- '#pre_render' => array('drupal_pre_render_links'),
- '#links' => array(
- 'parent_link' => array(
+ '#pre_render' => ['drupal_pre_render_links'],
+ '#links' => [
+ 'parent_link' => [
'title' => 'Parent link original',
'url' => Url::fromRoute('router_test.1'),
- ),
- ),
- 'first_child' => array(
+ ],
+ ],
+ 'first_child' => [
'#theme' => 'links',
- '#links' => array(
+ '#links' => [
// This should be rendered if 'first_child' is rendered separately,
// but ignored if the parent is being rendered (since it duplicates
// one of the parent's links).
- 'parent_link' => array(
+ 'parent_link' => [
'title' => 'Parent link copy',
'url' => Url::fromRoute('router_test.6'),
- ),
+ ],
// This should always be rendered.
- 'first_child_link' => array(
+ 'first_child_link' => [
'title' => 'First child link',
'url' => Url::fromRoute('router_test.7'),
- ),
- ),
- ),
+ ],
+ ],
+ ],
// This should always be rendered as part of the parent.
- 'second_child' => array(
+ 'second_child' => [
'#theme' => 'links',
- '#links' => array(
- 'second_child_link' => array(
+ '#links' => [
+ 'second_child_link' => [
'title' => 'Second child link',
'url' => Url::fromRoute('router_test.8'),
- ),
- ),
- ),
+ ],
+ ],
+ ],
// This should never be rendered, since the user does not have access to
// it.
- 'third_child' => array(
+ 'third_child' => [
'#theme' => 'links',
- '#links' => array(
- 'third_child_link' => array(
+ '#links' => [
+ 'third_child_link' => [
'title' => 'Third child link',
'url' => Url::fromRoute('router_test.9'),
- ),
- ),
+ ],
+ ],
'#access' => FALSE,
- ),
- );
+ ],
+ ];
// Start with a fresh copy of the base array, and try rendering the entire
// thing. We expect a single <ul> with appropriate links contained within
@@ -508,7 +508,7 @@ class FunctionsTest extends WebTestBase {
*/
function testImage() {
// Test that data URIs work with theme_image().
- $variables = array();
+ $variables = [];
$variables['uri'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
$variables['alt'] = 'Data URI image of a red dot';
$expected = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Data URI image of a red dot" />' . "\n";
diff --git a/core/modules/system/src/Tests/Theme/HtmlAttributesTest.php b/core/modules/system/src/Tests/Theme/HtmlAttributesTest.php
index f103caaa79c..b9babae5645 100644
--- a/core/modules/system/src/Tests/Theme/HtmlAttributesTest.php
+++ b/core/modules/system/src/Tests/Theme/HtmlAttributesTest.php
@@ -16,7 +16,7 @@ class HtmlAttributesTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('theme_test');
+ public static $modules = ['theme_test'];
/**
* Tests that attributes in the 'html' and 'body' elements can be altered.
diff --git a/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php b/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php
index 75e52c9b883..706fd267306 100644
--- a/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php
+++ b/core/modules/system/src/Tests/Theme/ThemeSuggestionsAlterTest.php
@@ -17,11 +17,11 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('theme_test');
+ public static $modules = ['theme_test'];
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
}
/**
@@ -57,7 +57,7 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
// Enable the theme_suggestions_test module to test modules implementing
// suggestions alter hooks.
- \Drupal::service('module_installer')->install(array('theme_suggestions_test'));
+ \Drupal::service('module_installer')->install(['theme_suggestions_test']);
$this->resetAll();
$this->drupalGet('theme-test/general-suggestion-alter');
$this->assertText('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_alter().');
@@ -79,7 +79,7 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
// Enable the theme_suggestions_test module to test modules implementing
// suggestions alter hooks.
- \Drupal::service('module_installer')->install(array('theme_suggestions_test'));
+ \Drupal::service('module_installer')->install(['theme_suggestions_test']);
$this->resetAll();
$this->drupalGet('theme-test/suggestion-alter');
$this->assertText('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_HOOK_alter().');
@@ -103,7 +103,7 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
$this->assertText('theme_test_specific_suggestions__variant', 'Specific theme call is added to the suggestions array.');
// Ensure that the base hook is used to determine the suggestion alter hook.
- \Drupal::service('module_installer')->install(array('theme_suggestions_test'));
+ \Drupal::service('module_installer')->install(['theme_suggestions_test']);
$this->resetAll();
$this->drupalGet('theme-test/specific-suggestion-alter');
$this->assertText('Template overridden based on suggestion alter hook determined by the base hook.');
@@ -126,7 +126,7 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
// Enable the theme_suggestions_test module to test modules implementing
// suggestions alter hooks.
- \Drupal::service('module_installer')->install(array('theme_suggestions_test'));
+ \Drupal::service('module_installer')->install(['theme_suggestions_test']);
$this->resetAll();
$this->drupalGet('theme-test/function-suggestion-alter');
$this->assertText('Theme function overridden based on new theme suggestion provided by a module.');
@@ -143,7 +143,7 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
// Enable theme_suggestions_test module and make two requests to make sure
// the include file is always loaded. The file will always be included for
// the first request because the theme registry is being rebuilt.
- \Drupal::service('module_installer')->install(array('theme_suggestions_test'));
+ \Drupal::service('module_installer')->install(['theme_suggestions_test']);
$this->resetAll();
$this->drupalGet('theme-test/suggestion-alter-include');
$this->assertText('Function suggested via suggestion alter hook found in include file.', 'Include file loaded for initial request.');
@@ -162,7 +162,7 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
$this->config('system.theme')
->set('default', 'test_theme')
->save();
- \Drupal::service('module_installer')->install(array('theme_suggestions_test'));
+ \Drupal::service('module_installer')->install(['theme_suggestions_test']);
$this->resetAll();
// Send two requests so that we get all the messages we've set via
@@ -170,15 +170,15 @@ class ThemeSuggestionsAlterTest extends WebTestBase {
$this->drupalGet('theme-test/suggestion-alter');
// Ensure that the order is first by extension, then for a given extension,
// the hook-specific one after the generic one.
- $expected = array(
+ $expected = [
'theme_suggestions_test_theme_suggestions_alter() executed.',
'theme_suggestions_test_theme_suggestions_theme_test_suggestions_alter() executed.',
'theme_test_theme_suggestions_alter() executed.',
'theme_test_theme_suggestions_theme_test_suggestions_alter() executed.',
'test_theme_theme_suggestions_alter() executed.',
'test_theme_theme_suggestions_theme_test_suggestions_alter() executed.',
- );
- $content = preg_replace('/\s+/', ' ', Xss::filter($this->content, array()));
+ ];
+ $content = preg_replace('/\s+/', ' ', Xss::filter($this->content, []));
$this->assert(strpos($content, implode(' ', $expected)) !== FALSE, 'Suggestion alter hooks executed in the expected order.');
}
diff --git a/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php
index afced8eb358..950e0739775 100644
--- a/core/modules/system/src/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/ThemeTest.php
@@ -22,11 +22,11 @@ class ThemeTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('theme_test', 'node');
+ public static $modules = ['theme_test', 'node'];
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
}
/**
@@ -40,14 +40,14 @@ class ThemeTest extends WebTestBase {
* - any attributes set in the template's preprocessing function
*/
function testAttributeMerging() {
- $theme_test_render_element = array(
- 'elements' => array(
- '#attributes' => array('data-foo' => 'bar'),
- ),
- 'attributes' => array(
+ $theme_test_render_element = [
+ 'elements' => [
+ '#attributes' => ['data-foo' => 'bar'],
+ ],
+ 'attributes' => [
'id' => 'bazinga',
- ),
- );
+ ],
+ ];
$this->assertThemeOutput('theme_test_render_element', $theme_test_render_element, '<div id="bazinga" data-foo="bar" data-variables-are-preprocessed></div>' . "\n");
}
@@ -58,10 +58,10 @@ class ThemeTest extends WebTestBase {
// theme_test_false is an implemented theme hook so \Drupal::theme() service
// should return a string or an object that implements MarkupInterface,
// even though the theme function itself can return anything.
- $foos = array('null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo', 'empty_string' => '');
+ $foos = ['null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo', 'empty_string' => ''];
foreach ($foos as $type => $example) {
- $output = \Drupal::theme()->render('theme_test_foo', array('foo' => $example));
- $this->assertTrue($output instanceof MarkupInterface || is_string($output), format_string('\Drupal::theme() returns an object that implements MarkupInterface or a string for data type @type.', array('@type' => $type)));
+ $output = \Drupal::theme()->render('theme_test_foo', ['foo' => $example]);
+ $this->assertTrue($output instanceof MarkupInterface || is_string($output), format_string('\Drupal::theme() returns an object that implements MarkupInterface or a string for data type @type.', ['@type' => $type]));
if ($output instanceof MarkupInterface) {
$this->assertIdentical((string) $example, $output->__toString());
}
@@ -72,7 +72,7 @@ class ThemeTest extends WebTestBase {
// suggestionnotimplemented is not an implemented theme hook so \Drupal::theme() service
// should return FALSE instead of a string.
- $output = \Drupal::theme()->render(array('suggestionnotimplemented'), array());
+ $output = \Drupal::theme()->render(['suggestionnotimplemented'], []);
$this->assertIdentical($output, FALSE, '\Drupal::theme() returns FALSE when a hook suggestion is not implemented.');
}
@@ -83,22 +83,22 @@ class ThemeTest extends WebTestBase {
// Set the front page as something random otherwise the CLI
// test runner fails.
$this->config('system.site')->set('page.front', '/nobody-home')->save();
- $args = array('node', '1', 'edit');
+ $args = ['node', '1', 'edit'];
$suggestions = theme_get_suggestions($args, 'page');
- $this->assertEqual($suggestions, array('page__node', 'page__node__%', 'page__node__1', 'page__node__edit'), 'Found expected node edit page suggestions');
+ $this->assertEqual($suggestions, ['page__node', 'page__node__%', 'page__node__1', 'page__node__edit'], 'Found expected node edit page suggestions');
// Check attack vectors.
- $args = array('node', '\\1');
+ $args = ['node', '\\1'];
$suggestions = theme_get_suggestions($args, 'page');
- $this->assertEqual($suggestions, array('page__node', 'page__node__%', 'page__node__1'), 'Removed invalid \\ from suggestions');
- $args = array('node', '1/');
+ $this->assertEqual($suggestions, ['page__node', 'page__node__%', 'page__node__1'], 'Removed invalid \\ from suggestions');
+ $args = ['node', '1/'];
$suggestions = theme_get_suggestions($args, 'page');
- $this->assertEqual($suggestions, array('page__node', 'page__node__%', 'page__node__1'), 'Removed invalid / from suggestions');
- $args = array('node', "1\0");
+ $this->assertEqual($suggestions, ['page__node', 'page__node__%', 'page__node__1'], 'Removed invalid / from suggestions');
+ $args = ['node', "1\0"];
$suggestions = theme_get_suggestions($args, 'page');
- $this->assertEqual($suggestions, array('page__node', 'page__node__%', 'page__node__1'), 'Removed invalid \\0 from suggestions');
+ $this->assertEqual($suggestions, ['page__node', 'page__node__%', 'page__node__1'], 'Removed invalid \\0 from suggestions');
// Define path with hyphens to be used to generate suggestions.
- $args = array('node', '1', 'hyphen-path');
- $result = array('page__node', 'page__node__%', 'page__node__1', 'page__node__hyphen_path');
+ $args = ['node', '1', 'hyphen-path'];
+ $result = ['page__node', 'page__node__%', 'page__node__1', 'page__node__hyphen_path'];
$suggestions = theme_get_suggestions($args, 'page');
$this->assertEqual($suggestions, $result, 'Found expected page suggestions for paths containing hyphens.');
}
@@ -150,7 +150,7 @@ class ThemeTest extends WebTestBase {
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/user/login'));
\Drupal::requestStack()->push($request);
$this->config('system.site')->set('page.front', '/user/login')->save();
- $suggestions = theme_get_suggestions(array('user', 'login'), 'page');
+ $suggestions = theme_get_suggestions(['user', 'login'], 'page');
// Set it back to not annoy the batch runner.
\Drupal::requestStack()->pop();
$this->assertTrue(in_array('page__front', $suggestions), 'Front page template was suggested.');
@@ -207,7 +207,7 @@ class ThemeTest extends WebTestBase {
*/
function testListThemes() {
$theme_handler = $this->container->get('theme_handler');
- $theme_handler->install(array('test_subtheme'));
+ $theme_handler->install(['test_subtheme']);
$themes = $theme_handler->listInfo();
// Check if ThemeHandlerInterface::listInfo() retrieves enabled themes.
@@ -215,8 +215,8 @@ class ThemeTest extends WebTestBase {
// Check if ThemeHandlerInterface::listInfo() returns disabled themes.
// Check for base theme and subtheme lists.
- $base_theme_list = array('test_basetheme' => 'Theme test base theme');
- $sub_theme_list = array('test_subsubtheme' => 'Theme test subsubtheme', 'test_subtheme' => 'Theme test subtheme');
+ $base_theme_list = ['test_basetheme' => 'Theme test base theme'];
+ $sub_theme_list = ['test_subsubtheme' => 'Theme test subsubtheme', 'test_subtheme' => 'Theme test subtheme'];
$this->assertIdentical($themes['test_basetheme']->sub_themes, $sub_theme_list, 'Base theme\'s object includes list of subthemes.');
$this->assertIdentical($themes['test_subtheme']->base_themes, $base_theme_list, 'Subtheme\'s object includes list of base themes.');
@@ -231,20 +231,20 @@ class ThemeTest extends WebTestBase {
* Tests child element rendering for 'render element' theme hooks.
*/
function testDrupalRenderChildren() {
- $element = array(
+ $element = [
'#theme' => 'theme_test_render_element_children',
- 'child' => array(
+ 'child' => [
'#markup' => 'Foo',
- ),
- );
+ ],
+ ];
$this->assertThemeOutput('theme_test_render_element_children', $element, 'Foo', 'drupal_render() avoids #theme recursion loop when rendering a render element.');
- $element = array(
- '#theme_wrappers' => array('theme_test_render_element_children'),
- 'child' => array(
+ $element = [
+ '#theme_wrappers' => ['theme_test_render_element_children'],
+ 'child' => [
'#markup' => 'Foo',
- ),
- );
+ ],
+ ];
$this->assertThemeOutput('theme_test_render_element_children', $element, 'Foo', 'drupal_render() avoids #theme_wrappers recursion loop when rendering a render element.');
}
@@ -281,7 +281,7 @@ class ThemeTest extends WebTestBase {
* Tests that region attributes can be manipulated via preprocess functions.
*/
public function testRegionClass() {
- \Drupal::service('module_installer')->install(array('block', 'theme_region_test'));
+ \Drupal::service('module_installer')->install(['block', 'theme_region_test']);
// Place a block.
$this->drupalPlaceBlock('system_main_block');
diff --git a/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
index df3c26cdaea..c6b6c51c58e 100644
--- a/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
@@ -16,7 +16,7 @@ class TwigDebugMarkupTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('theme_test', 'node');
+ public static $modules = ['theme_test', 'node'];
/**
* Tests debug markup added to Twig template output.
@@ -25,9 +25,9 @@ class TwigDebugMarkupTest extends WebTestBase {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
$extension = twig_extension();
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
$this->config('system.theme')->set('default', 'test_theme')->save();
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
// Enable debug, rebuild the service container, and clear all caches.
$parameters = $this->container->getParameter('twig.config');
$parameters['debug'] = TRUE;
@@ -62,7 +62,7 @@ class TwigDebugMarkupTest extends WebTestBase {
// Create another node and make sure the template suggestions shown in the
// debug markup are correct.
$node3 = $this->drupalCreateNode();
- $build = array('#theme' => 'node__foo__bar');
+ $build = ['#theme' => 'node__foo__bar'];
$build += node_view($node3);
$output = $renderer->renderRoot($build);
$this->assertTrue(strpos($output, "THEME HOOK: 'node__foo__bar'") !== FALSE, 'Theme call information found.');
diff --git a/core/modules/system/src/Tests/Theme/TwigFilterTest.php b/core/modules/system/src/Tests/Theme/TwigFilterTest.php
index 810ed533105..653e4fa96ae 100644
--- a/core/modules/system/src/Tests/Theme/TwigFilterTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigFilterTest.php
@@ -16,54 +16,54 @@ class TwigFilterTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('twig_theme_test');
+ public static $modules = ['twig_theme_test'];
/**
* Test Twig "without" filter.
*/
public function testTwigWithoutFilter() {
- $filter_test = array(
+ $filter_test = [
'#theme' => 'twig_theme_test_filter',
- '#quote' => array(
- 'content' => array('#markup' => 'You can only find truth with logic if you have already found truth without it.'),
- 'author' => array('#markup' => 'Gilbert Keith Chesterton'),
- 'date' => array('#markup' => '1874-1936'),
- ),
- '#attributes' => array(
+ '#quote' => [
+ 'content' => ['#markup' => 'You can only find truth with logic if you have already found truth without it.'],
+ 'author' => ['#markup' => 'Gilbert Keith Chesterton'],
+ 'date' => ['#markup' => '1874-1936'],
+ ],
+ '#attributes' => [
'id' => 'quotes',
'checked' => TRUE,
- 'class' => array('red', 'green', 'blue'),
- ),
- );
+ 'class' => ['red', 'green', 'blue'],
+ ],
+ ];
$rendered = \Drupal::service('renderer')->renderRoot($filter_test);
$this->setRawContent($rendered);
- $elements = array(
- array(
+ $elements = [
+ [
'expected' => '<div><strong>No author:</strong> You can only find truth with logic if you have already found truth without it.1874-1936.</div>',
'message' => '"No author" was successfully rendered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><strong>Complete quote after without:</strong> You can only find truth with logic if you have already found truth without it.Gilbert Keith Chesterton1874-1936.</div>',
'message' => '"Complete quote after without" was successfully rendered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><strong>Only author:</strong> Gilbert Keith Chesterton.</div>',
'message' => '"Only author:" was successfully rendered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><strong>No author or date:</strong> You can only find truth with logic if you have already found truth without it..</div>',
'message' => '"No author or date" was successfully rendered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><strong>Only date:</strong> 1874-1936.</div>',
'message' => '"Only date" was successfully rendered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><strong>Complete quote again for good measure:</strong> You can only find truth with logic if you have already found truth without it.Gilbert Keith Chesterton1874-1936.</div>',
'message' => '"Complete quote again for good measure" was successfully rendered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><strong>Marked-up:</strong>
<blockquote>
<p>You can only find truth with logic if you have already found truth without it.</p>
@@ -72,48 +72,48 @@ class TwigFilterTest extends WebTestBase {
</footer>
</blockquote>',
'message' => '"Marked-up quote" was successfully rendered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span id="quotes" checked class="red green blue">All attributes:</span></div>',
'message' => 'All attributes printed.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span class="red green blue" id="quotes" checked>Class attributes in front, remainder at the back:</span></div>',
'message' => 'Class attributes printed in the front, the rest in the back.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span id="quotes" checked data-class="red green blue">Class attributes in back, remainder at the front:</span></div>',
'message' => 'Class attributes printed in the back, the rest in the front.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span class="red green blue">Class attributes only:</span></div>',
'message' => 'Class attributes only printed.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span checked id="quotes" class="red green blue">Without boolean attribute.</span></div>',
'message' => 'Boolean attribute printed in the front.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span data-id="quotes" checked class="red green blue">Without string attribute.</span></div>',
'message' => 'Without string attribute in the front.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span checked>Without id and class attributes.</span></div>',
'message' => 'Attributes printed without id and class attributes.',
- ),
- array(
+ ],
+ [
'expected' => '<div><span id="quotes" checked class="red green blue">All attributes again.</span></div>',
'message' => 'All attributes printed again.',
- ),
- array(
+ ],
+ [
'expected' => '<div id="quotes-here"><span class="gray-like-a-bunny bem__ized--top-feature" id="quotes-here">ID and class. Having the same ID twice is not valid markup but we want to make sure the filter doesn\'t use \Drupal\Component\Utility\Html::getUniqueId().</span></div>',
'message' => 'Class and ID filtered.',
- ),
- array(
+ ],
+ [
'expected' => '<div><strong>Rendered author string length:</strong> 24.</div>',
'message' => 'Render filter string\'s length.',
- ),
- );
+ ],
+ ];
foreach ($elements as $element) {
$this->assertRaw($element['expected'], $element['message']);
diff --git a/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php b/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php
index 27a54d17994..ab62889b9a9 100644
--- a/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigNamespaceTest.php
@@ -16,7 +16,7 @@ class TwigNamespaceTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('twig_theme_test', 'twig_namespace_a', 'twig_namespace_b', 'node');
+ public static $modules = ['twig_theme_test', 'twig_namespace_a', 'twig_namespace_b', 'node'];
/**
* @var \Drupal\Core\Template\TwigEnvironment
@@ -25,7 +25,7 @@ class TwigNamespaceTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('test_theme', 'bartik'));
+ \Drupal::service('theme_handler')->install(['test_theme', 'bartik']);
$this->twig = \Drupal::service('twig');
}
@@ -52,7 +52,7 @@ class TwigNamespaceTest extends WebTestBase {
*/
public function testTwigNamespaces() {
// Test twig @extends and @include in template files.
- $test = array('#theme' => 'twig_namespace_test');
+ $test = ['#theme' => 'twig_namespace_test'];
$this->setRawContent(\Drupal::service('renderer')->renderRoot($test));
$this->assertText('This line is from twig_namespace_a/templates/test.html.twig');
diff --git a/core/modules/system/src/Tests/Theme/TwigRawTest.php b/core/modules/system/src/Tests/Theme/TwigRawTest.php
index 80afb8eaf88..8be63dbb518 100644
--- a/core/modules/system/src/Tests/Theme/TwigRawTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigRawTest.php
@@ -16,16 +16,16 @@ class TwigRawTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('twig_theme_test');
+ public static $modules = ['twig_theme_test'];
/**
* Tests the raw filter inside an autoescape tag.
*/
public function testAutoescapeRaw() {
- $test = array(
+ $test = [
'#theme' => 'twig_raw_test',
'#script' => '<script>alert("This alert is real because I will put it through the raw filter!");</script>',
- );
+ ];
$rendered = \Drupal::service('renderer')->renderRoot($test);
$this->setRawContent($rendered);
$this->assertRaw('<script>alert("This alert is real because I will put it through the raw filter!");</script>');
diff --git a/core/modules/system/src/Tests/Theme/TwigTransTest.php b/core/modules/system/src/Tests/Theme/TwigTransTest.php
index ef6fe05074f..b73cdaf0c24 100644
--- a/core/modules/system/src/Tests/Theme/TwigTransTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigTransTest.php
@@ -17,12 +17,12 @@ class TwigTransTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'theme_test',
'twig_theme_test',
'locale',
'language'
- );
+ ];
/**
* An administrative user for testing.
@@ -36,10 +36,10 @@ class TwigTransTest extends WebTestBase {
*
* @var array
*/
- protected $languages = array(
+ protected $languages = [
'xx' => 'Lolspeak',
'zz' => 'Lolspeak2',
- );
+ ];
/**
* {@inheritdoc}
@@ -48,16 +48,16 @@ class TwigTransTest extends WebTestBase {
parent::setUp();
// Setup test_theme.
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
$this->config('system.theme')->set('default', 'test_theme')->save();
// Create and log in as admin.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer languages',
'access administration pages',
'administer site configuration',
'translate interface'
- ));
+ ]);
$this->drupalLogin($this->adminUser);
// Install languages.
@@ -77,7 +77,7 @@ class TwigTransTest extends WebTestBase {
public function testTwigTransTags() {
// Run this once without and once with Twig debug because trans can work
// differently depending on that setting.
- $this->drupalGet('twig-theme-test/trans', array('language' => \Drupal::languageManager()->getLanguage('xx')));
+ $this->drupalGet('twig-theme-test/trans', ['language' => \Drupal::languageManager()->getLanguage('xx')]);
$this->assertTwigTransTags();
// Enable debug, rebuild the service container, and clear all caches.
@@ -87,7 +87,7 @@ class TwigTransTest extends WebTestBase {
$this->rebuildContainer();
$this->resetAll();
- $this->drupalGet('twig-theme-test/trans', array('language' => \Drupal::languageManager()->getLanguage('xx')));
+ $this->drupalGet('twig-theme-test/trans', ['language' => \Drupal::languageManager()->getLanguage('xx')]);
$this->assertTwigTransTags();
}
@@ -197,12 +197,12 @@ class TwigTransTest extends WebTestBase {
$contents = $this->poFileContents($langcode);
if ($contents) {
// Add test language for translation testing.
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
// Install the language in Drupal.
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
@@ -211,11 +211,11 @@ class TwigTransTest extends WebTestBase {
// Import the custom .po contents for the language.
$filename = \Drupal::service('file_system')->tempnam('temporary://', "po_") . '.po';
file_put_contents($filename, $contents);
- $options = array(
+ $options = [
'files[file]' => $filename,
'langcode' => $langcode,
'customized' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import'));
drupal_unlink($filename);
}
diff --git a/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php b/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php
index a9723c235dc..9e5cc123b82 100644
--- a/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php
+++ b/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php
@@ -17,7 +17,7 @@ class DependencyHookInvocationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('update_test_0', 'update_test_1', 'update_test_2');
+ public static $modules = ['update_test_0', 'update_test_1', 'update_test_2'];
protected function setUp() {
parent::setUp();
diff --git a/core/modules/system/src/Tests/Update/DependencyMissingTest.php b/core/modules/system/src/Tests/Update/DependencyMissingTest.php
index 9764b4c8126..fe208dc133c 100644
--- a/core/modules/system/src/Tests/Update/DependencyMissingTest.php
+++ b/core/modules/system/src/Tests/Update/DependencyMissingTest.php
@@ -16,7 +16,7 @@ class DependencyMissingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('update_test_0', 'update_test_2');
+ public static $modules = ['update_test_0', 'update_test_2'];
protected function setUp() {
// Only install update_test_2.module, even though its updates have a
@@ -26,9 +26,9 @@ class DependencyMissingTest extends WebTestBase {
}
function testMissingUpdate() {
- $starting_updates = array(
+ $starting_updates = [
'update_test_2' => 8001,
- );
+ ];
$update_graph = update_resolve_dependencies($starting_updates);
$this->assertTrue($update_graph['update_test_2_update_8001']['allowed'], "The module's first update function is allowed to run, since it does not have any missing dependencies.");
$this->assertFalse($update_graph['update_test_2_update_8002']['allowed'], "The module's second update function is not allowed to run, since it has a direct dependency on a missing update.");
diff --git a/core/modules/system/src/Tests/Update/DependencyOrderingTest.php b/core/modules/system/src/Tests/Update/DependencyOrderingTest.php
index bb3ae3717c4..f5c344fc093 100644
--- a/core/modules/system/src/Tests/Update/DependencyOrderingTest.php
+++ b/core/modules/system/src/Tests/Update/DependencyOrderingTest.php
@@ -16,7 +16,7 @@ class DependencyOrderingTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('update_test_0', 'update_test_1', 'update_test_2', 'update_test_3');
+ public static $modules = ['update_test_0', 'update_test_1', 'update_test_2', 'update_test_3'];
protected function setUp() {
parent::setUp();
@@ -27,14 +27,14 @@ class DependencyOrderingTest extends WebTestBase {
* Test that updates within a single module run in the correct order.
*/
function testUpdateOrderingSingleModule() {
- $starting_updates = array(
+ $starting_updates = [
'update_test_1' => 8001,
- );
- $expected_updates = array(
+ ];
+ $expected_updates = [
'update_test_1_update_8001',
'update_test_1_update_8002',
'update_test_1_update_8003',
- );
+ ];
$actual_updates = array_keys(update_resolve_dependencies($starting_updates));
$this->assertEqual($expected_updates, $actual_updates, 'Updates within a single module run in the correct order.');
}
@@ -43,10 +43,10 @@ class DependencyOrderingTest extends WebTestBase {
* Test that dependencies between modules are resolved correctly.
*/
function testUpdateOrderingModuleInterdependency() {
- $starting_updates = array(
+ $starting_updates = [
'update_test_2' => 8001,
'update_test_3' => 8001,
- );
+ ];
$update_order = array_keys(update_resolve_dependencies($starting_updates));
// Make sure that each dependency is satisfied.
$first_dependency_satisfied = array_search('update_test_2_update_8001', $update_order) < array_search('update_test_3_update_8001', $update_order);
diff --git a/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php b/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php
index ce5a0066f5e..60ac0c47c1c 100644
--- a/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php
+++ b/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php
@@ -17,7 +17,7 @@ class InvalidUpdateHookTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('update_test_invalid_hook', 'update_script_test', 'dblog');
+ public static $modules = ['update_test_invalid_hook', 'update_script_test', 'dblog'];
/**
* URL for the upgrade script.
@@ -38,7 +38,7 @@ class InvalidUpdateHookTest extends WebTestBase {
require_once \Drupal::root() . '/core/includes/update.inc';
$this->updateUrl = $GLOBALS['base_url'] . '/update.php';
- $this->updateUser = $this->drupalCreateUser(array('administer software updates'));
+ $this->updateUser = $this->drupalCreateUser(['administer software updates']);
}
function testInvalidUpdateHook() {
diff --git a/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php b/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php
index eb95fce6ed8..09cc586bc7e 100644
--- a/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php
+++ b/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php
@@ -29,13 +29,13 @@ class UpdatePathRC1TestBaseFilledTest extends UpdatePathRC1TestBaseTest {
$spanish = \Drupal::languageManager()->getLanguage('es');
- $expected_node_data = array(
+ $expected_node_data = [
[1, 'article', 'en', 'Test Article - New title'],
[2, 'book', 'en', 'Book page'],
[3, 'forum', 'en', 'Forum topic'],
[4, 'page', 'en', 'Test page'],
[8, 'test_content_type', 'en', 'Test title'],
- );
+ ];
foreach ($expected_node_data as $node_data) {
$id = $node_data[0];
$type = $node_data[1];
diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php
index 6edbfe3ae97..fe62340af8e 100644
--- a/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php
+++ b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php
@@ -29,13 +29,13 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
$spanish = \Drupal::languageManager()->getLanguage('es');
- $expected_node_data = array(
+ $expected_node_data = [
[1, 'article', 'en', 'Test Article - New title'],
[2, 'book', 'en', 'Book page'],
[3, 'forum', 'en', 'Forum topic'],
[4, 'page', 'en', 'Test page'],
[8, 'test_content_type', 'en', 'Test title'],
- );
+ ];
foreach ($expected_node_data as $node_data) {
$id = $node_data[0];
$type = $node_data[1];
diff --git a/core/modules/system/src/Tests/Update/UpdateScriptTest.php b/core/modules/system/src/Tests/Update/UpdateScriptTest.php
index b80ef82e3bc..12574ee4d4d 100644
--- a/core/modules/system/src/Tests/Update/UpdateScriptTest.php
+++ b/core/modules/system/src/Tests/Update/UpdateScriptTest.php
@@ -18,7 +18,7 @@ class UpdateScriptTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('update_script_test', 'dblog', 'language');
+ public static $modules = ['update_script_test', 'dblog', 'language'];
/**
* {@inheritdoc}
@@ -42,7 +42,7 @@ class UpdateScriptTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$this->updateUrl = Url::fromRoute('system.db_update');
- $this->updateUser = $this->drupalCreateUser(array('administer software updates', 'access site in maintenance mode'));
+ $this->updateUser = $this->drupalCreateUser(['administer software updates', 'access site in maintenance mode']);
\Drupal::service('entity.definition_update_manager')->applyUpdates();
}
@@ -53,7 +53,7 @@ class UpdateScriptTest extends WebTestBase {
// Try accessing update.php without the proper permission.
$regular_user = $this->drupalCreateUser();
$this->drupalLogin($regular_user);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertResponse(403);
// Check that a link to the update page is not accessible to regular users.
@@ -62,7 +62,7 @@ class UpdateScriptTest extends WebTestBase {
// Try accessing update.php as an anonymous user.
$this->drupalLogout();
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertResponse(403);
// Check that a link to the update page is not accessible to anonymous
@@ -72,7 +72,7 @@ class UpdateScriptTest extends WebTestBase {
// Access the update page with the proper permission.
$this->drupalLogin($this->updateUser);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertResponse(200);
// Check that a link to the update page is accessible to users with proper
@@ -82,7 +82,7 @@ class UpdateScriptTest extends WebTestBase {
// Access the update page as user 1.
$this->drupalLogin($this->rootUser);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertResponse(200);
// Check that a link to the update page is accessible to user 1.
@@ -99,7 +99,7 @@ class UpdateScriptTest extends WebTestBase {
// If there are no requirements warnings or errors, we expect to be able to
// go through the update process uninterrupted.
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
@@ -113,7 +113,7 @@ class UpdateScriptTest extends WebTestBase {
// successfully.
$update_script_test_config->set('requirement_type', REQUIREMENT_WARNING)->save();
drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertText('This is a requirements warning provided by the update_script_test module.');
$this->clickLink('try again');
$this->assertNoText('This is a requirements warning provided by the update_script_test module.');
@@ -124,7 +124,7 @@ class UpdateScriptTest extends WebTestBase {
$this->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after resolving a requirements warning and applying updates.');
// Now try again without pending updates to make sure that works too.
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertText('This is a requirements warning provided by the update_script_test module.');
$this->clickLink('try again');
$this->assertNoText('This is a requirements warning provided by the update_script_test module.');
@@ -137,7 +137,7 @@ class UpdateScriptTest extends WebTestBase {
// clicking the link to proceed (since the problem that triggered the error
// has not been fixed).
$update_script_test_config->set('requirement_type', REQUIREMENT_ERROR)->save();
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->assertText('This is a requirements error provided by the update_script_test module.');
$this->clickLink('try again');
$this->assertText('This is a requirements error provided by the update_script_test module.');
@@ -163,7 +163,7 @@ class UpdateScriptTest extends WebTestBase {
function testNoUpdateFunctionality() {
// Click through update.php with 'administer software updates' permission.
$this->drupalLogin($this->updateUser);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'));
$this->assertNoLink('Administration pages');
@@ -172,9 +172,9 @@ class UpdateScriptTest extends WebTestBase {
$this->assertResponse(200);
// Click through update.php with 'access administration pages' permission.
- $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer software updates', 'access administration pages']);
$this->drupalLogin($admin_user);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'));
$this->assertLink('Administration pages');
@@ -204,9 +204,9 @@ class UpdateScriptTest extends WebTestBase {
// Click through update.php with 'access administration pages' and
// 'access site reports' permissions.
- $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode'));
+ $admin_user = $this->drupalCreateUser(['administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode']);
$this->drupalLogin($admin_user);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->clickLink(t('Apply pending updates'));
$this->assertText('Updates were attempted.');
@@ -237,11 +237,11 @@ class UpdateScriptTest extends WebTestBase {
*/
function testSuccessfulMultilingualUpdateFunctionality() {
// Add some custom languages.
- foreach (array('aa', 'bb') as $language_code) {
- ConfigurableLanguage::create(array(
+ foreach (['aa', 'bb'] as $language_code) {
+ ConfigurableLanguage::create([
'id' => $language_code,
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
}
$config = \Drupal::service('config.factory')->getEditable('language.negotiation');
@@ -261,18 +261,18 @@ class UpdateScriptTest extends WebTestBase {
$this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.');
// Create admin user.
- $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode', 'administer site configuration']);
$this->drupalLogin($admin_user);
// Visit status report page and ensure, that link to update.php has no path prefix set.
- $this->drupalGet('en/admin/reports/status', array('external' => TRUE));
+ $this->drupalGet('en/admin/reports/status', ['external' => TRUE]);
$this->assertResponse(200);
$this->assertLinkByHref('/update.php');
$this->assertNoLinkByHref('en/update.php');
// Click through update.php with 'access administration pages' and
// 'access site reports' permissions.
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->clickLink(t('Apply pending updates'));
$this->assertText('Updates were attempted.');
@@ -303,7 +303,7 @@ class UpdateScriptTest extends WebTestBase {
else {
$this->assertNoText('Operating in maintenance mode.');
}
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->clickLink(t('Apply pending updates'));
@@ -330,74 +330,74 @@ class UpdateScriptTest extends WebTestBase {
* Returns the Drupal 7 system table schema.
*/
public function getSystemSchema() {
- return array(
+ return [
'description' => "A list of all modules, themes, and theme engines that are or have been installed in Drupal's file system.",
- 'fields' => array(
- 'filename' => array(
+ 'fields' => [
+ 'filename' => [
'description' => 'The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => 'The name of the item; e.g. node.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'type' => array(
+ ],
+ 'type' => [
'description' => 'The type of the item, either module, theme, or theme_engine.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
- ),
- 'owner' => array(
+ ],
+ 'owner' => [
'description' => "A theme's 'parent' . Can be either a theme or an engine.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'status' => array(
+ ],
+ 'status' => [
'description' => 'Boolean indicating whether or not this item is enabled.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'bootstrap' => array(
+ ],
+ 'bootstrap' => [
'description' => "Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted).",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'schema_version' => array(
+ ],
+ 'schema_version' => [
'description' => "The module's database schema version number. -1 if the module is not installed (its tables do not exist); \Drupal::CORE_MINIMUM_SCHEMA_VERSION or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed.",
'type' => 'int',
'not null' => TRUE,
'default' => -1,
'size' => 'small',
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'description' => "The order in which this module's hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'info' => array(
+ ],
+ 'info' => [
'description' => "A serialized array containing information from the module's .info file; keys can include name, description, package, version, core, dependencies, and php.",
'type' => 'blob',
'not null' => FALSE,
- ),
- ),
- 'primary key' => array('filename'),
- 'indexes' => array(
- 'system_list' => array('status', 'bootstrap', 'type', 'weight', 'name'),
- 'type_name' => array('type', 'name'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['filename'],
+ 'indexes' => [
+ 'system_list' => ['status', 'bootstrap', 'type', 'weight', 'name'],
+ 'type_name' => ['type', 'name'],
+ ],
+ ];
}
}
diff --git a/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php b/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php
index 9782d91c63c..3694cad78a7 100644
--- a/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php
+++ b/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php
@@ -17,7 +17,7 @@ class UpdatesWith7xTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('update_test_with_7x');
+ public static $modules = ['update_test_with_7x'];
/**
* The URL for the update page.
@@ -33,7 +33,7 @@ class UpdatesWith7xTest extends WebTestBase {
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
$this->updateUrl = $GLOBALS['base_url'] . '/update.php';
- $this->updateUser = $this->drupalCreateUser(array('administer software updates'));
+ $this->updateUser = $this->drupalCreateUser(['administer software updates']);
}
function testWith7x() {
@@ -47,7 +47,7 @@ class UpdatesWith7xTest extends WebTestBase {
// Click through update.php with 'administer software updates' permission.
$this->drupalLogin($this->updateUser);
- $this->drupalGet($this->updateUrl, array('external' => TRUE));
+ $this->drupalGet($this->updateUrl, ['external' => TRUE]);
$this->clickLink(t('Continue'));
$this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.'));
}
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index 94f630295ad..799869bbc37 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -49,10 +49,10 @@ function template_preprocess_admin_block_content(&$variables) {
* 'right'.
*/
function template_preprocess_admin_page(&$variables) {
- $variables['system_compact_link'] = array(
+ $variables['system_compact_link'] = [
'#type' => 'system_compact_link',
- );
- $variables['containers'] = array();
+ ];
+ $variables['containers'] = [];
$stripe = 0;
foreach ($variables['blocks'] as $block) {
if (!empty($block['content']['#content'])) {
@@ -60,10 +60,10 @@ function template_preprocess_admin_page(&$variables) {
// Perform automatic striping.
$block['position'] = ++$stripe % 2 ? 'left' : 'right';
}
- $variables['containers'][$block['position']]['blocks'][] = array(
+ $variables['containers'][$block['position']]['blocks'][] = [
'#theme' => 'admin_block',
'#block' => $block,
- );
+ ];
}
}
}
@@ -78,10 +78,10 @@ function template_preprocess_admin_page(&$variables) {
* - menu_items: An array of modules to be displayed.
*/
function template_preprocess_system_admin_index(&$variables) {
- $variables['system_compact_link'] = array(
+ $variables['system_compact_link'] = [
'#type' => 'system_compact_link',
- );
- $variables['containers'] = array();
+ ];
+ $variables['containers'] = [];
$stripe = 0;
// Iterate over all modules.
foreach ($variables['menu_items'] as $module => $block) {
@@ -89,18 +89,18 @@ function template_preprocess_system_admin_index(&$variables) {
$position = ++$stripe % 2 ? 'left' : 'right';
// Output links.
if (count($items)) {
- $variables['containers'][$position][] = array(
+ $variables['containers'][$position][] = [
'#theme' => 'admin_block',
- '#block' => array(
+ '#block' => [
'position' => $position,
'title' => $module,
- 'content' => array(
+ 'content' => [
'#theme' => 'admin_block_content',
'#content' => $items,
- ),
+ ],
'description' => t($description),
- ),
- );
+ ],
+ ];
}
}
}
@@ -241,7 +241,7 @@ function template_preprocess_system_modules_uninstall(&$variables) {
* - theme_group_titles: An associative array containing titles of themes.
*/
function template_preprocess_system_themes_page(&$variables) {
- $groups = array();
+ $groups = [];
$theme_groups = $variables['theme_groups'];
$variables['attributes']['id'] = 'system-themes-page';
@@ -251,33 +251,33 @@ function template_preprocess_system_themes_page(&$variables) {
continue;
}
// Start new theme group.
- $theme_group = array();
+ $theme_group = [];
$theme_group['state'] = $state;
$theme_group['title'] = $title;
- $theme_group['themes'] = array();
+ $theme_group['themes'] = [];
$theme_group['attributes'] = new Attribute();
foreach ($theme_groups[$state] as $theme) {
- $current_theme = array();
+ $current_theme = [];
// Screenshot depicting the theme.
if ($theme->screenshot) {
- $current_theme['screenshot'] = array(
+ $current_theme['screenshot'] = [
'#theme' => 'image',
'#uri' => $theme->screenshot['uri'],
'#alt' => $theme->screenshot['alt'],
'#title' => $theme->screenshot['title'],
'#attributes' => $theme->screenshot['attributes'],
- );
+ ];
}
else {
- $current_theme['screenshot'] = array(
+ $current_theme['screenshot'] = [
'#theme' => 'image',
'#uri' => drupal_get_path('module', 'system') . '/images/no_screenshot.png',
'#alt' => t('No screenshot'),
'#title' => t('No screenshot'),
- '#attributes' => new Attribute(array('class' => array('no-screenshot'))),
- );
+ '#attributes' => new Attribute(['class' => ['no-screenshot']]),
+ ];
}
// Localize the theme description.
@@ -302,23 +302,23 @@ function template_preprocess_system_themes_page(&$variables) {
if (substr_count($theme->info['php'], '.') < 2) {
$theme->info['php'] .= '.*';
}
- $current_theme['incompatible'] = t('This theme requires PHP version @php_required and is incompatible with PHP version @php_version.', array('@php_required' => $theme->info['php'], '@php_version' => phpversion()));
+ $current_theme['incompatible'] = t('This theme requires PHP version @php_required and is incompatible with PHP version @php_version.', ['@php_required' => $theme->info['php'], '@php_version' => phpversion()]);
}
elseif (!empty($theme->incompatible_base)) {
- $current_theme['incompatible'] = t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => $theme->info['base theme']));
+ $current_theme['incompatible'] = t('This theme requires the base theme @base_theme to operate correctly.', ['@base_theme' => $theme->info['base theme']]);
}
elseif (!empty($theme->incompatible_engine)) {
- $current_theme['incompatible'] = t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => $theme->info['engine']));
+ $current_theme['incompatible'] = t('This theme requires the theme engine @theme_engine to operate correctly.', ['@theme_engine' => $theme->info['engine']]);
}
// Build operation links.
- $current_theme['operations'] = array(
+ $current_theme['operations'] = [
'#theme' => 'links',
'#links' => $theme->operations,
- '#attributes' => array(
- 'class' => array('operations', 'clearfix'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['operations', 'clearfix'],
+ ],
+ ];
$theme_group['themes'][] = $current_theme;
}
$groups[] = $theme_group;
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 8534ebf7080..7951ecd21f8 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -24,11 +24,11 @@ function hook_system_themes_page_alter(&$theme_groups) {
foreach ($theme_groups as $state => &$group) {
foreach ($theme_groups[$state] as &$theme) {
// Add a foo link to each list of theme operations.
- $theme->operations[] = array(
+ $theme->operations[] = [
'title' => t('Foo'),
'url' => Url::fromRoute('system.themes_page'),
- 'query' => array('theme' => $theme->getName())
- );
+ 'query' => ['theme' => $theme->getName()]
+ ];
}
}
}
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index c4067ef3bbc..fadf17fdc60 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -27,36 +27,36 @@ use Symfony\Component\HttpFoundation\Request;
*/
function system_requirements($phase) {
global $install_state;
- $requirements = array();
+ $requirements = [];
// Report Drupal version
if ($phase == 'runtime') {
- $requirements['drupal'] = array(
+ $requirements['drupal'] = [
'title' => t('Drupal'),
'value' => \Drupal::VERSION,
'severity' => REQUIREMENT_INFO,
'weight' => -10,
- );
+ ];
// Display the currently active installation profile, if the site
// is not running the default installation profile.
$profile = drupal_get_profile();
if ($profile != 'standard') {
$info = system_get_info('module', $profile);
- $requirements['install_profile'] = array(
+ $requirements['install_profile'] = [
'title' => t('Installation profile'),
- 'value' => t('%profile_name (%profile-%version)', array(
+ 'value' => t('%profile_name (%profile-%version)', [
'%profile_name' => $info['name'],
'%profile' => $profile,
'%version' => $info['version']
- )),
+ ]),
'severity' => REQUIREMENT_INFO,
'weight' => -9
- );
+ ];
}
// Warn if any experimental modules are installed.
- $experimental = array();
+ $experimental = [];
$enabled_modules = \Drupal::moduleHandler()->getModuleList();
foreach ($enabled_modules as $module => $data) {
$info = system_get_info('module', $module);
@@ -65,20 +65,20 @@ function system_requirements($phase) {
}
}
if (!empty($experimental)) {
- $requirements['experimental'] = array(
+ $requirements['experimental'] = [
'title' => t('Experimental modules enabled'),
- 'value' => t('Experimental modules found: %module_list. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', array('%module_list' => implode(', ', $experimental), ':url' => 'https://www.drupal.org/core/experimental')),
+ 'value' => t('Experimental modules found: %module_list. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', ['%module_list' => implode(', ', $experimental), ':url' => 'https://www.drupal.org/core/experimental']),
'severity' => REQUIREMENT_WARNING,
- );
+ ];
}
}
// Web server information.
$software = \Drupal::request()->server->get('SERVER_SOFTWARE');
- $requirements['webserver'] = array(
+ $requirements['webserver'] = [
'title' => t('Web server'),
'value' => $software,
- );
+ ];
// Tests clean URL support.
if ($phase == 'install' && $install_state['interactive'] && !isset($_GET['rewrite']) && strpos($software, 'Apache') !== FALSE) {
@@ -127,30 +127,30 @@ function system_requirements($phase) {
}
if ($rewrite_warning) {
- $requirements['apache_version'] = array (
+ $requirements['apache_version'] = [
'title' => t('Apache version'),
'value' => $apache_version_string,
'severity' => REQUIREMENT_WARNING,
- 'description' => t('Due to the settings for ServerTokens in httpd.conf, it is impossible to accurately determine the version of Apache running on this server. The reported value is @reported, to run Drupal without mod_rewrite, a minimum version of 2.2.16 is needed.', array('@reported' => $apache_version_string)),
- );
+ 'description' => t('Due to the settings for ServerTokens in httpd.conf, it is impossible to accurately determine the version of Apache running on this server. The reported value is @reported, to run Drupal without mod_rewrite, a minimum version of 2.2.16 is needed.', ['@reported' => $apache_version_string]),
+ ];
}
if ($rewrite_error) {
- $requirements['Apache version'] = array (
+ $requirements['Apache version'] = [
'title' => t('Apache version'),
'value' => $apache_version_string,
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The minimum version of Apache needed to run Drupal without mod_rewrite enabled is 2.2.16. See the <a href=":link">enabling clean URLs</a> page for more information on mod_rewrite.', array(':link' => 'http://drupal.org/node/15365')),
- );
+ 'description' => t('The minimum version of Apache needed to run Drupal without mod_rewrite enabled is 2.2.16. See the <a href=":link">enabling clean URLs</a> page for more information on mod_rewrite.', [':link' => 'http://drupal.org/node/15365']),
+ ];
}
if (!$rewrite_error && !$rewrite_warning) {
- $requirements['rewrite_module'] = array (
+ $requirements['rewrite_module'] = [
'title' => t('Clean URLs'),
'value' => t('Disabled'),
'severity' => REQUIREMENT_WARNING,
- 'description' => t('Your server is capable of using clean URLs, but it is not enabled. Using clean URLs gives an improved user experience and is recommended. <a href=":link">Enable clean URLs</a>', array(':link' => 'http://drupal.org/node/15365')),
- );
+ 'description' => t('Your server is capable of using clean URLs, but it is not enabled. Using clean URLs gives an improved user experience and is recommended. <a href=":link">Enable clean URLs</a>', [':link' => 'http://drupal.org/node/15365']),
+ ];
}
}
@@ -160,22 +160,22 @@ function system_requirements($phase) {
if ($phase === 'runtime') {
$phpversion_label = t('@phpversion (<a href=":url">more information</a>)', ['@phpversion' => $phpversion, ':url' => (new Url('system.php'))->toString()]);
}
- $requirements['php'] = array(
+ $requirements['php'] = [
'title' => t('PHP'),
'value' => $phpversion_label,
- );
+ ];
}
else {
- $requirements['php'] = array(
+ $requirements['php'] = [
'title' => t('PHP'),
'value' => $phpversion_label,
- 'description' => t('The phpinfo() function has been disabled for security reasons. To see your server\'s phpinfo() information, change your PHP settings or contact your server administrator. For more information, <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', array(':phpinfo' => 'https://www.drupal.org/node/243993')),
+ 'description' => t('The phpinfo() function has been disabled for security reasons. To see your server\'s phpinfo() information, change your PHP settings or contact your server administrator. For more information, <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [':phpinfo' => 'https://www.drupal.org/node/243993']),
'severity' => REQUIREMENT_INFO,
- );
+ ];
}
if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) {
- $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
+ $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]);
$requirements['php']['severity'] = REQUIREMENT_ERROR;
// If PHP is old, it's not safe to continue with the requirements check.
return $requirements;
@@ -184,21 +184,21 @@ function system_requirements($phase) {
// Suggest to update to at least 5.5.21 or 5.6.5 for disabling multiple
// statements.
if (($phase === 'install' || \Drupal::database()->driver() === 'mysql') && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) {
- $requirements['php'] = array(
+ $requirements['php'] = [
'title' => t('PHP (multiple statement disabling)'),
'value' => $phpversion_label,
'description' => t('PHP versions higher than 5.6.5 or 5.5.21 provide built-in SQL injection protection for mysql databases. It is recommended to update.'),
'severity' => REQUIREMENT_INFO,
- );
+ ];
}
// Test for PHP extensions.
- $requirements['php_extensions'] = array(
+ $requirements['php_extensions'] = [
'title' => t('PHP extensions'),
- );
+ ];
- $missing_extensions = array();
- $required_extensions = array(
+ $missing_extensions = [];
+ $required_extensions = [
'date',
'dom',
'filter',
@@ -212,7 +212,7 @@ function system_requirements($phase) {
'SPL',
'tokenizer',
'xml',
- );
+ ];
foreach ($required_extensions as $extension) {
if (!extension_loaded($extension)) {
$missing_extensions[] = $extension;
@@ -220,22 +220,22 @@ function system_requirements($phase) {
}
if (!empty($missing_extensions)) {
- $description = t('Drupal requires you to enable the PHP extensions in the following list (see the <a href=":system_requirements">system requirements page</a> for more information):', array(
+ $description = t('Drupal requires you to enable the PHP extensions in the following list (see the <a href=":system_requirements">system requirements page</a> for more information):', [
':system_requirements' => 'https://www.drupal.org/requirements',
- ));
+ ]);
// We use twig inline_template to avoid twig's autoescape.
- $description = array(
+ $description = [
'#type' => 'inline_template',
'#template' => '{{ description }}{{ missing_extensions }}',
- '#context' => array(
+ '#context' => [
'description' => $description,
- 'missing_extensions' => array(
+ 'missing_extensions' => [
'#theme' => 'item_list',
'#items' => $missing_extensions,
- ),
- ),
- );
+ ],
+ ],
+ ];
$requirements['php_extensions']['value'] = t('Disabled');
$requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
@@ -248,11 +248,11 @@ function system_requirements($phase) {
if ($phase == 'install' || $phase == 'runtime') {
// Check to see if OPcache is installed.
if (!OpCodeCache::isEnabled()) {
- $requirements['php_opcache'] = array(
+ $requirements['php_opcache'] = [
'value' => t('Not enabled'),
'severity' => REQUIREMENT_WARNING,
'description' => t('PHP OPcode caching can improve your site\'s performance considerably. It is <strong>highly recommended</strong> to have <a href="http://php.net/manual/opcache.installation.php" target="_blank">OPcache</a> installed on your server.'),
- );
+ ];
}
else {
$requirements['php_opcache']['value'] = t('Enabled');
@@ -262,13 +262,13 @@ function system_requirements($phase) {
if ($phase != 'update') {
// Test whether we have a good source of random bytes.
- $requirements['php_random_bytes'] = array(
+ $requirements['php_random_bytes'] = [
'title' => t('Random number generation'),
- );
+ ];
try {
$bytes = random_bytes(10);
if (strlen($bytes) != 10) {
- throw new \Exception(t('Tried to generate 10 random bytes, generated @count', array('@count' => strlen($bytes))));
+ throw new \Exception(t('Tried to generate 10 random bytes, generated @count', ['@count' => strlen($bytes)]));
}
$requirements['php_random_bytes']['value'] = t('Successful');
}
@@ -280,13 +280,13 @@ function system_requirements($phase) {
$open_basedir = ini_get('open_basedir');
if ($open_basedir) {
$open_basedir_paths = explode(PATH_SEPARATOR, $open_basedir);
- $open_basedir_blocks_urandom = !array_intersect(array('/dev', '/dev/', '/dev/urandom'), $open_basedir_paths);
+ $open_basedir_blocks_urandom = !array_intersect(['/dev', '/dev/', '/dev/urandom'], $open_basedir_paths);
}
}
- $args = array(
+ $args = [
':drupal-php' => 'https://www.drupal.org/docs/7/system-requirements/php#csprng',
'%exception_message' => $e->getMessage(),
- );
+ ];
if ($open_basedir_blocks_urandom) {
$requirements['php_random_bytes']['description'] = t('Drupal is unable to generate highly randomized numbers, which means certain security features like password reset URLs are not as secure as they should be. Instead, only a slow, less-secure fallback generator is available. The most likely cause is that open_basedir restrictions are in effect and /dev/urandom is not on the whitelist. See the <a href=":drupal-php">system requirements</a> page for more information. %exception_message', $args);
}
@@ -300,33 +300,33 @@ function system_requirements($phase) {
if ($phase == 'install' || $phase == 'update') {
// Test for PDO (database).
- $requirements['database_extensions'] = array(
+ $requirements['database_extensions'] = [
'title' => t('Database support'),
- );
+ ];
// Make sure PDO is available.
$database_ok = extension_loaded('pdo');
if (!$database_ok) {
- $pdo_message = t('Your web server does not appear to support PDO (PHP Data Objects). Ask your hosting provider if they support the native PDO extension. See the <a href=":link">system requirements</a> page for more information.', array(
+ $pdo_message = t('Your web server does not appear to support PDO (PHP Data Objects). Ask your hosting provider if they support the native PDO extension. See the <a href=":link">system requirements</a> page for more information.', [
':link' => 'https://www.drupal.org/requirements/pdo',
- ));
+ ]);
}
else {
// Make sure at least one supported database driver exists.
$drivers = drupal_detect_database_types();
if (empty($drivers)) {
$database_ok = FALSE;
- $pdo_message = t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href=":drupal-databases">Drupal supports</a>.', array(
+ $pdo_message = t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href=":drupal-databases">Drupal supports</a>.', [
':drupal-databases' => 'https://www.drupal.org/requirements/database',
- ));
+ ]);
}
// Make sure the native PDO extension is available, not the older PEAR
// version. (See install_verify_pdo() for details.)
if (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) {
$database_ok = FALSE;
- $pdo_message = t('Your web server seems to have the wrong version of PDO installed. Drupal requires the PDO extension from PHP core. This system has the older PECL version. See the <a href=":link">system requirements</a> page for more information.', array(
+ $pdo_message = t('Your web server seems to have the wrong version of PDO installed. Drupal requires the PDO extension from PHP core. This system has the older PECL version. See the <a href=":link">system requirements</a> page for more information.', [
':link' => 'https://www.drupal.org/requirements/pdo#pecl',
- ));
+ ]);
}
}
@@ -343,54 +343,54 @@ function system_requirements($phase) {
// Database information.
$class = Database::getConnection()->getDriverClass('Install\\Tasks');
$tasks = new $class();
- $requirements['database_system'] = array(
+ $requirements['database_system'] = [
'title' => t('Database system'),
'value' => $tasks->name(),
- );
- $requirements['database_system_version'] = array(
+ ];
+ $requirements['database_system_version'] = [
'title' => t('Database system version'),
'value' => Database::getConnection()->version(),
- );
+ ];
}
// Test PHP memory_limit
$memory_limit = ini_get('memory_limit');
- $requirements['php_memory_limit'] = array(
+ $requirements['php_memory_limit'] = [
'title' => t('PHP memory limit'),
'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
- );
+ ];
if (!Environment::checkMemoryLimit(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
- $description = array();
+ $description = [];
if ($phase == 'install') {
- $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
+ $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', ['%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]);
}
elseif ($phase == 'update') {
- $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
+ $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', ['%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]);
}
elseif ($phase == 'runtime') {
- $description['phase'] = t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
+ $description['phase'] = t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', ['%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]);
}
if (!empty($description['phase'])) {
if ($php_ini_path = get_cfg_var('cfg_file_path')) {
- $description['memory'] = t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array('%configuration-file' => $php_ini_path));
+ $description['memory'] = t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', ['%configuration-file' => $php_ini_path]);
}
else {
$description['memory'] = t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
}
- $handbook_link = t('For more information, see the online handbook entry for <a href=":memory-limit">increasing the PHP memory limit</a>.', array(':memory-limit' => 'https://www.drupal.org/node/207036'));
+ $handbook_link = t('For more information, see the online handbook entry for <a href=":memory-limit">increasing the PHP memory limit</a>.', [':memory-limit' => 'https://www.drupal.org/node/207036']);
- $description = array(
+ $description = [
'#type' => 'inline_template',
'#template' => '{{ description_phase }} {{ description_memory }} {{ handbook }}',
- '#context' => array(
+ '#context' => [
'description_phase' => $description['phase'],
'description_memory' => $description['memory'],
'handbook' => $handbook_link,
- ),
- );
+ ],
+ ];
$requirements['php_memory_limit']['description'] = $description;
$requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
@@ -399,7 +399,7 @@ function system_requirements($phase) {
// Test configuration files and directory for writability.
if ($phase == 'runtime') {
- $conf_errors = array();
+ $conf_errors = [];
// Find the site path. Kernel service is not always available at this point,
// but is preferred, when available.
if (\Drupal::hasService('kernel')) {
@@ -421,13 +421,13 @@ function system_requirements($phase) {
// In normal operation, writable files or directories are an error.
$file_protection_severity = REQUIREMENT_ERROR;
if (!drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')) {
- $conf_errors[] = t("The directory %file is not protected from modifications and poses a security risk. You must change the directory's permissions to be non-writable.", array('%file' => $site_path));
+ $conf_errors[] = t("The directory %file is not protected from modifications and poses a security risk. You must change the directory's permissions to be non-writable.", ['%file' => $site_path]);
}
}
- foreach (array('settings.php', 'settings.local.php', 'services.yml') as $conf_file) {
+ foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) {
$full_path = $site_path . '/' . $conf_file;
if (file_exists($full_path) && (Settings::get('skip_permissions_hardening') || !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE))) {
- $conf_errors[] = t("The file %file is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.", array('%file' => $full_path));
+ $conf_errors[] = t("The file %file is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.", ['%file' => $full_path]);
}
}
if (!empty($conf_errors)) {
@@ -436,27 +436,27 @@ function system_requirements($phase) {
}
else {
// We use twig inline_template to avoid double escaping.
- $description = array(
+ $description = [
'#type' => 'inline_template',
'#template' => '{{ configuration_error_list }}',
- '#context' => array(
- 'configuration_error_list' => array(
+ '#context' => [
+ 'configuration_error_list' => [
'#theme' => 'item_list',
'#items' => $conf_errors,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
- $requirements['configuration_files'] = array(
+ $requirements['configuration_files'] = [
'value' => t('Not protected'),
'severity' => $file_protection_severity,
'description' => $description,
- );
+ ];
}
else {
- $requirements['configuration_files'] = array(
+ $requirements['configuration_files'] = [
'value' => t('Protected'),
- );
+ ];
}
$requirements['configuration_files']['title'] = t('Configuration files');
}
@@ -466,31 +466,31 @@ function system_requirements($phase) {
// Try to write the .htaccess files first, to prevent false alarms in case
// (for example) the /tmp directory was wiped.
file_ensure_htaccess();
- $htaccess_files['public://.htaccess'] = array(
+ $htaccess_files['public://.htaccess'] = [
'title' => t('Public files directory'),
'directory' => drupal_realpath('public://'),
- );
+ ];
if (PrivateStream::basePath()) {
- $htaccess_files['private://.htaccess'] = array(
+ $htaccess_files['private://.htaccess'] = [
'title' => t('Private files directory'),
'directory' => drupal_realpath('private://'),
- );
+ ];
}
- $htaccess_files['temporary://.htaccess'] = array(
+ $htaccess_files['temporary://.htaccess'] = [
'title' => t('Temporary files directory'),
'directory' => drupal_realpath('temporary://'),
- );
+ ];
foreach ($htaccess_files as $htaccess_file => $info) {
// Check for the string which was added to the recommended .htaccess file
// in the latest security update.
if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
$url = 'https://www.drupal.org/SA-CORE-2013-003';
- $requirements[$htaccess_file] = array(
+ $requirements[$htaccess_file] = [
'title' => $info['title'],
'value' => t('Not fully protected'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('See <a href=":url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', array(':url' => $url, '@url' => $url, '%directory' => $info['directory'])),
- );
+ 'description' => t('See <a href=":url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', [':url' => $url, '@url' => $url, '%directory' => $info['directory']]),
+ ];
}
}
}
@@ -519,13 +519,13 @@ function system_requirements($phase) {
}
// Set summary and description based on values determined above.
- $summary = t('Last run @time ago', array('@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
+ $summary = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
- $requirements['cron'] = array(
+ $requirements['cron'] = [
'title' => t('Cron maintenance tasks'),
'severity' => $severity,
'value' => $summary,
- );
+ ];
if ($severity != REQUIREMENT_INFO) {
$requirements['cron']['description'][] = [
[
@@ -557,19 +557,19 @@ function system_requirements($phase) {
}
if ($phase != 'install') {
$filesystem_config = \Drupal::config('system.file');
- $directories = array(
+ $directories = [
PublicStream::basePath(),
// By default no private files directory is configured. For private files
// to be secure the admin needs to provide a path outside the webroot.
PrivateStream::basePath(),
file_directory_temp(),
- );
+ ];
}
// During an install we need to make assumptions about the file system
// unless overrides are provided in settings.php.
if ($phase == 'install') {
- $directories = array();
+ $directories = [];
if ($file_public_path = Settings::get('file_public_path')) {
$directories[] = $file_public_path;
}
@@ -605,31 +605,31 @@ function system_requirements($phase) {
}
if (!is_dir($directory)) {
if ($phase == 'install') {
- $description = t('An automated attempt to create the directory %directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', array('%directory' => $directory, ':handbook_url' => 'https://www.drupal.org/server-permissions'));
+ $description = t('An automated attempt to create the directory %directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', ['%directory' => $directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']);
}
else {
- $description = t('The directory %directory does not exist.', array('%directory' => $directory));
+ $description = t('The directory %directory does not exist.', ['%directory' => $directory]);
}
- $requirements['config directory ' . $type] = array(
+ $requirements['config directory ' . $type] = [
'title' => t('Configuration directory: %type', ['%type' => $type]),
'description' => $description,
'severity' => REQUIREMENT_ERROR,
- );
+ ];
}
}
}
if ($phase != 'install' && (empty($GLOBALS['config_directories']) || empty($GLOBALS['config_directories'][CONFIG_SYNC_DIRECTORY]) )) {
- $requirements['config directories'] = array(
+ $requirements['config directories'] = [
'title' => t('Configuration directories'),
'value' => t('Not present'),
- 'description' => t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', array('%file' => $site_path . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY)),
+ 'description' => t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', ['%file' => $site_path . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY]),
'severity' => REQUIREMENT_ERROR,
- );
+ ];
}
- $requirements['file system'] = array(
+ $requirements['file system'] = [
'title' => t('File system'),
- );
+ ];
$error = '';
// For installer, create the directories if possible.
@@ -646,30 +646,30 @@ function system_requirements($phase) {
$description = '';
$requirements['file system']['value'] = t('Not writable');
if (!$is_directory) {
- $error = t('The directory %directory does not exist.', array('%directory' => $directory));
+ $error = t('The directory %directory does not exist.', ['%directory' => $directory]);
}
else {
- $error = t('The directory %directory is not writable.', array('%directory' => $directory));
+ $error = t('The directory %directory is not writable.', ['%directory' => $directory]);
}
// The files directory requirement check is done only during install and runtime.
if ($phase == 'runtime') {
- $description = t('You may need to set the correct directory at the <a href=":admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', array(':admin-file-system' => \Drupal::url('system.file_system_settings')));
+ $description = t('You may need to set the correct directory at the <a href=":admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', [':admin-file-system' => \Drupal::url('system.file_system_settings')]);
}
elseif ($phase == 'install') {
// For the installer UI, we need different wording. 'value' will
// be treated as version, so provide none there.
- $description = t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', array(':handbook_url' => 'https://www.drupal.org/server-permissions'));
+ $description = t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', [':handbook_url' => 'https://www.drupal.org/server-permissions']);
$requirements['file system']['value'] = '';
}
if (!empty($description)) {
- $description = array(
+ $description = [
'#type' => 'inline_template',
'#template' => '{{ error }} {{ description }}',
- '#context' => array(
+ '#context' => [
'error' => $error,
'description' => $description,
- ),
- );
+ ],
+ ];
$requirements['file system']['description'] = $description;
$requirements['file system']['severity'] = REQUIREMENT_ERROR;
}
@@ -688,10 +688,10 @@ function system_requirements($phase) {
// See if updates are available in update.php.
if ($phase == 'runtime') {
- $requirements['update'] = array(
+ $requirements['update'] = [
'title' => t('Database updates'),
'value' => t('Up to date'),
- );
+ ];
// Check installed modules.
$has_pending_updates = FALSE;
@@ -717,7 +717,7 @@ function system_requirements($phase) {
if ($has_pending_updates) {
$requirements['update']['severity'] = REQUIREMENT_ERROR;
$requirements['update']['value'] = t('Out of date');
- $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', array(':update' => \Drupal::url('system.db_update')));
+ $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [':update' => \Drupal::url('system.db_update')]);
}
$requirements['entity_update'] = [
@@ -746,16 +746,16 @@ function system_requirements($phase) {
// Verify the update.php access setting
if ($phase == 'runtime') {
if (Settings::get('update_free_access')) {
- $requirements['update access'] = array(
+ $requirements['update access'] = [
'value' => t('Not protected'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the @settings_name value in your settings.php back to FALSE.', array('@settings_name' => '$settings[\'update_free_access\']')),
- );
+ 'description' => t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the @settings_name value in your settings.php back to FALSE.', ['@settings_name' => '$settings[\'update_free_access\']']),
+ ];
}
else {
- $requirements['update access'] = array(
+ $requirements['update access'] = [
'value' => t('Protected'),
- );
+ ];
}
$requirements['update access']['title'] = t('Access to update.php');
}
@@ -773,7 +773,7 @@ function system_requirements($phase) {
$name = $file->info['name'];
$php = $file->info['php'];
if (version_compare($php, PHP_VERSION, '>')) {
- $requirements['php']['description'] .= t('@name requires at least PHP @version.', array('@name' => $name, '@version' => $php));
+ $requirements['php']['description'] .= t('@name requires at least PHP @version.', ['@name' => $name, '@version' => $php]);
$requirements['php']['severity'] = REQUIREMENT_ERROR;
}
// Check the module's required modules.
@@ -781,12 +781,12 @@ function system_requirements($phase) {
$required_module = $requirement['name'];
// Check if the module exists.
if (!isset($files[$required_module])) {
- $requirements["$module-$required_module"] = array(
+ $requirements["$module-$required_module"] = [
'title' => t('Unresolved dependency'),
- 'description' => t('@name requires this module.', array('@name' => $name)),
- 'value' => t('@required_name (Missing)', array('@required_name' => $required_module)),
+ 'description' => t('@name requires this module.', ['@name' => $name]),
+ 'value' => t('@required_name (Missing)', ['@required_name' => $required_module]),
'severity' => REQUIREMENT_ERROR,
- );
+ ];
continue;
}
// Check for an incompatible version.
@@ -796,12 +796,12 @@ function system_requirements($phase) {
$compatibility = drupal_check_incompatibility($requirement, $version);
if ($compatibility) {
$compatibility = rtrim(substr($compatibility, 2), ')');
- $requirements["$module-$required_module"] = array(
+ $requirements["$module-$required_module"] = [
'title' => t('Unresolved dependency'),
- 'description' => t('@name requires this module and version. Currently using @required_name version @version', array('@name' => $name, '@required_name' => $required_name, '@version' => $version)),
- 'value' => t('@required_name (Version @compatibility required)', array('@required_name' => $required_name, '@compatibility' => $compatibility)),
+ 'description' => t('@name requires this module and version. Currently using @required_name version @version', ['@name' => $name, '@required_name' => $required_name, '@version' => $version]),
+ 'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $compatibility]),
'severity' => REQUIREMENT_ERROR,
- );
+ ];
continue;
}
}
@@ -815,29 +815,29 @@ function system_requirements($phase) {
if ($phase == 'runtime') {
// Check for update status module.
if (!\Drupal::moduleHandler()->moduleExists('update')) {
- $requirements['update status'] = array(
+ $requirements['update status'] = [
'value' => t('Not enabled'),
'severity' => REQUIREMENT_WARNING,
- 'description' => t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the Update Manager module from the <a href=":module">module administration page</a> in order to stay up-to-date on new releases. For more information, <a href=":update">Update status handbook page</a>.', array(
+ 'description' => t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the Update Manager module from the <a href=":module">module administration page</a> in order to stay up-to-date on new releases. For more information, <a href=":update">Update status handbook page</a>.', [
':update' => 'https://www.drupal.org/documentation/modules/update',
':module' => \Drupal::url('system.modules_list'),
- )),
- );
+ ]),
+ ];
}
else {
- $requirements['update status'] = array(
+ $requirements['update status'] = [
'value' => t('Enabled'),
- );
+ ];
}
$requirements['update status']['title'] = t('Update notifications');
if (Settings::get('rebuild_access')) {
- $requirements['rebuild access'] = array(
+ $requirements['rebuild access'] = [
'title' => t('Rebuild access'),
'value' => t('Enabled'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The rebuild_access setting is enabled in settings.php. It is recommended to have this setting disabled unless you are performing a rebuild.'),
- );
+ ];
}
}
@@ -846,19 +846,19 @@ function system_requirements($phase) {
if ($phase == 'runtime') {
$trusted_host_patterns = Settings::get('trusted_host_patterns');
if (empty($trusted_host_patterns)) {
- $requirements['trusted_host_patterns'] = array(
+ $requirements['trusted_host_patterns'] = [
'title' => t('Trusted Host Settings'),
'value' => t('Not enabled'),
- 'description' => t('The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is <strong>highly recommended</strong> that you configure this. See <a href=":url">Protecting against HTTP HOST Header attacks</a> for more information.', array(':url' => 'https://www.drupal.org/node/1992030')),
+ 'description' => t('The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is <strong>highly recommended</strong> that you configure this. See <a href=":url">Protecting against HTTP HOST Header attacks</a> for more information.', [':url' => 'https://www.drupal.org/node/1992030']),
'severity' => REQUIREMENT_ERROR,
- );
+ ];
}
else {
- $requirements['trusted_host_patterns'] = array(
+ $requirements['trusted_host_patterns'] = [
'title' => t('Trusted Host Settings'),
'value' => t('Enabled'),
- 'description' => t('The trusted_host_patterns setting is set to allow %trusted_host_patterns', array('%trusted_host_patterns' => join(', ', $trusted_host_patterns))),
- );
+ 'description' => t('The trusted_host_patterns setting is set to allow %trusted_host_patterns', ['%trusted_host_patterns' => join(', ', $trusted_host_patterns)]),
+ ];
}
}
@@ -954,133 +954,133 @@ function system_install() {
* Implements hook_schema().
*/
function system_schema() {
- $schema['key_value'] = array(
+ $schema['key_value'] = [
'description' => 'Generic key-value storage table. See the state system for an example.',
- 'fields' => array(
- 'collection' => array(
+ 'fields' => [
+ 'collection' => [
'description' => 'A named collection of key and value pairs.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
- ),
- 'value' => array(
+ ],
+ 'value' => [
'description' => 'The value.',
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
- ),
- ),
- 'primary key' => array('collection', 'name'),
- );
+ ],
+ ],
+ 'primary key' => ['collection', 'name'],
+ ];
- $schema['key_value_expire'] = array(
+ $schema['key_value_expire'] = [
'description' => 'Generic key/value storage table with an expiration.',
- 'fields' => array(
- 'collection' => array(
+ 'fields' => [
+ 'collection' => [
'description' => 'A named collection of key and value pairs.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
- ),
- 'name' => array(
+ ],
+ 'name' => [
// KEY is an SQL reserved word, so use 'name' as the key's field name.
'description' => 'The key of the key/value pair.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
- ),
- 'value' => array(
+ ],
+ 'value' => [
'description' => 'The value of the key/value pair.',
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
- ),
- 'expire' => array(
+ ],
+ 'expire' => [
'description' => 'The time since Unix epoch in seconds when this item expires. Defaults to the maximum possible time.',
'type' => 'int',
'not null' => TRUE,
'default' => 2147483647,
- ),
- ),
- 'primary key' => array('collection', 'name'),
- 'indexes' => array(
- 'all' => array('name', 'collection', 'expire'),
- 'expire' => array('expire'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['collection', 'name'],
+ 'indexes' => [
+ 'all' => ['name', 'collection', 'expire'],
+ 'expire' => ['expire'],
+ ],
+ ];
- $schema['sequences'] = array(
+ $schema['sequences'] = [
'description' => 'Stores IDs.',
- 'fields' => array(
- 'value' => array(
+ 'fields' => [
+ 'value' => [
'description' => 'The value of the sequence.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('value'),
- );
+ ],
+ ],
+ 'primary key' => ['value'],
+ ];
- $schema['sessions'] = array(
+ $schema['sessions'] = [
'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
- 'fields' => array(
- 'uid' => array(
+ 'fields' => [
+ 'uid' => [
'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'sid' => array(
+ ],
+ 'sid' => [
'description' => "A session ID (hashed). The value is generated by Drupal's session handlers.",
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
- ),
- 'hostname' => array(
+ ],
+ 'hostname' => [
'description' => 'The IP address that last used this session ID (sid).',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
- ),
- 'timestamp' => array(
+ ],
+ 'timestamp' => [
'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'session' => array(
+ ],
+ 'session' => [
'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
- ),
- ),
- 'primary key' => array(
+ ],
+ ],
+ 'primary key' => [
'sid',
- ),
- 'indexes' => array(
- 'timestamp' => array('timestamp'),
- 'uid' => array('uid'),
- ),
- 'foreign keys' => array(
- 'session_user' => array(
+ ],
+ 'indexes' => [
+ 'timestamp' => ['timestamp'],
+ 'uid' => ['uid'],
+ ],
+ 'foreign keys' => [
+ 'session_user' => [
'table' => 'users',
- 'columns' => array('uid' => 'uid'),
- ),
- ),
- );
+ 'columns' => ['uid' => 'uid'],
+ ],
+ ],
+ ];
// Create the url_alias table. The alias_storage service can auto-create its
// table, but this relies on exceptions being thrown. These exceptions will be
@@ -1107,38 +1107,38 @@ function system_update_8001(&$sandbox = NULL) {
// Converting directly to blob can cause problems with reading out and
// serializing the string data later on postgres, so rename the existing
// columns and create replacement ones to hold the serialized objects.
- $old_fields = array(
- 'title' => array(
+ $old_fields = [
+ 'title' => [
'description' => 'The text displayed for the link.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'description' => array(
+ ],
+ 'description' => [
'description' => 'The description of this link - used for admin pages and title attribute.',
'type' => 'text',
'not null' => FALSE,
- ),
- );
+ ],
+ ];
foreach ($old_fields as $name => $spec) {
$schema->changeField('menu_tree', $name, 'system_update_8001_' . $name, $spec);
}
- $spec = array(
+ $spec = [
'description' => 'The title for the link. May be a serialized TranslatableMarkup.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
- );
+ ];
$schema->addField('menu_tree', 'title', $spec);
- $spec = array(
+ $spec = [
'description' => 'The description of this link - used for admin pages and title attribute.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
- );
+ ];
$schema->addField('menu_tree', 'description', $spec);
$sandbox['current'] = 0;
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index b6f97747d7c..a1a6b715a3a 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -95,29 +95,29 @@ function system_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.system':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The System module is integral to the site: it provides user interfaces for many core systems and settings, as well as the basic administrative menu structure. For more information, see the <a href=":system">online documentation for the System module</a>.', array(':system' => 'https://www.drupal.org/documentation/modules/system')) . '</p>';
+ $output .= '<p>' . t('The System module is integral to the site: it provides user interfaces for many core systems and settings, as well as the basic administrative menu structure. For more information, see the <a href=":system">online documentation for the System module</a>.', [':system' => 'https://www.drupal.org/documentation/modules/system']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing modules') . '</dt>';
- $output .= '<dd>' . t('Users with appropriate permission can install and uninstall modules from the <a href=":modules">Extend page</a>. Depending on which distribution or installation profile you choose when you install your site, several modules are installed and others are provided but not installed. Each module provides a discrete set of features; modules may be installed or uninstalled depending on the needs of the site. Many additional modules contributed by members of the Drupal community are available for download from the <a href=":drupal-modules">Drupal.org module page</a>. Note that uninstalling a module is a destructive action: when you uninstall a module, you will permanently lose all data connected to the module.', array(':modules' => \Drupal::url('system.modules_list'), ':drupal-modules' => 'https://www.drupal.org/project/modules')) . '</dd>';
+ $output .= '<dd>' . t('Users with appropriate permission can install and uninstall modules from the <a href=":modules">Extend page</a>. Depending on which distribution or installation profile you choose when you install your site, several modules are installed and others are provided but not installed. Each module provides a discrete set of features; modules may be installed or uninstalled depending on the needs of the site. Many additional modules contributed by members of the Drupal community are available for download from the <a href=":drupal-modules">Drupal.org module page</a>. Note that uninstalling a module is a destructive action: when you uninstall a module, you will permanently lose all data connected to the module.', [':modules' => \Drupal::url('system.modules_list'), ':drupal-modules' => 'https://www.drupal.org/project/modules']) . '</dd>';
$output .= '<dt>' . t('Managing themes') . '</dt>';
- $output .= '<dd>' . t('Users with appropriate permission can install and uninstall themes on the <a href=":themes">Appearance page</a>. Themes determine the design and presentation of your site. Depending on which distribution or installation profile you choose when you install your site, a default theme is installed, and possibly a different theme for administration pages. Other themes are provided but not installed, and additional contributed themes are available at the <a href=":drupal-themes">Drupal.org theme page</a>.', array(':themes' => \Drupal::url('system.themes_page'), ':drupal-themes' => 'https://www.drupal.org/project/themes')) . '</dd>';
+ $output .= '<dd>' . t('Users with appropriate permission can install and uninstall themes on the <a href=":themes">Appearance page</a>. Themes determine the design and presentation of your site. Depending on which distribution or installation profile you choose when you install your site, a default theme is installed, and possibly a different theme for administration pages. Other themes are provided but not installed, and additional contributed themes are available at the <a href=":drupal-themes">Drupal.org theme page</a>.', [':themes' => \Drupal::url('system.themes_page'), ':drupal-themes' => 'https://www.drupal.org/project/themes']) . '</dd>';
$output .= '<dt>' . t('Disabling drag-and-drop functionality') . '</dt>';
$output .= '<dd>' . t('The default drag-and-drop user interface for ordering tables in the administrative interface presents a challenge for some users, including users of screen readers and other assistive technology. The drag-and-drop interface can be disabled in a table by clicking a link labeled "Show row weights" above the table. The replacement interface allows users to order the table by choosing numerical weights instead of dragging table rows.') . '</dd>';
$output .= '<dt>' . t('Configuring basic site settings') . '</dt>';
- $output .= '<dd>' . t('The System module provides pages for managing basic site configuration, including <a href=":date-time-settings">Date and time formats</a> and <a href=":site-info">Basic site settings</a> (site name, email address to send mail from, home page, and error pages). Additional configuration pages are listed on the main <a href=":config">Configuration page</a>.', array(':date-time-settings' => \Drupal::url('entity.date_format.collection'), ':site-info' => \Drupal::url('system.site_information_settings'), ':config' => \Drupal::url('system.admin_config'))) . '</dd>';
+ $output .= '<dd>' . t('The System module provides pages for managing basic site configuration, including <a href=":date-time-settings">Date and time formats</a> and <a href=":site-info">Basic site settings</a> (site name, email address to send mail from, home page, and error pages). Additional configuration pages are listed on the main <a href=":config">Configuration page</a>.', [':date-time-settings' => \Drupal::url('entity.date_format.collection'), ':site-info' => \Drupal::url('system.site_information_settings'), ':config' => \Drupal::url('system.admin_config')]) . '</dd>';
$output .= '<dt>' . t('Checking site status') . '</dt>';
- $output .= '<dd>' . t('The <a href=":status">Status report</a> provides an overview of the configuration, status, and health of your site. Review this report to make sure there are not any problems to address, and to find information about the software your site and web server are using.', array(':status' => \Drupal::url('system.status'))) . '</dd>';
+ $output .= '<dd>' . t('The <a href=":status">Status report</a> provides an overview of the configuration, status, and health of your site. Review this report to make sure there are not any problems to address, and to find information about the software your site and web server are using.', [':status' => \Drupal::url('system.status')]) . '</dd>';
$output .= '<dt>' . t('Using maintenance mode') . '</dt>';
- $output .= '<dd>' . t('When you are performing site maintenance, you can prevent non-administrative users (including anonymous visitors) from viewing your site by putting it in <a href=":maintenance-mode">Maintenance mode</a>. This will prevent unauthorized users from making changes to the site while you are performing maintenance, or from seeing a broken site while updates are in progress.', array(':maintenance-mode' => \Drupal::url('system.site_maintenance_mode'))) . '</dd>';
+ $output .= '<dd>' . t('When you are performing site maintenance, you can prevent non-administrative users (including anonymous visitors) from viewing your site by putting it in <a href=":maintenance-mode">Maintenance mode</a>. This will prevent unauthorized users from making changes to the site while you are performing maintenance, or from seeing a broken site while updates are in progress.', [':maintenance-mode' => \Drupal::url('system.site_maintenance_mode')]) . '</dd>';
$output .= '<dt>' . t('Configuring for performance') . '</dt>';
- $output .= '<dd>' . t('On the <a href=":performance-page">Performance page</a>, the site can be configured to aggregate CSS and JavaScript files, making the total request size smaller. Note that, for small- to medium-sized websites, the <a href=":page-cache">Internal Page Cache module</a> should be installed so that pages are efficiently cached and reused for anonymous users. Finally, for websites of all sizes, the <a href=":dynamic-page-cache">Dynamic Page Cache module</a> should also be installed so that the non-personalized parts of pages are efficiently cached (for all users).', array(':performance-page' => \Drupal::url('system.performance_settings'), ':page-cache' => (\Drupal::moduleHandler()->moduleExists('page_cache')) ? \Drupal::url('help.page', array('name' => 'page_cache')) : '#', ':dynamic-page-cache' => (\Drupal::moduleHandler()->moduleExists('dynamic_page_cache')) ? \Drupal::url('help.page', array('name' => 'dynamic_page_cache')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('On the <a href=":performance-page">Performance page</a>, the site can be configured to aggregate CSS and JavaScript files, making the total request size smaller. Note that, for small- to medium-sized websites, the <a href=":page-cache">Internal Page Cache module</a> should be installed so that pages are efficiently cached and reused for anonymous users. Finally, for websites of all sizes, the <a href=":dynamic-page-cache">Dynamic Page Cache module</a> should also be installed so that the non-personalized parts of pages are efficiently cached (for all users).', [':performance-page' => \Drupal::url('system.performance_settings'), ':page-cache' => (\Drupal::moduleHandler()->moduleExists('page_cache')) ? \Drupal::url('help.page', ['name' => 'page_cache']) : '#', ':dynamic-page-cache' => (\Drupal::moduleHandler()->moduleExists('dynamic_page_cache')) ? \Drupal::url('help.page', ['name' => 'dynamic_page_cache']) : '#']) . '</dd>';
$output .= '<dt>' . t('Configuring cron') . '</dt>';
- $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis; these operations are known as <em>cron</em> tasks. On the <a href=":cron">Cron page</a>, you can configure cron to run periodically as part of server responses by installing the <em>Automated Cron</em> module, or you can turn this off and trigger cron from an outside process on your web server. You can verify the status of cron tasks by visiting the <a href=":status">Status report page</a>. For more information, see the <a href=":handbook">online documentation for configuring cron jobs</a>.', array(':status' => \Drupal::url('system.status'), ':handbook' => 'https://www.drupal.org/cron', ':cron' => \Drupal::url('system.cron_settings'))) . '</dd>';
+ $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis; these operations are known as <em>cron</em> tasks. On the <a href=":cron">Cron page</a>, you can configure cron to run periodically as part of server responses by installing the <em>Automated Cron</em> module, or you can turn this off and trigger cron from an outside process on your web server. You can verify the status of cron tasks by visiting the <a href=":status">Status report page</a>. For more information, see the <a href=":handbook">online documentation for configuring cron jobs</a>.', [':status' => \Drupal::url('system.status'), ':handbook' => 'https://www.drupal.org/cron', ':cron' => \Drupal::url('system.cron_settings')]) . '</dd>';
$output .= '<dt>' . t('Configuring the file system') . '</dt>';
- $output .= '<dd>' . t('Your site has several file directories, which are used to store and process uploaded and generated files. The <em>public</em> file directory, which is configured in your settings.php file, is the default place for storing uploaded files. Links to files in this directory contain the direct file URL, so when the files are requested, the web server will send them directly without invoking your site code. This means that the files can be downloaded by anyone with the file URL, so requests are not access-controlled but they are efficient. The <em>private</em> file directory, also configured in your settings.php file and ideally located outside the site web root, is access controlled. Links to files in this directory are not direct, so requests to these files are mediated by your site code. This means that your site can check file access permission for each file before deciding to fulfill the request, so the requests are more secure, but less efficient. You should only use the private storage for files that need access control, not for files like your site logo and background images used on every page. The <em>temporary</em> file directory is used internally by your site code for various operations, and is configured on the <a href=":file-system">File system settings</a> page. You can also see the configured public and private file directories on this page, and choose whether public or private should be the default for uploaded files.', array(':file-system' => \Drupal::url('system.file_system_settings'))) . '</dd>';
+ $output .= '<dd>' . t('Your site has several file directories, which are used to store and process uploaded and generated files. The <em>public</em> file directory, which is configured in your settings.php file, is the default place for storing uploaded files. Links to files in this directory contain the direct file URL, so when the files are requested, the web server will send them directly without invoking your site code. This means that the files can be downloaded by anyone with the file URL, so requests are not access-controlled but they are efficient. The <em>private</em> file directory, also configured in your settings.php file and ideally located outside the site web root, is access controlled. Links to files in this directory are not direct, so requests to these files are mediated by your site code. This means that your site can check file access permission for each file before deciding to fulfill the request, so the requests are more secure, but less efficient. You should only use the private storage for files that need access control, not for files like your site logo and background images used on every page. The <em>temporary</em> file directory is used internally by your site code for various operations, and is configured on the <a href=":file-system">File system settings</a> page. You can also see the configured public and private file directories on this page, and choose whether public or private should be the default for uploaded files.', [':file-system' => \Drupal::url('system.file_system_settings')]) . '</dd>';
$output .= '<dt>' . t('Configuring the image toolkit') . '</dt>';
- $output .= '<dd>' . t('On the <a href=":toolkit">Image toolkit page</a>, you can select and configure the PHP toolkit used to manipulate images. Depending on which distribution or installation profile you choose when you install your site, the GD2 toolkit and possibly others are included; other toolkits may be provided by contributed modules.', array(':toolkit' => \Drupal::url('system.image_toolkit_settings'))) . '</dd>';
+ $output .= '<dd>' . t('On the <a href=":toolkit">Image toolkit page</a>, you can select and configure the PHP toolkit used to manipulate images. Depending on which distribution or installation profile you choose when you install your site, the GD2 toolkit and possibly others are included; other toolkits may be provided by contributed modules.', [':toolkit' => \Drupal::url('system.image_toolkit_settings')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -125,24 +125,24 @@ function system_help($route_name, RouteMatchInterface $route_match) {
return '<p>' . t('This page shows you all available administration tasks for each module.') . '</p>';
case 'system.themes_page':
- $output = '<p>' . t('Set and configure the default theme for your website. Alternative <a href=":themes">themes</a> are available.', array(':themes' => 'https://www.drupal.org/project/themes')) . '</p>';
+ $output = '<p>' . t('Set and configure the default theme for your website. Alternative <a href=":themes">themes</a> are available.', [':themes' => 'https://www.drupal.org/project/themes']) . '</p>';
if (\Drupal::moduleHandler()->moduleExists('block')) {
- $output .= '<p>' . t('You can place blocks for each theme on the <a href=":blocks">block layout</a> page.', array(':blocks' => \Drupal::url('block.admin_display'))) . '</p>';
+ $output .= '<p>' . t('You can place blocks for each theme on the <a href=":blocks">block layout</a> page.', [':blocks' => \Drupal::url('block.admin_display')]) . '</p>';
}
return $output;
case 'system.theme_settings_theme':
$theme_list = \Drupal::service('theme_handler')->listInfo();
$theme = $theme_list[$route_match->getParameter('theme')];
- return '<p>' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', array('%name' => $theme->info['name'])) . '</p>';
+ return '<p>' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', ['%name' => $theme->info['name']]) . '</p>';
case 'system.theme_settings':
return '<p>' . t('Control default display settings for your site, across all themes. Use theme-specific settings to override these defaults.') . '</p>';
case 'system.modules_list':
- $output = '<p>' . t('Download additional <a href=":modules">contributed modules</a> to extend your site\'s functionality.', array(':modules' => 'https://www.drupal.org/project/modules')) . '</p>';
+ $output = '<p>' . t('Download additional <a href=":modules">contributed modules</a> to extend your site\'s functionality.', [':modules' => 'https://www.drupal.org/project/modules']) . '</p>';
if (!\Drupal::moduleHandler()->moduleExists('update')) {
- $output .= '<p>' . t('Regularly review available updates to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time a module is updated. Enable the <a href=":update-manager">Update Manager module</a> to update and install modules and themes.', array(':update-php' => \Drupal::url('system.db_update'), ':update-manager' => \Drupal::url('system.modules_list', [], ['fragment' => 'module-update']))) . '</p>';
+ $output .= '<p>' . t('Regularly review available updates to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time a module is updated. Enable the <a href=":update-manager">Update Manager module</a> to update and install modules and themes.', [':update-php' => \Drupal::url('system.db_update'), ':update-manager' => \Drupal::url('system.modules_list', [], ['fragment' => 'module-update'])]) . '</p>';
}
return $output;
@@ -168,7 +168,7 @@ function system_help($route_name, RouteMatchInterface $route_match) {
break;
case 'system.status':
- return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on Drupal.org's support forums and project issue queues. Before filing a support request, ensure that your web server meets the <a href=\":system-requirements\">system requirements.</a>", array(':system-requirements' => 'https://www.drupal.org/requirements')) . '</p>';
+ return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on Drupal.org's support forums and project issue queues. Before filing a support request, ensure that your web server meets the <a href=\":system-requirements\">system requirements.</a>", [':system-requirements' => 'https://www.drupal.org/requirements']) . '</p>';
}
}
@@ -176,117 +176,117 @@ function system_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function system_theme() {
- return array_merge(drupal_common_theme(), array(
+ return array_merge(drupal_common_theme(), [
// Normally theme suggestion templates are only picked up when they are in
// themes. We explicitly define theme suggestions here so that the block
// templates in core/modules/system/templates are picked up.
- 'block__system_branding_block' => array(
+ 'block__system_branding_block' => [
'render element' => 'elements',
'base hook' => 'block',
- ),
- 'block__system_messages_block' => array(
+ ],
+ 'block__system_messages_block' => [
'base hook' => 'block',
- ),
- 'block__system_menu_block' => array(
+ ],
+ 'block__system_menu_block' => [
'render element' => 'elements',
'base hook' => 'block',
- ),
- 'system_themes_page' => array(
- 'variables' => array(
- 'theme_groups' => array(),
- 'theme_group_titles' => array(),
- ),
+ ],
+ 'system_themes_page' => [
+ 'variables' => [
+ 'theme_groups' => [],
+ 'theme_group_titles' => [],
+ ],
'file' => 'system.admin.inc',
- ),
- 'system_config_form' => array(
+ ],
+ 'system_config_form' => [
'render element' => 'form',
- ),
- 'confirm_form' => array(
+ ],
+ 'confirm_form' => [
'render element' => 'form',
- ),
- 'system_modules_details' => array(
+ ],
+ 'system_modules_details' => [
'render element' => 'form',
'file' => 'system.admin.inc',
- ),
- 'system_modules_uninstall' => array(
+ ],
+ 'system_modules_uninstall' => [
'render element' => 'form',
'file' => 'system.admin.inc',
- ),
- 'status_report_page' => array(
- 'variables' => array(
- 'counters' => array(),
- 'general_info' => array(),
+ ],
+ 'status_report_page' => [
+ 'variables' => [
+ 'counters' => [],
+ 'general_info' => [],
'requirements' => NULL,
- ),
- ),
- 'status_report' => array(
- 'variables' => array(
+ ],
+ ],
+ 'status_report' => [
+ 'variables' => [
'grouped_requirements' => NULL,
'requirements' => NULL,
- ),
- ),
- 'status_report_grouped' => array(
- 'variables' => array(
+ ],
+ ],
+ 'status_report_grouped' => [
+ 'variables' => [
'grouped_requirements' => NULL,
'requirements' => NULL,
- ),
- ),
- 'status_report_counter' => array(
- 'variables' => array('amount' => NULL, 'text' => NULL, 'severity' => NULL),
- ),
- 'status_report_general_info' => array(
- 'variables' => array(
- 'drupal' => array(),
- 'cron' => array(),
- 'database_system' => array(),
- 'database_system_version' => array(),
- 'php' => array(),
- 'php_memory_limit' => array(),
- 'webserver' => array(),
- ),
- ),
- 'admin_page' => array(
- 'variables' => array('blocks' => NULL),
+ ],
+ ],
+ 'status_report_counter' => [
+ 'variables' => ['amount' => NULL, 'text' => NULL, 'severity' => NULL],
+ ],
+ 'status_report_general_info' => [
+ 'variables' => [
+ 'drupal' => [],
+ 'cron' => [],
+ 'database_system' => [],
+ 'database_system_version' => [],
+ 'php' => [],
+ 'php_memory_limit' => [],
+ 'webserver' => [],
+ ],
+ ],
+ 'admin_page' => [
+ 'variables' => ['blocks' => NULL],
'file' => 'system.admin.inc',
- ),
- 'admin_block' => array(
- 'variables' => array('block' => NULL),
+ ],
+ 'admin_block' => [
+ 'variables' => ['block' => NULL],
'file' => 'system.admin.inc',
- ),
- 'admin_block_content' => array(
- 'variables' => array('content' => NULL),
+ ],
+ 'admin_block_content' => [
+ 'variables' => ['content' => NULL],
'file' => 'system.admin.inc',
- ),
- 'system_admin_index' => array(
- 'variables' => array('menu_items' => NULL),
+ ],
+ 'system_admin_index' => [
+ 'variables' => ['menu_items' => NULL],
'file' => 'system.admin.inc',
- ),
- 'entity_add_list' => array(
- 'variables' => array(
- 'bundles' => array(),
+ ],
+ 'entity_add_list' => [
+ 'variables' => [
+ 'bundles' => [],
'add_bundle_message' => NULL,
- ),
+ ],
'template' => 'entity-add-list',
- ),
- ));
+ ],
+ ]);
}
/**
* Implements hook_hook_info().
*/
function system_hook_info() {
- $hooks['token_info'] = array(
+ $hooks['token_info'] = [
'group' => 'tokens',
- );
- $hooks['token_info_alter'] = array(
+ ];
+ $hooks['token_info_alter'] = [
'group' => 'tokens',
- );
- $hooks['tokens'] = array(
+ ];
+ $hooks['tokens'] = [
'group' => 'tokens',
- );
- $hooks['tokens_alter'] = array(
+ ];
+ $hooks['tokens_alter'] = [
'group' => 'tokens',
- );
+ ];
return $hooks;
}
@@ -311,7 +311,7 @@ function system_theme_suggestions_page(array $variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function system_theme_suggestions_maintenance_page(array $variables) {
- $suggestions = array();
+ $suggestions = [];
// Dead databases will show error messages so supplying this template will
// allow themers to override the page and the content completely.
@@ -334,7 +334,7 @@ function system_theme_suggestions_maintenance_page(array $variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function system_theme_suggestions_region(array $variables) {
- $suggestions = array();
+ $suggestions = [];
if (!empty($variables['elements']['#region'])) {
$suggestions[] = 'region__' . $variables['elements']['#region'];
}
@@ -345,7 +345,7 @@ function system_theme_suggestions_region(array $variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function system_theme_suggestions_field(array $variables) {
- $suggestions = array();
+ $suggestions = [];
$element = $variables['element'];
$suggestions[] = 'field__' . $element['#field_type'];
@@ -452,18 +452,18 @@ function template_preprocess_entity_add_list(&$variables) {
* @return
* Nothing, this function just initializes variables in the user's session.
*/
-function system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL) {
+function system_authorized_init($callback, $file, $arguments = [], $page_title = NULL) {
// First, figure out what file transfer backends the site supports, and put
// all of those in the SESSION so that authorize.php has access to all of
// them via the class autoloader, even without a full bootstrap.
$_SESSION['authorize_filetransfer_info'] = drupal_get_filetransfer_info();
// Now, define the callback to invoke.
- $_SESSION['authorize_operation'] = array(
+ $_SESSION['authorize_operation'] = [
'callback' => $callback,
'file' => $file,
'arguments' => $arguments,
- );
+ ];
if (isset($page_title)) {
$_SESSION['authorize_page_title'] = $page_title;
@@ -480,7 +480,7 @@ function system_authorized_init($callback, $file, $arguments = array(), $page_ti
*
* @see system_authorized_init()
*/
-function system_authorized_get_url(array $options = array()) {
+function system_authorized_get_url(array $options = []) {
// core/authorize.php is an unrouted URL, so using the base: scheme is
// the correct usage for this case.
$url = Url::fromUri('base:core/authorize.php');
@@ -497,8 +497,8 @@ function system_authorized_get_url(array $options = array()) {
*
* @return \Drupal\Core\Url
*/
-function system_authorized_batch_processing_url(array $options = array()) {
- $options['query'] = array('batch' => '1');
+function system_authorized_batch_processing_url(array $options = []) {
+ $options['query'] = ['batch' => '1'];
return system_authorized_get_url($options);
}
@@ -507,7 +507,7 @@ function system_authorized_batch_processing_url(array $options = array()) {
*
* @see system_authorized_init()
*/
-function system_authorized_run($callback, $file, $arguments = array(), $page_title = NULL) {
+function system_authorized_run($callback, $file, $arguments = [], $page_title = NULL) {
system_authorized_init($callback, $file, $arguments, $page_title);
return new RedirectResponse(system_authorized_get_url()->toString());
}
@@ -531,43 +531,43 @@ function system_authorized_batch_process() {
* Implements hook_updater_info().
*/
function system_updater_info() {
- return array(
- 'module' => array(
+ return [
+ 'module' => [
'class' => 'Drupal\Core\Updater\Module',
'name' => t('Update modules'),
'weight' => 0,
- ),
- 'theme' => array(
+ ],
+ 'theme' => [
'class' => 'Drupal\Core\Updater\Theme',
'name' => t('Update themes'),
'weight' => 0,
- ),
- );
+ ],
+ ];
}
/**
* Implements hook_filetransfer_info().
*/
function system_filetransfer_info() {
- $backends = array();
+ $backends = [];
// This is the default, will be available on most systems.
if (function_exists('ftp_connect')) {
- $backends['ftp'] = array(
+ $backends['ftp'] = [
'title' => t('FTP'),
'class' => 'Drupal\Core\FileTransfer\FTP',
'weight' => 0,
- );
+ ];
}
// SSH2 lib connection is only available if the proper PHP extension is
// installed.
if (function_exists('ssh2_connect')) {
- $backends['ssh'] = array(
+ $backends['ssh'] = [
'title' => t('SSH'),
'class' => 'Drupal\Core\FileTransfer\SSH',
'weight' => 20,
- );
+ ];
}
return $backends;
}
@@ -595,61 +595,61 @@ function system_page_attachments(array &$page) {
if (theme_get_setting('features.favicon')) {
$favicon = theme_get_setting('favicon.url');
$type = theme_get_setting('favicon.mimetype');
- $page['#attached']['html_head_link'][][] = array(
+ $page['#attached']['html_head_link'][][] = [
'rel' => 'shortcut icon',
'href' => UrlHelper::stripDangerousProtocols($favicon),
'type' => $type,
- );
+ ];
}
// Get the major Drupal version.
list($version, ) = explode('.', \Drupal::VERSION);
// Attach default meta tags.
- $meta_default = array(
+ $meta_default = [
// Make sure the Content-Type comes first because the IE browser may be
// vulnerable to XSS via encoding attacks from any content that comes
// before this META tag, such as a TITLE tag.
- 'system_meta_content_type' => array(
+ 'system_meta_content_type' => [
'#tag' => 'meta',
- '#attributes' => array(
+ '#attributes' => [
'charset' => 'utf-8',
- ),
+ ],
// Security: This always has to be output first.
'#weight' => -1000,
- ),
+ ],
// Show Drupal and the major version number in the META GENERATOR tag.
- 'system_meta_generator' => array(
+ 'system_meta_generator' => [
'#type' => 'html_tag',
'#tag' => 'meta',
- '#attributes' => array(
+ '#attributes' => [
'name' => 'Generator',
'content' => 'Drupal ' . $version . ' (https://www.drupal.org)',
- ),
- ),
+ ],
+ ],
// Attach default mobile meta tags for responsive design.
- 'MobileOptimized' => array(
+ 'MobileOptimized' => [
'#tag' => 'meta',
- '#attributes' => array(
+ '#attributes' => [
'name' => 'MobileOptimized',
'content' => 'width',
- ),
- ),
- 'HandheldFriendly' => array(
+ ],
+ ],
+ 'HandheldFriendly' => [
'#tag' => 'meta',
- '#attributes' => array(
+ '#attributes' => [
'name' => 'HandheldFriendly',
'content' => 'true',
- ),
- ),
- 'viewport' => array(
+ ],
+ ],
+ 'viewport' => [
'#tag' => 'meta',
- '#attributes' => array(
+ '#attributes' => [
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1.0',
- ),
- ),
- );
+ ],
+ ],
+ ];
foreach ($meta_default as $key => $value) {
$page['#attached']['html_head'][] = [$value, $key];
}
@@ -824,7 +824,7 @@ function system_user_login(UserInterface $account) {
$config = \Drupal::config('system.date');
// If the user has a NULL time zone, notify them to set a time zone.
if (!$account->getTimezone() && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
- drupal_set_message(t('Configure your <a href=":user-edit">account time zone setting</a>.', array(':user-edit' => $account->url('edit-form', array('query' => \Drupal::destination()->getAsArray(), 'fragment' => 'edit-timezone')))));
+ drupal_set_message(t('Configure your <a href=":user-edit">account time zone setting</a>.', [':user-edit' => $account->url('edit-form', ['query' => \Drupal::destination()->getAsArray(), 'fragment' => 'edit-timezone'])]));
}
}
@@ -835,23 +835,23 @@ function system_user_timezone(&$form, FormStateInterface $form_state) {
$user = \Drupal::currentUser();
$account = $form_state->getFormObject()->getEntity();
- $form['timezone'] = array(
+ $form['timezone'] = [
'#type' => 'details',
'#title' => t('Locale settings'),
'#open' => TRUE,
'#weight' => 6,
- );
- $form['timezone']['timezone'] = array(
+ ];
+ $form['timezone']['timezone'] = [
'#type' => 'select',
'#title' => t('Time zone'),
'#default_value' => $account->getTimezone() ? $account->getTimezone() : \Drupal::config('system.date')->get('timezone.default'),
'#options' => system_time_zones($account->id() != $user->id()),
'#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
- );
+ ];
$user_input = $form_state->getUserInput();
if (!$account->getTimezone() && $account->id() == $user->id() && empty($user_input['timezone'])) {
$form['timezone']['#attached']['library'][] = 'core/drupal.timezone';
- $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
+ $form['timezone']['timezone']['#attributes'] = ['class' => ['timezone-detect']];
}
}
@@ -903,14 +903,14 @@ function system_check_directory($form_element, FormStateInterface $form_state) {
$logger = \Drupal::logger('file system');
if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
// If the directory does not exists and cannot be created.
- $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
- $logger->error('The directory %directory does not exist and could not be created.', array('%directory' => $directory));
+ $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', ['%directory' => $directory]));
+ $logger->error('The directory %directory does not exist and could not be created.', ['%directory' => $directory]);
}
if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {
// If the directory is not writable and cannot be made so.
- $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
- $logger->error('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory));
+ $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', ['%directory' => $directory]));
+ $logger->error('The directory %directory exists but is not writable and could not be made writable.', ['%directory' => $directory]);
}
elseif (is_dir($directory)) {
if ($form_element['#name'] == 'file_public_path') {
@@ -971,7 +971,7 @@ function system_get_info($type, $name = NULL) {
}
}
else {
- $info = array();
+ $info = [];
$list = system_list($type);
foreach ($list as $shortname => $item) {
if (!empty($item->status)) {
@@ -980,7 +980,7 @@ function system_get_info($type, $name = NULL) {
}
}
if (isset($name)) {
- return isset($info[$name]) ? $info[$name] : array();
+ return isset($info[$name]) ? $info[$name] : [];
}
return $info;
}
@@ -1017,13 +1017,13 @@ function _system_rebuild_module_data() {
}
// Set defaults for module info.
- $defaults = array(
- 'dependencies' => array(),
+ $defaults = [
+ 'dependencies' => [],
'description' => '',
'package' => 'Other',
'version' => NULL,
'php' => DRUPAL_MINIMUM_PHP,
- );
+ ];
// Read info files for each module.
foreach ($modules as $key => $module) {
@@ -1085,7 +1085,7 @@ function _system_rebuild_module_data_ensure_required($module, &$modules) {
$dependency_name = ModuleHandler::parseDependency($dependency)['name'];
if (!isset($modules[$dependency_name]->info['required'])) {
$modules[$dependency_name]->info['required'] = TRUE;
- $modules[$dependency_name]->info['explanation'] = t('Dependency of required module @module', array('@module' => $module->info['name']));
+ $modules[$dependency_name]->info['explanation'] = t('Dependency of required module @module', ['@module' => $module->info['name']]);
// Ensure any dependencies it has are required.
_system_rebuild_module_data_ensure_required($modules[$dependency_name], $modules);
}
@@ -1106,10 +1106,10 @@ function system_rebuild_module_data() {
// reference from system_list_reset() during the rebuild.
if (!isset($modules_cache)) {
$modules = _system_rebuild_module_data();
- $files = array();
+ $files = [];
ksort($modules);
// Add status, weight, and schema version.
- $installed_modules = \Drupal::config('core.extension')->get('module') ?: array();
+ $installed_modules = \Drupal::config('core.extension')->get('module') ?: [];
foreach ($modules as $name => $module) {
$module->weight = isset($installed_modules[$name]) ? $installed_modules[$name] : 0;
$module->status = (int) isset($installed_modules[$name]);
@@ -1144,11 +1144,11 @@ function system_region_list($theme, $show = REGIONS_ALL) {
if (!$theme instanceof Extension) {
$themes = \Drupal::service('theme_handler')->listInfo();
if (!isset($themes[$theme])) {
- return array();
+ return [];
}
$theme = $themes[$theme];
}
- $list = array();
+ $list = [];
$info = $theme->info;
// If requested, suppress hidden regions. See block_admin_display_form().
foreach ($info['regions'] as $name => $label) {
@@ -1253,15 +1253,15 @@ function system_get_module_admin_tasks($module, array $info) {
$parameters = new MenuTreeParameters();
$parameters->setRoot('system.admin')->excludeRoot()->onlyEnabledLinks();
$tree = $menu_tree->load('system.admin', $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- array('callable' => 'menu.default_tree_manipulators:flatten'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ['callable' => 'menu.default_tree_manipulators:flatten'],
+ ];
$tree = $menu_tree->transform($tree, $manipulators);
}
- $admin_tasks = array();
+ $admin_tasks = [];
foreach ($tree as $element) {
if (!$element->access->isAllowed()) {
// @todo Bubble cacheability metadata of both accessible and inaccessible
@@ -1273,11 +1273,11 @@ function system_get_module_admin_tasks($module, array $info) {
if ($link->getProvider() != $module) {
continue;
}
- $admin_tasks[] = array(
+ $admin_tasks[] = [
'title' => $link->getTitle(),
'description' => $link->getDescription(),
'url' => $link->getUrlObject(),
- );
+ ];
}
// Append link for permissions.
@@ -1287,15 +1287,15 @@ function system_get_module_admin_tasks($module, array $info) {
if ($permission_handler->moduleProvidesPermissions($module)) {
/** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */
$access_manager = \Drupal::service('access_manager');
- if ($access_manager->checkNamedRoute('user.admin_permissions', array(), \Drupal::currentUser())) {
+ if ($access_manager->checkNamedRoute('user.admin_permissions', [], \Drupal::currentUser())) {
/** @var \Drupal\Core\Url $url */
$url = new Url('user.admin_permissions');
$url->setOption('fragment', 'module-' . $module);
- $admin_tasks["user.admin_permissions.$module"] = array(
- 'title' => t('Configure @module permissions', array('@module' => $info['name'])),
+ $admin_tasks["user.admin_permissions.$module"] = [
+ 'title' => t('Configure @module permissions', ['@module' => $info['name']]),
'description' => '',
'url' => $url,
- );
+ ];
}
}
@@ -1348,7 +1348,7 @@ function system_mail($key, &$message, $params) {
$subject = PlainTextOutput::renderFromHtml($token_service->replace($context['subject'], $context));
$body = $token_service->replace($context['message'], $context);
- $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
+ $message['subject'] .= str_replace(["\r", "\n"], '', $subject);
$message['body'][] = $body;
}
@@ -1360,13 +1360,13 @@ function system_mail($key, &$message, $params) {
*/
function system_time_zones($blank = NULL) {
$zonelist = timezone_identifiers_list();
- $zones = $blank ? array('' => t('- None selected -')) : array();
+ $zones = $blank ? ['' => t('- None selected -')] : [];
foreach ($zonelist as $zone) {
// Because many time zones exist in PHP only for backward compatibility
// reasons and should not be used, the list is filtered by a regular
// expression.
if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
- $zones[$zone] = t('@zone', array('@zone' => t(str_replace('_', ' ', $zone))));
+ $zones[$zone] = t('@zone', ['@zone' => t(str_replace('_', ' ', $zone))]);
}
}
// Sort the translated time zones alphabetically.
@@ -1425,11 +1425,11 @@ function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $repl
$local = $managed ? file_save_data($data, $path, $replace) : file_unmanaged_save_data($data, $path, $replace);
}
catch (RequestException $exception) {
- drupal_set_message(t('Failed to fetch file due to error "%error"', array('%error' => $exception->getMessage())), 'error');
+ drupal_set_message(t('Failed to fetch file due to error "%error"', ['%error' => $exception->getMessage()]), 'error');
return FALSE;
}
if (!$local) {
- drupal_set_message(t('@remote could not be saved to @path.', array('@remote' => $url, '@path' => $path)), 'error');
+ drupal_set_message(t('@remote could not be saved to @path.', ['@remote' => $url, '@path' => $path]), 'error');
}
return $local;
diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc
index 66b5c7faf3f..55c89ae9f92 100644
--- a/core/modules/system/system.tokens.inc
+++ b/core/modules/system/system.tokens.inc
@@ -14,74 +14,74 @@ use Drupal\Core\Render\BubbleableMetadata;
* Implements hook_token_info().
*/
function system_token_info() {
- $types['site'] = array(
+ $types['site'] = [
'name' => t("Site information"),
'description' => t("Tokens for site-wide settings and other global information."),
- );
- $types['date'] = array(
+ ];
+ $types['date'] = [
'name' => t("Dates"),
'description' => t("Tokens related to times and dates."),
- );
+ ];
// Site-wide global tokens.
- $site['name'] = array(
+ $site['name'] = [
'name' => t("Name"),
'description' => t("The name of the site."),
- );
- $site['slogan'] = array(
+ ];
+ $site['slogan'] = [
'name' => t("Slogan"),
'description' => t("The slogan of the site."),
- );
- $site['mail'] = array(
+ ];
+ $site['mail'] = [
'name' => t("Email"),
'description' => t("The administrative email address for the site."),
- );
- $site['url'] = array(
+ ];
+ $site['url'] = [
'name' => t("URL"),
'description' => t("The URL of the site's front page."),
- );
- $site['url-brief'] = array(
+ ];
+ $site['url-brief'] = [
'name' => t("URL (brief)"),
'description' => t("The URL of the site's front page without the protocol."),
- );
- $site['login-url'] = array(
+ ];
+ $site['login-url'] = [
'name' => t("Login page"),
'description' => t("The URL of the site's login page."),
- );
+ ];
// Date related tokens.
- $date['short'] = array(
+ $date['short'] = [
'name' => t("Short format"),
- 'description' => t("A date in 'short' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'short'))),
- );
- $date['medium'] = array(
+ 'description' => t("A date in 'short' format. (%date)", ['%date' => format_date(REQUEST_TIME, 'short')]),
+ ];
+ $date['medium'] = [
'name' => t("Medium format"),
- 'description' => t("A date in 'medium' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'medium'))),
- );
- $date['long'] = array(
+ 'description' => t("A date in 'medium' format. (%date)", ['%date' => format_date(REQUEST_TIME, 'medium')]),
+ ];
+ $date['long'] = [
'name' => t("Long format"),
- 'description' => t("A date in 'long' format. (%date)", array('%date' => format_date(REQUEST_TIME, 'long'))),
- );
- $date['custom'] = array(
+ 'description' => t("A date in 'long' format. (%date)", ['%date' => format_date(REQUEST_TIME, 'long')]),
+ ];
+ $date['custom'] = [
'name' => t("Custom format"),
'description' => t('A date in a custom format. See <a href="http://php.net/manual/function.date.php">the PHP documentation</a> for details.'),
- );
- $date['since'] = array(
+ ];
+ $date['since'] = [
'name' => t("Time-since"),
- 'description' => t("A date in 'time-since' format. (%date)", array('%date' => \Drupal::service('date.formatter')->formatTimeDiffSince(REQUEST_TIME - 360))),
- );
- $date['raw'] = array(
+ 'description' => t("A date in 'time-since' format. (%date)", ['%date' => \Drupal::service('date.formatter')->formatTimeDiffSince(REQUEST_TIME - 360)]),
+ ];
+ $date['raw'] = [
'name' => t("Raw timestamp"),
- 'description' => t("A date in UNIX timestamp format (%date)", array('%date' => REQUEST_TIME)),
- );
+ 'description' => t("A date in UNIX timestamp format (%date)", ['%date' => REQUEST_TIME]),
+ ];
- return array(
+ return [
'types' => $types,
- 'tokens' => array(
+ 'tokens' => [
'site' => $site,
'date' => $date,
- ),
- );
+ ],
+ ];
}
/**
@@ -90,7 +90,7 @@ function system_token_info() {
function system_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@@ -98,7 +98,7 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
else {
$langcode = NULL;
}
- $replacements = array();
+ $replacements = [];
if ($type == 'site') {
foreach ($tokens as $name => $original) {
@@ -129,16 +129,16 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
case 'url':
/** @var \Drupal\Core\GeneratedUrl $result */
- $result = \Drupal::url('<front>', array(), $url_options, TRUE);
+ $result = \Drupal::url('<front>', [], $url_options, TRUE);
$bubbleable_metadata->addCacheableDependency($result);
$replacements[$original] = $result->getGeneratedUrl();
break;
case 'url-brief':
/** @var \Drupal\Core\GeneratedUrl $result */
- $result = \Drupal::url('<front>', array(), $url_options, TRUE);
+ $result = \Drupal::url('<front>', [], $url_options, TRUE);
$bubbleable_metadata->addCacheableDependency($result);
- $replacements[$original] = preg_replace(array('!^https?://!', '!/$!'), '', $result->getGeneratedUrl());
+ $replacements[$original] = preg_replace(['!^https?://!', '!/$!'], '', $result->getGeneratedUrl());
break;
case 'login-url':
@@ -173,7 +173,7 @@ function system_tokens($type, $tokens, array $data, array $options, BubbleableMe
break;
case 'since':
- $replacements[$original] = \Drupal::service('date.formatter')->formatTimeDiffSince($date, array('langcode' => $langcode));
+ $replacements[$original] = \Drupal::service('date.formatter')->formatTimeDiffSince($date, ['langcode' => $langcode]);
$bubbleable_metadata->setCacheMaxAge(0);
break;
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php b/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php
index 7f23f902664..cb356768994 100644
--- a/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php
+++ b/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php
@@ -23,16 +23,16 @@ $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdt
foreach ($block_configs as $block_config) {
$connection->insert('config')
- ->fields(array(
+ ->fields([
'collection',
'name',
'data',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => '',
'name' => 'block.block.' . $block_config['id'],
'data' => serialize($block_config),
- ))
+ ])
->execute();
}
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php b/core/modules/system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php
index a511cb5477c..e3531a0c12d 100644
--- a/core/modules/system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php
+++ b/core/modules/system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php
@@ -11,64 +11,64 @@ use Drupal\Core\Database\Database;
$connection = Database::getConnection();
$connection->insert('key_value')
- ->fields(array(
+ ->fields([
'collection',
'name',
'value',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.body',
'value' => 'a:2:{s:19:"block_content__body";a:4:{s:11:"description";s:42:"Data storage for block_content field body.";s:6:"fields";a:9:{s:6:"bundle";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:88:"The field instance bundle to which this row belongs, used when deleting a field instance";}s:7:"deleted";a:5:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;s:7:"default";i:0;s:11:"description";s:60:"A boolean indicating whether this data item has been deleted";}s:9:"entity_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:38:"The entity id this data is attached to";}s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:47:"The entity revision id this data is attached to";}s:8:"langcode";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:37:"The language code for this data item.";}s:5:"delta";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:67:"The sequence number for this data item, used for multi-value fields";}s:10:"body_value";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:1;}s:12:"body_summary";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}s:11:"body_format";a:3:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:255;s:8:"not null";b:0;}}s:11:"primary key";a:4:{i:0;s:9:"entity_id";i:1;s:7:"deleted";i:2;s:5:"delta";i:3;s:8:"langcode";}s:7:"indexes";a:3:{s:6:"bundle";a:1:{i:0;s:6:"bundle";}s:11:"revision_id";a:1:{i:0;s:11:"revision_id";}s:11:"body_format";a:1:{i:0;s:11:"body_format";}}}s:28:"block_content_revision__body";a:4:{s:11:"description";s:54:"Revision archive storage for block_content field body.";s:6:"fields";a:9:{s:6:"bundle";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:88:"The field instance bundle to which this row belongs, used when deleting a field instance";}s:7:"deleted";a:5:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;s:7:"default";i:0;s:11:"description";s:60:"A boolean indicating whether this data item has been deleted";}s:9:"entity_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:38:"The entity id this data is attached to";}s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:47:"The entity revision id this data is attached to";}s:8:"langcode";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:37:"The language code for this data item.";}s:5:"delta";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:67:"The sequence number for this data item, used for multi-value fields";}s:10:"body_value";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:1;}s:12:"body_summary";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}s:11:"body_format";a:3:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:255;s:8:"not null";b:0;}}s:11:"primary key";a:5:{i:0;s:9:"entity_id";i:1;s:11:"revision_id";i:2;s:7:"deleted";i:3;s:5:"delta";i:4;s:8:"langcode";}s:7:"indexes";a:3:{s:6:"bundle";a:1:{i:0;s:6:"bundle";}s:11:"revision_id";a:1:{i:0;s:11:"revision_id";}s:11:"body_format";a:1:{i:0;s:11:"body_format";}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.changed',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:7:"changed";a:2:{s:4:"type";s:3:"int";s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:7:"changed";a:2:{s:4:"type";s:3:"int";s:8:"not null";b:0;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.default_langcode',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:16:"default_langcode";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:16:"default_langcode";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.id',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.info',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:4:"info";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:255;s:6:"binary";b:0;s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:4:"info";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:255;s:6:"binary";b:0;s:8:"not null";b:0;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.langcode',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_id',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:0;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_log',
'value' => 'a:1:{s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:12:"revision_log";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_translation_affected',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:29:"revision_translation_affected";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:29:"revision_translation_affected";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:0;}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.type',
'value' => 'a:2:{s:13:"block_content";a:2:{s:6:"fields";a:1:{s:4:"type";a:4:{s:11:"description";s:28:"The ID of the target entity.";s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;}}s:7:"indexes";a:1:{s:36:"block_content_field__type__target_id";a:1:{i:0;s:4:"type";}}}s:24:"block_content_field_data";a:2:{s:6:"fields";a:1:{s:4:"type";a:4:{s:11:"description";s:28:"The ID of the target entity.";s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;}}s:7:"indexes";a:1:{s:36:"block_content_field__type__target_id";a:1:{i:0;s:4:"type";}}}}',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.uuid',
'value' => 'a:1:{s:13:"block_content";a:2:{s:6:"fields";a:1:{s:4:"uuid";a:4:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:6:"binary";b:0;s:8:"not null";b:1;}}s:11:"unique keys";a:1:{s:32:"block_content_field__uuid__value";a:1:{i:0;s:4:"uuid";}}}}',
- ))
+ ])
->execute();
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.update-test-block-disabled-2513534.php b/core/modules/system/tests/fixtures/update/drupal-8.update-test-block-disabled-2513534.php
index fc8e1c5612d..fa394473d73 100644
--- a/core/modules/system/tests/fixtures/update/drupal-8.update-test-block-disabled-2513534.php
+++ b/core/modules/system/tests/fixtures/update/drupal-8.update-test-block-disabled-2513534.php
@@ -19,16 +19,16 @@ $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.second
foreach ($block_configs as $block_config) {
$connection->insert('config')
- ->fields(array(
+ ->fields([
'collection',
'name',
'data',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => '',
'name' => 'block.block.' . $block_config['id'],
'data' => serialize($block_config),
- ))
+ ])
->execute();
}
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php b/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php
index 7250741cf80..93592ecef21 100644
--- a/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php
+++ b/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php
@@ -10,20 +10,20 @@ use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Create the table.
-$connection->schema()->createTable('update_test_schema_table', array(
- 'fields' => array(
- 'a' => array(
+$connection->schema()->createTable('update_test_schema_table', [
+ 'fields' => [
+ 'a' => [
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
- ),
- 'b' => array(
+ ],
+ 'b' => [
'type' => 'blob',
'not null' => FALSE,
'size' => 'normal',
- ),
- ),
-));
+ ],
+ ],
+]);
// Set the schema version.
$connection->merge('key_value')
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php
index 2fcda10af17..7b04a3693c6 100644
--- a/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php
+++ b/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php
@@ -18,15 +18,15 @@ $views_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-ent
foreach ($views_configs as $views_config) {
$connection->insert('config')
- ->fields(array(
+ ->fields([
'collection',
'name',
'data',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => '',
'name' => 'views.view.' . $views_config['id'],
'data' => serialize($views_config),
- ))
+ ])
->execute();
}
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.views-revision-metadata-fields-2248983.php b/core/modules/system/tests/fixtures/update/drupal-8.views-revision-metadata-fields-2248983.php
index 59b05a5d6af..4cc5227774f 100644
--- a/core/modules/system/tests/fixtures/update/drupal-8.views-revision-metadata-fields-2248983.php
+++ b/core/modules/system/tests/fixtures/update/drupal-8.views-revision-metadata-fields-2248983.php
@@ -21,15 +21,15 @@ $views_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/views.view.entity_
foreach ($views_configs as $views_config) {
$connection->insert('config')
- ->fields(array(
+ ->fields([
'collection',
'name',
'data',
- ))
- ->values(array(
+ ])
+ ->values([
'collection' => '',
'name' => 'views.view.' . $views_config['id'],
'data' => serialize($views_config),
- ))
+ ])
->execute();
}
diff --git a/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php b/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php
index 0981f46ea47..1a3c61eafb6 100644
--- a/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php
+++ b/core/modules/system/tests/modules/accept_header_routing_test/src/Routing/AcceptHeaderMatcher.php
@@ -20,7 +20,7 @@ class AcceptHeaderMatcher implements RouteFilterInterface {
// Generates a list of Symfony formats matching the acceptable MIME types.
// @todo replace by proper content negotiation library.
$acceptable_mime_types = $request->getAcceptableContentTypes();
- $acceptable_formats = array_filter(array_map(array($request, 'getFormat'), $acceptable_mime_types));
+ $acceptable_formats = array_filter(array_map([$request, 'getFormat'], $acceptable_mime_types));
$primary_format = $request->getRequestFormat();
foreach ($collection as $name => $route) {
diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
index ecde048bc51..262572be9a7 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
+++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
@@ -89,7 +89,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterfac
$color = 'blue';
$response = new AjaxResponse();
- $response->addCommand(new CssCommand($selector, array('background-color' => $color)));
+ $response->addCommand(new CssCommand($selector, ['background-color' => $color]));
return $response;
}
@@ -108,7 +108,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterfa
*/
function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
- $response->addCommand(new InvokeCommand('#invoke_div', 'addClass', array('error')));
+ $response->addCommand(new InvokeCommand('#invoke_div', 'addClass', ['error']));
return $response;
}
@@ -181,7 +181,7 @@ function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInte
*/
function ajax_forms_test_validation_form_callback($form, FormStateInterface $form_state) {
drupal_set_message("ajax_forms_test_validation_form_callback invoked");
- drupal_set_message(t("Callback: drivertext=%drivertext, spare_required_field=%spare_required_field", array('%drivertext' => $form_state->getValue('drivertext'), '%spare_required_field' => $form_state->getValue('spare_required_field'))));
+ drupal_set_message(t("Callback: drivertext=%drivertext, spare_required_field=%spare_required_field", ['%drivertext' => $form_state->getValue('drivertext'), '%spare_required_field' => $form_state->getValue('spare_required_field')]));
return ['#markup' => '<div id="message_area">ajax_forms_test_validation_form_callback at ' . date('c') . '</div>'];
}
@@ -190,7 +190,7 @@ function ajax_forms_test_validation_form_callback($form, FormStateInterface $for
*/
function ajax_forms_test_validation_number_form_callback($form, FormStateInterface $form_state) {
drupal_set_message("ajax_forms_test_validation_number_form_callback invoked");
- drupal_set_message(t("Callback: drivernumber=%drivernumber, spare_required_field=%spare_required_field", array('%drivernumber' => $form_state->getValue('drivernumber'), '%spare_required_field' => $form_state->getValue('spare_required_field'))));
+ drupal_set_message(t("Callback: drivernumber=%drivernumber, spare_required_field=%spare_required_field", ['%drivernumber' => $form_state->getValue('drivernumber'), '%spare_required_field' => $form_state->getValue('spare_required_field')]));
return ['#markup' => '<div id="message_area_number">ajax_forms_test_validation_number_form_callback at ' . date('c') . '</div>'];
}
diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php
index d04b21703df..e3c09af92cd 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php
+++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php
@@ -21,178 +21,178 @@ class AjaxFormsTestCommandsForm extends FormBase {
* {@inheritdoc}.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form = array();
+ $form = [];
// Shows the 'after' command with a callback generating commands.
- $form['after_command_example'] = array(
+ $form['after_command_example'] = [
'#value' => $this->t("AJAX 'After': Click to put something after the div"),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_after_callback',
- ),
+ ],
'#suffix' => '<div id="after_div">Something can be inserted after this</div>',
- );
+ ];
// Shows the 'alert' command.
- $form['alert_command_example'] = array(
+ $form['alert_command_example'] = [
'#value' => $this->t("AJAX 'Alert': Click to alert"),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_alert_callback',
- ),
- );
+ ],
+ ];
// Shows the 'append' command.
- $form['append_command_example'] = array(
+ $form['append_command_example'] = [
'#value' => $this->t("AJAX 'Append': Click to append something"),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_append_callback',
- ),
+ ],
'#suffix' => '<div id="append_div">Append inside this div</div>',
- );
+ ];
// Shows the 'before' command.
- $form['before_command_example'] = array(
+ $form['before_command_example'] = [
'#value' => $this->t("AJAX 'before': Click to put something before the div"),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_before_callback',
- ),
+ ],
'#suffix' => '<div id="before_div">Insert something before this.</div>',
- );
+ ];
// Shows the 'changed' command without asterisk.
- $form['changed_command_example'] = array(
+ $form['changed_command_example'] = [
'#value' => $this->t("AJAX changed: Click to mark div changed."),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_changed_callback',
- ),
+ ],
'#suffix' => '<div id="changed_div"> <div id="changed_div_mark_this">This div can be marked as changed or not.</div></div>',
- );
+ ];
// Shows the 'changed' command adding the asterisk.
- $form['changed_command_asterisk_example'] = array(
+ $form['changed_command_asterisk_example'] = [
'#value' => $this->t("AJAX changed: Click to mark div changed with asterisk."),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_changed_asterisk_callback',
- ),
- );
+ ],
+ ];
// Shows the Ajax 'css' command.
- $form['css_command_example'] = array(
+ $form['css_command_example'] = [
'#value' => $this->t("Set the '#box' div to be blue."),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_css_callback',
- ),
+ ],
'#suffix' => '<div id="css_div" style="height: 50px; width: 50px; border: 1px solid black"> box</div>',
- );
+ ];
// Shows the Ajax 'data' command. But there is no use of this information,
// as this would require a javascript client to use the data.
- $form['data_command_example'] = array(
+ $form['data_command_example'] = [
'#value' => $this->t("AJAX data command: Issue command."),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_data_callback',
- ),
+ ],
'#suffix' => '<div id="data_div">Data attached to this div.</div>',
- );
+ ];
// Shows the Ajax 'invoke' command.
- $form['invoke_command_example'] = array(
+ $form['invoke_command_example'] = [
'#value' => $this->t("AJAX invoke command: Invoke addClass() method."),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_invoke_callback',
- ),
+ ],
'#suffix' => '<div id="invoke_div">Original contents</div>',
- );
+ ];
// Shows the Ajax 'html' command.
- $form['html_command_example'] = array(
+ $form['html_command_example'] = [
'#value' => $this->t("AJAX html: Replace the HTML in a selector."),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_html_callback',
- ),
+ ],
'#suffix' => '<div id="html_div">Original contents</div>',
- );
+ ];
// Shows the Ajax 'insert' command.
- $form['insert_command_example'] = array(
+ $form['insert_command_example'] = [
'#value' => $this->t("AJAX insert: Let client insert based on #ajax['method']."),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_insert_callback',
'method' => 'prepend',
- ),
+ ],
'#suffix' => '<div id="insert_div">Original contents</div>',
- );
+ ];
// Shows the Ajax 'prepend' command.
- $form['prepend_command_example'] = array(
+ $form['prepend_command_example'] = [
'#value' => $this->t("AJAX 'prepend': Click to prepend something"),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_prepend_callback',
- ),
+ ],
'#suffix' => '<div id="prepend_div">Something will be prepended to this div. </div>',
- );
+ ];
// Shows the Ajax 'remove' command.
- $form['remove_command_example'] = array(
+ $form['remove_command_example'] = [
'#value' => $this->t("AJAX 'remove': Click to remove text"),
'#type' => 'submit',
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_remove_callback',
- ),
+ ],
'#suffix' => '<div id="remove_div"><div id="remove_text">text to be removed</div></div>',
- );
+ ];
// Shows the Ajax 'restripe' command.
- $form['restripe_command_example'] = array(
+ $form['restripe_command_example'] = [
'#type' => 'submit',
'#value' => $this->t("AJAX 'restripe' command"),
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_restripe_callback',
- ),
+ ],
'#suffix' => '<div id="restripe_div">
<table id="restripe_table" style="border: 1px solid black" >
<tr id="table-first"><td>first row</td></tr>
<tr ><td>second row</td></tr>
</table>
</div>',
- );
+ ];
// Demonstrates the Ajax 'settings' command. The 'settings' command has
// nothing visual to "show", but it can be tested via SimpleTest and via
// Firebug.
- $form['settings_command_example'] = array(
+ $form['settings_command_example'] = [
'#type' => 'submit',
'#value' => $this->t("AJAX 'settings' command"),
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_settings_callback',
- ),
- );
+ ],
+ ];
// Shows the Ajax 'add_css' command.
- $form['add_css_command_example'] = array(
+ $form['add_css_command_example'] = [
'#type' => 'submit',
'#value' => $this->t("AJAX 'add_css' command"),
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_add_css_callback',
- ),
- );
+ ],
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php
index 19aaaf35e57..852cf443521 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php
+++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php
@@ -26,20 +26,20 @@ class AjaxFormsTestLazyLoadForm extends FormBase {
// command to ensure that the 'currentPath' setting is not part
// of the Ajax response.
$form['#attached']['drupalSettings']['test'] = 'currentPathUpdate';
- $form['add_files'] = array(
+ $form['add_files'] = [
'#title' => $this->t('Add files'),
'#type' => 'checkbox',
'#default_value' => FALSE,
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
- '#ajax' => array(
+ '#ajax' => [
'wrapper' => 'ajax-forms-test-lazy-load-ajax-wrapper',
'callback' => 'ajax_forms_test_lazy_load_form_ajax',
- ),
+ ],
'#prefix' => '<div id="ajax-forms-test-lazy-load-ajax-wrapper"></div>',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php
index 8ec5b71a51e..f69a1232319 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php
+++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php
@@ -24,47 +24,47 @@ class AjaxFormsTestSimpleForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$object = new Callbacks();
- $form = array();
- $form['select'] = array(
+ $form = [];
+ $form['select'] = [
'#title' => $this->t('Color'),
'#type' => 'select',
- '#options' => array(
+ '#options' => [
'red' => 'red',
'green' => 'green',
- 'blue' => 'blue'),
- '#ajax' => array(
- 'callback' => array($object, 'selectCallback'),
- ),
+ 'blue' => 'blue'],
+ '#ajax' => [
+ 'callback' => [$object, 'selectCallback'],
+ ],
'#suffix' => '<div id="ajax_selected_color">No color yet selected</div>',
- );
+ ];
- $form['checkbox'] = array(
+ $form['checkbox'] = [
'#type' => 'checkbox',
'#title' => $this->t('Test checkbox'),
- '#ajax' => array(
- 'callback' => array($object, 'checkboxCallback'),
- ),
+ '#ajax' => [
+ 'callback' => [$object, 'checkboxCallback'],
+ ],
'#suffix' => '<div id="ajax_checkbox_value">No action yet</div>',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('submit'),
- );
+ ];
// This is for testing invalid callbacks that should return a 500 error in
// \Drupal\Core\Form\FormAjaxResponseBuilderInterface::buildResponse().
- $invalid_callbacks = array(
+ $invalid_callbacks = [
'null' => NULL,
'empty' => '',
'nonexistent' => 'some_function_that_does_not_exist',
- );
+ ];
foreach ($invalid_callbacks as $key => $value) {
- $form['select_' . $key . '_callback'] = array(
+ $form['select_' . $key . '_callback'] = [
'#type' => 'select',
- '#title' => $this->t('Test %key callbacks', array('%key' => $key)),
- '#options' => array('red' => 'red'),
- '#ajax' => array('callback' => $value),
- );
+ '#title' => $this->t('Test %key callbacks', ['%key' => $key]),
+ '#options' => ['red' => 'red'],
+ '#ajax' => ['callback' => $value],
+ ];
}
$form['test_group'] = [
diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php
index dbf0b7fa5a2..fb3019493c0 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php
+++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php
@@ -21,42 +21,42 @@ class AjaxFormsTestValidationForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['drivertext'] = array(
+ $form['drivertext'] = [
'#title' => $this->t('AJAX-enabled textfield.'),
'#description' => $this->t("When this one AJAX-triggers and the spare required field is empty, you should not get an error."),
'#type' => 'textfield',
'#default_value' => $form_state->getValue('drivertext', ''),
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_validation_form_callback',
'wrapper' => 'message_area',
'method' => 'replace',
- ),
+ ],
'#suffix' => '<div id="message_area"></div>',
- );
+ ];
- $form['drivernumber'] = array(
+ $form['drivernumber'] = [
'#title' => $this->t('AJAX-enabled number field.'),
'#description' => $this->t("When this one AJAX-triggers and the spare required field is empty, you should not get an error."),
'#type' => 'number',
'#default_value' => $form_state->getValue('drivernumber', ''),
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'ajax_forms_test_validation_number_form_callback',
'wrapper' => 'message_area_number',
'method' => 'replace',
- ),
+ ],
'#suffix' => '<div id="message_area_number"></div>',
- );
+ ];
- $form['spare_required_field'] = array(
+ $form['spare_required_field'] = [
'#title' => $this->t("Spare Required Field"),
'#type' => 'textfield',
'#required' => TRUE,
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
index 63cc0abf163..5ba65e8013a 100644
--- a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
@@ -22,22 +22,22 @@ class AjaxTestController {
*/
public static function dialogContents() {
// This is a regular render array; the keys do not have special meaning.
- $content = array(
+ $content = [
'#title' => '<em>AJAX Dialog & contents</em>',
- 'content' => array(
+ 'content' => [
'#markup' => 'Example message',
- ),
- 'cancel' => array(
+ ],
+ 'cancel' => [
'#type' => 'link',
'#title' => 'Cancel',
'#url' => Url::fromRoute('<front>'),
- '#attributes' => array(
+ '#attributes' => [
// This is a special class to which JavaScript assigns dialog closing
// behavior.
- 'class' => array('dialog-cancel'),
- ),
- ),
- );
+ 'class' => ['dialog-cancel'],
+ ],
+ ],
+ ];
return $content;
}
@@ -111,88 +111,88 @@ class AjaxTestController {
public function dialog() {
// Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
// the global drupal-modal wrapper by default.
- $build['dialog_wrappers'] = array('#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>');
+ $build['dialog_wrappers'] = ['#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>'];
// Dialog behavior applied to a button.
$build['form'] = \Drupal::formBuilder()->getForm('Drupal\ajax_test\Form\AjaxTestDialogForm');
// Dialog behavior applied to a #type => 'link'.
- $build['link'] = array(
+ $build['link'] = [
'#type' => 'link',
'#title' => 'Link 1 (modal)',
'#url' => Url::fromRoute('ajax_test.dialog_contents'),
- '#attributes' => array(
- 'class' => array('use-ajax'),
+ '#attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
- ),
- );
+ ],
+ ];
// Dialog behavior applied to links rendered by links.html.twig.
- $build['links'] = array(
+ $build['links'] = [
'#theme' => 'links',
- '#links' => array(
- 'link2' => array(
+ '#links' => [
+ 'link2' => [
'title' => 'Link 2 (modal)',
'url' => Url::fromRoute('ajax_test.dialog_contents'),
- 'attributes' => array(
- 'class' => array('use-ajax'),
+ 'attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
- 'data-dialog-options' => json_encode(array(
+ 'data-dialog-options' => json_encode([
'width' => 400,
- ))
- ),
- ),
- 'link3' => array(
+ ])
+ ],
+ ],
+ 'link3' => [
'title' => 'Link 3 (non-modal)',
'url' => Url::fromRoute('ajax_test.dialog_contents'),
- 'attributes' => array(
- 'class' => array('use-ajax'),
+ 'attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'dialog',
- 'data-dialog-options' => json_encode(array(
+ 'data-dialog-options' => json_encode([
'target' => 'ajax-test-dialog-wrapper-1',
'width' => 800,
- ))
- ),
- ),
- 'link4' => array(
+ ])
+ ],
+ ],
+ 'link4' => [
'title' => 'Link 4 (close non-modal if open)',
'url' => Url::fromRoute('ajax_test.dialog_close'),
- 'attributes' => array(
- 'class' => array('use-ajax'),
+ 'attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
- ),
- ),
- 'link5' => array(
+ ],
+ ],
+ 'link5' => [
'title' => 'Link 5 (form)',
'url' => Url::fromRoute('ajax_test.dialog_form'),
- 'attributes' => array(
- 'class' => array('use-ajax'),
+ 'attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
- ),
- ),
- 'link6' => array(
+ ],
+ ],
+ 'link6' => [
'title' => 'Link 6 (entity form)',
'url' => Url::fromRoute('contact.form_add'),
- 'attributes' => array(
- 'class' => array('use-ajax'),
+ 'attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
- 'data-dialog-options' => json_encode(array(
+ 'data-dialog-options' => json_encode([
'width' => 800,
'height' => 500,
- ))
- ),
- ),
- 'link7' => array(
+ ])
+ ],
+ ],
+ 'link7' => [
'title' => 'Link 7 (non-modal, no target)',
'url' => Url::fromRoute('ajax_test.dialog_contents'),
- 'attributes' => array(
- 'class' => array('use-ajax'),
+ 'attributes' => [
+ 'class' => ['use-ajax'],
'data-dialog-type' => 'dialog',
- 'data-dialog-options' => json_encode(array(
+ 'data-dialog-options' => json_encode([
'width' => 800,
- ))
- ),
- ),
+ ])
+ ],
+ ],
'link8' => [
'title' => 'Link 8 (ajax)',
'url' => Url::fromRoute('ajax_test.admin.theme'),
@@ -204,8 +204,8 @@ class AjaxTestController {
]),
],
],
- ),
- );
+ ],
+ ];
return $build;
}
diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
index a97ed9525bc..5f11b6b71a2 100644
--- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
@@ -28,25 +28,25 @@ class AjaxTestDialogForm extends FormBase {
// In order to use WebTestBase::drupalPostAjaxForm() to POST from a link, we need
// to have a dummy field we can set in WebTestBase::drupalPostForm() else it won't
// submit anything.
- $form['textfield'] = array(
+ $form['textfield'] = [
'#type' => 'hidden'
- );
- $form['button1'] = array(
+ ];
+ $form['button1'] = [
'#type' => 'submit',
'#name' => 'button1',
'#value' => 'Button 1 (modal)',
- '#ajax' => array(
+ '#ajax' => [
'callback' => '::modal',
- ),
- );
- $form['button2'] = array(
+ ],
+ ];
+ $form['button2'] = [
'#type' => 'submit',
'#name' => 'button2',
'#value' => 'Button 2 (non-modal)',
- '#ajax' => array(
+ '#ajax' => [
'callback' => '::nonModal',
- ),
- );
+ ],
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php
index 604876994e2..ea431efa5ad 100644
--- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php
@@ -24,23 +24,23 @@ class AjaxTestForm extends FormBase {
$form['#action'] = \Drupal::url('ajax_test.dialog');
- $form['description'] = array(
+ $form['description'] = [
'#markup' => '<p>' . $this->t("Ajax Form contents description.") . '</p>',
- );
+ ];
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Do it'),
- );
- $form['actions']['preview'] = array(
+ ];
+ $form['actions']['preview'] = [
'#type' => 'submit',
'#value' => $this->t('Preview'),
// No regular submit-handler. This form only works via JavaScript.
- '#submit' => array(),
- '#ajax' => array(
+ '#submit' => [],
+ '#ajax' => [
// This means the ::preview() method on this class would be invoked in
// case of a click event. However, since Drupal core's test runner only
// is able to execute PHP, not JS, there is no point in actually
@@ -51,8 +51,8 @@ class AjaxTestForm extends FormBase {
// we cannot meaningfully test it anyway.
'callback' => '::preview',
'event' => 'click',
- ),
- );
+ ],
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc b/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc
index 4a271b087a1..9116c85fed7 100644
--- a/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc
+++ b/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc
@@ -100,7 +100,7 @@ function _batch_test_finished_helper($batch_id, $success, $results, $operations)
if (!$success) {
// A fatal error occurred during the processing.
$error_operation = reset($operations);
- $messages[] = t('An error occurred while processing @op with arguments:<br />@args', array('@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)));
+ $messages[] = t('An error occurred while processing @op with arguments:<br />@args', ['@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)]);
}
// Use item list template to render the messages.
diff --git a/core/modules/system/tests/modules/batch_test/batch_test.module b/core/modules/system/tests/modules/batch_test/batch_test.module
index e7a8de6e249..59327de4fe2 100644
--- a/core/modules/system/tests/modules/batch_test/batch_test.module
+++ b/core/modules/system/tests/modules/batch_test/batch_test.module
@@ -20,11 +20,11 @@ function _batch_test_nested_drupal_form_submit_callback($value) {
* Batch 0: Does nothing.
*/
function _batch_test_batch_0() {
- $batch = array(
- 'operations' => array(),
+ $batch = [
+ 'operations' => [],
'finished' => '_batch_test_finished_0',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
- );
+ ];
return $batch;
}
@@ -38,15 +38,15 @@ function _batch_test_batch_1() {
$total = 10;
$sleep = (1000000 / $total) * 2;
- $operations = array();
+ $operations = [];
for ($i = 1; $i <= $total; $i++) {
- $operations[] = array('_batch_test_callback_1', array($i, $sleep));
+ $operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
- $batch = array(
+ $batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_1',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
- );
+ ];
return $batch;
}
@@ -60,14 +60,14 @@ function _batch_test_batch_2() {
$total = 10;
$sleep = (1000000 / $total) * 2;
- $operations = array(
- array('_batch_test_callback_2', array(1, $total, $sleep)),
- );
- $batch = array(
+ $operations = [
+ ['_batch_test_callback_2', [1, $total, $sleep]],
+ ];
+ $batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_2',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
- );
+ ];
return $batch;
}
@@ -85,20 +85,20 @@ function _batch_test_batch_3() {
$total = 10;
$sleep = (1000000 / $total) * 2;
- $operations = array();
+ $operations = [];
for ($i = 1; $i <= round($total / 2); $i++) {
- $operations[] = array('_batch_test_callback_1', array($i, $sleep));
+ $operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
- $operations[] = array('_batch_test_callback_2', array(1, $total / 2, $sleep));
+ $operations[] = ['_batch_test_callback_2', [1, $total / 2, $sleep]];
for ($i = round($total / 2) + 1; $i <= $total; $i++) {
- $operations[] = array('_batch_test_callback_1', array($i, $sleep));
+ $operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
- $operations[] = array('_batch_test_callback_2', array(6, $total / 2, $sleep));
- $batch = array(
+ $operations[] = ['_batch_test_callback_2', [6, $total / 2, $sleep]];
+ $batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_3',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
- );
+ ];
return $batch;
}
@@ -115,19 +115,19 @@ function _batch_test_batch_4() {
$total = 10;
$sleep = (1000000 / $total) * 2;
- $operations = array();
+ $operations = [];
for ($i = 1; $i <= round($total / 2); $i++) {
- $operations[] = array('_batch_test_callback_1', array($i, $sleep));
+ $operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
- $operations[] = array('_batch_test_nested_batch_callback', array());
+ $operations[] = ['_batch_test_nested_batch_callback', []];
for ($i = round($total / 2) + 1; $i <= $total; $i++) {
- $operations[] = array('_batch_test_callback_1', array($i, $sleep));
+ $operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
- $batch = array(
+ $batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_4',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
- );
+ ];
return $batch;
}
@@ -141,15 +141,15 @@ function _batch_test_batch_5() {
$total = 10;
$sleep = (1000000 / $total) * 2;
- $operations = array();
+ $operations = [];
for ($i = 1; $i <= $total; $i++) {
- $operations[] = array('_batch_test_callback_5', array($i, $sleep));
+ $operations[] = ['_batch_test_callback_5', [$i, $sleep]];
}
- $batch = array(
+ $batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_5',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
- );
+ ];
return $batch;
}
diff --git a/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php b/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php
index 811c7fc3568..1cdaf5cc853 100644
--- a/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php
+++ b/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php
@@ -16,11 +16,11 @@ class BatchTestController {
* Render array containing success message.
*/
public function testRedirect() {
- return array(
- 'success' => array(
+ return [
+ 'success' => [
'#markup' => 'Redirection successful.',
- )
- );
+ ]
+ ];
}
/**
@@ -47,9 +47,9 @@ class BatchTestController {
*/
public function testNestedDrupalFormSubmit($value = 1) {
// Set the batch and process it.
- $batch['operations'] = array(
- array('_batch_test_nested_drupal_form_submit_callback', array($value)),
- );
+ $batch['operations'] = [
+ ['_batch_test_nested_drupal_form_submit_callback', [$value]],
+ ];
batch_set($batch);
return batch_process('batch-test/redirect');
}
@@ -100,11 +100,11 @@ class BatchTestController {
'value' => $value,
]);
\Drupal::formBuilder()->submitForm('Drupal\batch_test\Form\BatchTestChainedForm', $form_state);
- return array(
- 'success' => array(
+ return [
+ 'success' => [
'#markup' => 'Got out of a programmatic batched form.',
- )
- );
+ ]
+ ];
}
/**
@@ -115,11 +115,11 @@ class BatchTestController {
*/
public function testThemeBatch() {
batch_test_stack(NULL, TRUE);
- $batch = array(
- 'operations' => array(
- array('_batch_test_theme_callback', array()),
- ),
- );
+ $batch = [
+ 'operations' => [
+ ['_batch_test_theme_callback', []],
+ ],
+ ];
batch_set($batch);
return batch_process('batch-test/redirect');
}
diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php
index aa19ad3faba..fe2d02c5f13 100644
--- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php
+++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php
@@ -23,21 +23,21 @@ class BatchTestChainedForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
// This value is used to test that $form_state persists through batched
// submit handlers.
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'textfield',
'#title' => 'Value',
'#default_value' => 1,
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
- $form['#submit'] = array(
+ ];
+ $form['#submit'] = [
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit1',
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit2',
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit3',
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit4',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php
index ec8caff0913..2d26bcf4d58 100644
--- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php
+++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php
@@ -21,14 +21,14 @@ class BatchTestMockForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['test_value'] = array(
+ $form['test_value'] = [
'#title' => t('Test value'),
'#type' => 'textfield',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php
index 260941f50b6..916831e96b5 100644
--- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php
+++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php
@@ -27,13 +27,13 @@ class BatchTestMultiStepForm extends FormBase {
$form_state->set('step', $step);
}
- $form['step_display'] = array(
+ $form['step_display'] = [
'#markup' => 'step ' . $step . '<br/>',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
// This is a POST form with multiple steps that does not transition from one
// step to the next via POST requests, but via GET requests, because it uses
diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php
index 92cf6b110a6..999649dfc2d 100644
--- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php
+++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php
@@ -21,21 +21,21 @@ class BatchTestSimpleForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['batch'] = array(
+ $form['batch'] = [
'#type' => 'select',
'#title' => 'Choose batch',
- '#options' => array(
+ '#options' => [
'batch_0' => 'batch 0',
'batch_1' => 'batch 1',
'batch_2' => 'batch 2',
'batch_3' => 'batch 3',
'batch_4' => 'batch 4',
- ),
- );
- $form['submit'] = array(
+ ],
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module
index 0633ac889da..97bba7b3414 100644
--- a/core/modules/system/tests/modules/common_test/common_test.module
+++ b/core/modules/system/tests/modules/common_test/common_test.module
@@ -114,18 +114,18 @@ function common_test_module_implements_alter(&$implementations, $hook) {
* Implements hook_theme().
*/
function common_test_theme() {
- return array(
- 'common_test_foo' => array(
- 'variables' => array('foo' => 'foo', 'bar' => 'bar'),
- ),
- 'common_test_render_element' => array(
+ return [
+ 'common_test_foo' => [
+ 'variables' => ['foo' => 'foo', 'bar' => 'bar'],
+ ],
+ 'common_test_render_element' => [
'render element' => 'foo',
- ),
- 'common_test_empty' => array(
- 'variables' => array('foo' => 'foo'),
+ ],
+ 'common_test_empty' => [
+ 'variables' => ['foo' => 'foo'],
'function' => 'theme_common_test_empty',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php b/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php
index f77a5813a61..bb98a59c974 100644
--- a/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php
+++ b/core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php
@@ -18,40 +18,40 @@ class CommonTestController {
* generator.
*/
public function typeLinkActiveClass() {
- return array(
- 'no_query' => array(
+ return [
+ 'no_query' => [
'#type' => 'link',
'#title' => t('Link with no query string'),
'#url' => Url::fromRoute('<current>'),
- '#options' => array(
+ '#options' => [
'set_active_class' => TRUE,
- ),
- ),
- 'with_query' => array(
+ ],
+ ],
+ 'with_query' => [
'#type' => 'link',
'#title' => t('Link with a query string'),
'#url' => Url::fromRoute('<current>'),
- '#options' => array(
- 'query' => array(
+ '#options' => [
+ 'query' => [
'foo' => 'bar',
'one' => 'two',
- ),
+ ],
'set_active_class' => TRUE,
- ),
- ),
- 'with_query_reversed' => array(
+ ],
+ ],
+ 'with_query_reversed' => [
'#type' => 'link',
'#title' => t('Link with the same query string in reverse order'),
'#url' => Url::fromRoute('<current>'),
- '#options' => array(
- 'query' => array(
+ '#options' => [
+ 'query' => [
'one' => 'two',
'foo' => 'bar',
- ),
+ ],
'set_active_class' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -61,18 +61,18 @@ class CommonTestController {
* An empty string.
*/
public function jsAndCssQuerystring() {
- $attached = array(
- '#attached' => array(
- 'library' => array(
+ $attached = [
+ '#attached' => [
+ 'library' => [
'node/drupal.node',
- ),
- 'css' => array(
- drupal_get_path('module', 'node') . '/css/node.admin.css' => array(),
+ ],
+ 'css' => [
+ drupal_get_path('module', 'node') . '/css/node.admin.css' => [],
// A relative URI may have a query string.
- '/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2' => array(),
- ),
- ),
- );
+ '/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2' => [],
+ ],
+ ],
+ ];
return \Drupal::service('renderer')->renderRoot($attached);
}
diff --git a/core/modules/system/tests/modules/condition_test/src/FormController.php b/core/modules/system/tests/modules/condition_test/src/FormController.php
index 38b21ccade4..da475ae0c4e 100644
--- a/core/modules/system/tests/modules/condition_test/src/FormController.php
+++ b/core/modules/system/tests/modules/condition_test/src/FormController.php
@@ -39,10 +39,10 @@ class FormController implements FormInterface {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = $this->condition->buildConfigurationForm($form, $form_state);
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/database_test/database_test.install b/core/modules/system/tests/modules/database_test/database_test.install
index f6b4f68d82c..62cf38addd3 100644
--- a/core/modules/system/tests/modules/database_test/database_test.install
+++ b/core/modules/system/tests/modules/database_test/database_test.install
@@ -14,281 +14,281 @@
* like any other, not directly in the test file.
*/
function database_test_schema() {
- $schema['test'] = array(
+ $schema['test'] = [
'description' => 'Basic test table for the database unit tests.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => "A person's name",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'binary' => TRUE,
- ),
- 'age' => array(
+ ],
+ 'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'job' => array(
+ ],
+ 'job' => [
'description' => "The person's job",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Undefined',
- ),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'name' => array('name')
- ),
- 'indexes' => array(
- 'ages' => array('age'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'name' => ['name']
+ ],
+ 'indexes' => [
+ 'ages' => ['age'],
+ ],
+ ];
// This is an alternate version of the same table that is structured the same
// but has a non-serial Primary Key.
- $schema['test_people'] = array(
+ $schema['test_people'] = [
'description' => 'A duplicate version of the test table, used for additional tests.',
- 'fields' => array(
- 'name' => array(
+ 'fields' => [
+ 'name' => [
'description' => "A person's name",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'age' => array(
+ ],
+ 'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'job' => array(
+ ],
+ 'job' => [
'description' => "The person's job",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- ),
- 'primary key' => array('job'),
- 'indexes' => array(
- 'ages' => array('age'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['job'],
+ 'indexes' => [
+ 'ages' => ['age'],
+ ],
+ ];
- $schema['test_people_copy'] = array(
+ $schema['test_people_copy'] = [
'description' => 'A duplicate version of the test_people table, used for additional tests.',
- 'fields' => array(
- 'name' => array(
+ 'fields' => [
+ 'name' => [
'description' => "A person's name",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'age' => array(
+ ],
+ 'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'job' => array(
+ ],
+ 'job' => [
'description' => "The person's job",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- ),
- 'primary key' => array('job'),
- 'indexes' => array(
- 'ages' => array('age'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['job'],
+ 'indexes' => [
+ 'ages' => ['age'],
+ ],
+ ];
- $schema['test_one_blob'] = array(
+ $schema['test_one_blob'] = [
'description' => 'A simple table including a BLOB field for testing BLOB behavior.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'description' => 'Simple unique ID.',
'type' => 'serial',
'not null' => TRUE,
- ),
- 'blob1' => array(
+ ],
+ 'blob1' => [
'description' => 'A BLOB field.',
'type' => 'blob',
- ),
- ),
- 'primary key' => array('id'),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ ];
- $schema['test_two_blobs'] = array(
+ $schema['test_two_blobs'] = [
'description' => 'A simple test table with two BLOB fields.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'description' => 'Simple unique ID.',
'type' => 'serial',
'not null' => TRUE,
- ),
- 'blob1' => array(
+ ],
+ 'blob1' => [
'description' => 'A dummy BLOB field.',
'type' => 'blob',
- ),
- 'blob2' => array(
+ ],
+ 'blob2' => [
'description' => 'A second BLOB field.',
'type' => 'blob'
- ),
- ),
- 'primary key' => array('id'),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ ];
- $schema['test_task'] = array(
+ $schema['test_task'] = [
'description' => 'A task list for people in the test table.',
- 'fields' => array(
- 'tid' => array(
+ 'fields' => [
+ 'tid' => [
'description' => 'Task ID, primary key.',
'type' => 'serial',
'not null' => TRUE,
- ),
- 'pid' => array(
+ ],
+ 'pid' => [
'description' => 'The {test_people}.pid, foreign key for the test table.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'task' => array(
+ ],
+ 'task' => [
'description' => 'The task to be completed.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'priority' => array(
+ ],
+ 'priority' => [
'description' => 'The priority of the task.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('tid'),
- );
+ ],
+ ],
+ 'primary key' => ['tid'],
+ ];
- $schema['test_null'] = array(
+ $schema['test_null'] = [
'description' => 'Basic test table for NULL value handling.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => "A person's name.",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => FALSE,
'default' => '',
- ),
- 'age' => array(
+ ],
+ 'age' => [
'description' => "The person's age.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
- 'default' => 0),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'name' => array('name')
- ),
- 'indexes' => array(
- 'ages' => array('age'),
- ),
- );
+ 'default' => 0],
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'name' => ['name']
+ ],
+ 'indexes' => [
+ 'ages' => ['age'],
+ ],
+ ];
- $schema['test_serialized'] = array(
+ $schema['test_serialized'] = [
'description' => 'Basic test table for NULL value handling.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => "A person's name.",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => FALSE,
'default' => '',
- ),
- 'info' => array(
+ ],
+ 'info' => [
'description' => "The person's data in serialized form.",
'type' => 'blob',
'serialize' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'name' => array('name')
- ),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'name' => ['name']
+ ],
+ ];
- $schema['test_composite_primary'] = array(
+ $schema['test_composite_primary'] = [
'description' => 'Basic test table with a composite primary key',
- 'fields' => array(
- 'name' => array(
+ 'fields' => [
+ 'name' => [
'description' => "A person's name",
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
'binary' => TRUE,
- ),
- 'age' => array(
+ ],
+ 'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'job' => array(
+ ],
+ 'job' => [
'description' => "The person's job",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Undefined',
- ),
- ),
- 'primary key' => array('name', 'age'),
- );
+ ],
+ ],
+ 'primary key' => ['name', 'age'],
+ ];
- $schema['test_special_columns'] = array(
+ $schema['test_special_columns'] = [
'description' => 'A simple test table with special column names.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'description' => 'Simple unique ID.',
'type' => 'int',
'not null' => TRUE,
- ),
- 'offset' => array(
+ ],
+ 'offset' => [
'description' => 'A column with preserved name.',
'type' => 'text',
- ),
- ),
- 'primary key' => array('id'),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ ];
$schema['TEST_UPPERCASE'] = $schema['test'];
diff --git a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
index 7de24d49e8f..bd6dd9c7b27 100644
--- a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
+++ b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
@@ -19,11 +19,11 @@ class DatabaseTestController {
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function dbQueryTemporary() {
- $table_name = db_query_temporary('SELECT age FROM {test}', array());
- return new JsonResponse(array(
+ $table_name = db_query_temporary('SELECT age FROM {test}', []);
+ return new JsonResponse([
'table_name' => $table_name,
'row_count' => db_select($table_name)->countQuery()->execute()->fetchField(),
- ));
+ ]);
}
/**
@@ -37,7 +37,7 @@ class DatabaseTestController {
public function pagerQueryEven($limit) {
$query = db_select('test', 't');
$query
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->orderBy('age');
// This should result in 2 pages of results.
@@ -47,9 +47,9 @@ class DatabaseTestController {
$names = $query->execute()->fetchCol();
- return new JsonResponse(array(
+ return new JsonResponse([
'names' => $names,
- ));
+ ]);
}
/**
@@ -63,7 +63,7 @@ class DatabaseTestController {
public function pagerQueryOdd($limit) {
$query = db_select('test_task', 't');
$query
- ->fields('t', array('task'))
+ ->fields('t', ['task'])
->orderBy('pid');
// This should result in 4 pages of results.
@@ -73,9 +73,9 @@ class DatabaseTestController {
$names = $query->execute()->fetchCol();
- return new JsonResponse(array(
+ return new JsonResponse([
'names' => $names,
- ));
+ ]);
}
/**
@@ -87,16 +87,16 @@ class DatabaseTestController {
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function testTablesort() {
- $header = array(
- 'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
- 'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
- 'task' => array('data' => t('Task'), 'field' => 'task'),
- 'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
- );
+ $header = [
+ 'tid' => ['data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'],
+ 'pid' => ['data' => t('Person ID'), 'field' => 'pid'],
+ 'task' => ['data' => t('Task'), 'field' => 'task'],
+ 'priority' => ['data' => t('Priority'), 'field' => 'priority', ],
+ ];
$query = db_select('test_task', 't');
$query
- ->fields('t', array('tid', 'pid', 'task', 'priority'));
+ ->fields('t', ['tid', 'pid', 'task', 'priority']);
$query = $query
->extend('Drupal\Core\Database\Query\TableSortExtender')
@@ -105,9 +105,9 @@ class DatabaseTestController {
// We need all the results at once to check the sort.
$tasks = $query->execute()->fetchAll();
- return new JsonResponse(array(
+ return new JsonResponse([
'tasks' => $tasks,
- ));
+ ]);
}
/**
@@ -119,16 +119,16 @@ class DatabaseTestController {
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function testTablesortFirst() {
- $header = array(
- 'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
- 'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
- 'task' => array('data' => t('Task'), 'field' => 'task'),
- 'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
- );
+ $header = [
+ 'tid' => ['data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'],
+ 'pid' => ['data' => t('Person ID'), 'field' => 'pid'],
+ 'task' => ['data' => t('Task'), 'field' => 'task'],
+ 'priority' => ['data' => t('Priority'), 'field' => 'priority', ],
+ ];
$query = db_select('test_task', 't');
$query
- ->fields('t', array('tid', 'pid', 'task', 'priority'));
+ ->fields('t', ['tid', 'pid', 'task', 'priority']);
$query = $query
->extend('Drupal\Core\Database\Query\TableSortExtender')
@@ -138,9 +138,9 @@ class DatabaseTestController {
// We need all the results at once to check the sort.
$tasks = $query->execute()->fetchAll();
- return new JsonResponse(array(
+ return new JsonResponse([
'tasks' => $tasks,
- ));
+ ]);
}
}
diff --git a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
index 96125548bcc..12eebccab63 100644
--- a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
+++ b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
@@ -22,10 +22,10 @@ class DatabaseTestForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $header = array(
- 'username' => array('data' => t('Username'), 'field' => 'u.name'),
- 'status' => array('data' => t('Status'), 'field' => 'u.status'),
- );
+ $header = [
+ 'username' => ['data' => t('Username'), 'field' => 'u.name'],
+ 'status' => ['data' => t('Status'), 'field' => 'u.status'],
+ ];
$query = db_select('users_field_data', 'u');
$query->condition('u.uid', 0, '<>');
@@ -38,7 +38,7 @@ class DatabaseTestForm extends FormBase {
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('Drupal\Core\Database\Query\TableSortExtender');
$query
- ->fields('u', array('uid'))
+ ->fields('u', ['uid'])
->limit(50)
->orderByHeader($header)
->setCountQuery($count_query);
@@ -46,22 +46,22 @@ class DatabaseTestForm extends FormBase {
->execute()
->fetchCol();
- $options = array();
+ $options = [];
foreach (User::loadMultiple($uids) as $account) {
- $options[$account->id()] = array(
- 'title' => array('data' => array('#title' => $account->getUsername())),
+ $options[$account->id()] = [
+ 'title' => ['data' => ['#title' => $account->getUsername()]],
'username' => $account->getUsername(),
'status' => $account->isActive() ? t('active') : t('blocked'),
- );
+ ];
}
- $form['accounts'] = array(
+ $form['accounts'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No people available.'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php b/core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php
index 3768bcdf976..acfed444c4a 100644
--- a/core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php
+++ b/core/modules/system/tests/modules/display_variant_test/src/EventSubscriber/TestPageDisplayVariantSubscriber.php
@@ -32,7 +32,7 @@ class TestPageDisplayVariantSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = array('onSelectPageDisplayVariant');
+ $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = ['onSelectPageDisplayVariant'];
return $events;
}
diff --git a/core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module b/core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module
index 51b506b5dde..5ae4fcbbf15 100644
--- a/core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module
+++ b/core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module
@@ -12,7 +12,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* Implements hook_entity_base_field_info().
*/
function entity_reference_test_entity_base_field_info(EntityTypeInterface $entity_type) {
- $fields = array();
+ $fields = [];
if ($entity_type->id() === 'entity_test') {
$fields['user_role'] = BaseFieldDefinition::create('entity_reference')
@@ -33,10 +33,10 @@ function entity_reference_test_entity_base_field_info_alter(&$fields, EntityType
// Allow user_id field to use configurable widget.
$fields['user_id']
->setSetting('handler', 'default')
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
}
}
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.install b/core/modules/system/tests/modules/entity_test/entity_test.install
index 5e3bcaa2a13..c796c9adcbc 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.install
+++ b/core/modules/system/tests/modules/entity_test/entity_test.install
@@ -15,12 +15,12 @@ use Drupal\field\Entity\FieldConfig;
function entity_test_install() {
foreach (entity_test_entity_types() as $entity_type) {
// Auto-create fields for testing.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'type' => 'text',
'cardinality' => 1,
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
@@ -30,7 +30,7 @@ function entity_test_install() {
])->save();
entity_get_form_display($entity_type, $entity_type, 'default')
- ->setComponent('field_test_text', array('type' => 'text_textfield'))
+ ->setComponent('field_test_text', ['type' => 'text_textfield'])
->save();
}
}
@@ -40,17 +40,17 @@ function entity_test_install() {
*/
function entity_test_schema() {
// Schema for simple entity.
- $schema['entity_test_example'] = array(
+ $schema['entity_test_example'] = [
'description' => 'Stores entity_test items.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique entity-test item ID.',
- ),
- ),
- 'primary key' => array('id'),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ ];
return $schema;
}
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index cf1a63ccfec..3a7a51dde7f 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -54,7 +54,7 @@ const ENTITY_TEST_TYPES_ROUTING = 3;
* List with entity_types.
*/
function entity_test_entity_types($filter = NULL) {
- $types = array();
+ $types = [];
if ($filter === NULL || $filter === ENTITY_TEST_TYPES_ROUTING) {
$types[] = 'entity_test';
}
@@ -168,7 +168,7 @@ function entity_test_entity_base_field_info_alter(&$fields, EntityTypeInterface
*/
function entity_test_entity_field_storage_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'entity_test_update') {
- return \Drupal::state()->get('entity_test_update.additional_field_storage_definitions', array());
+ return \Drupal::state()->get('entity_test_update.additional_field_storage_definitions', []);
}
}
@@ -185,8 +185,8 @@ function entity_test_entity_field_storage_info(EntityTypeInterface $entity_type)
* 'entity_test'.
*/
function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity_test') {
- $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
- $bundles += array($bundle => array('label' => $text ? $text : $bundle));
+ $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: [$entity_type => ['label' => 'Entity Test Bundle']];
+ $bundles += [$bundle => ['label' => $text ? $text : $bundle]];
\Drupal::state()->set($entity_type . '.bundles', $bundles);
\Drupal::entityManager()->onBundleCreate($bundle, $entity_type);
@@ -202,7 +202,7 @@ function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity
* 'entity_test'.
*/
function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
- $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
+ $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: [$entity_type => ['label' => 'Entity Test Bundle']];
unset($bundles[$bundle]);
\Drupal::state()->set($entity_type . '.bundles', $bundles);
@@ -213,11 +213,11 @@ function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
* Implements hook_entity_bundle_info().
*/
function entity_test_entity_bundle_info() {
- $bundles = array();
+ $bundles = [];
$entity_types = \Drupal::entityManager()->getDefinitions();
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type->getProvider() == 'entity_test' && $entity_type_id != 'entity_test_with_bundle') {
- $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles') ?: array($entity_type_id => array('label' => 'Entity Test Bundle'));
+ $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles') ?: [$entity_type_id => ['label' => 'Entity Test Bundle']];
}
}
return $bundles;
@@ -230,18 +230,18 @@ function entity_test_entity_view_mode_info_alter(&$view_modes) {
$entity_info = \Drupal::entityManager()->getDefinitions();
foreach ($entity_info as $entity_type => $info) {
if ($entity_info[$entity_type]->getProvider() == 'entity_test' && !isset($view_modes[$entity_type])) {
- $view_modes[$entity_type] = array(
- 'full' => array(
+ $view_modes[$entity_type] = [
+ 'full' => [
'label' => t('Full object'),
'status' => TRUE,
'cache' => TRUE,
- ),
- 'teaser' => array(
+ ],
+ 'teaser' => [
'label' => t('Teaser'),
'status' => TRUE,
'cache' => TRUE,
- ),
- );
+ ],
+ ];
}
}
}
@@ -253,12 +253,12 @@ function entity_test_entity_form_mode_info_alter(&$form_modes) {
$entity_info = \Drupal::entityManager()->getDefinitions();
foreach ($entity_info as $entity_type => $info) {
if ($entity_info[$entity_type]->getProvider() == 'entity_test') {
- $form_modes[$entity_type] = array(
- 'compact' => array(
+ $form_modes[$entity_type] = [
+ 'compact' => [
'label' => t('Compact version'),
'status' => TRUE,
- ),
- );
+ ],
+ ];
}
}
}
@@ -267,24 +267,24 @@ function entity_test_entity_form_mode_info_alter(&$form_modes) {
* Implements hook_entity_extra_field_info().
*/
function entity_test_entity_extra_field_info() {
- $extra['entity_test']['bundle_with_extra_fields'] = array(
- 'display' => array(
+ $extra['entity_test']['bundle_with_extra_fields'] = [
+ 'display' => [
// Note: those extra fields do not currently display anything, they are
// just used in \Drupal\Tests\field_ui\Kernel\EntityDisplayTest to test
// the behavior of entity display objects.
- 'display_extra_field' => array(
+ 'display_extra_field' => [
'label' => t('Display extra field'),
'description' => t('An extra field on the display side.'),
'weight' => 5,
'visible' => TRUE,
- ),
- 'display_extra_field_hidden' => array(
+ ],
+ 'display_extra_field_hidden' => [
'label' => t('Display extra field (hidden)'),
'description' => t('An extra field on the display side, hidden by default.'),
'visible' => FALSE,
- ),
- )
- );
+ ],
+ ]
+ ];
return $extra;
}
@@ -676,16 +676,16 @@ function entity_test_field_default_value(FieldableEntityInterface $entity, Field
// that they are correctly passed.
$string = $definition->getName() . '_' . $entity->language()->getId();
// Return a "default value" with multiple items.
- return array(
- array(
+ return [
+ [
'shape' => "shape:0:$string",
'color' => "color:0:$string",
- ),
- array(
+ ],
+ [
'shape' => "shape:1:$string",
'color' => "color:1:$string",
- ),
- );
+ ],
+ ];
}
/**
@@ -715,7 +715,7 @@ function entity_test_entity_prepare_view($entity_type, array $entities, array $d
// Add a dummy field item attribute on field_test_text if it exists.
if ($entity->hasField('field_test_text') && $displays[$entity->bundle()]->getComponent('field_test_text')) {
foreach ($entity->get('field_test_text') as $item) {
- $item->_attributes += array('data-field-item-attr' => 'foobar');
+ $item->_attributes += ['data-field-item-attr' => 'foobar'];
}
}
@@ -724,7 +724,7 @@ function entity_test_entity_prepare_view($entity_type, array $entities, array $d
foreach ($fields as $field) {
if ($field->getType() === 'daterange') {
$item = $entity->get($field->getName());
- $item->_attributes += array('data-field-item-attr' => 'foobar');
+ $item->_attributes += ['data-field-item-attr' => 'foobar'];
}
}
}
diff --git a/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php b/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php
index d0cd895bf99..a69348849f4 100644
--- a/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php
+++ b/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php
@@ -38,7 +38,7 @@ class EntityTestController extends ControllerBase {
->getStorage($referenced_entity_type)
->load($referenced_entity_id);
if ($referenced_entity === NULL) {
- return array();
+ return [];
}
$query = $this->entityTypeManager()->getStorage('entity_test')->getQuery()
diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php
index a603f537943..f3ada1f6dfb 100644
--- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php
@@ -72,15 +72,15 @@ class EntityTest extends ContentEntityBase implements EntityOwnerInterface {
->setDescription(t('The name of the test entity.'))
->setTranslatable(TRUE)
->setSetting('max_length', 32)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ));
+ ]);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Authored on'))
@@ -94,17 +94,17 @@ class EntityTest extends ContentEntityBase implements EntityOwnerInterface {
->setSetting('handler', 'default')
// Default EntityTest entities to have the root user as the owner, to
// simplify testing.
- ->setDefaultValue(array(0 => array('target_id' => 1)))
+ ->setDefaultValue([0 => ['target_id' => 1]])
->setTranslatable(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => -1,
- 'settings' => array(
+ 'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'placeholder' => '',
- ),
- ));
+ ],
+ ]);
return $fields;
}
diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php
index f7fe8e643c6..7fe9ce2112c 100644
--- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php
@@ -53,39 +53,39 @@ class EntityTestBaseFieldDisplay extends EntityTest {
$fields['test_display_configurable'] = BaseFieldDefinition::create('text')
->setLabel(t('Field with configurable display'))
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 10,
- ))
+ ])
->setDisplayConfigurable('view', TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 10,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['test_display_non_configurable'] = BaseFieldDefinition::create('text')
->setLabel(t('Field with non-configurable display'))
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 11,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 11,
- ));
+ ]);
$fields['test_display_multiple'] = BaseFieldDefinition::create('text')
->setLabel(t('A field with multiple values'))
->setCardinality(FieldStorageDefinition::CARDINALITY_UNLIMITED)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 12,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 12,
- ));
+ ]);
return $fields;
}
diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php
index a8158b00a67..bd28b346b86 100644
--- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php
@@ -36,15 +36,15 @@ class EntityTestCompositeConstraint extends EntityTest {
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
- $fields['name']->setDisplayOptions('form', array(
+ $fields['name']->setDisplayOptions('form', [
'type' => 'string',
'weight' => 0,
- ));
+ ]);
- $fields['type']->setDisplayOptions('form', array(
+ $fields['type']->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 0,
- ));
+ ]);
return $fields;
}
diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
index 448718dc8ec..e12c74a0d15 100644
--- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
@@ -33,11 +33,11 @@ class EntityTestConstraintViolation extends EntityTest {
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
- $fields['name']->setDisplayOptions('form', array(
+ $fields['name']->setDisplayOptions('form', [
'type' => 'string',
'weight' => 0,
- ));
- $fields['name']->addConstraint('FieldWidgetConstraint', array());
+ ]);
+ $fields['name']->addConstraint('FieldWidgetConstraint', []);
return $fields;
}
diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUpdate.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUpdate.php
index 6cf0d5ca848..6d72f7aeac9 100644
--- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUpdate.php
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUpdate.php
@@ -35,7 +35,7 @@ class EntityTestUpdate extends EntityTestRev {
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
- $fields += \Drupal::state()->get('entity_test_update.additional_base_field_definitions', array());
+ $fields += \Drupal::state()->get('entity_test_update.additional_base_field_definitions', []);
return $fields;
}
@@ -44,7 +44,7 @@ class EntityTestUpdate extends EntityTestRev {
*/
public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
$fields = parent::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions);
- $fields += \Drupal::state()->get('entity_test_update.additional_bundle_field_definitions.' . $bundle, array());
+ $fields += \Drupal::state()->get('entity_test_update.additional_bundle_field_definitions.' . $bundle, []);
return $fields;
}
diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestAccessControlHandler.php b/core/modules/system/tests/modules/entity_test/src/EntityTestAccessControlHandler.php
index 22816667e4e..1bd49ddaa3c 100644
--- a/core/modules/system/tests/modules/entity_test/src/EntityTestAccessControlHandler.php
+++ b/core/modules/system/tests/modules/entity_test/src/EntityTestAccessControlHandler.php
@@ -45,13 +45,13 @@ class EntityTestAccessControlHandler extends EntityAccessControlHandler {
// Viewing the label of the 'entity_test_label' entity type is allowed.
return AccessResult::allowed();
}
- elseif (in_array($operation, array('view', 'view label'))) {
+ elseif (in_array($operation, ['view', 'view label'])) {
if (!$entity->isDefaultTranslation()) {
return AccessResult::allowedIfHasPermission($account, 'view test entity translations');
}
return AccessResult::allowedIfHasPermission($account, 'view test entity');
}
- elseif (in_array($operation, array('update', 'delete'))) {
+ elseif (in_array($operation, ['update', 'delete'])) {
return AccessResult::allowedIfHasPermission($account, 'administer entity_test content');
}
diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php
index 7e4caff4d06..e4c51143c85 100644
--- a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php
+++ b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php
@@ -32,11 +32,11 @@ class EntityTestForm extends ContentEntityForm {
// @todo: Is there a better way to check if an entity type is revisionable?
if ($entity->getEntityType()->hasKey('revision') && !$entity->isNew()) {
- $form['revision'] = array(
+ $form['revision'] = [
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $entity->isNewRevision(),
- );
+ ];
}
return $form;
@@ -58,10 +58,10 @@ class EntityTestForm extends ContentEntityForm {
$entity->save();
if ($is_new) {
- $message = t('%entity_type @id has been created.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()));
+ $message = t('%entity_type @id has been created.', ['@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()]);
}
else {
- $message = t('%entity_type @id has been updated.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()));
+ $message = t('%entity_type @id has been updated.', ['@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()]);
}
drupal_set_message($message);
@@ -69,7 +69,7 @@ class EntityTestForm extends ContentEntityForm {
$entity_type = $entity->getEntityTypeId();
$form_state->setRedirect(
"entity.$entity_type.edit_form",
- array($entity_type => $entity->id())
+ [$entity_type => $entity->id()]
);
}
else {
diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestStorageSchema.php b/core/modules/system/tests/modules/entity_test/src/EntityTestStorageSchema.php
index 67a13bdd045..bdd36dbb29b 100644
--- a/core/modules/system/tests/modules/entity_test/src/EntityTestStorageSchema.php
+++ b/core/modules/system/tests/modules/entity_test/src/EntityTestStorageSchema.php
@@ -18,7 +18,7 @@ class EntityTestStorageSchema extends SqlContentEntityStorageSchema {
$schema = parent::getEntitySchema($entity_type, $reset);
if ($entity_type->id() == 'entity_test_update') {
- $schema[$entity_type->getBaseTable()]['indexes'] += \Drupal::state()->get('entity_test_update.additional_entity_indexes', array());
+ $schema[$entity_type->getBaseTable()]['indexes'] += \Drupal::state()->get('entity_test_update.additional_entity_indexes', []);
}
return $schema;
}
diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php b/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php
index 720e3c3b8d6..e90a22700e3 100644
--- a/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php
+++ b/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php
@@ -18,18 +18,18 @@ class EntityTestViewBuilder extends EntityViewBuilder {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
- $build[$id]['label'] = array(
+ $build[$id]['label'] = [
'#weight' => -100,
'#plain_text' => $entity->label(),
- );
- $build[$id]['separator'] = array(
+ ];
+ $build[$id]['separator'] = [
'#weight' => -150,
'#markup' => ' | ',
- );
- $build[$id]['view_mode'] = array(
+ ];
+ $build[$id]['view_mode'] = [
'#weight' => -200,
'#plain_text' => $view_mode,
- );
+ ];
}
}
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php
index 059c3a9f4f1..ed3f1dc4315 100644
--- a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/EntityTestLocalTasks.php
@@ -13,16 +13,16 @@ class EntityTestLocalTasks extends DeriverBase {
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $this->derivatives = array();
+ $this->derivatives = [];
$types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);
foreach ($types as $entity_type) {
- $this->derivatives[$entity_type . '.canonical'] = array();
+ $this->derivatives[$entity_type . '.canonical'] = [];
$this->derivatives[$entity_type . '.canonical']['base_route'] = "entity.$entity_type.canonical";
$this->derivatives[$entity_type . '.canonical']['route_name'] = "entity.$entity_type.canonical";
$this->derivatives[$entity_type . '.canonical']['title'] = 'View';
- $this->derivatives[$entity_type . '.edit'] = array();
+ $this->derivatives[$entity_type . '.edit'] = [];
$this->derivatives[$entity_type . '.edit']['base_route'] = "entity.$entity_type.canonical";
$this->derivatives[$entity_type . '.edit']['route_name'] = "entity.$entity_type.edit_form";
$this->derivatives[$entity_type . '.edit']['title'] = 'Edit';
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
index 2310ffdd37a..df2b89b592d 100644
--- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
@@ -46,14 +46,14 @@ class FieldTestItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => 255,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php
index 0d2ebb9d6aa..4921dcf481e 100644
--- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php
@@ -21,9 +21,9 @@ class ShapeItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'foreign_key_name' => 'shape',
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
@@ -43,30 +43,30 @@ class ShapeItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- $foreign_keys = array();
+ $foreign_keys = [];
// The 'foreign keys' key is not always used in tests.
if ($field_definition->getSetting('foreign_key_name')) {
- $foreign_keys['foreign keys'] = array(
+ $foreign_keys['foreign keys'] = [
// This is a dummy foreign key definition, references a table that
// doesn't exist, but that's not a problem.
- $field_definition->getSetting('foreign_key_name') => array(
+ $field_definition->getSetting('foreign_key_name') => [
'table' => $field_definition->getSetting('foreign_key_name'),
- 'columns' => array($field_definition->getSetting('foreign_key_name') => 'id'),
- ),
- );
+ 'columns' => [$field_definition->getSetting('foreign_key_name') => 'id'],
+ ],
+ ];
}
- return array(
- 'columns' => array(
- 'shape' => array(
+ return [
+ 'columns' => [
+ 'shape' => [
'type' => 'varchar',
'length' => 32,
- ),
- 'color' => array(
+ ],
+ 'color' => [
'type' => 'varchar',
'length' => 32,
- ),
- ),
- ) + $foreign_keys;
+ ],
+ ],
+ ] + $foreign_keys;
}
/**
diff --git a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php
index d75d3595969..5732060d9a9 100644
--- a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php
+++ b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php
@@ -18,13 +18,13 @@ class EntityTestRoutes {
public function routes() {
$types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);
- $routes = array();
+ $routes = [];
foreach ($types as $entity_type_id) {
$routes["entity.$entity_type_id.admin_form"] = new Route(
"$entity_type_id/structure/{bundle}",
- array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testAdmin'),
- array('_permission' => 'administer entity_test content'),
- array('_admin_route' => TRUE)
+ ['_controller' => '\Drupal\entity_test\Controller\EntityTestController::testAdmin'],
+ ['_permission' => 'administer entity_test content'],
+ ['_admin_route' => TRUE]
);
}
return $routes;
diff --git a/core/modules/system/tests/modules/entity_test_extra/entity_test_extra.module b/core/modules/system/tests/modules/entity_test_extra/entity_test_extra.module
index d55aab3ca42..f399ae4b978 100644
--- a/core/modules/system/tests/modules/entity_test_extra/entity_test_extra.module
+++ b/core/modules/system/tests/modules/entity_test_extra/entity_test_extra.module
@@ -11,19 +11,19 @@ use Drupal\Core\Entity\EntityTypeInterface;
* Implements hook_entity_base_field_info().
*/
function entity_test_extra_entity_base_field_info(EntityTypeInterface $entity_type) {
- return \Drupal::state()->get($entity_type->id() . '.additional_base_field_definitions', array());
+ return \Drupal::state()->get($entity_type->id() . '.additional_base_field_definitions', []);
}
/**
* Implements hook_entity_field_storage_info().
*/
function entity_test_extra_entity_field_storage_info(EntityTypeInterface $entity_type) {
- return \Drupal::state()->get($entity_type->id() . '.additional_field_storage_definitions', array());
+ return \Drupal::state()->get($entity_type->id() . '.additional_field_storage_definitions', []);
}
/**
* Implements hook_entity_bundle_field_info().
*/
function entity_test_extra_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
- return \Drupal::state()->get($entity_type->id() . '.' . $bundle . '.additional_bundle_field_definitions', array());
+ return \Drupal::state()->get($entity_type->id() . '.' . $bundle . '.additional_bundle_field_definitions', []);
}
diff --git a/core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php b/core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php
index 8d9b4d1c56b..b03415ff58a 100644
--- a/core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php
+++ b/core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php
@@ -43,15 +43,15 @@ class EntityTestWithRevisionLog extends RevisionableContentEntityBase {
->setTranslatable(TRUE)
->setRevisionable(TRUE)
->setSetting('max_length', 32)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ));
+ ]);
return $fields;
}
diff --git a/core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php b/core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php
index 579d71f8c20..3f18bb9437a 100644
--- a/core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php
+++ b/core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php
@@ -16,7 +16,7 @@ class TestLog implements LoggerInterface {
/**
* {@inheritdoc}
*/
- public function log($level, $message, array $context = array()) {
+ public function log($level, $message, array $context = []) {
$trigger = [
'%type' => 'Exception',
'@message' => 'Deforestation',
diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module
index 7114a29ca69..e3a5e3f2812 100644
--- a/core/modules/system/tests/modules/form_test/form_test.module
+++ b/core/modules/system/tests/modules/form_test/form_test.module
@@ -41,49 +41,49 @@ function system_form_form_test_alter_form_alter(&$form, FormStateInterface $form
* Create a header and options array. Helper function for callbacks.
*/
function _form_test_tableselect_get_data() {
- $header = array(
+ $header = [
'one' => t('One'),
'two' => t('Two'),
'three' => t('Three'),
'four' => t('Four'),
- );
+ ];
- $options['row1'] = array(
- 'title' => array('data' => array('#title' => t('row1'))),
+ $options['row1'] = [
+ 'title' => ['data' => ['#title' => t('row1')]],
'one' => 'row1col1',
'two' => t('row1col2'),
'three' => t('row1col3'),
'four' => t('row1col4'),
- );
+ ];
- $options['row2'] = array(
- 'title' => array('data' => array('#title' => t('row2'))),
+ $options['row2'] = [
+ 'title' => ['data' => ['#title' => t('row2')]],
'one' => 'row2col1',
'two' => t('row2col2'),
'three' => t('row2col3'),
'four' => t('row2col4'),
- );
+ ];
- $options['row3'] = array(
- 'title' => array('data' => array('#title' => t('row3'))),
+ $options['row3'] = [
+ 'title' => ['data' => ['#title' => t('row3')]],
'one' => 'row3col1',
'two' => t('row3col2'),
'three' => t('row3col3'),
'four' => t('row3col4'),
- );
+ ];
- return array($header, $options);
+ return [$header, $options];
}
/**
* Implements hook_form_FORM_ID_alter() for the registration form.
*/
function form_test_form_user_register_form_alter(&$form, FormStateInterface $form_state) {
- $form['test_rebuild'] = array(
+ $form['test_rebuild'] = [
'#type' => 'submit',
'#value' => t('Rebuild'),
- '#submit' => array('form_test_user_register_form_rebuild'),
- );
+ '#submit' => ['form_test_user_register_form_rebuild'],
+ ];
}
/**
diff --git a/core/modules/system/tests/modules/form_test/src/AutocompleteController.php b/core/modules/system/tests/modules/form_test/src/AutocompleteController.php
index acbfa409238..cc78a9c0c4f 100644
--- a/core/modules/system/tests/modules/form_test/src/AutocompleteController.php
+++ b/core/modules/system/tests/modules/form_test/src/AutocompleteController.php
@@ -16,7 +16,7 @@ class AutocompleteController {
* A JSON response.
*/
public function autocomplete1() {
- return new JsonResponse(array('key' => 'value'));
+ return new JsonResponse(['key' => 'value']);
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/Callbacks.php b/core/modules/system/tests/modules/form_test/src/Callbacks.php
index 3bf07f3060f..0310a37e52f 100644
--- a/core/modules/system/tests/modules/form_test/src/Callbacks.php
+++ b/core/modules/system/tests/modules/form_test/src/Callbacks.php
@@ -38,7 +38,7 @@ class Callbacks {
if ($triggered) {
// Output the element's value from $form_state.
- drupal_set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state->getValue('name'))));
+ drupal_set_message(t('@label value: @value', ['@label' => $element['#title'], '@value' => $form_state->getValue('name')]));
// Trigger a form validation error to see our changes.
$form_state->setErrorByName('');
diff --git a/core/modules/system/tests/modules/form_test/src/ConfirmFormArrayPathTestForm.php b/core/modules/system/tests/modules/form_test/src/ConfirmFormArrayPathTestForm.php
index 8885836f2fc..eaa0f2037ee 100644
--- a/core/modules/system/tests/modules/form_test/src/ConfirmFormArrayPathTestForm.php
+++ b/core/modules/system/tests/modules/form_test/src/ConfirmFormArrayPathTestForm.php
@@ -20,11 +20,11 @@ class ConfirmFormArrayPathTestForm extends ConfirmFormTestForm {
* {@inheritdoc}
*/
public function getCancelUrl() {
- return new Url('form_test.route6', array(), array(
- 'query' => array(
+ return new Url('form_test.route6', [], [
+ 'query' => [
'destination' => 'admin/config',
- ),
- ));
+ ],
+ ]);
}
/**
diff --git a/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php b/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php
index d35c59d1ff7..917f9e0ef6d 100644
--- a/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php
+++ b/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php
@@ -57,7 +57,7 @@ class ConfirmFormTestForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['element'] = array('#markup' => '<p>The ConfirmFormTestForm::buildForm() method was used for this form.</p>');
+ $form['element'] = ['#markup' => '<p>The ConfirmFormTestForm::buildForm() method was used for this form.</p>'];
return parent::buildForm($form, $form_state);
}
diff --git a/core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php b/core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php
index 5d28bf253bf..4c9fbe2c8c2 100644
--- a/core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php
+++ b/core/modules/system/tests/modules/form_test/src/Controller/FormTestController.php
@@ -20,12 +20,12 @@ class FormTestController extends ControllerBase {
*/
public function twoFormInstances() {
$user = $this->currentUser();
- $values = array(
+ $values = [
'uid' => $user->id(),
'name' => $user->getUsername(),
'type' => 'page',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- );
+ ];
$node1 = $this->entityManager()->getStorage('node')->create($values);
$node2 = clone($node1);
$return['node_form_1'] = $this->entityFormBuilder()->getForm($node1);
diff --git a/core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php b/core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php
index 15e4545f3d5..3fb97507a4e 100644
--- a/core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php
+++ b/core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php
@@ -39,8 +39,8 @@ class FormTestEventSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
- $events[KernelEvents::REQUEST][] = array('onKernelRequest');
- $events[KernelEvents::RESPONSE][] = array('onKernelResponse');
+ $events[KernelEvents::REQUEST][] = ['onKernelRequest'];
+ $events[KernelEvents::RESPONSE][] = ['onKernelResponse'];
return $events;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php
index 6870781db13..4e3de3bb476 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php
@@ -21,16 +21,16 @@ class FormTestButtonClassForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['button'] = array(
+ $form['button'] = [
'#type' => 'button',
'#value' => 'test',
'#button_type' => 'foo',
- );
- $form['delete'] = array(
+ ];
+ $form['delete'] = [
'#type' => 'button',
'#value' => 'Delete',
'#button_type' => 'danger',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php
index 66f7d059fec..62220cc61a1 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php
@@ -20,65 +20,65 @@ class FormTestCheckboxForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// A required checkbox.
- $form['required_checkbox'] = array(
+ $form['required_checkbox'] = [
'#type' => 'checkbox',
'#required' => TRUE,
'#title' => 'required_checkbox',
- );
+ ];
// A disabled checkbox should get its default value back.
- $form['disabled_checkbox_on'] = array(
+ $form['disabled_checkbox_on'] = [
'#type' => 'checkbox',
'#disabled' => TRUE,
'#return_value' => 'disabled_checkbox_on',
'#default_value' => 'disabled_checkbox_on',
'#title' => 'disabled_checkbox_on',
- );
- $form['disabled_checkbox_off'] = array(
+ ];
+ $form['disabled_checkbox_off'] = [
'#type' => 'checkbox',
'#disabled' => TRUE,
'#return_value' => 'disabled_checkbox_off',
'#default_value' => NULL,
'#title' => 'disabled_checkbox_off',
- );
+ ];
// A checkbox is active when #default_value == #return_value.
- $form['checkbox_on'] = array(
+ $form['checkbox_on'] = [
'#type' => 'checkbox',
'#return_value' => 'checkbox_on',
'#default_value' => 'checkbox_on',
'#title' => 'checkbox_on',
- );
+ ];
// But inactive in any other case.
- $form['checkbox_off'] = array(
+ $form['checkbox_off'] = [
'#type' => 'checkbox',
'#return_value' => 'checkbox_off',
'#default_value' => 'checkbox_on',
'#title' => 'checkbox_off',
- );
+ ];
// Checkboxes with a #return_value of '0' are supported.
- $form['zero_checkbox_on'] = array(
+ $form['zero_checkbox_on'] = [
'#type' => 'checkbox',
'#return_value' => '0',
'#default_value' => '0',
'#title' => 'zero_checkbox_on',
- );
+ ];
// In that case, passing a #default_value != '0'
// means that the checkbox is off.
- $form['zero_checkbox_off'] = array(
+ $form['zero_checkbox_off'] = [
'#type' => 'checkbox',
'#return_value' => '0',
'#default_value' => '1',
'#title' => 'zero_checkbox_off',
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php
index eb48bfcbbdd..ad0a86e8c81 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php
@@ -21,12 +21,12 @@ class FormTestCheckboxTypeJugglingForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $default_value = NULL, $return_value = NULL) {
- $form['checkbox'] = array(
+ $form['checkbox'] = [
'#title' => t('Checkbox'),
'#type' => 'checkbox',
'#return_value' => $return_value,
'#default_value' => $default_value,
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php
index 7c412fec670..a1a45a0abb7 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php
@@ -24,53 +24,53 @@ class FormTestCheckboxesRadiosForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state, $customize = FALSE) {
// Expand #type checkboxes, setting custom element properties for some but not
// all options.
- $form['checkboxes'] = array(
+ $form['checkboxes'] = [
'#type' => 'checkboxes',
'#title' => 'Checkboxes',
- '#options' => array(
+ '#options' => [
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => $this->t('<em>Bar - checkboxes</em>'),
'>' => "<em>Special Char</em><script>alert('checkboxes');</script>",
- ),
- );
+ ],
+ ];
if ($customize) {
- $form['checkboxes'] += array(
- 'foo' => array(
+ $form['checkboxes'] += [
+ 'foo' => [
'#description' => 'Enable to foo.',
- ),
- 1 => array(
+ ],
+ 1 => [
'#weight' => 10,
- ),
- );
+ ],
+ ];
}
// Expand #type radios, setting custom element properties for some but not
// all options.
- $form['radios'] = array(
+ $form['radios'] = [
'#type' => 'radios',
'#title' => 'Radios',
- '#options' => array(
+ '#options' => [
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => '<em>Bar - radios</em>',
'>' => "<em>Special Char</em><script>alert('radios');</script>",
- ),
- );
+ ],
+ ];
if ($customize) {
- $form['radios'] += array(
- 'foo' => array(
+ $form['radios'] += [
+ 'foo' => [
'#description' => 'Enable to foo.',
- ),
- 1 => array(
+ ],
+ 1 => [
'#weight' => 10,
- ),
- );
+ ],
+ ];
}
- $form['submit'] = array('#type' => 'submit', '#value' => 'Submit');
+ $form['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
index 2f2a38f3874..59f81e95bda 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
@@ -23,27 +23,27 @@ class FormTestCheckboxesZeroForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, $json = TRUE) {
$form_state->set('json', $json);
- $form['checkbox_off'] = array(
+ $form['checkbox_off'] = [
'#title' => t('Checkbox off'),
'#type' => 'checkboxes',
- '#options' => array('foo', 'bar', 'baz'),
- );
- $form['checkbox_zero_default'] = array(
+ '#options' => ['foo', 'bar', 'baz'],
+ ];
+ $form['checkbox_zero_default'] = [
'#title' => t('Zero default'),
'#type' => 'checkboxes',
- '#options' => array('foo', 'bar', 'baz'),
- '#default_value' => array(0),
- );
- $form['checkbox_string_zero_default'] = array(
+ '#options' => ['foo', 'bar', 'baz'],
+ '#default_value' => [0],
+ ];
+ $form['checkbox_string_zero_default'] = [
'#title' => t('Zero default (string)'),
'#type' => 'checkboxes',
- '#options' => array('foo', 'bar', 'baz'),
- '#default_value' => array('0'),
- );
- $form['submit'] = array(
+ '#options' => ['foo', 'bar', 'baz'],
+ '#default_value' => ['0'],
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
index c6684db16bf..adab5bda001 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
@@ -26,10 +26,10 @@ class FormTestClickedButtonForm extends FormBase {
// submitted without any information identifying the button responsible for
// the submission. In other browsers, the form is submitted as though the
// first button were clicked.
- $form['text'] = array(
+ $form['text'] = [
'#title' => 'Text',
'#type' => 'textfield',
- );
+ ];
// Loop through each path argument, adding buttons based on the information
// in the argument. For example, if the path is
@@ -37,7 +37,7 @@ class FormTestClickedButtonForm extends FormBase {
// 'image_button', and a 'button' with #access=FALSE. This enables form.test
// to test a variety of combinations.
$i = 0;
- $args = array($first, $second, $third);
+ $args = [$first, $second, $third];
foreach ($args as $arg) {
$name = 'button' . ++$i;
// 's', 'b', or 'i' in the argument define the button type wanted.
@@ -54,10 +54,10 @@ class FormTestClickedButtonForm extends FormBase {
$type = NULL;
}
if (isset($type)) {
- $form[$name] = array(
+ $form[$name] = [
'#type' => $type,
'#name' => $name,
- );
+ ];
// Image buttons need a #src; the others need a #value.
if ($type == 'image_button') {
$form[$name]['#src'] = 'core/misc/druplicon.png';
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php
index a9be1eaafcd..07638809e35 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php
@@ -22,14 +22,14 @@ class FormTestColorForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['color'] = array(
+ $form['color'] = [
'#type' => 'color',
'#title' => 'Color',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php
index f7527af29c8..81120ad1459 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php
@@ -23,26 +23,26 @@ class FormTestDescriptionForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['form_textfield_test_description_before'] = array(
+ $form['form_textfield_test_description_before'] = [
'#type' => 'textfield',
'#title' => 'Textfield test for description before element',
'#description' => 'Textfield test for description before element',
'#description_display' => 'before',
- );
+ ];
- $form['form_textfield_test_description_after'] = array(
+ $form['form_textfield_test_description_after'] = [
'#type' => 'textfield',
'#title' => 'Textfield test for description after element',
'#description' => 'Textfield test for description after element',
'#description_display' => 'after',
- );
+ ];
- $form['form_textfield_test_description_invisible'] = array(
+ $form['form_textfield_test_description_invisible'] = [
'#type' => 'textfield',
'#title' => 'Textfield test for visually-hidden description',
'#description' => 'Textfield test for visually-hidden description',
'#description_display' => 'invisible',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php
index 8ebbf83e902..56e6d2ee0fb 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php
@@ -24,101 +24,101 @@ class FormTestDisabledElementsForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// Elements that take a simple default value.
- foreach (array('textfield', 'textarea', 'search', 'tel', 'hidden') as $type) {
- $form[$type] = array(
+ foreach (['textfield', 'textarea', 'search', 'tel', 'hidden'] as $type) {
+ $form[$type] = [
'#type' => $type,
'#title' => $type,
'#default_value' => $type,
'#test_hijack_value' => 'HIJACK',
'#disabled' => TRUE,
- );
+ ];
}
// Multiple values option elements.
- foreach (array('checkboxes', 'select') as $type) {
- $form[$type . '_multiple'] = array(
+ foreach (['checkboxes', 'select'] as $type) {
+ $form[$type . '_multiple'] = [
'#type' => $type,
'#title' => $type . ' (multiple)',
- '#options' => array(
+ '#options' => [
'test_1' => 'Test 1',
'test_2' => 'Test 2',
- ),
+ ],
'#multiple' => TRUE,
- '#default_value' => array('test_2' => 'test_2'),
+ '#default_value' => ['test_2' => 'test_2'],
// The keys of #test_hijack_value need to match the #name of the control.
// @see FormsTestCase::testDisabledElements()
- '#test_hijack_value' => $type == 'select' ? array('' => 'test_1') : array('test_1' => 'test_1'),
+ '#test_hijack_value' => $type == 'select' ? ['' => 'test_1'] : ['test_1' => 'test_1'],
'#disabled' => TRUE,
- );
+ ];
}
// Single values option elements.
- foreach (array('radios', 'select') as $type) {
- $form[$type . '_single'] = array(
+ foreach (['radios', 'select'] as $type) {
+ $form[$type . '_single'] = [
'#type' => $type,
'#title' => $type . ' (single)',
- '#options' => array(
+ '#options' => [
'test_1' => 'Test 1',
'test_2' => 'Test 2',
- ),
+ ],
'#multiple' => FALSE,
'#default_value' => 'test_2',
'#test_hijack_value' => 'test_1',
'#disabled' => TRUE,
- );
+ ];
}
// Checkbox and radio.
- foreach (array('checkbox', 'radio') as $type) {
- $form[$type . '_unchecked'] = array(
+ foreach (['checkbox', 'radio'] as $type) {
+ $form[$type . '_unchecked'] = [
'#type' => $type,
'#title' => $type . ' (unchecked)',
'#return_value' => 1,
'#default_value' => 0,
'#test_hijack_value' => 1,
'#disabled' => TRUE,
- );
- $form[$type . '_checked'] = array(
+ ];
+ $form[$type . '_checked'] = [
'#type' => $type,
'#title' => $type . ' (checked)',
'#return_value' => 1,
'#default_value' => 1,
'#test_hijack_value' => NULL,
'#disabled' => TRUE,
- );
+ ];
}
// Weight, number, range.
- foreach (array('weight', 'number', 'range') as $type) {
- $form[$type] = array(
+ foreach (['weight', 'number', 'range'] as $type) {
+ $form[$type] = [
'#type' => $type,
'#title' => $type,
'#default_value' => 10,
'#test_hijack_value' => 5,
'#disabled' => TRUE,
- );
+ ];
}
// Color.
- $form['color'] = array(
+ $form['color'] = [
'#type' => 'color',
'#title' => 'color',
'#default_value' => '#0000ff',
'#test_hijack_value' => '#ff0000',
'#disabled' => TRUE,
- );
+ ];
// The #disabled state should propagate to children.
- $form['disabled_container'] = array(
+ $form['disabled_container'] = [
'#disabled' => TRUE,
- );
- foreach (array('textfield', 'textarea', 'hidden', 'tel', 'url') as $type) {
- $form['disabled_container']['disabled_container_' . $type] = array(
+ ];
+ foreach (['textfield', 'textarea', 'hidden', 'tel', 'url'] as $type) {
+ $form['disabled_container']['disabled_container_' . $type] = [
'#type' => $type,
'#title' => $type,
'#default_value' => $type,
'#test_hijack_value' => 'HIJACK',
- );
+ ];
}
// Date.
@@ -128,103 +128,103 @@ class FormTestDisabledElementsForm extends FormBase {
// versions by encoding and decoding it again instead of hardcoding it.
// See https://github.com/php/php-src/commit/fdb2709dd27c5987c2d2c8aaf0cdbebf9f17f643
$expected = json_decode(json_encode($date), TRUE);
- $form['disabled_container']['disabled_container_datetime'] = array(
+ $form['disabled_container']['disabled_container_datetime'] = [
'#type' => 'datetime',
'#title' => 'datetime',
'#default_value' => $date,
'#expected_value' => $expected,
'#test_hijack_value' => new DrupalDateTime('1978-12-02 11:30:00', 'Europe/Berlin'),
'#date_timezone' => 'Europe/Berlin',
- );
+ ];
- $form['disabled_container']['disabled_container_date'] = array(
+ $form['disabled_container']['disabled_container_date'] = [
'#type' => 'date',
'#title' => 'date',
'#default_value' => '2001-01-13',
'#expected_value' => '2001-01-13',
'#test_hijack_value' => '2013-01-01',
'#date_timezone' => 'Europe/Berlin',
- );
+ ];
// Try to hijack the email field with a valid email.
- $form['disabled_container']['disabled_container_email'] = array(
+ $form['disabled_container']['disabled_container_email'] = [
'#type' => 'email',
'#title' => 'email',
'#default_value' => 'foo@example.com',
'#test_hijack_value' => 'bar@example.com',
- );
+ ];
// Try to hijack the URL field with a valid URL.
- $form['disabled_container']['disabled_container_url'] = array(
+ $form['disabled_container']['disabled_container_url'] = [
'#type' => 'url',
'#title' => 'url',
'#default_value' => 'http://example.com',
'#test_hijack_value' => 'http://example.com/foo',
- );
+ ];
// Text format.
- $form['text_format'] = array(
+ $form['text_format'] = [
'#type' => 'text_format',
'#title' => 'Text format',
'#disabled' => TRUE,
'#default_value' => 'Text value',
'#format' => 'plain_text',
- '#expected_value' => array(
+ '#expected_value' => [
'value' => 'Text value',
'format' => 'plain_text',
- ),
- '#test_hijack_value' => array(
+ ],
+ '#test_hijack_value' => [
'value' => 'HIJACK',
'format' => 'filtered_html',
- ),
- );
+ ],
+ ];
// Password fields.
- $form['password'] = array(
+ $form['password'] = [
'#type' => 'password',
'#title' => 'Password',
'#disabled' => TRUE,
- );
- $form['password_confirm'] = array(
+ ];
+ $form['password_confirm'] = [
'#type' => 'password_confirm',
'#title' => 'Password confirm',
'#disabled' => TRUE,
- );
+ ];
// Files.
- $form['file'] = array(
+ $form['file'] = [
'#type' => 'file',
'#title' => 'File',
'#disabled' => TRUE,
- );
- $form['managed_file'] = array(
+ ];
+ $form['managed_file'] = [
'#type' => 'managed_file',
'#title' => 'Managed file',
'#disabled' => TRUE,
- );
+ ];
// Buttons.
- $form['image_button'] = array(
+ $form['image_button'] = [
'#type' => 'image_button',
'#value' => 'Image button',
'#disabled' => TRUE,
- );
- $form['button'] = array(
+ ];
+ $form['button'] = [
'#type' => 'button',
'#value' => 'Button',
'#disabled' => TRUE,
- );
- $form['submit_disabled'] = array(
+ ];
+ $form['submit_disabled'] = [
'#type' => 'submit',
'#value' => 'Submit',
'#disabled' => TRUE,
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php
index d669515a5d3..8e82623dbce 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php
@@ -22,21 +22,21 @@ class FormTestEmailForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['email'] = array(
+ $form['email'] = [
'#type' => 'email',
'#title' => 'Email address',
'#description' => 'An email address.',
- );
- $form['email_required'] = array(
+ ];
+ $form['email_required'] = [
'#type' => 'email',
'#title' => 'Address',
'#required' => TRUE,
'#description' => 'A required email address field.',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php
index b6f94545905..14dcb0c3374 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php
@@ -21,12 +21,12 @@ class FormTestEmptySelectForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['empty_select'] = array(
+ $form['empty_select'] = [
'#type' => 'select',
'#title' => t('Empty Select'),
'#multiple' => FALSE,
'#options' => NULL,
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
index d3cbd5206e3..f910469bda4 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
@@ -22,16 +22,16 @@ class FormTestFormStateValuesCleanAdvancedForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// Build an example form containing a managed file and a submit form element.
- $form['image'] = array(
+ $form['image'] = [
'#type' => 'managed_file',
'#title' => t('Image'),
'#upload_location' => 'public://',
'#default_value' => 0,
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php
index bef5675243e..d5e0fd96587 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php
@@ -24,13 +24,13 @@ class FormTestFormStateValuesCleanForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
// Build an example form containing multiple submit and button elements; not
// only on the top-level.
- $form = array('#tree' => TRUE);
- $form['foo'] = array('#type' => 'submit', '#value' => t('Submit'));
- $form['bar'] = array('#type' => 'submit', '#value' => t('Submit'));
- $form['beer'] = array('#type' => 'value', '#value' => 1000);
- $form['baz']['foo'] = array('#type' => 'button', '#value' => t('Submit'));
- $form['baz']['baz'] = array('#type' => 'submit', '#value' => t('Submit'));
- $form['baz']['beer'] = array('#type' => 'value', '#value' => 2000);
+ $form = ['#tree' => TRUE];
+ $form['foo'] = ['#type' => 'submit', '#value' => t('Submit')];
+ $form['bar'] = ['#type' => 'submit', '#value' => t('Submit')];
+ $form['beer'] = ['#type' => 'value', '#value' => 1000];
+ $form['baz']['foo'] = ['#type' => 'button', '#value' => t('Submit')];
+ $form['baz']['baz'] = ['#type' => 'submit', '#value' => t('Submit')];
+ $form['baz']['beer'] = ['#type' => 'value', '#value' => 2000];
// Add an arbitrary element and manually set it to be cleaned.
// Using $form_state->addCleanValueKey('wine'); didn't work here.
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php
index a9298efddea..b141b7cc279 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php
@@ -21,19 +21,19 @@ class FormTestGroupContainerForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['container'] = array(
+ $form['container'] = [
'#type' => 'container',
- );
- $form['meta'] = array(
+ ];
+ $form['meta'] = [
'#type' => 'details',
'#title' => 'Group element',
'#open' => TRUE,
'#group' => 'container',
- );
- $form['meta']['element'] = array(
+ ];
+ $form['meta']['element'] = [
'#type' => 'textfield',
'#title' => 'Nest in details element',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php
index faa83cce9ca..002b07dd7f7 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php
@@ -21,22 +21,22 @@ class FormTestGroupDetailsForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $required = FALSE) {
- $form['details'] = array(
+ $form['details'] = [
'#type' => 'details',
'#title' => 'Root element',
'#open' => TRUE,
'#required' => !empty($required),
- );
- $form['meta'] = array(
+ ];
+ $form['meta'] = [
'#type' => 'details',
'#title' => 'Group element',
'#open' => TRUE,
'#group' => 'details',
- );
- $form['meta']['element'] = array(
+ ];
+ $form['meta']['element'] = [
'#type' => 'textfield',
'#title' => 'Nest in details element',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
index fd7d83b8c17..37ef246ec8f 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
@@ -21,20 +21,20 @@ class FormTestGroupFieldsetForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $required = FALSE) {
- $form['fieldset'] = array(
+ $form['fieldset'] = [
'#type' => 'fieldset',
'#title' => 'Fieldset',
'#required' => !empty($required),
- );
- $form['meta'] = array(
+ ];
+ $form['meta'] = [
'#type' => 'container',
'#title' => 'Group element',
'#group' => 'fieldset',
- );
- $form['meta']['element'] = array(
+ ];
+ $form['meta']['element'] = [
'#type' => 'textfield',
'#title' => 'Nest in container element',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php
index 842ae9d0c7a..2d2f98bdf46 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php
@@ -21,27 +21,27 @@ class FormTestGroupVerticalTabsForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['vertical_tabs'] = array(
+ $form['vertical_tabs'] = [
'#type' => 'vertical_tabs',
- );
- $form['meta'] = array(
+ ];
+ $form['meta'] = [
'#type' => 'details',
'#title' => 'First group element',
'#group' => 'vertical_tabs',
- );
- $form['meta']['element'] = array(
+ ];
+ $form['meta']['element'] = [
'#type' => 'textfield',
'#title' => 'First nested element in details element',
- );
- $form['meta_2'] = array(
+ ];
+ $form['meta_2'] = [
'#type' => 'details',
'#title' => 'Second group element',
'#group' => 'vertical_tabs',
- );
- $form['meta_2']['element_2'] = array(
+ ];
+ $form['meta_2']['element_2'] = [
'#type' => 'textfield',
'#title' => 'Second nested element in details element',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php
index 2eeaf7f414d..c8a82c88b48 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php
@@ -21,18 +21,18 @@ class FormTestInputForgeryForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
// For testing that a user can't submit a value not matching one of the
// allowed options.
- $form['checkboxes'] = array(
+ $form['checkboxes'] = [
'#title' => t('Checkboxes'),
'#type' => 'checkboxes',
- '#options' => array(
+ '#options' => [
'one' => 'One',
'two' => 'Two',
- ),
- );
- $form['submit'] = array(
+ ],
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php
index 1adaa18c1fe..74c92ab6111 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php
@@ -21,108 +21,108 @@ class FormTestLabelForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['form_checkboxes_test'] = array(
+ $form['form_checkboxes_test'] = [
'#type' => 'checkboxes',
'#title' => t('Checkboxes test'),
- '#options' => array(
+ '#options' => [
'first-checkbox' => t('First checkbox'),
'second-checkbox' => t('Second checkbox'),
'third-checkbox' => t('Third checkbox'),
'0' => t('0'),
- ),
- );
- $form['form_radios_test'] = array(
+ ],
+ ];
+ $form['form_radios_test'] = [
'#type' => 'radios',
'#title' => t('Radios test'),
- '#options' => array(
+ '#options' => [
'first-radio' => t('First radio'),
'second-radio' => t('Second radio'),
'third-radio' => t('Third radio'),
'0' => t('0'),
- ),
+ ],
// Test #field_prefix and #field_suffix placement.
'#field_prefix' => '<span id="form-test-radios-field-prefix">' . t('Radios #field_prefix element') . '</span>',
'#field_suffix' => '<span id="form-test-radios-field-suffix">' . t('Radios #field_suffix element') . '</span>',
- );
- $form['form_checkbox_test'] = array(
+ ];
+ $form['form_checkbox_test'] = [
'#type' => 'checkbox',
'#title' => t('Checkbox test'),
- );
- $form['form_textfield_test_title_and_required'] = array(
+ ];
+ $form['form_textfield_test_title_and_required'] = [
'#type' => 'textfield',
'#title' => t('Textfield test for required with title'),
'#required' => TRUE,
- );
- $form['form_textfield_test_no_title_required'] = array(
+ ];
+ $form['form_textfield_test_no_title_required'] = [
'#type' => 'textfield',
// We use an empty title, since not setting #title suppresses the label
// and required marker.
'#title' => '',
'#required' => TRUE,
- );
- $form['form_textfield_test_title'] = array(
+ ];
+ $form['form_textfield_test_title'] = [
'#type' => 'textfield',
'#title' => t('Textfield test for title only'),
// Not required.
// Test #prefix and #suffix placement.
'#prefix' => '<div id="form-test-textfield-title-prefix">' . t('Textfield #prefix element') . '</div>',
'#suffix' => '<div id="form-test-textfield-title-suffix">' . t('Textfield #suffix element') . '</div>',
- );
- $form['form_textfield_test_title_after'] = array(
+ ];
+ $form['form_textfield_test_title_after'] = [
'#type' => 'textfield',
'#title' => t('Textfield test for title after element'),
'#title_display' => 'after',
- );
- $form['form_textfield_test_title_invisible'] = array(
+ ];
+ $form['form_textfield_test_title_invisible'] = [
'#type' => 'textfield',
'#title' => t('Textfield test for invisible title'),
'#title_display' => 'invisible',
- );
+ ];
// Textfield test for title set not to display.
- $form['form_textfield_test_title_no_show'] = array(
+ $form['form_textfield_test_title_no_show'] = [
'#type' => 'textfield',
- );
+ ];
// Checkboxes & radios with title as attribute.
- $form['form_checkboxes_title_attribute'] = array(
+ $form['form_checkboxes_title_attribute'] = [
'#type' => 'checkboxes',
'#title' => 'Checkboxes test',
'#title_display' => 'attribute',
- '#options' => array(
+ '#options' => [
'first-checkbox' => 'First checkbox',
'second-checkbox' => 'Second checkbox',
- ),
+ ],
'#required' => TRUE,
- );
- $form['form_radios_title_attribute'] = array(
+ ];
+ $form['form_radios_title_attribute'] = [
'#type' => 'radios',
'#title' => 'Radios test',
'#title_display' => 'attribute',
- '#options' => array(
+ '#options' => [
'first-radio' => 'First radio',
'second-radio' => 'Second radio',
- ),
+ ],
'#required' => TRUE,
- );
- $form['form_checkboxes_title_invisible'] = array(
+ ];
+ $form['form_checkboxes_title_invisible'] = [
'#type' => 'checkboxes',
'#title' => 'Checkboxes test invisible',
'#title_display' => 'invisible',
- '#options' => array(
+ '#options' => [
'first-checkbox' => 'First checkbox',
'second-checkbox' => 'Second checkbox',
- ),
+ ],
'#required' => TRUE,
- );
- $form['form_radios_title_invisible'] = array(
+ ];
+ $form['form_radios_title_invisible'] = [
'#type' => 'radios',
'#title' => 'Radios test invisible',
'#title_display' => 'invisible',
- '#options' => array(
+ '#options' => [
'first-radio' => 'First radio',
'second-radio' => 'Second radio',
- ),
+ ],
'#required' => TRUE,
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php
index 04794504134..ba41e19fef8 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php
@@ -23,38 +23,38 @@ class FormTestLanguageSelectForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['languages_all'] = array(
+ $form['languages_all'] = [
'#title' => t('Languages: All'),
'#type' => 'language_select',
'#languages' => LanguageInterface::STATE_ALL,
'#default_value' => 'xx',
- );
- $form['languages_configurable'] = array(
+ ];
+ $form['languages_configurable'] = [
'#title' => t('Languages: Configurable'),
'#type' => 'language_select',
'#languages' => LanguageInterface::STATE_CONFIGURABLE,
'#default_value' => 'en',
- );
- $form['languages_locked'] = array(
+ ];
+ $form['languages_locked'] = [
'#title' => t('Languages: Locked'),
'#type' => 'language_select',
'#languages' => LanguageInterface::STATE_LOCKED,
- );
- $form['languages_config_and_locked'] = array(
+ ];
+ $form['languages_config_and_locked'] = [
'#title' => t('Languages: Configurable and locked'),
'#type' => 'language_select',
'#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED,
'#default_value' => 'dummy_value',
- );
- $form['language_custom_options'] = array(
+ ];
+ $form['language_custom_options'] = [
'#title' => t('Languages: Custom'),
'#type' => 'language_select',
'#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED,
- '#options' => array('opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'),
+ '#options' => ['opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'],
'#default_value' => 'opt2',
- );
+ ];
- $form['submit'] = array('#type' => 'submit', '#value' => 'Submit');
+ $form['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php
index 2cb22936aba..deff0b49d47 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php
@@ -21,62 +21,62 @@ class FormTestLimitValidationErrorsForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['title'] = array(
+ $form['title'] = [
'#type' => 'textfield',
'#title' => 'Title',
'#required' => TRUE,
- );
+ ];
- $form['test'] = array(
+ $form['test'] = [
'#title' => 'Test',
'#type' => 'textfield',
- '#element_validate' => array('::elementValidateLimitValidationErrors'),
- );
- $form['test_numeric_index'] = array(
+ '#element_validate' => ['::elementValidateLimitValidationErrors'],
+ ];
+ $form['test_numeric_index'] = [
'#tree' => TRUE,
- );
- $form['test_numeric_index'][0] = array(
+ ];
+ $form['test_numeric_index'][0] = [
'#title' => 'Test (numeric index)',
'#type' => 'textfield',
- '#element_validate' => array('::elementValidateLimitValidationErrors'),
- );
+ '#element_validate' => ['::elementValidateLimitValidationErrors'],
+ ];
- $form['test_substring'] = array(
+ $form['test_substring'] = [
'#tree' => TRUE,
- );
- $form['test_substring']['foo'] = array(
+ ];
+ $form['test_substring']['foo'] = [
'#title' => 'Test (substring) foo',
'#type' => 'textfield',
- '#element_validate' => array('::elementValidateLimitValidationErrors'),
- );
- $form['test_substring']['foobar'] = array(
+ '#element_validate' => ['::elementValidateLimitValidationErrors'],
+ ];
+ $form['test_substring']['foobar'] = [
'#title' => 'Test (substring) foobar',
'#type' => 'textfield',
- '#element_validate' => array('::elementValidateLimitValidationErrors'),
- );
+ '#element_validate' => ['::elementValidateLimitValidationErrors'],
+ ];
- $form['actions']['partial'] = array(
+ $form['actions']['partial'] = [
'#type' => 'submit',
- '#limit_validation_errors' => array(array('test')),
- '#submit' => array('::partialSubmitForm'),
+ '#limit_validation_errors' => [['test']],
+ '#submit' => ['::partialSubmitForm'],
'#value' => t('Partial validate'),
- );
- $form['actions']['partial_numeric_index'] = array(
+ ];
+ $form['actions']['partial_numeric_index'] = [
'#type' => 'submit',
- '#limit_validation_errors' => array(array('test_numeric_index', 0)),
- '#submit' => array('::partialSubmitForm'),
+ '#limit_validation_errors' => [['test_numeric_index', 0]],
+ '#submit' => ['::partialSubmitForm'],
'#value' => t('Partial validate (numeric index)'),
- );
- $form['actions']['substring'] = array(
+ ];
+ $form['actions']['substring'] = [
'#type' => 'submit',
- '#limit_validation_errors' => array(array('test_substring', 'foo')),
- '#submit' => array('::partialSubmitForm'),
+ '#limit_validation_errors' => [['test_substring', 'foo']],
+ '#submit' => ['::partialSubmitForm'],
'#value' => t('Partial validate (substring)'),
- );
- $form['actions']['full'] = array(
+ ];
+ $form['actions']['full'] = [
'#type' => 'submit',
'#value' => t('Full validate'),
- );
+ ];
return $form;
}
@@ -85,7 +85,7 @@ class FormTestLimitValidationErrorsForm extends FormBase {
*/
public function elementValidateLimitValidationErrors($element, FormStateInterface $form_state) {
if ($element['#value'] == 'invalid') {
- $form_state->setError($element, t('@label element is invalid', array('@label' => $element['#title'])));
+ $form_state->setError($element, t('@label element is invalid', ['@label' => $element['#title']]));
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php
index 6b9520bff0a..ab281462eb6 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php
@@ -21,114 +21,114 @@ class FormTestNumberForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $element = 'number') {
- $base = array(
+ $base = [
'#type' => $element,
- );
+ ];
- $form['integer_no_number'] = $base + array(
+ $form['integer_no_number'] = $base + [
'#title' => 'Integer test, #no_error',
'#default_value' => '#no_number',
- );
- $form['integer_no_step'] = $base + array(
+ ];
+ $form['integer_no_step'] = $base + [
'#title' => 'Integer test without step',
'#default_value' => 5,
- );
- $form['integer_no_step_step_error'] = $base + array(
+ ];
+ $form['integer_no_step_step_error'] = $base + [
'#title' => 'Integer test without step, #step_error',
'#default_value' => 4.5,
- );
- $form['integer_step'] = $base + array(
+ ];
+ $form['integer_step'] = $base + [
'#title' => 'Integer test with step',
'#default_value' => 5,
'#step' => 1,
- );
- $form['integer_step_error'] = $base + array(
+ ];
+ $form['integer_step_error'] = $base + [
'#title' => 'Integer test, with step, #step_error',
'#default_value' => 5,
'#step' => 2,
- );
- $form['integer_step_min'] = $base + array(
+ ];
+ $form['integer_step_min'] = $base + [
'#title' => 'Integer test with min value',
'#default_value' => 5,
'#min' => 0,
'#step' => 1,
- );
- $form['integer_step_min_error'] = $base + array(
+ ];
+ $form['integer_step_min_error'] = $base + [
'#title' => 'Integer test with min value, #min_error',
'#default_value' => 5,
'#min' => 6,
'#step' => 1,
- );
- $form['integer_step_max'] = $base + array(
+ ];
+ $form['integer_step_max'] = $base + [
'#title' => 'Integer test with max value',
'#default_value' => 5,
'#max' => 6,
'#step' => 1,
- );
- $form['integer_step_max_error'] = $base + array(
+ ];
+ $form['integer_step_max_error'] = $base + [
'#title' => 'Integer test with max value, #max_error',
'#default_value' => 5,
'#max' => 4,
'#step' => 1,
- );
- $form['integer_step_min_border'] = $base + array(
+ ];
+ $form['integer_step_min_border'] = $base + [
'#title' => 'Integer test with min border check',
'#default_value' => -1,
'#min' => -1,
'#step' => 1,
- );
- $form['integer_step_max_border'] = $base + array(
+ ];
+ $form['integer_step_max_border'] = $base + [
'#title' => 'Integer test with max border check',
'#default_value' => 5,
'#max' => 5,
'#step' => 1,
- );
- $form['integer_step_based_on_min'] = $base + array(
+ ];
+ $form['integer_step_based_on_min'] = $base + [
'#title' => 'Integer test with step based on min check',
'#default_value' => 3,
'#min' => -1,
'#step' => 2,
- );
- $form['integer_step_based_on_min_error'] = $base + array(
+ ];
+ $form['integer_step_based_on_min_error'] = $base + [
'#title' => 'Integer test with step based on min check, #step_error',
'#default_value' => 4,
'#min' => -1,
'#step' => 2,
- );
- $form['float_small_step'] = $base + array(
+ ];
+ $form['float_small_step'] = $base + [
'#title' => 'Float test with a small step',
'#default_value' => 4,
'#step' => 0.0000000000001,
- );
- $form['float_step_no_error'] = $base + array(
+ ];
+ $form['float_step_no_error'] = $base + [
'#title' => 'Float test',
'#default_value' => 1.2,
'#step' => 0.3,
- );
- $form['float_step_error'] = $base + array(
+ ];
+ $form['float_step_error'] = $base + [
'#title' => 'Float test, #step_error',
'#default_value' => 1.3,
'#step' => 0.3,
- );
- $form['float_step_hard_no_error'] = $base + array(
+ ];
+ $form['float_step_hard_no_error'] = $base + [
'#title' => 'Float test hard',
'#default_value' => 0.9411764729088,
'#step' => 0.00392156863712,
- );
- $form['float_step_hard_error'] = $base + array(
+ ];
+ $form['float_step_hard_error'] = $base + [
'#title' => 'Float test hard, #step_error',
'#default_value' => 0.9411764,
'#step' => 0.00392156863,
- );
- $form['float_step_any_no_error'] = $base + array(
+ ];
+ $form['float_step_any_no_error'] = $base + [
'#title' => 'Arbitrary float',
'#default_value' => 0.839562930284,
'#step' => 'aNy',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php
index 57801726643..9180628b139 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php
@@ -21,34 +21,34 @@ class FormTestPatternForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['textfield'] = array(
+ $form['textfield'] = [
'#type' => 'textfield',
'#title' => 'One digit followed by lowercase letters',
'#pattern' => '[0-9][a-z]+',
- );
- $form['tel'] = array(
+ ];
+ $form['tel'] = [
'#type' => 'tel',
'#title' => 'Everything except numbers',
'#pattern' => '[^\d]*',
- );
- $form['password'] = array(
+ ];
+ $form['password'] = [
'#type' => 'password',
'#title' => 'Password',
'#pattern' => '[01]+',
- );
- $form['url'] = array(
+ ];
+ $form['url'] = [
'#type' => 'url',
'#title' => 'Client side validation',
'#decription' => 'Just client side validation, using the #pattern attribute.',
- '#attributes' => array(
+ '#attributes' => [
'pattern' => '.*foo.*',
- ),
+ ],
'#pattern' => 'ignored',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php
index 21a50ff9f52..9dd53219f13 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php
@@ -21,12 +21,12 @@ class FormTestPlaceholderForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- foreach (array('textfield', 'textarea', 'url', 'password', 'search', 'tel', 'email', 'number') as $type) {
- $form[$type] = array(
+ foreach (['textfield', 'textarea', 'url', 'password', 'search', 'tel', 'email', 'number'] as $type) {
+ $form[$type] = [
'#type' => $type,
'#title' => $type,
'#placeholder' => 'placeholder-text',
- );
+ ];
}
return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
index 1e7a0146c76..66928f04f2a 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
@@ -21,61 +21,61 @@ class FormTestProgrammaticForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['textfield'] = array(
+ $form['textfield'] = [
'#title' => 'Textfield',
'#type' => 'textfield',
- );
+ ];
- $form['checkboxes'] = array(
+ $form['checkboxes'] = [
'#title' => t('Checkboxes'),
'#type' => 'checkboxes',
- '#options' => array(
+ '#options' => [
1 => 'First checkbox',
2 => 'Second checkbox',
- ),
+ ],
// Both checkboxes are selected by default so that we can test the ability
// of programmatic form submissions to uncheck them.
- '#default_value' => array(1, 2),
- );
+ '#default_value' => [1, 2],
+ ];
- $form['field_to_validate'] = array(
+ $form['field_to_validate'] = [
'#type' => 'radios',
'#title' => 'Field to validate (in the case of limited validation)',
'#description' => 'If the form is submitted by clicking the "Submit with limited validation" button, then validation can be limited based on the value of this radio button.',
- '#options' => array(
+ '#options' => [
'all' => 'Validate all fields',
'textfield' => 'Validate the "Textfield" field',
'field_to_validate' => 'Validate the "Field to validate" field',
- ),
+ ],
'#default_value' => 'all',
- );
+ ];
- $form['field_restricted'] = array(
+ $form['field_restricted'] = [
'#type' => 'textfield',
'#title' => 'Textfield (no access)',
'#access' => FALSE,
- );
+ ];
// The main submit button for the form.
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
// A secondary submit button that allows validation to be limited based on
// the value of the above radio selector.
- $form['submit_limit_validation'] = array(
+ $form['submit_limit_validation'] = [
'#type' => 'submit',
'#value' => 'Submit with limited validation',
// Use the same submit handler for this button as for the form itself.
// (This must be set explicitly or otherwise the form API will ignore the
// #limit_validation_errors property.)
- '#submit' => array('::submitForm'),
- );
+ '#submit' => ['::submitForm'],
+ ];
$user_input = $form_state->getUserInput();
if (!empty($user_input['field_to_validate']) && $user_input['field_to_validate'] != 'all') {
- $form['submit_limit_validation']['#limit_validation_errors'] = array(
- array($user_input['field_to_validate']),
- );
+ $form['submit_limit_validation']['#limit_validation_errors'] = [
+ [$user_input['field_to_validate']],
+ ];
}
return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php
index 25cdc3e46e1..94240e5e9a9 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php
@@ -22,7 +22,7 @@ class FormTestRangeForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['with_default_value'] = array(
+ $form['with_default_value'] = [
'#type' => 'range',
'#title' => 'Range with default value',
'#min' => 10,
@@ -30,34 +30,34 @@ class FormTestRangeForm extends FormBase {
'#step' => 2,
'#default_value' => 18,
'#description' => 'The default value is 18.',
- );
- $form['float'] = array(
+ ];
+ $form['float'] = [
'#type' => 'range',
'#title' => 'Float',
'#min' => 10,
'#max' => 11,
'#step' => 'any',
'#description' => 'Floating point number between 10 and 11.',
- );
- $form['integer'] = array(
+ ];
+ $form['integer'] = [
'#type' => 'range',
'#title' => 'Integer',
'#min' => 2,
'#max' => 8,
'#step' => 2,
'#description' => 'Even integer between 2 and 8.',
- );
- $form['offset'] = array(
+ ];
+ $form['offset'] = [
'#type' => 'range',
'#title' => 'Offset',
'#min' => 2.9,
'#max' => 10.9,
'#description' => 'Value between 2.9 and 10.9.',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php
index 49bb0b9bbec..541520585d6 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php
@@ -21,17 +21,17 @@ class FormTestRangeInvalidForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['minmax'] = array(
+ $form['minmax'] = [
'#type' => 'range',
'#min' => 10,
'#max' => 5,
'#title' => 'Invalid range',
'#description' => 'Minimum greater than maximum.',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php
index d0d520ec978..58934a78199 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php
@@ -23,58 +23,58 @@ class FormTestRebuildPreserveValuesForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
// Start the form with two checkboxes, to test different defaults, and a
// textfield, to test more than one element type.
- $form = array(
- 'checkbox_1_default_off' => array(
+ $form = [
+ 'checkbox_1_default_off' => [
'#type' => 'checkbox',
'#title' => t('This checkbox defaults to unchecked'),
'#default_value' => FALSE,
- ),
- 'checkbox_1_default_on' => array(
+ ],
+ 'checkbox_1_default_on' => [
'#type' => 'checkbox',
'#title' => t('This checkbox defaults to checked'),
'#default_value' => TRUE,
- ),
- 'text_1' => array(
+ ],
+ 'text_1' => [
'#type' => 'textfield',
'#title' => t('This textfield has a non-empty default value.'),
'#default_value' => 'DEFAULT 1',
- ),
- );
+ ],
+ ];
// Provide an 'add more' button that rebuilds the form with an additional two
// checkboxes and a textfield. The test is to make sure that the rebuild
// triggered by this button preserves the user input values for the initial
// elements and initializes the new elements with the correct default values.
if (!$form_state->has('add_more')) {
- $form['add_more'] = array(
+ $form['add_more'] = [
'#type' => 'submit',
'#value' => 'Add more',
- '#submit' => array('::addMoreSubmitForm'),
- );
+ '#submit' => ['::addMoreSubmitForm'],
+ ];
}
else {
- $form += array(
- 'checkbox_2_default_off' => array(
+ $form += [
+ 'checkbox_2_default_off' => [
'#type' => 'checkbox',
'#title' => t('This checkbox defaults to unchecked'),
'#default_value' => FALSE,
- ),
- 'checkbox_2_default_on' => array(
+ ],
+ 'checkbox_2_default_on' => [
'#type' => 'checkbox',
'#title' => t('This checkbox defaults to checked'),
'#default_value' => TRUE,
- ),
- 'text_2' => array(
+ ],
+ 'text_2' => [
'#type' => 'textfield',
'#title' => t('This textfield has a non-empty default value.'),
'#default_value' => 'DEFAULT 2',
- ),
- );
+ ],
+ ];
}
// A submit button that finishes the form workflow (does not rebuild).
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
@@ -92,7 +92,7 @@ class FormTestRebuildPreserveValuesForm extends FormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Finish the workflow. Do not rebuild.
- drupal_set_message(t('Form values: %values', array('%values' => var_export($form_state->getValues(), TRUE))));
+ drupal_set_message(t('Form values: %values', ['%values' => var_export($form_state->getValues(), TRUE)]));
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
index c540fb75536..4768acf901f 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
@@ -22,23 +22,23 @@ class FormTestRedirectForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['redirection'] = array(
+ $form['redirection'] = [
'#type' => 'checkbox',
'#title' => t('Use redirection'),
- );
- $form['destination'] = array(
+ ];
+ $form['destination'] = [
'#type' => 'textfield',
'#title' => t('Redirect destination'),
- '#states' => array(
- 'visible' => array(
- ':input[name="redirection"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['submit'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="redirection"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php
index f11c3caf20a..b0aa1b00b7e 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php
@@ -21,17 +21,17 @@ class FormTestRequiredAttributeForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- foreach (array('textfield', 'textarea', 'password') as $type) {
- $form[$type] = array(
+ foreach (['textfield', 'textarea', 'password'] as $type) {
+ $form[$type] = [
'#type' => $type,
'#required' => TRUE,
'#title' => $type,
- );
+ ];
}
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestResponseForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestResponseForm.php
index 47bc1b9981d..0ab3a0d211b 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestResponseForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestResponseForm.php
@@ -22,19 +22,19 @@ class FormTestResponseForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['content'] = array(
+ $form['content'] = [
'#type' => 'textfield',
'#title' => 'Content',
- );
- $form['status'] = array(
+ ];
+ $form['status'] = [
'#type' => 'textfield',
'#title' => 'Status',
'#default_value' => 200,
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php
index 76cdc1acbea..20242ec2ebd 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php
@@ -22,100 +22,100 @@ class FormTestSelectForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $base = array(
+ $base = [
'#type' => 'select',
- '#options' => array('one' => 'one', 'two' => 'two', 'three' => 'three', 'four' => '<strong>four</strong>'),
- );
+ '#options' => ['one' => 'one', 'two' => 'two', 'three' => 'three', 'four' => '<strong>four</strong>'],
+ ];
- $form['select'] = $base + array(
+ $form['select'] = $base + [
'#title' => '#default_value one',
'#default_value' => 'one',
- );
- $form['select_required'] = $base + array(
+ ];
+ $form['select_required'] = $base + [
'#title' => '#default_value one, #required',
'#required' => TRUE,
'#default_value' => 'one',
- );
- $form['select_optional'] = $base + array(
+ ];
+ $form['select_optional'] = $base + [
'#title' => '#default_value one, not #required',
'#required' => FALSE,
'#default_value' => 'one',
- );
- $form['empty_value'] = $base + array(
+ ];
+ $form['empty_value'] = $base + [
'#title' => '#default_value one, #required, #empty_value 0',
'#required' => TRUE,
'#default_value' => 'one',
'#empty_value' => 0,
- );
- $form['empty_value_one'] = $base + array(
+ ];
+ $form['empty_value_one'] = $base + [
'#title' => '#default_value = #empty_value, #required',
'#required' => TRUE,
'#default_value' => 'one',
'#empty_value' => 'one',
- );
+ ];
- $form['no_default'] = $base + array(
+ $form['no_default'] = $base + [
'#title' => 'No #default_value, #required',
'#required' => TRUE,
- );
- $form['no_default_optional'] = $base + array(
+ ];
+ $form['no_default_optional'] = $base + [
'#title' => 'No #default_value, not #required',
'#required' => FALSE,
'#description' => 'Should result in "one" because it is not required and there is no #empty_value requested, so default browser behavior of preselecting first option is in effect.',
- );
- $form['no_default_optional_empty_value'] = $base + array(
+ ];
+ $form['no_default_optional_empty_value'] = $base + [
'#title' => 'No #default_value, not #required, #empty_value empty string',
'#empty_value' => '',
'#required' => FALSE,
'#description' => 'Should result in an empty string (due to #empty_value) because it is optional.',
- );
+ ];
- $form['no_default_empty_option'] = $base + array(
+ $form['no_default_empty_option'] = $base + [
'#title' => 'No #default_value, #required, #empty_option',
'#required' => TRUE,
'#empty_option' => '- Choose -',
- );
- $form['no_default_empty_option_optional'] = $base + array(
+ ];
+ $form['no_default_empty_option_optional'] = $base + [
'#title' => 'No #default_value, not #required, #empty_option',
'#empty_option' => '- Dismiss -',
'#description' => 'Should result in an empty string (default of #empty_value) because it is optional.',
- );
+ ];
- $form['no_default_empty_value'] = $base + array(
+ $form['no_default_empty_value'] = $base + [
'#title' => 'No #default_value, #required, #empty_value 0',
'#required' => TRUE,
'#empty_value' => 0,
'#description' => 'Should never result in 0.',
- );
- $form['no_default_empty_value_one'] = $base + array(
+ ];
+ $form['no_default_empty_value_one'] = $base + [
'#title' => 'No #default_value, #required, #empty_value one',
'#required' => TRUE,
'#empty_value' => 'one',
'#description' => 'A mistakenly assigned #empty_value contained in #options should not be valid.',
- );
- $form['no_default_empty_value_optional'] = $base + array(
+ ];
+ $form['no_default_empty_value_optional'] = $base + [
'#title' => 'No #default_value, not #required, #empty_value 0',
'#required' => FALSE,
'#empty_value' => 0,
'#description' => 'Should result in 0 because it is optional.',
- );
+ ];
- $form['multiple'] = $base + array(
+ $form['multiple'] = $base + [
'#title' => '#multiple, #default_value two',
- '#default_value' => array('two'),
+ '#default_value' => ['two'],
'#multiple' => TRUE,
- );
- $form['multiple_no_default'] = $base + array(
+ ];
+ $form['multiple_no_default'] = $base + [
'#title' => '#multiple, no #default_value',
'#multiple' => TRUE,
- );
- $form['multiple_no_default_required'] = $base + array(
+ ];
+ $form['multiple_no_default_required'] = $base + [
'#title' => '#multiple, #required, no #default_value',
'#required' => TRUE,
'#multiple' => TRUE,
- );
+ ];
- $form['submit'] = array('#type' => 'submit', '#value' => 'Submit');
+ $form['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php
index 2640805cf20..e34af83b169 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php
@@ -21,18 +21,18 @@ class FormTestStatePersistForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['title'] = array(
+ $form['title'] = [
'#type' => 'textfield',
'#title' => 'title',
'#default_value' => 'DEFAULT',
'#required' => TRUE,
- );
+ ];
$form_state->set('value', 'State persisted.');
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php
index 948c592ceee..f9ae0734227 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php
@@ -28,7 +28,7 @@ class FormTestStorageForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
if ($form_state->isRebuilding()) {
- $form_state->setUserInput(array());
+ $form_state->setUserInput([]);
}
// Initialize
$storage = $form_state->getStorage();
@@ -50,32 +50,32 @@ class FormTestStorageForm extends FormBase {
$_SESSION['constructions']++;
drupal_set_message("Form constructions: " . $_SESSION['constructions']);
- $form['title'] = array(
+ $form['title'] = [
'#type' => 'textfield',
'#title' => 'Title',
'#default_value' => $storage['thing']['title'],
'#required' => TRUE,
- );
- $form['value'] = array(
+ ];
+ $form['value'] = [
'#type' => 'textfield',
'#title' => 'Value',
'#default_value' => $storage['thing']['value'],
- '#element_validate' => array('::elementValidateValueCached'),
- );
- $form['continue_button'] = array(
+ '#element_validate' => ['::elementValidateValueCached'],
+ ];
+ $form['continue_button'] = [
'#type' => 'button',
'#value' => 'Reset',
// Rebuilds the form without keeping the values.
- );
- $form['continue_submit'] = array(
+ ];
+ $form['continue_submit'] = [
'#type' => 'submit',
'#value' => 'Continue submit',
- '#submit' => array('::continueSubmitForm'),
- );
- $form['submit'] = array(
+ '#submit' => ['::continueSubmitForm'],
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- );
+ ];
// @todo Remove this in https://www.drupal.org/node/2524408, because form
// cache immutability is no longer necessary, because we no longer cache
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStoragePageCacheForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStoragePageCacheForm.php
index e7abbfddca7..adca384af8e 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStoragePageCacheForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStoragePageCacheForm.php
@@ -18,30 +18,30 @@ class FormTestStoragePageCacheForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['title'] = array(
+ $form['title'] = [
'#type' => 'textfield',
'#title' => 'Title',
'#required' => TRUE,
- );
+ ];
- $form['test_build_id_old'] = array(
+ $form['test_build_id_old'] = [
'#type' => 'item',
'#title' => 'Old build id',
'#markup' => 'No old build id',
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- );
+ ];
- $form['rebuild'] = array(
+ $form['rebuild'] = [
'#type' => 'submit',
'#value' => 'Rebuild',
- '#submit' => array(array($this, 'form_test_storage_page_cache_rebuild')),
- );
+ '#submit' => [[$this, 'form_test_storage_page_cache_rebuild']],
+ ];
- $form['#after_build'] = array(array($this, 'form_test_storage_page_cache_old_build_id'));
+ $form['#after_build'] = [[$this, 'form_test_storage_page_cache_old_build_id']];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php
index bae573ec18c..1c9628bcf30 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php
@@ -20,20 +20,20 @@ class FormTestTableSelectColspanForm extends FormTestTableSelectFormBase {
list($header, $options) = _form_test_tableselect_get_data();
// Change the data so that the third column has colspan=2.
- $header['three'] = array('data' => 'Three', 'colspan' => 2);
+ $header['three'] = ['data' => 'Three', 'colspan' => 2];
unset($header['four']);
// Set the each row so that column 3 is an array.
foreach ($options as $name => $row) {
- $options[$name]['three'] = array($row['three'], $row['four']);
+ $options[$name]['three'] = [$row['three'], $row['four']];
unset($options[$name]['four']);
}
// Combine cells in row 3.
- $options['row3']['one'] = array('data' => $options['row3']['one'], 'colspan' => 2);
+ $options['row3']['one'] = ['data' => $options['row3']['one'], 'colspan' => 2];
unset($options['row3']['two']);
- $options['row3']['three'] = array('data' => $options['row3']['three'][0], 'colspan' => 2);
+ $options['row3']['three'] = ['data' => $options['row3']['three'][0], 'colspan' => 2];
unset($options['row3']['four']);
- return $this->tableselectFormBuilder($form, $form_state, array('#header' => $header, '#options' => $options));
+ return $this->tableselectFormBuilder($form, $form_state, ['#header' => $header, '#options' => $options]);
}
/**
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php
index d7954f15d7a..199a7d3e274 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php
@@ -17,7 +17,7 @@ class FormTestTableSelectEmptyForm extends FormTestTableSelectFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- return $this->tableselectFormBuilder($form, $form_state, array('#options' => array()));
+ return $this->tableselectFormBuilder($form, $form_state, ['#options' => []]);
}
/**
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
index 4431460d990..0a5bd62a1c3 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
@@ -28,7 +28,7 @@ abstract class FormTestTableSelectFormBase extends FormBase {
$form['tableselect'] = $element_properties;
- $form['tableselect'] += array(
+ $form['tableselect'] += [
'#prefix' => '<div id="tableselect-wrapper">',
'#suffix' => '</div>',
'#type' => 'tableselect',
@@ -36,16 +36,16 @@ abstract class FormTestTableSelectFormBase extends FormBase {
'#options' => $options,
'#multiple' => FALSE,
'#empty' => t('Empty text.'),
- '#ajax' => array(
+ '#ajax' => [
'callback' => 'form_test_tableselect_ajax_callback',
'wrapper' => 'tableselect-wrapper',
- ),
- );
+ ],
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php
index e5483437f22..d6d606aea20 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php
@@ -19,19 +19,19 @@ class FormTestTableSelectJsSelectForm extends FormTestTableSelectFormBase {
public function buildForm(array $form, FormStateInterface $form_state, $test_action = NULL) {
switch ($test_action) {
case 'multiple-true-default':
- $options = array('#multiple' => TRUE);
+ $options = ['#multiple' => TRUE];
break;
case 'multiple-false-default':
- $options = array('#multiple' => FALSE);
+ $options = ['#multiple' => FALSE];
break;
case 'multiple-true-no-advanced-select':
- $options = array('#multiple' => TRUE, '#js_select' => FALSE);
+ $options = ['#multiple' => TRUE, '#js_select' => FALSE];
break;
case 'multiple-false-advanced-select':
- $options = array('#multiple' => FALSE, '#js_select' => TRUE);
+ $options = ['#multiple' => FALSE, '#js_select' => TRUE];
break;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php
index 66fda87b98f..f21ae3c6f47 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php
@@ -17,14 +17,14 @@ class FormTestTableSelectMultipleFalseForm extends FormTestTableSelectFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- return $this->tableselectFormBuilder($form, $form_state, array('#multiple' => FALSE));
+ return $this->tableselectFormBuilder($form, $form_state, ['#multiple' => FALSE]);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- drupal_set_message(t('Submitted: @value', array('@value' => $form_state->getValue('tableselect'))));
+ drupal_set_message(t('Submitted: @value', ['@value' => $form_state->getValue('tableselect')]));
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php
index 5d54b93dc75..d4a0c1d4079 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php
@@ -17,7 +17,7 @@ class FormTestTableSelectMultipleTrueForm extends FormTestTableSelectFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- return $this->tableselectFormBuilder($form, $form_state, array('#multiple' => TRUE));
+ return $this->tableselectFormBuilder($form, $form_state, ['#multiple' => TRUE]);
}
/**
@@ -26,7 +26,7 @@ class FormTestTableSelectMultipleTrueForm extends FormTestTableSelectFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$selected = $form_state->getValue('tableselect');
foreach ($selected as $key => $value) {
- drupal_set_message(t('Submitted: @key = @value', array('@key' => $key, '@value' => $value)));
+ drupal_set_message(t('Submitted: @key = @value', ['@key' => $key, '@value' => $value]));
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php
index 88a661556db..fff0e80521b 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php
@@ -22,21 +22,21 @@ class FormTestUrlForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['url'] = array(
+ $form['url'] = [
'#type' => 'url',
'#title' => 'Optional URL',
'#description' => 'An optional URL field.',
- );
- $form['url_required'] = array(
+ ];
+ $form['url_required'] = [
'#type' => 'url',
'#title' => 'Required URL',
'#description' => 'A required URL field.',
'#required' => TRUE,
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
index d17dca4f821..41772da288d 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
@@ -33,16 +33,16 @@ class FormTestValidateForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$object = new Callbacks();
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => 'Name',
'#default_value' => '',
- '#element_validate' => array(array($object, 'validateName')),
- );
- $form['submit'] = array(
+ '#element_validate' => [[$object, 'validateName']],
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- );
+ ];
return $form;
}
@@ -57,7 +57,7 @@ class FormTestValidateForm extends FormBase {
// Alter the submitted value in $form_state.
$form_state->setValueForElement($form['name'], 'value changed by setValueForElement() in #validate');
// Output the element's value from $form_state.
- drupal_set_message(t('@label value: @value', array('@label' => $form['name']['#title'], '@value' => $form_state->getValue('name'))));
+ drupal_set_message(t('@label value: @value', ['@label' => $form['name']['#title'], '@value' => $form_state->getValue('name')]));
// Trigger a form validation error to see our changes.
$form_state->setErrorByName('');
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php
index b5cf6ec8b19..88e6b353185 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php
@@ -21,50 +21,50 @@ class FormTestValidateRequiredForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $options = array('foo' => 'foo', 'bar' => 'bar');
- $validate = array('::elementValidateRequired');
+ $options = ['foo' => 'foo', 'bar' => 'bar'];
+ $validate = ['::elementValidateRequired'];
- $form['textfield'] = array(
+ $form['textfield'] = [
'#type' => 'textfield',
'#title' => 'Name',
'#required' => TRUE,
'#required_error' => t('Please enter a name.'),
- );
- $form['checkboxes'] = array(
+ ];
+ $form['checkboxes'] = [
'#type' => 'checkboxes',
'#title' => 'Checkboxes',
'#options' => $options,
'#required' => TRUE,
'#form_test_required_error' => t('Please choose at least one option.'),
'#element_validate' => $validate,
- );
- $form['select'] = array(
+ ];
+ $form['select'] = [
'#type' => 'select',
'#title' => 'Select',
'#options' => $options,
'#required' => TRUE,
'#form_test_required_error' => t('Please select something.'),
'#element_validate' => $validate,
- );
- $form['radios'] = array(
+ ];
+ $form['radios'] = [
'#type' => 'radios',
'#title' => 'Radios',
'#options' => $options,
'#required' => TRUE,
- );
- $form['radios_optional'] = array(
+ ];
+ $form['radios_optional'] = [
'#type' => 'radios',
'#title' => 'Radios (optional)',
'#options' => $options,
- );
- $form['radios_optional_default_value_false'] = array(
+ ];
+ $form['radios_optional_default_value_false'] = [
'#type' => 'radios',
'#title' => 'Radios (optional, with a default value of FALSE)',
'#options' => $options,
'#default_value' => FALSE,
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Submit');
+ ];
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php
index 30bd76aa110..29b3b5f9613 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php
@@ -21,12 +21,12 @@ class FormTestValidateRequiredNoTitleForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['textfield'] = array(
+ $form['textfield'] = [
'#type' => 'textfield',
'#required' => TRUE,
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Submit');
+ ];
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php
index bab4d192c0e..cb171a66712 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php
@@ -18,81 +18,81 @@ class FormTestVerticalTabsAccessForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['vertical_tabs1'] = array(
+ $form['vertical_tabs1'] = [
'#type' => 'vertical_tabs',
- );
- $form['tab1'] = array(
+ ];
+ $form['tab1'] = [
'#type' => 'fieldset',
'#title' => t('Tab 1'),
'#collapsible' => TRUE,
'#group' => 'vertical_tabs1',
- );
- $form['tab1']['field1'] = array(
+ ];
+ $form['tab1']['field1'] = [
'#title' => t('Field 1'),
'#type' => 'checkbox',
'#default_value' => TRUE,
- );
- $form['tab2'] = array(
+ ];
+ $form['tab2'] = [
'#type' => 'fieldset',
'#title' => t('Tab 2'),
'#collapsible' => TRUE,
'#group' => 'vertical_tabs1',
- );
- $form['tab2']['field2'] = array(
+ ];
+ $form['tab2']['field2'] = [
'#title' => t('Field 2'),
'#type' => 'textfield',
'#default_value' => 'field2',
- );
+ ];
- $form['fieldset1'] = array(
+ $form['fieldset1'] = [
'#type' => 'fieldset',
'#title' => t('Fieldset'),
- );
- $form['fieldset1']['field3'] = array(
+ ];
+ $form['fieldset1']['field3'] = [
'#type' => 'checkbox',
'#title' => t('Field 3'),
'#default_value' => TRUE,
- );
+ ];
- $form['container'] = array(
+ $form['container'] = [
'#type' => 'container',
- );
- $form['container']['field4'] = array(
+ ];
+ $form['container']['field4'] = [
'#type' => 'checkbox',
'#title' => t('Field 4'),
'#default_value' => TRUE,
- );
- $form['container']['subcontainer'] = array(
+ ];
+ $form['container']['subcontainer'] = [
'#type' => 'container',
- );
- $form['container']['subcontainer']['field5'] = array(
+ ];
+ $form['container']['subcontainer']['field5'] = [
'#type' => 'checkbox',
'#title' => t('Field 5'),
'#default_value' => TRUE,
- );
+ ];
- $form['vertical_tabs2'] = array(
+ $form['vertical_tabs2'] = [
'#type' => 'vertical_tabs',
- );
- $form['tab3'] = array(
+ ];
+ $form['tab3'] = [
'#type' => 'fieldset',
'#title' => t('Tab 3'),
'#collapsible' => TRUE,
'#group' => 'vertical_tabs2',
- );
- $form['tab3']['field6'] = array(
+ ];
+ $form['tab3']['field6'] = [
'#title' => t('Field 6'),
'#type' => 'checkbox',
'#default_value' => TRUE,
- );
+ ];
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php
index 3457db80874..b89636a433a 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php
@@ -20,23 +20,23 @@ class FormTestVerticalTabsForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$tab_count = 3;
- $form['vertical_tabs'] = array(
+ $form['vertical_tabs'] = [
'#type' => 'vertical_tabs',
'#default_tab' => 'edit-tab' . $tab_count,
- );
+ ];
for ($i = 1; $i <= $tab_count; $i++) {
- $form['tab' . $i] = array(
+ $form['tab' . $i] = [
'#type' => 'fieldset',
- '#title' => t('Tab @num', array('@num' => $i)),
+ '#title' => t('Tab @num', ['@num' => $i]),
'#group' => 'vertical_tabs',
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
- );
- $form['tab' . $i]['field' . $i] = array(
- '#title' => t('Field @num', array('@num' => $i)),
+ ];
+ $form['tab' . $i]['field' . $i] = [
+ '#title' => t('Field @num', ['@num' => $i]),
'#type' => 'textfield',
- );
+ ];
}
return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php b/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php
index 8963462fd2e..163ac227068 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php
@@ -23,8 +23,8 @@ class RedirectBlockForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit'));
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->t('Submit')];
return $form;
}
@@ -33,7 +33,7 @@ class RedirectBlockForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $form_state->setRedirect('form_test.route1', array(), array('query' => array('test1' => 'test2')));
+ $form_state->setRedirect('form_test.route1', [], ['query' => ['test1' => 'test2']]);
}
}
diff --git a/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php b/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php
index 7bba8e01032..7531ca816a5 100644
--- a/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php
+++ b/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php
@@ -28,19 +28,19 @@ class FormTestArgumentsObject extends ConfigFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $arg = NULL) {
- $form['element'] = array('#markup' => 'The FormTestArgumentsObject::buildForm() method was used for this form.');
+ $form['element'] = ['#markup' => 'The FormTestArgumentsObject::buildForm() method was used for this form.'];
- $form['bananas'] = array(
+ $form['bananas'] = [
'#type' => 'textfield',
'#default_value' => $arg,
'#title' => $this->t('Bananas'),
- );
+ ];
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php b/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php
index 5b2390cac05..019513d082f 100644
--- a/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php
+++ b/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php
@@ -21,17 +21,17 @@ class FormTestAutocompleteForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['autocomplete_1'] = array(
+ $form['autocomplete_1'] = [
'#type' => 'textfield',
'#title' => 'Autocomplete 1',
'#autocomplete_route_name' => 'form_test.autocomplete_1',
- );
- $form['autocomplete_2'] = array(
+ ];
+ $form['autocomplete_2'] = [
'#type' => 'textfield',
'#title' => 'Autocomplete 2',
'#autocomplete_route_name' => 'form_test.autocomplete_2',
- '#autocomplete_route_parameters' => array('param' => 'value'),
- );
+ '#autocomplete_route_parameters' => ['param' => 'value'],
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php b/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php
index 826bf2c2f0a..7573253481e 100644
--- a/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php
+++ b/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php
@@ -40,21 +40,21 @@ class FormTestControllerObject extends ConfigFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $custom_attributes = NULL) {
- $form['element'] = array('#markup' => 'The FormTestControllerObject::buildForm() method was used for this form.');
+ $form['element'] = ['#markup' => 'The FormTestControllerObject::buildForm() method was used for this form.'];
$form['custom_attribute']['#markup'] = $custom_attributes;
$form['request_attribute']['#markup'] = $request->attributes->get('request_attribute');
- $form['bananas'] = array(
+ $form['bananas'] = [
'#type' => 'textfield',
'#title' => $this->t('Bananas'),
- );
+ ];
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/form_test/src/FormTestObject.php b/core/modules/system/tests/modules/form_test/src/FormTestObject.php
index e64903049e0..f99fbe73004 100644
--- a/core/modules/system/tests/modules/form_test/src/FormTestObject.php
+++ b/core/modules/system/tests/modules/form_test/src/FormTestObject.php
@@ -28,12 +28,12 @@ class FormTestObject extends ConfigFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['element'] = array('#markup' => 'The FormTestObject::buildForm() method was used for this form.');
+ $form['element'] = ['#markup' => 'The FormTestObject::buildForm() method was used for this form.'];
- $form['bananas'] = array(
+ $form['bananas'] = [
'#type' => 'textfield',
'#title' => $this->t('Bananas'),
- );
+ ];
$form['strawberry'] = [
'#type' => 'hidden',
'#value' => 'red',
@@ -41,10 +41,10 @@ class FormTestObject extends ConfigFormBase {
];
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
- );
+ ];
$form['#title'] = 'Test dynamic title';
diff --git a/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php b/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php
index 10ad61b6199..effd319bb0c 100644
--- a/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php
+++ b/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php
@@ -28,19 +28,19 @@ class FormTestServiceObject extends ConfigFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['element'] = array('#markup' => 'The FormTestServiceObject::buildForm() method was used for this form.');
+ $form['element'] = ['#markup' => 'The FormTestServiceObject::buildForm() method was used for this form.'];
- $form['bananas'] = array(
+ $form['bananas'] = [
'#type' => 'textfield',
'#default_value' => 'brown',
'#title' => $this->t('Bananas'),
- );
+ ];
$form['actions']['#type'] = 'actions';
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/OperationBase.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/OperationBase.php
index 6ac953240a5..e978f2a0708 100644
--- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/OperationBase.php
+++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/OperationBase.php
@@ -13,7 +13,7 @@ abstract class OperationBase extends ImageToolkitOperationBase {
* {@inheritdoc}
*/
public function arguments() {
- return array();
+ return [];
}
/**
diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
index 9766d099060..a28c7869048 100644
--- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
+++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
@@ -92,14 +92,14 @@ class TestToolkit extends ImageToolkitBase {
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$this->logCall('settings', func_get_args());
- $form['test_parameter'] = array(
+ $form['test_parameter'] = [
'#type' => 'number',
'#title' => $this->t('Test toolkit parameter'),
'#description' => $this->t('A toolkit parameter for testing purposes.'),
'#min' => 0,
'#max' => 100,
'#default_value' => $this->configFactory->getEditable('system.image.test_toolkit')->get('test_parameter', FALSE),
- );
+ ];
return $form;
}
@@ -117,7 +117,7 @@ class TestToolkit extends ImageToolkitBase {
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configFactory->getEditable('system.image.test_toolkit')
- ->set('test_parameter', $form_state->getValue(array('test', 'test_parameter')))
+ ->set('test_parameter', $form_state->getValue(['test', 'test_parameter']))
->save();
}
@@ -165,7 +165,7 @@ class TestToolkit extends ImageToolkitBase {
* @see \Drupal\system\Tests\Image\ToolkitTestBase::imageTestGetAllCalls()
*/
protected function logCall($op, $args) {
- $results = $this->state->get('image_test.results') ?: array();
+ $results = $this->state->get('image_test.results') ?: [];
$results[$op][] = $args;
// A call to apply is also logged under its operation name whereby the
// array of arguments are logged as separate arguments, this because at the
@@ -236,7 +236,7 @@ class TestToolkit extends ImageToolkitBase {
* {@inheritdoc}
*/
public static function getSupportedExtensions() {
- $extensions = array();
+ $extensions = [];
foreach (static::supportedTypes() as $image_type) {
$extensions[] = Unicode::strtolower(image_type_to_extension($image_type, FALSE));
}
@@ -251,13 +251,13 @@ class TestToolkit extends ImageToolkitBase {
* IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
*/
protected static function supportedTypes() {
- return array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF);
+ return [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
}
/**
* {@inheritdoc}
*/
- public function apply($operation, array $arguments = array()) {
+ public function apply($operation, array $arguments = []) {
$this->logCall('apply', func_get_args());
return TRUE;
}
diff --git a/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module b/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module
index ed059960585..1e7da67fad9 100644
--- a/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module
+++ b/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module
@@ -13,6 +13,6 @@ function keyvalue_test_entity_type_alter(array &$entity_types) {
if (isset($entity_types['entity_test_label'])) {
$entity_types['entity_test_label']->setStorageClass('Drupal\Core\Entity\KeyValueStore\KeyValueContentEntityStorage');
$entity_keys = $entity_types['entity_test_label']->getKeys();
- $entity_types['entity_test_label']->set('entity_keys', $entity_keys + array('uuid' => 'uuid'));
+ $entity_types['entity_test_label']->set('entity_keys', $entity_keys + ['uuid' => 'uuid']);
}
}
diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module
index f891fce9f35..79b4dae2bbf 100644
--- a/core/modules/system/tests/modules/menu_test/menu_test.module
+++ b/core/modules/system/tests/modules/menu_test/menu_test.module
@@ -19,35 +19,35 @@ function menu_test_menu_links_discovered_alter(&$links) {
$links['menu_test.context']['title'] = \Drupal::config('menu_test.menu_item')->get('title');
// Adds a custom menu link.
- $links['menu_test.custom'] = array(
+ $links['menu_test.custom'] = [
'title' => 'Custom link',
'route_name' => 'menu_test.custom',
'description' => 'Custom link used to check the integrity of manually added menu links.',
'parent' => 'menu_test',
- );
+ ];
}
/**
* Implements hook_menu_local_tasks_alter().
*/
function menu_test_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) {
- if (in_array($route_name, array('menu_test.tasks_default'))) {
- $data['tabs'][0]['foo'] = array(
+ if (in_array($route_name, ['menu_test.tasks_default'])) {
+ $data['tabs'][0]['foo'] = [
'#theme' => 'menu_local_task',
- '#link' => array(
+ '#link' => [
'title' => "Task 1 <script>alert('Welcome to the jungle!')</script>",
- 'url' => Url::fromRoute('menu_test.router_test1', array('bar' => '1')),
- ),
+ 'url' => Url::fromRoute('menu_test.router_test1', ['bar' => '1']),
+ ],
'#weight' => 10,
- );
- $data['tabs'][0]['bar'] = array(
+ ];
+ $data['tabs'][0]['bar'] = [
'#theme' => 'menu_local_task',
- '#link' => array(
+ '#link' => [
'title' => 'Task 2',
- 'url' => Url::fromRoute('menu_test.router_test2', array('bar' => '2')),
- ),
+ 'url' => Url::fromRoute('menu_test.router_test2', ['bar' => '2']),
+ ],
'#weight' => 20,
- );
+ ];
}
$cacheability->addCacheTags(['kittens:dwarf-cat']);
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
index c0832692c66..fe6566cddb3 100644
--- a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
+++ b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
@@ -83,8 +83,8 @@ class MenuTestController extends ControllerBase {
* @return string
* The route title.
*/
- public function titleCallback(array $_title_arguments = array(), $_title = '') {
- $_title_arguments += array('case_number' => '2', 'title' => $_title);
+ public function titleCallback(array $_title_arguments = [], $_title = '') {
+ $_title_arguments += ['case_number' => '2', 'title' => $_title];
return t($_title_arguments['title']) . ' - Case ' . $_title_arguments['case_number'];
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTest.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTest.php
index 10c0810f684..decfd36740e 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTest.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTest.php
@@ -11,10 +11,10 @@ class LocalTaskTest extends DeriverBase {
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$weight = $base_plugin_definition['weight'];
- foreach (array('derive1' => 'Derive 1', 'derive2' => 'Derive 2') as $key => $title) {
+ foreach (['derive1' => 'Derive 1', 'derive2' => 'Derive 2'] as $key => $title) {
$this->derivatives[$key] = $base_plugin_definition;
$this->derivatives[$key]['title'] = $title;
- $this->derivatives[$key]['route_parameters'] = array('placeholder' => $key);
+ $this->derivatives[$key]['route_parameters'] = ['placeholder' => $key];
$this->derivatives[$key]['weight'] = $weight++; // ensure weights for testing.
}
return $this->derivatives;
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
index efd75799bc0..1f8300a4ba4 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
@@ -16,7 +16,7 @@ class TestLocalAction4 extends LocalActionDefault {
* {@inheritdoc}
*/
public function getTitle() {
- return $this->t('My @arg action', array('@arg' => 'dynamic-title'));
+ return $this->t('My @arg action', ['@arg' => 'dynamic-title']);
}
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
index 72ef717c717..cadaa9a0c92 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
@@ -13,7 +13,7 @@ class TestTasksSettingsSub1 extends LocalTaskDefault {
* {@inheritdoc}
*/
function getTitle() {
- return $this->t('Dynamic title for @class', array('@class' => 'TestTasksSettingsSub1'));
+ return $this->t('Dynamic title for @class', ['@class' => 'TestTasksSettingsSub1']);
}
/**
diff --git a/core/modules/system/tests/modules/menu_test/src/TestControllers.php b/core/modules/system/tests/modules/menu_test/src/TestControllers.php
index 9ed7851b2a9..31fb341afb0 100644
--- a/core/modules/system/tests/modules/menu_test/src/TestControllers.php
+++ b/core/modules/system/tests/modules/menu_test/src/TestControllers.php
@@ -59,7 +59,7 @@ class TestControllers {
*/
public function testDefaults($placeholder = NULL) {
if ($placeholder) {
- return ['#markup' => SafeMarkup::format("Sometimes there is a placeholder: '@placeholder'.", array('@placeholder' => $placeholder))];
+ return ['#markup' => SafeMarkup::format("Sometimes there is a placeholder: '@placeholder'.", ['@placeholder' => $placeholder])];
}
else {
return ['#markup' => 'Sometimes there is no placeholder.'];
diff --git a/core/modules/system/tests/modules/module_test/module_test.file.inc b/core/modules/system/tests/modules/module_test/module_test.file.inc
index 0842944ca68..b40e0f34537 100644
--- a/core/modules/system/tests/modules/module_test/module_test.file.inc
+++ b/core/modules/system/tests/modules/module_test/module_test.file.inc
@@ -9,5 +9,5 @@
* Implements hook_test_hook().
*/
function module_test_test_hook() {
- return array('module_test' => 'success!');
+ return ['module_test' => 'success!'];
}
diff --git a/core/modules/system/tests/modules/module_test/module_test.install b/core/modules/system/tests/modules/module_test/module_test.install
index e90fc577aca..5f3f6f654c9 100644
--- a/core/modules/system/tests/modules/module_test/module_test.install
+++ b/core/modules/system/tests/modules/module_test/module_test.install
@@ -9,18 +9,18 @@
* Implements hook_schema().
*/
function module_test_schema() {
- $schema['module_test'] = array(
+ $schema['module_test'] = [
'description' => 'Dummy table to test the behavior of hook_schema() during module installation.',
- 'fields' => array(
- 'data' => array(
+ 'fields' => [
+ 'data' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'An example data column for the module.',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $schema;
}
@@ -30,8 +30,8 @@ function module_test_schema() {
function module_test_install() {
$schema = drupal_get_module_schema('module_test', 'module_test');
db_insert('module_test')
- ->fields(array(
+ ->fields([
'data' => $schema['fields']['data']['type'],
- ))
+ ])
->execute();
}
diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module
index 9c5cd9ac29d..dba4889d530 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -60,9 +60,9 @@ function module_test_system_info_alter(&$info, Extension $file, $type) {
* Implements hook_hook_info().
*/
function module_test_hook_info() {
- $hooks['test_hook'] = array(
+ $hooks['test_hook'] = [
'group' => 'file',
- );
+ ];
return $hooks;
}
diff --git a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php b/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
index 39144c67fce..1964f740fe9 100644
--- a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
+++ b/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
@@ -28,7 +28,7 @@ class PagerTestController extends ControllerBase {
];
$query = db_select('watchdog', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element($element);
$result = $query
- ->fields('d', array('wid', 'type', 'timestamp'))
+ ->fields('d', ['wid', 'type', 'timestamp'])
->limit($limit)
->orderBy('d.wid')
->execute();
@@ -58,19 +58,19 @@ class PagerTestController extends ControllerBase {
// Counter of calls to the current pager.
$query_params = pager_get_query_parameters();
$pager_calls = isset($query_params['pager_calls']) ? ($query_params['pager_calls'] ? $query_params['pager_calls'] : 0) : 0;
- $build['l_pager_pager_0'] = array('#markup' => $this->t('Pager calls: @pager_calls', array('@pager_calls' => $pager_calls)));
+ $build['l_pager_pager_0'] = ['#markup' => $this->t('Pager calls: @pager_calls', ['@pager_calls' => $pager_calls])];
// Pager.
- $build['pager_pager_0'] = array(
+ $build['pager_pager_0'] = [
'#type' => 'pager',
'#element' => 0,
- '#parameters' => array(
+ '#parameters' => [
'pager_calls' => ++$pager_calls,
- ),
+ ],
'#pre_render' => [
'Drupal\pager_test\Controller\PagerTestController::showPagerCacheContext',
]
- );
+ ];
return $build;
}
@@ -82,34 +82,34 @@ class PagerTestController extends ControllerBase {
// Build three tables with same query and different pagers.
$build['pager_table_0'] = $this->buildTestTable(0, 20);
- $build['pager_pager_0'] = array(
+ $build['pager_pager_0'] = [
'#type' => 'container',
'#attributes' => ['class' => ['test-pager-0']],
'pager' => [
'#type' => 'pager',
'#element' => 0,
],
- );
+ ];
$build['pager_table_1'] = $this->buildTestTable(1, 20);
- $build['pager_pager_1'] = array(
+ $build['pager_pager_1'] = [
'#type' => 'container',
'#attributes' => ['class' => ['test-pager-1']],
'pager' => [
'#type' => 'pager',
'#element' => 1,
],
- );
+ ];
$build['pager_table_4'] = $this->buildTestTable(4, 20);
- $build['pager_pager_4'] = array(
+ $build['pager_pager_4'] = [
'#type' => 'container',
'#attributes' => ['class' => ['test-pager-4']],
'pager' => [
'#type' => 'pager',
'#element' => 4,
],
- );
+ ];
return $build;
}
diff --git a/core/modules/system/tests/modules/path_test/path_test.module b/core/modules/system/tests/modules/path_test/path_test.module
index df03931255d..32489c021f5 100644
--- a/core/modules/system/tests/modules/path_test/path_test.module
+++ b/core/modules/system/tests/modules/path_test/path_test.module
@@ -9,14 +9,14 @@
* Resets the path test results.
*/
function path_test_reset() {
- \Drupal::state()->set('path_test.results', array());
+ \Drupal::state()->set('path_test.results', []);
}
/**
* Implements hook_path_update().
*/
function path_test_path_update($path) {
- $results = \Drupal::state()->get('path_test.results') ?: array();
+ $results = \Drupal::state()->get('path_test.results') ?: [];
$results['hook_path_update'] = $path;
\Drupal::state()->set('path_test.results', $results);
}
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/Annotation/PluginExample.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/Annotation/PluginExample.php
index daca83bae66..b80460d6919 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/Annotation/PluginExample.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/Annotation/PluginExample.php
@@ -29,12 +29,12 @@ class PluginExample extends AnnotationBase {
* {@inheritdoc}
*/
public function get() {
- return array(
+ return [
'id' => $this->id,
'custom' => $this->custom,
'class' => $this->class,
'provider' => $this->provider,
- );
+ ];
}
}
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php
index eda8f8845ea..65d7078ceb6 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php
@@ -28,27 +28,27 @@ class DefaultsTestPluginManager extends DefaultPluginManager {
$this->moduleHandler = $module_handler;
// Specify default values.
- $this->defaults = array(
- 'metadata' => array(
+ $this->defaults = [
+ 'metadata' => [
'default' => TRUE,
- ),
- );
+ ],
+ ];
// Add a plugin with a custom value.
- $this->discovery->setDefinition('test_block1', array(
+ $this->discovery->setDefinition('test_block1', [
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockTestBlock',
- 'metadata' => array(
+ 'metadata' => [
'custom' => TRUE,
- ),
- ));
+ ],
+ ]);
// Add a plugin that overrides the default value.
- $this->discovery->setDefinition('test_block2', array(
+ $this->discovery->setDefinition('test_block2', [
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockTestBlock',
- 'metadata' => array(
+ 'metadata' => [
'custom' => TRUE,
'default' => FALSE,
- ),
- ));
+ ],
+ ]);
}
}
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php
index db4a05282d3..8748a7b9434 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php
@@ -34,11 +34,11 @@ class MockBlockManager extends PluginManagerBase {
// plugins to the system.
// A simple plugin: the user login block.
- $this->discovery->setDefinition('user_login', array(
+ $this->discovery->setDefinition('user_login', [
'id' => 'user_login',
'label' => t('User login'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock',
- ));
+ ]);
// A plugin that requires derivatives: the menu block plugin. We do not want
// a generic "Menu" block showing up in the Block administration UI.
@@ -46,17 +46,17 @@ class MockBlockManager extends PluginManagerBase {
// system and each one's title is user configurable. The
// MockMenuBlockDeriver class ensures that only derivatives, and not the
// base plugin, are available to the system.
- $this->discovery->setDefinition('menu', array(
+ $this->discovery->setDefinition('menu', [
'id' => 'menu',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock',
'deriver' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlockDeriver',
- ));
+ ]);
// A plugin defining itself as a derivative.
- $this->discovery->setDefinition('menu:foo', array(
+ $this->discovery->setDefinition('menu:foo', [
'id' => 'menu',
'label' => t('Base label'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock',
- ));
+ ]);
// A block plugin that can optionally be derived: the layout block plugin.
// A layout is a special kind of block into which other blocks can be
@@ -64,51 +64,51 @@ class MockBlockManager extends PluginManagerBase {
// administration UI as well as additional user-created custom layouts. The
// MockLayoutBlockDeriver class ensures that both the base plugin and the
// derivatives are available to the system.
- $this->discovery->setDefinition('layout', array(
+ $this->discovery->setDefinition('layout', [
'id' => 'layout',
'label' => t('Layout'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlock',
'deriver' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver',
- ));
+ ]);
// A block plugin that requires context to function. This block requires a
// user object in order to return the user name from the getTitle() method.
- $this->discovery->setDefinition('user_name', array(
+ $this->discovery->setDefinition('user_name', [
'id' => 'user_name',
'label' => t('User name'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
- 'context' => array(
+ 'context' => [
'user' => $this->createContextDefinition('entity:user', t('User')),
- ),
- ));
+ ],
+ ]);
// An optional context version of the previous block plugin.
- $this->discovery->setDefinition('user_name_optional', array(
+ $this->discovery->setDefinition('user_name_optional', [
'id' => 'user_name_optional',
'label' => t('User name optional'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
- 'context' => array(
+ 'context' => [
'user' => $this->createContextDefinition('entity:user', t('User'), FALSE),
- ),
- ));
+ ],
+ ]);
// A block plugin that requires a typed data string context to function.
- $this->discovery->setDefinition('string_context', array(
+ $this->discovery->setDefinition('string_context', [
'id' => 'string_context',
'label' => t('String typed data'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\TypedDataStringBlock',
- ));
+ ]);
// A complex context plugin that requires both a user and node for context.
- $this->discovery->setDefinition('complex_context', array(
+ $this->discovery->setDefinition('complex_context', [
'id' => 'complex_context',
'label' => t('Complex context'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock',
- 'context' => array(
+ 'context' => [
'user' => $this->createContextDefinition('entity:user', t('User')),
'node' => $this->createContextDefinition('entity:node', t('Node')),
- ),
- ));
+ ],
+ ]);
// In addition to finding all of the plugins available for a type, a plugin
// type must also be able to create instances of that plugin. For example, a
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/TestLazyPluginCollection.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/TestLazyPluginCollection.php
index dd426e481a3..1009faa5404 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/TestLazyPluginCollection.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/TestLazyPluginCollection.php
@@ -34,14 +34,14 @@ class TestLazyPluginCollection extends LazyPluginCollection {
* {@inheritdoc}
*/
protected function initializePlugin($instance_id) {
- $this->pluginInstances[$instance_id] = $this->manager->createInstance($instance_id, array());
+ $this->pluginInstances[$instance_id] = $this->manager->createInstance($instance_id, []);
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
- return array();
+ return [];
}
/**
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/TestPluginManager.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/TestPluginManager.php
index 60e74d83941..ec464a5b7ae 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/TestPluginManager.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/TestPluginManager.php
@@ -19,10 +19,10 @@ class TestPluginManager extends PluginManagerBase {
$this->discovery = new StaticDiscovery();
// A simple plugin: a mock user login block.
- $this->discovery->setDefinition('user_login', array(
+ $this->discovery->setDefinition('user_login', [
'label' => 'User login',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock',
- ));
+ ]);
// In addition to finding all of the plugins available for a type, a plugin
// type must also be able to create instances of that plugin. For example, a
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
index d2fa3a46ced..93fca538b88 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
@@ -31,7 +31,7 @@ class MockLayoutBlockDeriver implements DeriverInterface {
// key from the returned definitions.
unset($base_plugin_definition['deriver']);
- $derivatives = array(
+ $derivatives = [
// Adding a NULL key signifies that the base plugin may also be used in
// addition to the derivatives. In this case, we allow the administrator
// to add a generic layout block to the page.
@@ -40,10 +40,10 @@ class MockLayoutBlockDeriver implements DeriverInterface {
// We also allow them to add a customized one. Here, we just mock the
// customized one, but in a real implementation, this would be fetched
// from some \Drupal::config() object.
- 'foo' => array(
+ 'foo' => [
'label' => t('Layout Foo'),
- ) + $base_plugin_definition,
- );
+ ] + $base_plugin_definition,
+ ];
return $derivatives;
}
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
index 413eb133551..d5f6d6c2937 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
@@ -34,20 +34,20 @@ class MockMenuBlockDeriver implements DeriverInterface {
// Here, we create some mock menu block definitions for menus that might
// exist in a typical Drupal site. In a real implementation, we would query
// Drupal's configuration to find out which menus actually exist.
- $derivatives = array(
- 'main_menu' => array(
+ $derivatives = [
+ 'main_menu' => [
'label' => t('Main menu'),
- ) + $base_plugin_definition,
- 'navigation' => array(
+ ] + $base_plugin_definition,
+ 'navigation' => [
'label' => t('Navigation'),
- ) + $base_plugin_definition,
- 'foo' => array(
+ ] + $base_plugin_definition,
+ 'foo' => [
// Instead of the derivative label, the specific label will be used.
'label' => t('Derivative label'),
// This setting will be merged in.
'setting' => 'default'
- ) + $base_plugin_definition,
- );
+ ] + $base_plugin_definition,
+ ];
return $derivatives;
}
diff --git a/core/modules/system/tests/modules/requirements1_test/requirements1_test.install b/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
index c88489399d6..e8121617adc 100644
--- a/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
+++ b/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
@@ -9,15 +9,15 @@
* Implements hook_requirements().
*/
function requirements1_test_requirements($phase) {
- $requirements = array();
+ $requirements = [];
// Always fails requirements.
if ('install' == $phase) {
- $requirements['requirements1_test'] = array(
+ $requirements['requirements1_test'] = [
'title' => t('Requirements 1 Test'),
'severity' => REQUIREMENT_ERROR,
'description' => t('Requirements 1 Test failed requirements.'),
- );
+ ];
}
return $requirements;
diff --git a/core/modules/system/tests/modules/router_test_directory/src/RouterTestServiceProvider.php b/core/modules/system/tests/modules/router_test_directory/src/RouterTestServiceProvider.php
index 7635704fb3b..5430e8d8bca 100644
--- a/core/modules/system/tests/modules/router_test_directory/src/RouterTestServiceProvider.php
+++ b/core/modules/system/tests/modules/router_test_directory/src/RouterTestServiceProvider.php
@@ -16,7 +16,7 @@ class RouterTestServiceProvider implements ServiceProviderInterface {
public function register(ContainerBuilder $container) {
$container->register('router_test.subscriber', 'Drupal\router_test\RouteTestSubscriber')->addTag('event_subscriber');
$container->register('access_check.router_test', 'Drupal\router_test\Access\TestAccessCheck')
- ->addTag('access_check', array('applies_to' => '_access_router_test'));
+ ->addTag('access_check', ['applies_to' => '_access_router_test']);
}
}
diff --git a/core/modules/system/tests/modules/router_test_directory/src/TestContent.php b/core/modules/system/tests/modules/router_test_directory/src/TestContent.php
index 9cbe023ab12..f392a81e85e 100644
--- a/core/modules/system/tests/modules/router_test_directory/src/TestContent.php
+++ b/core/modules/system/tests/modules/router_test_directory/src/TestContent.php
@@ -63,7 +63,7 @@ class TestContent extends ControllerBase {
*/
public function subrequestTest(UserInterface $user) {
$request = \Drupal::request();
- $request = Request::create('/router_test/test13/' . $user->id(), 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all());
+ $request = Request::create('/router_test/test13/' . $user->id(), 'GET', $request->query->all(), $request->cookies->all(), [], $request->server->all());
return $this->httpKernel->handle($request, HttpKernelInterface::SUB_REQUEST);
}
diff --git a/core/modules/system/tests/modules/service_provider_test/src/TestClass.php b/core/modules/system/tests/modules/service_provider_test/src/TestClass.php
index 9a87c9721df..542239faa32 100644
--- a/core/modules/system/tests/modules/service_provider_test/src/TestClass.php
+++ b/core/modules/system/tests/modules/service_provider_test/src/TestClass.php
@@ -58,8 +58,8 @@ class TestClass implements EventSubscriberInterface, DestructableInterface, Cont
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
- $events[KernelEvents::REQUEST][] = array('onKernelRequestTest');
- $events[KernelEvents::RESPONSE][] = array('onKernelResponseTest');
+ $events[KernelEvents::REQUEST][] = ['onKernelRequestTest'];
+ $events[KernelEvents::RESPONSE][] = ['onKernelResponseTest'];
return $events;
}
diff --git a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
index edde4fd9af4..76a54629425 100644
--- a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
+++ b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
@@ -21,7 +21,7 @@ class SessionTestController extends ControllerBase {
public function get() {
return empty($_SESSION['session_test_value'])
? []
- : ['#markup' => $this->t('The current value of the stored session variable is: %val', array('%val' => $_SESSION['session_test_value']))];
+ : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $_SESSION['session_test_value']])];
}
/**
@@ -37,7 +37,7 @@ class SessionTestController extends ControllerBase {
$value = $request->getSession()->get("session_test_key");
return empty($value)
? []
- : ['#markup' => $this->t('The current value of the stored session variable is: %val', array('%val' => $value))];
+ : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $value])];
}
/**
@@ -84,7 +84,7 @@ class SessionTestController extends ControllerBase {
public function set($test_value) {
$_SESSION['session_test_value'] = $test_value;
- return ['#markup' => $this->t('The current value of the stored session variable has been set to %val', array('%val' => $test_value))];
+ return ['#markup' => $this->t('The current value of the stored session variable has been set to %val', ['%val' => $test_value])];
}
/**
@@ -100,7 +100,7 @@ class SessionTestController extends ControllerBase {
public function noSet($test_value) {
\Drupal::service('session_handler.write_safe')->setSessionWritable(FALSE);
$this->set($test_value);
- return ['#markup' => $this->t('session saving was disabled, and then %val was set', array('%val' => $test_value))];
+ return ['#markup' => $this->t('session saving was disabled, and then %val was set', ['%val' => $test_value])];
}
/**
diff --git a/core/modules/system/tests/modules/session_test/src/EventSubscriber/SessionTestSubscriber.php b/core/modules/system/tests/modules/session_test/src/EventSubscriber/SessionTestSubscriber.php
index ee03668ea85..47c8c5b110e 100644
--- a/core/modules/system/tests/modules/session_test/src/EventSubscriber/SessionTestSubscriber.php
+++ b/core/modules/system/tests/modules/session_test/src/EventSubscriber/SessionTestSubscriber.php
@@ -49,8 +49,8 @@ class SessionTestSubscriber implements EventSubscriberInterface {
* An array of event listener definitions.
*/
public static function getSubscribedEvents() {
- $events[KernelEvents::RESPONSE][] = array('onKernelResponseSessionTest');
- $events[KernelEvents::REQUEST][] = array('onKernelRequestSessionTest');
+ $events[KernelEvents::RESPONSE][] = ['onKernelResponseSessionTest'];
+ $events[KernelEvents::REQUEST][] = ['onKernelRequestSessionTest'];
return $events;
}
diff --git a/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php b/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
index 70c4f834723..bf250ac4524 100644
--- a/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
+++ b/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
@@ -22,17 +22,17 @@ class SessionTestForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['input'] = array(
+ $form['input'] = [
'#type' => 'textfield',
'#title' => 'Input',
'#required' => TRUE,
- );
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- );
+ ];
return $form;
}
@@ -41,7 +41,7 @@ class SessionTestForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- drupal_set_message(SafeMarkup::format('Ok: @input', array('@input' => $form_state->getValue('input'))));
+ drupal_set_message(SafeMarkup::format('Ok: @input', ['@input' => $form_state->getValue('input')]));
}
}
diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
index 8ef6457cb29..5e49c2403b6 100644
--- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
+++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
@@ -206,15 +206,15 @@ class SystemTestController extends ControllerBase {
* Set cache tag on on the returned render array.
*/
public function system_test_cache_tags_page() {
- $build['main'] = array(
- '#cache' => array('tags' => array('system_test_cache_tags_page')),
- '#pre_render' => array(
+ $build['main'] = [
+ '#cache' => ['tags' => ['system_test_cache_tags_page']],
+ '#pre_render' => [
'\Drupal\system_test\Controller\SystemTestController::preRenderCacheTags',
- ),
- 'message' => array(
+ ],
+ 'message' => [
'#markup' => 'Cache tags page example',
- ),
- );
+ ],
+ ];
return $build;
}
@@ -222,12 +222,12 @@ class SystemTestController extends ControllerBase {
* Set cache max-age on the returned render array.
*/
public function system_test_cache_maxage_page() {
- $build['main'] = array(
- '#cache' => array('max-age' => 90),
- 'message' => array(
+ $build['main'] = [
+ '#cache' => ['max-age' => 90],
+ 'message' => [
'#markup' => 'Cache max-age page example',
- ),
- );
+ ],
+ ];
return $build;
}
@@ -245,8 +245,8 @@ class SystemTestController extends ControllerBase {
* @see system_authorized_init()
*/
public function authorizeInit($page_title) {
- $authorize_url = Url::fromUri('base:core/authorize.php', array('absolute' => TRUE))->toString();
- system_authorized_init('system_test_authorize_run', __DIR__ . '/../../system_test.module', array(), $page_title);
+ $authorize_url = Url::fromUri('base:core/authorize.php', ['absolute' => TRUE])->toString();
+ system_authorized_init('system_test_authorize_run', __DIR__ . '/../../system_test.module', [], $page_title);
return new RedirectResponse($authorize_url);
}
@@ -258,7 +258,7 @@ class SystemTestController extends ControllerBase {
$response = new CacheableResponse();
$response->headers->set($query['name'], $query['value']);
$response->getCacheableMetadata()->addCacheContexts(['url.query_args:name', 'url.query_args:value']);
- $response->setContent($this->t('The following header was set: %name: %value', array('%name' => $query['name'], '%value' => $query['value'])));
+ $response->setContent($this->t('The following header was set: %name: %value', ['%name' => $query['name'], '%value' => $query['value']]));
return $response;
}
diff --git a/core/modules/system/tests/modules/system_test/src/MockFileTransfer.php b/core/modules/system/tests/modules/system_test/src/MockFileTransfer.php
index de065af2577..b7ea3f21e5c 100644
--- a/core/modules/system/tests/modules/system_test/src/MockFileTransfer.php
+++ b/core/modules/system/tests/modules/system_test/src/MockFileTransfer.php
@@ -21,11 +21,11 @@ class MockFileTransfer {
* Returns a settings form with a text field to input a username.
*/
public function getSettingsForm() {
- $form = array();
- $form['system_test_username'] = array(
+ $form = [];
+ $form['system_test_username'] = [
'#type' => 'textfield',
'#title' => t('System Test Username'),
- );
+ ];
return $form;
}
diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module
index 04fa2daaf4a..81739086c32 100644
--- a/core/modules/system/tests/modules/system_test/system_test.module
+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -27,7 +27,7 @@ function system_test_help($route_name, RouteMatchInterface $route_match) {
function system_test_modules_installed($modules) {
if (\Drupal::state()->get('system_test.verbose_module_hooks')) {
foreach ($modules as $module) {
- drupal_set_message(t('hook_modules_installed fired for @module', array('@module' => $module)));
+ drupal_set_message(t('hook_modules_installed fired for @module', ['@module' => $module]));
}
}
}
@@ -38,7 +38,7 @@ function system_test_modules_installed($modules) {
function system_test_modules_uninstalled($modules) {
if (\Drupal::state()->get('system_test.verbose_module_hooks')) {
foreach ($modules as $module) {
- drupal_set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
+ drupal_set_message(t('hook_modules_uninstalled fired for @module', ['@module' => $module]));
}
}
}
@@ -66,12 +66,12 @@ function system_test_system_info_alter(&$info, Extension $file, $type) {
if ($file->getName() == 'system_dependencies_test') {
$info['hidden'] = FALSE;
}
- if (in_array($file->getName(), array(
+ if (in_array($file->getName(), [
'system_incompatible_module_version_dependencies_test',
'system_incompatible_core_version_dependencies_test',
'system_incompatible_module_version_test',
'system_incompatible_core_version_test',
- ))) {
+ ])) {
$info['hidden'] = FALSE;
}
if ($file->getName() == 'requirements1_test' || $file->getName() == 'requirements2_test') {
@@ -99,7 +99,7 @@ function system_test_page_attachments(array &$page) {
*/
function _system_test_first_shutdown_function($arg1, $arg2) {
// Set something to ensure that this function got called.
- \Drupal::state()->set('_system_test_first_shutdown_function', array($arg1, $arg2));
+ \Drupal::state()->set('_system_test_first_shutdown_function', [$arg1, $arg2]);
drupal_register_shutdown_function('_system_test_second_shutdown_function', $arg1, $arg2);
}
@@ -108,7 +108,7 @@ function _system_test_first_shutdown_function($arg1, $arg2) {
*/
function _system_test_second_shutdown_function($arg1, $arg2) {
// Set something to ensure that this function got called.
- \Drupal::state()->set('_system_test_second_shutdown_function', array($arg1, $arg2));
+ \Drupal::state()->set('_system_test_second_shutdown_function', [$arg1, $arg2]);
// Throw an exception with an HTML tag. Since this is called in a shutdown
// function, it will not bubble up to the default exception handler but will
@@ -121,13 +121,13 @@ function _system_test_second_shutdown_function($arg1, $arg2) {
* Implements hook_filetransfer_info().
*/
function system_test_filetransfer_info() {
- return array(
- 'system_test' => array(
+ return [
+ 'system_test' => [
'title' => t('System Test FileTransfer'),
'class' => 'Drupal\system_test\MockFileTransfer',
'weight' => -10,
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php b/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php
index 7ec5fc0ce36..2de84e95936 100644
--- a/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php
+++ b/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php
@@ -15,7 +15,7 @@ class Test {
* A render array as expected by drupal_render()
*/
public function renderTitle() {
- $build = array();
+ $build = [];
$build['#markup'] = 'Hello Drupal';
$build['#title'] = 'Foo';
@@ -29,7 +29,7 @@ class Test {
* A render array as expected by drupal_render().
*/
public function staticTitle() {
- $build = array();
+ $build = [];
$build['#markup'] = 'Hello Drupal';
return $build;
@@ -66,9 +66,9 @@ class Test {
* A render array as expected by drupal_render()
*/
public function renderPage() {
- return array(
+ return [
'#markup' => 'Content',
- );
+ ];
}
/**
diff --git a/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module b/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module
index 974856ad2ae..50fb86d2b83 100644
--- a/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module
+++ b/core/modules/system/tests/modules/theme_suggestions_test/theme_suggestions_test.module
@@ -9,11 +9,11 @@
* Implements hook_theme().
*/
function theme_suggestions_test_theme() {
- $items['theme_suggestions_test_include'] = array(
+ $items['theme_suggestions_test_include'] = [
'file' => 'theme_suggestions_test.inc',
- 'variables' => array(),
+ 'variables' => [],
'function' => 'theme_theme_suggestions_test_include',
- );
+ ];
return $items;
}
diff --git a/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php b/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php
index d5f9110a7f7..650d44d412b 100644
--- a/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php
+++ b/core/modules/system/tests/modules/theme_test/src/EventSubscriber/ThemeTestSubscriber.php
@@ -63,11 +63,11 @@ class ThemeTestSubscriber implements EventSubscriberInterface {
// theme_test_request_listener_page_callback() to test that even when the
// theme system is initialized this early, it is still capable of
// returning output and theming the page as a whole.
- $more_link = array(
+ $more_link = [
'#type' => 'more_link',
'#url' => Url::fromRoute('user.page'),
- '#attributes' => array('title' => 'Themed output generated in a KernelEvents::REQUEST listener'),
- );
+ '#attributes' => ['title' => 'Themed output generated in a KernelEvents::REQUEST listener'],
+ ];
$GLOBALS['theme_test_output'] = $this->renderer->renderPlain($more_link);
}
}
@@ -77,9 +77,9 @@ class ThemeTestSubscriber implements EventSubscriberInterface {
*/
public function onView(GetResponseEvent $event) {
$current_route = $this->currentRouteMatch->getRouteName();
- $entity_autcomplete_route = array(
+ $entity_autcomplete_route = [
'system.entity_autocomplete',
- );
+ ];
if (in_array($current_route, $entity_autcomplete_route)) {
if ($this->container->initialized('theme.registry')) {
@@ -92,8 +92,8 @@ class ThemeTestSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
- $events[KernelEvents::REQUEST][] = array('onRequest');
- $events[KernelEvents::VIEW][] = array('onView', -1000);
+ $events[KernelEvents::REQUEST][] = ['onRequest'];
+ $events[KernelEvents::VIEW][] = ['onView', -1000];
return $events;
}
diff --git a/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
index 639f1b7438f..89cd3821539 100644
--- a/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
+++ b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
@@ -17,9 +17,9 @@ class ThemeTestController extends ControllerBase {
* Render array containing a theme.
*/
public function functionTemplateOverridden() {
- return array(
+ return [
'#theme' => 'theme_test_function_template_override',
- );
+ ];
}
/**
@@ -29,13 +29,13 @@ class ThemeTestController extends ControllerBase {
* A render array containing custom stylesheets.
*/
public function testInfoStylesheets() {
- return array(
- '#attached' => array(
- 'library' => array(
+ return [
+ '#attached' => [
+ 'library' => [
'theme_test/theme_stylesheets_override_and_remove_test',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -45,7 +45,7 @@ class ThemeTestController extends ControllerBase {
* A render array containing a theme override.
*/
public function testTemplate() {
- return ['#markup' => \Drupal::theme()->render('theme_test_template_test', array())];
+ return ['#markup' => \Drupal::theme()->render('theme_test_template_test', [])];
}
/**
@@ -55,12 +55,12 @@ class ThemeTestController extends ControllerBase {
* A render array containing an inline template.
*/
public function testInlineTemplate() {
- $element = array();
- $element['test'] = array(
+ $element = [];
+ $element['test'] = [
'#type' => 'inline_template',
'#template' => 'test-with-context {{ llama }}',
- '#context' => array('llama' => 'muuh'),
- );
+ '#context' => ['llama' => 'muuh'],
+ ];
return $element;
}
@@ -71,7 +71,7 @@ class ThemeTestController extends ControllerBase {
* An HTML string containing the themed output.
*/
public function testSuggestion() {
- return ['#markup' => \Drupal::theme()->render(array('theme_test__suggestion', 'theme_test'), array())];
+ return ['#markup' => \Drupal::theme()->render(['theme_test__suggestion', 'theme_test'], [])];
}
/**
@@ -88,35 +88,35 @@ class ThemeTestController extends ControllerBase {
* Menu callback for testing suggestion alter hooks with template files.
*/
function suggestionProvided() {
- return array('#theme' => 'theme_test_suggestion_provided');
+ return ['#theme' => 'theme_test_suggestion_provided'];
}
/**
* Menu callback for testing suggestion alter hooks with template files.
*/
function suggestionAlter() {
- return array('#theme' => 'theme_test_suggestions');
+ return ['#theme' => 'theme_test_suggestions'];
}
/**
* Menu callback for testing hook_theme_suggestions_alter().
*/
function generalSuggestionAlter() {
- return array('#theme' => 'theme_test_general_suggestions');
+ return ['#theme' => 'theme_test_general_suggestions'];
}
/**
* Menu callback for testing suggestion alter hooks with specific suggestions.
*/
function specificSuggestionAlter() {
- return array('#theme' => 'theme_test_specific_suggestions__variant');
+ return ['#theme' => 'theme_test_specific_suggestions__variant'];
}
/**
* Menu callback for testing suggestion alter hooks with theme functions.
*/
function functionSuggestionAlter() {
- return array('#theme' => 'theme_test_function_suggestions');
+ return ['#theme' => 'theme_test_function_suggestions'];
}
@@ -124,7 +124,7 @@ class ThemeTestController extends ControllerBase {
* Menu callback for testing includes with suggestion alter hooks.
*/
function suggestionAlterInclude() {
- return array('#theme' => 'theme_test_suggestions_include');
+ return ['#theme' => 'theme_test_suggestions_include'];
}
/**
diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module
index 540185ec9ba..2e6f1647335 100644
--- a/core/modules/system/tests/modules/theme_test/theme_test.module
+++ b/core/modules/system/tests/modules/theme_test/theme_test.module
@@ -11,55 +11,55 @@ use Drupal\Core\Extension\Extension;
* Implements hook_theme().
*/
function theme_test_theme($existing, $type, $theme, $path) {
- $items['theme_test'] = array(
+ $items['theme_test'] = [
'file' => 'theme_test.inc',
- 'variables' => array('foo' => ''),
+ 'variables' => ['foo' => ''],
'function' => 'theme_theme_test',
- );
- $items['theme_test_template_test'] = array(
+ ];
+ $items['theme_test_template_test'] = [
'template' => 'theme_test.template_test',
- );
- $items['theme_test_template_test_2'] = array(
+ ];
+ $items['theme_test_template_test_2'] = [
'template' => 'theme_test.template_test',
- );
- $items['theme_test_suggestion_provided'] = array(
- 'variables' => array(),
- );
- $items['theme_test_specific_suggestions'] = array(
- 'variables' => array(),
- );
- $items['theme_test_suggestions'] = array(
- 'variables' => array(),
- );
- $items['theme_test_general_suggestions'] = array(
- 'variables' => array(),
- );
- $items['theme_test_function_suggestions'] = array(
- 'variables' => array(),
+ ];
+ $items['theme_test_suggestion_provided'] = [
+ 'variables' => [],
+ ];
+ $items['theme_test_specific_suggestions'] = [
+ 'variables' => [],
+ ];
+ $items['theme_test_suggestions'] = [
+ 'variables' => [],
+ ];
+ $items['theme_test_general_suggestions'] = [
+ 'variables' => [],
+ ];
+ $items['theme_test_function_suggestions'] = [
+ 'variables' => [],
'function' => 'theme_theme_test_function_suggestions',
- );
- $items['theme_test_suggestions_include'] = array(
- 'variables' => array(),
+ ];
+ $items['theme_test_suggestions_include'] = [
+ 'variables' => [],
'function' => 'theme_theme_test_suggestions_include',
- );
- $items['theme_test_foo'] = array(
- 'variables' => array('foo' => NULL),
+ ];
+ $items['theme_test_foo'] = [
+ 'variables' => ['foo' => NULL],
'function' => 'theme_theme_test_foo',
- );
- $items['theme_test_render_element'] = array(
+ ];
+ $items['theme_test_render_element'] = [
'render element' => 'elements',
- );
- $items['theme_test_render_element_children'] = array(
+ ];
+ $items['theme_test_render_element_children'] = [
'render element' => 'element',
'function' => 'theme_theme_test_render_element_children',
- );
- $items['theme_test_function_template_override'] = array(
- 'variables' => array(),
+ ];
+ $items['theme_test_function_template_override'] = [
+ 'variables' => [],
'function' => 'theme_theme_test_function_template_override',
- );
- $info['test_theme_not_existing_function'] = array(
+ ];
+ $info['test_theme_not_existing_function'] = [
'function' => 'test_theme_not_existing_function',
- );
+ ];
$items['theme_test_preprocess_suggestions'] = [
'variables' => [
'foo' => '',
@@ -83,7 +83,7 @@ function theme_test_preprocess_html(&$variables) {
* Implements hook_page_bottom().
*/
function theme_test_page_bottom(array &$page_bottom) {
- $page_bottom['theme_test_page_bottom'] = array('#markup' => 'theme test page bottom markup');
+ $page_bottom['theme_test_page_bottom'] = ['#markup' => 'theme test page bottom markup'];
}
/**
@@ -167,7 +167,7 @@ function theme_theme_test_function_suggestions($variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function theme_test_theme_suggestions_theme_test_suggestion_provided(array $variables) {
- return array('theme_test_suggestion_provided__' . 'foo');
+ return ['theme_test_suggestion_provided__' . 'foo'];
}
/**
diff --git a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php
index 78d10202882..b364c59dd73 100644
--- a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php
+++ b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php
@@ -21,9 +21,9 @@ class TestExtension extends \Twig_Extension {
* The value is a standard PHP callback that defines what the function does.
*/
public function getFunctions() {
- return array(
- 'testfunc' => new \Twig_Function_Function(array('Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFunction')),
- );
+ return [
+ 'testfunc' => new \Twig_Function_Function(['Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFunction']),
+ ];
}
/**
@@ -39,9 +39,9 @@ class TestExtension extends \Twig_Extension {
* The value is a standard PHP callback that defines what the filter does.
*/
public function getFilters() {
- return array(
- 'testfilter' => new \Twig_Filter_Function(array('Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFilter')),
- );
+ return [
+ 'testfilter' => new \Twig_Filter_Function(['Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFilter']),
+ ];
}
/**
@@ -93,7 +93,7 @@ class TestExtension extends \Twig_Extension {
* @see \Drupal\system\Tests\Theme\TwigExtensionTest::testTwigExtensionFilter()
*/
public static function testFilter($string) {
- return str_replace(array('animal'), array('plant'), $string);
+ return str_replace(['animal'], ['plant'], $string);
}
}
diff --git a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtensionTestController.php b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtensionTestController.php
index 44e42d950e5..c15b16d8b0b 100644
--- a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtensionTestController.php
+++ b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtensionTestController.php
@@ -14,7 +14,7 @@ class TwigExtensionTestController {
* Menu callback for testing Twig filters in a Twig template.
*/
public function testFilterRender() {
- return array(
+ return [
'#theme' => 'twig_extension_test_filter',
'#message' => 'Every animal is not a mineral.',
'#safe_join_items' => [
@@ -22,14 +22,14 @@ class TwigExtensionTestController {
$this->t('<em>will be markup</em>'),
['#markup' => '<strong>will be rendered</strong>']
]
- );
+ ];
}
/**
* Menu callback for testing Twig functions in a Twig template.
*/
public function testFunctionRender() {
- return array('#theme' => 'twig_extension_test_function');
+ return ['#theme' => 'twig_extension_test_function'];
}
}
diff --git a/core/modules/system/tests/modules/twig_extension_test/twig_extension_test.module b/core/modules/system/tests/modules/twig_extension_test/twig_extension_test.module
index f55e619a781..eb69e34497d 100644
--- a/core/modules/system/tests/modules/twig_extension_test/twig_extension_test.module
+++ b/core/modules/system/tests/modules/twig_extension_test/twig_extension_test.module
@@ -9,14 +9,14 @@
* Implements hook_theme().
*/
function twig_extension_test_theme($existing, $type, $theme, $path) {
- return array(
- 'twig_extension_test_filter' => array(
- 'variables' => array('message' => NULL, 'safe_join_items' => NULL),
+ return [
+ 'twig_extension_test_filter' => [
+ 'variables' => ['message' => NULL, 'safe_join_items' => NULL],
'template' => 'twig_extension_test.filter',
- ),
- 'twig_extension_test_function' => array(
+ ],
+ 'twig_extension_test_function' => [
'render element' => 'element',
'template' => 'twig_extension_test.function',
- ),
- );
+ ],
+ ];
}
diff --git a/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php b/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php
index 7408ce8f472..8e1f69e7922 100644
--- a/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php
+++ b/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php
@@ -14,16 +14,16 @@ class TwigThemeTestController {
* Menu callback for testing PHP variables in a Twig template.
*/
public function phpVariablesRender() {
- return ['#markup' => \Drupal::theme()->render('twig_theme_test_php_variables', array())];
+ return ['#markup' => \Drupal::theme()->render('twig_theme_test_php_variables', [])];
}
/**
* Menu callback for testing translation blocks in a Twig template.
*/
public function transBlockRender() {
- return array(
+ return [
'#theme' => 'twig_theme_test_trans',
- );
+ ];
}
/**
@@ -40,9 +40,9 @@ class TwigThemeTestController {
* Renders for testing url_generator functions in a Twig template.
*/
public function urlGeneratorRender() {
- return array(
+ return [
'#theme' => 'twig_theme_test_url_generator',
- );
+ ];
}
/**
@@ -73,25 +73,25 @@ class TwigThemeTestController {
* Renders for testing file_url functions in a Twig template.
*/
public function fileUrlRender() {
- return array(
+ return [
'#theme' => 'twig_theme_test_file_url',
- );
+ ];
}
/**
* Renders for testing attach_library functions in a Twig template.
*/
public function attachLibraryRender() {
- return array(
+ return [
'#theme' => 'twig_theme_test_attach_library',
- );
+ ];
}
/**
* Menu callback for testing the Twig registry loader.
*/
public function registryLoaderRender() {
- return array('#theme' => 'twig_registry_loader_test');
+ return ['#theme' => 'twig_registry_loader_test'];
}
/**
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
index b3a75e5180c..a8b4086203a 100644
--- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
+++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
@@ -9,70 +9,70 @@
* Implements hook_theme().
*/
function twig_theme_test_theme($existing, $type, $theme, $path) {
- $items['twig_theme_test_filter'] = array(
- 'variables' => array('quote' => array(), 'attributes' => array()),
+ $items['twig_theme_test_filter'] = [
+ 'variables' => ['quote' => [], 'attributes' => []],
'template' => 'twig_theme_test.filter',
- );
- $items['twig_theme_test_php_variables'] = array(
+ ];
+ $items['twig_theme_test_php_variables'] = [
'template' => 'twig_theme_test.php_variables',
- );
- $items['twig_theme_test_trans'] = array(
- 'variables' => array(),
+ ];
+ $items['twig_theme_test_trans'] = [
+ 'variables' => [],
'template' => 'twig_theme_test.trans',
- );
- $items['twig_theme_test_placeholder_outside_trans'] = array(
- 'variables' => array('var' => ''),
+ ];
+ $items['twig_theme_test_placeholder_outside_trans'] = [
+ 'variables' => ['var' => ''],
'template' => 'twig_theme_test.placeholder_outside_trans',
- );
- $items['twig_namespace_test'] = array(
- 'variables' => array(),
+ ];
+ $items['twig_namespace_test'] = [
+ 'variables' => [],
'template' => 'twig_namespace_test',
- );
- $items['twig_registry_loader_test'] = array(
- 'variables' => array(),
- );
- $items['twig_registry_loader_test_include'] = array(
- 'variables' => array(),
- );
- $items['twig_registry_loader_test_extend'] = array(
- 'variables' => array(),
- );
- $items['twig_raw_test'] = array(
- 'variables' => array('script' => ''),
- );
- $items['twig_autoescape_test'] = array(
- 'variables' => array('script' => ''),
- );
- $items['twig_theme_test_url_generator'] = array(
- 'variables' => array(),
+ ];
+ $items['twig_registry_loader_test'] = [
+ 'variables' => [],
+ ];
+ $items['twig_registry_loader_test_include'] = [
+ 'variables' => [],
+ ];
+ $items['twig_registry_loader_test_extend'] = [
+ 'variables' => [],
+ ];
+ $items['twig_raw_test'] = [
+ 'variables' => ['script' => ''],
+ ];
+ $items['twig_autoescape_test'] = [
+ 'variables' => ['script' => ''],
+ ];
+ $items['twig_theme_test_url_generator'] = [
+ 'variables' => [],
'template' => 'twig_theme_test.url_generator',
- );
- $items['twig_theme_test_link_generator'] = array(
+ ];
+ $items['twig_theme_test_link_generator'] = [
'variables' => [
'test_url' => NULL,
'test_url_attribute' => NULL,
'attributes' => [],
],
'template' => 'twig_theme_test.link_generator',
- );
- $items['twig_theme_test_url_to_string'] = array(
- 'variables' => array('test_url' => NULL),
+ ];
+ $items['twig_theme_test_url_to_string'] = [
+ 'variables' => ['test_url' => NULL],
'template' => 'twig_theme_test.url_to_string',
- );
- $items['twig_theme_test_file_url'] = array(
- 'variables' => array(),
+ ];
+ $items['twig_theme_test_file_url'] = [
+ 'variables' => [],
'template' => 'twig_theme_test.file_url',
- );
- $items['twig_theme_test_attach_library'] = array(
- 'variables' => array(),
+ ];
+ $items['twig_theme_test_attach_library'] = [
+ 'variables' => [],
'template' => 'twig_theme_test.attach_library',
- );
- $items['twig_theme_test_renderable'] = array(
- 'variables' => array(
+ ];
+ $items['twig_theme_test_renderable'] = [
+ 'variables' => [
'renderable' => NULL,
- ),
+ ],
'template' => 'twig_theme_test.renderable',
- );
+ ];
return $items;
}
@@ -83,36 +83,36 @@ function _test_theme_twig_php_values() {
// Prefix each variable with "twig_" so that Twig doesn't get confused
// between a variable and a primitive. Arrays are not tested since they should
// be a Drupal render array.
- return array(
- 'twig_null' => array(
+ return [
+ 'twig_null' => [
'value' => NULL,
'expected' => '',
- ),
- 'twig_bool_false' => array(
+ ],
+ 'twig_bool_false' => [
'value' => FALSE,
'expected' => '',
- ),
- 'twig_bool_true' => array(
+ ],
+ 'twig_bool_true' => [
'value' => TRUE,
'expected' => '1',
- ),
- 'twig_int' => array(
+ ],
+ 'twig_int' => [
'value' => 1,
'expected' => '1',
- ),
- 'twig_int_0' => array(
+ ],
+ 'twig_int_0' => [
'value' => 0,
'expected' => '0',
- ),
- 'twig_float' => array(
+ ],
+ 'twig_float' => [
'value' => 122.34343,
'expected' => '122.34343',
- ),
- 'twig_string' => array(
+ ],
+ 'twig_string' => [
'value' => 'Hello world!',
'expected' => 'Hello world!',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php b/core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php
index b72ab1b91c7..e1c21c29c34 100644
--- a/core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php
+++ b/core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php
@@ -18,12 +18,12 @@ class UpdateScriptTestController extends ControllerBase {
// @todo Simplify with https://www.drupal.org/node/2548095
$base_url = str_replace('/update.php', '', $request->getBaseUrl());
$url = (new Url('system.db_update'))->setOption('base_url', $base_url);
- $build['main'] = array(
+ $build['main'] = [
'#type' => 'link',
'#title' => $this->t('Run database updates'),
'#url' => $url,
'#access' => $url->access($this->currentUser()),
- );
+ ];
return $build;
}
diff --git a/core/modules/system/tests/modules/update_script_test/update_script_test.install b/core/modules/system/tests/modules/update_script_test/update_script_test.install
index 0f1718d7d60..ce3874320dc 100644
--- a/core/modules/system/tests/modules/update_script_test/update_script_test.install
+++ b/core/modules/system/tests/modules/update_script_test/update_script_test.install
@@ -9,27 +9,27 @@
* Implements hook_requirements().
*/
function update_script_test_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if ($phase == 'update') {
// Set a requirements warning or error when the test requests it.
$requirement_type = \Drupal::config('update_script_test.settings')->get('requirement_type');
switch ($requirement_type) {
case REQUIREMENT_WARNING:
- $requirements['update_script_test'] = array(
+ $requirements['update_script_test'] = [
'title' => 'Update script test',
'value' => 'Warning',
'description' => 'This is a requirements warning provided by the update_script_test module.',
'severity' => REQUIREMENT_WARNING,
- );
+ ];
break;
case REQUIREMENT_ERROR:
- $requirements['update_script_test'] = array(
+ $requirements['update_script_test'] = [
'title' => 'Update script test',
'value' => 'Error',
'description' => 'This is a requirements error provided by the update_script_test module.',
'severity' => REQUIREMENT_ERROR,
- );
+ ];
break;
}
}
diff --git a/core/modules/system/tests/modules/update_test_1/update_test_1.install b/core/modules/system/tests/modules/update_test_1/update_test_1.install
index 7ef5d98adc9..1d632c713c5 100644
--- a/core/modules/system/tests/modules/update_test_1/update_test_1.install
+++ b/core/modules/system/tests/modules/update_test_1/update_test_1.install
@@ -18,21 +18,21 @@ function update_test_1_update_dependencies() {
// the correct array structure. Therefore, we use updates from the
// update_test_0 module (which will be installed first) that they will not
// get in the way of other tests.
- $dependencies['update_test_0'][8001] = array(
+ $dependencies['update_test_0'][8001] = [
// Compare to update_test_2_update_dependencies(), where the same
// update_test_0 module update function is forced to depend on an update
// function from a different module. This allows us to test that both
// dependencies are correctly recorded.
'update_test_1' => 8001,
- );
- $dependencies['update_test_0'][8002] = array(
+ ];
+ $dependencies['update_test_0'][8002] = [
// Compare to update_test_2_update_dependencies(), where the same
// update_test_0 module update function is forced to depend on a
// different update function within the same module. This allows us to
// test that only the dependency on the higher-numbered update function
// is recorded.
'update_test_1' => 8003,
- );
+ ];
return $dependencies;
}
diff --git a/core/modules/system/tests/modules/update_test_2/update_test_2.install b/core/modules/system/tests/modules/update_test_2/update_test_2.install
index 42027204fda..8818545c6a4 100644
--- a/core/modules/system/tests/modules/update_test_2/update_test_2.install
+++ b/core/modules/system/tests/modules/update_test_2/update_test_2.install
@@ -18,18 +18,18 @@ function update_test_2_update_dependencies() {
// 2. update_test_3_update_8001()
// 3. update_test_2_update_8002()
// 4. update_test_2_update_8003()
- $dependencies['update_test_2'][8002] = array(
+ $dependencies['update_test_2'][8002] = [
'update_test_3' => 8001,
- );
+ ];
// These are coordinated with the corresponding dependencies declared in
// update_test_1_update_dependencies().
- $dependencies['update_test_0'][8001] = array(
+ $dependencies['update_test_0'][8001] = [
'update_test_2' => 8002,
- );
- $dependencies['update_test_0'][8002] = array(
+ ];
+ $dependencies['update_test_0'][8002] = [
'update_test_1' => 8002,
- );
+ ];
return $dependencies;
}
diff --git a/core/modules/system/tests/modules/update_test_3/update_test_3.install b/core/modules/system/tests/modules/update_test_3/update_test_3.install
index ae2da4b09a2..6a837b69c8b 100644
--- a/core/modules/system/tests/modules/update_test_3/update_test_3.install
+++ b/core/modules/system/tests/modules/update_test_3/update_test_3.install
@@ -11,9 +11,9 @@
* @see update_test_2_update_dependencies()
*/
function update_test_3_update_dependencies() {
- $dependencies['update_test_3'][8001] = array(
+ $dependencies['update_test_3'][8001] = [
'update_test_2' => 8001,
- );
+ ];
return $dependencies;
}
diff --git a/core/modules/system/tests/modules/url_alter_test/src/PathProcessor.php b/core/modules/system/tests/modules/url_alter_test/src/PathProcessor.php
index b59fe4ccf30..3709907dcde 100644
--- a/core/modules/system/tests/modules/url_alter_test/src/PathProcessor.php
+++ b/core/modules/system/tests/modules/url_alter_test/src/PathProcessor.php
@@ -16,7 +16,7 @@ class PathProcessor implements InboundPathProcessorInterface {
public function processInbound($path, Request $request) {
if (preg_match('!^/user/([^/]+)(/.*)?!', $path, $matches)) {
if ($account = user_load_by_name($matches[1])) {
- $matches += array(2 => '');
+ $matches += [2 => ''];
$path = '/user/' . $account->id() . $matches[2];
}
}
diff --git a/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php b/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
index b3ba5688509..9a89df9b821 100644
--- a/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
+++ b/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
@@ -20,7 +20,7 @@ class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathPr
// Rewrite user/username to user/uid.
if (preg_match('!^/user/([^/]+)(/.*)?!', $path, $matches)) {
if ($account = user_load_by_name($matches[1])) {
- $matches += array(2 => '');
+ $matches += [2 => ''];
$path = '/user/' . $account->id() . $matches[2];
}
}
@@ -37,11 +37,11 @@ class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathPr
/**
* {@inheritdoc}
*/
- public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
// Rewrite user/uid to user/username.
if (preg_match('!^/user/([0-9]+)(/.*)?!', $path, $matches)) {
if ($account = User::load($matches[1])) {
- $matches += array(2 => '');
+ $matches += [2 => ''];
$path = '/user/' . $account->getUsername() . $matches[2];
if ($bubbleable_metadata) {
$bubbleable_metadata->addCacheTags($account->getCacheTags());
diff --git a/core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php b/core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php
index 1b0f31a7488..0931d65de12 100644
--- a/core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php
+++ b/core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php
@@ -16,7 +16,7 @@ class DrupalSetMessageTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('system_test');
+ public static $modules = ['system_test'];
/**
* Tests drupal_set_message().
diff --git a/core/modules/system/tests/src/Functional/Cache/ClearTest.php b/core/modules/system/tests/src/Functional/Cache/ClearTest.php
index 4b339874159..fd9641c59b9 100644
--- a/core/modules/system/tests/src/Functional/Cache/ClearTest.php
+++ b/core/modules/system/tests/src/Functional/Cache/ClearTest.php
@@ -35,7 +35,7 @@ class ClearTest extends CacheTestBase {
foreach ($bins as $bin => $cache_backend) {
$cid = 'test_cid_clear' . $bin;
- $this->assertFalse($this->checkCacheExists($cid, $this->defaultValue, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin)));
+ $this->assertFalse($this->checkCacheExists($cid, $this->defaultValue, $bin), format_string('All cache entries removed from @bin.', ['@bin' => $bin]));
}
}
diff --git a/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php
index de2b4194d9a..39a514fa3b2 100644
--- a/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php
+++ b/core/modules/system/tests/src/Functional/Cache/PageCacheTagsTestBase.php
@@ -44,12 +44,12 @@ abstract class PageCacheTagsTestBase extends BrowserTestBase {
*/
protected function verifyPageCache(Url $url, $hit_or_miss, $tags = FALSE) {
$this->drupalGet($url);
- $message = SafeMarkup::format('Page cache @hit_or_miss for %path.', array('@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()));
+ $message = SafeMarkup::format('Page cache @hit_or_miss for %path.', ['@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()]);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message);
if ($hit_or_miss === 'HIT' && is_array($tags)) {
$absolute_url = $url->setAbsolute()->toString();
- $cid_parts = array($absolute_url, 'html');
+ $cid_parts = [$absolute_url, 'html'];
$cid = implode(':', $cid_parts);
$cache_entry = \Drupal::cache('render')->get($cid);
sort($cache_entry->tags);
diff --git a/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php b/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php
index 8ac27b0fc0f..cc23f4895b7 100644
--- a/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php
+++ b/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php
@@ -16,7 +16,7 @@ class DrupalDateTimeTest extends BrowserTestBase {
/**
* Set up required modules.
*/
- public static $modules = array();
+ public static $modules = [];
/**
* Test setup.
@@ -30,11 +30,11 @@ class DrupalDateTimeTest extends BrowserTestBase {
* Test that the AJAX Timezone Callback can deal with various formats.
*/
public function testSystemTimezone() {
- $options = array(
- 'query' => array(
+ $options = [
+ 'query' => [
'date' => 'Tue+Sep+17+2013+21%3A35%3A31+GMT%2B0100+(BST)#',
- )
- );
+ ]
+ ];
// Query the AJAX Timezone Callback with a long-format date.
$response = $this->drupalGet('system/timezone/BST/3600/1', $options);
$this->assertEqual($response, '"Europe\/London"', 'Timezone AJAX callback successfully identifies and responds to a long-format date.');
@@ -80,11 +80,11 @@ class DrupalDateTimeTest extends BrowserTestBase {
// Create user.
$this->config('system.date')->set('timezone.user.configurable', 1)->save();
- $test_user = $this->drupalCreateUser(array());
+ $test_user = $this->drupalCreateUser([]);
$this->drupalLogin($test_user);
// Set up the user with a different timezone than the site.
- $edit = array('mail' => $test_user->getEmail(), 'timezone' => 'Asia/Manila');
+ $edit = ['mail' => $test_user->getEmail(), 'timezone' => 'Asia/Manila'];
$this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save'));
// Reload the user and reset the timezone in AccountProxy::setAccount().
@@ -109,7 +109,7 @@ class DrupalDateTimeTest extends BrowserTestBase {
$this->assertEqual($date->format('Y/m/d H:i:s e'), '1972/10/11 12:25:21 UTC', 'Date has default UTC time zone and correct date/time.');
// Verify that the format method can override the time zone.
- $this->assertEqual($date->format('Y/m/d H:i:s e', array('timezone' => 'America/New_York')), '1972/10/11 08:25:21 America/New_York', 'Date displayed overidden time zone and correct date/time');
+ $this->assertEqual($date->format('Y/m/d H:i:s e', ['timezone' => 'America/New_York']), '1972/10/11 08:25:21 America/New_York', 'Date displayed overidden time zone and correct date/time');
// Verify that the date format method still displays the default time zone
// for the date object.
diff --git a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php
index 49817ccf6b6..82e2e9249e0 100644
--- a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php
+++ b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php
@@ -20,7 +20,7 @@ class ContentNegotiationTest extends BrowserTestBase {
* @see https://www.drupal.org/node/1716790
*/
function testBogusAcceptHeader() {
- $tests = array(
+ $tests = [
// See https://bugs.webkit.org/show_bug.cgi?id=27267.
'Firefox 3.5 (2009)' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'IE8 (2009)' => 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*',
@@ -34,9 +34,9 @@ class ContentNegotiationTest extends BrowserTestBase {
'Safari (2010), iOS 4.2.1 (2012)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Android #1 (2012)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Android #2 (2012)' => 'text/xml,text/html,application/xhtml+xml,image/png,text/plain,*/*;q=0.8',
- );
+ ];
foreach ($tests as $case => $header) {
- $this->drupalGet('', array(), array('Accept: ' . $header));
+ $this->drupalGet('', [], ['Accept: ' . $header]);
$this->assertNoText('Unsupported Media Type', '"Unsupported Media Type" not found for ' . $case);
$this->assertText(t('Log in'), '"Log in" found for ' . $case);
}
diff --git a/core/modules/system/tests/src/Functional/Entity/ConfigEntityImportTest.php b/core/modules/system/tests/src/Functional/Entity/ConfigEntityImportTest.php
index c9243eae2d8..6c5a9d64c59 100644
--- a/core/modules/system/tests/src/Functional/Entity/ConfigEntityImportTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/ConfigEntityImportTest.php
@@ -21,7 +21,7 @@ class ConfigEntityImportTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('action', 'block', 'filter', 'image', 'search', 'search_extra_type');
+ public static $modules = ['action', 'block', 'filter', 'image', 'search', 'search_extra_type'];
/**
* {@inheritdoc}
@@ -48,10 +48,10 @@ class ConfigEntityImportTest extends BrowserTestBase {
protected function doActionUpdate() {
// Create a test action with a known label.
$name = 'system.action.apple';
- $entity = Action::create(array(
+ $entity = Action::create([
'id' => 'apple',
'plugin' => 'action_message_action',
- ));
+ ]);
$entity->save();
$this->checkSinglePluginConfigSync($entity, 'configuration', 'message', '');
@@ -69,10 +69,10 @@ class ConfigEntityImportTest extends BrowserTestBase {
protected function doBlockUpdate() {
// Create a test block with a known label.
$name = 'block.block.apple';
- $block = $this->drupalPlaceBlock('system_powered_by_block', array(
+ $block = $this->drupalPlaceBlock('system_powered_by_block', [
'id' => 'apple',
'label' => 'Red Delicious',
- ));
+ ]);
$this->checkSinglePluginConfigSync($block, 'settings', 'label', 'Red Delicious');
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php
index 541a412733d..1476dfafec6 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php
@@ -68,18 +68,18 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
if ($this->entity->getEntityType()->get('field_ui_base_route')) {
// Add field, so we can modify the field storage and field entities to
// verify that changes to those indeed clear cache tags.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'configurable_field',
'entity_type' => $this->entity->getEntityTypeId(),
'type' => 'test_field',
- 'settings' => array(),
- ))->save();
+ 'settings' => [],
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entity->getEntityTypeId(),
'bundle' => $this->entity->bundle(),
'field_name' => 'configurable_field',
'label' => 'Configurable field',
- 'settings' => array(),
+ 'settings' => [],
])->save();
// Reload the entity now that a new field has been added to it.
@@ -110,11 +110,11 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
* @see \Drupal\simpletest\TestBase::getInfo()
*/
protected static function generateStandardizedInfo($entity_type_label, $group) {
- return array(
+ return [
'name' => "$entity_type_label entity cache tags",
'description' => "Test the $entity_type_label entity's cache tags.",
'group' => $group,
- );
+ ];
}
/**
@@ -170,7 +170,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
* @see \Drupal\system\Tests\Entity\EntityCacheTagsTestBase::createEntity()
*/
protected function getAdditionalCacheTagsForEntity(EntityInterface $entity) {
- return array();
+ return [];
}
/**
@@ -205,7 +205,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
protected function selectViewMode($entity_type) {
$view_modes = \Drupal::entityManager()
->getStorage('entity_view_mode')
- ->loadByProperties(array('targetEntityType' => $entity_type));
+ ->loadByProperties(['targetEntityType' => $entity_type]);
if (empty($view_modes)) {
return 'default';
@@ -241,46 +241,46 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
// Add a field of the given type to the given entity type's "foo" bundle.
$field_name = $referenced_entity->getEntityTypeId() . '_reference';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'type' => 'entity_reference',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- 'settings' => array(
+ 'settings' => [
'target_type' => $referenced_entity->getEntityTypeId(),
- ),
- ))->save();
+ ],
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
- 'target_bundles' => array(
+ 'handler_settings' => [
+ 'target_bundles' => [
$referenced_entity->bundle() => $referenced_entity->bundle(),
- ),
- 'sort' => array('field' => '_none'),
+ ],
+ 'sort' => ['field' => '_none'],
'auto_create' => FALSE,
- ),
- ),
+ ],
+ ],
])->save();
if (!$this->entity->getEntityType()->hasHandlerClass('view_builder')) {
entity_get_display($entity_type, $bundle, 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
else {
$referenced_entity_view_mode = $this->selectViewMode($this->entity->getEntityTypeId());
entity_get_display($entity_type, $bundle, 'full')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_entity_view',
- 'settings' => array(
+ 'settings' => [
'view_mode' => $referenced_entity_view_mode,
- ),
- ))
+ ],
+ ])
->save();
}
@@ -288,28 +288,28 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
$label_key = \Drupal::entityManager()->getDefinition($entity_type)->getKey('label');
$referencing_entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
$label_key => 'Referencing ' . $entity_type,
'status' => 1,
'type' => $bundle,
- $field_name => array('target_id' => $referenced_entity->id()),
- ));
+ $field_name => ['target_id' => $referenced_entity->id()],
+ ]);
$referencing_entity->save();
// Create an entity that does not reference the entity being tested.
$non_referencing_entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
$label_key => 'Non-referencing ' . $entity_type,
'status' => 1,
'type' => $bundle,
- ));
+ ]);
$non_referencing_entity->save();
- return array(
+ return [
$referencing_entity,
$non_referencing_entity,
- );
+ ];
}
/**
@@ -350,7 +350,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
$page_cache_tags_referencing_entity = in_array('user.permissions', $this->getAccessCacheContextsForEntity($this->referencingEntity)) ? ['config:user.role.anonymous'] : [];
- $view_cache_tag = array();
+ $view_cache_tag = [];
if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) {
$view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)
->getCacheTags();
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php b/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
index 6d70760e2dd..94225f4e97d 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
@@ -16,7 +16,7 @@ class EntityListBuilderTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('entity_test');
+ public static $modules = ['entity_test'];
/**
* {@inheritdoc}
@@ -25,9 +25,9 @@ class EntityListBuilderTest extends BrowserTestBase {
parent::setUp();
// Create and log in user.
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'administer entity_test content',
- ));
+ ]);
$this->drupalLogin($this->webUser);
}
@@ -37,7 +37,7 @@ class EntityListBuilderTest extends BrowserTestBase {
public function testPager() {
// Create 51 test entities.
for ($i = 1; $i < 52; $i++) {
- EntityTest::create(array('name' => 'Test entity ' . $i))->save();
+ EntityTest::create(['name' => 'Test entity ' . $i])->save();
}
// Load the listing page.
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php b/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php
index 3919ad1d4a1..b020f42870c 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php
@@ -16,13 +16,13 @@ class EntityOperationsTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('entity_test');
+ public static $modules = ['entity_test'];
protected function setUp() {
parent::setUp();
// Create and log in user.
- $this->drupalLogin($this->drupalCreateUser(array('administer permissions')));
+ $this->drupalLogin($this->drupalCreateUser(['administer permissions']));
}
/**
@@ -36,7 +36,7 @@ class EntityOperationsTest extends BrowserTestBase {
$roles = user_roles();
foreach ($roles as $role) {
$this->assertLinkByHref($role->url() . '/test_operation');
- $this->assertLink(format_string('Test Operation: @label', array('@label' => $role->label())));
+ $this->assertLink(format_string('Test Operation: @label', ['@label' => $role->label()]));
}
}
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php b/core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
index b01d267469f..df33102811f 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
@@ -26,13 +26,13 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment');
+ public static $modules = ['node', 'comment'];
protected function setUp() {
parent::setUp();
// Create an Article node type.
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
/**
@@ -50,10 +50,10 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
foreach ($tests as $test) {
foreach ($test['arguments'] as $arguments) {
- $result = call_user_func_array(array($handler, 'getReferenceableEntities'), $arguments);
- $this->assertEqual($result, $test['result'], format_string('Valid result set returned by @handler.', array('@handler' => $handler_name)));
+ $result = call_user_func_array([$handler, 'getReferenceableEntities'], $arguments);
+ $this->assertEqual($result, $test['result'], format_string('Valid result set returned by @handler.', ['@handler' => $handler_name]));
- $result = call_user_func_array(array($handler, 'countReferenceableEntities'), $arguments);
+ $result = call_user_func_array([$handler, 'countReferenceableEntities'], $arguments);
if (!empty($test['result'])) {
$bundle = key($test['result']);
$count = count($test['result'][$bundle]);
@@ -62,7 +62,7 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
$count = 0;
}
- $this->assertEqual($result, $count, format_string('Valid count returned by @handler.', array('@handler' => $handler_name)));
+ $this->assertEqual($result, $count, format_string('Valid count returned by @handler.', ['@handler' => $handler_name]));
}
}
}
@@ -71,39 +71,39 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
* Test the node-specific overrides of the entity handler.
*/
public function testNodeHandler() {
- $selection_options = array(
+ $selection_options = [
'target_type' => 'node',
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
'target_bundles' => NULL,
- ),
- );
+ ],
+ ];
// Build a set of test data.
// Titles contain HTML-special characters to test escaping.
- $node_values = array(
- 'published1' => array(
+ $node_values = [
+ 'published1' => [
'type' => 'article',
'status' => NodeInterface::PUBLISHED,
'title' => 'Node published1 (<&>)',
'uid' => 1,
- ),
- 'published2' => array(
+ ],
+ 'published2' => [
'type' => 'article',
'status' => NodeInterface::PUBLISHED,
'title' => 'Node published2 (<&>)',
'uid' => 1,
- ),
- 'unpublished' => array(
+ ],
+ 'unpublished' => [
'type' => 'article',
'status' => NodeInterface::NOT_PUBLISHED,
'title' => 'Node unpublished (<&>)',
'uid' => 1,
- ),
- );
+ ],
+ ];
- $nodes = array();
- $node_labels = array();
+ $nodes = [];
+ $node_labels = [];
foreach ($node_values as $key => $values) {
$node = Node::create($values);
$node->save();
@@ -112,84 +112,84 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
}
// Test as a non-admin.
- $normal_user = $this->drupalCreateUser(array('access content'));
+ $normal_user = $this->drupalCreateUser(['access content']);
\Drupal::currentUser()->setAccount($normal_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published1']->id() => $node_labels['published1'],
$nodes['published2']->id() => $node_labels['published2'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('published1', 'CONTAINS'),
- array('Published1', 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['published1', 'CONTAINS'],
+ ['Published1', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published1']->id() => $node_labels['published1'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('published2', 'CONTAINS'),
- array('Published2', 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['published2', 'CONTAINS'],
+ ['Published2', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published2']->id() => $node_labels['published2'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('invalid node', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- array(
- 'arguments' => array(
- array('Node unpublished', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['invalid node', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ [
+ 'arguments' => [
+ ['Node unpublished', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Node handler');
// Test as an admin.
- $admin_user = $this->drupalCreateUser(array('access content', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'bypass node access']);
\Drupal::currentUser()->setAccount($admin_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published1']->id() => $node_labels['published1'],
$nodes['published2']->id() => $node_labels['published2'],
$nodes['unpublished']->id() => $node_labels['unpublished'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('Node unpublished', 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['Node unpublished', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['unpublished']->id() => $node_labels['unpublished'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Node handler (admin)');
}
@@ -197,39 +197,39 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
* Test the user-specific overrides of the entity handler.
*/
public function testUserHandler() {
- $selection_options = array(
+ $selection_options = [
'target_type' => 'user',
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
'target_bundles' => NULL,
'include_anonymous' => TRUE,
- ),
- );
+ ],
+ ];
// Build a set of test data.
- $user_values = array(
+ $user_values = [
'anonymous' => User::load(0),
'admin' => User::load(1),
- 'non_admin' => array(
+ 'non_admin' => [
'name' => 'non_admin <&>',
'mail' => 'non_admin@example.com',
- 'roles' => array(),
+ 'roles' => [],
'pass' => user_password(),
'status' => 1,
- ),
- 'blocked' => array(
+ ],
+ 'blocked' => [
'name' => 'blocked <&>',
'mail' => 'blocked@example.com',
- 'roles' => array(),
+ 'roles' => [],
'pass' => user_password(),
'status' => 0,
- ),
- );
+ ],
+ ];
$user_values['anonymous']->name = $this->config('user.settings')->get('anonymous');
- $users = array();
+ $users = [];
- $user_labels = array();
+ $user_labels = [];
foreach ($user_values as $key => $values) {
if (is_array($values)) {
$account = User::create($values);
@@ -244,113 +244,113 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
// Test as a non-admin.
\Drupal::currentUser()->setAccount($users['non_admin']);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['admin']->id() => $user_labels['admin'],
$users['non_admin']->id() => $user_labels['non_admin'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('non_admin', 'CONTAINS'),
- array('NON_ADMIN', 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['non_admin', 'CONTAINS'],
+ ['NON_ADMIN', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['non_admin']->id() => $user_labels['non_admin'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('invalid user', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- array(
- 'arguments' => array(
- array('blocked', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['invalid user', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ [
+ 'arguments' => [
+ ['blocked', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler');
\Drupal::currentUser()->setAccount($users['admin']);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['anonymous']->id() => $user_labels['anonymous'],
$users['admin']->id() => $user_labels['admin'],
$users['non_admin']->id() => $user_labels['non_admin'],
$users['blocked']->id() => $user_labels['blocked'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('blocked', 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['blocked', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['blocked']->id() => $user_labels['blocked'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('Anonymous', 'CONTAINS'),
- array('anonymous', 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['Anonymous', 'CONTAINS'],
+ ['anonymous', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['anonymous']->id() => $user_labels['anonymous'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (admin)');
// Test the 'include_anonymous' option.
$selection_options['handler_settings']['include_anonymous'] = FALSE;
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array('Anonymous', 'CONTAINS'),
- array('anonymous', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ ['Anonymous', 'CONTAINS'],
+ ['anonymous', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (does not include anonymous)');
// Check that the Anonymous user is not included in the results when no
// label matching is done, for example when using the 'options_select'
// widget.
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL),
- ),
- 'result' => array(
- 'user' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL],
+ ],
+ 'result' => [
+ 'user' => [
$users['admin']->id() => $user_labels['admin'],
$users['non_admin']->id() => $user_labels['non_admin'],
$users['blocked']->id() => $user_labels['blocked'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (does not include anonymous)');
}
@@ -358,30 +358,30 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
* Test the comment-specific overrides of the entity handler.
*/
public function testCommentHandler() {
- $selection_options = array(
+ $selection_options = [
'target_type' => 'comment',
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
'target_bundles' => NULL,
- ),
- );
+ ],
+ ];
// Build a set of test data.
- $node_values = array(
- 'published' => array(
+ $node_values = [
+ 'published' => [
'type' => 'article',
'status' => 1,
'title' => 'Node published',
'uid' => 1,
- ),
- 'unpublished' => array(
+ ],
+ 'unpublished' => [
'type' => 'article',
'status' => 0,
'title' => 'Node unpublished',
'uid' => 1,
- ),
- );
- $nodes = array();
+ ],
+ ];
+ $nodes = [];
foreach ($node_values as $key => $values) {
$node = Node::create($values);
$node->save();
@@ -391,8 +391,8 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
// Create comment field on article.
$this->addDefaultCommentField('node', 'article');
- $comment_values = array(
- 'published_published' => array(
+ $comment_values = [
+ 'published_published' => [
'entity_id' => $nodes['published']->id(),
'entity_type' => 'node',
'field_name' => 'comment',
@@ -402,8 +402,8 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
'status' => CommentInterface::PUBLISHED,
'subject' => 'Comment Published <&>',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ),
- 'published_unpublished' => array(
+ ],
+ 'published_unpublished' => [
'entity_id' => $nodes['published']->id(),
'entity_type' => 'node',
'field_name' => 'comment',
@@ -413,8 +413,8 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
'status' => CommentInterface::NOT_PUBLISHED,
'subject' => 'Comment Unpublished <&>',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ),
- 'unpublished_published' => array(
+ ],
+ 'unpublished_published' => [
'entity_id' => $nodes['unpublished']->id(),
'entity_type' => 'node',
'field_name' => 'comment',
@@ -424,11 +424,11 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
'status' => CommentInterface::NOT_PUBLISHED,
'subject' => 'Comment Published on Unpublished node <&>',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ),
- );
+ ],
+ ];
- $comments = array();
- $comment_labels = array();
+ $comments = [];
+ $comment_labels = [];
foreach ($comment_values as $key => $values) {
$comment = Comment::create($values);
$comment->save();
@@ -437,79 +437,79 @@ class EntityReferenceSelectionAccessTest extends BrowserTestBase {
}
// Test as a non-admin.
- $normal_user = $this->drupalCreateUser(array('access content', 'access comments'));
+ $normal_user = $this->drupalCreateUser(['access content', 'access comments']);
\Drupal::currentUser()->setAccount($normal_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('Published', 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['Published', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('invalid comment', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- array(
- 'arguments' => array(
- array('Comment Unpublished', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['invalid comment', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ [
+ 'arguments' => [
+ ['Comment Unpublished', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Comment handler');
// Test as a comment admin.
- $admin_user = $this->drupalCreateUser(array('access content', 'access comments', 'administer comments'));
+ $admin_user = $this->drupalCreateUser(['access content', 'access comments', 'administer comments']);
\Drupal::currentUser()->setAccount($admin_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
$comments['published_unpublished']->cid->value => $comment_labels['published_unpublished'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Comment handler (comment admin)');
// Test as a node and comment admin.
- $admin_user = $this->drupalCreateUser(array('access content', 'access comments', 'administer comments', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'access comments', 'administer comments', 'bypass node access']);
\Drupal::currentUser()->setAccount($admin_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
$comments['published_unpublished']->cid->value => $comment_labels['published_unpublished'],
$comments['unpublished_published']->cid->value => $comment_labels['unpublished_published'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Comment handler (comment + node admin)');
}
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
index ccc48df524f..38db0e9dc0e 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
@@ -19,7 +19,7 @@ class EntityRevisionsTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('entity_test', 'language');
+ public static $modules = ['entity_test', 'language'];
/**
* A user with permission to administer entity_test content.
@@ -32,10 +32,10 @@ class EntityRevisionsTest extends BrowserTestBase {
parent::setUp();
// Create and log in user.
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'administer entity_test content',
'view test entity',
- ));
+ ]);
$this->drupalLogin($this->webUser);
// Enable an additional language.
@@ -64,17 +64,17 @@ class EntityRevisionsTest extends BrowserTestBase {
// Create initial entity.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => 'foo',
'user_id' => $this->webUser->id(),
- ));
+ ]);
$entity->field_test_text->value = 'bar';
$entity->save();
- $names = array();
- $texts = array();
- $created = array();
- $revision_ids = array();
+ $names = [];
+ $texts = [];
+ $created = [];
+ $revision_ids = [];
// Create three revisions.
$revision_count = 3;
@@ -93,9 +93,9 @@ class EntityRevisionsTest extends BrowserTestBase {
$revision_ids[] = $entity->revision_id->value;
// Check that the fields and properties contain new content.
- $this->assertTrue($entity->revision_id->value > $legacy_revision_id, format_string('%entity_type: Revision ID changed.', array('%entity_type' => $entity_type)));
- $this->assertNotEqual($entity->name->value, $legacy_name, format_string('%entity_type: Name changed.', array('%entity_type' => $entity_type)));
- $this->assertNotEqual($entity->field_test_text->value, $legacy_text, format_string('%entity_type: Text changed.', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity->revision_id->value > $legacy_revision_id, format_string('%entity_type: Revision ID changed.', ['%entity_type' => $entity_type]));
+ $this->assertNotEqual($entity->name->value, $legacy_name, format_string('%entity_type: Name changed.', ['%entity_type' => $entity_type]));
+ $this->assertNotEqual($entity->field_test_text->value, $legacy_text, format_string('%entity_type: Text changed.', ['%entity_type' => $entity_type]));
}
$storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
@@ -104,13 +104,13 @@ class EntityRevisionsTest extends BrowserTestBase {
$entity_revision = $storage->loadRevision($revision_ids[$i]);
// Check if properties and fields contain the revision specific content.
- $this->assertEqual($entity_revision->revision_id->value, $revision_ids[$i], format_string('%entity_type: Revision ID matches.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity_revision->name->value, $names[$i], format_string('%entity_type: Name matches.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity_revision->field_test_text->value, $texts[$i], format_string('%entity_type: Text matches.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity_revision->revision_id->value, $revision_ids[$i], format_string('%entity_type: Revision ID matches.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity_revision->name->value, $names[$i], format_string('%entity_type: Name matches.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity_revision->field_test_text->value, $texts[$i], format_string('%entity_type: Text matches.', ['%entity_type' => $entity_type]));
// Check non-revisioned values are loaded.
- $this->assertTrue(isset($entity_revision->created->value), format_string('%entity_type: Non-revisioned field is loaded.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity_revision->created->value, $created[2], format_string('%entity_type: Non-revisioned field value is the same between revisions.', array('%entity_type' => $entity_type)));
+ $this->assertTrue(isset($entity_revision->created->value), format_string('%entity_type: Non-revisioned field is loaded.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity_revision->created->value, $created[2], format_string('%entity_type: Non-revisioned field value is the same between revisions.', ['%entity_type' => $entity_type]));
}
// Confirm the correct revision text appears in the edit form.
@@ -118,8 +118,8 @@ class EntityRevisionsTest extends BrowserTestBase {
->getStorage($entity_type)
->load($entity->id->value);
$this->drupalGet($entity_type . '/manage/' . $entity->id->value . '/edit');
- $this->assertFieldById('edit-name-0-value', $entity->name->value, format_string('%entity_type: Name matches in UI.', array('%entity_type' => $entity_type)));
- $this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, format_string('%entity_type: Text matches in UI.', array('%entity_type' => $entity_type)));
+ $this->assertFieldById('edit-name-0-value', $entity->name->value, format_string('%entity_type: Name matches in UI.', ['%entity_type' => $entity_type]));
+ $this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, format_string('%entity_type: Text matches in UI.', ['%entity_type' => $entity_type]));
}
/**
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
index 871892955dc..11a9b2e4a9e 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
@@ -17,14 +17,14 @@ class EntityViewControllerTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('entity_test');
+ public static $modules = ['entity_test'];
/**
* Array of test entities.
*
* @var array
*/
- protected $entities = array();
+ protected $entities = [];
protected function setUp() {
parent::setUp();
@@ -86,7 +86,7 @@ class EntityViewControllerTest extends BrowserTestBase {
public function testFieldItemAttributes() {
// Make sure the test field will be rendered.
entity_get_display('entity_test', 'entity_test', 'default')
- ->setComponent('field_test_text', array('type' => 'text_default'))
+ ->setComponent('field_test_text', ['type' => 'text_default'])
->save();
// Create an entity and save test value in field_test_text.
@@ -98,24 +98,24 @@ class EntityViewControllerTest extends BrowserTestBase {
// Browse to the entity and verify that the attribute is rendered in the
// field item HTML markup.
$this->drupalGet('entity_test/' . $entity->id());
- $xpath = $this->xpath('//div[@data-field-item-attr="foobar"]/p[text()=:value]', array(':value' => $test_value));
+ $xpath = $this->xpath('//div[@data-field-item-attr="foobar"]/p[text()=:value]', [':value' => $test_value]);
$this->assertTrue($xpath, 'The field item attribute has been found in the rendered output of the field.');
// Enable the RDF module to ensure that two modules can add attributes to
// the same field item.
- \Drupal::service('module_installer')->install(array('rdf'));
+ \Drupal::service('module_installer')->install(['rdf']);
$this->resetAll();
// Set an RDF mapping for the field_test_text field. This RDF mapping will
// be turned into RDFa attributes in the field item output.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping('field_test_text', array(
- 'properties' => array('schema:text'),
- ))->save();
+ $mapping->setFieldMapping('field_test_text', [
+ 'properties' => ['schema:text'],
+ ])->save();
// Browse to the entity and verify that the attributes from both modules
// are rendered in the field item HTML markup.
$this->drupalGet('entity_test/' . $entity->id());
- $xpath = $this->xpath('//div[@data-field-item-attr="foobar" and @property="schema:text"]/p[text()=:value]', array(':value' => $test_value));
+ $xpath = $this->xpath('//div[@data-field-item-attr="foobar" and @property="schema:text"]/p[text()=:value]', [':value' => $test_value]);
$this->assertTrue($xpath, 'The field item attributes from both modules have been found in the rendered output of the field.');
}
@@ -139,10 +139,10 @@ class EntityViewControllerTest extends BrowserTestBase {
* The created entity.
*/
protected function createTestEntity($entity_type) {
- $data = array(
+ $data = [
'bundle' => $entity_type,
'name' => $this->randomMachineName(),
- );
+ ];
return $this->container->get('entity.manager')->getStorage($entity_type)->create($data);
}
diff --git a/core/modules/system/tests/src/Functional/File/ConfigTest.php b/core/modules/system/tests/src/Functional/File/ConfigTest.php
index ea73322df2e..9ac71dc500b 100644
--- a/core/modules/system/tests/src/Functional/File/ConfigTest.php
+++ b/core/modules/system/tests/src/Functional/File/ConfigTest.php
@@ -13,7 +13,7 @@ class ConfigTest extends BrowserTestBase {
protected function setUp(){
parent::setUp();
- $this->drupalLogin ($this->drupalCreateUser(array('administer site configuration')));
+ $this->drupalLogin ($this->drupalCreateUser(['administer site configuration']));
}
/**
@@ -26,10 +26,10 @@ class ConfigTest extends BrowserTestBase {
// The respective directories are created automatically
// upon form submission.
$file_path = $this->publicFilesDirectory;
- $fields = array(
+ $fields = [
'file_temporary_path' => $file_path . '/file_config_page_test/temporary',
'file_default_scheme' => 'private',
- );
+ ];
// Check that public and private can be selected as default scheme.
$this->assertText('Public local files served by the webserver.');
@@ -43,10 +43,10 @@ class ConfigTest extends BrowserTestBase {
// Remove the private path, rebuild the container and verify that private
// can no longer be selected in the UI.
- $settings['settings']['file_private_path'] = (object) array(
+ $settings['settings']['file_private_path'] = (object) [
'value' => '',
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
$this->rebuildContainer();
diff --git a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php
index 985e21a5948..85d624d76b8 100644
--- a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php
+++ b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php
@@ -20,20 +20,20 @@ class FileTransferTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $this->testConnection = TestFileTransfer::factory(\Drupal::root(), array('hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port));
+ $this->testConnection = TestFileTransfer::factory(\Drupal::root(), ['hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port]);
}
function _getFakeModuleFiles() {
- $files = array(
+ $files = [
'fake.module',
'fake.info.yml',
- 'theme' => array(
+ 'theme' => [
'fake.html.twig'
- ),
- 'inc' => array(
+ ],
+ 'inc' => [
'fake.inc'
- )
- );
+ ]
+ ];
return $files;
}
@@ -41,7 +41,7 @@ class FileTransferTest extends BrowserTestBase {
$location = 'temporary://fake';
if (is_dir($location)) {
$ret = 0;
- $output = array();
+ $output = [];
exec('rm -Rf ' . escapeshellarg($location), $output, $ret);
if ($ret != 0) {
throw new Exception('Error removing fake module directory.');
@@ -53,7 +53,7 @@ class FileTransferTest extends BrowserTestBase {
return $location;
}
- function _writeDirectory($base, $files = array()) {
+ function _writeDirectory($base, $files = []) {
mkdir($base);
foreach ($files as $key => $file) {
if (is_array($file)) {
diff --git a/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php b/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php
index 6d877b279dc..e645f4e4fbf 100644
--- a/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php
+++ b/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php
@@ -7,7 +7,7 @@ namespace Drupal\Tests\system\Functional\FileTransfer;
*/
class MockTestConnection {
- protected $commandsRun = array();
+ protected $commandsRun = [];
public $connectionString;
function run($cmd) {
@@ -16,7 +16,7 @@ class MockTestConnection {
function flushCommands() {
$out = $this->commandsRun;
- $this->commandsRun = array();
+ $this->commandsRun = [];
return $out;
}
diff --git a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
index 04e282f9146..e02ee98e4b8 100644
--- a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
+++ b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
@@ -46,7 +46,7 @@ class TestFileTransfer extends FileTransfer {
function removeFileJailed($destination) {
if (!ftp_delete($this->connection, $item)) {
- throw new FileTransferException('Unable to remove to file @file.', NULL, array('@file' => $item));
+ throw new FileTransferException('Unable to remove to file @file.', NULL, ['@file' => $item]);
}
}
diff --git a/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php b/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php
index 0684c3d6cda..1a92893c392 100644
--- a/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php
@@ -16,7 +16,7 @@ class ElementsAccessTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
/**
* Ensures that child values are still processed when #access = FALSE.
diff --git a/core/modules/system/tests/src/Functional/Form/FormObjectTest.php b/core/modules/system/tests/src/Functional/Form/FormObjectTest.php
index a031198cc7a..67d7ecb0dd1 100644
--- a/core/modules/system/tests/src/Functional/Form/FormObjectTest.php
+++ b/core/modules/system/tests/src/Functional/Form/FormObjectTest.php
@@ -17,19 +17,19 @@ class FormObjectTest extends SystemConfigFormTestBase {
*
* @var array
*/
- public static $modules = array('form_test');
+ public static $modules = ['form_test'];
protected function setUp() {
parent::setUp();
$this->form = new FormTestObject($this->container->get('config.factory'));
- $this->values = array(
- 'bananas' => array(
+ $this->values = [
+ 'bananas' => [
'#value' => $this->randomString(10),
'#config_name' => 'form_test.object',
'#config_key' => 'bananas',
- ),
- );
+ ],
+ ];
}
/**
@@ -44,7 +44,7 @@ class FormObjectTest extends SystemConfigFormTestBase {
$this->assertText('The FormTestObject::buildForm() method was used for this form.');
$elements = $this->xpath('//form[@id="form-test-form-test-object"]');
$this->assertTrue(!empty($elements), 'The correct form ID was used.');
- $this->drupalPostForm(NULL, array('bananas' => 'green'), t('Save'));
+ $this->drupalPostForm(NULL, ['bananas' => 'green'], t('Save'));
$this->assertText('The FormTestObject::validateForm() method was used for this form.');
$this->assertText('The FormTestObject::submitForm() method was used for this form.');
$value = $config_factory->get('form_test.object')->get('bananas');
@@ -64,7 +64,7 @@ class FormObjectTest extends SystemConfigFormTestBase {
$this->assertText('The FormTestServiceObject::buildForm() method was used for this form.');
$elements = $this->xpath('//form[@id="form-test-form-test-service-object"]');
$this->assertTrue(!empty($elements), 'The correct form ID was used.');
- $this->drupalPostForm(NULL, array('bananas' => 'brown'), t('Save'));
+ $this->drupalPostForm(NULL, ['bananas' => 'brown'], t('Save'));
$this->assertText('The FormTestServiceObject::validateForm() method was used for this form.');
$this->assertText('The FormTestServiceObject::submitForm() method was used for this form.');
$value = $config_factory->get('form_test.object')->get('bananas');
@@ -77,7 +77,7 @@ class FormObjectTest extends SystemConfigFormTestBase {
$this->assertTrue(!empty($elements), 'The correct form ID was used.');
$this->assertText('custom_value', 'Ensure parameters are injected from request attributes.');
$this->assertText('request_value', 'Ensure the request object is injected.');
- $this->drupalPostForm(NULL, array('bananas' => 'black'), t('Save'));
+ $this->drupalPostForm(NULL, ['bananas' => 'black'], t('Save'));
$this->assertText('The FormTestControllerObject::validateForm() method was used for this form.');
$this->assertText('The FormTestControllerObject::submitForm() method was used for this form.');
$value = $config_factory->get('form_test.object')->get('bananas');
diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
index 640a60dd333..dc63e64d72d 100644
--- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
@@ -14,7 +14,7 @@ class ModulesListFormWebTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system_test', 'help');
+ public static $modules = ['system_test', 'help'];
/**
* {@inheritdoc}
@@ -30,7 +30,7 @@ class ModulesListFormWebTest extends BrowserTestBase {
public function testModuleListForm() {
$this->drupalLogin(
$this->drupalCreateUser(
- array('administer modules', 'administer permissions')
+ ['administer modules', 'administer permissions']
)
);
$this->drupalGet('admin/modules');
diff --git a/core/modules/system/tests/src/Functional/Form/RedirectTest.php b/core/modules/system/tests/src/Functional/Form/RedirectTest.php
index d369b9ccb6e..6c09c2d8223 100644
--- a/core/modules/system/tests/src/Functional/Form/RedirectTest.php
+++ b/core/modules/system/tests/src/Functional/Form/RedirectTest.php
@@ -16,60 +16,60 @@ class RedirectTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('form_test', 'block');
+ public static $modules = ['form_test', 'block'];
/**
* Tests form redirection.
*/
function testRedirect() {
$path = 'form-test/redirect';
- $options = array('query' => array('foo' => 'bar'));
+ $options = ['query' => ['foo' => 'bar']];
$options['absolute'] = TRUE;
// Test basic redirection.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'));
- $this->assertUrl($edit['destination'], array(), 'Basic redirection works.');
+ $this->assertUrl($edit['destination'], [], 'Basic redirection works.');
// Test without redirection.
- $edit = array(
+ $edit = [
'redirection' => FALSE,
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'));
- $this->assertUrl($path, array(), 'When redirect is set to FALSE, there should be no redirection.');
+ $this->assertUrl($path, [], 'When redirect is set to FALSE, there should be no redirection.');
// Test redirection with query parameters.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'), $options);
- $this->assertUrl($edit['destination'], array(), 'Redirection with query parameters works.');
+ $this->assertUrl($edit['destination'], [], 'Redirection with query parameters works.');
// Test without redirection but with query parameters.
- $edit = array(
+ $edit = [
'redirection' => FALSE,
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'), $options);
$this->assertUrl($path, $options, 'When redirect is set to FALSE, there should be no redirection, and the query parameters should be passed along.');
// Test redirection back to the original path.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => '',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'));
- $this->assertUrl($path, array(), 'When using an empty redirection string, there should be no redirection.');
+ $this->assertUrl($path, [], 'When using an empty redirection string, there should be no redirection.');
// Test redirection back to the original path with query parameters.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => '',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'), $options);
$this->assertUrl($path, $options, 'When using an empty redirection string, there should be no redirection, and the query parameters should be passed along.');
}
@@ -82,15 +82,15 @@ class RedirectTest extends BrowserTestBase {
$this->drupalPlaceBlock('redirect_form_block');
// Create a user that does not have permission to administer blocks.
- $user = $this->drupalCreateUser(array('administer themes'));
+ $user = $this->drupalCreateUser(['administer themes']);
$this->drupalLogin($user);
// Visit page 'foo' (404 page) and submit the form. Verify it ends up
// at the right URL.
- $expected = \Drupal::url('form_test.route1', array(), array('query' => array('test1' => 'test2'), 'absolute' => TRUE));
+ $expected = \Drupal::url('form_test.route1', [], ['query' => ['test1' => 'test2'], 'absolute' => TRUE]);
$this->drupalGet('foo');
$this->assertResponse(404);
- $this->drupalPostForm(NULL, array(), t('Submit'));
+ $this->drupalPostForm(NULL, [], t('Submit'));
$this->assertResponse(200);
$this->assertUrl($expected, [], 'Redirected to correct URL/query.');
@@ -98,7 +98,7 @@ class RedirectTest extends BrowserTestBase {
// ends up at the right URL.
$this->drupalGet('admin/structure/block');
$this->assertResponse(403);
- $this->drupalPostForm(NULL, array(), t('Submit'));
+ $this->drupalPostForm(NULL, [], t('Submit'));
$this->assertResponse(200);
$this->assertUrl($expected, [], 'Redirected to correct URL/query.');
}
diff --git a/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php b/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php
index 5e201217888..0b13f18d626 100644
--- a/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php
+++ b/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php
@@ -16,7 +16,7 @@ class LockFunctionalTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('system_test');
+ public static $modules = ['system_test'];
/**
* Confirms that we can acquire and release locks in two parallel requests.
diff --git a/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php b/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php
index cbcf87fd708..bdbfd749c94 100644
--- a/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php
+++ b/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php
@@ -27,8 +27,8 @@ class HtmlToTextTest extends BrowserTestBase {
protected function stringToHtml($text) {
return '"' .
str_replace(
- array("\n", ' '),
- array('\n', '&nbsp;'),
+ ["\n", ' '],
+ ['\n', '&nbsp;'],
Html::escape($text)
) . '"';
}
@@ -68,7 +68,7 @@ class HtmlToTextTest extends BrowserTestBase {
*/
public function testTags() {
global $base_path, $base_url;
- $tests = array(
+ $tests = [
// @todo Trailing linefeeds should be trimmed.
'<a href = "https://www.drupal.org">Drupal.org</a>' => "Drupal.org [1]\n\n[1] https://www.drupal.org\n",
// @todo Footer URLs should be absolute.
@@ -151,7 +151,7 @@ class HtmlToTextTest extends BrowserTestBase {
// A couple of tests for Unicode characters.
'<q>I <em>will</em> be back…</q>' => "I /will/ be back…\n",
'FrançAIS is ÜBER-åwesome' => "FrançAIS is ÜBER-åwesome\n",
- );
+ ];
foreach ($tests as $html => $text) {
$this->assertHtmlToText($html, $text, 'Supported tags');
@@ -168,27 +168,27 @@ class HtmlToTextTest extends BrowserTestBase {
'Drupal <b>Drupal</b> Drupal',
"Drupal *Drupal* Drupal\n",
'Allowed <b> tag found',
- array('b')
+ ['b']
);
$this->assertHtmlToText(
'Drupal <h1>Drupal</h1> Drupal',
"Drupal Drupal Drupal\n",
'Disallowed <h1> tag not found',
- array('b')
+ ['b']
);
$this->assertHtmlToText(
'Drupal <p><em><b>Drupal</b></em><p> Drupal',
"Drupal Drupal Drupal\n",
'Disallowed <p>, <em>, and <b> tags not found',
- array('a', 'br', 'h1')
+ ['a', 'br', 'h1']
);
$this->assertHtmlToText(
'<html><body>Drupal</body></html>',
"Drupal\n",
'Unsupported <html> and <body> tags not found',
- array('html', 'body')
+ ['html', 'body']
);
}
@@ -203,7 +203,7 @@ class HtmlToTextTest extends BrowserTestBase {
$input,
$collapsed,
'Whitespace is collapsed',
- array('p')
+ ['p']
);
}
@@ -312,17 +312,17 @@ class HtmlToTextTest extends BrowserTestBase {
* and spaces are properly handled.
*/
public function testDrupalHtmlToTextParagraphs() {
- $tests = array();
- $tests[] = array(
+ $tests = [];
+ $tests[] = [
'html' => "<p>line 1<br />\nline 2<br />line 3\n<br />line 4</p><p>paragraph</p>",
// @todo Trailing line breaks should be trimmed.
'text' => "line 1\nline 2\nline 3\nline 4\n\nparagraph\n\n",
- );
- $tests[] = array(
+ ];
+ $tests[] = [
'html' => "<p>line 1<br /> line 2</p> <p>line 4<br /> line 5</p> <p>0</p>",
// @todo Trailing line breaks should be trimmed.
'text' => "line 1\nline 2\n\nline 4\nline 5\n\n0\n\n",
- );
+ ];
foreach ($tests as $test) {
$this->assertHtmlToText($test['html'], $test['text'], 'Paragraph breaks');
}
diff --git a/core/modules/system/tests/src/Functional/Mail/MailTest.php b/core/modules/system/tests/src/Functional/Mail/MailTest.php
index 6550f095ce5..74549a3211e 100644
--- a/core/modules/system/tests/src/Functional/Mail/MailTest.php
+++ b/core/modules/system/tests/src/Functional/Mail/MailTest.php
@@ -18,7 +18,7 @@ class MailTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('simpletest', 'system_mail_failure_test');
+ public static $modules = ['simpletest', 'system_mail_failure_test'];
/**
* Assert that the pluggable mail system is functional.
@@ -28,7 +28,7 @@ class MailTest extends BrowserTestBase {
$this->config('system.mail')->set('interface.default', 'test_php_mail_failure')->save();
// Get the default MailInterface class instance.
- $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'default', 'key' => 'default'));
+ $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'default', 'key' => 'default']);
// Assert whether the default mail backend is an instance of the expected
// class.
@@ -38,7 +38,7 @@ class MailTest extends BrowserTestBase {
$this->config('system.mail')->set('interface.mymodule_testkey', 'test_mail_collector')->save();
// Get the added MailInterface class instance.
- $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'mymodule', 'key' => 'testkey'));
+ $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'mymodule', 'key' => 'testkey']);
// Assert whether the added mail backend is an instance of the expected
// class.
@@ -56,7 +56,7 @@ class MailTest extends BrowserTestBase {
// Use the state system collector mail backend.
$this->config('system.mail')->set('interface.default', 'test_mail_collector')->save();
// Reset the state variable that holds sent messages.
- \Drupal::state()->set('system.test_mail_collector', array());
+ \Drupal::state()->set('system.test_mail_collector', []);
// Send a test message that simpletest_mail_alter should cancel.
\Drupal::service('plugin.manager.mail')->mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->getId());
@@ -77,11 +77,11 @@ class MailTest extends BrowserTestBase {
// Use the state system collector mail backend.
$this->config('system.mail')->set('interface.default', 'test_mail_collector')->save();
// Reset the state variable that holds sent messages.
- \Drupal::state()->set('system.test_mail_collector', array());
+ \Drupal::state()->set('system.test_mail_collector', []);
// Send an email with a reply-to address specified.
$from_email = 'Drupal <simpletest@example.com>';
$reply_email = 'someone_else@example.com';
- \Drupal::service('plugin.manager.mail')->mail('simpletest', 'from_test', 'from_test@example.com', $language, array(), $reply_email);
+ \Drupal::service('plugin.manager.mail')->mail('simpletest', 'from_test', 'from_test@example.com', $language, [], $reply_email);
// Test that the reply-to email is just the email and not the site name
// and default sender email.
$captured_emails = \Drupal::state()->get('system.test_mail_collector');
diff --git a/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php b/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php
index 3156823c2f1..10af396a6d7 100644
--- a/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php
+++ b/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php
@@ -56,10 +56,10 @@ class MenuAccessTest extends BrowserTestBase {
// Attempt to access a restricted local task.
$this->drupalGet('foo/asdf/c');
$this->assertResponse(403);
- $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', array(
+ $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', [
':class' => 'tabs primary',
':href' => Url::fromRoute('menu_test.router_test1', ['bar' => 'asdf'])->toString(),
- ));
+ ]);
$this->assertTrue(empty($elements), 'No tab linking to foo/asdf found');
$this->assertNoLinkByHref('foo/asdf/b');
$this->assertNoLinkByHref('foo/asdf/c');
diff --git a/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php b/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php
index a9272394dfc..9a81499a280 100644
--- a/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php
+++ b/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php
@@ -23,7 +23,7 @@ class ClassLoaderTest extends BrowserTestBase {
*/
function testClassLoading() {
// Enable the module_test and module_autoload_test modules.
- \Drupal::service('module_installer')->install(array('module_test', 'module_autoload_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_test', 'module_autoload_test'], FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i = 0; $i < 2; $i++) {
@@ -40,7 +40,7 @@ class ClassLoaderTest extends BrowserTestBase {
*/
function testClassLoadingNotInstalledModules() {
// Enable the module_test module.
- \Drupal::service('module_installer')->install(array('module_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_test'], FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i = 0; $i < 2; $i++) {
@@ -57,10 +57,10 @@ class ClassLoaderTest extends BrowserTestBase {
*/
function testClassLoadingDisabledModules() {
// Enable the module_test and module_autoload_test modules.
- \Drupal::service('module_installer')->install(array('module_test', 'module_autoload_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_test', 'module_autoload_test'], FALSE);
$this->resetAll();
// Ensure that module_autoload_test is disabled.
- $this->container->get('module_installer')->uninstall(array('module_autoload_test'), FALSE);
+ $this->container->get('module_installer')->uninstall(['module_autoload_test'], FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i = 0; $i < 2; $i++) {
diff --git a/core/modules/system/tests/src/Functional/Module/InstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallTest.php
index db0d1d32086..ccbca6d3126 100644
--- a/core/modules/system/tests/src/Functional/Module/InstallTest.php
+++ b/core/modules/system/tests/src/Functional/Module/InstallTest.php
@@ -17,7 +17,7 @@ class InstallTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('module_test');
+ public static $modules = ['module_test'];
/**
* Verify that drupal_get_schema() can be used during module installation.
@@ -36,7 +36,7 @@ class InstallTest extends BrowserTestBase {
* be an array.
*/
public function testEnableUserTwice() {
- \Drupal::service('module_installer')->install(array('user'), FALSE);
+ \Drupal::service('module_installer')->install(['user'], FALSE);
$this->assertIdentical($this->config('core.extension')->get('module.user'), 0);
}
@@ -70,9 +70,9 @@ class InstallTest extends BrowserTestBase {
*/
public function testModuleNameLength() {
$module_name = 'invalid_module_name_over_the_maximum_allowed_character_length';
- $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', array('%name' => $module_name));
+ $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', ['%name' => $module_name]);
try {
- $this->container->get('module_installer')->install(array($module_name));
+ $this->container->get('module_installer')->install([$module_name]);
$this->fail($message);
}
catch (ExtensionNameLengthException $e) {
@@ -80,9 +80,9 @@ class InstallTest extends BrowserTestBase {
}
// Since for the UI, the submit callback uses FALSE, test that too.
- $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', array('%name' => $module_name));
+ $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', ['%name' => $module_name]);
try {
- $this->container->get('module_installer')->install(array($module_name), FALSE);
+ $this->container->get('module_installer')->install([$module_name], FALSE);
$this->fail($message);
}
catch (ExtensionNameLengthException $e) {
diff --git a/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php b/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php
index df9fbc6d7cf..704cbbaf64d 100644
--- a/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php
+++ b/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php
@@ -18,14 +18,14 @@ abstract class ModuleTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('system_test');
+ public static $modules = ['system_test'];
protected $adminUser;
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
+ $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$this->drupalLogin($this->adminUser);
}
@@ -42,9 +42,9 @@ abstract class ModuleTestBase extends BrowserTestBase {
$tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
if ($count) {
- return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
+ return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));
}
- return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', array('@base_table' => $base_table)));
+ return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', ['@base_table' => $base_table]));
}
/**
@@ -61,7 +61,7 @@ abstract class ModuleTestBase extends BrowserTestBase {
$tables_exist = FALSE;
}
}
- return $this->assertTrue($tables_exist, format_string('All database tables defined by the @module module exist.', array('@module' => $module)));
+ return $this->assertTrue($tables_exist, format_string('All database tables defined by the @module module exist.', ['@module' => $module]));
}
/**
@@ -78,7 +78,7 @@ abstract class ModuleTestBase extends BrowserTestBase {
$tables_exist = TRUE;
}
}
- return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', array('@module' => $module)));
+ return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', ['@module' => $module]));
}
/**
@@ -120,7 +120,7 @@ abstract class ModuleTestBase extends BrowserTestBase {
}
// Verify that all configuration has been installed (which means that $names
// is empty).
- return $this->assertFalse($names, format_string('All default configuration of @module module found.', array('@module' => $module)));
+ return $this->assertFalse($names, format_string('All default configuration of @module module found.', ['@module' => $module]));
}
/**
@@ -134,7 +134,7 @@ abstract class ModuleTestBase extends BrowserTestBase {
*/
function assertNoModuleConfig($module) {
$names = \Drupal::configFactory()->listAll($module . '.');
- return $this->assertFalse($names, format_string('No configuration found for @module module.', array('@module' => $module)));
+ return $this->assertFalse($names, format_string('No configuration found for @module module.', ['@module' => $module]));
}
/**
@@ -154,7 +154,7 @@ abstract class ModuleTestBase extends BrowserTestBase {
else {
$message = 'Module "@module" is not enabled.';
}
- $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, format_string($message, array('@module' => $module)));
+ $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, format_string($message, ['@module' => $module]));
}
}
@@ -178,7 +178,7 @@ abstract class ModuleTestBase extends BrowserTestBase {
* @param $link
* A link to associate with the message.
*/
- function assertLogMessage($type, $message, $variables = array(), $severity = RfcLogLevel::NOTICE, $link = '') {
+ function assertLogMessage($type, $message, $variables = [], $severity = RfcLogLevel::NOTICE, $link = '') {
$count = db_select('watchdog', 'w')
->condition('type', $type)
->condition('message', $message)
@@ -188,7 +188,7 @@ abstract class ModuleTestBase extends BrowserTestBase {
->countQuery()
->execute()
->fetchField();
- $this->assertTrue($count > 0, format_string('watchdog table contains @count rows for @message', array('@count' => $count, '@message' => format_string($message, $variables))));
+ $this->assertTrue($count > 0, format_string('watchdog table contains @count rows for @message', ['@count' => $count, '@message' => format_string($message, $variables)]));
}
}
diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php
index 1977cd025ff..c5225ee5776 100644
--- a/core/modules/system/tests/src/Functional/Module/UninstallTest.php
+++ b/core/modules/system/tests/src/Functional/Module/UninstallTest.php
@@ -21,7 +21,7 @@ class UninstallTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('module_test', 'user', 'views', 'node');
+ public static $modules = ['module_test', 'user', 'views', 'node'];
/**
* Tests the hook_modules_uninstalled() of the user module.
@@ -29,7 +29,7 @@ class UninstallTest extends BrowserTestBase {
function testUserPermsUninstalled() {
// Uninstalls the module_test module, so hook_modules_uninstalled()
// is executed.
- $this->container->get('module_installer')->uninstall(array('module_test'));
+ $this->container->get('module_installer')->uninstall(['module_test']);
// Are the perms defined by module_test removed?
$this->assertFalse(user_roles(FALSE, 'module_test perm'), 'Permissions were all removed.');
@@ -39,7 +39,7 @@ class UninstallTest extends BrowserTestBase {
* Tests the Uninstall page and Uninstall confirmation page.
*/
function testUninstallPage() {
- $account = $this->drupalCreateUser(array('administer modules'));
+ $account = $this->drupalCreateUser(['administer modules']);
$this->drupalLogin($account);
// Create a node type.
@@ -67,7 +67,7 @@ class UninstallTest extends BrowserTestBase {
$node->delete();
// Uninstall module_test.
- $edit = array();
+ $edit = [];
$edit['uninstall[module_test]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.');
@@ -78,14 +78,14 @@ class UninstallTest extends BrowserTestBase {
// Uninstall node testing that the configuration that will be deleted is
// listed.
- $node_dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('module', array('node'));
- $edit = array();
+ $node_dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('module', ['node']);
+ $edit = [];
$edit['uninstall[node]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertText(\Drupal::translation()->translate('Configuration deletions'), 'Configuration deletions listed on the module install confirmation page.');
$this->assertNoText(\Drupal::translation()->translate('Configuration updates'), 'No configuration updates listed on the module install confirmation page.');
- $entity_types = array();
+ $entity_types = [];
foreach ($node_dependencies as $entity) {
$label = $entity->label() ?: $entity->id();
$this->assertText($label);
@@ -103,7 +103,7 @@ class UninstallTest extends BrowserTestBase {
// cleared during the uninstall.
\Drupal::cache()->set('uninstall_test', 'test_uninstall_page', Cache::PERMANENT);
$cached = \Drupal::cache()->get('uninstall_test');
- $this->assertEqual($cached->data, 'test_uninstall_page', SafeMarkup::format('Cache entry found: @bin', array('@bin' => $cached->data)));
+ $this->assertEqual($cached->data, 'test_uninstall_page', SafeMarkup::format('Cache entry found: @bin', ['@bin' => $cached->data]));
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
$this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
@@ -123,7 +123,7 @@ class UninstallTest extends BrowserTestBase {
$this->assertTitle(t('Uninstall') . ' | Drupal');
// Make sure the correct error is shown when no modules are selected.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertText(t('No modules selected.'), 'No module is selected to uninstall');
}
@@ -132,12 +132,12 @@ class UninstallTest extends BrowserTestBase {
* Tests that a module which fails to install can still be uninstalled.
*/
public function testFailedInstallStatus() {
- $account = $this->drupalCreateUser(array('administer modules'));
+ $account = $this->drupalCreateUser(['administer modules']);
$this->drupalLogin($account);
$message = 'Exception thrown when installing module_installer_config_test with an invalid configuration file.';
try {
- $this->container->get('module_installer')->install(array('module_installer_config_test'));
+ $this->container->get('module_installer')->install(['module_installer_config_test']);
$this->fail($message);
}
catch (EntityMalformedException $e) {
diff --git a/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php b/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
index 52cd134156d..faafe84600a 100644
--- a/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
+++ b/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
@@ -12,7 +12,7 @@ use Drupal\language\Entity\ConfigurableLanguage;
*/
class UpcastingTest extends BrowserTestBase {
- public static $modules = array('paramconverter_test', 'node', 'language');
+ public static $modules = ['paramconverter_test', 'node', 'language'];
/**
* Confirms that all parameters are converted as expected.
@@ -25,8 +25,8 @@ class UpcastingTest extends BrowserTestBase {
* happening.
*/
public function testUpcasting() {
- $node = $this->drupalCreateNode(array('title' => $this->randomMachineName(8)));
- $user = $this->drupalCreateUser(array('access content'));
+ $node = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]);
+ $user = $this->drupalCreateUser(['access content']);
$foo = 'bar';
// paramconverter_test/test_user_node_foo/{user}/{node}/{foo}
@@ -48,8 +48,8 @@ class UpcastingTest extends BrowserTestBase {
* Confirms we can upcast to controller arguments of the same type.
*/
public function testSameTypes() {
- $node = $this->drupalCreateNode(array('title' => $this->randomMachineName(8)));
- $parent = $this->drupalCreateNode(array('title' => $this->randomMachineName(8)));
+ $node = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]);
+ $parent = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]);
// paramconverter_test/node/{node}/set/parent/{parent}
// options.parameters.parent.type = entity:node
$this->drupalGet("paramconverter_test/node/" . $node->id() . "/set/parent/" . $parent->id());
@@ -63,19 +63,19 @@ class UpcastingTest extends BrowserTestBase {
$language = ConfigurableLanguage::createFromLangcode('de');
$language->save();
\Drupal::configFactory()->getEditable('language.negotiation')
- ->set('url.prefixes', array('de' => 'de'))
+ ->set('url.prefixes', ['de' => 'de'])
->save();
// The container must be recreated after adding a new language.
$this->rebuildContainer();
- $node = $this->drupalCreateNode(array('title' => 'English label'));
+ $node = $this->drupalCreateNode(['title' => 'English label']);
$translation = $node->addTranslation('de');
$translation->setTitle('Deutscher Titel')->save();
$this->drupalGet("/paramconverter_test/node/" . $node->id() . "/test_language");
$this->assertRaw("English label");
- $this->drupalGet("paramconverter_test/node/" . $node->id() . "/test_language", array('language' => $language));
+ $this->drupalGet("paramconverter_test/node/" . $node->id() . "/test_language", ['language' => $language]);
$this->assertRaw("Deutscher Titel");
}
diff --git a/core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php b/core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php
index a24ddf934b4..13c592d1b22 100644
--- a/core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php
+++ b/core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php
@@ -19,7 +19,7 @@ class UrlAlterFunctionalTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('path', 'forum', 'url_alter_test');
+ public static $modules = ['path', 'forum', 'url_alter_test'];
/**
* Test that URL altering works and that it occurs in the correct order.
@@ -30,7 +30,7 @@ class UrlAlterFunctionalTest extends BrowserTestBase {
// User names can have quotes and plus signs so we should ensure that URL
// altering works with this.
- $account = $this->drupalCreateUser(array('administer url aliases'), "a'foo+bar");
+ $account = $this->drupalCreateUser(['administer url aliases'], "a'foo+bar");
$this->drupalLogin($account);
$uid = $account->id();
@@ -42,14 +42,14 @@ class UrlAlterFunctionalTest extends BrowserTestBase {
$this->assertUrlOutboundAlter("/user/$uid", "/user/$name");
// Test that a path always uses its alias.
- $path = array('source' => "/user/$uid/test1", 'alias' => '/alias/test1');
+ $path = ['source' => "/user/$uid/test1", 'alias' => '/alias/test1'];
$this->container->get('path.alias_storage')->save($path['source'], $path['alias']);
$this->rebuildContainer();
$this->assertUrlInboundAlter('/alias/test1', "/user/$uid/test1");
$this->assertUrlOutboundAlter("/user/$uid/test1", '/alias/test1');
// Test adding an alias via the UI.
- $edit = array('source' => "/user/$uid/edit", 'alias' => '/alias/test2');
+ $edit = ['source' => "/user/$uid/edit", 'alias' => '/alias/test2'];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$this->assertText(t('The alias has been saved.'));
$this->drupalGet('alias/test2');
@@ -95,7 +95,7 @@ class UrlAlterFunctionalTest extends BrowserTestBase {
protected function assertUrlOutboundAlter($original, $final) {
// Test outbound altering.
$result = $this->container->get('path_processor_manager')->processOutbound($original);
- return $this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
+ return $this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', ['%original' => $original, '%final' => $final, '%result' => $result]));
}
/**
@@ -112,7 +112,7 @@ class UrlAlterFunctionalTest extends BrowserTestBase {
protected function assertUrlInboundAlter($original, $final) {
// Test inbound altering.
$result = $this->container->get('path.alias_manager')->getPathByAlias($original);
- return $this->assertIdentical($result, $final, format_string('Altered inbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
+ return $this->assertIdentical($result, $final, format_string('Altered inbound URL %original, expected %final, and got %result.', ['%original' => $original, '%final' => $final, '%result' => $result]));
}
}
diff --git a/core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php b/core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
index 536fda9c8f4..6f5dc7da684 100644
--- a/core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
+++ b/core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
@@ -43,7 +43,7 @@ class AjaxPageStateTest extends BrowserTestBase {
* and available in code as scripts. Do this as the base test.
*/
public function testLibrariesAvailable() {
- $this->drupalGet('node', array());
+ $this->drupalGet('node', []);
$this->assertRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
'The html5shiv library from core should be loaded.'
@@ -63,14 +63,14 @@ class AjaxPageStateTest extends BrowserTestBase {
*/
public function testHtml5ShivIsNotLoaded() {
$this->drupalGet('node',
- array(
+ [
"query" =>
- array(
- 'ajax_page_state' => array(
+ [
+ 'ajax_page_state' => [
'libraries' => 'core/html5shiv'
- )
- )
- )
+ ]
+ ]
+ ]
);
$this->assertNoRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
diff --git a/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php b/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
index 4eba3aa6815..449046276e6 100644
--- a/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
+++ b/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
@@ -16,7 +16,7 @@ class DisplayVariantTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('display_variant_test');
+ public static $modules = ['display_variant_test'];
/**
* Tests selecting the variant and passing configuration.
diff --git a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php
index 5bc0bb50e58..62a511f2e43 100644
--- a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php
+++ b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php
@@ -16,7 +16,7 @@ class RouterPermissionTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('router_test');
+ public static $modules = ['router_test'];
/**
* Tests permission requirements on routes.
@@ -29,7 +29,7 @@ class RouterPermissionTest extends BrowserTestBase {
$this->drupalGet('router_test/test8');
$this->assertResponse(403, 'Access denied by default if no access specified');
- $user = $this->drupalCreateUser(array('access test7'));
+ $user = $this->drupalCreateUser(['access test7']);
$this->drupalLogin($user);
$this->drupalGet('router_test/test7');
$this->assertResponse(200);
diff --git a/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php b/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php
index 88a3ce692e3..73d6910087d 100644
--- a/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php
+++ b/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php
@@ -16,7 +16,7 @@ class ServiceProviderWebTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('file', 'service_provider_test');
+ public static $modules = ['file', 'service_provider_test'];
/**
* Tests that module service providers get registered to the DIC.
diff --git a/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php b/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php
index 29bb4c28671..7ff8af1fa4b 100644
--- a/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php
+++ b/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php
@@ -18,7 +18,7 @@ class DateFormatsMachineNameTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
// Create a new administrator user for the test.
- $admin = $this->drupalCreateUser(array('administer site configuration'));
+ $admin = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin);
}
@@ -28,49 +28,49 @@ class DateFormatsMachineNameTest extends BrowserTestBase {
public function testDateFormatsMachineNameAllowedValues() {
// Try to create a date format with a not allowed character to test the date
// format specific machine name replace pattern.
- $edit = array(
+ $edit = [
'label' => 'Something Not Allowed',
'id' => 'something.bad',
'date_format_pattern' => 'Y-m-d',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'), 'It is not possible to create a date format with the machine name that has any character other than lowercase letters, digits or underscore.');
// Try to create a date format with the reserved machine name "custom".
- $edit = array(
+ $edit = [
'label' => 'Custom',
'id' => 'custom',
'date_format_pattern' => 'Y-m-d',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'), 'It is not possible to create a date format with the machine name "custom".');
// Try to create a date format with a machine name, "fallback", that
// already exists.
- $edit = array(
+ $edit = [
'label' => 'Fallback',
'id' => 'fallback',
'date_format_pattern' => 'j/m/Y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name is already in use. It must be unique.'), 'It is not possible to create a date format with the machine name "fallback". It is a built-in format that already exists.');
// Create a date format with a machine name distinct from the previous two.
$id = Unicode::strtolower($this->randomMachineName(16));
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(16),
'id' => $id,
'date_format_pattern' => 'd/m/Y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('Custom date format added.'), 'It is possible to create a date format with a new machine name.');
// Try to create a date format with same machine name as the previous one.
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(16),
'id' => $id,
'date_format_pattern' => 'd-m-Y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name is already in use. It must be unique.'), 'It is not possible to create a new date format with an existing machine name.');
}
diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php
index 98dd35e5818..1f3f9779f08 100644
--- a/core/modules/system/tests/src/Functional/System/DateTimeTest.php
+++ b/core/modules/system/tests/src/Functional/System/DateTimeTest.php
@@ -25,14 +25,14 @@ class DateTimeTest extends BrowserTestBase {
parent::setUp();
// Create admin user and log in admin user.
- $this->drupalLogin ($this->drupalCreateUser(array(
+ $this->drupalLogin ($this->drupalCreateUser([
'administer site configuration',
'administer content types',
'administer nodes',
'administer node fields',
'administer node form display',
'administer node display',
- )));
+ ]));
$this->drupalPlaceBlock('local_actions_block');
}
@@ -52,9 +52,9 @@ class DateTimeTest extends BrowserTestBase {
// Create some nodes with different authored-on dates.
$date1 = '2007-01-31 21:00:00 -1000';
$date2 = '2007-07-31 21:00:00 -1000';
- $this->drupalCreateContentType(array('type' => 'article'));
- $node1 = $this->drupalCreateNode(array('created' => strtotime($date1), 'type' => 'article'));
- $node2 = $this->drupalCreateNode(array('created' => strtotime($date2), 'type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
+ $node1 = $this->drupalCreateNode(['created' => strtotime($date1), 'type' => 'article']);
+ $node2 = $this->drupalCreateNode(['created' => strtotime($date2), 'type' => 'article']);
// Confirm date format and time zone.
$this->drupalGet('node/' . $node1->id());
@@ -64,7 +64,7 @@ class DateTimeTest extends BrowserTestBase {
// Set time zone to Los Angeles time.
$config->set('timezone.default', 'America/Los_Angeles')->save();
- \Drupal::entityManager()->getViewBuilder('node')->resetCache(array($node1, $node2));
+ \Drupal::entityManager()->getViewBuilder('node')->resetCache([$node1, $node2]);
// Confirm date format and time zone.
$this->drupalGet('node/' . $node1->id());
@@ -85,11 +85,11 @@ class DateTimeTest extends BrowserTestBase {
$date_format_id = strtolower($this->randomMachineName(8));
$name = ucwords($date_format_id);
$date_format = 'd.m.Y - H:i';
- $edit = array(
+ $edit = [
'id' => $date_format_id,
'label' => $name,
'date_format_pattern' => $date_format,
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
@@ -100,24 +100,24 @@ class DateTimeTest extends BrowserTestBase {
$this->drupalGet('admin/config/regional/date-time');
$this->clickLink(t('Edit'));
$this->drupalPostForm(NULL, NULL, t('Save format'));
- $this->assertUrl('admin/config/regional/date-time', array('absolute' => TRUE), 'Correct page redirection.');
+ $this->assertUrl('admin/config/regional/date-time', ['absolute' => TRUE], 'Correct page redirection.');
$this->assertText(t('Custom date format updated.'), 'Custom date format successfully updated.');
// Edit custom date format.
$this->drupalGet('admin/config/regional/date-time');
$this->clickLink(t('Edit'));
- $edit = array(
+ $edit = [
'date_format_pattern' => 'Y m',
- );
+ ];
$this->drupalPostForm($this->getUrl(), $edit, t('Save format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format updated.'), 'Custom date format successfully updated.');
// Delete custom date format.
$this->clickLink(t('Delete'));
- $this->drupalPostForm('admin/config/regional/date-time/formats/manage/' . $date_format_id . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/date-time/formats/manage/' . $date_format_id . '/delete', [], t('Delete'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
- $this->assertRaw(t('The date format %format has been deleted.', array('%format' => $name)), 'Custom date format removed.');
+ $this->assertRaw(t('The date format %format has been deleted.', ['%format' => $name]), 'Custom date format removed.');
// Make sure the date does not exist in config.
$date_format = DateFormat::load($date_format_id);
@@ -127,22 +127,22 @@ class DateTimeTest extends BrowserTestBase {
$date_format_id = strtolower($this->randomMachineName(8));
$name = ucwords($date_format_id);
$date_format = 'Y';
- $edit = array(
+ $edit = [
'id' => $date_format_id,
'label' => $name,
'date_format_pattern' => $date_format,
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
$this->assertText($name, 'Custom date format appears in the date format list.');
$this->assertText(t('Delete'), 'Delete link for custom date format appears.');
- $date_format = DateFormat::create(array(
+ $date_format = DateFormat::create([
'id' => 'xss_short',
'label' => 'XSS format',
'pattern' => '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'\X\S\S\'\)\;\<\/\s\c\r\i\p\t\>',
- ));
+ ]);
$date_format->save();
$this->drupalGet(Url::fromRoute('entity.date_format.collection'));
@@ -152,11 +152,11 @@ class DateTimeTest extends BrowserTestBase {
$date_format_id = strtolower($this->randomMachineName(8));
$name = ucwords($date_format_id);
$date_format = '& \<\e\m\>Y\<\/\e\m\>';
- $edit = array(
+ $edit = [
'id' => $date_format_id,
'label' => $name,
'date_format_pattern' => $date_format,
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
@@ -169,51 +169,51 @@ class DateTimeTest extends BrowserTestBase {
*/
function testEnteringDateTimeViaSelectors() {
- $this->drupalCreateContentType(array('type' => 'page_with_date', 'name' => 'Page with date'));
+ $this->drupalCreateContentType(['type' => 'page_with_date', 'name' => 'Page with date']);
$this->drupalGet('admin/structure/types/manage/page_with_date');
$this->assertResponse(200, 'Content type created.');
$this->drupalGet('admin/structure/types/manage/page_with_date/fields/add-field');
- $edit = array(
+ $edit = [
'new_storage_type' => 'datetime',
'label' => 'dt',
'field_name' => 'dt',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/add-field', $edit, t('Save and continue'));
$this->assertText(t('These settings apply to the'), 'New datetime field created, now configuring');
$this->drupalGet('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage');
- $edit = array(
+ $edit = [
'settings[datetime_type]' => 'datetime',
'cardinality' => 'number',
'cardinality_number' => '1',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage', $edit, t('Save field settings'));
$this->drupalGet('admin/structure/types/manage/page_with_date/fields');
$this->assertText('field_dt', 'New field is in place');
$this->drupalGet('admin/structure/types/manage/page_with_date/form-display');
- $edit = array(
+ $edit = [
'fields[field_dt][type]' => 'datetime_datelist',
'fields[field_dt][region]' => 'content',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page_with_date/form-display', $edit, t('Save'));
$this->drupalLogout();
// Now log in as a regular editor.
- $this->drupalLogin($this->drupalCreateUser(array('create page_with_date content')));
+ $this->drupalLogin($this->drupalCreateUser(['create page_with_date content']));
$this->drupalGet('node/add/page_with_date');
- $edit = array(
+ $edit = [
'title[0][value]' => 'sample doc',
'field_dt[0][value][year]' => '2016',
'field_dt[0][value][month]' => '2',
'field_dt[0][value][day]' => '31',
'field_dt[0][value][hour]' => '1',
'field_dt[0][value][minute]' => '30',
- );
+ ];
$this->drupalPostForm('node/add/page_with_date', $edit, t('Save'));
$this->assertText(t('Selected combination of day and month is not valid.'), 'Inorrect date failed validation');
diff --git a/core/modules/system/tests/src/Functional/System/IndexPhpTest.php b/core/modules/system/tests/src/Functional/System/IndexPhpTest.php
index fa43ad28350..36cdb7b9165 100644
--- a/core/modules/system/tests/src/Functional/System/IndexPhpTest.php
+++ b/core/modules/system/tests/src/Functional/System/IndexPhpTest.php
@@ -20,10 +20,10 @@ class IndexPhpTest extends BrowserTestBase {
function testIndexPhpHandling() {
$index_php = $GLOBALS['base_url'] . '/index.php';
- $this->drupalGet($index_php, array('external' => TRUE));
+ $this->drupalGet($index_php, ['external' => TRUE]);
$this->assertResponse(200, 'Make sure index.php returns a valid page.');
- $this->drupalGet($index_php . '/user', array('external' => TRUE));
+ $this->drupalGet($index_php . '/user', ['external' => TRUE]);
$this->assertResponse(200, 'Make sure index.php/user returns a valid page.');
}
diff --git a/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php b/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php
index 8d64feb9911..f953e09853a 100644
--- a/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php
+++ b/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php
@@ -16,7 +16,7 @@ class MainContentFallbackTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('block', 'system_test');
+ public static $modules = ['block', 'system_test'];
protected $adminUser;
protected $webUser;
@@ -25,22 +25,22 @@ class MainContentFallbackTest extends BrowserTestBase {
parent::setUp();
// Create and log in admin user.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer site configuration',
'administer modules',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
// Create a web user.
- $this->webUser = $this->drupalCreateUser(array('access user profiles'));
+ $this->webUser = $this->drupalCreateUser(['access user profiles']);
}
/**
* Test availability of main content: Drupal falls back to SimplePageVariant.
*/
function testMainContentFallback() {
- $edit = array();
+ $edit = [];
// Uninstall the block module.
$edit['uninstall[block]'] = 'block';
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
@@ -63,7 +63,7 @@ class MainContentFallbackTest extends BrowserTestBase {
// Enable the block module again.
$this->drupalLogin($this->adminUser);
- $edit = array();
+ $edit = [];
$edit['modules[block][enable]'] = 'block';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText(t('Module Block has been enabled.'), 'Modules status has been updated.');
diff --git a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
index 6a4d3ee9c27..fbe97f4dab8 100644
--- a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
+++ b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
@@ -25,17 +25,17 @@ class SitesDirectoryHardeningTest extends BrowserTestBase {
$settings_file = $this->settingsFile($site_path);
// First, we check based on what the initial install has set.
- $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file.', array('@file' => $site_path)));
+ $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file.', ['@file' => $site_path]));
// We intentionally don't check for settings.local.php as that file is
// not created by Drupal.
- $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file.', array('@file' => $settings_file)));
+ $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file.', ['@file' => $settings_file]));
$this->makeWritable($site_path);
$this->checkSystemRequirements();
- $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file after manual permissions change.', array('@file' => $site_path)));
- $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file after manual permissions change.', array('@file' => $settings_file)));
+ $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file after manual permissions change.', ['@file' => $site_path]));
+ $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file after manual permissions change.', ['@file' => $settings_file]));
}
/**
diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php
index 34d4f758ba0..cb81d0521f8 100644
--- a/core/modules/system/tests/src/Functional/System/StatusTest.php
+++ b/core/modules/system/tests/src/Functional/System/StatusTest.php
@@ -26,17 +26,17 @@ class StatusTest extends BrowserTestBase {
// Unset the sync directory in settings.php to trigger $config_directories
// error.
- $settings['config_directories'] = array(
- CONFIG_SYNC_DIRECTORY => (object) array(
+ $settings['config_directories'] = [
+ CONFIG_SYNC_DIRECTORY => (object) [
'value' => '',
'required' => TRUE,
- ),
- );
+ ],
+ ];
$this->writeSettings($settings);
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer site configuration',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
@@ -71,7 +71,7 @@ class StatusTest extends BrowserTestBase {
$this->assertNoText(t('Out of date'));
// The global $config_directories is not properly formed.
- $this->assertRaw(t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', array('%file' => $this->siteDirectory . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY)));
+ $this->assertRaw(t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', ['%file' => $this->siteDirectory . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY]));
// Set the schema version of update_test_postupdate to a lower version, so
// update_test_postupdate_update_8001() needs to be executed.
diff --git a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
index 6878d6c73bd..01984a35815 100644
--- a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
+++ b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
@@ -16,13 +16,13 @@ class SystemAuthorizeTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('system_test');
+ public static $modules = ['system_test'];
protected function setUp() {
parent::setUp();
// Create an administrator user.
- $this->drupalLogin ($this->drupalCreateUser(array('administer software updates')));
+ $this->drupalLogin ($this->drupalCreateUser(['administer software updates']));
}
/**
@@ -46,7 +46,7 @@ class SystemAuthorizeTest extends BrowserTestBase {
function testFileTransferHooks() {
$page_title = $this->randomMachineName(16);
$this->drupalGetAuthorizePHP($page_title);
- $this->assertTitle(strtr('@title | Drupal', array('@title' => $page_title)), 'authorize.php page title is correct.');
+ $this->assertTitle(strtr('@title | Drupal', ['@title' => $page_title]), 'authorize.php page title is correct.');
$this->assertNoText('It appears you have reached this page in error.');
$this->assertText('To continue, provide your server connection details');
// Make sure we see the new connection method added by system_test.
diff --git a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
index ade5e2b738d..7a65474c7f5 100644
--- a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
+++ b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
@@ -17,9 +17,9 @@ class TrustedHostsTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer site configuration',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
@@ -39,10 +39,10 @@ class TrustedHostsTest extends BrowserTestBase {
* Tests that the status page shows the trusted patterns from settings.php.
*/
public function testStatusPageWithConfiguration() {
- $settings['settings']['trusted_host_patterns'] = (object) array(
- 'value' => array('^' . preg_quote(\Drupal::request()->getHost()) . '$'),
+ $settings['settings']['trusted_host_patterns'] = (object) [
+ 'value' => ['^' . preg_quote(\Drupal::request()->getHost()) . '$'],
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
@@ -63,10 +63,10 @@ class TrustedHostsTest extends BrowserTestBase {
$this->container->get('router.builder')->rebuild();
$host = $this->container->get('request_stack')->getCurrentRequest()->getHost();
- $settings['settings']['trusted_host_patterns'] = (object) array(
- 'value' => array('^' . preg_quote($host) . '$'),
+ $settings['settings']['trusted_host_patterns'] = (object) [
+ 'value' => ['^' . preg_quote($host) . '$'],
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
diff --git a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php
index 2d279d5be1a..6af03954817 100644
--- a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php
@@ -16,11 +16,11 @@ class EngineNyanCatTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('theme_test');
+ public static $modules = ['theme_test'];
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('test_theme_nyan_cat_engine'));
+ \Drupal::service('theme_handler')->install(['test_theme_nyan_cat_engine']);
}
/**
diff --git a/core/modules/system/tests/src/Functional/Theme/FastTest.php b/core/modules/system/tests/src/Functional/Theme/FastTest.php
index 198fd63b4dc..66426ee113f 100644
--- a/core/modules/system/tests/src/Functional/Theme/FastTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/FastTest.php
@@ -16,11 +16,11 @@ class FastTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('theme_test');
+ public static $modules = ['theme_test'];
protected function setUp() {
parent::setUp();
- $this->account = $this->drupalCreateUser(array('access user profiles'));
+ $this->account = $this->drupalCreateUser(['access user profiles']);
}
/**
@@ -28,7 +28,7 @@ class FastTest extends BrowserTestBase {
*/
function testUserAutocomplete() {
$this->drupalLogin($this->account);
- $this->drupalGet('user/autocomplete', array('query' => array('q' => $this->account->getUsername())));
+ $this->drupalGet('user/autocomplete', ['query' => ['q' => $this->account->getUsername()]]);
$this->assertRaw($this->account->getUsername());
$this->assertNoText('registry initialized', 'The registry was not initialized');
}
diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
index 89424bd201d..f899effaa95 100644
--- a/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
@@ -17,7 +17,7 @@ class ThemeEarlyInitializationTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('theme_test');
+ public static $modules = ['theme_test'];
/**
* Test that the theme system can generate output in a request listener.
diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
index 7f59aa238b6..d81b6d7e301 100644
--- a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
@@ -16,7 +16,7 @@ class ThemeInfoTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('theme_test');
+ public static $modules = ['theme_test'];
/**
* The theme handler used in this test for enabling themes.
@@ -54,7 +54,7 @@ class ThemeInfoTest extends BrowserTestBase {
* Tests stylesheets-remove.
*/
function testStylesheets() {
- $this->themeHandler->install(array('test_basetheme', 'test_subtheme'));
+ $this->themeHandler->install(['test_basetheme', 'test_subtheme']);
$this->config('system.theme')
->set('default', 'test_subtheme')
->save();
@@ -66,16 +66,16 @@ class ThemeInfoTest extends BrowserTestBase {
// should work nevertheless.
$this->drupalGet('theme-test/info/stylesheets');
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$base/base-add.css"))), "$base/base-add.css found");
- $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "base-remove.css"))), "base-remove.css not found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$base/base-add.css"])), "$base/base-add.css found");
+ $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', [':href' => "base-remove.css"])), "base-remove.css not found");
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$sub/sub-add.css"))), "$sub/sub-add.css found");
- $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "sub-remove.css"))), "sub-remove.css not found");
- $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "base-add.sub-remove.css"))), "base-add.sub-remove.css not found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$sub/sub-add.css"])), "$sub/sub-add.css found");
+ $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', [':href' => "sub-remove.css"])), "sub-remove.css not found");
+ $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', [':href' => "base-add.sub-remove.css"])), "base-add.sub-remove.css not found");
// Verify that CSS files with the same name are loaded from both the base theme and subtheme.
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$base/samename.css"))), "$base/samename.css found");
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$sub/samename.css"))), "$sub/samename.css found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$base/samename.css"])), "$base/samename.css found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$sub/samename.css"])), "$sub/samename.css found");
}
@@ -83,7 +83,7 @@ class ThemeInfoTest extends BrowserTestBase {
* Tests that changes to the info file are picked up.
*/
public function testChanges() {
- $this->themeHandler->install(array('test_theme'));
+ $this->themeHandler->install(['test_theme']);
$this->config('system.theme')->set('default', 'test_theme')->save();
$this->themeManager->resetActiveTheme();
diff --git a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php
index 36bfe2de081..f2491ac47aa 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php
@@ -16,11 +16,11 @@ class TwigExtensionTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('theme_test', 'twig_extension_test');
+ public static $modules = ['theme_test', 'twig_extension_test'];
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
}
/**
diff --git a/core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php b/core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php
index b580719837d..d2b0b5465d2 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php
@@ -25,10 +25,10 @@ class TwigLoaderTest extends BrowserTestBase {
$environment = \Drupal::service('twig');
$template = $environment->loadTemplate('kittens');
- $this->assertEqual($template->render(array()), 'kittens', 'Passing "kittens" to the custom Twig loader returns "kittens".');
+ $this->assertEqual($template->render([]), 'kittens', 'Passing "kittens" to the custom Twig loader returns "kittens".');
$template = $environment->loadTemplate('meow');
- $this->assertEqual($template->render(array()), 'cats', 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
+ $this->assertEqual($template->render([]), 'cats', 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
}
}
diff --git a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php
index a0161b11fdd..2446289984e 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php
@@ -16,7 +16,7 @@ class TwigRegistryLoaderTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('twig_theme_test', 'block');
+ public static $modules = ['twig_theme_test', 'block'];
/**
* @var \Drupal\Core\Template\TwigEnvironment
@@ -25,7 +25,7 @@ class TwigRegistryLoaderTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('test_theme_twig_registry_loader', 'test_theme_twig_registry_loader_theme', 'test_theme_twig_registry_loader_subtheme'));
+ \Drupal::service('theme_handler')->install(['test_theme_twig_registry_loader', 'test_theme_twig_registry_loader_theme', 'test_theme_twig_registry_loader_subtheme']);
$this->twig = \Drupal::service('twig');
}
diff --git a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php
index 2dbeed18331..58dcbc9af1b 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php
@@ -17,7 +17,7 @@ class TwigSettingsTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('theme_test');
+ public static $modules = ['theme_test'];
/**
* Ensures Twig template auto reload setting can be overridden.
@@ -77,7 +77,7 @@ class TwigSettingsTest extends BrowserTestBase {
function testTwigCacheOverride() {
$extension = twig_extension();
$theme_handler = $this->container->get('theme_handler');
- $theme_handler->install(array('test_theme'));
+ $theme_handler->install(['test_theme']);
$this->config('system.theme')->set('default', 'test_theme')->save();
// The registry still works on theme globals, so set them here.
diff --git a/core/modules/system/tests/src/Kernel/Action/ActionTest.php b/core/modules/system/tests/src/Kernel/Action/ActionTest.php
index 4ca24fb5ac3..6c381d7c80f 100644
--- a/core/modules/system/tests/src/Kernel/Action/ActionTest.php
+++ b/core/modules/system/tests/src/Kernel/Action/ActionTest.php
@@ -17,7 +17,7 @@ class ActionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system', 'field', 'user', 'action_test');
+ public static $modules = ['system', 'field', 'user', 'action_test'];
/**
* The action manager.
@@ -34,7 +34,7 @@ class ActionTest extends KernelTestBase {
$this->actionManager = $this->container->get('plugin.manager.action');
$this->installEntitySchema('user');
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
}
/**
@@ -59,7 +59,7 @@ class ActionTest extends KernelTestBase {
// Create a new unsaved user.
$name = $this->randomMachineName();
$user_storage = $this->container->get('entity.manager')->getStorage('user');
- $account = $user_storage->create(array('name' => $name, 'bundle' => 'user'));
+ $account = $user_storage->create(['name' => $name, 'bundle' => 'user']);
$loaded_accounts = $user_storage->loadMultiple();
$this->assertEqual(count($loaded_accounts), 0);
@@ -76,25 +76,25 @@ class ActionTest extends KernelTestBase {
*/
public function testDependencies() {
// Create a new action that depends on a user role.
- $action = Action::create(array(
+ $action = Action::create([
'id' => 'user_add_role_action.' . RoleInterface::ANONYMOUS_ID,
'type' => 'user',
'label' => t('Add the anonymous role to the selected users'),
- 'configuration' => array(
+ 'configuration' => [
'rid' => RoleInterface::ANONYMOUS_ID,
- ),
+ ],
'plugin' => 'user_add_role_action',
- ));
+ ]);
$action->save();
- $expected = array(
- 'config' => array(
+ $expected = [
+ 'config' => [
'user.role.' . RoleInterface::ANONYMOUS_ID,
- ),
- 'module' => array(
+ ],
+ 'module' => [
'user',
- ),
- );
+ ],
+ ];
$this->assertIdentical($expected, $action->calculateDependencies()->getDependencies());
}
diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
index ca1c5afff4e..6a9825e1208 100644
--- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
+++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
@@ -31,7 +31,7 @@ class SystemMenuBlockTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'system',
'block',
'menu_test',
@@ -39,7 +39,7 @@ class SystemMenuBlockTest extends KernelTestBase {
'field',
'user',
'link',
- );
+ ];
/**
* The block under test.
@@ -97,16 +97,16 @@ class SystemMenuBlockTest extends KernelTestBase {
$this->blockManager = $this->container->get('plugin.manager.block');
$routes = new RouteCollection();
- $requirements = array('_access' => 'TRUE');
- $options = array('_access_checks' => array('access_check.default'));
- $routes->add('example1', new Route('/example1', array(), $requirements, $options));
- $routes->add('example2', new Route('/example2', array(), $requirements, $options));
- $routes->add('example3', new Route('/example3', array(), $requirements, $options));
- $routes->add('example4', new Route('/example4', array(), $requirements, $options));
- $routes->add('example5', new Route('/example5', array(), $requirements, $options));
- $routes->add('example6', new Route('/example6', array(), $requirements, $options));
- $routes->add('example7', new Route('/example7', array(), $requirements, $options));
- $routes->add('example8', new Route('/example8', array(), $requirements, $options));
+ $requirements = ['_access' => 'TRUE'];
+ $options = ['_access_checks' => ['access_check.default']];
+ $routes->add('example1', new Route('/example1', [], $requirements, $options));
+ $routes->add('example2', new Route('/example2', [], $requirements, $options));
+ $routes->add('example3', new Route('/example3', [], $requirements, $options));
+ $routes->add('example4', new Route('/example4', [], $requirements, $options));
+ $routes->add('example5', new Route('/example5', [], $requirements, $options));
+ $routes->add('example6', new Route('/example6', [], $requirements, $options));
+ $routes->add('example7', new Route('/example7', [], $requirements, $options));
+ $routes->add('example8', new Route('/example8', [], $requirements, $options));
$mock_route_provider = new MockRouteProvider($routes);
$this->container->set('router.route_provider', $mock_route_provider);
@@ -115,11 +115,11 @@ class SystemMenuBlockTest extends KernelTestBase {
$menu_name = 'mock';
$label = $this->randomMachineName(16);
- $this->menu = Menu::create(array(
+ $this->menu = Menu::create([
'id' => $menu_name,
'label' => $label,
'description' => 'Description text',
- ));
+ ]);
$this->menu->save();
// This creates a tree with the following structure:
@@ -132,16 +132,16 @@ class SystemMenuBlockTest extends KernelTestBase {
// - 6
// - 8
// With link 6 being the only external link.
- $links = array(
- 1 => MenuLinkMock::create(array('id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '', 'weight' => 0)),
- 2 => MenuLinkMock::create(array('id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => '', 'route_parameters' => array('foo' => 'bar'), 'weight' => 1)),
- 3 => MenuLinkMock::create(array('id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'weight' => 2)),
- 4 => MenuLinkMock::create(array('id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3', 'weight' => 3)),
- 5 => MenuLinkMock::create(array('id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '', 'expanded' => TRUE, 'weight' => 4)),
- 6 => MenuLinkMock::create(array('id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '', 'weight' => 5)),
- 7 => MenuLinkMock::create(array('id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => 'test.example5', 'weight' => 6)),
- 8 => MenuLinkMock::create(array('id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '', 'weight' => 7)),
- );
+ $links = [
+ 1 => MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '', 'weight' => 0]),
+ 2 => MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => '', 'route_parameters' => ['foo' => 'bar'], 'weight' => 1]),
+ 3 => MenuLinkMock::create(['id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'weight' => 2]),
+ 4 => MenuLinkMock::create(['id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3', 'weight' => 3]),
+ 5 => MenuLinkMock::create(['id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '', 'expanded' => TRUE, 'weight' => 4]),
+ 6 => MenuLinkMock::create(['id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '', 'weight' => 5]),
+ 7 => MenuLinkMock::create(['id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => 'test.example5', 'weight' => 6]),
+ 8 => MenuLinkMock::create(['id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '', 'weight' => 7]),
+ ];
foreach ($links as $instance) {
$this->menuLinkManager->addDefinition($instance->getPluginId(), $instance->getPluginDefinition());
}
@@ -152,25 +152,25 @@ class SystemMenuBlockTest extends KernelTestBase {
*/
public function testSystemMenuBlockConfigDependencies() {
- $block = Block::create(array(
+ $block = Block::create([
'plugin' => 'system_menu_block:' . $this->menu->id(),
'region' => 'footer',
'id' => 'machinename',
'theme' => 'stark',
- ));
+ ]);
$dependencies = $block->calculateDependencies()->getDependencies();
- $expected = array(
- 'config' => array(
+ $expected = [
+ 'config' => [
'system.menu.' . $this->menu->id()
- ),
- 'module' => array(
+ ],
+ 'module' => [
'system'
- ),
- 'theme' => array(
+ ],
+ 'theme' => [
'stark'
- ),
- );
+ ],
+ ];
$this->assertIdentical($expected, $dependencies);
}
@@ -180,13 +180,13 @@ class SystemMenuBlockTest extends KernelTestBase {
public function testConfigLevelDepth() {
// Helper function to generate a configured block instance.
$place_block = function ($level, $depth) {
- return $this->blockManager->createInstance('system_menu_block:' . $this->menu->id(), array(
+ return $this->blockManager->createInstance('system_menu_block:' . $this->menu->id(), [
'region' => 'footer',
'id' => 'machinename',
'theme' => 'stark',
'level' => $level,
'depth' => $depth,
- ));
+ ]);
};
// All the different block instances we're going to test.
diff --git a/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php b/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php
index 7de7ecfb65d..fc30a1c504d 100644
--- a/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php
+++ b/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php
@@ -17,14 +17,14 @@ class SystemListingTest extends KernelTestBase {
function testDirectoryPrecedence() {
// Define the module files we will search for, and the directory precedence
// we expect.
- $expected_directories = array(
+ $expected_directories = [
// When both copies of the module are compatible with Drupal core, the
// copy in the profile directory takes precedence.
- 'drupal_system_listing_compatible_test' => array(
+ 'drupal_system_listing_compatible_test' => [
'core/profiles/testing/modules',
'core/modules/system/tests/modules',
- ),
- );
+ ],
+ ];
// This test relies on two versions of the same module existing in
// different places in the filesystem. Without that, the test has no
@@ -32,22 +32,22 @@ class SystemListingTest extends KernelTestBase {
foreach ($expected_directories as $module => $directories) {
foreach ($directories as $directory) {
$filename = "$directory/$module/$module.info.yml";
- $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename)));
+ $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', ['@filename' => $filename]));
}
}
// Now scan the directories and check that the files take precedence as
// expected.
$listing = new ExtensionDiscovery(\Drupal::root());
- $listing->setProfileDirectories(array('core/profiles/testing'));
+ $listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
foreach ($expected_directories as $module => $directories) {
$expected_directory = array_shift($directories);
$expected_uri = "$expected_directory/$module/$module.info.yml";
- $this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', array(
+ $this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', [
'@actual' => $files[$module]->getPathname(),
'@expected' => $expected_uri,
- )));
+ ]));
}
}
@@ -56,7 +56,7 @@ class SystemListingTest extends KernelTestBase {
*/
public function testFileScanIgnoreDirectory() {
$listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
- $listing->setProfileDirectories(array('core/profiles/testing'));
+ $listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
$this->assertArrayHasKey('drupal_system_listing_compatible_test', $files);
@@ -68,7 +68,7 @@ class SystemListingTest extends KernelTestBase {
$this->setSetting('file_scan_ignore_directories', ['drupal_system_listing_compatible_test']);
$listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
- $listing->setProfileDirectories(array('core/profiles/testing'));
+ $listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
$this->assertArrayNotHasKey('drupal_system_listing_compatible_test', $files);
}
diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
index 8a3e98ed8ac..8ee66ee5c4a 100644
--- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
+++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
@@ -44,7 +44,7 @@ class ModuleHandlerTest extends KernelTestBase {
$this->assertModuleList($module_list, 'Initial');
// Try to install a new module.
- $this->moduleInstaller()->install(array('ban'));
+ $this->moduleInstaller()->install(['ban']);
$module_list[] = 'ban';
sort($module_list);
$this->assertModuleList($module_list, 'After adding a module');
@@ -58,10 +58,10 @@ class ModuleHandlerTest extends KernelTestBase {
$this->assertModuleList($module_list, 'After changing weights');
// Test the fixed list feature.
- $fixed_list = array(
+ $fixed_list = [
'system' => 'core/modules/system/system.module',
'menu' => 'core/modules/menu/menu.module',
- );
+ ];
$this->moduleHandler()->setModuleList($fixed_list);
$new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
$this->assertModuleList($new_module_list, t('When using a fixed list'));
@@ -77,7 +77,7 @@ class ModuleHandlerTest extends KernelTestBase {
protected function assertModuleList(array $expected_values, $condition) {
$expected_values = array_values(array_unique($expected_values));
$enabled_modules = array_keys($this->container->get('module_handler')->getModuleList());
- $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', array('@condition' => $condition)));
+ $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', ['@condition' => $condition]));
}
/**
@@ -93,7 +93,7 @@ class ModuleHandlerTest extends KernelTestBase {
* @see https://www.drupal.org/files/issues/dep.gv__0.png
*/
function testDependencyResolution() {
- $this->enableModules(array('module_test'));
+ $this->enableModules(['module_test']);
$this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
// Ensure that modules are not enabled.
@@ -108,7 +108,7 @@ class ModuleHandlerTest extends KernelTestBase {
drupal_static_reset('system_rebuild_module_data');
try {
- $result = $this->moduleInstaller()->install(array('color'));
+ $result = $this->moduleInstaller()->install(['color']);
$this->fail(t('ModuleInstaller::install() throws an exception if dependencies are missing.'));
}
catch (MissingDependencyException $e) {
@@ -122,7 +122,7 @@ class ModuleHandlerTest extends KernelTestBase {
\Drupal::state()->set('module_test.dependency', 'dependency');
drupal_static_reset('system_rebuild_module_data');
- $result = $this->moduleInstaller()->install(array('color'));
+ $result = $this->moduleInstaller()->install(['color']);
$this->assertTrue($result, 'ModuleInstaller::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
@@ -132,20 +132,20 @@ class ModuleHandlerTest extends KernelTestBase {
$this->assertTrue($this->moduleHandler()->moduleExists('color'), 'Module installation with dependencies succeeded.');
// Verify that the modules were enabled in the correct order.
- $module_order = \Drupal::state()->get('module_test.install_order') ?: array();
- $this->assertEqual($module_order, array('help', 'config', 'color'));
+ $module_order = \Drupal::state()->get('module_test.install_order') ?: [];
+ $this->assertEqual($module_order, ['help', 'config', 'color']);
// Uninstall all three modules explicitly, but in the incorrect order,
// and make sure that ModuleInstaller::uninstall() uninstalled them in the
// correct sequence.
- $result = $this->moduleInstaller()->uninstall(array('config', 'help', 'color'));
+ $result = $this->moduleInstaller()->uninstall(['config', 'help', 'color']);
$this->assertTrue($result, 'ModuleInstaller::uninstall() returned TRUE.');
- foreach (array('color', 'config', 'help') as $module) {
+ foreach (['color', 'config', 'help'] as $module) {
$this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, "$module module was uninstalled.");
}
- $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
- $this->assertEqual($uninstalled_modules, array('color', 'config', 'help'), 'Modules were uninstalled in the correct order.');
+ $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: [];
+ $this->assertEqual($uninstalled_modules, ['color', 'config', 'help'], 'Modules were uninstalled in the correct order.');
// Enable Color module again, which should enable both the Config module and
// Help module. But, this time do it with Config module declaring a
@@ -154,7 +154,7 @@ class ModuleHandlerTest extends KernelTestBase {
\Drupal::state()->set('module_test.dependency', 'version dependency');
drupal_static_reset('system_rebuild_module_data');
- $result = $this->moduleInstaller()->install(array('color'));
+ $result = $this->moduleInstaller()->install(['color']);
$this->assertTrue($result, 'ModuleInstaller::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
@@ -164,8 +164,8 @@ class ModuleHandlerTest extends KernelTestBase {
$this->assertTrue($this->moduleHandler()->moduleExists('color'), 'Module installation with version dependencies succeeded.');
// Finally, verify that the modules were enabled in the correct order.
- $enable_order = \Drupal::state()->get('module_test.install_order') ?: array();
- $this->assertIdentical($enable_order, array('help', 'config', 'color'));
+ $enable_order = \Drupal::state()->get('module_test.install_order') ?: [];
+ $this->assertIdentical($enable_order, ['help', 'config', 'color']);
}
/**
@@ -180,23 +180,23 @@ class ModuleHandlerTest extends KernelTestBase {
// yet have any cached way to retrieve its location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', $profile, 'core/profiles/' . $profile . '/' . $profile . '.info.yml');
- $this->enableModules(array('module_test', $profile));
+ $this->enableModules(['module_test', $profile]);
drupal_static_reset('system_rebuild_module_data');
$data = system_rebuild_module_data();
$this->assertTrue(isset($data[$profile]->requires[$dependency]));
- $this->moduleInstaller()->install(array($dependency));
+ $this->moduleInstaller()->install([$dependency]);
$this->assertTrue($this->moduleHandler()->moduleExists($dependency));
// Uninstall the profile module "dependency".
- $result = $this->moduleInstaller()->uninstall(array($dependency));
+ $result = $this->moduleInstaller()->uninstall([$dependency]);
$this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.');
$this->assertFalse($this->moduleHandler()->moduleExists($dependency));
$this->assertEqual(drupal_get_installed_schema_version($dependency), SCHEMA_UNINSTALLED, "$dependency module was uninstalled.");
// Verify that the installation profile itself was not uninstalled.
- $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
+ $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: [];
$this->assertTrue(in_array($dependency, $uninstalled_modules), "$dependency module is in the list of uninstalled modules.");
$this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.');
}
@@ -205,7 +205,7 @@ class ModuleHandlerTest extends KernelTestBase {
* Tests uninstalling a module that has content.
*/
function testUninstallContentDependency() {
- $this->enableModules(array('module_test', 'entity_test', 'text', 'user', 'help'));
+ $this->enableModules(['module_test', 'entity_test', 'text', 'user', 'help']);
$this->assertTrue($this->moduleHandler()->moduleExists('entity_test'), 'Test module is enabled.');
$this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
@@ -224,13 +224,13 @@ class ModuleHandlerTest extends KernelTestBase {
drupal_static_reset('system_rebuild_module_data');
// Create an entity so that the modules can not be disabled.
- $entity = EntityTest::create(array('name' => $this->randomString()));
+ $entity = EntityTest::create(['name' => $this->randomString()]);
$entity->save();
// Uninstalling entity_test is not possible when there is content.
try {
$message = 'ModuleInstaller::uninstall() throws ModuleUninstallValidatorException upon uninstalling a module which does not pass validation.';
- $this->moduleInstaller()->uninstall(array('entity_test'));
+ $this->moduleInstaller()->uninstall(['entity_test']);
$this->fail($message);
}
catch (ModuleUninstallValidatorException $e) {
@@ -240,7 +240,7 @@ class ModuleHandlerTest extends KernelTestBase {
// Uninstalling help needs entity_test to be un-installable.
try {
$message = 'ModuleInstaller::uninstall() throws ModuleUninstallValidatorException upon uninstalling a module which does not pass validation.';
- $this->moduleInstaller()->uninstall(array('help'));
+ $this->moduleInstaller()->uninstall(['help']);
$this->fail($message);
}
catch (ModuleUninstallValidatorException $e) {
@@ -250,7 +250,7 @@ class ModuleHandlerTest extends KernelTestBase {
// Deleting the entity.
$entity->delete();
- $result = $this->moduleInstaller()->uninstall(array('help'));
+ $result = $this->moduleInstaller()->uninstall(['help']);
$this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.');
$this->assertEqual(drupal_get_installed_schema_version('entity_test'), SCHEMA_UNINSTALLED, "entity_test module was uninstalled.");
}
diff --git a/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php b/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php
index 54aaac277b0..b45a36050f0 100644
--- a/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php
+++ b/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php
@@ -37,7 +37,7 @@ class MigrateDateFormatTest extends MigrateDrupal6TestBase {
// Test that we can re-import using the EntityDateFormat destination.
Database::getConnection('default', 'migrate')
->update('variable')
- ->fields(array('value' => serialize('\S\H\O\R\T d/m/Y - H:i')))
+ ->fields(['value' => serialize('\S\H\O\R\T d/m/Y - H:i')])
->condition('name', 'date_format_short')
->execute();
diff --git a/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php b/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
index aff0c3f0f43..51c93778937 100644
--- a/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
+++ b/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
@@ -36,7 +36,7 @@ EOT;
// Test that we can re-import using the ConfigEntityBase destination.
Database::getConnection('default', 'migrate')
->update('menu_custom')
- ->fields(array('title' => 'Home Navigation'))
+ ->fields(['title' => 'Home Navigation'])
->condition('menu_name', 'navigation')
->execute();
diff --git a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
index 4a03afe2e22..455be2ad147 100644
--- a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
+++ b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
@@ -51,7 +51,7 @@ class MigrateMenuTest extends MigrateDrupal7TestBase {
// Test that we can re-import using the ConfigEntityBase destination.
Database::getConnection('default', 'migrate')
->update('menu_custom')
- ->fields(array('title' => 'Home Navigation'))
+ ->fields(['title' => 'Home Navigation'])
->condition('menu_name', 'navigation')
->execute();
diff --git a/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php b/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php
index 8adee9d929d..4d1c258b568 100644
--- a/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php
+++ b/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php
@@ -57,19 +57,19 @@ class PhpStorageFactoryTest extends KernelTestBase {
$this->assertTrue($php instanceof MockPhpStorage, 'A MockPhpStorage instance was returned from overridden settings.');
// Test that the name is used for the bin when it is NULL.
- $this->setSettings('test', array('bin' => NULL));
+ $this->setSettings('test', ['bin' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
$this->assertSame('test', $php->getConfigurationValue('bin'), 'Name value was used for bin.');
// Test that a default directory is set if it's empty.
- $this->setSettings('test', array('directory' => NULL));
+ $this->setSettings('test', ['directory' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
$this->assertSame(PublicStream::basePath() . '/php', $php->getConfigurationValue('directory'), 'Default file directory was used.');
// Test that a default storage class is set if it's empty.
- $this->setSettings('test', array('class' => NULL));
+ $this->setSettings('test', ['class' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MTimeProtectedFileStorage, 'An MTimeProtectedFileStorage instance was returned from overridden settings with no class.');
@@ -79,7 +79,7 @@ class PhpStorageFactoryTest extends KernelTestBase {
$this->assertNotEquals('mock hash salt', $php->getConfigurationValue('secret'), 'The default secret is not used if a secret is set in the overridden settings.');
// Test that a default secret is set if it's empty.
- $this->setSettings('test', array('secret' => NULL));
+ $this->setSettings('test', ['secret' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertSame('mock hash salt', $php->getConfigurationValue('secret'), 'The default secret is used if one is not set in the overridden settings.');
}
@@ -92,13 +92,13 @@ class PhpStorageFactoryTest extends KernelTestBase {
* @param array $configuration
* An array of configuration to set. Will be merged with default values.
*/
- protected function setSettings($name = 'default', array $configuration = array()) {
- $settings['php_storage'][$name] = $configuration + array(
+ protected function setSettings($name = 'default', array $configuration = []) {
+ $settings['php_storage'][$name] = $configuration + [
'class' => 'Drupal\system\PhpStorage\MockPhpStorage',
'directory' => 'tmp://',
'secret' => $this->randomString(),
'bin' => 'test',
- );
+ ];
$settings['hash_salt'] = 'mock hash salt';
new Settings($settings);
}
diff --git a/core/modules/system/tests/src/Kernel/Render/ClassyTest.php b/core/modules/system/tests/src/Kernel/Render/ClassyTest.php
index 76cf23ee634..776cb2e672f 100644
--- a/core/modules/system/tests/src/Kernel/Render/ClassyTest.php
+++ b/core/modules/system/tests/src/Kernel/Render/ClassyTest.php
@@ -14,7 +14,7 @@ class ClassyTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system', 'twig_theme_test');
+ public static $modules = ['system', 'twig_theme_test'];
/**
* {@inheritdoc}
@@ -39,9 +39,9 @@ class ClassyTest extends KernelTestBase {
function testClassyTheme() {
drupal_set_message('An error occurred', 'error');
drupal_set_message('But then something nice happened');
- $messages = array(
+ $messages = [
'#type' => 'status_messages',
- );
+ ];
$this->render($messages);
$this->assertNoText('custom-test-messages-class', 'The custom class attribute value added in the status messages preprocess function is not displayed as page content.');
}
diff --git a/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php b/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php
index c90d22663d3..8a292e502d4 100644
--- a/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php
+++ b/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php
@@ -51,10 +51,10 @@ class DbImportCommandTest extends KernelTestBase {
* @requires extension pdo_sqlite
*/
public function testDbImportCommand() {
- $connection_info = array(
+ $connection_info = [
'driver' => 'sqlite',
'database' => ':memory:',
- );
+ ];
Database::addConnectionInfo($this->databasePrefix, 'default', $connection_info);
$command = new DbImportCommand();
diff --git a/core/modules/system/tests/src/Kernel/System/CronQueueTest.php b/core/modules/system/tests/src/Kernel/System/CronQueueTest.php
index c51ee5a87af..649a2c75265 100644
--- a/core/modules/system/tests/src/Kernel/System/CronQueueTest.php
+++ b/core/modules/system/tests/src/Kernel/System/CronQueueTest.php
@@ -55,7 +55,7 @@ class CronQueueTest extends KernelTestBase {
$queue = $this->container->get('queue')->get('cron_queue_test_exception');
// Enqueue an item for processing.
- $queue->createItem(array($this->randomMachineName() => $this->randomMachineName()));
+ $queue->createItem([$this->randomMachineName() => $this->randomMachineName()]);
// Run cron; the worker for this queue should throw an exception and handle
// it.
diff --git a/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php b/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
index 8e6f79e010d..f8963273a61 100644
--- a/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
+++ b/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
@@ -11,7 +11,7 @@ use Drupal\KernelTests\KernelTestBase;
*/
class InfoAlterTest extends KernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Tests that theme .info.yml data is rebuild after enabling a module.
@@ -26,7 +26,7 @@ class InfoAlterTest extends KernelTestBase {
$this->assertFalse(isset($info['node']->info['required']), 'Before the module_required_test is installed the node module is not required.');
// Enable the test module.
- \Drupal::service('module_installer')->install(array('module_required_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_required_test'], FALSE);
$this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_required_test'), 'Test required module is enabled.');
$info = system_rebuild_module_data();
diff --git a/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
index 040cf1a353b..b334e641225 100644
--- a/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
+++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
@@ -29,25 +29,25 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
*/
public function testSystemTokenRecognition() {
// Generate prefixes and suffixes for the token context.
- $tests = array(
- array('prefix' => 'this is the ', 'suffix' => ' site'),
- array('prefix' => 'this is the', 'suffix' => 'site'),
- array('prefix' => '[', 'suffix' => ']'),
- array('prefix' => '', 'suffix' => ']]]'),
- array('prefix' => '[[[', 'suffix' => ''),
- array('prefix' => ':[:', 'suffix' => '--]'),
- array('prefix' => '-[-', 'suffix' => ':]:'),
- array('prefix' => '[:', 'suffix' => ']'),
- array('prefix' => '[site:', 'suffix' => ':name]'),
- array('prefix' => '[site:', 'suffix' => ']'),
- );
+ $tests = [
+ ['prefix' => 'this is the ', 'suffix' => ' site'],
+ ['prefix' => 'this is the', 'suffix' => 'site'],
+ ['prefix' => '[', 'suffix' => ']'],
+ ['prefix' => '', 'suffix' => ']]]'],
+ ['prefix' => '[[[', 'suffix' => ''],
+ ['prefix' => ':[:', 'suffix' => '--]'],
+ ['prefix' => '-[-', 'suffix' => ':]:'],
+ ['prefix' => '[:', 'suffix' => ']'],
+ ['prefix' => '[site:', 'suffix' => ':name]'],
+ ['prefix' => '[site:', 'suffix' => ']'],
+ ];
// Check if the token is recognized in each of the contexts.
foreach ($tests as $test) {
$input = $test['prefix'] . '[site:name]' . $test['suffix'];
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
- $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()));
- $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input)));
+ $output = $this->tokenService->replace($input, [], ['langcode' => $this->interfaceLanguage->getId()]);
+ $this->assertTrue($output == $expected, format_string('Token recognized in string %string', ['%string' => $input]));
}
// Test token replacement when the string contains no tokens.
@@ -67,12 +67,12 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
// Replace with the clear parameter, only the valid token should remain.
$target = Html::escape($this->config('system.site')->get('name'));
- $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE));
+ $result = $this->tokenService->replace($source, [], ['langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE]);
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
$target .= '[user:name]';
$target .= '[bogus:token]';
- $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId()));
+ $result = $this->tokenService->replace($source, [], ['langcode' => $this->interfaceLanguage->getId()]);
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
}
@@ -80,10 +80,10 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
* Tests the generation of all system site information tokens.
*/
public function testSystemSiteTokenReplacement() {
- $url_options = array(
+ $url_options = [
'absolute' => TRUE,
'language' => $this->interfaceLanguage,
- );
+ ];
$slogan = '<blink>Slogan</blink>';
$safe_slogan = Xss::filterAdmin($slogan);
@@ -98,12 +98,12 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$tests['[site:name]'] = Html::escape($config->get('name'));
$tests['[site:slogan]'] = $safe_slogan;
$tests['[site:mail]'] = $config->get('mail');
$tests['[site:url]'] = \Drupal::url('<front>', [], $url_options);
- $tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', \Drupal::url('<front>', [], $url_options));
+ $tests['[site:url-brief]'] = preg_replace(['!^https?://!', '!/$!'], '', \Drupal::url('<front>', [], $url_options));
$tests['[site:login-url]'] = \Drupal::url('user.page', [], $url_options);
$base_bubbleable_metadata = new BubbleableMetadata();
@@ -122,7 +122,7 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata);
+ $output = $this->tokenService->replace($input, [], ['langcode' => $this->interfaceLanguage->getId()], $bubbleable_metadata);
$this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
@@ -136,21 +136,21 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
$date = REQUEST_TIME - 3600;
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$date_formatter = \Drupal::service('date.formatter');
$tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->getId());
- $tests['[date:since]'] = $date_formatter->formatTimeDiffSince($date, array('langcode' => $this->interfaceLanguage->getId()));
+ $tests['[date:since]'] = $date_formatter->formatTimeDiffSince($date, ['langcode' => $this->interfaceLanguage->getId()]);
$tests['[date:raw]'] = Xss::filter($date);
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
- $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->getId()));
- $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input)));
+ $output = $this->tokenService->replace($input, ['date' => $date], ['langcode' => $this->interfaceLanguage->getId()]);
+ $this->assertEqual($output, $expected, format_string('Date token %token replaced.', ['%token' => $input]));
}
}
diff --git a/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php
index 0e2a3fc616f..2c833906048 100644
--- a/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php
+++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php
@@ -28,12 +28,12 @@ abstract class TokenReplaceKernelTestBase extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
protected function setUp() {
parent::setUp();
// Install default system configuration.
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
\Drupal::service('router.builder')->rebuild();
$this->interfaceLanguage = \Drupal::languageManager()->getCurrentLanguage();
diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index eb095a78076..d1eb8fb903e 100644
--- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -94,7 +94,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->requestMatcher = $this->getMock('\Symfony\Component\Routing\Matcher\RequestMatcherInterface');
- $config_factory = $this->getConfigFactoryStub(array('system.site' => array('front' => 'test_frontpage')));
+ $config_factory = $this->getConfigFactoryStub(['system.site' => ['front' => 'test_frontpage']]);
$this->pathProcessor = $this->getMock('\Drupal\Core\PathProcessor\InboundPathProcessorInterface');
$this->context = $this->getMock('\Drupal\Core\Routing\RequestContext');
@@ -182,11 +182,11 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->returnCallback(function(Request $request) use ($route_1) {
if ($request->getPathInfo() == '/example') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'example',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
}));
@@ -218,18 +218,18 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->returnCallback(function(Request $request) use ($route_1, $route_2) {
if ($request->getPathInfo() == '/example/bar') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'example_bar',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
elseif ($request->getPathInfo() == '/example') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'example',
RouteObjectInterface::ROUTE_OBJECT => $route_2,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
}));
@@ -286,11 +286,11 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
* @see \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithException()
*/
public function providerTestBuildWithException() {
- return array(
- array('Drupal\Core\ParamConverter\ParamNotConvertedException', ''),
- array('Symfony\Component\Routing\Exception\MethodNotAllowedException', array()),
- array('Symfony\Component\Routing\Exception\ResourceNotFoundException', ''),
- );
+ return [
+ ['Drupal\Core\ParamConverter\ParamNotConvertedException', ''],
+ ['Symfony\Component\Routing\Exception\MethodNotAllowedException', []],
+ ['Symfony\Component\Routing\Exception\ResourceNotFoundException', ''],
+ ];
}
/**
@@ -310,7 +310,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->requestMatcher->expects($this->any())
->method('matchRequest')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
@@ -348,11 +348,11 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->returnCallback(function(Request $request) use ($route_1) {
if ($request->getPathInfo() == '/user/1') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'user_page',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
}));
diff --git a/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php b/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php
index fd2b88495e6..0dd7510e89a 100644
--- a/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php
+++ b/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php
@@ -45,11 +45,11 @@ class InstallTranslationFilePatternTest extends UnitTestCase {
* @return array
*/
public function providerValidTranslationFiles() {
- return array(
- array('hu', 'drupal-8.0.0-alpha1.hu.po'),
- array('ta', 'drupal-8.10.10-beta12.ta.po'),
- array('hi', 'drupal-8.0.0.hi.po'),
- );
+ return [
+ ['hu', 'drupal-8.0.0-alpha1.hu.po'],
+ ['ta', 'drupal-8.10.10-beta12.ta.po'],
+ ['hi', 'drupal-8.0.0.hi.po'],
+ ];
}
/**
@@ -64,13 +64,13 @@ class InstallTranslationFilePatternTest extends UnitTestCase {
* @return array
*/
public function providerInvalidTranslationFiles() {
- return array(
- array('hu', 'drupal-alpha1-*-hu.po'),
- array('ta', 'drupal-beta12.ta'),
- array('hi', 'drupal-hi.po'),
- array('de', 'drupal-dummy-de.po'),
- array('hu', 'drupal-10.0.1.alpha1-hu.po'),
- );
+ return [
+ ['hu', 'drupal-alpha1-*-hu.po'],
+ ['ta', 'drupal-beta12.ta'],
+ ['hi', 'drupal-hi.po'],
+ ['de', 'drupal-dummy-de.po'],
+ ['hu', 'drupal-10.0.1.alpha1-hu.po'],
+ ];
}
}
diff --git a/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php b/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
index 9f0afc62fc2..c632a3e5530 100644
--- a/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
+++ b/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
@@ -25,20 +25,20 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
parent::setUp();
- $this->directoryList = array(
+ $this->directoryList = [
'system' => 'core/modules/system',
- );
+ ];
$this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme = new Extension($this->root, 'theme', '/core/themes/bartik', 'bartik.info.yml');
$theme->status = 1;
- $theme->info = array('name' => 'bartik');
+ $theme->info = ['name' => 'bartik'];
$this->themeHandler->expects($this->any())
->method('listInfo')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'bartik' => $theme,
- )));
+ ]));
$this->themeHandler->expects($this->any())
->method('hasUi')
->with('bartik')
@@ -59,13 +59,13 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getSystemAdminRoutes() {
- return array(
- array('system.admin_content', array(array('system.admin_content'))),
- array('system.theme_settings_theme', array(
- array('system.themes_page', 'system.theme_settings'),
- array('system.theme_settings_global', 'system.theme_settings_theme:bartik'),
- )),
- );
+ return [
+ ['system.admin_content', [['system.admin_content']]],
+ ['system.theme_settings_theme', [
+ ['system.themes_page', 'system.theme_settings'],
+ ['system.theme_settings_global', 'system.theme_settings_theme:bartik'],
+ ]],
+ ];
}
}
diff --git a/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php b/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php
index 90696fda4e5..689c1782abe 100644
--- a/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php
+++ b/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php
@@ -53,21 +53,21 @@ class MachineNameControllerTest extends UnitTestCase {
* - The expected content of the JSONresponse.
*/
public function providerTestMachineNameController() {
- $valid_data = array(
- array(array('text' => 'Bob', 'langcode' => 'en'), '"Bob"'),
- array(array('text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE), '"bob"'),
- array(array('text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob'), '"Alice"'),
- array(array('text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Tom'), '"Bob"'),
- array(array('text' => 'Äwesome', 'langcode' => 'en', 'lowercase' => TRUE), '"awesome"'),
- array(array('text' => 'Äwesome', 'langcode' => 'de', 'lowercase' => TRUE), '"aewesome"'),
+ $valid_data = [
+ [['text' => 'Bob', 'langcode' => 'en'], '"Bob"'],
+ [['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE], '"bob"'],
+ [['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob'], '"Alice"'],
+ [['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Tom'], '"Bob"'],
+ [['text' => 'Äwesome', 'langcode' => 'en', 'lowercase' => TRUE], '"awesome"'],
+ [['text' => 'Äwesome', 'langcode' => 'de', 'lowercase' => TRUE], '"aewesome"'],
// Tests special characters replacement in the input text.
- array(array('text' => 'B?!"@\/-ob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.]+'), '"b_ob_e"'),
+ [['text' => 'B?!"@\/-ob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.]+'], '"b_ob_e"'],
// Tests @ character in the replace_pattern regex.
- array(array('text' => 'Bob@e\0', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.@]+'), '"bob@e_0"'),
+ [['text' => 'Bob@e\0', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.@]+'], '"bob@e_0"'],
// Tests null byte in the replace_pattern regex.
- array(array('text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"), '"bob"'),
- array(array('text' => 'Bob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"), '"fail()"'),
- );
+ [['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"bob"'],
+ [['text' => 'Bob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"fail()"'],
+ ];
$valid_data = array_map(function ($data) {
if (isset($data[0]['replace_pattern'])) {
diff --git a/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
index 04666dc15d6..21cf116da38 100644
--- a/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
+++ b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
@@ -21,7 +21,7 @@ function nyan_cat_init(Extension $theme) {
* Implements hook_theme().
*/
function nyan_cat_theme($existing, $type, $theme, $path) {
- $templates = drupal_find_theme_functions($existing, array($theme));
+ $templates = drupal_find_theme_functions($existing, [$theme]);
$templates += drupal_find_theme_templates($existing, '.nyan-cat.html', $path);
return $templates;
}
diff --git a/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme b/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
index cd312dbcb7d..78333a9abaf 100644
--- a/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
+++ b/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
@@ -23,7 +23,7 @@ function test_subtheme_views_post_render(ViewExecutable $view, &$output, CachePl
// We append the function name to the title for test to check for.
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
if ($view->id() == 'test_page_display') {
- $output['#rows'][0]['#title'] = t('%total_rows items found.', array('%total_rows' => $view->total_rows));
+ $output['#rows'][0]['#title'] = t('%total_rows items found.', ['%total_rows' => $view->total_rows]);
}
}
diff --git a/core/modules/taxonomy/src/Controller/TaxonomyController.php b/core/modules/taxonomy/src/Controller/TaxonomyController.php
index 843cdd7a4ce..27b1ec0c86a 100644
--- a/core/modules/taxonomy/src/Controller/TaxonomyController.php
+++ b/core/modules/taxonomy/src/Controller/TaxonomyController.php
@@ -22,7 +22,7 @@ class TaxonomyController extends ControllerBase {
* The taxonomy term add form.
*/
public function addForm(VocabularyInterface $taxonomy_vocabulary) {
- $term = $this->entityManager()->getStorage('taxonomy_term')->create(array('vid' => $taxonomy_vocabulary->id()));
+ $term = $this->entityManager()->getStorage('taxonomy_term')->create(['vid' => $taxonomy_vocabulary->id()]);
return $this->entityFormBuilder()->getForm($term);
}
diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php
index 7aca19f108a..535fa8c4251 100644
--- a/core/modules/taxonomy/src/Entity/Term.php
+++ b/core/modules/taxonomy/src/Entity/Term.php
@@ -61,7 +61,7 @@ class Term extends ContentEntityBase implements TermInterface {
parent::postDelete($storage, $entities);
// See if any of the term's children are about to be become orphans.
- $orphans = array();
+ $orphans = [];
foreach (array_keys($entities) as $tid) {
if ($children = $storage->loadChildren($tid)) {
foreach ($children as $child) {
@@ -92,7 +92,7 @@ class Term extends ContentEntityBase implements TermInterface {
// Only change the parents if a value is set, keep the existing values if
// not.
if (isset($this->parent->target_id)) {
- $storage->deleteTermHierarchy(array($this->id()));
+ $storage->deleteTermHierarchy([$this->id()]);
$storage->updateTermHierarchy($this);
}
}
@@ -119,30 +119,30 @@ class Term extends ContentEntityBase implements TermInterface {
->setTranslatable(TRUE)
->setRequired(TRUE)
->setSetting('max_length', 255)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['description'] = BaseFieldDefinition::create('text_long')
->setLabel(t('Description'))
->setTranslatable(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('view', TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['weight'] = BaseFieldDefinition::create('integer')
diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php
index a2d7eef8a57..b0d1ac13d28 100644
--- a/core/modules/taxonomy/src/Entity/Vocabulary.php
+++ b/core/modules/taxonomy/src/Entity/Vocabulary.php
@@ -140,13 +140,13 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
return;
}
- $vocabularies = array();
+ $vocabularies = [];
foreach ($entities as $vocabulary) {
$vocabularies[$vocabulary->id()] = $vocabulary->id();
}
// Load all Taxonomy module fields and delete those which use only this
// vocabulary.
- $field_storages = entity_load_multiple_by_properties('field_storage_config', array('module' => 'taxonomy'));
+ $field_storages = entity_load_multiple_by_properties('field_storage_config', ['module' => 'taxonomy']);
foreach ($field_storages as $field_storage) {
$modified_storage = FALSE;
// Term reference fields may reference terms from more than one
diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php
index 4c8cee3fb74..b5014bbe796 100644
--- a/core/modules/taxonomy/src/Form/OverviewTerms.php
+++ b/core/modules/taxonomy/src/Form/OverviewTerms.php
@@ -101,10 +101,10 @@ class OverviewTerms extends FormBase {
$forward_step = 0;
// An array of the terms to be displayed on this page.
- $current_page = array();
+ $current_page = [];
$delta = 0;
- $term_deltas = array();
+ $term_deltas = [];
$tree = $this->storageController->loadTree($taxonomy_vocabulary->id(), 0, NULL, TRUE);
$tree_index = 0;
do {
@@ -199,93 +199,93 @@ class OverviewTerms extends FormBase {
$destination = $this->getDestinationArray();
$row_position = 0;
// Build the actual form.
- $form['terms'] = array(
+ $form['terms'] = [
'#type' => 'table',
- '#header' => array($this->t('Name'), $this->t('Weight'), $this->t('Operations')),
- '#empty' => $this->t('No terms available. <a href=":link">Add term</a>.', array(':link' => $this->url('entity.taxonomy_term.add_form', array('taxonomy_vocabulary' => $taxonomy_vocabulary->id())))),
- '#attributes' => array(
+ '#header' => [$this->t('Name'), $this->t('Weight'), $this->t('Operations')],
+ '#empty' => $this->t('No terms available. <a href=":link">Add term</a>.', [':link' => $this->url('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $taxonomy_vocabulary->id()])]),
+ '#attributes' => [
'id' => 'taxonomy',
- ),
- );
+ ],
+ ];
foreach ($current_page as $key => $term) {
/** @var $term \Drupal\Core\Entity\EntityInterface */
$form['terms'][$key]['#term'] = $term;
- $indentation = array();
+ $indentation = [];
if (isset($term->depth) && $term->depth > 0) {
- $indentation = array(
+ $indentation = [
'#theme' => 'indentation',
'#size' => $term->depth,
- );
+ ];
}
- $form['terms'][$key]['term'] = array(
+ $form['terms'][$key]['term'] = [
'#prefix' => !empty($indentation) ? drupal_render($indentation) : '',
'#type' => 'link',
'#title' => $term->getName(),
'#url' => $term->urlInfo(),
- );
+ ];
if ($taxonomy_vocabulary->getHierarchy() != VocabularyInterface::HIERARCHY_MULTIPLE && count($tree) > 1) {
$parent_fields = TRUE;
- $form['terms'][$key]['term']['tid'] = array(
+ $form['terms'][$key]['term']['tid'] = [
'#type' => 'hidden',
'#value' => $term->id(),
- '#attributes' => array(
- 'class' => array('term-id'),
- ),
- );
- $form['terms'][$key]['term']['parent'] = array(
+ '#attributes' => [
+ 'class' => ['term-id'],
+ ],
+ ];
+ $form['terms'][$key]['term']['parent'] = [
'#type' => 'hidden',
// Yes, default_value on a hidden. It needs to be changeable by the
// javascript.
'#default_value' => $term->parents[0],
- '#attributes' => array(
- 'class' => array('term-parent'),
- ),
- );
- $form['terms'][$key]['term']['depth'] = array(
+ '#attributes' => [
+ 'class' => ['term-parent'],
+ ],
+ ];
+ $form['terms'][$key]['term']['depth'] = [
'#type' => 'hidden',
// Same as above, the depth is modified by javascript, so it's a
// default_value.
'#default_value' => $term->depth,
- '#attributes' => array(
- 'class' => array('term-depth'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['term-depth'],
+ ],
+ ];
}
- $form['terms'][$key]['weight'] = array(
+ $form['terms'][$key]['weight'] = [
'#type' => 'weight',
'#delta' => $delta,
'#title' => $this->t('Weight for added term'),
'#title_display' => 'invisible',
'#default_value' => $term->getWeight(),
- '#attributes' => array(
- 'class' => array('term-weight'),
- ),
- );
- $operations = array(
- 'edit' => array(
+ '#attributes' => [
+ 'class' => ['term-weight'],
+ ],
+ ];
+ $operations = [
+ 'edit' => [
'title' => $this->t('Edit'),
'query' => $destination,
'url' => $term->urlInfo('edit-form'),
- ),
- 'delete' => array(
+ ],
+ 'delete' => [
'title' => $this->t('Delete'),
'query' => $destination,
'url' => $term->urlInfo('delete-form'),
- ),
- );
+ ],
+ ];
if ($this->moduleHandler->moduleExists('content_translation') && content_translation_translate_access($term)->isAllowed()) {
- $operations['translate'] = array(
+ $operations['translate'] = [
'title' => $this->t('Translate'),
'query' => $destination,
'url' => $term->urlInfo('drupal:content-translation-overview'),
- );
+ ];
}
- $form['terms'][$key]['operations'] = array(
+ $form['terms'][$key]['operations'] = [
'#type' => 'operations',
'#links' => $operations,
- );
+ ];
- $form['terms'][$key]['#attributes']['class'] = array();
+ $form['terms'][$key]['#attributes']['class'] = [];
if ($parent_fields) {
$form['terms'][$key]['#attributes']['class'][] = 'draggable';
}
@@ -314,44 +314,44 @@ class OverviewTerms extends FormBase {
}
if ($parent_fields) {
- $form['terms']['#tabledrag'][] = array(
+ $form['terms']['#tabledrag'][] = [
'action' => 'match',
'relationship' => 'parent',
'group' => 'term-parent',
'subgroup' => 'term-parent',
'source' => 'term-id',
'hidden' => FALSE,
- );
- $form['terms']['#tabledrag'][] = array(
+ ];
+ $form['terms']['#tabledrag'][] = [
'action' => 'depth',
'relationship' => 'group',
'group' => 'term-depth',
'hidden' => FALSE,
- );
+ ];
$form['terms']['#attached']['library'][] = 'taxonomy/drupal.taxonomy';
$form['terms']['#attached']['drupalSettings']['taxonomy'] = [
'backStep' => $back_step,
'forwardStep' => $forward_step,
];
}
- $form['terms']['#tabledrag'][] = array(
+ $form['terms']['#tabledrag'][] = [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'term-weight',
- );
+ ];
if ($taxonomy_vocabulary->getHierarchy() != VocabularyInterface::HIERARCHY_MULTIPLE && count($tree) > 1) {
- $form['actions'] = array('#type' => 'actions', '#tree' => FALSE);
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions', '#tree' => FALSE];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
'#button_type' => 'primary',
- );
- $form['actions']['reset_alphabetical'] = array(
+ ];
+ $form['actions']['reset_alphabetical'] = [
'#type' => 'submit',
- '#submit' => array('::submitReset'),
+ '#submit' => ['::submitReset'],
'#value' => $this->t('Reset to alphabetical'),
- );
+ ];
}
$form['pager_pager'] = ['#type' => 'pager'];
@@ -378,13 +378,13 @@ class OverviewTerms extends FormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Sort term order based on weight.
- uasort($form_state->getValue('terms'), array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($form_state->getValue('terms'), ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
$vocabulary = $form_state->get(['taxonomy', 'vocabulary']);
// Update the current hierarchy type as we go.
$hierarchy = VocabularyInterface::HIERARCHY_DISABLED;
- $changed_terms = array();
+ $changed_terms = [];
$tree = $this->storageController->loadTree($vocabulary->id(), 0, NULL, TRUE);
if (empty($tree)) {
@@ -405,7 +405,7 @@ class OverviewTerms extends FormBase {
}
// Renumber the current page weights and assign any new parents.
- $level_weights = array();
+ $level_weights = [];
foreach ($form_state->getValue('terms') as $tid => $values) {
if (isset($form['terms'][$tid]['#term'])) {
$term = $form['terms'][$tid]['#term'];
diff --git a/core/modules/taxonomy/src/Form/TermDeleteForm.php b/core/modules/taxonomy/src/Form/TermDeleteForm.php
index 22ab19b063c..0e97ff64a4b 100644
--- a/core/modules/taxonomy/src/Form/TermDeleteForm.php
+++ b/core/modules/taxonomy/src/Form/TermDeleteForm.php
@@ -38,7 +38,7 @@ class TermDeleteForm extends ContentEntityDeleteForm {
* {@inheritdoc}
*/
protected function getDeletionMessage() {
- return $this->t('Deleted term %name.', array('%name' => $this->entity->label()));
+ return $this->t('Deleted term %name.', ['%name' => $this->entity->label()]);
}
/**
@@ -54,7 +54,7 @@ class TermDeleteForm extends ContentEntityDeleteForm {
$vocabulary = $storage->load($this->entity->bundle());
// @todo Move to storage http://drupal.org/node/1988712
- taxonomy_check_vocabulary_hierarchy($vocabulary, array('tid' => $term->id()));
+ taxonomy_check_vocabulary_hierarchy($vocabulary, ['tid' => $term->id()]);
}
}
diff --git a/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php b/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php
index bada5d6eadc..7c91b7868cb 100644
--- a/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php
+++ b/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php
@@ -20,7 +20,7 @@ class VocabularyDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete the vocabulary %title?', array('%title' => $this->entity->label()));
+ return $this->t('Are you sure you want to delete the vocabulary %title?', ['%title' => $this->entity->label()]);
}
/**
@@ -34,7 +34,7 @@ class VocabularyDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
protected function getDeletionMessage() {
- return $this->t('Deleted vocabulary %name.', array('%name' => $this->entity->label()));
+ return $this->t('Deleted vocabulary %name.', ['%name' => $this->entity->label()]);
}
}
diff --git a/core/modules/taxonomy/src/Form/VocabularyResetForm.php b/core/modules/taxonomy/src/Form/VocabularyResetForm.php
index fb33e358e80..e036ff91768 100644
--- a/core/modules/taxonomy/src/Form/VocabularyResetForm.php
+++ b/core/modules/taxonomy/src/Form/VocabularyResetForm.php
@@ -49,7 +49,7 @@ class VocabularyResetForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to reset the vocabulary %title to alphabetical order?', array('%title' => $this->entity->label()));
+ return $this->t('Are you sure you want to reset the vocabulary %title to alphabetical order?', ['%title' => $this->entity->label()]);
}
/**
@@ -80,8 +80,8 @@ class VocabularyResetForm extends EntityConfirmFormBase {
parent::submitForm($form, $form_state);
$this->termStorage->resetWeights($this->entity->id());
- drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label())));
- $this->logger('taxonomy')->notice('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()));
+ drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', ['%name' => $this->entity->label()]));
+ $this->logger('taxonomy')->notice('Reset vocabulary %name to alphabetical order.', ['%name' => $this->entity->label()]);
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
index 7dd4aa2d6e5..b8f4d14fbe1 100644
--- a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
+++ b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
@@ -53,7 +53,7 @@ class TermSelection extends DefaultSelection {
return parent::getReferenceableEntities($match, $match_operator, $limit);
}
- $options = array();
+ $options = [];
$bundles = $this->entityManager->getBundleInfo('taxonomy_term');
$handler_settings = $this->configuration['handler_settings'];
diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
index 11e8325797a..0d0d9170b57 100644
--- a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
+++ b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
@@ -25,16 +25,16 @@ class EntityReferenceTaxonomyTermRssFormatter extends EntityReferenceFormatterBa
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$parent_entity = $items->getEntity();
- $elements = array();
+ $elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
- $parent_entity->rss_elements[] = array(
+ $parent_entity->rss_elements[] = [
'key' => 'category',
'value' => $entity->label(),
- 'attributes' => array(
- 'domain' => $entity->id() ? \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $entity->id()], array('absolute' => TRUE)) : '',
- ),
- );
+ 'attributes' => [
+ 'domain' => $entity->id() ? \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $entity->id()], ['absolute' => TRUE]) : '',
+ ],
+ ];
}
return $elements;
diff --git a/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php b/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php
index c3035c4312e..2d4e719d36e 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php
@@ -20,20 +20,20 @@ class TaxonomyTermReference extends CckFieldPluginBase {
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
- $process = array(
+ $process = [
'plugin' => 'iterator',
'source' => $field_name,
- 'process' => array(
+ 'process' => [
'target_id' => 'tid',
- ),
- );
+ ],
+ ];
$migration->setProcessOfProperty($field_name, $process);
}
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/Term.php b/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
index ce468a29dd7..545d205ba9f 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
@@ -64,14 +64,14 @@ class Term extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'tid' => $this->t('The term ID.'),
'vid' => $this->t('Existing term VID'),
'name' => $this->t('The name of the term.'),
'description' => $this->t('The term description.'),
'weight' => $this->t('Weight'),
'parent' => $this->t("The Drupal term IDs of the term's parents."),
- );
+ ];
if ($this->getModuleSchemaVersion('taxonomy') >= 7000) {
$fields['format'] = $this->t('Format of the term description.');
}
@@ -84,7 +84,7 @@ class Term extends DrupalSqlBase {
public function prepareRow(Row $row) {
// Find parents for this row.
$parents = $this->select($this->termHierarchyTable, 'th')
- ->fields('th', array('parent', 'tid'))
+ ->fields('th', ['parent', 'tid'])
->condition('tid', $row->getSourceProperty('tid'))
->execute()
->fetchCol();
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php b/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php
index 2635aaa7084..2b1c806f2b2 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php
@@ -26,10 +26,10 @@ class TermNode extends DrupalSqlBase {
public function query() {
$query = $this->select('term_node', 'tn')
->distinct()
- ->fields('tn', array('nid', 'vid'))
- ->fields('n', array('type'));
+ ->fields('tn', ['nid', 'vid'])
+ ->fields('n', ['type']);
// Because this is an inner join it enforces the current revision.
- $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
+ $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', [':vid' => $this->configuration['vid']]);
$query->innerJoin('node', 'n', static::JOIN);
return $query;
}
@@ -38,11 +38,11 @@ class TermNode extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'nid' => $this->t('The node revision ID.'),
'vid' => $this->t('The node revision ID.'),
'tid' => $this->t('The term ID.'),
- );
+ ];
}
/**
@@ -51,10 +51,10 @@ class TermNode extends DrupalSqlBase {
public function prepareRow(Row $row) {
// Select the terms belonging to the revision selected.
$query = $this->select('term_node', 'tn')
- ->fields('tn', array('tid'))
+ ->fields('tn', ['tid'])
->condition('n.nid', $row->getSourceProperty('nid'));
$query->join('node', 'n', static::JOIN);
- $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
+ $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', [':vid' => $this->configuration['vid']]);
$row->setSourceProperty('tid', $query->execute()->fetchCol());
return parent::prepareRow($row);
}
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
index 2573033889c..714fa933104 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
@@ -21,7 +21,7 @@ class Vocabulary extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('vocabulary', 'v')
- ->fields('v', array(
+ ->fields('v', [
'vid',
'name',
'description',
@@ -33,7 +33,7 @@ class Vocabulary extends DrupalSqlBase {
'tags',
'module',
'weight',
- ));
+ ]);
return $query;
}
@@ -41,7 +41,7 @@ class Vocabulary extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'vid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description' => $this->t('The description of the vocabulary.'),
@@ -54,7 +54,7 @@ class Vocabulary extends DrupalSqlBase {
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
'parents' => $this->t("The Drupal term IDs of the term's parents."),
'node_types' => $this->t('The names of the node types the vocabulary may be used with.'),
- );
+ ];
}
/**
@@ -63,7 +63,7 @@ class Vocabulary extends DrupalSqlBase {
public function prepareRow(Row $row) {
// Find node types for this row.
$node_types = $this->select('vocabulary_node_types', 'nt')
- ->fields('nt', array('type', 'vid'))
+ ->fields('nt', ['type', 'vid'])
->condition('vid', $row->getSourceProperty('vid'))
->execute()
->fetchCol();
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php b/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
index ac7a2fe1cc8..40a0094afe2 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
@@ -18,7 +18,7 @@ class VocabularyPerType extends Vocabulary {
public function query() {
$query = parent::query();
$query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
- $query->fields('nt', array('type'));
+ $query->fields('nt', ['type']);
return $query;
}
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php b/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
index e9eb4aa4476..31103a8be13 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
@@ -19,7 +19,7 @@ class Vocabulary extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('taxonomy_vocabulary', 'v')
- ->fields('v', array(
+ ->fields('v', [
'vid',
'name',
'description',
@@ -27,7 +27,7 @@ class Vocabulary extends DrupalSqlBase {
'module',
'weight',
'machine_name',
- ));
+ ]);
return $query;
}
@@ -35,7 +35,7 @@ class Vocabulary extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'vid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description' => $this->t('The description of the vocabulary.'),
@@ -43,7 +43,7 @@ class Vocabulary extends DrupalSqlBase {
'module' => $this->t('Module responsible for the vocabulary.'),
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
'machine_name' => $this->t('Unique machine name of the vocabulary.')
- );
+ ];
}
/**
diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php
index 8ab40e3e668..8d185453325 100644
--- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php
+++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php
@@ -15,7 +15,7 @@ use Drupal\views\Plugin\views\argument\ManyToOne;
class IndexTid extends ManyToOne {
public function titleQuery() {
- $titles = array();
+ $titles = [];
$terms = Term::loadMultiple($this->value);
foreach ($terms as $term) {
$titles[] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
index 97ee5952d9c..a41b8012362 100644
--- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
+++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
@@ -45,27 +45,27 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
protected function defineOptions() {
$options = parent::defineOptions();
- $options['depth'] = array('default' => 0);
- $options['break_phrase'] = array('default' => FALSE);
- $options['use_taxonomy_term_path'] = array('default' => FALSE);
+ $options['depth'] = ['default' => 0];
+ $options['break_phrase'] = ['default' => FALSE];
+ $options['use_taxonomy_term_path'] = ['default' => FALSE];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['depth'] = array(
+ $form['depth'] = [
'#type' => 'weight',
'#title' => $this->t('Depth'),
'#default_value' => $this->options['depth'],
'#description' => $this->t('The depth will match nodes tagged with terms in the hierarchy. For example, if you have the term "fruit" and a child term "apple", with a depth of 1 (or higher) then filtering for the term "fruit" will get nodes that are tagged with "apple" as well as "fruit". If negative, the reverse is true; searching for "apple" will also pick up nodes tagged with "fruit" if depth is -1 (or lower).'),
- );
+ ];
- $form['break_phrase'] = array(
+ $form['break_phrase'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple values'),
'#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3. Due to the number of JOINs it would require, AND will be treated as OR with this filter.'),
'#default_value' => !empty($this->options['break_phrase']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -75,7 +75,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
*/
protected function defaultActions($which = NULL) {
if ($which) {
- if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
+ if (in_array($which, ['ignore', 'not found', 'empty', 'default'])) {
return parent::defaultActions($which);
}
return;
@@ -93,7 +93,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
if (!empty($this->options['break_phrase'])) {
$break = static::breakString($this->argument);
- if ($break->value === array(-1)) {
+ if ($break->value === [-1]) {
return FALSE;
}
diff --git a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
index 33517b15aa1..fa1865474ab 100644
--- a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
+++ b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
@@ -96,11 +96,11 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
protected function defineOptions() {
$options = parent::defineOptions();
- $options['term_page'] = array('default' => TRUE);
- $options['node'] = array('default' => FALSE);
- $options['anyall'] = array('default' => ',');
- $options['limit'] = array('default' => FALSE);
- $options['vids'] = array('default' => array());
+ $options['term_page'] = ['default' => TRUE];
+ $options['node'] = ['default' => FALSE];
+ $options['anyall'] = ['default' => ','];
+ $options['limit'] = ['default' => FALSE];
+ $options['vids'] = ['default' => []];
return $options;
}
@@ -109,67 +109,67 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['term_page'] = array(
+ $form['term_page'] = [
'#type' => 'checkbox',
'#title' => $this->t('Load default filter from term page'),
'#default_value' => $this->options['term_page'],
- );
- $form['node'] = array(
+ ];
+ $form['node'] = [
'#type' => 'checkbox',
'#title' => $this->t('Load default filter from node page, that\'s good for related taxonomy blocks'),
'#default_value' => $this->options['node'],
- );
+ ];
- $form['limit'] = array(
+ $form['limit'] = [
'#type' => 'checkbox',
'#title' => $this->t('Limit terms by vocabulary'),
'#default_value' => $this->options['limit'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $options = array();
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[argument_default][taxonomy_tid][node]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $options = [];
$vocabularies = $this->vocabularyStorage->loadMultiple();
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
- $form['vids'] = array(
+ $form['vids'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vids'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[argument_default][taxonomy_tid][limit]"]' => array('checked' => TRUE),
- ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['anyall'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[argument_default][taxonomy_tid][limit]"]' => ['checked' => TRUE],
+ ':input[name="options[argument_default][taxonomy_tid][node]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['anyall'] = [
'#type' => 'radios',
'#title' => $this->t('Multiple-value handling'),
'#default_value' => $this->options['anyall'],
- '#options' => array(
+ '#options' => [
',' => $this->t('Filter to items that share all terms'),
'+' => $this->t('Filter to items that share any term'),
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ ],
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[argument_default][taxonomy_tid][node]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
- public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) {
+ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) {
// Filter unselected items so we don't unnecessarily store giant arrays.
$options['vids'] = array_filter($options['vids']);
}
@@ -188,7 +188,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
if (!empty($this->options['node'])) {
// Just check, if a node could be detected.
if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) {
- $taxonomy = array();
+ $taxonomy = [];
foreach ($node->getFieldDefinitions() as $field) {
if ($field->getType() == 'entity_reference' && $field->getSetting('target_type') == 'taxonomy_term') {
$taxonomy_terms = $node->{$field->getName()}->referencedEntities();
@@ -199,7 +199,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
}
}
if (!empty($this->options['limit'])) {
- $tids = array();
+ $tids = [];
// filter by vocabulary
foreach ($taxonomy as $tid => $vocab) {
if (!empty($this->options['vids'][$vocab])) {
diff --git a/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php b/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php
index eb30ff5fe99..ac7bad0fad7 100644
--- a/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php
+++ b/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php
@@ -39,7 +39,7 @@ class TermName extends Entity {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['transform'] = array('default' => FALSE);
+ $options['transform'] = ['default' => FALSE];
return $options;
}
@@ -50,11 +50,11 @@ class TermName extends Entity {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['transform'] = array(
+ $form['transform'] = [
'#type' => 'checkbox',
'#title' => $this->t('Transform dashes in URL to spaces in term name filter values'),
'#default_value' => $this->options['transform'],
- );
+ ];
}
/**
@@ -64,7 +64,7 @@ class TermName extends Entity {
if ($this->options['transform']) {
$argument = str_replace('-', ' ', $argument);
}
- $terms = $this->termStorage->loadByProperties(array('name' => $argument));
+ $terms = $this->termStorage->loadByProperties(['name' => $argument]);
if (!$terms) {
// Returned empty array no terms with the name.
diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php
index f33421a9f2f..1bab4461844 100644
--- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php
+++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php
@@ -62,19 +62,19 @@ class TaxonomyIndexTid extends PrerenderList {
// @todo: Wouldn't it be possible to use $this->base_table and no if here?
if ($view->storage->get('base_table') == 'node_field_revision') {
- $this->additional_fields['nid'] = array('table' => 'node_field_revision', 'field' => 'nid');
+ $this->additional_fields['nid'] = ['table' => 'node_field_revision', 'field' => 'nid'];
}
else {
- $this->additional_fields['nid'] = array('table' => 'node_field_data', 'field' => 'nid');
+ $this->additional_fields['nid'] = ['table' => 'node_field_data', 'field' => 'nid'];
}
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['link_to_taxonomy'] = array('default' => TRUE);
- $options['limit'] = array('default' => FALSE);
- $options['vids'] = array('default' => array());
+ $options['link_to_taxonomy'] = ['default' => TRUE];
+ $options['limit'] = ['default' => FALSE];
+ $options['vids'] = ['default' => []];
return $options;
}
@@ -83,36 +83,36 @@ class TaxonomyIndexTid extends PrerenderList {
* Provide "link to term" option.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['link_to_taxonomy'] = array(
+ $form['link_to_taxonomy'] = [
'#title' => $this->t('Link this field to its term page'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_taxonomy']),
- );
+ ];
- $form['limit'] = array(
+ $form['limit'] = [
'#type' => 'checkbox',
'#title' => $this->t('Limit terms by vocabulary'),
'#default_value' => $this->options['limit'],
- );
+ ];
- $options = array();
+ $options = [];
$vocabularies = $this->vocabularyStorage->loadMultiple();
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
- $form['vids'] = array(
+ $form['vids'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vids'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[limit]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[limit]"]' => ['checked' => TRUE],
+ ],
+ ],
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -127,7 +127,7 @@ class TaxonomyIndexTid extends PrerenderList {
public function preRender(&$values) {
$vocabularies = $this->vocabularyStorage->loadMultiple();
$this->field_alias = $this->aliases['nid'];
- $nids = array();
+ $nids = [];
foreach ($values as $result) {
if (!empty($result->{$this->aliases['nid']})) {
$nids[] = $result->{$this->aliases['nid']};
@@ -137,7 +137,7 @@ class TaxonomyIndexTid extends PrerenderList {
if ($nids) {
$vocabs = array_filter($this->options['vids']);
if (empty($this->options['limit'])) {
- $vocabs = array();
+ $vocabs = [];
}
$result = \Drupal::entityManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs);
@@ -169,7 +169,7 @@ class TaxonomyIndexTid extends PrerenderList {
}
protected function addSelfTokens(&$tokens, $item) {
- foreach (array('tid', 'name', 'vocabulary_vid', 'vocabulary') as $token) {
+ foreach (['tid', 'name', 'vocabulary_vid', 'vocabulary'] as $token) {
$tokens['{{ ' . $this->options['id'] . '__' . $token . ' }}'] = isset($item[$token]) ? $item[$token] : '';
}
}
diff --git a/core/modules/taxonomy/src/Plugin/views/field/TermName.php b/core/modules/taxonomy/src/Plugin/views/field/TermName.php
index 2fcd5299a77..0a777e9c1cf 100644
--- a/core/modules/taxonomy/src/Plugin/views/field/TermName.php
+++ b/core/modules/taxonomy/src/Plugin/views/field/TermName.php
@@ -37,7 +37,7 @@ class TermName extends EntityField {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['convert_spaces'] = array('default' => FALSE);
+ $options['convert_spaces'] = ['default' => FALSE];
return $options;
}
@@ -45,11 +45,11 @@ class TermName extends EntityField {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['convert_spaces'] = array(
+ $form['convert_spaces'] = [
'#title' => $this->t('Convert spaces in term names to hyphens'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['convert_spaces']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
index d769bb04d64..a68c3c8c6ce 100644
--- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -94,18 +94,18 @@ class TaxonomyIndexTid extends ManyToOne {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['type'] = array('default' => 'textfield');
- $options['limit'] = array('default' => TRUE);
- $options['vid'] = array('default' => '');
- $options['hierarchy'] = array('default' => FALSE);
- $options['error_message'] = array('default' => TRUE);
+ $options['type'] = ['default' => 'textfield'];
+ $options['limit'] = ['default' => TRUE];
+ $options['vid'] = ['default' => ''];
+ $options['hierarchy'] = ['default' => FALSE];
+ $options['error_message'] = ['default' => TRUE];
return $options;
}
public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
$vocabularies = $this->vocabularyStorage->loadMultiple();
- $options = array();
+ $options = [];
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
@@ -118,56 +118,56 @@ class TaxonomyIndexTid extends ManyToOne {
}
if (empty($this->definition['vocabulary'])) {
- $form['vid'] = array(
+ $form['vid'] = [
'#type' => 'radios',
'#title' => $this->t('Vocabulary'),
'#options' => $options,
'#description' => $this->t('Select which vocabulary to show terms for in the regular options.'),
'#default_value' => $this->options['vid'],
- );
+ ];
}
}
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'radios',
'#title' => $this->t('Selection type'),
- '#options' => array('select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')),
+ '#options' => ['select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')],
'#default_value' => $this->options['type'],
- );
+ ];
- $form['hierarchy'] = array(
+ $form['hierarchy'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show hierarchy in dropdown'),
'#default_value' => !empty($this->options['hierarchy']),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[type]"]' => array('value' => 'select'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[type]"]' => ['value' => 'select'],
+ ],
+ ],
+ ];
}
protected function valueForm(&$form, FormStateInterface $form_state) {
$vocabulary = $this->vocabularyStorage->load($this->options['vid']);
if (empty($vocabulary) && $this->options['limit']) {
- $form['markup'] = array(
+ $form['markup'] = [
'#markup' => '<div class="js-form-item form-item">' . $this->t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
- );
+ ];
return;
}
if ($this->options['type'] == 'textfield') {
- $terms = $this->value ? Term::loadMultiple(($this->value)) : array();
- $form['value'] = array(
- '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->label())) : $this->t('Select terms'),
+ $terms = $this->value ? Term::loadMultiple(($this->value)) : [];
+ $form['value'] = [
+ '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
'#type' => 'textfield',
'#default_value' => EntityAutocomplete::getEntityLabels($terms),
- );
+ ];
if ($this->options['limit']) {
$form['value']['#type'] = 'entity_autocomplete';
$form['value']['#target_type'] = 'taxonomy_term';
- $form['value']['#selection_settings']['target_bundles'] = array($vocabulary->id());
+ $form['value']['#selection_settings']['target_bundles'] = [$vocabulary->id()];
$form['value']['#tags'] = TRUE;
$form['value']['#process_default_value'] = FALSE;
}
@@ -175,18 +175,18 @@ class TaxonomyIndexTid extends ManyToOne {
else {
if (!empty($this->options['hierarchy']) && $this->options['limit']) {
$tree = $this->termStorage->loadTree($vocabulary->id(), 0, NULL, TRUE);
- $options = array();
+ $options = [];
if ($tree) {
foreach ($tree as $term) {
$choice = new \stdClass();
- $choice->option = array($term->id() => str_repeat('-', $term->depth) . \Drupal::entityManager()->getTranslationFromContext($term)->label());
+ $choice->option = [$term->id() => str_repeat('-', $term->depth) . \Drupal::entityManager()->getTranslationFromContext($term)->label()];
$options[] = $choice;
}
}
}
else {
- $options = array();
+ $options = [];
$query = \Drupal::entityQuery('taxonomy_term')
// @todo Sorting on vocabulary properties -
// https://www.drupal.org/node/1821274.
@@ -211,7 +211,7 @@ class TaxonomyIndexTid extends ManyToOne {
$options = $this->reduceValueOptions($options);
if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
- $default_value = array();
+ $default_value = [];
}
}
@@ -225,7 +225,7 @@ class TaxonomyIndexTid extends ManyToOne {
}
// Due to #1464174 there is a chance that array('') was saved in the admin ui.
// Let's choose a safe default value.
- elseif ($default_value == array('')) {
+ elseif ($default_value == ['']) {
$default_value = 'All';
}
else {
@@ -234,14 +234,14 @@ class TaxonomyIndexTid extends ManyToOne {
}
}
}
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'select',
- '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->label())) : $this->t('Select terms'),
+ '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
'#multiple' => TRUE,
'#options' => $options,
'#size' => min(9, count($options)),
'#default_value' => $default_value,
- );
+ ];
$user_input = $form_state->getUserInput();
if ($exposed && isset($identifier) && !isset($user_input[$identifier])) {
@@ -265,13 +265,13 @@ class TaxonomyIndexTid extends ManyToOne {
return;
}
- $tids = array();
- if ($values = $form_state->getValue(array('options', 'value'))) {
+ $tids = [];
+ if ($values = $form_state->getValue(['options', 'value'])) {
foreach ($values as $value) {
$tids[] = $value['target_id'];
}
}
- $form_state->setValue(array('options', 'value'), $tids);
+ $form_state->setValue(['options', 'value'], $tids);
}
public function acceptExposedInput($input) {
@@ -348,16 +348,16 @@ class TaxonomyIndexTid extends ManyToOne {
if ($this->options['type'] != 'select') {
unset($form['expose']['reduce']);
}
- $form['error_message'] = array(
+ $form['error_message'] = [
'#type' => 'checkbox',
'#title' => $this->t('Display error message'),
'#default_value' => !empty($this->options['error_message']),
- );
+ ];
}
public function adminSummary() {
// set up $this->valueOptions for the parent summary
- $this->valueOptions = array();
+ $this->valueOptions = [];
if ($this->value) {
$this->value = array_filter($this->value);
diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
index ecd32eb80e8..93115584c8c 100644
--- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
@@ -18,15 +18,15 @@ use Drupal\Core\Form\FormStateInterface;
class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
public function operatorOptions($which = 'title') {
- return array(
+ return [
'or' => $this->t('Is one of'),
- );
+ ];
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['depth'] = array('default' => 0);
+ $options['depth'] = ['default' => 0];
return $options;
}
@@ -34,12 +34,12 @@ class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildExtraOptionsForm($form, $form_state);
- $form['depth'] = array(
+ $form['depth'] = [
'#type' => 'weight',
'#title' => $this->t('Depth'),
'#default_value' => $this->options['depth'],
'#description' => $this->t('The depth will match nodes tagged with terms in the hierarchy. For example, if you have the term "fruit" and a child term "apple", with a depth of 1 (or higher) then filtering for the term "fruit" will get nodes that are tagged with "apple" as well as "fruit". If negative, the reverse is true; searching for "apple" will also pick up nodes tagged with "fruit" if depth is -1 (or lower).'),
- );
+ ];
}
public function query() {
diff --git a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php
index b1c72e4bdec..13fd056aba3 100644
--- a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php
+++ b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php
@@ -74,24 +74,24 @@ class NodeTermData extends RelationshipPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['vids'] = array('default' => array());
+ $options['vids'] = ['default' => []];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$vocabularies = $this->vocabularyStorage->loadMultiple();
- $options = array();
+ $options = [];
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
- $form['vids'] = array(
+ $form['vids'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vids'],
'#description' => $this->t('Choose which vocabularies you wish to relate. Remember that every term found will create a new record, so this relationship is best used on just one vocabulary that has only one term per node.'),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -134,7 +134,7 @@ class NodeTermData extends RelationshipPluginBase {
$query->condition('td.vid', array_filter($this->options['vids']), 'IN');
$query->addTag('taxonomy_term_access');
$query->fields('td');
- $query->fields('tn', array('nid'));
+ $query->fields('tn', ['nid']);
$def['table formula'] = $query;
}
diff --git a/core/modules/taxonomy/src/TermBreadcrumbBuilder.php b/core/modules/taxonomy/src/TermBreadcrumbBuilder.php
index 838011d7b6b..73588d1f046 100644
--- a/core/modules/taxonomy/src/TermBreadcrumbBuilder.php
+++ b/core/modules/taxonomy/src/TermBreadcrumbBuilder.php
@@ -68,7 +68,7 @@ class TermBreadcrumbBuilder implements BreadcrumbBuilderInterface {
foreach (array_reverse($parents) as $term) {
$term = $this->entityManager->getTranslationFromContext($term);
$breadcrumb->addCacheableDependency($term);
- $breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', array('taxonomy_term' => $term->id())));
+ $breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', ['taxonomy_term' => $term->id()]));
}
// This breadcrumb builder is based on a route parameter, and hence it
diff --git a/core/modules/taxonomy/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php
index 1f56351323f..6e307ca35a0 100644
--- a/core/modules/taxonomy/src/TermForm.php
+++ b/core/modules/taxonomy/src/TermForm.php
@@ -23,12 +23,12 @@ class TermForm extends ContentEntityForm {
$form_state->set(['taxonomy', 'parent'], $parent);
$form_state->set(['taxonomy', 'vocabulary'], $vocabulary);
- $form['relations'] = array(
+ $form['relations'] = [
'#type' => 'details',
'#title' => $this->t('Relations'),
'#open' => $vocabulary->getHierarchy() == VocabularyInterface::HIERARCHY_MULTIPLE,
'#weight' => 10,
- );
+ ];
// \Drupal\taxonomy\TermStorageInterface::loadTree() and
// \Drupal\taxonomy\TermStorageInterface::loadParents() may contain large
@@ -46,9 +46,9 @@ class TermForm extends ContentEntityForm {
$exclude[] = $term->id();
$tree = $taxonomy_storage->loadTree($vocabulary->id());
- $options = array('<' . $this->t('root') . '>');
+ $options = ['<' . $this->t('root') . '>'];
if (empty($parent)) {
- $parent = array(0);
+ $parent = [0];
}
foreach ($tree as $item) {
@@ -57,33 +57,33 @@ class TermForm extends ContentEntityForm {
}
}
- $form['relations']['parent'] = array(
+ $form['relations']['parent'] = [
'#type' => 'select',
'#title' => $this->t('Parent terms'),
'#options' => $options,
'#default_value' => $parent,
'#multiple' => TRUE,
- );
+ ];
}
- $form['relations']['weight'] = array(
+ $form['relations']['weight'] = [
'#type' => 'textfield',
'#title' => $this->t('Weight'),
'#size' => 6,
'#default_value' => $term->getWeight(),
'#description' => $this->t('Terms are displayed in ascending order by weight.'),
'#required' => TRUE,
- );
+ ];
- $form['vid'] = array(
+ $form['vid'] = [
'#type' => 'value',
'#value' => $vocabulary->id(),
- );
+ ];
- $form['tid'] = array(
+ $form['tid'] = [
'#type' => 'value',
'#value' => $term->id(),
- );
+ ];
return parent::form($form, $form_state, $term);
}
@@ -127,21 +127,21 @@ class TermForm extends ContentEntityForm {
$view_link = $term->link($term->getName());
switch ($result) {
case SAVED_NEW:
- drupal_set_message($this->t('Created new term %term.', array('%term' => $view_link)));
- $this->logger('taxonomy')->notice('Created new term %term.', array('%term' => $term->getName(), 'link' => $edit_link));
+ drupal_set_message($this->t('Created new term %term.', ['%term' => $view_link]));
+ $this->logger('taxonomy')->notice('Created new term %term.', ['%term' => $term->getName(), 'link' => $edit_link]);
break;
case SAVED_UPDATED:
- drupal_set_message($this->t('Updated term %term.', array('%term' => $view_link)));
- $this->logger('taxonomy')->notice('Updated term %term.', array('%term' => $term->getName(), 'link' => $edit_link));
+ drupal_set_message($this->t('Updated term %term.', ['%term' => $view_link]));
+ $this->logger('taxonomy')->notice('Updated term %term.', ['%term' => $term->getName(), 'link' => $edit_link]);
break;
}
$current_parent_count = count($form_state->getValue('parent'));
$previous_parent_count = count($form_state->get(['taxonomy', 'parent']));
// Root doesn't count if it's the only parent.
- if ($current_parent_count == 1 && $form_state->hasValue(array('parent', 0))) {
+ if ($current_parent_count == 1 && $form_state->hasValue(['parent', 0])) {
$current_parent_count = 0;
- $form_state->setValue('parent', array());
+ $form_state->setValue('parent', []);
}
// If the number of parents has been reduced to one or none, do a check on the
diff --git a/core/modules/taxonomy/src/TermStorage.php b/core/modules/taxonomy/src/TermStorage.php
index bc44c226fed..0a00c13de56 100644
--- a/core/modules/taxonomy/src/TermStorage.php
+++ b/core/modules/taxonomy/src/TermStorage.php
@@ -15,49 +15,49 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*
* @var array
*/
- protected $parents = array();
+ protected $parents = [];
/**
* Array of all loaded term ancestry keyed by ancestor term ID.
*
* @var array
*/
- protected $parentsAll = array();
+ protected $parentsAll = [];
/**
* Array of child terms keyed by parent term ID.
*
* @var array
*/
- protected $children = array();
+ protected $children = [];
/**
* Array of term parents keyed by vocabulary ID and child term ID.
*
* @var array
*/
- protected $treeParents = array();
+ protected $treeParents = [];
/**
* Array of term ancestors keyed by vocabulary ID and parent term ID.
*
* @var array
*/
- protected $treeChildren = array();
+ protected $treeChildren = [];
/**
* Array of terms in a tree keyed by vocabulary ID and term ID.
*
* @var array
*/
- protected $treeTerms = array();
+ protected $treeTerms = [];
/**
* Array of loaded trees keyed by a cache id matching tree arguments.
*
* @var array
*/
- protected $trees = array();
+ protected $trees = [];
/**
* {@inheritdoc}
@@ -66,10 +66,10 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
* An array of values to set, keyed by property name. A value for the
* vocabulary ID ('vid') is required.
*/
- public function create(array $values = array()) {
+ public function create(array $values = []) {
// Save new terms with no parents by default.
if (empty($values['parent'])) {
- $values['parent'] = array(0);
+ $values['parent'] = [0];
}
$entity = parent::create($values);
return $entity;
@@ -80,13 +80,13 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function resetCache(array $ids = NULL) {
drupal_static_reset('taxonomy_term_count_nodes');
- $this->parents = array();
- $this->parentsAll = array();
- $this->children = array();
- $this->treeChildren = array();
- $this->treeParents = array();
- $this->treeTerms = array();
- $this->trees = array();
+ $this->parents = [];
+ $this->parentsAll = [];
+ $this->children = [];
+ $this->treeChildren = [];
+ $this->treeParents = [];
+ $this->treeTerms = [];
+ $this->trees = [];
parent::resetCache($ids);
}
@@ -104,13 +104,13 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function updateTermHierarchy(EntityInterface $term) {
$query = $this->database->insert('taxonomy_term_hierarchy')
- ->fields(array('tid', 'parent'));
+ ->fields(['tid', 'parent']);
foreach ($term->parent as $parent) {
- $query->values(array(
+ $query->values([
'tid' => $term->id(),
'parent' => (int) $parent->target_id,
- ));
+ ]);
}
$query->execute();
}
@@ -120,7 +120,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function loadParents($tid) {
if (!isset($this->parents[$tid])) {
- $parents = array();
+ $parents = [];
$query = $this->database->select('taxonomy_term_field_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid');
$query->addField('t', 'tid');
@@ -142,7 +142,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function loadAllParents($tid) {
if (!isset($this->parentsAll[$tid])) {
- $parents = array();
+ $parents = [];
if ($term = $this->load($tid)) {
$parents[$term->id()] = $term;
$terms_to_search[] = $term->id();
@@ -169,7 +169,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function loadChildren($tid, $vid = NULL) {
if (!isset($this->children[$tid])) {
- $children = array();
+ $children = [];
$query = $this->database->select('taxonomy_term_field_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$query->addField('t', 'tid');
@@ -198,15 +198,15 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
// We cache trees, so it's not CPU-intensive to call on a term and its
// children, too.
if (!isset($this->treeChildren[$vid])) {
- $this->treeChildren[$vid] = array();
- $this->treeParents[$vid] = array();
- $this->treeTerms[$vid] = array();
+ $this->treeChildren[$vid] = [];
+ $this->treeParents[$vid] = [];
+ $this->treeTerms[$vid] = [];
$query = $this->database->select('taxonomy_term_field_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$result = $query
->addTag('taxonomy_term_access')
->fields('t')
- ->fields('h', array('parent'))
+ ->fields('h', ['parent'])
->condition('t.vid', $vid)
->condition('t.default_langcode', 1)
->orderBy('t.weight')
@@ -221,17 +221,17 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
// Load full entities, if necessary. The entity controller statically
// caches the results.
- $term_entities = array();
+ $term_entities = [];
if ($load_entities) {
$term_entities = $this->loadMultiple(array_keys($this->treeTerms[$vid]));
}
$max_depth = (!isset($max_depth)) ? count($this->treeChildren[$vid]) : $max_depth;
- $tree = array();
+ $tree = [];
// Keeps track of the parents we have to process, the last entry is used
// for the next processing step.
- $process_parents = array();
+ $process_parents = [];
$process_parents[] = $parent;
// Loops over the parent terms and adds its children to the tree array.
@@ -304,7 +304,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function resetWeights($vid) {
$this->database->update('taxonomy_term_field_data')
- ->fields(array('weight' => 0))
+ ->fields(['weight' => 0])
->condition('vid', $vid)
->execute();
}
@@ -312,10 +312,10 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
/**
* {@inheritdoc}
*/
- public function getNodeTerms(array $nids, array $vocabs = array(), $langcode = NULL) {
+ public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL) {
$query = db_select('taxonomy_term_field_data', 'td');
$query->innerJoin('taxonomy_index', 'tn', 'td.tid = tn.tid');
- $query->fields('td', array('tid'));
+ $query->fields('td', ['tid']);
$query->addField('tn', 'nid', 'node_nid');
$query->orderby('td.weight');
$query->orderby('td.name');
@@ -328,15 +328,15 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
$query->condition('td.langcode', $langcode);
}
- $results = array();
- $all_tids = array();
+ $results = [];
+ $all_tids = [];
foreach ($query->execute() as $term_record) {
$results[$term_record->node_nid][] = $term_record->tid;
$all_tids[] = $term_record->tid;
}
$all_terms = $this->loadMultiple($all_tids);
- $terms = array();
+ $terms = [];
foreach ($results as $nid => $tids) {
foreach ($tids as $tid) {
$terms[$nid][$tid] = $all_terms[$tid];
@@ -361,13 +361,13 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
public function __wakeup() {
parent::__wakeup();
// Initialize static caches.
- $this->parents = array();
- $this->parentsAll = array();
- $this->children = array();
- $this->treeChildren = array();
- $this->treeParents = array();
- $this->treeTerms = array();
- $this->trees = array();
+ $this->parents = [];
+ $this->parentsAll = [];
+ $this->children = [];
+ $this->treeChildren = [];
+ $this->treeParents = [];
+ $this->treeTerms = [];
+ $this->trees = [];
}
}
diff --git a/core/modules/taxonomy/src/TermStorageInterface.php b/core/modules/taxonomy/src/TermStorageInterface.php
index 99167114d14..05d8d7f4c7e 100644
--- a/core/modules/taxonomy/src/TermStorageInterface.php
+++ b/core/modules/taxonomy/src/TermStorageInterface.php
@@ -116,6 +116,6 @@ interface TermStorageInterface extends ContentEntityStorageInterface {
* @return array
* An array of nids and the term entities they were tagged with.
*/
- public function getNodeTerms(array $nids, array $vocabs = array(), $langcode = NULL);
+ public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL);
}
diff --git a/core/modules/taxonomy/src/TermStorageSchema.php b/core/modules/taxonomy/src/TermStorageSchema.php
index 5534821ef0c..5bcb088db45 100644
--- a/core/modules/taxonomy/src/TermStorageSchema.php
+++ b/core/modules/taxonomy/src/TermStorageSchema.php
@@ -17,93 +17,93 @@ class TermStorageSchema extends SqlContentEntityStorageSchema {
protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
$schema = parent::getEntitySchema($entity_type, $reset = FALSE);
- $schema['taxonomy_term_field_data']['indexes'] += array(
- 'taxonomy_term__tree' => array('vid', 'weight', 'name'),
- 'taxonomy_term__vid_name' => array('vid', 'name'),
- );
+ $schema['taxonomy_term_field_data']['indexes'] += [
+ 'taxonomy_term__tree' => ['vid', 'weight', 'name'],
+ 'taxonomy_term__vid_name' => ['vid', 'name'],
+ ];
- $schema['taxonomy_term_hierarchy'] = array(
+ $schema['taxonomy_term_hierarchy'] = [
'description' => 'Stores the hierarchical relationship between terms.',
- 'fields' => array(
- 'tid' => array(
+ 'fields' => [
+ 'tid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: The {taxonomy_term_data}.tid of the term.',
- ),
- 'parent' => array(
+ ],
+ 'parent' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "Primary Key: The {taxonomy_term_data}.tid of the term's parent. 0 indicates no parent.",
- ),
- ),
- 'indexes' => array(
- 'parent' => array('parent'),
- ),
- 'foreign keys' => array(
- 'taxonomy_term_data' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'parent' => ['parent'],
+ ],
+ 'foreign keys' => [
+ 'taxonomy_term_data' => [
'table' => 'taxonomy_term_data',
- 'columns' => array('tid' => 'tid'),
- ),
- ),
- 'primary key' => array('tid', 'parent'),
- );
+ 'columns' => ['tid' => 'tid'],
+ ],
+ ],
+ 'primary key' => ['tid', 'parent'],
+ ];
- $schema['taxonomy_index'] = array(
+ $schema['taxonomy_index'] = [
'description' => 'Maintains denormalized information about node/term relationships.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'tid' => array(
+ ],
+ 'tid' => [
'description' => 'The term ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'status' => array(
+ ],
+ 'status' => [
'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
- ),
- 'sticky' => array(
+ ],
+ 'sticky' => [
'description' => 'Boolean indicating whether the node is sticky.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
- ),
- 'created' => array(
+ ],
+ 'created' => [
'description' => 'The Unix timestamp when the node was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('nid', 'tid'),
- 'indexes' => array(
- 'term_node' => array('tid', 'status', 'sticky', 'created'),
- ),
- 'foreign keys' => array(
- 'tracked_node' => array(
+ ],
+ ],
+ 'primary key' => ['nid', 'tid'],
+ 'indexes' => [
+ 'term_node' => ['tid', 'status', 'sticky', 'created'],
+ ],
+ 'foreign keys' => [
+ 'tracked_node' => [
'table' => 'node',
- 'columns' => array('nid' => 'nid'),
- ),
- 'term' => array(
+ 'columns' => ['nid' => 'nid'],
+ ],
+ 'term' => [
'table' => 'taxonomy_term_data',
- 'columns' => array('tid' => 'tid'),
- ),
- ),
- );
+ 'columns' => ['tid' => 'tid'],
+ ],
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/taxonomy/src/TermTranslationHandler.php b/core/modules/taxonomy/src/TermTranslationHandler.php
index 72539b53dfd..8339267c417 100644
--- a/core/modules/taxonomy/src/TermTranslationHandler.php
+++ b/core/modules/taxonomy/src/TermTranslationHandler.php
@@ -16,7 +16,7 @@ class TermTranslationHandler extends ContentTranslationHandler {
*/
public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) {
parent::entityFormAlter($form, $form_state, $entity);
- $form['actions']['submit']['#submit'][] = array($this, 'entityFormSave');
+ $form['actions']['submit']['#submit'][] = [$this, 'entityFormSave'];
}
/**
diff --git a/core/modules/taxonomy/src/TermViewBuilder.php b/core/modules/taxonomy/src/TermViewBuilder.php
index ca74535ac4b..6748a4b03ca 100644
--- a/core/modules/taxonomy/src/TermViewBuilder.php
+++ b/core/modules/taxonomy/src/TermViewBuilder.php
@@ -16,10 +16,10 @@ class TermViewBuilder extends EntityViewBuilder {
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $entity, $display, $view_mode);
- $build['#contextual_links']['taxonomy_term'] = array(
- 'route_parameters' => array('taxonomy_term' => $entity->id()),
- 'metadata' => array('changed' => $entity->getChangedTime()),
- );
+ $build['#contextual_links']['taxonomy_term'] = [
+ 'route_parameters' => ['taxonomy_term' => $entity->id()],
+ 'metadata' => ['changed' => $entity->getChangedTime()],
+ ];
}
}
diff --git a/core/modules/taxonomy/src/TermViewsData.php b/core/modules/taxonomy/src/TermViewsData.php
index 32a238b9b7f..5e98bfe9b2a 100644
--- a/core/modules/taxonomy/src/TermViewsData.php
+++ b/core/modules/taxonomy/src/TermViewsData.php
@@ -19,13 +19,13 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_field_data']['table']['base']['access query tag'] = 'taxonomy_term_access';
$data['taxonomy_term_field_data']['table']['wizard_id'] = 'taxonomy_term';
- $data['taxonomy_term_field_data']['table']['join'] = array(
+ $data['taxonomy_term_field_data']['table']['join'] = [
// This is provided for the many_to_one argument.
- 'taxonomy_index' => array(
+ 'taxonomy_index' => [
'field' => 'tid',
'left_field' => 'tid',
- ),
- );
+ ],
+ ];
$data['taxonomy_term_field_data']['tid']['help'] = $this->t('The tid of a taxonomy term.');
@@ -39,18 +39,18 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_field_data']['tid']['filter']['hierarchy table'] = 'taxonomy_term_hierarchy';
$data['taxonomy_term_field_data']['tid']['filter']['numeric'] = TRUE;
- $data['taxonomy_term_field_data']['tid_raw'] = array(
+ $data['taxonomy_term_field_data']['tid_raw'] = [
'title' => $this->t('Term ID'),
'help' => $this->t('The tid of a taxonomy term.'),
'real field' => 'tid',
- 'filter' => array(
+ 'filter' => [
'id' => 'numeric',
'allow empty' => TRUE,
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['tid_representative'] = array(
- 'relationship' => array(
+ $data['taxonomy_term_field_data']['tid_representative'] = [
+ 'relationship' => [
'title' => $this->t('Representative node'),
'label' => $this->t('Representative node'),
'help' => $this->t('Obtains a single representative node for each term, according to a chosen sort criterion.'),
@@ -62,8 +62,8 @@ class TermViewsData extends EntityViewsData {
'base' => 'node_field_data',
'field' => 'nid',
'relationship' => 'node_field_data:term_node_tid'
- ),
- );
+ ],
+ ];
$data['taxonomy_term_field_data']['vid']['help'] = $this->t('Filter the results of "Taxonomy: Term" to a particular vocabulary.');
unset($data['taxonomy_term_field_data']['vid']['field']);
@@ -79,114 +79,114 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_field_data']['changed']['title'] = $this->t('Updated date');
$data['taxonomy_term_field_data']['changed']['help'] = $this->t('The date the term was last updated.');
- $data['taxonomy_term_field_data']['changed_fulldate'] = array(
+ $data['taxonomy_term_field_data']['changed_fulldate'] = [
'title' => $this->t('Updated date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_year_month'] = array(
+ $data['taxonomy_term_field_data']['changed_year_month'] = [
'title' => $this->t('Updated year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_year'] = array(
+ $data['taxonomy_term_field_data']['changed_year'] = [
'title' => $this->t('Updated year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_month'] = array(
+ $data['taxonomy_term_field_data']['changed_month'] = [
'title' => $this->t('Updated month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_day'] = array(
+ $data['taxonomy_term_field_data']['changed_day'] = [
'title' => $this->t('Updated day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_week'] = array(
+ $data['taxonomy_term_field_data']['changed_week'] = [
'title' => $this->t('Updated week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
$data['taxonomy_index']['table']['group'] = $this->t('Taxonomy term');
- $data['taxonomy_index']['table']['join'] = array(
- 'taxonomy_term_field_data' => array(
+ $data['taxonomy_index']['table']['join'] = [
+ 'taxonomy_term_field_data' => [
// links directly to taxonomy_term_field_data via tid
'left_field' => 'tid',
'field' => 'tid',
- ),
- 'node_field_data' => array(
+ ],
+ 'node_field_data' => [
// links directly to node via nid
'left_field' => 'nid',
'field' => 'nid',
- ),
- 'taxonomy_term_hierarchy' => array(
+ ],
+ 'taxonomy_term_hierarchy' => [
'left_field' => 'tid',
'field' => 'tid',
- ),
- );
+ ],
+ ];
- $data['taxonomy_index']['nid'] = array(
+ $data['taxonomy_index']['nid'] = [
'title' => $this->t('Content with term'),
'help' => $this->t('Relate all content tagged with a term.'),
- 'relationship' => array(
+ 'relationship' => [
'id' => 'standard',
'base' => 'node',
'base field' => 'nid',
'label' => $this->t('node'),
'skip base' => 'node',
- ),
- );
+ ],
+ ];
// @todo This stuff needs to move to a node field since really it's all
// about nodes.
- $data['taxonomy_index']['tid'] = array(
+ $data['taxonomy_index']['tid'] = [
'group' => $this->t('Content'),
'title' => $this->t('Has taxonomy term ID'),
'help' => $this->t('Display content if it has the selected taxonomy terms.'),
- 'argument' => array(
+ 'argument' => [
'id' => 'taxonomy_index_tid',
'name table' => 'taxonomy_term_field_data',
'name field' => 'name',
'empty field name' => $this->t('Uncategorized'),
'numeric' => TRUE,
'skip base' => 'taxonomy_term_field_data',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'title' => $this->t('Has taxonomy term'),
'id' => 'taxonomy_index_tid',
'hierarchy table' => 'taxonomy_term_hierarchy',
'numeric' => TRUE,
'skip base' => 'taxonomy_term_field_data',
'allow empty' => TRUE,
- ),
- );
+ ],
+ ];
$data['taxonomy_index']['status'] = [
'title' => $this->t('Publish status'),
@@ -226,37 +226,37 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_hierarchy']['table']['group'] = $this->t('Taxonomy term');
$data['taxonomy_term_hierarchy']['table']['provider'] = 'taxonomy';
- $data['taxonomy_term_hierarchy']['table']['join'] = array(
- 'taxonomy_term_hierarchy' => array(
+ $data['taxonomy_term_hierarchy']['table']['join'] = [
+ 'taxonomy_term_hierarchy' => [
// Link to self through left.parent = right.tid (going down in depth).
'left_field' => 'tid',
'field' => 'parent',
- ),
- 'taxonomy_term_field_data' => array(
+ ],
+ 'taxonomy_term_field_data' => [
// Link directly to taxonomy_term_field_data via tid.
'left_field' => 'tid',
'field' => 'tid',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_hierarchy']['parent'] = array(
+ $data['taxonomy_term_hierarchy']['parent'] = [
'title' => $this->t('Parent term'),
'help' => $this->t('The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.'),
- 'relationship' => array(
+ 'relationship' => [
'base' => 'taxonomy_term_field_data',
'field' => 'parent',
'label' => $this->t('Parent'),
'id' => 'standard',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'help' => $this->t('Filter the results of "Taxonomy: Term" by the parent pid.'),
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'help' => $this->t('The parent term of the term.'),
'id' => 'taxonomy',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/taxonomy/src/Tests/RssTest.php b/core/modules/taxonomy/src/Tests/RssTest.php
index f26cb077477..315f64d5df0 100644
--- a/core/modules/taxonomy/src/Tests/RssTest.php
+++ b/core/modules/taxonomy/src/Tests/RssTest.php
@@ -18,7 +18,7 @@ class RssTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_ui', 'views');
+ public static $modules = ['node', 'field_ui', 'views'];
/**
* Vocabulary for testing.
@@ -41,23 +41,23 @@ class RssTest extends TaxonomyTestBase {
$this->vocabulary = $this->createVocabulary();
$this->fieldName = 'taxonomy_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -72,21 +72,21 @@ class RssTest extends TaxonomyTestBase {
// RSS display must be added manually.
$this->drupalGet("admin/structure/types/manage/article/display");
- $edit = array(
+ $edit = [
"display_modes_custom[rss]" => '1',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Change the format to 'RSS category'.
$this->drupalGet("admin/structure/types/manage/article/display/rss");
- $edit = array(
+ $edit = [
"fields[taxonomy_" . $this->vocabulary->id() . "][type]" => 'entity_reference_rss_category',
"fields[taxonomy_" . $this->vocabulary->id() . "][region]" => 'content',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Post an article.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit[$this->fieldName . '[]'] = $term1->id();
$this->drupalPostForm('node/add/article', $edit, t('Save'));
@@ -95,7 +95,7 @@ class RssTest extends TaxonomyTestBase {
$this->drupalGet('rss.xml');
$test_element = sprintf(
'<category %s>%s</category>',
- 'domain="' . $term1->url('canonical', array('absolute' => TRUE)) . '"',
+ 'domain="' . $term1->url('canonical', ['absolute' => TRUE]) . '"',
$term1->getName()
);
$this->assertRaw($test_element, 'Term is displayed when viewing the rss feed.');
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
index 306e160b2ac..7d2ee2b639d 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
@@ -26,48 +26,48 @@ class TaxonomyImageTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('image');
+ public static $modules = ['image'];
protected function setUp() {
parent::setUp();
// Remove access content permission from registered users.
- user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, array('access content'));
+ user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, ['access content']);
$this->vocabulary = $this->createVocabulary();
// Add a field to the vocabulary.
$entity_type = 'taxonomy_term';
$name = 'field_test';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $name,
'entity_type' => $entity_type,
'type' => 'image',
- 'settings' => array(
+ 'settings' => [
'uri_scheme' => 'private',
- ),
- ))->save();
+ ],
+ ])->save();
FieldConfig::create([
'field_name' => $name,
'entity_type' => $entity_type,
'bundle' => $this->vocabulary->id(),
- 'settings' => array(),
+ 'settings' => [],
])->save();
entity_get_display($entity_type, $this->vocabulary->id(), 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'image',
- 'settings' => array(),
- ))
+ 'settings' => [],
+ ])
->save();
entity_get_form_display($entity_type, $this->vocabulary->id(), 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'image_image',
- 'settings' => array(),
- ))
+ 'settings' => [],
+ ])
->save();
}
public function testTaxonomyImageAccess() {
- $user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy', 'access user profiles'));
+ $user = $this->drupalCreateUser(['administer site configuration', 'administer taxonomy', 'access user profiles']);
$this->drupalLogin($user);
// Create a term and upload the image.
@@ -77,12 +77,12 @@ class TaxonomyImageTest extends TaxonomyTestBase {
$edit['files[field_test_0]'] = drupal_realpath($image->uri);
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
$this->drupalPostForm(NULL, ['field_test[0][alt]' => $this->randomMachineName()], t('Save'));
- $terms = entity_load_multiple_by_properties('taxonomy_term', array('name' => $edit['name[0][value]']));
+ $terms = entity_load_multiple_by_properties('taxonomy_term', ['name' => $edit['name[0][value]']]);
$term = reset($terms);
- $this->assertText(t('Created new term @name.', array('@name' => $term->getName())));
+ $this->assertText(t('Created new term @name.', ['@name' => $term->getName()]));
// Create a user that should have access to the file and one that doesn't.
- $access_user = $this->drupalCreateUser(array('access content'));
+ $access_user = $this->drupalCreateUser(['access content']);
$no_access_user = $this->drupalCreateUser();
$image = File::load($term->field_test->target_id);
$this->drupalLogin($access_user);
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php b/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php
index 543910b0b67..e5e787bb59b 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php
@@ -26,7 +26,7 @@ class TaxonomyQueryAlterTest extends WebTestBase {
public function testTaxonomyQueryAlter() {
// Create a new vocabulary and add a few terms to it.
$vocabulary = $this->createVocabulary();
- $terms = array();
+ $terms = [];
for ($i = 0; $i < 5; $i++) {
$terms[$i] = $this->createTerm($vocabulary);
}
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php b/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php
index 6043d77517c..b48de1a7adf 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php
@@ -14,7 +14,7 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* Vocabulary for testing.
@@ -42,12 +42,12 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
$taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
// Indent the second term under the first one.
- $edit = array(
+ $edit = [
'terms[tid:' . $term2->id() . ':0][term][tid]' => 2,
'terms[tid:' . $term2->id() . ':0][term][parent]' => 1,
'terms[tid:' . $term2->id() . ':0][term][depth]' => 1,
'terms[tid:' . $term2->id() . ':0][weight]' => 1,
- );
+ ];
// Submit the edited form and check for HTML indentation element presence.
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save'));
@@ -58,12 +58,12 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
$this->assertEqual(key($parents), 1, 'Term 1 is the term 2\'s parent');
// Move the second term back out to the root level.
- $edit = array(
+ $edit = [
'terms[tid:' . $term2->id() . ':0][term][tid]' => 2,
'terms[tid:' . $term2->id() . ':0][term][parent]' => 0,
'terms[tid:' . $term2->id() . ':0][term][depth]' => 0,
'terms[tid:' . $term2->id() . ':0][weight]' => 1,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid' ) . '/overview', $edit, t('Save'));
// All terms back at the root level, no indentation should be present.
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
index 12c30c7841f..838a9b02c90 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
@@ -21,7 +21,7 @@ abstract class TaxonomyTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'block');
+ public static $modules = ['taxonomy', 'block'];
/**
* {@inheritdoc}
@@ -32,7 +32,7 @@ abstract class TaxonomyTestBase extends WebTestBase {
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php b/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php
index f04be0013e3..dae42f3fe9d 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php
@@ -40,7 +40,7 @@ trait TaxonomyTestTrait {
* @return \Drupal\taxonomy\Entity\Term
* The new taxonomy term object.
*/
- function createTerm(Vocabulary $vocabulary, $values = array()) {
+ function createTerm(Vocabulary $vocabulary, $values = []) {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$term = Term::create($values + [
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php b/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php
index 5ae6270356f..3607fc6b0a5 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php
@@ -79,26 +79,26 @@ trait TaxonomyTranslationTestTrait {
* to FALSE.
*/
protected function setUpTermReferenceField() {
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->termFieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$field_storage = FieldStorageConfig::loadByName('node', $this->termFieldName);
$field_storage->setTranslatable(FALSE);
$field_storage->save();
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->termFieldName, array(
+ ->setComponent($this->termFieldName, [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->termFieldName, array(
+ ->setComponent($this->termFieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php
index 311ed6b7c30..cba983ddcdf 100644
--- a/core/modules/taxonomy/src/Tests/TermTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTest.php
@@ -52,24 +52,24 @@ class TermTest extends TaxonomyTestBase {
$field_name = 'taxonomy_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this->field = FieldConfig::loadByName('node', 'article', $field_name);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -89,8 +89,8 @@ class TermTest extends TaxonomyTestBase {
$this->assertEqual(0, $vocabulary->getHierarchy(), 'Vocabulary is flat.');
// Edit $term2, setting $term1 as parent.
- $edit = array();
- $edit['parent[]'] = array($term1->id());
+ $edit = [];
+ $edit['parent[]'] = [$term1->id()];
$this->drupalPostForm('taxonomy/term/' . $term2->id() . '/edit', $edit, t('Save'));
// Check the hierarchy.
@@ -107,7 +107,7 @@ class TermTest extends TaxonomyTestBase {
// Create a third term and save this as a parent of term2.
$term3 = $this->createTerm($this->vocabulary);
- $term2->parent = array($term1->id(), $term3->id());
+ $term2->parent = [$term1->id(), $term3->id()];
$term2->save();
$parents = $taxonomy_storage->loadParents($term2->id());
$this->assertTrue(isset($parents[$term1->id()]) && isset($parents[$term3->id()]), 'Both parents found successfully.');
@@ -127,7 +127,7 @@ class TermTest extends TaxonomyTestBase {
// Create 40 terms. Terms 1-12 get parent of $term1. All others are
// individual terms.
for ($x = 1; $x <= 40; $x++) {
- $edit = array();
+ $edit = [];
// Set terms in order so we know which terms will be on which pages.
$edit['weight'] = $x;
@@ -149,14 +149,14 @@ class TermTest extends TaxonomyTestBase {
}
// Get Page 2.
- $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', array('query' => array('page' => 1)));
+ $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 1]]);
$this->assertText($term1->getName(), 'Parent Term is displayed on Page 2');
for ($x = 1; $x <= 18; $x++) {
$this->assertText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' found on Page 2');
}
// Get Page 3.
- $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', array('query' => array('page' => 2)));
+ $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 2]]);
$this->assertNoText($term1->getName(), 'Parent Term is not displayed on Page 3');
for ($x = 1; $x <= 17; $x++) {
$this->assertNoText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' not found on Page 3');
@@ -177,7 +177,7 @@ class TermTest extends TaxonomyTestBase {
$term2 = $this->createTerm($this->vocabulary);
// Post an article.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$edit[$this->field->getName() . '[]'] = $term1->id();
@@ -190,7 +190,7 @@ class TermTest extends TaxonomyTestBase {
$this->clickLink(t('Edit'));
$this->assertText($term1->getName(), 'Term is displayed when editing the node.');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText($term1->getName(), 'Term is displayed after saving the node with no changes.');
// Edit the node with a different term.
@@ -214,24 +214,24 @@ class TermTest extends TaxonomyTestBase {
// Enable tags in the vocabulary.
$field = $this->field;
entity_get_form_display($field->getTargetEntityTypeId(), $field->getTargetBundle(), 'default')
- ->setComponent($field->getName(), array(
+ ->setComponent($field->getName(), [
'type' => 'entity_reference_autocomplete_tags',
- 'settings' => array(
+ 'settings' => [
'placeholder' => 'Start typing here.',
- ),
- ))
+ ],
+ ])
->save();
// Prefix the terms with a letter to ensure there is no clash in the first
// three letters.
// @see https://www.drupal.org/node/2397691
- $terms = array(
+ $terms = [
'term1' => 'a' . $this->randomMachineName(),
'term2' => 'b' . $this->randomMachineName(),
'term3' => 'c' . $this->randomMachineName() . ', ' . $this->randomMachineName(),
'term4' => 'd' . $this->randomMachineName(),
- );
+ ];
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
// Insert the terms in a comma separated list. Vocabulary 1 is a
@@ -255,10 +255,10 @@ class TermTest extends TaxonomyTestBase {
// Save, creating the terms.
$this->drupalPostForm('node/add/article', $edit, t('Save'));
- $this->assertText(t('@type @title has been created.', array('@type' => t('Article'), '@title' => $edit['title[0][value]'])), 'The node was created successfully.');
+ $this->assertText(t('@type @title has been created.', ['@type' => t('Article'), '@title' => $edit['title[0][value]']]), 'The node was created successfully.');
// Verify that the creation message contains a link to a node.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']);
$this->assert(isset($view_link), 'The message area contains a link to a node');
foreach ($terms as $term) {
@@ -266,7 +266,7 @@ class TermTest extends TaxonomyTestBase {
}
// Get the created terms.
- $term_objects = array();
+ $term_objects = [];
foreach ($terms as $key => $term) {
$term_objects[$key] = taxonomy_term_load_multiple_by_name($term);
$term_objects[$key] = reset($term_objects[$key]);
@@ -288,30 +288,30 @@ class TermTest extends TaxonomyTestBase {
// Delete term 2 from the term delete page.
$this->drupalGet('taxonomy/term/' . $term_objects['term2']->id() . '/delete');
- $this->drupalPostForm(NULL, array(), t('Delete'));
- $term_names = array($term_objects['term3']->getName(), $term_objects['term4']->getName());
+ $this->drupalPostForm(NULL, [], t('Delete'));
+ $term_names = [$term_objects['term3']->getName(), $term_objects['term4']->getName()];
$this->drupalGet('node/' . $node->id());
foreach ($term_names as $term_name) {
- $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted.', array('%name' => $term_name, '%deleted1' => $term_objects['term1']->getName(), '%deleted2' => $term_objects['term2']->getName())));
+ $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted.', ['%name' => $term_name, '%deleted1' => $term_objects['term1']->getName(), '%deleted2' => $term_objects['term2']->getName()]));
}
- $this->assertNoText($term_objects['term1']->getName(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term1']->getName())));
- $this->assertNoText($term_objects['term2']->getName(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term2']->getName())));
+ $this->assertNoText($term_objects['term1']->getName(), format_string('The deleted term %name does not appear on the node page.', ['%name' => $term_objects['term1']->getName()]));
+ $this->assertNoText($term_objects['term2']->getName(), format_string('The deleted term %name does not appear on the node page.', ['%name' => $term_objects['term2']->getName()]));
}
/**
* Save, edit and delete a term using the user interface.
*/
function testTermInterface() {
- \Drupal::service('module_installer')->install(array('views'));
- $edit = array(
+ \Drupal::service('module_installer')->install(['views']);
+ $edit = [
'name[0][value]' => $this->randomMachineName(12),
'description[0][value]' => $this->randomMachineName(100),
- );
+ ];
// Explicitly set the parents field to 'root', to ensure that
// TermForm::save() handles the invalid term ID correctly.
- $edit['parent[]'] = array(0);
+ $edit['parent[]'] = [0];
// Create the term to edit.
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
@@ -328,10 +328,10 @@ class TermTest extends TaxonomyTestBase {
$this->assertRaw($edit['name[0][value]'], 'The randomly generated term name is present.');
$this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(14),
'description[0][value]' => $this->randomMachineName(102),
- );
+ ];
// Edit the term.
$this->drupalPostForm('taxonomy/term/' . $term->id() . '/edit', $edit, t('Save'));
@@ -398,7 +398,7 @@ class TermTest extends TaxonomyTestBase {
// "tid:1:0[depth]", and "tid:1:0[weight]". Change the order to term2,
// term3, term1 by setting weight property, make term3 a child of term2 by
// setting the parent and depth properties, and update all hidden fields.
- $edit = array(
+ $edit = [
'terms[tid:' . $term2->id() . ':0][term][tid]' => $term2->id(),
'terms[tid:' . $term2->id() . ':0][term][parent]' => 0,
'terms[tid:' . $term2->id() . ':0][term][depth]' => 0,
@@ -411,18 +411,18 @@ class TermTest extends TaxonomyTestBase {
'terms[tid:' . $term1->id() . ':0][term][parent]' => 0,
'terms[tid:' . $term1->id() . ':0][term][depth]' => 0,
'terms[tid:' . $term1->id() . ':0][weight]' => 2,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$taxonomy_storage->resetCache();
$terms = $taxonomy_storage->loadTree($this->vocabulary->id());
$this->assertEqual($terms[0]->tid, $term2->id(), 'Term 2 was moved above term 1.');
- $this->assertEqual($terms[1]->parents, array($term2->id()), 'Term 3 was made a child of term 2.');
+ $this->assertEqual($terms[1]->parents, [$term2->id()], 'Term 3 was made a child of term 2.');
$this->assertEqual($terms[2]->tid, $term1->id(), 'Term 1 was moved below term 2.');
- $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', array(), t('Reset to alphabetical'));
+ $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', [], t('Reset to alphabetical'));
// Submit confirmation form.
- $this->drupalPostForm(NULL, array(), t('Reset to alphabetical'));
+ $this->drupalPostForm(NULL, [], t('Reset to alphabetical'));
// Ensure form redirected back to overview.
$this->assertUrl('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
@@ -431,7 +431,7 @@ class TermTest extends TaxonomyTestBase {
$this->assertEqual($terms[0]->id(), $term1->id(), 'Term 1 was moved to back above term 2.');
$this->assertEqual($terms[1]->id(), $term2->id(), 'Term 2 was moved to back below term 1.');
$this->assertEqual($terms[2]->id(), $term3->id(), 'Term 3 is still below term 2.');
- $this->assertEqual($terms[2]->parents, array($term2->id()), 'Term 3 is still a child of term 2.');
+ $this->assertEqual($terms[2]->parents, [$term2->id()], 'Term 3 is still a child of term 2.');
}
/**
@@ -442,11 +442,11 @@ class TermTest extends TaxonomyTestBase {
$parent = $this->createTerm($this->vocabulary);
// Add a new term with multiple parents.
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(12),
'description[0][value]' => $this->randomMachineName(100),
- 'parent[]' => array(0, $parent->id()),
- );
+ 'parent[]' => [0, $parent->id()],
+ ];
// Save the new term.
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
@@ -530,14 +530,14 @@ class TermTest extends TaxonomyTestBase {
// Enable tags in the vocabulary.
$field = $this->field;
entity_get_form_display($field->getTargetEntityTypeId(), $field->getTargetBundle(), 'default')
- ->setComponent($field->getName(), array(
+ ->setComponent($field->getName(), [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
// Create a term and a node using it.
$term = $this->createTerm($this->vocabulary);
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$edit[$this->field->getName() . '[target_id]'] = $term->getName();
@@ -547,7 +547,7 @@ class TermTest extends TaxonomyTestBase {
// changes.
$this->clickLink(t('Edit'));
$this->assertRaw($term->getName(), 'Term is displayed when editing the node.');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertRaw($term->getName(), 'Term is displayed after saving the node with no changes.');
}
diff --git a/core/modules/taxonomy/src/Tests/TermTranslationTest.php b/core/modules/taxonomy/src/Tests/TermTranslationTest.php
index 91b13b158ab..c1425b72adc 100644
--- a/core/modules/taxonomy/src/Tests/TermTranslationTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTranslationTest.php
@@ -20,23 +20,23 @@ class TermTranslationTest extends TaxonomyTestBase {
*
* @var array
*/
- protected $termTranslationMap = array(
+ protected $termTranslationMap = [
'one' => 'translatedOne',
'two' => 'translatedTwo',
'three' => 'translatedThree',
- );
+ ];
/**
* Created terms.
*
* @var \Drupal\taxonomy\Entity\Term[]
*/
- protected $terms = array();
+ protected $terms = [];
/**
* {@inheritdoc}
*/
- public static $modules = array('taxonomy', 'language', 'content_translation');
+ public static $modules = ['taxonomy', 'language', 'content_translation'];
/**
* {@inheritdoc}
@@ -55,7 +55,7 @@ class TermTranslationTest extends TaxonomyTestBase {
*/
public function testTranslatedBreadcrumbs() {
// Ensure non-translated breadcrumb is correct.
- $breadcrumb = array(Url::fromRoute('<front>')->toString() => 'Home');
+ $breadcrumb = [Url::fromRoute('<front>')->toString() => 'Home'];
foreach ($this->terms as $term) {
$breadcrumb[$term->url()] = $term->label();
}
@@ -69,7 +69,7 @@ class TermTranslationTest extends TaxonomyTestBase {
$languages = \Drupal::languageManager()->getLanguages();
// Construct the expected translated breadcrumb.
- $breadcrumb = array(Url::fromRoute('<front>', [], ['language' => $languages[$this->translateToLangcode]])->toString() => 'Home');
+ $breadcrumb = [Url::fromRoute('<front>', [], ['language' => $languages[$this->translateToLangcode]])->toString() => 'Home'];
foreach ($this->terms as $term) {
$translated = $term->getTranslation($this->translateToLangcode);
$url = $translated->url('canonical', ['language' => $languages[$this->translateToLangcode]]);
@@ -92,9 +92,9 @@ class TermTranslationTest extends TaxonomyTestBase {
// Set the display of the term reference field on the article content type
// to "Check boxes/radio buttons".
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->termFieldName, array(
+ ->setComponent($this->termFieldName, [
'type' => 'options_buttons',
- ))
+ ])
->save();
$this->drupalLogin($this->drupalCreateUser(['create article content']));
@@ -118,15 +118,15 @@ class TermTranslationTest extends TaxonomyTestBase {
$parent_vid = 0;
foreach ($this->termTranslationMap as $name => $translation) {
- $term = $this->createTerm($this->vocabulary, array(
+ $term = $this->createTerm($this->vocabulary, [
'name' => $name,
'langcode' => $this->baseLangcode,
'parent' => $parent_vid,
- ));
+ ]);
- $term->addTranslation($this->translateToLangcode, array(
+ $term->addTranslation($this->translateToLangcode, [
'name' => $translation,
- ));
+ ]);
$term->save();
// Each term is nested under the last.
diff --git a/core/modules/taxonomy/src/Tests/TermTranslationUITest.php b/core/modules/taxonomy/src/Tests/TermTranslationUITest.php
index fa9652def57..5e82ffc4fde 100644
--- a/core/modules/taxonomy/src/Tests/TermTranslationUITest.php
+++ b/core/modules/taxonomy/src/Tests/TermTranslationUITest.php
@@ -25,7 +25,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'taxonomy');
+ public static $modules = ['language', 'content_translation', 'taxonomy'];
protected function setUp() {
$this->entityTypeId = 'taxonomy_term';
@@ -54,14 +54,14 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('administer taxonomy'));
+ return array_merge(parent::getTranslatorPermissions(), ['administer taxonomy']);
}
/**
* {@inheritdoc}
*/
protected function getNewEntityValues($langcode) {
- return array('name' => $this->randomMachineName()) + parent::getNewEntityValues($langcode);
+ return ['name' => $this->randomMachineName()] + parent::getNewEntityValues($langcode);
}
/**
@@ -73,7 +73,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
// To be able to post values for the configurable base fields (name,
// description) have to be suffixed with [0][value].
foreach ($edit as $property => $value) {
- foreach (array('name', 'description') as $key) {
+ foreach (['name', 'description'] as $key) {
if ($property == $key) {
$edit[$key . '[0][value]'] = $value;
unset($edit[$property]);
@@ -91,7 +91,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
// Make sure that no row was inserted for taxonomy vocabularies which do
// not have translations enabled.
- $rows = db_query('SELECT tid, count(tid) AS count FROM {taxonomy_term_field_data} WHERE vid <> :vid GROUP BY tid', array(':vid' => $this->bundle))->fetchAll();
+ $rows = db_query('SELECT tid, count(tid) AS count FROM {taxonomy_term_field_data} WHERE vid <> :vid GROUP BY tid', [':vid' => $this->bundle])->fetchAll();
foreach ($rows as $row) {
$this->assertTrue($row->count < 2, 'Term does not have translations.');
}
@@ -103,9 +103,9 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
function testTranslateLinkVocabularyAdminPage() {
$this->drupalLogin($this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), ['access administration pages', 'administer taxonomy'])));
- $values = array(
+ $values = [
'name' => $this->randomMachineName(),
- );
+ ];
$translatable_tid = $this->createEntity($values, $this->langcodes[0], $this->vocabulary->id());
// Create an untranslatable vocabulary.
@@ -118,9 +118,9 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
]);
$untranslatable_vocabulary->save();
- $values = array(
+ $values = [
'name' => $this->randomMachineName(),
- );
+ ];
$untranslatable_tid = $this->createEntity($values, $this->langcodes[0], $untranslatable_vocabulary->id());
// Verify translation links.
@@ -148,14 +148,14 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('@title [%language translation]', array(
+ $title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
diff --git a/core/modules/taxonomy/src/Tests/ThemeTest.php b/core/modules/taxonomy/src/Tests/ThemeTest.php
index 54ad6e4622e..fc7f2cfcdc2 100644
--- a/core/modules/taxonomy/src/Tests/ThemeTest.php
+++ b/core/modules/taxonomy/src/Tests/ThemeTest.php
@@ -14,7 +14,7 @@ class ThemeTest extends TaxonomyTestBase {
// Make sure we are using distinct default and administrative themes for
// the duration of these tests.
- \Drupal::service('theme_handler')->install(array('bartik', 'seven'));
+ \Drupal::service('theme_handler')->install(['bartik', 'seven']);
$this->config('system.theme')
->set('default', 'bartik')
->set('admin', 'seven')
@@ -22,7 +22,7 @@ class ThemeTest extends TaxonomyTestBase {
// Create and log in as a user who has permission to add and edit taxonomy
// terms and view the administrative theme.
- $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'view the administration theme'));
+ $admin_user = $this->drupalCreateUser(['administer taxonomy', 'view the administration theme']);
$this->drupalLogin($admin_user);
}
diff --git a/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php b/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php
index c38c45c39e6..e76d81580f3 100644
--- a/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php
@@ -16,7 +16,7 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('test_taxonomy_node_term_data');
+ public static $testViews = ['test_taxonomy_node_term_data'];
function testViewsHandlerRelationshipNodeTermData() {
$view = Views::getView('test_taxonomy_node_term_data');
@@ -30,16 +30,16 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
],
];
$this->assertIdentical($expected, $view->getDependencies());
- $this->executeView($view, array($this->term1->id(), $this->term2->id()));
- $expected_result = array(
- array(
+ $this->executeView($view, [$this->term1->id(), $this->term2->id()]);
+ $expected_result = [
+ [
'nid' => $this->nodes[1]->id(),
- ),
- array(
+ ],
+ [
'nid' => $this->nodes[0]->id(),
- ),
- );
- $column_map = array('nid' => 'nid');
+ ],
+ ];
+ $column_map = ['nid' => 'nid'];
$this->assertIdenticalResultset($view, $expected_result, $column_map);
// Change the view to test relation limited by vocabulary.
@@ -51,7 +51,7 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
// Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies().
$expected['config'][] = 'taxonomy.vocabulary.views_testing_tags';
$this->assertIdentical($expected, $view->getDependencies());
- $this->executeView($view, array($this->term1->id(), $this->term2->id()));
+ $this->executeView($view, [$this->term1->id(), $this->term2->id()]);
$this->assertIdenticalResultset($view, $expected_result, $column_map);
}
diff --git a/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php b/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php
index d049f822821..aa85c9e5b6e 100644
--- a/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php
@@ -16,7 +16,7 @@ class RelationshipRepresentativeNodeTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('test_groupwise_term');
+ public static $testViews = ['test_groupwise_term'];
/**
* Tests the relationship.
@@ -24,17 +24,17 @@ class RelationshipRepresentativeNodeTest extends TaxonomyTestBase {
public function testRelationship() {
$view = Views::getView('test_groupwise_term');
$this->executeView($view);
- $map = array('node_field_data_taxonomy_term_field_data_nid' => 'nid', 'tid' => 'tid');
- $expected_result = array(
- array(
+ $map = ['node_field_data_taxonomy_term_field_data_nid' => 'nid', 'tid' => 'tid'];
+ $expected_result = [
+ [
'nid' => $this->nodes[1]->id(),
'tid' => $this->term2->id(),
- ),
- array(
+ ],
+ [
'nid' => $this->nodes[1]->id(),
'tid' => $this->term1->id(),
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $map);
}
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php
index c08266f12c1..8b263b4f619 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php
@@ -19,7 +19,7 @@ class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('taxonomy_default_argument_test');
+ public static $testViews = ['taxonomy_default_argument_test'];
/**
* Tests the relationship.
@@ -37,7 +37,7 @@ class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
$view->setResponse($response);
$view->initHandlers();
- $expected = implode(',', array($this->term1->id(), $this->term2->id()));
+ $expected = implode(',', [$this->term1->id(), $this->term2->id()]);
$this->assertEqual($expected, $view->argument['tid']->getDefaultArgument());
$view->destroy();
}
@@ -68,7 +68,7 @@ class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
$view->setResponse($response);
$view->initHandlers();
- $expected = implode(',', array($this->term1->id(), $this->term2->id()));
+ $expected = implode(',', [$this->term1->id(), $this->term2->id()]);
$this->assertEqual($expected, $view->argument['tid']->getDefaultArgument());
}
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php
index 75894ce4332..a75f16ae932 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php
@@ -17,7 +17,7 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('taxonomy_all_terms_test');
+ public static $testViews = ['taxonomy_all_terms_test'];
/**
* Tests the "all terms" field handler.
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
index fb0c0df2d15..2e9602d892b 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
@@ -22,14 +22,14 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language', 'taxonomy', 'taxonomy_test_views', 'text', 'views', 'node');
+ public static $modules = ['language', 'taxonomy', 'taxonomy_test_views', 'text', 'views', 'node'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_field_filters');
+ public static $testViews = ['test_field_filters'];
/**
* The vocabulary used for creating terms.
@@ -53,11 +53,11 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up term names.
- $this->termNames = array(
+ $this->termNames = [
'en' => 'Food in Paris',
'es' => 'Comida en Paris',
'fr' => 'Nouriture en Paris',
- );
+ ];
// Create a vocabulary.
$this->vocabulary = Vocabulary::create([
@@ -67,11 +67,11 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
$this->vocabulary->save();
// Add a translatable field to the vocabulary.
- $field = FieldStorageConfig::create(array(
+ $field = FieldStorageConfig::create([
'field_name' => 'field_foo',
'entity_type' => 'taxonomy_term',
'type' => 'text',
- ));
+ ]);
$field->save();
FieldConfig::create([
'field_name' => 'field_foo',
@@ -81,9 +81,9 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
])->save();
// Create term with translations.
- $taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
- foreach (array('es', 'fr') as $langcode) {
- $translation = $taxonomy->addTranslation($langcode, array('name' => $this->termNames[$langcode]));
+ $taxonomy = $this->createTermWithProperties(['name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']]);
+ foreach (['es', 'fr'] as $langcode) {
+ $translation = $taxonomy->addTranslation($langcode, ['name' => $this->termNames[$langcode]]);
$translation->description->value = $this->termNames[$langcode];
$translation->field_foo->value = $this->termNames[$langcode];
}
@@ -91,7 +91,7 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
Views::viewsData()->clear();
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
$this->container->get('router.builder')->rebuild();
}
@@ -101,27 +101,27 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
public function testFilters() {
// Test the name filter page, which filters for name contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-name-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida name filter');
+ $this->assertPageCounts('test-name-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida name filter');
// Test the description filter page, which filters for description contains
// 'Comida'. Should show just the Spanish translation, once.
- $this->assertPageCounts('test-desc-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida description filter');
+ $this->assertPageCounts('test-desc-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida description filter');
// Test the field filter page, which filters for field_foo contains
// 'Comida'. Should show just the Spanish translation, once.
- $this->assertPageCounts('test-field-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida field filter');
+ $this->assertPageCounts('test-field-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida field filter');
// Test the name Paris filter page, which filters for name contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-name-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris name filter');
+ $this->assertPageCounts('test-name-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris name filter');
// Test the description Paris page, which filters for description contains
// 'Paris'. Should show each translation, once.
- $this->assertPageCounts('test-desc-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris description filter');
+ $this->assertPageCounts('test-desc-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris description filter');
// Test the field Paris filter page, which filters for field_foo contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-field-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris field filter');
+ $this->assertPageCounts('test-field-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris field filter');
}
@@ -163,12 +163,12 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
- $properties += array(
+ $properties += [
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'field_foo' => $this->randomMachineName(),
- );
+ ];
$term = Term::create([
'name' => $properties['name'],
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php
index 6480491fc76..51489ac7951 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php
@@ -17,7 +17,7 @@ class TaxonomyFieldTidTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('test_taxonomy_tid_field');
+ public static $testViews = ['test_taxonomy_tid_field'];
function testViewsHandlerTidField() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php
index 9935aa96475..aa5054feb31 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php
@@ -58,7 +58,7 @@ class TaxonomyIndexTidFilterTest extends TaxonomyTestBase {
$term->save();
$this->terms[$term->id()] = $term;
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
}
/**
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php
index 7dff50a4862..efa51916ddc 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php
@@ -24,7 +24,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_filter_taxonomy_index_tid', 'test_taxonomy_term_name');
+ public static $testViews = ['test_filter_taxonomy_index_tid', 'test_taxonomy_term_name'];
/**
* Modules to enable.
@@ -71,7 +71,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
$term->save();
}
}
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
Vocabulary::create([
'vid' => 'empty_vocabulary',
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
index c79a406cfe1..a57a09a7ad6 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
@@ -18,14 +18,14 @@ class TaxonomyParentUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_taxonomy_parent');
+ public static $testViews = ['test_taxonomy_parent'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('taxonomy', 'taxonomy_test_views');
+ public static $modules = ['taxonomy', 'taxonomy_test_views'];
/**
* {@inheritdoc}
@@ -33,7 +33,7 @@ class TaxonomyParentUITest extends UITestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
}
/**
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php
index bada7fae872..7024e64b44c 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php
@@ -18,14 +18,14 @@ class TaxonomyRelationshipTest extends TaxonomyTestBase {
*
* @var \Drupal\taxonomy\TermInterface[]
*/
- protected $terms = array();
+ protected $terms = [];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_taxonomy_term_relationship');
+ public static $testViews = ['test_taxonomy_term_relationship'];
/**
* {@inheritdoc}
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php
index ef6da478f1f..bfd65cf46fd 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php
@@ -21,7 +21,7 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'views');
+ public static $modules = ['taxonomy', 'views'];
/**
* An user with permissions to administer taxonomy.
@@ -51,23 +51,23 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
$this->fieldName1 = Unicode::strtolower($this->randomMachineName());
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName1, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName1, array(
+ ->setComponent($this->fieldName1, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->fieldName1, array(
+ ->setComponent($this->fieldName1, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -79,7 +79,7 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
$term = $this->createTerm();
// Post an article.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $original_title = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$edit["{$this->fieldName1}[]"] = $term->id();
@@ -90,7 +90,7 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
$this->assertText($term->label());
$this->assertText($node->label());
- \Drupal::service('module_installer')->install(array('language', 'content_translation'));
+ \Drupal::service('module_installer')->install(['language', 'content_translation']);
$language = ConfigurableLanguage::createFromLangcode('ur');
$language->save();
// Enable translation for the article content type and ensure the change is
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
index dc5755993cd..6ff5514188e 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
@@ -22,14 +22,14 @@ abstract class TaxonomyTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'taxonomy_test_views');
+ public static $modules = ['taxonomy', 'taxonomy_test_views'];
/**
* Stores the nodes used for the different tests.
*
* @var \Drupal\node\NodeInterface[]
*/
- protected $nodes = array();
+ protected $nodes = [];
/**
* The vocabulary used for creating terms.
@@ -60,13 +60,13 @@ abstract class TaxonomyTestBase extends ViewTestBase {
$this->mockStandardInstall();
if ($import_test_views) {
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
}
$this->term1 = $this->createTerm();
$this->term2 = $this->createTerm();
- $node = array();
+ $node = [];
$node['type'] = 'article';
$node['field_views_testing_tags'][]['target_id'] = $this->term1->id();
$node['field_views_testing_tags'][]['target_id'] = $this->term2->id();
@@ -80,9 +80,9 @@ abstract class TaxonomyTestBase extends ViewTestBase {
* @see https://www.drupal.org/node/1708692
*/
protected function mockStandardInstall() {
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
- ));
+ ]);
// Create the vocabulary for the tag field.
$this->vocabulary = Vocabulary::create([
'name' => 'Views testing tags',
@@ -91,32 +91,32 @@ abstract class TaxonomyTestBase extends ViewTestBase {
$this->vocabulary->save();
$field_name = 'field_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_autocomplete_tags',
'weight' => -4,
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
'weight' => 10,
- ))
+ ])
->save();
entity_get_display('node', 'article', 'teaser')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
'weight' => 10,
- ))
+ ])
->save();
}
diff --git a/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php b/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php
index 2effe722b9e..98d1ab4b48f 100644
--- a/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php
@@ -16,7 +16,7 @@ class TermNameFieldTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
- public static $testViews = array('test_taxonomy_term_name');
+ public static $testViews = ['test_taxonomy_term_name'];
/**
* Tests term name field plugin functionality.
diff --git a/core/modules/taxonomy/src/Tests/VocabularyUiTest.php b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php
index 76fcac2bb08..e3710d610b2 100644
--- a/core/modules/taxonomy/src/Tests/VocabularyUiTest.php
+++ b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php
@@ -37,13 +37,13 @@ class VocabularyUiTest extends TaxonomyTestBase {
// Create a new vocabulary.
$this->clickLink(t('Add vocabulary'));
- $edit = array();
+ $edit = [];
$vid = Unicode::strtolower($this->randomMachineName());
$edit['name'] = $this->randomMachineName();
$edit['description'] = $this->randomMachineName();
$edit['vid'] = $vid;
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('Created new vocabulary %name.', array('%name' => $edit['name'])), 'Vocabulary created successfully.');
+ $this->assertRaw(t('Created new vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary created successfully.');
// Edit the vocabulary.
$this->drupalGet('admin/structure/taxonomy');
@@ -51,7 +51,7 @@ class VocabularyUiTest extends TaxonomyTestBase {
$this->assertText($edit['description'], 'Vocabulary description found in the vocabulary overview listing.');
$this->assertLinkByHref(Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $edit['vid']])->toString());
$this->clickLink(t('Edit vocabulary'));
- $edit = array();
+ $edit = [];
$edit['name'] = $this->randomMachineName();
$edit['description'] = $this->randomMachineName();
$this->drupalPostForm(NULL, $edit, t('Save'));
@@ -70,15 +70,15 @@ class VocabularyUiTest extends TaxonomyTestBase {
$this->assertText(t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
// Ensure that vocabulary titles are escaped properly.
- $edit = array();
+ $edit = [];
$edit['name'] = 'Don\'t Panic';
$edit['description'] = $this->randomMachineName();
$edit['vid'] = 'don_t_panic';
$this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
$site_name = $this->config('system.site')->get('name');
- $this->assertTitle(t('Don\'t Panic | @site-name', array('@site-name' => $site_name)), 'The page title contains the escaped character.');
- $this->assertNoTitle(t('Don&#039;t Panic | @site-name', array('@site-name' => $site_name)), 'The page title does not contain an encoded character.');
+ $this->assertTitle(t('Don\'t Panic | @site-name', ['@site-name' => $site_name]), 'The page title contains the escaped character.');
+ $this->assertNoTitle(t('Don&#039;t Panic | @site-name', ['@site-name' => $site_name]), 'The page title does not contain an encoded character.');
}
/**
@@ -91,7 +91,7 @@ class VocabularyUiTest extends TaxonomyTestBase {
}
// Get all vocabularies and change their weights.
$vocabularies = Vocabulary::loadMultiple();
- $edit = array();
+ $edit = [];
foreach ($vocabularies as $key => $vocabulary) {
$weight = -$vocabulary->get('weight');
$vocabularies[$key]->set('weight', $weight);
@@ -132,10 +132,10 @@ class VocabularyUiTest extends TaxonomyTestBase {
function testTaxonomyAdminDeletingVocabulary() {
// Create a vocabulary.
$vid = Unicode::strtolower($this->randomMachineName());
- $edit = array(
+ $edit = [
'name' => $this->randomMachineName(),
'vid' => $vid,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
$this->assertText(t('Created new vocabulary'), 'New vocabulary was created.');
@@ -147,12 +147,12 @@ class VocabularyUiTest extends TaxonomyTestBase {
// Delete the vocabulary.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id());
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->label())), '[confirm deletion] Asks for confirmation.');
+ $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', ['%name' => $vocabulary->label()]), '[confirm deletion] Asks for confirmation.');
$this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), '[confirm deletion] Inform that all terms will be deleted.');
// Confirm deletion.
$this->drupalPostForm(NULL, NULL, t('Delete'));
- $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->label())), 'Vocabulary deleted.');
+ $this->assertRaw(t('Deleted vocabulary %name.', ['%name' => $vocabulary->label()]), 'Vocabulary deleted.');
$this->container->get('entity.manager')->getStorage('taxonomy_vocabulary')->resetCache();
$this->assertFalse(Vocabulary::load($vid), 'Vocabulary not found.');
}
diff --git a/core/modules/taxonomy/src/VocabularyForm.php b/core/modules/taxonomy/src/VocabularyForm.php
index 1868ddc38f4..63f0ccb8ab5 100644
--- a/core/modules/taxonomy/src/VocabularyForm.php
+++ b/core/modules/taxonomy/src/VocabularyForm.php
@@ -52,59 +52,59 @@ class VocabularyForm extends BundleEntityFormBase {
$form['#title'] = $this->t('Edit vocabulary');
}
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#default_value' => $vocabulary->label(),
'#maxlength' => 255,
'#required' => TRUE,
- );
- $form['vid'] = array(
+ ];
+ $form['vid'] = [
'#type' => 'machine_name',
'#default_value' => $vocabulary->id(),
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
- 'source' => array('name'),
- ),
- );
- $form['description'] = array(
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
+ 'source' => ['name'],
+ ],
+ ];
+ $form['description'] = [
'#type' => 'textfield',
'#title' => $this->t('Description'),
'#default_value' => $vocabulary->getDescription(),
- );
+ ];
// $form['langcode'] is not wrapped in an
// if ($this->moduleHandler->moduleExists('language')) check because the
// language_select form element works also without the language module being
// installed. https://www.drupal.org/node/1749954 documents the new element.
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'language_select',
'#title' => $this->t('Vocabulary language'),
'#languages' => LanguageInterface::STATE_ALL,
'#default_value' => $vocabulary->language()->getId(),
- );
+ ];
if ($this->moduleHandler->moduleExists('language')) {
- $form['default_terms_language'] = array(
+ $form['default_terms_language'] = [
'#type' => 'details',
'#title' => $this->t('Terms language'),
'#open' => TRUE,
- );
- $form['default_terms_language']['default_language'] = array(
+ ];
+ $form['default_terms_language']['default_language'] = [
'#type' => 'language_configuration',
- '#entity_information' => array(
+ '#entity_information' => [
'entity_type' => 'taxonomy_term',
'bundle' => $vocabulary->id(),
- ),
+ ],
'#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vocabulary->id()),
- );
+ ];
}
// Set the hierarchy to "multiple parents" by default. This simplifies the
// vocabulary form and standardizes the term form.
- $form['hierarchy'] = array(
+ $form['hierarchy'] = [
'#type' => 'value',
'#value' => '0',
- );
+ ];
$form = parent::form($form, $form_state);
return $this->protectBundleIdElement($form);
@@ -123,14 +123,14 @@ class VocabularyForm extends BundleEntityFormBase {
$edit_link = $this->entity->link($this->t('Edit'));
switch ($status) {
case SAVED_NEW:
- drupal_set_message($this->t('Created new vocabulary %name.', array('%name' => $vocabulary->label())));
- $this->logger('taxonomy')->notice('Created new vocabulary %name.', array('%name' => $vocabulary->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Created new vocabulary %name.', ['%name' => $vocabulary->label()]));
+ $this->logger('taxonomy')->notice('Created new vocabulary %name.', ['%name' => $vocabulary->label(), 'link' => $edit_link]);
$form_state->setRedirectUrl($vocabulary->urlInfo('overview-form'));
break;
case SAVED_UPDATED:
- drupal_set_message($this->t('Updated vocabulary %name.', array('%name' => $vocabulary->label())));
- $this->logger('taxonomy')->notice('Updated vocabulary %name.', array('%name' => $vocabulary->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Updated vocabulary %name.', ['%name' => $vocabulary->label()]));
+ $this->logger('taxonomy')->notice('Updated vocabulary %name.', ['%name' => $vocabulary->label(), 'link' => $edit_link]);
$form_state->setRedirectUrl($vocabulary->urlInfo('collection'));
break;
}
diff --git a/core/modules/taxonomy/src/VocabularyListBuilder.php b/core/modules/taxonomy/src/VocabularyListBuilder.php
index 9c24311f1dc..8503c288a90 100644
--- a/core/modules/taxonomy/src/VocabularyListBuilder.php
+++ b/core/modules/taxonomy/src/VocabularyListBuilder.php
@@ -36,16 +36,16 @@ class VocabularyListBuilder extends DraggableListBuilder {
$operations['edit']['title'] = t('Edit vocabulary');
}
- $operations['list'] = array(
+ $operations['list'] = [
'title' => t('List terms'),
'weight' => 0,
'url' => $entity->urlInfo('overview-form'),
- );
- $operations['add'] = array(
+ ];
+ $operations['add'] = [
'title' => t('Add terms'),
'weight' => 10,
'url' => Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $entity->id()]),
- );
+ ];
unset($operations['delete']);
return $operations;
@@ -80,7 +80,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
unset($this->weightKey);
}
$build = parent::render();
- $build['table']['#empty'] = t('No vocabularies available. <a href=":link">Add vocabulary</a>.', array(':link' => \Drupal::url('entity.taxonomy_vocabulary.add_form')));
+ $build['table']['#empty'] = t('No vocabularies available. <a href=":link">Add vocabulary</a>.', [':link' => \Drupal::url('entity.taxonomy_vocabulary.add_form')]);
return $build;
}
@@ -89,7 +89,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
- $form['vocabularies']['#attributes'] = array('id' => 'taxonomy');
+ $form['vocabularies']['#attributes'] = ['id' => 'taxonomy'];
$form['actions']['submit']['#value'] = t('Save');
return $form;
diff --git a/core/modules/taxonomy/src/VocabularyStorage.php b/core/modules/taxonomy/src/VocabularyStorage.php
index 4b08b2931f0..bdbf8938f70 100644
--- a/core/modules/taxonomy/src/VocabularyStorage.php
+++ b/core/modules/taxonomy/src/VocabularyStorage.php
@@ -21,7 +21,7 @@ class VocabularyStorage extends ConfigEntityStorage implements VocabularyStorage
* {@inheritdoc}
*/
public function getToplevelTids($vids) {
- return db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid IN ( :vids[] ) AND th.parent = 0', array(':vids[]' => $vids))->fetchCol();
+ return db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid IN ( :vids[] ) AND th.parent = 0', [':vids[]' => $vids])->fetchCol();
}
}
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 80884329bd9..4a93989ad52 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -47,23 +47,23 @@ const TAXONOMY_HIERARCHY_MULTIPLE = 2;
function taxonomy_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.taxonomy':
- $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
+ $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Taxonomy module allows users who have permission to create and edit content to categorize (tag) content of that type. Users who have the <em>Administer vocabularies and terms</em> <a href=":permissions" title="Taxonomy module permissions">permission</a> can add <em>vocabularies</em> that contain a set of related <em>terms</em>. The terms in a vocabulary can either be pre-set by an administrator or built gradually as content is added and edited. Terms may be organized hierarchically if desired.', array(':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-taxonomy')))) . '</p>';
- $output .= '<p>' . t('For more information, see the <a href=":taxonomy">online documentation for the Taxonomy module</a>.', array(':taxonomy' => 'https://www.drupal.org/documentation/modules/taxonomy/')) . '</p>';
+ $output .= '<p>' . t('The Taxonomy module allows users who have permission to create and edit content to categorize (tag) content of that type. Users who have the <em>Administer vocabularies and terms</em> <a href=":permissions" title="Taxonomy module permissions">permission</a> can add <em>vocabularies</em> that contain a set of related <em>terms</em>. The terms in a vocabulary can either be pre-set by an administrator or built gradually as content is added and edited. Terms may be organized hierarchically if desired.', [':permissions' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-taxonomy'])]) . '</p>';
+ $output .= '<p>' . t('For more information, see the <a href=":taxonomy">online documentation for the Taxonomy module</a>.', [':taxonomy' => 'https://www.drupal.org/documentation/modules/taxonomy/']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing vocabularies') . '</dt>';
- $output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission can add and edit vocabularies from the <a href=":taxonomy_admin">Taxonomy administration page</a>. Vocabularies can be deleted from their <em>Edit vocabulary</em> page. Users with the <em>Taxonomy term: Administer fields</em> permission may add additional fields for terms in that vocabulary using the <a href=":field_ui">Field UI module</a>.', array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), ':field_ui' => $field_ui_url)) . '</dd>';
+ $output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission can add and edit vocabularies from the <a href=":taxonomy_admin">Taxonomy administration page</a>. Vocabularies can be deleted from their <em>Edit vocabulary</em> page. Users with the <em>Taxonomy term: Administer fields</em> permission may add additional fields for terms in that vocabulary using the <a href=":field_ui">Field UI module</a>.', [':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), ':field_ui' => $field_ui_url]) . '</dd>';
$output .= '<dt>' . t('Managing terms') . '</dt>';
- $output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission or the <em>Edit terms</em> permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the <a href=":taxonomy_admin">Taxonomy administration page</a> and clicking <em>List terms</em> in the <em>Operations</em> column. Users must have the <em>Administer vocabularies and terms</em> permission or the <em>Delete terms</em> permission for a particular vocabulary to delete terms.', array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'))) . ' </dd>';
+ $output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission or the <em>Edit terms</em> permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the <a href=":taxonomy_admin">Taxonomy administration page</a> and clicking <em>List terms</em> in the <em>Operations</em> column. Users must have the <em>Administer vocabularies and terms</em> permission or the <em>Delete terms</em> permission for a particular vocabulary to delete terms.', [':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection')]) . ' </dd>';
$output .= '<dt>' . t('Classifying entity content') . '</dt>';
- $output .= '<dd>' . t('A user with the <em>Administer fields</em> permission for a certain entity type may add <em>Taxonomy term</em> reference fields to the entity type, which will allow entities to be classified using taxonomy terms. See the <a href=":entity_reference">Entity Reference help</a> for more information about reference fields. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them.', array(':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', array('name' => 'field')), ':entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '</dd>';
+ $output .= '<dd>' . t('A user with the <em>Administer fields</em> permission for a certain entity type may add <em>Taxonomy term</em> reference fields to the entity type, which will allow entities to be classified using taxonomy terms. See the <a href=":entity_reference">Entity Reference help</a> for more information about reference fields. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them.', [':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', ['name' => 'field']), ':entity_reference' => \Drupal::url('help.page', ['name' => 'entity_reference'])]) . '</dd>';
$output .= '<dt>' . t('Adding new terms during content creation') . '</dt>';
$output .= '<dd>' . t('Allowing users to add new terms gradually builds a vocabulary as content is added and edited. Users can add new terms if either of the two <em>Autocomplete</em> widgets is chosen for the Taxonomy term reference field in the <em>Manage form display</em> page for the field. You will also need to enable the <em>Create referenced entities if they don\'t already exist</em> option, and restrict the field to one vocabulary.') . '</dd>';
$output .= '<dt>' . t('Configuring displays and form displays') . '</dt>';
- $output .= '<dd>' . t('See the <a href=":entity_reference">Entity Reference help</a> page for the field widgets and formatters that can be configured for any reference field on the <em>Manage display</em> and <em>Manage form display</em> pages. Taxonomy additionally provides an <em>RSS category</em> formatter that displays nothing when the entity item is displayed as HTML, but displays an RSS category instead of a list when the entity item is displayed in an RSS feed.', array(':entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '</li>';
+ $output .= '<dd>' . t('See the <a href=":entity_reference">Entity Reference help</a> page for the field widgets and formatters that can be configured for any reference field on the <em>Manage display</em> and <em>Manage form display</em> pages. Taxonomy additionally provides an <em>RSS category</em> formatter that displays nothing when the entity item is displayed as HTML, but displays an RSS category instead of a list when the entity item is displayed in an RSS feed.', [':entity_reference' => \Drupal::url('help.page', ['name' => 'entity_reference'])]) . '</li>';
$output .= '</ul>';
$output .= '</dd>';
$output .= '</dl>';
@@ -77,11 +77,11 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) {
$vocabulary = $route_match->getParameter('taxonomy_vocabulary');
switch ($vocabulary->getHierarchy()) {
case VocabularyInterface::HIERARCHY_DISABLED:
- return '<p>' . t('You can reorganize the terms in %capital_name using their drag-and-drop handles, and group terms under a parent term by sliding them under and to the right of the parent.', array('%capital_name' => Unicode::ucfirst($vocabulary->label()), '%name' => $vocabulary->label())) . '</p>';
+ return '<p>' . t('You can reorganize the terms in %capital_name using their drag-and-drop handles, and group terms under a parent term by sliding them under and to the right of the parent.', ['%capital_name' => Unicode::ucfirst($vocabulary->label()), '%name' => $vocabulary->label()]) . '</p>';
case VocabularyInterface::HIERARCHY_SINGLE:
- return '<p>' . t('%capital_name contains terms grouped under parent terms. You can reorganize the terms in %capital_name using their drag-and-drop handles.', array('%capital_name' => Unicode::ucfirst($vocabulary->label()), '%name' => $vocabulary->label())) . '</p>';
+ return '<p>' . t('%capital_name contains terms grouped under parent terms. You can reorganize the terms in %capital_name using their drag-and-drop handles.', ['%capital_name' => Unicode::ucfirst($vocabulary->label()), '%name' => $vocabulary->label()]) . '</p>';
case VocabularyInterface::HIERARCHY_MULTIPLE:
- return '<p>' . t('%capital_name contains terms with multiple parents. Drag and drop of terms with multiple parents is not supported, but you can re-enable drag-and-drop support by editing each term to include only a single parent.', array('%capital_name' => Unicode::ucfirst($vocabulary->label()))) . '</p>';
+ return '<p>' . t('%capital_name contains terms with multiple parents. Drag and drop of terms with multiple parents is not supported, but you can re-enable drag-and-drop support by editing each term to include only a single parent.', ['%capital_name' => Unicode::ucfirst($vocabulary->label())]) . '</p>';
}
}
}
@@ -90,9 +90,9 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) {
* Entity URI callback.
*/
function taxonomy_term_uri($term) {
- return new Url('entity.taxonomy_term.canonical', array(
+ return new Url('entity.taxonomy_term.canonical', [
'taxonomy_term' => $term->id(),
- ));
+ ]);
}
/**
@@ -103,24 +103,24 @@ function taxonomy_page_attachments_alter(array &$page) {
if ($route_match->getRouteName() == 'entity.taxonomy_term.canonical' && ($term = $route_match->getParameter('taxonomy_term')) && $term instanceof TermInterface) {
foreach ($term->uriRelationships() as $rel) {
// Set the URI relationships, like canonical.
- $page['#attached']['html_head_link'][] = array(
- array(
+ $page['#attached']['html_head_link'][] = [
+ [
'rel' => $rel,
'href' => $term->url($rel),
- ),
+ ],
TRUE,
- );
+ ];
// Set the term path as the canonical URL to prevent duplicate content.
if ($rel == 'canonical') {
// Set the non-aliased canonical path as a default shortlink.
- $page['#attached']['html_head_link'][] = array(
- array(
+ $page['#attached']['html_head_link'][] = [
+ [
'rel' => 'shortlink',
- 'href' => $term->url($rel, array('alias' => TRUE)),
- ),
+ 'href' => $term->url($rel, ['alias' => TRUE]),
+ ],
TRUE,
- );
+ ];
}
}
}
@@ -130,11 +130,11 @@ function taxonomy_page_attachments_alter(array &$page) {
* Implements hook_theme().
*/
function taxonomy_theme() {
- return array(
- 'taxonomy_term' => array(
+ return [
+ 'taxonomy_term' => [
'render element' => 'elements',
- ),
- );
+ ],
+ ];
}
/**
@@ -223,7 +223,7 @@ function taxonomy_term_view_multiple(array $terms, $view_mode = 'full', $langcod
* Implements hook_theme_suggestions_HOOK().
*/
function taxonomy_theme_suggestions_taxonomy_term(array $variables) {
- $suggestions = array();
+ $suggestions = [];
/** @var \Drupal\taxonomy\TermInterface $term */
$term = $variables['elements']['#taxonomy_term'];
@@ -261,7 +261,7 @@ function template_preprocess_taxonomy_term(&$variables) {
$variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);
// Helpful $content variable for templates.
- $variables['content'] = array();
+ $variables['content'] = [];
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
@@ -307,7 +307,7 @@ function taxonomy_vocabulary_get_names() {
$names = &drupal_static(__FUNCTION__);
if (!isset($names)) {
- $names = array();
+ $names = [];
$config_names = \Drupal::configFactory()->listAll('taxonomy.vocabulary.');
foreach ($config_names as $config_name) {
$id = substr($config_name, strlen('taxonomy.vocabulary.'));
@@ -333,7 +333,7 @@ function taxonomy_vocabulary_get_names() {
* An array of matching term objects.
*/
function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) {
- $values = array('name' => trim($name));
+ $values = ['name' => trim($name)];
if (isset($vocabulary)) {
$vocabularies = taxonomy_vocabulary_get_names();
if (isset($vocabularies[$vocabulary])) {
@@ -341,7 +341,7 @@ function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) {
}
else {
// Return an empty array when filtering by a non-existing vocabulary.
- return array();
+ return [];
}
}
return entity_load_multiple_by_properties('taxonomy_term', $values);
@@ -436,7 +436,7 @@ function taxonomy_term_load($tid) {
* @see \Drupal\Component\Utility\Tags::explode()
*/
function taxonomy_implode_tags($tags, $vid = NULL) {
- $typed_tags = array();
+ $typed_tags = [];
foreach ($tags as $tag) {
// Extract terms belonging to the vocabulary in question.
if (!isset($vid) || $tag->bundle() == $vid) {
@@ -510,7 +510,7 @@ function taxonomy_build_node_index($node) {
// We only maintain the taxonomy index for published nodes.
if ($status && $node->isDefaultRevision()) {
// Collect a unique list of all the term IDs from all node fields.
- $tid_all = array();
+ $tid_all = [];
$entity_reference_class = 'Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem';
foreach ($node->getFieldDefinitions() as $field) {
$field_name = $field->getName();
@@ -530,8 +530,8 @@ function taxonomy_build_node_index($node) {
if (!empty($tid_all)) {
foreach ($tid_all as $tid) {
db_merge('taxonomy_index')
- ->key(array('nid' => $node->id(), 'tid' => $tid, 'status' => $node->isPublished()))
- ->fields(array('sticky' => $sticky, 'created' => $node->getCreatedTime()))
+ ->key(['nid' => $node->id(), 'tid' => $tid, 'status' => $node->isPublished()])
+ ->fields(['sticky' => $sticky, 'created' => $node->getCreatedTime()])
->execute();
}
}
diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc
index 20251f224c6..211a1214451 100644
--- a/core/modules/taxonomy/taxonomy.tokens.inc
+++ b/core/modules/taxonomy/taxonomy.tokens.inc
@@ -12,80 +12,80 @@ use Drupal\taxonomy\Entity\Vocabulary;
* Implements hook_token_info().
*/
function taxonomy_token_info() {
- $types['term'] = array(
+ $types['term'] = [
'name' => t("Taxonomy terms"),
'description' => t("Tokens related to taxonomy terms."),
'needs-data' => 'term',
- );
- $types['vocabulary'] = array(
+ ];
+ $types['vocabulary'] = [
'name' => t("Vocabularies"),
'description' => t("Tokens related to taxonomy vocabularies."),
'needs-data' => 'vocabulary',
- );
+ ];
// Taxonomy term related variables.
- $term['tid'] = array(
+ $term['tid'] = [
'name' => t("Term ID"),
'description' => t("The unique ID of the taxonomy term."),
- );
- $term['name'] = array(
+ ];
+ $term['name'] = [
'name' => t("Name"),
'description' => t("The name of the taxonomy term."),
- );
- $term['description'] = array(
+ ];
+ $term['description'] = [
'name' => t("Description"),
'description' => t("The optional description of the taxonomy term."),
- );
- $term['node-count'] = array(
+ ];
+ $term['node-count'] = [
'name' => t("Node count"),
'description' => t("The number of nodes tagged with the taxonomy term."),
- );
- $term['url'] = array(
+ ];
+ $term['url'] = [
'name' => t("URL"),
'description' => t("The URL of the taxonomy term."),
- );
+ ];
// Taxonomy vocabulary related variables.
- $vocabulary['vid'] = array(
+ $vocabulary['vid'] = [
'name' => t("Vocabulary ID"),
'description' => t("The unique ID of the taxonomy vocabulary."),
- );
- $vocabulary['name'] = array(
+ ];
+ $vocabulary['name'] = [
'name' => t("Name"),
'description' => t("The name of the taxonomy vocabulary."),
- );
- $vocabulary['description'] = array(
+ ];
+ $vocabulary['description'] = [
'name' => t("Description"),
'description' => t("The optional description of the taxonomy vocabulary."),
- );
- $vocabulary['node-count'] = array(
+ ];
+ $vocabulary['node-count'] = [
'name' => t("Node count"),
'description' => t("The number of nodes tagged with terms belonging to the taxonomy vocabulary."),
- );
- $vocabulary['term-count'] = array(
+ ];
+ $vocabulary['term-count'] = [
'name' => t("Term count"),
'description' => t("The number of terms belonging to the taxonomy vocabulary."),
- );
+ ];
// Chained tokens for taxonomies
- $term['vocabulary'] = array(
+ $term['vocabulary'] = [
'name' => t("Vocabulary"),
'description' => t("The vocabulary the taxonomy term belongs to."),
'type' => 'vocabulary',
- );
- $term['parent'] = array(
+ ];
+ $term['parent'] = [
'name' => t("Parent term"),
'description' => t("The parent term of the taxonomy term, if one exists."),
'type' => 'term',
- );
+ ];
- return array(
+ return [
'types' => $types,
- 'tokens' => array(
+ 'tokens' => [
'term' => $term,
'vocabulary' => $vocabulary,
- ),
- );
+ ],
+ ];
}
/**
@@ -94,7 +94,7 @@ function taxonomy_token_info() {
function taxonomy_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $replacements = array();
+ $replacements = [];
$taxonomy_storage = \Drupal::entityManager()->getStorage('taxonomy_term');
if ($type == 'term' && !empty($data['term'])) {
$term = $data['term'];
@@ -116,7 +116,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
break;
case 'url':
- $replacements[$original] = $term->url('canonical', array('absolute' => TRUE));
+ $replacements[$original] = $term->url('canonical', ['absolute' => TRUE]);
break;
case 'node-count':
@@ -145,12 +145,12 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
if ($vocabulary_tokens = $token_service->findWithPrefix($tokens, 'vocabulary')) {
$vocabulary = Vocabulary::load($term->bundle());
- $replacements += $token_service->generate('vocabulary', $vocabulary_tokens, array('vocabulary' => $vocabulary), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('vocabulary', $vocabulary_tokens, ['vocabulary' => $vocabulary], $options, $bubbleable_metadata);
}
if (($vocabulary_tokens = $token_service->findWithPrefix($tokens, 'parent')) && $parents = $taxonomy_storage->loadParents($term->id())) {
$parent = array_pop($parents);
- $replacements += $token_service->generate('term', $vocabulary_tokens, array('term' => $parent), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('term', $vocabulary_tokens, ['term' => $parent], $options, $bubbleable_metadata);
}
}
diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc
index 5360d508147..1eedbbe7bf0 100644
--- a/core/modules/taxonomy/taxonomy.views.inc
+++ b/core/modules/taxonomy/taxonomy.views.inc
@@ -11,44 +11,44 @@ use Drupal\field\FieldStorageConfigInterface;
* Implements hook_views_data_alter().
*/
function taxonomy_views_data_alter(&$data) {
- $data['node_field_data']['term_node_tid'] = array(
+ $data['node_field_data']['term_node_tid'] = [
'title' => t('Taxonomy terms on node'),
'help' => t('Relate nodes to taxonomy terms, specifying which vocabulary or vocabularies to use. This relationship will cause duplicated records if there are multiple terms.'),
- 'relationship' => array(
+ 'relationship' => [
'id' => 'node_term_data',
'label' => t('term'),
'base' => 'taxonomy_term_field_data',
- ),
- 'field' => array(
+ ],
+ 'field' => [
'title' => t('All taxonomy terms'),
'help' => t('Display all taxonomy terms associated with a node from specified vocabularies.'),
'id' => 'taxonomy_index_tid',
'no group by' => TRUE,
'click sortable' => FALSE,
- ),
- );
+ ],
+ ];
- $data['node_field_data']['term_node_tid_depth'] = array(
+ $data['node_field_data']['term_node_tid_depth'] = [
'help' => t('Display content if it has the selected taxonomy terms, or children of the selected terms. Due to additional complexity, this has fewer options than the versions without depth.'),
'real field' => 'nid',
- 'argument' => array(
+ 'argument' => [
'title' => t('Has taxonomy term ID (with depth)'),
'id' => 'taxonomy_index_tid_depth',
'accept depth modifier' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'title' => t('Has taxonomy terms (with depth)'),
'id' => 'taxonomy_index_tid_depth',
- ),
- );
+ ],
+ ];
- $data['node_field_data']['term_node_tid_depth_modifier'] = array(
+ $data['node_field_data']['term_node_tid_depth_modifier'] = [
'title' => t('Has taxonomy term ID depth modifier'),
'help' => t('Allows the "depth" for Taxonomy: Term ID (with depth) to be modified via an additional contextual filter value.'),
- 'argument' => array(
+ 'argument' => [
'id' => 'taxonomy_index_tid_depth_modifier',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/taxonomy/tests/src/Functional/EfqTest.php b/core/modules/taxonomy/tests/src/Functional/EfqTest.php
index 1f788c82eef..945c0b1085c 100644
--- a/core/modules/taxonomy/tests/src/Functional/EfqTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/EfqTest.php
@@ -26,7 +26,7 @@ class EfqTest extends TaxonomyTestBase {
* Tests that a basic taxonomy entity query works.
*/
function testTaxonomyEfq() {
- $terms = array();
+ $terms = [];
for ($i = 0; $i < 5; $i++) {
$term = $this->createTerm($this->vocabulary);
$terms[$term->id()] = $term;
@@ -35,17 +35,17 @@ class EfqTest extends TaxonomyTestBase {
sort($result);
$this->assertEqual(array_keys($terms), $result, 'Taxonomy terms were retrieved by entity query.');
$tid = reset($result);
- $ids = (object) array(
+ $ids = (object) [
'entity_type' => 'taxonomy_term',
'entity_id' => $tid,
'bundle' => $this->vocabulary->id(),
- );
+ ];
$term = _field_create_entity_from_ids($ids);
$this->assertEqual($term->id(), $tid, 'Taxonomy term can be created based on the IDs.');
// Create a second vocabulary and five more terms.
$vocabulary2 = $this->createVocabulary();
- $terms2 = array();
+ $terms2 = [];
for ($i = 0; $i < 5; $i++) {
$term = $this->createTerm($vocabulary2);
$terms2[$term->id()] = $term;
@@ -55,13 +55,13 @@ class EfqTest extends TaxonomyTestBase {
->condition('vid', $vocabulary2->id())
->execute();
sort($result);
- $this->assertEqual(array_keys($terms2), $result, format_string('Taxonomy terms from the %name vocabulary were retrieved by entity query.', array('%name' => $vocabulary2->label())));
+ $this->assertEqual(array_keys($terms2), $result, format_string('Taxonomy terms from the %name vocabulary were retrieved by entity query.', ['%name' => $vocabulary2->label()]));
$tid = reset($result);
- $ids = (object) array(
+ $ids = (object) [
'entity_type' => 'taxonomy_term',
'entity_id' => $tid,
'bundle' => $vocabulary2->id(),
- );
+ ];
$term = _field_create_entity_from_ids($ids);
$this->assertEqual($term->id(), $tid, 'Taxonomy term can be created based on the IDs.');
}
diff --git a/core/modules/taxonomy/tests/src/Functional/LegacyTest.php b/core/modules/taxonomy/tests/src/Functional/LegacyTest.php
index fbbe16f9ffb..f3b0a74e090 100644
--- a/core/modules/taxonomy/tests/src/Functional/LegacyTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/LegacyTest.php
@@ -18,7 +18,7 @@ class LegacyTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('node', 'datetime');
+ public static $modules = ['node', 'datetime'];
protected function setUp() {
parent::setUp();
@@ -31,18 +31,18 @@ class LegacyTest extends TaxonomyTestBase {
$vocabulary->save();
$field_name = 'field_' . $vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
$this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'bypass node access']));
@@ -54,7 +54,7 @@ class LegacyTest extends TaxonomyTestBase {
function testTaxonomyLegacyNode() {
// Posts an article with a taxonomy term and a date prior to 1970.
$date = new DrupalDateTime('1969-01-01 00:00:00');
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['created[0][value][date]'] = $date->format('Y-m-d');
$edit['created[0][value][time]'] = $date->format('H:i:s');
diff --git a/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php b/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php
index 495599272cd..ce41b2ffc92 100644
--- a/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/LoadMultipleTest.php
@@ -31,9 +31,9 @@ class LoadMultipleTest extends TaxonomyTestBase {
$this->createTerm($vocabulary);
}
// Load the terms from the vocabulary.
- $terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
+ $terms = entity_load_multiple_by_properties('taxonomy_term', ['vid' => $vocabulary->id()]);
$count = count($terms);
- $this->assertEqual($count, 5, format_string('Correct number of terms were loaded. @count terms.', array('@count' => $count)));
+ $this->assertEqual($count, 5, format_string('Correct number of terms were loaded. @count terms.', ['@count' => $count]));
// Load the same terms again by tid.
$terms2 = Term::loadMultiple(array_keys($terms));
@@ -47,13 +47,13 @@ class LoadMultipleTest extends TaxonomyTestBase {
$this->assertFalse($deleted_term);
// Load terms from the vocabulary by vid.
- $terms3 = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
+ $terms3 = entity_load_multiple_by_properties('taxonomy_term', ['vid' => $vocabulary->id()]);
$this->assertEqual(count($terms3), 4, 'Correct number of terms were loaded.');
$this->assertFalse(isset($terms3[$deleted->id()]));
// Create a single term and load it by name.
$term = $this->createTerm($vocabulary);
- $loaded_terms = entity_load_multiple_by_properties('taxonomy_term', array('name' => $term->getName()));
+ $loaded_terms = entity_load_multiple_by_properties('taxonomy_term', ['name' => $term->getName()]);
$this->assertEqual(count($loaded_terms), 1, 'One term was loaded.');
$loaded_term = reset($loaded_terms);
$this->assertEqual($term->id(), $loaded_term->id(), 'Term loaded by name successfully.');
diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyTestBase.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTestBase.php
index 2625af076f7..ed8b95f6062 100644
--- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTestBase.php
@@ -19,7 +19,7 @@ abstract class TaxonomyTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'block');
+ public static $modules = ['taxonomy', 'block'];
/**
* {@inheritdoc}
@@ -30,7 +30,7 @@ abstract class TaxonomyTestBase extends BrowserTestBase {
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
diff --git a/core/modules/taxonomy/tests/src/Functional/TermCacheTagsTest.php b/core/modules/taxonomy/tests/src/Functional/TermCacheTagsTest.php
index 10f24e8da0d..35b7d6bd6e2 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermCacheTagsTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermCacheTagsTest.php
@@ -16,7 +16,7 @@ class TermCacheTagsTest extends EntityWithUriCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
diff --git a/core/modules/taxonomy/tests/src/Functional/TermEntityReferenceTest.php b/core/modules/taxonomy/tests/src/Functional/TermEntityReferenceTest.php
index 9cdafa368c8..2deeb417860 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermEntityReferenceTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermEntityReferenceTest.php
@@ -37,41 +37,41 @@ class TermEntityReferenceTest extends TaxonomyTestBase {
// Create an entity reference field.
$field_name = 'taxonomy_' . $vocabulary->id();
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'translatable' => FALSE,
- 'settings' => array(
+ 'settings' => [
'target_type' => 'taxonomy_term',
- ),
+ ],
'type' => 'entity_reference',
'cardinality' => 1,
- ));
+ ]);
$field_storage->save();
- $field = FieldConfig::create(array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'entity_type' => 'entity_test',
'bundle' => 'test_bundle',
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
// Restrict selection of terms to a single vocabulary.
- 'target_bundles' => array(
+ 'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
- ),
- ),
- ),
- ));
+ ],
+ ],
+ ],
+ ]);
$field->save();
$handler = $this->container->get('plugin.manager.entity_reference_selection')->getSelectionHandler($field);
$result = $handler->getReferenceableEntities();
- $expected_result = array(
- $vocabulary->id() => array(
+ $expected_result = [
+ $vocabulary->id() => [
$term->id() => $term->getName(),
- ),
- );
+ ],
+ ];
$this->assertIdentical($result, $expected_result, 'Terms selection restricted to a single vocabulary.');
}
diff --git a/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php b/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
index 75169392bb9..5266b8ff55e 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
@@ -17,7 +17,7 @@ class TermIndexTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('views');
+ public static $modules = ['views'];
/**
* Vocabulary for testing.
@@ -50,37 +50,37 @@ class TermIndexTest extends TaxonomyTestBase {
$this->vocabulary = $this->createVocabulary();
$this->fieldName1 = Unicode::strtolower($this->randomMachineName());
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName1, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName1, array(
+ ->setComponent($this->fieldName1, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->fieldName1, array(
+ ->setComponent($this->fieldName1, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
$this->fieldName2 = Unicode::strtolower($this->randomMachineName());
$this->createEntityReferenceField('node', 'article', $this->fieldName2, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName2, array(
+ ->setComponent($this->fieldName2, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->fieldName2, array(
+ ->setComponent($this->fieldName2, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -94,7 +94,7 @@ class TermIndexTest extends TaxonomyTestBase {
$term_2 = $this->createTerm($this->vocabulary);
// Post an article.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$edit["{$this->fieldName1}[]"] = $term_1->id();
@@ -103,10 +103,10 @@ class TermIndexTest extends TaxonomyTestBase {
// Check that the term is indexed, and only once.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed once.');
// Update the article to change one term.
@@ -114,15 +114,15 @@ class TermIndexTest extends TaxonomyTestBase {
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Check that both terms are indexed.
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed.');
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed.');
// Update the article to change another term.
@@ -130,19 +130,19 @@ class TermIndexTest extends TaxonomyTestBase {
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Check that only one term is indexed.
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(0, $index_count, 'Term 1 is not indexed.');
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed once.');
// Redo the above tests without interface.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$node = $node_storage->load($node->id());
$node->title = $this->randomMachineName();
@@ -150,47 +150,47 @@ class TermIndexTest extends TaxonomyTestBase {
$node->save();
// Check that the index was not changed.
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(0, $index_count, 'Term 1 is not indexed.');
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed once.');
// Update the article to change one term.
- $node->{$this->fieldName1} = array(array('target_id' => $term_1->id()));
+ $node->{$this->fieldName1} = [['target_id' => $term_1->id()]];
$node->save();
// Check that both terms are indexed.
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed.');
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed.');
// Update the article to change another term.
- $node->{$this->fieldName2} = array(array('target_id' => $term_1->id()));
+ $node->{$this->fieldName2} = [['target_id' => $term_1->id()]];
$node->save();
// Check that only one term is indexed.
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed once.');
- $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', array(
+ $index_count = db_query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual(0, $index_count, 'Term 2 is not indexed.');
}
@@ -201,7 +201,7 @@ class TermIndexTest extends TaxonomyTestBase {
// Create two taxonomy terms and set term2 as the parent of term1.
$term1 = $this->createTerm($this->vocabulary);
$term2 = $this->createTerm($this->vocabulary);
- $term1->parent = array($term2->id());
+ $term1->parent = [$term2->id()];
$term1->save();
// Verify that the page breadcrumbs include a link to the parent term.
diff --git a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php
index 1ab8d4865be..ce87396fc64 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php
@@ -12,7 +12,7 @@ use Drupal\language\Entity\ConfigurableLanguage;
*/
class TermLanguageTest extends TaxonomyTestBase {
- public static $modules = array('language');
+ public static $modules = ['language'];
/**
* Vocabulary for testing.
@@ -31,19 +31,19 @@ class TermLanguageTest extends TaxonomyTestBase {
$this->vocabulary = $this->createVocabulary();
// Add some custom languages.
- foreach (array('aa', 'bb', 'cc') as $language_code) {
- ConfigurableLanguage::create(array(
+ foreach (['aa', 'bb', 'cc'] as $language_code) {
+ ConfigurableLanguage::create([
'id' => $language_code,
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
}
}
function testTermLanguage() {
// Configure the vocabulary to not hide the language selector.
- $edit = array(
+ $edit = [
'default_language[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), $edit, t('Save'));
// Add a term.
@@ -51,10 +51,10 @@ class TermLanguageTest extends TaxonomyTestBase {
// Check that we have the language selector.
$this->assertField('edit-langcode-0-value', t('The language selector field was found on the page.'));
// Submit the term.
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(),
'langcode[0][value]' => 'aa',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
$term = reset($terms);
@@ -76,19 +76,19 @@ class TermLanguageTest extends TaxonomyTestBase {
function testDefaultTermLanguage() {
// Configure the vocabulary to not hide the language selector, and make the
// default language of the terms fixed.
- $edit = array(
+ $edit = [
'default_language[langcode]' => 'bb',
'default_language[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), $edit, t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
$this->assertOptionSelected('edit-langcode-0-value', 'bb', 'The expected langcode was selected.');
// Make the default language of the terms to be the current interface.
- $edit = array(
+ $edit = [
'default_language[langcode]' => 'current_interface',
'default_language[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), $edit, t('Save'));
$this->drupalGet('aa/admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
$this->assertOptionSelected('edit-langcode-0-value', 'aa', "The expected langcode, 'aa', was selected.");
@@ -98,10 +98,10 @@ class TermLanguageTest extends TaxonomyTestBase {
// Change the default language of the site and check if the default terms
// language is still correctly selected.
$this->config('system.site')->set('default_langcode', 'cc')->save();
- $edit = array(
+ $edit = [
'default_language[langcode]' => LanguageInterface::LANGCODE_SITE_DEFAULT,
'default_language[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), $edit, t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
$this->assertOptionSelected('edit-langcode-0-value', 'cc', "The expected langcode, 'cc', was selected.");
diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php
index 9588e4d0a8f..c5df74dadea 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php
@@ -40,7 +40,7 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'taxonomy');
+ public static $modules = ['language', 'content_translation', 'taxonomy'];
protected function setUp() {
parent::setUp();
@@ -79,7 +79,7 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
'value' => $this->randomMachineName(),
'format' => 'basic_html'
]],
- $this->termFieldName => array(array('target_id' => $this->term->id())),
+ $this->termFieldName => [['target_id' => $this->term->id()]],
'langcode' => $this->baseLangcode,
]);
$node->save();
@@ -92,14 +92,14 @@ class TermTranslationFieldViewTest extends TaxonomyTestBase {
* Creates a test subject term, with translation.
*/
protected function setUpTerm() {
- $this->term = $this->createTerm($this->vocabulary, array(
+ $this->term = $this->createTerm($this->vocabulary, [
'name' => $this->baseTagName,
'langcode' => $this->baseLangcode,
- ));
+ ]);
- $this->term->addTranslation($this->translateToLangcode, array(
+ $this->term->addTranslation($this->translateToLangcode, [
'name' => $this->translatedTagName,
- ));
+ ]);
$this->term->save();
}
diff --git a/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php b/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php
index 1c8b7ea5368..e6836f68049 100644
--- a/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php
@@ -33,23 +33,23 @@ class TokenReplaceTest extends TaxonomyTestBase {
$this->vocabulary = $this->createVocabulary();
$this->fieldName = 'taxonomy_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -65,23 +65,23 @@ class TokenReplaceTest extends TaxonomyTestBase {
$term2 = $this->createTerm($this->vocabulary);
// Edit $term2, setting $term1 as parent.
- $edit = array();
+ $edit = [];
$edit['name[0][value]'] = '<blink>Blinking Text</blink>';
- $edit['parent[]'] = array($term1->id());
+ $edit['parent[]'] = [$term1->id()];
$this->drupalPostForm('taxonomy/term/' . $term2->id() . '/edit', $edit, t('Save'));
// Create node with term2.
- $edit = array();
- $node = $this->drupalCreateNode(array('type' => 'article'));
+ $edit = [];
+ $node = $this->drupalCreateNode(['type' => 'article']);
$edit[$this->fieldName . '[]'] = $term2->id();
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Generate and test sanitized tokens for term1.
- $tests = array();
+ $tests = [];
$tests['[term:tid]'] = $term1->id();
$tests['[term:name]'] = $term1->getName();
$tests['[term:description]'] = $term1->description->processed;
- $tests['[term:url]'] = $term1->url('canonical', array('absolute' => TRUE));
+ $tests['[term:url]'] = $term1->url('canonical', ['absolute' => TRUE]);
$tests['[term:node-count]'] = 0;
$tests['[term:parent:name]'] = '[term:parent:name]';
$tests['[term:vocabulary:name]'] = $this->vocabulary->label();
@@ -89,7 +89,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($term1);
- $metadata_tests = array();
+ $metadata_tests = [];
$metadata_tests['[term:tid]'] = $base_bubbleable_metadata;
$metadata_tests['[term:name]'] = $base_bubbleable_metadata;
$metadata_tests['[term:description]'] = $base_bubbleable_metadata;
@@ -102,20 +102,20 @@ class TokenReplaceTest extends TaxonomyTestBase {
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->getId()), $bubbleable_metadata);
- $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
+ $output = $token_service->replace($input, ['term' => $term1], ['langcode' => $language_interface->getId()], $bubbleable_metadata);
+ $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
// Generate and test sanitized tokens for term2.
- $tests = array();
+ $tests = [];
$tests['[term:tid]'] = $term2->id();
$tests['[term:name]'] = $term2->getName();
$tests['[term:description]'] = $term2->description->processed;
- $tests['[term:url]'] = $term2->url('canonical', array('absolute' => TRUE));
+ $tests['[term:url]'] = $term2->url('canonical', ['absolute' => TRUE]);
$tests['[term:node-count]'] = 1;
$tests['[term:parent:name]'] = $term1->getName();
- $tests['[term:parent:url]'] = $term1->url('canonical', array('absolute' => TRUE));
+ $tests['[term:parent:url]'] = $term1->url('canonical', ['absolute' => TRUE]);
$tests['[term:parent:parent:name]'] = '[term:parent:parent:name]';
$tests['[term:vocabulary:name]'] = $this->vocabulary->label();
@@ -123,12 +123,12 @@ class TokenReplaceTest extends TaxonomyTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
- $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId()));
- $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
+ $output = $token_service->replace($input, ['term' => $term2], ['langcode' => $language_interface->getId()]);
+ $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', ['%token' => $input]));
}
// Generate and test sanitized tokens.
- $tests = array();
+ $tests = [];
$tests['[vocabulary:vid]'] = $this->vocabulary->id();
$tests['[vocabulary:name]'] = $this->vocabulary->label();
$tests['[vocabulary:description]'] = $this->vocabulary->getDescription();
@@ -139,8 +139,8 @@ class TokenReplaceTest extends TaxonomyTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
- $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId()));
- $this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
+ $output = $token_service->replace($input, ['vocabulary' => $this->vocabulary], ['langcode' => $language_interface->getId()]);
+ $this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', ['%token' => $input]));
}
}
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyCrudTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyCrudTest.php
index 2705ab0f097..d32fb0fd053 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyCrudTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyCrudTest.php
@@ -19,12 +19,12 @@ class VocabularyCrudTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('field_test', 'taxonomy_crud');
+ public static $modules = ['field_test', 'taxonomy_crud'];
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('create article content', 'administer taxonomy'));
+ $admin_user = $this->drupalCreateUser(['create article content', 'administer taxonomy']);
$this->drupalLogin($admin_user);
$this->vocabulary = $this->createVocabulary();
}
@@ -42,15 +42,15 @@ class VocabularyCrudTest extends TaxonomyTestBase {
// Assert that there are no terms left.
$this->assertEqual(0, $query->execute(), 'There are no terms remaining.');
- $terms = array();
+ $terms = [];
for ($i = 0; $i < 5; $i++) {
$terms[$i] = $this->createTerm($vocabulary);
}
// Set up hierarchy. term 2 is a child of 1 and 4 a child of 1 and 2.
- $terms[2]->parent = array($terms[1]->id());
+ $terms[2]->parent = [$terms[1]->id()];
$terms[2]->save();
- $terms[4]->parent = array($terms[1]->id(), $terms[2]->id());
+ $terms[4]->parent = [$terms[1]->id(), $terms[2]->id()];
$terms[4]->save();
// Assert that there are now 5 terms.
@@ -119,22 +119,22 @@ class VocabularyCrudTest extends TaxonomyTestBase {
// Fetch the vocabularies with entity_load_multiple(), specifying IDs.
// Ensure they are returned in the same order as the original array.
- $vocabularies = Vocabulary::loadMultiple(array($vocabulary3->id(), $vocabulary2->id(), $vocabulary1->id()));
+ $vocabularies = Vocabulary::loadMultiple([$vocabulary3->id(), $vocabulary2->id(), $vocabulary1->id()]);
$loaded_order = array_keys($vocabularies);
- $expected_order = array($vocabulary3->id(), $vocabulary2->id(), $vocabulary1->id());
+ $expected_order = [$vocabulary3->id(), $vocabulary2->id(), $vocabulary1->id()];
$this->assertIdentical($loaded_order, $expected_order);
// Test loading vocabularies by their properties.
$controller = $this->container->get('entity.manager')->getStorage('taxonomy_vocabulary');
// Fetch vocabulary 1 by name.
- $vocabulary = current($controller->loadByProperties(array('name' => $vocabulary1->label())));
+ $vocabulary = current($controller->loadByProperties(['name' => $vocabulary1->label()]));
$this->assertEqual($vocabulary->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by name.');
// Fetch vocabulary 2 by name and ID.
- $vocabulary = current($controller->loadByProperties(array(
+ $vocabulary = current($controller->loadByProperties([
'name' => $vocabulary2->label(),
'vid' => $vocabulary2->id(),
- )));
+ ]));
$this->assertEqual($vocabulary->id(), $vocabulary2->id(), 'Vocabulary loaded successfully by name and ID.');
}
@@ -145,19 +145,19 @@ class VocabularyCrudTest extends TaxonomyTestBase {
// Field storages and fields attached to taxonomy term bundles should be
// removed when the module is uninstalled.
$field_name = Unicode::strtolower($this->randomMachineName() . '_field_name');
- $storage_definition = array(
+ $storage_definition = [
'field_name' => $field_name,
'entity_type' => 'taxonomy_term',
'type' => 'text',
'cardinality' => 4
- );
+ ];
FieldStorageConfig::create($storage_definition)->save();
- $field_definition = array(
+ $field_definition = [
'field_name' => $field_name,
'entity_type' => 'taxonomy_term',
'bundle' => $this->vocabulary->id(),
'label' => $this->randomMachineName() . '_label',
- );
+ ];
FieldConfig::create($field_definition)->save();
// Remove the third party setting from the memory copy of the vocabulary.
@@ -166,8 +166,8 @@ class VocabularyCrudTest extends TaxonomyTestBase {
$this->vocabulary->unsetThirdPartySetting('taxonomy_crud', 'foo');
require_once \Drupal::root() . '/core/includes/install.inc';
- $this->container->get('module_installer')->uninstall(array('taxonomy'));
- $this->container->get('module_installer')->install(array('taxonomy'));
+ $this->container->get('module_installer')->uninstall(['taxonomy']);
+ $this->container->get('module_installer')->install(['taxonomy']);
// Now create a vocabulary with the same name. All fields
// connected to this vocabulary name should have been removed when the
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php
index da78589f29a..5b9cbfe8f62 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php
@@ -13,7 +13,7 @@ use Drupal\language\Entity\ContentLanguageSettings;
*/
class VocabularyLanguageTest extends TaxonomyTestBase {
- public static $modules = array('language');
+ public static $modules = ['language'];
protected function setUp() {
parent::setUp();
@@ -22,15 +22,15 @@ class VocabularyLanguageTest extends TaxonomyTestBase {
$this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
// Add some custom languages.
- ConfigurableLanguage::create(array(
+ ConfigurableLanguage::create([
'id' => 'aa',
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
- ConfigurableLanguage::create(array(
+ ConfigurableLanguage::create([
'id' => 'bb',
'label' => $this->randomMachineName(),
- ))->save();
+ ])->save();
}
/**
@@ -70,12 +70,12 @@ class VocabularyLanguageTest extends TaxonomyTestBase {
function testVocabularyDefaultLanguageForTerms() {
// Add a new vocabulary and check that the default language settings are for
// the terms are saved.
- $edit = array(
+ $edit = [
'name' => $this->randomMachineName(),
'vid' => Unicode::strtolower($this->randomMachineName()),
'default_language[langcode]' => 'bb',
'default_language[language_alterable]' => TRUE,
- );
+ ];
$vid = $edit['vid'];
$this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
@@ -93,10 +93,10 @@ class VocabularyLanguageTest extends TaxonomyTestBase {
$this->assertFieldChecked('edit-default-language-language-alterable', 'Show language selection option is checked.');
// Edit the vocabulary and check that the new settings are updated.
- $edit = array(
+ $edit = [
'default_language[langcode]' => 'aa',
'default_language[language_alterable]' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
// And check again the settings and also the interface.
@@ -109,11 +109,11 @@ class VocabularyLanguageTest extends TaxonomyTestBase {
$this->assertNoFieldChecked('edit-default-language-language-alterable', 'Show language selection option is not checked.');
// Check that language settings are changed after editing vocabulary.
- $edit = array(
+ $edit = [
'name' => $this->randomMachineName(),
'default_language[langcode]' => 'authors_default',
'default_language[language_alterable]' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
// Check that we have the new settings.
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
index 1b83d848ea6..c5f1f94b481 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
@@ -23,7 +23,7 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$vocabulary = $this->createVocabulary();
// Test as admin user.
- $user = $this->drupalCreateUser(array('administer taxonomy'));
+ $user = $this->drupalCreateUser(['administer taxonomy']);
$this->drupalLogin($user);
// Visit the main taxonomy administration page.
@@ -32,14 +32,14 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$this->assertField('edit-name-0-value', 'Add taxonomy term form opened successfully.');
// Submit the term.
- $edit = array();
+ $edit = [];
$edit['name[0][value]'] = $this->randomMachineName();
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('Created new term @name.', array('@name' => $edit['name[0][value]'])), 'Term created successfully.');
+ $this->assertText(t('Created new term @name.', ['@name' => $edit['name[0][value]']]), 'Term created successfully.');
// Verify that the creation message contains a link to a term.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
$this->assert(isset($view_link), 'The message area contains a link to a term');
$terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
@@ -52,18 +52,18 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$edit['name[0][value]'] = $this->randomMachineName();
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('Updated term @name.', array('@name' => $edit['name[0][value]'])), 'Term updated successfully.');
+ $this->assertText(t('Updated term @name.', ['@name' => $edit['name[0][value]']]), 'Term updated successfully.');
// Delete the vocabulary.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
- $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', array('@entity-type' => 'taxonomy term', '%label' => $edit['name[0][value]'])), 'Delete taxonomy term form opened successfully.');
+ $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $edit['name[0][value]']]), 'Delete taxonomy term form opened successfully.');
// Confirm deletion.
$this->drupalPostForm(NULL, NULL, t('Delete'));
- $this->assertRaw(t('Deleted term %name.', array('%name' => $edit['name[0][value]'])), 'Term deleted.');
+ $this->assertRaw(t('Deleted term %name.', ['%name' => $edit['name[0][value]']]), 'Term deleted.');
// Test as user with "edit" permissions.
- $user = $this->drupalCreateUser(array("edit terms in {$vocabulary->id()}"));
+ $user = $this->drupalCreateUser(["edit terms in {$vocabulary->id()}"]);
$this->drupalLogin($user);
// Visit the main taxonomy administration page.
@@ -80,10 +80,10 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$edit['name[0][value]'] = $this->randomMachineName();
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('Updated term @name.', array('@name' => $edit['name[0][value]'])), 'Term updated successfully.');
+ $this->assertText(t('Updated term @name.', ['@name' => $edit['name[0][value]']]), 'Term updated successfully.');
// Verify that the update message contains a link to a term.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
$this->assert(isset($view_link), 'The message area contains a link to a term');
// Delete the vocabulary.
@@ -91,7 +91,7 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$this->assertResponse(403, 'Delete taxonomy term form open failed.');
// Test as user with "delete" permissions.
- $user = $this->drupalCreateUser(array("delete terms in {$vocabulary->id()}"));
+ $user = $this->drupalCreateUser(["delete terms in {$vocabulary->id()}"]);
$this->drupalLogin($user);
// Visit the main taxonomy administration page.
@@ -107,11 +107,11 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
// Delete the vocabulary.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
- $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', array('@entity-type' => 'taxonomy term', '%label' => $term->getName())), 'Delete taxonomy term form opened successfully.');
+ $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $term->getName()]), 'Delete taxonomy term form opened successfully.');
// Confirm deletion.
$this->drupalPostForm(NULL, NULL, t('Delete'));
- $this->assertRaw(t('Deleted term %name.', array('%name' => $term->getName())), 'Term deleted.');
+ $this->assertRaw(t('Deleted term %name.', ['%name' => $term->getName()]), 'Term deleted.');
// Test as user without proper permissions.
$user = $this->drupalCreateUser();
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php
index 5c41f6cd4a7..3679b79db2b 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php
@@ -14,7 +14,7 @@ class VocabularyTranslationTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('content_translation', 'language');
+ public static $modules = ['content_translation', 'language'];
/**
* {@inheritdoc}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/MigrateTaxonomyConfigsTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/MigrateTaxonomyConfigsTest.php
index 6705fbbea6a..92ebe5926ae 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/MigrateTaxonomyConfigsTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/MigrateTaxonomyConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php
index b0311f3da48..125283355ee 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php
@@ -15,7 +15,7 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
@@ -30,44 +30,44 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
* Tests the Drupal 6 taxonomy term to Drupal 8 migration.
*/
public function testTaxonomyTerms() {
- $expected_results = array(
- '1' => array(
+ $expected_results = [
+ '1' => [
'source_vid' => 1,
'vid' => 'vocabulary_1_i_0_',
'weight' => 0,
- 'parent' => array(0),
- ),
- '2' => array(
+ 'parent' => [0],
+ ],
+ '2' => [
'source_vid' => 2,
'vid' => 'vocabulary_2_i_1_',
'weight' => 3,
- 'parent' => array(0),
- ),
- '3' => array(
+ 'parent' => [0],
+ ],
+ '3' => [
'source_vid' => 2,
'vid' => 'vocabulary_2_i_1_',
'weight' => 4,
- 'parent' => array(2),
- ),
- '4' => array(
+ 'parent' => [2],
+ ],
+ '4' => [
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 6,
- 'parent' => array(0),
- ),
- '5' => array(
+ 'parent' => [0],
+ ],
+ '5' => [
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 7,
- 'parent' => array(4),
- ),
- '6' => array(
+ 'parent' => [4],
+ ],
+ '6' => [
'source_vid' => 3,
'vid' => 'vocabulary_3_i_2_',
'weight' => 8,
- 'parent' => array(4, 5),
- ),
- );
+ 'parent' => [4, 5],
+ ],
+ ];
$terms = Term::loadMultiple(array_keys($expected_results));
// Find each term in the tree.
@@ -87,11 +87,11 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
$this->assertIdentical("description of term {$tid} of vocabulary {$values['source_vid']}", $term->description->value);
$this->assertIdentical($values['vid'], $term->vid->target_id);
$this->assertIdentical((string) $values['weight'], $term->weight->value);
- if ($values['parent'] === array(0)) {
+ if ($values['parent'] === [0]) {
$this->assertNull($term->parent->target_id);
}
else {
- $parents = array();
+ $parents = [];
foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) {
$parents[] = (int) $parent->id();
}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
index c2d4ab61a80..6c665980b2e 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
@@ -15,7 +15,7 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
@@ -32,7 +32,7 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
for ($i = 0; $i < 3; $i++) {
$j = $i + 1;
$vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
- $this->assertIdentical($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID(array($j)), array($vocabulary->id()));
+ $this->assertIdentical($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID([$j]), [$vocabulary->id()]);
$this->assertIdentical("vocabulary $j (i=$i)", $vocabulary->label());
$this->assertIdentical("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
$this->assertIdentical($i, $vocabulary->getHierarchy());
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
index 42f864e48e1..40f094e6c36 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
@@ -34,7 +34,7 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
$this->assertIdentical('entity_reference_label', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
- $this->assertIdentical(array('node', 'article', 'default', 'tags'), $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
+ $this->assertIdentical(['node', 'article', 'default', 'tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article']));
}
}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php
index a2e26c71caa..32370f25ab4 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php
@@ -34,7 +34,7 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
$this->assertIdentical('options_select', $component['type']);
$this->assertIdentical(20, $component['weight']);
// Test the Id map.
- $this->assertIdentical(array('node', 'article', 'default', 'tags'), $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
+ $this->assertIdentical(['node', 'article', 'default', 'tags'], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID([4, 'article']));
// Test the term widget tags setting.
$entity_form_display = EntityFormDisplay::load('node.story.default');
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php
index 2534c3e30f5..45db4a81759 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php
@@ -48,7 +48,7 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
$this->assertIdentical(['tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
$this->assertIdentical(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
- $this->assertIdentical(array('node', 'article', 'tags'), $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID(array(4, 'article')));
+ $this->assertIdentical(['node', 'article', 'tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID([4, 'article']));
// Test the the field vocabulary_1_i_0_
$field_id = 'node.story.vocabulary_1_i_0_';
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php
index eb0c480401b..6c3631bfebd 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php
@@ -39,7 +39,7 @@ class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
$this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct.");
$this->assertIdentical(1, $field_storage->getCardinality(), "Field cardinality in 1.");
- $this->assertIdentical(array('node', 'tags'), $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
+ $this->assertIdentical(['node', 'tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID([4]), "Test IdMap");
}
}
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateNodeTaxonomyTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateNodeTaxonomyTest.php
index d57e3341b14..0d985e24299 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateNodeTaxonomyTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateNodeTaxonomyTest.php
@@ -14,7 +14,7 @@ use Drupal\node\NodeInterface;
*/
class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
- public static $modules = array(
+ public static $modules = [
'datetime',
'field',
'filter',
@@ -24,7 +24,7 @@ class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
'taxonomy',
'telephone',
'text',
- );
+ ];
/**
* {@inheritdoc}
@@ -40,21 +40,21 @@ class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
$this->executeMigration('d7_node_type');
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'type' => 'entity_reference',
'field_name' => 'field_tags',
'entity_type' => 'node',
- 'settings' => array(
+ 'settings' => [
'target_type' => 'taxonomy_term',
- ),
+ ],
'cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED,
- ))->save();
+ ])->save();
- FieldConfig::create(array(
+ FieldConfig::create([
'entity_type' => 'node',
'field_name' => 'field_tags',
'bundle' => 'article',
- ))->save();
+ ])->save();
$this->executeMigrations([
'd7_taxonomy_vocabulary',
diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
index 3f29fbf77f9..7f2ceef8a24 100644
--- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
@@ -16,7 +16,7 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
diff --git a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php
index 1e2b2323025..0d70d840dab 100644
--- a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php
@@ -18,14 +18,14 @@ class TermKernelTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array( 'filter', 'taxonomy', 'text', 'user' );
+ public static $modules = [ 'filter', 'taxonomy', 'text', 'user' ];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('filter'));
+ $this->installConfig(['filter']);
$this->installEntitySchema('taxonomy_term');
}
@@ -38,11 +38,11 @@ class TermKernelTest extends KernelTestBase {
$valid_term = $this->createTerm($vocabulary);
// Delete a valid term.
$valid_term->delete();
- $terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
+ $terms = entity_load_multiple_by_properties('taxonomy_term', ['vid' => $vocabulary->id()]);
$this->assertTrue(empty($terms), 'Vocabulary is empty after deletion');
// Delete an invalid term. Should not throw any notices.
- entity_delete_multiple('taxonomy_term', array(42));
+ entity_delete_multiple('taxonomy_term', [42]);
}
/**
@@ -53,18 +53,18 @@ class TermKernelTest extends KernelTestBase {
$parent_term1 = $this->createTerm($vocabulary);
$parent_term2 = $this->createTerm($vocabulary);
$child_term = $this->createTerm($vocabulary);
- $child_term->parent = array($parent_term1->id(), $parent_term2->id());
+ $child_term->parent = [$parent_term1->id(), $parent_term2->id()];
$child_term->save();
$child_term_id = $child_term->id();
$parent_term1->delete();
$term_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
- $term_storage->resetCache(array($child_term_id));
+ $term_storage->resetCache([$child_term_id]);
$child_term = Term::load($child_term_id);
$this->assertTrue(!empty($child_term), 'Child term is not deleted if only one of its parents is removed.');
$parent_term2->delete();
- $term_storage->resetCache(array($child_term_id));
+ $term_storage->resetCache([$child_term_id]);
$child_term = Term::load($child_term_id);
$this->assertTrue(empty($child_term), 'Child term is deleted if all of its parents are removed.');
}
@@ -75,7 +75,7 @@ class TermKernelTest extends KernelTestBase {
public function testTaxonomyVocabularyTree() {
// Create a new vocabulary with 6 terms.
$vocabulary = $this->createVocabulary();
- $term = array();
+ $term = [];
for ($i = 0; $i < 6; $i++) {
$term[$i] = $this->createTerm($vocabulary);
}
@@ -90,13 +90,13 @@ class TermKernelTest extends KernelTestBase {
$term[1]->save();
// $term[2] is a child of 1 and 5.
- $term[2]->parent = array($term[1]->id(), $term[5]->id());
+ $term[2]->parent = [$term[1]->id(), $term[5]->id()];
$term[2]->save();
// $term[3] is a child of 2.
- $term[3]->parent = array($term[2]->id());
+ $term[3]->parent = [$term[2]->id()];
$term[3]->save();
// $term[5] is a child of 4.
- $term[5]->parent = array($term[4]->id());
+ $term[5]->parent = [$term[4]->id()];
$term[5]->save();
/**
diff --git a/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php b/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php
index 3d9cfb77765..437a305f6f5 100644
--- a/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php
+++ b/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php
@@ -16,7 +16,7 @@ class TermValidationTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
@@ -30,14 +30,14 @@ class TermValidationTest extends EntityKernelTestBase {
* Tests the term validation constraints.
*/
public function testValidation() {
- $this->entityManager->getStorage('taxonomy_vocabulary')->create(array(
+ $this->entityManager->getStorage('taxonomy_vocabulary')->create([
'vid' => 'tags',
'name' => 'Tags',
- ))->save();
- $term = $this->entityManager->getStorage('taxonomy_term')->create(array(
+ ])->save();
+ $term = $this->entityManager->getStorage('taxonomy_term')->create([
'name' => 'test',
'vid' => 'tags',
- ));
+ ]);
$violations = $term->validate();
$this->assertEqual(count($violations), 0, 'No violations when validating a default term.');
@@ -46,7 +46,7 @@ class TermValidationTest extends EntityKernelTestBase {
$this->assertEqual(count($violations), 1, 'Violation found when name is too long.');
$this->assertEqual($violations[0]->getPropertyPath(), 'name.0.value');
$field_label = $term->get('name')->getFieldDefinition()->getLabel();
- $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => 255)));
+ $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => $field_label, '@max' => 255]));
$term->set('name', NULL);
$violations = $term->validate();
@@ -58,7 +58,7 @@ class TermValidationTest extends EntityKernelTestBase {
$term->set('parent', 9999);
$violations = $term->validate();
$this->assertEqual(count($violations), 1, 'Violation found when term parent is invalid.');
- $this->assertEqual($violations[0]->getMessage(), format_string('The referenced entity (%type: %id) does not exist.', array('%type' => 'taxonomy_term', '%id' => 9999)));
+ $this->assertEqual($violations[0]->getMessage(), format_string('The referenced entity (%type: %id) does not exist.', ['%type' => 'taxonomy_term', '%id' => 9999]));
$term->set('parent', 0);
$violations = $term->validate();
diff --git a/core/modules/taxonomy/tests/src/Unit/Menu/TaxonomyLocalTasksTest.php b/core/modules/taxonomy/tests/src/Unit/Menu/TaxonomyLocalTasksTest.php
index dcd49671361..a2df0993455 100644
--- a/core/modules/taxonomy/tests/src/Unit/Menu/TaxonomyLocalTasksTest.php
+++ b/core/modules/taxonomy/tests/src/Unit/Menu/TaxonomyLocalTasksTest.php
@@ -12,7 +12,7 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class TaxonomyLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array('taxonomy' => 'core/modules/taxonomy');
+ $this->directoryList = ['taxonomy' => 'core/modules/taxonomy'];
parent::setUp();
}
@@ -21,10 +21,10 @@ class TaxonomyLocalTasksTest extends LocalTaskIntegrationTestBase {
*
* @dataProvider getTaxonomyPageRoutes
*/
- public function testTaxonomyPageLocalTasks($route, $subtask = array()) {
- $tasks = array(
- 0 => array('entity.taxonomy_term.canonical', 'entity.taxonomy_term.edit_form'),
- );
+ public function testTaxonomyPageLocalTasks($route, $subtask = []) {
+ $tasks = [
+ 0 => ['entity.taxonomy_term.canonical', 'entity.taxonomy_term.edit_form'],
+ ];
if ($subtask) $tasks[] = $subtask;
$this->assertLocalTasks($route, $tasks);
}
@@ -33,10 +33,10 @@ class TaxonomyLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getTaxonomyPageRoutes() {
- return array(
- array('entity.taxonomy_term.canonical'),
- array('entity.taxonomy_term.edit_form'),
- );
+ return [
+ ['entity.taxonomy_term.canonical'],
+ ['entity.taxonomy_term.edit_form'],
+ ];
}
}
diff --git a/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php b/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php
index f77b751e42c..afdf54146d6 100644
--- a/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php
+++ b/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php
@@ -24,20 +24,20 @@ class TelephoneLinkFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'title' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $elements['title'] = array(
+ $elements['title'] = [
'#type' => 'textfield',
'#title' => t('Title to replace basic numeric telephone number display'),
'#default_value' => $this->getSetting('title'),
- );
+ ];
return $elements;
}
@@ -46,11 +46,11 @@ class TelephoneLinkFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$settings = $this->getSettings();
if (!empty($settings['title'])) {
- $summary[] = t('Link using text: @title', array('@title' => $settings['title']));
+ $summary[] = t('Link using text: @title', ['@title' => $settings['title']]);
}
else {
$summary[] = t('Link using provided telephone number.');
@@ -63,23 +63,23 @@ class TelephoneLinkFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $element = array();
+ $element = [];
$title_setting = $this->getSetting('title');
foreach ($items as $delta => $item) {
// Render each element as link.
- $element[$delta] = array(
+ $element[$delta] = [
'#type' => 'link',
// Use custom title if available, otherwise use the telephone number
// itself as title.
'#title' => $title_setting ?: $item->value,
// Prepend 'tel:' to the telephone number.
'#url' => Url::fromUri('tel:' . rawurlencode(preg_replace('/\s+/', '', $item->value))),
- '#options' => array('external' => TRUE),
- );
+ '#options' => ['external' => TRUE],
+ ];
if (!empty($item->_attributes)) {
- $element[$delta]['#options'] += array('attributes' => array());
+ $element[$delta]['#options'] += ['attributes' => []];
$element[$delta]['#options']['attributes'] += $item->_attributes;
// Unset field item attributes since they have been included in the
// formatter output and should not be rendered in the field template.
diff --git a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php
index 20950e5ffb3..f2aa1ccddea 100644
--- a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php
+++ b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php
@@ -25,14 +25,14 @@ class TelephoneItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => 256,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -62,14 +62,14 @@ class TelephoneItem extends FieldItemBase {
$constraints = parent::getConstraints();
$max_length = 256;
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Length' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Length' => [
'max' => $max_length,
- 'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)),
- )
- ),
- ));
+ 'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
+ ]
+ ],
+ ]);
return $constraints;
}
diff --git a/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php
index f585067d2c6..1ea1837dea1 100644
--- a/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php
+++ b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php
@@ -23,21 +23,21 @@ class TelephoneDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['placeholder'] = array(
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
- );
+ ];
return $element;
}
@@ -45,11 +45,11 @@ class TelephoneDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
+ $summary = [];
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
- $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
+ $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
else {
$summary[] = t('No placeholder');
@@ -62,11 +62,11 @@ class TelephoneDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
- $element['value'] = $element + array(
+ $element['value'] = $element + [
'#type' => 'tel',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#placeholder' => $this->getSetting('placeholder'),
- );
+ ];
return $element;
}
diff --git a/core/modules/telephone/telephone.module b/core/modules/telephone/telephone.module
index e088958aad7..df2acc2518f 100644
--- a/core/modules/telephone/telephone.module
+++ b/core/modules/telephone/telephone.module
@@ -15,11 +15,11 @@ function telephone_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.telephone':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Telephone module allows you to create fields that contain telephone numbers. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":telephone_documentation">online documentation for the Telephone module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':telephone_documentation' => 'https://www.drupal.org/documentation/modules/telephone')) . '</p>';
+ $output .= '<p>' . t('The Telephone module allows you to create fields that contain telephone numbers. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":telephone_documentation">online documentation for the Telephone module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':telephone_documentation' => 'https://www.drupal.org/documentation/modules/telephone']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying telephone fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the telephone field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the telephone field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Displaying telephone numbers as links') . '</dt>';
$output .= '<dd>' . t('Telephone numbers can be displayed as links with the scheme name <em>tel:</em> by choosing the <em>Telephone</em> display format on the <em>Manage display</em> page. Any spaces will be stripped out of the link text. This semantic markup improves the user experience on mobile and assistive technology devices.') . '</dd>';
$output .= '</dl>';
diff --git a/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php b/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
index 7f536c45529..7256c9da39c 100644
--- a/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
+++ b/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
@@ -18,11 +18,11 @@ class TelephoneFieldTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'field',
'node',
'telephone'
- );
+ ];
/**
* A user with permission to create articles.
@@ -34,8 +34,8 @@ class TelephoneFieldTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'article'));
- $this->webUser = $this->drupalCreateUser(array('create article content', 'edit own article content'));
+ $this->drupalCreateContentType(['type' => 'article']);
+ $this->webUser = $this->drupalCreateUser(['create article content', 'edit own article content']);
$this->drupalLogin($this->webUser);
}
@@ -47,11 +47,11 @@ class TelephoneFieldTest extends BrowserTestBase {
function testTelephoneField() {
// Add the telephone field to the article content type.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_telephone',
'entity_type' => 'node',
'type' => 'telephone',
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => 'field_telephone',
'label' => 'Telephone Number',
@@ -60,19 +60,19 @@ class TelephoneFieldTest extends BrowserTestBase {
])->save();
entity_get_form_display('node', 'article', 'default')
- ->setComponent('field_telephone', array(
+ ->setComponent('field_telephone', [
'type' => 'telephone_default',
- 'settings' => array(
+ 'settings' => [
'placeholder' => '123-456-7890',
- ),
- ))
+ ],
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent('field_telephone', array(
+ ->setComponent('field_telephone', [
'type' => 'telephone_link',
'weight' => 1,
- ))
+ ])
->save();
// Display creation form.
@@ -81,19 +81,19 @@ class TelephoneFieldTest extends BrowserTestBase {
$this->assertRaw('placeholder="123-456-7890"');
// Test basic entry of telephone field.
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
'field_telephone[0][value]' => "123456789",
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertRaw('<a href="tel:123456789">', 'A telephone link is provided on the article node page.');
// Add number with a space in it. Need to ensure it is stripped on output.
- $edit = array(
+ $edit = [
'title[0][value]' => $this->randomMachineName(),
'field_telephone[0][value]' => "1234 56789",
- );
+ ];
$this->drupalPostForm('node/add/article', $edit, t('Save'));
$this->assertRaw('<a href="tel:123456789">', 'Telephone link is output with whitespace removed.');
diff --git a/core/modules/telephone/tests/src/Kernel/TelephoneItemTest.php b/core/modules/telephone/tests/src/Kernel/TelephoneItemTest.php
index 7f94ba3b163..72269409e43 100644
--- a/core/modules/telephone/tests/src/Kernel/TelephoneItemTest.php
+++ b/core/modules/telephone/tests/src/Kernel/TelephoneItemTest.php
@@ -21,17 +21,17 @@ class TelephoneItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('telephone');
+ public static $modules = ['telephone'];
protected function setUp() {
parent::setUp();
// Create a telephone field storage and field for validation.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_test',
'entity_type' => 'entity_test',
'type' => 'telephone',
- ))->save();
+ ])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test',
diff --git a/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php b/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php
index 0a78114185f..e746716995a 100644
--- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php
+++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php
@@ -24,17 +24,17 @@ class TextDefaultFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
// The ProcessedText element already handles cache context & tag bubbling.
// @see \Drupal\filter\Element\ProcessedText::preRenderText()
foreach ($items as $delta => $item) {
- $elements[$delta] = array(
+ $elements[$delta] = [
'#type' => 'processed_text',
'#text' => $item->value,
'#format' => $item->format,
'#langcode' => $item->getLangcode(),
- );
+ ];
}
return $elements;
diff --git a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php
index 8d69571a50d..65852382bd4 100644
--- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php
+++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php
@@ -33,24 +33,24 @@ class TextTrimmedFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'trim_length' => '600',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
- $element['trim_length'] = array(
+ $element['trim_length'] = [
'#title' => t('Trimmed limit'),
'#type' => 'number',
'#field_suffix' => t('characters'),
'#default_value' => $this->getSetting('trim_length'),
- '#description' => t('If the summary is not set, the trimmed %label field will end at the last full sentence before this character limit.', array('%label' => $this->fieldDefinition->getLabel())),
+ '#description' => t('If the summary is not set, the trimmed %label field will end at the last full sentence before this character limit.', ['%label' => $this->fieldDefinition->getLabel()]),
'#min' => 1,
'#required' => TRUE,
- );
+ ];
return $element;
}
@@ -58,8 +58,8 @@ class TextTrimmedFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
- $summary = array();
- $summary[] = t('Trimmed limit: @trim_length characters', array('@trim_length' => $this->getSetting('trim_length')));
+ $summary = [];
+ $summary[] = t('Trimmed limit: @trim_length characters', ['@trim_length' => $this->getSetting('trim_length')]);
return $summary;
}
@@ -67,7 +67,7 @@ class TextTrimmedFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
$render_as_summary = function (&$element) {
// Make sure any default #pre_render callbacks are set on the element,
@@ -82,12 +82,12 @@ class TextTrimmedFormatter extends FormatterBase {
// The ProcessedText element already handles cache context & tag bubbling.
// @see \Drupal\filter\Element\ProcessedText::preRenderText()
foreach ($items as $delta => $item) {
- $elements[$delta] = array(
+ $elements[$delta] = [
'#type' => 'processed_text',
'#text' => NULL,
'#format' => $item->format,
'#langcode' => $item->getLangcode(),
- );
+ ];
if ($this->getPluginId() == 'text_summary_or_trimmed' && !empty($item->summary)) {
$elements[$delta]['#text'] = $item->summary;
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
index ed896ad583b..447a0b180d5 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
@@ -23,30 +23,30 @@ class TextItem extends TextItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
- return array(
+ return [
'max_length' => 255,
- ) + parent::defaultStorageSettings();
+ ] + parent::defaultStorageSettings();
}
/**
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => $field_definition->getSetting('max_length'),
- ),
- 'format' => array(
+ ],
+ 'format' => [
'type' => 'varchar',
'length' => 255,
- ),
- ),
- 'indexes' => array(
- 'format' => array('format'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'format' => ['format'],
+ ],
+ ];
}
/**
@@ -57,14 +57,14 @@ class TextItem extends TextItemBase {
$constraints = parent::getConstraints();
if ($max_length = $this->getSetting('max_length')) {
- $constraints[] = $constraint_manager->create('ComplexData', array(
- 'value' => array(
- 'Length' => array(
+ $constraints[] = $constraint_manager->create('ComplexData', [
+ 'value' => [
+ 'Length' => [
'max' => $max_length,
- 'maxMessage' => t('%name: the text may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)),
- )
- ),
- ));
+ 'maxMessage' => t('%name: the text may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
+ ]
+ ],
+ ]);
}
return $constraints;
@@ -74,9 +74,9 @@ class TextItem extends TextItemBase {
* {@inheritdoc}
*/
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
- $element = array();
+ $element = [];
- $element['max_length'] = array(
+ $element['max_length'] = [
'#type' => 'number',
'#title' => t('Maximum length'),
'#default_value' => $this->getSetting('max_length'),
@@ -84,7 +84,7 @@ class TextItem extends TextItemBase {
'#description' => t('The maximum length of the field in characters.'),
'#min' => 1,
'#disabled' => $has_data,
- );
+ ];
$element += parent::storageSettingsForm($form, $form_state, $has_data);
return $element;
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php
index 83cea4ff5ee..6dd43392992 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php
@@ -39,7 +39,7 @@ abstract class TextItemBase extends FieldItemBase {
*/
public function applyDefaultValue($notify = TRUE) {
// @todo: Add in the filter default format here.
- $this->setValue(array('format' => NULL), $notify);
+ $this->setValue(['format' => NULL], $notify);
return $this;
}
@@ -82,11 +82,11 @@ abstract class TextItemBase extends FieldItemBase {
$value = substr($random->sentences(mt_rand(1, $settings['max_length'] / 3), FALSE), 0, $settings['max_length']);
}
- $values = array(
+ $values = [
'value' => $value,
'summary' => $value,
'format' => filter_fallback_format(),
- );
+ ];
return $values;
}
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php
index cf1f61634db..15e4eb6a845 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php
@@ -22,21 +22,21 @@ class TextLongItem extends TextItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'text',
'size' => 'big',
- ),
- 'format' => array(
+ ],
+ 'format' => [
'type' => 'varchar_ascii',
'length' => 255,
- ),
- ),
- 'indexes' => array(
- 'format' => array('format'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'format' => ['format'],
+ ],
+ ];
}
}
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
index d42e3a78398..6af6d0431fb 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
@@ -24,9 +24,9 @@ class TextWithSummaryItem extends TextItemBase {
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
- return array(
+ return [
'display_summary' => 0,
- ) + parent::defaultFieldSettings();
+ ] + parent::defaultFieldSettings();
}
/**
@@ -52,25 +52,25 @@ class TextWithSummaryItem extends TextItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array(
- 'columns' => array(
- 'value' => array(
+ return [
+ 'columns' => [
+ 'value' => [
'type' => 'text',
'size' => 'big',
- ),
- 'summary' => array(
+ ],
+ 'summary' => [
'type' => 'text',
'size' => 'big',
- ),
- 'format' => array(
+ ],
+ 'format' => [
'type' => 'varchar_ascii',
'length' => 255,
- ),
- ),
- 'indexes' => array(
- 'format' => array('format'),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'format' => ['format'],
+ ],
+ ];
}
/**
@@ -85,15 +85,15 @@ class TextWithSummaryItem extends TextItemBase {
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
- $element = array();
+ $element = [];
$settings = $this->getSettings();
- $element['display_summary'] = array(
+ $element['display_summary'] = [
'#type' => 'checkbox',
'#title' => t('Summary input'),
'#default_value' => $settings['display_summary'],
'#description' => t('This allows authors to input an explicit summary, to be displayed instead of the automatically trimmed text when using the "Summary or trimmed" display type.'),
- );
+ ];
return $element;
}
diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
index 8688efb83bb..69a660e4db4 100644
--- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
@@ -46,7 +46,7 @@ class TextareaWidget extends StringTextareaWidget {
* {@inheritdoc}
*/
public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
- if ($violation->arrayPropertyPath == array('format') && isset($element['format']['#access']) && !$element['format']['#access']) {
+ if ($violation->arrayPropertyPath == ['format'] && isset($element['format']['#access']) && !$element['format']['#access']) {
// Ignore validation errors for formats if formats may not be changed,
// i.e. when existing formats become invalid. See filter_process_format().
return FALSE;
diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
index 2afd14b0d18..e50e5cb232b 100644
--- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
@@ -23,11 +23,11 @@ class TextareaWithSummaryWidget extends TextareaWidget {
* {@inheritdoc}
*/
public static function defaultSettings() {
- return array(
+ return [
'rows' => '9',
'summary_rows' => '3',
'placeholder' => '',
- ) + parent::defaultSettings();
+ ] + parent::defaultSettings();
}
/**
@@ -35,14 +35,14 @@ class TextareaWithSummaryWidget extends TextareaWidget {
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
- $element['summary_rows'] = array(
+ $element['summary_rows'] = [
'#type' => 'number',
'#title' => t('Summary rows'),
'#default_value' => $this->getSetting('summary_rows'),
'#description' => $element['rows']['#description'],
'#required' => TRUE,
'#min' => 1,
- );
+ ];
return $element;
}
@@ -52,7 +52,7 @@ class TextareaWithSummaryWidget extends TextareaWidget {
public function settingsSummary() {
$summary = parent::settingsSummary();
- $summary[] = t('Number of summary rows: @rows', array('@rows' => $this->getSetting('summary_rows')));
+ $summary[] = t('Number of summary rows: @rows', ['@rows' => $this->getSetting('summary_rows')]);
return $summary;
}
@@ -64,20 +64,20 @@ class TextareaWithSummaryWidget extends TextareaWidget {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
$display_summary = $items[$delta]->summary || $this->getFieldSetting('display_summary');
- $element['summary'] = array(
+ $element['summary'] = [
'#type' => $display_summary ? 'textarea' : 'value',
'#default_value' => $items[$delta]->summary,
'#title' => t('Summary'),
'#rows' => $this->getSetting('summary_rows'),
'#description' => t('Leave blank to use trimmed value of full text as the summary.'),
- '#attached' => array(
- 'library' => array('text/drupal.text'),
- ),
- '#attributes' => array('class' => array('js-text-summary', 'text-summary')),
+ '#attached' => [
+ 'library' => ['text/drupal.text'],
+ ],
+ '#attributes' => ['class' => ['js-text-summary', 'text-summary']],
'#prefix' => '<div class="js-text-summary-wrapper text-summary-wrapper">',
'#suffix' => '</div>',
'#weight' => -10,
- );
+ ];
return $element;
}
diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
index 5a3ed05bae3..af8493de083 100644
--- a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
@@ -37,7 +37,7 @@ class TextfieldWidget extends StringTextfieldWidget {
* {@inheritdoc}
*/
public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
- if ($violation->arrayPropertyPath == array('format') && isset($element['format']['#access']) && !$element['format']['#access']) {
+ if ($violation->arrayPropertyPath == ['format'] && isset($element['format']['#access']) && !$element['format']['#access']) {
// Ignore validation errors for formats if formats may not be changed,
// i.e. when existing formats become invalid. See filter_process_format().
return FALSE;
diff --git a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php
index 89475ffd220..24dd450d85f 100644
--- a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php
+++ b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php
@@ -87,11 +87,11 @@ class TextField extends CckFieldPluginBase {
];
}
- $process = array(
+ $process = [
'plugin' => 'iterator',
'source' => $field_name,
'process' => $process,
- );
+ ];
$migration->setProcessOfProperty($field_name, $process);
}
diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php
index 993346a0793..5bd6d6f0257 100644
--- a/core/modules/text/src/Tests/TextFieldTest.php
+++ b/core/modules/text/src/Tests/TextFieldTest.php
@@ -26,7 +26,7 @@ class TextFieldTest extends StringFieldTest {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer filters'));
+ $this->adminUser = $this->drupalCreateUser(['administer filters']);
}
// Test fields.
@@ -38,14 +38,14 @@ class TextFieldTest extends StringFieldTest {
// Create a field with settings to validate.
$max_length = 3;
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text',
- 'settings' => array(
+ 'settings' => [
'max_length' => $max_length,
- )
- ));
+ ]
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -72,11 +72,11 @@ class TextFieldTest extends StringFieldTest {
function testRequiredLongTextWithFileUpload() {
// Create a text field.
$text_field_name = 'text_long';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $text_field_name,
'entity_type' => 'entity_test',
'type' => 'text_with_summary',
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -87,11 +87,11 @@ class TextFieldTest extends StringFieldTest {
// Create a file field.
$file_field_name = 'file_field';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $file_field_name,
'entity_type' => 'entity_test',
'type' => 'file'
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -100,12 +100,12 @@ class TextFieldTest extends StringFieldTest {
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($text_field_name, array(
+ ->setComponent($text_field_name, [
'type' => 'text_textarea_with_summary',
- ))
- ->setComponent($file_field_name, array(
+ ])
+ ->setComponent($file_field_name, [
'type' => 'file_generic',
- ))
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent($text_field_name)
@@ -116,9 +116,9 @@ class TextFieldTest extends StringFieldTest {
$edit['files[file_field_0]'] = drupal_realpath($test_file->uri);
$this->drupalPostForm('entity_test/add', $edit, 'Upload');
$this->assertResponse(200);
- $edit = array(
+ $edit = [
'text_long[0][value]' => 'Long text'
- );
+ ];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertResponse(200);
$this->drupalGet('entity_test/1');
@@ -150,11 +150,11 @@ class TextFieldTest extends StringFieldTest {
// Create a field.
$field_name = Unicode::strtolower($this->randomMachineName());
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $field_type
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
@@ -162,9 +162,9 @@ class TextFieldTest extends StringFieldTest {
'label' => $this->randomMachineName() . '_label',
])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => $widget_type,
- ))
+ ])
->save();
entity_get_display('entity_test', 'entity_test', 'full')
->setComponent($field_name)
@@ -174,7 +174,7 @@ class TextFieldTest extends StringFieldTest {
$this->drupalLogin($this->adminUser);
foreach (filter_formats() as $format) {
if (!$format->isFallbackFormat()) {
- $this->drupalPostForm('admin/config/content/formats/manage/' . $format->id() . '/disable', array(), t('Disable'));
+ $this->drupalPostForm('admin/config/content/formats/manage/' . $format->id() . '/disable', [], t('Disable'));
}
}
$this->drupalLogin($this->webUser);
@@ -187,13 +187,13 @@ class TextFieldTest extends StringFieldTest {
// Submit with data that should be filtered.
$value = '<em>' . $this->randomMachineName() . '</em>';
- $edit = array(
+ $edit = [
"{$field_name}[0][value]" => $value,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
$id = $match[1];
- $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
+ $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
// Display the entity.
$entity = EntityTest::load($id);
@@ -206,10 +206,10 @@ class TextFieldTest extends StringFieldTest {
// Create a new text format that does not escape HTML, and grant the user
// access to it.
$this->drupalLogin($this->adminUser);
- $edit = array(
+ $edit = [
'format' => Unicode::strtolower($this->randomMachineName()),
'name' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
filter_formats_reset();
$format = FilterFormat::load($edit['format']);
@@ -217,7 +217,7 @@ class TextFieldTest extends StringFieldTest {
$permission = $format->getPermissionName();
$roles = $this->webUser->getRoles();
$rid = $roles[0];
- user_role_grant_permissions($rid, array($permission));
+ user_role_grant_permissions($rid, [$permission]);
$this->drupalLogin($this->webUser);
// Display edition form.
@@ -227,14 +227,14 @@ class TextFieldTest extends StringFieldTest {
$this->assertFieldByName("{$field_name}[0][format]", NULL, 'Format selector is displayed');
// Edit and change the text format to the new one that was created.
- $edit = array(
+ $edit = [
"{$field_name}[0][format]" => $format_id,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated');
+ $this->assertText(t('entity_test @id has been updated.', ['@id' => $id]), 'Entity was updated');
// Display the entity.
- $this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
+ $this->container->get('entity.manager')->getStorage('entity_test')->resetCache([$id]);
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
diff --git a/core/modules/text/tests/src/Kernel/TextFormatterTest.php b/core/modules/text/tests/src/Kernel/TextFormatterTest.php
index 747a06ffa92..c75ac34bc43 100644
--- a/core/modules/text/tests/src/Kernel/TextFormatterTest.php
+++ b/core/modules/text/tests/src/Kernel/TextFormatterTest.php
@@ -33,7 +33,7 @@ class TextFormatterTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('text');
+ public static $modules = ['text'];
/**
* {@inheritdoc}
@@ -41,23 +41,23 @@ class TextFormatterTest extends EntityKernelTestBase {
protected function setUp() {
parent::setUp();
- FilterFormat::create(array(
+ FilterFormat::create([
'format' => 'my_text_format',
'name' => 'My text format',
- 'filters' => array(
- 'filter_autop' => array(
+ 'filters' => [
+ 'filter_autop' => [
'module' => 'filter',
'status' => TRUE,
- ),
- ),
- ))->save();
+ ],
+ ],
+ ])->save();
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'formatted_text',
'entity_type' => $this->entityType,
'type' => 'text',
- 'settings' => array(),
- ))->save();
+ 'settings' => [],
+ ])->save();
FieldConfig::create([
'entity_type' => $this->entityType,
'bundle' => $this->bundle,
@@ -70,28 +70,28 @@ class TextFormatterTest extends EntityKernelTestBase {
* Tests all text field formatters.
*/
public function testFormatters() {
- $formatters = array(
+ $formatters = [
'text_default',
'text_trimmed',
'text_summary_or_trimmed',
- );
+ ];
// Create the entity to be referenced.
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => $this->randomMachineName()));
- $entity->formatted_text = array(
+ ->create(['name' => $this->randomMachineName()]);
+ $entity->formatted_text = [
'value' => 'Hello, world!',
'format' => 'my_text_format',
- );
+ ];
$entity->save();
foreach ($formatters as $formatter) {
// Verify the text field formatter's render array.
- $build = $entity->get('formatted_text')->view(array('type' => $formatter));
+ $build = $entity->get('formatted_text')->view(['type' => $formatter]);
\Drupal::service('renderer')->renderRoot($build[0]);
$this->assertEqual($build[0]['#markup'], "<p>Hello, world!</p>\n");
- $this->assertEqual($build[0]['#cache']['tags'], FilterFormat::load('my_text_format')->getCacheTags(), format_string('The @formatter formatter has the expected cache tags when formatting a formatted text field.', array('@formatter' => $formatter)));
+ $this->assertEqual($build[0]['#cache']['tags'], FilterFormat::load('my_text_format')->getCacheTags(), format_string('The @formatter formatter has the expected cache tags when formatting a formatted text field.', ['@formatter' => $formatter]));
}
}
diff --git a/core/modules/text/tests/src/Kernel/TextSummaryTest.php b/core/modules/text/tests/src/Kernel/TextSummaryTest.php
index abc0b68bc81..62464e3dc5a 100644
--- a/core/modules/text/tests/src/Kernel/TextSummaryTest.php
+++ b/core/modules/text/tests/src/Kernel/TextSummaryTest.php
@@ -12,12 +12,12 @@ use Drupal\filter\Entity\FilterFormat;
*/
class TextSummaryTest extends KernelTestBase {
- public static $modules = array('system', 'user', 'filter', 'text');
+ public static $modules = ['system', 'user', 'filter', 'text'];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('text'));
+ $this->installConfig(['text']);
}
/**
@@ -50,25 +50,25 @@ class TextSummaryTest extends KernelTestBase {
* Test various summary length edge cases.
*/
function testLength() {
- FilterFormat::create(array(
+ FilterFormat::create([
'format' => 'autop',
- 'filters' => array(
- 'filter_autop' => array(
+ 'filters' => [
+ 'filter_autop' => [
'status' => 1,
- ),
- ),
- ))->save();
- FilterFormat::create(array(
+ ],
+ ],
+ ])->save();
+ FilterFormat::create([
'format' => 'autop_correct',
- 'filters' => array(
- 'filter_autop' => array(
+ 'filters' => [
+ 'filter_autop' => [
'status' => 1,
- ),
- 'filter_htmlcorrector' => array(
+ ],
+ 'filter_htmlcorrector' => [
'status' => 1,
- ),
- ),
- ))->save();
+ ],
+ ],
+ ])->save();
// This string tests a number of edge cases.
$text = "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>";
@@ -207,10 +207,10 @@ class TextSummaryTest extends KernelTestBase {
*/
function assertTextSummary($text, $expected, $format = NULL, $size = NULL) {
$summary = text_summary($text, $format, $size);
- $this->assertIdentical($summary, $expected, format_string('<pre style="white-space: pre-wrap">@actual</pre> is identical to <pre style="white-space: pre-wrap">@expected</pre>', array(
+ $this->assertIdentical($summary, $expected, format_string('<pre style="white-space: pre-wrap">@actual</pre> is identical to <pre style="white-space: pre-wrap">@expected</pre>', [
'@actual' => $summary,
'@expected' => $expected,
- )));
+ ]));
}
}
diff --git a/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php b/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php
index fc02daa7e92..a48c191b5ee 100644
--- a/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php
+++ b/core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php
@@ -21,7 +21,7 @@ class TextWithSummaryItemTest extends FieldKernelTestBase {
*
* @var array
*/
- public static $modules = array('filter');
+ public static $modules = ['filter'];
/**
* Field storage entity.
@@ -44,11 +44,11 @@ class TextWithSummaryItemTest extends FieldKernelTestBase {
$this->installEntitySchema('entity_test_rev');
// Create the necessary formats.
- $this->installConfig(array('filter'));
- FilterFormat::create(array(
+ $this->installConfig(['filter']);
+ FilterFormat::create([
'format' => 'no_filters',
- 'filters' => array(),
- ))->save();
+ 'filters' => [],
+ ])->save();
}
/**
@@ -100,14 +100,14 @@ class TextWithSummaryItemTest extends FieldKernelTestBase {
*/
protected function createField($entity_type) {
// Create a field .
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => 'summary_field',
'entity_type' => $entity_type,
'type' => 'text_with_summary',
- 'settings' => array(
+ 'settings' => [
'max_length' => 10,
- )
- ));
+ ]
+ ]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
diff --git a/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php b/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php
index 323fbce8cb9..d7dfcc679ea 100644
--- a/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php
+++ b/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php
@@ -71,12 +71,12 @@ class TextFieldTest extends UnitTestCase {
* @covers ::processCckFieldValues
*/
public function testProcessBooleanTextImplicitValues() {
- $info = array(
+ $info = [
'widget_type' => 'optionwidgets_onoff',
- 'global_settings' => array(
+ 'global_settings' => [
'allowed_values' => "foo\nbar",
- )
- );
+ ]
+ ];
$this->plugin->processCckFieldValues($this->migration, 'field', $info);
$expected = [
@@ -96,12 +96,12 @@ class TextFieldTest extends UnitTestCase {
* @covers ::processCckFieldValues
*/
public function testProcessBooleanTextExplicitValues() {
- $info = array(
+ $info = [
'widget_type' => 'optionwidgets_onoff',
- 'global_settings' => array(
+ 'global_settings' => [
'allowed_values' => "foo|Foo\nbaz|Baz",
- )
- );
+ ]
+ ];
$this->plugin->processCckFieldValues($this->migration, 'field', $info);
$expected = [
@@ -121,43 +121,43 @@ class TextFieldTest extends UnitTestCase {
* Data provider for testGetFieldType().
*/
public function getFieldTypeProvider() {
- return array(
- array('string_long', 'text_textfield', array(
+ return [
+ ['string_long', 'text_textfield', [
'text_processing' => FALSE,
- )),
- array('string', 'text_textfield', array(
+ ]],
+ ['string', 'text_textfield', [
'text_processing' => FALSE,
'max_length' => 128,
- )),
- array('string_long', 'text_textfield', array(
+ ]],
+ ['string_long', 'text_textfield', [
'text_processing' => FALSE,
'max_length' => 4096,
- )),
- array('text_long', 'text_textfield', array(
+ ]],
+ ['text_long', 'text_textfield', [
'text_processing' => TRUE,
- )),
- array('text', 'text_textfield', array(
+ ]],
+ ['text', 'text_textfield', [
'text_processing' => TRUE,
'max_length' => 128,
- )),
- array('text_long', 'text_textfield', array(
+ ]],
+ ['text_long', 'text_textfield', [
'text_processing' => TRUE,
'max_length' => 4096,
- )),
- array('list_string', 'optionwidgets_buttons'),
- array('list_string', 'optionwidgets_select'),
- array('boolean', 'optionwidgets_onoff'),
- array('text_long', 'text_textarea'),
- array(NULL, 'undefined'),
- );
+ ]],
+ ['list_string', 'optionwidgets_buttons'],
+ ['list_string', 'optionwidgets_select'],
+ ['boolean', 'optionwidgets_onoff'],
+ ['text_long', 'text_textarea'],
+ [NULL, 'undefined'],
+ ];
}
/**
* @covers ::getFieldType
* @dataProvider getFieldTypeProvider
*/
- public function testGetFieldType($expected_type, $widget_type, array $settings = array()) {
- $row = new Row(array('widget_type' => $widget_type), array('widget_type' => array()));
+ public function testGetFieldType($expected_type, $widget_type, array $settings = []) {
+ $row = new Row(['widget_type' => $widget_type], ['widget_type' => []]);
$row->setSourceProperty('global_settings', $settings);
$this->assertSame($expected_type, $this->plugin->getFieldType($row));
}
diff --git a/core/modules/text/text.module b/core/modules/text/text.module
index 906b4614ae1..1932e616496 100644
--- a/core/modules/text/text.module
+++ b/core/modules/text/text.module
@@ -18,11 +18,11 @@ function text_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.text':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Text module allows you to create short and long text fields with optional summaries. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":text_documentation">online documentation for the Text module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':text_documentation' => 'https://www.drupal.org/documentation/modules/text')) . '</p>';
+ $output .= '<p>' . t('The Text module allows you to create short and long text fields with optional summaries. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":text_documentation">online documentation for the Text module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':text_documentation' => 'https://www.drupal.org/documentation/modules/text']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying text fields') . '</dt>';
- $output .= '<dd>' . t('The <em>settings</em> and <em>display</em> of the text field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('The <em>settings</em> and <em>display</em> of the text field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
$output .= '<dt>' . t('Creating short text fields') . '</dt>';
$output .= '<dd>' . t('If you choose <em>Text (plain)</em> or <em>Text (formatted)</em> as the field type on the <em>Manage fields</em> page, then a field with a single row is displayed. You can change the maximum text length in the <em>Field settings</em> when you set up the field.') . '</dd>';
$output .= '<dt>' . t('Creating long text fields') . '</dt>';
@@ -32,7 +32,7 @@ function text_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dt>' . t('Displaying summaries instead of trimmed text') . '</dt>';
$output .= '<dd>' . t('As an alternative to using a trimmed version of the text, you can enter a separate summary by choosing the <em>Text (formatted, long, with summary)</em> field type on the <em>Manage fields</em> page. Even when <em>Summary input</em> is enabled, and summaries are provided, you can display <em>trimmed</em> text nonetheless by choosing the appropriate format on the <em>Manage display</em> page.') . '</dd>';
$output .= '<dt>' . t('Using text formats and editors') . '</dt>';
- $output .= '<dd>' . t('If you choose <em>Text (plain)</em> or <em>Text (plain, long)</em> you restrict the input to <em>Plain text</em> only. If you choose <em>Text (formatted)</em>, <em>Text (formatted, long)</em>, or <em>Text (formatted, long with summary)</em> you allow users to write formatted text. Which options are available to individual users depends on the settings on the <a href=":formats">Text formats and editors page</a>.', array(':formats' => \Drupal::url('filter.admin_overview'))) . '</dd>';
+ $output .= '<dd>' . t('If you choose <em>Text (plain)</em> or <em>Text (plain, long)</em> you restrict the input to <em>Plain text</em> only. If you choose <em>Text (formatted)</em>, <em>Text (formatted, long)</em>, or <em>Text (formatted, long with summary)</em> you allow users to write formatted text. Which options are available to individual users depends on the settings on the <a href=":formats">Text formats and editors page</a>.', [':formats' => \Drupal::url('filter.admin_overview')]) . '</dd>';
$output .= '</dl>';
return $output;
}
@@ -115,13 +115,13 @@ function text_summary($text, $format = NULL, $size = NULL) {
$reversed = strrev($summary);
// Build an array of arrays of break points grouped by preference.
- $break_points = array();
+ $break_points = [];
// A paragraph near the end of sliced summary is most preferable.
- $break_points[] = array('</p>' => 0);
+ $break_points[] = ['</p>' => 0];
// If no complete paragraph then treat line breaks as paragraphs.
- $line_breaks = array('<br />' => 6, '<br>' => 4);
+ $line_breaks = ['<br />' => 6, '<br>' => 4];
// Newline only indicates a line break if line break converter
// filter is present.
if (isset($format) && $filters->has('filter_autop') && $filters->get('filter_autop')->status) {
@@ -130,7 +130,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
$break_points[] = $line_breaks;
// If the first paragraph is too long, split at the end of a sentence.
- $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1);
+ $break_points[] = ['. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1];
// Iterate over the groups of break points until a break point is found.
foreach ($break_points as $points) {
diff --git a/core/modules/toolbar/src/Element/Toolbar.php b/core/modules/toolbar/src/Element/Toolbar.php
index 69a53dbd855..d92330b356b 100644
--- a/core/modules/toolbar/src/Element/Toolbar.php
+++ b/core/modules/toolbar/src/Element/Toolbar.php
@@ -18,35 +18,35 @@ class Toolbar extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderToolbar'),
- ),
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderToolbar'],
+ ],
'#theme' => 'toolbar',
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'toolbar/toolbar',
- ),
- ),
+ ],
+ ],
// Metadata for the toolbar wrapping element.
- '#attributes' => array(
+ '#attributes' => [
// The id cannot be simply "toolbar" or it will clash with the
// simpletest tests listing which produces a checkbox with attribute
// id="toolbar".
'id' => 'toolbar-administration',
'role' => 'group',
'aria-label' => $this->t('Site administration toolbar'),
- ),
+ ],
// Metadata for the administration bar.
- '#bar' => array(
+ '#bar' => [
'#heading' => $this->t('Toolbar items'),
- '#attributes' => array(
+ '#attributes' => [
'id' => 'toolbar-bar',
'role' => 'navigation',
'aria-label' => $this->t('Toolbar items'),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -68,7 +68,7 @@ class Toolbar extends RenderElement {
// toolbar presentation.
$breakpoints = static::breakpointManager()->getBreakpointsByGroup('toolbar');
if (!empty($breakpoints)) {
- $media_queries = array();
+ $media_queries = [];
foreach ($breakpoints as $id => $breakpoint) {
$media_queries[$id] = $breakpoint->getMediaQuery();
}
@@ -82,7 +82,7 @@ class Toolbar extends RenderElement {
// Allow for altering of hook_toolbar().
$module_handler->alter('toolbar', $items);
// Sort the children.
- uasort($items, array('\Drupal\Component\Utility\SortArray', 'sortByWeightProperty'));
+ uasort($items, ['\Drupal\Component\Utility\SortArray', 'sortByWeightProperty']);
// Merge in the original toolbar values.
$element = array_merge($element, $items);
diff --git a/core/modules/toolbar/src/Element/ToolbarItem.php b/core/modules/toolbar/src/Element/ToolbarItem.php
index e39295f1e76..79cbed2d032 100644
--- a/core/modules/toolbar/src/Element/ToolbarItem.php
+++ b/core/modules/toolbar/src/Element/ToolbarItem.php
@@ -19,16 +19,16 @@ class ToolbarItem extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderToolbarItem'),
- ),
- 'tab' => array(
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderToolbarItem'],
+ ],
+ 'tab' => [
'#type' => 'link',
'#title' => NULL,
'#url' => Url::fromRoute('<front>'),
- ),
- );
+ ],
+ ];
}
/**
@@ -47,33 +47,33 @@ class ToolbarItem extends RenderElement {
$id = $element['#id'];
// Provide attributes for a toolbar item.
- $attributes = array(
+ $attributes = [
'id' => $id,
- );
+ ];
// If tray content is present, markup the tray and its associated trigger.
if (!empty($element['tray'])) {
// Provide attributes necessary for trays.
- $attributes += array(
+ $attributes += [
'data-toolbar-tray' => $id . '-tray',
'aria-owns' => $id . '-tray',
'role' => 'button',
'aria-pressed' => 'false',
- );
+ ];
// Merge in module-provided attributes.
- $element['tab'] += array('#attributes' => array());
+ $element['tab'] += ['#attributes' => []];
$element['tab']['#attributes'] += $attributes;
$element['tab']['#attributes']['class'][] = 'trigger';
// Provide attributes for the tray theme wrapper.
- $attributes = array(
+ $attributes = [
'id' => $id . '-tray',
'data-toolbar-tray' => $id . '-tray',
- );
+ ];
// Merge in module-provided attributes.
if (!isset($element['tray']['#wrapper_attributes'])) {
- $element['tray']['#wrapper_attributes'] = array();
+ $element['tray']['#wrapper_attributes'] = [];
}
$element['tray']['#wrapper_attributes'] += $attributes;
$element['tray']['#wrapper_attributes']['class'][] = 'toolbar-tray';
diff --git a/core/modules/toolbar/src/Menu/ToolbarMenuLinkTree.php b/core/modules/toolbar/src/Menu/ToolbarMenuLinkTree.php
index 873ebec7ac8..24ef4e7720f 100644
--- a/core/modules/toolbar/src/Menu/ToolbarMenuLinkTree.php
+++ b/core/modules/toolbar/src/Menu/ToolbarMenuLinkTree.php
@@ -15,7 +15,7 @@ class ToolbarMenuLinkTree extends MenuLinkTree {
public function build(array $tree, $level = 0) {
if ($level == 0) {
if (!$tree) {
- return array();
+ return [];
}
$build = parent::build($tree, $level);
diff --git a/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php b/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php
index dde6b518db7..e78f463d892 100644
--- a/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php
+++ b/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php
@@ -53,12 +53,12 @@ class ToolbarAdminMenuTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'block', 'menu_ui', 'user', 'taxonomy', 'toolbar', 'language', 'test_page_test', 'locale');
+ public static $modules = ['node', 'block', 'menu_ui', 'user', 'taxonomy', 'toolbar', 'language', 'test_page_test', 'locale'];
protected function setUp() {
parent::setUp();
- $perms = array(
+ $perms = [
'access toolbar',
'access administration pages',
'administer site configuration',
@@ -75,7 +75,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
'administer taxonomy',
'administer languages',
'translate interface',
- );
+ ];
// Create an administrative user and log it in.
$this->adminUser = $this->drupalCreateUser($perms);
@@ -99,11 +99,11 @@ class ToolbarAdminMenuTest extends WebTestBase {
*/
function testModuleStatusChangeSubtreesHashCacheClear() {
// Uninstall a module.
- $edit = array();
+ $edit = [];
$edit['uninstall[taxonomy]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
// Confirm the uninstall form.
- $this->drupalPostForm(NULL, array(), t('Uninstall'));
+ $this->drupalPostForm(NULL, [], t('Uninstall'));
$this->rebuildContainer();
// Assert that the subtrees hash has been altered because the subtrees
@@ -111,7 +111,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
$this->assertDifferentHash();
// Enable a module.
- $edit = array();
+ $edit = [];
$edit['modules[taxonomy][enable]'] = TRUE;
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->rebuildContainer();
@@ -129,7 +129,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
$admin_menu_link_id = 'system.admin_config_development';
// Disable the link.
- $edit = array();
+ $edit = [];
$edit['enabled'] = FALSE;
$this->drupalPostForm("admin/structure/menu/link/" . $admin_menu_link_id . "/edit", $edit, t('Save'));
$this->assertResponse(200);
@@ -150,7 +150,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
unset($all_rids[array_search(RoleInterface::AUTHENTICATED_ID, $all_rids)]);
$rid = reset($all_rids);
- $edit = array();
+ $edit = [];
$edit[$rid . '[administer taxonomy]'] = FALSE;
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
@@ -179,10 +179,10 @@ class ToolbarAdminMenuTest extends WebTestBase {
$this->hash = $this->getSubtreesHash();
- $rid = $this->drupalCreateRole(array('administer content types',));
+ $rid = $this->drupalCreateRole(['administer content types',]);
// Assign the role to the user.
- $this->drupalPostForm('user/' . $this->adminUser->id() . '/edit', array("roles[$rid]" => $rid), t('Save'));
+ $this->drupalPostForm('user/' . $this->adminUser->id() . '/edit', ["roles[$rid]" => $rid], t('Save'));
$this->assertText(t('The changes have been saved.'));
// Assert that the subtrees hash has been altered because the subtrees
@@ -214,7 +214,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
// adminUser2 will add a role to adminUser.
$this->drupalLogin($this->adminUser2);
- $rid = $this->drupalCreateRole(array('administer content types',));
+ $rid = $this->drupalCreateRole(['administer content types',]);
// Get the subtree hash for adminUser2 to check later that it has not
// changed. Request a new page to refresh the drupalSettings object.
@@ -223,7 +223,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
$admin_user_2_hash = $this->getSubtreesHash();
// Assign the role to the user.
- $this->drupalPostForm('user/' . $admin_user_id . '/edit', array("roles[$rid]" => $rid), t('Save'));
+ $this->drupalPostForm('user/' . $admin_user_id . '/edit', ["roles[$rid]" => $rid], t('Save'));
$this->assertText(t('The changes have been saved.'));
// Log in adminUser and assert that the subtrees hash has changed.
@@ -246,7 +246,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
function testLocaleTranslationSubtreesHashCacheClear() {
$admin_user = $this->adminUser;
// User to translate and delete string.
- $translate_user = $this->drupalCreateUser(array('translate interface', 'access administration pages'));
+ $translate_user = $this->drupalCreateUser(['translate interface', 'access administration pages']);
// Create a new language with the langcode 'xx'.
$langcode = 'xx';
@@ -257,14 +257,14 @@ class ToolbarAdminMenuTest extends WebTestBase {
// Add custom language.
$this->drupalLogin($admin_user);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
- t($name, array(), array('langcode' => $langcode));
+ t($name, [], ['langcode' => $langcode]);
// Reset locale cache.
$this->container->get('string_translation')->reset();
$this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
@@ -285,11 +285,11 @@ class ToolbarAdminMenuTest extends WebTestBase {
// should create a new menu hash if the toolbar subtrees cache is correctly
// invalidated.
$this->drupalLogin($translate_user);
- $search = array(
+ $search = [
'string' => 'Search and metadata',
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$this->assertNoText(t('No strings available'));
$this->assertText($name, 'Search found the string as untranslated.');
@@ -298,9 +298,9 @@ class ToolbarAdminMenuTest extends WebTestBase {
// Translate the string to a random string.
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $translation,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$this->assertText(t('The strings have been saved.'), 'The strings have been saved.');
$this->assertUrl(\Drupal::url('locale.translate_page', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
@@ -350,7 +350,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
$this->rebuildContainer();
// Get a page with the new language langcode in the URL.
- $this->drupalGet('test-page', array('language' => $language));
+ $this->drupalGet('test-page', ['language' => $language]);
// Assert different hash.
$new_subtree_hash = $this->getSubtreesHash();
diff --git a/core/modules/toolbar/src/Tests/ToolbarMenuTranslationTest.php b/core/modules/toolbar/src/Tests/ToolbarMenuTranslationTest.php
index 8fa2bed5656..a98dacfcd4f 100644
--- a/core/modules/toolbar/src/Tests/ToolbarMenuTranslationTest.php
+++ b/core/modules/toolbar/src/Tests/ToolbarMenuTranslationTest.php
@@ -23,13 +23,13 @@ class ToolbarMenuTranslationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('toolbar', 'toolbar_test', 'locale', 'locale_test');
+ public static $modules = ['toolbar', 'toolbar_test', 'locale', 'locale_test'];
protected function setUp() {
parent::setUp();
// Create an administrative user and log it in.
- $this->adminUser = $this->drupalCreateUser(array('access toolbar', 'translate interface', 'administer languages', 'access administration pages'));
+ $this->adminUser = $this->drupalCreateUser(['access toolbar', 'translate interface', 'administer languages', 'access administration pages']);
$this->drupalLogin($this->adminUser);
}
@@ -50,11 +50,11 @@ class ToolbarMenuTranslationTest extends WebTestBase {
$this->drupalGet($langcode . '/admin/structure');
// Search for the menu item.
- $search = array(
+ $search = [
'string' => $menu_item,
'langcode' => $langcode,
'translation' => 'untranslated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Make sure will be able to translate the menu item.
$this->assertNoText('No strings available.', 'Search found the menu item as untranslated.');
@@ -67,17 +67,17 @@ class ToolbarMenuTranslationTest extends WebTestBase {
$menu_item_translated = $this->randomMachineName();
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
- $edit = array(
+ $edit = [
$lid => $menu_item_translated,
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Search for the translated menu item.
- $search = array(
+ $search = [
'string' => $menu_item,
'langcode' => $langcode,
'translation' => 'translated',
- );
+ ];
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
// Make sure the menu item string was translated.
$this->assertText($menu_item_translated, 'Search found the menu item as translated: ' . $menu_item_translated . '.');
diff --git a/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module b/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module
index 4a82ca7cb2e..323af166c6c 100644
--- a/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module
+++ b/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module
@@ -12,38 +12,38 @@ use Drupal\Core\Url;
*/
function toolbar_test_toolbar() {
- $items['testing'] = array(
+ $items['testing'] = [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#title' => t('Test tab'),
'#url' => Url::fromRoute('<front>'),
- '#options' => array(
- 'attributes' => array(
+ '#options' => [
+ 'attributes' => [
'id' => 'toolbar-tab-testing',
'title' => t('Test tab'),
- ),
- ),
- ),
- 'tray' => array(
+ ],
+ ],
+ ],
+ 'tray' => [
'#heading' => t('Test tray'),
- '#wrapper_attributes' => array(
+ '#wrapper_attributes' => [
'id' => 'toolbar-tray-testing',
- ),
- 'content' => array(
+ ],
+ 'content' => [
'#theme' => 'item_list',
- '#items' => array(
- \Drupal::l(t('link 1'), new Url('<front>', [], array('attributes' => array('title' => 'Test link 1 title')))),
- \Drupal::l(t('link 2'), new Url('<front>', [], array('attributes' => array('title' => 'Test link 2 title')))),
- \Drupal::l(t('link 3'), new Url('<front>', [], array('attributes' => array('title' => 'Test link 3 title')))),
- ),
- '#attributes' => array(
- 'class' => array('toolbar-menu'),
- ),
- ),
- ),
+ '#items' => [
+ \Drupal::l(t('link 1'), new Url('<front>', [], ['attributes' => ['title' => 'Test link 1 title']])),
+ \Drupal::l(t('link 2'), new Url('<front>', [], ['attributes' => ['title' => 'Test link 2 title']])),
+ \Drupal::l(t('link 3'), new Url('<front>', [], ['attributes' => ['title' => 'Test link 3 title']])),
+ ],
+ '#attributes' => [
+ 'class' => ['toolbar-menu'],
+ ],
+ ],
+ ],
'#weight' => 50,
- );
+ ];
return $items;
}
diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php
index 1bf6e82c5b5..6369946fc9d 100644
--- a/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php
+++ b/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php
@@ -23,13 +23,13 @@ class ToolbarHookToolbarTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('toolbar', 'toolbar_test', 'test_page_test');
+ public static $modules = ['toolbar', 'toolbar_test', 'test_page_test'];
protected function setUp() {
parent::setUp();
// Create an administrative user and log it in.
- $this->adminUser = $this->drupalCreateUser(array('access toolbar'));
+ $this->adminUser = $this->drupalCreateUser(['access toolbar']);
$this->drupalLogin($this->adminUser);
}
diff --git a/core/modules/toolbar/toolbar.api.php b/core/modules/toolbar/toolbar.api.php
index b2d04091b99..b6230827441 100644
--- a/core/modules/toolbar/toolbar.api.php
+++ b/core/modules/toolbar/toolbar.api.php
@@ -45,45 +45,45 @@ use Drupal\Core\Url;
* @ingroup toolbar_tabs
*/
function hook_toolbar() {
- $items = array();
+ $items = [];
// Add a search field to the toolbar. The search field employs no toolbar
// module theming functions.
- $items['global_search'] = array(
+ $items['global_search'] = [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'search',
- '#attributes' => array(
+ '#attributes' => [
'placeholder' => t('Search the site'),
- 'class' => array('search-global'),
- ),
- ),
+ 'class' => ['search-global'],
+ ],
+ ],
'#weight' => 200,
// Custom CSS, JS or a library can be associated with the toolbar item.
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'search/global',
- ),
- ),
- );
+ ],
+ ],
+ ];
// The 'Home' tab is a simple link, which is wrapped in markup associated
// with a visual tab styling.
- $items['home'] = array(
+ $items['home'] = [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#title' => t('Home'),
'#url' => Url::fromRoute('<front>'),
- '#options' => array(
- 'attributes' => array(
+ '#options' => [
+ 'attributes' => [
'title' => t('Home page'),
- 'class' => array('toolbar-icon', 'toolbar-icon-home'),
- ),
- ),
- ),
+ 'class' => ['toolbar-icon', 'toolbar-icon-home'],
+ ],
+ ],
+ ],
'#weight' => -20,
- );
+ ];
// A tray may be associated with a tab.
//
@@ -93,27 +93,27 @@ function hook_toolbar() {
// The tray should contain a renderable array. An optional #heading property
// can be passed. This text is written to a heading tag in the tray as a
// landmark for accessibility.
- $items['commerce'] = array(
+ $items['commerce'] = [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#title' => t('Shopping cart'),
'#url' => Url::fromRoute('cart'),
- '#options' => array(
- 'attributes' => array(
+ '#options' => [
+ 'attributes' => [
'title' => t('Shopping cart'),
- ),
- ),
- ),
- 'tray' => array(
+ ],
+ ],
+ ],
+ 'tray' => [
'#heading' => t('Shopping cart actions'),
- 'shopping_cart' => array(
+ 'shopping_cart' => [
'#theme' => 'item_list',
- '#items' => array( /* An item list renderable array */ ),
- ),
- ),
+ '#items' => [ /* An item list renderable array */ ],
+ ],
+ ],
'#weight' => 150,
- );
+ ];
// The tray can be used to render arbitrary content.
//
@@ -123,28 +123,28 @@ function hook_toolbar() {
// If the default behavior and styling of a toolbar tray is not desired, one
// can render content to the toolbar element and apply custom theming and
// behaviors.
- $items['user_messages'] = array(
+ $items['user_messages'] = [
// Include the toolbar_tab_wrapper to style the link like a toolbar tab.
// Exclude the theme wrapper if custom styling is desired.
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#theme' => 'user_message_toolbar_tab',
- '#theme_wrappers' => array(),
+ '#theme_wrappers' => [],
'#title' => t('Messages'),
'#url' => Url::fromRoute('user.message'),
- '#options' => array(
- 'attributes' => array(
+ '#options' => [
+ 'attributes' => [
'title' => t('Messages'),
- ),
- ),
- ),
- 'tray' => array(
+ ],
+ ],
+ ],
+ 'tray' => [
'#heading' => t('User messages'),
- 'messages' => array(/* renderable content */),
- ),
+ 'messages' => [/* renderable content */],
+ ],
'#weight' => 125,
- );
+ ];
return $items;
}
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 281f3abbbcc..4791f87f978 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -20,7 +20,7 @@ function toolbar_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.toolbar':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Toolbar module provides a toolbar for site administrators, which displays tabs and trays provided by the Toolbar module itself and other modules. For more information, see the <a href=":toolbar_docs">online documentation for the Toolbar module</a>.', array(':toolbar_docs' => 'https://www.drupal.org/documentation/modules/toolbar')) . '</p>';
+ $output .= '<p>' . t('The Toolbar module provides a toolbar for site administrators, which displays tabs and trays provided by the Toolbar module itself and other modules. For more information, see the <a href=":toolbar_docs">online documentation for the Toolbar module</a>.', [':toolbar_docs' => 'https://www.drupal.org/documentation/modules/toolbar']) . '</p>';
$output .= '<h4>' . t('Terminology') . '</h4>';
$output .= '<dl>';
$output .= '<dt>' . t('Tabs') . '</dt>';
@@ -36,13 +36,13 @@ function toolbar_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function toolbar_theme($existing, $type, $theme, $path) {
- $items['toolbar'] = array(
+ $items['toolbar'] = [
'render element' => 'element',
- );
- $items['menu__toolbar'] = array(
+ ];
+ $items['menu__toolbar'] = [
'base hook' => 'menu',
- 'variables' => array('items' => array(), 'attributes' => array()),
- );
+ 'variables' => ['items' => [], 'attributes' => []],
+ ];
return $items;
}
@@ -53,14 +53,14 @@ function toolbar_theme($existing, $type, $theme, $path) {
* Add admin toolbar to the top of the page automatically.
*/
function toolbar_page_top(array &$page_top) {
- $page_top['toolbar'] = array(
+ $page_top['toolbar'] = [
'#type' => 'toolbar',
'#access' => \Drupal::currentUser()->hasPermission('access toolbar'),
'#cache' => [
'keys' => ['toolbar'],
'contexts' => ['user.permissions'],
],
- );
+ ];
}
/**
@@ -83,9 +83,9 @@ function template_preprocess_toolbar(&$variables) {
// Prepare the trays and tabs for each toolbar item as well as the remainder
// variable that will hold any non-tray, non-tab elements.
- $variables['trays'] = array();
- $variables['tabs'] = array();
- $variables['remainder'] = array();
+ $variables['trays'] = [];
+ $variables['tabs'] = [];
+ $variables['remainder'] = [];
foreach (Element::children($element) as $key) {
// Early rendering to collect the wrapper attributes from
// ToolbarItem elements.
@@ -94,14 +94,14 @@ function template_preprocess_toolbar(&$variables) {
}
// Add the tray.
if (isset($element[$key]['tray'])) {
- $attributes = array();
+ $attributes = [];
if (!empty($element[$key]['tray']['#wrapper_attributes'])) {
$attributes = $element[$key]['tray']['#wrapper_attributes'];
}
- $variables['trays'][$key] = array(
+ $variables['trays'][$key] = [
'links' => $element[$key]['tray'],
'attributes' => new Attribute($attributes),
- );
+ ];
if (array_key_exists('#heading', $element[$key]['tray'])) {
$variables['trays'][$key]['label'] = $element[$key]['tray']['#heading'];
}
@@ -109,22 +109,22 @@ function template_preprocess_toolbar(&$variables) {
// Add the tab.
if (isset($element[$key]['tab'])) {
- $attributes = array();
+ $attributes = [];
// Pass the wrapper attributes along.
if (!empty($element[$key]['#wrapper_attributes'])) {
$attributes = $element[$key]['#wrapper_attributes'];
}
- $variables['tabs'][$key] = array(
+ $variables['tabs'][$key] = [
'link' => $element[$key]['tab'],
'attributes' => new Attribute($attributes),
- );
+ ];
}
// Add other non-tray, non-tab child elements to the remainder variable for
// later rendering.
foreach (Element::children($element[$key]) as $child_key) {
- if (!in_array($child_key, array('tray', 'tab'))) {
+ if (!in_array($child_key, ['tray', 'tab'])) {
$variables['remainder'][$key][$child_key] = $element[$key][$child_key];
}
}
@@ -136,28 +136,28 @@ function template_preprocess_toolbar(&$variables) {
*/
function toolbar_toolbar() {
// The 'Home' tab is a simple link, with no corresponding tray.
- $items['home'] = array(
+ $items['home'] = [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#title' => t('Back to site'),
'#url' => Url::fromRoute('<front>'),
- '#attributes' => array(
+ '#attributes' => [
'title' => t('Return to site content'),
- 'class' => array('toolbar-icon', 'toolbar-icon-escape-admin'),
+ 'class' => ['toolbar-icon', 'toolbar-icon-escape-admin'],
'data-toolbar-escape-admin' => TRUE,
- ),
- ),
- '#wrapper_attributes' => array(
- 'class' => array('hidden', 'home-toolbar-tab'),
- ),
- '#attached' => array(
- 'library' => array(
+ ],
+ ],
+ '#wrapper_attributes' => [
+ 'class' => ['hidden', 'home-toolbar-tab'],
+ ],
+ '#attached' => [
+ 'library' => [
'toolbar/toolbar.escapeAdmin',
- ),
- ),
+ ],
+ ],
'#weight' => -20,
- );
+ ];
// To conserve bandwidth, we only include the top-level links in the HTML.
// The subtrees are fetched through a JSONP script that is generated at the
@@ -171,38 +171,38 @@ function toolbar_toolbar() {
// The administration element has a link that is themed to correspond to
// a toolbar tray. The tray contains the full administrative menu of the site.
- $items['administration'] = array(
+ $items['administration'] = [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#title' => t('Manage'),
'#url' => Url::fromRoute('system.admin'),
- '#attributes' => array(
+ '#attributes' => [
'title' => t('Admin menu'),
- 'class' => array('toolbar-icon', 'toolbar-icon-menu'),
+ 'class' => ['toolbar-icon', 'toolbar-icon-menu'],
// A data attribute that indicates to the client to defer loading of
// the admin menu subtrees until this tab is activated. Admin menu
// subtrees will not render to the DOM if this attribute is removed.
// The value of the attribute is intentionally left blank. Only the
// presence of the attribute is necessary.
'data-drupal-subtrees' => '',
- ),
- ),
- 'tray' => array(
+ ],
+ ],
+ 'tray' => [
'#heading' => t('Administration menu'),
'#attached' => $subtrees_attached,
- 'toolbar_administration' => array(
- '#pre_render' => array(
+ 'toolbar_administration' => [
+ '#pre_render' => [
'toolbar_prerender_toolbar_administration_tray',
- ),
+ ],
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('toolbar-menu-administration'),
- ),
- ),
- ),
+ '#attributes' => [
+ 'class' => ['toolbar-menu-administration'],
+ ],
+ ],
+ ],
'#weight' => -15,
- );
+ ];
$hash_cacheability->applyTo($items['administration']);
return $items;
@@ -228,11 +228,11 @@ function toolbar_prerender_toolbar_administration_tray(array $element) {
$parameters->setMinDepth(2)->setMaxDepth(2)->onlyEnabledLinks();
// @todo Make the menu configurable in https://www.drupal.org/node/1869638.
$tree = $menu_tree->load('admin', $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- array('callable' => 'toolbar_menu_navigation_links'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ['callable' => 'toolbar_menu_navigation_links'],
+ ];
$tree = $menu_tree->transform($tree, $manipulators);
$element['administration_menu'] = $menu_tree->build($tree);
return $element;
@@ -262,7 +262,7 @@ function toolbar_menu_navigation_links(array $tree) {
$id = substr(Crypt::hashBase64($url->getUri()), 0, 16);
}
else {
- $id = str_replace(array('.', '<', '>'), array('-', '', ''), $url->getRouteName());
+ $id = str_replace(['.', '<', '>'], ['-', '', ''], $url->getRouteName());
}
// Get the non-localized title to make the icon class.
@@ -270,7 +270,7 @@ function toolbar_menu_navigation_links(array $tree) {
$element->options['attributes']['id'] = 'toolbar-link-' . $id;
$element->options['attributes']['class'][] = 'toolbar-icon';
- $element->options['attributes']['class'][] = 'toolbar-icon-' . strtolower(str_replace(array('.', ' ', '_'), array('-', '-', '-'), $definition['id']));
+ $element->options['attributes']['class'][] = 'toolbar-icon-' . strtolower(str_replace(['.', ' ', '_'], ['-', '-', '-'], $definition['id']));
$element->options['attributes']['title'] = $link->getDescription();
}
return $tree;
@@ -310,13 +310,13 @@ function _toolbar_do_get_rendered_subtrees(array $data) {
$parameters->setMinDepth(2)->setMaxDepth(4)->onlyEnabledLinks();
// @todo Make the menu configurable in https://www.drupal.org/node/1869638.
$tree = $menu_tree->load('admin', $parameters);
- $manipulators = array(
- array('callable' => 'menu.default_tree_manipulators:checkAccess'),
- array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
- array('callable' => 'toolbar_menu_navigation_links'),
- );
+ $manipulators = [
+ ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+ ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+ ['callable' => 'toolbar_menu_navigation_links'],
+ ];
$tree = $menu_tree->transform($tree, $manipulators);
- $subtrees = array();
+ $subtrees = [];
// Calculated the combined cacheability of all subtrees.
$cacheability = new CacheableMetadata();
foreach ($tree as $element) {
@@ -333,7 +333,7 @@ function _toolbar_do_get_rendered_subtrees(array $data) {
// Many routes have dots as route name, while some special ones like <front>
// have <> characters in them.
$url = $link->getUrlObject();
- $id = str_replace(array('.', '<', '>'), array('-', '', '' ), $url->isRouted() ? $url->getRouteName() : $url->getUri());
+ $id = str_replace(['.', '<', '>'], ['-', '', '' ], $url->isRouted() ? $url->getRouteName() : $url->getUri());
$subtrees[$id] = $output;
}
diff --git a/core/modules/tour/src/Entity/Tour.php b/core/modules/tour/src/Entity/Tour.php
index 290d3f8fb9f..6f4038d5d11 100644
--- a/core/modules/tour/src/Entity/Tour.php
+++ b/core/modules/tour/src/Entity/Tour.php
@@ -59,7 +59,7 @@ class Tour extends ConfigEntityBase implements TourInterface {
*
* @var array
*/
- protected $routes = array();
+ protected $routes = [];
/**
* The routes on which this tour should be displayed, keyed by route id.
@@ -80,7 +80,7 @@ class Tour extends ConfigEntityBase implements TourInterface {
*
* @var array
*/
- protected $tips = array();
+ protected $tips = [];
/**
* {@inheritdoc}
@@ -109,7 +109,7 @@ class Tour extends ConfigEntityBase implements TourInterface {
* {@inheritdoc}
*/
public function getTips() {
- $tips = array();
+ $tips = [];
foreach ($this->tips as $id => $tip) {
$tips[] = $this->getTip($id);
}
@@ -136,9 +136,9 @@ class Tour extends ConfigEntityBase implements TourInterface {
*/
public function hasMatchingRoute($route_name, $route_params) {
if (!isset($this->keyedRoutes)) {
- $this->keyedRoutes = array();
+ $this->keyedRoutes = [];
foreach ($this->getRoutes() as $route) {
- $this->keyedRoutes[$route['route_name']] = isset($route['route_params']) ? $route['route_params'] : array();
+ $this->keyedRoutes[$route['route_name']] = isset($route['route_params']) ? $route['route_params'] : [];
}
}
if (!isset($this->keyedRoutes[$route_name])) {
diff --git a/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php b/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php
index f7d279386ed..268741a83d9 100644
--- a/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php
+++ b/core/modules/tour/src/Plugin/tour/tip/TipPluginText.php
@@ -116,7 +116,7 @@ class TipPluginText extends TipPluginBase implements ContainerFactoryPluginInter
public function getOutput() {
$output = '<h2 class="tour-tip-label" id="tour-tip-' . $this->getAriaId() . '-label">' . Html::escape($this->getLabel()) . '</h2>';
$output .= '<p class="tour-tip-body" id="tour-tip-' . $this->getAriaId() . '-contents">' . $this->token->replace($this->getBody()) . '</p>';
- return array('#markup' => $output);
+ return ['#markup' => $output];
}
}
diff --git a/core/modules/tour/src/Tests/TourTest.php b/core/modules/tour/src/Tests/TourTest.php
index 78304c6e957..749e7c5a3ee 100644
--- a/core/modules/tour/src/Tests/TourTest.php
+++ b/core/modules/tour/src/Tests/TourTest.php
@@ -25,7 +25,7 @@ class TourTest extends TourTestBasic {
* @var array
* A list of permissions.
*/
- protected $permissions = array('access tour', 'administer languages');
+ protected $permissions = ['access tour', 'administer languages'];
/**
* Tour tip attributes to be tested. Keyed by the path.
@@ -33,9 +33,9 @@ class TourTest extends TourTestBasic {
* @var array
* An array of tip attributes, keyed by path.
*/
- protected $tips = array(
- 'tour-test-1' => array(),
- );
+ protected $tips = [
+ 'tour-test-1' => [],
+ ];
/**
* {@inheritdoc}
@@ -57,18 +57,18 @@ class TourTest extends TourTestBasic {
$this->drupalGet('tour-test-1');
// Test the TourTestBase class assertTourTips() method.
- $tips = array();
- $tips[] = array('data-id' => 'tour-test-1');
- $tips[] = array('data-class' => 'tour-test-5');
+ $tips = [];
+ $tips[] = ['data-id' => 'tour-test-1'];
+ $tips[] = ['data-class' => 'tour-test-5'];
$this->assertTourTips($tips);
$this->assertTourTips();
- $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', array(
+ $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', [
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1',
':data_id' => 'tour-test-1',
':href' => \Drupal::url('<front>', [], ['absolute' => TRUE]),
':text' => 'Drupal',
- ));
+ ]);
$this->assertEqual(count($elements), 1, 'Found Token replacement.');
$elements = $this->cssSelect("li[data-id=tour-test-1] h2:contains('The first tip')");
@@ -104,43 +104,43 @@ class TourTest extends TourTestBasic {
$this->assertNotEqual(count($elements), 1, 'Did not find English variant of tip 1.');
// Programmatically create a tour for use through the remainder of the test.
- $tour = Tour::create(array(
+ $tour = Tour::create([
'id' => 'tour-entity-create-test-en',
'label' => 'Tour test english',
'langcode' => 'en',
'module' => 'system',
- 'routes' => array(
- array('route_name' => 'tour_test.1'),
- ),
- 'tips' => array(
- 'tour-test-1' => array(
+ 'routes' => [
+ ['route_name' => 'tour_test.1'],
+ ],
+ 'tips' => [
+ 'tour-test-1' => [
'id' => 'tour-code-test-1',
'plugin' => 'text',
'label' => 'The rain in spain',
'body' => 'Falls mostly on the plain.',
'weight' => '100',
- 'attributes' => array(
+ 'attributes' => [
'data-id' => 'tour-code-test-1',
- ),
- ),
- 'tour-code-test-2' => array(
+ ],
+ ],
+ 'tour-code-test-2' => [
'id' => 'tour-code-test-2',
'plugin' => 'image',
'label' => 'The awesome image',
'url' => 'http://local/image.png',
'weight' => 1,
- 'attributes' => array(
+ 'attributes' => [
'data-id' => 'tour-code-test-2'
- ),
- ),
- ),
- ));
+ ],
+ ],
+ ],
+ ]);
$tour->save();
// Ensure that a tour entity has the expected dependencies based on plugin
// providers and the module named in the configuration entity.
$dependencies = $tour->calculateDependencies()->getDependencies();
- $this->assertEqual($dependencies['module'], array('system', 'tour_test'));
+ $this->assertEqual($dependencies['module'], ['system', 'tour_test']);
$this->drupalGet('tour-test-1');
@@ -167,21 +167,21 @@ class TourTest extends TourTestBasic {
// Navigate to tour-test-3 and verify the tour_test_1 tip is found with
// appropriate classes.
$this->drupalGet('tour-test-3/foo');
- $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', array(
+ $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', [
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1',
':data_id' => 'tour-test-1',
':text' => 'The first tip',
- ));
+ ]);
$this->assertEqual(count($elements), 1, 'Found English variant of tip 1.');
// Navigate to tour-test-3 and verify the tour_test_1 tip is not found with
// appropriate classes.
$this->drupalGet('tour-test-3/bar');
- $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', array(
+ $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', [
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1',
':data_id' => 'tour-test-1',
':text' => 'The first tip',
- ));
+ ]);
$this->assertEqual(count($elements), 0, 'Did not find English variant of tip 1.');
}
diff --git a/core/modules/tour/src/Tests/TourTestBase.php b/core/modules/tour/src/Tests/TourTestBase.php
index 8383c99d1f3..198051d3702 100644
--- a/core/modules/tour/src/Tests/TourTestBase.php
+++ b/core/modules/tour/src/Tests/TourTestBase.php
@@ -29,7 +29,7 @@ abstract class TourTestBase extends WebTestBase {
* $this->assertTourTips($tips);
* @endcode
*/
- public function assertTourTips($tips = array()) {
+ public function assertTourTips($tips = []) {
// Get the rendered tips and their data-id and data-class attributes.
if (empty($tips)) {
// Tips are rendered as <li> elements inside <ol id="tour">.
@@ -51,11 +51,11 @@ abstract class TourTestBase extends WebTestBase {
foreach ($tips as $tip) {
if (!empty($tip['data-id'])) {
$elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $this->content, TRUE);
- $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', array('%data-id' => $tip['data-id'])));
+ $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', ['%data-id' => $tip['data-id']]));
}
elseif (!empty($tip['data-class'])) {
$elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $this->content, TRUE);
- $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', array('%data-class' => $tip['data-class'])));
+ $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', ['%data-class' => $tip['data-class']]));
}
else {
// It's a modal.
@@ -63,7 +63,7 @@ abstract class TourTestBase extends WebTestBase {
}
$total++;
}
- $this->pass(format_string('Total %total Tips tested of which %modals modal(s).', array('%total' => $total, '%modals' => $modals)));
+ $this->pass(format_string('Total %total Tips tested of which %modals modal(s).', ['%total' => $total, '%modals' => $modals]));
}
}
diff --git a/core/modules/tour/src/Tests/TourTestBasic.php b/core/modules/tour/src/Tests/TourTestBasic.php
index e79eb2b451b..1db8bc5c6aa 100644
--- a/core/modules/tour/src/Tests/TourTestBasic.php
+++ b/core/modules/tour/src/Tests/TourTestBasic.php
@@ -22,7 +22,7 @@ abstract class TourTestBasic extends TourTestBase {
* );
* @endcode
*/
- protected $tips = array();
+ protected $tips = [];
/**
* An admin user with administrative permissions for tour.
@@ -37,14 +37,14 @@ abstract class TourTestBasic extends TourTestBase {
* @var array
* A list of permissions.
*/
- protected $permissions = array('access tour');
+ protected $permissions = ['access tour'];
protected function setUp() {
parent::setUp();
// Make sure we are using distinct default and administrative themes for
// the duration of these tests.
- $this->container->get('theme_handler')->install(array('bartik', 'seven'));
+ $this->container->get('theme_handler')->install(['bartik', 'seven']);
$this->config('system.theme')
->set('default', 'bartik')
->set('admin', 'seven')
diff --git a/core/modules/tour/src/TourViewBuilder.php b/core/modules/tour/src/TourViewBuilder.php
index 34172de0675..a9bfe5a5fdc 100644
--- a/core/modules/tour/src/TourViewBuilder.php
+++ b/core/modules/tour/src/TourViewBuilder.php
@@ -13,35 +13,35 @@ class TourViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
- public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
+ public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) {
/** @var \Drupal\tour\TourInterface[] $entities */
- $build = array();
+ $build = [];
foreach ($entities as $entity_id => $entity) {
$tips = $entity->getTips();
$count = count($tips);
- $list_items = array();
+ $list_items = [];
foreach ($tips as $index => $tip) {
if ($output = $tip->getOutput()) {
- $attributes = array(
- 'class' => array(
+ $attributes = [
+ 'class' => [
'tip-module-' . Html::cleanCssIdentifier($entity->getModule()),
'tip-type-' . Html::cleanCssIdentifier($tip->getPluginId()),
'tip-' . Html::cleanCssIdentifier($tip->id()),
- ),
- );
- $list_items[] = array(
+ ],
+ ];
+ $list_items[] = [
'output' => $output,
- 'counter' => array(
+ 'counter' => [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array(
+ '#attributes' => [
+ 'class' => [
'tour-progress',
- ),
- ),
- '#children' => t('@tour_item of @total', array('@tour_item' => $index + 1, '@total' => $count)),
- ),
+ ],
+ ],
+ '#children' => t('@tour_item of @total', ['@tour_item' => $index + 1, '@total' => $count]),
+ ],
'#wrapper_attributes' => $tip->getAttributes() + $attributes,
- );
+ ];
}
}
// If there is at least one tour item, build the tour.
@@ -49,20 +49,20 @@ class TourViewBuilder extends EntityViewBuilder {
end($list_items);
$key = key($list_items);
$list_items[$key]['#wrapper_attributes']['data-text'] = t('End tour');
- $build[$entity_id] = array(
+ $build[$entity_id] = [
'#theme' => 'item_list',
'#items' => $list_items,
'#list_type' => 'ol',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'tour',
- 'class' => array(
+ 'class' => [
'hidden',
- ),
- ),
+ ],
+ ],
'#cache' => [
'tags' => $entity->getCacheTags(),
],
- );
+ ];
}
}
// If at least one tour was built, attach the tour library.
diff --git a/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php b/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php
index c7048fb2a69..ff2e9e586e8 100644
--- a/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php
+++ b/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php
@@ -18,7 +18,7 @@ class TourCacheTagsTest extends PageCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('tour', 'tour_test');
+ public static $modules = ['tour', 'tour_test'];
/**
* {@inheritdoc}
diff --git a/core/modules/tour/tests/src/Kernel/TourPluginTest.php b/core/modules/tour/tests/src/Kernel/TourPluginTest.php
index 9278e2e548e..ce47467df71 100644
--- a/core/modules/tour/tests/src/Kernel/TourPluginTest.php
+++ b/core/modules/tour/tests/src/Kernel/TourPluginTest.php
@@ -16,7 +16,7 @@ class TourPluginTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('tour');
+ public static $modules = ['tour'];
/**
* Stores the tour plugin manager.
@@ -28,7 +28,7 @@ class TourPluginTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->installConfig(array('tour'));
+ $this->installConfig(['tour']);
$this->pluginManager = $this->container->get('plugin.manager.tour.tip');
}
diff --git a/core/modules/tour/tests/src/Unit/Entity/TourTest.php b/core/modules/tour/tests/src/Unit/Entity/TourTest.php
index 2c71aa9650c..08944eef2a1 100644
--- a/core/modules/tour/tests/src/Unit/Entity/TourTest.php
+++ b/core/modules/tour/tests/src/Unit/Entity/TourTest.php
@@ -29,7 +29,7 @@ class TourTest extends UnitTestCase {
public function testHasMatchingRoute($routes, $route_name, $route_params, $result) {
$tour = $this->getMockBuilder('\Drupal\tour\Entity\Tour')
->disableOriginalConstructor()
- ->setMethods(array('getRoutes'))
+ ->setMethods(['getRoutes'])
->getMock();
$tour->expects($this->any())
@@ -45,94 +45,94 @@ class TourTest extends UnitTestCase {
* Provides sample routes for testing.
*/
public function routeProvider() {
- return array(
+ return [
// Simple match.
- array(
- array(
- array('route_name' => 'some.route'),
- ),
+ [
+ [
+ ['route_name' => 'some.route'],
+ ],
'some.route',
- array(),
+ [],
TRUE,
- ),
+ ],
// Simple non-match.
- array(
- array(
- array('route_name' => 'another.route'),
- ),
+ [
+ [
+ ['route_name' => 'another.route'],
+ ],
'some.route',
- array(),
+ [],
FALSE,
- ),
+ ],
// Empty params.
- array(
- array(
- array(
+ [
+ [
+ [
'route_name' => 'some.route',
- 'route_params' => array('foo' => 'bar'),
- ),
- ),
+ 'route_params' => ['foo' => 'bar'],
+ ],
+ ],
'some.route',
- array(),
+ [],
FALSE,
- ),
+ ],
// Match on params.
- array(
- array(
- array(
+ [
+ [
+ [
'route_name' => 'some.route',
- 'route_params' => array('foo' => 'bar'),
- ),
- ),
+ 'route_params' => ['foo' => 'bar'],
+ ],
+ ],
'some.route',
- array('foo' => 'bar'),
+ ['foo' => 'bar'],
TRUE,
- ),
+ ],
// Non-matching params.
- array(
- array(
- array(
+ [
+ [
+ [
'route_name' => 'some.route',
- 'route_params' => array('foo' => 'bar'),
- ),
- ),
+ 'route_params' => ['foo' => 'bar'],
+ ],
+ ],
'some.route',
- array('bar' => 'foo'),
+ ['bar' => 'foo'],
FALSE,
- ),
+ ],
// One matching, one not.
- array(
- array(
- array(
+ [
+ [
+ [
'route_name' => 'some.route',
- 'route_params' => array('foo' => 'bar'),
- ),
- array(
+ 'route_params' => ['foo' => 'bar'],
+ ],
+ [
'route_name' => 'some.route',
- 'route_params' => array('bar' => 'foo'),
- ),
- ),
+ 'route_params' => ['bar' => 'foo'],
+ ],
+ ],
'some.route',
- array('bar' => 'foo'),
+ ['bar' => 'foo'],
TRUE,
- ),
+ ],
// One matching, one not.
- array(
- array(
- array(
+ [
+ [
+ [
'route_name' => 'some.route',
- 'route_params' => array('foo' => 'bar'),
- ),
- array(
+ 'route_params' => ['foo' => 'bar'],
+ ],
+ [
'route_name' => 'some.route',
- 'route_params' => array('foo' => 'baz'),
- ),
- ),
+ 'route_params' => ['foo' => 'baz'],
+ ],
+ ],
'some.route',
- array('foo' => 'baz'),
+ ['foo' => 'baz'],
TRUE,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/tour/tests/tour_test/src/Controller/TourTestController.php b/core/modules/tour/tests/tour_test/src/Controller/TourTestController.php
index 87b817df7bf..56505aa0a0f 100644
--- a/core/modules/tour/tests/tour_test/src/Controller/TourTestController.php
+++ b/core/modules/tour/tests/tour_test/src/Controller/TourTestController.php
@@ -18,56 +18,56 @@ class TourTestController {
* Array of markup.
*/
public function tourTest1($locale = 'foo') {
- return array(
- 'tip-1' => array(
+ return [
+ 'tip-1' => [
'#type' => 'container',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'tour-test-1',
- ),
+ ],
'#children' => t('Where does the rain in Spain fail?'),
- ),
- 'tip-3' => array(
+ ],
+ 'tip-3' => [
'#type' => 'container',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'tour-test-3',
- ),
+ ],
'#children' => t('Tip created now?'),
- ),
- 'tip-4' => array(
+ ],
+ 'tip-4' => [
'#type' => 'container',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'tour-test-4',
- ),
+ ],
'#children' => t('Tip created later?'),
- ),
- 'tip-5' => array(
+ ],
+ 'tip-5' => [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('tour-test-5'),
- ),
+ '#attributes' => [
+ 'class' => ['tour-test-5'],
+ ],
'#children' => t('Tip created later?'),
- ),
- 'code-tip-1' => array(
+ ],
+ 'code-tip-1' => [
'#type' => 'container',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'tour-code-test-1',
- ),
+ ],
'#children' => t('Tip created now?'),
- ),
- );
+ ],
+ ];
}
/**
* Outputs some content for testing tours.
*/
public function tourTest2() {
- return array(
+ return [
'#type' => 'container',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'tour-test-2',
- ),
+ ],
'#children' => t('Pangram example'),
- );
+ ];
}
diff --git a/core/modules/tour/tour.module b/core/modules/tour/tour.module
index e456361f876..1de83992bbf 100644
--- a/core/modules/tour/tour.module
+++ b/core/modules/tour/tour.module
@@ -16,13 +16,13 @@ function tour_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.tour':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t("The Tour module provides users with guided tours of the site interface. Each tour consists of several tips that highlight elements of the user interface, guide the user through a workflow, or explain key concepts of the website. For more information, see the <a href=':tour'>online documentation for the Tour module</a>.", array(':tour' => 'https://www.drupal.org/documentation/modules/tour')) . '</p>';
+ $output .= '<p>' . t("The Tour module provides users with guided tours of the site interface. Each tour consists of several tips that highlight elements of the user interface, guide the user through a workflow, or explain key concepts of the website. For more information, see the <a href=':tour'>online documentation for the Tour module</a>.", [':tour' => 'https://www.drupal.org/documentation/modules/tour']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Viewing tours') . '</dt>';
$output .= '<dd>' . t("If a tour is available on a page, a <em>Tour</em> button will be visible in the toolbar. If you click this button the first tip of the tour will appear. The tour continues after clicking the <em>Next</em> button in the tip. To see a tour users must have the permission <em>Access tour</em> and JavaScript must be enabled in the browser") . '</dd>';
$output .= '<dt>' . t('Creating tours') . '</dt>';
- $output .= '<dd>' . t("Tours can be written as YAML-documents with a text editor, or using the contributed <a href=':tour_ui'>Tour UI</a> module. For more information, see <a href=':doc_url'>the online documentation for writing tours</a>.", array(':doc_url' => 'https://www.drupal.org/developing/api/tour', ':tour_ui' => 'https://www.drupal.org/project/tour_ui')) . '</dd>';
+ $output .= '<dd>' . t("Tours can be written as YAML-documents with a text editor, or using the contributed <a href=':tour_ui'>Tour UI</a> module. For more information, see <a href=':doc_url'>the online documentation for writing tours</a>.", [':doc_url' => 'https://www.drupal.org/developing/api/tour', ':tour_ui' => 'https://www.drupal.org/project/tour_ui']) . '</dd>';
$output .= '</dl>';
return $output;
}
@@ -45,27 +45,27 @@ function tour_toolbar() {
return $items;
}
- $items['tour'] += array(
+ $items['tour'] += [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'html_tag',
'#tag' => 'button',
'#value' => t('Tour'),
- '#attributes' => array(
- 'class' => array('toolbar-icon', 'toolbar-icon-help'),
+ '#attributes' => [
+ 'class' => ['toolbar-icon', 'toolbar-icon-help'],
'aria-pressed' => 'false',
- ),
- ),
- '#wrapper_attributes' => array(
- 'class' => array('tour-toolbar-tab', 'hidden'),
+ ],
+ ],
+ '#wrapper_attributes' => [
+ 'class' => ['tour-toolbar-tab', 'hidden'],
'id' => 'toolbar-tab-tour',
- ),
- '#attached' => array(
- 'library' => array(
+ ],
+ '#attached' => [
+ 'library' => [
'tour/tour',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $items;
}
diff --git a/core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php b/core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
index 1cd42177f92..95264803f74 100644
--- a/core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
+++ b/core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
@@ -37,7 +37,7 @@ class UserTrackerTab extends LocalTaskDefault {
* {@inheritdoc}
*/
public function getRouteParameters(RouteMatchInterface $route_match) {
- return array('user' => $this->currentUser()->Id());
+ return ['user' => $this->currentUser()->Id()];
}
}
diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php
index a927e891c7f..2ac7cef9a0a 100644
--- a/core/modules/tracker/src/Tests/TrackerTest.php
+++ b/core/modules/tracker/src/Tests/TrackerTest.php
@@ -46,16 +46,16 @@ class TrackerTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
- $permissions = array('access comments', 'create page content', 'post comments', 'skip comment approval');
+ $permissions = ['access comments', 'create page content', 'post comments', 'skip comment approval'];
$this->user = $this->drupalCreateUser($permissions);
$this->otherUser = $this->drupalCreateUser($permissions);
$this->addDefaultCommentField('node', 'page');
- user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, array(
+ user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, [
'access content',
'access user profiles',
- ));
+ ]);
$this->drupalPlaceBlock('local_tasks_block', ['id' => 'page_tabs_block']);
$this->drupalPlaceBlock('local_actions_block', ['id' => 'page_actions_block']);
}
@@ -66,14 +66,14 @@ class TrackerTest extends WebTestBase {
function testTrackerAll() {
$this->drupalLogin($this->user);
- $unpublished = $this->drupalCreateNode(array(
+ $unpublished = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'status' => 0,
- ));
- $published = $this->drupalCreateNode(array(
+ ]);
+ $published = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'status' => 1,
- ));
+ ]);
$this->drupalGet('activity');
$this->assertNoText($unpublished->label(), 'Unpublished node does not show up in the tracker listing.');
@@ -132,30 +132,30 @@ class TrackerTest extends WebTestBase {
function testTrackerUser() {
$this->drupalLogin($this->user);
- $unpublished = $this->drupalCreateNode(array(
+ $unpublished = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'uid' => $this->user->id(),
'status' => 0,
- ));
- $my_published = $this->drupalCreateNode(array(
+ ]);
+ $my_published = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'uid' => $this->user->id(),
'status' => 1,
- ));
- $other_published_no_comment = $this->drupalCreateNode(array(
+ ]);
+ $other_published_no_comment = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'uid' => $this->otherUser->id(),
'status' => 1,
- ));
- $other_published_my_comment = $this->drupalCreateNode(array(
+ ]);
+ $other_published_my_comment = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'uid' => $this->otherUser->id(),
'status' => 1,
- ));
- $comment = array(
+ ]);
+ $comment = [
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $this->randomMachineName(20),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $other_published_my_comment->id() . '/comment', $comment, t('Save'));
$this->drupalGet('user/' . $this->user->id() . '/activity');
@@ -197,12 +197,12 @@ class TrackerTest extends WebTestBase {
$this->assertNoLink($unpublished->label());
// Verify that title and tab title have been set correctly.
$this->assertText('Activity', 'The user activity tab has the name "Activity".');
- $this->assertTitle(t('@name | @site', array('@name' => $this->user->getUsername(), '@site' => $this->config('system.site')->get('name'))), 'The user tracker page has the correct page title.');
+ $this->assertTitle(t('@name | @site', ['@name' => $this->user->getUsername(), '@site' => $this->config('system.site')->get('name')]), 'The user tracker page has the correct page title.');
// Verify that unpublished comments are removed from the tracker.
- $admin_user = $this->drupalCreateUser(array('post comments', 'administer comments', 'access user profiles'));
+ $admin_user = $this->drupalCreateUser(['post comments', 'administer comments', 'access user profiles']);
$this->drupalLogin($admin_user);
- $this->drupalPostForm('comment/1/edit', array('status' => CommentInterface::NOT_PUBLISHED), t('Save'));
+ $this->drupalPostForm('comment/1/edit', ['status' => CommentInterface::NOT_PUBLISHED], t('Save'));
$this->drupalGet('user/' . $this->user->id() . '/activity');
$this->assertNoText($other_published_my_comment->label(), 'Unpublished comments are not counted on the tracker listing.');
@@ -227,9 +227,9 @@ class TrackerTest extends WebTestBase {
$this->drupalLogin($this->user);
// Create a page node.
- $edit = array(
+ $edit = [
'title' => $this->randomMachineName(8),
- );
+ ];
$node = $this->drupalCreateNode($edit);
// Verify that the history metadata is present.
@@ -243,10 +243,10 @@ class TrackerTest extends WebTestBase {
// Add a comment to the page, make sure it is created after the node by
// sleeping for one second, to ensure the last comment timestamp is
// different from before.
- $comment = array(
+ $comment = [
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $this->randomMachineName(20),
- );
+ ];
sleep(1);
$this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $comment, t('Save'));
// Reload the node so that comment.module's hook_node_load()
@@ -277,22 +277,22 @@ class TrackerTest extends WebTestBase {
function testTrackerOrderingNewComments() {
$this->drupalLogin($this->user);
- $node_one = $this->drupalCreateNode(array(
+ $node_one = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
- ));
+ ]);
- $node_two = $this->drupalCreateNode(array(
+ $node_two = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
- ));
+ ]);
// Now get otherUser to track these pieces of content.
$this->drupalLogin($this->otherUser);
// Add a comment to the first page.
- $comment = array(
+ $comment = [
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $this->randomMachineName(20),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $node_one->id() . '/comment', $comment, t('Save'));
// If the comment is posted in the same second as the last one then Drupal
@@ -300,10 +300,10 @@ class TrackerTest extends WebTestBase {
sleep(1);
// Add a comment to the second page.
- $comment = array(
+ $comment = [
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $this->randomMachineName(20),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $node_two->id() . '/comment', $comment, t('Save'));
// We should at this point have in our tracker for otherUser:
@@ -320,10 +320,10 @@ class TrackerTest extends WebTestBase {
sleep(1);
// Add a comment to the second page.
- $comment = array(
+ $comment = [
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $this->randomMachineName(20),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $node_one->id() . '/comment', $comment, t('Save'));
// Switch back to the otherUser and assert that the order has swapped.
@@ -344,21 +344,21 @@ class TrackerTest extends WebTestBase {
$this->drupalLogin($this->user);
// Create 3 nodes.
- $edits = array();
- $nodes = array();
+ $edits = [];
+ $nodes = [];
for ($i = 1; $i <= 3; $i++) {
- $edits[$i] = array(
+ $edits[$i] = [
'title' => $this->randomMachineName(),
- );
+ ];
$nodes[$i] = $this->drupalCreateNode($edits[$i]);
}
// Add a comment to the last node as other user.
$this->drupalLogin($this->otherUser);
- $comment = array(
+ $comment = [
'subject[0][value]' => $this->randomMachineName(),
'comment_body[0][value]' => $this->randomMachineName(20),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $nodes[3]->id() . '/comment', $comment, t('Save'));
// Start indexing backwards from node 3.
@@ -378,7 +378,7 @@ class TrackerTest extends WebTestBase {
// Assert that all node titles are displayed.
foreach ($nodes as $i => $node) {
- $this->assertText($node->label(), format_string('Node @i is displayed on the tracker listing pages.', array('@i' => $i)));
+ $this->assertText($node->label(), format_string('Node @i is displayed on the tracker listing pages.', ['@i' => $i]));
}
// Fetch the site-wide tracker.
@@ -386,7 +386,7 @@ class TrackerTest extends WebTestBase {
// Assert that all node titles are displayed.
foreach ($nodes as $i => $node) {
- $this->assertText($node->label(), format_string('Node @i is displayed on the tracker listing pages.', array('@i' => $i)));
+ $this->assertText($node->label(), format_string('Node @i is displayed on the tracker listing pages.', ['@i' => $i]));
}
}
@@ -394,24 +394,24 @@ class TrackerTest extends WebTestBase {
* Tests that publish/unpublish works at admin/content/node.
*/
function testTrackerAdminUnpublish() {
- \Drupal::service('module_installer')->install(array('views'));
+ \Drupal::service('module_installer')->install(['views']);
\Drupal::service('router.builder')->rebuild();
- $admin_user = $this->drupalCreateUser(array('access content overview', 'administer nodes', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content overview', 'administer nodes', 'bypass node access']);
$this->drupalLogin($admin_user);
- $node = $this->drupalCreateNode(array(
+ $node = $this->drupalCreateNode([
'title' => $this->randomMachineName(),
- ));
+ ]);
// Assert that the node is displayed.
$this->drupalGet('activity');
$this->assertText($node->label(), 'A node is displayed on the tracker listing pages.');
// Unpublish the node and ensure that it's no longer displayed.
- $edit = array(
+ $edit = [
'action' => 'node_unpublish_action',
'node_bulk_form[0]' => $node->id(),
- );
+ ];
$this->drupalPostForm('admin/content', $edit, t('Apply to selected items'));
$this->drupalGet('activity');
diff --git a/core/modules/tracker/src/Tests/Views/TrackerTestBase.php b/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
index 7b2f9462ef9..53c21f906c1 100644
--- a/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
+++ b/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
@@ -20,7 +20,7 @@ abstract class TrackerTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('comment', 'tracker', 'tracker_test_views');
+ public static $modules = ['comment', 'tracker', 'tracker_test_views'];
/**
* The node used for testing.
@@ -39,30 +39,30 @@ abstract class TrackerTestBase extends ViewTestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('tracker_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Add a comment field.
$this->addDefaultCommentField('node', 'page');
- $permissions = array('access comments', 'create page content', 'post comments', 'skip comment approval');
+ $permissions = ['access comments', 'create page content', 'post comments', 'skip comment approval'];
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account);
- $this->node = $this->drupalCreateNode(array(
+ $this->node = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'uid' => $account->id(),
'status' => 1,
- ));
+ ]);
- $this->comment = Comment::create(array(
+ $this->comment = Comment::create([
'entity_id' => $this->node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'subject' => $this->randomMachineName(),
'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomMachineName(20),
- ));
+ ]);
}
diff --git a/core/modules/tracker/src/Tests/Views/TrackerUserUidTest.php b/core/modules/tracker/src/Tests/Views/TrackerUserUidTest.php
index 68b77777aa7..54732a02e8f 100644
--- a/core/modules/tracker/src/Tests/Views/TrackerUserUidTest.php
+++ b/core/modules/tracker/src/Tests/Views/TrackerUserUidTest.php
@@ -16,29 +16,29 @@ class TrackerUserUidTest extends TrackerTestBase {
*
* @var array
*/
- public static $testViews = array('test_tracker_user_uid');
+ public static $testViews = ['test_tracker_user_uid'];
/**
* Tests the user uid filter and argument.
*/
public function testUserUid() {
- $map = array(
+ $map = [
'nid' => 'nid',
'title' => 'title',
- );
+ ];
- $expected = array(
- array(
+ $expected = [
+ [
'nid' => $this->node->id(),
'title' => $this->node->label(),
- )
- );
+ ]
+ ];
$view = Views::getView('test_tracker_user_uid');
$this->executeView($view);
// We should have no results as the filter is set for uid 0.
- $this->assertIdenticalResultSet($view, array(), $map);
+ $this->assertIdenticalResultSet($view, [], $map);
$view->destroy();
// Change the filter value to our user.
@@ -55,13 +55,13 @@ class TrackerUserUidTest extends TrackerTestBase {
// Test the incorrect argument UID.
$view->initHandlers();
- $this->executeView($view, array(rand()));
- $this->assertIdenticalResultSet($view, array(), $map);
+ $this->executeView($view, [rand()]);
+ $this->assertIdenticalResultSet($view, [], $map);
$view->destroy();
// Test the correct argument UID.
$view->initHandlers();
- $this->executeView($view, array($this->node->getOwnerId()));
+ $this->executeView($view, [$this->node->getOwnerId()]);
$this->assertIdenticalResultSet($view, $expected, $map);
}
diff --git a/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php b/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php
index 1d33a23de32..ae9a6e0ebb9 100644
--- a/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php
+++ b/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php
@@ -21,12 +21,12 @@ class TrackerNodeAccessTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment', 'tracker', 'node_access_test');
+ public static $modules = ['node', 'comment', 'tracker', 'node_access_test'];
protected function setUp() {
parent::setUp();
node_access_rebuild();
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
node_access_test_add_field(NodeType::load('page'));
$this->addDefaultCommentField('node', 'page', 'comment', CommentItemInterface::OPEN);
\Drupal::state()->set('node_access_test.private', TRUE);
@@ -37,22 +37,22 @@ class TrackerNodeAccessTest extends BrowserTestBase {
*/
function testTrackerNodeAccess() {
// Create user with node test view permission.
- $access_user = $this->drupalCreateUser(array('node test view', 'access user profiles'));
+ $access_user = $this->drupalCreateUser(['node test view', 'access user profiles']);
// Create user without node test view permission.
- $no_access_user = $this->drupalCreateUser(array('access user profiles'));
+ $no_access_user = $this->drupalCreateUser(['access user profiles']);
$this->drupalLogin($access_user);
// Create some nodes.
- $private_node = $this->drupalCreateNode(array(
+ $private_node = $this->drupalCreateNode([
'title' => t('Private node test'),
'private' => TRUE,
- ));
- $public_node = $this->drupalCreateNode(array(
+ ]);
+ $public_node = $this->drupalCreateNode([
'title' => t('Public node test'),
'private' => FALSE,
- ));
+ ]);
// User with access should see both nodes created.
$this->drupalGet('activity');
diff --git a/core/modules/tracker/tracker.install b/core/modules/tracker/tracker.install
index 5f3e5a0fd1f..bc9ebc57c69 100644
--- a/core/modules/tracker/tracker.install
+++ b/core/modules/tracker/tracker.install
@@ -29,90 +29,90 @@ function tracker_install() {
* Implements hook_schema().
*/
function tracker_schema() {
- $schema['tracker_node'] = array(
+ $schema['tracker_node'] = [
'description' => 'Tracks when nodes were last changed or commented on.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'published' => array(
+ ],
+ 'published' => [
'description' => 'Boolean indicating whether the node is published.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
- ),
- 'changed' => array(
+ ],
+ 'changed' => [
'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'indexes' => array(
- 'tracker' => array('published', 'changed'),
- ),
- 'primary key' => array('nid'),
- 'foreign keys' => array(
- 'tracked_node' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'tracker' => ['published', 'changed'],
+ ],
+ 'primary key' => ['nid'],
+ 'foreign keys' => [
+ 'tracked_node' => [
'table' => 'node',
- 'columns' => array('nid' => 'nid'),
- ),
- ),
- );
+ 'columns' => ['nid' => 'nid'],
+ ],
+ ],
+ ];
- $schema['tracker_user'] = array(
+ $schema['tracker_user'] = [
'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'uid' => array(
+ ],
+ 'uid' => [
'description' => 'The {users}.uid of the node author or commenter.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'published' => array(
+ ],
+ 'published' => [
'description' => 'Boolean indicating whether the node is published.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
- ),
- 'changed' => array(
+ ],
+ 'changed' => [
'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'indexes' => array(
- 'tracker' => array('uid', 'published', 'changed'),
- ),
- 'primary key' => array('nid', 'uid'),
- 'foreign keys' => array(
- 'tracked_node' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'tracker' => ['uid', 'published', 'changed'],
+ ],
+ 'primary key' => ['nid', 'uid'],
+ 'foreign keys' => [
+ 'tracked_node' => [
'table' => 'node',
- 'columns' => array('nid' => 'nid'),
- ),
- 'tracked_user' => array(
+ 'columns' => ['nid' => 'nid'],
+ ],
+ 'tracked_user' => [
'table' => 'users',
- 'columns' => array('uid' => 'uid'),
- ),
- ),
- );
+ 'columns' => ['uid' => 'uid'],
+ ],
+ ],
+ ];
return $schema;
}
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index 1b2f648df5e..dbde704a5a1 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -19,11 +19,11 @@ function tracker_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.tracker':
$output = '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Activity Tracker module displays the most recently added and updated content on your site, and allows you to follow new content created by each user. This module has no configuration options. For more information, see the <a href=":tracker">online documentation for the Activity Tracker module</a>.', array(':tracker' => 'https://www.drupal.org/documentation/modules/tracker')) . '</p>';
+ $output .= '<p>' . t('The Activity Tracker module displays the most recently added and updated content on your site, and allows you to follow new content created by each user. This module has no configuration options. For more information, see the <a href=":tracker">online documentation for the Activity Tracker module</a>.', [':tracker' => 'https://www.drupal.org/documentation/modules/tracker']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Tracking new and updated site content') . '</dt>';
- $output .= '<dd>' . t('The <a href=":recent">Recent content</a> page shows new and updated content in reverse chronological order, listing the content type, title, author\'s name, number of comments, and time of last update. Content is considered updated when changes occur in the text, or when new comments are added. The <em>My recent content</em> tab limits the list to the currently logged-in user.', array(':recent' => \Drupal::url('tracker.page'))) . '</dd>';
+ $output .= '<dd>' . t('The <a href=":recent">Recent content</a> page shows new and updated content in reverse chronological order, listing the content type, title, author\'s name, number of comments, and time of last update. Content is considered updated when changes occur in the text, or when new comments are added. The <em>My recent content</em> tab limits the list to the currently logged-in user.', [':recent' => \Drupal::url('tracker.page')]) . '</dd>';
$output .= '<dt>' . t('Tracking user-specific content') . '</dt>';
$output .= '<dd>' . t("To follow a specific user's new and updated content, select the <em>Activity</em> tab from the user's profile page.") . '</dd>';
$output .= '</dl>';
@@ -70,21 +70,21 @@ function tracker_cron() {
// Insert the node-level data.
db_insert('tracker_node')
- ->fields(array(
+ ->fields([
'nid' => $nid,
'published' => $node->isPublished(),
'changed' => $changed,
- ))
+ ])
->execute();
// Insert the user-level data for the node's author.
db_insert('tracker_user')
- ->fields(array(
+ ->fields([
'nid' => $nid,
'published' => $node->isPublished(),
'changed' => $changed,
'uid' => $node->getOwnerId(),
- ))
+ ])
->execute();
// Insert the user-level data for the commenters (except if a commenter
@@ -103,12 +103,12 @@ function tracker_cron() {
if ($result) {
$query = db_insert('tracker_user');
foreach ($result as $row) {
- $query->fields(array(
+ $query->fields([
'uid' => $row['uid'],
'nid' => $nid,
'published' => CommentInterface::PUBLISHED,
'changed' => $changed,
- ));
+ ]);
}
$query->execute();
}
@@ -123,7 +123,7 @@ function tracker_cron() {
// Prepare a starting point for the next run.
$state->set('tracker.index_nid', $last_nid - 1);
- \Drupal::logger('tracker')->notice('Indexed %count content items for tracking.', array('%count' => $count));
+ \Drupal::logger('tracker')->notice('Indexed %count content items for tracking.', ['%count' => $count]);
}
else {
// If all nodes have been indexed, set to zero to skip future cron runs.
@@ -242,7 +242,7 @@ function tracker_comment_delete(CommentInterface $comment) {
function _tracker_add($nid, $uid, $changed) {
// @todo This should be actually filtering on the desired language and just
// fall back to the default language.
- $node = db_query('SELECT nid, status, uid, changed FROM {node_field_data} WHERE nid = :nid AND default_langcode = 1 ORDER BY changed DESC, status DESC', array(':nid' => $nid))->fetchObject();
+ $node = db_query('SELECT nid, status, uid, changed FROM {node_field_data} WHERE nid = :nid AND default_langcode = 1 ORDER BY changed DESC, status DESC', [':nid' => $nid])->fetchObject();
// Adding a comment can only increase the changed timestamp, so our
// calculation here is simple.
@@ -251,30 +251,30 @@ function _tracker_add($nid, $uid, $changed) {
// Update the node-level data.
db_merge('tracker_node')
->key('nid', $nid)
- ->fields(array(
+ ->fields([
'changed' => $changed,
'published' => $node->status,
- ))
+ ])
->execute();
// Create or update the user-level data, first for the user posting.
db_merge('tracker_user')
- ->keys(array(
+ ->keys([
'nid' => $nid,
'uid' => $uid,
- ))
- ->fields(array(
+ ])
+ ->fields([
'changed' => $changed,
'published' => $node->status,
- ))
+ ])
->execute();
// Update the times for all the other users tracking the post.
db_update('tracker_user')
->condition('nid', $nid)
- ->fields(array(
+ ->fields([
'changed' => $changed,
'published' => $node->status,
- ))
+ ])
->execute();
}
@@ -293,7 +293,7 @@ function _tracker_add($nid, $uid, $changed) {
*/
function _tracker_calculate_changed($node) {
$changed = $node->getChangedTime();
- $latest_comment = \Drupal::service('comment.statistics')->read(array($node), 'node', FALSE);
+ $latest_comment = \Drupal::service('comment.statistics')->read([$node], 'node', FALSE);
if ($latest_comment && $latest_comment->last_comment_timestamp > $changed) {
$changed = $latest_comment->last_comment_timestamp;
}
@@ -343,7 +343,7 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
// and the node itself.
// We only need to do this if the removed item has a timestamp that equals
// or exceeds the listed changed timestamp for the node.
- $tracker_node = db_query('SELECT nid, changed FROM {tracker_node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
+ $tracker_node = db_query('SELECT nid, changed FROM {tracker_node} WHERE nid = :nid', [':nid' => $nid])->fetchObject();
if ($tracker_node && $changed >= $tracker_node->changed) {
// If we're here, the item being removed is *possibly* the item that
// established the node's changed timestamp.
@@ -354,17 +354,17 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
// And then we push the out the new changed timestamp to our denormalized
// tables.
db_update('tracker_node')
- ->fields(array(
+ ->fields([
'changed' => $changed,
'published' => $node->isPublished(),
- ))
+ ])
->condition('nid', $nid)
->execute();
db_update('tracker_node')
- ->fields(array(
+ ->fields([
'changed' => $changed,
'published' => $node->isPublished(),
- ))
+ ])
->condition('nid', $nid)
->execute();
}
diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc
index e3082acfcca..76a775f45b1 100644
--- a/core/modules/tracker/tracker.pages.inc
+++ b/core/modules/tracker/tracker.pages.inc
@@ -30,7 +30,7 @@ function tracker_page($account = NULL) {
->condition('t.uid', $account->id());
}
else {
- $query = db_select('tracker_node', 't', array('target' => 'replica'))
+ $query = db_select('tracker_node', 't', ['target' => 'replica'])
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->addMetaData('base_table', 'tracker_node');
}
@@ -39,7 +39,7 @@ function tracker_page($account = NULL) {
// while keeping the correct order.
$tracker_data = $query
->addTag('node_access')
- ->fields('t', array('nid', 'changed'))
+ ->fields('t', ['nid', 'changed'])
->condition('t.published', 1)
->orderBy('t.changed', 'DESC')
->limit(25)
@@ -86,34 +86,34 @@ function tracker_page($account = NULL) {
$comments = $node->comment_count;
}
- $row = array(
+ $row = [
'type' => node_get_type_label($node),
- 'title' => array(
- 'data' => array(
+ 'title' => [
+ 'data' => [
'#type' => 'link',
'#url' => $node->urlInfo(),
'#title' => $node->getTitle(),
- ),
+ ],
'data-history-node-id' => $node->id(),
'data-history-node-timestamp' => $node->getChangedTime(),
- ),
- 'author' => array(
- 'data' => array(
+ ],
+ 'author' => [
+ 'data' => [
'#theme' => 'username',
'#account' => $node->getOwner(),
- ),
- ),
- 'comments' => array(
- 'class' => array('comments'),
+ ],
+ ],
+ 'comments' => [
+ 'class' => ['comments'],
'data' => $comments,
'data-history-node-last-comment-timestamp' => $node->last_comment_timestamp,
- ),
- 'last updated' => array(
- 'data' => t('@time ago', array(
+ ],
+ 'last updated' => [
+ 'data' => t('@time ago', [
'@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($node->last_activity),
- )),
- ),
- );
+ ]),
+ ],
+ ];
$rows[] = $row;
@@ -128,16 +128,16 @@ function tracker_page($account = NULL) {
// Add the list cache tag for nodes.
$cache_tags = Cache::mergeTags($cache_tags, \Drupal::entityManager()->getDefinition('node')->getListCacheTags());
- $page['tracker'] = array(
+ $page['tracker'] = [
'#rows' => $rows,
- '#header' => array(t('Type'), t('Title'), t('Author'), t('Comments'), t('Last updated')),
+ '#header' => [t('Type'), t('Title'), t('Author'), t('Comments'), t('Last updated')],
'#type' => 'table',
'#empty' => t('No content available.'),
- );
- $page['pager'] = array(
+ ];
+ $page['pager'] = [
'#type' => 'pager',
'#weight' => 10,
- );
+ ];
$page['#sorted'] = TRUE;
$page['#cache']['tags'] = $cache_tags;
$page['#cache']['contexts'][] = 'user.node_grants:view';
diff --git a/core/modules/tracker/tracker.views.inc b/core/modules/tracker/tracker.views.inc
index b7e4b9547d0..54402879dd5 100644
--- a/core/modules/tracker/tracker.views.inc
+++ b/core/modules/tracker/tracker.views.inc
@@ -9,146 +9,146 @@
* Implements hook_views_data().
*/
function tracker_views_data() {
- $data = array();
+ $data = [];
$data['tracker_node']['table']['group'] = t('Tracker');
- $data['tracker_node']['table']['join'] = array(
- 'node_field_data' => array(
+ $data['tracker_node']['table']['join'] = [
+ 'node_field_data' => [
'type' => 'INNER',
'left_field' => 'nid',
'field' => 'nid',
- ),
- );
- $data['tracker_node']['nid'] = array(
+ ],
+ ];
+ $data['tracker_node']['nid'] = [
'title' => t('Nid'),
'help' => t('The node ID of the node.'),
- 'field' => array(
+ 'field' => [
'id' => 'node',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'node_nid',
'name field' => 'title',
'numeric' => TRUE,
'validate type' => 'nid',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['tracker_node']['published'] = array(
+ ],
+ ];
+ $data['tracker_node']['published'] = [
'title' => t('Published'),
'help' => t('Whether or not the node is published.'),
- 'field' => array(
+ 'field' => [
'id' => 'boolean',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'boolean',
'label' => t('Published'),
'type' => 'yes-no',
'accept null' => TRUE,
'use_equal' => TRUE,
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['tracker_node']['changed'] = array(
+ ],
+ ];
+ $data['tracker_node']['changed'] = [
'title' => t('Updated date'),
'help' => t('The date the node was last updated.'),
- 'field' => array(
+ 'field' => [
'id' => 'date',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'date',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- );
+ ],
+ ];
$data['tracker_user']['table']['group'] = t('Tracker - User');
- $data['tracker_user']['table']['join'] = array(
- 'node_field_data' => array(
+ $data['tracker_user']['table']['join'] = [
+ 'node_field_data' => [
'type' => 'INNER',
'left_field' => 'nid',
'field' => 'nid',
- ),
- 'user_field_data' => array(
+ ],
+ 'user_field_data' => [
'type' => 'INNER',
'left_field' => 'uid',
'field' => 'uid',
- ),
- );
- $data['tracker_user']['nid'] = array(
+ ],
+ ];
+ $data['tracker_user']['nid'] = [
'title' => t('Nid'),
'help' => t('The node ID of the node a user created or commented on. You must use an argument or filter on UID or you will get misleading results using this field.'),
- 'field' => array(
+ 'field' => [
'id' => 'node',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'node_nid',
'name field' => 'title',
'numeric' => TRUE,
'validate type' => 'nid',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['tracker_user']['uid'] = array(
+ ],
+ ];
+ $data['tracker_user']['uid'] = [
'title' => t('Uid'),
'help' => t('The user ID of a user who touched the node (either created or commented on it).'),
- 'field' => array(
+ 'field' => [
'id' => 'user_name',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'user_uid',
'name field' => 'name',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'title' => t('Name'),
'id' => 'user_name',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['tracker_user']['published'] = array(
+ ],
+ ];
+ $data['tracker_user']['published'] = [
'title' => t('Published'),
'help' => t('Whether or not the node is published. You must use an argument or filter on UID or you will get misleading results using this field.'),
- 'field' => array(
+ 'field' => [
'id' => 'boolean',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'boolean',
'label' => t('Published'),
'type' => 'yes-no',
'accept null' => TRUE,
'use_equal' => TRUE,
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['tracker_user']['changed'] = array(
+ ],
+ ];
+ $data['tracker_user']['changed'] = [
'title' => t('Updated date'),
'help' => t('The date the node was last updated or commented on. You must use an argument or filter on UID or you will get misleading results using this field.'),
- 'field' => array(
+ 'field' => [
'id' => 'date',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'date',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- );
+ ],
+ ];
return $data;
}
@@ -158,22 +158,22 @@ function tracker_views_data() {
*/
function tracker_views_data_alter(&$data) {
// Provide additional uid_touch handlers which are handled by tracker
- $data['node_field_data']['uid_touch_tracker'] = array(
+ $data['node_field_data']['uid_touch_tracker'] = [
'group' => t('Tracker - User'),
'title' => t('User posted or commented'),
'help' => t('Display nodes only if a user posted the node or commented on the node.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'uid',
'name table' => 'users_field_data',
'name field' => 'name',
'id' => 'tracker_user_uid',
'no group by' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'field' => 'uid',
'name table' => 'users_field_data',
'name field' => 'name',
'id' => 'tracker_user_uid'
- ),
- );
+ ],
+ ];
}
diff --git a/core/modules/update/src/Controller/UpdateController.php b/core/modules/update/src/Controller/UpdateController.php
index cdd63b83af3..30b25c20642 100644
--- a/core/modules/update/src/Controller/UpdateController.php
+++ b/core/modules/update/src/Controller/UpdateController.php
@@ -44,9 +44,9 @@ class UpdateController extends ControllerBase {
* A build array with the update status of projects.
*/
public function updateStatus() {
- $build = array(
+ $build = [
'#theme' => 'update_report'
- );
+ ];
if ($available = update_get_available(TRUE)) {
$this->moduleHandler()->loadInclude('update', 'compare.inc');
$build['#data'] = update_calculate_project_data($available);
@@ -59,15 +59,15 @@ class UpdateController extends ControllerBase {
*/
public function updateStatusManually() {
$this->updateManager->refreshUpdateData();
- $batch = array(
- 'operations' => array(
- array(array($this->updateManager, 'fetchDataBatch'), array()),
- ),
+ $batch = [
+ 'operations' => [
+ [[$this->updateManager, 'fetchDataBatch'], []],
+ ],
'finished' => 'update_fetch_data_finished',
'title' => t('Checking available update data'),
'progress_message' => t('Trying to check available update data ...'),
'error_message' => t('Error checking available update data.'),
- );
+ ];
batch_set($batch);
return batch_process('admin/reports/updates');
}
diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php
index 3bc2c78a7c8..b14118286a9 100644
--- a/core/modules/update/src/Form/UpdateManagerInstall.php
+++ b/core/modules/update/src/Form/UpdateManagerInstall.php
@@ -79,41 +79,41 @@ class UpdateManagerInstall extends FormBase {
return $form;
}
- $form['help_text'] = array(
+ $form['help_text'] = [
'#prefix' => '<p>',
- '#markup' => $this->t('You can find <a href=":module_url">modules</a> and <a href=":theme_url">themes</a> on <a href=":drupal_org_url">drupal.org</a>. The following file extensions are supported: %extensions.', array(
+ '#markup' => $this->t('You can find <a href=":module_url">modules</a> and <a href=":theme_url">themes</a> on <a href=":drupal_org_url">drupal.org</a>. The following file extensions are supported: %extensions.', [
':module_url' => 'https://www.drupal.org/project/modules',
':theme_url' => 'https://www.drupal.org/project/themes',
':drupal_org_url' => 'https://www.drupal.org',
'%extensions' => archiver_get_extensions(),
- )),
+ ]),
'#suffix' => '</p>',
- );
+ ];
- $form['project_url'] = array(
+ $form['project_url'] = [
'#type' => 'url',
'#title' => $this->t('Install from a URL'),
- '#description' => $this->t('For example: %url', array('%url' => 'http://ftp.drupal.org/files/projects/name.tar.gz')),
- );
+ '#description' => $this->t('For example: %url', ['%url' => 'http://ftp.drupal.org/files/projects/name.tar.gz']),
+ ];
- $form['information'] = array(
+ $form['information'] = [
'#prefix' => '<strong>',
'#markup' => $this->t('Or'),
'#suffix' => '</strong>',
- );
+ ];
- $form['project_upload'] = array(
+ $form['project_upload'] = [
'#type' => 'file',
'#title' => $this->t('Upload a module or theme archive to install'),
- '#description' => $this->t('For example: %filename from your local computer', array('%filename' => 'name.tar.gz')),
- );
+ '#description' => $this->t('For example: %filename from your local computer', ['%filename' => 'name.tar.gz']),
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => $this->t('Install'),
- );
+ ];
return $form;
}
@@ -136,12 +136,12 @@ class UpdateManagerInstall extends FormBase {
if ($form_state->getValue('project_url')) {
$local_cache = update_manager_file_get($form_state->getValue('project_url'));
if (!$local_cache) {
- drupal_set_message($this->t('Unable to retrieve Drupal project from %url.', array('%url' => $form_state->getValue('project_url'))), 'error');
+ drupal_set_message($this->t('Unable to retrieve Drupal project from %url.', ['%url' => $form_state->getValue('project_url')]), 'error');
return;
}
}
elseif ($_FILES['files']['name']['project_upload']) {
- $validators = array('file_validate_extensions' => array(archiver_get_extensions()));
+ $validators = ['file_validate_extensions' => [archiver_get_extensions()]];
if (!($finfo = file_save_upload('project_upload', $validators, NULL, 0, FILE_EXISTS_REPLACE))) {
// Failed to upload the file. file_save_upload() calls
// drupal_set_message() on failure.
@@ -170,7 +170,7 @@ class UpdateManagerInstall extends FormBase {
// MODULE/) and others list an actual file (i.e., MODULE/README.TXT).
$project = strtok($files[0], '/\\');
- $archive_errors = $this->moduleHandler->invokeAll('verify_update_archive', array($project, $local_cache, $directory));
+ $archive_errors = $this->moduleHandler->invokeAll('verify_update_archive', [$project, $local_cache, $directory]);
if (!empty($archive_errors)) {
drupal_set_message(array_shift($archive_errors), 'error');
// @todo: Fix me in D8: We need a way to set multiple errors on the same
@@ -204,20 +204,20 @@ class UpdateManagerInstall extends FormBase {
}
if (!$project_title) {
- drupal_set_message($this->t('Unable to determine %project name.', array('%project' => $project)), 'error');
+ drupal_set_message($this->t('Unable to determine %project name.', ['%project' => $project]), 'error');
}
if ($updater->isInstalled()) {
- drupal_set_message($this->t('%project is already installed.', array('%project' => $project_title)), 'error');
+ drupal_set_message($this->t('%project is already installed.', ['%project' => $project_title]), 'error');
return;
}
$project_real_location = drupal_realpath($project_location);
- $arguments = array(
+ $arguments = [
'project' => $project,
'updater_name' => get_class($updater),
'local_url' => $project_real_location,
- );
+ ];
// This process is inherently difficult to test therefore use a state flag.
$test_authorize = FALSE;
@@ -232,7 +232,7 @@ class UpdateManagerInstall extends FormBase {
if (fileowner($project_real_location) == fileowner($this->sitePath) && !$test_authorize) {
$this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
$filetransfer = new Local($this->root);
- $response = call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));
+ $response = call_user_func_array('update_authorize_run_install', array_merge([$filetransfer], $arguments));
if ($response instanceof Response) {
$form_state->setResponse($response);
}
diff --git a/core/modules/update/src/Form/UpdateManagerUpdate.php b/core/modules/update/src/Form/UpdateManagerUpdate.php
index 44b7f62695e..db497c276bb 100644
--- a/core/modules/update/src/Form/UpdateManagerUpdate.php
+++ b/core/modules/update/src/Form/UpdateManagerUpdate.php
@@ -64,13 +64,13 @@ class UpdateManagerUpdate extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$this->moduleHandler->loadInclude('update', 'inc', 'update.manager');
- $last_markup = array(
+ $last_markup = [
'#theme' => 'update_last_check',
'#last' => $this->state->get('update.last_check') ?: 0,
- );
- $form['last_check'] = array(
+ ];
+ $form['last_check'] = [
'#markup' => drupal_render($last_markup),
- );
+ ];
if (!_update_manager_check_backends($form, 'update')) {
return $form;
@@ -78,9 +78,9 @@ class UpdateManagerUpdate extends FormBase {
$available = update_get_available(TRUE);
if (empty($available)) {
- $form['message'] = array(
+ $form['message'] = [
'#markup' => $this->t('There was a problem getting update information. Try again later.'),
- );
+ ];
return $form;
}
@@ -91,11 +91,11 @@ class UpdateManagerUpdate extends FormBase {
// manual updates, such as core). Then, each subarray is an array of
// projects of that type, indexed by project short name, and containing an
// array of data for cells in that project's row in the appropriate table.
- $projects = array();
+ $projects = [];
// This stores the actual download link we're going to update from for each
// project in the form, regardless of if it's enabled or disabled.
- $form['project_downloads'] = array('#tree' => TRUE);
+ $form['project_downloads'] = ['#tree' => TRUE];
$this->moduleHandler->loadInclude('update', 'inc', 'update.compare');
$project_data = update_calculate_project_data($available);
foreach ($project_data as $name => $project) {
@@ -134,25 +134,25 @@ class UpdateManagerUpdate extends FormBase {
$recommended_version .= '<div title="{{ major_update_warning_title }}" class="update-major-version-warning">{{ major_update_warning_text }}</div>';
}
- $recommended_version = array(
+ $recommended_version = [
'#type' => 'inline_template',
'#template' => $recommended_version,
- '#context' => array(
+ '#context' => [
'release_version' => $recommended_release['version'],
'release_link' => $recommended_release['release_link'],
- 'project_title' => $this->t('Release notes for @project_title', array('@project_title' => $project['title'])),
+ 'project_title' => $this->t('Release notes for @project_title', ['@project_title' => $project['title']]),
'major_update_warning_title' => $this->t('Major upgrade warning'),
'major_update_warning_text' => $this->t('This update is a major version update which means that it may not be backwards compatible with your currently running version. It is recommended that you read the release notes and proceed at your own risk.'),
'release_notes' => $this->t('Release notes'),
- ),
- );
+ ],
+ ];
// Create an entry for this project.
- $entry = array(
+ $entry = [
'title' => $project_name,
'installed_version' => $project['existing_version'],
- 'recommended_version' => array('data' => $recommended_version),
- );
+ 'recommended_version' => ['data' => $recommended_version],
+ ];
switch ($project['status']) {
case UPDATE_NOT_SECURE:
@@ -181,11 +181,11 @@ class UpdateManagerUpdate extends FormBase {
}
// Use the project title for the tableselect checkboxes.
- $entry['title'] = array('data' => array(
+ $entry['title'] = ['data' => [
'#title' => $entry['title'],
'#markup' => $entry['title'],
- ));
- $entry['#attributes'] = array('class' => array('update-' . $type));
+ ]];
+ $entry['#attributes'] = ['class' => ['update-' . $type]];
// Drupal core needs to be upgraded manually.
$needs_manual = $project['project_type'] == 'core';
@@ -198,15 +198,15 @@ class UpdateManagerUpdate extends FormBase {
unset($entry['#weight']);
$attributes = $entry['#attributes'];
unset($entry['#attributes']);
- $entry = array(
+ $entry = [
'data' => $entry,
- ) + $attributes;
+ ] + $attributes;
}
else {
- $form['project_downloads'][$name] = array(
+ $form['project_downloads'][$name] = [
'#type' => 'value',
'#value' => $recommended_release['download_link'],
- );
+ ];
}
// Based on what kind of project this is, save the entry into the
@@ -230,62 +230,62 @@ class UpdateManagerUpdate extends FormBase {
}
if (empty($projects)) {
- $form['message'] = array(
+ $form['message'] = [
'#markup' => $this->t('All of your projects are up to date.'),
- );
+ ];
return $form;
}
- $headers = array(
- 'title' => array(
+ $headers = [
+ 'title' => [
'data' => $this->t('Name'),
- 'class' => array('update-project-name'),
- ),
+ 'class' => ['update-project-name'],
+ ],
'installed_version' => $this->t('Installed version'),
'recommended_version' => $this->t('Recommended version'),
- );
+ ];
if (!empty($projects['enabled'])) {
- $form['projects'] = array(
+ $form['projects'] = [
'#type' => 'tableselect',
'#header' => $headers,
'#options' => $projects['enabled'],
- );
+ ];
if (!empty($projects['disabled'])) {
$form['projects']['#prefix'] = '<h2>' . $this->t('Enabled') . '</h2>';
}
}
if (!empty($projects['disabled'])) {
- $form['disabled_projects'] = array(
+ $form['disabled_projects'] = [
'#type' => 'tableselect',
'#header' => $headers,
'#options' => $projects['disabled'],
'#weight' => 1,
'#prefix' => '<h2>' . $this->t('Disabled') . '</h2>',
- );
+ ];
}
// If either table has been printed yet, we need a submit button and to
// validate the checkboxes.
if (!empty($projects['enabled']) || !empty($projects['disabled'])) {
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Download these updates'),
- );
+ ];
}
if (!empty($projects['manual'])) {
$prefix = '<h2>' . $this->t('Manual updates required') . '</h2>';
$prefix .= '<p>' . $this->t('Updates of Drupal core are not supported at this time.') . '</p>';
- $form['manual_updates'] = array(
+ $form['manual_updates'] = [
'#type' => 'table',
'#header' => $headers,
'#rows' => $projects['manual'],
'#prefix' => $prefix,
'#weight' => 120,
- );
+ ];
}
return $form;
@@ -311,29 +311,29 @@ class UpdateManagerUpdate extends FormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->moduleHandler->loadInclude('update', 'inc', 'update.manager');
- $projects = array();
- foreach (array('projects', 'disabled_projects') as $type) {
+ $projects = [];
+ foreach (['projects', 'disabled_projects'] as $type) {
if (!$form_state->isValueEmpty($type)) {
$projects = array_merge($projects, array_keys(array_filter($form_state->getValue($type))));
}
}
- $operations = array();
+ $operations = [];
foreach ($projects as $project) {
- $operations[] = array(
+ $operations[] = [
'update_manager_batch_project_get',
- array(
+ [
$project,
- $form_state->getValue(array('project_downloads', $project)),
- ),
- );
+ $form_state->getValue(['project_downloads', $project]),
+ ],
+ ];
}
- $batch = array(
+ $batch = [
'title' => $this->t('Downloading updates'),
'init_message' => $this->t('Preparing to download selected updates'),
'operations' => $operations,
'finished' => 'update_manager_download_batch_finished',
'file' => drupal_get_path('module', 'update') . '/update.manager.inc',
- );
+ ];
batch_set($batch);
}
diff --git a/core/modules/update/src/Form/UpdateReady.php b/core/modules/update/src/Form/UpdateReady.php
index c8f64a3ee3c..ef9a2f17122 100644
--- a/core/modules/update/src/Form/UpdateReady.php
+++ b/core/modules/update/src/Form/UpdateReady.php
@@ -91,23 +91,23 @@ class UpdateReady extends FormBase {
return $form;
}
- $form['backup'] = array(
+ $form['backup'] = [
'#prefix' => '<strong>',
- '#markup' => $this->t('Back up your database and site before you continue. <a href=":backup_url">Learn how</a>.', array(':backup_url' => 'https://www.drupal.org/node/22281')),
+ '#markup' => $this->t('Back up your database and site before you continue. <a href=":backup_url">Learn how</a>.', [':backup_url' => 'https://www.drupal.org/node/22281']),
'#suffix' => '</strong>',
- );
+ ];
- $form['maintenance_mode'] = array(
+ $form['maintenance_mode'] = [
'#title' => $this->t('Perform updates with site in maintenance mode (strongly recommended)'),
'#type' => 'checkbox',
'#default_value' => TRUE,
- );
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Continue'),
- );
+ ];
return $form;
}
@@ -126,7 +126,7 @@ class UpdateReady extends FormBase {
// Make sure the Updater registry is loaded.
drupal_get_updaters();
- $updates = array();
+ $updates = [];
$directory = _update_manager_extract_directory();
$projects = $_SESSION['update_manager_update_projects'];
@@ -137,11 +137,11 @@ class UpdateReady extends FormBase {
$project_location = $directory . '/' . $project;
$updater = Updater::factory($project_location, $this->root);
$project_real_location = drupal_realpath($project_location);
- $updates[] = array(
+ $updates[] = [
'project' => $project,
'updater_name' => get_class($updater),
'local_url' => $project_real_location,
- );
+ ];
}
// If the owner of the last directory we extracted is the same as the
@@ -164,7 +164,7 @@ class UpdateReady extends FormBase {
// The page title must be passed here to ensure it is initially used
// when authorize.php loads for the first time with the FTP/SSH
// credentials form.
- system_authorized_init('update_authorize_run_update', __DIR__ . '/../../update.authorize.inc', array($updates), $this->t('Update manager'));
+ system_authorized_init('update_authorize_run_update', __DIR__ . '/../../update.authorize.inc', [$updates], $this->t('Update manager'));
$form_state->setRedirectUrl(system_authorized_get_url());
}
}
diff --git a/core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php b/core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php
index 0d0989ba97e..9d1819fca3d 100644
--- a/core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php
+++ b/core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php
@@ -14,11 +14,11 @@ class FileTransferAuthorizeFormTest extends UpdateTestBase {
*
* @var array
*/
- public static $modules = array('update', 'update_test');
+ public static $modules = ['update', 'update_test'];
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer software updates', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer software updates', 'administer site configuration']);
$this->drupalLogin($admin_user);
// Create a local cache so the module is not downloaded from drupal.org.
diff --git a/core/modules/update/src/Tests/UpdateContribTest.php b/core/modules/update/src/Tests/UpdateContribTest.php
index 88cf378419c..2a7c675cc5e 100644
--- a/core/modules/update/src/Tests/UpdateContribTest.php
+++ b/core/modules/update/src/Tests/UpdateContribTest.php
@@ -18,11 +18,11 @@ class UpdateContribTest extends UpdateTestBase {
*
* @var array
*/
- public static $modules = array('update_test', 'update', 'aaa_update_test', 'bbb_update_test', 'ccc_update_test');
+ public static $modules = ['update_test', 'update', 'aaa_update_test', 'bbb_update_test', 'ccc_update_test'];
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
}
@@ -30,18 +30,18 @@ class UpdateContribTest extends UpdateTestBase {
* Tests when there is no available release data for a contrib module.
*/
function testNoReleasesAvailable() {
- $system_info = array(
- '#all' => array(
+ $system_info = [
+ '#all' => [
'version' => '8.0.0',
- ),
- 'aaa_update_test' => array(
+ ],
+ 'aaa_update_test' => [
'project' => 'aaa_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $system_info)->save();
- $this->refreshUpdateStatus(array('drupal' => '0.0', 'aaa_update_test' => 'no-releases'));
+ $this->refreshUpdateStatus(['drupal' => '0.0', 'aaa_update_test' => 'no-releases']);
$this->drupalGet('admin/reports/updates');
// Cannot use $this->standardTests() because we need to check for the
// 'No available releases found' string.
@@ -62,22 +62,22 @@ class UpdateContribTest extends UpdateTestBase {
*/
function testUpdateContribBasic() {
$project_link = \Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'));
- $system_info = array(
- '#all' => array(
+ $system_info = [
+ '#all' => [
'version' => '8.0.0',
- ),
- 'aaa_update_test' => array(
+ ],
+ 'aaa_update_test' => [
'project' => 'aaa_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(
- array(
+ [
'drupal' => '0.0',
'aaa_update_test' => '1_0',
- )
+ ]
);
$this->standardTests();
$this->assertText(t('Up to date'));
@@ -90,10 +90,10 @@ class UpdateContribTest extends UpdateTestBase {
$system_info['aaa_update_test']['hidden'] = TRUE;
$this->config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(
- array(
+ [
'drupal' => '0.0',
'aaa_update_test' => '1_0',
- )
+ ]
);
$this->assertNoRaw($project_link, 'Link to aaa_update_test project does not appear.');
@@ -101,10 +101,10 @@ class UpdateContribTest extends UpdateTestBase {
$system_info['aaa_update_test']['package'] = 'aaa_update_test';
$this->config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(
- array(
+ [
'drupal' => '0.0',
'aaa_update_test' => '1_0',
- )
+ ]
);
$this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
}
@@ -124,38 +124,38 @@ class UpdateContribTest extends UpdateTestBase {
*/
function testUpdateContribOrder() {
// We want core to be version 8.0.0.
- $system_info = array(
- '#all' => array(
+ $system_info = [
+ '#all' => [
'version' => '8.0.0',
- ),
+ ],
// All the rest should be visible as contrib modules at version 8.x-1.0.
// aaa_update_test needs to be part of the "CCC Update test" project,
// which would throw off the report if we weren't properly sorting by
// the project names.
- 'aaa_update_test' => array(
+ 'aaa_update_test' => [
'project' => 'ccc_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
+ ],
// This should be its own project, and listed first on the report.
- 'bbb_update_test' => array(
+ 'bbb_update_test' => [
'project' => 'bbb_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
+ ],
// This will contain both aaa_update_test and ccc_update_test, and
// should come after the bbb_update_test project.
- 'ccc_update_test' => array(
+ 'ccc_update_test' => [
'project' => 'ccc_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $system_info)->save();
- $this->refreshUpdateStatus(array('drupal' => '0.0', '#all' => '1_0'));
+ $this->refreshUpdateStatus(['drupal' => '0.0', '#all' => '1_0']);
$this->standardTests();
// We're expecting the report to say all projects are up to date.
$this->assertText(t('Up to date'));
@@ -188,33 +188,33 @@ class UpdateContribTest extends UpdateTestBase {
// @todo https://www.drupal.org/node/2338175 base themes have to be
// installed.
// Only install the subtheme, not the base theme.
- \Drupal::service('theme_handler')->install(array('update_test_subtheme'));
+ \Drupal::service('theme_handler')->install(['update_test_subtheme']);
// Define the initial state for core and the subtheme.
- $system_info = array(
+ $system_info = [
// We want core to be version 8.0.0.
- '#all' => array(
+ '#all' => [
'version' => '8.0.0',
- ),
+ ],
// Show the update_test_basetheme
- 'update_test_basetheme' => array(
+ 'update_test_basetheme' => [
'project' => 'update_test_basetheme',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
+ ],
// Show the update_test_subtheme
- 'update_test_subtheme' => array(
+ 'update_test_subtheme' => [
'project' => 'update_test_subtheme',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $system_info)->save();
- $xml_mapping = array(
+ $xml_mapping = [
'drupal' => '0.0',
'update_test_subtheme' => '1_0',
'update_test_basetheme' => '1_1-sec',
- );
+ ];
$this->refreshUpdateStatus($xml_mapping);
$this->assertText(t('Security update required!'));
$this->assertRaw(\Drupal::l(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme')), 'Link to the Update test base theme project appears.');
@@ -238,38 +238,38 @@ class UpdateContribTest extends UpdateTestBase {
$extension_config->save();
// Define the initial state for core and the test contrib themes.
- $system_info = array(
+ $system_info = [
// We want core to be version 8.0.0.
- '#all' => array(
+ '#all' => [
'version' => '8.0.0',
- ),
+ ],
// The update_test_basetheme should be visible and up to date.
- 'update_test_basetheme' => array(
+ 'update_test_basetheme' => [
'project' => 'update_test_basetheme',
'version' => '8.x-1.1',
'hidden' => FALSE,
- ),
+ ],
// The update_test_subtheme should be visible and up to date.
- 'update_test_subtheme' => array(
+ 'update_test_subtheme' => [
'project' => 'update_test_subtheme',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
// When there are contributed modules in the site's file system, the
// total number of attempts made in the test may exceed the default value
// of update_max_fetch_attempts. Therefore this variable is set very high
// to avoid test failures in those cases.
$update_settings->set('fetch.max_attempts', 99999)->save();
$this->config('update_test.settings')->set('system_info', $system_info)->save();
- $xml_mapping = array(
+ $xml_mapping = [
'drupal' => '0.0',
'update_test_subtheme' => '1_0',
'update_test_basetheme' => '1_1-sec',
- );
+ ];
$base_theme_project_link = \Drupal::l(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme'));
$sub_theme_project_link = \Drupal::l(t('Update test subtheme'), Url::fromUri('http://example.com/project/update_test_subtheme'));
- foreach (array(TRUE, FALSE) as $check_disabled) {
+ foreach ([TRUE, FALSE] as $check_disabled) {
$update_settings->set('check.disabled_extensions', $check_disabled)->save();
$this->refreshUpdateStatus($xml_mapping);
// In neither case should we see the "Themes" heading for installed
@@ -295,21 +295,21 @@ class UpdateContribTest extends UpdateTestBase {
module_load_include('compare.inc', 'update');
// Install the subtheme.
- \Drupal::service('theme_handler')->install(array('update_test_subtheme'));
+ \Drupal::service('theme_handler')->install(['update_test_subtheme']);
// Add a project and initial state for base theme and subtheme.
- $system_info = array(
+ $system_info = [
// Hide the update_test_basetheme.
- 'update_test_basetheme' => array(
+ 'update_test_basetheme' => [
'project' => 'update_test_basetheme',
'hidden' => TRUE,
- ),
+ ],
// Show the update_test_subtheme.
- 'update_test_subtheme' => array(
+ 'update_test_subtheme' => [
'project' => 'update_test_subtheme',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $system_info)->save();
$projects = \Drupal::service('update.manager')->getProjects();
$theme_data = \Drupal::service('theme_handler')->rebuildThemeData();
@@ -323,37 +323,37 @@ class UpdateContribTest extends UpdateTestBase {
* Makes sure that if we fetch from a broken URL, sane things happen.
*/
function testUpdateBrokenFetchURL() {
- $system_info = array(
- '#all' => array(
+ $system_info = [
+ '#all' => [
'version' => '8.0.0',
- ),
- 'aaa_update_test' => array(
+ ],
+ 'aaa_update_test' => [
'project' => 'aaa_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- 'bbb_update_test' => array(
+ ],
+ 'bbb_update_test' => [
'project' => 'bbb_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- 'ccc_update_test' => array(
+ ],
+ 'ccc_update_test' => [
'project' => 'ccc_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $system_info)->save();
// Ensure that the update information is correct before testing.
$this->drupalGet('admin/reports/updates');
- $xml_mapping = array(
+ $xml_mapping = [
'drupal' => '0.0',
'aaa_update_test' => '1_0',
'bbb_update_test' => 'does-not-exist',
'ccc_update_test' => '1_0',
- );
+ ];
$this->refreshUpdateStatus($xml_mapping);
$this->assertText(t('Up to date'));
@@ -388,31 +388,31 @@ class UpdateContribTest extends UpdateTestBase {
*/
function testHookUpdateStatusAlter() {
$update_test_config = $this->config('update_test.settings');
- $update_admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer software updates'));
+ $update_admin_user = $this->drupalCreateUser(['administer site configuration', 'administer software updates']);
$this->drupalLogin($update_admin_user);
- $system_info = array(
- '#all' => array(
+ $system_info = [
+ '#all' => [
'version' => '8.0.0',
- ),
- 'aaa_update_test' => array(
+ ],
+ 'aaa_update_test' => [
'project' => 'aaa_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
- ),
- );
+ ],
+ ];
$update_test_config->set('system_info', $system_info)->save();
- $update_status = array(
- 'aaa_update_test' => array(
+ $update_status = [
+ 'aaa_update_test' => [
'status' => UPDATE_NOT_SECURE,
- ),
- );
+ ],
+ ];
$update_test_config->set('update_status', $update_status)->save();
$this->refreshUpdateStatus(
- array(
+ [
'drupal' => '0.0',
'aaa_update_test' => '1_0',
- )
+ ]
);
$this->drupalGet('admin/reports/updates');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
@@ -421,7 +421,7 @@ class UpdateContribTest extends UpdateTestBase {
// Visit the reports page again without the altering and make sure the
// status is back to normal.
- $update_test_config->set('update_status', array())->save();
+ $update_test_config->set('update_status', [])->save();
$this->drupalGet('admin/reports/updates');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertNoText(t('Security update required!'));
@@ -433,7 +433,7 @@ class UpdateContribTest extends UpdateTestBase {
$this->assertText(t('Security update'));
// Turn the altering back off and visit the Update manager UI.
- $update_test_config->set('update_status', array())->save();
+ $update_test_config->set('update_status', [])->save();
$this->drupalGet('admin/modules/update');
$this->assertNoText(t('Security update'));
}
diff --git a/core/modules/update/src/Tests/UpdateCoreTest.php b/core/modules/update/src/Tests/UpdateCoreTest.php
index baecde88c50..48b3fcdcd98 100644
--- a/core/modules/update/src/Tests/UpdateCoreTest.php
+++ b/core/modules/update/src/Tests/UpdateCoreTest.php
@@ -21,7 +21,7 @@ class UpdateCoreTest extends UpdateTestBase {
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules', 'administer themes'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration', 'administer modules', 'administer themes']);
$this->drupalLogin($admin_user);
$this->drupalPlaceBlock('local_actions_block');
}
@@ -33,11 +33,11 @@ class UpdateCoreTest extends UpdateTestBase {
* The version.
*/
protected function setSystemInfo($version) {
- $setting = array(
- '#all' => array(
+ $setting = [
+ '#all' => [
'version' => $version,
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $setting)->save();
}
@@ -45,11 +45,11 @@ class UpdateCoreTest extends UpdateTestBase {
* Tests the Update Manager module when no updates are available.
*/
function testNoUpdatesAvailable() {
- foreach (array(0, 1) as $minor_version) {
- foreach (array(0, 1) as $patch_version) {
- foreach (array('-alpha1', '-beta1', '') as $extra_version) {
+ foreach ([0, 1] as $minor_version) {
+ foreach ([0, 1] as $patch_version) {
+ foreach (['-alpha1', '-beta1', ''] as $extra_version) {
$this->setSystemInfo("8.$minor_version.$patch_version" . $extra_version);
- $this->refreshUpdateStatus(array('drupal' => "$minor_version.$patch_version" . $extra_version));
+ $this->refreshUpdateStatus(['drupal' => "$minor_version.$patch_version" . $extra_version]);
$this->standardTests();
$this->assertText(t('Up to date'));
$this->assertNoText(t('Update available'));
@@ -70,9 +70,9 @@ class UpdateCoreTest extends UpdateTestBase {
$this->drupalGet('admin/reports/updates/check');
$this->assertResponse(403, 'Accessing admin/reports/updates/check without a CSRF token results in access denied.');
- foreach (array(0, 1) as $minor_version) {
- foreach (array('-alpha1', '-beta1', '') as $extra_version) {
- $this->refreshUpdateStatus(array('drupal' => "$minor_version.1" . $extra_version));
+ foreach ([0, 1] as $minor_version) {
+ foreach (['-alpha1', '-beta1', ''] as $extra_version) {
+ $this->refreshUpdateStatus(['drupal' => "$minor_version.1" . $extra_version]);
$this->standardTests();
$this->drupalGet('admin/reports/updates');
$this->clickLink(t('Check manually'));
@@ -131,11 +131,11 @@ class UpdateCoreTest extends UpdateTestBase {
* Tests the Update Manager module when a major update is available.
*/
function testMajorUpdateAvailable() {
- foreach (array(0, 1) as $minor_version) {
- foreach (array(0, 1) as $patch_version) {
- foreach (array('-alpha1', '-beta1', '') as $extra_version) {
+ foreach ([0, 1] as $minor_version) {
+ foreach ([0, 1] as $patch_version) {
+ foreach (['-alpha1', '-beta1', ''] as $extra_version) {
$this->setSystemInfo("8.$minor_version.$patch_version" . $extra_version);
- $this->refreshUpdateStatus(array('drupal' => '9'));
+ $this->refreshUpdateStatus(['drupal' => '9']);
$this->standardTests();
$this->drupalGet('admin/reports/updates');
$this->clickLink(t('Check manually'));
@@ -157,9 +157,9 @@ class UpdateCoreTest extends UpdateTestBase {
* Tests the Update Manager module when a security update is available.
*/
function testSecurityUpdateAvailable() {
- foreach (array(0, 1) as $minor_version) {
+ foreach ([0, 1] as $minor_version) {
$this->setSystemInfo("8.$minor_version.0");
- $this->refreshUpdateStatus(array('drupal' => "$minor_version.2-sec"));
+ $this->refreshUpdateStatus(['drupal' => "$minor_version.2-sec"]);
$this->standardTests();
$this->assertNoText(t('Up to date'));
$this->assertNoText(t('Update available'));
@@ -175,19 +175,19 @@ class UpdateCoreTest extends UpdateTestBase {
* Ensures proper results where there are date mismatches among modules.
*/
function testDatestampMismatch() {
- $system_info = array(
- '#all' => array(
+ $system_info = [
+ '#all' => [
// We need to think we're running a -dev snapshot to see dates.
'version' => '8.1.0-dev',
'datestamp' => time(),
- ),
- 'block' => array(
+ ],
+ 'block' => [
// This is 2001-09-09 01:46:40 GMT, so test for "2001-Sep-".
'datestamp' => '1000000000',
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')->set('system_info', $system_info)->save();
- $this->refreshUpdateStatus(array('drupal' => 'dev'));
+ $this->refreshUpdateStatus(['drupal' => 'dev']);
$this->assertNoText(t('2001-Sep-'));
$this->assertText(t('Up to date'));
$this->assertNoText(t('Update available'));
@@ -203,7 +203,7 @@ class UpdateCoreTest extends UpdateTestBase {
->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
->save();
$this->config('update_test.settings')
- ->set('xml_map', array('drupal' => '0.0'))
+ ->set('xml_map', ['drupal' => '0.0'])
->save();
$this->cronRun();
@@ -221,7 +221,7 @@ class UpdateCoreTest extends UpdateTestBase {
->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
->save();
$this->config('update_test.settings')
- ->set('xml_map', array('drupal' => '0.0'))
+ ->set('xml_map', ['drupal' => '0.0'])
->save();
$this->drupalGet('admin/reports/updates');
@@ -242,7 +242,7 @@ class UpdateCoreTest extends UpdateTestBase {
->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
->save();
$this->config('update_test.settings')
- ->set('xml_map', array('drupal' => '0.1'))
+ ->set('xml_map', ['drupal' => '0.1'])
->save();
$this->drupalGet('admin/reports/updates');
@@ -263,7 +263,7 @@ class UpdateCoreTest extends UpdateTestBase {
->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
->save();
$this->config('update_test.settings')
- ->set('xml_map', array('drupal' => '0.2-sec'))
+ ->set('xml_map', ['drupal' => '0.2-sec'])
->save();
$this->drupalGet('admin/reports/updates');
@@ -296,7 +296,7 @@ class UpdateCoreTest extends UpdateTestBase {
* Tests the Update Manager module when the update server returns 503 errors.
*/
function testServiceUnavailable() {
- $this->refreshUpdateStatus(array(), '503-error');
+ $this->refreshUpdateStatus([], '503-error');
// Ensure that no "Warning: SimpleXMLElement..." parse errors are found.
$this->assertNoText('SimpleXMLElement');
$this->assertUniqueText(t('Failed to get available update data for one project.'));
@@ -306,12 +306,12 @@ class UpdateCoreTest extends UpdateTestBase {
* Tests that exactly one fetch task per project is created and not more.
*/
function testFetchTasks() {
- $projecta = array(
+ $projecta = [
'name' => 'aaa_update_test',
- );
- $projectb = array(
+ ];
+ $projectb = [
'name' => 'bbb_update_test',
- );
+ ];
$queue = \Drupal::queue('update_fetch_tasks');
$this->assertEqual($queue->numberOfItems(), 0, 'Queue is empty');
update_create_fetch_task($projecta);
@@ -338,7 +338,7 @@ class UpdateCoreTest extends UpdateTestBase {
->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
->save();
$this->config('update_test.settings')
- ->set('xml_map', array('drupal' => '0.1'))
+ ->set('xml_map', ['drupal' => '0.1'])
->save();
$this->drupalGet('admin/reports/updates');
@@ -349,7 +349,7 @@ class UpdateCoreTest extends UpdateTestBase {
* Ensures that the local actions appear.
*/
public function testLocalActions() {
- $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules', 'administer software updates', 'administer themes'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration', 'administer modules', 'administer software updates', 'administer themes']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/modules');
diff --git a/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php b/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php
index 63c2889a53b..96f3ca8274e 100644
--- a/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php
+++ b/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php
@@ -14,7 +14,7 @@ class UpdateDeleteFileIfStaleTest extends UpdateTestBase {
*
* @var array
*/
- public static $modules = array('update');
+ public static $modules = ['update'];
/**
* {@inheritdoc}
diff --git a/core/modules/update/src/Tests/UpdateTestBase.php b/core/modules/update/src/Tests/UpdateTestBase.php
index 9cb3c20fc05..fc39d1a3cce 100644
--- a/core/modules/update/src/Tests/UpdateTestBase.php
+++ b/core/modules/update/src/Tests/UpdateTestBase.php
@@ -63,7 +63,7 @@ abstract class UpdateTestBase extends WebTestBase {
protected function refreshUpdateStatus($xml_map, $url = 'update-test') {
// Tell the Update Manager module to fetch from the URL provided by
// update_test module.
- $this->config('update.settings')->set('fetch.url', Url::fromUri('base:' . $url, array('absolute' => TRUE))->toString())->save();
+ $this->config('update.settings')->set('fetch.url', Url::fromUri('base:' . $url, ['absolute' => TRUE])->toString())->save();
// Save the map for UpdateTestController::updateTest() to use.
$this->config('update_test.settings')->set('xml_map', $xml_map)->save();
// Manually check the update status.
diff --git a/core/modules/update/src/Tests/UpdateUploadTest.php b/core/modules/update/src/Tests/UpdateUploadTest.php
index 9b5296267bb..c3de290d117 100644
--- a/core/modules/update/src/Tests/UpdateUploadTest.php
+++ b/core/modules/update/src/Tests/UpdateUploadTest.php
@@ -18,11 +18,11 @@ class UpdateUploadTest extends UpdateTestBase {
*
* @var array
*/
- public static $modules = array('update', 'update_test');
+ public static $modules = ['update', 'update_test'];
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer modules', 'administer software updates', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer modules', 'administer software updates', 'administer site configuration']);
$this->drupalLogin($admin_user);
}
@@ -39,23 +39,23 @@ class UpdateUploadTest extends UpdateTestBase {
// emits a notice in strict mode.
$imageTestFiles = $this->drupalGetTestFiles('image');
$invalidArchiveFile = reset($imageTestFiles);
- $edit = array(
+ $edit = [
'files[project_upload]' => $invalidArchiveFile->uri,
- );
+ ];
// This also checks that the correct archive extensions are allowed.
$this->drupalPostForm('admin/modules/install', $edit, t('Install'));
- $this->assertText(t('Only files with the following extensions are allowed: @archive_extensions.', array('@archive_extensions' => archiver_get_extensions())), 'Only valid archives can be uploaded.');
+ $this->assertText(t('Only files with the following extensions are allowed: @archive_extensions.', ['@archive_extensions' => archiver_get_extensions()]), 'Only valid archives can be uploaded.');
$this->assertUrl('admin/modules/install');
// Check to ensure an existing module can't be reinstalled. Also checks that
// the archive was extracted since we can't know if the module is already
// installed until after extraction.
$validArchiveFile = __DIR__ . '/../../tests/aaa_update_test.tar.gz';
- $edit = array(
+ $edit = [
'files[project_upload]' => $validArchiveFile,
- );
+ ];
$this->drupalPostForm('admin/modules/install', $edit, t('Install'));
- $this->assertText(t('@module_name is already installed.', array('@module_name' => 'AAA Update test')), 'Existing module was extracted and not reinstalled.');
+ $this->assertText(t('@module_name is already installed.', ['@module_name' => 'AAA Update test']), 'Existing module was extracted and not reinstalled.');
$this->assertUrl('admin/modules/install');
// Ensure that a new module can be extracted and installed.
@@ -64,16 +64,16 @@ class UpdateUploadTest extends UpdateTestBase {
$installedInfoFilePath = $this->container->get('update.root') . '/' . $moduleUpdater::getRootDirectoryRelativePath() . '/update_test_new_module/update_test_new_module.info.yml';
$this->assertFalse(file_exists($installedInfoFilePath), 'The new module does not exist in the filesystem before it is installed with the Update Manager.');
$validArchiveFile = __DIR__ . '/../../tests/update_test_new_module/8.x-1.0/update_test_new_module.tar.gz';
- $edit = array(
+ $edit = [
'files[project_upload]' => $validArchiveFile,
- );
+ ];
$this->drupalPostForm('admin/modules/install', $edit, t('Install'));
// Check that submitting the form takes the user to authorize.php.
$this->assertUrl('core/authorize.php');
$this->assertTitle('Update manager | Drupal');
// Check for a success message on the page, and check that the installed
// module now exists in the expected place in the filesystem.
- $this->assertRaw(t('Installed %project_name successfully', array('%project_name' => 'update_test_new_module')));
+ $this->assertRaw(t('Installed %project_name successfully', ['%project_name' => 'update_test_new_module']));
$this->assertTrue(file_exists($installedInfoFilePath), 'The new module exists in the filesystem after it is installed with the Update Manager.');
// Ensure the links are relative to the site root and not
// core/authorize.php.
@@ -98,27 +98,27 @@ class UpdateUploadTest extends UpdateTestBase {
$this->assertEqual($info['version'], '8.x-1.0');
// Enable the module.
- $this->drupalPostForm('admin/modules', array('modules[update_test_new_module][enable]' => TRUE), t('Install'));
+ $this->drupalPostForm('admin/modules', ['modules[update_test_new_module][enable]' => TRUE], t('Install'));
// Define the update XML such that the new module downloaded above needs an
// update from 8.x-1.0 to 8.x-1.1.
$update_test_config = $this->config('update_test.settings');
- $system_info = array(
- 'update_test_new_module' => array(
+ $system_info = [
+ 'update_test_new_module' => [
'project' => 'update_test_new_module',
- ),
- );
+ ],
+ ];
$update_test_config->set('system_info', $system_info)->save();
- $xml_mapping = array(
+ $xml_mapping = [
'update_test_new_module' => '1_1',
- );
+ ];
$this->refreshUpdateStatus($xml_mapping);
// Run the updates for the new module.
- $this->drupalPostForm('admin/reports/updates/update', array('projects[update_test_new_module]' => TRUE), t('Download these updates'));
- $this->drupalPostForm(NULL, array('maintenance_mode' => FALSE), t('Continue'));
+ $this->drupalPostForm('admin/reports/updates/update', ['projects[update_test_new_module]' => TRUE], t('Download these updates'));
+ $this->drupalPostForm(NULL, ['maintenance_mode' => FALSE], t('Continue'));
$this->assertText(t('Update was completed successfully.'));
- $this->assertRaw(t('Installed %project_name successfully', array('%project_name' => 'update_test_new_module')));
+ $this->assertRaw(t('Installed %project_name successfully', ['%project_name' => 'update_test_new_module']));
// Parse the info file again to check that the module has been updated to
// 8.x-1.1.
@@ -141,14 +141,14 @@ class UpdateUploadTest extends UpdateTestBase {
* Checks the messages on update manager pages when missing a security update.
*/
function testUpdateManagerCoreSecurityUpdateMessages() {
- $setting = array(
- '#all' => array(
+ $setting = [
+ '#all' => [
'version' => '8.0.0',
- ),
- );
+ ],
+ ];
$this->config('update_test.settings')
->set('system_info', $setting)
- ->set('xml_map', array('drupal' => '0.2-sec'))
+ ->set('xml_map', ['drupal' => '0.2-sec'])
->save();
$this->config('update.settings')
->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
diff --git a/core/modules/update/src/UpdateFetcher.php b/core/modules/update/src/UpdateFetcher.php
index 29d5582eef8..2b03c9c1011 100644
--- a/core/modules/update/src/UpdateFetcher.php
+++ b/core/modules/update/src/UpdateFetcher.php
@@ -62,7 +62,7 @@ class UpdateFetcher implements UpdateFetcherInterface {
$data = '';
try {
$data = (string) $this->httpClient
- ->get($url, array('headers' => array('Accept' => 'text/xml')))
+ ->get($url, ['headers' => ['Accept' => 'text/xml']])
->getBody();
}
catch (RequestException $exception) {
diff --git a/core/modules/update/src/UpdateManager.php b/core/modules/update/src/UpdateManager.php
index 52a7eb28c2e..07416915af6 100644
--- a/core/modules/update/src/UpdateManager.php
+++ b/core/modules/update/src/UpdateManager.php
@@ -91,7 +91,7 @@ class UpdateManager implements UpdateManagerInterface {
$this->keyValueStore = $key_value_expirable_factory->get('update');
$this->themeHandler = $theme_handler;
$this->availableReleasesTempStore = $key_value_expirable_factory->get('update_available_releases');
- $this->projects = array();
+ $this->projects = [];
}
/**
@@ -151,11 +151,11 @@ class UpdateManager implements UpdateManagerInterface {
* {@inheritdoc}
*/
public function projectStorage($key) {
- $projects = array();
+ $projects = [];
// On certain paths, we should clear the data and recompute the projects for
// update status of the site to avoid presenting stale information.
- $route_names = array(
+ $route_names = [
'update.theme_update',
'system.modules_list',
'system.theme_install',
@@ -169,12 +169,12 @@ class UpdateManager implements UpdateManagerInterface {
'update.manual_status',
'update.confirmation_page',
'system.themes_page',
- );
+ ];
if (in_array(\Drupal::routeMatch()->getRouteName(), $route_names)) {
$this->keyValueStore->delete($key);
}
else {
- $projects = $this->keyValueStore->get($key, array());
+ $projects = $this->keyValueStore->get($key, []);
}
return $projects;
}
@@ -198,10 +198,10 @@ class UpdateManager implements UpdateManagerInterface {
if ($item = $this->updateProcessor->claimQueueItem()) {
if ($this->updateProcessor->processFetchTask($item->data)) {
$context['results']['updated']++;
- $context['message'] = $this->t('Checked available update data for %title.', array('%title' => $item->data['info']['name']));
+ $context['message'] = $this->t('Checked available update data for %title.', ['%title' => $item->data['info']['name']]);
}
else {
- $context['message'] = $this->t('Failed to check available update data for %title.', array('%title' => $item->data['info']['name']));
+ $context['message'] = $this->t('Failed to check available update data for %title.', ['%title' => $item->data['info']['name']]);
$context['results']['failures']++;
}
$context['sandbox']['progress']++;
diff --git a/core/modules/update/src/UpdateProcessor.php b/core/modules/update/src/UpdateProcessor.php
index 75e3241c095..25dfc7a004b 100644
--- a/core/modules/update/src/UpdateProcessor.php
+++ b/core/modules/update/src/UpdateProcessor.php
@@ -104,8 +104,8 @@ class UpdateProcessor implements UpdateProcessorInterface {
$this->availableReleasesTempStore = $key_value_expirable_factory->get('update_available_releases');
$this->stateStore = $state_store;
$this->privateKey = $private_key;
- $this->fetchTasks = array();
- $this->failed = array();
+ $this->fetchTasks = [];
+ $this->failed = [];
}
/**
@@ -151,7 +151,7 @@ class UpdateProcessor implements UpdateProcessorInterface {
$max_fetch_attempts = $this->updateSettings->get('fetch.max_attempts');
$success = FALSE;
- $available = array();
+ $available = [];
$site_key = Crypt::hmacBase64($base_url, $this->privateKey->get());
$fetch_url_base = $this->updateFetcher->getFetchBaseUrl($project);
$project_name = $project['name'];
@@ -219,23 +219,23 @@ class UpdateProcessor implements UpdateProcessorInterface {
if (!isset($xml->short_name)) {
return NULL;
}
- $data = array();
+ $data = [];
foreach ($xml as $k => $v) {
$data[$k] = (string) $v;
}
- $data['releases'] = array();
+ $data['releases'] = [];
if (isset($xml->releases)) {
foreach ($xml->releases->children() as $release) {
$version = (string) $release->version;
- $data['releases'][$version] = array();
+ $data['releases'][$version] = [];
foreach ($release->children() as $k => $v) {
$data['releases'][$version][$k] = (string) $v;
}
- $data['releases'][$version]['terms'] = array();
+ $data['releases'][$version]['terms'] = [];
if ($release->terms) {
foreach ($release->terms->children() as $term) {
if (!isset($data['releases'][$version]['terms'][(string) $term->name])) {
- $data['releases'][$version]['terms'][(string) $term->name] = array();
+ $data['releases'][$version]['terms'][(string) $term->name] = [];
}
$data['releases'][$version]['terms'][(string) $term->name][] = (string) $term->value;
}
diff --git a/core/modules/update/src/UpdateSettingsForm.php b/core/modules/update/src/UpdateSettingsForm.php
index d830de57f45..1860269d609 100644
--- a/core/modules/update/src/UpdateSettingsForm.php
+++ b/core/modules/update/src/UpdateSettingsForm.php
@@ -59,42 +59,42 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('update.settings');
- $form['update_check_frequency'] = array(
+ $form['update_check_frequency'] = [
'#type' => 'radios',
'#title' => t('Check for updates'),
'#default_value' => $config->get('check.interval_days'),
- '#options' => array(
+ '#options' => [
'1' => t('Daily'),
'7' => t('Weekly'),
- ),
+ ],
'#description' => t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
- );
+ ];
- $form['update_check_disabled'] = array(
+ $form['update_check_disabled'] = [
'#type' => 'checkbox',
'#title' => t('Check for updates of uninstalled modules and themes'),
'#default_value' => $config->get('check.disabled_extensions'),
- );
+ ];
$notification_emails = $config->get('notification.emails');
- $form['update_notify_emails'] = array(
+ $form['update_notify_emails'] = [
'#type' => 'textarea',
'#title' => t('Email addresses to notify when updates are available'),
'#rows' => 4,
'#default_value' => implode("\n", $notification_emails),
'#description' => t('Whenever your site checks for available updates and finds new releases, it can notify a list of users via email. Put each address on a separate line. If blank, no emails will be sent.'),
- );
+ ];
- $form['update_notification_threshold'] = array(
+ $form['update_notification_threshold'] = [
'#type' => 'radios',
'#title' => t('Email notification threshold'),
'#default_value' => $config->get('notification.threshold'),
- '#options' => array(
+ '#options' => [
'all' => t('All newer versions'),
'security' => t('Only security updates'),
- ),
- '#description' => t('You can choose to send email only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href=":status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', array(':status_report' => $this->url('system.status')))
- );
+ ],
+ '#description' => t('You can choose to send email only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href=":status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', [':status_report' => $this->url('system.status')])
+ ];
return parent::buildForm($form, $form_state);
}
@@ -105,8 +105,8 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_state->set('notify_emails', []);
if (!$form_state->isValueEmpty('update_notify_emails')) {
- $valid = array();
- $invalid = array();
+ $valid = [];
+ $invalid = [];
foreach (explode("\n", trim($form_state->getValue('update_notify_emails'))) as $email) {
$email = trim($email);
if (!empty($email)) {
@@ -122,10 +122,10 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
$form_state->set('notify_emails', $valid);
}
elseif (count($invalid) == 1) {
- $form_state->setErrorByName('update_notify_emails', $this->t('%email is not a valid email address.', array('%email' => reset($invalid))));
+ $form_state->setErrorByName('update_notify_emails', $this->t('%email is not a valid email address.', ['%email' => reset($invalid)]));
}
else {
- $form_state->setErrorByName('update_notify_emails', $this->t('%emails are not valid email addresses.', array('%emails' => implode(', ', $invalid))));
+ $form_state->setErrorByName('update_notify_emails', $this->t('%emails are not valid email addresses.', ['%emails' => implode(', ', $invalid)]));
}
}
diff --git a/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php b/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php
index bdf6d343562..3ca46baa3c2 100644
--- a/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php
+++ b/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php
@@ -64,7 +64,7 @@ class UpdateTestController extends ControllerBase {
}
$file = __DIR__ . "/../../$project_name.$availability_scenario.xml";
- $headers = array('Content-Type' => 'text/xml; charset=utf-8');
+ $headers = ['Content-Type' => 'text/xml; charset=utf-8'];
if (!is_file($file)) {
// Return an empty response.
return new Response('', 200, $headers);
diff --git a/core/modules/update/tests/modules/update_test/src/Plugin/Archiver/UpdateTestArchiver.php b/core/modules/update/tests/modules/update_test/src/Plugin/Archiver/UpdateTestArchiver.php
index a9e499a7e47..ffa4e46d717 100644
--- a/core/modules/update/tests/modules/update_test/src/Plugin/Archiver/UpdateTestArchiver.php
+++ b/core/modules/update/tests/modules/update_test/src/Plugin/Archiver/UpdateTestArchiver.php
@@ -32,7 +32,7 @@ class UpdateTestArchiver implements ArchiverInterface {
/**
* {@inheritdoc}
*/
- public function extract($path, array $files = array()) {
+ public function extract($path, array $files = []) {
return $this;
}
@@ -40,7 +40,7 @@ class UpdateTestArchiver implements ArchiverInterface {
* {@inheritdoc}
*/
public function listContents() {
- return array();
+ return [];
}
}
diff --git a/core/modules/update/tests/modules/update_test/src/TestFileTransferWithSettingsForm.php b/core/modules/update/tests/modules/update_test/src/TestFileTransferWithSettingsForm.php
index 5737c09cd2e..4afcade707e 100644
--- a/core/modules/update/tests/modules/update_test/src/TestFileTransferWithSettingsForm.php
+++ b/core/modules/update/tests/modules/update_test/src/TestFileTransferWithSettingsForm.php
@@ -29,11 +29,11 @@ class TestFileTransferWithSettingsForm extends Local {
* Returns a settings form with a text field to input a username.
*/
public function getSettingsForm() {
- $form = array();
- $form['update_test_username'] = array(
+ $form = [];
+ $form['update_test_username'] = [
'#type' => 'textfield',
'#title' => t('Update Test Username'),
- );
+ ];
return $form;
}
diff --git a/core/modules/update/tests/modules/update_test/update_test.module b/core/modules/update/tests/modules/update_test/update_test.module
index 90b6cdc009d..5dd207069f9 100644
--- a/core/modules/update/tests/modules/update_test/update_test.module
+++ b/core/modules/update/tests/modules/update_test/update_test.module
@@ -20,7 +20,7 @@ use Drupal\Core\Extension\Extension;
*/
function update_test_system_info_alter(&$info, Extension $file) {
$setting = \Drupal::config('update_test.settings')->get('system_info');
- foreach (array('#all', $file->getName()) as $id) {
+ foreach (['#all', $file->getName()] as $id) {
if (!empty($setting[$id])) {
foreach ($setting[$id] as $key => $value) {
$info[$key] = $value;
@@ -44,7 +44,7 @@ function update_test_update_status_alter(&$projects) {
$setting = \Drupal::config('update_test.settings')->get('update_status');
if (!empty($setting)) {
foreach ($projects as $project_name => &$project) {
- foreach (array('#all', $project_name) as $id) {
+ foreach (['#all', $project_name] as $id) {
if (!empty($setting[$id])) {
foreach ($setting[$id] as $key => $value) {
$project[$key] = $value;
@@ -62,11 +62,11 @@ function update_test_filetransfer_info() {
// Define a test file transfer method, to ensure that there will always be at
// least one method available in the user interface (regardless of the
// environment in which the update manager tests are run).
- return array(
- 'system_test' => array(
+ return [
+ 'system_test' => [
'title' => t('Update Test FileTransfer'),
'class' => 'Drupal\update_test\TestFileTransferWithSettingsForm',
'weight' => -20,
- ),
- );
+ ],
+ ];
}
diff --git a/core/modules/update/tests/src/Kernel/Migrate/d6/MigrateUpdateConfigsTest.php b/core/modules/update/tests/src/Kernel/Migrate/d6/MigrateUpdateConfigsTest.php
index 62138925d80..aa3563c6085 100644
--- a/core/modules/update/tests/src/Kernel/Migrate/d6/MigrateUpdateConfigsTest.php
+++ b/core/modules/update/tests/src/Kernel/Migrate/d6/MigrateUpdateConfigsTest.php
@@ -17,7 +17,7 @@ class MigrateUpdateConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('update');
+ public static $modules = ['update'];
/**
* {@inheritdoc}
@@ -35,7 +35,7 @@ class MigrateUpdateConfigsTest extends MigrateDrupal6TestBase {
$this->assertIdentical(2, $config->get('fetch.max_attempts'));
$this->assertIdentical('http://updates.drupal.org/release-history', $config->get('fetch.url'));
$this->assertIdentical('all', $config->get('notification.threshold'));
- $this->assertIdentical(array(), $config->get('notification.emails'));
+ $this->assertIdentical([], $config->get('notification.emails'));
$this->assertIdentical(7, $config->get('check.interval_days'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'update.settings', $config->get());
}
diff --git a/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php b/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php
index f57997fd6a0..113f006aad2 100644
--- a/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php
+++ b/core/modules/update/tests/src/Unit/Menu/UpdateLocalTasksTest.php
@@ -12,7 +12,7 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class UpdateLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array('update' => 'core/modules/update');
+ $this->directoryList = ['update' => 'core/modules/update'];
parent::setUp();
}
@@ -22,20 +22,20 @@ class UpdateLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getUpdateReportRoutes
*/
public function testUpdateReportLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('update.status', 'update.settings', 'update.report_update'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['update.status', 'update.settings', 'update.report_update'],
+ ]);
}
/**
* Provides a list of report routes to test.
*/
public function getUpdateReportRoutes() {
- return array(
- array('update.status'),
- array('update.settings'),
- array('update.report_update'),
- );
+ return [
+ ['update.status'],
+ ['update.settings'],
+ ['update.report_update'],
+ ];
}
/**
@@ -44,9 +44,9 @@ class UpdateLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getUpdateModuleRoutes
*/
public function testUpdateModuleLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('update.module_update'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['update.module_update'],
+ ]);
;
}
@@ -54,9 +54,9 @@ class UpdateLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of module routes to test.
*/
public function getUpdateModuleRoutes() {
- return array(
- array('update.module_update'),
- );
+ return [
+ ['update.module_update'],
+ ];
}
/**
@@ -65,9 +65,9 @@ class UpdateLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getUpdateThemeRoutes
*/
public function testUpdateThemeLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('update.theme_update'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['update.theme_update'],
+ ]);
;
}
@@ -75,9 +75,9 @@ class UpdateLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of theme routes to test.
*/
public function getUpdateThemeRoutes() {
- return array(
- array('update.theme_update'),
- );
+ return [
+ ['update.theme_update'],
+ ];
}
}
diff --git a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
index c203f3b5214..c3e447d1fcf 100644
--- a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
+++ b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
@@ -27,7 +27,7 @@ class UpdateFetcherTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
- $config_factory = $this->getConfigFactoryStub(array('update.settings' => array('fetch_url' => 'http://www.example.com')));
+ $config_factory = $this->getConfigFactoryStub(['update.settings' => ['fetch_url' => 'http://www.example.com']]);
$http_client_mock = $this->getMock('\GuzzleHttp\ClientInterface');
$this->updateFetcher = new UpdateFetcher($config_factory, $http_client_mock);
}
@@ -62,25 +62,25 @@ class UpdateFetcherTest extends UnitTestCase {
* - 'expected' - The expected url from UpdateFetcher::buildFetchUrl().
*/
public function providerTestUpdateBuildFetchUrl() {
- $data = array();
+ $data = [];
// First test that we didn't break the trivial case.
$project['name'] = 'update_test';
$project['project_type'] = '';
$project['info']['version'] = '';
$project['info']['project status url'] = 'http://www.example.com';
- $project['includes'] = array('module1' => 'Module 1', 'module2' => 'Module 2');
+ $project['includes'] = ['module1' => 'Module 1', 'module2' => 'Module 2'];
$site_key = '';
$expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
- $data[] = array($project, $site_key, $expected);
+ $data[] = [$project, $site_key, $expected];
// For disabled projects it shouldn't add the site key either.
$site_key = 'site_key';
$project['project_type'] = 'disabled';
$expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
- $data[] = array($project, $site_key, $expected);
+ $data[] = [$project, $site_key, $expected];
// For enabled projects, test adding the site key.
$project['project_type'] = '';
@@ -88,7 +88,7 @@ class UpdateFetcherTest extends UnitTestCase {
$expected .= '?site_key=site_key';
$expected .= '&list=' . rawurlencode('module1,module2');
- $data[] = array($project, $site_key, $expected);
+ $data[] = [$project, $site_key, $expected];
// Test when the URL contains a question mark.
$project['info']['project status url'] = 'http://www.example.com/?project=';
@@ -96,7 +96,7 @@ class UpdateFetcherTest extends UnitTestCase {
$expected .= '&site_key=site_key';
$expected .= '&list=' . rawurlencode('module1,module2');
- $data[] = array($project, $site_key, $expected);
+ $data[] = [$project, $site_key, $expected];
return $data;
}
diff --git a/core/modules/update/update.api.php b/core/modules/update/update.api.php
index 37ef66a4743..48216eb0938 100644
--- a/core/modules/update/update.api.php
+++ b/core/modules/update/update.api.php
@@ -40,11 +40,11 @@ function hook_update_projects_alter(&$projects) {
// Add a disabled module to the list.
// The key for the array should be the machine-readable project "short name".
- $projects['disabled_project_name'] = array(
+ $projects['disabled_project_name'] = [
// Machine-readable project short name (same as the array key above).
'name' => 'disabled_project_name',
// Array of values from the main .info.yml file for this project.
- 'info' => array(
+ 'info' => [
'name' => 'Some disabled module',
'description' => 'A module not enabled on the site that you want to see in the available updates report.',
'version' => '8.x-1.0',
@@ -52,7 +52,7 @@ function hook_update_projects_alter(&$projects) {
// The maximum file change time (the "ctime" returned by the filectime()
// PHP method) for all of the .info.yml files included in this project.
'_info_file_ctime' => 1243888165,
- ),
+ ],
// The date stamp when the project was released, if known. If the disabled
// project was an officially packaged release from drupal.org, this will
// be included in the .info.yml file as the 'datestamp' field. This only
@@ -62,15 +62,15 @@ function hook_update_projects_alter(&$projects) {
// Any modules (or themes) included in this project. Keyed by machine-
// readable "short name", value is the human-readable project name printed
// in the UI.
- 'includes' => array(
+ 'includes' => [
'disabled_project' => 'Disabled module',
'disabled_project_helper' => 'Disabled module helper module',
'disabled_project_foo' => 'Disabled module foo add-on module',
- ),
+ ],
// Does this project contain a 'module', 'theme', 'disabled-module', or
// 'disabled-theme'?
'project_type' => 'disabled-module',
- );
+ ];
}
/**
@@ -92,11 +92,11 @@ function hook_update_status_alter(&$projects) {
$projects[$project]['status'] = UPDATE_NOT_CHECKED;
$projects[$project]['reason'] = t('Ignored from settings');
if (!empty($settings[$project]['notes'])) {
- $projects[$project]['extra'][] = array(
- 'class' => array('admin-note'),
+ $projects[$project]['extra'][] = [
+ 'class' => ['admin-note'],
'label' => t('Administrator note'),
'data' => $settings[$project]['notes'],
- );
+ ];
}
}
}
@@ -120,9 +120,9 @@ function hook_update_status_alter(&$projects) {
* @ingroup update_manager_file
*/
function hook_verify_update_archive($project, $archive_file, $directory) {
- $errors = array();
+ $errors = [];
if (!file_exists($directory)) {
- $errors[] = t('The %directory does not exist.', array('%directory' => $directory));
+ $errors[] = t('The %directory does not exist.', ['%directory' => $directory]);
}
// Add other checks on the archive integrity here.
return $errors;
diff --git a/core/modules/update/update.authorize.inc b/core/modules/update/update.authorize.inc
index 58f14647033..1c2cc60fb2e 100644
--- a/core/modules/update/update.authorize.inc
+++ b/core/modules/update/update.authorize.inc
@@ -36,25 +36,25 @@ use Drupal\Core\Url;
* should use that response for the current page request.
*/
function update_authorize_run_update($filetransfer, $projects) {
- $operations = array();
+ $operations = [];
foreach ($projects as $project_info) {
- $operations[] = array(
+ $operations[] = [
'update_authorize_batch_copy_project',
- array(
+ [
$project_info['project'],
$project_info['updater_name'],
$project_info['local_url'],
$filetransfer,
- ),
- );
+ ],
+ ];
}
- $batch = array(
+ $batch = [
'init_message' => t('Preparing to update your site'),
'operations' => $operations,
'finished' => 'update_authorize_update_batch_finished',
'file' => drupal_get_path('module', 'update') . '/update.authorize.inc',
- );
+ ];
batch_set($batch);
// Since authorize.php has its own method for setting the page title, set it
@@ -91,30 +91,30 @@ function update_authorize_run_update($filetransfer, $projects) {
* should use that response for the current page request.
*/
function update_authorize_run_install($filetransfer, $project, $updater_name, $local_url) {
- $operations[] = array(
+ $operations[] = [
'update_authorize_batch_copy_project',
- array(
+ [
$project,
$updater_name,
$local_url,
$filetransfer,
- ),
- );
+ ],
+ ];
// @todo Instantiate our Updater to set the human-readable title?
- $batch = array(
+ $batch = [
'init_message' => t('Preparing to install'),
'operations' => $operations,
// @todo Use a different finished callback for different messages?
'finished' => 'update_authorize_install_batch_finished',
'file' => drupal_get_path('module', 'update') . '/update.authorize.inc',
- );
+ ];
batch_set($batch);
// Since authorize.php has its own method for setting the page title, set it
// manually here rather than passing it in to batch_set() as would normally
// be done.
- $_SESSION['authorize_page_title'] = t('Installing %project', array('%project' => $project));
+ $_SESSION['authorize_page_title'] = t('Installing %project', ['%project' => $project]);
// Invoke the batch via authorize.php.
return system_authorized_batch_process();
@@ -142,14 +142,14 @@ function update_authorize_batch_copy_project($project, $updater_name, $local_url
// Initialize some variables in the Batch API $context array.
if (!isset($context['results']['log'])) {
- $context['results']['log'] = array();
+ $context['results']['log'] = [];
}
if (!isset($context['results']['log'][$project])) {
- $context['results']['log'][$project] = array();
+ $context['results']['log'][$project] = [];
}
if (!isset($context['results']['tasks'])) {
- $context['results']['tasks'] = array();
+ $context['results']['tasks'] = [];
}
// The batch API uses a session, and since all the arguments are serialized
@@ -184,7 +184,7 @@ function update_authorize_batch_copy_project($project, $updater_name, $local_url
return;
}
- _update_batch_create_message($context['results']['log'][$project], t('Installed %project_name successfully', array('%project_name' => $project)));
+ _update_batch_create_message($context['results']['log'][$project], t('Installed %project_name successfully', ['%project_name' => $project]));
if (!empty($tasks)) {
$context['results']['tasks'] += $tasks;
}
@@ -221,29 +221,29 @@ function update_authorize_update_batch_finished($success, $results) {
// Take the site out of maintenance mode if it was previously that way.
if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) {
\Drupal::state()->set('system.maintenance_mode', FALSE);
- $page_message = array(
+ $page_message = [
'message' => t('Update was completed successfully. Your site has been taken out of maintenance mode.'),
'type' => 'status',
- );
+ ];
}
else {
- $page_message = array(
+ $page_message = [
'message' => t('Update was completed successfully.'),
'type' => 'status',
- );
+ ];
}
}
elseif (!$offline) {
- $page_message = array(
+ $page_message = [
'message' => t('Update failed! See the log below for more information.'),
'type' => 'error',
- );
+ ];
}
else {
- $page_message = array(
+ $page_message = [
'message' => t('Update failed! See the log below for more information. Your site is still in maintenance mode.'),
'type' => 'error',
- );
+ ];
}
// Since we're doing an update of existing code, always add a task for
// running update.php.
@@ -300,29 +300,29 @@ function update_authorize_install_batch_finished($success, $results) {
// Take the site out of maintenance mode if it was previously that way.
if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) {
\Drupal::state()->set('system.maintenance_mode', FALSE);
- $page_message = array(
+ $page_message = [
'message' => t('Installation was completed successfully. Your site has been taken out of maintenance mode.'),
'type' => 'status',
- );
+ ];
}
else {
- $page_message = array(
+ $page_message = [
'message' => t('Installation was completed successfully.'),
'type' => 'status',
- );
+ ];
}
}
elseif (!$success && !$offline) {
- $page_message = array(
+ $page_message = [
'message' => t('Installation failed! See the log below for more information.'),
'type' => 'error',
- );
+ ];
}
else {
- $page_message = array(
+ $page_message = [
'message' => t('Installation failed! See the log below for more information. Your site is still in maintenance mode.'),
'type' => 'error',
- );
+ ];
}
// Unset the variable since it is no longer needed.
@@ -348,7 +348,7 @@ function update_authorize_install_batch_finished($success, $results) {
* if there were errors. Defaults to TRUE.
*/
function _update_batch_create_message(&$project_results, $message, $success = TRUE) {
- $project_results[] = array('message' => $message, 'success' => $success);
+ $project_results[] = ['message' => $message, 'success' => $success];
}
/**
diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc
index a077c38d2f1..2ba5fdce75a 100644
--- a/core/modules/update/update.compare.inc
+++ b/core/modules/update/update.compare.inc
@@ -32,7 +32,7 @@ function update_process_project_info(&$projects) {
// Figure out what the currently installed major version is. We need
// to handle both contribution (e.g. "5.x-1.3", major = 1) and core
// (e.g. "5.1", major = 5) version strings.
- $matches = array();
+ $matches = [];
if (preg_match('/^(\d+\.x-)?(\d+)\..*$/', $info['version'], $matches)) {
$info['major'] = $matches[2];
}
@@ -171,7 +171,7 @@ function update_calculate_project_data($available) {
* Data about available project releases of a specific project.
*/
function update_calculate_project_update_status(&$project_data, $available) {
- foreach (array('title', 'link') as $attribute) {
+ foreach (['title', 'link'] as $attribute) {
if (!isset($project_data[$attribute]) && isset($available[$attribute])) {
$project_data[$attribute] = $available[$attribute];
}
@@ -184,33 +184,33 @@ function update_calculate_project_update_status(&$project_data, $available) {
case 'insecure':
$project_data['status'] = UPDATE_NOT_SECURE;
if (empty($project_data['extra'])) {
- $project_data['extra'] = array();
+ $project_data['extra'] = [];
}
- $project_data['extra'][] = array(
+ $project_data['extra'][] = [
'label' => t('Project not secure'),
'data' => t('This project has been labeled insecure by the Drupal security team, and is no longer available for download. Immediately disabling everything included by this project is strongly recommended!'),
- );
+ ];
break;
case 'unpublished':
case 'revoked':
$project_data['status'] = UPDATE_REVOKED;
if (empty($project_data['extra'])) {
- $project_data['extra'] = array();
+ $project_data['extra'] = [];
}
- $project_data['extra'][] = array(
+ $project_data['extra'][] = [
'label' => t('Project revoked'),
'data' => t('This project has been revoked, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
- );
+ ];
break;
case 'unsupported':
$project_data['status'] = UPDATE_NOT_SUPPORTED;
if (empty($project_data['extra'])) {
- $project_data['extra'] = array();
+ $project_data['extra'] = [];
}
- $project_data['extra'][] = array(
+ $project_data['extra'][] = [
'label' => t('Project not supported'),
'data' => t('This project is no longer supported, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
- );
+ ];
break;
case 'not-fetched':
$project_data['status'] = UPDATE_NOT_FETCHED;
@@ -233,7 +233,7 @@ function update_calculate_project_update_status(&$project_data, $available) {
// Figure out the target major version.
$existing_major = $project_data['existing_major'];
- $supported_majors = array();
+ $supported_majors = [];
if (isset($available['supported_majors'])) {
$supported_majors = explode(',', $available['supported_majors']);
}
@@ -303,25 +303,25 @@ function update_calculate_project_update_status(&$project_data, $available) {
elseif ($release['status'] == 'unpublished') {
$project_data['status'] = UPDATE_REVOKED;
if (empty($project_data['extra'])) {
- $project_data['extra'] = array();
+ $project_data['extra'] = [];
}
- $project_data['extra'][] = array(
- 'class' => array('release-revoked'),
+ $project_data['extra'][] = [
+ 'class' => ['release-revoked'],
'label' => t('Release revoked'),
'data' => t('Your currently installed release has been revoked, and is no longer available for download. Disabling everything included in this release or upgrading is strongly recommended!'),
- );
+ ];
}
elseif (isset($release['terms']['Release type']) &&
in_array('Unsupported', $release['terms']['Release type'])) {
$project_data['status'] = UPDATE_NOT_SUPPORTED;
if (empty($project_data['extra'])) {
- $project_data['extra'] = array();
+ $project_data['extra'] = [];
}
- $project_data['extra'][] = array(
- 'class' => array('release-not-supported'),
+ $project_data['extra'][] = [
+ 'class' => ['release-not-supported'],
'label' => t('Release not supported'),
'data' => t('Your currently installed release is now unsupported, and is no longer available for download. Disabling everything included in this release or upgrading is strongly recommended!'),
- );
+ ];
}
}
@@ -341,7 +341,7 @@ function update_calculate_project_update_status(&$project_data, $available) {
if (isset($release['version_major']) && $release['version_major'] > $target_major) {
if (in_array($release['version_major'], $supported_majors)) {
if (!isset($project_data['also'])) {
- $project_data['also'] = array();
+ $project_data['also'] = [];
}
if (!isset($project_data['also'][$release['version_major']])) {
$project_data['also'][$release['version_major']] = $version;
diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc
index a710dd9f7a7..9964910b17e 100644
--- a/core/modules/update/update.fetch.inc
+++ b/core/modules/update/update.fetch.inc
@@ -18,9 +18,9 @@ function _update_cron_notify() {
$update_config = \Drupal::config('update.settings');
module_load_install('update');
$status = update_requirements('runtime');
- $params = array();
+ $params = [];
$notify_all = ($update_config->get('notification.threshold') == 'all');
- foreach (array('core', 'contrib') as $report_type) {
+ foreach (['core', 'contrib'] as $report_type) {
$type = 'update_' . $report_type;
if (isset($status[$type]['severity'])
&& ($status[$type]['severity'] == REQUIREMENT_ERROR || ($notify_all && $status[$type]['reason'] == UPDATE_NOT_CURRENT))) {
diff --git a/core/modules/update/update.install b/core/modules/update/update.install
index e8101295c1e..d76d09e95ea 100644
--- a/core/modules/update/update.install
+++ b/core/modules/update/update.install
@@ -28,7 +28,7 @@ use Drupal\Core\Url;
* @see _update_cron_notify()
*/
function update_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if ($phase == 'runtime') {
if ($available = update_get_available(FALSE)) {
module_load_include('inc', 'update', 'update.compare');
@@ -97,7 +97,7 @@ function update_uninstall() {
* @see update_calculate_project_data()
*/
function _update_requirement_check($project, $type) {
- $requirement = array();
+ $requirement = [];
if ($type == 'core') {
$requirement['title'] = t('Drupal core update status');
}
@@ -143,7 +143,7 @@ function _update_requirement_check($project, $type) {
$requirement_label = t('Up to date');
}
if ($status != UPDATE_CURRENT && $type == 'core' && isset($project['recommended'])) {
- $requirement_label .= ' ' . t('(version @version available)', array('@version' => $project['recommended']));
+ $requirement_label .= ' ' . t('(version @version available)', ['@version' => $project['recommended']]);
}
$requirement['value'] = \Drupal::l($requirement_label, new Url(_update_manager_access() ? 'update.report_update' : 'update.status'));
return $requirement;
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index f9c7c5f3f42..541ab6f34a8 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -48,11 +48,11 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
function update_manager_download_batch_finished($success, $results) {
if (!empty($results['errors'])) {
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#title' => t('Downloading updates failed:'),
'#items' => $results['errors'],
- );
+ ];
drupal_set_message(drupal_render($item_list), 'error');
}
elseif ($success) {
@@ -91,23 +91,23 @@ function _update_manager_check_backends(&$form, $operation) {
}
// Otherwise, show the available backends.
- $form['available_backends'] = array(
+ $form['available_backends'] = [
'#prefix' => '<p>',
'#suffix' => '</p>',
- );
+ ];
$available_backends = drupal_get_filetransfer_info();
if (empty($available_backends)) {
if ($operation == 'update') {
- $form['available_backends']['#markup'] = t('Your server does not support updating modules and themes from this interface. Instead, update modules and themes by uploading the new versions directly to the server, as described in the <a href=":handbook_url">handbook</a>.', array(':handbook_url' => 'https://www.drupal.org/getting-started/install-contrib'));
+ $form['available_backends']['#markup'] = t('Your server does not support updating modules and themes from this interface. Instead, update modules and themes by uploading the new versions directly to the server, as described in the <a href=":handbook_url">handbook</a>.', [':handbook_url' => 'https://www.drupal.org/getting-started/install-contrib']);
}
else {
- $form['available_backends']['#markup'] = t('Your server does not support installing modules and themes from this interface. Instead, install modules and themes by uploading them directly to the server, as described in the <a href=":handbook_url">handbook</a>.', array(':handbook_url' => 'https://www.drupal.org/getting-started/install-contrib'));
+ $form['available_backends']['#markup'] = t('Your server does not support installing modules and themes from this interface. Instead, install modules and themes by uploading them directly to the server, as described in the <a href=":handbook_url">handbook</a>.', [':handbook_url' => 'https://www.drupal.org/getting-started/install-contrib']);
}
return FALSE;
}
- $backend_names = array();
+ $backend_names = [];
foreach ($available_backends as $backend) {
$backend_names[] = $backend['title'];
}
@@ -116,20 +116,20 @@ function _update_manager_check_backends(&$form, $operation) {
count($available_backends),
'Updating modules and themes requires <strong>@backends access</strong> to your server. See the <a href=":handbook_url">handbook</a> for other update methods.',
'Updating modules and themes requires access to your server via one of the following methods: <strong>@backends</strong>. See the <a href=":handbook_url">handbook</a> for other update methods.',
- array(
+ [
'@backends' => implode(', ', $backend_names),
':handbook_url' => 'https://www.drupal.org/getting-started/install-contrib',
- ));
+ ]);
}
else {
$form['available_backends']['#markup'] = \Drupal::translation()->formatPlural(
count($available_backends),
'Installing modules and themes requires <strong>@backends access</strong> to your server. See the <a href=":handbook_url">handbook</a> for other installation methods.',
'Installing modules and themes requires access to your server via one of the following methods: <strong>@backends</strong>. See the <a href=":handbook_url">handbook</a> for other installation methods.',
- array(
+ [
'@backends' => implode(', ', $backend_names),
':handbook_url' => 'https://www.drupal.org/getting-started/install-contrib',
- ));
+ ]);
}
return TRUE;
}
@@ -150,7 +150,7 @@ function _update_manager_check_backends(&$form, $operation) {
function update_manager_archive_extract($file, $directory) {
$archiver = archiver_get_archiver($file);
if (!$archiver) {
- throw new Exception(t('Cannot extract %file, not a valid archive.', array ('%file' => $file)));
+ throw new Exception(t('Cannot extract %file, not a valid archive.', ['%file' => $file]));
}
// Remove the directory if it exists, otherwise it might contain a mixture of
@@ -189,7 +189,7 @@ function update_manager_archive_extract($file, $directory) {
* are no errors, it will be an empty array.
*/
function update_manager_archive_verify($project, $archive_file, $directory) {
- return \Drupal::moduleHandler()->invokeAll('verify_update_archive', array($project, $archive_file, $directory));
+ return \Drupal::moduleHandler()->invokeAll('verify_update_archive', [$project, $archive_file, $directory]);
}
/**
@@ -205,7 +205,7 @@ function update_manager_archive_verify($project, $archive_file, $directory) {
*/
function update_manager_file_get($url) {
$parsed_url = parse_url($url);
- $remote_schemes = array('http', 'https', 'ftp', 'ftps', 'smb', 'nfs');
+ $remote_schemes = ['http', 'https', 'ftp', 'ftps', 'smb', 'nfs'];
if (!isset($parsed_url['scheme']) || !in_array($parsed_url['scheme'], $remote_schemes)) {
// This is a local file, just return the path.
return drupal_realpath($url);
@@ -245,14 +245,14 @@ function update_manager_batch_project_get($project, $url, &$context) {
// This is here to show the user that we are in the process of downloading.
if (!isset($context['sandbox']['started'])) {
$context['sandbox']['started'] = TRUE;
- $context['message'] = t('Downloading %project', array('%project' => $project));
+ $context['message'] = t('Downloading %project', ['%project' => $project]);
$context['finished'] = 0;
return;
}
// Actually try to download the file.
if (!($local_cache = update_manager_file_get($url))) {
- $context['results']['errors'][$project] = t('Failed to download %project from %url', array('%project' => $project, '%url' => $url));
+ $context['results']['errors'][$project] = t('Failed to download %project from %url', ['%project' => $project, '%url' => $url]);
return;
}
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 6ef4628210a..32b5b8cc877 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -98,7 +98,7 @@ function update_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.update':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Update Manager module periodically checks for new versions of your site\'s software (including contributed modules and themes), and alerts administrators to available updates. The Update Manager system is also used by some other modules to manage updates and downloads; for example, the Interface Translation module uses the Update Manager to download translations from the localization server. Note that whenever the Update Manager system is used, anonymous usage statistics are sent to Drupal.org. If desired, you may disable the Update Manager module from the <a href=":modules">Extend page</a>; if you do so, functionality that depends on the Update Manager system will not work. For more information, see the <a href=":update">online documentation for the Update Manager module</a>.', array(':update' => 'https://www.drupal.org/documentation/modules/update', ':modules' => \Drupal::url('system.modules_list'))) . '</p>';
+ $output .= '<p>' . t('The Update Manager module periodically checks for new versions of your site\'s software (including contributed modules and themes), and alerts administrators to available updates. The Update Manager system is also used by some other modules to manage updates and downloads; for example, the Interface Translation module uses the Update Manager to download translations from the localization server. Note that whenever the Update Manager system is used, anonymous usage statistics are sent to Drupal.org. If desired, you may disable the Update Manager module from the <a href=":modules">Extend page</a>; if you do so, functionality that depends on the Update Manager system will not work. For more information, see the <a href=":update">online documentation for the Update Manager module</a>.', [':update' => 'https://www.drupal.org/documentation/modules/update', ':modules' => \Drupal::url('system.modules_list')]) . '</p>';
// Only explain the Update manager if it has not been disabled.
if (_update_manager_access()) {
$output .= '<p>' . t('The Update Manager also allows administrators to update and install modules and themes through the administration interface.') . '</p>';
@@ -106,13 +106,13 @@ function update_help($route_name, RouteMatchInterface $route_match) {
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Checking for available updates') . '</dt>';
- $output .= '<dd>' . t('The <a href=":update-report">Available updates report</a> displays core, contributed modules, and themes for which there are new releases available for download. On the report page, you can also check manually for updates. You can configure the frequency of update checks, which are performed during cron runs, and whether notifications are sent on the <a href=":update-settings">Update Manager settings page</a>.', array(':update-report' => \Drupal::url('update.status'), ':update-settings' => \Drupal::url('update.settings'))) . '</dd>';
+ $output .= '<dd>' . t('The <a href=":update-report">Available updates report</a> displays core, contributed modules, and themes for which there are new releases available for download. On the report page, you can also check manually for updates. You can configure the frequency of update checks, which are performed during cron runs, and whether notifications are sent on the <a href=":update-settings">Update Manager settings page</a>.', [':update-report' => \Drupal::url('update.status'), ':update-settings' => \Drupal::url('update.settings')]) . '</dd>';
// Only explain the Update manager if it has not been disabled.
if (_update_manager_access()) {
$output .= '<dt>' . t('Performing updates through the Update page') . '</dt>';
- $output .= '<dd>' . t('The Update Manager module allows administrators to perform updates directly from the <a href=":update-page">Update page</a>. It lists all available updates, and you can confirm whether you want to download them. If you don\'t have sufficient access rights to your web server, you could be prompted for your FTP/SSH password. Afterwards the files are transferred into your site installation, overwriting your old files. Direct links to the Update page are also displayed on the <a href=":modules_page">Extend page</a> and the <a href=":themes_page">Appearance page</a>.', array(':modules_page' => \Drupal::url('system.modules_list'), ':themes_page' => \Drupal::url('system.themes_page'), ':update-page' => \Drupal::url('update.report_update'))) . '</dd>';
+ $output .= '<dd>' . t('The Update Manager module allows administrators to perform updates directly from the <a href=":update-page">Update page</a>. It lists all available updates, and you can confirm whether you want to download them. If you don\'t have sufficient access rights to your web server, you could be prompted for your FTP/SSH password. Afterwards the files are transferred into your site installation, overwriting your old files. Direct links to the Update page are also displayed on the <a href=":modules_page">Extend page</a> and the <a href=":themes_page">Appearance page</a>.', [':modules_page' => \Drupal::url('system.modules_list'), ':themes_page' => \Drupal::url('system.themes_page'), ':update-page' => \Drupal::url('update.report_update')]) . '</dd>';
$output .= '<dt>' . t('Installing new modules and themes through the Install page') . '</dt>';
- $output .= '<dd>' . t('You can also install new modules and themes in the same fashion, through the <a href=":install">Install page</a>, or by clicking the <em>Install new module/theme</em> links at the top of the <a href=":modules_page">Extend page</a> and the <a href=":themes_page">Appearance page</a>. In this case, you are prompted to provide either the URL to the download, or to upload a packaged release file from your local computer.', array(':modules_page' => \Drupal::url('system.modules_list'), ':themes_page' => \Drupal::url('system.themes_page'), ':install' => \Drupal::url('update.report_install'))) . '</dd>';
+ $output .= '<dd>' . t('You can also install new modules and themes in the same fashion, through the <a href=":install">Install page</a>, or by clicking the <em>Install new module/theme</em> links at the top of the <a href=":modules_page">Extend page</a> and the <a href=":themes_page">Appearance page</a>. In this case, you are prompted to provide either the URL to the download, or to upload a packaged release file from your local computer.', [':modules_page' => \Drupal::url('system.modules_list'), ':themes_page' => \Drupal::url('system.themes_page'), ':install' => \Drupal::url('update.report_install')]) . '</dd>';
}
$output .= '</dl>';
return $output;
@@ -122,10 +122,10 @@ function update_help($route_name, RouteMatchInterface $route_match) {
case 'system.modules_list':
if (_update_manager_access()) {
- $output = '<p>' . t('Regularly review and install <a href=":updates">available updates</a> to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time a module is updated.', array(':update-php' => \Drupal::url('system.db_update'), ':updates' => \Drupal::url('update.status'))) . '</p>';
+ $output = '<p>' . t('Regularly review and install <a href=":updates">available updates</a> to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time a module is updated.', [':update-php' => \Drupal::url('system.db_update'), ':updates' => \Drupal::url('update.status')]) . '</p>';
}
else {
- $output = '<p>' . t('Regularly review <a href=":updates">available updates</a> to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time a module is updated.', array(':update-php' => \Drupal::url('system.db_update'), ':updates' => \Drupal::url('update.status'))) . '</p>';
+ $output = '<p>' . t('Regularly review <a href=":updates">available updates</a> to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time a module is updated.', [':update-php' => \Drupal::url('system.db_update'), ':updates' => \Drupal::url('update.status')]) . '</p>';
}
return $output;
}
@@ -164,7 +164,7 @@ function update_page_top() {
}
module_load_install('update');
$status = update_requirements('runtime');
- foreach (array('core', 'contrib') as $report_type) {
+ foreach (['core', 'contrib'] as $report_type) {
$type = 'update_' . $report_type;
// hook_requirements() supports render arrays therefore we need to render
// them before using drupal_set_message().
@@ -212,25 +212,25 @@ function _update_manager_access() {
* Implements hook_theme().
*/
function update_theme() {
- return array(
- 'update_last_check' => array(
- 'variables' => array('last' => 0),
- ),
- 'update_report' => array(
- 'variables' => array('data' => NULL),
+ return [
+ 'update_last_check' => [
+ 'variables' => ['last' => 0],
+ ],
+ 'update_report' => [
+ 'variables' => ['data' => NULL],
'file' => 'update.report.inc',
- ),
- 'update_project_status' => array(
- 'variables' => array('project' => array()),
+ ],
+ 'update_project_status' => [
+ 'variables' => ['project' => []],
'file' => 'update.report.inc',
- ),
+ ],
// We are using template instead of '#type' => 'table' here to keep markup
// out of preprocess and allow for easier changes to markup.
- 'update_version' => array(
- 'variables' => array('version' => NULL, 'title' => NULL, 'attributes' => array()),
+ 'update_version' => [
+ 'variables' => ['version' => NULL, 'title' => NULL, 'attributes' => []],
'file' => 'update.report.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -312,10 +312,10 @@ function update_storage_clear_submit($form, FormStateInterface $form_state) {
*/
function _update_no_data() {
$destination = \Drupal::destination()->getAsArray();
- return t('No update information available. <a href=":run_cron">Run cron</a> or <a href=":check_manually">check manually</a>.', array(
+ return t('No update information available. <a href=":run_cron">Run cron</a> or <a href=":check_manually">check manually</a>.', [
':run_cron' => \Drupal::url('system.run_cron', [], ['query' => $destination]),
':check_manually' => \Drupal::url('update.manual_status', [], ['query' => $destination]),
- ));
+ ]);
}
/**
@@ -471,20 +471,20 @@ function update_fetch_data_finished($success, $results) {
function update_mail($key, &$message, $params) {
$langcode = $message['langcode'];
$language = \Drupal::languageManager()->getLanguage($langcode);
- $message['subject'] .= t('New release(s) available for @site_name', array('@site_name' => \Drupal::config('system.site')->get('name')), array('langcode' => $langcode));
+ $message['subject'] .= t('New release(s) available for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name')], ['langcode' => $langcode]);
foreach ($params as $msg_type => $msg_reason) {
$message['body'][] = _update_message_text($msg_type, $msg_reason, $langcode);
}
- $message['body'][] = t('See the available updates page for more information:', array(), array('langcode' => $langcode)) . "\n" . \Drupal::url('update.status', [], ['absolute' => TRUE, 'language' => $language]);
+ $message['body'][] = t('See the available updates page for more information:', [], ['langcode' => $langcode]) . "\n" . \Drupal::url('update.status', [], ['absolute' => TRUE, 'language' => $language]);
if (_update_manager_access()) {
- $message['body'][] = t('You can automatically install your missing updates using the Update manager:', array(), array('langcode' => $langcode)) . "\n" . \Drupal::url('update.report_update', [], ['absolute' => TRUE, 'language' => $language]);
+ $message['body'][] = t('You can automatically install your missing updates using the Update manager:', [], ['langcode' => $langcode]) . "\n" . \Drupal::url('update.report_update', [], ['absolute' => TRUE, 'language' => $language]);
}
$settings_url = \Drupal::url('update.settings', [], ['absolute' => TRUE]);
if (\Drupal::config('update.settings')->get('notification.threshold') == 'all') {
- $message['body'][] = t('Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, @url.', array('@url' => $settings_url));
+ $message['body'][] = t('Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, @url.', ['@url' => $settings_url]);
}
else {
- $message['body'][] = t('Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, @url.', array('@url' => $settings_url));
+ $message['body'][] = t('Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, @url.', ['@url' => $settings_url]);
}
}
@@ -511,37 +511,37 @@ function _update_message_text($msg_type, $msg_reason, $langcode = NULL) {
switch ($msg_reason) {
case UPDATE_NOT_SECURE:
if ($msg_type == 'core') {
- $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), array('langcode' => $langcode));
+ $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', [], ['langcode' => $langcode]);
}
else {
- $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), array('langcode' => $langcode));
+ $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', [], ['langcode' => $langcode]);
}
break;
case UPDATE_REVOKED:
if ($msg_type == 'core') {
- $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), array('langcode' => $langcode));
+ $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', [], ['langcode' => $langcode]);
}
else {
- $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), array('langcode' => $langcode));
+ $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', [], ['langcode' => $langcode]);
}
break;
case UPDATE_NOT_SUPPORTED:
if ($msg_type == 'core') {
- $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), array('langcode' => $langcode));
+ $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', [], ['langcode' => $langcode]);
}
else {
- $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended. See the project homepage for more details.', array(), array('langcode' => $langcode));
+ $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended. See the project homepage for more details.', [], ['langcode' => $langcode]);
}
break;
case UPDATE_NOT_CURRENT:
if ($msg_type == 'core') {
- $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('langcode' => $langcode));
+ $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', [], ['langcode' => $langcode]);
}
else {
- $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('langcode' => $langcode));
+ $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', [], ['langcode' => $langcode]);
}
break;
@@ -550,10 +550,10 @@ function _update_message_text($msg_type, $msg_reason, $langcode = NULL) {
case UPDATE_NOT_FETCHED:
case UPDATE_FETCH_PENDING:
if ($msg_type == 'core') {
- $text = t('There was a problem checking <a href=":update-report">available updates</a> for Drupal.', array(':update-report' => \Drupal::url('update.status')), array('langcode' => $langcode));
+ $text = t('There was a problem checking <a href=":update-report">available updates</a> for Drupal.', [':update-report' => \Drupal::url('update.status')], ['langcode' => $langcode]);
}
else {
- $text = t('There was a problem checking <a href=":update-report">available updates</a> for your modules or themes.', array(':update-report' => \Drupal::url('update.status')), array('langcode' => $langcode));
+ $text = t('There was a problem checking <a href=":update-report">available updates</a> for your modules or themes.', [':update-report' => \Drupal::url('update.status')], ['langcode' => $langcode]);
}
break;
}
@@ -593,7 +593,7 @@ function _update_project_status_sort($a, $b) {
*/
function template_preprocess_update_last_check(&$variables) {
$variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($variables['last']);
- $variables['link'] = \Drupal::l(t('Check manually'), new Url('update.manual_status', array(), array('query' => \Drupal::destination()->getAsArray())));
+ $variables['link'] = \Drupal::l(t('Check manually'), new Url('update.manual_status', [], ['query' => \Drupal::destination()->getAsArray()]));
}
/**
@@ -610,7 +610,7 @@ function template_preprocess_update_last_check(&$variables) {
* @see _system_rebuild_module_data()
*/
function update_verify_update_archive($project, $archive_file, $directory) {
- $errors = array();
+ $errors = [];
// Make sure this isn't a tarball of Drupal core.
if (
@@ -620,9 +620,9 @@ function update_verify_update_archive($project, $archive_file, $directory) {
&& file_exists("$directory/$project/core/modules/node/node.module")
&& file_exists("$directory/$project/core/modules/system/system.module")
) {
- return array(
- 'no-core' => t('Automatic updating of Drupal core is not supported. See the <a href=":upgrade-guide">upgrade guide</a> for information on how to update Drupal core manually.', array(':upgrade-guide' => 'https://www.drupal.org/upgrade')),
- );
+ return [
+ 'no-core' => t('Automatic updating of Drupal core is not supported. See the <a href=":upgrade-guide">upgrade guide</a> for information on how to update Drupal core manually.', [':upgrade-guide' => 'https://www.drupal.org/upgrade']),
+ ];
}
// Parse all the .info.yml files and make sure at least one is compatible with
@@ -631,8 +631,8 @@ function update_verify_update_archive($project, $archive_file, $directory) {
// with some out-of-date modules that are not necessary for its overall
// functionality).
$compatible_project = FALSE;
- $incompatible = array();
- $files = file_scan_directory("$directory/$project", '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', array('key' => 'name', 'min_depth' => 0));
+ $incompatible = [];
+ $files = file_scan_directory("$directory/$project", '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', ['key' => 'name', 'min_depth' => 0]);
foreach ($files as $file) {
// Get the .info.yml file for the module or theme this file belongs to.
$info = \Drupal::service('info_parser')->parse($file->uri);
@@ -648,14 +648,14 @@ function update_verify_update_archive($project, $archive_file, $directory) {
}
if (empty($files)) {
- $errors[] = t('%archive_file does not contain any .info.yml files.', array('%archive_file' => drupal_basename($archive_file)));
+ $errors[] = t('%archive_file does not contain any .info.yml files.', ['%archive_file' => drupal_basename($archive_file)]);
}
elseif (!$compatible_project) {
$errors[] = \Drupal::translation()->formatPlural(
count($incompatible),
'%archive_file contains a version of %names that is not compatible with Drupal @version.',
'%archive_file contains versions of modules or themes that are not compatible with Drupal @version: %names',
- array('@version' => \Drupal::CORE_COMPATIBILITY, '%archive_file' => drupal_basename($archive_file), '%names' => implode(', ', $incompatible))
+ ['@version' => \Drupal::CORE_COMPATIBILITY, '%archive_file' => drupal_basename($archive_file), '%names' => implode(', ', $incompatible)]
);
}
@@ -734,14 +734,14 @@ function _update_manager_cache_directory($create = TRUE) {
function update_clear_update_disk_cache() {
// List of update module cache directories. Do not create the directories if
// they do not exist.
- $directories = array(
+ $directories = [
_update_manager_cache_directory(FALSE),
_update_manager_extract_directory(FALSE),
- );
+ ];
// Search for files and directories in base folder only without recursion.
foreach ($directories as $directory) {
- file_scan_directory($directory, '/.*/', array('callback' => 'update_delete_file_if_stale', 'recurse' => FALSE));
+ file_scan_directory($directory, '/.*/', ['callback' => 'update_delete_file_if_stale', 'recurse' => FALSE]);
}
}
diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc
index 5f198d9ba95..7b14a058525 100644
--- a/core/modules/update/update.report.inc
+++ b/core/modules/update/update.report.inc
@@ -23,36 +23,36 @@ function template_preprocess_update_report(&$variables) {
$last = \Drupal::state()->get('update.last_check') ?: 0;
- $variables['last_checked'] = array(
+ $variables['last_checked'] = [
'#theme' => 'update_last_check',
'#last' => $last,
// Attach the library to a variable that gets printed always.
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'update/drupal.update.admin',
- ),
- )
- );
+ ],
+ ]
+ ];
// For no project update data, populate no data message.
if (empty($data)) {
$variables['no_updates_message'] = _update_no_data();
}
- $rows = array();
+ $rows = [];
foreach ($data as $project) {
- $project_status = array(
+ $project_status = [
'#theme' => 'update_project_status',
'#project' => $project,
- );
+ ];
// Build project rows.
if (!isset($rows[$project['project_type']])) {
- $rows[$project['project_type']] = array(
+ $rows[$project['project_type']] = [
'#type' => 'table',
- '#attributes' => array('class' => array('update')),
- );
+ '#attributes' => ['class' => ['update']],
+ ];
}
$row_key = !empty($project['title']) ? Unicode::strtolower($project['title']) : Unicode::strtolower($project['name']);
@@ -62,7 +62,7 @@ function template_preprocess_update_report(&$variables) {
// Add project status class attribute to the table row.
switch ($project['status']) {
case UPDATE_CURRENT:
- $rows[$project['project_type']][$row_key]['#attributes'] = array('class' => array('color-success'));
+ $rows[$project['project_type']][$row_key]['#attributes'] = ['class' => ['color-success']];
break;
case UPDATE_UNKNOWN:
case UPDATE_FETCH_PENDING:
@@ -70,32 +70,32 @@ function template_preprocess_update_report(&$variables) {
case UPDATE_NOT_SECURE:
case UPDATE_REVOKED:
case UPDATE_NOT_SUPPORTED:
- $rows[$project['project_type']][$row_key]['#attributes'] = array('class' => array('color-error'));
+ $rows[$project['project_type']][$row_key]['#attributes'] = ['class' => ['color-error']];
break;
case UPDATE_NOT_CHECKED:
case UPDATE_NOT_CURRENT:
default:
- $rows[$project['project_type']][$row_key]['#attributes'] = array('class' => array('color-warning'));
+ $rows[$project['project_type']][$row_key]['#attributes'] = ['class' => ['color-warning']];
break;
}
}
- $project_types = array(
+ $project_types = [
'core' => t('Drupal core'),
'module' => t('Modules'),
'theme' => t('Themes'),
'module-disabled' => t('Uninstalled modules'),
'theme-disabled' => t('Uninstalled themes'),
- );
+ ];
- $variables['project_types'] = array();
+ $variables['project_types'] = [];
foreach ($project_types as $type_name => $type_label) {
if (!empty($rows[$type_name])) {
ksort($rows[$type_name]);
- $variables['project_types'][] = array(
+ $variables['project_types'][] = [
'label' => $type_label,
'table' => $rows[$type_name],
- );
+ ];
}
}
}
@@ -124,9 +124,9 @@ function template_preprocess_update_project_status(&$variables) {
$variables['existing_version'] = $project['existing_version'];
- $versions_inner = array();
- $security_class = array();
- $version_class = array();
+ $versions_inner = [];
+ $security_class = [];
+ $version_class = [];
if (isset($project['recommended'])) {
if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] !== $project['recommended']) {
@@ -156,57 +156,57 @@ function template_preprocess_update_project_status(&$variables) {
) {
$version_class[] = 'project-update__version--recommended-strong';
}
- $versions_inner[] = array(
+ $versions_inner[] = [
'#theme' => 'update_version',
'#version' => $project['releases'][$project['recommended']],
'#title' => t('Recommended version:'),
- '#attributes' => array('class' => $version_class),
- );
+ '#attributes' => ['class' => $version_class],
+ ];
}
// Now, print any security updates.
if (!empty($project['security updates'])) {
$security_class[] = 'version-security';
foreach ($project['security updates'] as $security_update) {
- $versions_inner[] = array(
+ $versions_inner[] = [
'#theme' => 'update_version',
'#version' => $security_update,
'#title' => t('Security update:'),
- '#attributes' => array('class' => $security_class),
- );
+ '#attributes' => ['class' => $security_class],
+ ];
}
}
}
if ($project['recommended'] !== $project['latest_version']) {
- $versions_inner[] = array(
+ $versions_inner[] = [
'#theme' => 'update_version',
'#version' => $project['releases'][$project['latest_version']],
'#title' => t('Latest version:'),
- '#attributes' => array('class' => array('version-latest')),
- );
+ '#attributes' => ['class' => ['version-latest']],
+ ];
}
if ($project['install_type'] == 'dev'
&& $project['status'] != UPDATE_CURRENT
&& isset($project['dev_version'])
&& $project['recommended'] !== $project['dev_version']) {
- $versions_inner[] = array(
+ $versions_inner[] = [
'#theme' => 'update_version',
'#version' => $project['releases'][$project['dev_version']],
'#title' => t('Development version:'),
- '#attributes' => array('class' => array('version-latest')),
- );
+ '#attributes' => ['class' => ['version-latest']],
+ ];
}
}
if (isset($project['also'])) {
foreach ($project['also'] as $also) {
- $versions_inner[] = array(
+ $versions_inner[] = [
'#theme' => 'update_version',
'#version' => $project['releases'][$also],
'#title' => t('Also available:'),
- '#attributes' => array('class' => array('version-also-available')),
- );
+ '#attributes' => ['class' => ['version-also-available']],
+ ];
}
}
@@ -222,10 +222,10 @@ function template_preprocess_update_project_status(&$variables) {
sort($project['includes']);
$variables['includes'] = $project['includes'];
- $variables['extras'] = array();
+ $variables['extras'] = [];
if (!empty($project['extra'])) {
foreach ($project['extra'] as $value) {
- $extra_item = array();
+ $extra_item = [];
$extra_item['attributes'] = new Attribute();
$extra_item['label'] = $value['label'];
$extra_item['data'] = [
@@ -285,12 +285,12 @@ function template_preprocess_update_project_status(&$variables) {
break;
}
- $variables['status']['icon'] = array(
+ $variables['status']['icon'] = [
'#theme' => 'image',
'#width' => 18,
'#height' => 18,
'#uri' => $uri,
'#alt' => $text,
'#title' => $text,
- );
+ ];
}
diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php
index 5f4d82002e1..f5e2e49acf4 100644
--- a/core/modules/user/src/AccountForm.php
+++ b/core/modules/user/src/AccountForm.php
@@ -72,48 +72,48 @@ abstract class AccountForm extends ContentEntityForm {
$admin = $user->hasPermission('administer users');
// Account information.
- $form['account'] = array(
+ $form['account'] = [
'#type' => 'container',
'#weight' => -10,
- );
+ ];
// The mail field is NOT required if account originally had no mail set
// and the user performing the edit has 'administer users' permission.
// This allows users without email address to be edited and deleted.
// Also see \Drupal\user\Plugin\Validation\Constraint\UserMailRequired.
- $form['account']['mail'] = array(
+ $form['account']['mail'] = [
'#type' => 'email',
'#title' => $this->t('Email address'),
'#description' => $this->t('A valid email address. All emails from the system will be sent to this address. The email address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by email.'),
'#required' => !(!$account->getEmail() && $user->hasPermission('administer users')),
'#default_value' => (!$register ? $account->getEmail() : ''),
- );
+ ];
// Only show name field on registration form or user can change own username.
- $form['account']['name'] = array(
+ $form['account']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Username'),
'#maxlength' => USERNAME_MAX_LENGTH,
'#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."),
'#required' => TRUE,
- '#attributes' => array(
- 'class' => array('username'),
+ '#attributes' => [
+ 'class' => ['username'],
'autocorrect' => 'off',
'autocapitalize' => 'off',
'spellcheck' => 'false',
- ),
+ ],
'#default_value' => (!$register ? $account->getAccountName() : ''),
'#access' => ($register || ($user->id() == $account->id() && $user->hasPermission('change own username')) || $admin),
- );
+ ];
// Display password field only for existing users or when user is allowed to
// assign a password during registration.
if (!$register) {
- $form['account']['pass'] = array(
+ $form['account']['pass'] = [
'#type' => 'password_confirm',
'#size' => 25,
'#description' => $this->t('To change the current user password, enter the new password in both fields.'),
- );
+ ];
// To skip the current password field, the user must have logged in via a
// one-time link and have the token in the URL. Store this in $form_state
@@ -126,7 +126,7 @@ abstract class AccountForm extends ContentEntityForm {
// The user must enter their current password to change to a new one.
if ($user->id() == $account->id()) {
- $form['account']['current_pass'] = array(
+ $form['account']['current_pass'] = [
'#type' => 'password',
'#title' => $this->t('Current password'),
'#size' => 25,
@@ -135,34 +135,34 @@ abstract class AccountForm extends ContentEntityForm {
// Do not let web browsers remember this password, since we are
// trying to confirm that the person submitting the form actually
// knows the current one.
- '#attributes' => array('autocomplete' => 'off'),
- );
+ '#attributes' => ['autocomplete' => 'off'],
+ ];
$form_state->set('user', $account);
// The user may only change their own password without their current
// password if they logged in via a one-time login link.
if (!$form_state->get('user_pass_reset')) {
- $form['account']['current_pass']['#description'] = $this->t('Required if you want to change the %mail or %pass below. <a href=":request_new_url" title="Send password reset instructions via email.">Reset your password</a>.', array(
+ $form['account']['current_pass']['#description'] = $this->t('Required if you want to change the %mail or %pass below. <a href=":request_new_url" title="Send password reset instructions via email.">Reset your password</a>.', [
'%mail' => $form['account']['mail']['#title'],
'%pass' => $this->t('Password'),
':request_new_url' => $this->url('user.pass'),
- ));
+ ]);
}
}
}
elseif (!$config->get('verify_mail') || $admin) {
- $form['account']['pass'] = array(
+ $form['account']['pass'] = [
'#type' => 'password_confirm',
'#size' => 25,
'#description' => $this->t('Provide a password for the new account in both fields.'),
'#required' => TRUE,
- );
+ ];
}
// When not building the user registration form, prevent web browsers from
// autofilling/prefilling the email, username, and password fields.
if ($this->getOperation() != 'register') {
- foreach (array('mail', 'name', 'pass') as $key) {
+ foreach (['mail', 'name', 'pass'] as $key) {
if (isset($form['account'][$key])) {
$form['account'][$key]['#attributes']['autocomplete'] = 'off';
}
@@ -176,35 +176,35 @@ abstract class AccountForm extends ContentEntityForm {
$status = $config->get('register') == USER_REGISTER_VISITORS ? 1 : 0;
}
- $form['account']['status'] = array(
+ $form['account']['status'] = [
'#type' => 'radios',
'#title' => $this->t('Status'),
'#default_value' => $status,
- '#options' => array($this->t('Blocked'), $this->t('Active')),
+ '#options' => [$this->t('Blocked'), $this->t('Active')],
'#access' => $admin,
- );
+ ];
- $roles = array_map(array('\Drupal\Component\Utility\Html', 'escape'), user_role_names(TRUE));
+ $roles = array_map(['\Drupal\Component\Utility\Html', 'escape'], user_role_names(TRUE));
- $form['account']['roles'] = array(
+ $form['account']['roles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Roles'),
- '#default_value' => (!$register ? $account->getRoles() : array()),
+ '#default_value' => (!$register ? $account->getRoles() : []),
'#options' => $roles,
'#access' => $roles && $user->hasPermission('administer permissions'),
- );
+ ];
// Special handling for the inevitable "Authenticated user" role.
- $form['account']['roles'][RoleInterface::AUTHENTICATED_ID] = array(
+ $form['account']['roles'][RoleInterface::AUTHENTICATED_ID] = [
'#default_value' => TRUE,
'#disabled' => TRUE,
- );
+ ];
- $form['account']['notify'] = array(
+ $form['account']['notify'] = [
'#type' => 'checkbox',
'#title' => $this->t('Notify user of new account'),
'#access' => $register && $admin,
- );
+ ];
$user_preferred_langcode = $register ? $language_interface->getId() : $account->getPreferredLangcode();
@@ -216,16 +216,16 @@ abstract class AccountForm extends ContentEntityForm {
$negotiator = $this->languageManager->getNegotiator();
$user_language_added = $negotiator && $negotiator->isNegotiationMethodEnabled(LanguageNegotiationUser::METHOD_ID, LanguageInterface::TYPE_INTERFACE);
}
- $form['language'] = array(
+ $form['language'] = [
'#type' => $this->languageManager->isMultilingual() ? 'details' : 'container',
'#title' => $this->t('Language settings'),
'#open' => TRUE,
// Display language selector when either creating a user on the admin
// interface or editing a user account.
'#access' => !$register || $user->hasPermission('administer users'),
- );
+ ];
- $form['language']['preferred_langcode'] = array(
+ $form['language']['preferred_langcode'] = [
'#type' => 'language_select',
'#title' => $this->t('Site language'),
'#languages' => LanguageInterface::STATE_CONFIGURABLE,
@@ -235,7 +235,7 @@ abstract class AccountForm extends ContentEntityForm {
// language are synchronized. It can be removed if a different behavior is
// desired.
'#pre_render' => ['user_langcode' => [$this, 'alterPreferredLangcodeDescription']],
- );
+ ];
// Only show the account setting for Administration pages language to users
// if one of the detection and selection methods uses it.
@@ -244,7 +244,7 @@ abstract class AccountForm extends ContentEntityForm {
$negotiator = $this->languageManager->getNegotiator();
$show_admin_language = $negotiator && $negotiator->isNegotiationMethodEnabled(LanguageNegotiationUserAdmin::METHOD_ID);
}
- $form['language']['preferred_admin_langcode'] = array(
+ $form['language']['preferred_admin_langcode'] = [
'#type' => 'language_select',
'#title' => $this->t('Administration pages language'),
'#languages' => LanguageInterface::STATE_CONFIGURABLE,
@@ -252,7 +252,7 @@ abstract class AccountForm extends ContentEntityForm {
'#access' => $show_admin_language,
'#empty_option' => $this->t('- No preference -'),
'#empty_value' => '',
- );
+ ];
// User entities contain both a langcode property (for identifying the
// language of the entity data) and a preferred_langcode property (see
@@ -317,7 +317,7 @@ abstract class AccountForm extends ContentEntityForm {
$account = parent::buildEntity($form, $form_state);
// Translate the empty value '' of language selects to an unset field.
- foreach (array('preferred_langcode', 'preferred_admin_langcode') as $field_name) {
+ foreach (['preferred_langcode', 'preferred_admin_langcode'] as $field_name) {
if ($form_state->getValue($field_name) === '') {
$account->$field_name = NULL;
}
@@ -340,7 +340,7 @@ abstract class AccountForm extends ContentEntityForm {
* {@inheritdoc}
*/
protected function getEditedFieldNames(FormStateInterface $form_state) {
- return array_merge(array(
+ return array_merge([
'name',
'pass',
'mail',
@@ -348,7 +348,7 @@ abstract class AccountForm extends ContentEntityForm {
'langcode',
'preferred_langcode',
'preferred_admin_langcode'
- ), parent::getEditedFieldNames($form_state));
+ ], parent::getEditedFieldNames($form_state));
}
/**
@@ -358,7 +358,7 @@ abstract class AccountForm extends ContentEntityForm {
// Manually flag violations of fields not handled by the form display. This
// is necessary as entity form displays only flag violations for fields
// contained in the display.
- $field_names = array(
+ $field_names = [
'name',
'pass',
'mail',
@@ -366,7 +366,7 @@ abstract class AccountForm extends ContentEntityForm {
'langcode',
'preferred_langcode',
'preferred_admin_langcode'
- );
+ ];
foreach ($violations->getByFields($field_names) as $violation) {
list($field_name) = explode('.', $violation->getPropertyPath(), 2);
$form_state->setErrorByName($field_name, $violation->getMessage());
diff --git a/core/modules/user/src/AccountSettingsForm.php b/core/modules/user/src/AccountSettingsForm.php
index 1e5cd4980e5..eacc37857c7 100644
--- a/core/modules/user/src/AccountSettingsForm.php
+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -85,25 +85,25 @@ class AccountSettingsForm extends ConfigFormBase {
$form['#attached']['library'][] = 'user/drupal.user.admin';
// Settings for anonymous users.
- $form['anonymous_settings'] = array(
+ $form['anonymous_settings'] = [
'#type' => 'details',
'#title' => $this->t('Anonymous users'),
'#open' => TRUE,
- );
- $form['anonymous_settings']['anonymous'] = array(
+ ];
+ $form['anonymous_settings']['anonymous'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#default_value' => $config->get('anonymous'),
'#description' => $this->t('The name used to indicate anonymous users.'),
'#required' => TRUE,
- );
+ ];
// Administrative role option.
- $form['admin_role'] = array(
+ $form['admin_role'] = [
'#type' => 'details',
'#title' => $this->t('Administrator role'),
'#open' => TRUE,
- );
+ ];
// Do not allow users to set the anonymous or authenticated user roles as the
// administrator role.
$roles = user_role_names(TRUE);
@@ -114,7 +114,7 @@ class AccountSettingsForm extends ConfigFormBase {
->execute();
$default_value = reset($admin_roles);
- $form['admin_role']['user_admin_role'] = array(
+ $form['admin_role']['user_admin_role'] = [
'#type' => 'select',
'#title' => $this->t('Administrator role'),
'#empty_value' => '',
@@ -124,53 +124,53 @@ class AccountSettingsForm extends ConfigFormBase {
// Don't allow to select a single admin role in case multiple roles got
// marked as admin role already.
'#access' => count($admin_roles) <= 1,
- );
+ ];
// @todo Remove this check once language settings are generalized.
if ($this->moduleHandler->moduleExists('content_translation')) {
- $form['language'] = array(
+ $form['language'] = [
'#type' => 'details',
'#title' => $this->t('Language settings'),
'#open' => TRUE,
'#tree' => TRUE,
- );
+ ];
$form_state->set(['content_translation', 'key'], 'language');
$form['language'] += content_translation_enable_widget('user', 'user', $form, $form_state);
}
// User registration settings.
- $form['registration_cancellation'] = array(
+ $form['registration_cancellation'] = [
'#type' => 'details',
'#title' => $this->t('Registration and cancellation'),
'#open' => TRUE,
- );
- $form['registration_cancellation']['user_register'] = array(
+ ];
+ $form['registration_cancellation']['user_register'] = [
'#type' => 'radios',
'#title' => $this->t('Who can register accounts?'),
'#default_value' => $config->get('register'),
- '#options' => array(
+ '#options' => [
USER_REGISTER_ADMINISTRATORS_ONLY => $this->t('Administrators only'),
USER_REGISTER_VISITORS => $this->t('Visitors'),
USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL => $this->t('Visitors, but administrator approval is required'),
- )
- );
- $form['registration_cancellation']['user_email_verification'] = array(
+ ]
+ ];
+ $form['registration_cancellation']['user_email_verification'] = [
'#type' => 'checkbox',
'#title' => $this->t('Require email verification when a visitor creates an account'),
'#default_value' => $config->get('verify_mail'),
'#description' => $this->t('New users will be required to validate their email address prior to logging into the site, and will be assigned a system-generated password. With this setting disabled, users will be logged in immediately upon registering, and may select their own passwords during registration.')
- );
- $form['registration_cancellation']['user_password_strength'] = array(
+ ];
+ $form['registration_cancellation']['user_password_strength'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable password strength indicator'),
'#default_value' => $config->get('password_strength'),
- );
- $form['registration_cancellation']['user_cancel_method'] = array(
+ ];
+ $form['registration_cancellation']['user_cancel_method'] = [
'#type' => 'radios',
'#title' => $this->t('When cancelling a user account'),
'#default_value' => $config->get('cancel_method'),
- '#description' => $this->t('Users with the %select-cancel-method or %administer-users <a href=":permissions-url">permissions</a> can override this default method.', array('%select-cancel-method' => $this->t('Select method for cancelling account'), '%administer-users' => $this->t('Administer users'), ':permissions-url' => $this->url('user.admin_permissions'))),
- );
+ '#description' => $this->t('Users with the %select-cancel-method or %administer-users <a href=":permissions-url">permissions</a> can override this default method.', ['%select-cancel-method' => $this->t('Select method for cancelling account'), '%administer-users' => $this->t('Administer users'), ':permissions-url' => $this->url('user.admin_permissions')]),
+ ];
$form['registration_cancellation']['user_cancel_method'] += user_cancel_methods();
foreach (Element::children($form['registration_cancellation']['user_cancel_method']) as $key) {
// All account cancellation methods that specify #access cannot be
@@ -182,239 +182,239 @@ class AccountSettingsForm extends ConfigFormBase {
}
// Default notifications address.
- $form['mail_notification_address'] = array(
+ $form['mail_notification_address'] = [
'#type' => 'email',
'#title' => $this->t('Notification email address'),
'#default_value' => $site_config->get('mail_notification'),
- '#description' => $this->t("The email address to be used as the 'from' address for all account notifications listed below. If <em>'Visitors, but administrator approval is required'</em> is selected above, a notification email will also be sent to this address for any new registrations. Leave empty to use the default system email address <em>(%site-email).</em>", array('%site-email' => $site_config->get('mail'))),
+ '#description' => $this->t("The email address to be used as the 'from' address for all account notifications listed below. If <em>'Visitors, but administrator approval is required'</em> is selected above, a notification email will also be sent to this address for any new registrations. Leave empty to use the default system email address <em>(%site-email).</em>", ['%site-email' => $site_config->get('mail')]),
'#maxlength' => 180,
- );
+ ];
- $form['email'] = array(
+ $form['email'] = [
'#type' => 'vertical_tabs',
'#title' => $this->t('Emails'),
- );
+ ];
// These email tokens are shared for all settings, so just define
// the list once to help ensure they stay in sync.
$email_token_help = $this->t('Available variables are: [site:name], [site:url], [user:display-name], [user:account-name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].');
- $form['email_admin_created'] = array(
+ $form['email_admin_created'] = [
'#type' => 'details',
'#title' => $this->t('Welcome (new user created by administrator)'),
'#open' => $config->get('register') == USER_REGISTER_ADMINISTRATORS_ONLY,
'#description' => $this->t('Edit the welcome email messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_admin_created']['user_mail_register_admin_created_subject'] = array(
+ ];
+ $form['email_admin_created']['user_mail_register_admin_created_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('register_admin_created.subject'),
'#maxlength' => 180,
- );
- $form['email_admin_created']['user_mail_register_admin_created_body'] = array(
+ ];
+ $form['email_admin_created']['user_mail_register_admin_created_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('register_admin_created.body'),
'#rows' => 15,
- );
+ ];
- $form['email_pending_approval'] = array(
+ $form['email_pending_approval'] = [
'#type' => 'details',
'#title' => $this->t('Welcome (awaiting approval)'),
'#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
'#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when administrative approval is required.') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_pending_approval']['user_mail_register_pending_approval_subject'] = array(
+ ];
+ $form['email_pending_approval']['user_mail_register_pending_approval_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('register_pending_approval.subject'),
'#maxlength' => 180,
- );
- $form['email_pending_approval']['user_mail_register_pending_approval_body'] = array(
+ ];
+ $form['email_pending_approval']['user_mail_register_pending_approval_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('register_pending_approval.body'),
'#rows' => 8,
- );
+ ];
- $form['email_pending_approval_admin'] = array(
+ $form['email_pending_approval_admin'] = [
'#type' => 'details',
'#title' => $this->t('Admin (user awaiting approval)'),
'#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
'#description' => $this->t('Edit the email notifying the site administrator that there are new members awaiting administrative approval.') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_pending_approval_admin']['register_pending_approval_admin_subject'] = array(
+ ];
+ $form['email_pending_approval_admin']['register_pending_approval_admin_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('register_pending_approval_admin.subject'),
'#maxlength' => 180,
- );
- $form['email_pending_approval_admin']['register_pending_approval_admin_body'] = array(
+ ];
+ $form['email_pending_approval_admin']['register_pending_approval_admin_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('register_pending_approval_admin.body'),
'#rows' => 8,
- );
+ ];
- $form['email_no_approval_required'] = array(
+ $form['email_no_approval_required'] = [
'#type' => 'details',
'#title' => $this->t('Welcome (no approval required)'),
'#open' => $config->get('register') == USER_REGISTER_VISITORS,
'#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when no administrator approval is required.') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_no_approval_required']['user_mail_register_no_approval_required_subject'] = array(
+ ];
+ $form['email_no_approval_required']['user_mail_register_no_approval_required_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('register_no_approval_required.subject'),
'#maxlength' => 180,
- );
- $form['email_no_approval_required']['user_mail_register_no_approval_required_body'] = array(
+ ];
+ $form['email_no_approval_required']['user_mail_register_no_approval_required_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('register_no_approval_required.body'),
'#rows' => 15,
- );
+ ];
- $form['email_password_reset'] = array(
+ $form['email_password_reset'] = [
'#type' => 'details',
'#title' => $this->t('Password recovery'),
'#description' => $this->t('Edit the email messages sent to users who request a new password.') . ' ' . $email_token_help,
'#group' => 'email',
'#weight' => 10,
- );
- $form['email_password_reset']['user_mail_password_reset_subject'] = array(
+ ];
+ $form['email_password_reset']['user_mail_password_reset_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('password_reset.subject'),
'#maxlength' => 180,
- );
- $form['email_password_reset']['user_mail_password_reset_body'] = array(
+ ];
+ $form['email_password_reset']['user_mail_password_reset_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('password_reset.body'),
'#rows' => 12,
- );
+ ];
- $form['email_activated'] = array(
+ $form['email_activated'] = [
'#type' => 'details',
'#title' => $this->t('Account activation'),
'#description' => $this->t('Enable and edit email messages sent to users upon account activation (when an administrator activates an account of a user who has already registered, on a site where administrative approval is required).') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_activated']['user_mail_status_activated_notify'] = array(
+ ];
+ $form['email_activated']['user_mail_status_activated_notify'] = [
'#type' => 'checkbox',
'#title' => $this->t('Notify user when account is activated'),
'#default_value' => $config->get('notify.status_activated'),
- );
- $form['email_activated']['settings'] = array(
+ ];
+ $form['email_activated']['settings'] = [
'#type' => 'container',
- '#states' => array(
+ '#states' => [
// Hide the additional settings when this email is disabled.
- 'invisible' => array(
- 'input[name="user_mail_status_activated_notify"]' => array('checked' => FALSE),
- ),
- ),
- );
- $form['email_activated']['settings']['user_mail_status_activated_subject'] = array(
+ 'invisible' => [
+ 'input[name="user_mail_status_activated_notify"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+ $form['email_activated']['settings']['user_mail_status_activated_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('status_activated.subject'),
'#maxlength' => 180,
- );
- $form['email_activated']['settings']['user_mail_status_activated_body'] = array(
+ ];
+ $form['email_activated']['settings']['user_mail_status_activated_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('status_activated.body'),
'#rows' => 15,
- );
+ ];
- $form['email_blocked'] = array(
+ $form['email_blocked'] = [
'#type' => 'details',
'#title' => $this->t('Account blocked'),
'#description' => $this->t('Enable and edit email messages sent to users when their accounts are blocked.') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_blocked']['user_mail_status_blocked_notify'] = array(
+ ];
+ $form['email_blocked']['user_mail_status_blocked_notify'] = [
'#type' => 'checkbox',
'#title' => $this->t('Notify user when account is blocked'),
'#default_value' => $config->get('notify.status_blocked'),
- );
- $form['email_blocked']['settings'] = array(
+ ];
+ $form['email_blocked']['settings'] = [
'#type' => 'container',
- '#states' => array(
+ '#states' => [
// Hide the additional settings when the blocked email is disabled.
- 'invisible' => array(
- 'input[name="user_mail_status_blocked_notify"]' => array('checked' => FALSE),
- ),
- ),
- );
- $form['email_blocked']['settings']['user_mail_status_blocked_subject'] = array(
+ 'invisible' => [
+ 'input[name="user_mail_status_blocked_notify"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+ $form['email_blocked']['settings']['user_mail_status_blocked_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('status_blocked.subject'),
'#maxlength' => 180,
- );
- $form['email_blocked']['settings']['user_mail_status_blocked_body'] = array(
+ ];
+ $form['email_blocked']['settings']['user_mail_status_blocked_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('status_blocked.body'),
'#rows' => 3,
- );
+ ];
- $form['email_cancel_confirm'] = array(
+ $form['email_cancel_confirm'] = [
'#type' => 'details',
'#title' => $this->t('Account cancellation confirmation'),
'#description' => $this->t('Edit the email messages sent to users when they attempt to cancel their accounts.') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_cancel_confirm']['user_mail_cancel_confirm_subject'] = array(
+ ];
+ $form['email_cancel_confirm']['user_mail_cancel_confirm_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('cancel_confirm.subject'),
'#maxlength' => 180,
- );
- $form['email_cancel_confirm']['user_mail_cancel_confirm_body'] = array(
+ ];
+ $form['email_cancel_confirm']['user_mail_cancel_confirm_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('cancel_confirm.body'),
'#rows' => 3,
- );
+ ];
- $form['email_canceled'] = array(
+ $form['email_canceled'] = [
'#type' => 'details',
'#title' => $this->t('Account canceled'),
'#description' => $this->t('Enable and edit email messages sent to users when their accounts are canceled.') . ' ' . $email_token_help,
'#group' => 'email',
- );
- $form['email_canceled']['user_mail_status_canceled_notify'] = array(
+ ];
+ $form['email_canceled']['user_mail_status_canceled_notify'] = [
'#type' => 'checkbox',
'#title' => $this->t('Notify user when account is canceled'),
'#default_value' => $config->get('notify.status_canceled'),
- );
- $form['email_canceled']['settings'] = array(
+ ];
+ $form['email_canceled']['settings'] = [
'#type' => 'container',
- '#states' => array(
+ '#states' => [
// Hide the settings when the cancel notify checkbox is disabled.
- 'invisible' => array(
- 'input[name="user_mail_status_canceled_notify"]' => array('checked' => FALSE),
- ),
- ),
- );
- $form['email_canceled']['settings']['user_mail_status_canceled_subject'] = array(
+ 'invisible' => [
+ 'input[name="user_mail_status_canceled_notify"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+ $form['email_canceled']['settings']['user_mail_status_canceled_subject'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $mail_config->get('status_canceled.subject'),
'#maxlength' => 180,
- );
- $form['email_canceled']['settings']['user_mail_status_canceled_body'] = array(
+ ];
+ $form['email_canceled']['settings']['user_mail_status_canceled_body'] = [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $mail_config->get('status_canceled.body'),
'#rows' => 3,
- );
+ ];
return $form;
}
diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php
index 779cf90fbe0..be15fac4ab8 100644
--- a/core/modules/user/src/Controller/UserController.php
+++ b/core/modules/user/src/Controller/UserController.php
@@ -121,7 +121,7 @@ class UserController extends ControllerBase {
/** @var \Drupal\user\UserInterface $reset_link_user */
if ($reset_link_user = $this->userStorage->load($uid)) {
drupal_set_message($this->t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href=":logout">log out</a> and try using the link again.',
- array('%other_user' => $account->getUsername(), '%resetting_user' => $reset_link_user->getUsername(), ':logout' => $this->url('user.logout'))), 'warning');
+ ['%other_user' => $account->getUsername(), '%resetting_user' => $reset_link_user->getUsername(), ':logout' => $this->url('user.logout')]), 'warning');
}
else {
// Invalid one-time link specifies an unknown user.
@@ -254,7 +254,7 @@ class UserController extends ControllerBase {
* Returns a redirect to the profile of the currently logged in user.
*/
public function userPage() {
- return $this->redirect('entity.user.canonical', array('user' => $this->currentUser()->id()));
+ return $this->redirect('entity.user.canonical', ['user' => $this->currentUser()->id()]);
}
/**
@@ -305,9 +305,9 @@ class UserController extends ControllerBase {
if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) {
// Validate expiration and hashed password/login.
if ($timestamp <= $current && $current - $timestamp < $timeout && $user->id() && $timestamp >= $user->getLastLoginTime() && Crypt::hashEquals($hashed_pass, user_pass_rehash($user, $timestamp))) {
- $edit = array(
+ $edit = [
'user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : $this->config('user.settings')->get('notify.status_canceled'),
- );
+ ];
user_cancel($edit, $user->id(), $account_data['cancel_method']);
// Since user_cancel() is not invoked via Form API, batch processing
// needs to be invoked manually and should redirect to the front page
diff --git a/core/modules/user/src/Entity/Role.php b/core/modules/user/src/Entity/Role.php
index a0b709c35bf..0e7ef0e5cbf 100644
--- a/core/modules/user/src/Entity/Role.php
+++ b/core/modules/user/src/Entity/Role.php
@@ -72,7 +72,7 @@ class Role extends ConfigEntityBase implements RoleInterface {
*
* @var array
*/
- protected $permissions = array();
+ protected $permissions = [];
/**
* An indicator whether the role has all permissions.
@@ -136,7 +136,7 @@ class Role extends ConfigEntityBase implements RoleInterface {
if ($this->isAdmin()) {
return $this;
}
- $this->permissions = array_diff($this->permissions, array($permission));
+ $this->permissions = array_diff($this->permissions, [$permission]);
return $this;
}
diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php
index 062af442518..38f0f39845e 100644
--- a/core/modules/user/src/Entity/User.php
+++ b/core/modules/user/src/Entity/User.php
@@ -82,13 +82,13 @@ class User extends ContentEntityBase implements UserInterface {
// Make sure that the authenticated/anonymous roles are not persisted.
foreach ($this->get('roles') as $index => $item) {
- if (in_array($item->target_id, array(RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID))) {
+ if (in_array($item->target_id, [RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID])) {
$this->get('roles')->offsetUnset($index);
}
}
// Store account cancellation information.
- foreach (array('user_cancel_method', 'user_cancel_notify') as $key) {
+ foreach (['user_cancel_method', 'user_cancel_notify'] as $key) {
if (isset($this->{$key})) {
\Drupal::service('user.data')->set('user', $this->id(), substr($key, 5), $this->{$key});
}
@@ -140,7 +140,7 @@ class User extends ContentEntityBase implements UserInterface {
* {@inheritdoc}
*/
public function getRoles($exclude_locked_roles = FALSE) {
- $roles = array();
+ $roles = [];
// Users with an ID always have the authenticated user role.
if (!$exclude_locked_roles) {
@@ -186,7 +186,7 @@ class User extends ContentEntityBase implements UserInterface {
* {@inheritdoc}
*/
public function removeRole($rid) {
- $this->set('roles', array_diff($this->getRoles(TRUE), array($rid)));
+ $this->set('roles', array_diff($this->getRoles(TRUE), [$rid]));
}
/**
@@ -445,9 +445,9 @@ class User extends ContentEntityBase implements UserInterface {
->setDescription(t("The user's preferred language code for receiving emails and viewing the site."))
// @todo: Define this via an options provider once
// https://www.drupal.org/node/2329937 is completed.
- ->addPropertyConstraints('value', array(
- 'AllowedValues' => array('callback' => __CLASS__ . '::getAllowedConfigurableLanguageCodes'),
- ));
+ ->addPropertyConstraints('value', [
+ 'AllowedValues' => ['callback' => __CLASS__ . '::getAllowedConfigurableLanguageCodes'],
+ ]);
$fields['preferred_admin_langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Preferred admin language code'))
@@ -455,12 +455,12 @@ class User extends ContentEntityBase implements UserInterface {
// @todo: A default value of NULL is ignored, so we have to specify
// an empty field item structure instead. Fix this in
// https://www.drupal.org/node/2318605.
- ->setDefaultValue(array(0 => array ('value' => NULL)))
+ ->setDefaultValue([0 => ['value' => NULL]])
// @todo: Define this via an options provider once
// https://www.drupal.org/node/2329937 is completed.
- ->addPropertyConstraints('value', array(
- 'AllowedValues' => array('callback' => __CLASS__ . '::getAllowedConfigurableLanguageCodes'),
- ));
+ ->addPropertyConstraints('value', [
+ 'AllowedValues' => ['callback' => __CLASS__ . '::getAllowedConfigurableLanguageCodes'],
+ ]);
// The name should not vary per language. The username is the visual
// identifier for a user and needs to be consistent in all languages.
@@ -468,12 +468,12 @@ class User extends ContentEntityBase implements UserInterface {
->setLabel(t('Name'))
->setDescription(t('The name of this user.'))
->setRequired(TRUE)
- ->setConstraints(array(
+ ->setConstraints([
// No Length constraint here because the UserName constraint also covers
// that.
- 'UserName' => array(),
- 'UserNameUnique' => array(),
- ));
+ 'UserName' => [],
+ 'UserNameUnique' => [],
+ ]);
$fields['name']->getItemDefinition()->setClass('\Drupal\user\UserNameItem');
$fields['pass'] = BaseFieldDefinition::create('password')
@@ -495,9 +495,9 @@ class User extends ContentEntityBase implements UserInterface {
->setSetting('max_length', 32)
// @todo: Define this via an options provider once
// https://www.drupal.org/node/2329937 is completed.
- ->addPropertyConstraints('value', array(
- 'AllowedValues' => array('callback' => __CLASS__ . '::getAllowedTimezones'),
- ));
+ ->addPropertyConstraints('value', [
+ 'AllowedValues' => ['callback' => __CLASS__ . '::getAllowedTimezones'],
+ ]);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('User status'))
diff --git a/core/modules/user/src/Form/UserCancelForm.php b/core/modules/user/src/Form/UserCancelForm.php
index 0ab89335b9a..14c553c3b78 100644
--- a/core/modules/user/src/Form/UserCancelForm.php
+++ b/core/modules/user/src/Form/UserCancelForm.php
@@ -31,7 +31,7 @@ class UserCancelForm extends ContentEntityConfirmFormBase {
if ($this->entity->id() == $this->currentUser()->id()) {
return $this->t('Are you sure you want to cancel your account?');
}
- return $this->t('Are you sure you want to cancel the account %name?', array('%name' => $this->entity->label()));
+ return $this->t('Are you sure you want to cancel the account %name?', ['%name' => $this->entity->label()]);
}
/**
@@ -74,43 +74,43 @@ class UserCancelForm extends ContentEntityConfirmFormBase {
// Display account cancellation method selection, if allowed.
$admin_access = $user->hasPermission('administer users');
- $form['user_cancel_method'] = array(
+ $form['user_cancel_method'] = [
'#type' => 'radios',
'#title' => ($this->entity->id() == $user->id() ? $this->t('When cancelling your account') : $this->t('When cancelling the account')),
'#access' => $admin_access || $user->hasPermission('select account cancellation method'),
- );
+ ];
$form['user_cancel_method'] += $this->cancelMethods;
// Allow user administrators to skip the account cancellation confirmation
// mail (by default), as long as they do not attempt to cancel their own
// account.
$override_access = $admin_access && ($this->entity->id() != $user->id());
- $form['user_cancel_confirm'] = array(
+ $form['user_cancel_confirm'] = [
'#type' => 'checkbox',
'#title' => $this->t('Require email confirmation to cancel account'),
'#default_value' => !$override_access,
'#access' => $override_access,
'#description' => $this->t('When enabled, the user must confirm the account cancellation via email.'),
- );
+ ];
// Also allow to send account canceled notification mail, if enabled.
$default_notify = $this->config('user.settings')->get('notify.status_canceled');
- $form['user_cancel_notify'] = array(
+ $form['user_cancel_notify'] = [
'#type' => 'checkbox',
'#title' => $this->t('Notify user when account is canceled'),
'#default_value' => ($override_access ? FALSE : $default_notify),
'#access' => $override_access && $default_notify,
'#description' => $this->t('When enabled, the user will receive an email notification after the account has been canceled.'),
- );
+ ];
// Always provide entity id in the same form key as in the entity edit form.
- $form['uid'] = array('#type' => 'value', '#value' => $this->entity->id());
+ $form['uid'] = ['#type' => 'value', '#value' => $this->entity->id()];
// Store the user permissions so that it can be altered in hook_form_alter()
// if desired.
- $form['access'] = array(
+ $form['access'] = [
'#type' => 'value',
'#value' => $user->hasPermission('administer users'),
- );
+ ];
$form = parent::buildForm($form, $form_state);
@@ -138,11 +138,11 @@ class UserCancelForm extends ContentEntityConfirmFormBase {
$this->entity->save();
_user_mail_notify('cancel_confirm', $this->entity);
drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your email address.'));
- $this->logger('user')->notice('Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'));
+ $this->logger('user')->notice('Sent account cancellation request to %name %email.', ['%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>']);
$form_state->setRedirect(
'entity.user.canonical',
- array('user' => $this->entity->id())
+ ['user' => $this->entity->id()]
);
}
}
diff --git a/core/modules/user/src/Form/UserLoginForm.php b/core/modules/user/src/Form/UserLoginForm.php
index 43b29e545a6..25a54ec4b72 100644
--- a/core/modules/user/src/Form/UserLoginForm.php
+++ b/core/modules/user/src/Form/UserLoginForm.php
@@ -88,31 +88,31 @@ class UserLoginForm extends FormBase {
$config = $this->config('system.site');
// Display login form:
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Username'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
- '#description' => $this->t('Enter your @s username.', array('@s' => $config->get('name'))),
+ '#description' => $this->t('Enter your @s username.', ['@s' => $config->get('name')]),
'#required' => TRUE,
- '#attributes' => array(
+ '#attributes' => [
'autocorrect' => 'none',
'autocapitalize' => 'none',
'spellcheck' => 'false',
'autofocus' => 'autofocus',
- ),
- );
+ ],
+ ];
- $form['pass'] = array(
+ $form['pass'] = [
'#type' => 'password',
'#title' => $this->t('Password'),
'#size' => 60,
'#description' => $this->t('Enter the password that accompanies your username.'),
'#required' => TRUE,
- );
+ ];
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Log in'));
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->t('Log in')];
$form['#validate'][] = '::validateName';
$form['#validate'][] = '::validateAuthentication';
@@ -133,7 +133,7 @@ class UserLoginForm extends FormBase {
if (!$this->getRequest()->request->has('destination')) {
$form_state->setRedirect(
'entity.user.canonical',
- array('user' => $account->id())
+ ['user' => $account->id()]
);
}
else {
@@ -149,7 +149,7 @@ class UserLoginForm extends FormBase {
public function validateName(array &$form, FormStateInterface $form_state) {
if (!$form_state->isValueEmpty('name') && user_is_blocked($form_state->getValue('name'))) {
// Blocked in user administration.
- $form_state->setErrorByName('name', $this->t('The username %name has not been activated or is blocked.', array('%name' => $form_state->getValue('name'))));
+ $form_state->setErrorByName('name', $this->t('The username %name has not been activated or is blocked.', ['%name' => $form_state->getValue('name')]));
}
}
@@ -171,7 +171,7 @@ class UserLoginForm extends FormBase {
$form_state->set('flood_control_triggered', 'ip');
return;
}
- $accounts = $this->userStorage->loadByProperties(array('name' => $form_state->getValue('name'), 'status' => 1));
+ $accounts = $this->userStorage->loadByProperties(['name' => $form_state->getValue('name'), 'status' => 1]);
$account = reset($accounts);
if ($account) {
if ($flood_config->get('uid_only')) {
@@ -218,11 +218,11 @@ class UserLoginForm extends FormBase {
if ($flood_control_triggered = $form_state->get('flood_control_triggered')) {
if ($flood_control_triggered == 'user') {
- $form_state->setErrorByName('name', $this->formatPlural($flood_config->get('user_limit'), 'There has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', 'There have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', array(':url' => $this->url('user.pass'))));
+ $form_state->setErrorByName('name', $this->formatPlural($flood_config->get('user_limit'), 'There has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', 'There have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => $this->url('user.pass')]));
}
else {
// We did not find a uid, so the limit is IP-based.
- $form_state->setErrorByName('name', $this->t('Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', array(':url' => $this->url('user.pass'))));
+ $form_state->setErrorByName('name', $this->t('Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => $this->url('user.pass')]));
}
}
else {
@@ -231,16 +231,16 @@ class UserLoginForm extends FormBase {
// $form_state->getValue() may have been modified by validation
// handlers that ran earlier than this one.
$user_input = $form_state->getUserInput();
- $query = isset($user_input['name']) ? array('name' => $user_input['name']) : array();
- $form_state->setErrorByName('name', $this->t('Unrecognized username or password. <a href=":password">Forgot your password?</a>', array(':password' => $this->url('user.pass', [], array('query' => $query)))));
- $accounts = $this->userStorage->loadByProperties(array('name' => $form_state->getValue('name')));
+ $query = isset($user_input['name']) ? ['name' => $user_input['name']] : [];
+ $form_state->setErrorByName('name', $this->t('Unrecognized username or password. <a href=":password">Forgot your password?</a>', [':password' => $this->url('user.pass', [], ['query' => $query])]));
+ $accounts = $this->userStorage->loadByProperties(['name' => $form_state->getValue('name')]);
if (!empty($accounts)) {
- $this->logger('user')->notice('Login attempt failed for %user.', array('%user' => $form_state->getValue('name')));
+ $this->logger('user')->notice('Login attempt failed for %user.', ['%user' => $form_state->getValue('name')]);
}
else {
// If the username entered is not a valid user,
// only store the IP address.
- $this->logger('user')->notice('Login attempt failed from %ip.', array('%ip' => $this->getRequest()->getClientIp()));
+ $this->logger('user')->notice('Login attempt failed from %ip.', ['%ip' => $this->getRequest()->getClientIp()]);
}
}
}
diff --git a/core/modules/user/src/Form/UserMultipleCancelConfirm.php b/core/modules/user/src/Form/UserMultipleCancelConfirm.php
index a97f803ac91..62a64e5d2b0 100644
--- a/core/modules/user/src/Form/UserMultipleCancelConfirm.php
+++ b/core/modules/user/src/Form/UserMultipleCancelConfirm.php
@@ -129,7 +129,7 @@ class UserMultipleCancelConfirm extends ConfirmFormBase {
// Output a notice that user 1 cannot be canceled.
if (isset($root)) {
$redirect = (count($accounts) == 1);
- $message = $this->t('The user account %name cannot be canceled.', array('%name' => $root->label()));
+ $message = $this->t('The user account %name cannot be canceled.', ['%name' => $root->label()]);
drupal_set_message($message, $redirect ? 'error' : 'warning');
// If only user 1 was selected, redirect to the overview.
if ($redirect) {
@@ -137,30 +137,30 @@ class UserMultipleCancelConfirm extends ConfirmFormBase {
}
}
- $form['operation'] = array('#type' => 'hidden', '#value' => 'cancel');
+ $form['operation'] = ['#type' => 'hidden', '#value' => 'cancel'];
- $form['user_cancel_method'] = array(
+ $form['user_cancel_method'] = [
'#type' => 'radios',
'#title' => $this->t('When cancelling these accounts'),
- );
+ ];
$form['user_cancel_method'] += user_cancel_methods();
// Allow to send the account cancellation confirmation mail.
- $form['user_cancel_confirm'] = array(
+ $form['user_cancel_confirm'] = [
'#type' => 'checkbox',
'#title' => $this->t('Require email confirmation to cancel account'),
'#default_value' => FALSE,
'#description' => $this->t('When enabled, the user must confirm the account cancellation via email.'),
- );
+ ];
// Also allow to send account canceled notification mail, if enabled.
- $form['user_cancel_notify'] = array(
+ $form['user_cancel_notify'] = [
'#type' => 'checkbox',
'#title' => $this->t('Notify user when account is canceled'),
'#default_value' => FALSE,
'#access' => $this->config('user.settings')->get('notify.status_canceled'),
'#description' => $this->t('When enabled, the user will receive an email notification after the account has been canceled.'),
- );
+ ];
$form = parent::buildForm($form, $form_state);
@@ -183,7 +183,7 @@ class UserMultipleCancelConfirm extends ConfirmFormBase {
}
// Prevent user administrators from deleting themselves without confirmation.
if ($uid == $current_user_id) {
- $admin_form_mock = array();
+ $admin_form_mock = [];
$admin_form_state = $form_state;
$admin_form_state->unsetValue('user_cancel_confirm');
// The $user global is not a complete user entity, so load the full
diff --git a/core/modules/user/src/Form/UserPasswordForm.php b/core/modules/user/src/Form/UserPasswordForm.php
index a89549a0edb..ea224fe439e 100644
--- a/core/modules/user/src/Form/UserPasswordForm.php
+++ b/core/modules/user/src/Form/UserPasswordForm.php
@@ -65,40 +65,40 @@ class UserPasswordForm extends FormBase {
* The request object.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Username or email address'),
'#size' => 60,
'#maxlength' => max(USERNAME_MAX_LENGTH, Email::EMAIL_MAX_LENGTH),
'#required' => TRUE,
- '#attributes' => array(
+ '#attributes' => [
'autocorrect' => 'off',
'autocapitalize' => 'off',
'spellcheck' => 'false',
'autofocus' => 'autofocus',
- ),
- );
+ ],
+ ];
// Allow logged in users to request this also.
$user = $this->currentUser();
if ($user->isAuthenticated()) {
$form['name']['#type'] = 'value';
$form['name']['#value'] = $user->getEmail();
- $form['mail'] = array(
+ $form['mail'] = [
'#prefix' => '<p>',
- '#markup' => $this->t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the email.', array('%email' => $user->getEmail())),
+ '#markup' => $this->t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the email.', ['%email' => $user->getEmail()]),
'#suffix' => '</p>',
- );
+ ];
}
else {
- $form['mail'] = array(
+ $form['mail'] = [
'#prefix' => '<p>',
'#markup' => $this->t('Password reset instructions will be sent to your registered email address.'),
'#suffix' => '</p>',
- );
+ ];
$form['name']['#default_value'] = $this->getRequest()->query->get('name');
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit'));
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->t('Submit')];
$form['#cache']['contexts'][] = 'url.query_args';
return $form;
@@ -110,23 +110,23 @@ class UserPasswordForm extends FormBase {
public function validateForm(array &$form, FormStateInterface $form_state) {
$name = trim($form_state->getValue('name'));
// Try to load by email.
- $users = $this->userStorage->loadByProperties(array('mail' => $name));
+ $users = $this->userStorage->loadByProperties(['mail' => $name]);
if (empty($users)) {
// No success, try to load by name.
- $users = $this->userStorage->loadByProperties(array('name' => $name));
+ $users = $this->userStorage->loadByProperties(['name' => $name]);
}
$account = reset($users);
if ($account && $account->id()) {
// Blocked accounts cannot request a new password.
if (!$account->isActive()) {
- $form_state->setErrorByName('name', $this->t('%name is blocked or has not been activated yet.', array('%name' => $name)));
+ $form_state->setErrorByName('name', $this->t('%name is blocked or has not been activated yet.', ['%name' => $name]));
}
else {
- $form_state->setValueForElement(array('#parents' => array('account')), $account);
+ $form_state->setValueForElement(['#parents' => ['account']], $account);
}
}
else {
- $form_state->setErrorByName('name', $this->t('%name is not recognized as a username or an email address.', array('%name' => $name)));
+ $form_state->setErrorByName('name', $this->t('%name is not recognized as a username or an email address.', ['%name' => $name]));
}
}
@@ -140,7 +140,7 @@ class UserPasswordForm extends FormBase {
// Mail one time login URL and instructions using current language.
$mail = _user_mail_notify('password_reset', $account, $langcode);
if (!empty($mail)) {
- $this->logger('user')->notice('Password reset instructions mailed to %name at %email.', array('%name' => $account->getUsername(), '%email' => $account->getEmail()));
+ $this->logger('user')->notice('Password reset instructions mailed to %name at %email.', ['%name' => $account->getUsername(), '%email' => $account->getEmail()]);
drupal_set_message($this->t('Further instructions have been sent to your email address.'));
}
diff --git a/core/modules/user/src/Form/UserPasswordResetForm.php b/core/modules/user/src/Form/UserPasswordResetForm.php
index 1372415cf2d..ce8c7cca1d7 100644
--- a/core/modules/user/src/Form/UserPasswordResetForm.php
+++ b/core/modules/user/src/Form/UserPasswordResetForm.php
@@ -38,21 +38,21 @@ class UserPasswordResetForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, AccountInterface $user = NULL, $expiration_date = NULL, $timestamp = NULL, $hash = NULL) {
if ($expiration_date) {
- $form['message'] = array('#markup' => $this->t('<p>This is a one-time login for %user_name and will expire on %expiration_date.</p><p>Click on this button to log in to the site and change your password.</p>', array('%user_name' => $user->getUsername(), '%expiration_date' => $expiration_date)));
+ $form['message'] = ['#markup' => $this->t('<p>This is a one-time login for %user_name and will expire on %expiration_date.</p><p>Click on this button to log in to the site and change your password.</p>', ['%user_name' => $user->getUsername(), '%expiration_date' => $expiration_date])];
$form['#title'] = $this->t('Reset password');
}
else {
// No expiration for first time login.
- $form['message'] = array('#markup' => $this->t('<p>This is a one-time login for %user_name.</p><p>Click on this button to log in to the site and change your password.</p>', array('%user_name' => $user->getUsername())));
+ $form['message'] = ['#markup' => $this->t('<p>This is a one-time login for %user_name.</p><p>Click on this button to log in to the site and change your password.</p>', ['%user_name' => $user->getUsername()])];
$form['#title'] = $this->t('Set password');
}
- $form['help'] = array('#markup' => '<p>' . $this->t('This login can be used only once.') . '</p>');
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['help'] = ['#markup' => '<p>' . $this->t('This login can be used only once.') . '</p>'];
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Log in'),
- );
+ ];
$form['#action'] = Url::fromRoute('user.reset.login', [
'uid' => $user->id(),
'timestamp' => $timestamp,
diff --git a/core/modules/user/src/Form/UserPermissionsForm.php b/core/modules/user/src/Form/UserPermissionsForm.php
index 75bbaf23522..0b3da3b8a76 100644
--- a/core/modules/user/src/Form/UserPermissionsForm.php
+++ b/core/modules/user/src/Form/UserPermissionsForm.php
@@ -83,9 +83,9 @@ class UserPermissionsForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $role_names = array();
- $role_permissions = array();
- $admin_roles = array();
+ $role_names = [];
+ $role_permissions = [];
+ $admin_roles = [];
foreach ($this->getRoles() as $role_name => $role) {
// Retrieve role names for columns.
$role_names[$role_name] = $role->label();
@@ -95,79 +95,79 @@ class UserPermissionsForm extends FormBase {
}
// Store $role_names for use when saving the data.
- $form['role_names'] = array(
+ $form['role_names'] = [
'#type' => 'value',
'#value' => $role_names,
- );
+ ];
// Render role/permission overview:
$hide_descriptions = system_admin_compact_mode();
- $form['system_compact_link'] = array(
+ $form['system_compact_link'] = [
'#id' => FALSE,
'#type' => 'system_compact_link',
- );
+ ];
- $form['permissions'] = array(
+ $form['permissions'] = [
'#type' => 'table',
- '#header' => array($this->t('Permission')),
+ '#header' => [$this->t('Permission')],
'#id' => 'permissions',
'#attributes' => ['class' => ['permissions', 'js-permissions']],
'#sticky' => TRUE,
- );
+ ];
foreach ($role_names as $name) {
- $form['permissions']['#header'][] = array(
+ $form['permissions']['#header'][] = [
'data' => $name,
- 'class' => array('checkbox'),
- );
+ 'class' => ['checkbox'],
+ ];
}
$permissions = $this->permissionHandler->getPermissions();
- $permissions_by_provider = array();
+ $permissions_by_provider = [];
foreach ($permissions as $permission_name => $permission) {
$permissions_by_provider[$permission['provider']][$permission_name] = $permission;
}
foreach ($permissions_by_provider as $provider => $permissions) {
// Module name.
- $form['permissions'][$provider] = array(array(
- '#wrapper_attributes' => array(
+ $form['permissions'][$provider] = [[
+ '#wrapper_attributes' => [
'colspan' => count($role_names) + 1,
- 'class' => array('module'),
+ 'class' => ['module'],
'id' => 'module-' . $provider,
- ),
+ ],
'#markup' => $this->moduleHandler->getName($provider),
- ));
+ ]];
foreach ($permissions as $perm => $perm_item) {
// Fill in default values for the permission.
- $perm_item += array(
+ $perm_item += [
'description' => '',
'restrict access' => FALSE,
'warning' => !empty($perm_item['restrict access']) ? $this->t('Warning: Give to trusted roles only; this permission has security implications.') : '',
- );
- $form['permissions'][$perm]['description'] = array(
+ ];
+ $form['permissions'][$perm]['description'] = [
'#type' => 'inline_template',
'#template' => '<div class="permission"><span class="title">{{ title }}</span>{% if description or warning %}<div class="description">{% if warning %}<em class="permission-warning">{{ warning }}</em> {% endif %}{{ description }}</div>{% endif %}</div>',
- '#context' => array(
+ '#context' => [
'title' => $perm_item['title'],
- ),
- );
+ ],
+ ];
// Show the permission description.
if (!$hide_descriptions) {
$form['permissions'][$perm]['description']['#context']['description'] = $perm_item['description'];
$form['permissions'][$perm]['description']['#context']['warning'] = $perm_item['warning'];
}
foreach ($role_names as $rid => $name) {
- $form['permissions'][$perm][$rid] = array(
+ $form['permissions'][$perm][$rid] = [
'#title' => $name . ': ' . $perm_item['title'],
'#title_display' => 'invisible',
- '#wrapper_attributes' => array(
- 'class' => array('checkbox'),
- ),
+ '#wrapper_attributes' => [
+ 'class' => ['checkbox'],
+ ],
'#type' => 'checkbox',
'#default_value' => in_array($perm, $role_permissions[$rid]) ? 1 : 0,
- '#attributes' => array('class' => array('rid-' . $rid, 'js-rid-' . $rid)),
- '#parents' => array($rid, $perm),
- );
+ '#attributes' => ['class' => ['rid-' . $rid, 'js-rid-' . $rid]],
+ '#parents' => [$rid, $perm],
+ ];
// Show a column of disabled but checked checkboxes.
if ($admin_roles[$rid]) {
$form['permissions'][$perm][$rid]['#disabled'] = TRUE;
@@ -177,12 +177,12 @@ class UserPermissionsForm extends FormBase {
}
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save permissions'),
'#button_type' => 'primary',
- );
+ ];
$form['#attached']['library'][] = 'user/drupal.user.permissions';
diff --git a/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php b/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php
index 41ae8b8788c..4281a44b97b 100644
--- a/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php
+++ b/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php
@@ -21,7 +21,7 @@ class UserPermissionsRoleSpecificForm extends UserPermissionsForm {
* {@inheritdoc}
*/
protected function getRoles() {
- return array($this->userRole->id() => $this->userRole);
+ return [$this->userRole->id() => $this->userRole];
}
/**
diff --git a/core/modules/user/src/PermissionHandler.php b/core/modules/user/src/PermissionHandler.php
index d7179b65ec6..1f07b25d950 100644
--- a/core/modules/user/src/PermissionHandler.php
+++ b/core/modules/user/src/PermissionHandler.php
@@ -136,8 +136,8 @@ class PermissionHandler implements PermissionHandlerInterface {
* - provider: The provider of the permission.
*/
protected function buildPermissionsYaml() {
- $all_permissions = array();
- $all_callback_permissions = array();
+ $all_permissions = [];
+ $all_callback_permissions = [];
foreach ($this->getYamlDiscovery()->findAll() as $provider => $permissions) {
// The top-level 'permissions_callback' is a list of methods in controller
@@ -151,15 +151,15 @@ class PermissionHandler implements PermissionHandlerInterface {
// defaults can then get processed below.
foreach ($callback_permissions as $name => $callback_permission) {
if (!is_array($callback_permission)) {
- $callback_permission = array(
+ $callback_permission = [
'title' => $callback_permission,
- );
+ ];
}
- $callback_permission += array(
+ $callback_permission += [
'description' => NULL,
'provider' => $provider,
- );
+ ];
$all_callback_permissions[$name] = $callback_permission;
}
@@ -171,9 +171,9 @@ class PermissionHandler implements PermissionHandlerInterface {
foreach ($permissions as &$permission) {
if (!is_array($permission)) {
- $permission = array(
+ $permission = [
'title' => $permission,
- );
+ ];
}
$permission['title'] = $this->t($permission['title']);
$permission['description'] = isset($permission['description']) ? $this->t($permission['description']) : NULL;
@@ -198,7 +198,7 @@ class PermissionHandler implements PermissionHandlerInterface {
* - description: The description of the permission, defaults to NULL.
* - provider: The provider of the permission.
*/
- protected function sortPermissions(array $all_permissions = array()) {
+ protected function sortPermissions(array $all_permissions = []) {
// Get a list of all the modules providing permissions and sort by
// display name.
$modules = $this->getModuleNames();
@@ -221,7 +221,7 @@ class PermissionHandler implements PermissionHandlerInterface {
* Returns the human readable names of all modules keyed by machine name.
*/
protected function getModuleNames() {
- $modules = array();
+ $modules = [];
foreach (array_keys($this->moduleHandler->getModuleList()) as $module) {
$modules[$module] = $this->moduleHandler->getName($module);
}
diff --git a/core/modules/user/src/Plugin/Action/CancelUser.php b/core/modules/user/src/Plugin/Action/CancelUser.php
index 7c51f5fe166..140ef42e2f2 100644
--- a/core/modules/user/src/Plugin/Action/CancelUser.php
+++ b/core/modules/user/src/Plugin/Action/CancelUser.php
@@ -79,7 +79,7 @@ class CancelUser extends ActionBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public function execute($object = NULL) {
- $this->executeMultiple(array($object));
+ $this->executeMultiple([$object]);
}
/**
diff --git a/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php b/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php
index 02424bc3f44..de4c4040fec 100644
--- a/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php
+++ b/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php
@@ -49,9 +49,9 @@ abstract class ChangeUserRoleBase extends ConfigurableActionBase implements Cont
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
+ return [
'rid' => '',
- );
+ ];
}
/**
@@ -60,13 +60,13 @@ abstract class ChangeUserRoleBase extends ConfigurableActionBase implements Cont
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$roles = user_role_names(TRUE);
unset($roles[RoleInterface::AUTHENTICATED_ID]);
- $form['rid'] = array(
+ $form['rid'] = [
'#type' => 'radios',
'#title' => t('Role'),
'#options' => $roles,
'#default_value' => $this->configuration['rid'],
'#required' => TRUE,
- );
+ ];
return $form;
}
diff --git a/core/modules/user/src/Plugin/Block/UserLoginBlock.php b/core/modules/user/src/Plugin/Block/UserLoginBlock.php
index d7ff9da73c8..ed0e2eaf1a8 100644
--- a/core/modules/user/src/Plugin/Block/UserLoginBlock.php
+++ b/core/modules/user/src/Plugin/Block/UserLoginBlock.php
@@ -72,7 +72,7 @@ class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterfac
*/
protected function blockAccess(AccountInterface $account) {
$route_name = $this->routeMatch->getRouteName();
- if ($account->isAnonymous() && !in_array($route_name, array('user.login', 'user.logout'))) {
+ if ($account->isAnonymous() && !in_array($route_name, ['user.login', 'user.logout'])) {
return AccessResult::allowed()
->addCacheContexts(['route.name', 'user.roles:anonymous']);
}
@@ -96,7 +96,7 @@ class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterfac
$form['pass']['#size'] = 15;
$form['#action'] = $this->url('<current>', [], ['query' => $this->getDestinationArray(), 'external' => FALSE]);
// Build action links.
- $items = array();
+ $items = [];
if (\Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
$items['create_account'] = [
'#type' => 'link',
@@ -119,13 +119,13 @@ class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterfac
],
]),
];
- return array(
+ return [
'user_login_form' => $form,
- 'user_links' => array(
+ 'user_links' => [
'#theme' => 'item_list',
'#items' => $items,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/user/src/Plugin/Condition/UserRole.php b/core/modules/user/src/Plugin/Condition/UserRole.php
index ea69e143216..60b8b0e29c3 100644
--- a/core/modules/user/src/Plugin/Condition/UserRole.php
+++ b/core/modules/user/src/Plugin/Condition/UserRole.php
@@ -22,13 +22,13 @@ class UserRole extends ConditionPluginBase {
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- $form['roles'] = array(
+ $form['roles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('When the user has the following roles'),
'#default_value' => $this->configuration['roles'],
'#options' => array_map('\Drupal\Component\Utility\Html::escape', user_role_names()),
'#description' => $this->t('If you select no roles, the condition will evaluate to TRUE for all users.'),
- );
+ ];
return parent::buildConfigurationForm($form, $form_state);
}
@@ -36,9 +36,9 @@ class UserRole extends ConditionPluginBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array(
- 'roles' => array(),
- ) + parent::defaultConfiguration();
+ return [
+ 'roles' => [],
+ ] + parent::defaultConfiguration();
}
/**
@@ -62,10 +62,10 @@ class UserRole extends ConditionPluginBase {
$roles = reset($roles);
}
if (!empty($this->configuration['negate'])) {
- return $this->t('The user is not a member of @roles', array('@roles' => $roles));
+ return $this->t('The user is not a member of @roles', ['@roles' => $roles]);
}
else {
- return $this->t('The user is a member of @roles', array('@roles' => $roles));
+ return $this->t('The user is a member of @roles', ['@roles' => $roles]);
}
}
diff --git a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
index 6043c37208e..feec81b4682 100644
--- a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
+++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
@@ -87,51 +87,51 @@ class UserSelection extends DefaultSelection {
$selection_handler_settings = $this->configuration['handler_settings'];
// Merge in default values.
- $selection_handler_settings += array(
- 'filter' => array(
+ $selection_handler_settings += [
+ 'filter' => [
'type' => '_none',
- ),
+ ],
'include_anonymous' => TRUE,
- );
+ ];
- $form['include_anonymous'] = array(
+ $form['include_anonymous'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include the anonymous user.'),
'#default_value' => $selection_handler_settings['include_anonymous'],
- );
+ ];
// Add user specific filter options.
- $form['filter']['type'] = array(
+ $form['filter']['type'] = [
'#type' => 'select',
'#title' => $this->t('Filter by'),
- '#options' => array(
+ '#options' => [
'_none' => $this->t('- None -'),
'role' => $this->t('User role'),
- ),
+ ],
'#ajax' => TRUE,
- '#limit_validation_errors' => array(),
+ '#limit_validation_errors' => [],
'#default_value' => $selection_handler_settings['filter']['type'],
- );
+ ];
- $form['filter']['settings'] = array(
+ $form['filter']['settings'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('entity_reference-settings')),
- '#process' => array(array('\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem', 'formProcessMergeParent')),
- );
+ '#attributes' => ['class' => ['entity_reference-settings']],
+ '#process' => [['\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem', 'formProcessMergeParent']],
+ ];
if ($selection_handler_settings['filter']['type'] == 'role') {
// Merge in default values.
- $selection_handler_settings['filter'] += array(
+ $selection_handler_settings['filter'] += [
'role' => NULL,
- );
+ ];
- $form['filter']['settings']['role'] = array(
+ $form['filter']['settings']['role'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Restrict to the selected roles'),
'#required' => TRUE,
- '#options' => array_diff_key(user_role_names(TRUE), array(RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID)),
+ '#options' => array_diff_key(user_role_names(TRUE), [RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID]),
'#default_value' => $selection_handler_settings['filter']['role'],
- );
+ ];
}
$form += parent::buildConfigurationForm($form, $form_state);
@@ -240,7 +240,7 @@ class UserSelection extends DefaultSelection {
$value_part->condition('anonymous_name', $condition['value'], $condition['operator']);
$value_part->compile($this->connection, $query);
$or->condition((new Condition('AND'))
- ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => \Drupal::config('user.settings')->get('anonymous')))
+ ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + [':anonymous_name' => \Drupal::config('user.settings')->get('anonymous')])
->condition('base_table.uid', 0)
);
$query->condition($or);
diff --git a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php
index ede1615e5df..9f74d67d091 100644
--- a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php
+++ b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php
@@ -25,18 +25,18 @@ class AuthorFormatter extends EntityReferenceFormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
- $elements = array();
+ $elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
/** @var $referenced_user \Drupal\user\UserInterface */
- $elements[$delta] = array(
+ $elements[$delta] = [
'#theme' => 'username',
'#account' => $entity,
- '#link_options' => array('attributes' => array('rel' => 'author')),
- '#cache' => array(
+ '#link_options' => ['attributes' => ['rel' => 'author']],
+ '#cache' => [
'tags' => $entity->getCacheTags(),
- ),
- );
+ ],
+ ];
}
return $elements;
diff --git a/core/modules/user/src/Plugin/Search/UserSearch.php b/core/modules/user/src/Plugin/Search/UserSearch.php
index f8471211d7a..063d3ef1122 100644
--- a/core/modules/user/src/Plugin/Search/UserSearch.php
+++ b/core/modules/user/src/Plugin/Search/UserSearch.php
@@ -104,7 +104,7 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface {
* {@inheritdoc}
*/
public function execute() {
- $results = array();
+ $results = [];
if (!$this->isSearchExecutable()) {
return $results;
}
@@ -120,12 +120,12 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface {
$query = $this->database
->select('users_field_data', 'users')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
- $query->fields('users', array('uid'));
+ $query->fields('users', ['uid']);
$query->condition('default_langcode', 1);
if ($this->currentUser->hasPermission('administer users')) {
// Administrators can also search in the otherwise private email field,
// and they don't need to be restricted to only active users.
- $query->fields('users', array('mail'));
+ $query->fields('users', ['mail']);
$query->condition($query->orConditionGroup()
->condition('name', '%' . $keys . '%', 'LIKE')
->condition('mail', '%' . $keys . '%', 'LIKE')
@@ -144,10 +144,10 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface {
$accounts = $this->entityManager->getStorage('user')->loadMultiple($uids);
foreach ($accounts as $account) {
- $result = array(
+ $result = [
'title' => $account->getDisplayName(),
- 'link' => $account->url('canonical', array('absolute' => TRUE)),
- );
+ 'link' => $account->url('canonical', ['absolute' => TRUE]),
+ ];
if ($this->currentUser->hasPermission('administer users')) {
$result['title'] .= ' (' . $account->getEmail() . ')';
}
@@ -162,13 +162,13 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface {
* {@inheritdoc}
*/
public function getHelp() {
- $help = array('list' => array(
+ $help = ['list' => [
'#theme' => 'item_list',
- '#items' => array(
+ '#items' => [
$this->t('User search looks for user names and partial user names. Example: mar would match usernames mar, delmar, and maryjane.'),
$this->t('You can use * as a wildcard within your keyword. Example: m*r would match user names mar, delmar, and elementary.'),
- ),
- ));
+ ],
+ ]];
return $help;
}
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidator.php b/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidator.php
index 2bfdca4cabe..a8b12af8f44 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidator.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidator.php
@@ -86,7 +86,7 @@ class ProtectedUserFieldConstraintValidator extends ConstraintValidator implemen
$changed = $items->getValue() != $account_unchanged->get($field->getName())->getValue();
}
if ($changed && (!$account->checkExistingPassword($account_unchanged))) {
- $this->context->addViolation($constraint->message, array('%name' => $field->getLabel()));
+ $this->context->addViolation($constraint->message, ['%name' => $field->getLabel()]);
}
}
}
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
index fa714646b3c..9e4776bdcaf 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
@@ -54,7 +54,7 @@ class UserNameConstraintValidator extends ConstraintValidator {
$this->context->addViolation($constraint->illegalMessage);
}
if (Unicode::strlen($name) > USERNAME_MAX_LENGTH) {
- $this->context->addViolation($constraint->tooLongMessage, array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
+ $this->context->addViolation($constraint->tooLongMessage, ['%name' => $name, '%max' => USERNAME_MAX_LENGTH]);
}
}
diff --git a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php
index b11d8670b9e..7c2c81af969 100644
--- a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php
+++ b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php
@@ -77,7 +77,7 @@ class EntityUser extends EntityContentBase {
* {@inheritdoc}
* @throws \Drupal\migrate\MigrateException
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
// Do not overwrite the root account password.
if ($row->getDestinationProperty('uid') == 1) {
$row->removeDestinationProperty('pass');
@@ -88,7 +88,7 @@ class EntityUser extends EntityContentBase {
/**
* {@inheritdoc}
*/
- protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {
+ protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) {
// Do not overwrite the root account password.
if ($entity->id() != 1) {
// Set the pre_hashed password so that the PasswordItem field does not hash
diff --git a/core/modules/user/src/Plugin/migrate/destination/UserData.php b/core/modules/user/src/Plugin/migrate/destination/UserData.php
index 6ca60179aa5..7c48f93e6d3 100644
--- a/core/modules/user/src/Plugin/migrate/destination/UserData.php
+++ b/core/modules/user/src/Plugin/migrate/destination/UserData.php
@@ -56,7 +56,7 @@ class UserData extends DestinationBase implements ContainerFactoryPluginInterfac
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$uid = $row->getDestinationProperty('uid');
$module = $row->getDestinationProperty('module');
$key = $row->getDestinationProperty('key');
diff --git a/core/modules/user/src/Plugin/migrate/process/ConvertTokens.php b/core/modules/user/src/Plugin/migrate/process/ConvertTokens.php
index ce93c0e794a..ed95db27157 100644
--- a/core/modules/user/src/Plugin/migrate/process/ConvertTokens.php
+++ b/core/modules/user/src/Plugin/migrate/process/ConvertTokens.php
@@ -21,7 +21,7 @@ class ConvertTokens extends ProcessPluginBase {
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
- $tokens = array(
+ $tokens = [
'!site' => '[site:name]',
'!username' => '[user:name]',
'!mailto' => '[user:mail]',
@@ -32,7 +32,7 @@ class ConvertTokens extends ProcessPluginBase {
'!uri' => '[site:url]',
'!date' => '[date:medium]',
'!password' => '',
- );
+ ];
// Given that our source is a database column that could hold a NULL
// value, sometimes that filters down to here. str_replace() cannot
diff --git a/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php b/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php
index 6230f7b7bb6..6e16c59d5b2 100644
--- a/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php
+++ b/core/modules/user/src/Plugin/migrate/process/ProfileFieldSettings.php
@@ -17,7 +17,7 @@ class ProfileFieldSettings extends ProcessPluginBase {
* {@inheritdoc}
*/
public function transform($type, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
- $settings = array();
+ $settings = [];
switch ($type) {
case 'date':
$settings['datetime_type'] = 'date';
diff --git a/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php b/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php
index 36f65741d9d..7a67c466e3f 100644
--- a/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php
+++ b/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php
@@ -22,10 +22,10 @@ class UserUpdate8002 extends ProcessPluginBase {
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$rid = $row->getSourceProperty('rid');
- $map = array(
+ $map = [
1 => 'anonymous',
2 => 'authenticated',
- );
+ ];
return isset($map[$rid]) ? $map[$rid] : $value;
}
diff --git a/core/modules/user/src/Plugin/migrate/source/ProfileField.php b/core/modules/user/src/Plugin/migrate/source/ProfileField.php
index c2a6fe447d4..151d5017def 100644
--- a/core/modules/user/src/Plugin/migrate/source/ProfileField.php
+++ b/core/modules/user/src/Plugin/migrate/source/ProfileField.php
@@ -70,7 +70,7 @@ class ProfileField extends DrupalSqlBase {
// D6 profile checkboxes values are always 0 or 1 (with no labels), so we
// need to create two label-less options that will get 0 and 1 for their
// keys.
- $row->setSourceProperty('options', array(NULL, NULL));
+ $row->setSourceProperty('options', [NULL, NULL]);
}
return parent::prepareRow($row);
@@ -80,7 +80,7 @@ class ProfileField extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'fid' => $this->t('Primary Key: Unique profile field ID.'),
'title' => $this->t('Title of the field shown to the end user.'),
'name' => $this->t('Internal name of the field used in the form HTML and URLs.'),
@@ -94,7 +94,7 @@ class ProfileField extends DrupalSqlBase {
'visibility' => $this->t('The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)'),
'autocomplete' => $this->t('Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)'),
'options' => $this->t('List of options to be used in a list selection field.'),
- );
+ ];
}
/**
diff --git a/core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php b/core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php
index 746a76fd991..441fdc78c75 100644
--- a/core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php
+++ b/core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php
@@ -22,24 +22,24 @@ class UserPictureInstance extends DrupalSqlBase {
* {@inheritdoc}
*/
public function initializeIterator() {
- return new \ArrayIterator(array(
- array(
+ return new \ArrayIterator([
+ [
'id' => '',
'file_directory' => $this->variableGet('user_picture_path', 'pictures'),
'max_filesize' => $this->variableGet('user_picture_file_size', '30') . 'KB',
'max_resolution' => $this->variableGet('user_picture_dimensions', '85x85'),
- )));
+ ]]);
}
/**
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'file_directory' => 'The directory to store images..',
'max_filesize' => 'The maximum allowed file size in KBs.',
'max_resolution' => "The maximum resolution.",
- );
+ ];
}
/**
diff --git a/core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldValues.php b/core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldValues.php
index 0ccbbeb51d8..80db9df9696 100644
--- a/core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldValues.php
+++ b/core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldValues.php
@@ -21,7 +21,7 @@ class ProfileFieldValues extends DrupalSqlBase {
public function query() {
$query = $this->select('profile_values', 'pv')
->distinct()
- ->fields('pv', array('uid'));
+ ->fields('pv', ['uid']);
return $query;
}
@@ -32,9 +32,9 @@ class ProfileFieldValues extends DrupalSqlBase {
public function prepareRow(Row $row) {
// Find profile values for this row.
$query = $this->select('profile_values', 'pv')
- ->fields('pv', array('fid', 'value'));
+ ->fields('pv', ['fid', 'value']);
$query->leftJoin('profile_fields', 'pf', 'pf.fid=pv.fid');
- $query->fields('pf', array('name', 'type'));
+ $query->fields('pf', ['name', 'type']);
$query->condition('uid', $row->getSourceProperty('uid'));
$results = $query->execute();
@@ -43,14 +43,14 @@ class ProfileFieldValues extends DrupalSqlBase {
if ($profile_value['type'] == 'date') {
$date = unserialize($profile_value['value']);
$date = date('Y-m-d', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
- $row->setSourceProperty($profile_value['name'], array('value' => $date));
+ $row->setSourceProperty($profile_value['name'], ['value' => $date]);
}
elseif ($profile_value['type'] == 'list') {
// Explode by newline and comma.
$row->setSourceProperty($profile_value['name'], preg_split("/[\r\n,]+/", $profile_value['value']));
}
else {
- $row->setSourceProperty($profile_value['name'], array($profile_value['value']));
+ $row->setSourceProperty($profile_value['name'], [$profile_value['value']]);
}
}
@@ -61,16 +61,16 @@ class ProfileFieldValues extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'fid' => $this->t('Unique profile field ID.'),
'uid' => $this->t('The user Id.'),
'value' => $this->t('The value for this field.'),
- );
+ ];
$query = $this->select('profile_values', 'pv')
- ->fields('pv', array('fid', 'value'));
+ ->fields('pv', ['fid', 'value']);
$query->leftJoin('profile_fields', 'pf', 'pf.fid=pv.fid');
- $query->fields('pf', array('name', 'title'));
+ $query->fields('pf', ['name', 'title']);
$results = $query->execute();
foreach ($results as $profile) {
$fields[$profile['name']] = $this->t($profile['title']);
@@ -83,12 +83,12 @@ class ProfileFieldValues extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'uid' => array(
+ return [
+ 'uid' => [
'type' => 'integer',
'alias' => 'pv',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/user/src/Plugin/migrate/source/d6/Role.php b/core/modules/user/src/Plugin/migrate/source/d6/Role.php
index 2357c5c860e..82ad3e99325 100644
--- a/core/modules/user/src/Plugin/migrate/source/d6/Role.php
+++ b/core/modules/user/src/Plugin/migrate/source/d6/Role.php
@@ -19,14 +19,14 @@ class Role extends DrupalSqlBase {
*
* @var array
*/
- protected $filterPermissions = array();
+ protected $filterPermissions = [];
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('role', 'r')
- ->fields('r', array('rid', 'name'))
+ ->fields('r', ['rid', 'name'])
->orderBy('r.rid');
return $query;
}
@@ -35,10 +35,10 @@ class Role extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'rid' => $this->t('Role ID.'),
'name' => $this->t('The name of the user role.'),
- );
+ ];
}
/**
@@ -46,7 +46,7 @@ class Role extends DrupalSqlBase {
*/
protected function initializeIterator() {
$filter_roles = $this->select('filter_formats', 'f')
- ->fields('f', array('format', 'roles'))
+ ->fields('f', ['format', 'roles'])
->execute()
->fetchAllKeyed();
foreach ($filter_roles as $format => $roles) {
@@ -65,7 +65,7 @@ class Role extends DrupalSqlBase {
public function prepareRow(Row $row) {
$rid = $row->getSourceProperty('rid');
$permissions = $this->select('permission', 'p')
- ->fields('p', array('perm'))
+ ->fields('p', ['perm'])
->condition('rid', $rid)
->execute()
->fetchField();
diff --git a/core/modules/user/src/Plugin/migrate/source/d6/User.php b/core/modules/user/src/Plugin/migrate/source/d6/User.php
index 56f68bf8c80..c8e9d19a702 100644
--- a/core/modules/user/src/Plugin/migrate/source/d6/User.php
+++ b/core/modules/user/src/Plugin/migrate/source/d6/User.php
@@ -35,7 +35,7 @@ class User extends DrupalSqlBase {
// Profile fields.
if ($this->moduleExists('profile')) {
$fields += $this->select('profile_fields', 'pf')
- ->fields('pf', array('name', 'title'))
+ ->fields('pf', ['name', 'title'])
->execute()
->fetchAllKeyed();
}
@@ -49,7 +49,7 @@ class User extends DrupalSqlBase {
public function prepareRow(Row $row) {
// User roles.
$roles = $this->select('users_roles', 'ur')
- ->fields('ur', array('rid'))
+ ->fields('ur', ['rid'])
->condition('ur.uid', $row->getSourceProperty('uid'))
->execute()
->fetchCol();
@@ -60,7 +60,7 @@ class User extends DrupalSqlBase {
if ($row->hasSourceProperty('timezone_id') && $row->getSourceProperty('timezone_id')) {
if ($this->getDatabase()->schema()->tableExists('event_timezones')) {
$event_timezone = $this->select('event_timezones', 'e')
- ->fields('e', array('name'))
+ ->fields('e', ['name'])
->condition('e.timezone', $row->getSourceProperty('timezone_id'))
->execute()
->fetchField();
@@ -80,12 +80,12 @@ class User extends DrupalSqlBase {
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'uid' => array(
+ return [
+ 'uid' => [
'type' => 'integer',
'alias' => 'u',
- ),
- );
+ ],
+ ];
}
/**
@@ -95,7 +95,7 @@ class User extends DrupalSqlBase {
* Associative array having field name as key and description as value.
*/
protected function baseFields() {
- $fields = array(
+ $fields = [
'uid' => $this->t('User ID'),
'name' => $this->t('Username'),
'pass' => $this->t('Password'),
@@ -112,7 +112,7 @@ class User extends DrupalSqlBase {
'picture' => $this->t('Picture'),
'init' => $this->t('Init'),
'data' => $this->t('User data'),
- );
+ ];
// Possible field added by Date contributed module.
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
diff --git a/core/modules/user/src/Plugin/migrate/source/d6/UserPicture.php b/core/modules/user/src/Plugin/migrate/source/d6/UserPicture.php
index 13ae4f31dce..6b16ad4009d 100644
--- a/core/modules/user/src/Plugin/migrate/source/d6/UserPicture.php
+++ b/core/modules/user/src/Plugin/migrate/source/d6/UserPicture.php
@@ -21,7 +21,7 @@ class UserPicture extends DrupalSqlBase {
public function query() {
$query = $this->select('users', 'u')
->condition('picture', '', '<>')
- ->fields('u', array('uid', 'access', 'picture'))
+ ->fields('u', ['uid', 'access', 'picture'])
->orderBy('u.access');
return $query;
}
@@ -30,11 +30,11 @@ class UserPicture extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'uid' => 'Primary Key: Unique user ID.',
'access' => 'Timestamp for previous time user accessed the site.',
'picture' => "Path to the user's uploaded picture.",
- );
+ ];
}
/**
* {@inheritdoc}
diff --git a/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php b/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php
index d394e9c08f8..8952ffdf82b 100644
--- a/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php
+++ b/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php
@@ -34,7 +34,7 @@ class UserPictureFile extends DrupalSqlBase {
public function query() {
$query = $this->select('users', 'u')
->condition('u.picture', '', '<>')
- ->fields('u', array('uid', 'picture'));
+ ->fields('u', ['uid', 'picture']);
return $query;
}
@@ -62,10 +62,10 @@ class UserPictureFile extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'picture' => "Path to the user's uploaded picture.",
'filename' => 'The picture filename.',
- );
+ ];
}
/**
* {@inheritdoc}
diff --git a/core/modules/user/src/Plugin/migrate/source/d7/Role.php b/core/modules/user/src/Plugin/migrate/source/d7/Role.php
index 1067610e957..9245aab9699 100644
--- a/core/modules/user/src/Plugin/migrate/source/d7/Role.php
+++ b/core/modules/user/src/Plugin/migrate/source/d7/Role.php
@@ -25,11 +25,11 @@ class Role extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'rid' => $this->t('Role ID.'),
'name' => $this->t('The name of the user role.'),
'weight' => $this->t('The weight of the role.'),
- );
+ ];
}
/**
diff --git a/core/modules/user/src/Plugin/migrate/source/d7/User.php b/core/modules/user/src/Plugin/migrate/source/d7/User.php
index 717e12028fb..408d998803e 100644
--- a/core/modules/user/src/Plugin/migrate/source/d7/User.php
+++ b/core/modules/user/src/Plugin/migrate/source/d7/User.php
@@ -27,7 +27,7 @@ class User extends FieldableEntity {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'uid' => $this->t('User ID'),
'name' => $this->t('Username'),
'pass' => $this->t('Password'),
@@ -44,12 +44,12 @@ class User extends FieldableEntity {
'init' => $this->t('Init'),
'data' => $this->t('User data'),
'roles' => $this->t('Roles'),
- );
+ ];
// Profile fields.
if ($this->moduleExists('profile')) {
$fields += $this->select('profile_fields', 'pf')
- ->fields('pf', array('name', 'title'))
+ ->fields('pf', ['name', 'title'])
->execute()
->fetchAllKeyed();
}
@@ -79,9 +79,9 @@ class User extends FieldableEntity {
// ProfileFieldValues plugin.
if ($this->getDatabase()->schema()->tableExists('profile_value')) {
$query = $this->select('profile_value', 'pv')
- ->fields('pv', array('fid', 'value'));
+ ->fields('pv', ['fid', 'value']);
$query->leftJoin('profile_field', 'pf', 'pf.fid=pv.fid');
- $query->fields('pf', array('name', 'type'));
+ $query->fields('pf', ['name', 'type']);
$query->condition('uid', $row->getSourceProperty('uid'));
$results = $query->execute();
@@ -89,14 +89,14 @@ class User extends FieldableEntity {
if ($profile_value['type'] == 'date') {
$date = unserialize($profile_value['value']);
$date = date('Y-m-d', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
- $row->setSourceProperty($profile_value['name'], array('value' => $date));
+ $row->setSourceProperty($profile_value['name'], ['value' => $date]);
}
elseif ($profile_value['type'] == 'list') {
// Explode by newline and comma.
$row->setSourceProperty($profile_value['name'], preg_split("/[\r\n,]+/", $profile_value['value']));
}
else {
- $row->setSourceProperty($profile_value['name'], array($profile_value['value']));
+ $row->setSourceProperty($profile_value['name'], [$profile_value['value']]);
}
}
}
@@ -108,12 +108,12 @@ class User extends FieldableEntity {
* {@inheritdoc}
*/
public function getIds() {
- return array(
- 'uid' => array(
+ return [
+ 'uid' => [
'type' => 'integer',
'alias' => 'u',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/user/src/Plugin/views/access/Permission.php b/core/modules/user/src/Plugin/views/access/Permission.php
index d2d757bd91d..8d0c43dfcef 100644
--- a/core/modules/user/src/Plugin/views/access/Permission.php
+++ b/core/modules/user/src/Plugin/views/access/Permission.php
@@ -103,7 +103,7 @@ class Permission extends AccessPluginBase implements CacheableDependencyInterfac
protected function defineOptions() {
$options = parent::defineOptions();
- $options['perm'] = array('default' => 'access content');
+ $options['perm'] = ['default' => 'access content'];
return $options;
}
@@ -119,13 +119,13 @@ class Permission extends AccessPluginBase implements CacheableDependencyInterfac
$perms[$display_name][$perm] = strip_tags($perm_item['title']);
}
- $form['perm'] = array(
+ $form['perm'] = [
'#type' => 'select',
'#options' => $perms,
'#title' => $this->t('Permission'),
'#default_value' => $this->options['perm'],
'#description' => $this->t('Only users with the selected permission flag will be able to access this display.'),
- );
+ ];
}
/**
diff --git a/core/modules/user/src/Plugin/views/access/Role.php b/core/modules/user/src/Plugin/views/access/Role.php
index 2e5b6b4b0b0..e35daa1eea9 100644
--- a/core/modules/user/src/Plugin/views/access/Role.php
+++ b/core/modules/user/src/Plugin/views/access/Role.php
@@ -99,31 +99,31 @@ class Role extends AccessPluginBase implements CacheableDependencyInterface {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['role'] = array('default' => array());
+ $options['role'] = ['default' => []];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['role'] = array(
+ $form['role'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Role'),
'#default_value' => $this->options['role'],
'#options' => array_map('\Drupal\Component\Utility\Html::escape', user_role_names()),
'#description' => $this->t('Only the checked roles will be able to access this display.'),
- );
+ ];
}
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
- $role = $form_state->getValue(array('access_options', 'role'));
+ $role = $form_state->getValue(['access_options', 'role']);
$role = array_filter($role);
if (!$role) {
$form_state->setError($form['role'], $this->t('You must select at least one role if type is "by role"'));
}
- $form_state->setValue(array('access_options', 'role'), $role);
+ $form_state->setValue(['access_options', 'role'], $role);
}
/**
diff --git a/core/modules/user/src/Plugin/views/argument/RolesRid.php b/core/modules/user/src/Plugin/views/argument/RolesRid.php
index a1bba793705..ff9bf5ec82b 100644
--- a/core/modules/user/src/Plugin/views/argument/RolesRid.php
+++ b/core/modules/user/src/Plugin/views/argument/RolesRid.php
@@ -52,7 +52,7 @@ class RolesRid extends ManyToOne {
*/
public function titleQuery() {
$entities = $this->roleStorage->loadMultiple($this->value);
- $titles = array();
+ $titles = [];
foreach ($entities as $entity) {
$titles[] = $entity->label();
}
diff --git a/core/modules/user/src/Plugin/views/argument_default/User.php b/core/modules/user/src/Plugin/views/argument_default/User.php
index 0d1d4458196..448f79c55df 100644
--- a/core/modules/user/src/Plugin/views/argument_default/User.php
+++ b/core/modules/user/src/Plugin/views/argument_default/User.php
@@ -64,7 +64,7 @@ class User extends ArgumentDefaultPluginBase implements CacheableDependencyInter
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['user'] = array('default' => '');
+ $options['user'] = ['default' => ''];
return $options;
}
@@ -73,11 +73,11 @@ class User extends ArgumentDefaultPluginBase implements CacheableDependencyInter
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['user'] = array(
+ $form['user'] = [
'#type' => 'checkbox',
'#title' => $this->t('Also look for a node and use the node author'),
'#default_value' => $this->options['user'],
- );
+ ];
}
/**
diff --git a/core/modules/user/src/Plugin/views/argument_validator/User.php b/core/modules/user/src/Plugin/views/argument_validator/User.php
index fa61dbf662c..e7d213917b8 100644
--- a/core/modules/user/src/Plugin/views/argument_validator/User.php
+++ b/core/modules/user/src/Plugin/views/argument_validator/User.php
@@ -38,8 +38,8 @@ class User extends Entity {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['restrict_roles'] = array('default' => FALSE);
- $options['roles'] = array('default' => array());
+ $options['restrict_roles'] = ['default' => FALSE];
+ $options['roles'] = ['default' => []];
return $options;
}
@@ -51,30 +51,30 @@ class User extends Entity {
parent::buildOptionsForm($form, $form_state);
$sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']);
- $form['restrict_roles'] = array(
+ $form['restrict_roles'] = [
'#type' => 'checkbox',
'#title' => $this->t('Restrict user based on role'),
'#default_value' => $this->options['restrict_roles'],
- );
+ ];
- $form['roles'] = array(
+ $form['roles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Restrict to the selected roles'),
- '#options' => array_map(array('\Drupal\Component\Utility\Html', 'escape'), user_role_names(TRUE)),
+ '#options' => array_map(['\Drupal\Component\Utility\Html', 'escape'], user_role_names(TRUE)),
'#default_value' => $this->options['roles'],
'#description' => $this->t('If no roles are selected, users from any role will be allowed.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[validate][options][' . $sanitized_id . '][restrict_roles]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[validate][options][' . $sanitized_id . '][restrict_roles]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
- public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) {
+ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) {
// filter trash out of the options so we don't store giant unnecessary arrays
$options['roles'] = array_filter($options['roles']);
}
diff --git a/core/modules/user/src/Plugin/views/argument_validator/UserName.php b/core/modules/user/src/Plugin/views/argument_validator/UserName.php
index 88ffd646172..8ef4999b342 100644
--- a/core/modules/user/src/Plugin/views/argument_validator/UserName.php
+++ b/core/modules/user/src/Plugin/views/argument_validator/UserName.php
@@ -23,10 +23,10 @@ class UserName extends User {
$entity_type = $this->entityManager->getDefinition('user');
- $form['multiple']['#options'] = array(
- 0 => $this->t('Single name', array('%type' => $entity_type->getLabel())),
- 1 => $this->t('One or more names separated by , or +', array('%type' => $entity_type->getLabel())),
- );
+ $form['multiple']['#options'] = [
+ 0 => $this->t('Single name', ['%type' => $entity_type->getLabel()]),
+ 1 => $this->t('One or more names separated by , or +', ['%type' => $entity_type->getLabel()]),
+ ];
}
/**
@@ -39,14 +39,14 @@ class UserName extends User {
$names = array_filter(preg_split('/[,+ ]/', $argument));
}
elseif ($argument) {
- $names = array($argument);
+ $names = [$argument];
}
// No specified argument should be invalid.
else {
return FALSE;
}
- $accounts = $this->userStorage->loadByProperties(array('name' => $names));
+ $accounts = $this->userStorage->loadByProperties(['name' => $names]);
// If there are no accounts, return FALSE now. As we will not enter the
// loop below otherwise.
diff --git a/core/modules/user/src/Plugin/views/field/Permissions.php b/core/modules/user/src/Plugin/views/field/Permissions.php
index c9d5a9f5139..ecba8df9309 100644
--- a/core/modules/user/src/Plugin/views/field/Permissions.php
+++ b/core/modules/user/src/Plugin/views/field/Permissions.php
@@ -66,7 +66,7 @@ class Permissions extends PrerenderList {
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
- $this->additional_fields['uid'] = array('table' => 'users_field_data', 'field' => 'uid');
+ $this->additional_fields['uid'] = ['table' => 'users_field_data', 'field' => 'uid'];
}
public function query() {
@@ -75,11 +75,11 @@ class Permissions extends PrerenderList {
}
public function preRender(&$values) {
- $this->items = array();
+ $this->items = [];
$permission_names = \Drupal::service('user.permissions')->getPermissions();
- $rids = array();
+ $rids = [];
foreach ($values as $result) {
$user_rids = $this->getEntity($result)->getRoles();
$uid = $this->getValue($result);
diff --git a/core/modules/user/src/Plugin/views/field/Roles.php b/core/modules/user/src/Plugin/views/field/Roles.php
index 9d8edc04f09..bb7dc209779 100644
--- a/core/modules/user/src/Plugin/views/field/Roles.php
+++ b/core/modules/user/src/Plugin/views/field/Roles.php
@@ -55,7 +55,7 @@ class Roles extends PrerenderList {
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
- $this->additional_fields['uid'] = array('table' => 'users_field_data', 'field' => 'uid');
+ $this->additional_fields['uid'] = ['table' => 'users_field_data', 'field' => 'uid'];
}
public function query() {
@@ -64,8 +64,8 @@ class Roles extends PrerenderList {
}
public function preRender(&$values) {
- $uids = array();
- $this->items = array();
+ $uids = [];
+ $this->items = [];
foreach ($values as $result) {
$uids[] = $this->getValue($result);
@@ -73,7 +73,7 @@ class Roles extends PrerenderList {
if ($uids) {
$roles = user_roles();
- $result = $this->database->query('SELECT u.entity_id as uid, u.roles_target_id as rid FROM {user__roles} u WHERE u.entity_id IN ( :uids[] ) AND u.roles_target_id IN ( :rids[] )', array(':uids[]' => $uids, ':rids[]' => array_keys($roles)));
+ $result = $this->database->query('SELECT u.entity_id as uid, u.roles_target_id as rid FROM {user__roles} u WHERE u.entity_id IN ( :uids[] ) AND u.roles_target_id IN ( :rids[] )', [':uids[]' => $uids, ':rids[]' => array_keys($roles)]);
foreach ($result as $role) {
$this->items[$role->uid][$role->rid]['role'] = $roles[$role->rid]->label();
$this->items[$role->uid][$role->rid]['rid'] = $role->rid;
diff --git a/core/modules/user/src/Plugin/views/field/UserBulkForm.php b/core/modules/user/src/Plugin/views/field/UserBulkForm.php
index 57ae4370b4e..3d0196a9621 100644
--- a/core/modules/user/src/Plugin/views/field/UserBulkForm.php
+++ b/core/modules/user/src/Plugin/views/field/UserBulkForm.php
@@ -25,7 +25,7 @@ class UserBulkForm extends BulkForm {
foreach ($this->view->result as $row_index => $result) {
$account = $result->_entity;
if ($account instanceof UserInterface) {
- $form[$this->options['id']][$row_index]['#title'] = $this->t('Update the user %name', array('%name' => $account->label()));
+ $form[$this->options['id']][$row_index]['#title'] = $this->t('Update the user %name', ['%name' => $account->label()]);
}
}
}
diff --git a/core/modules/user/src/Plugin/views/field/UserData.php b/core/modules/user/src/Plugin/views/field/UserData.php
index b87346fc6c0..365ab3b746a 100644
--- a/core/modules/user/src/Plugin/views/field/UserData.php
+++ b/core/modules/user/src/Plugin/views/field/UserData.php
@@ -58,8 +58,8 @@ class UserData extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['data_module'] = array('default' => '');
- $options['data_name'] = array('default' => '');
+ $options['data_module'] = ['default' => ''];
+ $options['data_name'] = ['default' => ''];
return $options;
}
@@ -71,25 +71,25 @@ class UserData extends FieldPluginBase {
parent::buildOptionsForm($form, $form_state);
$modules = $this->moduleHandler->getModuleList();
- $names = array();
+ $names = [];
foreach (array_keys($modules) as $name) {
$names[$name] = $this->moduleHandler->getName($name);
}
- $form['data_module'] = array(
+ $form['data_module'] = [
'#title' => $this->t('Module name'),
'#type' => 'select',
'#description' => $this->t('The module which sets this user data.'),
'#default_value' => $this->options['data_module'],
'#options' => $names,
- );
+ ];
- $form['data_name'] = array(
+ $form['data_name'] = [
'#title' => $this->t('Name'),
'#type' => 'textfield',
'#description' => $this->t('The name of the data key.'),
'#default_value' => $this->options['data_name'],
- );
+ ];
}
/**
diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php
index e241e876361..f4260c5c0bd 100644
--- a/core/modules/user/src/Plugin/views/filter/Name.php
+++ b/core/modules/user/src/Plugin/views/filter/Name.php
@@ -19,9 +19,9 @@ class Name extends InOperator {
protected $alwaysMultiple = TRUE;
protected function valueForm(&$form, FormStateInterface $form_state) {
- $users = $this->value ? User::loadMultiple($this->value) : array();
+ $users = $this->value ? User::loadMultiple($this->value) : [];
$default_value = EntityAutocomplete::getEntityLabels($users);
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'entity_autocomplete',
'#title' => $this->t('Usernames'),
'#description' => $this->t('Enter a comma separated list of user names.'),
@@ -29,7 +29,7 @@ class Name extends InOperator {
'#tags' => TRUE,
'#default_value' => $default_value,
'#process_default_value' => $this->isExposed(),
- );
+ ];
$user_input = $form_state->getUserInput();
if ($form_state->get('exposed') && !isset($user_input[$this->options['expose']['identifier']])) {
@@ -40,13 +40,13 @@ class Name extends InOperator {
protected function valueValidate($form, FormStateInterface $form_state) {
$uids = [];
- if ($values = $form_state->getValue(array('options', 'value'))) {
+ if ($values = $form_state->getValue(['options', 'value'])) {
foreach ($values as $value) {
$uids[] = $value['target_id'];
}
sort($uids);
}
- $form_state->setValue(array('options', 'value'), $uids);
+ $form_state->setValue(['options', 'value'], $uids);
}
public function acceptExposedInput($input) {
@@ -105,7 +105,7 @@ class Name extends InOperator {
public function adminSummary() {
// set up $this->valueOptions for the parent summary
- $this->valueOptions = array();
+ $this->valueOptions = [];
if ($this->value) {
$result = \Drupal::entityTypeManager()->getStorage('user')
diff --git a/core/modules/user/src/Plugin/views/filter/Permissions.php b/core/modules/user/src/Plugin/views/filter/Permissions.php
index 7d444c681d0..7dd9171aa0b 100644
--- a/core/modules/user/src/Plugin/views/filter/Permissions.php
+++ b/core/modules/user/src/Plugin/views/filter/Permissions.php
@@ -88,7 +88,7 @@ class Permissions extends ManyToOne {
*/
public function query() {
// @todo user_role_names() should maybe support multiple permissions.
- $rids = array();
+ $rids = [];
// Get all role IDs that have the configured permissions.
foreach ($this->value as $permission) {
$roles = user_role_names(FALSE, $permission);
diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php
index 64074c3920e..b04e1b1f517 100644
--- a/core/modules/user/src/Plugin/views/filter/Roles.php
+++ b/core/modules/user/src/Plugin/views/filter/Roles.php
@@ -73,7 +73,7 @@ class Roles extends ManyToOne {
* {@inheritdoc}
*/
public function calculateDependencies() {
- $dependencies = array();
+ $dependencies = [];
foreach ($this->value as $role_id) {
$role = $this->roleStorage->load($role_id);
$dependencies[$role->getConfigDependencyKey()][] = $role->getConfigDependencyName();
diff --git a/core/modules/user/src/Plugin/views/wizard/Users.php b/core/modules/user/src/Plugin/views/wizard/Users.php
index efd42723c79..081a509a2df 100644
--- a/core/modules/user/src/Plugin/views/wizard/Users.php
+++ b/core/modules/user/src/Plugin/views/wizard/Users.php
@@ -27,16 +27,16 @@ class Users extends WizardPluginBase {
/**
* Set default values for the filters.
*/
- protected $filters = array(
- 'status' => array(
+ protected $filters = [
+ 'status' => [
'value' => TRUE,
'table' => 'users_field_data',
'field' => 'status',
'plugin_id' => 'boolean',
'entity_type' => 'user',
'entity_field' => 'status',
- )
- );
+ ]
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/user/src/PrivateTempStore.php b/core/modules/user/src/PrivateTempStore.php
index 1e73420bb5d..651227c3716 100644
--- a/core/modules/user/src/PrivateTempStore.php
+++ b/core/modules/user/src/PrivateTempStore.php
@@ -125,11 +125,11 @@ class PrivateTempStore {
}
}
- $value = (object) array(
+ $value = (object) [
'owner' => $this->getOwner(),
'data' => $value,
'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'),
- );
+ ];
$this->storage->setWithExpire($key, $value, $this->expire);
$this->lockBackend->release($key);
}
diff --git a/core/modules/user/src/ProfileForm.php b/core/modules/user/src/ProfileForm.php
index fc80230fe51..343d4d0e060 100644
--- a/core/modules/user/src/ProfileForm.php
+++ b/core/modules/user/src/ProfileForm.php
@@ -22,7 +22,7 @@ class ProfileForm extends AccountForm {
$user = $this->currentUser();
$element['delete']['#type'] = 'submit';
$element['delete']['#value'] = $this->t('Cancel account');
- $element['delete']['#submit'] = array('::editCancelSubmit');
+ $element['delete']['#submit'] = ['::editCancelSubmit'];
$element['delete']['#access'] = $account->id() > 1 && (($account->id() == $user->id() && $user->hasPermission('cancel account')) || $user->hasPermission('administer users'));
return $element;
@@ -43,17 +43,17 @@ class ProfileForm extends AccountForm {
* Provides a submit handler for the 'Cancel account' button.
*/
public function editCancelSubmit($form, FormStateInterface $form_state) {
- $destination = array();
+ $destination = [];
$query = $this->getRequest()->query;
if ($query->has('destination')) {
- $destination = array('destination' => $query->get('destination'));
+ $destination = ['destination' => $query->get('destination')];
$query->remove('destination');
}
// We redirect from user/%/edit to user/%/cancel to make the tabs disappear.
$form_state->setRedirect(
'entity.user.cancel_form',
- array('user' => $this->entity->id()),
- array('query' => $destination)
+ ['user' => $this->entity->id()],
+ ['query' => $destination]
);
}
diff --git a/core/modules/user/src/ProfileTranslationHandler.php b/core/modules/user/src/ProfileTranslationHandler.php
index d981f99f6c0..5b469525a4a 100644
--- a/core/modules/user/src/ProfileTranslationHandler.php
+++ b/core/modules/user/src/ProfileTranslationHandler.php
@@ -32,7 +32,7 @@ class ProfileTranslationHandler extends ContentTranslationHandler {
*/
public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) {
parent::entityFormAlter($form, $form_state, $entity);
- $form['actions']['submit']['#submit'][] = array($this, 'entityFormSave');
+ $form['actions']['submit']['#submit'][] = [$this, 'entityFormSave'];
}
/**
diff --git a/core/modules/user/src/RegisterForm.php b/core/modules/user/src/RegisterForm.php
index 9bc047b581f..7a97974fb2d 100644
--- a/core/modules/user/src/RegisterForm.php
+++ b/core/modules/user/src/RegisterForm.php
@@ -20,10 +20,10 @@ class RegisterForm extends AccountForm {
// Pass access information to the submit handler. Running an access check
// inside the submit function interferes with form processing and breaks
// hook_form_alter().
- $form['administer_users'] = array(
+ $form['administer_users'] = [
'#type' => 'value',
'#value' => $admin,
- );
+ ];
$form['#attached']['library'][] = 'core/drupal.form';
@@ -94,14 +94,14 @@ class RegisterForm extends AccountForm {
$form_state->set('user', $account);
$form_state->setValue('uid', $account->id());
- $this->logger('user')->notice('New user: %name %email.', array('%name' => $form_state->getValue('name'), '%email' => '<' . $form_state->getValue('mail') . '>', 'type' => $account->link($this->t('Edit'), 'edit-form')));
+ $this->logger('user')->notice('New user: %name %email.', ['%name' => $form_state->getValue('name'), '%email' => '<' . $form_state->getValue('mail') . '>', 'type' => $account->link($this->t('Edit'), 'edit-form')]);
// Add plain text password into user account to generate mail tokens.
$account->password = $pass;
// New administrative account without notification.
if ($admin && !$notify) {
- drupal_set_message($this->t('Created a new user account for <a href=":url">%name</a>. No email has been sent.', array(':url' => $account->url(), '%name' => $account->getUsername())));
+ drupal_set_message($this->t('Created a new user account for <a href=":url">%name</a>. No email has been sent.', [':url' => $account->url(), '%name' => $account->getUsername()]));
}
// No email verification required; log in user immediately.
elseif (!$admin && !\Drupal::config('user.settings')->get('verify_mail') && $account->isActive()) {
@@ -113,13 +113,13 @@ class RegisterForm extends AccountForm {
// No administrator approval required.
elseif ($account->isActive() || $notify) {
if (!$account->getEmail() && $notify) {
- drupal_set_message($this->t('The new user <a href=":url">%name</a> was created without an email address, so no welcome message was sent.', array(':url' => $account->url(), '%name' => $account->getUsername())));
+ drupal_set_message($this->t('The new user <a href=":url">%name</a> was created without an email address, so no welcome message was sent.', [':url' => $account->url(), '%name' => $account->getUsername()]));
}
else {
$op = $notify ? 'register_admin_created' : 'register_no_approval_required';
if (_user_mail_notify($op, $account)) {
if ($notify) {
- drupal_set_message($this->t('A welcome message with further instructions has been emailed to the new user <a href=":url">%name</a>.', array(':url' => $account->url(), '%name' => $account->getUsername())));
+ drupal_set_message($this->t('A welcome message with further instructions has been emailed to the new user <a href=":url">%name</a>.', [':url' => $account->url(), '%name' => $account->getUsername()]));
}
else {
drupal_set_message($this->t('A welcome message with further instructions has been sent to your email address.'));
diff --git a/core/modules/user/src/RoleForm.php b/core/modules/user/src/RoleForm.php
index 3199c45aa56..7e7885354b9 100644
--- a/core/modules/user/src/RoleForm.php
+++ b/core/modules/user/src/RoleForm.php
@@ -15,7 +15,7 @@ class RoleForm extends EntityForm {
*/
public function form(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Role name'),
'#default_value' => $entity->label(),
@@ -23,22 +23,22 @@ class RoleForm extends EntityForm {
'#required' => TRUE,
'#maxlength' => 64,
'#description' => $this->t('The name for this role. Example: "Moderator", "Editorial board", "Site architect".'),
- );
- $form['id'] = array(
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#default_value' => $entity->id(),
'#required' => TRUE,
'#disabled' => !$entity->isNew(),
'#size' => 30,
'#maxlength' => 64,
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => ['\Drupal\user\Entity\Role', 'load'],
- ),
- );
- $form['weight'] = array(
+ ],
+ ];
+ $form['weight'] = [
'#type' => 'value',
'#value' => $entity->getWeight(),
- );
+ ];
return parent::form($form, $form_state, $entity);
}
@@ -55,12 +55,12 @@ class RoleForm extends EntityForm {
$edit_link = $this->entity->link($this->t('Edit'));
if ($status == SAVED_UPDATED) {
- drupal_set_message($this->t('Role %label has been updated.', array('%label' => $entity->label())));
- $this->logger('user')->notice('Role %label has been updated.', array('%label' => $entity->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Role %label has been updated.', ['%label' => $entity->label()]));
+ $this->logger('user')->notice('Role %label has been updated.', ['%label' => $entity->label(), 'link' => $edit_link]);
}
else {
- drupal_set_message($this->t('Role %label has been added.', array('%label' => $entity->label())));
- $this->logger('user')->notice('Role %label has been added.', array('%label' => $entity->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Role %label has been added.', ['%label' => $entity->label()]));
+ $this->logger('user')->notice('Role %label has been added.', ['%label' => $entity->label(), 'link' => $edit_link]);
}
$form_state->setRedirect('entity.user_role.collection');
}
diff --git a/core/modules/user/src/RoleListBuilder.php b/core/modules/user/src/RoleListBuilder.php
index 16bd92cd6a1..aa3b844fd36 100644
--- a/core/modules/user/src/RoleListBuilder.php
+++ b/core/modules/user/src/RoleListBuilder.php
@@ -43,11 +43,11 @@ class RoleListBuilder extends DraggableListBuilder {
$operations = parent::getDefaultOperations($entity);
if ($entity->hasLinkTemplate('edit-permissions-form')) {
- $operations['permissions'] = array(
+ $operations['permissions'] = [
'title' => t('Edit permissions'),
'weight' => 20,
'url' => $entity->urlInfo('edit-permissions-form'),
- );
+ ];
}
return $operations;
}
diff --git a/core/modules/user/src/SharedTempStore.php b/core/modules/user/src/SharedTempStore.php
index 40d39203f00..2c6113ff66a 100644
--- a/core/modules/user/src/SharedTempStore.php
+++ b/core/modules/user/src/SharedTempStore.php
@@ -142,11 +142,11 @@ class SharedTempStore {
* TRUE if the data was set, or FALSE if it already existed.
*/
public function setIfNotExists($key, $value) {
- $value = (object) array(
+ $value = (object) [
'owner' => $this->owner,
'data' => $value,
'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'),
- );
+ ];
return $this->storage->setWithExpireIfNotExists($key, $value, $this->expire);
}
@@ -200,11 +200,11 @@ class SharedTempStore {
}
}
- $value = (object) array(
+ $value = (object) [
'owner' => $this->owner,
'data' => $value,
'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'),
- );
+ ];
$this->storage->setWithExpire($key, $value, $this->expire);
$this->lockBackend->release($key);
}
diff --git a/core/modules/user/src/Tests/UserAccountLinksTest.php b/core/modules/user/src/Tests/UserAccountLinksTest.php
index 6d7d723fce1..7f456c4a055 100644
--- a/core/modules/user/src/Tests/UserAccountLinksTest.php
+++ b/core/modules/user/src/Tests/UserAccountLinksTest.php
@@ -16,7 +16,7 @@ class UserAccountLinksTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('menu_ui', 'block', 'test_page_test');
+ public static $modules = ['menu_ui', 'block', 'test_page_test'];
/**
* {@inheritdoc}
@@ -33,7 +33,7 @@ class UserAccountLinksTest extends WebTestBase {
*/
function testSecondaryMenu() {
// Create a regular user.
- $user = $this->drupalCreateUser(array());
+ $user = $this->drupalCreateUser([]);
// Log in and get the homepage.
$this->drupalLogin($user);
@@ -41,18 +41,18 @@ class UserAccountLinksTest extends WebTestBase {
// For a logged-in user, expect the secondary menu to have links for "My
// account" and "Log out".
- $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
+ $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', [
':menu_class' => 'menu',
':href' => 'user',
':text' => 'My account',
- ));
+ ]);
$this->assertEqual(count($link), 1, 'My account link is in secondary menu.');
- $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
+ $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', [
':menu_class' => 'menu',
':href' => 'user/logout',
':text' => 'Log out',
- ));
+ ]);
$this->assertEqual(count($link), 1, 'Log out link is in secondary menu.');
// Log out and get the homepage.
@@ -60,11 +60,11 @@ class UserAccountLinksTest extends WebTestBase {
$this->drupalGet('<front>');
// For a logged-out user, expect the secondary menu to have a "Log in" link.
- $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
+ $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', [
':menu_class' => 'menu',
':href' => 'user/login',
':text' => 'Log in',
- ));
+ ]);
$this->assertEqual(count($link), 1, 'Log in link is in secondary menu.');
}
@@ -73,22 +73,22 @@ class UserAccountLinksTest extends WebTestBase {
*/
function testDisabledAccountLink() {
// Create an admin user and log in.
- $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer menu')));
+ $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer menu']));
// Verify that the 'My account' link exists before we check for its
// disappearance.
- $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
+ $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', [
':menu_class' => 'menu',
':href' => 'user',
':text' => 'My account',
- ));
+ ]);
$this->assertEqual(count($link), 1, 'My account link is in the secondary menu.');
// Verify that the 'My account' link is enabled. Do not assume the value of
// auto-increment is 1. Use XPath to obtain input element id and name using
// the consistent label text.
$this->drupalGet('admin/structure/menu/manage/account');
- $label = $this->xpath('//label[contains(.,:text)]/@for', array(':text' => 'Enable My account menu link'));
+ $label = $this->xpath('//label[contains(.,:text)]/@for', [':text' => 'Enable My account menu link']);
$this->assertFieldChecked((string) $label[0], "The 'My account' link is enabled by default.");
// Disable the 'My account' link.
@@ -99,11 +99,11 @@ class UserAccountLinksTest extends WebTestBase {
$this->drupalGet('<front>');
// Verify that the 'My account' link does not appear when disabled.
- $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
+ $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', [
':menu_class' => 'menu',
':href' => 'user',
':text' => 'My account',
- ));
+ ]);
$this->assertEqual(count($link), 0, 'My account link is not in the secondary menu.');
}
diff --git a/core/modules/user/src/Tests/UserAdminLanguageTest.php b/core/modules/user/src/Tests/UserAdminLanguageTest.php
index 03baa044e83..87bf835f617 100644
--- a/core/modules/user/src/Tests/UserAdminLanguageTest.php
+++ b/core/modules/user/src/Tests/UserAdminLanguageTest.php
@@ -31,12 +31,12 @@ class UserAdminLanguageTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('user', 'language', 'language_test');
+ public static $modules = ['user', 'language', 'language_test'];
protected function setUp() {
parent::setUp();
// User to add and remove language.
- $this->adminUser = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $this->adminUser = $this->drupalCreateUser(['administer languages', 'access administration pages']);
// User to check non-admin access.
$this->regularUser = $this->drupalCreateUser();
}
@@ -117,7 +117,7 @@ class UserAdminLanguageTest extends WebTestBase {
$this->assertText('Language negotiation method: language-url');
// Set a preferred language code for the user.
- $edit = array();
+ $edit = [];
$edit['preferred_admin_langcode'] = 'xx';
$this->drupalPostForm($path, $edit, t('Save'));
@@ -137,7 +137,7 @@ class UserAdminLanguageTest extends WebTestBase {
$this->assertText('Language negotiation method: language-user-admin');
// Unset the preferred language code for the user.
- $edit = array();
+ $edit = [];
$edit['preferred_admin_langcode'] = '';
$this->drupalPostForm($path, $edit, t('Save'));
$this->drupalGet($path);
@@ -156,12 +156,12 @@ class UserAdminLanguageTest extends WebTestBase {
* Whether the admin negotiation should be first.
*/
function setLanguageNegotiation($admin_first = FALSE) {
- $edit = array(
+ $edit = [
'language_interface[enabled][language-user-admin]' => TRUE,
'language_interface[enabled][language-url]' => TRUE,
'language_interface[weight][language-user-admin]' => ($admin_first ? -12 : -8),
'language_interface[weight][language-url]' => -10,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
}
@@ -172,12 +172,12 @@ class UserAdminLanguageTest extends WebTestBase {
$langcode = 'xx';
// The English name for the language.
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
}
diff --git a/core/modules/user/src/Tests/UserAdminListingTest.php b/core/modules/user/src/Tests/UserAdminListingTest.php
index 2ca50c8ffeb..9ec95060bf4 100644
--- a/core/modules/user/src/Tests/UserAdminListingTest.php
+++ b/core/modules/user/src/Tests/UserAdminListingTest.php
@@ -21,7 +21,7 @@ class UserAdminListingTest extends WebTestBase {
$this->assertResponse(403, 'Anonymous user does not have access to the user admin listing.');
// Create a bunch of users.
- $accounts = array();
+ $accounts = [];
for ($i = 0; $i < 3; $i++) {
$account = $this->drupalCreateUser();
$accounts[$account->label()] = $account;
@@ -39,8 +39,8 @@ class UserAdminListingTest extends WebTestBase {
$accounts[$account->label()] = $account;
$timestamp_user = $account->label();
- $rid_1 = $this->drupalCreateRole(array(), 'custom_role_1', 'custom_role_1');
- $rid_2 = $this->drupalCreateRole(array(), 'custom_role_2', 'custom_role_2');
+ $rid_1 = $this->drupalCreateRole([], 'custom_role_1', 'custom_role_1');
+ $rid_2 = $this->drupalCreateRole([], 'custom_role_2', 'custom_role_2');
$account = $this->drupalCreateUser();
$account->addRole($rid_1);
@@ -50,7 +50,7 @@ class UserAdminListingTest extends WebTestBase {
$role_account_name = $account->label();
// Create an admin user and look at the listing.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$accounts[$admin_user->label()] = $admin_user;
$accounts['admin'] = User::load(1);
@@ -61,22 +61,22 @@ class UserAdminListingTest extends WebTestBase {
$this->assertResponse(200, 'The admin user has access to the user admin listing.');
$result = $this->xpath('//table[contains(@class, "responsive-enabled")]/tbody/tr');
- $result_accounts = array();
+ $result_accounts = [];
foreach ($result as $account) {
$name = (string) $account->td[0]->span;
- $roles = array();
+ $roles = [];
if (isset($account->td[2]->div->ul)) {
foreach ($account->td[2]->div->ul->li as $element) {
$roles[] = (string) $element;
}
}
- $result_accounts[$name] = array(
+ $result_accounts[$name] = [
'name' => $name,
'status' => (string) $account->td[1],
'roles' => $roles,
'member_for' => (string) $account->td[3],
'last_access' => (string) $account->td[4],
- );
+ ];
}
$this->assertFalse(array_keys(array_diff_key($result_accounts, $accounts)), 'Ensure all accounts are listed.');
@@ -84,7 +84,7 @@ class UserAdminListingTest extends WebTestBase {
$this->assertEqual($values['status'] == t('active'), $accounts[$name]->status->value, 'Ensure the status is displayed properly.');
}
- $expected_roles = array('custom_role_1', 'custom_role_2');
+ $expected_roles = ['custom_role_1', 'custom_role_2'];
$this->assertEqual($result_accounts[$role_account_name]['roles'], $expected_roles, 'Ensure roles are listed properly.');
$this->assertEqual($result_accounts[$timestamp_user]['member_for'], \Drupal::service('date.formatter')->formatTimeDiffSince($accounts[$timestamp_user]->created->value), 'Ensure the right member time is displayed.');
diff --git a/core/modules/user/src/Tests/UserAdminSettingsFormTest.php b/core/modules/user/src/Tests/UserAdminSettingsFormTest.php
index 2fba848bf24..b77411154c6 100644
--- a/core/modules/user/src/Tests/UserAdminSettingsFormTest.php
+++ b/core/modules/user/src/Tests/UserAdminSettingsFormTest.php
@@ -16,33 +16,33 @@ class UserAdminSettingsFormTest extends SystemConfigFormTestBase {
parent::setUp();
$this->form = AccountSettingsForm::create($this->container);
- $this->values = array(
- 'anonymous' => array(
+ $this->values = [
+ 'anonymous' => [
'#value' => $this->randomString(10),
'#config_name' => 'user.settings',
'#config_key' => 'anonymous',
- ),
- 'user_mail_cancel_confirm_body' => array(
+ ],
+ 'user_mail_cancel_confirm_body' => [
'#value' => $this->randomString(),
'#config_name' => 'user.mail',
'#config_key' => 'cancel_confirm.body',
- ),
- 'user_mail_cancel_confirm_subject' => array(
+ ],
+ 'user_mail_cancel_confirm_subject' => [
'#value' => $this->randomString(20),
'#config_name' => 'user.mail',
'#config_key' => 'cancel_confirm.subject',
- ),
- 'register_pending_approval_admin_body' => array(
+ ],
+ 'register_pending_approval_admin_body' => [
'#value' => $this->randomString(),
'#config_name' => 'user.mail',
'#config_key' => 'register_pending_approval_admin.body',
- ),
- 'register_pending_approval_admin_subject' => array(
+ ],
+ 'register_pending_approval_admin_subject' => [
'#value' => $this->randomString(20),
'#config_name' => 'user.mail',
'#config_key' => 'register_pending_approval_admin.subject',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/user/src/Tests/UserAdminTest.php b/core/modules/user/src/Tests/UserAdminTest.php
index 8d4a22be78a..6c83016cde7 100644
--- a/core/modules/user/src/Tests/UserAdminTest.php
+++ b/core/modules/user/src/Tests/UserAdminTest.php
@@ -17,7 +17,7 @@ class UserAdminTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'views');
+ public static $modules = ['taxonomy', 'views'];
/**
* Registers a user and deletes it.
@@ -28,17 +28,17 @@ class UserAdminTest extends WebTestBase {
$user_a->name = 'User A';
$user_a->mail = $this->randomMachineName() . '@example.com';
$user_a->save();
- $user_b = $this->drupalCreateUser(array('administer taxonomy'));
+ $user_b = $this->drupalCreateUser(['administer taxonomy']);
$user_b->name = 'User B';
$user_b->save();
- $user_c = $this->drupalCreateUser(array('administer taxonomy'));
+ $user_c = $this->drupalCreateUser(['administer taxonomy']);
$user_c->name = 'User C';
$user_c->save();
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create admin user to delete registered user.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
// Use a predictable name so that we can reliably order the user admin page
// by name.
$admin_user->name = 'Admin user';
@@ -51,11 +51,11 @@ class UserAdminTest extends WebTestBase {
$this->assertText($admin_user->getUsername(), 'Found Admin user on admin users page');
// Test for existence of edit link in table.
- $link = $user_a->link(t('Edit'), 'edit-form', array('query' => array('destination' => $user_a->url('collection'))));
+ $link = $user_a->link(t('Edit'), 'edit-form', ['query' => ['destination' => $user_a->url('collection')]]);
$this->assertRaw($link, 'Found user A edit link on admin users page');
// Test exposed filter elements.
- foreach (array('user', 'role', 'permission', 'status') as $field) {
+ foreach (['user', 'role', 'permission', 'status'] as $field) {
$this->assertField("edit-$field", "$field exposed filter found.");
}
// Make sure the reduce duplicates element from the ManyToOneHelper is not
@@ -63,18 +63,18 @@ class UserAdminTest extends WebTestBase {
$this->assertNoField('edit-reduce-duplicates', 'Reduce duplicates form element not found in exposed filters.');
// Filter the users by name/email.
- $this->drupalGet('admin/people', array('query' => array('user' => $user_a->getUsername())));
+ $this->drupalGet('admin/people', ['query' => ['user' => $user_a->getUsername()]]);
$result = $this->xpath('//table/tbody/tr');
$this->assertEqual(1, count($result), 'Filter by username returned the right amount.');
$this->assertEqual($user_a->getUsername(), (string) $result[0]->td[1]->span, 'Filter by username returned the right user.');
- $this->drupalGet('admin/people', array('query' => array('user' => $user_a->getEmail())));
+ $this->drupalGet('admin/people', ['query' => ['user' => $user_a->getEmail()]]);
$result = $this->xpath('//table/tbody/tr');
$this->assertEqual(1, count($result), 'Filter by username returned the right amount.');
$this->assertEqual($user_a->getUsername(), (string) $result[0]->td[1]->span, 'Filter by username returned the right user.');
// Filter the users by permission 'administer taxonomy'.
- $this->drupalGet('admin/people', array('query' => array('permission' => 'administer taxonomy')));
+ $this->drupalGet('admin/people', ['query' => ['permission' => 'administer taxonomy']]);
// Check if the correct users show up.
$this->assertNoText($user_a->getUsername(), 'User A not on filtered by perm admin users page');
@@ -84,7 +84,7 @@ class UserAdminTest extends WebTestBase {
// Filter the users by role. Grab the system-generated role name for User C.
$roles = $user_c->getRoles();
unset($roles[array_search(RoleInterface::AUTHENTICATED_ID, $roles)]);
- $this->drupalGet('admin/people', array('query' => array('role' => reset($roles))));
+ $this->drupalGet('admin/people', ['query' => ['role' => reset($roles)]]);
// Check if the correct users show up when filtered by role.
$this->assertNoText($user_a->getUsername(), 'User A not on filtered by role on admin users page');
@@ -94,53 +94,53 @@ class UserAdminTest extends WebTestBase {
// Test blocking of a user.
$account = $user_storage->load($user_c->id());
$this->assertTrue($account->isActive(), 'User C not blocked');
- $edit = array();
+ $edit = [];
$edit['action'] = 'user_block_user_action';
$edit['user_bulk_form[4]'] = TRUE;
$config
->set('notify.status_blocked', TRUE)
->save();
- $this->drupalPostForm('admin/people', $edit, t('Apply to selected items'), array(
+ $this->drupalPostForm('admin/people', $edit, t('Apply to selected items'), [
// Sort the table by username so that we know reliably which user will be
// targeted with the blocking action.
- 'query' => array('order' => 'name', 'sort' => 'asc')
- ));
+ 'query' => ['order' => 'name', 'sort' => 'asc']
+ ]);
$site_name = $this->config('system.site')->get('name');
$this->assertMailString('body', 'Your account on ' . $site_name . ' has been blocked.', 1, 'Blocked message found in the mail sent to user C.');
- $user_storage->resetCache(array($user_c->id()));
+ $user_storage->resetCache([$user_c->id()]);
$account = $user_storage->load($user_c->id());
$this->assertTrue($account->isBlocked(), 'User C blocked');
// Test filtering on admin page for blocked users
- $this->drupalGet('admin/people', array('query' => array('status' => 2)));
+ $this->drupalGet('admin/people', ['query' => ['status' => 2]]);
$this->assertNoText($user_a->getUsername(), 'User A not on filtered by status on admin users page');
$this->assertNoText($user_b->getUsername(), 'User B not on filtered by status on admin users page');
$this->assertText($user_c->getUsername(), 'User C on filtered by status on admin users page');
// Test unblocking of a user from /admin/people page and sending of activation mail
- $editunblock = array();
+ $editunblock = [];
$editunblock['action'] = 'user_unblock_user_action';
$editunblock['user_bulk_form[4]'] = TRUE;
- $this->drupalPostForm('admin/people', $editunblock, t('Apply to selected items'), array(
+ $this->drupalPostForm('admin/people', $editunblock, t('Apply to selected items'), [
// Sort the table by username so that we know reliably which user will be
// targeted with the blocking action.
- 'query' => array('order' => 'name', 'sort' => 'asc')
- ));
- $user_storage->resetCache(array($user_c->id()));
+ 'query' => ['order' => 'name', 'sort' => 'asc']
+ ]);
+ $user_storage->resetCache([$user_c->id()]);
$account = $user_storage->load($user_c->id());
$this->assertTrue($account->isActive(), 'User C unblocked');
$this->assertMail("to", $account->getEmail(), "Activation mail sent to user C");
// Test blocking and unblocking another user from /user/[uid]/edit form and sending of activation mail
- $user_d = $this->drupalCreateUser(array());
- $user_storage->resetCache(array($user_d->id()));
+ $user_d = $this->drupalCreateUser([]);
+ $user_storage->resetCache([$user_d->id()]);
$account1 = $user_storage->load($user_d->id());
- $this->drupalPostForm('user/' . $account1->id() . '/edit', array('status' => 0), t('Save'));
- $user_storage->resetCache(array($user_d->id()));
+ $this->drupalPostForm('user/' . $account1->id() . '/edit', ['status' => 0], t('Save'));
+ $user_storage->resetCache([$user_d->id()]);
$account1 = $user_storage->load($user_d->id());
$this->assertTrue($account1->isBlocked(), 'User D blocked');
- $this->drupalPostForm('user/' . $account1->id() . '/edit', array('status' => TRUE), t('Save'));
- $user_storage->resetCache(array($user_d->id()));
+ $this->drupalPostForm('user/' . $account1->id() . '/edit', ['status' => TRUE], t('Save'));
+ $user_storage->resetCache([$user_d->id()]);
$account1 = $user_storage->load($user_d->id());
$this->assertTrue($account1->isActive(), 'User D unblocked');
$this->assertMail("to", $account1->getEmail(), "Activation mail sent to user D");
@@ -151,7 +151,7 @@ class UserAdminTest extends WebTestBase {
*/
function testNotificationEmailAddress() {
// Test that the Notification Email address field is on the config page.
- $admin_user = $this->drupalCreateUser(array('administer users', 'administer account settings'));
+ $admin_user = $this->drupalCreateUser(['administer users', 'administer account settings']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/config/people/accounts');
$this->assertRaw('id="edit-mail-notification-address"', 'Notification Email address field exists');
@@ -173,27 +173,27 @@ class UserAdminTest extends WebTestBase {
->set('mail_notification', $notify_address)
->save();
// Register a new user account.
- $edit = array();
+ $edit = [];
$edit['name'] = $this->randomMachineName();
$edit['mail'] = $edit['name'] . '@example.com';
$this->drupalPostForm('user/register', $edit, t('Create new account'));
$subject = 'Account details for ' . $edit['name'] . ' at ' . $system->get('name') . ' (pending admin approval)';
// Ensure that admin notification mail is sent to the configured
// Notification Email address.
- $admin_mail = $this->drupalGetMails(array(
+ $admin_mail = $this->drupalGetMails([
'to' => $notify_address,
'from' => $server_address,
'subject' => $subject,
- ));
+ ]);
$this->assertTrue(count($admin_mail), 'New user mail to admin is sent to configured Notification Email address');
// Ensure that user notification mail is sent from the configured
// Notification Email address.
- $user_mail = $this->drupalGetMails(array(
+ $user_mail = $this->drupalGetMails([
'to' => $edit['mail'],
'from' => $server_address,
'reply-to' => $notify_address,
'subject' => $subject,
- ));
+ ]);
$this->assertTrue(count($user_mail), 'New user mail to user is sent from configured Notification Email address');
}
diff --git a/core/modules/user/src/Tests/UserBlocksTest.php b/core/modules/user/src/Tests/UserBlocksTest.php
index 9216a2765d1..beb263b23e6 100644
--- a/core/modules/user/src/Tests/UserBlocksTest.php
+++ b/core/modules/user/src/Tests/UserBlocksTest.php
@@ -16,7 +16,7 @@ class UserBlocksTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'views');
+ public static $modules = ['block', 'views'];
/**
* A user with the 'administer blocks' permission.
@@ -28,7 +28,7 @@ class UserBlocksTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer blocks'));
+ $this->adminUser = $this->drupalCreateUser(['administer blocks']);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('user_login_block');
$this->drupalLogout($this->adminUser);
@@ -63,10 +63,10 @@ class UserBlocksTest extends WebTestBase {
*/
function testUserLoginBlock() {
// Create a user with some permission that anonymous users lack.
- $user = $this->drupalCreateUser(array('administer permissions'));
+ $user = $this->drupalCreateUser(['administer permissions']);
// Log in using the block.
- $edit = array();
+ $edit = [];
$edit['name'] = $user->getUsername();
$edit['pass'] = $user->pass_raw;
$this->drupalPostForm('admin/people/permissions', $edit, t('Log in'));
@@ -84,14 +84,14 @@ class UserBlocksTest extends WebTestBase {
// Check that the user login block is not vulnerable to information
// disclosure to third party sites.
$this->drupalLogout();
- $this->drupalPostForm('http://example.com/', $edit, t('Log in'), array('external' => FALSE));
+ $this->drupalPostForm('http://example.com/', $edit, t('Log in'), ['external' => FALSE]);
// Check that we remain on the site after login.
$this->assertUrl($user->url('canonical', ['absolute' => TRUE]), [], 'Redirected to user profile page after login from the frontpage');
// Verify that form validation errors are displayed immediately for forms
// in blocks and not on subsequent page requests.
$this->drupalLogout();
- $edit = array();
+ $edit = [];
$edit['name'] = 'foo';
$edit['pass'] = 'invalid password';
$this->drupalPostForm('filter/tips', $edit, t('Log in'));
@@ -107,9 +107,9 @@ class UserBlocksTest extends WebTestBase {
$block = $this->drupalPlaceBlock('views_block:who_s_online-who_s_online_block');
// Generate users.
- $user1 = $this->drupalCreateUser(array('access user profiles'));
- $user2 = $this->drupalCreateUser(array());
- $user3 = $this->drupalCreateUser(array());
+ $user1 = $this->drupalCreateUser(['access user profiles']);
+ $user2 = $this->drupalCreateUser([]);
+ $user3 = $this->drupalCreateUser([]);
// Update access of two users to be within the active timespan.
$this->updateAccess($user1->id());
@@ -138,7 +138,7 @@ class UserBlocksTest extends WebTestBase {
private function updateAccess($uid, $access = REQUEST_TIME) {
db_update('users_field_data')
->condition('uid', $uid)
- ->fields(array('access' => $access))
+ ->fields(['access' => $access])
->execute();
}
diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php
index e8a9c79d744..6cfd5baf1a0 100644
--- a/core/modules/user/src/Tests/UserCancelTest.php
+++ b/core/modules/user/src/Tests/UserCancelTest.php
@@ -22,12 +22,12 @@ class UserCancelTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'comment');
+ public static $modules = ['node', 'comment'];
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
}
/**
@@ -39,14 +39,14 @@ class UserCancelTest extends WebTestBase {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create a user.
- $account = $this->drupalCreateUser(array());
+ $account = $this->drupalCreateUser([]);
$this->drupalLogin($account);
// Load a real user object.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
// Create a node.
- $node = $this->drupalCreateNode(array('uid' => $account->id()));
+ $node = $this->drupalCreateNode(['uid' => $account->id()]);
// Attempt to cancel account.
$this->drupalGet('user/' . $account->id() . '/edit');
@@ -56,12 +56,12 @@ class UserCancelTest extends WebTestBase {
$timestamp = $account->getLastLoginTime();
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp));
$this->assertResponse(403, 'Bogus cancelling request rejected.');
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->isActive(), 'User account was not canceled.');
// Confirm user's content has not been altered.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$test_node = $node_storage->load($node->id());
$this->assertTrue(($test_node->getOwnerId() == $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.');
}
@@ -70,21 +70,21 @@ class UserCancelTest extends WebTestBase {
* Test ability to change the permission for canceling users.
*/
public function testUserCancelChangePermission() {
- \Drupal::service('module_installer')->install(array('user_form_test'));
+ \Drupal::service('module_installer')->install(['user_form_test']);
\Drupal::service('router.builder')->rebuild();
$this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
// Create a regular user.
- $account = $this->drupalCreateUser(array());
+ $account = $this->drupalCreateUser([]);
- $admin_user = $this->drupalCreateUser(array('cancel other accounts'));
+ $admin_user = $this->drupalCreateUser(['cancel other accounts']);
$this->drupalLogin($admin_user);
// Delete regular user.
- $this->drupalPostForm('user_form_test_cancel/' . $account->id(), array(), t('Cancel account'));
+ $this->drupalPostForm('user_form_test_cancel/' . $account->id(), [], t('Cancel account'));
// Confirm deletion.
- $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), 'User deleted.');
+ $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), 'User deleted.');
$this->assertFalse(User::load($account->id()), 'User is not found in the database.');
}
@@ -97,14 +97,14 @@ class UserCancelTest extends WebTestBase {
function testUserCancelUid1() {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
- \Drupal::service('module_installer')->install(array('views'));
+ \Drupal::service('module_installer')->install(['views']);
\Drupal::service('router.builder')->rebuild();
// Update uid 1's name and password to we know it.
$password = user_password();
- $account = array(
+ $account = [
'name' => 'user1',
'pass' => $this->container->get('password')->hash(trim($password)),
- );
+ ];
// We cannot use $account->save() here, because this would result in the
// password being hashed again.
db_update('users_field_data')
@@ -113,21 +113,21 @@ class UserCancelTest extends WebTestBase {
->execute();
// Reload and log in uid 1.
- $user_storage->resetCache(array(1));
+ $user_storage->resetCache([1]);
$user1 = $user_storage->load(1);
$user1->pass_raw = $password;
// Try to cancel uid 1's account with a different user.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
- $edit = array(
+ $edit = [
'action' => 'user_cancel_user_action',
'user_bulk_form[0]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/people', $edit, t('Apply to selected items'));
// Verify that uid 1's account was not cancelled.
- $user_storage->resetCache(array(1));
+ $user_storage->resetCache([1]);
$user1 = $user_storage->load(1);
$this->assertTrue($user1->isActive(), 'User #1 still exists and is not blocked.');
}
@@ -141,14 +141,14 @@ class UserCancelTest extends WebTestBase {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create a user.
- $account = $this->drupalCreateUser(array('cancel account'));
+ $account = $this->drupalCreateUser(['cancel account']);
$this->drupalLogin($account);
// Load a real user object.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
// Create a node.
- $node = $this->drupalCreateNode(array('uid' => $account->id()));
+ $node = $this->drupalCreateNode(['uid' => $account->id()]);
// Attempt to cancel account.
$this->drupalPostForm('user/' . $account->id() . '/edit', NULL, t('Cancel account'));
@@ -162,7 +162,7 @@ class UserCancelTest extends WebTestBase {
$bogus_timestamp = $timestamp + 60;
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account, $bogus_timestamp));
$this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'Bogus cancelling request rejected.');
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->isActive(), 'User account was not canceled.');
@@ -170,12 +170,12 @@ class UserCancelTest extends WebTestBase {
$bogus_timestamp = $timestamp - 86400 - 60;
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account, $bogus_timestamp));
$this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'Expired cancel account request rejected.');
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->isActive(), 'User account was not canceled.');
// Confirm user's content has not been altered.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$test_node = $node_storage->load($node->id());
$this->assertTrue(($test_node->getOwnerId() == $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.');
}
@@ -188,11 +188,11 @@ class UserCancelTest extends WebTestBase {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create a user.
- $web_user = $this->drupalCreateUser(array('cancel account'));
+ $web_user = $this->drupalCreateUser(['cancel account']);
$this->drupalLogin($web_user);
// Load a real user object.
- $user_storage->resetCache(array($web_user->id()));
+ $user_storage->resetCache([$web_user->id()]);
$account = $user_storage->load($web_user->id());
// Attempt to cancel account.
@@ -210,12 +210,12 @@ class UserCancelTest extends WebTestBase {
// Confirm account cancellation request.
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp));
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->isBlocked(), 'User has been blocked.');
// Confirm that the confirmation message made it through to the end user.
- $this->assertRaw(t('%name has been disabled.', array('%name' => $account->getUsername())), "Confirmation message displayed to user.");
+ $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user.");
}
/**
@@ -229,14 +229,14 @@ class UserCancelTest extends WebTestBase {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create a user.
- $account = $this->drupalCreateUser(array('cancel account'));
+ $account = $this->drupalCreateUser(['cancel account']);
$this->drupalLogin($account);
// Load a real user object.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
// Create a node with two revisions.
- $node = $this->drupalCreateNode(array('uid' => $account->id()));
+ $node = $this->drupalCreateNode(['uid' => $account->id()]);
$settings = get_object_vars($node);
$settings['revision'] = 1;
$node = $this->drupalCreateNode($settings);
@@ -244,7 +244,7 @@ class UserCancelTest extends WebTestBase {
// Add a comment to the page.
$comment_subject = $this->randomMachineName(8);
$comment_body = $this->randomMachineName(8);
- $comment = Comment::create(array(
+ $comment = Comment::create([
'subject' => $comment_subject,
'comment_body' => $comment_body,
'entity_id' => $node->id(),
@@ -252,7 +252,7 @@ class UserCancelTest extends WebTestBase {
'field_name' => 'comment',
'status' => CommentInterface::PUBLISHED,
'uid' => $account->id(),
- ));
+ ]);
$comment->save();
// Attempt to cancel account.
@@ -268,24 +268,24 @@ class UserCancelTest extends WebTestBase {
// Confirm account cancellation request.
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp));
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->isBlocked(), 'User has been blocked.');
// Confirm user's content has been unpublished.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$test_node = $node_storage->load($node->id());
$this->assertFalse($test_node->isPublished(), 'Node of the user has been unpublished.');
$test_node = node_revision_load($node->getRevisionId());
$this->assertFalse($test_node->isPublished(), 'Node revision of the user has been unpublished.');
$storage = \Drupal::entityManager()->getStorage('comment');
- $storage->resetCache(array($comment->id()));
+ $storage->resetCache([$comment->id()]);
$comment = $storage->load($comment->id());
$this->assertFalse($comment->isPublished(), 'Comment of the user has been unpublished.');
// Confirm that the confirmation message made it through to the end user.
- $this->assertRaw(t('%name has been disabled.', array('%name' => $account->getUsername())), "Confirmation message displayed to user.");
+ $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user.");
}
/**
@@ -299,19 +299,19 @@ class UserCancelTest extends WebTestBase {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create a user.
- $account = $this->drupalCreateUser(array('cancel account'));
+ $account = $this->drupalCreateUser(['cancel account']);
$this->drupalLogin($account);
// Load a real user object.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
// Create a simple node.
- $node = $this->drupalCreateNode(array('uid' => $account->id()));
+ $node = $this->drupalCreateNode(['uid' => $account->id()]);
// Add a comment to the page.
$comment_subject = $this->randomMachineName(8);
$comment_body = $this->randomMachineName(8);
- $comment = Comment::create(array(
+ $comment = Comment::create([
'subject' => $comment_subject,
'comment_body' => $comment_body,
'entity_id' => $node->id(),
@@ -319,12 +319,12 @@ class UserCancelTest extends WebTestBase {
'field_name' => 'comment',
'status' => CommentInterface::PUBLISHED,
'uid' => $account->id(),
- ));
+ ]);
$comment->save();
// Create a node with two revisions, the initial one belonging to the
// cancelling user.
- $revision_node = $this->drupalCreateNode(array('uid' => $account->id()));
+ $revision_node = $this->drupalCreateNode(['uid' => $account->id()]);
$revision = $revision_node->getRevisionId();
$settings = get_object_vars($revision_node);
$settings['revision'] = 1;
@@ -335,7 +335,7 @@ class UserCancelTest extends WebTestBase {
$this->drupalGet('user/' . $account->id() . '/edit');
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
$this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
- $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => $this->config('user.settings')->get('anonymous'))), 'Informs that all content will be attributed to anonymous account.');
+ $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]), 'Informs that all content will be attributed to anonymous account.');
// Confirm account cancellation.
$timestamp = time();
@@ -344,28 +344,28 @@ class UserCancelTest extends WebTestBase {
// Confirm account cancellation request.
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp));
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$this->assertFalse($user_storage->load($account->id()), 'User is not found in the database.');
// Confirm that user's content has been attributed to anonymous user.
$anonymous_user = User::getAnonymousUser();
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$test_node = $node_storage->load($node->id());
$this->assertTrue(($test_node->getOwnerId() == 0 && $test_node->isPublished()), 'Node of the user has been attributed to anonymous user.');
$test_node = node_revision_load($revision, TRUE);
$this->assertTrue(($test_node->getRevisionUser()->id() == 0 && $test_node->isPublished()), 'Node revision of the user has been attributed to anonymous user.');
- $node_storage->resetCache(array($revision_node->id()));
+ $node_storage->resetCache([$revision_node->id()]);
$test_node = $node_storage->load($revision_node->id());
$this->assertTrue(($test_node->getOwnerId() != 0 && $test_node->isPublished()), "Current revision of the user's node was not attributed to anonymous user.");
$storage = \Drupal::entityManager()->getStorage('comment');
- $storage->resetCache(array($comment->id()));
+ $storage->resetCache([$comment->id()]);
$test_comment = $storage->load($comment->id());
$this->assertTrue(($test_comment->getOwnerId() == 0 && $test_comment->isPublished()), 'Comment of the user has been attributed to anonymous user.');
$this->assertEqual($test_comment->getAuthorName(), $anonymous_user->getDisplayName(), 'Comment of the user has been attributed to anonymous user name.');
// Confirm that the confirmation message made it through to the end user.
- $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), "Confirmation message displayed to user.");
+ $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user.");
}
/**
@@ -377,7 +377,7 @@ class UserCancelTest extends WebTestBase {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create a user.
- $account = $this->drupalCreateUser(array('cancel account'));
+ $account = $this->drupalCreateUser(['cancel account']);
$this->drupalLogin($account);
// Load a real user object.
$user_storage->resetCache([$account->id()]);
@@ -395,7 +395,7 @@ class UserCancelTest extends WebTestBase {
$this->drupalGet('user/' . $account->id() . '/edit');
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
$this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
- $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => $this->config('user.settings')->get('anonymous'))), 'Informs that all content will be attributed to anonymous account.');
+ $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]), 'Informs that all content will be attributed to anonymous account.');
// Confirm account cancellation.
$timestamp = time();
@@ -421,36 +421,36 @@ class UserCancelTest extends WebTestBase {
function testUserDelete() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$this->config('user.settings')->set('cancel_method', 'user_cancel_delete')->save();
- \Drupal::service('module_installer')->install(array('comment'));
+ \Drupal::service('module_installer')->install(['comment']);
$this->resetAll();
$this->addDefaultCommentField('node', 'page');
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create a user.
- $account = $this->drupalCreateUser(array('cancel account', 'post comments', 'skip comment approval'));
+ $account = $this->drupalCreateUser(['cancel account', 'post comments', 'skip comment approval']);
$this->drupalLogin($account);
// Load a real user object.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
// Create a simple node.
- $node = $this->drupalCreateNode(array('uid' => $account->id()));
+ $node = $this->drupalCreateNode(['uid' => $account->id()]);
// Create comment.
- $edit = array();
+ $edit = [];
$edit['subject[0][value]'] = $this->randomMachineName(8);
$edit['comment_body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $edit, t('Preview'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText(t('Your comment has been posted.'));
- $comments = entity_load_multiple_by_properties('comment', array('subject' => $edit['subject[0][value]']));
+ $comments = entity_load_multiple_by_properties('comment', ['subject' => $edit['subject[0][value]']]);
$comment = reset($comments);
$this->assertTrue($comment->id(), 'Comment found.');
// Create a node with two revisions, the initial one belonging to the
// cancelling user.
- $revision_node = $this->drupalCreateNode(array('uid' => $account->id()));
+ $revision_node = $this->drupalCreateNode(['uid' => $account->id()]);
$revision = $revision_node->getRevisionId();
$settings = get_object_vars($revision_node);
$settings['revision'] = 1;
@@ -470,20 +470,20 @@ class UserCancelTest extends WebTestBase {
// Confirm account cancellation request.
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp));
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$this->assertFalse($user_storage->load($account->id()), 'User is not found in the database.');
// Confirm that user's content has been deleted.
- $node_storage->resetCache(array($node->id()));
+ $node_storage->resetCache([$node->id()]);
$this->assertFalse($node_storage->load($node->id()), 'Node of the user has been deleted.');
$this->assertFalse(node_revision_load($revision), 'Node revision of the user has been deleted.');
- $node_storage->resetCache(array($revision_node->id()));
+ $node_storage->resetCache([$revision_node->id()]);
$this->assertTrue($node_storage->load($revision_node->id()), "Current revision of the user's node was not deleted.");
- \Drupal::entityManager()->getStorage('comment')->resetCache(array($comment->id()));
+ \Drupal::entityManager()->getStorage('comment')->resetCache([$comment->id()]);
$this->assertFalse(Comment::load($comment->id()), 'Comment of the user has been deleted.');
// Confirm that the confirmation message made it through to the end user.
- $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), "Confirmation message displayed to user.");
+ $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), "Confirmation message displayed to user.");
}
/**
@@ -493,21 +493,21 @@ class UserCancelTest extends WebTestBase {
$this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
// Create a regular user.
- $account = $this->drupalCreateUser(array());
+ $account = $this->drupalCreateUser([]);
// Create administrative user.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
// Delete regular user.
$this->drupalGet('user/' . $account->id() . '/edit');
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
- $this->assertRaw(t('Are you sure you want to cancel the account %name?', array('%name' => $account->getUsername())), 'Confirmation form to cancel account displayed.');
+ $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getUsername()]), 'Confirmation form to cancel account displayed.');
$this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.');
// Confirm deletion.
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
- $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), 'User deleted.');
+ $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), 'User deleted.');
$this->assertFalse(User::load($account->id()), 'User is not found in the database.');
}
@@ -518,24 +518,24 @@ class UserCancelTest extends WebTestBase {
$this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
// Create a regular user.
- $account = $this->drupalCreateUser(array());
+ $account = $this->drupalCreateUser([]);
// This user has no email address.
$account->mail = '';
$account->save();
// Create administrative user.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
// Delete regular user without email address.
$this->drupalGet('user/' . $account->id() . '/edit');
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
- $this->assertRaw(t('Are you sure you want to cancel the account %name?', array('%name' => $account->getUsername())), 'Confirmation form to cancel account displayed.');
+ $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getUsername()]), 'Confirmation form to cancel account displayed.');
$this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.');
// Confirm deletion.
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
- $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), 'User deleted.');
+ $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getUsername()]), 'User deleted.');
$this->assertFalse(User::load($account->id()), 'User is not found in the database.');
}
@@ -543,7 +543,7 @@ class UserCancelTest extends WebTestBase {
* Create an administrative user and mass-delete other users.
*/
function testMassUserCancelByAdmin() {
- \Drupal::service('module_installer')->install(array('views'));
+ \Drupal::service('module_installer')->install(['views']);
\Drupal::service('router.builder')->rebuild();
$this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
$user_storage = $this->container->get('entity.manager')->getStorage('user');
@@ -551,18 +551,18 @@ class UserCancelTest extends WebTestBase {
$this->config('user.settings')->set('notify.status_canceled', TRUE)->save();
// Create administrative user.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
// Create some users.
- $users = array();
+ $users = [];
for ($i = 0; $i < 3; $i++) {
- $account = $this->drupalCreateUser(array());
+ $account = $this->drupalCreateUser([]);
$users[$account->id()] = $account;
}
// Cancel user accounts, including own one.
- $edit = array();
+ $edit = [];
$edit['action'] = 'user_cancel_user_action';
for ($i = 0; $i <= 4; $i++) {
$edit['user_bulk_form[' . $i . ']'] = TRUE;
@@ -578,7 +578,7 @@ class UserCancelTest extends WebTestBase {
$status = TRUE;
foreach ($users as $account) {
$status = $status && (strpos($this->content, $account->getUsername() . '</em> has been deleted.') !== FALSE);
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$status = $status && !$user_storage->load($account->id());
}
$this->assertTrue($status, 'Users deleted and not found in the database.');
@@ -589,7 +589,7 @@ class UserCancelTest extends WebTestBase {
$this->assertTrue($admin_user->isActive(), 'Administrative user is found in the database and enabled.');
// Verify that uid 1's account was not cancelled.
- $user_storage->resetCache(array(1));
+ $user_storage->resetCache([1]);
$user1 = $user_storage->load(1);
$this->assertTrue($user1->isActive(), 'User #1 still exists and is not blocked.');
}
diff --git a/core/modules/user/src/Tests/UserCreateTest.php b/core/modules/user/src/Tests/UserCreateTest.php
index efc7ddf7aa3..7b534435a0c 100644
--- a/core/modules/user/src/Tests/UserCreateTest.php
+++ b/core/modules/user/src/Tests/UserCreateTest.php
@@ -18,14 +18,14 @@ class UserCreateTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('image');
+ public static $modules = ['image'];
/**
* Create a user through the administration interface and ensure that it
* displays in the user list.
*/
public function testUserAdd() {
- $user = $this->drupalCreateUser(array('administer users'));
+ $user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($user);
$this->assertEqual($user->getCreatedTime(), REQUEST_TIME, 'Creating a user sets default "created" timestamp.');
@@ -33,18 +33,18 @@ class UserCreateTest extends WebTestBase {
// Create a field.
$field_name = 'test_field';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'user',
'module' => 'image',
'type' => 'image',
'cardinality' => 1,
'locked' => FALSE,
- 'indexes' => array('target_id' => array('target_id')),
- 'settings' => array(
+ 'indexes' => ['target_id' => ['target_id']],
+ 'settings' => [
'uri_scheme' => 'public',
- ),
- ))->save();
+ ],
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
@@ -53,7 +53,7 @@ class UserCreateTest extends WebTestBase {
'bundle' => 'user',
'description' => t('Your virtual face or picture.'),
'required' => FALSE,
- 'settings' => array(
+ 'settings' => [
'file_extensions' => 'png gif jpg jpeg',
'file_directory' => 'pictures',
'max_filesize' => '30 KB',
@@ -61,7 +61,7 @@ class UserCreateTest extends WebTestBase {
'title_field' => 0,
'max_resolution' => '85x85',
'min_resolution' => '',
- ),
+ ],
])->save();
// Test user creation page for valid fields.
@@ -86,23 +86,23 @@ class UserCreateTest extends WebTestBase {
// We create two users, notifying one and not notifying the other, to
// ensure that the tests work in both cases.
- foreach (array(FALSE, TRUE) as $notify) {
+ foreach ([FALSE, TRUE] as $notify) {
$name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'name' => $name,
'mail' => $this->randomMachineName() . '@example.com',
'pass[pass1]' => $pass = $this->randomString(),
'pass[pass2]' => $pass,
'notify' => $notify,
- );
+ ];
$this->drupalPostForm('admin/people/create', $edit, t('Create new account'));
if ($notify) {
- $this->assertText(t('A welcome message with further instructions has been emailed to the new user @name.', array('@name' => $edit['name'])), 'User created');
+ $this->assertText(t('A welcome message with further instructions has been emailed to the new user @name.', ['@name' => $edit['name']]), 'User created');
$this->assertEqual(count($this->drupalGetMails()), 1, 'Notification email sent');
}
else {
- $this->assertText(t('Created a new user account for @name. No email has been sent.', array('@name' => $edit['name'])), 'User created');
+ $this->assertText(t('Created a new user account for @name. No email has been sent.', ['@name' => $edit['name']]), 'User created');
$this->assertEqual(count($this->drupalGetMails()), 0, 'Notification email not sent');
}
@@ -115,13 +115,13 @@ class UserCreateTest extends WebTestBase {
// Test that the password '0' is considered a password.
// @see https://www.drupal.org/node/2563751.
$name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'name' => $name,
'mail' => $this->randomMachineName() . '@example.com',
'pass[pass1]' => 0,
'pass[pass2]' => 0,
'notify' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/people/create', $edit, t('Create new account'));
$this->assertText("Created a new user account for $name. No email has been sent");
$this->assertNoText('Password field is required');
diff --git a/core/modules/user/src/Tests/UserEditTest.php b/core/modules/user/src/Tests/UserEditTest.php
index 5b34d2e028c..7c2fe4f311e 100644
--- a/core/modules/user/src/Tests/UserEditTest.php
+++ b/core/modules/user/src/Tests/UserEditTest.php
@@ -16,14 +16,14 @@ class UserEditTest extends WebTestBase {
*/
function testUserEdit() {
// Test user edit functionality.
- $user1 = $this->drupalCreateUser(array('change own username'));
- $user2 = $this->drupalCreateUser(array());
+ $user1 = $this->drupalCreateUser(['change own username']);
+ $user2 = $this->drupalCreateUser([]);
$this->drupalLogin($user1);
// Test that error message appears when attempting to use a non-unique user name.
$edit['name'] = $user2->getUsername();
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
- $this->assertRaw(t('The username %name is already taken.', array('%name' => $edit['name'])));
+ $this->assertRaw(t('The username %name is already taken.', ['%name' => $edit['name']]));
// Check that the default value in user name field
// is the raw value and not a formatted one.
@@ -33,7 +33,7 @@ class UserEditTest extends WebTestBase {
$this->assertFieldByName('name', $user1->getAccountName());
// Check that filling out a single password field does not validate.
- $edit = array();
+ $edit = [];
$edit['pass[pass1]'] = '';
$edit['pass[pass2]'] = $this->randomMachineName();
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
@@ -46,21 +46,21 @@ class UserEditTest extends WebTestBase {
// Test that the error message appears when attempting to change the mail or
// pass without the current password.
- $edit = array();
+ $edit = [];
$edit['mail'] = $this->randomMachineName() . '@new.example.com';
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
- $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('Email'))));
+ $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Email')]));
$edit['current_pass'] = $user1->pass_raw;
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
$this->assertRaw(t("The changes have been saved."));
// Test that the user must enter current password before changing passwords.
- $edit = array();
+ $edit = [];
$edit['pass[pass1]'] = $new_pass = $this->randomMachineName();
$edit['pass[pass2]'] = $new_pass;
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
- $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('Password'))));
+ $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Password')]));
// Try again with the current password.
$edit['current_pass'] = $user1->pass_raw;
@@ -90,20 +90,20 @@ class UserEditTest extends WebTestBase {
// Check that the user status field has the correct value and that it is
// properly displayed.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
$this->drupalGet('user/' . $user1->id() . '/edit');
$this->assertNoFieldChecked('edit-status-0');
$this->assertFieldChecked('edit-status-1');
- $edit = array('status' => 0);
+ $edit = ['status' => 0];
$this->drupalPostForm('user/' . $user1->id() . '/edit', $edit, t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertFieldChecked('edit-status-0');
$this->assertNoFieldChecked('edit-status-1');
- $edit = array('status' => 1);
+ $edit = ['status' => 1];
$this->drupalPostForm('user/' . $user1->id() . '/edit', $edit, t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertNoFieldChecked('edit-status-0');
@@ -133,14 +133,14 @@ class UserEditTest extends WebTestBase {
*/
function testUserWithoutEmailEdit() {
// Test that an admin can edit users without an email address.
- $admin = $this->drupalCreateUser(array('administer users'));
+ $admin = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin);
// Create a regular user.
- $user1 = $this->drupalCreateUser(array());
+ $user1 = $this->drupalCreateUser([]);
// This user has no email address.
$user1->mail = '';
$user1->save();
- $this->drupalPostForm("user/" . $user1->id() . "/edit", array('mail' => ''), t('Save'));
+ $this->drupalPostForm("user/" . $user1->id() . "/edit", ['mail' => ''], t('Save'));
$this->assertRaw(t("The changes have been saved."));
}
diff --git a/core/modules/user/src/Tests/UserLanguageCreationTest.php b/core/modules/user/src/Tests/UserLanguageCreationTest.php
index 08ca7077a7e..e38a9c03eda 100644
--- a/core/modules/user/src/Tests/UserLanguageCreationTest.php
+++ b/core/modules/user/src/Tests/UserLanguageCreationTest.php
@@ -18,14 +18,14 @@ class UserLanguageCreationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('user', 'language');
+ public static $modules = ['user', 'language'];
/**
* Functional test for language handling during user creation.
*/
function testLocalUserCreation() {
// User to add and remove language and create new users.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer users'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer users']);
$this->drupalLogin($admin_user);
// Add predefined language.
@@ -33,9 +33,9 @@ class UserLanguageCreationTest extends WebTestBase {
ConfigurableLanguage::createFromLangcode($langcode)->save();
// Set language negotiation.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-url]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->assertText(t('Language detection configuration saved.'), 'Set language negotiation.');
@@ -47,12 +47,12 @@ class UserLanguageCreationTest extends WebTestBase {
// Create a user with the admin/people/create form and check if the correct
// language is set.
$username = $this->randomMachineName(10);
- $edit = array(
+ $edit = [
'name' => $username,
'mail' => $this->randomMachineName(4) . '@example.com',
'pass[pass1]' => $username,
'pass[pass2]' => $username,
- );
+ ];
$this->drupalPostForm($langcode . '/admin/people/create', $edit, t('Create new account'));
@@ -67,10 +67,10 @@ class UserLanguageCreationTest extends WebTestBase {
$this->assertNoFieldByName('language[fr]', 'Language selector is not accessible.');
$username = $this->randomMachineName(10);
- $edit = array(
+ $edit = [
'name' => $username,
'mail' => $this->randomMachineName(4) . '@example.com',
- );
+ ];
$this->drupalPostForm($langcode . '/user/register', $edit, t('Create new account'));
@@ -88,10 +88,10 @@ class UserLanguageCreationTest extends WebTestBase {
// Set pass_raw so we can log in the new user.
$user->pass_raw = $this->randomMachineName(10);
- $edit = array(
+ $edit = [
'pass[pass1]' => $user->pass_raw,
'pass[pass2]' => $user->pass_raw,
- );
+ ];
$this->drupalPostForm($user_edit, $edit, t('Save'));
diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php
index af00c747376..406ccc04374 100644
--- a/core/modules/user/src/Tests/UserLoginTest.php
+++ b/core/modules/user/src/Tests/UserLoginTest.php
@@ -21,9 +21,9 @@ class UserLoginTest extends WebTestBase {
// depends on config:system.site, and its cache tags should be present.
$this->assertCacheTag('config:system.site');
- $user = $this->drupalCreateUser(array());
- $this->drupalGet('user/login', array('query' => array('destination' => 'foo')));
- $edit = array('name' => $user->getUserName(), 'pass' => $user->pass_raw);
+ $user = $this->drupalCreateUser([]);
+ $this->drupalGet('user/login', ['query' => ['destination' => 'foo']]);
+ $edit = ['name' => $user->getUserName(), 'pass' => $user->pass_raw];
$this->drupalPostForm(NULL, $edit, t('Log in'));
$this->assertUrl('foo', [], 'Redirected to the correct URL');
}
@@ -38,7 +38,7 @@ class UserLoginTest extends WebTestBase {
->set('user_limit', 4000)
->save();
- $user1 = $this->drupalCreateUser(array());
+ $user1 = $this->drupalCreateUser([]);
$incorrect_user1 = clone $user1;
$incorrect_user1->pass_raw .= 'incorrect';
@@ -75,11 +75,11 @@ class UserLoginTest extends WebTestBase {
->set('user_limit', 3)
->save();
- $user1 = $this->drupalCreateUser(array());
+ $user1 = $this->drupalCreateUser([]);
$incorrect_user1 = clone $user1;
$incorrect_user1->pass_raw .= 'incorrect';
- $user2 = $this->drupalCreateUser(array());
+ $user2 = $this->drupalCreateUser([]);
// Try 2 failed logins.
for ($i = 0; $i < 2; $i++) {
@@ -116,7 +116,7 @@ class UserLoginTest extends WebTestBase {
$password_hasher = $this->container->get('password');
// Create a new user and authenticate.
- $account = $this->drupalCreateUser(array());
+ $account = $this->drupalCreateUser([]);
$password = $account->pass_raw;
$this->drupalLogin($account);
$this->drupalLogout();
@@ -129,13 +129,13 @@ class UserLoginTest extends WebTestBase {
// containing the necessary container builder code and then verify that the
// users password gets rehashed during the login.
$overridden_count_log2 = 19;
- \Drupal::service('module_installer')->install(array('user_custom_phpass_params_test'));
+ \Drupal::service('module_installer')->install(['user_custom_phpass_params_test']);
$this->resetAll();
$account->pass_raw = $password;
$this->drupalLogin($account);
// Load the stored user, which should have a different password hash now.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertIdentical($password_hasher->getCountLog2($account->getPassword()), $overridden_count_log2);
$this->assertTrue($password_hasher->check($password, $account->getPassword()));
@@ -155,19 +155,19 @@ class UserLoginTest extends WebTestBase {
* - Set to NULL to expect a failed login.
*/
function assertFailedLogin($account, $flood_trigger = NULL) {
- $edit = array(
+ $edit = [
'name' => $account->getUsername(),
'pass' => $account->pass_raw,
- );
+ ];
$this->drupalPostForm('user/login', $edit, t('Log in'));
$this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.');
if (isset($flood_trigger)) {
if ($flood_trigger == 'user') {
- $this->assertRaw(\Drupal::translation()->formatPlural($this->config('user.flood')->get('user_limit'), 'There has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', 'There have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', array(':url' => \Drupal::url('user.pass'))));
+ $this->assertRaw(\Drupal::translation()->formatPlural($this->config('user.flood')->get('user_limit'), 'There has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', 'There have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => \Drupal::url('user.pass')]));
}
else {
// No uid, so the limit is IP-based.
- $this->assertRaw(t('Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', array(':url' => \Drupal::url('user.pass'))));
+ $this->assertRaw(t('Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => \Drupal::url('user.pass')]));
}
}
else {
diff --git a/core/modules/user/src/Tests/UserPasswordResetTest.php b/core/modules/user/src/Tests/UserPasswordResetTest.php
index f3463bf1dc9..fb19779d1c7 100644
--- a/core/modules/user/src/Tests/UserPasswordResetTest.php
+++ b/core/modules/user/src/Tests/UserPasswordResetTest.php
@@ -61,7 +61,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// that it is definitely over a second ago.
$account->login = REQUEST_TIME - mt_rand(10, 100000);
db_update('users_field_data')
- ->fields(array('login' => $account->getLastLoginTime()))
+ ->fields(['login' => $account->getLastLoginTime()])
->condition('uid', $account->id())
->execute();
}
@@ -78,11 +78,11 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Try to reset the password for an invalid account.
$this->drupalGet('user/password');
- $edit = array('name' => $this->randomMachineName(32));
+ $edit = ['name' => $this->randomMachineName(32)];
$this->drupalPostForm(NULL, $edit, t('Submit'));
- $this->assertText(t('@name is not recognized as a username or an email address.', array('@name' => $edit['name'])), 'Validation error message shown when trying to request password for invalid account.');
- $this->assertEqual(count($this->drupalGetMails(array('id' => 'user_password_reset'))), 0, 'No email was sent when requesting a password for an invalid account.');
+ $this->assertText(t('@name is not recognized as a username or an email address.', ['@name' => $edit['name']]), 'Validation error message shown when trying to request password for invalid account.');
+ $this->assertEqual(count($this->drupalGetMails(['id' => 'user_password_reset'])), 0, 'No email was sent when requesting a password for an invalid account.');
// Reset the password by username via the password reset page.
$edit['name'] = $this->account->getUsername();
@@ -90,7 +90,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Verify that the user was sent an email.
$this->assertMail('to', $this->account->getEmail(), 'Password email sent to user.');
- $subject = t('Replacement login information for @username at @site', array('@username' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name')));
+ $subject = t('Replacement login information for @username at @site', ['@username' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name')]);
$this->assertMail('subject', $subject, 'Password reset email subject is correct.');
$resetURL = $this->getResetURL();
@@ -112,19 +112,19 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Check successful login.
$this->drupalPostForm(NULL, NULL, t('Log in'));
$this->assertLink(t('Log out'));
- $this->assertTitle(t('@name | @site', array('@name' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name'))), 'Logged in using password reset link.');
+ $this->assertTitle(t('@name | @site', ['@name' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name')]), 'Logged in using password reset link.');
// Make sure the ajax request from uploading a user picture does not
// invalidate the reset token.
$image = current($this->drupalGetTestFiles('image'));
- $edit = array(
+ $edit = [
'files[user_picture_0]' => drupal_realpath($image->uri),
- );
+ ];
$this->drupalPostAjaxForm(NULL, $edit, 'user_picture_0_upload_button');
// Change the forgotten password.
$password = user_password();
- $edit = array('pass[pass1]' => $password, 'pass[pass2]' => $password);
+ $edit = ['pass[pass1]' => $password, 'pass[pass2]' => $password];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('The changes have been saved.'), 'Forgotten password changed.');
@@ -141,10 +141,10 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Request a new password again, this time using the email address.
$this->drupalGet('user/password');
// Count email messages before to compare with after.
- $before = count($this->drupalGetMails(array('id' => 'user_password_reset')));
- $edit = array('name' => $this->account->getEmail());
+ $before = count($this->drupalGetMails(['id' => 'user_password_reset']));
+ $edit = ['name' => $this->account->getEmail()];
$this->drupalPostForm(NULL, $edit, t('Submit'));
- $this->assertTrue( count($this->drupalGetMails(array('id' => 'user_password_reset'))) === $before + 1, 'Email sent when requesting password reset using email address.');
+ $this->assertTrue( count($this->drupalGetMails(['id' => 'user_password_reset'])) === $before + 1, 'Email sent when requesting password reset using email address.');
// Visit the user edit page without pass-reset-token and make sure it does
// not cause an error.
@@ -173,15 +173,15 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Verify a blocked user can not request a new password.
$this->drupalGet('user/password');
// Count email messages before to compare with after.
- $before = count($this->drupalGetMails(array('id' => 'user_password_reset')));
- $edit = array('name' => $blocked_account->getUsername());
+ $before = count($this->drupalGetMails(['id' => 'user_password_reset']));
+ $edit = ['name' => $blocked_account->getUsername()];
$this->drupalPostForm(NULL, $edit, t('Submit'));
- $this->assertRaw(t('%name is blocked or has not been activated yet.', array('%name' => $blocked_account->getUsername())), 'Notified user blocked accounts can not request a new password');
- $this->assertTrue(count($this->drupalGetMails(array('id' => 'user_password_reset'))) === $before, 'No email was sent when requesting password reset for a blocked account');
+ $this->assertRaw(t('%name is blocked or has not been activated yet.', ['%name' => $blocked_account->getUsername()]), 'Notified user blocked accounts can not request a new password');
+ $this->assertTrue(count($this->drupalGetMails(['id' => 'user_password_reset'])) === $before, 'No email was sent when requesting password reset for a blocked account');
// Verify a password reset link is invalidated when the user's email address changes.
$this->drupalGet('user/password');
- $edit = array('name' => $this->account->getUsername());
+ $edit = ['name' => $this->account->getUsername()];
$this->drupalPostForm(NULL, $edit, t('Submit'));
$old_email_reset_link = $this->getResetURL();
$this->account->setEmail("1" . $this->account->getEmail());
@@ -193,12 +193,12 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Verify a password reset link will automatically log a user when /login is
// appended.
$this->drupalGet('user/password');
- $edit = array('name' => $this->account->getUsername());
+ $edit = ['name' => $this->account->getUsername()];
$this->drupalPostForm(NULL, $edit, t('Submit'));
$reset_url = $this->getResetURL();
$this->drupalGet($reset_url . '/login');
$this->assertLink(t('Log out'));
- $this->assertTitle(t('@name | @site', array('@name' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name'))), 'Logged in using password reset link.');
+ $this->assertTitle(t('@name | @site', ['@name' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name')]), 'Logged in using password reset link.');
// Ensure blocked and deleted accounts can't access the user.reset.login
// route.
@@ -221,7 +221,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Assume the most recent email.
$_emails = $this->drupalGetMails();
$email = end($_emails);
- $urls = array();
+ $urls = [];
preg_match('#.+user/reset/.+#', $email['body'], $urls);
return $urls[0];
@@ -264,7 +264,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// Change the password.
$password = user_password();
- $edit = array('pass[pass1]' => $password, 'pass[pass2]' => $password);
+ $edit = ['pass[pass1]' => $password, 'pass[pass2]' => $password];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('The changes have been saved.'), 'Password changed.');
@@ -282,15 +282,15 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
*/
public function testUserResetPasswordTextboxFilled() {
$this->drupalGet('user/login');
- $edit = array(
+ $edit = [
'name' => $this->randomMachineName(),
'pass' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('user/login', $edit, t('Log in'));
$this->assertRaw(t('Unrecognized username or password. <a href=":password">Forgot your password?</a>',
- array(':password' => \Drupal::url('user.pass', [], array('query' => array('name' => $edit['name']))))));
+ [':password' => \Drupal::url('user.pass', [], ['query' => ['name' => $edit['name']]])]));
unset($edit['pass']);
- $this->drupalGet('user/password', array('query' => array('name' => $edit['name'])));
+ $this->drupalGet('user/password', ['query' => ['name' => $edit['name']]]);
$this->assertFieldByName('name', $edit['name'], 'User name found.');
// Ensure the name field value is not cached.
$this->drupalGet('user/password');
@@ -303,7 +303,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
function testResetImpersonation() {
// Create two identical user accounts except for the user name. They must
// have the same empty password, so we can't use $this->drupalCreateUser().
- $edit = array();
+ $edit = [];
$edit['name'] = $this->randomMachineName();
$edit['mail'] = $edit['name'] . '@example.com';
$edit['status'] = 1;
@@ -333,7 +333,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
$this->drupalGet($attack_reset_url);
$this->drupalPostForm(NULL, NULL, t('Log in'));
$this->assertNoText($user2->getUsername(), 'The invalid password reset page does not show the user name.');
- $this->assertUrl('user/password', array(), 'The user is redirected to the password reset request page.');
+ $this->assertUrl('user/password', [], 'The user is redirected to the password reset request page.');
$this->assertText('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.');
}
diff --git a/core/modules/user/src/Tests/UserPermissionsTest.php b/core/modules/user/src/Tests/UserPermissionsTest.php
index 5e3ecd54929..50a7f9e3297 100644
--- a/core/modules/user/src/Tests/UserPermissionsTest.php
+++ b/core/modules/user/src/Tests/UserPermissionsTest.php
@@ -31,7 +31,7 @@ class UserPermissionsTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'access user profiles', 'administer site configuration', 'administer modules', 'administer account settings'));
+ $this->adminUser = $this->drupalCreateUser(['administer permissions', 'access user profiles', 'administer site configuration', 'administer modules', 'administer account settings']);
// Find the new role ID.
$all_rids = $this->adminUser->getRoles();
@@ -59,7 +59,7 @@ class UserPermissionsTest extends WebTestBase {
// Add a permission.
$this->assertFalse($account->hasPermission('administer users'), 'User does not have "administer users" permission.');
- $edit = array();
+ $edit = [];
$edit[$rid . '[administer users]'] = TRUE;
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), 'Successful save message displayed.');
@@ -72,7 +72,7 @@ class UserPermissionsTest extends WebTestBase {
// Remove a permission.
$this->assertTrue($account->hasPermission('access user profiles'), 'User has "access user profiles" permission.');
- $edit = array();
+ $edit = [];
$edit[$rid . '[access user profiles]'] = FALSE;
$this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), 'Successful save message displayed.');
@@ -102,7 +102,7 @@ class UserPermissionsTest extends WebTestBase {
$this->assertFalse(Role::load($this->rid)->isAdmin());
// Set the user's role to be the administrator role.
- $edit = array();
+ $edit = [];
$edit['user_admin_role'] = $this->rid;
$this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration'));
@@ -111,12 +111,12 @@ class UserPermissionsTest extends WebTestBase {
// Enable aggregator module and ensure the 'administer news feeds'
// permission is assigned by default.
- \Drupal::service('module_installer')->install(array('aggregator'));
+ \Drupal::service('module_installer')->install(['aggregator']);
$this->assertTrue($this->adminUser->hasPermission('administer news feeds'), 'The permission was automatically assigned to the administrator role');
// Ensure that selecting '- None -' removes the admin role.
- $edit = array();
+ $edit = [];
$edit['user_admin_role'] = '';
$this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration'));
@@ -148,10 +148,10 @@ class UserPermissionsTest extends WebTestBase {
$this->assertTrue($account->hasPermission('administer site configuration'), 'User has "administer site configuration" permission.');
// Change permissions.
- $permissions = array(
+ $permissions = [
'administer users' => 1,
'access user profiles' => 0,
- );
+ ];
user_role_change_permissions($rid, $permissions);
// Verify proper permission changes.
diff --git a/core/modules/user/src/Tests/UserPictureTest.php b/core/modules/user/src/Tests/UserPictureTest.php
index 3f8db42770d..e4c4d9abec1 100644
--- a/core/modules/user/src/Tests/UserPictureTest.php
+++ b/core/modules/user/src/Tests/UserPictureTest.php
@@ -33,12 +33,12 @@ class UserPictureTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'access content',
'access comments',
'post comments',
'skip comment approval',
- ));
+ ]);
}
/**
@@ -56,17 +56,17 @@ class UserPictureTest extends WebTestBase {
$this->assertRaw(file_uri_target($file->getFileUri()), 'User picture found on user account page.');
// Delete the picture.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Remove'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Call file_cron() to clean up the file. Make sure the timestamp
// of the file is older than the system.file.temporary_maximum_age
// configuration value.
db_update('file_managed')
- ->fields(array(
+ ->fields([
'changed' => REQUEST_TIME - ($this->config('system.file')->get('temporary_maximum_age') + 1),
- ))
+ ])
->condition('fid', $file->id())
->execute();
\Drupal::service('cron')->run();
@@ -88,7 +88,7 @@ class UserPictureTest extends WebTestBase {
$image = current($this->drupalGetTestFiles('image'));
$file = $this->saveUserPicture($image);
- $node = $this->drupalCreateNode(array('type' => 'article'));
+ $node = $this->drupalCreateNode(['type' => 'article']);
// Enable user pictures on nodes.
$this->config('system.theme.global')->set('features.node_user_picture', TRUE)->save();
@@ -109,9 +109,9 @@ class UserPictureTest extends WebTestBase {
->set('features.comment_user_picture', TRUE)
->save();
- $edit = array(
+ $edit = [
'comment_body[0][value]' => $this->randomString(),
- );
+ ];
$this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $edit, t('Save'));
$elements = $this->cssSelect('.comment__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
$this->assertEqual(count($elements), 1, 'User picture with alt text found on the comment.');
@@ -130,12 +130,12 @@ class UserPictureTest extends WebTestBase {
* Edits the user picture for the test user.
*/
function saveUserPicture($image) {
- $edit = array('files[user_picture_0]' => drupal_realpath($image->uri));
+ $edit = ['files[user_picture_0]' => drupal_realpath($image->uri)];
$this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Save'));
// Load actual user data from database.
$user_storage = $this->container->get('entity.manager')->getStorage('user');
- $user_storage->resetCache(array($this->webUser->id()));
+ $user_storage->resetCache([$this->webUser->id()]);
$account = $user_storage->load($this->webUser->id());
return File::load($account->user_picture->target_id);
}
diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php
index d537c6f82ab..6b6937c95ca 100644
--- a/core/modules/user/src/Tests/UserRegistrationTest.php
+++ b/core/modules/user/src/Tests/UserRegistrationTest.php
@@ -21,7 +21,7 @@ class UserRegistrationTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('field_test');
+ public static $modules = ['field_test'];
function testRegistrationWithEmailVerification() {
$config = $this->config('user.settings');
@@ -35,7 +35,7 @@ class UserRegistrationTest extends WebTestBase {
// Allow registration by site visitors without administrator approval.
$config->set('register', USER_REGISTER_VISITORS)->save();
- $edit = array();
+ $edit = [];
$edit['name'] = $name = $this->randomMachineName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
$this->drupalPostForm('user/register', $edit, t('Create new account'));
@@ -52,7 +52,7 @@ class UserRegistrationTest extends WebTestBase {
// Allow registration by site visitors, but require administrator approval.
$config->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save();
- $edit = array();
+ $edit = [];
$edit['name'] = $name = $this->randomMachineName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
$this->drupalPostForm('user/register', $edit, t('Create new account'));
@@ -71,7 +71,7 @@ class UserRegistrationTest extends WebTestBase {
->set('register', USER_REGISTER_VISITORS)
->save();
- $edit = array();
+ $edit = [];
$edit['name'] = $name = $this->randomMachineName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
@@ -95,7 +95,7 @@ class UserRegistrationTest extends WebTestBase {
// Allow registration by site visitors, but require administrator approval.
$config->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save();
- $edit = array();
+ $edit = [];
$edit['name'] = $name = $this->randomMachineName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
$edit['pass[pass1]'] = $pass = $this->randomMachineName();
@@ -104,22 +104,22 @@ class UserRegistrationTest extends WebTestBase {
$this->assertText(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.'), 'Users are notified of pending approval');
// Try to log in before administrator approval.
- $auth = array(
+ $auth = [
'name' => $name,
'pass' => $pass,
- );
+ ];
$this->drupalPostForm('user/login', $auth, t('Log in'));
- $this->assertText(t('The username @name has not been activated or is blocked.', array('@name' => $name)), 'User cannot log in yet.');
+ $this->assertText(t('The username @name has not been activated or is blocked.', ['@name' => $name]), 'User cannot log in yet.');
// Activate the new account.
$accounts = $this->container->get('entity_type.manager')->getStorage('user')
->loadByProperties(['name' => $name, 'mail' => $mail]);
$new_user = reset($accounts);
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
- $edit = array(
+ $edit = [
'status' => 1,
- );
+ ];
$this->drupalPostForm('user/' . $new_user->id() . '/edit', $edit, t('Save'));
$this->drupalLogout();
@@ -139,19 +139,19 @@ class UserRegistrationTest extends WebTestBase {
// Set up a user to check for duplicates.
$duplicate_user = $this->drupalCreateUser();
- $edit = array();
+ $edit = [];
$edit['name'] = $this->randomMachineName();
$edit['mail'] = $duplicate_user->getEmail();
// Attempt to create a new account using an existing email address.
$this->drupalPostForm('user/register', $edit, t('Create new account'));
- $this->assertText(t('The email address @email is already taken.', array('@email' => $duplicate_user->getEmail())), 'Supplying an exact duplicate email address displays an error message');
+ $this->assertText(t('The email address @email is already taken.', ['@email' => $duplicate_user->getEmail()]), 'Supplying an exact duplicate email address displays an error message');
// Attempt to bypass duplicate email registration validation by adding spaces.
$edit['mail'] = ' ' . $duplicate_user->getEmail() . ' ';
$this->drupalPostForm('user/register', $edit, t('Create new account'));
- $this->assertText(t('The email address @email is already taken.', array('@email' => $duplicate_user->getEmail())), 'Supplying a duplicate email address with added whitespace displays an error message');
+ $this->assertText(t('The email address @email is already taken.', ['@email' => $duplicate_user->getEmail()]), 'Supplying a duplicate email address with added whitespace displays an error message');
}
/**
@@ -241,7 +241,7 @@ class UserRegistrationTest extends WebTestBase {
$this->drupalGet('user/register');
$this->assertCacheTag('config:user.settings');
- $edit = array();
+ $edit = [];
$edit['name'] = $name = $this->randomMachineName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
$edit['pass[pass1]'] = $new_pass = $this->randomMachineName();
@@ -285,12 +285,12 @@ class UserRegistrationTest extends WebTestBase {
*/
function testRegistrationWithUserFields() {
// Create a field on 'user' entity type.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'test_user_field',
'entity_type' => 'user',
'type' => 'test_field',
'cardinality' => 1,
- ));
+ ]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
@@ -300,7 +300,7 @@ class UserRegistrationTest extends WebTestBase {
]);
$field->save();
entity_get_form_display('user', 'user', 'default')
- ->setComponent('test_user_field', array('type' => 'test_field_widget'))
+ ->setComponent('test_user_field', ['type' => 'test_field_widget'])
->save();
entity_get_form_display('user', 'user', 'register')
->save();
@@ -313,7 +313,7 @@ class UserRegistrationTest extends WebTestBase {
// Have the field appear on the registration form.
entity_get_form_display('user', 'user', 'register')
- ->setComponent('test_user_field', array('type' => 'test_field_widget'))
+ ->setComponent('test_user_field', ['type' => 'test_field_widget'])
->save();
$this->drupalGet('user/register');
@@ -321,19 +321,19 @@ class UserRegistrationTest extends WebTestBase {
$this->assertRegistrationFormCacheTagsWithUserFields();
// Check that validation errors are correctly reported.
- $edit = array();
+ $edit = [];
$edit['name'] = $name = $this->randomMachineName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
// Missing input in required field.
$edit['test_user_field[0][value]'] = '';
$this->drupalPostForm(NULL, $edit, t('Create new account'));
$this->assertRegistrationFormCacheTagsWithUserFields();
- $this->assertRaw(t('@name field is required.', array('@name' => $field->label())), 'Field validation error was correctly reported.');
+ $this->assertRaw(t('@name field is required.', ['@name' => $field->label()]), 'Field validation error was correctly reported.');
// Invalid input.
$edit['test_user_field[0][value]'] = '-1';
$this->drupalPostForm(NULL, $edit, t('Create new account'));
$this->assertRegistrationFormCacheTagsWithUserFields();
- $this->assertRaw(t('%name does not accept the value -1.', array('%name' => $field->label())), 'Field validation error was correctly reported.');
+ $this->assertRaw(t('%name does not accept the value -1.', ['%name' => $field->label()]), 'Field validation error was correctly reported.');
// Submit with valid data.
$value = rand(1, 255);
@@ -348,12 +348,12 @@ class UserRegistrationTest extends WebTestBase {
// Check that the 'add more' button works.
$field_storage->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$field_storage->save();
- foreach (array('js', 'nojs') as $js) {
+ foreach (['js', 'nojs'] as $js) {
$this->drupalGet('user/register');
$this->assertRegistrationFormCacheTagsWithUserFields();
// Add two inputs.
$value = rand(1, 255);
- $edit = array();
+ $edit = [];
$edit['test_user_field[0][value]'] = $value;
if ($js == 'js') {
$this->drupalPostAjaxForm(NULL, $edit, 'test_user_field_add_more');
@@ -371,11 +371,11 @@ class UserRegistrationTest extends WebTestBase {
$this->drupalPostForm(NULL, $edit, t('Create new account'));
// Check user fields.
$accounts = $this->container->get('entity_type.manager')->getStorage('user')
- ->loadByProperties(array('name' => $name, 'mail' => $mail));
+ ->loadByProperties(['name' => $name, 'mail' => $mail]);
$new_user = reset($accounts);
- $this->assertEqual($new_user->test_user_field[0]->value, $value, format_string('@js : The field value was correctly saved.', array('@js' => $js)));
- $this->assertEqual($new_user->test_user_field[1]->value, $value + 1, format_string('@js : The field value was correctly saved.', array('@js' => $js)));
- $this->assertEqual($new_user->test_user_field[2]->value, $value + 2, format_string('@js : The field value was correctly saved.', array('@js' => $js)));
+ $this->assertEqual($new_user->test_user_field[0]->value, $value, format_string('@js : The field value was correctly saved.', ['@js' => $js]));
+ $this->assertEqual($new_user->test_user_field[1]->value, $value + 1, format_string('@js : The field value was correctly saved.', ['@js' => $js]));
+ $this->assertEqual($new_user->test_user_field[2]->value, $value + 2, format_string('@js : The field value was correctly saved.', ['@js' => $js]));
}
}
diff --git a/core/modules/user/src/Tests/UserRoleAdminTest.php b/core/modules/user/src/Tests/UserRoleAdminTest.php
index 182da93cb00..5b0be69c830 100644
--- a/core/modules/user/src/Tests/UserRoleAdminTest.php
+++ b/core/modules/user/src/Tests/UserRoleAdminTest.php
@@ -32,7 +32,7 @@ class UserRoleAdminTest extends WebTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'administer users'));
+ $this->adminUser = $this->drupalCreateUser(['administer permissions', 'administer users']);
$this->drupalPlaceBlock('local_tasks_block');
}
@@ -44,19 +44,19 @@ class UserRoleAdminTest extends WebTestBase {
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
// Test presence of tab.
$this->drupalGet('admin/people/permissions');
- $tabs = $this->xpath('//ul[@class=:classes and //a[contains(., :text)]]', array(
+ $tabs = $this->xpath('//ul[@class=:classes and //a[contains(., :text)]]', [
':classes' => 'tabs primary',
':text' => t('Roles'),
- ));
+ ]);
$this->assertEqual(count($tabs), 1, 'Found roles tab');
// Test adding a role. (In doing so, we use a role name that happens to
// correspond to an integer, to test that the role administration pages
// correctly distinguish between role names and IDs.)
$role_name = '123';
- $edit = array('label' => $role_name, 'id' => $role_name);
+ $edit = ['label' => $role_name, 'id' => $role_name];
$this->drupalPostForm('admin/people/roles/add', $edit, t('Save'));
- $this->assertRaw(t('Role %label has been added.', array('%label' => 123)));
+ $this->assertRaw(t('Role %label has been added.', ['%label' => 123]));
$role = Role::load($role_name);
$this->assertTrue(is_object($role), 'The role was successfully retrieved from the database.');
@@ -69,20 +69,20 @@ class UserRoleAdminTest extends WebTestBase {
// Test renaming a role.
$role_name = '456';
- $edit = array('label' => $role_name);
+ $edit = ['label' => $role_name];
$this->drupalPostForm("admin/people/roles/manage/{$role->id()}", $edit, t('Save'));
- $this->assertRaw(t('Role %label has been updated.', array('%label' => $role_name)));
- \Drupal::entityManager()->getStorage('user_role')->resetCache(array($role->id()));
+ $this->assertRaw(t('Role %label has been updated.', ['%label' => $role_name]));
+ \Drupal::entityManager()->getStorage('user_role')->resetCache([$role->id()]);
$new_role = Role::load($role->id());
$this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.');
// Test deleting a role.
$this->drupalGet("admin/people/roles/manage/{$role->id()}");
$this->clickLink(t('Delete'));
- $this->drupalPostForm(NULL, array(), t('Delete'));
- $this->assertRaw(t('The role %label has been deleted.', array('%label' => $role_name)));
+ $this->drupalPostForm(NULL, [], t('Delete'));
+ $this->assertRaw(t('The role %label has been deleted.', ['%label' => $role_name]));
$this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.');
- \Drupal::entityManager()->getStorage('user_role')->resetCache(array($role->id()));
+ \Drupal::entityManager()->getStorage('user_role')->resetCache([$role->id()]);
$this->assertFalse(Role::load($role->id()), 'A deleted role can no longer be loaded.');
// Make sure that the system-defined roles can be edited via the user
@@ -102,11 +102,11 @@ class UserRoleAdminTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
$roles = user_roles();
$weight = count($roles);
- $new_role_weights = array();
- $saved_rids = array();
+ $new_role_weights = [];
+ $saved_rids = [];
// Change the role weights to make the roles in reverse order.
- $edit = array();
+ $edit = [];
foreach ($roles as $role) {
$edit['entities[' . $role->id() . '][weight]'] = $weight;
$new_role_weights[$role->id()] = $weight;
@@ -119,7 +119,7 @@ class UserRoleAdminTest extends WebTestBase {
// Load up the user roles with the new weights.
drupal_static_reset('user_roles');
$roles = user_roles();
- $rids = array();
+ $rids = [];
// Test that the role weights have been correctly saved.
foreach ($roles as $role) {
$this->assertEqual($role->getWeight(), $new_role_weights[$role->id()]);
diff --git a/core/modules/user/src/Tests/UserTimeZoneTest.php b/core/modules/user/src/Tests/UserTimeZoneTest.php
index 3229d319bb5..9b027b55715 100644
--- a/core/modules/user/src/Tests/UserTimeZoneTest.php
+++ b/core/modules/user/src/Tests/UserTimeZoneTest.php
@@ -17,7 +17,7 @@ class UserTimeZoneTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'system_test');
+ public static $modules = ['node', 'system_test'];
/**
* Tests the display of dates and time when user-configurable time zones are set.
@@ -42,10 +42,10 @@ class UserTimeZoneTest extends WebTestBase {
$date2 = '2007-03-11 01:00:00 -0800';
// One date in PDT (summer time):
$date3 = '2007-03-20 21:00:00 -0700';
- $this->drupalCreateContentType(array('type' => 'article'));
- $node1 = $this->drupalCreateNode(array('created' => strtotime($date1), 'type' => 'article'));
- $node2 = $this->drupalCreateNode(array('created' => strtotime($date2), 'type' => 'article'));
- $node3 = $this->drupalCreateNode(array('created' => strtotime($date3), 'type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
+ $node1 = $this->drupalCreateNode(['created' => strtotime($date1), 'type' => 'article']);
+ $node2 = $this->drupalCreateNode(['created' => strtotime($date2), 'type' => 'article']);
+ $node3 = $this->drupalCreateNode(['created' => strtotime($date3), 'type' => 'article']);
// Confirm date format and time zone.
$this->drupalGet('node/' . $node1->id());
@@ -56,7 +56,7 @@ class UserTimeZoneTest extends WebTestBase {
$this->assertText('2007-03-20 21:00 PDT', 'Date should be PDT.');
// Change user time zone to Santiago time.
- $edit = array();
+ $edit = [];
$edit['mail'] = $web_user->getEmail();
$edit['timezone'] = 'America/Santiago';
$this->drupalPostForm("user/" . $web_user->id() . "/edit", $edit, t('Save'));
diff --git a/core/modules/user/src/Tests/UserTranslationUITest.php b/core/modules/user/src/Tests/UserTranslationUITest.php
index 82a34451452..32a9b8febbd 100644
--- a/core/modules/user/src/Tests/UserTranslationUITest.php
+++ b/core/modules/user/src/Tests/UserTranslationUITest.php
@@ -23,7 +23,7 @@ class UserTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'user', 'views');
+ public static $modules = ['language', 'content_translation', 'user', 'views'];
protected function setUp() {
$this->entityTypeId = 'user';
@@ -38,7 +38,7 @@ class UserTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('administer users'));
+ return array_merge(parent::getTranslatorPermissions(), ['administer users']);
}
/**
@@ -46,7 +46,7 @@ class UserTranslationUITest extends ContentTranslationUITestBase {
*/
protected function getNewEntityValues($langcode) {
// User name is not translatable hence we use a fixed value.
- return array('name' => $this->name) + parent::getNewEntityValues($langcode);
+ return ['name' => $this->name] + parent::getNewEntityValues($langcode);
}
/**
@@ -62,14 +62,14 @@ class UserTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('@title [%language translation]', array(
+ $title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
diff --git a/core/modules/user/src/Tests/Views/AccessPermissionTest.php b/core/modules/user/src/Tests/Views/AccessPermissionTest.php
index b8ef5a9f8e8..f82b103d283 100644
--- a/core/modules/user/src/Tests/Views/AccessPermissionTest.php
+++ b/core/modules/user/src/Tests/Views/AccessPermissionTest.php
@@ -19,7 +19,7 @@ class AccessPermissionTest extends AccessTestBase {
*
* @var array
*/
- public static $testViews = array('test_access_perm');
+ public static $testViews = ['test_access_perm'];
/**
* Tests perm access plugin.
diff --git a/core/modules/user/src/Tests/Views/AccessRoleTest.php b/core/modules/user/src/Tests/Views/AccessRoleTest.php
index 24629158b8f..04f2876dc00 100644
--- a/core/modules/user/src/Tests/Views/AccessRoleTest.php
+++ b/core/modules/user/src/Tests/Views/AccessRoleTest.php
@@ -20,7 +20,7 @@ class AccessRoleTest extends AccessTestBase {
*
* @var array
*/
- public static $testViews = array('test_access_role');
+ public static $testViews = ['test_access_role'];
/**
* Tests role access plugin.
@@ -29,9 +29,9 @@ class AccessRoleTest extends AccessTestBase {
/** @var \Drupal\views\ViewEntityInterface $view */
$view = \Drupal::entityManager()->getStorage('view')->load('test_access_role');
$display = &$view->getDisplay('default');
- $display['display_options']['access']['options']['role'] = array(
+ $display['display_options']['access']['options']['role'] = [
$this->normalRole => $this->normalRole,
- );
+ ];
$view->save();
$this->container->get('router.builder')->rebuildIfNeeded();
$expected = [
@@ -63,10 +63,10 @@ class AccessRoleTest extends AccessTestBase {
// Test allowing multiple roles.
$view = Views::getView('test_access_role')->storage;
$display = &$view->getDisplay('default');
- $display['display_options']['access']['options']['role'] = array(
+ $display['display_options']['access']['options']['role'] = [
$this->normalRole => $this->normalRole,
'anonymous' => 'anonymous',
- );
+ ];
$view->save();
$this->container->get('router.builder')->rebuildIfNeeded();
@@ -102,9 +102,9 @@ class AccessRoleTest extends AccessTestBase {
$display['display_options']['cache'] = [
'type' => 'tag',
];
- $display['display_options']['access']['options']['role'] = array(
+ $display['display_options']['access']['options']['role'] = [
$this->normalRole => $this->normalRole,
- );
+ ];
$view->save();
/** @var \Drupal\Core\Render\RendererInterface $renderer */
diff --git a/core/modules/user/src/Tests/Views/AccessRoleUITest.php b/core/modules/user/src/Tests/Views/AccessRoleUITest.php
index 7fb94960099..bea8c53c603 100644
--- a/core/modules/user/src/Tests/Views/AccessRoleUITest.php
+++ b/core/modules/user/src/Tests/Views/AccessRoleUITest.php
@@ -18,14 +18,14 @@ class AccessRoleUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_access_role');
+ public static $testViews = ['test_access_role'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('user', 'user_test_views');
+ public static $modules = ['user', 'user_test_views'];
/**
* {@inheritdoc}
@@ -33,7 +33,7 @@ class AccessRoleUITest extends UITestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('user_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['user_test_views']);
}
/**
@@ -41,20 +41,20 @@ class AccessRoleUITest extends UITestBase {
*/
public function testAccessRoleUI() {
$entity_manager = $this->container->get('entity.manager');
- $entity_manager->getStorage('user_role')->create(array('id' => 'custom_role', 'label' => 'Custom role'))->save();
+ $entity_manager->getStorage('user_role')->create(['id' => 'custom_role', 'label' => 'Custom role'])->save();
$access_url = "admin/structure/views/nojs/display/test_access_role/default/access_options";
- $this->drupalPostForm($access_url, array('access_options[role][custom_role]' => 1), t('Apply'));
+ $this->drupalPostForm($access_url, ['access_options[role][custom_role]' => 1], t('Apply'));
$this->assertResponse(200);
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = $entity_manager->getStorage('view')->load('test_access_role');
$display = $view->getDisplay('default');
- $this->assertEqual($display['display_options']['access']['options']['role'], array('custom_role' => 'custom_role'));
+ $this->assertEqual($display['display_options']['access']['options']['role'], ['custom_role' => 'custom_role']);
// Test changing access plugin from role to none.
$this->drupalPostForm('admin/structure/views/nojs/display/test_access_role/default/access', ['access[type]' => 'none'], t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Verify that role option is not set.
$view = $entity_manager->getStorage('view')->load('test_access_role');
$display = $view->getDisplay('default');
diff --git a/core/modules/user/src/Tests/Views/AccessTestBase.php b/core/modules/user/src/Tests/Views/AccessTestBase.php
index 90a3d2f52e5..b0395b0f09a 100644
--- a/core/modules/user/src/Tests/Views/AccessTestBase.php
+++ b/core/modules/user/src/Tests/Views/AccessTestBase.php
@@ -12,7 +12,7 @@ abstract class AccessTestBase extends UserTestBase {
*
* @var array
*/
- public static $modules = array('block');
+ public static $modules = ['block'];
/**
* Contains a user object that has no special permissions.
@@ -55,8 +55,8 @@ abstract class AccessTestBase extends UserTestBase {
$roles = $this->webUser->getRoles();
$this->webRole = $roles[0];
- $this->normalRole = $this->drupalCreateRole(array());
- $this->normalUser = $this->drupalCreateUser(array('views_test_data test permission'));
+ $this->normalRole = $this->drupalCreateRole([]);
+ $this->normalUser = $this->drupalCreateUser(['views_test_data test permission']);
$this->normalUser->addRole($this->normalRole);
$this->normalUser->save();
// @todo when all the plugin information is cached make a reset function and
diff --git a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php
index 4e21d79cfb1..7db32373a84 100644
--- a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php
+++ b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php
@@ -16,7 +16,7 @@ class ArgumentDefaultTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_plugin_argument_default_current_user');
+ public static $testViews = ['test_plugin_argument_default_current_user'];
public function test_plugin_argument_default_current_user() {
// Create a user to test.
diff --git a/core/modules/user/src/Tests/Views/ArgumentValidateTest.php b/core/modules/user/src/Tests/Views/ArgumentValidateTest.php
index 0a49142547d..1f60df20d90 100644
--- a/core/modules/user/src/Tests/Views/ArgumentValidateTest.php
+++ b/core/modules/user/src/Tests/Views/ArgumentValidateTest.php
@@ -18,7 +18,7 @@ class ArgumentValidateTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_view_argument_validate_user', 'test_view_argument_validate_username');
+ public static $testViews = ['test_view_argument_validate_user', 'test_view_argument_validate_username'];
/**
* A user for this test.
@@ -48,7 +48,7 @@ class ArgumentValidateTest extends UserTestBase {
// Fail for a valid numeric, but for a user that doesn't exist
$this->assertFalse($view->argument['null']->validateArgument(32));
- $form = array();
+ $form = [];
$form_state = new FormState();
$view->argument['null']->buildOptionsForm($form, $form_state);
$sanitized_id = ArgumentPluginBase::encodeValidatorId('entity:user');
diff --git a/core/modules/user/src/Tests/Views/BulkFormAccessTest.php b/core/modules/user/src/Tests/Views/BulkFormAccessTest.php
index 3aa5f93f4e2..2b36240442a 100644
--- a/core/modules/user/src/Tests/Views/BulkFormAccessTest.php
+++ b/core/modules/user/src/Tests/Views/BulkFormAccessTest.php
@@ -18,26 +18,26 @@ class BulkFormAccessTest extends UserTestBase {
*
* @var array
*/
- public static $modules = array('user_access_test');
+ public static $modules = ['user_access_test'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_user_bulk_form');
+ public static $testViews = ['test_user_bulk_form'];
/**
* Tests if users that may not be edited, can not be edited in bulk.
*/
public function testUserEditAccess() {
// Create an authenticated user.
- $no_edit_user = $this->drupalCreateUser(array(), 'no_edit');
+ $no_edit_user = $this->drupalCreateUser([], 'no_edit');
// Ensure this account is not blocked.
$this->assertFalse($no_edit_user->isBlocked(), 'The user is not blocked.');
// Log in as user admin.
- $admin_user = $this->drupalCreateUser(array('administer users'));
+ $admin_user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($admin_user);
// Ensure that the account "no_edit" can not be edited.
@@ -46,10 +46,10 @@ class BulkFormAccessTest extends UserTestBase {
$this->assertResponse(403, 'The user may not be edited.');
// Test blocking the account "no_edit".
- $edit = array(
+ $edit = [
'user_bulk_form[' . ($no_edit_user->id() - 1) . ']' => TRUE,
'action' => 'user_block_user_action',
- );
+ ];
$this->drupalPostForm('test-user-bulk-form', $edit, t('Apply to selected items'));
$this->assertResponse(200);
@@ -67,10 +67,10 @@ class BulkFormAccessTest extends UserTestBase {
$normal_user = $this->drupalCreateUser();
$this->assertTrue($normal_user->access('update', $admin_user));
- $edit = array(
+ $edit = [
'user_bulk_form[' . ($normal_user->id() - 1) . ']' => TRUE,
'action' => 'user_block_user_action',
- );
+ ];
$this->drupalPostForm('test-user-bulk-form', $edit, t('Apply to selected items'));
$normal_user = User::load($normal_user->id());
@@ -79,10 +79,10 @@ class BulkFormAccessTest extends UserTestBase {
// Log in as user without the 'administer users' permission.
$this->drupalLogin($this->drupalCreateUser());
- $edit = array(
+ $edit = [
'user_bulk_form[' . ($normal_user->id() - 1) . ']' => TRUE,
'action' => 'user_unblock_user_action',
- );
+ ];
$this->drupalPostForm('test-user-bulk-form', $edit, t('Apply to selected items'));
// Re-load the normal user and ensure it is still blocked.
@@ -95,11 +95,11 @@ class BulkFormAccessTest extends UserTestBase {
*/
public function testUserDeleteAccess() {
// Create two authenticated users.
- $account = $this->drupalCreateUser(array(), 'no_delete');
- $account2 = $this->drupalCreateUser(array(), 'may_delete');
+ $account = $this->drupalCreateUser([], 'no_delete');
+ $account2 = $this->drupalCreateUser([], 'may_delete');
// Log in as user admin.
- $this->drupalLogin($this->drupalCreateUser(array('administer users')));
+ $this->drupalLogin($this->drupalCreateUser(['administer users']));
// Ensure that the account "no_delete" can not be deleted.
$this->drupalGet('user/' . $account->id() . '/cancel');
@@ -109,15 +109,15 @@ class BulkFormAccessTest extends UserTestBase {
$this->assertResponse(200, 'The user "may_delete" may be deleted.');
// Test deleting the accounts "no_delete" and "may_delete".
- $edit = array(
+ $edit = [
'user_bulk_form[' . ($account->id() - 1) . ']' => TRUE,
'user_bulk_form[' . ($account2->id() - 1) . ']' => TRUE,
'action' => 'user_cancel_user_action',
- );
+ ];
$this->drupalPostForm('test-user-bulk-form', $edit, t('Apply to selected items'));
- $edit = array(
+ $edit = [
'user_cancel_method' => 'user_cancel_delete',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Cancel accounts'));
// Ensure the account "no_delete" still exists.
diff --git a/core/modules/user/src/Tests/Views/BulkFormTest.php b/core/modules/user/src/Tests/Views/BulkFormTest.php
index 00bdc821b01..665af74a94c 100644
--- a/core/modules/user/src/Tests/Views/BulkFormTest.php
+++ b/core/modules/user/src/Tests/Views/BulkFormTest.php
@@ -19,33 +19,33 @@ class BulkFormTest extends UserTestBase {
*
* @var array
*/
- public static $modules = array('views_ui');
+ public static $modules = ['views_ui'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_user_bulk_form', 'test_user_bulk_form_combine_filter');
+ public static $testViews = ['test_user_bulk_form', 'test_user_bulk_form_combine_filter'];
/**
* Tests the user bulk form.
*/
public function testBulkForm() {
// Log in as a user without 'administer users'.
- $this->drupalLogin($this->drupalCreateUser(array('administer permissions')));
+ $this->drupalLogin($this->drupalCreateUser(['administer permissions']));
$user_storage = $this->container->get('entity.manager')->getStorage('user');
// Create an user which actually can change users.
- $this->drupalLogin($this->drupalCreateUser(array('administer users')));
+ $this->drupalLogin($this->drupalCreateUser(['administer users']));
$this->drupalGet('test-user-bulk-form');
$result = $this->cssSelect('#edit-action option');
$this->assertTrue(count($result) > 0);
// Test submitting the page with no selection.
- $edit = array(
+ $edit = [
'action' => 'user_block_user_action',
- );
+ ];
$this->drupalPostForm('test-user-bulk-form', $edit, t('Apply to selected items'));
$this->assertText(t('No users selected.'));
@@ -56,36 +56,36 @@ class BulkFormTest extends UserTestBase {
$role = key($roles);
$this->assertFalse($account->hasRole($role), 'The user currently does not have a custom role.');
- $edit = array(
+ $edit = [
'user_bulk_form[1]' => TRUE,
'action' => 'user_add_role_action.' . $role,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
// Re-load the user and check their roles.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->hasRole($role), 'The user now has the custom role.');
- $edit = array(
+ $edit = [
'user_bulk_form[1]' => TRUE,
'action' => 'user_remove_role_action.' . $role,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
// Re-load the user and check their roles.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertFalse($account->hasRole($role), 'The user no longer has the custom role.');
// Block a user using the bulk form.
$this->assertTrue($account->isActive(), 'The user is not blocked.');
$this->assertRaw($account->label(), 'The user is found in the table.');
- $edit = array(
+ $edit = [
'user_bulk_form[1]' => TRUE,
'action' => 'user_block_user_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
// Re-load the user and check their status.
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->isBlocked(), 'The user is blocked.');
$this->assertNoRaw($account->label(), 'The user is not found in the table.');
@@ -100,16 +100,16 @@ class BulkFormTest extends UserTestBase {
$this->assertText($this->config('user.settings')->get('anonymous'));
// Attempt to block the anonymous user.
- $edit = array(
+ $edit = [
'user_bulk_form[0]' => TRUE,
'action' => 'user_block_user_action',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
$anonymous_account = $user_storage->load(0);
$this->assertTrue($anonymous_account->isBlocked(), 'Ensure the anonymous user got blocked.');
// Test the list of available actions with a value that contains a dot.
- $this->drupalLogin($this->drupalCreateUser(array('administer permissions', 'administer views', 'administer users')));
+ $this->drupalLogin($this->drupalCreateUser(['administer permissions', 'administer views', 'administer users']));
$action_id = 'user_add_role_action.' . $role;
$edit = [
'options[include_exclude]' => 'exclude',
@@ -134,7 +134,7 @@ class BulkFormTest extends UserTestBase {
User::load($this->users[0]->id());
$view = Views::getView('test_user_bulk_form_combine_filter');
$errors = $view->validate();
- $this->assertEqual(reset($errors['default']), t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', array('%field' => 'User: Bulk update', '%filter' => 'Global: Combine fields filter')));
+ $this->assertEqual(reset($errors['default']), t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', ['%field' => 'User: Bulk update', '%filter' => 'Global: Combine fields filter']));
}
}
diff --git a/core/modules/user/src/Tests/Views/FilterPermissionUiTest.php b/core/modules/user/src/Tests/Views/FilterPermissionUiTest.php
index e55c6c38e12..f9444bc7d70 100644
--- a/core/modules/user/src/Tests/Views/FilterPermissionUiTest.php
+++ b/core/modules/user/src/Tests/Views/FilterPermissionUiTest.php
@@ -30,7 +30,7 @@ class FilterPermissionUiTest extends ViewTestBase {
protected function setUp() {
parent::setUp(TRUE);
- ViewTestData::createTestViews(get_class($this), array('user_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['user_test_views']);
$this->enableViewsTestModule();
}
diff --git a/core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php b/core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php
index d84a5425284..73ee53fabbf 100644
--- a/core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php
@@ -16,7 +16,7 @@ class HandlerArgumentUserUidTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_user_uid_argument');
+ public static $testViews = ['test_user_uid_argument'];
/**
* Tests the generated title of an user: uid argument.
@@ -25,29 +25,29 @@ class HandlerArgumentUserUidTest extends UserTestBase {
$view = Views::getView('test_user_uid_argument');
// Tests an invalid user uid.
- $this->executeView($view, array(rand(1000, 10000)));
+ $this->executeView($view, [rand(1000, 10000)]);
$this->assertFalse($view->getTitle());
$view->destroy();
// Tests a valid user.
$account = $this->drupalCreateUser();
- $this->executeView($view, array($account->id()));
+ $this->executeView($view, [$account->id()]);
$this->assertEqual($view->getTitle(), $account->label());
$view->destroy();
// Tests the anonymous user.
$anonymous = $this->config('user.settings')->get('anonymous');
- $this->executeView($view, array(0));
+ $this->executeView($view, [0]);
$this->assertEqual($view->getTitle(), $anonymous);
$view->destroy();
$view->getDisplay()->getHandler('argument', 'uid')->options['break_phrase'] = TRUE;
- $this->executeView($view, array($account->id() . ',0'));
+ $this->executeView($view, [$account->id() . ',0']);
$this->assertEqual($view->getTitle(), $account->label() . ', ' . $anonymous);
$view->destroy();
$view->getDisplay()->getHandler('argument', 'uid')->options['break_phrase'] = TRUE;
- $this->executeView($view, array('0,' . $account->id()));
+ $this->executeView($view, ['0,' . $account->id()]);
$this->assertEqual($view->getTitle(), $anonymous . ', ' . $account->label());
$view->destroy();
}
diff --git a/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php b/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php
index de7c65c906b..6a5ebfc6482 100644
--- a/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php
@@ -18,18 +18,18 @@ class HandlerFieldRoleTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_views_handler_field_role');
+ public static $testViews = ['test_views_handler_field_role'];
public function testRole() {
// Create a couple of roles for the view.
$rolename_a = 'a' . $this->randomMachineName(8);
- $this->drupalCreateRole(array('access content'), $rolename_a, '<em>' . $rolename_a . '</em>', 9);
+ $this->drupalCreateRole(['access content'], $rolename_a, '<em>' . $rolename_a . '</em>', 9);
$rolename_b = 'b' . $this->randomMachineName(8);
- $this->drupalCreateRole(array('access content'), $rolename_b, $rolename_b, 8);
+ $this->drupalCreateRole(['access content'], $rolename_b, $rolename_b, 8);
$rolename_not_assigned = $this->randomMachineName(8);
- $this->drupalCreateRole(array('access content'), $rolename_not_assigned, $rolename_not_assigned);
+ $this->drupalCreateRole(['access content'], $rolename_not_assigned, $rolename_not_assigned);
// Add roles to user 1.
$user = User::load(1);
diff --git a/core/modules/user/src/Tests/Views/HandlerFieldUserNameTest.php b/core/modules/user/src/Tests/Views/HandlerFieldUserNameTest.php
index 6af16447eb9..39a3ec87c10 100644
--- a/core/modules/user/src/Tests/Views/HandlerFieldUserNameTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFieldUserNameTest.php
@@ -18,13 +18,13 @@ class HandlerFieldUserNameTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_views_handler_field_user_name');
+ public static $testViews = ['test_views_handler_field_user_name'];
public function testUserName() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
- $new_user = $this->drupalCreateUser(array('access user profiles'));
+ $new_user = $this->drupalCreateUser(['access user profiles']);
$this->drupalLogin($new_user);
// Set defaults.
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php b/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
index eaf24aa0fd6..c4f70656c82 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
@@ -19,47 +19,47 @@ class HandlerFilterUserNameTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('views_ui', 'user_test_views');
+ public static $modules = ['views_ui', 'user_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_user_name');
+ public static $testViews = ['test_user_name'];
/**
* Accounts used by this test.
*
* @var array
*/
- protected $accounts = array();
+ protected $accounts = [];
/**
* Usernames of $accounts.
*
* @var array
*/
- protected $names = array();
+ protected $names = [];
/**
* Stores the column map for this testCase.
*
* @var array
*/
- public $columnMap = array(
+ public $columnMap = [
'uid' => 'uid',
- );
+ ];
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('user_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['user_test_views']);
$this->enableViewsTestModule();
- $this->accounts = array();
- $this->names = array();
+ $this->accounts = [];
+ $this->names = [];
for ($i = 0; $i < 3; $i++) {
$this->accounts[] = $account = $this->drupalCreateUser();
$this->names[] = $account->label();
@@ -74,10 +74,10 @@ class HandlerFilterUserNameTest extends ViewTestBase {
$view = Views::getView('test_user_name');
$view->initHandlers();
- $view->filter['uid']->value = array($this->accounts[0]->id());
+ $view->filter['uid']->value = [$this->accounts[0]->id()];
$this->executeView($view);
- $this->assertIdenticalResultset($view, array(array('uid' => $this->accounts[0]->id())), $this->columnMap);
+ $this->assertIdenticalResultset($view, [['uid' => $this->accounts[0]->id()]], $this->columnMap);
$this->assertEqual($view->filter['uid']->getValueOptions(), NULL);
}
@@ -86,40 +86,40 @@ class HandlerFilterUserNameTest extends ViewTestBase {
* Tests using the user interface.
*/
public function testAdminUserInterface() {
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
$path = 'admin/structure/views/nojs/handler/test_user_name/default/filter/uid';
$this->drupalGet($path);
// Pass in an invalid username, the validation should catch it.
- $users = array($this->randomMachineName());
+ $users = [$this->randomMachineName()];
$users = array_map('strtolower', $users);
- $edit = array(
+ $edit = [
'options[value]' => implode(', ', $users)
- );
+ ];
$this->drupalPostForm($path, $edit, t('Apply'));
- $this->assertRaw(t('There are no entities matching "%value".', array('%value' => implode(', ', $users))));
+ $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
// Pass in an invalid username and a valid username.
$random_name = $this->randomMachineName();
- $users = array($random_name, $this->names[0]);
+ $users = [$random_name, $this->names[0]];
$users = array_map('strtolower', $users);
- $edit = array(
+ $edit = [
'options[value]' => implode(', ', $users)
- );
- $users = array($users[0]);
+ ];
+ $users = [$users[0]];
$this->drupalPostForm($path, $edit, t('Apply'));
- $this->assertRaw(t('There are no entities matching "%value".', array('%value' => implode(', ', $users))));
+ $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
// Pass in just valid usernames.
$users = $this->names;
$users = array_map('strtolower', $users);
- $edit = array(
+ $edit = [
'options[value]' => implode(', ', $users)
- );
+ ];
$this->drupalPostForm($path, $edit, t('Apply'));
- $this->assertNoRaw(t('There are no entities matching "%value".', array('%value' => implode(', ', $users))));
+ $this->assertNoRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
}
/**
@@ -128,14 +128,14 @@ class HandlerFilterUserNameTest extends ViewTestBase {
public function testExposedFilter() {
$path = 'test_user_name';
- $options = array();
+ $options = [];
// Pass in an invalid username, the validation should catch it.
- $users = array($this->randomMachineName());
+ $users = [$this->randomMachineName()];
$users = array_map('strtolower', $users);
$options['query']['uid'] = implode(', ', $users);
$this->drupalGet($path, $options);
- $this->assertRaw(t('There are no entities matching "%value".', array('%value' => implode(', ', $users))));
+ $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
// Pass in an invalid target_id in for the entity_autocomplete value format.
// There should be no errors, but all results should be returned as the
@@ -149,13 +149,13 @@ class HandlerFilterUserNameTest extends ViewTestBase {
}
// Pass in an invalid username and a valid username.
- $users = array($this->randomMachineName(), $this->names[0]);
+ $users = [$this->randomMachineName(), $this->names[0]];
$users = array_map('strtolower', $users);
$options['query']['uid'] = implode(', ', $users);
- $users = array($users[0]);
+ $users = [$users[0]];
$this->drupalGet($path, $options);
- $this->assertRaw(t('There are no entities matching "%value".', array('%value' => implode(', ', $users))));
+ $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
// Pass in just valid usernames.
$users = $this->names;
diff --git a/core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php b/core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php
index 3ad6346a535..14f44123e3e 100644
--- a/core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php
+++ b/core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php
@@ -16,7 +16,7 @@ class RelationshipRepresentativeNodeTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_groupwise_user');
+ public static $testViews = ['test_groupwise_user'];
/**
* Tests the relationship.
@@ -24,17 +24,17 @@ class RelationshipRepresentativeNodeTest extends UserTestBase {
public function testRelationship() {
$view = Views::getView('test_groupwise_user');
$this->executeView($view);
- $map = array('node_field_data_users_field_data_nid' => 'nid', 'uid' => 'uid');
- $expected_result = array(
- array(
+ $map = ['node_field_data_users_field_data_nid' => 'nid', 'uid' => 'uid'];
+ $expected_result = [
+ [
'uid' => $this->users[1]->id(),
'nid' => $this->nodes[1]->id(),
- ),
- array(
+ ],
+ [
'uid' => $this->users[0]->id(),
'nid' => $this->nodes[0]->id(),
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $map);
}
diff --git a/core/modules/user/src/Tests/Views/RolesRidArgumentTest.php b/core/modules/user/src/Tests/Views/RolesRidArgumentTest.php
index a658b2202b4..58782e94c76 100644
--- a/core/modules/user/src/Tests/Views/RolesRidArgumentTest.php
+++ b/core/modules/user/src/Tests/Views/RolesRidArgumentTest.php
@@ -15,7 +15,7 @@ class RolesRidArgumentTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_user_roles_rid');
+ public static $testViews = ['test_user_roles_rid'];
/**
* Tests the generated title of a user: roles argument.
diff --git a/core/modules/user/src/Tests/Views/UserChangedTest.php b/core/modules/user/src/Tests/Views/UserChangedTest.php
index 50e21e58885..ddd7903e546 100644
--- a/core/modules/user/src/Tests/Views/UserChangedTest.php
+++ b/core/modules/user/src/Tests/Views/UserChangedTest.php
@@ -17,19 +17,19 @@ class UserChangedTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('views_ui', 'user_test_views');
+ public static $modules = ['views_ui', 'user_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_user_changed');
+ public static $testViews = ['test_user_changed'];
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('user_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['user_test_views']);
$this->enableViewsTestModule();
}
@@ -40,7 +40,7 @@ class UserChangedTest extends ViewTestBase {
public function testChangedField() {
$path = 'test_user_changed';
- $options = array();
+ $options = [];
$this->drupalGet($path, $options);
diff --git a/core/modules/user/src/Tests/Views/UserDataTest.php b/core/modules/user/src/Tests/Views/UserDataTest.php
index a55eac5e761..4628ae2b7de 100644
--- a/core/modules/user/src/Tests/Views/UserDataTest.php
+++ b/core/modules/user/src/Tests/Views/UserDataTest.php
@@ -24,7 +24,7 @@ class UserDataTest extends UserTestBase {
*
* @var array
*/
- public static $testViews = array('test_user_data');
+ public static $testViews = ['test_user_data'];
/**
* Tests field handler.
diff --git a/core/modules/user/src/Tests/Views/UserTestBase.php b/core/modules/user/src/Tests/Views/UserTestBase.php
index 4c8007aeb3f..c49dcb2379c 100644
--- a/core/modules/user/src/Tests/Views/UserTestBase.php
+++ b/core/modules/user/src/Tests/Views/UserTestBase.php
@@ -16,31 +16,31 @@ abstract class UserTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('user_test_views', 'node');
+ public static $modules = ['user_test_views', 'node'];
/**
* Users to use during this test.
*
* @var array
*/
- protected $users = array();
+ protected $users = [];
/**
* Nodes to use during this test.
*
* @var array
*/
- protected $nodes = array();
+ protected $nodes = [];
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('user_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['user_test_views']);
$this->users[] = $this->drupalCreateUser();
$this->users[] = User::load(1);
- $this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->id()));
- $this->nodes[] = $this->drupalCreateNode(array('uid' => 1));
+ $this->nodes[] = $this->drupalCreateNode(['uid' => $this->users[0]->id()]);
+ $this->nodes[] = $this->drupalCreateNode(['uid' => 1]);
}
}
diff --git a/core/modules/user/src/UserAccessControlHandler.php b/core/modules/user/src/UserAccessControlHandler.php
index dd7142c5c4f..712b32ab515 100644
--- a/core/modules/user/src/UserAccessControlHandler.php
+++ b/core/modules/user/src/UserAccessControlHandler.php
@@ -80,9 +80,9 @@ class UserAccessControlHandler extends EntityAccessControlHandler {
*/
protected function checkFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
// Fields that are not implicitly allowed to administrative users.
- $explicit_check_fields = array(
+ $explicit_check_fields = [
'pass',
- );
+ ];
// Administrative users are allowed to edit and view all fields.
if (!in_array($field_definition->getName(), $explicit_check_fields) && $account->hasPermission('administer users')) {
diff --git a/core/modules/user/src/UserAuth.php b/core/modules/user/src/UserAuth.php
index 9fbcf094869..43ce31b8620 100644
--- a/core/modules/user/src/UserAuth.php
+++ b/core/modules/user/src/UserAuth.php
@@ -44,7 +44,7 @@ class UserAuth implements UserAuthInterface {
$uid = FALSE;
if (!empty($username) && strlen($password) > 0) {
- $account_search = $this->entityManager->getStorage('user')->loadByProperties(array('name' => $username));
+ $account_search = $this->entityManager->getStorage('user')->loadByProperties(['name' => $username]);
if ($account = reset($account_search)) {
if ($this->passwordChecker->check($password, $account->getPassword())) {
diff --git a/core/modules/user/src/UserData.php b/core/modules/user/src/UserData.php
index 3418c838466..735c3de4e61 100644
--- a/core/modules/user/src/UserData.php
+++ b/core/modules/user/src/UserData.php
@@ -50,7 +50,7 @@ class UserData implements UserDataInterface {
}
// If $module and $uid was passed, return the name/value pairs.
elseif (isset($uid)) {
- $return = array();
+ $return = [];
foreach ($result as $record) {
$return[$record->name] = ($record->serialized ? unserialize($record->value) : $record->value);
}
@@ -58,7 +58,7 @@ class UserData implements UserDataInterface {
}
// If $module and $name was passed, return the uid/value pairs.
elseif (isset($name)) {
- $return = array();
+ $return = [];
foreach ($result as $record) {
$return[$record->uid] = ($record->serialized ? unserialize($record->value) : $record->value);
}
@@ -66,7 +66,7 @@ class UserData implements UserDataInterface {
}
// If only $module was passed, return data keyed by uid and name.
else {
- $return = array();
+ $return = [];
foreach ($result as $record) {
$return[$record->uid][$record->name] = ($record->serialized ? unserialize($record->value) : $record->value);
}
@@ -84,15 +84,15 @@ class UserData implements UserDataInterface {
$serialized = 1;
}
$this->connection->merge('users_data')
- ->keys(array(
+ ->keys([
'uid' => $uid,
'module' => $module,
'name' => $name,
- ))
- ->fields(array(
+ ])
+ ->fields([
'value' => $value,
'serialized' => $serialized,
- ))
+ ])
->execute();
}
diff --git a/core/modules/user/src/UserListBuilder.php b/core/modules/user/src/UserListBuilder.php
index 9dae5f4a23e..306d04609e7 100644
--- a/core/modules/user/src/UserListBuilder.php
+++ b/core/modules/user/src/UserListBuilder.php
@@ -79,36 +79,36 @@ class UserListBuilder extends EntityListBuilder {
* {@inheritdoc}
*/
public function buildHeader() {
- $header = array(
- 'username' => array(
+ $header = [
+ 'username' => [
'data' => $this->t('Username'),
'field' => 'name',
'specifier' => 'name',
- ),
- 'status' => array(
+ ],
+ 'status' => [
'data' => $this->t('Status'),
'field' => 'status',
'specifier' => 'status',
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
- 'roles' => array(
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
+ 'roles' => [
'data' => $this->t('Roles'),
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
- 'member_for' => array(
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
+ 'member_for' => [
'data' => $this->t('Member for'),
'field' => 'created',
'specifier' => 'created',
'sort' => 'desc',
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
- 'access' => array(
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
+ 'access' => [
'data' => $this->t('Last access'),
'field' => 'access',
'specifier' => 'access',
- 'class' => array(RESPONSIVE_PRIORITY_LOW),
- ),
- );
+ 'class' => [RESPONSIVE_PRIORITY_LOW],
+ ],
+ ];
return $header + parent::buildHeader();
}
@@ -116,25 +116,25 @@ class UserListBuilder extends EntityListBuilder {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
- $row['username']['data'] = array(
+ $row['username']['data'] = [
'#theme' => 'username',
'#account' => $entity,
- );
+ ];
$row['status'] = $entity->isActive() ? $this->t('active') : $this->t('blocked');
$roles = user_role_names(TRUE);
unset($roles[RoleInterface::AUTHENTICATED_ID]);
- $users_roles = array();
+ $users_roles = [];
foreach ($entity->getRoles() as $role) {
if (isset($roles[$role])) {
$users_roles[] = $roles[$role];
}
}
asort($users_roles);
- $row['roles']['data'] = array(
+ $row['roles']['data'] = [
'#theme' => 'item_list',
'#items' => $users_roles,
- );
+ ];
$options = [
'return_as_object' => TRUE,
];
diff --git a/core/modules/user/src/UserStorage.php b/core/modules/user/src/UserStorage.php
index 1c5a54a8aff..809f3e384b7 100644
--- a/core/modules/user/src/UserStorage.php
+++ b/core/modules/user/src/UserStorage.php
@@ -40,11 +40,11 @@ class UserStorage extends SqlContentEntityStorage implements UserStorageInterfac
*/
public function updateLastLoginTimestamp(UserInterface $account) {
$this->database->update('users_field_data')
- ->fields(array('login' => $account->getLastLoginTime()))
+ ->fields(['login' => $account->getLastLoginTime()])
->condition('uid', $account->id())
->execute();
// Ensure that the entity cache is cleared.
- $this->resetCache(array($account->id()));
+ $this->resetCache([$account->id()]);
}
/**
@@ -52,13 +52,13 @@ class UserStorage extends SqlContentEntityStorage implements UserStorageInterfac
*/
public function updateLastAccessTimestamp(AccountInterface $account, $timestamp) {
$this->database->update('users_field_data')
- ->fields(array(
+ ->fields([
'access' => $timestamp,
- ))
+ ])
->condition('uid', $account->id())
->execute();
// Ensure that the entity cache is cleared.
- $this->resetCache(array($account->id()));
+ $this->resetCache([$account->id()]);
}
/**
diff --git a/core/modules/user/src/UserStorageSchema.php b/core/modules/user/src/UserStorageSchema.php
index c8c3e46e837..5e590b8958c 100644
--- a/core/modules/user/src/UserStorageSchema.php
+++ b/core/modules/user/src/UserStorageSchema.php
@@ -17,9 +17,9 @@ class UserStorageSchema extends SqlContentEntityStorageSchema {
protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
$schema = parent::getEntitySchema($entity_type, $reset);
- $schema['users_field_data']['unique keys'] += array(
- 'user__name' => array('name', 'langcode'),
- );
+ $schema['users_field_data']['unique keys'] += [
+ 'user__name' => ['name', 'langcode'],
+ ];
return $schema;
}
diff --git a/core/modules/user/src/UserViewsData.php b/core/modules/user/src/UserViewsData.php
index e2229112eb6..2c791147905 100644
--- a/core/modules/user/src/UserViewsData.php
+++ b/core/modules/user/src/UserViewsData.php
@@ -21,15 +21,15 @@ class UserViewsData extends EntityViewsData {
$data['users_field_data']['table']['wizard_id'] = 'user';
$data['users_field_data']['uid']['argument']['id'] = 'user_uid';
- $data['users_field_data']['uid']['argument'] += array(
+ $data['users_field_data']['uid']['argument'] += [
'name table' => 'users_field_data',
'name field' => 'name',
'empty field name' => \Drupal::config('user.settings')->get('anonymous'),
- );
+ ];
$data['users_field_data']['uid']['filter']['id'] = 'user_name';
$data['users_field_data']['uid']['filter']['title'] = $this->t('Name (autocomplete)');
$data['users_field_data']['uid']['filter']['help'] = $this->t('The user or author name. Uses an autocomplete widget to find a user name, the actual filter uses the resulting user ID.');
- $data['users_field_data']['uid']['relationship'] = array(
+ $data['users_field_data']['uid']['relationship'] = [
'title' => $this->t('Content authored'),
'help' => $this->t('Relate content to the user who created it. This relationship will create one record for each content item created by the user.'),
'id' => 'standard',
@@ -37,19 +37,19 @@ class UserViewsData extends EntityViewsData {
'base field' => 'uid',
'field' => 'uid',
'label' => $this->t('nodes'),
- );
+ ];
- $data['users_field_data']['uid_raw'] = array(
+ $data['users_field_data']['uid_raw'] = [
'help' => $this->t('The raw numeric user ID.'),
'real field' => 'uid',
- 'filter' => array(
+ 'filter' => [
'title' => $this->t('The user ID'),
'id' => 'numeric',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['uid_representative'] = array(
- 'relationship' => array(
+ $data['users_field_data']['uid_representative'] = [
+ 'relationship' => [
'title' => $this->t('Representative node'),
'label' => $this->t('Representative node'),
'help' => $this->t('Obtains a single representative node for each user, according to a chosen sort criterion.'),
@@ -61,18 +61,18 @@ class UserViewsData extends EntityViewsData {
'base' => 'node_field_data',
'field' => 'nid',
'relationship' => 'node_field_data:uid'
- ),
- );
+ ],
+ ];
- $data['users']['uid_current'] = array(
+ $data['users']['uid_current'] = [
'real field' => 'uid',
'title' => $this->t('Current'),
'help' => $this->t('Filter the view to the currently logged in user.'),
- 'filter' => array(
+ 'filter' => [
'id' => 'user_current',
'type' => 'yes-no',
- ),
- );
+ ],
+ ];
$data['users_field_data']['name']['help'] = $this->t('The user or author name.');
$data['users_field_data']['name']['field']['default_formatter'] = 'user_name';
@@ -90,178 +90,178 @@ class UserViewsData extends EntityViewsData {
$data['users_field_data']['preferred_admin_langcode']['title'] = $this->t('Preferred admin language');
$data['users_field_data']['preferred_admin_langcode']['help'] = $this->t('Preferred administrative language of the user');
- $data['users_field_data']['created_fulldate'] = array(
+ $data['users_field_data']['created_fulldate'] = [
'title' => $this->t('Created date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['created_year_month'] = array(
+ $data['users_field_data']['created_year_month'] = [
'title' => $this->t('Created year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['created_year'] = array(
+ $data['users_field_data']['created_year'] = [
'title' => $this->t('Created year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['created_month'] = array(
+ $data['users_field_data']['created_month'] = [
'title' => $this->t('Created month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['created_day'] = array(
+ $data['users_field_data']['created_day'] = [
'title' => $this->t('Created day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['created_week'] = array(
+ $data['users_field_data']['created_week'] = [
'title' => $this->t('Created week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'created',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
$data['users_field_data']['status']['filter']['label'] = $this->t('Active');
$data['users_field_data']['status']['filter']['type'] = 'yes-no';
$data['users_field_data']['changed']['title'] = $this->t('Updated date');
- $data['users_field_data']['changed_fulldate'] = array(
+ $data['users_field_data']['changed_fulldate'] = [
'title' => $this->t('Updated date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['changed_year_month'] = array(
+ $data['users_field_data']['changed_year_month'] = [
'title' => $this->t('Updated year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['changed_year'] = array(
+ $data['users_field_data']['changed_year'] = [
'title' => $this->t('Updated year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['changed_month'] = array(
+ $data['users_field_data']['changed_month'] = [
'title' => $this->t('Updated month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['changed_day'] = array(
+ $data['users_field_data']['changed_day'] = [
'title' => $this->t('Updated day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['users_field_data']['changed_week'] = array(
+ $data['users_field_data']['changed_week'] = [
'title' => $this->t('Updated week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
- $data['users']['data'] = array(
+ $data['users']['data'] = [
'title' => $this->t('Data'),
'help' => $this->t('Provides access to the user data service.'),
'real field' => 'uid',
- 'field' => array(
+ 'field' => [
'id' => 'user_data',
- ),
- );
+ ],
+ ];
- $data['users']['user_bulk_form'] = array(
+ $data['users']['user_bulk_form'] = [
'title' => $this->t('Bulk update'),
'help' => $this->t('Add a form element that lets you run operations on multiple users.'),
- 'field' => array(
+ 'field' => [
'id' => 'user_bulk_form',
- ),
- );
+ ],
+ ];
$data['user__roles']['table']['group'] = $this->t('User');
- $data['user__roles']['table']['join'] = array(
- 'users_field_data' => array(
+ $data['user__roles']['table']['join'] = [
+ 'users_field_data' => [
'left_field' => 'uid',
'field' => 'entity_id',
- ),
- );
+ ],
+ ];
- $data['user__roles']['roles_target_id'] = array(
+ $data['user__roles']['roles_target_id'] = [
'title' => $this->t('Roles'),
'help' => $this->t('Roles that a user belongs to.'),
- 'field' => array(
+ 'field' => [
'id' => 'user_roles',
'no group by' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'user_roles',
'allow empty' => TRUE,
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'user__roles_rid',
'name table' => 'role',
'name field' => 'name',
'empty field name' => $this->t('No role'),
'zero is null' => TRUE,
'numeric' => TRUE,
- ),
- );
+ ],
+ ];
- $data['user__roles']['permission'] = array(
+ $data['user__roles']['permission'] = [
'title' => $this->t('Permission'),
'help' => $this->t('The user permissions.'),
- 'field' => array(
+ 'field' => [
'id' => 'user_permissions',
'no group by' => TRUE,
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'user_permissions',
'real field' => 'roles_target_id',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/core/modules/user/tests/fixtures/update/drupal-8.user-email-token-2587275.php b/core/modules/user/tests/fixtures/update/drupal-8.user-email-token-2587275.php
index 75ec703f8c7..eaa2a9a618c 100644
--- a/core/modules/user/tests/fixtures/update/drupal-8.user-email-token-2587275.php
+++ b/core/modules/user/tests/fixtures/update/drupal-8.user-email-token-2587275.php
@@ -14,9 +14,9 @@ $connection = Database::getConnection();
// already.
$connection->delete('config')->condition('name', 'user.mail')->execute();
$connection->insert('config')
- ->fields(array('collection', 'name', 'data'))
- ->values(array(
+ ->fields(['collection', 'name', 'data'])
+ ->values([
'collection' => '',
'name' => 'user.mail',
'data' => "a:10:{s:14:\"cancel_confirm\";a:2:{s:4:\"body\";s:369:\"[user:name],\n\nA request to cancel your account has been made at [site:name].\n\nYou may now cancel your account on [site:url-brief] by clicking this link or copying and pasting it into your browser:\n\n[user:cancel-url]\n\nNOTE: The cancellation of your account is not reversible.\n\nThis link expires in one day and nothing will happen if it is not used.\n\n-- [site:name] team\";s:7:\"subject\";s:59:\"Account cancellation request for [user:name] at [site:name]\";}s:14:\"password_reset\";a:2:{s:4:\"body\";s:397:\"[user:name],\n\nA request to reset the password for your account has been made at [site:name].\n\nYou may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used.\n\n-- [site:name] team\";s:7:\"subject\";s:60:\"Replacement login information for [user:name] at [site:name]\";}s:22:\"register_admin_created\";a:2:{s:4:\"body\";s:463:\"[user:name],\n\nA site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n-- [site:name] team\";s:7:\"subject\";s:58:\"An administrator created an account for you at [site:name]\";}s:29:\"register_no_approval_required\";a:2:{s:4:\"body\";s:437:\"[user:name],\n\nThank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n-- [site:name] team\";s:7:\"subject\";s:46:\"Account details for [user:name] at [site:name]\";}s:25:\"register_pending_approval\";a:2:{s:4:\"body\";s:281:\"[user:name],\n\nThank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- [site:name] team\";s:7:\"subject\";s:71:\"Account details for [user:name] at [site:name] (pending admin approval)\";}s:31:\"register_pending_approval_admin\";a:2:{s:4:\"body\";s:56:\"[user:name] has applied for an account.\n\n[user:edit-url]\";s:7:\"subject\";s:71:\"Account details for [user:name] at [site:name] (pending admin approval)\";}s:16:\"status_activated\";a:2:{s:4:\"body\";s:446:\"[user:name],\n\nYour account at [site:name] has been activated.\n\nYou may now log in by clicking this link or copying and pasting it into your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n-- [site:name] team\";s:7:\"subject\";s:57:\"Account details for [user:name] at [site:name] (approved)\";}s:14:\"status_blocked\";a:2:{s:4:\"body\";s:89:\"[user:name],\n\nYour account on [site:account-name] has been blocked.\n\n-- [site:name] team\";s:7:\"subject\";s:56:\"Account details for [user:name] at [site:name] (blocked)\";}s:15:\"status_canceled\";a:2:{s:4:\"body\";s:82:\"[user:name],\n\nYour account on [site:name] has been canceled.\n\n-- [site:name] team\";s:7:\"subject\";s:57:\"Account details for [user:name] at [site:name] (canceled)\";}s:8:\"langcode\";s:2:\"en\";}"
-))->execute();
+])->execute();
diff --git a/core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module b/core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module
index a036c65c6b0..9baf8ab4d46 100644
--- a/core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module
+++ b/core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module
@@ -13,7 +13,7 @@ use Drupal\Component\Utility\SafeMarkup;
function user_hooks_test_user_format_name_alter(&$name, $account) {
if (\Drupal::state()->get('user_hooks_test_user_format_name_alter', FALSE)) {
if (\Drupal::state()->get('user_hooks_test_user_format_name_alter_safe', FALSE)) {
- $name = SafeMarkup::format('<em>@uid</em>', array('@uid' => $account->id()));
+ $name = SafeMarkup::format('<em>@uid</em>', ['@uid' => $account->id()]);
}
else {
$name = '<em>' . $account->id() . '</em>';
diff --git a/core/modules/user/tests/src/Functional/UserCacheTagsTest.php b/core/modules/user/tests/src/Functional/UserCacheTagsTest.php
index d4455ffa032..a9e98575b7b 100644
--- a/core/modules/user/tests/src/Functional/UserCacheTagsTest.php
+++ b/core/modules/user/tests/src/Functional/UserCacheTagsTest.php
@@ -17,7 +17,7 @@ class UserCacheTagsTest extends EntityWithUriCacheTagsTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('user');
+ public static $modules = ['user'];
/**
* {@inheritdoc}
diff --git a/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php b/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php
index d844b0abdbd..38f2514a496 100644
--- a/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php
+++ b/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php
@@ -16,30 +16,30 @@ class UserCreateFailMailTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('system_mail_failure_test');
+ public static $modules = ['system_mail_failure_test'];
/**
* Tests the create user administration page.
*/
public function testUserAdd() {
- $user = $this->drupalCreateUser(array('administer users'));
+ $user = $this->drupalCreateUser(['administer users']);
$this->drupalLogin($user);
// Replace the mail functionality with a fake, malfunctioning service.
$this->config('system.mail')->set('interface.default', 'test_php_mail_failure')->save();
// Create a user, but fail to send an email.
$name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'name' => $name,
'mail' => $this->randomMachineName() . '@example.com',
'pass[pass1]' => $pass = $this->randomString(),
'pass[pass2]' => $pass,
'notify' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/people/create', $edit, t('Create new account'));
$this->assertText(t('Unable to send email. Contact the site administrator if the problem persists.'));
- $this->assertNoText(t('A welcome message with further instructions has been emailed to the new user @name.', array('@name' => $edit['name'])));
+ $this->assertNoText(t('A welcome message with further instructions has been emailed to the new user @name.', ['@name' => $edit['name']]));
}
}
diff --git a/core/modules/user/tests/src/Functional/UserDeleteTest.php b/core/modules/user/tests/src/Functional/UserDeleteTest.php
index c82a2f3fde8..abfb6162080 100644
--- a/core/modules/user/tests/src/Functional/UserDeleteTest.php
+++ b/core/modules/user/tests/src/Functional/UserDeleteTest.php
@@ -17,16 +17,16 @@ class UserDeleteTest extends BrowserTestBase {
*/
function testUserDeleteMultiple() {
// Create a few users with permissions, so roles will be created.
- $user_a = $this->drupalCreateUser(array('access user profiles'));
- $user_b = $this->drupalCreateUser(array('access user profiles'));
- $user_c = $this->drupalCreateUser(array('access user profiles'));
+ $user_a = $this->drupalCreateUser(['access user profiles']);
+ $user_b = $this->drupalCreateUser(['access user profiles']);
+ $user_c = $this->drupalCreateUser(['access user profiles']);
- $uids = array($user_a->id(), $user_b->id(), $user_c->id());
+ $uids = [$user_a->id(), $user_b->id(), $user_c->id()];
// These users should have a role
$query = db_select('user__roles', 'r');
$roles_created = $query
- ->fields('r', array('entity_id'))
+ ->fields('r', ['entity_id'])
->condition('entity_id', $uids, 'IN')
->countQuery()
->execute()
@@ -40,16 +40,16 @@ class UserDeleteTest extends BrowserTestBase {
// Test if the roles assignments are deleted.
$query = db_select('user__roles', 'r');
$roles_after_deletion = $query
- ->fields('r', array('entity_id'))
+ ->fields('r', ['entity_id'])
->condition('entity_id', $uids, 'IN')
->countQuery()
->execute()
->fetchField();
$this->assertTrue($roles_after_deletion == 0, 'Role assignments deleted along with users');
// Test if the users are deleted, User::load() will return NULL.
- $this->assertNull(User::load($user_a->id()), format_string('User with id @uid deleted.', array('@uid' => $user_a->id())));
- $this->assertNull(User::load($user_b->id()), format_string('User with id @uid deleted.', array('@uid' => $user_b->id())));
- $this->assertNull(User::load($user_c->id()), format_string('User with id @uid deleted.', array('@uid' => $user_c->id())));
+ $this->assertNull(User::load($user_a->id()), format_string('User with id @uid deleted.', ['@uid' => $user_a->id()]));
+ $this->assertNull(User::load($user_b->id()), format_string('User with id @uid deleted.', ['@uid' => $user_b->id()]));
+ $this->assertNull(User::load($user_c->id()), format_string('User with id @uid deleted.', ['@uid' => $user_c->id()]));
}
}
diff --git a/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php b/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php
index 7783eb90464..29e9a17b2a5 100644
--- a/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php
+++ b/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php
@@ -16,7 +16,7 @@ class UserEditedOwnAccountTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('user_form_test');
+ public static $modules = ['user_form_test'];
function testUserEditedOwnAccount() {
// Change account setting 'Who can register accounts?' to Administrators
@@ -24,11 +24,11 @@ class UserEditedOwnAccountTest extends BrowserTestBase {
$this->config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
// Create a new user account and log in.
- $account = $this->drupalCreateUser(array('change own username'));
+ $account = $this->drupalCreateUser(['change own username']);
$this->drupalLogin($account);
// Change own username.
- $edit = array();
+ $edit = [];
$edit['name'] = $this->randomMachineName();
$this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save'));
diff --git a/core/modules/user/tests/src/Functional/UserEntityCallbacksTest.php b/core/modules/user/tests/src/Functional/UserEntityCallbacksTest.php
index ceb8edaa64f..5b5a34e4a3f 100644
--- a/core/modules/user/tests/src/Functional/UserEntityCallbacksTest.php
+++ b/core/modules/user/tests/src/Functional/UserEntityCallbacksTest.php
@@ -18,7 +18,7 @@ class UserEntityCallbacksTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('user', 'user_hooks_test');
+ public static $modules = ['user', 'user_hooks_test'];
/**
* An authenticated user to use for testing.
diff --git a/core/modules/user/tests/src/Functional/UserLanguageTest.php b/core/modules/user/tests/src/Functional/UserLanguageTest.php
index e4aeb58ef2b..fcdceb8a3be 100644
--- a/core/modules/user/tests/src/Functional/UserLanguageTest.php
+++ b/core/modules/user/tests/src/Functional/UserLanguageTest.php
@@ -17,14 +17,14 @@ class UserLanguageTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('user', 'language');
+ public static $modules = ['user', 'language'];
/**
* Test if user can change their default language.
*/
function testUserLanguageConfiguration() {
// User to add and remove language.
- $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']);
// User to change their default language.
$web_user = $this->drupalCreateUser();
@@ -34,12 +34,12 @@ class UserLanguageTest extends BrowserTestBase {
$langcode = 'xx';
// The English name for the language.
$name = $this->randomMachineName(16);
- $edit = array(
+ $edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->drupalLogout();
@@ -52,9 +52,9 @@ class UserLanguageTest extends BrowserTestBase {
// Ensure custom language is present.
$this->assertText($name, 'Language present on form.');
// Switch to our custom language.
- $edit = array(
+ $edit = [
'preferred_langcode' => $langcode,
- );
+ ];
$this->drupalPostForm($path, $edit, t('Save'));
// Ensure form was submitted successfully.
$this->assertText(t('The changes have been saved.'), 'Changes were saved.');
diff --git a/core/modules/user/tests/src/Functional/UserMailNotifyTest.php b/core/modules/user/tests/src/Functional/UserMailNotifyTest.php
index 7f5257a5655..57bebc042a4 100644
--- a/core/modules/user/tests/src/Functional/UserMailNotifyTest.php
+++ b/core/modules/user/tests/src/Functional/UserMailNotifyTest.php
@@ -49,7 +49,7 @@ class UserMailNotifyTest extends EntityKernelTestBase {
$return = _user_mail_notify($op, $this->createUser());
$this->assertTrue($return, '_user_mail_notify() returns TRUE.');
foreach ($mail_keys as $key) {
- $filter = array('key' => $key);
+ $filter = ['key' => $key];
$this->assertNotEmpty($this->getMails($filter), "Mails with $key exists.");
}
$this->assertCount(count($mail_keys), $this->getMails(), 'The expected number of emails sent.');
diff --git a/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php b/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php
index 1701b0f64de..309dee2da1d 100644
--- a/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php
+++ b/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php
@@ -13,7 +13,7 @@ class UserRolesAssignmentTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
- $admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users'));
+ $admin_user = $this->drupalCreateUser(['administer permissions', 'administer users']);
$this->drupalLogin($admin_user);
}
@@ -22,17 +22,17 @@ class UserRolesAssignmentTest extends BrowserTestBase {
* again.
*/
function testAssignAndRemoveRole() {
- $rid = $this->drupalCreateRole(array('administer users'));
+ $rid = $this->drupalCreateRole(['administer users']);
$account = $this->drupalCreateUser();
// Assign the role to the user.
- $this->drupalPostForm('user/' . $account->id() . '/edit', array("roles[$rid]" => $rid), t('Save'));
+ $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => $rid], t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertFieldChecked('edit-roles-' . $rid, 'Role is assigned.');
$this->userLoadAndCheckRoleAssigned($account, $rid);
// Remove the role from the user.
- $this->drupalPostForm('user/' . $account->id() . '/edit', array("roles[$rid]" => FALSE), t('Save'));
+ $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => FALSE], t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.');
$this->userLoadAndCheckRoleAssigned($account, $rid, FALSE);
@@ -43,17 +43,17 @@ class UserRolesAssignmentTest extends BrowserTestBase {
* be removed again.
*/
function testCreateUserWithRole() {
- $rid = $this->drupalCreateRole(array('administer users'));
+ $rid = $this->drupalCreateRole(['administer users']);
// Create a new user and add the role at the same time.
- $edit = array(
+ $edit = [
'name' => $this->randomMachineName(),
'mail' => $this->randomMachineName() . '@example.com',
'pass[pass1]' => $pass = $this->randomString(),
'pass[pass2]' => $pass,
"roles[$rid]" => $rid,
- );
+ ];
$this->drupalPostForm('admin/people/create', $edit, t('Create new account'));
- $this->assertText(t('Created a new user account for @name.', array('@name' => $edit['name'])));
+ $this->assertText(t('Created a new user account for @name.', ['@name' => $edit['name']]));
// Get the newly added user.
$account = user_load_by_name($edit['name']);
@@ -62,7 +62,7 @@ class UserRolesAssignmentTest extends BrowserTestBase {
$this->userLoadAndCheckRoleAssigned($account, $rid);
// Remove the role again.
- $this->drupalPostForm('user/' . $account->id() . '/edit', array("roles[$rid]" => FALSE), t('Save'));
+ $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => FALSE], t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.');
$this->userLoadAndCheckRoleAssigned($account, $rid, FALSE);
@@ -81,7 +81,7 @@ class UserRolesAssignmentTest extends BrowserTestBase {
*/
private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) {
$user_storage = $this->container->get('entity.manager')->getStorage('user');
- $user_storage->resetCache(array($account->id()));
+ $user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
if ($is_assigned) {
$this->assertFalse(array_search($rid, $account->getRoles()) === FALSE, 'The role is present in the user object.');
diff --git a/core/modules/user/tests/src/Functional/UserSearchTest.php b/core/modules/user/tests/src/Functional/UserSearchTest.php
index af2fb28ba78..7eafb4af8e9 100644
--- a/core/modules/user/tests/src/Functional/UserSearchTest.php
+++ b/core/modules/user/tests/src/Functional/UserSearchTest.php
@@ -17,70 +17,70 @@ class UserSearchTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('search');
+ public static $modules = ['search'];
function testUserSearch() {
// Verify that a user without 'administer users' permission cannot search
// for users by email address. Additionally, ensure that the username has a
// plus sign to ensure searching works with that.
- $user1 = $this->drupalCreateUser(array('access user profiles', 'search content'), "foo+bar");
+ $user1 = $this->drupalCreateUser(['access user profiles', 'search content'], "foo+bar");
$this->drupalLogin($user1);
$keys = $user1->getEmail();
- $edit = array('keys' => $keys);
+ $edit = ['keys' => $keys];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText(t('Your search yielded no results.'), 'Search by email did not work for non-admin user');
$this->assertText('no results', 'Search by email gave no-match message');
// Verify that a non-matching query gives an appropriate message.
$keys = 'nomatch';
- $edit = array('keys' => $keys);
+ $edit = ['keys' => $keys];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText('no results', 'Non-matching search gave appropriate message');
// Verify that a user with search permission can search for users by name.
$keys = $user1->getUsername();
- $edit = array('keys' => $keys);
+ $edit = ['keys' => $keys];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertLink($keys, 0, 'Search by username worked for non-admin user');
// Verify that searching by sub-string works too.
$subkey = substr($keys, 1, 5);
- $edit = array('keys' => $subkey);
+ $edit = ['keys' => $subkey];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertLink($keys, 0, 'Search by username substring worked for non-admin user');
// Verify that wildcard search works.
$subkey = substr($keys, 0, 2) . '*' . substr($keys, 4, 2);
- $edit = array('keys' => $subkey);
+ $edit = ['keys' => $subkey];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertLink($keys, 0, 'Search with wildcard worked for non-admin user');
// Verify that a user with 'administer users' permission can search by
// email.
- $user2 = $this->drupalCreateUser(array('administer users', 'access user profiles', 'search content'));
+ $user2 = $this->drupalCreateUser(['administer users', 'access user profiles', 'search content']);
$this->drupalLogin($user2);
$keys = $user2->getEmail();
- $edit = array('keys' => $keys);
+ $edit = ['keys' => $keys];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText($keys, 'Search by email works for administrative user');
$this->assertText($user2->getUsername(), 'Search by email resulted in username on page for administrative user');
// Verify that a substring works too for email.
$subkey = substr($keys, 1, 5);
- $edit = array('keys' => $subkey);
+ $edit = ['keys' => $subkey];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText($keys, 'Search by email substring works for administrative user');
$this->assertText($user2->getUsername(), 'Search by email substring resulted in username on page for administrative user');
// Verify that wildcard search works for email
$subkey = substr($keys, 0, 2) . '*' . substr($keys, 4, 2);
- $edit = array('keys' => $subkey);
+ $edit = ['keys' => $subkey];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText($user2->getUsername(), 'Search for email wildcard resulted in username on page for administrative user');
// Verify that if they search by user name, they see email address too.
$keys = $user1->getUsername();
- $edit = array('keys' => $keys);
+ $edit = ['keys' => $keys];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText($keys, 'Search by username works for admin user');
$this->assertText($user1->getEmail(), 'Search by username for admin shows email address too');
@@ -92,25 +92,25 @@ class UserSearchTest extends BrowserTestBase {
// Verify that users with "administer users" permissions can see blocked
// accounts in search results.
- $edit = array('keys' => $blocked_user->getUsername());
+ $edit = ['keys' => $blocked_user->getUsername()];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText($blocked_user->getUsername(), 'Blocked users are listed on the user search results for users with the "administer users" permission.');
// Verify that users without "administer users" permissions do not see
// blocked accounts in search results.
$this->drupalLogin($user1);
- $edit = array('keys' => $blocked_user->getUsername());
+ $edit = ['keys' => $blocked_user->getUsername()];
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText(t('Your search yielded no results.'), 'Blocked users are hidden from the user search results.');
// Create a user without search permission, and one without user page view
// permission. Verify that neither one can access the user search page.
- $user3 = $this->drupalCreateUser(array('search content'));
+ $user3 = $this->drupalCreateUser(['search content']);
$this->drupalLogin($user3);
$this->drupalGet('search/user');
$this->assertResponse('403', 'User without user profile access cannot search');
- $user4 = $this->drupalCreateUser(array('access user profiles'));
+ $user4 = $this->drupalCreateUser(['access user profiles']);
$this->drupalLogin($user4);
$this->drupalGet('search/user');
$this->assertResponse('403', 'User without search permission cannot search');
diff --git a/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php b/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php
index 869339a1611..d563d363411 100644
--- a/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php
+++ b/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php
@@ -21,7 +21,7 @@ class UserTokenReplaceTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('language', 'user_hooks_test');
+ public static $modules = ['language', 'user_hooks_test'];
/**
* {@inheritdoc}
@@ -37,17 +37,17 @@ class UserTokenReplaceTest extends BrowserTestBase {
function testUserTokenReplacement() {
$token_service = \Drupal::token();
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
- $url_options = array(
+ $url_options = [
'absolute' => TRUE,
'language' => $language_interface,
- );
+ ];
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
\Drupal::state()->set('user_hooks_test_user_format_name_alter_safe', TRUE);
// Create two users and log them in one after another.
- $user1 = $this->drupalCreateUser(array());
- $user2 = $this->drupalCreateUser(array());
+ $user1 = $this->drupalCreateUser([]);
+ $user2 = $this->drupalCreateUser([]);
$this->drupalLogin($user1);
$this->drupalLogout();
$this->drupalLogin($user2);
@@ -56,7 +56,7 @@ class UserTokenReplaceTest extends BrowserTestBase {
$global_account = User::load(\Drupal::currentUser()->id());
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$tests['[user:uid]'] = $account->id();
$tests['[user:name]'] = $account->getAccountName();
$tests['[user:account-name]'] = $account->getAccountName();
@@ -121,18 +121,18 @@ class UserTokenReplaceTest extends BrowserTestBase {
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $token_service->replace($input, array('user' => $anonymous_user), array('langcode' => $language_interface->getId()), $bubbleable_metadata);
- $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input)));
+ $output = $token_service->replace($input, ['user' => $anonymous_user], ['langcode' => $language_interface->getId()], $bubbleable_metadata);
+ $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
// Generate login and cancel link.
- $tests = array();
+ $tests = [];
$tests['[user:one-time-login-url]'] = user_pass_reset_url($account);
$tests['[user:cancel-url]'] = user_cancel_url($account);
// Generate tokens with interface language.
- $link = \Drupal::url('user.page', [], array('absolute' => TRUE));
+ $link = \Drupal::url('user.page', [], ['absolute' => TRUE]);
foreach ($tests as $input => $expected) {
$output = $token_service->replace($input, ['user' => $account], ['langcode' => $language_interface->getId(), 'callback' => 'user_mail_tokens', 'clear' => TRUE]);
$this->assertTrue(strpos($output, $link) === 0, 'Generated URL is in interface language.');
@@ -141,16 +141,16 @@ class UserTokenReplaceTest extends BrowserTestBase {
// Generate tokens with the user's preferred language.
$account->preferred_langcode = 'de';
$account->save();
- $link = \Drupal::url('user.page', [], array('language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), 'absolute' => TRUE));
+ $link = \Drupal::url('user.page', [], ['language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), 'absolute' => TRUE]);
foreach ($tests as $input => $expected) {
$output = $token_service->replace($input, ['user' => $account], ['callback' => 'user_mail_tokens', 'clear' => TRUE]);
$this->assertTrue(strpos($output, $link) === 0, "Generated URL is in the user's preferred language.");
}
// Generate tokens with one specific language.
- $link = \Drupal::url('user.page', [], array('language' => \Drupal::languageManager()->getLanguage('de'), 'absolute' => TRUE));
+ $link = \Drupal::url('user.page', [], ['language' => \Drupal::languageManager()->getLanguage('de'), 'absolute' => TRUE]);
foreach ($tests as $input => $expected) {
- foreach (array($user1, $user2) as $account) {
+ foreach ([$user1, $user2] as $account) {
$output = $token_service->replace($input, ['user' => $account], ['langcode' => 'de', 'callback' => 'user_mail_tokens', 'clear' => TRUE]);
$this->assertTrue(strpos($output, $link) === 0, "Generated URL in the requested language.");
}
diff --git a/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php b/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php
index 6e553646e33..075b04c5e0e 100644
--- a/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php
+++ b/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php
@@ -48,7 +48,7 @@ class UserRoleConditionTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field');
+ public static $modules = ['system', 'user', 'field'];
/**
* {@inheritdoc}
@@ -62,38 +62,38 @@ class UserRoleConditionTest extends KernelTestBase {
$this->manager = $this->container->get('plugin.manager.condition');
// Set up the authenticated and anonymous roles.
- Role::create(array(
+ Role::create([
'id' => RoleInterface::ANONYMOUS_ID,
'label' => 'Anonymous user',
- ))->save();
- Role::create(array(
+ ])->save();
+ Role::create([
'id' => RoleInterface::AUTHENTICATED_ID,
'label' => 'Authenticated user',
- ))->save();
+ ])->save();
// Create new role.
$rid = strtolower($this->randomMachineName(8));
$label = $this->randomString(8);
- $role = Role::create(array(
+ $role = Role::create([
'id' => $rid,
'label' => $label,
- ));
+ ]);
$role->save();
$this->role = $role;
// Setup an anonymous user for our tests.
- $this->anonymous = User::create(array(
+ $this->anonymous = User::create([
'name' => '',
'uid' => 0,
- ));
+ ]);
$this->anonymous->save();
// Loading the anonymous user adds the correct role.
$this->anonymous = User::load($this->anonymous->id());
// Setup an authenticated user for our tests.
- $this->authenticated = User::create(array(
+ $this->authenticated = User::create([
'name' => $this->randomMachineName(),
- ));
+ ]);
$this->authenticated->save();
// Add the custom role.
$this->authenticated->addRole($this->role->id());
@@ -107,7 +107,7 @@ class UserRoleConditionTest extends KernelTestBase {
// authenticated user roles.
/** @var $condition \Drupal\Core\Condition\ConditionInterface */
$condition = $this->manager->createInstance('user_role')
- ->setConfig('roles', array(RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID))
+ ->setConfig('roles', [RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID])
->setContextValue('user', $this->anonymous);
$this->assertFalse($condition->execute(), 'Anonymous users fail role checks for authenticated.');
// Check for the proper summary.
@@ -115,13 +115,13 @@ class UserRoleConditionTest extends KernelTestBase {
$this->assertEqual($condition->summary(), 'The user is a member of Authenticated user');
// Set the user role to anonymous.
- $condition->setConfig('roles', array(RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID));
+ $condition->setConfig('roles', [RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID]);
$this->assertTrue($condition->execute(), 'Anonymous users pass role checks for anonymous.');
// Check for the proper summary.
$this->assertEqual($condition->summary(), 'The user is a member of Anonymous user');
// Set the user role to check anonymous or authenticated.
- $condition->setConfig('roles', array(RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID));
+ $condition->setConfig('roles', [RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID]);
$this->assertTrue($condition->execute(), 'Anonymous users pass role checks for anonymous or authenticated.');
// Check for the proper summary.
$this->assertEqual($condition->summary(), 'The user is a member of Anonymous user, Authenticated user');
@@ -132,11 +132,11 @@ class UserRoleConditionTest extends KernelTestBase {
$this->assertTrue($condition->execute(), 'Authenticated users pass role checks for anonymous or authenticated.');
// Set the role to just authenticated and recheck.
- $condition->setConfig('roles', array(RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID));
+ $condition->setConfig('roles', [RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID]);
$this->assertTrue($condition->execute(), 'Authenticated users pass role checks for authenticated.');
// Test Constructor injection.
- $condition = $this->manager->createInstance('user_role', array('roles' => array(RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID), 'context' => array('user' => $this->authenticated)));
+ $condition = $this->manager->createInstance('user_role', ['roles' => [RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID], 'context' => ['user' => $this->authenticated]]);
$this->assertTrue($condition->execute(), 'Constructor injection of context and configuration working as anticipated.');
// Check the negated summary.
@@ -144,14 +144,14 @@ class UserRoleConditionTest extends KernelTestBase {
$this->assertEqual($condition->summary(), 'The user is not a member of Authenticated user');
// Check the complex negated summary.
- $condition->setConfig('roles', array(RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID));
+ $condition->setConfig('roles', [RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID]);
$this->assertEqual($condition->summary(), 'The user is not a member of Anonymous user, Authenticated user');
// Check a custom role.
- $condition->setConfig('roles', array($this->role->id() => $this->role->id()));
+ $condition->setConfig('roles', [$this->role->id() => $this->role->id()]);
$condition->setConfig('negate', FALSE);
$this->assertTrue($condition->execute(), 'Authenticated user is a member of the custom role.');
- $this->assertEqual($condition->summary(), SafeMarkup::format('The user is a member of @roles', array('@roles' => $this->role->label())));
+ $this->assertEqual($condition->summary(), SafeMarkup::format('The user is a member of @roles', ['@roles' => $this->role->label()]));
}
}
diff --git a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldTest.php b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldTest.php
index 0f64c79a554..75bccf14beb 100644
--- a/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldTest.php
+++ b/core/modules/user/tests/src/Kernel/Migrate/MigrateUserProfileFieldTest.php
@@ -41,7 +41,7 @@ class MigrateUserProfileFieldTest extends MigrateDrupal6TestBase {
$field_storage = FieldStorageConfig::load('user.profile_sold_to');
$this->assertIdentical('list_string', $field_storage->getType(), 'Field type is list_string.');
$settings = $field_storage->getSettings();
- $this->assertEqual($settings['allowed_values'], array(
+ $this->assertEqual($settings['allowed_values'], [
'Pill spammers' => 'Pill spammers',
'Fitness spammers' => 'Fitness spammers',
'Back\slash' => 'Back\slash',
@@ -49,7 +49,7 @@ class MigrateUserProfileFieldTest extends MigrateDrupal6TestBase {
'Dot.in.the.middle' => 'Dot.in.the.middle',
'Faithful servant' => 'Faithful servant',
'Anonymous donor' => 'Anonymous donor',
- ));
+ ]);
$this->assertIdentical('list_string', $field_storage->getType(), 'Field type is list_string.');
// Migrated list field.
diff --git a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureFileTest.php b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureFileTest.php
index b3b6a642304..1d28e2a7dc1 100644
--- a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureFileTest.php
+++ b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureFileTest.php
@@ -29,7 +29,7 @@ class MigrateUserPictureFileTest extends MigrateDrupal6TestBase {
* Tests the Drupal 6 user pictures to Drupal 8 migration.
*/
public function testUserPictures() {
- $file_ids = array();
+ $file_ids = [];
foreach ($this->migration->getIdMap() as $destination_ids) {
$file_ids[] = reset($destination_ids);
}
diff --git a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php
index 33952d177a9..ed287770ae7 100644
--- a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php
+++ b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php
@@ -37,7 +37,7 @@ class MigrateUserTest extends MigrateDrupal6TestBase {
// Make sure uid 1 is created.
user_install();
- $file = File::create(array(
+ $file = File::create([
'fid' => 2,
'uid' => 2,
'filename' => 'image-test.jpg',
@@ -46,12 +46,12 @@ class MigrateUserTest extends MigrateDrupal6TestBase {
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
$file->save();
- $file = File::create(array(
+ $file = File::create([
'fid' => 8,
'uid' => 8,
'filename' => 'image-test.png',
@@ -60,7 +60,7 @@ class MigrateUserTest extends MigrateDrupal6TestBase {
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-2.jpg'));
$file->save();
@@ -84,14 +84,14 @@ class MigrateUserTest extends MigrateDrupal6TestBase {
// Get roles directly from the source.
$rids = Database::getConnection('default', 'migrate')
->select('users_roles', 'ur')
- ->fields('ur', array('rid'))
+ ->fields('ur', ['rid'])
->condition('ur.uid', $source->uid)
->execute()
->fetchCol();
- $roles = array(RoleInterface::AUTHENTICATED_ID);
+ $roles = [RoleInterface::AUTHENTICATED_ID];
$id_map = $this->getMigration('d6_user_role')->getIdMap();
foreach ($rids as $rid) {
- $role = $id_map->lookupDestinationId(array($rid));
+ $role = $id_map->lookupDestinationId([$rid]);
$roles[] = reset($role);
}
diff --git a/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php b/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php
index d18d0711b1e..7d73dafecd1 100644
--- a/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php
+++ b/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php
@@ -177,20 +177,20 @@ class MigrateUserTest extends MigrateDrupal7TestBase {
foreach ($users as $source) {
$rids = Database::getConnection('default', 'migrate')
->select('users_roles', 'ur')
- ->fields('ur', array('rid'))
+ ->fields('ur', ['rid'])
->condition('ur.uid', $source->uid)
->execute()
->fetchCol();
- $roles = array(RoleInterface::AUTHENTICATED_ID);
+ $roles = [RoleInterface::AUTHENTICATED_ID];
$id_map = $this->getMigration('d7_user_role')->getIdMap();
foreach ($rids as $rid) {
- $role = $id_map->lookupDestinationId(array($rid));
+ $role = $id_map->lookupDestinationId([$rid]);
$roles[] = reset($role);
}
$field_integer = Database::getConnection('default', 'migrate')
->select('field_data_field_integer', 'fi')
- ->fields('fi', array('field_integer_value'))
+ ->fields('fi', ['field_integer_value'])
->condition('fi.entity_id', $source->uid)
->execute()
->fetchCol();
diff --git a/core/modules/user/tests/src/Kernel/TempStoreDatabaseTest.php b/core/modules/user/tests/src/Kernel/TempStoreDatabaseTest.php
index 254524a9712..b3d7ff1e1a1 100644
--- a/core/modules/user/tests/src/Kernel/TempStoreDatabaseTest.php
+++ b/core/modules/user/tests/src/Kernel/TempStoreDatabaseTest.php
@@ -21,7 +21,7 @@ class TempStoreDatabaseTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user');
+ public static $modules = ['system', 'user'];
/**
* A key/value store factory.
@@ -42,21 +42,21 @@ class TempStoreDatabaseTest extends KernelTestBase {
*
* @var array
*/
- protected $users = array();
+ protected $users = [];
/**
* An array of random stdClass objects.
*
* @var array
*/
- protected $objects = array();
+ protected $objects = [];
protected function setUp() {
parent::setUp();
// Install system tables to test the key/value storage without installing a
// full Drupal environment.
- $this->installSchema('system', array('key_value_expire'));
+ $this->installSchema('system', ['key_value_expire']);
// Create several objects for testing.
for ($i = 0; $i <= 3; $i++) {
@@ -135,7 +135,7 @@ class TempStoreDatabaseTest extends KernelTestBase {
// Now manually expire the item (this is not exposed by the API) and then
// assert it is no longer accessible.
db_update('key_value_expire')
- ->fields(array('expire' => REQUEST_TIME - 1))
+ ->fields(['expire' => REQUEST_TIME - 1])
->condition('collection', "user.shared_tempstore.$collection")
->condition('name', $key)
->execute();
diff --git a/core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php b/core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php
index 40229725417..e4367a05155 100644
--- a/core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php
+++ b/core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php
@@ -18,7 +18,7 @@ class UserAccountFormFieldsTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field');
+ public static $modules = ['system', 'user', 'field'];
/**
* Tests the root user account form section in the "Configure site" form.
@@ -37,7 +37,7 @@ class UserAccountFormFieldsTest extends KernelTestBase {
// Verify that web browsers may autocomplete the email value and
// autofill/prefill the name and pass values.
- foreach (array('mail', 'name', 'pass') as $key) {
+ foreach (['mail', 'name', 'pass'] as $key) {
$this->assertFalse(isset($form['account'][$key]['#attributes']['autocomplete']), "'$key' field: 'autocomplete' attribute not found.");
}
}
@@ -47,7 +47,7 @@ class UserAccountFormFieldsTest extends KernelTestBase {
*/
function testUserRegistrationForm() {
// Install default configuration; required for AccountFormController.
- $this->installConfig(array('user'));
+ $this->installConfig(['user']);
// Disable email confirmation to unlock the password field.
$this->config('user.settings')
@@ -61,7 +61,7 @@ class UserAccountFormFieldsTest extends KernelTestBase {
// Verify that web browsers may autocomplete the email value and
// autofill/prefill the name and pass values.
- foreach (array('mail', 'name', 'pass') as $key) {
+ foreach (['mail', 'name', 'pass'] as $key) {
$this->assertFalse(isset($form['account'][$key]['#attributes']['autocomplete']), "'$key' field: 'autocomplete' attribute not found.");
}
}
@@ -71,7 +71,7 @@ class UserAccountFormFieldsTest extends KernelTestBase {
*/
function testUserEditForm() {
// Install default configuration; required for AccountFormController.
- $this->installConfig(array('user'));
+ $this->installConfig(['user']);
// Install the router table and then rebuild.
\Drupal::service('router.builder')->rebuild();
@@ -82,7 +82,7 @@ class UserAccountFormFieldsTest extends KernelTestBase {
$this->assertFieldOrder($form['account']);
// Verify that autocomplete is off on all account fields.
- foreach (array('mail', 'name', 'pass') as $key) {
+ foreach (['mail', 'name', 'pass'] as $key) {
$this->assertIdentical($form['account'][$key]['#attributes']['autocomplete'], 'off', "'$key' field: 'autocomplete' attribute is 'off'.");
}
}
@@ -128,7 +128,7 @@ class UserAccountFormFieldsTest extends KernelTestBase {
protected function buildAccountForm($operation) {
// @see HtmlEntityFormController::getFormObject()
$entity_type = 'user';
- $fields = array();
+ $fields = [];
if ($operation != 'register') {
$fields['uid'] = 2;
}
diff --git a/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php b/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php
index bde5861e3dc..c405ad97aec 100644
--- a/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php
+++ b/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php
@@ -21,14 +21,14 @@ class UserActionConfigSchemaTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user');
+ public static $modules = ['system', 'user'];
/**
* Tests whether the user action config schema are valid.
*/
function testValidUserActionConfigSchema() {
$rid = strtolower($this->randomMachineName(8));
- Role::create(array('id' => $rid))->save();
+ Role::create(['id' => $rid])->save();
// Test user_add_role_action configuration.
$config = $this->config('system.action.user_add_role_action.' . $rid);
diff --git a/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php b/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php
index 8958c542a4e..14dc7ada242 100644
--- a/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php
+++ b/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php
@@ -36,16 +36,16 @@ class UserEntityReferenceTest extends EntityKernelTestBase {
protected function setUp() {
parent::setUp();
- $this->role1 = Role::create(array(
+ $this->role1 = Role::create([
'id' => strtolower($this->randomMachineName(8)),
'label' => $this->randomMachineName(8),
- ));
+ ]);
$this->role1->save();
- $this->role2 = Role::create(array(
+ $this->role2 = Role::create([
'id' => strtolower($this->randomMachineName(8)),
'label' => $this->randomMachineName(8),
- ));
+ ]);
$this->role2->save();
$this->createEntityReferenceField('user', 'user', 'user_reference', 'User reference', 'user');
@@ -57,23 +57,23 @@ class UserEntityReferenceTest extends EntityKernelTestBase {
function testUserSelectionByRole() {
$field_definition = FieldConfig::loadByName('user', 'user', 'user_reference');
$handler_settings = $field_definition->getSetting('handler_settings');
- $handler_settings['filter']['role'] = array(
+ $handler_settings['filter']['role'] = [
$this->role1->id() => $this->role1->id(),
$this->role2->id() => 0,
- );
+ ];
$handler_settings['filter']['type'] = 'role';
$field_definition->setSetting('handler_settings', $handler_settings);
$field_definition->save();
- $user1 = $this->createUser(array('name' => 'aabb'));
+ $user1 = $this->createUser(['name' => 'aabb']);
$user1->addRole($this->role1->id());
$user1->save();
- $user2 = $this->createUser(array('name' => 'aabbb'));
+ $user2 = $this->createUser(['name' => 'aabbb']);
$user2->addRole($this->role1->id());
$user2->save();
- $user3 = $this->createUser(array('name' => 'aabbbb'));
+ $user3 = $this->createUser(['name' => 'aabbbb']);
$user3->addRole($this->role2->id());
$user3->save();
@@ -83,7 +83,7 @@ class UserEntityReferenceTest extends EntityKernelTestBase {
$matches = $autocomplete->getMatches('user', 'default', $field_definition->getSetting('handler_settings'), 'aabb');
$this->assertEqual(count($matches), 2);
- $users = array();
+ $users = [];
foreach ($matches as $match) {
$users[] = $match['label'];
}
diff --git a/core/modules/user/tests/src/Kernel/UserEntityTest.php b/core/modules/user/tests/src/Kernel/UserEntityTest.php
index 9002e5ca379..1c501f049e7 100644
--- a/core/modules/user/tests/src/Kernel/UserEntityTest.php
+++ b/core/modules/user/tests/src/Kernel/UserEntityTest.php
@@ -19,7 +19,7 @@ class UserEntityTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field');
+ public static $modules = ['system', 'user', 'field'];
/**
* Tests some of the methods.
@@ -30,39 +30,39 @@ class UserEntityTest extends KernelTestBase {
*/
public function testUserMethods() {
$role_storage = $this->container->get('entity.manager')->getStorage('user_role');
- $role_storage->create(array('id' => 'test_role_one'))->save();
- $role_storage->create(array('id' => 'test_role_two'))->save();
- $role_storage->create(array('id' => 'test_role_three'))->save();
+ $role_storage->create(['id' => 'test_role_one'])->save();
+ $role_storage->create(['id' => 'test_role_two'])->save();
+ $role_storage->create(['id' => 'test_role_three'])->save();
- $values = array(
+ $values = [
'uid' => 1,
- 'roles' => array('test_role_one'),
- );
+ 'roles' => ['test_role_one'],
+ ];
$user = User::create($values);
$this->assertTrue($user->hasRole('test_role_one'));
$this->assertFalse($user->hasRole('test_role_two'));
- $this->assertEqual(array(RoleInterface::AUTHENTICATED_ID, 'test_role_one'), $user->getRoles());
+ $this->assertEqual([RoleInterface::AUTHENTICATED_ID, 'test_role_one'], $user->getRoles());
$user->addRole('test_role_one');
$this->assertTrue($user->hasRole('test_role_one'));
$this->assertFalse($user->hasRole('test_role_two'));
- $this->assertEqual(array(RoleInterface::AUTHENTICATED_ID, 'test_role_one'), $user->getRoles());
+ $this->assertEqual([RoleInterface::AUTHENTICATED_ID, 'test_role_one'], $user->getRoles());
$user->addRole('test_role_two');
$this->assertTrue($user->hasRole('test_role_one'));
$this->assertTrue($user->hasRole('test_role_two'));
- $this->assertEqual(array(RoleInterface::AUTHENTICATED_ID, 'test_role_one', 'test_role_two'), $user->getRoles());
+ $this->assertEqual([RoleInterface::AUTHENTICATED_ID, 'test_role_one', 'test_role_two'], $user->getRoles());
$user->removeRole('test_role_three');
$this->assertTrue($user->hasRole('test_role_one'));
$this->assertTrue($user->hasRole('test_role_two'));
- $this->assertEqual(array(RoleInterface::AUTHENTICATED_ID, 'test_role_one', 'test_role_two'), $user->getRoles());
+ $this->assertEqual([RoleInterface::AUTHENTICATED_ID, 'test_role_one', 'test_role_two'], $user->getRoles());
$user->removeRole('test_role_one');
$this->assertFalse($user->hasRole('test_role_one'));
$this->assertTrue($user->hasRole('test_role_two'));
- $this->assertEqual(array(RoleInterface::AUTHENTICATED_ID, 'test_role_two'), $user->getRoles());
+ $this->assertEqual([RoleInterface::AUTHENTICATED_ID, 'test_role_two'], $user->getRoles());
}
}
diff --git a/core/modules/user/tests/src/Kernel/UserFieldsTest.php b/core/modules/user/tests/src/Kernel/UserFieldsTest.php
index f0fb5322f5d..18f8f3b365a 100644
--- a/core/modules/user/tests/src/Kernel/UserFieldsTest.php
+++ b/core/modules/user/tests/src/Kernel/UserFieldsTest.php
@@ -27,7 +27,7 @@ class UserFieldsTest extends KernelTestBase {
$this->installEntitySchema('user');
// Set up a test theme that prints the user's mail field.
- \Drupal::service('theme_handler')->install(array('user_test_theme'));
+ \Drupal::service('theme_handler')->install(['user_test_theme']);
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('user_test_theme'));
// Clear the theme registry.
$this->container->set('theme.registry', NULL);
diff --git a/core/modules/user/tests/src/Kernel/UserInstallTest.php b/core/modules/user/tests/src/Kernel/UserInstallTest.php
index 2bbcd5fcd4a..f61811be79f 100644
--- a/core/modules/user/tests/src/Kernel/UserInstallTest.php
+++ b/core/modules/user/tests/src/Kernel/UserInstallTest.php
@@ -16,7 +16,7 @@ class UserInstallTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('user');
+ public static $modules = ['user'];
/**
* {@inheritdoc}
diff --git a/core/modules/user/tests/src/Kernel/UserRoleDeleteTest.php b/core/modules/user/tests/src/Kernel/UserRoleDeleteTest.php
index 1aefbcfcece..cac470aaab8 100644
--- a/core/modules/user/tests/src/Kernel/UserRoleDeleteTest.php
+++ b/core/modules/user/tests/src/Kernel/UserRoleDeleteTest.php
@@ -17,7 +17,7 @@ class UserRoleDeleteTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field');
+ public static $modules = ['system', 'user', 'field'];
protected function setUp() {
parent::setUp();
@@ -32,15 +32,15 @@ class UserRoleDeleteTest extends KernelTestBase {
public function testRoleDeleteUserRoleReferenceDelete() {
// Create two test roles.
$role_storage = $this->container->get('entity.manager')->getStorage('user_role');
- $role_storage->create(array('id' => 'test_role_one'))->save();
- $role_storage->create(array('id' => 'test_role_two'))->save();
+ $role_storage->create(['id' => 'test_role_one'])->save();
+ $role_storage->create(['id' => 'test_role_two'])->save();
// Create user and assign both test roles.
- $values = array(
+ $values = [
'uid' => 1,
'name' => $this->randomString(),
- 'roles' => array('test_role_one', 'test_role_two'),
- );
+ 'roles' => ['test_role_one', 'test_role_two'],
+ ];
$user = User::create($values);
$user->save();
@@ -60,7 +60,7 @@ class UserRoleDeleteTest extends KernelTestBase {
$this->assertTrue($user->hasRole('test_role_two'));
// Create new role with same name.
- $role_storage->create(array('id' => 'test_role_one'))->save();
+ $role_storage->create(['id' => 'test_role_one'])->save();
// Load user again from the database.
$user = User::load($user->id());
diff --git a/core/modules/user/tests/src/Kernel/UserSaveStatusTest.php b/core/modules/user/tests/src/Kernel/UserSaveStatusTest.php
index 00a29fcd606..0ad1bde38cb 100644
--- a/core/modules/user/tests/src/Kernel/UserSaveStatusTest.php
+++ b/core/modules/user/tests/src/Kernel/UserSaveStatusTest.php
@@ -17,7 +17,7 @@ class UserSaveStatusTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field');
+ public static $modules = ['system', 'user', 'field'];
protected function setUp() {
parent::setUp();
@@ -29,10 +29,10 @@ class UserSaveStatusTest extends KernelTestBase {
*/
function testUserSaveStatus() {
// Create a new user.
- $values = array(
+ $values = [
'uid' => 1,
'name' => $this->randomMachineName(),
- );
+ ];
$user = User::create($values);
// Test SAVED_NEW.
diff --git a/core/modules/user/tests/src/Kernel/UserValidationTest.php b/core/modules/user/tests/src/Kernel/UserValidationTest.php
index b27b00f747e..9be1fd0d627 100644
--- a/core/modules/user/tests/src/Kernel/UserValidationTest.php
+++ b/core/modules/user/tests/src/Kernel/UserValidationTest.php
@@ -21,7 +21,7 @@ class UserValidationTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('field', 'user', 'system');
+ public static $modules = ['field', 'user', 'system'];
/**
* {@inheritdoc}
@@ -29,10 +29,10 @@ class UserValidationTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
$this->installEntitySchema('user');
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
// Make sure that the default roles exist.
- $this->installConfig(array('user'));
+ $this->installConfig(['user']);
}
@@ -40,25 +40,25 @@ class UserValidationTest extends KernelTestBase {
* Tests user name validation.
*/
function testUsernames() {
- $test_cases = array( // '<username>' => array('<description>', 'assert<testName>'),
- 'foo' => array('Valid username', 'assertNull'),
- 'FOO' => array('Valid username', 'assertNull'),
- 'Foo O\'Bar' => array('Valid username', 'assertNull'),
- 'foo@bar' => array('Valid username', 'assertNull'),
- 'foo@example.com' => array('Valid username', 'assertNull'),
- 'foo@-example.com' => array('Valid username', 'assertNull'), // invalid domains are allowed in usernames
- 'þòøÇߪř€' => array('Valid username', 'assertNull'),
- 'foo+bar' => array('Valid username', 'assertNull'), // '+' symbol is allowed
- 'ᚠᛇᚻ᛫ᛒᛦᚦ' => array('Valid UTF8 username', 'assertNull'), // runes
- ' foo' => array('Invalid username that starts with a space', 'assertNotNull'),
- 'foo ' => array('Invalid username that ends with a space', 'assertNotNull'),
- 'foo bar' => array('Invalid username that contains 2 spaces \'&nbsp;&nbsp;\'', 'assertNotNull'),
- '' => array('Invalid empty username', 'assertNotNull'),
- 'foo/' => array('Invalid username containing invalid chars', 'assertNotNull'),
- 'foo' . chr(0) . 'bar' => array('Invalid username containing chr(0)', 'assertNotNull'), // NULL
- 'foo' . chr(13) . 'bar' => array('Invalid username containing chr(13)', 'assertNotNull'), // CR
- str_repeat('x', USERNAME_MAX_LENGTH + 1) => array('Invalid excessively long username', 'assertNotNull'),
- );
+ $test_cases = [ // '<username>' => array('<description>', 'assert<testName>'),
+ 'foo' => ['Valid username', 'assertNull'],
+ 'FOO' => ['Valid username', 'assertNull'],
+ 'Foo O\'Bar' => ['Valid username', 'assertNull'],
+ 'foo@bar' => ['Valid username', 'assertNull'],
+ 'foo@example.com' => ['Valid username', 'assertNull'],
+ 'foo@-example.com' => ['Valid username', 'assertNull'], // invalid domains are allowed in usernames
+ 'þòøÇߪř€' => ['Valid username', 'assertNull'],
+ 'foo+bar' => ['Valid username', 'assertNull'], // '+' symbol is allowed
+ 'ᚠᛇᚻ᛫ᛒᛦᚦ' => ['Valid UTF8 username', 'assertNull'], // runes
+ ' foo' => ['Invalid username that starts with a space', 'assertNotNull'],
+ 'foo ' => ['Invalid username that ends with a space', 'assertNotNull'],
+ 'foo bar' => ['Invalid username that contains 2 spaces \'&nbsp;&nbsp;\'', 'assertNotNull'],
+ '' => ['Invalid empty username', 'assertNotNull'],
+ 'foo/' => ['Invalid username containing invalid chars', 'assertNotNull'],
+ 'foo' . chr(0) . 'bar' => ['Invalid username containing chr(0)', 'assertNotNull'], // NULL
+ 'foo' . chr(13) . 'bar' => ['Invalid username containing chr(13)', 'assertNotNull'], // CR
+ str_repeat('x', USERNAME_MAX_LENGTH + 1) => ['Invalid excessively long username', 'assertNotNull'],
+ ];
foreach ($test_cases as $name => $test_case) {
list($description, $test) = $test_case;
$result = user_validate_name($name);
@@ -70,10 +70,10 @@ class UserValidationTest extends KernelTestBase {
* Runs entity validation checks.
*/
function testValidation() {
- $user = User::create(array(
+ $user = User::create([
'name' => 'test',
'mail' => 'test@example.com',
- ));
+ ]);
$violations = $user->validate();
$this->assertEqual(count($violations), 0, 'No violations when validating a default user.');
@@ -84,7 +84,7 @@ class UserValidationTest extends KernelTestBase {
$violations = $user->validate();
$this->assertEqual(count($violations), 1, 'Violation found when name is too long.');
$this->assertEqual($violations[0]->getPropertyPath(), 'name');
- $this->assertEqual($violations[0]->getMessage(), t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => 60)));
+ $this->assertEqual($violations[0]->getMessage(), t('The username %name is too long: it must be %max characters or less.', ['%name' => $name, '%max' => 60]));
// Create a second test user to provoke a name collision.
$user2 = User::create([
@@ -96,7 +96,7 @@ class UserValidationTest extends KernelTestBase {
$violations = $user->validate();
$this->assertEqual(count($violations), 1, 'Violation found on name collision.');
$this->assertEqual($violations[0]->getPropertyPath(), 'name');
- $this->assertEqual($violations[0]->getMessage(), t('The username %name is already taken.', array('%name' => 'existing')));
+ $this->assertEqual($violations[0]->getMessage(), t('The username %name is already taken.', ['%name' => 'existing']));
// Make the name valid.
$user->set('name', $this->randomMachineName());
@@ -116,7 +116,7 @@ class UserValidationTest extends KernelTestBase {
// https://www.drupal.org/node/2023465.
$this->assertEqual(count($violations), 2, 'Violations found when email is too long');
$this->assertEqual($violations[0]->getPropertyPath(), 'mail.0.value');
- $this->assertEqual($violations[0]->getMessage(), t('%name: the email address can not be longer than @max characters.', array('%name' => $user->get('mail')->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH)));
+ $this->assertEqual($violations[0]->getMessage(), t('%name: the email address can not be longer than @max characters.', ['%name' => $user->get('mail')->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH]));
$this->assertEqual($violations[1]->getPropertyPath(), 'mail.0.value');
$this->assertEqual($violations[1]->getMessage(), t('This value is not a valid email address.'));
@@ -125,12 +125,12 @@ class UserValidationTest extends KernelTestBase {
$violations = $user->validate();
$this->assertEqual(count($violations), 1, 'Violation found when email already exists.');
$this->assertEqual($violations[0]->getPropertyPath(), 'mail');
- $this->assertEqual($violations[0]->getMessage(), t('The email address %mail is already taken.', array('%mail' => 'existing@example.com')));
+ $this->assertEqual($violations[0]->getMessage(), t('The email address %mail is already taken.', ['%mail' => 'existing@example.com']));
$user->set('mail', NULL);
$violations = $user->validate();
$this->assertEqual(count($violations), 1, 'Email addresses may not be removed');
$this->assertEqual($violations[0]->getPropertyPath(), 'mail');
- $this->assertEqual($violations[0]->getMessage(), t('@name field is required.', array('@name' => $user->getFieldDefinition('mail')->getLabel())));
+ $this->assertEqual($violations[0]->getMessage(), t('@name field is required.', ['@name' => $user->getFieldDefinition('mail')->getLabel()]));
$user->set('mail', 'someone@example.com');
$user->set('timezone', $this->randomString(33));
@@ -157,14 +157,14 @@ class UserValidationTest extends KernelTestBase {
$this->assertAllowedValuesViolation($user, 'preferred_admin_langcode');
$user->set('preferred_admin_langcode', NULL);
- Role::create(array('id' => 'role1'))->save();
- Role::create(array('id' => 'role2'))->save();
+ Role::create(['id' => 'role1'])->save();
+ Role::create(['id' => 'role2'])->save();
// Test cardinality of user roles.
$user = User::create([
'name' => 'role_test',
'mail' => 'test@example.com',
- 'roles' => array('role1', 'role2'),
+ 'roles' => ['role1', 'role2'],
]);
$violations = $user->validate();
$this->assertEqual(count($violations), 0);
@@ -173,7 +173,7 @@ class UserValidationTest extends KernelTestBase {
$violations = $user->validate();
$this->assertEqual(count($violations), 1);
$this->assertEqual($violations[0]->getPropertyPath(), 'roles.1.target_id');
- $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%entity_type: %name) does not exist.', array('%entity_type' => 'user_role', '%name' => 'unknown_role')));
+ $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%entity_type: %name) does not exist.', ['%entity_type' => 'user_role', '%name' => 'unknown_role']));
}
/**
@@ -195,7 +195,7 @@ class UserValidationTest extends KernelTestBase {
$this->assertEqual(count($violations), $count, "Violation found when $field_name is too long.");
$this->assertEqual($violations[$expected_index]->getPropertyPath(), "$field_name.0.value");
$field_label = $entity->get($field_name)->getFieldDefinition()->getLabel();
- $this->assertEqual($violations[$expected_index]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => $length)));
+ $this->assertEqual($violations[$expected_index]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => $field_label, '@max' => $length]));
}
/**
diff --git a/core/modules/user/tests/src/Kernel/Views/HandlerFieldPermissionTest.php b/core/modules/user/tests/src/Kernel/Views/HandlerFieldPermissionTest.php
index c0c791fe5d1..0d212218414 100644
--- a/core/modules/user/tests/src/Kernel/Views/HandlerFieldPermissionTest.php
+++ b/core/modules/user/tests/src/Kernel/Views/HandlerFieldPermissionTest.php
@@ -17,7 +17,7 @@ class HandlerFieldPermissionTest extends UserKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_field_permission');
+ public static $testViews = ['test_field_permission'];
/**
* Tests the permission field handler output.
@@ -31,9 +31,9 @@ class HandlerFieldPermissionTest extends UserKernelTestBase {
$view->render();
$style_plugin = $view->style_plugin;
- $expected_permissions = array();
- $expected_permissions[$this->users[0]->id()] = array();
- $expected_permissions[$this->users[1]->id()] = array();
+ $expected_permissions = [];
+ $expected_permissions[$this->users[0]->id()] = [];
+ $expected_permissions[$this->users[1]->id()] = [];
$expected_permissions[$this->users[2]->id()][] = t('Administer permissions');
// View user profiles comes first, because we sort by the permission
// machine name.
diff --git a/core/modules/user/tests/src/Kernel/Views/HandlerFilterPermissionTest.php b/core/modules/user/tests/src/Kernel/Views/HandlerFilterPermissionTest.php
index 069a9239d1a..b005f62adaa 100644
--- a/core/modules/user/tests/src/Kernel/Views/HandlerFilterPermissionTest.php
+++ b/core/modules/user/tests/src/Kernel/Views/HandlerFilterPermissionTest.php
@@ -18,7 +18,7 @@ class HandlerFilterPermissionTest extends UserKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_filter_permission');
+ public static $testViews = ['test_filter_permission'];
protected $columnMap;
@@ -31,64 +31,64 @@ class HandlerFilterPermissionTest extends UserKernelTestBase {
public function testFilterPermission() {
$this->setupPermissionTestData();
- $column_map = array('uid' => 'uid');
+ $column_map = ['uid' => 'uid'];
$view = Views::getView('test_filter_permission');
// Filter by a non existing permission.
$view->initHandlers();
- $view->filter['permission']->value = array('non_existent_permission');
+ $view->filter['permission']->value = ['non_existent_permission'];
$this->executeView($view);
$this->assertEqual(count($view->result), 4, 'A non existent permission is not filtered so everything is the result.');
- $expected[] = array('uid' => 1);
- $expected[] = array('uid' => 2);
- $expected[] = array('uid' => 3);
- $expected[] = array('uid' => 4);
+ $expected[] = ['uid' => 1];
+ $expected[] = ['uid' => 2];
+ $expected[] = ['uid' => 3];
+ $expected[] = ['uid' => 4];
$this->assertIdenticalResultset($view, $expected, $column_map);
$view->destroy();
// Filter by a permission.
$view->initHandlers();
- $view->filter['permission']->value = array('administer permissions');
+ $view->filter['permission']->value = ['administer permissions'];
$this->executeView($view);
$this->assertEqual(count($view->result), 2);
- $expected = array();
- $expected[] = array('uid' => 3);
- $expected[] = array('uid' => 4);
+ $expected = [];
+ $expected[] = ['uid' => 3];
+ $expected[] = ['uid' => 4];
$this->assertIdenticalResultset($view, $expected, $column_map);
$view->destroy();
// Filter by not a permission.
$view->initHandlers();
$view->filter['permission']->operator = 'not';
- $view->filter['permission']->value = array('administer users');
+ $view->filter['permission']->value = ['administer users'];
$this->executeView($view);
$this->assertEqual(count($view->result), 3);
- $expected = array();
- $expected[] = array('uid' => 1);
- $expected[] = array('uid' => 2);
- $expected[] = array('uid' => 3);
+ $expected = [];
+ $expected[] = ['uid' => 1];
+ $expected[] = ['uid' => 2];
+ $expected[] = ['uid' => 3];
$this->assertIdenticalResultset($view, $expected, $column_map);
$view->destroy();
// Filter by not multiple permissions, that are present in multiple roles.
$view->initHandlers();
$view->filter['permission']->operator = 'not';
- $view->filter['permission']->value = array('administer users', 'administer permissions');
+ $view->filter['permission']->value = ['administer users', 'administer permissions'];
$this->executeView($view);
$this->assertEqual(count($view->result), 2);
- $expected = array();
- $expected[] = array('uid' => 1);
- $expected[] = array('uid' => 2);
+ $expected = [];
+ $expected[] = ['uid' => 1];
+ $expected[] = ['uid' => 2];
$this->assertIdenticalResultset($view, $expected, $column_map);
$view->destroy();
// Filter by another permission of a role with multiple permissions.
$view->initHandlers();
- $view->filter['permission']->value = array('administer users');
+ $view->filter['permission']->value = ['administer users'];
$this->executeView($view);
$this->assertEqual(count($view->result), 1);
- $expected = array();
- $expected[] = array('uid' => 4);
+ $expected = [];
+ $expected[] = ['uid' => 4];
$this->assertIdenticalResultset($view, $expected, $column_map);
$view->destroy();
@@ -103,7 +103,7 @@ class HandlerFilterPermissionTest extends UserKernelTestBase {
foreach ($permissions as $name => $permission) {
$permission_by_module[$permission['provider']][$name] = $permission;
}
- foreach (array('system' => 'System', 'user' => 'User') as $module => $title) {
+ foreach (['system' => 'System', 'user' => 'User'] as $module => $title) {
$expected = array_map(function ($permission) {
return Html::escape(strip_tags($permission['title']));
}, $permission_by_module[$module]);
diff --git a/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php b/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php
index 37d0f2cdc2e..306e813323f 100644
--- a/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php
+++ b/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php
@@ -20,7 +20,7 @@ class HandlerFilterRolesTest extends UserKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_user_name');
+ public static $testViews = ['test_user_name'];
/**
* Tests that role filter dependencies are calculated correctly.
diff --git a/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php b/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php
index 075315c50ed..0e862c86b89 100644
--- a/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php
+++ b/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php
@@ -15,14 +15,14 @@ abstract class UserKernelTestBase extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('user_test_views', 'user', 'system', 'field');
+ public static $modules = ['user_test_views', 'user', 'system', 'field'];
/**
* Users to use during this test.
*
* @var array
*/
- protected $users = array();
+ protected $users = [];
/**
* The entity storage for roles.
@@ -41,7 +41,7 @@ abstract class UserKernelTestBase extends ViewsKernelTestBase {
protected function setUp($import_test_views = TRUE) {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('user_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['user_test_views']);
$this->installEntitySchema('user');
@@ -55,33 +55,33 @@ abstract class UserKernelTestBase extends ViewsKernelTestBase {
*/
protected function setupPermissionTestData() {
// Setup a role without any permission.
- $this->roleStorage->create(array('id' => 'authenticated'))
+ $this->roleStorage->create(['id' => 'authenticated'])
->save();
- $this->roleStorage->create(array('id' => 'no_permission'))
+ $this->roleStorage->create(['id' => 'no_permission'])
->save();
// Setup a role with just one permission.
- $this->roleStorage->create(array('id' => 'one_permission'))
+ $this->roleStorage->create(['id' => 'one_permission'])
->save();
- user_role_grant_permissions('one_permission', array('administer permissions'));
+ user_role_grant_permissions('one_permission', ['administer permissions']);
// Setup a role with multiple permissions.
- $this->roleStorage->create(array('id' => 'multiple_permissions'))
+ $this->roleStorage->create(['id' => 'multiple_permissions'])
->save();
- user_role_grant_permissions('multiple_permissions', array('administer permissions', 'administer users', 'access user profiles'));
+ user_role_grant_permissions('multiple_permissions', ['administer permissions', 'administer users', 'access user profiles']);
// Setup a user without an extra role.
$this->users[] = $account = $this->userStorage->create(['name' => $this->randomString()]);
$account->save();
// Setup a user with just the first role (so no permission beside the
// ones from the authenticated role).
- $this->users[] = $account = $this->userStorage->create(array('name' => 'first_role'));
+ $this->users[] = $account = $this->userStorage->create(['name' => 'first_role']);
$account->addRole('no_permission');
$account->save();
// Setup a user with just the second role (so one additional permission).
- $this->users[] = $account = $this->userStorage->create(array('name' => 'second_role'));
+ $this->users[] = $account = $this->userStorage->create(['name' => 'second_role']);
$account->addRole('one_permission');
$account->save();
// Setup a user with both the second and the third role.
- $this->users[] = $account = $this->userStorage->create(array('name' => 'second_third_role'));
+ $this->users[] = $account = $this->userStorage->create(['name' => 'second_third_role']);
$account->addRole('one_permission');
$account->addRole('multiple_permissions');
$account->save();
diff --git a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php
index 97e9f33f38f..106e09142c1 100644
--- a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php
+++ b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php
@@ -12,7 +12,7 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
- $this->directoryList = array('user' => 'core/modules/user');
+ $this->directoryList = ['user' => 'core/modules/user'];
parent::setUp();
}
@@ -29,12 +29,12 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getUserAdminRoutes() {
- return array(
- array('entity.user.collection', array(array('entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection'))),
- array('user.admin_permissions', array(array('entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection'))),
- array('entity.user_role.collection', array(array('entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection'))),
- array('entity.user.admin_form', array(array('user.account_settings_tab'))),
- );
+ return [
+ ['entity.user.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection']]],
+ ['user.admin_permissions', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection']]],
+ ['entity.user_role.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection']]],
+ ['entity.user.admin_form', [['user.account_settings_tab']]],
+ ];
}
/**
@@ -43,9 +43,9 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
* @dataProvider getUserLoginRoutes
*/
public function testUserLoginLocalTasks($route) {
- $tasks = array(
- 0 => array('user.register', 'user.pass', 'user.login',),
- );
+ $tasks = [
+ 0 => ['user.register', 'user.pass', 'user.login',],
+ ];
$this->assertLocalTasks($route, $tasks);
}
@@ -53,11 +53,11 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getUserLoginRoutes() {
- return array(
- array('user.login'),
- array('user.register'),
- array('user.pass'),
- );
+ return [
+ ['user.login'],
+ ['user.register'],
+ ['user.pass'],
+ ];
}
/**
@@ -65,10 +65,10 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
*
* @dataProvider getUserPageRoutes
*/
- public function testUserPageLocalTasks($route, $subtask = array()) {
- $tasks = array(
- 0 => array('entity.user.canonical', 'entity.user.edit_form',),
- );
+ public function testUserPageLocalTasks($route, $subtask = []) {
+ $tasks = [
+ 0 => ['entity.user.canonical', 'entity.user.edit_form',],
+ ];
if ($subtask) $tasks[] = $subtask;
$this->assertLocalTasks($route, $tasks);
}
@@ -77,10 +77,10 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getUserPageRoutes() {
- return array(
- array('entity.user.canonical'),
- array('entity.user.edit_form'),
- );
+ return [
+ ['entity.user.canonical'],
+ ['entity.user.edit_form'],
+ ];
}
}
diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php
index b0b91da89f1..2918d2f61ea 100644
--- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php
+++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php
@@ -97,11 +97,11 @@ class PermissionHandlerTest extends UnitTestCase {
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('getModuleDirectories')
- ->willReturn(array(
+ ->willReturn([
'module_a' => vfsStream::url('modules/module_a'),
'module_b' => vfsStream::url('modules/module_b'),
'module_c' => vfsStream::url('modules/module_c'),
- ));
+ ]);
$url = vfsStream::url('modules');
mkdir($url . '/module_a');
@@ -124,16 +124,16 @@ EOF
'restrict access': TRUE
EOF
);
- $modules = array('module_a', 'module_b', 'module_c');
- $extensions = array(
+ $modules = ['module_a', 'module_b', 'module_c'];
+ $extensions = [
'module_a' => $this->mockModuleExtension('module_a', 'Module a'),
'module_b' => $this->mockModuleExtension('module_b', 'Module b'),
'module_c' => $this->mockModuleExtension('module_c', 'Module c'),
- );
+ ];
$this->moduleHandler->expects($this->any())
->method('getImplementations')
->with('permission')
- ->willReturn(array());
+ ->willReturn([]);
$this->moduleHandler->expects($this->any())
->method('getModuleList')
@@ -227,11 +227,11 @@ EOF
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('getModuleDirectories')
- ->willReturn(array(
+ ->willReturn([
'module_a' => vfsStream::url('modules/module_a'),
'module_b' => vfsStream::url('modules/module_b'),
'module_c' => vfsStream::url('modules/module_c'),
- ));
+ ]);
$url = vfsStream::url('modules');
mkdir($url . '/module_a');
@@ -254,17 +254,17 @@ permission_callbacks:
EOF
);
- $modules = array('module_a', 'module_b', 'module_c');
- $extensions = array(
+ $modules = ['module_a', 'module_b', 'module_c'];
+ $extensions = [
'module_a' => $this->mockModuleExtension('module_a', 'Module a'),
'module_b' => $this->mockModuleExtension('module_b', 'Module b'),
'module_c' => $this->mockModuleExtension('module_c', 'Module c'),
- );
+ ];
$this->moduleHandler->expects($this->any())
->method('getImplementations')
->with('permission')
- ->willReturn(array());
+ ->willReturn([]);
$this->moduleHandler->expects($this->any())
->method('getModuleList')
@@ -273,19 +273,19 @@ EOF
$this->controllerResolver->expects($this->at(0))
->method('getControllerFromDefinition')
->with('Drupal\\user\\Tests\\TestPermissionCallbacks::singleDescription')
- ->willReturn(array(new TestPermissionCallbacks(), 'singleDescription'));
+ ->willReturn([new TestPermissionCallbacks(), 'singleDescription']);
$this->controllerResolver->expects($this->at(1))
->method('getControllerFromDefinition')
->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription')
- ->willReturn(array(new TestPermissionCallbacks(), 'titleDescription'));
+ ->willReturn([new TestPermissionCallbacks(), 'titleDescription']);
$this->controllerResolver->expects($this->at(2))
->method('getControllerFromDefinition')
->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleProvider')
- ->willReturn(array(new TestPermissionCallbacks(), 'titleProvider'));
+ ->willReturn([new TestPermissionCallbacks(), 'titleProvider']);
$this->controllerResolver->expects($this->at(3))
->method('getControllerFromDefinition')
->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescriptionRestrictAccess')
- ->willReturn(array(new TestPermissionCallbacks(), 'titleDescriptionRestrictAccess'));
+ ->willReturn([new TestPermissionCallbacks(), 'titleDescriptionRestrictAccess']);
$this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver);
@@ -307,9 +307,9 @@ EOF
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('getModuleDirectories')
- ->willReturn(array(
+ ->willReturn([
'module_a' => vfsStream::url('modules/module_a'),
- ));
+ ]);
$url = vfsStream::url('modules');
mkdir($url . '/module_a');
@@ -322,15 +322,15 @@ permission_callbacks:
EOF
);
- $modules = array('module_a');
- $extensions = array(
+ $modules = ['module_a'];
+ $extensions = [
'module_a' => $this->mockModuleExtension('module_a', 'Module a'),
- );
+ ];
$this->moduleHandler->expects($this->any())
->method('getImplementations')
->with('permission')
- ->willReturn(array());
+ ->willReturn([]);
$this->moduleHandler->expects($this->any())
->method('getModuleList')
@@ -339,7 +339,7 @@ EOF
$this->controllerResolver->expects($this->once())
->method('getControllerFromDefinition')
->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription')
- ->willReturn(array(new TestPermissionCallbacks(), 'titleDescription'));
+ ->willReturn([new TestPermissionCallbacks(), 'titleDescription']);
$this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver);
@@ -399,37 +399,37 @@ class TestPermissionHandler extends PermissionHandler {
class TestPermissionCallbacks {
public function singleDescription() {
- return array(
+ return [
'access_module_a' => 'single_description'
- );
+ ];
}
public function titleDescription() {
- return array(
- 'access module b' => array(
+ return [
+ 'access module b' => [
'title' => 'Access B',
'description' => 'bla bla',
- ),
- );
+ ],
+ ];
}
public function titleDescriptionRestrictAccess() {
- return array(
- 'access_module_c' => array(
+ return [
+ 'access_module_c' => [
'title' => 'Access C',
'description' => 'bla bla',
'restrict access' => TRUE,
- ),
- );
+ ],
+ ];
}
public function titleProvider() {
- return array(
- 'access module a via module b' => array(
+ return [
+ 'access module a via module b' => [
'title' => 'Access A via B',
'provider' => 'module_a',
- ),
- );
+ ],
+ ];
}
}
@@ -442,7 +442,7 @@ class TestTranslationManager implements TranslationInterface {
/**
* {@inheritdoc}
*/
- public function translate($string, array $args = array(), array $options = array()) {
+ public function translate($string, array $args = [], array $options = []) {
return new TranslatableMarkup($string, $args, $options, $this);
}
@@ -456,7 +456,7 @@ class TestTranslationManager implements TranslationInterface {
/**
* {@inheritdoc}
*/
- public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) {
+ public function formatPlural($count, $singular, $plural, array $args = [], array $options = []) {
return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this);
}
diff --git a/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php b/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php
index 0763b256502..5ca694b84ef 100644
--- a/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php
@@ -22,8 +22,8 @@ class AddRoleUserTest extends RoleUserTestBase {
->with($this->equalTo('test_role_1'))
->will($this->returnValue(TRUE));
- $config = array('rid' => 'test_role_1');
- $remove_role_plugin = new AddRoleUser($config, 'user_add_role_action', array('type' => 'user'), $this->userRoleEntityType);
+ $config = ['rid' => 'test_role_1'];
+ $remove_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType);
$remove_role_plugin->execute($this->account);
}
@@ -40,8 +40,8 @@ class AddRoleUserTest extends RoleUserTestBase {
->with($this->equalTo('test_role_1'))
->will($this->returnValue(FALSE));
- $config = array('rid' => 'test_role_1');
- $remove_role_plugin = new AddRoleUser($config, 'user_remove_role_action', array('type' => 'user'), $this->userRoleEntityType);
+ $config = ['rid' => 'test_role_1'];
+ $remove_role_plugin = new AddRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
$remove_role_plugin->execute($this->account);
}
diff --git a/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php b/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php
index 1c6fa25be84..878b4baad24 100644
--- a/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php
@@ -22,8 +22,8 @@ class RemoveRoleUserTest extends RoleUserTestBase {
->with($this->equalTo('test_role_1'))
->will($this->returnValue(TRUE));
- $config = array('rid' => 'test_role_1');
- $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', array('type' => 'user'), $this->userRoleEntityType);
+ $config = ['rid' => 'test_role_1'];
+ $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
$remove_role_plugin->execute($this->account);
}
@@ -40,8 +40,8 @@ class RemoveRoleUserTest extends RoleUserTestBase {
->with($this->equalTo('test_role_1'))
->will($this->returnValue(FALSE));
- $config = array('rid' => 'test_role_1');
- $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', array('type' => 'user'), $this->userRoleEntityType);
+ $config = ['rid' => 'test_role_1'];
+ $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
$remove_role_plugin->execute($this->account);
}
diff --git a/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php b/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php
index 86ce8e9ac71..623203ee74d 100644
--- a/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php
@@ -14,20 +14,20 @@ class UserTest extends UserSessionTest {
/**
* {@inheritdoc}
*/
- protected function createUserSession(array $rids = array(), $authenticated = FALSE) {
+ protected function createUserSession(array $rids = [], $authenticated = FALSE) {
$user = $this->getMockBuilder('Drupal\user\Entity\User')
->disableOriginalConstructor()
- ->setMethods(array('get', 'id'))
+ ->setMethods(['get', 'id'])
->getMock();
$user->expects($this->any())
->method('id')
// @todo Also test the uid = 1 handling.
->will($this->returnValue($authenticated ? 2 : 0));
- $roles = array();
+ $roles = [];
foreach ($rids as $rid) {
- $roles[] = (object) array(
+ $roles[] = (object) [
'target_id' => $rid,
- );
+ ];
}
$user->expects($this->any())
->method('get')
@@ -44,14 +44,14 @@ class UserTest extends UserSessionTest {
*/
public function testUserGetRoles() {
// Anonymous user.
- $user = $this->createUserSession(array());
- $this->assertEquals(array(RoleInterface::ANONYMOUS_ID), $user->getRoles());
- $this->assertEquals(array(), $user->getRoles(TRUE));
+ $user = $this->createUserSession([]);
+ $this->assertEquals([RoleInterface::ANONYMOUS_ID], $user->getRoles());
+ $this->assertEquals([], $user->getRoles(TRUE));
// Authenticated user.
- $user = $this->createUserSession(array(), TRUE);
- $this->assertEquals(array(RoleInterface::AUTHENTICATED_ID), $user->getRoles());
- $this->assertEquals(array(), $user->getRoles(TRUE));
+ $user = $this->createUserSession([], TRUE);
+ $this->assertEquals([RoleInterface::AUTHENTICATED_ID], $user->getRoles());
+ $this->assertEquals([], $user->getRoles(TRUE));
}
}
diff --git a/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php b/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php
index 69edf3b4d6a..805c96ec2c2 100644
--- a/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php
@@ -53,7 +53,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
if ($expected_violation) {
$context->expects($this->once())
->method('addViolation')
- ->with($constraint->message, array('%name' => $name));
+ ->with($constraint->message, ['%name' => $name]);
}
else {
$context->expects($this->never())
diff --git a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php
index cdbd30a5d70..11a970a0bf3 100644
--- a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php
@@ -25,7 +25,7 @@ class UserBulkFormTest extends UnitTestCase {
* Tests the constructor assignment of actions.
*/
public function testConstructor() {
- $actions = array();
+ $actions = [];
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
@@ -60,7 +60,7 @@ class UserBulkFormTest extends UnitTestCase {
$views_data->expects($this->any())
->method('get')
->with('users')
- ->will($this->returnValue(array('table' => array('entity type' => 'user'))));
+ ->will($this->returnValue(['table' => ['entity type' => 'user']]));
$container = new ContainerBuilder();
$container->set('views.views_data', $views_data);
$container->set('string_translation', $this->getStringTranslationStub());
@@ -82,9 +82,9 @@ class UserBulkFormTest extends UnitTestCase {
->getMock();
$definition['title'] = '';
- $options = array();
+ $options = [];
- $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', $definition, $entity_manager, $language_manager);
+ $user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_manager, $language_manager);
$user_bulk_form->init($executable, $display, $options);
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form);
diff --git a/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php
index 515c862a4f6..c038b71809a 100644
--- a/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php
+++ b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php
@@ -81,11 +81,11 @@ class PrivateTempStoreTest extends UnitTestCase {
$this->tempStore = new PrivateTempStore($this->keyValue, $this->lock, $this->currentUser, $this->requestStack, 604800);
- $this->ownObject = (object) array(
+ $this->ownObject = (object) [
'data' => 'test_data',
'owner' => $this->currentUser->id(),
'updated' => (int) $request->server->get('REQUEST_TIME'),
- );
+ ];
// Clone the object but change the owner.
$this->otherObject = clone $this->ownObject;
diff --git a/core/modules/user/tests/src/Unit/SharedTempStoreTest.php b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php
index 15a4ec6c24a..ba556a3aeae 100644
--- a/core/modules/user/tests/src/Unit/SharedTempStoreTest.php
+++ b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php
@@ -76,11 +76,11 @@ class SharedTempStoreTest extends UnitTestCase {
$this->tempStore = new SharedTempStore($this->keyValue, $this->lock, $this->owner, $this->requestStack, 604800);
- $this->ownObject = (object) array(
+ $this->ownObject = (object) [
'data' => 'test_data',
'owner' => $this->owner,
'updated' => (int) $request->server->get('REQUEST_TIME'),
- );
+ ];
// Clone the object but change the owner.
$this->otherObject = clone $this->ownObject;
diff --git a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
index 4657a5d5041..216e8d65221 100644
--- a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
+++ b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
@@ -80,10 +80,10 @@ class UserAccessControlHandlerTest extends UnitTestCase {
$this->owner
->expects($this->any())
->method('hasPermission')
- ->will($this->returnValueMap(array(
- array('administer users', FALSE),
- array('change own username', TRUE),
- )));
+ ->will($this->returnValueMap([
+ ['administer users', FALSE],
+ ['change own username', TRUE],
+ ]));
$this->owner
->expects($this->any())
@@ -102,7 +102,7 @@ class UserAccessControlHandlerTest extends UnitTestCase {
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$module_handler->expects($this->any())
->method('getImplementations')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->accessControlHandler->setModuleHandler($module_handler);
$this->items = $this->getMockBuilder('Drupal\Core\Field\FieldItemList')
@@ -128,7 +128,7 @@ class UserAccessControlHandlerTest extends UnitTestCase {
->method('getEntity')
->will($this->returnValue($this->{$target}));
- foreach (array('view' => $view, 'edit' => $edit) as $operation => $result) {
+ foreach (['view' => $view, 'edit' => $edit] as $operation => $result) {
$result_text = !isset($result) ? 'null' : ($result ? 'true' : 'false');
$message = "User '$field' field access returns '$result_text' with operation '$operation' for '$viewer' accessing '$target'";
$this->assertSame($result, $this->accessControlHandler->fieldAccess($operation, $field_definition, $this->{$viewer}, $this->items), $message);
@@ -148,41 +148,41 @@ class UserAccessControlHandlerTest extends UnitTestCase {
* Provides test data for testUserNameAccess().
*/
public function userNameProvider() {
- $name_access = array(
+ $name_access = [
// The viewer user is allowed to see user names on all accounts.
- array(
+ [
'viewer' => 'viewer',
'target' => 'viewer',
'view' => TRUE,
'edit' => FALSE,
- ),
- array(
+ ],
+ [
'viewer' => 'owner',
'target' => 'viewer',
'view' => TRUE,
'edit' => FALSE,
- ),
- array(
+ ],
+ [
'viewer' => 'viewer',
'target' => 'owner',
'view' => TRUE,
'edit' => FALSE,
- ),
+ ],
// The owner user is allowed to change its own user name.
- array(
+ [
'viewer' => 'owner',
'target' => 'owner',
'view' => TRUE,
'edit' => TRUE,
- ),
+ ],
// The users-administrator user has full access.
- array(
+ [
'viewer' => 'admin',
'target' => 'owner',
'view' => TRUE,
'edit' => TRUE,
- ),
- );
+ ],
+ ];
return $name_access;
}
@@ -199,24 +199,24 @@ class UserAccessControlHandlerTest extends UnitTestCase {
* Provides test data for testHiddenUserSettings().
*/
public function hiddenUserSettingsProvider() {
- $access_info = array();
+ $access_info = [];
- $fields = array(
+ $fields = [
'preferred_langcode',
'preferred_admin_langcode',
'timezone',
'mail',
- );
+ ];
foreach ($fields as $field) {
- $access_info[] = array(
+ $access_info[] = [
'field' => $field,
'viewer' => 'viewer',
'target' => 'viewer',
'view' => TRUE,
'edit' => TRUE,
- );
- $access_info[] = array(
+ ];
+ $access_info[] = [
'field' => $field,
'viewer' => 'viewer',
'target' => 'owner',
@@ -225,21 +225,21 @@ class UserAccessControlHandlerTest extends UnitTestCase {
// reality edit access will already be checked on entity level and the
// user without view access will typically not be able to edit.
'edit' => TRUE,
- );
- $access_info[] = array(
+ ];
+ $access_info[] = [
'field' => $field,
'viewer' => 'owner',
'target' => 'owner',
'view' => TRUE,
'edit' => TRUE,
- );
- $access_info[] = array(
+ ];
+ $access_info[] = [
'field' => $field,
'viewer' => 'admin',
'target' => 'owner',
'view' => TRUE,
'edit' => TRUE,
- );
+ ];
}
return $access_info;
@@ -258,38 +258,38 @@ class UserAccessControlHandlerTest extends UnitTestCase {
* Provides test data for testAdminFieldAccess().
*/
public function adminFieldAccessProvider() {
- $access_info = array();
+ $access_info = [];
- $fields = array(
+ $fields = [
'roles',
'status',
'access',
'login',
'init',
- );
+ ];
foreach ($fields as $field) {
- $access_info[] = array(
+ $access_info[] = [
'field' => $field,
'viewer' => 'viewer',
'target' => 'viewer',
'view' => FALSE,
'edit' => FALSE,
- );
- $access_info[] = array(
+ ];
+ $access_info[] = [
'field' => $field,
'viewer' => 'viewer',
'target' => 'owner',
'view' => FALSE,
'edit' => FALSE,
- );
- $access_info[] = array(
+ ];
+ $access_info[] = [
'field' => $field,
'viewer' => 'admin',
'target' => 'owner',
'view' => TRUE,
'edit' => TRUE,
- );
+ ];
}
return $access_info;
@@ -308,14 +308,14 @@ class UserAccessControlHandlerTest extends UnitTestCase {
* Provides test data for passwordAccessProvider().
*/
public function passwordAccessProvider() {
- $pass_access = array(
- array(
+ $pass_access = [
+ [
'viewer' => 'viewer',
'target' => 'viewer',
'view' => FALSE,
'edit' => TRUE,
- ),
- array(
+ ],
+ [
'viewer' => 'viewer',
'target' => 'owner',
'view' => FALSE,
@@ -323,20 +323,20 @@ class UserAccessControlHandlerTest extends UnitTestCase {
// reality edit access will already be checked on entity level and the
// user without view access will typically not be able to edit.
'edit' => TRUE,
- ),
- array(
+ ],
+ [
'viewer' => 'owner',
'target' => 'viewer',
'view' => FALSE,
'edit' => TRUE,
- ),
- array(
+ ],
+ [
'viewer' => 'admin',
'target' => 'owner',
'view' => FALSE,
'edit' => TRUE,
- ),
- );
+ ],
+ ];
return $pass_access;
}
@@ -353,26 +353,26 @@ class UserAccessControlHandlerTest extends UnitTestCase {
* Provides test data for testCreatedAccess().
*/
public function createdAccessProvider() {
- $created_access = array(
- array(
+ $created_access = [
+ [
'viewer' => 'viewer',
'target' => 'viewer',
'view' => TRUE,
'edit' => FALSE,
- ),
- array(
+ ],
+ [
'viewer' => 'owner',
'target' => 'viewer',
'view' => TRUE,
'edit' => FALSE,
- ),
- array(
+ ],
+ [
'viewer' => 'admin',
'target' => 'owner',
'view' => TRUE,
'edit' => TRUE,
- ),
- );
+ ],
+ ];
return $created_access;
}
@@ -392,26 +392,26 @@ class UserAccessControlHandlerTest extends UnitTestCase {
* Provides test data for testNonExistingFieldAccess().
*/
public function NonExistingFieldAccessProvider() {
- $created_access = array(
- array(
+ $created_access = [
+ [
'viewer' => 'viewer',
'target' => 'viewer',
'view' => TRUE,
'edit' => TRUE,
- ),
- array(
+ ],
+ [
'viewer' => 'owner',
'target' => 'viewer',
'view' => TRUE,
'edit' => TRUE,
- ),
- array(
+ ],
+ [
'viewer' => 'admin',
'target' => 'owner',
'view' => TRUE,
'edit' => TRUE,
- ),
- );
+ ],
+ ];
return $created_access;
}
diff --git a/core/modules/user/tests/src/Unit/UserAuthTest.php b/core/modules/user/tests/src/Unit/UserAuthTest.php
index 1b96d8f80dc..698c8b5fead 100644
--- a/core/modules/user/tests/src/Unit/UserAuthTest.php
+++ b/core/modules/user/tests/src/Unit/UserAuthTest.php
@@ -69,7 +69,7 @@ class UserAuthTest extends UnitTestCase {
$this->testUser = $this->getMockBuilder('Drupal\user\Entity\User')
->disableOriginalConstructor()
- ->setMethods(array('id', 'setPassword', 'save', 'getPassword'))
+ ->setMethods(['id', 'setPassword', 'save', 'getPassword'])
->getMock();
$this->userAuth = new UserAuth($entity_manager, $this->passwordService);
@@ -95,12 +95,12 @@ class UserAuthTest extends UnitTestCase {
* @return array
*/
public function providerTestAuthenticateWithMissingCredentials() {
- return array(
- array(NULL, NULL),
- array(NULL, ''),
- array('', NULL),
- array('', ''),
- );
+ return [
+ [NULL, NULL],
+ [NULL, ''],
+ ['', NULL],
+ ['', ''],
+ ];
}
/**
@@ -111,8 +111,8 @@ class UserAuthTest extends UnitTestCase {
public function testAuthenticateWithNoAccountReturned() {
$this->userStorage->expects($this->once())
->method('loadByProperties')
- ->with(array('name' => $this->username))
- ->will($this->returnValue(array()));
+ ->with(['name' => $this->username])
+ ->will($this->returnValue([]));
$this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
}
@@ -125,8 +125,8 @@ class UserAuthTest extends UnitTestCase {
public function testAuthenticateWithIncorrectPassword() {
$this->userStorage->expects($this->once())
->method('loadByProperties')
- ->with(array('name' => $this->username))
- ->will($this->returnValue(array($this->testUser)));
+ ->with(['name' => $this->username])
+ ->will($this->returnValue([$this->testUser]));
$this->passwordService->expects($this->once())
->method('check')
@@ -148,8 +148,8 @@ class UserAuthTest extends UnitTestCase {
$this->userStorage->expects($this->once())
->method('loadByProperties')
- ->with(array('name' => $this->username))
- ->will($this->returnValue(array($this->testUser)));
+ ->with(['name' => $this->username])
+ ->will($this->returnValue([$this->testUser]));
$this->passwordService->expects($this->once())
->method('check')
@@ -175,8 +175,8 @@ class UserAuthTest extends UnitTestCase {
$this->userStorage->expects($this->once())
->method('loadByProperties')
- ->with(array('name' => $this->username))
- ->will($this->returnValue(array($this->testUser)));
+ ->with(['name' => $this->username])
+ ->will($this->returnValue([$this->testUser]));
$this->passwordService->expects($this->once())
->method('check')
@@ -203,8 +203,8 @@ class UserAuthTest extends UnitTestCase {
$this->userStorage->expects($this->once())
->method('loadByProperties')
- ->with(array('name' => $this->username))
- ->will($this->returnValue(array($this->testUser)));
+ ->with(['name' => $this->username])
+ ->will($this->returnValue([$this->testUser]));
$this->passwordService->expects($this->once())
->method('check')
diff --git a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
index 8693fc4b375..b8f28884260 100644
--- a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
+++ b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
@@ -19,24 +19,24 @@ class RolesRidTest extends UnitTestCase {
* @covers ::titleQuery
*/
public function testTitleQuery() {
- $role1 = new Role(array(
+ $role1 = new Role([
'id' => 'test_rid_1',
'label' => 'test rid 1'
- ), 'user_role');
- $role2 = new Role(array(
+ ], 'user_role');
+ $role2 = new Role([
'id' => 'test_rid_2',
'label' => 'test <strong>rid 2</strong>',
- ), 'user_role');
+ ], 'user_role');
// Creates a stub entity storage;
$role_storage = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityStorageInterface');
$role_storage->expects($this->any())
->method('loadMultiple')
- ->will($this->returnValueMap(array(
- array(array(), array()),
- array(array('test_rid_1'), array('test_rid_1' => $role1)),
- array(array('test_rid_1', 'test_rid_2'), array('test_rid_1' => $role1, 'test_rid_2' => $role2)),
- )));
+ ->will($this->returnValueMap([
+ [[], []],
+ [['test_rid_1'], ['test_rid_1' => $role1]],
+ [['test_rid_1', 'test_rid_2'], ['test_rid_1' => $role1, 'test_rid_2' => $role2]],
+ ]));
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->any())
@@ -63,19 +63,19 @@ class RolesRidTest extends UnitTestCase {
$container->set('entity.manager', $entity_manager);
\Drupal::setContainer($container);
- $roles_rid_argument = new RolesRid(array(), 'user__roles_rid', array(), $entity_manager);
+ $roles_rid_argument = new RolesRid([], 'user__roles_rid', [], $entity_manager);
- $roles_rid_argument->value = array();
+ $roles_rid_argument->value = [];
$titles = $roles_rid_argument->titleQuery();
- $this->assertEquals(array(), $titles);
+ $this->assertEquals([], $titles);
- $roles_rid_argument->value = array('test_rid_1');
+ $roles_rid_argument->value = ['test_rid_1'];
$titles = $roles_rid_argument->titleQuery();
- $this->assertEquals(array('test rid 1'), $titles);
+ $this->assertEquals(['test rid 1'], $titles);
- $roles_rid_argument->value = array('test_rid_1', 'test_rid_2');
+ $roles_rid_argument->value = ['test_rid_1', 'test_rid_2'];
$titles = $roles_rid_argument->titleQuery();
- $this->assertEquals(array('test rid 1', 'test <strong>rid 2</strong>'), $titles);
+ $this->assertEquals(['test rid 1', 'test <strong>rid 2</strong>'], $titles);
}
}
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 2f40eb90b46..364dd1ac634 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -44,7 +44,7 @@ function hook_user_cancel($edit, $account, $method) {
$nodes = \Drupal::entityQuery('node')
->condition('uid', $account->id())
->execute();
- node_mass_update($nodes, array('status' => 0), NULL, TRUE);
+ node_mass_update($nodes, ['status' => 0], NULL, TRUE);
break;
case 'user_cancel_reassign':
@@ -53,10 +53,10 @@ function hook_user_cancel($edit, $account, $method) {
$nodes = \Drupal::entityQuery('node')
->condition('uid', $account->id())
->execute();
- node_mass_update($nodes, array('uid' => 0), NULL, TRUE);
+ node_mass_update($nodes, ['uid' => 0], NULL, TRUE);
// Anonymize old revisions.
db_update('node_field_revision')
- ->fields(array('uid' => 0))
+ ->fields(['uid' => 0])
->condition('uid', $account->id())
->execute();
break;
@@ -94,12 +94,12 @@ function hook_user_cancel_methods_alter(&$methods) {
unset($methods['user_cancel_reassign']);
// Add a custom zero-out method.
- $methods['mymodule_zero_out'] = array(
+ $methods['mymodule_zero_out'] = [
'title' => t('Delete the account and remove all content.'),
'description' => t('All your content will be replaced by empty strings.'),
// access should be used for administrative methods only.
'access' => $account->hasPermission('access zero-out account cancellation method'),
- );
+ ];
}
/**
@@ -123,7 +123,7 @@ function hook_user_cancel_methods_alter(&$methods) {
function hook_user_format_name_alter(&$name, $account) {
// Display the user's uid instead of name.
if ($account->id()) {
- $name = t('User @uid', array('@uid' => $account->id()));
+ $name = t('User @uid', ['@uid' => $account->id()]);
}
}
@@ -137,7 +137,7 @@ function hook_user_login($account) {
$config = \Drupal::config('system.date');
// If the user has a NULL time zone, notify them to set a time zone.
if (!$account->getTimezone() && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
- drupal_set_message(t('Configure your <a href=":user-edit">account time zone setting</a>.', array(':user-edit' => $account->url('edit-form', array('query' => \Drupal::destination()->getAsArray(), 'fragment' => 'edit-timezone')))));
+ drupal_set_message(t('Configure your <a href=":user-edit">account time zone setting</a>.', [':user-edit' => $account->url('edit-form', ['query' => \Drupal::destination()->getAsArray(), 'fragment' => 'edit-timezone'])]));
}
}
@@ -149,10 +149,10 @@ function hook_user_login($account) {
*/
function hook_user_logout($account) {
db_insert('logouts')
- ->fields(array(
+ ->fields([
'uid' => $account->id(),
'time' => time(),
- ))
+ ])
->execute();
}
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index 7cc46ef6aa6..330ad149b58 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -9,53 +9,53 @@
* Implements hook_schema().
*/
function user_schema() {
- $schema['users_data'] = array(
+ $schema['users_data'] = [
'description' => 'Stores module data as key/value pairs per user.',
- 'fields' => array(
- 'uid' => array(
+ 'fields' => [
+ 'uid' => [
'description' => 'Primary key: {users}.uid for user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'module' => array(
+ ],
+ 'module' => [
'description' => 'The name of the module declaring the variable.',
'type' => 'varchar_ascii',
'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
'not null' => TRUE,
'default' => '',
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => 'The identifier of the data.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
- ),
- 'value' => array(
+ ],
+ 'value' => [
'description' => 'The value.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
- ),
- 'serialized' => array(
+ ],
+ 'serialized' => [
'description' => 'Whether value is serialized.',
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('uid', 'module', 'name'),
- 'indexes' => array(
- 'module' => array('module'),
- 'name' => array('name'),
- ),
- 'foreign keys' => array(
- 'uid' => array('users' => 'uid'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['uid', 'module', 'name'],
+ 'indexes' => [
+ 'module' => ['module'],
+ 'name' => ['name'],
+ ],
+ 'foreign keys' => [
+ 'uid' => ['users' => 'uid'],
+ ],
+ ];
return $schema;
}
@@ -67,22 +67,22 @@ function user_install() {
$storage = \Drupal::entityManager()->getStorage('user');
// Insert a row for the anonymous user.
$storage
- ->create(array(
+ ->create([
'uid' => 0,
'status' => 0,
'name' => '',
- ))
+ ])
->save();
// We need some placeholders here as name and mail are unique.
// This will be changed by the settings form in the installer.
$storage
- ->create(array(
+ ->create([
'uid' => 1,
'name' => 'placeholder-for-uid-1',
'mail' => 'placeholder-for-uid-1',
'status' => TRUE,
- ))
+ ])
->save();
}
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 638ed649e5f..b865e958d9e 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -68,19 +68,19 @@ function user_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.user':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The User module allows users to register, log in, and log out. It also allows users with proper permissions to manage user roles and permissions. For more information, see the <a href=":user_docs">online documentation for the User module</a>.', array(':user_docs' => 'https://www.drupal.org/documentation/modules/user')) . '</p>';
+ $output .= '<p>' . t('The User module allows users to register, log in, and log out. It also allows users with proper permissions to manage user roles and permissions. For more information, see the <a href=":user_docs">online documentation for the User module</a>.', [':user_docs' => 'https://www.drupal.org/documentation/modules/user']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating and managing users') . '</dt>';
- $output .= '<dd>' . t('Through the <a href=":people">People administration page</a> you can add and cancel user accounts and assign users to roles. By editing one particular user you can change their username, email address, password, and information in other fields.', array(':people' => \Drupal::url('entity.user.collection'))) . '</dd>';
+ $output .= '<dd>' . t('Through the <a href=":people">People administration page</a> you can add and cancel user accounts and assign users to roles. By editing one particular user you can change their username, email address, password, and information in other fields.', [':people' => \Drupal::url('entity.user.collection')]) . '</dd>';
$output .= '<dt>' . t('Configuring user roles') . '</dt>';
- $output .= '<dd>' . t('<em>Roles</em> are used to group and classify users; each user can be assigned one or more roles. Typically there are two pre-defined roles: <em>Anonymous user</em> (users that are not logged in), and <em>Authenticated user</em> (users that are registered and logged in). Depending on how your site was set up, an <em>Administrator</em> role may also be available: users with this role will automatically be assigned any new permissions whenever a module is enabled. You can create additional roles on the <a href=":roles">Roles administration page</a>.', array(':roles' => \Drupal::url('entity.user_role.collection'))) . '</dd>';
+ $output .= '<dd>' . t('<em>Roles</em> are used to group and classify users; each user can be assigned one or more roles. Typically there are two pre-defined roles: <em>Anonymous user</em> (users that are not logged in), and <em>Authenticated user</em> (users that are registered and logged in). Depending on how your site was set up, an <em>Administrator</em> role may also be available: users with this role will automatically be assigned any new permissions whenever a module is enabled. You can create additional roles on the <a href=":roles">Roles administration page</a>.', [':roles' => \Drupal::url('entity.user_role.collection')]) . '</dd>';
$output .= '<dt>' . t('Setting permissions') . '</dt>';
- $output .= '<dd>' . t('After creating roles, you can set permissions for each role on the <a href=":permissions_user">Permissions page</a>. Granting a permission allows users who have been assigned a particular role to perform an action on the site, such as viewing content, editing or creating a particular type of content, administering settings for a particular module, or using a particular function of the site (such as search).', array(':permissions_user' => \Drupal::url('user.admin_permissions'))) . '</dd>';
+ $output .= '<dd>' . t('After creating roles, you can set permissions for each role on the <a href=":permissions_user">Permissions page</a>. Granting a permission allows users who have been assigned a particular role to perform an action on the site, such as viewing content, editing or creating a particular type of content, administering settings for a particular module, or using a particular function of the site (such as search).', [':permissions_user' => \Drupal::url('user.admin_permissions')]) . '</dd>';
$output .= '<dt>' . t('Managing account settings') . '</dt>';
- $output .= '<dd>' . t('The <a href=":accounts">Account settings page</a> allows you to manage settings for the displayed name of the Anonymous user role, personal contact forms, user registration settings, and account cancellation settings. On this page you can also manage settings for account personalization, and adapt the text for the email messages that users receive when they register or request a password recovery. You may also set which role is automatically assigned new permissions whenever a module is enabled (the Administrator role).', array(':accounts' => \Drupal::url('entity.user.admin_form'))) . '</dd>';
+ $output .= '<dd>' . t('The <a href=":accounts">Account settings page</a> allows you to manage settings for the displayed name of the Anonymous user role, personal contact forms, user registration settings, and account cancellation settings. On this page you can also manage settings for account personalization, and adapt the text for the email messages that users receive when they register or request a password recovery. You may also set which role is automatically assigned new permissions whenever a module is enabled (the Administrator role).', [':accounts' => \Drupal::url('entity.user.admin_form')]) . '</dd>';
$output .= '<dt>' . t('Managing user account fields') . '</dt>';
- $output .= '<dd>' . t('Because User accounts are an entity type, you can extend them by adding fields through the Manage fields tab on the <a href=":accounts">Account settings page</a>. By adding fields for e.g., a picture, a biography, or address, you can a create a custom profile for the users of the website. For background information on entities and fields, see the <a href=":field_help">Field module help page</a>.', array(':field_help' => (\Drupal::moduleHandler()->moduleExists('field')) ? \Drupal::url('help.page', array('name' => 'field')) : '#', ':accounts' => \Drupal::url('entity.user.admin_form'))) . '</dd>';
+ $output .= '<dd>' . t('Because User accounts are an entity type, you can extend them by adding fields through the Manage fields tab on the <a href=":accounts">Account settings page</a>. By adding fields for e.g., a picture, a biography, or address, you can a create a custom profile for the users of the website. For background information on entities and fields, see the <a href=":field_help">Field module help page</a>.', [':field_help' => (\Drupal::moduleHandler()->moduleExists('field')) ? \Drupal::url('help.page', ['name' => 'field']) : '#', ':accounts' => \Drupal::url('entity.user.admin_form')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -88,10 +88,10 @@ function user_help($route_name, RouteMatchInterface $route_match) {
return '<p>' . t("This web page allows administrators to register new users. Users' email addresses and usernames must be unique.") . '</p>';
case 'user.admin_permissions':
- return '<p>' . t('Permissions let you control what users can do and see on your site. You can define a specific set of permissions for each role. (See the <a href=":role">Roles</a> page to create a role.) Any permissions granted to the Authenticated user role will be given to any user who is logged in to your site. From the <a href=":settings">Account settings</a> page, you can make any role into an Administrator role for the site, meaning that role will be granted all new permissions automatically. You should be careful to ensure that only trusted users are given this access and level of control of your site.', array(':role' => \Drupal::url('entity.user_role.collection'), ':settings' => \Drupal::url('entity.user.admin_form'))) . '</p>';
+ return '<p>' . t('Permissions let you control what users can do and see on your site. You can define a specific set of permissions for each role. (See the <a href=":role">Roles</a> page to create a role.) Any permissions granted to the Authenticated user role will be given to any user who is logged in to your site. From the <a href=":settings">Account settings</a> page, you can make any role into an Administrator role for the site, meaning that role will be granted all new permissions automatically. You should be careful to ensure that only trusted users are given this access and level of control of your site.', [':role' => \Drupal::url('entity.user_role.collection'), ':settings' => \Drupal::url('entity.user.admin_form')]) . '</p>';
case 'entity.user_role.collection':
- return '<p>' . t('A role defines a group of users that have certain privileges. These privileges are defined on the <a href=":permissions">Permissions page</a>. Here, you can define the names and the display sort order of the roles on your site. It is recommended to order roles from least permissive (for example, Anonymous user) to most permissive (for example, Administrator user). Users who are not logged in have the Anonymous user role. Users who are logged in have the Authenticated user role, plus any other roles granted to their user account.', array(':permissions' => \Drupal::url('user.admin_permissions'))) . '</p>';
+ return '<p>' . t('A role defines a group of users that have certain privileges. These privileges are defined on the <a href=":permissions">Permissions page</a>. Here, you can define the names and the display sort order of the roles on your site. It is recommended to order roles from least permissive (for example, Anonymous user) to most permissive (for example, Administrator user). Users who are not logged in have the Anonymous user role. Users who are logged in have the Authenticated user role, plus any other roles granted to their user account.', [':permissions' => \Drupal::url('user.admin_permissions')]) . '</p>';
case 'entity.user.field_ui_fields':
return '<p>' . t('This form lets administrators add and edit fields for storing user data.') . '</p>';
@@ -108,14 +108,14 @@ function user_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function user_theme() {
- return array(
- 'user' => array(
+ return [
+ 'user' => [
'render element' => 'elements',
- ),
- 'username' => array(
- 'variables' => array('account' => NULL, 'attributes' => array(), 'link_options' => array()),
- ),
- );
+ ],
+ 'username' => [
+ 'variables' => ['account' => NULL, 'attributes' => [], 'link_options' => []],
+ ],
+ ];
}
/**
@@ -149,29 +149,29 @@ function user_picture_enabled() {
* Implements hook_entity_extra_field_info().
*/
function user_entity_extra_field_info() {
- $fields['user']['user']['form']['account'] = array(
+ $fields['user']['user']['form']['account'] = [
'label' => t('User name and password'),
'description' => t('User module account form elements.'),
'weight' => -10,
- );
- $fields['user']['user']['form']['language'] = array(
+ ];
+ $fields['user']['user']['form']['language'] = [
'label' => t('Language settings'),
'description' => t('User module form element.'),
'weight' => 0,
- );
+ ];
if (\Drupal::config('system.date')->get('timezone.user.configurable')) {
- $fields['user']['user']['form']['timezone'] = array(
+ $fields['user']['user']['form']['timezone'] = [
'label' => t('Timezone'),
'description' => t('System module form element.'),
'weight' => 6,
- );
+ ];
}
- $fields['user']['user']['display']['member_for'] = array(
+ $fields['user']['user']['display']['member_for'] = [
'label' => t('Member for'),
'description' => t('User module \'member for\' view element.'),
'weight' => 5,
- );
+ ];
return $fields;
}
@@ -228,7 +228,7 @@ function user_load_multiple(array $uids = NULL, $reset = FALSE) {
*/
function user_load($uid, $reset = FALSE) {
if ($reset) {
- \Drupal::entityManager()->getStorage('user')->resetCache(array($uid));
+ \Drupal::entityManager()->getStorage('user')->resetCache([$uid]);
}
return User::load($uid);
}
@@ -279,7 +279,7 @@ function user_load_by_name($name) {
*/
function user_validate_name($name) {
$definition = BaseFieldDefinition::create('string')
- ->addConstraint('UserName', array());
+ ->addConstraint('UserName', []);
$data = \Drupal::typedDataManager()->create($definition);
$data->setValue($name);
$violations = $data->validate();
@@ -334,9 +334,9 @@ function user_role_permissions(array $roles) {
return _user_role_permissions_update($roles);
}
$entities = Role::loadMultiple($roles);
- $role_permissions = array();
+ $role_permissions = [];
foreach ($roles as $rid) {
- $role_permissions[$rid] = isset($entities[$rid]) ? $entities[$rid]->getPermissions() : array();
+ $role_permissions[$rid] = isset($entities[$rid]) ? $entities[$rid]->getPermissions() : [];
}
return $role_permissions;
}
@@ -356,9 +356,9 @@ function user_role_permissions(array $roles) {
* for the given role.
*/
function _user_role_permissions_update($roles) {
- $role_permissions = array();
+ $role_permissions = [];
foreach ($roles as $rid) {
- $role_permissions[$rid] = \Drupal::config("user.role.$rid")->get('permissions') ?: array();
+ $role_permissions[$rid] = \Drupal::config("user.role.$rid")->get('permissions') ?: [];
}
return $role_permissions;
}
@@ -384,10 +384,10 @@ function user_is_blocked($name) {
*/
function user_user_view(array &$build, UserInterface $account, EntityViewDisplayInterface $display) {
if ($display->getComponent('member_for')) {
- $build['member_for'] = array(
+ $build['member_for'] = [
'#type' => 'item',
'#markup' => '<h4 class="label">' . t('Member for') . '</h4> ' . \Drupal::service('date.formatter')->formatTimeDiffSince($account->getCreatedTime()),
- );
+ ];
}
}
@@ -519,9 +519,9 @@ function template_preprocess_username(&$variables) {
->toString();
}
else {
- $variables['attributes']['href'] = Url::fromRoute('entity.user.canonical', array(
+ $variables['attributes']['href'] = Url::fromRoute('entity.user.canonical', [
'user' => $variables['uid'],
- ))->toString();
+ ])->toString();
}
}
}
@@ -542,7 +542,7 @@ function template_preprocess_username(&$variables) {
*/
function user_login_finalize(UserInterface $account) {
\Drupal::currentUser()->setAccount($account);
- \Drupal::logger('user')->notice('Session opened for %name.', array('%name' => $account->getUsername()));
+ \Drupal::logger('user')->notice('Session opened for %name.', ['%name' => $account->getUsername()]);
// Update the user table timestamp noting user has logged in.
// This is also used to invalidate one-time login links.
$account->setLastLoginTime(REQUEST_TIME);
@@ -556,7 +556,7 @@ function user_login_finalize(UserInterface $account) {
// in place.
\Drupal::service('session')->migrate();
\Drupal::service('session')->set('uid', $account->id());
- \Drupal::moduleHandler()->invokeAll('user_login', array($account));
+ \Drupal::moduleHandler()->invokeAll('user_login', [$account]);
}
/**
@@ -591,19 +591,19 @@ function user_user_logout($account) {
* A unique URL that provides a one-time log in for the user, from which
* they can change their password.
*/
-function user_pass_reset_url($account, $options = array()) {
+function user_pass_reset_url($account, $options = []) {
$timestamp = REQUEST_TIME;
$langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
return \Drupal::url('user.reset',
- array(
+ [
'uid' => $account->id(),
'timestamp' => $timestamp,
'hash' => user_pass_rehash($account, $timestamp),
- ),
- array(
+ ],
+ [
'absolute' => TRUE,
'language' => \Drupal::languageManager()->getLanguage($langcode)
- )
+ ]
);
}
@@ -624,10 +624,10 @@ function user_pass_reset_url($account, $options = array()) {
* @see user_mail_tokens()
* @see \Drupal\user\Controller\UserController::confirmCancel()
*/
-function user_cancel_url(UserInterface $account, $options = array()) {
+function user_cancel_url(UserInterface $account, $options = []) {
$timestamp = REQUEST_TIME;
$langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
- $url_options = array('absolute' => TRUE, 'language' => \Drupal::languageManager()->getLanguage($langcode));
+ $url_options = ['absolute' => TRUE, 'language' => \Drupal::languageManager()->getLanguage($langcode)];
return \Drupal::url('user.cancel_confirm', [
'user' => $account->id(),
'timestamp' => $timestamp,
@@ -683,16 +683,16 @@ function user_cancel($edit, $uid, $method) {
$account = User::load($uid);
if (!$account) {
- drupal_set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error');
- \Drupal::logger('user')->error('Attempted to cancel non-existing user account: %id.', array('%id' => $uid));
+ drupal_set_message(t('The user account %id does not exist.', ['%id' => $uid]), 'error');
+ \Drupal::logger('user')->error('Attempted to cancel non-existing user account: %id.', ['%id' => $uid]);
return;
}
// Initialize batch (to set title).
- $batch = array(
+ $batch = [
'title' => t('Cancelling account'),
- 'operations' => array(),
- );
+ 'operations' => [],
+ ];
batch_set($batch);
// When the 'user_cancel_delete' method is used, user_delete() is called,
@@ -701,16 +701,16 @@ function user_cancel($edit, $uid, $method) {
// account deletion.
if ($method != 'user_cancel_delete') {
// Allow modules to add further sets to this batch.
- \Drupal::moduleHandler()->invokeAll('user_cancel', array($edit, $account, $method));
+ \Drupal::moduleHandler()->invokeAll('user_cancel', [$edit, $account, $method]);
}
// Finish the batch and actually cancel the account.
- $batch = array(
+ $batch = [
'title' => t('Cancelling user account'),
- 'operations' => array(
- array('_user_cancel', array($edit, $account, $method)),
- ),
- );
+ 'operations' => [
+ ['_user_cancel', [$edit, $account, $method]],
+ ],
+ ];
// After cancelling account, ensure that user is logged out.
if ($account->id() == \Drupal::currentUser()->id()) {
@@ -754,8 +754,8 @@ function _user_cancel($edit, $account, $method) {
}
$account->block();
$account->save();
- drupal_set_message(t('%name has been disabled.', array('%name' => $account->getDisplayName())));
- $logger->notice('Blocked user: %name %email.', array('%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>'));
+ drupal_set_message(t('%name has been disabled.', ['%name' => $account->getDisplayName()]));
+ $logger->notice('Blocked user: %name %email.', ['%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>']);
break;
case 'user_cancel_reassign':
@@ -765,8 +765,8 @@ function _user_cancel($edit, $account, $method) {
_user_mail_notify('status_canceled', $account);
}
$account->delete();
- drupal_set_message(t('%name has been deleted.', array('%name' => $account->getDisplayName())));
- $logger->notice('Deleted user: %name %email.', array('%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>'));
+ drupal_set_message(t('%name has been deleted.', ['%name' => $account->getDisplayName()]));
+ $logger->notice('Deleted user: %name %email.', ['%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>']);
break;
}
@@ -806,33 +806,33 @@ function _user_cancel_session_regenerate() {
function user_cancel_methods() {
$user_settings = \Drupal::config('user.settings');
$anonymous_name = $user_settings->get('anonymous');
- $methods = array(
- 'user_cancel_block' => array(
+ $methods = [
+ 'user_cancel_block' => [
'title' => t('Disable the account and keep its content.'),
'description' => t('Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your username.'),
- ),
- 'user_cancel_block_unpublish' => array(
+ ],
+ 'user_cancel_block_unpublish' => [
'title' => t('Disable the account and unpublish its content.'),
'description' => t('Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.'),
- ),
- 'user_cancel_reassign' => array(
- 'title' => t('Delete the account and make its content belong to the %anonymous-name user.', array('%anonymous-name' => $anonymous_name)),
- 'description' => t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => $anonymous_name)),
- ),
- 'user_cancel_delete' => array(
+ ],
+ 'user_cancel_reassign' => [
+ 'title' => t('Delete the account and make its content belong to the %anonymous-name user.', ['%anonymous-name' => $anonymous_name]),
+ 'description' => t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $anonymous_name]),
+ ],
+ 'user_cancel_delete' => [
'title' => t('Delete the account and its content.'),
'description' => t('Your account will be removed and all account information deleted. All of your content will also be deleted.'),
'access' => \Drupal::currentUser()->hasPermission('administer users'),
- ),
- );
+ ],
+ ];
// Allow modules to customize account cancellation methods.
\Drupal::moduleHandler()->alter('user_cancel_methods', $methods);
// Turn all methods into real form elements.
- $form = array(
- '#options' => array(),
+ $form = [
+ '#options' => [],
'#default_value' => $user_settings->get('cancel_method'),
- );
+ ];
foreach ($methods as $name => $method) {
$form['#options'][$name] = $method['title'];
// Add the description for the confirmation form. This description is never
@@ -855,7 +855,7 @@ function user_cancel_methods() {
* A user ID.
*/
function user_delete($uid) {
- user_delete_multiple(array($uid));
+ user_delete_multiple([$uid]);
}
/**
@@ -924,7 +924,7 @@ function user_mail($key, &$message, $params) {
$token_service = \Drupal::token();
$language_manager = \Drupal::languageManager();
$langcode = $message['langcode'];
- $variables = array('user' => $params['account']);
+ $variables = ['user' => $params['account']];
$language = $language_manager->getLanguage($params['account']->getPreferredLangcode());
$original_language = $language_manager->getConfigOverrideLanguage();
@@ -994,34 +994,34 @@ function user_role_names($membersonly = FALSE, $permission = NULL) {
*/
function user_user_role_insert(RoleInterface $role) {
// Ignore the authenticated and anonymous roles or the role is being synced.
- if (in_array($role->id(), array(RoleInterface::AUTHENTICATED_ID, RoleInterface::ANONYMOUS_ID)) || $role->isSyncing()) {
+ if (in_array($role->id(), [RoleInterface::AUTHENTICATED_ID, RoleInterface::ANONYMOUS_ID]) || $role->isSyncing()) {
return;
}
$add_id = 'user_add_role_action.' . $role->id();
if (!Action::load($add_id)) {
- $action = Action::create(array(
+ $action = Action::create([
'id' => $add_id,
'type' => 'user',
- 'label' => t('Add the @label role to the selected users', array('@label' => $role->label())),
- 'configuration' => array(
+ 'label' => t('Add the @label role to the selected users', ['@label' => $role->label()]),
+ 'configuration' => [
'rid' => $role->id(),
- ),
+ ],
'plugin' => 'user_add_role_action',
- ));
+ ]);
$action->trustData()->save();
}
$remove_id = 'user_remove_role_action.' . $role->id();
if (!Action::load($remove_id)) {
- $action = Action::create(array(
+ $action = Action::create([
'id' => $remove_id,
'type' => 'user',
- 'label' => t('Remove the @label role from the selected users', array('@label' => $role->label())),
- 'configuration' => array(
+ 'label' => t('Remove the @label role from the selected users', ['@label' => $role->label()]),
+ 'configuration' => [
'rid' => $role->id(),
- ),
+ ],
'plugin' => 'user_remove_role_action',
- ));
+ ]);
$action->trustData()->save();
}
}
@@ -1032,10 +1032,10 @@ function user_user_role_insert(RoleInterface $role) {
function user_user_role_delete(RoleInterface $role) {
// Delete role references for all users.
$user_storage = \Drupal::entityManager()->getStorage('user');
- $user_storage->deleteRoleReferences(array($role->id()));
+ $user_storage->deleteRoleReferences([$role->id()]);
// Ignore the authenticated and anonymous roles or the role is being synced.
- if (in_array($role->id(), array(RoleInterface::AUTHENTICATED_ID, RoleInterface::ANONYMOUS_ID)) || $role->isSyncing()) {
+ if (in_array($role->id(), [RoleInterface::AUTHENTICATED_ID, RoleInterface::ANONYMOUS_ID]) || $role->isSyncing()) {
return;
}
@@ -1125,7 +1125,7 @@ function user_role_load($rid) {
* @see user_role_grant_permissions()
* @see user_role_revoke_permissions()
*/
-function user_role_change_permissions($rid, array $permissions = array()) {
+function user_role_change_permissions($rid, array $permissions = []) {
// Grant new permissions for the role.
$grant = array_filter($permissions);
if (!empty($grant)) {
@@ -1149,7 +1149,7 @@ function user_role_change_permissions($rid, array $permissions = array()) {
* @see user_role_change_permissions()
* @see user_role_revoke_permissions()
*/
-function user_role_grant_permissions($rid, array $permissions = array()) {
+function user_role_grant_permissions($rid, array $permissions = []) {
// Grant new permissions for the role.
if ($role = Role::load($rid)) {
foreach ($permissions as $permission) {
@@ -1170,7 +1170,7 @@ function user_role_grant_permissions($rid, array $permissions = array()) {
* @see user_role_change_permissions()
* @see user_role_grant_permissions()
*/
-function user_role_revoke_permissions($rid, array $permissions = array()) {
+function user_role_revoke_permissions($rid, array $permissions = []) {
// Revoke permissions for the role.
$role = Role::load($rid);
foreach ($permissions as $permission) {
@@ -1251,16 +1251,16 @@ function user_element_info_alter(array &$types) {
* validation.
*/
function user_form_process_password_confirm($element) {
- $password_settings = array(
+ $password_settings = [
'confirmTitle' => t('Passwords match:'),
'confirmSuccess' => t('yes'),
'confirmFailure' => t('no'),
'showStrengthIndicator' => FALSE,
- );
+ ];
if (\Drupal::config('user.settings')->get('password_strength')) {
$password_settings['showStrengthIndicator'] = TRUE;
- $password_settings += array(
+ $password_settings += [
'strengthTitle' => t('Password strength:'),
'hasWeaknesses' => t('Recommendations to make your password stronger:'),
'tooShort' => t('Make it at least 12 characters'),
@@ -1274,7 +1274,7 @@ function user_form_process_password_confirm($element) {
'good' => t('Good'),
'strong' => t('Strong'),
'username' => \Drupal::currentUser()->getUsername(),
- );
+ ];
}
$element['#attached']['library'][] = 'user/drupal.user';
@@ -1323,77 +1323,77 @@ function user_toolbar() {
// Add logout & user account links or login link.
$links_cache_contexts = [];
if ($user->isAuthenticated()) {
- $links = array(
- 'account' => array(
+ $links = [
+ 'account' => [
'title' => t('View profile'),
'url' => Url::fromRoute('user.page'),
- 'attributes' => array(
+ 'attributes' => [
'title' => t('User account'),
- ),
- ),
- 'account_edit' => array(
+ ],
+ ],
+ 'account_edit' => [
'title' => t('Edit profile'),
'url' => Url::fromRoute('entity.user.edit_form', ['user' => $user->id()]),
- 'attributes' => array(
+ 'attributes' => [
'title' => t('Edit user account'),
- ),
- ),
- 'logout' => array(
+ ],
+ ],
+ 'logout' => [
'title' => t('Log out'),
'url' => Url::fromRoute('user.logout'),
- ),
- );
+ ],
+ ];
// The "Edit user account" link is per-user.
$links_cache_contexts[] = 'user';
}
else {
- $links = array(
- 'login' => array(
+ $links = [
+ 'login' => [
'title' => t('Log in'),
'url' => Url::fromRoute('user.page'),
- ),
- );
+ ],
+ ];
}
- $items['user'] = array(
+ $items['user'] = [
'#type' => 'toolbar_item',
- 'tab' => array(
+ 'tab' => [
'#type' => 'link',
'#title' => $user->getDisplayName(),
'#url' => Url::fromRoute('user.page'),
- '#attributes' => array(
+ '#attributes' => [
'title' => t('My account'),
- 'class' => array('toolbar-icon', 'toolbar-icon-user'),
- ),
+ 'class' => ['toolbar-icon', 'toolbar-icon-user'],
+ ],
'#cache' => [
'contexts' => [
// Cacheable per user, because the current user's name is shown.
'user',
],
],
- ),
- 'tray' => array(
+ ],
+ 'tray' => [
'#heading' => t('User account actions'),
- 'user_links' => array(
+ 'user_links' => [
'#cache' => [
// Cacheable per "authenticated or not", because the links to
// display depend on that.
- 'contexts' => Cache::mergeContexts(array('user.roles:authenticated'), $links_cache_contexts),
+ 'contexts' => Cache::mergeContexts(['user.roles:authenticated'], $links_cache_contexts),
],
'#theme' => 'links__toolbar_user',
'#links' => $links,
- '#attributes' => array(
- 'class' => array('toolbar-menu'),
- ),
- ),
- ),
+ '#attributes' => [
+ 'class' => ['toolbar-menu'],
+ ],
+ ],
+ ],
'#weight' => 100,
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'user/drupal.user.icons',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $items;
}
@@ -1404,9 +1404,9 @@ function user_toolbar() {
function user_logout() {
$user = \Drupal::currentUser();
- \Drupal::logger('user')->notice('Session closed for %name.', array('%name' => $user->getAccountName()));
+ \Drupal::logger('user')->notice('Session closed for %name.', ['%name' => $user->getAccountName()]);
- \Drupal::moduleHandler()->invokeAll('user_logout', array($user));
+ \Drupal::moduleHandler()->invokeAll('user_logout', [$user]);
// Destroy the current session, and reset $user to the anonymous user.
// Note: In Symfony the session is intended to be destroyed with
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index 7f456f66141..8c02f6e6cbb 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -13,61 +13,61 @@ use Drupal\user\Entity\User;
* Implements hook_token_info().
*/
function user_token_info() {
- $types['user'] = array(
+ $types['user'] = [
'name' => t('Users'),
'description' => t('Tokens related to individual user accounts.'),
'needs-data' => 'user',
- );
- $types['current-user'] = array(
+ ];
+ $types['current-user'] = [
'name' => t('Current user'),
'description' => t('Tokens related to the currently logged in user.'),
'type' => 'user',
- );
+ ];
- $user['uid'] = array(
+ $user['uid'] = [
'name' => t('User ID'),
'description' => t("The unique ID of the user account."),
- );
- $user['name'] = array(
+ ];
+ $user['name'] = [
'name' => t("Deprecated: User Name"),
'description' => t("Deprecated: Use account-name or display-name instead."),
- );
- $user['account-name'] = array(
+ ];
+ $user['account-name'] = [
'name' => t("Account Name"),
'description' => t("The login name of the user account."),
- );
- $user['display-name'] = array(
+ ];
+ $user['display-name'] = [
'name' => t("Display Name"),
'description' => t("The display name of the user account."),
- );
- $user['mail'] = array(
+ ];
+ $user['mail'] = [
'name' => t("Email"),
'description' => t("The email address of the user account."),
- );
- $user['url'] = array(
+ ];
+ $user['url'] = [
'name' => t("URL"),
'description' => t("The URL of the account profile page."),
- );
- $user['edit-url'] = array(
+ ];
+ $user['edit-url'] = [
'name' => t("Edit URL"),
'description' => t("The URL of the account edit page."),
- );
+ ];
- $user['last-login'] = array(
+ $user['last-login'] = [
'name' => t("Last login"),
'description' => t("The date the user last logged in to the site."),
'type' => 'date',
- );
- $user['created'] = array(
+ ];
+ $user['created'] = [
'name' => t("Created"),
'description' => t("The date the user account was created."),
'type' => 'date',
- );
+ ];
- return array(
+ return [
'types' => $types,
- 'tokens' => array('user' => $user),
- );
+ 'tokens' => ['user' => $user],
+ ];
}
/**
@@ -76,7 +76,7 @@ function user_token_info() {
function user_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@@ -84,7 +84,7 @@ function user_tokens($type, $tokens, array $data, array $options, BubbleableMeta
else {
$langcode = NULL;
}
- $replacements = array();
+ $replacements = [];
if ($type == 'user' && !empty($data['user'])) {
/** @var \Drupal\user\UserInterface $account */
@@ -142,18 +142,18 @@ function user_tokens($type, $tokens, array $data, array $options, BubbleableMeta
}
if ($login_tokens = $token_service->findWithPrefix($tokens, 'last-login')) {
- $replacements += $token_service->generate('date', $login_tokens, array('date' => $account->getLastLoginTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $login_tokens, ['date' => $account->getLastLoginTime()], $options, $bubbleable_metadata);
}
if ($registered_tokens = $token_service->findWithPrefix($tokens, 'created')) {
- $replacements += $token_service->generate('date', $registered_tokens, array('date' => $account->getCreatedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $registered_tokens, ['date' => $account->getCreatedTime()], $options, $bubbleable_metadata);
}
}
if ($type == 'current-user') {
$account = User::load(\Drupal::currentUser()->id());
$bubbleable_metadata->addCacheContexts(['user']);
- $replacements += $token_service->generate('user', $tokens, array('user' => $account), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('user', $tokens, ['user' => $account], $options, $bubbleable_metadata);
}
return $replacements;
diff --git a/core/modules/user/user.views_execution.inc b/core/modules/user/user.views_execution.inc
index c9a3f1dbc97..255fbf26838 100644
--- a/core/modules/user/user.views_execution.inc
+++ b/core/modules/user/user.views_execution.inc
@@ -13,5 +13,5 @@ use Drupal\views\ViewExecutable;
* Allow replacement of current userid so we can cache these queries.
*/
function user_views_query_substitutions(ViewExecutable $view) {
- return array('***CURRENT_USER***' => \Drupal::currentUser()->id());
+ return ['***CURRENT_USER***' => \Drupal::currentUser()->id()];
}
diff --git a/core/modules/views/src/Ajax/HighlightCommand.php b/core/modules/views/src/Ajax/HighlightCommand.php
index c19ff1b66c3..b04c0bef057 100644
--- a/core/modules/views/src/Ajax/HighlightCommand.php
+++ b/core/modules/views/src/Ajax/HighlightCommand.php
@@ -32,10 +32,10 @@ class HighlightCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'viewsHighlight',
'selector' => $this->selector,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Ajax/ReplaceTitleCommand.php b/core/modules/views/src/Ajax/ReplaceTitleCommand.php
index 45972c3c129..90e462abfa3 100644
--- a/core/modules/views/src/Ajax/ReplaceTitleCommand.php
+++ b/core/modules/views/src/Ajax/ReplaceTitleCommand.php
@@ -32,10 +32,10 @@ class ReplaceTitleCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'viewsReplaceTitle',
'selector' => $this->title,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Ajax/ScrollTopCommand.php b/core/modules/views/src/Ajax/ScrollTopCommand.php
index a303ffbbe9e..bf2db4e7c91 100644
--- a/core/modules/views/src/Ajax/ScrollTopCommand.php
+++ b/core/modules/views/src/Ajax/ScrollTopCommand.php
@@ -32,10 +32,10 @@ class ScrollTopCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'viewsScrollTop',
'selector' => $this->selector,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Ajax/ShowButtonsCommand.php b/core/modules/views/src/Ajax/ShowButtonsCommand.php
index f5d7dceb7bd..aecd6bd63a9 100644
--- a/core/modules/views/src/Ajax/ShowButtonsCommand.php
+++ b/core/modules/views/src/Ajax/ShowButtonsCommand.php
@@ -33,10 +33,10 @@ class ShowButtonsCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'viewsShowButtons',
'changed' => $this->changed,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Ajax/TriggerPreviewCommand.php b/core/modules/views/src/Ajax/TriggerPreviewCommand.php
index 080bc0247b3..64e76cb83ee 100644
--- a/core/modules/views/src/Ajax/TriggerPreviewCommand.php
+++ b/core/modules/views/src/Ajax/TriggerPreviewCommand.php
@@ -15,9 +15,9 @@ class TriggerPreviewCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'viewsTriggerPreview',
- );
+ ];
}
}
diff --git a/core/modules/views/src/Analyzer.php b/core/modules/views/src/Analyzer.php
index 2a3334292f1..3688fdaf43b 100644
--- a/core/modules/views/src/Analyzer.php
+++ b/core/modules/views/src/Analyzer.php
@@ -44,7 +44,7 @@ class Analyzer {
*/
public function getMessages(ViewExecutable $view) {
$view->initDisplay();
- $messages = $this->moduleHandler->invokeAll('views_analyze', array($view));
+ $messages = $this->moduleHandler->invokeAll('views_analyze', [$view]);
return $messages;
}
@@ -57,13 +57,13 @@ class Analyzer {
*/
public function formatMessages(array $messages) {
if (empty($messages)) {
- $messages = array(static::formatMessage(t('View analysis can find nothing to report.'), 'ok'));
+ $messages = [static::formatMessage(t('View analysis can find nothing to report.'), 'ok')];
}
- $types = array('ok' => array(), 'warning' => array(), 'error' => array());
+ $types = ['ok' => [], 'warning' => [], 'error' => []];
foreach ($messages as $message) {
if (empty($types[$message['type']])) {
- $types[$message['type']] = array();
+ $types[$message['type']] = [];
}
$types[$message['type']][] = $message['message'];
}
@@ -73,10 +73,10 @@ class Analyzer {
$type .= ' messages';
$message = '';
if (count($messages) > 1) {
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#items' => $messages,
- );
+ ];
$message = drupal_render($item_list);
}
elseif ($messages) {
@@ -116,7 +116,7 @@ class Analyzer {
* A single formatted message, consisting of a key message and a key type.
*/
static function formatMessage($message, $type = 'error') {
- return array('message' => $message, 'type' => $type);
+ return ['message' => $message, 'type' => $type];
}
}
diff --git a/core/modules/views/src/Controller/ViewAjaxController.php b/core/modules/views/src/Controller/ViewAjaxController.php
index 7993d2a5850..c40cf857660 100644
--- a/core/modules/views/src/Controller/ViewAjaxController.php
+++ b/core/modules/views/src/Controller/ViewAjaxController.php
@@ -114,7 +114,7 @@ class ViewAjaxController implements ContainerInjectionInterface {
$display_id = $request->request->get('view_display_id');
if (isset($name) && isset($display_id)) {
$args = $request->request->get('view_args');
- $args = isset($args) && $args !== '' ? explode('/', $args) : array();
+ $args = isset($args) && $args !== '' ? explode('/', $args) : [];
// Arguments can be empty, make sure they are passed on as NULL so that
// argument validation is not triggered.
@@ -132,7 +132,7 @@ class ViewAjaxController implements ContainerInjectionInterface {
// Remove all of this stuff from the query of the request so it doesn't
// end up in pagers and tablesort URLs.
- foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER) as $key) {
+ foreach (['view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER] as $key) {
$request->query->remove($key);
$request->request->remove($key);
}
diff --git a/core/modules/views/src/DisplayPluginCollection.php b/core/modules/views/src/DisplayPluginCollection.php
index 0b692b115d6..7c3c736fad9 100644
--- a/core/modules/views/src/DisplayPluginCollection.php
+++ b/core/modules/views/src/DisplayPluginCollection.php
@@ -80,7 +80,7 @@ class DisplayPluginCollection extends DefaultLazyPluginCollection {
// display plugin isn't found.
catch (PluginException $e) {
$message = $e->getMessage();
- drupal_set_message(t('@message', array('@message' => $message)), 'warning');
+ drupal_set_message(t('@message', ['@message' => $message]), 'warning');
}
// If no plugin instance has been created, return NULL.
diff --git a/core/modules/views/src/Element/View.php b/core/modules/views/src/Element/View.php
index b02e260fe71..43d1058c876 100644
--- a/core/modules/views/src/Element/View.php
+++ b/core/modules/views/src/Element/View.php
@@ -17,16 +17,16 @@ class View extends RenderElement {
*/
public function getInfo() {
$class = get_class($this);
- return array(
- '#pre_render' => array(
- array($class, 'preRenderViewElement'),
- ),
+ return [
+ '#pre_render' => [
+ [$class, 'preRenderViewElement'],
+ ],
'#name' => NULL,
'#display_id' => 'default',
- '#arguments' => array(),
+ '#arguments' => [],
'#embed' => TRUE,
'#cache' => [],
- );
+ ];
}
/**
@@ -92,7 +92,7 @@ class View extends RenderElement {
}
if (empty($view->display_handler->getPluginDefinition()['returns_response'])) {
$element['#attributes']['class'][] = 'views-element-container';
- $element['#theme_wrappers'] = array('container');
+ $element['#theme_wrappers'] = ['container'];
}
}
diff --git a/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php b/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php
index e08ef04d301..8fbc191d149 100644
--- a/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php
+++ b/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php
@@ -30,10 +30,10 @@ trait EntityTranslationRenderTrait {
$view = $this->getView();
$rendering_language = $view->display_handler->getOption('rendering_language');
$langcode = NULL;
- $dynamic_renderers = array(
+ $dynamic_renderers = [
'***LANGUAGE_entity_translation***' => 'TranslationLanguageRenderer',
'***LANGUAGE_entity_default***' => 'DefaultLanguageRenderer',
- );
+ ];
if (isset($dynamic_renderers[$rendering_language])) {
// Dynamic language set based on result rows or instance defaults.
$renderer = $dynamic_renderers[$rendering_language];
diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php
index f75badb027c..a8d8d44b89b 100644
--- a/core/modules/views/src/Entity/View.php
+++ b/core/modules/views/src/Entity/View.php
@@ -93,7 +93,7 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
*
* @var array
*/
- protected $display = array();
+ protected $display = [];
/**
* The name of the base field to use.
@@ -184,15 +184,15 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
}
}
- $display_options = array(
+ $display_options = [
'display_plugin' => $plugin_id,
'id' => $id,
// Cast the display title to a string since it is an object.
// @see \Drupal\Core\StringTranslation\TranslatableMarkup
'display_title' => (string) $title,
'position' => $id === 'default' ? 0 : count($this->display),
- 'display_options' => array(),
- );
+ 'display_options' => [],
+ ];
// Add the display options to the view.
$this->display[$id] = $display_options;
@@ -413,17 +413,17 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
// If there is no information about displays available add at least the
// default display.
- $values += array(
- 'display' => array(
- 'default' => array(
+ $values += [
+ 'display' => [
+ 'default' => [
'display_plugin' => 'default',
'id' => 'default',
'display_title' => 'Master',
'position' => 0,
- 'display_options' => array(),
- ),
- )
- );
+ 'display_options' => [],
+ ],
+ ]
+ ];
}
/**
@@ -468,15 +468,15 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
* {@inheritdoc}
*/
public function mergeDefaultDisplaysOptions() {
- $displays = array();
+ $displays = [];
foreach ($this->get('display') as $key => $options) {
- $options += array(
- 'display_options' => array(),
+ $options += [
+ 'display_options' => [],
'display_plugin' => NULL,
'id' => NULL,
'display_title' => '',
'position' => NULL,
- );
+ ];
// Add the defaults for the display.
$displays[$key] = $options;
}
diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php
index 61def5acd49..1a65b1c8a26 100644
--- a/core/modules/views/src/EntityViewsData.php
+++ b/core/modules/views/src/EntityViewsData.php
@@ -161,28 +161,28 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
if ($label_key = $this->entityType->getKey('label')) {
if ($data_table) {
- $data[$views_base_table]['table']['base']['defaults'] = array(
+ $data[$views_base_table]['table']['base']['defaults'] = [
'field' => $label_key,
'table' => $data_table,
- );
+ ];
}
else {
- $data[$views_base_table]['table']['base']['defaults'] = array(
+ $data[$views_base_table]['table']['base']['defaults'] = [
'field' => $label_key,
- );
+ ];
}
}
// Entity types must implement a list_builder in order to use Views'
// entity operations field.
if ($this->entityType->hasListBuilderClass()) {
- $data[$base_table]['operations'] = array(
- 'field' => array(
+ $data[$base_table]['operations'] = [
+ 'field' => [
'title' => $this->t('Operations links'),
'help' => $this->t('Provides links to perform entity operations.'),
'id' => 'entity_operations',
- ),
- );
+ ],
+ ];
}
if ($this->entityType->hasViewBuilderClass()) {
@@ -215,26 +215,26 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
$views_revision_base_table = $revision_data_table;
}
$data[$views_revision_base_table]['table']['entity revision'] = TRUE;
- $data[$views_revision_base_table]['table']['base'] = array(
+ $data[$views_revision_base_table]['table']['base'] = [
'field' => $revision_field,
- 'title' => $this->t('@entity_type revisions', array('@entity_type' => $this->entityType->getLabel())),
- );
+ 'title' => $this->t('@entity_type revisions', ['@entity_type' => $this->entityType->getLabel()]),
+ ];
// Join the revision table to the base table.
- $data[$views_revision_base_table]['table']['join'][$views_base_table] = array(
+ $data[$views_revision_base_table]['table']['join'][$views_base_table] = [
'left_field' => $revision_field,
'field' => $revision_field,
'type' => 'INNER',
- );
+ ];
if ($revision_data_table) {
$data[$revision_data_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]);
$data[$revision_data_table]['table']['entity revision'] = TRUE;
- $data[$revision_table]['table']['join'][$revision_data_table] = array(
+ $data[$revision_table]['table']['join'][$revision_data_table] = [
'left_field' => $revision_field,
'field' => $revision_field,
'type' => 'INNER',
- );
+ ];
}
}
@@ -404,7 +404,7 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
* The modified views data field definition.
*/
protected function mapSingleFieldViewsData($table, $field_name, $field_type, $column_name, $column_type, $first, FieldDefinitionInterface $field_definition) {
- $views_field = array();
+ $views_field = [];
// Provide a nicer, less verbose label for the first column within a field.
// @todo Introduce concept of the "main" column for a field, rather than
diff --git a/core/modules/views/src/EventSubscriber/RouteSubscriber.php b/core/modules/views/src/EventSubscriber/RouteSubscriber.php
index c209ddbaf11..c2b9ea89135 100644
--- a/core/modules/views/src/EventSubscriber/RouteSubscriber.php
+++ b/core/modules/views/src/EventSubscriber/RouteSubscriber.php
@@ -49,7 +49,7 @@ class RouteSubscriber extends RouteSubscriberBase {
*
* @var array
*/
- protected $viewRouteNames = array();
+ protected $viewRouteNames = [];
/**
* Constructs a \Drupal\views\EventSubscriber\RouteSubscriber instance.
@@ -76,7 +76,7 @@ class RouteSubscriber extends RouteSubscriberBase {
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
- $events[RoutingEvents::FINISHED] = array('routeRebuildFinished');
+ $events[RoutingEvents::FINISHED] = ['routeRebuildFinished'];
// Ensure to run after the entity resolver subscriber
// @see \Drupal\Core\EventSubscriber\EntityRouteAlterSubscriber
$events[RoutingEvents::ALTER] = ['onAlterRoutes', -175];
@@ -89,7 +89,7 @@ class RouteSubscriber extends RouteSubscriberBase {
*/
protected function getViewsDisplayIDsWithRoute() {
if (!isset($this->viewsDisplayPairs)) {
- $this->viewsDisplayPairs = array();
+ $this->viewsDisplayPairs = [];
// @todo Convert this method to some service.
$views = $this->getApplicableViews();
diff --git a/core/modules/views/src/ExposedFormCache.php b/core/modules/views/src/ExposedFormCache.php
index cb67a9ba075..f60cc71c127 100644
--- a/core/modules/views/src/ExposedFormCache.php
+++ b/core/modules/views/src/ExposedFormCache.php
@@ -14,7 +14,7 @@ class ExposedFormCache {
*
* @var array
*/
- protected $cache = array();
+ protected $cache = [];
/**
* Save the Views exposed form for later use.
@@ -56,7 +56,7 @@ class ExposedFormCache {
* Rests the form cache.
*/
public function reset() {
- $this->cache = array();
+ $this->cache = [];
}
}
diff --git a/core/modules/views/src/Form/ViewsExposedForm.php b/core/modules/views/src/Form/ViewsExposedForm.php
index bacd554954e..44e7ec4b0f3 100644
--- a/core/modules/views/src/Form/ViewsExposedForm.php
+++ b/core/modules/views/src/Form/ViewsExposedForm.php
@@ -52,10 +52,10 @@ class ViewsExposedForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
// Don't show the form when batch operations are in progress.
if ($batch = batch_get() && isset($batch['current_set'])) {
- return array(
+ return [
// Set the theme callback to be nothing to avoid errors in template_preprocess_views_exposed_form().
'#theme' => '',
- );
+ ];
}
// Make sure that we validate because this form might be submitted
@@ -74,7 +74,7 @@ class ViewsExposedForm extends FormBase {
return $cache;
}
- $form['#info'] = array();
+ $form['#info'] = [];
// Go through each handler and let it generate its exposed widget.
foreach ($view->display_handler->handlers as $type => $value) {
@@ -100,16 +100,16 @@ class ViewsExposedForm extends FormBase {
}
}
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions'
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
// Prevent from showing up in \Drupal::request()->query.
'#name' => '',
'#type' => 'submit',
'#value' => $this->t('Apply'),
'#id' => Html::getUniqueId('edit-submit-' . $view->storage->id()),
- );
+ ];
$form['#action'] = $view->hasUrl() ? $view->getUrl()->toString() : Url::fromRoute('<current>')->toString();
$form['#theme'] = $view->buildThemeFunctions('views_exposed_form');
@@ -131,7 +131,7 @@ class ViewsExposedForm extends FormBase {
public function validateForm(array &$form, FormStateInterface $form_state) {
$view = $form_state->get('view');
- foreach (array('field', 'filter') as $type) {
+ foreach (['field', 'filter'] as $type) {
/** @var \Drupal\views\Plugin\views\ViewsHandlerInterface[] $handlers */
$handlers = &$view->$type;
foreach ($handlers as $key => $handler) {
@@ -148,9 +148,9 @@ class ViewsExposedForm extends FormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Form input keys that will not be included in $view->exposed_raw_data.
- $exclude = array('submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset');
+ $exclude = ['submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset'];
$values = $form_state->getValues();
- foreach (array('field', 'filter') as $type) {
+ foreach (['field', 'filter'] as $type) {
/** @var \Drupal\views\Plugin\views\ViewsHandlerInterface[] $handlers */
$handlers = &$form_state->get('view')->$type;
foreach ($handlers as $key => $info) {
@@ -169,7 +169,7 @@ class ViewsExposedForm extends FormBase {
$view->exposed_data = $values;
$view->exposed_raw_input = [];
- $exclude = array('submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset');
+ $exclude = ['submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset'];
/** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */
$exposed_form_plugin = $view->display_handler->getPlugin('exposed_form');
$exposed_form_plugin->exposedFormSubmit($form, $form_state, $exclude);
diff --git a/core/modules/views/src/Form/ViewsForm.php b/core/modules/views/src/Form/ViewsForm.php
index b124d653d64..575b92313fc 100644
--- a/core/modules/views/src/Form/ViewsForm.php
+++ b/core/modules/views/src/Form/ViewsForm.php
@@ -151,19 +151,19 @@ class ViewsForm implements FormInterface, ContainerInjectionInterface {
// Add the base form ID.
$form_state->addBuildInfo('base_form_id', $this->getBaseFormId());
- $form = array();
+ $form = [];
$query = $this->requestStack->getCurrentRequest()->query->all();
- $query = UrlHelper::filterQueryParameters($query, array(), '');
+ $query = UrlHelper::filterQueryParameters($query, [], '');
- $options = array('query' => $query);
+ $options = ['query' => $query];
$form['#action'] = $view->hasUrl() ? $view->getUrl()->setOptions($options)->toString() : Url::fromRoute('<current>')->setOptions($options)->toString();
// Tell the preprocessor whether it should hide the header, footer, pager,
// etc.
- $form['show_view_elements'] = array(
+ $form['show_view_elements'] = [
'#type' => 'value',
'#value' => ($step == 'views_form_views_form') ? TRUE : FALSE,
- );
+ ];
$form_object = $this->getFormObject($form_state);
$form += $form_object->buildForm($form, $form_state, $view, $output);
diff --git a/core/modules/views/src/Form/ViewsFormMainForm.php b/core/modules/views/src/Form/ViewsFormMainForm.php
index fb8818ae716..da56f491698 100644
--- a/core/modules/views/src/Form/ViewsFormMainForm.php
+++ b/core/modules/views/src/Form/ViewsFormMainForm.php
@@ -30,15 +30,15 @@ class ViewsFormMainForm implements FormInterface {
// (below the exposed widgets).
$form['output']['#weight'] = 50;
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
- );
+ ];
- $substitutions = array();
+ $substitutions = [];
foreach ($view->field as $field_name => $field) {
$form_element_name = $field_name;
if (method_exists($field, 'form_element_name')) {
@@ -71,11 +71,11 @@ class ViewsFormMainForm implements FormInterface {
$form_element_row_id = $row_id;
}
- $substitutions[] = array(
+ $substitutions[] = [
'placeholder' => '<!--form-item-' . $form_element_name . '--' . $form_element_row_id . '-->',
'field_name' => $form_element_name,
'row_id' => $form_element_row_id,
- );
+ ];
}
}
}
@@ -89,10 +89,10 @@ class ViewsFormMainForm implements FormInterface {
}
}
- $form['#substitutions'] = array(
+ $form['#substitutions'] = [
'#type' => 'value',
'#value' => $substitutions,
- );
+ ];
return $form;
}
@@ -111,7 +111,7 @@ class ViewsFormMainForm implements FormInterface {
}
// Call the validate method on every area handler that has it.
- foreach (array('header', 'footer') as $area) {
+ foreach (['header', 'footer'] as $area) {
foreach ($view->{$area} as $area_handler) {
if (method_exists($area_handler, 'viewsFormValidate')) {
$area_handler->viewsFormValidate($form, $form_state);
@@ -134,7 +134,7 @@ class ViewsFormMainForm implements FormInterface {
}
// Call the submit method on every area handler that has it.
- foreach (array('header', 'footer') as $area) {
+ foreach (['header', 'footer'] as $area) {
foreach ($view->{$area} as $area_handler) {
if (method_exists($area_handler, 'viewsFormSubmit')) {
$area_handler->viewsFormSubmit($form, $form_state);
diff --git a/core/modules/views/src/ManyToOneHelper.php b/core/modules/views/src/ManyToOneHelper.php
index d9ed2ca7f9b..51d2b4f4814 100644
--- a/core/modules/views/src/ManyToOneHelper.php
+++ b/core/modules/views/src/ManyToOneHelper.php
@@ -26,17 +26,17 @@ class ManyToOneHelper {
}
public static function defineOptions(&$options) {
- $options['reduce_duplicates'] = array('default' => FALSE);
+ $options['reduce_duplicates'] = ['default' => FALSE];
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['reduce_duplicates'] = array(
+ $form['reduce_duplicates'] = [
'#type' => 'checkbox',
'#title' => t('Reduce duplicates'),
'#description' => t("This filter can cause items that have more than one of the selected options to appear as duplicate results. If this filter causes duplicate results to occur, this checkbox can reduce those duplicates; however, the more terms it has to search for, the less performant the query will be, so use this with caution. Shouldn't be set on single-value fields, as it may cause values to disappear from display, if used on an incompatible field."),
'#default_value' => !empty($this->handler->options['reduce_duplicates']),
'#weight' => 4,
- );
+ ];
}
/**
@@ -134,14 +134,14 @@ class ManyToOneHelper {
else {
if (!empty($view->many_to_one_tables[$field])) {
foreach ($view->many_to_one_tables[$field] as $value) {
- $join->extra = array(
- array(
+ $join->extra = [
+ [
'field' => $this->handler->realField,
'operator' => '!=',
'value' => $value,
'numeric' => !empty($this->definition['numeric']),
- ),
- );
+ ],
+ ];
}
}
return $this->addTable($join);
@@ -173,14 +173,14 @@ class ManyToOneHelper {
$join->type = 'LEFT';
if (!empty($this->handler->view->many_to_one_tables[$field])) {
foreach ($this->handler->view->many_to_one_tables[$field] as $value) {
- $join->extra = array(
- array(
+ $join->extra = [
+ [
'field' => $this->handler->realField,
'operator' => '!=',
'value' => $value,
'numeric' => !empty($this->handler->definition['numeric']),
- ),
- );
+ ],
+ ];
}
}
@@ -194,19 +194,19 @@ class ManyToOneHelper {
// We do one join per selected value.
if ($this->handler->operator != 'not') {
// Clone the join for each table:
- $this->handler->tableAliases = array();
+ $this->handler->tableAliases = [];
foreach ($this->handler->value as $value) {
$join = $this->getJoin();
if ($this->handler->operator == 'and') {
$join->type = 'INNER';
}
- $join->extra = array(
- array(
+ $join->extra = [
+ [
'field' => $this->handler->realField,
'value' => $value,
'numeric' => !empty($this->handler->definition['numeric']),
- ),
- );
+ ],
+ ];
// The table alias needs to be unique to this value across the
// multiple times the filter or argument is called by the view.
@@ -230,14 +230,14 @@ class ManyToOneHelper {
else {
$join = $this->getJoin();
$join->type = 'LEFT';
- $join->extra = array();
+ $join->extra = [];
$join->extraOperator = 'OR';
foreach ($this->handler->value as $value) {
- $join->extra[] = array(
+ $join->extra[] = [
'field' => $this->handler->realField,
'value' => $value,
'numeric' => !empty($this->handler->definition['numeric']),
- );
+ ];
}
$this->handler->tableAlias = $this->addTable($join);
@@ -297,9 +297,9 @@ class ManyToOneHelper {
else {
$operator = "$operator $placeholder";
}
- $placeholders = array(
+ $placeholders = [
$placeholder => $value,
- );
+ ];
$this->handler->query->addWhereExpression($options['group'], "$field $operator", $placeholders);
}
else {
@@ -311,7 +311,7 @@ class ManyToOneHelper {
$this->handler->query->addWhereExpression(0, "$field $operator");
}
else {
- $this->handler->query->addWhereExpression(0, "$field $operator($placeholder)", array($placeholder => $value));
+ $this->handler->query->addWhereExpression(0, "$field $operator($placeholder)", [$placeholder => $value]);
}
}
else {
@@ -319,7 +319,7 @@ class ManyToOneHelper {
$this->handler->query->addWhereExpression(0, "$field $operator");
}
else {
- $this->handler->query->addWhereExpression(0, "$field $operator $placeholder", array($placeholder => $value));
+ $this->handler->query->addWhereExpression(0, "$field $operator $placeholder", [$placeholder => $value]);
}
}
}
diff --git a/core/modules/views/src/Plugin/Block/ViewsBlock.php b/core/modules/views/src/Plugin/Block/ViewsBlock.php
index 34116fd5502..34738cddd4d 100644
--- a/core/modules/views/src/Plugin/Block/ViewsBlock.php
+++ b/core/modules/views/src/Plugin/Block/ViewsBlock.php
@@ -74,7 +74,7 @@ class ViewsBlock extends ViewsBlockBase {
return $output;
}
- return array();
+ return [];
}
/**
@@ -117,7 +117,7 @@ class ViewsBlock extends ViewsBlockBase {
return $this->view->display_handler->blockForm($this, $form, $form_state);
}
- return array();
+ return [];
}
/**
diff --git a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php
index 4a814d7511f..4e3020ca0ab 100644
--- a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php
+++ b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php
@@ -102,7 +102,7 @@ abstract class ViewsBlockBase extends BlockBase implements ContainerFactoryPlugi
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array('views_label' => '');
+ return ['views_label' => ''];
}
/**
@@ -122,39 +122,39 @@ abstract class ViewsBlockBase extends BlockBase implements ContainerFactoryPlugi
$form['#pre_render'][] = '\Drupal\views\Plugin\views\PluginBase::preRenderAddFieldsetMarkup';
// Allow to override the label on the actual page.
- $form['views_label_checkbox'] = array(
+ $form['views_label_checkbox'] = [
'#type' => 'checkbox',
'#title' => $this->t('Override title'),
'#default_value' => !empty($this->configuration['views_label']),
- );
+ ];
- $form['views_label_fieldset'] = array(
+ $form['views_label_fieldset'] = [
'#type' => 'fieldset',
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE),
- ),
- ),
- ),
- );
-
- $form['views_label'] = array(
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="settings[views_label_checkbox]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ],
+ ];
+
+ $form['views_label'] = [
'#title' => $this->t('Title'),
'#type' => 'textfield',
'#default_value' => $this->configuration['views_label'] ?: $this->view->getTitle(),
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE),
- ),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="settings[views_label_checkbox]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ],
'#fieldset' => 'views_label_fieldset',
- );
+ ];
if ($this->view->storage->access('edit') && \Drupal::moduleHandler()->moduleExists('views_ui')) {
- $form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore. (Try changing it directly in <a href=":url">@name</a>.)', array(':url' => \Drupal::url('entity.view.edit_display_form', array('view' => $this->view->storage->id(), 'display_id' => $this->displayID)), '@name' => $this->view->storage->label()));
+ $form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore. (Try changing it directly in <a href=":url">@name</a>.)', [':url' => \Drupal::url('entity.view.edit_display_form', ['view' => $this->view->storage->id(), 'display_id' => $this->displayID]), '@name' => $this->view->storage->label()]);
}
else {
$form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore.');
@@ -194,7 +194,7 @@ abstract class ViewsBlockBase extends BlockBase implements ContainerFactoryPlugi
// array, so if the block contains a string of already-rendered markup,
// convert it to an array.
if (is_string($output)) {
- $output = array('#markup' => $output);
+ $output = ['#markup' => $output];
}
// views_add_contextual_links() needs the following information in
diff --git a/core/modules/views/src/Plugin/Derivative/DefaultWizardDeriver.php b/core/modules/views/src/Plugin/Derivative/DefaultWizardDeriver.php
index 072d692be94..f6a045cf32d 100644
--- a/core/modules/views/src/Plugin/Derivative/DefaultWizardDeriver.php
+++ b/core/modules/views/src/Plugin/Derivative/DefaultWizardDeriver.php
@@ -17,16 +17,16 @@ class DefaultWizardDeriver extends DeriverBase {
public function getDerivativeDefinitions($base_plugin_definition) {
$views_data = Views::viewsData();
$base_tables = array_keys($views_data->fetchBaseTables());
- $this->derivatives = array();
+ $this->derivatives = [];
foreach ($base_tables as $table) {
$views_info = $views_data->get($table);
if (empty($views_info['table']['wizard_id'])) {
- $this->derivatives[$table] = array(
+ $this->derivatives[$table] = [
'id' => 'standard',
'base_table' => $table,
'title' => $views_info['table']['base']['title'],
'class' => 'Drupal\views\Plugin\views\wizard\Standard'
- );
+ ];
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
index c092a28ddac..f4da73d4bd9 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
@@ -19,7 +19,7 @@ class ViewsBlock implements ContainerDeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* The base plugin ID.
@@ -101,15 +101,15 @@ class ViewsBlock implements ContainerDeriverInterface {
}
}
- $this->derivatives[$delta] = array(
+ $this->derivatives[$delta] = [
'category' => $display->getOption('block_category'),
'admin_label' => $admin_label,
- 'config_dependencies' => array(
- 'config' => array(
+ 'config_dependencies' => [
+ 'config' => [
$view->getConfigDependencyName(),
- ),
- ),
- );
+ ],
+ ],
+ ];
// Look for arguments and expose them as context.
foreach ($display->getHandlers('argument') as $argument_name => $argument) {
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php b/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php
index 2343c9d515e..539eb479872 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php
@@ -38,7 +38,7 @@ class ViewsEntityArgumentValidator extends DeriverBase implements ContainerDeriv
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* Constructs an ViewsEntityArgumentValidator object.
@@ -72,16 +72,16 @@ class ViewsEntityArgumentValidator extends DeriverBase implements ContainerDeriv
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$entity_types = $this->entityManager->getDefinitions();
- $this->derivatives = array();
+ $this->derivatives = [];
foreach ($entity_types as $entity_type_id => $entity_type) {
- $this->derivatives[$entity_type_id] = array(
+ $this->derivatives[$entity_type_id] = [
'id' => 'entity:' . $entity_type_id,
'provider' => 'views',
'title' => $entity_type->getLabel(),
- 'help' => $this->t('Validate @label', array('@label' => $entity_type->getLabel())),
+ 'help' => $this->t('Validate @label', ['@label' => $entity_type->getLabel()]),
'entity_type' => $entity_type_id,
'class' => $base_plugin_definition['class'],
- );
+ ];
}
return $this->derivatives;
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php b/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php
index 6b36c083989..67e7c33fd62 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php
@@ -21,7 +21,7 @@ class ViewsEntityRow implements ContainerDeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* The base plugin ID that the derivative is for.
@@ -89,16 +89,16 @@ class ViewsEntityRow implements ContainerDeriverInterface {
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
// Just add support for entity types which have a views integration.
if (($base_table = $entity_type->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityManager->hasHandler($entity_type_id, 'view_builder')) {
- $this->derivatives[$entity_type_id] = array(
+ $this->derivatives[$entity_type_id] = [
'id' => 'entity:' . $entity_type_id,
'provider' => 'views',
'title' => $entity_type->getLabel(),
- 'help' => t('Display the @label', array('@label' => $entity_type->getLabel())),
- 'base' => array($entity_type->getDataTable() ?: $entity_type->getBaseTable()),
+ 'help' => t('Display the @label', ['@label' => $entity_type->getLabel()]),
+ 'base' => [$entity_type->getDataTable() ?: $entity_type->getBaseTable()],
'entity_type' => $entity_type_id,
- 'display_types' => array('normal'),
+ 'display_types' => ['normal'],
'class' => $base_plugin_definition['class'],
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
index 50edadcb043..fc2e9b894b7 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
@@ -18,7 +18,7 @@ class ViewsExposedFilterBlock implements ContainerDeriverInterface {
*
* @var array
*/
- protected $derivatives = array();
+ protected $derivatives = [];
/**
* The view storage.
@@ -85,15 +85,15 @@ class ViewsExposedFilterBlock implements ContainerDeriverInterface {
// Add a block definition for the block.
if ($display->usesExposedFormInBlock()) {
$delta = $view->id() . '-' . $display->display['id'];
- $desc = t('Exposed form: @view-@display_id', array('@view' => $view->id(), '@display_id' => $display->display['id']));
- $this->derivatives[$delta] = array(
+ $desc = t('Exposed form: @view-@display_id', ['@view' => $view->id(), '@display_id' => $display->display['id']]);
+ $this->derivatives[$delta] = [
'admin_label' => $desc,
- 'config_dependencies' => array(
- 'config' => array(
+ 'config_dependencies' => [
+ 'config' => [
$view->getConfigDependencyName(),
- )
- )
- );
+ ]
+ ]
+ ];
$this->derivatives[$delta] += $base_plugin_definition;
}
}
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php b/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php
index a8149848f43..bc6400c0189 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php
@@ -67,7 +67,7 @@ class ViewsLocalTask extends DeriverBase implements ContainerDeriverInterface {
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $this->derivatives = array();
+ $this->derivatives = [];
$view_route_names = $this->state->get('views.view_route_names');
foreach ($this->getApplicableMenuViews() as $pair) {
@@ -77,7 +77,7 @@ class ViewsLocalTask extends DeriverBase implements ContainerDeriverInterface {
$executable->setDisplay($display_id);
$menu = $executable->display_handler->getOption('menu');
- if (in_array($menu['type'], array('tab', 'default tab'))) {
+ if (in_array($menu['type'], ['tab', 'default tab'])) {
$plugin_id = 'view.' . $executable->storage->id() . '.' . $display_id;
$route_name = $view_route_names[$executable->storage->id() . '.' . $display_id];
@@ -87,11 +87,11 @@ class ViewsLocalTask extends DeriverBase implements ContainerDeriverInterface {
continue;
}
- $this->derivatives[$plugin_id] = array(
+ $this->derivatives[$plugin_id] = [
'route_name' => $route_name,
'weight' => $menu['weight'],
'title' => $menu['title'],
- ) + $base_plugin_definition;
+ ] + $base_plugin_definition;
// Default local tasks have themselves as root tab.
if ($menu['type'] == 'default tab') {
@@ -117,7 +117,7 @@ class ViewsLocalTask extends DeriverBase implements ContainerDeriverInterface {
$menu = $executable->display_handler->getOption('menu');
// We already have set the base_route for default tabs.
- if (in_array($menu['type'], array('tab'))) {
+ if (in_array($menu['type'], ['tab'])) {
$plugin_id = 'view.' . $executable->storage->id() . '.' . $display_id;
$view_route_name = $view_route_names[$executable->storage->id() . '.' . $display_id];
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php b/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php
index 1095d01f243..40dfe44a205 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php
@@ -46,7 +46,7 @@ class ViewsMenuLink extends DeriverBase implements ContainerDeriverInterface {
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $links = array();
+ $links = [];
$views = Views::getApplicableViews('uses_menu_links');
foreach ($views as $data) {
diff --git a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
index db190529280..05ac9b99f14 100644
--- a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
+++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
@@ -97,14 +97,14 @@ class ViewsSelection extends PluginBase implements SelectionInterface, Container
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$selection_handler_settings = $this->configuration['handler_settings'];
- $view_settings = !empty($selection_handler_settings['view']) ? $selection_handler_settings['view'] : array();
+ $view_settings = !empty($selection_handler_settings['view']) ? $selection_handler_settings['view'] : [];
$displays = Views::getApplicableViews('entity_reference_display');
// Filter views that list the entity type we want, and group the separate
// displays by view.
$entity_type = $this->entityManager->getDefinition($this->configuration['target_type']);
$view_storage = $this->entityManager->getStorage('view');
- $options = array();
+ $options = [];
foreach ($displays as $data) {
list($view_id, $display_id) = $data;
$view = $view_storage->load($view_id);
@@ -118,36 +118,36 @@ class ViewsSelection extends PluginBase implements SelectionInterface, Container
// into 'view_name' and 'view_display' in the final submitted values, so
// we massage the data at validate time on the wrapping element (not
// ideal).
- $form['view']['#element_validate'] = array(array(get_called_class(), 'settingsFormValidate'));
+ $form['view']['#element_validate'] = [[get_called_class(), 'settingsFormValidate']];
if ($options) {
$default = !empty($view_settings['view_name']) ? $view_settings['view_name'] . ':' . $view_settings['display_name'] : NULL;
- $form['view']['view_and_display'] = array(
+ $form['view']['view_and_display'] = [
'#type' => 'select',
'#title' => $this->t('View used to select the entities'),
'#required' => TRUE,
'#options' => $options,
'#default_value' => $default,
'#description' => '<p>' . $this->t('Choose the view and display that select the entities that can be referenced.<br />Only views with a display of type "Entity Reference" are eligible.') . '</p>',
- );
+ ];
$default = !empty($view_settings['arguments']) ? implode(', ', $view_settings['arguments']) : '';
- $form['view']['arguments'] = array(
+ $form['view']['arguments'] = [
'#type' => 'textfield',
'#title' => $this->t('View arguments'),
'#default_value' => $default,
'#required' => FALSE,
'#description' => $this->t('Provide a comma separated list of arguments to pass to the view.'),
- );
+ ];
}
else {
if ($this->currentUser->hasPermission('administer views') && $this->moduleHandler->moduleExists('views_ui')) {
- $form['view']['no_view_help'] = array(
- '#markup' => '<p>' . $this->t('No eligible views were found. <a href=":create">Create a view</a> with an <em>Entity Reference</em> display, or add such a display to an <a href=":existing">existing view</a>.', array(
+ $form['view']['no_view_help'] = [
+ '#markup' => '<p>' . $this->t('No eligible views were found. <a href=":create">Create a view</a> with an <em>Entity Reference</em> display, or add such a display to an <a href=":existing">existing view</a>.', [
':create' => Url::fromRoute('views_ui.add')->toString(),
':existing' => Url::fromRoute('entity.view.collection')->toString(),
- )) . '</p>',
- );
+ ]) . '</p>',
+ ];
}
else {
$form['view']['no_view_help']['#markup'] = '<p>' . $this->t('No eligible views were found.') . '</p>';
@@ -191,18 +191,18 @@ class ViewsSelection extends PluginBase implements SelectionInterface, Container
// Check that the view is valid and the display still exists.
$this->view = Views::getView($view_name);
if (!$this->view || !$this->view->access($display_name)) {
- drupal_set_message(t('The reference view %view_name cannot be found.', array('%view_name' => $view_name)), 'warning');
+ drupal_set_message(t('The reference view %view_name cannot be found.', ['%view_name' => $view_name]), 'warning');
return FALSE;
}
$this->view->setDisplay($display_name);
// Pass options to the display handler to make them available later.
- $entity_reference_options = array(
+ $entity_reference_options = [
'match' => $match,
'match_operator' => $match_operator,
'limit' => $limit,
'ids' => $ids,
- );
+ ];
$this->view->displayHandlers->get($display_name)->setOption('entity_reference_options', $entity_reference_options);
return TRUE;
}
@@ -214,13 +214,13 @@ class ViewsSelection extends PluginBase implements SelectionInterface, Container
$handler_settings = $this->configuration['handler_settings'];
$display_name = $handler_settings['view']['display_name'];
$arguments = $handler_settings['view']['arguments'];
- $result = array();
+ $result = [];
if ($this->initializeView($match, $match_operator, $limit)) {
// Get the results.
$result = $this->view->executeDisplay($display_name, $arguments);
}
- $return = array();
+ $return = [];
if ($result) {
foreach ($this->view->result as $row) {
$entity = $row->_entity;
@@ -245,7 +245,7 @@ class ViewsSelection extends PluginBase implements SelectionInterface, Container
$handler_settings = $this->configuration['handler_settings'];
$display_name = $handler_settings['view']['display_name'];
$arguments = $handler_settings['view']['arguments'];
- $result = array();
+ $result = [];
if ($this->initializeView(NULL, 'CONTAINS', 0, $ids)) {
// Get the results.
$entities = $this->view->executeDisplay($display_name, $arguments);
@@ -272,14 +272,14 @@ class ViewsSelection extends PluginBase implements SelectionInterface, Container
// empty array instead.
$arguments_string = trim($element['arguments']['#value']);
if ($arguments_string === '') {
- $arguments = array();
+ $arguments = [];
}
else {
// array_map() is called to trim whitespaces from the arguments.
$arguments = array_map('trim', explode(',', $arguments_string));
}
- $value = array('view_name' => $view, 'display_name' => $display, 'arguments' => $arguments);
+ $value = ['view_name' => $view, 'display_name' => $display, 'arguments' => $arguments];
$form_state->setValueForElement($element, $value);
}
diff --git a/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php b/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php
index d330cdf392f..1699f3e94f6 100644
--- a/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php
+++ b/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php
@@ -28,16 +28,16 @@ class ViewsMenuLinkForm extends MenuLinkDefaultForm {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Put the title field first.
- $form['title'] = array(
+ $form['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Title'),
// @todo Ensure that the view is not loaded with a localized title.
// https://www.drupal.org/node/2309507
'#default_value' => $this->menuLink->getTitle(),
'#weight' => -10,
- );
+ ];
- $form['description'] = array(
+ $form['description'] = [
'#type' => 'textfield',
'#title' => $this->t('Description'),
'#description' => $this->t('Shown when hovering over the menu link.'),
@@ -45,7 +45,7 @@ class ViewsMenuLinkForm extends MenuLinkDefaultForm {
// https://www.drupal.org/node/2309507
'#default_value' => $this->menuLink->getDescription(),
'#weight' => -5,
- );
+ ];
$form += parent::buildConfigurationForm($form, $form_state);
@@ -56,10 +56,10 @@ class ViewsMenuLinkForm extends MenuLinkDefaultForm {
$id = $view->storage->id();
$label = $view->storage->label();
if ($this->moduleHandler->moduleExists('views_ui')) {
- $message = $this->t('This link is provided by the Views module. The path can be changed by editing the view <a href=":url">@label</a>', array(':url' => \Drupal::url('entity.view.edit_form', array('view' => $id)), '@label' => $label));
+ $message = $this->t('This link is provided by the Views module. The path can be changed by editing the view <a href=":url">@label</a>', [':url' => \Drupal::url('entity.view.edit_form', ['view' => $id]), '@label' => $label]);
}
else {
- $message = $this->t('This link is provided by the Views module from view %label.', array('%label' => $label));
+ $message = $this->t('This link is provided by the Views module from view %label.', ['%label' => $label]);
}
$form['info']['#title'] = $message;
return $form;
diff --git a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php
index b484c24b124..b4f078fc684 100644
--- a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php
+++ b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php
@@ -18,7 +18,7 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf
/**
* {@inheritdoc}
*/
- protected $overrideAllowed = array(
+ protected $overrideAllowed = [
'menu_name' => 1,
'parent' => 1,
'weight' => 1,
@@ -26,7 +26,7 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf
'enabled' => 1,
'title' => 1,
'description' => 1,
- );
+ ];
/**
* The entity manager.
diff --git a/core/modules/views/src/Plugin/ViewsHandlerManager.php b/core/modules/views/src/Plugin/ViewsHandlerManager.php
index d918696d674..bfc859227a1 100644
--- a/core/modules/views/src/Plugin/ViewsHandlerManager.php
+++ b/core/modules/views/src/Plugin/ViewsHandlerManager.php
@@ -59,9 +59,9 @@ class ViewsHandlerManager extends DefaultPluginManager implements FallbackPlugin
$this->viewsData = $views_data;
$this->handlerType = $handler_type;
- $this->defaults = array(
+ $this->defaults = [
'plugin_type' => $handler_type,
- );
+ ];
}
/**
@@ -86,7 +86,7 @@ class ViewsHandlerManager extends DefaultPluginManager implements FallbackPlugin
if (isset($data[$field][$this->handlerType])) {
$definition = $data[$field][$this->handlerType];
- foreach (array('group', 'title', 'title short', 'label', 'help', 'real field', 'real table', 'entity type', 'entity field') as $key) {
+ foreach (['group', 'title', 'title short', 'label', 'help', 'real field', 'real table', 'entity type', 'entity field'] as $key) {
if (!isset($definition[$key])) {
// First check the field level.
if (!empty($data[$field][$key])) {
@@ -111,13 +111,13 @@ class ViewsHandlerManager extends DefaultPluginManager implements FallbackPlugin
}
// Finally, use the 'broken' handler.
- return $this->createInstance('broken', array('original_configuration' => $item));
+ return $this->createInstance('broken', ['original_configuration' => $item]);
}
/**
* {@inheritdoc}
*/
- public function createInstance($plugin_id, array $configuration = array()) {
+ public function createInstance($plugin_id, array $configuration = []) {
$instance = parent::createInstance($plugin_id, $configuration);
if ($instance instanceof HandlerBase) {
$instance->setModuleHandler($this->moduleHandler);
@@ -129,7 +129,7 @@ class ViewsHandlerManager extends DefaultPluginManager implements FallbackPlugin
/**
* {@inheritdoc}
*/
- public function getFallbackPluginId($plugin_id, array $configuration = array()) {
+ public function getFallbackPluginId($plugin_id, array $configuration = []) {
return 'broken';
}
diff --git a/core/modules/views/src/Plugin/ViewsPluginManager.php b/core/modules/views/src/Plugin/ViewsPluginManager.php
index a8dadb0485b..8124d316302 100644
--- a/core/modules/views/src/Plugin/ViewsPluginManager.php
+++ b/core/modules/views/src/Plugin/ViewsPluginManager.php
@@ -31,11 +31,11 @@ class ViewsPluginManager extends DefaultPluginManager {
$plugin_definition_annotation_name = 'Drupal\views\Annotation\Views' . Container::camelize($type);
parent::__construct("Plugin/views/$type", $namespaces, $module_handler, 'Drupal\views\Plugin\views\ViewsPluginInterface', $plugin_definition_annotation_name);
- $this->defaults += array(
+ $this->defaults += [
'parent' => 'parent',
'plugin_type' => $type,
'register_theme' => TRUE,
- );
+ ];
$this->alterInfo('views_plugins_' . $type);
$this->setCacheBackend($cache_backend, "views:$type");
diff --git a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
index df129da4998..00233f7cca6 100644
--- a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
+++ b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
@@ -25,7 +25,7 @@ trait BrokenHandlerTrait {
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
*/
public function defineOptions() {
- return array();
+ return [];
}
/**
@@ -55,28 +55,28 @@ trait BrokenHandlerTrait {
foreach ($this->definition['original_configuration'] as $key => $value) {
if (is_scalar($value)) {
- $items[] = SafeMarkup::format('@key: @value', array('@key' => $key, '@value' => $value));
+ $items[] = SafeMarkup::format('@key: @value', ['@key' => $key, '@value' => $value]);
}
}
$description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.');
- $form['description'] = array(
+ $form['description'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('js-form-item', 'form-item', 'description'),
- ),
- 'description_top' => array(
+ '#attributes' => [
+ 'class' => ['js-form-item', 'form-item', 'description'],
+ ],
+ 'description_top' => [
'#markup' => '<p>' . $description_top . '</p>',
- ),
- 'detail_list' => array(
+ ],
+ 'detail_list' => [
'#theme' => 'item_list',
'#items' => $items,
- ),
- 'description_bottom' => array(
+ ],
+ 'description_bottom' => [
'#markup' => '<p>' . $description_bottom . '</p>',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php
index 5c2200cc6ed..8396c6bbf67 100644
--- a/core/modules/views/src/Plugin/views/HandlerBase.php
+++ b/core/modules/views/src/Plugin/views/HandlerBase.php
@@ -138,12 +138,12 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['id'] = array('default' => '');
- $options['table'] = array('default' => '');
- $options['field'] = array('default' => '');
- $options['relationship'] = array('default' => 'none');
- $options['group_type'] = array('default' => 'group');
- $options['admin_label'] = array('default' => '');
+ $options['id'] = ['default' => ''];
+ $options['table'] = ['default' => ''];
+ $options['field'] = ['default' => ''];
+ $options['relationship'] = ['default' => 'none'];
+ $options['group_type'] = ['default' => 'group'];
+ $options['admin_label'] = ['default' => ''];
return $options;
}
@@ -156,7 +156,7 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
return $this->options['admin_label'];
}
$title = ($short && isset($this->definition['title short'])) ? $this->definition['title short'] : $this->definition['title'];
- return $this->t('@group: @title', array('@group' => $this->definition['group'], '@title' => $title));
+ return $this->t('@group: @title', ['@group' => $this->definition['group'], '@title' => $title]);
}
/**
@@ -248,36 +248,36 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
// be moved into one because of the $form_state->getValues() hierarchy. Those
// elements can add a #fieldset => 'fieldset_name' property, and they'll
// be moved to their fieldset during pre_render.
- $form['#pre_render'][] = array(get_class($this), 'preRenderAddFieldsetMarkup');
+ $form['#pre_render'][] = [get_class($this), 'preRenderAddFieldsetMarkup'];
parent::buildOptionsForm($form, $form_state);
- $form['fieldsets'] = array(
+ $form['fieldsets'] = [
'#type' => 'value',
- '#value' => array('more', 'admin_label'),
- );
+ '#value' => ['more', 'admin_label'],
+ ];
- $form['admin_label'] = array(
+ $form['admin_label'] = [
'#type' => 'details',
'#title' => $this->t('Administrative title'),
'#weight' => 150,
- );
- $form['admin_label']['admin_label'] = array(
+ ];
+ $form['admin_label']['admin_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Administrative title'),
'#description' => $this->t('This title will be displayed on the views edit page instead of the default one. This might be useful if you have the same item twice.'),
'#default_value' => $this->options['admin_label'],
- '#parents' => array('options', 'admin_label'),
- );
+ '#parents' => ['options', 'admin_label'],
+ ];
// This form is long and messy enough that the "Administrative title" option
// belongs in "Administrative title" fieldset at the bottom of the form.
- $form['more'] = array(
+ $form['more'] = [
'#type' => 'details',
'#title' => $this->t('More'),
'#weight' => 200,
'#optional' => TRUE,
- );
+ ];
// Allow to alter the default values brought into the form.
// @todo Do we really want to keep this hook.
@@ -329,13 +329,13 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
$group_types[$id] = $aggregate['title'];
}
- $form['group_type'] = array(
+ $form['group_type'] = [
'#type' => 'select',
'#title' => $this->t('Aggregation type'),
'#default_value' => $this->options['group_type'],
'#description' => $this->t('Select the aggregation function to use on this field.'),
'#options' => $group_types,
- );
+ ];
}
/**
@@ -454,7 +454,7 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
public function access(AccountInterface $account) {
if (isset($this->definition['access callback']) && function_exists($this->definition['access callback'])) {
if (isset($this->definition['access arguments']) && is_array($this->definition['access arguments'])) {
- return call_user_func_array($this->definition['access callback'], array($account) + $this->definition['access arguments']);
+ return call_user_func_array($this->definition['access callback'], [$account] + $this->definition['access arguments']);
}
return $this->definition['access callback']($account);
}
@@ -587,7 +587,7 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
/**
* {@inheritdoc}
*/
- public function validate() { return array(); }
+ public function validate() { return []; }
/**
* {@inheritdoc}
@@ -703,7 +703,7 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
*/
public static function breakString($str, $force_int = FALSE) {
$operator = NULL;
- $value = array();
+ $value = [];
// Determine if the string has 'or' operators (plus signs) or 'and'
// operators (commas) and split the string accordingly.
@@ -726,7 +726,7 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
$value = array_map('intval', $value);
}
- return (object) array('value' => $value, 'operator' => $operator);
+ return (object) ['value' => $value, 'operator' => $operator];
}
/**
diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php
index 6d5aec184a7..e523ebafaff 100644
--- a/core/modules/views/src/Plugin/views/PluginBase.php
+++ b/core/modules/views/src/Plugin/views/PluginBase.php
@@ -66,7 +66,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
*
* @var array
*/
- public $options = array();
+ public $options = [];
/**
* The top object of a view.
@@ -155,7 +155,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
* @return array
* Returns the options of this handler/plugin.
*/
- protected function defineOptions() { return array(); }
+ protected function defineOptions() { return []; }
/**
* Fills up the options of the plugin with defaults.
@@ -175,7 +175,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
protected function setOptionDefaults(array &$storage, array $options) {
foreach ($options as $option => $definition) {
if (isset($definition['contains'])) {
- $storage[$option] = array();
+ $storage[$option] = [];
$this->setOptionDefaults($storage[$option], $definition['contains']);
}
else {
@@ -231,7 +231,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
}
if (!isset($storage[$key]) || !is_array($storage[$key])) {
- $storage[$key] = array();
+ $storage[$key] = [];
}
// If we're just unpacking our known options, and we're dropping an
@@ -242,7 +242,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
continue;
}
- $this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE);
+ $this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : [], $all, FALSE);
}
elseif ($all || !empty($definition[$key])) {
$storage[$key] = $value;
@@ -265,7 +265,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
// be moved into one because of the $form_state->getValues() hierarchy. Those
// elements can add a #fieldset => 'fieldset_name' property, and they'll
// be moved to their fieldset during pre_render.
- $form['#pre_render'][] = array(get_class($this), 'preRenderAddFieldsetMarkup');
+ $form['#pre_render'][] = [get_class($this), 'preRenderAddFieldsetMarkup'];
}
/**
@@ -293,7 +293,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
/**
* {@inheritdoc}
*/
- public function validate() { return array(); }
+ public function validate() { return []; }
/**
* {@inheritdoc}
@@ -323,8 +323,8 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
/**
* {@inheritdoc}
*/
- public function globalTokenReplace($string = '', array $options = array()) {
- return \Drupal::token()->replace($string, array('view' => $this->view), $options);
+ public function globalTokenReplace($string = '', array $options = []) {
+ return \Drupal::token()->replace($string, ['view' => $this->view], $options);
}
/**
@@ -347,7 +347,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
return Xss::filterAdmin($text);
}
- $twig_tokens = array();
+ $twig_tokens = [];
foreach ($tokens as $token => $replacement) {
// Twig wants a token replacement array stripped of curly-brackets.
// Some Views tokens come with curly-braces, others do not.
@@ -371,11 +371,11 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
$parts = explode('.', $token);
$top = array_shift($parts);
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.');
- $token_array = array(array_pop($parts) => $replacement);
+ $token_array = [array_pop($parts) => $replacement];
foreach (array_reverse($parts) as $key) {
// The key could also be numeric (array index) so allow that.
assert('is_numeric($key) || (preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1)', 'Tokens need to be valid Twig variables.');
- $token_array = array($key => $token_array);
+ $token_array = [$key => $token_array];
}
if (!isset($twig_tokens[$top])) {
$twig_tokens[$top] = [];
@@ -389,7 +389,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
// Otherwise, Xss::filterAdmin could remove valid Twig syntax before the
// template is parsed.
- $build = array(
+ $build = [
'#type' => 'inline_template',
'#template' => $text,
'#context' => $twig_tokens,
@@ -398,7 +398,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
return Xss::filterAdmin($children);
}
],
- );
+ ];
// Currently you cannot attach assets to tokens with
// Renderer::renderPlain(). This may be unnecessarily limiting. Consider
@@ -414,15 +414,15 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
/**
* {@inheritdoc}
*/
- public function getAvailableGlobalTokens($prepared = FALSE, array $types = array()) {
+ public function getAvailableGlobalTokens($prepared = FALSE, array $types = []) {
$info = \Drupal::token()->getInfo();
// Site and view tokens should always be available.
- $types += array('site', 'view');
+ $types += ['site', 'view'];
$available = array_intersect_key($info['tokens'], array_flip($types));
// Construct the token string for each token.
if ($prepared) {
- $prepared = array();
+ $prepared = [];
foreach ($available as $type => $tokens) {
foreach (array_keys($tokens) as $token) {
$prepared[$type][] = "[$type:$token]";
@@ -439,13 +439,13 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
* {@inheritdoc}
*/
public function globalTokenForm(&$form, FormStateInterface $form_state) {
- $token_items = array();
+ $token_items = [];
foreach ($this->getAvailableGlobalTokens() as $type => $tokens) {
- $item = array(
+ $item = [
'#markup' => $type,
- 'children' => array(),
- );
+ 'children' => [],
+ ];
foreach ($tokens as $name => $info) {
$item['children'][$name] = "[$type:$name]" . ' - ' . $info['name'] . ': ' . $info['description'];
}
@@ -453,17 +453,17 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
$token_items[$type] = $item;
}
- $form['global_tokens'] = array(
+ $form['global_tokens'] = [
'#type' => 'details',
'#title' => $this->t('Available global token replacements'),
- );
- $form['global_tokens']['list'] = array(
+ ];
+ $form['global_tokens']['list'] = [
'#theme' => 'item_list',
'#items' => $token_items,
- '#attributes' => array(
- 'class' => array('global-tokens'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['global-tokens'],
+ ],
+ ];
}
/**
@@ -546,7 +546,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
protected function listLanguages($flags = LanguageInterface::STATE_ALL, array $current_values = NULL) {
$manager = \Drupal::languageManager();
$languages = $manager->getLanguages($flags);
- $list = array();
+ $list = [];
// The entity languages should come first, if requested.
if ($flags & PluginBase::INCLUDE_ENTITY) {
@@ -582,7 +582,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
$name = $types_info[$id]['name'];
// Surround IDs by '***LANGUAGE_...***', to avoid query collisions.
$id = '***LANGUAGE_' . $id . '***';
- $list[$id] = $this->t('@type language selected for page', array('@type' => $name));
+ $list[$id] = $this->t('@type language selected for page', ['@type' => $name]);
}
}
if (!empty($current_values)) {
@@ -592,7 +592,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
// add that option too, so it is not lost. If not among the current
// values, skip displaying it to avoid user confusion.
if (isset($type['name']) && !isset($list[$id]) && in_array($id, $current_values)) {
- $list[$id] = $this->t('@type language selected for page', array('@type' => $type['name']));
+ $list[$id] = $this->t('@type language selected for page', ['@type' => $type['name']]);
}
}
}
@@ -619,7 +619,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
* the query substitutions needed for the special language types.
*/
public static function queryLanguageSubstitutions() {
- $changes = array();
+ $changes = [];
$manager = \Drupal::languageManager();
// Handle default language.
diff --git a/core/modules/views/src/Plugin/views/ViewsPluginInterface.php b/core/modules/views/src/Plugin/views/ViewsPluginInterface.php
index e685c4d8af4..83d9c89bbc7 100644
--- a/core/modules/views/src/Plugin/views/ViewsPluginInterface.php
+++ b/core/modules/views/src/Plugin/views/ViewsPluginInterface.php
@@ -113,7 +113,7 @@ interface ViewsPluginInterface extends PluginInspectionInterface, DerivativeInsp
* @return array
* An array of available token replacement info or tokens, grouped by type.
*/
- public function getAvailableGlobalTokens($prepared = FALSE, array $types = array());
+ public function getAvailableGlobalTokens($prepared = FALSE, array $types = []);
/**
* Flattens the structure of form elements.
@@ -141,7 +141,7 @@ interface ViewsPluginInterface extends PluginInspectionInterface, DerivativeInsp
* @return string
* The tokenized string.
*/
- public function globalTokenReplace($string = '', array $options = array());
+ public function globalTokenReplace($string = '', array $options = []);
/**
* Clears a plugin.
diff --git a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php
index 2ad7f46be9b..813e4306c09 100644
--- a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php
+++ b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php
@@ -62,7 +62,7 @@ abstract class AreaPluginBase extends HandlerBase {
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
$options['admin_label']['default'] = $label;
- $options['empty'] = array('default' => FALSE);
+ $options['empty'] = ['default' => FALSE];
return $options;
}
@@ -81,11 +81,11 @@ abstract class AreaPluginBase extends HandlerBase {
parent::buildOptionsForm($form, $form_state);
if ($form_state->get('type') != 'empty') {
- $form['empty'] = array(
+ $form['empty'] = [
'#type' => 'checkbox',
'#title' => $this->t('Display even if view has no result'),
'#default_value' => isset($this->options['empty']) ? $this->options['empty'] : 0,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/area/Broken.php b/core/modules/views/src/Plugin/views/area/Broken.php
index 549c306298e..7bd6cdbd83f 100644
--- a/core/modules/views/src/Plugin/views/area/Broken.php
+++ b/core/modules/views/src/Plugin/views/area/Broken.php
@@ -19,7 +19,7 @@ class Broken extends AreaPluginBase {
*/
public function render($empty = FALSE) {
// Simply render nothing by returning an empty render array.
- return array();
+ return [];
}
}
diff --git a/core/modules/views/src/Plugin/views/area/Entity.php b/core/modules/views/src/Plugin/views/area/Entity.php
index 30c24ecb3a9..d073d53fcf7 100644
--- a/core/modules/views/src/Plugin/views/area/Entity.php
+++ b/core/modules/views/src/Plugin/views/area/Entity.php
@@ -93,12 +93,12 @@ class Entity extends TokenizeAreaPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['view_mode'] = array(
+ $form['view_mode'] = [
'#type' => 'select',
'#options' => $this->entityManager->getViewModeOptions($this->entityType),
'#title' => $this->t('View mode'),
'#default_value' => $this->options['view_mode'],
- );
+ ];
$label = $this->entityManager->getDefinition($this->entityType)->getLabel();
$target = $this->options['target'];
@@ -121,12 +121,12 @@ class Entity extends TokenizeAreaPluginBase {
'#default_value' => $target,
];
- $form['bypass_access'] = array(
+ $form['bypass_access'] = [
'#type' => 'checkbox',
'#title' => $this->t('Bypass access checks'),
'#description' => $this->t('If enabled, access permissions for rendering the entity are not checked.'),
'#default_value' => !empty($this->options['bypass_access']),
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php b/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php
index 4f6667a5e9b..d9b81454125 100644
--- a/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php
+++ b/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php
@@ -20,7 +20,7 @@ class HTTPStatusCode extends AreaPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['status_code'] = array('default' => 200);
+ $options['status_code'] = ['default' => 200];
return $options;
}
@@ -35,23 +35,23 @@ class HTTPStatusCode extends AreaPluginBase {
$options = Response::$statusTexts;
// Move 403/404/500 to the top.
- $options = array(
+ $options = [
'404' => $options['404'],
'403' => $options['403'],
'500' => $options['500'],
- ) + $options;
+ ] + $options;
// Add the HTTP status code, so it's easier for people to find it.
array_walk($options, function($title, $code) use(&$options) {
- $options[$code] = $this->t('@code (@title)', array('@code' => $code, '@title' => $title));
+ $options[$code] = $this->t('@code (@title)', ['@code' => $code, '@title' => $title]);
});
- $form['status_code'] = array(
+ $form['status_code'] = [
'#title' => $this->t('HTTP status code'),
'#type' => 'select',
'#default_value' => $this->options['status_code'],
'#options' => $options,
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/area/Messages.php b/core/modules/views/src/Plugin/views/area/Messages.php
index 37df125a683..c26b995ed38 100644
--- a/core/modules/views/src/Plugin/views/area/Messages.php
+++ b/core/modules/views/src/Plugin/views/area/Messages.php
@@ -26,11 +26,11 @@ class Messages extends AreaPluginBase {
*/
public function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
- return array(
+ return [
'#type' => 'status_messages',
- );
+ ];
}
- return array();
+ return [];
}
}
diff --git a/core/modules/views/src/Plugin/views/area/Result.php b/core/modules/views/src/Plugin/views/area/Result.php
index d8139cbee8a..f0082dbb7b3 100644
--- a/core/modules/views/src/Plugin/views/area/Result.php
+++ b/core/modules/views/src/Plugin/views/area/Result.php
@@ -22,9 +22,9 @@ class Result extends AreaPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['content'] = array(
+ $options['content'] = [
'default' => $this->t('Displaying @start - @end of @total'),
- );
+ ];
return $options;
}
@@ -34,9 +34,9 @@ class Result extends AreaPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
- '#items' => array(
+ '#items' => [
'@start -- the initial record number in the set',
'@end -- the last record number in the set',
'@total -- the total records in the set',
@@ -45,16 +45,16 @@ class Result extends AreaPluginBase {
'@current_page -- the current page number',
'@current_record_count -- the current page record count',
'@page_count -- the total page count',
- ),
- );
+ ],
+ ];
$list = drupal_render($item_list);
- $form['content'] = array(
+ $form['content'] = [
'#title' => $this->t('Display'),
'#type' => 'textarea',
'#rows' => 3,
'#default_value' => $this->options['content'],
'#description' => $this->t('You may use HTML code in this field. The following tokens are supported:') . $list,
- );
+ ];
}
/**
@@ -72,7 +72,7 @@ class Result extends AreaPluginBase {
public function render($empty = FALSE) {
// Must have options and does not work on summaries.
if (!isset($this->options['content']) || $this->view->style_plugin instanceof DefaultSummary) {
- return array();
+ return [];
}
$output = '';
$format = $this->options['content'];
@@ -113,9 +113,9 @@ class Result extends AreaPluginBase {
$output .= Xss::filterAdmin(str_replace(array_keys($replacements), array_values($replacements), $format));
}
// Return as render array.
- return array(
+ return [
'#markup' => $output,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/area/Text.php b/core/modules/views/src/Plugin/views/area/Text.php
index dab32e9e932..aafcbf2095d 100644
--- a/core/modules/views/src/Plugin/views/area/Text.php
+++ b/core/modules/views/src/Plugin/views/area/Text.php
@@ -18,12 +18,12 @@ class Text extends TokenizeAreaPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['content'] = array(
- 'contains' => array(
- 'value' => array('default' => ''),
- 'format' => array('default' => NULL),
- ),
- );
+ $options['content'] = [
+ 'contains' => [
+ 'value' => ['default' => ''],
+ 'format' => ['default' => NULL],
+ ],
+ ];
return $options;
}
@@ -33,14 +33,14 @@ class Text extends TokenizeAreaPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['content'] = array(
+ $form['content'] = [
'#title' => $this->t('Content'),
'#type' => 'text_format',
'#default_value' => $this->options['content']['value'],
'#rows' => 6,
'#format' => isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format(),
'#editor' => FALSE,
- );
+ ];
}
/**
@@ -60,14 +60,14 @@ class Text extends TokenizeAreaPluginBase {
public function render($empty = FALSE) {
$format = isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format();
if (!$empty || !empty($this->options['empty'])) {
- return array(
+ return [
'#type' => 'processed_text',
'#text' => $this->tokenizeValue($this->options['content']['value']),
'#format' => $format,
- );
+ ];
}
- return array();
+ return [];
}
}
diff --git a/core/modules/views/src/Plugin/views/area/TextCustom.php b/core/modules/views/src/Plugin/views/area/TextCustom.php
index 0eeabaa92d4..56e963dd6f4 100644
--- a/core/modules/views/src/Plugin/views/area/TextCustom.php
+++ b/core/modules/views/src/Plugin/views/area/TextCustom.php
@@ -18,7 +18,7 @@ class TextCustom extends TokenizeAreaPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['content'] = array('default' => '');
+ $options['content'] = ['default' => ''];
return $options;
}
@@ -28,12 +28,12 @@ class TextCustom extends TokenizeAreaPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['content'] = array(
+ $form['content'] = [
'#title' => $this->t('Content'),
'#type' => 'textarea',
'#default_value' => $this->options['content'],
'#rows' => 6,
- );
+ ];
}
/**
@@ -41,12 +41,12 @@ class TextCustom extends TokenizeAreaPluginBase {
*/
public function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
- return array(
+ return [
'#markup' => $this->renderTextarea($this->options['content']),
- );
+ ];
}
- return array();
+ return [];
}
/**
diff --git a/core/modules/views/src/Plugin/views/area/Title.php b/core/modules/views/src/Plugin/views/area/Title.php
index 85e4788167a..d6139e0a104 100644
--- a/core/modules/views/src/Plugin/views/area/Title.php
+++ b/core/modules/views/src/Plugin/views/area/Title.php
@@ -18,7 +18,7 @@ class Title extends AreaPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['title'] = array('default' => '');
+ $options['title'] = ['default' => ''];
return $options;
}
@@ -28,12 +28,12 @@ class Title extends AreaPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['title'] = array(
+ $form['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Overridden title'),
'#default_value' => $this->options['title'],
'#description' => $this->t('Override the title of this view when it is empty. The available global tokens below can be used here.'),
- );
+ ];
// Don't use the AreaPluginBase tokenForm method, we don't want row tokens.
$this->globalTokenForm($form, $form_state);
@@ -57,7 +57,7 @@ class Title extends AreaPluginBase {
*/
public function render($empty = FALSE) {
// Do nothing for this handler by returning an empty render array.
- return array();
+ return [];
}
}
diff --git a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
index e8833787c9a..1e0047976c7 100644
--- a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
+++ b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
@@ -21,7 +21,7 @@ abstract class TokenizeAreaPluginBase extends AreaPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['tokenize'] = array('default' => FALSE);
+ $options['tokenize'] = ['default' => FALSE];
return $options;
}
@@ -39,14 +39,14 @@ abstract class TokenizeAreaPluginBase extends AreaPluginBase {
* Adds tokenization form elements.
*/
public function tokenForm(&$form, FormStateInterface $form_state) {
- $form['tokenize'] = array(
+ $form['tokenize'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use replacement tokens from the first row'),
'#default_value' => $this->options['tokenize'],
- );
+ ];
// Get a list of the available fields and arguments for token replacement.
- $options = array();
+ $options = [];
$optgroup_arguments = (string) t('Arguments');
$optgroup_fields = (string) t('Fields');
foreach ($this->view->display_handler->getHandlers('field') as $field => $handler) {
@@ -54,35 +54,35 @@ abstract class TokenizeAreaPluginBase extends AreaPluginBase {
}
foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
- $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel()));
- $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel()));
+ $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
+ $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
}
if (!empty($options)) {
- $form['tokens'] = array(
+ $form['tokens'] = [
'#type' => 'details',
'#title' => $this->t('Replacement patterns'),
'#open' => TRUE,
'#id' => 'edit-options-token-help',
- '#states' => array(
- 'visible' => array(
- ':input[name="options[tokenize]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['tokens']['help'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[tokenize]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['tokens']['help'] = [
'#markup' => '<p>' . $this->t('The following tokens are available. You may use Twig syntax in this field.') . '</p>',
- );
+ ];
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
- $items = array();
+ $items = [];
foreach ($options[$type] as $key => $value) {
$items[] = $key . ' == ' . $value;
}
- $form['tokens'][$type]['tokens'] = array(
+ $form['tokens'][$type]['tokens'] = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
}
}
}
diff --git a/core/modules/views/src/Plugin/views/area/View.php b/core/modules/views/src/Plugin/views/area/View.php
index 12f417cf279..832e23185dd 100644
--- a/core/modules/views/src/Plugin/views/area/View.php
+++ b/core/modules/views/src/Plugin/views/area/View.php
@@ -66,8 +66,8 @@ class View extends AreaPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['view_to_insert'] = array('default' => '');
- $options['inherit_arguments'] = array('default' => FALSE);
+ $options['view_to_insert'] = ['default' => ''];
+ $options['inherit_arguments'] = ['default' => FALSE];
return $options;
}
@@ -79,22 +79,22 @@ class View extends AreaPluginBase {
$view_display = $this->view->storage->id() . ':' . $this->view->current_display;
- $options = array('' => $this->t('-Select-'));
+ $options = ['' => $this->t('-Select-')];
$options += Views::getViewsAsOptions(FALSE, 'all', $view_display, FALSE, TRUE);
- $form['view_to_insert'] = array(
+ $form['view_to_insert'] = [
'#type' => 'select',
'#title' => $this->t('View to insert'),
'#default_value' => $this->options['view_to_insert'],
'#description' => $this->t('The view to insert into this area.'),
'#options' => $options,
- );
+ ];
- $form['inherit_arguments'] = array(
+ $form['inherit_arguments'] = [
'#type' => 'checkbox',
'#title' => $this->t('Inherit contextual filters'),
'#default_value' => $this->options['inherit_arguments'],
'#description' => $this->t('If checked, this view will receive the same contextual filters as its parent.'),
- );
+ ];
}
/**
@@ -107,7 +107,7 @@ class View extends AreaPluginBase {
$view = $this->viewStorage->load($view_name)->getExecutable();
if (empty($view) || !$view->access($display_id)) {
- return array();
+ return [];
}
$view->setDisplay($display_id);
@@ -118,7 +118,7 @@ class View extends AreaPluginBase {
// Check if the view is part of the parent views of this view
$search = "$view_name:$display_id";
if (in_array($search, $this->view->parent_views)) {
- drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $display_id)), 'error');
+ drupal_set_message(t("Recursion detected in view @view display @display.", ['@view' => $view_name, '@display' => $display_id]), 'error');
}
else {
if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
@@ -131,7 +131,7 @@ class View extends AreaPluginBase {
return $output;
}
}
- return array();
+ return [];
}
/**
diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
index 6b8105b106c..6a9632f4eaa 100644
--- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
+++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
@@ -116,35 +116,35 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
protected function defineOptions() {
$options = parent::defineOptions();
- $options['default_action'] = array('default' => 'ignore');
- $options['exception'] = array(
- 'contains' => array(
- 'value' => array('default' => 'all'),
- 'title_enable' => array('default' => FALSE),
- 'title' => array('default' => 'All'),
- ),
- );
- $options['title_enable'] = array('default' => FALSE);
- $options['title'] = array('default' => '');
- $options['default_argument_type'] = array('default' => 'fixed');
- $options['default_argument_options'] = array('default' => array());
- $options['default_argument_skip_url'] = array('default' => FALSE);
- $options['summary_options'] = array('default' => array());
- $options['summary'] = array(
- 'contains' => array(
- 'sort_order' => array('default' => 'asc'),
- 'number_of_records' => array('default' => 0),
- 'format' => array('default' => 'default_summary'),
- ),
- );
- $options['specify_validation'] = array('default' => FALSE);
- $options['validate'] = array(
- 'contains' => array(
- 'type' => array('default' => 'none'),
- 'fail' => array('default' => 'not found'),
- ),
- );
- $options['validate_options'] = array('default' => array());
+ $options['default_action'] = ['default' => 'ignore'];
+ $options['exception'] = [
+ 'contains' => [
+ 'value' => ['default' => 'all'],
+ 'title_enable' => ['default' => FALSE],
+ 'title' => ['default' => 'All'],
+ ],
+ ];
+ $options['title_enable'] = ['default' => FALSE];
+ $options['title'] = ['default' => ''];
+ $options['default_argument_type'] = ['default' => 'fixed'];
+ $options['default_argument_options'] = ['default' => []];
+ $options['default_argument_skip_url'] = ['default' => FALSE];
+ $options['summary_options'] = ['default' => []];
+ $options['summary'] = [
+ 'contains' => [
+ 'sort_order' => ['default' => 'asc'],
+ 'number_of_records' => ['default' => 0],
+ 'format' => ['default' => 'default_summary'],
+ ],
+ ];
+ $options['specify_validation'] = ['default' => FALSE];
+ $options['validate'] = [
+ 'contains' => [
+ 'type' => ['default' => 'none'],
+ 'fail' => ['default' => 'not found'],
+ ],
+ ];
+ $options['validate_options'] = ['default' => []];
return $options;
}
@@ -154,68 +154,68 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
$argument_text = $this->view->display_handler->getArgumentText();
- $form['#pre_render'][] = array(get_class($this), 'preRenderMoveArgumentOptions');
+ $form['#pre_render'][] = [get_class($this), 'preRenderMoveArgumentOptions'];
- $form['description'] = array(
+ $form['description'] = [
'#markup' => $argument_text['description'],
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('description')),
- );
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['description']],
+ ];
- $form['no_argument'] = array(
+ $form['no_argument'] = [
'#type' => 'details',
'#title' => $argument_text['filter value not present'],
'#open' => TRUE,
- );
+ ];
// Everything in the details is floated, so the last element needs to
// clear those floats.
- $form['no_argument']['clearfix'] = array(
+ $form['no_argument']['clearfix'] = [
'#weight' => 1000,
'#markup' => '<div class="clearfix"></div>',
- );
- $form['default_action'] = array(
+ ];
+ $form['default_action'] = [
'#title' => $this->t('Default actions'),
'#title_display' => 'invisible',
'#type' => 'radios',
- '#process' => array(array($this, 'processContainerRadios')),
+ '#process' => [[$this, 'processContainerRadios']],
'#default_value' => $this->options['default_action'],
'#fieldset' => 'no_argument',
- );
+ ];
- $form['exception'] = array(
+ $form['exception'] = [
'#type' => 'details',
'#title' => $this->t('Exceptions'),
'#fieldset' => 'no_argument',
- );
- $form['exception']['value'] = array(
+ ];
+ $form['exception']['value'] = [
'#type' => 'textfield',
'#title' => $this->t('Exception value'),
'#size' => 20,
'#default_value' => $this->options['exception']['value'],
'#description' => $this->t('If this value is received, the filter will be ignored; i.e, "all values"'),
- );
- $form['exception']['title_enable'] = array(
+ ];
+ $form['exception']['title_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Override title'),
'#default_value' => $this->options['exception']['title_enable'],
- );
- $form['exception']['title'] = array(
+ ];
+ $form['exception']['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Override title'),
'#title_display' => 'invisible',
'#size' => 20,
'#default_value' => $this->options['exception']['title'],
'#description' => $this->t('Override the view and other argument titles. You may use Twig syntax in this field as well as the "arguments" and "raw_arguments" arrays.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[exception][title_enable]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $options = array();
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[exception][title_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $options = [];
$defaults = $this->defaultActions();
- $validate_options = array();
+ $validate_options = [];
foreach ($defaults as $id => $info) {
$options[$id] = $info['title'];
if (empty($info['default only'])) {
@@ -227,30 +227,30 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
}
$form['default_action']['#options'] = $options;
- $form['argument_present'] = array(
+ $form['argument_present'] = [
'#type' => 'details',
'#title' => $argument_text['filter value present'],
'#open' => TRUE,
- );
- $form['title_enable'] = array(
+ ];
+ $form['title_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Override title'),
'#default_value' => $this->options['title_enable'],
'#fieldset' => 'argument_present',
- );
- $form['title'] = array(
+ ];
+ $form['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Provide title'),
'#title_display' => 'invisible',
'#default_value' => $this->options['title'],
'#description' => $this->t('Override the view and other argument titles. You may use Twig syntax in this field.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[title_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[title_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'argument_present',
- );
+ ];
$output = $this->getTokenHelp();
$form['token_help'] = [
@@ -269,29 +269,29 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
],
];
- $form['specify_validation'] = array(
+ $form['specify_validation'] = [
'#type' => 'checkbox',
'#title' => $this->t('Specify validation criteria'),
'#default_value' => $this->options['specify_validation'],
'#fieldset' => 'argument_present',
- );
+ ];
- $form['validate'] = array(
+ $form['validate'] = [
'#type' => 'container',
'#fieldset' => 'argument_present',
- );
+ ];
// Validator options include derivatives with :. These are sanitized for js
// and reverted on submission.
- $form['validate']['type'] = array(
+ $form['validate']['type'] = [
'#type' => 'select',
'#title' => $this->t('Validator'),
'#default_value' => static::encodeValidatorId($this->options['validate']['type']),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[specify_validation]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[specify_validation]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
$plugins = Views::pluginManager('argument_validator')->getDefinitions();
foreach ($plugins as $id => $info) {
@@ -320,21 +320,21 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
if ($plugin->access() || $this->options['validate']['type'] == $id) {
// Sanitize ID for js.
$sanitized_id = static::encodeValidatorId($id);
- $form['validate']['options'][$sanitized_id] = array(
+ $form['validate']['options'][$sanitized_id] = [
'#prefix' => '<div id="edit-options-validate-options-' . $sanitized_id . '-wrapper">',
'#suffix' => '</div>',
'#type' => 'item',
// Even if the plugin has no options add the key to the form_state.
'#input' => TRUE, // trick it into checking input to make #process run
- '#states' => array(
- 'visible' => array(
- ':input[name="options[specify_validation]"]' => array('checked' => TRUE),
- ':input[name="options[validate][type]"]' => array('value' => $sanitized_id),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[specify_validation]"]' => ['checked' => TRUE],
+ ':input[name="options[validate][type]"]' => ['value' => $sanitized_id],
+ ],
+ ],
'#id' => 'edit-options-validate-options-' . $sanitized_id,
- '#default_value' => array(),
- );
+ '#default_value' => [],
+ ];
$plugin->buildOptionsForm($form['validate']['options'][$sanitized_id], $form_state);
$validate_types[$sanitized_id] = $info['title'];
}
@@ -345,18 +345,18 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
asort($validate_types);
$form['validate']['type']['#options'] = $validate_types;
- $form['validate']['fail'] = array(
+ $form['validate']['fail'] = [
'#type' => 'select',
'#title' => $this->t('Action to take if filter value does not validate'),
'#default_value' => $this->options['validate']['fail'],
'#options' => $validate_options,
- '#states' => array(
- 'visible' => array(
- ':input[name="options[specify_validation]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[specify_validation]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'argument_present',
- );
+ ];
}
/**
@@ -370,8 +370,8 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
/** @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase $handler */
- $options[(string) t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel()));
- $options[(string) t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel()));
+ $options[(string) t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
+ $options[(string) t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
}
// We have some options, so make a list.
@@ -381,14 +381,14 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
];
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
- $items = array();
+ $items = [];
foreach ($options[$type] as $key => $value) {
$items[] = $key . ' == ' . $value;
}
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
$output[] = $item_list;
}
}
@@ -488,38 +488,38 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
* Override this method to provide additional (or fewer) default behaviors.
*/
protected function defaultActions($which = NULL) {
- $defaults = array(
- 'ignore' => array(
+ $defaults = [
+ 'ignore' => [
'title' => $this->t('Display all results for the specified field'),
'method' => 'defaultIgnore',
- ),
- 'default' => array(
+ ],
+ 'default' => [
'title' => $this->t('Provide default value'),
'method' => 'defaultDefault',
'form method' => 'defaultArgumentForm',
'has default argument' => TRUE,
'default only' => TRUE, // this can only be used for missing argument, not validation failure
- ),
- 'not found' => array(
+ ],
+ 'not found' => [
'title' => $this->t('Hide view'),
'method' => 'defaultNotFound',
'hard fail' => TRUE, // This is a hard fail condition
- ),
- 'summary' => array(
+ ],
+ 'summary' => [
'title' => $this->t('Display a summary'),
'method' => 'defaultSummary',
'form method' => 'defaultSummaryForm',
'style plugin' => TRUE,
- ),
- 'empty' => array(
+ ],
+ 'empty' => [
'title' => $this->t('Display contents of "No results found"'),
'method' => 'defaultEmpty',
- ),
- 'access denied' => array(
+ ],
+ 'access denied' => [
'title' => $this->t('Display "Access Denied"'),
'method' => 'defaultAccessDenied',
- ),
- );
+ ],
+ ];
if ($this->view->display_handler->hasPath()) {
$defaults['not found']['title'] = $this->t('Show "Page not found"');
@@ -541,31 +541,31 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
*/
public function defaultArgumentForm(&$form, FormStateInterface $form_state) {
$plugins = Views::pluginManager('argument_default')->getDefinitions();
- $options = array();
+ $options = [];
- $form['default_argument_skip_url'] = array(
+ $form['default_argument_skip_url'] = [
'#type' => 'checkbox',
'#title' => $this->t('Skip default argument for view URL'),
'#default_value' => $this->options['default_argument_skip_url'],
'#description' => $this->t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.')
- );
+ ];
- $form['default_argument_type'] = array(
+ $form['default_argument_type'] = [
'#prefix' => '<div id="edit-options-default-argument-type-wrapper">',
'#suffix' => '</div>',
'#type' => 'select',
'#id' => 'edit-options-default-argument-type',
'#title' => $this->t('Type'),
'#default_value' => $this->options['default_argument_type'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'default'),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[default_action]"]' => ['value' => 'default'],
+ ],
+ ],
// Views custom key, moves this element to the appropriate container
// under the radio button.
'#argument_option' => 'default',
- );
+ ];
foreach ($plugins as $id => $info) {
if (!empty($info['no_ui'])) {
@@ -575,21 +575,21 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
if ($plugin) {
if ($plugin->access() || $this->options['default_argument_type'] == $id) {
$form['argument_default']['#argument_option'] = 'default';
- $form['argument_default'][$id] = array(
+ $form['argument_default'][$id] = [
'#prefix' => '<div id="edit-options-argument-default-options-' . $id . '-wrapper">',
'#suffix' => '</div>',
'#id' => 'edit-options-argument-default-options-' . $id,
'#type' => 'item',
// Even if the plugin has no options add the key to the form_state.
'#input' => TRUE,
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'default'),
- ':input[name="options[default_argument_type]"]' => array('value' => $id),
- ),
- ),
- '#default_value' => array(),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[default_action]"]' => ['value' => 'default'],
+ ':input[name="options[default_argument_type]"]' => ['value' => $id],
+ ],
+ ],
+ '#default_value' => [],
+ ];
$options[$id] = $info['title'];
$plugin->buildOptionsForm($form['argument_default'][$id], $form_state);
}
@@ -606,8 +606,8 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
*/
public function defaultSummaryForm(&$form, FormStateInterface $form_state) {
$style_plugins = Views::pluginManager('style')->getDefinitions();
- $summary_plugins = array();
- $format_options = array();
+ $summary_plugins = [];
+ $format_options = [];
foreach ($style_plugins as $key => $plugin) {
if (isset($plugin['display_types']) && in_array('summary', $plugin['display_types'])) {
$summary_plugins[$key] = $plugin;
@@ -615,48 +615,48 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
}
}
- $form['summary'] = array(
+ $form['summary'] = [
// Views custom key, moves this element to the appropriate container
// under the radio button.
'#argument_option' => 'summary',
- );
- $form['summary']['sort_order'] = array(
+ ];
+ $form['summary']['sort_order'] = [
'#type' => 'radios',
'#title' => $this->t('Sort order'),
- '#options' => array('asc' => $this->t('Ascending'), 'desc' => $this->t('Descending')),
+ '#options' => ['asc' => $this->t('Ascending'), 'desc' => $this->t('Descending')],
'#default_value' => $this->options['summary']['sort_order'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'summary'),
- ),
- ),
- );
- $form['summary']['number_of_records'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[default_action]"]' => ['value' => 'summary'],
+ ],
+ ],
+ ];
+ $form['summary']['number_of_records'] = [
'#type' => 'radios',
'#title' => $this->t('Sort by'),
'#default_value' => $this->options['summary']['number_of_records'],
- '#options' => array(
+ '#options' => [
0 => $this->getSortName(),
1 => $this->t('Number of records')
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'summary'),
- ),
- ),
- );
-
- $form['summary']['format'] = array(
+ ],
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[default_action]"]' => ['value' => 'summary'],
+ ],
+ ],
+ ];
+
+ $form['summary']['format'] = [
'#type' => 'radios',
'#title' => $this->t('Format'),
'#options' => $format_options,
'#default_value' => $this->options['summary']['format'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'summary'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[default_action]"]' => ['value' => 'summary'],
+ ],
+ ],
+ ];
foreach ($summary_plugins as $id => $info) {
$plugin = $this->getPlugin('style', $id);
@@ -664,20 +664,20 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
continue;
}
if ($plugin) {
- $form['summary']['options'][$id] = array(
+ $form['summary']['options'][$id] = [
'#prefix' => '<div id="edit-options-summary-options-' . $id . '-wrapper">',
'#suffix' => '</div>',
'#id' => 'edit-options-summary-options-' . $id,
'#type' => 'item',
'#input' => TRUE, // trick it into checking input to make #process run
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'summary'),
- ':input[name="options[summary][format]"]' => array('value' => $id),
- ),
- ),
- '#default_value' => array(),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[default_action]"]' => ['value' => 'summary'],
+ ':input[name="options[summary][format]"]' => ['value' => $id],
+ ],
+ ],
+ '#default_value' => [],
+ ];
$options[$id] = $info['title'];
$plugin->buildOptionsForm($form['summary']['options'][$id], $form_state);
}
@@ -703,7 +703,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
}
if (!empty($info['method args'])) {
- return call_user_func_array(array(&$this, $info['method']), $info['method args']);
+ return call_user_func_array([&$this, $info['method']], $info['method args']);
}
else {
return $this->{$info['method']}();
@@ -760,7 +760,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
// We return with no query; this will force the empty text.
$this->view->built = TRUE;
$this->view->executed = TRUE;
- $this->view->result = array();
+ $this->view->result = [];
return FALSE;
}
@@ -897,7 +897,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
// Add the number of nodes counter
$distinct = ($this->view->display_handler->getOption('distinct') && empty($this->query->no_distinct));
- $count_alias = $this->query->addField($this->view->storage->get('base_table'), $this->view->storage->get('base_field'), 'num_records', array('count' => TRUE, 'distinct' => $distinct));
+ $count_alias = $this->query->addField($this->view->storage->get('base_table'), $this->view->storage->get('base_field'), 'num_records', ['count' => TRUE, 'distinct' => $distinct]);
$this->query->addGroupBy($this->name_alias);
if ($count_field) {
@@ -1074,7 +1074,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
* Get the display or row plugin, if it exists.
*/
public function getPlugin($type = 'argument_default', $name = NULL) {
- $options = array();
+ $options = [];
switch ($type) {
case 'argument_default':
if (!isset($this->options['default_argument_type'])) {
@@ -1127,7 +1127,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
* their argument is (e.g. alphabetical, numeric, date).
*/
public function getSortName() {
- return $this->t('Default sort', array(), array('context' => 'Sort order'));
+ return $this->t('Default sort', [], ['context' => 'Sort order']);
}
/**
@@ -1142,12 +1142,12 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
public static function processContainerRadios($element) {
if (count($element['#options']) > 0) {
foreach ($element['#options'] as $key => $choice) {
- $element += array($key => array());
+ $element += [$key => []];
// Generate the parents as the autogenerator does, so we will have a
// unique id for each radio button.
- $parents_for_id = array_merge($element['#parents'], array($key));
+ $parents_for_id = array_merge($element['#parents'], [$key]);
- $element[$key] += array(
+ $element[$key] += [
'#type' => 'radio',
'#title' => $choice,
// The key is sanitized in drupal_attributes() during output from the
@@ -1158,11 +1158,11 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
'#parents' => $element['#parents'],
'#id' => Html::getUniqueId('edit-' . implode('-', $parents_for_id)),
'#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
- );
- $element[$key . '_options'] = array(
+ ];
+ $element[$key . '_options'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('views-admin-dependent')),
- );
+ '#attributes' => ['class' => ['views-admin-dependent']],
+ ];
}
}
return $element;
diff --git a/core/modules/views/src/Plugin/views/argument/Date.php b/core/modules/views/src/Plugin/views/argument/Date.php
index 8d1dd4010bb..a751d561b7d 100644
--- a/core/modules/views/src/Plugin/views/argument/Date.php
+++ b/core/modules/views/src/Plugin/views/argument/Date.php
@@ -85,9 +85,9 @@ class Date extends Formula implements ContainerFactoryPluginInterface {
*/
public function defaultArgumentForm(&$form, FormStateInterface $form_state) {
parent::defaultArgumentForm($form, $form_state);
- $form['default_argument_type']['#options'] += array('date' => $this->t('Current date'));
- $form['default_argument_type']['#options'] += array('node_created' => $this->t("Current node's creation time"));
- $form['default_argument_type']['#options'] += array('node_changed' => $this->t("Current node's update time"));
+ $form['default_argument_type']['#options'] += ['date' => $this->t('Current date')];
+ $form['default_argument_type']['#options'] += ['node_created' => $this->t("Current node's creation time")];
+ $form['default_argument_type']['#options'] += ['node_changed' => $this->t("Current node's update time")];
}
/**
@@ -98,7 +98,7 @@ class Date extends Formula implements ContainerFactoryPluginInterface {
if (!$raw && $this->options['default_argument_type'] == 'date') {
return date($this->argFormat, REQUEST_TIME);
}
- elseif (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) {
+ elseif (!$raw && in_array($this->options['default_argument_type'], ['node_created', 'node_changed'])) {
$node = $this->routeMatch->getParameter('node');
if (!($node instanceof NodeInterface)) {
@@ -119,7 +119,7 @@ class Date extends Formula implements ContainerFactoryPluginInterface {
* {@inheritdoc}
*/
public function getSortName() {
- return $this->t('Date', array(), array('context' => 'Sort order'));
+ return $this->t('Date', [], ['context' => 'Sort order']);
}
/**
diff --git a/core/modules/views/src/Plugin/views/argument/Formula.php b/core/modules/views/src/Plugin/views/argument/Formula.php
index a80074c6b77..83b33782222 100644
--- a/core/modules/views/src/Plugin/views/argument/Formula.php
+++ b/core/modules/views/src/Plugin/views/argument/Formula.php
@@ -59,9 +59,9 @@ class Formula extends ArgumentPluginBase {
// Now that our table is secure, get our formula.
$placeholder = $this->placeholder();
$formula = $this->getFormula() . ' = ' . $placeholder;
- $placeholders = array(
+ $placeholders = [
$placeholder => $this->argument,
- );
+ ];
$this->query->addWhere(0, $formula, $placeholders, 'formula');
}
diff --git a/core/modules/views/src/Plugin/views/argument/GroupByNumeric.php b/core/modules/views/src/Plugin/views/argument/GroupByNumeric.php
index 1e7ba38862f..64be23ef865 100644
--- a/core/modules/views/src/Plugin/views/argument/GroupByNumeric.php
+++ b/core/modules/views/src/Plugin/views/argument/GroupByNumeric.php
@@ -16,7 +16,7 @@ class GroupByNumeric extends ArgumentPluginBase {
$field = $this->getField();
$placeholder = $this->placeholder();
- $this->query->addHavingExpression(0, "$field = $placeholder", array($placeholder => $this->argument));
+ $this->query->addHavingExpression(0, "$field = $placeholder", [$placeholder => $this->argument]);
}
public function adminLabel($short = FALSE) {
@@ -27,7 +27,7 @@ class GroupByNumeric extends ArgumentPluginBase {
* {@inheritdoc}
*/
public function getSortName() {
- return $this->t('Numerical', array(), array('context' => 'Sort order'));
+ return $this->t('Numerical', [], ['context' => 'Sort order']);
}
}
diff --git a/core/modules/views/src/Plugin/views/argument/ManyToOne.php b/core/modules/views/src/Plugin/views/argument/ManyToOne.php
index 48385d532e4..f0bd9ba68e7 100644
--- a/core/modules/views/src/Plugin/views/argument/ManyToOne.php
+++ b/core/modules/views/src/Plugin/views/argument/ManyToOne.php
@@ -34,18 +34,18 @@ class ManyToOne extends ArgumentPluginBase {
// Ensure defaults for these, during summaries and stuff:
$this->operator = 'or';
- $this->value = array();
+ $this->value = [];
}
protected function defineOptions() {
$options = parent::defineOptions();
if (!empty($this->definition['numeric'])) {
- $options['break_phrase'] = array('default' => FALSE);
+ $options['break_phrase'] = ['default' => FALSE];
}
- $options['add_table'] = array('default' => FALSE);
- $options['require_value'] = array('default' => FALSE);
+ $options['add_table'] = ['default' => FALSE];
+ $options['require_value'] = ['default' => FALSE];
if (isset($this->helper)) {
$this->helper->defineOptions($options);
@@ -62,28 +62,28 @@ class ManyToOne extends ArgumentPluginBase {
parent::buildOptionsForm($form, $form_state);
// allow + for or, , for and
- $form['break_phrase'] = array(
+ $form['break_phrase'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple values'),
'#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'),
'#default_value' => !empty($this->options['break_phrase']),
'#group' => 'options][more',
- );
+ ];
- $form['add_table'] = array(
+ $form['add_table'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple filter values to work together'),
'#description' => $this->t('If selected, multiple instances of this filter can work together, as though multiple values were supplied to the same filter. This setting is not compatible with the "Reduce duplicates" setting.'),
'#default_value' => !empty($this->options['add_table']),
'#group' => 'options][more',
- );
+ ];
- $form['require_value'] = array(
+ $form['require_value'] = [
'#type' => 'checkbox',
'#title' => $this->t('Do not display items with no value in summary'),
'#default_value' => !empty($this->options['require_value']),
'#group' => 'options][more',
- );
+ ];
$this->helper->buildOptionsForm($form, $form_state);
}
@@ -119,7 +119,7 @@ class ManyToOne extends ArgumentPluginBase {
$this->unpackArgumentValue($force_int);
}
else {
- $this->value = array($this->argument);
+ $this->value = [$this->argument];
$this->operator = 'or';
}
@@ -136,7 +136,7 @@ class ManyToOne extends ArgumentPluginBase {
$this->unpackArgumentValue($force_int);
}
else {
- $this->value = array($this->argument);
+ $this->value = [$this->argument];
$this->operator = 'or';
}
@@ -146,7 +146,7 @@ class ManyToOne extends ArgumentPluginBase {
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : $this->t('Uncategorized');
}
- if ($this->value === array(-1)) {
+ if ($this->value === [-1]) {
return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : $this->t('Invalid input');
}
diff --git a/core/modules/views/src/Plugin/views/argument/NullArgument.php b/core/modules/views/src/Plugin/views/argument/NullArgument.php
index 181fb33c7b7..7fadf1688d3 100644
--- a/core/modules/views/src/Plugin/views/argument/NullArgument.php
+++ b/core/modules/views/src/Plugin/views/argument/NullArgument.php
@@ -15,7 +15,7 @@ class NullArgument extends ArgumentPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['must_not_be'] = array('default' => FALSE);
+ $options['must_not_be'] = ['default' => FALSE];
return $options;
}
@@ -25,13 +25,13 @@ class NullArgument extends ArgumentPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['must_not_be'] = array(
+ $form['must_not_be'] = [
'#type' => 'checkbox',
'#title' => $this->t('Fail basic validation if any argument is given'),
'#default_value' => !empty($this->options['must_not_be']),
'#description' => $this->t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),
'#group' => 'options][more',
- );
+ ];
unset($form['exception']);
}
@@ -42,7 +42,7 @@ class NullArgument extends ArgumentPluginBase {
*/
protected function defaultActions($which = NULL) {
if ($which) {
- if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
+ if (in_array($which, ['ignore', 'not found', 'empty', 'default'])) {
return parent::defaultActions($which);
}
return;
diff --git a/core/modules/views/src/Plugin/views/argument/NumericArgument.php b/core/modules/views/src/Plugin/views/argument/NumericArgument.php
index c2a82936601..188d8e9bd68 100644
--- a/core/modules/views/src/Plugin/views/argument/NumericArgument.php
+++ b/core/modules/views/src/Plugin/views/argument/NumericArgument.php
@@ -30,8 +30,8 @@ class NumericArgument extends ArgumentPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['break_phrase'] = array('default' => FALSE);
- $options['not'] = array('default' => FALSE);
+ $options['break_phrase'] = ['default' => FALSE];
+ $options['not'] = ['default' => FALSE];
return $options;
}
@@ -40,21 +40,21 @@ class NumericArgument extends ArgumentPluginBase {
parent::buildOptionsForm($form, $form_state);
// allow + for or, , for and
- $form['break_phrase'] = array(
+ $form['break_phrase'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple values'),
'#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'),
'#default_value' => !empty($this->options['break_phrase']),
'#group' => 'options][more',
- );
+ ];
- $form['not'] = array(
+ $form['not'] = [
'#type' => 'checkbox',
'#title' => $this->t('Exclude'),
'#description' => $this->t('If selected, the numbers entered for the filter will be excluded rather than limiting the view.'),
'#default_value' => !empty($this->options['not']),
'#group' => 'options][more',
- );
+ ];
}
function title() {
@@ -68,7 +68,7 @@ class NumericArgument extends ArgumentPluginBase {
$this->operator = $break->operator;
}
else {
- $this->value = array($this->argument);
+ $this->value = [$this->argument];
$this->operator = 'or';
}
@@ -76,7 +76,7 @@ class NumericArgument extends ArgumentPluginBase {
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : $this->t('Uncategorized');
}
- if ($this->value === array(-1)) {
+ if ($this->value === [-1]) {
return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : $this->t('Invalid input');
}
@@ -101,7 +101,7 @@ class NumericArgument extends ArgumentPluginBase {
$this->operator = $break->operator;
}
else {
- $this->value = array($this->argument);
+ $this->value = [$this->argument];
}
$placeholder = $this->placeholder();
@@ -110,11 +110,11 @@ class NumericArgument extends ArgumentPluginBase {
if (count($this->value) > 1) {
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
$placeholder .= '[]';
- $this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator($placeholder) $null_check", array($placeholder => $this->value));
+ $this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator($placeholder) $null_check", [$placeholder => $this->value]);
}
else {
$operator = empty($this->options['not']) ? '=' : '!=';
- $this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator $placeholder $null_check", array($placeholder => $this->argument));
+ $this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator $placeholder $null_check", [$placeholder => $this->argument]);
}
}
@@ -122,7 +122,7 @@ class NumericArgument extends ArgumentPluginBase {
* {@inheritdoc}
*/
public function getSortName() {
- return $this->t('Numerical', array(), array('context' => 'Sort order'));
+ return $this->t('Numerical', [], ['context' => 'Sort order']);
}
/**
diff --git a/core/modules/views/src/Plugin/views/argument/StringArgument.php b/core/modules/views/src/Plugin/views/argument/StringArgument.php
index e138c1d2725..0948c676461 100644
--- a/core/modules/views/src/Plugin/views/argument/StringArgument.php
+++ b/core/modules/views/src/Plugin/views/argument/StringArgument.php
@@ -31,23 +31,23 @@ class StringArgument extends ArgumentPluginBase {
// Ensure defaults for these, during summaries and stuff:
$this->operator = 'or';
- $this->value = array();
+ $this->value = [];
}
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['glossary'] = array('default' => FALSE);
- $options['limit'] = array('default' => 0);
- $options['case'] = array('default' => 'none');
- $options['path_case'] = array('default' => 'none');
- $options['transform_dash'] = array('default' => FALSE);
- $options['break_phrase'] = array('default' => FALSE);
+ $options['glossary'] = ['default' => FALSE];
+ $options['limit'] = ['default' => 0];
+ $options['case'] = ['default' => 'none'];
+ $options['path_case'] = ['default' => 'none'];
+ $options['transform_dash'] = ['default' => FALSE];
+ $options['break_phrase'] = ['default' => FALSE];
if (!empty($this->definition['many to one'])) {
- $options['add_table'] = array('default' => FALSE);
- $options['require_value'] = array('default' => FALSE);
+ $options['add_table'] = ['default' => FALSE];
+ $options['require_value'] = ['default' => FALSE];
}
return $options;
@@ -56,89 +56,89 @@ class StringArgument extends ArgumentPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['glossary'] = array(
+ $form['glossary'] = [
'#type' => 'checkbox',
'#title' => $this->t('Glossary mode'),
'#description' => $this->t('Glossary mode applies a limit to the number of characters used in the filter value, which allows the summary view to act as a glossary.'),
'#default_value' => $this->options['glossary'],
'#group' => 'options][more',
- );
+ ];
- $form['limit'] = array(
+ $form['limit'] = [
'#type' => 'textfield',
'#title' => $this->t('Character limit'),
'#description' => $this->t('How many characters of the filter value to filter against. If set to 1, all fields starting with the first letter in the filter value would be matched.'),
'#default_value' => $this->options['limit'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[glossary]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[glossary]"]' => ['checked' => TRUE],
+ ],
+ ],
'#group' => 'options][more',
- );
+ ];
- $form['case'] = array(
+ $form['case'] = [
'#type' => 'select',
'#title' => $this->t('Case'),
'#description' => $this->t('When printing the title and summary, how to transform the case of the filter value.'),
- '#options' => array(
+ '#options' => [
'none' => $this->t('No transform'),
'upper' => $this->t('Upper case'),
'lower' => $this->t('Lower case'),
'ucfirst' => $this->t('Capitalize first letter'),
'ucwords' => $this->t('Capitalize each word'),
- ),
+ ],
'#default_value' => $this->options['case'],
'#group' => 'options][more',
- );
+ ];
- $form['path_case'] = array(
+ $form['path_case'] = [
'#type' => 'select',
'#title' => $this->t('Case in path'),
'#description' => $this->t('When printing URL paths, how to transform the case of the filter value. Do not use this unless with Postgres as it uses case sensitive comparisons.'),
- '#options' => array(
+ '#options' => [
'none' => $this->t('No transform'),
'upper' => $this->t('Upper case'),
'lower' => $this->t('Lower case'),
'ucfirst' => $this->t('Capitalize first letter'),
'ucwords' => $this->t('Capitalize each word'),
- ),
+ ],
'#default_value' => $this->options['path_case'],
'#group' => 'options][more',
- );
+ ];
- $form['transform_dash'] = array(
+ $form['transform_dash'] = [
'#type' => 'checkbox',
'#title' => $this->t('Transform spaces to dashes in URL'),
'#default_value' => $this->options['transform_dash'],
'#group' => 'options][more',
- );
+ ];
if (!empty($this->definition['many to one'])) {
- $form['add_table'] = array(
+ $form['add_table'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple filter values to work together'),
'#description' => $this->t('If selected, multiple instances of this filter can work together, as though multiple values were supplied to the same filter. This setting is not compatible with the "Reduce duplicates" setting.'),
'#default_value' => !empty($this->options['add_table']),
'#group' => 'options][more',
- );
+ ];
- $form['require_value'] = array(
+ $form['require_value'] = [
'#type' => 'checkbox',
'#title' => $this->t('Do not display items with no value in summary'),
'#default_value' => !empty($this->options['require_value']),
'#group' => 'options][more',
- );
+ ];
}
// allow + for or, , for and
- $form['break_phrase'] = array(
+ $form['break_phrase'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple values'),
'#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'),
'#default_value' => !empty($this->options['break_phrase']),
'#group' => 'options][more',
- );
+ ];
}
/**
@@ -206,7 +206,7 @@ class StringArgument extends ArgumentPluginBase {
$this->unpackArgumentValue();
}
else {
- $this->value = array($argument);
+ $this->value = [$argument];
$this->operator = 'or';
}
@@ -253,9 +253,9 @@ class StringArgument extends ArgumentPluginBase {
else {
$field .= ' = ' . $placeholder;
}
- $placeholders = array(
+ $placeholders = [
$placeholder => $argument,
- );
+ ];
$this->query->addWhereExpression(0, $field, $placeholders);
}
else {
@@ -275,7 +275,7 @@ class StringArgument extends ArgumentPluginBase {
* {@inheritdoc}
*/
public function getSortName() {
- return $this->t('Alphabetical', array(), array('context' => 'Sort order'));
+ return $this->t('Alphabetical', [], ['context' => 'Sort order']);
}
function title() {
@@ -294,7 +294,7 @@ class StringArgument extends ArgumentPluginBase {
$this->unpackArgumentValue();
}
else {
- $this->value = array($this->argument);
+ $this->value = [$this->argument];
$this->operator = 'or';
}
@@ -302,7 +302,7 @@ class StringArgument extends ArgumentPluginBase {
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : $this->t('Uncategorized');
}
- if ($this->value === array(-1)) {
+ if ($this->value === [-1]) {
return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : $this->t('Invalid input');
}
diff --git a/core/modules/views/src/Plugin/views/argument/WeekDate.php b/core/modules/views/src/Plugin/views/argument/WeekDate.php
index 73cc2055d00..918cfec55b2 100644
--- a/core/modules/views/src/Plugin/views/argument/WeekDate.php
+++ b/core/modules/views/src/Plugin/views/argument/WeekDate.php
@@ -19,7 +19,7 @@ class WeekDate extends Date {
*/
public function summaryName($data) {
$created = $data->{$this->name_alias};
- return $this->t('Week @week', array('@week' => $created));
+ return $this->t('Week @week', ['@week' => $created]);
}
}
diff --git a/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php b/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php
index c3b1c86c5f0..6cea74d4a0d 100644
--- a/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php
+++ b/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php
@@ -58,7 +58,7 @@ abstract class ArgumentDefaultPluginBase extends PluginBase {
* Retrieve the options when this is a new access
* control plugin
*/
- protected function defineOptions() { return array(); }
+ protected function defineOptions() { return []; }
/**
* Provide the default form for setting options.
@@ -73,7 +73,7 @@ abstract class ArgumentDefaultPluginBase extends PluginBase {
/**
* Provide the default form form for submitting options
*/
- public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) { }
+ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) { }
/**
* Determine if the administrator has the privileges to use this
diff --git a/core/modules/views/src/Plugin/views/argument_default/Fixed.php b/core/modules/views/src/Plugin/views/argument_default/Fixed.php
index 317708aad23..da08e561f0f 100644
--- a/core/modules/views/src/Plugin/views/argument_default/Fixed.php
+++ b/core/modules/views/src/Plugin/views/argument_default/Fixed.php
@@ -23,7 +23,7 @@ class Fixed extends ArgumentDefaultPluginBase implements CacheableDependencyInte
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['argument'] = array('default' => '');
+ $options['argument'] = ['default' => ''];
return $options;
}
@@ -33,11 +33,11 @@ class Fixed extends ArgumentDefaultPluginBase implements CacheableDependencyInte
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['argument'] = array(
+ $form['argument'] = [
'#type' => 'textfield',
'#title' => $this->t('Fixed value'),
'#default_value' => $this->options['argument'],
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php b/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php
index e5b5e201a9e..1b45615fd83 100644
--- a/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php
+++ b/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php
@@ -23,9 +23,9 @@ class QueryParameter extends ArgumentDefaultPluginBase implements CacheableDepen
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['query_param'] = array('default' => '');
- $options['fallback'] = array('default' => '');
- $options['multiple'] = array('default' => 'and');
+ $options['query_param'] = ['default' => ''];
+ $options['fallback'] = ['default' => ''];
+ $options['multiple'] = ['default' => 'and'];
return $options;
}
@@ -35,28 +35,28 @@ class QueryParameter extends ArgumentDefaultPluginBase implements CacheableDepen
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['query_param'] = array(
+ $form['query_param'] = [
'#type' => 'textfield',
'#title' => $this->t('Query parameter'),
'#description' => $this->t('The query parameter to use.'),
'#default_value' => $this->options['query_param'],
- );
- $form['fallback'] = array(
+ ];
+ $form['fallback'] = [
'#type' => 'textfield',
'#title' => $this->t('Fallback value'),
'#description' => $this->t('The fallback value to use when the above query parameter is not present.'),
'#default_value' => $this->options['fallback'],
- );
- $form['multiple'] = array(
+ ];
+ $form['multiple'] = [
'#type' => 'radios',
'#title' => $this->t('Multiple values'),
'#description' => $this->t('Conjunction to use when handling multiple values. E.g. "?value[0]=a&value[1]=b".'),
'#default_value' => $this->options['multiple'],
- '#options' => array(
+ '#options' => [
'and' => $this->t('AND'),
'or' => $this->t('OR'),
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/argument_default/Raw.php b/core/modules/views/src/Plugin/views/argument_default/Raw.php
index 8dd32733470..2491bd83c0d 100644
--- a/core/modules/views/src/Plugin/views/argument_default/Raw.php
+++ b/core/modules/views/src/Plugin/views/argument_default/Raw.php
@@ -74,8 +74,8 @@ class Raw extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['index'] = array('default' => '');
- $options['use_alias'] = array('default' => FALSE);
+ $options['index'] = ['default' => ''];
+ $options['use_alias'] = ['default' => FALSE];
return $options;
}
@@ -85,7 +85,7 @@ class Raw extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['index'] = array(
+ $form['index'] = [
'#type' => 'select',
'#title' => $this->t('Path component'),
'#default_value' => $this->options['index'],
@@ -94,13 +94,13 @@ class Raw extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
// - values that count from 1 for display to humans.
'#options' => range(1, 10),
'#description' => $this->t('The numbering starts from 1, e.g. on the page admin/structure/types, the 3rd path component is "types".'),
- );
- $form['use_alias'] = array(
+ ];
+ $form['use_alias'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use path alias'),
'#default_value' => $this->options['use_alias'],
'#description' => $this->t('Use path alias instead of internal path.'),
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
index c1d41d494ab..5f40430d2be 100644
--- a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
+++ b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
@@ -53,7 +53,7 @@ abstract class ArgumentValidatorPluginBase extends PluginBase {
/**
* Retrieves the options when this is a new access control plugin.
*/
- protected function defineOptions() { return array(); }
+ protected function defineOptions() { return []; }
/**
* Provides the default form for setting options.
@@ -68,7 +68,7 @@ abstract class ArgumentValidatorPluginBase extends PluginBase {
/**
* Provides the default form for submitting options.
*/
- public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) { }
+ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) { }
/**
* Determines if the administrator has the privileges to use this plugin.
diff --git a/core/modules/views/src/Plugin/views/argument_validator/Entity.php b/core/modules/views/src/Plugin/views/argument_validator/Entity.php
index 5a963bab35a..896d24bf64c 100644
--- a/core/modules/views/src/Plugin/views/argument_validator/Entity.php
+++ b/core/modules/views/src/Plugin/views/argument_validator/Entity.php
@@ -71,10 +71,10 @@ class Entity extends ArgumentValidatorPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['bundles'] = array('default' => array());
- $options['access'] = array('default' => FALSE);
- $options['operation'] = array('default' => 'view');
- $options['multiple'] = array('default' => FALSE);
+ $options['bundles'] = ['default' => []];
+ $options['access'] = ['default' => FALSE];
+ $options['operation'] = ['default' => 'view'];
+ $options['multiple'] = ['default' => FALSE];
return $options;
}
@@ -93,60 +93,60 @@ class Entity extends ArgumentValidatorPluginBase {
// If the entity has bundles, allow option to restrict to bundle(s).
if ($entity_type->hasKey('bundle')) {
- $bundle_options = array();
+ $bundle_options = [];
foreach ($this->entityManager->getBundleInfo($entity_type_id) as $bundle_id => $bundle_info) {
$bundle_options[$bundle_id] = $bundle_info['label'];
}
- $form['bundles'] = array(
+ $form['bundles'] = [
'#title' => $entity_type->getBundleLabel() ?: $this->t('Bundles'),
'#default_value' => $this->options['bundles'],
'#type' => 'checkboxes',
'#options' => $bundle_options,
'#description' => $this->t('If none are selected, all are allowed.'),
- );
+ ];
}
// Offer the option to filter by access to the entity in the argument.
- $form['access'] = array(
+ $form['access'] = [
'#type' => 'checkbox',
- '#title' => $this->t('Validate user has access to the %name', array('%name' => $entity_type->getLabel())),
+ '#title' => $this->t('Validate user has access to the %name', ['%name' => $entity_type->getLabel()]),
'#default_value' => $this->options['access'],
- );
- $form['operation'] = array(
+ ];
+ $form['operation'] = [
'#type' => 'radios',
'#title' => $this->t('Access operation to check'),
- '#options' => array(
+ '#options' => [
'view' => $this->t('View'),
'update' => $this->t('Edit'),
'delete' => $this->t('Delete'),
- ),
+ ],
'#default_value' => $this->options['operation'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[validate][options][' . $sanitized_id . '][access]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[validate][options][' . $sanitized_id . '][access]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
// If class is multiple capable give the option to validate single/multiple.
if ($this->multipleCapable) {
- $form['multiple'] = array(
+ $form['multiple'] = [
'#type' => 'radios',
'#title' => $this->t('Multiple arguments'),
- '#options' => array(
- 0 => $this->t('Single ID', array('%type' => $entity_type->getLabel())),
- 1 => $this->t('One or more IDs separated by , or +', array('%type' => $entity_type->getLabel())),
- ),
+ '#options' => [
+ 0 => $this->t('Single ID', ['%type' => $entity_type->getLabel()]),
+ 1 => $this->t('One or more IDs separated by , or +', ['%type' => $entity_type->getLabel()]),
+ ],
'#default_value' => (string) $this->options['multiple'],
- );
+ ];
}
}
/**
* {@inheritdoc}
*/
- public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) {
+ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) {
// Filter out unused options so we don't store giant unnecessary arrays.
$options['bundles'] = array_filter($options['bundles']);
}
@@ -163,7 +163,7 @@ class Entity extends ArgumentValidatorPluginBase {
$ids = array_filter(preg_split('/[,+ ]/', $argument));
}
elseif ($argument) {
- $ids = array($argument);
+ $ids = [$argument];
}
// No specified argument should be invalid.
else {
diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
index 3b79c69d751..36b8e19c9c1 100644
--- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
@@ -31,7 +31,7 @@ abstract class CachePluginBase extends PluginBase {
/**
* Contains all data that should be written/read from cache.
*/
- public $storage = array();
+ public $storage = [];
/**
* Which cache bin to store query results in.
@@ -104,11 +104,11 @@ abstract class CachePluginBase extends PluginBase {
// Not supported currently, but this is certainly where we'd put it.
break;
case 'results':
- $data = array(
+ $data = [
'result' => $this->prepareViewResult($this->view->result),
'total_rows' => isset($this->view->total_rows) ? $this->view->total_rows : 0,
'current_page' => $this->view->getCurrentPage(),
- );
+ ];
$expire = ($this->cacheSetMaxAge($type) === Cache::PERMANENT) ? Cache::PERMANENT : (int) $this->view->getRequest()->server->get('REQUEST_TIME') + $this->cacheSetMaxAge($type);
\Drupal::cache($this->resultsBin)->set($this->generateResultsKey(), $data, $expire, $this->getCacheTags());
break;
@@ -183,16 +183,16 @@ abstract class CachePluginBase extends PluginBase {
if (!isset($this->resultsKey)) {
$build_info = $this->view->build_info;
- foreach (array('query', 'count_query') as $index) {
+ foreach (['query', 'count_query'] as $index) {
// If the default query back-end is used generate SQL query strings from
// the query objects.
if ($build_info[$index] instanceof Select) {
$query = clone $build_info[$index];
$query->preExecute();
- $build_info[$index] = array(
+ $build_info[$index] = [
'query' => (string)$query,
'arguments' => $query->getArguments(),
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/cache/Time.php b/core/modules/views/src/Plugin/views/cache/Time.php
index 601fbac9f7c..962693d9214 100644
--- a/core/modules/views/src/Plugin/views/cache/Time.php
+++ b/core/modules/views/src/Plugin/views/cache/Time.php
@@ -76,64 +76,64 @@ class Time extends CachePluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['results_lifespan'] = array('default' => 3600);
- $options['results_lifespan_custom'] = array('default' => 0);
- $options['output_lifespan'] = array('default' => 3600);
- $options['output_lifespan_custom'] = array('default' => 0);
+ $options['results_lifespan'] = ['default' => 3600];
+ $options['results_lifespan_custom'] = ['default' => 0];
+ $options['output_lifespan'] = ['default' => 3600];
+ $options['output_lifespan_custom'] = ['default' => 0];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $options = array(60, 300, 1800, 3600, 21600, 518400);
- $options = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($options, $options));
- $options = array(0 => $this->t('Never cache')) + $options + array('custom' => $this->t('Custom'));
+ $options = [60, 300, 1800, 3600, 21600, 518400];
+ $options = array_map([$this->dateFormatter, 'formatInterval'], array_combine($options, $options));
+ $options = [0 => $this->t('Never cache')] + $options + ['custom' => $this->t('Custom')];
- $form['results_lifespan'] = array(
+ $form['results_lifespan'] = [
'#type' => 'select',
'#title' => $this->t('Query results'),
'#description' => $this->t('The length of time raw query results should be cached.'),
'#options' => $options,
'#default_value' => $this->options['results_lifespan'],
- );
- $form['results_lifespan_custom'] = array(
+ ];
+ $form['results_lifespan_custom'] = [
'#type' => 'textfield',
'#title' => $this->t('Seconds'),
'#size' => '25',
'#maxlength' => '30',
'#description' => $this->t('Length of time in seconds raw query results should be cached.'),
'#default_value' => $this->options['results_lifespan_custom'],
- '#states' => array(
- 'visible' => array(
- ':input[name="cache_options[results_lifespan]"]' => array('value' => 'custom'),
- ),
- ),
- );
- $form['output_lifespan'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="cache_options[results_lifespan]"]' => ['value' => 'custom'],
+ ],
+ ],
+ ];
+ $form['output_lifespan'] = [
'#type' => 'select',
'#title' => $this->t('Rendered output'),
'#description' => $this->t('The length of time rendered HTML output should be cached.'),
'#options' => $options,
'#default_value' => $this->options['output_lifespan'],
- );
- $form['output_lifespan_custom'] = array(
+ ];
+ $form['output_lifespan_custom'] = [
'#type' => 'textfield',
'#title' => $this->t('Seconds'),
'#size' => '25',
'#maxlength' => '30',
'#description' => $this->t('Length of time in seconds rendered HTML output should be cached.'),
'#default_value' => $this->options['output_lifespan_custom'],
- '#states' => array(
- 'visible' => array(
- ':input[name="cache_options[output_lifespan]"]' => array('value' => 'custom'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="cache_options[output_lifespan]"]' => ['value' => 'custom'],
+ ],
+ ],
+ ];
}
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
- $custom_fields = array('output_lifespan', 'results_lifespan');
+ $custom_fields = ['output_lifespan', 'results_lifespan'];
foreach ($custom_fields as $field) {
$cache_options = $form_state->getValue('cache_options');
if ($cache_options[$field] == 'custom' && !is_numeric($cache_options[$field . '_custom'])) {
diff --git a/core/modules/views/src/Plugin/views/display/Attachment.php b/core/modules/views/src/Plugin/views/display/Attachment.php
index 6171525a2d7..315ab595134 100644
--- a/core/modules/views/src/Plugin/views/display/Attachment.php
+++ b/core/modules/views/src/Plugin/views/display/Attachment.php
@@ -34,12 +34,12 @@ class Attachment extends DisplayPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['displays'] = array('default' => array());
- $options['attachment_position'] = array('default' => 'before');
- $options['inherit_arguments'] = array('default' => TRUE);
- $options['inherit_exposed_filters'] = array('default' => FALSE);
- $options['inherit_pager'] = array('default' => FALSE);
- $options['render_pager'] = array('default' => FALSE);
+ $options['displays'] = ['default' => []];
+ $options['attachment_position'] = ['default' => 'before'];
+ $options['inherit_arguments'] = ['default' => TRUE];
+ $options['inherit_exposed_filters'] = ['default' => FALSE];
+ $options['inherit_pager'] = ['default' => FALSE];
+ $options['render_pager'] = ['default' => FALSE];
return $options;
}
@@ -49,11 +49,11 @@ class Attachment extends DisplayPluginBase {
}
public function attachmentPositions($position = NULL) {
- $positions = array(
+ $positions = [
'before' => $this->t('Before'),
'after' => $this->t('After'),
'both' => $this->t('Both'),
- );
+ ];
if ($position) {
return $positions[$position];
@@ -71,13 +71,13 @@ class Attachment extends DisplayPluginBase {
// It is very important to call the parent function here:
parent::optionsSummary($categories, $options);
- $categories['attachment'] = array(
+ $categories['attachment'] = [
'title' => $this->t('Attachment settings'),
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -10,
- ),
- );
+ ],
+ ];
$displays = array_filter($this->getOption('displays'));
if (count($displays) > 1) {
@@ -94,41 +94,41 @@ class Attachment extends DisplayPluginBase {
$attach_to = $this->t('Not defined');
}
- $options['displays'] = array(
+ $options['displays'] = [
'category' => 'attachment',
'title' => $this->t('Attach to'),
'value' => $attach_to,
- );
+ ];
- $options['attachment_position'] = array(
+ $options['attachment_position'] = [
'category' => 'attachment',
'title' => $this->t('Attachment position'),
'value' => $this->attachmentPositions($this->getOption('attachment_position')),
- );
+ ];
- $options['inherit_arguments'] = array(
+ $options['inherit_arguments'] = [
'category' => 'attachment',
'title' => $this->t('Inherit contextual filters'),
'value' => $this->getOption('inherit_arguments') ? $this->t('Yes') : $this->t('No'),
- );
+ ];
- $options['inherit_exposed_filters'] = array(
+ $options['inherit_exposed_filters'] = [
'category' => 'attachment',
'title' => $this->t('Inherit exposed filters'),
'value' => $this->getOption('inherit_exposed_filters') ? $this->t('Yes') : $this->t('No'),
- );
+ ];
- $options['inherit_pager'] = array(
+ $options['inherit_pager'] = [
'category' => 'pager',
'title' => $this->t('Inherit pager'),
'value' => $this->getOption('inherit_pager') ? $this->t('Yes') : $this->t('No'),
- );
+ ];
- $options['render_pager'] = array(
+ $options['render_pager'] = [
'category' => 'pager',
'title' => $this->t('Render pager'),
'value' => $this->getOption('render_pager') ? $this->t('Yes') : $this->t('No'),
- );
+ ];
}
@@ -142,65 +142,65 @@ class Attachment extends DisplayPluginBase {
switch ($form_state->get('section')) {
case 'inherit_arguments':
$form['#title'] .= $this->t('Inherit contextual filters');
- $form['inherit_arguments'] = array(
+ $form['inherit_arguments'] = [
'#type' => 'checkbox',
'#title' => $this->t('Inherit'),
'#description' => $this->t('Should this display inherit its contextual filter values from the parent display to which it is attached?'),
'#default_value' => $this->getOption('inherit_arguments'),
- );
+ ];
break;
case 'inherit_exposed_filters':
$form['#title'] .= $this->t('Inherit exposed filters');
- $form['inherit_exposed_filters'] = array(
+ $form['inherit_exposed_filters'] = [
'#type' => 'checkbox',
'#title' => $this->t('Inherit'),
'#description' => $this->t('Should this display inherit its exposed filter values from the parent display to which it is attached?'),
'#default_value' => $this->getOption('inherit_exposed_filters'),
- );
+ ];
break;
case 'inherit_pager':
$form['#title'] .= $this->t('Inherit pager');
- $form['inherit_pager'] = array(
+ $form['inherit_pager'] = [
'#type' => 'checkbox',
'#title' => $this->t('Inherit'),
'#description' => $this->t('Should this display inherit its paging values from the parent display to which it is attached?'),
'#default_value' => $this->getOption('inherit_pager'),
- );
+ ];
break;
case 'render_pager':
$form['#title'] .= $this->t('Render pager');
- $form['render_pager'] = array(
+ $form['render_pager'] = [
'#type' => 'checkbox',
'#title' => $this->t('Render'),
'#description' => $this->t('Should this display render the pager values? This is only meaningful if inheriting a pager.'),
'#default_value' => $this->getOption('render_pager'),
- );
+ ];
break;
case 'attachment_position':
$form['#title'] .= $this->t('Position');
- $form['attachment_position'] = array(
+ $form['attachment_position'] = [
'#title' => $this->t('Position'),
'#type' => 'radios',
'#description' => $this->t('Attach before or after the parent display?'),
'#options' => $this->attachmentPositions(),
'#default_value' => $this->getOption('attachment_position'),
- );
+ ];
break;
case 'displays':
$form['#title'] .= $this->t('Attach to');
- $displays = array();
+ $displays = [];
foreach ($this->view->storage->get('display') as $display_id => $display) {
if ($this->view->displayHandlers->has($display_id) && $this->view->displayHandlers->get($display_id)->acceptAttachments()) {
$displays[$display_id] = $display['display_title'];
}
}
- $form['displays'] = array(
+ $form['displays'] = [
'#title' => $this->t('Displays'),
'#type' => 'checkboxes',
'#description' => $this->t('Select which display or displays this should attach to.'),
'#options' => array_map('\Drupal\Component\Utility\Html::escape', $displays),
'#default_value' => $this->getOption('displays'),
- );
+ ];
break;
}
}
@@ -240,7 +240,7 @@ class Attachment extends DisplayPluginBase {
return;
}
- $args = $this->getOption('inherit_arguments') ? $this->view->args : array();
+ $args = $this->getOption('inherit_arguments') ? $this->view->args : [];
$view->setArguments($args);
$view->setDisplay($this->display['id']);
if ($this->getOption('inherit_pager')) {
diff --git a/core/modules/views/src/Plugin/views/display/Block.php b/core/modules/views/src/Plugin/views/display/Block.php
index 5cc04a790d7..5e833d752a5 100644
--- a/core/modules/views/src/Plugin/views/display/Block.php
+++ b/core/modules/views/src/Plugin/views/display/Block.php
@@ -78,15 +78,15 @@ class Block extends DisplayPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['block_description'] = array('default' => '');
- $options['block_category'] = array('default' => $this->t('Lists (Views)'));
- $options['block_hide_empty'] = array('default' => FALSE);
-
- $options['allow'] = array(
- 'contains' => array(
- 'items_per_page' => array('default' => 'items_per_page'),
- ),
- );
+ $options['block_description'] = ['default' => ''];
+ $options['block_category'] = ['default' => $this->t('Lists (Views)')];
+ $options['block_hide_empty'] = ['default' => FALSE];
+
+ $options['allow'] = [
+ 'contains' => [
+ 'items_per_page' => ['default' => 'items_per_page'],
+ ],
+ ];
return $options;
}
@@ -116,7 +116,7 @@ class Block extends DisplayPluginBase {
// display, and arguments should be set on the view.
$element = $this->view->render();
if ($this->outputIsEmpty() && $this->getOption('block_hide_empty') && empty($this->view->style_plugin->definition['even empty'])) {
- return array();
+ return [];
}
else {
return $element;
@@ -131,13 +131,13 @@ class Block extends DisplayPluginBase {
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
- $categories['block'] = array(
+ $categories['block'] = [
'title' => $this->t('Block settings'),
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -10,
- ),
- );
+ ],
+ ];
$block_description = strip_tags($this->getOption('block_description'));
if (empty($block_description)) {
@@ -145,30 +145,30 @@ class Block extends DisplayPluginBase {
}
$block_category = $this->getOption('block_category');
- $options['block_description'] = array(
+ $options['block_description'] = [
'category' => 'block',
'title' => $this->t('Block name'),
'value' => views_ui_truncate($block_description, 24),
- );
- $options['block_category'] = array(
+ ];
+ $options['block_category'] = [
'category' => 'block',
'title' => $this->t('Block category'),
'value' => views_ui_truncate($block_category, 24),
- );
+ ];
$filtered_allow = array_filter($this->getOption('allow'));
- $options['allow'] = array(
+ $options['allow'] = [
'category' => 'block',
'title' => $this->t('Allow settings'),
'value' => empty($filtered_allow) ? $this->t('None') : $this->t('Items per page'),
- );
+ ];
- $options['block_hide_empty'] = array(
+ $options['block_hide_empty'] = [
'category' => 'other',
'title' => $this->t('Hide block if the view output is empty'),
'value' => $this->getOption('block_hide_empty') ? $this->t('Yes') : $this->t('No'),
- );
+ ];
}
/**
@@ -180,53 +180,53 @@ class Block extends DisplayPluginBase {
switch ($form_state->get('section')) {
case 'block_description':
$form['#title'] .= $this->t('Block admin description');
- $form['block_description'] = array(
+ $form['block_description'] = [
'#type' => 'textfield',
'#description' => $this->t('This will appear as the name of this block in administer >> structure >> blocks.'),
'#default_value' => $this->getOption('block_description'),
- );
+ ];
break;
case 'block_category':
$form['#title'] .= $this->t('Block category');
- $form['block_category'] = array(
+ $form['block_category'] = [
'#type' => 'textfield',
'#autocomplete_route_name' => 'block.category_autocomplete',
- '#description' => $this->t('The category this block will appear under on the <a href=":href">blocks placement page</a>.', array(':href' => \Drupal::url('block.admin_display'))),
+ '#description' => $this->t('The category this block will appear under on the <a href=":href">blocks placement page</a>.', [':href' => \Drupal::url('block.admin_display')]),
'#default_value' => $this->getOption('block_category'),
- );
+ ];
break;
case 'block_hide_empty':
$form['#title'] .= $this->t('Block empty settings');
- $form['block_hide_empty'] = array(
+ $form['block_hide_empty'] = [
'#title' => $this->t('Hide block if no result/empty text'),
'#type' => 'checkbox',
'#description' => $this->t('Hide the block if there is no result and no empty text and no header/footer which is shown on empty result'),
'#default_value' => $this->getOption('block_hide_empty'),
- );
+ ];
break;
case 'exposed_form_options':
$this->view->initHandlers();
if (!$this->usesExposed() && parent::usesExposed()) {
- $form['exposed_form_options']['warning'] = array(
+ $form['exposed_form_options']['warning'] = [
'#weight' => -10,
'#markup' => '<div class="messages messages--warning">' . $this->t('Exposed filters in block displays require "Use AJAX" to be set to work correctly.') . '</div>',
- );
+ ];
}
break;
case 'allow':
$form['#title'] .= $this->t('Allow settings in the block configuration');
- $options = array(
+ $options = [
'items_per_page' => $this->t('Items per page'),
- );
+ ];
$allow = array_filter($this->getOption('allow'));
- $form['allow'] = array(
+ $form['allow'] = [
'#type' => 'checkboxes',
'#default_value' => $allow,
'#options' => $options,
- );
+ ];
break;
}
}
@@ -276,18 +276,18 @@ class Block extends DisplayPluginBase {
}
switch ($type) {
case 'items_per_page':
- $form['override']['items_per_page'] = array(
+ $form['override']['items_per_page'] = [
'#type' => 'select',
'#title' => $this->t('Items per block'),
- '#options' => array(
- 'none' => $this->t('@count (default setting)', array('@count' => $this->getPlugin('pager')->getItemsPerPage())),
+ '#options' => [
+ 'none' => $this->t('@count (default setting)', ['@count' => $this->getPlugin('pager')->getItemsPerPage()]),
5 => 5,
10 => 10,
20 => 20,
40 => 40,
- ),
+ ],
'#default_value' => $block_configuration['items_per_page'],
- );
+ ];
break;
}
}
@@ -323,10 +323,10 @@ class Block extends DisplayPluginBase {
* @see \Drupal\views\Plugin\Block\ViewsBlock::blockSubmit()
*/
public function blockSubmit(ViewsBlock $block, $form, FormStateInterface $form_state) {
- if ($items_per_page = $form_state->getValue(array('override', 'items_per_page'))) {
+ if ($items_per_page = $form_state->getValue(['override', 'items_per_page'])) {
$block->setConfigurationValue('items_per_page', $items_per_page);
}
- $form_state->unsetValue(array('override', 'items_per_page'));
+ $form_state->unsetValue(['override', 'items_per_page']);
}
/**
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index c8b07ea1e08..c16ee3b65fe 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -44,7 +44,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
*
* @var \Drupal\views\Plugin\views\ViewsPluginInterface[]
*/
- protected $plugins = array();
+ protected $plugins = [];
/**
* Stores all available display extenders.
@@ -107,7 +107,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
*
* @var array
*/
- protected static $unpackOptions = array();
+ protected static $unpackOptions = [];
/**
* The display information coming directly from the view entity.
@@ -139,7 +139,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* The plugin implementation definition.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
- parent::__construct(array(), $plugin_id, $plugin_definition);
+ parent::__construct([], $plugin_id, $plugin_definition);
}
/**
@@ -150,7 +150,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// Load extenders as soon as possible.
$display['display_options'] += ['display_extenders' => []];
- $this->extenders = array();
+ $this->extenders = [];
if ($extenders = Views::getEnabledDisplayExtenders()) {
$manager = Views::pluginManager('display_extender');
$display_extender_options = $display['display_options']['display_extenders'];
@@ -182,7 +182,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$skip_cache = \Drupal::config('views.settings')->get('skip_cache');
if (empty($view->editing) || !$skip_cache) {
- $cid = 'views:unpack_options:' . hash('sha256', serialize(array($this->options, $options))) . ':' . \Drupal::languageManager()->getCurrentLanguage()->getId();
+ $cid = 'views:unpack_options:' . hash('sha256', serialize([$this->options, $options])) . ':' . \Drupal::languageManager()->getCurrentLanguage()->getId();
if (empty(static::$unpackOptions[$cid])) {
$cache = \Drupal::cache('data')->get($cid);
if (!empty($cache->data)) {
@@ -400,40 +400,40 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function defaultableSections($section = NULL) {
- $sections = array(
- 'access' => array('access'),
- 'cache' => array('cache'),
- 'title' => array('title'),
- 'css_class' => array('css_class'),
- 'use_ajax' => array('use_ajax'),
- 'hide_attachment_summary' => array('hide_attachment_summary'),
- 'show_admin_links' => array('show_admin_links'),
- 'group_by' => array('group_by'),
- 'query' => array('query'),
- 'use_more' => array('use_more', 'use_more_always', 'use_more_text'),
- 'use_more_always' => array('use_more', 'use_more_always', 'use_more_text'),
- 'use_more_text' => array('use_more', 'use_more_always', 'use_more_text'),
- 'link_display' => array('link_display', 'link_url'),
+ $sections = [
+ 'access' => ['access'],
+ 'cache' => ['cache'],
+ 'title' => ['title'],
+ 'css_class' => ['css_class'],
+ 'use_ajax' => ['use_ajax'],
+ 'hide_attachment_summary' => ['hide_attachment_summary'],
+ 'show_admin_links' => ['show_admin_links'],
+ 'group_by' => ['group_by'],
+ 'query' => ['query'],
+ 'use_more' => ['use_more', 'use_more_always', 'use_more_text'],
+ 'use_more_always' => ['use_more', 'use_more_always', 'use_more_text'],
+ 'use_more_text' => ['use_more', 'use_more_always', 'use_more_text'],
+ 'link_display' => ['link_display', 'link_url'],
// Force these to cascade properly.
- 'style' => array('style', 'row'),
- 'row' => array('style', 'row'),
+ 'style' => ['style', 'row'],
+ 'row' => ['style', 'row'],
- 'pager' => array('pager'),
+ 'pager' => ['pager'],
- 'exposed_form' => array('exposed_form'),
+ 'exposed_form' => ['exposed_form'],
// These sections are special.
- 'header' => array('header'),
- 'footer' => array('footer'),
- 'empty' => array('empty'),
- 'relationships' => array('relationships'),
- 'fields' => array('fields'),
- 'sorts' => array('sorts'),
- 'arguments' => array('arguments'),
- 'filters' => array('filters', 'filter_groups'),
- 'filter_groups' => array('filters', 'filter_groups'),
- );
+ 'header' => ['header'],
+ 'footer' => ['footer'],
+ 'empty' => ['empty'],
+ 'relationships' => ['relationships'],
+ 'fields' => ['fields'],
+ 'sorts' => ['sorts'],
+ 'arguments' => ['arguments'],
+ 'filters' => ['filters', 'filter_groups'],
+ 'filter_groups' => ['filters', 'filter_groups'],
+ ];
// If the display cannot use a pager, then we cannot default it.
if (!$this->usesPager()) {
@@ -456,9 +456,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
protected function defineOptions() {
- $options = array(
- 'defaults' => array(
- 'default' => array(
+ $options = [
+ 'defaults' => [
+ 'default' => [
'access' => TRUE,
'cache' => TRUE,
'query' => TRUE,
@@ -492,152 +492,152 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
'arguments' => TRUE,
'filters' => TRUE,
'filter_groups' => TRUE,
- ),
- ),
+ ],
+ ],
- 'title' => array(
+ 'title' => [
'default' => '',
- ),
- 'enabled' => array(
+ ],
+ 'enabled' => [
'default' => TRUE,
- ),
- 'display_comment' => array(
+ ],
+ 'display_comment' => [
'default' => '',
- ),
- 'css_class' => array(
+ ],
+ 'css_class' => [
'default' => '',
- ),
- 'display_description' => array(
+ ],
+ 'display_description' => [
'default' => '',
- ),
- 'use_ajax' => array(
+ ],
+ 'use_ajax' => [
'default' => FALSE,
- ),
- 'hide_attachment_summary' => array(
+ ],
+ 'hide_attachment_summary' => [
'default' => FALSE,
- ),
- 'show_admin_links' => array(
+ ],
+ 'show_admin_links' => [
'default' => TRUE,
- ),
- 'use_more' => array(
+ ],
+ 'use_more' => [
'default' => FALSE,
- ),
- 'use_more_always' => array(
+ ],
+ 'use_more_always' => [
'default' => TRUE,
- ),
- 'use_more_text' => array(
+ ],
+ 'use_more_text' => [
'default' => 'more',
- ),
- 'link_display' => array(
+ ],
+ 'link_display' => [
'default' => '',
- ),
- 'link_url' => array(
+ ],
+ 'link_url' => [
'default' => '',
- ),
- 'group_by' => array(
+ ],
+ 'group_by' => [
'default' => FALSE,
- ),
- 'rendering_language' => array(
+ ],
+ 'rendering_language' => [
'default' => '***LANGUAGE_entity_translation***',
- ),
+ ],
// These types are all plugins that can have individual settings
// and therefore need special handling.
- 'access' => array(
- 'contains' => array(
- 'type' => array('default' => 'none'),
- 'options' => array('default' => array()),
- ),
- 'merge_defaults' => array($this, 'mergePlugin'),
- ),
- 'cache' => array(
- 'contains' => array(
- 'type' => array('default' => 'tag'),
- 'options' => array('default' => array()),
- ),
- 'merge_defaults' => array($this, 'mergePlugin'),
- ),
- 'query' => array(
- 'contains' => array(
- 'type' => array('default' => 'views_query'),
- 'options' => array('default' => array()),
- ),
- 'merge_defaults' => array($this, 'mergePlugin'),
- ),
- 'exposed_form' => array(
- 'contains' => array(
- 'type' => array('default' => 'basic'),
- 'options' => array('default' => array()),
- ),
- 'merge_defaults' => array($this, 'mergePlugin'),
- ),
- 'pager' => array(
- 'contains' => array(
- 'type' => array('default' => 'mini'),
- 'options' => array('default' => array()),
- ),
- 'merge_defaults' => array($this, 'mergePlugin'),
- ),
- 'style' => array(
- 'contains' => array(
- 'type' => array('default' => 'default'),
- 'options' => array('default' => array()),
- ),
- 'merge_defaults' => array($this, 'mergePlugin'),
- ),
- 'row' => array(
- 'contains' => array(
- 'type' => array('default' => 'fields'),
- 'options' => array('default' => array()),
- ),
- 'merge_defaults' => array($this, 'mergePlugin'),
- ),
-
- 'exposed_block' => array(
+ 'access' => [
+ 'contains' => [
+ 'type' => ['default' => 'none'],
+ 'options' => ['default' => []],
+ ],
+ 'merge_defaults' => [$this, 'mergePlugin'],
+ ],
+ 'cache' => [
+ 'contains' => [
+ 'type' => ['default' => 'tag'],
+ 'options' => ['default' => []],
+ ],
+ 'merge_defaults' => [$this, 'mergePlugin'],
+ ],
+ 'query' => [
+ 'contains' => [
+ 'type' => ['default' => 'views_query'],
+ 'options' => ['default' => []],
+ ],
+ 'merge_defaults' => [$this, 'mergePlugin'],
+ ],
+ 'exposed_form' => [
+ 'contains' => [
+ 'type' => ['default' => 'basic'],
+ 'options' => ['default' => []],
+ ],
+ 'merge_defaults' => [$this, 'mergePlugin'],
+ ],
+ 'pager' => [
+ 'contains' => [
+ 'type' => ['default' => 'mini'],
+ 'options' => ['default' => []],
+ ],
+ 'merge_defaults' => [$this, 'mergePlugin'],
+ ],
+ 'style' => [
+ 'contains' => [
+ 'type' => ['default' => 'default'],
+ 'options' => ['default' => []],
+ ],
+ 'merge_defaults' => [$this, 'mergePlugin'],
+ ],
+ 'row' => [
+ 'contains' => [
+ 'type' => ['default' => 'fields'],
+ 'options' => ['default' => []],
+ ],
+ 'merge_defaults' => [$this, 'mergePlugin'],
+ ],
+
+ 'exposed_block' => [
'default' => FALSE,
- ),
-
- 'header' => array(
- 'default' => array(),
- 'merge_defaults' => array($this, 'mergeHandler'),
- ),
- 'footer' => array(
- 'default' => array(),
- 'merge_defaults' => array($this, 'mergeHandler'),
- ),
- 'empty' => array(
- 'default' => array(),
- 'merge_defaults' => array($this, 'mergeHandler'),
- ),
+ ],
+
+ 'header' => [
+ 'default' => [],
+ 'merge_defaults' => [$this, 'mergeHandler'],
+ ],
+ 'footer' => [
+ 'default' => [],
+ 'merge_defaults' => [$this, 'mergeHandler'],
+ ],
+ 'empty' => [
+ 'default' => [],
+ 'merge_defaults' => [$this, 'mergeHandler'],
+ ],
// We want these to export last.
// These are the 5 handler types.
- 'relationships' => array(
- 'default' => array(),
- 'merge_defaults' => array($this, 'mergeHandler'),
- ),
- 'fields' => array(
- 'default' => array(),
- 'merge_defaults' => array($this, 'mergeHandler'),
- ),
- 'sorts' => array(
- 'default' => array(),
- 'merge_defaults' => array($this, 'mergeHandler'),
- ),
- 'arguments' => array(
- 'default' => array(),
- 'merge_defaults' => array($this, 'mergeHandler'),
- ),
- 'filter_groups' => array(
- 'contains' => array(
- 'operator' => array('default' => 'AND'),
- 'groups' => array('default' => array(1 => 'AND')),
- ),
- ),
- 'filters' => array(
- 'default' => array(),
- ),
- );
+ 'relationships' => [
+ 'default' => [],
+ 'merge_defaults' => [$this, 'mergeHandler'],
+ ],
+ 'fields' => [
+ 'default' => [],
+ 'merge_defaults' => [$this, 'mergeHandler'],
+ ],
+ 'sorts' => [
+ 'default' => [],
+ 'merge_defaults' => [$this, 'mergeHandler'],
+ ],
+ 'arguments' => [
+ 'default' => [],
+ 'merge_defaults' => [$this, 'mergeHandler'],
+ ],
+ 'filter_groups' => [
+ 'contains' => [
+ 'operator' => ['default' => 'AND'],
+ 'groups' => ['default' => [1 => 'AND']],
+ ],
+ ],
+ 'filters' => [
+ 'default' => [],
+ ],
+ ];
if (!$this->usesPager()) {
$options['defaults']['default']['pager'] = FALSE;
@@ -682,7 +682,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
*/
public function getAttachedDisplays() {
$current_display_id = $this->display['id'];
- $attached_displays = array();
+ $attached_displays = [];
// Go through all displays and search displays which link to this one.
foreach ($this->view->storage->get('display') as $display_id => $display) {
@@ -840,7 +840,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
*/
public function &getHandlers($type) {
if (!isset($this->handlers[$type])) {
- $this->handlers[$type] = array();
+ $this->handlers[$type] = [];
$types = ViewExecutable::getHandlerTypes();
$plural = $types[$type]['plural'];
@@ -950,7 +950,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// Collect all the dependencies of handlers and plugins. Only calculate
// their dependencies if they are configured by this display.
$plugins = array_merge($this->getAllHandlers(TRUE), $this->getAllPlugins(TRUE));
- array_walk($plugins, array($this, 'calculatePluginDependencies'));
+ array_walk($plugins, [$this, 'calculatePluginDependencies']);
return $this->dependencies;
}
@@ -960,7 +960,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function getFieldLabels($groupable_only = FALSE) {
- $options = array();
+ $options = [];
foreach ($this->getHandlers('relationship') as $relationship => $handler) {
$relationships[$relationship] = $handler->adminLabel();
}
@@ -1015,32 +1015,32 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
if (!empty($class)) {
- $text = SafeMarkup::format('<span>@text</span>', array('@text' => $text));
+ $text = SafeMarkup::format('<span>@text</span>', ['@text' => $text]);
}
if (empty($title)) {
$title = $text;
}
- return \Drupal::l($text, new Url('views_ui.form_display', array(
+ return \Drupal::l($text, new Url('views_ui.form_display', [
'js' => 'nojs',
'view' => $this->view->storage->id(),
'display_id' => $this->display['id'],
'type' => $section
- ), array(
- 'attributes' => array(
- 'class' => array('views-ajax-link', $class),
+ ], [
+ 'attributes' => [
+ 'class' => ['views-ajax-link', $class],
'title' => $title,
'id' => Html::getUniqueId('views-' . $this->display['id'] . '-' . $section)
- )
- )));
+ ]
+ ]));
}
/**
* {@inheritdoc}
*/
public function getArgumentsTokens() {
- $tokens = array();
+ $tokens = [];
if (!empty($this->view->build_info['substitutions'])) {
$tokens = $this->view->build_info['substitutions'];
}
@@ -1052,94 +1052,94 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function optionsSummary(&$categories, &$options) {
- $categories = array(
- 'title' => array(
+ $categories = [
+ 'title' => [
'title' => $this->t('Title'),
'column' => 'first',
- ),
- 'format' => array(
+ ],
+ 'format' => [
'title' => $this->t('Format'),
'column' => 'first',
- ),
- 'filters' => array(
+ ],
+ 'filters' => [
'title' => $this->t('Filters'),
'column' => 'first',
- ),
- 'fields' => array(
+ ],
+ 'fields' => [
'title' => $this->t('Fields'),
'column' => 'first',
- ),
- 'pager' => array(
+ ],
+ 'pager' => [
'title' => $this->t('Pager'),
'column' => 'second',
- ),
- 'language' => array(
+ ],
+ 'language' => [
'title' => $this->t('Language'),
'column' => 'second',
- ),
- 'exposed' => array(
+ ],
+ 'exposed' => [
'title' => $this->t('Exposed form'),
'column' => 'third',
- 'build' => array(
+ 'build' => [
'#weight' => 1,
- ),
- ),
- 'access' => array(
+ ],
+ ],
+ 'access' => [
'title' => '',
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -5,
- ),
- ),
- 'other' => array(
+ ],
+ ],
+ 'other' => [
'title' => $this->t('Other'),
'column' => 'third',
- 'build' => array(
+ 'build' => [
'#weight' => 2,
- ),
- ),
- );
+ ],
+ ],
+ ];
if ($this->display['id'] != 'default') {
- $options['display_id'] = array(
+ $options['display_id'] = [
'category' => 'other',
'title' => $this->t('Machine Name'),
'value' => !empty($this->display['new_id']) ? $this->display['new_id'] : $this->display['id'],
'desc' => $this->t('Change the machine name of this display.'),
- );
+ ];
}
$display_comment = views_ui_truncate($this->getOption('display_comment'), 80);
- $options['display_comment'] = array(
+ $options['display_comment'] = [
'category' => 'other',
'title' => $this->t('Administrative comment'),
'value' => !empty($display_comment) ? $display_comment : $this->t('None'),
'desc' => $this->t('Comment or document this display.'),
- );
+ ];
$title = strip_tags($this->getOption('title'));
if (!$title) {
$title = $this->t('None');
}
- $options['title'] = array(
+ $options['title'] = [
'category' => 'title',
'title' => $this->t('Title'),
'value' => views_ui_truncate($title, 32),
'desc' => $this->t('Change the title that this display will use.'),
- );
+ ];
$style_plugin_instance = $this->getPlugin('style');
$style_summary = empty($style_plugin_instance->definition['title']) ? $this->t('Missing style plugin') : $style_plugin_instance->summaryTitle();
$style_title = empty($style_plugin_instance->definition['title']) ? $this->t('Missing style plugin') : $style_plugin_instance->pluginTitle();
- $options['style'] = array(
+ $options['style'] = [
'category' => 'format',
'title' => $this->t('Format'),
'value' => $style_title,
'setting' => $style_summary,
'desc' => $this->t('Change the way content is formatted.'),
- );
+ ];
// This adds a 'Settings' link to the style_options setting if the style has
// options.
@@ -1152,13 +1152,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$row_summary = empty($row_plugin_instance->definition['title']) ? $this->t('Missing row plugin') : $row_plugin_instance->summaryTitle();
$row_title = empty($row_plugin_instance->definition['title']) ? $this->t('Missing row plugin') : $row_plugin_instance->pluginTitle();
- $options['row'] = array(
+ $options['row'] = [
'category' => 'format',
'title' => $this->t('Show'),
'value' => $row_title,
'setting' => $row_summary,
'desc' => $this->t('Change the way each row in the view is styled.'),
- );
+ ];
// This adds a 'Settings' link to the row_options setting if the row style
// has options.
if ($row_plugin_instance->usesOptions()) {
@@ -1166,28 +1166,28 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
}
if ($this->usesAJAX()) {
- $options['use_ajax'] = array(
+ $options['use_ajax'] = [
'category' => 'other',
'title' => $this->t('Use AJAX'),
'value' => $this->getOption('use_ajax') ? $this->t('Yes') : $this->t('No'),
'desc' => $this->t('Change whether or not this display will use AJAX.'),
- );
+ ];
}
if ($this->usesAttachments()) {
- $options['hide_attachment_summary'] = array(
+ $options['hide_attachment_summary'] = [
'category' => 'other',
'title' => $this->t('Hide attachments in summary'),
'value' => $this->getOption('hide_attachment_summary') ? $this->t('Yes') : $this->t('No'),
'desc' => $this->t('Change whether or not to display attachments when displaying a contextual filter summary.'),
- );
+ ];
}
if (!isset($this->definition['contextual links locations']) || !empty($this->definition['contextual links locations'])) {
- $options['show_admin_links'] = array(
+ $options['show_admin_links'] = [
'category' => 'other',
'title' => $this->t('Contextual links'),
'value' => $this->getOption('show_admin_links') ? $this->t('Shown') : $this->t('Hidden'),
'desc' => $this->t('Change whether or not to display contextual links for this view.'),
- );
+ ];
}
$pager_plugin = $this->getPlugin('pager');
@@ -1198,13 +1198,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$pager_str = $pager_plugin->summaryTitle();
- $options['pager'] = array(
+ $options['pager'] = [
'category' => 'pager',
'title' => $this->t('Use pager'),
'value' => $pager_plugin->pluginTitle(),
'setting' => $pager_str,
'desc' => $this->t("Change this display's pager setting."),
- );
+ ];
// If pagers aren't allowed, change the text of the item.
if (!$this->usesPager()) {
@@ -1216,39 +1216,39 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
if ($this->usesMore()) {
- $options['use_more'] = array(
+ $options['use_more'] = [
'category' => 'pager',
'title' => $this->t('More link'),
'value' => $this->getOption('use_more') ? $this->t('Yes') : $this->t('No'),
'desc' => $this->t('Specify whether this display will provide a "more" link.'),
- );
+ ];
}
$this->view->initQuery();
if ($this->view->query->getAggregationInfo()) {
- $options['group_by'] = array(
+ $options['group_by'] = [
'category' => 'other',
'title' => $this->t('Use aggregation'),
'value' => $this->getOption('group_by') ? $this->t('Yes') : $this->t('No'),
'desc' => $this->t('Allow grouping and aggregation (calculation) of fields.'),
- );
+ ];
}
- $options['query'] = array(
+ $options['query'] = [
'category' => 'other',
'title' => $this->t('Query settings'),
'value' => $this->t('Settings'),
'desc' => $this->t('Allow to set some advanced settings for the query plugin'),
- );
+ ];
if (\Drupal::languageManager()->isMultilingual() && $this->isBaseTableTranslatable()) {
$rendering_language_options = $this->buildRenderingLanguageOptions();
- $options['rendering_language'] = array(
+ $options['rendering_language'] = [
'category' => 'language',
'title' => $this->t('Rendering Language'),
'value' => $rendering_language_options[$this->getOption('rendering_language')],
'desc' => $this->t('All content that supports translations will be displayed in the selected language.'),
- );
+ ];
}
$access_plugin = $this->getPlugin('access');
@@ -1259,13 +1259,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$access_str = $access_plugin->summaryTitle();
- $options['access'] = array(
+ $options['access'] = [
'category' => 'access',
'title' => $this->t('Access'),
'value' => $access_plugin->pluginTitle(),
'setting' => $access_str,
'desc' => $this->t('Specify access control type for this display.'),
- );
+ ];
if ($access_plugin->usesOptions()) {
$options['access']['links']['access_options'] = $this->t('Change settings for this access type.');
@@ -1279,13 +1279,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$cache_str = $cache_plugin->summaryTitle();
- $options['cache'] = array(
+ $options['cache'] = [
'category' => 'other',
'title' => $this->t('Caching'),
'value' => $cache_plugin->pluginTitle(),
'setting' => $cache_str,
'desc' => $this->t('Specify caching type for this display.'),
- );
+ ];
if ($cache_plugin->usesOptions()) {
$options['cache']['links']['cache_options'] = $this->t('Change settings for this caching type.');
@@ -1310,21 +1310,21 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
}
- $options['link_display'] = array(
+ $options['link_display'] = [
'category' => 'pager',
'title' => $this->t('Link display'),
'value' => $link_display,
'desc' => $this->t('Specify which display or custom URL this display will link to.'),
- );
+ ];
}
if ($this->usesExposedFormInBlock()) {
- $options['exposed_block'] = array(
+ $options['exposed_block'] = [
'category' => 'exposed',
'title' => $this->t('Exposed form in block'),
'value' => $this->getOption('exposed_block') ? $this->t('Yes') : $this->t('No'),
'desc' => $this->t('Allow the exposed form to appear in a block instead of the view.'),
- );
+ ];
}
/** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form_plugin */
@@ -1336,13 +1336,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$exposed_form_str = $exposed_form_plugin->summaryTitle();
- $options['exposed_form'] = array(
+ $options['exposed_form'] = [
'category' => 'exposed',
'title' => $this->t('Exposed form style'),
'value' => $exposed_form_plugin->pluginTitle(),
'setting' => $exposed_form_str,
'desc' => $this->t('Select the kind of exposed filter to use.'),
- );
+ ];
if ($exposed_form_plugin->usesOptions()) {
$options['exposed_form']['links']['exposed_form_options'] = $this->t('Exposed form settings for this exposed form style.');
@@ -1353,12 +1353,12 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$css_class = $this->t('None');
}
- $options['css_class'] = array(
+ $options['css_class'] = [
'category' => 'other',
'title' => $this->t('CSS class'),
'value' => $css_class,
'desc' => $this->t('Change the CSS class name(s) that will be added to this display.'),
- );
+ ];
foreach ($this->extenders as $extender) {
$extender->optionsSummary($categories, $options);
@@ -1390,144 +1390,144 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
switch ($section) {
case 'display_id':
$form['#title'] .= $this->t('The machine name of this display');
- $form['display_id'] = array(
+ $form['display_id'] = [
'#type' => 'textfield',
'#title' => $this->t('Machine name of the display'),
'#default_value' => !empty($this->display['new_id']) ? $this->display['new_id'] : $this->display['id'],
'#required' => TRUE,
'#size' => 64,
- );
+ ];
break;
case 'display_title':
$form['#title'] .= $this->t('The name and the description of this display');
- $form['display_title'] = array(
+ $form['display_title'] = [
'#title' => $this->t('Administrative name'),
'#type' => 'textfield',
'#default_value' => $this->display['display_title'],
- );
- $form['display_description'] = array(
+ ];
+ $form['display_description'] = [
'#title' => $this->t('Administrative description'),
'#type' => 'textfield',
'#default_value' => $this->getOption('display_description'),
- );
+ ];
break;
case 'display_comment':
$form['#title'] .= $this->t('Administrative comment');
- $form['display_comment'] = array(
+ $form['display_comment'] = [
'#type' => 'textarea',
'#title' => $this->t('Administrative comment'),
'#description' => $this->t('This description will only be seen within the administrative interface and can be used to document this display.'),
'#default_value' => $this->getOption('display_comment'),
- );
+ ];
break;
case 'title':
$form['#title'] .= $this->t('The title of this view');
- $form['title'] = array(
+ $form['title'] = [
'#title' => $this->t('Title'),
'#type' => 'textfield',
'#description' => $this->t('This title will be displayed with the view, wherever titles are normally displayed; i.e, as the page title, block title, etc.'),
'#default_value' => $this->getOption('title'),
'#maxlength' => 255,
- );
+ ];
break;
case 'css_class':
$form['#title'] .= $this->t('CSS class');
- $form['css_class'] = array(
+ $form['css_class'] = [
'#type' => 'textfield',
'#title' => $this->t('CSS class name(s)'),
'#description' => $this->t('Separate multiple classes by spaces.'),
'#default_value' => $this->getOption('css_class'),
- );
+ ];
break;
case 'use_ajax':
$form['#title'] .= $this->t('AJAX');
- $form['use_ajax'] = array(
+ $form['use_ajax'] = [
'#description' => $this->t('Options such as paging, table sorting, and exposed filters will not initiate a page refresh.'),
'#type' => 'checkbox',
'#title' => $this->t('Use AJAX'),
'#default_value' => $this->getOption('use_ajax') ? 1 : 0,
- );
+ ];
break;
case 'hide_attachment_summary':
$form['#title'] .= $this->t('Hide attachments when displaying a contextual filter summary');
- $form['hide_attachment_summary'] = array(
+ $form['hide_attachment_summary'] = [
'#type' => 'checkbox',
'#title' => $this->t('Hide attachments in summary'),
'#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0,
- );
+ ];
break;
case 'show_admin_links':
$form['#title'] .= $this->t('Show contextual links on this view.');
- $form['show_admin_links'] = array(
+ $form['show_admin_links'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show contextual links'),
'#default_value' => $this->getOption('show_admin_links'),
- );
+ ];
break;
case 'use_more':
$form['#title'] .= $this->t('Add a more link to the bottom of the display.');
- $form['use_more'] = array(
+ $form['use_more'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create more link'),
'#description' => $this->t("This will add a more link to the bottom of this view, which will link to the page view. If you have more than one page view, the link will point to the display specified in 'Link display' section under pager. You can override the URL at the link display setting."),
'#default_value' => $this->getOption('use_more'),
- );
- $form['use_more_always'] = array(
+ ];
+ $form['use_more_always'] = [
'#type' => 'checkbox',
'#title' => $this->t('Always display the more link'),
'#description' => $this->t('Check this to display the more link even if there are no more items to display.'),
'#default_value' => $this->getOption('use_more_always'),
- '#states' => array(
- 'visible' => array(
- ':input[name="use_more"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['use_more_text'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="use_more"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['use_more_text'] = [
'#type' => 'textfield',
'#title' => $this->t('More link text'),
'#description' => $this->t('The text to display for the more link.'),
'#default_value' => $this->getOption('use_more_text'),
- '#states' => array(
- 'visible' => array(
- ':input[name="use_more"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="use_more"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
break;
case 'group_by':
$form['#title'] .= $this->t('Allow grouping and aggregation (calculation) of fields.');
- $form['group_by'] = array(
+ $form['group_by'] = [
'#type' => 'checkbox',
'#title' => $this->t('Aggregate'),
'#description' => $this->t('If enabled, some fields may become unavailable. All fields that are selected for grouping will be collapsed to one record per distinct value. Other fields which are selected for aggregation will have the function run on them. For example, you can group nodes on title and count the number of nids in order to get a list of duplicate titles.'),
'#default_value' => $this->getOption('group_by'),
- );
+ ];
break;
case 'access':
$form['#title'] .= $this->t('Access restrictions');
- $form['access'] = array(
+ $form['access'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
+ ];
$access = $this->getOption('access');
- $form['access']['type'] = array(
+ $form['access']['type'] = [
'#title' => $this->t('Access'),
'#title_display' => 'invisible',
'#type' => 'radios',
- '#options' => Views::fetchPluginNames('access', $this->getType(), array($this->view->storage->get('base_table'))),
+ '#options' => Views::fetchPluginNames('access', $this->getType(), [$this->view->storage->get('base_table')]),
'#default_value' => $access['type'],
- );
+ ];
$access_plugin = $this->getPlugin('access');
if ($access_plugin->usesOptions()) {
- $form['markup'] = array(
+ $form['markup'] = [
'#prefix' => '<div class="js-form-item form-item description">',
- '#markup' => $this->t('You may also adjust the @settings for the currently selected access restriction.', array('@settings' => $this->optionLink($this->t('settings'), 'access_options'))),
+ '#markup' => $this->t('You may also adjust the @settings for the currently selected access restriction.', ['@settings' => $this->optionLink($this->t('settings'), 'access_options')]),
'#suffix' => '</div>',
- );
+ ];
}
break;
@@ -1535,45 +1535,45 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$plugin = $this->getPlugin('access');
$form['#title'] .= $this->t('Access options');
if ($plugin) {
- $form['access_options'] = array(
+ $form['access_options'] = [
'#tree' => TRUE,
- );
+ ];
$plugin->buildOptionsForm($form['access_options'], $form_state);
}
break;
case 'cache':
$form['#title'] .= $this->t('Caching');
- $form['cache'] = array(
+ $form['cache'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
+ ];
$cache = $this->getOption('cache');
- $form['cache']['type'] = array(
+ $form['cache']['type'] = [
'#title' => $this->t('Caching'),
'#title_display' => 'invisible',
'#type' => 'radios',
- '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))),
+ '#options' => Views::fetchPluginNames('cache', $this->getType(), [$this->view->storage->get('base_table')]),
'#default_value' => $cache['type'],
- );
+ ];
$cache_plugin = $this->getPlugin('cache');
if ($cache_plugin->usesOptions()) {
- $form['markup'] = array(
+ $form['markup'] = [
'#prefix' => '<div class="js-form-item form-item description">',
'#suffix' => '</div>',
- '#markup' => $this->t('You may also adjust the @settings for the currently selected cache mechanism.', array('@settings' => $this->optionLink($this->t('settings'), 'cache_options'))),
- );
+ '#markup' => $this->t('You may also adjust the @settings for the currently selected cache mechanism.', ['@settings' => $this->optionLink($this->t('settings'), 'cache_options')]),
+ ];
}
break;
case 'cache_options':
$plugin = $this->getPlugin('cache');
$form['#title'] .= $this->t('Caching options');
if ($plugin) {
- $form['cache_options'] = array(
+ $form['cache_options'] = [
'#tree' => TRUE,
- );
+ ];
$plugin->buildOptionsForm($form['cache_options'], $form_state);
}
break;
@@ -1584,16 +1584,16 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$form['#title'] .= $this->t('Query options');
$this->view->initQuery();
if ($this->view->query) {
- $form['query'] = array(
+ $form['query'] = [
'#tree' => TRUE,
- 'type' => array(
+ 'type' => [
'#type' => 'value',
'#value' => $plugin_name,
- ),
- 'options' => array(
+ ],
+ 'options' => [
'#tree' => TRUE,
- ),
- );
+ ],
+ ];
$this->view->query->buildOptionsForm($form['query']['options'], $form_state);
}
@@ -1602,13 +1602,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$form['#title'] .= $this->t('Rendering language');
if (\Drupal::languageManager()->isMultilingual() && $this->isBaseTableTranslatable()) {
$options = $this->buildRenderingLanguageOptions();
- $form['rendering_language'] = array(
+ $form['rendering_language'] = [
'#type' => 'select',
'#options' => $options,
'#title' => $this->t('Rendering language'),
'#description' => $this->t('All content that supports translations will be displayed in the selected language.'),
'#default_value' => $this->getOption('rendering_language'),
- );
+ ];
}
else {
$form['rendering_language']['#markup'] = $this->t('The view is not based on a translatable entity type or the site is not multilingual.');
@@ -1617,26 +1617,26 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
case 'style':
$form['#title'] .= $this->t('How should this view be styled');
$style_plugin = $this->getPlugin('style');
- $form['style'] = array(
+ $form['style'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
- $form['style']['type'] = array(
+ ];
+ $form['style']['type'] = [
'#title' => $this->t('Style'),
'#title_display' => 'invisible',
'#type' => 'radios',
- '#options' => Views::fetchPluginNames('style', $this->getType(), array($this->view->storage->get('base_table'))),
+ '#options' => Views::fetchPluginNames('style', $this->getType(), [$this->view->storage->get('base_table')]),
'#default_value' => $style_plugin->definition['id'],
'#description' => $this->t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'),
- );
+ ];
if ($style_plugin->usesOptions()) {
- $form['markup'] = array(
+ $form['markup'] = [
'#prefix' => '<div class="js-form-item form-item description">',
'#suffix' => '</div>',
- '#markup' => $this->t('You may also adjust the @settings for the currently selected style.', array('@settings' => $this->optionLink($this->t('settings'), 'style_options'))),
- );
+ '#markup' => $this->t('You may also adjust the @settings for the currently selected style.', ['@settings' => $this->optionLink($this->t('settings'), 'style_options')]),
+ ];
}
break;
@@ -1666,31 +1666,31 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
case 'row':
$form['#title'] .= $this->t('How should each row in this view be styled');
$row_plugin_instance = $this->getPlugin('row');
- $form['row'] = array(
+ $form['row'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
- $form['row']['type'] = array(
+ ];
+ $form['row']['type'] = [
'#title' => $this->t('Row'),
'#title_display' => 'invisible',
'#type' => 'radios',
- '#options' => Views::fetchPluginNames('row', $this->getType(), array($this->view->storage->get('base_table'))),
+ '#options' => Views::fetchPluginNames('row', $this->getType(), [$this->view->storage->get('base_table')]),
'#default_value' => $row_plugin_instance->definition['id'],
- );
+ ];
if ($row_plugin_instance->usesOptions()) {
- $form['markup'] = array(
+ $form['markup'] = [
'#prefix' => '<div class="js-form-item form-item description">',
'#suffix' => '</div>',
- '#markup' => $this->t('You may also adjust the @settings for the currently selected row style.', array('@settings' => $this->optionLink($this->t('settings'), 'row_options'))),
- );
+ '#markup' => $this->t('You may also adjust the @settings for the currently selected row style.', ['@settings' => $this->optionLink($this->t('settings'), 'row_options')]),
+ ];
}
break;
case 'link_display':
$form['#title'] .= $this->t('Which display to use for path');
- $options = array(FALSE => $this->t('None'), 'custom_url' => $this->t('Custom URL'));
+ $options = [FALSE => $this->t('None'), 'custom_url' => $this->t('Custom URL')];
foreach ($this->view->storage->get('display') as $display_id => $display) {
if ($this->view->displayHandlers->get($display_id)->hasPath()) {
@@ -1698,18 +1698,18 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
}
- $form['link_display'] = array(
+ $form['link_display'] = [
'#type' => 'radios',
'#options' => $options,
'#description' => $this->t("Which display to use to get this display's path for things like summary links, rss feed links, more links, etc."),
'#default_value' => $this->getOption('link_display'),
- );
+ ];
- $options = array();
+ $options = [];
$optgroup_arguments = (string) t('Arguments');
foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
- $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel()));
- $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel()));
+ $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
+ $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
}
// Default text.
@@ -1726,102 +1726,102 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
];
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
- $items = array();
+ $items = [];
foreach ($options[$type] as $key => $value) {
$items[] = $key . ' == ' . $value;
}
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
$description[] = $item_list;
}
}
}
- $form['link_url'] = array(
+ $form['link_url'] = [
'#type' => 'textfield',
'#title' => $this->t('Custom URL'),
'#default_value' => $this->getOption('link_url'),
'#description' => $description,
- '#states' => array(
- 'visible' => array(
- ':input[name="link_display"]' => array('value' => 'custom_url'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="link_display"]' => ['value' => 'custom_url'],
+ ],
+ ],
+ ];
break;
case 'exposed_block':
$form['#title'] .= $this->t('Put the exposed form in a block');
- $form['description'] = array(
+ $form['description'] = [
'#markup' => '<div class="js-form-item form-item description">' . $this->t('If set, any exposed widgets will not appear with this view. Instead, a block will be made available to the Drupal block administration system, and the exposed form will appear there. Note that this block must be enabled manually, Views will not enable it for you.') . '</div>',
- );
- $form['exposed_block'] = array(
+ ];
+ $form['exposed_block'] = [
'#type' => 'radios',
- '#options' => array(1 => $this->t('Yes'), 0 => $this->t('No')),
+ '#options' => [1 => $this->t('Yes'), 0 => $this->t('No')],
'#default_value' => $this->getOption('exposed_block') ? 1 : 0,
- );
+ ];
break;
case 'exposed_form':
$form['#title'] .= $this->t('Exposed Form');
- $form['exposed_form'] = array(
+ $form['exposed_form'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
+ ];
$exposed_form = $this->getOption('exposed_form');
- $form['exposed_form']['type'] = array(
+ $form['exposed_form']['type'] = [
'#title' => $this->t('Exposed form'),
'#title_display' => 'invisible',
'#type' => 'radios',
- '#options' => Views::fetchPluginNames('exposed_form', $this->getType(), array($this->view->storage->get('base_table'))),
+ '#options' => Views::fetchPluginNames('exposed_form', $this->getType(), [$this->view->storage->get('base_table')]),
'#default_value' => $exposed_form['type'],
- );
+ ];
$exposed_form_plugin = $this->getPlugin('exposed_form');
if ($exposed_form_plugin->usesOptions()) {
- $form['markup'] = array(
+ $form['markup'] = [
'#prefix' => '<div class="js-form-item form-item description">',
'#suffix' => '</div>',
- '#markup' => $this->t('You may also adjust the @settings for the currently selected style.', array('@settings' => $this->optionLink($this->t('settings'), 'exposed_form_options'))),
- );
+ '#markup' => $this->t('You may also adjust the @settings for the currently selected style.', ['@settings' => $this->optionLink($this->t('settings'), 'exposed_form_options')]),
+ ];
}
break;
case 'exposed_form_options':
$plugin = $this->getPlugin('exposed_form');
$form['#title'] .= $this->t('Exposed form options');
if ($plugin) {
- $form['exposed_form_options'] = array(
+ $form['exposed_form_options'] = [
'#tree' => TRUE,
- );
+ ];
$plugin->buildOptionsForm($form['exposed_form_options'], $form_state);
}
break;
case 'pager':
$form['#title'] .= $this->t('Select pager');
- $form['pager'] = array(
+ $form['pager'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
+ ];
$pager = $this->getOption('pager');
- $form['pager']['type'] = array(
+ $form['pager']['type'] = [
'#title' => $this->t('Pager'),
'#title_display' => 'invisible',
'#type' => 'radios',
- '#options' => Views::fetchPluginNames('pager', !$this->usesPager() ? 'basic' : NULL, array($this->view->storage->get('base_table'))),
+ '#options' => Views::fetchPluginNames('pager', !$this->usesPager() ? 'basic' : NULL, [$this->view->storage->get('base_table')]),
'#default_value' => $pager['type'],
- );
+ ];
$pager_plugin = $this->getPlugin('pager');
if ($pager_plugin->usesOptions()) {
- $form['markup'] = array(
+ $form['markup'] = [
'#prefix' => '<div class="js-form-item form-item description">',
'#suffix' => '</div>',
- '#markup' => $this->t('You may also adjust the @settings for the currently selected pager.', array('@settings' => $this->optionLink($this->t('settings'), 'pager_options'))),
- );
+ '#markup' => $this->t('You may also adjust the @settings for the currently selected pager.', ['@settings' => $this->optionLink($this->t('settings'), 'pager_options')]),
+ ];
}
break;
@@ -1829,9 +1829,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$plugin = $this->getPlugin('pager');
$form['#title'] .= $this->t('Pager options');
if ($plugin) {
- $form['pager_options'] = array(
+ $form['pager_options'] = [
'#tree' => TRUE,
- );
+ ];
$plugin->buildOptionsForm($form['pager_options'], $form_state);
}
break;
@@ -1955,16 +1955,16 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
case 'style':
$plugin_type = $section;
$plugin_options = $this->getOption($plugin_type);
- $type = $form_state->getValue(array($plugin_type, 'type'));
+ $type = $form_state->getValue([$plugin_type, 'type']);
if ($plugin_options['type'] != $type) {
/** @var \Drupal\views\Plugin\views\ViewsPluginInterface $plugin */
$plugin = Views::pluginManager($plugin_type)->createInstance($type);
if ($plugin) {
$plugin->init($this->view, $this, $plugin_options['options']);
- $plugin_options = array(
+ $plugin_options = [
'type' => $type,
'options' => $plugin->options,
- );
+ ];
$plugin->filterByDefinedOptions($plugin_options['options']);
$this->setOption($plugin_type, $plugin_options);
if ($plugin->usesOptions()) {
@@ -2082,18 +2082,18 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// If a URL is available (either from the display or a custom path),
// render the "More" link.
if ($url) {
- $url_options = array();
+ $url_options = [];
if (!empty($this->view->exposed_raw_input)) {
$url_options['query'] = $this->view->exposed_raw_input;
}
$url->setOptions($url_options);
- return array(
+ return [
'#type' => 'more_link',
'#url' => $url,
'#title' => $this->useMoreText(),
'#view' => $this->view,
- );
+ ];
}
}
}
@@ -2102,9 +2102,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function render() {
- $rows = (!empty($this->view->result) || $this->view->style_plugin->evenEmpty()) ? $this->view->style_plugin->render($this->view->result) : array();
+ $rows = (!empty($this->view->result) || $this->view->style_plugin->evenEmpty()) ? $this->view->style_plugin->render($this->view->result) : [];
- $element = array(
+ $element = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#pre_render' => [[$this, 'elementPreRender']],
@@ -2113,7 +2113,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// be available on the view.
'#attached' => &$this->view->element['#attached'],
'#cache' => &$this->view->element['#cache'],
- );
+ ];
$this->applyDisplayCacheabilityMetadata($this->view->element);
@@ -2163,15 +2163,15 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// Force a render array so CSS/JS can be attached.
if (!is_array($element['#rows'])) {
- $element['#rows'] = array('#markup' => $element['#rows']);
+ $element['#rows'] = ['#markup' => $element['#rows']];
}
$element['#header'] = $view->display_handler->renderArea('header', $empty);
$element['#footer'] = $view->display_handler->renderArea('footer', $empty);
- $element['#empty'] = $empty ? $view->display_handler->renderArea('empty', $empty) : array();
- $element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : array();
+ $element['#empty'] = $empty ? $view->display_handler->renderArea('empty', $empty) : [];
+ $element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : [];
$element['#more'] = $view->display_handler->renderMoreLink();
- $element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : array();
+ $element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : [];
if ($view->display_handler->renderPager()) {
$exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL;
@@ -2201,12 +2201,12 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// The form is requesting that all non-essential views elements be hidden,
// usually because the rendered step is not a view result.
if ($form['show_view_elements']['#value'] == FALSE) {
- $element['#header'] = array();
- $element['#exposed'] = array();
- $element['#pager'] = array();
- $element['#footer'] = array();
- $element['#more'] = array();
- $element['#feed_icons'] = array();
+ $element['#header'] = [];
+ $element['#exposed'] = [];
+ $element['#pager'] = [];
+ $element['#footer'] = [];
+ $element['#more'] = [];
+ $element['#feed_icons'] = [];
}
$element['#rows'] = $form;
@@ -2219,7 +2219,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function renderArea($area, $empty = FALSE) {
- $return = array();
+ $return = [];
foreach ($this->getHandlers($area) as $key => $area_handler) {
if ($area_render = $area_handler->render($empty)) {
if (isset($area_handler->position)) {
@@ -2407,7 +2407,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function validate() {
- $errors = array();
+ $errors = [];
// Make sure displays that use fields HAVE fields.
if ($this->usesFields()) {
$fields = FALSE;
@@ -2418,7 +2418,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
if (!$fields) {
- $errors[] = $this->t('Display "@display" uses fields but there are none defined for it or all are excluded.', array('@display' => $this->display['display_title']));
+ $errors[] = $this->t('Display "@display" uses fields but there are none defined for it or all are excluded.', ['@display' => $this->display['display_title']]);
}
}
@@ -2426,18 +2426,18 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
if ($this->isMoreEnabled() && $this->getOption('link_display') !== 'custom_url') {
$routed_display = $this->getRoutedDisplay();
if (!$routed_display || !$routed_display->isEnabled()) {
- $errors[] = $this->t('Display "@display" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', array('@display' => $this->display['display_title']));
+ $errors[] = $this->t('Display "@display" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', ['@display' => $this->display['display_title']]);
}
}
if ($this->hasPath() && !$this->getOption('path')) {
- $errors[] = $this->t('Display "@display" uses a path but the path is undefined.', array('@display' => $this->display['display_title']));
+ $errors[] = $this->t('Display "@display" uses a path but the path is undefined.', ['@display' => $this->display['display_title']]);
}
// Validate style plugin.
$style = $this->getPlugin('style');
if (empty($style)) {
- $errors[] = $this->t('Display "@display" has an invalid style plugin.', array('@display' => $this->display['display_title']));
+ $errors[] = $this->t('Display "@display" has an invalid style plugin.', ['@display' => $this->display['display_title']]);
}
else {
$result = $style->validate();
@@ -2458,7 +2458,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
foreach (ViewExecutable::getHandlerTypes() as $type => $handler_type_info) {
foreach ($this->getHandlers($type) as $handler_id => $handler) {
if (!empty($handler->options['relationship']) && $handler->options['relationship'] != 'none' && !in_array($handler->options['relationship'], $relationships)) {
- $errors[] = $this->t('The %handler_type %handler uses a relationship that has been removed.', array('%handler_type' => $handler_type_info['lstitle'], '%handler' => $handler->adminLabel()));
+ $errors[] = $this->t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => $handler_type_info['lstitle'], '%handler' => $handler->adminLabel()]);
}
}
}
@@ -2514,7 +2514,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
// Check whether all of the area handlers are empty.
- foreach (array('empty', 'footer', 'header') as $type) {
+ foreach (['empty', 'footer', 'header'] as $type) {
$handlers = $this->getHandlers($type);
foreach ($handlers as $handler) {
// If one is not empty, return FALSE now.
@@ -2531,15 +2531,15 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function getSpecialBlocks() {
- $blocks = array();
+ $blocks = [];
if ($this->usesExposedFormInBlock()) {
$delta = '-exp-' . $this->view->storage->id() . '-' . $this->display['id'];
- $desc = $this->t('Exposed form: @view-@display_id', array('@view' => $this->view->storage->id(), '@display_id' => $this->display['id']));
+ $desc = $this->t('Exposed form: @view-@display_id', ['@view' => $this->view->storage->id(), '@display_id' => $this->display['id']]);
- $blocks[$delta] = array(
+ $blocks[$delta] = [
'info' => $desc,
- );
+ ];
}
return $blocks;
@@ -2567,21 +2567,21 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
* {@inheritdoc}
*/
public function getArgumentText() {
- return array(
+ return [
'filter value not present' => $this->t('When the filter value is <em>NOT</em> available'),
'filter value present' => $this->t('When the filter value <em>IS</em> available or a default is provided'),
'description' => $this->t("This display does not have a source for contextual filters, so no contextual filter value will be available unless you select 'Provide default'."),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getPagerText() {
- return array(
+ return [
'items per page title' => $this->t('Items to display'),
'items per page description' => $this->t('Enter 0 for no limit.')
- );
+ ];
}
/**
@@ -2591,7 +2591,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$defined_options = $this->defineOptions();
// Build a map of plural => singular for handler types.
- $type_map = array();
+ $type_map = [];
foreach (ViewExecutable::getHandlerTypes() as $type => $info) {
$type_map[$info['plural']] = $type;
}
@@ -2668,7 +2668,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
// https://www.drupal.org/node/2173811.
// Pass the current rendering language (in this case a one element array) so
// is not lost when there are language configuration changes.
- return $this->listLanguages(LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED | PluginBase::INCLUDE_ENTITY, array($this->getOption('rendering_language')));
+ return $this->listLanguages(LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED | PluginBase::INCLUDE_ENTITY, [$this->getOption('rendering_language')]);
}
/**
diff --git a/core/modules/views/src/Plugin/views/display/EntityReference.php b/core/modules/views/src/Plugin/views/display/EntityReference.php
index 8291378390b..4dedd51a83d 100644
--- a/core/modules/views/src/Plugin/views/display/EntityReference.php
+++ b/core/modules/views/src/Plugin/views/display/EntityReference.php
@@ -49,9 +49,9 @@ class EntityReference extends DisplayPluginBase {
// Force the style plugin to 'entity_reference_style' and the row plugin to
// 'fields'.
- $options['style']['contains']['type'] = array('default' => 'entity_reference');
+ $options['style']['contains']['type'] = ['default' => 'entity_reference'];
$options['defaults']['default']['style'] = FALSE;
- $options['row']['contains']['type'] = array('default' => 'entity_reference');
+ $options['row']['contains']['type'] = ['default' => 'entity_reference'];
$options['defaults']['default']['row'] = FALSE;
// Make sure the query is not cached.
@@ -167,14 +167,14 @@ class EntityReference extends DisplayPluginBase {
// Verify that search fields are set up.
$style = $this->getOption('style');
if (!isset($style['options']['search_fields'])) {
- $errors[] = $this->t('Display "@display" needs a selected search fields to work properly. See the settings for the Entity Reference list format.', array('@display' => $this->display['display_title']));
+ $errors[] = $this->t('Display "@display" needs a selected search fields to work properly. See the settings for the Entity Reference list format.', ['@display' => $this->display['display_title']]);
}
else {
// Verify that the search fields used actually exist.
$fields = array_keys($this->handlers['field']);
foreach ($style['options']['search_fields'] as $field_alias => $enabled) {
if ($enabled && !in_array($field_alias, $fields)) {
- $errors[] = $this->t('Display "@display" uses field %field as search field, but the field is no longer present. See the settings for the Entity Reference list format.', array('@display' => $this->display['display_title'], '%field' => $field_alias));
+ $errors[] = $this->t('Display "@display" uses field %field as search field, but the field is no longer present. See the settings for the Entity Reference list format.', ['@display' => $this->display['display_title'], '%field' => $field_alias]);
}
}
}
diff --git a/core/modules/views/src/Plugin/views/display/Feed.php b/core/modules/views/src/Plugin/views/display/Feed.php
index 35da2459155..c664c053e25 100644
--- a/core/modules/views/src/Plugin/views/display/Feed.php
+++ b/core/modules/views/src/Plugin/views/display/Feed.php
@@ -90,11 +90,11 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
$output = $this->view->render();
if (!empty($this->view->live_preview)) {
- $output = array(
+ $output = [
'#prefix' => '<pre>',
'#plain_text' => drupal_render_root($output),
'#suffix' => '</pre>',
- );
+ ];
}
return $output;
@@ -117,7 +117,7 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
public function defaultableSections($section = NULL) {
$sections = parent::defaultableSections($section);
- if (in_array($section, array('style', 'row'))) {
+ if (in_array($section, ['style', 'row'])) {
return FALSE;
}
@@ -137,11 +137,11 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['displays'] = array('default' => array());
+ $options['displays'] = ['default' => []];
// Overrides for standard stuff.
$options['style']['contains']['type']['default'] = 'rss';
- $options['style']['contains']['options']['default'] = array('description' => '');
+ $options['style']['contains']['options']['default'] = ['description' => ''];
$options['sitename_title']['default'] = FALSE;
$options['row']['contains']['type']['default'] = 'rss_fields';
$options['defaults']['default']['style'] = FALSE;
@@ -160,7 +160,7 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
// definition, but in this case it's dependent on the view's base table,
// which we don't know until init().
if (empty($this->options['row']['type']) || $this->options['row']['type'] === 'rss_fields') {
- $row_plugins = Views::fetchPluginNames('row', $this->getType(), array($this->view->storage->get('base_table')));
+ $row_plugins = Views::fetchPluginNames('row', $this->getType(), [$this->view->storage->get('base_table')]);
$default_row_plugin = key($row_plugins);
$options = $this->getOption('row');
@@ -177,13 +177,13 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
// Since we're childing off the 'path' type, we'll still *call* our
// category 'page' but let's override it so it says feed settings.
- $categories['page'] = array(
+ $categories['page'] = [
'title' => $this->t('Feed settings'),
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -10,
- ),
- );
+ ],
+ ];
if ($this->getOption('sitename_title')) {
$options['title']['value'] = $this->t('Using the site name');
@@ -205,11 +205,11 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
$attach_to = $this->t('None');
}
- $options['displays'] = array(
+ $options['displays'] = [
'category' => 'page',
'title' => $this->t('Attach to'),
'value' => $attach_to,
- );
+ ];
}
/**
@@ -224,34 +224,34 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
$title = $form['title'];
// A little juggling to move the 'title' field beyond our checkbox.
unset($form['title']);
- $form['sitename_title'] = array(
+ $form['sitename_title'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use the site name for the title'),
'#default_value' => $this->getOption('sitename_title'),
- );
+ ];
$form['title'] = $title;
- $form['title']['#states'] = array(
- 'visible' => array(
- ':input[name="sitename_title"]' => array('checked' => FALSE),
- ),
- );
+ $form['title']['#states'] = [
+ 'visible' => [
+ ':input[name="sitename_title"]' => ['checked' => FALSE],
+ ],
+ ];
break;
case 'displays':
$form['#title'] .= $this->t('Attach to');
- $displays = array();
+ $displays = [];
foreach ($this->view->storage->get('display') as $display_id => $display) {
// @todo The display plugin should have display_title and id as well.
if ($this->view->displayHandlers->has($display_id) && $this->view->displayHandlers->get($display_id)->acceptAttachments()) {
$displays[$display_id] = $display['display_title'];
}
}
- $form['displays'] = array(
+ $form['displays'] = [
'#title' => $this->t('Displays'),
'#type' => 'checkboxes',
'#description' => $this->t('The feed icon will be available only to the selected displays.'),
'#options' => array_map('\Drupal\Component\Utility\Html::escape', $displays),
'#default_value' => $this->getOption('displays'),
- );
+ ];
break;
case 'path':
$form['path']['#description'] = $this->t('This view will be displayed by visiting this path on your site. It is recommended that the path be something like "path/%/%/feed" or "path/%/%/rss.xml", putting one % in the path for each contextual filter you have defined in the view.');
diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php
index d79b75b8337..aca0683f3c5 100644
--- a/core/modules/views/src/Plugin/views/display/Page.php
+++ b/core/modules/views/src/Plugin/views/display/Page.php
@@ -118,27 +118,27 @@ class Page extends PathPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['menu'] = array(
- 'contains' => array(
- 'type' => array('default' => 'none'),
- 'title' => array('default' => ''),
- 'description' => array('default' => ''),
- 'weight' => array('default' => 0),
- 'enabled' => array('default' => TRUE),
- 'menu_name' => array('default' => 'main'),
- 'parent' => array('default' => ''),
- 'context' => array('default' => ''),
- 'expanded' => array('default' => FALSE),
- ),
- );
- $options['tab_options'] = array(
- 'contains' => array(
- 'type' => array('default' => 'none'),
- 'title' => array('default' => ''),
- 'description' => array('default' => ''),
- 'weight' => array('default' => 0),
- ),
- );
+ $options['menu'] = [
+ 'contains' => [
+ 'type' => ['default' => 'none'],
+ 'title' => ['default' => ''],
+ 'description' => ['default' => ''],
+ 'weight' => ['default' => 0],
+ 'enabled' => ['default' => TRUE],
+ 'menu_name' => ['default' => 'main'],
+ 'parent' => ['default' => ''],
+ 'context' => ['default' => ''],
+ 'expanded' => ['default' => FALSE],
+ ],
+ ];
+ $options['tab_options'] = [
+ 'contains' => [
+ 'type' => ['default' => 'none'],
+ 'title' => ['default' => ''],
+ 'description' => ['default' => ''],
+ 'weight' => ['default' => 0],
+ ],
+ ];
return $options;
}
@@ -175,9 +175,9 @@ class Page extends PathPluginBase {
// @todo Figure out how to support custom response objects. Maybe for pages
// it should be dropped.
if (is_array($render)) {
- $render += array(
+ $render += [
'#title' => ['#markup' => $this->view->getTitle(), '#allowed_tags' => Xss::getHtmlTagList()],
- );
+ ];
}
return $render;
}
@@ -190,7 +190,7 @@ class Page extends PathPluginBase {
$menu = $this->getOption('menu');
if (!is_array($menu)) {
- $menu = array('type' => 'none');
+ $menu = ['type' => 'none'];
}
switch ($menu['type']) {
case 'none':
@@ -198,19 +198,19 @@ class Page extends PathPluginBase {
$menu_str = $this->t('No menu');
break;
case 'normal':
- $menu_str = $this->t('Normal: @title', array('@title' => $menu['title']));
+ $menu_str = $this->t('Normal: @title', ['@title' => $menu['title']]);
break;
case 'tab':
case 'default tab':
- $menu_str = $this->t('Tab: @title', array('@title' => $menu['title']));
+ $menu_str = $this->t('Tab: @title', ['@title' => $menu['title']]);
break;
}
- $options['menu'] = array(
+ $options['menu'] = [
'category' => 'page',
'title' => $this->t('Menu'),
'value' => views_ui_truncate($menu_str, 24),
- );
+ ];
// This adds a 'Settings' link to the style_options setting if the style
// has options.
@@ -229,67 +229,67 @@ class Page extends PathPluginBase {
switch ($form_state->get('section')) {
case 'menu':
$form['#title'] .= $this->t('Menu item entry');
- $form['menu'] = array(
+ $form['menu'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
+ ];
$menu = $this->getOption('menu');
if (empty($menu)) {
- $menu = array('type' => 'none', 'title' => '', 'weight' => 0, 'expanded' => FALSE);
+ $menu = ['type' => 'none', 'title' => '', 'weight' => 0, 'expanded' => FALSE];
}
- $form['menu']['type'] = array(
+ $form['menu']['type'] = [
'#prefix' => '<div class="views-left-30">',
'#suffix' => '</div>',
'#title' => $this->t('Type'),
'#type' => 'radios',
- '#options' => array(
+ '#options' => [
'none' => $this->t('No menu entry'),
'normal' => $this->t('Normal menu entry'),
'tab' => $this->t('Menu tab'),
'default tab' => $this->t('Default menu tab')
- ),
+ ],
'#default_value' => $menu['type'],
- );
+ ];
- $form['menu']['title'] = array(
+ $form['menu']['title'] = [
'#prefix' => '<div class="views-left-50">',
'#title' => $this->t('Menu link title'),
'#type' => 'textfield',
'#default_value' => $menu['title'],
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="menu[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'tab'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'default tab'),
- ),
- ),
- ),
- );
- $form['menu']['description'] = array(
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="menu[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'tab'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'default tab'],
+ ],
+ ],
+ ],
+ ];
+ $form['menu']['description'] = [
'#title' => $this->t('Description'),
'#type' => 'textfield',
'#default_value' => $menu['description'],
'#description' => $this->t("Shown when hovering over the menu link."),
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="menu[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'tab'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'default tab'),
- ),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="menu[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'tab'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'default tab'],
+ ],
+ ],
+ ],
+ ];
$form['menu']['expanded'] = [
'#title' => $this->t('Show as expanded'),
'#type' => 'checkbox',
@@ -302,133 +302,133 @@ class Page extends PathPluginBase {
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
$menu_link = 'views_view:views.' . $form_state->get('view')->id() . '.' . $form_state->get('display_id');
$form['menu']['parent'] = \Drupal::service('menu.parent_form_selector')->parentSelectElement($menu_parent, $menu_link);
- $form['menu']['parent'] += array(
+ $form['menu']['parent'] += [
'#title' => $this->t('Parent'),
'#description' => $this->t('The maximum depth for a link and all its children is fixed. Some menu links may not be available as parents if selecting them would exceed this limit.'),
- '#attributes' => array('class' => array('menu-title-select')),
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="menu[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'tab'),
- ),
- ),
- ),
- );
+ '#attributes' => ['class' => ['menu-title-select']],
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="menu[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'tab'],
+ ],
+ ],
+ ],
+ ];
}
else {
- $form['menu']['parent'] = array(
+ $form['menu']['parent'] = [
'#type' => 'value',
'#value' => $menu_parent,
- );
- $form['menu']['markup'] = array(
+ ];
+ $form['menu']['markup'] = [
'#markup' => $this->t('Menu selection requires the activation of Menu UI module.'),
- );
+ ];
}
- $form['menu']['weight'] = array(
+ $form['menu']['weight'] = [
'#title' => $this->t('Weight'),
'#type' => 'textfield',
'#default_value' => isset($menu['weight']) ? $menu['weight'] : 0,
'#description' => $this->t('In the menu, the heavier links will sink and the lighter links will be positioned nearer the top.'),
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="menu[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'tab'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'default tab'),
- ),
- ),
- ),
- );
- $form['menu']['context'] = array(
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="menu[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'tab'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'default tab'],
+ ],
+ ],
+ ],
+ ];
+ $form['menu']['context'] = [
'#title' => $this->t('Context'),
'#suffix' => '</div>',
'#type' => 'checkbox',
'#default_value' => !empty($menu['context']),
'#description' => $this->t('Displays the link in contextual links'),
- '#states' => array(
- 'visible' => array(
- ':input[name="menu[type]"]' => array('value' => 'tab'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="menu[type]"]' => ['value' => 'tab'],
+ ],
+ ],
+ ];
break;
case 'tab_options':
$form['#title'] .= $this->t('Default tab options');
$tab_options = $this->getOption('tab_options');
if (empty($tab_options)) {
- $tab_options = array('type' => 'none', 'title' => '', 'weight' => 0);
+ $tab_options = ['type' => 'none', 'title' => '', 'weight' => 0];
}
- $form['tab_markup'] = array(
+ $form['tab_markup'] = [
'#markup' => '<div class="js-form-item form-item description">' . $this->t('When providing a menu item as a tab, Drupal needs to know what the parent menu item of that tab will be. Sometimes the parent will already exist, but other times you will need to have one created. The path of a parent item will always be the same path with the last part left off. i.e, if the path to this view is <em>foo/bar/baz</em>, the parent path would be <em>foo/bar</em>.') . '</div>',
- );
+ ];
- $form['tab_options'] = array(
+ $form['tab_options'] = [
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#tree' => TRUE,
- );
- $form['tab_options']['type'] = array(
+ ];
+ $form['tab_options']['type'] = [
'#prefix' => '<div class="views-left-25">',
'#suffix' => '</div>',
'#title' => $this->t('Parent menu item'),
'#type' => 'radios',
- '#options' => array('none' => $this->t('Already exists'), 'normal' => $this->t('Normal menu item'), 'tab' => $this->t('Menu tab')),
+ '#options' => ['none' => $this->t('Already exists'), 'normal' => $this->t('Normal menu item'), 'tab' => $this->t('Menu tab')],
'#default_value' => $tab_options['type'],
- );
- $form['tab_options']['title'] = array(
+ ];
+ $form['tab_options']['title'] = [
'#prefix' => '<div class="views-left-75">',
'#title' => $this->t('Title'),
'#type' => 'textfield',
'#default_value' => $tab_options['title'],
'#description' => $this->t('If creating a parent menu item, enter the title of the item.'),
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="tab_options[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="tab_options[type]"]' => array('value' => 'tab'),
- ),
- ),
- ),
- );
- $form['tab_options']['description'] = array(
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="tab_options[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="tab_options[type]"]' => ['value' => 'tab'],
+ ],
+ ],
+ ],
+ ];
+ $form['tab_options']['description'] = [
'#title' => $this->t('Description'),
'#type' => 'textfield',
'#default_value' => $tab_options['description'],
'#description' => $this->t('If creating a parent menu item, enter the description of the item.'),
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="tab_options[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="tab_options[type]"]' => array('value' => 'tab'),
- ),
- ),
- ),
- );
- $form['tab_options']['weight'] = array(
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="tab_options[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="tab_options[type]"]' => ['value' => 'tab'],
+ ],
+ ],
+ ],
+ ];
+ $form['tab_options']['weight'] = [
'#suffix' => '</div>',
'#title' => $this->t('Tab weight'),
'#type' => 'textfield',
'#default_value' => $tab_options['weight'],
'#size' => 5,
'#description' => $this->t('If the parent menu item is a tab, enter the weight of the tab. Heavier tabs will sink and the lighter tabs will be positioned nearer to the first menu item.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="tab_options[type]"]' => array('value' => 'tab'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="tab_options[type]"]' => ['value' => 'tab'],
+ ],
+ ],
+ ];
break;
}
}
@@ -441,7 +441,7 @@ class Page extends PathPluginBase {
if ($form_state->get('section') == 'menu') {
$path = $this->getOption('path');
- $menu_type = $form_state->getValue(array('menu', 'type'));
+ $menu_type = $form_state->getValue(['menu', 'type']);
if ($menu_type == 'normal' && strpos($path, '%') !== FALSE) {
$form_state->setError($form['menu']['type'], $this->t('Views cannot create normal menu items for paths with a % in them.'));
}
@@ -454,7 +454,7 @@ class Page extends PathPluginBase {
}
}
- if ($menu_type != 'none' && $form_state->isValueEmpty(array('menu', 'title'))) {
+ if ($menu_type != 'none' && $form_state->isValueEmpty(['menu', 'title'])) {
$form_state->setError($form['menu']['title'], $this->t('Title is required for this menu type.'));
}
}
@@ -472,7 +472,7 @@ class Page extends PathPluginBase {
list($menu['menu_name'], $menu['parent']) = explode(':', $menu['parent'], 2);
$this->setOption('menu', $menu);
// send ajax form to options page if we use it.
- if ($form_state->getValue(array('menu', 'type')) == 'default tab') {
+ if ($form_state->getValue(['menu', 'type']) == 'default tab') {
$form_state->get('view')->addFormToStack('display', $this->display['id'], 'tab_options');
}
break;
@@ -490,13 +490,13 @@ class Page extends PathPluginBase {
$menu = $this->getOption('menu');
if (!empty($menu['type']) && $menu['type'] != 'none' && empty($menu['title'])) {
- $errors[] = $this->t('Display @display is set to use a menu but the menu link text is not set.', array('@display' => $this->display['display_title']));
+ $errors[] = $this->t('Display @display is set to use a menu but the menu link text is not set.', ['@display' => $this->display['display_title']]);
}
if ($menu['type'] == 'default tab') {
$tab_options = $this->getOption('tab_options');
if (!empty($tab_options['type']) && $tab_options['type'] != 'none' && empty($tab_options['title'])) {
- $errors[] = $this->t('Display @display is set to use a parent menu but the parent menu link text is not set.', array('@display' => $this->display['display_title']));
+ $errors[] = $this->t('Display @display is set to use a parent menu but the parent menu link text is not set.', ['@display' => $this->display['display_title']]);
}
}
@@ -507,21 +507,21 @@ class Page extends PathPluginBase {
* {@inheritdoc}
*/
public function getArgumentText() {
- return array(
+ return [
'filter value not present' => $this->t('When the filter value is <em>NOT</em> in the URL'),
'filter value present' => $this->t('When the filter value <em>IS</em> in the URL or a default is provided'),
'description' => $this->t('The contextual filter values are provided by the URL.'),
- );
+ ];
}
/**
* {@inheritdoc}
*/
public function getPagerText() {
- return array(
+ return [
'items per page title' => $this->t('Items per page'),
'items per page description' => $this->t('Enter 0 for no limit.')
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
index 3654d63aa1b..17d8663ed16 100644
--- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
@@ -109,8 +109,8 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['path'] = array('default' => '');
- $options['route_name'] = array('default' => '');
+ $options['path'] = ['default' => ''];
+ $options['route_name'] = ['default' => ''];
return $options;
}
@@ -127,13 +127,13 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
* The route for the view.
*/
protected function getRoute($view_id, $display_id) {
- $defaults = array(
+ $defaults = [
'_controller' => 'Drupal\views\Routing\ViewPageController::handle',
'_title' => $this->view->getTitle(),
'view_id' => $view_id,
'display_id' => $display_id,
'_view_display_show_admin_links' => $this->getOption('show_admin_links'),
- );
+ ];
// @todo How do we apply argument validation?
$bits = explode('/', $this->getOption('path'));
@@ -145,7 +145,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
$argument_ids = array_keys((array) $this->getOption('arguments'));
$total_arguments = count($argument_ids);
- $argument_map = array();
+ $argument_map = [];
// Replace arguments in the views UI (defined via %) with parameters in
// routes (defined via {}). As a name for the parameter use arg_$key, so
@@ -223,7 +223,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
$route_name = "view.$view_id.$display_id";
}
$collection->add($route_name, $route);
- return array("$view_id.$display_id" => $route_name);
+ return ["$view_id.$display_id" => $route_name];
}
/**
@@ -274,7 +274,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
* {@inheritdoc}
*/
public function alterRoutes(RouteCollection $collection) {
- $view_route_names = array();
+ $view_route_names = [];
$view_path = $this->getPath();
$view_id = $this->view->storage->id();
$display_id = $this->display['id'];
@@ -293,7 +293,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
$path = $view_route->getPath();
// Replace the path with the original parameter names and add a mapping.
- $argument_map = array();
+ $argument_map = [];
// We assume that the numeric ids of the parameters match the one from
// the view argument handlers.
foreach ($parameters as $position => $parameter_name) {
@@ -324,7 +324,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
* {@inheritdoc}
*/
public function getMenuLinks() {
- $links = array();
+ $links = [];
// Replace % with the link to our standard views argument loader
// views_arg_load -- which lives in views.module.
@@ -336,7 +336,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
foreach ($bits as $pos => $bit) {
if ($bit == '%') {
// If a view requires any arguments we cannot create a static menu link.
- return array();
+ return [];
}
}
@@ -349,15 +349,15 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
if ($path) {
$menu = $this->getOption('menu');
if (!empty($menu['type']) && $menu['type'] == 'normal') {
- $links[$menu_link_id] = array();
+ $links[$menu_link_id] = [];
// Some views might override existing paths, so we have to set the route
// name based upon the altering.
- $links[$menu_link_id] = array(
+ $links[$menu_link_id] = [
'route_name' => $this->getRouteName(),
// Identify URL embedded arguments and correlate them to a handler.
- 'load arguments' => array($this->view->storage->id(), $this->display['id'], '%index'),
+ 'load arguments' => [$this->view->storage->id(), $this->display['id'], '%index'],
'id' => $menu_link_id,
- );
+ ];
$links[$menu_link_id]['title'] = $menu['title'];
$links[$menu_link_id]['description'] = $menu['description'];
$links[$menu_link_id]['parent'] = $menu['parent'];
@@ -371,10 +371,10 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
// Insert item into the proper menu.
$links[$menu_link_id]['menu_name'] = $menu['menu_name'];
// Keep track of where we came from.
- $links[$menu_link_id]['metadata'] = array(
+ $links[$menu_link_id]['metadata'] = [
'view_id' => $view_id,
'display_id' => $display_id,
- );
+ ];
}
}
@@ -404,13 +404,13 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
- $categories['page'] = array(
+ $categories['page'] = [
'title' => $this->t('Page settings'),
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -10,
- ),
- );
+ ],
+ ];
$path = strip_tags($this->getOption('path'));
@@ -421,11 +421,11 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
$path = '/' . $path;
}
- $options['path'] = array(
+ $options['path'] = [
'category' => 'page',
'title' => $this->t('Path'),
'value' => views_ui_truncate($path, 24),
- );
+ ];
}
/**
@@ -437,17 +437,17 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
switch ($form_state->get('section')) {
case 'path':
$form['#title'] .= $this->t('The menu path or URL of this view');
- $form['path'] = array(
+ $form['path'] = [
'#type' => 'textfield',
'#title' => $this->t('Path'),
'#description' => $this->t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed". If needed you can even specify named route parameters like taxonomy/term/%taxonomy_term'),
'#default_value' => $this->getOption('path'),
'#field_prefix' => '<span dir="ltr">' . $this->url('<none>', [], ['absolute' => TRUE]),
'#field_suffix' => '</span>&lrm;',
- '#attributes' => array('dir' => LanguageInterface::DIRECTION_LTR),
+ '#attributes' => ['dir' => LanguageInterface::DIRECTION_LTR],
// Account for the leading backslash.
'#maxlength' => 254,
- );
+ ];
break;
}
}
@@ -490,7 +490,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
* A list of error strings.
*/
protected function validatePath($path) {
- $errors = array();
+ $errors = [];
if (strpos($path, '%') === 0) {
$errors[] = $this->t('"%" may not be used for the first segment of a path.');
}
@@ -557,7 +557,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
* {@inheritdoc}
*/
public function getAlteredRouteNames() {
- return $this->state->get('views.view_route_names') ?: array();
+ return $this->state->get('views.view_route_names') ?: [];
}
/**
diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
index 4a2bc81d036..fffe084c725 100644
--- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
+++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
@@ -26,13 +26,13 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['submit_button'] = array('default' => $this->t('Apply'));
- $options['reset_button'] = array('default' => FALSE);
- $options['reset_button_label'] = array('default' => $this->t('Reset'));
- $options['exposed_sorts_label'] = array('default' => $this->t('Sort by'));
- $options['expose_sort_order'] = array('default' => TRUE);
- $options['sort_asc_label'] = array('default' => $this->t('Asc'));
- $options['sort_desc_label'] = array('default' => $this->t('Desc'));
+ $options['submit_button'] = ['default' => $this->t('Apply')];
+ $options['reset_button'] = ['default' => FALSE];
+ $options['reset_button_label'] = ['default' => $this->t('Reset')];
+ $options['exposed_sorts_label'] = ['default' => $this->t('Sort by')];
+ $options['expose_sort_order'] = ['default' => TRUE];
+ $options['sort_asc_label'] = ['default' => $this->t('Asc')];
+ $options['sort_desc_label'] = ['default' => $this->t('Desc')];
return $options;
}
@@ -41,69 +41,69 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['submit_button'] = array(
+ $form['submit_button'] = [
'#type' => 'textfield',
'#title' => $this->t('Submit button text'),
'#default_value' => $this->options['submit_button'],
'#required' => TRUE,
- );
+ ];
- $form['reset_button'] = array(
+ $form['reset_button'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include reset button (resets all applied exposed filters)'),
'#default_value' => $this->options['reset_button'],
- );
+ ];
- $form['reset_button_label'] = array(
+ $form['reset_button_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Reset button label'),
'#description' => $this->t('Text to display in the reset button of the exposed form.'),
'#default_value' => $this->options['reset_button_label'],
'#required' => TRUE,
- '#states' => array(
- 'invisible' => array(
- 'input[name="exposed_form_options[reset_button]"]' => array('checked' => FALSE),
- ),
- ),
- );
-
- $form['exposed_sorts_label'] = array(
+ '#states' => [
+ 'invisible' => [
+ 'input[name="exposed_form_options[reset_button]"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+
+ $form['exposed_sorts_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Exposed sorts label'),
'#default_value' => $this->options['exposed_sorts_label'],
'#required' => TRUE,
- );
+ ];
- $form['expose_sort_order'] = array(
+ $form['expose_sort_order'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow people to choose the sort order'),
'#description' => $this->t('If sort order is not exposed, the sort criteria settings for each sort will determine its order.'),
'#default_value' => $this->options['expose_sort_order'],
- );
+ ];
- $form['sort_asc_label'] = array(
+ $form['sort_asc_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label for ascending sort'),
'#default_value' => $this->options['sort_asc_label'],
'#required' => TRUE,
- '#states' => array(
- 'visible' => array(
- 'input[name="exposed_form_options[expose_sort_order]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['sort_desc_label'] = array(
+ '#states' => [
+ 'visible' => [
+ 'input[name="exposed_form_options[expose_sort_order]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['sort_desc_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label for descending sort'),
'#default_value' => $this->options['sort_desc_label'],
'#required' => TRUE,
- '#states' => array(
- 'visible' => array(
- 'input[name="exposed_form_options[expose_sort_order]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ 'input[name="exposed_form_options[expose_sort_order]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
}
/**
@@ -141,7 +141,7 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
}
if (!$this->view->display_handler->displaysExposed() || (!$block && $this->view->display_handler->getOption('exposed_block'))) {
- return array();
+ return [];
}
else {
return $form;
@@ -153,19 +153,19 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
*/
public function query() {
$view = $this->view;
- $exposed_data = isset($view->exposed_data) ? $view->exposed_data : array();
+ $exposed_data = isset($view->exposed_data) ? $view->exposed_data : [];
$sort_by = isset($exposed_data['sort_by']) ? $exposed_data['sort_by'] : NULL;
if (!empty($sort_by)) {
// Make sure the original order of sorts is preserved
// (e.g. a sticky sort is often first)
if (isset($view->sort[$sort_by])) {
- $view->query->orderby = array();
+ $view->query->orderby = [];
foreach ($view->sort as $key => $sort) {
if (!$sort->isExposed()) {
$sort->query();
}
elseif ($key == $sort_by) {
- if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], array('ASC', 'DESC'))) {
+ if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], ['ASC', 'DESC'])) {
$sort->options['order'] = $exposed_data['sort_order'];
}
$sort->setRelationship();
@@ -205,7 +205,7 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
}
// Check if there is exposed sorts for this view
- $exposed_sorts = array();
+ $exposed_sorts = [];
foreach ($this->view->sort as $id => $handler) {
if ($handler->canExpose() && $handler->isExposed()) {
$exposed_sorts[$id] = Html::escape($handler->options['expose']['label']);
@@ -213,15 +213,15 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
}
if (count($exposed_sorts)) {
- $form['sort_by'] = array(
+ $form['sort_by'] = [
'#type' => 'select',
'#options' => $exposed_sorts,
'#title' => $this->options['exposed_sorts_label'],
- );
- $sort_order = array(
+ ];
+ $sort_order = [
'ASC' => $this->options['sort_asc_label'],
'DESC' => $this->options['sort_desc_label'],
- );
+ ];
$user_input = $form_state->getUserInput();
if (isset($user_input['sort_by']) && isset($this->view->sort[$user_input['sort_by']])) {
$default_sort_order = $this->view->sort[$user_input['sort_by']]->options['order'];
@@ -238,22 +238,22 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
}
if ($this->options['expose_sort_order']) {
- $form['sort_order'] = array(
+ $form['sort_order'] = [
'#type' => 'select',
'#options' => $sort_order,
- '#title' => $this->t('Order', array(), array('context' => 'Sort order')),
+ '#title' => $this->t('Order', [], ['context' => 'Sort order']),
'#default_value' => $default_sort_order,
- );
+ ];
}
$form['submit']['#weight'] = 10;
}
if (!empty($this->options['reset_button'])) {
- $form['actions']['reset'] = array(
+ $form['actions']['reset'] = [
'#value' => $this->options['reset_button_label'],
'#type' => 'submit',
'#weight' => 10,
- );
+ ];
// Get an array of exposed filters, keyed by identifier option.
$exposed_filters = [];
@@ -329,7 +329,7 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
}
else {
$form_state->setRebuild();
- $this->view->exposed_data = array();
+ $this->view->exposed_data = [];
}
$form_state->setRedirect('<current>');
diff --git a/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
index 8b885978de4..38a5283606c 100644
--- a/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
+++ b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
@@ -21,28 +21,28 @@ class InputRequired extends ExposedFormPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['text_input_required'] = array('default' => $this->t('Select any filter and click on Apply to see results'));
- $options['text_input_required_format'] = array('default' => NULL);
+ $options['text_input_required'] = ['default' => $this->t('Select any filter and click on Apply to see results')];
+ $options['text_input_required_format'] = ['default' => NULL];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['text_input_required'] = array(
+ $form['text_input_required'] = [
'#type' => 'text_format',
'#title' => $this->t('Text on demand'),
'#description' => $this->t('Text to display instead of results until the user selects and applies an exposed filter.'),
'#default_value' => $this->options['text_input_required'],
'#format' => isset($this->options['text_input_required_format']) ? $this->options['text_input_required_format'] : filter_default_format(),
'#editor' => FALSE,
- );
+ ];
}
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
$exposed_form_options = $form_state->getValue('exposed_form_options');
- $form_state->setValue(array('exposed_form_options', 'text_input_required_format'), $exposed_form_options['text_input_required']['format']);
- $form_state->setValue(array('exposed_form_options', 'text_input_required'), $exposed_form_options['text_input_required']['value']);
+ $form_state->setValue(['exposed_form_options', 'text_input_required_format'], $exposed_form_options['text_input_required']['format']);
+ $form_state->setValue(['exposed_form_options', 'text_input_required'], $exposed_form_options['text_input_required']['value']);
parent::submitOptionsForm($form, $form_state);
}
@@ -72,7 +72,7 @@ class InputRequired extends ExposedFormPluginBase {
// text to display instead of results until the user selects and applies
// an exposed filter.
if (!$this->exposedFilterApplied()) {
- $options = array(
+ $options = [
'id' => 'area',
'table' => 'views',
'field' => 'area',
@@ -88,14 +88,14 @@ class InputRequired extends ExposedFormPluginBase {
'value' => $this->options['text_input_required'],
'format' => $this->options['text_input_required_format'],
],
- );
+ ];
$handler = Views::handlerManager('area')->getHandler($options);
$handler->init($this->view, $this->displayHandler, $options);
- $this->displayHandler->handlers['empty'] = array(
+ $this->displayHandler->handlers['empty'] = [
'area' => $handler,
- );
+ ];
// Override the existing empty result message (if applicable).
- $this->displayHandler->setOption('empty', array('text' => $options));
+ $this->displayHandler->setOption('empty', ['text' => $options]);
}
}
@@ -104,7 +104,7 @@ class InputRequired extends ExposedFormPluginBase {
// We return with no query; this will force the empty text.
$this->view->built = TRUE;
$this->view->executed = TRUE;
- $this->view->result = array();
+ $this->view->result = [];
}
else {
parent::query();
diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php
index 59d3b292fbc..75f097e1348 100644
--- a/core/modules/views/src/Plugin/views/field/Boolean.php
+++ b/core/modules/views/src/Plugin/views/field/Boolean.php
@@ -34,10 +34,10 @@ class Boolean extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['type'] = array('default' => 'yes-no');
- $options['type_custom_true'] = array('default' => '');
- $options['type_custom_false'] = array('default' => '');
- $options['not'] = array('default' => FALSE);
+ $options['type'] = ['default' => 'yes-no'];
+ $options['type_custom_true'] = ['default' => ''];
+ $options['type_custom_false'] = ['default' => ''];
+ $options['not'] = ['default' => FALSE];
return $options;
}
@@ -48,16 +48,16 @@ class Boolean extends FieldPluginBase {
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
- $default_formats = array(
- 'yes-no' => array(t('Yes'), $this->t('No')),
- 'true-false' => array(t('True'), $this->t('False')),
- 'on-off' => array(t('On'), $this->t('Off')),
- 'enabled-disabled' => array(t('Enabled'), $this->t('Disabled')),
- 'boolean' => array(1, 0),
- 'unicode-yes-no' => array('✔', '✖'),
- );
- $output_formats = isset($this->definition['output formats']) ? $this->definition['output formats'] : array();
- $custom_format = array('custom' => array(t('Custom')));
+ $default_formats = [
+ 'yes-no' => [t('Yes'), $this->t('No')],
+ 'true-false' => [t('True'), $this->t('False')],
+ 'on-off' => [t('On'), $this->t('Off')],
+ 'enabled-disabled' => [t('Enabled'), $this->t('Disabled')],
+ 'boolean' => [1, 0],
+ 'unicode-yes-no' => ['✔', '✖'],
+ ];
+ $output_formats = isset($this->definition['output formats']) ? $this->definition['output formats'] : [];
+ $custom_format = ['custom' => [t('Custom')]];
$this->formats = array_merge($default_formats, $output_formats, $custom_format);
}
@@ -69,38 +69,38 @@ class Boolean extends FieldPluginBase {
$options[$key] = implode('/', $item);
}
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'select',
'#title' => $this->t('Output format'),
'#options' => $options,
'#default_value' => $this->options['type'],
- );
- $form['type_custom_true'] = array(
+ ];
+ $form['type_custom_true'] = [
'#type' => 'textfield',
'#title' => $this->t('Custom output for TRUE'),
'#default_value' => $this->options['type_custom_true'],
- '#states' => array(
- 'visible' => array(
- 'select[name="options[type]"]' => array('value' => 'custom'),
- ),
- ),
- );
- $form['type_custom_false'] = array(
+ '#states' => [
+ 'visible' => [
+ 'select[name="options[type]"]' => ['value' => 'custom'],
+ ],
+ ],
+ ];
+ $form['type_custom_false'] = [
'#type' => 'textfield',
'#title' => $this->t('Custom output for FALSE'),
'#default_value' => $this->options['type_custom_false'],
- '#states' => array(
- 'visible' => array(
- 'select[name="options[type]"]' => array('value' => 'custom'),
- ),
- ),
- );
- $form['not'] = array(
+ '#states' => [
+ 'visible' => [
+ 'select[name="options[type]"]' => ['value' => 'custom'],
+ ],
+ ],
+ ];
+ $form['not'] = [
'#type' => 'checkbox',
'#title' => $this->t('Reverse'),
'#description' => $this->t('If checked, true will be displayed as false.'),
'#default_value' => $this->options['not'],
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/core/modules/views/src/Plugin/views/field/Counter.php b/core/modules/views/src/Plugin/views/field/Counter.php
index 06d9b561688..d32e5e754eb 100644
--- a/core/modules/views/src/Plugin/views/field/Counter.php
+++ b/core/modules/views/src/Plugin/views/field/Counter.php
@@ -28,7 +28,7 @@ class Counter extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['counter_start'] = array('default' => 1);
+ $options['counter_start'] = ['default' => 1];
return $options;
}
@@ -36,13 +36,13 @@ class Counter extends FieldPluginBase {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['counter_start'] = array(
+ $form['counter_start'] = [
'#type' => 'textfield',
'#title' => $this->t('Starting value'),
'#default_value' => $this->options['counter_start'],
'#description' => $this->t('Specify the number the counter should start at.'),
'#size' => 2,
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/core/modules/views/src/Plugin/views/field/Custom.php b/core/modules/views/src/Plugin/views/field/Custom.php
index 19552b223e5..6dfa8ac15e4 100644
--- a/core/modules/views/src/Plugin/views/field/Custom.php
+++ b/core/modules/views/src/Plugin/views/field/Custom.php
@@ -37,8 +37,8 @@ class Custom extends FieldPluginBase {
$options = parent::defineOptions();
// Override the alter text option to always alter the text.
- $options['alter']['contains']['alter_text'] = array('default' => TRUE);
- $options['hide_alter_empty'] = array('default' => FALSE);
+ $options['alter']['contains']['alter_text'] = ['default' => TRUE];
+ $options['hide_alter_empty'] = ['default' => FALSE];
return $options;
}
@@ -52,7 +52,7 @@ class Custom extends FieldPluginBase {
unset($form['alter']['alter_text']);
unset($form['alter']['text']['#states']);
unset($form['alter']['help']['#states']);
- $form['#pre_render'][] = array($this, 'preRenderCustomForm');
+ $form['#pre_render'][] = [$this, 'preRenderCustomForm'];
}
/**
diff --git a/core/modules/views/src/Plugin/views/field/Date.php b/core/modules/views/src/Plugin/views/field/Date.php
index f5a5204b196..37455cc783f 100644
--- a/core/modules/views/src/Plugin/views/field/Date.php
+++ b/core/modules/views/src/Plugin/views/field/Date.php
@@ -71,9 +71,9 @@ class Date extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['date_format'] = array('default' => 'small');
- $options['custom_date_format'] = array('default' => '');
- $options['timezone'] = array('default' => '');
+ $options['date_format'] = ['default' => 'small'];
+ $options['custom_date_format'] = ['default' => ''];
+ $options['timezone'] = ['default' => ''];
return $options;
}
@@ -83,15 +83,15 @@ class Date extends FieldPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $date_formats = array();
+ $date_formats = [];
foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) {
- $date_formats[$machine_name] = $this->t('@name format: @date', array('@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)));
+ $date_formats[$machine_name] = $this->t('@name format: @date', ['@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)]);
}
- $form['date_format'] = array(
+ $form['date_format'] = [
'#type' => 'select',
'#title' => $this->t('Date format'),
- '#options' => $date_formats + array(
+ '#options' => $date_formats + [
'custom' => $this->t('Custom'),
'raw time ago' => $this->t('Time ago'),
'time ago' => $this->t('Time ago (with "ago" appended)'),
@@ -100,32 +100,32 @@ class Date extends FieldPluginBase {
'raw time span' => $this->t('Time span (future dates have "-" prepended)'),
'inverse time span' => $this->t('Time span (past dates have "-" prepended)'),
'time span' => $this->t('Time span (with "ago/hence" appended)'),
- ),
+ ],
'#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small',
- );
- $form['custom_date_format'] = array(
+ ];
+ $form['custom_date_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Custom date format'),
'#description' => $this->t('If "Custom", see <a href="http://us.php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.'),
'#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '',
- );
+ ];
// Setup #states for all possible date_formats on the custom_date_format form element.
- foreach (array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span') as $custom_date_possible) {
- $form['custom_date_format']['#states']['visible'][] = array(
- ':input[name="options[date_format]"]' => array('value' => $custom_date_possible),
- );
+ foreach (['custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'] as $custom_date_possible) {
+ $form['custom_date_format']['#states']['visible'][] = [
+ ':input[name="options[date_format]"]' => ['value' => $custom_date_possible],
+ ];
}
- $form['timezone'] = array(
+ $form['timezone'] = [
'#type' => 'select',
'#title' => $this->t('Timezone'),
'#description' => $this->t('Timezone to be used for date output.'),
- '#options' => array('' => $this->t('- Default site/user timezone -')) + system_time_zones(FALSE),
+ '#options' => ['' => $this->t('- Default site/user timezone -')] + system_time_zones(FALSE),
'#default_value' => $this->options['timezone'],
- );
- foreach (array_merge(array('custom'), array_keys($date_formats)) as $timezone_date_formats) {
- $form['timezone']['#states']['visible'][] = array(
- ':input[name="options[date_format]"]' => array('value' => $timezone_date_formats),
- );
+ ];
+ foreach (array_merge(['custom'], array_keys($date_formats)) as $timezone_date_formats) {
+ $form['timezone']['#states']['visible'][] = [
+ ':input[name="options[date_format]"]' => ['value' => $timezone_date_formats],
+ ];
}
parent::buildOptionsForm($form, $form_state);
@@ -137,7 +137,7 @@ class Date extends FieldPluginBase {
public function render(ResultRow $values) {
$value = $this->getValue($values);
$format = $this->options['date_format'];
- if (in_array($format, array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'))) {
+ if (in_array($format, ['custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'])) {
$custom_format = $this->options['custom_date_format'];
}
@@ -146,26 +146,26 @@ class Date extends FieldPluginBase {
$time_diff = REQUEST_TIME - $value; // will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence)
switch ($format) {
case 'raw time ago':
- return $this->dateFormatter->formatTimeDiffSince($value, array('granularity' => is_numeric($custom_format) ? $custom_format : 2));
+ return $this->dateFormatter->formatTimeDiffSince($value, ['granularity' => is_numeric($custom_format) ? $custom_format : 2]);
case 'time ago':
- return $this->t('%time ago', array('%time' => $this->dateFormatter->formatTimeDiffSince($value, array('granularity' => is_numeric($custom_format) ? $custom_format : 2))));
+ return $this->t('%time ago', ['%time' => $this->dateFormatter->formatTimeDiffSince($value, ['granularity' => is_numeric($custom_format) ? $custom_format : 2])]);
case 'raw time hence':
- return $this->dateFormatter->formatTimeDiffUntil($value, array('granularity' => is_numeric($custom_format) ? $custom_format : 2));
+ return $this->dateFormatter->formatTimeDiffUntil($value, ['granularity' => is_numeric($custom_format) ? $custom_format : 2]);
case 'time hence':
- return $this->t('%time hence', array('%time' => $this->dateFormatter->formatTimeDiffUntil($value, array('granularity' => is_numeric($custom_format) ? $custom_format : 2))));
+ return $this->t('%time hence', ['%time' => $this->dateFormatter->formatTimeDiffUntil($value, ['granularity' => is_numeric($custom_format) ? $custom_format : 2])]);
case 'raw time span':
- return ($time_diff < 0 ? '-' : '') . $this->dateFormatter->formatTimeDiffSince($value, array('strict' => FALSE, 'granularity' => is_numeric($custom_format) ? $custom_format : 2));
+ return ($time_diff < 0 ? '-' : '') . $this->dateFormatter->formatTimeDiffSince($value, ['strict' => FALSE, 'granularity' => is_numeric($custom_format) ? $custom_format : 2]);
case 'inverse time span':
- return ($time_diff > 0 ? '-' : '') . $this->dateFormatter->formatTimeDiffSince($value, array('strict' => FALSE, 'granularity' => is_numeric($custom_format) ? $custom_format : 2));
+ return ($time_diff > 0 ? '-' : '') . $this->dateFormatter->formatTimeDiffSince($value, ['strict' => FALSE, 'granularity' => is_numeric($custom_format) ? $custom_format : 2]);
case 'time span':
- $time = $this->dateFormatter->formatTimeDiffSince($value, array('strict' => FALSE, 'granularity' => is_numeric($custom_format) ? $custom_format : 2));
- return ($time_diff < 0) ? $this->t('%time hence', array('%time' => $time)) : $this->t('%time ago', array('%time' => $time));
+ $time = $this->dateFormatter->formatTimeDiffSince($value, ['strict' => FALSE, 'granularity' => is_numeric($custom_format) ? $custom_format : 2]);
+ return ($time_diff < 0) ? $this->t('%time hence', ['%time' => $time]) : $this->t('%time ago', ['%time' => $time]);
case 'custom':
if ($custom_format == 'r') {
diff --git a/core/modules/views/src/Plugin/views/field/Dropbutton.php b/core/modules/views/src/Plugin/views/field/Dropbutton.php
index f5cf4d34553..b5a9b60dc56 100644
--- a/core/modules/views/src/Plugin/views/field/Dropbutton.php
+++ b/core/modules/views/src/Plugin/views/field/Dropbutton.php
@@ -20,10 +20,10 @@ class Dropbutton extends Links {
$links = $this->getLinks();
if (!empty($links)) {
- return array(
+ return [
'#type' => 'dropbutton',
'#links' => $links,
- );
+ ];
}
else {
return '';
diff --git a/core/modules/views/src/Plugin/views/field/EntityField.php b/core/modules/views/src/Plugin/views/field/EntityField.php
index dfabda3a3f9..6a0c762191f 100644
--- a/core/modules/views/src/Plugin/views/field/EntityField.php
+++ b/core/modules/views/src/Plugin/views/field/EntityField.php
@@ -44,7 +44,7 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
*
* @var array
*/
- public $items = array();
+ public $items = [];
/**
* Does the field supports multiple field values.
@@ -232,14 +232,14 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
if ($use_groupby) {
// Add the fields that we're actually grouping on.
- $options = array();
+ $options = [];
if ($this->options['group_column'] != 'entity_id') {
- $options = array($this->options['group_column'] => $this->options['group_column']);
+ $options = [$this->options['group_column'] => $this->options['group_column']];
}
- $options += is_array($this->options['group_columns']) ? $this->options['group_columns'] : array();
+ $options += is_array($this->options['group_columns']) ? $this->options['group_columns'] : [];
// Go through the list and determine the actual column name from field api.
- $fields = array();
+ $fields = [];
$table_mapping = $this->getTableMapping();
$field_definition = $this->getFieldStorageDefinition();
@@ -354,9 +354,9 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
}
// If the field has a "value" column, we probably need that one.
- $options['click_sort_column'] = array(
+ $options['click_sort_column'] = [
'default' => $default_column,
- );
+ ];
if (isset($this->definition['default_formatter'])) {
$options['type'] = ['default' => $this->definition['default_formatter']];
@@ -368,45 +368,45 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
$options['type'] = ['default' => ''];
}
- $options['settings'] = array(
+ $options['settings'] = [
'default' => isset($this->definition['default_formatter_settings']) ? $this->definition['default_formatter_settings'] : [],
- );
- $options['group_column'] = array(
+ ];
+ $options['group_column'] = [
'default' => $default_column,
- );
- $options['group_columns'] = array(
- 'default' => array(),
- );
+ ];
+ $options['group_columns'] = [
+ 'default' => [],
+ ];
// Options used for multiple value fields.
- $options['group_rows'] = array(
+ $options['group_rows'] = [
'default' => TRUE,
- );
+ ];
// If we know the exact number of allowed values, then that can be
// the default. Otherwise, default to 'all'.
- $options['delta_limit'] = array(
+ $options['delta_limit'] = [
'default' => ($field_storage_definition->getCardinality() > 1) ? $field_storage_definition->getCardinality() : 0,
- );
- $options['delta_offset'] = array(
+ ];
+ $options['delta_offset'] = [
'default' => 0,
- );
- $options['delta_reversed'] = array(
+ ];
+ $options['delta_reversed'] = [
'default' => FALSE,
- );
- $options['delta_first_last'] = array(
+ ];
+ $options['delta_first_last'] = [
'default' => FALSE,
- );
+ ];
- $options['multi_type'] = array(
+ $options['multi_type'] = [
'default' => 'separator'
- );
- $options['separator'] = array(
+ ];
+ $options['separator'] = [
'default' => ', '
- );
+ ];
- $options['field_api_classes'] = array(
+ $options['field_api_classes'] = [
'default' => FALSE,
- );
+ ];
return $options;
}
@@ -428,48 +428,48 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
// No need to ask the user anything if the field has only one column.
if (count($field->getColumns()) == 1) {
- $form['click_sort_column'] = array(
+ $form['click_sort_column'] = [
'#type' => 'value',
'#value' => isset($column_names[0]) ? $column_names[0] : '',
- );
+ ];
}
else {
- $form['click_sort_column'] = array(
+ $form['click_sort_column'] = [
'#type' => 'select',
'#title' => $this->t('Column used for click sorting'),
'#options' => array_combine($column_names, $column_names),
'#default_value' => $this->options['click_sort_column'],
'#description' => $this->t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
- );
+ ];
}
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'select',
'#title' => $this->t('Formatter'),
'#options' => $formatters,
'#default_value' => $this->options['type'],
- '#ajax' => array(
+ '#ajax' => [
'url' => views_ui_build_form_url($form_state),
- ),
- '#submit' => array(array($this, 'submitTemporaryForm')),
+ ],
+ '#submit' => [[$this, 'submitTemporaryForm']],
'#executes_submit_callback' => TRUE,
- );
+ ];
- $form['field_api_classes'] = array(
+ $form['field_api_classes'] = [
'#title' => $this->t('Use field template'),
'#type' => 'checkbox',
'#default_value' => $this->options['field_api_classes'],
'#description' => $this->t('If checked, field api classes will be added by field templates. This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'),
'#fieldset' => 'style_settings',
'#weight' => 20,
- );
+ ];
if ($this->multiple) {
$form['field_api_classes']['#description'] .= ' ' . $this->t('Checking this option will cause the group Display Type and Separator values to be ignored.');
}
// Get the settings form.
- $settings_form = array('#value' => array());
+ $settings_form = ['#value' => []];
$format = isset($form_state->getUserInput()['options']['type']) ? $form_state->getUserInput()['options']['type'] : $this->options['type'];
if ($formatter = $this->getFormatterInstance($format)) {
$settings_form = $formatter->settingsForm($form, $form_state);
@@ -500,19 +500,19 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
function multiple_options_form(&$form, FormStateInterface $form_state) {
$field = $this->getFieldDefinition();
- $form['multiple_field_settings'] = array(
+ $form['multiple_field_settings'] = [
'#type' => 'details',
'#title' => $this->t('Multiple field settings'),
'#weight' => 5,
- );
+ ];
- $form['group_rows'] = array(
+ $form['group_rows'] = [
'#title' => $this->t('Display all values in the same row'),
'#type' => 'checkbox',
'#default_value' => $this->options['group_rows'],
'#description' => $this->t('If checked, multiple values for this field will be shown in the same row. If not checked, each value in this field will create a new row. If using group by, please make sure to group by "Entity ID" for this setting to have any effect.'),
'#fieldset' => 'multiple_field_settings',
- );
+ ];
// Make the string translatable by keeping it as a whole rather than
// translating prefix and suffix separately.
@@ -529,37 +529,37 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
$options = array_combine($range, $range);
$size = 1;
}
- $form['multi_type'] = array(
+ $form['multi_type'] = [
'#type' => 'radios',
'#title' => $this->t('Display type'),
- '#options' => array(
+ '#options' => [
'ul' => $this->t('Unordered list'),
'ol' => $this->t('Ordered list'),
'separator' => $this->t('Simple separator'),
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[group_rows]"]' => array('checked' => TRUE),
- ),
- ),
+ ],
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[group_rows]"]' => ['checked' => TRUE],
+ ],
+ ],
'#default_value' => $this->options['multi_type'],
'#fieldset' => 'multiple_field_settings',
- );
+ ];
- $form['separator'] = array(
+ $form['separator'] = [
'#type' => 'textfield',
'#title' => $this->t('Separator'),
'#default_value' => $this->options['separator'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[group_rows]"]' => array('checked' => TRUE),
- ':input[name="options[multi_type]"]' => array('value' => 'separator'),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[group_rows]"]' => ['checked' => TRUE],
+ ':input[name="options[multi_type]"]' => ['value' => 'separator'],
+ ],
+ ],
'#fieldset' => 'multiple_field_settings',
- );
+ ];
- $form['delta_limit'] = array(
+ $form['delta_limit'] = [
'#type' => $type,
'#size' => $size,
'#field_prefix' => $prefix,
@@ -567,54 +567,54 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
'#options' => $options,
'#default_value' => $this->options['delta_limit'],
'#prefix' => '<div class="container-inline">',
- '#states' => array(
- 'visible' => array(
- ':input[name="options[group_rows]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[group_rows]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'multiple_field_settings',
- );
+ ];
list($prefix, $suffix) = explode('@count', $this->t('starting from @count'));
- $form['delta_offset'] = array(
+ $form['delta_offset'] = [
'#type' => 'textfield',
'#size' => 5,
'#field_prefix' => $prefix,
'#field_suffix' => $suffix,
'#default_value' => $this->options['delta_offset'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[group_rows]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[group_rows]"]' => ['checked' => TRUE],
+ ],
+ ],
'#description' => $this->t('(first item is 0)'),
'#fieldset' => 'multiple_field_settings',
- );
- $form['delta_reversed'] = array(
+ ];
+ $form['delta_reversed'] = [
'#title' => $this->t('Reversed'),
'#type' => 'checkbox',
'#default_value' => $this->options['delta_reversed'],
'#suffix' => $suffix,
- '#states' => array(
- 'visible' => array(
- ':input[name="options[group_rows]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[group_rows]"]' => ['checked' => TRUE],
+ ],
+ ],
'#description' => $this->t('(start from last values)'),
'#fieldset' => 'multiple_field_settings',
- );
- $form['delta_first_last'] = array(
+ ];
+ $form['delta_first_last'] = [
'#title' => $this->t('First and last only'),
'#type' => 'checkbox',
'#default_value' => $this->options['delta_first_last'],
'#suffix' => '</div>',
- '#states' => array(
- 'visible' => array(
- ':input[name="options[group_rows]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[group_rows]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'multiple_field_settings',
- );
+ ];
}
/**
@@ -626,31 +626,31 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
// and any additional grouping columns must be specified.
$field_columns = array_keys($this->getFieldDefinition()->getColumns());
- $group_columns = array(
+ $group_columns = [
'entity_id' => $this->t('Entity ID'),
- ) + array_map('ucfirst', array_combine($field_columns, $field_columns));
+ ] + array_map('ucfirst', array_combine($field_columns, $field_columns));
- $form['group_column'] = array(
+ $form['group_column'] = [
'#type' => 'select',
'#title' => $this->t('Group column'),
'#default_value' => $this->options['group_column'],
'#description' => $this->t('Select the column of this field to apply the grouping function selected above.'),
'#options' => $group_columns,
- );
+ ];
- $options = array(
+ $options = [
'bundle' => 'Bundle',
'language' => 'Language',
'entity_type' => 'Entity_type',
- );
+ ];
// Add on defined fields, noting that they're prefixed with the field name.
- $form['group_columns'] = array(
+ $form['group_columns'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Group columns (additional)'),
'#default_value' => $this->options['group_columns'],
'#description' => $this->t('Select any additional columns of this field to include in the query and to group on.'),
'#options' => $options + $group_columns,
- );
+ ];
}
public function submitGroupByForm(&$form, FormStateInterface $form_state) {
@@ -658,8 +658,8 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
$item = &$form_state->get('handler')->options;
// Add settings for "field API" fields.
- $item['group_column'] = $form_state->getValue(array('options', 'group_column'));
- $item['group_columns'] = array_filter($form_state->getValue(array('options', 'group_columns')));
+ $item['group_column'] = $form_state->getValue(['options', 'group_column']);
+ $item['group_columns'] = array_filter($form_state->getValue(['options', 'group_columns']));
}
/**
@@ -680,12 +680,12 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
];
}
else {
- $build = array(
+ $build = [
'#theme' => 'item_list',
'#items' => $items,
'#title' => NULL,
'#list_type' => $this->options['multi_type'],
- );
+ ];
}
return $this->renderer->render($build);
}
@@ -738,7 +738,7 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
// Determine if only the first and last values should be shown.
$delta_first_last = $this->options['delta_first_last'];
- $new_values = array();
+ $new_values = [];
for ($i = 0; $i < $delta_limit; $i++) {
$new_delta = $offset + $i;
@@ -877,7 +877,7 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
// cause some weirdness, but there is only so much we can hope to do.
if (!empty($this->group_fields) && isset($entity->{$this->definition['field_name']})) {
// first, test to see if we have a base value.
- $base_value = array();
+ $base_value = [];
// Note: We would copy original values here, but it can cause problems.
// For example, text fields store cached filtered values as 'safe_value'
// which does not appear anywhere in the field definition so we cannot
@@ -896,10 +896,10 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
if ($data) {
// Now, overwrite the original value with our aggregated value.
// This overwrites it so there is always just one entry.
- $processed_entity->{$this->definition['field_name']} = array($base_value);
+ $processed_entity->{$this->definition['field_name']} = [$base_value];
}
else {
- $processed_entity->{$this->definition['field_name']} = array();
+ $processed_entity->{$this->definition['field_name']} = [];
}
}
@@ -913,7 +913,7 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
protected function documentSelfTokens(&$tokens) {
$field = $this->getFieldDefinition();
foreach ($field->getColumns() as $id => $column) {
- $tokens['{{ ' . $this->options['id'] . '__' . $id . ' }}'] = $this->t('Raw @column', array('@column' => $id));
+ $tokens['{{ ' . $this->options['id'] . '__' . $id . ' }}'] = $this->t('Raw @column', ['@column' => $id]);
}
}
diff --git a/core/modules/views/src/Plugin/views/field/EntityLabel.php b/core/modules/views/src/Plugin/views/field/EntityLabel.php
index 967fd526b78..86ccd05449a 100644
--- a/core/modules/views/src/Plugin/views/field/EntityLabel.php
+++ b/core/modules/views/src/Plugin/views/field/EntityLabel.php
@@ -23,7 +23,7 @@ class EntityLabel extends FieldPluginBase {
*
* @var array
*/
- protected $loadedReferencers = array();
+ protected $loadedReferencers = [];
/**
* EntityManager class.
@@ -75,7 +75,7 @@ class EntityLabel extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['link_to_entity'] = array('default' => FALSE);
+ $options['link_to_entity'] = ['default' => FALSE];
return $options;
}
@@ -83,12 +83,12 @@ class EntityLabel extends FieldPluginBase {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['link_to_entity'] = array(
+ $form['link_to_entity'] = [
'#title' => $this->t('Link to entity'),
'#description' => $this->t('Make entity label a link to entity page.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_entity']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -128,7 +128,7 @@ class EntityLabel extends FieldPluginBase {
public function preRender(&$values) {
parent::preRender($values);
- $entity_ids_per_type = array();
+ $entity_ids_per_type = [];
foreach ($values as $value) {
if ($type = $this->getValue($value, 'type')) {
$entity_ids_per_type[$type][] = $this->getValue($value);
diff --git a/core/modules/views/src/Plugin/views/field/EntityOperations.php b/core/modules/views/src/Plugin/views/field/EntityOperations.php
index f2a3ba997cd..c8a307bd1db 100644
--- a/core/modules/views/src/Plugin/views/field/EntityOperations.php
+++ b/core/modules/views/src/Plugin/views/field/EntityOperations.php
@@ -83,9 +83,9 @@ class EntityOperations extends FieldPluginBase {
public function defineOptions() {
$options = parent::defineOptions();
- $options['destination'] = array(
+ $options['destination'] = [
'default' => TRUE,
- );
+ ];
return $options;
}
@@ -96,12 +96,12 @@ class EntityOperations extends FieldPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['destination'] = array(
+ $form['destination'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include destination'),
'#description' => $this->t('Include a <code>destination</code> parameter in the link to return the user to the original view upon completing the link action.'),
'#default_value' => $this->options['destination'],
- );
+ ];
}
/**
@@ -113,15 +113,15 @@ class EntityOperations extends FieldPluginBase {
if ($this->options['destination']) {
foreach ($operations as &$operation) {
if (!isset($operation['query'])) {
- $operation['query'] = array();
+ $operation['query'] = [];
}
$operation['query'] += $this->getDestinationArray();
}
}
- $build = array(
+ $build = [
'#type' => 'operations',
'#links' => $operations,
- );
+ ];
return $build;
}
diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
index 1432972b6ce..8291fed53fd 100644
--- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -69,7 +69,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
const RENDER_TEXT_PHASE_EMPTY = 2;
public $field_alias = 'unknown';
- public $aliases = array();
+ public $aliases = [];
/**
* The field value prior to any rewriting.
@@ -85,7 +85,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
*
* @var array
*/
- public $additional_fields = array();
+ public $additional_fields = [];
/**
* The link generator.
@@ -114,7 +114,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
- $this->additional_fields = array();
+ $this->additional_fields = [];
if (!empty($this->definition['additional fields'])) {
$this->additional_fields = $this->definition['additional fields'];
}
@@ -140,7 +140,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
public function query() {
$this->ensureMyTable();
// Add the field.
- $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array();
+ $params = $this->options['group_type'] != 'group' ? ['function' => $this->options['group_type']] : [];
$this->field_alias = $this->query->addField($this->tableAlias, $this->realField, NULL, $params);
$this->addAdditionalFields();
@@ -165,11 +165,11 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
$fields = $this->additional_fields;
}
- $group_params = array();
+ $group_params = [];
if ($this->options['group_type'] != 'group') {
- $group_params = array(
+ $group_params = [
'function' => $this->options['group_type'],
- );
+ ];
}
if (!empty($fields) && is_array($fields)) {
@@ -183,12 +183,12 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
}
if (empty($table_alias)) {
- debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', array('@handler' => $this->definition['id'], '@identifier' => $identifier, '@table' => $info['table'])));
+ debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', ['@handler' => $this->definition['id'], '@identifier' => $identifier, '@table' => $info['table']]));
$this->aliases[$identifier] = 'broken';
continue;
}
- $params = array();
+ $params = [];
if (!empty($info['params'])) {
$params = $info['params'];
}
@@ -210,7 +210,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
if (isset($this->field_alias)) {
// Since fields should always have themselves already added, just
// add a sort on the field.
- $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array();
+ $params = $this->options['group_type'] != 'group' ? ['function' => $this->options['group_type']] : [];
$this->query->addOrderBy(NULL, NULL, $order, $this->field_alias, $params);
}
}
@@ -307,10 +307,10 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
static $elements = NULL;
if (!isset($elements)) {
// @todo Add possible html5 elements.
- $elements = array(
+ $elements = [
'' => $this->t('- Use default -'),
'0' => $this->t('- None -')
- );
+ ];
$elements += \Drupal::config('views.settings')->get('field_rewrite_elements');
}
@@ -334,10 +334,10 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
*/
public function tokenizeValue($value, $row_index = NULL) {
if (strpos($value, '{{') !== FALSE) {
- $fake_item = array(
+ $fake_item = [
'alter_text' => TRUE,
'text' => $value,
- );
+ ];
// Use isset() because empty() will trigger on 0 and 0 is
// the first row.
@@ -421,60 +421,60 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
protected function defineOptions() {
$options = parent::defineOptions();
- $options['label'] = array('default' => '');
+ $options['label'] = ['default' => ''];
// Some styles (for example table) should have labels enabled by default.
$style = $this->view->getStyle();
if (isset($style) && $style->defaultFieldLabels()) {
$options['label']['default'] = $this->definition['title'];
}
- $options['exclude'] = array('default' => FALSE);
- $options['alter'] = array(
- 'contains' => array(
- 'alter_text' => array('default' => FALSE),
- 'text' => array('default' => ''),
- 'make_link' => array('default' => FALSE),
- 'path' => array('default' => ''),
- 'absolute' => array('default' => FALSE),
- 'external' => array('default' => FALSE),
- 'replace_spaces' => array('default' => FALSE),
- 'path_case' => array('default' => 'none'),
- 'trim_whitespace' => array('default' => FALSE),
- 'alt' => array('default' => ''),
- 'rel' => array('default' => ''),
- 'link_class' => array('default' => ''),
- 'prefix' => array('default' => ''),
- 'suffix' => array('default' => ''),
- 'target' => array('default' => ''),
- 'nl2br' => array('default' => FALSE),
- 'max_length' => array('default' => 0),
- 'word_boundary' => array('default' => TRUE),
- 'ellipsis' => array('default' => TRUE),
- 'more_link' => array('default' => FALSE),
- 'more_link_text' => array('default' => ''),
- 'more_link_path' => array('default' => ''),
- 'strip_tags' => array('default' => FALSE),
- 'trim' => array('default' => FALSE),
- 'preserve_tags' => array('default' => ''),
- 'html' => array('default' => FALSE),
- ),
- );
- $options['element_type'] = array('default' => '');
- $options['element_class'] = array('default' => '');
-
- $options['element_label_type'] = array('default' => '');
- $options['element_label_class'] = array('default' => '');
- $options['element_label_colon'] = array('default' => TRUE);
-
- $options['element_wrapper_type'] = array('default' => '');
- $options['element_wrapper_class'] = array('default' => '');
-
- $options['element_default_classes'] = array('default' => TRUE);
-
- $options['empty'] = array('default' => '');
- $options['hide_empty'] = array('default' => FALSE);
- $options['empty_zero'] = array('default' => FALSE);
- $options['hide_alter_empty'] = array('default' => TRUE);
+ $options['exclude'] = ['default' => FALSE];
+ $options['alter'] = [
+ 'contains' => [
+ 'alter_text' => ['default' => FALSE],
+ 'text' => ['default' => ''],
+ 'make_link' => ['default' => FALSE],
+ 'path' => ['default' => ''],
+ 'absolute' => ['default' => FALSE],
+ 'external' => ['default' => FALSE],
+ 'replace_spaces' => ['default' => FALSE],
+ 'path_case' => ['default' => 'none'],
+ 'trim_whitespace' => ['default' => FALSE],
+ 'alt' => ['default' => ''],
+ 'rel' => ['default' => ''],
+ 'link_class' => ['default' => ''],
+ 'prefix' => ['default' => ''],
+ 'suffix' => ['default' => ''],
+ 'target' => ['default' => ''],
+ 'nl2br' => ['default' => FALSE],
+ 'max_length' => ['default' => 0],
+ 'word_boundary' => ['default' => TRUE],
+ 'ellipsis' => ['default' => TRUE],
+ 'more_link' => ['default' => FALSE],
+ 'more_link_text' => ['default' => ''],
+ 'more_link_path' => ['default' => ''],
+ 'strip_tags' => ['default' => FALSE],
+ 'trim' => ['default' => FALSE],
+ 'preserve_tags' => ['default' => ''],
+ 'html' => ['default' => FALSE],
+ ],
+ ];
+ $options['element_type'] = ['default' => ''];
+ $options['element_class'] = ['default' => ''];
+
+ $options['element_label_type'] = ['default' => ''];
+ $options['element_label_class'] = ['default' => ''];
+ $options['element_label_colon'] = ['default' => TRUE];
+
+ $options['element_wrapper_type'] = ['default' => ''];
+ $options['element_wrapper_class'] = ['default' => ''];
+
+ $options['element_default_classes'] = ['default' => TRUE];
+
+ $options['empty'] = ['default' => ''];
+ $options['hide_empty'] = ['default' => FALSE];
+ $options['empty_zero'] = ['default' => FALSE];
+ $options['hide_alter_empty'] = ['default' => TRUE];
return $options;
}
@@ -484,8 +484,8 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
*/
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
$options = &$form_state->getValue('options');
- $types = array('element_type', 'element_label_type', 'element_wrapper_type');
- $classes = array_combine(array('element_class', 'element_label_class', 'element_wrapper_class'), $types);
+ $types = ['element_type', 'element_label_type', 'element_wrapper_type'];
+ $classes = array_combine(['element_class', 'element_label_class', 'element_wrapper_class'], $types);
foreach ($types as $type) {
if (!$options[$type . '_enable']) {
@@ -513,349 +513,349 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
parent::buildOptionsForm($form, $form_state);
$label = $this->label();
- $form['custom_label'] = array(
+ $form['custom_label'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create a label'),
'#default_value' => $label !== '',
'#weight' => -103,
- );
- $form['label'] = array(
+ ];
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#default_value' => $label,
- '#states' => array(
- 'visible' => array(
- ':input[name="options[custom_label]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[custom_label]"]' => ['checked' => TRUE],
+ ],
+ ],
'#weight' => -102,
- );
- $form['element_label_colon'] = array(
+ ];
+ $form['element_label_colon'] = [
'#type' => 'checkbox',
'#title' => $this->t('Place a colon after the label'),
'#default_value' => $this->options['element_label_colon'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[custom_label]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[custom_label]"]' => ['checked' => TRUE],
+ ],
+ ],
'#weight' => -101,
- );
+ ];
- $form['exclude'] = array(
+ $form['exclude'] = [
'#type' => 'checkbox',
'#title' => $this->t('Exclude from display'),
'#default_value' => $this->options['exclude'],
'#description' => $this->t('Enable to load this field as hidden. Often used to group fields, or to use as token in another field.'),
'#weight' => -100,
- );
+ ];
- $form['style_settings'] = array(
+ $form['style_settings'] = [
'#type' => 'details',
'#title' => $this->t('Style settings'),
'#weight' => 99,
- );
+ ];
- $form['element_type_enable'] = array(
+ $form['element_type_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Customize field HTML'),
'#default_value' => !empty($this->options['element_type']) || (string) $this->options['element_type'] == '0' || !empty($this->options['element_class']) || (string) $this->options['element_class'] == '0',
'#fieldset' => 'style_settings',
- );
- $form['element_type'] = array(
+ ];
+ $form['element_type'] = [
'#title' => $this->t('HTML element'),
'#options' => $this->getElements(),
'#type' => 'select',
'#default_value' => $this->options['element_type'],
'#description' => $this->t('Choose the HTML element to wrap around this field, e.g. H1, H2, etc.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_type_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_type_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'style_settings',
- );
+ ];
- $form['element_class_enable'] = array(
+ $form['element_class_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create a CSS class'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_type_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_type_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#default_value' => !empty($this->options['element_class']) || (string) $this->options['element_class'] == '0',
'#fieldset' => 'style_settings',
- );
- $form['element_class'] = array(
+ ];
+ $form['element_class'] = [
'#title' => $this->t('CSS class'),
'#description' => $this->t('You may use token substitutions from the rewriting section in this class.'),
'#type' => 'textfield',
'#default_value' => $this->options['element_class'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_type_enable]"]' => array('checked' => TRUE),
- ':input[name="options[element_class_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_type_enable]"]' => ['checked' => TRUE],
+ ':input[name="options[element_class_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'style_settings',
- );
+ ];
- $form['element_label_type_enable'] = array(
+ $form['element_label_type_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Customize label HTML'),
'#default_value' => !empty($this->options['element_label_type']) || (string) $this->options['element_label_type'] == '0' || !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0',
'#fieldset' => 'style_settings',
- );
- $form['element_label_type'] = array(
+ ];
+ $form['element_label_type'] = [
'#title' => $this->t('Label HTML element'),
'#options' => $this->getElements(FALSE),
'#type' => 'select',
'#default_value' => $this->options['element_label_type'],
'#description' => $this->t('Choose the HTML element to wrap around this label, e.g. H1, H2, etc.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_label_type_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_label_type_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'style_settings',
- );
- $form['element_label_class_enable'] = array(
+ ];
+ $form['element_label_class_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create a CSS class'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_label_type_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_label_type_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#default_value' => !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0',
'#fieldset' => 'style_settings',
- );
- $form['element_label_class'] = array(
+ ];
+ $form['element_label_class'] = [
'#title' => $this->t('CSS class'),
'#description' => $this->t('You may use token substitutions from the rewriting section in this class.'),
'#type' => 'textfield',
'#default_value' => $this->options['element_label_class'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_label_type_enable]"]' => array('checked' => TRUE),
- ':input[name="options[element_label_class_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_label_type_enable]"]' => ['checked' => TRUE],
+ ':input[name="options[element_label_class_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'style_settings',
- );
+ ];
- $form['element_wrapper_type_enable'] = array(
+ $form['element_wrapper_type_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Customize field and label wrapper HTML'),
'#default_value' => !empty($this->options['element_wrapper_type']) || (string) $this->options['element_wrapper_type'] == '0' || !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] == '0',
'#fieldset' => 'style_settings',
- );
- $form['element_wrapper_type'] = array(
+ ];
+ $form['element_wrapper_type'] = [
'#title' => $this->t('Wrapper HTML element'),
'#options' => $this->getElements(FALSE),
'#type' => 'select',
'#default_value' => $this->options['element_wrapper_type'],
'#description' => $this->t('Choose the HTML element to wrap around this field and label, e.g. H1, H2, etc. This may not be used if the field and label are not rendered together, such as with a table.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_wrapper_type_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_wrapper_type_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'style_settings',
- );
+ ];
- $form['element_wrapper_class_enable'] = array(
+ $form['element_wrapper_class_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create a CSS class'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_wrapper_type_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_wrapper_type_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#default_value' => !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] == '0',
'#fieldset' => 'style_settings',
- );
- $form['element_wrapper_class'] = array(
+ ];
+ $form['element_wrapper_class'] = [
'#title' => $this->t('CSS class'),
'#description' => $this->t('You may use token substitutions from the rewriting section in this class.'),
'#type' => 'textfield',
'#default_value' => $this->options['element_wrapper_class'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[element_wrapper_class_enable]"]' => array('checked' => TRUE),
- ':input[name="options[element_wrapper_type_enable]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[element_wrapper_class_enable]"]' => ['checked' => TRUE],
+ ':input[name="options[element_wrapper_type_enable]"]' => ['checked' => TRUE],
+ ],
+ ],
'#fieldset' => 'style_settings',
- );
+ ];
- $form['element_default_classes'] = array(
+ $form['element_default_classes'] = [
'#type' => 'checkbox',
'#title' => $this->t('Add default classes'),
'#default_value' => $this->options['element_default_classes'],
'#description' => $this->t('Use default Views classes to identify the field, field label and field content.'),
'#fieldset' => 'style_settings',
- );
+ ];
- $form['alter'] = array(
+ $form['alter'] = [
'#title' => $this->t('Rewrite results'),
'#type' => 'details',
'#weight' => 100,
- );
+ ];
if ($this->allowAdvancedRender()) {
$form['alter']['#tree'] = TRUE;
- $form['alter']['alter_text'] = array(
+ $form['alter']['alter_text'] = [
'#type' => 'checkbox',
'#title' => $this->t('Override the output of this field with custom text'),
'#default_value' => $this->options['alter']['alter_text'],
- );
+ ];
- $form['alter']['text'] = array(
+ $form['alter']['text'] = [
'#title' => $this->t('Text'),
'#type' => 'textarea',
'#default_value' => $this->options['alter']['text'],
- '#description' => $this->t('The text to display for this field. You may include HTML or <a href=":url">Twig</a>. You may enter data from this view as per the "Replacement patterns" below.', array(':url' => CoreUrl::fromUri('http://twig.sensiolabs.org/documentation')->toString())),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][alter_text]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['make_link'] = array(
+ '#description' => $this->t('The text to display for this field. You may include HTML or <a href=":url">Twig</a>. You may enter data from this view as per the "Replacement patterns" below.', [':url' => CoreUrl::fromUri('http://twig.sensiolabs.org/documentation')->toString()]),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][alter_text]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['make_link'] = [
'#type' => 'checkbox',
'#title' => $this->t('Output this field as a custom link'),
'#default_value' => $this->options['alter']['make_link'],
- );
- $form['alter']['path'] = array(
+ ];
+ $form['alter']['path'] = [
'#title' => $this->t('Link path'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['path'],
'#description' => $this->t('The Drupal path or absolute URL for this link. You may enter data from this view as per the "Replacement patterns" below.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
'#maxlength' => 255,
- );
- $form['alter']['absolute'] = array(
+ ];
+ $form['alter']['absolute'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use absolute path'),
'#default_value' => $this->options['alter']['absolute'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['replace_spaces'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['replace_spaces'] = [
'#type' => 'checkbox',
'#title' => $this->t('Replace spaces with dashes'),
'#default_value' => $this->options['alter']['replace_spaces'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['external'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['external'] = [
'#type' => 'checkbox',
'#title' => $this->t('External server URL'),
'#default_value' => $this->options['alter']['external'],
'#description' => $this->t("Links to an external server using a full URL: e.g. 'http://www.example.com' or 'www.example.com'."),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['path_case'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['path_case'] = [
'#type' => 'select',
'#title' => $this->t('Transform the case'),
'#description' => $this->t('When printing URL paths, how to transform the case of the filter value.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- '#options' => array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ '#options' => [
'none' => $this->t('No transform'),
'upper' => $this->t('Upper case'),
'lower' => $this->t('Lower case'),
'ucfirst' => $this->t('Capitalize first letter'),
'ucwords' => $this->t('Capitalize each word'),
- ),
+ ],
'#default_value' => $this->options['alter']['path_case'],
- );
- $form['alter']['link_class'] = array(
+ ];
+ $form['alter']['link_class'] = [
'#title' => $this->t('Link class'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['link_class'],
'#description' => $this->t('The CSS class to apply to the link.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['alt'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['alt'] = [
'#title' => $this->t('Title text'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['alt'],
'#description' => $this->t('Text to place as "title" text which most browsers display as a tooltip when hovering over the link.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['rel'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['rel'] = [
'#title' => $this->t('Rel Text'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['rel'],
'#description' => $this->t('Include Rel attribute for use in lightbox2 or other javascript utility.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['prefix'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['prefix'] = [
'#title' => $this->t('Prefix text'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['prefix'],
'#description' => $this->t('Any text to display before this link. You may include HTML.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['suffix'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['suffix'] = [
'#title' => $this->t('Suffix text'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['suffix'],
'#description' => $this->t('Any text to display after this link. You may include HTML.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['target'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['target'] = [
'#title' => $this->t('Target'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['target'],
'#description' => $this->t("Target of the link, such as _blank, _parent or an iframe's name. This field is rarely used."),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
// Get a list of the available fields and arguments for token replacement.
@@ -871,8 +871,8 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
$options[$optgroup_fields]["{{ {$this->options['id']} }}"] = substr(strrchr($this->adminLabel(), ":"), 2 );
foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
- $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', array('@argument' => $handler->adminLabel()));
- $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', array('@argument' => $handler->adminLabel()));
+ $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
+ $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
}
$this->documentSelfTokens($options[$optgroup_fields]);
@@ -890,14 +890,14 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
];
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
- $items = array();
+ $items = [];
foreach ($options[$type] as $key => $value) {
$items[] = $key . ' == ' . $value;
}
- $item_list = array(
+ $item_list = [
'#theme' => 'item_list',
'#items' => $items,
- );
+ ];
$output[] = $item_list;
}
}
@@ -906,181 +906,181 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// run. It also has an extra div because the dependency wants to hide
// the parent in situations like this, so we need a second div to
// make this work.
- $form['alter']['help'] = array(
+ $form['alter']['help'] = [
'#type' => 'details',
'#title' => $this->t('Replacement patterns'),
'#value' => $output,
- '#states' => array(
- 'visible' => array(
- array(
- ':input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- array(
- ':input[name="options[alter][alter_text]"]' => array('checked' => TRUE),
- ),
- array(
- ':input[name="options[alter][more_link]"]' => array('checked' => TRUE),
- ),
- ),
- ),
- );
-
- $form['alter']['trim'] = array(
+ '#states' => [
+ 'visible' => [
+ [
+ ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
+ ],
+ [
+ ':input[name="options[alter][alter_text]"]' => ['checked' => TRUE],
+ ],
+ [
+ ':input[name="options[alter][more_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ],
+ ];
+
+ $form['alter']['trim'] = [
'#type' => 'checkbox',
'#title' => $this->t('Trim this field to a maximum number of characters'),
'#default_value' => $this->options['alter']['trim'],
- );
+ ];
- $form['alter']['max_length'] = array(
+ $form['alter']['max_length'] = [
'#title' => $this->t('Maximum number of characters'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['max_length'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['word_boundary'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][trim]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['word_boundary'] = [
'#type' => 'checkbox',
'#title' => $this->t('Trim only on a word boundary'),
'#description' => $this->t('If checked, this field be trimmed only on a word boundary. This is guaranteed to be the maximum characters stated or less. If there are no word boundaries this could trim a field to nothing.'),
'#default_value' => $this->options['alter']['word_boundary'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['ellipsis'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][trim]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['ellipsis'] = [
'#type' => 'checkbox',
'#title' => $this->t('Add "…" at the end of trimmed text'),
'#default_value' => $this->options['alter']['ellipsis'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['more_link'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][trim]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['more_link'] = [
'#type' => 'checkbox',
'#title' => $this->t('Add a read-more link if output is trimmed'),
'#default_value' => $this->options['alter']['more_link'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['more_link_text'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][trim]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['more_link_text'] = [
'#type' => 'textfield',
'#title' => $this->t('More link label'),
'#default_value' => $this->options['alter']['more_link_text'],
'#description' => $this->t('You may use the "Replacement patterns" above.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ':input[name="options[alter][more_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
- $form['alter']['more_link_path'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][trim]"]' => ['checked' => TRUE],
+ ':input[name="options[alter][more_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+ $form['alter']['more_link_path'] = [
'#type' => 'textfield',
'#title' => $this->t('More link path'),
'#default_value' => $this->options['alter']['more_link_path'],
'#description' => $this->t('This can be an internal Drupal path such as node/add or an external URL such as "https://www.drupal.org". You may use the "Replacement patterns" above.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ':input[name="options[alter][more_link]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['html'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][trim]"]' => ['checked' => TRUE],
+ ':input[name="options[alter][more_link]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['html'] = [
'#type' => 'checkbox',
'#title' => $this->t('Field can contain HTML'),
'#description' => $this->t('An HTML corrector will be run to ensure HTML tags are properly closed after trimming.'),
'#default_value' => $this->options['alter']['html'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['strip_tags'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][trim]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['strip_tags'] = [
'#type' => 'checkbox',
'#title' => $this->t('Strip HTML tags'),
'#default_value' => $this->options['alter']['strip_tags'],
- );
+ ];
- $form['alter']['preserve_tags'] = array(
+ $form['alter']['preserve_tags'] = [
'#type' => 'textfield',
'#title' => $this->t('Preserve certain tags'),
'#description' => $this->t('List the tags that need to be preserved during the stripping process. example &quot;&lt;p&gt; &lt;br&gt;&quot; which will preserve all p and br elements'),
'#default_value' => $this->options['alter']['preserve_tags'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[alter][strip_tags]"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['alter']['trim_whitespace'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[alter][strip_tags]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['alter']['trim_whitespace'] = [
'#type' => 'checkbox',
'#title' => $this->t('Remove whitespace'),
'#default_value' => $this->options['alter']['trim_whitespace'],
- );
+ ];
- $form['alter']['nl2br'] = array(
+ $form['alter']['nl2br'] = [
'#type' => 'checkbox',
'#title' => $this->t('Convert newlines to HTML &lt;br&gt; tags'),
'#default_value' => $this->options['alter']['nl2br'],
- );
+ ];
}
- $form['empty_field_behavior'] = array(
+ $form['empty_field_behavior'] = [
'#type' => 'details',
'#title' => $this->t('No results behavior'),
'#weight' => 100,
- );
+ ];
- $form['empty'] = array(
+ $form['empty'] = [
'#type' => 'textarea',
'#title' => $this->t('No results text'),
'#default_value' => $this->options['empty'],
'#description' => $this->t('Provide text to display if this field contains an empty result. You may include HTML. You may enter data from this view as per the "Replacement patterns" in the "Rewrite Results" section below.'),
'#fieldset' => 'empty_field_behavior',
- );
+ ];
- $form['empty_zero'] = array(
+ $form['empty_zero'] = [
'#type' => 'checkbox',
'#title' => $this->t('Count the number 0 as empty'),
'#default_value' => $this->options['empty_zero'],
'#description' => $this->t('Enable to display the "no results text" if the field contains the number 0.'),
'#fieldset' => 'empty_field_behavior',
- );
+ ];
- $form['hide_empty'] = array(
+ $form['hide_empty'] = [
'#type' => 'checkbox',
'#title' => $this->t('Hide if empty'),
'#default_value' => $this->options['hide_empty'],
'#description' => $this->t('Enable to hide this field if it is empty. Note that the field label or rewritten output may still be displayed. To hide labels, check the style or row style settings for empty fields. To hide rewritten content, check the "Hide rewriting if empty" checkbox.'),
'#fieldset' => 'empty_field_behavior',
- );
+ ];
- $form['hide_alter_empty'] = array(
+ $form['hide_alter_empty'] = [
'#type' => 'checkbox',
'#title' => $this->t('Hide rewriting if empty'),
'#default_value' => $this->options['hide_alter_empty'],
'#description' => $this->t('Do not display rewritten content if this field is empty.'),
'#fieldset' => 'empty_field_behavior',
- );
+ ];
}
/**
@@ -1152,7 +1152,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
if ($this->allowAdvancedRender()) {
$tokens = NULL;
if ($this instanceof MultiItemsFieldHandlerInterface) {
- $items = array();
+ $items = [];
foreach ($raw_items as $count => $item) {
$value = $this->render_item($count, $item);
if (is_array($value)) {
@@ -1169,7 +1169,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
$value = $this->renderItems($items);
}
else {
- $alter = array('phase' => static::RENDER_TEXT_PHASE_COMPLETELY) + $this->options['alter'];
+ $alter = ['phase' => static::RENDER_TEXT_PHASE_COMPLETELY] + $this->options['alter'];
$value = $this->renderText($alter);
}
@@ -1291,13 +1291,13 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// @todo Views should expect and store a leading /. See
// https://www.drupal.org/node/2423913.
- $options = array(
- 'attributes' => array(
- 'class' => array(
+ $options = [
+ 'attributes' => [
+ 'class' => [
'views-more-link',
- ),
- ),
- );
+ ],
+ ],
+ ];
if (UrlHelper::isExternal($more_link_path)) {
$more_link_url = CoreUrl::fromUri($more_link_path, $options);
}
@@ -1375,7 +1375,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
* the user.
*/
protected function renderAsLink($alter, $text, $tokens) {
- $options = array(
+ $options = [
'absolute' => !empty($alter['absolute']) ? TRUE : FALSE,
'alias' => FALSE,
'entity' => NULL,
@@ -1383,7 +1383,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
'fragment' => NULL,
'language' => NULL,
'query' => [],
- );
+ ];
$alter += [
'path' => NULL
@@ -1488,7 +1488,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
}
if (isset($url['fragment'])) {
- $path = strtr($path, array('#' . $url['fragment'] => ''));
+ $path = strtr($path, ['#' . $url['fragment'] => '']);
// If the path is empty we want to have a fragment for the current site.
if ($path == '') {
$options['external'] = TRUE;
@@ -1504,7 +1504,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
$class = $this->viewsTokenReplace($alter['link_class'], $tokens);
if ($class) {
- $options['attributes']['class'] = array($class);
+ $options['attributes']['class'] = [$class];
}
if (!empty($alter['rel']) && $rel = $this->viewsTokenReplace($alter['rel'], $tokens)) {
@@ -1534,7 +1534,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// \Drupal\Core\Utility\LinkGeneratorInterface::generate().
$options['query'] = UrlHelper::buildQuery($alter['query']);
$options['query'] = $this->viewsTokenReplace($options['query'], $tokens);
- $query = array();
+ $query = [];
parse_str($options['query'], $query);
$options['query'] = $query;
}
@@ -1582,7 +1582,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
* {@inheritdoc}
*/
public function getRenderTokens($item) {
- $tokens = array();
+ $tokens = [];
if (!empty($this->view->build_info['substitutions'])) {
$tokens = $this->view->build_info['substitutions'];
}
@@ -1677,8 +1677,8 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
* @return
* An array of available tokens, with nested keys representative of the array structure.
*/
- protected function getTokenValuesRecursive(array $array, array $parent_keys = array()) {
- $tokens = array();
+ protected function getTokenValuesRecursive(array $array, array $parent_keys = []) {
+ $tokens = [];
foreach ($array as $param => $val) {
if (is_array($val)) {
@@ -1727,12 +1727,12 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
*/
function theme(ResultRow $values) {
$renderer = $this->getRenderer();
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#field' => $this,
'#row' => $values,
- );
+ ];
$output = $renderer->render($build);
// Set the bubbleable rendering metadata on $view->element. This ensures the
@@ -1744,7 +1744,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
}
public function themeFunctions() {
- $themes = array();
+ $themes = [];
$hook = 'views_view_field';
$display = $this->view->display_handler->display;
diff --git a/core/modules/views/src/Plugin/views/field/FileSize.php b/core/modules/views/src/Plugin/views/field/FileSize.php
index af184d3e11d..c8a0b95681b 100644
--- a/core/modules/views/src/Plugin/views/field/FileSize.php
+++ b/core/modules/views/src/Plugin/views/field/FileSize.php
@@ -20,7 +20,7 @@ class FileSize extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['file_size_display'] = array('default' => 'formatted');
+ $options['file_size_display'] = ['default' => 'formatted'];
return $options;
}
@@ -30,14 +30,14 @@ class FileSize extends FieldPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['file_size_display'] = array(
+ $form['file_size_display'] = [
'#title' => $this->t('File size display'),
'#type' => 'select',
- '#options' => array(
+ '#options' => [
'formatted' => $this->t('Formatted (in KB or MB)'),
'bytes' => $this->t('Raw bytes'),
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/field/LanguageField.php b/core/modules/views/src/Plugin/views/field/LanguageField.php
index f51f2fbbaae..53e2c84e161 100644
--- a/core/modules/views/src/Plugin/views/field/LanguageField.php
+++ b/core/modules/views/src/Plugin/views/field/LanguageField.php
@@ -19,7 +19,7 @@ class LanguageField extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['native_language'] = array('default' => FALSE);
+ $options['native_language'] = ['default' => FALSE];
return $options;
}
@@ -29,11 +29,11 @@ class LanguageField extends FieldPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['native_language'] = array(
+ $form['native_language'] = [
'#title' => $this->t('Display in native language'),
'#type' => 'checkbox',
'#default_value' => $this->options['native_language'],
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/field/LinkBase.php b/core/modules/views/src/Plugin/views/field/LinkBase.php
index ebe1e9d0cb1..31dca4c7c3c 100644
--- a/core/modules/views/src/Plugin/views/field/LinkBase.php
+++ b/core/modules/views/src/Plugin/views/field/LinkBase.php
@@ -82,7 +82,7 @@ abstract class LinkBase extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['text'] = array('default' => $this->getDefaultLabel());
+ $options['text'] = ['default' => $this->getDefaultLabel()];
return $options;
}
diff --git a/core/modules/views/src/Plugin/views/field/Links.php b/core/modules/views/src/Plugin/views/field/Links.php
index 6f1695721f7..4e731a9af57 100644
--- a/core/modules/views/src/Plugin/views/field/Links.php
+++ b/core/modules/views/src/Plugin/views/field/Links.php
@@ -26,8 +26,8 @@ abstract class Links extends FieldPluginBase {
public function defineOptions() {
$options = parent::defineOptions();
- $options['fields'] = array('default' => array());
- $options['destination'] = array('default' => TRUE);
+ $options['fields'] = ['default' => []];
+ $options['destination'] = ['default' => TRUE];
return $options;
}
@@ -39,19 +39,19 @@ abstract class Links extends FieldPluginBase {
parent::buildOptionsForm($form, $form_state);
// Only show fields that precede this one.
$field_options = $this->getPreviousFieldLabels();
- $form['fields'] = array(
+ $form['fields'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Fields'),
'#description' => $this->t('Fields to be included as links.'),
'#options' => $field_options,
'#default_value' => $this->options['fields'],
- );
- $form['destination'] = array(
+ ];
+ $form['destination'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include destination'),
'#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the link action.'),
'#default_value' => $this->options['destination'],
- );
+ ];
}
/**
@@ -61,7 +61,7 @@ abstract class Links extends FieldPluginBase {
* The links which are used by the render function.
*/
protected function getLinks() {
- $links = array();
+ $links = [];
foreach ($this->options['fields'] as $field) {
if (empty($this->view->field[$field]->last_render_text)) {
continue;
@@ -76,13 +76,13 @@ abstract class Links extends FieldPluginBase {
$url = $this->view->field[$field]->options['alter']['url'];
}
// Make sure that tokens are replaced for this paths as well.
- $tokens = $this->getRenderTokens(array());
+ $tokens = $this->getRenderTokens([]);
$path = strip_tags(Html::decodeEntities($this->viewsTokenReplace($path, $tokens)));
- $links[$field] = array(
+ $links[$field] = [
'url' => $path ? UrlObject::fromUri('internal:/' . $path) : $url,
'title' => $title,
- );
+ ];
if (!empty($this->options['destination'])) {
$links[$field]['query'] = \Drupal::destination()->getAsArray();
}
diff --git a/core/modules/views/src/Plugin/views/field/MachineName.php b/core/modules/views/src/Plugin/views/field/MachineName.php
index feba80e6331..ea6a0c4be1f 100644
--- a/core/modules/views/src/Plugin/views/field/MachineName.php
+++ b/core/modules/views/src/Plugin/views/field/MachineName.php
@@ -36,7 +36,7 @@ class MachineName extends FieldPluginBase {
}
}
else {
- $this->valueOptions = array();
+ $this->valueOptions = [];
}
}
@@ -45,7 +45,7 @@ class MachineName extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['machine_name'] = array('default' => FALSE);
+ $options['machine_name'] = ['default' => FALSE];
return $options;
}
@@ -56,12 +56,12 @@ class MachineName extends FieldPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['machine_name'] = array(
+ $form['machine_name'] = [
'#title' => $this->t('Output machine name'),
'#description' => $this->t('Display field as machine name.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['machine_name']),
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/field/Markup.php b/core/modules/views/src/Plugin/views/field/Markup.php
index 7ca789f6464..883bd56fb08 100644
--- a/core/modules/views/src/Plugin/views/field/Markup.php
+++ b/core/modules/views/src/Plugin/views/field/Markup.php
@@ -29,7 +29,7 @@ class Markup extends FieldPluginBase {
$this->format = $this->definition['format'];
- $this->additional_fields = array();
+ $this->additional_fields = [];
if (is_array($this->format)) {
$this->additional_fields['format'] = $this->format;
}
diff --git a/core/modules/views/src/Plugin/views/field/NumericField.php b/core/modules/views/src/Plugin/views/field/NumericField.php
index 0cf4c889b66..8b6a209125d 100644
--- a/core/modules/views/src/Plugin/views/field/NumericField.php
+++ b/core/modules/views/src/Plugin/views/field/NumericField.php
@@ -25,14 +25,14 @@ class NumericField extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['set_precision'] = array('default' => FALSE);
- $options['precision'] = array('default' => 0);
- $options['decimal'] = array('default' => '.');
- $options['separator'] = array('default' => ',');
- $options['format_plural'] = array('default' => FALSE);
- $options['format_plural_string'] = array('default' => '1' . LOCALE_PLURAL_DELIMITER . '@count');
- $options['prefix'] = array('default' => '');
- $options['suffix'] = array('default' => '');
+ $options['set_precision'] = ['default' => FALSE];
+ $options['precision'] = ['default' => 0];
+ $options['decimal'] = ['default' => '.'];
+ $options['separator'] = ['default' => ','];
+ $options['format_plural'] = ['default' => FALSE];
+ $options['format_plural_string'] = ['default' => '1' . LOCALE_PLURAL_DELIMITER . '@count'];
+ $options['prefix'] = ['default' => ''];
+ $options['suffix'] = ['default' => ''];
return $options;
}
@@ -42,72 +42,72 @@ class NumericField extends FieldPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
if (!empty($this->definition['float'])) {
- $form['set_precision'] = array(
+ $form['set_precision'] = [
'#type' => 'checkbox',
'#title' => $this->t('Round'),
'#description' => $this->t('If checked, the number will be rounded.'),
'#default_value' => $this->options['set_precision'],
- );
- $form['precision'] = array(
+ ];
+ $form['precision'] = [
'#type' => 'textfield',
'#title' => $this->t('Precision'),
'#default_value' => $this->options['precision'],
'#description' => $this->t('Specify how many digits to print after the decimal point.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[set_precision]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[set_precision]"]' => ['checked' => TRUE],
+ ],
+ ],
'#size' => 2,
- );
- $form['decimal'] = array(
+ ];
+ $form['decimal'] = [
'#type' => 'textfield',
'#title' => $this->t('Decimal point'),
'#default_value' => $this->options['decimal'],
'#description' => $this->t('What single character to use as a decimal point.'),
'#size' => 2,
- );
+ ];
}
- $form['separator'] = array(
+ $form['separator'] = [
'#type' => 'select',
'#title' => $this->t('Thousands marker'),
- '#options' => array(
+ '#options' => [
'' => $this->t('- None -'),
',' => $this->t('Comma'),
' ' => $this->t('Space'),
'.' => $this->t('Decimal'),
'\'' => $this->t('Apostrophe'),
- ),
+ ],
'#default_value' => $this->options['separator'],
'#description' => $this->t('What single character to use as the thousands separator.'),
'#size' => 2,
- );
- $form['format_plural'] = array(
+ ];
+ $form['format_plural'] = [
'#type' => 'checkbox',
'#title' => $this->t('Format plural'),
'#description' => $this->t('If checked, special handling will be used for plurality.'),
'#default_value' => $this->options['format_plural'],
- );
- $form['format_plural_string'] = array(
+ ];
+ $form['format_plural_string'] = [
'#type' => 'value',
'#default_value' => $this->options['format_plural_string'],
- );
+ ];
$plural_array = explode(LOCALE_PLURAL_DELIMITER, $this->options['format_plural_string']);
$plurals = $this->getNumberOfPlurals($this->view->storage->get('langcode'));
for ($i = 0; $i < $plurals; $i++) {
- $form['format_plural_values'][$i] = array(
+ $form['format_plural_values'][$i] = [
'#type' => 'textfield',
// @todo Should use better labels https://www.drupal.org/node/2499639
'#title' => ($i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form')),
'#default_value' => isset($plural_array[$i]) ? $plural_array[$i] : '',
'#description' => $this->t('Text to use for this variant, @count will be replaced with the value.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[format_plural]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[format_plural]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
}
if ($plurals == 2) {
// Simplify interface text for the most common case.
@@ -116,18 +116,18 @@ class NumericField extends FieldPluginBase {
$form['format_plural_values'][1]['#description'] = $this->t('Text to use for the plural form, @count will be replaced with the value.');
}
- $form['prefix'] = array(
+ $form['prefix'] = [
'#type' => 'textfield',
'#title' => $this->t('Prefix'),
'#default_value' => $this->options['prefix'],
'#description' => $this->t('Text to put before the number, such as currency symbol.'),
- );
- $form['suffix'] = array(
+ ];
+ $form['suffix'] = [
'#type' => 'textfield',
'#title' => $this->t('Suffix'),
'#default_value' => $this->options['suffix'],
'#description' => $this->t('Text to put after the number, such as currency symbol.'),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/core/modules/views/src/Plugin/views/field/PrerenderList.php b/core/modules/views/src/Plugin/views/field/PrerenderList.php
index aa8f75207e4..f851cbb6a00 100644
--- a/core/modules/views/src/Plugin/views/field/PrerenderList.php
+++ b/core/modules/views/src/Plugin/views/field/PrerenderList.php
@@ -25,7 +25,7 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH
*
* @var array
*/
- public $items = array();
+ public $items = [];
/**
* {@inheritdoc}
@@ -33,8 +33,8 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH
protected function defineOptions() {
$options = parent::defineOptions();
- $options['type'] = array('default' => 'separator');
- $options['separator'] = array('default' => ', ');
+ $options['type'] = ['default' => 'separator'];
+ $options['separator'] = ['default' => ', '];
return $options;
}
@@ -43,27 +43,27 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'radios',
'#title' => $this->t('Display type'),
- '#options' => array(
+ '#options' => [
'ul' => $this->t('Unordered list'),
'ol' => $this->t('Ordered list'),
'separator' => $this->t('Simple separator'),
- ),
+ ],
'#default_value' => $this->options['type'],
- );
+ ];
- $form['separator'] = array(
+ $form['separator'] = [
'#type' => 'textfield',
'#title' => $this->t('Separator'),
'#default_value' => $this->options['separator'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[type]"]' => array('value' => 'separator'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[type]"]' => ['value' => 'separator'],
+ ],
+ ],
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -83,12 +83,12 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH
];
}
else {
- $render = array(
+ $render = [
'#theme' => 'item_list',
'#items' => $items,
'#title' => NULL,
'#list_type' => $this->options['type'],
- );
+ ];
}
return drupal_render($render);
}
@@ -110,7 +110,7 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH
return $this->items[$field];
}
- return array();
+ return [];
}
}
diff --git a/core/modules/views/src/Plugin/views/field/Serialized.php b/core/modules/views/src/Plugin/views/field/Serialized.php
index 3df1cca7b94..4d74a4f1ae8 100644
--- a/core/modules/views/src/Plugin/views/field/Serialized.php
+++ b/core/modules/views/src/Plugin/views/field/Serialized.php
@@ -19,8 +19,8 @@ class Serialized extends FieldPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['format'] = array('default' => 'unserialized');
- $options['key'] = array('default' => '');
+ $options['format'] = ['default' => 'unserialized'];
+ $options['key'] = ['default' => ''];
return $options;
}
@@ -30,27 +30,27 @@ class Serialized extends FieldPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['format'] = array(
+ $form['format'] = [
'#type' => 'select',
'#title' => $this->t('Display format'),
'#description' => $this->t('How should the serialized data be displayed. You can choose a custom array/object key or a print_r on the full output.'),
- '#options' => array(
+ '#options' => [
'unserialized' => $this->t('Full data (unserialized)'),
'serialized' => $this->t('Full data (serialized)'),
'key' => $this->t('A certain key'),
- ),
+ ],
'#default_value' => $this->options['format'],
- );
- $form['key'] = array(
+ ];
+ $form['key'] = [
'#type' => 'textfield',
'#title' => $this->t('Which key should be displayed'),
'#default_value' => $this->options['key'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[format]"]' => array('value' => 'key'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[format]"]' => ['value' => 'key'],
+ ],
+ ],
+ ];
}
/**
@@ -58,7 +58,7 @@ class Serialized extends FieldPluginBase {
*/
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
// Require a key if the format is key.
- if ($form_state->getValue(array('options', 'format')) == 'key' && $form_state->getValue(array('options', 'key')) == '') {
+ if ($form_state->getValue(['options', 'format']) == 'key' && $form_state->getValue(['options', 'key']) == '') {
$form_state->setError($form['key'], $this->t('You have to enter a key if you want to display a key of the data.'));
}
}
diff --git a/core/modules/views/src/Plugin/views/field/TimeInterval.php b/core/modules/views/src/Plugin/views/field/TimeInterval.php
index d7ec0d31927..79cd190605a 100644
--- a/core/modules/views/src/Plugin/views/field/TimeInterval.php
+++ b/core/modules/views/src/Plugin/views/field/TimeInterval.php
@@ -58,7 +58,7 @@ class TimeInterval extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['granularity'] = array('default' => 2);
+ $options['granularity'] = ['default' => 2];
return $options;
}
@@ -69,12 +69,12 @@ class TimeInterval extends FieldPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['granularity'] = array(
+ $form['granularity'] = [
'#type' => 'textfield',
'#title' => $this->t('Granularity'),
'#description' => $this->t('How many different units to display in the string.'),
'#default_value' => $this->options['granularity'],
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/field/Url.php b/core/modules/views/src/Plugin/views/field/Url.php
index e847e4479b7..08e1fbad26c 100644
--- a/core/modules/views/src/Plugin/views/field/Url.php
+++ b/core/modules/views/src/Plugin/views/field/Url.php
@@ -21,7 +21,7 @@ class Url extends FieldPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['display_as_link'] = array('default' => TRUE);
+ $options['display_as_link'] = ['default' => TRUE];
return $options;
}
@@ -30,11 +30,11 @@ class Url extends FieldPluginBase {
* Provide link to the page being visited.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['display_as_link'] = array(
+ $form['display_as_link'] = [
'#title' => $this->t('Display as link'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['display_as_link']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
index 7078032e89d..69b6ebac7eb 100644
--- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
@@ -54,7 +54,7 @@ class BooleanOperator extends FilterPluginBase {
* {@inheritdoc}
*/
public function operatorOptions($which = 'title') {
- $options = array();
+ $options = [];
foreach ($this->operators() as $id => $info) {
$options[$id] = $info[$which];
}
@@ -68,22 +68,22 @@ class BooleanOperator extends FilterPluginBase {
* @return array
*/
protected function operators() {
- return array(
- '=' => array(
+ return [
+ '=' => [
'title' => $this->t('Is equal to'),
'method' => 'queryOpBoolean',
'short' => $this->t('='),
'values' => 1,
'query_operator' => static::EQUAL,
- ),
- '!=' => array(
+ ],
+ '!=' => [
'title' => $this->t('Is not equal to'),
'method' => 'queryOpBoolean',
'short' => $this->t('!='),
'values' => 1,
'query_operator' => static::NOT_EQUAL,
- ),
- );
+ ],
+ ];
}
/**
@@ -125,19 +125,19 @@ class BooleanOperator extends FilterPluginBase {
public function getValueOptions() {
if (isset($this->definition['type'])) {
if ($this->definition['type'] == 'yes-no') {
- $this->valueOptions = array(1 => $this->t('Yes'), 0 => $this->t('No'));
+ $this->valueOptions = [1 => $this->t('Yes'), 0 => $this->t('No')];
}
if ($this->definition['type'] == 'on-off') {
- $this->valueOptions = array(1 => $this->t('On'), 0 => $this->t('Off'));
+ $this->valueOptions = [1 => $this->t('On'), 0 => $this->t('Off')];
}
if ($this->definition['type'] == 'enabled-disabled') {
- $this->valueOptions = array(1 => $this->t('Enabled'), 0 => $this->t('Disabled'));
+ $this->valueOptions = [1 => $this->t('Enabled'), 0 => $this->t('Disabled')];
}
}
// Provide a fallback if the above didn't set anything.
if (!isset($this->valueOptions)) {
- $this->valueOptions = array(1 => $this->t('True'), 0 => $this->t('False'));
+ $this->valueOptions = [1 => $this->t('True'), 0 => $this->t('False')];
}
}
@@ -162,12 +162,12 @@ class BooleanOperator extends FilterPluginBase {
// Configuring a filter: use radios for clarity.
$filter_form_type = 'radios';
}
- $form['value'] = array(
+ $form['value'] = [
'#type' => $filter_form_type,
'#title' => $this->value_value,
'#options' => $this->valueOptions,
'#default_value' => $this->value,
- );
+ ];
if (!empty($this->options['exposed'])) {
$identifier = $this->options['expose']['identifier'];
$user_input = $form_state->getUserInput();
@@ -177,13 +177,13 @@ class BooleanOperator extends FilterPluginBase {
}
// If we're configuring an exposed filter, add an - Any - option.
if (!$exposed || empty($this->options['expose']['required'])) {
- $form['value']['#options'] = array('All' => $this->t('- Any -')) + $form['value']['#options'];
+ $form['value']['#options'] = ['All' => $this->t('- Any -')] + $form['value']['#options'];
}
}
}
protected function valueValidate($form, FormStateInterface $form_state) {
- if ($form_state->getValue(array('options', 'value')) == 'All' && !$form_state->isValueEmpty(array('options', 'expose', 'required'))) {
+ if ($form_state->getValue(['options', 'value']) == 'All' && !$form_state->isValueEmpty(['options', 'expose', 'required'])) {
$form_state->setErrorByName('value', $this->t('You must select a value unless this is an non-required exposed filter.'));
}
}
@@ -221,7 +221,7 @@ class BooleanOperator extends FilterPluginBase {
$info = $this->operators();
if (!empty($info[$this->operator]['method'])) {
- call_user_func(array($this, $info[$this->operator]['method']), $field, $info[$this->operator]['query_operator']);
+ call_user_func([$this, $info[$this->operator]['method']], $field, $info[$this->operator]['query_operator']);
}
}
diff --git a/core/modules/views/src/Plugin/views/filter/Bundle.php b/core/modules/views/src/Plugin/views/filter/Bundle.php
index 1ae5eb38814..46142fe851f 100644
--- a/core/modules/views/src/Plugin/views/filter/Bundle.php
+++ b/core/modules/views/src/Plugin/views/filter/Bundle.php
@@ -94,9 +94,9 @@ class Bundle extends InOperator {
public function getValueOptions() {
if (!isset($this->valueOptions)) {
$types = $this->bundleInfoService->getBundleInfo($this->entityTypeId);
- $this->valueTitle = $this->t('@entity types', array('@entity' => $this->entityType->getLabel()));
+ $this->valueTitle = $this->t('@entity types', ['@entity' => $this->entityType->getLabel()]);
- $options = array();
+ $options = [];
foreach ($types as $type => $info) {
$options[$type] = $info['label'];
}
diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php
index 1b4ab9c1c24..0396ff47ec4 100644
--- a/core/modules/views/src/Plugin/views/filter/Combine.php
+++ b/core/modules/views/src/Plugin/views/filter/Combine.php
@@ -21,7 +21,7 @@ class Combine extends StringFilter {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['fields'] = array('default' => array());
+ $options['fields'] = ['default' => []];
return $options;
}
@@ -32,7 +32,7 @@ class Combine extends StringFilter {
// Allow to choose all fields as possible
if ($this->view->style_plugin->usesFields()) {
- $options = array();
+ $options = [];
foreach ($this->view->display_handler->getHandlers('field') as $name => $field) {
// Only allow clickSortable fields. Fields without clickSorting will
// probably break in the Combine filter.
@@ -41,14 +41,14 @@ class Combine extends StringFilter {
}
}
if ($options) {
- $form['fields'] = array(
+ $form['fields'] = [
'#type' => 'select',
'#title' => $this->t('Choose fields to combine for filtering'),
'#description' => $this->t("This filter doesn't work for very special field handlers."),
'#multiple' => TRUE,
'#options' => $options,
'#default_value' => $this->options['fields'],
- );
+ ];
}
else {
$form_state->setErrorByName('', $this->t('You have to add some fields to be able to use this filter.'));
@@ -58,7 +58,7 @@ class Combine extends StringFilter {
public function query() {
$this->view->_build('field');
- $fields = array();
+ $fields = [];
// Only add the fields if they have a proper field and table alias.
foreach ($this->options['fields'] as $id) {
// Overridden fields can lead to fields missing from a display that are
@@ -78,7 +78,7 @@ class Combine extends StringFilter {
}
if ($fields) {
$count = count($fields);
- $separated_fields = array();
+ $separated_fields = [];
foreach ($fields as $key => $field) {
$separated_fields[] = $field;
if ($key < $count - 1) {
@@ -106,7 +106,7 @@ class Combine extends StringFilter {
if (!isset($fields[$id])) {
// Combined field filter only works with fields that are in the field
// settings.
- $errors[] = $this->t('Field %field set in %filter is not set in display %display.', array('%field' => $id, '%filter' => $this->adminLabel(), '%display' => $this->displayHandler->display['display_title']));
+ $errors[] = $this->t('Field %field set in %filter is not set in display %display.', ['%field' => $id, '%filter' => $this->adminLabel(), '%display' => $this->displayHandler->display['display_title']]);
break;
}
elseif (!$fields[$id]->clickSortable()) {
@@ -114,12 +114,12 @@ class Combine extends StringFilter {
// is not click sortable we can assume it is not a simple field.
// @todo change this check to isComputed. See
// https://www.drupal.org/node/2349465
- $errors[] = $this->t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', array('%field' => $fields[$id]->adminLabel(), '%filter' => $this->adminLabel()));
+ $errors[] = $this->t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', ['%field' => $fields[$id]->adminLabel(), '%filter' => $this->adminLabel()]);
}
}
}
else {
- $errors[] = $this->t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', array('%display' => $this->displayHandler->display['display_title'], '%filter' => $this->adminLabel()));
+ $errors[] = $this->t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', ['%display' => $this->displayHandler->display['display_title'], '%filter' => $this->adminLabel()]);
}
return $errors;
}
@@ -131,12 +131,12 @@ class Combine extends StringFilter {
function opEqual($expression) {
$placeholder = $this->placeholder();
$operator = $this->operator();
- $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", array($placeholder => $this->value));
+ $this->query->addWhereExpression($this->options['group'], "$expression $operator $placeholder", [$placeholder => $this->value]);
}
protected function opContains($expression) {
$placeholder = $this->placeholder();
- $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
+ $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", [$placeholder => '%' . db_like($this->value) . '%']);
}
/**
@@ -169,38 +169,38 @@ class Combine extends StringFilter {
$temp_placeholder = $placeholder . '_' . $match_key;
// Clean up the user input and remove the sentence delimiters.
$word = trim($match[2], ',?!();:-"');
- $this->query->addWhereExpression($group, "$expression $operator $temp_placeholder", array($temp_placeholder => '%' . Database::getConnection()->escapeLike($word) . '%'));
+ $this->query->addWhereExpression($group, "$expression $operator $temp_placeholder", [$temp_placeholder => '%' . Database::getConnection()->escapeLike($word) . '%']);
}
}
protected function opStartsWith($expression) {
$placeholder = $this->placeholder();
- $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
+ $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", [$placeholder => db_like($this->value) . '%']);
}
protected function opNotStartsWith($expression) {
$placeholder = $this->placeholder();
- $this->query->addWhereExpression($this->options['group'], "$expression NOT LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
+ $this->query->addWhereExpression($this->options['group'], "$expression NOT LIKE $placeholder", [$placeholder => db_like($this->value) . '%']);
}
protected function opEndsWith($expression) {
$placeholder = $this->placeholder();
- $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
+ $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", [$placeholder => '%' . db_like($this->value)]);
}
protected function opNotEndsWith($expression) {
$placeholder = $this->placeholder();
- $this->query->addWhereExpression($this->options['group'], "$expression NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
+ $this->query->addWhereExpression($this->options['group'], "$expression NOT LIKE $placeholder", [$placeholder => '%' . db_like($this->value)]);
}
protected function opNotLike($expression) {
$placeholder = $this->placeholder();
- $this->query->addWhereExpression($this->options['group'], "$expression NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
+ $this->query->addWhereExpression($this->options['group'], "$expression NOT LIKE $placeholder", [$placeholder => '%' . db_like($this->value) . '%']);
}
protected function opRegex($expression) {
$placeholder = $this->placeholder();
- $this->query->addWhereExpression($this->options['group'], "$expression REGEXP $placeholder", array($placeholder => $this->value));
+ $this->query->addWhereExpression($this->options['group'], "$expression REGEXP $placeholder", [$placeholder => $this->value]);
}
protected function opEmpty($expression) {
diff --git a/core/modules/views/src/Plugin/views/filter/Date.php b/core/modules/views/src/Plugin/views/filter/Date.php
index 84a1c421c61..b69be2bcfc9 100644
--- a/core/modules/views/src/Plugin/views/filter/Date.php
+++ b/core/modules/views/src/Plugin/views/filter/Date.php
@@ -27,15 +27,15 @@ class Date extends NumericFilter {
*/
protected function valueForm(&$form, FormStateInterface $form_state) {
if (!$form_state->get('exposed')) {
- $form['value']['type'] = array(
+ $form['value']['type'] = [
'#type' => 'radios',
'#title' => $this->t('Value type'),
- '#options' => array(
+ '#options' => [
'date' => $this->t('A date in any machine readable format. CCYY-MM-DD HH:MM:SS is preferred.'),
- 'offset' => $this->t('An offset from the current time such as "@example1" or "@example2"', array('@example1' => '+1 day', '@example2' => '-2 hours -30 minutes')),
- ),
+ 'offset' => $this->t('An offset from the current time such as "@example1" or "@example2"', ['@example1' => '+1 day', '@example2' => '-2 hours -30 minutes']),
+ ],
'#default_value' => !empty($this->value['type']) ? $this->value['type'] : 'date',
- );
+ ];
}
parent::valueForm($form, $form_state);
}
@@ -43,12 +43,12 @@ class Date extends NumericFilter {
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
parent::validateOptionsForm($form, $form_state);
- if (!empty($this->options['exposed']) && $form_state->isValueEmpty(array('options', 'expose', 'required'))) {
+ if (!empty($this->options['exposed']) && $form_state->isValueEmpty(['options', 'expose', 'required'])) {
// Who cares what the value is if it's exposed and non-required.
return;
}
- $this->validateValidTime($form['value'], $form_state, $form_state->getValue(array('options', 'operator')), $form_state->getValue(array('options', 'value')));
+ $this->validateValidTime($form['value'], $form_state, $form_state->getValue(['options', 'operator']), $form_state->getValue(['options', 'value']));
}
public function validateExposed(&$form, FormStateInterface $form_state) {
diff --git a/core/modules/views/src/Plugin/views/filter/Equality.php b/core/modules/views/src/Plugin/views/filter/Equality.php
index 748c60d698c..e1d2aeb1e80 100644
--- a/core/modules/views/src/Plugin/views/filter/Equality.php
+++ b/core/modules/views/src/Plugin/views/filter/Equality.php
@@ -20,22 +20,22 @@ class Equality extends FilterPluginBase {
* Provide simple equality operator
*/
public function operatorOptions() {
- return array(
+ return [
'=' => $this->t('Is equal to'),
'!=' => $this->t('Is not equal to'),
- );
+ ];
}
/**
* Provide a simple textfield for equality
*/
protected function valueForm(&$form, FormStateInterface $form_state) {
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'textfield',
'#title' => $this->t('Value'),
'#size' => 30,
'#default_value' => $this->value,
- );
+ ];
if ($exposed = $form_state->get('exposed')) {
$identifier = $this->options['expose']['identifier'];
diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
index 5c2a8d8c0fb..bce17f36720 100644
--- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
+++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
@@ -116,26 +116,26 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
protected function defineOptions() {
$options = parent::defineOptions();
- $options['operator'] = array('default' => '=');
- $options['value'] = array('default' => '');
- $options['group'] = array('default' => '1');
- $options['exposed'] = array('default' => FALSE);
- $options['expose'] = array(
- 'contains' => array(
- 'operator_id' => array('default' => FALSE),
- 'label' => array('default' => ''),
- 'description' => array('default' => ''),
- 'use_operator' => array('default' => FALSE),
- 'operator' => array('default' => ''),
- 'identifier' => array('default' => ''),
- 'required' => array('default' => FALSE),
- 'remember' => array('default' => FALSE),
- 'multiple' => array('default' => FALSE),
- 'remember_roles' => array('default' => array(
+ $options['operator'] = ['default' => '='];
+ $options['value'] = ['default' => ''];
+ $options['group'] = ['default' => '1'];
+ $options['exposed'] = ['default' => FALSE];
+ $options['expose'] = [
+ 'contains' => [
+ 'operator_id' => ['default' => FALSE],
+ 'label' => ['default' => ''],
+ 'description' => ['default' => ''],
+ 'use_operator' => ['default' => FALSE],
+ 'operator' => ['default' => ''],
+ 'identifier' => ['default' => ''],
+ 'required' => ['default' => FALSE],
+ 'remember' => ['default' => FALSE],
+ 'multiple' => ['default' => FALSE],
+ 'remember_roles' => ['default' => [
RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID,
- )),
- ),
- );
+ ]],
+ ],
+ ];
// A group is a combination of a filter, an operator and a value
// operating like a single filter.
@@ -145,21 +145,21 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
// an identifier and other settings like the widget and the label.
// This settings are saved in another array to allow users to switch
// between a normal filter and a group of filters with a single click.
- $options['is_grouped'] = array('default' => FALSE);
- $options['group_info'] = array(
- 'contains' => array(
- 'label' => array('default' => ''),
- 'description' => array('default' => ''),
- 'identifier' => array('default' => ''),
- 'optional' => array('default' => TRUE),
- 'widget' => array('default' => 'select'),
- 'multiple' => array('default' => FALSE),
- 'remember' => array('default' => 0),
- 'default_group' => array('default' => 'All'),
- 'default_group_multiple' => array('default' => array()),
- 'group_items' => array('default' => array()),
- ),
- );
+ $options['is_grouped'] = ['default' => FALSE];
+ $options['group_info'] = [
+ 'contains' => [
+ 'label' => ['default' => ''],
+ 'description' => ['default' => ''],
+ 'identifier' => ['default' => ''],
+ 'optional' => ['default' => TRUE],
+ 'widget' => ['default' => 'select'],
+ 'multiple' => ['default' => FALSE],
+ 'remember' => ['default' => 0],
+ 'default_group' => ['default' => 'All'],
+ 'default_group_multiple' => ['default' => []],
+ 'group_items' => ['default' => []],
+ ],
+ ];
return $options;
}
@@ -205,19 +205,19 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
if ($this->canBuildGroup()) {
$this->showBuildGroupButton($form, $form_state);
}
- $form['clear_markup_start'] = array(
+ $form['clear_markup_start'] = [
'#markup' => '<div class="clearfix">',
- );
+ ];
if ($this->isAGroup()) {
if ($this->canBuildGroup()) {
- $form['clear_markup_start'] = array(
+ $form['clear_markup_start'] = [
'#markup' => '<div class="clearfix">',
- );
+ ];
// Render the build group form.
$this->showBuildGroupForm($form, $form_state);
- $form['clear_markup_end'] = array(
+ $form['clear_markup_end'] = [
'#markup' => '</div>',
- );
+ ];
}
}
else {
@@ -225,9 +225,9 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
$this->showOperatorForm($form, $form_state);
// Add the subform from valueForm().
$this->showValueForm($form, $form_state);
- $form['clear_markup_end'] = array(
+ $form['clear_markup_end'] = [
'#markup' => '</div>',
- );
+ ];
if ($this->canExpose()) {
// Add the subform from buildExposeForm().
$this->showExposeForm($form, $form_state);
@@ -289,12 +289,12 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
protected function operatorForm(&$form, FormStateInterface $form_state) {
$options = $this->operatorOptions();
if (!empty($options)) {
- $form['operator'] = array(
+ $form['operator'] = [
'#type' => count($options) < 10 ? 'radios' : 'select',
'#title' => $this->t('Operator'),
'#default_value' => $this->operator,
'#options' => $options,
- );
+ ];
}
}
@@ -302,7 +302,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
* Provide a list of options for the default operator form.
* Should be overridden by classes that don't override operatorForm
*/
- public function operatorOptions() { return array(); }
+ public function operatorOptions() { return []; }
/**
* Validate the operator form.
@@ -335,7 +335,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
* @see buildOptionsForm()
*/
protected function valueForm(&$form, FormStateInterface $form_state) {
- $form['value'] = array();
+ $form['value'] = [];
}
/**
@@ -377,47 +377,47 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
*/
protected function showBuildGroupButton(&$form, FormStateInterface $form_state) {
- $form['group_button'] = array(
+ $form['group_button'] = [
'#prefix' => '<div class="views-grouped clearfix">',
'#suffix' => '</div>',
// Should always come after the description and the relationship.
'#weight' => -190,
- );
+ ];
$grouped_description = $this->t('Grouped filters allow a choice between predefined operator|value pairs.');
- $form['group_button']['radios'] = array(
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('js-only')),
- );
- $form['group_button']['radios']['radios'] = array(
+ $form['group_button']['radios'] = [
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['js-only']],
+ ];
+ $form['group_button']['radios']['radios'] = [
'#title' => $this->t('Filter type to expose'),
'#description' => $grouped_description,
'#type' => 'radios',
- '#options' => array(
+ '#options' => [
$this->t('Single filter'),
$this->t('Grouped filters'),
- ),
- );
+ ],
+ ];
if (empty($this->options['is_grouped'])) {
- $form['group_button']['markup'] = array(
+ $form['group_button']['markup'] = [
'#markup' => '<div class="description grouped-description">' . $grouped_description . '</div>',
- );
- $form['group_button']['button'] = array(
- '#limit_validation_errors' => array(),
+ ];
+ $form['group_button']['button'] = [
+ '#limit_validation_errors' => [],
'#type' => 'submit',
'#value' => $this->t('Grouped filters'),
- '#submit' => array(array($this, 'buildGroupForm')),
- );
+ '#submit' => [[$this, 'buildGroupForm']],
+ ];
$form['group_button']['radios']['radios']['#default_value'] = 0;
}
else {
- $form['group_button']['button'] = array(
- '#limit_validation_errors' => array(),
+ $form['group_button']['button'] = [
+ '#limit_validation_errors' => [],
'#type' => 'submit',
'#value' => $this->t('Single filter'),
- '#submit' => array(array($this, 'buildGroupForm')),
- );
+ '#submit' => [[$this, 'buildGroupForm']],
+ ];
$form['group_button']['radios']['radios']['#default_value'] = 1;
}
}
@@ -453,47 +453,47 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
* Shortcut to display the expose/hide button.
*/
public function showExposeButton(&$form, FormStateInterface $form_state) {
- $form['expose_button'] = array(
+ $form['expose_button'] = [
'#prefix' => '<div class="views-expose clearfix">',
'#suffix' => '</div>',
// Should always come after the description and the relationship.
'#weight' => -200,
- );
+ ];
// Add a checkbox for JS users, which will have behavior attached to it
// so it can replace the button.
- $form['expose_button']['checkbox'] = array(
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('js-only')),
- );
- $form['expose_button']['checkbox']['checkbox'] = array(
+ $form['expose_button']['checkbox'] = [
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['js-only']],
+ ];
+ $form['expose_button']['checkbox']['checkbox'] = [
'#title' => $this->t('Expose this filter to visitors, to allow them to change it'),
'#type' => 'checkbox',
- );
+ ];
// Then add the button itself.
if (empty($this->options['exposed'])) {
- $form['expose_button']['markup'] = array(
+ $form['expose_button']['markup'] = [
'#markup' => '<div class="description exposed-description">' . $this->t('This filter is not exposed. Expose it to allow the users to change it.') . '</div>',
- );
- $form['expose_button']['button'] = array(
- '#limit_validation_errors' => array(),
+ ];
+ $form['expose_button']['button'] = [
+ '#limit_validation_errors' => [],
'#type' => 'submit',
'#value' => $this->t('Expose filter'),
- '#submit' => array(array($this, 'displayExposedForm')),
- );
+ '#submit' => [[$this, 'displayExposedForm']],
+ ];
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
}
else {
- $form['expose_button']['markup'] = array(
+ $form['expose_button']['markup'] = [
'#markup' => '<div class="description exposed-description">' . $this->t('This filter is exposed. If you hide it, users will not be able to change it.') . '</div>',
- );
- $form['expose_button']['button'] = array(
- '#limit_validation_errors' => array(),
+ ];
+ $form['expose_button']['button'] = [
+ '#limit_validation_errors' => [],
'#type' => 'submit',
'#value' => $this->t('Hide filter'),
- '#submit' => array(array($this, 'displayExposedForm')),
- );
+ '#submit' => [[$this, 'displayExposedForm']],
+ ];
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
}
}
@@ -509,35 +509,35 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
// prior to rendering. That's why the preRender for it needs to run first,
// so that when the next preRender (the one for fieldsets) runs, it gets
// the flattened data.
- array_unshift($form['#pre_render'], array(get_class($this), 'preRenderFlattenData'));
+ array_unshift($form['#pre_render'], [get_class($this), 'preRenderFlattenData']);
$form['expose']['#flatten'] = TRUE;
if (empty($this->always_required)) {
- $form['expose']['required'] = array(
+ $form['expose']['required'] = [
'#type' => 'checkbox',
'#title' => $this->t('Required'),
'#default_value' => $this->options['expose']['required'],
- );
+ ];
}
else {
- $form['expose']['required'] = array(
+ $form['expose']['required'] = [
'#type' => 'value',
'#value' => TRUE,
- );
+ ];
}
- $form['expose']['label'] = array(
+ $form['expose']['label'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['label'],
'#title' => $this->t('Label'),
'#size' => 40,
- );
+ ];
- $form['expose']['description'] = array(
+ $form['expose']['description'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['description'],
'#title' => $this->t('Description'),
'#size' => 60,
- );
+ ];
if (!empty($form['operator']['#type'])) {
// Increase the width of the left (operator) column.
@@ -546,75 +546,75 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
$form['value']['#prefix'] = '<div class="views-group-box views-right-60">';
$form['value']['#suffix'] = '</div>';
- $form['expose']['use_operator'] = array(
+ $form['expose']['use_operator'] = [
'#type' => 'checkbox',
'#title' => $this->t('Expose operator'),
'#description' => $this->t('Allow the user to choose the operator.'),
'#default_value' => !empty($this->options['expose']['use_operator']),
- );
- $form['expose']['operator_id'] = array(
+ ];
+ $form['expose']['operator_id'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['operator_id'],
'#title' => $this->t('Operator identifier'),
'#size' => 40,
'#description' => $this->t('This will appear in the URL after the ? to identify this operator.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[expose][use_operator]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[expose][use_operator]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
}
else {
- $form['expose']['operator_id'] = array(
+ $form['expose']['operator_id'] = [
'#type' => 'value',
'#value' => '',
- );
+ ];
}
if (empty($this->alwaysMultiple)) {
- $form['expose']['multiple'] = array(
+ $form['expose']['multiple'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple selections'),
'#description' => $this->t('Enable to allow users to select multiple items.'),
'#default_value' => $this->options['expose']['multiple'],
- );
+ ];
}
- $form['expose']['remember'] = array(
+ $form['expose']['remember'] = [
'#type' => 'checkbox',
'#title' => $this->t('Remember the last selection'),
'#description' => $this->t('Enable to remember the last selection made by the user.'),
'#default_value' => $this->options['expose']['remember'],
- );
+ ];
$role_options = array_map('\Drupal\Component\Utility\Html::escape', user_role_names());
- $form['expose']['remember_roles'] = array(
+ $form['expose']['remember_roles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('User roles'),
'#description' => $this->t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'),
'#default_value' => $this->options['expose']['remember_roles'],
'#options' => $role_options,
- '#states' => array(
- 'invisible' => array(
- ':input[name="options[expose][remember]"]' => array('checked' => FALSE),
- ),
- ),
- );
-
- $form['expose']['identifier'] = array(
+ '#states' => [
+ 'invisible' => [
+ ':input[name="options[expose][remember]"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+
+ $form['expose']['identifier'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['identifier'],
'#title' => $this->t('Filter identifier'),
'#size' => 40,
'#description' => $this->t('This will appear in the URL after the ? to identify this filter. Cannot be blank. Only letters, digits and the dot ("."), hyphen ("-"), underscore ("_"), and tilde ("~") characters are allowed.'),
- );
+ ];
}
/**
* Validate the options form.
*/
public function validateExposeForm($form, FormStateInterface $form_state) {
- $identifier = $form_state->getValue(array('options', 'expose', 'identifier'));
+ $identifier = $form_state->getValue(['options', 'expose', 'identifier']);
$this->validateIdentifier($identifier, $form_state, $form['expose']['identifier']);
}
@@ -654,12 +654,12 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
* Validate the build group options form.
*/
protected function buildGroupValidate($form, FormStateInterface $form_state) {
- if (!$form_state->isValueEmpty(array('options', 'group_info'))) {
- $identifier = $form_state->getValue(array('options', 'group_info', 'identifier'));
+ if (!$form_state->isValueEmpty(['options', 'group_info'])) {
+ $identifier = $form_state->getValue(['options', 'group_info', 'identifier']);
$this->validateIdentifier($identifier, $form_state, $form['group_info']['identifier']);
}
- if ($group_items = $form_state->getValue(array('options', 'group_info', 'group_items'))) {
+ if ($group_items = $form_state->getValue(['options', 'group_info', 'group_items'])) {
foreach ($group_items as $id => $group) {
if (empty($group['remove'])) {
$has_valid_value = $this->hasValidGroupedValue($group);
@@ -694,7 +694,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
*
* @return string
*/
- protected function validateIdentifier($identifier, FormStateInterface $form_state = NULL, &$form_group = array()) {
+ protected function validateIdentifier($identifier, FormStateInterface $form_state = NULL, &$form_group = []) {
$error = '';
if (empty($identifier)) {
$error = $this->t('The identifier is required if the filter is exposed.');
@@ -720,9 +720,9 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
* Save new group items, re-enumerates and remove groups marked to delete.
*/
protected function buildGroupSubmit($form, FormStateInterface $form_state) {
- $groups = array();
- $group_items = $form_state->getValue(array('options', 'group_info', 'group_items'));
- uasort($group_items, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ $groups = [];
+ $group_items = $form_state->getValue(['options', 'group_info', 'group_items']);
+ uasort($group_items, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
// Filter out removed items.
// Start from 1 to avoid problems with #default_value in the widget.
@@ -735,26 +735,26 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
unset($group['weight']);
$groups[$new_id] = $group;
- if ($form_state->getValue(array('options', 'group_info', 'default_group')) == $id) {
+ if ($form_state->getValue(['options', 'group_info', 'default_group']) == $id) {
$new_default = $new_id;
}
}
$new_id++;
}
if ($new_default != 'All') {
- $form_state->setValue(array('options', 'group_info', 'default_group'), $new_default);
+ $form_state->setValue(['options', 'group_info', 'default_group'], $new_default);
}
- $filter_default_multiple = $form_state->getValue(array('options', 'group_info', 'default_group_multiple'));
- $form_state->setValue(array('options', 'group_info', 'default_group_multiple'), array_filter($filter_default_multiple));
+ $filter_default_multiple = $form_state->getValue(['options', 'group_info', 'default_group_multiple']);
+ $form_state->setValue(['options', 'group_info', 'default_group_multiple'], array_filter($filter_default_multiple));
- $form_state->setValue(array('options', 'group_info', 'group_items'), $groups);
+ $form_state->setValue(['options', 'group_info', 'group_items'], $groups);
}
/**
* Provide default options for exposed filters.
*/
public function defaultExposeOptions() {
- $this->options['expose'] = array(
+ $this->options['expose'] = [
'use_operator' => FALSE,
'operator' => $this->options['id'] . '_op',
'identifier' => $this->options['id'],
@@ -763,14 +763,14 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
'remember' => FALSE,
'multiple' => FALSE,
'required' => FALSE,
- );
+ ];
}
/**
* Provide default options for exposed filters.
*/
protected function buildGroupOptions() {
- $this->options['group_info'] = array(
+ $this->options['group_info'] = [
'label' => $this->definition['title'],
'description' => NULL,
'identifier' => $this->options['id'],
@@ -779,9 +779,9 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
'multiple' => FALSE,
'remember' => FALSE,
'default_group' => 'All',
- 'default_group_multiple' => array(),
- 'group_items' => array(),
- );
+ 'default_group_multiple' => [],
+ 'group_items' => [],
+ ];
}
/**
@@ -790,7 +790,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
*/
public function groupForm(&$form, FormStateInterface $form_state) {
if (!empty($this->options['group_info']['optional']) && !$this->multipleExposedInput()) {
- $groups = array('All' => $this->t('- Any -'));
+ $groups = ['All' => $this->t('- Any -')];
}
foreach ($this->options['group_info']['group_items'] as $id => $group) {
if (!empty($group['title'])) {
@@ -801,12 +801,12 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
if (count($groups)) {
$value = $this->options['group_info']['identifier'];
- $form[$value] = array(
+ $form[$value] = [
'#title' => $this->options['group_info']['label'],
'#type' => $this->options['group_info']['widget'],
'#default_value' => $this->group_info,
'#options' => $groups,
- );
+ ];
if (!empty($this->options['group_info']['multiple'])) {
if (count($groups) < 5) {
$form[$value]['#type'] = 'checkboxes';
@@ -890,7 +890,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
// prior to rendering. That's why the preRender for it needs to run first,
// so that when the next preRender (the one for fieldsets) runs, it gets
// the flattened data.
- array_unshift($form['#pre_render'], array(get_class($this), 'preRenderFlattenData'));
+ array_unshift($form['#pre_render'], [get_class($this), 'preRenderFlattenData']);
$form['group_info']['#flatten'] = TRUE;
if (!empty($this->options['group_info']['identifier'])) {
@@ -899,53 +899,53 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
else {
$identifier = 'group_' . $this->options['expose']['identifier'];
}
- $form['group_info']['identifier'] = array(
+ $form['group_info']['identifier'] = [
'#type' => 'textfield',
'#default_value' => $identifier,
'#title' => $this->t('Filter identifier'),
'#size' => 40,
'#description' => $this->t('This will appear in the URL after the ? to identify this filter. Cannot be blank. Only letters, digits and the dot ("."), hyphen ("-"), underscore ("_"), and tilde ("~") characters are allowed.'),
- );
- $form['group_info']['label'] = array(
+ ];
+ $form['group_info']['label'] = [
'#type' => 'textfield',
'#default_value' => $this->options['group_info']['label'],
'#title' => $this->t('Label'),
'#size' => 40,
- );
- $form['group_info']['description'] = array(
+ ];
+ $form['group_info']['description'] = [
'#type' => 'textfield',
'#default_value' => $this->options['group_info']['description'],
'#title' => $this->t('Description'),
'#size' => 60,
- );
- $form['group_info']['optional'] = array(
+ ];
+ $form['group_info']['optional'] = [
'#type' => 'checkbox',
'#title' => $this->t('Optional'),
'#description' => $this->t('This exposed filter is optional and will have added options to allow it not to be set.'),
'#default_value' => $this->options['group_info']['optional'],
- );
- $form['group_info']['multiple'] = array(
+ ];
+ $form['group_info']['multiple'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple selections'),
'#description' => $this->t('Enable to allow users to select multiple items.'),
'#default_value' => $this->options['group_info']['multiple'],
- );
- $form['group_info']['widget'] = array(
+ ];
+ $form['group_info']['widget'] = [
'#type' => 'radios',
'#default_value' => $this->options['group_info']['widget'],
'#title' => $this->t('Widget type'),
- '#options' => array(
+ '#options' => [
'radios' => $this->t('Radios'),
'select' => $this->t('Select'),
- ),
+ ],
'#description' => $this->t('Select which kind of widget will be used to render the group of filters'),
- );
- $form['group_info']['remember'] = array(
+ ];
+ $form['group_info']['remember'] = [
'#type' => 'checkbox',
'#title' => $this->t('Remember'),
'#description' => $this->t('Remember the last setting the user gave this filter.'),
'#default_value' => $this->options['group_info']['remember'],
- );
+ ];
if (!empty($this->options['group_info']['identifier'])) {
$identifier = $this->options['group_info']['identifier'];
@@ -953,53 +953,53 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
else {
$identifier = 'group_' . $this->options['expose']['identifier'];
}
- $form['group_info']['identifier'] = array(
+ $form['group_info']['identifier'] = [
'#type' => 'textfield',
'#default_value' => $identifier,
'#title' => $this->t('Filter identifier'),
'#size' => 40,
'#description' => $this->t('This will appear in the URL after the ? to identify this filter. Cannot be blank. Only letters, digits and the dot ("."), hyphen ("-"), underscore ("_"), and tilde ("~") characters are allowed.'),
- );
- $form['group_info']['label'] = array(
+ ];
+ $form['group_info']['label'] = [
'#type' => 'textfield',
'#default_value' => $this->options['group_info']['label'],
'#title' => $this->t('Label'),
'#size' => 40,
- );
- $form['group_info']['optional'] = array(
+ ];
+ $form['group_info']['optional'] = [
'#type' => 'checkbox',
'#title' => $this->t('Optional'),
'#description' => $this->t('This exposed filter is optional and will have added options to allow it not to be set.'),
'#default_value' => $this->options['group_info']['optional'],
- );
- $form['group_info']['widget'] = array(
+ ];
+ $form['group_info']['widget'] = [
'#type' => 'radios',
'#default_value' => $this->options['group_info']['widget'],
'#title' => $this->t('Widget type'),
- '#options' => array(
+ '#options' => [
'radios' => $this->t('Radios'),
'select' => $this->t('Select'),
- ),
+ ],
'#description' => $this->t('Select which kind of widget will be used to render the group of filters'),
- );
- $form['group_info']['remember'] = array(
+ ];
+ $form['group_info']['remember'] = [
'#type' => 'checkbox',
'#title' => $this->t('Remember'),
'#description' => $this->t('Remember the last setting the user gave this filter.'),
'#default_value' => $this->options['group_info']['remember'],
- );
+ ];
- $groups = array('All' => $this->t('- Any -')); // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form
+ $groups = ['All' => $this->t('- Any -')]; // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form
// Provide 3 options to start when we are in a new group.
if (count($this->options['group_info']['group_items']) == 0) {
- $this->options['group_info']['group_items'] = array_fill(1, 3, array());
+ $this->options['group_info']['group_items'] = array_fill(1, 3, []);
}
// After the general settings, comes a table with all the existent groups.
$default_weight = 0;
foreach ($this->options['group_info']['group_items'] as $item_id => $item) {
- if (!$form_state->isValueEmpty(array('options', 'group_info', 'group_items', $item_id, 'remove'))) {
+ if (!$form_state->isValueEmpty(['options', 'group_info', 'group_items', $item_id, 'remove'])) {
continue;
}
// Each rows contains three widgets:
@@ -1009,8 +1009,8 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
// In each row, we have to display the operator form and the value from
// $row acts as a fake form to render each widget in a row.
- $row = array();
- $groups[$item_id] = $this->t('Grouping @id', array('@id' => $item_id));
+ $row = [];
+ $groups[$item_id] = $this->t('Grouping @id', ['@id' => $item_id]);
$this->operatorForm($row, $form_state);
// Force the operator form to be a select box. Some handlers uses
// radios and they occupy a lot of space in a table row.
@@ -1057,71 +1057,71 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
}
// Per item group, we have a title that identifies it.
- $form['group_info']['group_items'][$item_id] = array(
- 'title' => array(
+ $form['group_info']['group_items'][$item_id] = [
+ 'title' => [
'#title' => $this->t('Label'),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#size' => 20,
'#default_value' => $default_title,
- ),
+ ],
'operator' => $row['operator'],
'value' => $row['value'],
// No title is given here, since this input is never displayed. It is
// only triggered by JavaScript.
- 'remove' => array(
+ 'remove' => [
'#type' => 'checkbox',
'#id' => 'views-removed-' . $item_id,
- '#attributes' => array('class' => array('views-remove-checkbox')),
+ '#attributes' => ['class' => ['views-remove-checkbox']],
'#default_value' => 0,
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'#title' => $this->t('Weight'),
'#title_display' => 'invisible',
'#type' => 'weight',
'#delta' => 10,
'#default_value' => $default_weight++,
- '#attributes' => array('class' => array('weight')),
- ),
- );
+ '#attributes' => ['class' => ['weight']],
+ ],
+ ];
}
// From all groups, let chose which is the default.
- $form['group_info']['default_group'] = array(
+ $form['group_info']['default_group'] = [
'#type' => 'radios',
'#options' => $groups,
'#default_value' => $this->options['group_info']['default_group'],
'#required' => TRUE,
- '#attributes' => array(
- 'class' => array('default-radios'),
- )
- );
+ '#attributes' => [
+ 'class' => ['default-radios'],
+ ]
+ ];
// From all groups, let chose which is the default.
- $form['group_info']['default_group_multiple'] = array(
+ $form['group_info']['default_group_multiple'] = [
'#type' => 'checkboxes',
'#options' => $groups,
'#default_value' => $this->options['group_info']['default_group_multiple'],
- '#attributes' => array(
- 'class' => array('default-checkboxes'),
- )
- );
+ '#attributes' => [
+ 'class' => ['default-checkboxes'],
+ ]
+ ];
- $form['group_info']['add_group'] = array(
+ $form['group_info']['add_group'] = [
'#prefix' => '<div class="views-build-group clear-block">',
'#suffix' => '</div>',
'#type' => 'submit',
'#value' => $this->t('Add another item'),
- '#submit' => array(array($this, 'addGroupForm')),
- );
+ '#submit' => [[$this, 'addGroupForm']],
+ ];
- $js = array();
- $js['tableDrag']['views-filter-groups']['weight'][0] = array(
+ $js = [];
+ $js['tableDrag']['views-filter-groups']['weight'][0] = [
'target' => 'weight',
'source' => NULL,
'relationship' => 'sibling',
'action' => 'order',
'hidden' => TRUE,
'limit' => 0,
- );
+ ];
$js_settings = $form_state->get('js_settings');
if ($js_settings && is_array($js)) {
$js_settings = array_merge($js_settings, $js);
@@ -1139,7 +1139,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
$item = &$this->options;
// Add a new row.
- $item['group_info']['group_items'][] = array();
+ $item['group_info']['group_items'][] = [];
$view = $form_state->get('view');
$display_id = $form_state->get('display_id');
@@ -1186,7 +1186,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
}
if ($type == 'value' && empty($this->always_required) && empty($this->options['expose']['required']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
- $form['#options'] = array('All' => $this->t('- Any -')) + $form['#options'];
+ $form['#options'] = ['All' => $this->t('- Any -')] + $form['#options'];
$form['#default_value'] = 'All';
}
@@ -1240,19 +1240,19 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
}
if ($this->isAGroup()) {
- return array(
+ return [
'value' => $this->options['group_info']['identifier'],
'label' => $this->options['group_info']['label'],
'description' => $this->options['group_info']['description'],
- );
+ ];
}
- return array(
+ return [
'operator' => $this->options['expose']['operator_id'],
'value' => $this->options['expose']['identifier'],
'label' => $this->options['expose']['label'],
'description' => $this->options['expose']['description'],
- );
+ ];
}
/**
@@ -1309,7 +1309,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
if (!empty($input[$this->options['group_info']['identifier']])) {
return array_filter($input[$this->options['group_info']['identifier']]);
}
- return array();
+ return [];
}
/**
@@ -1350,7 +1350,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
if ($status !== FALSE) {
if (!isset($_SESSION['views'][$this->view->storage->id()][$display_id])) {
- $_SESSION['views'][$this->view->storage->id()][$display_id] = array();
+ $_SESSION['views'][$this->view->storage->id()][$display_id] = [];
}
$session = &$_SESSION['views'][$this->view->storage->id()][$display_id];
@@ -1388,7 +1388,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
}
if ($this->operator != 'empty' && $this->operator != 'not empty') {
- if ($value == 'All' || $value === array()) {
+ if ($value == 'All' || $value === []) {
return FALSE;
}
@@ -1406,7 +1406,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
if (isset($value)) {
$this->value = $value;
if (empty($this->alwaysMultiple) && empty($this->options['expose']['multiple']) && !is_array($value)) {
- $this->value = array($value);
+ $this->value = [$value];
}
}
else {
@@ -1428,7 +1428,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
// Check if we store exposed value for current user.
$user = \Drupal::currentUser();
- $allowed_rids = empty($this->options['expose']['remember_roles']) ? array() : array_filter($this->options['expose']['remember_roles']);
+ $allowed_rids = empty($this->options['expose']['remember_roles']) ? [] : array_filter($this->options['expose']['remember_roles']);
$intersect_rids = array_intersect(array_keys($allowed_rids), $user->getRoles());
if (empty($intersect_rids)) {
return;
@@ -1456,7 +1456,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
if ($status) {
if (!isset($_SESSION['views'][$this->view->storage->id()][$display_id])) {
- $_SESSION['views'][$this->view->storage->id()][$display_id] = array();
+ $_SESSION['views'][$this->view->storage->id()][$display_id] = [];
}
$session = &$_SESSION['views'][$this->view->storage->id()][$display_id];
diff --git a/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php b/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php
index 4f1baa189da..4934e6e7a91 100644
--- a/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php
+++ b/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php
@@ -24,17 +24,17 @@ class GroupByNumeric extends NumericFilter {
$placeholder_min = $this->placeholder();
$placeholder_max = $this->placeholder();
if ($this->operator == 'between') {
- $this->query->addHavingExpression($this->options['group'], "$field >= $placeholder_min", array($placeholder_min => $this->value['min']));
- $this->query->addHavingExpression($this->options['group'], "$field <= $placeholder_max", array($placeholder_max => $this->value['max']));
+ $this->query->addHavingExpression($this->options['group'], "$field >= $placeholder_min", [$placeholder_min => $this->value['min']]);
+ $this->query->addHavingExpression($this->options['group'], "$field <= $placeholder_max", [$placeholder_max => $this->value['max']]);
}
else {
- $this->query->addHavingExpression($this->options['group'], "$field < $placeholder_min OR $field > $placeholder_max", array($placeholder_min => $this->value['min'], $placeholder_max => $this->value['max']));
+ $this->query->addHavingExpression($this->options['group'], "$field < $placeholder_min OR $field > $placeholder_max", [$placeholder_min => $this->value['min'], $placeholder_max => $this->value['max']]);
}
}
protected function opSimple($field) {
$placeholder = $this->placeholder();
- $this->query->addHavingExpression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value']));
+ $this->query->addHavingExpression($this->options['group'], "$field $this->operator $placeholder", [$placeholder => $this->value['value']]);
}
protected function opEmpty($field) {
diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index ff4186f4ae7..df01536824f 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -71,7 +71,7 @@ class InOperator extends FilterPluginBase {
}
}
else {
- $this->valueOptions = array(t('Yes'), $this->t('No'));
+ $this->valueOptions = [t('Yes'), $this->t('No')];
}
return $this->valueOptions;
@@ -84,20 +84,20 @@ class InOperator extends FilterPluginBase {
public function buildExposeForm(&$form, FormStateInterface $form_state) {
parent::buildExposeForm($form, $form_state);
- $form['expose']['reduce'] = array(
+ $form['expose']['reduce'] = [
'#type' => 'checkbox',
'#title' => $this->t('Limit list to selected items'),
'#description' => $this->t('If checked, the only items presented to the user will be the ones selected here.'),
'#default_value' => !empty($this->options['expose']['reduce']), // safety
- );
+ ];
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['operator']['default'] = 'in';
- $options['value']['default'] = array();
- $options['expose']['contains']['reduce'] = array('default' => FALSE);
+ $options['value']['default'] = [];
+ $options['expose']['contains']['reduce'] = ['default' => FALSE];
return $options;
}
@@ -108,38 +108,38 @@ class InOperator extends FilterPluginBase {
* adding/removing items from this array.
*/
function operators() {
- $operators = array(
- 'in' => array(
+ $operators = [
+ 'in' => [
'title' => $this->t('Is one of'),
'short' => $this->t('in'),
'short_single' => $this->t('='),
'method' => 'opSimple',
'values' => 1,
- ),
- 'not in' => array(
+ ],
+ 'not in' => [
'title' => $this->t('Is not one of'),
'short' => $this->t('not in'),
'short_single' => $this->t('<>'),
'method' => 'opSimple',
'values' => 1,
- ),
- );
+ ],
+ ];
// if the definition allows for the empty operator, add it.
if (!empty($this->definition['allow empty'])) {
- $operators += array(
- 'empty' => array(
+ $operators += [
+ 'empty' => [
'title' => $this->t('Is empty (NULL)'),
'method' => 'opEmpty',
'short' => $this->t('empty'),
'values' => 0,
- ),
- 'not empty' => array(
+ ],
+ 'not empty' => [
'title' => $this->t('Is not empty (NOT NULL)'),
'method' => 'opEmpty',
'short' => $this->t('not empty'),
'values' => 0,
- ),
- );
+ ],
+ ];
}
return $operators;
@@ -149,7 +149,7 @@ class InOperator extends FilterPluginBase {
* Build strings from the operators() for 'select' options
*/
public function operatorOptions($which = 'title') {
- $options = array();
+ $options = [];
foreach ($this->operators() as $id => $info) {
$options[$id] = $info[$which];
}
@@ -158,7 +158,7 @@ class InOperator extends FilterPluginBase {
}
protected function operatorValues($values = 1) {
- $options = array();
+ $options = [];
foreach ($this->operators() as $id => $info) {
if (isset($info['values']) && $info['values'] == $values) {
$options[] = $id;
@@ -169,13 +169,13 @@ class InOperator extends FilterPluginBase {
}
protected function valueForm(&$form, FormStateInterface $form_state) {
- $form['value'] = array();
- $options = array();
+ $form['value'] = [];
+ $options = [];
$exposed = $form_state->get('exposed');
if (!$exposed) {
// Add a select all option to the value form.
- $options = array('all' => $this->t('Select all'));
+ $options = ['all' => $this->t('Select all')];
}
$this->getValueOptions();
@@ -201,7 +201,7 @@ class InOperator extends FilterPluginBase {
$options = $this->reduceValueOptions();
if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
- $default_value = array();
+ $default_value = [];
}
}
@@ -221,7 +221,7 @@ class InOperator extends FilterPluginBase {
}
if ($which == 'all' || $which == 'value') {
- $form['value'] = array(
+ $form['value'] = [
'#type' => $this->valueFormType,
'#title' => $this->valueTitle,
'#options' => $options,
@@ -229,7 +229,7 @@ class InOperator extends FilterPluginBase {
// These are only valid for 'select' type, but do no harm to checkboxes.
'#multiple' => TRUE,
'#size' => count($options) > 8 ? 8 : count($options),
- );
+ ];
$user_input = $form_state->getUserInput();
if ($exposed && !isset($user_input[$identifier])) {
$user_input[$identifier] = $default_value;
@@ -243,9 +243,9 @@ class InOperator extends FilterPluginBase {
}
// Setup #states for all operators with one value.
foreach ($this->operatorValues(1) as $operator) {
- $form['value']['#states']['visible'][] = array(
- $source => array('value' => $operator),
- );
+ $form['value']['#states']['visible'][] = [
+ $source => ['value' => $operator],
+ ];
}
}
}
@@ -262,7 +262,7 @@ class InOperator extends FilterPluginBase {
// Because options may be an array of strings, or an array of mixed arrays
// and strings (optgroups) or an array of objects, we have to
// step through and handle each one individually.
- $options = array();
+ $options = [];
foreach ($input as $id => $option) {
if (is_array($option)) {
$options[$id] = $this->reduceValueOptions($option);
@@ -313,7 +313,7 @@ class InOperator extends FilterPluginBase {
// *only* a list of checkboxes that were set, and we can use that
// instead.
- $form_state->setValue(array('options', 'value'), $form['value']['#value']);
+ $form_state->setValue(['options', 'value'], $form['value']['#value']);
}
public function adminSummary() {
@@ -417,11 +417,11 @@ class InOperator extends FilterPluginBase {
// If the operator is an operator which doesn't require a value, there is
// no need for additional validation.
if (in_array($this->operator, $this->operatorValues(0))) {
- return array();
+ return [];
}
if (!in_array($this->operator, $this->operatorValues(1))) {
- $errors[] = $this->t('The operator is invalid on filter: @filter.', array('@filter' => $this->adminLabel(TRUE)));
+ $errors[] = $this->t('The operator is invalid on filter: @filter.', ['@filter' => $this->adminLabel(TRUE)]);
}
if (is_array($this->value)) {
if (!isset($this->valueOptions)) {
@@ -444,11 +444,11 @@ class InOperator extends FilterPluginBase {
}
// Choose different kind of output for 0, a single and multiple values.
if (count($this->value) == 0) {
- $errors[] = $this->t('No valid values found on filter: @filter.', array('@filter' => $this->adminLabel(TRUE)));
+ $errors[] = $this->t('No valid values found on filter: @filter.', ['@filter' => $this->adminLabel(TRUE)]);
}
}
elseif (!empty($this->value) && ($this->operator == 'in' || $this->operator == 'not in')) {
- $errors[] = $this->t('The value @value is not an array for @operator on filter: @filter', array('@value' => var_export($this->value), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE)));
+ $errors[] = $this->t('The value @value is not an array for @operator on filter: @filter', ['@value' => var_export($this->value), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE)]);
}
return $errors;
}
diff --git a/core/modules/views/src/Plugin/views/filter/ManyToOne.php b/core/modules/views/src/Plugin/views/filter/ManyToOne.php
index 7fa1fbc46fe..645dc819c2e 100644
--- a/core/modules/views/src/Plugin/views/filter/ManyToOne.php
+++ b/core/modules/views/src/Plugin/views/filter/ManyToOne.php
@@ -41,7 +41,7 @@ class ManyToOne extends InOperator {
$options = parent::defineOptions();
$options['operator']['default'] = 'or';
- $options['value']['default'] = array();
+ $options['value']['default'] = [];
if (isset($this->helper)) {
$this->helper->defineOptions($options);
@@ -55,48 +55,48 @@ class ManyToOne extends InOperator {
}
function operators() {
- $operators = array(
- 'or' => array(
+ $operators = [
+ 'or' => [
'title' => $this->t('Is one of'),
'short' => $this->t('or'),
'short_single' => $this->t('='),
'method' => 'opHelper',
'values' => 1,
'ensure_my_table' => 'helper',
- ),
- 'and' => array(
+ ],
+ 'and' => [
'title' => $this->t('Is all of'),
'short' => $this->t('and'),
'short_single' => $this->t('='),
'method' => 'opHelper',
'values' => 1,
'ensure_my_table' => 'helper',
- ),
- 'not' => array(
+ ],
+ 'not' => [
'title' => $this->t('Is none of'),
'short' => $this->t('not'),
'short_single' => $this->t('<>'),
'method' => 'opHelper',
'values' => 1,
'ensure_my_table' => 'helper',
- ),
- );
+ ],
+ ];
// if the definition allows for the empty operator, add it.
if (!empty($this->definition['allow empty'])) {
- $operators += array(
- 'empty' => array(
+ $operators += [
+ 'empty' => [
'title' => $this->t('Is empty (NULL)'),
'method' => 'opEmpty',
'short' => $this->t('empty'),
'values' => 0,
- ),
- 'not empty' => array(
+ ],
+ 'not empty' => [
'title' => $this->t('Is not empty (NOT NULL)'),
'method' => 'opEmpty',
'short' => $this->t('not empty'),
'values' => 0,
- ),
- );
+ ],
+ ];
}
return $operators;
diff --git a/core/modules/views/src/Plugin/views/filter/NumericFilter.php b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
index d1b5257a644..347c9f2cc47 100644
--- a/core/modules/views/src/Plugin/views/filter/NumericFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -18,91 +18,91 @@ class NumericFilter extends FilterPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['value'] = array(
- 'contains' => array(
- 'min' => array('default' => ''),
- 'max' => array('default' => ''),
- 'value' => array('default' => ''),
- ),
- );
+ $options['value'] = [
+ 'contains' => [
+ 'min' => ['default' => ''],
+ 'max' => ['default' => ''],
+ 'value' => ['default' => ''],
+ ],
+ ];
return $options;
}
function operators() {
- $operators = array(
- '<' => array(
+ $operators = [
+ '<' => [
'title' => $this->t('Is less than'),
'method' => 'opSimple',
'short' => $this->t('<'),
'values' => 1,
- ),
- '<=' => array(
+ ],
+ '<=' => [
'title' => $this->t('Is less than or equal to'),
'method' => 'opSimple',
'short' => $this->t('<='),
'values' => 1,
- ),
- '=' => array(
+ ],
+ '=' => [
'title' => $this->t('Is equal to'),
'method' => 'opSimple',
'short' => $this->t('='),
'values' => 1,
- ),
- '!=' => array(
+ ],
+ '!=' => [
'title' => $this->t('Is not equal to'),
'method' => 'opSimple',
'short' => $this->t('!='),
'values' => 1,
- ),
- '>=' => array(
+ ],
+ '>=' => [
'title' => $this->t('Is greater than or equal to'),
'method' => 'opSimple',
'short' => $this->t('>='),
'values' => 1,
- ),
- '>' => array(
+ ],
+ '>' => [
'title' => $this->t('Is greater than'),
'method' => 'opSimple',
'short' => $this->t('>'),
'values' => 1,
- ),
- 'between' => array(
+ ],
+ 'between' => [
'title' => $this->t('Is between'),
'method' => 'opBetween',
'short' => $this->t('between'),
'values' => 2,
- ),
- 'not between' => array(
+ ],
+ 'not between' => [
'title' => $this->t('Is not between'),
'method' => 'opBetween',
'short' => $this->t('not between'),
'values' => 2,
- ),
- 'regular_expression' => array(
+ ],
+ 'regular_expression' => [
'title' => $this->t('Regular expression'),
'short' => $this->t('regex'),
'method' => 'opRegex',
'values' => 1,
- ),
- );
+ ],
+ ];
// if the definition allows for the empty operator, add it.
if (!empty($this->definition['allow empty'])) {
- $operators += array(
- 'empty' => array(
+ $operators += [
+ 'empty' => [
'title' => $this->t('Is empty (NULL)'),
'method' => 'opEmpty',
'short' => $this->t('empty'),
'values' => 0,
- ),
- 'not empty' => array(
+ ],
+ 'not empty' => [
'title' => $this->t('Is not empty (NOT NULL)'),
'method' => 'opEmpty',
'short' => $this->t('not empty'),
'values' => 0,
- ),
- );
+ ],
+ ];
}
return $operators;
@@ -112,7 +112,7 @@ class NumericFilter extends FilterPluginBase {
* Provide a list of all the numeric operators
*/
public function operatorOptions($which = 'title') {
- $options = array();
+ $options = [];
foreach ($this->operators() as $id => $info) {
$options[$id] = $info[$which];
}
@@ -121,7 +121,7 @@ class NumericFilter extends FilterPluginBase {
}
protected function operatorValues($values = 1) {
- $options = array();
+ $options = [];
foreach ($this->operators() as $id => $info) {
if ($info['values'] == $values) {
$options[] = $id;
@@ -159,17 +159,17 @@ class NumericFilter extends FilterPluginBase {
$user_input = $form_state->getUserInput();
if ($which == 'all') {
- $form['value']['value'] = array(
+ $form['value']['value'] = [
'#type' => 'textfield',
'#title' => !$exposed ? $this->t('Value') : '',
'#size' => 30,
'#default_value' => $this->value['value'],
- );
+ ];
// Setup #states for all operators with one value.
foreach ($this->operatorValues(1) as $operator) {
- $form['value']['value']['#states']['visible'][] = array(
- $source => array('value' => $operator),
- );
+ $form['value']['value']['#states']['visible'][] = [
+ $source => ['value' => $operator],
+ ];
}
if ($exposed && !isset($user_input[$identifier]['value'])) {
$user_input[$identifier]['value'] = $this->value['value'];
@@ -179,12 +179,12 @@ class NumericFilter extends FilterPluginBase {
elseif ($which == 'value') {
// When exposed we drop the value-value and just do value if
// the operator is locked.
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'textfield',
'#title' => !$exposed ? $this->t('Value') : '',
'#size' => 30,
'#default_value' => $this->value['value'],
- );
+ ];
if ($exposed && !isset($user_input[$identifier])) {
$user_input[$identifier] = $this->value['value'];
$form_state->setUserInput($user_input);
@@ -192,26 +192,26 @@ class NumericFilter extends FilterPluginBase {
}
if ($which == 'all' || $which == 'minmax') {
- $form['value']['min'] = array(
+ $form['value']['min'] = [
'#type' => 'textfield',
'#title' => !$exposed ? $this->t('Min') : $this->exposedInfo()['label'],
'#size' => 30,
'#default_value' => $this->value['min'],
'#description' => !$exposed ? '' : $this->exposedInfo()['description']
- );
- $form['value']['max'] = array(
+ ];
+ $form['value']['max'] = [
'#type' => 'textfield',
'#title' => !$exposed ? $this->t('And max') : $this->t('And'),
'#size' => 30,
'#default_value' => $this->value['max'],
- );
+ ];
if ($which == 'all') {
- $states = array();
+ $states = [];
// Setup #states for all operators with two values.
foreach ($this->operatorValues(2) as $operator) {
- $states['#states']['visible'][] = array(
- $source => array('value' => $operator),
- );
+ $states['#states']['visible'][] = [
+ $source => ['value' => $operator],
+ ];
}
$form['value']['min'] += $states;
$form['value']['max'] += $states;
@@ -225,10 +225,10 @@ class NumericFilter extends FilterPluginBase {
if (!isset($form['value'])) {
// Ensure there is something in the 'value'.
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'value',
'#value' => NULL
- );
+ ];
}
}
}
@@ -245,10 +245,10 @@ class NumericFilter extends FilterPluginBase {
protected function opBetween($field) {
if ($this->operator == 'between') {
- $this->query->addWhere($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN');
+ $this->query->addWhere($this->options['group'], $field, [$this->value['min'], $this->value['max']], 'BETWEEN');
}
else {
- $this->query->addWhere($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'NOT BETWEEN');
+ $this->query->addWhere($this->options['group'], $field, [$this->value['min'], $this->value['max']], 'NOT BETWEEN');
}
}
@@ -288,7 +288,7 @@ class NumericFilter extends FilterPluginBase {
$options = $this->operatorOptions('short');
$output = $options[$this->operator];
if (in_array($this->operator, $this->operatorValues(2))) {
- $output .= ' ' . $this->t('@min and @max', array('@min' => $this->value['min'], '@max' => $this->value['max']));
+ $output .= ' ' . $this->t('@min and @max', ['@min' => $this->value['min'], '@max' => $this->value['max']]);
}
elseif (in_array($this->operator, $this->operatorValues(1))) {
$output .= ' ' . $this->value['value'];
@@ -309,9 +309,9 @@ class NumericFilter extends FilterPluginBase {
if (!empty($this->options['expose']['identifier'])) {
$value = &$input[$this->options['expose']['identifier']];
if (!is_array($value)) {
- $value = array(
+ $value = [
'value' => $value,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php
index 68739c37208..d55fe69d688 100644
--- a/core/modules/views/src/Plugin/views/filter/StringFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
@@ -26,7 +26,7 @@ class StringFilter extends FilterPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['expose']['contains']['required'] = array('default' => FALSE);
+ $options['expose']['contains']['required'] = ['default' => FALSE];
return $options;
}
@@ -37,102 +37,102 @@ class StringFilter extends FilterPluginBase {
* adding/removing items from this array.
*/
function operators() {
- $operators = array(
- '=' => array(
+ $operators = [
+ '=' => [
'title' => $this->t('Is equal to'),
'short' => $this->t('='),
'method' => 'opEqual',
'values' => 1,
- ),
- '!=' => array(
+ ],
+ '!=' => [
'title' => $this->t('Is not equal to'),
'short' => $this->t('!='),
'method' => 'opEqual',
'values' => 1,
- ),
- 'contains' => array(
+ ],
+ 'contains' => [
'title' => $this->t('Contains'),
'short' => $this->t('contains'),
'method' => 'opContains',
'values' => 1,
- ),
- 'word' => array(
+ ],
+ 'word' => [
'title' => $this->t('Contains any word'),
'short' => $this->t('has word'),
'method' => 'opContainsWord',
'values' => 1,
- ),
- 'allwords' => array(
+ ],
+ 'allwords' => [
'title' => $this->t('Contains all words'),
'short' => $this->t('has all'),
'method' => 'opContainsWord',
'values' => 1,
- ),
- 'starts' => array(
+ ],
+ 'starts' => [
'title' => $this->t('Starts with'),
'short' => $this->t('begins'),
'method' => 'opStartsWith',
'values' => 1,
- ),
- 'not_starts' => array(
+ ],
+ 'not_starts' => [
'title' => $this->t('Does not start with'),
'short' => $this->t('not_begins'),
'method' => 'opNotStartsWith',
'values' => 1,
- ),
- 'ends' => array(
+ ],
+ 'ends' => [
'title' => $this->t('Ends with'),
'short' => $this->t('ends'),
'method' => 'opEndsWith',
'values' => 1,
- ),
- 'not_ends' => array(
+ ],
+ 'not_ends' => [
'title' => $this->t('Does not end with'),
'short' => $this->t('not_ends'),
'method' => 'opNotEndsWith',
'values' => 1,
- ),
- 'not' => array(
+ ],
+ 'not' => [
'title' => $this->t('Does not contain'),
'short' => $this->t('!has'),
'method' => 'opNotLike',
'values' => 1,
- ),
- 'shorterthan' => array(
+ ],
+ 'shorterthan' => [
'title' => $this->t('Length is shorter than'),
'short' => $this->t('shorter than'),
'method' => 'opShorterThan',
'values' => 1,
- ),
- 'longerthan' => array(
+ ],
+ 'longerthan' => [
'title' => $this->t('Length is longer than'),
'short' => $this->t('longer than'),
'method' => 'opLongerThan',
'values' => 1,
- ),
- 'regular_expression' => array(
+ ],
+ 'regular_expression' => [
'title' => $this->t('Regular expression'),
'short' => $this->t('regex'),
'method' => 'opRegex',
'values' => 1,
- ),
- );
+ ],
+ ];
// if the definition allows for the empty operator, add it.
if (!empty($this->definition['allow empty'])) {
- $operators += array(
- 'empty' => array(
+ $operators += [
+ 'empty' => [
'title' => $this->t('Is empty (NULL)'),
'method' => 'opEmpty',
'short' => $this->t('empty'),
'values' => 0,
- ),
- 'not empty' => array(
+ ],
+ 'not empty' => [
'title' => $this->t('Is not empty (NOT NULL)'),
'method' => 'opEmpty',
'short' => $this->t('not empty'),
'values' => 0,
- ),
- );
+ ],
+ ];
}
return $operators;
@@ -142,7 +142,7 @@ class StringFilter extends FilterPluginBase {
* Build strings from the operators() for 'select' options
*/
public function operatorOptions($which = 'title') {
- $options = array();
+ $options = [];
foreach ($this->operators() as $id => $info) {
$options[$id] = $info[$which];
}
@@ -170,7 +170,7 @@ class StringFilter extends FilterPluginBase {
}
protected function operatorValues($values = 1) {
- $options = array();
+ $options = [];
foreach ($this->operators() as $id => $info) {
if (isset($info['values']) && $info['values'] == $values) {
$options[] = $id;
@@ -205,12 +205,12 @@ class StringFilter extends FilterPluginBase {
}
if ($which == 'all' || $which == 'value') {
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'textfield',
'#title' => $this->t('Value'),
'#size' => 30,
'#default_value' => $this->value,
- );
+ ];
$user_input = $form_state->getUserInput();
if ($exposed && !isset($user_input[$identifier])) {
$user_input[$identifier] = $this->value;
@@ -220,19 +220,19 @@ class StringFilter extends FilterPluginBase {
if ($which == 'all') {
// Setup #states for all operators with one value.
foreach ($this->operatorValues(1) as $operator) {
- $form['value']['#states']['visible'][] = array(
- $source => array('value' => $operator),
- );
+ $form['value']['#states']['visible'][] = [
+ $source => ['value' => $operator],
+ ];
}
}
}
if (!isset($form['value'])) {
// Ensure there is something in the 'value'.
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'value',
'#value' => NULL
- );
+ ];
}
}
@@ -282,7 +282,7 @@ class StringFilter extends FilterPluginBase {
$phrase = TRUE;
}
$words = trim($match[2], ',?!();:-');
- $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
+ $words = $phrase ? [$words] : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
foreach ($words as $word) {
$where->condition($field, '%' . db_like(trim($word, " ,!?")) . '%', 'LIKE');
}
@@ -321,14 +321,14 @@ class StringFilter extends FilterPluginBase {
$placeholder = $this->placeholder();
// Type cast the argument to an integer because the SQLite database driver
// has to do some specific alterations to the query base on that data type.
- $this->query->addWhereExpression($this->options['group'], "LENGTH($field) < $placeholder", array($placeholder => (int) $this->value));
+ $this->query->addWhereExpression($this->options['group'], "LENGTH($field) < $placeholder", [$placeholder => (int) $this->value]);
}
protected function opLongerThan($field) {
$placeholder = $this->placeholder();
// Type cast the argument to an integer because the SQLite database driver
// has to do some specific alterations to the query base on that data type.
- $this->query->addWhereExpression($this->options['group'], "LENGTH($field) > $placeholder", array($placeholder => (int) $this->value));
+ $this->query->addWhereExpression($this->options['group'], "LENGTH($field) > $placeholder", [$placeholder => (int) $this->value]);
}
/**
diff --git a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
index 37c1e064b7b..0aa6aa3b679 100644
--- a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
+++ b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
@@ -191,7 +191,7 @@ class JoinPluginBase extends PluginBase implements JoinPluginInterface {
*
* @see \Drupal\views\Plugin\views\join\JoinPluginBase::initJoin()
*/
- public $configuration = array();
+ public $configuration = [];
/**
* How all the extras will be combined. Either AND or OR.
@@ -223,10 +223,10 @@ class JoinPluginBase extends PluginBase implements JoinPluginInterface {
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
// Merge in some default values.
- $configuration += array(
+ $configuration += [
'type' => 'LEFT',
'extra_operator' => 'AND'
- );
+ ];
$this->configuration = $configuration;
if (!empty($configuration['table'])) {
@@ -270,17 +270,17 @@ class JoinPluginBase extends PluginBase implements JoinPluginInterface {
}
$condition = "$left_field = $table[alias].$this->field";
- $arguments = array();
+ $arguments = [];
// Tack on the extra.
if (isset($this->extra)) {
if (is_array($this->extra)) {
- $extras = array();
+ $extras = [];
foreach ($this->extra as $info) {
// Do not require 'value' to be set; allow for field syntax instead.
- $info += array(
+ $info += [
'value' => NULL,
- );
+ ];
// Figure out the table name. Remember, only use aliases provided
// if at all possible.
$join_table = '';
diff --git a/core/modules/views/src/Plugin/views/join/Subquery.php b/core/modules/views/src/Plugin/views/join/Subquery.php
index fa2e421b8f2..f407ffce33d 100644
--- a/core/modules/views/src/Plugin/views/join/Subquery.php
+++ b/core/modules/views/src/Plugin/views/join/Subquery.php
@@ -48,14 +48,14 @@ class Subquery extends JoinPluginBase {
// Add our join condition, using a subquery on the left instead of a field.
$condition = "($this->left_query) = $table[alias].$this->field";
- $arguments = array();
+ $arguments = [];
// Tack on the extra.
// This is just copied verbatim from the parent class, which itself has a
// bug: https://www.drupal.org/node/1118100.
if (isset($this->extra)) {
if (is_array($this->extra)) {
- $extras = array();
+ $extras = [];
foreach ($this->extra as $info) {
// Figure out the table name. Remember, only use aliases provided
// if at all possible.
diff --git a/core/modules/views/src/Plugin/views/pager/Full.php b/core/modules/views/src/Plugin/views/pager/Full.php
index 76e646974f6..7d3adae63c0 100644
--- a/core/modules/views/src/Plugin/views/pager/Full.php
+++ b/core/modules/views/src/Plugin/views/pager/Full.php
@@ -27,10 +27,10 @@ class Full extends SqlBase {
$options = parent::defineOptions();
// Use the same default quantity that core uses by default.
- $options['quantity'] = array('default' => 9);
+ $options['quantity'] = ['default' => 9];
- $options['tags']['contains']['first'] = array('default' => $this->t('« First'));
- $options['tags']['contains']['last'] = array('default' => $this->t('Last »'));
+ $options['tags']['contains']['first'] = ['default' => $this->t('« First')];
+ $options['tags']['contains']['last'] = ['default' => $this->t('Last »')];
return $options;
}
@@ -41,26 +41,26 @@ class Full extends SqlBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['quantity'] = array(
+ $form['quantity'] = [
'#type' => 'number',
'#title' => $this->t('Number of pager links visible'),
'#description' => $this->t('Specify the number of links to pages to display in the pager.'),
'#default_value' => $this->options['quantity'],
- );
+ ];
- $form['tags']['first'] = array(
+ $form['tags']['first'] = [
'#type' => 'textfield',
'#title' => $this->t('First page link text'),
'#default_value' => $this->options['tags']['first'],
'#weight' => -10,
- );
+ ];
- $form['tags']['last'] = array(
+ $form['tags']['last'] = [
'#type' => 'textfield',
'#title' => $this->t('Last page link text'),
'#default_value' => $this->options['tags']['last'],
'#weight' => 10,
- );
+ ];
}
/**
@@ -68,9 +68,9 @@ class Full extends SqlBase {
*/
public function summaryTitle() {
if (!empty($this->options['offset'])) {
- return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', 'Paged, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
+ return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', 'Paged, @count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]);
}
- return $this->formatPlural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page']));
+ return $this->formatPlural($this->options['items_per_page'], '@count item', 'Paged, @count items', ['@count' => $this->options['items_per_page']]);
}
/**
@@ -79,20 +79,20 @@ class Full extends SqlBase {
public function render($input) {
// The 0, 1, 3, 4 indexes are correct. See the template_preprocess_pager()
// documentation.
- $tags = array(
+ $tags = [
0 => $this->options['tags']['first'],
1 => $this->options['tags']['previous'],
3 => $this->options['tags']['next'],
4 => $this->options['tags']['last'],
- );
- return array(
+ ];
+ return [
'#theme' => $this->themeFunctions(),
'#tags' => $tags,
'#element' => $this->options['id'],
'#parameters' => $input,
'#quantity' => $this->options['quantity'],
'#route_name' => !empty($this->view->live_preview) ? '<current>' : '<none>',
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/pager/Mini.php b/core/modules/views/src/Plugin/views/pager/Mini.php
index c6520f4fb60..f92f193b15a 100644
--- a/core/modules/views/src/Plugin/views/pager/Mini.php
+++ b/core/modules/views/src/Plugin/views/pager/Mini.php
@@ -36,9 +36,9 @@ class Mini extends SqlBase {
*/
public function summaryTitle() {
if (!empty($this->options['offset'])) {
- return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
+ return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]);
}
- return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page']));
+ return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', ['@count' => $this->options['items_per_page']]);
}
/**
@@ -89,17 +89,17 @@ class Mini extends SqlBase {
*/
public function render($input) {
// The 1, 3 indexes are correct, see template_preprocess_pager().
- $tags = array(
+ $tags = [
1 => $this->options['tags']['previous'],
3 => $this->options['tags']['next'],
- );
- return array(
+ ];
+ return [
'#theme' => $this->themeFunctions(),
'#tags' => $tags,
'#element' => $this->options['id'],
'#parameters' => $input,
'#route_name' => !empty($this->view->live_preview) ? '<current>' : '<none>',
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/pager/None.php b/core/modules/views/src/Plugin/views/pager/None.php
index e5dcecdef89..ae2891a27db 100644
--- a/core/modules/views/src/Plugin/views/pager/None.php
+++ b/core/modules/views/src/Plugin/views/pager/None.php
@@ -32,14 +32,14 @@ class None extends PagerPluginBase {
public function summaryTitle() {
if (!empty($this->options['offset'])) {
- return $this->t('All items, skip @skip', array('@skip' => $this->options['offset']));
+ return $this->t('All items, skip @skip', ['@skip' => $this->options['offset']]);
}
return $this->t('All items');
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['offset'] = array('default' => 0);
+ $options['offset'] = ['default' => 0];
return $options;
}
@@ -49,12 +49,12 @@ class None extends PagerPluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['offset'] = array(
+ $form['offset'] = [
'#type' => 'textfield',
'#title' => $this->t('Offset (number of items to skip)'),
'#description' => $this->t('For example, set this to 3 and the first 3 items will not be displayed.'),
'#default_value' => $this->options['offset'],
- );
+ ];
}
public function usePager() {
diff --git a/core/modules/views/src/Plugin/views/pager/Some.php b/core/modules/views/src/Plugin/views/pager/Some.php
index ef7f65d8437..59edaea082b 100644
--- a/core/modules/views/src/Plugin/views/pager/Some.php
+++ b/core/modules/views/src/Plugin/views/pager/Some.php
@@ -20,15 +20,15 @@ class Some extends PagerPluginBase {
public function summaryTitle() {
if (!empty($this->options['offset'])) {
- return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
+ return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]);
}
- return $this->formatPlural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page']));
+ return $this->formatPlural($this->options['items_per_page'], '@count item', '@count items', ['@count' => $this->options['items_per_page']]);
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['items_per_page'] = array('default' => 10);
- $options['offset'] = array('default' => 0);
+ $options['items_per_page'] = ['default' => 10];
+ $options['offset'] = ['default' => 0];
return $options;
}
@@ -39,19 +39,19 @@ class Some extends PagerPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$pager_text = $this->displayHandler->getPagerText();
- $form['items_per_page'] = array(
+ $form['items_per_page'] = [
'#title' => $pager_text['items per page title'],
'#type' => 'textfield',
'#description' => $pager_text['items per page description'],
'#default_value' => $this->options['items_per_page'],
- );
+ ];
- $form['offset'] = array(
+ $form['offset'] = [
'#type' => 'textfield',
'#title' => $this->t('Offset (number of items to skip)'),
'#description' => $this->t('For example, set this to 3 and the first 3 items will not be displayed.'),
'#default_value' => $this->options['offset'],
- );
+ ];
}
public function usePager() {
diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php
index 0154762c07c..46daeb7ed71 100644
--- a/core/modules/views/src/Plugin/views/pager/SqlBase.php
+++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php
@@ -13,28 +13,28 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt
protected function defineOptions() {
$options = parent::defineOptions();
- $options['items_per_page'] = array('default' => 10);
- $options['offset'] = array('default' => 0);
- $options['id'] = array('default' => 0);
- $options['total_pages'] = array('default' => '');
- $options['expose'] = array(
- 'contains' => array(
- 'items_per_page' => array('default' => FALSE),
- 'items_per_page_label' => array('default' => $this->t('Items per page')),
- 'items_per_page_options' => array('default' => '5, 10, 25, 50'),
- 'items_per_page_options_all' => array('default' => FALSE),
- 'items_per_page_options_all_label' => array('default' => $this->t('- All -')),
-
- 'offset' => array('default' => FALSE),
- 'offset_label' => array('default' => $this->t('Offset')),
- ),
- );
- $options['tags'] = array(
- 'contains' => array(
- 'previous' => array('default' => $this->t('‹ Previous')),
- 'next' => array('default' => $this->t('Next ›')),
- ),
- );
+ $options['items_per_page'] = ['default' => 10];
+ $options['offset'] = ['default' => 0];
+ $options['id'] = ['default' => 0];
+ $options['total_pages'] = ['default' => ''];
+ $options['expose'] = [
+ 'contains' => [
+ 'items_per_page' => ['default' => FALSE],
+ 'items_per_page_label' => ['default' => $this->t('Items per page')],
+ 'items_per_page_options' => ['default' => '5, 10, 25, 50'],
+ 'items_per_page_options_all' => ['default' => FALSE],
+ 'items_per_page_options_all_label' => ['default' => $this->t('- All -')],
+
+ 'offset' => ['default' => FALSE],
+ 'offset_label' => ['default' => $this->t('Offset')],
+ ],
+ ];
+ $options['tags'] = [
+ 'contains' => [
+ 'previous' => ['default' => $this->t('‹ Previous')],
+ 'next' => ['default' => $this->t('Next ›')],
+ ],
+ ];
return $options;
}
@@ -44,135 +44,135 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$pager_text = $this->displayHandler->getPagerText();
- $form['items_per_page'] = array(
+ $form['items_per_page'] = [
'#title' => $pager_text['items per page title'],
'#type' => 'number',
'#description' => $pager_text['items per page description'],
'#default_value' => $this->options['items_per_page'],
- );
+ ];
- $form['offset'] = array(
+ $form['offset'] = [
'#type' => 'number',
'#title' => $this->t('Offset (number of items to skip)'),
'#description' => $this->t('For example, set this to 3 and the first 3 items will not be displayed.'),
'#default_value' => $this->options['offset'],
- );
+ ];
- $form['id'] = array(
+ $form['id'] = [
'#type' => 'number',
'#title' => $this->t('Pager ID'),
'#description' => $this->t("Unless you're experiencing problems with pagers related to this view, you should leave this at 0. If using multiple pagers on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add a lot of commas to your URLs, so avoid if possible."),
'#default_value' => $this->options['id'],
- );
+ ];
- $form['total_pages'] = array(
+ $form['total_pages'] = [
'#type' => 'number',
'#title' => $this->t('Number of pages'),
'#description' => $this->t('Leave empty to show all pages.'),
'#default_value' => $this->options['total_pages'],
- );
+ ];
- $form['tags'] = array(
+ $form['tags'] = [
'#type' => 'details',
'#open' => TRUE,
'#tree' => TRUE,
'#title' => $this->t('Pager link labels'),
'#input' => TRUE,
- );
+ ];
- $form['tags']['previous'] = array(
+ $form['tags']['previous'] = [
'#type' => 'textfield',
'#title' => $this->t('Previous page link text'),
'#default_value' => $this->options['tags']['previous'],
- );
+ ];
- $form['tags']['next'] = array(
+ $form['tags']['next'] = [
'#type' => 'textfield',
'#title' => $this->t('Next page link text'),
'#default_value' => $this->options['tags']['next'],
- );
+ ];
- $form['expose'] = array(
+ $form['expose'] = [
'#type' => 'details',
'#open' => TRUE,
'#tree' => TRUE,
'#title' => $this->t('Exposed options'),
'#input' => TRUE,
'#description' => $this->t('Allow user to control selected display options for this view.'),
- );
+ ];
- $form['expose']['items_per_page'] = array(
+ $form['expose']['items_per_page'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow user to control the number of items displayed in this view'),
'#default_value' => $this->options['expose']['items_per_page'],
- );
+ ];
- $form['expose']['items_per_page_label'] = array(
+ $form['expose']['items_per_page_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Items per page label'),
'#required' => TRUE,
'#default_value' => $this->options['expose']['items_per_page_label'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE),
- ),
- ),
- );
-
- $form['expose']['items_per_page_options'] = array(
+ '#states' => [
+ 'invisible' => [
+ 'input[name="pager_options[expose][items_per_page]"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+
+ $form['expose']['items_per_page_options'] = [
'#type' => 'textfield',
'#title' => $this->t('Exposed items per page options'),
'#required' => TRUE,
'#description' => $this->t('Set between which values the user can choose when determining the items per page. Separated by comma.'),
'#default_value' => $this->options['expose']['items_per_page_options'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE),
- ),
- ),
- );
+ '#states' => [
+ 'invisible' => [
+ 'input[name="pager_options[expose][items_per_page]"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
- $form['expose']['items_per_page_options_all'] = array(
+ $form['expose']['items_per_page_options_all'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow user to display all items'),
'#default_value' => $this->options['expose']['items_per_page_options_all'],
- );
+ ];
- $form['expose']['items_per_page_options_all_label'] = array(
+ $form['expose']['items_per_page_options_all_label'] = [
'#type' => 'textfield',
'#title' => $this->t('All items label'),
'#default_value' => $this->options['expose']['items_per_page_options_all_label'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="pager_options[expose][items_per_page_options_all]"]' => array('checked' => FALSE),
- ),
- ),
- );
-
- $form['expose']['offset'] = array(
+ '#states' => [
+ 'invisible' => [
+ 'input[name="pager_options[expose][items_per_page_options_all]"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
+
+ $form['expose']['offset'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow user to specify number of items skipped from beginning of this view.'),
'#default_value' => $this->options['expose']['offset'],
- );
+ ];
- $form['expose']['offset_label'] = array(
+ $form['expose']['offset_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Offset label'),
'#required' => TRUE,
'#default_value' => $this->options['expose']['offset_label'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="pager_options[expose][offset]"]' => array('checked' => FALSE),
- ),
- ),
- );
+ '#states' => [
+ 'invisible' => [
+ 'input[name="pager_options[expose][offset]"]' => ['checked' => FALSE],
+ ],
+ ],
+ ];
}
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
// Only accept integer values.
$error = FALSE;
- $exposed_options = $form_state->getValue(array('pager_options', 'expose', 'items_per_page_options'));
+ $exposed_options = $form_state->getValue(['pager_options', 'expose', 'items_per_page_options']);
if (strpos($exposed_options, '.') !== FALSE) {
$error = TRUE;
}
@@ -192,11 +192,11 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt
}
// Make sure that the items_per_page is part of the expose settings.
- if (!$form_state->isValueEmpty(array('pager_options', 'expose', 'items_per_page')) && !$form_state->isValueEmpty(array('pager_options', 'items_per_page'))) {
- $items_per_page = $form_state->getValue(array('pager_options', 'items_per_page'));
+ if (!$form_state->isValueEmpty(['pager_options', 'expose', 'items_per_page']) && !$form_state->isValueEmpty(['pager_options', 'items_per_page'])) {
+ $items_per_page = $form_state->getValue(['pager_options', 'items_per_page']);
if (array_search($items_per_page, $options) === FALSE) {
$form_state->setErrorByName('pager_options][expose][items_per_page_options', $this->t("The <em>Exposed items per page</em> field's options must include the value from the <em>Items per page</em> field (@items_per_page).",
- array('@items_per_page' => $items_per_page))
+ ['@items_per_page' => $items_per_page])
);
}
}
@@ -253,13 +253,13 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt
global $pager_page_array;
if (empty($pager_page_array)) {
- $pager_page_array = array();
+ $pager_page_array = [];
}
// Fill in missing values in the global page array, in case the global page
// array hasn't been initialized before.
$page = $this->view->getRequest()->query->get('page');
- $page = isset($page) ? explode(',', $page) : array();
+ $page = isset($page) ? explode(',', $page) : [];
for ($i = 0; $i <= $this->options['id'] || $i < count($pager_page_array); $i++) {
$pager_page_array[$i] = empty($page[$i]) ? 0 : $page[$i];
@@ -331,7 +331,7 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt
public function exposedFormAlter(&$form, FormStateInterface $form_state) {
if ($this->itemsPerPageExposed()) {
$options = explode(',', $this->options['expose']['items_per_page_options']);
- $sanitized_options = array();
+ $sanitized_options = [];
if (is_array($options)) {
foreach ($options as $option) {
$sanitized_options[intval($option)] = intval($option);
@@ -339,23 +339,23 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt
if (!empty($this->options['expose']['items_per_page_options_all']) && !empty($this->options['expose']['items_per_page_options_all_label'])) {
$sanitized_options['All'] = $this->options['expose']['items_per_page_options_all_label'];
}
- $form['items_per_page'] = array(
+ $form['items_per_page'] = [
'#type' => 'select',
'#title' => $this->options['expose']['items_per_page_label'],
'#options' => $sanitized_options,
'#default_value' => $this->getItemsPerPage(),
- );
+ ];
}
}
if ($this->isOffsetExposed()) {
- $form['offset'] = array(
+ $form['offset'] = [
'#type' => 'textfield',
'#size' => 10,
'#maxlength' => 10,
'#title' => $this->options['expose']['offset_label'],
'#default_value' => $this->getOffset(),
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
index d4e1b23cc78..3f9535e2609 100644
--- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
+++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
@@ -173,7 +173,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
// Create an empty group
if (empty($groups[$group])) {
- $groups[$group] = array('conditions' => array(), 'args' => array());
+ $groups[$group] = ['conditions' => [], 'args' => []];
}
$groups[$group]['type'] = strtoupper($type);
@@ -261,19 +261,19 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
*/
public function getEntityTableInfo() {
// Start with the base table.
- $entity_tables = array();
+ $entity_tables = [];
$views_data = Views::viewsData();
$base_table = $this->view->storage->get('base_table');
$base_table_data = $views_data->get($base_table);
if (isset($base_table_data['table']['entity type'])) {
- $entity_tables[$base_table_data['table']['entity type']] = array(
+ $entity_tables[$base_table_data['table']['entity type']] = [
'base' => $base_table,
'alias' => $base_table,
'relationship_id' => 'none',
'entity_type' => $base_table_data['table']['entity type'],
'revision' => $base_table_data['table']['entity revision'],
- );
+ ];
// Include the entity provider.
if (!empty($base_table_data['table']['provider'])) {
@@ -293,13 +293,13 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
continue;
}
- $entity_tables[$relationship_id . '__' . $relationship->tableAlias] = array(
+ $entity_tables[$relationship_id . '__' . $relationship->tableAlias] = [
'base' => $relationship->definition['base'],
'relationship_id' => $relationship_id,
'alias' => $relationship->alias,
'entity_type' => $table_data['table']['entity type'],
'revision' => $table_data['table']['entity revision'],
- );
+ ];
// Include the entity provider.
if (!empty($table_data['table']['provider'])) {
diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index 9252b6cb03a..ab056f59a71 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -33,31 +33,31 @@ class Sql extends QueryPluginBase {
/**
* A list of tables in the order they should be added, keyed by alias.
*/
- protected $tableQueue = array();
+ protected $tableQueue = [];
/**
* Holds an array of tables and counts added so that we can create aliases
*/
- public $tables = array();
+ public $tables = [];
/**
* Holds an array of relationships, which are aliases of the primary
* table that represent different ways to join the same table in.
*/
- public $relationships = array();
+ public $relationships = [];
/**
* An array of sections of the WHERE query. Each section is in itself
* an array of pieces and a flag as to whether or not it should be AND
* or OR.
*/
- public $where = array();
+ public $where = [];
/**
* An array of sections of the HAVING query. Each section is in itself
* an array of pieces and a flag as to whether or not it should be AND
* or OR.
*/
- public $having = array();
+ public $having = [];
/**
* The default operator to use when connecting the WHERE groups. May be
* AND or OR.
@@ -67,18 +67,18 @@ class Sql extends QueryPluginBase {
/**
* A simple array of order by clauses.
*/
- public $orderby = array();
+ public $orderby = [];
/**
* A simple array of group by clauses.
*/
- public $groupby = array();
+ public $groupby = [];
/**
* An array of fields.
*/
- public $fields = array();
+ public $fields = [];
/**
* A flag as to whether or not to make the primary field distinct.
@@ -95,12 +95,12 @@ class Sql extends QueryPluginBase {
/**
* An array mapping table aliases and field names to field aliases.
*/
- protected $fieldAliases = array();
+ protected $fieldAliases = [];
/**
* Query tags which will be passed over to the dbtng query object.
*/
- public $tags = array();
+ public $tags = [];
/**
* Is the view marked as not distinct.
@@ -151,33 +151,33 @@ class Sql extends QueryPluginBase {
$base_table = $this->view->storage->get('base_table');
$base_field = $this->view->storage->get('base_field');
- $this->relationships[$base_table] = array(
+ $this->relationships[$base_table] = [
'link' => NULL,
'table' => $base_table,
'alias' => $base_table,
'base' => $base_table
- );
+ ];
// init the table queue with our primary table.
- $this->tableQueue[$base_table] = array(
+ $this->tableQueue[$base_table] = [
'alias' => $base_table,
'table' => $base_table,
'relationship' => $base_table,
'join' => NULL,
- );
+ ];
// init the tables with our primary table
- $this->tables[$base_table][$base_table] = array(
+ $this->tables[$base_table][$base_table] = [
'count' => 1,
'alias' => $base_table,
- );
+ ];
- $this->count_field = array(
+ $this->count_field = [
'table' => $base_table,
'field' => $base_field,
'alias' => $base_field,
'count' => TRUE,
- );
+ ];
}
/**
@@ -199,31 +199,31 @@ class Sql extends QueryPluginBase {
if (empty($alias)) {
$alias = $table . '_' . $field;
}
- $this->count_field = array(
+ $this->count_field = [
'table' => $table,
'field' => $field,
'alias' => $alias,
'count' => TRUE,
- );
+ ];
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['disable_sql_rewrite'] = array(
+ $options['disable_sql_rewrite'] = [
'default' => FALSE,
- );
- $options['distinct'] = array(
+ ];
+ $options['distinct'] = [
'default' => FALSE,
- );
- $options['replica'] = array(
+ ];
+ $options['replica'] = [
'default' => FALSE,
- );
- $options['query_comment'] = array(
+ ];
+ $options['query_comment'] = [
'default' => '',
- );
- $options['query_tags'] = array(
- 'default' => array(),
- );
+ ];
+ $options['query_tags'] = [
+ 'default' => [],
+ ];
return $options;
}
@@ -234,45 +234,45 @@ class Sql extends QueryPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['disable_sql_rewrite'] = array(
+ $form['disable_sql_rewrite'] = [
'#title' => $this->t('Disable SQL rewriting'),
'#description' => $this->t('Disabling SQL rewriting will omit all query tags, i. e. disable node access checks as well as override hook_query_alter() implementations in other modules.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['disable_sql_rewrite']),
'#suffix' => '<div class="messages messages--warning sql-rewrite-warning js-hide">' . $this->t('WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Use this option only if you understand and accept this security risk.') . '</div>',
- );
- $form['distinct'] = array(
+ ];
+ $form['distinct'] = [
'#type' => 'checkbox',
'#title' => $this->t('Distinct'),
'#description' => $this->t('This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution.'),
'#default_value' => !empty($this->options['distinct']),
- );
- $form['replica'] = array(
+ ];
+ $form['replica'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use Secondary Server'),
'#description' => $this->t('This will make the query attempt to connect to a replica server if available. If no replica server is defined or available, it will fall back to the default server.'),
'#default_value' => !empty($this->options['replica']),
- );
- $form['query_comment'] = array(
+ ];
+ $form['query_comment'] = [
'#type' => 'textfield',
'#title' => $this->t('Query Comment'),
'#description' => $this->t('If set, this comment will be embedded in the query and passed to the SQL server. This can be helpful for logging or debugging.'),
'#default_value' => $this->options['query_comment'],
- );
- $form['query_tags'] = array(
+ ];
+ $form['query_tags'] = [
'#type' => 'textfield',
'#title' => $this->t('Query Tags'),
'#description' => $this->t('If set, these tags will be appended to the query and can be used to identify the query in a module. This can be helpful for altering queries.'),
'#default_value' => implode(', ', $this->options['query_tags']),
- '#element_validate' => array('views_element_validate_tags'),
- );
+ '#element_validate' => ['views_element_validate_tags'],
+ ];
}
/**
* Special submit handling.
*/
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
- $element = array('#parents' => array('query', 'options', 'query_tags'));
+ $element = ['#parents' => ['query', 'options', 'query_tags']];
$value = explode(',', NestedArray::getValue($form_state->getValues(), $element['#parents']));
$value = array_filter(array_map('trim', $value));
$form_state->setValueForElement($element, $value);
@@ -328,24 +328,24 @@ class Sql extends QueryPluginBase {
// Add the table directly to the queue to avoid accidentally marking
// it.
- $this->tableQueue[$alias] = array(
+ $this->tableQueue[$alias] = [
'table' => $join->table,
'num' => 1,
'alias' => $alias,
'join' => $join,
'relationship' => $link_point,
- );
+ ];
- $this->relationships[$alias] = array(
+ $this->relationships[$alias] = [
'link' => $link_point,
'table' => $join->table,
'base' => $base,
- );
+ ];
- $this->tables[$this->view->storage->get('base_table')][$alias] = array(
+ $this->tables[$this->view->storage->get('base_table')][$alias] = [
'count' => 1,
'alias' => $alias,
- );
+ ];
return $alias;
}
@@ -471,13 +471,13 @@ class Sql extends QueryPluginBase {
$join = $this->adjustJoin($join, $relationship);
}
- $this->tableQueue[$alias] = array(
+ $this->tableQueue[$alias] = [
'table' => $table,
'num' => $this->tables[$relationship][$table]['count'],
'alias' => $alias,
'join' => $join,
'relationship' => $relationship,
- );
+ ];
return $alias;
}
@@ -494,10 +494,10 @@ class Sql extends QueryPluginBase {
}
$alias .= $table;
}
- $this->tables[$relationship][$table] = array(
+ $this->tables[$relationship][$table] = [
'count' => 1,
'alias' => $alias,
- );
+ ];
}
else {
$this->tables[$relationship][$table]['count']++;
@@ -603,7 +603,7 @@ class Sql extends QueryPluginBase {
* query they will be added, but additional copies will NOT be added
* if the table is already there.
*/
- protected function ensurePath($table, $relationship = NULL, $join = NULL, $traced = array(), $add = array()) {
+ protected function ensurePath($table, $relationship = NULL, $join = NULL, $traced = [], $add = []) {
if (!isset($relationship)) {
$relationship = $this->view->storage->get('base_table');
}
@@ -763,7 +763,7 @@ class Sql extends QueryPluginBase {
* @return string
* The name that this field can be referred to as. Usually this is the alias.
*/
- public function addField($table, $field, $alias = '', $params = array()) {
+ public function addField($table, $field, $alias = '', $params = []) {
// We check for this specifically because it gets a special alias.
if ($table == $this->view->storage->get('base_table') && $field == $this->view->storage->get('base_field') && empty($alias)) {
$alias = $this->view->storage->get('base_field');
@@ -788,11 +788,11 @@ class Sql extends QueryPluginBase {
$alias = strtolower(substr($alias, 0, 60));
// Create a field info array.
- $field_info = array(
+ $field_info = [
'field' => $field,
'table' => $table,
'alias' => $alias,
- ) + $params;
+ ] + $params;
// Test to see if the field is actually the same or not. Due to
// differing parameters changing the aggregation function, we need
@@ -818,7 +818,7 @@ class Sql extends QueryPluginBase {
* mode where we're changing the query because we didn't get data we needed.
*/
public function clearFields() {
- $this->fields = array();
+ $this->fields = [];
}
/**
@@ -867,11 +867,11 @@ class Sql extends QueryPluginBase {
$this->setWhereGroup('AND', $group);
}
- $this->where[$group]['conditions'][] = array(
+ $this->where[$group]['conditions'][] = [
'field' => $field,
'value' => $value,
'operator' => $operator,
- );
+ ];
}
/**
@@ -893,7 +893,7 @@ class Sql extends QueryPluginBase {
*
* @see QueryConditionInterface::where()
*/
- public function addWhereExpression($group, $snippet, $args = array()) {
+ public function addWhereExpression($group, $snippet, $args = []) {
// Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
// the default group.
if (empty($group)) {
@@ -905,11 +905,11 @@ class Sql extends QueryPluginBase {
$this->setWhereGroup('AND', $group);
}
- $this->where[$group]['conditions'][] = array(
+ $this->where[$group]['conditions'][] = [
'field' => $snippet,
'value' => $args,
'operator' => 'formula',
- );
+ ];
}
/**
@@ -930,7 +930,7 @@ class Sql extends QueryPluginBase {
*
* @see QueryConditionInterface::having()
*/
- public function addHavingExpression($group, $snippet, $args = array()) {
+ public function addHavingExpression($group, $snippet, $args = []) {
// Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
// the default group.
if (empty($group)) {
@@ -943,11 +943,11 @@ class Sql extends QueryPluginBase {
}
// Add the clause and the args.
- $this->having[$group]['conditions'][] = array(
+ $this->having[$group]['conditions'][] = [
'field' => $snippet,
'value' => $args,
'operator' => 'formula',
- );
+ ];
}
/**
@@ -969,7 +969,7 @@ class Sql extends QueryPluginBase {
* @param $params
* Any params that should be passed through to the addField.
*/
- public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) {
+ public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = []) {
// Only ensure the table if it's not the special random key.
// @todo: Maybe it would make sense to just add an addOrderByRand or something similar.
if ($table && $table != 'rand') {
@@ -989,10 +989,10 @@ class Sql extends QueryPluginBase {
$as = $this->addField($table, $field, $as, $params);
}
- $this->orderby[] = array(
+ $this->orderby[] = [
'field' => $as,
'direction' => strtoupper($order)
- );
+ ];
}
/**
@@ -1031,7 +1031,7 @@ class Sql extends QueryPluginBase {
* Generates a unique placeholder used in the db query.
*/
public function placeholder($base = 'views') {
- static $placeholders = array();
+ static $placeholders = [];
if (!isset($placeholders[$base])) {
$placeholders[$base] = 0;
return ':' . $base;
@@ -1111,7 +1111,7 @@ class Sql extends QueryPluginBase {
* An array of the fieldnames which are non-aggregates.
*/
protected function getNonAggregates() {
- $non_aggregates = array();
+ $non_aggregates = [];
foreach ($this->fields as $field) {
$string = '';
if (!empty($field['table'])) {
@@ -1167,9 +1167,9 @@ class Sql extends QueryPluginBase {
if (!empty($field['function'])) {
$info = $this->getAggregationInfo();
- if (!empty($info[$field['function']]['method']) && is_callable(array($this, $info[$field['function']]['method']))) {
+ if (!empty($info[$field['function']]['method']) && is_callable([$this, $info[$field['function']]['method']])) {
$string = $this::{$info[$field['function']]['method']}($field['function'], $string);
- $placeholders = !empty($field['placeholders']) ? $field['placeholders'] : array();
+ $placeholders = !empty($field['placeholders']) ? $field['placeholders'] : [];
$query->addExpression($string, $fieldname, $placeholders);
}
@@ -1177,7 +1177,7 @@ class Sql extends QueryPluginBase {
}
// This is a formula, using no tables.
elseif (empty($field['table'])) {
- $placeholders = !empty($field['placeholders']) ? $field['placeholders'] : array();
+ $placeholders = !empty($field['placeholders']) ? $field['placeholders'] : [];
$query->addExpression($string, $fieldname, $placeholders);
}
elseif ($this->distinct && !in_array($fieldname, $this->groupby)) {
@@ -1228,7 +1228,7 @@ class Sql extends QueryPluginBase {
$this->getCountOptimized = TRUE;
}
- $options = array();
+ $options = [];
$target = 'default';
$key = 'default';
// Detect an external database and set the
@@ -1274,7 +1274,7 @@ class Sql extends QueryPluginBase {
// Allow 'GROUP BY' even no aggregation function has been set.
$this->hasAggregate = $this->view->display_handler->getOption('group_by');
}
- $groupby = array();
+ $groupby = [];
if ($this->hasAggregate && (!empty($this->groupby) || !empty($non_aggregates))) {
$groupby = array_unique(array_merge($this->groupby, $non_aggregates));
}
@@ -1283,12 +1283,12 @@ class Sql extends QueryPluginBase {
// entities can be loaded.
$entity_information = $this->getEntityTableInfo();
if ($entity_information) {
- $params = array();
+ $params = [];
if ($groupby) {
// Handle grouping, by retrieving the minimum entity_id.
- $params = array(
+ $params = [
'function' => 'min',
- );
+ ];
}
foreach ($entity_information as $entity_type_id => $info) {
@@ -1347,7 +1347,7 @@ class Sql extends QueryPluginBase {
}
// Add all query substitutions as metadata.
- $query->addMetaData('views_substitutions', \Drupal::moduleHandler()->invokeAll('views_query_substitutions', array($this->view)));
+ $query->addMetaData('views_substitutions', \Drupal::moduleHandler()->invokeAll('views_query_substitutions', [$this->view]));
return $query;
}
@@ -1356,7 +1356,7 @@ class Sql extends QueryPluginBase {
* Get the arguments attached to the WHERE and HAVING clauses of this query.
*/
public function getWhereArgs() {
- $args = array();
+ $args = [];
foreach ($this->where as $where) {
$args = array_merge($args, $where['args']);
}
@@ -1370,7 +1370,7 @@ class Sql extends QueryPluginBase {
* Let modules modify the query just prior to finalizing it.
*/
public function alter(ViewExecutable $view) {
- \Drupal::moduleHandler()->invokeAll('views_query_alter', array($view, $this));
+ \Drupal::moduleHandler()->invokeAll('views_query_alter', [$view, $this]);
}
/**
@@ -1425,7 +1425,7 @@ class Sql extends QueryPluginBase {
}
if ($query) {
- $additional_arguments = \Drupal::moduleHandler()->invokeAll('views_query_substitutions', array($view));
+ $additional_arguments = \Drupal::moduleHandler()->invokeAll('views_query_substitutions', [$view]);
// Count queries must be run through the preExecute() method.
// If not, then hook_query_node_access_alter() may munge the count by
@@ -1481,7 +1481,7 @@ class Sql extends QueryPluginBase {
$this->loadEntities($view->result);
}
catch (DatabaseExceptionWrapper $e) {
- $view->result = array();
+ $view->result = [];
if (!empty($view->live_preview)) {
drupal_set_message($e->getMessage(), 'error');
}
@@ -1515,7 +1515,7 @@ class Sql extends QueryPluginBase {
}
// Extract all entity types from entity_information.
- $entity_types = array();
+ $entity_types = [];
foreach ($entity_information as $info) {
$entity_type = $info['entity_type'];
if (!isset($entity_types[$entity_type])) {
@@ -1665,82 +1665,82 @@ class Sql extends QueryPluginBase {
public function getAggregationInfo() {
// @todo -- need a way to get database specific and customized aggregation
// functions into here.
- return array(
- 'group' => array(
+ return [
+ 'group' => [
'title' => $this->t('Group results together'),
'is aggregate' => FALSE,
- ),
- 'count' => array(
+ ],
+ 'count' => [
'title' => $this->t('Count'),
'method' => 'aggregationMethodSimple',
- 'handler' => array(
+ 'handler' => [
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
- ),
- ),
- 'count_distinct' => array(
+ ],
+ ],
+ 'count_distinct' => [
'title' => $this->t('Count DISTINCT'),
'method' => 'aggregationMethodDistinct',
- 'handler' => array(
+ 'handler' => [
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
- ),
- ),
- 'sum' => array(
+ ],
+ ],
+ 'sum' => [
'title' => $this->t('Sum'),
'method' => 'aggregationMethodSimple',
- 'handler' => array(
+ 'handler' => [
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
- ),
- ),
- 'avg' => array(
+ ],
+ ],
+ 'avg' => [
'title' => $this->t('Average'),
'method' => 'aggregationMethodSimple',
- 'handler' => array(
+ 'handler' => [
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
- ),
- ),
- 'min' => array(
+ ],
+ ],
+ 'min' => [
'title' => $this->t('Minimum'),
'method' => 'aggregationMethodSimple',
- 'handler' => array(
+ 'handler' => [
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
- ),
- ),
- 'max' => array(
+ ],
+ ],
+ 'max' => [
'title' => $this->t('Maximum'),
'method' => 'aggregationMethodSimple',
- 'handler' => array(
+ 'handler' => [
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
- ),
- ),
- 'stddev_pop' => array(
+ ],
+ ],
+ 'stddev_pop' => [
'title' => $this->t('Standard deviation'),
'method' => 'aggregationMethodSimple',
- 'handler' => array(
+ 'handler' => [
'argument' => 'groupby_numeric',
'field' => 'numeric',
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
- ),
- )
- );
+ ],
+ ]
+ ];
}
public function aggregationMethodSimple($group_type, $field) {
@@ -1795,7 +1795,7 @@ class Sql extends QueryPluginBase {
// set up the database timezone
$db_type = Database::getConnection()->databaseType();
- if (in_array($db_type, array('mysql', 'pgsql'))) {
+ if (in_array($db_type, ['mysql', 'pgsql'])) {
$offset = '+00:00';
static $already_set = FALSE;
if (!$already_set) {
@@ -1820,7 +1820,7 @@ class Sql extends QueryPluginBase {
$db_type = Database::getConnection()->databaseType();
switch ($db_type) {
case 'mysql':
- $replace = array(
+ $replace = [
'Y' => '%Y',
'y' => '%y',
'M' => '%b',
@@ -1837,11 +1837,11 @@ class Sql extends QueryPluginBase {
'i' => '%i',
's' => '%s',
'A' => '%p',
- );
+ ];
$format = strtr($format, $replace);
return "DATE_FORMAT($field, '$format')";
case 'pgsql':
- $replace = array(
+ $replace = [
'Y' => 'YYYY',
'y' => 'YY',
'M' => 'Mon',
@@ -1861,7 +1861,7 @@ class Sql extends QueryPluginBase {
'i' => 'MI',
's' => 'SS',
'A' => 'AM',
- );
+ ];
$format = strtr($format, $replace);
if (!$string_date) {
return "TO_CHAR($field, '$format')";
@@ -1870,7 +1870,7 @@ class Sql extends QueryPluginBase {
// date, back to a string again.
return "TO_CHAR(TO_TIMESTAMP($field, 'YYYY-MM-DD HH24:MI:SS'), '$format')";
case 'sqlite':
- $replace = array(
+ $replace = [
'Y' => '%Y',
// No format for 2 digit year number.
'y' => '%Y',
@@ -1896,7 +1896,7 @@ class Sql extends QueryPluginBase {
's' => '%S',
// No format for AM/PM.
'A' => '',
- );
+ ];
$format = strtr($format, $replace);
// Don't use the 'unixepoch' flag for string date comparisons.
diff --git a/core/modules/views/src/Plugin/views/relationship/EntityReverse.php b/core/modules/views/src/Plugin/views/relationship/EntityReverse.php
index 42d6fa1e744..7c016046049 100644
--- a/core/modules/views/src/Plugin/views/relationship/EntityReverse.php
+++ b/core/modules/views/src/Plugin/views/relationship/EntityReverse.php
@@ -48,13 +48,13 @@ class EntityReverse extends RelationshipPluginBase {
$views_data = Views::viewsData()->get($this->table);
$left_field = $views_data['table']['base']['field'];
- $first = array(
+ $first = [
'left_table' => $this->tableAlias,
'left_field' => $left_field,
'table' => $this->definition['field table'],
'field' => $this->definition['field field'],
'adjusted' => TRUE
- );
+ ];
if (!empty($this->options['required'])) {
$first['type'] = 'INNER';
}
@@ -76,13 +76,13 @@ class EntityReverse extends RelationshipPluginBase {
// Second, relate the field table to the entity specified using
// the entity id on the field table and the entity's id field.
- $second = array(
+ $second = [
'left_table' => $this->first_alias,
'left_field' => 'entity_id',
'table' => $this->definition['base'],
'field' => $this->definition['base field'],
'adjusted' => TRUE
- );
+ ];
if (!empty($this->options['required'])) {
$second['type'] = 'INNER';
diff --git a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
index dc23a6872e6..1db8da7f72c 100644
--- a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
+++ b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
@@ -65,12 +65,12 @@ class GroupwiseMax extends RelationshipPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['subquery_sort'] = array('default' => NULL);
+ $options['subquery_sort'] = ['default' => NULL];
// Descending more useful.
- $options['subquery_order'] = array('default' => 'DESC');
- $options['subquery_regenerate'] = array('default' => FALSE);
- $options['subquery_view'] = array('default' => FALSE);
- $options['subquery_namespace'] = array('default' => FALSE);
+ $options['subquery_order'] = ['default' => 'DESC'];
+ $options['subquery_regenerate'] = ['default' => FALSE];
+ $options['subquery_view'] = ['default' => FALSE];
+ $options['subquery_namespace'] = ['default' => FALSE];
return $options;
}
@@ -83,7 +83,7 @@ class GroupwiseMax extends RelationshipPluginBase {
// Get the sorts that apply to our base.
$sorts = Views::viewsDataHelper()->fetchFields($this->definition['base'], 'sort');
- $sort_options = array();
+ $sort_options = [];
foreach ($sorts as $sort_id => $sort) {
$sort_options[$sort_id] = "$sort[group]: $sort[title]";
}
@@ -91,34 +91,34 @@ class GroupwiseMax extends RelationshipPluginBase {
// Extends the relationship's basic options, allowing the user to pick a
// sort and an order for it.
- $form['subquery_sort'] = array(
+ $form['subquery_sort'] = [
'#type' => 'select',
'#title' => $this->t('Representative sort criteria'),
// Provide the base field as sane default sort option.
'#default_value' => !empty($this->options['subquery_sort']) ? $this->options['subquery_sort'] : $this->definition['base'] . '.' . $base_table_data['table']['base']['field'],
'#options' => $sort_options,
'#description' => $this->t("The sort criteria is applied to the data brought in by the relationship to determine how a representative item is obtained for each row. For example, to show the most recent node for each user, pick 'Content: Updated date'."),
- );
+ ];
- $form['subquery_order'] = array(
+ $form['subquery_order'] = [
'#type' => 'radios',
'#title' => $this->t('Representative sort order'),
'#description' => $this->t("The ordering to use for the sort criteria selected above."),
- '#options' => array('ASC' => $this->t('Ascending'), 'DESC' => $this->t('Descending')),
+ '#options' => ['ASC' => $this->t('Ascending'), 'DESC' => $this->t('Descending')],
'#default_value' => $this->options['subquery_order'],
- );
+ ];
- $form['subquery_namespace'] = array(
+ $form['subquery_namespace'] = [
'#type' => 'textfield',
'#title' => $this->t('Subquery namespace'),
'#description' => $this->t('Advanced. Enter a namespace for the subquery used by this relationship.'),
'#default_value' => $this->options['subquery_namespace'],
- );
+ ];
// WIP: This stuff doesn't work yet: namespacing issues.
// A list of suitable views to pick one as the subview.
- $views = array('' => '- None -');
+ $views = ['' => '- None -'];
foreach (Views::getAllViews() as $view) {
// Only get views that are suitable:
// - base must the base that our relationship joins towards
@@ -130,20 +130,20 @@ class GroupwiseMax extends RelationshipPluginBase {
}
}
- $form['subquery_view'] = array(
+ $form['subquery_view'] = [
'#type' => 'select',
'#title' => $this->t('Representative view'),
'#default_value' => $this->options['subquery_view'],
'#options' => $views,
'#description' => $this->t('Advanced. Use another view to generate the relationship subquery. This allows you to use filtering and more than one sort. If you pick a view here, the sort options above are ignored. Your view must have the ID of its base as its only field, and should have some kind of sorting.'),
- );
+ ];
- $form['subquery_regenerate'] = array(
+ $form['subquery_regenerate'] = [
'#type' => 'checkbox',
'#title' => $this->t('Generate subquery each time view is run'),
'#default_value' => $this->options['subquery_regenerate'],
'#description' => $this->t('Will re-generate the subquery for this relationship every time the view is run, instead of only when these options are saved. Use for testing if you are making changes elsewhere. WARNING: seriously impairs performance.'),
- );
+ ];
}
/**
@@ -152,7 +152,7 @@ class GroupwiseMax extends RelationshipPluginBase {
* We use this to obtain our subquery SQL.
*/
protected function getTemporaryView() {
- $view = View::create(array('base_table' => $this->definition['base']));
+ $view = View::create(['base_table' => $this->definition['base']]);
$view->addDisplay('default');
return $view->getExecutable();
}
@@ -198,7 +198,7 @@ class GroupwiseMax extends RelationshipPluginBase {
// We work around this further down.
$sort = $options['subquery_sort'];
list($sort_table, $sort_field) = explode('.', $sort);
- $sort_options = array('order' => $options['subquery_order']);
+ $sort_options = ['order' => $options['subquery_order']];
$temp_view->addHandler('default', 'sort', $sort_table, $sort_field, $sort_options);
}
@@ -219,7 +219,7 @@ class GroupwiseMax extends RelationshipPluginBase {
list($relationship_table, $relationship_field) = explode(':', $this->definition['relationship']);
$relationship_id = $temp_view->addHandler('default', 'relationship', $relationship_table, $relationship_field);
}
- $temp_item_options = array('relationship' => $relationship_id);
+ $temp_item_options = ['relationship' => $relationship_id];
// Add the correct argument for our relationship's base
// ie the 'how to get back to base' argument.
diff --git a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php
index 25a0001e791..860189175c5 100644
--- a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php
+++ b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php
@@ -99,7 +99,7 @@ abstract class RelationshipPluginBase extends HandlerBase {
}
$options['admin_label']['default'] = $label;
- $options['required'] = array('default' => FALSE);
+ $options['required'] = ['default' => FALSE];
return $options;
}
@@ -113,12 +113,12 @@ abstract class RelationshipPluginBase extends HandlerBase {
unset($form['admin_label']['#fieldset']);
$form['admin_label']['#weight'] = -1;
- $form['required'] = array(
+ $form['required'] = [
'#type' => 'checkbox',
'#title' => $this->t('Require this relationship'),
'#description' => $this->t('Enable to hide items that do not contain this relationship'),
'#default_value' => !empty($this->options['required']),
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/row/EntityReference.php b/core/modules/views/src/Plugin/views/row/EntityReference.php
index 4ca79ba42f3..a985ee366d5 100644
--- a/core/modules/views/src/Plugin/views/row/EntityReference.php
+++ b/core/modules/views/src/Plugin/views/row/EntityReference.php
@@ -25,7 +25,7 @@ class EntityReference extends Fields {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['separator'] = array('default' => '-');
+ $options['separator'] = ['default' => '-'];
return $options;
}
diff --git a/core/modules/views/src/Plugin/views/row/EntityRow.php b/core/modules/views/src/Plugin/views/row/EntityRow.php
index f5365296531..e98133af72f 100644
--- a/core/modules/views/src/Plugin/views/row/EntityRow.php
+++ b/core/modules/views/src/Plugin/views/row/EntityRow.php
@@ -130,7 +130,7 @@ class EntityRow extends RowPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['view_mode'] = array('default' => 'default');
+ $options['view_mode'] = ['default' => 'default'];
return $options;
}
@@ -140,12 +140,12 @@ class EntityRow extends RowPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['view_mode'] = array(
+ $form['view_mode'] = [
'#type' => 'select',
'#options' => \Drupal::entityManager()->getViewModeOptions($this->entityTypeId),
'#title' => $this->t('View mode'),
'#default_value' => $this->options['view_mode'],
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/row/Fields.php b/core/modules/views/src/Plugin/views/row/Fields.php
index 3904b0c050b..711704eab2c 100644
--- a/core/modules/views/src/Plugin/views/row/Fields.php
+++ b/core/modules/views/src/Plugin/views/row/Fields.php
@@ -32,10 +32,10 @@ class Fields extends RowPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['inline'] = array('default' => array());
- $options['separator'] = array('default' => '');
- $options['hide_empty'] = array('default' => FALSE);
- $options['default_field_elements'] = array('default' => TRUE);
+ $options['inline'] = ['default' => []];
+ $options['separator'] = ['default' => ''];
+ $options['hide_empty'] = ['default' => FALSE];
+ $options['default_field_elements'] = ['default' => TRUE];
return $options;
}
@@ -47,48 +47,48 @@ class Fields extends RowPluginBase {
$options = $this->displayHandler->getFieldLabels();
if (empty($this->options['inline'])) {
- $this->options['inline'] = array();
+ $this->options['inline'] = [];
}
- $form['default_field_elements'] = array(
+ $form['default_field_elements'] = [
'#type' => 'checkbox',
'#title' => $this->t('Provide default field wrapper elements'),
'#default_value' => $this->options['default_field_elements'],
'#description' => $this->t('If not checked, fields that are not configured to customize their HTML elements will get no wrappers at all for their field, label and field + label wrappers. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'),
- );
+ ];
- $form['inline'] = array(
+ $form['inline'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Inline fields'),
'#options' => $options,
'#default_value' => $this->options['inline'],
'#description' => $this->t('Inline fields will be displayed next to each other rather than one after another. Note that some fields will ignore this if they are block elements, particularly body fields and other formatted HTML.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="row_options[default_field_elements]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="row_options[default_field_elements]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
- $form['separator'] = array(
+ $form['separator'] = [
'#title' => $this->t('Separator'),
'#type' => 'textfield',
'#size' => 10,
'#default_value' => isset($this->options['separator']) ? $this->options['separator'] : '',
'#description' => $this->t('The separator may be placed between inline fields to keep them from squishing up next to each other. You can use HTML in this field.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="row_options[default_field_elements]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="row_options[default_field_elements]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
- $form['hide_empty'] = array(
+ $form['hide_empty'] = [
'#type' => 'checkbox',
'#title' => $this->t('Hide empty fields'),
'#default_value' => $this->options['hide_empty'],
'#description' => $this->t('Do not display fields, labels or markup for fields that are empty.'),
- );
+ ];
}
@@ -97,8 +97,8 @@ class Fields extends RowPluginBase {
* There is no need for this function to actually store the data.
*/
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
- $inline = $form_state->getValue(array('row_options', 'inline'));
- $form_state->setValue(array('row_options', 'inline'), array_filter($inline));
+ $inline = $form_state->getValue(['row_options', 'inline']);
+ $form_state->setValue(['row_options', 'inline'], array_filter($inline));
}
}
diff --git a/core/modules/views/src/Plugin/views/row/OpmlFields.php b/core/modules/views/src/Plugin/views/row/OpmlFields.php
index 0c8f684bf28..aaeecbf69a1 100644
--- a/core/modules/views/src/Plugin/views/row/OpmlFields.php
+++ b/core/modules/views/src/Plugin/views/row/OpmlFields.php
@@ -29,14 +29,14 @@ class OpmlFields extends RowPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['text_field'] = array('default' => '');
- $options['created_field'] = array('default' => '');
- $options['type_field'] = array('default' => '');
- $options['description_field'] = array('default' => '');
- $options['html_url_field'] = array('default' => '');
- $options['language_field'] = array('default' => '');
- $options['xml_url_field'] = array('default' => '');
- $options['url_field'] = array('default' => '');
+ $options['text_field'] = ['default' => ''];
+ $options['created_field'] = ['default' => ''];
+ $options['type_field'] = ['default' => ''];
+ $options['description_field'] = ['default' => ''];
+ $options['html_url_field'] = ['default' => ''];
+ $options['language_field'] = ['default' => ''];
+ $options['xml_url_field'] = ['default' => ''];
+ $options['url_field'] = ['default' => ''];
return $options;
}
@@ -46,101 +46,101 @@ class OpmlFields extends RowPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $initial_labels = array('' => $this->t('- None -'));
+ $initial_labels = ['' => $this->t('- None -')];
$view_fields_labels = $this->displayHandler->getFieldLabels();
$view_fields_labels = array_merge($initial_labels, $view_fields_labels);
- $types = array(
+ $types = [
'rss' => $this->t('RSS'),
'link' => $this->t('Link'),
'include' => $this->t('Include'),
- );
+ ];
$types = array_merge($initial_labels, $types);
- $form['type_field'] = array(
+ $form['type_field'] = [
'#type' => 'select',
'#title' => $this->t('Type attribute'),
'#description' => $this->t('The type of this row.'),
'#options' => $types,
'#default_value' => $this->options['type_field'],
- );
- $form['text_field'] = array(
+ ];
+ $form['text_field'] = [
'#type' => 'select',
'#title' => $this->t('Text attribute'),
'#description' => $this->t('The field that is going to be used as the OPML text attribute for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['text_field'],
'#required' => TRUE,
- );
- $form['created_field'] = array(
+ ];
+ $form['created_field'] = [
'#type' => 'select',
'#title' => $this->t('Created attribute'),
'#description' => $this->t('The field that is going to be used as the OPML created attribute for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['created_field'],
- );
- $form['description_field'] = array(
+ ];
+ $form['description_field'] = [
'#type' => 'select',
'#title' => $this->t('Description attribute'),
'#description' => $this->t('The field that is going to be used as the OPML description attribute for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['description_field'],
- '#states' => array(
- 'visible' => array(
- ':input[name="row_options[type_field]"]' => array('value' => 'rss'),
- ),
- ),
- );
- $form['html_url_field'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="row_options[type_field]"]' => ['value' => 'rss'],
+ ],
+ ],
+ ];
+ $form['html_url_field'] = [
'#type' => 'select',
'#title' => $this->t('HTML URL attribute'),
'#description' => $this->t('The field that is going to be used as the OPML htmlUrl attribute for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['html_url_field'],
- '#states' => array(
- 'visible' => array(
- ':input[name="row_options[type_field]"]' => array('value' => 'rss'),
- ),
- ),
- );
- $form['language_field'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="row_options[type_field]"]' => ['value' => 'rss'],
+ ],
+ ],
+ ];
+ $form['language_field'] = [
'#type' => 'select',
'#title' => $this->t('Language attribute'),
'#description' => $this->t('The field that is going to be used as the OPML language attribute for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['language_field'],
- '#states' => array(
- 'visible' => array(
- ':input[name="row_options[type_field]"]' => array('value' => 'rss'),
- ),
- ),
- );
- $form['xml_url_field'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="row_options[type_field]"]' => ['value' => 'rss'],
+ ],
+ ],
+ ];
+ $form['xml_url_field'] = [
'#type' => 'select',
'#title' => $this->t('XML URL attribute'),
'#description' => $this->t('The field that is going to be used as the OPML text attribute for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['xml_url_field'],
- '#states' => array(
- 'visible' => array(
- ':input[name="row_options[type_field]"]' => array('value' => 'rss'),
- ),
- ),
- );
- $form['url_field'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="row_options[type_field]"]' => ['value' => 'rss'],
+ ],
+ ],
+ ];
+ $form['url_field'] = [
'#type' => 'select',
'#title' => $this->t('URL attribute'),
'#description' => $this->t('The field that is going to be used as the OPML URL attribute for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['url_field'],
- '#states' => array(
- 'visible' => array(
- ':input[name="row_options[type_field]"]' => array(
- array('value' => 'link'),
- array('value' => 'include'),
- ),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="row_options[type_field]"]' => [
+ ['value' => 'link'],
+ ['value' => 'include'],
+ ],
+ ],
+ ],
+ ];
}
/**
@@ -157,7 +157,7 @@ class OpmlFields extends RowPluginBase {
$errors[] = $this->t('Row style plugin requires specifying which views field to use for XML URL attribute.');
}
}
- elseif (in_array($this->options['type_field'], array('link', 'include'))) {
+ elseif (in_array($this->options['type_field'], ['link', 'include'])) {
if (empty($this->options['url_field'])) {
$errors[] = $this->t('Row style plugin requires specifying which views field to use for URL attribute.');
}
@@ -171,7 +171,7 @@ class OpmlFields extends RowPluginBase {
*/
public function render($row) {
// Create the OPML item array.
- $item = array();
+ $item = [];
$row_index = $this->view->row_index;
$item['text'] = $this->getField($row_index, $this->options['text_field']);
$item['created'] = $this->getField($row_index, $this->options['created_field']);
@@ -190,13 +190,13 @@ class OpmlFields extends RowPluginBase {
// Remove empty attributes.
$item = array_filter($item);
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $item,
'#field_alias' => isset($this->field_alias) ? $this->field_alias : '',
- );
+ ];
return $build;
}
diff --git a/core/modules/views/src/Plugin/views/row/RowPluginBase.php b/core/modules/views/src/Plugin/views/row/RowPluginBase.php
index d1e090e0aac..fd2b96c3226 100644
--- a/core/modules/views/src/Plugin/views/row/RowPluginBase.php
+++ b/core/modules/views/src/Plugin/views/row/RowPluginBase.php
@@ -64,7 +64,7 @@ abstract class RowPluginBase extends PluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
if (isset($this->base_table)) {
- $options['relationship'] = array('default' => 'none');
+ $options['relationship'] = ['default' => 'none'];
}
return $options;
@@ -81,7 +81,7 @@ abstract class RowPluginBase extends PluginBase {
// A whole bunch of code to figure out what relationships are valid for
// this item.
$relationships = $executable->display_handler->getOption('relationships');
- $relationship_options = array();
+ $relationship_options = [];
foreach ($relationships as $relationship) {
$relationship_handler = Views::handlerManager('relationship')->getHandler($relationship);
@@ -96,25 +96,25 @@ abstract class RowPluginBase extends PluginBase {
}
if (!empty($relationship_options)) {
- $relationship_options = array_merge(array('none' => $this->t('Do not use a relationship')), $relationship_options);
+ $relationship_options = array_merge(['none' => $this->t('Do not use a relationship')], $relationship_options);
$rel = empty($this->options['relationship']) ? 'none' : $this->options['relationship'];
if (empty($relationship_options[$rel])) {
// Pick the first relationship.
$rel = key($relationship_options);
}
- $form['relationship'] = array(
+ $form['relationship'] = [
'#type' => 'select',
'#title' => $this->t('Relationship'),
'#options' => $relationship_options,
'#default_value' => $rel,
- );
+ ];
}
else {
- $form['relationship'] = array(
+ $form['relationship'] = [
'#type' => 'value',
'#value' => 'none',
- );
+ ];
}
}
}
@@ -164,13 +164,13 @@ abstract class RowPluginBase extends PluginBase {
* The rendered output of a single row, used by the style plugin.
*/
public function render($row) {
- return array(
+ return [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $row,
'#field_alias' => isset($this->field_alias) ? $this->field_alias : '',
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/row/RssFields.php b/core/modules/views/src/Plugin/views/row/RssFields.php
index a420bb7f997..1b56aae5f18 100644
--- a/core/modules/views/src/Plugin/views/row/RssFields.php
+++ b/core/modules/views/src/Plugin/views/row/RssFields.php
@@ -27,87 +27,87 @@ class RssFields extends RowPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['title_field'] = array('default' => '');
- $options['link_field'] = array('default' => '');
- $options['description_field'] = array('default' => '');
- $options['creator_field'] = array('default' => '');
- $options['date_field'] = array('default' => '');
- $options['guid_field_options']['contains']['guid_field'] = array('default' => '');
- $options['guid_field_options']['contains']['guid_field_is_permalink'] = array('default' => TRUE);
+ $options['title_field'] = ['default' => ''];
+ $options['link_field'] = ['default' => ''];
+ $options['description_field'] = ['default' => ''];
+ $options['creator_field'] = ['default' => ''];
+ $options['date_field'] = ['default' => ''];
+ $options['guid_field_options']['contains']['guid_field'] = ['default' => ''];
+ $options['guid_field_options']['contains']['guid_field_is_permalink'] = ['default' => TRUE];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $initial_labels = array('' => $this->t('- None -'));
+ $initial_labels = ['' => $this->t('- None -')];
$view_fields_labels = $this->displayHandler->getFieldLabels();
$view_fields_labels = array_merge($initial_labels, $view_fields_labels);
- $form['title_field'] = array(
+ $form['title_field'] = [
'#type' => 'select',
'#title' => $this->t('Title field'),
'#description' => $this->t('The field that is going to be used as the RSS item title for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['title_field'],
'#required' => TRUE,
- );
- $form['link_field'] = array(
+ ];
+ $form['link_field'] = [
'#type' => 'select',
'#title' => $this->t('Link field'),
'#description' => $this->t('The field that is going to be used as the RSS item link for each row. This must be a drupal relative path.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['link_field'],
'#required' => TRUE,
- );
- $form['description_field'] = array(
+ ];
+ $form['description_field'] = [
'#type' => 'select',
'#title' => $this->t('Description field'),
'#description' => $this->t('The field that is going to be used as the RSS item description for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['description_field'],
'#required' => TRUE,
- );
- $form['creator_field'] = array(
+ ];
+ $form['creator_field'] = [
'#type' => 'select',
'#title' => $this->t('Creator field'),
'#description' => $this->t('The field that is going to be used as the RSS item creator for each row.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['creator_field'],
'#required' => TRUE,
- );
- $form['date_field'] = array(
+ ];
+ $form['date_field'] = [
'#type' => 'select',
'#title' => $this->t('Publication date field'),
'#description' => $this->t('The field that is going to be used as the RSS item pubDate for each row. It needs to be in RFC 2822 format.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['date_field'],
'#required' => TRUE,
- );
- $form['guid_field_options'] = array(
+ ];
+ $form['guid_field_options'] = [
'#type' => 'details',
'#title' => $this->t('GUID settings'),
'#open' => TRUE,
- );
- $form['guid_field_options']['guid_field'] = array(
+ ];
+ $form['guid_field_options']['guid_field'] = [
'#type' => 'select',
'#title' => $this->t('GUID field'),
'#description' => $this->t('The globally unique identifier of the RSS item.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['guid_field_options']['guid_field'],
'#required' => TRUE,
- );
- $form['guid_field_options']['guid_field_is_permalink'] = array(
+ ];
+ $form['guid_field_options']['guid_field_is_permalink'] = [
'#type' => 'checkbox',
'#title' => $this->t('GUID is permalink'),
'#description' => $this->t('The RSS item GUID is a permalink.'),
'#default_value' => $this->options['guid_field_options']['guid_field_is_permalink'],
- );
+ ];
}
public function validate() {
$errors = parent::validate();
- $required_options = array('title_field', 'link_field', 'description_field', 'creator_field', 'date_field');
+ $required_options = ['title_field', 'link_field', 'description_field', 'creator_field', 'date_field'];
foreach ($required_options as $required_option) {
if (empty($this->options[$required_option])) {
$errors[] = $this->t('Row style plugin requires specifying which views fields to use for RSS item.');
@@ -129,7 +129,7 @@ class RssFields extends RowPluginBase {
if (function_exists('rdf_get_namespaces')) {
// Merge RDF namespaces in the XML namespaces in case they are used
// further in the RSS content.
- $xml_rdf_namespaces = array();
+ $xml_rdf_namespaces = [];
foreach (rdf_get_namespaces() as $prefix => $uri) {
$xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
}
@@ -146,14 +146,14 @@ class RssFields extends RowPluginBase {
$field = $this->getField($row_index, $this->options['description_field']);
$item->description = is_array($field) ? $field : ['#markup' => $field];
- $item->elements = array(
- array('key' => 'pubDate', 'value' => $this->getField($row_index, $this->options['date_field'])),
- array(
+ $item->elements = [
+ ['key' => 'pubDate', 'value' => $this->getField($row_index, $this->options['date_field'])],
+ [
'key' => 'dc:creator',
'value' => $this->getField($row_index, $this->options['creator_field']),
- 'namespace' => array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/'),
- ),
- );
+ 'namespace' => ['xmlns:dc' => 'http://purl.org/dc/elements/1.1/'],
+ ],
+ ];
$guid_is_permalink_string = 'false';
$item_guid = $this->getField($row_index, $this->options['guid_field_options']['guid_field']);
if ($this->options['guid_field_options']['guid_field_is_permalink']) {
@@ -162,11 +162,11 @@ class RssFields extends RowPluginBase {
// https://www.drupal.org/node/2430589.
$item_guid = Url::fromUserInput('/' . $item_guid)->setAbsolute()->toString();
}
- $item->elements[] = array(
+ $item->elements[] = [
'key' => 'guid',
'value' => $item_guid,
- 'attributes' => array('isPermaLink' => $guid_is_permalink_string),
- );
+ 'attributes' => ['isPermaLink' => $guid_is_permalink_string],
+ ];
$row_index++;
@@ -176,13 +176,13 @@ class RssFields extends RowPluginBase {
}
}
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $item,
'#field_alias' => isset($this->field_alias) ? $this->field_alias : '',
- );
+ ];
return $build;
}
diff --git a/core/modules/views/src/Plugin/views/row/RssPluginBase.php b/core/modules/views/src/Plugin/views/row/RssPluginBase.php
index b5fd385bdc3..b8c518bc9e5 100644
--- a/core/modules/views/src/Plugin/views/row/RssPluginBase.php
+++ b/core/modules/views/src/Plugin/views/row/RssPluginBase.php
@@ -61,7 +61,7 @@ abstract class RssPluginBase extends RowPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['view_mode'] = array('default' => 'default');
+ $options['view_mode'] = ['default' => 'default'];
return $options;
}
@@ -72,12 +72,12 @@ abstract class RssPluginBase extends RowPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['view_mode'] = array(
+ $form['view_mode'] = [
'#type' => 'select',
'#title' => $this->t('Display type'),
'#options' => $this->buildOptionsForm_summary_options(),
'#default_value' => $this->options['view_mode'],
- );
+ ];
}
/**
@@ -85,7 +85,7 @@ abstract class RssPluginBase extends RowPluginBase {
*/
public function buildOptionsForm_summary_options() {
$view_modes = $this->entityManager->getViewModes($this->entityTypeId);
- $options = array();
+ $options = [];
foreach ($view_modes as $mode => $settings) {
$options[$mode] = $settings['label'];
}
diff --git a/core/modules/views/src/Plugin/views/sort/Date.php b/core/modules/views/src/Plugin/views/sort/Date.php
index 4017e2b4c98..0c7d9e14fc5 100644
--- a/core/modules/views/src/Plugin/views/sort/Date.php
+++ b/core/modules/views/src/Plugin/views/sort/Date.php
@@ -17,7 +17,7 @@ class Date extends SortPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['granularity'] = array('default' => 'second');
+ $options['granularity'] = ['default' => 'second'];
return $options;
}
@@ -25,20 +25,20 @@ class Date extends SortPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['granularity'] = array(
+ $form['granularity'] = [
'#type' => 'radios',
'#title' => $this->t('Granularity'),
- '#options' => array(
+ '#options' => [
'second' => $this->t('Second'),
'minute' => $this->t('Minute'),
'hour' => $this->t('Hour'),
'day' => $this->t('Day'),
'month' => $this->t('Month'),
'year' => $this->t('Year'),
- ),
+ ],
'#description' => $this->t('The granularity is the smallest unit to use when determining whether two dates are the same; for example, if the granularity is "Year" then all dates in 1999, regardless of when they fall in 1999, will be considered the same date.'),
'#default_value' => $this->options['granularity'],
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/sort/GroupByNumeric.php b/core/modules/views/src/Plugin/views/sort/GroupByNumeric.php
index b7245ddc69c..5308439e66c 100644
--- a/core/modules/views/src/Plugin/views/sort/GroupByNumeric.php
+++ b/core/modules/views/src/Plugin/views/sort/GroupByNumeric.php
@@ -30,9 +30,9 @@ class GroupByNumeric extends SortPluginBase {
public function query() {
$this->ensureMyTable();
- $params = array(
+ $params = [
'function' => $this->options['group_type'],
- );
+ ];
$this->query->addOrderBy($this->tableAlias, $this->realField, $this->options['order'], NULL, $params);
}
diff --git a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php
index 97122b1507d..a40dc346b3a 100644
--- a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php
+++ b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php
@@ -42,13 +42,13 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
protected function defineOptions() {
$options = parent::defineOptions();
- $options['order'] = array('default' => 'ASC');
- $options['exposed'] = array('default' => FALSE);
- $options['expose'] = array(
- 'contains' => array(
- 'label' => array('default' => ''),
- ),
- );
+ $options['order'] = ['default' => 'ASC'];
+ $options['exposed'] = ['default' => FALSE];
+ $options['expose'] = [
+ 'contains' => [
+ 'label' => ['default' => ''],
+ ],
+ ];
return $options;
}
@@ -79,9 +79,9 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
if ($this->canExpose()) {
$this->showExposeButton($form, $form_state);
}
- $form['op_val_start'] = array('#value' => '<div class="clearfix">');
+ $form['op_val_start'] = ['#value' => '<div class="clearfix">'];
$this->showSortForm($form, $form_state);
- $form['op_val_end'] = array('#value' => '</div>');
+ $form['op_val_end'] = ['#value' => '</div>'];
if ($this->canExpose()) {
$this->showExposeForm($form, $form_state);
}
@@ -91,47 +91,47 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
* Shortcut to display the expose/hide button.
*/
public function showExposeButton(&$form, FormStateInterface $form_state) {
- $form['expose_button'] = array(
+ $form['expose_button'] = [
'#prefix' => '<div class="views-expose clearfix">',
'#suffix' => '</div>',
// Should always come first
'#weight' => -1000,
- );
+ ];
// Add a checkbox for JS users, which will have behavior attached to it
// so it can replace the button.
- $form['expose_button']['checkbox'] = array(
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('js-only')),
- );
- $form['expose_button']['checkbox']['checkbox'] = array(
+ $form['expose_button']['checkbox'] = [
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['js-only']],
+ ];
+ $form['expose_button']['checkbox']['checkbox'] = [
'#title' => $this->t('Expose this sort to visitors, to allow them to change it'),
'#type' => 'checkbox',
- );
+ ];
// Then add the button itself.
if (empty($this->options['exposed'])) {
- $form['expose_button']['markup'] = array(
+ $form['expose_button']['markup'] = [
'#markup' => '<div class="description exposed-description" style="float: left; margin-right:10px">' . $this->t('This sort is not exposed. Expose it to allow the users to change it.') . '</div>',
- );
- $form['expose_button']['button'] = array(
- '#limit_validation_errors' => array(),
+ ];
+ $form['expose_button']['button'] = [
+ '#limit_validation_errors' => [],
'#type' => 'submit',
'#value' => $this->t('Expose sort'),
- '#submit' => array(array($this, 'displayExposedForm')),
- );
+ '#submit' => [[$this, 'displayExposedForm']],
+ ];
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
}
else {
- $form['expose_button']['markup'] = array(
+ $form['expose_button']['markup'] = [
'#markup' => '<div class="description exposed-description">' . $this->t('This sort is exposed. If you hide it, users will not be able to change it.') . '</div>',
- );
- $form['expose_button']['button'] = array(
- '#limit_validation_errors' => array(),
+ ];
+ $form['expose_button']['button'] = [
+ '#limit_validation_errors' => [],
'#type' => 'submit',
'#value' => $this->t('Hide sort'),
- '#submit' => array(array($this, 'displayExposedForm')),
- );
+ '#submit' => [[$this, 'displayExposedForm']],
+ ];
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
}
}
@@ -166,12 +166,12 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
protected function showSortForm(&$form, FormStateInterface $form_state) {
$options = $this->sortOptions();
if (!empty($options)) {
- $form['order'] = array(
+ $form['order'] = [
'#title' => $this->t('Order'),
'#type' => 'radios',
'#options' => $options,
'#default_value' => $this->options['order'],
- );
+ ];
}
}
@@ -184,10 +184,10 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
* Should be overridden by classes that don't override sort_form
*/
protected function sortOptions() {
- return array(
+ return [
'ASC' => $this->t('Sort ascending'),
'DESC' => $this->t('Sort descending'),
- );
+ ];
}
public function buildExposeForm(&$form, FormStateInterface $form_state) {
@@ -195,26 +195,26 @@ abstract class SortPluginBase extends HandlerBase implements CacheableDependency
// prior to rendering. That's why the preRender for it needs to run first,
// so that when the next preRender (the one for fieldsets) runs, it gets
// the flattened data.
- array_unshift($form['#pre_render'], array(get_class($this), 'preRenderFlattenData'));
+ array_unshift($form['#pre_render'], [get_class($this), 'preRenderFlattenData']);
$form['expose']['#flatten'] = TRUE;
- $form['expose']['label'] = array(
+ $form['expose']['label'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['label'],
'#title' => $this->t('Label'),
'#required' => TRUE,
'#size' => 40,
'#weight' => -1,
- );
+ ];
}
/**
* Provide default options for exposed sorts.
*/
public function defaultExposeOptions() {
- $this->options['expose'] = array(
+ $this->options['expose'] = [
'label' => $this->definition['title'],
- );
+ ];
}
/**
diff --git a/core/modules/views/src/Plugin/views/style/DefaultSummary.php b/core/modules/views/src/Plugin/views/style/DefaultSummary.php
index abd149dc6b4..0b4325bcc93 100644
--- a/core/modules/views/src/Plugin/views/style/DefaultSummary.php
+++ b/core/modules/views/src/Plugin/views/style/DefaultSummary.php
@@ -22,10 +22,10 @@ class DefaultSummary extends StylePluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['base_path'] = array('default' => '');
- $options['count'] = array('default' => TRUE);
- $options['override'] = array('default' => FALSE);
- $options['items_per_page'] = array('default' => 25);
+ $options['base_path'] = ['default' => ''];
+ $options['count'] = ['default' => TRUE];
+ $options['override'] = ['default' => FALSE];
+ $options['items_per_page'] = ['default' => 25];
return $options;
}
@@ -37,7 +37,7 @@ class DefaultSummary extends StylePluginBase {
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['base_path'] = array(
+ $form['base_path'] = [
'#type' => 'textfield',
'#title' => $this->t('Base path'),
'#default_value' => $this->options['base_path'],
@@ -46,43 +46,43 @@ class DefaultSummary extends StylePluginBase {
Do not include beginning and ending forward slash. If this value
is empty, views will use the first path found as the base path,
in page displays, or / if no path could be found.'),
- );
- $form['count'] = array(
+ ];
+ $form['count'] = [
'#type' => 'checkbox',
'#default_value' => !empty($this->options['count']),
'#title' => $this->t('Display record count with link'),
- );
- $form['override'] = array(
+ ];
+ $form['override'] = [
'#type' => 'checkbox',
'#default_value' => !empty($this->options['override']),
'#title' => $this->t('Override number of items to display'),
- );
+ ];
- $form['items_per_page'] = array(
+ $form['items_per_page'] = [
'#type' => 'textfield',
'#title' => $this->t('Items to display'),
'#default_value' => $this->options['items_per_page'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[summary][options][' . $this->definition['id'] . '][override]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[summary][options][' . $this->definition['id'] . '][override]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
}
public function render() {
- $rows = array();
+ $rows = [];
foreach ($this->view->result as $row) {
// @todo: Include separator as an option.
$rows[] = $row;
}
- return array(
+ return [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#rows' => $rows,
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/style/EntityReference.php b/core/modules/views/src/Plugin/views/style/EntityReference.php
index f694b00e138..e07a0f18589 100644
--- a/core/modules/views/src/Plugin/views/style/EntityReference.php
+++ b/core/modules/views/src/Plugin/views/style/EntityReference.php
@@ -41,7 +41,7 @@ class EntityReference extends StylePluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['search_fields'] = array('default' => array());
+ $options['search_fields'] = ['default' => []];
return $options;
}
@@ -53,7 +53,7 @@ class EntityReference extends StylePluginBase {
parent::buildOptionsForm($form, $form_state);
$options = $this->displayHandler->getFieldLabels(TRUE);
- $form['search_fields'] = array(
+ $form['search_fields'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Search fields'),
'#options' => $options,
@@ -61,7 +61,7 @@ class EntityReference extends StylePluginBase {
'#default_value' => $this->options['search_fields'],
'#description' => $this->t('Select the field(s) that will be searched when using the autocomplete widget.'),
'#weight' => -3,
- );
+ ];
}
/**
@@ -81,7 +81,7 @@ class EntityReference extends StylePluginBase {
// @todo We don't display grouping info for now. Could be useful for select
// widget, though.
- $results = array();
+ $results = [];
foreach ($sets as $records) {
foreach ($records as $values) {
$results[$values->{$id_field_alias}] = $this->view->rowPlugin->render($values);
diff --git a/core/modules/views/src/Plugin/views/style/Grid.php b/core/modules/views/src/Plugin/views/style/Grid.php
index 34ab8ed2855..938c1b52364 100644
--- a/core/modules/views/src/Plugin/views/style/Grid.php
+++ b/core/modules/views/src/Plugin/views/style/Grid.php
@@ -32,13 +32,13 @@ class Grid extends StylePluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['columns'] = array('default' => '4');
- $options['automatic_width'] = array('default' => TRUE);
- $options['alignment'] = array('default' => 'horizontal');
- $options['col_class_custom'] = array('default' => '');
- $options['col_class_default'] = array('default' => TRUE);
- $options['row_class_custom'] = array('default' => '');
- $options['row_class_default'] = array('default' => TRUE);
+ $options['columns'] = ['default' => '4'];
+ $options['automatic_width'] = ['default' => TRUE];
+ $options['alignment'] = ['default' => 'horizontal'];
+ $options['col_class_custom'] = ['default' => ''];
+ $options['col_class_default'] = ['default' => TRUE];
+ $options['row_class_custom'] = ['default' => ''];
+ $options['row_class_default'] = ['default' => TRUE];
return $options;
}
@@ -47,53 +47,53 @@ class Grid extends StylePluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['columns'] = array(
+ $form['columns'] = [
'#type' => 'number',
'#title' => $this->t('Number of columns'),
'#default_value' => $this->options['columns'],
'#required' => TRUE,
'#min' => 1,
- );
- $form['automatic_width'] = array(
+ ];
+ $form['automatic_width'] = [
'#type' => 'checkbox',
'#title' => $this->t('Automatic width'),
'#description' => $this->t('The width of each column will be calculated automatically based on the number of columns provided. If additional classes are entered or a theme injects classes based on a grid system, disabling this option may prove beneficial.'),
'#default_value' => $this->options['automatic_width'],
- );
- $form['alignment'] = array(
+ ];
+ $form['alignment'] = [
'#type' => 'radios',
'#title' => $this->t('Alignment'),
- '#options' => array('horizontal' => $this->t('Horizontal'), 'vertical' => $this->t('Vertical')),
+ '#options' => ['horizontal' => $this->t('Horizontal'), 'vertical' => $this->t('Vertical')],
'#default_value' => $this->options['alignment'],
'#description' => $this->t('Horizontal alignment will place items starting in the upper left and moving right. Vertical alignment will place items starting in the upper left and moving down.'),
- );
- $form['col_class_default'] = array(
+ ];
+ $form['col_class_default'] = [
'#title' => $this->t('Default column classes'),
'#description' => $this->t('Add the default views column classes like views-col, col-1 and clearfix to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'),
'#type' => 'checkbox',
'#default_value' => $this->options['col_class_default'],
- );
- $form['col_class_custom'] = array(
+ ];
+ $form['col_class_custom'] = [
'#title' => $this->t('Custom column class'),
'#description' => $this->t('Additional classes to provide on each column. Separated by a space.'),
'#type' => 'textfield',
'#default_value' => $this->options['col_class_custom'],
- );
+ ];
if ($this->usesFields()) {
$form['col_class_custom']['#description'] .= ' ' . $this->t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
}
- $form['row_class_default'] = array(
+ $form['row_class_default'] = [
'#title' => $this->t('Default row classes'),
'#description' => $this->t('Adds the default views row classes like views-row, row-1 and clearfix to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'),
'#type' => 'checkbox',
'#default_value' => $this->options['row_class_default'],
- );
- $form['row_class_custom'] = array(
+ ];
+ $form['row_class_custom'] = [
'#title' => $this->t('Custom row class'),
'#description' => $this->t('Additional classes to provide on each row. Separated by a space.'),
'#type' => 'textfield',
'#default_value' => $this->options['row_class_custom'],
- );
+ ];
if ($this->usesFields()) {
$form['row_class_custom']['#description'] .= ' ' . $this->t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
}
diff --git a/core/modules/views/src/Plugin/views/style/HtmlList.php b/core/modules/views/src/Plugin/views/style/HtmlList.php
index a89b0f1269b..a6df09d2b27 100644
--- a/core/modules/views/src/Plugin/views/style/HtmlList.php
+++ b/core/modules/views/src/Plugin/views/style/HtmlList.php
@@ -39,9 +39,9 @@ class HtmlList extends StylePluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['type'] = array('default' => 'ul');
- $options['class'] = array('default' => '');
- $options['wrapper_class'] = array('default' => 'item-list');
+ $options['type'] = ['default' => 'ul'];
+ $options['class'] = ['default' => ''];
+ $options['wrapper_class'] = ['default' => 'item-list'];
return $options;
}
@@ -51,26 +51,26 @@ class HtmlList extends StylePluginBase {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'radios',
'#title' => $this->t('List type'),
- '#options' => array('ul' => $this->t('Unordered list'), 'ol' => $this->t('Ordered list')),
+ '#options' => ['ul' => $this->t('Unordered list'), 'ol' => $this->t('Ordered list')],
'#default_value' => $this->options['type'],
- );
- $form['wrapper_class'] = array(
+ ];
+ $form['wrapper_class'] = [
'#title' => $this->t('Wrapper class'),
'#description' => $this->t('The class to provide on the wrapper, outside the list.'),
'#type' => 'textfield',
'#size' => '30',
'#default_value' => $this->options['wrapper_class'],
- );
- $form['class'] = array(
+ ];
+ $form['class'] = [
'#title' => $this->t('List class'),
'#description' => $this->t('The class to provide on the list element itself.'),
'#type' => 'textfield',
'#size' => '30',
'#default_value' => $this->options['class'],
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/style/Mapping.php b/core/modules/views/src/Plugin/views/style/Mapping.php
index e7c72422df8..7db52478866 100644
--- a/core/modules/views/src/Plugin/views/style/Mapping.php
+++ b/core/modules/views/src/Plugin/views/style/Mapping.php
@@ -49,14 +49,14 @@ abstract class Mapping extends StylePluginBase {
// Parse the mapping and add a default for each.
foreach ($this->defineMapping() as $key => $value) {
- $default = !empty($value['#multiple']) ? array() : '';
- $options['mapping']['contains'][$key] = array(
+ $default = !empty($value['#multiple']) ? [] : '';
+ $options['mapping']['contains'][$key] = [
'default' => isset($value['#default_value']) ? $value['#default_value'] : $default,
- );
+ ];
if (!empty($value['#toggle'])) {
- $options['mapping']['contains']["toggle_$key"] = array(
+ $options['mapping']['contains']["toggle_$key"] = [
'default' => FALSE,
- );
+ ];
}
}
@@ -79,19 +79,19 @@ abstract class Mapping extends StylePluginBase {
$field_labels = $this->displayHandler->getFieldLabels();
// Provide some default values.
- $defaults = array(
+ $defaults = [
'#type' => 'select',
'#required' => FALSE,
'#multiple' => FALSE,
- );
+ ];
// For each mapping, add a select element to the form.
foreach ($options as $key => $value) {
// If the field is optional, add a 'None' value to the top of the options.
- $field_options = array();
+ $field_options = [];
$required = !empty($mapping[$key]['#required']);
if (!$required && empty($mapping[$key]['#multiple'])) {
- $field_options = array('' => $this->t('- None -'));
+ $field_options = ['' => $this->t('- None -')];
}
$field_options += $field_labels;
@@ -104,19 +104,19 @@ abstract class Mapping extends StylePluginBase {
}
// These values must always be set.
- $overrides = array(
+ $overrides = [
'#options' => $field_options,
'#default_value' => $options[$key],
- );
+ ];
// Optionally allow the select to be toggleable.
if (!empty($mapping[$key]['#toggle'])) {
- $form['mapping']["toggle_$key"] = array(
+ $form['mapping']["toggle_$key"] = [
'#type' => 'checkbox',
- '#title' => $this->t('Use a custom %field_name', array('%field_name' => strtolower($mapping[$key]['#title']))),
+ '#title' => $this->t('Use a custom %field_name', ['%field_name' => strtolower($mapping[$key]['#title'])]),
'#default_value' => $this->options['mapping']["toggle_$key"],
- );
- $overrides['#states']['visible'][':input[name="style_options[mapping][' . "toggle_$key" . ']"]'] = array('checked' => TRUE);
+ ];
+ $overrides['#states']['visible'][':input[name="style_options[mapping][' . "toggle_$key" . ']"]'] = ['checked' => TRUE];
}
$form['mapping'][$key] = $overrides + $mapping[$key] + $defaults;
@@ -129,13 +129,13 @@ abstract class Mapping extends StylePluginBase {
* Provides the mapping definition as an available variable.
*/
public function render() {
- return array(
+ return [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#rows' => $this->view->result,
'#mapping' => $this->defineMapping(),
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/style/Opml.php b/core/modules/views/src/Plugin/views/style/Opml.php
index ed02511a0c4..69679d3ce7b 100644
--- a/core/modules/views/src/Plugin/views/style/Opml.php
+++ b/core/modules/views/src/Plugin/views/style/Opml.php
@@ -31,7 +31,7 @@ class Opml extends StylePluginBase {
*/
public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
$display = $this->view->displayHandlers->get($display_id);
- $url_options = array();
+ $url_options = [];
$input = $this->view->getExposedInput();
if ($input) {
$url_options['query'] = $input;
@@ -41,15 +41,15 @@ class Opml extends StylePluginBase {
$url = $feed_url->setOptions($url_options)->toString();
if ($display->hasPath()) {
if (empty($this->preview)) {
- $build['#attached']['feed'][] = array($url, $title);
+ $build['#attached']['feed'][] = [$url, $title];
}
}
else {
- $this->view->feedIcons[] = array(
+ $this->view->feedIcons[] = [
'#theme' => 'feed_icon',
'#url' => $url,
'#title' => $title,
- );
+ ];
}
}
@@ -61,19 +61,19 @@ class Opml extends StylePluginBase {
debug('Drupal\views\Plugin\views\style\Opml: Missing row plugin');
return;
}
- $rows = array();
+ $rows = [];
foreach ($this->view->result as $row_index => $row) {
$this->view->row_index = $row_index;
$rows[] = $this->view->rowPlugin->render($row);
}
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#rows' => $rows,
- );
+ ];
unset($this->view->row_index);
return $build;
}
diff --git a/core/modules/views/src/Plugin/views/style/Rss.php b/core/modules/views/src/Plugin/views/style/Rss.php
index e612453e622..b7efa578d75 100644
--- a/core/modules/views/src/Plugin/views/style/Rss.php
+++ b/core/modules/views/src/Plugin/views/style/Rss.php
@@ -28,7 +28,7 @@ class Rss extends StylePluginBase {
protected $usesRowPlugin = TRUE;
public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
- $url_options = array();
+ $url_options = [];
$input = $this->view->getExposedInput();
if ($input) {
$url_options['query'] = $input;
@@ -45,18 +45,18 @@ class Rss extends StylePluginBase {
];
// Attach a link to the RSS feed, which is an alternate representation.
- $build['#attached']['html_head_link'][][] = array(
+ $build['#attached']['html_head_link'][][] = [
'rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => $title,
'href' => $url,
- );
+ ];
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['description'] = array('default' => '');
+ $options['description'] = ['default' => ''];
return $options;
}
@@ -64,13 +64,13 @@ class Rss extends StylePluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['description'] = array(
+ $form['description'] = [
'#type' => 'textfield',
'#title' => $this->t('RSS description'),
'#default_value' => $this->options['description'],
'#description' => $this->t('This will appear in the RSS feed itself.'),
'#maxlength' => 1024,
- );
+ ];
}
/**
@@ -80,7 +80,7 @@ class Rss extends StylePluginBase {
* A render array.
*/
protected function getChannelElements() {
- return array();
+ return [];
}
/**
@@ -101,13 +101,13 @@ class Rss extends StylePluginBase {
public function render() {
if (empty($this->view->rowPlugin)) {
debug('Drupal\views\Plugin\views\style\Rss: Missing row plugin');
- return array();
+ return [];
}
$rows = [];
// This will be filled in by the row plugin and is used later on in the
// theming output.
- $this->namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/');
+ $this->namespaces = ['xmlns:dc' => 'http://purl.org/dc/elements/1.1/'];
// Fetch any additional elements for the channel and merge in their
// namespaces.
@@ -123,12 +123,12 @@ class Rss extends StylePluginBase {
$rows[] = $this->view->rowPlugin->render($row);
}
- $build = array(
+ $build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#rows' => $rows,
- );
+ ];
unset($this->view->row_index);
return $build;
}
diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
index a7b191753f0..1131b6af0d0 100644
--- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php
+++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
@@ -47,7 +47,7 @@ abstract class StylePluginBase extends PluginBase {
/**
* Store all available tokens row rows.
*/
- protected $rowTokens = array();
+ protected $rowTokens = [];
/**
* Does the style plugin allows to use style plugins.
@@ -122,9 +122,9 @@ abstract class StylePluginBase extends PluginBase {
$this->view->rowPlugin = $display->getPlugin('row');
}
- $this->options += array(
- 'grouping' => array(),
- );
+ $this->options += [
+ 'grouping' => [],
+ ];
}
@@ -230,7 +230,7 @@ abstract class StylePluginBase extends PluginBase {
public function tokenizeValue($value, $row_index) {
if (strpos($value, '{{') !== FALSE) {
// Row tokens might be empty, for example for node row style.
- $tokens = isset($this->rowTokens[$row_index]) ? $this->rowTokens[$row_index] : array();
+ $tokens = isset($this->rowTokens[$row_index]) ? $this->rowTokens[$row_index] : [];
if (!empty($this->view->build_info['substitutions'])) {
$tokens += $this->view->build_info['substitutions'];
}
@@ -257,12 +257,12 @@ abstract class StylePluginBase extends PluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['grouping'] = array('default' => array());
+ $options['grouping'] = ['default' => []];
if ($this->usesRowClass()) {
- $options['row_class'] = array('default' => '');
- $options['default_row_class'] = array('default' => TRUE);
+ $options['row_class'] = ['default' => ''];
+ $options['default_row_class'] = ['default' => TRUE];
}
- $options['uses_fields'] = array('default' => FALSE);
+ $options['uses_fields'] = ['default' => FALSE];
return $options;
}
@@ -277,7 +277,7 @@ abstract class StylePluginBase extends PluginBase {
// to FALSE.
// @TODO: Document "usesGrouping" in docs.php when docs.php is written.
if ($this->usesFields() && $this->usesGrouping()) {
- $options = array('' => $this->t('- None -'));
+ $options = ['' => $this->t('- None -')];
$field_labels = $this->displayHandler->getFieldLabels(TRUE);
$options += $field_labels;
// If there are no fields, we can't group on them.
@@ -286,7 +286,7 @@ abstract class StylePluginBase extends PluginBase {
// select form.
if (is_string($this->options['grouping'])) {
$grouping = $this->options['grouping'];
- $this->options['grouping'] = array();
+ $this->options['grouping'] = [];
$this->options['grouping'][0]['field'] = $grouping;
}
if (isset($this->options['group_rendered']) && is_string($this->options['group_rendered'])) {
@@ -297,67 +297,67 @@ abstract class StylePluginBase extends PluginBase {
$c = count($this->options['grouping']);
// Add a form for every grouping, plus one.
for ($i = 0; $i <= $c; $i++) {
- $grouping = !empty($this->options['grouping'][$i]) ? $this->options['grouping'][$i] : array();
- $grouping += array('field' => '', 'rendered' => TRUE, 'rendered_strip' => FALSE);
- $form['grouping'][$i]['field'] = array(
+ $grouping = !empty($this->options['grouping'][$i]) ? $this->options['grouping'][$i] : [];
+ $grouping += ['field' => '', 'rendered' => TRUE, 'rendered_strip' => FALSE];
+ $form['grouping'][$i]['field'] = [
'#type' => 'select',
- '#title' => $this->t('Grouping field Nr.@number', array('@number' => $i + 1)),
+ '#title' => $this->t('Grouping field Nr.@number', ['@number' => $i + 1]),
'#options' => $options,
'#default_value' => $grouping['field'],
'#description' => $this->t('You may optionally specify a field by which to group the records. Leave blank to not group.'),
- );
- $form['grouping'][$i]['rendered'] = array(
+ ];
+ $form['grouping'][$i]['rendered'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use rendered output to group rows'),
'#default_value' => $grouping['rendered'],
'#description' => $this->t('If enabled the rendered output of the grouping field is used to group the rows.'),
- '#states' => array(
- 'invisible' => array(
- ':input[name="style_options[grouping][' . $i . '][field]"]' => array('value' => ''),
- ),
- ),
- );
- $form['grouping'][$i]['rendered_strip'] = array(
+ '#states' => [
+ 'invisible' => [
+ ':input[name="style_options[grouping][' . $i . '][field]"]' => ['value' => ''],
+ ],
+ ],
+ ];
+ $form['grouping'][$i]['rendered_strip'] = [
'#type' => 'checkbox',
'#title' => $this->t('Remove tags from rendered output'),
'#default_value' => $grouping['rendered_strip'],
- '#states' => array(
- 'invisible' => array(
- ':input[name="style_options[grouping][' . $i . '][field]"]' => array('value' => ''),
- ),
- ),
- );
+ '#states' => [
+ 'invisible' => [
+ ':input[name="style_options[grouping][' . $i . '][field]"]' => ['value' => ''],
+ ],
+ ],
+ ];
}
}
}
if ($this->usesRowClass()) {
- $form['row_class'] = array(
+ $form['row_class'] = [
'#title' => $this->t('Row class'),
'#description' => $this->t('The class to provide on each row.'),
'#type' => 'textfield',
'#default_value' => $this->options['row_class'],
- );
+ ];
if ($this->usesFields()) {
$form['row_class']['#description'] .= ' ' . $this->t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
}
- $form['default_row_class'] = array(
+ $form['default_row_class'] = [
'#title' => $this->t('Add views row classes'),
- '#description' => $this->t('Add the default row classes like @classes to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.', array('@classes' => 'views-row')),
+ '#description' => $this->t('Add the default row classes like @classes to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.', ['@classes' => 'views-row']),
'#type' => 'checkbox',
'#default_value' => $this->options['default_row_class'],
- );
+ ];
}
if (!$this->usesFields() || !empty($this->options['uses_fields'])) {
- $form['uses_fields'] = array(
+ $form['uses_fields'] = [
'#type' => 'checkbox',
'#title' => $this->t('Force using fields'),
'#description' => $this->t('If neither the row nor the style plugin supports fields, this field allows to enable them, so you can for example use groupby.'),
'#default_value' => $this->options['uses_fields'],
- );
+ ];
}
}
@@ -366,12 +366,12 @@ abstract class StylePluginBase extends PluginBase {
*/
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
// Don't run validation on style plugins without the grouping setting.
- if ($form_state->hasValue(array('style_options', 'grouping'))) {
+ if ($form_state->hasValue(['style_options', 'grouping'])) {
// Don't save grouping if no field is specified.
- $groupings = $form_state->getValue(array('style_options', 'grouping'));
+ $groupings = $form_state->getValue(['style_options', 'grouping']);
foreach ($groupings as $index => $grouping) {
if (empty($grouping['field'])) {
- $form_state->unsetValue(array('style_options', 'grouping', $index));
+ $form_state->unsetValue(['style_options', 'grouping', $index]);
}
}
}
@@ -442,12 +442,12 @@ abstract class StylePluginBase extends PluginBase {
* @return array
* The render array containing the single group theme output.
*/
- protected function renderRowGroup(array $rows = array()) {
- return array(
+ protected function renderRowGroup(array $rows = []) {
+ return [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#rows' => $rows,
- );
+ ];
}
/**
@@ -486,7 +486,7 @@ abstract class StylePluginBase extends PluginBase {
* Rendered output of given grouping sets.
*/
public function renderGroupingSets($sets) {
- $output = array();
+ $output = [];
$theme_functions = $this->view->buildThemeFunctions($this->groupingTheme);
foreach ($sets as $set) {
$level = isset($set['level']) ? $set['level'] : 0;
@@ -494,12 +494,12 @@ abstract class StylePluginBase extends PluginBase {
$row = reset($set['rows']);
// Render as a grouping set.
if (is_array($row) && isset($row['group'])) {
- $single_output = array(
+ $single_output = [
'#theme' => $theme_functions,
'#view' => $this->view,
'#grouping' => $this->options['grouping'][$level],
'#rows' => $set['rows'],
- );
+ ];
}
// Render as a record set.
else {
@@ -562,17 +562,17 @@ abstract class StylePluginBase extends PluginBase {
* )
* @endcode
*/
- public function renderGrouping($records, $groupings = array(), $group_rendered = NULL) {
+ public function renderGrouping($records, $groupings = [], $group_rendered = NULL) {
// This is for backward compatibility, when $groupings was a string
// containing the ID of a single field.
if (is_string($groupings)) {
$rendered = $group_rendered === NULL ? TRUE : $group_rendered;
- $groupings = array(array('field' => $groupings, 'rendered' => $rendered));
+ $groupings = [['field' => $groupings, 'rendered' => $rendered]];
}
// Make sure fields are rendered
$this->renderFields($this->view->result);
- $sets = array();
+ $sets = [];
if ($groupings) {
foreach ($records as $index => $row) {
// Iterate through configured grouping fields to determine the
@@ -613,7 +613,7 @@ abstract class StylePluginBase extends PluginBase {
if (empty($set[$grouping])) {
$set[$grouping]['group'] = $group_content;
$set[$grouping]['level'] = $level;
- $set[$grouping]['rows'] = array();
+ $set[$grouping]['rows'] = [];
}
// Move the set reference into the row set of the group we just determined.
@@ -625,17 +625,17 @@ abstract class StylePluginBase extends PluginBase {
}
else {
// Create a single group with an empty grouping field.
- $sets[''] = array(
+ $sets[''] = [
'group' => '',
'rows' => $records,
- );
+ ];
}
// If this parameter isn't explicitly set, modify the output to be fully
// backward compatible to code before Views 7.x-3.0-rc2.
// @TODO Remove this as soon as possible e.g. October 2020
if ($group_rendered === NULL) {
- $old_style_sets = array();
+ $old_style_sets = [];
foreach ($sets as $group) {
$old_style_sets[$group['group']] = $group['rows'];
}
@@ -806,7 +806,7 @@ abstract class StylePluginBase extends PluginBase {
if ($this->usesRowPlugin()) {
$plugin = $this->displayHandler->getPlugin('row');
if (empty($plugin)) {
- $errors[] = $this->t('Style @style requires a row style but the row plugin is invalid.', array('@style' => $this->definition['title']));
+ $errors[] = $this->t('Style @style requires a row style but the row plugin is invalid.', ['@style' => $this->definition['title']]);
}
else {
$result = $plugin->validate();
diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php
index c49f6e984f0..00e28b3c6dc 100644
--- a/core/modules/views/src/Plugin/views/style/Table.php
+++ b/core/modules/views/src/Plugin/views/style/Table.php
@@ -65,16 +65,16 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['columns'] = array('default' => array());
- $options['default'] = array('default' => '');
- $options['info'] = array('default' => array());
- $options['override'] = array('default' => TRUE);
- $options['sticky'] = array('default' => FALSE);
- $options['order'] = array('default' => 'asc');
- $options['caption'] = array('default' => '');
- $options['summary'] = array('default' => '');
- $options['description'] = array('default' => '');
- $options['empty_table'] = array('default' => FALSE);
+ $options['columns'] = ['default' => []];
+ $options['default'] = ['default' => ''];
+ $options['info'] = ['default' => []];
+ $options['override'] = ['default' => TRUE];
+ $options['sticky'] = ['default' => FALSE];
+ $options['order'] = ['default' => 'asc'];
+ $options['caption'] = ['default' => ''];
+ $options['summary'] = ['default' => ''];
+ $options['description'] = ['default' => ''];
+ $options['empty_table'] = ['default' => FALSE];
return $options;
}
@@ -165,7 +165,7 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
* An array of all the sanitized columns.
*/
public function sanitizeColumns($columns, $fields = NULL) {
- $sanitized = array();
+ $sanitized = [];
if ($fields === NULL) {
$fields = $this->displayHandler->getOption('fields');
}
@@ -202,57 +202,57 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
parent::buildOptionsForm($form, $form_state);
$handlers = $this->displayHandler->getHandlers('field');
if (empty($handlers)) {
- $form['error_markup'] = array(
+ $form['error_markup'] = [
'#markup' => '<div class="messages messages--error">' . $this->t('You need at least one field before you can configure your table settings') . '</div>',
- );
+ ];
return;
}
- $form['override'] = array(
+ $form['override'] = [
'#type' => 'checkbox',
'#title' => $this->t('Override normal sorting if click sorting is used'),
'#default_value' => !empty($this->options['override']),
- );
+ ];
- $form['sticky'] = array(
+ $form['sticky'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable Drupal style "sticky" table headers (Javascript)'),
'#default_value' => !empty($this->options['sticky']),
'#description' => $this->t('(Sticky header effects will not be active for preview below, only on live output.)'),
- );
+ ];
- $form['caption'] = array(
+ $form['caption'] = [
'#type' => 'textfield',
'#title' => $this->t('Caption for the table'),
'#description' => $this->t('A title semantically associated with your table for increased accessibility.'),
'#default_value' => $this->options['caption'],
'#maxlength' => 255,
- );
+ ];
- $form['accessibility_details'] = array(
+ $form['accessibility_details'] = [
'#type' => 'details',
'#title' => $this->t('Table details'),
- );
+ ];
- $form['summary'] = array(
+ $form['summary'] = [
'#title' => $this->t('Summary title'),
'#type' => 'textfield',
'#default_value' => $this->options['summary'],
'#fieldset' => 'accessibility_details',
- );
+ ];
- $form['description'] = array(
+ $form['description'] = [
'#title' => $this->t('Table description'),
'#type' => 'textarea',
'#description' => $this->t('Provide additional details about the table to increase accessibility.'),
'#default_value' => $this->options['description'],
- '#states' => array(
- 'visible' => array(
- 'input[name="style_options[summary]"]' => array('filled' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ 'input[name="style_options[summary]"]' => ['filled' => TRUE],
+ ],
+ ],
'#fieldset' => 'accessibility_details',
- );
+ ];
// Note: views UI registers this theme handler on our behalf. Your module
// will have to register your theme handlers if you do stuff like this.
@@ -276,137 +276,137 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
foreach ($columns as $field => $column) {
$column_selector = ':input[name="style_options[columns][' . $field . ']"]';
- $form['columns'][$field] = array(
- '#title' => $this->t('Columns for @field', array('@field' => $field)),
+ $form['columns'][$field] = [
+ '#title' => $this->t('Columns for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => $field_names,
'#default_value' => $column,
- );
+ ];
if ($handlers[$field]->clickSortable()) {
- $form['info'][$field]['sortable'] = array(
- '#title' => $this->t('Sortable for @field', array('@field' => $field)),
+ $form['info'][$field]['sortable'] = [
+ '#title' => $this->t('Sortable for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#default_value' => !empty($this->options['info'][$field]['sortable']),
- '#states' => array(
- 'visible' => array(
- $column_selector => array('value' => $field),
- ),
- ),
- );
- $form['info'][$field]['default_sort_order'] = array(
- '#title' => $this->t('Default sort order for @field', array('@field' => $field)),
+ '#states' => [
+ 'visible' => [
+ $column_selector => ['value' => $field],
+ ],
+ ],
+ ];
+ $form['info'][$field]['default_sort_order'] = [
+ '#title' => $this->t('Default sort order for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'select',
- '#options' => array('asc' => $this->t('Ascending'), 'desc' => $this->t('Descending')),
+ '#options' => ['asc' => $this->t('Ascending'), 'desc' => $this->t('Descending')],
'#default_value' => !empty($this->options['info'][$field]['default_sort_order']) ? $this->options['info'][$field]['default_sort_order'] : 'asc',
- '#states' => array(
- 'visible' => array(
- $column_selector => array('value' => $field),
- ':input[name="style_options[info][' . $field . '][sortable]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ $column_selector => ['value' => $field],
+ ':input[name="style_options[info][' . $field . '][sortable]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
// Provide an ID so we can have such things.
$radio_id = Html::getUniqueId('edit-default-' . $field);
- $form['default'][$field] = array(
- '#title' => $this->t('Default sort for @field', array('@field' => $field)),
+ $form['default'][$field] = [
+ '#title' => $this->t('Default sort for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'radio',
'#return_value' => $field,
- '#parents' => array('style_options', 'default'),
+ '#parents' => ['style_options', 'default'],
'#id' => $radio_id,
// because 'radio' doesn't fully support '#id' =(
- '#attributes' => array('id' => $radio_id),
+ '#attributes' => ['id' => $radio_id],
'#default_value' => $default,
- '#states' => array(
- 'visible' => array(
- $column_selector => array('value' => $field),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ $column_selector => ['value' => $field],
+ ],
+ ],
+ ];
}
- $form['info'][$field]['align'] = array(
- '#title' => $this->t('Alignment for @field', array('@field' => $field)),
+ $form['info'][$field]['align'] = [
+ '#title' => $this->t('Alignment for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'select',
'#default_value' => !empty($this->options['info'][$field]['align']) ? $this->options['info'][$field]['align'] : '',
- '#options' => array(
+ '#options' => [
'' => $this->t('None'),
- 'views-align-left' => $this->t('Left', array(), array('context' => 'Text alignment')),
- 'views-align-center' => $this->t('Center', array(), array('context' => 'Text alignment')),
- 'views-align-right' => $this->t('Right', array(), array('context' => 'Text alignment')),
- ),
- '#states' => array(
- 'visible' => array(
- $column_selector => array('value' => $field),
- ),
- ),
- );
- $form['info'][$field]['separator'] = array(
- '#title' => $this->t('Separator for @field', array('@field' => $field)),
+ 'views-align-left' => $this->t('Left', [], ['context' => 'Text alignment']),
+ 'views-align-center' => $this->t('Center', [], ['context' => 'Text alignment']),
+ 'views-align-right' => $this->t('Right', [], ['context' => 'Text alignment']),
+ ],
+ '#states' => [
+ 'visible' => [
+ $column_selector => ['value' => $field],
+ ],
+ ],
+ ];
+ $form['info'][$field]['separator'] = [
+ '#title' => $this->t('Separator for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#size' => 10,
'#default_value' => isset($this->options['info'][$field]['separator']) ? $this->options['info'][$field]['separator'] : '',
- '#states' => array(
- 'visible' => array(
- $column_selector => array('value' => $field),
- ),
- ),
- );
- $form['info'][$field]['empty_column'] = array(
- '#title' => $this->t('Hide empty column for @field', array('@field' => $field)),
+ '#states' => [
+ 'visible' => [
+ $column_selector => ['value' => $field],
+ ],
+ ],
+ ];
+ $form['info'][$field]['empty_column'] = [
+ '#title' => $this->t('Hide empty column for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#default_value' => isset($this->options['info'][$field]['empty_column']) ? $this->options['info'][$field]['empty_column'] : FALSE,
- '#states' => array(
- 'visible' => array(
- $column_selector => array('value' => $field),
- ),
- ),
- );
- $form['info'][$field]['responsive'] = array(
- '#title' => $this->t('Responsive setting for @field', array('@field' => $field)),
+ '#states' => [
+ 'visible' => [
+ $column_selector => ['value' => $field],
+ ],
+ ],
+ ];
+ $form['info'][$field]['responsive'] = [
+ '#title' => $this->t('Responsive setting for @field', ['@field' => $field]),
'#title_display' => 'invisible',
'#type' => 'select',
'#default_value' => isset($this->options['info'][$field]['responsive']) ? $this->options['info'][$field]['responsive'] : '',
- '#options' => array('' => $this->t('High'), RESPONSIVE_PRIORITY_MEDIUM => $this->t('Medium'), RESPONSIVE_PRIORITY_LOW => $this->t('Low')),
- '#states' => array(
- 'visible' => array(
- $column_selector => array('value' => $field),
- ),
- ),
- );
+ '#options' => ['' => $this->t('High'), RESPONSIVE_PRIORITY_MEDIUM => $this->t('Medium'), RESPONSIVE_PRIORITY_LOW => $this->t('Low')],
+ '#states' => [
+ 'visible' => [
+ $column_selector => ['value' => $field],
+ ],
+ ],
+ ];
// markup for the field name
- $form['info'][$field]['name'] = array(
+ $form['info'][$field]['name'] = [
'#markup' => $field_names[$field],
- );
+ ];
}
// Provide a radio for no default sort
- $form['default'][-1] = array(
+ $form['default'][-1] = [
'#title' => $this->t('No default sort'),
'#title_display' => 'invisible',
'#type' => 'radio',
'#return_value' => -1,
- '#parents' => array('style_options', 'default'),
+ '#parents' => ['style_options', 'default'],
'#id' => 'edit-default-0',
'#default_value' => $default,
- );
+ ];
- $form['empty_table'] = array(
+ $form['empty_table'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show the empty text in the table'),
'#default_value' => $this->options['empty_table'],
'#description' => $this->t('Per default the table is hidden for an empty view. With this option it is possible to show an empty table with the text in it.'),
- );
+ ];
- $form['description_markup'] = array(
+ $form['description_markup'] = [
'#markup' => '<div class="js-form-item form-item description">' . $this->t('Place fields into columns; you may combine multiple fields into the same column. If you do, the separator in the column specified will be used to separate the fields. Check the sortable box to make that column click sortable, and check the default sort radio to determine which column will be sorted by default, if any. You may control column order and field labels in the fields section.') . '</div>',
- );
+ ];
}
public function evenEmpty() {
diff --git a/core/modules/views/src/Plugin/views/style/UnformattedSummary.php b/core/modules/views/src/Plugin/views/style/UnformattedSummary.php
index b6b6d6e46fb..6460841afb2 100644
--- a/core/modules/views/src/Plugin/views/style/UnformattedSummary.php
+++ b/core/modules/views/src/Plugin/views/style/UnformattedSummary.php
@@ -21,23 +21,23 @@ class UnformattedSummary extends DefaultSummary {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['inline'] = array('default' => FALSE);
- $options['separator'] = array('default' => '');
+ $options['inline'] = ['default' => FALSE];
+ $options['separator'] = ['default' => ''];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['inline'] = array(
+ $form['inline'] = [
'#type' => 'checkbox',
'#default_value' => !empty($this->options['inline']),
'#title' => $this->t('Display items inline'),
- );
- $form['separator'] = array(
+ ];
+ $form['separator'] = [
'#type' => 'textfield',
'#title' => $this->t('Separator'),
'#default_value' => $this->options['separator'],
- );
+ ];
}
}
diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
index aab57a6980a..1771c710ea2 100644
--- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
+++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
@@ -66,7 +66,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
*
* @var array
*/
- protected $validated_views = array();
+ protected $validated_views = [];
/**
* The table column used for sorting by create date of this wizard.
@@ -80,21 +80,21 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
*
* @var array
*/
- protected $filters = array();
+ protected $filters = [];
/**
* Views items configuration arrays for sorts added by the wizard.
*
* @var array
*/
- protected $sorts = array();
+ protected $sorts = [];
/**
* The available store criteria.
*
* @var array
*/
- protected $availableSorts = array();
+ protected $availableSorts = [];
/**
* Default values for filters.
@@ -104,11 +104,11 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
*
* @var array()
*/
- protected $filter_defaults = array(
+ protected $filter_defaults = [
'id' => NULL,
- 'expose' => array('operator' => FALSE),
+ 'expose' => ['operator' => FALSE],
'group' => 1,
- );
+ ];
/**
* The bundle info service.
@@ -163,7 +163,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* @return array
*/
public function getFilters() {
- $filters = array();
+ $filters = [];
$default = $this->filter_defaults;
@@ -197,100 +197,100 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $style_options = Views::fetchPluginNames('style', 'normal', array($this->base_table));
- $feed_row_options = Views::fetchPluginNames('row', 'feed', array($this->base_table));
+ $style_options = Views::fetchPluginNames('style', 'normal', [$this->base_table]);
+ $feed_row_options = Views::fetchPluginNames('row', 'feed', [$this->base_table]);
$path_prefix = $this->url('<none>', [], ['absolute' => TRUE]);
// Add filters and sorts which apply to the view as a whole.
$this->buildFilters($form, $form_state);
$this->buildSorts($form, $form_state);
- $form['displays']['page'] = array(
+ $form['displays']['page'] = [
'#type' => 'fieldset',
'#title' => $this->t('Page settings'),
- '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')),
+ '#attributes' => ['class' => ['views-attachment', 'fieldset-no-legend']],
'#tree' => TRUE,
- );
- $form['displays']['page']['create'] = array(
+ ];
+ $form['displays']['page']['create'] = [
'#title' => $this->t('Create a page'),
'#type' => 'checkbox',
- '#attributes' => array('class' => array('strong')),
+ '#attributes' => ['class' => ['strong']],
'#default_value' => FALSE,
'#id' => 'edit-page-create',
- );
+ ];
// All options for the page display are included in this container so they
// can be hidden as a group when the "Create a page" checkbox is unchecked.
- $form['displays']['page']['options'] = array(
+ $form['displays']['page']['options'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('options-set')),
- '#states' => array(
- 'visible' => array(
- ':input[name="page[create]"]' => array('checked' => TRUE),
- ),
- ),
+ '#attributes' => ['class' => ['options-set']],
+ '#states' => [
+ 'visible' => [
+ ':input[name="page[create]"]' => ['checked' => TRUE],
+ ],
+ ],
'#prefix' => '<div><div id="edit-page-wrapper">',
'#suffix' => '</div></div>',
- '#parents' => array('page'),
- );
+ '#parents' => ['page'],
+ ];
- $form['displays']['page']['options']['title'] = array(
+ $form['displays']['page']['options']['title'] = [
'#title' => $this->t('Page title'),
'#type' => 'textfield',
'#maxlength' => 255,
- );
- $form['displays']['page']['options']['path'] = array(
+ ];
+ $form['displays']['page']['options']['path'] = [
'#title' => $this->t('Path'),
'#type' => 'textfield',
'#field_prefix' => $path_prefix,
// Account for the leading backslash.
'#maxlength' => 254,
- );
- $form['displays']['page']['options']['style'] = array(
+ ];
+ $form['displays']['page']['options']['style'] = [
'#type' => 'fieldset',
'#title' => $this->t('Page display settings'),
- '#attributes' => array('class' => array('container-inline', 'fieldset-no-legend')),
- );
+ '#attributes' => ['class' => ['container-inline', 'fieldset-no-legend']],
+ ];
// Create the dropdown for choosing the display format.
- $form['displays']['page']['options']['style']['style_plugin'] = array(
+ $form['displays']['page']['options']['style']['style_plugin'] = [
'#title' => $this->t('Display format'),
'#type' => 'select',
'#options' => $style_options,
- );
+ ];
$style_form = &$form['displays']['page']['options']['style'];
- $style_form['style_plugin']['#default_value'] = static::getSelected($form_state, array('page', 'style', 'style_plugin'), 'default', $style_form['style_plugin']);
+ $style_form['style_plugin']['#default_value'] = static::getSelected($form_state, ['page', 'style', 'style_plugin'], 'default', $style_form['style_plugin']);
// Changing this dropdown updates $form['displays']['page']['options'] via
// AJAX.
- views_ui_add_ajax_trigger($style_form, 'style_plugin', array('displays', 'page', 'options'));
+ views_ui_add_ajax_trigger($style_form, 'style_plugin', ['displays', 'page', 'options']);
$this->buildFormStyle($form, $form_state, 'page');
- $form['displays']['page']['options']['items_per_page'] = array(
+ $form['displays']['page']['options']['items_per_page'] = [
'#title' => $this->t('Items to display'),
'#type' => 'number',
'#default_value' => 10,
'#min' => 0,
- );
- $form['displays']['page']['options']['pager'] = array(
+ ];
+ $form['displays']['page']['options']['pager'] = [
'#title' => $this->t('Use a pager'),
'#type' => 'checkbox',
'#default_value' => TRUE,
- );
- $form['displays']['page']['options']['link'] = array(
+ ];
+ $form['displays']['page']['options']['link'] = [
'#title' => $this->t('Create a menu link'),
'#type' => 'checkbox',
'#id' => 'edit-page-link',
- );
- $form['displays']['page']['options']['link_properties'] = array(
+ ];
+ $form['displays']['page']['options']['link_properties'] = [
'#type' => 'container',
- '#states' => array(
- 'visible' => array(
- ':input[name="page[link]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="page[link]"]' => ['checked' => TRUE],
+ ],
+ ],
'#prefix' => '<div id="edit-page-link-properties-wrapper">',
'#suffix' => '</div>',
- );
+ ];
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
$menu_options = menu_ui_get_menus();
}
@@ -301,162 +301,162 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$menu_options[$name] = $this->t($title);
}
}
- $form['displays']['page']['options']['link_properties']['menu_name'] = array(
+ $form['displays']['page']['options']['link_properties']['menu_name'] = [
'#title' => $this->t('Menu'),
'#type' => 'select',
'#options' => $menu_options,
- );
- $form['displays']['page']['options']['link_properties']['title'] = array(
+ ];
+ $form['displays']['page']['options']['link_properties']['title'] = [
'#title' => $this->t('Link text'),
'#type' => 'textfield',
- );
+ ];
// Only offer a feed if we have at least one available feed row style.
if ($feed_row_options) {
- $form['displays']['page']['options']['feed'] = array(
+ $form['displays']['page']['options']['feed'] = [
'#title' => $this->t('Include an RSS feed'),
'#type' => 'checkbox',
'#id' => 'edit-page-feed',
- );
- $form['displays']['page']['options']['feed_properties'] = array(
+ ];
+ $form['displays']['page']['options']['feed_properties'] = [
'#type' => 'container',
- '#states' => array(
- 'visible' => array(
- ':input[name="page[feed]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="page[feed]"]' => ['checked' => TRUE],
+ ],
+ ],
'#prefix' => '<div id="edit-page-feed-properties-wrapper">',
'#suffix' => '</div>',
- );
- $form['displays']['page']['options']['feed_properties']['path'] = array(
+ ];
+ $form['displays']['page']['options']['feed_properties']['path'] = [
'#title' => $this->t('Feed path'),
'#type' => 'textfield',
'#field_prefix' => $path_prefix,
// Account for the leading backslash.
'#maxlength' => 254,
- );
+ ];
// This will almost never be visible.
- $form['displays']['page']['options']['feed_properties']['row_plugin'] = array(
+ $form['displays']['page']['options']['feed_properties']['row_plugin'] = [
'#title' => $this->t('Feed row style'),
'#type' => 'select',
'#options' => $feed_row_options,
'#default_value' => key($feed_row_options),
'#access' => (count($feed_row_options) > 1),
- '#states' => array(
- 'visible' => array(
- ':input[name="page[feed]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="page[feed]"]' => ['checked' => TRUE],
+ ],
+ ],
'#prefix' => '<div id="edit-page-feed-properties-row-plugin-wrapper">',
'#suffix' => '</div>',
- );
+ ];
}
// Only offer the block settings if the module is enabled.
if (\Drupal::moduleHandler()->moduleExists('block')) {
- $form['displays']['block'] = array(
+ $form['displays']['block'] = [
'#type' => 'fieldset',
'#title' => $this->t('Block settings'),
- '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')),
+ '#attributes' => ['class' => ['views-attachment', 'fieldset-no-legend']],
'#tree' => TRUE,
- );
- $form['displays']['block']['create'] = array(
+ ];
+ $form['displays']['block']['create'] = [
'#title' => $this->t('Create a block'),
'#type' => 'checkbox',
- '#attributes' => array('class' => array('strong')),
+ '#attributes' => ['class' => ['strong']],
'#id' => 'edit-block-create',
- );
+ ];
// All options for the block display are included in this container so
// they can be hidden as a group when the "Create a block" checkbox is
// unchecked.
- $form['displays']['block']['options'] = array(
+ $form['displays']['block']['options'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('options-set')),
- '#states' => array(
- 'visible' => array(
- ':input[name="block[create]"]' => array('checked' => TRUE),
- ),
- ),
+ '#attributes' => ['class' => ['options-set']],
+ '#states' => [
+ 'visible' => [
+ ':input[name="block[create]"]' => ['checked' => TRUE],
+ ],
+ ],
'#prefix' => '<div id="edit-block-wrapper">',
'#suffix' => '</div>',
- '#parents' => array('block'),
- );
+ '#parents' => ['block'],
+ ];
- $form['displays']['block']['options']['title'] = array(
+ $form['displays']['block']['options']['title'] = [
'#title' => $this->t('Block title'),
'#type' => 'textfield',
'#maxlength' => 255,
- );
- $form['displays']['block']['options']['style'] = array(
+ ];
+ $form['displays']['block']['options']['style'] = [
'#type' => 'fieldset',
'#title' => $this->t('Block display settings'),
- '#attributes' => array('class' => array('container-inline', 'fieldset-no-legend')),
- );
+ '#attributes' => ['class' => ['container-inline', 'fieldset-no-legend']],
+ ];
// Create the dropdown for choosing the display format.
- $form['displays']['block']['options']['style']['style_plugin'] = array(
+ $form['displays']['block']['options']['style']['style_plugin'] = [
'#title' => $this->t('Display format'),
'#type' => 'select',
'#options' => $style_options,
- );
+ ];
$style_form = &$form['displays']['block']['options']['style'];
- $style_form['style_plugin']['#default_value'] = static::getSelected($form_state, array('block', 'style', 'style_plugin'), 'default', $style_form['style_plugin']);
+ $style_form['style_plugin']['#default_value'] = static::getSelected($form_state, ['block', 'style', 'style_plugin'], 'default', $style_form['style_plugin']);
// Changing this dropdown updates $form['displays']['block']['options']
// via AJAX.
- views_ui_add_ajax_trigger($style_form, 'style_plugin', array('displays', 'block', 'options'));
+ views_ui_add_ajax_trigger($style_form, 'style_plugin', ['displays', 'block', 'options']);
$this->buildFormStyle($form, $form_state, 'block');
- $form['displays']['block']['options']['items_per_page'] = array(
+ $form['displays']['block']['options']['items_per_page'] = [
'#title' => $this->t('Items per block'),
'#type' => 'number',
'#default_value' => 5,
'#min' => 0,
- );
- $form['displays']['block']['options']['pager'] = array(
+ ];
+ $form['displays']['block']['options']['pager'] = [
'#title' => $this->t('Use a pager'),
'#type' => 'checkbox',
'#default_value' => FALSE,
- );
+ ];
}
// Only offer the REST export settings if the module is enabled.
if (\Drupal::moduleHandler()->moduleExists('rest')) {
- $form['displays']['rest_export'] = array(
+ $form['displays']['rest_export'] = [
'#type' => 'fieldset',
'#title' => $this->t('REST export settings'),
- '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')),
+ '#attributes' => ['class' => ['views-attachment', 'fieldset-no-legend']],
'#tree' => TRUE,
- );
- $form['displays']['rest_export']['create'] = array(
+ ];
+ $form['displays']['rest_export']['create'] = [
'#title' => $this->t('Provide a REST export'),
'#type' => 'checkbox',
- '#attributes' => array('class' => array('strong')),
+ '#attributes' => ['class' => ['strong']],
'#id' => 'edit-rest-export-create',
- );
+ ];
// All options for the REST export display are included in this container
// so they can be hidden as a group when the "Provide a REST export"
// checkbox is unchecked.
- $form['displays']['rest_export']['options'] = array(
+ $form['displays']['rest_export']['options'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('options-set')),
- '#states' => array(
- 'visible' => array(
- ':input[name="rest_export[create]"]' => array('checked' => TRUE),
- ),
- ),
+ '#attributes' => ['class' => ['options-set']],
+ '#states' => [
+ 'visible' => [
+ ':input[name="rest_export[create]"]' => ['checked' => TRUE],
+ ],
+ ],
'#prefix' => '<div id="edit-rest-export-wrapper">',
'#suffix' => '</div>',
- '#parents' => array('rest_export'),
- );
+ '#parents' => ['rest_export'],
+ ];
- $form['displays']['rest_export']['options']['path'] = array(
+ $form['displays']['rest_export']['options']['path'] = [
'#title' => $this->t('REST export path'),
'#type' => 'textfield',
'#field_prefix' => $path_prefix,
// Account for the leading backslash.
'#maxlength' => 254,
- );
+ ];
}
return $form;
@@ -561,28 +561,28 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$style_plugin = Views::pluginManager('style')->createInstance($style);
if (isset($style_plugin) && $style_plugin->usesRowPlugin()) {
$options = $this->rowStyleOptions();
- $style_form['row_plugin'] = array(
+ $style_form['row_plugin'] = [
'#type' => 'select',
'#title' => $this->t('of'),
'#options' => $options,
'#access' => count($options) > 1,
- );
+ ];
// For the block display, the default value should be "titles (linked)",
// if it's available (since that's the most common use case).
$block_with_linked_titles_available = ($type == 'block' && isset($options['titles_linked']));
$default_value = $block_with_linked_titles_available ? 'titles_linked' : key($options);
- $style_form['row_plugin']['#default_value'] = static::getSelected($form_state, array($type, 'style', 'row_plugin'), $default_value, $style_form['row_plugin']);
+ $style_form['row_plugin']['#default_value'] = static::getSelected($form_state, [$type, 'style', 'row_plugin'], $default_value, $style_form['row_plugin']);
// Changing this dropdown updates the individual row options via AJAX.
- views_ui_add_ajax_trigger($style_form, 'row_plugin', array('displays', $type, 'options', 'style', 'row_options'));
+ views_ui_add_ajax_trigger($style_form, 'row_plugin', ['displays', $type, 'options', 'style', 'row_options']);
// This is the region that can be updated by AJAX. The base class doesn't
// add anything here, but child classes can.
- $style_form['row_options'] = array(
- '#theme_wrappers' => array('container'),
- );
+ $style_form['row_options'] = [
+ '#theme_wrappers' => ['container'],
+ ];
}
elseif ($style_plugin->usesFields()) {
- $style_form['row_plugin'] = array('#markup' => '<span>' . $this->t('of fields') . '</span>');
+ $style_form['row_plugin'] = ['#markup' => '<span>' . $this->t('of fields') . '</span>'];
}
}
@@ -594,7 +594,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
*/
protected function rowStyleOptions() {
// Get all available row plugins by default.
- $options = Views::fetchPluginNames('row', 'normal', array($this->base_table));
+ $options = Views::fetchPluginNames('row', 'normal', [$this->base_table]);
return $options;
}
@@ -611,21 +611,21 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
// If the current base table support bundles and has more than one (like user).
if (!empty($bundles) && $this->entityType && $this->entityType->hasKey('bundle')) {
// Get all bundles and their human readable names.
- $options = array('all' => $this->t('All'));
+ $options = ['all' => $this->t('All')];
foreach ($bundles as $type => $bundle) {
$options[$type] = $bundle['label'];
}
- $form['displays']['show']['type'] = array(
+ $form['displays']['show']['type'] = [
'#type' => 'select',
'#title' => $this->t('of type'),
'#options' => $options,
- );
- $selected_bundle = static::getSelected($form_state, array('show', 'type'), 'all', $form['displays']['show']['type']);
+ ];
+ $selected_bundle = static::getSelected($form_state, ['show', 'type'], 'all', $form['displays']['show']['type']);
$form['displays']['show']['type']['#default_value'] = $selected_bundle;
// Changing this dropdown updates the entire content of $form['displays']
// via AJAX, since each bundle might have entirely different fields
// attached to it, etc.
- views_ui_add_ajax_trigger($form['displays']['show'], 'type', array('displays'));
+ views_ui_add_ajax_trigger($form['displays']['show'], 'type', ['displays']);
}
}
@@ -635,16 +635,16 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* By default, this adds a "sorted by [date]" filter (when it is available).
*/
protected function buildSorts(&$form, FormStateInterface $form_state) {
- $sorts = array(
+ $sorts = [
'none' => $this->t('Unsorted'),
- );
+ ];
// Check if we are allowed to sort by creation date.
$created_column = $this->getCreatedColumn();
if ($created_column) {
- $sorts += array(
+ $sorts += [
$created_column . ':DESC' => $this->t('Newest first'),
$created_column . ':ASC' => $this->t('Oldest first'),
- );
+ ];
}
if ($available_sorts = $this->getAvailableSorts()) {
$sorts += $available_sorts;
@@ -652,12 +652,12 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
// If there is no sorts option available continue.
if (!empty($sorts)) {
- $form['displays']['show']['sort'] = array(
+ $form['displays']['show']['sort'] = [
'#type' => 'select',
'#title' => $this->t('sorted by'),
'#options' => $sorts,
'#default_value' => isset($created_column) ? $created_column . ':DESC' : 'none',
- );
+ ];
}
}
@@ -669,13 +669,13 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
*/
protected function instantiateView($form, FormStateInterface $form_state) {
// Build the basic view properties and create the view.
- $values = array(
+ $values = [
'id' => $form_state->getValue('id'),
'label' => $form_state->getValue('label'),
'description' => $form_state->getValue('description'),
'base_table' => $this->base_table,
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
- );
+ ];
$view = View::create($values);
@@ -702,25 +702,25 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
protected function buildDisplayOptions($form, FormStateInterface $form_state) {
// Display: Master
$display_options['default'] = $this->defaultDisplayOptions();
- $display_options['default'] += array(
- 'filters' => array(),
- 'sorts' => array(),
- );
+ $display_options['default'] += [
+ 'filters' => [],
+ 'sorts' => [],
+ ];
$display_options['default']['filters'] += $this->defaultDisplayFilters($form, $form_state);
$display_options['default']['sorts'] += $this->defaultDisplaySorts($form, $form_state);
// Display: Page
- if (!$form_state->isValueEmpty(array('page', 'create'))) {
+ if (!$form_state->isValueEmpty(['page', 'create'])) {
$display_options['page'] = $this->pageDisplayOptions($form, $form_state);
// Display: Feed (attached to the page)
- if (!$form_state->isValueEmpty(array('page', 'feed'))) {
+ if (!$form_state->isValueEmpty(['page', 'feed'])) {
$display_options['feed'] = $this->pageFeedDisplayOptions($form, $form_state);
}
}
// Display: Block
- if (!$form_state->isValueEmpty(array('block', 'create'))) {
+ if (!$form_state->isValueEmpty(['block', 'create'])) {
$display_options['block'] = $this->blockDisplayOptions($form, $form_state);
}
@@ -812,7 +812,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* Returns an array of display options.
*/
protected function defaultDisplayOptions() {
- $display_options = array();
+ $display_options = [];
$display_options['access']['type'] = 'none';
$display_options['cache']['type'] = 'tag';
$display_options['query']['type'] = 'views_query';
@@ -823,7 +823,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
// Add default options array to each plugin type.
foreach ($display_options as &$options) {
- $options['options'] = array();
+ $options['options'] = [];
}
// Add a least one field so the view validates and the user has a preview.
@@ -849,14 +849,14 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
}
// @todo Refactor the code to use ViewExecutable::addHandler. See
// https://www.drupal.org/node/2383157.
- $display_options['fields'][$default_field] = array(
+ $display_options['fields'][$default_field] = [
'table' => $default_table,
'field' => $default_field,
'id' => $default_field,
'entity_type' => isset($data[$default_field]['entity type']) ? $data[$default_field]['entity type'] : NULL,
'entity_field' => isset($data[$default_field]['entity field']) ? $data[$default_field]['entity field'] : NULL,
'plugin_id' => $data[$default_field]['field']['id'],
- );
+ ];
return $display_options;
}
@@ -877,7 +877,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* accepted by a filter handler.
*/
protected function defaultDisplayFilters($form, FormStateInterface $form_state) {
- $filters = array();
+ $filters = [];
// Add any filters provided by the plugin.
foreach ($this->getFilters() as $name => $info) {
@@ -903,9 +903,9 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* accepted by a filter handler.
*/
protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) {
- $filters = array();
+ $filters = [];
- if (($type = $form_state->getValue(array('show', 'type'))) && $type != 'all') {
+ if (($type = $form_state->getValue(['show', 'type'])) && $type != 'all') {
$bundle_key = $this->entityType->getKey('bundle');
// Figure out the table where $bundle_key lives. It may not be the same as
// the base table for the view; the taxonomy vocabulary machine_name, for
@@ -928,14 +928,14 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$handler = $table_data[$bundle_key]['filter']['id'];
$handler_definition = Views::pluginManager('filter')->getDefinition($handler);
if ($handler == 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) {
- $value = array($type => $type);
+ $value = [$type => $type];
}
// Otherwise, use just a single value.
else {
$value = $type;
}
- $filters[$bundle_key] = array(
+ $filters[$bundle_key] = [
'id' => $bundle_key,
'table' => $table,
'field' => $bundle_key,
@@ -943,7 +943,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
'entity_type' => isset($table_data['table']['entity type']) ? $table_data['table']['entity type'] : NULL,
'entity_field' => isset($table_data[$bundle_key]['entity field']) ? $table_data[$bundle_key]['entity field'] : NULL,
'plugin_id' => $handler,
- );
+ ];
}
return $filters;
@@ -965,7 +965,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* accepted by a sort handler.
*/
protected function defaultDisplaySorts($form, FormStateInterface $form_state) {
- $sorts = array();
+ $sorts = [];
// Add any sorts provided by the plugin.
foreach ($this->getSorts() as $name => $info) {
@@ -991,11 +991,11 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* accepted by a sort handler.
*/
protected function defaultDisplaySortsUser($form, FormStateInterface $form_state) {
- $sorts = array();
+ $sorts = [];
// Don't add a sort if there is no form value or the user set the sort to
// 'none'.
- if (($sort_type = $form_state->getValue(array('show', 'sort'))) && $sort_type != 'none') {
+ if (($sort_type = $form_state->getValue(['show', 'sort'])) && $sort_type != 'none') {
list($column, $sort) = explode(':', $sort_type);
// Column either be a column-name or the table-column-name.
$column = explode('-', $column);
@@ -1014,7 +1014,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
// enabled.
$data = Views::viewsData()->get($table);
if (isset($data[$column]['sort'])) {
- $sorts[$column] = array(
+ $sorts[$column] = [
'id' => $column,
'table' => $table,
'field' => $column,
@@ -1022,7 +1022,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
'entity_type' => isset($data['table']['entity type']) ? $data['table']['entity type'] : NULL,
'entity_field' => isset($data[$column]['entity field']) ? $data[$column]['entity field'] : NULL,
'plugin_id' => $data[$column]['sort']['id'],
- );
+ ];
}
}
@@ -1041,15 +1041,15 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* Returns an array of display options.
*/
protected function pageDisplayOptions(array $form, FormStateInterface $form_state) {
- $display_options = array();
+ $display_options = [];
$page = $form_state->getValue('page');
$display_options['title'] = $page['title'];
$display_options['path'] = $page['path'];
- $display_options['style'] = array('type' => $page['style']['style_plugin']);
+ $display_options['style'] = ['type' => $page['style']['style_plugin']];
// Not every style plugin supports row style plugins.
// Make sure that the selected row plugin is a valid one.
$options = $this->rowStyleOptions();
- $display_options['row'] = array('type' => (isset($page['style']['row_plugin']) && isset($options[$page['style']['row_plugin']])) ? $page['style']['row_plugin'] : 'fields');
+ $display_options['row'] = ['type' => (isset($page['style']['row_plugin']) && isset($options[$page['style']['row_plugin']])) ? $page['style']['row_plugin'] : 'fields'];
// If the specific 0 items per page, use no pager.
if (empty($page['items_per_page'])) {
@@ -1087,12 +1087,12 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* Returns an array of display options.
*/
protected function blockDisplayOptions(array $form, FormStateInterface $form_state) {
- $display_options = array();
+ $display_options = [];
$block = $form_state->getValue('block');
$display_options['title'] = $block['title'];
- $display_options['style'] = array('type' => $block['style']['style_plugin']);
+ $display_options['style'] = ['type' => $block['style']['style_plugin']];
$options = $this->rowStyleOptions();
- $display_options['row'] = array('type' => (isset($block['style']['row_plugin']) && isset($options[$block['style']['row_plugin']])) ? $block['style']['row_plugin'] : 'fields');
+ $display_options['row'] = ['type' => (isset($block['style']['row_plugin']) && isset($options[$block['style']['row_plugin']])) ? $block['style']['row_plugin'] : 'fields'];
$display_options['pager']['type'] = $block['pager'] ? 'full' : (empty($block['items_per_page']) ? 'none' : 'some');
$display_options['pager']['options']['items_per_page'] = $block['items_per_page'];
return $display_options;
@@ -1110,9 +1110,9 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* Returns an array of display options.
*/
protected function restExportDisplayOptions(array $form, FormStateInterface $form_state) {
- $display_options = array();
+ $display_options = [];
$display_options['path'] = $form_state->getValue(['rest_export', 'path']);
- $display_options['style'] = array('type' => 'serializer');
+ $display_options['style'] = ['type' => 'serializer'];
return $display_options;
}
@@ -1129,16 +1129,16 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
* Returns an array of display options.
*/
protected function pageFeedDisplayOptions($form, FormStateInterface $form_state) {
- $display_options = array();
+ $display_options = [];
$display_options['pager']['type'] = 'some';
- $display_options['style'] = array('type' => 'rss');
- $display_options['row'] = array('type' => $form_state->getValue(array('page', 'feed_properties', 'row_plugin')));
- $display_options['path'] = $form_state->getValue(array('page', 'feed_properties', 'path'));
- $display_options['title'] = $form_state->getValue(array('page', 'title'));
- $display_options['displays'] = array(
+ $display_options['style'] = ['type' => 'rss'];
+ $display_options['row'] = ['type' => $form_state->getValue(['page', 'feed_properties', 'row_plugin'])];
+ $display_options['path'] = $form_state->getValue(['page', 'feed_properties', 'path']);
+ $display_options['title'] = $form_state->getValue(['page', 'title']);
+ $display_options['displays'] = [
'default' => 'default',
'page_1' => 'page_1',
- );
+ ];
return $display_options;
}
diff --git a/core/modules/views/src/ResultRow.php b/core/modules/views/src/ResultRow.php
index 39febcf6d1e..da55038fc98 100644
--- a/core/modules/views/src/ResultRow.php
+++ b/core/modules/views/src/ResultRow.php
@@ -34,7 +34,7 @@ class ResultRow {
* @param array $values
* (optional) An array of values to add as properties on the object.
*/
- public function __construct(array $values = array()) {
+ public function __construct(array $values = []) {
foreach ($values as $key => $value) {
$this->{$key} = $value;
}
diff --git a/core/modules/views/src/Routing/ViewPageController.php b/core/modules/views/src/Routing/ViewPageController.php
index dc9153c4bfa..772103d3786 100644
--- a/core/modules/views/src/Routing/ViewPageController.php
+++ b/core/modules/views/src/Routing/ViewPageController.php
@@ -22,9 +22,9 @@ class ViewPageController {
* @return null|void
*/
public function handle($view_id, $display_id, RouteMatchInterface $route_match) {
- $args = array();
+ $args = [];
$route = $route_match->getRouteObject();
- $map = $route->hasOption('_view_argument_map') ? $route->getOption('_view_argument_map') : array();
+ $map = $route->hasOption('_view_argument_map') ? $route->getOption('_view_argument_map') : [];
foreach ($map as $attribute => $parameter_name) {
// Allow parameters be pulled from the request.
diff --git a/core/modules/views/src/Tests/DefaultViewsTest.php b/core/modules/views/src/Tests/DefaultViewsTest.php
index 5c1f601b20a..e5349ab4d1e 100644
--- a/core/modules/views/src/Tests/DefaultViewsTest.php
+++ b/core/modules/views/src/Tests/DefaultViewsTest.php
@@ -29,18 +29,18 @@ class DefaultViewsTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('views', 'node', 'search', 'comment', 'taxonomy', 'block', 'user');
+ public static $modules = ['views', 'node', 'search', 'comment', 'taxonomy', 'block', 'user'];
/**
* An array of argument arrays to use for default views.
*
* @var array
*/
- protected $viewArgMap = array(
- 'backlinks' => array(1),
- 'taxonomy_term' => array(1),
- 'glossary' => array('all'),
- );
+ protected $viewArgMap = [
+ 'backlinks' => [1],
+ 'taxonomy_term' => [1],
+ 'glossary' => ['all'],
+ ];
protected function setUp() {
parent::setUp();
@@ -48,7 +48,7 @@ class DefaultViewsTest extends ViewTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create Basic page node type.
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$vocabulary = Vocabulary::create([
'name' => $this->randomMachineName(),
@@ -56,7 +56,7 @@ class DefaultViewsTest extends ViewTestBase {
'vid' => Unicode::strtolower($this->randomMachineName()),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'help' => '',
- 'nodes' => array('page' => 'page'),
+ 'nodes' => ['page' => 'page'],
'weight' => mt_rand(0, 10),
]);
$vocabulary->save();
@@ -64,12 +64,12 @@ class DefaultViewsTest extends ViewTestBase {
// Create a field.
$field_name = Unicode::strtolower($this->randomMachineName());
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'page', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
// Create a time in the past for the archive.
@@ -81,7 +81,7 @@ class DefaultViewsTest extends ViewTestBase {
$user = $this->drupalCreateUser();
$term = $this->createTerm($vocabulary);
- $values = array('created' => $time, 'type' => 'page');
+ $values = ['created' => $time, 'type' => 'page'];
$values[$field_name][]['target_id'] = $term->id();
// Make every other node promoted.
@@ -92,19 +92,19 @@ class DefaultViewsTest extends ViewTestBase {
$node = $this->drupalCreateNode($values);
- $comment = array(
+ $comment = [
'uid' => $user->id(),
'status' => CommentInterface::PUBLISHED,
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment'
- );
+ ];
Comment::create($comment)->save();
}
// Some views, such as the "Who's Online" view, only return results if at
// least one user is logged in.
- $account = $this->drupalCreateUser(array());
+ $account = $this->drupalCreateUser([]);
$this->drupalLogin($account);
}
@@ -127,14 +127,14 @@ class DefaultViewsTest extends ViewTestBase {
$view->preExecute($this->viewArgMap[$name]);
}
- $this->assert(TRUE, format_string('View @view will be executed.', array('@view' => $view->storage->id())));
+ $this->assert(TRUE, format_string('View @view will be executed.', ['@view' => $view->storage->id()]));
$view->execute();
- $tokens = array('@name' => $name, '@display_id' => $display_id);
+ $tokens = ['@name' => $name, '@display_id' => $display_id];
$this->assertTrue($view->executed, format_string('@name:@display_id has been executed.', $tokens));
$count = count($view->result);
- $this->assertTrue($count > 0, format_string('@count results returned', array('@count' => $count)));
+ $this->assertTrue($count > 0, format_string('@count results returned', ['@count' => $count]));
$view->destroy();
}
}
@@ -164,49 +164,49 @@ class DefaultViewsTest extends ViewTestBase {
public function testArchiveView() {
// Create additional nodes compared to the one in the setup method.
// Create two nodes in the same month, and one in each following month.
- $node = array(
+ $node = [
'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT
- );
+ ];
$this->drupalCreateNode($node);
$this->drupalCreateNode($node);
- $node = array(
+ $node = [
'created' => 282891600, // Tue, 19 Dec 1978 05:00:00 GMT
- );
+ ];
$this->drupalCreateNode($node);
- $node = array(
+ $node = [
'created' => 285570000, // Fri, 19 Jan 1979 05:00:00 GMT
- );
+ ];
$this->drupalCreateNode($node);
$view = Views::getView('archive');
$view->setDisplay('page_1');
$this->executeView($view);
- $columns = array('nid', 'created_year_month', 'num_records');
+ $columns = ['nid', 'created_year_month', 'num_records'];
$column_map = array_combine($columns, $columns);
// Create time of additional nodes created in the setup method.
$created_year_month = date('Ym', REQUEST_TIME - 3600);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'nid' => 1,
'created_year_month' => $created_year_month,
'num_records' => 11,
- ),
- array(
+ ],
+ [
'nid' => 15,
'created_year_month' => 197901,
'num_records' => 1,
- ),
- array(
+ ],
+ [
'nid' => 14,
'created_year_month' => 197812,
'num_records' => 1,
- ),
- array(
+ ],
+ [
'nid' => 12,
'created_year_month' => 197811,
'num_records' => 2,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $column_map);
$view->storage->setStatus(TRUE);
diff --git a/core/modules/views/src/Tests/Entity/BaseFieldAccessTest.php b/core/modules/views/src/Tests/Entity/BaseFieldAccessTest.php
index db1110d4784..698a43e79f8 100644
--- a/core/modules/views/src/Tests/Entity/BaseFieldAccessTest.php
+++ b/core/modules/views/src/Tests/Entity/BaseFieldAccessTest.php
@@ -18,7 +18,7 @@ class BaseFieldAccessTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_test_protected_access');
+ public static $testViews = ['test_entity_test_protected_access'];
/**
* Modules to enable
@@ -38,7 +38,7 @@ class BaseFieldAccessTest extends ViewTestBase {
$update_manager = $this->container->get('entity.definition_update_manager');
\Drupal::entityManager()->clearCachedDefinitions();
$update_manager->applyUpdates();
- ViewTestData::createTestViews(get_class($this), array('comment_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
\Drupal::state()->set('entity_test.views_data', [
'entity_test' => [
'test_text_access' => [
diff --git a/core/modules/views/src/Tests/Entity/FieldEntityTest.php b/core/modules/views/src/Tests/Entity/FieldEntityTest.php
index 215b631ba9f..89f71edf0c3 100644
--- a/core/modules/views/src/Tests/Entity/FieldEntityTest.php
+++ b/core/modules/views/src/Tests/Entity/FieldEntityTest.php
@@ -24,14 +24,14 @@ class FieldEntityTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_field_get_entity');
+ public static $testViews = ['test_field_get_entity'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'comment');
+ public static $modules = ['node', 'comment'];
/**
* {@inheritdoc}
@@ -39,10 +39,10 @@ class FieldEntityTest extends ViewTestBase {
protected function setUp($import_test_views = TRUE) {
parent::setUp(FALSE);
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
$this->addDefaultCommentField('node', 'page');
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
}
/**
@@ -61,12 +61,12 @@ class FieldEntityTest extends ViewTestBase {
'title' => $this->randomString(),
]);
$node->save();
- $comment = Comment::create(array(
+ $comment = Comment::create([
'uid' => $account->id(),
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment'
- ));
+ ]);
$comment->save();
$user = $this->drupalCreateUser(['access comments']);
diff --git a/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php b/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php
index 589c4dc02f5..f099569b80b 100644
--- a/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php
+++ b/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php
@@ -19,14 +19,14 @@ class FilterEntityBundleTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_type_filter');
+ public static $testViews = ['test_entity_type_filter'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Entity bundle data.
@@ -40,15 +40,15 @@ class FilterEntityBundleTest extends ViewTestBase {
*
* @var array
*/
- protected $entities = array();
+ protected $entities = [];
protected function setUp() {
parent::setUp(FALSE);
- $this->drupalCreateContentType(array('type' => 'test_bundle'));
- $this->drupalCreateContentType(array('type' => 'test_bundle_2'));
+ $this->drupalCreateContentType(['type' => 'test_bundle']);
+ $this->drupalCreateContentType(['type' => 'test_bundle_2']);
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
$this->entityBundles = $this->container->get('entity_type.bundle.info')->getBundleInfo('node');
@@ -92,7 +92,7 @@ class FilterEntityBundleTest extends ViewTestBase {
$this->assertEqual(count($view->result), $this->entities['count']);
// Test the valueOptions of the filter handler.
- $expected = array();
+ $expected = [];
foreach ($this->entityBundles as $key => $info) {
$expected[$key] = $info['label'];
@@ -106,7 +106,7 @@ class FilterEntityBundleTest extends ViewTestBase {
// Test each bundle type.
$view->initDisplay();
$filters = $view->display_handler->getOption('filters');
- $filters['type']['value'] = array($key => $key);
+ $filters['type']['value'] = [$key => $key];
$view->display_handler->setOption('filters', $filters);
$this->executeView($view);
@@ -118,7 +118,7 @@ class FilterEntityBundleTest extends ViewTestBase {
// Test an invalid bundle type to make sure we have no results.
$view->initDisplay();
$filters = $view->display_handler->getOption('filters');
- $filters['type']['value'] = array('type_3' => 'type_3');
+ $filters['type']['value'] = ['type_3' => 'type_3'];
$view->display_handler->setOption('filters', $filters);
$this->executeView($view);
diff --git a/core/modules/views/src/Tests/Entity/ViewNonTranslatableEntityTest.php b/core/modules/views/src/Tests/Entity/ViewNonTranslatableEntityTest.php
index df6f7d4da5f..82c683995cf 100644
--- a/core/modules/views/src/Tests/Entity/ViewNonTranslatableEntityTest.php
+++ b/core/modules/views/src/Tests/Entity/ViewNonTranslatableEntityTest.php
@@ -18,12 +18,12 @@ class ViewNonTranslatableEntityTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'entity_test',
'content_translation',
'language_test',
'views_ui',
- );
+ ];
/**
* Tests displaying a view of non-translatable entities.
diff --git a/core/modules/views/src/Tests/FieldApiDataTest.php b/core/modules/views/src/Tests/FieldApiDataTest.php
index 3fd8a03fa35..24b2cf30e0b 100644
--- a/core/modules/views/src/Tests/FieldApiDataTest.php
+++ b/core/modules/views/src/Tests/FieldApiDataTest.php
@@ -19,12 +19,12 @@ class FieldApiDataTest extends FieldTestBase {
$field_names = $this->setUpFieldStorages(1);
// Attach the field to nodes only.
- $field = array(
+ $field = [
'field_name' => $field_names[0],
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'GiraffeA" label'
- );
+ ];
FieldConfig::create($field)->save();
// Attach the same field to a different bundle with a different label.
@@ -38,9 +38,9 @@ class FieldApiDataTest extends FieldTestBase {
// Now create some example nodes/users for the view result.
for ($i = 0; $i < 5; $i++) {
- $edit = array(
- $field_names[0] => array((array('value' => $this->randomMachineName()))),
- );
+ $edit = [
+ $field_names[0] => [(['value' => $this->randomMachineName()])],
+ ];
$nodes[] = $this->drupalCreateNode($edit);
}
}
@@ -63,25 +63,25 @@ class FieldApiDataTest extends FieldTestBase {
$this->assertTrue(isset($data[$current_table]['table']['join']['node_field_data']));
$this->assertTrue(isset($data[$revision_table]['table']['join']['node_field_revision']));
- $expected_join = array(
+ $expected_join = [
'table' => $current_table,
'left_field' => 'nid',
'field' => 'entity_id',
- 'extra' => array(
- array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
- array('left_field' => 'langcode', 'field' => 'langcode'),
- ),
- );
+ 'extra' => [
+ ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
+ ['left_field' => 'langcode', 'field' => 'langcode'],
+ ],
+ ];
$this->assertEqual($expected_join, $data[$current_table]['table']['join']['node_field_data']);
- $expected_join = array(
+ $expected_join = [
'table' => $revision_table,
'left_field' => 'vid',
'field' => 'revision_id',
- 'extra' => array(
- array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
- array('left_field' => 'langcode', 'field' => 'langcode'),
- ),
- );
+ 'extra' => [
+ ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
+ ['left_field' => 'langcode', 'field' => 'langcode'],
+ ],
+ ];
$this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_field_revision']);
// Test click sortable.
@@ -124,7 +124,7 @@ class FieldApiDataTest extends FieldTestBase {
*/
protected function getViewsData() {
$views_data = $this->container->get('views.views_data');
- $data = array();
+ $data = [];
// Check the table and the joins of the first field.
// Attached to node only.
diff --git a/core/modules/views/src/Tests/GlossaryTest.php b/core/modules/views/src/Tests/GlossaryTest.php
index 2a5bc907c6e..b1657687dfd 100644
--- a/core/modules/views/src/Tests/GlossaryTest.php
+++ b/core/modules/views/src/Tests/GlossaryTest.php
@@ -21,7 +21,7 @@ class GlossaryTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Tests the default glossary view.
@@ -29,19 +29,19 @@ class GlossaryTest extends ViewTestBase {
public function testGlossaryView() {
// Create a content type and add some nodes, with a non-random title.
$type = $this->drupalCreateContentType();
- $nodes_per_char = array(
+ $nodes_per_char = [
'd' => 1,
'r' => 4,
'u' => 10,
'p' => 2,
'a' => 3,
'l' => 6,
- );
+ ];
$nodes_by_char = [];
foreach ($nodes_per_char as $char => $count) {
- $setting = array(
+ $setting = [
'type' => $type->id()
- );
+ ];
for ($i = 0; $i < $count; $i++) {
$node = $setting;
$node['title'] = $char . $this->randomString(3);
@@ -111,10 +111,10 @@ class GlossaryTest extends ViewTestBase {
$label = Unicode::strtoupper($char);
// Get the summary link for a certain character. Filter by label and href
// to ensure that both of them are correct.
- $result = $this->xpath('//a[contains(@href, :href) and normalize-space(text())=:label]/..', array(':href' => $href, ':label' => $label));
+ $result = $this->xpath('//a[contains(@href, :href) and normalize-space(text())=:label]/..', [':href' => $href, ':label' => $label]);
$this->assertTrue(count($result));
// The rendered output looks like "| (count)" so let's figure out the int.
- $result_count = trim(str_replace(array('|', '(', ')'), '', (string) $result[0]));
+ $result_count = trim(str_replace(['|', '(', ')'], '', (string) $result[0]));
$this->assertEqual($result_count, $count, 'The expected number got rendered.');
}
}
diff --git a/core/modules/views/src/Tests/Handler/AreaHTTPStatusCodeTest.php b/core/modules/views/src/Tests/Handler/AreaHTTPStatusCodeTest.php
index 86d1f992a93..2656adc4dcd 100644
--- a/core/modules/views/src/Tests/Handler/AreaHTTPStatusCodeTest.php
+++ b/core/modules/views/src/Tests/Handler/AreaHTTPStatusCodeTest.php
@@ -17,14 +17,14 @@ class AreaHTTPStatusCodeTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_http_status_code');
+ public static $testViews = ['test_http_status_code'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Tests the area handler.
diff --git a/core/modules/views/src/Tests/Handler/AreaTest.php b/core/modules/views/src/Tests/Handler/AreaTest.php
index 454ab58d0eb..ca9fc422dcb 100644
--- a/core/modules/views/src/Tests/Handler/AreaTest.php
+++ b/core/modules/views/src/Tests/Handler/AreaTest.php
@@ -19,14 +19,14 @@ class AreaTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_example_area', 'test_example_area_access');
+ public static $testViews = ['test_example_area', 'test_example_area_access'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'views_ui');
+ public static $modules = ['node', 'views_ui'];
protected function setUp() {
parent::setUp();
@@ -36,13 +36,13 @@ class AreaTest extends HandlerTestBase {
protected function viewsData() {
$data = parent::viewsData();
- $data['views']['test_example'] = array(
+ $data['views']['test_example'] = [
'title' => 'Test Example area',
'help' => 'A area handler which just exists for tests.',
- 'area' => array(
+ 'area' => [
'id' => 'test_example'
- )
- );
+ ]
+ ];
return $data;
}
@@ -52,21 +52,21 @@ class AreaTest extends HandlerTestBase {
* Tests the generic UI of a area handler.
*/
public function testUI() {
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
- $types = array('header', 'footer', 'empty');
- $labels = array();
+ $types = ['header', 'footer', 'empty'];
+ $labels = [];
foreach ($types as $type) {
$edit_path = 'admin/structure/views/nojs/handler/test_example_area/default/' . $type . '/test_example';
// First setup an empty label.
- $this->drupalPostForm($edit_path, array(), t('Apply'));
+ $this->drupalPostForm($edit_path, [], t('Apply'));
$this->assertText('Test Example area');
// Then setup a no empty label.
$labels[$type] = $this->randomMachineName();
- $this->drupalPostForm($edit_path, array('options[admin_label]' => $labels[$type]), t('Apply'));
+ $this->drupalPostForm($edit_path, ['options[admin_label]' => $labels[$type]], t('Apply'));
// Make sure that the new label appears on the site.
$this->assertText($labels[$type]);
@@ -188,7 +188,7 @@ class AreaTest extends HandlerTestBase {
* Tests global tokens.
*/
public function testRenderAreaToken() {
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
$view = Views::getView('test_example_area');
@@ -204,7 +204,7 @@ class AreaTest extends HandlerTestBase {
// Test the list of available tokens.
$available = $empty_handler->getAvailableGlobalTokens();
- foreach (array('site', 'view') as $type) {
+ foreach (['site', 'view'] as $type) {
$this->assertTrue(!empty($available[$type]) && is_array($available[$type]));
// Test that each item exists in the list.
foreach ($available[$type] as $token => $info) {
@@ -230,8 +230,8 @@ class AreaTest extends HandlerTestBase {
$view->initDisplay('page_1');
// Add the title area handler to the empty area.
- $view->displayHandlers->get('page_1')->overrideOption('empty', array(
- 'title' => array(
+ $view->displayHandlers->get('page_1')->overrideOption('empty', [
+ 'title' => [
'id' => 'title',
'table' => 'views',
'field' => 'title',
@@ -239,8 +239,8 @@ class AreaTest extends HandlerTestBase {
'empty' => '0',
'title' => 'Overridden title',
'plugin_id' => 'title',
- ),
- ));
+ ],
+ ]);
$view->storage->enable()->save();
diff --git a/core/modules/views/src/Tests/Handler/ArgumentStringTest.php b/core/modules/views/src/Tests/Handler/ArgumentStringTest.php
index e47b1a362fc..9d83fad572f 100644
--- a/core/modules/views/src/Tests/Handler/ArgumentStringTest.php
+++ b/core/modules/views/src/Tests/Handler/ArgumentStringTest.php
@@ -16,14 +16,14 @@ class ArgumentStringTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_glossary');
+ public static $testViews = ['test_glossary'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Tests the glossary feature.
@@ -31,11 +31,11 @@ class ArgumentStringTest extends HandlerTestBase {
function testGlossary() {
// Setup some nodes, one with a, two with b and three with c.
$counter = 1;
- foreach (array('a', 'b', 'c') as $char) {
+ foreach (['a', 'b', 'c'] as $char) {
for ($i = 0; $i < $counter; $i++) {
- $edit = array(
+ $edit = [
'title' => $char . $this->randomMachineName(),
- );
+ ];
$this->drupalCreateNode($edit);
}
}
diff --git a/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php b/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php
index f2082f0a2f7..9d5c67fa752 100644
--- a/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php
@@ -15,14 +15,14 @@ class FieldDropButtonTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_dropbutton');
+ public static $testViews = ['test_dropbutton'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* {@inheritdoc}
@@ -39,16 +39,16 @@ class FieldDropButtonTest extends HandlerTestBase {
*/
public function testDropbutton() {
// Create some test nodes.
- $nodes = array();
+ $nodes = [];
for ($i = 0; $i < 5; $i++) {
$nodes[] = $this->drupalCreateNode();
}
$this->drupalGet('test-dropbutton');
foreach ($nodes as $node) {
- $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/node/' . $node->id(), ':title' => $node->label()));
+ $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', [':path' => '/node/' . $node->id(), ':title' => $node->label()]);
$this->assertEqual(count($result), 1, 'Just one node title link was found.');
- $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/node/' . $node->id(), ':title' => t('Custom Text')));
+ $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', [':path' => '/node/' . $node->id(), ':title' => t('Custom Text')]);
$this->assertEqual(count($result), 1, 'Just one custom link was found.');
}
diff --git a/core/modules/views/src/Tests/Handler/FieldEntityOperationsTest.php b/core/modules/views/src/Tests/Handler/FieldEntityOperationsTest.php
index e76d54e34b2..57544b5c66f 100644
--- a/core/modules/views/src/Tests/Handler/FieldEntityOperationsTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldEntityOperationsTest.php
@@ -18,14 +18,14 @@ class FieldEntityOperationsTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_operations');
+ public static $testViews = ['test_entity_operations'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'language', 'views_ui');
+ public static $modules = ['node', 'language', 'views_ui'];
function setUp() {
parent::setUp();
@@ -46,7 +46,7 @@ class FieldEntityOperationsTest extends HandlerTestBase {
// Create some test entities. Every other entity is Hungarian while all
// have a Spanish translation.
- $entities = array();
+ $entities = [];
for ($i = 0; $i < 5; $i++) {
$entity = Node::create([
'title' => $this->randomString(),
@@ -60,7 +60,7 @@ class FieldEntityOperationsTest extends HandlerTestBase {
$entities[$i] = $entity;
}
- $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer nodes', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access administration pages', 'administer nodes', 'bypass node access']);
$this->drupalLogin($this->rootUser);
$this->drupalGet('test-entity-operations');
/** @var $entity \Drupal\entity_test\Entity\EntityTest */
@@ -72,8 +72,8 @@ class FieldEntityOperationsTest extends HandlerTestBase {
$this->assertTrue(count($operations) > 0, 'There are operations.');
foreach ($operations as $operation) {
$expected_destination = Url::fromUri('internal:/test-entity-operations')->toString();
- $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[@href=:path and text()=:title]', array(':path' => $operation['url']->toString() . '?destination=' . $expected_destination, ':title' => $operation['title']));
- $this->assertEqual(count($result), 1, t('Found entity @operation link with destination parameter.', array('@operation' => $operation['title'])));
+ $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[@href=:path and text()=:title]', [':path' => $operation['url']->toString() . '?destination=' . $expected_destination, ':title' => $operation['title']]);
+ $this->assertEqual(count($result), 1, t('Found entity @operation link with destination parameter.', ['@operation' => $operation['title']]));
// Entities which were created in Hungarian should link to the Hungarian
// edit form, others to the English one (which has no path prefix here).
$base_path = \Drupal::request()->getBasePath();
diff --git a/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php b/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php
index 87203613ac6..2521e6329e7 100644
--- a/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php
@@ -22,14 +22,14 @@ class FieldGroupRowsTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_group_rows', 'test_ungroup_rows');
+ public static $testViews = ['test_group_rows', 'test_ungroup_rows'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'field_test');
+ public static $modules = ['node', 'field_test'];
/**
* Field that will be created to test the group/ungroup rows functionality
@@ -42,22 +42,22 @@ class FieldGroupRowsTest extends HandlerTestBase {
parent::setUp();
// Create content type with unlimited text field.
- $node_type = $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
+ $node_type = $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create the unlimited text field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
- ));
+ ]);
$field_storage->save();
// Create an instance of the text field on the content type.
- $field = array(
+ $field = [
'field_storage' => $field_storage,
'bundle' => $node_type->id(),
- );
+ ];
FieldConfig::create($field)->save();
}
@@ -68,10 +68,10 @@ class FieldGroupRowsTest extends HandlerTestBase {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
- $edit = array(
+ $edit = [
'title' => $this->randomMachineName(),
- $this->fieldName => array('a', 'b', 'c'),
- );
+ $this->fieldName => ['a', 'b', 'c'],
+ ];
$this->drupalCreateNode($edit);
$view = Views::getView('test_group_rows');
diff --git a/core/modules/views/src/Tests/Handler/FieldWebTest.php b/core/modules/views/src/Tests/Handler/FieldWebTest.php
index e85206985a9..31de7be7e62 100644
--- a/core/modules/views/src/Tests/Handler/FieldWebTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldWebTest.php
@@ -25,7 +25,7 @@ class FieldWebTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_field_classes', 'test_field_output', 'test_click_sort');
+ public static $testViews = ['test_view', 'test_field_classes', 'test_field_output', 'test_click_sort'];
/**
* {@inheritdoc}
@@ -37,9 +37,9 @@ class FieldWebTest extends HandlerTestBase {
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
- );
+ ];
protected function setUp() {
parent::setUp();
@@ -97,7 +97,7 @@ class FieldWebTest extends HandlerTestBase {
*/
protected function clickSortLoadIdsFromOutput() {
$fields = $this->xpath("//td[contains(@class, 'views-field-id')]");
- $ids = array();
+ $ids = [];
foreach ($fields as $field) {
$ids[] = (int) $field[0];
}
@@ -174,14 +174,14 @@ class FieldWebTest extends HandlerTestBase {
* format and return values see the SimpleXML documentation,
* http://php.net/manual/function.simplexml-element-xpath.php.
*/
- protected function xpathContent($content, $xpath, array $arguments = array()) {
+ protected function xpathContent($content, $xpath, array $arguments = []) {
if ($elements = $this->parseContent($content)) {
$xpath = $this->buildXPathQuery($xpath, $arguments);
$result = $elements->xpath($xpath);
// Some combinations of PHP / libxml versions return an empty array
// instead of the documented FALSE. Forcefully convert any falsish values
// to an empty array to allow foreach(...) constructions.
- return $result ? $result : array();
+ return $result ? $result : [];
}
else {
return FALSE;
@@ -224,7 +224,7 @@ class FieldWebTest extends HandlerTestBase {
// Some generic test code adapted from the UrlTest class, which tests
// mostly the different options for the path.
- foreach (array(FALSE, TRUE) as $absolute) {
+ foreach ([FALSE, TRUE] as $absolute) {
$alter = &$id_field->options['alter'];
$alter['path'] = 'node/123';
@@ -258,7 +258,7 @@ class FieldWebTest extends HandlerTestBase {
// @todo The route-based URL generator strips out NULL attributes.
// $expected_result = \Drupal::url('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute]);
- $expected_result = Url::fromUserInput('/node/123', array('query' => array('foo' => NULL), 'fragment' => 'bar', 'absolute' => $absolute))->toString();
+ $expected_result = Url::fromUserInput('/node/123', ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute])->toString();
$alter['path'] = 'node/123?foo#bar';
$result = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
@@ -345,7 +345,7 @@ class FieldWebTest extends HandlerTestBase {
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
- $elements = $this->xpathContent($output, '//a[contains(@class, :class)]', array(':class' => $class));
+ $elements = $this->xpathContent($output, '//a[contains(@class, :class)]', [':class' => $class]);
$this->assertTrue($elements);
// @fixme link_class, alt, rel cannot be unset, which should be fixed.
$id_field->options['alter']['link_class'] = '';
@@ -355,7 +355,7 @@ class FieldWebTest extends HandlerTestBase {
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
- $elements = $this->xpathContent($output, '//a[contains(@title, :alt)]', array(':alt' => $rel));
+ $elements = $this->xpathContent($output, '//a[contains(@title, :alt)]', [':alt' => $rel]);
$this->assertTrue($elements);
$id_field->options['alter']['alt'] = '';
@@ -364,7 +364,7 @@ class FieldWebTest extends HandlerTestBase {
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
- $elements = $this->xpathContent($output, '//a[contains(@rel, :rel)]', array(':rel' => $rel));
+ $elements = $this->xpathContent($output, '//a[contains(@rel, :rel)]', [':rel' => $rel]);
$this->assertTrue($elements);
$id_field->options['alter']['rel'] = '';
@@ -373,7 +373,7 @@ class FieldWebTest extends HandlerTestBase {
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
- $elements = $this->xpathContent($output, '//a[contains(@target, :target)]', array(':target' => $target));
+ $elements = $this->xpathContent($output, '//a[contains(@target, :target)]', [':target' => $target]);
$this->assertTrue($elements);
unset($id_field->options['alter']['target']);
}
@@ -395,81 +395,81 @@ class FieldWebTest extends HandlerTestBase {
$id_field->options['label'] = $this->randomMachineName();
$output = $view->preview();
$output = $renderer->renderRoot($output);
- $this->assertFalse($this->xpathContent($output, '//div[contains(@class, :class)]', array(':class' => 'field-content')));
- $this->assertFalse($this->xpathContent($output, '//div[contains(@class, :class)]', array(':class' => 'field__label')));
+ $this->assertFalse($this->xpathContent($output, '//div[contains(@class, :class)]', [':class' => 'field-content']));
+ $this->assertFalse($this->xpathContent($output, '//div[contains(@class, :class)]', [':class' => 'field__label']));
$id_field->options['element_default_classes'] = TRUE;
$output = $view->preview();
$output = $renderer->renderRoot($output);
// Per default the label and the element of the field are spans.
- $this->assertTrue($this->xpathContent($output, '//span[contains(@class, :class)]', array(':class' => 'field-content')));
- $this->assertTrue($this->xpathContent($output, '//span[contains(@class, :class)]', array(':class' => 'views-label')));
- $this->assertTrue($this->xpathContent($output, '//div[contains(@class, :class)]', array(':class' => 'views-field')));
+ $this->assertTrue($this->xpathContent($output, '//span[contains(@class, :class)]', [':class' => 'field-content']));
+ $this->assertTrue($this->xpathContent($output, '//span[contains(@class, :class)]', [':class' => 'views-label']));
+ $this->assertTrue($this->xpathContent($output, '//div[contains(@class, :class)]', [':class' => 'views-field']));
// Tests the element wrapper classes/element.
$random_class = $this->randomMachineName();
// Set some common wrapper element types and see whether they appear with and without a custom class set.
- foreach (array('h1', 'span', 'p', 'div') as $element_type) {
+ foreach (['h1', 'span', 'p', 'div'] as $element_type) {
$id_field->options['element_wrapper_type'] = $element_type;
// Set a custom wrapper element css class.
$id_field->options['element_wrapper_class'] = $random_class;
$output = $view->preview();
$output = $renderer->renderRoot($output);
- $this->assertTrue($this->xpathContent($output, "//{$element_type}[contains(@class, :class)]", array(':class' => $random_class)));
+ $this->assertTrue($this->xpathContent($output, "//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
// Set no custom css class.
$id_field->options['element_wrapper_class'] = '';
$output = $view->preview();
$output = $renderer->renderRoot($output);
- $this->assertFalse($this->xpathContent($output, "//{$element_type}[contains(@class, :class)]", array(':class' => $random_class)));
+ $this->assertFalse($this->xpathContent($output, "//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
$this->assertTrue($this->xpathContent($output, "//li[contains(@class, views-row)]/{$element_type}"));
}
// Tests the label class/element.
// Set some common label element types and see whether they appear with and without a custom class set.
- foreach (array('h1', 'span', 'p', 'div') as $element_type) {
+ foreach (['h1', 'span', 'p', 'div'] as $element_type) {
$id_field->options['element_label_type'] = $element_type;
// Set a custom label element css class.
$id_field->options['element_label_class'] = $random_class;
$output = $view->preview();
$output = $renderer->renderRoot($output);
- $this->assertTrue($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}[contains(@class, :class)]", array(':class' => $random_class)));
+ $this->assertTrue($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
// Set no custom css class.
$id_field->options['element_label_class'] = '';
$output = $view->preview();
$output = $renderer->renderRoot($output);
- $this->assertFalse($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}[contains(@class, :class)]", array(':class' => $random_class)));
+ $this->assertFalse($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
$this->assertTrue($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}"));
}
// Tests the element classes/element.
// Set some common element element types and see whether they appear with and without a custom class set.
- foreach (array('h1', 'span', 'p', 'div') as $element_type) {
+ foreach (['h1', 'span', 'p', 'div'] as $element_type) {
$id_field->options['element_type'] = $element_type;
// Set a custom label element css class.
$id_field->options['element_class'] = $random_class;
$output = $view->preview();
$output = $renderer->renderRoot($output);
- $this->assertTrue($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}[contains(@class, :class)]", array(':class' => $random_class)));
+ $this->assertTrue($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
// Set no custom css class.
$id_field->options['element_class'] = '';
$output = $view->preview();
$output = $renderer->renderRoot($output);
- $this->assertFalse($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}[contains(@class, :class)]", array(':class' => $random_class)));
+ $this->assertFalse($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
$this->assertTrue($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}"));
}
// Tests the available html elements.
$element_types = $id_field->getElements();
- $expected_elements = array(
+ $expected_elements = [
'',
0,
'div',
@@ -484,7 +484,7 @@ class FieldWebTest extends HandlerTestBase {
'strong',
'em',
'marquee'
- );
+ ];
$this->assertEqual(array_keys($element_types), $expected_elements);
}
@@ -560,14 +560,14 @@ class FieldWebTest extends HandlerTestBase {
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
return $name_field->advancedRender($row);
});
- $this->assertSubString($output, $trimmed_name, format_string('Make sure the trimmed output (@trimmed) appears in the rendered output (@output).', array('@trimmed' => $trimmed_name, '@output' => $output)));
- $this->assertNotSubString($output, $row->views_test_data_name, format_string("Make sure the untrimmed value (@untrimmed) shouldn't appear in the rendered output (@output).", array('@untrimmed' => $row->views_test_data_name, '@output' => $output)));
+ $this->assertSubString($output, $trimmed_name, format_string('Make sure the trimmed output (@trimmed) appears in the rendered output (@output).', ['@trimmed' => $trimmed_name, '@output' => $output]));
+ $this->assertNotSubString($output, $row->views_test_data_name, format_string("Make sure the untrimmed value (@untrimmed) shouldn't appear in the rendered output (@output).", ['@untrimmed' => $row->views_test_data_name, '@output' => $output]));
$name_field->options['alter']['max_length'] = 9;
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
return $name_field->advancedRender($row);
});
- $this->assertSubString($output, $trimmed_name, format_string('Make sure the untrimmed (@untrimmed) output appears in the rendered output (@output).', array('@trimmed' => $trimmed_name, '@output' => $output)));
+ $this->assertSubString($output, $trimmed_name, format_string('Make sure the untrimmed (@untrimmed) output appears in the rendered output (@output).', ['@trimmed' => $trimmed_name, '@output' => $output]));
// Take word_boundary into account for the tests.
$name_field->options['alter']['max_length'] = 5;
@@ -575,34 +575,34 @@ class FieldWebTest extends HandlerTestBase {
$random_text_2 = $this->randomMachineName(2);
$random_text_4 = $this->randomMachineName(4);
$random_text_8 = $this->randomMachineName(8);
- $tuples = array(
+ $tuples = [
// Create one string which doesn't fit at all into the limit.
- array(
+ [
'value' => $random_text_8,
'trimmed_value' => '',
'trimmed' => TRUE
- ),
+ ],
// Create one string with two words which doesn't fit both into the limit.
- array(
+ [
'value' => $random_text_8 . ' ' . $random_text_8,
'trimmed_value' => '',
'trimmed' => TRUE
- ),
+ ],
// Create one string which contains of two words, of which only the first
// fits into the limit.
- array(
+ [
'value' => $random_text_4 . ' ' . $random_text_8,
'trimmed_value' => $random_text_4,
'trimmed' => TRUE
- ),
+ ],
// Create one string which contains of two words, of which both fits into
// the limit.
- array(
+ [
'value' => $random_text_2 . ' ' . $random_text_2,
'trimmed_value' => $random_text_2 . ' ' . $random_text_2,
'trimmed' => FALSE
- )
- );
+ ]
+ ];
foreach ($tuples as $tuple) {
$row->views_test_data_name = $tuple['value'];
@@ -611,10 +611,10 @@ class FieldWebTest extends HandlerTestBase {
});
if ($tuple['trimmed']) {
- $this->assertNotSubString($output, $tuple['value'], format_string('The untrimmed value (@untrimmed) should not appear in the trimmed output (@output).', array('@untrimmed' => $tuple['value'], '@output' => $output)));
+ $this->assertNotSubString($output, $tuple['value'], format_string('The untrimmed value (@untrimmed) should not appear in the trimmed output (@output).', ['@untrimmed' => $tuple['value'], '@output' => $output]));
}
if (!empty($tuple['trimmed_value'])) {
- $this->assertSubString($output, $tuple['trimmed_value'], format_string('The trimmed value (@trimmed) should appear in the trimmed output (@output).', array('@trimmed' => $tuple['trimmed_value'], '@output' => $output)));
+ $this->assertSubString($output, $tuple['trimmed_value'], format_string('The trimmed value (@trimmed) should appear in the trimmed output (@output).', ['@trimmed' => $tuple['trimmed_value'], '@output' => $output]));
}
}
@@ -629,14 +629,14 @@ class FieldWebTest extends HandlerTestBase {
return $name_field->advancedRender($row);
});
$this->assertSubString($output, $more_text, 'Make sure a read more text is displayed if the output got trimmed');
- $this->assertTrue($this->xpathContent($output, '//a[contains(@href, :path)]', array(':path' => $more_path)), 'Make sure the read more link points to the right destination.');
+ $this->assertTrue($this->xpathContent($output, '//a[contains(@href, :path)]', [':path' => $more_path]), 'Make sure the read more link points to the right destination.');
$name_field->options['alter']['more_link'] = FALSE;
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
return $name_field->advancedRender($row);
});
$this->assertNotSubString($output, $more_text, 'Make sure no read more text appears.');
- $this->assertFalse($this->xpathContent($output, '//a[contains(@href, :path)]', array(':path' => $more_path)), 'Make sure no read more link appears.');
+ $this->assertFalse($this->xpathContent($output, '//a[contains(@href, :path)]', [':path' => $more_path]), 'Make sure no read more link appears.');
// Check for the ellipses.
$row->views_test_data_name = $this->randomMachineName(8);
diff --git a/core/modules/views/src/Tests/Handler/FilterDateTest.php b/core/modules/views/src/Tests/Handler/FilterDateTest.php
index 2045b8aff33..52789f40741 100644
--- a/core/modules/views/src/Tests/Handler/FilterDateTest.php
+++ b/core/modules/views/src/Tests/Handler/FilterDateTest.php
@@ -16,27 +16,27 @@ class FilterDateTest extends HandlerTestBase {
*
* @var array
*/
- public static $testViews = array('test_filter_date_between');
+ public static $testViews = ['test_filter_date_between'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'views_ui');
+ public static $modules = ['node', 'views_ui'];
protected function setUp() {
parent::setUp();
// Add some basic test nodes.
- $this->nodes = array();
- $this->nodes[] = $this->drupalCreateNode(array('created' => 100000));
- $this->nodes[] = $this->drupalCreateNode(array('created' => 200000));
- $this->nodes[] = $this->drupalCreateNode(array('created' => 300000));
- $this->nodes[] = $this->drupalCreateNode(array('created' => time() + 86400));
+ $this->nodes = [];
+ $this->nodes[] = $this->drupalCreateNode(['created' => 100000]);
+ $this->nodes[] = $this->drupalCreateNode(['created' => 200000]);
+ $this->nodes[] = $this->drupalCreateNode(['created' => 300000]);
+ $this->nodes[] = $this->drupalCreateNode(['created' => time() + 86400]);
- $this->map = array(
+ $this->map = [
'nid' => 'nid',
- );
+ ];
}
/**
@@ -60,9 +60,9 @@ class FilterDateTest extends HandlerTestBase {
$view->filter['created']->value['type'] = 'offset';
$view->filter['created']->value['value'] = '+1 hour';
$view->executeDisplay('default');
- $expected_result = array(
- array('nid' => $this->nodes[3]->id()),
- );
+ $expected_result = [
+ ['nid' => $this->nodes[3]->id()],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
@@ -73,9 +73,9 @@ class FilterDateTest extends HandlerTestBase {
$view->filter['created']->value['max'] = '+2 days';
$view->filter['created']->value['min'] = '+1 hour';
$view->executeDisplay('default');
- $expected_result = array(
- array('nid' => $this->nodes[3]->id()),
- );
+ $expected_result = [
+ ['nid' => $this->nodes[3]->id()],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
}
@@ -91,9 +91,9 @@ class FilterDateTest extends HandlerTestBase {
$view->filter['created']->value['min'] = format_date(150000, 'custom', 'Y-m-d H:i:s');
$view->filter['created']->value['max'] = format_date(200000, 'custom', 'Y-m-d H:i:s');
$view->executeDisplay('default');
- $expected_result = array(
- array('nid' => $this->nodes[1]->id()),
- );
+ $expected_result = [
+ ['nid' => $this->nodes[1]->id()],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
@@ -102,10 +102,10 @@ class FilterDateTest extends HandlerTestBase {
$view->filter['created']->operator = 'between';
$view->filter['created']->value['max'] = format_date(200000, 'custom', 'Y-m-d H:i:s');
$view->executeDisplay('default');
- $expected_result = array(
- array('nid' => $this->nodes[0]->id()),
- array('nid' => $this->nodes[1]->id()),
- );
+ $expected_result = [
+ ['nid' => $this->nodes[0]->id()],
+ ['nid' => $this->nodes[1]->id()],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
@@ -116,10 +116,10 @@ class FilterDateTest extends HandlerTestBase {
$view->filter['created']->value['max'] = format_date(200000, 'custom', 'Y-m-d H:i:s');
$view->executeDisplay('default');
- $expected_result = array(
- array('nid' => $this->nodes[2]->id()),
- array('nid' => $this->nodes[3]->id()),
- );
+ $expected_result = [
+ ['nid' => $this->nodes[2]->id()],
+ ['nid' => $this->nodes[3]->id()],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
@@ -128,10 +128,10 @@ class FilterDateTest extends HandlerTestBase {
$view->filter['created']->operator = 'not between';
$view->filter['created']->value['max'] = format_date(200000, 'custom', 'Y-m-d H:i:s');
$view->executeDisplay('default');
- $expected_result = array(
- array('nid' => $this->nodes[2]->id()),
- array('nid' => $this->nodes[3]->id()),
- );
+ $expected_result = [
+ ['nid' => $this->nodes[2]->id()],
+ ['nid' => $this->nodes[3]->id()],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
}
@@ -140,12 +140,12 @@ class FilterDateTest extends HandlerTestBase {
*/
protected function _testUiValidation() {
- $this->drupalLogin($this->drupalCreateUser(array('administer views', 'administer site configuration')));
+ $this->drupalLogin($this->drupalCreateUser(['administer views', 'administer site configuration']));
$this->drupalGet('admin/structure/views/view/test_filter_date_between/edit');
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_date_between/default/filter/created');
- $edit = array();
+ $edit = [];
// Generate a definitive wrong value, which should be checked by validation.
$edit['options[value][value]'] = $this->randomString() . '-------';
$this->drupalPostForm(NULL, $edit, t('Apply'));
diff --git a/core/modules/views/src/Tests/Handler/HandlerAllTest.php b/core/modules/views/src/Tests/Handler/HandlerAllTest.php
index c15ce57e823..565437657e7 100644
--- a/core/modules/views/src/Tests/Handler/HandlerAllTest.php
+++ b/core/modules/views/src/Tests/Handler/HandlerAllTest.php
@@ -22,7 +22,7 @@ class HandlerAllTest extends HandlerTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'aggregator',
'book',
'block',
@@ -40,13 +40,13 @@ class HandlerAllTest extends HandlerTestBase {
'statistics',
'taxonomy',
'user',
- );
+ ];
/**
* Tests most of the handlers.
*/
public function testHandlers() {
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
$this->addDefaultCommentField('node', 'article');
$object_types = array_keys(ViewExecutable::getHandlerTypes());
@@ -55,7 +55,7 @@ class HandlerAllTest extends HandlerTestBase {
continue;
}
- $view = View::create(array('base_table' => $base_table));
+ $view = View::create(['base_table' => $base_table]);
$view = $view->getExecutable();
// @todo The groupwise relationship is currently broken.
@@ -66,18 +66,18 @@ class HandlerAllTest extends HandlerTestBase {
foreach ($info as $field => $field_info) {
// Table is a reserved key for the metainformation.
if ($field != 'table' && !in_array("$base_table:$field", $exclude)) {
- $item = array(
+ $item = [
'table' => $base_table,
'field' => $field,
- );
+ ];
foreach ($object_types as $type) {
if (isset($field_info[$type]['id'])) {
- $options = array();
+ $options = [];
if ($type == 'filter') {
$handler = $this->container->get("plugin.manager.views.$type")->getHandler($item);
// Set the value to use for the filter based on the filter type.
if ($handler instanceof InOperator) {
- $options['value'] = array(1);
+ $options['value'] = [1];
}
else {
$options['value'] = 1;
@@ -102,10 +102,10 @@ class HandlerAllTest extends HandlerTestBase {
foreach ($view->{$type} as $handler) {
$this->assertTrue($handler instanceof HandlerBase, format_string(
'@type handler of class %class is an instance of HandlerBase',
- array(
+ [
'@type' => $type,
'%class' => get_class($handler),
- )));
+ ]));
}
}
}
diff --git a/core/modules/views/src/Tests/Handler/HandlerTest.php b/core/modules/views/src/Tests/Handler/HandlerTest.php
index 8ff4033b5ef..e07beb38345 100644
--- a/core/modules/views/src/Tests/Handler/HandlerTest.php
+++ b/core/modules/views/src/Tests/Handler/HandlerTest.php
@@ -23,18 +23,18 @@ class HandlerTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_view_handler_weight', 'test_handler_relationships', 'test_handler_test_access', 'test_filter_in_operator_ui');
+ public static $testViews = ['test_view', 'test_view_handler_weight', 'test_handler_relationships', 'test_handler_test_access', 'test_filter_in_operator_ui'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('views_ui', 'comment', 'node');
+ public static $modules = ['views_ui', 'comment', 'node'];
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
$this->addDefaultCommentField('node', 'page');
$this->enableViewsTestModule();
}
@@ -56,7 +56,7 @@ class HandlerTest extends ViewTestBase {
$data['views_test_data']['access_callback'][$type]['access callback'] = 'views_test_data_handler_test_access_callback';
$data['views_test_data']['access_callback_arguments'][$type]['access callback'] = 'views_test_data_handler_test_access_callback_argument';
- $data['views_test_data']['access_callback_arguments'][$type]['access arguments'] = array(TRUE);
+ $data['views_test_data']['access_callback_arguments'][$type]['access arguments'] = [TRUE];
}
}
@@ -68,45 +68,45 @@ class HandlerTest extends ViewTestBase {
*/
public function testBreakString() {
// Check defaults.
- $this->assertEqual((object) array('value' => array(), 'operator' => NULL), HandlerBase::breakString(''));
+ $this->assertEqual((object) ['value' => [], 'operator' => NULL], HandlerBase::breakString(''));
// Test ors
$handler = HandlerBase::breakString('word1 word2+word');
- $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
+ $this->assertEqualValue(['word1', 'word2', 'word'], $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakString('word1+word2+word');
- $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
+ $this->assertEqualValue(['word1', 'word2', 'word'], $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakString('word1 word2 word');
- $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
+ $this->assertEqualValue(['word1', 'word2', 'word'], $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakString('word-1+word-2+word');
- $this->assertEqualValue(array('word-1', 'word-2', 'word'), $handler);
+ $this->assertEqualValue(['word-1', 'word-2', 'word'], $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakString('wõrd1+wõrd2+wõrd');
- $this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler);
+ $this->assertEqualValue(['wõrd1', 'wõrd2', 'wõrd'], $handler);
$this->assertEqual('or', $handler->operator);
// Test ands.
$handler = HandlerBase::breakString('word1,word2,word');
- $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
+ $this->assertEqualValue(['word1', 'word2', 'word'], $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakString('word1 word2,word');
- $this->assertEqualValue(array('word1 word2', 'word'), $handler);
+ $this->assertEqualValue(['word1 word2', 'word'], $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakString('word1,word2 word');
- $this->assertEqualValue(array('word1', 'word2 word'), $handler);
+ $this->assertEqualValue(['word1', 'word2 word'], $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakString('word-1,word-2,word');
- $this->assertEqualValue(array('word-1', 'word-2', 'word'), $handler);
+ $this->assertEqualValue(['word-1', 'word-2', 'word'], $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakString('wõrd1,wõrd2,wõrd');
- $this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler);
+ $this->assertEqualValue(['wõrd1', 'wõrd2', 'wõrd'], $handler);
$this->assertEqual('and', $handler->operator);
// Test a single word
$handler = HandlerBase::breakString('word');
- $this->assertEqualValue(array('word'), $handler);
+ $this->assertEqualValue(['word'], $handler);
$this->assertEqual('and', $handler->operator);
$s1 = $this->randomMachineName();
@@ -117,45 +117,45 @@ class HandlerTest extends ViewTestBase {
// Test "or"s.
$handlerBase = HandlerBase::breakString("$s1 $n2+$n3");
- $this->assertEqualValue(array($s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$s1, $n2, $n3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1+$n2+$n3");
- $this->assertEqualValue(array($s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$s1, $n2, $n3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1 $n2 $n3");
- $this->assertEqualValue(array($s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$s1, $n2, $n3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1 $n2++$n3");
- $this->assertEqualValue(array($s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$s1, $n2, $n3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
// Test "and"s.
$handlerBase = HandlerBase::breakString("$s1,$n2,$n3");
- $this->assertEqualValue(array($s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$s1, $n2, $n3], $handlerBase);
$this->assertEqual('and', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1,,$n2,$n3");
- $this->assertEqualValue(array($s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$s1, $n2, $n3], $handlerBase);
$this->assertEqual('and', $handlerBase->operator);
// Enforce int values.
$handlerBase = HandlerBase::breakString("$n1,$n2,$n3", TRUE);
- $this->assertEqualValue(array($n1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$n1, $n2, $n3], $handlerBase);
$this->assertEqual('and', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$n1+$n2+$n3", TRUE);
- $this->assertEqualValue(array($n1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([$n1, $n2, $n3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1,$n2,$n3", TRUE);
- $this->assertEqualValue(array((int) $s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([(int) $s1, $n2, $n3], $handlerBase);
$this->assertEqual('and', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1+$n2+$n3", TRUE);
- $this->assertEqualValue(array((int) $s1, $n2, $n3), $handlerBase);
+ $this->assertEqualValue([(int) $s1, $n2, $n3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
// Generate three random decimals which can be used below;
@@ -165,28 +165,28 @@ class HandlerTest extends ViewTestBase {
// Test "or"s.
$handlerBase = HandlerBase::breakString("$s1 $d1+$d2");
- $this->assertEqualValue(array($s1, $d1, $d2), $handlerBase);
+ $this->assertEqualValue([$s1, $d1, $d2], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1+$d1+$d3");
- $this->assertEqualValue(array($s1, $d1, $d3), $handlerBase);
+ $this->assertEqualValue([$s1, $d1, $d3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1 $d2 $d3");
- $this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
+ $this->assertEqualValue([$s1, $d2, $d3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1 $d2++$d3");
- $this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
+ $this->assertEqualValue([$s1, $d2, $d3], $handlerBase);
$this->assertEqual('or', $handlerBase->operator);
// Test "and"s.
$handlerBase = HandlerBase::breakString("$s1,$d2,$d3");
- $this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
+ $this->assertEqualValue([$s1, $d2, $d3], $handlerBase);
$this->assertEqual('and', $handlerBase->operator);
$handlerBase = HandlerBase::breakString("$s1,,$d2,$d3");
- $this->assertEqualValue(array($s1, $d2, $d3), $handlerBase);
+ $this->assertEqualValue([$s1, $d2, $d3], $handlerBase);
$this->assertEqual('and', $handlerBase->operator);
}
@@ -194,13 +194,13 @@ class HandlerTest extends ViewTestBase {
* Tests the order of handlers is the same before and after saving.
*/
public function testHandlerWeights() {
- $handler_types = array('fields', 'filters', 'sorts');
+ $handler_types = ['fields', 'filters', 'sorts'];
$view = Views::getView('test_view_handler_weight');
$view->initDisplay();
// Store the order of handlers before saving the view.
- $original_order = array();
+ $original_order = [];
foreach ($handler_types as $type) {
$original_order[$type] = array_keys($view->display_handler->getOption($type));
}
@@ -233,7 +233,7 @@ class HandlerTest extends ViewTestBase {
*/
protected function assertEqualValue($expected, $handler, $message = '', $group = 'Other') {
if (empty($message)) {
- $message = t('Comparing @first and @second', array('@first' => implode(',', $expected), '@second' => implode(',', $handler->value)));
+ $message = t('Comparing @first and @second', ['@first' => implode(',', $expected), '@second' => implode(',', $handler->value)]);
}
return $this->assert($expected == $handler->value, $message, $group);
@@ -243,7 +243,7 @@ class HandlerTest extends ViewTestBase {
* Tests the relationship ui for field/filter/argument/relationship.
*/
public function testRelationshipUI() {
- $views_admin = $this->drupalCreateUser(array('administer views'));
+ $views_admin = $this->drupalCreateUser(['administer views']);
$this->drupalLogin($views_admin);
// Make sure the link to the field options exists.
@@ -262,18 +262,18 @@ class HandlerTest extends ViewTestBase {
// Check for available options.
$xpath = $this->constructFieldXpath('name', $relationship_name);
$fields = $this->xpath($xpath);
- $options = array();
+ $options = [];
foreach ($fields as $field) {
$items = $this->getAllOptions($field);
foreach ($items as $item) {
$options[] = $item->attributes()->value;
}
}
- $expected_options = array('none', 'nid');
+ $expected_options = ['none', 'nid'];
$this->assertEqual($options, $expected_options);
// Remove the relationship and make sure no relationship option appears.
- $this->drupalPostForm('admin/structure/views/nojs/handler/test_handler_relationships/default/relationship/nid', array(), t('Remove'));
+ $this->drupalPostForm('admin/structure/views/nojs/handler/test_handler_relationships/default/relationship/nid', [], t('Remove'));
$this->drupalGet($handler_options_path);
$this->assertNoFieldByName($relationship_name, NULL, 'Make sure that no relationship option is available');
@@ -298,9 +298,9 @@ class HandlerTest extends ViewTestBase {
$view = Views::getView('test_handler_relationships');
$view->setDisplay();
// Setup a broken relationship.
- $view->addHandler('default', 'relationship', $this->randomMachineName(), $this->randomMachineName(), array(), 'broken_relationship');
+ $view->addHandler('default', 'relationship', $this->randomMachineName(), $this->randomMachineName(), [], 'broken_relationship');
// Setup a valid relationship.
- $view->addHandler('default', 'relationship', 'comment_field_data', 'node', array('relationship' => 'cid'), 'valid_relationship');
+ $view->addHandler('default', 'relationship', 'comment_field_data', 'node', ['relationship' => 'cid'], 'valid_relationship');
$view->initHandlers();
$field = $view->field['title'];
@@ -377,7 +377,7 @@ class HandlerTest extends ViewTestBase {
$view->initHandlers();
foreach ($views_data['access_callback'] as $type => $info) {
- if (!in_array($type, array('title', 'help'))) {
+ if (!in_array($type, ['title', 'help'])) {
$this->assertTrue($view->field['access_callback'] instanceof HandlerBase, 'Make sure the user got access to the access_callback field ');
$this->assertFalse(isset($view->field['access_callback_arguments']), 'Make sure the user got no access to the access_callback_arguments field ');
}
@@ -391,7 +391,7 @@ class HandlerTest extends ViewTestBase {
$view->initHandlers();
foreach ($views_data['access_callback'] as $type => $info) {
- if (!in_array($type, array('title', 'help'))) {
+ if (!in_array($type, ['title', 'help'])) {
$this->assertFalse(isset($view->field['access_callback']), 'Make sure the user got no access to the access_callback field ');
$this->assertTrue($view->field['access_callback_arguments'] instanceof HandlerBase, 'Make sure the user got access to the access_callback_arguments field ');
}
diff --git a/core/modules/views/src/Tests/Plugin/AccessTest.php b/core/modules/views/src/Tests/Plugin/AccessTest.php
index 1bcf30013c5..2278f6771c8 100644
--- a/core/modules/views/src/Tests/Plugin/AccessTest.php
+++ b/core/modules/views/src/Tests/Plugin/AccessTest.php
@@ -19,14 +19,14 @@ class AccessTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_access_none', 'test_access_static', 'test_access_dynamic');
+ public static $testViews = ['test_access_none', 'test_access_static', 'test_access_dynamic'];
/**
* Modules to enable.
*
* @return array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Web user for testing.
@@ -47,12 +47,12 @@ class AccessTest extends PluginTestBase {
$this->enableViewsTestModule();
- ViewTestData::createTestViews(get_class($this), array('views_test_data'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_data']);
$this->webUser = $this->drupalCreateUser();
- $normal_role = $this->drupalCreateRole(array());
- $this->normalUser = $this->drupalCreateUser(array('views_test_data test permission'));
+ $normal_role = $this->drupalCreateRole([]);
+ $this->normalUser = $this->drupalCreateUser(['views_test_data test permission']);
$this->normalUser->addRole($normal_role);
// @todo when all the plugin information is cached make a reset function and
// call it here.
diff --git a/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
index 5abc27c83ce..a4e82172e09 100644
--- a/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
+++ b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
@@ -22,20 +22,20 @@ class ArgumentDefaultTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array(
+ public static $testViews = [
'test_view',
'test_argument_default_fixed',
'test_argument_default_current_user',
'test_argument_default_node',
'test_argument_default_query_param',
- );
+ ];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'views_ui', 'block');
+ public static $modules = ['node', 'views_ui', 'block'];
protected function setUp() {
parent::setUp();
@@ -52,13 +52,13 @@ class ArgumentDefaultTest extends PluginTestBase {
$view = Views::getView('test_view');
// Add a new argument and set the test plugin for the argument_default.
- $options = array(
+ $options = [
'default_argument_type' => 'argument_default_test',
- 'default_argument_options' => array(
+ 'default_argument_options' => [
'value' => 'John'
- ),
+ ],
'default_action' => 'default'
- );
+ ];
$id = $view->addHandler('default', 'argument', 'views_test_data', 'name', $options);
$view->initHandlers();
$plugin = $view->argument[$id]->getPlugin('argument_default');
@@ -70,15 +70,15 @@ class ArgumentDefaultTest extends PluginTestBase {
// just returns John.
$this->executeView($view);
$this->assertEqual($view->argument[$id]->getValue(), 'John', 'The correct argument value is used.');
- $expected_result = array(array('name' => 'John'));
- $this->assertIdenticalResultset($view, $expected_result, array('views_test_data_name' => 'name'));
+ $expected_result = [['name' => 'John']];
+ $this->assertIdenticalResultset($view, $expected_result, ['views_test_data_name' => 'name']);
// Pass in value as argument to be sure that not the default value is used.
$view->destroy();
- $this->executeView($view, array('George'));
+ $this->executeView($view, ['George']);
$this->assertEqual($view->argument[$id]->getValue(), 'George', 'The correct argument value is used.');
- $expected_result = array(array('name' => 'George'));
- $this->assertIdenticalResultset($view, $expected_result, array('views_test_data_name' => 'name'));
+ $expected_result = [['name' => 'George']];
+ $this->assertIdenticalResultset($view, $expected_result, ['views_test_data_name' => 'name']);
}
@@ -86,24 +86,24 @@ class ArgumentDefaultTest extends PluginTestBase {
* Tests the use of a default argument plugin that provides no options.
*/
public function testArgumentDefaultNoOptions() {
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
// The current_user plugin has no options form, and should pass validation.
$argument_type = 'current_user';
- $edit = array(
+ $edit = [
'options[default_argument_type]' => $argument_type,
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_argument_default_current_user/default/argument/uid', $edit, t('Apply'));
// Note, the undefined index error has two spaces after it.
- $error = array(
+ $error = [
'%type' => 'Notice',
'@message' => 'Undefined index: ' . $argument_type,
'%function' => 'views_handler_argument->validateOptionsForm()',
- );
+ ];
$message = t('%type: @message in %function', $error);
- $this->assertNoRaw($message, format_string('Did not find error message: @message.', array('@message' => $message)));
+ $this->assertNoRaw($message, format_string('Did not find error message: @message.', ['@message' => $message]));
}
/**
@@ -122,7 +122,7 @@ class ArgumentDefaultTest extends PluginTestBase {
// Make sure that a normal argument provided is used
$random_string = $this->randomMachineName();
- $view->executeDisplay('default', array($random_string));
+ $view->executeDisplay('default', [$random_string]);
$this->assertEqual($view->args[0], $random_string, 'Provided argument should be used.');
}
@@ -137,13 +137,13 @@ class ArgumentDefaultTest extends PluginTestBase {
*/
public function testArgumentDefaultNode() {
// Create a user that has permission to place a view block.
- $permissions = array(
+ $permissions = [
'administer views',
'administer blocks',
'bypass node access',
'access user profiles',
'view all revisions',
- );
+ ];
$views_admin = $this->drupalCreateUser($permissions);
$this->drupalLogin($views_admin);
diff --git a/core/modules/views/src/Tests/Plugin/CacheTagTest.php b/core/modules/views/src/Tests/Plugin/CacheTagTest.php
index eaee6569d10..72d94f3cf34 100644
--- a/core/modules/views/src/Tests/Plugin/CacheTagTest.php
+++ b/core/modules/views/src/Tests/Plugin/CacheTagTest.php
@@ -19,14 +19,14 @@ class CacheTagTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_tag_cache');
+ public static $testViews = ['test_tag_cache'];
/**
* Views used by this test.
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* The node storage.
@@ -73,17 +73,17 @@ class CacheTagTest extends PluginTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
$this->nodeStorage = $this->container->get('entity.manager')->getStorage('node');
$this->nodeViewBuilder = $this->container->get('entity.manager')->getViewBuilder('node');
$this->userViewBuilder = $this->container->get('entity.manager')->getViewBuilder('user');
for ($i = 1; $i <= 5; $i++) {
- $this->pages[] = $this->drupalCreateNode(array('title' => "Test $i", 'type' => 'page'));
+ $this->pages[] = $this->drupalCreateNode(['title' => "Test $i", 'type' => 'page']);
}
- $this->article = $this->drupalCreateNode(array('title' => "Test article", 'type' => 'article'));
+ $this->article = $this->drupalCreateNode(['title' => "Test article", 'type' => 'article']);
$this->user = $this->drupalCreateUser();
// Mark the current request safe, in order to make render cache working, see
@@ -183,7 +183,7 @@ class CacheTagTest extends PluginTestBase {
$this->assertTrue($cache_plugin->cacheGet('results'), 'Results cache found.');
$this->assertTrue($this->getRenderCache($view), 'Output cache found.');
- $this->userViewBuilder->resetCache(array($this->user));
+ $this->userViewBuilder->resetCache([$this->user]);
$cache_plugin = $view->display_handler->getPlugin('cache');
$this->assertTrue($cache_plugin->cacheGet('results'), 'Results cache found after a user is invalidated.');
diff --git a/core/modules/views/src/Tests/Plugin/CacheWebTest.php b/core/modules/views/src/Tests/Plugin/CacheWebTest.php
index f41e786e468..7786606376a 100644
--- a/core/modules/views/src/Tests/Plugin/CacheWebTest.php
+++ b/core/modules/views/src/Tests/Plugin/CacheWebTest.php
@@ -21,14 +21,14 @@ class CacheWebTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_display');
+ public static $testViews = ['test_display'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* {@inheritdoc}
@@ -46,13 +46,13 @@ class CacheWebTest extends PluginTestBase {
$view = Views::getView('test_display');
$view->storage->setStatus(TRUE);
$view->setDisplay('page_1');
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'time',
- 'options' => array(
+ 'options' => [
'results_lifespan' => '3600',
'output_lifespan' => '3600'
- )
- ));
+ ]
+ ]);
$view->save();
$this->container->get('router.builder')->rebuildIfNeeded();
diff --git a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php
index 9238dda36f7..cb439469133 100644
--- a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php
@@ -15,14 +15,14 @@ class DisabledDisplayTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_disabled_display');
+ public static $testViews = ['test_disabled_display'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('block', 'node', 'views');
+ public static $modules = ['block', 'node', 'views'];
protected function setUp() {
parent::setUp();
@@ -31,7 +31,7 @@ class DisabledDisplayTest extends PluginTestBase {
$this->drupalPlaceBlock('page_title_block');
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
}
@@ -44,7 +44,7 @@ class DisabledDisplayTest extends PluginTestBase {
*/
public function testDisabledDisplays() {
// The displays defined in this view.
- $display_ids = array('attachment_1', 'block_1', 'embed_1', 'feed_1', 'page_2');
+ $display_ids = ['attachment_1', 'block_1', 'embed_1', 'feed_1', 'page_2'];
$this->drupalCreateContentType(['type' => 'page']);
$this->drupalCreateNode();
diff --git a/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
index 88db8b1b926..16c0680b36d 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
@@ -17,21 +17,21 @@ class DisplayAttachmentTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_display_attachment', 'test_attached_disabled');
+ public static $testViews = ['test_display_attachment', 'test_attached_disabled'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'views');
+ public static $modules = ['node', 'views'];
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
}
diff --git a/core/modules/views/src/Tests/Plugin/DisplayEntityReferenceTest.php b/core/modules/views/src/Tests/Plugin/DisplayEntityReferenceTest.php
index 96d0369263a..ac7209c2841 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayEntityReferenceTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayEntityReferenceTest.php
@@ -24,14 +24,14 @@ class DisplayEntityReferenceTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_display_entity_reference');
+ public static $testViews = ['test_display_entity_reference'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('entity_test', 'field', 'views_ui');
+ public static $modules = ['entity_test', 'field', 'views_ui'];
/**
* The used field name in the test.
@@ -67,7 +67,7 @@ class DisplayEntityReferenceTest extends PluginTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->drupalCreateUser(array('administer views')));
+ $this->drupalLogin($this->drupalCreateUser(['administer views']));
// Create the text field.
$this->fieldName = 'field_test_entity_ref_display';
diff --git a/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php b/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php
index 33c3713c1e1..896b1348dd2 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayExtenderTest.php
@@ -18,7 +18,7 @@ class DisplayExtenderTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
protected function setUp() {
parent::setUp();
@@ -30,7 +30,7 @@ class DisplayExtenderTest extends PluginTestBase {
* Test display extenders.
*/
public function testDisplayExtenders() {
- $this->config('views.settings')->set('display_extenders', array('display_extender_test'))->save();
+ $this->config('views.settings')->set('display_extenders', ['display_extender_test'])->save();
$this->assertEqual(count(Views::getEnabledDisplayExtenders()), 1, 'Make sure that there is only one enabled display extender.');
$view = Views::getView('test_view');
diff --git a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
index d31f457bcc7..2a3dc4ecd18 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
@@ -17,21 +17,21 @@ class DisplayFeedTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_display_feed', 'test_attached_disabled', 'test_feed_icon');
+ public static $testViews = ['test_display_feed', 'test_attached_disabled', 'test_feed_icon'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('block', 'node', 'views');
+ public static $modules = ['block', 'node', 'views'];
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
- $admin_user = $this->drupalCreateUser(array('administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
}
@@ -101,13 +101,13 @@ class DisplayFeedTest extends PluginTestBase {
// Verify a title with HTML entities is properly escaped.
$node_title = 'This "cool" & "neat" article\'s title';
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'title' => $node_title,
'body' => [0 => [
'value' => 'A paragraph',
'format' => filter_default_format(),
]],
- ));
+ ]);
$this->drupalGet('test-feed-display-fields.xml');
$result = $this->xpath('//title/a');
diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php
index acb3af86f12..b5c853faec5 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php
@@ -19,7 +19,7 @@ class DisplayPageWebTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_page_display', 'test_page_display_arguments', 'test_page_display_menu', 'test_page_display_path');
+ public static $testViews = ['test_page_display', 'test_page_display_arguments', 'test_page_display_menu', 'test_page_display_path'];
/**
* Modules to enable.
@@ -88,10 +88,10 @@ class DisplayPageWebTest extends PluginTestBase {
// Check local tasks.
$this->drupalGet('test_page_display_menu');
$this->assertResponse(200);
- $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', array(
+ $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', [
':ul_class' => 'tabs primary',
':a_class' => 'is-active',
- ));
+ ]);
$this->assertEqual((string) $element[0], t('Test default tab'));
$this->assertTitle(t('Test default page | Drupal'));
@@ -100,10 +100,10 @@ class DisplayPageWebTest extends PluginTestBase {
$this->drupalGet('test_page_display_menu/local');
$this->assertResponse(200);
- $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', array(
+ $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', [
':ul_class' => 'tabs primary',
':a_class' => 'is-active',
- ));
+ ]);
$this->assertEqual((string) $element[0], t('Test local tab'));
$this->assertTitle(t('Test local page | Drupal'));
diff --git a/core/modules/views/src/Tests/Plugin/DisplayTest.php b/core/modules/views/src/Tests/Plugin/DisplayTest.php
index 3bbfd66b7a5..42a389cb911 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayTest.php
@@ -19,26 +19,26 @@ class DisplayTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_filter_groups', 'test_get_attach_displays', 'test_view', 'test_display_more', 'test_display_invalid', 'test_display_empty', 'test_exposed_relationship_admin_ui');
+ public static $testViews = ['test_filter_groups', 'test_get_attach_displays', 'test_view', 'test_display_more', 'test_display_invalid', 'test_display_empty', 'test_exposed_relationship_admin_ui'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('views_ui', 'node', 'block');
+ public static $modules = ['views_ui', 'node', 'block'];
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
- $this->adminUser = $this->drupalCreateUser(array('administer views'));
+ $this->adminUser = $this->drupalCreateUser(['administer views']);
$this->drupalLogin($this->adminUser);
// Create 10 nodes.
for ($i = 0; $i <= 10; $i++) {
- $this->drupalCreateNode(array('promote' => TRUE));
+ $this->drupalCreateNode(['promote' => TRUE]);
}
}
@@ -59,25 +59,25 @@ class DisplayTest extends PluginTestBase {
$this->assertTrue(isset($displays['display_test_1']), 'Added display has been assigned to "display_test_1"');
// Check the display options are like expected.
- $options = array(
- 'display_options' => array(),
+ $options = [
+ 'display_options' => [],
'display_plugin' => 'display_test',
'id' => 'display_test_1',
'display_title' => 'Display test',
'position' => 1,
- );
+ ];
$this->assertEqual($displays['display_test_1'], $options);
// Add another one to ensure that position is counted up.
$view->storage->addDisplay('display_test');
$displays = $view->storage->get('display');
- $options = array(
- 'display_options' => array(),
+ $options = [
+ 'display_options' => [],
'display_plugin' => 'display_test',
'id' => 'display_test_2',
'display_title' => 'Display test 2',
'position' => 2,
- );
+ ];
$this->assertEqual($displays['display_test_2'], $options);
// Move the second display before the first one in order to test custom
@@ -120,7 +120,7 @@ class DisplayTest extends PluginTestBase {
$this->clickLink('Test option title');
$test_option = $this->randomString();
- $this->drupalPostForm(NULL, array('test_option' => $test_option), t('Apply'));
+ $this->drupalPostForm(NULL, ['test_option' => $test_option], t('Apply'));
// Check the new value has been saved by checking the UI summary text.
$this->drupalGet('admin/structure/views/view/test_view/edit/display_test_1');
@@ -154,10 +154,10 @@ class DisplayTest extends PluginTestBase {
// Both the feed_1 and the feed_2 display are attached to the page display.
$view->setDisplay('page_1');
- $this->assertEqual($view->display_handler->getAttachedDisplays(), array('feed_1', 'feed_2'));
+ $this->assertEqual($view->display_handler->getAttachedDisplays(), ['feed_1', 'feed_2']);
$view->setDisplay('feed_1');
- $this->assertEqual($view->display_handler->getAttachedDisplays(), array());
+ $this->assertEqual($view->display_handler->getAttachedDisplays(), []);
}
/**
@@ -179,7 +179,7 @@ class DisplayTest extends PluginTestBase {
$output = $renderer->renderRoot($output);
$this->setRawContent($output);
- $result = $this->xpath('//a[@class=:class]', array(':class' => 'more-link'));
+ $result = $this->xpath('//a[@class=:class]', [':class' => 'more-link']);
$this->assertEqual($result[0]->attributes()->href, \Drupal::url('view.test_display_more.page_1'), 'The right more link is shown.');
$this->assertEqual(trim($result[0][0]), $expected_more_text, 'The right link text is shown.');
@@ -188,7 +188,7 @@ class DisplayTest extends PluginTestBase {
$more_link = $view->display_handler->renderMoreLink();
$more_link = $renderer->renderRoot($more_link);
$this->setRawContent($more_link);
- $result = $this->xpath('//a[@class=:class]', array(':class' => 'more-link'));
+ $result = $this->xpath('//a[@class=:class]', [':class' => 'more-link']);
$this->assertEqual($result[0]->attributes()->href, \Drupal::url('view.test_display_more.page_1'), 'The right more link is shown.');
$this->assertEqual(trim($result[0][0]), $expected_more_text, 'The right link text is shown.');
@@ -204,25 +204,25 @@ class DisplayTest extends PluginTestBase {
$output = $view->preview();
$output = $renderer->renderRoot($output);
$this->setRawContent($output);
- $result = $this->xpath('//a[@class=:class]', array(':class' => 'more-link'));
+ $result = $this->xpath('//a[@class=:class]', [':class' => 'more-link']);
$this->assertTrue(empty($result), 'The more link is not shown.');
$view = Views::getView('test_display_more');
$view->setDisplay();
$view->display_handler->setOption('use_more', 0);
$view->display_handler->setOption('use_more_always', 0);
- $view->display_handler->setOption('pager', array(
+ $view->display_handler->setOption('pager', [
'type' => 'some',
- 'options' => array(
+ 'options' => [
'items_per_page' => 1,
'offset' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
$output = $view->preview();
$output = $renderer->renderRoot($output);
$this->setRawContent($output);
- $result = $this->xpath('//a[@class=:class]', array(':class' => 'more-link'));
+ $result = $this->xpath('//a[@class=:class]', [':class' => 'more-link']);
$this->assertTrue(empty($result), 'The more link is not shown when view has more records.');
// Test the default value of use_more_always.
@@ -286,7 +286,7 @@ class DisplayTest extends PluginTestBase {
$config->save();
// Place the block display.
- $block = $this->drupalPlaceBlock('views_block:test_display_invalid-block_1', array('label' => 'Invalid display'));
+ $block = $this->drupalPlaceBlock('views_block:test_display_invalid-block_1', ['label' => 'Invalid display']);
$this->drupalGet('<front>');
$this->assertResponse(200);
@@ -326,8 +326,8 @@ class DisplayTest extends PluginTestBase {
$errors = $view->validate();
// Check that the error messages are shown.
$this->assertTrue(count($errors['default']) == 2, 'Error messages found for required relationship');
- $this->assertEqual($errors['default'][0], t('The %handler_type %handler uses a relationship that has been removed.', array('%handler_type' => 'field', '%handler' => 'User: Last login')));
- $this->assertEqual($errors['default'][1], t('The %handler_type %handler uses a relationship that has been removed.', array('%handler_type' => 'field', '%handler' => 'User: Created')));
+ $this->assertEqual($errors['default'][0], t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => 'field', '%handler' => 'User: Last login']));
+ $this->assertEqual($errors['default'][1], t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => 'field', '%handler' => 'User: Created']));
}
/**
@@ -342,12 +342,12 @@ class DisplayTest extends PluginTestBase {
// Add a filter, so the view result is empty.
$view->setDisplay('default');
- $item = array(
+ $item = [
'table' => 'views_test_data',
'field' => 'id',
'id' => 'id',
- 'value' => array('value' => 7297)
- );
+ 'value' => ['value' => 7297]
+ ];
$view->setHandler('default', 'filter', 'id', $item);
$this->executeView($view);
$this->assertFalse(count($view->result), 'Ensure the result of the view is empty.');
diff --git a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
index b51129cf4c8..cfb3c0a0713 100644
--- a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
+++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
@@ -24,25 +24,25 @@ class ExposedFormTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_exposed_form_buttons', 'test_exposed_block', 'test_exposed_form_sort_items_per_page');
+ public static $testViews = ['test_exposed_form_buttons', 'test_exposed_block', 'test_exposed_form_sort_items_per_page'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'views_ui', 'block', 'entity_test');
+ public static $modules = ['node', 'views_ui', 'block', 'entity_test'];
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
// Create some random nodes.
for ($i = 0; $i < 5; $i++) {
- $this->drupalCreateNode(array('type' => 'article'));
+ $this->drupalCreateNode(['type' => 'article']);
}
}
@@ -90,7 +90,7 @@ class ExposedFormTest extends ViewTestBase {
$view = Views::getView('test_exposed_form_buttons');
$view->setDisplay();
$identifier = 'new_identifier';
- $view->displayHandlers->get('default')->overrideOption('filters', array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
'type' => [
'exposed' => TRUE,
'field' => 'type',
@@ -107,9 +107,9 @@ class ExposedFormTest extends ViewTestBase {
'description' => 'Exposed overridden description'
],
]
- ));
+ ]);
$view->save();
- $this->drupalGet('test_exposed_form_buttons', array('query' => array($identifier => 'article')));
+ $this->drupalGet('test_exposed_form_buttons', ['query' => [$identifier => 'article']]);
$this->assertFieldById(Html::getId('edit-' . $identifier), 'article', "Article type filter set with new identifier.");
// Alter the identifier of the filter to a random string containing
@@ -117,7 +117,7 @@ class ExposedFormTest extends ViewTestBase {
$view = Views::getView('test_exposed_form_buttons');
$view->setDisplay();
$identifier = 'bad identifier';
- $view->displayHandlers->get('default')->overrideOption('filters', array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
'type' => [
'exposed' => TRUE,
'field' => 'type',
@@ -134,7 +134,7 @@ class ExposedFormTest extends ViewTestBase {
'description' => 'Exposed overridden description'
],
]
- ));
+ ]);
$this->executeView($view);
$errors = $view->validate();
@@ -153,12 +153,12 @@ class ExposedFormTest extends ViewTestBase {
$this->drupalGet('test_exposed_form_buttons');
$this->assertNoField('edit-reset');
- $this->drupalGet('test_exposed_form_buttons', array('query' => array('type' => 'article')));
+ $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]);
// Test that the type has been set.
$this->assertFieldById('edit-type', 'article', 'Article type filter set.');
// Test the reset works.
- $this->drupalGet('test_exposed_form_buttons', array('query' => array('op' => 'Reset')));
+ $this->drupalGet('test_exposed_form_buttons', ['query' => ['op' => 'Reset']]);
$this->assertResponse(200);
// Test the type has been reset.
$this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.');
@@ -167,7 +167,7 @@ class ExposedFormTest extends ViewTestBase {
$this->assertNoField('edit-reset');
// Test the reset works with type set.
- $this->drupalGet('test_exposed_form_buttons', array('query' => array('type' => 'article', 'op' => 'Reset')));
+ $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article', 'op' => 'Reset']]);
$this->assertResponse(200);
$this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.');
@@ -185,7 +185,7 @@ class ExposedFormTest extends ViewTestBase {
$view->save();
// Look whether the reset button label changed.
- $this->drupalGet('test_exposed_form_buttons', array('query' => array('type' => 'article')));
+ $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]);
$this->assertResponse(200);
$this->helperButtonHasLabel('edit-reset', $expected_label);
@@ -207,7 +207,7 @@ class ExposedFormTest extends ViewTestBase {
$expected_action = $view->display_handler->getUrlInfo()->toString();
$this->assertFieldByXPath('//form/@action', $expected_action, 'The expected value for the action attribute was found.');
// Make sure the description is shown.
- $result = $this->xpath('//form//div[contains(@id, :id) and normalize-space(text())=:description]', array(':id' => 'edit-type--description', ':description' => t('Exposed description')));
+ $result = $this->xpath('//form//div[contains(@id, :id) and normalize-space(text())=:description]', [':id' => 'edit-type--description', ':description' => t('Exposed description')]);
$this->assertEqual(count($result), 1, 'Filter description was found.');
}
@@ -220,7 +220,7 @@ class ExposedFormTest extends ViewTestBase {
$this->drupalCreateNode(['type' => 'page']);
// Use a test theme to convert multi-select elements into checkboxes.
- \Drupal::service('theme_handler')->install(array('views_test_checkboxes_theme'));
+ \Drupal::service('theme_handler')->install(['views_test_checkboxes_theme']);
$this->config('system.theme')
->set('default', 'views_test_checkboxes_theme')
->save();
@@ -264,15 +264,15 @@ class ExposedFormTest extends ViewTestBase {
$this->drupalGet('test_exposed_block');
// Test there is an exposed form in a block.
- $xpath = $this->buildXPathQuery('//div[@id=:id]/form/@id', array(':id' => Html::getUniqueId('block-' . $block->id())));
+ $xpath = $this->buildXPathQuery('//div[@id=:id]/form/@id', [':id' => Html::getUniqueId('block-' . $block->id())]);
$this->assertFieldByXpath($xpath, $this->getExpectedExposedFormId($view), 'Expected form found in views block.');
// Test there is not an exposed form in the view page content area.
- $xpath = $this->buildXPathQuery('//div[@class="view-content"]/form/@id', array(':id' => Html::getUniqueId('block-' . $block->id())));
+ $xpath = $this->buildXPathQuery('//div[@class="view-content"]/form/@id', [':id' => Html::getUniqueId('block-' . $block->id())]);
$this->assertNoFieldByXpath($xpath, $this->getExpectedExposedFormId($view), 'No exposed form found in views content region.');
// Test there is only one views exposed form on the page.
- $elements = $this->xpath('//form[@id=:id]', array(':id' => $this->getExpectedExposedFormId($view)));
+ $elements = $this->xpath('//form[@id=:id]', [':id' => $this->getExpectedExposedFormId($view)]);
$this->assertEqual(count($elements), 1, 'One exposed form block found.');
// Test that the correct option is selected after form submission.
@@ -302,7 +302,7 @@ class ExposedFormTest extends ViewTestBase {
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
$this->assertEqual(count($rows), 0, 'No rows are displayed by default when no input is provided.');
- $this->drupalGet('test_exposed_form_buttons', array('query' => array('type' => 'article')));
+ $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]);
// Ensure that results are displayed.
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
@@ -330,7 +330,7 @@ class ExposedFormTest extends ViewTestBase {
// Ensure that the "on demand text" is not displayed when an exposed filter
// is applied.
- $this->drupalGet('test_exposed_form_buttons', array('query' => array('type' => 'article')));
+ $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]);
$this->assertNoText($on_demand_text);
}
@@ -411,7 +411,7 @@ class ExposedFormTest extends ViewTestBase {
$this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.');
$this->assertRaw('<div class="views-row">', 'Views result shown.');
- $this->drupalPostForm(NULL, array(), t('Submit'));
+ $this->drupalPostForm(NULL, [], t('Submit'));
$this->assertResponse(200);
$form = $this->cssSelect('form.views-exposed-form');
$this->assertTrue($form, 'The exposed form element was found.');
diff --git a/core/modules/views/src/Tests/Plugin/FilterTest.php b/core/modules/views/src/Tests/Plugin/FilterTest.php
index 1b2cf222b59..081835f404c 100644
--- a/core/modules/views/src/Tests/Plugin/FilterTest.php
+++ b/core/modules/views/src/Tests/Plugin/FilterTest.php
@@ -18,21 +18,21 @@ class FilterTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_filter', 'test_filter_in_operator_ui');
+ public static $testViews = ['test_filter', 'test_filter_in_operator_ui'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('views_ui', 'node');
+ public static $modules = ['views_ui', 'node'];
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
- $this->adminUser = $this->drupalCreateUser(array('administer views'));
+ $this->adminUser = $this->drupalCreateUser(['administer views']);
$this->drupalLogin($this->adminUser);
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Page']);
@@ -60,16 +60,16 @@ class FilterTest extends PluginTestBase {
$view->initDisplay();
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'test_filter' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'test_filter' => [
'id' => 'test_filter',
'table' => 'views_test_data',
'field' => 'name',
'operator' => '=',
'value' => 'John',
'group' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
@@ -90,23 +90,23 @@ class FilterTest extends PluginTestBase {
// Check that we have a single element, as a result of applying the '= John'
// filter.
- $this->assertEqual(count($view->result), 1, format_string('Results were returned. @count results.', array('@count' => count($view->result))));
+ $this->assertEqual(count($view->result), 1, format_string('Results were returned. @count results.', ['@count' => count($view->result)]));
$view->destroy();
$view->initDisplay();
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'test_filter' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'test_filter' => [
'id' => 'test_filter',
'table' => 'views_test_data',
'field' => 'name',
'operator' => '<>',
'value' => 'John',
'group' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
@@ -116,15 +116,15 @@ class FilterTest extends PluginTestBase {
// Check if we have the other elements in the dataset, as a result of
// applying the '<> John' filter.
- $this->assertEqual(count($view->result), 4, format_string('Results were returned. @count results.', array('@count' => count($view->result))));
+ $this->assertEqual(count($view->result), 4, format_string('Results were returned. @count results.', ['@count' => count($view->result)]));
$view->destroy();
$view->initDisplay();
// Set the test_enable option to FALSE. The 'where' clause should not be
// added to the query.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'test_filter' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'test_filter' => [
'id' => 'test_filter',
'table' => 'views_test_data',
'field' => 'name',
@@ -133,14 +133,14 @@ class FilterTest extends PluginTestBase {
'group' => 0,
// Disable this option, so nothing should be added to the query.
'test_enable' => FALSE,
- ),
- ));
+ ],
+ ]);
// Execute the view again.
$this->executeView($view);
// Check if we have all 5 results.
- $this->assertEqual(count($view->result), 5, format_string('All @count results returned', array('@count' => count($view->displayHandlers))));
+ $this->assertEqual(count($view->result), 5, format_string('All @count results returned', ['@count' => count($view->displayHandlers)]));
}
/**
diff --git a/core/modules/views/src/Tests/Plugin/MiniPagerTest.php b/core/modules/views/src/Tests/Plugin/MiniPagerTest.php
index 1a73b698088..7e9f57a3050 100644
--- a/core/modules/views/src/Tests/Plugin/MiniPagerTest.php
+++ b/core/modules/views/src/Tests/Plugin/MiniPagerTest.php
@@ -17,14 +17,14 @@ class MiniPagerTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_mini_pager');
+ public static $testViews = ['test_mini_pager'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
/**
* Nodes used by the test.
@@ -36,7 +36,7 @@ class MiniPagerTest extends PluginTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
// Create a bunch of test nodes.
for ($i = 0; $i < 20; $i++) {
$this->nodes[] = $this->drupalCreateNode();
@@ -55,7 +55,7 @@ class MiniPagerTest extends PluginTestBase {
$this->assertText($this->nodes[1]->label());
$this->assertText($this->nodes[2]->label());
- $this->drupalGet('test_mini_pager', array('query' => array('page' => 1)));
+ $this->drupalGet('test_mini_pager', ['query' => ['page' => 1]]);
$this->assertText('‹‹ test', 'The previous link appears.');
$this->assertText('Page 2', 'The current page info shows the second page.');
$this->assertText('›› test', 'The next link appears.');
@@ -63,7 +63,7 @@ class MiniPagerTest extends PluginTestBase {
$this->assertText($this->nodes[4]->label());
$this->assertText($this->nodes[5]->label());
- $this->drupalGet('test_mini_pager', array('query' => array('page' => 6)));
+ $this->drupalGet('test_mini_pager', ['query' => ['page' => 6]]);
$this->assertNoText('›› test', 'The next link appears on the last page.');
$this->assertText('Page 7', 'The current page info shows the last page.');
$this->assertText('‹‹ test', 'The previous link does not appear on the last page.');
@@ -77,9 +77,9 @@ class MiniPagerTest extends PluginTestBase {
$this->assertIdentical($view->get_total_rows, TRUE, 'The query was set to calculate the total number of rows.');
$this->assertEqual(count($this->nodes), $view->total_rows, 'The total row count is equal to the number of nodes.');
- $this->drupalGet('test_mini_pager_total', array('query' => array('page' => 1)));
+ $this->drupalGet('test_mini_pager_total', ['query' => ['page' => 1]]);
$this->assertText('of ' . count($this->nodes), 'The first page shows the total row count.');
- $this->drupalGet('test_mini_pager_total', array('query' => array('page' => 6)));
+ $this->drupalGet('test_mini_pager_total', ['query' => ['page' => 6]]);
$this->assertText('of ' . count($this->nodes), 'The last page shows the total row count.');
// Test a mini pager with just one item per page.
@@ -88,13 +88,13 @@ class MiniPagerTest extends PluginTestBase {
$this->assertText('Page 1');
$this->assertText($this->nodes[0]->label());
- $this->drupalGet('test_mini_pager_one', array('query' => array('page' => 1)));
+ $this->drupalGet('test_mini_pager_one', ['query' => ['page' => 1]]);
$this->assertText('‹‹');
$this->assertText('Page 2');
$this->assertText('››');
$this->assertText($this->nodes[1]->label());
- $this->drupalGet('test_mini_pager_one', array('query' => array('page' => 19)));
+ $this->drupalGet('test_mini_pager_one', ['query' => ['page' => 19]]);
$this->assertNoText('››');
$this->assertText('Page 20');
$this->assertText('‹‹');
diff --git a/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php b/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php
index bb0632875c6..79f1922a922 100644
--- a/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php
+++ b/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php
@@ -18,14 +18,14 @@ class NumericFormatPluralTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('views_ui', 'file', 'language', 'locale');
+ public static $modules = ['views_ui', 'file', 'language', 'locale'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('numeric_test');
+ public static $testViews = ['numeric_test'];
protected function setUp() {
parent::setUp();
@@ -59,7 +59,7 @@ class NumericFormatPluralTest extends ViewTestBase {
// Assert that changing the settings will change configuration properly.
$edit = ['options[format_plural_values][0]' => '1 time', 'options[format_plural_values][1]' => '@count times'];
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$config = $this->config('views.view.numeric_test');
$field_config_prefix = 'display.default.display_options.fields.count.';
@@ -103,7 +103,7 @@ class NumericFormatPluralTest extends ViewTestBase {
'options[format_plural_values][3]' => '@count time3',
];
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$config = $this->config('views.view.numeric_test');
$field_config_prefix = 'display.default.display_options.fields.count.';
$this->assertEqual($config->get($field_config_prefix . 'format_plural'), TRUE);
diff --git a/core/modules/views/src/Tests/Plugin/PagerTest.php b/core/modules/views/src/Tests/Plugin/PagerTest.php
index f922748e4d2..907fef2a569 100644
--- a/core/modules/views/src/Tests/Plugin/PagerTest.php
+++ b/core/modules/views/src/Tests/Plugin/PagerTest.php
@@ -20,14 +20,14 @@ class PagerTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_store_pager_settings', 'test_pager_none', 'test_pager_some', 'test_pager_full', 'test_view_pager_full_zero_items_per_page', 'test_view', 'content');
+ public static $testViews = ['test_store_pager_settings', 'test_pager_none', 'test_pager_some', 'test_pager_full', 'test_view_pager_full_zero_items_per_page', 'test_view', 'content'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'views_ui');
+ public static $modules = ['node', 'views_ui'];
/**
* String translation storage object.
@@ -45,27 +45,27 @@ class PagerTest extends PluginTestBase {
// Show the master display so the override selection is shown.
\Drupal::configFactory()->getEditable('views.settings')->set('ui.show.master_display', TRUE)->save();
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
// Test behavior described in
// https://www.drupal.org/node/652712#comment-2354918.
$this->drupalGet('admin/structure/views/view/test_view/edit');
- $edit = array(
+ $edit = [
'pager[type]' => 'full',
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager', $edit, t('Apply'));
- $edit = array(
+ $edit = [
'pager_options[items_per_page]' => 20,
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager_options', $edit, t('Apply'));
$this->assertText('20 items');
// Change type and check whether the type is new type is stored.
- $edit = array(
+ $edit = [
'pager[type]' => 'mini',
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager', $edit, t('Apply'));
$this->drupalGet('admin/structure/views/view/test_view/edit');
$this->assertText('Mini', 'Changed pager plugin, should change some text');
@@ -78,38 +78,38 @@ class PagerTest extends PluginTestBase {
$this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit');
- $edit = array(
+ $edit = [
'pager[type]' => 'full',
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/default/pager', $edit, t('Apply'));
$this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit');
$this->assertText('Full');
- $edit = array(
+ $edit = [
'pager_options[items_per_page]' => 20,
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
$this->assertText('20 items');
// add new display and test the settings again, by override it.
- $edit = array( );
+ $edit = [ ];
// Add a display and override the pager settings.
$this->drupalPostForm('admin/structure/views/view/test_store_pager_settings/edit', $edit, t('Add Page'));
- $edit = array(
+ $edit = [
'override[dropdown]' => 'page_1',
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));
- $edit = array(
+ $edit = [
'pager[type]' => 'mini',
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));
$this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit/page_1');
$this->assertText('Mini', 'Changed pager plugin, should change some text');
- $edit = array(
+ $edit = [
'pager_options[items_per_page]' => 10,
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
$this->assertText('10 items', 'The default value has been changed.');
$this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit/page_1');
@@ -128,7 +128,7 @@ class PagerTest extends PluginTestBase {
public function testNoLimit() {
// Create 11 nodes and make sure that everyone is returned.
// We create 11 nodes, because the default pager plugin had 10 items per page.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 11; $i++) {
$this->drupalCreateNode();
}
@@ -139,12 +139,12 @@ class PagerTest extends PluginTestBase {
// Setup and test a offset.
$view = Views::getView('test_pager_none');
$view->setDisplay();
- $pager = array(
+ $pager = [
'type' => 'none',
- 'options' => array(
+ 'options' => [
'offset' => 3,
- ),
- );
+ ],
+ ];
$view->display_handler->setOption('pager', $pager);
$this->executeView($view);
@@ -157,7 +157,7 @@ class PagerTest extends PluginTestBase {
}
public function testViewTotalRowsWithoutPager() {
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 23; $i++) {
$this->drupalCreateNode();
}
@@ -175,7 +175,7 @@ class PagerTest extends PluginTestBase {
public function testLimit() {
// Create 11 nodes and make sure that everyone is returned.
// We create 11 nodes, because the default pager plugin had 10 items per page.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 11; $i++) {
$this->drupalCreateNode();
}
@@ -187,13 +187,13 @@ class PagerTest extends PluginTestBase {
// Setup and test a offset.
$view = Views::getView('test_pager_some');
$view->setDisplay();
- $pager = array(
+ $pager = [
'type' => 'none',
- 'options' => array(
+ 'options' => [
'offset' => 8,
'items_per_page' => 5,
- ),
- );
+ ],
+ ];
$view->display_handler->setOption('pager', $pager);
$this->executeView($view);
$this->assertEqual(count($view->result), 3, 'Make sure that only a certain count of items is returned');
@@ -209,7 +209,7 @@ class PagerTest extends PluginTestBase {
public function testNormalPager() {
// Create 11 nodes and make sure that everyone is returned.
// We create 11 nodes, because the default pager plugin had 10 items per page.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 11; $i++) {
$this->drupalCreateNode();
}
@@ -221,13 +221,13 @@ class PagerTest extends PluginTestBase {
// Setup and test a offset.
$view = Views::getView('test_pager_full');
$view->setDisplay();
- $pager = array(
+ $pager = [
'type' => 'full',
- 'options' => array(
+ 'options' => [
'offset' => 8,
'items_per_page' => 5,
- ),
- );
+ ],
+ ];
$view->display_handler->setOption('pager', $pager);
$this->executeView($view);
$this->assertEqual(count($view->result), 3, 'Make sure that only a certain count of items is returned');
@@ -244,13 +244,13 @@ class PagerTest extends PluginTestBase {
// Setup and test a offset.
$view = Views::getView('test_pager_full');
$view->setDisplay();
- $pager = array(
+ $pager = [
'type' => 'full',
- 'options' => array(
+ 'options' => [
'offset' => 0,
'items_per_page' => 0,
- ),
- );
+ ],
+ ];
$view->display_handler->setOption('pager', $pager);
$this->executeView($view);
@@ -268,7 +268,7 @@ class PagerTest extends PluginTestBase {
public function testRenderNullPager() {
// Create 11 nodes and make sure that everyone is returned.
// We create 11 nodes, because the default pager plugin had 10 items per page.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 11; $i++) {
$this->drupalCreateNode();
}
@@ -348,10 +348,10 @@ class PagerTest extends PluginTestBase {
$view->save();
// Enable locale, config_translation and language module.
- $this->container->get('module_installer')->install(array('locale', 'language', 'config_translation'));
+ $this->container->get('module_installer')->install(['locale', 'language', 'config_translation']);
$this->resetAll();
- $admin_user = $this->drupalCreateUser(array('access content overview', 'administer nodes', 'bypass node access', 'translate configuration'));
+ $admin_user = $this->drupalCreateUser(['access content overview', 'administer nodes', 'bypass node access', 'translate configuration']);
$this->drupalLogin($admin_user);
$langcode = 'nl';
@@ -362,29 +362,29 @@ class PagerTest extends PluginTestBase {
// Add Dutch language programmatically.
ConfigurableLanguage::createFromLangcode($langcode)->save();
- $edit = array(
+ $edit = [
'translation[config_names][views.view.content][display][default][display_options][pager][options][tags][first]' => '« Eerste',
'translation[config_names][views.view.content][display][default][display_options][pager][options][tags][previous]' => '‹ Vorige',
'translation[config_names][views.view.content][display][default][display_options][pager][options][tags][next]' => 'Volgende ›',
'translation[config_names][views.view.content][display][default][display_options][pager][options][tags][last]' => 'Laatste »',
- );
+ ];
$this->drupalPostForm('admin/structure/views/view/content/translate/nl/edit', $edit, t('Save translation'));
// We create 11 nodes, this will give us 3 pages.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 11; $i++) {
$this->drupalCreateNode();
}
// Go to the second page so we see both previous and next buttons.
- $this->drupalGet('nl/admin/content', array('query' => array('page' => 1)));
+ $this->drupalGet('nl/admin/content', ['query' => ['page' => 1]]);
// Translation mapping..
- $labels = array(
+ $labels = [
'« First' => '« Eerste',
'‹ Previous' => '‹ Vorige',
'Next ›' => 'Volgende ›',
'Last »' => 'Laatste »',
- );
+ ];
foreach ($labels as $label => $translation) {
// Check if we can find the translation.
$this->assertRaw($translation);
@@ -396,7 +396,7 @@ class PagerTest extends PluginTestBase {
*/
public function testPagerLocale() {
// Enable locale and language module.
- $this->container->get('module_installer')->install(array('locale', 'language'));
+ $this->container->get('module_installer')->install(['locale', 'language']);
$this->resetAll();
$langcode = 'nl';
@@ -407,31 +407,31 @@ class PagerTest extends PluginTestBase {
ConfigurableLanguage::createFromLangcode($langcode)->save();
// Labels that need translations.
- $labels = array(
+ $labels = [
'« First' => '« Eerste',
'‹ Previous' => '‹ Vorige',
'Next ›' => 'Volgende ›',
'Last »' => 'Laatste »',
- );
+ ];
foreach ($labels as $label => $translation) {
// Create source string.
$source = $this->localeStorage->createString(
- array(
+ [
'source' => $label
- )
+ ]
);
$source->save();
$this->createTranslation($source, $translation, $langcode);
}
// We create 11 nodes, this will give us 3 pages.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 11; $i++) {
$this->drupalCreateNode();
}
// Go to the second page so we see both previous and next buttons.
- $this->drupalGet('nl/test_pager_full', array('query' => array('page' => 1)));
+ $this->drupalGet('nl/test_pager_full', ['query' => ['page' => 1]]);
foreach ($labels as $label => $translation) {
// Check if we can find the translation.
$this->assertRaw($translation);
@@ -442,11 +442,11 @@ class PagerTest extends PluginTestBase {
* Creates single translation for source string.
*/
protected function createTranslation($source, $translation, $langcode) {
- $values = array(
+ $values = [
'lid' => $source->lid,
'language' => $langcode,
'translation' => $translation,
- );
+ ];
return $this->localeStorage->createTranslation($values)->save();
}
diff --git a/core/modules/views/src/Tests/Plugin/StyleGridTest.php b/core/modules/views/src/Tests/Plugin/StyleGridTest.php
index 49bf67d4392..3b8989cbdb0 100644
--- a/core/modules/views/src/Tests/Plugin/StyleGridTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleGridTest.php
@@ -18,12 +18,12 @@ class StyleGridTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_grid');
+ public static $testViews = ['test_grid'];
/**
* Keeps track of which alignments have been tested.
*/
- protected $alignmentsTested = array();
+ protected $alignmentsTested = [];
/**
* {@inheritdoc}
@@ -38,7 +38,7 @@ class StyleGridTest extends PluginTestBase {
*/
public function testGrid() {
$view = Views::getView('test_grid');
- foreach (array('horizontal', 'vertical') as $alignment) {
+ foreach (['horizontal', 'vertical'] as $alignment) {
$this->assertGrid($view, $alignment, 5);
$this->assertGrid($view, $alignment, 4);
$this->assertGrid($view, $alignment, 3);
@@ -73,7 +73,7 @@ class StyleGridTest extends PluginTestBase {
$output = \Drupal::service('renderer')->renderRoot($output);
$this->setRawContent($output);
if (!in_array($alignment, $this->alignmentsTested)) {
- $result = $this->xpath('//div[contains(@class, "views-view-grid") and contains(@class, :alignment) and contains(@class, :columns)]', array(':alignment' => $alignment, ':columns' => 'cols-' . $columns));
+ $result = $this->xpath('//div[contains(@class, "views-view-grid") and contains(@class, :alignment) and contains(@class, :columns)]', [':alignment' => $alignment, ':columns' => 'cols-' . $columns]);
$this->assertTrue(count($result), ucfirst($alignment) . " grid markup detected.");
$this->alignmentsTested[] = $alignment;
}
@@ -86,10 +86,10 @@ class StyleGridTest extends PluginTestBase {
case 1: $width = '100'; break;
}
// Ensure last column exists.
- $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns) and starts-with(@style, :width)]', array(':columns' => 'col-' . $columns, ':width' => 'width: ' . $width));
+ $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns) and starts-with(@style, :width)]', [':columns' => 'col-' . $columns, ':width' => 'width: ' . $width]);
$this->assertTrue(count($result), ucfirst($alignment) . " $columns column grid: last column exists and automatic width calculated correctly.");
// Ensure no extra columns were generated.
- $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns)]', array(':columns' => 'col-' . ($columns + 1)));
+ $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns)]', [':columns' => 'col-' . ($columns + 1)]);
$this->assertFalse(count($result), ucfirst($alignment) . " $columns column grid: no extraneous columns exist.");
// Ensure tokens are being replaced in custom row/column classes.
$result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, "name-John")]');
diff --git a/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php b/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
index 1b4a53de956..4e84433dca1 100644
--- a/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
@@ -15,14 +15,14 @@ class StyleOpmlTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_style_opml');
+ public static $testViews = ['test_style_opml'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('aggregator');
+ public static $modules = ['aggregator'];
/**
* {@inheritdoc}
@@ -32,7 +32,7 @@ class StyleOpmlTest extends PluginTestBase {
$this->enableViewsTestModule();
- $admin_user = $this->drupalCreateUser(array('administer news feeds'));
+ $admin_user = $this->drupalCreateUser(['administer news feeds']);
$this->drupalLogin($admin_user);
}
@@ -41,11 +41,11 @@ class StyleOpmlTest extends PluginTestBase {
*/
public function testOpmlOutput() {
// Create a test feed.
- $values = array(
+ $values = [
'title' => $this->randomMachineName(10),
'url' => 'http://example.com/rss.xml',
'refresh' => '900',
- );
+ ];
$feed = $this->container->get('entity.manager')
->getStorage('aggregator_feed')
->create($values);
diff --git a/core/modules/views/src/Tests/Plugin/StyleTableTest.php b/core/modules/views/src/Tests/Plugin/StyleTableTest.php
index 9a3f25ef946..537839f7bf0 100644
--- a/core/modules/views/src/Tests/Plugin/StyleTableTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleTableTest.php
@@ -16,7 +16,7 @@ class StyleTableTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_table');
+ public static $testViews = ['test_table'];
/**
* {@inheritdoc}
@@ -115,13 +115,13 @@ class StyleTableTest extends PluginTestBase {
$data_set = $this->dataSet();
$query = db_insert('views_test_data')
->fields(array_keys($data_set[0]));
- $query->values(array(
+ $query->values([
'name' => 'James McCartney',
'age' => 0,
'job' => 'Baby',
'created' => gmmktime(6, 30, 10, 1, 1, 2000),
'status' => 1,
- ));
+ ]);
$query->execute();
$this->drupalGet('test-table');
@@ -162,11 +162,11 @@ class StyleTableTest extends PluginTestBase {
// specific style options.
$display = &$view->getDisplay('default');
// Set job as the grouping field.
- $display['display_options']['style']['options']['grouping'][0] = array(
+ $display['display_options']['style']['options']['grouping'][0] = [
'field' => 'job',
'rendered' => TRUE,
'rendered_strip' => FALSE,
- );
+ ];
// Clear the caption text, the rendered job field will be used as a caption.
$display['display_options']['style']['options']['caption'] = '';
$display['display_options']['style']['options']['summary'] = '';
@@ -175,13 +175,13 @@ class StyleTableTest extends PluginTestBase {
// Add a record containing unsafe markup to be sure it's filtered out.
$unsafe_markup = '<script>alert("Rapper");</script>';
- $unsafe_markup_data = array(
+ $unsafe_markup_data = [
'name' => 'Marshall',
'age' => 42,
'job' => $unsafe_markup,
'created' => gmmktime(0, 0, 0, 2, 15, 2001),
'status' => 1,
- );
+ ];
$database = $this->container->get('database');
$database->insert('views_test_data')
->fields(array_keys($unsafe_markup_data))
@@ -189,13 +189,13 @@ class StyleTableTest extends PluginTestBase {
->execute();
$this->drupalGet('test-table');
- $expected_captions = array(
+ $expected_captions = [
'Job: Speaker',
'Job: Songwriter',
'Job: Drummer',
'Job: Singer',
'Job: ' . $unsafe_markup,
- );
+ ];
// Ensure that we don't find the caption containing unsafe markup.
$this->assertNoRaw($unsafe_markup, "Didn't find caption containing unsafe markup.");
@@ -211,13 +211,13 @@ class StyleTableTest extends PluginTestBase {
$view->save();
$this->drupalGet('test-table');
- $expected_captions = array(
+ $expected_captions = [
'Speaker',
'Songwriter',
'Drummer',
'Singer',
$unsafe_markup,
- );
+ ];
// Ensure that we don't find the caption containing unsafe markup.
$this->assertNoRaw($unsafe_markup, "Didn't find caption containing unsafe markup.");
diff --git a/core/modules/views/src/Tests/Plugin/StyleTest.php b/core/modules/views/src/Tests/Plugin/StyleTest.php
index 6773c83cf77..61798a6773b 100644
--- a/core/modules/views/src/Tests/Plugin/StyleTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleTest.php
@@ -22,7 +22,7 @@ class StyleTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Stores the SimpleXML representation of the output.
@@ -100,52 +100,52 @@ class StyleTest extends ViewTestBase {
$view->setDisplay();
// Setup grouping by the job and the age field.
$view->initStyle();
- $view->style_plugin->options['grouping'] = array(
- array('field' => 'job'),
- array('field' => 'age'),
- );
+ $view->style_plugin->options['grouping'] = [
+ ['field' => 'job'],
+ ['field' => 'age'],
+ ];
// Reduce the amount of items to make the test a bit easier.
// Set up the pager.
- $view->displayHandlers->get('default')->overrideOption('pager', array(
+ $view->displayHandlers->get('default')->overrideOption('pager', [
'type' => 'some',
- 'options' => array('items_per_page' => 3),
- ));
+ 'options' => ['items_per_page' => 3],
+ ]);
// Add the job and age field.
- $fields = array(
- 'name' => array(
+ $fields = [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'label' => 'Name',
- ),
- 'job' => array(
+ ],
+ 'job' => [
'id' => 'job',
'table' => 'views_test_data',
'field' => 'job',
'relationship' => 'none',
'label' => 'Job',
- ),
- 'age' => array(
+ ],
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'label' => 'Age',
- ),
- );
+ ],
+ ];
$view->displayHandlers->get('default')->overrideOption('fields', $fields);
// Now run the query and groupby the result.
$this->executeView($view);
- $expected = array();
- $expected['Job: Singer'] = array();
+ $expected = [];
+ $expected['Job: Singer'] = [];
$expected['Job: Singer']['group'] = 'Job: Singer';
$expected['Job: Singer']['level'] = 0;
- $expected['Job: Singer']['rows']['Age: 25'] = array();
+ $expected['Job: Singer']['rows']['Age: 25'] = [];
$expected['Job: Singer']['rows']['Age: 25']['group'] = 'Age: 25';
$expected['Job: Singer']['rows']['Age: 25']['level'] = 1;
$expected['Job: Singer']['rows']['Age: 25']['rows'][0] = new ResultRow(['index' => 0]);
@@ -153,7 +153,7 @@ class StyleTest extends ViewTestBase {
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_data_job = 'Singer';
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_data_age = '25';
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_data_id = '1';
- $expected['Job: Singer']['rows']['Age: 27'] = array();
+ $expected['Job: Singer']['rows']['Age: 27'] = [];
$expected['Job: Singer']['rows']['Age: 27']['group'] = 'Age: 27';
$expected['Job: Singer']['rows']['Age: 27']['level'] = 1;
$expected['Job: Singer']['rows']['Age: 27']['rows'][1] = new ResultRow(['index' => 1]);
@@ -161,10 +161,10 @@ class StyleTest extends ViewTestBase {
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_data_job = 'Singer';
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_data_age = '27';
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_data_id = '2';
- $expected['Job: Drummer'] = array();
+ $expected['Job: Drummer'] = [];
$expected['Job: Drummer']['group'] = 'Job: Drummer';
$expected['Job: Drummer']['level'] = 0;
- $expected['Job: Drummer']['rows']['Age: 28'] = array();
+ $expected['Job: Drummer']['rows']['Age: 28'] = [];
$expected['Job: Drummer']['rows']['Age: 28']['group'] = 'Age: 28';
$expected['Job: Drummer']['rows']['Age: 28']['level'] = 1;
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2] = new ResultRow(['index' => 2]);
@@ -190,8 +190,8 @@ class StyleTest extends ViewTestBase {
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_data_job = 'Drummer' . $rand3;
$expected['Job: Drummer']['group'] = 'Job: Drummer';
- $view->style_plugin->options['grouping'][0] = array('field' => 'job', 'rendered' => TRUE, 'rendered_strip' => TRUE);
- $view->style_plugin->options['grouping'][1] = array('field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE);
+ $view->style_plugin->options['grouping'][0] = ['field' => 'job', 'rendered' => TRUE, 'rendered_strip' => TRUE];
+ $view->style_plugin->options['grouping'][1] = ['field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE];
}
@@ -226,10 +226,10 @@ class StyleTest extends ViewTestBase {
$view->setDisplay();
$view->initStyle();
$view->displayHandlers->get('default')->overrideOption('fields', $fields);
- $view->style_plugin->options['grouping'] = array(
- array('field' => 'job'),
- array('field' => 'age'),
- );
+ $view->style_plugin->options['grouping'] = [
+ ['field' => 'job'],
+ ['field' => 'age'],
+ ];
$this->executeView($view);
@@ -237,8 +237,8 @@ class StyleTest extends ViewTestBase {
$view->result[0]->views_test_data_job .= $rand1;
$view->result[1]->views_test_data_job .= $rand2;
$view->result[2]->views_test_data_job .= $rand3;
- $view->style_plugin->options['grouping'][0] = array('field' => 'job', 'rendered' => TRUE, 'rendered_strip' => TRUE);
- $view->style_plugin->options['grouping'][1] = array('field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE);
+ $view->style_plugin->options['grouping'][0] = ['field' => 'job', 'rendered' => TRUE, 'rendered_strip' => TRUE];
+ $view->style_plugin->options['grouping'][1] = ['field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE];
}
$sets_new_rendered = $view->style_plugin->renderGrouping($view->result, $view->style_plugin->options['grouping'], TRUE);
diff --git a/core/modules/views/src/Tests/Plugin/ViewsBulkTest.php b/core/modules/views/src/Tests/Plugin/ViewsBulkTest.php
index fd988895349..d7df00a25ee 100644
--- a/core/modules/views/src/Tests/Plugin/ViewsBulkTest.php
+++ b/core/modules/views/src/Tests/Plugin/ViewsBulkTest.php
@@ -23,7 +23,7 @@ class ViewsBulkTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'views');
+ public static $modules = ['node', 'views'];
public function setUp() {
parent::setUp();
diff --git a/core/modules/views/src/Tests/Plugin/ViewsFormTest.php b/core/modules/views/src/Tests/Plugin/ViewsFormTest.php
index 01f7a8cff09..a7301893179 100644
--- a/core/modules/views/src/Tests/Plugin/ViewsFormTest.php
+++ b/core/modules/views/src/Tests/Plugin/ViewsFormTest.php
@@ -16,7 +16,7 @@ class ViewsFormTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('action_bulk_test');
+ public static $modules = ['action_bulk_test'];
/**
* Tests the Views form wrapper.
diff --git a/core/modules/views/src/Tests/Plugin/ViewsSqlExceptionTest.php b/core/modules/views/src/Tests/Plugin/ViewsSqlExceptionTest.php
index 27504d2aa01..d3c93de4472 100644
--- a/core/modules/views/src/Tests/Plugin/ViewsSqlExceptionTest.php
+++ b/core/modules/views/src/Tests/Plugin/ViewsSqlExceptionTest.php
@@ -17,7 +17,7 @@ class ViewsSqlExceptionTest extends PluginTestBase {
*
* @var array
*/
- public static $testViews = array('test_filter');
+ public static $testViews = ['test_filter'];
/**
* {@inheritdoc}
@@ -46,16 +46,16 @@ class ViewsSqlExceptionTest extends PluginTestBase {
$view->initDisplay();
// Adding a filter that will result in an invalid query.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'test_filter' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'test_filter' => [
'id' => 'test_exception_filter',
'table' => 'views_test_data',
'field' => 'name',
'operator' => '=',
'value' => 'John',
'group' => 0,
- ),
- ));
+ ],
+ ]);
try {
$this->executeView($view);
diff --git a/core/modules/views/src/Tests/SearchIntegrationTest.php b/core/modules/views/src/Tests/SearchIntegrationTest.php
index e71e1594d50..1b6ab891596 100644
--- a/core/modules/views/src/Tests/SearchIntegrationTest.php
+++ b/core/modules/views/src/Tests/SearchIntegrationTest.php
@@ -16,14 +16,14 @@ class SearchIntegrationTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'search');
+ public static $modules = ['node', 'search'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_search');
+ public static $testViews = ['test_search'];
/**
* Tests search integration.
@@ -36,7 +36,7 @@ class SearchIntegrationTest extends ViewTestBase {
// "sandwich", and one containing "cola is good with pizza". Make the
// second node link to the first.
$node['title'] = 'pizza';
- $node['body'] = array(array('value' => 'pizza'));
+ $node['body'] = [['value' => 'pizza']];
$node['type'] = $type->id();
$this->drupalCreateNode($node);
@@ -44,11 +44,11 @@ class SearchIntegrationTest extends ViewTestBase {
$node_url = $this->getUrl();
$node['title'] = 'sandwich';
- $node['body'] = array(array('value' => 'sandwich with a <a href="' . $node_url . '">link to first node</a>'));
+ $node['body'] = [['value' => 'sandwich with a <a href="' . $node_url . '">link to first node</a>']];
$this->drupalCreateNode($node);
$node['title'] = 'cola';
- $node['body'] = array(array('value' => 'cola is good with pizza'));
+ $node['body'] = [['value' => 'cola is good with pizza']];
$node['type'] = $type->id();
$this->drupalCreateNode($node);
@@ -141,8 +141,8 @@ class SearchIntegrationTest extends ViewTestBase {
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertOneLink($label) {
- $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
- $message = SafeMarkup::format('Link with label %label found once.', array('%label' => $label));
+ $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
+ $message = SafeMarkup::format('Link with label %label found once.', ['%label' => $label]);
return $this->assert(isset($links[0]) && !isset($links[1]), $message);
}
diff --git a/core/modules/views/src/Tests/SearchMultilingualTest.php b/core/modules/views/src/Tests/SearchMultilingualTest.php
index 3fdb8dbd232..f53421917bc 100644
--- a/core/modules/views/src/Tests/SearchMultilingualTest.php
+++ b/core/modules/views/src/Tests/SearchMultilingualTest.php
@@ -17,14 +17,14 @@ class SearchMultilingualTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'search', 'language', 'content_translation');
+ public static $modules = ['node', 'search', 'language', 'content_translation'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_search');
+ public static $testViews = ['test_search'];
/**
* Tests search with multilingual nodes.
@@ -32,7 +32,7 @@ class SearchMultilingualTest extends ViewTestBase {
public function testMultilingualSearchFilter() {
// Create a user with admin for languages, content, and content types, plus
// the ability to access content and searches.
- $user = $this->drupalCreateUser(array('administer nodes', 'administer content types', 'administer languages', 'administer content translation', 'access content', 'search content'));
+ $user = $this->drupalCreateUser(['administer nodes', 'administer content types', 'administer languages', 'administer content translation', 'access content', 'search content']);
$this->drupalLogin($user);
// Add Spanish language programmatically.
@@ -40,24 +40,24 @@ class SearchMultilingualTest extends ViewTestBase {
// Create a content type and make it translatable.
$type = $this->drupalCreateContentType();
- $edit = array(
+ $edit = [
'language_configuration[language_alterable]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/' . $type->id(), $edit, t('Save content type'));
- $edit = array(
+ $edit = [
'entity_types[node]' => TRUE,
'settings[node][' . $type->id() . '][translatable]' => TRUE,
'settings[node][' . $type->id() . '][fields][title]' => TRUE,
'settings[node][' . $type->id() . '][fields][body]' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
// Add a node in English, with title "sandwich".
- $values = array(
+ $values = [
'title' => 'sandwich',
'type' => $type->id(),
- );
+ ];
$node = $this->drupalCreateNode($values);
// "Translate" this node into Spanish, with title "pizza".
diff --git a/core/modules/views/src/Tests/ViewAjaxTest.php b/core/modules/views/src/Tests/ViewAjaxTest.php
index c1705a5b332..b8b2730e6ed 100644
--- a/core/modules/views/src/Tests/ViewAjaxTest.php
+++ b/core/modules/views/src/Tests/ViewAjaxTest.php
@@ -17,7 +17,7 @@ class ViewAjaxTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_ajax_view');
+ public static $testViews = ['test_ajax_view'];
protected function setUp() {
parent::setUp();
@@ -38,14 +38,14 @@ class ViewAjaxTest extends ViewTestBase {
$this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'test_ajax_view', 'The view\'s ajaxViews array entry has the correct \'view_name\' key.');
$this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'page_1', 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.');
- $data = array();
+ $data = [];
$data['view_name'] = 'test_ajax_view';
$data['view_display_id'] = 'test_ajax_view';
- $post = array(
+ $post = [
'view_name' => 'test_ajax_view',
'view_display_id' => 'page_1',
- );
+ ];
$post += $this->getAjaxPageStatePostData();
$response = $this->drupalPost('views/ajax', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$data = Json::decode($response);
diff --git a/core/modules/views/src/Tests/ViewElementTest.php b/core/modules/views/src/Tests/ViewElementTest.php
index 2ec2e679adc..ff11dc2c765 100644
--- a/core/modules/views/src/Tests/ViewElementTest.php
+++ b/core/modules/views/src/Tests/ViewElementTest.php
@@ -16,7 +16,7 @@ class ViewElementTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_view_embed');
+ public static $testViews = ['test_view_embed'];
protected function setUp() {
parent::setUp();
@@ -60,23 +60,23 @@ class ViewElementTest extends ViewTestBase {
$this->assertEqual(count($xpath), 5);
// Add an argument and save the view.
- $view->displayHandlers->get('default')->overrideOption('arguments', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('arguments', [
+ 'age' => [
'default_action' => 'ignore',
'title' => '',
'default_argument_type' => 'fixed',
- 'validate' => array(
+ 'validate' => [
'type' => 'none',
'fail' => 'not found',
- ),
+ ],
'break_phrase' => FALSE,
'not' => FALSE,
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'plugin_id' => 'numeric',
- )
- ));
+ ]
+ ]);
$view->save();
// Test the render array again.
@@ -129,23 +129,23 @@ class ViewElementTest extends ViewTestBase {
$this->assertEqual(count($xpath), 5);
// Add an argument and save the view.
- $view->displayHandlers->get('default')->overrideOption('arguments', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('arguments', [
+ 'age' => [
'default_action' => 'ignore',
'title' => '',
'default_argument_type' => 'fixed',
- 'validate' => array(
+ 'validate' => [
'type' => 'none',
'fail' => 'not found',
- ),
+ ],
'break_phrase' => FALSE,
'not' => FALSE,
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'plugin_id' => 'numeric',
- )
- ));
+ ]
+ ]);
$view->save();
// Test the render array again.
diff --git a/core/modules/views/src/Tests/ViewKernelTestBase.php b/core/modules/views/src/Tests/ViewKernelTestBase.php
index 3a5df3457eb..b39bc7473ae 100644
--- a/core/modules/views/src/Tests/ViewKernelTestBase.php
+++ b/core/modules/views/src/Tests/ViewKernelTestBase.php
@@ -26,7 +26,7 @@ abstract class ViewKernelTestBase extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'views', 'views_test_config', 'views_test_data', 'user');
+ public static $modules = ['system', 'views', 'views_test_config', 'views_test_data', 'user'];
/**
* {@inheritdoc}
@@ -39,11 +39,11 @@ abstract class ViewKernelTestBase extends KernelTestBase {
protected function setUp($import_test_views = TRUE) {
parent::setUp();
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
$this->setUpFixtures();
if ($import_test_views) {
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
}
}
@@ -56,13 +56,13 @@ abstract class ViewKernelTestBase extends KernelTestBase {
protected function setUpFixtures() {
// First install the system module. Many Views have Page displays have menu
// links, and for those to work, the system menus must already be present.
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
// Define the schema and views data variable before enabling the test module.
\Drupal::state()->set('views_test_data_schema', $this->schemaDefinition());
\Drupal::state()->set('views_test_data_views_data', $this->viewsData());
- $this->installConfig(array('views', 'views_test_config', 'views_test_data'));
+ $this->installConfig(['views', 'views_test_config', 'views_test_data']);
foreach ($this->schemaDefinition() as $table => $schema) {
$this->installSchema('views_test_data', $table);
}
@@ -113,7 +113,7 @@ abstract class ViewKernelTestBase extends KernelTestBase {
* @param array $args
* (optional) An array of the view arguments to use for the view.
*/
- protected function executeView($view, array $args = array()) {
+ protected function executeView($view, array $args = []) {
$view->setDisplay();
$view->preExecute($args);
$view->execute();
diff --git a/core/modules/views/src/Tests/ViewRenderTest.php b/core/modules/views/src/Tests/ViewRenderTest.php
index 4bde8b27985..0b3f0ee2577 100644
--- a/core/modules/views/src/Tests/ViewRenderTest.php
+++ b/core/modules/views/src/Tests/ViewRenderTest.php
@@ -16,7 +16,7 @@ class ViewRenderTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_view_render');
+ public static $testViews = ['test_view_render'];
protected function setUp() {
parent::setUp();
diff --git a/core/modules/views/src/Tests/ViewResultAssertionTrait.php b/core/modules/views/src/Tests/ViewResultAssertionTrait.php
index de5a2aac46a..00501f5f0d3 100644
--- a/core/modules/views/src/Tests/ViewResultAssertionTrait.php
+++ b/core/modules/views/src/Tests/ViewResultAssertionTrait.php
@@ -30,7 +30,7 @@ trait ViewResultAssertionTrait {
* @return bool
* TRUE if the assertion succeeded, or FALSE otherwise.
*/
- protected function assertIdenticalResultset($view, $expected_result, $column_map = array(), $message = NULL) {
+ protected function assertIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL) {
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertIdentical', $message);
}
@@ -53,7 +53,7 @@ trait ViewResultAssertionTrait {
* @return bool
* TRUE if the assertion succeeded, or FALSE otherwise.
*/
- protected function assertNotIdenticalResultset($view, $expected_result, $column_map = array(), $message = NULL) {
+ protected function assertNotIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL) {
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertNotIdentical', $message);
}
@@ -81,9 +81,9 @@ trait ViewResultAssertionTrait {
*/
protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $assert_method, $message = NULL) {
// Convert $view->result to an array of arrays.
- $result = array();
+ $result = [];
foreach ($view->result as $key => $value) {
- $row = array();
+ $row = [];
foreach ($column_map as $view_column => $expected_column) {
if (property_exists($value, $view_column)) {
$row[$expected_column] = (string) $value->$view_column;
@@ -104,7 +104,7 @@ trait ViewResultAssertionTrait {
// Remove the columns we don't need from the expected result.
foreach ($expected_result as $key => $value) {
- $row = array();
+ $row = [];
foreach ($column_map as $expected_column) {
// The comparison will be done on the string representation of the value.
if (is_object($value)) {
@@ -136,10 +136,10 @@ trait ViewResultAssertionTrait {
// Do the actual comparison.
if (!isset($message)) {
$not = (strpos($assert_method, 'Not') ? 'not' : '');
- $message = format_string("Actual result <pre>\n@actual\n</pre> is $not identical to expected <pre>\n@expected\n</pre>", array(
+ $message = format_string("Actual result <pre>\n@actual\n</pre> is $not identical to expected <pre>\n@expected\n</pre>", [
'@actual' => var_export($result, TRUE),
'@expected' => var_export($expected_result, TRUE),
- ));
+ ]);
}
return $this->$assert_method($result, $expected_result, $message);
}
diff --git a/core/modules/views/src/Tests/ViewTestBase.php b/core/modules/views/src/Tests/ViewTestBase.php
index 6ce349467bc..c694a8626bc 100644
--- a/core/modules/views/src/Tests/ViewTestBase.php
+++ b/core/modules/views/src/Tests/ViewTestBase.php
@@ -25,12 +25,12 @@ abstract class ViewTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('views', 'views_test_config');
+ public static $modules = ['views', 'views_test_config'];
protected function setUp($import_test_views = TRUE) {
parent::setUp();
if ($import_test_views) {
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
}
}
@@ -45,7 +45,7 @@ abstract class ViewTestBase extends WebTestBase {
\Drupal::state()->set('views_test_data_schema', $this->schemaDefinition());
\Drupal::state()->set('views_test_data_views_data', $this->viewsData());
- \Drupal::service('module_installer')->install(array('views_test_data'));
+ \Drupal::service('module_installer')->install(['views_test_data']);
$this->resetAll();
$this->rebuildContainer();
$this->container->get('module_handler')->reload();
@@ -101,7 +101,7 @@ abstract class ViewTestBase extends WebTestBase {
* TRUE if the assertion was successful, or FALSE on failure.
*/
protected function helperButtonHasLabel($id, $expected_label, $message = 'Label has the expected value: %label.') {
- return $this->assertFieldById($id, $expected_label, t($message, array('%label' => $expected_label)));
+ return $this->assertFieldById($id, $expected_label, t($message, ['%label' => $expected_label]));
}
/**
@@ -112,7 +112,7 @@ abstract class ViewTestBase extends WebTestBase {
* @param array $args
* (optional) An array of the view arguments to use for the view.
*/
- protected function executeView(ViewExecutable $view, $args = array()) {
+ protected function executeView(ViewExecutable $view, $args = []) {
// A view does not really work outside of a request scope, due to many
// dependencies like the current user.
$view->setDisplay();
diff --git a/core/modules/views/src/Tests/ViewTestData.php b/core/modules/views/src/Tests/ViewTestData.php
index d54902d6a6e..7b9bc9ebe1d 100644
--- a/core/modules/views/src/Tests/ViewTestData.php
+++ b/core/modules/views/src/Tests/ViewTestData.php
@@ -23,7 +23,7 @@ class ViewTestData {
* The module directories to look in for test views.
*/
public static function createTestViews($class, array $modules) {
- $views = array();
+ $views = [];
while ($class) {
if (property_exists($class, 'testViews')) {
$views = array_merge($views, $class::$testViews);
@@ -60,57 +60,57 @@ class ViewTestData {
* Returns the schema definition.
*/
public static function schemaDefinition() {
- $schema['views_test_data'] = array(
+ $schema['views_test_data'] = [
'description' => 'Basic test table for Views tests.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'name' => array(
+ ],
+ 'name' => [
'description' => "A person's name",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'age' => array(
+ ],
+ 'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- 'default' => 0),
- 'job' => array(
+ 'default' => 0],
+ 'job' => [
'description' => "The person's job",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Undefined',
- ),
- 'created' => array(
+ ],
+ 'created' => [
'description' => "The creation date of this record",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'status' => array(
+ ],
+ 'status' => [
'description' => "The status of this record",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'name' => array('name')
- ),
- 'indexes' => array(
- 'ages' => array('age'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'name' => ['name']
+ ],
+ 'indexes' => [
+ 'ages' => ['age'],
+ ],
+ ];
return $schema;
}
@@ -119,109 +119,109 @@ class ViewTestData {
*/
public static function viewsData() {
// Declaration of the base table.
- $data['views_test_data']['table'] = array(
+ $data['views_test_data']['table'] = [
'group' => 'Views test',
- 'base' => array(
+ 'base' => [
'field' => 'id',
'title' => 'Views test data',
'help' => 'Users who have created accounts on your site.',
- ),
- );
+ ],
+ ];
// Declaration of fields.
- $data['views_test_data']['id'] = array(
+ $data['views_test_data']['id'] = [
'title' => 'ID',
'help' => 'The test data ID',
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['views_test_data']['name'] = array(
+ ],
+ ];
+ $data['views_test_data']['name'] = [
'title' => 'Name',
'help' => 'The name of the person',
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['views_test_data']['age'] = array(
+ ],
+ ];
+ $data['views_test_data']['age'] = [
'title' => 'Age',
'help' => 'The age of the person',
- 'field' => array(
+ 'field' => [
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'numeric',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'numeric',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['views_test_data']['job'] = array(
+ ],
+ ];
+ $data['views_test_data']['job'] = [
'title' => 'Job',
'help' => 'The job of the person',
- 'field' => array(
+ 'field' => [
'id' => 'standard',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'string',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'string',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
- $data['views_test_data']['created'] = array(
+ ],
+ ];
+ $data['views_test_data']['created'] = [
'title' => 'Created',
'help' => 'The creation date of this record',
- 'field' => array(
+ 'field' => [
'id' => 'date',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'id' => 'date',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'date',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'date',
- ),
- );
- $data['views_test_data']['status'] = array(
+ ],
+ ];
+ $data['views_test_data']['status'] = [
'title' => 'Status',
'help' => 'The status of this record',
- 'field' => array(
+ 'field' => [
'id' => 'boolean',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'id' => 'boolean',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'id' => 'standard',
- ),
- );
+ ],
+ ];
return $data;
}
@@ -229,43 +229,43 @@ class ViewTestData {
* Returns a very simple test dataset.
*/
public static function dataSet() {
- return array(
- array(
+ return [
+ [
'name' => 'John',
'age' => 25,
'job' => 'Singer',
'created' => gmmktime(0, 0, 0, 1, 1, 2000),
'status' => 1,
- ),
- array(
+ ],
+ [
'name' => 'George',
'age' => 27,
'job' => 'Singer',
'created' => gmmktime(0, 0, 0, 1, 2, 2000),
'status' => 0,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
'job' => 'Drummer',
'created' => gmmktime(6, 30, 30, 1, 1, 2000),
'status' => 1,
- ),
- array(
+ ],
+ [
'name' => 'Paul',
'age' => 26,
'job' => 'Songwriter',
'created' => gmmktime(6, 0, 0, 1, 1, 2000),
'status' => 0,
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
'age' => 30,
'job' => 'Speaker',
'created' => gmmktime(6, 30, 10, 1, 1, 2000),
'status' => 1,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/modules/views/src/Tests/ViewsEscapingTest.php b/core/modules/views/src/Tests/ViewsEscapingTest.php
index 08892c0e2a7..1ec3a9f3d0e 100644
--- a/core/modules/views/src/Tests/ViewsEscapingTest.php
+++ b/core/modules/views/src/Tests/ViewsEscapingTest.php
@@ -14,7 +14,7 @@ class ViewsEscapingTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_page_display', 'test_field_header');
+ public static $testViews = ['test_page_display', 'test_field_header'];
/**
* Used by WebTestBase::setup()
@@ -25,7 +25,7 @@ class ViewsEscapingTest extends ViewTestBase {
*
* @see \Drupal\simpletest\WebTestBase::setup()
*/
- public static $modules = array('views', 'theme_test');
+ public static $modules = ['views', 'theme_test'];
/**
* {@inheritdoc}
@@ -47,7 +47,7 @@ class ViewsEscapingTest extends ViewTestBase {
$this->assertNoEscaped('<');
// Install theme to test with template system.
- \Drupal::service('theme_handler')->install(array('views_test_theme'));
+ \Drupal::service('theme_handler')->install(['views_test_theme']);
// Make base theme default then test for hook invocations.
$this->config('system.theme')
diff --git a/core/modules/views/src/Tests/ViewsTemplateTest.php b/core/modules/views/src/Tests/ViewsTemplateTest.php
index 2d7b206da06..4a069082960 100644
--- a/core/modules/views/src/Tests/ViewsTemplateTest.php
+++ b/core/modules/views/src/Tests/ViewsTemplateTest.php
@@ -17,7 +17,7 @@ class ViewsTemplateTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_view_display_template');
+ public static $testViews = ['test_view_display_template'];
/**
* {@inheritdoc}
@@ -26,7 +26,7 @@ class ViewsTemplateTest extends ViewTestBase {
parent::setUp(FALSE);
$this->enableViewsTestModule();
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
}
/**
diff --git a/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php b/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php
index 63e7e2ec6e2..1fe836a82ec 100644
--- a/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php
+++ b/core/modules/views/src/Tests/ViewsThemeIntegrationTest.php
@@ -16,7 +16,7 @@ class ViewsThemeIntegrationTest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_page_display');
+ public static $testViews = ['test_page_display'];
/**
@@ -28,7 +28,7 @@ class ViewsThemeIntegrationTest extends ViewTestBase {
*
* @see \Drupal\simpletest\WebTestBase::setup()
*/
- public static $modules = array('views', 'theme_test');
+ public static $modules = ['views', 'theme_test'];
/**
* {@inheritdoc}
@@ -45,7 +45,7 @@ class ViewsThemeIntegrationTest extends ViewTestBase {
*/
public function testThemedViewPage() {
- \Drupal::service('theme_handler')->install(array('test_basetheme', 'test_subtheme'));
+ \Drupal::service('theme_handler')->install(['test_basetheme', 'test_subtheme']);
// Make base theme default then test for hook invocations.
$this->config('system.theme')
diff --git a/core/modules/views/src/Tests/Wizard/BasicTest.php b/core/modules/views/src/Tests/Wizard/BasicTest.php
index 00237d79a96..e63583227f8 100644
--- a/core/modules/views/src/Tests/Wizard/BasicTest.php
+++ b/core/modules/views/src/Tests/Wizard/BasicTest.php
@@ -21,15 +21,15 @@ class BasicTest extends WizardTestBase {
}
function testViewsWizardAndListing() {
- $this->drupalCreateContentType(array('type' => 'article'));
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'article']);
+ $this->drupalCreateContentType(['type' => 'page']);
// Check if we can access the main views admin page.
$this->drupalGet('admin/structure/views');
$this->assertText(t('Add view'));
// Create a simple and not at all useful view.
- $view1 = array();
+ $view1 = [];
$view1['label'] = $this->randomMachineName(16);
$view1['id'] = strtolower($this->randomMachineName(16));
$view1['description'] = $this->randomMachineName(16);
@@ -51,11 +51,11 @@ class BasicTest extends WizardTestBase {
$this->assertNoText($view1['label']);
// Create two nodes.
- $node1 = $this->drupalCreateNode(array('type' => 'page'));
- $node2 = $this->drupalCreateNode(array('type' => 'article'));
+ $node1 = $this->drupalCreateNode(['type' => 'page']);
+ $node2 = $this->drupalCreateNode(['type' => 'article']);
// Now create a page with simple node listing and an attached feed.
- $view2 = array();
+ $view2 = [];
$view2['label'] = $this->randomMachineName(16);
$view2['id'] = strtolower($this->randomMachineName(16));
$view2['description'] = $this->randomMachineName(16);
@@ -102,7 +102,7 @@ class BasicTest extends WizardTestBase {
$this->assertNoText('View: ' . $view2['label']);
// Create a view with a page and a block, and filter the listing.
- $view3 = array();
+ $view3 = [];
$view3['label'] = $this->randomMachineName(16);
$view3['id'] = strtolower($this->randomMachineName(16));
$view3['description'] = $this->randomMachineName(16);
@@ -150,7 +150,7 @@ class BasicTest extends WizardTestBase {
$this->assertNoText('tracker', 'Default tracker view does not show on the listing page.');
// Create a view with only a REST export.
- $view4 = array();
+ $view4 = [];
$view4['label'] = $this->randomMachineName(16);
$view4['id'] = strtolower($this->randomMachineName(16));
$view4['description'] = $this->randomMachineName(16);
@@ -159,7 +159,7 @@ class BasicTest extends WizardTestBase {
$view4['rest_export[create]'] = 1;
$view4['rest_export[path]'] = $this->randomMachineName(16);
$this->drupalPostForm('admin/structure/views/add', $view4, t('Save and edit'));
- $this->assertRaw(t('The view %view has been saved.', array('%view' => $view4['label'])));
+ $this->assertRaw(t('The view %view has been saved.', ['%view' => $view4['label']]));
// Check that the REST export path works.
$this->drupalGet($view4['rest_export[path]']);
@@ -178,7 +178,7 @@ class BasicTest extends WizardTestBase {
public function testWizardDefaultValues() {
$random_id = strtolower($this->randomMachineName(16));
// Create a basic view.
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = $random_id;
$view['description'] = $this->randomMachineName(16);
@@ -192,8 +192,8 @@ class BasicTest extends WizardTestBase {
$displays = $view->storage->get('display');
foreach ($displays as $display) {
- foreach (array('query', 'exposed_form', 'pager', 'style', 'row') as $type) {
- $this->assertFalse(empty($display['display_options'][$type]['options']), SafeMarkup::format('Default options found for @plugin.', array('@plugin' => $type)));
+ foreach (['query', 'exposed_form', 'pager', 'style', 'row'] as $type) {
+ $this->assertFalse(empty($display['display_options'][$type]['options']), SafeMarkup::format('Default options found for @plugin.', ['@plugin' => $type]));
}
}
}
diff --git a/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php b/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php
index 7a2f4302649..500eff2563d 100644
--- a/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php
+++ b/core/modules/views/src/Tests/Wizard/ItemsPerPageTest.php
@@ -20,22 +20,22 @@ class ItemsPerPageTest extends WizardTestBase {
* Tests the number of items per page.
*/
function testItemsPerPage() {
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
// Create articles, each with a different creation time so that we can do a
// meaningful sort.
- $node1 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME));
- $node2 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 1));
- $node3 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 2));
- $node4 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 3));
- $node5 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 4));
+ $node1 = $this->drupalCreateNode(['type' => 'article', 'created' => REQUEST_TIME]);
+ $node2 = $this->drupalCreateNode(['type' => 'article', 'created' => REQUEST_TIME + 1]);
+ $node3 = $this->drupalCreateNode(['type' => 'article', 'created' => REQUEST_TIME + 2]);
+ $node4 = $this->drupalCreateNode(['type' => 'article', 'created' => REQUEST_TIME + 3]);
+ $node5 = $this->drupalCreateNode(['type' => 'article', 'created' => REQUEST_TIME + 4]);
// Create a page. This should never appear in the view created below.
- $page_node = $this->drupalCreateNode(array('type' => 'page', 'created' => REQUEST_TIME + 2));
+ $page_node = $this->drupalCreateNode(['type' => 'page', 'created' => REQUEST_TIME + 2]);
// Create a view that sorts newest first, and shows 4 items in the page and
// 3 in the block.
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['description'] = $this->randomMachineName(16);
diff --git a/core/modules/views/src/Tests/Wizard/MenuTest.php b/core/modules/views/src/Tests/Wizard/MenuTest.php
index 552ff507800..242065f245e 100644
--- a/core/modules/views/src/Tests/Wizard/MenuTest.php
+++ b/core/modules/views/src/Tests/Wizard/MenuTest.php
@@ -19,7 +19,7 @@ class MenuTest extends WizardTestBase {
$this->drupalPlaceBlock('system_menu_block:main');
// Create a view with a page display and a menu link in the Main Menu.
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['description'] = $this->randomMachineName(16);
@@ -44,9 +44,9 @@ class MenuTest extends WizardTestBase {
/** @var \Drupal\Core\Menu\MenuLinkInterface $link */
$link = $menu_link_manager->createInstance('views_view:views.' . $view['id'] . '.page_1');
$url = $link->getUrlObject();
- $this->assertEqual($url->getRouteName(), 'view.' . $view['id'] . '.page_1', SafeMarkup::format('Found a link to %path in the main menu', array('%path' => $view['page[path]'])));
+ $this->assertEqual($url->getRouteName(), 'view.' . $view['id'] . '.page_1', SafeMarkup::format('Found a link to %path in the main menu', ['%path' => $view['page[path]']]));
$metadata = $link->getMetaData();
- $this->assertEqual(array('view_id' => $view['id'], 'display_id' => 'page_1'), $metadata);
+ $this->assertEqual(['view_id' => $view['id'], 'display_id' => 'page_1'], $metadata);
}
}
diff --git a/core/modules/views/src/Tests/Wizard/NodeWizardTest.php b/core/modules/views/src/Tests/Wizard/NodeWizardTest.php
index 14a1766ed34..dd63efe373b 100644
--- a/core/modules/views/src/Tests/Wizard/NodeWizardTest.php
+++ b/core/modules/views/src/Tests/Wizard/NodeWizardTest.php
@@ -15,9 +15,9 @@ class NodeWizardTest extends WizardTestBase {
* Tests creating a view with node titles.
*/
public function testViewAddWithNodeTitles() {
- $this->drupalCreateContentType(array('type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['description'] = $this->randomMachineName(16);
diff --git a/core/modules/views/src/Tests/Wizard/PagerTest.php b/core/modules/views/src/Tests/Wizard/PagerTest.php
index 1dfc21e5676..2ec6d555118 100644
--- a/core/modules/views/src/Tests/Wizard/PagerTest.php
+++ b/core/modules/views/src/Tests/Wizard/PagerTest.php
@@ -15,9 +15,9 @@ class PagerTest extends WizardTestBase {
public function testPager() {
// Create nodes, each with a different creation time so that we have
// conditions that are meaningful for the use of a pager.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 12; $i++) {
- $this->drupalCreateNode(array('created' => REQUEST_TIME - $i));
+ $this->drupalCreateNode(['created' => REQUEST_TIME - $i]);
}
// Make a View that uses a pager.
@@ -27,14 +27,14 @@ class PagerTest extends WizardTestBase {
// This technique for finding the existence of a pager
// matches that used in Drupal\views_ui\Tests\PreviewTest.php.
- $elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
+ $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Full pager found.');
// Make a View that does not have a pager.
$path_with_no_pager = 'test-view-without-pager';
$this->createViewAtPath($path_with_no_pager, FALSE);
$this->drupalGet($path_with_no_pager);
- $elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
+ $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
$this->assertTrue(empty($elements), 'Full pager not found.');
}
@@ -47,7 +47,7 @@ class PagerTest extends WizardTestBase {
* A boolean for whether the View created should use a pager.
*/
protected function createViewAtPath($path, $pager = TRUE) {
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['show[sort]'] = 'node_field_data-created:ASC';
diff --git a/core/modules/views/src/Tests/Wizard/SortingTest.php b/core/modules/views/src/Tests/Wizard/SortingTest.php
index 61729306bc7..545c50db4a7 100644
--- a/core/modules/views/src/Tests/Wizard/SortingTest.php
+++ b/core/modules/views/src/Tests/Wizard/SortingTest.php
@@ -21,13 +21,13 @@ class SortingTest extends WizardTestBase {
function testSorting() {
// Create nodes, each with a different creation time so that we can do a
// meaningful sort.
- $this->drupalCreateContentType(array('type' => 'page'));
- $node1 = $this->drupalCreateNode(array('created' => REQUEST_TIME));
- $node2 = $this->drupalCreateNode(array('created' => REQUEST_TIME + 1));
- $node3 = $this->drupalCreateNode(array('created' => REQUEST_TIME + 2));
+ $this->drupalCreateContentType(['type' => 'page']);
+ $node1 = $this->drupalCreateNode(['created' => REQUEST_TIME]);
+ $node2 = $this->drupalCreateNode(['created' => REQUEST_TIME + 1]);
+ $node3 = $this->drupalCreateNode(['created' => REQUEST_TIME + 2]);
// Create a view that sorts oldest first.
- $view1 = array();
+ $view1 = [];
$view1['label'] = $this->randomMachineName(16);
$view1['id'] = strtolower($this->randomMachineName(16));
$view1['description'] = $this->randomMachineName(16);
@@ -52,7 +52,7 @@ class SortingTest extends WizardTestBase {
$this->assertTrue($pos1 < $pos2 && $pos2 < $pos3, 'The nodes appear in the expected order in a view that sorts by oldest first.');
// Create a view that sorts newest first.
- $view2 = array();
+ $view2 = [];
$view2['label'] = $this->randomMachineName(16);
$view2['id'] = strtolower($this->randomMachineName(16));
$view2['description'] = $this->randomMachineName(16);
diff --git a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
index 939473f581c..d9299461993 100644
--- a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
+++ b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
@@ -21,7 +21,7 @@ class TaggedWithTest extends WizardTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* Node type with an autocomplete tagging field.
@@ -83,31 +83,31 @@ class TaggedWithTest extends WizardTestBase {
// Create the tag field itself.
$this->tagFieldName = 'field_views_testing_tags';
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->tagVocabulary->id() => $this->tagVocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', $this->nodeTypeWithTags->id(), $this->tagFieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', $this->nodeTypeWithTags->id(), 'default')
- ->setComponent($this->tagFieldName, array(
+ ->setComponent($this->tagFieldName, [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
entity_get_display('node', $this->nodeTypeWithTags->id(), 'default')
- ->setComponent($this->tagFieldName, array(
+ ->setComponent($this->tagFieldName, [
'type' => 'entity_reference_label',
'weight' => 10,
- ))
+ ])
->save();
entity_get_display('node', $this->nodeTypeWithTags->id(), 'teaser')
- ->setComponent('field_views_testing_tags', array(
+ ->setComponent('field_views_testing_tags', [
'type' => 'entity_reference_label',
'weight' => 10,
- ))
+ ])
->save();
}
@@ -120,21 +120,21 @@ class TaggedWithTest extends WizardTestBase {
$node_add_path = 'node/add/' . $this->nodeTypeWithTags->id();
// Create three nodes, with different tags.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $node_tag1_title = $this->randomMachineName();
$edit[$this->tagFieldName . '[target_id]'] = 'tag1';
$this->drupalPostForm($node_add_path, $edit, t('Save'));
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $node_tag1_tag2_title = $this->randomMachineName();
$edit[$this->tagFieldName . '[target_id]'] = 'tag1, tag2';
$this->drupalPostForm($node_add_path, $edit, t('Save'));
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $node_no_tags_title = $this->randomMachineName();
$this->drupalPostForm($node_add_path, $edit, t('Save'));
// Create a view that filters by taxonomy term "tag1". It should show only
// the two nodes from above that are tagged with "tag1".
- $view1 = array();
+ $view1 = [];
// First select the node type and update the form so the correct tag field
// is used.
$view1['show[type]'] = $this->nodeTypeWithTags->id();
@@ -158,7 +158,7 @@ class TaggedWithTest extends WizardTestBase {
// Create a view that filters by taxonomy term "tag2". It should show only
// the one node from above that is tagged with "tag2".
- $view2 = array();
+ $view2 = [];
$view2['show[type]'] = $this->nodeTypeWithTags->id();
$this->drupalPostForm('admin/structure/views/add', $view2, t('Update "of type" choice'));
$this->assertResponse(200);
@@ -202,20 +202,20 @@ class TaggedWithTest extends WizardTestBase {
'field_name' => $this->tagFieldName,
'entity_type' => 'node',
'bundle' => $this->nodeTypeWithoutTags->id(),
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
- 'handler_settings' => array(
- 'target_bundles' => array(
+ 'handler_settings' => [
+ 'target_bundles' => [
$this->tagVocabulary->id() => $this->tagVocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- ),
- ),
+ ],
+ ],
])->save();
entity_get_form_display('node', $this->nodeTypeWithoutTags->id(), 'default')
- ->setComponent($this->tagFieldName, array(
+ ->setComponent($this->tagFieldName, [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
$view['show[type]'] = $this->nodeTypeWithTags->id();
diff --git a/core/modules/views/src/Tests/Wizard/WizardTestBase.php b/core/modules/views/src/Tests/Wizard/WizardTestBase.php
index e00b01827b8..835b9f4edbe 100644
--- a/core/modules/views/src/Tests/Wizard/WizardTestBase.php
+++ b/core/modules/views/src/Tests/Wizard/WizardTestBase.php
@@ -14,13 +14,13 @@ abstract class WizardTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'views_ui', 'block', 'rest');
+ public static $modules = ['node', 'views_ui', 'block', 'rest'];
protected function setUp() {
parent::setUp();
// Create and log in a user with administer views permission.
- $views_admin = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions'));
+ $views_admin = $this->drupalCreateUser(['administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions']);
$this->drupalLogin($views_admin);
$this->drupalPlaceBlock('local_actions_block');
}
diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 991f6c3d887..b1861f7b367 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -51,14 +51,14 @@ class ViewExecutable implements \Serializable {
*
* @var array
*/
- public $args = array();
+ public $args = [];
/**
* An array of build info.
*
* @var array
*/
- public $build_info = array();
+ public $build_info = [];
/**
* Whether this view uses AJAX.
@@ -74,7 +74,7 @@ class ViewExecutable implements \Serializable {
*
* @var \Drupal\views\ResultRow[]
*/
- public $result = array();
+ public $result = [];
// May be used to override the current pager info.
@@ -111,21 +111,21 @@ class ViewExecutable implements \Serializable {
*
* @var array()
*/
- public $attachment_before = array();
+ public $attachment_before = [];
/**
* Attachments to place after the view.
*
* @var array
*/
- public $attachment_after = array();
+ public $attachment_after = [];
/**
* Feed icons attached to the view.
*
* @var array
*/
- public $feedIcons = array();
+ public $feedIcons = [];
// Exposed widget input
@@ -134,35 +134,35 @@ class ViewExecutable implements \Serializable {
*
* @var array
*/
- public $exposed_data = array();
+ public $exposed_data = [];
/**
* An array of input values from exposed forms.
*
* @var array
*/
- protected $exposed_input = array();
+ protected $exposed_input = [];
/**
* Exposed widget input directly from the $form_state->getValues().
*
* @var array
*/
- public $exposed_raw_input = array();
+ public $exposed_raw_input = [];
/**
* Used to store views that were previously running if we recurse.
*
* @var \Drupal\views\ViewExecutable[]
*/
- public $old_view = array();
+ public $old_view = [];
/**
* To avoid recursion in views embedded into areas.
*
* @var \Drupal\views\ViewExecutable[]
*/
- public $parent_views = array();
+ public $parent_views = [];
/**
* Whether this view is an attachment to another view.
@@ -680,7 +680,7 @@ class ViewExecutable implements \Serializable {
$this->exposed_input = \Drupal::request()->query->all();
// unset items that are definitely not our input:
- foreach (array('page', 'q') as $key) {
+ foreach (['page', 'q'] as $key) {
if (isset($this->exposed_input[$key])) {
unset($this->exposed_input[$key]);
}
@@ -788,7 +788,7 @@ class ViewExecutable implements \Serializable {
// Ensure the requested display exists.
if (!$this->displayHandlers->has($display_id)) {
- debug(format_string('setDisplay() called with invalid display ID "@display".', array('@display' => $display_id)));
+ debug(format_string('setDisplay() called with invalid display ID "@display".', ['@display' => $display_id]));
return FALSE;
}
@@ -956,10 +956,10 @@ class ViewExecutable implements \Serializable {
* An array of base tables to be used by the view.
*/
public function getBaseTables() {
- $base_tables = array(
+ $base_tables = [
$this->storage->get('base_table') => TRUE,
'#global' => TRUE,
- );
+ ];
foreach ($this->display_handler->getHandlers('relationship') as $handler) {
$base_tables[$handler->definition['base']] = TRUE;
@@ -1054,7 +1054,7 @@ class ViewExecutable implements \Serializable {
// build arguments.
$position = -1;
- $substitutions = array();
+ $substitutions = [];
$status = TRUE;
// Get the title.
@@ -1192,18 +1192,18 @@ class ViewExecutable implements \Serializable {
// Let modules modify the view just prior to building it.
$module_handler = \Drupal::moduleHandler();
- $module_handler->invokeAll('views_pre_build', array($this));
+ $module_handler->invokeAll('views_pre_build', [$this]);
// Attempt to load from cache.
// @todo Load a build_info from cache.
$start = microtime(TRUE);
// If that fails, let's build!
- $this->build_info = array(
+ $this->build_info = [
'query' => '',
'count_query' => '',
- 'query_args' => array(),
- );
+ 'query_args' => [],
+ ];
$this->initQuery();
@@ -1314,7 +1314,7 @@ class ViewExecutable implements \Serializable {
$this->attachDisplays();
// Let modules modify the view just after building it.
- $module_handler->invokeAll('views_post_build', array($this));
+ $module_handler->invokeAll('views_post_build', [$this]);
return TRUE;
}
@@ -1335,7 +1335,7 @@ class ViewExecutable implements \Serializable {
foreach ($handlers as $id => $data) {
if (!empty($handlers[$id]) && is_object($handlers[$id])) {
- $multiple_exposed_input = array(0 => NULL);
+ $multiple_exposed_input = [0 => NULL];
if ($handlers[$id]->multipleExposedInput()) {
$multiple_exposed_input = $handlers[$id]->groupMultipleExposedInput($this->exposed_data);
}
@@ -1391,7 +1391,7 @@ class ViewExecutable implements \Serializable {
// Let modules modify the view just prior to executing it.
$module_handler = \Drupal::moduleHandler();
- $module_handler->invokeAll('views_pre_execute', array($this));
+ $module_handler->invokeAll('views_pre_execute', [$this]);
// Check for already-cached results.
/** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */
@@ -1418,7 +1418,7 @@ class ViewExecutable implements \Serializable {
}
// Let modules modify the view just after executing it.
- $module_handler->invokeAll('views_post_execute', array($this));
+ $module_handler->invokeAll('views_post_execute', [$this]);
return $this->executed = TRUE;
}
@@ -1494,7 +1494,7 @@ class ViewExecutable implements \Serializable {
$this->style_plugin->preRender($this->result);
// Let each area handler have access to the result set.
- $areas = array('header', 'footer');
+ $areas = ['header', 'footer'];
// Only call preRender() on the empty handlers if the result is empty.
if (empty($this->result)) {
$areas[] = 'empty';
@@ -1506,7 +1506,7 @@ class ViewExecutable implements \Serializable {
}
// Let modules modify the view just prior to rendering it.
- $module_handler->invokeAll('views_pre_render', array($this));
+ $module_handler->invokeAll('views_pre_render', [$this]);
// Let the themes play too, because pre render is a very themey thing.
foreach ($themes as $theme_name) {
@@ -1523,7 +1523,7 @@ class ViewExecutable implements \Serializable {
$cache->postRender($this->display_handler->output);
// Let modules modify the view output after it is rendered.
- $module_handler->invokeAll('views_post_render', array($this, &$this->display_handler->output, $cache));
+ $module_handler->invokeAll('views_post_render', [$this, &$this->display_handler->output, $cache]);
// Let the themes play too, because post render is a very themey thing.
foreach ($themes as $theme_name) {
@@ -1570,7 +1570,7 @@ class ViewExecutable implements \Serializable {
* A renderable array with #type 'view' or NULL if the display ID was
* invalid.
*/
- public function buildRenderable($display_id = NULL, $args = array(), $cache = TRUE) {
+ public function buildRenderable($display_id = NULL, $args = [], $cache = TRUE) {
// @todo Extract that into a generic method.
if (empty($this->current_display) || $this->current_display != $this->chooseDisplay($display_id)) {
if (!$this->setDisplay($display_id)) {
@@ -1603,7 +1603,7 @@ class ViewExecutable implements \Serializable {
* A renderable array containing the view output or NULL if the display ID
* of the view to be executed doesn't exist.
*/
- public function executeDisplay($display_id = NULL, $args = array()) {
+ public function executeDisplay($display_id = NULL, $args = []) {
if (empty($this->current_display) || $this->current_display != $this->chooseDisplay($display_id)) {
if (!$this->setDisplay($display_id)) {
return NULL;
@@ -1635,7 +1635,7 @@ class ViewExecutable implements \Serializable {
* A renderable array containing the view output or NULL if the display ID
* of the view to be executed doesn't exist.
*/
- public function preview($display_id = NULL, $args = array()) {
+ public function preview($display_id = NULL, $args = []) {
if (empty($this->current_display) || ((!empty($display_id)) && $this->current_display != $display_id)) {
if (!$this->setDisplay($display_id)) {
return FALSE;
@@ -1657,7 +1657,7 @@ class ViewExecutable implements \Serializable {
* @param array $args
* An array of arguments from the URL that can be used by the view.
*/
- public function preExecute($args = array()) {
+ public function preExecute($args = []) {
$this->old_view[] = views_get_current_view();
views_set_current_view($this);
$display_id = $this->current_display;
@@ -1669,7 +1669,7 @@ class ViewExecutable implements \Serializable {
}
// Let modules modify the view just prior to executing it.
- \Drupal::moduleHandler()->invokeAll('views_pre_view', array($this, $display_id, &$this->args));
+ \Drupal::moduleHandler()->invokeAll('views_pre_view', [$this, $display_id, &$this->args]);
// Allow hook_views_pre_view() to set the dom_id, then ensure it is set.
$this->dom_id = !empty($this->dom_id) ? $this->dom_id : hash('sha256', $this->storage->id() . REQUEST_TIME . mt_rand());
@@ -1947,7 +1947,7 @@ class ViewExecutable implements \Serializable {
return $display_handler->getUrlInfo();
}
- $argument_keys = isset($this->argument) ? array_keys($this->argument) : array();
+ $argument_keys = isset($this->argument) ? array_keys($this->argument) : [];
$id = current($argument_keys);
/** @var \Drupal\Core\Url $url */
@@ -2084,7 +2084,7 @@ class ViewExecutable implements \Serializable {
* errors.
*/
public function validate() {
- $errors = array();
+ $errors = [];
$this->initDisplay();
$current_display = $this->current_display;
@@ -2158,7 +2158,7 @@ class ViewExecutable implements \Serializable {
* @return string
* The unique ID for this handler instance.
*/
- public function addHandler($display_id, $type, $table, $field, $options = array(), $id = NULL) {
+ public function addHandler($display_id, $type, $table, $field, $options = [], $id = NULL) {
$types = $this::getHandlerTypes();
$this->setDisplay($display_id);
@@ -2172,11 +2172,11 @@ class ViewExecutable implements \Serializable {
// If the desired type is not found, use the original value directly.
$handler_type = !empty($types[$type]['type']) ? $types[$type]['type'] : $type;
- $fields[$id] = array(
+ $fields[$id] = [
'id' => $id,
'table' => $table,
'field' => $field,
- ) + $options;
+ ] + $options;
if (isset($data['table']['entity type'])) {
$fields[$id]['entity_type'] = $data['table']['entity type'];
@@ -2405,7 +2405,7 @@ class ViewExecutable implements \Serializable {
* An array of theme hook suggestions.
*/
public function buildThemeFunctions($hook) {
- $themes = array();
+ $themes = [];
$display = isset($this->display_handler) ? $this->display_handler->display : NULL;
$id = $this->storage->id();
diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php
index 5628d96a39b..9962d38d574 100644
--- a/core/modules/views/src/Views.php
+++ b/core/modules/views/src/Views.php
@@ -26,7 +26,7 @@ class Views {
*
* @var array
*/
- protected static $plugins = array(
+ protected static $plugins = [
'access' => 'plugin',
'area' => 'handler',
'argument' => 'handler',
@@ -46,7 +46,7 @@ class Views {
'sort' => 'handler',
'style' => 'plugin',
'wizard' => 'plugin',
- );
+ ];
/**
* Returns the views data service.
@@ -139,9 +139,9 @@ class Views {
* @return
* A keyed array of in the form of 'base_table' => 'Description'.
*/
- public static function fetchPluginNames($type, $key = NULL, array $base = array()) {
+ public static function fetchPluginNames($type, $key = NULL, array $base = []) {
$definitions = static::pluginManager($type)->getDefinitions();
- $plugins = array();
+ $plugins = [];
foreach ($definitions as $id => $plugin) {
// Skip plugins that don't conform to our key, if they have one.
@@ -169,7 +169,7 @@ class Views {
* An array of plugin definitions for all types.
*/
public static function getPluginDefinitions() {
- $plugins = array();
+ $plugins = [];
foreach (ViewExecutable::getPluginTypes() as $plugin_type) {
$plugins[$plugin_type] = static::pluginManager($plugin_type)->getDefinitions();
}
@@ -218,7 +218,7 @@ class Views {
->condition("display.*.display_plugin", $plugin_ids, 'IN')
->execute();
- $result = array();
+ $result = [];
foreach (\Drupal::entityTypeManager()->getStorage('view')->loadMultiple($entity_ids) as $view) {
// Check each display to see if it meets the criteria and is enabled.
@@ -309,7 +309,7 @@ class Views {
$views = call_user_func("static::get{$filter}Views");
break;
default:
- return array();
+ return [];
}
// Prepare exclude view strings for comparison.
@@ -327,7 +327,7 @@ class Views {
list($exclude_view_name, $exclude_view_display) = explode(':', "$exclude_view:");
}
- $options = array();
+ $options = [];
foreach ($views as $view) {
$id = $view->id();
// Return only views.
@@ -339,10 +339,10 @@ class Views {
foreach ($view->get('display') as $display_id => $display) {
if (!($id == $exclude_view_name && $display_id == $exclude_view_display)) {
if ($optgroup) {
- $options[$id][$id . ':' . $display['id']] = t('@view : @display', array('@view' => $id, '@display' => $display['id']));
+ $options[$id][$id . ':' . $display['id']] = t('@view : @display', ['@view' => $id, '@display' => $display['id']]);
}
else {
- $options[$id . ':' . $display['id']] = t('View: @view - Display: @display', array('@view' => $id, '@display' => $display['id']));
+ $options[$id . ':' . $display['id']] = t('View: @view - Display: @display', ['@view' => $id, '@display' => $display['id']]);
}
}
}
@@ -368,7 +368,7 @@ class Views {
*/
public static function pluginList() {
$plugin_data = static::getPluginDefinitions();
- $plugins = array();
+ $plugins = [];
foreach (static::getEnabledViews() as $view) {
foreach ($view->get('display') as $display) {
foreach ($plugin_data as $type => $info) {
@@ -389,12 +389,12 @@ class Views {
$key = $type . ':' . $name;
// Add info for this plugin.
if (!isset($plugins[$key])) {
- $plugins[$key] = array(
+ $plugins[$key] = [
'type' => $type,
'title' => $info[$name]['title'],
'provider' => $info[$name]['provider'],
- 'views' => array(),
- );
+ 'views' => [],
+ ];
}
// Add this view to the list for this plugin.
@@ -423,8 +423,8 @@ class Views {
// Statically cache this so translation only occurs once per request for all
// of these values.
if (!isset(static::$handlerTypes)) {
- static::$handlerTypes = array(
- 'field' => array(
+ static::$handlerTypes = [
+ 'field' => [
// title
'title' => static::t('Fields'),
// Lowercase title for mid-sentence.
@@ -434,60 +434,60 @@ class Views {
// Singular lowercase title for mid sentence
'lstitle' => static::t('field'),
'plural' => 'fields',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'title' => static::t('Contextual filters'),
'ltitle' => static::t('contextual filters'),
'stitle' => static::t('Contextual filter'),
'lstitle' => static::t('contextual filter'),
'plural' => 'arguments',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'title' => static::t('Sort criteria'),
'ltitle' => static::t('sort criteria'),
'stitle' => static::t('Sort criterion'),
'lstitle' => static::t('sort criterion'),
'plural' => 'sorts',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'title' => static::t('Filter criteria'),
'ltitle' => static::t('filter criteria'),
'stitle' => static::t('Filter criterion'),
'lstitle' => static::t('filter criterion'),
'plural' => 'filters',
- ),
- 'relationship' => array(
+ ],
+ 'relationship' => [
'title' => static::t('Relationships'),
'ltitle' => static::t('relationships'),
'stitle' => static::t('Relationship'),
'lstitle' => static::t('Relationship'),
'plural' => 'relationships',
- ),
- 'header' => array(
+ ],
+ 'header' => [
'title' => static::t('Header'),
'ltitle' => static::t('header'),
'stitle' => static::t('Header'),
'lstitle' => static::t('Header'),
'plural' => 'header',
'type' => 'area',
- ),
- 'footer' => array(
+ ],
+ 'footer' => [
'title' => static::t('Footer'),
'ltitle' => static::t('footer'),
'stitle' => static::t('Footer'),
'lstitle' => static::t('Footer'),
'plural' => 'footer',
'type' => 'area',
- ),
- 'empty' => array(
+ ],
+ 'empty' => [
'title' => static::t('No results behavior'),
'ltitle' => static::t('no results behavior'),
'stitle' => static::t('No results behavior'),
'lstitle' => static::t('No results behavior'),
'plural' => 'empty',
'type' => 'area',
- ),
- );
+ ],
+ ];
}
return static::$handlerTypes;
@@ -508,7 +508,7 @@ class Views {
return array_keys(static::$plugins);
}
- if (!in_array($type, array('plugin', 'handler'))) {
+ if (!in_array($type, ['plugin', 'handler'])) {
throw new \Exception('Invalid plugin type used. Valid types are "plugin" or "handler".');
}
@@ -522,7 +522,7 @@ class Views {
*
* See the t() documentation for details.
*/
- protected static function t($string, array $args = array(), array $options = array()) {
+ protected static function t($string, array $args = [], array $options = []) {
if (empty(static::$translationManager)) {
static::$translationManager = \Drupal::service('string_translation');
}
diff --git a/core/modules/views/src/ViewsData.php b/core/modules/views/src/ViewsData.php
index a079413337a..e5281abf364 100644
--- a/core/modules/views/src/ViewsData.php
+++ b/core/modules/views/src/ViewsData.php
@@ -40,7 +40,7 @@ class ViewsData {
*
* @var array
*/
- protected $storage = array();
+ protected $storage = [];
/**
* All table storage data loaded from cache.
@@ -50,7 +50,7 @@ class ViewsData {
*
* @var array
*/
- protected $allStorage = array();
+ protected $allStorage = [];
/**
* Whether the data has been fully loaded in this request.
@@ -167,8 +167,8 @@ class ViewsData {
// Write an empty cache entry if no information for that table
// exists to avoid repeated cache get calls for this table and
// prevent loading all tables unnecessarily.
- $this->storage[$key] = array();
- $this->allStorage[$key] = array();
+ $this->storage[$key] = [];
+ $this->allStorage[$key] = [];
}
else {
$this->storage[$key] = $this->allStorage[$key];
@@ -208,7 +208,7 @@ class ViewsData {
* The data that will be cached.
*/
protected function cacheSet($cid, $data) {
- return $this->cacheBackend->set($this->prepareCid($cid), $data, Cache::PERMANENT, array('views_data', 'config:core.extension'));
+ return $this->cacheBackend->set($this->prepareCid($cid), $data, Cache::PERMANENT, ['views_data', 'config:core.extension']);
}
/**
@@ -274,9 +274,9 @@ class ViewsData {
if (!empty($table_info['table']['entity type'])) {
$entity_table = 'views_entity_' . $table_info['table']['entity type'];
- $data[$entity_table]['table']['join'][$table_name] = array(
+ $data[$entity_table]['table']['join'][$table_name] = [
'left_table' => $table_name,
- );
+ ];
$data[$entity_table]['table']['entity type'] = $table_info['table']['entity type'];
// Copy over the default table group if we have none yet.
if (!empty($table_info['table']['group']) && empty($data[$entity_table]['table']['group'])) {
@@ -297,15 +297,15 @@ class ViewsData {
* - weight: The weight of the base table.
*/
public function fetchBaseTables() {
- $tables = array();
+ $tables = [];
foreach ($this->get() as $table => $info) {
if (!empty($info['table']['base'])) {
- $tables[$table] = array(
+ $tables[$table] = [
'title' => $info['table']['base']['title'],
'help' => !empty($info['table']['base']['help']) ? $info['table']['base']['help'] : '',
'weight' => !empty($info['table']['base']['weight']) ? $info['table']['base']['weight'] : 0,
- );
+ ];
}
}
@@ -327,10 +327,10 @@ class ViewsData {
* Clears the class storage and cache.
*/
public function clear() {
- $this->storage = array();
- $this->allStorage = array();
+ $this->storage = [];
+ $this->allStorage = [];
$this->fullyLoaded = FALSE;
- Cache::invalidateTags(array('views_data'));
+ Cache::invalidateTags(['views_data']);
}
}
diff --git a/core/modules/views/src/ViewsDataHelper.php b/core/modules/views/src/ViewsDataHelper.php
index bbdf809ae67..32e6adae8f2 100644
--- a/core/modules/views/src/ViewsDataHelper.php
+++ b/core/modules/views/src/ViewsDataHelper.php
@@ -64,9 +64,9 @@ class ViewsDataHelper {
// each field have a cheap kind of inheritance.
foreach ($data as $table => $table_data) {
- $bases = array();
- $strings = array();
- $skip_bases = array();
+ $bases = [];
+ $strings = [];
+ $skip_bases = [];
foreach ($table_data as $field => $info) {
// Collect table data from this table
if ($field == 'table') {
@@ -78,7 +78,7 @@ class ViewsDataHelper {
$bases[] = $table;
continue;
}
- foreach (array('field', 'sort', 'filter', 'argument', 'relationship', 'area') as $key) {
+ foreach (['field', 'sort', 'filter', 'argument', 'relationship', 'area'] as $key) {
if (!empty($info[$key])) {
if ($grouping && !empty($info[$key]['no group by'])) {
continue;
@@ -96,7 +96,7 @@ class ViewsDataHelper {
$skip_bases[$field][$key][$base_name] = TRUE;
}
}
- foreach (array('title', 'group', 'help', 'base', 'aliases') as $string) {
+ foreach (['title', 'group', 'help', 'base', 'aliases'] as $string) {
// First, try the lowest possible level
if (!empty($info[$key][$string])) {
$strings[$field][$key][$string] = $info[$key][$string];
@@ -120,7 +120,7 @@ class ViewsDataHelper {
}
else {
if ($string != 'base') {
- $strings[$field][$key][$string] = SafeMarkup::format("Error: missing @component", array('@component' => $string));
+ $strings[$field][$key][$string] = SafeMarkup::format("Error: missing @component", ['@component' => $string]);
}
}
}
@@ -143,21 +143,21 @@ class ViewsDataHelper {
// all and add them together. Duplicate keys will be lost and that's
// Just Fine.
if (is_array($base)) {
- $strings = array();
+ $strings = [];
foreach ($base as $base_table) {
if (isset($this->fields[$base_table][$type])) {
$strings += $this->fields[$base_table][$type];
}
}
- uasort($strings, array('self', 'fetchedFieldSort'));
+ uasort($strings, ['self', 'fetchedFieldSort']);
return $strings;
}
if (isset($this->fields[$base][$type])) {
- uasort($this->fields[$base][$type], array($this, 'fetchedFieldSort'));
+ uasort($this->fields[$base][$type], [$this, 'fetchedFieldSort']);
return $this->fields[$base][$type];
}
- return array();
+ return [];
}
/**
diff --git a/core/modules/views/tests/fixtures/update/argument-placeholder.php b/core/modules/views/tests/fixtures/update/argument-placeholder.php
index 2a7cf4bb2f1..2158eb270b7 100644
--- a/core/modules/views/tests/fixtures/update/argument-placeholder.php
+++ b/core/modules/views/tests/fixtures/update/argument-placeholder.php
@@ -11,9 +11,9 @@ use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
$connection->insert('config')
- ->fields(array(
+ ->fields([
'collection' => '',
'name' => 'views.view.test_token_view',
'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml'))),
- ))
+ ])
->execute();
diff --git a/core/modules/views/tests/fixtures/update/boolean-filter-values.php b/core/modules/views/tests/fixtures/update/boolean-filter-values.php
index d78a3edd785..2b8e78fb97a 100644
--- a/core/modules/views/tests/fixtures/update/boolean-filter-values.php
+++ b/core/modules/views/tests/fixtures/update/boolean-filter-values.php
@@ -11,9 +11,9 @@ use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
$connection->insert('config')
- ->fields(array(
+ ->fields([
'collection' => '',
'name' => 'views.view.test_boolean_filter_values',
'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/fixtures/update/views.view.test_boolean_filter_values.yml'))),
- ))
+ ])
->execute();
diff --git a/core/modules/views/tests/fixtures/update/duplicate-field-handler.php b/core/modules/views/tests/fixtures/update/duplicate-field-handler.php
index 775f75a4c2e..21cf164f41a 100644
--- a/core/modules/views/tests/fixtures/update/duplicate-field-handler.php
+++ b/core/modules/views/tests/fixtures/update/duplicate-field-handler.php
@@ -11,9 +11,9 @@ use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
$connection->insert('config')
- ->fields(array(
+ ->fields([
'collection' => '',
'name' => 'views.view.test_duplicate_field_handlers',
'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_duplicate_field_handlers.yml'))),
- ))
+ ])
->execute();
diff --git a/core/modules/views/tests/modules/views_entity_test/views_entity_test.module b/core/modules/views/tests/modules/views_entity_test/views_entity_test.module
index 0506710f53b..cd136538f24 100644
--- a/core/modules/views/tests/modules/views_entity_test/views_entity_test.module
+++ b/core/modules/views/tests/modules/views_entity_test/views_entity_test.module
@@ -22,10 +22,10 @@ function views_entity_test_entity_base_field_info(EntityTypeInterface $entity_ty
->setLabel(t('Test access'))
->setTranslatable(FALSE)
->setSetting('max_length', 64)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 10,
- ));
+ ]);
return $definitions;
}
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php b/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php
index 6e7fcf14eae..987be303699 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Controller/ViewsTestDataController.php
@@ -14,11 +14,11 @@ class ViewsTestDataController {
* an exposed form.
*/
public function errorFormPage() {
- $build = array();
- $build['view'] = array(
+ $build = [];
+ $build['view'] = [
'#type' => 'view',
'#name' => 'test_exposed_form_buttons',
- );
+ ];
$build['error_form'] = \Drupal::formBuilder()->getForm('Drupal\views_test_data\Form\ViewsTestDataErrorForm');
return $build;
diff --git a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementEmbedForm.php b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementEmbedForm.php
index f80092b3ac3..80d19d1faff 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementEmbedForm.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementEmbedForm.php
@@ -21,13 +21,13 @@ class ViewsTestDataElementEmbedForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['view'] = array(
+ $form['view'] = [
'#type' => 'view',
'#name' => 'test_view_embed',
'#display_id' => 'embed_1',
- '#arguments' => array(25),
+ '#arguments' => [25],
'#embed' => TRUE,
- );
+ ];
return $form;
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php
index ba00cacb06a..78aa9980066 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php
@@ -21,13 +21,13 @@ class ViewsTestDataElementForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['view'] = array(
+ $form['view'] = [
'#type' => 'view',
'#name' => 'test_view_embed',
'#display_id' => 'default',
- '#arguments' => array(25),
+ '#arguments' => [25],
'#embed' => FALSE,
- );
+ ];
return $form;
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php
index 77e578c38d0..6ad0361cde2 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php
@@ -21,13 +21,13 @@ class ViewsTestDataErrorForm implements FormInterface {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['text'] = array(
+ $form['text'] = [
'#type' => 'textfield',
- );
- $form['submit'] = array(
+ ];
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php
index b2026f7c5b4..551598632fa 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/access/StaticTest.php
@@ -19,7 +19,7 @@ class StaticTest extends AccessPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['access'] = array('default' => FALSE);
+ $options['access'] = ['default' => FALSE];
return $options;
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php
index 5cd26239a14..74818e8bb31 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php
@@ -27,8 +27,8 @@ class TestExample extends AreaPluginBase {
*/
public function defineOptions() {
$options = parent::defineOptions();
- $options['string'] = array('default' => '');
- $options['custom_access'] = array('default' => TRUE);
+ $options['string'] = ['default' => ''];
+ $options['custom_access'] = ['default' => TRUE];
return $options;
}
@@ -46,11 +46,11 @@ class TestExample extends AreaPluginBase {
*/
public function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
- return array(
+ return [
'#markup' => $this->globalTokenReplace($this->options['string']),
- );
+ ];
}
- return array();
+ return [];
}
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_default/ArgumentDefaultTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_default/ArgumentDefaultTest.php
index b2ad514f36e..ac068e17af4 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_default/ArgumentDefaultTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_default/ArgumentDefaultTest.php
@@ -19,7 +19,7 @@ class ArgumentDefaultTest extends ArgumentDefaultPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['value'] = array('default' => '');
+ $options['value'] = ['default' => ''];
return $options;
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php
index c149dcb01f2..0ff2ba81f1a 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php
@@ -39,7 +39,7 @@ class DisplayTest extends DisplayPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['test_option'] = array('default' => '');
+ $options['test_option'] = ['default' => ''];
return $options;
}
@@ -50,21 +50,21 @@ class DisplayTest extends DisplayPluginBase {
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
- $categories['display_test'] = array(
+ $categories['display_test'] = [
'title' => $this->t('Display test settings'),
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -100,
- ),
- );
+ ],
+ ];
$test_option = $this->getOption('test_option') ?: $this->t('Empty');
- $options['test_option'] = array(
+ $options['test_option'] = [
'category' => 'display_test',
'title' => $this->t('Test option'),
'value' => views_ui_truncate($test_option, 24),
- );
+ ];
}
/**
@@ -76,12 +76,12 @@ class DisplayTest extends DisplayPluginBase {
switch ($form_state->get('section')) {
case 'test_option':
$form['#title'] .= $this->t('Test option');
- $form['test_option'] = array(
+ $form['test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->getOption('test_option'),
- );
+ ];
break;
}
}
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php
index 8e3dbd82c1d..25594c3584a 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php
@@ -39,19 +39,19 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
- $categories['display_extender_test'] = array(
+ $categories['display_extender_test'] = [
'title' => $this->t('Display extender test settings'),
'column' => 'second',
- 'build' => array(
+ 'build' => [
'#weight' => -100,
- ),
- );
+ ],
+ ];
- $options['test_extender_test_option'] = array(
+ $options['test_extender_test_option'] = [
'category' => 'display_extender_test',
'title' => $this->t('Test option'),
'value' => views_ui_truncate($this->options['test_extender_test_option'], 24),
- );
+ ];
}
/**
@@ -61,12 +61,12 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
switch ($form_state->get('section')) {
case 'test_extender_test_option':
$form['#title'] .= $this->t('Test option');
- $form['test_extender_test_option'] = array(
+ $form['test_extender_test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->options['test_extender_test_option'],
- );
+ ];
}
}
@@ -86,7 +86,7 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
* {@inheritdoc}
*/
public function defaultableSections(&$sections, $section = NULL) {
- $sections['test_extender_test_option'] = array('test_extender_test_option');
+ $sections['test_extender_test_option'] = ['test_extender_test_option'];
}
/**
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php
index 4d6cd298d21..5bc7a190cd6 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php
@@ -18,7 +18,7 @@ class FilterTest extends FilterPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['test_enable'] = array('default' => TRUE);
+ $options['test_enable'] = ['default' => TRUE];
return $options;
}
@@ -30,11 +30,11 @@ class FilterTest extends FilterPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['test_enable'] = array(
+ $form['test_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Controls whether the filter plugin should be active'),
'#default_value' => $this->options['test_enable'],
- );
+ ];
}
/**
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
index c1d04cf0c10..cf430af25c0 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
@@ -18,17 +18,17 @@ use Drupal\views\ViewExecutable;
* )
*/
class QueryTest extends QueryPluginBase {
- protected $conditions = array();
- protected $fields = array();
- protected $allItems = array();
- protected $orderBy = array();
+ protected $conditions = [];
+ protected $fields = [];
+ protected $allItems = [];
+ protected $orderBy = [];
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['test_setting'] = array('default' => '');
+ $options['test_setting'] = ['default' => ''];
return $options;
}
@@ -39,11 +39,11 @@ class QueryTest extends QueryPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['test_setting'] = array(
+ $form['test_setting'] = [
'#title' => $this->t('Test setting'),
'#type' => 'textfield',
'#default_value' => $this->options['test_setting'],
- );
+ ];
}
/**
@@ -57,21 +57,21 @@ class QueryTest extends QueryPluginBase {
}
public function addWhere($group, $field, $value = NULL, $operator = NULL) {
- $this->conditions[] = array(
+ $this->conditions[] = [
'field' => $field,
'value' => $value,
'operator' => $operator
- );
+ ];
}
- public function addField($table, $field, $alias = '', $params = array()) {
+ public function addField($table, $field, $alias = '', $params = []) {
$this->fields[$field] = $field;
return $field;
}
- public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) {
- $this->orderBy = array('field' => $field, 'order' => $order);
+ public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = []) {
+ $this->orderBy = ['field' => $field, 'order' => $order];
}
@@ -96,7 +96,7 @@ class QueryTest extends QueryPluginBase {
* {@inheritdoc}
*/
public function execute(ViewExecutable $view) {
- $result = array();
+ $result = [];
foreach ($this->allItems as $element) {
// Run all conditions on the element, and add it to the result if they
// match.
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php
index 8ca36c6ff5d..6af493b1e77 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php
@@ -32,7 +32,7 @@ class RowTest extends RowPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['test_option'] = array('default' => '');
+ $options['test_option'] = ['default' => ''];
return $options;
}
@@ -43,12 +43,12 @@ class RowTest extends RowPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['test_option'] = array(
+ $form['test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->options['test_option'],
- );
+ ];
}
/**
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php
index 2c655e745db..3ae816a8d62 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php
@@ -24,26 +24,26 @@ class MappingTest extends Mapping {
* {@inheritdoc}
*/
protected function defineMapping() {
- return array(
- 'title_field' => array(
+ return [
+ 'title_field' => [
'#title' => $this->t('Title field'),
'#description' => $this->t('Choose the field with the custom title.'),
'#toggle' => TRUE,
'#required' => TRUE,
- ),
- 'name_field' => array(
+ ],
+ 'name_field' => [
'#title' => $this->t('Name field'),
'#description' => $this->t('Choose the field with the custom name.'),
- ),
- 'numeric_field' => array(
+ ],
+ 'numeric_field' => [
'#title' => $this->t('Numeric field'),
'#description' => $this->t('Select one or more numeric fields.'),
'#multiple' => TRUE,
'#toggle' => TRUE,
'#filter' => 'filterNumericFields',
'#required' => TRUE,
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php
index cb66d43f71f..9c0c3d707bd 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php
@@ -40,7 +40,7 @@ class StyleTest extends StylePluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['test_option'] = array('default' => '');
+ $options['test_option'] = ['default' => ''];
return $options;
}
@@ -51,12 +51,12 @@ class StyleTest extends StylePluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['test_option'] = array(
+ $form['test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->options['test_option'],
- );
+ ];
}
/**
diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.install b/core/modules/views/tests/modules/views_test_data/views_test_data.install
index eeb5faa845c..3590440b9fa 100644
--- a/core/modules/views/tests/modules/views_test_data/views_test_data.install
+++ b/core/modules/views/tests/modules/views_test_data/views_test_data.install
@@ -17,7 +17,7 @@ function views_test_data_schema() {
*/
function views_test_data_install() {
// Add the marquee tag to possible html elements to test the field handler.
- $values = array(
+ $values = [
'div' => 'DIV',
'span' => 'SPAN',
'h1' => 'H1',
@@ -30,6 +30,6 @@ function views_test_data_install() {
'strong' => 'STRONG',
'em' => 'EM',
'marquee' => 'MARQUEE'
- );
+ ];
\Drupal::configFactory()->getEditable('views.settings')->set('field_rewrite_elements', $values)->save();
}
diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.module b/core/modules/views/tests/modules/views_test_data/views_test_data.module
index bd917c7eee7..cdb99cc100f 100644
--- a/core/modules/views/tests/modules/views_test_data/views_test_data.module
+++ b/core/modules/views/tests/modules/views_test_data/views_test_data.module
@@ -66,13 +66,13 @@ function views_test_data_preprocess_views_view_table(&$variables) {
* - view: The view object.
*/
function template_preprocess_views_view_mapping_test(&$variables) {
- $variables['element'] = array();
+ $variables['element'] = [];
foreach ($variables['rows'] as $delta => $row) {
- $fields = array();
+ $fields = [];
foreach ($variables['options']['mapping'] as $type => $field_names) {
if (!is_array($field_names)) {
- $field_names = array($field_names);
+ $field_names = [$field_names];
}
foreach ($field_names as $field_name) {
if ($value = $variables['view']->style_plugin->getField($delta, $field_name)) {
@@ -87,26 +87,26 @@ function template_preprocess_views_view_mapping_test(&$variables) {
}
// Build a container for the row.
- $variables['element'][$delta] = array(
+ $variables['element'][$delta] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array(
+ '#attributes' => [
+ 'class' => [
'views-row-mapping-test',
- ),
- ),
- );
+ ],
+ ],
+ ];
// Add each field to the row.
foreach ($fields as $key => $render) {
- $variables['element'][$delta][$key] = array(
+ $variables['element'][$delta][$key] = [
'#children' => $render,
'#type' => 'container',
- '#attributes' => array(
- 'class' => array(
+ '#attributes' => [
+ 'class' => [
$key,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
}
diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.views.inc b/core/modules/views/tests/modules/views_test_data/views_test_data.views.inc
index ceaa8e9fed2..11159412b4a 100644
--- a/core/modules/views/tests/modules/views_test_data/views_test_data.views.inc
+++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views.inc
@@ -39,7 +39,7 @@ function views_test_data_views_data_alter() {
function views_test_data_views_analyze(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_analyze', TRUE);
- $ret = array();
+ $ret = [];
$ret[] = Analyzer::formatMessage(t('Test ok message'), 'ok');
$ret[] = Analyzer::formatMessage(t('Test warning message'), 'warning');
diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
index d9d2a668dbf..dd69f4c95fb 100644
--- a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
+++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
@@ -22,10 +22,10 @@ function views_test_data_views_query_substitutions(ViewExecutable $view) {
function views_test_data_views_form_substitutions() {
\Drupal::state()->set('views_hook_test_views_form_substitutions', TRUE);
$render = ['#markup' => '<em>unescaped</em>'];
- return array(
+ return [
'<!--will-be-escaped-->' => '<em>escaped</em>',
'<!--will-be-not-escaped-->' => \Drupal::service('renderer')->renderPlain($render),
- );
+ ];
}
/**
diff --git a/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php b/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php
index 42da7b6593b..3611829e8c9 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php
@@ -42,7 +42,7 @@ class GlossaryViewTest extends JavascriptTestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
// Create a Content type and some test nodes with titles that start with
// different letters.
diff --git a/core/modules/views/tests/src/Kernel/BasicTest.php b/core/modules/views/tests/src/Kernel/BasicTest.php
index 49f4398bfb1..4ef22b14084 100644
--- a/core/modules/views/tests/src/Kernel/BasicTest.php
+++ b/core/modules/views/tests/src/Kernel/BasicTest.php
@@ -16,7 +16,7 @@ class BasicTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_simple_argument');
+ public static $testViews = ['test_view', 'test_simple_argument'];
/**
* Tests a trivial result set.
@@ -30,10 +30,10 @@ class BasicTest extends ViewsKernelTestBase {
// Verify the result.
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultset($view, $this->dataSet(), array(
+ $this->assertIdenticalResultset($view, $this->dataSet(), [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
}
/**
@@ -44,55 +44,55 @@ class BasicTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a filter.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'operator' => '<',
- 'value' => array(
+ 'value' => [
'value' => '28',
'min' => '',
'max' => '',
- ),
+ ],
'group' => '0',
'exposed' => FALSE,
- 'expose' => array(
+ 'expose' => [
'operator' => FALSE,
'label' => '',
- ),
+ ],
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Execute the view.
$this->executeView($view);
// Build the expected result.
- $dataset = array(
- array(
+ $dataset = [
+ [
'id' => 1,
'name' => 'John',
'age' => 25,
- ),
- array(
+ ],
+ [
'id' => 2,
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'id' => 4,
'name' => 'Paul',
'age' => 26,
- ),
- );
+ ],
+ ];
// Verify the result.
$this->assertEqual(3, count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultSet($view, $dataset, array(
+ $this->assertIdenticalResultSet($view, $dataset, [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
}
/**
@@ -101,24 +101,24 @@ class BasicTest extends ViewsKernelTestBase {
public function testSimpleArgument() {
// Execute with a view
$view = Views::getView('test_simple_argument');
- $view->setArguments(array(27));
+ $view->setArguments([27]);
$this->executeView($view);
// Build the expected result.
- $dataset = array(
- array(
+ $dataset = [
+ [
'id' => 2,
'name' => 'George',
'age' => 27,
- ),
- );
+ ],
+ ];
// Verify the result.
$this->assertEqual(1, count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultSet($view, $dataset, array(
+ $this->assertIdenticalResultSet($view, $dataset, [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
// Test "show all" if no argument is present.
$view = Views::getView('test_simple_argument');
@@ -128,10 +128,10 @@ class BasicTest extends ViewsKernelTestBase {
$dataset = $this->dataSet();
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultSet($view, $dataset, array(
+ $this->assertIdenticalResultSet($view, $dataset, [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
}
}
diff --git a/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php b/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php
index dfcb30e2024..b20f98118c8 100644
--- a/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php
+++ b/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php
@@ -27,7 +27,7 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_row_renderers');
+ public static $testViews = ['test_entity_row_renderers'];
/**
* An array of added languages.
@@ -51,13 +51,13 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
$this->installEntitySchema('node');
$this->installEntitySchema('user');
- $this->installSchema('node', array('node_access'));
- $this->installConfig(array('node', 'language'));
+ $this->installSchema('node', ['node_access']);
+ $this->installConfig(['node', 'language']);
// The entity.node.canonical route must exist when nodes are rendered.
$this->container->get('router.builder')->rebuild();
- $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->getId());
+ $this->langcodes = [\Drupal::languageManager()->getDefaultLanguage()->getId()];
for ($i = 0; $i < 2; $i++) {
$langcode = 'l' . $i;
$this->langcodes[] = $langcode;
@@ -65,27 +65,27 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
}
// Make sure we do not try to render non-existing user data.
- $node_type = NodeType::create(array('type' => 'test'));
+ $node_type = NodeType::create(['type' => 'test']);
$node_type->setDisplaySubmitted(FALSE);
$node_type->save();
- $this->values = array();
+ $this->values = [];
$controller = \Drupal::entityManager()->getStorage('node');
$langcode_index = 0;
for ($i = 0; $i < count($this->langcodes); $i++) {
// Create a node with a different default language each time.
$default_langcode = $this->langcodes[$langcode_index++];
- $node = $controller->create(array('type' => 'test', 'uid' => 0, 'langcode' => $default_langcode));
+ $node = $controller->create(['type' => 'test', 'uid' => 0, 'langcode' => $default_langcode]);
// Ensure the default language is processed first.
- $langcodes = array_merge(array($default_langcode), array_diff($this->langcodes, array($default_langcode)));
+ $langcodes = array_merge([$default_langcode], array_diff($this->langcodes, [$default_langcode]));
foreach ($langcodes as $langcode) {
// Ensure we have a predictable result order.
$this->values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName();
if ($langcode != $default_langcode) {
- $node->addTranslation($langcode, array('title' => $this->values[$i][$langcode]));
+ $node->addTranslation($langcode, ['title' => $this->values[$i][$langcode]]);
}
else {
$node->setTitle($this->values[$i][$langcode]);
@@ -121,7 +121,7 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
* node.
*/
protected function checkLanguageRenderers($display, $values) {
- $expected = array(
+ $expected = [
$values[0]['en'],
$values[0]['en'],
$values[0]['en'],
@@ -131,10 +131,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
$values[2]['en'],
$values[2]['en'],
$values[2]['en'],
- );
+ ];
$this->assertTranslations($display, '***LANGUAGE_language_content***', $expected, 'The current language renderer behaves as expected.');
- $expected = array(
+ $expected = [
$values[0]['en'],
$values[0]['en'],
$values[0]['en'],
@@ -144,10 +144,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
$values[2]['l1'],
$values[2]['l1'],
$values[2]['l1'],
- );
+ ];
$this->assertTranslations($display, '***LANGUAGE_entity_default***', $expected, 'The default language renderer behaves as expected.');
- $expected = array(
+ $expected = [
$values[0]['en'],
$values[0]['l0'],
$values[0]['l1'],
@@ -157,10 +157,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
$values[2]['en'],
$values[2]['l0'],
$values[2]['l1'],
- );
+ ];
$this->assertTranslations($display, '***LANGUAGE_entity_translation***', $expected, 'The translation language renderer behaves as expected.');
- $expected = array(
+ $expected = [
$values[0][$this->langcodes[0]],
$values[0][$this->langcodes[0]],
$values[0][$this->langcodes[0]],
@@ -170,10 +170,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
$values[2][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
- );
+ ];
$this->assertTranslations($display, '***LANGUAGE_site_default***', $expected, 'The site default language renderer behaves as expected.');
- $expected = array(
+ $expected = [
$values[0]['l0'],
$values[0]['l0'],
$values[0]['l0'],
@@ -183,7 +183,7 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
$values[2]['l0'],
$values[2]['l0'],
$values[2]['l0'],
- );
+ ];
$this->assertTranslations($display, 'l0', $expected, 'The language specific renderer behaves as expected.');
}
diff --git a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
index f97659a7f0f..4929c7ecf71 100644
--- a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
+++ b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php
@@ -40,14 +40,14 @@ class ViewEntityDependenciesTest extends ViewsKernelTestBase {
// Install the necessary dependencies for node type creation to work.
$this->installEntitySchema('node');
- $this->installConfig(array('field', 'node'));
+ $this->installConfig(['field', 'node']);
- $comment_type = CommentType::create(array(
+ $comment_type = CommentType::create([
'id' => 'comment',
'label' => 'Comment settings',
'description' => 'Comment settings',
'target_entity_type_id' => 'node',
- ));
+ ]);
$comment_type->save();
$content_type = NodeType::create([
@@ -55,29 +55,29 @@ class ViewEntityDependenciesTest extends ViewsKernelTestBase {
'name' => $this->randomString(),
]);
$content_type->save();
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => Unicode::strtolower($this->randomMachineName()),
'entity_type' => 'node',
'type' => 'comment',
- ));
+ ]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $content_type->id(),
'label' => $this->randomMachineName() . '_label',
'description' => $this->randomMachineName() . '_description',
- 'settings' => array(
+ 'settings' => [
'comment_type' => $comment_type->id(),
- ),
+ ],
])->save();
FieldConfig::create([
'field_storage' => FieldStorageConfig::loadByName('node', 'body'),
'bundle' => $content_type->id(),
'label' => $this->randomMachineName() . '_body',
- 'settings' => array('display_summary' => TRUE),
+ 'settings' => ['display_summary' => TRUE],
])->save();
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
}
/**
diff --git a/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php b/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php
index 3c46c9eddd0..bf982724fe4 100644
--- a/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php
+++ b/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php
@@ -79,7 +79,7 @@ class ViewsEntitySchemaSubscriberIntegrationTest extends ViewsKernelTestBase {
// Install every entity type's schema that wasn't installed in the parent
// method.
- foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(array('user', 'entity_test'))) as $entity_type_id => $entity_type) {
+ foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(['user', 'entity_test'])) as $entity_type_id => $entity_type) {
$this->installEntitySchema($entity_type_id);
}
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
index ebf9e054c80..a95214a782e 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
@@ -31,7 +31,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_area');
+ public static $testViews = ['test_entity_area'];
/**
* {@inheritdoc}
@@ -70,9 +70,9 @@ class AreaEntityTest extends ViewsKernelTestBase {
// Test that all expected entity types have data.
foreach (array_keys($expected_entities) as $entity) {
- $this->assertTrue(!empty($data['entity_' . $entity]), format_string('Views entity area data found for @entity', array('@entity' => $entity)));
+ $this->assertTrue(!empty($data['entity_' . $entity]), format_string('Views entity area data found for @entity', ['@entity' => $entity]));
// Test that entity_type is set correctly in the area data.
- $this->assertEqual($entity, $data['entity_' . $entity]['area']['entity_type'], format_string('Correct entity_type set for @entity', array('@entity' => $entity)));
+ $this->assertEqual($entity, $data['entity_' . $entity]['area']['entity_type'], format_string('Correct entity_type set for @entity', ['@entity' => $entity]));
}
$expected_entities = array_filter($entity_types, function (EntityTypeInterface $type) {
@@ -81,7 +81,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
// Test that no configuration entity types have data.
foreach (array_keys($expected_entities) as $entity) {
- $this->assertTrue(empty($data['entity_' . $entity]), format_string('Views config entity area data not found for @entity', array('@entity' => $entity)));
+ $this->assertTrue(empty($data['entity_' . $entity]), format_string('Views config entity area data not found for @entity', ['@entity' => $entity]));
}
}
@@ -90,10 +90,10 @@ class AreaEntityTest extends ViewsKernelTestBase {
*/
public function testEntityArea() {
/** @var \Drupal\Core\Entity\EntityInterface[] $entities */
- $entities = array();
+ $entities = [];
for ($i = 0; $i < 3; $i++) {
$random_label = $this->randomMachineName();
- $data = array('bundle' => 'entity_test', 'name' => $random_label);
+ $data = ['bundle' => 'entity_test', 'name' => $random_label];
$entity_test = $this->container->get('entity.manager')
->getStorage('entity_test')
->create($data);
@@ -137,7 +137,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
$this->assertTrue(strpos(trim((string) $result[0]), $entities[1]->label()) !== FALSE, 'The rendered entity appears in the footer of the view.');
$this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.');
- $preview = $view->preview('default', array($entities[1]->id()));
+ $preview = $view->preview('default', [$entities[1]->id()]);
$this->setRawContent($renderer->renderRoot($preview));
$result = $this->xpath($header_xpath);
@@ -159,7 +159,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
$item['view_mode'] = 'test';
$view->setHandler('default', 'header', 'entity_entity_test', $item);
- $preview = $view->preview('default', array($entities[1]->id()));
+ $preview = $view->preview('default', [$entities[1]->id()]);
$this->setRawContent($renderer->renderRoot($preview));
$view_class = 'js-view-dom-id-' . $view->dom_id;
$result = $this->xpath('//div[@class = "' . $view_class . '"]/header[1]');
@@ -168,14 +168,14 @@ class AreaEntityTest extends ViewsKernelTestBase {
// Test entity access.
$view = Views::getView('test_entity_area');
- $preview = $view->preview('default', array($entities[2]->id()));
+ $preview = $view->preview('default', [$entities[2]->id()]);
$this->setRawContent($renderer->renderRoot($preview));
$view_class = 'js-view-dom-id-' . $view->dom_id;
$result = $this->xpath('//div[@class = "' . $view_class . '"]/footer[1]');
$this->assertTrue(strpos($result[0], $entities[2]->label()) === FALSE, 'The rendered entity does not appear in the footer of the view.');
// Test the available view mode options.
- $form = array();
+ $form = [];
$form_state = (new FormState())
->set('type', 'header');
$view->display_handler->getHandler('header', 'entity_entity_test')->buildOptionsForm($form, $form_state);
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaMessagesTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaMessagesTest.php
index 7e1fbb9125e..476551c9a8f 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaMessagesTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaMessagesTest.php
@@ -18,7 +18,7 @@ class AreaMessagesTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_area_messages');
+ public static $testViews = ['test_area_messages'];
/**
* Tests the messages area handler.
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php
index 9ade514b8dd..84a66ab5c8f 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php
@@ -21,14 +21,14 @@ class AreaOrderTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('user', 'block');
+ public static $modules = ['user', 'block'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_area_order');
+ public static $testViews = ['test_area_order'];
/**
* {@inheritdoc}
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaTextTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaTextTest.php
index 5ccacd87bb0..2feaaf144e0 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaTextTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaTextTest.php
@@ -13,19 +13,19 @@ use Drupal\views\Views;
*/
class AreaTextTest extends ViewsKernelTestBase {
- public static $modules = array('system', 'user', 'filter');
+ public static $modules = ['system', 'user', 'filter'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
protected function setUp($import_test_views = TRUE) {
parent::setUp();
- $this->installConfig(array('system', 'filter'));
+ $this->installConfig(['system', 'filter']);
$this->installEntitySchema('user');
}
@@ -37,16 +37,16 @@ class AreaTextTest extends ViewsKernelTestBase {
// add a text header
$string = $this->randomMachineName();
- $view->displayHandlers->get('default')->overrideOption('header', array(
- 'area' => array(
+ $view->displayHandlers->get('default')->overrideOption('header', [
+ 'area' => [
'id' => 'area',
'table' => 'views',
'field' => 'area',
- 'content' => array(
+ 'content' => [
'value' => $string,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
// Execute the view.
$this->executeView($view);
@@ -60,7 +60,7 @@ class AreaTextTest extends ViewsKernelTestBase {
$this->assertEqual(check_markup($string), $renderer->renderRoot($build), 'Existent format should return something');
// Empty results, and it shouldn't be displayed .
- $this->assertEqual(array(), $view->display_handler->handlers['header']['area']->render(TRUE), 'No result should lead to no header');
+ $this->assertEqual([], $view->display_handler->handlers['header']['area']->render(TRUE), 'No result should lead to no header');
// Empty results, and it should be displayed.
$view->display_handler->handlers['header']['area']->options['empty'] = TRUE;
$build = $view->display_handler->handlers['header']['area']->render(TRUE);
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php
index f2a4151ea8d..8c16b63088d 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaTitleTest.php
@@ -18,7 +18,7 @@ class AreaTitleTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_area_title');
+ public static $testViews = ['test_area_title'];
/**
* Tests the title area handler.
@@ -34,7 +34,7 @@ class AreaTitleTest extends ViewsKernelTestBase {
$view->setDisplay('default');
$this->executeView($view);
- $view->result = array();
+ $view->result = [];
$view->render();
$this->assertEqual($view->getTitle(), 'test_title_empty', 'The title area should override the title if the result is empty.');
$view->destroy();
@@ -47,7 +47,7 @@ class AreaTitleTest extends ViewsKernelTestBase {
$view->setDisplay('page_1');
$this->executeView($view);
- $view->result = array();
+ $view->result = [];
$view->render();
$this->assertEqual($view->getTitle(), 'test_title_empty', 'The title area should override the title if the result is empty.');
$view->destroy();
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php
index 89fe49e9e23..6eaba132d56 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php
@@ -18,14 +18,14 @@ class AreaViewTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('user');
+ public static $modules = ['user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_simple_argument', 'test_area_view');
+ public static $testViews = ['test_simple_argument', 'test_area_view'];
/**
* Tests the view area handler.
@@ -44,7 +44,7 @@ class AreaViewTest extends ViewsKernelTestBase {
$this->assertTrue(strpos($output, 'js-view-dom-id-' . $view->dom_id) !== FALSE, 'The test view is correctly embedded.');
$view->destroy();
- $view->setArguments(array(27));
+ $view->setArguments([27]);
$this->executeView($view);
$output = $view->render();
$output = $renderer->renderRoot($output);
diff --git a/core/modules/views/tests/src/Kernel/Handler/ArgumentDateTest.php b/core/modules/views/tests/src/Kernel/Handler/ArgumentDateTest.php
index 527bd724f24..db26e11a8fb 100644
--- a/core/modules/views/tests/src/Kernel/Handler/ArgumentDateTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/ArgumentDateTest.php
@@ -18,16 +18,16 @@ class ArgumentDateTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_argument_date');
+ public static $testViews = ['test_argument_date'];
/**
* Stores the column map for this testCase.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'id' => 'id',
- );
+ ];
/**
* {@inheritdoc}
@@ -35,14 +35,14 @@ class ArgumentDateTest extends ViewsKernelTestBase {
public function viewsData() {
$data = parent::viewsData();
- $date_plugins = array(
+ $date_plugins = [
'date_fulldate',
'date_day',
'date_month',
'date_week',
'date_year',
'date_year_month',
- );
+ ];
foreach ($date_plugins as $plugin_id) {
$data['views_test_data'][$plugin_id] = $data['views_test_data']['created'];
$data['views_test_data'][$plugin_id]['real field'] = 'created';
@@ -59,25 +59,25 @@ class ArgumentDateTest extends ViewsKernelTestBase {
public function testCreatedFullDateHandler() {
$view = Views::getView('test_argument_date');
$view->setDisplay('default');
- $this->executeView($view, array('20000102'));
- $expected = array();
- $expected[] = array('id' => 2);
+ $this->executeView($view, ['20000102']);
+ $expected = [];
+ $expected[] = ['id' => 2];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('default');
- $this->executeView($view, array('20000101'));
- $expected = array();
- $expected[] = array('id' => 1);
- $expected[] = array('id' => 3);
- $expected[] = array('id' => 4);
- $expected[] = array('id' => 5);
+ $this->executeView($view, ['20000101']);
+ $expected = [];
+ $expected[] = ['id' => 1];
+ $expected[] = ['id' => 3];
+ $expected[] = ['id' => 4];
+ $expected[] = ['id' => 5];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('default');
- $this->executeView($view, array('20001023'));
- $expected = array();
+ $this->executeView($view, ['20001023']);
+ $expected = [];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
}
@@ -90,25 +90,25 @@ class ArgumentDateTest extends ViewsKernelTestBase {
public function testDayHandler() {
$view = Views::getView('test_argument_date');
$view->setDisplay('embed_1');
- $this->executeView($view, array('02'));
- $expected = array();
- $expected[] = array('id' => 2);
+ $this->executeView($view, ['02']);
+ $expected = [];
+ $expected[] = ['id' => 2];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_1');
- $this->executeView($view, array('01'));
- $expected = array();
- $expected[] = array('id' => 1);
- $expected[] = array('id' => 3);
- $expected[] = array('id' => 4);
- $expected[] = array('id' => 5);
+ $this->executeView($view, ['01']);
+ $expected = [];
+ $expected[] = ['id' => 1];
+ $expected[] = ['id' => 3];
+ $expected[] = ['id' => 4];
+ $expected[] = ['id' => 5];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_1');
- $this->executeView($view, array('23'));
- $expected = array();
+ $this->executeView($view, ['23']);
+ $expected = [];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
}
@@ -120,19 +120,19 @@ class ArgumentDateTest extends ViewsKernelTestBase {
public function testMonthHandler() {
$view = Views::getView('test_argument_date');
$view->setDisplay('embed_2');
- $this->executeView($view, array('01'));
- $expected = array();
- $expected[] = array('id' => 1);
- $expected[] = array('id' => 2);
- $expected[] = array('id' => 3);
- $expected[] = array('id' => 4);
- $expected[] = array('id' => 5);
+ $this->executeView($view, ['01']);
+ $expected = [];
+ $expected[] = ['id' => 1];
+ $expected[] = ['id' => 2];
+ $expected[] = ['id' => 3];
+ $expected[] = ['id' => 4];
+ $expected[] = ['id' => 5];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_2');
- $this->executeView($view, array('12'));
- $expected = array();
+ $this->executeView($view, ['12']);
+ $expected = [];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
}
@@ -143,27 +143,27 @@ class ArgumentDateTest extends ViewsKernelTestBase {
*/
public function testWeekHandler() {
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 9, 26, 2008)))
+ ->fields(['created' => gmmktime(0, 0, 0, 9, 26, 2008)])
->condition('id', 1)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 2, 29, 2004)))
+ ->fields(['created' => gmmktime(0, 0, 0, 2, 29, 2004)])
->condition('id', 2)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2000)))
+ ->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2000)])
->condition('id', 3)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 1, 10, 2000)))
+ ->fields(['created' => gmmktime(0, 0, 0, 1, 10, 2000)])
->condition('id', 4)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 2, 1, 2000)))
+ ->fields(['created' => gmmktime(0, 0, 0, 2, 1, 2000)])
->condition('id', 5)
->execute();
@@ -171,46 +171,46 @@ class ArgumentDateTest extends ViewsKernelTestBase {
$view->setDisplay('embed_3');
// Check the week calculation for a leap year.
// @see http://wikipedia.org/wiki/ISO_week_date#Calculation
- $this->executeView($view, array('39'));
- $expected = array();
- $expected[] = array('id' => 1);
+ $this->executeView($view, ['39']);
+ $expected = [];
+ $expected[] = ['id' => 1];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_3');
// Check the week calculation for the 29th of February in a leap year.
// @see http://wikipedia.org/wiki/ISO_week_date#Calculation
- $this->executeView($view, array('09'));
- $expected = array();
- $expected[] = array('id' => 2);
+ $this->executeView($view, ['09']);
+ $expected = [];
+ $expected[] = ['id' => 2];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_3');
// The first jan 2000 was still in the last week of the previous year.
- $this->executeView($view, array('52'));
- $expected = array();
- $expected[] = array('id' => 3);
+ $this->executeView($view, ['52']);
+ $expected = [];
+ $expected[] = ['id' => 3];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_3');
- $this->executeView($view, array('02'));
- $expected = array();
- $expected[] = array('id' => 4);
+ $this->executeView($view, ['02']);
+ $expected = [];
+ $expected[] = ['id' => 4];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_3');
- $this->executeView($view, array('05'));
- $expected = array();
- $expected[] = array('id' => 5);
+ $this->executeView($view, ['05']);
+ $expected = [];
+ $expected[] = ['id' => 5];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_3');
- $this->executeView($view, array('23'));
- $expected = array();
+ $this->executeView($view, ['23']);
+ $expected = [];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
}
@@ -221,47 +221,47 @@ class ArgumentDateTest extends ViewsKernelTestBase {
*/
public function testYearHandler() {
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2001)))
+ ->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2001)])
->condition('id', 3)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2002)))
+ ->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2002)])
->condition('id', 4)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2002)))
+ ->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2002)])
->condition('id', 5)
->execute();
$view = Views::getView('test_argument_date');
$view->setDisplay('embed_4');
- $this->executeView($view, array('2000'));
- $expected = array();
- $expected[] = array('id' => 1);
- $expected[] = array('id' => 2);
+ $this->executeView($view, ['2000']);
+ $expected = [];
+ $expected[] = ['id' => 1];
+ $expected[] = ['id' => 2];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_4');
- $this->executeView($view, array('2001'));
- $expected = array();
- $expected[] = array('id' => 3);
+ $this->executeView($view, ['2001']);
+ $expected = [];
+ $expected[] = ['id' => 3];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_4');
- $this->executeView($view, array('2002'));
- $expected = array();
- $expected[] = array('id' => 4);
- $expected[] = array('id' => 5);
+ $this->executeView($view, ['2002']);
+ $expected = [];
+ $expected[] = ['id' => 4];
+ $expected[] = ['id' => 5];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_4');
- $this->executeView($view, array('23'));
- $expected = array();
+ $this->executeView($view, ['23']);
+ $expected = [];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
}
@@ -272,47 +272,47 @@ class ArgumentDateTest extends ViewsKernelTestBase {
*/
public function testYearMonthHandler() {
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2001)))
+ ->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2001)])
->condition('id', 3)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 4, 1, 2001)))
+ ->fields(['created' => gmmktime(0, 0, 0, 4, 1, 2001)])
->condition('id', 4)
->execute();
$this->container->get('database')->update('views_test_data')
- ->fields(array('created' => gmmktime(0, 0, 0, 4, 1, 2001)))
+ ->fields(['created' => gmmktime(0, 0, 0, 4, 1, 2001)])
->condition('id', 5)
->execute();
$view = Views::getView('test_argument_date');
$view->setDisplay('embed_5');
- $this->executeView($view, array('200001'));
- $expected = array();
- $expected[] = array('id' => 1);
- $expected[] = array('id' => 2);
+ $this->executeView($view, ['200001']);
+ $expected = [];
+ $expected[] = ['id' => 1];
+ $expected[] = ['id' => 2];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_5');
- $this->executeView($view, array('200101'));
- $expected = array();
- $expected[] = array('id' => 3);
+ $this->executeView($view, ['200101']);
+ $expected = [];
+ $expected[] = ['id' => 3];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_5');
- $this->executeView($view, array('200104'));
- $expected = array();
- $expected[] = array('id' => 4);
- $expected[] = array('id' => 5);
+ $this->executeView($view, ['200104']);
+ $expected = [];
+ $expected[] = ['id' => 4];
+ $expected[] = ['id' => 5];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
$view->destroy();
$view->setDisplay('embed_5');
- $this->executeView($view, array('201301'));
- $expected = array();
+ $this->executeView($view, ['201301']);
+ $expected = [];
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/ArgumentNullTest.php b/core/modules/views/tests/src/Kernel/Handler/ArgumentNullTest.php
index e90ec85560e..99fa7c86751 100644
--- a/core/modules/views/tests/src/Kernel/Handler/ArgumentNullTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/ArgumentNullTest.php
@@ -17,7 +17,7 @@ class ArgumentNullTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
function viewsData() {
$data = parent::viewsData();
@@ -32,13 +32,13 @@ class ArgumentNullTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a null argument.
- $view->displayHandlers->get('default')->overrideOption('arguments', array(
- 'null' => array(
+ $view->displayHandlers->get('default')->overrideOption('arguments', [
+ 'null' => [
'id' => 'null',
'table' => 'views',
'field' => 'null',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
@@ -57,15 +57,15 @@ class ArgumentNullTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a argument, which has null as handler.
- $view->displayHandlers->get('default')->overrideOption('arguments', array(
- 'id' => array(
+ $view->displayHandlers->get('default')->overrideOption('arguments', [
+ 'id' => [
'id' => 'id',
'table' => 'views_test_data',
'field' => 'id',
- ),
- ));
+ ],
+ ]);
- $this->executeView($view, array(26));
+ $this->executeView($view, [26]);
// The argument should be ignored, so every result should return.
$this->assertEqual(5, count($view->result));
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldBooleanTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldBooleanTest.php
index 1a5551c773f..01f5166447b 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldBooleanTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldBooleanTest.php
@@ -17,7 +17,7 @@ class FieldBooleanTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
function dataSet() {
// Use default dataset but remove the age from john and paul
@@ -37,14 +37,14 @@ class FieldBooleanTest extends ViewsKernelTestBase {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
@@ -70,7 +70,7 @@ class FieldBooleanTest extends ViewsKernelTestBase {
$this->assertEqual('✔', $view->field['age']->advancedRender($view->result[1]));
// Set a custom output format.
- $view->field['age']->formats['test'] = array(t('Test-True'), t('Test-False'));
+ $view->field['age']->formats['test'] = [t('Test-True'), t('Test-False')];
$view->field['age']->options['type'] = 'test';
$this->assertEqual(t('Test-False'), $view->field['age']->advancedRender($view->result[0]));
$this->assertEqual(t('Test-True'), $view->field['age']->advancedRender($view->result[1]));
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php
index 12f68ede749..49d914eee45 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldCounterTest.php
@@ -17,71 +17,71 @@ class FieldCounterTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('user');
+ public static $modules = ['user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
function testSimple() {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'counter' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'counter' => [
'id' => 'counter',
'table' => 'views',
'field' => 'counter',
'relationship' => 'none',
- ),
- 'name' => array(
+ ],
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
$view->preview();
$counter = $view->style_plugin->getField(0, 'counter');
- $this->assertEqual($counter, '1', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 1, '@counter' => $counter)));
+ $this->assertEqual($counter, '1', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 1, '@counter' => $counter]));
$counter = $view->style_plugin->getField(1, 'counter');
- $this->assertEqual($counter, '2', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 2, '@counter' => $counter)));
+ $this->assertEqual($counter, '2', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 2, '@counter' => $counter]));
$counter = $view->style_plugin->getField(2, 'counter');
- $this->assertEqual($counter, '3', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 3, '@counter' => $counter)));
+ $this->assertEqual($counter, '3', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 3, '@counter' => $counter]));
$view->destroy();
$view->storage->invalidateCaches();
$view->setDisplay();
$rand_start = rand(5, 10);
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'counter' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'counter' => [
'id' => 'counter',
'table' => 'views',
'field' => 'counter',
'relationship' => 'none',
'counter_start' => $rand_start
- ),
- 'name' => array(
+ ],
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
$view->preview();
$counter = $view->style_plugin->getField(0, 'counter');
$expected_number = 0 + $rand_start;
- $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
+ $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
$counter = $view->style_plugin->getField(1, 'counter');
$expected_number = 1 + $rand_start;
- $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
+ $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
$counter = $view->style_plugin->getField(2, 'counter');
$expected_number = 2 + $rand_start;
- $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
+ $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
}
/**
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldCustomTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldCustomTest.php
index af7bc1bc890..fb6e3c4db69 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldCustomTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldCustomTest.php
@@ -18,7 +18,7 @@ class FieldCustomTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* {@inheritdoc}
@@ -38,17 +38,17 @@ class FieldCustomTest extends ViewsKernelTestBase {
// Alter the text of the field to a random string.
$random = '<div>' . $this->randomMachineName() . '</div>';
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- 'alter' => array(
+ 'alter' => [
'text' => $random,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->executeView($view);
@@ -98,17 +98,17 @@ class FieldCustomTest extends ViewsKernelTestBase {
// Alter the text of the field to include XSS.
$text = '<script>alert("kittens")</script>';
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- 'alter' => array(
+ 'alter' => [
'text' => $text,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->executeView($view);
$this->assertEqual(Xss::filter($text), $view->style_plugin->getField(0, 'name'));
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldDateTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldDateTest.php
index cb30bf7f6a0..833b5c99d19 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldDateTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldDateTest.php
@@ -17,20 +17,20 @@ class FieldDateTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* {@inheritdoc}
*/
public function schemaDefinition() {
$schema = parent::schemaDefinition();
- $schema['views_test_data']['fields']['destroyed'] = array(
+ $schema['views_test_data']['fields']['destroyed'] = [
'description' => "The destruction date of this record",
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
- );
+ ];
return $schema;
}
@@ -40,14 +40,14 @@ class FieldDateTest extends ViewsKernelTestBase {
public function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['created']['field']['id'] = 'date';
- $data['views_test_data']['destroyed'] = array(
+ $data['views_test_data']['destroyed'] = [
'title' => 'Destroyed',
'help' => 'Date in future this will be destroyed.',
- 'field' => array('id' => 'date'),
- 'argument' => array('id' => 'date'),
- 'filter' => array('id' => 'date'),
- 'sort' => array('id' => 'date'),
- );
+ 'field' => ['id' => 'date'],
+ 'argument' => ['id' => 'date'],
+ 'filter' => ['id' => 'date'],
+ 'sort' => ['id' => 'date'],
+ ];
return $data;
}
@@ -69,36 +69,36 @@ class FieldDateTest extends ViewsKernelTestBase {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'created' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'created' => [
'id' => 'created',
'table' => 'views_test_data',
'field' => 'created',
'relationship' => 'none',
// ISO 8601 format, see http://php.net/manual/function.date.php
'custom_date_format' => 'c',
- ),
- 'destroyed' => array(
+ ],
+ 'destroyed' => [
'id' => 'destroyed',
'table' => 'views_test_data',
'field' => 'destroyed',
'relationship' => 'none',
'custom_date_format' => 'c',
- ),
- ));
+ ],
+ ]);
$time = gmmktime(0, 0, 0, 1, 1, 2000);
$this->executeView($view);
- $timezones = array(
+ $timezones = [
NULL,
'UTC',
'America/New_York',
- );
+ ];
// Check each date/time in various timezones.
foreach ($timezones as $timezone) {
- $dates = array(
+ $dates = [
'short' => format_date($time, 'short', '', $timezone),
'medium' => format_date($time, 'medium', '', $timezone),
'long' => format_date($time, 'long', '', $timezone),
@@ -111,30 +111,30 @@ class FieldDateTest extends ViewsKernelTestBase {
'html_week' => format_date($time, 'html_week', '', $timezone),
'html_year' => format_date($time, 'html_year', '', $timezone),
'html_yearless_date' => format_date($time, 'html_yearless_date', '', $timezone),
- );
+ ];
$this->assertRenderedDatesEqual($view, $dates, $timezone);
}
// Check times in the past.
$time_since = $this->container->get('date.formatter')->formatTimeDiffSince($time);
- $intervals = array(
+ $intervals = [
'raw time ago' => $time_since,
- 'time ago' => t('%time ago', array('%time' => $time_since)),
+ 'time ago' => t('%time ago', ['%time' => $time_since]),
'raw time span' => $time_since,
'inverse time span' => "-$time_since",
- 'time span' => t('%time ago', array('%time' => $time_since)),
- );
+ 'time span' => t('%time ago', ['%time' => $time_since]),
+ ];
$this->assertRenderedDatesEqual($view, $intervals);
// Check times in the future.
$time = gmmktime(0, 0, 0, 1, 1, 2050);
$formatted = $this->container->get('date.formatter')->formatTimeDiffUntil($time);
- $intervals = array(
+ $intervals = [
'raw time span' => "-$formatted",
- 'time span' => t('%time hence', array(
+ 'time span' => t('%time hence', [
'%time' => $formatted,
- )),
- );
+ ]),
+ ];
$this->assertRenderedFutureDatesEqual($view, $intervals);
}
@@ -151,10 +151,10 @@ class FieldDateTest extends ViewsKernelTestBase {
protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
foreach ($map as $date_format => $expected_result) {
$view->field['created']->options['date_format'] = $date_format;
- $t_args = array(
+ $t_args = [
'%value' => $expected_result,
'%format' => $date_format,
- );
+ ];
if (isset($timezone)) {
$t_args['%timezone'] = $timezone;
$message = t('Value %value in %format format for timezone %timezone matches.', $t_args);
@@ -180,11 +180,11 @@ class FieldDateTest extends ViewsKernelTestBase {
foreach ($map as $format => $result) {
$view->field['destroyed']->options['date_format'] = $format;
$view_result = $view->field['destroyed']->advancedRender($view->result[0]);
- $t_args = array(
+ $t_args = [
'%value' => $result,
'%format' => $format,
'%actual' => $view_result,
- );
+ ];
$message = t('Value %value in %format matches %actual', $t_args);
$this->assertEqual($view_result, $result, $message);
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php
index 8f53f6a361f..874f03d4fcc 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php
@@ -23,14 +23,14 @@ class FieldEntityLinkTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_test_link');
+ public static $testViews = ['test_entity_test_link'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('user', 'entity_test');
+ public static $modules = ['user', 'entity_test'];
/**
* An admin user account.
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php
index c82fc693806..1d304f53a19 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php
@@ -70,7 +70,7 @@ class FieldFieldTest extends ViewsKernelTestBase {
$this->installEntitySchema('entity_test');
$this->installEntitySchema('entity_test_rev');
- ViewTestData::createTestViews(get_class($this), array('views_test_config'));
+ ViewTestData::createTestViews(get_class($this), ['views_test_config']);
// Bypass any field access.
$this->adminUser = User::create(['name' => $this->randomString()]);
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php
index 2f60e34bf76..7af6442e480 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php
@@ -18,7 +18,7 @@ class FieldFileSizeTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
function dataSet() {
$data = parent::dataSet();
@@ -41,13 +41,13 @@ class FieldFileSizeTest extends ViewsKernelTestBase {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php
index be8a4f1331b..b5b04b00dd5 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php
@@ -15,23 +15,23 @@ use Drupal\views\Views;
*/
class FieldKernelTest extends ViewsKernelTestBase {
- public static $modules = array('user');
+ public static $modules = ['user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view', 'test_field_tokens', 'test_field_argument_tokens', 'test_field_output');
+ public static $testViews = ['test_view', 'test_field_tokens', 'test_field_argument_tokens', 'test_field_output'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
- );
+ ];
/**
* {@inheritdoc}
@@ -73,7 +73,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
$id_field = $view->field['id'];
$id_field->additional_fields['job'] = 'job';
// Choose also a field alias key which doesn't match to the table field.
- $id_field->additional_fields['created_test'] = array('table' => 'views_test_data', 'field' => 'created');
+ $id_field->additional_fields['created_test'] = ['table' => 'views_test_data', 'field' => 'created'];
$view->build();
// Make sure the field aliases have the expected value.
@@ -778,10 +778,10 @@ class FieldKernelTest extends ViewsKernelTestBase {
*/
public function testClickSortable() {
// Test that clickSortable is TRUE by default.
- $item = array(
+ $item = [
'table' => 'views_test_data',
'field' => 'name',
- );
+ ];
$plugin = $this->container->get('plugin.manager.views.field')->getHandler($item);
$this->assertTrue($plugin->clickSortable(), 'TRUE as a default value is correct.');
@@ -801,7 +801,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
*/
public function testTrimText() {
// Test unicode. See https://www.drupal.org/node/513396#comment-2839416.
- $text = array(
+ $text = [
'Tuy nhiên, những hi vọng',
'Giả sử chúng tôi có 3 Apple',
'siêu nhỏ này là bộ xử lý',
@@ -810,12 +810,12 @@ class FieldKernelTest extends ViewsKernelTestBase {
'của hãng bao gồm ba dòng',
'сд асд асд ас',
'асд асд асд ас'
- );
+ ];
// Just test maxlength without word boundary.
- $alter = array(
+ $alter = [
'max_length' => 10,
- );
- $expect = array(
+ ];
+ $expect = [
'Tuy nhiên,',
'Giả sử chú',
'siêu nhỏ n',
@@ -824,7 +824,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
'của hãng b',
'сд асд асд',
'асд асд ас',
- );
+ ];
foreach ($text as $key => $line) {
$result_text = FieldPluginBase::trimText($alter, $line);
@@ -833,7 +833,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
// Test also word_boundary
$alter['word_boundary'] = TRUE;
- $expect = array(
+ $expect = [
'Tuy nhiên',
'Giả sử',
'siêu nhỏ',
@@ -842,7 +842,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
'của hãng',
'сд асд',
'асд асд',
- );
+ ];
foreach ($text as $key => $line) {
$result_text = FieldPluginBase::trimText($alter, $line);
diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldUrlTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldUrlTest.php
index bfb764d4fa5..828fdb4fdf1 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FieldUrlTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FieldUrlTest.php
@@ -13,14 +13,14 @@ use Drupal\views\Views;
*/
class FieldUrlTest extends ViewsKernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
function viewsData() {
$data = parent::viewsData();
@@ -32,15 +32,15 @@ class FieldUrlTest extends ViewsKernelTestBase {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'display_as_link' => FALSE,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
@@ -50,14 +50,14 @@ class FieldUrlTest extends ViewsKernelTestBase {
$view->destroy();
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorStringTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorStringTest.php
index 5bd2157afa3..325da5106e2 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorStringTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorStringTest.php
@@ -19,23 +19,23 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_id' => 'id',
- );
+ ];
/**
* {@inheritdoc}
@@ -43,13 +43,13 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
- $schema['views_test_data']['fields']['status'] = array(
+ $schema['views_test_data']['fields']['status'] = [
'description' => 'The status of this record',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- );
+ ];
return $schema;
}
@@ -91,20 +91,20 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a the status boolean filter.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'status' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'status' => [
'id' => 'status',
'field' => 'status',
'table' => 'views_test_data',
'value' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $expected_result = array(
- array('id' => 2),
- array('id' => 4),
- );
+ $expected_result = [
+ ['id' => 2],
+ ['id' => 4],
+ ];
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -113,21 +113,21 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add the status boolean filter.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'status' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'status' => [
'id' => 'status',
'field' => 'status',
'table' => 'views_test_data',
'value' => 1,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $expected_result = array(
- array('id' => 1),
- array('id' => 3),
- array('id' => 5),
- );
+ $expected_result = [
+ ['id' => 1],
+ ['id' => 3],
+ ['id' => 5],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -140,32 +140,32 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
$filters = $this->getGroupedExposedFilters();
$view = Views::getView('test_view');
- $view->setExposedInput(array('status' => 1));
+ $view->setExposedInput(['status' => 1]);
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
$this->executeView($view);
- $expected_result = array(
- array('id' => 1),
- array('id' => 3),
- array('id' => 5),
- );
+ $expected_result = [
+ ['id' => 1],
+ ['id' => 3],
+ ['id' => 5],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
- $view->setExposedInput(array('status' => 2));
+ $view->setExposedInput(['status' => 2]);
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
$this->executeView($view);
- $expected_result = array(
- array('id' => 2),
- array('id' => 4),
- );
+ $expected_result = [
+ ['id' => 2],
+ ['id' => 4],
+ ];
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -178,38 +178,38 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
* Returns the filter configuration for exposed filters.
*/
protected function getGroupedExposedFilters() {
- $filters = array(
- 'status' => array(
+ $filters = [
+ 'status' => [
'id' => 'status',
'table' => 'views_test_data',
'field' => 'status',
'relationship' => 'none',
'exposed' => TRUE,
- 'expose' => array(
+ 'expose' => [
'operator' => 'status_op',
'label' => 'status',
'identifier' => 'status',
- ),
+ ],
'is_grouped' => TRUE,
- 'group_info' => array(
+ 'group_info' => [
'label' => 'status',
'identifier' => 'status',
'default_group' => 'All',
- 'group_items' => array(
- 1 => array(
+ 'group_items' => [
+ 1 => [
'title' => 'Active',
'operator' => '=',
'value' => '1',
- ),
- 2 => array(
+ ],
+ 2 => [
'title' => 'Blocked',
'operator' => '=',
'value' => '0',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
return $filters;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php
index 7a88066e881..7cdd41f525d 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php
@@ -18,23 +18,23 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_id' => 'id',
- );
+ ];
/**
* Tests the BooleanOperator filter.
@@ -44,20 +44,20 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a the status boolean filter.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'status' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'status' => [
'id' => 'status',
'field' => 'status',
'table' => 'views_test_data',
'value' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $expected_result = array(
- array('id' => 2),
- array('id' => 4),
- );
+ $expected_result = [
+ ['id' => 2],
+ ['id' => 4],
+ ];
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -66,21 +66,21 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add the status boolean filter.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'status' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'status' => [
'id' => 'status',
'field' => 'status',
'table' => 'views_test_data',
'value' => 1,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $expected_result = array(
- array('id' => 1),
- array('id' => 3),
- array('id' => 5),
- );
+ $expected_result = [
+ ['id' => 1],
+ ['id' => 3],
+ ['id' => 5],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -89,22 +89,22 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
$view->setDisplay();
// Testing the same scenario but using the reverse status and operation.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'status' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'status' => [
'id' => 'status',
'field' => 'status',
'table' => 'views_test_data',
'value' => 0,
'operator' => '!=',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $expected_result = array(
- array('id' => 1),
- array('id' => 3),
- array('id' => 5),
- );
+ $expected_result = [
+ ['id' => 1],
+ ['id' => 3],
+ ['id' => 5],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -117,32 +117,32 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
$filters = $this->getGroupedExposedFilters();
$view = Views::getView('test_view');
- $view->setExposedInput(array('status' => 1));
+ $view->setExposedInput(['status' => 1]);
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
$this->executeView($view);
- $expected_result = array(
- array('id' => 1),
- array('id' => 3),
- array('id' => 5),
- );
+ $expected_result = [
+ ['id' => 1],
+ ['id' => 3],
+ ['id' => 5],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
- $view->setExposedInput(array('status' => 2));
+ $view->setExposedInput(['status' => 2]);
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
$this->executeView($view);
- $expected_result = array(
- array('id' => 2),
- array('id' => 4),
- );
+ $expected_result = [
+ ['id' => 2],
+ ['id' => 4],
+ ];
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -156,11 +156,11 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
$this->executeView($view);
- $expected_result = array(
- array('id' => 1),
- array('id' => 3),
- array('id' => 5),
- );
+ $expected_result = [
+ ['id' => 1],
+ ['id' => 3],
+ ['id' => 5],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -172,45 +172,45 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
* @return array
*/
protected function getGroupedExposedFilters() {
- $filters = array(
- 'status' => array(
+ $filters = [
+ 'status' => [
'id' => 'status',
'table' => 'views_test_data',
'field' => 'status',
'relationship' => 'none',
'exposed' => TRUE,
- 'expose' => array(
+ 'expose' => [
'operator' => 'status_op',
'label' => 'status',
'identifier' => 'status',
- ),
+ ],
'is_grouped' => TRUE,
- 'group_info' => array(
+ 'group_info' => [
'label' => 'status',
'identifier' => 'status',
'default_group' => 'All',
- 'group_items' => array(
- 1 => array(
+ 'group_items' => [
+ 1 => [
'title' => 'Active',
'operator' => '=',
'value' => '1',
- ),
- 2 => array(
+ ],
+ 2 => [
'title' => 'Blocked',
'operator' => '=',
'value' => '0',
- ),
+ ],
// This group should return the same results as group 1, because it
// is the negation of group 2.
- 3 => array(
+ 3 => [
'title' => 'Active (reverse)',
'operator' => '!=',
'value' => '0',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
return $filters;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php
index 0424263833d..e5d37119df0 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php
@@ -15,24 +15,24 @@ class FilterCombineTest extends ViewsKernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('entity_test');
+ public static $modules = ['entity_test'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view', 'entity_test_fields');
+ public static $testViews = ['test_view', 'entity_test_fields'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
'views_test_data_job' => 'job',
- );
+ ];
/**
* {@inheritdoc}
@@ -48,50 +48,50 @@ class FilterCombineTest extends ViewsKernelTestBase {
$view->setDisplay();
$fields = $view->displayHandlers->get('default')->getOption('fields');
- $view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
- 'job' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', $fields + [
+ 'job' => [
'id' => 'job',
'table' => 'views_test_data',
'field' => 'job',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => 'contains',
- 'fields' => array(
+ 'fields' => [
'name',
'job',
- ),
+ ],
'value' => 'ing',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
'job' => 'Singer',
- ),
- array(
+ ],
+ [
'name' => 'George',
'job' => 'Singer',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'job' => 'Drummer',
- ),
- array(
+ ],
+ [
'name' => 'Ginger',
'job' => NULL,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -103,46 +103,46 @@ class FilterCombineTest extends ViewsKernelTestBase {
$view->setDisplay();
$fields = $view->displayHandlers->get('default')->getOption('fields');
- $view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
- 'job' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', $fields + [
+ 'job' => [
'id' => 'job',
'table' => 'views_test_data',
'field' => 'job',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => 'word',
- 'fields' => array(
+ 'fields' => [
'name',
'job',
- ),
+ ],
'value' => 'singer ringo',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
'job' => 'Singer',
- ),
- array(
+ ],
+ [
'name' => 'George',
'job' => 'Singer',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'job' => 'Drummer',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -154,39 +154,39 @@ class FilterCombineTest extends ViewsKernelTestBase {
$view->setDisplay();
$fields = $view->displayHandlers->get('default')->getOption('fields');
- $view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
- 'job' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', $fields + [
+ 'job' => [
'id' => 'job',
'table' => 'views_test_data',
'field' => 'job',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Set the filtering to allwords and simulate searching for a phrase.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => 'allwords',
- 'fields' => array(
+ 'fields' => [
'name',
'job',
'age',
- ),
+ ],
'value' => '25 "john singer"',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
'job' => 'Singer',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -202,40 +202,40 @@ class FilterCombineTest extends ViewsKernelTestBase {
$view->setDisplay();
$fields = $view->displayHandlers->get('default')->getOption('fields');
- $view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
- 'job' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', $fields + [
+ 'job' => [
'id' => 'job',
'table' => 'views_test_data',
'field' => 'job',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => 'contains',
- 'fields' => array(
+ 'fields' => [
'name',
'job',
// Add a dummy field to the combined fields to simulate
// a removed or deleted field.
'dummy',
- ),
+ ],
'value' => 'ing',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
// Make sure this view will not get displayed.
$this->assertTrue($view->build_info['fail'], "View build has been marked as failed.");
// Make sure this view does not pass validation with the right error.
$errors = $view->validate();
- $this->assertEquals(t('Field %field set in %filter is not set in display %display.', array('%field' => 'dummy', '%filter' => 'Global: Combine fields filter', '%display' => 'Master')), reset($errors['default']));
+ $this->assertEquals(t('Field %field set in %filter is not set in display %display.', ['%field' => 'dummy', '%filter' => 'Global: Combine fields filter', '%display' => 'Master']), reset($errors['default']));
}
/**
@@ -247,30 +247,30 @@ class FilterCombineTest extends ViewsKernelTestBase {
$view->setDisplay();
// Set the rows to a plugin type that doesn't support fields.
- $view->displayHandlers->get('default')->overrideOption('row', array(
+ $view->displayHandlers->get('default')->overrideOption('row', [
'type' => 'entity:entity_test',
- 'options' => array(
+ 'options' => [
'view_mode' => 'teaser',
- ),
- ));
+ ],
+ ]);
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'combine',
'table' => 'views',
'field' => 'combine',
'relationship' => 'none',
'operator' => 'contains',
- 'fields' => array(
+ 'fields' => [
'name',
- ),
+ ],
'value' => 'ing',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
$errors = $view->validate();
// Check that the right error is shown.
- $this->assertEquals(t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', array('%filter' => 'Global: Combine fields filter', '%display' => 'Master')), reset($errors['default']));
+ $this->assertEquals(t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', ['%filter' => 'Global: Combine fields filter', '%display' => 'Master']), reset($errors['default']));
}
/**
@@ -278,13 +278,13 @@ class FilterCombineTest extends ViewsKernelTestBase {
*/
protected function dataSet() {
$data_set = parent::dataSet();
- $data_set[] = array(
+ $data_set[] = [
'name' => 'Ginger',
'age' => 25,
'job' => NULL,
'created' => gmmktime(0, 0, 0, 1, 2, 2000),
'status' => 1,
- );
+ ];
return $data_set;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterEqualityTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterEqualityTest.php
index a4bd6c84080..41002e806c3 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterEqualityTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterEqualityTest.php
@@ -12,23 +12,23 @@ use Drupal\views\Views;
*/
class FilterEqualityTest extends ViewsKernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
- );
+ ];
function viewsData() {
$data = parent::viewsData();
@@ -41,23 +41,23 @@ class FilterEqualityTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => '=',
'value' => 'Ringo',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -74,11 +74,11 @@ class FilterEqualityTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -87,32 +87,32 @@ class FilterEqualityTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => '!=',
'value' => 'Ringo',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -129,27 +129,27 @@ class FilterEqualityTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
protected function getGroupedExposedFilters() {
- $filters = array(
- 'name' => array(
+ $filters = [
+ 'name' => [
'id' => 'name',
'plugin_id' => 'equality',
'table' => 'views_test_data',
@@ -157,31 +157,31 @@ class FilterEqualityTest extends ViewsKernelTestBase {
'relationship' => 'none',
'group' => 1,
'exposed' => TRUE,
- 'expose' => array(
+ 'expose' => [
'operator' => 'name_op',
'label' => 'name',
'identifier' => 'name',
- ),
+ ],
'is_grouped' => TRUE,
- 'group_info' => array(
+ 'group_info' => [
'label' => 'name',
'identifier' => 'name',
'default_group' => 'All',
- 'group_items' => array(
- 1 => array(
+ 'group_items' => [
+ 1 => [
'title' => 'Name is equal to Ringo',
'operator' => '=',
'value' => 'Ringo',
- ),
- 2 => array(
+ ],
+ 2 => [
'title' => 'Name is not equal to Ringo',
'operator' => '!=',
'value' => 'Ringo',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
return $filters;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterInOperatorTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterInOperatorTest.php
index 9ab08e1c467..b542c9c1dad 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterInOperatorTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterInOperatorTest.php
@@ -12,24 +12,24 @@ use Drupal\views\Views;
*/
class FilterInOperatorTest extends ViewsKernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- );
+ ];
function viewsData() {
$data = parent::viewsData();
@@ -42,28 +42,28 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a in_operator ordering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'field' => 'age',
'table' => 'views_test_data',
- 'value' => array(26, 30),
+ 'value' => [26, 30],
'operator' => 'in',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'name' => 'Paul',
'age' => 26,
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
'age' => 30,
- ),
- );
+ ],
+ ];
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -72,32 +72,32 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a in_operator ordering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'field' => 'age',
'table' => 'views_test_data',
- 'value' => array(26, 30),
+ 'value' => [26, 30],
'operator' => 'not in',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'name' => 'John',
'age' => 25,
- ),
- array(
+ ],
+ [
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- );
+ ],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -114,16 +114,16 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'name' => 'Paul',
'age' => 26,
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
'age' => 30,
- ),
- );
+ ],
+ ];
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
@@ -140,58 +140,58 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'name' => 'John',
'age' => 25,
- ),
- array(
+ ],
+ [
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- );
+ ],
+ ];
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
protected function getGroupedExposedFilters() {
- $filters = array(
- 'age' => array(
+ $filters = [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'exposed' => TRUE,
- 'expose' => array(
+ 'expose' => [
'operator' => 'age_op',
'label' => 'age',
'identifier' => 'age',
- ),
+ ],
'is_grouped' => TRUE,
- 'group_info' => array(
+ 'group_info' => [
'label' => 'age',
'identifier' => 'age',
'default_group' => 'All',
- 'group_items' => array(
- 1 => array(
+ 'group_items' => [
+ 1 => [
'title' => 'Age is one of 26, 30',
'operator' => 'in',
- 'value' => array(26, 30),
- ),
- 2 => array(
+ 'value' => [26, 30],
+ ],
+ 2 => [
'title' => 'Age is not one of 26, 30',
'operator' => 'not in',
- 'value' => array(26, 30),
- ),
- ),
- ),
- ),
- );
+ 'value' => [26, 30],
+ ],
+ ],
+ ],
+ ],
+ ];
return $filters;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php
index ca1587913d0..d10b7920806 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php
@@ -12,24 +12,24 @@ use Drupal\views\Views;
*/
class FilterNumericTest extends ViewsKernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- );
+ ];
function viewsData() {
$data = parent::viewsData();
@@ -44,24 +44,24 @@ class FilterNumericTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'operator' => '=',
- 'value' => array('value' => 28),
- ),
- ));
+ 'value' => ['value' => 28],
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -78,12 +78,12 @@ class FilterNumericTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -92,35 +92,35 @@ class FilterNumericTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'operator' => 'between',
- 'value' => array(
+ 'value' => [
'min' => 26,
'max' => 29,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- array(
+ ],
+ [
'name' => 'Paul',
'age' => 26,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
// test not between
@@ -128,31 +128,31 @@ class FilterNumericTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'operator' => 'not between',
- 'value' => array(
+ 'value' => [
'min' => 26,
'max' => 29,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
'age' => 25,
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
'age' => 30,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -169,20 +169,20 @@ class FilterNumericTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- array(
+ ],
+ [
'name' => 'Paul',
'age' => 26,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -199,16 +199,16 @@ class FilterNumericTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
'age' => 25,
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
'age' => 30,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -220,26 +220,26 @@ class FilterNumericTest extends ViewsKernelTestBase {
$view->setDisplay();
// Filtering by regular expression pattern.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'operator' => 'regular_expression',
- 'value' => array(
+ 'value' => [
'value' => '2[8]',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -259,16 +259,16 @@ class FilterNumericTest extends ViewsKernelTestBase {
$view->save();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -277,58 +277,58 @@ class FilterNumericTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'operator' => 'empty',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- );
+ $resultset = [
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
$view->destroy();
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'operator' => 'not empty',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
'age' => 25,
- ),
- array(
+ ],
+ [
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- array(
+ ],
+ [
'name' => 'Paul',
'age' => 26,
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
'age' => 30,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -345,8 +345,8 @@ class FilterNumericTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- );
+ $resultset = [
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -363,28 +363,28 @@ class FilterNumericTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
'age' => 25,
- ),
- array(
+ ],
+ [
'name' => 'George',
'age' => 27,
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
'age' => 28,
- ),
- array(
+ ],
+ [
'name' => 'Paul',
'age' => 26,
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
'age' => 30,
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -392,20 +392,20 @@ class FilterNumericTest extends ViewsKernelTestBase {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'id' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'id' => [
'id' => 'id',
'table' => 'views_test_data',
'field' => 'id',
'relationship' => 'none',
- ),
- 'age' => array(
+ ],
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
$view->initHandlers();
@@ -419,65 +419,65 @@ class FilterNumericTest extends ViewsKernelTestBase {
}
protected function getGroupedExposedFilters() {
- $filters = array(
- 'age' => array(
+ $filters = [
+ 'age' => [
'id' => 'age',
'plugin_id' => 'numeric',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'exposed' => TRUE,
- 'expose' => array(
+ 'expose' => [
'operator' => 'age_op',
'label' => 'age',
'identifier' => 'age',
- ),
+ ],
'is_grouped' => TRUE,
- 'group_info' => array(
+ 'group_info' => [
'label' => 'age',
'identifier' => 'age',
'default_group' => 'All',
- 'group_items' => array(
- 1 => array(
+ 'group_items' => [
+ 1 => [
'title' => 'Age is 28',
'operator' => '=',
- 'value' => array('value' => 28),
- ),
- 2 => array(
+ 'value' => ['value' => 28],
+ ],
+ 2 => [
'title' => 'Age is between 26 and 29',
'operator' => 'between',
- 'value' => array(
+ 'value' => [
'min' => 26,
'max' => 29,
- ),
- ),
- 3 => array(
+ ],
+ ],
+ 3 => [
'title' => 'Age is not between 26 and 29',
'operator' => 'not between',
- 'value' => array(
+ 'value' => [
'min' => 26,
'max' => 29,
- ),
- ),
- 4 => array(
+ ],
+ ],
+ 4 => [
'title' => 'Age is empty',
'operator' => 'empty',
- ),
- 5 => array(
+ ],
+ 5 => [
'title' => 'Age is not empty',
'operator' => 'not empty',
- ),
- 6 => array(
+ ],
+ 6 => [
'title' => 'Age is regexp 2[7-8]',
'operator' => 'regular_expression',
- 'value' => array(
+ 'value' => [
'value' => '2[7-8]',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $filters;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
index 5dd47ecb3b3..c21df9a0f78 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
@@ -12,23 +12,23 @@ use Drupal\views\Views;
*/
class FilterStringTest extends ViewsKernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Map column names.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
- );
+ ];
function viewsData() {
$data = parent::viewsData();
@@ -41,12 +41,12 @@ class FilterStringTest extends ViewsKernelTestBase {
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
- $schema['views_test_data']['fields']['description'] = array(
+ $schema['views_test_data']['fields']['description'] = [
'description' => "A person's description",
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
- );
+ ];
return $schema;
}
@@ -86,23 +86,23 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => '=',
'value' => 'Ringo',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -119,11 +119,11 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -133,32 +133,32 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => '!=',
'value' => 'Ringo',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -176,20 +176,20 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
- array(
+ ],
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -199,23 +199,23 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => 'contains',
'value' => 'ing',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -233,11 +233,11 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -248,26 +248,26 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'word',
'value' => 'actor',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
$view->destroy();
@@ -275,23 +275,23 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'allwords',
'value' => 'Richard Starkey',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -309,11 +309,11 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
$view->destroy();
@@ -327,14 +327,14 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->displayHandlers->get('page_1')->overrideOption('filters', $filters);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -343,23 +343,23 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'starts',
'value' => 'George',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -376,11 +376,11 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -389,30 +389,30 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'not_starts',
'value' => 'George',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
+ ],
// There is no Meredith returned because his description is empty
- );
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -429,18 +429,18 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
+ ],
// There is no Meredith returned because his description is empty
- );
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -449,26 +449,26 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'ends',
'value' => 'Beatles.',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -485,14 +485,14 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'George',
- ),
- array(
+ ],
+ [
'name' => 'Ringo',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -501,27 +501,27 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'not_ends',
'value' => 'Beatles.',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
+ ],
// There is no Meredith returned because his description is empty
- );
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -538,15 +538,15 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
+ ],
// There is no Meredith returned because his description is empty
- );
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -555,27 +555,27 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'not',
'value' => 'Beatles.',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
+ ],
// There is no Meredith returned because his description is empty
- );
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -593,15 +593,15 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
+ ],
// There is no Meredith returned because his description is empty
- );
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -611,26 +611,26 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => 'shorterthan',
'value' => 5,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -646,14 +646,14 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'John',
- ),
- array(
+ ],
+ [
'name' => 'Paul',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -662,23 +662,23 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'operator' => 'longerthan',
'value' => 7,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -694,11 +694,11 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -708,22 +708,22 @@ class FilterStringTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the filtering
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'description' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
'id' => 'description',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'operator' => 'empty',
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
@@ -739,119 +739,119 @@ class FilterStringTest extends ViewsKernelTestBase {
$this->container->get('router.builder')->rebuild();
$this->executeView($view);
- $resultset = array(
- array(
+ $resultset = [
+ [
'name' => 'Meredith',
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
protected function getGroupedExposedFilters() {
- $filters = array(
- 'name' => array(
+ $filters = [
+ 'name' => [
'id' => 'name',
'plugin_id' => 'string',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
'exposed' => TRUE,
- 'expose' => array(
+ 'expose' => [
'operator' => 'name_op',
'label' => 'name',
'identifier' => 'name',
- ),
+ ],
'is_grouped' => TRUE,
- 'group_info' => array(
+ 'group_info' => [
'label' => 'name',
'identifier' => 'name',
'default_group' => 'All',
- 'group_items' => array(
- 1 => array(
+ 'group_items' => [
+ 1 => [
'title' => 'Is Ringo',
'operator' => '=',
'value' => 'Ringo',
- ),
- 2 => array(
+ ],
+ 2 => [
'title' => 'Is not Ringo',
'operator' => '!=',
'value' => 'Ringo',
- ),
- 3 => array(
+ ],
+ 3 => [
'title' => 'Contains ing',
'operator' => 'contains',
'value' => 'ing',
- ),
- 4 => array(
+ ],
+ 4 => [
'title' => 'Shorter than 5 letters',
'operator' => 'shorterthan',
'value' => 5,
- ),
- 5 => array(
+ ],
+ 5 => [
'title' => 'Longer than 7 letters',
'operator' => 'longerthan',
'value' => 7,
- ),
- ),
- ),
- ),
- 'description' => array(
+ ],
+ ],
+ ],
+ ],
+ 'description' => [
'id' => 'description',
'plugin_id' => 'string',
'table' => 'views_test_data',
'field' => 'description',
'relationship' => 'none',
'exposed' => TRUE,
- 'expose' => array(
+ 'expose' => [
'operator' => 'description_op',
'label' => 'description',
'identifier' => 'description',
- ),
+ ],
'is_grouped' => TRUE,
- 'group_info' => array(
+ 'group_info' => [
'label' => 'description',
'identifier' => 'description',
'default_group' => 'All',
- 'group_items' => array(
- 1 => array(
+ 'group_items' => [
+ 1 => [
'title' => 'Contains the word: Actor',
'operator' => 'word',
'value' => 'actor',
- ),
- 2 => array(
+ ],
+ 2 => [
'title' => 'Starts with George',
'operator' => 'starts',
'value' => 'George',
- ),
- 3 => array(
+ ],
+ 3 => [
'title' => 'Not Starts with: George',
'operator' => 'not_starts',
'value' => 'George',
- ),
- 4 => array(
+ ],
+ 4 => [
'title' => 'Ends with: Beatles',
'operator' => 'ends',
'value' => 'Beatles.',
- ),
- 5 => array(
+ ],
+ 5 => [
'title' => 'Not Ends with: Beatles',
'operator' => 'not_ends',
'value' => 'Beatles.',
- ),
- 6 => array(
+ ],
+ 6 => [
'title' => 'Does not contain: Beatles',
'operator' => 'not',
'value' => 'Beatles.',
- ),
- 7 => array(
+ ],
+ 7 => [
'title' => 'Empty description',
'operator' => 'empty',
'value' => '',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
return $filters;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/HandlerAliasTest.php b/core/modules/views/tests/src/Kernel/Handler/HandlerAliasTest.php
index 48f4e3d4900..53d25b38e6a 100644
--- a/core/modules/views/tests/src/Kernel/Handler/HandlerAliasTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/HandlerAliasTest.php
@@ -12,14 +12,14 @@ use Drupal\views\Views;
*/
class HandlerAliasTest extends ViewsKernelTestBase {
- public static $modules = array('user');
+ public static $modules = ['user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_filter', 'test_alias');
+ public static $testViews = ['test_filter', 'test_alias'];
protected function setUp($import_test_views = TRUE) {
parent::setUp();
@@ -45,16 +45,16 @@ class HandlerAliasTest extends ViewsKernelTestBase {
$view->initDisplay();
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'test_filter' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'test_filter' => [
'id' => 'test_filter',
'table' => 'views_test_data_alias',
'field' => 'name_alias',
'operator' => '=',
'value' => 'John',
'group' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
diff --git a/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php b/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php
index 4a137541125..2d1a2fcc2fc 100644
--- a/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/SortDateTest.php
@@ -18,123 +18,123 @@ class SortDateTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
protected function expectedResultSet($granularity, $reverse = TRUE) {
- $expected = array();
+ $expected = [];
if (!$reverse) {
switch ($granularity) {
case 'second':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- array('name' => 'Ringo'),
- array('name' => 'George'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ['name' => 'Ringo'],
+ ['name' => 'George'],
+ ];
break;
case 'minute':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'Paul'),
- array('name' => 'Ringo'),
- array('name' => 'Meredith'),
- array('name' => 'George'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'Paul'],
+ ['name' => 'Ringo'],
+ ['name' => 'Meredith'],
+ ['name' => 'George'],
+ ];
break;
case 'hour':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- array('name' => 'George'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ['name' => 'George'],
+ ];
break;
case 'day':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- array('name' => 'George'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ['name' => 'George'],
+ ];
break;
case 'month':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'George'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'George'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ];
break;
case 'year':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'George'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'George'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ];
break;
}
}
else {
switch ($granularity) {
case 'second':
- $expected = array(
- array('name' => 'George'),
- array('name' => 'Ringo'),
- array('name' => 'Meredith'),
- array('name' => 'Paul'),
- array('name' => 'John'),
- );
+ $expected = [
+ ['name' => 'George'],
+ ['name' => 'Ringo'],
+ ['name' => 'Meredith'],
+ ['name' => 'Paul'],
+ ['name' => 'John'],
+ ];
break;
case 'minute':
- $expected = array(
- array('name' => 'George'),
- array('name' => 'Ringo'),
- array('name' => 'Meredith'),
- array('name' => 'Paul'),
- array('name' => 'John'),
- );
+ $expected = [
+ ['name' => 'George'],
+ ['name' => 'Ringo'],
+ ['name' => 'Meredith'],
+ ['name' => 'Paul'],
+ ['name' => 'John'],
+ ];
break;
case 'hour':
- $expected = array(
- array('name' => 'George'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- array('name' => 'John'),
- );
+ $expected = [
+ ['name' => 'George'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ['name' => 'John'],
+ ];
break;
case 'day':
- $expected = array(
- array('name' => 'George'),
- array('name' => 'John'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- );
+ $expected = [
+ ['name' => 'George'],
+ ['name' => 'John'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ];
break;
case 'month':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'George'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'George'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ];
break;
case 'year':
- $expected = array(
- array('name' => 'John'),
- array('name' => 'George'),
- array('name' => 'Ringo'),
- array('name' => 'Paul'),
- array('name' => 'Meredith'),
- );
+ $expected = [
+ ['name' => 'John'],
+ ['name' => 'George'],
+ ['name' => 'Ringo'],
+ ['name' => 'Paul'],
+ ['name' => 'Meredith'],
+ ];
break;
}
}
@@ -146,54 +146,54 @@ class SortDateTest extends ViewsKernelTestBase {
* Tests numeric ordering of the result set.
*/
public function testDateOrdering() {
- foreach (array('second', 'minute', 'hour', 'day', 'month', 'year') as $granularity) {
- foreach (array(FALSE, TRUE) as $reverse) {
+ foreach (['second', 'minute', 'hour', 'day', 'month', 'year'] as $granularity) {
+ foreach ([FALSE, TRUE] as $reverse) {
$view = Views::getView('test_view');
$view->setDisplay();
// Change the fields.
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'name' => [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- ),
- 'created' => array(
+ ],
+ 'created' => [
'id' => 'created',
'table' => 'views_test_data',
'field' => 'created',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Change the ordering
- $view->displayHandlers->get('default')->overrideOption('sorts', array(
- 'created' => array(
+ $view->displayHandlers->get('default')->overrideOption('sorts', [
+ 'created' => [
'id' => 'created',
'table' => 'views_test_data',
'field' => 'created',
'relationship' => 'none',
'granularity' => $granularity,
'order' => $reverse ? 'DESC' : 'ASC',
- ),
- 'id' => array(
+ ],
+ 'id' => [
'id' => 'id',
'table' => 'views_test_data',
'field' => 'id',
'relationship' => 'none',
'order' => 'ASC',
- ),
- ));
+ ],
+ ]);
// Execute the view.
$this->executeView($view);
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultset($view, $this->expectedResultSet($granularity, $reverse), array(
+ $this->assertIdenticalResultset($view, $this->expectedResultSet($granularity, $reverse), [
'views_test_data_name' => 'name',
- ), SafeMarkup::format('Result is returned correctly when ordering by granularity @granularity, @reverse.', array('@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward')));
+ ], SafeMarkup::format('Result is returned correctly when ordering by granularity @granularity, @reverse.', ['@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward']));
$view->destroy();
unset($view);
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php b/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
index 97b27073364..941ed8d9efa 100644
--- a/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
@@ -19,7 +19,7 @@ class SortRandomTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Add more items to the test set, to make the order tests more robust.
@@ -34,13 +34,13 @@ class SortRandomTest extends ViewsKernelTestBase {
protected function dataSet() {
$data = parent::dataSet();
for ($i = 0; $i < 55; $i++) {
- $data[] = array(
+ $data[] = [
'name' => 'name_' . $i,
'age' => $i,
'job' => 'job_' . $i,
'created' => rand(0, time()),
'status' => 1,
- );
+ ];
}
return $data;
}
@@ -53,13 +53,13 @@ class SortRandomTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a random ordering.
- $view->displayHandlers->get('default')->overrideOption('sorts', array(
- 'random' => array(
+ $view->displayHandlers->get('default')->overrideOption('sorts', [
+ 'random' => [
'id' => 'random',
'field' => 'random',
'table' => 'views',
- ),
- ));
+ ],
+ ]);
return $view;
}
@@ -76,28 +76,28 @@ class SortRandomTest extends ViewsKernelTestBase {
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultset($view, $this->dataSet(), array(
+ $this->assertIdenticalResultset($view, $this->dataSet(), [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
// Execute a random view, we expect the result set to be different.
$view_random = $this->getBasicRandomView();
$this->executeView($view_random);
$this->assertEqual(count($this->dataSet()), count($view_random->result), 'The number of returned rows match.');
- $this->assertNotIdenticalResultset($view_random, $view->result, array(
+ $this->assertNotIdenticalResultset($view_random, $view->result, [
'views_test_data_name' => 'views_test_data_name',
'views_test_data_age' => 'views_test_data_name',
- ));
+ ]);
// Execute a second random view, we expect the result set to be different again.
$view_random_2 = $this->getBasicRandomView();
$this->executeView($view_random_2);
$this->assertEqual(count($this->dataSet()), count($view_random_2->result), 'The number of returned rows match.');
- $this->assertNotIdenticalResultset($view_random, $view->result, array(
+ $this->assertNotIdenticalResultset($view_random, $view->result, [
'views_test_data_name' => 'views_test_data_name',
'views_test_data_age' => 'views_test_data_name',
- ));
+ ]);
}
/**
diff --git a/core/modules/views/tests/src/Kernel/Handler/SortTest.php b/core/modules/views/tests/src/Kernel/Handler/SortTest.php
index 38cbcd1a370..91560495fb8 100644
--- a/core/modules/views/tests/src/Kernel/Handler/SortTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/SortTest.php
@@ -17,7 +17,7 @@ class SortTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests numeric ordering of the result set.
@@ -27,49 +27,49 @@ class SortTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the ordering
- $view->displayHandlers->get('default')->overrideOption('sorts', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('sorts', [
+ 'age' => [
'order' => 'ASC',
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Execute the view.
$this->executeView($view);
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age'), array(
+ $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age'), [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
$view->destroy();
$view->setDisplay();
// Reverse the ordering
- $view->displayHandlers->get('default')->overrideOption('sorts', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('sorts', [
+ 'age' => [
'order' => 'DESC',
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Execute the view.
$this->executeView($view);
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age', TRUE), array(
+ $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age', TRUE), [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
}
/**
@@ -80,49 +80,49 @@ class SortTest extends ViewsKernelTestBase {
$view->setDisplay();
// Change the ordering
- $view->displayHandlers->get('default')->overrideOption('sorts', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('sorts', [
+ 'name' => [
'order' => 'ASC',
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Execute the view.
$this->executeView($view);
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name'), array(
+ $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name'), [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
$view->destroy();
$view->setDisplay();
// Reverse the ordering
- $view->displayHandlers->get('default')->overrideOption('sorts', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('sorts', [
+ 'name' => [
'order' => 'DESC',
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'relationship' => 'none',
- ),
- ));
+ ],
+ ]);
// Execute the view.
$this->executeView($view);
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name', TRUE), array(
+ $this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name', TRUE), [
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
- ));
+ ]);
}
}
diff --git a/core/modules/views/tests/src/Kernel/ModuleTest.php b/core/modules/views/tests/src/Kernel/ModuleTest.php
index 204433dc963..4ed5e0a9697 100644
--- a/core/modules/views/tests/src/Kernel/ModuleTest.php
+++ b/core/modules/views/tests/src/Kernel/ModuleTest.php
@@ -19,7 +19,7 @@ class ModuleTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view_status', 'test_view', 'test_argument');
+ public static $testViews = ['test_view_status', 'test_view', 'test_argument'];
/**
* Modules to enable.
@@ -43,27 +43,27 @@ class ModuleTest extends ViewsKernelTestBase {
* @see views_get_handler()
*/
public function testViewsGetHandler() {
- $types = array('field', 'area', 'filter');
+ $types = ['field', 'area', 'filter'];
foreach ($types as $type) {
- $item = array(
+ $item = [
'table' => $this->randomMachineName(),
'field' => $this->randomMachineName(),
- );
+ ];
$handler = $this->container->get('plugin.manager.views.' . $type)->getHandler($item);
$this->assertEqual('Drupal\views\Plugin\views\\' . $type . '\Broken', get_class($handler), new FormattableMarkup('Make sure that a broken handler of type: @type is created.', ['@type' => $type]));
}
$views_data = $this->viewsData();
- $test_tables = array('views_test_data' => array('id', 'name'));
+ $test_tables = ['views_test_data' => ['id', 'name']];
foreach ($test_tables as $table => $fields) {
foreach ($fields as $field) {
$data = $views_data[$table][$field];
- $item = array(
+ $item = [
'table' => $table,
'field' => $field,
- );
+ ];
foreach ($data as $id => $field_data) {
- if (!in_array($id, array('title', 'help'))) {
+ if (!in_array($id, ['title', 'help'])) {
$handler = $this->container->get('plugin.manager.views.' . $id)->getHandler($item);
$this->assertInstanceHandler($handler, $table, $field, $id);
}
@@ -72,10 +72,10 @@ class ModuleTest extends ViewsKernelTestBase {
}
// Test the override handler feature.
- $item = array(
+ $item = [
'table' => 'views_test_data',
'field' => 'job',
- );
+ ];
$handler = $this->container->get('plugin.manager.views.filter')->getHandler($item, 'standard');
$this->assertTrue($handler instanceof Standard);
@@ -84,29 +84,29 @@ class ModuleTest extends ViewsKernelTestBase {
return;
// Test non-existent tables/fields.
- set_error_handler(array($this, 'customErrorHandler'));
- $item = array(
+ set_error_handler([$this, 'customErrorHandler']);
+ $item = [
'table' => 'views_test_data',
'field' => 'field_invalid',
- );
+ ];
$this->container->get('plugin.manager.views.field')->getHandler($item);
- $this->assertTrue(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field'))) !== FALSE, 'An invalid field name throws a debug message.');
+ $this->assertTrue(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", ['@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field'])) !== FALSE, 'An invalid field name throws a debug message.');
unset($this->lastErrorMessage);
- $item = array(
+ $item = [
'table' => 'table_invalid',
'field' => 'id',
- );
+ ];
$this->container->get('plugin.manager.views.filter')->getHandler($item);
- $this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
+ $this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", ['@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'])) !== FALSE, 'An invalid table name throws a debug message.');
unset($this->lastErrorMessage);
- $item = array(
+ $item = [
'table' => 'table_invalid',
'field' => 'id',
- );
+ ];
$this->container->get('plugin.manager.views.filter')->getHandler($item);
- $this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
+ $this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", ['@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'])) !== FALSE, 'An invalid table name throws a debug message.');
unset($this->lastErrorMessage);
restore_error_handler();
@@ -139,8 +139,8 @@ class ModuleTest extends ViewsKernelTestBase {
* Tests the load wrapper/helper functions.
*/
public function testLoadFunctions() {
- $this->enableModules(array('text', 'node'));
- $this->installConfig(array('node'));
+ $this->enableModules(['text', 'node']);
+ $this->installConfig(['node']);
$storage = $this->container->get('entity.manager')->getStorage('view');
// Test views_view_is_enabled/disabled.
@@ -172,7 +172,7 @@ class ModuleTest extends ViewsKernelTestBase {
// Test Views::getViewsAsOptions().
// Test the $views_only parameter.
$this->assertIdentical(array_keys($all_views), array_keys(Views::getViewsAsOptions(TRUE)), 'Expected option keys for all views were returned.');
- $expected_options = array();
+ $expected_options = [];
foreach ($all_views as $id => $view) {
$expected_options[$id] = $view->label();
}
@@ -196,10 +196,10 @@ class ModuleTest extends ViewsKernelTestBase {
$this->assertFalse(array_key_exists('archive', Views::getViewsAsOptions(TRUE, 'all', $archive->getExecutable())), 'View excluded from options based on object');
// Test the $opt_group parameter.
- $expected_opt_groups = array();
+ $expected_opt_groups = [];
foreach ($all_views as $view) {
foreach ($view->get('display') as $display) {
- $expected_opt_groups[$view->id()][$view->id() . ':' . $display['id']] = (string) t('@view : @display', array('@view' => $view->id(), '@display' => $display['id']));
+ $expected_opt_groups[$view->id()][$view->id() . ':' . $display['id']] = (string) t('@view : @display', ['@view' => $view->id(), '@display' => $display['id']]);
}
}
$this->assertIdentical($expected_opt_groups, $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'all', NULL, TRUE)), 'Expected option array for an option group returned.');
@@ -229,7 +229,7 @@ class ModuleTest extends ViewsKernelTestBase {
// All style plugins should be returned, as we have not specified a type.
$plugins = Views::fetchPluginNames('style');
$definitions = $this->container->get('plugin.manager.views.style')->getDefinitions();
- $expected = array();
+ $expected = [];
foreach ($definitions as $id => $definition) {
$expected[$id] = $definition['title'];
}
@@ -239,11 +239,11 @@ class ModuleTest extends ViewsKernelTestBase {
// Test using the 'test' style plugin type only returns the test_style and
// mapping_test plugins.
$plugins = Views::fetchPluginNames('style', 'test');
- $this->assertIdentical(array_keys($plugins), array('mapping_test', 'test_style', 'test_template_style'));
+ $this->assertIdentical(array_keys($plugins), ['mapping_test', 'test_style', 'test_template_style']);
// Test a non existent style plugin type returns no plugins.
$plugins = Views::fetchPluginNames('style', $this->randomString());
- $this->assertIdentical($plugins, array());
+ $this->assertIdentical($plugins, []);
}
/**
@@ -252,11 +252,11 @@ class ModuleTest extends ViewsKernelTestBase {
public function testViewsPluginList() {
$plugin_list = Views::pluginList();
// Only plugins used by 'test_view' should be in the plugin list.
- foreach (array('display:default', 'pager:none') as $key) {
+ foreach (['display:default', 'pager:none'] as $key) {
list($plugin_type, $plugin_id) = explode(':', $key);
$plugin_def = $this->container->get("plugin.manager.views.$plugin_type")->getDefinition($plugin_id);
- $this->assertTrue(isset($plugin_list[$key]), SafeMarkup::format('The expected @key plugin list key was found.', array('@key' => $key)));
+ $this->assertTrue(isset($plugin_list[$key]), SafeMarkup::format('The expected @key plugin list key was found.', ['@key' => $key]));
$plugin_details = $plugin_list[$key];
$this->assertEqual($plugin_details['type'], $plugin_type, 'The expected plugin type was found.');
@@ -303,35 +303,35 @@ class ModuleTest extends ViewsKernelTestBase {
$this->assertEqual(count($result['#view']->result), 5);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('0' => 1));
+ $result = $view->preview('default', ['0' => 1]);
$this->assertEqual(count($result['#view']->result), 1);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('3' => 1));
+ $result = $view->preview('default', ['3' => 1]);
$this->assertEqual(count($result['#view']->result), 1);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('0' => '1,2'));
+ $result = $view->preview('default', ['0' => '1,2']);
$this->assertEqual(count($result['#view']->result), 2);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('3' => '1,2'));
+ $result = $view->preview('default', ['3' => '1,2']);
$this->assertEqual(count($result['#view']->result), 2);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('0' => '1,2', '1' => 'John'));
+ $result = $view->preview('default', ['0' => '1,2', '1' => 'John']);
$this->assertEqual(count($result['#view']->result), 1);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('3' => '1,2', '4' => 'John'));
+ $result = $view->preview('default', ['3' => '1,2', '4' => 'John']);
$this->assertEqual(count($result['#view']->result), 1);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('0' => '1,2', '1' => 'John,George'));
+ $result = $view->preview('default', ['0' => '1,2', '1' => 'John,George']);
$this->assertEqual(count($result['#view']->result), 2);
$view = Views::getView('test_argument');
- $result = $view->preview('default', array('3' => '1,2', '4' => 'John,George'));
+ $result = $view->preview('default', ['3' => '1,2', '4' => 'John,George']);
$this->assertEqual(count($result['#view']->result), 2);
}
@@ -345,12 +345,12 @@ class ModuleTest extends ViewsKernelTestBase {
* @return array
* A formatted options array that matches the expected output.
*/
- protected function formatViewOptions(array $views = array()) {
- $expected_options = array();
+ protected function formatViewOptions(array $views = []) {
+ $expected_options = [];
foreach ($views as $view) {
foreach ($view->get('display') as $display) {
$expected_options[$view->id() . ':' . $display['id']] = (string) t('View: @view - Display: @display',
- array('@view' => $view->id(), '@display' => $display['id']));
+ ['@view' => $view->id(), '@display' => $display['id']]);
}
}
diff --git a/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php b/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php
index 6b5de6e6aec..1a9f32eff7b 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php
@@ -17,14 +17,14 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_exposed_block');
+ public static $testViews = ['test_exposed_block'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('node', 'block', 'user', 'field');
+ public static $modules = ['node', 'block', 'user', 'field'];
/**
* Tests that exposed filter blocks have the correct dependencies.
@@ -34,11 +34,11 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
public function testExposedBlock() {
$block = $this->createBlock('views_exposed_filter_block:test_exposed_block-page_1');
$dependencies = $block->calculateDependencies()->getDependencies();
- $expected = array(
- 'config' => array('views.view.test_exposed_block'),
- 'module' => array('views'),
- 'theme' => array('stark')
- );
+ $expected = [
+ 'config' => ['views.view.test_exposed_block'],
+ 'module' => ['views'],
+ 'theme' => ['stark']
+ ];
$this->assertIdentical($expected, $dependencies);
}
@@ -50,11 +50,11 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
public function testViewsBlock() {
$block = $this->createBlock('views_block:content_recent-block_1');
$dependencies = $block->calculateDependencies()->getDependencies();
- $expected = array(
- 'config' => array('views.view.content_recent'),
- 'module' => array('views'),
- 'theme' => array('stark')
- );
+ $expected = [
+ 'config' => ['views.view.content_recent'],
+ 'module' => ['views'],
+ 'theme' => ['stark']
+ ];
$this->assertIdentical($expected, $dependencies);
}
@@ -82,18 +82,18 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
* @return \Drupal\block\Entity\Block
* The block entity.
*/
- protected function createBlock($plugin_id, array $settings = array()) {
- $settings += array(
+ protected function createBlock($plugin_id, array $settings = []) {
+ $settings += [
'plugin' => $plugin_id,
'region' => 'sidebar_first',
'id' => strtolower($this->randomMachineName(8)),
'theme' => $this->config('system.theme')->get('default'),
'label' => $this->randomMachineName(8),
- 'visibility' => array(),
+ 'visibility' => [],
'weight' => 0,
- );
+ ];
$values = [];
- foreach (array('region', 'id', 'theme', 'plugin', 'weight', 'visibility') as $key) {
+ foreach (['region', 'id', 'theme', 'plugin', 'weight', 'visibility'] as $key) {
$values[$key] = $settings[$key];
// Remove extra values that do not belong in the settings array.
unset($settings[$key]);
diff --git a/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php b/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php
index e1328d767e0..01c67217267 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php
@@ -21,14 +21,14 @@ class CacheTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_cache', 'test_groupwise_term_ui', 'test_display', 'test_filter');
+ public static $testViews = ['test_view', 'test_cache', 'test_groupwise_term_ui', 'test_display', 'test_filter'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('taxonomy', 'text', 'user', 'node');
+ public static $modules = ['taxonomy', 'text', 'user', 'node'];
/**
* {@inheritdoc}
@@ -70,13 +70,13 @@ class CacheTest extends ViewsKernelTestBase {
public function testTimeResultCaching() {
$view = Views::getView('test_cache');
$view->setDisplay();
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'time',
- 'options' => array(
+ 'options' => [
'results_lifespan' => '3600',
'output_lifespan' => '3600',
- )
- ));
+ ]
+ ]);
// Test the default (non-paged) display.
$this->executeView($view);
@@ -84,11 +84,11 @@ class CacheTest extends ViewsKernelTestBase {
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
// Add another man to the beatles.
- $record = array(
+ $record = [
'name' => 'Rod Davis',
'age' => 29,
'job' => 'Banjo',
- );
+ ];
db_insert('views_test_data')->fields($record)->execute();
// The result should be the same as before, because of the caching. (Note
@@ -112,25 +112,25 @@ class CacheTest extends ViewsKernelTestBase {
$view = Views::getView('test_filter');
$view->initDisplay();
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'time',
- 'options' => array(
+ 'options' => [
'results_lifespan' => '3600',
'output_lifespan' => '3600',
- ),
- ));
+ ],
+ ]);
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'test_filter' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'test_filter' => [
'id' => 'test_filter',
'table' => 'views_test_data',
'field' => 'name',
'operator' => '=',
'value' => 'John',
'group' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
@@ -138,29 +138,29 @@ class CacheTest extends ViewsKernelTestBase {
$cid1 = $view->display_handler->getPlugin('cache')->generateResultsKey();
// Build the expected result.
- $dataset = array(array('name' => 'John'));
+ $dataset = [['name' => 'John']];
// Verify the result.
$this->assertEqual(1, count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultSet($view, $dataset, array(
+ $this->assertIdenticalResultSet($view, $dataset, [
'views_test_data_name' => 'name',
- ));
+ ]);
$view->destroy();
$view->initDisplay();
// Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'test_filter' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'test_filter' => [
'id' => 'test_filter',
'table' => 'views_test_data',
'field' => 'name',
'operator' => '=',
'value' => 'Ringo',
'group' => 0,
- ),
- ));
+ ],
+ ]);
$this->executeView($view);
@@ -169,13 +169,13 @@ class CacheTest extends ViewsKernelTestBase {
$this->assertNotEqual($cid1, $cid2, "Results keys are different.");
// Build the expected result.
- $dataset = array(array('name' => 'Ringo'));
+ $dataset = [['name' => 'Ringo']];
// Verify the result.
$this->assertEqual(1, count($view->result), 'The number of returned rows match.');
- $this->assertIdenticalResultSet($view, $dataset, array(
+ $this->assertIdenticalResultSet($view, $dataset, [
'views_test_data_name' => 'name',
- ));
+ ]);
}
/**
@@ -184,13 +184,13 @@ class CacheTest extends ViewsKernelTestBase {
public function testTimeResultCachingWithPager() {
$view = Views::getView('test_cache');
$view->setDisplay();
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'time',
- 'options' => array(
+ 'options' => [
'results_lifespan' => '3600',
'output_lifespan' => '3600',
- )
- ));
+ ]
+ ]);
$mapping = ['views_test_data_name' => 'name'];
@@ -228,30 +228,30 @@ class CacheTest extends ViewsKernelTestBase {
// Create a basic result which just 2 results.
$view = Views::getView('test_cache');
$view->setDisplay();
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'none',
- 'options' => array(),
- ));
+ 'options' => [],
+ ]);
$this->executeView($view);
// Verify the result.
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
// Add another man to the beatles.
- $record = array(
+ $record = [
'name' => 'Rod Davis',
'age' => 29,
'job' => 'Banjo',
- );
+ ];
db_insert('views_test_data')->fields($record)->execute();
// The Result changes, because the view is not cached.
$view = Views::getView('test_cache');
$view->setDisplay();
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'none',
- 'options' => array(),
- ));
+ 'options' => [],
+ ]);
$this->executeView($view);
// Verify the result.
@@ -268,12 +268,12 @@ class CacheTest extends ViewsKernelTestBase {
$view = Views::getView('test_view');
$view->setDisplay();
$view->storage->set('id', 'test_cache_header_storage');
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'time',
- 'options' => array(
+ 'options' => [
'output_lifespan' => '3600',
- )
- ));
+ ]
+ ]);
$output = $view->buildRenderable();
/** @var \Drupal\Core\Render\RendererInterface $renderer */
@@ -326,13 +326,13 @@ class CacheTest extends ViewsKernelTestBase {
$view = Views::getView('test_display');
$view->setDisplay();
- $view->display_handler->overrideOption('cache', array(
+ $view->display_handler->overrideOption('cache', [
'type' => 'time',
- 'options' => array(
+ 'options' => [
'results_lifespan' => '3600',
'output_lifespan' => '3600',
- )
- ));
+ ]
+ ]);
$this->executeView($view);
// Get the cache item.
@@ -390,13 +390,13 @@ class CacheTest extends ViewsKernelTestBase {
$view = Views::getView('test_view');
// Add a new argument and set the test plugin for the argument_default.
- $options = array(
+ $options = [
'default_argument_type' => 'argument_default_test',
- 'default_argument_options' => array(
+ 'default_argument_options' => [
'value' => 'John'
- ),
+ ],
'default_action' => 'default'
- );
+ ];
$view->addHandler('default', 'argument', 'views_test_data', 'name', $options);
$view->initHandlers();
diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php
index 156b06119cc..69666cf3422 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php
@@ -24,14 +24,14 @@ class DisplayKernelTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('block', 'node', 'field', 'user');
+ public static $modules = ['block', 'node', 'field', 'user'];
/**
* Views plugin types to test.
*
* @var array
*/
- protected $pluginTypes = array(
+ protected $pluginTypes = [
'access',
'cache',
'query',
@@ -39,24 +39,24 @@ class DisplayKernelTest extends ViewsKernelTestBase {
'pager',
'style',
'row',
- );
+ ];
/**
* Views handler types to test.
*
* @var array
*/
- protected $handlerTypes = array(
+ protected $handlerTypes = [
'fields',
'sorts',
- );
+ ];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_display_defaults');
+ public static $testViews = ['test_display_defaults'];
/**
* Tests the default display options.
diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
index 5e4724a82b2..8aaaa2dd5d7 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php
@@ -22,14 +22,14 @@ class DisplayPageTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_page_display', 'test_page_display_route', 'test_page_display_menu');
+ public static $testViews = ['test_page_display', 'test_page_display_route', 'test_page_display_menu'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('system', 'user', 'field');
+ public static $modules = ['system', 'user', 'field'];
/**
* The router dumper to get all routes.
diff --git a/core/modules/views/tests/src/Kernel/Plugin/JoinTest.php b/core/modules/views/tests/src/Kernel/Plugin/JoinTest.php
index db0262a1dbb..0839fcb2c86 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/JoinTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/JoinTest.php
@@ -21,7 +21,7 @@ class JoinTest extends RelationshipJoinTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* A plugin manager which handlers the instances of joins.
@@ -47,12 +47,12 @@ class JoinTest extends RelationshipJoinTestBase {
$view->initDisplay();
$view->initQuery();
- $configuration = array(
+ $configuration = [
'left_table' => 'views_test_data',
'left_field' => 'uid',
'table' => 'users_field_data',
'field' => 'uid',
- );
+ ];
$join = $this->manager->createInstance('join_test', $configuration);
$this->assertTrue($join instanceof JoinTestPlugin, 'The correct join class got loaded.');
@@ -60,7 +60,7 @@ class JoinTest extends RelationshipJoinTestBase {
$join->setJoinValue($rand_int);
$query = db_select('views_test_data');
- $table = array('alias' => 'users_field_data');
+ $table = ['alias' => 'users_field_data'];
$join->buildJoin($query, $table, $view->query);
$tables = $query->getTables();
@@ -80,13 +80,13 @@ class JoinTest extends RelationshipJoinTestBase {
// First define a simple join without an extra condition.
// Set the various options on the join object.
- $configuration = array(
+ $configuration = [
'left_table' => 'views_test_data',
'left_field' => 'uid',
'table' => 'users_field_data',
'field' => 'uid',
'adjusted' => TRUE,
- );
+ ];
$join = $this->manager->createInstance('standard', $configuration);
$this->assertTrue($join instanceof JoinPluginBase, 'The correct join class got loaded.');
$this->assertNull($join->extra, 'The field extra was not overridden.');
@@ -95,7 +95,7 @@ class JoinTest extends RelationshipJoinTestBase {
// Build the actual join values and read them back from the dbtng query
// object.
$query = db_select('views_test_data');
- $table = array('alias' => 'users_field_data');
+ $table = ['alias' => 'users_field_data'];
$join->buildJoin($query, $table, $view->query);
$tables = $query->getTables();
@@ -107,7 +107,7 @@ class JoinTest extends RelationshipJoinTestBase {
// Set a different alias and make sure table info is as expected.
$join = $this->manager->createInstance('standard', $configuration);
- $table = array('alias' => 'users1');
+ $table = ['alias' => 'users1'];
$join->buildJoin($query, $table, $view->query);
$tables = $query->getTables();
@@ -117,7 +117,7 @@ class JoinTest extends RelationshipJoinTestBase {
// Set a different join type (INNER) and make sure it is used.
$configuration['type'] = 'INNER';
$join = $this->manager->createInstance('standard', $configuration);
- $table = array('alias' => 'users2');
+ $table = ['alias' => 'users2'];
$join->buildJoin($query, $table, $view->query);
$tables = $query->getTables();
@@ -127,19 +127,19 @@ class JoinTest extends RelationshipJoinTestBase {
// Setup addition conditions and make sure it is used.
$random_name_1 = $this->randomMachineName();
$random_name_2 = $this->randomMachineName();
- $configuration['extra'] = array(
- array(
+ $configuration['extra'] = [
+ [
'field' => 'name',
'value' => $random_name_1
- ),
- array(
+ ],
+ [
'field' => 'name',
'value' => $random_name_2,
'operator' => '<>'
- ),
- );
+ ],
+ ];
$join = $this->manager->createInstance('standard', $configuration);
- $table = array('alias' => 'users3');
+ $table = ['alias' => 'users3'];
$join->buildJoin($query, $table, $view->query);
$tables = $query->getTables();
@@ -147,25 +147,25 @@ class JoinTest extends RelationshipJoinTestBase {
$this->assertTrue(strpos($join_info['condition'], "views_test_data.uid = users3.uid") !== FALSE, 'Make sure the join condition appears in the query.');
$this->assertTrue(strpos($join_info['condition'], "users3.name = :views_join_condition_0") !== FALSE, 'Make sure the first extra join condition appears in the query and uses the first placeholder.');
$this->assertTrue(strpos($join_info['condition'], "users3.name <> :views_join_condition_1") !== FALSE, 'Make sure the second extra join condition appears in the query and uses the second placeholder.');
- $this->assertEqual(array_values($join_info['arguments']), array($random_name_1, $random_name_2), 'Make sure the arguments are in the right order');
+ $this->assertEqual(array_values($join_info['arguments']), [$random_name_1, $random_name_2], 'Make sure the arguments are in the right order');
// Test that 'IN' conditions are properly built.
$random_name_1 = $this->randomMachineName();
$random_name_2 = $this->randomMachineName();
$random_name_3 = $this->randomMachineName();
$random_name_4 = $this->randomMachineName();
- $configuration['extra'] = array(
- array(
+ $configuration['extra'] = [
+ [
'field' => 'name',
'value' => $random_name_1
- ),
- array(
+ ],
+ [
'field' => 'name',
- 'value' => array($random_name_2, $random_name_3, $random_name_4),
- ),
- );
+ 'value' => [$random_name_2, $random_name_3, $random_name_4],
+ ],
+ ];
$join = $this->manager->createInstance('standard', $configuration);
- $table = array('alias' => 'users4');
+ $table = ['alias' => 'users4'];
$join->buildJoin($query, $table, $view->query);
$tables = $query->getTables();
@@ -173,26 +173,26 @@ class JoinTest extends RelationshipJoinTestBase {
$this->assertTrue(strpos($join_info['condition'], "views_test_data.uid = users4.uid") !== FALSE, 'Make sure the join condition appears in the query.');
$this->assertTrue(strpos($join_info['condition'], "users4.name = :views_join_condition_2") !== FALSE, 'Make sure the first extra join condition appears in the query.');
$this->assertTrue(strpos($join_info['condition'], "users4.name IN ( :views_join_condition_3[] )") !== FALSE, 'The IN condition for the join is properly formed.');
- $this->assertEqual($join_info['arguments'][':views_join_condition_3[]'], array($random_name_2, $random_name_3, $random_name_4), 'Make sure the IN arguments are still part of an array.');
+ $this->assertEqual($join_info['arguments'][':views_join_condition_3[]'], [$random_name_2, $random_name_3, $random_name_4], 'Make sure the IN arguments are still part of an array.');
// Test that all the conditions are properly built.
- $configuration['extra'] = array(
- array(
+ $configuration['extra'] = [
+ [
'field' => 'langcode',
'value' => 'en'
- ),
- array(
+ ],
+ [
'left_field' => 'status',
'value' => 0,
'numeric' => TRUE,
- ),
- array(
+ ],
+ [
'field' => 'name',
'left_field' => 'name'
- ),
- );
+ ],
+ ];
$join = $this->manager->createInstance('standard', $configuration);
- $table = array('alias' => 'users5');
+ $table = ['alias' => 'users5'];
$join->buildJoin($query, $table, $view->query);
$tables = $query->getTables();
@@ -201,7 +201,7 @@ class JoinTest extends RelationshipJoinTestBase {
$this->assertTrue(strpos($join_info['condition'], "users5.langcode = :views_join_condition_4") !== FALSE, 'Make sure the first extra join condition appears in the query.');
$this->assertTrue(strpos($join_info['condition'], "views_test_data.status = :views_join_condition_5") !== FALSE, 'Make sure the second extra join condition appears in the query.');
$this->assertTrue(strpos($join_info['condition'], "users5.name = views_test_data.name") !== FALSE, 'Make sure the third extra join condition appears in the query.');
- $this->assertEqual(array_values($join_info['arguments']), array('en', 0), 'Make sure the arguments are in the right order');
+ $this->assertEqual(array_values($join_info['arguments']), ['en', 0], 'Make sure the arguments are in the right order');
}
}
diff --git a/core/modules/views/tests/src/Kernel/Plugin/QueryTest.php b/core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
index 2422deda3e8..02548b25c90 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
@@ -18,7 +18,7 @@ class QueryTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
protected function viewsData() {
$data = parent::viewsData();
diff --git a/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php b/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php
index cf604f93596..1163297b1bd 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php
@@ -18,7 +18,7 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field');
+ public static $modules = ['system', 'user', 'field'];
/**
* @var \Drupal\user\Entity\User
@@ -30,7 +30,7 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
*/
protected function setUpFixtures() {
$this->installEntitySchema('user');
- $this->installConfig(array('user'));
+ $this->installConfig(['user']);
parent::setUpFixtures();
// Create a record for uid 1.
@@ -48,13 +48,13 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
- $schema['views_test_data']['fields']['uid'] = array(
+ $schema['views_test_data']['fields']['uid'] = [
'description' => "The {users_field_data}.uid of the author of the beatle entry.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0
- );
+ ];
return $schema;
}
@@ -66,15 +66,15 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
*/
protected function viewsData() {
$data = parent::viewsData();
- $data['views_test_data']['uid'] = array(
+ $data['views_test_data']['uid'] = [
'title' => t('UID'),
'help' => t('The test data UID'),
- 'relationship' => array(
+ 'relationship' => [
'id' => 'standard',
'base' => 'users_field_data',
'base field' => 'uid'
- )
- );
+ ]
+ ];
return $data;
}
diff --git a/core/modules/views/tests/src/Kernel/Plugin/RelationshipTest.php b/core/modules/views/tests/src/Kernel/Plugin/RelationshipTest.php
index 846da660d1c..802befe1ca7 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/RelationshipTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/RelationshipTest.php
@@ -19,17 +19,17 @@ class RelationshipTest extends RelationshipJoinTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Maps between the key in the expected result and the query result.
*
* @var array
*/
- protected $columnMap = array(
+ protected $columnMap = [
'views_test_data_name' => 'name',
'users_field_data_views_test_data_uid' => 'uid',
- );
+ ];
/**
* Tests the query result of a view with a relationship.
@@ -42,53 +42,53 @@ class RelationshipTest extends RelationshipJoinTestBase {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('relationships', array(
- 'uid' => array(
+ $view->displayHandlers->get('default')->overrideOption('relationships', [
+ 'uid' => [
'id' => 'uid',
'table' => 'views_test_data',
'field' => 'uid',
- ),
- ));
+ ],
+ ]);
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'uid' => array(
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'uid' => [
'id' => 'uid',
'table' => 'users_field_data',
'field' => 'uid',
'relationship' => 'uid',
- ),
- ));
+ ],
+ ]);
$fields = $view->displayHandlers->get('default')->getOption('fields');
- $view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
- 'uid' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', $fields + [
+ 'uid' => [
'id' => 'uid',
'table' => 'users_field_data',
'field' => 'uid',
'relationship' => 'uid',
- ),
- ));
+ ],
+ ]);
$view->initHandlers();
// Check for all beatles created by admin.
- $view->filter['uid']->value = array(1);
+ $view->filter['uid']->value = [1];
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'name' => 'John',
'uid' => 1
- )
- );
+ ]
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
// Check for all beatles created by another user, which so doesn't exist.
$view->initHandlers();
- $view->filter['uid']->value = array(3);
+ $view->filter['uid']->value = [3];
$this->executeView($view);
- $expected_result = array();
+ $expected_result = [];
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
@@ -98,12 +98,12 @@ class RelationshipTest extends RelationshipJoinTestBase {
$view->relationship['uid']->options['required'] = TRUE;
$this->executeView($view);
- $expected_result = array(
- array(
+ $expected_result = [
+ [
'name' => 'John',
'uid' => 1
- )
- );
+ ]
+ ];
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
diff --git a/core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php b/core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php
index 8d2d86632a6..b4ac0be838a 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php
@@ -28,7 +28,7 @@ class RowEntityTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_entity_row');
+ public static $testViews = ['test_entity_row'];
/**
* {@inheritdoc}
@@ -37,7 +37,7 @@ class RowEntityTest extends ViewsKernelTestBase {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
- $this->installConfig(array('taxonomy'));
+ $this->installConfig(['taxonomy']);
\Drupal::service('router.builder')->rebuild();
}
@@ -57,7 +57,7 @@ class RowEntityTest extends ViewsKernelTestBase {
$this->assertText($term->getName(), 'The rendered entity appears as row in the view.');
// Tests the available view mode options.
- $form = array();
+ $form = [];
$form_state = new FormState();
$form_state->set('view', $view->storage);
$view->rowPlugin->buildOptionsForm($form, $form_state);
diff --git a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php
index ac85c77a969..223963e2d05 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php
@@ -24,14 +24,14 @@ class RowRenderCacheTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('user', 'node');
+ public static $modules = ['user', 'node'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_row_render_cache', 'test_row_render_cache_none');
+ public static $testViews = ['test_row_render_cache', 'test_row_render_cache_none'];
/**
* An editor user account.
diff --git a/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php b/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php
index ca7ba5bc7cb..6846f776304 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php
@@ -18,7 +18,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* {@inheritdoc}
@@ -26,7 +26,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
protected function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['table']['base']['access query tag'] = 'test_tag';
- $data['views_test_data']['table']['base']['query metadata'] = array('key1' => 'test_metadata', 'key2' => 'test_metadata2');
+ $data['views_test_data']['table']['base']['query metadata'] = ['key1' => 'test_metadata', 'key2' => 'test_metadata2'];
return $data;
}
@@ -45,7 +45,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
/** @var \Drupal\Core\Database\Query\Select $count_query */
$count_query = $view->build_info['count_query'];
- foreach (array($main_query, $count_query) as $query) {
+ foreach ([$main_query, $count_query] as $query) {
// Check query access tags.
$this->assertTrue($query->hasTag('test_tag'));
@@ -69,7 +69,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
/** @var \Drupal\Core\Database\Query\Select $count_query */
$count_query = $view->build_info['count_query'];
- foreach (array($main_query, $count_query) as $query) {
+ foreach ([$main_query, $count_query] as $query) {
// Check query access tags.
$this->assertFalse($query->hasTag('test_tag'));
diff --git a/core/modules/views/tests/src/Kernel/Plugin/StyleHtmlListTest.php b/core/modules/views/tests/src/Kernel/Plugin/StyleHtmlListTest.php
index f1f1fb1a62c..717403dacc6 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/StyleHtmlListTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/StyleHtmlListTest.php
@@ -18,7 +18,7 @@ class StyleHtmlListTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_style_html_list');
+ public static $testViews = ['test_style_html_list'];
/**
* Make sure that the HTML list style markup is correct.
diff --git a/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php b/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php
index 1cb44000ff2..d0683deb47a 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php
@@ -11,14 +11,14 @@ use Drupal\views\Views;
*/
class StyleMappingTest extends StyleTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_style_mapping');
+ public static $testViews = ['test_style_mapping'];
/**
* Verifies that the fields were mapped correctly.
@@ -68,7 +68,7 @@ class StyleMappingTest extends StyleTestBase {
// separated by ':'.
$expected_result = $name . ':' . $data_set[$count][$field_id];
$actual_result = (string) $field;
- $this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id)));
+ $this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', ['%name' => $name, '%field_id' => $field_id]));
}
$count++;
diff --git a/core/modules/views/tests/src/Kernel/Plugin/StyleTableUnitTest.php b/core/modules/views/tests/src/Kernel/Plugin/StyleTableUnitTest.php
index f7ede520d6a..365b0c78e8b 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/StyleTableUnitTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/StyleTableUnitTest.php
@@ -19,7 +19,7 @@ class StyleTableUnitTest extends PluginKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_table');
+ public static $testViews = ['test_table'];
/**
* Tests the table style.
@@ -101,7 +101,7 @@ class StyleTableUnitTest extends PluginKernelTestBase {
$view->destroy();
// Use a existing field, and sort both ascending and descending.
- foreach (array('asc', 'desc') as $order) {
+ foreach (['asc', 'desc'] as $order) {
$this->prepareView($view);
$style_plugin = $view->style_plugin;
$request->query->set('sort', $order);
@@ -133,7 +133,7 @@ class StyleTableUnitTest extends PluginKernelTestBase {
// Render an empty result, and ensure that the area handler is rendered.
$view->setDisplay('default');
$view->executed = TRUE;
- $view->result = array();
+ $view->result = [];
$output = $view->preview();
$output = \Drupal::service('renderer')->renderRoot($output);
diff --git a/core/modules/views/tests/src/Kernel/Plugin/StyleUnformattedTest.php b/core/modules/views/tests/src/Kernel/Plugin/StyleUnformattedTest.php
index 14e5895514e..f1b254cf7e6 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/StyleUnformattedTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/StyleUnformattedTest.php
@@ -16,7 +16,7 @@ class StyleUnformattedTest extends StyleTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Make sure that the default css classes works as expected.
diff --git a/core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php b/core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php
index d06ae66ba2a..879f6d44d54 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/ViewsBlockTest.php
@@ -19,14 +19,14 @@ class ViewsBlockTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test_views');
+ public static $modules = ['block', 'block_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view_block');
+ public static $testViews = ['test_view_block'];
/**
* {@inheritdoc}
@@ -34,7 +34,7 @@ class ViewsBlockTest extends ViewsKernelTestBase {
protected function setUp($import_test_views = TRUE) {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('block_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['block_test_views']);
}
/**
@@ -43,11 +43,11 @@ class ViewsBlockTest extends ViewsKernelTestBase {
* @see \Drupal\views\Plugin\Block::getmachineNameSuggestion()
*/
public function testMachineNameSuggestion() {
- $plugin_definition = array(
+ $plugin_definition = [
'provider' => 'views',
- );
+ ];
$plugin_id = 'views_block:test_view_block-block_1';
- $views_block = ViewsBlock::create($this->container, array(), $plugin_id, $plugin_definition);
+ $views_block = ViewsBlock::create($this->container, [], $plugin_id, $plugin_definition);
$this->assertEqual($views_block->getMachineNameSuggestion(), 'views_block__test_view_block_block_1');
}
@@ -96,8 +96,8 @@ class ViewsBlockTest extends ViewsKernelTestBase {
$view->setDisplay();
// Add a fixed argument that sets a title and save the view.
- $view->displayHandlers->get('default')->overrideOption('arguments', array(
- 'name' => array(
+ $view->displayHandlers->get('default')->overrideOption('arguments', [
+ 'name' => [
'default_action' => 'default',
'title_enable' => TRUE,
'title' => 'Overridden title',
@@ -105,16 +105,16 @@ class ViewsBlockTest extends ViewsKernelTestBase {
'default_argument_options' => [
'argument' => 'fixed'
],
- 'validate' => array(
+ 'validate' => [
'type' => 'none',
'fail' => 'not found',
- ),
+ ],
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'plugin_id' => 'string',
- )
- ));
+ ]
+ ]);
$view->save();
$plugin_definition = [
diff --git a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php
index f5c61ee3e84..b120400604f 100644
--- a/core/modules/views/tests/src/Kernel/PluginInstanceTest.php
+++ b/core/modules/views/tests/src/Kernel/PluginInstanceTest.php
@@ -16,7 +16,7 @@ class PluginInstanceTest extends ViewsKernelTestBase {
*
* @var array
*/
- protected $pluginTypes = array(
+ protected $pluginTypes = [
'access',
'area',
'argument',
@@ -36,7 +36,7 @@ class PluginInstanceTest extends ViewsKernelTestBase {
'sort',
'style',
'wizard',
- );
+ ];
/**
* An array of plugin definitions, keyed by plugin type.
@@ -60,8 +60,8 @@ class PluginInstanceTest extends ViewsKernelTestBase {
// Check all plugin types.
foreach ($this->pluginTypes as $type) {
- $this->assertTrue(array_key_exists($type, $this->definitions), format_string('Key for plugin type @type found.', array('@type' => $type)));
- $this->assertTrue(is_array($this->definitions[$type]) && !empty($this->definitions[$type]), format_string('Plugin type @type has an array of plugins.', array('@type' => $type)));
+ $this->assertTrue(array_key_exists($type, $this->definitions), format_string('Key for plugin type @type found.', ['@type' => $type]));
+ $this->assertTrue(is_array($this->definitions[$type]) && !empty($this->definitions[$type]), format_string('Plugin type @type has an array of plugins.', ['@type' => $type]));
}
// Tests that the plugin list has not missed any types.
@@ -87,7 +87,7 @@ class PluginInstanceTest extends ViewsKernelTestBase {
// good to check they can be created but for throwing any notices for
// method signatures etc. too.
$instance = $manager->createInstance($id);
- $this->assertTrue($instance instanceof $definition['class'], format_string('Instance of @type:@id created', array('@type' => $type, '@id' => $id)));
+ $this->assertTrue($instance instanceof $definition['class'], format_string('Instance of @type:@id created', ['@type' => $type, '@id' => $id]));
}
}
}
diff --git a/core/modules/views/tests/src/Kernel/QueryGroupByTest.php b/core/modules/views/tests/src/Kernel/QueryGroupByTest.php
index 594bd6251b6..e4a088459fe 100644
--- a/core/modules/views/tests/src/Kernel/QueryGroupByTest.php
+++ b/core/modules/views/tests/src/Kernel/QueryGroupByTest.php
@@ -20,14 +20,14 @@ class QueryGroupByTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle');
+ public static $testViews = ['test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('entity_test', 'system', 'field', 'user', 'language');
+ public static $modules = ['entity_test', 'system', 'field', 'user', 'language'];
/**
* The storage for the test entity type.
@@ -63,7 +63,7 @@ class QueryGroupByTest extends ViewsKernelTestBase {
$this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
- $types = array();
+ $types = [];
foreach ($view->result as $item) {
// num_records is a alias for id.
$types[$item->entity_test_name] = $item->num_records;
@@ -101,12 +101,12 @@ class QueryGroupByTest extends ViewsKernelTestBase {
$this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
// Group by name to identify the right count.
- $results = array();
+ $results = [];
foreach ($view->result as $item) {
$results[$item->entity_test_name] = $item->id;
}
- $this->assertEqual($results['name1'], $values[0], format_string('Aggregation with @aggregation_function and groupby name: name1 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
- $this->assertEqual($results['name2'], $values[1], format_string('Aggregation with @aggregation_function and groupby name: name2 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
+ $this->assertEqual($results['name1'], $values[0], format_string('Aggregation with @aggregation_function and groupby name: name1 returned the expected amount of results', ['@aggregation_function' => $aggregation_function]));
+ $this->assertEqual($results['name2'], $values[1], format_string('Aggregation with @aggregation_function and groupby name: name2 returned the expected amount of results', ['@aggregation_function' => $aggregation_function]));
}
/**
@@ -114,18 +114,18 @@ class QueryGroupByTest extends ViewsKernelTestBase {
*/
protected function setupTestEntities() {
// Create 4 entities with name1 and 3 entities with name2.
- $entity_1 = array(
+ $entity_1 = [
'name' => 'name1',
- );
+ ];
$this->storage->create($entity_1)->save();
$this->storage->create($entity_1)->save();
$this->storage->create($entity_1)->save();
$this->storage->create($entity_1)->save();
- $entity_2 = array(
+ $entity_2 = [
'name' => 'name2',
- );
+ ];
$this->storage->create($entity_2)->save();
$this->storage->create($entity_2)->save();
$this->storage->create($entity_2)->save();
@@ -135,42 +135,42 @@ class QueryGroupByTest extends ViewsKernelTestBase {
* Tests the count aggregation function.
*/
public function testGroupByCount() {
- $this->groupByTestHelper('count', array(4, 3));
+ $this->groupByTestHelper('count', [4, 3]);
}
/**
* Tests the sum aggregation function.
*/
public function testGroupBySum() {
- $this->groupByTestHelper('sum', array(10, 18));
+ $this->groupByTestHelper('sum', [10, 18]);
}
/**
* Tests the average aggregation function.
*/
public function testGroupByAverage() {
- $this->groupByTestHelper('avg', array(2.5, 6));
+ $this->groupByTestHelper('avg', [2.5, 6]);
}
/**
* Tests the min aggregation function.
*/
public function testGroupByMin() {
- $this->groupByTestHelper('min', array(1, 5));
+ $this->groupByTestHelper('min', [1, 5]);
}
/**
* Tests the max aggregation function.
*/
public function testGroupByMax() {
- $this->groupByTestHelper('max', array(4, 7));
+ $this->groupByTestHelper('max', [4, 7]);
}
/**
* Tests aggregation with no specific function.
*/
public function testGroupByNone() {
- $this->groupByTestHelper(NULL, array(1, 5));
+ $this->groupByTestHelper(NULL, [1, 5]);
}
/**
@@ -181,7 +181,7 @@ class QueryGroupByTest extends ViewsKernelTestBase {
// doesn't display SUM, COUNT, MAX, etc. functions in SELECT statement.
for ($x = 0; $x < 10; $x++) {
- $this->storage->create(array('name' => 'name1'))->save();
+ $this->storage->create(['name' => 'name1'])->save();
}
$view = Views::getView('test_group_by_in_filters');
diff --git a/core/modules/views/tests/src/Kernel/TestViewsTest.php b/core/modules/views/tests/src/Kernel/TestViewsTest.php
index 79d88190965..f9aa6734210 100644
--- a/core/modules/views/tests/src/Kernel/TestViewsTest.php
+++ b/core/modules/views/tests/src/Kernel/TestViewsTest.php
@@ -22,7 +22,7 @@ class TestViewsTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('views_test_data');
+ public static $modules = ['views_test_data'];
/**
* Tests default configuration data type.
diff --git a/core/modules/views/tests/src/Kernel/TokenReplaceTest.php b/core/modules/views/tests/src/Kernel/TokenReplaceTest.php
index 160f4e25e2b..41f2cf07afd 100644
--- a/core/modules/views/tests/src/Kernel/TokenReplaceTest.php
+++ b/core/modules/views/tests/src/Kernel/TokenReplaceTest.php
@@ -12,14 +12,14 @@ use Drupal\views\Views;
*/
class TokenReplaceTest extends ViewsKernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_tokens', 'test_invalid_tokens');
+ public static $testViews = ['test_tokens', 'test_invalid_tokens'];
protected function setUp($import_test_views = TRUE) {
parent::setUp();
@@ -37,7 +37,7 @@ class TokenReplaceTest extends ViewsKernelTestBase {
$view->display_handler->getPlugin('pager')->setItemsPerPage(4);
$this->executeView($view);
- $expected = array(
+ $expected = [
'[view:label]' => 'Test tokens',
'[view:description]' => 'Test view to token replacement tests.',
'[view:id]' => 'test_tokens',
@@ -49,7 +49,7 @@ class TokenReplaceTest extends ViewsKernelTestBase {
'[view:items-per-page]' => '4',
'[view:current-page]' => '1',
'[view:page-count]' => '2',
- );
+ ];
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($view->storage);
$metadata_tests = [];
@@ -67,8 +67,8 @@ class TokenReplaceTest extends ViewsKernelTestBase {
foreach ($expected as $token => $expected_output) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $token_handler->replace($token, array('view' => $view), [], $bubbleable_metadata);
- $this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', array('%token' => $token)));
+ $output = $token_handler->replace($token, ['view' => $view], [], $bubbleable_metadata);
+ $this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', ['%token' => $token]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$token]);
}
}
@@ -84,7 +84,7 @@ class TokenReplaceTest extends ViewsKernelTestBase {
$this->assertSame(TRUE, $view->get_total_rows, 'The query was set to calculate the total number of rows.');
- $expected = array(
+ $expected = [
'[view:label]' => 'Test tokens',
'[view:description]' => 'Test view to token replacement tests.',
'[view:id]' => 'test_tokens',
@@ -98,13 +98,13 @@ class TokenReplaceTest extends ViewsKernelTestBase {
'[view:items-per-page]' => '2',
'[view:current-page]' => '1',
'[view:page-count]' => '3',
- );
+ ];
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($view->storage);
foreach ($expected as $token => $expected_output) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $token_handler->replace($token, array('view' => $view), [], $bubbleable_metadata);
+ $output = $token_handler->replace($token, ['view' => $view], [], $bubbleable_metadata);
$this->assertSame($expected_output, $output, sprintf('Token %s replaced correctly.', $token));
$this->assertEquals($base_bubbleable_metadata, $bubbleable_metadata);
}
@@ -119,13 +119,13 @@ class TokenReplaceTest extends ViewsKernelTestBase {
$view->setDisplay('page_2');
$this->executeView($view);
- $expected = array(
+ $expected = [
'[view:page-count]' => '1',
- );
+ ];
foreach ($expected as $token => $expected_output) {
- $output = $token_handler->replace($token, array('view' => $view));
- $this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', array('%token' => $token)));
+ $output = $token_handler->replace($token, ['view' => $view]);
+ $this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', ['%token' => $token]));
}
}
@@ -138,13 +138,13 @@ class TokenReplaceTest extends ViewsKernelTestBase {
$view->setDisplay('block_1');
$this->executeView($view);
- $expected = array(
+ $expected = [
'[view:url]' => '',
- );
+ ];
foreach ($expected as $token => $expected_output) {
- $output = $token_handler->replace($token, array('view' => $view));
- $this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', array('%token' => $token)));
+ $output = $token_handler->replace($token, ['view' => $view]);
+ $this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', ['%token' => $token]));
}
}
diff --git a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
index 01057b47655..f843892e5da 100644
--- a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
+++ b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
@@ -38,14 +38,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_destroy', 'test_executable_displays');
+ public static $testViews = ['test_destroy', 'test_executable_displays'];
/**
* Properties that should be stored in the configuration.
*
* @var array
*/
- protected $configProperties = array(
+ protected $configProperties = [
'disabled',
'name',
'description',
@@ -54,14 +54,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
'label',
'core',
'display',
- );
+ ];
/**
* Properties that should be stored in the executable.
*
* @var array
*/
- protected $executableProperties = array(
+ protected $executableProperties = [
'storage',
'built',
'executed',
@@ -74,14 +74,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
'exposed_raw_input',
'old_view',
'parent_views',
- );
+ ];
protected function setUpFixtures() {
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installEntitySchema('comment');
- $this->installSchema('comment', array('comment_entity_statistics'));
- $this->installConfig(array('system', 'field', 'node', 'comment'));
+ $this->installSchema('comment', ['comment_entity_statistics']);
+ $this->installConfig(['system', 'field', 'node', 'comment']);
NodeType::create([
'type' => 'page',
@@ -90,7 +90,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
$this->addDefaultCommentField('node', 'page');
parent::setUpFixtures();
- $this->installConfig(array('filter'));
+ $this->installConfig(['filter']);
}
/**
@@ -123,7 +123,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
if ($type == 'relationship') {
continue;
}
- $this->assertTrue(count($view->$type), format_string('Make sure a %type instance got instantiated.', array('%type' => $type)));
+ $this->assertTrue(count($view->$type), format_string('Make sure a %type instance got instantiated.', ['%type' => $type]));
}
// initHandlers() should create display handlers automatically as well.
@@ -256,7 +256,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
$this->assertTrue($view->rowPlugin instanceof Fields);
// Test the newDisplay() method.
- $view = $this->container->get('entity.manager')->getStorage('view')->create(array('id' => 'test_executable_displays'));
+ $view = $this->container->get('entity.manager')->getStorage('view')->create(['id' => 'test_executable_displays']);
$executable = $view->getExecutable();
$executable->newDisplay('page');
@@ -289,10 +289,10 @@ class ViewExecutableTest extends ViewsKernelTestBase {
$this->assertNull($view->usePager());
// Add a pager, initialize, and test.
- $view->displayHandlers->get('default')->overrideOption('pager', array(
+ $view->displayHandlers->get('default')->overrideOption('pager', [
'type' => 'full',
- 'options' => array('items_per_page' => 10),
- ));
+ 'options' => ['items_per_page' => 10],
+ ]);
$view->initPager();
$this->assertTrue($view->usePager());
@@ -302,10 +302,10 @@ class ViewExecutableTest extends ViewsKernelTestBase {
$this->assertEqual($view->getOffset(), $rand);
// Test the getBaseTable() method.
- $expected = array(
+ $expected = [
'views_test_data' => TRUE,
'#global' => TRUE,
- );
+ ];
$this->assertIdentical($view->getBaseTables(), $expected);
// Test response methods.
@@ -386,7 +386,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
*/
public function testGetHandlerTypes() {
$types = ViewExecutable::getHandlerTypes();
- foreach (array('field', 'filter', 'argument', 'sort', 'header', 'footer', 'empty') as $type) {
+ foreach (['field', 'filter', 'argument', 'sort', 'header', 'footer', 'empty'] as $type) {
$this->assertTrue(isset($types[$type]));
// @todo The key on the display should be footers, headers and empties
// or something similar instead of the singular, but so long check for
@@ -430,7 +430,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
$match = function($value) use ($display) {
return strpos($value, $display->display['display_title']) !== FALSE;
};
- $this->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', array('@id' => $id)));
+ $this->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', ['@id' => $id]));
$count++;
}
diff --git a/core/modules/views/tests/src/Kernel/ViewStorageTest.php b/core/modules/views/tests/src/Kernel/ViewStorageTest.php
index fa264bd731f..29f19963446 100644
--- a/core/modules/views/tests/src/Kernel/ViewStorageTest.php
+++ b/core/modules/views/tests/src/Kernel/ViewStorageTest.php
@@ -21,7 +21,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
*
* @var array
*/
- protected $configProperties = array(
+ protected $configProperties = [
'status',
'module',
'id',
@@ -31,7 +31,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
'label',
'core',
'display',
- );
+ ];
/**
* The entity type definition.
@@ -52,7 +52,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view_storage');
+ public static $testViews = ['test_view_storage'];
/**
* Tests CRUD operations.
@@ -85,11 +85,11 @@ class ViewStorageTest extends ViewsKernelTestBase {
// expected properties.
$this->assertTrue($view instanceof View, 'Single View instance loaded.');
foreach ($this->configProperties as $property) {
- $this->assertTrue($view->get($property) !== NULL, format_string('Property: @property loaded onto View.', array('@property' => $property)));
+ $this->assertTrue($view->get($property) !== NULL, format_string('Property: @property loaded onto View.', ['@property' => $property]));
}
// Check the displays have been loaded correctly from config display data.
- $expected_displays = array('default', 'block_1', 'page_1');
+ $expected_displays = ['default', 'block_1', 'page_1'];
$this->assertEqual(array_keys($view->get('display')), $expected_displays, 'The correct display names are present.');
// Check each ViewDisplay object and confirm that it has the correct key and
@@ -101,7 +101,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
// exists.
$original_options = $data['display'][$key];
foreach ($original_options as $orig_key => $value) {
- $this->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', array('@key' => $key)));
+ $this->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', ['@key' => $key]));
}
}
@@ -115,12 +115,12 @@ class ViewStorageTest extends ViewsKernelTestBase {
*/
protected function createTests() {
// Create a new View instance with empty values.
- $created = $this->controller->create(array());
+ $created = $this->controller->create([]);
$this->assertTrue($created instanceof View, 'Created object is a View.');
// Check that the View contains all of the properties.
foreach ($this->configProperties as $property) {
- $this->assertTrue(property_exists($created, $property), format_string('Property: @property created on View.', array('@property' => $property)));
+ $this->assertTrue(property_exists($created, $property), format_string('Property: @property created on View.', ['@property' => $property]));
}
// Create a new View instance with config values.
@@ -137,8 +137,8 @@ class ViewStorageTest extends ViewsKernelTestBase {
// Test all properties except displays.
foreach ($properties as $property) {
- $this->assertTrue($created->get($property) !== NULL, format_string('Property: @property created on View.', array('@property' => $property)));
- $this->assertIdentical($values[$property], $created->get($property), format_string('Property value: @property matches configuration value.', array('@property' => $property)));
+ $this->assertTrue($created->get($property) !== NULL, format_string('Property: @property created on View.', ['@property' => $property]));
+ $this->assertIdentical($values[$property], $created->get($property), format_string('Property value: @property matches configuration value.', ['@property' => $property]));
}
// Check the UUID of the loaded View.
@@ -177,44 +177,44 @@ class ViewStorageTest extends ViewsKernelTestBase {
* Tests the display related functions like getDisplaysList().
*/
protected function displayMethodTests() {
- $config['display'] = array(
- 'page_1' => array(
- 'display_options' => array('path' => 'test'),
+ $config['display'] = [
+ 'page_1' => [
+ 'display_options' => ['path' => 'test'],
'display_plugin' => 'page',
'id' => 'page_2',
'display_title' => 'Page 1',
'position' => 1
- ),
- 'feed_1' => array(
- 'display_options' => array('path' => 'test.xml'),
+ ],
+ 'feed_1' => [
+ 'display_options' => ['path' => 'test.xml'],
'display_plugin' => 'feed',
'id' => 'feed',
'display_title' => 'Feed',
'position' => 2
- ),
- 'page_2' => array(
- 'display_options' => array('path' => 'test/%/extra'),
+ ],
+ 'page_2' => [
+ 'display_options' => ['path' => 'test/%/extra'],
'display_plugin' => 'page',
'id' => 'page_2',
'display_title' => 'Page 2',
'position' => 3
- )
- );
+ ]
+ ];
$view = $this->controller->create($config);
// Tests Drupal\views\Entity\View::addDisplay()
- $view = $this->controller->create(array());
+ $view = $this->controller->create([]);
$random_title = $this->randomMachineName();
$id = $view->addDisplay('page', $random_title);
- $this->assertEqual($id, 'page_1', format_string('Make sure the first display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_1')));
+ $this->assertEqual($id, 'page_1', format_string('Make sure the first display (%id_new) has the expected ID (%id)', ['%id_new' => $id, '%id' => 'page_1']));
$display = $view->get('display');
$this->assertEqual($display[$id]['display_title'], $random_title);
$random_title = $this->randomMachineName();
$id = $view->addDisplay('page', $random_title);
$display = $view->get('display');
- $this->assertEqual($id, 'page_2', format_string('Make sure the second display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_2')));
+ $this->assertEqual($id, 'page_2', format_string('Make sure the second display (%id_new) has the expected ID (%id)', ['%id_new' => $id, '%id' => 'page_2']));
$this->assertEqual($display[$id]['display_title'], $random_title);
$id = $view->addDisplay('page');
@@ -233,7 +233,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
// Tests Drupal\views\Entity\View::generateDisplayId(). Since
// generateDisplayId() is protected, we have to use reflection to unit-test
// it.
- $view = $this->controller->create(array());
+ $view = $this->controller->create([]);
$ref_generate_display_id = new \ReflectionMethod($view, 'generateDisplayId');
$ref_generate_display_id->setAccessible(TRUE);
$this->assertEqual(
@@ -254,38 +254,38 @@ class ViewStorageTest extends ViewsKernelTestBase {
);
// Tests item related methods().
- $view = $this->controller->create(array('base_table' => 'views_test_data'));
+ $view = $this->controller->create(['base_table' => 'views_test_data']);
$view->addDisplay('default');
$view = $view->getExecutable();
$display_id = 'default';
- $expected_items = array();
+ $expected_items = [];
// Tests addHandler with getItem.
// Therefore add one item without any options and one item with some
// options.
$id1 = $view->addHandler($display_id, 'field', 'views_test_data', 'id');
$item1 = $view->getHandler($display_id, 'field', 'id');
- $expected_items[$id1] = $expected_item = array(
+ $expected_items[$id1] = $expected_item = [
'id' => 'id',
'table' => 'views_test_data',
'field' => 'id',
'plugin_id' => 'numeric',
- );
+ ];
$this->assertEqual($item1, $expected_item);
- $options = array(
- 'alter' => array(
+ $options = [
+ 'alter' => [
'text' => $this->randomMachineName()
- )
- );
+ ]
+ ];
$id2 = $view->addHandler($display_id, 'field', 'views_test_data', 'name', $options);
$item2 = $view->getHandler($display_id, 'field', 'name');
- $expected_items[$id2] = $expected_item = array(
+ $expected_items[$id2] = $expected_item = [
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'plugin_id' => 'standard',
- ) + $options;
+ ] + $options;
$this->assertEqual($item2, $expected_item);
// Tests the expected fields from the previous additions.
@@ -293,11 +293,11 @@ class ViewStorageTest extends ViewsKernelTestBase {
// Alter an existing item via setItem and check the result via getItem
// and getItems.
- $item = array(
- 'alter' => array(
+ $item = [
+ 'alter' => [
'text' => $this->randomMachineName(),
- )
- ) + $item1;
+ ]
+ ] + $item1;
$expected_items[$id1] = $item;
$view->setHandler($display_id, 'field', $id1, $item);
$this->assertEqual($view->getHandler($display_id, 'field', 'id'), $item);
@@ -327,24 +327,24 @@ class ViewStorageTest extends ViewsKernelTestBase {
// Check the other properties.
// @todo Create a reusable property on the base test class for these?
- $config_properties = array(
+ $config_properties = [
'disabled',
'description',
'tag',
'base_table',
'label',
'core',
- );
+ ];
foreach ($config_properties as $property) {
- $this->assertIdentical($view->storage->get($property), $copy->get($property), format_string('@property property is identical.', array('@property' => $property)));
+ $this->assertIdentical($view->storage->get($property), $copy->get($property), format_string('@property property is identical.', ['@property' => $property]));
}
// Check the displays are the same.
$copy_display = $copy->get('display');
foreach ($view->storage->get('display') as $id => $display) {
// assertIdentical will not work here.
- $this->assertEqual($display, $copy_display[$id], format_string('The @display display has been copied correctly.', array('@display' => $id)));
+ $this->assertEqual($display, $copy_display[$id], format_string('The @display display has been copied correctly.', ['@display' => $id]));
}
}
diff --git a/core/modules/views/tests/src/Kernel/ViewsHooksTest.php b/core/modules/views/tests/src/Kernel/ViewsHooksTest.php
index e048454336a..612934e7322 100644
--- a/core/modules/views/tests/src/Kernel/ViewsHooksTest.php
+++ b/core/modules/views/tests/src/Kernel/ViewsHooksTest.php
@@ -19,14 +19,14 @@ class ViewsHooksTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* An array of available views hooks to test.
*
* @var array
*/
- protected static $hooks = array (
+ protected static $hooks = [
'views_data' => 'all',
'views_data_alter' => 'alter',
'views_query_substitutions' => 'view',
@@ -41,7 +41,7 @@ class ViewsHooksTest extends ViewsKernelTestBase {
'views_post_render' => 'view',
'views_query_alter' => 'view',
'views_invalidate_cache' => 'all',
- );
+ ];
/**
* The module handler to use for invoking hooks.
@@ -65,28 +65,28 @@ class ViewsHooksTest extends ViewsKernelTestBase {
// Test each hook is found in the implementations array and is invoked.
foreach (static::$hooks as $hook => $type) {
- $this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), format_string('The hook @hook was registered.', array('@hook' => $hook)));
+ $this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), format_string('The hook @hook was registered.', ['@hook' => $hook]));
if ($hook == 'views_post_render') {
- $this->moduleHandler->invoke('views_test_data', $hook, array($view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')));
+ $this->moduleHandler->invoke('views_test_data', $hook, [$view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')]);
continue;
}
switch ($type) {
case 'view':
- $this->moduleHandler->invoke('views_test_data', $hook, array($view));
+ $this->moduleHandler->invoke('views_test_data', $hook, [$view]);
break;
case 'alter':
- $data = array();
- $this->moduleHandler->invoke('views_test_data', $hook, array($data));
+ $data = [];
+ $this->moduleHandler->invoke('views_test_data', $hook, [$data]);
break;
default:
$this->moduleHandler->invoke('views_test_data', $hook);
}
- $this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), format_string('The %hook hook was invoked.', array('%hook' => $hook)));
+ $this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), format_string('The %hook hook was invoked.', ['%hook' => $hook]));
// Reset the module implementations cache, so we ensure that the
// .views.inc file is loaded actively.
$this->moduleHandler->resetImplementations();
diff --git a/core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php b/core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php
index 27f21c220ce..beb7b486d50 100644
--- a/core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php
+++ b/core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php
@@ -20,7 +20,7 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('language', 'system', 'user', 'views_ui');
+ public static $modules = ['language', 'system', 'user', 'views_ui'];
/**
* Contains thw wizard plugin manager.
@@ -32,9 +32,9 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
protected function setUp($import_test_views = TRUE) {
parent::setUp();
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
- $this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', array());
+ $this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', []);
}
/**
@@ -43,7 +43,7 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
* @see \Drupal\views\Plugin\views\wizard\WizardPluginBase
*/
public function testCreateView() {
- $form = array();
+ $form = [];
$form_state = new FormState();
$form = $this->wizard->buildForm($form, $form_state);
$random_id = strtolower($this->randomMachineName());
diff --git a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php
index d6b2a1e798d..5483ee47bb0 100644
--- a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php
+++ b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php
@@ -228,7 +228,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
list($view, $executable) = $this->setupValidMocks();
$executable->expects($this->once())
->method('preview')
- ->with('page_1', array('arg1', 'arg2'));
+ ->with('page_1', ['arg1', 'arg2']);
$response = $this->viewAjaxController->ajaxView($request);
$this->assertTrue($response instanceof ViewAjaxResponse);
@@ -249,7 +249,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
list($view, $executable) = $this->setupValidMocks();
$executable->expects($this->once())
->method('preview')
- ->with('page_1', $this->identicalTo(array('arg1', NULL)));
+ ->with('page_1', $this->identicalTo(['arg1', NULL]));
$response = $this->viewAjaxController->ajaxView($request);
$this->assertTrue($response instanceof ViewAjaxResponse);
@@ -317,14 +317,14 @@ class ViewAjaxControllerTest extends UnitTestCase {
->will($this->returnValue(TRUE));
$executable->expects($this->once())
->method('preview')
- ->will($this->returnValue(array('#markup' => 'View result')));
+ ->will($this->returnValue(['#markup' => 'View result']));
$this->executableFactory->expects($this->once())
->method('get')
->with($view)
->will($this->returnValue($executable));
- return array($view, $executable);
+ return [$view, $executable];
}
/**
diff --git a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
index 276fc5c0d8e..74bcc083e12 100644
--- a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
+++ b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php
@@ -92,7 +92,7 @@ class EntityViewsDataTest extends UnitTestCase {
$typed_data_manager->expects($this->any())
->method('getDefinition')
->with($this->equalTo('field_item:string_long'))
- ->willReturn(array('class' => '\Drupal\Core\Field\Plugin\Field\FieldType\StringLongItem'));
+ ->willReturn(['class' => '\Drupal\Core\Field\Plugin\Field\FieldType\StringLongItem']);
$this->baseEntityType = new TestEntityType([
'base_table' => 'entity_test',
@@ -147,16 +147,16 @@ class EntityViewsDataTest extends UnitTestCase {
->setLabel('Description')
->setDescription('A description of the term.')
->setTranslatable(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('view', TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
// Add a URL field; this example is from the Comment entity.
diff --git a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php
index f9d3add2329..c89554a77cd 100644
--- a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php
+++ b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php
@@ -68,16 +68,16 @@ class RouteSubscriberTest extends UnitTestCase {
$display_1->expects($this->once())
->method('collectRoutes')
- ->will($this->returnValue(array('test_id.page_1' => 'views.test_id.page_1')));
+ ->will($this->returnValue(['test_id.page_1' => 'views.test_id.page_1']));
$display_2->expects($this->once())
->method('collectRoutes')
- ->will($this->returnValue(array('test_id.page_2' => 'views.test_id.page_2')));
+ ->will($this->returnValue(['test_id.page_2' => 'views.test_id.page_2']));
$this->routeSubscriber->routes();
$this->state->expects($this->once())
->method('set')
- ->with('views.view_route_names', array('test_id.page_1' => 'views.test_id.page_1', 'test_id.page_2' => 'views.test_id.page_2'));
+ ->with('views.view_route_names', ['test_id.page_1' => 'views.test_id.page_1', 'test_id.page_2' => 'views.test_id.page_2']);
$this->routeSubscriber->routeRebuildFinished();
}
@@ -89,8 +89,8 @@ class RouteSubscriberTest extends UnitTestCase {
public function testOnAlterRoutes() {
$collection = new RouteCollection();
// The first route will be overridden later.
- $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\Tests\Core\Controller\TestController')));
- $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\Tests\Core\Controller\TestController'));
+ $collection->add('test_route', new Route('test_route', ['_controller' => 'Drupal\Tests\Core\Controller\TestController']));
+ $route_2 = new Route('test_route/example', ['_controller' => 'Drupal\Tests\Core\Controller\TestController']);
$collection->add('test_route_2', $route_2);
$route_event = new RouteBuildEvent($collection, 'views');
@@ -128,7 +128,7 @@ class RouteSubscriberTest extends UnitTestCase {
$this->state->expects($this->once())
->method('set')
- ->with('views.view_route_names', array('test_id.page_1' => 'test_route', 'test_id.page_2' => 'views.test_id.page_2'));
+ ->with('views.view_route_names', ['test_id.page_1' => 'test_route', 'test_id.page_2' => 'views.test_id.page_2']);
$collection = $route_event->getRouteCollection();
$this->assertEquals(['test_route', 'test_route_2', 'views.test_id.page_2'], array_keys($collection->all()));
@@ -163,11 +163,11 @@ class RouteSubscriberTest extends UnitTestCase {
$executable->expects($this->any())
->method('setDisplay')
- ->will($this->returnValueMap(array(
- array('page_1', TRUE),
- array('page_2', TRUE),
- array('page_3', FALSE),
- )));
+ ->will($this->returnValueMap([
+ ['page_1', TRUE],
+ ['page_2', TRUE],
+ ['page_3', FALSE],
+ ]));
// Ensure that only the first two displays are actually called.
$display_1 = $this->getMock('Drupal\views\Plugin\views\display\DisplayRouterInterface');
@@ -178,18 +178,18 @@ class RouteSubscriberTest extends UnitTestCase {
->getMock();
$display_collection->expects($this->any())
->method('get')
- ->will($this->returnValueMap(array(
- array('page_1', $display_1),
- array('page_2', $display_2),
- )));
+ ->will($this->returnValueMap([
+ ['page_1', $display_1],
+ ['page_2', $display_2],
+ ]));
$executable->displayHandlers = $display_collection;
- $this->routeSubscriber->applicableViews = array();
- $this->routeSubscriber->applicableViews[] = array('test_id', 'page_1');
- $this->routeSubscriber->applicableViews[] = array('test_id', 'page_2');
- $this->routeSubscriber->applicableViews[] = array('test_id', 'page_3');
+ $this->routeSubscriber->applicableViews = [];
+ $this->routeSubscriber->applicableViews[] = ['test_id', 'page_1'];
+ $this->routeSubscriber->applicableViews[] = ['test_id', 'page_2'];
+ $this->routeSubscriber->applicableViews[] = ['test_id', 'page_3'];
- return array($display_1, $display_2);
+ return [$display_1, $display_2];
}
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
index b269f9b2927..cbe6adef86b 100644
--- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
@@ -62,7 +62,7 @@ class ViewsBlockTest extends UnitTestCase {
$condition_plugin_manager = $this->getMock('Drupal\Core\Executable\ExecutableManagerInterface');
$condition_plugin_manager->expects($this->any())
->method('getDefinitions')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$container = new ContainerBuilder();
$container->set('plugin.manager.condition', $condition_plugin_manager);
\Drupal::setContainer($container);
@@ -136,15 +136,15 @@ class ViewsBlockTest extends UnitTestCase {
*/
public function testBuild() {
$output = $this->randomMachineName(100);
- $build = array('view_build' => $output, '#view_id' => 'test_view', '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', '#view_display_show_admin_links' => FALSE, '#view_display_plugin_id' => 'block', '#pre_rendered' => TRUE);
+ $build = ['view_build' => $output, '#view_id' => 'test_view', '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', '#view_display_show_admin_links' => FALSE, '#view_display_plugin_id' => 'block', '#pre_rendered' => TRUE];
$this->executable->expects($this->once())
->method('buildRenderable')
->with('block_1', [])
->willReturn($build);
$block_id = 'views_block:test_view-block_1';
- $config = array();
- $definition = array();
+ $config = [];
+ $definition = [];
$definition['provider'] = 'views';
$plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account);
@@ -187,13 +187,13 @@ class ViewsBlockTest extends UnitTestCase {
->willReturn($output);
$block_id = 'views_block:test_view-block_1';
- $config = array();
- $definition = array();
+ $config = [];
+ $definition = [];
$definition['provider'] = 'views';
$plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account);
- $this->assertEquals(array(), $plugin->build());
+ $this->assertEquals([], $plugin->build());
}
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php b/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php
index af9a683f0b5..7ecf9ef0417 100644
--- a/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php
@@ -37,10 +37,10 @@ class ViewsLocalTaskTest extends UnitTestCase {
*/
protected $viewStorage;
- protected $baseDefinition = array(
+ protected $baseDefinition = [
'class' => '\Drupal\views\Plugin\Menu\LocalTask\ViewsLocalTask',
'deriver' => '\Drupal\views\Plugin\Derivative\ViewsLocalTask'
- );
+ ];
/**
* The tested local task derivative class.
@@ -63,11 +63,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
* @see \Drupal\views\Plugin\Derivative\ViewsLocalTask::getDerivativeDefinitions()
*/
public function testGetDerivativeDefinitionsWithoutHookMenuViews() {
- $result = array();
+ $result = [];
$this->localTaskDerivative->setApplicableMenuViews($result);
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
- $this->assertEquals(array(), $definitions);
+ $this->assertEquals([], $definitions);
}
/**
@@ -78,13 +78,13 @@ class ViewsLocalTaskTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
- ->setMethods(array('getOption'))
+ ->setMethods(['getOption'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$display_plugin->expects($this->once())
->method('getOption')
->with('menu')
- ->will($this->returnValue(array('type' => 'normal')));
+ ->will($this->returnValue(['type' => 'normal']));
$executable->display_handler = $display_plugin;
$storage = $this->getMockBuilder('Drupal\views\Entity\View')
@@ -106,7 +106,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$this->localTaskDerivative->setApplicableMenuViews($result);
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
- $this->assertEquals(array(), $definitions);
+ $this->assertEquals([], $definitions);
}
/**
@@ -133,20 +133,20 @@ class ViewsLocalTaskTest extends UnitTestCase {
->willReturn($storage);
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
- ->setMethods(array('getOption'))
+ ->setMethods(['getOption'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$display_plugin->expects($this->once())
->method('getOption')
->with('menu')
- ->will($this->returnValue(array('type' => 'tab', 'weight' => 12, 'title' => 'Example title')));
+ ->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
$executable->display_handler = $display_plugin;
$result = [['example_view', 'page_1']];
$this->localTaskDerivative->setApplicableMenuViews($result);
// Mock the view route names state.
- $view_route_names = array();
+ $view_route_names = [];
$view_route_names['example_view.page_1'] = 'view.example_view.page_1';
$this->state->expects($this->once())
->method('get')
@@ -186,20 +186,20 @@ class ViewsLocalTaskTest extends UnitTestCase {
->willReturn($storage);
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
- ->setMethods(array('getOption'))
+ ->setMethods(['getOption'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$display_plugin->expects($this->once())
->method('getOption')
->with('menu')
- ->will($this->returnValue(array('type' => 'tab', 'weight' => 12)));
+ ->will($this->returnValue(['type' => 'tab', 'weight' => 12]));
$executable->display_handler = $display_plugin;
$result = [['example_view', 'page_1']];
$this->localTaskDerivative->setApplicableMenuViews($result);
// Mock the view route names state.
- $view_route_names = array();
+ $view_route_names = [];
// Setup a view which overrides an existing route.
$view_route_names['example_view.page_1'] = 'example_overridden_route';
$this->state->expects($this->once())
@@ -235,20 +235,20 @@ class ViewsLocalTaskTest extends UnitTestCase {
->willReturn($storage);
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
- ->setMethods(array('getOption'))
+ ->setMethods(['getOption'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$display_plugin->expects($this->exactly(2))
->method('getOption')
->with('menu')
- ->will($this->returnValue(array('type' => 'default tab', 'weight' => 12, 'title' => 'Example title')));
+ ->will($this->returnValue(['type' => 'default tab', 'weight' => 12, 'title' => 'Example title']));
$executable->display_handler = $display_plugin;
$result = [['example_view', 'page_1']];
$this->localTaskDerivative->setApplicableMenuViews($result);
// Mock the view route names state.
- $view_route_names = array();
+ $view_route_names = [];
$view_route_names['example_view.page_1'] = 'view.example_view.page_1';
$this->state->expects($this->exactly(2))
->method('get')
@@ -304,13 +304,13 @@ class ViewsLocalTaskTest extends UnitTestCase {
->willReturn($storage);
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
- ->setMethods(array('getOption', 'getPath'))
+ ->setMethods(['getOption', 'getPath'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$display_plugin->expects($this->exactly(2))
->method('getOption')
->with('menu')
- ->will($this->returnValue(array('type' => 'tab', 'weight' => 12, 'title' => 'Example title')));
+ ->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
$display_plugin->expects($this->once())
->method('getPath')
->will($this->returnValue('path/example'));
@@ -320,7 +320,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$this->localTaskDerivative->setApplicableMenuViews($result);
// Mock the view route names state.
- $view_route_names = array();
+ $view_route_names = [];
$view_route_names['example_view.page_1'] = 'view.example_view.page_1';
$this->state->expects($this->exactly(2))
->method('get')
@@ -336,11 +336,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
->will($this->returnValue($route_collection));
// Setup the existing local task of the test_route.
- $definitions['test_route_tab'] = $other_tab = array(
+ $definitions['test_route_tab'] = $other_tab = [
'route_name' => 'test_route',
'title' => 'Test route',
'base_route' => 'test_route',
- );
+ ];
$definitions += $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
diff --git a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php
index 3b0aebf190a..556aef91a9d 100644
--- a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php
@@ -82,7 +82,7 @@ class EntityTest extends UnitTestCase {
->getMock();
$this->executable->style_plugin = $this->stylePlugin;
- $this->entityHandler = new Entity(array(), 'entity', array('entity_type' => 'entity_test'), $this->entityManager);
+ $this->entityHandler = new Entity([], 'entity', ['entity_type' => 'entity_test'], $this->entityManager);
$this->display->expects($this->any())
->method('getPlugin')
diff --git a/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php b/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php
index 07dca650ea3..1c6728da37a 100644
--- a/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php
@@ -31,7 +31,7 @@ class MessagesTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- $this->messagesHandler = new Messages(array(), 'result', array());
+ $this->messagesHandler = new Messages([], 'result', []);
}
/**
@@ -43,15 +43,15 @@ class MessagesTest extends UnitTestCase {
public function testRender() {
// The handler is configured to show with empty views by default, so should
// appear.
- $this->assertSame(array('#type' => 'status_messages'), $this->messagesHandler->render());
+ $this->assertSame(['#type' => 'status_messages'], $this->messagesHandler->render());
// Turn empty off, and make sure it isn't rendered.
$this->messagesHandler->options['empty'] = FALSE;
// $empty parameter passed to render will still be FALSE, so should still
// appear.
- $this->assertSame(array('#type' => 'status_messages'), $this->messagesHandler->render());
+ $this->assertSame(['#type' => 'status_messages'], $this->messagesHandler->render());
// Should now be empty as both the empty option and parameter are empty.
- $this->assertSame(array(), $this->messagesHandler->render(TRUE));
+ $this->assertSame([], $this->messagesHandler->render(TRUE));
}
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php b/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php
index 164d4110a68..a94b672af57 100644
--- a/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php
@@ -79,7 +79,7 @@ class ResultTest extends UnitTestCase {
public function testResultArea($content, $expected, $items_per_page = 0) {
$this->setupViewPager($items_per_page);
$this->resultHandler->options['content'] = $content;
- $this->assertEquals(array('#markup' => $expected), $this->resultHandler->render());
+ $this->assertEquals(['#markup' => $expected], $this->resultHandler->render());
}
/**
@@ -88,25 +88,25 @@ class ResultTest extends UnitTestCase {
* @return array
*/
public function providerTestResultArea() {
- return array(
- array('@label', 'ResultTest'),
- array('@start', '1'),
- array('@start', '1', 1),
- array('@end', '100'),
- array('@end', '1', 1),
- array('@total', '100'),
- array('@total', '100', 1),
- array('@per_page', '0'),
- array('@per_page', '1', 1),
- array('@current_page', '1'),
- array('@current_page', '1', 1),
- array('@current_record_count', '100'),
- array('@current_record_count', '1', 1),
- array('@page_count', '1'),
- array('@page_count', '100', 1),
- array('@start | @end | @total', '1 | 100 | 100'),
- array('@start | @end | @total', '1 | 1 | 100', 1),
- );
+ return [
+ ['@label', 'ResultTest'],
+ ['@start', '1'],
+ ['@start', '1', 1],
+ ['@end', '100'],
+ ['@end', '1', 1],
+ ['@total', '100'],
+ ['@total', '100', 1],
+ ['@per_page', '0'],
+ ['@per_page', '1', 1],
+ ['@current_page', '1'],
+ ['@current_page', '1', 1],
+ ['@current_record_count', '100'],
+ ['@current_record_count', '1', 1],
+ ['@page_count', '1'],
+ ['@page_count', '100', 1],
+ ['@start | @end | @total', '1 | 100 | 100'],
+ ['@start | @end | @total', '1 | 1 | 100', 1],
+ ];
}
/**
@@ -127,7 +127,7 @@ class ResultTest extends UnitTestCase {
$this->view->pager = $pager->reveal();
$this->view->style_plugin = new \stdClass();
$this->view->total_rows = 100;
- $this->view->result = array(1, 2, 3, 4, 5);
+ $this->view->result = [1, 2, 3, 4, 5];
}
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php b/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php
index f472ab28456..91d52829c5a 100644
--- a/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php
@@ -31,7 +31,7 @@ class ViewTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->entityStorage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
- $this->viewHandler = new ViewAreaPlugin(array(), 'view', array(), $this->entityStorage);
+ $this->viewHandler = new ViewAreaPlugin([], 'view', [], $this->entityStorage);
$this->viewHandler->view = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
->getMock();
@@ -60,10 +60,10 @@ class ViewTest extends UnitTestCase {
$this->viewHandler->options['view_to_insert'] = 'other:default';
- $this->assertArrayEquals(array('config' => array('view.other')), $this->viewHandler->calculateDependencies());
+ $this->assertArrayEquals(['config' => ['view.other']], $this->viewHandler->calculateDependencies());
$this->viewHandler->options['view_to_insert'] = 'this:default';
- $this->assertArrayEquals(array(), $this->viewHandler->calculateDependencies());
+ $this->assertArrayEquals([], $this->viewHandler->calculateDependencies());
}
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php b/core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php
index 40016941064..8bacd3dcdb5 100644
--- a/core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php
@@ -28,7 +28,7 @@ class QueryParameterTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- $raw = new QueryParameter(array(), 'query_parameter', array());
+ $raw = new QueryParameter([], 'query_parameter', []);
$raw->init($view, $display_plugin, $options);
$this->assertEquals($expected, $raw->getArgument());
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php b/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php
index 365e4694329..62c89a9a878 100644
--- a/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php
@@ -39,34 +39,34 @@ class RawTest extends UnitTestCase {
// Don't use aliases. Check against NULL and nonexistent path component
// values in addition to valid ones.
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => FALSE,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals(NULL, $raw->getArgument());
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => FALSE,
'index' => 0,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals('test', $raw->getArgument());
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => FALSE,
'index' => 1,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals('example', $raw->getArgument());
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => FALSE,
'index' => 2,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals(NULL, $raw->getArgument());
@@ -77,34 +77,34 @@ class RawTest extends UnitTestCase {
->with($this->equalTo('/test/example'))
->will($this->returnValue('/other/example'));
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => TRUE,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals(NULL, $raw->getArgument());
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => TRUE,
'index' => 0,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals('other', $raw->getArgument());
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => TRUE,
'index' => 1,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals('example', $raw->getArgument());
- $raw = new Raw(array(), 'raw', array(), $alias_manager, $current_path);
- $options = array(
+ $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
+ $options = [
'use_alias' => TRUE,
'index' => 2,
- );
+ ];
$raw->init($view, $display_plugin, $options);
$this->assertEquals(NULL, $raw->getArgument());
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php b/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
index f9ca7d873ca..13a7bc952d8 100644
--- a/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
@@ -47,43 +47,43 @@ class EntityTest extends UnitTestCase {
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
- $mock_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', array(), '', FALSE, TRUE, TRUE, array('bundle', 'access'));
+ $mock_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
$mock_entity->expects($this->any())
->method('bundle')
->will($this->returnValue('test_bundle'));
$mock_entity->expects($this->any())
->method('access')
- ->will($this->returnValueMap(array(
- array('test_op', NULL, FALSE, TRUE),
- array('test_op_2', NULL, FALSE, FALSE),
- array('test_op_3', NULL, FALSE, TRUE),
- )));
+ ->will($this->returnValueMap([
+ ['test_op', NULL, FALSE, TRUE],
+ ['test_op_2', NULL, FALSE, FALSE],
+ ['test_op_3', NULL, FALSE, TRUE],
+ ]));
- $mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', array(), '', FALSE, TRUE, TRUE, array('bundle', 'access'));
+ $mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
$mock_entity_bundle_2->expects($this->any())
->method('bundle')
->will($this->returnValue('test_bundle_2'));
$mock_entity_bundle_2->expects($this->any())
->method('access')
- ->will($this->returnValueMap(array(
- array('test_op', NULL, FALSE, FALSE),
- array('test_op_2', NULL, FALSE, FALSE),
- array('test_op_3', NULL, FALSE, TRUE),
- )));
+ ->will($this->returnValueMap([
+ ['test_op', NULL, FALSE, FALSE],
+ ['test_op_2', NULL, FALSE, FALSE],
+ ['test_op_3', NULL, FALSE, TRUE],
+ ]));
$storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
// Setup values for IDs passed as strings or numbers.
- $value_map = array(
- array(array(), array()),
- array(array(1), array(1 => $mock_entity)),
- array(array('1'), array(1 => $mock_entity)),
- array(array(1, 2), array(1 => $mock_entity, 2 => $mock_entity_bundle_2)),
- array(array('1', '2'), array(1 => $mock_entity, 2 => $mock_entity_bundle_2)),
- array(array(2), array(2 => $mock_entity_bundle_2)),
- array(array('2'), array(2 => $mock_entity_bundle_2)),
- );
+ $value_map = [
+ [[], []],
+ [[1], [1 => $mock_entity]],
+ [['1'], [1 => $mock_entity]],
+ [[1, 2], [1 => $mock_entity, 2 => $mock_entity_bundle_2]],
+ [['1', '2'], [1 => $mock_entity, 2 => $mock_entity_bundle_2]],
+ [[2], [2 => $mock_entity_bundle_2]],
+ [['2'], [2 => $mock_entity_bundle_2]],
+ ];
$storage->expects($this->any())
->method('loadMultiple')
->will($this->returnValueMap($value_map));
@@ -100,11 +100,11 @@ class EntityTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- $definition = array(
+ $definition = [
'entity_type' => 'entity_test',
- );
+ ];
- $this->argumentValidator = new Entity(array(), 'entity_test', $definition, $this->entityManager);
+ $this->argumentValidator = new Entity([], 'entity_test', $definition, $this->entityManager);
}
/**
@@ -113,9 +113,9 @@ class EntityTest extends UnitTestCase {
* @see \Drupal\views\Plugin\views\argument_validator\Entity::validateArgument()
*/
public function testValidateArgumentNoAccess() {
- $options = array();
+ $options = [];
$options['access'] = FALSE;
- $options['bundles'] = array();
+ $options['bundles'] = [];
$this->argumentValidator->init($this->executable, $this->display, $options);
$this->assertFalse($this->argumentValidator->validateArgument(3));
@@ -132,9 +132,9 @@ class EntityTest extends UnitTestCase {
* @see \Drupal\views\Plugin\views\argument_validator\Entity::validateArgument()
*/
public function testValidateArgumentAccess() {
- $options = array();
+ $options = [];
$options['access'] = TRUE;
- $options['bundles'] = array();
+ $options['bundles'] = [];
$options['operation'] = 'test_op';
$this->argumentValidator->init($this->executable, $this->display, $options);
@@ -143,9 +143,9 @@ class EntityTest extends UnitTestCase {
$this->assertTrue($this->argumentValidator->validateArgument(1));
- $options = array();
+ $options = [];
$options['access'] = TRUE;
- $options['bundles'] = array();
+ $options['bundles'] = [];
$options['operation'] = 'test_op_2';
$this->argumentValidator->init($this->executable, $this->display, $options);
@@ -160,9 +160,9 @@ class EntityTest extends UnitTestCase {
* Tests the validate argument method with bundle checking.
*/
public function testValidateArgumentBundle() {
- $options = array();
+ $options = [];
$options['access'] = FALSE;
- $options['bundles'] = array('test_bundle' => 1);
+ $options['bundles'] = ['test_bundle' => 1];
$this->argumentValidator->init($this->executable, $this->display, $options);
$this->assertTrue($this->argumentValidator->validateArgument(1));
@@ -208,10 +208,10 @@ class EntityTest extends UnitTestCase {
->willReturn($storage);
// Set up the argument validator.
- $argumentValidator = new Entity(array(), 'entity_test', ['entity_type' => 'entity_test'], $entityManager);
- $options = array();
+ $argumentValidator = new Entity([], 'entity_test', ['entity_type' => 'entity_test'], $entityManager);
+ $options = [];
$options['access'] = FALSE;
- $options['bundles'] = array('test_bundle' => 1);
+ $options['bundles'] = ['test_bundle' => 1];
$argumentValidator->init($this->executable, $this->display, $options);
$this->assertEquals(['config' => ['test_bundle']], $argumentValidator->calculateDependencies());
@@ -221,9 +221,9 @@ class EntityTest extends UnitTestCase {
* Tests the validate argument method with multiple argument splitting.
*/
public function testValidateArgumentMultiple() {
- $options = array();
+ $options = [];
$options['access'] = TRUE;
- $options['bundles'] = array();
+ $options['bundles'] = [];
$options['operation'] = 'test_op';
$options['multiple'] = TRUE;
$this->argumentValidator->init($this->executable, $this->display, $options);
@@ -234,9 +234,9 @@ class EntityTest extends UnitTestCase {
$this->assertFalse($this->argumentValidator->validateArgument('1,2'));
$this->assertFalse($this->argumentValidator->validateArgument('1+2'));
- $options = array();
+ $options = [];
$options['access'] = TRUE;
- $options['bundles'] = array();
+ $options['bundles'] = [];
$options['operation'] = 'test_op_3';
$options['multiple'] = TRUE;
$this->argumentValidator->init($this->executable, $this->display, $options);
diff --git a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
index b028b9d6b32..08ec780dad8 100644
--- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
@@ -55,7 +55,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
$this->state = $this->getMock('\Drupal\Core\State\StateInterface');
$this->pathPlugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
- ->setConstructorArgs(array(array(), 'path_base', array(), $this->routeProvider, $this->state))
+ ->setConstructorArgs([[], 'path_base', [], $this->routeProvider, $this->state])
->setMethods(NULL)
->getMock();
$this->setupContainer();
@@ -71,12 +71,12 @@ class PathPluginBaseTest extends UnitTestCase {
$container = new ContainerBuilder();
$container->set('plugin.manager.views.access', $this->accessPluginManager);
- $config = array(
- 'views.settings' => array(
+ $config = [
+ 'views.settings' => [
'skip_cache' => TRUE,
- 'display_extenders' => array(),
- ),
- );
+ 'display_extenders' => [],
+ ],
+ ];
$container->set('config.factory', $this->getConfigFactoryStub($config));
@@ -91,17 +91,17 @@ class PathPluginBaseTest extends UnitTestCase {
public function testCollectRoutes() {
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$collection = new RouteCollection();
$result = $this->pathPlugin->collectRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'view.test_id.page_1'), $result);
+ $this->assertEquals(['test_id.page_1' => 'view.test_id.page_1'], $result);
$route = $collection->get('view.test_id.page_1');
$this->assertTrue($route instanceof Route);
@@ -119,14 +119,14 @@ class PathPluginBaseTest extends UnitTestCase {
public function testCollectRoutesWithDisplayReturnResponse() {
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route',
- );
+ ];
$this->pathPlugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
- ->setConstructorArgs(array(array(), 'path_base', array('returns_response' => TRUE), $this->routeProvider, $this->state))
+ ->setConstructorArgs([[], 'path_base', ['returns_response' => TRUE], $this->routeProvider, $this->state])
->setMethods(NULL)
->getMock();
$this->pathPlugin->initDisplay($view, $display);
@@ -146,23 +146,23 @@ class PathPluginBaseTest extends UnitTestCase {
public function testCollectRoutesWithArguments() {
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route/%/example',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$collection = new RouteCollection();
$result = $this->pathPlugin->collectRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'view.test_id.page_1'), $result);
+ $this->assertEquals(['test_id.page_1' => 'view.test_id.page_1'], $result);
$route = $collection->get('view.test_id.page_1');
$this->assertTrue($route instanceof Route);
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
- $this->assertEquals(array('arg_0' => 'arg_0'), $route->getOption('_view_argument_map'));
+ $this->assertEquals(['arg_0' => 'arg_0'], $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
@@ -174,26 +174,26 @@ class PathPluginBaseTest extends UnitTestCase {
public function testCollectRoutesWithArgumentsNotSpecifiedInPath() {
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_with_arguments',
- );
- $display['display_options']['arguments'] = array(
- 'test_id' => array(),
- );
+ ];
+ $display['display_options']['arguments'] = [
+ 'test_id' => [],
+ ];
$this->pathPlugin->initDisplay($view, $display);
$collection = new RouteCollection();
$result = $this->pathPlugin->collectRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'view.test_id.page_1'), $result);
+ $this->assertEquals(['test_id.page_1' => 'view.test_id.page_1'], $result);
$route = $collection->get('view.test_id.page_1');
$this->assertTrue($route instanceof Route);
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
- $this->assertEquals(array('arg_0' => 'arg_0'), $route->getOption('_view_argument_map'));
+ $this->assertEquals(['arg_0' => 'arg_0'], $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
@@ -203,18 +203,18 @@ class PathPluginBaseTest extends UnitTestCase {
public function testCollectRoutesWithSpecialRouteName() {
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route',
'route_name' => 'test_route',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$collection = new RouteCollection();
$result = $this->pathPlugin->collectRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'test_route'), $result);
+ $this->assertEquals(['test_id.page_1' => 'test_route'], $result);
$route = $collection->get('test_route');
$this->assertTrue($route instanceof Route);
@@ -228,22 +228,22 @@ class PathPluginBaseTest extends UnitTestCase {
*/
public function testAlterRoute() {
$collection = new RouteCollection();
- $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content')));
- $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content'));
+ $collection->add('test_route', new Route('test_route', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content']));
+ $route_2 = new Route('test_route/example', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content']);
$collection->add('test_route_2', $route_2);
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$view_route_names = $this->pathPlugin->alterRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'test_route'), $view_route_names);
+ $this->assertEquals(['test_id.page_1' => 'test_route'], $view_route_names);
// Ensure that the test_route is overridden.
$route = $collection->get('test_route');
@@ -342,22 +342,22 @@ class PathPluginBaseTest extends UnitTestCase {
*/
public function testAlterRouteWithAlterCallback() {
$collection = new RouteCollection();
- $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content', '_title_callback' => '\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle')));
- $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content'));
+ $collection->add('test_route', new Route('test_route', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content', '_title_callback' => '\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle']));
+ $route_2 = new Route('test_route/example', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content']);
$collection->add('test_route_2', $route_2);
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$view_route_names = $this->pathPlugin->alterRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'test_route'), $view_route_names);
+ $this->assertEquals(['test_id.page_1' => 'test_route'], $view_route_names);
// Ensure that the test_route is overridden.
$route = $collection->get('test_route');
@@ -384,22 +384,22 @@ class PathPluginBaseTest extends UnitTestCase {
/** @var \Drupal\views\ViewExecutable|\PHPUnit_Framework_MockObject_MockObject $view */
list($view) = $this->setupViewExecutableAccessPlugin();
- $view->argument = array();
+ $view->argument = [];
$view->argument['nid'] = $this->getMockBuilder('Drupal\views\Plugin\views\argument\ArgumentPluginBase')
->disableOriginalConstructor()
->getMock();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route/%node/example',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$collection = new RouteCollection();
$result = $this->pathPlugin->collectRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'view.test_id.page_1'), $result);
+ $this->assertEquals(['test_id.page_1' => 'view.test_id.page_1'], $result);
$route = $collection->get('view.test_id.page_1');
$this->assertTrue($route instanceof Route);
@@ -407,7 +407,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals('my views title', $route->getDefault('_title'));
- $this->assertEquals(array('arg_0' => 'node'), $route->getOption('_view_argument_map'));
+ $this->assertEquals(['arg_0' => 'node'], $route->getOption('_view_argument_map'));
}
/**
@@ -415,7 +415,7 @@ class PathPluginBaseTest extends UnitTestCase {
*/
public function testAlterRoutesWithParameters() {
$collection = new RouteCollection();
- $collection->add('test_route', new Route('test_route/{parameter}', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content')));
+ $collection->add('test_route', new Route('test_route/{parameter}', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content']));
list($view) = $this->setupViewExecutableAccessPlugin();
@@ -425,16 +425,16 @@ class PathPluginBaseTest extends UnitTestCase {
->getMock();
$view->argument['test_id'] = $argument;
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route/%',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$view_route_names = $this->pathPlugin->alterRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'test_route'), $view_route_names);
+ $this->assertEquals(['test_id.page_1' => 'test_route'], $view_route_names);
// Ensure that the test_route is overridden.
$route = $collection->get('test_route');
@@ -443,7 +443,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertEquals('page_1', $route->getDefault('display_id'));
// Ensure that the path did not changed and placeholders are respected.
$this->assertEquals('/test_route/{parameter}', $route->getPath());
- $this->assertEquals(array('arg_0' => 'parameter'), $route->getOption('_view_argument_map'));
+ $this->assertEquals(['arg_0' => 'parameter'], $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
@@ -462,7 +462,7 @@ class PathPluginBaseTest extends UnitTestCase {
->getMock();
$view->argument['test_id'] = $argument;
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
$display['display_options'] = [
@@ -490,24 +490,24 @@ class PathPluginBaseTest extends UnitTestCase {
*/
public function testAlterRoutesWithOptionalParameters() {
$collection = new RouteCollection();
- $collection->add('test_route', new Route('test_route/{parameter}', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content')));
+ $collection->add('test_route', new Route('test_route/{parameter}', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content']));
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route/%',
- );
- $display['display_options']['arguments'] = array(
- 'test_id' => array(),
- 'test_id2' => array(),
- );
+ ];
+ $display['display_options']['arguments'] = [
+ 'test_id' => [],
+ 'test_id2' => [],
+ ];
$this->pathPlugin->initDisplay($view, $display);
$view_route_names = $this->pathPlugin->alterRoutes($collection);
- $this->assertEquals(array('test_id.page_1' => 'test_route'), $view_route_names);
+ $this->assertEquals(['test_id.page_1' => 'test_route'], $view_route_names);
// Ensure that the test_route is overridden.
$route = $collection->get('test_route');
@@ -516,7 +516,7 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertEquals('page_1', $route->getDefault('display_id'));
// Ensure that the path did not changed and placeholders are respected.
$this->assertEquals('/test_route/{parameter}/{arg_1}', $route->getPath());
- $this->assertEquals(array('arg_0' => 'parameter'), $route->getOption('_view_argument_map'));
+ $this->assertEquals(['arg_0' => 'parameter'], $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
@@ -526,12 +526,12 @@ class PathPluginBaseTest extends UnitTestCase {
public function testGetRouteName() {
list($view) = $this->setupViewExecutableAccessPlugin();
- $display = array();
+ $display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
- $display['display_options'] = array(
+ $display['display_options'] = [
'path' => 'test_route',
- );
+ ];
$this->pathPlugin->initDisplay($view, $display);
$route_name = $this->pathPlugin->getRouteName();
// Ensure that the expected routename is returned.
@@ -568,7 +568,7 @@ class PathPluginBaseTest extends UnitTestCase {
->method('createInstance')
->will($this->returnValue($access_plugin));
- return array($view, $view_entity, $access_plugin);
+ return [$view, $view_entity, $access_plugin];
}
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php b/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php
index e6afa89aba8..4d67c00d8a4 100644
--- a/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php
@@ -41,7 +41,7 @@ class CounterTest extends UnitTestCase {
*
* @var array
*/
- protected $testData = array();
+ protected $testData = [];
/**
* The handler definition of the counter field.
@@ -57,12 +57,12 @@ class CounterTest extends UnitTestCase {
parent::setUp();
// Setup basic stuff like the view and the display.
- $config = array();
- $config['display']['default'] = array(
+ $config = [];
+ $config['display']['default'] = [
'id' => 'default',
'display_plugin' => 'default',
'display_title' => 'Default',
- );
+ ];
$storage = new View($config, 'view');
$user = $this->getMock('Drupal\Core\Session\AccountInterface');
@@ -70,7 +70,7 @@ class CounterTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$route_provider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
- $this->view = $this->getMock('Drupal\views\ViewExecutable', NULL, array($storage, $user, $views_data, $route_provider));
+ $this->view = $this->getMock('Drupal\views\ViewExecutable', NULL, [$storage, $user, $views_data, $route_provider]);
$this->display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
->disableOriginalConstructor()
@@ -88,7 +88,7 @@ class CounterTest extends UnitTestCase {
$this->testData[] = new ResultRow($set + ['index' => $index]);
}
- $this->definition = array('title' => 'counter field', 'plugin_type' => 'field');
+ $this->definition = ['title' => 'counter field', 'plugin_type' => 'field'];
}
/**
@@ -98,11 +98,11 @@ class CounterTest extends UnitTestCase {
* Returns an array of row index to test.
*/
public function providerRowIndexes() {
- return array(
- array(0),
- array(1),
- array(2),
- );
+ return [
+ [0],
+ [1],
+ [2],
+ ];
}
/**
@@ -111,8 +111,8 @@ class CounterTest extends UnitTestCase {
* @dataProvider providerRowIndexes
*/
public function testSimpleCounter($i) {
- $counter_handler = new Counter(array(), 'counter', $this->definition);
- $options = array();
+ $counter_handler = new Counter([], 'counter', $this->definition);
+ $options = [];
$counter_handler->init($this->view, $this->display, $options);
$this->view->row_index = $i;
@@ -135,10 +135,10 @@ class CounterTest extends UnitTestCase {
public function testCounterRandomStart($i) {
// Setup a counter field with a random start.
$rand_start = rand(5, 10);
- $counter_handler = new Counter(array(), 'counter', $this->definition);
- $options = array(
+ $counter_handler = new Counter([], 'counter', $this->definition);
+ $options = [
'counter_start' => $rand_start,
- );
+ ];
$counter_handler->init($this->view, $this->display, $options);
$this->view->row_index = $i;
@@ -164,10 +164,10 @@ class CounterTest extends UnitTestCase {
$this->pager->setOffset($offset);
$rand_start = rand(5, 10);
- $counter_handler = new Counter(array(), 'counter', $this->definition);
- $options = array(
+ $counter_handler = new Counter([], 'counter', $this->definition);
+ $options = [
'counter_start' => $rand_start,
- );
+ ];
$counter_handler->init($this->view, $this->display, $options);
$this->view->row_index = $i;
@@ -197,10 +197,10 @@ class CounterTest extends UnitTestCase {
$this->pager->setCurrentPage($current_page);
$rand_start = rand(5, 10);
- $counter_handler = new Counter(array(), 'counter', $this->definition);
- $options = array(
+ $counter_handler = new Counter([], 'counter', $this->definition);
+ $options = [
'counter_start' => $rand_start,
- );
+ ];
$counter_handler->init($this->view, $this->display, $options);
$this->view->row_index = $i;
diff --git a/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php
index f137105ddb4..555c8a404b5 100644
--- a/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php
@@ -35,10 +35,10 @@ class PagerPluginBaseTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- $options = array(
+ $options = [
'items_per_page' => 5,
'offset' => 1,
- );
+ ];
$this->pager->init($view, $display, $options);
@@ -183,20 +183,20 @@ class PagerPluginBaseTest extends UnitTestCase {
* @see self::testHasMoreRecords
*/
public function providerTestHasMoreRecords() {
- return array(
+ return [
// No items per page, so there can't be more available records.
- array(0, 0, 0, FALSE),
- array(0, 10, 0, FALSE),
+ [0, 0, 0, FALSE],
+ [0, 10, 0, FALSE],
// The amount of total items equals the items per page, so there is no
// next page available.
- array(5, 5, 0, FALSE),
+ [5, 5, 0, FALSE],
// There is one more item, and we are at the first page.
- array(5, 6, 0, TRUE),
+ [5, 6, 0, TRUE],
// Now we are on the second page, which has just a single one left.
- array(5, 6, 1, FALSE),
+ [5, 6, 1, FALSE],
// Increase the total items, so we have some available on the third page.
- array(5, 12, 1, TRUE)
- );
+ [5, 12, 1, TRUE]
+ ];
}
/**
diff --git a/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php b/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php
index a3e86a1f645..21af7bf3af3 100644
--- a/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php
@@ -39,7 +39,7 @@ class BlockTest extends UnitTestCase {
$this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
- ->setMethods(array('executeDisplay', 'setDisplay', 'setItemsPerPage'))
+ ->setMethods(['executeDisplay', 'setDisplay', 'setItemsPerPage'])
->getMock();
$this->executable->expects($this->any())
->method('setDisplay')
@@ -67,7 +67,7 @@ class BlockTest extends UnitTestCase {
$this->blockPlugin->expects($this->once())
->method('getConfiguration')
- ->will($this->returnValue(array('items_per_page' => 'none')));
+ ->will($this->returnValue(['items_per_page' => 'none']));
$this->blockDisplay->preBlockBuild($this->blockPlugin);
}
@@ -82,7 +82,7 @@ class BlockTest extends UnitTestCase {
$this->blockPlugin->expects($this->once())
->method('getConfiguration')
- ->will($this->returnValue(array('items_per_page' => 5)));
+ ->will($this->returnValue(['items_per_page' => 5]));
$this->blockDisplay->preBlockBuild($this->blockPlugin);
}
diff --git a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
index 5457baa6362..0900df69247 100644
--- a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
@@ -42,11 +42,11 @@ class EntityOperationsUnitTest extends UnitTestCase {
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
$this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface');
- $configuration = array();
+ $configuration = [];
$plugin_id = $this->randomMachineName();
- $plugin_definition = array(
+ $plugin_definition = [
'title' => $this->randomMachineName(),
- );
+ ];
$this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityManager, $this->languageManager);
$redirect_service = $this->getMock('Drupal\Core\Routing\RedirectDestinationInterface');
@@ -93,11 +93,11 @@ class EntityOperationsUnitTest extends UnitTestCase {
->method('getEntityTypeId')
->will($this->returnValue($entity_type_id));
- $operations = array(
- 'foo' => array(
+ $operations = [
+ 'foo' => [
'title' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$list_builder = $this->getMock('\Drupal\Core\Entity\EntityListBuilderInterface');
$list_builder->expects($this->once())
->method('getOperations')
@@ -114,10 +114,10 @@ class EntityOperationsUnitTest extends UnitTestCase {
$result = new ResultRow();
$result->_entity = $entity;
- $expected_build = array(
+ $expected_build = [
'#type' => 'operations',
'#links' => $operations
- );
+ ];
$expected_build['#links']['foo']['query'] = ['destination' => 'foobar'];
$build = $this->plugin->render($result);
$this->assertSame($expected_build, $build);
@@ -135,11 +135,11 @@ class EntityOperationsUnitTest extends UnitTestCase {
->method('getEntityTypeId')
->will($this->returnValue($entity_type_id));
- $operations = array(
- 'foo' => array(
+ $operations = [
+ 'foo' => [
'title' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$list_builder = $this->getMock('\Drupal\Core\Entity\EntityListBuilderInterface');
$list_builder->expects($this->once())
->method('getOperations')
@@ -156,10 +156,10 @@ class EntityOperationsUnitTest extends UnitTestCase {
$result = new ResultRow();
$result->_entity = $entity;
- $expected_build = array(
+ $expected_build = [
'#type' => 'operations',
'#links' => $operations
- );
+ ];
$build = $this->plugin->render($result);
$this->assertSame($expected_build, $build);
}
diff --git a/core/modules/views/tests/src/Unit/PluginBaseTest.php b/core/modules/views/tests/src/Unit/PluginBaseTest.php
index ef19e1168c9..718cf44e37e 100644
--- a/core/modules/views/tests/src/Unit/PluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/PluginBaseTest.php
@@ -24,7 +24,7 @@ class PluginBaseTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- $this->testHelperPlugin = new TestHelperPlugin(array(), 'default', array());
+ $this->testHelperPlugin = new TestHelperPlugin([], 'default', []);
}
/**
@@ -73,148 +73,148 @@ class PluginBaseTest extends UnitTestCase {
* @return array
*/
public function providerTestUnpackOptions() {
- $test_parameters = array();
+ $test_parameters = [];
// Set a storage but no value, so the storage value should be kept.
- $test_parameters[] = array(
- 'storage' => array(
+ $test_parameters[] = [
+ 'storage' => [
'key' => 'value',
- ),
- 'options' => array(
- ),
- 'definition' => array(
- 'key' => array('default' => 'value2'),
- ),
- 'expected' => array(
+ ],
+ 'options' => [
+ ],
+ 'definition' => [
+ 'key' => ['default' => 'value2'],
+ ],
+ 'expected' => [
'key' => 'value',
- ),
- );
+ ],
+ ];
// Set a storage and a option value, so the option value should be kept.
- $test_parameters[] = array(
- 'storage' => array(
+ $test_parameters[] = [
+ 'storage' => [
'key' => 'value',
- ),
- 'options' => array(
+ ],
+ 'options' => [
'key' => 'value2',
- ),
- 'definition' => array(
- 'key' => array('default' => 'value3'),
- ),
- 'expected' => array(
+ ],
+ 'definition' => [
+ 'key' => ['default' => 'value3'],
+ ],
+ 'expected' => [
'key' => 'value2',
- ),
+ ],
''
- );
+ ];
// Set no storage but an options value, so the options value should be kept.
- $test_parameters[] = array(
- 'storage' => array(),
- 'options' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'options' => [
'key' => 'value',
- ),
- 'definition' => array(
- 'key' => array('default' => 'value2'),
- ),
- 'expected' => array(
+ ],
+ 'definition' => [
+ 'key' => ['default' => 'value2'],
+ ],
+ 'expected' => [
'key' => 'value',
- ),
- );
+ ],
+ ];
// Set additional options, which aren't part of the definition, so they
// should be ignored if all is set.
- $test_parameters[] = array(
- 'storage' => array(),
- 'options' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'options' => [
'key' => 'value',
'key2' => 'value2',
- ),
- 'definition' => array(
- 'key' => array('default' => 'value2'),
- ),
- 'expected' => array(
+ ],
+ 'definition' => [
+ 'key' => ['default' => 'value2'],
+ ],
+ 'expected' => [
'key' => 'value',
- ),
- );
- $test_parameters[] = array(
- 'storage' => array(),
- 'options' => array(
+ ],
+ ];
+ $test_parameters[] = [
+ 'storage' => [],
+ 'options' => [
'key' => 'value',
'key2' => 'value2',
- ),
- 'definition' => array(
- 'key' => array('default' => 'value2'),
- ),
- 'expected' => array(
+ ],
+ 'definition' => [
+ 'key' => ['default' => 'value2'],
+ ],
+ 'expected' => [
'key' => 'value',
'key2' => 'value2',
- ),
+ ],
'all' => TRUE,
- );
+ ];
// Provide multiple options with their corresponding definition.
- $test_parameters[] = array(
- 'storage' => array(),
- 'options' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'options' => [
'key' => 'value',
'key2' => 'value2',
- ),
- 'definition' => array(
- 'key' => array('default' => 'value2'),
- 'key2' => array('default' => 'value3'),
- ),
- 'expected' => array(
+ ],
+ 'definition' => [
+ 'key' => ['default' => 'value2'],
+ 'key2' => ['default' => 'value3'],
+ ],
+ 'expected' => [
'key' => 'value',
'key2' => 'value2',
- ),
- );
+ ],
+ ];
// Set a complex definition structure with a zero and a one level structure.
- $test_parameters[] = array(
- 'storage' => array(),
- 'options' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'options' => [
'key0' => 'value',
- 'key1' => array('key1:1' => 'value1', 'key1:2' => 'value2'),
- ),
- 'definition' => array(
- 'key0' => array('default' => 'value0'),
- 'key1' => array('contains' => array(
- 'key1:1' => array('default' => 'value1:1'),
- )),
- ),
- 'expected' => array(
+ 'key1' => ['key1:1' => 'value1', 'key1:2' => 'value2'],
+ ],
+ 'definition' => [
+ 'key0' => ['default' => 'value0'],
+ 'key1' => ['contains' => [
+ 'key1:1' => ['default' => 'value1:1'],
+ ]],
+ ],
+ 'expected' => [
'key0' => 'value',
- 'key1' => array('key1:1' => 'value1'),
- ),
- );
+ 'key1' => ['key1:1' => 'value1'],
+ ],
+ ];
// Setup a two level structure.
- $test_parameters[] = array(
- 'storage' => array(),
- 'options' => array(
- 'key2' => array(
- 'key2:1' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'options' => [
+ 'key2' => [
+ 'key2:1' => [
'key2:1:1' => 'value0',
- 'key2:1:2' => array(
+ 'key2:1:2' => [
'key2:1:2:1' => 'value1',
- ),
- ),
- ),
- ),
- 'definition' => array(
- 'key2' => array('contains' => array(
- 'key2:1' => array('contains' => array(
- 'key2:1:1' => array('default' => 'value2:1:2:1'),
- 'key2:1:2' => array('contains' => array(
- 'key2:1:2:1' => array('default' => 'value2:1:2:1'),
- )),
- )),
- )),
- ),
- 'expected' => array(
- 'key2' => array(
- 'key2:1' => array(
+ ],
+ ],
+ ],
+ ],
+ 'definition' => [
+ 'key2' => ['contains' => [
+ 'key2:1' => ['contains' => [
+ 'key2:1:1' => ['default' => 'value2:1:2:1'],
+ 'key2:1:2' => ['contains' => [
+ 'key2:1:2:1' => ['default' => 'value2:1:2:1'],
+ ]],
+ ]],
+ ]],
+ ],
+ 'expected' => [
+ 'key2' => [
+ 'key2:1' => [
'key2:1:1' => 'value0',
- 'key2:1:2' => array(
+ 'key2:1:2' => [
'key2:1:2:1' => 'value1',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
return $test_parameters;
}
@@ -225,55 +225,55 @@ class PluginBaseTest extends UnitTestCase {
* @return array
*/
public function providerTestSetOptionDefault() {
- $test_parameters = array();
+ $test_parameters = [];
// No definition should change anything on the storage.
- $test_parameters[] = array(
- 'storage' => array(),
- 'definition' => array(),
- 'expected' => array(),
- );
+ $test_parameters[] = [
+ 'storage' => [],
+ 'definition' => [],
+ 'expected' => [],
+ ];
// Set a single definition, which should be picked up.
- $test_parameters[] = array(
- 'storage' => array(),
- 'definition' => array(
- 'key' => array('default' => 'value'),
- ),
- 'expected' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'definition' => [
+ 'key' => ['default' => 'value'],
+ ],
+ 'expected' => [
'key' => 'value',
- ),
- );
+ ],
+ ];
// Set multiple keys, all should be picked up.
- $test_parameters[] = array(
- 'storage' => array(),
- 'definition' => array(
- 'key' => array('default' => 'value'),
- 'key2' => array('default' => 'value2'),
- 'key3' => array('default' => 'value3'),
- ),
- 'expected' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'definition' => [
+ 'key' => ['default' => 'value'],
+ 'key2' => ['default' => 'value2'],
+ 'key3' => ['default' => 'value3'],
+ ],
+ 'expected' => [
'key' => 'value',
'key2' => 'value2',
'key3' => 'value3',
- ),
- );
+ ],
+ ];
// Setup a definition with multiple levels.
- $test_parameters[] = array(
- 'storage' => array(),
- 'definition' => array(
- 'key' => array('default' => 'value'),
- 'key2' => array('contains' => array(
- 'key2:1' => array('default' => 'value2:1'),
- 'key2:2' => array('default' => 'value2:2'),
- )),
- ),
- 'expected' => array(
+ $test_parameters[] = [
+ 'storage' => [],
+ 'definition' => [
+ 'key' => ['default' => 'value'],
+ 'key2' => ['contains' => [
+ 'key2:1' => ['default' => 'value2:1'],
+ 'key2:2' => ['default' => 'value2:2'],
+ ]],
+ ],
+ 'expected' => [
'key' => 'value',
- 'key2' => array(
+ 'key2' => [
'key2:1' => 'value2:1',
'key2:2' => 'value2:2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $test_parameters;
}
diff --git a/core/modules/views/tests/src/Unit/PluginTypeListTest.php b/core/modules/views/tests/src/Unit/PluginTypeListTest.php
index 32b46d51aa7..29da6b3aff4 100644
--- a/core/modules/views/tests/src/Unit/PluginTypeListTest.php
+++ b/core/modules/views/tests/src/Unit/PluginTypeListTest.php
@@ -16,7 +16,7 @@ class PluginTypeListTest extends UnitTestCase {
* Tests the plugins list is correct.
*/
public function testPluginList() {
- $plugin_list = array(
+ $plugin_list = [
'access',
'area',
'argument',
@@ -36,7 +36,7 @@ class PluginTypeListTest extends UnitTestCase {
'sort',
'style',
'wizard',
- );
+ ];
$diff = array_diff($plugin_list, ViewExecutable::getPluginTypes());
$this->assertTrue(empty($diff), 'The plugin list is correct');
diff --git a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
index 971c1c499ff..9242545b7ad 100644
--- a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
+++ b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php
@@ -148,7 +148,7 @@ class ViewPageControllerTest extends UnitTestCase {
$request->attributes->set('display_id', 'page_1');
// Add the argument to the request.
$request->attributes->set('test_entity', $this->getMock('Drupal\Core\Entity\EntityInterface'));
- $raw_variables = new ParameterBag(array('test_entity' => 'example_id'));
+ $raw_variables = new ParameterBag(['test_entity' => 'example_id']);
$request->attributes->set('_raw_variables', $raw_variables);
$options = [
'_view_argument_map' => [
diff --git a/core/modules/views/tests/src/Unit/ViewExecutableTest.php b/core/modules/views/tests/src/Unit/ViewExecutableTest.php
index fe64ec27880..6abcd99279d 100644
--- a/core/modules/views/tests/src/Unit/ViewExecutableTest.php
+++ b/core/modules/views/tests/src/Unit/ViewExecutableTest.php
@@ -476,7 +476,7 @@ class ViewExecutableTest extends UnitTestCase {
* Returns the view executable and default display.
*/
protected function setupBaseViewAndDisplay() {
- $config = array(
+ $config = [
'id' => 'test_view',
'tag' => 'OnE, TWO, and three',
'display' => [
@@ -486,7 +486,7 @@ class ViewExecutableTest extends UnitTestCase {
'display_title' => 'Default',
],
],
- );
+ ];
$storage = new View($config, 'view');
$view = new ViewExecutable($storage, $this->user, $this->viewsData, $this->routeProvider);
@@ -516,7 +516,7 @@ class ViewExecutableTest extends UnitTestCase {
$view->$type = [];
}
- return array($view, $display);
+ return [$view, $display];
}
/**
diff --git a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
index 97153f5cea0..2289f236e6c 100644
--- a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
@@ -30,7 +30,7 @@ class ViewsDataHelperTest extends UnitTestCase {
$data['views_test_data']['age']['area']['id'] = 'text';
$data['views_test_data']['age']['area']['sub_type'] = 'header';
$data['views_test_data']['job']['area']['id'] = 'text';
- $data['views_test_data']['job']['area']['sub_type'] = array('header', 'footer');
+ $data['views_test_data']['job']['area']['sub_type'] = ['header', 'footer'];
return $data;
}
@@ -48,52 +48,52 @@ class ViewsDataHelperTest extends UnitTestCase {
$data_helper = new ViewsDataHelper($views_data);
- $expected = array(
- 'field' => array(
+ $expected = [
+ 'field' => [
'age',
'created',
'job',
'name',
'status',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'age',
'created',
'id',
'job',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'created',
'id',
'job',
'name',
'status',
- ),
- 'sort' => array(
+ ],
+ 'sort' => [
'age',
'created',
'id',
'name',
'status',
- ),
- 'area' => array(
+ ],
+ 'area' => [
'age',
'created',
'job',
- ),
- 'header' => array(
+ ],
+ 'header' => [
'age',
'created',
'job',
- ),
- 'footer' => array(
+ ],
+ 'footer' => [
'age',
'created',
'job',
- ),
- );
+ ],
+ ];
- $handler_types = array('field', 'argument', 'filter', 'sort', 'area');
+ $handler_types = ['field', 'argument', 'filter', 'sort', 'area'];
foreach ($handler_types as $handler_type) {
$fields = $data_helper->fetchFields('views_test_data', $handler_type);
$expected_keys = $expected[$handler_type];
@@ -104,7 +104,7 @@ class ViewsDataHelperTest extends UnitTestCase {
}
// Check for subtype filtering, so header and footer.
- foreach (array('header', 'footer') as $sub_type) {
+ foreach (['header', 'footer'] as $sub_type) {
$fields = $data_helper->fetchFields('views_test_data', 'area', FALSE, $sub_type);
$expected_keys = $expected[$sub_type];
diff --git a/core/modules/views/tests/src/Unit/ViewsDataTest.php b/core/modules/views/tests/src/Unit/ViewsDataTest.php
index 235189213c2..a145538a6f8 100644
--- a/core/modules/views/tests/src/Unit/ViewsDataTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsDataTest.php
@@ -63,14 +63,14 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$this->getContainerWithCacheTagsInvalidator($this->cacheTagsInvalidator);
- $configs = array();
+ $configs = [];
$configs['views.settings']['skip_cache'] = FALSE;
$this->configFactory = $this->getConfigFactoryStub($configs);
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager->expects($this->any())
->method('getCurrentLanguage')
- ->will($this->returnValue(new Language(array('id' => 'en'))));
+ ->will($this->returnValue(new Language(['id' => 'en'])));
$this->viewsData = new ViewsData($this->cacheBackend, $this->configFactory, $this->moduleHandler, $this->languageManager);
}
@@ -90,7 +90,7 @@ class ViewsDataTest extends UnitTestCase {
$data['views_test_data']['age']['area']['id'] = 'text';
$data['views_test_data']['age']['area']['sub_type'] = 'header';
$data['views_test_data']['job']['area']['id'] = 'text';
- $data['views_test_data']['job']['area']['sub_type'] = array('header', 'footer');
+ $data['views_test_data']['job']['area']['sub_type'] = ['header', 'footer'];
// Duplicate the example views test data for different weight, different title,
// and matching data.
@@ -136,7 +136,7 @@ class ViewsDataTest extends UnitTestCase {
$this->moduleHandler->expects($this->at(0))
->method('getImplementations')
->with('views_data')
- ->willReturn(array('views_test_data'));
+ ->willReturn(['views_test_data']);
$this->moduleHandler->expects($this->at(1))
->method('invoke')
->with('views_test_data', 'views_data')
@@ -167,11 +167,11 @@ class ViewsDataTest extends UnitTestCase {
}
// Test the values returned for each base table.
- $defaults = array(
+ $defaults = [
'title' => '',
'help' => '',
'weight' => 0,
- );
+ ];
foreach ($base_tables as $base_table => $info) {
// Merge in default values as in fetchBaseTables().
$expected = $data[$base_table]['table']['base'] += $defaults;
@@ -215,7 +215,7 @@ class ViewsDataTest extends UnitTestCase {
$this->moduleHandler->expects($this->at(0))
->method('getImplementations')
->with('views_data')
- ->willReturn(array('views_test_data'));
+ ->willReturn(['views_test_data']);
$this->moduleHandler->expects($this->at(1))
->method('invoke')
->with('views_test_data', 'views_data')
@@ -227,7 +227,7 @@ class ViewsDataTest extends UnitTestCase {
$this->moduleHandler->expects($this->at(3))
->method('getImplementations')
->with('views_data')
- ->willReturn(array('views_test_data'));
+ ->willReturn(['views_test_data']);
$this->moduleHandler->expects($this->at(4))
->method('invoke')
->with('views_test_data', 'views_data')
@@ -252,7 +252,7 @@ class ViewsDataTest extends UnitTestCase {
->will($this->returnValue(FALSE));
$this->cacheBackend->expects($this->at(3))
->method('set')
- ->with("views_data:$random_table_name:en", array());
+ ->with("views_data:$random_table_name:en", []);
$this->cacheTagsInvalidator->expects($this->once())
->method('invalidateTags')
->with(['views_data']);
@@ -269,7 +269,7 @@ class ViewsDataTest extends UnitTestCase {
->will($this->returnValue(FALSE));
$this->cacheBackend->expects($this->at(7))
->method('set')
- ->with("views_data:$random_table_name:en", array());
+ ->with("views_data:$random_table_name:en", []);
$views_data = $this->viewsData->getAll();
$this->assertSame($expected_views_data, $views_data);
@@ -283,7 +283,7 @@ class ViewsDataTest extends UnitTestCase {
$this->assertSame($expected_views_data[$table_name_2], $views_data);
$views_data = $this->viewsData->get($random_table_name);
- $this->assertSame(array(), $views_data);
+ $this->assertSame([], $views_data);
$this->viewsData->clear();
@@ -379,11 +379,11 @@ class ViewsDataTest extends UnitTestCase {
// All views data should be requested on the first try.
$views_data = $this->viewsData->get($random_table_name);
- $this->assertSame(array(), $views_data, 'Make sure fetching views data for an invalid table returns an empty array.');
+ $this->assertSame([], $views_data, 'Make sure fetching views data for an invalid table returns an empty array.');
// Test no data is rebuilt when requesting an invalid table again.
$views_data = $this->viewsData->get($random_table_name);
- $this->assertSame(array(), $views_data, 'Make sure fetching views data for an invalid table returns an empty array.');
+ $this->assertSame([], $views_data, 'Make sure fetching views data for an invalid table returns an empty array.');
}
/**
@@ -433,7 +433,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once())
->method('get')
->with('views_data:views_test_data:en')
- ->will($this->returnValue((object) array('data' => $expected_views_data['views_test_data'])));
+ ->will($this->returnValue((object) ['data' => $expected_views_data['views_test_data']]));
$this->cacheBackend->expects($this->never())
->method('set');
@@ -466,7 +466,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->at(1))
->method('get')
->with('views_data:en')
- ->will($this->returnValue((object) array('data' => $expected_views_data)));
+ ->will($this->returnValue((object) ['data' => $expected_views_data]));
$this->cacheBackend->expects($this->at(2))
->method('set')
->with('views_data:views_test_data_2:en', $expected_views_data['views_test_data_2']);
@@ -502,10 +502,10 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->at(1))
->method('get')
->with('views_data:en')
- ->will($this->returnValue((object) array('data' => $expected_views_data)));
+ ->will($this->returnValue((object) ['data' => $expected_views_data]));
$this->cacheBackend->expects($this->at(2))
->method('set')
- ->with("views_data:$non_existing_table:en", array());
+ ->with("views_data:$non_existing_table:en", []);
// Initialize the views data cache and request a non-existing table. This
// will result in the same cache requests as we explicitly write an empty
@@ -514,7 +514,7 @@ class ViewsDataTest extends UnitTestCase {
// check if the table does exist or not.
for ($i = 0; $i < 5; $i++) {
$views_data = $this->viewsData->get($non_existing_table);
- $this->assertSame(array(), $views_data);
+ $this->assertSame([], $views_data);
}
}
@@ -535,7 +535,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once())
->method('get')
->with("views_data:$non_existing_table:en")
- ->will($this->returnValue((object) array('data' => array())));
+ ->will($this->returnValue((object) ['data' => []]));
$this->cacheBackend->expects($this->never())
->method('set');
@@ -546,7 +546,7 @@ class ViewsDataTest extends UnitTestCase {
// check if the table does exist or not.
for ($i = 0; $i < 5; $i++) {
$views_data = $this->viewsData->get($non_existing_table);
- $this->assertSame(array(), $views_data);
+ $this->assertSame([], $views_data);
}
}
@@ -588,7 +588,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once())
->method('get')
->with("views_data:en")
- ->will($this->returnValue((object) array('data' => $expected_views_data)));
+ ->will($this->returnValue((object) ['data' => $expected_views_data]));
$this->cacheBackend->expects($this->never())
->method('set');
@@ -618,7 +618,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->at(1))
->method('get')
->with('views_data:en')
- ->will($this->returnValue((object) array('data' => $expected_views_data)));
+ ->will($this->returnValue((object) ['data' => $expected_views_data]));
$this->cacheBackend->expects($this->at(2))
->method('set')
->with("views_data:$table_name:en", $expected_views_data[$table_name]);
diff --git a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php
index efbbe49e6f6..c181b943567 100644
--- a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php
@@ -48,7 +48,7 @@ class ViewsHandlerManagerTest extends UnitTestCase {
->getMock();
$cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
- $this->handlerManager = new ViewsHandlerManager('test', new \ArrayObject(array()), $this->viewsData, $cache_backend, $this->moduleHandler);
+ $this->handlerManager = new ViewsHandlerManager('test', new \ArrayObject([]), $this->viewsData, $cache_backend, $this->moduleHandler);
}
/**
@@ -72,7 +72,7 @@ class ViewsHandlerManagerTest extends UnitTestCase {
public function testAlterHookInvocation() {
$this->moduleHandler->expects($this->once())
->method('alter')
- ->with('views_plugins_test', array());
+ ->with('views_plugins_test', []);
$this->handlerManager->getDefinitions();
}
diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php
index 345ecc959e7..c21b9c54e8b 100644
--- a/core/modules/views/views.api.php
+++ b/core/modules/views/views.api.php
@@ -93,7 +93,7 @@ use Drupal\views\ViewExecutable;
* to the user following analysis of the view.
*/
function hook_views_analyze(Drupal\views\ViewExecutable $view) {
- $messages = array();
+ $messages = [];
if ($view->display_handler->options['pager']['type'] == 'none') {
$messages[] = Drupal\views\Analyzer::formatMessage(t('This view has no pager. This could cause performance issues when the view contains many items.'), 'warning');
@@ -144,15 +144,15 @@ function hook_views_data() {
// );
// Define the return array.
- $data = array();
+ $data = [];
// The outermost keys of $data are Views table names, which should usually
// be the same as the hook_schema() table names.
- $data['example_table'] = array();
+ $data['example_table'] = [];
// The value corresponding to key 'table' gives properties of the table
// itself.
- $data['example_table']['table'] = array();
+ $data['example_table']['table'] = [];
// Within 'table', the value of 'group' (translated string) is used as a
// prefix in Views UI for this table's fields, filters, etc. When adding
@@ -169,7 +169,7 @@ function hook_views_data() {
// for views. Non-base tables can only be brought in via relationships in
// views based on other tables. To define a table to be a base table, add
// key 'base' to the 'table' array:
- $data['example_table']['table']['base'] = array(
+ $data['example_table']['table']['base'] = [
// Identifier (primary) field in this table for Views.
'field' => 'nid',
// Label in the UI.
@@ -177,7 +177,7 @@ function hook_views_data() {
// Longer description in the UI. Required.
'help' => t('Example table contains example content and can be related to nodes.'),
'weight' => -10,
- );
+ ];
// Some tables have an implicit, automatic relationship to other tables,
// meaning that when the other table is available in a view (either as the
@@ -196,7 +196,7 @@ function hook_views_data() {
// ... FROM example_table et ... JOIN node_field_data nfd
// ON et.nid = nfd.nid AND ('extra' clauses will be here) ...
// although the table aliases will be different.
- $data['example_table']['table']['join'] = array(
+ $data['example_table']['table']['join'] = [
// Within the 'join' section, list one or more tables to automatically
// join to. In this example, every time 'node_field_data' is available in
// a view, 'example_table' will be too. The array keys here are the array
@@ -204,36 +204,36 @@ function hook_views_data() {
// implementations. If the table listed here is from another module's
// hook_views_data() implementation, make sure your module depends on that
// other module.
- 'node_field_data' => array(
+ 'node_field_data' => [
// Primary key field in node_field_data to use in the join.
'left_field' => 'nid',
// Foreign key field in example_table to use in the join.
'field' => 'nid',
// 'extra' is an array of additional conditions on the join.
- 'extra' => array(
- 0 => array(
+ 'extra' => [
+ 0 => [
// Adds AND node_field_data.published = TRUE to the join.
'field' => 'published',
'value' => TRUE,
- ),
- 1 => array(
+ ],
+ 1 => [
// Adds AND example_table.numeric_field = 1 to the join.
'left_field' => 'numeric_field',
'value' => 1,
// If true, the value will not be surrounded in quotes.
'numeric' => TRUE,
- ),
- 2 => array(
+ ],
+ 2 => [
// Adds AND example_table.boolean_field <>
// node_field_data.published to the join.
'field' => 'published',
'left_field' => 'boolean_field',
// The operator used, Defaults to "=".
'operator' => '!=',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
// You can also do a more complex join, where in order to get to a certain
// base table defined in a hook_views_data() implementation, you will join
@@ -248,7 +248,7 @@ function hook_views_data() {
// JOIN node_field_data nfd ON (definition of the join from the foo
// module goes here) ...
// although the table aliases will be different.
- $data['example_table']['table']['join']['node_field_data'] = array(
+ $data['example_table']['table']['join']['node_field_data'] = [
// 'node_field_data' above is the base we're joining to in Views.
// 'left_table' is the table we're actually joining to, in order to get to
// 'node_field_data'. It has to be something that Views knows how to join
@@ -257,16 +257,16 @@ function hook_views_data() {
'left_field' => 'nid',
'field' => 'nid',
// 'extra' is an array of additional conditions on the join.
- 'extra' => array(
+ 'extra' => [
// This syntax matches additional fields in the two tables:
// ... AND foo.langcode = example_table.langcode ...
- array('left_field' => 'langcode', 'field' => 'langcode'),
+ ['left_field' => 'langcode', 'field' => 'langcode'],
// This syntax adds a condition on our table. 'operator' defaults to
// '=' for non-array values, or 'IN' for array values.
// ... AND example_table.numeric_field > 0 ...
- array('field' => 'numeric_field', 'value' => 0, 'numeric' => TRUE, 'operator' => '>'),
- ),
- );
+ ['field' => 'numeric_field', 'value' => 0, 'numeric' => TRUE, 'operator' => '>'],
+ ],
+ ];
// Other array elements at the top level of your table's array describe
// individual database table fields made available to Views. The array keys
@@ -296,7 +296,7 @@ function hook_views_data() {
// Node ID field, exposed as relationship only, since it is a foreign key
// in this table.
- $data['example_table']['nid'] = array(
+ $data['example_table']['nid'] = [
'title' => t('Example content'),
'help' => t('Relate example content to the node content'),
@@ -306,7 +306,7 @@ function hook_views_data() {
// - Use hook_views_data_alter() -- see the function body example on that
// hook for details.
// - Use the implicit join method described above.
- 'relationship' => array(
+ 'relationship' => [
// Views name of the table to join to for the relationship.
'base' => 'node_field_data',
// Database field name in the other table to join on.
@@ -315,78 +315,78 @@ function hook_views_data() {
'id' => 'standard',
// Default label for relationship in the UI.
'label' => t('Example node'),
- ),
- );
+ ],
+ ];
// Plain text field, exposed as a field, sort, filter, and argument.
- $data['example_table']['plain_text_field'] = array(
+ $data['example_table']['plain_text_field'] = [
'title' => t('Plain text field'),
'help' => t('Just a plain text field.'),
- 'field' => array(
+ 'field' => [
// ID of field handler plugin to use.
'id' => 'standard',
- ),
+ ],
- 'sort' => array(
+ 'sort' => [
// ID of sort handler plugin to use.
'id' => 'standard',
- ),
+ ],
- 'filter' => array(
+ 'filter' => [
// ID of filter handler plugin to use.
'id' => 'string',
- ),
+ ],
- 'argument' => array(
+ 'argument' => [
// ID of argument handler plugin to use.
'id' => 'string',
- ),
- );
+ ],
+ ];
// Numeric field, exposed as a field, sort, filter, and argument.
- $data['example_table']['numeric_field'] = array(
+ $data['example_table']['numeric_field'] = [
'title' => t('Numeric field'),
'help' => t('Just a numeric field.'),
- 'field' => array(
+ 'field' => [
// ID of field handler plugin to use.
'id' => 'numeric',
- ),
+ ],
- 'sort' => array(
+ 'sort' => [
// ID of sort handler plugin to use.
'id' => 'standard',
- ),
+ ],
- 'filter' => array(
+ 'filter' => [
// ID of filter handler plugin to use.
'id' => 'numeric',
- ),
+ ],
- 'argument' => array(
+ 'argument' => [
// ID of argument handler plugin to use.
'id' => 'numeric',
- ),
- );
+ ],
+ ];
// Boolean field, exposed as a field, sort, and filter. The filter section
// illustrates overriding various settings.
- $data['example_table']['boolean_field'] = array(
+ $data['example_table']['boolean_field'] = [
'title' => t('Boolean field'),
'help' => t('Just an on/off field.'),
- 'field' => array(
+ 'field' => [
// ID of field handler plugin to use.
'id' => 'boolean',
- ),
+ ],
- 'sort' => array(
+ 'sort' => [
// ID of sort handler plugin to use.
'id' => 'standard',
- ),
+ ],
- 'filter' => array(
+ 'filter' => [
// ID of filter handler plugin to use.
'id' => 'boolean',
// Override the generic field title, so that the filter uses a different
@@ -398,43 +398,43 @@ function hook_views_data() {
// Override the default Boolean filter handler's 'use_equal' setting, to
// make the query use 'boolean_field = 1' instead of 'boolean_field <> 0'.
'use_equal' => TRUE,
- ),
- );
+ ],
+ ];
// Integer timestamp field, exposed as a field, sort, and filter.
- $data['example_table']['timestamp_field'] = array(
+ $data['example_table']['timestamp_field'] = [
'title' => t('Timestamp field'),
'help' => t('Just a timestamp field.'),
- 'field' => array(
+ 'field' => [
// ID of field handler plugin to use.
'id' => 'date',
- ),
+ ],
- 'sort' => array(
+ 'sort' => [
// ID of sort handler plugin to use.
'id' => 'date',
- ),
+ ],
- 'filter' => array(
+ 'filter' => [
// ID of filter handler plugin to use.
'id' => 'date',
- ),
- );
+ ],
+ ];
// Area example. Areas are not generally associated with actual data
// tables and fields. This example is from views_views_data(), which defines
// the "Global" table (not really a table, but a group of Fields, Filters,
// etc. that are grouped into section "Global" in the UI). Here's the
// definition of the generic "Text area":
- $data['views']['area'] = array(
+ $data['views']['area'] = [
'title' => t('Text area'),
'help' => t('Provide markup text for the area.'),
- 'area' => array(
+ 'area' => [
// ID of the area handler plugin to use.
'id' => 'text',
- ),
- );
+ ],
+ ];
return $data;
}
@@ -453,15 +453,15 @@ function hook_views_data_alter(array &$data) {
$data['node_field_data']['nid']['title'] = t('Node-Nid');
// Add an additional field to the users_field_data table.
- $data['users_field_data']['example_field'] = array(
+ $data['users_field_data']['example_field'] = [
'title' => t('Example field'),
'help' => t('Some example content that references a user'),
- 'field' => array(
+ 'field' => [
// ID of the field handler to use.
'id' => 'example_field',
- ),
- );
+ ],
+ ];
// Change the handler of the node title field, presumably to a handler plugin
// you define in your module. Give the ID of this plugin.
@@ -479,11 +479,11 @@ function hook_views_data_alter(array &$data) {
// rather than adding this relationship directly to the $data['foo']['fid']
// field entry, which could overwrite an existing relationship, we define
// a dummy field key to handle the relationship.
- $data['foo']['unique_dummy_name'] = array(
+ $data['foo']['unique_dummy_name'] = [
'title' => t('Title seen while adding relationship'),
'help' => t('More information about the relationship'),
- 'relationship' => array(
+ 'relationship' => [
// Views name of the table being joined to from foo.
'base' => 'example_table',
// Database field name in example_table for the join.
@@ -494,8 +494,8 @@ function hook_views_data_alter(array &$data) {
// ID of relationship handler plugin to use.
'id' => 'standard',
'label' => t('Default label for relationship'),
- ),
- );
+ ],
+ ];
// Note that the $data array is not returned – it is modified by reference.
}
@@ -525,12 +525,12 @@ function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the target_id field.
- $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array(
+ $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = [
'id' => 'standard',
'base' => 'file_managed',
'base field' => 'target_id',
- 'label' => t('image from @field_name', array('@field_name' => $field_storage->getName())),
- );
+ 'label' => t('image from @field_name', ['@field_name' => $field_storage->getName()]),
+ ];
}
return $data;
@@ -563,9 +563,9 @@ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageCon
list($label) = views_entity_field_label($entity_type_id, $field_name);
- $data['file_managed'][$pseudo_field_name]['relationship'] = array(
- 'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
- 'help' => t('Relate each @entity with a @field set to the image.', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
+ $data['file_managed'][$pseudo_field_name]['relationship'] = [
+ 'title' => t('@entity using @field', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
+ 'help' => t('Relate each @entity with a @field set to the image.', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
'id' => 'entity_reverse',
'field_name' => $field_name,
'entity_type' => $entity_type_id,
@@ -574,14 +574,14 @@ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageCon
'base' => $entity_type->getBaseTable(),
'base field' => $entity_type->getKey('id'),
'label' => $field_name,
- 'join_extra' => array(
- 0 => array(
+ 'join_extra' => [
+ 0 => [
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -620,9 +620,9 @@ function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\Fiel
$table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping();
// Views data for this field is in $data[$data_key].
- $data[$data_key][$pseudo_field_name]['relationship'] = array(
- 'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
- 'help' => t('Relate each @entity with a @field set to the term.', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
+ $data[$data_key][$pseudo_field_name]['relationship'] = [
+ 'title' => t('@entity using @field', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
+ 'help' => t('Relate each @entity with a @field set to the term.', ['@entity' => $entity_type->getLabel(), '@field' => $label]),
'id' => 'entity_reverse',
'field_name' => $field_name,
'entity_type' => $entity_type_id,
@@ -631,14 +631,14 @@ function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\Fiel
'base' => $entity_type->getBaseTable(),
'base field' => $entity_type->getKey('id'),
'label' => $field_name,
- 'join_extra' => array(
- 0 => array(
+ 'join_extra' => [
+ 0 => [
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -659,12 +659,12 @@ function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\Fiel
*/
function hook_views_query_substitutions(ViewExecutable $view) {
// Example from views_views_query_substitutions().
- return array(
+ return [
'***CURRENT_VERSION***' => \Drupal::VERSION,
'***CURRENT_TIME***' => REQUEST_TIME,
'***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(),
PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => \Drupal::languageManager()->getDefaultLanguage()->getId(),
- );
+ ];
}
/**
@@ -676,9 +676,9 @@ function hook_views_query_substitutions(ViewExecutable $view) {
* is already marked safe.
*/
function hook_views_form_substitutions() {
- return array(
+ return [
'<!--views-form-example-substitutions-->' => 'Example Substitution',
- );
+ ];
}
/**
@@ -771,7 +771,7 @@ function hook_views_pre_execute(ViewExecutable $view) {
$account = \Drupal::currentUser();
if (count($view->query->tables) > 2 && $account->hasPermission('administer views')) {
- drupal_set_message(t('The view %view may be heavy to execute.', array('%view' => $view->id())), 'warning');
+ drupal_set_message(t('The view %view may be heavy to execute.', ['%view' => $view->id()]), 'warning');
}
}
@@ -882,11 +882,11 @@ function hook_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
// If this is the part of the query filtering on title, chang the
// condition to filter on node ID.
if ($condition['field'] == 'node.title') {
- $condition = array(
+ $condition = [
'field' => 'node.nid',
'value' => $view->exposed_raw_input['title'],
'operator' => '=',
- );
+ ];
}
}
}
@@ -915,10 +915,10 @@ function hook_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
function hook_views_preview_info_alter(array &$rows, ViewExecutable $view) {
// Adds information about the tables being queried by the view to the query
// part of the info box.
- $rows['query'][] = array(
+ $rows['query'][] = [
t('<strong>Table queue</strong>'),
count($view->query->table_queue) . ': (' . implode(', ', array_keys($view->query->table_queue)) . ')',
- );
+ ];
}
/**
@@ -938,7 +938,7 @@ function hook_views_preview_info_alter(array &$rows, ViewExecutable $view) {
function hook_views_ui_display_top_links_alter(array &$links, ViewExecutable $view, $display_id) {
// Put the export link first in the list.
if (isset($links['export'])) {
- $links = array('export' => $links['export']) + $links;
+ $links = ['export' => $links['export']] + $links;
}
}
@@ -953,7 +953,7 @@ function hook_views_ui_display_top_links_alter(array &$links, ViewExecutable $vi
* @see views_invalidate_cache()
*/
function hook_views_invalidate_cache() {
- \Drupal\Core\Cache\Cache::invalidateTags(array('views'));
+ \Drupal\Core\Cache\Cache::invalidateTags(['views']);
}
/**
diff --git a/core/modules/views/views.module b/core/modules/views/views.module
index 96e6dd3dcbf..f9bd098169c 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -28,14 +28,14 @@ function views_help($route_name, RouteMatchInterface $route_match) {
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Views module provides a back end to fetch information from content, user accounts, taxonomy terms, and other entities from the database and present it to the user as a grid, HTML list, table, unformatted list, etc. The resulting displays are known generally as <em>views</em>.') . '</p>';
- $output .= '<p>' . t('For more information, see the <a href=":views">online documentation for the Views module</a>.', array(':views' => 'https://www.drupal.org/documentation/modules/views')) . '</p>';
- $output .= '<p>' . t('In order to create and modify your own views using the administration and configuration user interface, you will need to enable either the Views UI module in core or a contributed module that provides a user interface for Views. See the <a href=":views-ui">Views UI module help page</a> for more information.', array(':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', array('name' => 'views_ui')) : '#')) . '</p>';
+ $output .= '<p>' . t('For more information, see the <a href=":views">online documentation for the Views module</a>.', [':views' => 'https://www.drupal.org/documentation/modules/views']) . '</p>';
+ $output .= '<p>' . t('In order to create and modify your own views using the administration and configuration user interface, you will need to enable either the Views UI module in core or a contributed module that provides a user interface for Views. See the <a href=":views-ui">Views UI module help page</a> for more information.', [':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', ['name' => 'views_ui']) : '#']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Adding functionality to administrative pages') . '</dt>';
$output .= '<dd>' . t('The Views module adds functionality to some core administration pages. For example, <em>admin/content</em> uses Views to filter and sort content. With Views uninstalled, <em>admin/content</em> is more limited.') . '</dd>';
$output .= '<dt>' . t('Expanding Views functionality') . '</dt>';
- $output .= '<dd>' . t('Contributed projects that support the Views module can be found in the <a href=":node">online documentation for Views-related contributed modules</a>.', array(':node' => 'https://www.drupal.org/documentation/modules/views/add-ons')) . '</dd>';
+ $output .= '<dd>' . t('Contributed projects that support the Views module can be found in the <a href=":node">online documentation for Views-related contributed modules</a>.', [':node' => 'https://www.drupal.org/documentation/modules/views/add-ons']) . '</dd>';
$output .= '<dt>' . t('Improving table accessibility') . '</dt>';
$output .= '<dd>' . t('Views tables include semantic markup to improve accessibility. Data cells are automatically associated with header cells through id and header attributes. To improve the accessibility of your tables you can add descriptive elements within the Views table settings. The <em>caption</em> element can introduce context for a table, making it easier to understand. The <em>summary</em> element can provide an overview of how the data has been organized and how to navigate the table. Both the caption and summary are visible by default and also implemented according to HTML5 guidelines.') . '</dd>';
$output .= '<dt>' . t('Working with multilingual views') . '</dt>';
@@ -53,10 +53,10 @@ function views_help($route_name, RouteMatchInterface $route_match) {
function views_views_pre_render($view) {
// If using AJAX, send identifying data about this view.
if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) {
- $view->element['#attached']['drupalSettings']['views'] = array(
+ $view->element['#attached']['drupalSettings']['views'] = [
'ajax_path' => \Drupal::url('views.ajax'),
- 'ajaxViews' => array(
- 'views_dom_id:' . $view->dom_id => array(
+ 'ajaxViews' => [
+ 'views_dom_id:' . $view->dom_id => [
'view_name' => $view->storage->id(),
'view_display_id' => $view->current_display,
'view_args' => Html::escape(implode('/', $view->args)),
@@ -66,9 +66,9 @@ function views_views_pre_render($view) {
// To fit multiple views on a page, the programmer may have
// overridden the display's pager_element.
'pager_element' => isset($view->pager) ? $view->pager->getPagerId() : 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
$view->element['#attached']['library'][] = 'views/views.ajax';
}
@@ -85,50 +85,50 @@ function views_theme($existing, $type, $theme, $path) {
\Drupal::moduleHandler()->loadInclude('views', 'inc', 'views.theme');
// Some quasi clever array merging here.
- $base = array(
+ $base = [
'file' => 'views.theme.inc',
- );
+ ];
// Our extra version of pager from pager.inc
- $hooks['views_mini_pager'] = $base + array(
- 'variables' => array('tags' => array(), 'quantity' => 9, 'element' => 0, 'parameters' => array()),
- );
+ $hooks['views_mini_pager'] = $base + [
+ 'variables' => ['tags' => [], 'quantity' => 9, 'element' => 0, 'parameters' => []],
+ ];
- $variables = array(
+ $variables = [
// For displays, we pass in a dummy array as the first parameter, since
// $view is an object but the core contextual_preprocess() function only
// attaches contextual links when the primary theme argument is an array.
- 'display' => array(
- 'view_array' => array(),
+ 'display' => [
+ 'view_array' => [],
'view' => NULL,
- 'rows' => array(),
- 'header' => array(),
- 'footer' => array(),
- 'empty' => array(),
- 'exposed' => array(),
- 'more' => array(),
- 'feed_icons' => array(),
- 'pager' => array(),
+ 'rows' => [],
+ 'header' => [],
+ 'footer' => [],
+ 'empty' => [],
+ 'exposed' => [],
+ 'more' => [],
+ 'feed_icons' => [],
+ 'pager' => [],
'title' => '',
- 'attachment_before' => array(),
- 'attachment_after' => array(),
- ),
- 'style' => array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL),
- 'row' => array('view' => NULL, 'options' => NULL, 'row' => NULL, 'field_alias' => NULL),
- 'exposed_form' => array('view' => NULL, 'options' => NULL),
- 'pager' => array(
+ 'attachment_before' => [],
+ 'attachment_after' => [],
+ ],
+ 'style' => ['view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL],
+ 'row' => ['view' => NULL, 'options' => NULL, 'row' => NULL, 'field_alias' => NULL],
+ 'exposed_form' => ['view' => NULL, 'options' => NULL],
+ 'pager' => [
'view' => NULL, 'options' => NULL,
- 'tags' => array(), 'quantity' => 9, 'element' => 0, 'parameters' => array()
- ),
- );
+ 'tags' => [], 'quantity' => 9, 'element' => 0, 'parameters' => []
+ ],
+ ];
// Default view themes
- $hooks['views_view_field'] = $base + array(
- 'variables' => array('view' => NULL, 'field' => NULL, 'row' => NULL),
- );
- $hooks['views_view_grouping'] = $base + array(
- 'variables' => array('view' => NULL, 'grouping' => NULL, 'grouping_level' => NULL, 'rows' => NULL, 'title' => NULL),
- );
+ $hooks['views_view_field'] = $base + [
+ 'variables' => ['view' => NULL, 'field' => NULL, 'row' => NULL],
+ ];
+ $hooks['views_view_grouping'] = $base + [
+ 'variables' => ['view' => NULL, 'grouping' => NULL, 'grouping_level' => NULL, 'rows' => NULL, 'title' => NULL],
+ ];
// Only display, pager, row, and style plugins can provide theme hooks.
$plugin_types = [
@@ -138,7 +138,7 @@ function views_theme($existing, $type, $theme, $path) {
'style',
'exposed_form',
];
- $plugins = array();
+ $plugins = [];
foreach ($plugin_types as $plugin_type) {
$plugins[$plugin_type] = Views::pluginManager($plugin_type)->getDefinitions();
}
@@ -164,9 +164,9 @@ function views_theme($existing, $type, $theme, $path) {
continue;
}
- $hooks[$def['theme']] = array(
+ $hooks[$def['theme']] = [
'variables' => $variables[$type],
- );
+ ];
// We always use the module directory as base dir.
$module_dir = drupal_get_path('module', $def['provider']);
@@ -175,7 +175,7 @@ function views_theme($existing, $type, $theme, $path) {
// For the views module we ensure views.theme.inc is included.
if ($def['provider'] == 'views') {
if (!isset($hooks[$def['theme']]['includes'])) {
- $hooks[$def['theme']]['includes'] = array();
+ $hooks[$def['theme']]['includes'] = [];
}
if (!in_array('views.theme.inc', $hooks[$def['theme']]['includes'])) {
$hooks[$def['theme']]['includes'][] = $module_dir . '/views.theme.inc';
@@ -210,13 +210,13 @@ function views_theme($existing, $type, $theme, $path) {
}
}
- $hooks['views_form_views_form'] = $base + array(
+ $hooks['views_form_views_form'] = $base + [
'render element' => 'form',
- );
+ ];
- $hooks['views_exposed_form'] = $base + array(
+ $hooks['views_exposed_form'] = $base + [
'render element' => 'form',
- );
+ ];
return $hooks;
}
@@ -378,13 +378,13 @@ function views_add_contextual_links(&$render_element, $location, $display_id, ar
// set 'contextual_links_locations' to, e.g., {""}.)
if (!isset($plugin['contextual_links_locations'])) {
- $plugin['contextual_links_locations'] = array('view');
+ $plugin['contextual_links_locations'] = ['view'];
}
- elseif ($plugin['contextual_links_locations'] == array() || $plugin['contextual_links_locations'] == array('')) {
- $plugin['contextual_links_locations'] = array();
+ elseif ($plugin['contextual_links_locations'] == [] || $plugin['contextual_links_locations'] == ['']) {
+ $plugin['contextual_links_locations'] = [];
}
else {
- $plugin += array('contextual_links_locations' => array('view'));
+ $plugin += ['contextual_links_locations' => ['view']];
}
// On exposed_forms blocks contextual links should always be visible.
@@ -392,7 +392,7 @@ function views_add_contextual_links(&$render_element, $location, $display_id, ar
$has_links = !empty($plugin['contextual links']) && !empty($plugin['contextual_links_locations']);
if ($has_links && in_array($location, $plugin['contextual_links_locations'])) {
foreach ($plugin['contextual links'] as $group => $link) {
- $args = array();
+ $args = [];
$valid = TRUE;
if (!empty($link['route_parameters_names'])) {
$view_storage = \Drupal::entityManager()
@@ -416,14 +416,14 @@ function views_add_contextual_links(&$render_element, $location, $display_id, ar
// array.
if ($valid) {
$render_element['#views_contextual_links'] = TRUE;
- $render_element['#contextual_links'][$group] = array(
+ $render_element['#contextual_links'][$group] = [
'route_parameters' => $args,
- 'metadata' => array(
+ 'metadata' => [
'location' => $location,
'name' => $view_id,
'display_id' => $display_id,
- ),
- );
+ ],
+ ];
// If we're setting contextual links on a page, for a page view, for a
// user that may use contextual links, attach Views' contextual links
// JavaScript.
@@ -508,23 +508,23 @@ function &views_get_current_view() {
* Implements hook_hook_info().
*/
function views_hook_info() {
- $hooks = array();
+ $hooks = [];
- $hooks += array_fill_keys(array(
+ $hooks += array_fill_keys([
'views_data',
'views_data_alter',
'views_analyze',
'views_invalidate_cache',
- ), array('group' => 'views'));
+ ], ['group' => 'views']);
// Register a views_plugins alter hook for all plugin types.
foreach (ViewExecutable::getPluginTypes() as $type) {
- $hooks['views_plugins_' . $type . '_alter'] = array(
+ $hooks['views_plugins_' . $type . '_alter'] = [
'group' => 'views',
- );
+ ];
}
- $hooks += array_fill_keys(array(
+ $hooks += array_fill_keys([
'views_query_substitutions',
'views_form_substitutions',
'views_pre_view',
@@ -535,14 +535,14 @@ function views_hook_info() {
'views_pre_render',
'views_post_render',
'views_query_alter',
- ), array('group' => 'views_execution'));
+ ], ['group' => 'views_execution']);
- $hooks['field_views_data'] = array(
+ $hooks['field_views_data'] = [
'group' => 'views',
- );
- $hooks['field_views_data_alter'] = array(
+ ];
+ $hooks['field_views_data_alter'] = [
'group' => 'views',
- );
+ ];
return $hooks;
}
@@ -605,8 +605,8 @@ function views_disable_view(View $view) {
*/
function views_pre_render_views_form_views_form($element) {
// Placeholders and their substitutions (usually rendered form elements).
- $search = array();
- $replace = array();
+ $search = [];
+ $replace = [];
// Add in substitutions provided by the form.
foreach ($element['#substitutions']['#value'] as $substitution) {
@@ -788,7 +788,7 @@ function views_get_view_result($name, $display_id = NULL) {
return $view->result;
}
else {
- return array();
+ return [];
}
}
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index 8dcdf672b02..4866d1c22c2 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -90,7 +90,7 @@ function template_preprocess_views_view_fields(&$variables) {
// Loop through the fields for this view.
$previous_inline = FALSE;
- $variables['fields'] = array(); // ensure it's at least an empty array.
+ $variables['fields'] = []; // ensure it's at least an empty array.
/** @var \Drupal\views\ResultRow $row */
$row = $variables['row'];
foreach ($view->field as $id => $field) {
@@ -107,7 +107,7 @@ function template_preprocess_views_view_fields(&$variables) {
$object->element_type = $object->handler->elementType(TRUE, !$variables['options']['default_field_elements'], $object->inline);
if ($object->element_type) {
- $attributes = array();
+ $attributes = [];
if ($object->handler->options['element_default_classes']) {
$attributes['class'][] = 'field-content';
}
@@ -141,7 +141,7 @@ function template_preprocess_views_view_fields(&$variables) {
// Set up field wrapper attributes if field wrapper was set.
if ($object->wrapper_element) {
- $attributes = array();
+ $attributes = [];
if ($object->handler->options['element_default_classes']) {
$attributes['class'][] = 'views-field';
$attributes['class'][] = 'views-field-' . $object->class;
@@ -169,7 +169,7 @@ function template_preprocess_views_view_fields(&$variables) {
// Set up label attributes.
if ($object->label_element) {
- $attributes = array();
+ $attributes = [];
if ($object->handler->options['element_default_classes']) {
$attributes['class'][] = 'views-label';
$attributes['class'][] = 'views-label-' . $object->class;
@@ -241,13 +241,13 @@ function template_preprocess_views_view_summary(&$variables) {
$view = $variables['view'];
$argument = $view->argument[$view->build_info['summary_level']];
- $url_options = array();
+ $url_options = [];
if (!empty($view->exposed_raw_input)) {
$url_options['query'] = $view->exposed_raw_input;
}
- $active_urls = array(
+ $active_urls = [
// Force system path.
\Drupal::url('<current>', [], ['alias' => TRUE]),
// Force system path.
@@ -256,13 +256,13 @@ function template_preprocess_views_view_summary(&$variables) {
\Drupal::url('<current>'),
// Could be an alias.
Url::fromRouteMatch(\Drupal::routeMatch())->toString(),
- );
+ ];
$active_urls = array_combine($active_urls, $active_urls);
// Collect all arguments foreach row, to be able to alter them for example
// by the validator. This is not done per single argument value, because this
// could cause performance problems.
- $row_args = array();
+ $row_args = [];
foreach ($variables['rows'] as $id => $row) {
$row_args[$id] = $argument->summaryArgument($row);
@@ -270,7 +270,7 @@ function template_preprocess_views_view_summary(&$variables) {
$argument->processSummaryArguments($row_args);
foreach ($variables['rows'] as $id => $row) {
- $variables['rows'][$id]->attributes = array();
+ $variables['rows'][$id]->attributes = [];
$variables['rows'][$id]->link = $argument->summaryName($row);
$args = $view->args;
$args[$argument->position] = $row_args[$id];
@@ -329,25 +329,25 @@ function template_preprocess_views_view_summary_unformatted(&$variables) {
$view = $variables['view'];
$argument = $view->argument[$view->build_info['summary_level']];
- $url_options = array();
+ $url_options = [];
if (!empty($view->exposed_raw_input)) {
$url_options['query'] = $view->exposed_raw_input;
}
$count = 0;
- $active_urls = array(
+ $active_urls = [
// Force system path.
\Drupal::url('<current>', [], ['alias' => TRUE]),
// Could be an alias.
\Drupal::url('<current>'),
- );
+ ];
$active_urls = array_combine($active_urls, $active_urls);
// Collect all arguments for each row, to be able to alter them for example
// by the validator. This is not done per single argument value, because
// this could cause performance problems.
- $row_args = array();
+ $row_args = [];
foreach ($variables['rows'] as $id => $row) {
$row_args[$id] = $argument->summaryArgument($row);
}
@@ -358,7 +358,7 @@ function template_preprocess_views_view_summary_unformatted(&$variables) {
if ($count++) {
$variables['rows'][$id]->separator = Xss::filterAdmin($variables['options']['separator']);
}
- $variables['rows'][$id]->attributes = array();
+ $variables['rows'][$id]->attributes = [];
$variables['rows'][$id]->link = $argument->summaryName($row);
$args = $view->args;
$args[$argument->position] = $row_args[$id];
@@ -417,8 +417,8 @@ function template_preprocess_views_view_table(&$variables) {
// so that it can get rebuilt.
// Store rows so that they may be used by further preprocess functions.
$result = $variables['result'] = $variables['rows'];
- $variables['rows'] = array();
- $variables['header'] = array();
+ $variables['rows'] = [];
+ $variables['header'] = [];
$options = $view->style_plugin->options;
$handler = $view->style_plugin;
@@ -466,19 +466,19 @@ function template_preprocess_views_view_table(&$variables) {
$initial = ($order == 'asc') ? 'desc' : 'asc';
}
- $title = t('sort by @s', array('@s' => $label));
+ $title = t('sort by @s', ['@s' => $label]);
if ($active == $field) {
- $variables['header'][$field]['sort_indicator'] = array(
+ $variables['header'][$field]['sort_indicator'] = [
'#theme' => 'tablesort_indicator',
'#style' => $initial,
- );
+ ];
}
$query['order'] = $field;
$query['sort'] = $initial;
- $link_options = array(
+ $link_options = [
'query' => $query,
- );
+ ];
$url = new Url($route_name, [], $link_options);
$variables['header'][$field]['url'] = $url->toString();
$variables['header'][$field]['content'] = $label;
@@ -487,7 +487,7 @@ function template_preprocess_views_view_table(&$variables) {
$variables['header'][$field]['default_classes'] = $fields[$field]->options['element_default_classes'];
// Set up the header label class.
- $variables['header'][$field]['attributes'] = array();
+ $variables['header'][$field]['attributes'] = [];
$class = $fields[$field]->elementLabelClasses(0);
if ($class) {
$variables['header'][$field]['attributes']['class'][] = $class;
@@ -543,7 +543,7 @@ function template_preprocess_views_view_table(&$variables) {
// Add field classes.
if (!isset($column_reference['attributes'])) {
- $column_reference['attributes'] = array();
+ $column_reference['attributes'] = [];
}
if ($classes = $fields[$field]->elementClasses($num)) {
@@ -557,7 +557,7 @@ function template_preprocess_views_view_table(&$variables) {
// Improves accessibility of complex tables.
if (isset($variables['header'][$field]['attributes']['id'])) {
- $column_reference['attributes']['headers'] = array($variables['header'][$field]['attributes']['id']);
+ $column_reference['attributes']['headers'] = [$variables['header'][$field]['attributes']['id']];
}
if (!empty($fields[$field])) {
@@ -604,11 +604,11 @@ function template_preprocess_views_view_table(&$variables) {
// Hide table header if all labels are empty.
if (!$has_header_labels) {
- $variables['header'] = array();
+ $variables['header'] = [];
}
foreach ($variables['rows'] as $num => $row) {
- $variables['rows'][$num]['attributes'] = array();
+ $variables['rows'][$num]['attributes'] = [];
if ($row_class = $handler->getRowClass($num)) {
$variables['rows'][$num]['attributes']['class'][] = $row_class;
}
@@ -620,10 +620,10 @@ function template_preprocess_views_view_table(&$variables) {
$variables['rows'][0]['columns'][0]['content'][0]['field_output'] = $build;
$variables['rows'][0]['attributes'] = new Attribute(['class' => ['odd']]);
// Calculate the amounts of rows with output.
- $variables['rows'][0]['columns'][0]['attributes'] = new Attribute(array(
+ $variables['rows'][0]['columns'][0]['attributes'] = new Attribute([
'colspan' => count($variables['header']),
'class' => ['views-empty'],
- ));
+ ]);
}
$variables['sticky'] = FALSE;
@@ -678,7 +678,7 @@ function template_preprocess_views_view_grid(&$variables) {
$col = 0;
$row = 0;
- $items = array();
+ $items = [];
$remainders = count($variables['rows']) % $options['columns'];
$num_rows = floor(count($variables['rows']) / $options['columns']);
@@ -695,7 +695,7 @@ function template_preprocess_views_view_grid(&$variables) {
// Create attributes for rows.
if (!$horizontal || ($horizontal && empty($items[$row]['attributes']))) {
- $row_attributes = array('class' => array());
+ $row_attributes = ['class' => []];
// Add custom row classes.
$row_class = array_filter(explode(' ', $variables['view']->style_plugin->getCustomClass($result_index, 'row')));
if (!empty($row_class)) {
@@ -712,7 +712,7 @@ function template_preprocess_views_view_grid(&$variables) {
// Create attributes for columns.
if ($horizontal || (!$horizontal && empty($items[$col]['attributes']))) {
- $col_attributes = array('class' => array());
+ $col_attributes = ['class' => []];
// Add default views column classes.
// Add custom column classes.
$col_class = array_filter(explode(' ', $variables['view']->style_plugin->getCustomClass($result_index, 'col')));
@@ -781,7 +781,7 @@ function template_preprocess_views_view_unformatted(&$variables) {
$variables['default_row_class'] = !empty($options['default_row_class']);
foreach ($rows as $id => $row) {
- $variables['rows'][$id] = array();
+ $variables['rows'][$id] = [];
$variables['rows'][$id]['content'] = $row;
$variables['rows'][$id]['attributes'] = new Attribute();
if ($row_class = $view->style_plugin->getRowClass($id)) {
@@ -808,7 +808,7 @@ function template_preprocess_views_view_list(&$variables) {
$class = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $class);
// Initialize a new attribute class for $class.
- $variables['list']['attributes'] = new Attribute(array('class' => $class));
+ $variables['list']['attributes'] = new Attribute(['class' => $class]);
}
// Fetch wrapper classes from handler options.
@@ -864,7 +864,7 @@ function template_preprocess_views_view_rss(&$variables) {
/** @var \Drupal\Core\Url $url */
if ($url) {
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (!empty($view->exposed_raw_input)) {
$url_options['query'] = $view->exposed_raw_input;
}
@@ -913,7 +913,7 @@ function template_preprocess_views_view_row_rss(&$variables) {
$variables['description'] = (string) \Drupal::service('renderer')->render($item->description);
}
- $variables['item_elements'] = array();
+ $variables['item_elements'] = [];
foreach ($item->elements as $element) {
if (isset($element['attributes']) && is_array($element['attributes'])) {
$element['attributes'] = new Attribute($element['attributes']);
@@ -1022,9 +1022,9 @@ function template_preprocess_views_mini_pager(&$variables) {
$variables['items']['current'] = $pager_page_array[$element] + 1;
if ($pager_total[$element] > 1 && $pager_page_array[$element] > 0) {
- $options = array(
+ $options = [
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
- );
+ ];
$variables['items']['previous']['href'] = \Drupal::url('<current>', [], $options);
if (isset($tags[1])) {
$variables['items']['previous']['text'] = $tags[1];
@@ -1033,9 +1033,9 @@ function template_preprocess_views_mini_pager(&$variables) {
}
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
- $options = array(
+ $options = [
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
- );
+ ];
$variables['items']['next']['href'] = \Drupal::url('<current>', [], $options);
if (isset($tags[3])) {
$variables['items']['next']['text'] = $tags[3];
diff --git a/core/modules/views/views.tokens.inc b/core/modules/views/views.tokens.inc
index defd34fd3b5..9bf5470a660 100644
--- a/core/modules/views/views.tokens.inc
+++ b/core/modules/views/views.tokens.inc
@@ -11,56 +11,56 @@ use Drupal\Core\Render\BubbleableMetadata;
* Implements hook_token_info().
*/
function views_token_info() {
- $info['types']['view'] = array(
+ $info['types']['view'] = [
'name' => t('View', [], ['context' => 'View entity type']),
'description' => t('Tokens related to views.'),
'needs-data' => 'view',
- );
- $info['tokens']['view']['label'] = array(
+ ];
+ $info['tokens']['view']['label'] = [
'name' => t('Label'),
'description' => t('The label of the view.'),
- );
- $info['tokens']['view']['description'] = array(
+ ];
+ $info['tokens']['view']['description'] = [
'name' => t('Description'),
'description' => t('The description of the view.'),
- );
- $info['tokens']['view']['id'] = array(
+ ];
+ $info['tokens']['view']['id'] = [
'name' => t('ID'),
'description' => t('The machine-readable ID of the view.'),
- );
- $info['tokens']['view']['title'] = array(
+ ];
+ $info['tokens']['view']['title'] = [
'name' => t('Title'),
'description' => t('The title of current display of the view.'),
- );
- $info['tokens']['view']['url'] = array(
+ ];
+ $info['tokens']['view']['url'] = [
'name' => t('URL'),
'description' => t('The URL of the view.'),
'type' => 'url',
- );
- $info['tokens']['view']['base-table'] = array(
+ ];
+ $info['tokens']['view']['base-table'] = [
'name' => t('Base table'),
'description' => t('The base table used for this view.'),
- );
- $info['tokens']['view']['base-field'] = array(
+ ];
+ $info['tokens']['view']['base-field'] = [
'name' => t('Base field'),
'description' => t('The base field used for this view.'),
- );
- $info['tokens']['view']['total-rows'] = array(
+ ];
+ $info['tokens']['view']['total-rows'] = [
'name' => t('Total rows'),
'description' => t('The total amount of results returned from the view. The current display will be used.'),
- );
- $info['tokens']['view']['items-per-page'] = array(
+ ];
+ $info['tokens']['view']['items-per-page'] = [
'name' => t('Items per page'),
'description' => t('The number of items per page.'),
- );
- $info['tokens']['view']['current-page'] = array(
+ ];
+ $info['tokens']['view']['current-page'] = [
'name' => t('Current page'),
'description' => t('The current page of results the view is on.'),
- );
- $info['tokens']['view']['page-count'] = array(
+ ];
+ $info['tokens']['view']['page-count'] = [
'name' => t('Page count'),
'description' => t('The total page count.'),
- );
+ ];
return $info;
}
@@ -69,11 +69,11 @@ function views_token_info() {
* Implements hook_tokens().
*/
function views_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['language'])) {
$url_options['language'] = $options['language'];
}
- $replacements = array();
+ $replacements = [];
if ($type == 'view' && !empty($data['view'])) {
/** @var \Drupal\views\ViewExecutable $view */
diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc
index 93a659cda20..0bd5f270057 100644
--- a/core/modules/views/views.views.inc
+++ b/core/modules/views/views.views.inc
@@ -18,129 +18,129 @@ use Drupal\system\ActionConfigEntityInterface;
*/
function views_views_data() {
$data['views']['table']['group'] = t('Global');
- $data['views']['table']['join'] = array(
+ $data['views']['table']['join'] = [
// #global is a special flag which allows a table to appear all the time.
- '#global' => array(),
- );
+ '#global' => [],
+ ];
- $data['views']['random'] = array(
+ $data['views']['random'] = [
'title' => t('Random'),
'help' => t('Randomize the display order.'),
- 'sort' => array(
+ 'sort' => [
'id' => 'random',
- ),
- );
+ ],
+ ];
- $data['views']['null'] = array(
+ $data['views']['null'] = [
'title' => t('Null'),
'help' => t('Allow a contextual filter value to be ignored. The query will not be altered by this contextual filter value. Can be used when contextual filter values come from the URL, and a part of the URL needs to be ignored.'),
- 'argument' => array(
+ 'argument' => [
'id' => 'null',
- ),
- );
+ ],
+ ];
- $data['views']['nothing'] = array(
+ $data['views']['nothing'] = [
'title' => t('Custom text'),
'help' => t('Provide custom text or link.'),
- 'field' => array(
+ 'field' => [
'id' => 'custom',
- ),
- );
+ ],
+ ];
- $data['views']['counter'] = array(
+ $data['views']['counter'] = [
'title' => t('View result counter'),
'help' => t('Displays the actual position of the view result'),
- 'field' => array(
+ 'field' => [
'id' => 'counter',
- ),
- );
+ ],
+ ];
- $data['views']['area'] = array(
+ $data['views']['area'] = [
'title' => t('Text area'),
'help' => t('Provide markup text for the area.'),
- 'area' => array(
+ 'area' => [
'id' => 'text',
- ),
- );
+ ],
+ ];
- $data['views']['area_text_custom'] = array(
+ $data['views']['area_text_custom'] = [
'title' => t('Unfiltered text'),
'help' => t('Add unrestricted, custom text or markup. This is similar to the custom text field.'),
- 'area' => array(
+ 'area' => [
'id' => 'text_custom',
- ),
- );
+ ],
+ ];
- $data['views']['title'] = array(
+ $data['views']['title'] = [
'title' => t('Title override'),
'help' => t('Override the default view title for this view. This is useful to display an alternative title when a view is empty.'),
- 'area' => array(
+ 'area' => [
'id' => 'title',
'sub_type' => 'empty',
- ),
- );
+ ],
+ ];
- $data['views']['view'] = array(
+ $data['views']['view'] = [
'title' => t('View area'),
'help' => t('Insert a view inside an area.'),
- 'area' => array(
+ 'area' => [
'id' => 'view',
- ),
- );
+ ],
+ ];
- $data['views']['result'] = array(
+ $data['views']['result'] = [
'title' => t('Result summary'),
'help' => t('Shows result summary, for example the items per page.'),
- 'area' => array(
+ 'area' => [
'id' => 'result',
- ),
- );
+ ],
+ ];
- $data['views']['messages'] = array(
+ $data['views']['messages'] = [
'title' => t('Messages'),
'help' => t('Displays messages in an area.'),
- 'area' => array(
+ 'area' => [
'id' => 'messages',
- ),
- );
+ ],
+ ];
- $data['views']['http_status_code'] = array(
+ $data['views']['http_status_code'] = [
'title' => t('Response status code'),
'help' => t('Alter the HTTP response status code used by this view, mostly helpful for empty results.'),
- 'area' => array(
+ 'area' => [
'id' => 'http_status_code',
- ),
- );
+ ],
+ ];
- $data['views']['combine'] = array(
+ $data['views']['combine'] = [
'title' => t('Combine fields filter'),
'help' => t('Combine multiple fields together and search by them.'),
- 'filter' => array(
+ 'filter' => [
'id' => 'combine',
- ),
- );
+ ],
+ ];
- $data['views']['dropbutton'] = array(
+ $data['views']['dropbutton'] = [
'title' => t('Dropbutton'),
'help' => t('Display fields in a dropbutton.'),
- 'field' => array(
+ 'field' => [
'id' => 'dropbutton',
- ),
- );
+ ],
+ ];
// Registers an entity area handler per entity type.
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
// Excludes entity types, which cannot be rendered.
if ($entity_type->hasViewBuilderClass()) {
$label = $entity_type->getLabel();
- $data['views']['entity_' . $entity_type_id] = array(
- 'title' => t('Rendered entity - @label', array('@label' => $label)),
- 'help' => t('Displays a rendered @label entity in an area.', array('@label' => $label)),
- 'area' => array(
+ $data['views']['entity_' . $entity_type_id] = [
+ 'title' => t('Rendered entity - @label', ['@label' => $label]),
+ 'help' => t('Displays a rendered @label entity in an area.', ['@label' => $label]),
+ 'area' => [
'entity_type' => $entity_type_id,
'id' => 'entity',
- ),
- );
+ ],
+ ];
}
}
@@ -152,13 +152,13 @@ function views_views_data() {
if (empty($actions)) {
continue;
}
- $data[$entity_info->getBaseTable()][$entity_type . '_bulk_form'] = array(
+ $data[$entity_info->getBaseTable()][$entity_type . '_bulk_form'] = [
'title' => t('Bulk update'),
'help' => t('Allows users to apply an action to one or more items.'),
- 'field' => array(
+ 'field' => [
'id' => 'bulk_form',
- ),
- );
+ ],
+ ];
}
// Registers views data for the entity itself.
@@ -180,7 +180,7 @@ function views_views_data() {
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
foreach ($entity_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) {
if (_views_field_get_entity_type_storage($field_storage)) {
- $result = (array) $module_handler->invoke($field_storage->getTypeProvider(), 'field_views_data', array($field_storage));
+ $result = (array) $module_handler->invoke($field_storage->getTypeProvider(), 'field_views_data', [$field_storage]);
if (empty($result)) {
$result = views_field_default_views_data($field_storage);
}
@@ -245,8 +245,8 @@ function _views_field_get_entity_type_storage(FieldStorageConfigInterface $field
* Therefore it looks up in all bundles to find the most used field.
*/
function views_entity_field_label($entity_type, $field_name) {
- $label_counter = array();
- $all_labels = array();
+ $label_counter = [];
+ $all_labels = [];
// Count the amount of fields per label per field storage.
foreach (array_keys(\Drupal::entityManager()->getBundleInfo($entity_type)) as $bundle) {
$bundle_fields = array_filter(\Drupal::entityManager()->getFieldDefinitions($entity_type, $bundle), function ($field_definition) {
@@ -260,7 +260,7 @@ function views_entity_field_label($entity_type, $field_name) {
}
}
if (empty($label_counter)) {
- return array($field_name, $all_labels);
+ return [$field_name, $all_labels];
}
// Sort the field labels by it most used label and return the most used one.
// If the counts are equal, sort by the label to ensure the result is
@@ -272,7 +272,7 @@ function views_entity_field_label($entity_type, $field_name) {
return $label_counter[$a] > $label_counter[$b] ? -1 : 1;
});
$label_counter = array_keys($label_counter);
- return array($label_counter[0], $all_labels);
+ return [$label_counter[0], $all_labels];
}
/**
@@ -285,7 +285,7 @@ function views_entity_field_label($entity_type, $field_name) {
* The default views data for the field.
*/
function views_field_default_views_data(FieldStorageConfigInterface $field_storage) {
- $data = array();
+ $data = [];
// Check the field type is available.
if (!\Drupal::service('plugin.manager.field.field_type')->hasDefinition($field_storage->getType())) {
@@ -319,7 +319,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
// We cannot do anything if for some reason there is no base table.
return $data;
}
- $entity_tables = array($base_table => $entity_type_id);
+ $entity_tables = [$base_table => $entity_type_id];
// Some entities may not have a data table.
$data_table = $entity_type->getDataTable();
if ($data_table) {
@@ -339,69 +339,69 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
// @todo Generalize this code to make it work with any table layout. See
// https://www.drupal.org/node/2079019.
$table_mapping = $storage->getTableMapping();
- $field_tables = array(
- EntityStorageInterface::FIELD_LOAD_CURRENT => array(
+ $field_tables = [
+ EntityStorageInterface::FIELD_LOAD_CURRENT => [
'table' => $table_mapping->getDedicatedDataTableName($field_storage),
'alias' => "{$entity_type_id}__{$field_name}",
- ),
- );
+ ],
+ ];
if ($supports_revisions) {
- $field_tables[EntityStorageInterface::FIELD_LOAD_REVISION] = array(
+ $field_tables[EntityStorageInterface::FIELD_LOAD_REVISION] = [
'table' => $table_mapping->getDedicatedRevisionTableName($field_storage),
'alias' => "{$entity_type_id}_revision__{$field_name}",
- );
+ ];
}
// Build the relationships between the field table and the entity tables.
$table_alias = $field_tables[EntityStorageInterface::FIELD_LOAD_CURRENT]['alias'];
if ($data_table) {
// Tell Views how to join to the base table, via the data table.
- $data[$table_alias]['table']['join'][$data_table] = array(
+ $data[$table_alias]['table']['join'][$data_table] = [
'table' => $table_mapping->getDedicatedDataTableName($field_storage),
'left_field' => $entity_type->getKey('id'),
'field' => 'entity_id',
- 'extra' => array(
- array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
- array('left_field' => 'langcode', 'field' => 'langcode'),
- ),
- );
+ 'extra' => [
+ ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
+ ['left_field' => 'langcode', 'field' => 'langcode'],
+ ],
+ ];
}
else {
// If there is no data table, just join directly.
- $data[$table_alias]['table']['join'][$base_table] = array(
+ $data[$table_alias]['table']['join'][$base_table] = [
'table' => $table_mapping->getDedicatedDataTableName($field_storage),
'left_field' => $entity_type->getKey('id'),
'field' => 'entity_id',
- 'extra' => array(
- array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
- ),
- );
+ 'extra' => [
+ ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
+ ],
+ ];
}
if ($supports_revisions) {
$table_alias = $field_tables[EntityStorageInterface::FIELD_LOAD_REVISION]['alias'];
if ($entity_revision_data_table) {
// Tell Views how to join to the revision table, via the data table.
- $data[$table_alias]['table']['join'][$entity_revision_data_table] = array(
+ $data[$table_alias]['table']['join'][$entity_revision_data_table] = [
'table' => $table_mapping->getDedicatedRevisionTableName($field_storage),
'left_field' => $entity_type->getKey('revision'),
'field' => 'revision_id',
- 'extra' => array(
- array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
- array('left_field' => 'langcode', 'field' => 'langcode'),
- ),
- );
+ 'extra' => [
+ ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
+ ['left_field' => 'langcode', 'field' => 'langcode'],
+ ],
+ ];
}
else {
// If there is no data table, just join directly.
- $data[$table_alias]['table']['join'][$entity_revision_table] = array(
+ $data[$table_alias]['table']['join'][$entity_revision_table] = [
'table' => $table_mapping->getDedicatedRevisionTableName($field_storage),
'left_field' => $entity_type->getKey('revision'),
'field' => 'revision_id',
- 'extra' => array(
- array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
- ),
- );
+ 'extra' => [
+ ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
+ ],
+ ];
}
}
@@ -409,7 +409,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
// Get the list of bundles the field appears in.
$bundles_names = $field_storage->getBundles();
// Build the list of additional fields to add to queries.
- $add_fields = array('delta', 'langcode', 'bundle');
+ $add_fields = ['delta', 'langcode', 'bundle'];
foreach (array_keys($field_columns) as $column) {
$add_fields[] = $table_mapping->getFieldColumnName($field_storage, $column);
}
@@ -428,41 +428,41 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
$field_alias = $field_name;
}
else {
- $group = t('@group (historical data)', array('@group' => $group_name));
+ $group = t('@group (historical data)', ['@group' => $group_name]);
$field_alias = $field_name . '-revision_id';
}
- $data[$table_alias][$field_alias] = array(
+ $data[$table_alias][$field_alias] = [
'group' => $group,
'title' => $label,
'title short' => $label,
- 'help' => t('Appears in: @bundles.', array('@bundles' => implode(', ', $bundles_names))),
- );
+ 'help' => t('Appears in: @bundles.', ['@bundles' => implode(', ', $bundles_names)]),
+ ];
// Go through and create a list of aliases for all possible combinations of
// entity type + name.
- $aliases = array();
- $also_known = array();
+ $aliases = [];
+ $also_known = [];
foreach ($all_labels as $label_name => $true) {
if ($type == EntityStorageInterface::FIELD_LOAD_CURRENT) {
if ($label != $label_name) {
- $aliases[] = array(
+ $aliases[] = [
'base' => $base_table,
'group' => $group_name,
'title' => $label_name,
- 'help' => t('This is an alias of @group: @field.', array('@group' => $group_name, '@field' => $label)),
- );
- $also_known[] = t('@group: @field', array('@group' => $group_name, '@field' => $label_name));
+ 'help' => t('This is an alias of @group: @field.', ['@group' => $group_name, '@field' => $label]),
+ ];
+ $also_known[] = t('@group: @field', ['@group' => $group_name, '@field' => $label_name]);
}
}
elseif ($supports_revisions && $label != $label_name) {
- $aliases[] = array(
+ $aliases[] = [
'base' => $table,
- 'group' => t('@group (historical data)', array('@group' => $group_name)),
+ 'group' => t('@group (historical data)', ['@group' => $group_name]),
'title' => $label_name,
- 'help' => t('This is an alias of @group: @field.', array('@group' => $group_name, '@field' => $label)),
- );
- $also_known[] = t('@group (historical data): @field', array('@group' => $group_name, '@field' => $label_name));
+ 'help' => t('This is an alias of @group: @field.', ['@group' => $group_name, '@field' => $label]),
+ ];
+ $also_known[] = t('@group (historical data): @field', ['@group' => $group_name, '@field' => $label_name]);
}
}
if ($aliases) {
@@ -481,7 +481,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
$keys = array_keys($field_columns);
$real_field = reset($keys);
- $data[$table_alias][$field_alias]['field'] = array(
+ $data[$table_alias][$field_alias]['field'] = [
'table' => $table,
'id' => 'field',
'field_name' => $field_name,
@@ -492,7 +492,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
// Default the element type to div, let the UI change it if necessary.
'element type' => 'div',
'is revision' => $type == EntityStorageInterface::FIELD_LOAD_REVISION,
- );
+ ];
}
// Expose data for each field property individually.
@@ -527,12 +527,12 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
}
if (count($field_columns) == 1 || $column == 'value') {
- $title = t('@label (@name)', array('@label' => $label, '@name' => $field_name));
+ $title = t('@label (@name)', ['@label' => $label, '@name' => $field_name]);
$title_short = $label;
}
else {
- $title = t('@label (@name:@column)', array('@label' => $label, '@name' => $field_name, '@column' => $column));
- $title_short = t('@label:@column', array('@label' => $label, '@column' => $column));
+ $title = t('@label (@name:@column)', ['@label' => $label, '@name' => $field_name, '@column' => $column]);
+ $title_short = t('@label:@column', ['@label' => $label, '@column' => $column]);
}
// Expose data for the property.
@@ -544,38 +544,38 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
$group = $group_name;
}
else {
- $group = t('@group (historical data)', array('@group' => $group_name));
+ $group = t('@group (historical data)', ['@group' => $group_name]);
}
$column_real_name = $table_mapping->getFieldColumnName($field_storage, $column);
// Load all the fields from the table by default.
$additional_fields = $table_mapping->getAllColumns($table);
- $data[$table_alias][$column_real_name] = array(
+ $data[$table_alias][$column_real_name] = [
'group' => $group,
'title' => $title,
'title short' => $title_short,
- 'help' => t('Appears in: @bundles.', array('@bundles' => implode(', ', $bundles_names))),
- );
+ 'help' => t('Appears in: @bundles.', ['@bundles' => implode(', ', $bundles_names)]),
+ ];
// Go through and create a list of aliases for all possible combinations of
// entity type + name.
- $aliases = array();
- $also_known = array();
+ $aliases = [];
+ $also_known = [];
foreach ($all_labels as $label_name => $true) {
if ($label != $label_name) {
if (count($field_columns) == 1 || $column == 'value') {
- $alias_title = t('@label (@name)', array('@label' => $label_name, '@name' => $field_name));
+ $alias_title = t('@label (@name)', ['@label' => $label_name, '@name' => $field_name]);
}
else {
- $alias_title = t('@label (@name:@column)', array('@label' => $label_name, '@name' => $field_name, '@column' => $column));
+ $alias_title = t('@label (@name:@column)', ['@label' => $label_name, '@name' => $field_name, '@column' => $column]);
}
- $aliases[] = array(
+ $aliases[] = [
'group' => $group_name,
'title' => $alias_title,
- 'help' => t('This is an alias of @group: @field.', array('@group' => $group_name, '@field' => $title)),
- );
- $also_known[] = t('@group: @field', array('@group' => $group_name, '@field' => $title));
+ 'help' => t('This is an alias of @group: @field.', ['@group' => $group_name, '@field' => $title]),
+ ];
+ $also_known[] = t('@group: @field', ['@group' => $group_name, '@field' => $title]);
}
}
if ($aliases) {
@@ -592,7 +592,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
$data[$table_alias][$column_real_name]['help'] = Markup::create($data[$table_alias][$column_real_name]['help'] . ' ' . t('Also known as:') . ' ' . implode(', ', $also_known));
}
- $data[$table_alias][$column_real_name]['argument'] = array(
+ $data[$table_alias][$column_real_name]['argument'] = [
'field' => $column_real_name,
'table' => $table,
'id' => $argument,
@@ -600,8 +600,8 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
'field_name' => $field_name,
'entity_type' => $entity_type_id,
'empty field name' => t('- No value -'),
- );
- $data[$table_alias][$column_real_name]['filter'] = array(
+ ];
+ $data[$table_alias][$column_real_name]['filter'] = [
'field' => $column_real_name,
'table' => $table,
'id' => $filter,
@@ -609,16 +609,16 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
'field_name' => $field_name,
'entity_type' => $entity_type_id,
'allow empty' => TRUE,
- );
+ ];
if (!empty($allow_sort)) {
- $data[$table_alias][$column_real_name]['sort'] = array(
+ $data[$table_alias][$column_real_name]['sort'] = [
'field' => $column_real_name,
'table' => $table,
'id' => $sort,
'additional fields' => $additional_fields,
'field_name' => $field_name,
'entity_type' => $entity_type_id,
- );
+ ];
}
// Set click sortable if there is a field definition.
@@ -628,19 +628,19 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
// Expose additional delta column for multiple value fields.
if ($field_storage->isMultiple()) {
- $title_delta = t('@label (@name:delta)', array('@label' => $label, '@name' => $field_name));
- $title_short_delta = t('@label:delta', array('@label' => $label));
+ $title_delta = t('@label (@name:delta)', ['@label' => $label, '@name' => $field_name]);
+ $title_short_delta = t('@label:delta', ['@label' => $label]);
- $data[$table_alias]['delta'] = array(
+ $data[$table_alias]['delta'] = [
'group' => $group,
'title' => $title_delta,
'title short' => $title_short_delta,
- 'help' => t('Delta - Appears in: @bundles.', array('@bundles' => implode(', ', $bundles_names))),
- );
- $data[$table_alias]['delta']['field'] = array(
+ 'help' => t('Delta - Appears in: @bundles.', ['@bundles' => implode(', ', $bundles_names)]),
+ ];
+ $data[$table_alias]['delta']['field'] = [
'id' => 'numeric',
- );
- $data[$table_alias]['delta']['argument'] = array(
+ ];
+ $data[$table_alias]['delta']['argument'] = [
'field' => 'delta',
'table' => $table,
'id' => 'numeric',
@@ -648,8 +648,8 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
'empty field name' => t('- No value -'),
'field_name' => $field_name,
'entity_type' => $entity_type_id,
- );
- $data[$table_alias]['delta']['filter'] = array(
+ ];
+ $data[$table_alias]['delta']['filter'] = [
'field' => 'delta',
'table' => $table,
'id' => 'numeric',
@@ -657,15 +657,15 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
'field_name' => $field_name,
'entity_type' => $entity_type_id,
'allow empty' => TRUE,
- );
- $data[$table_alias]['delta']['sort'] = array(
+ ];
+ $data[$table_alias]['delta']['sort'] = [
'field' => 'delta',
'table' => $table,
'id' => 'standard',
'additional fields' => $additional_fields,
'field_name' => $field_name,
'entity_type' => $entity_type_id,
- );
+ ];
}
}
}
@@ -704,30 +704,30 @@ function core_field_views_data(FieldStorageConfigInterface $field_storage) {
// Provide a relationship for the entity type with the entity reference
// field.
- $args = array(
+ $args = [
'@label' => $target_entity_type->getLabel(),
'@field_name' => $field_name,
- );
- $data[$table_name][$field_name]['relationship'] = array(
+ ];
+ $data[$table_name][$field_name]['relationship'] = [
'title' => t('@label referenced from @field_name', $args),
'label' => t('@field_name: @label', $args),
'group' => $entity_type->getLabel(),
- 'help' => t('Appears in: @bundles.', array('@bundles' => implode(', ', $field_storage->getBundles()))),
+ 'help' => t('Appears in: @bundles.', ['@bundles' => implode(', ', $field_storage->getBundles())]),
'id' => 'standard',
'base' => $target_base_table,
'entity type' => $target_entity_type_id,
'base field' => $target_entity_type->getKey('id'),
'relationship field' => $field_name . '_target_id',
- );
+ ];
// Provide a reverse relationship for the entity type that is referenced by
// the field.
$args['@entity'] = $entity_type->getLabel();
$args['@label'] = $target_entity_type->getLowercaseLabel();
$pseudo_field_name = 'reverse__' . $entity_type_id . '__' . $field_name;
- $data[$target_base_table][$pseudo_field_name]['relationship'] = array(
+ $data[$target_base_table][$pseudo_field_name]['relationship'] = [
'title' => t('@entity using @field_name', $args),
- 'label' => t('@field_name', array('@field_name' => $field_name)),
+ 'label' => t('@field_name', ['@field_name' => $field_name]),
'group' => $target_entity_type->getLabel(),
'help' => t('Relate each @entity with a @field_name set to the @label.', $args),
'id' => 'entity_reverse',
@@ -737,14 +737,14 @@ function core_field_views_data(FieldStorageConfigInterface $field_storage) {
'field_name' => $field_name,
'field table' => $table_mapping->getDedicatedDataTableName($field_storage),
'field field' => $field_name . '_target_id',
- 'join_extra' => array(
- array(
+ 'join_extra' => [
+ [
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
return $data;
diff --git a/core/modules/views/views.views_execution.inc b/core/modules/views/views.views_execution.inc
index 91dead539b8..8b324a359bf 100644
--- a/core/modules/views/views.views_execution.inc
+++ b/core/modules/views/views.views_execution.inc
@@ -18,10 +18,10 @@ use Drupal\views\Plugin\views\PluginBase;
* \Drupal\views\Plugin\views\PluginBase::listLanguages().
*/
function views_views_query_substitutions(ViewExecutable $view) {
- $substitutions = array(
+ $substitutions = [
'***CURRENT_VERSION***' => \Drupal::VERSION,
'***CURRENT_TIME***' => REQUEST_TIME,
- ) + PluginBase::queryLanguageSubstitutions();
+ ] + PluginBase::queryLanguageSubstitutions();
return $substitutions;
}
diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc
index fd031d2427b..a2d9fedcbc1 100644
--- a/core/modules/views_ui/admin.inc
+++ b/core/modules/views_ui/admin.inc
@@ -41,8 +41,8 @@ use Drupal\Core\Url;
* array('dynamic_content', 'section') for this parameter.
*/
function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_parents) {
- $seen_ids = &drupal_static(__FUNCTION__ . ':seen_ids', array());
- $seen_buttons = &drupal_static(__FUNCTION__ . ':seen_buttons', array());
+ $seen_ids = &drupal_static(__FUNCTION__ . ':seen_ids', []);
+ $seen_buttons = &drupal_static(__FUNCTION__ . ':seen_buttons', []);
// Add the AJAX behavior to the triggering element.
$triggering_element = &$wrapping_element[$trigger_key];
@@ -60,28 +60,28 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa
// should be displayed next to the triggering element on the form.
$button_key = $trigger_key . '_trigger_update';
$element_info = \Drupal::service('element_info');
- $wrapping_element[$button_key] = array(
+ $wrapping_element[$button_key] = [
'#type' => 'submit',
// Hide this button when JavaScript is enabled.
- '#attributes' => array('class' => array('js-hide')),
- '#submit' => array('views_ui_nojs_submit'),
+ '#attributes' => ['class' => ['js-hide']],
+ '#submit' => ['views_ui_nojs_submit'],
// Add a process function to limit this button's validation errors to the
// triggering element only. We have to do this in #process since until the
// form API has added the #parents property to the triggering element for
// us, we don't have any (easy) way to find out where its submitted values
// will eventually appear in $form_state->getValues().
- '#process' => array_merge(array('views_ui_add_limited_validation'), $element_info->getInfoProperty('submit', '#process', array())),
+ '#process' => array_merge(['views_ui_add_limited_validation'], $element_info->getInfoProperty('submit', '#process', [])),
// Add an after-build function that inserts a wrapper around the region of
// the form that needs to be refreshed by AJAX (so that the AJAX system can
// detect and dynamically update it). This is done in #after_build because
// it's a convenient place where we have automatic access to the complete
// form array, but also to minimize the chance that the HTML we add will
// get clobbered by code that runs after we have added it.
- '#after_build' => array_merge($element_info->getInfoProperty('submit', '#after_build', array()), array('views_ui_add_ajax_wrapper')),
- );
+ '#after_build' => array_merge($element_info->getInfoProperty('submit', '#after_build', []), ['views_ui_add_ajax_wrapper']),
+ ];
// Copy #weight and #access from the triggering element to the button, so
// that the two elements will be displayed together.
- foreach (array('#weight', '#access') as $property) {
+ foreach (['#weight', '#access'] as $property) {
if (isset($triggering_element[$property])) {
$wrapping_element[$button_key][$property] = $triggering_element[$property];
}
@@ -92,25 +92,25 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa
// key and it may be a TranslatableMarkup.
$button_title = !empty($triggering_element['#title']) ? (string) $triggering_element['#title'] : $trigger_key;
if (empty($seen_buttons[$button_title])) {
- $wrapping_element[$button_key]['#value'] = t('Update "@title" choice', array(
+ $wrapping_element[$button_key]['#value'] = t('Update "@title" choice', [
'@title' => $button_title,
- ));
+ ]);
$seen_buttons[$button_title] = 1;
}
else {
- $wrapping_element[$button_key]['#value'] = t('Update "@title" choice (@number)', array(
+ $wrapping_element[$button_key]['#value'] = t('Update "@title" choice (@number)', [
'@title' => $button_title,
'@number' => ++$seen_buttons[$button_title],
- ));
+ ]);
}
// Attach custom data to the triggering element and submit button, so we can
// use it in both the process function and AJAX callback.
- $ajax_data = array(
+ $ajax_data = [
'wrapper' => $triggering_element['#ajax']['wrapper'],
'trigger_key' => $trigger_key,
'refresh_parents' => $refresh_parents,
- );
+ ];
$seen_ids[$triggering_element['#ajax']['wrapper']] = TRUE;
$triggering_element['#views_ui_ajax_data'] = $ajax_data;
$wrapping_element[$button_key]['#views_ui_ajax_data'] = $ajax_data;
@@ -132,7 +132,7 @@ function views_ui_add_limited_validation($element, FormStateInterface $form_stat
// Limit this button's validation to the AJAX triggering element, so it can
// update the form for that change without requiring that the rest of the
// form be filled out properly yet.
- $element['#limit_validation_errors'] = array($ajax_triggering_element['#parents']);
+ $element['#limit_validation_errors'] = [$ajax_triggering_element['#parents']];
// If we are in the process of a form submission and this is the button that
// was clicked, the form API workflow in \Drupal::formBuilder()->doBuildForm()
@@ -165,10 +165,10 @@ function views_ui_add_ajax_wrapper($element, FormStateInterface $form_state) {
// The HTML ID that AJAX expects was also stored in a property on the
// element, so use that information to insert the wrapper <div> here.
$id = $element['#views_ui_ajax_data']['wrapper'];
- $refresh_element += array(
+ $refresh_element += [
'#prefix' => '',
'#suffix' => '',
- );
+ ];
$refresh_element['#prefix'] = '<div id="' . $id . '" class="views-ui-ajax-wrapper">' . $refresh_element['#prefix'];
$refresh_element['#suffix'] .= '</div>';
@@ -213,16 +213,16 @@ function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_sta
// @todo Move this to a separate function if it's needed on any forms that
// don't have the display dropdown.
- $form['override'] = array(
+ $form['override'] = [
'#prefix' => '<div class="views-override clearfix form--inline views-offset-top" data-drupal-views-offset="top">',
'#suffix' => '</div>',
'#weight' => -1000,
'#tree' => TRUE,
- );
+ ];
// Add the "2 of 3" progress indicator.
if ($form_progress = $view->getFormProgress()) {
- $form['progress']['#markup'] = '<div id="views-progress-indicator" class="views-progress-indicator">' . t('@current of @total', array('@current' => $form_progress['current'], '@total' => $form_progress['total'])) . '</div>';
+ $form['progress']['#markup'] = '<div id="views-progress-indicator" class="views-progress-indicator">' . t('@current of @total', ['@current' => $form_progress['current'], '@total' => $form_progress['total']]) . '</div>';
$form['progress']['#weight'] = -1001;
}
@@ -247,17 +247,17 @@ function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_sta
}
$display_dropdown['default'] = ($section_overrides ? t('All displays (except overridden)') : t('All displays'));
- $display_dropdown[$display_id] = t('This @display_type (override)', array('@display_type' => $current_display->getPluginId()));
+ $display_dropdown[$display_id] = t('This @display_type (override)', ['@display_type' => $current_display->getPluginId()]);
// Only display the revert option if we are in a overridden section.
if (!$section_defaulted) {
$display_dropdown['default_revert'] = t('Revert to default');
}
- $form['override']['dropdown'] = array(
+ $form['override']['dropdown'] = [
'#type' => 'select',
'#title' => t('For'), // @TODO: Translators may need more context than this.
'#options' => $display_dropdown,
- );
+ ];
if ($current_display->isDefaulted($section)) {
$form['override']['dropdown']['#default_value'] = 'defaults';
}
diff --git a/core/modules/views_ui/src/Ajax/SetFormCommand.php b/core/modules/views_ui/src/Ajax/SetFormCommand.php
index ffafde6c6f9..3910eb21982 100644
--- a/core/modules/views_ui/src/Ajax/SetFormCommand.php
+++ b/core/modules/views_ui/src/Ajax/SetFormCommand.php
@@ -32,10 +32,10 @@ class SetFormCommand implements CommandInterface {
* {@inheritdoc}
*/
public function render() {
- return array(
+ return [
'command' => 'viewsSetForm',
'url' => $this->url,
- );
+ ];
}
}
diff --git a/core/modules/views_ui/src/Controller/ViewsUIController.php b/core/modules/views_ui/src/Controller/ViewsUIController.php
index f36e912ad23..97947620742 100644
--- a/core/modules/views_ui/src/Controller/ViewsUIController.php
+++ b/core/modules/views_ui/src/Controller/ViewsUIController.php
@@ -58,7 +58,7 @@ class ViewsUIController extends ControllerBase {
// Fetch all fieldapi fields which are used in views
// Therefore search in all views, displays and handler-types.
- $fields = array();
+ $fields = [];
$handler_types = ViewExecutable::getHandlerTypes();
foreach ($views as $view) {
$executable = $view->getExecutable();
@@ -81,12 +81,12 @@ class ViewsUIController extends ControllerBase {
}
}
- $header = array(t('Field name'), t('Used in'));
- $rows = array();
+ $header = [t('Field name'), t('Used in')];
+ $rows = [];
foreach ($fields as $field_name => $views) {
$rows[$field_name]['data'][0]['data']['#plain_text'] = $field_name;
foreach ($views as $view) {
- $rows[$field_name]['data'][1][] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view)));
+ $rows[$field_name]['data'][1][] = $this->l($view, new Url('entity.view.edit_form', ['view' => $view]));
}
$item_list = [
'#theme' => 'item_list',
@@ -98,12 +98,12 @@ class ViewsUIController extends ControllerBase {
// Sort rows by field name.
ksort($rows);
- $output = array(
+ $output = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No fields have been used in views yet.'),
- );
+ ];
return $output;
}
@@ -120,7 +120,7 @@ class ViewsUIController extends ControllerBase {
$views = [];
// Link each view name to the view itself.
foreach ($row['views'] as $row_name => $view) {
- $views[] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view)));
+ $views[] = $this->l($view, new Url('entity.view.edit_form', ['view' => $view]));
}
unset($row['views']);
$row['views']['data'] = [
@@ -132,12 +132,12 @@ class ViewsUIController extends ControllerBase {
// Sort rows by field name.
ksort($rows);
- return array(
+ return [
'#type' => 'table',
- '#header' => array(t('Type'), t('Name'), t('Provided by'), t('Used in')),
+ '#header' => [t('Type'), t('Name'), t('Provided by'), t('Used in')],
'#rows' => $rows,
'#empty' => t('There are no enabled views.'),
- );
+ ];
}
/**
@@ -180,7 +180,7 @@ class ViewsUIController extends ControllerBase {
* A JSON response containing the autocomplete suggestions for Views tags.
*/
public function autocompleteTag(Request $request) {
- $matches = array();
+ $matches = [];
$string = $request->query->get('q');
// Get matches from default views.
$views = $this->entityManager()->getStorage('view')->loadMultiple();
@@ -223,8 +223,8 @@ class ViewsUIController extends ControllerBase {
}
$build['#title'] = $name;
- $build['edit'] = $this->entityFormBuilder()->getForm($view, 'edit', array('display_id' => $display_id));
- $build['preview'] = $this->entityFormBuilder()->getForm($view, 'preview', array('display_id' => $display_id));
+ $build['edit'] = $this->entityFormBuilder()->getForm($view, 'edit', ['display_id' => $display_id]);
+ $build['preview'] = $this->entityFormBuilder()->getForm($view, 'preview', ['display_id' => $display_id]);
return $build;
}
diff --git a/core/modules/views_ui/src/Form/AdvancedSettingsForm.php b/core/modules/views_ui/src/Form/AdvancedSettingsForm.php
index 88661a775a1..36f34c26a1f 100644
--- a/core/modules/views_ui/src/Form/AdvancedSettingsForm.php
+++ b/core/modules/views_ui/src/Form/AdvancedSettingsForm.php
@@ -32,52 +32,52 @@ class AdvancedSettingsForm extends ConfigFormBase {
$form = parent::buildForm($form, $form_state);
$config = $this->config('views.settings');
- $form['cache'] = array(
+ $form['cache'] = [
'#type' => 'details',
'#title' => $this->t('Caching'),
'#open' => TRUE,
- );
+ ];
- $form['cache']['skip_cache'] = array(
+ $form['cache']['skip_cache'] = [
'#type' => 'checkbox',
'#title' => $this->t('Disable views data caching'),
'#description' => $this->t("Views caches data about tables, modules and views available, to increase performance. By checking this box, Views will skip this cache and always rebuild this data when needed. This can have a serious performance impact on your site."),
'#default_value' => $config->get('skip_cache'),
- );
+ ];
- $form['cache']['clear_cache'] = array(
+ $form['cache']['clear_cache'] = [
'#type' => 'submit',
'#value' => $this->t("Clear Views' cache"),
- '#submit' => array('::cacheSubmit'),
- );
+ '#submit' => ['::cacheSubmit'],
+ ];
- $form['debug'] = array(
+ $form['debug'] = [
'#type' => 'details',
'#title' => $this->t('Debugging'),
'#open' => TRUE,
- );
+ ];
- $form['debug']['sql_signature'] = array(
+ $form['debug']['sql_signature'] = [
'#type' => 'checkbox',
'#title' => $this->t('Add Views signature to all SQL queries'),
'#description' => $this->t("All Views-generated queries will include the name of the views and display 'view-name:display-name' as a string at the end of the SELECT clause. This makes identifying Views queries in database server logs simpler, but should only be used when troubleshooting."),
'#default_value' => $config->get('sql_signature'),
- );
+ ];
$options = Views::fetchPluginNames('display_extender');
if (!empty($options)) {
- $form['extenders'] = array(
+ $form['extenders'] = [
'#type' => 'details',
'#open' => TRUE,
- );
- $form['extenders']['display_extenders'] = array(
+ ];
+ $form['extenders']['display_extenders'] = [
'#title' => $this->t('Display extenders'),
'#default_value' => array_filter($config->get('display_extenders')),
'#options' => $options,
'#type' => 'checkboxes',
'#description' => $this->t('Select extensions of the views interface.')
- );
+ ];
}
return $form;
@@ -90,7 +90,7 @@ class AdvancedSettingsForm extends ConfigFormBase {
$this->config('views.settings')
->set('skip_cache', $form_state->getValue('skip_cache'))
->set('sql_signature', $form_state->getValue('sql_signature'))
- ->set('display_extenders', $form_state->getValue('display_extenders', array()))
+ ->set('display_extenders', $form_state->getValue('display_extenders', []))
->save();
parent::submitForm($form, $form_state);
diff --git a/core/modules/views_ui/src/Form/Ajax/AddHandler.php b/core/modules/views_ui/src/Form/Ajax/AddHandler.php
index ada0ccd347c..0a04000a6a1 100644
--- a/core/modules/views_ui/src/Form/Ajax/AddHandler.php
+++ b/core/modules/views_ui/src/Form/Ajax/AddHandler.php
@@ -49,16 +49,16 @@ class AddHandler extends ViewsFormBase {
$display_id = $form_state->get('display_id');
$type = $form_state->get('type');
- $form = array(
- 'options' => array(
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
- ),
- );
+ $form = [
+ 'options' => [
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
+ ],
+ ];
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
- $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
+ $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
return $form;
}
$display = &$executable->displayHandlers->get($display_id);
@@ -71,7 +71,7 @@ class AddHandler extends ViewsFormBase {
$type = $types[$type]['type'];
}
- $form['#title'] = $this->t('Add @type', array('@type' => $ltitle));
+ $form['#title'] = $this->t('Add @type', ['@type' => $ltitle]);
$form['#section'] = $display_id . 'add-handler';
// Add the display override dropdown.
@@ -82,36 +82,36 @@ class AddHandler extends ViewsFormBase {
$options = Views::viewsDataHelper()->fetchFields(array_keys($base_tables), $type, $display->useGroupBy(), $form_state->get('type'));
if (!empty($options)) {
- $form['override']['controls'] = array(
- '#theme_wrappers' => array('container'),
+ $form['override']['controls'] = [
+ '#theme_wrappers' => ['container'],
'#id' => 'views-filterable-options-controls',
'#attributes' => ['class' => ['form--inline', 'views-filterable-options-controls']],
- );
- $form['override']['controls']['options_search'] = array(
+ ];
+ $form['override']['controls']['options_search'] = [
'#type' => 'textfield',
'#title' => $this->t('Search'),
- );
+ ];
- $groups = array('all' => $this->t('- All -'));
- $form['override']['controls']['group'] = array(
+ $groups = ['all' => $this->t('- All -')];
+ $form['override']['controls']['group'] = [
'#type' => 'select',
'#title' => $this->t('Category'),
- '#options' => array(),
- );
+ '#options' => [],
+ ];
- $form['options']['name'] = array(
+ $form['options']['name'] = [
'#prefix' => '<div class="views-radio-box form-checkboxes views-filterable-options">',
'#suffix' => '</div>',
'#type' => 'tableselect',
- '#header' => array(
+ '#header' => [
'title' => $this->t('Title'),
'group' => $this->t('Category'),
'help' => $this->t('Description'),
- ),
+ ],
'#js_select' => FALSE,
- );
+ ];
- $grouped_options = array();
+ $grouped_options = [];
foreach ($options as $key => $option) {
$group = preg_replace('/[^a-z0-9]/', '-', strtolower($option['group']));
$groups[$group] = $option['group'];
@@ -136,50 +136,50 @@ class AddHandler extends ViewsFormBase {
foreach ($grouped_options as $group => $group_options) {
foreach ($group_options as $key => $option) {
- $form['options']['name']['#options'][$key] = array(
- '#attributes' => array(
- 'class' => array('filterable-option', $group),
- ),
- 'title' => array(
- 'data' => array(
+ $form['options']['name']['#options'][$key] = [
+ '#attributes' => [
+ 'class' => ['filterable-option', $group],
+ ],
+ 'title' => [
+ 'data' => [
'#title' => $option['title'],
'#plain_text' => $option['title'],
- ),
- 'class' => array('title'),
- ),
+ ],
+ 'class' => ['title'],
+ ],
'group' => $option['group'],
- 'help' => array(
+ 'help' => [
'data' => $option['help'],
- 'class' => array('description'),
- ),
- );
+ 'class' => ['description'],
+ ],
+ ];
}
}
$form['override']['controls']['group']['#options'] = $groups;
}
else {
- $form['options']['markup'] = array(
- '#markup' => '<div class="js-form-item form-item">' . $this->t('There are no @types available to add.', array('@types' => $ltitle)) . '</div>',
- );
+ $form['options']['markup'] = [
+ '#markup' => '<div class="js-form-item form-item">' . $this->t('There are no @types available to add.', ['@types' => $ltitle]) . '</div>',
+ ];
}
// Add a div to show the selected items
- $form['selected'] = array(
+ $form['selected'] = [
'#type' => 'item',
'#markup' => '<span class="views-ui-view-title">' . $this->t('Selected:') . '</span> ' . '<div class="views-selected-options"></div>',
- '#theme_wrappers' => array('form_element', 'views_ui_container'),
- '#attributes' => array(
- 'class' => array('container-inline', 'views-add-form-selected', 'views-offset-bottom'),
+ '#theme_wrappers' => ['form_element', 'views_ui_container'],
+ '#attributes' => [
+ 'class' => ['container-inline', 'views-add-form-selected', 'views-offset-bottom'],
'data-drupal-views-offset' => 'bottom',
- ),
- );
- $view->getStandardButtons($form, $form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', array('@types' => $ltitle)));
+ ],
+ ];
+ $view->getStandardButtons($form, $form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', ['@types' => $ltitle]));
// Remove the default submit function.
$form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit'], function($var) {
return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit');
});
- $form['actions']['submit']['#submit'][] = array($view, 'submitItemAdd');
+ $form['actions']['submit']['#submit'][] = [$view, 'submitItemAdd'];
return $form;
}
diff --git a/core/modules/views_ui/src/Form/Ajax/Analyze.php b/core/modules/views_ui/src/Form/Ajax/Analyze.php
index 458575d37cb..52784d3d3c5 100644
--- a/core/modules/views_ui/src/Form/Ajax/Analyze.php
+++ b/core/modules/views_ui/src/Form/Ajax/Analyze.php
@@ -36,11 +36,11 @@ class Analyze extends ViewsFormBase {
$analyzer = Views::analyzer();
$messages = $analyzer->getMessages($view->getExecutable());
- $form['analysis'] = array(
+ $form['analysis'] = [
'#prefix' => '<div class="js-form-item form-item">',
'#suffix' => '</div>',
'#markup' => $analyzer->formatMessages($messages),
- );
+ ];
// Inform the standard button function that we want an OK button.
$form_state->set('ok_button', TRUE);
diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php
index 819cb755b39..972b4b940fd 100644
--- a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php
+++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php
@@ -54,17 +54,17 @@ class ConfigHandler extends ViewsFormBase {
$type = $form_state->get('type');
$id = $form_state->get('id');
- $form = array(
- 'options' => array(
+ $form = [
+ 'options' => [
'#tree' => TRUE,
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
- ),
- );
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
+ ],
+ ];
$executable = $view->getExecutable();
$save_ui_cache = FALSE;
if (!$executable->setDisplay($display_id)) {
- $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
+ $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
return $form;
}
$item = $executable->getHandler($display_id, $type, $id);
@@ -72,7 +72,7 @@ class ConfigHandler extends ViewsFormBase {
if ($item) {
$handler = $executable->display_handler->getHandler($type, $id);
if (empty($handler)) {
- $form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
+ $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
}
else {
$types = ViewExecutable::getHandlerTypes();
@@ -88,7 +88,7 @@ class ConfigHandler extends ViewsFormBase {
// A whole bunch of code to figure out what relationships are valid for
// this item.
$relationships = $executable->display_handler->getOption('relationships');
- $relationship_options = array();
+ $relationship_options = [];
foreach ($relationships as $relationship) {
// relationships can't link back to self. But also, due to ordering,
@@ -118,7 +118,7 @@ class ConfigHandler extends ViewsFormBase {
// it to none.
$base_fields = Views::viewsDataHelper()->fetchFields($view->get('base_table'), $type, $executable->display_handler->useGroupBy());
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
- $relationship_options = array_merge(array('none' => $this->t('Do not use a relationship')), $relationship_options);
+ $relationship_options = array_merge(['none' => $this->t('Do not use a relationship')], $relationship_options);
}
$rel = empty($item['relationship']) ? 'none' : $item['relationship'];
if (empty($relationship_options[$rel])) {
@@ -133,30 +133,30 @@ class ConfigHandler extends ViewsFormBase {
$handler->init($executable, $executable->display_handler, $item);
}
- $form['options']['relationship'] = array(
+ $form['options']['relationship'] = [
'#type' => 'select',
'#title' => $this->t('Relationship'),
'#options' => $relationship_options,
'#default_value' => $rel,
'#weight' => -500,
- );
+ ];
}
else {
- $form['options']['relationship'] = array(
+ $form['options']['relationship'] = [
'#type' => 'value',
'#value' => 'none',
- );
+ ];
}
- $form['#title'] = $this->t('Configure @type: @item', array('@type' => $types[$type]['lstitle'], '@item' => $handler->adminLabel()));
+ $form['#title'] = $this->t('Configure @type: @item', ['@type' => $types[$type]['lstitle'], '@item' => $handler->adminLabel()]);
if (!empty($handler->definition['help'])) {
- $form['options']['form_description'] = array(
+ $form['options']['form_description'] = [
'#markup' => $handler->definition['help'],
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('js-form-item form-item description')),
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['js-form-item form-item description']],
'#weight' => -1000,
- );
+ ];
}
$form['#section'] = $display_id . '-' . $type . '-' . $id;
@@ -170,13 +170,13 @@ class ConfigHandler extends ViewsFormBase {
$view->getStandardButtons($form, $form_state, 'views_ui_config_item_form', $name);
// Add a 'remove' button.
- $form['actions']['remove'] = array(
+ $form['actions']['remove'] = [
'#type' => 'submit',
'#value' => $this->t('Remove'),
- '#submit' => array(array($this, 'remove')),
- '#limit_validation_errors' => array(array('override')),
+ '#submit' => [[$this, 'remove']],
+ '#limit_validation_errors' => [['override']],
'#button_type' => 'danger',
- );
+ ];
}
if ($save_ui_cache) {
diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php
index 0c10fb1faf9..a79d03142eb 100644
--- a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php
+++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php
@@ -51,16 +51,16 @@ class ConfigHandlerExtra extends ViewsFormBase {
$type = $form_state->get('type');
$id = $form_state->get('id');
- $form = array(
- 'options' => array(
+ $form = [
+ 'options' => [
'#tree' => TRUE,
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
- ),
- );
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
+ ],
+ ];
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
- $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
+ $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
return $form;
}
$item = $executable->getHandler($display_id, $type, $id);
@@ -68,13 +68,13 @@ class ConfigHandlerExtra extends ViewsFormBase {
if ($item) {
$handler = $executable->display_handler->getHandler($type, $id);
if (empty($handler)) {
- $form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
+ $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
}
else {
$handler->init($executable, $executable->display_handler, $item);
$types = ViewExecutable::getHandlerTypes();
- $form['#title'] = $this->t('Configure extra settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
+ $form['#title'] = $this->t('Configure extra settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);
$form['#section'] = $display_id . '-' . $type . '-' . $id;
diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php
index e7c7a839334..b4d0f136b88 100644
--- a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php
+++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php
@@ -52,16 +52,16 @@ class ConfigHandlerGroup extends ViewsFormBase {
$type = $form_state->get('type');
$id = $form_state->get('id');
- $form = array(
- 'options' => array(
+ $form = [
+ 'options' => [
'#tree' => TRUE,
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
- ),
- );
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
+ ],
+ ];
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
- $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
+ $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
return $form;
}
@@ -72,13 +72,13 @@ class ConfigHandlerGroup extends ViewsFormBase {
if ($item) {
$handler = $executable->display_handler->getHandler($type, $id);
if (empty($handler)) {
- $form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
+ $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
}
else {
$handler->init($executable, $executable->display_handler, $item);
$types = ViewExecutable::getHandlerTypes();
- $form['#title'] = $this->t('Configure aggregation settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
+ $form['#title'] = $this->t('Configure aggregation settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);
$handler->buildGroupByForm($form['options'], $form_state);
$form_state->set('handler', $handler);
diff --git a/core/modules/views_ui/src/Form/Ajax/Display.php b/core/modules/views_ui/src/Form/Ajax/Display.php
index bd129af1e89..302d75959eb 100644
--- a/core/modules/views_ui/src/Form/Ajax/Display.php
+++ b/core/modules/views_ui/src/Form/Ajax/Display.php
@@ -60,15 +60,15 @@ class Display extends ViewsFormBase {
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
- $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
+ $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
return $form;
}
// Get form from the handler.
- $form['options'] = array(
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
- );
+ $form['options'] = [
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
+ ];
$executable->display_handler->buildOptionsForm($form['options'], $form_state);
// The handler options form sets $form['#title'], which we need on the entire
diff --git a/core/modules/views_ui/src/Form/Ajax/EditDetails.php b/core/modules/views_ui/src/Form/Ajax/EditDetails.php
index ced404426ee..07b1625a8d4 100644
--- a/core/modules/views_ui/src/Form/Ajax/EditDetails.php
+++ b/core/modules/views_ui/src/Form/Ajax/EditDetails.php
@@ -33,33 +33,33 @@ class EditDetails extends ViewsFormBase {
$form['#title'] = $this->t('Name and description');
$form['#section'] = 'details';
- $form['details'] = array(
- '#theme_wrappers' => array('container'),
- '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
- );
- $form['details']['label'] = array(
+ $form['details'] = [
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
+ ];
+ $form['details']['label'] = [
'#type' => 'textfield',
'#title' => t('Administrative name'),
'#default_value' => $view->label(),
- );
- $form['details']['langcode'] = array(
+ ];
+ $form['details']['langcode'] = [
'#type' => 'language_select',
'#title' => $this->t('View language'),
'#description' => $this->t('Language of labels and other textual elements in this view.'),
'#default_value' => $view->get('langcode'),
- );
- $form['details']['description'] = array(
+ ];
+ $form['details']['description'] = [
'#type' => 'textfield',
'#title' => t('Administrative description'),
'#default_value' => $view->get('description'),
- );
- $form['details']['tag'] = array(
+ ];
+ $form['details']['tag'] = [
'#type' => 'textfield',
'#title' => t('Administrative tags'),
'#description' => t('Enter a comma-separated list of words to describe your view.'),
'#default_value' => $view->get('tag'),
'#autocomplete_route_name' => 'views_ui.autocomplete',
- );
+ ];
$view->getStandardButtons($form, $form_state, 'views_ui_edit_details_form');
return $form;
diff --git a/core/modules/views_ui/src/Form/Ajax/Rearrange.php b/core/modules/views_ui/src/Form/Ajax/Rearrange.php
index 04877695013..2a46120c603 100644
--- a/core/modules/views_ui/src/Form/Ajax/Rearrange.php
+++ b/core/modules/views_ui/src/Form/Ajax/Rearrange.php
@@ -53,11 +53,11 @@ class Rearrange extends ViewsFormBase {
$types = ViewExecutable::getHandlerTypes();
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
- $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
+ $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
return $form;
}
$display = &$executable->displayHandlers->get($display_id);
- $form['#title'] = $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle']));
+ $form['#title'] = $this->t('Rearrange @type', ['@type' => $types[$type]['ltitle']]);
$form['#section'] = $display_id . 'rearrange-item';
if ($display->defaultableSections($types[$type]['plural'])) {
@@ -69,31 +69,31 @@ class Rearrange extends ViewsFormBase {
$count = 0;
// Get relationship labels
- $relationships = array();
+ $relationships = [];
foreach ($display->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->adminLabel();
}
- $form['fields'] = array(
+ $form['fields'] = [
'#type' => 'table',
- '#header' => array('', $this->t('Weight'), $this->t('Remove')),
+ '#header' => ['', $this->t('Weight'), $this->t('Remove')],
'#empty' => $this->t('No fields available.'),
- '#tabledrag' => array(
- array(
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'weight',
- )
- ),
+ ]
+ ],
'#tree' => TRUE,
'#prefix' => '<div class="scroll" data-drupal-views-scroll>',
'#suffix' => '</div>',
- );
+ ];
foreach ($display->getOption($types[$type]['plural']) as $id => $field) {
- $form['fields'][$id] = array();
+ $form['fields'][$id] = [];
- $form['fields'][$id]['#attributes'] = array('class' => array('draggable'), 'id' => 'views-row-' . $id);
+ $form['fields'][$id]['#attributes'] = ['class' => ['draggable'], 'id' => 'views-row-' . $id];
$handler = $display->getHandler($type, $id);
if ($handler) {
@@ -105,34 +105,34 @@ class Rearrange extends ViewsFormBase {
}
else {
$name = $id;
- $markup = $this->t('Broken field @id', array('@id' => $id));
+ $markup = $this->t('Broken field @id', ['@id' => $id]);
}
- $form['fields'][$id]['name'] = array('#markup' => $markup);
+ $form['fields'][$id]['name'] = ['#markup' => $markup];
- $form['fields'][$id]['weight'] = array(
+ $form['fields'][$id]['weight'] = [
'#type' => 'textfield',
'#default_value' => ++$count,
- '#attributes' => array('class' => array('weight')),
- '#title' => t('Weight for @title', array('@title' => $name)),
+ '#attributes' => ['class' => ['weight']],
+ '#title' => t('Weight for @title', ['@title' => $name]),
'#title_display' => 'invisible',
- );
+ ];
- $form['fields'][$id]['removed'] = array(
+ $form['fields'][$id]['removed'] = [
'#type' => 'checkbox',
- '#title' => t('Remove @title', array('@title' => $name)),
+ '#title' => t('Remove @title', ['@title' => $name]),
'#title_display' => 'invisible',
'#id' => 'views-removed-' . $id,
- '#attributes' => array('class' => array('views-remove-checkbox')),
+ '#attributes' => ['class' => ['views-remove-checkbox']],
'#default_value' => 0,
- '#suffix' => \Drupal::l(SafeMarkup::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
- Url::fromRoute('<none>', array(), array('attributes' => array(
+ '#suffix' => \Drupal::l(SafeMarkup::format('<span>@text</span>', ['@text' => $this->t('Remove')]),
+ Url::fromRoute('<none>', [], ['attributes' => [
'id' => 'views-remove-link-' . $id,
- 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'),
+ 'class' => ['views-hidden', 'views-button-remove', 'views-remove-link'],
'alt' => $this->t('Remove this item'),
- 'title' => $this->t('Remove this item')),
- ))
+ 'title' => $this->t('Remove this item')],
+ ])
),
- );
+ ];
}
$view->getStandardButtons($form, $form_state, 'views_ui_rearrange_form');
@@ -152,7 +152,7 @@ class Rearrange extends ViewsFormBase {
$display = &$view->getExecutable()->displayHandlers->get($display_id);
$old_fields = $display->getOption($types[$type]['plural']);
- $new_fields = $order = array();
+ $new_fields = $order = [];
// Make an array with the weights
foreach ($form_state->getValue('fields') as $field => $info) {
diff --git a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php
index ea2235b7bb7..32986810512 100644
--- a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php
+++ b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php
@@ -43,12 +43,12 @@ class RearrangeFilter extends ViewsFormBase {
$types = ViewExecutable::getHandlerTypes();
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
- $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
+ $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
return $form;
}
$display = $executable->displayHandlers->get($display_id);
$form['#title'] = Html::escape($display->display['display_title']) . ': ';
- $form['#title'] .= $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle']));
+ $form['#title'] .= $this->t('Rearrange @type', ['@type' => $types[$type]['ltitle']]);
$form['#section'] = $display_id . 'rearrange-item';
if ($display->defaultableSections($types[$type]['plural'])) {
@@ -68,12 +68,12 @@ class RearrangeFilter extends ViewsFormBase {
$count = 0;
// Get relationship labels
- $relationships = array();
+ $relationships = [];
foreach ($display->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->adminLabel();
}
- $group_options = array();
+ $group_options = [];
/**
* Filter groups is an array that contains:
@@ -88,59 +88,59 @@ class RearrangeFilter extends ViewsFormBase {
$grouping = count(array_keys($groups['groups'])) > 1;
$form['filter_groups']['#tree'] = TRUE;
- $form['filter_groups']['operator'] = array(
+ $form['filter_groups']['operator'] = [
'#type' => 'select',
- '#options' => array(
+ '#options' => [
'AND' => $this->t('And'),
'OR' => $this->t('Or'),
- ),
+ ],
'#default_value' => $groups['operator'],
- '#attributes' => array(
- 'class' => array('warning-on-change'),
- ),
+ '#attributes' => [
+ 'class' => ['warning-on-change'],
+ ],
'#title' => $this->t('Operator to use on all groups'),
'#description' => $this->t('Either "group 0 AND group 1 AND group 2" or "group 0 OR group 1 OR group 2", etc'),
'#access' => $grouping,
- );
+ ];
$form['remove_groups']['#tree'] = TRUE;
foreach ($groups['groups'] as $id => $group) {
- $form['filter_groups']['groups'][$id] = array(
+ $form['filter_groups']['groups'][$id] = [
'#title' => $this->t('Operator'),
'#type' => 'select',
- '#options' => array(
+ '#options' => [
'AND' => $this->t('And'),
'OR' => $this->t('Or'),
- ),
+ ],
'#default_value' => $group,
- '#attributes' => array(
- 'class' => array('warning-on-change'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['warning-on-change'],
+ ],
+ ];
- $form['remove_groups'][$id] = array(); // to prevent a notice
+ $form['remove_groups'][$id] = []; // to prevent a notice
if ($id != 1) {
- $form['remove_groups'][$id] = array(
+ $form['remove_groups'][$id] = [
'#type' => 'submit',
- '#value' => $this->t('Remove group @group', array('@group' => $id)),
+ '#value' => $this->t('Remove group @group', ['@group' => $id]),
'#id' => "views-remove-group-$id",
- '#attributes' => array(
- 'class' => array('views-remove-group'),
- ),
+ '#attributes' => [
+ 'class' => ['views-remove-group'],
+ ],
'#group' => $id,
'#ajax' => ['url' => NULL],
- );
+ ];
}
- $group_options[$id] = $id == 1 ? $this->t('Default group') : $this->t('Group @group', array('@group' => $id));
- $form['#group_renders'][$id] = array();
+ $group_options[$id] = $id == 1 ? $this->t('Default group') : $this->t('Group @group', ['@group' => $id]);
+ $form['#group_renders'][$id] = [];
}
$form['#group_options'] = $group_options;
$form['#groups'] = $groups;
// We don't use getHandlers() because we want items without handlers to
// appear and show up as 'broken' so that the user can see them.
- $form['filters'] = array('#tree' => TRUE);
+ $form['filters'] = ['#tree' => TRUE];
foreach ($handlers as $id => $field) {
// If the group does not exist, move the filters to the default group.
if (empty($field['group']) || empty($groups['groups'][$field['group']])) {
@@ -162,24 +162,24 @@ class RearrangeFilter extends ViewsFormBase {
// Place this item into the proper group for rendering.
$form['#group_renders'][$field['group']][] = $id;
- $form['filters'][$id]['weight'] = array(
- '#title' => t('Weight for @id', array('@id' => $id)),
+ $form['filters'][$id]['weight'] = [
+ '#title' => t('Weight for @id', ['@id' => $id]),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#default_value' => ++$count,
'#size' => 8,
- );
- $form['filters'][$id]['group'] = array(
- '#title' => t('Group for @id', array('@id' => $id)),
+ ];
+ $form['filters'][$id]['group'] = [
+ '#title' => t('Group for @id', ['@id' => $id]),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => $group_options,
'#default_value' => $field['group'],
- '#attributes' => array(
- 'class' => array('views-region-select', 'views-region-' . $id),
- ),
+ '#attributes' => [
+ 'class' => ['views-region-select', 'views-region-' . $id],
+ ],
'#access' => $field['group'] !== 'ungroupable',
- );
+ ];
if ($handler) {
$name = $handler->adminLabel() . ' ' . $handler->adminSummary();
@@ -187,34 +187,34 @@ class RearrangeFilter extends ViewsFormBase {
$name = '(' . $relationships[$field['relationship']] . ') ' . $name;
}
- $form['filters'][$id]['name'] = array(
+ $form['filters'][$id]['name'] = [
'#markup' => $name,
- );
+ ];
}
else {
- $form['filters'][$id]['name'] = array('#markup' => $this->t('Broken field @id', array('@id' => $id)));
+ $form['filters'][$id]['name'] = ['#markup' => $this->t('Broken field @id', ['@id' => $id])];
}
- $form['filters'][$id]['removed'] = array(
- '#title' => t('Remove @id', array('@id' => $id)),
+ $form['filters'][$id]['removed'] = [
+ '#title' => t('Remove @id', ['@id' => $id]),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#id' => 'views-removed-' . $id,
- '#attributes' => array('class' => array('views-remove-checkbox')),
+ '#attributes' => ['class' => ['views-remove-checkbox']],
'#default_value' => 0,
- );
+ ];
}
$view->getStandardButtons($form, $form_state, 'views_ui_rearrange_filter_form');
- $form['actions']['add_group'] = array(
+ $form['actions']['add_group'] = [
'#type' => 'submit',
'#value' => $this->t('Create new filter group'),
'#id' => 'views-add-group',
'#group' => 'add',
- '#attributes' => array(
- 'class' => array('views-add-group'),
- ),
+ '#attributes' => [
+ 'class' => ['views-add-group'],
+ ],
'#ajax' => ['url' => NULL],
- );
+ ];
return $form;
}
@@ -226,7 +226,7 @@ class RearrangeFilter extends ViewsFormBase {
$types = ViewExecutable::getHandlerTypes();
$view = $form_state->get('view');
$display = &$view->getExecutable()->displayHandlers->get($form_state->get('display_id'));
- $remember_groups = array();
+ $remember_groups = [];
if (!empty($view->form_cache)) {
$old_fields = $view->form_cache['handlers'];
@@ -237,7 +237,7 @@ class RearrangeFilter extends ViewsFormBase {
$groups = $form_state->getValue('filter_groups');
// Whatever button was clicked, re-calculate field information.
- $new_fields = $order = array();
+ $new_fields = $order = [];
// Make an array with the weights
foreach ($form_state->getValue('filters') as $field => $info) {
diff --git a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php
index 7d1285f80da..377a3d55c23 100644
--- a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php
+++ b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php
@@ -40,10 +40,10 @@ class ReorderDisplays extends ViewsFormBase {
'view' => $view->id(),
'display_id' => $display_id,
]);
- $form['view'] = array(
+ $form['view'] = [
'#type' => 'value',
'#value' => $view
- );
+ ];
$displays = $view->get('display');
$count = count($displays);
@@ -56,82 +56,82 @@ class ReorderDisplays extends ViewsFormBase {
return 0;
});
- $form['displays'] = array(
+ $form['displays'] = [
'#type' => 'table',
'#id' => 'reorder-displays',
- '#header' => array($this->t('Display'), $this->t('Weight'), $this->t('Remove')),
+ '#header' => [$this->t('Display'), $this->t('Weight'), $this->t('Remove')],
'#empty' => $this->t('No displays available.'),
- '#tabledrag' => array(
- array(
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'weight',
- )
- ),
+ ]
+ ],
'#tree' => TRUE,
'#prefix' => '<div class="scroll" data-drupal-views-scroll>',
'#suffix' => '</div>',
- );
+ ];
foreach ($displays as $id => $display) {
- $form['displays'][$id] = array(
+ $form['displays'][$id] = [
'#display' => $display,
- '#attributes' => array(
+ '#attributes' => [
'id' => 'display-row-' . $id,
- ),
+ ],
'#weight' => $display['position'],
- );
+ ];
// Only make row draggable if it's not the default display.
if ($id !== 'default') {
$form['displays'][$id]['#attributes']['class'][] = 'draggable';
}
- $form['displays'][$id]['title'] = array(
+ $form['displays'][$id]['title'] = [
'#markup' => $display['display_title'],
- );
+ ];
- $form['displays'][$id]['weight'] = array(
+ $form['displays'][$id]['weight'] = [
'#type' => 'weight',
'#value' => $display['position'],
'#delta' => $count,
- '#title' => $this->t('Weight for @display', array('@display' => $display['display_title'])),
+ '#title' => $this->t('Weight for @display', ['@display' => $display['display_title']]),
'#title_display' => 'invisible',
- '#attributes' => array(
- 'class' => array('weight'),
- ),
- );
-
- $form['displays'][$id]['removed'] = array(
- 'checkbox' => array(
- '#title' => t('Remove @id', array('@id' => $id)),
+ '#attributes' => [
+ 'class' => ['weight'],
+ ],
+ ];
+
+ $form['displays'][$id]['removed'] = [
+ 'checkbox' => [
+ '#title' => t('Remove @id', ['@id' => $id]),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#id' => 'display-removed-' . $id,
- '#attributes' => array(
- 'class' => array('views-remove-checkbox'),
- ),
+ '#attributes' => [
+ 'class' => ['views-remove-checkbox'],
+ ],
'#default_value' => !empty($display['deleted']),
- ),
- 'link' => array(
+ ],
+ 'link' => [
'#type' => 'link',
- '#title' => SafeMarkup::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
+ '#title' => SafeMarkup::format('<span>@text</span>', ['@text' => $this->t('Remove')]),
'#url' => Url::fromRoute('<none>'),
- '#attributes' => array(
+ '#attributes' => [
'id' => 'display-remove-link-' . $id,
- 'class' => array('views-button-remove', 'display-remove-link'),
+ 'class' => ['views-button-remove', 'display-remove-link'],
'alt' => $this->t('Remove this display'),
'title' => $this->t('Remove this display'),
- ),
- ),
+ ],
+ ],
'#access' => ($id !== 'default'),
- );
+ ];
if (!empty($display['deleted'])) {
- $form['displays'][$id]['deleted'] = array(
+ $form['displays'][$id]['deleted'] = [
'#type' => 'value',
'#value' => TRUE,
- );
+ ];
$form['displays'][$id]['#attributes']['class'][] = 'hidden';
}
@@ -149,7 +149,7 @@ class ReorderDisplays extends ViewsFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
/** @var $view \Drupal\views_ui\ViewUI */
$view = $form_state->get('view');
- $order = array();
+ $order = [];
$user_input = $form_state->getUserInput();
foreach ($user_input['displays'] as $display => $info) {
diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
index 93bd0498080..375766a4c3c 100644
--- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
+++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
@@ -108,7 +108,7 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
unset($view->stack[$key]);
if (array_shift($top) != $identifier) {
- $view->stack = array();
+ $view->stack = [];
}
}
@@ -138,7 +138,7 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
$form_state = $reflection->newInstanceArgs(array_slice($top, 3, 2))->getFormState($view, $top[2], $form_state->get('ajax'));
$form_class = get_class($form_state->getFormObject());
- $form_state->setUserInput(array());
+ $form_state->setUserInput([]);
$form_url = views_ui_build_form_url($form_state);
if (!$form_state->get('ajax')) {
return new RedirectResponse($form_url->setAbsolute()->toString());
@@ -234,16 +234,16 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
$response->setAttachments($form['#attached']);
$display = '';
- $status_messages = array('#type' => 'status_messages');
+ $status_messages = ['#type' => 'status_messages'];
if ($messages = $renderer->renderRoot($status_messages)) {
$display = '<div class="views-messages">' . $messages . '</div>';
}
$display .= $output;
- $options = array(
+ $options = [
'dialogClass' => 'views-ui-dialog js-views-ui-dialog',
'width' => '75%',
- );
+ ];
$response->addCommand(new OpenModalDialogCommand($title, $display, $options));
diff --git a/core/modules/views_ui/src/Form/BasicSettingsForm.php b/core/modules/views_ui/src/Form/BasicSettingsForm.php
index 61501960074..bcd533662c5 100644
--- a/core/modules/views_ui/src/Form/BasicSettingsForm.php
+++ b/core/modules/views_ui/src/Form/BasicSettingsForm.php
@@ -65,7 +65,7 @@ class BasicSettingsForm extends ConfigFormBase {
$form = parent::buildForm($form, $form_state);
$config = $this->config('views.settings');
- $options = array();
+ $options = [];
foreach ($this->themeHandler->listInfo() as $name => $theme) {
if ($theme->status) {
$options[$name] = $theme->info['name'];
@@ -74,94 +74,94 @@ class BasicSettingsForm extends ConfigFormBase {
// This is not currently a fieldset but we may want it to be later,
// so this will make it easier to change if we do.
- $form['basic'] = array();
+ $form['basic'] = [];
- $form['basic']['ui_show_master_display'] = array(
+ $form['basic']['ui_show_master_display'] = [
'#type' => 'checkbox',
'#title' => $this->t('Always show the master (default) display'),
'#default_value' => $config->get('ui.show.master_display'),
- );
+ ];
- $form['basic']['ui_show_advanced_column'] = array(
+ $form['basic']['ui_show_advanced_column'] = [
'#type' => 'checkbox',
'#title' => $this->t('Always show advanced display settings'),
'#default_value' => $config->get('ui.show.advanced_column'),
- );
+ ];
- $form['basic']['ui_show_display_embed'] = array(
+ $form['basic']['ui_show_display_embed'] = [
'#type' => 'checkbox',
'#title' => t('Allow embedded displays'),
'#description' => t('Embedded displays can be used in code via views_embed_view().'),
'#default_value' => $config->get('ui.show.display_embed'),
- );
+ ];
- $form['basic']['ui_exposed_filter_any_label'] = array(
+ $form['basic']['ui_exposed_filter_any_label'] = [
'#type' => 'select',
'#title' => $this->t('Label for "Any" value on non-required single-select exposed filters'),
- '#options' => array('old_any' => '<Any>', 'new_any' => $this->t('- Any -')),
+ '#options' => ['old_any' => '<Any>', 'new_any' => $this->t('- Any -')],
'#default_value' => $config->get('ui.exposed_filter_any_label'),
- );
+ ];
- $form['live_preview'] = array(
+ $form['live_preview'] = [
'#type' => 'details',
'#title' => $this->t('Live preview settings'),
'#open' => TRUE,
- );
+ ];
- $form['live_preview']['ui_always_live_preview'] = array(
+ $form['live_preview']['ui_always_live_preview'] = [
'#type' => 'checkbox',
'#title' => $this->t('Automatically update preview on changes'),
'#default_value' => $config->get('ui.always_live_preview'),
- );
+ ];
- $form['live_preview']['ui_show_preview_information'] = array(
+ $form['live_preview']['ui_show_preview_information'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show information and statistics about the view during live preview'),
'#default_value' => $config->get('ui.show.preview_information'),
- );
+ ];
- $form['live_preview']['options'] = array(
+ $form['live_preview']['options'] = [
'#type' => 'container',
- '#states' => array(
- 'visible' => array(
- ':input[name="ui_show_preview_information"]' => array('checked' => TRUE),
- ),
- ),
- );
-
- $form['live_preview']['options']['ui_show_sql_query_enabled'] = array(
+ '#states' => [
+ 'visible' => [
+ ':input[name="ui_show_preview_information"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
+
+ $form['live_preview']['options']['ui_show_sql_query_enabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show the SQL query'),
'#default_value' => $config->get('ui.show.sql_query.enabled'),
- );
+ ];
- $form['live_preview']['options']['ui_show_sql_query_where'] = array(
+ $form['live_preview']['options']['ui_show_sql_query_where'] = [
'#type' => 'radios',
- '#states' => array(
- 'visible' => array(
- ':input[name="ui_show_sql_query_enabled"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="ui_show_sql_query_enabled"]' => ['checked' => TRUE],
+ ],
+ ],
'#title' => t('Show SQL query'),
- '#options' => array(
+ '#options' => [
'above' => $this->t('Above the preview'),
'below' => $this->t('Below the preview'),
- ),
+ ],
'#default_value' => $config->get('ui.show.sql_query.where'),
- );
+ ];
- $form['live_preview']['options']['ui_show_performance_statistics'] = array(
+ $form['live_preview']['options']['ui_show_performance_statistics'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show performance statistics'),
'#default_value' => $config->get('ui.show.performance_statistics'),
- );
+ ];
- $form['live_preview']['options']['ui_show_additional_queries'] = array(
+ $form['live_preview']['options']['ui_show_additional_queries'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show other queries run during render during live preview'),
'#description' => $this->t("Drupal has the potential to run many queries while a view is being rendered. Checking this box will display every query run during view render as part of the live preview."),
'#default_value' => $config->get('ui.show.additional_queries'),
- );
+ ];
return $form;
}
diff --git a/core/modules/views_ui/src/Form/BreakLockForm.php b/core/modules/views_ui/src/Form/BreakLockForm.php
index 12a3e3efb86..94a626f2734 100644
--- a/core/modules/views_ui/src/Form/BreakLockForm.php
+++ b/core/modules/views_ui/src/Form/BreakLockForm.php
@@ -61,7 +61,7 @@ class BreakLockForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Do you want to break the lock on view %name?', array('%name' => $this->entity->id()));
+ return $this->t('Do you want to break the lock on view %name?', ['%name' => $this->entity->id()]);
}
/**
@@ -70,11 +70,11 @@ class BreakLockForm extends EntityConfirmFormBase {
public function getDescription() {
$locked = $this->tempStore->getMetadata($this->entity->id());
$account = $this->entityManager->getStorage('user')->load($locked->owner);
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $account,
- );
- return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', array('@user' => drupal_render($username)));
+ ];
+ return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => drupal_render($username)]);
}
/**
@@ -96,7 +96,7 @@ class BreakLockForm extends EntityConfirmFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
if (!$this->tempStore->getMetadata($this->entity->id())) {
- $form['message']['#markup'] = $this->t('There is no lock on view %name to break.', array('%name' => $this->entity->id()));
+ $form['message']['#markup'] = $this->t('There is no lock on view %name to break.', ['%name' => $this->entity->id()]);
return $form;
}
return parent::buildForm($form, $form_state);
diff --git a/core/modules/views_ui/src/Tests/AnalyzeTest.php b/core/modules/views_ui/src/Tests/AnalyzeTest.php
index 6cc9203d070..ef1744b3b71 100644
--- a/core/modules/views_ui/src/Tests/AnalyzeTest.php
+++ b/core/modules/views_ui/src/Tests/AnalyzeTest.php
@@ -16,14 +16,14 @@ class AnalyzeTest extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('views_ui');
+ public static $modules = ['views_ui'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
protected function setUp() {
parent::setUp();
@@ -31,7 +31,7 @@ class AnalyzeTest extends ViewTestBase {
$this->enableViewsTestModule();
// Add an admin user will full rights;
- $this->admin = $this->drupalCreateUser(array('administer views'));
+ $this->admin = $this->drupalCreateUser(['administer views']);
}
/**
@@ -47,13 +47,13 @@ class AnalyzeTest extends ViewTestBase {
$this->clickLink(t('Analyze view'));
$this->assertText(t('View analysis'));
- foreach (array('ok', 'warning', 'error') as $type) {
- $xpath = $this->xpath('//div[contains(@class, :class)]', array(':class' => $type));
- $this->assertTrue(count($xpath), format_string('Analyse messages with @type found', array('@type' => $type)));
+ foreach (['ok', 'warning', 'error'] as $type) {
+ $xpath = $this->xpath('//div[contains(@class, :class)]', [':class' => $type]);
+ $this->assertTrue(count($xpath), format_string('Analyse messages with @type found', ['@type' => $type]));
}
// This redirects the user back to the main views edit page.
- $this->drupalPostForm(NULL, array(), t('Ok'));
+ $this->drupalPostForm(NULL, [], t('Ok'));
}
}
diff --git a/core/modules/views_ui/src/Tests/ArgumentValidatorTest.php b/core/modules/views_ui/src/Tests/ArgumentValidatorTest.php
index b62f876e52f..d94e682fb2b 100644
--- a/core/modules/views_ui/src/Tests/ArgumentValidatorTest.php
+++ b/core/modules/views_ui/src/Tests/ArgumentValidatorTest.php
@@ -16,7 +16,7 @@ class ArgumentValidatorTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_argument');
+ public static $testViews = ['test_argument'];
/**
* Tests the 'Specify validation criteria' checkbox functionality.
@@ -46,12 +46,12 @@ class ArgumentValidatorTest extends UITestBase {
* @param bool $specify_validation
*/
protected function saveArgumentHandlerWithValidationOptions($specify_validation) {
- $options = array(
+ $options = [
'options[validate][type]' => 'entity---node',
'options[specify_validation]' => $specify_validation,
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_argument/default/argument/id', $options, t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/test_argument', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/view/test_argument', [], t('Save'));
}
}
diff --git a/core/modules/views_ui/src/Tests/CachedDataUITest.php b/core/modules/views_ui/src/Tests/CachedDataUITest.php
index 1f69b196d04..a605d0f29cb 100644
--- a/core/modules/views_ui/src/Tests/CachedDataUITest.php
+++ b/core/modules/views_ui/src/Tests/CachedDataUITest.php
@@ -14,7 +14,7 @@ class CachedDataUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the user tempstore views data in the UI.
@@ -28,7 +28,7 @@ class CachedDataUITest extends UITestBase {
$this->drupalGet('admin/structure/views/view/test_view/edit');
// Make sure we have 'changes' to the view.
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', array(), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply'));
$this->assertText('You have unsaved changes.');
$this->assertEqual($temp_store->getMetadata('test_view')->owner, $views_admin_user_uid, 'View cache has been saved.');
@@ -39,13 +39,13 @@ class CachedDataUITest extends UITestBase {
$this->assertEqual($temp_store->getMetadata('test_view')->owner, $views_admin_user_uid, 'The view is locked.');
// Cancel the view edit and make sure the cache is deleted.
- $this->drupalPostForm(NULL, array(), t('Cancel'));
+ $this->drupalPostForm(NULL, [], t('Cancel'));
$this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'User tempstore data has been removed.');
// Test we are redirected to the view listing page.
- $this->assertUrl('admin/structure/views', array(), 'Redirected back to the view listing page.');
+ $this->assertUrl('admin/structure/views', [], 'Redirected back to the view listing page.');
// Log in with another user and make sure the view is locked and break.
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', array(), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply'));
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/structure/views/view/test_view/edit');
@@ -56,17 +56,17 @@ class CachedDataUITest extends UITestBase {
$this->assertLinkByHref('admin/structure/views/view/test_view/break-lock');
// Break the lock.
$this->clickLink(t('break this lock'));
- $this->drupalPostForm(NULL, array(), t('Break lock'));
+ $this->drupalPostForm(NULL, [], t('Break lock'));
// Test that save and cancel buttons are shown.
$this->assertFieldById('edit-actions-submit', t('Save'));
$this->assertFieldById('edit-actions-cancel', t('Cancel'));
// Test we can save the view.
- $this->drupalPostForm('admin/structure/views/view/test_view/edit', array(), t('Save'));
- $this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view')));
+ $this->drupalPostForm('admin/structure/views/view/test_view/edit', [], t('Save'));
+ $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
// Test that a deleted view has no tempstore data.
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', array(), t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/test_view/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply'));
+ $this->drupalPostForm('admin/structure/views/view/test_view/delete', [], t('Delete'));
// No view tempstore data should be returned for this view after deletion.
$this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'View tempstore data has been removed after deletion.');
}
diff --git a/core/modules/views_ui/src/Tests/CustomBooleanTest.php b/core/modules/views_ui/src/Tests/CustomBooleanTest.php
index ecde493b63f..adae59ab22c 100644
--- a/core/modules/views_ui/src/Tests/CustomBooleanTest.php
+++ b/core/modules/views_ui/src/Tests/CustomBooleanTest.php
@@ -18,7 +18,7 @@ class CustomBooleanTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* \Drupal\views\Tests\ViewTestBase::viewsData().
@@ -47,15 +47,15 @@ class CustomBooleanTest extends UITestBase {
$view = Views::getView('test_view');
$view->setDisplay();
- $view->displayHandlers->get('default')->overrideOption('fields', array(
- 'age' => array(
+ $view->displayHandlers->get('default')->overrideOption('fields', [
+ 'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'plugin_id' => 'boolean',
- ),
- ));
+ ],
+ ]);
$view->save();
$this->executeView($view);
@@ -64,35 +64,35 @@ class CustomBooleanTest extends UITestBase {
$custom_false = 'Nay';
// Set up some custom value mappings for different types.
- $custom_values = array(
- 'plain' => array(
+ $custom_values = [
+ 'plain' => [
'true' => $custom_true,
'false' => $custom_false,
'test' => 'assertTrue',
- ),
- 'allowed tag' => array(
+ ],
+ 'allowed tag' => [
'true' => '<p>' . $custom_true . '</p>',
'false' => '<p>' . $custom_false . '</p>',
'test' => 'assertTrue',
- ),
- 'disallowed tag' => array(
+ ],
+ 'disallowed tag' => [
'true' => '<script>' . $custom_true . '</script>',
'false' => '<script>' . $custom_false . '</script>',
'test' => 'assertFalse',
- ),
- );
+ ],
+ ];
// Run the same tests on each type.
foreach ($custom_values as $type => $values) {
- $options = array(
+ $options = [
'options[type]' => 'custom',
'options[type_custom_true]' => $values['true'],
'options[type_custom_false]' => $values['false'],
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/field/age', $options, 'Apply');
// Save the view.
- $this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save');
+ $this->drupalPostForm('admin/structure/views/view/test_view', [], 'Save');
$view = Views::getView('test_view');
$output = $view->preview();
@@ -136,35 +136,35 @@ class CustomBooleanTest extends UITestBase {
$custom_false = 'Nay';
// Set up some custom value mappings for different types.
- $custom_values = array(
- 'plain' => array(
+ $custom_values = [
+ 'plain' => [
'true' => $custom_true,
'false' => $custom_false,
'test' => 'assertTrue',
- ),
- 'allowed tag' => array(
+ ],
+ 'allowed tag' => [
'true' => '<p>' . $custom_true . '</p>',
'false' => '<p>' . $custom_false . '</p>',
'test' => 'assertTrue',
- ),
- 'disallowed tag' => array(
+ ],
+ 'disallowed tag' => [
'true' => '<script>' . $custom_true . '</script>',
'false' => '<script>' . $custom_false . '</script>',
'test' => 'assertFalse',
- ),
- );
+ ],
+ ];
// Run the same tests on each type.
foreach ($custom_values as $type => $values) {
- $options = array(
+ $options = [
'options[type]' => 'custom',
'options[type_custom_true]' => $values['true'],
'options[type_custom_false]' => $values['false'],
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/field/age', $options, 'Apply');
// Save the view.
- $this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save');
+ $this->drupalPostForm('admin/structure/views/view/test_view', [], 'Save');
$view = Views::getView('test_view');
$output = $view->preview();
diff --git a/core/modules/views_ui/src/Tests/DefaultViewsTest.php b/core/modules/views_ui/src/Tests/DefaultViewsTest.php
index 08fcae8ea4e..855cbdad7d7 100644
--- a/core/modules/views_ui/src/Tests/DefaultViewsTest.php
+++ b/core/modules/views_ui/src/Tests/DefaultViewsTest.php
@@ -18,7 +18,7 @@ class DefaultViewsTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view_status', 'test_page_display_menu', 'test_page_display_arguments');
+ public static $testViews = ['test_view_status', 'test_page_display_menu', 'test_page_display_arguments'];
protected function setUp() {
@@ -55,16 +55,16 @@ class DefaultViewsTest extends UITestBase {
// Edit the view and change the title. Make sure that the new title is
// displayed.
$new_title = $this->randomMachineName(16);
- $edit = array('title' => $new_title);
+ $edit = ['title' => $new_title];
$this->drupalPostForm('admin/structure/views/nojs/display/glossary/page_1/title', $edit, t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/glossary/edit/page_1', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/view/glossary/edit/page_1', [], t('Save'));
$this->drupalGet('glossary');
$this->assertResponse(200);
$this->assertText($new_title);
// Save another view in the UI.
- $this->drupalPostForm('admin/structure/views/nojs/display/archive/page_1/title', array(), t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/archive/edit/page_1', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/archive/page_1/title', [], t('Apply'));
+ $this->drupalPostForm('admin/structure/views/view/archive/edit/page_1', [], t('Save'));
// Check there is an enable link. i.e. The view has not been enabled after
// editing.
@@ -85,19 +85,19 @@ class DefaultViewsTest extends UITestBase {
// Duplicate the view and check that the normal schema of duplicated views is used.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
- $edit = array(
+ $edit = [
'id' => 'duplicate_of_glossary',
- );
- $this->assertTitle(t('Duplicate of @label | @site-name', array('@label' => 'Glossary', '@site-name' => $this->config('system.site')->get('name'))));
+ ];
+ $this->assertTitle(t('Duplicate of @label | @site-name', ['@label' => 'Glossary', '@site-name' => $this->config('system.site')->get('name')]));
$this->drupalPostForm(NULL, $edit, t('Duplicate'));
- $this->assertUrl('admin/structure/views/view/duplicate_of_glossary', array(), 'The normal duplicating name schema is applied.');
+ $this->assertUrl('admin/structure/views/view/duplicate_of_glossary', [], 'The normal duplicating name schema is applied.');
// Duplicate a view and set a custom name.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
$random_name = strtolower($this->randomMachineName());
- $this->drupalPostForm(NULL, array('id' => $random_name), t('Duplicate'));
- $this->assertUrl("admin/structure/views/view/$random_name", array(), 'The custom view name got saved.');
+ $this->drupalPostForm(NULL, ['id' => $random_name], t('Duplicate'));
+ $this->assertUrl("admin/structure/views/view/$random_name", [], 'The custom view name got saved.');
// Now disable the view, and make sure it stops appearing on the main view
// listing page but instead goes back to displaying on the disabled views
@@ -129,7 +129,7 @@ class DefaultViewsTest extends UITestBase {
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), '/glossary/');
// Submit the confirmation form.
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
// Ensure the view is no longer listed.
$this->assertUrl('admin/structure/views');
$this->assertNoLinkByHref($edit_href);
@@ -142,7 +142,7 @@ class DefaultViewsTest extends UITestBase {
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary');
// Submit the confirmation form.
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->drupalGet('glossary');
$this->assertResponse(200);
@@ -150,7 +150,7 @@ class DefaultViewsTest extends UITestBase {
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), $random_name);
// Submit the confirmation form.
- $this->drupalPostForm(NULL, array(), t('Delete'));
+ $this->drupalPostForm(NULL, [], t('Delete'));
$this->drupalGet('glossary');
$this->assertResponse(404);
$this->assertText('Page not found');
@@ -163,10 +163,10 @@ class DefaultViewsTest extends UITestBase {
// Build a re-usable xpath query.
$xpath = '//div[@id="views-entity-list"]/div[@class = :status]/table//td/text()[contains(., :title)]';
- $arguments = array(
+ $arguments = [
':status' => 'views-list-section enabled',
':title' => 'test_view_status',
- );
+ ];
$this->drupalGet('admin/structure/views');
@@ -228,7 +228,7 @@ class DefaultViewsTest extends UITestBase {
* failure. Failure also results in a failed assertion.
*/
function clickViewsOperationLink($label, $unique_href_part) {
- $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
+ $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
foreach ($links as $link_index => $link) {
$position = strpos($link['href'], $unique_href_part);
if ($position !== FALSE) {
@@ -236,7 +236,7 @@ class DefaultViewsTest extends UITestBase {
break;
}
}
- $this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', array('@label' => $label, '@part' => $unique_href_part)));
+ $this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', ['@label' => $label, '@part' => $unique_href_part]));
if (isset($index)) {
return $this->clickLink($label, $index);
}
diff --git a/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php b/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php
index 9cff06e11e3..480172bb33c 100644
--- a/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php
@@ -17,7 +17,7 @@ class DisplayAttachmentTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_attachment_ui');
+ public static $testViews = ['test_attachment_ui'];
/**
* Tests the attachment UI.
@@ -31,31 +31,31 @@ class DisplayAttachmentTest extends UITestBase {
// Display labels should be escaped.
$this->assertEscaped('<em>Page</em>');
- foreach (array('default', 'page-1') as $display_id) {
- $this->assertNoFieldChecked("edit-displays-$display_id", format_string('Make sure the @display_id can be marked as attached', array('@display_id' => $display_id)));
+ foreach (['default', 'page-1'] as $display_id) {
+ $this->assertNoFieldChecked("edit-displays-$display_id", format_string('Make sure the @display_id can be marked as attached', ['@display_id' => $display_id]));
}
// Save the attachments and test the value on the view.
- $this->drupalPostForm($attachment_display_url, array('displays[page_1]' => 1), t('Apply'));
+ $this->drupalPostForm($attachment_display_url, ['displays[page_1]' => 1], t('Apply'));
// Options summary should be escaped.
$this->assertEscaped('<em>Page</em>');
$this->assertNoRaw('<em>Page</em>');
- $result = $this->xpath('//a[@id = :id]', array(':id' => 'views-attachment-1-displays'));
+ $result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
$this->assertEqual($result[0]->attributes()->title, t('Page'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView('test_attachment_ui');
$view->initDisplay();
- $this->assertEqual(array_keys(array_filter($view->displayHandlers->get('attachment_1')->getOption('displays'))), array('page_1'), 'The attached displays got saved as expected');
+ $this->assertEqual(array_keys(array_filter($view->displayHandlers->get('attachment_1')->getOption('displays'))), ['page_1'], 'The attached displays got saved as expected');
- $this->drupalPostForm($attachment_display_url, array('displays[default]' => 1, 'displays[page_1]' => 1), t('Apply'));
- $result = $this->xpath('//a[@id = :id]', array(':id' => 'views-attachment-1-displays'));
+ $this->drupalPostForm($attachment_display_url, ['displays[default]' => 1, 'displays[page_1]' => 1], t('Apply'));
+ $result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
$this->assertEqual($result[0]->attributes()->title, t('Multiple displays'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView('test_attachment_ui');
$view->initDisplay();
- $this->assertEqual(array_keys($view->displayHandlers->get('attachment_1')->getOption('displays')), array('default', 'page_1'), 'The attached displays got saved as expected');
+ $this->assertEqual(array_keys($view->displayHandlers->get('attachment_1')->getOption('displays')), ['default', 'page_1'], 'The attached displays got saved as expected');
}
/**
@@ -69,21 +69,21 @@ class DisplayAttachmentTest extends UITestBase {
// Open the Page display and create the attachment display.
$this->drupalGet($path_prefix . '/page_1');
- $this->drupalPostForm(NULL, array(), 'Add Attachment');
+ $this->drupalPostForm(NULL, [], 'Add Attachment');
$this->assertText(t('Not defined'), 'The right text appears if there is no attachment selection yet.');
// Attach the Attachment to the Page display.
- $this->drupalPostForm($attachment_display_url, array('displays[page_1]' => 1), t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm($attachment_display_url, ['displays[page_1]' => 1], t('Apply'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Open the Page display and mark it as deleted.
$this->drupalGet($path_prefix . '/page_1');
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display.');
- $this->drupalPostForm($path_prefix . '/page_1', array(), 'Delete Page');
+ $this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page');
// Open the attachment display and save it.
$this->drupalGet($path_prefix . '/attachment_1');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Check that there is no warning for the removed page display.
$this->assertNoText("Plugin ID &#039;page_1&#039; was not found.");
diff --git a/core/modules/views_ui/src/Tests/DisplayCRUDTest.php b/core/modules/views_ui/src/Tests/DisplayCRUDTest.php
index 1e060dcb78d..e29f0a94e92 100644
--- a/core/modules/views_ui/src/Tests/DisplayCRUDTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayCRUDTest.php
@@ -16,14 +16,14 @@ class DisplayCRUDTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_display');
+ public static $testViews = ['test_display'];
/**
* Modules to enable
*
* @var array
*/
- public static $modules = array('contextual');
+ public static $modules = ['contextual'];
/**
* Tests adding a display.
@@ -39,14 +39,14 @@ class DisplayCRUDTest extends UITestBase {
$this->drupalGet($path_prefix);
// Add a new display.
- $this->drupalPostForm(NULL, array(), 'Add Page');
+ $this->drupalPostForm(NULL, [], 'Add Page');
$this->assertLinkByHref($path_prefix . '/page_1', 0, 'Make sure after adding a display the new display appears in the UI');
$this->assertNoLink('Master*', 'Make sure the master display is not marked as changed.');
$this->assertLink('Page*', 0, 'Make sure the added display is marked as changed.');
- $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/path", array('path' => 'test/path'), t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/path", ['path' => 'test/path'], t('Apply'));
+ $this->drupalPostForm(NULL, [], t('Save'));
}
/**
@@ -63,22 +63,22 @@ class DisplayCRUDTest extends UITestBase {
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display.');
// Delete the page, so we can test the undo process.
- $this->drupalPostForm($path_prefix . '/page_1', array(), 'Delete Page');
+ $this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page');
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there a undo button on the page display after deleting.');
- $element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', array(':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link'));
+ $element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', [':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link']);
$this->assertTrue(!empty($element), 'Make sure the display link is marked as to be deleted.');
- $element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', array(':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link'));
+ $element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', [':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link']);
$this->assertTrue(!empty($element), 'Make sure the display link is marked as to be deleted.');
// Undo the deleting of the display.
- $this->drupalPostForm($path_prefix . '/page_1', array(), 'Undo delete of Page');
+ $this->drupalPostForm($path_prefix . '/page_1', [], 'Undo delete of Page');
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there is no undo button on the page display after reverting.');
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display after the reverting.');
// Now delete again and save the view.
- $this->drupalPostForm($path_prefix . '/page_1', array(), 'Delete Page');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page');
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertNoLinkByHref($path_prefix . '/page_1', 'Make sure there is no display tab for the deleted display.');
@@ -86,9 +86,9 @@ class DisplayCRUDTest extends UITestBase {
$view = $this->randomView();
$machine_name = 'new_machine_name';
$path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
- $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/display_id", array('display_id' => $machine_name), 'Apply');
- $this->drupalPostForm(NULL, array(), 'Delete Page');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/display_id", ['display_id' => $machine_name], 'Apply');
+ $this->drupalPostForm(NULL, [], 'Delete Page');
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertResponse(200);
$this->assertNoLinkByHref($path_prefix . '/new_machine_name', 'Make sure there is no display tab for the deleted display.');
}
@@ -111,24 +111,24 @@ class DisplayCRUDTest extends UITestBase {
$path = $view['page[path]'];
$this->drupalGet($path_prefix);
- $this->drupalPostForm(NULL, array(), 'Duplicate Page');
+ $this->drupalPostForm(NULL, [], 'Duplicate Page');
$this->assertLinkByHref($path_prefix . '/page_2', 0, 'Make sure after duplicating the new display appears in the UI');
- $this->assertUrl($path_prefix . '/page_2', array(), 'The user got redirected to the new display.');
+ $this->assertUrl($path_prefix . '/page_2', [], 'The user got redirected to the new display.');
// Set the title and override the css classes.
$random_title = $this->randomMachineName();
$random_css = $this->randomMachineName();
- $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/title", array('title' => $random_title), t('Apply'));
- $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/css_class", array('override[dropdown]' => 'page_2', 'css_class' => $random_css), t('Apply'));
+ $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/title", ['title' => $random_title], t('Apply'));
+ $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/css_class", ['override[dropdown]' => 'page_2', 'css_class' => $random_css], t('Apply'));
// Duplicate as a different display type.
- $this->drupalPostForm(NULL, array(), 'Duplicate as Block');
+ $this->drupalPostForm(NULL, [], 'Duplicate as Block');
$this->assertLinkByHref($path_prefix . '/block_1', 0, 'Make sure after duplicating the new display appears in the UI');
- $this->assertUrl($path_prefix . '/block_1', array(), 'The user got redirected to the new display.');
+ $this->assertUrl($path_prefix . '/block_1', [], 'The user got redirected to the new display.');
$this->assertText(t('Block settings'));
$this->assertNoText(t('Page settings'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView($view['id']);
$view->initDisplay();
diff --git a/core/modules/views_ui/src/Tests/DisplayExtenderUITest.php b/core/modules/views_ui/src/Tests/DisplayExtenderUITest.php
index 7e26dffd23c..e8eff0a0cb4 100644
--- a/core/modules/views_ui/src/Tests/DisplayExtenderUITest.php
+++ b/core/modules/views_ui/src/Tests/DisplayExtenderUITest.php
@@ -16,13 +16,13 @@ class DisplayExtenderUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the display extender UI.
*/
public function testDisplayExtenderUI() {
- $this->config('views.settings')->set('display_extenders', array('display_extender_test'))->save();
+ $this->config('views.settings')->set('display_extenders', ['display_extender_test'])->save();
$view = Views::getView('test_view');
$view_edit_url = "admin/structure/views/view/{$view->storage->id()}/edit";
@@ -32,9 +32,9 @@ class DisplayExtenderUITest extends UITestBase {
$this->assertLinkByHref($display_option_url, 0, 'Make sure the option defined by the test display extender appears in the UI.');
$random_text = $this->randomMachineName();
- $this->drupalPostForm($display_option_url, array('test_extender_test_option' => $random_text), t('Apply'));
+ $this->drupalPostForm($display_option_url, ['test_extender_test_option' => $random_text], t('Apply'));
$this->assertLink($random_text);
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView($view->storage->id());
$view->initDisplay();
$display_extender_options = $view->display_handler->getOption('display_extenders');
diff --git a/core/modules/views_ui/src/Tests/DisplayFeedTest.php b/core/modules/views_ui/src/Tests/DisplayFeedTest.php
index 4e7bf8a4c74..d8d003191ed 100644
--- a/core/modules/views_ui/src/Tests/DisplayFeedTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayFeedTest.php
@@ -15,14 +15,14 @@ class DisplayFeedTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_display_feed', 'test_style_opml');
+ public static $testViews = ['test_display_feed', 'test_style_opml'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('views_ui', 'aggregator');
+ public static $modules = ['views_ui', 'aggregator'];
/**
* Tests feed display admin UI.
@@ -55,7 +55,7 @@ class DisplayFeedTest extends UITestBase {
// Load all the options of the checkbox.
$result = $this->xpath('//div[@id="edit-displays"]/div');
- $options = array();
+ $options = [];
foreach ($result as $item) {
foreach ($item->input->attributes() as $attribute => $value) {
if ($attribute == 'value') {
@@ -64,10 +64,10 @@ class DisplayFeedTest extends UITestBase {
}
}
- $this->assertEqual($options, array('default', 'page'), 'Make sure all displays appears as expected.');
+ $this->assertEqual($options, ['default', 'page'], 'Make sure all displays appears as expected.');
// Post and save this and check the output.
- $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', array('displays[page]' => 'page'), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[page]' => 'page'], t('Apply'));
// Options summary should be escaped.
$this->assertEscaped('<em>Page</em>');
$this->assertNoRaw('<em>Page</em>');
@@ -76,7 +76,7 @@ class DisplayFeedTest extends UITestBase {
$this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', '<em>Page</em>');
// Add the default display, so there should now be multiple displays.
- $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', array('displays[default]' => 'default'), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[default]' => 'default'], t('Apply'));
$this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
$this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Multiple displays');
}
diff --git a/core/modules/views_ui/src/Tests/DisplayPathTest.php b/core/modules/views_ui/src/Tests/DisplayPathTest.php
index 8baa50649a4..d1d1732baba 100644
--- a/core/modules/views_ui/src/Tests/DisplayPathTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayPathTest.php
@@ -21,14 +21,14 @@ class DisplayPathTest extends UITestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('menu_ui');
+ public static $modules = ['menu_ui'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view', 'test_page_display_menu');
+ public static $testViews = ['test_view', 'test_page_display_menu'];
/**
* Runs the tests.
@@ -46,9 +46,9 @@ class DisplayPathTest extends UITestBase {
$this->drupalGet('admin/structure/views/view/test_view');
// Add a new page display and check the appearing text.
- $this->drupalPostForm(NULL, array(), 'Add Page');
+ $this->drupalPostForm(NULL, [], 'Add Page');
$this->assertText(t('No path is set'), 'The right text appears if no path was set.');
- $this->assertNoLink(t('View @display', array('@display' => 'page')), 'No view page link found on the page.');
+ $this->assertNoLink(t('View @display', ['@display' => 'page']), 'No view page link found on the page.');
// Save a path and make sure the summary appears as expected.
$random_path = $this->randomMachineName();
@@ -56,7 +56,7 @@ class DisplayPathTest extends UITestBase {
// longer use Url::fromUri(), and this path will be able to contain ':'.
$random_path = str_replace(':', '', $random_path);
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => $random_path), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => $random_path], t('Apply'));
$this->assertText('/' . $random_path, 'The custom path appears in the summary.');
$display_link_text = t('View @display', ['@display' => 'Page']);
$this->assertLink($display_link_text, 0, 'view page link found on the page.');
@@ -69,13 +69,13 @@ class DisplayPathTest extends UITestBase {
*/
public function doPathXssFilterTest() {
$this->drupalGet('admin/structure/views/view/test_view');
- $this->drupalPostForm(NULL, array(), 'Add Page');
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_2/path', array('path' => '<object>malformed_path</object>'), t('Apply'));
- $this->drupalPostForm(NULL, array(), 'Add Page');
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_3/path', array('path' => '<script>alert("hello");</script>'), t('Apply'));
- $this->drupalPostForm(NULL, array(), 'Add Page');
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_4/path', array('path' => '<script>alert("hello I have placeholders %");</script>'), t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
+ $this->drupalPostForm(NULL, [], 'Add Page');
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_2/path', ['path' => '<object>malformed_path</object>'], t('Apply'));
+ $this->drupalPostForm(NULL, [], 'Add Page');
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_3/path', ['path' => '<script>alert("hello");</script>'], t('Apply'));
+ $this->drupalPostForm(NULL, [], 'Add Page');
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_4/path', ['path' => '<script>alert("hello I have placeholders %");</script>'], t('Apply'));
+ $this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
$this->drupalGet('admin/structure/views');
// The anchor text should be escaped.
$this->assertEscaped('/<object>malformed_path</object>');
@@ -92,11 +92,11 @@ class DisplayPathTest extends UITestBase {
protected function doAdvancedPathsValidationTest() {
$url = 'admin/structure/views/nojs/display/test_view/page_1/path';
- $this->drupalPostForm($url, array('path' => '%/magrathea'), t('Apply'));
+ $this->drupalPostForm($url, ['path' => '%/magrathea'], t('Apply'));
$this->assertUrl($url);
$this->assertText('"%" may not be used for the first segment of a path.');
- $this->drupalPostForm($url, array('path' => 'user/%1/example'), t('Apply'));
+ $this->drupalPostForm($url, ['path' => 'user/%1/example'], t('Apply'));
$this->assertUrl($url);
$this->assertText("Numeric placeholders may not be used. Please use plain placeholders (%).");
}
@@ -106,51 +106,51 @@ class DisplayPathTest extends UITestBase {
*/
public function testDeleteWithNoPath() {
$this->drupalGet('admin/structure/views/view/test_view');
- $this->drupalPostForm(NULL, array(), t('Add Page'));
- $this->drupalPostForm(NULL, array(), t('Delete Page'));
- $this->drupalPostForm(NULL, array(), t('Save'));
- $this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view')));
+ $this->drupalPostForm(NULL, [], t('Add Page'));
+ $this->drupalPostForm(NULL, [], t('Delete Page'));
+ $this->drupalPostForm(NULL, [], t('Save'));
+ $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
}
/**
* Tests the menu and tab option form.
*/
public function testMenuOptions() {
- $this->container->get('module_installer')->install(array('menu_ui'));
+ $this->container->get('module_installer')->install(['menu_ui']);
$this->drupalGet('admin/structure/views/view/test_view');
// Add a new page display.
- $this->drupalPostForm(NULL, array(), 'Add Page');
+ $this->drupalPostForm(NULL, [], 'Add Page');
// Add an invalid path (only fragment).
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => '#foo'), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => '#foo'], t('Apply'));
$this->assertText('Path is empty');
// Add an invalid path with a query.
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => 'foo?bar'), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => 'foo?bar'], t('Apply'));
$this->assertText('No query allowed.');
// Add an invalid path with just a query.
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => '?bar'), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => '?bar'], t('Apply'));
$this->assertText('Path is empty');
// Provide a random, valid path string.
$random_string = $this->randomMachineName();
// Save a path.
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => $random_string), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => $random_string], t('Apply'));
$this->drupalGet('admin/structure/views/view/test_view');
- $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/menu', array('menu[type]' => 'default tab', 'menu[title]' => 'Test tab title'), t('Apply'));
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/menu', ['menu[type]' => 'default tab', 'menu[title]' => 'Test tab title'], t('Apply'));
$this->assertResponse(200);
$this->assertUrl('admin/structure/views/nojs/display/test_view/page_1/tab_options');
- $this->drupalPostForm(NULL, array('tab_options[type]' => 'tab', 'tab_options[title]' => $this->randomString()), t('Apply'));
+ $this->drupalPostForm(NULL, ['tab_options[type]' => 'tab', 'tab_options[title]' => $this->randomString()], t('Apply'));
$this->assertResponse(200);
$this->assertUrl('admin/structure/views/view/test_view/edit/page_1');
$this->drupalGet('admin/structure/views/view/test_view');
- $this->assertLink(t('Tab: @title', array('@title' => 'Test tab title')));
+ $this->assertLink(t('Tab: @title', ['@title' => 'Test tab title']));
// If it's a default tab, it should also have an additional settings link.
$this->assertLinkByHref('admin/structure/views/nojs/display/test_view/page_1/tab_options');
diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/src/Tests/DisplayTest.php
index 7f5f12547b5..afb2c7ff069 100644
--- a/core/modules/views_ui/src/Tests/DisplayTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayTest.php
@@ -20,14 +20,14 @@ class DisplayTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_display');
+ public static $testViews = ['test_display'];
/**
* Modules to enable
*
* @var array
*/
- public static $modules = array('contextual');
+ public static $modules = ['contextual'];
/**
* Tests adding a display.
@@ -53,9 +53,9 @@ class DisplayTest extends UITestBase {
* Tests reordering of displays.
*/
public function testReorderDisplay() {
- $view = array(
+ $view = [
'block[create]' => TRUE
- );
+ ];
$view = $this->randomView($view);
$this->clickLink(t('Reorder displays'));
@@ -64,15 +64,15 @@ class DisplayTest extends UITestBase {
$this->assertTrue($this->xpath('//tr[@id="display-row-block_1"]'), 'Make sure the block display appears on the reorder listing');
// Ensure the view displays are in the expected order in configuration.
- $expected_display_order = array('default', 'block_1', 'page_1');
+ $expected_display_order = ['default', 'block_1', 'page_1'];
$this->assertEqual(array_keys(Views::getView($view['id'])->storage->get('display')), $expected_display_order, 'The correct display names are present.');
// Put the block display in front of the page display.
- $edit = array(
+ $edit = [
'displays[page_1][weight]' => 2,
'displays[block_1][weight]' => 1
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView($view['id']);
$displays = $view->storage->get('display');
@@ -92,17 +92,17 @@ class DisplayTest extends UITestBase {
$path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
$this->drupalGet($path_prefix);
- $this->assertFalse($this->xpath('//div[contains(@class, :class)]', array(':class' => 'views-display-disabled')), 'Make sure the disabled display css class does not appear after initial adding of a view.');
+ $this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appear after initial adding of a view.');
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is visible.');
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is not visible.');
- $this->drupalPostForm(NULL, array(), 'Disable Page');
- $this->assertTrue($this->xpath('//div[contains(@class, :class)]', array(':class' => 'views-display-disabled')), 'Make sure the disabled display css class appears once the display is marked as such.');
+ $this->drupalPostForm(NULL, [], 'Disable Page');
+ $this->assertTrue($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class appears once the display is marked as such.');
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is not visible.');
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is visible.');
- $this->drupalPostForm(NULL, array(), 'Enable Page');
- $this->assertFalse($this->xpath('//div[contains(@class, :class)]', array(':class' => 'views-display-disabled')), 'Make sure the disabled display css class does not appears once the display is enabled again.');
+ $this->drupalPostForm(NULL, [], 'Enable Page');
+ $this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appears once the display is enabled again.');
}
/**
@@ -111,10 +111,10 @@ class DisplayTest extends UITestBase {
public function testDisplayPluginsAlter() {
$definitions = Views::pluginManager('display')->getDefinitions();
- $expected = array(
+ $expected = [
'route_name' => 'entity.view.edit_form',
- 'route_parameters_names' => array('view' => 'id'),
- );
+ 'route_parameters_names' => ['view' => 'id'],
+ ];
// Test the expected views_ui array exists on each definition.
foreach ($definitions as $definition) {
@@ -136,16 +136,16 @@ class DisplayTest extends UITestBase {
$this->drupalGet('admin/structure/views/view/test_display/edit/display_no_area_test_1');
- $areas = array(
+ $areas = [
'header',
'footer',
'empty',
- );
+ ];
// Assert that the expected text is found in each area category.
foreach ($areas as $type) {
- $element = $this->xpath('//div[contains(@class, :class)]/div', array(':class' => $type));
- $this->assertEqual((string) $element[0], SafeMarkup::format('The selected display type does not use @type plugins', array('@type' => $type)));
+ $element = $this->xpath('//div[contains(@class, :class)]/div', [':class' => $type]);
+ $this->assertEqual((string) $element[0], SafeMarkup::format('The selected display type does not use @type plugins', ['@type' => $type]));
}
}
@@ -159,28 +159,28 @@ class DisplayTest extends UITestBase {
// Test the link text displays 'None' and not 'Block 1'
$this->drupalGet($path);
- $result = $this->xpath("//a[contains(@href, :path)]", array(':path' => $link_display_path));
+ $result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
$this->assertEqual($result[0], t('None'), 'Make sure that the link option summary shows "None" by default.');
$this->drupalGet($link_display_path);
$this->assertFieldChecked('edit-link-display-0');
// Test the default radio option on the link display form.
- $this->drupalPostForm($link_display_path, array('link_display' => 'page_1'), t('Apply'));
+ $this->drupalPostForm($link_display_path, ['link_display' => 'page_1'], t('Apply'));
// The form redirects to the master display.
$this->drupalGet($path);
- $result = $this->xpath("//a[contains(@href, :path)]", array(':path' => $link_display_path));
+ $result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
$this->assertEqual($result[0], 'Page', 'Make sure that the link option summary shows the right linked display.');
- $this->drupalPostForm($link_display_path, array('link_display' => 'custom_url', 'link_url' => 'a-custom-url'), t('Apply'));
+ $this->drupalPostForm($link_display_path, ['link_display' => 'custom_url', 'link_url' => 'a-custom-url'], t('Apply'));
// The form redirects to the master display.
$this->drupalGet($path);
$this->assertLink(t('Custom URL'), 0, 'The link option has custom URL as summary.');
// Test the default link_url value for new display
- $this->drupalPostForm(NULL, array(), t('Add Block'));
+ $this->drupalPostForm(NULL, [], t('Add Block'));
$this->assertUrl('admin/structure/views/view/test_display/edit/block_2');
$this->clickLink(t('Custom URL'));
$this->assertFieldByName('link_url', 'a-custom-url');
@@ -190,7 +190,7 @@ class DisplayTest extends UITestBase {
* Tests contextual links on Views page displays.
*/
public function testPageContextualLinks() {
- $this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links')));
+ $this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links']));
$view = View::load('test_display');
$view->enable()->save();
$this->container->get('router.builder')->rebuildIfNeeded();
@@ -200,12 +200,12 @@ class DisplayTest extends UITestBase {
$this->drupalGet('test-display');
$id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
- $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+ $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
// Get server-rendered contextual links.
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
- $post = array('ids[0]' => $id);
- $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => 'test-display')));
+ $post = ['ids[0]' => $id];
+ $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => 'test-display']]);
$this->assertResponse(200);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1">Edit view</a></li></ul>');
@@ -217,7 +217,7 @@ class DisplayTest extends UITestBase {
$this->drupalGet('test-display');
$id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
- $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
+ $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
}
/**
@@ -229,14 +229,14 @@ class DisplayTest extends UITestBase {
// The view should initially have the enabled class on it's form wrapper.
$this->drupalGet('admin/structure/views/view/' . $id);
- $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', array(':edit' => 'views-edit-view', ':status' => 'enabled'));
+ $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [':edit' => 'views-edit-view', ':status' => 'enabled']);
$this->assertTrue($elements, 'The enabled class was found on the form wrapper');
$view = Views::getView($id);
$view->storage->disable()->save();
$this->drupalGet('admin/structure/views/view/' . $id);
- $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', array(':edit' => 'views-edit-view', ':status' => 'disabled'));
+ $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [':edit' => 'views-edit-view', ':status' => 'disabled']);
$this->assertTrue($elements, 'The disabled class was found on the form wrapper.');
}
@@ -278,7 +278,7 @@ class DisplayTest extends UITestBase {
$display_title = "'<test>'";
$this->drupalGet('admin/structure/views/view/test_display');
$display_title_path = 'admin/structure/views/nojs/display/test_display/block_1/display_title';
- $this->drupalPostForm($display_title_path, array('display_title' => $display_title), t('Apply'));
+ $this->drupalPostForm($display_title_path, ['display_title' => $display_title], t('Apply'));
// Ensure that the title is escaped as expected.
$this->assertEscaped($display_title);
diff --git a/core/modules/views_ui/src/Tests/DuplicateTest.php b/core/modules/views_ui/src/Tests/DuplicateTest.php
index a6948f00294..1096ab4314c 100644
--- a/core/modules/views_ui/src/Tests/DuplicateTest.php
+++ b/core/modules/views_ui/src/Tests/DuplicateTest.php
@@ -24,7 +24,7 @@ class DuplicateTest extends UITestBase {
$random_view = $this->randomView();
// Initialize array for duplicated view.
- $view = array();
+ $view = [];
// Generate random label and id for new view.
$view['label'] = $this->randomMachineName(255);
@@ -34,7 +34,7 @@ class DuplicateTest extends UITestBase {
$this->drupalPostForm('admin/structure/views/view/' . $random_view['id'] . '/duplicate', $view, t('Duplicate'));
// Assert that the page url is correct.
- $this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
+ $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
// Assert that the page title is correctly displayed.
$this->assertText($view['label']);
diff --git a/core/modules/views_ui/src/Tests/ExposedFormUITest.php b/core/modules/views_ui/src/Tests/ExposedFormUITest.php
index 66280b1beb7..d1e3a664a84 100644
--- a/core/modules/views_ui/src/Tests/ExposedFormUITest.php
+++ b/core/modules/views_ui/src/Tests/ExposedFormUITest.php
@@ -16,12 +16,12 @@ class ExposedFormUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_exposed_admin_ui');
+ public static $testViews = ['test_exposed_admin_ui'];
/**
* {@inheritdoc}
*/
- public static $modules = array('node', 'views_ui', 'block', 'taxonomy', 'field_ui', 'datetime');
+ public static $modules = ['node', 'views_ui', 'block', 'taxonomy', 'field_ui', 'datetime'];
/**
* Array of error message strings raised by the grouped form.
@@ -35,8 +35,8 @@ class ExposedFormUITest extends UITestBase {
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'article'));
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'article']);
+ $this->drupalCreateContentType(['type' => 'page']);
// Create some random nodes.
for ($i = 0; $i < 5; $i++) {
@@ -53,7 +53,7 @@ class ExposedFormUITest extends UITestBase {
* Tests the admin interface of exposed filter and sort items.
*/
function testExposedAdminUi() {
- $edit = array();
+ $edit = [];
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
// Be sure that the button is called exposed.
@@ -78,12 +78,12 @@ class ExposedFormUITest extends UITestBase {
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists');
// Check the validations of the filter handler.
- $edit = array();
+ $edit = [];
$edit['options[expose][identifier]'] = '';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText(t('The identifier is required if the filter is exposed.'));
- $edit = array();
+ $edit = [];
$edit['options[expose][identifier]'] = 'value';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText(t('This identifier is not allowed.'));
@@ -95,7 +95,7 @@ class ExposedFormUITest extends UITestBase {
// Un-expose the filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
- $this->drupalPostForm(NULL, array(), t('Hide filter'));
+ $this->drupalPostForm(NULL, [], t('Hide filter'));
// After Un-exposing the filter, Operator and Value should be shown again.
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists after hide filter');
@@ -104,7 +104,7 @@ class ExposedFormUITest extends UITestBase {
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists after hide filter');
// Click the Expose sort button.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
// Check the label of the expose button.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort'));
@@ -135,7 +135,7 @@ class ExposedFormUITest extends UITestBase {
* Tests the admin interface of exposed grouped filters.
*/
function testGroupedFilterAdminUi() {
- $edit = array();
+ $edit = [];
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
@@ -146,7 +146,7 @@ class ExposedFormUITest extends UITestBase {
// Click the Grouped Filters button.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
- $this->drupalPostForm(NULL, array(), t('Grouped filters'));
+ $this->drupalPostForm(NULL, [], t('Grouped filters'));
// After click on 'Grouped Filters', the standard operator and value should
// not be displayed.
@@ -161,7 +161,7 @@ class ExposedFormUITest extends UITestBase {
// Validate a single entry for a grouped filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
- $edit = array();
+ $edit = [];
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
@@ -170,7 +170,7 @@ class ExposedFormUITest extends UITestBase {
// Validate multiple entries for grouped filters.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
- $edit = array();
+ $edit = [];
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$edit["options[group_info][group_items][2][title]"] = 'Is Page';
@@ -179,28 +179,28 @@ class ExposedFormUITest extends UITestBase {
$edit["options[group_info][group_items][3][value][article]"] = 'article';
$edit["options[group_info][group_items][3][value][page]"] = 'page';
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'Correct validation of the node type filter.');
+ $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'Correct validation of the node type filter.');
$this->assertNoGroupedFilterErrors();
// Validate an "is empty" filter -- title without value is valid.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
- $edit = array();
+ $edit = [];
$edit["options[group_info][group_items][1][title]"] = 'No body';
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'The "empty" operator validates correctly.');
+ $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'The "empty" operator validates correctly.');
$this->assertNoGroupedFilterErrors();
// Ensure the string "0" can be used as a value for numeric filters.
- $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', array('name[node_field_data.nid]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria'))));
- $this->drupalPostForm(NULL, array(), t('Expose filter'));
- $this->drupalPostForm(NULL, array(), t('Grouped filters'));
- $edit = array();
+ $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', ['name[node_field_data.nid]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
+ $this->drupalPostForm(NULL, [], t('Expose filter'));
+ $this->drupalPostForm(NULL, [], t('Grouped filters'));
+ $edit = [];
$edit['options[group_info][group_items][1][title]'] = 'Testing zero';
$edit['options[group_info][group_items][1][operator]'] = '>';
$edit['options[group_info][group_items][1][value][value]'] = '0';
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'A string "0" is a valid value.');
+ $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'A string "0" is a valid value.');
$this->assertNoGroupedFilterErrors();
// Ensure "between" filters validate correctly.
@@ -210,14 +210,14 @@ class ExposedFormUITest extends UITestBase {
$edit['options[group_info][group_items][1][value][min]'] = '0';
$edit['options[group_info][group_items][1][value][max]'] = '10';
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'The "between" filter validates correctly.');
+ $this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'The "between" filter validates correctly.');
$this->assertNoGroupedFilterErrors();
}
public function testGroupedFilterAdminUiErrors() {
// Select the empty operator without a title specified.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
- $edit = array();
+ $edit = [];
$edit["options[group_info][group_items][1][title]"] = '';
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPostForm(NULL, $edit, t('Apply'));
@@ -227,14 +227,14 @@ class ExposedFormUITest extends UITestBase {
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Expose filter'));
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Grouped filters'));
- $edit = array();
+ $edit = [];
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText($this->groupFormUiErrors['missing_value']);
// Specify a value without a title.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
- $edit = array();
+ $edit = [];
$edit["options[group_info][group_items][1][title]"] = '';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
diff --git a/core/modules/views_ui/src/Tests/FieldUITest.php b/core/modules/views_ui/src/Tests/FieldUITest.php
index 8c486d8b32f..4e873236996 100644
--- a/core/modules/views_ui/src/Tests/FieldUITest.php
+++ b/core/modules/views_ui/src/Tests/FieldUITest.php
@@ -18,7 +18,7 @@ class FieldUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the UI of field handlers.
@@ -31,7 +31,7 @@ class FieldUITest extends UITestBase {
// Hides the field and check whether the hidden label is appended.
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name';
- $this->drupalPostForm($edit_handler_url, array('options[exclude]' => TRUE), t('Apply'));
+ $this->drupalPostForm($edit_handler_url, ['options[exclude]' => TRUE], t('Apply'));
$this->assertText('Views test: Name [' . t('hidden') . ']');
@@ -62,9 +62,9 @@ class FieldUITest extends UITestBase {
$this->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.');
// Enable aggregation on the view.
- $edit = array(
+ $edit = [
'group_by' => TRUE,
- );
+ ];
$this->drupalPostForm('/admin/structure/views/nojs/display/test_view/default/group_by', $edit, t('Apply'));
$this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.');
@@ -81,7 +81,7 @@ class FieldUITest extends UITestBase {
public function testFieldLabel() {
// Create a view with unformatted style and make sure the fields have no
// labels by default.
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['description'] = $this->randomMachineName(16);
diff --git a/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php b/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php
index 668cc4c1de1..a3e58d755eb 100644
--- a/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php
+++ b/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php
@@ -15,22 +15,22 @@ class FilterBooleanWebTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the filter boolean UI.
*/
public function testFilterBooleanUI() {
- $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', array('name[views_test_data.status]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria'))));
+ $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', ['name[views_test_data.status]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
// Check the field widget label. 'title' should be used as a fallback.
$result = $this->cssSelect('#edit-options-value--wrapper legend span');
$this->assertEqual((string) $result[0], 'Status');
- $this->drupalPostForm(NULL, array(), t('Expose filter'));
- $this->drupalPostForm(NULL, array(), t('Grouped filters'));
+ $this->drupalPostForm(NULL, [], t('Expose filter'));
+ $this->drupalPostForm(NULL, [], t('Grouped filters'));
- $edit = array();
+ $edit = [];
$edit['options[group_info][group_items][1][title]'] = 'Published';
$edit['options[group_info][group_items][1][operator]'] = '=';
$edit['options[group_info][group_items][1][value]'] = 1;
@@ -56,7 +56,7 @@ class FilterBooleanWebTest extends UITestBase {
$this->assertEqual(count($this->cssSelect('a.views-remove-link')), 3);
// Test selecting a default and removing an item.
- $edit = array();
+ $edit = [];
$edit['options[group_info][default_group]'] = 2;
$edit['options[group_info][group_items][3][remove]'] = 1;
$this->drupalPostForm(NULL, $edit, t('Apply'));
diff --git a/core/modules/views_ui/src/Tests/FilterNumericWebTest.php b/core/modules/views_ui/src/Tests/FilterNumericWebTest.php
index 1964f1ea22f..104d62f54da 100644
--- a/core/modules/views_ui/src/Tests/FilterNumericWebTest.php
+++ b/core/modules/views_ui/src/Tests/FilterNumericWebTest.php
@@ -18,18 +18,18 @@ class FilterNumericWebTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests the filter numeric UI.
*/
public function testFilterNumericUI() {
- $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', array('name[views_test_data.age]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria'))));
+ $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', ['name[views_test_data.age]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
- $this->drupalPostForm(NULL, array(), t('Expose filter'));
- $this->drupalPostForm(NULL, array(), t('Grouped filters'));
+ $this->drupalPostForm(NULL, [], t('Expose filter'));
+ $this->drupalPostForm(NULL, [], t('Grouped filters'));
- $edit = array();
+ $edit = [];
$edit['options[group_info][group_items][1][title]'] = 'Old';
$edit['options[group_info][group_items][1][operator]'] = '>';
$edit['options[group_info][group_items][1][value][value]'] = 27;
@@ -48,17 +48,17 @@ class FilterNumericWebTest extends UITestBase {
$this->assertFieldByName($name, $value);
}
- $this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
$this->assertConfigSchemaByName('views.view.test_view');
// Test that the exposed filter works as expected.
- $this->drupalPostForm(NULL, array(), t('Update preview'));
+ $this->drupalPostForm(NULL, [], t('Update preview'));
$this->assertText('John');
$this->assertText('Paul');
$this->assertText('Ringo');
$this->assertText('George');
$this->assertText('Meredith');
- $this->drupalPostForm(NULL, array('age' => '2'), t('Update preview'));
+ $this->drupalPostForm(NULL, ['age' => '2'], t('Update preview'));
$this->assertText('John');
$this->assertText('Paul');
$this->assertNoText('Ringo');
@@ -67,21 +67,21 @@ class FilterNumericWebTest extends UITestBase {
// Change the filter to a single filter to test the schema when the operator
// is not exposed.
- $this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/filter/age', array(), t('Single filter'));
- $edit = array();
+ $this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/filter/age', [], t('Single filter'));
+ $edit = [];
$edit['options[value][value]'] = 25;
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
$this->assertConfigSchemaByName('views.view.test_view');
// Test that the filter works as expected.
- $this->drupalPostForm(NULL, array(), t('Update preview'));
+ $this->drupalPostForm(NULL, [], t('Update preview'));
$this->assertText('John');
$this->assertNoText('Paul');
$this->assertNoText('Ringo');
$this->assertNoText('George');
$this->assertNoText('Meredith');
- $this->drupalPostForm(NULL, array('age' => '26'), t('Update preview'));
+ $this->drupalPostForm(NULL, ['age' => '26'], t('Update preview'));
$this->assertNoText('John');
$this->assertText('Paul');
$this->assertNoText('Ringo');
@@ -91,17 +91,17 @@ class FilterNumericWebTest extends UITestBase {
// Change the filter to a 'between' filter to test if the label and
// description are set for the 'minimum' filter element.
$this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/age');
- $edit = array();
+ $edit = [];
$edit['options[expose][label]'] = 'Age between';
$edit['options[expose][description]'] = 'Description of the exposed filter';
$edit['options[operator]'] = 'between';
$edit['options[value][min]'] = 26;
$edit['options[value][max]'] = 28;
$this->drupalPostForm(NULL, $edit, t('Apply'));
- $this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
+ $this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
$this->assertConfigSchemaByName('views.view.test_view');
- $this->drupalPostForm(NULL, array(), t('Update preview'));
+ $this->drupalPostForm(NULL, [], t('Update preview'));
// Check the max field label.
$this->assertRaw('<label for="edit-age-max">And</label>', 'Max field label found');
$this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
diff --git a/core/modules/views_ui/src/Tests/FilterUITest.php b/core/modules/views_ui/src/Tests/FilterUITest.php
index 371800f841d..1197fc6e022 100644
--- a/core/modules/views_ui/src/Tests/FilterUITest.php
+++ b/core/modules/views_ui/src/Tests/FilterUITest.php
@@ -17,21 +17,21 @@ class FilterUITest extends ViewTestBase {
*
* @var array
*/
- public static $testViews = array('test_filter_in_operator_ui', 'test_filter_groups');
+ public static $testViews = ['test_filter_in_operator_ui', 'test_filter_groups'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('views_ui', 'node');
+ public static $modules = ['views_ui', 'node'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
$this->enableViewsTestModule();
}
@@ -39,7 +39,7 @@ class FilterUITest extends ViewTestBase {
* Tests that an option for a filter is saved as expected from the UI.
*/
public function testFilterInOperatorUi() {
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
$path = 'admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/type';
@@ -48,9 +48,9 @@ class FilterUITest extends ViewTestBase {
$this->assertFieldByName('options[expose][reduce]', FALSE);
// Select "Limit list to selected items" option and apply.
- $edit = array(
+ $edit = [
'options[expose][reduce]' => TRUE,
- );
+ ];
$this->drupalPostForm($path, $edit, t('Apply'));
// Verifies that the option was saved as expected.
@@ -62,7 +62,7 @@ class FilterUITest extends ViewTestBase {
* Tests the filters from the UI.
*/
public function testFiltersUI() {
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/structure/views/view/test_filter_groups');
@@ -94,28 +94,28 @@ class FilterUITest extends ViewTestBase {
* Tests the identifier settings and restrictions.
*/
public function testFilterIdentifier() {
- $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
$this->drupalLogin($admin_user);
$path = 'admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/type';
// Set an empty identifier.
- $edit = array(
+ $edit = [
'options[expose][identifier]' => '',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Apply'));
$this->assertText('The identifier is required if the filter is exposed.');
// Set the identifier to 'value'.
- $edit = array(
+ $edit = [
'options[expose][identifier]' => 'value',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Apply'));
$this->assertText('This identifier is not allowed.');
// Set the identifier to a value with a restricted character.
- $edit = array(
+ $edit = [
'options[expose][identifier]' => 'value value',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Apply'));
$this->assertText('This identifier has illegal characters.');
}
diff --git a/core/modules/views_ui/src/Tests/GroupByTest.php b/core/modules/views_ui/src/Tests/GroupByTest.php
index 8d0ae3a91b3..1bf8f01929d 100644
--- a/core/modules/views_ui/src/Tests/GroupByTest.php
+++ b/core/modules/views_ui/src/Tests/GroupByTest.php
@@ -14,7 +14,7 @@ class GroupByTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_views_groupby_save');
+ public static $testViews = ['test_views_groupby_save'];
/**
* Tests whether basic saving works.
@@ -28,18 +28,18 @@ class GroupByTest extends UITestBase {
$this->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.');
// Enable aggregation on the view.
- $edit = array(
+ $edit = [
'group_by' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by', $edit, t('Apply'));
$this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.');
// Change the groupby type in the UI.
- $this->drupalPostForm($edit_groupby_url, array('options[group_type]' => 'count'), t('Apply'));
+ $this->drupalPostForm($edit_groupby_url, ['options[group_type]' => 'count'], t('Apply'));
$this->assertLink('COUNT(Views test: ID)', 0, 'The count setting is displayed in the UI');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_views_groupby_save');
$display = $view->getDisplay('default');
diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/src/Tests/HandlerTest.php
index bc61a37056f..8fb29f97c89 100644
--- a/core/modules/views_ui/src/Tests/HandlerTest.php
+++ b/core/modules/views_ui/src/Tests/HandlerTest.php
@@ -19,14 +19,14 @@ class HandlerTest extends UITestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('node_test_views');
+ public static $modules = ['node_test_views'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_view_empty', 'test_view_broken', 'node', 'test_node_view');
+ public static $testViews = ['test_view_empty', 'test_view_broken', 'node', 'test_node_view'];
/**
* {@inheritdoc}
@@ -35,7 +35,7 @@ class HandlerTest extends UITestBase {
parent::setUp();
$this->drupalPlaceBlock('page_title_block');
- ViewTestData::createTestViews(get_class($this), array('node_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
/**
@@ -46,13 +46,13 @@ class HandlerTest extends UITestBase {
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
- $schema['views_test_data']['fields']['uid'] = array(
+ $schema['views_test_data']['fields']['uid'] = [
'description' => "The {users}.uid of the author of the beatle entry.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0
- );
+ ];
return $schema;
}
@@ -66,15 +66,15 @@ class HandlerTest extends UITestBase {
*/
protected function viewsData() {
$data = parent::viewsData();
- $data['views_test_data']['uid'] = array(
+ $data['views_test_data']['uid'] = [
'title' => t('UID'),
'help' => t('The test data UID'),
- 'relationship' => array(
+ 'relationship' => [
'id' => 'standard',
'base' => 'users_field_data',
'base field' => 'uid'
- )
- );
+ ]
+ ];
// Create a dummy field with no help text.
$data['views_test_data']['no_help'] = $data['views_test_data']['name'];
@@ -95,43 +95,43 @@ class HandlerTest extends UITestBase {
$add_handler_url = "admin/structure/views/nojs/add-handler/test_view_empty/default/$type";
// Area handler types need to use a different handler.
- if (in_array($type, array('header', 'footer', 'empty'))) {
- $this->drupalPostForm($add_handler_url, array('name[views.area]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
+ if (in_array($type, ['header', 'footer', 'empty'])) {
+ $this->drupalPostForm($add_handler_url, ['name[views.area]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
$id = 'area';
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id";
}
elseif ($type == 'relationship') {
- $this->drupalPostForm($add_handler_url, array('name[views_test_data.uid]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
+ $this->drupalPostForm($add_handler_url, ['name[views_test_data.uid]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
$id = 'uid';
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id";
}
else {
- $this->drupalPostForm($add_handler_url, array('name[views_test_data.job]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
+ $this->drupalPostForm($add_handler_url, ['name[views_test_data.job]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
$id = 'job';
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id";
}
- $this->assertUrl($edit_handler_url, array(), 'The user got redirected to the handler edit form.');
+ $this->assertUrl($edit_handler_url, [], 'The user got redirected to the handler edit form.');
$random_label = $this->randomMachineName();
- $this->drupalPostForm(NULL, array('options[admin_label]' => $random_label), t('Apply'));
+ $this->drupalPostForm(NULL, ['options[admin_label]' => $random_label], t('Apply'));
- $this->assertUrl('admin/structure/views/view/test_view_empty/edit/default', array(), 'The user got redirected to the views edit form.');
+ $this->assertUrl('admin/structure/views/view/test_view_empty/edit/default', [], 'The user got redirected to the views edit form.');
$this->assertLinkByHref($edit_handler_url, 0, 'The handler edit link appears in the UI.');
- $links = $this->xpath('//a[starts-with(normalize-space(text()), :label)]', array(':label' => $random_label));
+ $links = $this->xpath('//a[starts-with(normalize-space(text()), :label)]', [':label' => $random_label]);
$this->assertTrue(isset($links[0]), 'The handler edit link has the right label');
// Save the view and have a look whether the handler was added as expected.
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view_empty');
$display = $view->getDisplay('default');
$this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.');
// Remove the item and check that it's removed
- $this->drupalPostForm($edit_handler_url, array(), t('Remove'));
+ $this->drupalPostForm($edit_handler_url, [], t('Remove'));
$this->assertNoLinkByHref($edit_handler_url, 0, 'The handler edit link does not appears in the UI after removing.');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view_empty');
$display = $view->getDisplay('default');
$this->assertFalse(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was removed from the view itself.');
@@ -140,19 +140,19 @@ class HandlerTest extends UITestBase {
// Test adding a field of the user table using the uid relationship.
$type_info = $handler_types['relationship'];
$add_handler_url = "admin/structure/views/nojs/add-handler/test_view_empty/default/relationship";
- $this->drupalPostForm($add_handler_url, array('name[views_test_data.uid]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
+ $this->drupalPostForm($add_handler_url, ['name[views_test_data.uid]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
$add_handler_url = "admin/structure/views/nojs/add-handler/test_view_empty/default/field";
$type_info = $handler_types['field'];
- $this->drupalPostForm($add_handler_url, array('name[users_field_data.name]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
+ $this->drupalPostForm($add_handler_url, ['name[users_field_data.name]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
$id = 'name';
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/field/$id";
- $this->assertUrl($edit_handler_url, array(), 'The user got redirected to the handler edit form.');
+ $this->assertUrl($edit_handler_url, [], 'The user got redirected to the handler edit form.');
$this->assertFieldByName('options[relationship]', 'uid', 'Ensure the relationship select is filled with the UID relationship.');
- $this->drupalPostForm(NULL, array(), t('Apply'));
+ $this->drupalPostForm(NULL, [], t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view_empty');
$display = $view->getDisplay('default');
$this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.');
@@ -203,8 +203,8 @@ class HandlerTest extends UITestBase {
$href = "admin/structure/views/nojs/handler/test_view_broken/default/$type/id_broken";
- $result = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
- $this->assertEqual(count($result), 1, SafeMarkup::format('Handler (%type) edit link found.', array('%type' => $type)));
+ $result = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
+ $this->assertEqual(count($result), 1, SafeMarkup::format('Handler (%type) edit link found.', ['%type' => $type]));
$text = 'Broken/missing handler';
@@ -223,7 +223,7 @@ class HandlerTest extends UITestBase {
];
foreach ($original_configuration as $key => $value) {
- $this->assertText(SafeMarkup::format('@key: @value', array('@key' => $key, '@value' => $value)));
+ $this->assertText(SafeMarkup::format('@key: @value', ['@key' => $key, '@value' => $value]));
}
}
}
diff --git a/core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php b/core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php
index a01e24bda6a..3318f0b640a 100644
--- a/core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php
+++ b/core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php
@@ -16,16 +16,16 @@ class NewViewConfigSchemaTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('views_ui', 'node', 'comment', 'file', 'taxonomy', 'dblog', 'aggregator');
+ public static $modules = ['views_ui', 'node', 'comment', 'file', 'taxonomy', 'dblog', 'aggregator'];
/**
* Tests creating brand new views.
*/
public function testNewViews() {
- $this->drupalLogin($this->drupalCreateUser(array('administer views')));
+ $this->drupalLogin($this->drupalCreateUser(['administer views']));
// Create views with all core Views wizards.
- $wizards = array(
+ $wizards = [
// Wizard with their own classes.
'node',
'node_revision',
@@ -37,9 +37,9 @@ class NewViewConfigSchemaTest extends WebTestBase {
// Standard derivative classes.
'standard:aggregator_feed',
'standard:aggregator_item',
- );
+ ];
foreach ($wizards as $wizard_key) {
- $edit = array();
+ $edit = [];
$edit['label'] = $this->randomString();
$edit['id'] = strtolower($this->randomMachineName());
$edit['show[wizard_key]'] = $wizard_key;
diff --git a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php b/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php
index 98576ad3b30..fdd73e13022 100644
--- a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php
+++ b/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php
@@ -33,15 +33,15 @@ class OverrideDisplaysTest extends UITestBase {
// same (empty) title in the views wizard, we expect the wizard to have set
// things up so that they both inherit from the default display, and we
// therefore only need to change that to have it take effect for both.
- $edit = array();
+ $edit = [];
$edit['title'] = $original_title = $this->randomMachineName(16);
$edit['override[dropdown]'] = 'default';
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply'));
- $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", array(), t('Save'));
+ $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save'));
// Add a node that will appear in the view, so that the block will actually
// be displayed.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
$this->drupalCreateNode();
// Make sure the title appears in the page.
@@ -63,11 +63,11 @@ class OverrideDisplaysTest extends UITestBase {
// Change the title for the page display only, and make sure that the
// original title still appears on the page.
- $edit = array();
+ $edit = [];
$edit['title'] = $new_title = $this->randomMachineName(16);
$edit['override[dropdown]'] = 'page_1';
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply'));
- $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", array(), t('Save'));
+ $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save'));
$this->drupalGet($view_path);
$this->assertResponse(200);
$this->assertText($new_title);
@@ -95,7 +95,7 @@ class OverrideDisplaysTest extends UITestBase {
// Add a node that will appear in the view, so that the block will actually
// be displayed.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
$this->drupalCreateNode();
// Make sure that the feed, page and block all start off with the correct
@@ -117,14 +117,14 @@ class OverrideDisplaysTest extends UITestBase {
// Put the block into the first sidebar region, and make sure it will not
// display on the view's page display (since we will be searching for the
// presence/absence of the view's title in both the page and the block).
- $this->drupalPlaceBlock("views_block:{$view['id']}-block_1", array(
- 'visibility' => array(
- 'request_path' => array(
+ $this->drupalPlaceBlock("views_block:{$view['id']}-block_1", [
+ 'visibility' => [
+ 'request_path' => [
'pages' => '/' . $view['page[path]'],
'negate' => TRUE,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->drupalGet('');
$this->assertText($view['block[title]']);
@@ -132,10 +132,10 @@ class OverrideDisplaysTest extends UITestBase {
// Edit the page and change the title. This should automatically change
// the feed's title also, but not the block.
- $edit = array();
+ $edit = [];
$edit['title'] = $new_default_title = $this->randomMachineName(16);
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply'));
- $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", array(), t('Save'));
+ $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save'));
$this->drupalGet($view['page[path]']);
$this->assertResponse(200);
$this->assertText($new_default_title);
@@ -153,10 +153,10 @@ class OverrideDisplaysTest extends UITestBase {
// Edit the block and change the title. This should automatically change
// the block title only, and leave the defaults alone.
- $edit = array();
+ $edit = [];
$edit['title'] = $new_block_title = $this->randomMachineName(16);
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/block_1/title", $edit, t('Apply'));
- $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", array(), t('Save'));
+ $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", [], t('Save'));
$this->drupalGet($view['page[path]']);
$this->assertResponse(200);
$this->assertText($new_default_title);
@@ -187,12 +187,12 @@ class OverrideDisplaysTest extends UITestBase {
// Revert the title of the block to the default ones, but submit some new
// values to be sure that the new value is not stored.
- $edit = array();
+ $edit = [];
$edit['title'] = $new_block_title = $this->randomMachineName();
$edit['override[dropdown]'] = 'default_revert';
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/block_1/title", $edit, t('Apply'));
- $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", array(), t('Save'));
+ $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", [], t('Save'));
$this->assertText($view['page[title]']);
}
diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php
index d2dcd121936..48e0ada2a9f 100644
--- a/core/modules/views_ui/src/Tests/PreviewTest.php
+++ b/core/modules/views_ui/src/Tests/PreviewTest.php
@@ -17,23 +17,23 @@ class PreviewTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager', 'test_click_sort');
+ public static $testViews = ['test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager', 'test_click_sort'];
/**
* Tests contextual links in the preview form.
*/
public function testPreviewContextual() {
- \Drupal::service('module_installer')->install(array('contextual'));
+ \Drupal::service('module_installer')->install(['contextual']);
$this->resetAll();
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->assertResponse(200);
- $this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = [], t('Update preview'));
- $elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', array(':ul-class' => 'contextual-links', ':li-class' => 'filter-add'));
+ $elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', [':ul-class' => 'contextual-links', ':li-class' => 'filter-add']);
$this->assertEqual(count($elements), 1, 'The contextual link to add a new field is shown.');
- $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
// Test that area text and exposed filters are present and rendered.
$this->assertFieldByName('id', NULL, 'ID exposed filter field found.');
@@ -49,19 +49,19 @@ class PreviewTest extends UITestBase {
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->assertResponse(200);
- $this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = [], t('Update preview'));
$elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
$this->assertEqual(count($elements), 5);
// Filter just the first result.
- $this->drupalPostForm(NULL, $edit = array('view_args' => '1'), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = ['view_args' => '1'], t('Update preview'));
$elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
$this->assertEqual(count($elements), 1);
// Filter for no results.
- $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
$elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
$this->assertEqual(count($elements), 0);
@@ -73,7 +73,7 @@ class PreviewTest extends UITestBase {
$this->assertText('Test empty text', 'Rendered empty text found.');
// Test feed preview.
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['page[create]'] = 1;
@@ -83,7 +83,7 @@ class PreviewTest extends UITestBase {
$view['page[feed_properties][path]'] = $this->randomMachineName(16);
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
$this->clickLink(t('Feed'));
- $this->drupalPostForm(NULL, array(), t('Update preview'));
+ $this->drupalPostForm(NULL, [], t('Update preview'));
$result = $this->xpath('//div[@id="views-live-preview"]/pre');
$this->assertTrue(strpos($result[0], '<title>' . $view['page[title]'] . '</title>'), 'The Feed RSS preview was rendered.');
@@ -92,7 +92,7 @@ class PreviewTest extends UITestBase {
$settings = \Drupal::configFactory()->getEditable('views.settings');
$settings->set('ui.show.performance_statistics', TRUE)->save();
$this->drupalGet('admin/structure/views/view/test_preview/edit');
- $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
$this->assertText(t('Query build time'));
$this->assertText(t('Query execute time'));
$this->assertText(t('View render time'));
@@ -100,7 +100,7 @@ class PreviewTest extends UITestBase {
// Statistics and query.
$settings->set('ui.show.sql_query.enabled', TRUE)->save();
- $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
$this->assertText(t('Query build time'));
$this->assertText(t('Query execute time'));
$this->assertText(t('View render time'));
@@ -112,7 +112,7 @@ class PreviewTest extends UITestBase {
// Test that statistics and query rendered below the preview.
$settings->set('ui.show.sql_query.where', 'below')->save();
- $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
$this->assertTrue(strpos($this->getRawContent(), 'view-test-preview') < strpos($this->getRawContent(), 'views-query-info'), 'Statistics shown below the preview.');
}
@@ -124,7 +124,7 @@ class PreviewTest extends UITestBase {
* @see https://www.drupal.org/node/2452659
*/
public function testTaxonomyAJAX() {
- \Drupal::service('module_installer')->install(array('taxonomy'));
+ \Drupal::service('module_installer')->install(['taxonomy']);
$this->getPreviewAJAX('taxonomy_term', 'page_1', 0);
}
@@ -134,7 +134,7 @@ class PreviewTest extends UITestBase {
public function testPreviewWithPagersUI() {
// Create 11 nodes and make sure that everyone is returned.
- $this->drupalCreateContentType(array('type' => 'page'));
+ $this->drupalCreateContentType(['type' => 'page']);
for ($i = 0; $i < 11; $i++) {
$this->drupalCreateNode();
}
@@ -143,7 +143,7 @@ class PreviewTest extends UITestBase {
$this->getPreviewAJAX('test_pager_full', 'default', 5);
// Test that the pager is present and rendered.
- $elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
+ $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Full pager found.');
// Verify elements and links to pages.
@@ -165,11 +165,11 @@ class PreviewTest extends UITestBase {
$this->assertTrue($elements[4]->a, 'Link to last page found.');
// Navigate to next page.
- $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--next'));
+ $elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--next']);
$this->clickPreviewLinkAJAX($elements[0]['href'], 5);
// Test that the pager is present and rendered.
- $elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
+ $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Full pager found.');
// Verify elements and links to pages.
@@ -201,7 +201,7 @@ class PreviewTest extends UITestBase {
$this->getPreviewAJAX('test_mini_pager', 'default', 3);
// Test that the pager is present and rendered.
- $elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
+ $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Mini pager found.');
// Verify elements and links to pages.
@@ -213,11 +213,11 @@ class PreviewTest extends UITestBase {
$this->assertTrue($elements[1]->a, 'Link to next page found.');
// Navigate to next page.
- $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--next'));
+ $elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--next']);
$this->clickPreviewLinkAJAX($elements[0]['href'], 3);
// Test that the pager is present and rendered.
- $elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
+ $elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Mini pager found.');
// Verify elements and links to pages.
@@ -237,17 +237,17 @@ class PreviewTest extends UITestBase {
* Tests the additional information query info area.
*/
public function testPreviewAdditionalInfo() {
- \Drupal::service('module_installer')->install(array('views_ui_test'));
+ \Drupal::service('module_installer')->install(['views_ui_test']);
$this->resetAll();
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->assertResponse(200);
- $this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = [], t('Update preview'));
// Check for implementation of hook_views_preview_info_alter().
// @see views_ui_test.module
- $elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', array(':text' => t('Test row count')));
+ $elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', [':text' => t('Test row count')]);
$this->assertEqual(count($elements), 1, 'Views Query Preview Info area altered.');
// Check that additional assets are attached.
$this->assertTrue(strpos($this->getDrupalSettings()['ajaxPageState']['libraries'], 'views_ui_test/views_ui_test.test') !== FALSE, 'Attached library found.');
@@ -261,7 +261,7 @@ class PreviewTest extends UITestBase {
$this->drupalGet('admin/structure/views/view/test_preview_error/edit');
$this->assertResponse(200);
- $this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
+ $this->drupalPostForm(NULL, $edit = [], t('Update preview'));
$this->assertText('Unable to preview due to validation errors.', 'Preview error text found.');
}
@@ -275,7 +275,7 @@ class PreviewTest extends UITestBase {
$this->getPreviewAJAX('test_click_sort', 'page_1', 0);
// Test that the header label is present.
- $elements = $this->xpath('//th[contains(@class, :class)]/a', array(':class' => 'views-field views-field-name'));
+ $elements = $this->xpath('//th[contains(@class, :class)]/a', [':class' => 'views-field views-field-name']);
$this->assertTrue(!empty($elements), 'The header label is present.');
// Verify link.
@@ -285,7 +285,7 @@ class PreviewTest extends UITestBase {
$this->clickPreviewLinkAJAX($elements[0]['href'], 0);
// Test that the header label is present.
- $elements = $this->xpath('//th[contains(@class, :class)]/a', array(':class' => 'views-field views-field-name is-active'));
+ $elements = $this->xpath('//th[contains(@class, :class)]/a', [':class' => 'views-field views-field-name is-active']);
$this->assertTrue(!empty($elements), 'The header label is present.');
// Verify link.
@@ -304,7 +304,7 @@ class PreviewTest extends UITestBase {
*/
protected function getPreviewAJAX($view_name, $panel_id, $row_count) {
$this->drupalGet('admin/structure/views/view/' . $view_name . '/preview/' . $panel_id);
- $result = $this->drupalPostAjaxForm(NULL, array(), array('op' => t('Update preview')));
+ $result = $this->drupalPostAjaxForm(NULL, [], ['op' => t('Update preview')]);
$this->assertPreviewAJAX($result, $row_count);
}
@@ -319,12 +319,12 @@ class PreviewTest extends UITestBase {
protected function clickPreviewLinkAJAX($url, $row_count) {
$content = $this->content;
$drupal_settings = $this->drupalSettings;
- $ajax_settings = array(
+ $ajax_settings = [
'wrapper' => 'views-preview-wrapper',
'method' => 'replaceWith',
- );
+ ];
$url = $this->getAbsoluteUrl($url);
- $post = array('js' => 'true') + $this->getAjaxPageStatePostData();
+ $post = ['js' => 'true'] + $this->getAjaxPageStatePostData();
$result = Json::decode($this->drupalPost($url, '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]));
if (!empty($result)) {
$this->drupalProcessAjaxResponse($content, $result, $ajax_settings, $drupal_settings);
@@ -343,7 +343,7 @@ class PreviewTest extends UITestBase {
protected function assertPreviewAJAX($result, $row_count) {
// Has AJAX callback replied with an insert command? If so, we can
// assume that the page content was updated with AJAX returned data.
- $result_commands = array();
+ $result_commands = [];
foreach ($result as $command) {
$result_commands[$command['command']] = $command;
}
diff --git a/core/modules/views_ui/src/Tests/QueryTest.php b/core/modules/views_ui/src/Tests/QueryTest.php
index 351859bbc8c..066be3e56da 100644
--- a/core/modules/views_ui/src/Tests/QueryTest.php
+++ b/core/modules/views_ui/src/Tests/QueryTest.php
@@ -17,7 +17,7 @@ class QueryTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* {@inheritdoc}
@@ -41,8 +41,8 @@ class QueryTest extends UITestBase {
// Save some query settings.
$query_settings_path = "admin/structure/views/nojs/display/test_view/default/query";
$random_value = $this->randomMachineName();
- $this->drupalPostForm($query_settings_path, array('query[options][test_setting]' => $random_value), t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm($query_settings_path, ['query[options][test_setting]' => $random_value], t('Apply'));
+ $this->drupalPostForm(NULL, [], t('Save'));
// Check that the settings are saved into the view itself.
$view = Views::getView('test_view');
diff --git a/core/modules/views_ui/src/Tests/RearrangeFieldsTest.php b/core/modules/views_ui/src/Tests/RearrangeFieldsTest.php
index 35c229bf131..7d5eddf4308 100644
--- a/core/modules/views_ui/src/Tests/RearrangeFieldsTest.php
+++ b/core/modules/views_ui/src/Tests/RearrangeFieldsTest.php
@@ -17,7 +17,7 @@ class RearrangeFieldsTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Gets the fields from the View.
@@ -25,7 +25,7 @@ class RearrangeFieldsTest extends UITestBase {
protected function getViewFields($view_name = 'test_view', $display_id = 'default') {
$view = Views::getView($view_name);
$view->setDisplay($display_id);
- $fields = array();
+ $fields = [];
foreach ($view->displayHandlers->get('default')->getHandlers('field') as $field => $handler) {
$fields[] = $field;
}
@@ -58,13 +58,13 @@ class RearrangeFieldsTest extends UITestBase {
$this->assertFieldOrder($view_name, $this->getViewFields($view_name));
// Checks that a field is not deleted if a value is not passed back.
- $fields = array();
+ $fields = [];
$this->drupalPostForm('admin/structure/views/nojs/rearrange/' . $view_name . '/default/field', $fields, t('Apply'));
$this->assertFieldOrder($view_name, $this->getViewFields($view_name));
// Checks that revers the new field order is respected.
$reversedFields = array_reverse($this->getViewFields($view_name));
- $fields = array();
+ $fields = [];
foreach ($reversedFields as $delta => $field) {
$fields['fields[' . $field . '][weight]'] = $delta;
}
diff --git a/core/modules/views_ui/src/Tests/RedirectTest.php b/core/modules/views_ui/src/Tests/RedirectTest.php
index 7a019597c76..cc5d2467ec0 100644
--- a/core/modules/views_ui/src/Tests/RedirectTest.php
+++ b/core/modules/views_ui/src/Tests/RedirectTest.php
@@ -14,7 +14,7 @@ class RedirectTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_redirect_view');
+ public static $testViews = ['test_view', 'test_redirect_view'];
/**
* Tests the redirecting.
@@ -25,8 +25,8 @@ class RedirectTest extends UITestBase {
$random_destination = $this->randomMachineName();
$edit_path = "admin/structure/views/view/$view_name/edit";
- $this->drupalPostForm($edit_path, array(), t('Save'), array('query' => array('destination' => $random_destination)));
- $this->assertUrl($random_destination, array(), 'Make sure the user got redirected to the expected page defined in the destination.');
+ $this->drupalPostForm($edit_path, [], t('Save'), ['query' => ['destination' => $random_destination]]);
+ $this->assertUrl($random_destination, [], 'Make sure the user got redirected to the expected page defined in the destination.');
// Setup a view with a certain page display path. If you change the path
// but have the old url in the destination the user should be redirected to
@@ -37,9 +37,9 @@ class RedirectTest extends UITestBase {
$edit_path = "admin/structure/views/view/$view_name/edit";
$path_edit_path = "admin/structure/views/nojs/display/$view_name/page_1/path";
- $this->drupalPostForm($path_edit_path, array('path' => $new_path), t('Apply'));
- $this->drupalPostForm($edit_path, array(), t('Save'), array('query' => array('destination' => 'test-redirect-view')));
- $this->assertUrl($new_path, array(), 'Make sure the user got redirected to the expected page after changing the URL of a page display.');
+ $this->drupalPostForm($path_edit_path, ['path' => $new_path], t('Apply'));
+ $this->drupalPostForm($edit_path, [], t('Save'), ['query' => ['destination' => 'test-redirect-view']]);
+ $this->assertUrl($new_path, [], 'Make sure the user got redirected to the expected page after changing the URL of a page display.');
}
}
diff --git a/core/modules/views_ui/src/Tests/ReportTest.php b/core/modules/views_ui/src/Tests/ReportTest.php
index d7228f17110..0162519c15f 100644
--- a/core/modules/views_ui/src/Tests/ReportTest.php
+++ b/core/modules/views_ui/src/Tests/ReportTest.php
@@ -15,7 +15,7 @@ class ReportTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('views', 'views_ui');
+ public static $modules = ['views', 'views_ui'];
/**
* Stores an admin user used by the different tests.
@@ -26,7 +26,7 @@ class ReportTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer views'));
+ $this->adminUser = $this->drupalCreateUser(['administer views']);
}
/**
diff --git a/core/modules/views_ui/src/Tests/RowUITest.php b/core/modules/views_ui/src/Tests/RowUITest.php
index 188e0b51a21..56890097839 100644
--- a/core/modules/views_ui/src/Tests/RowUITest.php
+++ b/core/modules/views_ui/src/Tests/RowUITest.php
@@ -18,7 +18,7 @@ class RowUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests changing the row plugin and changing some options of a row.
@@ -33,20 +33,20 @@ class RowUITest extends UITestBase {
$this->drupalGet($row_plugin_url);
$this->assertFieldByName('row[type]', 'fields', 'The default row plugin selected in the UI should be fields.');
- $edit = array(
+ $edit = [
'row[type]' => 'test_row'
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertFieldByName('row_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
$random_name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'row_options[test_option]' => $random_name
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->drupalGet($row_options_url);
$this->assertFieldByName('row_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.');
- $this->drupalPostForm($view_edit_url, array(), t('Save'));
+ $this->drupalPostForm($view_edit_url, [], t('Save'));
$this->assertLink(t('Test row plugin'), 0, 'Make sure the test row plugin is shown in the UI');
$view = Views::getView($view_name);
diff --git a/core/modules/views_ui/src/Tests/SettingsTest.php b/core/modules/views_ui/src/Tests/SettingsTest.php
index 30397f404e8..40a52e9ae06 100644
--- a/core/modules/views_ui/src/Tests/SettingsTest.php
+++ b/core/modules/views_ui/src/Tests/SettingsTest.php
@@ -35,16 +35,16 @@ class SettingsTest extends UITestBase {
$this->assertLinkByHref('admin/structure/views/settings');
// Test the confirmation message.
- $this->drupalPostForm('admin/structure/views/settings', array(), t('Save configuration'));
+ $this->drupalPostForm('admin/structure/views/settings', [], t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
// Configure to always show the master display.
- $edit = array(
+ $edit = [
'ui_show_master_display' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['description'] = $this->randomMachineName(16);
@@ -56,9 +56,9 @@ class SettingsTest extends UITestBase {
// Configure to not always show the master display.
// If you have a view without a page or block the master display should be
// still shown.
- $edit = array(
+ $edit = [
'ui_show_master_display' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
$view['page[create]'] = FALSE;
@@ -75,45 +75,45 @@ class SettingsTest extends UITestBase {
// @todo It doesn't seem to be a way to test this as this works just on js.
// Configure to show the embeddable display.
- $edit = array(
+ $edit = [
'ui_show_display_embed' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
$view['id'] = strtolower($this->randomMachineName());
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
$this->assertFieldById('edit-displays-top-add-display-embed');
- $edit = array(
+ $edit = [
'ui_show_display_embed' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
$this->assertNoFieldById('edit-displays-top-add-display-embed');
// Configure to hide/show the sql at the preview.
- $edit = array(
+ $edit = [
'ui_show_sql_query_enabled' => FALSE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
$view['id'] = strtolower($this->randomMachineName());
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
- $this->drupalPostForm(NULL, array(), t('Update preview'));
+ $this->drupalPostForm(NULL, [], t('Update preview'));
$xpath = $this->xpath('//div[@class="views-query-info"]/pre');
$this->assertEqual(count($xpath), 0, 'The views sql is hidden.');
- $edit = array(
+ $edit = [
'ui_show_sql_query_enabled' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
$view['id'] = strtolower($this->randomMachineName());
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
- $this->drupalPostForm(NULL, array(), t('Update preview'));
+ $this->drupalPostForm(NULL, [], t('Update preview'));
$xpath = $this->xpath('//div[@class="views-query-info"]//pre');
$this->assertEqual(count($xpath), 1, 'The views sql is shown.');
$this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
@@ -122,20 +122,20 @@ class SettingsTest extends UITestBase {
// Test the advanced settings form.
// Test the confirmation message.
- $this->drupalPostForm('admin/structure/views/settings/advanced', array(), t('Save configuration'));
+ $this->drupalPostForm('admin/structure/views/settings/advanced', [], t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
- $edit = array(
+ $edit = [
'skip_cache' => TRUE,
'sql_signature' => TRUE,
- );
+ ];
$this->drupalPostForm('admin/structure/views/settings/advanced', $edit, t('Save configuration'));
$this->assertFieldChecked('edit-skip-cache', 'The skip_cache option is checked.');
$this->assertFieldChecked('edit-sql-signature', 'The sql_signature option is checked.');
// Test the "Clear Views' cache" button.
- $this->drupalPostForm('admin/structure/views/settings/advanced', array(), t("Clear Views' cache"));
+ $this->drupalPostForm('admin/structure/views/settings/advanced', [], t("Clear Views' cache"));
$this->assertText(t('The cache has been cleared.'));
}
diff --git a/core/modules/views_ui/src/Tests/StorageTest.php b/core/modules/views_ui/src/Tests/StorageTest.php
index f01a136c6cb..fa33b8f00bc 100644
--- a/core/modules/views_ui/src/Tests/StorageTest.php
+++ b/core/modules/views_ui/src/Tests/StorageTest.php
@@ -17,14 +17,14 @@ class StorageTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('views_ui', 'language');
+ public static $modules = ['views_ui', 'language'];
/**
* Tests changing label, description and tag.
@@ -36,20 +36,20 @@ class StorageTest extends UITestBase {
ConfigurableLanguage::createFromLangcode('fr')->save();
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(),
'tag' => $this->randomMachineName(),
'description' => $this->randomMachineName(30),
'langcode' => 'fr',
- );
+ ];
$this->drupalPostForm("admin/structure/views/nojs/edit-details/$view_name/default", $edit, t('Apply'));
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView($view_name);
- foreach (array('label', 'tag', 'description', 'langcode') as $property) {
- $this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property)));
+ foreach (['label', 'tag', 'description', 'langcode'] as $property) {
+ $this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', ['@property' => $property]));
}
}
diff --git a/core/modules/views_ui/src/Tests/StyleTableTest.php b/core/modules/views_ui/src/Tests/StyleTableTest.php
index 7eb757cb33d..d6b757e9959 100644
--- a/core/modules/views_ui/src/Tests/StyleTableTest.php
+++ b/core/modules/views_ui/src/Tests/StyleTableTest.php
@@ -17,7 +17,7 @@ class StyleTableTest extends UITestBase {
*/
public function testWizard() {
// Create a new view and check that the first field has a label.
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['show[wizard_key]'] = 'node';
diff --git a/core/modules/views_ui/src/Tests/StyleUITest.php b/core/modules/views_ui/src/Tests/StyleUITest.php
index f83cb0391f3..3fc2ae07628 100644
--- a/core/modules/views_ui/src/Tests/StyleUITest.php
+++ b/core/modules/views_ui/src/Tests/StyleUITest.php
@@ -17,7 +17,7 @@ class StyleUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view');
+ public static $testViews = ['test_view'];
/**
* Tests changing the style plugin and changing some options of a style.
@@ -32,20 +32,20 @@ class StyleUITest extends UITestBase {
$this->drupalGet($style_plugin_url);
$this->assertFieldByName('style[type]', 'default', 'The default style plugin selected in the UI should be unformatted list.');
- $edit = array(
+ $edit = [
'style[type]' => 'test_style'
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertFieldByName('style_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
$random_name = $this->randomMachineName();
- $edit = array(
+ $edit = [
'style_options[test_option]' => $random_name
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->drupalGet($style_options_url);
$this->assertFieldByName('style_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.');
- $this->drupalPostForm($view_edit_url, array(), t('Save'));
+ $this->drupalPostForm($view_edit_url, [], t('Save'));
$this->assertLink(t('Test style plugin'), 0, 'Make sure the test style plugin is shown in the UI');
$view = Views::getView($view_name);
@@ -56,8 +56,8 @@ class StyleUITest extends UITestBase {
// Test that fields are working correctly in the UI for style plugins when
// a field row plugin is selected.
- $this->drupalPostForm("admin/structure/views/view/$view_name/edit", array(), 'Add Page');
- $this->drupalPostForm("admin/structure/views/nojs/display/$view_name/page_1/row", array('row[type]' => 'fields'), t('Apply'));
+ $this->drupalPostForm("admin/structure/views/view/$view_name/edit", [], 'Add Page');
+ $this->drupalPostForm("admin/structure/views/nojs/display/$view_name/page_1/row", ['row[type]' => 'fields'], t('Apply'));
// If fields are being used this text will not be shown.
$this->assertNoText(t('The selected style or row format does not use fields.'));
}
diff --git a/core/modules/views_ui/src/Tests/UITestBase.php b/core/modules/views_ui/src/Tests/UITestBase.php
index 74b6f4ff054..0b90e04d1e7 100644
--- a/core/modules/views_ui/src/Tests/UITestBase.php
+++ b/core/modules/views_ui/src/Tests/UITestBase.php
@@ -28,7 +28,7 @@ abstract class UITestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('node', 'views_ui', 'block', 'taxonomy');
+ public static $modules = ['node', 'views_ui', 'block', 'taxonomy'];
/**
* {@inheritdoc}
@@ -38,24 +38,24 @@ abstract class UITestBase extends ViewTestBase {
$this->enableViewsTestModule();
- $this->adminUser = $this->drupalCreateUser(array('administer views'));
+ $this->adminUser = $this->drupalCreateUser(['administer views']);
- $this->fullAdminUser = $this->drupalCreateUser(array('administer views',
+ $this->fullAdminUser = $this->drupalCreateUser(['administer views',
'administer blocks',
'bypass node access',
'access user profiles',
'view all revisions',
'administer permissions',
- ));
+ ]);
$this->drupalLogin($this->fullAdminUser);
}
/**
* A helper method which creates a random view.
*/
- public function randomView(array $view = array()) {
+ public function randomView(array $view = []) {
// Create a new view in the UI.
- $default = array();
+ $default = [];
$default['label'] = $this->randomMachineName(16);
$default['id'] = strtolower($this->randomMachineName(16));
$default['description'] = $this->randomMachineName(16);
@@ -72,7 +72,7 @@ abstract class UITestBase extends ViewTestBase {
/**
* {@inheritdoc}
*/
- protected function drupalGet($path, array $options = array(), array $headers = array()) {
+ protected function drupalGet($path, array $options = [], array $headers = []) {
$url = $this->buildUrl($path, $options);
// Ensure that each nojs page is accessible via ajax as well.
diff --git a/core/modules/views_ui/src/Tests/UnsavedPreviewTest.php b/core/modules/views_ui/src/Tests/UnsavedPreviewTest.php
index 4652daca722..6418fc08688 100644
--- a/core/modules/views_ui/src/Tests/UnsavedPreviewTest.php
+++ b/core/modules/views_ui/src/Tests/UnsavedPreviewTest.php
@@ -28,7 +28,7 @@ class UnsavedPreviewTest extends ViewTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('node', 'views_ui');
+ public static $modules = ['node', 'views_ui'];
/**
* Sets up a Drupal site for running functional and integration tests.
diff --git a/core/modules/views_ui/src/Tests/ViewEditTest.php b/core/modules/views_ui/src/Tests/ViewEditTest.php
index afa21df615c..08c5cfe862b 100644
--- a/core/modules/views_ui/src/Tests/ViewEditTest.php
+++ b/core/modules/views_ui/src/Tests/ViewEditTest.php
@@ -17,7 +17,7 @@ class ViewEditTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_view', 'test_display', 'test_groupwise_term_ui');
+ public static $testViews = ['test_view', 'test_display', 'test_groupwise_term_ui'];
/**
* Tests the delete link on a views UI.
@@ -30,8 +30,8 @@ class ViewEditTest extends UITestBase {
$this->assertTrue($view instanceof View);
$this->clickLink(t('Delete view'));
$this->assertUrl('admin/structure/views/view/test_view/delete');
- $this->drupalPostForm(NULL, array(), t('Delete'));
- $this->assertRaw(t('The view %name has been deleted.', array('%name' => $view->label())));
+ $this->drupalPostForm(NULL, [], t('Delete'));
+ $this->assertRaw(t('The view %name has been deleted.', ['%name' => $view->label()]));
$this->assertUrl('admin/structure/views');
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view');
@@ -44,20 +44,20 @@ class ViewEditTest extends UITestBase {
public function testOtherOptions() {
$this->drupalGet('admin/structure/views/view/test_view');
// Add a new attachment display.
- $this->drupalPostForm(NULL, array(), 'Add Attachment');
+ $this->drupalPostForm(NULL, [], 'Add Attachment');
// Test that a long administrative comment is truncated.
- $edit = array('display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen');
+ $edit = ['display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen'];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_comment', $edit, 'Apply');
$this->assertText('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...');
// Change the machine name for the display from page_1 to test_1.
- $edit = array('display_id' => 'test_1');
+ $edit = ['display_id' => 'test_1'];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_id', $edit, 'Apply');
$this->assertLink(t('test_1'));
// Save the view, and test the new ID has been saved.
- $this->drupalPostForm(NULL, array(), 'Save');
+ $this->drupalPostForm(NULL, [], 'Save');
$view = \Drupal::entityManager()->getStorage('view')->load('test_view');
$displays = $view->get('display');
$this->assertTrue(!empty($displays['test_1']), 'Display data found for new display ID key.');
@@ -72,16 +72,16 @@ class ViewEditTest extends UITestBase {
$this->drupalGet('admin/structure/views/ajax/handler/test_view/fake_display_name/filter/title');
$this->assertText('Invalid display id fake_display_name');
- $edit = array('display_id' => 'test 1');
+ $edit = ['display_id' => 'test 1'];
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this->assertText($error_text);
- $edit = array('display_id' => 'test_1#');
+ $edit = ['display_id' => 'test_1#'];
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this->assertText($error_text);
// Test using an existing display ID.
- $edit = array('display_id' => 'default');
+ $edit = ['display_id' => 'default'];
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this->assertText(t('Display id should be unique.'));
@@ -97,10 +97,10 @@ class ViewEditTest extends UITestBase {
$fields['fields[id][removed]'] = 1;
$fields['fields[name][removed]'] = 1;
$this->drupalPostForm('admin/structure/views/nojs/rearrange/test_view/default/field', $fields, t('Apply'));
- $this->drupalPostForm(NULL, array(), 'Save');
- $this->drupalPostForm(NULL, array(), t('Cancel'));
+ $this->drupalPostForm(NULL, [], 'Save');
+ $this->drupalPostForm(NULL, [], t('Cancel'));
$this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, 'No error message is displayed.');
- $this->assertUrl('admin/structure/views', array(), 'Redirected back to the view listing page..');
+ $this->assertUrl('admin/structure/views', [], 'Redirected back to the view listing page..');
}
/**
@@ -108,21 +108,21 @@ class ViewEditTest extends UITestBase {
*/
public function testEditFormLanguageOptions() {
// Language options should not exist without language module.
- $test_views = array(
+ $test_views = [
'test_view' => 'default',
'test_display' => 'page_1',
- );
+ ];
foreach ($test_views as $view_name => $display) {
$this->drupalGet('admin/structure/views/view/' . $view_name);
$this->assertResponse(200);
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
$this->assertNoLinkByHref($langcode_url);
- $this->assertNoLink(t('@type language selected for page', array('@type' => t('Content'))));
+ $this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
$this->assertNoLink(t('Content language of view row'));
}
// Make the site multilingual and test the options again.
- $this->container->get('module_installer')->install(array('language', 'content_translation'));
+ $this->container->get('module_installer')->install(['language', 'content_translation']);
ConfigurableLanguage::createFromLangcode('hu')->save();
$this->resetAll();
$this->rebuildContainer();
@@ -134,12 +134,12 @@ class ViewEditTest extends UITestBase {
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
if ($view_name == 'test_view') {
$this->assertNoLinkByHref($langcode_url);
- $this->assertNoLink(t('@type language selected for page', array('@type' => t('Content'))));
+ $this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
$this->assertNoLink(t('Content language of view row'));
}
else {
$this->assertLinkByHref($langcode_url);
- $this->assertNoLink(t('@type language selected for page', array('@type' => t('Content'))));
+ $this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
$this->assertLink(t('Content language of view row'));
}
@@ -152,14 +152,14 @@ class ViewEditTest extends UITestBase {
$this->assertFieldByName('rendering_language', '***LANGUAGE_entity_translation***');
// Test that the order of the language list is similar to other language
// lists, such as in the content translation settings.
- $expected_elements = array(
+ $expected_elements = [
'***LANGUAGE_entity_translation***',
'***LANGUAGE_entity_default***',
'***LANGUAGE_site_default***',
'***LANGUAGE_language_interface***',
'en',
'hu',
- );
+ ];
$elements = $this->xpath('//select[@id="edit-rendering-language"]/option');
// Compare values inside the option elements with expected values.
for ($i = 0; $i < count($elements); $i++) {
@@ -202,7 +202,7 @@ class ViewEditTest extends UITestBase {
$this->drupalGet($langcode_url);
$this->assertResponse(200);
- $expected_elements = array(
+ $expected_elements = [
'all',
'***LANGUAGE_site_default***',
'***LANGUAGE_language_interface***',
@@ -211,7 +211,7 @@ class ViewEditTest extends UITestBase {
'hu',
'und',
'zxx',
- );
+ ];
$elements = $this->xpath('//div[@id="edit-options-value"]//input');
// Compare values inside the option elements with expected values.
for ($i = 0; $i < count($elements); $i++) {
@@ -229,7 +229,7 @@ class ViewEditTest extends UITestBase {
$edit["name[taxonomy_term_field_data.tid_representative]"] = TRUE;
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_groupwise_term_ui/default/relationship', $edit, 'Add and configure relationships');
// Apply changes.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_groupwise_term_ui/default/relationship/tid_representative', $edit, 'Apply');
}
diff --git a/core/modules/views_ui/src/Tests/ViewsListTest.php b/core/modules/views_ui/src/Tests/ViewsListTest.php
index 768e449d5c5..51786746c11 100644
--- a/core/modules/views_ui/src/Tests/ViewsListTest.php
+++ b/core/modules/views_ui/src/Tests/ViewsListTest.php
@@ -18,7 +18,7 @@ class ViewsListTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('block', 'views_ui');
+ public static $modules = ['block', 'views_ui'];
/**
* A user with permission to administer views.
diff --git a/core/modules/views_ui/src/Tests/ViewsUITourTest.php b/core/modules/views_ui/src/Tests/ViewsUITourTest.php
index ccc0f296d72..31748e87276 100644
--- a/core/modules/views_ui/src/Tests/ViewsUITourTest.php
+++ b/core/modules/views_ui/src/Tests/ViewsUITourTest.php
@@ -31,11 +31,11 @@ class ViewsUITourTest extends TourTestBase {
*
* @var array
*/
- public static $modules = array('views_ui', 'tour', 'language', 'locale');
+ public static $modules = ['views_ui', 'tour', 'language', 'locale'];
protected function setUp() {
parent::setUp();
- $this->adminUser = $this->drupalCreateUser(array('administer views', 'access tour'));
+ $this->adminUser = $this->drupalCreateUser(['administer views', 'access tour']);
$this->drupalLogin($this->adminUser);
}
@@ -66,18 +66,18 @@ class ViewsUITourTest extends TourTestBase {
ConfigurableLanguage::createFromLangcode($langcode)->save();
// Handler titles that need translations.
- $handler_titles = array(
+ $handler_titles = [
'Format',
'Fields',
'Sort criteria',
'Filter criteria',
- );
+ ];
foreach ($handler_titles as $handler_title) {
// Create source string.
- $source = $this->localeStorage->createString(array(
+ $source = $this->localeStorage->createString([
'source' => $handler_title
- ));
+ ]);
$source->save();
$this->createTranslation($source, $langcode);
}
@@ -101,11 +101,11 @@ class ViewsUITourTest extends TourTestBase {
* Creates single translation for source string.
*/
public function createTranslation($source, $langcode) {
- return $this->localeStorage->createTranslation(array(
+ return $this->localeStorage->createTranslation([
'lid' => $source->lid,
'language' => $langcode,
'translation' => $this->randomMachineName(100),
- ))->save();
+ ])->save();
}
}
diff --git a/core/modules/views_ui/src/Tests/WizardTest.php b/core/modules/views_ui/src/Tests/WizardTest.php
index 58cf97c83fd..4e57e8f7b69 100644
--- a/core/modules/views_ui/src/Tests/WizardTest.php
+++ b/core/modules/views_ui/src/Tests/WizardTest.php
@@ -18,7 +18,7 @@ class WizardTest extends WizardTestBase {
* Tests filling in the wizard with really long strings.
*/
public function testWizardFieldLength() {
- $view = array();
+ $view = [];
$view['label'] = $this->randomMachineName(256);
$view['id'] = strtolower($this->randomMachineName(129));
$view['page[create]'] = TRUE;
@@ -54,7 +54,7 @@ class WizardTest extends WizardTestBase {
$view['rest_export[path]'] = $this->randomMachineName(254);
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
- $this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
+ $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
// Assert that the page title is correctly truncated.
$this->assertText(views_ui_truncate($view['page[title]'], 32));
}
diff --git a/core/modules/views_ui/src/Tests/XssTest.php b/core/modules/views_ui/src/Tests/XssTest.php
index 1d61f194272..1c3cef62cb2 100644
--- a/core/modules/views_ui/src/Tests/XssTest.php
+++ b/core/modules/views_ui/src/Tests/XssTest.php
@@ -14,7 +14,7 @@ class XssTest extends UITestBase {
*
* @var array
*/
- public static $modules = array('node', 'user', 'views_ui', 'views_ui_test');
+ public static $modules = ['node', 'user', 'views_ui', 'views_ui_test'];
public function testViewsUi() {
$this->drupalGet('admin/structure/views/view/sa_contrib_2013_035');
diff --git a/core/modules/views_ui/src/ViewAddForm.php b/core/modules/views_ui/src/ViewAddForm.php
index c3d5c77ce2a..429032c8457 100644
--- a/core/modules/views_ui/src/ViewAddForm.php
+++ b/core/modules/views_ui/src/ViewAddForm.php
@@ -51,83 +51,83 @@ class ViewAddForm extends ViewFormBase {
*/
public function form(array $form, FormStateInterface $form_state) {
$form['#attached']['library'][] = 'views_ui/views_ui.admin';
- $form['#attributes']['class'] = array('views-admin');
+ $form['#attributes']['class'] = ['views-admin'];
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'fieldset',
'#title' => t('View basic information'),
- '#attributes' => array('class' => array('fieldset-no-legend')),
- );
+ '#attributes' => ['class' => ['fieldset-no-legend']],
+ ];
- $form['name']['label'] = array(
+ $form['name']['label'] = [
'#type' => 'textfield',
'#title' => $this->t('View name'),
'#required' => TRUE,
'#size' => 32,
'#default_value' => '',
'#maxlength' => 255,
- );
- $form['name']['id'] = array(
+ ];
+ $form['name']['id'] = [
'#type' => 'machine_name',
'#maxlength' => 128,
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\views\Views::getView',
- 'source' => array('name', 'label'),
- ),
+ 'source' => ['name', 'label'],
+ ],
'#description' => $this->t('A unique machine-readable name for this View. It must only contain lowercase letters, numbers, and underscores.'),
- );
+ ];
- $form['name']['description_enable'] = array(
+ $form['name']['description_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Description'),
- );
- $form['name']['description'] = array(
+ ];
+ $form['name']['description'] = [
'#type' => 'textfield',
'#title' => $this->t('Provide description'),
'#title_display' => 'invisible',
'#size' => 64,
'#default_value' => '',
- '#states' => array(
- 'visible' => array(
- ':input[name="description_enable"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="description_enable"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
// Create a wrapper for the entire dynamic portion of the form. Everything
// that can be updated by AJAX goes somewhere inside here. For example, this
// is needed by "Show" dropdown (below); it changes the base table of the
// view and therefore potentially requires all options on the form to be
// dynamically updated.
- $form['displays'] = array();
+ $form['displays'] = [];
// Create the part of the form that allows the user to select the basic
// properties of what the view will display.
- $form['displays']['show'] = array(
+ $form['displays']['show'] = [
'#type' => 'fieldset',
'#title' => t('View settings'),
'#tree' => TRUE,
- '#attributes' => array('class' => array('container-inline')),
- );
+ '#attributes' => ['class' => ['container-inline']],
+ ];
// Create the "Show" dropdown, which allows the base table of the view to be
// selected.
$wizard_plugins = $this->wizardManager->getDefinitions();
- $options = array();
+ $options = [];
foreach ($wizard_plugins as $key => $wizard) {
$options[$key] = $wizard['title'];
}
- $form['displays']['show']['wizard_key'] = array(
+ $form['displays']['show']['wizard_key'] = [
'#type' => 'select',
'#title' => $this->t('Show'),
'#options' => $options,
- );
+ ];
$show_form = &$form['displays']['show'];
$default_value = \Drupal::moduleHandler()->moduleExists('node') ? 'node' : 'users';
- $show_form['wizard_key']['#default_value'] = WizardPluginBase::getSelected($form_state, array('show', 'wizard_key'), $default_value, $show_form['wizard_key']);
+ $show_form['wizard_key']['#default_value'] = WizardPluginBase::getSelected($form_state, ['show', 'wizard_key'], $default_value, $show_form['wizard_key']);
// Changing this dropdown updates the entire content of $form['displays'] via
// AJAX.
- views_ui_add_ajax_trigger($show_form, 'wizard_key', array('displays'));
+ views_ui_add_ajax_trigger($show_form, 'wizard_key', ['displays']);
// Build the rest of the form based on the currently selected wizard plugin.
$wizard_key = $show_form['wizard_key']['#default_value'];
@@ -144,13 +144,13 @@ class ViewAddForm extends ViewFormBase {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = $this->t('Save and edit');
// Remove EntityFormController::save() form the submission handlers.
- $actions['submit']['#submit'] = array(array($this, 'submitForm'));
- $actions['cancel'] = array(
+ $actions['submit']['#submit'] = [[$this, 'submitForm']];
+ $actions['cancel'] = [
'#type' => 'submit',
'#value' => $this->t('Cancel'),
- '#submit' => array('::cancel'),
- '#limit_validation_errors' => array(),
- );
+ '#submit' => ['::cancel'],
+ '#limit_validation_errors' => [],
+ ];
return $actions;
}
@@ -158,7 +158,7 @@ class ViewAddForm extends ViewFormBase {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
- $wizard_type = $form_state->getValue(array('show', 'wizard_key'));
+ $wizard_type = $form_state->getValue(['show', 'wizard_key']);
$wizard_instance = $this->wizardManager->createInstance($wizard_type);
$form_state->set('wizard', $wizard_instance->getPluginDefinition());
$form_state->set('wizard_instance', $wizard_instance);
@@ -187,7 +187,7 @@ class ViewAddForm extends ViewFormBase {
return;
}
$this->entity->save();
- drupal_set_message($this->t('The view %name has been saved.', array('%name' => $form_state->getValue('label'))));
+ drupal_set_message($this->t('The view %name has been saved.', ['%name' => $form_state->getValue('label')]));
$form_state->setRedirectUrl($this->entity->urlInfo('edit-form'));
}
diff --git a/core/modules/views_ui/src/ViewDuplicateForm.php b/core/modules/views_ui/src/ViewDuplicateForm.php
index 9870d8e8e14..fa2db608011 100644
--- a/core/modules/views_ui/src/ViewDuplicateForm.php
+++ b/core/modules/views_ui/src/ViewDuplicateForm.php
@@ -22,26 +22,26 @@ class ViewDuplicateForm extends ViewFormBase {
public function form(array $form, FormStateInterface $form_state) {
parent::form($form, $form_state);
- $form['#title'] = $this->t('Duplicate of @label', array('@label' => $this->entity->label()));
+ $form['#title'] = $this->t('Duplicate of @label', ['@label' => $this->entity->label()]);
- $form['label'] = array(
+ $form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('View name'),
'#required' => TRUE,
'#size' => 32,
'#maxlength' => 255,
- '#default_value' => $this->t('Duplicate of @label', array('@label' => $this->entity->label())),
- );
- $form['id'] = array(
+ '#default_value' => $this->t('Duplicate of @label', ['@label' => $this->entity->label()]),
+ ];
+ $form['id'] = [
'#type' => 'machine_name',
'#maxlength' => 128,
- '#machine_name' => array(
+ '#machine_name' => [
'exists' => '\Drupal\views\Views::getView',
- 'source' => array('label'),
- ),
+ 'source' => ['label'],
+ ],
'#default_value' => '',
'#description' => $this->t('A unique machine-readable name for this View. It must only contain lowercase letters, numbers, and underscores.'),
- );
+ ];
return $form;
}
@@ -50,10 +50,10 @@ class ViewDuplicateForm extends ViewFormBase {
* {@inheritdoc}
*/
protected function actions(array $form, FormStateInterface $form_state) {
- $actions['submit'] = array(
+ $actions['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Duplicate'),
- );
+ ];
return $actions;
}
diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php
index 6e819395914..67d1229555d 100644
--- a/core/modules/views_ui/src/ViewEditForm.php
+++ b/core/modules/views_ui/src/ViewEditForm.php
@@ -98,7 +98,7 @@ class ViewEditForm extends ViewFormBase {
if ($display_id) {
if (!$view->getExecutable()->setDisplay($display_id)) {
- $form['#markup'] = $this->t('Invalid display id @display', array('@display' => $display_id));
+ $form['#markup'] = $this->t('Invalid display id @display', ['@display' => $display_id]);
return $form;
}
}
@@ -112,55 +112,55 @@ class ViewEditForm extends ViewFormBase {
$form['#attached']['library'][] = 'views_ui/views_ui.admin';
$form['#attached']['library'][] = 'views_ui/admin.styling';
- $form += array(
+ $form += [
'#prefix' => '',
'#suffix' => '',
- );
+ ];
$view_status = $view->status() ? 'enabled' : 'disabled';
$form['#prefix'] .= '<div class="views-edit-view views-admin ' . $view_status . ' clearfix">';
$form['#suffix'] = '</div>' . $form['#suffix'];
- $form['#attributes']['class'] = array('form-edit');
+ $form['#attributes']['class'] = ['form-edit'];
if ($view->isLocked()) {
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $this->entityManager->getStorage('user')->load($view->lock->owner),
- );
- $lock_message_substitutions = array(
+ ];
+ $lock_message_substitutions = [
'@user' => drupal_render($username),
'@age' => $this->dateFormatter->formatTimeDiffSince($view->lock->updated),
':url' => $view->url('break-lock-form'),
- );
- $form['locked'] = array(
+ ];
+ $form['locked'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('view-locked', 'messages', 'messages--warning')),
+ '#attributes' => ['class' => ['view-locked', 'messages', 'messages--warning']],
'#children' => $this->t('This view is being edited by user @user, and is therefore locked from editing by others. This lock is @age old. Click here to <a href=":url">break this lock</a>.', $lock_message_substitutions),
'#weight' => -10,
- );
+ ];
}
else {
- $form['changed'] = array(
+ $form['changed'] = [
'#type' => 'container',
- '#attributes' => array('class' => array('view-changed', 'messages', 'messages--warning')),
+ '#attributes' => ['class' => ['view-changed', 'messages', 'messages--warning']],
'#children' => $this->t('You have unsaved changes.'),
'#weight' => -10,
- );
+ ];
if (empty($view->changed)) {
$form['changed']['#attributes']['class'][] = 'js-hide';
}
}
- $form['displays'] = array(
+ $form['displays'] = [
'#prefix' => '<h1 class="unit-title clearfix">' . $this->t('Displays') . '</h1>',
'#type' => 'container',
- '#attributes' => array(
- 'class' => array(
+ '#attributes' => [
+ 'class' => [
'views-displays',
- ),
- ),
- );
+ ],
+ ],
+ ];
$form['displays']['top'] = $this->renderDisplayTop($view);
@@ -170,13 +170,13 @@ class ViewEditForm extends ViewFormBase {
$form_state->set('display_id', $display_id);
// The part of the page where editing will take place.
- $form['displays']['settings'] = array(
+ $form['displays']['settings'] = [
'#type' => 'container',
'#id' => 'edit-display-settings',
- '#attributes' => array(
- 'class' => array('edit-display-settings'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['edit-display-settings'],
+ ],
+ ];
// Add a text that the display is disabled.
if ($view->getExecutable()->displayHandlers->has($display_id)) {
@@ -187,8 +187,8 @@ class ViewEditForm extends ViewFormBase {
// Add the edit display content
$tab_content = $this->getDisplayTab($view);
- $tab_content['#theme_wrappers'] = array('container');
- $tab_content['#attributes'] = array('class' => array('views-display-tab'));
+ $tab_content['#theme_wrappers'] = ['container'];
+ $tab_content['#attributes'] = ['class' => ['views-display-tab']];
$tab_content['#id'] = 'views-tab-' . $display_id;
// Mark deleted displays as such.
$display = $view->get('display');
@@ -200,10 +200,10 @@ class ViewEditForm extends ViewFormBase {
if ($view->getExecutable()->displayHandlers->has($display_id) && !$view->getExecutable()->displayHandlers->get($display_id)->isEnabled()) {
$tab_content['#attributes']['class'][] = 'views-display-disabled';
}
- $form['displays']['settings']['settings_content'] = array(
+ $form['displays']['settings']['settings_content'] = [
'#type' => 'container',
'tab_content' => $tab_content,
- );
+ ];
}
return $form;
@@ -216,12 +216,12 @@ class ViewEditForm extends ViewFormBase {
$actions = parent::actions($form, $form_state);
unset($actions['delete']);
- $actions['cancel'] = array(
+ $actions['cancel'] = [
'#type' => 'submit',
'#value' => $this->t('Cancel'),
- '#submit' => array('::cancel'),
- '#limit_validation_errors' => array(),
- );
+ '#submit' => ['::cancel'],
+ '#limit_validation_errors' => [],
+ ];
if ($this->entity->isLocked()) {
$actions['submit']['#access'] = FALSE;
$actions['cancel']['#access'] = FALSE;
@@ -285,10 +285,10 @@ class ViewEditForm extends ViewFormBase {
unset($displays[$id]);
// Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors.
- $form_state->setRedirect('entity.view.edit_display_form', array(
+ $form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $new_id,
- ));
+ ]);
}
}
$view->set('display', $displays);
@@ -320,7 +320,7 @@ class ViewEditForm extends ViewFormBase {
$view->save();
- drupal_set_message($this->t('The view %name has been saved.', array('%name' => $view->label())));
+ drupal_set_message($this->t('The view %name has been saved.', ['%name' => $view->label()]));
// Remove this view from cache so we can edit it properly.
$this->tempStore->delete($view->id());
@@ -345,14 +345,14 @@ class ViewEditForm extends ViewFormBase {
* Returns a renderable array representing the edit page for one display.
*/
public function getDisplayTab($view) {
- $build = array();
+ $build = [];
$display_id = $this->displayID;
$display = $view->getExecutable()->displayHandlers->get($display_id);
// If the plugin doesn't exist, display an error message instead of an edit
// page.
if (empty($display)) {
// @TODO: Improved UX for the case where a plugin is missing.
- $build['#markup'] = $this->t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display->display['id'], '@plugin' => $display->display['display_plugin']));
+ $build['#markup'] = $this->t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", ['@display' => $display->display['id'], '@plugin' => $display->display['display_plugin']]);
}
// Build the content of the edit page.
else {
@@ -374,10 +374,10 @@ class ViewEditForm extends ViewFormBase {
*/
public function getDisplayDetails($view, $display) {
$display_title = $this->getDisplayLabel($view, $display['id'], FALSE);
- $build = array(
- '#theme_wrappers' => array('container'),
- '#attributes' => array('id' => 'edit-display-settings-details'),
- );
+ $build = [
+ '#theme_wrappers' => ['container'],
+ '#attributes' => ['id' => 'edit-display-settings-details'],
+ ];
$is_display_deleted = !empty($display['deleted']);
// The master display cannot be duplicated.
@@ -386,14 +386,14 @@ class ViewEditForm extends ViewFormBase {
$is_enabled = $view->getExecutable()->displayHandlers->get($display['id'])->isEnabled();
if ($display['id'] != 'default') {
- $build['top']['#theme_wrappers'] = array('container');
+ $build['top']['#theme_wrappers'] = ['container'];
$build['top']['#attributes']['id'] = 'edit-display-settings-top';
- $build['top']['#attributes']['class'] = array('views-ui-display-tab-actions', 'edit-display-settings-top', 'views-ui-display-tab-bucket', 'clearfix');
+ $build['top']['#attributes']['class'] = ['views-ui-display-tab-actions', 'edit-display-settings-top', 'views-ui-display-tab-bucket', 'clearfix'];
// The Delete, Duplicate and Undo Delete buttons.
- $build['top']['actions'] = array(
- '#theme_wrappers' => array('dropbutton_wrapper'),
- );
+ $build['top']['actions'] = [
+ '#theme_wrappers' => ['dropbutton_wrapper'],
+ ];
// Because some of the 'links' are actually submit buttons, we have to
// manually wrap each item in <li> and the whole list in <ul>.
@@ -401,14 +401,14 @@ class ViewEditForm extends ViewFormBase {
if (!$is_display_deleted) {
if (!$is_enabled) {
- $build['top']['actions']['enable'] = array(
+ $build['top']['actions']['enable'] = [
'#type' => 'submit',
'#value' => $this->t('Enable @display_title', ['@display_title' => $display_title]),
- '#limit_validation_errors' => array(),
- '#submit' => array('::submitDisplayEnable', '::submitDelayDestination'),
+ '#limit_validation_errors' => [],
+ '#submit' => ['::submitDisplayEnable', '::submitDelayDestination'],
'#prefix' => '<li class="enable">',
"#suffix" => '</li>',
- );
+ ];
}
// Add a link to view the page unless the view is disabled or has no
// path.
@@ -423,118 +423,118 @@ class ViewEditForm extends ViewFormBase {
else {
$url = Url::fromUri("base:$path");
}
- $build['top']['actions']['path'] = array(
+ $build['top']['actions']['path'] = [
'#type' => 'link',
'#title' => $this->t('View @display_title', ['@display_title' => $display_title]),
- '#options' => array('alt' => array($this->t("Go to the real page for this display"))),
+ '#options' => ['alt' => [$this->t("Go to the real page for this display")]],
'#url' => $url,
'#prefix' => '<li class="view">',
"#suffix" => '</li>',
- );
+ ];
}
}
if (!$is_default) {
- $build['top']['actions']['duplicate'] = array(
+ $build['top']['actions']['duplicate'] = [
'#type' => 'submit',
'#value' => $this->t('Duplicate @display_title', ['@display_title' => $display_title]),
- '#limit_validation_errors' => array(),
- '#submit' => array('::submitDisplayDuplicate', '::submitDelayDestination'),
+ '#limit_validation_errors' => [],
+ '#submit' => ['::submitDisplayDuplicate', '::submitDelayDestination'],
'#prefix' => '<li class="duplicate">',
"#suffix" => '</li>',
- );
+ ];
}
// Always allow a display to be deleted.
- $build['top']['actions']['delete'] = array(
+ $build['top']['actions']['delete'] = [
'#type' => 'submit',
'#value' => $this->t('Delete @display_title', ['@display_title' => $display_title]),
- '#limit_validation_errors' => array(),
- '#submit' => array('::submitDisplayDelete', '::submitDelayDestination'),
+ '#limit_validation_errors' => [],
+ '#submit' => ['::submitDisplayDelete', '::submitDelayDestination'],
'#prefix' => '<li class="delete">',
"#suffix" => '</li>',
- );
+ ];
- foreach (Views::fetchPluginNames('display', NULL, array($view->get('storage')->get('base_table'))) as $type => $label) {
+ foreach (Views::fetchPluginNames('display', NULL, [$view->get('storage')->get('base_table')]) as $type => $label) {
if ($type == $display['display_plugin']) {
continue;
}
- $build['top']['actions']['duplicate_as'][$type] = array(
+ $build['top']['actions']['duplicate_as'][$type] = [
'#type' => 'submit',
'#value' => $this->t('Duplicate as @type', ['@type' => $label]),
- '#limit_validation_errors' => array(),
- '#submit' => array('::submitDuplicateDisplayAsType', '::submitDelayDestination'),
+ '#limit_validation_errors' => [],
+ '#submit' => ['::submitDuplicateDisplayAsType', '::submitDelayDestination'],
'#prefix' => '<li class="duplicate">',
'#suffix' => '</li>',
- );
+ ];
}
}
else {
- $build['top']['actions']['undo_delete'] = array(
+ $build['top']['actions']['undo_delete'] = [
'#type' => 'submit',
'#value' => $this->t('Undo delete of @display_title', ['@display_title' => $display_title]),
- '#limit_validation_errors' => array(),
- '#submit' => array('::submitDisplayUndoDelete', '::submitDelayDestination'),
+ '#limit_validation_errors' => [],
+ '#submit' => ['::submitDisplayUndoDelete', '::submitDelayDestination'],
'#prefix' => '<li class="undo-delete">',
"#suffix" => '</li>',
- );
+ ];
}
if ($is_enabled) {
- $build['top']['actions']['disable'] = array(
+ $build['top']['actions']['disable'] = [
'#type' => 'submit',
'#value' => $this->t('Disable @display_title', ['@display_title' => $display_title]),
- '#limit_validation_errors' => array(),
- '#submit' => array('::submitDisplayDisable', '::submitDelayDestination'),
+ '#limit_validation_errors' => [],
+ '#submit' => ['::submitDisplayDisable', '::submitDelayDestination'],
'#prefix' => '<li class="disable">',
"#suffix" => '</li>',
- );
+ ];
}
$build['top']['actions']['suffix']['#markup'] = '</ul>';
// The area above the three columns.
- $build['top']['display_title'] = array(
+ $build['top']['display_title'] = [
'#theme' => 'views_ui_display_tab_setting',
'#description' => $this->t('Display name'),
'#link' => $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($display_title, 'display_title'),
- );
+ ];
}
- $build['columns'] = array();
- $build['columns']['#theme_wrappers'] = array('container');
- $build['columns']['#attributes'] = array('id' => 'edit-display-settings-main', 'class' => array('clearfix', 'views-display-columns'));
+ $build['columns'] = [];
+ $build['columns']['#theme_wrappers'] = ['container'];
+ $build['columns']['#attributes'] = ['id' => 'edit-display-settings-main', 'class' => ['clearfix', 'views-display-columns']];
- $build['columns']['first']['#theme_wrappers'] = array('container');
- $build['columns']['first']['#attributes'] = array('class' => array('views-display-column', 'first'));
+ $build['columns']['first']['#theme_wrappers'] = ['container'];
+ $build['columns']['first']['#attributes'] = ['class' => ['views-display-column', 'first']];
- $build['columns']['second']['#theme_wrappers'] = array('container');
- $build['columns']['second']['#attributes'] = array('class' => array('views-display-column', 'second'));
+ $build['columns']['second']['#theme_wrappers'] = ['container'];
+ $build['columns']['second']['#attributes'] = ['class' => ['views-display-column', 'second']];
- $build['columns']['second']['settings'] = array();
- $build['columns']['second']['header'] = array();
- $build['columns']['second']['footer'] = array();
- $build['columns']['second']['empty'] = array();
- $build['columns']['second']['pager'] = array();
+ $build['columns']['second']['settings'] = [];
+ $build['columns']['second']['header'] = [];
+ $build['columns']['second']['footer'] = [];
+ $build['columns']['second']['empty'] = [];
+ $build['columns']['second']['pager'] = [];
// The third column buckets are wrapped in details.
- $build['columns']['third'] = array(
+ $build['columns']['third'] = [
'#type' => 'details',
'#title' => $this->t('Advanced'),
- '#theme_wrappers' => array('details'),
- '#attributes' => array(
- 'class' => array(
+ '#theme_wrappers' => ['details'],
+ '#attributes' => [
+ 'class' => [
'views-display-column',
'third',
- ),
- ),
- );
+ ],
+ ],
+ ];
// Collapse the details by default.
$build['columns']['third']['#open'] = \Drupal::config('views.settings')->get('ui.show.advanced_column');
// Each option (e.g. title, access, display as grid/table/list) fits into one
// of several "buckets," or boxes (Format, Fields, Sort, and so on).
- $buckets = array();
+ $buckets = [];
// Fetch options from the display plugin, with a list of buckets they go into.
- $options = array();
+ $options = [];
$view->getExecutable()->displayHandlers->get($display['id'])->optionsSummary($buckets, $options);
// Place each option into its bucket.
@@ -589,10 +589,10 @@ class ViewEditForm extends ViewFormBase {
$view->cacheSet();
// Redirect to the top-level edit page.
- $form_state->setRedirect('entity.view.edit_display_form', array(
+ $form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $id,
- ));
+ ]);
}
/**
@@ -608,10 +608,10 @@ class ViewEditForm extends ViewFormBase {
$view->cacheSet();
// Redirect to the top-level edit page.
- $form_state->setRedirect('entity.view.edit_display_form', array(
+ $form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $id,
- ));
+ ]);
}
/**
@@ -626,10 +626,10 @@ class ViewEditForm extends ViewFormBase {
$view->cacheSet();
// Redirect to the top-level edit page.
- $form_state->setRedirect('entity.view.edit_display_form', array(
+ $form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $id,
- ));
+ ]);
}
/**
@@ -681,43 +681,43 @@ class ViewEditForm extends ViewFormBase {
public function renderDisplayTop(ViewUI $view) {
$display_id = $this->displayID;
$element['#theme_wrappers'][] = 'views_ui_container';
- $element['#attributes']['class'] = array('views-display-top', 'clearfix');
- $element['#attributes']['id'] = array('views-display-top');
+ $element['#attributes']['class'] = ['views-display-top', 'clearfix'];
+ $element['#attributes']['id'] = ['views-display-top'];
// Extra actions for the display
- $element['extra_actions'] = array(
+ $element['extra_actions'] = [
'#type' => 'dropbutton',
- '#attributes' => array(
+ '#attributes' => [
'id' => 'views-display-extra-actions',
- ),
- '#links' => array(
- 'edit-details' => array(
+ ],
+ '#links' => [
+ 'edit-details' => [
'title' => $this->t('Edit view name/description'),
'url' => Url::fromRoute('views_ui.form_edit_details', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]),
- 'attributes' => array('class' => array('views-ajax-link')),
- ),
- 'analyze' => array(
+ 'attributes' => ['class' => ['views-ajax-link']],
+ ],
+ 'analyze' => [
'title' => $this->t('Analyze view'),
'url' => Url::fromRoute('views_ui.form_analyze', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]),
- 'attributes' => array('class' => array('views-ajax-link')),
- ),
- 'duplicate' => array(
+ 'attributes' => ['class' => ['views-ajax-link']],
+ ],
+ 'duplicate' => [
'title' => $this->t('Duplicate view'),
'url' => $view->urlInfo('duplicate-form'),
- ),
- 'reorder' => array(
+ ],
+ 'reorder' => [
'title' => $this->t('Reorder displays'),
'url' => Url::fromRoute('views_ui.form_reorder_displays', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]),
- 'attributes' => array('class' => array('views-ajax-link')),
- ),
- ),
- );
+ 'attributes' => ['class' => ['views-ajax-link']],
+ ],
+ ],
+ ];
if ($view->access('delete')) {
- $element['extra_actions']['#links']['delete'] = array(
+ $element['extra_actions']['#links']['delete'] = [
'title' => $this->t('Delete view'),
'url' => $view->urlInfo('delete-form'),
- );
+ ];
}
// Let other modules add additional links here.
@@ -725,17 +725,17 @@ class ViewEditForm extends ViewFormBase {
if (isset($view->type) && $view->type != $this->t('Default')) {
if ($view->type == $this->t('Overridden')) {
- $element['extra_actions']['#links']['revert'] = array(
+ $element['extra_actions']['#links']['revert'] = [
'title' => $this->t('Revert view'),
'href' => "admin/structure/views/view/{$view->id()}/revert",
- 'query' => array('destination' => $view->url('edit-form')),
- );
+ 'query' => ['destination' => $view->url('edit-form')],
+ ];
}
else {
- $element['extra_actions']['#links']['delete'] = array(
+ $element['extra_actions']['#links']['delete'] = [
'title' => $this->t('Delete view'),
'url' => $view->urlInfo('delete-form'),
- );
+ ];
}
}
@@ -750,18 +750,18 @@ class ViewEditForm extends ViewFormBase {
}
// Buttons for adding a new display.
- foreach (Views::fetchPluginNames('display', NULL, array($view->get('base_table'))) as $type => $label) {
- $element['add_display'][$type] = array(
+ foreach (Views::fetchPluginNames('display', NULL, [$view->get('base_table')]) as $type => $label) {
+ $element['add_display'][$type] = [
'#type' => 'submit',
- '#value' => $this->t('Add @display', array('@display' => $label)),
- '#limit_validation_errors' => array(),
- '#submit' => array('::submitDisplayAdd', '::submitDelayDestination'),
- '#attributes' => array('class' => array('add-display')),
+ '#value' => $this->t('Add @display', ['@display' => $label]),
+ '#limit_validation_errors' => [],
+ '#submit' => ['::submitDisplayAdd', '::submitDelayDestination'],
+ '#attributes' => ['class' => ['add-display']],
// Allow JavaScript to remove the 'Add ' prefix from the button label when
// placing the button in a "Add" dropdown menu.
- '#process' => array_merge(array('views_ui_form_button_was_clicked'), $this->elementInfo->getInfoProperty('submit', '#process', array())),
- '#values' => array($this->t('Add @display', array('@display' => $label)), $label),
- );
+ '#process' => array_merge(['views_ui_form_button_was_clicked'], $this->elementInfo->getInfoProperty('submit', '#process', [])),
+ '#values' => [$this->t('Add @display', ['@display' => $label]), $label],
+ ];
}
return $element;
@@ -824,10 +824,10 @@ class ViewEditForm extends ViewFormBase {
$view->cacheSet();
// Redirect to the new display's edit page.
- $form_state->setRedirect('entity.view.edit_display_form', array(
+ $form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $new_display_id,
- ));
+ ]);
}
/**
@@ -846,10 +846,10 @@ class ViewEditForm extends ViewFormBase {
$view->cacheSet();
// Redirect to the new display's edit page.
- $form_state->setRedirect('entity.view.edit_display_form', array(
+ $form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $display_id,
- ));
+ ]);
}
/**
@@ -872,10 +872,10 @@ class ViewEditForm extends ViewFormBase {
$view->cacheSet();
// Redirect to the new display's edit page.
- $form_state->setRedirect('entity.view.edit_display_form', array(
+ $form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $new_display_id,
- ));
+ ]);
}
/**
@@ -885,14 +885,14 @@ class ViewEditForm extends ViewFormBase {
* object emerges out of refactoring.
*/
public function buildOptionForm(ViewUI $view, $id, $option, $display) {
- $option_build = array();
+ $option_build = [];
$option_build['#theme'] = 'views_ui_display_tab_setting';
$option_build['#description'] = $option['title'];
$option_build['#link'] = $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($option['value'], $id, '', empty($option['desc']) ? '' : $option['desc']);
- $option_build['#links'] = array();
+ $option_build['#links'] = [];
if (!empty($option['links']) && is_array($option['links'])) {
foreach ($option['links'] as $link_id => $link_value) {
$option_build['#settings_links'][] = $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($option['setting'], $link_id, 'views-button-configure', $link_value);
@@ -925,9 +925,9 @@ class ViewEditForm extends ViewFormBase {
$types = $executable->getHandlerTypes();
- $build = array(
- '#theme_wrappers' => array('views_ui_display_tab_bucket'),
- );
+ $build = [
+ '#theme_wrappers' => ['views_ui_display_tab_bucket'],
+ ];
$build['#overridden'] = FALSE;
$build['#defaulted'] = FALSE;
@@ -953,11 +953,11 @@ class ViewEditForm extends ViewFormBase {
$style_plugin = $executable->style_plugin;
$uses_fields = $style_plugin && $style_plugin->usesFields();
if (!$uses_fields) {
- $build['fields'][] = array(
+ $build['fields'][] = [
'#markup' => $this->t('The selected style or row format does not use fields.'),
- '#theme_wrappers' => array('views_ui_container'),
- '#attributes' => array('class' => array('views-display-setting')),
- );
+ '#theme_wrappers' => ['views_ui_container'],
+ '#attributes' => ['class' => ['views-display-setting']],
+ ];
return $build;
}
break;
@@ -965,47 +965,47 @@ class ViewEditForm extends ViewFormBase {
case 'footer':
case 'empty':
if (!$executable->display_handler->usesAreas()) {
- $build[$type][] = array(
- '#markup' => $this->t('The selected display type does not use @type plugins', array('@type' => $type)),
- '#theme_wrappers' => array('views_ui_container'),
- '#attributes' => array('class' => array('views-display-setting')),
- );
+ $build[$type][] = [
+ '#markup' => $this->t('The selected display type does not use @type plugins', ['@type' => $type]),
+ '#theme_wrappers' => ['views_ui_container'],
+ '#attributes' => ['class' => ['views-display-setting']],
+ ];
return $build;
}
break;
}
// Create an array of actions to pass to links template.
- $actions = array();
+ $actions = [];
$count_handlers = count($executable->display_handler->getHandlers($type));
// Create the add text variable for the add action.
- $add_text = $this->t('Add <span class="visually-hidden">@type</span>', array('@type' => $types[$type]['ltitle']));
+ $add_text = $this->t('Add <span class="visually-hidden">@type</span>', ['@type' => $types[$type]['ltitle']]);
- $actions['add'] = array(
+ $actions['add'] = [
'title' => $add_text,
'url' => Url::fromRoute('views_ui.form_add_handler', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display['id'], 'type' => $type]),
- 'attributes' => array('class' => array('icon compact add', 'views-ajax-link'), 'id' => 'views-add-' . $type),
- );
+ 'attributes' => ['class' => ['icon compact add', 'views-ajax-link'], 'id' => 'views-add-' . $type],
+ ];
if ($count_handlers > 0) {
// Create the rearrange text variable for the rearrange action.
- $rearrange_text = $type == 'filter' ? $this->t('And/Or Rearrange <span class="visually-hidden">filter criteria</span>') : $this->t('Rearrange <span class="visually-hidden">@type</span>', array('@type' => $types[$type]['ltitle']));
+ $rearrange_text = $type == 'filter' ? $this->t('And/Or Rearrange <span class="visually-hidden">filter criteria</span>') : $this->t('Rearrange <span class="visually-hidden">@type</span>', ['@type' => $types[$type]['ltitle']]);
- $actions['rearrange'] = array(
+ $actions['rearrange'] = [
'title' => $rearrange_text,
'url' => $rearrange_url,
- 'attributes' => array('class' => array($class, 'views-ajax-link'), 'id' => 'views-rearrange-' . $type),
- );
+ 'attributes' => ['class' => [$class, 'views-ajax-link'], 'id' => 'views-rearrange-' . $type],
+ ];
}
// Render the array of links
- $build['#actions'] = array(
+ $build['#actions'] = [
'#type' => 'dropbutton',
'#links' => $actions,
- '#attributes' => array(
- 'class' => array('views-ui-settings-bucket-operations'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['views-ui-settings-bucket-operations'],
+ ],
+ ];
if (!$executable->display_handler->isDefaultDisplay()) {
if (!$executable->display_handler->isDefaulted($types[$type]['plural'])) {
@@ -1019,14 +1019,14 @@ class ViewEditForm extends ViewFormBase {
static $relationships = NULL;
if (!isset($relationships)) {
// Get relationship labels.
- $relationships = array();
+ $relationships = [];
foreach ($executable->display_handler->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->adminLabel();
}
}
// Filters can now be grouped so we do a little bit extra:
- $groups = array();
+ $groups = [];
$grouping = FALSE;
if ($type == 'filter') {
$group_info = $executable->display_handler->getOption('filter_groups');
@@ -1035,28 +1035,28 @@ class ViewEditForm extends ViewFormBase {
// "OR" label next to items within the group.
if (!empty($group_info['groups']) && (count($group_info['groups']) > 1 || current($group_info['groups']) == 'OR')) {
$grouping = TRUE;
- $groups = array(0 => array());
+ $groups = [0 => []];
}
}
- $build['fields'] = array();
+ $build['fields'] = [];
foreach ($executable->display_handler->getOption($types[$type]['plural']) as $id => $field) {
// Build the option link for this handler ("Node: ID = article").
- $build['fields'][$id] = array();
+ $build['fields'][$id] = [];
$build['fields'][$id]['#theme'] = 'views_ui_display_tab_setting';
$handler = $executable->display_handler->getHandler($type, $id);
if ($handler->broken()) {
$build['fields'][$id]['#class'][] = 'broken';
$field_name = $handler->adminLabel();
- $build['fields'][$id]['#link'] = $this->l($field_name, new Url('views_ui.form_handler', array(
+ $build['fields'][$id]['#link'] = $this->l($field_name, new Url('views_ui.form_handler', [
'js' => 'nojs',
'view' => $view->id(),
'display_id' => $display['id'],
'type' => $type,
'id' => $id,
- ), array('attributes' => array('class' => array('views-ajax-link')))));
+ ], ['attributes' => ['class' => ['views-ajax-link']]]));
continue;
}
@@ -1067,39 +1067,39 @@ class ViewEditForm extends ViewFormBase {
$description = $handler->adminSummary();
$link_text = $field_name . (empty($description) ? '' : " ($description)");
- $link_attributes = array('class' => array('views-ajax-link'));
+ $link_attributes = ['class' => ['views-ajax-link']];
if (!empty($field['exclude'])) {
$link_attributes['class'][] = 'views-field-excluded';
// Add a [hidden] marker, if the field is excluded.
$link_text .= ' [' . $this->t('hidden') . ']';
}
- $build['fields'][$id]['#link'] = $this->l($link_text, new Url('views_ui.form_handler', array(
+ $build['fields'][$id]['#link'] = $this->l($link_text, new Url('views_ui.form_handler', [
'js' => 'nojs',
'view' => $view->id(),
'display_id' => $display['id'],
'type' => $type,
'id' => $id,
- ), array('attributes' => $link_attributes)));
+ ], ['attributes' => $link_attributes]));
$build['fields'][$id]['#class'][] = Html::cleanCssIdentifier($display['id'] . '-' . $type . '-' . $id);
if ($executable->display_handler->useGroupBy() && $handler->usesGroupBy()) {
- $build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', array('@text' => $this->t('Aggregation settings'))), new Url('views_ui.form_handler_group', array(
+ $build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', ['@text' => $this->t('Aggregation settings')]), new Url('views_ui.form_handler_group', [
'js' => 'nojs',
'view' => $view->id(),
'display_id' => $display['id'],
'type' => $type,
'id' => $id,
- ), array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => $this->t('Aggregation settings')))));
+ ], ['attributes' => ['class' => ['views-button-configure', 'views-ajax-link'], 'title' => $this->t('Aggregation settings')]]));
}
if ($handler->hasExtraOptions()) {
- $build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', array('@text' => $this->t('Settings'))), new Url('views_ui.form_handler_extra', array(
+ $build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', ['@text' => $this->t('Settings')]), new Url('views_ui.form_handler_extra', [
'js' => 'nojs',
'view' => $view->id(),
'display_id' => $display['id'],
'type' => $type,
'id' => $id,
- ), array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => $this->t('Settings')))));
+ ], ['attributes' => ['class' => ['views-button-configure', 'views-ajax-link'], 'title' => $this->t('Settings')]]));
}
if ($grouping) {
@@ -1116,15 +1116,15 @@ class ViewEditForm extends ViewFormBase {
// If using grouping, re-order fields so that they show up properly in the list.
if ($type == 'filter' && $grouping) {
$store = $build['fields'];
- $build['fields'] = array();
+ $build['fields'] = [];
foreach ($groups as $gid => $contents) {
// Display an operator between each group.
if (!empty($build['fields'])) {
- $build['fields'][] = array(
+ $build['fields'][] = [
'#theme' => 'views_ui_display_tab_setting',
- '#class' => array('views-group-text'),
+ '#class' => ['views-group-text'],
'#link' => ($group_info['operator'] == 'OR' ? $this->t('OR') : $this->t('AND')),
- );
+ ];
}
// Display an operator between each pair of filters within the group.
$keys = array_keys($contents);
diff --git a/core/modules/views_ui/src/ViewFormBase.php b/core/modules/views_ui/src/ViewFormBase.php
index 1533b80caf4..49cdc4955f2 100644
--- a/core/modules/views_ui/src/ViewFormBase.php
+++ b/core/modules/views_ui/src/ViewFormBase.php
@@ -88,7 +88,7 @@ abstract class ViewFormBase extends EntityForm {
$executable = $view->getExecutable();
$executable->initDisplay();
$display_id = $this->displayID;
- $tabs = array();
+ $tabs = [];
// Create a tab for each display.
foreach ($view->get('display') as $id => $display) {
@@ -99,15 +99,15 @@ abstract class ViewFormBase extends EntityForm {
continue;
}
- $tabs[$id] = array(
+ $tabs[$id] = [
'#theme' => 'menu_local_task',
'#weight' => $display['position'],
- '#link' => array(
+ '#link' => [
'title' => $this->getDisplayLabel($view, $id),
- 'localized_options' => array(),
+ 'localized_options' => [],
'url' => $view->urlInfo('edit-display-form')->setRouteParameter('display_id', $id),
- ),
- );
+ ],
+ ];
if (!empty($display['deleted'])) {
$tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'views-display-deleted-link';
}
diff --git a/core/modules/views_ui/src/ViewListBuilder.php b/core/modules/views_ui/src/ViewListBuilder.php
index b38a15f75bd..604426cab0d 100644
--- a/core/modules/views_ui/src/ViewListBuilder.php
+++ b/core/modules/views_ui/src/ViewListBuilder.php
@@ -65,10 +65,10 @@ class ViewListBuilder extends ConfigEntityListBuilder {
* {@inheritdoc}
*/
public function load() {
- $entities = array(
- 'enabled' => array(),
- 'disabled' => array(),
- );
+ $entities = [
+ 'enabled' => [],
+ 'disabled' => [],
+ ];
foreach (parent::load() as $entity) {
if ($entity->status()) {
$entities['enabled'][] = $entity;
@@ -85,73 +85,73 @@ class ViewListBuilder extends ConfigEntityListBuilder {
*/
public function buildRow(EntityInterface $view) {
$row = parent::buildRow($view);
- return array(
- 'data' => array(
- 'view_name' => array(
- 'data' => array(
+ return [
+ 'data' => [
+ 'view_name' => [
+ 'data' => [
'#plain_text' => $view->label(),
- ),
- ),
- 'machine_name' => array(
- 'data' => array(
+ ],
+ ],
+ 'machine_name' => [
+ 'data' => [
'#plain_text' => $view->id(),
- ),
- ),
- 'description' => array(
- 'data' => array(
+ ],
+ ],
+ 'description' => [
+ 'data' => [
'#plain_text' => $view->get('description'),
- ),
- ),
- 'displays' => array(
- 'data' => array(
+ ],
+ ],
+ 'displays' => [
+ 'data' => [
'#theme' => 'views_ui_view_displays_list',
'#displays' => $this->getDisplaysList($view),
- ),
- ),
+ ],
+ ],
'operations' => $row['operations'],
- ),
- '#attributes' => array(
- 'class' => array($view->status() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'),
- ),
- );
+ ],
+ '#attributes' => [
+ 'class' => [$view->status() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
public function buildHeader() {
- return array(
- 'view_name' => array(
+ return [
+ 'view_name' => [
'data' => $this->t('View name'),
- '#attributes' => array(
- 'class' => array('views-ui-name'),
- ),
- ),
- 'machine_name' => array(
+ '#attributes' => [
+ 'class' => ['views-ui-name'],
+ ],
+ ],
+ 'machine_name' => [
'data' => $this->t('Machine name'),
- '#attributes' => array(
- 'class' => array('views-ui-machine-name'),
- ),
- ),
- 'description' => array(
+ '#attributes' => [
+ 'class' => ['views-ui-machine-name'],
+ ],
+ ],
+ 'description' => [
'data' => $this->t('Description'),
- '#attributes' => array(
- 'class' => array('views-ui-description'),
- ),
- ),
- 'displays' => array(
+ '#attributes' => [
+ 'class' => ['views-ui-description'],
+ ],
+ ],
+ 'displays' => [
'data' => $this->t('Displays'),
- '#attributes' => array(
- 'class' => array('views-ui-displays'),
- ),
- ),
- 'operations' => array(
+ '#attributes' => [
+ 'class' => ['views-ui-displays'],
+ ],
+ ],
+ 'operations' => [
'data' => $this->t('Operations'),
- '#attributes' => array(
- 'class' => array('views-ui-operations'),
- ),
- ),
- );
+ '#attributes' => [
+ 'class' => ['views-ui-operations'],
+ ],
+ ],
+ ];
}
/**
@@ -161,15 +161,15 @@ class ViewListBuilder extends ConfigEntityListBuilder {
$operations = parent::getDefaultOperations($entity);
if ($entity->hasLinkTemplate('duplicate-form')) {
- $operations['duplicate'] = array(
+ $operations['duplicate'] = [
'title' => $this->t('Duplicate'),
'weight' => 15,
'url' => $entity->urlInfo('duplicate-form'),
- );
+ ];
}
// Add AJAX functionality to enable/disable operations.
- foreach (array('enable', 'disable') as $op) {
+ foreach (['enable', 'disable'] as $op) {
if (isset($operations[$op])) {
$operations[$op]['url'] = $entity->urlInfo($op);
// Enable and disable operations should use AJAX.
@@ -191,37 +191,37 @@ class ViewListBuilder extends ConfigEntityListBuilder {
$list['#attached']['library'][] = 'core/drupal.ajax';
$list['#attached']['library'][] = 'views_ui/views_ui.listing';
- $form['filters'] = array(
+ $form['filters'] = [
'#type' => 'container',
- '#attributes' => array(
- 'class' => array('table-filter', 'js-show'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['table-filter', 'js-show'],
+ ],
+ ];
- $list['filters']['text'] = array(
+ $list['filters']['text'] = [
'#type' => 'search',
'#title' => $this->t('Filter'),
'#title_display' => 'invisible',
'#size' => 60,
'#placeholder' => $this->t('Filter by view name, machine name, description, or display path'),
- '#attributes' => array(
- 'class' => array('views-filter-text'),
+ '#attributes' => [
+ 'class' => ['views-filter-text'],
'data-table' => '.views-listing-table',
'autocomplete' => 'off',
'title' => $this->t('Enter a part of the view name, machine name, description, or display path to filter by.'),
- ),
- );
+ ],
+ ];
- $list['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', array(), array('context' => 'Plural')) . '</h2>';
- $list['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', array(), array('context' => 'Plural')) . '</h2>';
- foreach (array('enabled', 'disabled') as $status) {
+ $list['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', [], ['context' => 'Plural']) . '</h2>';
+ $list['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', [], ['context' => 'Plural']) . '</h2>';
+ foreach (['enabled', 'disabled'] as $status) {
$list[$status]['#type'] = 'container';
- $list[$status]['#attributes'] = array('class' => array('views-list-section', $status));
- $list[$status]['table'] = array(
+ $list[$status]['#attributes'] = ['class' => ['views-list-section', $status]];
+ $list[$status]['table'] = [
'#theme' => 'views_ui_views_listing_table',
'#headers' => $this->buildHeader(),
- '#attributes' => array('class' => array('views-listing-table', $status)),
- );
+ '#attributes' => ['class' => ['views-listing-table', $status]],
+ ];
foreach ($entities[$status] as $entity) {
$list[$status]['table']['#rows'][$entity->id()] = $this->buildRow($entity);
}
@@ -244,7 +244,7 @@ class ViewListBuilder extends ConfigEntityListBuilder {
* An array of display types that this view includes.
*/
protected function getDisplaysList(EntityInterface $view) {
- $displays = array();
+ $displays = [];
$executable = $view->getExecutable();
$executable->initDisplay();
@@ -263,10 +263,10 @@ class ViewListBuilder extends ConfigEntityListBuilder {
$rendered_path = '/' . $path;
}
}
- $displays[] = array(
+ $displays[] = [
'display' => $definition['admin'],
'path' => $rendered_path,
- );
+ ];
}
}
diff --git a/core/modules/views_ui/src/ViewPreviewForm.php b/core/modules/views_ui/src/ViewPreviewForm.php
index 7b779297dea..2cc25332efc 100644
--- a/core/modules/views_ui/src/ViewPreviewForm.php
+++ b/core/modules/views_ui/src/ViewPreviewForm.php
@@ -22,43 +22,43 @@ class ViewPreviewForm extends ViewFormBase {
$form_state->disableCache();
- $form['controls']['#attributes'] = array('class' => array('clearfix'));
+ $form['controls']['#attributes'] = ['class' => ['clearfix']];
- $form['controls']['title'] = array(
+ $form['controls']['title'] = [
'#prefix' => '<h2 class="view-preview-form__title">',
'#markup' => $this->t('Preview'),
'#suffix' => '</h2>',
- );
+ ];
// Add a checkbox controlling whether or not this display auto-previews.
- $form['controls']['live_preview'] = array(
+ $form['controls']['live_preview'] = [
'#type' => 'checkbox',
'#id' => 'edit-displays-live-preview',
'#title' => $this->t('Auto preview'),
'#default_value' => \Drupal::config('views.settings')->get('ui.always_live_preview'),
- );
+ ];
// Add the arguments textfield
- $form['controls']['view_args'] = array(
+ $form['controls']['view_args'] = [
'#type' => 'textfield',
'#title' => $this->t('Preview with contextual filters:'),
- '#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')),
+ '#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', ['%example' => '40/12/10']),
'#id' => 'preview-args',
- );
+ ];
- $args = array();
+ $args = [];
if (!$form_state->isValueEmpty('view_args')) {
$args = explode('/', $form_state->getValue('view_args'));
}
$user_input = $form_state->getUserInput();
if ($form_state->get('show_preview') || !empty($user_input['js'])) {
- $form['preview'] = array(
+ $form['preview'] = [
'#weight' => 110,
- '#theme_wrappers' => array('container'),
+ '#theme_wrappers' => ['container'],
'#attributes' => ['id' => 'views-live-preview', 'class' => ['views-live-preview']],
'preview' => $view->renderPreview($this->displayID, $args),
- );
+ ];
}
$uri = $view->urlInfo('preview-form');
$uri->setRouteParameter('display_id', $this->displayID);
@@ -72,27 +72,27 @@ class ViewPreviewForm extends ViewFormBase {
*/
protected function actions(array $form, FormStateInterface $form_state) {
$view = $this->entity;
- return array(
- '#attributes' => array(
+ return [
+ '#attributes' => [
'id' => 'preview-submit-wrapper',
- 'class' => array('preview-submit-wrapper')
- ),
- 'button' => array(
+ 'class' => ['preview-submit-wrapper']
+ ],
+ 'button' => [
'#type' => 'submit',
'#value' => $this->t('Update preview'),
- '#attributes' => array('class' => array('arguments-preview')),
- '#submit' => array('::submitPreview'),
+ '#attributes' => ['class' => ['arguments-preview']],
+ '#submit' => ['::submitPreview'],
'#id' => 'preview-submit',
- '#ajax' => array(
+ '#ajax' => [
'url' => Url::fromRoute('entity.view.preview_form', ['view' => $view->id(), 'display_id' => $this->displayID]),
'wrapper' => 'views-preview-wrapper',
'event' => 'click',
- 'progress' => array('type' => 'fullscreen'),
+ 'progress' => ['type' => 'fullscreen'],
'method' => 'replaceWith',
'disable-refocus' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php
index cb222b0b442..b6841a84bc6 100644
--- a/core/modules/views_ui/src/ViewUI.php
+++ b/core/modules/views_ui/src/ViewUI.php
@@ -107,7 +107,7 @@ class ViewUI implements ViewEntityInterface {
*
* @var array
*/
- public static $forms = array(
+ public static $forms = [
'add-handler' => '\Drupal\views_ui\Form\Ajax\AddItem',
'analyze' => '\Drupal\views_ui\Form\Ajax\Analyze',
'handler' => '\Drupal\views_ui\Form\Ajax\ConfigHandler',
@@ -118,7 +118,7 @@ class ViewUI implements ViewEntityInterface {
'rearrange' => '\Drupal\views_ui\Form\Ajax\Rearrange',
'rearrange-filter' => '\Drupal\views_ui\Form\Ajax\RearrangeFilter',
'reorder-displays' => '\Drupal\views_ui\Form\Ajax\ReorderDisplays',
- );
+ ];
/**
* Whether the config is being created, updated or deleted through the
@@ -277,22 +277,22 @@ class ViewUI implements ViewEntityInterface {
* docblock outdated?
*/
public function getStandardButtons(&$form, FormStateInterface $form_state, $form_id, $name = NULL) {
- $form['actions'] = array(
+ $form['actions'] = [
'#type' => 'actions',
- );
+ ];
if (empty($name)) {
$name = t('Apply');
if (!empty($this->stack) && count($this->stack) > 1) {
$name = t('Apply and continue');
}
- $names = array(t('Apply'), t('Apply and continue'));
+ $names = [t('Apply'), t('Apply and continue')];
}
// Forms that are purely informational set an ok_button flag, so we know not
// to create an "Apply" button for them.
if (!$form_state->get('ok_button')) {
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $name,
'#id' => 'edit-submit-' . Html::getUniqueId($form_id),
@@ -301,9 +301,9 @@ class ViewUI implements ViewEntityInterface {
// the current display. Since we have no way of knowing at this point
// which display the user wants to update, views_ui_standard_submit will
// take care of running the regular submit handler as appropriate.
- '#submit' => array(array($this, 'standardSubmit')),
+ '#submit' => [[$this, 'standardSubmit']],
'#button_type' => 'primary',
- );
+ ];
// Form API button click detection requires the button's #value to be the
// same between the form build of the initial page request, and the
// initial form build of the request processing the form submission.
@@ -315,21 +315,21 @@ class ViewUI implements ViewEntityInterface {
// button labels.
if (isset($names)) {
$form['actions']['submit']['#values'] = $names;
- $form['actions']['submit']['#process'] = array_merge(array('views_ui_form_button_was_clicked'), \Drupal::service('element_info')->getInfoProperty($form['actions']['submit']['#type'], '#process', array()));
+ $form['actions']['submit']['#process'] = array_merge(['views_ui_form_button_was_clicked'], \Drupal::service('element_info')->getInfoProperty($form['actions']['submit']['#type'], '#process', []));
}
// If a validation handler exists for the form, assign it to this button.
$form['actions']['submit']['#validate'][] = [$form_state->getFormObject(), 'validateForm'];
}
// Create a "Cancel" button. For purely informational forms, label it "OK".
- $cancel_submit = function_exists($form_id . '_cancel') ? $form_id . '_cancel' : array($this, 'standardCancel');
- $form['actions']['cancel'] = array(
+ $cancel_submit = function_exists($form_id . '_cancel') ? $form_id . '_cancel' : [$this, 'standardCancel'];
+ $form['actions']['cancel'] = [
'#type' => 'submit',
'#value' => !$form_state->get('ok_button') ? t('Cancel') : t('Ok'),
- '#submit' => array($cancel_submit),
- '#validate' => array(),
- '#limit_validation_errors' => array(),
- );
+ '#submit' => [$cancel_submit],
+ '#validate' => [],
+ '#limit_validation_errors' => [],
+ ];
// Compatibility, to be removed later: // TODO: When is "later"?
// We used to set these items on the form, but now we want them on the $form_state:
@@ -348,11 +348,11 @@ class ViewUI implements ViewEntityInterface {
*/
public function getOverrideValues($form, FormStateInterface $form_state) {
// Make sure the dropdown exists in the first place.
- if ($form_state->hasValue(array('override', 'dropdown'))) {
+ if ($form_state->hasValue(['override', 'dropdown'])) {
// #default_value is used to determine whether it was the default value or not.
// So the available options are: $display, 'default' and 'default_revert', not 'defaults'.
$was_defaulted = ($form['override']['dropdown']['#default_value'] === 'defaults');
- $dropdown = $form_state->getValue(array('override', 'dropdown'));
+ $dropdown = $form_state->getValue(['override', 'dropdown']);
$is_defaulted = ($dropdown === 'default');
$revert = ($dropdown === 'default_revert');
@@ -369,7 +369,7 @@ class ViewUI implements ViewEntityInterface {
$revert = FALSE;
}
- return array($was_defaulted, $is_defaulted, $revert);
+ return [$was_defaulted, $is_defaulted, $revert];
}
/**
@@ -383,10 +383,10 @@ class ViewUI implements ViewEntityInterface {
Html::resetSeenIds();
if (empty($this->stack)) {
- $this->stack = array();
+ $this->stack = [];
}
- $stack = array(implode('-', array_filter(array($key, $this->id(), $display_id, $type, $id))), $key, $display_id, $type, $id);
+ $stack = [implode('-', array_filter([$key, $this->id(), $display_id, $type, $id])), $key, $display_id, $type, $id];
// If we're being asked to add this form to the bottom of the stack, no
// special logic is required. Our work is equally easy if we were asked to add
// to the top of the stack, but there's nothing in it yet.
@@ -463,10 +463,10 @@ class ViewUI implements ViewEntityInterface {
if (isset($types[$type]['type'])) {
$key = $types[$type]['type'];
}
- $item = array(
+ $item = [
'table' => $table,
'field' => $field,
- );
+ ];
$handler = Views::handlerManager($key)->getHandler($item);
if ($this->getExecutable()->displayHandlers->get('default')->useGroupBy() && $handler->usesGroupBy()) {
$this->addFormToStack('handler-group', $display_id, $type, $id);
@@ -512,7 +512,7 @@ class ViewUI implements ViewEntityInterface {
$this->additionalQueries = $queries;
}
- public function renderPreview($display_id, $args = array()) {
+ public function renderPreview($display_id, $args = []) {
// Save the current path so it can be restored before returning from this function.
$request_stack = \Drupal::requestStack();
$current_request = $request_stack->getCurrentRequest();
@@ -531,7 +531,7 @@ class ViewUI implements ViewEntityInterface {
$combined = $show_query && $show_stats;
- $rows = array('query' => array(), 'statistics' => array());
+ $rows = ['query' => [], 'statistics' => []];
$errors = $executable->validate();
$executable->destroy();
@@ -545,7 +545,7 @@ class ViewUI implements ViewEntityInterface {
// have some input in the query parameters, so we merge request() and
// query() to ensure we get it all.
$exposed_input = array_merge(\Drupal::request()->request->all(), \Drupal::request()->query->all());
- foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER, 'ajax_page_state', 'form_id', 'form_build_id', 'form_token') as $key) {
+ foreach (['view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER, 'ajax_page_state', 'form_id', 'form_build_id', 'form_token'] as $key) {
if (isset($exposed_input[$key])) {
unset($exposed_input[$key]);
}
@@ -554,7 +554,7 @@ class ViewUI implements ViewEntityInterface {
if (!$executable->setDisplay($display_id)) {
return [
- '#markup' => t('Invalid display id @display', array('@display' => $display_id)),
+ '#markup' => t('Invalid display id @display', ['@display' => $display_id]),
];
}
@@ -620,76 +620,76 @@ class ViewUI implements ViewEntityInterface {
if ($show_query) {
$query_string = $executable->build_info['query'];
// Only the sql default class has a method getArguments.
- $quoted = array();
+ $quoted = [];
if ($executable->query instanceof Sql) {
$quoted = $query_string->getArguments();
$connection = Database::getConnection();
foreach ($quoted as $key => $val) {
if (is_array($val)) {
- $quoted[$key] = implode(', ', array_map(array($connection, 'quote'), $val));
+ $quoted[$key] = implode(', ', array_map([$connection, 'quote'], $val));
}
else {
$quoted[$key] = $connection->quote($val);
}
}
}
- $rows['query'][] = array(
- array(
- 'data' => array(
+ $rows['query'][] = [
+ [
+ 'data' => [
'#type' => 'inline_template',
'#template' => "<strong>{% trans 'Query' %}</strong>",
- ),
- ),
- array(
- 'data' => array(
+ ],
+ ],
+ [
+ 'data' => [
'#type' => 'inline_template',
'#template' => '<pre>{{ query }}</pre>',
- '#context' => array('query' => strtr($query_string, $quoted)),
- ),
- ),
- );
+ '#context' => ['query' => strtr($query_string, $quoted)],
+ ],
+ ],
+ ];
if (!empty($this->additionalQueries)) {
- $queries[] = array(
+ $queries[] = [
'#prefix' => '<strong>',
'#markup' => t('These queries were run during view rendering:'),
'#suffix' => '</strong>',
- );
+ ];
foreach ($this->additionalQueries as $query) {
$query_string = strtr($query['query'], $query['args']);
- $queries[] = array(
+ $queries[] = [
'#prefix' => "\n",
- '#markup' => t('[@time ms] @query', array('@time' => round($query['time'] * 100000, 1) / 100000.0, '@query' => $query_string)),
- );
+ '#markup' => t('[@time ms] @query', ['@time' => round($query['time'] * 100000, 1) / 100000.0, '@query' => $query_string]),
+ ];
}
- $rows['query'][] = array(
- array(
- 'data' => array(
+ $rows['query'][] = [
+ [
+ 'data' => [
'#type' => 'inline_template',
'#template' => "<strong>{% trans 'Other queries' %}</strong>",
- ),
- ),
- array(
- 'data' => array(
+ ],
+ ],
+ [
+ 'data' => [
'#prefix' => '<pre>',
'queries' => $queries,
'#suffix' => '</pre>',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
if ($show_info) {
- $rows['query'][] = array(
- array(
- 'data' => array(
+ $rows['query'][] = [
+ [
+ 'data' => [
'#type' => 'inline_template',
'#template' => "<strong>{% trans 'Title' %}</strong>",
- ),
- ),
+ ],
+ ],
Xss::filterAdmin($executable->getTitle()),
- );
+ ];
if (isset($path)) {
// @todo Views should expect and store a leading /. See:
// https://www.drupal.org/node/2423913
@@ -698,51 +698,51 @@ class ViewUI implements ViewEntityInterface {
else {
$path = t('This display has no path.');
}
- $rows['query'][] = array(
- array(
- 'data' => array(
+ $rows['query'][] = [
+ [
+ 'data' => [
'#prefix' => '<strong>',
'#markup' => t('Path'),
'#suffix' => '</strong>',
- ),
- ),
- array(
- 'data' => array(
+ ],
+ ],
+ [
+ 'data' => [
'#markup' => $path,
- ),
- )
- );
+ ],
+ ]
+ ];
}
if ($show_stats) {
- $rows['statistics'][] = array(
- array(
- 'data' => array(
+ $rows['statistics'][] = [
+ [
+ 'data' => [
'#type' => 'inline_template',
'#template' => "<strong>{% trans 'Query build time' %}</strong>",
- ),
- ),
- t('@time ms', array('@time' => intval($executable->build_time * 100000) / 100)),
- );
-
- $rows['statistics'][] = array(
- array(
- 'data' => array(
+ ],
+ ],
+ t('@time ms', ['@time' => intval($executable->build_time * 100000) / 100]),
+ ];
+
+ $rows['statistics'][] = [
+ [
+ 'data' => [
'#type' => 'inline_template',
'#template' => "<strong>{% trans 'Query execute time' %}</strong>",
- ),
- ),
- t('@time ms', array('@time' => intval($executable->execute_time * 100000) / 100)),
- );
-
- $rows['statistics'][] = array(
- array(
- 'data' => array(
+ ],
+ ],
+ t('@time ms', ['@time' => intval($executable->execute_time * 100000) / 100]),
+ ];
+
+ $rows['statistics'][] = [
+ [
+ 'data' => [
'#type' => 'inline_template',
'#template' => "<strong>{% trans 'View render time' %}</strong>",
- ),
- ),
- t('@time ms', array('@time' => intval($this->render_time * 100) / 100)),
- );
+ ],
+ ],
+ t('@time ms', ['@time' => intval($this->render_time * 100) / 100]),
+ ];
}
\Drupal::moduleHandler()->alter('views_preview_info', $rows, $executable);
}
@@ -750,36 +750,36 @@ class ViewUI implements ViewEntityInterface {
// No query was run. Display that information in place of either the
// query or the performance statistics, whichever comes first.
if ($combined || ($show_location === 'above')) {
- $rows['query'][] = array(
- array(
- 'data' => array(
+ $rows['query'][] = [
+ [
+ 'data' => [
'#prefix' => '<strong>',
'#markup' => t('Query'),
'#suffix' => '</strong>',
- ),
- ),
- array(
- 'data' => array(
+ ],
+ ],
+ [
+ 'data' => [
'#markup' => t('No query was run'),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
else {
- $rows['statistics'][] = array(
- array(
- 'data' => array(
+ $rows['statistics'][] = [
+ [
+ 'data' => [
'#prefix' => '<strong>',
'#markup' => t('Query'),
'#suffix' => '</strong>',
- ),
- ),
- array(
- 'data' => array(
+ ],
+ ],
+ [
+ 'data' => [
'#markup' => t('No query was run'),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
}
@@ -795,12 +795,12 @@ class ViewUI implements ViewEntityInterface {
// Assemble the preview, the query info, and the query statistics in the
// requested order.
- $table = array(
+ $table = [
'#type' => 'table',
'#prefix' => '<div class="views-query-info">',
'#suffix' => '</div>',
'#rows' => array_merge($rows['query'], $rows['statistics']),
- );
+ ];
if ($show_location == 'above') {
$output = [
@@ -843,7 +843,7 @@ class ViewUI implements ViewEntityInterface {
$current = reset($keys) + 1;
$total = end($keys) + 1;
if ($total > 1) {
- $progress = array();
+ $progress = [];
$progress['current'] = $current;
$progress['total'] = $total;
}
@@ -892,7 +892,7 @@ class ViewUI implements ViewEntityInterface {
* Passes through all unknown calls onto the storage object.
*/
public function __call($method, $args) {
- return call_user_func_array(array($this->storage, $method), $args);
+ return call_user_func_array([$this->storage, $method], $args);
}
/**
@@ -968,7 +968,7 @@ class ViewUI implements ViewEntityInterface {
/**
* {@inheritdoc}
*/
- public static function create(array $values = array()) {
+ public static function create(array $values = []) {
return View::create($values);
}
@@ -1167,7 +1167,7 @@ class ViewUI implements ViewEntityInterface {
/**
* {@inheritdoc}
*/
- public function url($rel = 'edit-form', $options = array()) {
+ public function url($rel = 'edit-form', $options = []) {
return $this->storage->url($rel, $options);
}
diff --git a/core/modules/views_ui/tests/src/Kernel/TagTest.php b/core/modules/views_ui/tests/src/Kernel/TagTest.php
index fda2e2852ae..294e48158f0 100644
--- a/core/modules/views_ui/tests/src/Kernel/TagTest.php
+++ b/core/modules/views_ui/tests/src/Kernel/TagTest.php
@@ -19,7 +19,7 @@ class TagTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('views', 'views_ui', 'user');
+ public static $modules = ['views', 'views_ui', 'user'];
/**
* Tests the views_ui_autocomplete_tag function.
@@ -28,12 +28,12 @@ class TagTest extends ViewsKernelTestBase {
\Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');
// Save 15 views with a tag.
- $tags = array();
+ $tags = [];
for ($i = 0; $i < 16; $i++) {
$suffix = $i % 2 ? 'odd' : 'even';
$tag = 'autocomplete_tag_test_' . $suffix . $this->randomMachineName();
$tags[] = $tag;
- View::create(array('tag' => $tag, 'id' => $this->randomMachineName()))->save();
+ View::create(['tag' => $tag, 'id' => $this->randomMachineName()])->save();
}
// Make sure just ten results are returns.
@@ -46,7 +46,7 @@ class TagTest extends ViewsKernelTestBase {
// Make sure the returned array has the proper format.
$suggestions = array_map(function ($tag) {
- return array('value' => $tag, 'label' => Html::escape($tag));
+ return ['value' => $tag, 'label' => Html::escape($tag)];
}, $tags);
foreach ($matches as $match) {
$this->assertTrue(in_array($match, $suggestions), 'Make sure the returned array has the proper format.');
@@ -59,7 +59,7 @@ class TagTest extends ViewsKernelTestBase {
$matches = (array) json_decode($result->getContent(), TRUE);
$this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
foreach ($matches as $tag) {
- $this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag['value'])));
+ $this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', ['@tag' => $tag['value']]));
}
// Make sure an invalid result doesn't return anything.
diff --git a/core/modules/views_ui/tests/src/Unit/Form/Ajax/RearrangeFilterTest.php b/core/modules/views_ui/tests/src/Unit/Form/Ajax/RearrangeFilterTest.php
index bb8eb77398e..b2d3f96ab62 100644
--- a/core/modules/views_ui/tests/src/Unit/Form/Ajax/RearrangeFilterTest.php
+++ b/core/modules/views_ui/tests/src/Unit/Form/Ajax/RearrangeFilterTest.php
@@ -17,8 +17,8 @@ class RearrangeFilterTest extends UnitTestCase {
*/
public function testStaticMethods() {
// Test the RearrangeFilter::arrayKeyPlus method.
- $original = array(0 => 'one', 1 => 'two', 2 => 'three');
- $expected = array(1 => 'one', 2 => 'two', 3 => 'three');
+ $original = [0 => 'one', 1 => 'two', 2 => 'three'];
+ $expected = [1 => 'one', 2 => 'two', 3 => 'three'];
$this->assertSame(RearrangeFilter::arrayKeyPlus($original), $expected);
}
diff --git a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
index 9b646964eb0..23cc7a8e65d 100644
--- a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
+++ b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
@@ -38,54 +38,54 @@ class ViewListBuilderTest extends UnitTestCase {
$display_manager->expects($this->any())
->method('getDefinition')
- ->will($this->returnValueMap(array(
- array(
+ ->will($this->returnValueMap([
+ [
'default',
TRUE,
- array(
+ [
'id' => 'default',
'title' => 'Master',
'theme' => 'views_view',
'no_ui' => TRUE,
'admin' => '',
- )
- ),
- array(
+ ]
+ ],
+ [
'page',
TRUE,
- array(
+ [
'id' => 'page',
'title' => 'Page',
'uses_menu_links' => TRUE,
'uses_route' => TRUE,
- 'contextual_links_locations' => array('page'),
+ 'contextual_links_locations' => ['page'],
'theme' => 'views_view',
'admin' => 'Page admin label',
- )
- ),
- array(
+ ]
+ ],
+ [
'embed',
TRUE,
- array(
+ [
'id' => 'embed',
'title' => 'embed',
'theme' => 'views_view',
'admin' => 'Embed admin label',
- )
- ),
- )));
+ ]
+ ],
+ ]));
$default_display = $this->getMock('Drupal\views\Plugin\views\display\DefaultDisplay',
- array('initDisplay'),
- array(array(), 'default', $display_manager->getDefinition('default'))
+ ['initDisplay'],
+ [[], 'default', $display_manager->getDefinition('default')]
);
$route_provider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
$state = $this->getMock('\Drupal\Core\State\StateInterface');
$menu_storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
$page_display = $this->getMock('Drupal\views\Plugin\views\display\Page',
- array('initDisplay', 'getPath'),
- array(array(), 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage)
+ ['initDisplay', 'getPath'],
+ [[], 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage]
);
$page_display->expects($this->any())
->method('getPath')
@@ -94,11 +94,11 @@ class ViewListBuilderTest extends UnitTestCase {
$this->returnValue('<object>malformed_path</object>'),
$this->returnValue('<script>alert("placeholder_page/%")</script>')));
- $embed_display = $this->getMock('Drupal\views\Plugin\views\display\Embed', array('initDisplay'),
- array(array(), 'default', $display_manager->getDefinition('embed'))
+ $embed_display = $this->getMock('Drupal\views\Plugin\views\display\Embed', ['initDisplay'],
+ [[], 'default', $display_manager->getDefinition('embed')]
);
- $values = array();
+ $values = [];
$values['status'] = FALSE;
$values['display']['default']['id'] = 'default';
$values['display']['default']['display_title'] = 'Display';
@@ -125,13 +125,13 @@ class ViewListBuilderTest extends UnitTestCase {
$display_manager->expects($this->any())
->method('createInstance')
- ->will($this->returnValueMap(array(
- array('default', $values['display']['default'], $default_display),
- array('page', $values['display']['page_1'], $page_display),
- array('page', $values['display']['page_2'], $page_display),
- array('page', $values['display']['page_3'], $page_display),
- array('embed', $values['display']['embed'], $embed_display),
- )));
+ ->will($this->returnValueMap([
+ ['default', $values['display']['default'], $default_display],
+ ['page', $values['display']['page_1'], $page_display],
+ ['page', $values['display']['page_2'], $page_display],
+ ['page', $values['display']['page_3'], $page_display],
+ ['embed', $values['display']['embed'], $embed_display],
+ ]));
$container = new ContainerBuilder();
$user = $this->getMock('Drupal\Core\Session\AccountInterface');
@@ -159,24 +159,24 @@ class ViewListBuilderTest extends UnitTestCase {
$row = $view_list_builder->buildRow($view);
// Expected output array for view's displays.
- $expected_displays = array(
- '0' => array(
+ $expected_displays = [
+ '0' => [
'display' => 'Embed admin label',
'path' => FALSE,
- ),
- '1' => array(
+ ],
+ '1' => [
'display' => 'Page admin label',
'path' => '/<object>malformed_path</object>',
- ),
- '2' => array(
+ ],
+ '2' => [
'display' => 'Page admin label',
'path' => '/<script>alert("placeholder_page/%")</script>',
- ),
- '3' => array(
+ ],
+ '3' => [
'display' => 'Page admin label',
'path' => '/test_page',
- ),
- );
+ ],
+ ];
// Compare the expected and generated output.
$this->assertEquals($expected_displays, $row['data']['displays']['data']['#displays']);
@@ -187,7 +187,7 @@ class ViewListBuilderTest extends UnitTestCase {
class TestViewListBuilder extends ViewListBuilder {
public function buildOperations(EntityInterface $entity) {
- return array();
+ return [];
}
}
diff --git a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
index 293bfebeaf4..f49b25a9fc8 100644
--- a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
+++ b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
@@ -18,14 +18,14 @@ class ViewUIObjectTest extends UnitTestCase {
* Tests entity method decoration.
*/
public function testEntityDecoration() {
- $method_args = array();
- $method_args['setOriginalId'] = array(12);
- $method_args['setStatus'] = array(TRUE);
- $method_args['enforceIsNew'] = array(FALSE);
- $method_args['label'] = array(LanguageInterface::LANGCODE_NOT_SPECIFIED);
+ $method_args = [];
+ $method_args['setOriginalId'] = [12];
+ $method_args['setStatus'] = [TRUE];
+ $method_args['enforceIsNew'] = [FALSE];
+ $method_args['label'] = [LanguageInterface::LANGCODE_NOT_SPECIFIED];
$reflection = new \ReflectionClass('Drupal\Core\Config\Entity\ConfigEntityInterface');
- $interface_methods = array();
+ $interface_methods = [];
foreach ($reflection->getMethods() as $reflection_method) {
$interface_methods[] = $reflection_method->getName();
@@ -38,15 +38,15 @@ class ViewUIObjectTest extends UnitTestCase {
// dependency management.
if (!in_array($reflection_method->getName(), ['isNew', 'isSyncing', 'isUninstalling', 'getConfigDependencyKey', 'getConfigDependencyName', 'calculateDependencies'])) {
if (count($reflection_method->getParameters()) == 0) {
- $method_args[$reflection_method->getName()] = array();
+ $method_args[$reflection_method->getName()] = [];
}
}
}
- $storage = $this->getMock('Drupal\views\Entity\View', $interface_methods, array(array(), 'view'));
+ $storage = $this->getMock('Drupal\views\Entity\View', $interface_methods, [[], 'view']);
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
- ->setConstructorArgs(array($storage))
+ ->setConstructorArgs([$storage])
->getMock();
$storage->set('executable', $executable);
@@ -58,7 +58,7 @@ class ViewUIObjectTest extends UnitTestCase {
foreach ($args as $arg) {
$method_mock->with($this->equalTo($arg));
}
- call_user_func_array(array($view_ui, $method), $args);
+ call_user_func_array([$view_ui, $method], $args);
}
$storage->expects($this->once())
@@ -70,10 +70,10 @@ class ViewUIObjectTest extends UnitTestCase {
* Tests the isLocked method.
*/
public function testIsLocked() {
- $storage = $this->getMock('Drupal\views\Entity\View', array(), array(array(), 'view'));
+ $storage = $this->getMock('Drupal\views\Entity\View', [], [[], 'view']);
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
- ->setConstructorArgs(array($storage))
+ ->setConstructorArgs([$storage])
->getMock();
$storage->set('executable', $executable);
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
@@ -91,20 +91,20 @@ class ViewUIObjectTest extends UnitTestCase {
$this->assertFalse($view_ui->isLocked());
// Set the lock object with a different owner than the mocked account above.
- $lock = (object) array(
+ $lock = (object) [
'owner' => 2,
- 'data' => array(),
+ 'data' => [],
'updated' => (int) $_SERVER['REQUEST_TIME'],
- );
+ ];
$view_ui->lock = $lock;
$this->assertTrue($view_ui->isLocked());
// Set a different lock object with the same object as the mocked account.
- $lock = (object) array(
+ $lock = (object) [
'owner' => 1,
- 'data' => array(),
+ 'data' => [],
'updated' => (int) $_SERVER['REQUEST_TIME'],
- );
+ ];
$view_ui->lock = $lock;
$this->assertFalse($view_ui->isLocked());
}
diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module
index 511bcf942db..15f85e3a023 100644
--- a/core/modules/views_ui/views_ui.module
+++ b/core/modules/views_ui/views_ui.module
@@ -19,15 +19,15 @@ function views_ui_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.views_ui':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Views UI module provides an interface for managing views for the <a href=":views">Views module</a>. For more information, see the <a href=":handbook">online documentation for the Views UI module</a>.', array(':views' => \Drupal::url('help.page', array('name' => 'views')), ':handbook' => 'https://www.drupal.org/documentation/modules/views_ui')) . '</p>';
+ $output .= '<p>' . t('The Views UI module provides an interface for managing views for the <a href=":views">Views module</a>. For more information, see the <a href=":handbook">online documentation for the Views UI module</a>.', [':views' => \Drupal::url('help.page', ['name' => 'views']), ':handbook' => 'https://www.drupal.org/documentation/modules/views_ui']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating and managing views') . '</dt>';
- $output .= '<dd>' . t('Views can be created from the <a href=":list">Views list page</a> by using the "Add view" action. Existing views can be managed from the <a href=":list">Views list page</a> by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".', array(':list' => \Drupal::url('entity.view.collection', array('name' => 'views_ui')))) . '</dd>';
+ $output .= '<dd>' . t('Views can be created from the <a href=":list">Views list page</a> by using the "Add view" action. Existing views can be managed from the <a href=":list">Views list page</a> by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".', [':list' => \Drupal::url('entity.view.collection', ['name' => 'views_ui'])]) . '</dd>';
$output .= '<dt>' . t('Enabling and disabling views') . '<dt>';
- $output .= '<dd>' . t('Views can be enabled or disabled from the <a href=":list">Views list page</a>. To enable a view, find the view within the "Disabled" list and select the "Enable" operation. To disable a view find the view within the "Enabled" list and select the "Disable" operation.', array(':list' => \Drupal::url('entity.view.collection', array('name' => 'views_ui')))) . '</dd>';
+ $output .= '<dd>' . t('Views can be enabled or disabled from the <a href=":list">Views list page</a>. To enable a view, find the view within the "Disabled" list and select the "Enable" operation. To disable a view find the view within the "Enabled" list and select the "Disable" operation.', [':list' => \Drupal::url('entity.view.collection', ['name' => 'views_ui'])]) . '</dd>';
$output .= '<dt>' . t('Exporting and importing views') . '</dt>';
- $output .= '<dd>' . t('Views can be exported and imported as configuration files by using the <a href=":config">Configuration Manager module</a>.', array(':config' => (\Drupal::moduleHandler()->moduleExists('config')) ? \Drupal::url('help.page', array('name' => 'config')) : '#')) . '</dd>';
+ $output .= '<dd>' . t('Views can be exported and imported as configuration files by using the <a href=":config">Configuration Manager module</a>.', [':config' => (\Drupal::moduleHandler()->moduleExists('config')) ? \Drupal::url('help.page', ['name' => 'config']) : '#']) . '</dd>';
$output .= '</dl>';
return $output;
}
@@ -61,69 +61,69 @@ function views_ui_entity_type_build(array &$entity_types) {
* Implements hook_theme().
*/
function views_ui_theme() {
- return array(
+ return [
// edit a view
- 'views_ui_display_tab_setting' => array(
- 'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()),
+ 'views_ui_display_tab_setting' => [
+ 'variables' => ['description' => '', 'link' => '', 'settings_links' => [], 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => []],
'file' => 'views_ui.theme.inc',
- ),
- 'views_ui_display_tab_bucket' => array(
+ ],
+ 'views_ui_display_tab_bucket' => [
'render element' => 'element',
'file' => 'views_ui.theme.inc',
- ),
- 'views_ui_rearrange_filter_form' => array(
+ ],
+ 'views_ui_rearrange_filter_form' => [
'render element' => 'form',
'file' => 'views_ui.theme.inc',
- ),
- 'views_ui_expose_filter_form' => array(
+ ],
+ 'views_ui_expose_filter_form' => [
'render element' => 'form',
'file' => 'views_ui.theme.inc',
- ),
+ ],
// Legacy theme hook for displaying views info.
- 'views_ui_view_info' => array(
- 'variables' => array('view' => NULL, 'displays' => NULL),
+ 'views_ui_view_info' => [
+ 'variables' => ['view' => NULL, 'displays' => NULL],
'file' => 'views_ui.theme.inc',
- ),
+ ],
// List views.
- 'views_ui_views_listing_table' => array(
- 'variables' => array(
+ 'views_ui_views_listing_table' => [
+ 'variables' => [
'headers' => NULL,
'rows' => NULL,
- 'attributes' => array(),
- ),
+ 'attributes' => [],
+ ],
'file' => 'views_ui.theme.inc',
- ),
- 'views_ui_view_displays_list' => array(
- 'variables' => array('displays' => array()),
- ),
+ ],
+ 'views_ui_view_displays_list' => [
+ 'variables' => ['displays' => []],
+ ],
// Group of filters.
- 'views_ui_build_group_filter_form' => array(
+ 'views_ui_build_group_filter_form' => [
'render element' => 'form',
'file' => 'views_ui.theme.inc',
- ),
+ ],
// On behalf of a plugin
- 'views_ui_style_plugin_table' => array(
+ 'views_ui_style_plugin_table' => [
'render element' => 'form',
'file' => 'views_ui.theme.inc',
- ),
+ ],
// When previewing a view.
- 'views_ui_view_preview_section' => array(
- 'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''),
+ 'views_ui_view_preview_section' => [
+ 'variables' => ['view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''],
'file' => 'views_ui.theme.inc',
- ),
+ ],
// Generic container wrapper, to use instead of theme_container when an id
// is not desired.
- 'views_ui_container' => array(
- 'variables' => array('children' => NULL, 'attributes' => array()),
+ 'views_ui_container' => [
+ 'variables' => ['children' => NULL, 'attributes' => []],
'file' => 'views_ui.theme.inc',
- ),
- );
+ ],
+ ];
}
/**
@@ -141,16 +141,16 @@ function views_ui_preprocess_views_view(&$variables) {
if (!empty($view->live_preview) && \Drupal::moduleHandler()->moduleExists('contextual')) {
$view->setShowAdminLinks(FALSE);
- foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) {
+ foreach (['title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before'] as $section) {
if (!empty($variables[$section])) {
- $variables[$section] = array(
+ $variables[$section] = [
'#theme' => 'views_ui_view_preview_section',
'#view' => $view,
'#section' => $section,
'#content' => $variables[$section],
- '#theme_wrappers' => array('views_ui_container'),
- '#attributes' => array('class' => array('contextual-region')),
- );
+ '#theme_wrappers' => ['views_ui_container'],
+ '#attributes' => ['class' => ['contextual-region']],
+ ];
}
}
}
@@ -169,28 +169,28 @@ function views_ui_preprocess_views_view(&$variables) {
function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type, $title = FALSE) {
$display = $view->display_handler->display;
$handlers = $view->display_handler->getHandlers($type);
- $links = array();
+ $links = [];
$types = ViewExecutable::getHandlerTypes();
if ($title) {
- $links[$type . '-title'] = array(
+ $links[$type . '-title'] = [
'title' => $types[$type]['title'],
- );
+ ];
}
foreach ($handlers as $id => $handler) {
$field_name = $handler->adminLabel(TRUE);
- $links[$type . '-edit-' . $id] = array(
- 'title' => t('Edit @section', array('@section' => $field_name)),
+ $links[$type . '-edit-' . $id] = [
+ 'title' => t('Edit @section', ['@section' => $field_name]),
'url' => Url::fromRoute('views_ui.form_handler', ['js' => 'nojs', 'view' => $view->storage->id(), 'display_id' => $display['id'], 'type' => $type, 'id' => $id]),
- 'attributes' => array('class' => array('views-ajax-link')),
- );
+ 'attributes' => ['class' => ['views-ajax-link']],
+ ];
}
- $links[$type . '-add'] = array(
+ $links[$type . '-add'] = [
'title' => t('Add new'),
'url' => Url::fromRoute('views_ui.form_add_handler', ['js' => 'nojs', 'view' => $view->storage->id(), 'display_id' => $display['id'], 'type' => $type]),
- 'attributes' => array('class' => array('views-ajax-link')),
- );
+ 'attributes' => ['class' => ['views-ajax-link']],
+ ];
return $links;
}
@@ -200,13 +200,13 @@ function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type
*/
function views_ui_view_preview_section_display_category_links(ViewExecutable $view, $type, $title) {
$display = $view->display_handler->display;
- $links = array(
- $type . '-edit' => array(
- 'title' => t('Edit @section', array('@section' => $title)),
+ $links = [
+ $type . '-edit' => [
+ 'title' => t('Edit @section', ['@section' => $title]),
'url' => Url::fromRoute('views_ui.form_display', ['js' => 'nojs', 'view' => $view->storage->id(), 'display_id' => $display['id'], 'type' => $type]),
- 'attributes' => array('class' => array('views-ajax-link')),
- ),
- );
+ 'attributes' => ['class' => ['views-ajax-link']],
+ ],
+ ];
return $links;
}
@@ -215,7 +215,7 @@ function views_ui_view_preview_section_display_category_links(ViewExecutable $vi
* Returns all contextual links for the main content part of the view.
*/
function views_ui_view_preview_section_rows_links(ViewExecutable $view) {
- $links = array();
+ $links = [];
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE));
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE));
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'sort', TRUE));
@@ -233,10 +233,10 @@ function views_ui_views_plugins_display_alter(&$plugins) {
// paths underneath "admin/structure/views/view/{$view->id()}" (i.e., paths
// for editing and performing other contextual actions on the view).
foreach ($plugins as &$display) {
- $display['contextual links']['entity.view.edit_form'] = array(
+ $display['contextual links']['entity.view.edit_form'] = [
'route_name' => 'entity.view.edit_form',
- 'route_parameters_names' => array('view' => 'id'),
- );
+ 'route_parameters_names' => ['view' => 'id'],
+ ];
}
}
@@ -247,7 +247,7 @@ function views_ui_contextual_links_view_alter(&$element, $items) {
// Remove contextual links from being rendered, when so desired, such as
// within a View preview.
if (views_ui_contextual_links_suppress()) {
- $element['#links'] = array();
+ $element['#links'] = [];
}
// Append the display ID to the Views UI edit links, so that clicking on the
// contextual link takes you directly to the correct display tab on the edit
@@ -305,7 +305,7 @@ function views_ui_contextual_links_suppress_pop() {
* node.views.inc as well.
*/
function views_ui_views_analyze(ViewExecutable $view) {
- $ret = array();
+ $ret = [];
// Check for something other than the default display:
if (count($view->displayHandlers) < 2) {
$ret[] = Analyzer::formatMessage(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning');
@@ -320,7 +320,7 @@ function views_ui_views_analyze(ViewExecutable $view) {
if ($display->hasPath() && $path = $display->getOption('path')) {
$normal_path = \Drupal::service('path.alias_manager')->getPathByAlias($path);
if ($path != $normal_path) {
- $ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display->display['display_title'])), 'warning');
+ $ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', ['%display' => $display->display['display_title']]), 'warning');
}
}
}
diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc
index 926f82ab309..e6ef8756ff7 100644
--- a/core/modules/views_ui/views_ui.theme.inc
+++ b/core/modules/views_ui/views_ui.theme.inc
@@ -89,7 +89,7 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) {
$variables['overridden'] = isset($element['#overridden']) ? $element['#overridden'] : NULL;
$variables['content'] = $element['#children'];
$variables['title'] = $element['#title'];
- $variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : array();
+ $variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : [];
}
/**
@@ -105,14 +105,14 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
$form = $variables['form'];
// Prepare table of options.
- $header = array(
+ $header = [
t('Default'),
t('Weight'),
t('Label'),
t('Operator'),
t('Value'),
t('Operations'),
- );
+ ];
// Prepare default selectors.
$form_state = new FormState();
@@ -120,15 +120,15 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
$form['default_group_multiple'] = Checkboxes::processCheckboxes($form['default_group_multiple'], $form_state, $form);
$form['default_group']['All']['#title'] = '';
- $rows[] = array(
+ $rows[] = [
['data' => $form['default_group']['All']],
'',
- array(
+ [
'data' => \Drupal::config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? t('&lt;Any&gt;') : t('- Any -'),
'colspan' => 4,
- 'class' => array('class' => 'any-default-radios-row'),
- ),
- );
+ 'class' => ['class' => 'any-default-radios-row'],
+ ],
+ ];
// Remove the 'All' default_group form element because it's added to the
// table row.
unset($variables['form']['default_group']['All']);
@@ -161,32 +161,32 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
'#title' => SafeMarkup::format('<span>@text</span>', ['@text' => t('Remove')]),
];
$remove = [$form['group_items'][$group_id]['remove'], $link];
- $data = array(
+ $data = [
'default' => ['data' => $default],
'weight' => ['data' => $form['group_items'][$group_id]['weight']],
'title' => ['data' => $form['group_items'][$group_id]['title']],
'operator' => ['data' => $form['group_items'][$group_id]['operator']],
'value' => ['data' => $form['group_items'][$group_id]['value']],
'remove' => ['data' => $remove],
- );
- $rows[] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable'));
+ ];
+ $rows[] = ['data' => $data, 'id' => 'views-row-' . $group_id, 'class' => ['draggable']];
}
- $variables['table'] = array(
+ $variables['table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- '#attributes' => array(
- 'class' => array('views-filter-groups'),
+ '#attributes' => [
+ 'class' => ['views-filter-groups'],
'id' => 'views-filter-groups',
- ),
- '#tabledrag' => array(
- array(
+ ],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'weight',
- )
- ),
- );
+ ]
+ ],
+ ];
// Hide fields used in table.
unset($variables['form']['group_items']);
@@ -203,7 +203,7 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
*/
function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
$form = &$variables['form'];
- $rows = $ungroupable_rows = array();
+ $rows = $ungroupable_rows = [];
// Enable grouping only if > 1 group.
$variables['grouping'] = count(array_keys($form['#group_options'])) > 1;
@@ -212,41 +212,41 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
if ($group_id !== 'ungroupable') {
// Set up tabledrag so that it changes the group dropdown when rows are
// dragged between groups.
- $options = array(
+ $options = [
'table_id' => 'views-rearrange-filters',
'action' => 'match',
'relationship' => 'sibling',
'group' => 'views-group-select',
'subgroup' => 'views-group-select-' . $group_id,
- );
+ ];
drupal_attach_tabledrag($form['override'], $options);
// Title row, spanning all columns.
- $row = array();
+ $row = [];
// Add a cell to the first row, containing the group operator.
- $row[] = array(
- 'class' => array('group', 'group-operator', 'container-inline'),
+ $row[] = [
+ 'class' => ['group', 'group-operator', 'container-inline'],
'data' => $form['filter_groups']['groups'][$group_id],
- 'rowspan' => max(array(2, count($contents) + 1)),
- );
+ 'rowspan' => max([2, count($contents) + 1]),
+ ];
// Title.
- $row[] = array(
- 'class' => array('group', 'group-title'),
- 'data' => array(
+ $row[] = [
+ 'class' => ['group', 'group-title'],
+ 'data' => [
'#prefix' => '<span>',
'#markup' => $form['#group_options'][$group_id],
'#suffix' => '</span>',
- ),
+ ],
'colspan' => 4,
- );
- $rows[] = array(
- 'class' => array('views-group-title'),
+ ];
+ $rows[] = [
+ 'class' => ['views-group-title'],
'data' => $row,
'id' => 'views-group-title-' . $group_id,
- );
+ ];
// Row which will only appear if the group has nothing in it.
- $row = array();
+ $row = [];
$class = 'group-' . (count($contents) ? 'populated' : 'empty');
$instructions = '<span>' . t('No filters have been added.') . '</span> <span class="js-only">' . t('Drag to add filters.') . '</span>';
// When JavaScript is enabled, the button for removing the group (if it's
@@ -255,63 +255,63 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
if (!empty($form['remove_groups'][$group_id]['#type']) && $form['remove_groups'][$group_id]['#type'] == 'submit') {
$form['remove_groups'][$group_id]['#attributes']['class'][] = 'js-hide';
}
- $row[] = array(
+ $row[] = [
'colspan' => 5,
- 'data' => array(
- array('#markup' => $instructions),
+ 'data' => [
+ ['#markup' => $instructions],
$form['remove_groups'][$group_id],
- ),
- );
- $rows[] = array(
- 'class' => array(
+ ],
+ ];
+ $rows[] = [
+ 'class' => [
'group-message',
'group-' . $group_id . '-message',
$class,
- ),
+ ],
'data' => $row,
'id' => 'views-group-' . $group_id,
- );
+ ];
}
foreach ($contents as $id) {
if (isset($form['filters'][$id]['name'])) {
- $row = array();
+ $row = [];
$row[]['data'] = $form['filters'][$id]['name'];
- $form['filters'][$id]['weight']['#attributes']['class'] = array('weight');
+ $form['filters'][$id]['weight']['#attributes']['class'] = ['weight'];
$row[]['data'] = $form['filters'][$id]['weight'];
- $form['filters'][$id]['group']['#attributes']['class'] = array('views-group-select views-group-select-' . $group_id);
+ $form['filters'][$id]['group']['#attributes']['class'] = ['views-group-select views-group-select-' . $group_id];
$row[]['data'] = $form['filters'][$id]['group'];
$form['filters'][$id]['removed']['#attributes']['class'][] = 'js-hide';
- $remove_link = array(
+ $remove_link = [
'#type' => 'link',
'#url' => Url::fromRoute('<none>'),
- '#title' => SafeMarkup::format('<span>@text</span>', array('@text' => t('Remove'))),
+ '#title' => SafeMarkup::format('<span>@text</span>', ['@text' => t('Remove')]),
'#weight' => '1',
- '#options' => array(
- 'attributes' => array(
+ '#options' => [
+ 'attributes' => [
'id' => 'views-remove-link-' . $id,
- 'class' => array(
+ 'class' => [
'views-hidden',
'views-button-remove',
'views-groups-remove-link',
'views-remove-link',
- ),
+ ],
'alt' => t('Remove this item'),
'title' => t('Remove this item'),
- ),
- ),
- );
- $row[]['data'] = array(
+ ],
+ ],
+ ];
+ $row[]['data'] = [
$form['filters'][$id]['removed'],
$remove_link,
- );
+ ];
- $row = array(
+ $row = [
'data' => $row,
- 'class' => array('draggable'),
+ 'class' => ['draggable'],
'id' => 'views-row-' . $id,
- );
+ ];
if ($group_id !== 'ungroupable') {
$rows[] = $row;
@@ -328,56 +328,56 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
}
if (!empty($ungroupable_rows)) {
- $header = array(
+ $header = [
t('Ungroupable filters'),
t('Weight'),
- array(
+ [
'data' => t('Group'),
- 'class' => array('views-hide-label'),
- ),
- array(
+ 'class' => ['views-hide-label'],
+ ],
+ [
'data' => t('Remove'),
- 'class' => array('views-hide-label'),
- ),
- );
- $variables['ungroupable_table'] = array(
+ 'class' => ['views-hide-label'],
+ ],
+ ];
+ $variables['ungroupable_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $ungroupable_rows,
- '#attributes' => array(
+ '#attributes' => [
'id' => 'views-rearrange-filters-ungroupable',
- 'class' => array('arrange'),
- ),
- '#tabledrag' => array(
- array(
+ 'class' => ['arrange'],
+ ],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'weight',
- )
- ),
- );
+ ]
+ ],
+ ];
}
if (empty($rows)) {
- $rows[] = array(array('data' => t('No fields available.'), 'colspan' => '2'));
+ $rows[] = [['data' => t('No fields available.'), 'colspan' => '2']];
}
// Set up tabledrag so that the weights are changed when rows are dragged.
- $variables['table'] = array(
+ $variables['table'] = [
'#type' => 'table',
'#rows' => $rows,
- '#attributes' => array(
+ '#attributes' => [
'id' => 'views-rearrange-filters',
- 'class' => array('arrange'),
- ),
- '#tabledrag' => array(
- array(
+ 'class' => ['arrange'],
+ ],
+ '#tabledrag' => [
+ [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'weight',
- ),
- ),
- );
+ ],
+ ],
+ ];
// When JavaScript is enabled, the button for adding a new group should be
// hidden, since it will be replaced by a link on the client side.
@@ -397,72 +397,72 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
function template_preprocess_views_ui_style_plugin_table(&$variables) {
$form = $variables['form'];
- $header = array(
+ $header = [
t('Field'),
t('Column'),
t('Align'),
t('Separator'),
- array(
+ [
'data' => t('Sortable'),
'align' => 'center',
- ),
- array(
+ ],
+ [
'data' => t('Default order'),
'align' => 'center',
- ),
- array(
+ ],
+ [
'data' => t('Default sort'),
'align' => 'center',
- ),
- array(
+ ],
+ [
'data' => t('Hide empty column'),
'align' => 'center',
- ),
- array(
+ ],
+ [
'data' => t('Responsive'),
'align' => 'center',
- ),
- );
- $rows = array();
+ ],
+ ];
+ $rows = [];
foreach (Element::children($form['columns']) as $id) {
- $row = array();
+ $row = [];
$row[]['data'] = $form['info'][$id]['name'];
$row[]['data'] = $form['columns'][$id];
$row[]['data'] = $form['info'][$id]['align'];
$row[]['data'] = $form['info'][$id]['separator'];
if (!empty($form['info'][$id]['sortable'])) {
- $row[] = array(
+ $row[] = [
'data' => $form['info'][$id]['sortable'],
'align' => 'center',
- );
- $row[] = array(
+ ];
+ $row[] = [
'data' => $form['info'][$id]['default_sort_order'],
'align' => 'center',
- );
- $row[] = array(
+ ];
+ $row[] = [
'data' => $form['default'][$id],
'align' => 'center',
- );
+ ];
}
else {
$row[] = '';
$row[] = '';
$row[] = '';
}
- $row[] = array(
+ $row[] = [
'data' => $form['info'][$id]['empty_column'],
'align' => 'center',
- );
- $row[] = array(
+ ];
+ $row[] = [
'data' => $form['info'][$id]['responsive'],
'align' => 'center',
- );
+ ];
$rows[] = $row;
}
// Add the special 'None' row.
- $rows[] = array(array('data' => t('None'), 'colspan' => 6), array('align' => 'center', 'data' => $form['default'][-1]), array('colspan' => 2));
+ $rows[] = [['data' => t('None'), 'colspan' => 6], ['align' => 'center', 'data' => $form['default'][-1]], ['colspan' => 2]];
// Unset elements from the form array that are used to build the table so that
// they are not rendered twice.
@@ -470,12 +470,12 @@ function template_preprocess_views_ui_style_plugin_table(&$variables) {
unset($form['info']);
unset($form['columns']);
- $variables['table'] = array(
+ $variables['table'] = [
'#type' => 'table',
'#theme' => 'table__views_ui_style_plugin_table',
'#header' => $header,
'#rows' => $rows,
- );
+ ];
$variables['form'] = $form;
}
@@ -536,14 +536,14 @@ function template_preprocess_views_ui_view_preview_section(&$variables) {
}
if (isset($links)) {
- $build = array(
+ $build = [
'#theme' => 'links__contextual',
'#links' => $links,
- '#attributes' => array('class' => array('contextual-links')),
- '#attached' => array(
- 'library' => array('contextual/drupal.contextual-links'),
- ),
- );
+ '#attributes' => ['class' => ['contextual-links']],
+ '#attached' => [
+ 'library' => ['contextual/drupal.contextual-links'],
+ ],
+ ];
$variables['links'] = $build;
}
}
@@ -552,5 +552,5 @@ function template_preprocess_views_ui_view_preview_section(&$variables) {
* Implements hook_theme_suggestions_HOOK().
*/
function views_ui_theme_suggestions_views_ui_view_preview_section(array $variables) {
- return array('views_ui_view_preview_section__' . $variables['section']);
+ return ['views_ui_view_preview_section__' . $variables['section']];
}
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index 9ad822f3903..e4e42bea220 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -101,6 +101,7 @@
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.UpperCaseConstant"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
+ <rule ref="Generic.Arrays.DisallowLongArraySyntax" />
<!-- PSR-2 sniffs -->
<rule ref="PSR2.Classes.PropertyDeclaration">
diff --git a/core/profiles/minimal/src/Tests/MinimalTest.php b/core/profiles/minimal/src/Tests/MinimalTest.php
index 056565e710e..7a505cd0a23 100644
--- a/core/profiles/minimal/src/Tests/MinimalTest.php
+++ b/core/profiles/minimal/src/Tests/MinimalTest.php
@@ -24,7 +24,7 @@ class MinimalTest extends WebTestBase {
// Create a user to test tools and navigation blocks for logged in users
// with appropriate permissions.
- $user = $this->drupalCreateUser(array('access administration pages', 'administer content types'));
+ $user = $this->drupalCreateUser(['access administration pages', 'administer content types']);
$this->drupalLogin($user);
$this->drupalGet('');
$this->assertText(t('Tools'));
diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install
index 0a40ce6cddc..2f567abb495 100644
--- a/core/profiles/standard/standard.install
+++ b/core/profiles/standard/standard.install
@@ -25,8 +25,8 @@ function standard_install() {
$user_settings->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save(TRUE);
// Enable default permissions for system roles.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access comments'));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access comments', 'post comments', 'skip comment approval'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access comments', 'post comments', 'skip comment approval']);
// Assign user 1 the "administrator" role.
$user = User::load(1);
@@ -40,34 +40,34 @@ function standard_install() {
// Enable the Contact link in the footer menu.
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
- $menu_link_manager->updateDefinition('contact.site_page', array('enabled' => TRUE));
+ $menu_link_manager->updateDefinition('contact.site_page', ['enabled' => TRUE]);
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access site-wide contact form'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access site-wide contact form']);
// Allow authenticated users to use shortcuts.
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access shortcuts'));
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access shortcuts']);
// Populate the default shortcut set.
- $shortcut = Shortcut::create(array(
+ $shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
- 'link' => array('uri' => 'internal:/node/add'),
- ));
+ 'link' => ['uri' => 'internal:/node/add'],
+ ]);
$shortcut->save();
- $shortcut = Shortcut::create(array(
+ $shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
- 'link' => array('uri' => 'internal:/admin/content'),
- ));
+ 'link' => ['uri' => 'internal:/admin/content'],
+ ]);
$shortcut->save();
// Allow all users to use search.
- user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('search content'));
- user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('search content'));
+ user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['search content']);
+ user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['search content']);
// Enable the admin theme.
\Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE);
diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php
index 64163681a3c..9baae37c82a 100644
--- a/core/profiles/standard/tests/src/Functional/StandardTest.php
+++ b/core/profiles/standard/tests/src/Functional/StandardTest.php
@@ -38,20 +38,20 @@ class StandardTest extends BrowserTestBase {
$this->assertResponse(200);
// Test anonymous user can access 'Main navigation' block.
- $this->adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'administer blocks',
'post comments',
'skip comment approval',
'create article content',
'create page content',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
// Configure the block.
$this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
- $this->drupalPostForm(NULL, array(
+ $this->drupalPostForm(NULL, [
'region' => 'sidebar_first',
'id' => 'main_navigation',
- ), t('Save block'));
+ ], t('Save block'));
// Verify admin user can see the block.
$this->drupalGet('');
$this->assertText('Main navigation');
@@ -59,18 +59,18 @@ class StandardTest extends BrowserTestBase {
// Verify we have role = aria on system_powered_by and help_block
// blocks.
$this->drupalGet('admin/structure/block');
- $elements = $this->xpath('//div[@role=:role and @id=:id]', array(
+ $elements = $this->xpath('//div[@role=:role and @id=:id]', [
':role' => 'complementary',
':id' => 'block-bartik-help',
- ));
+ ]);
$this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
$this->drupalGet('');
- $elements = $this->xpath('//div[@role=:role and @id=:id]', array(
+ $elements = $this->xpath('//div[@role=:role and @id=:id]', [
':role' => 'complementary',
':id' => 'block-bartik-powered',
- ));
+ ]);
$this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');
// Verify anonymous user can see the block.
@@ -79,22 +79,22 @@ class StandardTest extends BrowserTestBase {
// Ensure comments don't show in the front page RSS feed.
// Create an article.
- $this->drupalCreateNode(array(
+ $this->drupalCreateNode([
'type' => 'article',
'title' => 'Foobar',
'promote' => 1,
'status' => 1,
- 'body' => array(array('value' => 'Then she picked out two somebodies,<br />Sally and me', 'format' => 'basic_html')),
- ));
+ 'body' => [['value' => 'Then she picked out two somebodies,<br />Sally and me', 'format' => 'basic_html']],
+ ]);
// Add a comment.
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/1');
$this->assertRaw('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
- $this->drupalPostForm(NULL, array(
+ $this->drupalPostForm(NULL, [
'subject[0][value]' => 'Barfoo',
'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me',
- ), t('Save'));
+ ], t('Save'));
// Fetch the feed.
$this->drupalGet('rss.xml');
$this->assertText('Foobar');
@@ -131,9 +131,9 @@ class StandardTest extends BrowserTestBase {
$filter->removeFilter('editor_file_reference');
$filter->save();
}
- \Drupal::service('module_installer')->uninstall(array('editor', 'ckeditor'));
+ \Drupal::service('module_installer')->uninstall(['editor', 'ckeditor']);
$this->rebuildContainer();
- \Drupal::service('module_installer')->install(array('editor'));
+ \Drupal::service('module_installer')->install(['editor']);
/** @var \Drupal\contact\ContactFormInterface $contact_form */
$contact_form = ContactForm::load('feedback');
$recipients = $contact_form->getRecipients();
@@ -167,7 +167,7 @@ class StandardTest extends BrowserTestBase {
// Make sure the optional image styles are installed after enabling
// the responsive_image module.
- \Drupal::service('module_installer')->install(array('responsive_image'));
+ \Drupal::service('module_installer')->install(['responsive_image']);
$this->rebuildContainer();
$this->drupalGet('admin/config/media/image-styles');
$this->assertText('Max 325x325');
diff --git a/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php b/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php
index 332b0008148..ac2087be77a 100644
--- a/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php
+++ b/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php
@@ -20,7 +20,7 @@ class SystemListingCompatibleTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('drupal_system_listing_compatible_test');
+ public static $modules = ['drupal_system_listing_compatible_test'];
/**
* Use the Minimal profile.
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php
index 10aa88e9215..bf2643da6a5 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php
@@ -27,9 +27,9 @@ class MachineNameTest extends JavascriptTestBase {
protected function setUp() {
parent::setUp();
- $account = $this->drupalCreateUser(array(
+ $account = $this->drupalCreateUser([
'access content',
- ));
+ ]);
$this->drupalLogin($account);
}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
index a116c6fde8d..511dee6e32a 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
@@ -52,9 +52,9 @@ class EntityReferenceAutocompleteWidgetTest extends JavascriptTestBase {
entity_get_form_display('node', 'page', 'default')
->setComponent($field_name, [
'type' => 'entity_reference_autocomplete',
- 'settings' => array(
+ 'settings' => [
'match_operator' => 'CONTAINS',
- ),
+ ],
])
->save();
@@ -78,9 +78,9 @@ class EntityReferenceAutocompleteWidgetTest extends JavascriptTestBase {
entity_get_form_display('node', 'page', 'default')
->setComponent($field_name, [
'type' => 'entity_reference_autocomplete',
- 'settings' => array(
+ 'settings' => [
'match_operator' => 'STARTS_WITH',
- ),
+ ],
])
->save();
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
index 815a26b54e2..81d379f915b 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
@@ -113,7 +113,7 @@ JS;
* The page element node if found, NULL if not.
*/
public function waitForButton($locator, $timeout = 10000) {
- return $this->waitForElement('named', array('button', $locator), $timeout);
+ return $this->waitForElement('named', ['button', $locator], $timeout);
}
/**
@@ -128,7 +128,7 @@ JS;
* The page element node if found, NULL if not.
*/
public function waitForLink($locator, $timeout = 10000) {
- return $this->waitForElement('named', array('link', $locator), $timeout);
+ return $this->waitForElement('named', ['link', $locator], $timeout);
}
/**
@@ -143,7 +143,7 @@ JS;
* The page element node if found, NULL if not.
*/
public function waitForField($locator, $timeout = 10000) {
- return $this->waitForElement('named', array('field', $locator), $timeout);
+ return $this->waitForElement('named', ['field', $locator], $timeout);
}
/**
@@ -158,7 +158,7 @@ JS;
* The page element node if found, NULL if not.
*/
public function waitForId($id, $timeout = 10000) {
- return $this->waitForElement('named', array('id', $id), $timeout);
+ return $this->waitForElement('named', ['id', $id], $timeout);
}
/**
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php
index 7930a909d96..36f6340f727 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php
@@ -80,7 +80,7 @@ class JSWebAssertTest extends JavascriptTestBase {
$result = $page->findButton('Added WaitForElementVisible');
$this->assertEmpty($result);
$test_wait_on_element_visible->click();
- $result = $assert_session->waitForElementVisible('named', array('button', 'Added WaitForElementVisible'));
+ $result = $assert_session->waitForElementVisible('named', ['button', 'Added WaitForElementVisible']);
$this->assertNotEmpty($result);
$this->assertTrue($result instanceof NodeElement);
$this->assertEquals(TRUE, $result->isVisible());
diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
index 5e9caf4886e..1cf46fce128 100644
--- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
+++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
@@ -711,7 +711,7 @@ trait AssertLegacyTrait {
* @deprecated Scheduled for removal in Drupal 9.0.0.
* Use $this->assertSession()->buildXPathQuery() instead.
*/
- protected function buildXPathQuery($xpath, array $args = array()) {
+ protected function buildXPathQuery($xpath, array $args = []) {
return $this->assertSession()->buildXPathQuery($xpath, $args);
}
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index 25d1c702eb4..b555fb66fc0 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -21,7 +21,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('test_page_test', 'form_test', 'system_test');
+ public static $modules = ['test_page_test', 'form_test', 'system_test'];
/**
* Tests basic page test.
@@ -58,9 +58,9 @@ class BrowserTestBaseTest extends BrowserTestBase {
$this->assertSession()->pageTextContains('Hello Drupal');
// Test that setting headers with drupalGet() works.
- $this->drupalGet('system-test/header', array(), array(
+ $this->drupalGet('system-test/header', [], [
'Test-Header' => 'header value',
- ));
+ ]);
$returned_header = $this->getSession()->getResponseHeader('Test-Header');
$this->assertSame('header value', $returned_header);
}
diff --git a/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php b/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php
index 7138c5e80fc..698a7d1a034 100644
--- a/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php
+++ b/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php
@@ -17,6 +17,6 @@ class SchemaConfigListenerTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
}
diff --git a/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php b/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php
index c63170115af..ba30da948ad 100644
--- a/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php
+++ b/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php
@@ -84,10 +84,10 @@ class ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest extends B
$this->drupalGet($this->entityTypeId . '/manage/' . $entity->id() . '/edit');
// Rearrange the field items.
- $edit = array(
+ $edit = [
"$this->fieldName[0][_weight]" => 0,
"$this->fieldName[1][_weight]" => -1,
- );
+ ];
// Executing an ajax call is important before saving as it will trigger
// form state caching and so if for any reasons the form is rebuilt with
// the entity built based on the user submitted values with already
diff --git a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php
index 72e7b6f8faf..3e058028110 100644
--- a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php
@@ -39,7 +39,7 @@ class AttachedAssetsTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language', 'simpletest', 'common_test', 'system');
+ public static $modules = ['language', 'simpletest', 'common_test', 'system'];
/**
* {@inheritdoc}
@@ -57,10 +57,10 @@ class AttachedAssetsTest extends KernelTestBase {
*/
function testDefault() {
$assets = new AttachedAssets();
- $this->assertEqual(array(), $this->assetResolver->getCssAssets($assets, FALSE), 'Default CSS is empty.');
+ $this->assertEqual([], $this->assetResolver->getCssAssets($assets, FALSE), 'Default CSS is empty.');
list($js_assets_header, $js_assets_footer) = $this->assetResolver->getJsAssets($assets, FALSE);
- $this->assertEqual(array(), $js_assets_header, 'Default header JavaScript is empty.');
- $this->assertEqual(array(), $js_assets_footer, 'Default footer JavaScript is empty.');
+ $this->assertEqual([], $js_assets_header, 'Default header JavaScript is empty.');
+ $this->assertEqual([], $js_assets_footer, 'Default footer JavaScript is empty.');
}
/**
@@ -187,7 +187,7 @@ class AttachedAssetsTest extends KernelTestBase {
* Tests JavaScript settings.
*/
function testSettings() {
- $build = array();
+ $build = [];
$build['#attached']['library'][] = 'core/drupalSettings';
// Nonsensical value to verify if it's possible to override path settings.
$build['#attached']['drupalSettings']['path']['pathPrefix'] = 'yarhar';
@@ -311,12 +311,12 @@ class AttachedAssetsTest extends KernelTestBase {
$js = $this->assetResolver->getJsAssets($assets, FALSE)[1];
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
$rendered_js = $this->renderer->renderPlain($js_render_array);
- $matches = array();
+ $matches = [];
if (preg_match_all('/weight_([-0-9]+_[0-9]+)/', $rendered_js, $matches)) {
$result = $matches[1];
}
else {
- $result = array();
+ $result = [];
}
$this->assertIdentical($result, $expected_order_js, 'JavaScript is added in the expected weight order.');
@@ -353,12 +353,12 @@ class AttachedAssetsTest extends KernelTestBase {
$css = $this->assetResolver->getCssAssets($assets, FALSE);
$css_render_array = \Drupal::service('asset.css.collection_renderer')->render($css);
$rendered_css = $this->renderer->renderPlain($css_render_array);
- $matches = array();
+ $matches = [];
if (preg_match_all('/([a-z]+)_weight_([-0-9]+_[0-9]+)/', $rendered_css, $matches)) {
$result = $matches[0];
}
else {
- $result = array();
+ $result = [];
}
$this->assertIdentical($result, $expected_order_css, 'CSS is added in the expected weight order.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php
index e2108b3cc09..9246eaa22ed 100644
--- a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php
@@ -39,7 +39,7 @@ class GetFilenameTest extends KernelTestBase {
$this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml');
// Retrieving the location of a theme.
- \Drupal::service('theme_handler')->install(array('stark'));
+ \Drupal::service('theme_handler')->install(['stark']);
$this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml');
// Retrieving the location of a theme engine.
diff --git a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php
index 484ee9cc971..0fefc390f43 100644
--- a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php
@@ -19,7 +19,7 @@ class DatabaseBackendTagTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* {@inheritdoc}
@@ -30,21 +30,21 @@ class DatabaseBackendTagTest extends KernelTestBase {
$container
->register('cache_factory', 'Drupal\Core\Cache\CacheFactory')
->addArgument(new Reference('settings'))
- ->addMethodCall('setContainer', array(new Reference('service_container')));
+ ->addMethodCall('setContainer', [new Reference('service_container')]);
}
public function testTagInvalidations() {
// Create cache entry in multiple bins.
- $tags = array('test_tag:1', 'test_tag:2', 'test_tag:3');
- $bins = array('data', 'bootstrap', 'render');
+ $tags = ['test_tag:1', 'test_tag:2', 'test_tag:3'];
+ $bins = ['data', 'bootstrap', 'render'];
foreach ($bins as $bin) {
$bin = \Drupal::cache($bin);
$bin->set('test', 'value', Cache::PERMANENT, $tags);
$this->assertTrue($bin->get('test'), 'Cache item was set in bin.');
}
- $invalidations_before = intval(db_select('cachetags')->fields('cachetags', array('invalidations'))->condition('tag', 'test_tag:2')->execute()->fetchField());
- Cache::invalidateTags(array('test_tag:2'));
+ $invalidations_before = intval(db_select('cachetags')->fields('cachetags', ['invalidations'])->condition('tag', 'test_tag:2')->execute()->fetchField());
+ Cache::invalidateTags(['test_tag:2']);
// Test that cache entry has been invalidated in multiple bins.
foreach ($bins as $bin) {
@@ -53,7 +53,7 @@ class DatabaseBackendTagTest extends KernelTestBase {
}
// Test that only one tag invalidation has occurred.
- $invalidations_after = intval(db_select('cachetags')->fields('cachetags', array('invalidations'))->condition('tag', 'test_tag:2')->execute()->fetchField());
+ $invalidations_after = intval(db_select('cachetags')->fields('cachetags', ['invalidations'])->condition('tag', 'test_tag:2')->execute()->fetchField());
$this->assertEqual($invalidations_after, $invalidations_before + 1, 'Only one addition cache tag invalidation has occurred after invalidating a tag used in multiple bins.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php
index fd1c9423583..de8bbda5539 100644
--- a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php
@@ -16,7 +16,7 @@ class DatabaseBackendTest extends GenericCacheBackendUnitTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Creates a new instance of DatabaseBackend.
diff --git a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php
index d5f3e957299..8179d7d5a1d 100644
--- a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php
@@ -102,7 +102,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
}
protected function setUp() {
- $this->cachebackends = array();
+ $this->cachebackends = [];
$this->defaultValue = $this->randomMachineName(10);
parent::setUp();
@@ -131,7 +131,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend = $this->getCacheBackend();
$this->assertIdentical(FALSE, $backend->get('test1'), "Backend does not contain data for cache id test1.");
- $with_backslash = array('foo' => '\Drupal\foo\Bar');
+ $with_backslash = ['foo' => '\Drupal\foo\Bar'];
$backend->set('test1', $with_backslash);
$cached = $backend->get('test1');
$this->assert(is_object($cached), "Backend returned an object for cache id test1.");
@@ -142,10 +142,10 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
$this->assertIdentical(FALSE, $backend->get('test2'), "Backend does not contain data for cache id test2.");
- $backend->set('test2', array('value' => 3), REQUEST_TIME + 3);
+ $backend->set('test2', ['value' => 3], REQUEST_TIME + 3);
$cached = $backend->get('test2');
$this->assert(is_object($cached), "Backend returned an object for cache id test2.");
- $this->assertIdentical(array('value' => 3), $cached->data);
+ $this->assertIdentical(['value' => 3], $cached->data);
$this->assertTrue($cached->valid, 'Item is marked as valid.');
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
$this->assertEqual($cached->expire, REQUEST_TIME + 3, 'Expire time is correct.');
@@ -159,7 +159,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertEqual($cached->expire, REQUEST_TIME - 3, 'Expire time is correct.');
$this->assertIdentical(FALSE, $backend->get('test4'), "Backend does not contain data for cache id test4.");
- $with_eof = array('foo' => "\nEOF\ndata");
+ $with_eof = ['foo' => "\nEOF\ndata"];
$backend->set('test4', $with_eof);
$cached = $backend->get('test4');
$this->assert(is_object($cached), "Backend returned an object for cache id test4.");
@@ -169,7 +169,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
$this->assertIdentical(FALSE, $backend->get('test5'), "Backend does not contain data for cache id test5.");
- $with_eof_and_semicolon = array('foo' => "\nEOF;\ndata");
+ $with_eof_and_semicolon = ['foo' => "\nEOF;\ndata"];
$backend->set('test5', $with_eof_and_semicolon);
$cached = $backend->get('test5');
$this->assert(is_object($cached), "Backend returned an object for cache id test5.");
@@ -178,7 +178,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
- $with_variable = array('foo' => '$bar');
+ $with_variable = ['foo' => '$bar'];
$backend->set('test6', $with_variable);
$cached = $backend->get('test6');
$this->assert(is_object($cached), "Backend returned an object for cache id test6.");
@@ -257,14 +257,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
public function testValueTypeIsKept() {
$backend = $this->getCacheBackend();
- $variables = array(
+ $variables = [
'test1' => 1,
'test2' => '0',
'test3' => '',
'test4' => 12.64,
'test5' => FALSE,
- 'test6' => array(1, 2, 3),
- );
+ 'test6' => [1, 2, 3],
+ ];
// Create cache entries.
foreach ($variables as $cid => $data) {
@@ -297,14 +297,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend->set($long_cid, 300);
// Mismatch order for harder testing.
- $reference = array(
+ $reference = [
'test3',
'test7',
'test21', // Cid does not exist.
'test6',
'test19', // Cid does not exist until added before second getMultiple().
'test2',
- );
+ ];
$cids = $reference;
$ret = $backend->getMultiple($cids);
@@ -364,7 +364,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertFalse(in_array('test19', $cids), "Added cache id test19 is not in cids array.");
// Test with a long $cid and non-numeric array key.
- $cids = array('key:key' => $long_cid);
+ $cids = ['key:key' => $long_cid];
$return = $backend->getMultiple($cids);
$this->assertEqual(300, $return[$long_cid]->data);
$this->assertTrue(empty($cids));
@@ -380,13 +380,13 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
// Set multiple testing keys.
$backend->set('cid_1', 'Some other value');
- $items = array(
- 'cid_1' => array('data' => 1),
- 'cid_2' => array('data' => 2),
- 'cid_3' => array('data' => array(1, 2)),
- 'cid_4' => array('data' => 1, 'expire' => $future_expiration),
- 'cid_5' => array('data' => 1, 'tags' => array('test:a', 'test:b')),
- );
+ $items = [
+ 'cid_1' => ['data' => 1],
+ 'cid_2' => ['data' => 2],
+ 'cid_3' => ['data' => [1, 2]],
+ 'cid_4' => ['data' => 1, 'expire' => $future_expiration],
+ 'cid_5' => ['data' => 1, 'tags' => ['test:a', 'test:b']],
+ ];
$backend->setMultiple($items);
$cids = array_keys($items);
$cached = $backend->getMultiple($cids);
@@ -411,9 +411,9 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
// assertion.
try {
$items = [
- 'exception_test_1' => array('data' => 1, 'tags' => []),
- 'exception_test_2' => array('data' => 2, 'tags' => ['valid']),
- 'exception_test_3' => array('data' => 3, 'tags' => ['node' => [3, 5, 7]]),
+ 'exception_test_1' => ['data' => 1, 'tags' => []],
+ 'exception_test_2' => ['data' => 2, 'tags' => ['valid']],
+ 'exception_test_3' => ['data' => 3, 'tags' => ['node' => [3, 5, 7]]],
];
$backend->setMultiple($items);
$this->fail('::setMultiple() was called with invalid cache tags, runtime assertion did not fail.');
@@ -441,13 +441,13 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend->delete('test1');
$backend->delete('test23'); // Nonexistent key should not cause an error.
- $backend->deleteMultiple(array(
+ $backend->deleteMultiple([
'test3',
'test5',
'test7',
'test19', // Nonexistent key should not cause an error.
'test21', // Nonexistent key should not cause an error.
- ));
+ ]);
// Test if expected keys have been deleted.
$this->assertIdentical(FALSE, $backend->get('test1'), "Cache id test1 deleted.");
@@ -465,7 +465,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$this->assertIdentical(FALSE, $backend->get('test21'), "Cache id test21 does not exist.");
// Calling deleteMultiple() with an empty array should not cause an error.
- $this->assertFalse($backend->deleteMultiple(array()));
+ $this->assertFalse($backend->deleteMultiple([]));
}
/**
@@ -498,14 +498,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend->set('test3', 2);
$backend->set('test4', 2);
- $reference = array('test1', 'test2', 'test3', 'test4');
+ $reference = ['test1', 'test2', 'test3', 'test4'];
$cids = $reference;
$ret = $backend->getMultiple($cids);
$this->assertEqual(count($ret), 4, 'Four items returned.');
$backend->invalidate('test1');
- $backend->invalidateMultiple(array('test2', 'test3'));
+ $backend->invalidateMultiple(['test2', 'test3']);
$cids = $reference;
$ret = $backend->getMultiple($cids);
@@ -517,7 +517,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
// Calling invalidateMultiple() with an empty array should not cause an
// error.
- $this->assertFalse($backend->invalidateMultiple(array()));
+ $this->assertFalse($backend->invalidateMultiple([]));
}
/**
@@ -527,45 +527,45 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
$backend = $this->getCacheBackend();
// Create two cache entries with the same tag and tag value.
- $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
- $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
+ $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
+ $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
// Invalidate test_tag of value 1. This should invalidate both entries.
- Cache::invalidateTags(array('test_tag:2'));
+ Cache::invalidateTags(['test_tag:2']);
$this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two cache items invalidated after invalidating a cache tag.');
$this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
// Create two cache entries with the same tag and an array tag value.
- $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
- $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
+ $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
+ $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
// Invalidate test_tag of value 1. This should invalidate both entries.
- Cache::invalidateTags(array('test_tag:1'));
+ Cache::invalidateTags(['test_tag:1']);
$this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two caches removed after invalidating a cache tag.');
$this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
// Create three cache entries with a mix of tags and tag values.
- $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
- $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
- $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, array('test_tag_foo:3'));
+ $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
+ $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
+ $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, ['test_tag_foo:3']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2') && $backend->get('test_cid_invalidate3'), 'Three cached items were created.');
- Cache::invalidateTags(array('test_tag_foo:3'));
+ Cache::invalidateTags(['test_tag_foo:3']);
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Cache items not matching the tag were not invalidated.');
$this->assertFalse($backend->get('test_cid_invalidated3'), 'Cached item matching the tag was removed.');
// Create cache entry in multiple bins. Two cache entries
// (test_cid_invalidate1 and test_cid_invalidate2) still exist from previous
// tests.
- $tags = array('test_tag:1', 'test_tag:2', 'test_tag:3');
- $bins = array('path', 'bootstrap', 'page');
+ $tags = ['test_tag:1', 'test_tag:2', 'test_tag:3'];
+ $bins = ['path', 'bootstrap', 'page'];
foreach ($bins as $bin) {
$this->getCacheBackend($bin)->set('test', $this->defaultValue, Cache::PERMANENT, $tags);
$this->assertTrue($this->getCacheBackend($bin)->get('test'), 'Cache item was set in bin.');
}
- Cache::invalidateTags(array('test_tag:2'));
+ Cache::invalidateTags(['test_tag:2']);
// Test that the cache entry has been invalidated in multiple bins.
foreach ($bins as $bin) {
diff --git a/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php b/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php
index 2bcee75390e..a759bb5c16d 100644
--- a/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php
@@ -18,7 +18,7 @@ class SizeTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
$kb = Bytes::KILOBYTE;
- $this->exactTestCases = array(
+ $this->exactTestCases = [
'1 byte' => 1,
'1 KB' => $kb,
'1 MB' => $kb * $kb,
@@ -28,21 +28,21 @@ class SizeTest extends KernelTestBase {
'1 EB' => $kb * $kb * $kb * $kb * $kb * $kb,
'1 ZB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb,
'1 YB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb * $kb,
- );
- $this->roundedTestCases = array(
+ ];
+ $this->roundedTestCases = [
'2 bytes' => 2,
'1 MB' => ($kb * $kb) - 1, // rounded to 1 MB (not 1000 or 1024 kilobyte!)
round(3623651 / ($this->exactTestCases['1 MB']), 2) . ' MB' => 3623651, // megabytes
round(67234178751368124 / ($this->exactTestCases['1 PB']), 2) . ' PB' => 67234178751368124, // petabytes
round(235346823821125814962843827 / ($this->exactTestCases['1 YB']), 2) . ' YB' => 235346823821125814962843827, // yottabytes
- );
+ ];
}
/**
* Checks that format_size() returns the expected string.
*/
function testCommonFormatSize() {
- foreach (array($this->exactTestCases, $this->roundedTestCases) as $test_cases) {
+ foreach ([$this->exactTestCases, $this->roundedTestCases] as $test_cases) {
foreach ($test_cases as $expected => $input) {
$this->assertEqual(
($result = format_size($input, NULL)),
diff --git a/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php b/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php
index 7c68ed4554e..0a67384148d 100644
--- a/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php
@@ -18,11 +18,11 @@ class XssUnitTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'system');
+ public static $modules = ['filter', 'system'];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
}
/**
@@ -31,9 +31,9 @@ class XssUnitTest extends KernelTestBase {
function testT() {
$text = t('Simple text');
$this->assertEqual($text, 'Simple text', 't leaves simple text alone.');
- $text = t('Escaped text: @value', array('@value' => '<script>'));
+ $text = t('Escaped text: @value', ['@value' => '<script>']);
$this->assertEqual($text, 'Escaped text: &lt;script&gt;', 't replaces and escapes string.');
- $text = t('Placeholder text: %value', array('%value' => '<script>'));
+ $text = t('Placeholder text: %value', ['%value' => '<script>']);
$this->assertEqual($text, 'Placeholder text: <em class="placeholder">&lt;script&gt;</em>', 't replaces, escapes and themes string.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php
index 2af8b742c0f..6c40b1469d0 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php
@@ -32,7 +32,7 @@ class ConfigCRUDTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Tests CRUD operations.
@@ -52,7 +52,7 @@ class ConfigCRUDTest extends KernelTestBase {
// Verify the active configuration contains the saved value.
$actual_data = $storage->read($name);
- $this->assertIdentical($actual_data, array('value' => 'initial'));
+ $this->assertIdentical($actual_data, ['value' => 'initial']);
// Update the configuration object instance.
$config->set('value', 'instance-update');
@@ -61,7 +61,7 @@ class ConfigCRUDTest extends KernelTestBase {
// Verify the active configuration contains the updated value.
$actual_data = $storage->read($name);
- $this->assertIdentical($actual_data, array('value' => 'instance-update'));
+ $this->assertIdentical($actual_data, ['value' => 'instance-update']);
// Verify a call to $this->config() immediately returns the updated value.
$new_config = $this->config($name);
@@ -75,7 +75,7 @@ class ConfigCRUDTest extends KernelTestBase {
$config->delete();
// Verify the configuration object is empty.
- $this->assertIdentical($config->get(), array());
+ $this->assertIdentical($config->get(), []);
$this->assertIdentical($config->isNew(), TRUE);
// Verify that all copies of the configuration has been removed from the
@@ -98,7 +98,7 @@ class ConfigCRUDTest extends KernelTestBase {
// Verify the active configuration contains the updated value.
$actual_data = $storage->read($name);
- $this->assertIdentical($actual_data, array('value' => 're-created'));
+ $this->assertIdentical($actual_data, ['value' => 're-created']);
// Verify a call to $this->config() immediately returns the updated value.
$new_config = $this->config($name);
@@ -115,7 +115,7 @@ class ConfigCRUDTest extends KernelTestBase {
// Ensure that the old configuration object is removed from both the cache
// and the configuration storage.
$config = $this->config($name);
- $this->assertIdentical($config->get(), array());
+ $this->assertIdentical($config->get(), []);
$this->assertIdentical($config->isNew(), TRUE);
// Test renaming when config.factory does not have the object in its static
@@ -138,10 +138,10 @@ class ConfigCRUDTest extends KernelTestBase {
// Merge data into the configuration object.
$new_config = $this->config($new_name);
- $expected_values = array(
+ $expected_values = [
'value' => 'herp',
'404' => 'derp',
- );
+ ];
$new_config->merge($expected_values);
$new_config->save();
$this->assertIdentical($new_config->get('value'), $expected_values['value']);
@@ -181,7 +181,7 @@ class ConfigCRUDTest extends KernelTestBase {
}
// Verify that disallowed characters in the name cause an exception.
- $characters = $test_characters = array(':', '?', '*', '<', '>', '"', '\'', '/', '\\');
+ $characters = $test_characters = [':', '?', '*', '<', '>', '"', '\'', '/', '\\'];
foreach ($test_characters as $i => $c) {
try {
$name = 'namespace.object' . $c;
@@ -192,9 +192,9 @@ class ConfigCRUDTest extends KernelTestBase {
unset($test_characters[$i]);
}
}
- $this->assertTrue(empty($test_characters), format_string('Expected ConfigNameException was thrown for all invalid name characters: @characters', array(
+ $this->assertTrue(empty($test_characters), format_string('Expected ConfigNameException was thrown for all invalid name characters: @characters', [
'@characters' => implode(' ', $characters),
- )));
+ ]));
// Verify that a valid config object name can be saved.
$name = 'namespace.object';
@@ -217,7 +217,7 @@ class ConfigCRUDTest extends KernelTestBase {
// Verify that setData() will catch dotted keys.
$message = 'Expected ConfigValueException was thrown from setData() for value with dotted keys.';
try {
- $this->config('namespace.object')->setData(array('key.value' => 12))->save();
+ $this->config('namespace.object')->setData(['key.value' => 12])->save();
$this->fail($message);
}
catch (ConfigValueException $e) {
@@ -227,7 +227,7 @@ class ConfigCRUDTest extends KernelTestBase {
// Verify that set() will catch dotted keys.
$message = 'Expected ConfigValueException was thrown from set() for value with dotted keys.';
try {
- $this->config('namespace.object')->set('foo', array('key.value' => 12))->save();
+ $this->config('namespace.object')->set('foo', ['key.value' => 12])->save();
$this->fail($message);
}
catch (ConfigValueException $e) {
@@ -239,7 +239,7 @@ class ConfigCRUDTest extends KernelTestBase {
* Tests data type handling.
*/
public function testDataTypes() {
- \Drupal::service('module_installer')->install(array('config_test'));
+ \Drupal::service('module_installer')->install(['config_test']);
$storage = new DatabaseStorage($this->container->get('database'), 'config');
$name = 'config_test.types';
$config = $this->config($name);
@@ -247,8 +247,8 @@ class ConfigCRUDTest extends KernelTestBase {
$this->verbose('<pre>' . $original_content . "\n" . var_export($storage->read($name), TRUE));
// Verify variable data types are intact.
- $data = array(
- 'array' => array(),
+ $data = [
+ 'array' => [],
'boolean' => TRUE,
'exp' => 1.2e+34,
'float' => 3.14159,
@@ -258,7 +258,7 @@ class ConfigCRUDTest extends KernelTestBase {
'octal' => 0775,
'string' => 'string',
'string_int' => '1',
- );
+ ];
$data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($data));
$this->assertIdentical($config->get(), $data);
@@ -292,9 +292,9 @@ class ConfigCRUDTest extends KernelTestBase {
$this->fail('No Exception thrown upon saving invalid data type.');
}
catch (UnsupportedDataTypeConfigException $e) {
- $this->pass(SafeMarkup::format('%class thrown upon saving invalid data type.', array(
+ $this->pass(SafeMarkup::format('%class thrown upon saving invalid data type.', [
'%class' => get_class($e),
- )));
+ ]));
}
// Test that setting an unsupported type for a config object with no schema
@@ -309,9 +309,9 @@ class ConfigCRUDTest extends KernelTestBase {
$this->fail('No Exception thrown upon saving invalid data type.');
}
catch (UnsupportedDataTypeConfigException $e) {
- $this->pass(SafeMarkup::format('%class thrown upon saving invalid data type.', array(
+ $this->pass(SafeMarkup::format('%class thrown upon saving invalid data type.', [
'%class' => get_class($e),
- )));
+ ]));
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php
index 1c26774a6b8..79b01cba5d0 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php
@@ -21,20 +21,20 @@ class ConfigDependencyTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test', 'entity_test', 'user');
+ public static $modules = ['config_test', 'entity_test', 'user'];
/**
* Tests that calculating dependencies for system module.
*/
public function testNonEntity() {
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
$config_manager = \Drupal::service('config.manager');
- $dependents = $config_manager->findConfigEntityDependents('module', array('system'));
+ $dependents = $config_manager->findConfigEntityDependents('module', ['system']);
$this->assertTrue(isset($dependents['system.site']), 'Simple configuration system.site has a UUID key even though it is not a configuration entity and therefore is found when looking for dependencies of the System module.');
// Ensure that calling
// \Drupal\Core\Config\ConfigManager::findConfigEntityDependentsAsEntities()
// does not try to load system.site as an entity.
- $config_manager->findConfigEntityDependentsAsEntities('module', array('system'));
+ $config_manager->findConfigEntityDependentsAsEntities('module', ['system']);
}
/**
@@ -46,22 +46,22 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$storage = $this->container->get('entity.manager')->getStorage('config_test');
// Test dependencies between modules.
$entity1 = $storage->create(
- array(
+ [
'id' => 'entity1',
- 'dependencies' => array(
- 'enforced' => array(
- 'module' => array('node')
- )
- )
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'module' => ['node']
+ ]
+ ]
+ ]
);
$entity1->save();
- $dependents = $config_manager->findConfigEntityDependents('module', array('node'));
+ $dependents = $config_manager->findConfigEntityDependents('module', ['node']);
$this->assertTrue(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 has a dependency on the Node module.');
- $dependents = $config_manager->findConfigEntityDependents('module', array('config_test'));
+ $dependents = $config_manager->findConfigEntityDependents('module', ['config_test']);
$this->assertTrue(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 has a dependency on the config_test module.');
- $dependents = $config_manager->findConfigEntityDependents('module', array('views'));
+ $dependents = $config_manager->findConfigEntityDependents('module', ['views']);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on the Views module.');
// Ensure that the provider of the config entity is not actually written to
// the dependencies array.
@@ -70,22 +70,22 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$this->assertTrue(empty($root_module_dependencies), 'Node module is not written to the root dependencies array as it is enforced.');
// Create additional entities to test dependencies on config entities.
- $entity2 = $storage->create(array('id' => 'entity2', 'dependencies' => array('enforced' => array('config' => array($entity1->getConfigDependencyName())))));
+ $entity2 = $storage->create(['id' => 'entity2', 'dependencies' => ['enforced' => ['config' => [$entity1->getConfigDependencyName()]]]]);
$entity2->save();
- $entity3 = $storage->create(array('id' => 'entity3', 'dependencies' => array('enforced' => array('config' => array($entity2->getConfigDependencyName())))));
+ $entity3 = $storage->create(['id' => 'entity3', 'dependencies' => ['enforced' => ['config' => [$entity2->getConfigDependencyName()]]]]);
$entity3->save();
- $entity4 = $storage->create(array('id' => 'entity4', 'dependencies' => array('enforced' => array('config' => array($entity3->getConfigDependencyName())))));
+ $entity4 = $storage->create(['id' => 'entity4', 'dependencies' => ['enforced' => ['config' => [$entity3->getConfigDependencyName()]]]]);
$entity4->save();
// Test getting $entity1's dependencies as configuration dependency objects.
- $dependents = $config_manager->findConfigEntityDependents('config', array($entity1->getConfigDependencyName()));
+ $dependents = $config_manager->findConfigEntityDependents('config', [$entity1->getConfigDependencyName()]);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on itself.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 has a dependency on config_test.dynamic.entity1.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on config_test.dynamic.entity1.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity4']), 'config_test.dynamic.entity4 has a dependency on config_test.dynamic.entity1.');
// Test getting $entity2's dependencies as entities.
- $dependents = $config_manager->findConfigEntityDependentsAsEntities('config', array($entity2->getConfigDependencyName()));
+ $dependents = $config_manager->findConfigEntityDependentsAsEntities('config', [$entity2->getConfigDependencyName()]);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertFalse(in_array('config_test:entity1', $dependent_ids), 'config_test.dynamic.entity1 does not have a dependency on config_test.dynamic.entity1.');
$this->assertFalse(in_array('config_test:entity2', $dependent_ids), 'config_test.dynamic.entity2 does not have a dependency on itself.');
@@ -94,7 +94,7 @@ class ConfigDependencyTest extends EntityKernelTestBase {
// Test getting node module's dependencies as configuration dependency
// objects.
- $dependents = $config_manager->findConfigEntityDependents('module', array('node'));
+ $dependents = $config_manager->findConfigEntityDependents('module', ['node']);
$this->assertTrue(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 has a dependency on the Node module.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 has a dependency on the Node module.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on the Node module.');
@@ -105,20 +105,20 @@ class ConfigDependencyTest extends EntityKernelTestBase {
// no longer depend on node module.
$entity1->setEnforcedDependencies([])->save();
$entity3->setEnforcedDependencies(['module' => ['node'], 'config' => [$entity2->getConfigDependencyName()]])->save();
- $dependents = $config_manager->findConfigEntityDependents('module', array('node'));
+ $dependents = $config_manager->findConfigEntityDependents('module', ['node']);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on the Node module.');
$this->assertFalse(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 does not have a dependency on the Node module.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on the Node module.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity4']), 'config_test.dynamic.entity4 has a dependency on the Node module.');
// Test dependency on a content entity.
- $entity_test = EntityTest::create(array(
+ $entity_test = EntityTest::create([
'name' => $this->randomString(),
'type' => 'entity_test',
- ));
+ ]);
$entity_test->save();
$entity2->setEnforcedDependencies(['config' => [$entity1->getConfigDependencyName()], 'content' => [$entity_test->getConfigDependencyName()]])->save();;
- $dependents = $config_manager->findConfigEntityDependents('content', array($entity_test->getConfigDependencyName()));
+ $dependents = $config_manager->findConfigEntityDependents('content', [$entity_test->getConfigDependencyName()]);
$this->assertFalse(isset($dependents['config_test.dynamic.entity1']), 'config_test.dynamic.entity1 does not have a dependency on the content entity.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity2']), 'config_test.dynamic.entity2 has a dependency on the content entity.');
$this->assertTrue(isset($dependents['config_test.dynamic.entity3']), 'config_test.dynamic.entity3 has a dependency on the content entity (via entity2).');
@@ -127,10 +127,10 @@ class ConfigDependencyTest extends EntityKernelTestBase {
// Create a configuration entity of a different type with the same ID as one
// of the entities already created.
$alt_storage = $this->container->get('entity.manager')->getStorage('config_query_test');
- $alt_storage->create(array('id' => 'entity1', 'dependencies' => array('enforced' => array('config' => array($entity1->getConfigDependencyName())))))->save();
- $alt_storage->create(array('id' => 'entity2', 'dependencies' => array('enforced' => array('module' => array('views')))))->save();
+ $alt_storage->create(['id' => 'entity1', 'dependencies' => ['enforced' => ['config' => [$entity1->getConfigDependencyName()]]]])->save();
+ $alt_storage->create(['id' => 'entity2', 'dependencies' => ['enforced' => ['module' => ['views']]]])->save();
- $dependents = $config_manager->findConfigEntityDependentsAsEntities('config', array($entity1->getConfigDependencyName()));
+ $dependents = $config_manager->findConfigEntityDependentsAsEntities('config', [$entity1->getConfigDependencyName()]);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertFalse(in_array('config_test:entity1', $dependent_ids), 'config_test.dynamic.entity1 does not have a dependency on itself.');
$this->assertTrue(in_array('config_test:entity2', $dependent_ids), 'config_test.dynamic.entity2 has a dependency on config_test.dynamic.entity1.');
@@ -139,7 +139,7 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$this->assertTrue(in_array('config_query_test:entity1', $dependent_ids), 'config_query_test.dynamic.entity1 has a dependency on config_test.dynamic.entity1.');
$this->assertFalse(in_array('config_query_test:entity2', $dependent_ids), 'config_query_test.dynamic.entity2 does not have a dependency on config_test.dynamic.entity1.');
- $dependents = $config_manager->findConfigEntityDependentsAsEntities('module', array('node', 'views'));
+ $dependents = $config_manager->findConfigEntityDependentsAsEntities('module', ['node', 'views']);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertFalse(in_array('config_test:entity1', $dependent_ids), 'config_test.dynamic.entity1 does not have a dependency on Views or Node.');
$this->assertFalse(in_array('config_test:entity2', $dependent_ids), 'config_test.dynamic.entity2 does not have a dependency on Views or Node.');
@@ -148,7 +148,7 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$this->assertFalse(in_array('config_query_test:entity1', $dependent_ids), 'config_test.query.entity1 does not have a dependency on Views or Node.');
$this->assertTrue(in_array('config_query_test:entity2', $dependent_ids), 'config_test.query.entity2 has a dependency on Views or Node.');
- $dependents = $config_manager->findConfigEntityDependentsAsEntities('module', array('config_test'));
+ $dependents = $config_manager->findConfigEntityDependentsAsEntities('module', ['config_test']);
$dependent_ids = $this->getDependentIds($dependents);
$this->assertTrue(in_array('config_test:entity1', $dependent_ids), 'config_test.dynamic.entity1 has a dependency on config_test module.');
$this->assertTrue(in_array('config_test:entity2', $dependent_ids), 'config_test.dynamic.entity2 has a dependency on config_test module.');
@@ -194,25 +194,25 @@ class ConfigDependencyTest extends EntityKernelTestBase {
->getStorage('config_test');
// Test dependencies between modules.
$entity1 = $storage->create(
- array(
+ [
'id' => 'entity1',
- 'dependencies' => array(
- 'enforced' => array(
- 'module' => array('node', 'config_test')
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'module' => ['node', 'config_test']
+ ],
+ ],
+ ]
);
$entity1->save();
$entity2 = $storage->create(
- array(
+ [
'id' => 'entity2',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity1->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity1->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity2->save();
// Perform a module rebuild so we can know where the node module is located
@@ -258,14 +258,14 @@ class ConfigDependencyTest extends EntityKernelTestBase {
->getStorage('config_test');
// Entity 1 will be deleted because it depends on node.
$entity_1 = $storage->create(
- array(
+ [
'id' => 'entity_' . $entity_id_suffixes[0],
- 'dependencies' => array(
- 'enforced' => array(
- 'module' => array('node', 'config_test')
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'module' => ['node', 'config_test']
+ ],
+ ],
+ ]
);
$entity_1->save();
@@ -273,14 +273,14 @@ class ConfigDependencyTest extends EntityKernelTestBase {
// \Drupal\config_test\Entity::onDependencyRemoval() will remove the
// dependency before config entities are deleted.
$entity_2 = $storage->create(
- array(
+ [
'id' => 'entity_' . $entity_id_suffixes[1],
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity_1->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity_1->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity_2->save();
@@ -288,34 +288,34 @@ class ConfigDependencyTest extends EntityKernelTestBase {
// be fixed. The ConfigEntityInterface::onDependencyRemoval() method will
// not be called for this entity.
$entity_3 = $storage->create(
- array(
+ [
'id' => 'entity_' . $entity_id_suffixes[2],
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity_2->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity_2->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity_3->save();
// Entity 4's config dependency will be fixed but it will still be deleted
// because it also depends on the node module.
$entity_4 = $storage->create(
- array(
+ [
'id' => 'entity_' . $entity_id_suffixes[3],
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity_1->getConfigDependencyName()),
- 'module' => array('node', 'config_test')
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity_1->getConfigDependencyName()],
+ 'module' => ['node', 'config_test']
+ ],
+ ],
+ ]
);
$entity_4->save();
// Set a more complicated test where dependencies will be fixed.
- \Drupal::state()->set('config_test.fix_dependencies', array($entity_1->getConfigDependencyName()));
+ \Drupal::state()->set('config_test.fix_dependencies', [$entity_1->getConfigDependencyName()]);
\Drupal::state()->set('config_test.on_dependency_removal_called', []);
// Do a dry run using
@@ -341,7 +341,7 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$this->assertFalse($storage->load($entity_1->id()), 'Entity 1 deleted');
$entity_2 = $storage->load($entity_2->id());
$this->assertTrue($entity_2, 'Entity 2 not deleted');
- $this->assertEqual($entity_2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on entity 1.');
+ $this->assertEqual($entity_2->calculateDependencies()->getDependencies()['config'], [], 'Entity 2 dependencies updated to remove dependency on entity 1.');
$entity_3 = $storage->load($entity_3->id());
$this->assertTrue($entity_3, 'Entity 3 not deleted');
$this->assertEqual($entity_3->calculateDependencies()->getDependencies()['config'], [$entity_2->getConfigDependencyName()], 'Entity 3 still depends on entity 2.');
@@ -475,20 +475,20 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$storage = $this->container->get('entity.manager')->getStorage('config_test');
// Test dependencies between configuration entities.
$entity1 = $storage->create(
- array(
+ [
'id' => 'entity1'
- )
+ ]
);
$entity1->save();
$entity2 = $storage->create(
- array(
+ [
'id' => 'entity2',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity1->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity1->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity2->save();
@@ -506,13 +506,13 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$this->assertFalse($storage->load('entity2'), 'Entity 2 deleted');
// Set a more complicated test where dependencies will be fixed.
- \Drupal::state()->set('config_test.fix_dependencies', array($entity1->getConfigDependencyName()));
+ \Drupal::state()->set('config_test.fix_dependencies', [$entity1->getConfigDependencyName()]);
// Entity1 will be deleted by the test.
$entity1 = $storage->create(
- array(
+ [
'id' => 'entity1',
- )
+ ]
);
$entity1->save();
@@ -520,28 +520,28 @@ class ConfigDependencyTest extends EntityKernelTestBase {
// \Drupal\config_test\Entity::onDependencyRemoval() will remove the
// dependency before config entities are deleted.
$entity2 = $storage->create(
- array(
+ [
'id' => 'entity2',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity1->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity1->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity2->save();
// Entity3 will be unchanged because it is dependent on Entity2 which can
// be fixed.
$entity3 = $storage->create(
- array(
+ [
'id' => 'entity3',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity2->getConfigDependencyName()),
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity2->getConfigDependencyName()],
+ ],
+ ],
+ ]
);
$entity3->save();
@@ -559,7 +559,7 @@ class ConfigDependencyTest extends EntityKernelTestBase {
$this->assertFalse($storage->load('entity1'), 'Entity 1 deleted');
$entity2 = $storage->load('entity2');
$this->assertTrue($entity2, 'Entity 2 not deleted');
- $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.');
+ $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], [], 'Entity 2 dependencies updated to remove dependency on Entity1.');
$entity3 = $storage->load('entity3');
$this->assertTrue($entity3, 'Entity 3 not deleted');
$this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.');
@@ -585,30 +585,30 @@ class ConfigDependencyTest extends EntityKernelTestBase {
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = $this->container->get('entity.manager')->getStorage('config_test');
$entity1 = $storage->create(
- array(
+ [
'id' => 'entity1',
- 'dependencies' => array(
- 'enforced' => array(
- 'content' => array($content_entity->getConfigDependencyName())
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'content' => [$content_entity->getConfigDependencyName()]
+ ],
+ ],
+ ]
);
$entity1->save();
$entity2 = $storage->create(
- array(
+ [
'id' => 'entity2',
- 'dependencies' => array(
- 'enforced' => array(
- 'config' => array($entity1->getConfigDependencyName())
- ),
- ),
- )
+ 'dependencies' => [
+ 'enforced' => [
+ 'config' => [$entity1->getConfigDependencyName()]
+ ],
+ ],
+ ]
);
$entity2->save();
// Create a configuration entity that is not in the dependency chain.
- $entity3 = $storage->create(array('id' => 'entity3'));
+ $entity3 = $storage->create(['id' => 'entity3']);
$entity3->save();
$config_entities = $config_manager->getConfigEntitiesToChangeOnDependencyRemoval('content', [$content_entity->getConfigDependencyName()]);
@@ -628,7 +628,7 @@ class ConfigDependencyTest extends EntityKernelTestBase {
* An array with values of entity_type_id:ID
*/
protected function getDependentIds(array $dependents) {
- $dependent_ids = array();
+ $dependent_ids = [];
foreach ($dependents as $dependent) {
$dependent_ids[] = $dependent->getEntityTypeId() . ':' . $dependent->id();
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
index 409b7948e66..6fd5c4edbf3 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
@@ -16,7 +16,7 @@ class ConfigDiffTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test', 'system');
+ public static $modules = ['config_test', 'system'];
/**
* Tests calculating the difference between two sets of configuration.
@@ -32,7 +32,7 @@ class ConfigDiffTest extends KernelTestBase {
$change_data = 'foobar';
// Install the default config.
- $this->installConfig(array('config_test'));
+ $this->installConfig(['config_test']);
$original_data = \Drupal::config($config_name)->get();
// Change a configuration value in sync.
@@ -75,10 +75,10 @@ class ConfigDiffTest extends KernelTestBase {
// Test diffing a renamed config entity.
$test_entity_id = $this->randomMachineName();
- $test_entity = entity_create('config_test', array(
+ $test_entity = entity_create('config_test', [
'id' => $test_entity_id,
'label' => $this->randomMachineName(),
- ));
+ ]);
$test_entity->save();
$data = $active->read('config_test.dynamic.' . $test_entity_id);
$sync->write('config_test.dynamic.' . $test_entity_id, $data);
@@ -117,12 +117,12 @@ class ConfigDiffTest extends KernelTestBase {
$sync_test_collection = $sync->createCollection('test');
$config_name = 'config_test.test';
- $data = array('foo' => 'bar');
+ $data = ['foo' => 'bar'];
$active->write($config_name, $data);
$sync->write($config_name, $data);
$active_test_collection->write($config_name, $data);
- $sync_test_collection->write($config_name, array('foo' => 'baz'));
+ $sync_test_collection->write($config_name, ['foo' => 'baz']);
// Test the fields match in the default collection diff.
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php
index bfa823383df..5a137b9f4f4 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php
@@ -16,7 +16,7 @@ class ConfigEntityNormalizeTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
protected function setUp() {
parent::setUp();
@@ -24,15 +24,15 @@ class ConfigEntityNormalizeTest extends KernelTestBase {
}
public function testNormalize() {
- $config_entity = entity_create('config_test', array('id' => 'system', 'label' => 'foobar', 'weight' => 1));
+ $config_entity = entity_create('config_test', ['id' => 'system', 'label' => 'foobar', 'weight' => 1]);
$config_entity->save();
// Modify stored config entity, this is comparable with a schema change.
$config = $this->config('config_test.dynamic.system');
- $data = array(
+ $data = [
'label' => 'foobar',
'additional_key' => TRUE
- ) + $config->getRawData();
+ ] + $config->getRawData();
$config->setData($data)->save();
$this->assertNotIdentical($config_entity->toArray(), $config->getRawData(), 'Stored config entity is not is equivalent to config schema.');
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php
index 6733415f465..3c3f70b6540 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php
@@ -17,7 +17,7 @@ class ConfigEntityStaticCacheTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test', 'config_entity_static_cache_test');
+ public static $modules = ['config_test', 'config_entity_static_cache_test'];
/**
* The type ID of the entity under test.
@@ -42,7 +42,7 @@ class ConfigEntityStaticCacheTest extends KernelTestBase {
$this->entityId = 'test_1';
$this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
- ->create(array('id' => $this->entityId, 'label' => 'Original label'))
+ ->create(['id' => $this->entityId, 'label' => 'Original label'])
->save();
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php
index 14765ef526e..55610bfc934 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php
@@ -16,15 +16,15 @@ class ConfigEntityStatusTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Tests the enabling/disabling of entities.
*/
function testCRUD() {
- $entity = entity_create('config_test', array(
+ $entity = entity_create('config_test', [
'id' => strtolower($this->randomMachineName()),
- ));
+ ]);
$this->assertTrue($entity->status(), 'Default status is enabled.');
$entity->save();
$this->assertTrue($entity->status(), 'Status is enabled after saving.');
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php
index 5b7022a4d9a..bf41e1de505 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php
@@ -18,7 +18,7 @@ class ConfigEntityStorageTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Tests creating configuration entities with changed UUIDs.
@@ -43,7 +43,7 @@ class ConfigEntityStorageTest extends KernelTestBase {
$this->fail('Exception thrown when attempting to save a configuration entity with a UUID that does not match the existing UUID.');
}
catch (ConfigDuplicateUUIDException $e) {
- $this->pass(format_string('Exception thrown when attempting to save a configuration entity with a UUID that does not match existing data: %e.', array('%e' => $e)));
+ $this->pass(format_string('Exception thrown when attempting to save a configuration entity with a UUID that does not match existing data: %e.', ['%e' => $e]));
}
// Ensure that the config entity was not corrupted.
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php
index 04c12c41e90..0010da78601 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php
@@ -25,7 +25,7 @@ class ConfigEntityUnitTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* The config_test entity storage.
@@ -57,19 +57,19 @@ class ConfigEntityUnitTest extends KernelTestBase {
// Create three entities, two with the same style.
$style = $this->randomMachineName(8);
for ($i = 0; $i < 2; $i++) {
- $entity = $this->storage->create(array(
+ $entity = $this->storage->create([
'id' => $this->randomMachineName(),
'label' => $this->randomString(),
'style' => $style,
- ));
+ ]);
$entity->save();
}
- $entity = $this->storage->create(array(
+ $entity = $this->storage->create([
'id' => $this->randomMachineName(),
'label' => $this->randomString(),
// Use a different length for the entity to ensure uniqueness.
'style' => $this->randomMachineName(9),
- ));
+ ]);
$entity->save();
// Ensure that the configuration entity can be loaded by UUID.
@@ -85,7 +85,7 @@ class ConfigEntityUnitTest extends KernelTestBase {
$entities = $this->storage->loadByProperties();
$this->assertEqual(count($entities), 3, 'Three entities are loaded when no properties are specified.');
- $entities = $this->storage->loadByProperties(array('style' => $style));
+ $entities = $this->storage->loadByProperties(['style' => $style]);
$this->assertEqual(count($entities), 2, 'Two entities are loaded when the style property is specified.');
// Assert that both returned entities have a matching style property.
@@ -94,11 +94,11 @@ class ConfigEntityUnitTest extends KernelTestBase {
}
// Test that schema type enforcement can be overridden by trusting the data.
- $entity = $this->storage->create(array(
+ $entity = $this->storage->create([
'id' => $this->randomMachineName(),
'label' => $this->randomString(),
'style' => 999
- ));
+ ]);
$entity->save();
$this->assertIdentical('999', $entity->style);
$entity->style = 999;
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEventsTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEventsTest.php
index 7c0680589e2..b39231531d2 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEventsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEventsTest.php
@@ -18,7 +18,7 @@ class ConfigEventsTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_events_test');
+ public static $modules = ['config_events_test'];
/**
* Tests configuration events.
@@ -28,28 +28,28 @@ class ConfigEventsTest extends KernelTestBase {
$config = new Config($name, \Drupal::service('config.storage'), \Drupal::service('event_dispatcher'), \Drupal::service('config.typed'));
$config->set('key', 'initial');
- $this->assertIdentical(\Drupal::state()->get('config_events_test.event', array()), array(), 'No events fired by creating a new configuration object');
+ $this->assertIdentical(\Drupal::state()->get('config_events_test.event', []), [], 'No events fired by creating a new configuration object');
$config->save();
- $event = \Drupal::state()->get('config_events_test.event', array());
+ $event = \Drupal::state()->get('config_events_test.event', []);
$this->assertIdentical($event['event_name'], ConfigEvents::SAVE);
- $this->assertIdentical($event['current_config_data'], array('key' => 'initial'));
- $this->assertIdentical($event['raw_config_data'], array('key' => 'initial'));
- $this->assertIdentical($event['original_config_data'], array());
+ $this->assertIdentical($event['current_config_data'], ['key' => 'initial']);
+ $this->assertIdentical($event['raw_config_data'], ['key' => 'initial']);
+ $this->assertIdentical($event['original_config_data'], []);
$config->set('key', 'updated')->save();
- $event = \Drupal::state()->get('config_events_test.event', array());
+ $event = \Drupal::state()->get('config_events_test.event', []);
$this->assertIdentical($event['event_name'], ConfigEvents::SAVE);
- $this->assertIdentical($event['current_config_data'], array('key' => 'updated'));
- $this->assertIdentical($event['raw_config_data'], array('key' => 'updated'));
- $this->assertIdentical($event['original_config_data'], array('key' => 'initial'));
+ $this->assertIdentical($event['current_config_data'], ['key' => 'updated']);
+ $this->assertIdentical($event['raw_config_data'], ['key' => 'updated']);
+ $this->assertIdentical($event['original_config_data'], ['key' => 'initial']);
$config->delete();
- $event = \Drupal::state()->get('config_events_test.event', array());
+ $event = \Drupal::state()->get('config_events_test.event', []);
$this->assertIdentical($event['event_name'], ConfigEvents::DELETE);
- $this->assertIdentical($event['current_config_data'], array());
- $this->assertIdentical($event['raw_config_data'], array());
- $this->assertIdentical($event['original_config_data'], array('key' => 'updated'));
+ $this->assertIdentical($event['current_config_data'], []);
+ $this->assertIdentical($event['raw_config_data'], []);
+ $this->assertIdentical($event['original_config_data'], ['key' => 'updated']);
}
/**
@@ -58,24 +58,24 @@ class ConfigEventsTest extends KernelTestBase {
function testConfigRenameEvent() {
$name = 'config_events_test.test';
$new_name = 'config_events_test.test_rename';
- $GLOBALS['config'][$name] = array('key' => 'overridden');
- $GLOBALS['config'][$new_name] = array('key' => 'new overridden');
+ $GLOBALS['config'][$name] = ['key' => 'overridden'];
+ $GLOBALS['config'][$new_name] = ['key' => 'new overridden'];
$config = $this->config($name);
$config->set('key', 'initial')->save();
- $event = \Drupal::state()->get('config_events_test.event', array());
+ $event = \Drupal::state()->get('config_events_test.event', []);
$this->assertIdentical($event['event_name'], ConfigEvents::SAVE);
- $this->assertIdentical($event['current_config_data'], array('key' => 'initial'));
+ $this->assertIdentical($event['current_config_data'], ['key' => 'initial']);
// Override applies when getting runtime config.
$this->assertEqual($GLOBALS['config'][$name], \Drupal::config($name)->get());
\Drupal::configFactory()->rename($name, $new_name);
- $event = \Drupal::state()->get('config_events_test.event', array());
+ $event = \Drupal::state()->get('config_events_test.event', []);
$this->assertIdentical($event['event_name'], ConfigEvents::RENAME);
- $this->assertIdentical($event['current_config_data'], array('key' => 'new overridden'));
- $this->assertIdentical($event['raw_config_data'], array('key' => 'initial'));
- $this->assertIdentical($event['original_config_data'], array('key' => 'new overridden'));
+ $this->assertIdentical($event['current_config_data'], ['key' => 'new overridden']);
+ $this->assertIdentical($event['raw_config_data'], ['key' => 'initial']);
+ $this->assertIdentical($event['original_config_data'], ['key' => 'new overridden']);
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigFileContentTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigFileContentTest.php
index 40241f6b90c..854c0907fdf 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigFileContentTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigFileContentTest.php
@@ -33,19 +33,19 @@ class ConfigFileContentTest extends KernelTestBase {
$nested_key = 'biff.bang';
$nested_value = 'pow';
$array_key = 'array';
- $array_value = array(
+ $array_value = [
'foo' => 'bar',
- 'biff' => array(
+ 'biff' => [
'bang' => 'pow',
- ),
- );
+ ],
+ ];
$casting_array_key = 'casting_array';
$casting_array_false_value_key = 'casting_array.cast.false';
- $casting_array_value = array(
- 'cast' => array(
+ $casting_array_value = [
+ 'cast' => [
'false' => FALSE,
- ),
- );
+ ],
+ ];
$nested_array_key = 'nested.array';
$true_key = 'true';
$false_key = 'false';
@@ -58,7 +58,7 @@ class ConfigFileContentTest extends KernelTestBase {
$this->assertTrue($config, 'Config object created.');
// Verify the configuration object is empty.
- $this->assertEqual($config->get(), array(), 'New config object is empty.');
+ $this->assertEqual($config->get(), [], 'New config object is empty.');
// Verify nothing was saved.
$data = $storage->read($name);
@@ -173,7 +173,7 @@ class ConfigFileContentTest extends KernelTestBase {
// Get file listing for all files starting with 'bar'. Should return
// an empty array.
$files = $storage->listAll('bar');
- $this->assertEqual($files, array(), 'No files listed with the prefix \'bar\'.');
+ $this->assertEqual($files, [], 'No files listed with the prefix \'bar\'.');
// Delete the configuration.
$config = $this->config($name);
@@ -189,20 +189,20 @@ class ConfigFileContentTest extends KernelTestBase {
*/
function testSerialization() {
$name = $this->randomMachineName(10) . '.' . $this->randomMachineName(10);
- $config_data = array(
+ $config_data = [
// Indexed arrays; the order of elements is essential.
- 'numeric keys' => array('i', 'n', 'd', 'e', 'x', 'e', 'd'),
+ 'numeric keys' => ['i', 'n', 'd', 'e', 'x', 'e', 'd'],
// Infinitely nested keys using arbitrary element names.
- 'nested keys' => array(
+ 'nested keys' => [
// HTML/XML in values.
'HTML' => '<strong> <bold> <em> <blockquote>',
// UTF-8 in values.
'UTF-8' => 'FrançAIS is ÜBER-åwesome',
// Unicode in keys and values.
'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ' => 'αβγδεζηθικλμνξοσὠ',
- ),
+ ],
'invalid xml' => '</title><script type="text/javascript">alert("Title XSS!");</script> & < > " \' ',
- );
+ ];
// Encode and write, and reload and decode the configuration data.
$filestorage = new FileStorage(config_get_config_directory(CONFIG_SYNC_DIRECTORY));
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php
index 570ca4c1bed..0523ee85bf4 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php
@@ -33,7 +33,7 @@ class ConfigImportRecreateTest extends KernelTestBase {
parent::setUp();
$this->installEntitySchema('node');
- $this->installConfig(array('field', 'node'));
+ $this->installConfig(['field', 'node']);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
index 48b9c4675da..e755d5fd88b 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
@@ -40,7 +40,7 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
$this->installEntitySchema('user');
$this->installEntitySchema('node');
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
// Set up the ConfigImporter object for testing.
$storage_comparer = new StorageComparer(
@@ -67,10 +67,10 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
public function testRenameValidation() {
// Create a test entity.
$test_entity_id = $this->randomMachineName();
- $test_entity = entity_create('config_test', array(
+ $test_entity = entity_create('config_test', [
'id' => $test_entity_id,
'label' => $this->randomMachineName(),
- ));
+ ]);
$test_entity->save();
$uuid = $test_entity->uuid();
@@ -91,9 +91,9 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
// Confirm that the staged configuration is detected as a rename since the
// UUIDs match.
$this->configImporter->reset();
- $expected = array(
+ $expected = [
'node.type.' . $content_type->id() . '::config_test.dynamic.' . $test_entity_id,
- );
+ ];
$renames = $this->configImporter->getUnprocessedConfiguration('rename');
$this->assertIdentical($expected, $renames);
@@ -105,9 +105,9 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
}
catch (ConfigImporterException $e) {
$this->pass('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.');
- $expected = array(
- SafeMarkup::format('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', array('@old_type' => 'node_type', '@new_type' => 'config_test', '@old_name' => 'node.type.' . $content_type->id(), '@new_name' => 'config_test.dynamic.' . $test_entity_id))
- );
+ $expected = [
+ SafeMarkup::format('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => 'node_type', '@new_type' => 'config_test', '@old_name' => 'node.type.' . $content_type->id(), '@new_name' => 'config_test.dynamic.' . $test_entity_id])
+ ];
$this->assertEqual($expected, $this->configImporter->getErrors());
}
}
@@ -134,9 +134,9 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
// Confirm that the staged configuration is detected as a rename since the
// UUIDs match.
$this->configImporter->reset();
- $expected = array(
+ $expected = [
'config_test.old::config_test.new'
- );
+ ];
$renames = $this->configImporter->getUnprocessedConfiguration('rename');
$this->assertIdentical($expected, $renames);
@@ -148,9 +148,9 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
}
catch (ConfigImporterException $e) {
$this->pass('Expected ConfigImporterException thrown when simple configuration is renamed.');
- $expected = array(
- SafeMarkup::format('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', array('@old_name' => 'config_test.old', '@new_name' => 'config_test.new'))
- );
+ $expected = [
+ SafeMarkup::format('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => 'config_test.old', '@new_name' => 'config_test.new'])
+ ];
$this->assertEqual($expected, $this->configImporter->getErrors());
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php
index 55f64814f9a..93311952f99 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php
@@ -26,14 +26,14 @@ class ConfigImporterMissingContentTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'entity_test', 'config_test', 'config_import_test');
+ public static $modules = ['system', 'user', 'entity_test', 'config_test', 'config_import_test'];
protected function setUp() {
parent::setUp();
$this->installSchema('system', 'sequences');
$this->installEntitySchema('entity_test');
$this->installEntitySchema('user');
- $this->installConfig(array('config_test'));
+ $this->installConfig(['config_test']);
// Installing config_test's default configuration pollutes the global
// variable being used for recording hook invocations by this test already,
// so it has to be cleared out manually.
@@ -73,9 +73,9 @@ class ConfigImporterMissingContentTest extends KernelTestBase {
// on two content entities that do not exist.
$storage = $this->container->get('config.storage');
$sync = $this->container->get('config.storage.sync');
- $entity_one = EntityTest::create(array('name' => 'one'));
- $entity_two = EntityTest::create(array('name' => 'two'));
- $entity_three = EntityTest::create(array('name' => 'three'));
+ $entity_one = EntityTest::create(['name' => 'one']);
+ $entity_two = EntityTest::create(['name' => 'two']);
+ $entity_three = EntityTest::create(['name' => 'three']);
$dynamic_name = 'config_test.dynamic.dotted.default';
$original_dynamic_data = $storage->read($dynamic_name);
// Entity one will be resolved by
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php
index bde5644ec6a..53ac7d19ef7 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php
@@ -28,12 +28,12 @@ class ConfigImporterTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test', 'system', 'config_import_test');
+ public static $modules = ['config_test', 'system', 'config_import_test'];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('config_test'));
+ $this->installConfig(['config_test']);
// Installing config_test's default configuration pollutes the global
// variable being used for recording hook invocations by this test already,
// so it has to be cleared out manually.
@@ -106,7 +106,7 @@ class ConfigImporterTest extends KernelTestBase {
catch (ConfigImporterException $e) {
$this->assertEqual($e->getMessage(), 'There were errors validating the config synchronization.');
$error_log = $this->configImporter->getErrors();
- $expected = array('Site UUID in source storage does not match the target storage.');
+ $expected = ['Site UUID in source storage does not match the target storage.'];
$this->assertEqual($expected, $error_log);
}
}
@@ -160,11 +160,11 @@ class ConfigImporterTest extends KernelTestBase {
$this->assertIdentical($storage->exists($dynamic_name), FALSE, $dynamic_name . ' not found.');
// Create new config entity.
- $original_dynamic_data = array(
+ $original_dynamic_data = [
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
'status' => TRUE,
- 'dependencies' => array(),
+ 'dependencies' => [],
'id' => 'new',
'label' => 'New',
'weight' => 0,
@@ -172,7 +172,7 @@ class ConfigImporterTest extends KernelTestBase {
'size' => '',
'size_value' => '',
'protected_property' => '',
- );
+ ];
$sync->write($dynamic_name, $original_dynamic_data);
$this->assertIdentical($sync->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
@@ -211,23 +211,23 @@ class ConfigImporterTest extends KernelTestBase {
$sync = $this->container->get('config.storage.sync');
$uuid = $this->container->get('uuid');
- $values_primary = array(
+ $values_primary = [
'id' => 'primary',
'label' => 'Primary',
'weight' => 0,
'uuid' => $uuid->generate(),
- );
+ ];
$sync->write($name_primary, $values_primary);
- $values_secondary = array(
+ $values_secondary = [
'id' => 'secondary',
'label' => 'Secondary Sync',
'weight' => 0,
'uuid' => $uuid->generate(),
// Add a dependency on primary, to ensure that is synced first.
- 'dependencies' => array(
- 'config' => array($name_primary),
- )
- );
+ 'dependencies' => [
+ 'config' => [$name_primary],
+ ]
+ ];
$sync->write($name_secondary, $values_secondary);
// Import.
@@ -245,7 +245,7 @@ class ConfigImporterTest extends KernelTestBase {
$logs = $this->configImporter->getErrors();
$this->assertEqual(count($logs), 1);
- $this->assertEqual($logs[0], SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary)));
+ $this->assertEqual($logs[0], SafeMarkup::format('Deleted and replaced configuration entity "@name"', ['@name' => $name_secondary]));
}
/**
@@ -257,23 +257,23 @@ class ConfigImporterTest extends KernelTestBase {
$sync = $this->container->get('config.storage.sync');
$uuid = $this->container->get('uuid');
- $values_primary = array(
+ $values_primary = [
'id' => 'primary',
'label' => 'Primary',
'weight' => 0,
'uuid' => $uuid->generate(),
// Add a dependency on secondary, so that is synced first.
- 'dependencies' => array(
- 'config' => array($name_secondary),
- )
- );
+ 'dependencies' => [
+ 'config' => [$name_secondary],
+ ]
+ ];
$sync->write($name_primary, $values_primary);
- $values_secondary = array(
+ $values_secondary = [
'id' => 'secondary',
'label' => 'Secondary Sync',
'weight' => 0,
'uuid' => $uuid->generate(),
- );
+ ];
$sync->write($name_secondary, $values_secondary);
// Import.
@@ -305,52 +305,52 @@ class ConfigImporterTest extends KernelTestBase {
$sync = $this->container->get('config.storage.sync');
$uuid = $this->container->get('uuid');
- $values_deleter = array(
+ $values_deleter = [
'id' => 'deleter',
'label' => 'Deleter',
'weight' => 0,
'uuid' => $uuid->generate(),
- );
+ ];
$storage->write($name_deleter, $values_deleter);
$values_deleter['label'] = 'Updated Deleter';
$sync->write($name_deleter, $values_deleter);
- $values_deletee = array(
+ $values_deletee = [
'id' => 'deletee',
'label' => 'Deletee',
'weight' => 0,
'uuid' => $uuid->generate(),
// Add a dependency on deleter, to make sure that is synced first.
- 'dependencies' => array(
- 'config' => array($name_deleter),
- )
- );
+ 'dependencies' => [
+ 'config' => [$name_deleter],
+ ]
+ ];
$storage->write($name_deletee, $values_deletee);
$values_deletee['label'] = 'Updated Deletee';
$sync->write($name_deletee, $values_deletee);
// Ensure that import will continue after the error.
- $values_other = array(
+ $values_other = [
'id' => 'other',
'label' => 'Other',
'weight' => 0,
'uuid' => $uuid->generate(),
// Add a dependency on deleter, to make sure that is synced first. This
// will also be synced after the deletee due to alphabetical ordering.
- 'dependencies' => array(
- 'config' => array($name_deleter),
- )
- );
+ 'dependencies' => [
+ 'config' => [$name_deleter],
+ ]
+ ];
$storage->write($name_other, $values_other);
$values_other['label'] = 'Updated other';
$sync->write($name_other, $values_other);
// Check update changelist order.
$updates = $this->configImporter->reset()->getStorageComparer()->getChangelist('update');
- $expected = array(
+ $expected = [
$name_deleter,
$name_deletee,
$name_other,
- );
+ ];
$this->assertIdentical($expected, $updates);
// Import.
@@ -373,7 +373,7 @@ class ConfigImporterTest extends KernelTestBase {
$logs = $this->configImporter->getErrors();
$this->assertEqual(count($logs), 1);
- $this->assertEqual($logs[0], SafeMarkup::format('Update target "@name" is missing.', array('@name' => $name_deletee)));
+ $this->assertEqual($logs[0], SafeMarkup::format('Update target "@name" is missing.', ['@name' => $name_deletee]));
}
/**
@@ -390,25 +390,25 @@ class ConfigImporterTest extends KernelTestBase {
$sync = $this->container->get('config.storage.sync');
$uuid = $this->container->get('uuid');
- $values_deleter = array(
+ $values_deleter = [
'id' => 'deleter',
'label' => 'Deleter',
'weight' => 0,
'uuid' => $uuid->generate(),
// Add a dependency on deletee, to make sure that is synced first.
- 'dependencies' => array(
- 'config' => array($name_deletee),
- ),
- );
+ 'dependencies' => [
+ 'config' => [$name_deletee],
+ ],
+ ];
$storage->write($name_deleter, $values_deleter);
$values_deleter['label'] = 'Updated Deleter';
$sync->write($name_deleter, $values_deleter);
- $values_deletee = array(
+ $values_deletee = [
'id' => 'deletee',
'label' => 'Deletee',
'weight' => 0,
'uuid' => $uuid->generate(),
- );
+ ];
$storage->write($name_deletee, $values_deletee);
$values_deletee['label'] = 'Updated Deletee';
$sync->write($name_deletee, $values_deletee);
@@ -436,23 +436,23 @@ class ConfigImporterTest extends KernelTestBase {
$uuid = $this->container->get('uuid');
- $values_deleter = array(
+ $values_deleter = [
'id' => 'deleter',
'label' => 'Deleter',
'weight' => 0,
'uuid' => $uuid->generate(),
// Add a dependency on deletee, to make sure this delete is synced first.
- 'dependencies' => array(
- 'config' => array($name_deletee),
- ),
- );
+ 'dependencies' => [
+ 'config' => [$name_deletee],
+ ],
+ ];
$storage->write($name_deleter, $values_deleter);
- $values_deletee = array(
+ $values_deletee = [
'id' => 'deletee',
'label' => 'Deletee',
'weight' => 0,
'uuid' => $uuid->generate(),
- );
+ ];
$storage->write($name_deletee, $values_deletee);
// Import.
@@ -483,9 +483,9 @@ class ConfigImporterTest extends KernelTestBase {
// Replace the file content of the existing configuration objects in the
// sync directory.
- $original_name_data = array(
+ $original_name_data = [
'foo' => 'beer',
- );
+ ];
$sync->write($name, $original_name_data);
$original_dynamic_data = $storage->read($dynamic_name);
$original_dynamic_data['label'] = 'Updated';
@@ -532,7 +532,7 @@ class ConfigImporterTest extends KernelTestBase {
$config_name = 'config_test.dynamic.isinstallable';
$this->assertFalse($this->container->get('config.storage')->exists($config_name));
\Drupal::state()->set('config_test.isinstallable', TRUE);
- $this->installConfig(array('config_test'));
+ $this->installConfig(['config_test']);
$this->assertTrue($this->container->get('config.storage')->exists($config_name));
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
index dcd66a32a0e..953ff24b85d 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
@@ -49,7 +49,7 @@ class ConfigInstallTest extends KernelTestBase {
$this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema does not exist.');
// Install the test module.
- $this->installModules(array('config_test'));
+ $this->installModules(['config_test']);
// Verify that default module config exists.
\Drupal::configFactory()->reset($default_config);
@@ -69,14 +69,14 @@ class ConfigInstallTest extends KernelTestBase {
$this->assertFalse(isset($GLOBALS['hook_config_test']['delete']));
// Install the schema test module.
- $this->enableModules(array('config_schema_test'));
- $this->installConfig(array('config_schema_test'));
+ $this->enableModules(['config_schema_test']);
+ $this->installConfig(['config_schema_test']);
// After module installation the new schema should exist.
$this->assertTrue(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema exists.');
// Test that uninstalling configuration removes configuration schema.
- $this->config('core.extension')->set('module', array())->save();
+ $this->config('core.extension')->set('module', [])->save();
\Drupal::service('config.manager')->uninstall('module', 'config_test');
$this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema does not exist.');
}
@@ -86,28 +86,28 @@ class ConfigInstallTest extends KernelTestBase {
*/
public function testCollectionInstallationNoCollections() {
// Install the test module.
- $this->enableModules(array('config_collection_install_test'));
- $this->installConfig(array('config_collection_install_test'));
+ $this->enableModules(['config_collection_install_test']);
+ $this->installConfig(['config_collection_install_test']);
/** @var \Drupal\Core\Config\StorageInterface $active_storage */
$active_storage = \Drupal::service('config.storage');
- $this->assertEqual(array(), $active_storage->getAllCollectionNames());
+ $this->assertEqual([], $active_storage->getAllCollectionNames());
}
/**
* Tests config objects in collections are installed as expected.
*/
public function testCollectionInstallationCollections() {
- $collections = array(
+ $collections = [
'another_collection',
'collection.test1',
'collection.test2',
- );
+ ];
// Set the event listener to return three possible collections.
// @see \Drupal\config_collection_install_test\EventSubscriber
\Drupal::state()->set('config_collection_install_test.collection_names', $collections);
// Install the test module.
- $this->enableModules(array('config_collection_install_test'));
- $this->installConfig(array('config_collection_install_test'));
+ $this->enableModules(['config_collection_install_test']);
+ $this->installConfig(['config_collection_install_test']);
/** @var \Drupal\Core\Config\StorageInterface $active_storage */
$active_storage = \Drupal::service('config.storage');
$this->assertEqual($collections, $active_storage->getAllCollectionNames());
@@ -140,20 +140,20 @@ class ConfigInstallTest extends KernelTestBase {
// is not enabled.
$this->assertEqual($collections, $active_storage->getAllCollectionNames());
// Enable the 'config_test' module and try again.
- $this->enableModules(array('config_test'));
+ $this->enableModules(['config_test']);
\Drupal::service('config.installer')->installCollectionDefaultConfig('entity');
$collections[] = 'entity';
$this->assertEqual($collections, $active_storage->getAllCollectionNames());
$collection_storage = $active_storage->createCollection('entity');
$data = $collection_storage->read('config_test.dynamic.dotted.default');
- $this->assertIdentical(array('label' => 'entity'), $data);
+ $this->assertIdentical(['label' => 'entity'], $data);
// Test that the config manager uninstalls configuration from collections
// as expected.
\Drupal::service('config.manager')->uninstall('module', 'config_collection_install_test');
- $this->assertEqual(array('entity'), $active_storage->getAllCollectionNames());
+ $this->assertEqual(['entity'], $active_storage->getAllCollectionNames());
\Drupal::service('config.manager')->uninstall('module', 'config_test');
- $this->assertEqual(array(), $active_storage->getAllCollectionNames());
+ $this->assertEqual([], $active_storage->getAllCollectionNames());
}
/**
@@ -165,12 +165,12 @@ class ConfigInstallTest extends KernelTestBase {
* using simple configuration.
*/
public function testCollectionInstallationCollectionConfigEntity() {
- $collections = array(
+ $collections = [
'entity',
- );
+ ];
\Drupal::state()->set('config_collection_install_test.collection_names', $collections);
// Install the test module.
- $this->installModules(array('config_test', 'config_collection_install_test'));
+ $this->installModules(['config_test', 'config_collection_install_test']);
/** @var \Drupal\Core\Config\StorageInterface $active_storage */
$active_storage = \Drupal::service('config.storage');
$this->assertEqual($collections, $active_storage->getAllCollectionNames());
@@ -185,7 +185,7 @@ class ConfigInstallTest extends KernelTestBase {
$data = $active_storage->read($name);
$this->assertTrue(isset($data['uuid']));
$data = $collection_storage->read($name);
- $this->assertIdentical(array('label' => 'entity'), $data);
+ $this->assertIdentical(['label' => 'entity'], $data);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php
index 994406c2a2d..6c6fa906222 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php
@@ -17,14 +17,14 @@ class ConfigLanguageOverrideTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('user', 'language', 'config_test', 'system', 'field');
+ public static $modules = ['user', 'language', 'config_test', 'system', 'field'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('config_test'));
+ $this->installConfig(['config_test']);
}
/**
@@ -68,40 +68,40 @@ class ConfigLanguageOverrideTest extends KernelTestBase {
// Test how overrides react to base configuration changes. Set up some base
// values.
\Drupal::configFactory()->getEditable('config_test.foo')
- ->set('value', array('key' => 'original'))
+ ->set('value', ['key' => 'original'])
->set('label', 'Original')
->save();
\Drupal::languageManager()
->getLanguageConfigOverride('de', 'config_test.foo')
- ->set('value', array('key' => 'override'))
+ ->set('value', ['key' => 'override'])
->set('label', 'Override')
->save();
\Drupal::languageManager()
->getLanguageConfigOverride('fr', 'config_test.foo')
- ->set('value', array('key' => 'override'))
+ ->set('value', ['key' => 'override'])
->save();
\Drupal::configFactory()->clearStaticCache();
$config = \Drupal::config('config_test.foo');
- $this->assertIdentical($config->get('value'), array('key' => 'override'));
+ $this->assertIdentical($config->get('value'), ['key' => 'override']);
// Ensure renaming the config will rename the override.
\Drupal::languageManager()->setConfigOverrideLanguage(\Drupal::languageManager()->getLanguage('en'));
\Drupal::configFactory()->rename('config_test.foo', 'config_test.bar');
$config = \Drupal::config('config_test.bar');
- $this->assertEqual($config->get('value'), array('key' => 'original'));
+ $this->assertEqual($config->get('value'), ['key' => 'original']);
$override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.foo');
$this->assertTrue($override->isNew());
$this->assertEqual($override->get('value'), NULL);
$override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.bar');
$this->assertFalse($override->isNew());
- $this->assertEqual($override->get('value'), array('key' => 'override'));
+ $this->assertEqual($override->get('value'), ['key' => 'override']);
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'config_test.bar');
$this->assertFalse($override->isNew());
- $this->assertEqual($override->get('value'), array('key' => 'override'));
+ $this->assertEqual($override->get('value'), ['key' => 'override']);
// Ensure changing data in the config will update the overrides.
$config = \Drupal::configFactory()->getEditable('config_test.bar')->clear('value.key')->save();
- $this->assertEqual($config->get('value'), array());
+ $this->assertEqual($config->get('value'), []);
$override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.bar');
$this->assertFalse($override->isNew());
$this->assertEqual($override->get('value'), NULL);
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php
index 1310cb32fcf..a94123d4cb9 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php
@@ -16,7 +16,7 @@ class ConfigModuleOverridesTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'config', 'config_override_test');
+ public static $modules = ['system', 'config', 'config_override_test'];
public function testSimpleModuleOverrides() {
$GLOBALS['config_test_run_module_overrides'] = TRUE;
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php
index 914adcf104f..157853bc937 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php
@@ -16,7 +16,7 @@ class ConfigOverrideTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'config_test');
+ public static $modules = ['system', 'config_test'];
protected function setUp() {
parent::setUp();
@@ -27,11 +27,11 @@ class ConfigOverrideTest extends KernelTestBase {
* Tests configuration override.
*/
function testConfOverride() {
- $expected_original_data = array(
+ $expected_original_data = [
'foo' => 'bar',
'baz' => NULL,
'404' => 'herp',
- );
+ ];
// Set globals before installing to prove that the installed file does not
// contain these values.
@@ -40,7 +40,7 @@ class ConfigOverrideTest extends KernelTestBase {
$overrides['config_test.system']['404'] = 'derp';
$GLOBALS['config'] = $overrides;
- $this->installConfig(array('config_test'));
+ $this->installConfig(['config_test']);
// Verify that the original configuration data exists. Have to read storage
// directly otherwise overrides will apply.
@@ -90,10 +90,10 @@ class ConfigOverrideTest extends KernelTestBase {
// Write file to sync.
$sync = $this->container->get('config.storage.sync');
- $expected_new_data = array(
+ $expected_new_data = [
'foo' => 'barbar',
'404' => 'herpderp',
- );
+ ];
$sync->write('config_test.system', $expected_new_data);
// Import changed data from sync to active.
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php
index f18bf3c8743..6c568b8417f 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php
@@ -18,7 +18,7 @@ class ConfigOverridesPriorityTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'config', 'config_override_test', 'language');
+ public static $modules = ['system', 'config', 'config_override_test', 'language'];
public function testOverridePriorities() {
$GLOBALS['config_test_run_module_overrides'] = FALSE;
@@ -50,10 +50,10 @@ class ConfigOverridesPriorityTest extends KernelTestBase {
$this->assertEqual(50, $config_factory->get('system.site')->get('weight_select_max'));
// Override using language.
- $language = new Language(array(
+ $language = new Language([
'name' => 'French',
'id' => 'fr',
- ));
+ ]);
\Drupal::languageManager()->setConfigOverrideLanguage($language);
\Drupal::languageManager()
->getLanguageConfigOverride($language->getId(), 'system.site')
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php
index 8a39d64edc9..5554fb2870a 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php
@@ -25,14 +25,14 @@ class ConfigSchemaTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'language', 'field', 'image', 'config_test', 'config_schema_test');
+ public static $modules = ['system', 'language', 'field', 'image', 'config_test', 'config_schema_test'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('system', 'image', 'config_schema_test'));
+ $this->installConfig(['system', 'image', 'config_schema_test']);
}
/**
@@ -42,7 +42,7 @@ class ConfigSchemaTest extends KernelTestBase {
// Nonexistent configuration key will have Undefined as metadata.
$this->assertIdentical(FALSE, \Drupal::service('config.typed')->hasConfigSchema('config_schema_test.no_such_key'));
$definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.no_such_key');
- $expected = array();
+ $expected = [];
$expected['label'] = 'Undefined';
$expected['class'] = Undefined::class;
$expected['type'] = 'undefined';
@@ -57,14 +57,14 @@ class ConfigSchemaTest extends KernelTestBase {
// Configuration file with only some schema.
$this->assertIdentical(TRUE, \Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'));
$definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.someschema');
- $expected = array();
+ $expected = [];
$expected['label'] = 'Schema test data';
$expected['class'] = Mapping::class;
$expected['mapping']['langcode']['type'] = 'string';
$expected['mapping']['langcode']['label'] = 'Language code';
$expected['mapping']['_core']['type'] = '_core_config_info';
- $expected['mapping']['testitem'] = array('label' => 'Test item');
- $expected['mapping']['testlist'] = array('label' => 'Test list');
+ $expected['mapping']['testitem'] = ['label' => 'Test item'];
+ $expected['mapping']['testlist'] = ['label' => 'Test list'];
$expected['type'] = 'config_schema_test.someschema';
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
$this->assertEqual($definition, $expected, 'Retrieved the right metadata for configuration with only some schema.');
@@ -72,21 +72,21 @@ class ConfigSchemaTest extends KernelTestBase {
// Check type detection on elements with undefined types.
$config = \Drupal::service('config.typed')->get('config_schema_test.someschema');
$definition = $config->get('testitem')->getDataDefinition()->toArray();
- $expected = array();
+ $expected = [];
$expected['label'] = 'Test item';
$expected['class'] = Undefined::class;
$expected['type'] = 'undefined';
$expected['definition_class'] = '\Drupal\Core\TypedData\DataDefinition';
$this->assertEqual($definition, $expected, 'Automatic type detected for a scalar is undefined.');
$definition = $config->get('testlist')->getDataDefinition()->toArray();
- $expected = array();
+ $expected = [];
$expected['label'] = 'Test list';
$expected['class'] = Undefined::class;
$expected['type'] = 'undefined';
$expected['definition_class'] = '\Drupal\Core\TypedData\DataDefinition';
$this->assertEqual($definition, $expected, 'Automatic type detected for a list is undefined.');
$definition = $config->get('testnoschema')->getDataDefinition()->toArray();
- $expected = array();
+ $expected = [];
$expected['label'] = 'Undefined';
$expected['class'] = Undefined::class;
$expected['type'] = 'undefined';
@@ -95,17 +95,17 @@ class ConfigSchemaTest extends KernelTestBase {
// Simple case, straight metadata.
$definition = \Drupal::service('config.typed')->getDefinition('system.maintenance');
- $expected = array();
+ $expected = [];
$expected['label'] = 'Maintenance mode';
$expected['class'] = Mapping::class;
- $expected['mapping']['message'] = array(
+ $expected['mapping']['message'] = [
'label' => 'Message to display when in maintenance mode',
'type' => 'text',
- );
- $expected['mapping']['langcode'] = array(
+ ];
+ $expected['mapping']['langcode'] = [
'label' => 'Language code',
'type' => 'string',
- );
+ ];
$expected['mapping']['_core']['type'] = '_core_config_info';
$expected['type'] = 'system.maintenance';
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
@@ -113,38 +113,38 @@ class ConfigSchemaTest extends KernelTestBase {
// Mixed schema with ignore elements.
$definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.ignore');
- $expected = array();
+ $expected = [];
$expected['label'] = 'Ignore test';
$expected['class'] = Mapping::class;
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
- $expected['mapping']['langcode'] = array(
+ $expected['mapping']['langcode'] = [
'type' => 'string',
'label' => 'Language code',
- );
+ ];
$expected['mapping']['_core']['type'] = '_core_config_info';
- $expected['mapping']['label'] = array(
+ $expected['mapping']['label'] = [
'label' => 'Label',
'type' => 'label',
- );
- $expected['mapping']['irrelevant'] = array(
+ ];
+ $expected['mapping']['irrelevant'] = [
'label' => 'Irrelevant',
'type' => 'ignore',
- );
- $expected['mapping']['indescribable'] = array(
+ ];
+ $expected['mapping']['indescribable'] = [
'label' => 'Indescribable',
'type' => 'ignore',
- );
- $expected['mapping']['weight'] = array(
+ ];
+ $expected['mapping']['weight'] = [
'label' => 'Weight',
'type' => 'integer',
- );
+ ];
$expected['type'] = 'config_schema_test.ignore';
$this->assertEqual($definition, $expected);
// The ignore elements themselves.
$definition = \Drupal::service('config.typed')->get('config_schema_test.ignore')->get('irrelevant')->getDataDefinition()->toArray();
- $expected = array();
+ $expected = [];
$expected['type'] = 'ignore';
$expected['label'] = 'Irrelevant';
$expected['class'] = Ignore::class;
@@ -156,7 +156,7 @@ class ConfigSchemaTest extends KernelTestBase {
// More complex case, generic type. Metadata for image style.
$definition = \Drupal::service('config.typed')->getDefinition('image.style.large');
- $expected = array();
+ $expected = [];
$expected['label'] = 'Image style';
$expected['class'] = Mapping::class;
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
@@ -189,7 +189,7 @@ class ConfigSchemaTest extends KernelTestBase {
// More complex, type based on a complex one.
$definition = \Drupal::service('config.typed')->getDefinition('image.effect.image_scale');
// This should be the schema for image.effect.image_scale.
- $expected = array();
+ $expected = [];
$expected['label'] = 'Image scale';
$expected['class'] = Mapping::class;
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
@@ -215,7 +215,7 @@ class ConfigSchemaTest extends KernelTestBase {
$a = \Drupal::config('config_test.dynamic.third_party');
$test = \Drupal::service('config.typed')->get('config_test.dynamic.third_party')->get('third_party_settings.config_schema_test');
$definition = $test->getDataDefinition()->toArray();
- $expected = array();
+ $expected = [];
$expected['type'] = 'config_test.dynamic.*.third_party.config_schema_test';
$expected['label'] = 'Mapping';
$expected['class'] = Mapping::class;
@@ -229,7 +229,7 @@ class ConfigSchemaTest extends KernelTestBase {
// More complex, several level deep test.
$definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.someschema.somemodule.section_one.subsection');
// This should be the schema of config_schema_test.someschema.somemodule.*.*.
- $expected = array();
+ $expected = [];
$expected['label'] = 'Schema multiple filesystem marker test';
$expected['class'] = Mapping::class;
$expected['mapping']['langcode']['type'] = 'string';
@@ -258,34 +258,34 @@ class ConfigSchemaTest extends KernelTestBase {
// Test fetching parent one level up.
$entry = $config_data->get('one_level');
$definition = $entry->get('testitem')->getDataDefinition()->toArray();
- $expected = array(
+ $expected = [
'type' => 'config_schema_test.someschema.with_parents.key_1',
'label' => 'Test item nested one level',
'class' => StringData::class,
'definition_class' => '\Drupal\Core\TypedData\DataDefinition',
- );
+ ];
$this->assertEqual($definition, $expected);
// Test fetching parent two levels up.
$entry = $config_data->get('two_levels');
$definition = $entry->get('wrapper')->get('testitem')->getDataDefinition()->toArray();
- $expected = array(
+ $expected = [
'type' => 'config_schema_test.someschema.with_parents.key_2',
'label' => 'Test item nested two levels',
'class' => StringData::class,
'definition_class' => '\Drupal\Core\TypedData\DataDefinition',
- );
+ ];
$this->assertEqual($definition, $expected);
// Test fetching parent three levels up.
$entry = $config_data->get('three_levels');
$definition = $entry->get('wrapper_1')->get('wrapper_2')->get('testitem')->getDataDefinition()->toArray();
- $expected = array(
+ $expected = [
'type' => 'config_schema_test.someschema.with_parents.key_3',
'label' => 'Test item nested three levels',
'class' => StringData::class,
'definition_class' => '\Drupal\Core\TypedData\DataDefinition',
- );
+ ];
$this->assertEqual($definition, $expected);
}
@@ -328,7 +328,7 @@ class ConfigSchemaTest extends KernelTestBase {
* Test configuration value data type enforcement using schemas.
*/
public function testConfigSaveWithSchema() {
- $untyped_values = array(
+ $untyped_values = [
'string' => 1,
'empty_string' => '',
'null_string' => NULL,
@@ -337,22 +337,22 @@ class ConfigSchemaTest extends KernelTestBase {
'boolean' => 1,
// If the config schema doesn't have a type it shouldn't be casted.
'no_type' => 1,
- 'mapping' => array(
+ 'mapping' => [
'string' => 1
- ),
+ ],
'float' => '3.14',
'null_float' => '',
- 'sequence' => array (1, 0, 1),
- 'sequence_bc' => array(1, 0, 1),
+ 'sequence' => [1, 0, 1],
+ 'sequence_bc' => [1, 0, 1],
// Not in schema and therefore should be left untouched.
'not_present_in_schema' => TRUE,
// Test a custom type.
'config_schema_test_integer' => '1',
'config_schema_test_integer_empty_string' => '',
- );
+ ];
$untyped_to_typed = $untyped_values;
- $typed_values = array(
+ $typed_values = [
'string' => '1',
'empty_string' => '',
'null_string' => NULL,
@@ -360,17 +360,17 @@ class ConfigSchemaTest extends KernelTestBase {
'null_integer' => NULL,
'boolean' => TRUE,
'no_type' => 1,
- 'mapping' => array(
+ 'mapping' => [
'string' => '1'
- ),
+ ],
'float' => 3.14,
'null_float' => NULL,
- 'sequence' => array (TRUE, FALSE, TRUE),
- 'sequence_bc' => array(TRUE, FALSE, TRUE),
+ 'sequence' => [TRUE, FALSE, TRUE],
+ 'sequence_bc' => [TRUE, FALSE, TRUE],
'not_present_in_schema' => TRUE,
'config_schema_test_integer' => 1,
'config_schema_test_integer_empty_string' => NULL,
- );
+ ];
// Save config which has a schema that enforces types.
$this->config('config_schema_test.schema_data_types')
@@ -401,7 +401,7 @@ class ConfigSchemaTest extends KernelTestBase {
function testSchemaFallback() {
$definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.wildcard_fallback.something');
// This should be the schema of config_schema_test.wildcard_fallback.*.
- $expected = array();
+ $expected = [];
$expected['label'] = 'Schema wildcard fallback test';
$expected['class'] = Mapping::class;
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php
index efac2dd12a2..2261168af67 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php
@@ -17,7 +17,7 @@ class ConfigSnapshotTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test', 'system');
+ public static $modules = ['config_test', 'system'];
/**
* {@inheritdoc}
@@ -50,7 +50,7 @@ class ConfigSnapshotTest extends KernelTestBase {
$this->assertFalse($active_snapshot_comparer->createChangelist()->hasChanges());
// Install the default config.
- $this->installConfig(array('config_test'));
+ $this->installConfig(['config_test']);
// Although we have imported config this has not affected the snapshot.
$this->assertTrue($active_snapshot_comparer->reset()->hasChanges());
diff --git a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php
index 4b14805175b..f06806cad6f 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php
@@ -23,7 +23,7 @@ class DefaultConfigTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'config_test');
+ public static $modules = ['system', 'config_test'];
/**
* Themes which provide default configuration and need enabling.
diff --git a/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php
index 15aecaaaf2d..68a8962e569 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php
@@ -27,14 +27,14 @@ class SchemaCheckTraitTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test', 'config_schema_test');
+ public static $modules = ['config_test', 'config_schema_test'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('config_test', 'config_schema_test'));
+ $this->installConfig(['config_test', 'config_schema_test']);
$this->typedConfig = \Drupal::service('config.typed');
}
@@ -53,14 +53,14 @@ class SchemaCheckTraitTest extends KernelTestBase {
// Add a new key, a new array and overwrite boolean with array to test the
// error messages.
- $config_data = array('new_key' => 'new_value', 'new_array' => array()) + $config_data;
- $config_data['boolean'] = array();
+ $config_data = ['new_key' => 'new_value', 'new_array' => []] + $config_data;
+ $config_data['boolean'] = [];
$ret = $this->checkConfigSchema($this->typedConfig, 'config_test.types', $config_data);
- $expected = array(
+ $expected = [
'config_test.types:new_key' => 'missing schema',
'config_test.types:new_array' => 'missing schema',
'config_test.types:boolean' => 'non-scalar value but not defined as an array (such as mapping or sequence)',
- );
+ ];
$this->assertEqual($ret, $expected);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php b/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php
index f0780212779..2674a3c6df8 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php
@@ -17,7 +17,7 @@ class SchemaConfigListenerTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* {@inheritdoc}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php
index 163cca71150..236647810cd 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php
@@ -37,7 +37,7 @@ class CachedStorageTest extends ConfigStorageTestBase {
$this->storage = new CachedStorage($this->fileStorage, \Drupal::service('cache.config'));
$this->cache = \Drupal::service('cache_factory')->get('config');
// ::listAll() verifications require other configuration data to exist.
- $this->storage->write('system.performance', array());
+ $this->storage->write('system.performance', []);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php
index 1863dab2fcf..079ac04a62b 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php
@@ -44,7 +44,7 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
$this->assertIdentical($data, FALSE);
// Writing data returns TRUE and the data has been written.
- $data = array('foo' => 'bar');
+ $data = ['foo' => 'bar'];
$result = $this->storage->write($name, $data);
$this->assertIdentical($result, TRUE);
@@ -86,11 +86,11 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
// Deleting all names with prefix deletes the appropriate data and returns
// TRUE.
- $files = array(
+ $files = [
'config_test.test.biff',
'config_test.test.bang',
'config_test.test.pow',
- );
+ ];
foreach ($files as $name) {
$this->storage->write($name, $data);
}
@@ -98,7 +98,7 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
$result = $this->storage->deleteAll('config_test.');
$names = $this->storage->listAll('config_test.');
$this->assertIdentical($result, TRUE);
- $this->assertIdentical($names, array());
+ $this->assertIdentical($names, []);
// Test renaming an object that does not exist throws an exception.
try {
@@ -127,7 +127,7 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
// Write something to the valid storage to prove that the storages do not
// pollute one another.
- $data = array('foo' => 'bar');
+ $data = ['foo' => 'bar'];
$result = $this->storage->write($name, $data);
$this->assertIdentical($result, TRUE);
@@ -150,11 +150,11 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
// Listing on a non-existing storage bin returns an empty array.
$result = $this->invalidStorage->listAll();
- $this->assertIdentical($result, array());
+ $this->assertIdentical($result, []);
// Writing to a non-existing storage bin creates the bin.
- $this->invalidStorage->write($name, array('foo' => 'bar'));
+ $this->invalidStorage->write($name, ['foo' => 'bar']);
$result = $this->invalidStorage->read($name);
- $this->assertIdentical($result, array('foo' => 'bar'));
+ $this->assertIdentical($result, ['foo' => 'bar']);
}
/**
@@ -162,8 +162,8 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
*/
function testDataTypes() {
$name = 'config_test.types';
- $data = array(
- 'array' => array(),
+ $data = [
+ 'array' => [],
'boolean' => TRUE,
'exp' => 1.2e+34,
'float' => 3.14159,
@@ -172,7 +172,7 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
'octal' => 0775,
'string' => 'string',
'string_int' => '1',
- );
+ ];
$result = $this->storage->write($name, $data);
$this->assertIdentical($result, TRUE);
@@ -186,7 +186,7 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
*/
public function testCollection() {
$name = 'config_test.storage';
- $data = array('foo' => 'bar');
+ $data = ['foo' => 'bar'];
$result = $this->storage->write($name, $data);
$this->assertIdentical($result, TRUE);
$this->assertIdentical($data, $this->storage->read($name));
@@ -194,13 +194,13 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
// Create configuration in a new collection.
$new_storage = $this->storage->createCollection('collection.sub.new');
$this->assertFalse($new_storage->exists($name));
- $this->assertEqual(array(), $new_storage->listAll());
+ $this->assertEqual([], $new_storage->listAll());
$new_storage->write($name, $data);
$this->assertIdentical($result, TRUE);
$this->assertIdentical($data, $new_storage->read($name));
- $this->assertEqual(array($name), $new_storage->listAll());
+ $this->assertEqual([$name], $new_storage->listAll());
$this->assertTrue($new_storage->exists($name));
- $new_data = array('foo' => 'baz');
+ $new_data = ['foo' => 'baz'];
$new_storage->write($name, $new_data);
$this->assertIdentical($result, TRUE);
$this->assertIdentical($new_data, $new_storage->read($name));
@@ -208,11 +208,11 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
// Create configuration in another collection.
$another_storage = $this->storage->createCollection('collection.sub.another');
$this->assertFalse($another_storage->exists($name));
- $this->assertEqual(array(), $another_storage->listAll());
+ $this->assertEqual([], $another_storage->listAll());
$another_storage->write($name, $new_data);
$this->assertIdentical($result, TRUE);
$this->assertIdentical($new_data, $another_storage->read($name));
- $this->assertEqual(array($name), $another_storage->listAll());
+ $this->assertEqual([$name], $another_storage->listAll());
$this->assertTrue($another_storage->exists($name));
// Create configuration in yet another collection.
@@ -226,33 +226,33 @@ abstract class ConfigStorageTestBase extends KernelTestBase {
$this->assertIdentical($data, $this->storage->read($name));
// Check that the getAllCollectionNames() method works.
- $this->assertIdentical(array('alternate', 'collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames());
+ $this->assertIdentical(['alternate', 'collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames());
// Check that the collections are removed when they are empty.
$alt_storage->delete($name);
- $this->assertIdentical(array('collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames());
+ $this->assertIdentical(['collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames());
// Create configuration in collection called 'collection'. This ensures that
// FileStorage's collection storage works regardless of its use of
// subdirectories.
$parent_storage = $this->storage->createCollection('collection');
$this->assertFalse($parent_storage->exists($name));
- $this->assertEqual(array(), $parent_storage->listAll());
+ $this->assertEqual([], $parent_storage->listAll());
$parent_storage->write($name, $new_data);
$this->assertIdentical($result, TRUE);
$this->assertIdentical($new_data, $parent_storage->read($name));
- $this->assertEqual(array($name), $parent_storage->listAll());
+ $this->assertEqual([$name], $parent_storage->listAll());
$this->assertTrue($parent_storage->exists($name));
- $this->assertIdentical(array('collection', 'collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames());
+ $this->assertIdentical(['collection', 'collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames());
$parent_storage->deleteAll();
- $this->assertIdentical(array('collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames());
+ $this->assertIdentical(['collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames());
// Check that the having an empty collection-less storage does not break
// anything. Before deleting check that the previous delete did not affect
// data in another collection.
$this->assertIdentical($data, $this->storage->read($name));
$this->storage->delete($name);
- $this->assertIdentical(array('collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames());
+ $this->assertIdentical(['collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames());
}
abstract protected function read($name);
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
index 6f09a829d4a..0aecc72b8f9 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
@@ -21,20 +21,20 @@ class DatabaseStorageTest extends ConfigStorageTestBase {
$this->invalidStorage = new DatabaseStorage($this->container->get('database'), 'invalid');
// ::listAll() verifications require other configuration data to exist.
- $this->storage->write('system.performance', array());
+ $this->storage->write('system.performance', []);
}
protected function read($name) {
- $data = db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $name))->fetchField();
+ $data = db_query('SELECT data FROM {config} WHERE name = :name', [':name' => $name])->fetchField();
return unserialize($data);
}
protected function insert($name, $data) {
- db_insert('config')->fields(array('name' => $name, 'data' => $data))->execute();
+ db_insert('config')->fields(['name' => $name, 'data' => $data])->execute();
}
protected function update($name, $data) {
- db_update('config')->fields(array('data' => $data))->condition('name', $name)->execute();
+ db_update('config')->fields(['data' => $data])->condition('name', $name)->execute();
}
protected function delete($name) {
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php
index fa10a09741b..23bd5ea6260 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php
@@ -33,7 +33,7 @@ class FileStorageTest extends ConfigStorageTestBase {
// FileStorage::listAll() requires other configuration data to exist.
$this->storage->write('system.performance', $this->config('system.performance')->get());
- $this->storage->write('core.extension', array('module' => array()));
+ $this->storage->write('core.extension', ['module' => []]);
}
protected function read($name) {
@@ -57,10 +57,10 @@ class FileStorageTest extends ConfigStorageTestBase {
* Tests the FileStorage::listAll method with a relative and absolute path.
*/
public function testlistAll() {
- $expected_files = array(
+ $expected_files = [
'core.extension',
'system.performance',
- );
+ ];
$config_files = $this->storage->listAll();
$this->assertIdentical($config_files, $expected_files, 'Relative path, two config files found.');
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php
index 84b4f564c32..44ce4958f37 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php
@@ -19,8 +19,8 @@ class StorageReplaceDataWrapperTest extends ConfigStorageTestBase {
parent::setUp();
$this->storage = new StorageReplaceDataWrapper($this->container->get('config.storage'));
// ::listAll() verifications require other configuration data to exist.
- $this->storage->write('system.performance', array());
- $this->storage->replaceData('system.performance', array('foo' => 'bar'));
+ $this->storage->write('system.performance', []);
+ $this->storage->replaceData('system.performance', ['foo' => 'bar']);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
index eaf50e50f2f..c595e8f7625 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php
@@ -16,13 +16,13 @@ class BasicSyntaxTest extends DatabaseTestBase {
* Tests string concatenation.
*/
function testConcatLiterals() {
- $result = db_query('SELECT CONCAT(:a1, CONCAT(:a2, CONCAT(:a3, CONCAT(:a4, :a5))))', array(
+ $result = db_query('SELECT CONCAT(:a1, CONCAT(:a2, CONCAT(:a3, CONCAT(:a4, :a5))))', [
':a1' => 'This',
':a2' => ' ',
':a3' => 'is',
':a4' => ' a ',
':a5' => 'test.',
- ));
+ ]);
$this->assertIdentical($result->fetchField(), 'This is a test.', 'Basic CONCAT works.');
}
@@ -30,12 +30,12 @@ class BasicSyntaxTest extends DatabaseTestBase {
* Tests string concatenation with field values.
*/
function testConcatFields() {
- $result = db_query('SELECT CONCAT(:a1, CONCAT(name, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age', array(
+ $result = db_query('SELECT CONCAT(:a1, CONCAT(name, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age', [
':a1' => 'The age of ',
':a2' => ' is ',
':a3' => '.',
':age' => 25,
- ));
+ ]);
$this->assertIdentical($result->fetchField(), 'The age of John is 25.', 'Field CONCAT works.');
}
@@ -43,12 +43,12 @@ class BasicSyntaxTest extends DatabaseTestBase {
* Tests string concatenation with separator.
*/
function testConcatWsLiterals() {
- $result = db_query("SELECT CONCAT_WS(', ', :a1, NULL, :a2, :a3, :a4)", array(
+ $result = db_query("SELECT CONCAT_WS(', ', :a1, NULL, :a2, :a3, :a4)", [
':a1' => 'Hello',
':a2' => NULL,
':a3' => '',
':a4' => 'world.',
- ));
+ ]);
$this->assertIdentical($result->fetchField(), 'Hello, , world.');
}
@@ -56,11 +56,11 @@ class BasicSyntaxTest extends DatabaseTestBase {
* Tests string concatenation with separator, with field values.
*/
function testConcatWsFields() {
- $result = db_query("SELECT CONCAT_WS('-', :a1, name, :a2, age) FROM {test} WHERE age = :age", array(
+ $result = db_query("SELECT CONCAT_WS('-', :a1, name, :a2, age) FROM {test} WHERE age = :age", [
':a1' => 'name',
':a2' => 'age',
':age' => 25,
- ));
+ ]);
$this->assertIdentical($result->fetchField(), 'name-John-age-25');
}
@@ -69,9 +69,9 @@ class BasicSyntaxTest extends DatabaseTestBase {
*/
function testLikeEscape() {
db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'Ring_',
- ))
+ ])
->execute();
// Match both "Ringo" and "Ring_".
@@ -95,13 +95,13 @@ class BasicSyntaxTest extends DatabaseTestBase {
*/
function testLikeBackslash() {
db_insert('test')
- ->fields(array('name'))
- ->values(array(
+ ->fields(['name'])
+ ->values([
'name' => 'abcde\f',
- ))
- ->values(array(
+ ])
+ ->values([
'name' => 'abc%\_',
- ))
+ ])
->execute();
// Match both rows using a LIKE expression with two wildcards and a verbatim
diff --git a/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php b/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
index 35fdb4d912e..24a18729e9f 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php
@@ -15,16 +15,16 @@ class CaseSensitivityTest extends DatabaseTestBase {
$num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'john', // <- A record already exists with name 'John'.
'age' => 2,
'job' => 'Baby',
- ))
+ ])
->execute();
$num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$this->assertIdentical($num_records_before + 1, (int) $num_records_after, 'Record inserts correctly.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'john'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'john'])->fetchField();
$this->assertIdentical($saved_age, '2', 'Can retrieve after inserting.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
index 0cc3627fb28..5a8444a18cc 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
@@ -168,9 +168,9 @@ class ConnectionTest extends DatabaseTestBase {
$stmt->execute();
foreach ($stmt->fetchAllAssoc('word') as $word => $row) {
$expected = '"' . $word . '"';
- $this->assertIdentical($db->escapeTable($word), $expected, format_string('The reserved word %word was correctly escaped when used as a table name.', array('%word' => $word)));
- $this->assertIdentical($db->escapeField($word), $expected, format_string('The reserved word %word was correctly escaped when used as a column name.', array('%word' => $word)));
- $this->assertIdentical($db->escapeAlias($word), $expected, format_string('The reserved word %word was correctly escaped when used as an alias.', array('%word' => $word)));
+ $this->assertIdentical($db->escapeTable($word), $expected, format_string('The reserved word %word was correctly escaped when used as a table name.', ['%word' => $word]));
+ $this->assertIdentical($db->escapeField($word), $expected, format_string('The reserved word %word was correctly escaped when used as a column name.', ['%word' => $word]));
+ $this->assertIdentical($db->escapeAlias($word), $expected, format_string('The reserved word %word was correctly escaped when used as an alias.', ['%word' => $word]));
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
index e315f9651dd..cd5dcd4b782 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
@@ -75,7 +75,7 @@ class ConnectionUnitTest extends KernelTestBase {
*/
protected function assertConnection($id) {
$list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0);
- return $this->assertTrue(isset($list[$id]), format_string('Connection ID @id found.', array('@id' => $id)));
+ return $this->assertTrue(isset($list[$id]), format_string('Connection ID @id found.', ['@id' => $id]));
}
/**
@@ -86,7 +86,7 @@ class ConnectionUnitTest extends KernelTestBase {
*/
protected function assertNoConnection($id) {
$list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0);
- return $this->assertFalse(isset($list[$id]), format_string('Connection ID @id not found.', array('@id' => $id)));
+ return $this->assertFalse(isset($list[$id]), format_string('Connection ID @id not found.', ['@id' => $id]));
}
/**
@@ -186,18 +186,18 @@ class ConnectionUnitTest extends KernelTestBase {
// Create a table.
$name = 'foo';
- Database::getConnection($this->target, $this->key)->schema()->createTable($name, array(
- 'fields' => array(
- 'name' => array(
+ Database::getConnection($this->target, $this->key)->schema()->createTable($name, [
+ 'fields' => [
+ 'name' => [
'type' => 'varchar',
'length' => 255,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
// Execute a query.
Database::getConnection($this->target, $this->key)->select('foo', 'f')
- ->fields('f', array('name'))
+ ->fields('f', ['name'])
->execute()
->fetchAll();
diff --git a/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php
index f8c8c3dcaf7..7781a9080b7 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php
@@ -12,11 +12,11 @@ use Drupal\KernelTests\KernelTestBase;
*/
abstract class DatabaseTestBase extends KernelTestBase {
- public static $modules = array('database_test');
+ public static $modules = ['database_test'];
protected function setUp() {
parent::setUp();
- $this->installSchema('database_test', array(
+ $this->installSchema('database_test', [
'test',
'test_people',
'test_people_copy',
@@ -27,7 +27,7 @@ abstract class DatabaseTestBase extends KernelTestBase {
'test_serialized',
'test_special_columns',
'TEST_UPPERCASE',
- ));
+ ]);
self::addSampleData();
}
@@ -36,19 +36,19 @@ abstract class DatabaseTestBase extends KernelTestBase {
*/
function ensureSampleDataNull() {
db_insert('test_null')
- ->fields(array('name', 'age'))
- ->values(array(
+ ->fields(['name', 'age'])
+ ->values([
'name' => 'Kermit',
'age' => 25,
- ))
- ->values(array(
+ ])
+ ->values([
'name' => 'Fozzie',
'age' => NULL,
- ))
- ->values(array(
+ ])
+ ->values([
'name' => 'Gonzo',
'age' => 27,
- ))
+ ])
->execute();
}
@@ -58,89 +58,89 @@ abstract class DatabaseTestBase extends KernelTestBase {
static function addSampleData() {
// We need the IDs, so we can't use a multi-insert here.
$john = db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'John',
'age' => 25,
'job' => 'Singer',
- ))
+ ])
->execute();
$george = db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'George',
'age' => 27,
'job' => 'Singer',
- ))
+ ])
->execute();
db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'Ringo',
'age' => 28,
'job' => 'Drummer',
- ))
+ ])
->execute();
$paul = db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'Paul',
'age' => 26,
'job' => 'Songwriter',
- ))
+ ])
->execute();
db_insert('test_people')
- ->fields(array(
+ ->fields([
'name' => 'Meredith',
'age' => 30,
'job' => 'Speaker',
- ))
+ ])
->execute();
db_insert('test_task')
- ->fields(array('pid', 'task', 'priority'))
- ->values(array(
+ ->fields(['pid', 'task', 'priority'])
+ ->values([
'pid' => $john,
'task' => 'eat',
'priority' => 3,
- ))
- ->values(array(
+ ])
+ ->values([
'pid' => $john,
'task' => 'sleep',
'priority' => 4,
- ))
- ->values(array(
+ ])
+ ->values([
'pid' => $john,
'task' => 'code',
'priority' => 1,
- ))
- ->values(array(
+ ])
+ ->values([
'pid' => $george,
'task' => 'sing',
'priority' => 2,
- ))
- ->values(array(
+ ])
+ ->values([
'pid' => $george,
'task' => 'sleep',
'priority' => 2,
- ))
- ->values(array(
+ ])
+ ->values([
'pid' => $paul,
'task' => 'found new band',
'priority' => 1,
- ))
- ->values(array(
+ ])
+ ->values([
'pid' => $paul,
'task' => 'perform at superbowl',
'priority' => 3,
- ))
+ ])
->execute();
db_insert('test_special_columns')
- ->fields(array(
+ ->fields([
'id' => 1,
'offset' => 'Offset value 1',
- ))
+ ])
->execute();
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
index 1545dd9dd3e..37dbab11e3b 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
@@ -25,8 +25,8 @@ class DeleteTruncateTest extends DatabaseTestBase {
$pid_to_delete = db_query("SELECT * FROM {test_task} WHERE task = 'sleep'")->fetchField();
$subquery = db_select('test', 't')
- ->fields('t', array('id'))
- ->condition('t.id', array($pid_to_delete), 'IN');
+ ->fields('t', ['id'])
+ ->condition('t.id', [$pid_to_delete], 'IN');
$delete = db_delete('test_task')
->condition('task', 'sleep')
->condition('pid', $subquery, 'IN');
diff --git a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php
index e4f4d670496..a29811dbd4d 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php
@@ -19,8 +19,8 @@ class FetchTest extends DatabaseTestBase {
* Confirms that we can fetch a record properly in default object mode.
*/
function testQueryFetchDefault() {
- $records = array();
- $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25));
+ $records = [];
+ $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25]);
$this->assertTrue($result instanceof StatementInterface, 'Result set is a Drupal statement object.');
foreach ($result as $record) {
$records[] = $record;
@@ -35,8 +35,8 @@ class FetchTest extends DatabaseTestBase {
* Confirms that we can fetch a record to an object explicitly.
*/
function testQueryFetchObject() {
- $records = array();
- $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_OBJ));
+ $records = [];
+ $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_OBJ]);
foreach ($result as $record) {
$records[] = $record;
$this->assertTrue(is_object($record), 'Record is an object.');
@@ -50,8 +50,8 @@ class FetchTest extends DatabaseTestBase {
* Confirms that we can fetch a record to an associative array explicitly.
*/
function testQueryFetchArray() {
- $records = array();
- $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_ASSOC));
+ $records = [];
+ $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_ASSOC]);
foreach ($result as $record) {
$records[] = $record;
if ($this->assertTrue(is_array($record), 'Record is an array.')) {
@@ -68,8 +68,8 @@ class FetchTest extends DatabaseTestBase {
* @see \Drupal\system\Tests\Database\FakeRecord
*/
function testQueryFetchClass() {
- $records = array();
- $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => 'Drupal\system\Tests\Database\FakeRecord'));
+ $records = [];
+ $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => 'Drupal\system\Tests\Database\FakeRecord']);
foreach ($result as $record) {
$records[] = $record;
if ($this->assertTrue($record instanceof FakeRecord, 'Record is an object of class FakeRecord.')) {
@@ -84,8 +84,8 @@ class FetchTest extends DatabaseTestBase {
* Confirms that we can fetch a record into an indexed array explicitly.
*/
function testQueryFetchNum() {
- $records = array();
- $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_NUM));
+ $records = [];
+ $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_NUM]);
foreach ($result as $record) {
$records[] = $record;
if ($this->assertTrue(is_array($record), 'Record is an array.')) {
@@ -100,8 +100,8 @@ class FetchTest extends DatabaseTestBase {
* Confirms that we can fetch a record into a doubly-keyed array explicitly.
*/
function testQueryFetchBoth() {
- $records = array();
- $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_BOTH));
+ $records = [];
+ $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_BOTH]);
foreach ($result as $record) {
$records[] = $record;
if ($this->assertTrue(is_array($record), 'Record is an array.')) {
@@ -130,11 +130,11 @@ class FetchTest extends DatabaseTestBase {
* Confirms that we can fetch an entire column of a result set at once.
*/
function testQueryFetchCol() {
- $result = db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25));
+ $result = db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25]);
$column = $result->fetchCol();
$this->assertIdentical(count($column), 3, 'fetchCol() returns the right number of records.');
- $result = db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25));
+ $result = db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25]);
$i = 0;
foreach ($result as $record) {
$this->assertIdentical($record->name, $column[$i++], 'Column matches direct access.');
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
index 6e0363aeb30..0cf1eba5c33 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
@@ -15,12 +15,12 @@ class InsertDefaultsTest extends DatabaseTestBase {
* Tests that we can run a query that uses default values for everything.
*/
function testDefaultInsert() {
- $query = db_insert('test')->useDefaults(array('job'));
+ $query = db_insert('test')->useDefaults(['job']);
$id = $query->execute();
$schema = drupal_get_module_schema('database_test', 'test');
- $job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField();
+ $job = db_query('SELECT job FROM {test} WHERE id = :id', [':id' => $id])->fetchField();
$this->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.');
}
@@ -48,13 +48,13 @@ class InsertDefaultsTest extends DatabaseTestBase {
*/
function testDefaultInsertWithFields() {
$query = db_insert('test')
- ->fields(array('name' => 'Bob'))
- ->useDefaults(array('job'));
+ ->fields(['name' => 'Bob'])
+ ->useDefaults(['job']);
$id = $query->execute();
$schema = drupal_get_module_schema('database_test', 'test');
- $job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField();
+ $job = db_query('SELECT job FROM {test} WHERE id = :id', [':id' => $id])->fetchField();
$this->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php
index cb41dc03987..ca4273e7ff8 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php
@@ -16,10 +16,10 @@ class InsertLobTest extends DatabaseTestBase {
$data = "This is\000a test.";
$this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
$id = db_insert('test_one_blob')
- ->fields(array('blob1' => $data))
+ ->fields(['blob1' => $data])
->execute();
- $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id))->fetchAssoc();
- $this->assertTrue($r['blob1'] === $data, format_string('Can insert a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r))));
+ $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', [':id' => $id])->fetchAssoc();
+ $this->assertTrue($r['blob1'] === $data, format_string('Can insert a blob: id @id, @data.', ['@id' => $id, '@data' => serialize($r)]));
}
/**
@@ -27,12 +27,12 @@ class InsertLobTest extends DatabaseTestBase {
*/
function testInsertMultipleBlob() {
$id = db_insert('test_two_blobs')
- ->fields(array(
+ ->fields([
'blob1' => 'This is',
'blob2' => 'a test',
- ))
+ ])
->execute();
- $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', array(':id' => $id))->fetchAssoc();
+ $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', [':id' => $id])->fetchAssoc();
$this->assertTrue($r['blob1'] === 'This is' && $r['blob2'] === 'a test', 'Can insert multiple blobs per row.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
index d703f9d3150..0c72d2eb6e1 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
@@ -16,10 +16,10 @@ class InsertTest extends DatabaseTestBase {
$num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$query = db_insert('test');
- $query->fields(array(
+ $query->fields([
'name' => 'Yoko',
'age' => '29',
- ));
+ ]);
// Check how many records are queued for insertion.
$this->assertIdentical($query->count(), 1, 'One record is queued for insertion.');
@@ -27,7 +27,7 @@ class InsertTest extends DatabaseTestBase {
$num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$this->assertIdentical($num_records_before + 1, (int) $num_records_after, 'Record inserts correctly.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Yoko'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Yoko'])->fetchField();
$this->assertIdentical($saved_age, '29', 'Can retrieve after inserting.');
}
@@ -38,23 +38,23 @@ class InsertTest extends DatabaseTestBase {
$num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$query = db_insert('test');
- $query->fields(array(
+ $query->fields([
'name' => 'Larry',
'age' => '30',
- ));
+ ]);
// We should be able to specify values in any order if named.
- $query->values(array(
+ $query->values([
'age' => '31',
'name' => 'Curly',
- ));
+ ]);
// Check how many records are queued for insertion.
$this->assertIdentical($query->count(), 2, 'Two records are queued for insertion.');
// We should be able to say "use the field order".
// This is not the recommended mechanism for most cases, but it should work.
- $query->values(array('Moe', '32'));
+ $query->values(['Moe', '32']);
// Check how many records are queued for insertion.
$this->assertIdentical($query->count(), 3, 'Three records are queued for insertion.');
@@ -62,11 +62,11 @@ class InsertTest extends DatabaseTestBase {
$num_records_after = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$this->assertIdentical($num_records_before + 3, $num_records_after, 'Record inserts correctly.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Larry'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Larry'])->fetchField();
$this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Curly'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Curly'])->fetchField();
$this->assertIdentical($saved_age, '31', 'Can retrieve after inserting.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Moe'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Moe'])->fetchField();
$this->assertIdentical($saved_age, '32', 'Can retrieve after inserting.');
}
@@ -78,25 +78,25 @@ class InsertTest extends DatabaseTestBase {
$query = db_insert('test');
- $query->fields(array(
+ $query->fields([
'name' => 'Larry',
'age' => '30',
- ));
+ ]);
// Check how many records are queued for insertion.
$this->assertIdentical($query->count(), 1, 'One record is queued for insertion.');
$query->execute(); // This should run the insert, but leave the fields intact.
// We should be able to specify values in any order if named.
- $query->values(array(
+ $query->values([
'age' => '31',
'name' => 'Curly',
- ));
+ ]);
// Check how many records are queued for insertion.
$this->assertIdentical($query->count(), 1, 'One record is queued for insertion.');
$query->execute();
// We should be able to say "use the field order".
- $query->values(array('Moe', '32'));
+ $query->values(['Moe', '32']);
// Check how many records are queued for insertion.
$this->assertIdentical($query->count(), 1, 'One record is queued for insertion.');
@@ -104,11 +104,11 @@ class InsertTest extends DatabaseTestBase {
$num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$this->assertIdentical((int) $num_records_before + 3, (int) $num_records_after, 'Record inserts correctly.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Larry'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Larry'])->fetchField();
$this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Curly'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Curly'])->fetchField();
$this->assertIdentical($saved_age, '31', 'Can retrieve after inserting.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Moe'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Moe'])->fetchField();
$this->assertIdentical($saved_age, '32', 'Can retrieve after inserting.');
}
@@ -119,16 +119,16 @@ class InsertTest extends DatabaseTestBase {
// This is useful for importers, when we want to create a query and define
// its fields once, then loop over a multi-insert execution.
db_insert('test')
- ->fields(array('name', 'age'))
- ->values(array('Larry', '30'))
- ->values(array('Curly', '31'))
- ->values(array('Moe', '32'))
+ ->fields(['name', 'age'])
+ ->values(['Larry', '30'])
+ ->values(['Curly', '31'])
+ ->values(['Moe', '32'])
->execute();
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Larry'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Larry'])->fetchField();
$this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Curly'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Curly'])->fetchField();
$this->assertIdentical($saved_age, '31', 'Can retrieve after inserting.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Moe'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Moe'])->fetchField();
$this->assertIdentical($saved_age, '32', 'Can retrieve after inserting.');
}
@@ -137,10 +137,10 @@ class InsertTest extends DatabaseTestBase {
*/
function testInsertLastInsertID() {
$id = db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'Larry',
'age' => '30',
- ))
+ ])
->execute();
$this->assertIdentical($id, '5', 'Auto-increment ID returned successfully.');
@@ -156,7 +156,7 @@ class InsertTest extends DatabaseTestBase {
// re-ordered.
$query->addExpression('tp.age', 'age');
$query
- ->fields('tp', array('name', 'job'))
+ ->fields('tp', ['name', 'job'])
->condition('tp.name', 'Meredith');
// The resulting query should be equivalent to:
@@ -168,7 +168,7 @@ class InsertTest extends DatabaseTestBase {
->from($query)
->execute();
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Meredith'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Meredith'])->fetchField();
$this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.');
}
@@ -189,7 +189,7 @@ class InsertTest extends DatabaseTestBase {
->from($query)
->execute();
- $saved_age = db_query('SELECT age FROM {test_people_copy} WHERE name = :name', array(':name' => 'Meredith'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test_people_copy} WHERE name = :name', [':name' => 'Meredith'])->fetchField();
$this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.');
}
@@ -198,12 +198,12 @@ class InsertTest extends DatabaseTestBase {
*/
function testSpecialColumnInsert() {
$id = db_insert('test_special_columns')
- ->fields(array(
+ ->fields([
'id' => 2,
'offset' => 'Offset value 2',
- ))
+ ])
->execute();
- $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', array(':id' => 2))->fetchField();
+ $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', [':id' => 2])->fetchField();
$this->assertIdentical($saved_value, 'Offset value 2', 'Can retrieve special column name value after inserting.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php b/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php
index 774a20b8bec..bf64bc8d0c5 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php
@@ -18,27 +18,27 @@ class InvalidDataTest extends DatabaseTestBase {
// Try to insert multiple records where at least one has bad data.
try {
db_insert('test')
- ->fields(array('name', 'age', 'job'))
- ->values(array(
+ ->fields(['name', 'age', 'job'])
+ ->values([
'name' => 'Elvis',
'age' => 63,
'job' => 'Singer',
- ))->values(array(
+ ])->values([
'name' => 'John', // <-- Duplicate value on unique field.
'age' => 17,
'job' => 'Consultant',
- ))
- ->values(array(
+ ])
+ ->values([
'name' => 'Frank',
'age' => 75,
'job' => 'Singer',
- ))
+ ])
->execute();
$this->fail('Insert succeeded when it should not have.');
}
catch (IntegrityConstraintViolationException $e) {
// Check if the first record was inserted.
- $name = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 63))->fetchField();
+ $name = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 63])->fetchField();
if ($name == 'Elvis') {
if (!Database::getConnection()->supportsTransactions()) {
@@ -58,8 +58,8 @@ class InvalidDataTest extends DatabaseTestBase {
// Ensure the other values were not inserted.
$record = db_select('test')
- ->fields('test', array('name', 'age'))
- ->condition('age', array(17, 75), 'IN')
+ ->fields('test', ['name', 'age'])
+ ->condition('age', [17, 75], 'IN')
->execute()->fetchObject();
$this->assertFalse($record, 'The rest of the insert aborted as expected.');
diff --git a/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php
index 4b24ebefbd7..a0aaa14c6e3 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php
@@ -29,7 +29,7 @@ class LargeQueryTest extends DatabaseTestBase {
if (Environment::checkMemoryLimit($max_allowed_packet + (16 * 1024 * 1024))) {
$long_name = str_repeat('a', $max_allowed_packet + 1);
try {
- db_query('SELECT name FROM {test} WHERE name = :name', array(':name' => $long_name));
+ db_query('SELECT name FROM {test} WHERE name = :name', [':name' => $long_name]);
$this->fail("An exception should be thrown for queries larger than 'max_allowed_packet'");
}
catch (DatabaseException $e) {
diff --git a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php
index c354c8292b5..ac10fe87614 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php
@@ -17,11 +17,11 @@ class LoggingTest extends DatabaseTestBase {
function testEnableLogging() {
Database::startLog('testing');
- db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol();
- db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchCol();
+ db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol();
+ db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchCol();
// Trigger a call that does not have file in the backtrace.
- call_user_func_array('db_query', array('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo')))->fetchCol();
+ call_user_func_array('db_query', ['SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo']])->fetchCol();
$queries = Database::getLog('testing', 'default');
@@ -38,11 +38,11 @@ class LoggingTest extends DatabaseTestBase {
function testEnableMultiLogging() {
Database::startLog('testing1');
- db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol();
+ db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol();
Database::startLog('testing2');
- db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchCol();
+ db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchCol();
$queries1 = Database::getLog('testing1');
$queries2 = Database::getLog('testing2');
@@ -62,9 +62,9 @@ class LoggingTest extends DatabaseTestBase {
Database::startLog('testing1');
- db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol();
+ db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol();
- db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'), array('target' => 'replica'));//->fetchCol();
+ db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'], ['target' => 'replica']);//->fetchCol();
$queries1 = Database::getLog('testing1');
@@ -83,14 +83,14 @@ class LoggingTest extends DatabaseTestBase {
function testEnableTargetLoggingNoTarget() {
Database::startLog('testing1');
- db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol();
+ db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol();
// We use "fake" here as a target because any non-existent target will do.
// However, because all of the tests in this class share a single page
// request there is likely to be a target of "replica" from one of the other
// unit tests, so we use a target here that we know with absolute certainty
// does not exist.
- db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'), array('target' => 'fake'))->fetchCol();
+ db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'], ['target' => 'fake'])->fetchCol();
$queries1 = Database::getLog('testing1');
@@ -111,11 +111,11 @@ class LoggingTest extends DatabaseTestBase {
Database::startLog('testing1');
Database::startLog('testing1', 'test2');
- db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol();
+ db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol();
$old_key = db_set_active('test2');
- db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'), array('target' => 'replica'))->fetchCol();
+ db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'], ['target' => 'replica'])->fetchCol();
db_set_active($old_key);
diff --git a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php
index 34b81d0f212..853e5b2f0cd 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php
@@ -20,10 +20,10 @@ class MergeTest extends DatabaseTestBase {
$result = db_merge('test_people')
->key('job', 'Presenter')
- ->fields(array(
+ ->fields([
'age' => 31,
'name' => 'Tiffany',
- ))
+ ])
->execute();
$this->assertEqual($result, Merge::STATUS_INSERT, 'Insert status returned.');
@@ -31,7 +31,7 @@ class MergeTest extends DatabaseTestBase {
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before + 1, $num_records_after, 'Merge inserted properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Presenter'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Presenter'])->fetch();
$this->assertEqual($person->name, 'Tiffany', 'Name set correctly.');
$this->assertEqual($person->age, 31, 'Age set correctly.');
$this->assertEqual($person->job, 'Presenter', 'Job set correctly.');
@@ -45,10 +45,10 @@ class MergeTest extends DatabaseTestBase {
$result = db_merge('test_people')
->key('job', 'Speaker')
- ->fields(array(
+ ->fields([
'age' => 31,
'name' => 'Tiffany',
- ))
+ ])
->execute();
$this->assertEqual($result, Merge::STATUS_UPDATE, 'Update status returned.');
@@ -56,7 +56,7 @@ class MergeTest extends DatabaseTestBase {
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch();
$this->assertEqual($person->name, 'Tiffany', 'Name set correctly.');
$this->assertEqual($person->age, 31, 'Age set correctly.');
$this->assertEqual($person->job, 'Speaker', 'Job set correctly.');
@@ -73,14 +73,14 @@ class MergeTest extends DatabaseTestBase {
db_merge('test_people')
->key('job', 'Speaker')
- ->insertFields(array('age' => 31))
- ->updateFields(array('name' => 'Tiffany'))
+ ->insertFields(['age' => 31])
+ ->updateFields(['name' => 'Tiffany'])
->execute();
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch();
$this->assertEqual($person->name, 'Tiffany', 'Name set correctly.');
$this->assertEqual($person->age, 30, 'Age skipped correctly.');
$this->assertEqual($person->job, 'Speaker', 'Job set correctly.');
@@ -94,19 +94,19 @@ class MergeTest extends DatabaseTestBase {
db_merge('test_people')
->key('job', 'Speaker')
- ->insertFields(array(
+ ->insertFields([
'age' => 31,
'name' => 'Tiffany',
- ))
- ->updateFields(array(
+ ])
+ ->updateFields([
'name' => 'Joe',
- ))
+ ])
->execute();
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch();
$this->assertEqual($person->name, 'Joe', 'Name set correctly.');
$this->assertEqual($person->age, 30, 'Age skipped correctly.');
$this->assertEqual($person->job, 'Speaker', 'Job set correctly.');
@@ -118,7 +118,7 @@ class MergeTest extends DatabaseTestBase {
function testMergeUpdateExpression() {
$num_records_before = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
- $age_before = db_query('SELECT age FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetchField();
+ $age_before = db_query('SELECT age FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetchField();
// This is a very contrived example, as I have no idea why you'd want to
// change age this way, but that's beside the point.
@@ -127,15 +127,15 @@ class MergeTest extends DatabaseTestBase {
// which is what is supposed to happen.
db_merge('test_people')
->key('job', 'Speaker')
- ->fields(array('name' => 'Tiffany'))
- ->insertFields(array('age' => 31))
- ->expression('age', 'age + :age', array(':age' => 4))
+ ->fields(['name' => 'Tiffany'])
+ ->insertFields(['age' => 31])
+ ->expression('age', 'age + :age', [':age' => 4])
->execute();
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch();
$this->assertEqual($person->name, 'Tiffany', 'Name set correctly.');
$this->assertEqual($person->age, $age_before + 4, 'Age updated correctly.');
$this->assertEqual($person->job, 'Speaker', 'Job set correctly.');
@@ -154,7 +154,7 @@ class MergeTest extends DatabaseTestBase {
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before + 1, $num_records_after, 'Merge inserted properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Presenter'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Presenter'])->fetch();
$this->assertEqual($person->name, '', 'Name set correctly.');
$this->assertEqual($person->age, 0, 'Age set correctly.');
$this->assertEqual($person->job, 'Presenter', 'Job set correctly.');
@@ -173,20 +173,20 @@ class MergeTest extends DatabaseTestBase {
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before, $num_records_after, 'Merge skipped properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch();
$this->assertEqual($person->name, 'Meredith', 'Name skipped correctly.');
$this->assertEqual($person->age, 30, 'Age skipped correctly.');
$this->assertEqual($person->job, 'Speaker', 'Job skipped correctly.');
db_merge('test_people')
->key('job', 'Speaker')
- ->insertFields(array('age' => 31))
+ ->insertFields(['age' => 31])
->execute();
$num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before, $num_records_after, 'Merge skipped properly.');
- $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch();
+ $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch();
$this->assertEqual($person->name, 'Meredith', 'Name skipped correctly.');
$this->assertEqual($person->age, 30, 'Age skipped correctly.');
$this->assertEqual($person->job, 'Speaker', 'Job skipped correctly.');
@@ -202,10 +202,10 @@ class MergeTest extends DatabaseTestBase {
// the throw_exception option.
$options['throw_exception'] = FALSE;
db_merge('test_people', $options)
- ->fields(array(
+ ->fields([
'age' => 31,
'name' => 'Tiffany',
- ))
+ ])
->execute();
$this->pass('$options[\'throw_exception\'] is FALSE, no InvalidMergeQueryException thrown.');
}
@@ -217,10 +217,10 @@ class MergeTest extends DatabaseTestBase {
try {
// This query will fail because there is no key field specified.
db_merge('test_people')
- ->fields(array(
+ ->fields([
'age' => 31,
'name' => 'Tiffany',
- ))
+ ])
->execute();
}
catch (InvalidMergeQueryException $e) {
diff --git a/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php b/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php
index b0cdc857faf..5c0239f449b 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php
@@ -15,7 +15,7 @@ class NextIdTest extends KernelTestBase {
* The modules to enable.
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
protected function setUp() {
parent::setUp();
diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
index f84a9c860d7..966f96f667c 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
@@ -13,10 +13,10 @@ class QueryTest extends DatabaseTestBase {
* Tests that we can pass an array of values directly in the query.
*/
function testArraySubstitution() {
- $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(':ages[]' => array(25, 26, 27)))->fetchAll();
+ $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', [':ages[]' => [25, 26, 27]])->fetchAll();
$this->assertEqual(count($names), 3, 'Correct number of names returned');
- $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(':ages[]' => array(25)))->fetchAll();
+ $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', [':ages[]' => [25]])->fetchAll();
$this->assertEqual(count($names), 1, 'Correct number of names returned');
}
@@ -25,7 +25,7 @@ class QueryTest extends DatabaseTestBase {
*/
function testScalarSubstitution() {
try {
- $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(':ages[]' => 25))->fetchAll();
+ $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', [':ages[]' => 25])->fetchAll();
$this->fail('Array placeholder with scalar argument should result in an exception.');
}
catch (\InvalidArgumentException $e) {
@@ -39,12 +39,12 @@ class QueryTest extends DatabaseTestBase {
*/
public function testArrayArgumentsSQLInjection() {
// Attempt SQL injection and verify that it does not work.
- $condition = array(
+ $condition = [
"1 ;INSERT INTO {test} (name) VALUES ('test12345678'); -- " => '',
'1' => '',
- );
+ ];
try {
- db_query("SELECT * FROM {test} WHERE name = :name", array(':name' => $condition))->fetchObject();
+ db_query("SELECT * FROM {test} WHERE name = :name", [':name' => $condition])->fetchObject();
$this->fail('SQL injection attempt via array arguments should result in a database exception.');
}
catch (\InvalidArgumentException $e) {
@@ -101,7 +101,7 @@ class QueryTest extends DatabaseTestBase {
try {
$result = db_select('test', 't')
- ->fields('t', array('name', 'name'))
+ ->fields('t', ['name', 'name'])
->condition('name', 1, $injection)
->execute();
$this->fail('Should not be able to attempt SQL injection via operator.');
@@ -118,7 +118,7 @@ class QueryTest extends DatabaseTestBase {
try {
$result = db_select('test', 't')
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->condition('name', 1, $injection)
->execute();
$this->fail('Should not be able to attempt SQL injection via operator.');
@@ -139,9 +139,9 @@ class QueryTest extends DatabaseTestBase {
$count = db_query('SELECT COUNT(*) >= 3 FROM {test}')->fetchField();
$this->assertEqual((bool) $count, TRUE);
- $count = db_query('SELECT COUNT(*) >= :count FROM {test}', array(
+ $count = db_query('SELECT COUNT(*) >= :count FROM {test}', [
':count' => 3,
- ))->fetchField();
+ ])->fetchField();
$this->assertEqual((bool) $count, TRUE);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php
index 33f315b7cb1..44c25350034 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php
@@ -14,7 +14,7 @@ class RangeQueryTest extends DatabaseTestBase {
*
* @var array
*/
- public static $modules = array('database_test');
+ public static $modules = ['database_test'];
/**
* Confirms that range queries work and return the correct result.
diff --git a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php
index e13bcfe5542..29a966a08ee 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php
@@ -14,7 +14,7 @@ class RegressionTest extends DatabaseTestBase {
*
* @var array
*/
- public static $modules = array('node', 'user');
+ public static $modules = ['node', 'user'];
/**
* Ensures that non-ASCII UTF-8 data is stored in the database properly.
@@ -23,13 +23,13 @@ class RegressionTest extends DatabaseTestBase {
// That's a 255 character UTF-8 string.
$job = str_repeat("é", 255);
db_insert('test')
- ->fields(array(
+ ->fields([
'name' => $this->randomMachineName(),
'age' => 20,
'job' => $job,
- ))->execute();
+ ])->execute();
- $from_database = db_query('SELECT job FROM {test} WHERE job = :job', array(':job' => $job))->fetchField();
+ $from_database = db_query('SELECT job FROM {test} WHERE job = :job', [':job' => $job])->fetchField();
$this->assertIdentical($job, $from_database, 'The database handles UTF-8 characters cleanly.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
index 8641fd3c9cc..346c4ce0eac 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
@@ -26,32 +26,32 @@ class SchemaTest extends KernelTestBase {
*/
function testSchema() {
// Try creating a table.
- $table_specification = array(
+ $table_specification = [
'description' => 'Schema table description may contain "quotes" and could be long—very long indeed.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'int',
'default' => NULL,
- ),
- 'test_field' => array(
+ ],
+ 'test_field' => [
'type' => 'int',
'not null' => TRUE,
'description' => 'Schema table description may contain "quotes" and could be long—very long indeed. There could be "multiple quoted regions".',
- ),
- 'test_field_string' => array(
+ ],
+ 'test_field_string' => [
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
'default' => "'\"funky default'\"",
'description' => 'Schema column description for string.',
- ),
- 'test_field_string_ascii' => array(
+ ],
+ 'test_field_string_ascii' => [
'type' => 'varchar_ascii',
'length' => 255,
'description' => 'Schema column description for ASCII string.',
- ),
- ),
- );
+ ],
+ ],
+ ];
db_create_table('test_table', $table_specification);
// Assert that the table exists.
@@ -95,7 +95,7 @@ class SchemaTest extends KernelTestBase {
$index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
$this->assertIdentical($index_exists, FALSE, 'Fake index does not exists');
// Add index.
- db_add_index('test_table', 'test_field', array('test_field'), $table_specification);
+ db_add_index('test_table', 'test_field', ['test_field'], $table_specification);
// Test for created index and test for the boolean result of indexExists().
$index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
$this->assertIdentical($index_exists, TRUE, 'Index created.');
@@ -123,13 +123,13 @@ class SchemaTest extends KernelTestBase {
// Recreate the table.
db_create_table('test_table', $table_specification);
db_field_set_default('test_table', 'test_field', 0);
- db_add_field('test_table', 'test_serial', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Added column description.'));
+ db_add_field('test_table', 'test_serial', ['type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Added column description.']);
// Assert that the column comment has been set.
$this->checkSchemaComment('Added column description.', 'test_table', 'test_serial');
// Change the new field to a serial column.
- db_change_field('test_table', 'test_serial', 'test_serial', array('type' => 'serial', 'not null' => TRUE, 'description' => 'Changed column description.'), array('primary key' => array('test_serial')));
+ db_change_field('test_table', 'test_serial', 'test_serial', ['type' => 'serial', 'not null' => TRUE, 'description' => 'Changed column description.'], ['primary key' => ['test_serial']]);
// Assert that the column comment has been set.
$this->checkSchemaComment('Changed column description.', 'test_table', 'test_serial');
@@ -145,22 +145,22 @@ class SchemaTest extends KernelTestBase {
// Test renaming of keys and constraints.
db_drop_table('test_table');
- $table_specification = array(
- 'fields' => array(
- 'id' => array(
+ $table_specification = [
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- 'test_field' => array(
+ ],
+ 'test_field' => [
'type' => 'int',
'default' => 0,
- ),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'test_field' => array('test_field'),
- ),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'test_field' => ['test_field'],
+ ],
+ ];
db_create_table('test_table', $table_specification);
// Tests for indexes are Database specific.
@@ -215,18 +215,18 @@ class SchemaTest extends KernelTestBase {
}
// Use database specific data type and ensure that table is created.
- $table_specification = array(
+ $table_specification = [
'description' => 'Schema table description.',
- 'fields' => array(
- 'timestamp' => array(
+ 'fields' => [
+ 'timestamp' => [
'mysql_type' => 'timestamp',
'pgsql_type' => 'timestamp',
'sqlite_type' => 'datetime',
'not null' => FALSE,
'default' => NULL,
- ),
- ),
- );
+ ],
+ ],
+ ];
try {
db_create_table('test_timestamp', $table_specification);
}
@@ -244,52 +244,52 @@ class SchemaTest extends KernelTestBase {
if (Database::getConnection()->databaseType() != 'mysql') {
return;
}
- $table_specification = array(
- 'fields' => array(
- 'id' => array(
+ $table_specification = [
+ 'fields' => [
+ 'id' => [
'type' => 'int',
'default' => NULL,
- ),
- 'test_field_text' => array(
+ ],
+ 'test_field_text' => [
'type' => 'text',
'not null' => TRUE,
- ),
- 'test_field_string_long' => array(
+ ],
+ 'test_field_string_long' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
- ),
- 'test_field_string_ascii_long' => array(
+ ],
+ 'test_field_string_ascii_long' => [
'type' => 'varchar_ascii',
'length' => 255,
- ),
- 'test_field_string_short' => array(
+ ],
+ 'test_field_string_short' => [
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
- ),
- ),
- 'indexes' => array(
- 'test_regular' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'test_regular' => [
'test_field_text',
'test_field_string_long',
'test_field_string_ascii_long',
'test_field_string_short',
- ),
- 'test_length' => array(
- array('test_field_text', 128),
- array('test_field_string_long', 128),
- array('test_field_string_ascii_long', 128),
- array('test_field_string_short', 128),
- ),
- 'test_mixed' => array(
- array('test_field_text', 200),
+ ],
+ 'test_length' => [
+ ['test_field_text', 128],
+ ['test_field_string_long', 128],
+ ['test_field_string_ascii_long', 128],
+ ['test_field_string_short', 128],
+ ],
+ 'test_mixed' => [
+ ['test_field_text', 200],
'test_field_string_long',
- array('test_field_string_ascii_long', 200),
+ ['test_field_string_ascii_long', 200],
'test_field_string_short',
- ),
- ),
- );
+ ],
+ ],
+ ];
db_create_table('test_table_index_length', $table_specification);
$schema_object = Database::getConnection()->schema();
@@ -331,29 +331,29 @@ class SchemaTest extends KernelTestBase {
// Get index information.
$results = db_query('SHOW INDEX FROM {test_table_index_length}');
- $expected_lengths = array(
- 'test_regular' => array(
+ $expected_lengths = [
+ 'test_regular' => [
'test_field_text' => 191,
'test_field_string_long' => 191,
'test_field_string_ascii_long' => NULL,
'test_field_string_short' => NULL,
- ),
- 'test_length' => array(
+ ],
+ 'test_length' => [
'test_field_text' => 128,
'test_field_string_long' => 128,
'test_field_string_ascii_long' => 128,
'test_field_string_short' => NULL,
- ),
- 'test_mixed' => array(
+ ],
+ 'test_mixed' => [
'test_field_text' => 191,
'test_field_string_long' => 191,
'test_field_string_ascii_long' => 200,
'test_field_string_short' => NULL,
- ),
- 'test_separate' => array(
+ ],
+ 'test_separate' => [
'test_field_text' => 191,
- ),
- );
+ ],
+ ];
// Count the number of columns defined in the indexes.
$column_count = 0;
@@ -382,7 +382,7 @@ class SchemaTest extends KernelTestBase {
function tryInsert($table = 'test_table') {
try {
db_insert($table)
- ->fields(array('id' => mt_rand(10, 20)))
+ ->fields(['id' => mt_rand(10, 20)])
->execute();
return TRUE;
}
@@ -419,18 +419,18 @@ class SchemaTest extends KernelTestBase {
function testUnsignedColumns() {
// First create the table with just a serial column.
$table_name = 'unsigned_table';
- $table_spec = array(
- 'fields' => array('serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE)),
- 'primary key' => array('serial_column'),
- );
+ $table_spec = [
+ 'fields' => ['serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE]],
+ 'primary key' => ['serial_column'],
+ ];
db_create_table($table_name, $table_spec);
// Now set up columns for the other types.
- $types = array('int', 'float', 'numeric');
+ $types = ['int', 'float', 'numeric'];
foreach ($types as $type) {
- $column_spec = array('type' => $type, 'unsigned' => TRUE);
+ $column_spec = ['type' => $type, 'unsigned' => TRUE];
if ($type == 'numeric') {
- $column_spec += array('precision' => 10, 'scale' => 0);
+ $column_spec += ['precision' => 10, 'scale' => 0];
}
$column_name = $type . '_column';
$table_spec['fields'][$column_name] = $column_spec;
@@ -439,8 +439,8 @@ class SchemaTest extends KernelTestBase {
// Finally, check each column and try to insert invalid values into them.
foreach ($table_spec['fields'] as $column_name => $column_spec) {
- $this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', array('@type' => $column_spec['type'])));
- $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type'])));
+ $this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', ['@type' => $column_spec['type']]));
+ $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', ['@type' => $column_spec['type']]));
}
}
@@ -458,7 +458,7 @@ class SchemaTest extends KernelTestBase {
function tryUnsignedInsert($table_name, $column_name) {
try {
db_insert($table_name)
- ->fields(array($column_name => -1))
+ ->fields([$column_name => -1])
->execute();
return TRUE;
}
@@ -472,20 +472,20 @@ class SchemaTest extends KernelTestBase {
*/
function testSchemaAddField() {
// Test varchar types.
- foreach (array(1, 32, 128, 256, 512) as $length) {
- $base_field_spec = array(
+ foreach ([1, 32, 128, 256, 512] as $length) {
+ $base_field_spec = [
'type' => 'varchar',
'length' => $length,
- );
- $variations = array(
- array('not null' => FALSE),
- array('not null' => FALSE, 'default' => '7'),
- array('not null' => FALSE, 'default' => substr('"thing"', 0, $length)),
- array('not null' => FALSE, 'default' => substr("\"'hing", 0, $length)),
- array('not null' => TRUE, 'initial' => 'd'),
- array('not null' => FALSE, 'default' => NULL),
- array('not null' => TRUE, 'initial' => 'd', 'default' => '7'),
- );
+ ];
+ $variations = [
+ ['not null' => FALSE],
+ ['not null' => FALSE, 'default' => '7'],
+ ['not null' => FALSE, 'default' => substr('"thing"', 0, $length)],
+ ['not null' => FALSE, 'default' => substr("\"'hing", 0, $length)],
+ ['not null' => TRUE, 'initial' => 'd'],
+ ['not null' => FALSE, 'default' => NULL],
+ ['not null' => TRUE, 'initial' => 'd', 'default' => '7'],
+ ];
foreach ($variations as $variation) {
$field_spec = $variation + $base_field_spec;
@@ -494,19 +494,19 @@ class SchemaTest extends KernelTestBase {
}
// Test int and float types.
- foreach (array('int', 'float') as $type) {
- foreach (array('tiny', 'small', 'medium', 'normal', 'big') as $size) {
- $base_field_spec = array(
+ foreach (['int', 'float'] as $type) {
+ foreach (['tiny', 'small', 'medium', 'normal', 'big'] as $size) {
+ $base_field_spec = [
'type' => $type,
'size' => $size,
- );
- $variations = array(
- array('not null' => FALSE),
- array('not null' => FALSE, 'default' => 7),
- array('not null' => TRUE, 'initial' => 1),
- array('not null' => TRUE, 'initial' => 1, 'default' => 7),
- array('not null' => TRUE, 'initial_from_field' => 'serial_column'),
- );
+ ];
+ $variations = [
+ ['not null' => FALSE],
+ ['not null' => FALSE, 'default' => 7],
+ ['not null' => TRUE, 'initial' => 1],
+ ['not null' => TRUE, 'initial' => 1, 'default' => 7],
+ ['not null' => TRUE, 'initial_from_field' => 'serial_column'],
+ ];
foreach ($variations as $variation) {
$field_spec = $variation + $base_field_spec;
@@ -516,25 +516,25 @@ class SchemaTest extends KernelTestBase {
}
// Test numeric types.
- foreach (array(1, 5, 10, 40, 65) as $precision) {
- foreach (array(0, 2, 10, 30) as $scale) {
+ foreach ([1, 5, 10, 40, 65] as $precision) {
+ foreach ([0, 2, 10, 30] as $scale) {
// Skip combinations where precision is smaller than scale.
if ($precision <= $scale) {
continue;
}
- $base_field_spec = array(
+ $base_field_spec = [
'type' => 'numeric',
'scale' => $scale,
'precision' => $precision,
- );
- $variations = array(
- array('not null' => FALSE),
- array('not null' => FALSE, 'default' => 7),
- array('not null' => TRUE, 'initial' => 1),
- array('not null' => TRUE, 'initial' => 1, 'default' => 7),
- array('not null' => TRUE, 'initial_from_field' => 'serial_column'),
- );
+ ];
+ $variations = [
+ ['not null' => FALSE],
+ ['not null' => FALSE, 'default' => 7],
+ ['not null' => TRUE, 'initial' => 1],
+ ['not null' => TRUE, 'initial' => 1, 'default' => 7],
+ ['not null' => TRUE, 'initial_from_field' => 'serial_column'],
+ ];
foreach ($variations as $variation) {
$field_spec = $variation + $base_field_spec;
@@ -556,15 +556,15 @@ class SchemaTest extends KernelTestBase {
protected function assertFieldAdditionRemoval($field_spec) {
// Try creating the field on a new table.
$table_name = 'test_table_' . ($this->counter++);
- $table_spec = array(
- 'fields' => array(
- 'serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+ $table_spec = [
+ 'fields' => [
+ 'serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE],
'test_field' => $field_spec,
- ),
- 'primary key' => array('serial_column'),
- );
+ ],
+ 'primary key' => ['serial_column'],
+ ];
db_create_table($table_name, $table_spec);
- $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
+ $this->pass(format_string('Table %table created.', ['%table' => $table_name]));
// Check the characteristics of the field.
$this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
@@ -574,24 +574,24 @@ class SchemaTest extends KernelTestBase {
// Try adding a field to an existing table.
$table_name = 'test_table_' . ($this->counter++);
- $table_spec = array(
- 'fields' => array(
- 'serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
- ),
- 'primary key' => array('serial_column'),
- );
+ $table_spec = [
+ 'fields' => [
+ 'serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE],
+ ],
+ 'primary key' => ['serial_column'],
+ ];
db_create_table($table_name, $table_spec);
- $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
+ $this->pass(format_string('Table %table created.', ['%table' => $table_name]));
// Insert some rows to the table to test the handling of initial values.
for ($i = 0; $i < 3; $i++) {
db_insert($table_name)
- ->useDefaults(array('serial_column'))
+ ->useDefaults(['serial_column'])
->execute();
}
db_add_field($table_name, 'test_field', $field_spec);
- $this->pass(format_string('Column %column created.', array('%column' => 'test_field')));
+ $this->pass(format_string('Column %column created.', ['%column' => 'test_field']));
// Check the characteristics of the field.
$this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
@@ -614,7 +614,7 @@ class SchemaTest extends KernelTestBase {
if (isset($field_spec['initial'])) {
// There should be no row with a value different then $field_spec['initial'].
$count = db_select($table_name)
- ->fields($table_name, array('serial_column'))
+ ->fields($table_name, ['serial_column'])
->condition($field_name, $field_spec['initial'], '<>')
->countQuery()
->execute()
@@ -627,7 +627,7 @@ class SchemaTest extends KernelTestBase {
// There should be no row with a value different than
// $field_spec['initial_from_field'].
$count = db_select($table_name)
- ->fields($table_name, array('serial_column'))
+ ->fields($table_name, ['serial_column'])
->where($table_name . '.' . $field_spec['initial_from_field'] . ' <> ' . $table_name . '.' . $field_name)
->countQuery()
->execute()
@@ -639,10 +639,10 @@ class SchemaTest extends KernelTestBase {
if (isset($field_spec['default'])) {
// Try inserting a row, and check the resulting value of the new column.
$id = db_insert($table_name)
- ->useDefaults(array('serial_column'))
+ ->useDefaults(['serial_column'])
->execute();
$field_value = db_select($table_name)
- ->fields($table_name, array($field_name))
+ ->fields($table_name, [$field_name])
->condition('serial_column', $id)
->execute()
->fetchField();
@@ -654,14 +654,14 @@ class SchemaTest extends KernelTestBase {
* Tests changing columns between types.
*/
function testSchemaChangeField() {
- $field_specs = array(
- array('type' => 'int', 'size' => 'normal', 'not null' => FALSE),
- array('type' => 'int', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 17),
- array('type' => 'float', 'size' => 'normal', 'not null' => FALSE),
- array('type' => 'float', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 7.3),
- array('type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => FALSE),
- array('type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => TRUE, 'initial' => 1, 'default' => 7),
- );
+ $field_specs = [
+ ['type' => 'int', 'size' => 'normal', 'not null' => FALSE],
+ ['type' => 'int', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 17],
+ ['type' => 'float', 'size' => 'normal', 'not null' => FALSE],
+ ['type' => 'float', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 7.3],
+ ['type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => FALSE],
+ ['type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => TRUE, 'initial' => 1, 'default' => 7],
+ ];
foreach ($field_specs as $i => $old_spec) {
foreach ($field_specs as $j => $new_spec) {
@@ -673,12 +673,12 @@ class SchemaTest extends KernelTestBase {
}
}
- $field_specs = array(
- array('type' => 'varchar_ascii', 'length' => '255'),
- array('type' => 'varchar', 'length' => '255'),
- array('type' => 'text'),
- array('type' => 'blob', 'size' => 'big'),
- );
+ $field_specs = [
+ ['type' => 'varchar_ascii', 'length' => '255'],
+ ['type' => 'varchar', 'length' => '255'],
+ ['type' => 'text'],
+ ['type' => 'blob', 'size' => 'big'],
+ ];
foreach ($field_specs as $i => $old_spec) {
foreach ($field_specs as $j => $new_spec) {
@@ -705,15 +705,15 @@ class SchemaTest extends KernelTestBase {
*/
protected function assertFieldChange($old_spec, $new_spec, $test_data = NULL) {
$table_name = 'test_table_' . ($this->counter++);
- $table_spec = array(
- 'fields' => array(
- 'serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+ $table_spec = [
+ 'fields' => [
+ 'serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE],
'test_field' => $old_spec,
- ),
- 'primary key' => array('serial_column'),
- );
+ ],
+ 'primary key' => ['serial_column'],
+ ];
db_create_table($table_name, $table_spec);
- $this->pass(format_string('Table %table created.', array('%table' => $table_name)));
+ $this->pass(format_string('Table %table created.', ['%table' => $table_name]));
// Check the characteristics of the field.
$this->assertFieldCharacteristics($table_name, 'test_field', $old_spec);
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
index f10710053e7..94ee755ab2f 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
@@ -19,7 +19,7 @@ class SelectComplexTest extends DatabaseTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'node_access_test', 'field');
+ public static $modules = ['system', 'user', 'node_access_test', 'field'];
/**
* Tests simple JOIN statements.
@@ -83,7 +83,7 @@ class SelectComplexTest extends DatabaseTestBase {
$num_records = 0;
$last_count = 0;
- $records = array();
+ $records = [];
foreach ($result as $record) {
$num_records++;
$this->assertTrue($record->$count_field >= $last_count, 'Results returned in correct order.');
@@ -91,16 +91,16 @@ class SelectComplexTest extends DatabaseTestBase {
$records[$record->$task_field] = $record->$count_field;
}
- $correct_results = array(
+ $correct_results = [
'eat' => 1,
'sleep' => 2,
'code' => 1,
'found new band' => 1,
'perform at superbowl' => 1,
- );
+ ];
foreach ($correct_results as $task => $count) {
- $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", array('@task' => $task)));
+ $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", ['@task' => $task]));
}
$this->assertEqual($num_records, 6, 'Returned the correct number of total rows.');
@@ -120,7 +120,7 @@ class SelectComplexTest extends DatabaseTestBase {
$num_records = 0;
$last_count = 0;
- $records = array();
+ $records = [];
foreach ($result as $record) {
$num_records++;
$this->assertTrue($record->$count_field >= 2, 'Record has the minimum count.');
@@ -129,12 +129,12 @@ class SelectComplexTest extends DatabaseTestBase {
$records[$record->$task_field] = $record->$count_field;
}
- $correct_results = array(
+ $correct_results = [
'sleep' => 2,
- );
+ ];
foreach ($correct_results as $task => $count) {
- $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", array('@task' => $task)));
+ $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", ['@task' => $task]));
}
$this->assertEqual($num_records, 1, 'Returned the correct number of total rows.');
@@ -256,7 +256,7 @@ class SelectComplexTest extends DatabaseTestBase {
// number of records, which in this case happens to be 4 (there are four
// records in the {test} table).
$query = db_select('test');
- $query->fields('test', array('fail'));
+ $query->fields('test', ['fail']);
$this->assertEqual(4, $query->countQuery()->execute()->fetchField(), 'Count Query removed fields');
$query = db_select('test');
@@ -344,7 +344,7 @@ class SelectComplexTest extends DatabaseTestBase {
'mail' => $this->randomMachineName() . '@example.com',
]);
- $query = db_select('test_task', 'tt', array('target' => 'replica'));
+ $query = db_select('test_task', 'tt', ['target' => 'replica']);
$query->addExpression('tt.pid + 1', 'abc');
$query->condition('priority', 1, '>');
$query->condition('priority', 100, '<');
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php
index c9e199be902..53a311c6ca9 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php
@@ -43,12 +43,12 @@ class SelectOrderedTest extends DatabaseTestBase {
$result = $query->execute();
$num_records = 0;
- $expected = array(
- array('Ringo', 28, 'Drummer'),
- array('John', 25, 'Singer'),
- array('George', 27, 'Singer'),
- array('Paul', 26, 'Songwriter'),
- );
+ $expected = [
+ ['Ringo', 28, 'Drummer'],
+ ['John', 25, 'Singer'],
+ ['George', 27, 'Singer'],
+ ['Paul', 26, 'Songwriter'],
+ ];
$results = $result->fetchAll(\PDO::FETCH_NUM);
foreach ($expected as $k => $record) {
$num_records++;
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php
index 98849bbaaab..d5f02375f3e 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php
@@ -210,18 +210,18 @@ class SelectSubqueryTest extends DatabaseTestBase {
function testExistsSubquerySelect() {
// Put George into {test_people}.
db_insert('test_people')
- ->fields(array(
+ ->fields([
'name' => 'George',
'age' => 27,
'job' => 'Singer',
- ))
+ ])
->execute();
// Base query to {test}.
$query = db_select('test', 't')
- ->fields('t', array('name'));
+ ->fields('t', ['name']);
// Subquery to {test_people}.
$subquery = db_select('test_people', 'tp')
- ->fields('tp', array('name'))
+ ->fields('tp', ['name'])
->where('tp.name = t.name');
$query->exists($subquery);
$result = $query->execute();
@@ -240,19 +240,19 @@ class SelectSubqueryTest extends DatabaseTestBase {
function testNotExistsSubquerySelect() {
// Put George into {test_people}.
db_insert('test_people')
- ->fields(array(
+ ->fields([
'name' => 'George',
'age' => 27,
'job' => 'Singer',
- ))
+ ])
->execute();
// Base query to {test}.
$query = db_select('test', 't')
- ->fields('t', array('name'));
+ ->fields('t', ['name']);
// Subquery to {test_people}.
$subquery = db_select('test_people', 'tp')
- ->fields('tp', array('name'))
+ ->fields('tp', ['name'])
->where('tp.name = t.name');
$query->notExists($subquery);
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
index b3eef546301..038224e9c0c 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
@@ -163,7 +163,7 @@ class SelectTest extends DatabaseTestBase {
*/
function testSimpleSelectMultipleFields() {
$record = db_select('test')
- ->fields('test', array('id', 'name', 'age', 'job'))
+ ->fields('test', ['id', 'name', 'age', 'job'])
->condition('age', 27)
->execute()->fetchObject();
@@ -211,7 +211,7 @@ class SelectTest extends DatabaseTestBase {
$this->ensureSampleDataNull();
$names = db_select('test_null', 'tn')
- ->fields('tn', array('name'))
+ ->fields('tn', ['name'])
->condition('age', NULL)
->execute()->fetchCol();
@@ -225,7 +225,7 @@ class SelectTest extends DatabaseTestBase {
$this->ensureSampleDataNull();
$names = db_select('test_null', 'tn')
- ->fields('tn', array('name'))
+ ->fields('tn', ['name'])
->isNull('age')
->execute()->fetchCol();
@@ -240,7 +240,7 @@ class SelectTest extends DatabaseTestBase {
$this->ensureSampleDataNull();
$names = db_select('test_null', 'tn')
- ->fields('tn', array('name'))
+ ->fields('tn', ['name'])
->isNotNull('tn.age')
->orderBy('name')
->execute()->fetchCol();
@@ -258,11 +258,11 @@ class SelectTest extends DatabaseTestBase {
*/
function testUnion() {
$query_1 = db_select('test', 't')
- ->fields('t', array('name'))
- ->condition('age', array(27, 28), 'IN');
+ ->fields('t', ['name'])
+ ->condition('age', [27, 28], 'IN');
$query_2 = db_select('test', 't')
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->condition('age', 28);
$query_1->union($query_2);
@@ -281,11 +281,11 @@ class SelectTest extends DatabaseTestBase {
*/
function testUnionAll() {
$query_1 = db_select('test', 't')
- ->fields('t', array('name'))
- ->condition('age', array(27, 28), 'IN');
+ ->fields('t', ['name'])
+ ->condition('age', [27, 28], 'IN');
$query_2 = db_select('test', 't')
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->condition('age', 28);
$query_1->union($query_2, 'ALL');
@@ -305,11 +305,11 @@ class SelectTest extends DatabaseTestBase {
*/
function testUnionCount() {
$query_1 = db_select('test', 't')
- ->fields('t', array('name', 'age'))
- ->condition('age', array(27, 28), 'IN');
+ ->fields('t', ['name', 'age'])
+ ->condition('age', [27, 28], 'IN');
$query_2 = db_select('test', 't')
- ->fields('t', array('name', 'age'))
+ ->fields('t', ['name', 'age'])
->condition('age', 28);
$query_1->union($query_2, 'ALL');
@@ -328,12 +328,12 @@ class SelectTest extends DatabaseTestBase {
function testUnionOrder() {
// This gives George and Ringo.
$query_1 = db_select('test', 't')
- ->fields('t', array('name'))
- ->condition('age', array(27, 28), 'IN');
+ ->fields('t', ['name'])
+ ->condition('age', [27, 28], 'IN');
// This gives Paul.
$query_2 = db_select('test', 't')
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->condition('age', 26);
$query_1->union($query_2);
@@ -357,12 +357,12 @@ class SelectTest extends DatabaseTestBase {
function testUnionOrderLimit() {
// This gives George and Ringo.
$query_1 = db_select('test', 't')
- ->fields('t', array('name'))
- ->condition('age', array(27, 28), 'IN');
+ ->fields('t', ['name'])
+ ->condition('age', [27, 28], 'IN');
// This gives Paul.
$query_2 = db_select('test', 't')
- ->fields('t', array('name'))
+ ->fields('t', ['name'])
->condition('age', 26);
$query_1->union($query_2);
@@ -401,13 +401,13 @@ class SelectTest extends DatabaseTestBase {
// after shuffling it (in other words, nearly impossible).
$number_of_items = 52;
while (db_query("SELECT MAX(id) FROM {test}")->fetchField() < $number_of_items) {
- db_insert('test')->fields(array('name' => $this->randomMachineName()))->execute();
+ db_insert('test')->fields(['name' => $this->randomMachineName()])->execute();
}
// First select the items in order and make sure we get an ordered list.
$expected_ids = range(1, $number_of_items);
$ordered_ids = db_select('test', 't')
- ->fields('t', array('id'))
+ ->fields('t', ['id'])
->range(0, $number_of_items)
->orderBy('id')
->execute()
@@ -418,7 +418,7 @@ class SelectTest extends DatabaseTestBase {
// expect this to contain a differently ordered version of the original
// result.
$randomized_ids = db_select('test', 't')
- ->fields('t', array('id'))
+ ->fields('t', ['id'])
->range(0, $number_of_items)
->orderRandom()
->execute()
@@ -431,7 +431,7 @@ class SelectTest extends DatabaseTestBase {
// Now perform the exact same query again, and make sure the order is
// different.
$randomized_ids_second_set = db_select('test', 't')
- ->fields('t', array('id'))
+ ->fields('t', ['id'])
->range(0, $number_of_items)
->orderRandom()
->execute()
@@ -447,24 +447,24 @@ class SelectTest extends DatabaseTestBase {
*/
public function testRegexCondition() {
- $test_groups[] = array(
+ $test_groups[] = [
'regex' => 'hn$',
- 'expected' => array(
+ 'expected' => [
'John',
- ),
- );
- $test_groups[] = array(
+ ],
+ ];
+ $test_groups[] = [
'regex' => '^Pau',
- 'expected' => array(
+ 'expected' => [
'Paul',
- ),
- );
- $test_groups[] = array(
+ ],
+ ];
+ $test_groups[] = [
'regex' => 'Ringo|George',
- 'expected' => array(
+ 'expected' => [
'Ringo', 'George',
- ),
- );
+ ],
+ ];
$database = $this->container->get('database');
@@ -480,25 +480,25 @@ class SelectTest extends DatabaseTestBase {
// Ensure that filter by "#" still works due to the quoting.
$database->insert('test')
- ->fields(array(
+ ->fields([
'name' => 'Pete',
'age' => 26,
'job' => '#Drummer',
- ))
+ ])
->execute();
- $test_groups = array();
- $test_groups[] = array(
+ $test_groups = [];
+ $test_groups[] = [
'regex' => '#Drummer',
- 'expected' => array(
+ 'expected' => [
'Pete',
- ),
- );
- $test_groups[] = array(
+ ],
+ ];
+ $test_groups[] = [
'regex' => '#Singer',
- 'expected' => array(
- ),
- );
+ 'expected' => [
+ ],
+ ];
foreach ($test_groups as $test_group) {
$query = $database->select('test', 't');
@@ -570,7 +570,7 @@ class SelectTest extends DatabaseTestBase {
try {
db_select('test', 't')
->fields('t')
- ->condition('age', array(), 'IN')
+ ->condition('age', [], 'IN')
->execute();
$this->fail('Expected exception not thrown');
@@ -582,7 +582,7 @@ class SelectTest extends DatabaseTestBase {
try {
db_select('test', 't')
->fields('t')
- ->condition('age', array(), 'NOT IN')
+ ->condition('age', [], 'NOT IN')
->execute();
$this->fail('Expected exception not thrown');
diff --git a/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php
index 611b2460b71..0f9f6d463b6 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php
@@ -111,10 +111,10 @@ class TaggingTest extends DatabaseTestBase {
$query->addField('test', 'name');
$query->addField('test', 'age', 'age');
- $data = array(
+ $data = [
'a' => 'A',
'b' => 'B',
- );
+ ];
$query->addMetaData('test', $data);
diff --git a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
index d060f4de7ae..862b3e646b5 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
@@ -58,10 +58,10 @@ class TransactionTest extends DatabaseTestBase {
// Insert a single row into the testing table.
db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'David' . $suffix,
'age' => '24',
- ))
+ ])
->execute();
$this->assertTrue($connection->inTransaction(), 'In transaction before calling nested transaction.');
@@ -108,25 +108,25 @@ class TransactionTest extends DatabaseTestBase {
// Insert a single row into the testing table.
db_insert('test')
- ->fields(array(
+ ->fields([
'name' => 'Daniel' . $suffix,
'age' => '19',
- ))
+ ])
->execute();
$this->assertTrue($connection->inTransaction(), 'In transaction inside nested transaction.');
if ($ddl_statement) {
- $table = array(
- 'fields' => array(
- 'id' => array(
+ $table = [
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ ];
db_create_table('database_test_1', $table);
$this->assertTrue($connection->inTransaction(), 'In transaction inside nested transaction.');
@@ -157,9 +157,9 @@ class TransactionTest extends DatabaseTestBase {
// Neither of the rows we inserted in the two transaction layers
// should be present in the tables post-rollback.
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DavidB'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DavidB'])->fetchField();
$this->assertNotIdentical($saved_age, '24', 'Cannot retrieve DavidB row after commit.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DanielB'])->fetchField();
$this->assertNotIdentical($saved_age, '19', 'Cannot retrieve DanielB row after commit.');
}
catch (\Exception $e) {
@@ -183,9 +183,9 @@ class TransactionTest extends DatabaseTestBase {
// Because our current database claims to not support transactions,
// the inserted rows should be present despite the attempt to roll back.
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DavidB'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DavidB'])->fetchField();
$this->assertIdentical($saved_age, '24', 'DavidB not rolled back, since transactions are not supported.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DanielB'])->fetchField();
$this->assertIdentical($saved_age, '19', 'DanielB not rolled back, since transactions are not supported.');
}
catch (\Exception $e) {
@@ -205,9 +205,9 @@ class TransactionTest extends DatabaseTestBase {
$this->transactionOuterLayer('A');
// Because we committed, both of the inserted rows should be present.
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DavidA'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DavidA'])->fetchField();
$this->assertIdentical($saved_age, '24', 'Can retrieve DavidA row after commit.');
- $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielA'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DanielA'])->fetchField();
$this->assertIdentical($saved_age, '19', 'Can retrieve DanielA row after commit.');
}
catch (\Exception $e) {
@@ -311,9 +311,9 @@ class TransactionTest extends DatabaseTestBase {
*/
protected function insertRow($name) {
db_insert('test')
- ->fields(array(
+ ->fields([
'name' => $name,
- ))
+ ])
->execute();
}
@@ -322,16 +322,16 @@ class TransactionTest extends DatabaseTestBase {
*/
protected function executeDDLStatement() {
static $count = 0;
- $table = array(
- 'fields' => array(
- 'id' => array(
+ $table = [
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ ];
db_create_table('database_test_' . ++$count, $table);
}
@@ -353,9 +353,9 @@ class TransactionTest extends DatabaseTestBase {
*/
function assertRowPresent($name, $message = NULL) {
if (!isset($message)) {
- $message = format_string('Row %name is present.', array('%name' => $name));
+ $message = format_string('Row %name is present.', ['%name' => $name]);
}
- $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', array(':name' => $name))->fetchField();
+ $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', [':name' => $name])->fetchField();
return $this->assertTrue($present, $message);
}
@@ -369,9 +369,9 @@ class TransactionTest extends DatabaseTestBase {
*/
function assertRowAbsent($name, $message = NULL) {
if (!isset($message)) {
- $message = format_string('Row %name is absent.', array('%name' => $name));
+ $message = format_string('Row %name is absent.', ['%name' => $name]);
}
- $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', array(':name' => $name))->fetchField();
+ $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', [':name' => $name])->fetchField();
return $this->assertFalse($present, $message);
}
@@ -498,7 +498,7 @@ class TransactionTest extends DatabaseTestBase {
// Test a failed query using the query() method.
try {
- $connection->query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'David'))->fetchField();
+ $connection->query('SELECT age FROM {test} WHERE name = :name', [':name' => 'David'])->fetchField();
$this->fail('Using the query method failed.');
}
catch (\Exception $e) {
@@ -594,16 +594,16 @@ class TransactionTest extends DatabaseTestBase {
// Create the missing schema and insert a row.
$this->installSchema('database_test', ['test']);
$connection->insert('test')
- ->fields(array(
+ ->fields([
'name' => 'David',
'age' => '24',
- ))
+ ])
->execute();
// Commit the transaction.
unset($transaction);
- $saved_age = $connection->query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'David'))->fetchField();
+ $saved_age = $connection->query('SELECT age FROM {test} WHERE name = :name', [':name' => 'David'])->fetchField();
$this->assertEqual('24', $saved_age);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php
index e4289e6187f..85521b1cc0b 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php
@@ -16,7 +16,7 @@ class UpdateComplexTest extends DatabaseTestBase {
*/
function testOrConditionUpdate() {
$update = db_update('test')
- ->fields(array('job' => 'Musician'))
+ ->fields(['job' => 'Musician'])
->condition((new Condition('OR'))
->condition('name', 'John')
->condition('name', 'Paul')
@@ -24,7 +24,7 @@ class UpdateComplexTest extends DatabaseTestBase {
$num_updated = $update->execute();
$this->assertIdentical($num_updated, 2, 'Updated 2 records.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}
@@ -33,12 +33,12 @@ class UpdateComplexTest extends DatabaseTestBase {
*/
function testInConditionUpdate() {
$num_updated = db_update('test')
- ->fields(array('job' => 'Musician'))
- ->condition('name', array('John', 'Paul'), 'IN')
+ ->fields(['job' => 'Musician'])
+ ->condition('name', ['John', 'Paul'], 'IN')
->execute();
$this->assertIdentical($num_updated, 2, 'Updated 2 records.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}
@@ -49,12 +49,12 @@ class UpdateComplexTest extends DatabaseTestBase {
// The o is lowercase in the 'NoT IN' operator, to make sure the operators
// work in mixed case.
$num_updated = db_update('test')
- ->fields(array('job' => 'Musician'))
- ->condition('name', array('John', 'Paul', 'George'), 'NoT IN')
+ ->fields(['job' => 'Musician'])
+ ->condition('name', ['John', 'Paul', 'George'], 'NoT IN')
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '1', 'Updated fields successfully.');
}
@@ -63,12 +63,12 @@ class UpdateComplexTest extends DatabaseTestBase {
*/
function testBetweenConditionUpdate() {
$num_updated = db_update('test')
- ->fields(array('job' => 'Musician'))
- ->condition('age', array(25, 26), 'BETWEEN')
+ ->fields(['job' => 'Musician'])
+ ->condition('age', [25, 26], 'BETWEEN')
->execute();
$this->assertIdentical($num_updated, 2, 'Updated 2 records.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}
@@ -77,12 +77,12 @@ class UpdateComplexTest extends DatabaseTestBase {
*/
function testLikeConditionUpdate() {
$num_updated = db_update('test')
- ->fields(array('job' => 'Musician'))
+ ->fields(['job' => 'Musician'])
->condition('name', '%ge%', 'LIKE')
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '1', 'Updated fields successfully.');
}
@@ -90,18 +90,18 @@ class UpdateComplexTest extends DatabaseTestBase {
* Tests UPDATE with expression values.
*/
function testUpdateExpression() {
- $before_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField();
+ $before_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField();
$num_updated = db_update('test')
->condition('name', 'Ringo')
- ->fields(array('job' => 'Musician'))
- ->expression('age', 'age + :age', array(':age' => 4))
+ ->fields(['job' => 'Musician'])
+ ->expression('age', 'age + :age', [':age' => 4])
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '1', 'Updated fields successfully.');
- $person = db_query('SELECT * FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetch();
+ $person = db_query('SELECT * FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetch();
$this->assertEqual($person->name, 'Ringo', 'Name set correctly.');
$this->assertEqual($person->age, $before_age + 4, 'Age set correctly.');
$this->assertEqual($person->job, 'Musician', 'Job set correctly.');
@@ -111,14 +111,14 @@ class UpdateComplexTest extends DatabaseTestBase {
* Tests UPDATE with only expression values.
*/
function testUpdateOnlyExpression() {
- $before_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField();
+ $before_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField();
$num_updated = db_update('test')
->condition('name', 'Ringo')
- ->expression('age', 'age + :age', array(':age' => 4))
+ ->expression('age', 'age + :age', [':age' => 4])
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $after_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField();
+ $after_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField();
$this->assertEqual($before_age + 4, $after_age, 'Age updated correctly');
}
@@ -127,7 +127,7 @@ class UpdateComplexTest extends DatabaseTestBase {
*/
function testSubSelectUpdate() {
$subselect = db_select('test_task', 't');
- $subselect->addExpression('MAX(priority) + :increment', 'max_priority', array(':increment' => 30));
+ $subselect->addExpression('MAX(priority) + :increment', 'max_priority', [':increment' => 30]);
// Clone this to make sure we are running a different query when
// asserting.
$select = clone $subselect;
@@ -136,7 +136,7 @@ class UpdateComplexTest extends DatabaseTestBase {
->condition('name', 'Ringo');
// Save the number of rows that updated for assertion later.
$num_updated = $query->execute();
- $after_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField();
+ $after_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField();
$expected_age = $select->execute()->fetchField();
$this->assertEqual($after_age, $expected_age);
$this->assertEqual(1, $num_updated, t('Expected 1 row to be updated in subselect update query.'));
diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php
index 57a141835d2..cee2c958adc 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php
@@ -16,17 +16,17 @@ class UpdateLobTest extends DatabaseTestBase {
$data = "This is\000a test.";
$this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
$id = db_insert('test_one_blob')
- ->fields(array('blob1' => $data))
+ ->fields(['blob1' => $data])
->execute();
$data .= $data;
db_update('test_one_blob')
->condition('id', $id)
- ->fields(array('blob1' => $data))
+ ->fields(['blob1' => $data])
->execute();
- $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id))->fetchAssoc();
- $this->assertTrue($r['blob1'] === $data, format_string('Can update a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r))));
+ $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', [':id' => $id])->fetchAssoc();
+ $this->assertTrue($r['blob1'] === $data, format_string('Can update a blob: id @id, @data.', ['@id' => $id, '@data' => serialize($r)]));
}
/**
@@ -34,18 +34,18 @@ class UpdateLobTest extends DatabaseTestBase {
*/
function testUpdateMultipleBlob() {
$id = db_insert('test_two_blobs')
- ->fields(array(
+ ->fields([
'blob1' => 'This is',
'blob2' => 'a test',
- ))
+ ])
->execute();
db_update('test_two_blobs')
->condition('id', $id)
- ->fields(array('blob1' => 'and so', 'blob2' => 'is this'))
+ ->fields(['blob1' => 'and so', 'blob2' => 'is this'])
->execute();
- $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', array(':id' => $id))->fetchAssoc();
+ $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', [':id' => $id])->fetchAssoc();
$this->assertTrue($r['blob1'] === 'and so' && $r['blob2'] === 'is this', 'Can update multiple blobs per row.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php
index 25ad3cbac6c..aef6e866ebb 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php
@@ -14,12 +14,12 @@ class UpdateTest extends DatabaseTestBase {
*/
function testSimpleUpdate() {
$num_updated = db_update('test')
- ->fields(array('name' => 'Tiffany'))
+ ->fields(['name' => 'Tiffany'])
->condition('id', 1)
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', array(':id' => 1))->fetchField();
+ $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', [':id' => 1])->fetchField();
$this->assertIdentical($saved_name, 'Tiffany', 'Updated name successfully.');
}
@@ -29,12 +29,12 @@ class UpdateTest extends DatabaseTestBase {
function testSimpleNullUpdate() {
$this->ensureSampleDataNull();
$num_updated = db_update('test_null')
- ->fields(array('age' => NULL))
+ ->fields(['age' => NULL])
->condition('name', 'Kermit')
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $saved_age = db_query('SELECT age FROM {test_null} WHERE name = :name', array(':name' => 'Kermit'))->fetchField();
+ $saved_age = db_query('SELECT age FROM {test_null} WHERE name = :name', [':name' => 'Kermit'])->fetchField();
$this->assertNull($saved_age, 'Updated name successfully.');
}
@@ -43,12 +43,12 @@ class UpdateTest extends DatabaseTestBase {
*/
function testMultiUpdate() {
$num_updated = db_update('test')
- ->fields(array('job' => 'Musician'))
+ ->fields(['job' => 'Musician'])
->condition('job', 'Singer')
->execute();
$this->assertIdentical($num_updated, 2, 'Updated 2 records.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}
@@ -57,12 +57,12 @@ class UpdateTest extends DatabaseTestBase {
*/
function testMultiGTUpdate() {
$num_updated = db_update('test')
- ->fields(array('job' => 'Musician'))
+ ->fields(['job' => 'Musician'])
->condition('age', 26, '>')
->execute();
$this->assertIdentical($num_updated, 2, 'Updated 2 records.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}
@@ -71,12 +71,12 @@ class UpdateTest extends DatabaseTestBase {
*/
function testWhereUpdate() {
$num_updated = db_update('test')
- ->fields(array('job' => 'Musician'))
- ->where('age > :age', array(':age' => 26))
+ ->fields(['job' => 'Musician'])
+ ->where('age > :age', [':age' => 26])
->execute();
$this->assertIdentical($num_updated, 2, 'Updated 2 records.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}
@@ -85,13 +85,13 @@ class UpdateTest extends DatabaseTestBase {
*/
function testWhereAndConditionUpdate() {
$update = db_update('test')
- ->fields(array('job' => 'Musician'))
- ->where('age > :age', array(':age' => 26))
+ ->fields(['job' => 'Musician'])
+ ->where('age > :age', [':age' => 26])
->condition('name', 'Ringo');
$num_updated = $update->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField();
+ $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField();
$this->assertIdentical($num_matches, '1', 'Updated fields successfully.');
}
@@ -106,7 +106,7 @@ class UpdateTest extends DatabaseTestBase {
->execute();
$this->assertIdentical($num_rows, 4, 'Updated 4 records.');
- $saved_name = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => pow(26, 2)))->fetchField();
+ $saved_name = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => pow(26, 2)])->fetchField();
$this->assertIdentical($saved_name, 'Paul', 'Successfully updated values using an algebraic expression.');
}
@@ -122,7 +122,7 @@ class UpdateTest extends DatabaseTestBase {
// because that's cross-db expected behavior.
$num_rows = db_update('test_task')
->condition('priority', 1, '<>')
- ->fields(array('task' => 'sleep'))
+ ->fields(['task' => 'sleep'])
->execute();
$this->assertIdentical($num_rows, 5, 'Correctly returned 5 affected rows.');
}
@@ -132,12 +132,12 @@ class UpdateTest extends DatabaseTestBase {
*/
function testPrimaryKeyUpdate() {
$num_updated = db_update('test')
- ->fields(array('id' => 42, 'name' => 'John'))
+ ->fields(['id' => 42, 'name' => 'John'])
->condition('id', 1)
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 record.');
- $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', array(':id' => 42))->fetchField();
+ $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', [':id' => 42])->fetchField();
$this->assertIdentical($saved_name, 'John', 'Updated primary key successfully.');
}
@@ -146,12 +146,12 @@ class UpdateTest extends DatabaseTestBase {
*/
function testSpecialColumnUpdate() {
$num_updated = db_update('test_special_columns')
- ->fields(array('offset' => 'New offset value'))
+ ->fields(['offset' => 'New offset value'])
->condition('id', 1)
->execute();
$this->assertIdentical($num_updated, 1, 'Updated 1 special column record.');
- $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', array(':id' => 1))->fetchField();
+ $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', [':id' => 1])->fetchField();
$this->assertIdentical($saved_value, 'New offset value', 'Updated special column name value successfully.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php
index 9b8e167ebf0..5c62f87f6ba 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php
@@ -42,12 +42,12 @@ class UpsertTest extends DatabaseTestBase {
$num_records_after = $connection->query('SELECT COUNT(*) FROM {test_people}')->fetchField();
$this->assertEqual($num_records_before + 1, $num_records_after, 'Rows were inserted and updated properly.');
- $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Presenter'))->fetch();
+ $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Presenter'])->fetch();
$this->assertEqual($person->job, 'Presenter', 'Job set correctly.');
$this->assertEqual($person->age, 31, 'Age set correctly.');
$this->assertEqual($person->name, 'Tiffany', 'Name set correctly.');
- $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch();
+ $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch();
$this->assertEqual($person->job, 'Speaker', 'Job was not changed.');
$this->assertEqual($person->age, 32, 'Age updated correctly.');
$this->assertEqual($person->name, 'Meredith', 'Name was not changed.');
diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
index 7778a5a4531..7370491816b 100644
--- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
+++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
@@ -60,10 +60,10 @@ class DrupalKernelTest extends KernelTestBase {
*/
public function testCompileDIC() {
// @todo: write a memory based storage backend for testing.
- $modules_enabled = array(
+ $modules_enabled = [
'system' => 'system',
'user' => 'user',
- );
+ ];
$request = Request::createFromGlobals();
$this->getTestKernel($request, $modules_enabled);
@@ -128,11 +128,11 @@ class DrupalKernelTest extends KernelTestBase {
// Check that the location of the new module is registered.
$modules = $container->getParameter('container.modules');
- $this->assertEqual($modules['service_provider_test'], array(
+ $this->assertEqual($modules['service_provider_test'], [
'type' => 'module',
'pathname' => drupal_get_filename('module', 'service_provider_test'),
'filename' => NULL,
- ));
+ ]);
// Check that the container itself is not among the persist IDs because it
// does not make sense to persist the container itself.
@@ -169,10 +169,10 @@ class DrupalKernelTest extends KernelTestBase {
*/
public function testPreventChangeOfSitePath() {
// @todo: write a memory based storage backend for testing.
- $modules_enabled = array(
+ $modules_enabled = [
'system' => 'system',
'user' => 'user',
- );
+ ];
$request = Request::createFromGlobals();
$kernel = $this->getTestKernel($request, $modules_enabled);
diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php
index f4fe09450f6..1716280d5ee 100644
--- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php
@@ -17,7 +17,7 @@ class ServiceDestructionTest extends KernelTestBase {
*/
public function testDestructionUsed() {
// Enable the test module to add it to the container.
- $this->enableModules(array('service_provider_test'));
+ $this->enableModules(['service_provider_test']);
$request = $this->container->get('request_stack')->getCurrentRequest();
$kernel = $this->container->get('kernel');
@@ -39,7 +39,7 @@ class ServiceDestructionTest extends KernelTestBase {
*/
public function testDestructionUnused() {
// Enable the test module to add it to the container.
- $this->enableModules(array('service_provider_test'));
+ $this->enableModules(['service_provider_test']);
$request = $this->container->get('request_stack')->getCurrentRequest();
$kernel = $this->container->get('kernel');
diff --git a/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php
index ca4e5015c48..b5b9ffd5ec8 100644
--- a/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php
@@ -30,7 +30,7 @@ class PathElementFormTest extends KernelTestBase implements FormInterface {
*
* @var array
*/
- public static $modules = array('system', 'user');
+ public static $modules = ['system', 'user'];
/**
* Sets up the test.
@@ -41,16 +41,16 @@ class PathElementFormTest extends KernelTestBase implements FormInterface {
$this->installEntitySchema('user');
\Drupal::service('router.builder')->rebuild();
/** @var \Drupal\user\RoleInterface $role */
- $role = Role::create(array(
+ $role = Role::create([
'id' => 'admin',
'label' => 'admin',
- ));
+ ]);
$role->grantPermission('link to any page');
$role->save();
- $this->testUser = User::create(array(
+ $this->testUser = User::create([
'name' => 'foobar',
'mail' => 'foobar@example.com',
- ));
+ ]);
$this->testUser->addRole($role->id());
$this->testUser->save();
\Drupal::service('current_user')->setAccount($this->testUser);
@@ -68,57 +68,57 @@ class PathElementFormTest extends KernelTestBase implements FormInterface {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// A required validated path.
- $form['required_validate'] = array(
+ $form['required_validate'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_validate',
'#convert_path' => PathElement::CONVERT_NONE,
- );
+ ];
// A non validated required path.
- $form['required_non_validate'] = array(
+ $form['required_non_validate'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_non_validate',
'#convert_path' => PathElement::CONVERT_NONE,
'#validate_path' => FALSE,
- );
+ ];
// A non required validated path.
- $form['optional_validate'] = array(
+ $form['optional_validate'] = [
'#type' => 'path',
'#required' => FALSE,
'#title' => 'optional_validate',
'#convert_path' => PathElement::CONVERT_NONE,
- );
+ ];
// A non required converted path.
- $form['optional_validate'] = array(
+ $form['optional_validate'] = [
'#type' => 'path',
'#required' => FALSE,
'#title' => 'optional_validate',
'#convert_path' => PathElement::CONVERT_ROUTE,
- );
+ ];
// A converted required validated path.
- $form['required_validate_route'] = array(
+ $form['required_validate_route'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_validate_route',
- );
+ ];
// A converted required validated path.
- $form['required_validate_url'] = array(
+ $form['required_validate_url'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_validate_url',
'#convert_path' => PathElement::CONVERT_URL,
- );
+ ];
- $form['submit'] = array(
+ $form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
- );
+ ];
return $form;
}
@@ -154,19 +154,19 @@ class PathElementFormTest extends KernelTestBase implements FormInterface {
// Valid form state.
$this->assertEqual(count($form_state->getErrors()), 0);
- $this->assertEqual($form_state->getValue('required_validate_route'), array(
+ $this->assertEqual($form_state->getValue('required_validate_route'), [
'route_name' => 'entity.user.canonical',
- 'route_parameters' => array(
+ 'route_parameters' => [
'user' => $this->testUser->id(),
- ),
- ));
+ ],
+ ]);
/** @var \Drupal\Core\Url $url */
$url = $form_state->getValue('required_validate_url');
$this->assertTrue($url instanceof Url);
$this->assertEqual($url->getRouteName(), 'entity.user.canonical');
- $this->assertEqual($url->getRouteParameters(), array(
+ $this->assertEqual($url->getRouteParameters(), [
'user' => $this->testUser->id(),
- ));
+ ]);
// Test #required.
$form_state = (new FormState())
@@ -179,7 +179,7 @@ class PathElementFormTest extends KernelTestBase implements FormInterface {
$errors = $form_state->getErrors();
// Should be missing 'required_validate' field.
$this->assertEqual(count($errors), 1);
- $this->assertEqual($errors, array('required_validate' => t('@name field is required.', array('@name' => 'required_validate'))));
+ $this->assertEqual($errors, ['required_validate' => t('@name field is required.', ['@name' => 'required_validate'])]);
// Test invalid parameters.
$form_state = (new FormState())
@@ -195,11 +195,11 @@ class PathElementFormTest extends KernelTestBase implements FormInterface {
// Valid form state.
$errors = $form_state->getErrors();
$this->assertEqual(count($errors), 3);
- $this->assertEqual($errors, array(
- 'required_validate' => t('This path does not exist or you do not have permission to link to %path.', array('%path' => 'user/74')),
- 'required_validate_route' => t('This path does not exist or you do not have permission to link to %path.', array('%path' => 'user/74')),
- 'required_validate_url' => t('This path does not exist or you do not have permission to link to %path.', array('%path' => 'user/74')),
- ));
+ $this->assertEqual($errors, [
+ 'required_validate' => t('This path does not exist or you do not have permission to link to %path.', ['%path' => 'user/74']),
+ 'required_validate_route' => t('This path does not exist or you do not have permission to link to %path.', ['%path' => 'user/74']),
+ 'required_validate_url' => t('This path does not exist or you do not have permission to link to %path.', ['%path' => 'user/74']),
+ ]);
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php
index 2219487d776..613ba4e17dd 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php
@@ -19,7 +19,7 @@ class BundleConstraintValidatorTest extends KernelTestBase {
*/
protected $typedData;
- public static $modules = array('node', 'field', 'text', 'user');
+ public static $modules = ['node', 'field', 'text', 'user'];
protected function setUp() {
parent::setUp();
@@ -32,7 +32,7 @@ class BundleConstraintValidatorTest extends KernelTestBase {
*/
public function testValidation() {
// Test with multiple values.
- $this->assertValidation(array('foo', 'bar'));
+ $this->assertValidation(['foo', 'bar']);
// Test with a single string value as well.
$this->assertValidation('foo');
}
@@ -49,14 +49,14 @@ class BundleConstraintValidatorTest extends KernelTestBase {
->addConstraint('Bundle', $bundle);
// Test the validation.
- $node = $this->container->get('entity.manager')->getStorage('node')->create(array('type' => 'foo'));
+ $node = $this->container->get('entity.manager')->getStorage('node')->create(['type' => 'foo']);
$typed_data = $this->typedData->create($definition, $node);
$violations = $typed_data->validate();
$this->assertEqual($violations->count(), 0, 'Validation passed for correct value.');
// Test the validation when an invalid value is passed.
- $page_node = $this->container->get('entity.manager')->getStorage('node')->create(array('type' => 'baz'));
+ $page_node = $this->container->get('entity.manager')->getStorage('node')->create(['type' => 'baz']);
$typed_data = $this->typedData->create($definition, $page_node);
$violations = $typed_data->validate();
@@ -64,7 +64,7 @@ class BundleConstraintValidatorTest extends KernelTestBase {
// Make sure the information provided by a violation is correct.
$violation = $violations[0];
- $this->assertEqual($violation->getMessage(), t('The entity must be of bundle %bundle.', array('%bundle' => implode(', ', (array) $bundle))), 'The message for invalid value is correct.');
+ $this->assertEqual($violation->getMessage(), t('The entity must be of bundle %bundle.', ['%bundle' => implode(', ', (array) $bundle)]), 'The message for invalid value is correct.');
$this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.');
$this->assertEqual($violation->getInvalidValue(), $page_node, 'The invalid value is set correctly in the violation.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
index 22cae65fe4a..87ba10480ff 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
@@ -19,7 +19,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('config_test');
+ public static $modules = ['config_test'];
/**
* Stores the search results for alter comparison.
@@ -45,7 +45,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->entities = array();
+ $this->entities = [];
$this->factory = $this->container->get('entity.query');
// These two are here to make sure that matchArray needs to go over several
@@ -54,56 +54,56 @@ class ConfigEntityQueryTest extends KernelTestBase {
$array['level1a']['level2'] = 9;
// The tests match array.level1.level2.
$array['level1']['level2'] = 1;
- $entity = ConfigQueryTest::create(array(
+ $entity = ConfigQueryTest::create([
'label' => $this->randomMachineName(),
'id' => '1',
'number' => 31,
'array' => $array,
- ));
+ ]);
$this->entities[] = $entity;
$entity->enforceIsNew();
$entity->save();
$array['level1']['level2'] = 2;
- $entity = ConfigQueryTest::create(array(
+ $entity = ConfigQueryTest::create([
'label' => $this->randomMachineName(),
'id' => '2',
'number' => 41,
'array' => $array,
- ));
+ ]);
$this->entities[] = $entity;
$entity->enforceIsNew();
$entity->save();
$array['level1']['level2'] = 1;
- $entity = ConfigQueryTest::create(array(
+ $entity = ConfigQueryTest::create([
'label' => 'test_prefix_' . $this->randomMachineName(),
'id' => '3',
'number' => 59,
'array' => $array,
- ));
+ ]);
$this->entities[] = $entity;
$entity->enforceIsNew();
$entity->save();
$array['level1']['level2'] = 2;
- $entity = ConfigQueryTest::create(array(
+ $entity = ConfigQueryTest::create([
'label' => $this->randomMachineName() . '_test_suffix',
'id' => '4',
'number' => 26,
'array' => $array,
- ));
+ ]);
$this->entities[] = $entity;
$entity->enforceIsNew();
$entity->save();
$array['level1']['level2'] = 3;
- $entity = ConfigQueryTest::create(array(
+ $entity = ConfigQueryTest::create([
'label' => $this->randomMachineName() . '_TEST_contains_' . $this->randomMachineName(),
'id' => '5',
'number' => 53,
'array' => $array,
- ));
+ ]);
$this->entities[] = $entity;
$entity->enforceIsNew();
$entity->save();
@@ -116,84 +116,84 @@ class ConfigEntityQueryTest extends KernelTestBase {
// Run a test without any condition.
$this->queryResults = $this->factory->get('config_query_test')
->execute();
- $this->assertResults(array('1', '2', '3', '4', '5'));
+ $this->assertResults(['1', '2', '3', '4', '5']);
// No conditions, OR.
$this->queryResults = $this->factory->get('config_query_test', 'OR')
->execute();
- $this->assertResults(array('1', '2', '3', '4', '5'));
+ $this->assertResults(['1', '2', '3', '4', '5']);
// Filter by ID with equality.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3')
->execute();
- $this->assertResults(array('3'));
+ $this->assertResults(['3']);
// Filter by label with a known prefix.
$this->queryResults = $this->factory->get('config_query_test')
->condition('label', 'test_prefix', 'STARTS_WITH')
->execute();
- $this->assertResults(array('3'));
+ $this->assertResults(['3']);
// Filter by label with a known suffix.
$this->queryResults = $this->factory->get('config_query_test')
->condition('label', 'test_suffix', 'ENDS_WITH')
->execute();
- $this->assertResults(array('4'));
+ $this->assertResults(['4']);
// Filter by label with a known containing word.
$this->queryResults = $this->factory->get('config_query_test')
->condition('label', 'test_contains', 'CONTAINS')
->execute();
- $this->assertResults(array('5'));
+ $this->assertResults(['5']);
// Filter by ID with the IN operator.
$this->queryResults = $this->factory->get('config_query_test')
- ->condition('id', array('2', '3'), 'IN')
+ ->condition('id', ['2', '3'], 'IN')
->execute();
- $this->assertResults(array('2', '3'));
+ $this->assertResults(['2', '3']);
// Filter by ID with the implicit IN operator.
$this->queryResults = $this->factory->get('config_query_test')
- ->condition('id', array('2', '3'))
+ ->condition('id', ['2', '3'])
->execute();
- $this->assertResults(array('2', '3'));
+ $this->assertResults(['2', '3']);
// Filter by ID with the > operator.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3', '>')
->execute();
- $this->assertResults(array('4', '5'));
+ $this->assertResults(['4', '5']);
// Filter by ID with the >= operator.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3', '>=')
->execute();
- $this->assertResults(array('3', '4', '5'));
+ $this->assertResults(['3', '4', '5']);
// Filter by ID with the <> operator.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3', '<>')
->execute();
- $this->assertResults(array('1', '2', '4', '5'));
+ $this->assertResults(['1', '2', '4', '5']);
// Filter by ID with the < operator.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3', '<')
->execute();
- $this->assertResults(array('1', '2'));
+ $this->assertResults(['1', '2']);
// Filter by ID with the <= operator.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3', '<=')
->execute();
- $this->assertResults(array('1', '2', '3'));
+ $this->assertResults(['1', '2', '3']);
// Filter by two conditions on the same field.
$this->queryResults = $this->factory->get('config_query_test')
->condition('label', 'test_pref', 'STARTS_WITH')
->condition('label', 'test_prefix', 'STARTS_WITH')
->execute();
- $this->assertResults(array('3'));
+ $this->assertResults(['3']);
// Filter by two conditions on different fields. The first query matches for
// a different ID, so the result is empty.
@@ -201,7 +201,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition('label', 'test_prefix', 'STARTS_WITH')
->condition('id', '5')
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
// Filter by two different conditions on different fields. This time the
// first condition matches on one item, but the second one does as well.
@@ -209,7 +209,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition('label', 'test_prefix', 'STARTS_WITH')
->condition('id', '3')
->execute();
- $this->assertResults(array('3'));
+ $this->assertResults(['3']);
// Filter by two different conditions, of which the first one matches for
// every entry, the second one as well, but just the third one filters so
@@ -219,37 +219,37 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition('number', 10, '>=')
->condition('number', 50, '>=')
->execute();
- $this->assertResults(array('3', '5'));
+ $this->assertResults(['3', '5']);
// Filter with an OR condition group.
$this->queryResults = $this->factory->get('config_query_test', 'OR')
->condition('id', 1)
->condition('id', '2')
->execute();
- $this->assertResults(array('1', '2'));
+ $this->assertResults(['1', '2']);
// Simplify it with IN.
$this->queryResults = $this->factory->get('config_query_test')
- ->condition('id', array('1', '2'))
+ ->condition('id', ['1', '2'])
->execute();
- $this->assertResults(array('1', '2'));
+ $this->assertResults(['1', '2']);
// Try explicit IN.
$this->queryResults = $this->factory->get('config_query_test')
- ->condition('id', array('1', '2'), 'IN')
+ ->condition('id', ['1', '2'], 'IN')
->execute();
- $this->assertResults(array('1', '2'));
+ $this->assertResults(['1', '2']);
// Try not IN.
$this->queryResults = $this->factory->get('config_query_test')
- ->condition('id', array('1', '2'), 'NOT IN')
+ ->condition('id', ['1', '2'], 'NOT IN')
->execute();
- $this->assertResults(array('3', '4', '5'));
+ $this->assertResults(['3', '4', '5']);
// Filter with an OR condition group on different fields.
$this->queryResults = $this->factory->get('config_query_test', 'OR')
->condition('id', 1)
->condition('number', 41)
->execute();
- $this->assertResults(array('1', '2'));
+ $this->assertResults(['1', '2']);
// Filter with an OR condition group on different fields but matching on the
// same entity.
@@ -257,7 +257,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition('id', 1)
->condition('number', 31)
->execute();
- $this->assertResults(array('1'));
+ $this->assertResults(['1']);
// NO simple conditions, YES complex conditions, 'AND'.
$query = $this->factory->get('config_query_test', 'AND');
@@ -271,7 +271,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition($and_condition_1)
->condition($and_condition_2)
->execute();
- $this->assertResults(array('1'));
+ $this->assertResults(['1']);
// NO simple conditions, YES complex conditions, 'OR'.
$query = $this->factory->get('config_query_test', 'OR');
@@ -285,7 +285,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition($and_condition_1)
->condition($and_condition_2)
->execute();
- $this->assertResults(array('1', '2'));
+ $this->assertResults(['1', '2']);
// YES simple conditions, YES complex conditions, 'AND'.
$query = $this->factory->get('config_query_test', 'AND');
@@ -300,7 +300,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition($and_condition_1)
->condition($and_condition_2)
->execute();
- $this->assertResults(array('1'));
+ $this->assertResults(['1']);
// YES simple conditions, YES complex conditions, 'OR'.
$query = $this->factory->get('config_query_test', 'OR');
@@ -315,28 +315,28 @@ class ConfigEntityQueryTest extends KernelTestBase {
->condition($and_condition_1)
->condition($and_condition_2)
->execute();
- $this->assertResults(array('1', '2', '4', '5'));
+ $this->assertResults(['1', '2', '4', '5']);
// Test the exists and notExists conditions.
$this->queryResults = $this->factory->get('config_query_test')
->exists('id')
->execute();
- $this->assertResults(array('1', '2', '3', '4', '5'));
+ $this->assertResults(['1', '2', '3', '4', '5']);
$this->queryResults = $this->factory->get('config_query_test')
->exists('non-existent')
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
$this->queryResults = $this->factory->get('config_query_test')
->notExists('id')
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
$this->queryResults = $this->factory->get('config_query_test')
->notExists('non-existent')
->execute();
- $this->assertResults(array('1', '2', '3', '4', '5'));
+ $this->assertResults(['1', '2', '3', '4', '5']);
}
/**
@@ -344,10 +344,10 @@ class ConfigEntityQueryTest extends KernelTestBase {
*/
public function testStringIdConditions() {
// We need an entity with a non-numeric ID.
- $entity = ConfigQueryTest::create(array(
+ $entity = ConfigQueryTest::create([
'label' => $this->randomMachineName(),
'id' => 'foo.bar',
- ));
+ ]);
$this->entities[] = $entity;
$entity->enforceIsNew();
$entity->save();
@@ -356,43 +356,43 @@ class ConfigEntityQueryTest extends KernelTestBase {
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'foo.bar', 'STARTS_WITH')
->execute();
- $this->assertResults(array('foo.bar'));
+ $this->assertResults(['foo.bar']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'f', 'STARTS_WITH')
->execute();
- $this->assertResults(array('foo.bar'));
+ $this->assertResults(['foo.bar']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'miss', 'STARTS_WITH')
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
// Test 'CONTAINS' condition.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'foo.bar', 'CONTAINS')
->execute();
- $this->assertResults(array('foo.bar'));
+ $this->assertResults(['foo.bar']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'oo.ba', 'CONTAINS')
->execute();
- $this->assertResults(array('foo.bar'));
+ $this->assertResults(['foo.bar']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'miss', 'CONTAINS')
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
// Test 'ENDS_WITH' condition.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'foo.bar', 'ENDS_WITH')
->execute();
- $this->assertResults(array('foo.bar'));
+ $this->assertResults(['foo.bar']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'r', 'ENDS_WITH')
->execute();
- $this->assertResults(array('foo.bar'));
+ $this->assertResults(['foo.bar']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', 'miss', 'ENDS_WITH')
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
}
/**
@@ -429,62 +429,62 @@ class ConfigEntityQueryTest extends KernelTestBase {
$this->queryResults = $this->factory->get('config_query_test')
->sort('number', 'DESC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('3', '5', '2', '1', '4'));
+ $this->assertIdentical(array_values($this->queryResults), ['3', '5', '2', '1', '4']);
$this->queryResults = $this->factory->get('config_query_test')
->sort('number', 'ASC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('4', '1', '2', '5', '3'));
+ $this->assertIdentical(array_values($this->queryResults), ['4', '1', '2', '5', '3']);
// Apply some filters and sort.
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3', '>')
->sort('number', 'DESC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('5', '4'));
+ $this->assertIdentical(array_values($this->queryResults), ['5', '4']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('id', '3', '>')
->sort('number', 'ASC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('4', '5'));
+ $this->assertIdentical(array_values($this->queryResults), ['4', '5']);
// Apply a pager and sort.
$this->queryResults = $this->factory->get('config_query_test')
->sort('number', 'DESC')
->range('2', '2')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('2', '1'));
+ $this->assertIdentical(array_values($this->queryResults), ['2', '1']);
$this->queryResults = $this->factory->get('config_query_test')
->sort('number', 'ASC')
->range('2', '2')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('2', '5'));
+ $this->assertIdentical(array_values($this->queryResults), ['2', '5']);
// Add a range to a query without a start parameter.
$this->queryResults = $this->factory->get('config_query_test')
->range(0, '3')
->sort('id', 'ASC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3'));
+ $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3']);
// Apply a pager with limit 4.
$this->queryResults = $this->factory->get('config_query_test')
->pager('4', 0)
->sort('id', 'ASC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3', '4'));
+ $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3', '4']);
}
/**
* Tests sorting with tableSort on config entity queries.
*/
public function testTableSort() {
- $header = array(
- array('data' => t('ID'), 'specifier' => 'id'),
- array('data' => t('Number'), 'specifier' => 'number'),
- );
+ $header = [
+ ['data' => t('ID'), 'specifier' => 'id'],
+ ['data' => t('Number'), 'specifier' => 'number'],
+ ];
// Sort key: id
// Sorting with 'DESC' upper case
@@ -492,28 +492,28 @@ class ConfigEntityQueryTest extends KernelTestBase {
->tableSort($header)
->sort('id', 'DESC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('5', '4', '3', '2', '1'));
+ $this->assertIdentical(array_values($this->queryResults), ['5', '4', '3', '2', '1']);
// Sorting with 'ASC' upper case
$this->queryResults = $this->factory->get('config_query_test')
->tableSort($header)
->sort('id', 'ASC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3', '4', '5'));
+ $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3', '4', '5']);
// Sorting with 'desc' lower case
$this->queryResults = $this->factory->get('config_query_test')
->tableSort($header)
->sort('id', 'desc')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('5', '4', '3', '2', '1'));
+ $this->assertIdentical(array_values($this->queryResults), ['5', '4', '3', '2', '1']);
// Sorting with 'asc' lower case
$this->queryResults = $this->factory->get('config_query_test')
->tableSort($header)
->sort('id', 'asc')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3', '4', '5'));
+ $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3', '4', '5']);
// Sort key: number
// Sorting with 'DeSc' mixed upper and lower case
@@ -521,28 +521,28 @@ class ConfigEntityQueryTest extends KernelTestBase {
->tableSort($header)
->sort('number', 'DeSc')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('3', '5', '2', '1', '4'));
+ $this->assertIdentical(array_values($this->queryResults), ['3', '5', '2', '1', '4']);
// Sorting with 'AsC' mixed upper and lower case
$this->queryResults = $this->factory->get('config_query_test')
->tableSort($header)
->sort('number', 'AsC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('4', '1', '2', '5', '3'));
+ $this->assertIdentical(array_values($this->queryResults), ['4', '1', '2', '5', '3']);
// Sorting with 'dEsC' mixed upper and lower case
$this->queryResults = $this->factory->get('config_query_test')
->tableSort($header)
->sort('number', 'dEsC')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('3', '5', '2', '1', '4'));
+ $this->assertIdentical(array_values($this->queryResults), ['3', '5', '2', '1', '4']);
// Sorting with 'aSc' mixed upper and lower case
$this->queryResults = $this->factory->get('config_query_test')
->tableSort($header)
->sort('number', 'aSc')
->execute();
- $this->assertIdentical(array_values($this->queryResults), array('4', '1', '2', '5', '3'));
+ $this->assertIdentical(array_values($this->queryResults), ['4', '1', '2', '5', '3']);
}
/**
@@ -552,26 +552,26 @@ class ConfigEntityQueryTest extends KernelTestBase {
$this->queryResults = $this->factory->get('config_query_test')
->condition('array.level1.*', 1)
->execute();
- $this->assertResults(array('1', '3'));
+ $this->assertResults(['1', '3']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('*.level1.level2', 2)
->execute();
- $this->assertResults(array('2', '4'));
+ $this->assertResults(['2', '4']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('array.level1.*', 3)
->execute();
- $this->assertResults(array('5'));
+ $this->assertResults(['5']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('array.level1.level2', 3)
->execute();
- $this->assertResults(array('5'));
+ $this->assertResults(['5']);
// Make sure that values on the wildcard level do not match if there are
// sub-keys defined. This must not find anything even if entity 2 has a
// top-level key number with value 41.
$this->queryResults = $this->factory->get('config_query_test')
->condition('*.level1.level2', 41)
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
}
/**
@@ -582,12 +582,12 @@ class ConfigEntityQueryTest extends KernelTestBase {
$this->queryResults = $this->factory->get('config_query_test')
->condition('label', 'TEST', 'CONTAINS')
->execute();
- $this->assertResults(array('3', '4', '5'));
+ $this->assertResults(['3', '4', '5']);
$this->queryResults = $this->factory->get('config_query_test')
->condition('label', 'test', 'CONTAINS')
->execute();
- $this->assertResults(array('3', '4', '5'));
+ $this->assertResults(['3', '4', '5']);
}
/**
@@ -599,11 +599,11 @@ class ConfigEntityQueryTest extends KernelTestBase {
$key_value = $this->container->get('keyvalue')->get(QueryFactory::CONFIG_LOOKUP_PREFIX . 'config_test');
$test_entities = [];
- $entity = entity_create('config_test', array(
+ $entity = entity_create('config_test', [
'label' => $this->randomMachineName(),
'id' => '1',
'style' => 'test',
- ));
+ ]);
$test_entities[$entity->getConfigDependencyName()] = $entity;
$entity->enforceIsNew();
$entity->save();
@@ -612,22 +612,22 @@ class ConfigEntityQueryTest extends KernelTestBase {
$expected[] = $entity->getConfigDependencyName();
$this->assertEqual($expected, $key_value->get('style:test'));
- $entity = entity_create('config_test', array(
+ $entity = entity_create('config_test', [
'label' => $this->randomMachineName(),
'id' => '2',
'style' => 'test',
- ));
+ ]);
$test_entities[$entity->getConfigDependencyName()] = $entity;
$entity->enforceIsNew();
$entity->save();
$expected[] = $entity->getConfigDependencyName();
$this->assertEqual($expected, $key_value->get('style:test'));
- $entity = entity_create('config_test', array(
+ $entity = entity_create('config_test', [
'label' => $this->randomMachineName(),
'id' => '3',
'style' => 'blah',
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
// Do not add this entity to the list of expected result as it has a
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php
index e9e2ad14252..66e1abb2c51 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php
@@ -59,12 +59,12 @@ class ContentEntityChangedTest extends EntityKernelTestBase {
$user2 = $this->createUser();
// Create a test entity.
- $entity = EntityTestMulChanged::create(array(
+ $entity = EntityTestMulChanged::create([
'name' => $this->randomString(),
'not_translatable' => $this->randomString(),
'user_id' => $user1->id(),
'language' => 'en',
- ));
+ ]);
$entity->save();
$this->assertTrue(
@@ -289,11 +289,11 @@ class ContentEntityChangedTest extends EntityKernelTestBase {
$user2 = $this->createUser();
// Create a test entity.
- $entity = EntityTestMulRevChanged::create(array(
+ $entity = EntityTestMulRevChanged::create([
'name' => $this->randomString(),
'user_id' => $user1->id(),
'language' => 'en',
- ));
+ ]);
$entity->save();
$this->assertTrue(
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php
index 73684e9f7fa..99c99b06883 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php
@@ -57,21 +57,21 @@ class ContentEntityNonRevisionableFieldTest extends EntityKernelTestBase {
$user2 = $this->createUser();
// Create a test entity.
- $entity = EntityTestMulRev::create(array(
+ $entity = EntityTestMulRev::create([
'name' => $this->randomString(),
'user_id' => $user1->id(),
'language' => 'en',
'non_rev_field' => 'Huron',
- ));
+ ]);
$entity->save();
// Create a test entity.
- $entity2 = EntityTestMulRev::create(array(
+ $entity2 = EntityTestMulRev::create([
'name' => $this->randomString(),
'user_id' => $user1->id(),
'language' => 'en',
'non_rev_field' => 'Michigan',
- ));
+ ]);
$entity2->save();
$this->assertEquals('Huron', $entity->get('non_rev_field')->value, 'Huron found on entity 1');
@@ -123,19 +123,19 @@ class ContentEntityNonRevisionableFieldTest extends EntityKernelTestBase {
$user2 = $this->createUser();
// Create a test entity.
- $entity = EntityTestRev::create(array(
+ $entity = EntityTestRev::create([
'name' => $this->randomString(),
'user_id' => $user1->id(),
'non_rev_field' => 'Superior',
- ));
+ ]);
$entity->save();
// Create a test entity.
- $entity2 = EntityTestRev::create(array(
+ $entity2 = EntityTestRev::create([
'name' => $this->randomString(),
'user_id' => $user1->id(),
'non_rev_field' => 'Ontario',
- ));
+ ]);
$entity2->save();
$this->assertEquals('Superior', $entity->get('non_rev_field')->value, 'Superior found on entity 1');
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php
index 51162fcd634..697f1be15d9 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php
@@ -22,7 +22,7 @@ class ContentEntityNullStorageTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'contact', 'user');
+ public static $modules = ['system', 'contact', 'user'];
/**
* Tests using entity query with ContentEntityNullStorage.
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php
index c2d737bfb8d..5d7ea0eb8ed 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php
@@ -50,23 +50,23 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
$this->installEntitySchema('entity_test_string_id');
\Drupal::service('router.builder')->rebuild();
- $this->testUser = User::create(array(
+ $this->testUser = User::create([
'name' => 'foobar1',
'mail' => 'foobar1@example.com',
- ));
+ ]);
$this->testUser->save();
\Drupal::service('current_user')->setAccount($this->testUser);
- $this->testAutocreateUser = User::create(array(
+ $this->testAutocreateUser = User::create([
'name' => 'foobar2',
'mail' => 'foobar2@example.com',
- ));
+ ]);
$this->testAutocreateUser->save();
for ($i = 1; $i < 3; $i++) {
- $entity = EntityTest::create(array(
+ $entity = EntityTest::create([
'name' => $this->randomMachineName()
- ));
+ ]);
$entity->save();
$this->referencedEntities[] = $entity;
}
@@ -94,84 +94,84 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['single'] = array(
+ $form['single'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
- );
- $form['single_autocreate'] = array(
+ ];
+ $form['single_autocreate'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
- '#autocreate' => array(
+ '#autocreate' => [
'bundle' => 'entity_test',
- ),
- );
- $form['single_autocreate_specific_uid'] = array(
+ ],
+ ];
+ $form['single_autocreate_specific_uid'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
- '#autocreate' => array(
+ '#autocreate' => [
'bundle' => 'entity_test',
'uid' => $this->testAutocreateUser->id(),
- ),
- );
+ ],
+ ];
- $form['tags'] = array(
+ $form['tags'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
'#tags' => TRUE,
- );
- $form['tags_autocreate'] = array(
+ ];
+ $form['tags_autocreate'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
'#tags' => TRUE,
- '#autocreate' => array(
+ '#autocreate' => [
'bundle' => 'entity_test',
- ),
- );
- $form['tags_autocreate_specific_uid'] = array(
+ ],
+ ];
+ $form['tags_autocreate_specific_uid'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
'#tags' => TRUE,
- '#autocreate' => array(
+ '#autocreate' => [
'bundle' => 'entity_test',
'uid' => $this->testAutocreateUser->id(),
- ),
- );
+ ],
+ ];
- $form['single_no_validate'] = array(
+ $form['single_no_validate'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
'#validate_reference' => FALSE,
- );
- $form['single_autocreate_no_validate'] = array(
+ ];
+ $form['single_autocreate_no_validate'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
'#validate_reference' => FALSE,
- '#autocreate' => array(
+ '#autocreate' => [
'bundle' => 'entity_test',
- ),
- );
+ ],
+ ];
- $form['single_access'] = array(
+ $form['single_access'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
'#default_value' => $this->referencedEntities[0],
- );
- $form['tags_access'] = array(
+ ];
+ $form['tags_access'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test',
'#tags' => TRUE,
- '#default_value' => array($this->referencedEntities[0], $this->referencedEntities[1]),
- );
+ '#default_value' => [$this->referencedEntities[0], $this->referencedEntities[1]],
+ ];
- $form['single_string_id'] = array(
+ $form['single_string_id'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test_string_id',
- );
- $form['tags_string_id'] = array(
+ ];
+ $form['tags_string_id'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'entity_test_string_id',
'#tags' => TRUE,
- );
+ ];
return $form;
}
@@ -229,10 +229,10 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
$this->assertEqual($value['entity']->getOwnerId(), $this->testAutocreateUser->id());
// Test the 'tags' element.
- $expected = array(
- array('target_id' => $this->referencedEntities[0]->id()),
- array('target_id' => $this->referencedEntities[1]->id()),
- );
+ $expected = [
+ ['target_id' => $this->referencedEntities[0]->id()],
+ ['target_id' => $this->referencedEntities[1]->id()],
+ ];
$this->assertEqual($form_state->getValue('tags'), $expected);
// Test the 'single_autocreate' element.
@@ -281,7 +281,7 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
]);
$form_builder->submitForm($this, $form_state);
$this->assertEqual(count($form_state->getErrors()), 1);
- $this->assertEqual($form_state->getErrors()['single'], t('There are no entities matching "%value".', array('%value' => 'single - non-existent label')));
+ $this->assertEqual($form_state->getErrors()['single'], t('There are no entities matching "%value".', ['%value' => 'single - non-existent label']));
// Test 'single' with a entity ID that doesn't exist.
$form_state = (new FormState())
@@ -290,7 +290,7 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
]);
$form_builder->submitForm($this, $form_state);
$this->assertEqual(count($form_state->getErrors()), 1);
- $this->assertEqual($form_state->getErrors()['single'], t('The referenced entity (%type: %id) does not exist.', array('%type' => 'entity_test', '%id' => 42)));
+ $this->assertEqual($form_state->getErrors()['single'], t('The referenced entity (%type: %id) does not exist.', ['%type' => 'entity_test', '%id' => 42]));
// Do the same tests as above but on an element with '#validate_reference'
// set to FALSE.
@@ -304,7 +304,7 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
// The element without 'autocreate' support still has to emit a warning when
// the input doesn't end with an entity ID enclosed in parentheses.
$this->assertEqual(count($form_state->getErrors()), 1);
- $this->assertEqual($form_state->getErrors()['single_no_validate'], t('There are no entities matching "%value".', array('%value' => 'single - non-existent label')));
+ $this->assertEqual($form_state->getErrors()['single_no_validate'], t('There are no entities matching "%value".', ['%value' => 'single - non-existent label']));
$form_state = (new FormState())
->setValues([
@@ -333,7 +333,7 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
$this->assertEqual($form['tags_access']['#value'], $expected);
// Set up a non-admin user that is *not* allowed to view test entities.
- \Drupal::currentUser()->setAccount($this->createUser(array(), array()));
+ \Drupal::currentUser()->setAccount($this->createUser([], []));
// Rebuild the form.
$form = $form_builder->getForm($this);
@@ -381,7 +381,7 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
* A string that can be used as a value for EntityAutocomplete elements.
*/
protected function getAutocompleteInput(EntityInterface $entity) {
- return EntityAutocomplete::getEntityLabels(array($entity));
+ return EntityAutocomplete::getEntityLabels([$entity]);
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
index 77210d5c4da..a0ab99978c0 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
@@ -25,10 +25,10 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
*/
function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface $account = NULL) {
foreach ($ops as $op => $result) {
- $message = format_string("Entity access returns @result with operation '@op'.", array(
+ $message = format_string("Entity access returns @result with operation '@op'.", [
'@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'),
'@op' => $op,
- ));
+ ]);
$this->assertEqual($result, $object->access($op, $account), $message);
}
@@ -45,44 +45,44 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
$user = $this->createUser();
// The current user is allowed to view the anonymous user label.
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
'view label' => TRUE,
- ), $anonymous_user);
+ ], $anonymous_user);
// The current user is allowed to view user labels.
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
'view label' => TRUE,
- ), $user);
+ ], $user);
// Switch to a anonymous user account.
$account_switcher = \Drupal::service('account_switcher');
$account_switcher->switchTo(new AnonymousUserSession());
// The anonymous user is allowed to view the anonymous user label.
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
'view label' => TRUE,
- ), $anonymous_user);
+ ], $anonymous_user);
// The anonymous user is allowed to view user labels.
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
'view label' => TRUE,
- ), $user);
+ ], $user);
// Restore user account.
$account_switcher->switchBack();
@@ -93,33 +93,33 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
*/
function testEntityAccess() {
// Set up a non-admin user that is allowed to view test entities.
- \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity')));
+ \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity']));
// Use the 'entity_test_label' entity type in order to test the 'view label'
// access operation.
- $entity = EntityTestLabel::create(array(
+ $entity = EntityTestLabel::create([
'name' => 'test',
- ));
+ ]);
// The current user is allowed to view entities.
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => TRUE,
'view label' => TRUE,
- ), $entity);
+ ], $entity);
// The custom user is not allowed to perform any operation on test entities,
// except for viewing their label.
$custom_user = $this->createUser();
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
'view label' => TRUE,
- ), $entity, $custom_user);
+ ], $entity, $custom_user);
}
/**
@@ -136,18 +136,18 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
*/
function testDefaultEntityAccess() {
// Set up a non-admin user that is allowed to view test entities.
- \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity')));
- $entity = EntityTest::create(array(
+ \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity']));
+ $entity = EntityTest::create([
'name' => 'forbid_access',
- ));
+ ]);
// The user is denied access to the entity.
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
- ), $entity);
+ ], $entity);
}
/**
@@ -155,7 +155,7 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
*/
function testEntityAccessDefaultController() {
// The implementation requires that the global user id can be loaded.
- \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2)));
+ \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2]));
// Check that the default access control handler is used for entities that don't
// have a specific access control handler defined.
@@ -163,12 +163,12 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
$this->assertTrue($handler instanceof EntityAccessControlHandler, 'The default entity handler is used for the entity_test_default_access entity type.');
$entity = EntityTestDefaultAccess::create();
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
- ), $entity);
+ ], $entity);
}
/**
@@ -177,26 +177,26 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
function testEntityTranslationAccess() {
// Set up a non-admin user that is allowed to view test entity translations.
- \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity translations')));
+ \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity translations']));
// Create two test languages.
- foreach (array('foo', 'bar') as $langcode) {
- ConfigurableLanguage::create(array(
+ foreach (['foo', 'bar'] as $langcode) {
+ ConfigurableLanguage::create([
'id' => $langcode,
'label' => $this->randomString(),
- ))->save();
+ ])->save();
}
- $entity = EntityTest::create(array(
+ $entity = EntityTest::create([
'name' => 'test',
'langcode' => 'foo',
- ));
+ ]);
$entity->save();
$translation = $entity->addTranslation('bar');
- $this->assertEntityAccess(array(
+ $this->assertEntityAccess([
'view' => TRUE,
- ), $translation);
+ ], $translation);
}
/**
@@ -204,9 +204,9 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
*/
public function testHooks() {
$state = $this->container->get('state');
- $entity = EntityTest::create(array(
+ $entity = EntityTest::create([
'name' => 'test',
- ));
+ ]);
// Test hook_entity_create_access() and hook_ENTITY_TYPE_create_access().
$entity->access('create');
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
index 7ce15f53cdd..744121e764f 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
@@ -49,15 +49,15 @@ class EntityApiTest extends EntityKernelTestBase {
// Create some test entities.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('name' => 'test', 'user_id' => $user1->id()));
+ ->create(['name' => 'test', 'user_id' => $user1->id()]);
$entity->save();
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('name' => 'test2', 'user_id' => $user1->id()));
+ ->create(['name' => 'test2', 'user_id' => $user1->id()]);
$entity->save();
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('name' => 'test', 'user_id' => NULL));
+ ->create(['name' => 'test', 'user_id' => NULL]);
$entity->save();
/** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
@@ -65,32 +65,32 @@ class EntityApiTest extends EntityKernelTestBase {
->getStorage($entity_type);
$entities = array_values($storage->loadByProperties(['name' => 'test']));
- $this->assertEqual($entities[0]->name->value, 'test', format_string('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type)));
- $this->assertEqual($entities[1]->name->value, 'test', format_string('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entities[0]->name->value, 'test', format_string('%entity_type: Created and loaded entity', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entities[1]->name->value, 'test', format_string('%entity_type: Created and loaded entity', ['%entity_type' => $entity_type]));
// Test loading a single entity.
$loaded_entity = $storage->load($entity->id());
- $this->assertEqual($loaded_entity->id(), $entity->id(), format_string('%entity_type: Loaded a single entity by id.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($loaded_entity->id(), $entity->id(), format_string('%entity_type: Loaded a single entity by id.', ['%entity_type' => $entity_type]));
// Test deleting an entity.
$entities = array_values($storage->loadByProperties(['name' => 'test2']));
$entities[0]->delete();
$entities = array_values($storage->loadByProperties(['name' => 'test2']));
- $this->assertEqual($entities, array(), format_string('%entity_type: Entity deleted.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entities, [], format_string('%entity_type: Entity deleted.', ['%entity_type' => $entity_type]));
// Test updating an entity.
$entities = array_values($storage->loadByProperties(['name' => 'test']));
$entities[0]->name->value = 'test3';
$entities[0]->save();
$entity = $storage->load($entities[0]->id());
- $this->assertEqual($entity->name->value, 'test3', format_string('%entity_type: Entity updated.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->name->value, 'test3', format_string('%entity_type: Entity updated.', ['%entity_type' => $entity_type]));
// Try deleting multiple test entities by deleting all.
$ids = array_keys($storage->loadMultiple());
entity_delete_multiple($entity_type, $ids);
$all = $storage->loadMultiple();
- $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', array('%entity_type' => $entity_type)));
+ $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type]));
// Verify that all data got deleted.
$definition = \Drupal::entityManager()->getDefinition($entity_type);
@@ -103,11 +103,11 @@ class EntityApiTest extends EntityKernelTestBase {
}
// Test deleting a list of entities not indexed by entity id.
- $entities = array();
- $entity = entity_create($entity_type, array('name' => 'test', 'user_id' => $user1->id()));
+ $entities = [];
+ $entity = entity_create($entity_type, ['name' => 'test', 'user_id' => $user1->id()]);
$entity->save();
$entities['test'] = $entity;
- $entity = entity_create($entity_type, array('name' => 'test2', 'user_id' => $user1->id()));
+ $entity = entity_create($entity_type, ['name' => 'test2', 'user_id' => $user1->id()]);
$entity->save();
$entities['test2'] = $entity;
$controller = \Drupal::entityManager()->getStorage($entity_type);
@@ -115,7 +115,7 @@ class EntityApiTest extends EntityKernelTestBase {
// Verify that entities got deleted.
$all = $storage->loadMultiple();
- $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', array('%entity_type' => $entity_type)));
+ $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type]));
// Verify that all data got deleted from the tables.
$definition = \Drupal::entityManager()->getDefinition($entity_type);
@@ -132,7 +132,7 @@ class EntityApiTest extends EntityKernelTestBase {
* Tests that exceptions are thrown when saving or deleting an entity.
*/
public function testEntityStorageExceptionHandling() {
- $entity = EntityTest::create(array('name' => 'test'));
+ $entity = EntityTest::create(['name' => 'test']);
try {
$GLOBALS['entity_test_throw_exception'] = TRUE;
$entity->save();
@@ -142,7 +142,7 @@ class EntityApiTest extends EntityKernelTestBase {
$this->assertEqual($e->getcode(), 1, 'Entity presave EntityStorageException caught.');
}
- $entity = EntityTest::create(array('name' => 'test2'));
+ $entity = EntityTest::create(['name' => 'test2']);
try {
unset($GLOBALS['entity_test_throw_exception']);
$entity->save();
@@ -152,7 +152,7 @@ class EntityApiTest extends EntityKernelTestBase {
$this->assertNotEqual($e->getCode(), 1, 'Entity presave EntityStorageException caught.');
}
- $entity = EntityTest::create(array('name' => 'test3'));
+ $entity = EntityTest::create(['name' => 'test3']);
$entity->save();
try {
$GLOBALS['entity_test_throw_exception'] = TRUE;
@@ -164,7 +164,7 @@ class EntityApiTest extends EntityKernelTestBase {
}
unset($GLOBALS['entity_test_throw_exception']);
- $entity = EntityTest::create(array('name' => 'test4'));
+ $entity = EntityTest::create(['name' => 'test4']);
$entity->save();
try {
$entity->delete();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php
index ae4925ce01c..3fed33c0519 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php
@@ -47,19 +47,19 @@ class EntityAutocompleteTest extends EntityKernelTestBase {
// Add an entity with a slash in its name.
$entity_1 = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => '10/16/2011'));
+ ->create(['name' => '10/16/2011']);
$entity_1->save();
// Add another entity that differs after the slash character.
$entity_2 = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => '10/17/2011'));
+ ->create(['name' => '10/17/2011']);
$entity_2->save();
// Add another entity that has both a comma, a slash and markup.
$entity_3 = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('name' => 'label with, and / test'));
+ ->create(['name' => 'label with, and / test']);
$entity_3->save();
// Try to autocomplete a entity label that matches both entities.
@@ -73,10 +73,10 @@ class EntityAutocompleteTest extends EntityKernelTestBase {
// We should only get the first entity in a JSON encoded string.
$input = '10/16';
$data = $this->getAutocompleteResult($input);
- $target = array(
+ $target = [
'value' => $entity_1->name->value . ' (1)',
'label' => Html::escape($entity_1->name->value),
- );
+ ];
$this->assertIdentical(reset($data), $target, 'Autocomplete returns only the expected matching entity.');
// Try to autocomplete a entity label that matches the second entity, and
@@ -91,10 +91,10 @@ class EntityAutocompleteTest extends EntityKernelTestBase {
$n = $entity_3->name->value . ' (3)';
// Entity labels containing commas or quotes must be wrapped in quotes.
$n = Tags::encode($n);
- $target = array(
+ $target = [
'value' => $n,
'label' => Html::escape($entity_3->name->value),
- );
+ ];
$this->assertIdentical(reset($data), $target, 'Autocomplete returns an entity label containing a comma and a slash.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php
index ec8fd1cfe46..ed30d4b56f4 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php
@@ -14,7 +14,7 @@ class EntityBundleFieldTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('entity_schema_test');
+ public static $modules = ['entity_schema_test'];
/**
* The module handler.
@@ -35,7 +35,7 @@ class EntityBundleFieldTest extends EntityKernelTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installSchema('user', array('users_data'));
+ $this->installSchema('user', ['users_data']);
$this->moduleHandler = $this->container->get('module_handler');
$this->database = $this->container->get('database');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
index 935fd7a2af7..8178cecf8b1 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
@@ -40,17 +40,17 @@ class EntityCrudHookTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('block', 'block_test', 'entity_crud_hook_test', 'file', 'taxonomy', 'node', 'comment');
+ public static $modules = ['block', 'block_test', 'entity_crud_hook_test', 'file', 'taxonomy', 'node', 'comment'];
- protected $ids = array();
+ protected $ids = [];
protected function setUp() {
parent::setUp();
- $this->installSchema('user', array('users_data'));
- $this->installSchema('file', array('file_usage'));
- $this->installSchema('node', array('node_access'));
- $this->installSchema('comment', array('comment_entity_statistics'));
+ $this->installSchema('user', ['users_data']);
+ $this->installSchema('file', ['file_usage']);
+ $this->installSchema('node', ['node_access']);
+ $this->installSchema('comment', ['comment_entity_statistics']);
$this->installConfig(['node', 'comment']);
}
@@ -64,7 +64,7 @@ class EntityCrudHookTest extends EntityKernelTestBase {
* An array of plain-text messages in the order they should appear.
*/
protected function assertHookMessageOrder($messages) {
- $positions = array();
+ $positions = [];
foreach ($messages as $message) {
// Verify that each message is found and record its position.
$position = array_search($message, $GLOBALS['entity_crud_hook_test']);
@@ -83,55 +83,55 @@ class EntityCrudHookTest extends EntityKernelTestBase {
* Tests hook invocations for CRUD operations on blocks.
*/
public function testBlockHooks() {
- $entity = Block::create(array(
+ $entity = Block::create([
'id' => 'stark_test_html',
'plugin' => 'test_html',
'theme' => 'stark',
- ));
+ ]);
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_block_create called',
'entity_crud_hook_test_entity_create called for type block',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$entity->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_block_presave called',
'entity_crud_hook_test_entity_presave called for type block',
'entity_crud_hook_test_block_insert called',
'entity_crud_hook_test_entity_insert called for type block',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$entity = Block::load($entity->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_entity_load called for type block',
'entity_crud_hook_test_block_load called',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$entity->label = 'New label';
$entity->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_block_presave called',
'entity_crud_hook_test_entity_presave called for type block',
'entity_crud_hook_test_block_update called',
'entity_crud_hook_test_entity_update called for type block',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$entity->delete();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_block_predelete called',
'entity_crud_hook_test_entity_predelete called for type block',
'entity_crud_hook_test_block_delete called',
'entity_crud_hook_test_entity_delete called for type block',
- ));
+ ]);
}
/**
@@ -158,9 +158,9 @@ class EntityCrudHookTest extends EntityKernelTestBase {
]);
$node->save();
$nid = $node->id();
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
- $comment = Comment::create(array(
+ $comment = Comment::create([
'cid' => NULL,
'pid' => 0,
'entity_id' => $nid,
@@ -172,51 +172,51 @@ class EntityCrudHookTest extends EntityKernelTestBase {
'changed' => REQUEST_TIME,
'status' => 1,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_comment_create called',
'entity_crud_hook_test_entity_create called for type comment',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$comment->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_comment_presave called',
'entity_crud_hook_test_entity_presave called for type comment',
'entity_crud_hook_test_comment_insert called',
'entity_crud_hook_test_entity_insert called for type comment',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$comment = Comment::load($comment->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_entity_load called for type comment',
'entity_crud_hook_test_comment_load called',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$comment->setSubject('New subject');
$comment->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_comment_presave called',
'entity_crud_hook_test_entity_presave called for type comment',
'entity_crud_hook_test_comment_update called',
'entity_crud_hook_test_entity_update called for type comment',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$comment->delete();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_comment_predelete called',
'entity_crud_hook_test_entity_predelete called for type comment',
'entity_crud_hook_test_comment_delete called',
'entity_crud_hook_test_entity_delete called for type comment',
- ));
+ ]);
}
/**
@@ -239,49 +239,49 @@ class EntityCrudHookTest extends EntityKernelTestBase {
'changed' => REQUEST_TIME,
]);
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_file_create called',
'entity_crud_hook_test_entity_create called for type file',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$file->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_file_presave called',
'entity_crud_hook_test_entity_presave called for type file',
'entity_crud_hook_test_file_insert called',
'entity_crud_hook_test_entity_insert called for type file',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$file = File::load($file->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_entity_load called for type file',
'entity_crud_hook_test_file_load called',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$file->setFilename('new.entity_crud_hook_test.file');
$file->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_file_presave called',
'entity_crud_hook_test_entity_presave called for type file',
'entity_crud_hook_test_file_update called',
'entity_crud_hook_test_entity_update called for type file',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$file->delete();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_file_predelete called',
'entity_crud_hook_test_entity_predelete called for type file',
'entity_crud_hook_test_file_delete called',
'entity_crud_hook_test_entity_delete called for type file',
- ));
+ ]);
}
/**
@@ -302,49 +302,49 @@ class EntityCrudHookTest extends EntityKernelTestBase {
'changed' => REQUEST_TIME,
]);
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_node_create called',
'entity_crud_hook_test_entity_create called for type node',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$node->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_node_presave called',
'entity_crud_hook_test_entity_presave called for type node',
'entity_crud_hook_test_node_insert called',
'entity_crud_hook_test_entity_insert called for type node',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$node = Node::load($node->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_entity_load called for type node',
'entity_crud_hook_test_node_load called',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$node->title = 'New title';
$node->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_node_presave called',
'entity_crud_hook_test_entity_presave called for type node',
'entity_crud_hook_test_node_update called',
'entity_crud_hook_test_entity_update called for type node',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$node->delete();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_node_predelete called',
'entity_crud_hook_test_entity_predelete called for type node',
'entity_crud_hook_test_node_delete called',
'entity_crud_hook_test_entity_delete called for type node',
- ));
+ ]);
}
/**
@@ -361,7 +361,7 @@ class EntityCrudHookTest extends EntityKernelTestBase {
'module' => 'entity_crud_hook_test',
]);
$vocabulary->save();
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$term = Term::create([
'vid' => $vocabulary->id(),
@@ -371,49 +371,49 @@ class EntityCrudHookTest extends EntityKernelTestBase {
'format' => 1,
]);
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_term_create called',
'entity_crud_hook_test_entity_create called for type taxonomy_term',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$term->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_term_presave called',
'entity_crud_hook_test_entity_presave called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_insert called',
'entity_crud_hook_test_entity_insert called for type taxonomy_term',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$term = Term::load($term->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_entity_load called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_load called',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$term->setName('New name');
$term->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_term_presave called',
'entity_crud_hook_test_entity_presave called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_update called',
'entity_crud_hook_test_entity_update called for type taxonomy_term',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$term->delete();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_term_predelete called',
'entity_crud_hook_test_entity_predelete called for type taxonomy_term',
'entity_crud_hook_test_taxonomy_term_delete called',
'entity_crud_hook_test_entity_delete called for type taxonomy_term',
- ));
+ ]);
}
/**
@@ -430,49 +430,49 @@ class EntityCrudHookTest extends EntityKernelTestBase {
'module' => 'entity_crud_hook_test',
]);
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_vocabulary_create called',
'entity_crud_hook_test_entity_create called for type taxonomy_vocabulary',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$vocabulary->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_vocabulary_presave called',
'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary',
'entity_crud_hook_test_taxonomy_vocabulary_insert called',
'entity_crud_hook_test_entity_insert called for type taxonomy_vocabulary',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$vocabulary = Vocabulary::load($vocabulary->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_entity_load called for type taxonomy_vocabulary',
'entity_crud_hook_test_taxonomy_vocabulary_load called',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$vocabulary->set('name', 'New name');
$vocabulary->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_vocabulary_presave called',
'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary',
'entity_crud_hook_test_taxonomy_vocabulary_update called',
'entity_crud_hook_test_entity_update called for type taxonomy_vocabulary',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$vocabulary->delete();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_taxonomy_vocabulary_predelete called',
'entity_crud_hook_test_entity_predelete called for type taxonomy_vocabulary',
'entity_crud_hook_test_taxonomy_vocabulary_delete called',
'entity_crud_hook_test_entity_delete called for type taxonomy_vocabulary',
- ));
+ ]);
}
/**
@@ -487,49 +487,49 @@ class EntityCrudHookTest extends EntityKernelTestBase {
'language' => 'en',
]);
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_user_create called',
'entity_crud_hook_test_entity_create called for type user',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$account->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_user_presave called',
'entity_crud_hook_test_entity_presave called for type user',
'entity_crud_hook_test_user_insert called',
'entity_crud_hook_test_entity_insert called for type user',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
User::load($account->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_entity_load called for type user',
'entity_crud_hook_test_user_load called',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
$account->name = 'New name';
$account->save();
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_user_presave called',
'entity_crud_hook_test_entity_presave called for type user',
'entity_crud_hook_test_user_update called',
'entity_crud_hook_test_entity_update called for type user',
- ));
+ ]);
- $GLOBALS['entity_crud_hook_test'] = array();
+ $GLOBALS['entity_crud_hook_test'] = [];
user_delete($account->id());
- $this->assertHookMessageOrder(array(
+ $this->assertHookMessageOrder([
'entity_crud_hook_test_user_predelete called',
'entity_crud_hook_test_entity_predelete called for type user',
'entity_crud_hook_test_user_delete called',
'entity_crud_hook_test_entity_delete called for type user',
- ));
+ ]);
}
/**
@@ -538,7 +538,7 @@ class EntityCrudHookTest extends EntityKernelTestBase {
function testEntityRollback() {
// Create a block.
try {
- EntityTest::create(array('name' => 'fail_insert'))->save();
+ EntityTest::create(['name' => 'fail_insert'])->save();
$this->fail('Expected exception has not been thrown.');
}
catch (\Exception $e) {
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php
index e49ee7ea92d..e37a4e0f89f 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php
@@ -49,7 +49,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// Install every entity type's schema that wasn't installed in the parent
// method.
- foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(array('user', 'entity_test'))) as $entity_type_id => $entity_type) {
+ foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(['user', 'entity_test'])) as $entity_type_id => $entity_type) {
$this->installEntitySchema($entity_type_id);
}
}
@@ -80,7 +80,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
public function testNoUpdates() {
// Ensure that the definition update manager reports no updates.
$this->assertFalse($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that no updates are needed.');
- $this->assertIdentical($this->entityDefinitionUpdateManager->getChangeSummary(), array(), 'EntityDefinitionUpdateManager reports an empty change summary.');
+ $this->assertIdentical($this->entityDefinitionUpdateManager->getChangeSummary(), [], 'EntityDefinitionUpdateManager reports an empty change summary.');
// Ensure that applyUpdates() runs without error (it's not expected to do
// anything when there aren't updates).
@@ -99,14 +99,14 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// reports that an update is needed.
$this->updateEntityTypeToRevisionable();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %entity_type entity type needs to be updated.', ['%entity_type' => $this->entityManager->getDefinition('entity_test_update')->getLabel()]),
// The revision key is now defined, so the revision field needs to be
// created.
t('The %field_name field needs to be installed.', ['%field_name' => 'Revision ID']),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected); //, 'EntityDefinitionUpdateManager reports the expected change summary.');
// Run the update and ensure the revision table is created.
@@ -141,11 +141,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// creates its schema.
$this->addBaseField();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %field_name field needs to be installed.', ['%field_name' => t('A new base field')]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertTrue($this->database->schema()->fieldExists('entity_test_update', 'new_base_field'), 'Column created in shared table for new_base_field.');
@@ -154,11 +154,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// and the update creates it.
$this->addBaseFieldIndex();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %field_name field needs to be updated.', ['%field_name' => t('A new base field')]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertTrue($this->database->schema()->indexExists('entity_test_update', 'entity_test_update_field__new_base_field'), 'Index created.');
@@ -167,11 +167,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// update deletes it.
$this->removeBaseFieldIndex();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %field_name field needs to be updated.', ['%field_name' => t('A new base field')]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertFalse($this->database->schema()->indexExists('entity_test_update', 'entity_test_update_field__new_base_field'), 'Index deleted.');
@@ -181,11 +181,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// accordingly.
$this->modifyBaseField();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %field_name field needs to be updated.', ['%field_name' => t('A new base field')]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertFalse($this->database->schema()->fieldExists('entity_test_update', 'new_base_field'), 'Original column deleted in shared table for new_base_field.');
@@ -196,11 +196,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// update deletes the schema.
$this->removeBaseField();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %field_name field needs to be uninstalled.', ['%field_name' => t('A new base field')]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertFalse($this->database->schema()->fieldExists('entity_test_update', 'new_base_field_value'), 'Value column deleted from shared table for new_base_field.');
@@ -215,11 +215,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// creates its schema.
$this->addBundleField();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %field_name field needs to be installed.', ['%field_name' => t('A new bundle field')]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertTrue($this->database->schema()->tableExists('entity_test_update__new_bundle_field'), 'Dedicated table created for new_bundle_field.');
@@ -229,11 +229,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// accordingly.
$this->modifyBundleField();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
+ $expected = [
'entity_test_update' => [
t('The %field_name field needs to be updated.', ['%field_name' => t('A new bundle field')]),
],
- );
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertTrue($this->database->schema()->fieldExists('entity_test_update__new_bundle_field', 'new_bundle_field_format'), 'Format column created in dedicated table for new_base_field.');
@@ -242,11 +242,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// update deletes the schema.
$this->removeBundleField();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %field_name field needs to be uninstalled.', ['%field_name' => t('A new bundle field')]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertFalse($this->database->schema()->tableExists('entity_test_update__new_bundle_field'), 'Dedicated table deleted for new_bundle_field.');
@@ -264,7 +264,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// Save an entity.
$name = $this->randomString();
$storage = $this->entityManager->getStorage('entity_test_update');
- $entity = $storage->create(array('name' => $name));
+ $entity = $storage->create(['name' => $name]);
$entity->save();
// Add a base field and run the update. Ensure the base field's column is
@@ -304,7 +304,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
$this->entityDefinitionUpdateManager->applyUpdates();
$assert = $schema_handler->fieldExists('entity_test_update', 'new_base_field__shape') && $schema_handler->fieldExists('entity_test_update', 'new_base_field__color');
$this->assertTrue($assert, 'Columns created again in shared table for new_base_field.');
- $entity = $storage->create(array('name' => $name));
+ $entity = $storage->create(['name' => $name]);
$entity->save();
$this->pass('The new_base_field columns are still nullable');
}
@@ -321,7 +321,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// Save an entity.
$name = $this->randomString();
$storage = $this->entityManager->getStorage('entity_test_update');
- $entity = $storage->create(array('name' => $name));
+ $entity = $storage->create(['name' => $name]);
$entity->save();
// Add a bundle field and run the update. Ensure the bundle field's table
@@ -345,7 +345,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
$this->addBundleField('shape_required');
$this->entityDefinitionUpdateManager->applyUpdates();
$message = 'The new_bundle_field_shape column is not nullable.';
- $values = array(
+ $values = [
'bundle' => $entity->bundle(),
'deleted' => 0,
'entity_id' => $entity->id(),
@@ -353,7 +353,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'delta' => 0,
'new_bundle_field_color' => $this->randomString(),
- );
+ ];
try {
// Try to insert a record without providing a value for the 'not null'
// column. This should fail.
@@ -388,7 +388,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
$this->entityDefinitionUpdateManager->applyUpdates();
// Save an entity with the base field populated.
- $this->entityManager->getStorage('entity_test_update')->create(array('new_base_field' => 'foo'))->save();
+ $this->entityManager->getStorage('entity_test_update')->create(['new_base_field' => 'foo'])->save();
// Remove the base field and apply updates. It's expected to throw an
// exception.
@@ -414,7 +414,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// Save an entity with the bundle field populated.
entity_test_create_bundle('custom');
- $this->entityManager->getStorage('entity_test_update')->create(array('type' => 'test_bundle', 'new_bundle_field' => 'foo'))->save();
+ $this->entityManager->getStorage('entity_test_update')->create(['type' => 'test_bundle', 'new_bundle_field' => 'foo'])->save();
// Remove the bundle field and apply updates. It's expected to throw an
// exception.
@@ -439,7 +439,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
$this->entityDefinitionUpdateManager->applyUpdates();
// Save an entity with the base field populated.
- $this->entityManager->getStorage('entity_test_update')->create(array('new_base_field' => 'foo'))->save();
+ $this->entityManager->getStorage('entity_test_update')->create(['new_base_field' => 'foo'])->save();
// Change the field's field type and apply updates. It's expected to
// throw an exception.
@@ -463,7 +463,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// Save an entity with the bundle field populated.
entity_test_create_bundle('custom');
- $this->entityManager->getStorage('entity_test_update')->create(array('type' => 'test_bundle', 'new_bundle_field' => 'foo'))->save();
+ $this->entityManager->getStorage('entity_test_update')->create(['type' => 'test_bundle', 'new_bundle_field' => 'foo'])->save();
// Change the field's field type and apply updates. It's expected to
// throw an exception.
@@ -485,11 +485,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// update to the entity type.
$this->addEntityIndex();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %entity_type entity type needs to be updated.', ['%entity_type' => $this->entityManager->getDefinition('entity_test_update')->getLabel()]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
// Run the update and ensure the new index is created.
@@ -500,11 +500,11 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// update to the entity type.
$this->removeEntityIndex();
$this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
- $expected = array(
- 'entity_test_update' => array(
+ $expected = [
+ 'entity_test_update' => [
t('The %entity_type entity type needs to be updated.', ['%entity_type' => $this->entityManager->getDefinition('entity_test_update')->getLabel()]),
- ),
- );
+ ],
+ ];
$this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.');
// Run the update and ensure the index is deleted.
@@ -530,7 +530,7 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
public function testEntityIndexCreateWithData() {
// Save an entity.
$name = $this->randomString();
- $entity = $this->entityManager->getStorage('entity_test_update')->create(array('name' => $name));
+ $entity = $this->entityManager->getStorage('entity_test_update')->create(['name' => $name]);
$entity->save();
// Add an entity index, run the update. Ensure that the index is created
@@ -732,13 +732,13 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
// Save an entity.
$name = $this->randomString();
$storage = $this->entityManager->getStorage('entity_test_update');
- $entity = $storage->create(array('name' => $name));
+ $entity = $storage->create(['name' => $name]);
$entity->save();
// Create an index.
- $indexes = array(
- 'entity_test_update__type_index' => array('type'),
- );
+ $indexes = [
+ 'entity_test_update__type_index' => ['type'],
+ ];
$this->state->set('entity_test_update.additional_entity_indexes', $indexes);
$this->entityDefinitionUpdateManager->applyUpdates();
$this->assertTrue($this->database->schema()->indexExists('entity_test_update', 'entity_test_update__type_index'), "New index 'entity_test_update__type_index' has been created on the 'entity_test_update' table.");
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
index c806409f5b5..c300b48e46a 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
@@ -47,9 +47,9 @@ class EntityFieldDefaultValueTest extends EntityKernelTestBase {
->create();
$definition = $this->entityManager->getDefinition($entity_type_id);
$langcode_key = $definition->getKey('langcode');
- $this->assertEqual($entity->{$langcode_key}->value, 'en', SafeMarkup::format('%entity_type: Default language', array('%entity_type' => $entity_type_id)));
- $this->assertTrue(Uuid::isValid($entity->uuid->value), SafeMarkup::format('%entity_type: Default UUID', array('%entity_type' => $entity_type_id)));
- $this->assertEqual($entity->name->getValue(), array(), 'Field has one empty value by default.');
+ $this->assertEqual($entity->{$langcode_key}->value, 'en', SafeMarkup::format('%entity_type: Default language', ['%entity_type' => $entity_type_id]));
+ $this->assertTrue(Uuid::isValid($entity->uuid->value), SafeMarkup::format('%entity_type: Default UUID', ['%entity_type' => $entity_type_id]));
+ $this->assertEqual($entity->name->getValue(), [], 'Field has one empty value by default.');
}
/**
@@ -60,16 +60,16 @@ class EntityFieldDefaultValueTest extends EntityKernelTestBase {
// The description field has a default value callback for testing, see
// entity_test_field_default_value().
$string = 'description_' . $entity->language()->getId();
- $expected = array(
- array(
+ $expected = [
+ [
'shape' => "shape:0:$string",
'color' => "color:0:$string",
- ),
- array(
+ ],
+ [
'shape' => "shape:1:$string",
'color' => "color:1:$string",
- ),
- );
+ ],
+ ];
$this->assertEqual($entity->description->getValue(), $expected);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
index 5dc1a948d35..e0bf6551ffe 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
@@ -31,7 +31,7 @@ class EntityFieldTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'text', 'node', 'user', 'field_test');
+ public static $modules = ['filter', 'text', 'node', 'user', 'field_test'];
/**
* @var string
@@ -63,7 +63,7 @@ class EntityFieldTest extends EntityKernelTestBase {
entity_test_install();
// Install required default configuration for filter module.
- $this->installConfig(array('system', 'filter'));
+ $this->installConfig(['system', 'filter']);
}
/**
@@ -112,108 +112,108 @@ class EntityFieldTest extends EntityKernelTestBase {
$langcode = 'en';
// Access the name field.
- $this->assertTrue($entity->name instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type)));
- $this->assertTrue($entity->name[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity->name instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', ['%entity_type' => $entity_type]));
+ $this->assertTrue($entity->name[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', ['%entity_type' => $entity_type]));
- $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityName, $entity->name[0]->value, format_string('%entity_type: Name value can be read through list access.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entityName)), format_string('%entity_type: Plain field value returned.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityName, $entity->name[0]->value, format_string('%entity_type: Name value can be read through list access.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->name->getValue(), [0 => ['value' => $this->entityName]], format_string('%entity_type: Plain field value returned.', ['%entity_type' => $entity_type]));
// Change the name.
$new_name = $this->randomMachineName();
$entity->name->value = $new_name;
- $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $new_name)), format_string('%entity_type: Plain field value reflects the update.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->name->getValue(), [0 => ['value' => $new_name]], format_string('%entity_type: Plain field value reflects the update.', ['%entity_type' => $entity_type]));
$new_name = $this->randomMachineName();
$entity->name[0]->value = $new_name;
- $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read through list access.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read through list access.', ['%entity_type' => $entity_type]));
// Access the user field.
- $this->assertTrue($entity->user_id instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type)));
- $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity->user_id instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', ['%entity_type' => $entity_type]));
+ $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', ['%entity_type' => $entity_type]));
- $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', ['%entity_type' => $entity_type]));
// Change the assigned user by entity.
$new_user1 = $this->createUser();
$entity->user_id->entity = $new_user1;
- $this->assertEqual($new_user1->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($new_user1->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($new_user1->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($new_user1->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', ['%entity_type' => $entity_type]));
// Change the assigned user by id.
$new_user2 = $this->createUser();
$entity->user_id->target_id = $new_user2->id();
- $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', ['%entity_type' => $entity_type]));
// Try unsetting a field property.
$entity->name->value = NULL;
$entity->user_id->target_id = NULL;
- $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', array('%entity_type' => $entity_type)));
- $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type)));
- $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type)));
+ $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', ['%entity_type' => $entity_type]));
+ $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', ['%entity_type' => $entity_type]));
+ $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', ['%entity_type' => $entity_type]));
// Test setting the values via the typed data API works as well.
// Change the assigned user by entity.
$entity->user_id->first()->get('entity')->setValue($new_user2);
- $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', ['%entity_type' => $entity_type]));
// Change the assigned user by id.
$entity->user_id->first()->get('target_id')->setValue($new_user2->id());
- $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', ['%entity_type' => $entity_type]));
// Try unsetting a field.
$entity->name->first()->get('value')->setValue(NULL);
$entity->user_id->first()->get('target_id')->setValue(NULL);
- $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', array('%entity_type' => $entity_type)));
- $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type)));
- $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type)));
+ $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', ['%entity_type' => $entity_type]));
+ $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', ['%entity_type' => $entity_type]));
+ $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', ['%entity_type' => $entity_type]));
// Create a fresh entity so target_id does not get its property object
// instantiated, then verify setting a new value via typed data API works.
$entity2 = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
- 'user_id' => array('target_id' => $new_user1->id()),
- ));
+ ->create([
+ 'user_id' => ['target_id' => $new_user1->id()],
+ ]);
// Access the property object, and set a value.
$entity2->user_id->first()->get('target_id')->setValue($new_user2->id());
- $this->assertEqual($new_user2->id(), $entity2->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($new_user2->name->value, $entity2->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($new_user2->id(), $entity2->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($new_user2->name->value, $entity2->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', ['%entity_type' => $entity_type]));
// Test using isset(), empty() and unset().
$entity->name->value = 'test unset';
unset($entity->name->value);
- $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
- $this->assertTrue(empty($entity->name->value), format_string('%entity_type: Name is empty.', array('%entity_type' => $entity_type)));
- $this->assertTrue(empty($entity->name[0]->value), format_string('%entity_type: Name is empty.', array('%entity_type' => $entity_type)));
+ $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type]));
+ $this->assertTrue(empty($entity->name->value), format_string('%entity_type: Name is empty.', ['%entity_type' => $entity_type]));
+ $this->assertTrue(empty($entity->name[0]->value), format_string('%entity_type: Name is empty.', ['%entity_type' => $entity_type]));
$entity->name->value = 'a value';
- $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
- $this->assertTrue(isset($entity->name[0]->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(empty($entity->name->value), format_string('%entity_type: Name is not empty.', array('%entity_type' => $entity_type)));
- $this->assertFalse(empty($entity->name[0]->value), format_string('%entity_type: Name is not empty.', array('%entity_type' => $entity_type)));
- $this->assertTrue(isset($entity->name[0]), format_string('%entity_type: Name string item is set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->name[1]), format_string('%entity_type: Second name string item is not set as it does not exist', array('%entity_type' => $entity_type)));
- $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->nameInvalid), format_string('%entity_type: Not existing field is not set.', array('%entity_type' => $entity_type)));
+ $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', ['%entity_type' => $entity_type]));
+ $this->assertTrue(isset($entity->name[0]->value), format_string('%entity_type: Name is set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(empty($entity->name->value), format_string('%entity_type: Name is not empty.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(empty($entity->name[0]->value), format_string('%entity_type: Name is not empty.', ['%entity_type' => $entity_type]));
+ $this->assertTrue(isset($entity->name[0]), format_string('%entity_type: Name string item is set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->name[1]), format_string('%entity_type: Second name string item is not set as it does not exist', ['%entity_type' => $entity_type]));
+ $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->nameInvalid), format_string('%entity_type: Not existing field is not set.', ['%entity_type' => $entity_type]));
unset($entity->name[0]);
- $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
+ $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type]));
// Test emptying a field by assigning an empty value. NULL and array()
// behave the same.
- foreach ([NULL, array(), 'unset'] as $empty) {
+ foreach ([NULL, [], 'unset'] as $empty) {
// Make sure a value is present
$entity->name->value = 'a value';
- $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type)));
+ $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', ['%entity_type' => $entity_type]));
// Now, empty the field.
if ($empty === 'unset') {
unset($entity->name);
@@ -221,36 +221,36 @@ class EntityFieldTest extends EntityKernelTestBase {
else {
$entity->name = $empty;
}
- $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
- $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type)));
- $this->assertIdentical(count($entity->name), 0, format_string('%entity_type: Name field contains no items.', array('%entity_type' => $entity_type)));
- $this->assertIdentical($entity->name->getValue(), array(), format_string('%entity_type: Name field value is an empty array.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: First name item value is not set.', array('%entity_type' => $entity_type)));
- $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name value is not set.', array('%entity_type' => $entity_type)));
+ $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', ['%entity_type' => $entity_type]));
+ $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is set.', ['%entity_type' => $entity_type]));
+ $this->assertIdentical(count($entity->name), 0, format_string('%entity_type: Name field contains no items.', ['%entity_type' => $entity_type]));
+ $this->assertIdentical($entity->name->getValue(), [], format_string('%entity_type: Name field value is an empty array.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: First name item value is not set.', ['%entity_type' => $entity_type]));
+ $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name value is not set.', ['%entity_type' => $entity_type]));
}
// Access the language field.
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
- $this->assertEqual($langcode, $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($langcode, $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type]));
// Change the language by code.
$entity->{$langcode_key}->value = \Drupal::languageManager()->getDefaultLanguage()->getId();
- $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type]));
// Revert language by code then try setting it by language object.
$entity->{$langcode_key}->value = $langcode;
$entity->{$langcode_key}->language = \Drupal::languageManager()->getDefaultLanguage();
- $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type]));
// Access the text field and test updating.
- $this->assertEqual($entity->field_test_text->value, $this->entityFieldText, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->field_test_text->value, $this->entityFieldText, format_string('%entity_type: Text field can be read.', ['%entity_type' => $entity_type]));
$new_text = $this->randomMachineName();
$entity->field_test_text->value = $new_text;
- $this->assertEqual($entity->field_test_text->value, $new_text, format_string('%entity_type: Updated text field can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->field_test_text->value, $new_text, format_string('%entity_type: Updated text field can be read.', ['%entity_type' => $entity_type]));
// Test creating the entity by passing in plain values.
$this->entityName = $this->randomMachineName();
@@ -262,98 +262,98 @@ class EntityFieldTest extends EntityKernelTestBase {
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => $name_item,
'user_id' => $user_item,
'field_test_text' => $text_item,
- ));
- $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
+ ]);
+ $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', ['%entity_type' => $entity_type]));
// Tests copying field values by assigning the TypedData objects.
$entity2 = $this->createTestEntity($entity_type);
$entity2->name = $entity->name;
$entity2->user_id = $entity->user_id;
$entity2->field_test_text = $entity->field_test_text;
- $this->assertFalse($entity->name === $entity2->name, format_string('%entity_type: Copying properties results in a different field object.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->name->value, $entity2->name->value, format_string('%entity_type: Name field copied.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->user_id->target_id, $entity2->user_id->target_id, format_string('%entity_type: User id field copied.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->field_test_text->value, $entity2->field_test_text->value, format_string('%entity_type: Text field copied.', array('%entity_type' => $entity_type)));
+ $this->assertFalse($entity->name === $entity2->name, format_string('%entity_type: Copying properties results in a different field object.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->name->value, $entity2->name->value, format_string('%entity_type: Name field copied.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->user_id->target_id, $entity2->user_id->target_id, format_string('%entity_type: User id field copied.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->field_test_text->value, $entity2->field_test_text->value, format_string('%entity_type: Text field copied.', ['%entity_type' => $entity_type]));
// Tests that assigning TypedData objects to non-field properties keeps the
// assigned value as is.
$entity2 = $this->createTestEntity($entity_type);
$entity2->_not_a_field = $entity->name;
- $this->assertTrue($entity2->_not_a_field === $entity->name, format_string('%entity_type: Typed data objects can be copied to non-field properties as is.', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity2->_not_a_field === $entity->name, format_string('%entity_type: Typed data objects can be copied to non-field properties as is.', ['%entity_type' => $entity_type]));
// Tests adding a value to a field item list.
$entity->name[] = 'Another name';
- $this->assertEqual($entity->name[1]->value, 'Another name', format_string('%entity_type: List item added via [] and the first property.', array('%entity_type' => $entity_type)));
- $entity->name[] = array('value' => 'Third name');
- $this->assertEqual($entity->name[2]->value, 'Third name', format_string('%entity_type: List item added via [] and an array of properties.', array('%entity_type' => $entity_type)));
- $entity->name[3] = array('value' => 'Fourth name');
- $this->assertEqual($entity->name[3]->value, 'Fourth name', format_string('%entity_type: List item added via offset and an array of properties.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->name[1]->value, 'Another name', format_string('%entity_type: List item added via [] and the first property.', ['%entity_type' => $entity_type]));
+ $entity->name[] = ['value' => 'Third name'];
+ $this->assertEqual($entity->name[2]->value, 'Third name', format_string('%entity_type: List item added via [] and an array of properties.', ['%entity_type' => $entity_type]));
+ $entity->name[3] = ['value' => 'Fourth name'];
+ $this->assertEqual($entity->name[3]->value, 'Fourth name', format_string('%entity_type: List item added via offset and an array of properties.', ['%entity_type' => $entity_type]));
unset($entity->name[3]);
// Test removing and empty-ing list items.
- $this->assertEqual(count($entity->name), 3, format_string('%entity_type: List has 3 items.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entity->name), 3, format_string('%entity_type: List has 3 items.', ['%entity_type' => $entity_type]));
unset($entity->name[1]);
- $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Second list item has been removed.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->name[1]->value, 'Third name', format_string('%entity_type: The subsequent items have been shifted up.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->name[1]->getName(), 1, format_string('%entity_type: The items names have been updated to their new delta.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Second list item has been removed.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->name[1]->value, 'Third name', format_string('%entity_type: The subsequent items have been shifted up.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->name[1]->getName(), 1, format_string('%entity_type: The items names have been updated to their new delta.', ['%entity_type' => $entity_type]));
$entity->name[1] = NULL;
- $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Assigning NULL does not reduce array count.', array('%entity_type' => $entity_type)));
- $this->assertTrue($entity->name[1]->isEmpty(), format_string('%entity_type: Assigning NULL empties the item.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Assigning NULL does not reduce array count.', ['%entity_type' => $entity_type]));
+ $this->assertTrue($entity->name[1]->isEmpty(), format_string('%entity_type: Assigning NULL empties the item.', ['%entity_type' => $entity_type]));
// Test using isEmpty().
unset($entity->name[1]);
- $this->assertFalse($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is not empty.', array('%entity_type' => $entity_type)));
+ $this->assertFalse($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is not empty.', ['%entity_type' => $entity_type]));
$entity->name->value = NULL;
- $this->assertTrue($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is empty.', array('%entity_type' => $entity_type)));
- $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is empty.', array('%entity_type' => $entity_type)));
- $this->assertEqual(count($entity->name), 1, format_string('%entity_type: Empty item is considered when counting.', array('%entity_type' => $entity_type)));
- $this->assertEqual(count(iterator_to_array($entity->name->getIterator())), count($entity->name), format_string('%entity_type: Count matches iterator count.', array('%entity_type' => $entity_type)));
- $this->assertTrue($entity->name->getValue() === array(0 => array('value' => NULL)), format_string('%entity_type: Name field value contains a NULL value.', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is empty.', ['%entity_type' => $entity_type]));
+ $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is empty.', ['%entity_type' => $entity_type]));
+ $this->assertEqual(count($entity->name), 1, format_string('%entity_type: Empty item is considered when counting.', ['%entity_type' => $entity_type]));
+ $this->assertEqual(count(iterator_to_array($entity->name->getIterator())), count($entity->name), format_string('%entity_type: Count matches iterator count.', ['%entity_type' => $entity_type]));
+ $this->assertTrue($entity->name->getValue() === [0 => ['value' => NULL]], format_string('%entity_type: Name field value contains a NULL value.', ['%entity_type' => $entity_type]));
// Test using filterEmptyItems().
- $entity->name = array(NULL, 'foo');
- $this->assertEqual(count($entity->name), 2, format_string('%entity_type: List has 2 items.', array('%entity_type' => $entity_type)));
+ $entity->name = [NULL, 'foo'];
+ $this->assertEqual(count($entity->name), 2, format_string('%entity_type: List has 2 items.', ['%entity_type' => $entity_type]));
$entity->name->filterEmptyItems();
- $this->assertEqual(count($entity->name), 1, format_string('%entity_type: The empty item was removed.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->name[0]->value, 'foo', format_string('%entity_type: The items were renumbered.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity->name[0]->getName(), 0, format_string('%entity_type: The deltas were updated in the items.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entity->name), 1, format_string('%entity_type: The empty item was removed.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->name[0]->value, 'foo', format_string('%entity_type: The items were renumbered.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity->name[0]->getName(), 0, format_string('%entity_type: The deltas were updated in the items.', ['%entity_type' => $entity_type]));
// Test get and set field values.
$entity->name = 'foo';
- $this->assertEqual($entity->name[0]->toArray(), array('value' => 'foo'), format_string('%entity_type: Field value has been retrieved via toArray()', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->name[0]->toArray(), ['value' => 'foo'], format_string('%entity_type: Field value has been retrieved via toArray()', ['%entity_type' => $entity_type]));
$values = $entity->toArray();
- $this->assertEqual($values['name'], array(0 => array('value' => 'foo')), format_string('%entity_type: Field value has been retrieved via toArray() from an entity.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($values['name'], [0 => ['value' => 'foo']], format_string('%entity_type: Field value has been retrieved via toArray() from an entity.', ['%entity_type' => $entity_type]));
// Make sure the user id can be set to zero.
$user_item[0]['target_id'] = 0;
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => $name_item,
'user_id' => $user_item,
'field_test_text' => $text_item,
- ));
- $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type)));
- $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type)));
+ ]);
+ $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', ['%entity_type' => $entity_type]));
+ $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', ['%entity_type' => $entity_type]));
// Test setting the ID with the value only.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => $name_item,
'user_id' => 0,
'field_test_text' => $text_item,
- ));
- $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type)));
- $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type)));
+ ]);
+ $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', ['%entity_type' => $entity_type]));
+ $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', ['%entity_type' => $entity_type]));
}
/**
@@ -376,21 +376,21 @@ class EntityFieldTest extends EntityKernelTestBase {
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$entity = $this->createTestEntity($entity_type);
$entity->save();
- $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity has received an id.', array('%entity_type' => $entity_type)));
+ $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity has received an id.', ['%entity_type' => $entity_type]));
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->load($entity->id());
- $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity loaded.', array('%entity_type' => $entity_type)));
+ $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity loaded.', ['%entity_type' => $entity_type]));
// Access the name field.
- $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', array('%entity_type' => $entity_type)));
- $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual('en', $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', ['%entity_type' => $entity_type]));
+ $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual('en', $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', ['%entity_type' => $entity_type]));
}
/**
@@ -532,8 +532,8 @@ class EntityFieldTest extends EntityKernelTestBase {
}
$fields = $entity->getFields();
- $this->assertEqual(array_keys($fields), array_keys($entity->getTypedData()->getDataDefinition()->getPropertyDefinitions()), format_string('%entity_type: All fields returned.', array('%entity_type' => $entity_type)));
- $this->assertEqual($fields, iterator_to_array($entity->getIterator()), format_string('%entity_type: Entity iterator iterates over all fields.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(array_keys($fields), array_keys($entity->getTypedData()->getDataDefinition()->getPropertyDefinitions()), format_string('%entity_type: All fields returned.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($fields, iterator_to_array($entity->getIterator()), format_string('%entity_type: Entity iterator iterates over all fields.', ['%entity_type' => $entity_type]));
}
/**
@@ -558,12 +558,12 @@ class EntityFieldTest extends EntityKernelTestBase {
// Test using the whole tree of typed data by navigating through the tree of
// contained properties and getting all contained strings, limited by a
// certain depth.
- $strings = array();
+ $strings = [];
$this->getContainedStrings($entity->getTypedData(), 0, $strings);
// @todo: Once the user entity has defined properties this should contain
// the user name and other user entity strings as well.
- $target_strings = array(
+ $target_strings = [
$entity->uuid->value,
'en',
$this->entityName,
@@ -572,7 +572,7 @@ class EntityFieldTest extends EntityKernelTestBase {
$this->entityFieldText,
// Field format.
NULL,
- );
+ ];
if ($entity instanceof RevisionLogInterface) {
// Adding empty string for revision message.
@@ -581,7 +581,7 @@ class EntityFieldTest extends EntityKernelTestBase {
asort($strings);
asort($target_strings);
- $this->assertEqual(array_values($strings), array_values($target_strings), format_string('%entity_type: All contained strings found.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(array_values($strings), array_values($target_strings), format_string('%entity_type: All contained strings found.', ['%entity_type' => $entity_type]));
}
/**
@@ -629,10 +629,10 @@ class EntityFieldTest extends EntityKernelTestBase {
* @see entity_test_entity_base_field_info_alter()
*/
public function testBaseFieldNonExistingBaseField() {
- $this->entityManager->getStorage('node_type')->create(array(
+ $this->entityManager->getStorage('node_type')->create([
'type' => 'page',
'name' => 'page',
- ))->save();
+ ])->save();
$this->entityManager->clearCachedFieldDefinitions();
$fields = $this->entityManager->getFieldDefinitions('node', 'page');
$override = $fields['status']->getConfig('page');
@@ -686,7 +686,7 @@ class EntityFieldTest extends EntityKernelTestBase {
->setLabel('Test entity')
->setSetting('target_type', 'entity_test');
$reference_field = \Drupal::typedDataManager()->create($definition);
- $reference = $reference_field->appendItem(array('entity' => $entity))->get('entity');
+ $reference = $reference_field->appendItem(['entity' => $entity])->get('entity');
// Test validation the typed data object.
$violations = $reference->validate();
@@ -705,14 +705,14 @@ class EntityFieldTest extends EntityKernelTestBase {
$this->assertEqual($violations->count(), 1);
// Test bundle validation.
- NodeType::create(array('type' => 'article'))
+ NodeType::create(['type' => 'article'])
->save();
$definition = BaseFieldDefinition::create('entity_reference')
->setLabel('Test entity')
->setSetting('target_type', 'node')
->setSetting('handler_settings', ['target_bundles' => ['article' => 'article']]);
$reference_field = \Drupal::TypedDataManager()->create($definition);
- $reference_field->appendItem(array('entity' => $node));
+ $reference_field->appendItem(['entity' => $node]);
$violations = $reference_field->validate();
$this->assertEqual($violations->count(), 1);
@@ -749,14 +749,14 @@ class EntityFieldTest extends EntityKernelTestBase {
$entity->field_test_text->format = filter_default_format();
$target = "<p>The &lt;strong&gt;text&lt;/strong&gt; text to filter.</p>\n";
- $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', ['%entity_type' => $entity_type]));
// Save and load entity and make sure it still works.
$entity->save();
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->load($entity->id());
- $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', ['%entity_type' => $entity_type]));
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php
index 4b08a56f82a..f7108d53b17 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php
@@ -31,7 +31,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
*
* @var array
*/
- protected $generatedIds = array();
+ protected $generatedIds = [];
/**
* The state service.
@@ -62,7 +62,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
// Only check the modules, if the $modules property was not inherited.
$rp = new \ReflectionProperty($class, 'modules');
if ($rp->class == $class) {
- foreach (array_intersect(array('node', 'comment'), $class::$modules) as $module) {
+ foreach (array_intersect(['node', 'comment'], $class::$modules) as $module) {
$this->installEntitySchema($module);
}
if (in_array('forum', $class::$modules, TRUE)) {
@@ -79,7 +79,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
$class = get_parent_class($class);
}
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
}
/**
@@ -93,22 +93,22 @@ abstract class EntityKernelTestBase extends KernelTestBase {
* @return \Drupal\user\Entity\User
* The created user entity.
*/
- protected function createUser($values = array(), $permissions = array()) {
+ protected function createUser($values = [], $permissions = []) {
if ($permissions) {
// Create a new role and apply permissions to it.
- $role = Role::create(array(
+ $role = Role::create([
'id' => strtolower($this->randomMachineName(8)),
'label' => $this->randomMachineName(8),
- ));
+ ]);
$role->save();
user_role_grant_permissions($role->id(), $permissions);
$values['roles'][] = $role->id();
}
- $account = User::create($values + array(
+ $account = User::create($values + [
'name' => $this->randomMachineName(),
'status' => 1,
- ));
+ ]);
$account->enforceIsNew();
$account->save();
return $account;
@@ -125,7 +125,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
*/
protected function reloadEntity(EntityInterface $entity) {
$controller = $this->entityManager->getStorage($entity->getEntityTypeId());
- $controller->resetCache(array($entity->id()));
+ $controller->resetCache([$entity->id()]);
return $controller->load($entity->id());
}
@@ -138,7 +138,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
protected function getHooksInfo() {
$key = 'entity_test.hooks';
$hooks = $this->state->get($key);
- $this->state->set($key, array());
+ $this->state->set($key, []);
return $hooks;
}
@@ -149,7 +149,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
* The module to install.
*/
protected function installModule($module) {
- $this->enableModules(array($module));
+ $this->enableModules([$module]);
$this->refreshServices();
}
@@ -160,7 +160,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
* The module to uninstall.
*/
protected function uninstallModule($module) {
- $this->disableModules(array($module));
+ $this->disableModules([$module]);
$this->refreshServices();
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php
index 59510bac248..570aa984465 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php
@@ -40,7 +40,7 @@ abstract class EntityLanguageTestBase extends EntityKernelTestBase {
*/
protected $untranslatableFieldName;
- public static $modules = array('language', 'entity_test');
+ public static $modules = ['language', 'entity_test'];
protected function setUp() {
parent::setUp();
@@ -54,7 +54,7 @@ abstract class EntityLanguageTestBase extends EntityKernelTestBase {
}
}
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
// Create the test field.
module_load_install('entity_test');
@@ -71,12 +71,12 @@ abstract class EntityLanguageTestBase extends EntityKernelTestBase {
// Create field fields in all entity variations.
foreach (entity_test_entity_types() as $entity_type) {
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $entity_type,
'type' => 'text',
'cardinality' => 4,
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $entity_type,
@@ -84,12 +84,12 @@ abstract class EntityLanguageTestBase extends EntityKernelTestBase {
'translatable' => TRUE,
])->save();
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $this->untranslatableFieldName,
'entity_type' => $entity_type,
'type' => 'text',
'cardinality' => 4,
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $this->untranslatableFieldName,
'entity_type' => $entity_type,
@@ -99,16 +99,16 @@ abstract class EntityLanguageTestBase extends EntityKernelTestBase {
}
// Create the default languages.
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
// Create test languages.
- $this->langcodes = array();
+ $this->langcodes = [];
for ($i = 0; $i < 3; ++$i) {
- $language = ConfigurableLanguage::create(array(
+ $language = ConfigurableLanguage::create([
'id' => 'l' . $i,
'label' => $this->randomString(),
'weight' => $i,
- ));
+ ]);
$this->langcodes[$i] = $language->getId();
$language->save();
}
@@ -121,7 +121,7 @@ abstract class EntityLanguageTestBase extends EntityKernelTestBase {
* The type of the entity fields are attached to.
*/
protected function toggleFieldTranslatability($entity_type, $bundle) {
- $fields = array($this->fieldName, $this->untranslatableFieldName);
+ $fields = [$this->fieldName, $this->untranslatableFieldName];
foreach ($fields as $field_name) {
$field = FieldConfig::loadByName($entity_type, $bundle, $field_name);
$translatable = !$field->isTranslatable();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php
index da6ec6644c4..bab52b0fe32 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php
@@ -14,7 +14,7 @@ class EntityNonRevisionableTranslatableFieldTest extends EntityKernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('entity_test', 'language', 'content_translation');
+ public static $modules = ['entity_test', 'language', 'content_translation'];
protected function setUp() {
parent::setUp();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
index 819445d152e..b6362fbcae6 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
@@ -18,7 +18,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array();
+ public static $modules = [];
/**
* The entity_test storage to create the test entities.
@@ -50,12 +50,12 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
// Add some fieldapi fields to be used in the test.
for ($i = 1; $i <= 2; $i++) {
$field_name = 'field_test_' . $i;
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'integer',
'cardinality' => 2,
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
@@ -63,53 +63,53 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
])->save();
}
- $entity = $this->entityStorage->create(array(
+ $entity = $this->entityStorage->create([
'id' => 1,
'user_id' => 1,
'field_test_1' => 1,
'field_test_2' => 2,
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
- $entity = $this->entityStorage->create(array(
+ $entity = $this->entityStorage->create([
'id' => 2,
'user_id' => 2,
'field_test_1' => 1,
'field_test_2' => 7,
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
- $entity = $this->entityStorage->create(array(
+ $entity = $this->entityStorage->create([
'id' => 3,
'user_id' => 2,
'field_test_1' => 2,
'field_test_2' => 1,
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
- $entity = $this->entityStorage->create(array(
+ $entity = $this->entityStorage->create([
'id' => 4,
'user_id' => 2,
'field_test_1' => 2,
'field_test_2' => 8,
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
- $entity = $this->entityStorage->create(array(
+ $entity = $this->entityStorage->create([
'id' => 5,
'user_id' => 3,
'field_test_1' => 2,
'field_test_2' => 2,
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
- $entity = $this->entityStorage->create(array(
+ $entity = $this->entityStorage->create([
'id' => 6,
'user_id' => 3,
'field_test_1' => 3,
'field_test_2' => 8,
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
@@ -124,18 +124,18 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 1),
- array('user_id' => 2),
- array('user_id' => 3),
- ));
+ $this->assertResults([
+ ['user_id' => 1],
+ ['user_id' => 2],
+ ['user_id' => 3],
+ ]);
- $function_expected = array();
- $function_expected['count'] = array(array('id_count' => 6));
- $function_expected['min'] = array(array('id_min' => 1));
- $function_expected['max'] = array(array('id_max' => 6));
- $function_expected['sum'] = array(array('id_sum' => 21));
- $function_expected['avg'] = array(array('id_avg' => (21.0 / 6.0)));
+ $function_expected = [];
+ $function_expected['count'] = [['id_count' => 6]];
+ $function_expected['min'] = [['id_min' => 1]];
+ $function_expected['max'] = [['id_max' => 6]];
+ $function_expected['sum'] = [['id_sum' => 21]];
+ $function_expected['avg'] = [['id_avg' => (21.0 / 6.0)]];
// Apply a simple aggregation for different aggregation functions.
foreach ($function_expected as $aggregation_function => $expected) {
@@ -150,11 +150,11 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->aggregate('id', 'COUNT')
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 1, 'id_count' => 1),
- array('user_id' => 2, 'id_count' => 3),
- array('user_id' => 3, 'id_count' => 2),
- ));
+ $this->assertResults([
+ ['user_id' => 1, 'id_count' => 1],
+ ['user_id' => 2, 'id_count' => 3],
+ ['user_id' => 3, 'id_count' => 2],
+ ]);
// Apply aggregation and a condition which matches.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -162,14 +162,14 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('id')
->conditionAggregate('id', 'COUNT', 8)
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
// Don't call aggregate to test the implicit aggregate call.
$this->queryResult = $this->factory->getAggregate('entity_test')
->groupBy('id')
->conditionAggregate('id', 'COUNT', 8)
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
// Apply aggregation and a condition which matches.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -177,7 +177,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('id')
->conditionAggregate('id', 'COUNT', 6)
->execute();
- $this->assertResults(array(array('id_count' => 6)));
+ $this->assertResults([['id_count' => 6]]);
// Apply aggregation, a groupby and a condition which matches partially via
// the operator '='.
@@ -186,7 +186,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->conditionAggregate('id', 'count', 2)
->groupBy('user_id')
->execute();
- $this->assertResults(array(array('id_count' => 2, 'user_id' => 3)));
+ $this->assertResults([['id_count' => 2, 'user_id' => 3]]);
// Apply aggregation, a groupby and a condition which matches partially via
// the operator '>'.
@@ -195,10 +195,10 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->conditionAggregate('id', 'COUNT', 1, '>')
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('id_count' => 2, 'user_id' => 3),
- array('id_count' => 3, 'user_id' => 2),
- ));
+ $this->assertResults([
+ ['id_count' => 2, 'user_id' => 3],
+ ['id_count' => 3, 'user_id' => 2],
+ ]);
// Apply aggregation and a sort. This might not be useful, but have a proper
// test coverage.
@@ -206,13 +206,13 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->aggregate('id', 'COUNT')
->sortAggregate('id', 'COUNT')
->execute();
- $this->assertSortedResults(array(array('id_count' => 6)));
+ $this->assertSortedResults([['id_count' => 6]]);
// Don't call aggregate to test the implicit aggregate call.
$this->queryResult = $this->factory->getAggregate('entity_test')
->sortAggregate('id', 'COUNT')
->execute();
- $this->assertSortedResults(array(array('id_count' => 6)));
+ $this->assertSortedResults([['id_count' => 6]]);
// Apply aggregation, groupby and a sort descending.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -220,11 +220,11 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('user_id')
->sortAggregate('id', 'COUNT', 'DESC')
->execute();
- $this->assertSortedResults(array(
- array('user_id' => 2, 'id_count' => 3),
- array('user_id' => 3, 'id_count' => 2),
- array('user_id' => 1, 'id_count' => 1),
- ));
+ $this->assertSortedResults([
+ ['user_id' => 2, 'id_count' => 3],
+ ['user_id' => 3, 'id_count' => 2],
+ ['user_id' => 1, 'id_count' => 1],
+ ]);
// Apply aggregation, groupby and a sort ascending.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -232,11 +232,11 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('user_id')
->sortAggregate('id', 'COUNT', 'ASC')
->execute();
- $this->assertSortedResults(array(
- array('user_id' => 1, 'id_count' => 1),
- array('user_id' => 3, 'id_count' => 2),
- array('user_id' => 2, 'id_count' => 3),
- ));
+ $this->assertSortedResults([
+ ['user_id' => 1, 'id_count' => 1],
+ ['user_id' => 3, 'id_count' => 2],
+ ['user_id' => 2, 'id_count' => 3],
+ ]);
// Apply aggregation, groupby, an aggregation condition and a sort with the
// operator '='.
@@ -246,7 +246,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->sortAggregate('id', 'COUNT')
->conditionAggregate('id', 'COUNT', 2)
->execute();
- $this->assertSortedResults(array(array('id_count' => 2, 'user_id' => 3)));
+ $this->assertSortedResults([['id_count' => 2, 'user_id' => 3]]);
// Apply aggregation, groupby, an aggregation condition and a sort with the
// operator '<' and order ASC.
@@ -256,10 +256,10 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->sortAggregate('id', 'COUNT', 'ASC')
->conditionAggregate('id', 'COUNT', 3, '<')
->execute();
- $this->assertSortedResults(array(
- array('id_count' => 1, 'user_id' => 1),
- array('id_count' => 2, 'user_id' => 3),
- ));
+ $this->assertSortedResults([
+ ['id_count' => 1, 'user_id' => 1],
+ ['id_count' => 2, 'user_id' => 3],
+ ]);
// Apply aggregation, groupby, an aggregation condition and a sort with the
// operator '<' and order DESC.
@@ -269,10 +269,10 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->sortAggregate('id', 'COUNT', 'DESC')
->conditionAggregate('id', 'COUNT', 3, '<')
->execute();
- $this->assertSortedResults(array(
- array('id_count' => 2, 'user_id' => 3),
- array('id_count' => 1, 'user_id' => 1),
- ));
+ $this->assertSortedResults([
+ ['id_count' => 2, 'user_id' => 3],
+ ['id_count' => 1, 'user_id' => 1],
+ ]);
// Test aggregation/groupby support for fieldapi fields.
@@ -280,11 +280,11 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
$this->queryResult = $this->factory->getAggregate('entity_test')
->groupBy('field_test_1')
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1),
- array('field_test_1' => 2),
- array('field_test_1' => 3),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1],
+ ['field_test_1' => 2],
+ ['field_test_1' => 3],
+ ]);
// Group by a fieldapi field and aggregate a normal property.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -292,11 +292,11 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('field_test_1')
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'user_id_count' => 2),
- array('field_test_1' => 2, 'user_id_count' => 3),
- array('field_test_1' => 3, 'user_id_count' => 1),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'user_id_count' => 2],
+ ['field_test_1' => 2, 'user_id_count' => 3],
+ ['field_test_1' => 3, 'user_id_count' => 1],
+ ]);
// Group by a normal property and aggregate a fieldapi field.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -304,21 +304,21 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 1, 'field_test_1_count' => 1),
- array('user_id' => 2, 'field_test_1_count' => 3),
- array('user_id' => 3, 'field_test_1_count' => 2),
- ));
+ $this->assertResults([
+ ['user_id' => 1, 'field_test_1_count' => 1],
+ ['user_id' => 2, 'field_test_1_count' => 3],
+ ['user_id' => 3, 'field_test_1_count' => 2],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->aggregate('field_test_1', 'SUM')
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 1, 'field_test_1_sum' => 1),
- array('user_id' => 2, 'field_test_1_sum' => 5),
- array('user_id' => 3, 'field_test_1_sum' => 5),
- ));
+ $this->assertResults([
+ ['user_id' => 1, 'field_test_1_sum' => 1],
+ ['user_id' => 2, 'field_test_1_sum' => 5],
+ ['user_id' => 3, 'field_test_1_sum' => 5],
+ ]);
// Aggregate by two different fieldapi fields.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -326,11 +326,11 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->aggregate('field_test_2', 'SUM')
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 1, 'field_test_1_sum' => 1, 'field_test_2_sum' => 2),
- array('user_id' => 2, 'field_test_1_sum' => 5, 'field_test_2_sum' => 16),
- array('user_id' => 3, 'field_test_1_sum' => 5, 'field_test_2_sum' => 10),
- ));
+ $this->assertResults([
+ ['user_id' => 1, 'field_test_1_sum' => 1, 'field_test_2_sum' => 2],
+ ['user_id' => 2, 'field_test_1_sum' => 5, 'field_test_2_sum' => 16],
+ ['user_id' => 3, 'field_test_1_sum' => 5, 'field_test_2_sum' => 10],
+ ]);
// This time aggregate the same field twice.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -338,22 +338,22 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->aggregate('field_test_1', 'COUNT')
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 1, 'field_test_1_sum' => 1, 'field_test_1_count' => 1),
- array('user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3),
- array('user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2),
- ));
+ $this->assertResults([
+ ['user_id' => 1, 'field_test_1_sum' => 1, 'field_test_1_count' => 1],
+ ['user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3],
+ ['user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2],
+ ]);
// Group by and aggregate by a fieldapi field.
$this->queryResult = $this->factory->getAggregate('entity_test')
->groupBy('field_test_1')
->aggregate('field_test_2', 'COUNT')
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'field_test_2_count' => 2),
- array('field_test_1' => 2, 'field_test_2_count' => 3),
- array('field_test_1' => 3, 'field_test_2_count' => 1),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'field_test_2_count' => 2],
+ ['field_test_1' => 2, 'field_test_2_count' => 3],
+ ['field_test_1' => 3, 'field_test_2_count' => 1],
+ ]);
// Group by and aggregate by a fieldapi field and use multiple aggregate
// functions.
@@ -362,11 +362,11 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->aggregate('field_test_2', 'COUNT')
->aggregate('field_test_2', 'SUM')
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9),
- array('field_test_1' => 2, 'field_test_2_count' => 3, 'field_test_2_sum' => 11),
- array('field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9],
+ ['field_test_1' => 2, 'field_test_2_count' => 3, 'field_test_2_sum' => 11],
+ ['field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8],
+ ]);
// Apply an aggregate condition for a fieldapi field and group by a simple
// property.
@@ -374,20 +374,20 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->conditionAggregate('field_test_1', 'COUNT', 3)
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 2, 'field_test_1_count' => 3),
- array('user_id' => 3, 'field_test_1_count' => 2),
- ));
+ $this->assertResults([
+ ['user_id' => 2, 'field_test_1_count' => 3],
+ ['user_id' => 3, 'field_test_1_count' => 2],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->aggregate('field_test_1', 'SUM')
->conditionAggregate('field_test_1', 'COUNT', 2, '>')
->groupBy('user_id')
->execute();
- $this->assertResults(array(
- array('user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3),
- array('user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2),
- ));
+ $this->assertResults([
+ ['user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3],
+ ['user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2],
+ ]);
// Apply an aggregate condition for a simple property and a group by a
// fieldapi field.
@@ -395,35 +395,35 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->conditionAggregate('user_id', 'COUNT', 2)
->groupBy('field_test_1')
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'user_id_count' => 2),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'user_id_count' => 2],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->conditionAggregate('user_id', 'COUNT', 2, '>')
->groupBy('field_test_1')
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'user_id_count' => 2),
- array('field_test_1' => 2, 'user_id_count' => 3),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'user_id_count' => 2],
+ ['field_test_1' => 2, 'user_id_count' => 3],
+ ]);
// Apply an aggregate condition and a group by fieldapi fields.
$this->queryResult = $this->factory->getAggregate('entity_test')
->groupBy('field_test_1')
->conditionAggregate('field_test_2', 'COUNT', 2)
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'field_test_2_count' => 2),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'field_test_2_count' => 2],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->groupBy('field_test_1')
->conditionAggregate('field_test_2', 'COUNT', 2, '>')
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'field_test_2_count' => 2),
- array('field_test_1' => 2, 'field_test_2_count' => 3),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'field_test_2_count' => 2],
+ ['field_test_1' => 2, 'field_test_2_count' => 3],
+ ]);
// Apply an aggregate condition and a group by fieldapi fields with multiple
// conditions via AND.
@@ -432,7 +432,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->conditionAggregate('field_test_2', 'COUNT', 2)
->conditionAggregate('field_test_2', 'SUM', 8)
->execute();
- $this->assertResults(array());
+ $this->assertResults([]);
// Apply an aggregate condition and a group by fieldapi fields with multiple
// conditions via OR.
@@ -441,10 +441,10 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->conditionAggregate('field_test_2', 'COUNT', 2)
->conditionAggregate('field_test_2', 'SUM', 8)
->execute();
- $this->assertResults(array(
- array('field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9),
- array('field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8),
- ));
+ $this->assertResults([
+ ['field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9],
+ ['field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8],
+ ]);
// Group by a normal property and aggregate a fieldapi field and sort by the
// groupby field.
@@ -453,32 +453,32 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('user_id')
->sort('user_id', 'DESC')
->execute();
- $this->assertSortedResults(array(
- array('user_id' => 3, 'field_test_1_count' => 2),
- array('user_id' => 2, 'field_test_1_count' => 3),
- array('user_id' => 1, 'field_test_1_count' => 1),
- ));
+ $this->assertSortedResults([
+ ['user_id' => 3, 'field_test_1_count' => 2],
+ ['user_id' => 2, 'field_test_1_count' => 3],
+ ['user_id' => 1, 'field_test_1_count' => 1],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->aggregate('field_test_1', 'COUNT')
->groupBy('user_id')
->sort('user_id', 'ASC')
->execute();
- $this->assertSortedResults(array(
- array('user_id' => 1, 'field_test_1_count' => 1),
- array('user_id' => 2, 'field_test_1_count' => 3),
- array('user_id' => 3, 'field_test_1_count' => 2),
- ));
+ $this->assertSortedResults([
+ ['user_id' => 1, 'field_test_1_count' => 1],
+ ['user_id' => 2, 'field_test_1_count' => 3],
+ ['user_id' => 3, 'field_test_1_count' => 2],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->conditionAggregate('field_test_1', 'COUNT', 2, '>')
->groupBy('user_id')
->sort('user_id', 'ASC')
->execute();
- $this->assertSortedResults(array(
- array('user_id' => 2, 'field_test_1_count' => 3),
- array('user_id' => 3, 'field_test_1_count' => 2),
- ));
+ $this->assertSortedResults([
+ ['user_id' => 2, 'field_test_1_count' => 3],
+ ['user_id' => 3, 'field_test_1_count' => 2],
+ ]);
// Group by a normal property, aggregate a fieldapi field, and sort by the
// aggregated field.
@@ -486,21 +486,21 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->sortAggregate('field_test_1', 'COUNT', 'DESC')
->groupBy('user_id')
->execute();
- $this->assertSortedResults(array(
- array('user_id' => 2, 'field_test_1_count' => 3),
- array('user_id' => 3, 'field_test_1_count' => 2),
- array('user_id' => 1, 'field_test_1_count' => 1),
- ));
+ $this->assertSortedResults([
+ ['user_id' => 2, 'field_test_1_count' => 3],
+ ['user_id' => 3, 'field_test_1_count' => 2],
+ ['user_id' => 1, 'field_test_1_count' => 1],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->sortAggregate('field_test_1', 'COUNT', 'ASC')
->groupBy('user_id')
->execute();
- $this->assertSortedResults(array(
- array('user_id' => 1, 'field_test_1_count' => 1),
- array('user_id' => 3, 'field_test_1_count' => 2),
- array('user_id' => 2, 'field_test_1_count' => 3),
- ));
+ $this->assertSortedResults([
+ ['user_id' => 1, 'field_test_1_count' => 1],
+ ['user_id' => 3, 'field_test_1_count' => 2],
+ ['user_id' => 2, 'field_test_1_count' => 3],
+ ]);
// Group by and aggregate by fieldapi field, and sort by the groupby field.
$this->queryResult = $this->factory->getAggregate('entity_test')
@@ -508,22 +508,22 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->aggregate('field_test_2', 'COUNT')
->sort('field_test_1', 'ASC')
->execute();
- $this->assertSortedResults(array(
- array('field_test_1' => 1, 'field_test_2_count' => 2),
- array('field_test_1' => 2, 'field_test_2_count' => 3),
- array('field_test_1' => 3, 'field_test_2_count' => 1),
- ));
+ $this->assertSortedResults([
+ ['field_test_1' => 1, 'field_test_2_count' => 2],
+ ['field_test_1' => 2, 'field_test_2_count' => 3],
+ ['field_test_1' => 3, 'field_test_2_count' => 1],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->groupBy('field_test_1')
->aggregate('field_test_2', 'COUNT')
->sort('field_test_1', 'DESC')
->execute();
- $this->assertSortedResults(array(
- array('field_test_1' => 3, 'field_test_2_count' => 1),
- array('field_test_1' => 2, 'field_test_2_count' => 3),
- array('field_test_1' => 1, 'field_test_2_count' => 2),
- ));
+ $this->assertSortedResults([
+ ['field_test_1' => 3, 'field_test_2_count' => 1],
+ ['field_test_1' => 2, 'field_test_2_count' => 3],
+ ['field_test_1' => 1, 'field_test_2_count' => 2],
+ ]);
// Groupby and aggregate by fieldapi field, and sort by the aggregated
// field.
@@ -531,21 +531,21 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
->groupBy('field_test_1')
->sortAggregate('field_test_2', 'COUNT', 'DESC')
->execute();
- $this->assertSortedResults(array(
- array('field_test_1' => 2, 'field_test_2_count' => 3),
- array('field_test_1' => 1, 'field_test_2_count' => 2),
- array('field_test_1' => 3, 'field_test_2_count' => 1),
- ));
+ $this->assertSortedResults([
+ ['field_test_1' => 2, 'field_test_2_count' => 3],
+ ['field_test_1' => 1, 'field_test_2_count' => 2],
+ ['field_test_1' => 3, 'field_test_2_count' => 1],
+ ]);
$this->queryResult = $this->factory->getAggregate('entity_test')
->groupBy('field_test_1')
->sortAggregate('field_test_2', 'COUNT', 'ASC')
->execute();
- $this->assertSortedResults(array(
- array('field_test_1' => 3, 'field_test_2_count' => 1),
- array('field_test_1' => 1, 'field_test_2_count' => 2),
- array('field_test_1' => 2, 'field_test_2_count' => 3),
- ));
+ $this->assertSortedResults([
+ ['field_test_1' => 3, 'field_test_2_count' => 1],
+ ['field_test_1' => 1, 'field_test_2_count' => 2],
+ ['field_test_1' => 2, 'field_test_2_count' => 3],
+ ]);
}
@@ -559,7 +559,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
$found = TRUE;
$expected_keys = array_keys($expected);
foreach ($this->queryResult as $key => $row) {
- $keys = $sorted ? array($key) : $expected_keys;
+ $keys = $sorted ? [$key] : $expected_keys;
foreach ($keys as $key) {
$expected_row = $expected[$key];
if (!array_diff_assoc($row, $expected_row) && !array_diff_assoc($expected_row, $row)) {
@@ -569,7 +569,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
$found = FALSE;
break;
}
- return $this->assertTrue($found, strtr('!expected expected, !found found', array('!expected' => print_r($expected, TRUE), '!found' => print_r($this->queryResult, TRUE))));
+ return $this->assertTrue($found, strtr('!expected expected, !found found', ['!expected' => print_r($expected, TRUE), '!found' => print_r($this->queryResult, TRUE)]));
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
index 60dc13c67b5..0bb5b16c34a 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
@@ -23,7 +23,7 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* @var \Drupal\Core\Entity\Query\QueryFactory
@@ -80,12 +80,12 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
// Second, create the field.
entity_test_create_bundle('test_bundle');
$this->fieldName = strtolower($this->randomMachineName());
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('entity_test', 'test_bundle', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings);
// Create two terms and also two accounts.
@@ -102,7 +102,7 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
// 0th account and 0th term, the 1st and 2nd entity will point to the
// 1st account and 1st term.
for ($i = 0; $i <= 2; $i++) {
- $entity = EntityTest::create(array('type' => 'test_bundle'));
+ $entity = EntityTest::create(['type' => 'test_bundle']);
$entity->name->value = $this->randomMachineName();
$index = $i ? 1 : 0;
$entity->user_id->target_id = $this->accounts[$index]->id();
@@ -122,18 +122,18 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
$this->queryResults = $this->factory->get('entity_test')
->condition("user_id.entity.name", $this->accounts[0]->getUsername())
->execute();
- $this->assertResults(array(0));
+ $this->assertResults([0]);
// This returns the 1st and 2nd entity as those point to the 1st account.
$this->queryResults = $this->factory->get('entity_test')
->condition("user_id.entity.name", $this->accounts[0]->getUsername(), '<>')
->execute();
- $this->assertResults(array(1, 2));
+ $this->assertResults([1, 2]);
// This returns all three entities because all of them point to an
// account.
$this->queryResults = $this->factory->get('entity_test')
->exists("user_id.entity.name")
->execute();
- $this->assertResults(array(0, 1, 2));
+ $this->assertResults([0, 1, 2]);
// This returns no entities because all of them point to an account.
$this->queryResults = $this->factory->get('entity_test')
->notExists("user_id.entity.name")
@@ -144,35 +144,35 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
$this->queryResults = $this->factory->get('entity_test')
->condition("$this->fieldName.entity.name", $this->terms[0]->name->value)
->execute();
- $this->assertResults(array(0));
+ $this->assertResults([0]);
// This returns the 0th entity as that's only one pointing to the 0th
// term (test with specifying the column name).
$this->queryResults = $this->factory->get('entity_test')
->condition("$this->fieldName.target_id.entity.name", $this->terms[0]->name->value)
->execute();
- $this->assertResults(array(0));
+ $this->assertResults([0]);
// This returns the 1st and 2nd entity as those point to the 1st term.
$this->queryResults = $this->factory->get('entity_test')
->condition("$this->fieldName.entity.name", $this->terms[0]->name->value, '<>')
->execute();
- $this->assertResults(array(1, 2));
+ $this->assertResults([1, 2]);
// This returns the 0th entity as that's only one pointing to the 0th
// account.
$this->queryResults = $this->factory->get('entity_test')
->condition("user_id.entity:user.name", $this->accounts[0]->getUsername())
->execute();
- $this->assertResults(array(0));
+ $this->assertResults([0]);
// This returns the 1st and 2nd entity as those point to the 1st account.
$this->queryResults = $this->factory->get('entity_test')
->condition("user_id.entity:user.name", $this->accounts[0]->getUsername(), '<>')
->execute();
- $this->assertResults(array(1, 2));
+ $this->assertResults([1, 2]);
// This returns all three entities because all of them point to an
// account.
$this->queryResults = $this->factory->get('entity_test')
->exists("user_id.entity:user.name")
->execute();
- $this->assertResults(array(0, 1, 2));
+ $this->assertResults([0, 1, 2]);
// This returns no entities because all of them point to an account.
$this->queryResults = $this->factory->get('entity_test')
->notExists("user_id.entity:user.name")
@@ -183,18 +183,18 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
$this->queryResults = $this->factory->get('entity_test')
->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value)
->execute();
- $this->assertResults(array(0));
+ $this->assertResults([0]);
// This returns the 0th entity as that's only one pointing to the 0th
// term (test with specifying the column name).
$this->queryResults = $this->factory->get('entity_test')
->condition("$this->fieldName.target_id.entity:taxonomy_term.name", $this->terms[0]->name->value)
->execute();
- $this->assertResults(array(0));
+ $this->assertResults([0]);
// This returns the 1st and 2nd entity as those point to the 1st term.
$this->queryResults = $this->factory->get('entity_test')
->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value, '<>')
->execute();
- $this->assertResults(array(1, 2));
+ $this->assertResults([1, 2]);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
index 8c79c5c6342..1ad2f31bb8e 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
@@ -24,7 +24,7 @@ class EntityQueryTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('field_test', 'language');
+ public static $modules = ['field_test', 'language'];
/**
* @var array
@@ -62,21 +62,21 @@ class EntityQueryTest extends EntityKernelTestBase {
$this->installEntitySchema('entity_test_mulrev');
- $this->installConfig(array('language'));
+ $this->installConfig(['language']);
$figures = Unicode::strtolower($this->randomMachineName());
$greetings = Unicode::strtolower($this->randomMachineName());
- foreach (array($figures => 'shape', $greetings => 'text') as $field_name => $field_type) {
- $field_storage = FieldStorageConfig::create(array(
+ foreach ([$figures => 'shape', $greetings => 'text'] as $field_name => $field_type) {
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test_mulrev',
'type' => $field_type,
'cardinality' => 2,
- ));
+ ]);
$field_storage->save();
$field_storages[] = $field_storage;
}
- $bundles = array();
+ $bundles = [];
for ($i = 0; $i < 2; $i++) {
// For the sake of tablesort, make sure the second bundle is higher than
// the first one. Beware: MySQL is not case sensitive.
@@ -93,24 +93,24 @@ class EntityQueryTest extends EntityKernelTestBase {
$bundles[] = $bundle;
}
// Each unit is a list of field name, langcode and a column-value array.
- $units[] = array($figures, 'en', array(
+ $units[] = [$figures, 'en', [
'color' => 'red',
'shape' => 'triangle',
- ));
- $units[] = array($figures, 'en', array(
+ ]];
+ $units[] = [$figures, 'en', [
'color' => 'blue',
'shape' => 'circle',
- ));
+ ]];
// To make it easier to test sorting, the greetings get formats according
// to their langcode.
- $units[] = array($greetings, 'tr', array(
+ $units[] = [$greetings, 'tr', [
'value' => 'merhaba',
'format' => 'format-tr'
- ));
- $units[] = array($greetings, 'pl', array(
+ ]];
+ $units[] = [$greetings, 'pl', [
'value' => 'siema',
'format' => 'format-pl'
- ));
+ ]];
// Make these languages available to the greetings field.
ConfigurableLanguage::createFromLangcode('tr')->save();
ConfigurableLanguage::createFromLangcode('pl')->save();
@@ -119,13 +119,13 @@ class EntityQueryTest extends EntityKernelTestBase {
// decimal 13 is binary 1101 so unit 3,2 and 0 will be added to the
// entity.
for ($i = 1; $i <= 15; $i++) {
- $entity = EntityTestMulRev::create(array(
+ $entity = EntityTestMulRev::create([
'type' => $bundles[$i & 1],
'name' => $this->randomMachineName(),
'langcode' => 'en',
- ));
+ ]);
// Make sure the name is set for every language that we might create.
- foreach (array('tr', 'pl') as $langcode) {
+ foreach (['tr', 'pl'] as $langcode) {
$entity->addTranslation($langcode)->name = $this->randomMachineName();
}
foreach (array_reverse(str_split(decbin($i))) as $key => $bit) {
@@ -216,8 +216,8 @@ class EntityQueryTest extends EntityKernelTestBase {
// Do the same test but with IN operator.
$query = $this->factory->get('entity_test_mulrev');
- $group_blue = $query->andConditionGroup()->condition("$figures.color", array('blue'), 'IN');
- $group_red = $query->andConditionGroup()->condition("$figures.color", array('red'), 'IN');
+ $group_blue = $query->andConditionGroup()->condition("$figures.color", ['blue'], 'IN');
+ $group_red = $query->andConditionGroup()->condition("$figures.color", ['red'], 'IN');
$this->queryResults = $query
->condition($group_blue)
->condition($group_red)
@@ -228,7 +228,7 @@ class EntityQueryTest extends EntityKernelTestBase {
// An entity might have either red or blue figure.
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition("$figures.color", array('blue', 'red'), 'IN')
+ ->condition("$figures.color", ['blue', 'red'], 'IN')
->sort('id')
->execute();
// Bit 0 or 1 is on.
@@ -267,7 +267,7 @@ class EntityQueryTest extends EntityKernelTestBase {
->allRevisions()
->sort('revision_id')
->execute();
- $this->assertRevisionResult(array($first_entity->id()), array($first_entity->id()));
+ $this->assertRevisionResult([$first_entity->id()], [$first_entity->id()]);
// When querying current revisions, this string is no longer found.
$this->queryResults = $this->factory->get('entity_test_mulrev')
->condition("$greetings.value", 'merhaba')
@@ -279,14 +279,14 @@ class EntityQueryTest extends EntityKernelTestBase {
->sort('revision_id')
->execute();
// The query only matches the original revisions.
- $this->assertRevisionResult(array(4, 5, 6, 7, 12, 13, 14, 15), array(4, 5, 6, 7, 12, 13, 14, 15));
+ $this->assertRevisionResult([4, 5, 6, 7, 12, 13, 14, 15], [4, 5, 6, 7, 12, 13, 14, 15]);
$results = $this->factory->get('entity_test_mulrev')
->condition("$greetings.value", 'siema', 'CONTAINS')
->sort('id')
->execute();
// This matches both the original and new current revisions, multiple
// revisions are returned for some entities.
- $assert = array(16 => '4', 17 => '5', 18 => '6', 19 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 20 => '12', 21 => '13', 22 => '14', 23 => '15');
+ $assert = [16 => '4', 17 => '5', 18 => '6', 19 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 20 => '12', 21 => '13', 22 => '14', 23 => '15'];
$this->assertIdentical($results, $assert);
$results = $this->factory->get('entity_test_mulrev')
->condition("$greetings.value", 'siema', 'STARTS_WITH')
@@ -309,7 +309,7 @@ class EntityQueryTest extends EntityKernelTestBase {
->sort('revision_id')
->execute();
// Now we get everything.
- $assert = array(4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12', 20 => '12', 13 => '13', 21 => '13', 14 => '14', 22 => '14', 15 => '15', 23 => '15');
+ $assert = [4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12', 20 => '12', 13 => '13', 21 => '13', 14 => '14', 22 => '14', 15 => '15', 23 => '15'];
$this->assertIdentical($results, $assert);
}
@@ -376,9 +376,9 @@ class EntityQueryTest extends EntityKernelTestBase {
// Test the pager by setting element #1 to page 2 with a page size of 4.
// Results will be #8-12 from above.
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
'page' => '0,2',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
$this->queryResults = $this->factory->get('entity_test_mulrev')
->sort("$figures.color")
@@ -407,40 +407,40 @@ class EntityQueryTest extends EntityKernelTestBase {
// assert that all entities from one bundle are after the other as the
// order dictates.
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
'sort' => 'asc',
'order' => 'Type',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
- $header = array(
- 'id' => array('data' => 'Id', 'specifier' => 'id'),
- 'type' => array('data' => 'Type', 'specifier' => 'type'),
- );
+ $header = [
+ 'id' => ['data' => 'Id', 'specifier' => 'id'],
+ 'type' => ['data' => 'Type', 'specifier' => 'type'],
+ ];
$this->queryResults = array_values($this->factory->get('entity_test_mulrev')
->tableSort($header)
->execute());
$this->assertBundleOrder('asc');
- $request->query->add(array(
+ $request->query->add([
'sort' => 'desc',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
- $header = array(
- 'id' => array('data' => 'Id', 'specifier' => 'id'),
- 'type' => array('data' => 'Type', 'specifier' => 'type'),
- );
+ $header = [
+ 'id' => ['data' => 'Id', 'specifier' => 'id'],
+ 'type' => ['data' => 'Type', 'specifier' => 'type'],
+ ];
$this->queryResults = array_values($this->factory->get('entity_test_mulrev')
->tableSort($header)
->execute());
$this->assertBundleOrder('desc');
// Ordering on ID is definite, however.
- $request->query->add(array(
+ $request->query->add([
'order' => 'Id',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
$this->queryResults = $this->factory->get('entity_test_mulrev')
->tableSort($header)
@@ -454,13 +454,13 @@ class EntityQueryTest extends EntityKernelTestBase {
public function testCount() {
// Create a field with the same name in a different entity type.
$field_name = $this->figures;
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'shape',
'cardinality' => 2,
'translatable' => TRUE,
- ));
+ ]);
$field_storage->save();
$bundle = $this->randomMachineName();
FieldConfig::create([
@@ -468,10 +468,10 @@ class EntityQueryTest extends EntityKernelTestBase {
'bundle' => $bundle,
])->save();
- $entity = EntityTest::create(array(
+ $entity = EntityTest::create([
'id' => 1,
'type' => $bundle,
- ));
+ ]);
$entity->enforceIsNew();
$entity->save();
@@ -545,8 +545,8 @@ class EntityQueryTest extends EntityKernelTestBase {
// Test the delta range condition.
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition("$figures.%delta.color", array('blue', 'red'), 'IN')
- ->condition("$figures.%delta", array(0, 1), 'IN')
+ ->condition("$figures.%delta.color", ['blue', 'red'], 'IN')
+ ->condition("$figures.%delta", [0, 1], 'IN')
->sort('id')
->execute();
// Figure delta 0 or 1 can be blue or red, this matches a lot of entities.
@@ -563,12 +563,12 @@ class EntityQueryTest extends EntityKernelTestBase {
// Numeric delta on single value base field should return results only if
// the first item is being targeted.
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition("id.0.value", array(1, 3, 5), 'IN')
+ ->condition("id.0.value", [1, 3, 5], 'IN')
->sort('id')
->execute();
$this->assertResult(1, 3, 5);
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition("id.1.value", array(1, 3, 5), 'IN')
+ ->condition("id.1.value", [1, 3, 5], 'IN')
->sort('id')
->execute();
$this->assertResult();
@@ -576,18 +576,18 @@ class EntityQueryTest extends EntityKernelTestBase {
// Delta range condition on single value base field should return results
// only if just the field value is targeted.
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition("id.%delta.value", array(1, 3, 5), 'IN')
+ ->condition("id.%delta.value", [1, 3, 5], 'IN')
->sort('id')
->execute();
$this->assertResult(1, 3, 5);
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition("id.%delta.value", array(1, 3, 5), 'IN')
+ ->condition("id.%delta.value", [1, 3, 5], 'IN')
->condition("id.%delta", 0, '=')
->sort('id')
->execute();
$this->assertResult(1, 3, 5);
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition("id.%delta.value", array(1, 3, 5), 'IN')
+ ->condition("id.%delta.value", [1, 3, 5], 'IN')
->condition("id.%delta", 1, '=')
->sort('id')
->execute();
@@ -596,7 +596,7 @@ class EntityQueryTest extends EntityKernelTestBase {
}
protected function assertResult() {
- $assert = array();
+ $assert = [];
$expected = func_get_args();
if ($expected && is_array($expected[0])) {
$expected = $expected[0];
@@ -608,7 +608,7 @@ class EntityQueryTest extends EntityKernelTestBase {
}
protected function assertRevisionResult($keys, $expected) {
- $assert = array();
+ $assert = [];
foreach ($expected as $key => $binary) {
$assert[$keys[$key]] = strval($binary);
}
@@ -659,41 +659,41 @@ class EntityQueryTest extends EntityKernelTestBase {
public function testCaseSensitivity() {
$bundle = $this->randomMachineName();
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_ci',
'entity_type' => 'entity_test_mulrev',
'type' => 'string',
'cardinality' => 1,
'translatable' => FALSE,
- 'settings' => array(
+ 'settings' => [
'case_sensitive' => FALSE,
- )
- ));
+ ]
+ ]);
$field_storage->save();
- FieldConfig::create(array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $bundle,
- ))->save();
+ ])->save();
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'field_cs',
'entity_type' => 'entity_test_mulrev',
'type' => 'string',
'cardinality' => 1,
'translatable' => FALSE,
- 'settings' => array(
+ 'settings' => [
'case_sensitive' => TRUE,
- ),
- ));
+ ],
+ ]);
$field_storage->save();
- FieldConfig::create(array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $bundle,
- ))->save();
+ ])->save();
- $fixtures = array();
+ $fixtures = [];
for ($i = 0; $i < 2; $i++) {
// If the last 4 of the string are all numbers, then there is no
@@ -701,20 +701,20 @@ class EntityQueryTest extends EntityKernelTestBase {
// test will fail. Ensure that can not happen by appending a non-numeric
// character. See https://www.drupal.org/node/2397297.
$string = $this->randomMachineName(7) . 'a';
- $fixtures[] = array(
+ $fixtures[] = [
'original' => $string,
'uppercase' => Unicode::strtoupper($string),
'lowercase' => Unicode::strtolower($string),
- );
+ ];
}
- EntityTestMulRev::create(array(
+ EntityTestMulRev::create([
'type' => $bundle,
'name' => $this->randomMachineName(),
'langcode' => 'en',
'field_ci' => $fixtures[0]['uppercase'] . $fixtures[1]['lowercase'],
'field_cs' => $fixtures[0]['uppercase'] . $fixtures[1]['lowercase']
- ))->save();
+ ])->save();
// Check the case insensitive field, = operator.
$result = \Drupal::entityQuery('entity_test_mulrev')->condition(
@@ -750,33 +750,33 @@ class EntityQueryTest extends EntityKernelTestBase {
// Check the case insensitive field, IN operator.
$result = \Drupal::entityQuery('entity_test_mulrev')->condition(
- 'field_ci', array($fixtures[0]['lowercase'] . $fixtures[1]['lowercase']), 'IN'
+ 'field_ci', [$fixtures[0]['lowercase'] . $fixtures[1]['lowercase']], 'IN'
)->execute();
$this->assertIdentical(count($result), 1, 'Case insensitive, lowercase');
$result = \Drupal::entityQuery('entity_test_mulrev')->condition(
- 'field_ci', array($fixtures[0]['uppercase'] . $fixtures[1]['uppercase']), 'IN'
+ 'field_ci', [$fixtures[0]['uppercase'] . $fixtures[1]['uppercase']], 'IN'
)->execute();
$this->assertIdentical(count($result), 1, 'Case insensitive, uppercase');
$result = \Drupal::entityQuery('entity_test_mulrev')->condition(
- 'field_ci', array($fixtures[0]['uppercase'] . $fixtures[1]['lowercase']), 'IN'
+ 'field_ci', [$fixtures[0]['uppercase'] . $fixtures[1]['lowercase']], 'IN'
)->execute();
$this->assertIdentical(count($result), 1, 'Case insensitive, mixed');
// Check the case sensitive field, IN operator.
$result = \Drupal::entityQuery('entity_test_mulrev')->condition(
- 'field_cs', array($fixtures[0]['lowercase'] . $fixtures[1]['lowercase']), 'IN'
+ 'field_cs', [$fixtures[0]['lowercase'] . $fixtures[1]['lowercase']], 'IN'
)->execute();
$this->assertIdentical(count($result), 0, 'Case sensitive, lowercase');
$result = \Drupal::entityQuery('entity_test_mulrev')->condition(
- 'field_cs', array($fixtures[0]['uppercase'] . $fixtures[1]['uppercase']), 'IN'
+ 'field_cs', [$fixtures[0]['uppercase'] . $fixtures[1]['uppercase']], 'IN'
)->execute();
$this->assertIdentical(count($result), 0, 'Case sensitive, uppercase');
$result = \Drupal::entityQuery('entity_test_mulrev')->condition(
- 'field_cs', array($fixtures[0]['uppercase'] . $fixtures[1]['lowercase']), 'IN'
+ 'field_cs', [$fixtures[0]['uppercase'] . $fixtures[1]['lowercase']], 'IN'
)->execute();
$this->assertIdentical(count($result), 1, 'Case sensitive, mixed');
@@ -863,19 +863,19 @@ class EntityQueryTest extends EntityKernelTestBase {
$term1 = Term::create([
'name' => $this->randomMachineName(),
'vid' => 'tags',
- 'description' => array(
+ 'description' => [
'value' => $this->randomString(),
'format' => 'format1',
- )]);
+ ]]);
$term1->save();
$term2 = Term::create([
'name' => $this->randomMachineName(),
'vid' => 'tags',
- 'description' => array(
+ 'description' => [
'value' => $this->randomString(),
'format' => 'format2',
- )]);
+ ]]);
$term2->save();
$ids = \Drupal::entityQuery('taxonomy_term')
@@ -936,7 +936,7 @@ class EntityQueryTest extends EntityKernelTestBase {
public function testInjectionInCondition() {
try {
$this->queryResults = $this->factory->get('entity_test_mulrev')
- ->condition('1 ; -- ', array(0, 1), 'IN')
+ ->condition('1 ; -- ', [0, 1], 'IN')
->sort('id')
->execute();
$this->fail('SQL Injection attempt in Entity Query condition in operator should result in an exception.');
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
index cb82742faaf..e9b1857dc61 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
@@ -59,7 +59,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('entity_reference_test');
+ public static $modules = ['entity_reference_test'];
/**
* {@inheritdoc}
@@ -77,7 +77,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
'Field test',
$this->referencedEntityType,
'default',
- array('target_bundles' => array($this->bundle)),
+ ['target_bundles' => [$this->bundle]],
FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED
);
@@ -90,12 +90,12 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
// Test a valid reference.
$referenced_entity = $this->container->get('entity_type.manager')
->getStorage($this->referencedEntityType)
- ->create(array('type' => $this->bundle));
+ ->create(['type' => $this->bundle]);
$referenced_entity->save();
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('type' => $this->bundle));
+ ->create(['type' => $this->bundle]);
$entity->{$this->fieldName}->target_id = $referenced_entity->id();
$violations = $entity->{$this->fieldName}->validate();
$this->assertEqual($violations->count(), 0, 'Validation passes.');
@@ -104,16 +104,16 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
$entity->{$this->fieldName}->target_id = 9999;
$violations = $entity->{$this->fieldName}->validate();
$this->assertEqual($violations->count(), 1, 'Validation throws a violation.');
- $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', array('%type' => $this->referencedEntityType, '%id' => 9999)));
+ $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', ['%type' => $this->referencedEntityType, '%id' => 9999]));
// Test a non-referenceable bundle.
entity_test_create_bundle('non_referenceable', NULL, $this->referencedEntityType);
- $referenced_entity = entity_create($this->referencedEntityType, array('type' => 'non_referenceable'));
+ $referenced_entity = entity_create($this->referencedEntityType, ['type' => 'non_referenceable']);
$referenced_entity->save();
$entity->{$this->fieldName}->target_id = $referenced_entity->id();
$violations = $entity->{$this->fieldName}->validate();
$this->assertEqual($violations->count(), 1, 'Validation throws a violation.');
- $this->assertEqual($violations[0]->getMessage(), t('This entity (%type: %id) cannot be referenced.', array('%type' => $this->referencedEntityType, '%id' => $referenced_entity->id())));
+ $this->assertEqual($violations[0]->getMessage(), t('This entity (%type: %id) cannot be referenced.', ['%type' => $this->referencedEntityType, '%id' => $referenced_entity->id()]));
}
/**
@@ -123,15 +123,15 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
// Create the parent entity.
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('type' => $this->bundle));
+ ->create(['type' => $this->bundle]);
// Create three target entities and attach them to parent field.
- $target_entities = array();
- $reference_field = array();
+ $target_entities = [];
+ $reference_field = [];
for ($i = 0; $i < 3; $i++) {
$target_entity = $this->container->get('entity_type.manager')
->getStorage($this->referencedEntityType)
- ->create(array('type' => $this->bundle));
+ ->create(['type' => $this->bundle]);
$target_entity->save();
$target_entities[] = $target_entity;
$reference_field[]['target_id'] = $target_entity->id();
@@ -154,7 +154,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
// "autocreate" feature.
$target_entity_unsaved = $this->container->get('entity_type.manager')
->getStorage($this->referencedEntityType)
- ->create(array('type' => $this->bundle, 'name' => $this->randomString()));
+ ->create(['type' => $this->bundle, 'name' => $this->randomString()]);
$reference_field[6]['entity'] = $target_entity_unsaved;
$target_entities[6] = $target_entity_unsaved;
@@ -201,13 +201,13 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
'Field test',
'entity_test_string_id',
'default',
- array('target_bundles' => array($this->bundle)),
+ ['target_bundles' => [$this->bundle]],
FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED
);
// Create the parent entity.
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('type' => $this->bundle));
+ ->create(['type' => $this->bundle]);
// Create the default target entity.
$target_entity = EntityTestStringId::create([
@@ -217,7 +217,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
$target_entity->save();
// Set the field value.
- $entity->{$field_name}->setValue(array(array('target_id' => $target_entity->id())));
+ $entity->{$field_name}->setValue([['target_id' => $target_entity->id()]]);
// Load the target entities using EntityReferenceField::referencedEntities().
$entities = $entity->{$field_name}->referencedEntities();
@@ -233,7 +233,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
// Test that the default value works.
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityType)
- ->create(array('type' => $this->bundle));
+ ->create(['type' => $this->bundle]);
$entities = $entity->{$field_name}->referencedEntities();
$this->assertEqual($entities[0]->id(), $target_entity->id());
}
@@ -244,7 +244,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
function testAutocreateApi() {
$entity = $this->entityManager
->getStorage($this->entityType)
- ->create(array('name' => $this->randomString()));
+ ->create(['name' => $this->randomString()]);
// Test content entity autocreation.
$this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) {
@@ -260,13 +260,13 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
$entity->user_id[0]->get('entity')->setValue($user);
});
$this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) {
- $entity->user_id->setValue(array('entity' => $user, 'target_id' => NULL));
+ $entity->user_id->setValue(['entity' => $user, 'target_id' => NULL]);
});
try {
$message = 'Setting both the entity and an invalid target_id property fails.';
$this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) {
$user->save();
- $entity->user_id->setValue(array('entity' => $user, 'target_id' => $this->generateRandomEntityId()));
+ $entity->user_id->setValue(['entity' => $user, 'target_id' => $this->generateRandomEntityId()]);
});
$this->fail($message);
}
@@ -294,13 +294,13 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
$entity->user_role[0]->get('entity')->setValue($role);
});
$this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) {
- $entity->user_role->setValue(array('entity' => $role, 'target_id' => NULL));
+ $entity->user_role->setValue(['entity' => $role, 'target_id' => NULL]);
});
try {
$message = 'Setting both the entity and an invalid target_id property fails.';
$this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) {
$role->save();
- $entity->user_role->setValue(array('entity' => $role, 'target_id' => $this->generateRandomEntityId(TRUE)));
+ $entity->user_role->setValue(['entity' => $role, 'target_id' => $this->generateRandomEntityId(TRUE)]);
});
$this->fail($message);
}
@@ -317,7 +317,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
// Test target entity saving after setting it as new.
$storage = $this->entityManager->getStorage('user');
$user_id = $this->generateRandomEntityId();
- $user = $storage->create(array('uid' => $user_id, 'name' => $this->randomString()));
+ $user = $storage->create(['uid' => $user_id, 'name' => $this->randomString()]);
$entity->user_id = $user;
$user->save();
$entity->save();
@@ -338,7 +338,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
protected function assertUserAutocreate(EntityInterface $entity, $setter_callback) {
$storage = $this->entityManager->getStorage('user');
$user_id = $this->generateRandomEntityId();
- $user = $storage->create(array('uid' => $user_id, 'name' => $this->randomString()));
+ $user = $storage->create(['uid' => $user_id, 'name' => $this->randomString()]);
$setter_callback($entity, $user);
$entity->save();
$storage->resetCache();
@@ -360,7 +360,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_callback) {
$storage = $this->entityManager->getStorage('user_role');
$role_id = $this->generateRandomEntityId(TRUE);
- $role = $storage->create(array('id' => $role_id, 'label' => $this->randomString()));
+ $role = $storage->create(['id' => $role_id, 'label' => $this->randomString()]);
$setter_callback($entity, $role);
$entity->save();
$storage->resetCache();
@@ -378,11 +378,11 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type->setHandlerClass('storage', '\Drupal\entity_test\EntityTestNoLoadStorage');
$this->state->set('entity_test_update.entity_type', $entity_type);
- $definitions = array(
+ $definitions = [
'target_reference' => BaseFieldDefinition::create('entity_reference')
->setSetting('target_type', $entity_type->id())
->setSetting('handler', 'default')
- );
+ ];
$this->state->set('entity_test_update.additional_base_field_definitions', $definitions);
$this->entityManager->clearCachedDefinitions();
$this->installEntitySchema($entity_type->id());
@@ -390,7 +390,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
// Create the target entity.
$storage = $this->entityManager->getStorage($entity_type->id());
$target_id = $this->generateRandomEntityId();
- $target = $storage->create(array('id' => $target_id, 'name' => $this->randomString()));
+ $target = $storage->create(['id' => $target_id, 'name' => $this->randomString()]);
$target->save();
$this->assertEqual($target_id, $target->id(), 'The target entity has a random identifier.');
@@ -400,7 +400,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
try {
$entity = $this->entityManager
->getStorage($entity_type->id())
- ->create(array('name' => $this->randomString()));
+ ->create(['name' => $this->randomString()]);
$entity->target_reference = $target_id;
$this->pass($message);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
index f51c8ea3dc7..eb13d0e4912 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
@@ -21,19 +21,19 @@ class EntityReferenceSelectionSortTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = ['node'];
protected function setUp() {
parent::setUp();
// Create an Article node type.
- $article = NodeType::create(array(
+ $article = NodeType::create([
'type' => 'article',
- ));
+ ]);
$article->save();
// Test as a non-admin.
- $normal_user = $this->createUser(array(), array('access content'));
+ $normal_user = $this->createUser([], ['access content']);
\Drupal::currentUser()->setAccount($normal_user);
}
@@ -42,50 +42,50 @@ class EntityReferenceSelectionSortTest extends EntityKernelTestBase {
*/
public function testSort() {
// Add text field to entity, to sort by.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_text',
'entity_type' => 'node',
'type' => 'text',
- 'entity_types' => array('node'),
- ))->save();
+ 'entity_types' => ['node'],
+ ])->save();
FieldConfig::create([
'label' => 'Text Field',
'field_name' => 'field_text',
'entity_type' => 'node',
'bundle' => 'article',
- 'settings' => array(),
+ 'settings' => [],
'required' => FALSE,
])->save();
// Build a set of test data.
- $node_values = array(
- 'published1' => array(
+ $node_values = [
+ 'published1' => [
'type' => 'article',
'status' => 1,
'title' => 'Node published1 (<&>)',
'uid' => 1,
- 'field_text' => array(
- array(
+ 'field_text' => [
+ [
'value' => 1,
- ),
- ),
- ),
- 'published2' => array(
+ ],
+ ],
+ ],
+ 'published2' => [
'type' => 'article',
'status' => 1,
'title' => 'Node published2 (<&>)',
'uid' => 1,
- 'field_text' => array(
- array(
+ 'field_text' => [
+ [
'value' => 2,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
- $nodes = array();
- $node_labels = array();
+ $nodes = [];
+ $node_labels = [];
foreach ($node_values as $key => $values) {
$node = Node::create($values);
$node->save();
@@ -93,40 +93,40 @@ class EntityReferenceSelectionSortTest extends EntityKernelTestBase {
$node_labels[$key] = Html::escape($node->label());
}
- $selection_options = array(
+ $selection_options = [
'target_type' => 'node',
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
'target_bundles' => NULL,
// Add sorting.
- 'sort' => array(
+ 'sort' => [
'field' => 'field_text.value',
'direction' => 'DESC',
- ),
- ),
- );
+ ],
+ ],
+ ];
$handler = $this->container->get('plugin.manager.entity_reference_selection')->getInstance($selection_options);
// Not only assert the result, but make sure the keys are sorted as
// expected.
$result = $handler->getReferenceableEntities();
- $expected_result = array(
+ $expected_result = [
$nodes['published2']->id() => $node_labels['published2'],
$nodes['published1']->id() => $node_labels['published1'],
- );
+ ];
$this->assertIdentical($result['article'], $expected_result, 'Query sorted by field returned expected values.');
// Assert sort by base field.
- $selection_options['handler_settings']['sort'] = array(
+ $selection_options['handler_settings']['sort'] = [
'field' => 'nid',
'direction' => 'ASC',
- );
+ ];
$handler = $this->container->get('plugin.manager.entity_reference_selection')->getInstance($selection_options);
$result = $handler->getReferenceableEntities();
- $expected_result = array(
+ $expected_result = [
$nodes['published1']->id() => $node_labels['published1'],
$nodes['published2']->id() => $node_labels['published2'],
- );
+ ];
$this->assertIdentical($result['article'], $expected_result, 'Query sorted by property returned expected values.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php
index fdf72df4a39..3e285ff69b2 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php
@@ -23,7 +23,7 @@ class EntitySchemaTest extends EntityKernelTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installSchema('user', array('users_data'));
+ $this->installSchema('user', ['users_data']);
$this->database = $this->container->get('database');
}
@@ -80,33 +80,33 @@ class EntitySchemaTest extends EntityKernelTestBase {
$this->entityManager->onFieldStorageDefinitionCreate($storage_definitions['custom_base_field']);
$this->entityManager->onFieldStorageDefinitionCreate($storage_definitions['custom_bundle_field']);
$schema_handler = $this->database->schema();
- $tables = array('entity_test', 'entity_test_revision', 'entity_test_field_data', 'entity_test_field_revision');
- $dedicated_tables = array('entity_test__custom_bundle_field', 'entity_test_revision__custom_bundle_field');
+ $tables = ['entity_test', 'entity_test_revision', 'entity_test_field_data', 'entity_test_field_revision'];
+ $dedicated_tables = ['entity_test__custom_bundle_field', 'entity_test_revision__custom_bundle_field'];
// Initially only the base table and the dedicated field data table should
// exist.
foreach ($tables as $index => $table) {
- $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table)));
+ $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', ['@table' => $table]));
}
- $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table)));
+ $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', ['@table' => $table]));
// Update the entity type definition and check that the entity schema now
// supports translations and revisions.
$this->updateEntityType(TRUE);
foreach ($tables as $table) {
- $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table)));
+ $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Entity schema correct for the @table table.', ['@table' => $table]));
}
foreach ($dedicated_tables as $table) {
- $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table)));
+ $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Field schema correct for the @table table.', ['@table' => $table]));
}
// Revert changes and check that the entity schema now does not support
// neither translations nor revisions.
$this->updateEntityType(FALSE);
foreach ($tables as $index => $table) {
- $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table)));
+ $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', ['@table' => $table]));
}
- $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table)));
+ $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', ['@table' => $table]));
}
/**
@@ -167,7 +167,7 @@ class EntitySchemaTest extends EntityKernelTestBase {
$this->assertNotEqual($entity_type_id_count, 0, 'There are storage definitions provided by the entity_test module in the schema.');
// Uninstall the entity_test module.
- $this->container->get('module_installer')->uninstall(array('entity_test'));
+ $this->container->get('module_installer')->uninstall(['entity_test']);
// Get a list of all the entities in the schema.
$key_value_store = \Drupal::keyValue('entity.storage_schema.sql');
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
index ed6140da0e6..fad38991431 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
@@ -37,28 +37,28 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => 'test',
'user_id' => $this->container->get('current_user')->id(),
- ));
- $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type)));
+ ]);
+ $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', ['%entity_type' => $entity_type]));
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => 'test',
'user_id' => \Drupal::currentUser()->id(),
$langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ));
+ ]);
- $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type)));
- $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', ['%entity_type' => $entity_type]));
+ $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', ['%entity_type' => $entity_type]));
// Set the value in default language.
- $entity->set($this->fieldName, array(0 => array('value' => 'default value')));
+ $entity->set($this->fieldName, [0 => ['value' => 'default value']]);
// Get the value.
$field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get($this->fieldName);
- $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
- $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type]));
// Try to get add a translation to language neutral entity.
$message = 'Adding a translation to a language-neutral entity results in an error.';
@@ -74,22 +74,22 @@ class EntityTranslationTest extends EntityLanguageTestBase {
// translating it.
$default_langcode = $this->langcodes[0];
$entity->{$langcode_key}->value = $default_langcode;
- $entity->{$this->fieldName} = array();
- $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type)));
- $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
+ $entity->{$this->fieldName} = [];
+ $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', ['%entity_type' => $entity_type]));
+ $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', ['%entity_type' => $entity_type]));
// Set the value in default language.
- $entity->set($this->fieldName, array(0 => array('value' => 'default value')));
+ $entity->set($this->fieldName, [0 => ['value' => 'default value']]);
// Get the value.
$field = $entity->get($this->fieldName);
- $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
- $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type]));
// Set a translation.
- $entity->addTranslation($this->langcodes[1])->set($this->fieldName, array(0 => array('value' => 'translation 1')));
+ $entity->addTranslation($this->langcodes[1])->set($this->fieldName, [0 => ['value' => 'translation 1']]);
$field = $entity->getTranslation($this->langcodes[1])->{$this->fieldName};
- $this->assertEqual($field->value, 'translation 1', format_string('%entity_type: Translated value set.', array('%entity_type' => $entity_type)));
- $this->assertEqual($field->getLangcode(), $this->langcodes[1], format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($field->value, 'translation 1', format_string('%entity_type: Translated value set.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($field->getLangcode(), $this->langcodes[1], format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type]));
// Make sure the untranslated value stays.
$field = $entity->get($this->fieldName);
@@ -110,7 +110,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
}
// Try to get a not available translation.
- $this->assertNull($entity->addTranslation($this->langcodes[2])->get($this->fieldName)->value, format_string('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type)));
+ $this->assertNull($entity->addTranslation($this->langcodes[2])->get($this->fieldName)->value, format_string('%entity_type: A translation that is not available is NULL.', ['%entity_type' => $entity_type]));
// Try to get a value using an invalid language code.
$message = 'Getting an invalid translation results in an error.';
@@ -125,19 +125,19 @@ class EntityTranslationTest extends EntityLanguageTestBase {
// Try to set a value using an invalid language code.
try {
$entity->getTranslation('invalid')->set($this->fieldName, NULL);
- $this->fail(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type)));
+ $this->fail(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', ['%entity_type' => $entity_type]));
}
catch (\InvalidArgumentException $e) {
- $this->pass(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type)));
+ $this->pass(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', ['%entity_type' => $entity_type]));
}
// Set the value in default language.
$field_name = 'field_test_text';
- $entity->getTranslation($this->langcodes[1])->set($field_name, array(0 => array('value' => 'default value2')));
+ $entity->getTranslation($this->langcodes[1])->set($field_name, [0 => ['value' => 'default value2']]);
// Get the value.
$field = $entity->get($field_name);
- $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value set into a translation in non-strict mode.', array('%entity_type' => $entity_type)));
- $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value set into a translation in non-strict mode.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type]));
}
/**
@@ -171,51 +171,51 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$entity->save();
$entity = $storage->load($entity->id());
$default_langcode = $entity->language()->getId();
- $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', ['%entity_type' => $entity_type]));
$field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('name');
- $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
- $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
- $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', ['%entity_type' => $entity_type]));
$translation = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT);
$field = $translation->get('name');
- $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to neutral language.', array('%entity_type' => $entity_type)));
- $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
- $this->assertEqual($uid, $translation->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to neutral language.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to neutral language.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($uid, $translation->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to neutral language.', ['%entity_type' => $entity_type]));
$field = $entity->get('name');
- $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
- $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
- $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', ['%entity_type' => $entity_type]));
// Create a language-aware entity and check that properties are stored
// as language-aware.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('name' => $name, 'user_id' => $uid, $langcode_key => $langcode));
+ ->create(['name' => $name, 'user_id' => $uid, $langcode_key => $langcode]);
$entity->save();
$entity = $storage->load($entity->id());
$default_langcode = $entity->language()->getId();
- $this->assertEqual($default_langcode, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($default_langcode, $langcode, format_string('%entity_type: Entity created as language specific.', ['%entity_type' => $entity_type]));
$field = $entity->getTranslation($langcode)->get('name');
- $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
- $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type)));
- $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', ['%entity_type' => $entity_type]));
// Create property translations.
- $properties = array();
+ $properties = [];
$default_langcode = $langcode;
foreach ($this->langcodes as $langcode) {
if ($langcode != $default_langcode) {
- $properties[$langcode] = array(
- 'name' => array(0 => $this->randomMachineName()),
- 'user_id' => array(0 => mt_rand(128, 256)),
- );
+ $properties[$langcode] = [
+ 'name' => [0 => $this->randomMachineName()],
+ 'user_id' => [0 => mt_rand(128, 256)],
+ ];
}
else {
- $properties[$langcode] = array(
- 'name' => array(0 => $name),
- 'user_id' => array(0 => $uid),
- );
+ $properties[$langcode] = [
+ 'name' => [0 => $name],
+ 'user_id' => [0 => $uid],
+ ];
}
$translation = $entity->hasTranslation($langcode) ? $entity->getTranslation($langcode) : $entity->addTranslation($langcode);
foreach ($properties[$langcode] as $field_name => $values) {
@@ -227,10 +227,10 @@ class EntityTranslationTest extends EntityLanguageTestBase {
// Check that property translation were correctly stored.
$entity = $storage->load($entity->id());
foreach ($this->langcodes as $langcode) {
- $args = array(
+ $args = [
'%entity_type' => $entity_type,
'%langcode' => $langcode,
- );
+ ];
$field = $entity->getTranslation($langcode)->get('name');
$this->assertEqual($properties[$langcode]['name'][0], $field->value, format_string('%entity_type: The entity name has been correctly stored for language %langcode.', $args));
$field_langcode = ($langcode == $entity->language()->getId()) ? $default_langcode : $langcode;
@@ -254,24 +254,24 @@ class EntityTranslationTest extends EntityLanguageTestBase {
->save();
$entities = $storage->loadMultiple();
- $this->assertEqual(count($entities), 3, format_string('%entity_type: Three entities were created.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 3, format_string('%entity_type: Three entities were created.', ['%entity_type' => $entity_type]));
$entities = $storage->loadMultiple([$translated_id]);
- $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by id.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by id.', ['%entity_type' => $entity_type]));
$entities = $storage->loadByProperties(['name' => $name]);
- $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities correctly loaded by name.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities correctly loaded by name.', ['%entity_type' => $entity_type]));
// @todo The default language condition should go away in favor of an
// explicit parameter.
$entities = $storage->loadByProperties(['name' => $properties[$langcode]['name'][0], $default_langcode_key => 0]);
- $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name translation.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name translation.', ['%entity_type' => $entity_type]));
$entities = $storage->loadByProperties([$langcode_key => $default_langcode, 'name' => $name]);
- $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name and language.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name and language.', ['%entity_type' => $entity_type]));
$entities = $storage->loadByProperties([$langcode_key => $langcode, 'name' => $properties[$langcode]['name'][0]]);
- $this->assertEqual(count($entities), 0, format_string('%entity_type: No entity loaded by name translation specifying the translation language.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 0, format_string('%entity_type: No entity loaded by name translation specifying the translation language.', ['%entity_type' => $entity_type]));
$entities = $storage->loadByProperties([$langcode_key => $langcode, 'name' => $properties[$langcode]['name'][0], $default_langcode_key => 0]);
- $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity loaded by name translation and language specifying to look for translations.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity loaded by name translation and language specifying to look for translations.', ['%entity_type' => $entity_type]));
$entities = $storage->loadByProperties(['user_id' => $properties[$langcode]['user_id'][0], $default_langcode_key => NULL]);
- $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities loaded by uid without caring about property translatability.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities loaded by uid without caring about property translatability.', ['%entity_type' => $entity_type]));
// Test property conditions and orders with multiple languages in the same
// query.
@@ -283,13 +283,13 @@ class EntityTranslationTest extends EntityLanguageTestBase {
->condition($group)
->condition('name', $properties[$langcode]['name'][0], '=', $langcode)
->execute();
- $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name and uid using different language meta conditions.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name and uid using different language meta conditions.', ['%entity_type' => $entity_type]));
// Test mixed property and field conditions.
$storage->resetCache($result);
$entity = $storage->load(reset($result));
$field_value = $this->randomString();
- $entity->getTranslation($langcode)->set($this->fieldName, array(array('value' => $field_value)));
+ $entity->getTranslation($langcode)->set($this->fieldName, [['value' => $field_value]]);
$entity->save();
$query = \Drupal::entityQuery($entity_type);
$default_langcode_group = $query->andConditionGroup()
@@ -303,7 +303,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
->condition($default_langcode_group)
->condition($langcode_group)
->execute();
- $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name, uid and field value using different language meta conditions.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name, uid and field value using different language meta conditions.', ['%entity_type' => $entity_type]));
}
/**
@@ -331,7 +331,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->entityManager
->getStorage($entity_type)
- ->create(array('name' => $this->randomMachineName(), $langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED));
+ ->create(['name' => $this->randomMachineName(), $langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED]);
$entity->save();
$hooks = $this->getHooksInfo();
@@ -462,8 +462,8 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$entity = $this->reloadEntity($entity);
$translation = $entity->getTranslation($langcode2);
$entity->removeTranslation($langcode2);
- foreach (array('get', 'set', '__get', '__set', 'createDuplicate') as $method) {
- $message = format_string('The @method method raises an exception when trying to manipulate a removed translation.', array('@method' => $method));
+ foreach (['get', 'set', '__get', '__set', 'createDuplicate'] as $method) {
+ $message = format_string('The @method method raises an exception when trying to manipulate a removed translation.', ['@method' => $method]);
try {
$translation->{$method}('name', $this->randomMachineName());
$this->fail($message);
@@ -484,8 +484,8 @@ class EntityTranslationTest extends EntityLanguageTestBase {
// Check that removing an invalid translation causes an exception to be
// thrown.
- foreach (array($default_langcode, LanguageInterface::LANGCODE_DEFAULT, $this->randomMachineName()) as $invalid_langcode) {
- $message = format_string('Removing an invalid translation (@langcode) causes an exception to be thrown.', array('@langcode' => $invalid_langcode));
+ foreach ([$default_langcode, LanguageInterface::LANGCODE_DEFAULT, $this->randomMachineName()] as $invalid_langcode) {
+ $message = format_string('Removing an invalid translation (@langcode) causes an exception to be thrown.', ['@langcode' => $invalid_langcode]);
try {
$entity->removeTranslation($invalid_langcode);
$this->fail($message);
@@ -566,16 +566,16 @@ class EntityTranslationTest extends EntityLanguageTestBase {
->getStorage('entity_test_mul_default_value')
->create(['name' => $this->randomMachineName(), 'langcode' => $langcode]);
$translation = $entity->addTranslation($langcode2);
- $expected = array(
- array(
+ $expected = [
+ [
'shape' => "shape:0:description_$langcode2",
'color' => "color:0:description_$langcode2",
- ),
- array(
+ ],
+ [
'shape' => "shape:1:description_$langcode2",
'color' => "color:1:description_$langcode2",
- ),
- );
+ ],
+ ];
$this->assertEqual($translation->description->getValue(), $expected, 'Language-aware default values correctly populated.');
$this->assertEqual($translation->description->getLangcode(), $langcode2, 'Field object has the expected langcode.');
@@ -606,7 +606,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$current_langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();
$this->langcodes[] = $current_langcode;
- $values = array();
+ $values = [];
foreach ($this->langcodes as $langcode) {
$values[$langcode]['name'] = $this->randomMachineName();
$values[$langcode]['user_id'] = mt_rand(0, 127);
@@ -623,7 +623,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$this->languageManager->reset();
$controller = $this->entityManager->getStorage($entity_type);
- $entity = $controller->create(array($langcode_key => $default_langcode) + $values[$default_langcode]);
+ $entity = $controller->create([$langcode_key => $default_langcode] + $values[$default_langcode]);
$entity->save();
$entity->addTranslation($langcode, $values[$langcode]);
@@ -649,7 +649,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$this->assertEqual($current_langcode, $translation->language()->getId(), 'The current translation language matches the current language.');
// Check that if the entity has no translation no fallback is applied.
- $entity2 = $controller->create(array($langcode_key => $default_langcode));
+ $entity2 = $controller->create([$langcode_key => $default_langcode]);
// Get an view builder.
$controller = $this->entityManager->getViewBuilder($entity_type);
$entity2_build = $controller->view($entity2);
@@ -686,12 +686,12 @@ class EntityTranslationTest extends EntityLanguageTestBase {
// Check that field translatability can be altered to be enabled or disabled
// in field definitions.
$entity_type = 'entity_test_mulrev';
- $this->state->set('entity_test.field_definitions.translatable', array('name' => FALSE));
+ $this->state->set('entity_test.field_definitions.translatable', ['name' => FALSE]);
$this->entityManager->clearCachedFieldDefinitions();
$definitions = $this->entityManager->getBaseFieldDefinitions($entity_type);
$this->assertFalse($definitions['name']->isTranslatable(), 'Field translatability can be disabled programmatically.');
- $this->state->set('entity_test.field_definitions.translatable', array('name' => TRUE));
+ $this->state->set('entity_test.field_definitions.translatable', ['name' => TRUE]);
$this->entityManager->clearCachedFieldDefinitions();
$definitions = $this->entityManager->getBaseFieldDefinitions($entity_type);
$this->assertTrue($definitions['name']->isTranslatable(), 'Field translatability can be enabled programmatically.');
@@ -702,17 +702,17 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$this->assertFalse($definitions['id']->isTranslatable(), 'Field translatability is disabled by default.');
// Check that entity id keys have the expect translatability.
- $translatable_fields = array(
+ $translatable_fields = [
'id' => TRUE,
'uuid' => TRUE,
'revision_id' => TRUE,
'type' => TRUE,
'langcode' => FALSE,
- );
+ ];
foreach ($translatable_fields as $name => $translatable) {
- $this->state->set('entity_test.field_definitions.translatable', array($name => $translatable));
+ $this->state->set('entity_test.field_definitions.translatable', [$name => $translatable]);
$this->entityManager->clearCachedFieldDefinitions();
- $message = format_string('Field %field cannot be translatable.', array('%field' => $name));
+ $message = format_string('Field %field cannot be translatable.', ['%field' => $name]);
try {
$this->entityManager->getBaseFieldDefinitions($entity_type);
@@ -747,13 +747,13 @@ class EntityTranslationTest extends EntityLanguageTestBase {
// check that field languages match entity language regardless of field
// translatability.
- $values = array(
+ $values = [
$langcode_key => $langcode,
$this->fieldName => $this->randomMachineName(),
$this->untranslatableFieldName => $this->randomMachineName(),
- );
+ ];
$entity = $controller->create($values);
- foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) {
+ foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) {
$this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected.');
}
@@ -761,16 +761,16 @@ class EntityTranslationTest extends EntityLanguageTestBase {
// changing it.
$langcode = $this->langcodes[1];
$entity->{$langcode_key}->value = $langcode;
- foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) {
+ foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) {
$this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected after changing entity language.');
}
// Check that entity translation does not affect the language of original
// field values and untranslatable ones.
$langcode = $this->langcodes[0];
- $entity->addTranslation($this->langcodes[2], array($this->fieldName => $this->randomMachineName()));
+ $entity->addTranslation($this->langcodes[2], [$this->fieldName => $this->randomMachineName()]);
$entity->{$langcode_key}->value = $langcode;
- foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) {
+ foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) {
$this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected after translating the entity and changing language.');
}
@@ -792,21 +792,21 @@ class EntityTranslationTest extends EntityLanguageTestBase {
function testEntityAdapter() {
$entity_type = 'entity_test';
$default_langcode = 'en';
- $values[$default_langcode] = array('name' => $this->randomString());
+ $values[$default_langcode] = ['name' => $this->randomString()];
$controller = $this->entityManager->getStorage($entity_type);
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $controller->create($values[$default_langcode]);
foreach ($this->langcodes as $langcode) {
- $values[$langcode] = array('name' => $this->randomString());
+ $values[$langcode] = ['name' => $this->randomString()];
$entity->addTranslation($langcode, $values[$langcode]);
}
- $langcodes = array_merge(array($default_langcode), $this->langcodes);
+ $langcodes = array_merge([$default_langcode], $this->langcodes);
foreach ($langcodes as $langcode) {
$adapter = $entity->getTranslation($langcode)->getTypedData();
$name = $adapter->get('name')->value;
- $this->assertEqual($name, $values[$langcode]['name'], SafeMarkup::format('Name correctly retrieved from "@langcode" adapter', array('@langcode' => $langcode)));
+ $this->assertEqual($name, $values[$langcode]['name'], SafeMarkup::format('Name correctly retrieved from "@langcode" adapter', ['@langcode' => $langcode]));
}
}
@@ -879,11 +879,11 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$field->save();
// Create an entity with both translatable and untranslatable test fields.
- $values = array(
+ $values = [
'name' => $this->randomString(),
'translatable_test_field' => $this->randomString(),
'untranslatable_test_field' => $this->randomString(),
- );
+ ];
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $controller->create($values);
@@ -940,11 +940,11 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$storage = $this->entityManager->getStorage($entity_type);
// Create an entity with both translatable and untranslatable test fields.
- $values = array(
+ $values = [
'name' => $this->randomString(),
'translatable_test_field' => $this->randomString(),
'untranslatable_test_field' => $this->randomString(),
- );
+ ];
/** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\Core\TypedData\TranslationStatusInterface $entity */
// Test that newly created entity has the translation status
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php
index 87d76b484c4..3671d6d408e 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php
@@ -18,7 +18,7 @@ class EntityTypeConstraintValidatorTest extends EntityKernelTestBase {
*/
protected $typedData;
- public static $modules = array('node', 'field', 'user');
+ public static $modules = ['node', 'field', 'user'];
protected function setUp() {
parent::setUp();
@@ -32,13 +32,13 @@ class EntityTypeConstraintValidatorTest extends EntityKernelTestBase {
// Create a typed data definition with an EntityType constraint.
$entity_type = 'node';
$definition = DataDefinition::create('entity_reference')
- ->setConstraints(array(
+ ->setConstraints([
'EntityType' => $entity_type,
- )
+ ]
);
// Test the validation.
- $node = $this->container->get('entity.manager')->getStorage('node')->create(array('type' => 'page'));
+ $node = $this->container->get('entity.manager')->getStorage('node')->create(['type' => 'page']);
$typed_data = $this->typedData->create($definition, $node);
$violations = $typed_data->validate();
$this->assertEqual($violations->count(), 0, 'Validation passed for correct value.');
@@ -53,7 +53,7 @@ class EntityTypeConstraintValidatorTest extends EntityKernelTestBase {
// Make sure the information provided by a violation is correct.
$violation = $violations[0];
- $this->assertEqual($violation->getMessage(), t('The entity must be of type %type.', array('%type' => $entity_type)), 'The message for invalid value is correct.');
+ $this->assertEqual($violation->getMessage(), t('The entity must be of type %type.', ['%type' => $entity_type]), 'The message for invalid value is correct.');
$this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.');
$this->assertEqual($violation->getInvalidValue(), $account, 'The invalid value is set correctly in the violation.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php
index b61a6dd412d..9d5095d1494 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php
@@ -31,7 +31,7 @@ class EntityTypedDataDefinitionTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'text', 'node', 'user');
+ public static $modules = ['filter', 'text', 'node', 'user'];
protected function setUp() {
parent::setup();
@@ -51,14 +51,14 @@ class EntityTypedDataDefinitionTest extends KernelTestBase {
$this->assertTrue($field_item_definition instanceof ComplexDataDefinitionInterface);
// Derive metadata about field item properties.
- $this->assertEqual(array_keys($field_item_definition->getPropertyDefinitions()), array('value'));
+ $this->assertEqual(array_keys($field_item_definition->getPropertyDefinitions()), ['value']);
$this->assertEqual($field_item_definition->getPropertyDefinition('value')->getDataType(), 'integer');
$this->assertEqual($field_item_definition->getMainPropertyName(), 'value');
$this->assertNull($field_item_definition->getPropertyDefinition('invalid'));
// Test accessing field item property metadata via the field definition.
$this->assertTrue($field_definition instanceof FieldDefinitionInterface);
- $this->assertEqual(array_keys($field_definition->getPropertyDefinitions()), array('value'));
+ $this->assertEqual(array_keys($field_definition->getPropertyDefinitions()), ['value']);
$this->assertEqual($field_definition->getPropertyDefinition('value')->getDataType(), 'integer');
$this->assertEqual($field_definition->getMainPropertyName(), 'value');
$this->assertNull($field_definition->getPropertyDefinition('invalid'));
@@ -106,7 +106,7 @@ class EntityTypedDataDefinitionTest extends KernelTestBase {
// Config entities don't support typed data.
$entity_definition = EntityDataDefinition::create('node_type');
- $this->assertEqual(array(), $entity_definition->getPropertyDefinitions());
+ $this->assertEqual([], $entity_definition->getPropertyDefinitions());
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php
index ae26ec590bc..c76ea6a8613 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php
@@ -42,10 +42,10 @@ class EntityUUIDTest extends EntityKernelTestBase {
$uuid = $uuid_service->generate();
$custom_entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => $this->randomMachineName(),
'uuid' => $uuid,
- ));
+ ]);
$this->assertIdentical($custom_entity->uuid(), $uuid);
// Save this entity, so we have more than one later.
$custom_entity->save();
@@ -53,7 +53,7 @@ class EntityUUIDTest extends EntityKernelTestBase {
// Verify that a new UUID is generated upon creating an entity.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('name' => $this->randomMachineName()));
+ ->create(['name' => $this->randomMachineName()]);
$uuid = $entity->uuid();
$this->assertTrue($uuid);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php
index dc7d94f0603..bf2a147e0a1 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php
@@ -16,7 +16,7 @@ class EntityValidationTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('filter', 'text');
+ public static $modules = ['filter', 'text'];
/**
* @var string
@@ -44,7 +44,7 @@ class EntityValidationTest extends EntityKernelTestBase {
entity_test_install();
// Install required default configuration for filter module.
- $this->installConfig(array('system', 'filter'));
+ $this->installConfig(['system', 'filter']);
}
/**
@@ -123,13 +123,13 @@ class EntityValidationTest extends EntityKernelTestBase {
$test_entity->id->value = -1;
$violations = $test_entity->validate();
$this->assertEqual($violations->count(), 1, 'Validation failed.');
- $this->assertEqual($violations[0]->getMessage(), t('%name: The integer must be larger or equal to %min.', array('%name' => 'ID', '%min' => 0)));
+ $this->assertEqual($violations[0]->getMessage(), t('%name: The integer must be larger or equal to %min.', ['%name' => 'ID', '%min' => 0]));
$test_entity = clone $entity;
$test_entity->uuid->value = $this->randomString(129);
$violations = $test_entity->validate();
$this->assertEqual($violations->count(), 1, 'Validation failed.');
- $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => 'UUID', '@max' => 128)));
+ $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => 'UUID', '@max' => 128]));
$test_entity = clone $entity;
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
@@ -137,7 +137,7 @@ class EntityValidationTest extends EntityKernelTestBase {
$violations = $test_entity->validate();
// This should fail on AllowedValues and Length constraints.
$this->assertEqual($violations->count(), 2, 'Validation failed.');
- $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '12')));
+ $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', ['%limit' => '12']));
$this->assertEqual($violations[1]->getMessage(), t('The value you selected is not a valid choice.'));
$test_entity = clone $entity;
@@ -150,7 +150,7 @@ class EntityValidationTest extends EntityKernelTestBase {
$test_entity->name->value = $this->randomString(33);
$violations = $test_entity->validate();
$this->assertEqual($violations->count(), 1, 'Validation failed.');
- $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => 'Name', '@max' => 32)));
+ $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => 'Name', '@max' => 32]));
// Make sure the information provided by a violation is correct.
$violation = $violations[0];
@@ -162,7 +162,7 @@ class EntityValidationTest extends EntityKernelTestBase {
$test_entity->set('user_id', 9999);
$violations = $test_entity->validate();
$this->assertEqual($violations->count(), 1, 'Validation failed.');
- $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', array('%type' => 'user', '%id' => 9999)));
+ $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', ['%type' => 'user', '%id' => 9999]));
$test_entity = clone $entity;
$test_entity->field_test_text->format = $this->randomString(33);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php
index 0143128f197..e1537bc809c 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php
@@ -23,7 +23,7 @@ class EntityViewBuilderTest extends EntityKernelTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installConfig(array('user', 'entity_test'));
+ $this->installConfig(['user', 'entity_test']);
// Give anonymous users permission to view test entities.
Role::load(RoleInterface::ANONYMOUS_ID)
@@ -182,7 +182,7 @@ class EntityViewBuilderTest extends EntityKernelTestBase {
// Set a weight for the label component.
entity_get_display('entity_test', 'entity_test', 'full')
- ->setComponent('label', array('weight' => 20))
+ ->setComponent('label', ['weight' => 20])
->save();
// Create and build a test entity.
@@ -204,10 +204,10 @@ class EntityViewBuilderTest extends EntityKernelTestBase {
* The created entity.
*/
protected function createTestEntity($entity_type) {
- $data = array(
+ $data = [
'bundle' => $entity_type,
'name' => $this->randomMachineName(),
- );
+ ];
return $this->container->get('entity.manager')->getStorage($entity_type)->create($data);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
index 449f3f23841..30e817d1db7 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
@@ -23,7 +23,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('field', 'field_test', 'text', 'entity_test');
+ public static $modules = ['field', 'field_test', 'text', 'entity_test'];
/**
* The name of the created field.
@@ -80,12 +80,12 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$this->fieldName = strtolower($this->randomMachineName());
$this->fieldCardinality = 4;
- $this->fieldStorage = FieldStorageConfig::create(array(
+ $this->fieldStorage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $entity_type,
'type' => 'test_field',
'cardinality' => $this->fieldCardinality,
- ));
+ ]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
@@ -107,10 +107,10 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$entity_type = $bundle = 'entity_test_rev';
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
- $columns = array('bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', $this->tableMapping->getFieldColumnName($this->fieldStorage, 'value'));
+ $columns = ['bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', $this->tableMapping->getFieldColumnName($this->fieldStorage, 'value')];
// Create an entity with four revisions.
- $revision_ids = array();
+ $revision_ids = [];
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create();
@@ -123,20 +123,20 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
}
// Generate values and insert them directly in the storage tables.
- $values = array();
+ $values = [];
$query = db_insert($this->revisionTable)->fields($columns);
foreach ($revision_ids as $revision_id) {
// Put one value too many.
for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) {
$value = mt_rand(1, 127);
$values[$revision_id][] = $value;
- $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value));
+ $query->values([$bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value]);
}
$query->execute();
}
$query = db_insert($this->table)->fields($columns);
foreach ($values[$revision_id] as $delta => $value) {
- $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value));
+ $query->values([$bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value]);
}
$query->execute();
@@ -167,7 +167,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Add a translation in an unavailable language code and verify it is not
// loaded.
$unavailable_langcode = 'xx';
- $values = array($bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127));
+ $values = [$bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127)];
db_insert($this->table)->fields($columns)->values($values)->execute();
db_insert($this->revisionTable)->fields($columns)->values($values)->execute();
$entity = $storage->load($entity->id());
@@ -183,10 +183,10 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
->getStorage($entity_type)
->create();
- $revision_values = array();
+ $revision_values = [];
// Check insert. Add one value too many.
- $values = array();
+ $values = [];
for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
}
@@ -197,7 +197,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
$this->assertEqual(count($rows), $this->fieldCardinality);
foreach ($rows as $delta => $row) {
- $expected = array(
+ $expected = [
'bundle' => $bundle,
'deleted' => 0,
'entity_id' => $entity->id(),
@@ -205,13 +205,13 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
'langcode' => $entity->language()->getId(),
'delta' => $delta,
$this->fieldName . '_value' => $values[$delta]['value'],
- );
+ ];
$this->assertEqual($row, $expected, "Row $delta was stored as expected.");
}
// Test update. Add less values and check that the previous values did not
// persist.
- $values = array();
+ $values = [];
for ($delta = 0; $delta <= $this->fieldCardinality - 2; $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
}
@@ -220,7 +220,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
$this->assertEqual(count($rows), count($values));
foreach ($rows as $delta => $row) {
- $expected = array(
+ $expected = [
'bundle' => $bundle,
'deleted' => 0,
'entity_id' => $entity->id(),
@@ -228,13 +228,13 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
'langcode' => $entity->language()->getId(),
'delta' => $delta,
$this->fieldName . '_value' => $values[$delta]['value'],
- );
+ ];
$this->assertEqual($row, $expected, "Row $delta was stored as expected.");
}
// Create a new revision.
$revision_values[$entity->getRevisionId()] = $values;
- $values = array();
+ $values = [];
for ($delta = 0; $delta < $this->fieldCardinality; $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
}
@@ -248,7 +248,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$rows = db_select($this->revisionTable, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
$this->assertEqual(count($rows), min(count($values), $this->fieldCardinality));
foreach ($rows as $delta => $row) {
- $expected = array(
+ $expected = [
'bundle' => $bundle,
'deleted' => 0,
'entity_id' => $entity->id(),
@@ -256,7 +256,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
'langcode' => $entity->language()->getId(),
'delta' => $delta,
$this->fieldName . '_value' => $values[$delta]['value'],
- );
+ ];
$this->assertEqual($row, $expected, "Row $delta was stored as expected.");
}
}
@@ -279,15 +279,15 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Create two fields and generate random values.
$name_base = Unicode::strtolower($this->randomMachineName(FieldStorageConfig::NAME_MAX_LENGTH - 1));
- $field_names = array();
- $values = array();
+ $field_names = [];
+ $values = [];
for ($i = 0; $i < 2; $i++) {
$field_names[$i] = $name_base . $i;
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
'type' => 'test_field',
- ))->save();
+ ])->save();
FieldConfig::create([
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
@@ -315,12 +315,12 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
function testUpdateFieldSchemaWithData() {
$entity_type = 'entity_test_rev';
// Create a decimal 5.2 field and add some data.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'decimal52',
'entity_type' => $entity_type,
'type' => 'decimal',
- 'settings' => array('precision' => 5, 'scale' => 2),
- ));
+ 'settings' => ['precision' => 5, 'scale' => 2],
+ ]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
@@ -329,10 +329,10 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$field->save();
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'id' => 0,
'revision_id' => 0,
- ));
+ ]);
$entity->decimal52->value = '1.235';
$entity->save();
@@ -352,12 +352,12 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
*/
function testFieldUpdateFailure() {
// Create a text field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => 'test_text',
'entity_type' => 'entity_test_rev',
'type' => 'text',
- 'settings' => array('max_length' => 255),
- ));
+ 'settings' => ['max_length' => 255],
+ ]);
$field_storage->save();
// Attempt to update the field in a way that would break the storage. The
@@ -376,12 +376,12 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
}
// Ensure that the field tables are still there.
- $tables = array(
+ $tables = [
$this->tableMapping->getDedicatedDataTableName($prior_field_storage),
$this->tableMapping->getDedicatedRevisionTableName($prior_field_storage),
- );
+ ];
foreach ($tables as $table_name) {
- $this->assertTrue(db_table_exists($table_name), t('Table %table exists.', array('%table' => $table_name)));
+ $this->assertTrue(db_table_exists($table_name), t('Table %table exists.', ['%table' => $table_name]));
}
}
@@ -392,32 +392,32 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Create a decimal field.
$field_name = 'testfield';
$entity_type = 'entity_test_rev';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'type' => 'text',
- ));
+ ]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $entity_type,
]);
$field->save();
- $tables = array($this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage));
+ $tables = [$this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage)];
// Verify the indexes we will create do not exist yet.
foreach ($tables as $table) {
- $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in @table", array('@table' => $table)));
- $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in @table", array('@table' => $table)));
+ $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in @table", ['@table' => $table]));
+ $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in @table", ['@table' => $table]));
}
// Add data so the table cannot be dropped.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'id' => 1,
'revision_id' => 1,
- ));
+ ]);
$entity->$field_name->value = 'field data';
$entity->enforceIsNew();
$entity->save();
@@ -426,15 +426,15 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$field_storage->setIndexes(['value' => [['value', 255]]]);
$field_storage->save();
foreach ($tables as $table) {
- $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in @table", array('@table' => $table)));
+ $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in @table", ['@table' => $table]));
}
// Add a different index, removing the existing custom one.
$field_storage->setIndexes(['value_format' => [['value', 127], ['format', 127]]]);
$field_storage->save();
foreach ($tables as $table) {
- $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in @table", array('@table' => $table)));
- $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in @table", array('@table' => $table)));
+ $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in @table", ['@table' => $table]));
+ $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in @table", ['@table' => $table]));
}
// Verify that the tables were not dropped in the process.
@@ -450,12 +450,12 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// field_test_field_schema()).
$field_name = 'testfield';
$foreign_key_name = 'shape';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'shape',
- 'settings' => array('foreign_key_name' => $foreign_key_name),
- ));
+ 'settings' => ['foreign_key_name' => $foreign_key_name],
+ ]);
$field_storage->save();
// Get the field schema.
$schema = $field_storage->getSchema();
@@ -487,11 +487,11 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Short entity type and field name.
$entity_type = 'short_entity_type';
$field_name = 'short_field_name';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
- ));
+ ]);
$expected = 'short_entity_type__short_field_name';
$this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected);
$expected = 'short_entity_type_revision__short_field_name';
@@ -500,11 +500,11 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Short entity type, long field name
$entity_type = 'short_entity_type';
$field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
- ));
+ ]);
$expected = 'short_entity_type__' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
$this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected);
$expected = 'short_entity_type_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
@@ -513,11 +513,11 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Long entity type, short field name
$entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz';
$field_name = 'short_field_name';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
- ));
+ ]);
$expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
$this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected);
$expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
@@ -526,31 +526,31 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Long entity type and field name.
$entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz';
$field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz';
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
- ));
+ ]);
$expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
$this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected);
$expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
$this->assertEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $expected);
// Try creating a second field and check there are no clashes.
- $field_storage2 = FieldStorageConfig::create(array(
+ $field_storage2 = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name . '2',
'type' => 'test_field',
- ));
+ ]);
$this->assertNotEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedDataTableName($field_storage2));
$this->assertNotEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage2));
// Deleted field.
- $field_storage = FieldStorageConfig::create(array(
+ $field_storage = FieldStorageConfig::create([
'entity_type' => 'some_entity_type',
'field_name' => 'some_field_name',
'type' => 'test_field',
'deleted' => TRUE,
- ));
+ ]);
$expected = 'field_deleted_data_' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
$this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage, TRUE), $expected);
$expected = 'field_deleted_revision_' . substr(hash('sha256', $field_storage->uuid()), 0, 10);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php
index b301c64f530..c398732f3c5 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php
@@ -20,10 +20,10 @@ class FieldTranslationSqlStorageTest extends EntityLanguageTestBase {
$entity_type = 'entity_test_mul';
$controller = $this->entityManager->getStorage($entity_type);
- $values = array(
+ $values = [
$this->fieldName => $this->randomMachineName(),
$this->untranslatableFieldName => $this->randomMachineName(),
- );
+ ];
$entity = $controller->create($values);
$entity->save();
@@ -45,7 +45,7 @@ class FieldTranslationSqlStorageTest extends EntityLanguageTestBase {
// before.
$this->toggleFieldTranslatability($entity_type, $entity_type);
$entity = $this->reloadEntity($entity);
- foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) {
+ foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) {
$this->assertEqual($entity->get($field_name)->value, $values[$field_name], 'Field language works as expected after switching translatability.');
}
@@ -76,7 +76,7 @@ class FieldTranslationSqlStorageTest extends EntityLanguageTestBase {
$entity_type = $entity->getEntityTypeId();
$id = $entity->id();
$langcode = $entity->getUntranslated()->language()->getId();
- $fields = array($this->fieldName, $this->untranslatableFieldName);
+ $fields = [$this->fieldName, $this->untranslatableFieldName];
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php
index 50d173bc284..5ae824b71a2 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php
@@ -15,7 +15,7 @@ use Drupal\KernelTests\KernelTestBase;
*/
class FieldWidgetConstraintValidatorTest extends KernelTestBase {
- public static $modules = array('entity_test', 'field', 'user', 'system');
+ public static $modules = ['entity_test', 'field', 'user', 'system'];
/**
* {@inheritdoc}
@@ -37,9 +37,9 @@ class FieldWidgetConstraintValidatorTest extends KernelTestBase {
$entity_type = 'entity_test_constraint_violation';
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array('id' => 1, 'revision_id' => 1));
+ ->create(['id' => 1, 'revision_id' => 1]);
$display = entity_get_form_display($entity_type, $entity_type, 'default');
- $form = array();
+ $form = [];
$form_state = new FormState();
$display->buildForm($entity, $form, $form_state);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php
index 64bb933dd36..a365ea58095 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php
@@ -21,14 +21,14 @@ class ValidReferenceConstraintValidatorTest extends EntityKernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('field', 'user');
+ public static $modules = ['field', 'user'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
- $this->installSchema('user', array('users_data'));
+ $this->installSchema('user', ['users_data']);
$this->typedData = $this->container->get('typed_data_manager');
}
@@ -40,18 +40,18 @@ class ValidReferenceConstraintValidatorTest extends EntityKernelTestBase {
$entity = $this->createUser();
// By default entity references already have the ValidReference constraint.
$definition = BaseFieldDefinition::create('entity_reference')
- ->setSettings(array('target_type' => 'user'));
+ ->setSettings(['target_type' => 'user']);
- $typed_data = $this->typedData->create($definition, array('target_id' => $entity->id()));
+ $typed_data = $this->typedData->create($definition, ['target_id' => $entity->id()]);
$violations = $typed_data->validate();
$this->assertFalse($violations->count(), 'Validation passed for correct value.');
// NULL is also considered a valid reference.
- $typed_data = $this->typedData->create($definition, array('target_id' => NULL));
+ $typed_data = $this->typedData->create($definition, ['target_id' => NULL]);
$violations = $typed_data->validate();
$this->assertFalse($violations->count(), 'Validation passed for correct value.');
- $typed_data = $this->typedData->create($definition, array('target_id' => $entity->id()));
+ $typed_data = $this->typedData->create($definition, ['target_id' => $entity->id()]);
// Delete the referenced entity.
$entity->delete();
$violations = $typed_data->validate();
@@ -59,10 +59,10 @@ class ValidReferenceConstraintValidatorTest extends EntityKernelTestBase {
// Make sure the information provided by a violation is correct.
$violation = $violations[0];
- $this->assertEqual($violation->getMessage(), t('The referenced entity (%type: %id) does not exist.', array(
+ $this->assertEqual($violation->getMessage(), t('The referenced entity (%type: %id) does not exist.', [
'%type' => 'user',
'%id' => $entity->id(),
- )), 'The message for invalid value is correct.');
+ ]), 'The message for invalid value is correct.');
$this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php
index f55d744f70f..c0ec629721c 100644
--- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php
@@ -32,7 +32,7 @@ class ModuleImplementsAlterTest extends KernelTestBase {
'Module handler instance is still the same.');
// Install the module_test module.
- \Drupal::service('module_installer')->install(array('module_test'));
+ \Drupal::service('module_installer')->install(['module_test']);
// Assert that the \Drupal::moduleHandler() instance has been replaced.
$this->assertFalse($module_handler === \Drupal::moduleHandler(),
@@ -76,7 +76,7 @@ class ModuleImplementsAlterTest extends KernelTestBase {
function testModuleImplementsAlterNonExistingImplementation() {
// Install the module_test module.
- \Drupal::service('module_installer')->install(array('module_test'));
+ \Drupal::service('module_installer')->install(['module_test']);
try {
// Trigger hook discovery.
diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php
index 5a59a235733..f019ff2917a 100644
--- a/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php
@@ -34,7 +34,7 @@ class FieldAccessTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
// Install field configuration.
- $this->installConfig(array('field'));
+ $this->installConfig(['field']);
// The users table is needed for creating dummy user accounts.
$this->installEntitySchema('user');
// Register entity_test text field.
@@ -49,18 +49,18 @@ class FieldAccessTest extends KernelTestBase {
* @see entity_test_entity_field_access_alter()
*/
function testFieldAccess() {
- $values = array(
+ $values = [
'name' => $this->randomMachineName(),
'user_id' => 1,
- 'field_test_text' => array(
+ 'field_test_text' => [
'value' => 'no access value',
'format' => 'full_html',
- ),
- );
+ ],
+ ];
$entity = EntityTest::create($values);
// Create a dummy user account for testing access with.
- $values = array('name' => 'test');
+ $values = ['name' => 'test'];
$account = User::create($values);
$this->assertFalse($entity->field_test_text->access('view', $account), 'Access to the field was denied.');
diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php
index af2fb07e244..b9d545e29f9 100644
--- a/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php
@@ -73,7 +73,7 @@ class FieldModuleUninstallValidatorTest extends EntityKernelTestBase {
try {
$message = 'Module uninstallation fails as the module provides a base field which has content.';
- $this->getModuleInstaller()->uninstall(array('entity_test_extra'));
+ $this->getModuleInstaller()->uninstall(['entity_test_extra']);
$this->fail($message);
}
catch (ModuleUninstallValidatorException $e) {
@@ -93,7 +93,7 @@ class FieldModuleUninstallValidatorTest extends EntityKernelTestBase {
]);
$entity->save();
try {
- $this->getModuleInstaller()->uninstall(array('entity_test_extra'));
+ $this->getModuleInstaller()->uninstall(['entity_test_extra']);
$this->fail('Module uninstallation fails as the module provides a bundle field which has content.');
}
catch (ModuleUninstallValidatorException $e) {
diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php
index a55888f6167..583e55b7c40 100644
--- a/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php
@@ -19,7 +19,7 @@ class FieldSettingsTest extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('field', 'field_test');
+ public static $modules = ['field', 'field_test'];
/**
* @covers \Drupal\Core\Field\BaseFieldDefinition::getSettings
diff --git a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
index d7e7c382f6e..c8aa14ec92d 100644
--- a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
@@ -106,14 +106,14 @@ class DirectoryTest extends FileTestBase {
$directory = 'core/misc';
$original = $directory . '/' . $basename;
$path = file_create_filename($basename, $directory);
- $this->assertEqual($path, $original, format_string('New filepath %new equals %original.', array('%new' => $path, '%original' => $original)), 'File');
+ $this->assertEqual($path, $original, format_string('New filepath %new equals %original.', ['%new' => $path, '%original' => $original]), 'File');
// Then we test against a file that already exists within that directory.
$basename = 'druplicon.png';
$original = $directory . '/' . $basename;
$expected = $directory . '/druplicon_0.png';
$path = file_create_filename($basename, $directory);
- $this->assertEqual($path, $expected, format_string('Creating a new filepath from %original equals %new (expected %expected).', array('%new' => $path, '%original' => $original, '%expected' => $expected)), 'File');
+ $this->assertEqual($path, $expected, format_string('Creating a new filepath from %original equals %new (expected %expected).', ['%new' => $path, '%original' => $original, '%expected' => $expected]), 'File');
// @TODO: Finally we copy a file into a directory several times, to ensure a properly iterating filename suffix.
}
diff --git a/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php b/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php
index 548d1bcf9d7..0b10d9288f2 100644
--- a/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php
@@ -16,7 +16,7 @@ abstract class FileTestBase extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* A stream wrapper scheme to register for the test.
@@ -70,9 +70,9 @@ abstract class FileTestBase extends KernelTestBase {
$this->setSetting('file_public_path', $public_file_directory);
- $GLOBALS['config_directories'] = array(
+ $GLOBALS['config_directories'] = [
CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync',
- );
+ ];
}
/**
@@ -105,7 +105,7 @@ abstract class FileTestBase extends KernelTestBase {
}
if (!isset($message)) {
- $message = t('Expected file permission to be %expected, actually were %actual.', array('%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode)));
+ $message = t('Expected file permission to be %expected, actually were %actual.', ['%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode)]);
}
$this->assertEqual($actual_mode, $expected_mode, $message);
}
@@ -141,7 +141,7 @@ abstract class FileTestBase extends KernelTestBase {
}
if (!isset($message)) {
- $message = t('Expected directory permission to be %expected, actually were %actual.', array('%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode)));
+ $message = t('Expected directory permission to be %expected, actually were %actual.', ['%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode)]);
}
$this->assertEqual($actual_mode, $expected_mode, $message);
}
diff --git a/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php b/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php
index 0ef50780297..896627671d0 100644
--- a/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php
@@ -82,11 +82,11 @@ class HtaccessTest extends KernelTestBase {
*/
protected function assertFilePermissions($uri, $expected) {
$actual = fileperms($uri) & 0777;
- return $this->assertIdentical($actual, $expected, SafeMarkup::format('@uri file permissions @actual are identical to @expected.', array(
+ return $this->assertIdentical($actual, $expected, SafeMarkup::format('@uri file permissions @actual are identical to @expected.', [
'@uri' => $uri,
'@actual' => 0 . decoct($actual),
'@expected' => 0 . decoct($expected),
- )));
+ ]));
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php b/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php
index 9bfe681544c..05ac7c2557f 100644
--- a/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php
@@ -14,7 +14,7 @@ class MimeTypeTest extends FileTestBase {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* Test mapping of mimetypes from filenames.
@@ -22,7 +22,7 @@ class MimeTypeTest extends FileTestBase {
public function testFileMimeTypeDetection() {
$prefixes = ['public://', 'private://', 'temporary://', 'dummy-remote://'];
- $test_case = array(
+ $test_case = [
'test.jar' => 'application/java-archive',
'test.jpeg' => 'image/jpeg',
'test.JPEG' => 'image/jpeg',
@@ -37,7 +37,7 @@ class MimeTypeTest extends FileTestBase {
'foo.file_test_2' => 'madeup/file_test_2',
'foo.doc' => 'madeup/doc',
'test.ogg' => 'audio/ogg',
- );
+ ];
$guesser = $this->container->get('file.mime_type.guesser');
// Test using default mappings.
@@ -45,27 +45,27 @@ class MimeTypeTest extends FileTestBase {
// Test stream [URI].
foreach ($prefixes as $prefix) {
$output = $guesser->guess($prefix . $input);
- $this->assertIdentical($output, $expected, format_string('Mimetype for %input is %output (expected: %expected).', array('%input' => $prefix . $input, '%output' => $output, '%expected' => $expected)));
+ $this->assertIdentical($output, $expected, format_string('Mimetype for %input is %output (expected: %expected).', ['%input' => $prefix . $input, '%output' => $output, '%expected' => $expected]));
}
// Test normal path equivalent
$output = $guesser->guess($input);
- $this->assertIdentical($output, $expected, format_string('Mimetype (using default mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
+ $this->assertIdentical($output, $expected, format_string('Mimetype (using default mappings) for %input is %output (expected: %expected).', ['%input' => $input, '%output' => $output, '%expected' => $expected]));
}
// Now test the extension gusser by passing in a custom mapping.
- $mapping = array(
- 'mimetypes' => array(
+ $mapping = [
+ 'mimetypes' => [
0 => 'application/java-archive',
1 => 'image/jpeg',
- ),
- 'extensions' => array(
+ ],
+ 'extensions' => [
'jar' => 0,
'jpg' => 1,
- )
- );
+ ]
+ ];
- $test_case = array(
+ $test_case = [
'test.jar' => 'application/java-archive',
'test.jpeg' => 'application/octet-stream',
'test.jpg' => 'image/jpeg',
@@ -79,13 +79,13 @@ class MimeTypeTest extends FileTestBase {
'foo.file_test_2' => 'application/octet-stream',
'foo.doc' => 'application/octet-stream',
'test.ogg' => 'application/octet-stream',
- );
+ ];
$extension_guesser = $this->container->get('file.mime_type.guesser.extension');
$extension_guesser->setMapping($mapping);
foreach ($test_case as $input => $expected) {
$output = $extension_guesser->guess($input);
- $this->assertIdentical($output, $expected, format_string('Mimetype (using passed-in mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected)));
+ $this->assertIdentical($output, $expected, format_string('Mimetype (using passed-in mappings) for %input is %output (expected: %expected).', ['%input' => $input, '%output' => $output, '%expected' => $expected]));
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php b/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php
index 1fff41e2f9f..8e1506d535d 100644
--- a/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php
@@ -39,8 +39,8 @@ class NameMungingTest extends FileTestBase {
$this->config('system.file')->set('allow_insecure_uploads', 0)->save();
$munged_name = file_munge_filename($this->name, '', TRUE);
$messages = drupal_get_messages();
- $this->assertTrue(in_array(strtr('For security reasons, your upload has been renamed to <em class="placeholder">%filename</em>.', array('%filename' => $munged_name)), $messages['status']), 'Alert properly set when a file is renamed.');
- $this->assertNotEqual($munged_name, $this->name, format_string('The new filename (%munged) has been modified from the original (%original)', array('%munged' => $munged_name, '%original' => $this->name)));
+ $this->assertTrue(in_array(strtr('For security reasons, your upload has been renamed to <em class="placeholder">%filename</em>.', ['%filename' => $munged_name]), $messages['status']), 'Alert properly set when a file is renamed.');
+ $this->assertNotEqual($munged_name, $this->name, format_string('The new filename (%munged) has been modified from the original (%original)', ['%munged' => $munged_name, '%original' => $this->name]));
}
/**
@@ -59,7 +59,7 @@ class NameMungingTest extends FileTestBase {
function testMungeIgnoreInsecure() {
$this->config('system.file')->set('allow_insecure_uploads', 1)->save();
$munged_name = file_munge_filename($this->name, '');
- $this->assertIdentical($munged_name, $this->name, format_string('The original filename (%original) matches the munged filename (%munged) when insecure uploads are enabled.', array('%munged' => $munged_name, '%original' => $this->name)));
+ $this->assertIdentical($munged_name, $this->name, format_string('The original filename (%original) matches the munged filename (%munged) when insecure uploads are enabled.', ['%munged' => $munged_name, '%original' => $this->name]));
}
/**
@@ -69,10 +69,10 @@ class NameMungingTest extends FileTestBase {
// Declare our extension as whitelisted. The declared extensions should
// be case insensitive so test using one with a different case.
$munged_name = file_munge_filename($this->nameWithUcExt, $this->badExtension);
- $this->assertIdentical($munged_name, $this->nameWithUcExt, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->nameWithUcExt)));
+ $this->assertIdentical($munged_name, $this->nameWithUcExt, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', ['%munged' => $munged_name, '%original' => $this->nameWithUcExt]));
// The allowed extensions should also be normalized.
$munged_name = file_munge_filename($this->name, strtoupper($this->badExtension));
- $this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name)));
+ $this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', ['%munged' => $munged_name, '%original' => $this->name]));
}
/**
@@ -81,7 +81,7 @@ class NameMungingTest extends FileTestBase {
function testUnMunge() {
$munged_name = file_munge_filename($this->name, '', FALSE);
$unmunged_name = file_unmunge_filename($munged_name);
- $this->assertIdentical($unmunged_name, $this->name, format_string('The unmunged (%unmunged) filename matches the original (%original)', array('%unmunged' => $unmunged_name, '%original' => $this->name)));
+ $this->assertIdentical($unmunged_name, $this->name, format_string('The unmunged (%unmunged) filename matches the original (%original)', ['%unmunged' => $unmunged_name, '%original' => $this->name]));
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php
index 3265562b9b1..e41fb74e2e1 100644
--- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php
@@ -14,7 +14,7 @@ class RemoteFileDirectoryTest extends DirectoryTest {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php
index 3d872bce2c3..e3c68a72f33 100644
--- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php
@@ -14,7 +14,7 @@ class RemoteFileScanDirectoryTest extends ScanDirectoryTest {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php
index 8be67268dca..b13b92cba52 100644
--- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php
@@ -14,7 +14,7 @@ class RemoteFileUnmanagedCopyTest extends UnmanagedCopyTest {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php
index 06f0e1aa2f6..6be98df4aa7 100644
--- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php
@@ -14,7 +14,7 @@ class RemoteFileUnmanagedDeleteRecursiveTest extends UnmanagedDeleteRecursiveTes
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php
index fe0ad6edb17..f826d4dd294 100644
--- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php
@@ -14,7 +14,7 @@ class RemoteFileUnmanagedDeleteTest extends UnmanagedDeleteTest {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php
index 47b66f237ae..e41f87e694c 100644
--- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php
@@ -14,7 +14,7 @@ class RemoteFileUnmanagedMoveTest extends UnmanagedMoveTest {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php
index 15b592958d2..817da28288e 100644
--- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php
@@ -14,7 +14,7 @@ class RemoteFileUnmanagedSaveDataTest extends UnmanagedSaveDataTest {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
diff --git a/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
index 8362c041ac7..471c1aac7c6 100644
--- a/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
@@ -14,7 +14,7 @@ class ScanDirectoryTest extends FileTestBase {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* @var string
@@ -61,7 +61,7 @@ class ScanDirectoryTest extends FileTestBase {
function testOptionCallback() {
// When nothing is matched nothing should be passed to the callback.
- $all_files = file_scan_directory($this->path, '/^NONEXISTINGFILENAME/', array('callback' => 'file_test_file_scan_callback'));
+ $all_files = file_scan_directory($this->path, '/^NONEXISTINGFILENAME/', ['callback' => 'file_test_file_scan_callback']);
$this->assertEqual(0, count($all_files), 'No files were found.');
$results = file_test_file_scan_callback();
file_test_file_scan_callback_reset();
@@ -69,7 +69,7 @@ class ScanDirectoryTest extends FileTestBase {
// Grab a listing of all the JavaScript files and check that they're
// passed to the callback.
- $all_files = file_scan_directory($this->path, '/^javascript-/', array('callback' => 'file_test_file_scan_callback'));
+ $all_files = file_scan_directory($this->path, '/^javascript-/', ['callback' => 'file_test_file_scan_callback']);
$this->assertEqual(2, count($all_files), 'Found two, expected javascript files.');
$results = file_test_file_scan_callback();
file_test_file_scan_callback_reset();
@@ -85,7 +85,7 @@ class ScanDirectoryTest extends FileTestBase {
$this->assertEqual(2, count($all_files), 'Found two, expected javascript files.');
// Now use the nomask parameter to filter out the .script file.
- $filtered_files = file_scan_directory($this->path, '/^javascript-/', array('nomask' => '/.script$/'));
+ $filtered_files = file_scan_directory($this->path, '/^javascript-/', ['nomask' => '/.script$/']);
$this->assertEqual(1, count($filtered_files), 'Filtered correctly.');
}
@@ -94,26 +94,26 @@ class ScanDirectoryTest extends FileTestBase {
*/
function testOptionKey() {
// "filename", for the path starting with $dir.
- $expected = array($this->path . '/javascript-1.txt', $this->path . '/javascript-2.script');
- $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filepath')));
+ $expected = [$this->path . '/javascript-1.txt', $this->path . '/javascript-2.script'];
+ $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'filepath']));
sort($actual);
$this->assertEqual($expected, $actual, 'Returned the correct values for the filename key.');
// "basename", for the basename of the file.
- $expected = array('javascript-1.txt', 'javascript-2.script');
- $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename')));
+ $expected = ['javascript-1.txt', 'javascript-2.script'];
+ $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'filename']));
sort($actual);
$this->assertEqual($expected, $actual, 'Returned the correct values for the basename key.');
// "name" for the name of the file without an extension.
- $expected = array('javascript-1', 'javascript-2');
- $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'name')));
+ $expected = ['javascript-1', 'javascript-2'];
+ $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'name']));
sort($actual);
$this->assertEqual($expected, $actual, 'Returned the correct values for the name key.');
// Invalid option that should default back to "filename".
- $expected = array($this->path . '/javascript-1.txt', $this->path . '/javascript-2.script');
- $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'INVALID')));
+ $expected = [$this->path . '/javascript-1.txt', $this->path . '/javascript-2.script'];
+ $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'INVALID']));
sort($actual);
$this->assertEqual($expected, $actual, 'An invalid key defaulted back to the default.');
}
@@ -122,10 +122,10 @@ class ScanDirectoryTest extends FileTestBase {
* Check that the recurse option descends into subdirectories.
*/
function testOptionRecurse() {
- $files = file_scan_directory($this->path . '/..', '/^javascript-/', array('recurse' => FALSE));
+ $files = file_scan_directory($this->path . '/..', '/^javascript-/', ['recurse' => FALSE]);
$this->assertTrue(empty($files), "Without recursion couldn't find javascript files.");
- $files = file_scan_directory($this->path . '/..', '/^javascript-/', array('recurse' => TRUE));
+ $files = file_scan_directory($this->path . '/..', '/^javascript-/', ['recurse' => TRUE]);
$this->assertEqual(2, count($files), 'With recursion we found the expected javascript files.');
}
@@ -135,10 +135,10 @@ class ScanDirectoryTest extends FileTestBase {
* directory.
*/
function testOptionMinDepth() {
- $files = file_scan_directory($this->path, '/^javascript-/', array('min_depth' => 0));
+ $files = file_scan_directory($this->path, '/^javascript-/', ['min_depth' => 0]);
$this->assertEqual(2, count($files), 'No minimum-depth gets files in current directory.');
- $files = file_scan_directory($this->path, '/^javascript-/', array('min_depth' => 1));
+ $files = file_scan_directory($this->path, '/^javascript-/', ['min_depth' => 1]);
$this->assertTrue(empty($files), 'Minimum-depth of 1 successfully excludes files from current directory.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
index e9c86424ba3..3db171da5c4 100644
--- a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
@@ -19,7 +19,7 @@ class StreamWrapperTest extends FileTestBase {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* A stream wrapper scheme to register for the test.
@@ -119,7 +119,7 @@ class StreamWrapperTest extends FileTestBase {
$this->assertEqual(-1 /*EOF*/, @stream_set_write_buffer($handle, 512), 'Unable to set write buffer using a local stream wrapper.');
// This will test stream_cast().
- $read = array($handle);
+ $read = [$handle];
$write = NULL;
$except = NULL;
$this->assertEqual(1, stream_select($read, $write, $except, 0), 'Able to cast a stream via stream_select.');
diff --git a/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php b/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php
index 5494975af03..e2294cba5be 100644
--- a/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php
@@ -16,7 +16,7 @@ class UrlRewritingTest extends FileTestBase {
*
* @var array
*/
- public static $modules = array('file_test');
+ public static $modules = ['file_test'];
/**
* Tests the rewriting of shipped file URLs by hook_file_url_alter().
diff --git a/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php b/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php
index fa86bee1443..7cc1ff8fa09 100644
--- a/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php
@@ -20,7 +20,7 @@ class FormCacheTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user');
+ public static $modules = ['system', 'user'];
/**
* @var string
@@ -39,12 +39,12 @@ class FormCacheTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->installSchema('system', array('key_value_expire'));
+ $this->installSchema('system', ['key_value_expire']);
$this->formBuildId = $this->randomMachineName();
- $this->form = array(
+ $this->form = [
'#property' => $this->randomMachineName(),
- );
+ ];
$this->formState = new FormState();
$this->formState->set('example', $this->randomMachineName());
}
@@ -53,7 +53,7 @@ class FormCacheTest extends KernelTestBase {
* Tests the form cache with a logged-in user.
*/
function testCacheToken() {
- \Drupal::currentUser()->setAccount(new UserSession(array('uid' => 1)));
+ \Drupal::currentUser()->setAccount(new UserSession(['uid' => 1]));
\Drupal::formBuilder()->setCache($this->formBuildId, $this->form, $this->formState);
$cached_form_state = new FormState();
diff --git a/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php b/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php
index 7f046e9d79d..021c65fce91 100644
--- a/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php
@@ -19,7 +19,7 @@ class FormDefaultHandlersTest extends KernelTestBase implements FormInterface {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* {@inheritdoc}
@@ -42,7 +42,7 @@ class FormDefaultHandlersTest extends KernelTestBase implements FormInterface {
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#validate'][] = '::customValidateForm';
$form['#submit'][] = '::customSubmitForm';
- $form['submit'] = array('#type' => 'submit', '#value' => 'Save');
+ $form['submit'] = ['#type' => 'submit', '#value' => 'Save'];
return $form;
}
diff --git a/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php b/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php
index c24d47e017a..a51bc5d9662 100644
--- a/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php
@@ -25,27 +25,27 @@ class TriggeringElementProgrammedTest extends KernelTestBase implements FormInte
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['one'] = array(
+ $form['one'] = [
'#type' => 'textfield',
'#title' => 'One',
'#required' => TRUE,
- );
- $form['two'] = array(
+ ];
+ $form['two'] = [
'#type' => 'textfield',
'#title' => 'Two',
'#required' => TRUE,
- );
- $form['actions'] = array('#type' => 'actions');
+ ];
+ $form['actions'] = ['#type' => 'actions'];
$user_input = $form_state->getUserInput();
- $form['actions']['submit'] = array(
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
- '#limit_validation_errors' => array(
- array($user_input['section']),
- ),
+ '#limit_validation_errors' => [
+ [$user_input['section']],
+ ],
// Required for #limit_validation_errors.
- '#submit' => array(array($this, 'submitForm')),
- );
+ '#submit' => [[$this, 'submitForm']],
+ ];
return $form;
}
diff --git a/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php
index 166ec244c80..29bbcff9a84 100644
--- a/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php
@@ -19,7 +19,7 @@ class StackKernelIntegrationTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('httpkernel_test', 'system');
+ public static $modules = ['httpkernel_test', 'system'];
/**
* {@inheritdoc}
diff --git a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
index fe36c3dc8a5..a3a57750a6d 100644
--- a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
@@ -23,16 +23,16 @@ class ToolkitGdTest extends KernelTestBase {
protected $imageFactory;
// Colors that are used in testing.
- protected $black = array(0, 0, 0, 0);
- protected $red = array(255, 0, 0, 0);
- protected $green = array(0, 255, 0, 0);
- protected $blue = array(0, 0, 255, 0);
- protected $yellow = array(255, 255, 0, 0);
- protected $white = array(255, 255, 255, 0);
- protected $transparent = array(0, 0, 0, 127);
+ protected $black = [0, 0, 0, 0];
+ protected $red = [255, 0, 0, 0];
+ protected $green = [0, 255, 0, 0];
+ protected $blue = [0, 0, 255, 0];
+ protected $yellow = [255, 255, 0, 0];
+ protected $white = [255, 255, 255, 0];
+ protected $transparent = [0, 0, 0, 127];
// Used as rotate background colors.
- protected $fuchsia = array(255, 0, 255, 0);
- protected $rotateTransparent = array(255, 255, 255, 127);
+ protected $fuchsia = [255, 0, 255, 0];
+ protected $rotateTransparent = [255, 255, 255, 127];
protected $width = 40;
protected $height = 20;
@@ -42,7 +42,7 @@ class ToolkitGdTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'simpletest');
+ public static $modules = ['system', 'simpletest'];
/**
* {@inheritdoc}
@@ -57,9 +57,9 @@ class ToolkitGdTest extends KernelTestBase {
protected function checkRequirements() {
// GD2 support is available.
if (!function_exists('imagegd2')) {
- return array(
+ return [
'Image manipulations for the GD toolkit cannot run because the GD toolkit is not available.',
- );
+ ];
}
return parent::checkRequirements();
}
@@ -91,7 +91,7 @@ class ToolkitGdTest extends KernelTestBase {
$transparent_index = imagecolortransparent($toolkit->getResource());
if ($color_index == $transparent_index) {
- return array(0, 0, 0, 127);
+ return [0, 0, 0, 127];
}
return array_values(imagecolorsforindex($toolkit->getResource(), $color_index));
@@ -129,143 +129,143 @@ class ToolkitGdTest extends KernelTestBase {
// Typically the corner colors will be unchanged. These colors are in the
// order of top-left, top-right, bottom-right, bottom-left.
- $default_corners = array($this->red, $this->green, $this->blue, $this->transparent);
+ $default_corners = [$this->red, $this->green, $this->blue, $this->transparent];
// A list of files that will be tested.
- $files = array(
+ $files = [
'image-test.png',
'image-test.gif',
'image-test-no-transparency.gif',
'image-test.jpg',
- );
+ ];
// Setup a list of tests to perform on each type.
- $operations = array(
- 'resize' => array(
+ $operations = [
+ 'resize' => [
'function' => 'resize',
- 'arguments' => array('width' => 20, 'height' => 10),
+ 'arguments' => ['width' => 20, 'height' => 10],
'width' => 20,
'height' => 10,
'corners' => $default_corners,
- ),
- 'scale_x' => array(
+ ],
+ 'scale_x' => [
'function' => 'scale',
- 'arguments' => array('width' => 20),
+ 'arguments' => ['width' => 20],
'width' => 20,
'height' => 10,
'corners' => $default_corners,
- ),
- 'scale_y' => array(
+ ],
+ 'scale_y' => [
'function' => 'scale',
- 'arguments' => array('height' => 10),
+ 'arguments' => ['height' => 10],
'width' => 20,
'height' => 10,
'corners' => $default_corners,
- ),
- 'upscale_x' => array(
+ ],
+ 'upscale_x' => [
'function' => 'scale',
- 'arguments' => array('width' => 80, 'upscale' => TRUE),
+ 'arguments' => ['width' => 80, 'upscale' => TRUE],
'width' => 80,
'height' => 40,
'corners' => $default_corners,
- ),
- 'upscale_y' => array(
+ ],
+ 'upscale_y' => [
'function' => 'scale',
- 'arguments' => array('height' => 40, 'upscale' => TRUE),
+ 'arguments' => ['height' => 40, 'upscale' => TRUE],
'width' => 80,
'height' => 40,
'corners' => $default_corners,
- ),
- 'crop' => array(
+ ],
+ 'crop' => [
'function' => 'crop',
- 'arguments' => array('x' => 12, 'y' => 4, 'width' => 16, 'height' => 12),
+ 'arguments' => ['x' => 12, 'y' => 4, 'width' => 16, 'height' => 12],
'width' => 16,
'height' => 12,
'corners' => array_fill(0, 4, $this->white),
- ),
- 'scale_and_crop' => array(
+ ],
+ 'scale_and_crop' => [
'function' => 'scale_and_crop',
- 'arguments' => array('width' => 10, 'height' => 8),
+ 'arguments' => ['width' => 10, 'height' => 8],
'width' => 10,
'height' => 8,
'corners' => array_fill(0, 4, $this->black),
- ),
- 'convert_jpg' => array(
+ ],
+ 'convert_jpg' => [
'function' => 'convert',
'width' => 40,
'height' => 20,
- 'arguments' => array('extension' => 'jpeg'),
+ 'arguments' => ['extension' => 'jpeg'],
'corners' => $default_corners,
- ),
- 'convert_gif' => array(
+ ],
+ 'convert_gif' => [
'function' => 'convert',
'width' => 40,
'height' => 20,
- 'arguments' => array('extension' => 'gif'),
+ 'arguments' => ['extension' => 'gif'],
'corners' => $default_corners,
- ),
- 'convert_png' => array(
+ ],
+ 'convert_png' => [
'function' => 'convert',
'width' => 40,
'height' => 20,
- 'arguments' => array('extension' => 'png'),
+ 'arguments' => ['extension' => 'png'],
'corners' => $default_corners,
- ),
- );
+ ],
+ ];
// Systems using non-bundled GD2 don't have imagerotate. Test if available.
if (function_exists('imagerotate')) {
- $operations += array(
- 'rotate_5' => array(
+ $operations += [
+ 'rotate_5' => [
'function' => 'rotate',
- 'arguments' => array('degrees' => 5, 'background' => '#FF00FF'), // Fuchsia background.
+ 'arguments' => ['degrees' => 5, 'background' => '#FF00FF'], // Fuchsia background.
'width' => 41,
'height' => 23,
'corners' => array_fill(0, 4, $this->fuchsia),
- ),
- 'rotate_90' => array(
+ ],
+ 'rotate_90' => [
'function' => 'rotate',
- 'arguments' => array('degrees' => 90, 'background' => '#FF00FF'), // Fuchsia background.
+ 'arguments' => ['degrees' => 90, 'background' => '#FF00FF'], // Fuchsia background.
'width' => 20,
'height' => 40,
- 'corners' => array($this->transparent, $this->red, $this->green, $this->blue),
- ),
- 'rotate_transparent_5' => array(
+ 'corners' => [$this->transparent, $this->red, $this->green, $this->blue],
+ ],
+ 'rotate_transparent_5' => [
'function' => 'rotate',
- 'arguments' => array('degrees' => 5),
+ 'arguments' => ['degrees' => 5],
'width' => 41,
'height' => 23,
'corners' => array_fill(0, 4, $this->rotateTransparent),
- ),
- 'rotate_transparent_90' => array(
+ ],
+ 'rotate_transparent_90' => [
'function' => 'rotate',
- 'arguments' => array('degrees' => 90),
+ 'arguments' => ['degrees' => 90],
'width' => 20,
'height' => 40,
- 'corners' => array($this->transparent, $this->red, $this->green, $this->blue),
- ),
- );
+ 'corners' => [$this->transparent, $this->red, $this->green, $this->blue],
+ ],
+ ];
}
// Systems using non-bundled GD2 don't have imagefilter. Test if available.
if (function_exists('imagefilter')) {
- $operations += array(
- 'desaturate' => array(
+ $operations += [
+ 'desaturate' => [
'function' => 'desaturate',
- 'arguments' => array(),
+ 'arguments' => [],
'height' => 20,
'width' => 40,
// Grayscale corners are a bit funky. Each of the corners are a shade of
// gray. The values of these were determined simply by looking at the
// final image to see what desaturated colors end up being.
- 'corners' => array(
- array_fill(0, 3, 76) + array(3 => 0),
- array_fill(0, 3, 149) + array(3 => 0),
- array_fill(0, 3, 29) + array(3 => 0),
- array_fill(0, 3, 225) + array(3 => 127)
- ),
- ),
- );
+ 'corners' => [
+ array_fill(0, 3, 76) + [3 => 0],
+ array_fill(0, 3, 149) + [3 => 0],
+ array_fill(0, 3, 29) + [3 => 0],
+ array_fill(0, 3, 225) + [3 => 127]
+ ],
+ ],
+ ];
}
// Prepare a directory for test file results.
@@ -278,14 +278,14 @@ class ToolkitGdTest extends KernelTestBase {
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
$toolkit = $image->getToolkit();
if (!$image->isValid()) {
- $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
+ $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file]));
continue 2;
}
$image_original_type = $image->getToolkit()->getType();
// All images should be converted to truecolor when loaded.
$image_truecolor = imageistruecolor($toolkit->getResource());
- $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', array('%file' => $file)));
+ $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', ['%file' => $file]));
// Store the original GD resource.
$old_res = $toolkit->getResource();
@@ -317,8 +317,8 @@ class ToolkitGdTest extends KernelTestBase {
$file_path = $directory . '/' . $op . image_type_to_extension($image->getToolkit()->getType());
$image->save($file_path);
- $this->assertTrue($correct_dimensions_real, SafeMarkup::format('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
- $this->assertTrue($correct_dimensions_object, SafeMarkup::format('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
+ $this->assertTrue($correct_dimensions_real, SafeMarkup::format('Image %file after %action action has proper dimensions.', ['%file' => $file, '%action' => $op]));
+ $this->assertTrue($correct_dimensions_object, SafeMarkup::format('Image %file object after %action action is reporting the proper height and width values.', ['%file' => $file, '%action' => $op]));
// JPEG colors will always be messed up due to compression. So we skip
// these tests if the original or the result is in jpeg format.
@@ -365,7 +365,7 @@ class ToolkitGdTest extends KernelTestBase {
if ($image->getToolkit()->getType() == $image_original_type || $corner != $this->transparent) {
$correct_colors = $this->colorsAreEqual($color, $corner);
$this->assertTrue($correct_colors, SafeMarkup::format('Image %file object after %action action has the correct color placement at corner %corner.',
- array('%file' => $file, '%action' => $op, '%corner' => $key)));
+ ['%file' => $file, '%action' => $op, '%corner' => $key]));
}
}
}
@@ -377,30 +377,30 @@ class ToolkitGdTest extends KernelTestBase {
}
// Test creation of image from scratch, and saving to storage.
- foreach (array(IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG) as $type) {
+ foreach ([IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG] as $type) {
$image = $this->imageFactory->get();
$image->createNew(50, 20, image_type_to_extension($type, FALSE), '#ffff00');
$file = 'from_null' . image_type_to_extension($type);
$file_path = $directory . '/' . $file ;
- $this->assertEqual(50, $image->getWidth(), SafeMarkup::format('Image file %file has the correct width.', array('%file' => $file)));
- $this->assertEqual(20, $image->getHeight(), SafeMarkup::format('Image file %file has the correct height.', array('%file' => $file)));
- $this->assertEqual(image_type_to_mime_type($type), $image->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', array('%file' => $file)));
- $this->assertTrue($image->save($file_path), SafeMarkup::format('Image %file created anew from a null image was saved.', array('%file' => $file)));
+ $this->assertEqual(50, $image->getWidth(), SafeMarkup::format('Image file %file has the correct width.', ['%file' => $file]));
+ $this->assertEqual(20, $image->getHeight(), SafeMarkup::format('Image file %file has the correct height.', ['%file' => $file]));
+ $this->assertEqual(image_type_to_mime_type($type), $image->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', ['%file' => $file]));
+ $this->assertTrue($image->save($file_path), SafeMarkup::format('Image %file created anew from a null image was saved.', ['%file' => $file]));
// Reload saved image.
$image_reloaded = $this->imageFactory->get($file_path);
if (!$image_reloaded->isValid()) {
- $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
+ $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file]));
continue;
}
- $this->assertEqual(50, $image_reloaded->getWidth(), SafeMarkup::format('Image file %file has the correct width.', array('%file' => $file)));
- $this->assertEqual(20, $image_reloaded->getHeight(), SafeMarkup::format('Image file %file has the correct height.', array('%file' => $file)));
- $this->assertEqual(image_type_to_mime_type($type), $image_reloaded->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', array('%file' => $file)));
+ $this->assertEqual(50, $image_reloaded->getWidth(), SafeMarkup::format('Image file %file has the correct width.', ['%file' => $file]));
+ $this->assertEqual(20, $image_reloaded->getHeight(), SafeMarkup::format('Image file %file has the correct height.', ['%file' => $file]));
+ $this->assertEqual(image_type_to_mime_type($type), $image_reloaded->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', ['%file' => $file]));
if ($image_reloaded->getToolkit()->getType() == IMAGETYPE_GIF) {
- $this->assertEqual('#ffff00', $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has the correct transparent color channel set.', array('%file' => $file)));
+ $this->assertEqual('#ffff00', $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has the correct transparent color channel set.', ['%file' => $file]));
}
else {
- $this->assertEqual(NULL, $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has no color channel set.', array('%file' => $file)));
+ $this->assertEqual(NULL, $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has no color channel set.', ['%file' => $file]));
}
}
@@ -496,12 +496,12 @@ class ToolkitGdTest extends KernelTestBase {
$toolkit = $image->getToolkit();
if (!$image->isValid()) {
- $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
+ $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file]));
}
else {
// All images should be converted to truecolor when loaded.
$image_truecolor = imageistruecolor($toolkit->getResource());
- $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', array('%file' => $file)));
+ $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', ['%file' => $file]));
}
}
@@ -519,11 +519,11 @@ class ToolkitGdTest extends KernelTestBase {
// Load up a fresh image.
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
if (!$image->isValid()) {
- $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file)));
+ $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file]));
}
// Try perform a missing toolkit operation.
- $this->assertFalse($image->apply('missing_op', array()), 'Calling a missing image toolkit operation plugin fails.');
+ $this->assertFalse($image->apply('missing_op', []), 'Calling a missing image toolkit operation plugin fails.');
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php b/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php
index 060ee46f5ef..d619d38552d 100644
--- a/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php
@@ -18,21 +18,21 @@ class InstallerLanguageTest extends KernelTestBase {
function testInstallerTranslationFiles() {
// Different translation files would be found depending on which language
// we are looking for.
- $expected_translation_files = array(
- NULL => array('drupal-8.0.0-beta2.hu.po', 'drupal-8.0.0.de.po'),
- 'de' => array('drupal-8.0.0.de.po'),
- 'hu' => array('drupal-8.0.0-beta2.hu.po'),
- 'it' => array(),
- );
+ $expected_translation_files = [
+ NULL => ['drupal-8.0.0-beta2.hu.po', 'drupal-8.0.0.de.po'],
+ 'de' => ['drupal-8.0.0.de.po'],
+ 'hu' => ['drupal-8.0.0-beta2.hu.po'],
+ 'it' => [],
+ ];
// Hardcode the simpletest module location as we don't yet know where it is.
// @todo Remove as part of https://www.drupal.org/node/2186491
$file_translation = new FileTranslation('core/modules/simpletest/files/translations');
foreach ($expected_translation_files as $langcode => $files_expected) {
$files_found = $file_translation->findTranslationFiles($langcode);
- $this->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', array('@count' => count($files_expected))));
+ $this->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', ['@count' => count($files_expected)]));
foreach ($files_found as $file) {
- $this->assertTrue(in_array($file->filename, $files_expected), format_string('@file found.', array('@file' => $file->filename)));
+ $this->assertTrue(in_array($file->filename, $files_expected), format_string('@file found.', ['@file' => $file->filename]));
}
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php b/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php
index fea860973bc..0aca302db3a 100644
--- a/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php
@@ -29,7 +29,7 @@ class InstallerRedirectTraitTest extends KernelTestBase {
* - Whether or not there exists a sessions table in the database.
*/
public function providerShouldRedirectToInstaller() {
- return array(
+ return [
[TRUE, DatabaseNotFoundException::class, FALSE, FALSE],
[TRUE, DatabaseNotFoundException::class, TRUE, FALSE],
[TRUE, DatabaseNotFoundException::class, FALSE, TRUE],
@@ -59,7 +59,7 @@ class InstallerRedirectTraitTest extends KernelTestBase {
[FALSE, \Exception::class, FALSE, TRUE],
[FALSE, \Exception::class, TRUE, TRUE],
[FALSE, \Exception::class, TRUE, TRUE, FALSE],
- );
+ ];
}
/**
@@ -73,7 +73,7 @@ class InstallerRedirectTraitTest extends KernelTestBase {
catch (\Exception $e) {
// Mock the trait.
$trait = $this->getMockBuilder(InstallerRedirectTrait::class)
- ->setMethods(array('isCli'))
+ ->setMethods(['isCli'])
->getMockForTrait();
// Make sure that the method thinks we are not using the cli.
@@ -95,14 +95,14 @@ class InstallerRedirectTraitTest extends KernelTestBase {
// Mock the database connection.
$connection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
- ->setMethods(array('schema'))
+ ->setMethods(['schema'])
->getMockForAbstractClass();
if ($connection_info) {
// Mock the database schema class.
$schema = $this->getMockBuilder(Schema::class)
->disableOriginalConstructor()
- ->setMethods(array('tableExists'))
+ ->setMethods(['tableExists'])
->getMockForAbstractClass();
$schema->expects($this->any())
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
index 16315010654..2d543cbf01f 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php
@@ -17,12 +17,12 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
protected function setUp() {
parent::setUp();
$this->factory = 'keyvalue.expirable';
- $this->installSchema('system', array('key_value_expire'));
+ $this->installSchema('system', ['key_value_expire']);
}
/**
@@ -60,12 +60,12 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
$this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo'));
// Verify that multiple items can be stored with setMultipleWithExpire().
- $values = array(
+ $values = [
'foo' => $this->objects[3],
'bar' => $this->objects[4],
- );
+ ];
$stores[0]->setMultipleWithExpire($values, rand(500, 100000));
- $result = $stores[0]->getMultiple(array('foo', 'bar'));
+ $result = $stores[0]->getMultiple(['foo', 'bar']);
foreach ($values as $j => $value) {
$this->assertIdenticalObject($value, $result[$j]);
}
@@ -85,13 +85,13 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
}
// Verify that all items in the other collection are different.
$result = $stores[1]->getAll();
- $this->assertEqual($result, array('foo' => $this->objects[5]));
+ $this->assertEqual($result, ['foo' => $this->objects[5]]);
// Verify that multiple items can be deleted.
$stores[0]->deleteMultiple(array_keys($values));
$this->assertFalse($stores[0]->get('foo'));
$this->assertFalse($stores[0]->get('bar'));
- $this->assertFalse($stores[0]->getMultiple(array('foo', 'bar')));
+ $this->assertFalse($stores[0]->getMultiple(['foo', 'bar']));
// Verify that the item in the other collection still exists.
$this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo'));
@@ -132,16 +132,16 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
$this->assertFalse($stores[0]->get('yesterday'));
$this->assertTrue($stores[0]->has('troubles'));
$this->assertIdentical($stores[0]->get('troubles'), 'here to stay');
- $this->assertIdentical(count($stores[0]->getMultiple(array('yesterday', 'troubles'))), 1);
+ $this->assertIdentical(count($stores[0]->getMultiple(['yesterday', 'troubles'])), 1);
// Store items set to expire in the past in various ways.
$stores[0]->setWithExpire($this->randomMachineName(), $this->objects[0], -7 * $day);
$stores[0]->setWithExpireIfNotExists($this->randomMachineName(), $this->objects[1], -5 * $day);
$stores[0]->setMultipleWithExpire(
- array(
+ [
$this->randomMachineName() => $this->objects[2],
$this->randomMachineName() => $this->objects[3],
- ),
+ ],
-3 * $day
);
$stores[0]->setWithExpireIfNotExists('yesterday', "you'd forgiven me", -1 * $day);
@@ -150,7 +150,7 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
// Ensure only non-expired items are retrieved.
$all = $stores[0]->getAll();
$this->assertIdentical(count($all), 2);
- foreach (array('troubles', 'still') as $key) {
+ foreach (['troubles', 'still'] as $key) {
$this->assertTrue(!empty($all[$key]));
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
index 676ab1084df..5852da143f1 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
@@ -17,11 +17,11 @@ class DatabaseStorageTest extends StorageTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
protected function setUp() {
parent::setUp();
- $this->installSchema('system', array('key_value'));
+ $this->installSchema('system', ['key_value']);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php
index 4dc9b47f51e..e0badd88d14 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php
@@ -19,13 +19,13 @@ class GarbageCollectionTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
protected function setUp() {
parent::setUp();
// These additional tables are necessary due to the call to system_cron().
- $this->installSchema('system', array('key_value_expire'));
+ $this->installSchema('system', ['key_value_expire']);
}
/**
@@ -44,13 +44,13 @@ class GarbageCollectionTest extends KernelTestBase {
// Manually expire the data.
for ($i = 0; $i <= 3; $i++) {
db_merge('key_value_expire')
- ->keys(array(
+ ->keys([
'name' => 'key_' . $i,
'collection' => $collection,
- ))
- ->fields(array(
+ ])
+ ->fields([
'expire' => REQUEST_TIME - 1,
- ))
+ ])
->execute();
}
@@ -62,9 +62,9 @@ class GarbageCollectionTest extends KernelTestBase {
// Query the database and confirm that the stale records were deleted.
$result = db_query(
'SELECT name, value FROM {key_value_expire} WHERE collection = :collection',
- array(
+ [
':collection' => $collection,
- ))->fetchAll();
+ ])->fetchAll();
$this->assertIdentical(count($result), 1, 'Only one item remains after garbage collection');
}
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php
index 068216b3436..4fc9c7a719e 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php
@@ -19,7 +19,7 @@ class KeyValueContentEntityStorageTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('user', 'entity_test', 'keyvalue_test');
+ public static $modules = ['user', 'entity_test', 'keyvalue_test'];
/**
* {@inheritdoc}
@@ -69,9 +69,9 @@ class KeyValueContentEntityStorageTest extends KernelTestBase {
}
// Verify that an entity with an empty ID string is considered empty, too.
- $empty_id = EntityTestLabel::create(array(
+ $empty_id = EntityTestLabel::create([
'id' => '',
- ));
+ ]);
$this->assertIdentical($empty_id->isNew(), TRUE);
try {
$empty_id->save();
@@ -82,10 +82,10 @@ class KeyValueContentEntityStorageTest extends KernelTestBase {
}
// Verify properties on a newly created entity.
- $entity_test = EntityTestLabel::create($expected = array(
+ $entity_test = EntityTestLabel::create($expected = [
'id' => $this->randomMachineName(),
'name' => $this->randomString(),
- ));
+ ]);
$this->assertIdentical($entity_test->id->value, $expected['id']);
$this->assertTrue($entity_test->uuid->value);
$this->assertNotEqual($entity_test->uuid->value, $empty->uuid->value);
@@ -125,9 +125,9 @@ class KeyValueContentEntityStorageTest extends KernelTestBase {
// Ensure that creating an entity with the same id as an existing one is not
// possible.
- $same_id = EntityTestLabel::create(array(
+ $same_id = EntityTestLabel::create([
'id' => $entity_test->id(),
- ));
+ ]);
$this->assertIdentical($same_id->isNew(), TRUE);
try {
$same_id->save();
@@ -138,7 +138,7 @@ class KeyValueContentEntityStorageTest extends KernelTestBase {
}
// Verify that renaming the ID returns correct status and properties.
- $ids = array($expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4));
+ $ids = [$expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4)];
for ($i = 1; $i < 3; $i++) {
$old_id = $ids[$i - 1];
$new_id = $ids[$i];
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
index 48e047dfcc1..76512342686 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
@@ -14,14 +14,14 @@ abstract class StorageTestBase extends KernelTestBase {
*
* @var array
*/
- protected $objects = array();
+ protected $objects = [];
/**
* An array of data collection labels.
*
* @var array
*/
- protected $collections = array();
+ protected $collections = [];
/**
* Whether we are using an expirable key/value store.
@@ -34,7 +34,7 @@ abstract class StorageTestBase extends KernelTestBase {
parent::setUp();
// Define two data collections,
- $this->collections = array(0 => 'zero', 1 => 'one');
+ $this->collections = [0 => 'zero', 1 => 'one'];
// Create several objects for testing.
for ($i = 0; $i <= 5; $i++) {
@@ -82,14 +82,14 @@ abstract class StorageTestBase extends KernelTestBase {
$this->assertFalse($stores[1]->get('foo'));
// Verify that multiple items can be stored.
- $values = array(
+ $values = [
'foo' => $this->objects[3],
'bar' => $this->objects[4],
- );
+ ];
$stores[0]->setMultiple($values);
// Verify that multiple items can be retrieved.
- $result = $stores[0]->getMultiple(array('foo', 'bar'));
+ $result = $stores[0]->getMultiple(['foo', 'bar']);
foreach ($values as $j => $value) {
$this->assertIdenticalObject($value, $result[$j]);
}
@@ -109,15 +109,15 @@ abstract class StorageTestBase extends KernelTestBase {
}
// Verify that all items in the other collection are different.
$result = $stores[1]->getAll();
- $this->assertEqual($result, array('foo' => $this->objects[5]));
+ $this->assertEqual($result, ['foo' => $this->objects[5]]);
// Verify that multiple items can be deleted.
$stores[0]->deleteMultiple(array_keys($values));
$this->assertFalse($stores[0]->get('foo'));
$this->assertFalse($stores[0]->get('bar'));
- $this->assertFalse($stores[0]->getMultiple(array('foo', 'bar')));
+ $this->assertFalse($stores[0]->getMultiple(['foo', 'bar']));
// Verify that deleting no items does not cause an error.
- $stores[0]->deleteMultiple(array());
+ $stores[0]->deleteMultiple([]);
// Verify that the item in the other collection still exists.
$this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo'));
@@ -146,7 +146,7 @@ abstract class StorageTestBase extends KernelTestBase {
// Verify that a non-existing key is not returned when getting multiple keys.
$stores[0]->set('bar', 'baz');
- $values = $stores[0]->getMultiple(array('foo', 'bar'));
+ $values = $stores[0]->getMultiple(['foo', 'bar']);
$this->assertFalse(isset($values['foo']), "Key 'foo' not found.");
$this->assertIdentical($values['bar'], 'baz');
}
@@ -204,7 +204,7 @@ abstract class StorageTestBase extends KernelTestBase {
* @see \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::garbageCollection()
*/
protected function createStorage() {
- $stores = array();
+ $stores = [];
foreach ($this->collections as $i => $collection) {
$stores[$i] = $this->container->get($this->factory)->get($collection);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php
index b9998873769..d0da9130a69 100644
--- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php
@@ -17,9 +17,9 @@ class MenuLinkDefaultIntegrationTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'menu_test',
- );
+ ];
/**
* Tests moving a static menu link without a specified menu to the root.
@@ -39,7 +39,7 @@ class MenuLinkDefaultIntegrationTest extends KernelTestBase {
$this->assertEqual($tree['menu_test.parent']->subtree['menu_test.child']->link->getPluginId(), 'menu_test.child');
// Ensure that the menu name is not forgotten.
- $menu_link_manager->updateDefinition('menu_test.child', array('parent' => ''));
+ $menu_link_manager->updateDefinition('menu_test.child', ['parent' => '']);
$menu_link = $menu_link_manager->getDefinition('menu_test.child');
$this->assertEqual($menu_link['parent'], '');
diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php
index 1efb14bc02b..033451ac000 100644
--- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php
@@ -35,13 +35,13 @@ class MenuLinkTreeTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'system',
'menu_test',
'menu_link_content',
'field',
'link',
- );
+ ];
/**
* {@inheritdoc}
@@ -59,12 +59,12 @@ class MenuLinkTreeTest extends KernelTestBase {
* Tests deleting all the links in a menu.
*/
public function testDeleteLinksInMenu() {
- \Drupal::entityManager()->getStorage('menu')->create(array('id' => 'menu1'))->save();
- \Drupal::entityManager()->getStorage('menu')->create(array('id' => 'menu2'))->save();
+ \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu1'])->save();
+ \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu2'])->save();
- \Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save();
- \Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save();
- \Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content'))->save();
+ \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'])->save();
+ \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'])->save();
+ \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content'])->save();
$output = $this->linkTree->load('menu1', new MenuTreeParameters());
$this->assertEqual(count($output), 2);
@@ -95,16 +95,16 @@ class MenuLinkTreeTest extends KernelTestBase {
// - 8
// With link 6 being the only external link.
- $links = array(
- 1 => MenuLinkMock::create(array('id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '')),
- 2 => MenuLinkMock::create(array('id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => 'test.example1', 'route_parameters' => array('foo' => 'bar'))),
- 3 => MenuLinkMock::create(array('id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'route_parameters' => array('baz' => 'qux'))),
- 4 => MenuLinkMock::create(array('id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3')),
- 5 => MenuLinkMock::create(array('id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '')),
- 6 => MenuLinkMock::create(array('id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '')),
- 7 => MenuLinkMock::create(array('id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => '')),
- 8 => MenuLinkMock::create(array('id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '')),
- );
+ $links = [
+ 1 => MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '']),
+ 2 => MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => 'test.example1', 'route_parameters' => ['foo' => 'bar']]),
+ 3 => MenuLinkMock::create(['id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'route_parameters' => ['baz' => 'qux']]),
+ 4 => MenuLinkMock::create(['id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3']),
+ 5 => MenuLinkMock::create(['id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '']),
+ 6 => MenuLinkMock::create(['id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '']),
+ 7 => MenuLinkMock::create(['id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => '']),
+ 8 => MenuLinkMock::create(['id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '']),
+ ];
foreach ($links as $instance) {
$this->menuLinkManager->addDefinition($instance->getPluginId(), $instance->getPluginDefinition());
}
diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
index cb1d74d960b..ad3f04d0ab4 100644
--- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
@@ -77,16 +77,16 @@ class MenuTreeStorageTest extends KernelTestBase {
// -- test2
// --- test3
$this->addMenuLink('test1', '');
- $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1));
+ $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]);
$this->addMenuLink('test2', 'test1');
- $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test2'));
- $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 2), array('test1'));
+ $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test2']);
+ $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 2], ['test1']);
$this->addMenuLink('test3', 'test2');
- $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test2', 'test3'));
- $this->assertMenuLink('test2', array('has_children' => 1, 'depth' => 2), array('test1'), array('test3'));
- $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 3), array('test2', 'test1'));
+ $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test2', 'test3']);
+ $this->assertMenuLink('test2', ['has_children' => 1, 'depth' => 2], ['test1'], ['test3']);
+ $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 3], ['test2', 'test1']);
}
/**
@@ -109,11 +109,11 @@ class MenuTreeStorageTest extends KernelTestBase {
$this->addMenuLink('test5', 'test4');
$this->addMenuLink('test6', 'test5');
- $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test2', 'test3'));
- $this->assertMenuLink('test2', array('has_children' => 1, 'depth' => 2), array('test1'), array('test3'));
- $this->assertMenuLink('test4', array('has_children' => 1, 'depth' => 1), array(), array('test5', 'test6'));
- $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 2), array('test4'), array('test6'));
- $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 3), array('test5', 'test4'));
+ $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test2', 'test3']);
+ $this->assertMenuLink('test2', ['has_children' => 1, 'depth' => 2], ['test1'], ['test3']);
+ $this->assertMenuLink('test4', ['has_children' => 1, 'depth' => 1], [], ['test5', 'test6']);
+ $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 2], ['test4'], ['test6']);
+ $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 3], ['test5', 'test4']);
$this->moveMenuLink('test2', 'test5');
// After the 1st move.
@@ -125,12 +125,12 @@ class MenuTreeStorageTest extends KernelTestBase {
// ---- test3
// --- test6
- $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1));
- $this->assertMenuLink('test2', array('has_children' => 1, 'depth' => 3), array('test5', 'test4'), array('test3'));
- $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 4), array('test2', 'test5', 'test4'));
- $this->assertMenuLink('test4', array('has_children' => 1, 'depth' => 1), array(), array('test5', 'test2', 'test3', 'test6'));
- $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 2), array('test4'), array('test2', 'test3', 'test6'));
- $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 3), array('test5', 'test4'));
+ $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]);
+ $this->assertMenuLink('test2', ['has_children' => 1, 'depth' => 3], ['test5', 'test4'], ['test3']);
+ $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 4], ['test2', 'test5', 'test4']);
+ $this->assertMenuLink('test4', ['has_children' => 1, 'depth' => 1], [], ['test5', 'test2', 'test3', 'test6']);
+ $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 2], ['test4'], ['test2', 'test3', 'test6']);
+ $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 3], ['test5', 'test4']);
$this->moveMenuLink('test4', 'test1');
$this->moveMenuLink('test3', 'test1');
@@ -143,12 +143,12 @@ class MenuTreeStorageTest extends KernelTestBase {
// ---- test2
// ---- test6
- $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test4', 'test5', 'test2', 'test3', 'test6'));
- $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 4), array('test5', 'test4', 'test1'));
- $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 2), array('test1'));
- $this->assertMenuLink('test4', array('has_children' => 1, 'depth' => 2), array('test1'), array('test2', 'test5', 'test6'));
- $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 3), array('test4', 'test1'), array('test2', 'test6'));
- $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 4), array('test5', 'test4', 'test1'));
+ $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test4', 'test5', 'test2', 'test3', 'test6']);
+ $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 4], ['test5', 'test4', 'test1']);
+ $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 2], ['test1']);
+ $this->assertMenuLink('test4', ['has_children' => 1, 'depth' => 2], ['test1'], ['test2', 'test5', 'test6']);
+ $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 3], ['test4', 'test1'], ['test2', 'test6']);
+ $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 4], ['test5', 'test4', 'test1']);
// Deleting a link in the middle should re-attach child links to the parent.
$this->treeStorage->delete('test4');
@@ -159,12 +159,12 @@ class MenuTreeStorageTest extends KernelTestBase {
// -- test5
// --- test2
// --- test6
- $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test5', 'test2', 'test3', 'test6'));
- $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 3), array('test5', 'test1'));
- $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 2), array('test1'));
+ $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test5', 'test2', 'test3', 'test6']);
+ $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 3], ['test5', 'test1']);
+ $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 2], ['test1']);
$this->assertFalse($this->treeStorage->load('test4'));
- $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 2), array('test1'), array('test2', 'test6'));
- $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 3), array('test5', 'test1'));
+ $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 2], ['test1'], ['test2', 'test6']);
+ $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 3], ['test5', 'test1']);
}
/**
@@ -177,12 +177,12 @@ class MenuTreeStorageTest extends KernelTestBase {
// -- test2 (disabled)
$this->addMenuLink('test1', '');
- $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1));
+ $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]);
- $this->addMenuLink('test2', 'test1', '<front>', array(), 'tools', array('enabled' => 0));
+ $this->addMenuLink('test2', 'test1', '<front>', [], 'tools', ['enabled' => 0]);
// The 1st link does not have any visible children, so has_children is 0.
- $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1));
- $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 2, 'enabled' => 0), array('test1'));
+ $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]);
+ $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 2, 'enabled' => 0], ['test1']);
// Add more links with parent on the previous one.
// <footer>
@@ -198,8 +198,8 @@ class MenuTreeStorageTest extends KernelTestBase {
// ------- test7
// -------- test8
// --------- test9
- $this->addMenuLink('footerA', '', '<front>', array(), 'footer');
- $visible_children = array();
+ $this->addMenuLink('footerA', '', '<front>', [], 'footer');
+ $visible_children = [];
for ($i = 3; $i <= $this->treeStorage->maxDepth(); $i++) {
$parent = $i - 1;
$this->addMenuLink("test$i", "test$parent");
@@ -207,7 +207,7 @@ class MenuTreeStorageTest extends KernelTestBase {
}
// The 1st link does not have any visible children, so has_children is still
// 0. However, it has visible links below it that will be found.
- $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1), array(), $visible_children);
+ $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1], [], $visible_children);
// This should fail since test9 would end up at greater than max depth.
try {
$this->moveMenuLink('test1', 'footerA');
@@ -219,7 +219,7 @@ class MenuTreeStorageTest extends KernelTestBase {
// The opposite move should work, and change the has_children flag.
$this->moveMenuLink('footerA', 'test1');
$visible_children[] = 'footerA';
- $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), $visible_children);
+ $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], $visible_children);
}
/**
@@ -241,7 +241,7 @@ class MenuTreeStorageTest extends KernelTestBase {
$this->assertEqual(count($tree['test4']['subtree']['test5']['subtree']), 0);
$parameters = new MenuTreeParameters();
- $parameters->setActiveTrail(array('test4', 'test5'));
+ $parameters->setActiveTrail(['test4', 'test5']);
$data = $this->treeStorage->loadTreeData('tools', $parameters);
$tree = $data['tree'];
$this->assertEqual(count($tree['test1']['subtree']), 1);
@@ -342,10 +342,10 @@ class MenuTreeStorageTest extends KernelTestBase {
* Tests MenuTreeStorage::loadByProperties().
*/
public function testLoadByProperties() {
- $tests = array(
- array('foo' => 'bar'),
- array(0 => 'wrong'),
- );
+ $tests = [
+ ['foo' => 'bar'],
+ [0 => 'wrong'],
+ ];
$message = 'An invalid property name throws an exception.';
foreach ($tests as $properties) {
try {
@@ -357,8 +357,8 @@ class MenuTreeStorageTest extends KernelTestBase {
$this->pass($message);
}
}
- $this->addMenuLink('test_link.1', '', 'test', array(), 'menu1');
- $properties = array('menu_name' => 'menu1');
+ $this->addMenuLink('test_link.1', '', 'test', [], 'menu1');
+ $properties = ['menu_name' => 'menu1'];
$links = $this->treeStorage->loadByProperties($properties);
$this->assertEqual('menu1', $links['test_link.1']['menu_name']);
$this->assertEqual('test', $links['test_link.1']['route_name']);
@@ -367,17 +367,17 @@ class MenuTreeStorageTest extends KernelTestBase {
/**
* Adds a link with the given ID and supply defaults.
*/
- protected function addMenuLink($id, $parent = '', $route_name = 'test', $route_parameters = array(), $menu_name = 'tools', $extra = array()) {
- $link = array(
+ protected function addMenuLink($id, $parent = '', $route_name = 'test', $route_parameters = [], $menu_name = 'tools', $extra = []) {
+ $link = [
'id' => $id,
'menu_name' => $menu_name,
'route_name' => $route_name,
'route_parameters' => $route_parameters,
'title' => 'test',
'parent' => $parent,
- 'options' => array(),
- 'metadata' => array(),
- ) + $extra;
+ 'options' => [],
+ 'metadata' => [],
+ ] + $extra;
$this->treeStorage->save($link);
}
@@ -407,7 +407,7 @@ class MenuTreeStorageTest extends KernelTestBase {
* @param array $children
* Array of child IDs that are visible (enabled == 1).
*/
- protected function assertMenuLink($id, array $expected_properties, array $parents = array(), array $children = array()) {
+ protected function assertMenuLink($id, array $expected_properties, array $parents = [], array $children = []) {
$query = $this->connection->select('menu_tree');
$query->fields('menu_tree');
$query->condition('id', $id);
@@ -422,7 +422,7 @@ class MenuTreeStorageTest extends KernelTestBase {
array_unshift($parents, $raw['id']);
$query = $this->connection->select('menu_tree');
- $query->fields('menu_tree', array('id', 'mlid'));
+ $query->fields('menu_tree', ['id', 'mlid']);
$query->condition('id', $parents, 'IN');
$found_parents = $query->execute()->fetchAllKeyed(0, 1);
diff --git a/core/tests/Drupal/KernelTests/Core/Path/AliasTest.php b/core/tests/Drupal/KernelTests/Core/Path/AliasTest.php
index ad1e6d494db..e4320280374 100644
--- a/core/tests/Drupal/KernelTests/Core/Path/AliasTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Path/AliasTest.php
@@ -29,10 +29,10 @@ class AliasTest extends PathUnitTestBase {
foreach ($aliases as $idx => $alias) {
$aliasStorage->save($alias['source'], $alias['alias'], $alias['langcode']);
- $result = $connection->query('SELECT * FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', array(':source' => $alias['source'], ':alias' => $alias['alias'], ':langcode' => $alias['langcode']));
+ $result = $connection->query('SELECT * FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', [':source' => $alias['source'], ':alias' => $alias['alias'], ':langcode' => $alias['langcode']]);
$rows = $result->fetchAll();
- $this->assertEqual(count($rows), 1, format_string('Created an entry for %alias.', array('%alias' => $alias['alias'])));
+ $this->assertEqual(count($rows), 1, format_string('Created an entry for %alias.', ['%alias' => $alias['alias']]));
//Cache the pid for further tests.
$aliases[$idx]['pid'] = $rows[0]->pid;
@@ -41,12 +41,12 @@ class AliasTest extends PathUnitTestBase {
//Load a few aliases
foreach ($aliases as $alias) {
$pid = $alias['pid'];
- $loadedAlias = $aliasStorage->load(array('pid' => $pid));
- $this->assertEqual($loadedAlias, $alias, format_string('Loaded the expected path with pid %pid.', array('%pid' => $pid)));
+ $loadedAlias = $aliasStorage->load(['pid' => $pid]);
+ $this->assertEqual($loadedAlias, $alias, format_string('Loaded the expected path with pid %pid.', ['%pid' => $pid]));
}
// Load alias by source path.
- $loadedAlias = $aliasStorage->load(array('source' => '/node/1'));
+ $loadedAlias = $aliasStorage->load(['source' => '/node/1']);
$this->assertEqual($loadedAlias['alias'], '/alias_for_node_1_und', 'The last created alias loaded by default.');
//Update a few aliases
@@ -55,21 +55,21 @@ class AliasTest extends PathUnitTestBase {
$this->assertEqual($alias['alias'], $fields['original']['alias']);
- $result = $connection->query('SELECT pid FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', array(':source' => $alias['source'], ':alias' => $alias['alias'] . '_updated', ':langcode' => $alias['langcode']));
+ $result = $connection->query('SELECT pid FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', [':source' => $alias['source'], ':alias' => $alias['alias'] . '_updated', ':langcode' => $alias['langcode']]);
$pid = $result->fetchField();
- $this->assertEqual($pid, $alias['pid'], format_string('Updated entry for pid %pid.', array('%pid' => $pid)));
+ $this->assertEqual($pid, $alias['pid'], format_string('Updated entry for pid %pid.', ['%pid' => $pid]));
}
//Delete a few aliases
foreach ($aliases as $alias) {
$pid = $alias['pid'];
- $aliasStorage->delete(array('pid' => $pid));
+ $aliasStorage->delete(['pid' => $pid]);
- $result = $connection->query('SELECT * FROM {url_alias} WHERE pid = :pid', array(':pid' => $pid));
+ $result = $connection->query('SELECT * FROM {url_alias} WHERE pid = :pid', [':pid' => $pid]);
$rows = $result->fetchAll();
- $this->assertEqual(count($rows), 0, format_string('Deleted entry with pid %pid.', array('%pid' => $pid)));
+ $this->assertEqual(count($rows), 0, format_string('Deleted entry with pid %pid.', ['%pid' => $pid]));
}
}
@@ -84,21 +84,21 @@ class AliasTest extends PathUnitTestBase {
// Test the situation where the source is the same for multiple aliases.
// Start with a language-neutral alias, which we will override.
- $path = array(
+ $path = [
'source' => "/user/1",
'alias' => '/foo',
- );
+ ];
$aliasStorage->save($path['source'], $path['alias']);
$this->assertEqual($aliasManager->getAliasByPath($path['source']), $path['alias'], 'Basic alias lookup works.');
$this->assertEqual($aliasManager->getPathByAlias($path['alias']), $path['source'], 'Basic source lookup works.');
// Create a language specific alias for the default language (English).
- $path = array(
+ $path = [
'source' => "/user/1",
'alias' => "/users/Dries",
'langcode' => 'en',
- );
+ ];
$aliasStorage->save($path['source'], $path['alias'], $path['langcode']);
// Hook that clears cache is not executed with unit tests.
\Drupal::service('path.alias_manager')->cacheClear();
@@ -106,19 +106,19 @@ class AliasTest extends PathUnitTestBase {
$this->assertEqual($aliasManager->getPathByAlias($path['alias']), $path['source'], 'English source overrides language-neutral source.');
// Create a language-neutral alias for the same path, again.
- $path = array(
+ $path = [
'source' => "/user/1",
'alias' => '/bar',
- );
+ ];
$aliasStorage->save($path['source'], $path['alias']);
$this->assertEqual($aliasManager->getAliasByPath($path['source']), "/users/Dries", 'English alias still returned after entering a language-neutral alias.');
// Create a language-specific (xx-lolspeak) alias for the same path.
- $path = array(
+ $path = [
'source' => "/user/1",
'alias' => '/LOL',
'langcode' => 'xx-lolspeak',
- );
+ ];
$aliasStorage->save($path['source'], $path['alias'], $path['langcode']);
$this->assertEqual($aliasManager->getAliasByPath($path['source']), "/users/Dries", 'English alias still returned after entering a LOLspeak alias.');
// The LOLspeak alias should be returned if we really want LOLspeak.
@@ -126,11 +126,11 @@ class AliasTest extends PathUnitTestBase {
// Create a new alias for this path in English, which should override the
// previous alias for "user/1".
- $path = array(
+ $path = [
'source' => "/user/1",
'alias' => '/users/my-new-path',
'langcode' => 'en',
- );
+ ];
$aliasStorage->save($path['source'], $path['alias'], $path['langcode']);
// Hook that clears cache is not executed with unit tests.
$aliasManager->cacheClear();
@@ -139,7 +139,7 @@ class AliasTest extends PathUnitTestBase {
// Remove the English aliases, which should cause a fallback to the most
// recently created language-neutral alias, 'bar'.
- $aliasStorage->delete(array('langcode' => 'en'));
+ $aliasStorage->delete(['langcode' => 'en']);
// Hook that clears cache is not executed with unit tests.
$aliasManager->cacheClear();
$this->assertEqual($aliasManager->getAliasByPath($path['source']), '/bar', 'Path lookup falls back to recently created language-neutral alias.');
@@ -190,7 +190,7 @@ class AliasTest extends PathUnitTestBase {
$this->assertNull($whitelist->get($this->randomMachineName()));
// Remove the user alias again, whitelist entry should be removed.
- $aliasStorage->delete(array('source' => '/user/1'));
+ $aliasStorage->delete(['source' => '/user/1']);
$aliasManager->cacheClear();
$this->assertNull($whitelist->get('user'));
$this->assertTrue($whitelist->get('admin'));
diff --git a/core/tests/Drupal/KernelTests/Core/Path/PathUnitTestBase.php b/core/tests/Drupal/KernelTests/Core/Path/PathUnitTestBase.php
index 9c50f9a4519..671dbc4792b 100644
--- a/core/tests/Drupal/KernelTests/Core/Path/PathUnitTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Path/PathUnitTestBase.php
@@ -21,7 +21,7 @@ abstract class PathUnitTestBase extends KernelTestBase {
$this->fixtures = new UrlAliasFixtures();
// The alias whitelist expects that the menu path roots are set by a
// menu router rebuild.
- \Drupal::state()->set('router.path_roots', array('user', 'admin'));
+ \Drupal::state()->set('router.path_roots', ['user', 'admin']);
}
protected function tearDown() {
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php
index f152319390f..7a69d2eb04a 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php
@@ -15,24 +15,24 @@ class CurrentThemeConditionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system', 'theme_test');
+ public static $modules = ['system', 'theme_test'];
/**
* Tests the current theme condition.
*/
public function testCurrentTheme() {
- \Drupal::service('theme_handler')->install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
$manager = \Drupal::service('plugin.manager.condition');
/** @var $condition \Drupal\Core\Condition\ConditionInterface */
$condition = $manager->createInstance('current_theme');
- $condition->setConfiguration(array('theme' => 'test_theme'));
+ $condition->setConfiguration(['theme' => 'test_theme']);
/** @var $condition_negated \Drupal\Core\Condition\ConditionInterface */
$condition_negated = $manager->createInstance('current_theme');
- $condition_negated->setConfiguration(array('theme' => 'test_theme', 'negate' => TRUE));
+ $condition_negated->setConfiguration(['theme' => 'test_theme', 'negate' => TRUE]);
- $this->assertEqual($condition->summary(), SafeMarkup::format('The current theme is @theme', array('@theme' => 'test_theme')));
- $this->assertEqual($condition_negated->summary(), SafeMarkup::format('The current theme is not @theme', array('@theme' => 'test_theme')));
+ $this->assertEqual($condition->summary(), SafeMarkup::format('The current theme is @theme', ['@theme' => 'test_theme']));
+ $this->assertEqual($condition_negated->summary(), SafeMarkup::format('The current theme is not @theme', ['@theme' => 'test_theme']));
// The expected theme has not been set up yet.
$this->assertFalse($condition->execute());
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Condition/RequestPathTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Condition/RequestPathTest.php
index 02f2a5de2e4..68b6eb770e8 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Condition/RequestPathTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Condition/RequestPathTest.php
@@ -42,7 +42,7 @@ class RequestPathTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'user', 'field', 'path');
+ public static $modules = ['system', 'user', 'field', 'path'];
/**
* The current path.
@@ -57,7 +57,7 @@ class RequestPathTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
$this->pluginManager = $this->container->get('plugin.manager.condition');
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/ContextPluginTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/ContextPluginTest.php
index 3c25184ab1e..10e35e55970 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/ContextPluginTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/ContextPluginTest.php
@@ -17,7 +17,7 @@ use Drupal\user\Entity\User;
*/
class ContextPluginTest extends KernelTestBase {
- public static $modules = array('system', 'user', 'node', 'field', 'filter', 'text');
+ public static $modules = ['system', 'user', 'node', 'field', 'filter', 'text'];
/**
* Tests basic context definition and value getters and setters.
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
index 9a714c43376..9003713f532 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
@@ -13,69 +13,69 @@ class AnnotatedClassDiscoveryTest extends DiscoveryTestBase {
protected function setUp() {
parent::setUp();
- $this->expectedDefinitions = array(
- 'apple' => array(
+ $this->expectedDefinitions = [
+ 'apple' => [
'id' => 'apple',
'label' => 'Apple',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple',
'provider' => 'plugin_test',
- ),
- 'banana' => array(
+ ],
+ 'banana' => [
'id' => 'banana',
'label' => 'Banana',
'color' => 'yellow',
- 'uses' => array(
+ 'uses' => [
'bread' => t('Banana bread'),
- 'loaf' => array(
+ 'loaf' => [
'singular' => '@count loaf',
'plural' => '@count loaves',
'context' => NULL,
- ),
- ),
+ ],
+ ],
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Banana',
'provider' => 'plugin_test',
- ),
- 'cherry' => array(
+ ],
+ 'cherry' => [
'id' => 'cherry',
'label' => 'Cherry',
'color' => 'red',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry',
'provider' => 'plugin_test',
- ),
- 'kale' => array(
+ ],
+ 'kale' => [
'id' => 'kale',
'label' => 'Kale',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Kale',
'provider' => 'plugin_test',
- ),
- 'orange' => array(
+ ],
+ 'orange' => [
'id' => 'orange',
'label' => 'Orange',
'color' => 'orange',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange',
'provider' => 'plugin_test',
- ),
- 'big_apple' => array(
+ ],
+ 'big_apple' => [
'id' => 'big_apple',
'label' => 'Big Apple',
'color' => 'green',
'class' => 'Drupal\plugin_test_extended\Plugin\plugin_test\fruit\BigApple',
'provider' => 'plugin_test_extended',
- ),
- 'extending_non_installed_class' => array(
+ ],
+ 'extending_non_installed_class' => [
'id' => 'extending_non_installed_class',
'label' => 'A plugin whose class is extending from a non-installed module class',
'color' => 'pink',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\ExtendingNonInstalledClass',
'provider' => 'plugin_test',
- ),
- );
+ ],
+ ];
$base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src';
$base_directory2 = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test_extended/src';
- $namespaces = new \ArrayObject(array('Drupal\plugin_test' => $base_directory, 'Drupal\plugin_test_extended' => $base_directory2));
+ $namespaces = new \ArrayObject(['Drupal\plugin_test' => $base_directory, 'Drupal\plugin_test_extended' => $base_directory2]);
$annotation_namespaces = ['Drupal\plugin_test\Plugin\Annotation', 'Drupal\plugin_test_extended\Plugin\Annotation'];
$this->discovery = new AnnotatedClassDiscovery('Plugin/plugin_test/fruit', $namespaces, 'Drupal\Component\Annotation\Plugin', $annotation_namespaces);
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php
index 5cd8f756e9d..3ae576cfdfb 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php
@@ -15,23 +15,23 @@ class CustomAnnotationClassDiscoveryTest extends DiscoveryTestBase {
protected function setUp() {
parent::setUp();
- $this->expectedDefinitions = array(
- 'example_1' => array(
+ $this->expectedDefinitions = [
+ 'example_1' => [
'id' => 'example_1',
'custom' => 'John',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\custom_annotation\Example1',
'provider' => 'plugin_test',
- ),
- 'example_2' => array(
+ ],
+ 'example_2' => [
'id' => 'example_2',
'custom' => 'Paul',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\custom_annotation\Example2',
'provider' => 'plugin_test',
- ),
- );
+ ],
+ ];
$base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src';
- $root_namespaces = new \ArrayObject(array('Drupal\plugin_test' => $base_directory));
+ $root_namespaces = new \ArrayObject(['Drupal\plugin_test' => $base_directory]);
$this->discovery = new AnnotatedClassDiscovery('Plugin/plugin_test/custom_annotation', $root_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample');
$this->emptyDiscovery = new AnnotatedClassDiscovery('Plugin/non_existing_module/non_existing_plugin_type', $root_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample');
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php
index a9fbf799eab..a6ae259bc2f 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php
@@ -15,73 +15,73 @@ class CustomDirectoryAnnotatedClassDiscoveryTest extends DiscoveryTestBase {
protected function setUp() {
parent::setUp();
- $this->expectedDefinitions = array(
- 'custom_example_1' => array(
+ $this->expectedDefinitions = [
+ 'custom_example_1' => [
'id' => 'custom_example_1',
'custom' => 'Tim',
'class' => 'Drupal\plugin_test\CustomDirectoryExample1',
'provider' => 'plugin_test',
- ),
- 'custom_example_2' => array(
+ ],
+ 'custom_example_2' => [
'id' => 'custom_example_2',
'custom' => 'Meghan',
'class' => 'Drupal\plugin_test\CustomDirectoryExample2',
'provider' => 'plugin_test',
- ),
- 'apple' => array(
+ ],
+ 'apple' => [
'id' => 'apple',
'label' => 'Apple',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple',
'provider' => 'plugin_test',
- ),
- 'banana' => array(
+ ],
+ 'banana' => [
'id' => 'banana',
'label' => 'Banana',
'color' => 'yellow',
- 'uses' => array(
+ 'uses' => [
'bread' => t('Banana bread'),
- 'loaf' => array(
+ 'loaf' => [
'singular' => '@count loaf',
'plural' => '@count loaves',
'context' => NULL,
- ),
- ),
+ ],
+ ],
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Banana',
'provider' => 'plugin_test',
- ),
- 'cherry' => array(
+ ],
+ 'cherry' => [
'id' => 'cherry',
'label' => 'Cherry',
'color' => 'red',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry',
'provider' => 'plugin_test',
- ),
- 'kale' => array(
+ ],
+ 'kale' => [
'id' => 'kale',
'label' => 'Kale',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Kale',
'provider' => 'plugin_test',
- ),
- 'orange' => array(
+ ],
+ 'orange' => [
'id' => 'orange',
'label' => 'Orange',
'color' => 'orange',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange',
'provider' => 'plugin_test',
- ),
- 'extending_non_installed_class' => array(
+ ],
+ 'extending_non_installed_class' => [
'id' => 'extending_non_installed_class',
'label' => 'A plugin whose class is extending from a non-installed module class',
'color' => 'pink',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\ExtendingNonInstalledClass',
'provider' => 'plugin_test',
- ),
- );
+ ],
+ ];
$base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src';
- $namespaces = new \ArrayObject(array('Drupal\plugin_test' => $base_directory));
+ $namespaces = new \ArrayObject(['Drupal\plugin_test' => $base_directory]);
$this->discovery = new AnnotatedClassDiscovery('', $namespaces);
$empty_namespaces = new \ArrayObject();
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
index bbe207359a3..054887707b5 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
@@ -51,7 +51,7 @@ abstract class DiscoveryTestBase extends KernelTestBase {
}
// Ensure that an empty array is returned if no plugin definitions are found.
- $this->assertIdentical($this->emptyDiscovery->getDefinitions(), array(), 'array() returned if no plugin definitions are found.');
+ $this->assertIdentical($this->emptyDiscovery->getDefinitions(), [], 'array() returned if no plugin definitions are found.');
// Ensure that NULL is returned as the definition of a non-existing plugin.
$this->assertIdentical($this->emptyDiscovery->getDefinition('non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing plugin.');
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php
index bd0c317220d..fb9eb3a9ffd 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php
@@ -13,20 +13,20 @@ class StaticDiscoveryTest extends DiscoveryTestBase {
protected function setUp() {
parent::setUp();
- $this->expectedDefinitions = array(
- 'apple' => array(
+ $this->expectedDefinitions = [
+ 'apple' => [
'label' => 'Apple',
'color' => 'green',
- ),
- 'cherry' => array(
+ ],
+ 'cherry' => [
'label' => 'Cherry',
'color' => 'red',
- ),
- 'orange' => array(
+ ],
+ 'orange' => [
'label' => 'Orange',
'color' => 'orange',
- ),
- );
+ ],
+ ];
// Instead of registering the empty discovery component first and then
// setting the plugin definitions, we set them first and then delete them
// again. This implicitly tests StaticDiscovery::deleteDefinition() (in
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php
index 47609902dcd..783f6bc7f42 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php
@@ -16,7 +16,7 @@ class FactoryTest extends PluginTestBase {
*/
function testDefaultFactory() {
// Ensure a non-derivative plugin can be instantiated.
- $plugin = $this->testPluginManager->createInstance('user_login', array('title' => 'Please enter your login name and password'));
+ $plugin = $this->testPluginManager->createInstance('user_login', ['title' => 'Please enter your login name and password']);
$this->assertIdentical(get_class($plugin), 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock', 'Correct plugin class instantiated with default factory.');
$this->assertIdentical($plugin->getTitle(), 'Please enter your login name and password', 'Plugin instance correctly configured.');
@@ -46,19 +46,19 @@ class FactoryTest extends PluginTestBase {
*/
function testReflectionFactory() {
// Ensure a non-derivative plugin can be instantiated.
- $plugin = $this->mockBlockManager->createInstance('user_login', array('title' => 'Please enter your login name and password'));
+ $plugin = $this->mockBlockManager->createInstance('user_login', ['title' => 'Please enter your login name and password']);
$this->assertIdentical(get_class($plugin), 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock', 'Correct plugin class instantiated.');
$this->assertIdentical($plugin->getTitle(), 'Please enter your login name and password', 'Plugin instance correctly configured.');
// Ensure a derivative plugin can be instantiated.
- $plugin = $this->mockBlockManager->createInstance('menu:main_menu', array('depth' => 2));
+ $plugin = $this->mockBlockManager->createInstance('menu:main_menu', ['depth' => 2]);
$this->assertIdentical($plugin->getContent(), '<ul><li>1<ul><li>1.1</li></ul></li></ul>', 'Derived plugin instance correctly instantiated and configured.');
// Ensure that attempting to instantiate non-existing plugins throws a
// PluginException. Test this for a non-existing base plugin, a non-existing
// derivative plugin, and a base plugin that may not be used without
// deriving.
- foreach (array('non_existing', 'menu:non_existing', 'menu') as $invalid_id) {
+ foreach (['non_existing', 'menu:non_existing', 'menu'] as $invalid_id) {
try {
$this->mockBlockManager->createInstance($invalid_id);
$this->fail('Drupal\Component\Plugin\Exception\ExceptionInterface expected');
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php
index 4ff9573c808..eaff844551c 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/InspectionTest.php
@@ -13,7 +13,7 @@ class InspectionTest extends PluginTestBase {
* Ensure the test plugins correctly implement getPluginId() and getPluginDefinition().
*/
function testInspection() {
- foreach (array('user_login') as $id) {
+ foreach (['user_login'] as $id) {
$plugin = $this->testPluginManager->createInstance($id);
$expected_definition = $this->testPluginExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
@@ -22,7 +22,7 @@ class InspectionTest extends PluginTestBase {
}
// Skip the 'menu' derived blocks, because MockMenuBlock does not implement
// PluginInspectionInterface. The others do by extending PluginBase.
- foreach (array('user_login', 'layout') as $id) {
+ foreach (['user_login', 'layout'] as $id) {
$plugin = $this->mockBlockManager->createInstance($id);
$expected_definition = $this->mockBlockExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
@@ -30,7 +30,7 @@ class InspectionTest extends PluginTestBase {
$this->assertIdentical($this->castSafeStrings($plugin->getPluginDefinition()), $expected_definition);
}
// Test a plugin manager that provides defaults.
- foreach (array('test_block1', 'test_block2') as $id) {
+ foreach (['test_block1', 'test_block2'] as $id) {
$plugin = $this->defaultsTestPluginManager->createInstance($id);
$expected_definition = $this->defaultsTestPluginExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php b/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php
index dd5528b6da4..ccc82369a0e 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/PluginTestBase.php
@@ -20,7 +20,7 @@ abstract class PluginTestBase extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('plugin_test');
+ public static $modules = ['plugin_test'];
protected $testPluginManager;
protected $testPluginExpectedDefinitions;
@@ -42,7 +42,7 @@ abstract class PluginTestBase extends KernelTestBase {
// as derivatives and ReflectionFactory.
$this->testPluginManager = new TestPluginManager();
$this->mockBlockManager = new MockBlockManager();
- $module_handler = new ModuleHandler(\Drupal::root(), array(), new MemoryBackend(), $this->container->get('event_dispatcher'));
+ $module_handler = new ModuleHandler(\Drupal::root(), [], new MemoryBackend(), $this->container->get('event_dispatcher'));
$this->defaultsTestPluginManager = new DefaultsTestPluginManager($module_handler);
// The expected plugin definitions within each manager. Several tests assert
@@ -50,91 +50,91 @@ abstract class PluginTestBase extends KernelTestBase {
// necessary API functions.
// @see TestPluginManager::_construct().
// @see MockBlockManager::_construct().
- $this->testPluginExpectedDefinitions = array(
- 'user_login' => array(
+ $this->testPluginExpectedDefinitions = [
+ 'user_login' => [
'label' => 'User login',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock',
- ),
- );
- $this->mockBlockExpectedDefinitions = array(
- 'user_login' => array(
+ ],
+ ];
+ $this->mockBlockExpectedDefinitions = [
+ 'user_login' => [
'id' => 'user_login',
'label' => 'User login',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock',
- ),
- 'menu:main_menu' => array(
+ ],
+ 'menu:main_menu' => [
'id' => 'menu',
'label' => 'Main menu',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock',
- ),
- 'menu:navigation' => array(
+ ],
+ 'menu:navigation' => [
'id' => 'menu',
'label' => 'Navigation',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock',
- ),
- 'menu:foo' => array(
+ ],
+ 'menu:foo' => [
'id' => 'menu',
'label' => 'Base label',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock',
'setting' => 'default',
- ),
- 'layout' => array(
+ ],
+ 'layout' => [
'id' => 'layout',
'label' => 'Layout',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlock',
- ),
- 'layout:foo' => array(
+ ],
+ 'layout:foo' => [
'id' => 'layout',
'label' => 'Layout Foo',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlock',
- ),
- 'user_name' => array(
+ ],
+ 'user_name' => [
'id' => 'user_name',
'label' => 'User name',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
- 'context' => array(
+ 'context' => [
'user' => new ContextDefinition('entity:user', 'User'),
- ),
- ),
- 'user_name_optional' => array(
+ ],
+ ],
+ 'user_name_optional' => [
'id' => 'user_name_optional',
'label' => 'User name optional',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
- 'context' => array(
+ 'context' => [
'user' => new ContextDefinition('entity:user', 'User', FALSE),
- ),
- ),
- 'string_context' => array(
+ ],
+ ],
+ 'string_context' => [
'id' => 'string_context',
'label' => 'String typed data',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\TypedDataStringBlock',
- ),
- 'complex_context' => array(
+ ],
+ 'complex_context' => [
'id' => 'complex_context',
'label' => 'Complex context',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock',
- 'context' => array(
+ 'context' => [
'user' => new ContextDefinition('entity:user', 'User'),
'node' => new ContextDefinition('entity:node', 'Node'),
- ),
- ),
- );
- $this->defaultsTestPluginExpectedDefinitions = array(
- 'test_block1' => array(
- 'metadata' => array(
+ ],
+ ],
+ ];
+ $this->defaultsTestPluginExpectedDefinitions = [
+ 'test_block1' => [
+ 'metadata' => [
'default' => TRUE,
'custom' => TRUE,
- ),
+ ],
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockTestBlock',
- ),
- 'test_block2' => array(
- 'metadata' => array(
+ ],
+ 'test_block2' => [
+ 'metadata' => [
'default' => FALSE,
'custom' => TRUE,
- ),
+ ],
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockTestBlock',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php b/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php
index 3ea4c66ea52..b4e122b4b7a 100644
--- a/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php
@@ -30,7 +30,7 @@ class QueueSerializationTest extends KernelTestBase implements FormInterface {
*
* @var array
*/
- public static $modules = array('system', 'user', 'aggregator');
+ public static $modules = ['system', 'user', 'aggregator'];
/**
* {@inheritdoc}
@@ -80,10 +80,10 @@ class QueueSerializationTest extends KernelTestBase implements FormInterface {
$this->installSchema('system', ['key_value_expire', 'sequences']);
$this->installEntitySchema('user');
$this->queue = \Drupal::service('queue.database')->get('aggregator_refresh');
- $test_user = User::create(array(
+ $test_user = User::create([
'name' => 'foobar',
'mail' => 'foobar@example.com',
- ));
+ ]);
$test_user->save();
\Drupal::service('current_user')->setAccount($test_user);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Queue/QueueTest.php b/core/tests/Drupal/KernelTests/Core/Queue/QueueTest.php
index 1a2af7d416c..8bf48340aac 100644
--- a/core/tests/Drupal/KernelTests/Core/Queue/QueueTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Queue/QueueTest.php
@@ -50,9 +50,9 @@ class QueueTest extends KernelTestBase {
*/
protected function queueTest($queue1, $queue2) {
// Create four items.
- $data = array();
+ $data = [];
for ($i = 0; $i < 4; $i++) {
- $data[] = array($this->randomMachineName() => $this->randomMachineName());
+ $data[] = [$this->randomMachineName() => $this->randomMachineName()];
}
// Queue items 1 and 2 in the queue1.
@@ -60,8 +60,8 @@ class QueueTest extends KernelTestBase {
$queue1->createItem($data[1]);
// Retrieve two items from queue1.
- $items = array();
- $new_items = array();
+ $items = [];
+ $new_items = [];
$items[] = $item = $queue1->claimItem();
$new_items[] = $item->data;
diff --git a/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php b/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
index 3e11695af39..4cfb32c7dd9 100644
--- a/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
@@ -18,11 +18,11 @@ class RenderElementTypesTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'router_test');
+ public static $modules = ['system', 'router_test'];
protected function setUp() {
parent::setUp();
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
\Drupal::service('router.builder')->rebuild();
}
@@ -53,27 +53,27 @@ class RenderElementTypesTest extends KernelTestBase {
*/
function testContainer() {
// Basic container with no attributes.
- $this->assertElements(array(
+ $this->assertElements([
'#type' => 'container',
'#markup' => 'foo',
- ), "<div>foo</div>\n", "#type 'container' with no HTML attributes");
+ ], "<div>foo</div>\n", "#type 'container' with no HTML attributes");
// Container with a class.
- $this->assertElements(array(
+ $this->assertElements([
'#type' => 'container',
'#markup' => 'foo',
- '#attributes' => array(
- 'class' => array('bar'),
- ),
- ), '<div class="bar">foo</div>' . "\n", "#type 'container' with a class HTML attribute");
+ '#attributes' => [
+ 'class' => ['bar'],
+ ],
+ ], '<div class="bar">foo</div>' . "\n", "#type 'container' with a class HTML attribute");
// Container with children.
- $this->assertElements(array(
+ $this->assertElements([
'#type' => 'container',
- 'child' => array(
+ 'child' => [
'#markup' => 'foo',
- ),
- ), "<div>foo</div>\n", "#type 'container' with child elements");
+ ],
+ ], "<div>foo</div>\n", "#type 'container' with child elements");
}
/**
@@ -81,111 +81,111 @@ class RenderElementTypesTest extends KernelTestBase {
*/
function testHtmlTag() {
// Test void element.
- $this->assertElements(array(
+ $this->assertElements([
'#type' => 'html_tag',
'#tag' => 'meta',
'#value' => 'ignored',
- '#attributes' => array(
+ '#attributes' => [
'name' => 'description',
'content' => 'Drupal test',
- ),
- ), '<meta name="description" content="Drupal test" />' . "\n", "#type 'html_tag', void element renders properly");
+ ],
+ ], '<meta name="description" content="Drupal test" />' . "\n", "#type 'html_tag', void element renders properly");
// Test non-void element.
- $this->assertElements(array(
+ $this->assertElements([
'#type' => 'html_tag',
'#tag' => 'section',
'#value' => 'value',
- '#attributes' => array(
- 'class' => array('unicorns'),
- ),
- ), '<section class="unicorns">value</section>' . "\n", "#type 'html_tag', non-void element renders properly");
+ '#attributes' => [
+ 'class' => ['unicorns'],
+ ],
+ ], '<section class="unicorns">value</section>' . "\n", "#type 'html_tag', non-void element renders properly");
// Test empty void element tag.
- $this->assertElements(array(
+ $this->assertElements([
'#type' => 'html_tag',
'#tag' => 'link',
- ), "<link />\n", "#type 'html_tag' empty void element renders properly");
+ ], "<link />\n", "#type 'html_tag' empty void element renders properly");
// Test empty non-void element tag.
- $this->assertElements(array(
+ $this->assertElements([
'#type' => 'html_tag',
'#tag' => 'section',
- ), "<section></section>\n", "#type 'html_tag' empty non-void element renders properly");
+ ], "<section></section>\n", "#type 'html_tag' empty non-void element renders properly");
}
/**
* Tests system #type 'more_link'.
*/
function testMoreLink() {
- $elements = array(
- array(
+ $elements = [
+ [
'name' => "#type 'more_link' anchor tag generation without extra classes",
- 'value' => array(
+ 'value' => [
'#type' => 'more_link',
'#url' => Url::fromUri('https://www.drupal.org'),
- ),
+ ],
'expected' => '//div[@class="more-link"]/a[@href="https://www.drupal.org" and text()="More"]',
- ),
- array(
+ ],
+ [
'name' => "#type 'more_link' anchor tag generation with different link text",
- 'value' => array(
+ 'value' => [
'#type' => 'more_link',
'#url' => Url::fromUri('https://www.drupal.org'),
'#title' => 'More Titles',
- ),
+ ],
'expected' => '//div[@class="more-link"]/a[@href="https://www.drupal.org" and text()="More Titles"]',
- ),
- array(
+ ],
+ [
'name' => "#type 'more_link' anchor tag generation with attributes on wrapper",
- 'value' => array(
+ 'value' => [
'#type' => 'more_link',
'#url' => Url::fromUri('https://www.drupal.org'),
- '#theme_wrappers' => array(
- 'container' => array(
- '#attributes' => array(
+ '#theme_wrappers' => [
+ 'container' => [
+ '#attributes' => [
'title' => 'description',
- 'class' => array('more-link', 'drupal', 'test'),
- ),
- ),
- ),
- ),
+ 'class' => ['more-link', 'drupal', 'test'],
+ ],
+ ],
+ ],
+ ],
'expected' => '//div[@title="description" and contains(@class, "more-link") and contains(@class, "drupal") and contains(@class, "test")]/a[@href="https://www.drupal.org" and text()="More"]',
- ),
- array(
+ ],
+ [
'name' => "#type 'more_link' anchor tag with a relative path",
- 'value' => array(
+ 'value' => [
'#type' => 'more_link',
'#url' => Url::fromRoute('router_test.1'),
- ),
+ ],
'expected' => '//div[@class="more-link"]/a[@href="' . Url::fromRoute('router_test.1')->toString() . '" and text()="More"]',
- ),
- array(
+ ],
+ [
'name' => "#type 'more_link' anchor tag with a route",
- 'value' => array(
+ 'value' => [
'#type' => 'more_link',
'#url' => Url::fromRoute('router_test.1'),
- ),
+ ],
'expected' => '//div[@class="more-link"]/a[@href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" and text()="More"]',
- ),
- array(
+ ],
+ [
'name' => "#type 'more_link' anchor tag with an absolute path",
- 'value' => array(
+ 'value' => [
'#type' => 'more_link',
'#url' => Url::fromRoute('system.admin_content'),
- '#options' => array('absolute' => TRUE),
- ),
+ '#options' => ['absolute' => TRUE],
+ ],
'expected' => '//div[@class="more-link"]/a[@href="' . Url::fromRoute('system.admin_content')->setAbsolute()->toString() . '" and text()="More"]',
- ),
- array(
+ ],
+ [
'name' => "#type 'more_link' anchor tag to the front page",
- 'value' => array(
+ 'value' => [
'#type' => 'more_link',
'#url' => Url::fromRoute('<front>'),
- ),
+ ],
'expected' => '//div[@class="more-link"]/a[@href="' . Url::fromRoute('<front>')->toString() . '" and text()="More"]',
- ),
- );
+ ],
+ ];
foreach ($elements as $element) {
$xml = new \SimpleXMLElement(\Drupal::service('renderer')->renderRoot($element['value']));
@@ -198,25 +198,25 @@ class RenderElementTypesTest extends KernelTestBase {
* Tests system #type 'system_compact_link'.
*/
function testSystemCompactLink() {
- $elements = array(
- array(
+ $elements = [
+ [
'name' => "#type 'system_compact_link' when admin compact mode is off",
- 'value' => array(
+ 'value' => [
'#type' => 'system_compact_link',
- ),
+ ],
'expected' => '//div[@class="compact-link"]/a[contains(@href, "admin/compact/on?") and text()="Hide descriptions"]',
- ),
- array(
+ ],
+ [
'name' => "#type 'system_compact_link' when adding extra attributes",
- 'value' => array(
+ 'value' => [
'#type' => 'system_compact_link',
- '#attributes' => array(
- 'class' => array('kittens-rule'),
- ),
- ),
+ '#attributes' => [
+ 'class' => ['kittens-rule'],
+ ],
+ ],
'expected' => '//div[@class="compact-link"]/a[contains(@href, "admin/compact/on?") and @class="kittens-rule" and text()="Hide descriptions"]',
- ),
- );
+ ],
+ ];
foreach ($elements as $element) {
$xml = new \SimpleXMLElement(\Drupal::service('renderer')->renderRoot($element['value']));
@@ -227,13 +227,13 @@ class RenderElementTypesTest extends KernelTestBase {
// Set admin compact mode on for additional tests.
\Drupal::request()->cookies->set('Drupal_visitor_admin_compact_mode', TRUE);
- $element = array(
+ $element = [
'name' => "#type 'system_compact_link' when admin compact mode is on",
- 'value' => array(
+ 'value' => [
'#type' => 'system_compact_link',
- ),
+ ],
'expected' => '//div[@class="compact-link"]/a[contains(@href, "admin/compact?") and text()="Show descriptions"]',
- );
+ ];
$xml = new \SimpleXMLElement(\Drupal::service('renderer')->renderRoot($element['value']));
$result = $xml->xpath($element['expected']);
diff --git a/core/tests/Drupal/KernelTests/Core/Render/Element/TableSortExtenderTest.php b/core/tests/Drupal/KernelTests/Core/Render/Element/TableSortExtenderTest.php
index a77d52e51b1..10b215bb619 100644
--- a/core/tests/Drupal/KernelTests/Core/Render/Element/TableSortExtenderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Render/Element/TableSortExtenderTest.php
@@ -20,121 +20,121 @@ class TableSortExtenderTest extends KernelTestBase {
// Test simple table headers.
- $headers = array('foo', 'bar', 'baz');
+ $headers = ['foo', 'bar', 'baz'];
// Reset $request->query to prevent parameters from Simpletest and Batch API
// ending up in $ts['query'].
- $expected_ts = array(
+ $expected_ts = [
'name' => 'foo',
'sql' => '',
'sort' => 'asc',
- 'query' => array(),
- );
+ 'query' => [],
+ ];
$request = Request::createFromGlobals();
- $request->query->replace(array());
+ $request->query->replace([]);
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
- $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
+ $this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.');
// Test with simple table headers plus $_GET parameters that should _not_
// override the default.
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
// This should not override the table order because only complex
// headers are overridable.
'order' => 'bar',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
- $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
+ $this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.');
// Test with simple table headers plus $_GET parameters that _should_
// override the default.
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
'sort' => 'DESC',
// Add an unrelated parameter to ensure that tablesort will include
// it in the links that it creates.
'alpha' => 'beta',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
$expected_ts['sort'] = 'desc';
- $expected_ts['query'] = array('alpha' => 'beta');
+ $expected_ts['query'] = ['alpha' => 'beta'];
$ts = tablesort_init($headers);
- $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
+ $this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($ts, $expected_ts, 'Simple table headers plus $_GET parameters sorted correctly.');
// Test complex table headers.
- $headers = array(
+ $headers = [
'foo',
- array(
+ [
'data' => '1',
'field' => 'one',
'sort' => 'asc',
'colspan' => 1,
- ),
- array(
+ ],
+ [
'data' => '2',
'field' => 'two',
'sort' => 'desc',
- ),
- );
+ ],
+ ];
// Reset $_GET from previous assertion.
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
'order' => '2',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
- $expected_ts = array(
+ $expected_ts = [
'name' => '2',
'sql' => 'two',
'sort' => 'desc',
- 'query' => array(),
- );
- $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
+ 'query' => [],
+ ];
+ $this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($ts, $expected_ts, 'Complex table headers sorted correctly.');
// Test complex table headers plus $_GET parameters that should _not_
// override the default.
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
// This should not override the table order because this header does not
// exist.
'order' => 'bar',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = tablesort_init($headers);
- $expected_ts = array(
+ $expected_ts = [
'name' => '1',
'sql' => 'one',
'sort' => 'asc',
- 'query' => array(),
- );
- $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
+ 'query' => [],
+ ];
+ $this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.');
// Test complex table headers plus $_GET parameters that _should_
// override the default.
$request = Request::createFromGlobals();
- $request->query->replace(array(
+ $request->query->replace([
'order' => '1',
'sort' => 'ASC',
// Add an unrelated parameter to ensure that tablesort will include
// it in the links that it creates.
'alpha' => 'beta',
- ));
+ ]);
\Drupal::getContainer()->get('request_stack')->push($request);
- $expected_ts = array(
+ $expected_ts = [
'name' => '1',
'sql' => 'one',
'sort' => 'asc',
- 'query' => array('alpha' => 'beta'),
- );
+ 'query' => ['alpha' => 'beta'],
+ ];
$ts = tablesort_init($headers);
- $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
+ $this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php b/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
index 0f9e5b696a1..4fdb60edbbe 100644
--- a/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
@@ -22,14 +22,14 @@ class TableTest extends KernelTestBase {
* Tableheader.js provides 'sticky' table headers, and is included by default.
*/
function testThemeTableStickyHeaders() {
- $header = array('one', 'two', 'three');
- $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
- $table = array(
+ $header = ['one', 'two', 'three'];
+ $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#sticky' => TRUE,
- );
+ ];
$this->render($table);
// Make sure tableheader.js was attached.
$tableheader = $this->xpath("//script[contains(@src, 'tableheader.js')]");
@@ -41,12 +41,12 @@ class TableTest extends KernelTestBase {
* If $sticky is FALSE, no tableheader.js should be included.
*/
function testThemeTableNoStickyHeaders() {
- $header = array('one', 'two', 'three');
- $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
- $attributes = array();
+ $header = ['one', 'two', 'three'];
+ $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+ $attributes = [];
$caption = NULL;
- $colgroups = array();
- $table = array(
+ $colgroups = [];
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
@@ -54,7 +54,7 @@ class TableTest extends KernelTestBase {
'#caption' => $caption,
'#colgroups' => $colgroups,
'#sticky' => FALSE,
- );
+ ];
$this->render($table);
// Make sure tableheader.js was not attached.
$tableheader = $this->xpath("//script[contains(@src, 'tableheader.js')]");
@@ -67,19 +67,19 @@ class TableTest extends KernelTestBase {
* and that the empty text is displayed correctly.
*/
function testThemeTableWithEmptyMessage() {
- $header = array(
+ $header = [
'Header 1',
- array(
+ [
'data' => 'Header 2',
'colspan' => 2,
- ),
- );
- $table = array(
+ ],
+ ];
+ $table = [
'#type' => 'table',
'#header' => $header,
- '#rows' => array(),
+ '#rows' => [],
'#empty' => 'Empty row.',
- );
+ ];
// Enable the Classy theme.
\Drupal::service('theme_handler')->install(['classy']);
@@ -95,16 +95,16 @@ class TableTest extends KernelTestBase {
* Tests that the 'no_striping' option works correctly.
*/
function testThemeTableWithNoStriping() {
- $rows = array(
- array(
- 'data' => array(1),
+ $rows = [
+ [
+ 'data' => [1],
'no_striping' => TRUE,
- ),
- );
- $table = array(
+ ],
+ ];
+ $table = [
'#type' => 'table',
'#rows' => $rows,
- );
+ ];
$this->render($table);
$this->assertNoRaw('class="odd"', 'Odd/even classes were not added because $no_striping = TRUE.');
$this->assertNoRaw('no_striping', 'No invalid no_striping HTML attribute was printed.');
@@ -114,18 +114,18 @@ class TableTest extends KernelTestBase {
* Test that the 'footer' option works correctly.
*/
function testThemeTableFooter() {
- $footer = array(
- array(
- 'data' => array(1),
- ),
- array('Foo'),
- );
+ $footer = [
+ [
+ 'data' => [1],
+ ],
+ ['Foo'],
+ ];
- $table = array(
+ $table = [
'#type' => 'table',
- '#rows' => array(),
+ '#rows' => [],
'#footer' => $footer,
- );
+ ];
$this->render($table);
$this->removeWhiteSpace();
@@ -136,17 +136,17 @@ class TableTest extends KernelTestBase {
* Tests that the 'header' option in cells works correctly.
*/
function testThemeTableHeaderCellOption() {
- $rows = array(
- array(
- array('data' => 1, 'header' => TRUE),
- array('data' => 1, 'header' => FALSE),
- array('data' => 1),
- ),
- );
- $table = array(
+ $rows = [
+ [
+ ['data' => 1, 'header' => TRUE],
+ ['data' => 1, 'header' => FALSE],
+ ['data' => 1],
+ ],
+ ];
+ $table = [
'#type' => 'table',
'#rows' => $rows,
- );
+ ];
$this->render($table);
$this->removeWhiteSpace();
$this->assertRaw('<th>1</th><td>1</td><td>1</td>', 'The th and td tags was printed correctly.');
@@ -156,14 +156,14 @@ class TableTest extends KernelTestBase {
* Tests that the 'responsive-table' class is applied correctly.
*/
public function testThemeTableResponsive() {
- $header = array('one', 'two', 'three');
- $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
- $table = array(
+ $header = ['one', 'two', 'three'];
+ $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#responsive' => TRUE,
- );
+ ];
$this->render($table);
$this->assertRaw('responsive-enabled', 'The responsive-enabled class was printed correctly.');
}
@@ -172,12 +172,12 @@ class TableTest extends KernelTestBase {
* Tests that the 'responsive-table' class is not applied without headers.
*/
public function testThemeTableNotResponsiveHeaders() {
- $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
- $table = array(
+ $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+ $table = [
'#type' => 'table',
'#rows' => $rows,
'#responsive' => TRUE,
- );
+ ];
$this->render($table);
$this->assertNoRaw('responsive-enabled', 'The responsive-enabled class is not applied without table headers.');
}
@@ -186,14 +186,14 @@ class TableTest extends KernelTestBase {
* Tests that 'responsive-table' class only applied when responsive is TRUE.
*/
public function testThemeTableNotResponsiveProperty() {
- $header = array('one', 'two', 'three');
- $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
- $table = array(
+ $header = ['one', 'two', 'three'];
+ $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#responsive' => FALSE,
- );
+ ];
$this->render($table);
$this->assertNoRaw('responsive-enabled', 'The responsive-enabled class is not applied without the "responsive" property set to TRUE.');
}
@@ -202,21 +202,21 @@ class TableTest extends KernelTestBase {
* Tests 'priority-medium' and 'priority-low' classes.
*/
public function testThemeTableResponsivePriority() {
- $header = array(
+ $header = [
// Test associative header indices.
- 'associative_key' => array('data' => 1, 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)),
+ 'associative_key' => ['data' => 1, 'class' => [RESPONSIVE_PRIORITY_MEDIUM]],
// Test non-associative header indices.
- array('data' => 2, 'class' => array(RESPONSIVE_PRIORITY_LOW)),
+ ['data' => 2, 'class' => [RESPONSIVE_PRIORITY_LOW]],
// Test no responsive priorities.
- array('data' => 3),
- );
- $rows = array(array(4, 5, 6));
- $table = array(
+ ['data' => 3],
+ ];
+ $rows = [[4, 5, 6]];
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#responsive' => TRUE,
- );
+ ];
$this->render($table);
$this->assertRaw('<th class="priority-medium">1</th>', 'Header 1: the priority-medium class was applied correctly.');
$this->assertRaw('<th class="priority-low">2</th>', 'Header 2: the priority-low class was applied correctly.');
@@ -230,28 +230,28 @@ class TableTest extends KernelTestBase {
* Tests header elements with a mix of string and render array values.
*/
public function testThemeTableHeaderRenderArray() {
- $header = array(
- array (
- 'data' => array(
+ $header = [
+ [
+ 'data' => [
'#markup' => 'one',
- ),
- ),
+ ],
+ ],
'two',
- array (
- 'data' => array(
+ [
+ 'data' => [
'#type' => 'html_tag',
'#tag' => 'b',
'#value' => 'three',
- ),
- ),
- );
- $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
- $table = array(
+ ],
+ ],
+ ];
+ $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#responsive' => FALSE,
- );
+ ];
$this->render($table);
$this->removeWhiteSpace();
$this->assertRaw('<thead><tr><th>one</th><th>two</th><th><b>three</b></th></tr>', 'Table header found.');
@@ -261,37 +261,37 @@ class TableTest extends KernelTestBase {
* Tests row elements with a mix of string and render array values.
*/
public function testThemeTableRowRenderArray() {
- $header = array('one', 'two', 'three');
- $rows = array(
- array(
+ $header = ['one', 'two', 'three'];
+ $rows = [
+ [
'1-one',
- array(
+ [
'data' => '1-two'
- ),
+ ],
'1-three',
- ),
- array(
- array (
- 'data' => array(
+ ],
+ [
+ [
+ 'data' => [
'#markup' => '2-one',
- ),
- ),
+ ],
+ ],
'2-two',
- array (
- 'data' => array(
+ [
+ 'data' => [
'#type' => 'html_tag',
'#tag' => 'b',
'#value' => '2-three',
- ),
- ),
- ),
- );
- $table = array(
+ ],
+ ],
+ ],
+ ];
+ $table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#responsive' => FALSE,
- );
+ ];
$this->render($table);
$this->removeWhiteSpace();
$this->assertRaw('<tbody><tr><td>1-one</td><td>1-two</td><td>1-three</td></tr>', 'Table row 1 found.');
diff --git a/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php b/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php
index 8860c19a154..88f993e7251 100644
--- a/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php
@@ -16,7 +16,7 @@ class RenderTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'common_test');
+ public static $modules = ['system', 'common_test'];
/**
* Tests theme preprocess functions being able to attach assets.
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php b/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php
index 3998268f156..3054ecb165d 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php
@@ -125,9 +125,9 @@ class MatcherDumperTest extends KernelTestBase {
$this->fixtures->createTables($connection);
- $dumper->dump(array('provider' => 'test'));
+ $dumper->dump(['provider' => 'test']);
- $record = $connection->query("SELECT * FROM {test_routes} WHERE name= :name", array(':name' => 'test_route'))->fetchObject();
+ $record = $connection->query("SELECT * FROM {test_routes} WHERE name= :name", [':name' => 'test_route'])->fetchObject();
$loaded_route = unserialize($record->route);
@@ -155,15 +155,15 @@ class MatcherDumperTest extends KernelTestBase {
$this->fixtures->createTables($connection);
- $dumper->dump(array('provider' => 'test'));
+ $dumper->dump(['provider' => 'test']);
// Using binary for readability, we expect a 0 at any wildcard slug. They
// should be ordered from longest to shortest.
- $expected = array(
+ $expected = [
bindec('1011111'),
bindec('10111'),
bindec('111'),
bindec('101'),
- );
+ ];
$this->assertEqual($this->state->get('routing.menu_masks.test_routes'), $expected);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
index 524587089fe..835c812ca92 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
@@ -117,7 +117,7 @@ class RouteProviderTest extends KernelTestBase {
$connection = Database::getConnection();
$provider = new TestRouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
- $parts = array('node', '5', 'edit');
+ $parts = ['node', '5', 'edit'];
$candidates = $provider->getCandidateOutlines($parts);
@@ -335,9 +335,9 @@ class RouteProviderTest extends KernelTestBase {
$this->fixtures->createTables($connection);
$collection = new RouteCollection();
- $collection->add('poink', new Route('/some/path/{value}', array(
+ $collection->add('poink', new Route('/some/path/{value}', [
'value' => 'poink',
- )));
+ ]));
$dumper = new MatcherDumper($connection, $this->state, 'test_routes');
$dumper->addRoutes($collection);
@@ -373,9 +373,9 @@ class RouteProviderTest extends KernelTestBase {
$this->fixtures->createTables($connection);
$collection = new RouteCollection();
- $collection->add('poink', new Route('/some/path/{value}', array(
+ $collection->add('poink', new Route('/some/path/{value}', [
'value' => 'poink',
- )));
+ ]));
$collection->add('narf', new Route('/some/path/here'));
$dumper = new MatcherDumper($connection, $this->state, 'test_routes');
@@ -412,9 +412,9 @@ class RouteProviderTest extends KernelTestBase {
$this->fixtures->createTables($connection);
$collection = new RouteCollection();
- $collection->add('poink', new Route('/some/path/{value}', array(
+ $collection->add('poink', new Route('/some/path/{value}', [
'value' => 'poink',
- )));
+ ]));
$collection->add('narf', new Route('/some/path/here'));
$collection->add('eep', new Route('/something/completely/different'));
@@ -431,7 +431,7 @@ class RouteProviderTest extends KernelTestBase {
$routes_array = $routes->all();
$this->assertEqual(count($routes), 2, 'The correct number of routes was found.');
- $this->assertEqual(array('narf', 'poink'), array_keys($routes_array), 'Ensure the fitness was taken into account.');
+ $this->assertEqual(['narf', 'poink'], array_keys($routes_array), 'Ensure the fitness was taken into account.');
$this->assertNotNull($routes->get('narf'), 'The first matching route was found.');
$this->assertNotNull($routes->get('poink'), 'The second matching route was found.');
$this->assertNull($routes->get('eep'), 'Non-matching route was not found.');
@@ -470,7 +470,7 @@ class RouteProviderTest extends KernelTestBase {
$routes_array = $routes->all();
$this->assertEqual(count($routes), 2, 'The correct number of routes was found.');
- $this->assertEqual(array('poink', 'poink2'), array_keys($routes_array), 'Ensure the fitness and name were taken into account in the sort.');
+ $this->assertEqual(['poink', 'poink2'], array_keys($routes_array), 'Ensure the fitness and name were taken into account in the sort.');
$this->assertNotNull($routes->get('poink'), 'The first matching route was found.');
$this->assertNotNull($routes->get('poink2'), 'The second matching route was found.');
$this->assertNull($routes->get('eep'), 'Non-matching route was not found.');
@@ -631,7 +631,7 @@ class RouteProviderTest extends KernelTestBase {
}
$this->assertTrue($exception_thrown, 'Random route was not found.');
- $routes = $provider->getRoutesByNames(array('route_c', 'route_d', $this->randomMachineName()));
+ $routes = $provider->getRoutesByNames(['route_c', 'route_d', $this->randomMachineName()]);
$this->assertEqual(count($routes), 2, 'Only two valid routes found.');
$this->assertEqual($routes['route_c']->getPath(), '/path/two');
$this->assertEqual($routes['route_d']->getPath(), '/path/three');
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php
index a70cc1fa38b..053db792cbb 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php
@@ -19,7 +19,7 @@ class UrlIntegrationTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('user', 'router_test', 'system');
+ public static $modules = ['user', 'router_test', 'system'];
/**
* Ensures that the access() method on \Drupal\Core\Url objects works.
diff --git a/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php b/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php
index 2995c973ec3..011dfb70d80 100644
--- a/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php
@@ -16,7 +16,7 @@ class ServiceProviderTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('file', 'service_provider_test', 'system');
+ public static $modules = ['file', 'service_provider_test', 'system'];
/**
* Tests that services provided by module service providers get registered to the DIC.
@@ -32,11 +32,11 @@ class ServiceProviderTest extends KernelTestBase {
*/
function testServiceProviderRegistrationDynamic() {
// Uninstall the module and ensure the service provider's service is not registered.
- \Drupal::service('module_installer')->uninstall(array('service_provider_test'));
+ \Drupal::service('module_installer')->uninstall(['service_provider_test']);
$this->assertFalse(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service does not exist in the DIC.');
// Install the module and ensure the service provider's service is registered.
- \Drupal::service('module_installer')->install(array('service_provider_test'));
+ \Drupal::service('module_installer')->install(['service_provider_test']);
$this->assertTrue(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service exists in the DIC.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php b/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php
index 0e6fa8a7782..0492d773475 100644
--- a/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php
@@ -20,7 +20,7 @@ class AccountSwitcherTest extends KernelTestBase {
$original_session_saving = $session_handler->isSessionWritable();
// Switch to user with uid 2.
- $switcher->switchTo(new UserSession(array('uid' => 2)));
+ $switcher->switchTo(new UserSession(['uid' => 2]));
// Verify that the active user has changed, and that session saving is
// disabled.
@@ -28,7 +28,7 @@ class AccountSwitcherTest extends KernelTestBase {
$this->assertFalse($session_handler->isSessionWritable(), 'Session saving is disabled.');
// Perform a second (nested) user account switch.
- $switcher->switchTo(new UserSession(array('uid' => 3)));
+ $switcher->switchTo(new UserSession(['uid' => 3]));
$this->assertEqual($user->id(), 3, 'Switched to user 3.');
// Revert to the user session that was active between the first and second
diff --git a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php
index 948236bc41c..a015d07608a 100644
--- a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php
@@ -18,83 +18,83 @@ class SettingsRewriteTest extends KernelTestBase {
function testDrupalRewriteSettings() {
include_once \Drupal::root() . '/core/includes/install.inc';
$site_path = $this->container->get('site.path');
- $tests = array(
- array(
+ $tests = [
+ [
'original' => '$no_index_value_scalar = TRUE;',
- 'settings' => array(
- 'no_index_value_scalar' => (object) array(
+ 'settings' => [
+ 'no_index_value_scalar' => (object) [
'value' => FALSE,
'comment' => 'comment',
- ),
- ),
+ ],
+ ],
'expected' => '$no_index_value_scalar = false; // comment',
- ),
- array(
+ ],
+ [
'original' => '$no_index_value_scalar = TRUE;',
- 'settings' => array(
- 'no_index_value_foo' => array(
- 'foo' => array(
- 'value' => (object) array(
+ 'settings' => [
+ 'no_index_value_foo' => [
+ 'foo' => [
+ 'value' => (object) [
'value' => NULL,
'required' => TRUE,
'comment' => 'comment',
- ),
- ),
- ),
- ),
+ ],
+ ],
+ ],
+ ],
'expected' => <<<'EXPECTED'
$no_index_value_scalar = TRUE;
$no_index_value_foo['foo']['value'] = NULL; // comment
EXPECTED
- ),
- array(
+ ],
+ [
'original' => '$no_index_value_array = array("old" => "value");',
- 'settings' => array(
- 'no_index_value_array' => (object) array(
+ 'settings' => [
+ 'no_index_value_array' => (object) [
'value' => FALSE,
'required' => TRUE,
'comment' => 'comment',
- ),
- ),
+ ],
+ ],
'expected' => '$no_index_value_array = array("old" => "value");
$no_index_value_array = false; // comment',
- ),
- array(
+ ],
+ [
'original' => '$has_index_value_scalar["foo"]["bar"] = NULL;',
- 'settings' => array(
- 'has_index_value_scalar' => array(
- 'foo' => array(
- 'bar' => (object) array(
+ 'settings' => [
+ 'has_index_value_scalar' => [
+ 'foo' => [
+ 'bar' => (object) [
'value' => FALSE,
'required' => TRUE,
'comment' => 'comment',
- ),
- ),
- ),
- ),
+ ],
+ ],
+ ],
+ ],
'expected' => '$has_index_value_scalar["foo"]["bar"] = false; // comment',
- ),
- array(
+ ],
+ [
'original' => '$has_index_value_scalar["foo"]["bar"] = "foo";',
- 'settings' => array(
- 'has_index_value_scalar' => array(
- 'foo' => array(
- 'value' => (object) array(
- 'value' => array('value' => 2),
+ 'settings' => [
+ 'has_index_value_scalar' => [
+ 'foo' => [
+ 'value' => (object) [
+ 'value' => ['value' => 2],
'required' => TRUE,
'comment' => 'comment',
- ),
- ),
- ),
- ),
+ ],
+ ],
+ ],
+ ],
'expected' => <<<'EXPECTED'
$has_index_value_scalar["foo"]["bar"] = "foo";
$has_index_value_scalar['foo']['value'] = array (
'value' => 2,
); // comment
EXPECTED
- ),
- );
+ ],
+ ];
foreach ($tests as $test) {
$filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php';
file_put_contents($filename, "<?php\n" . $test['original'] . "\n");
@@ -104,15 +104,15 @@ EXPECTED
// Test that <?php gets added to the start of an empty settings file.
// Set the array of settings that will be written to the file.
- $test = array(
- 'settings' => array(
- 'no_index' => (object) array(
+ $test = [
+ 'settings' => [
+ 'no_index' => (object) [
'value' => TRUE,
'required' => TRUE,
- ),
- ),
+ ],
+ ],
'expected' => '$no_index = true;'
- );
+ ];
// Make an empty file.
$filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php';
file_put_contents($filename, "");
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php
index 51608ebdce9..dd8ef7cc552 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php
@@ -17,7 +17,7 @@ class ImageTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/*
* The images to test with.
@@ -36,10 +36,10 @@ class ImageTest extends KernelTestBase {
$this->container = \Drupal::service('kernel')->getContainer();
$this->container->get('request_stack')->push($request);
- $this->testImages = array(
+ $this->testImages = [
'core/misc/druplicon.png',
'core/misc/loading.gif',
- );
+ ];
}
/**
@@ -48,7 +48,7 @@ class ImageTest extends KernelTestBase {
function testThemeImageWithSizes() {
// Test with multipliers.
$sizes = '(max-width: ' . rand(10, 30) . 'em) 100vw, (max-width: ' . rand(30, 50) . 'em) 50vw, 30vw';
- $image = array(
+ $image = [
'#theme' => 'image',
'#sizes' => $sizes,
'#uri' => reset($this->testImages),
@@ -56,7 +56,7 @@ class ImageTest extends KernelTestBase {
'#height' => rand(0, 500) . 'px',
'#alt' => $this->randomMachineName(),
'#title' => $this->randomMachineName(),
- );
+ ];
$this->render($image);
// Make sure sizes is set.
@@ -68,14 +68,14 @@ class ImageTest extends KernelTestBase {
*/
function testThemeImageWithSrc() {
- $image = array(
+ $image = [
'#theme' => 'image',
'#uri' => reset($this->testImages),
'#width' => rand(0, 1000) . 'px',
'#height' => rand(0, 500) . 'px',
'#alt' => $this->randomMachineName(),
'#title' => $this->randomMachineName(),
- );
+ ];
$this->render($image);
// Make sure the src attribute has the correct value.
@@ -87,23 +87,23 @@ class ImageTest extends KernelTestBase {
*/
function testThemeImageWithSrcsetMultiplier() {
// Test with multipliers.
- $image = array(
+ $image = [
'#theme' => 'image',
- '#srcset' => array(
- array(
+ '#srcset' => [
+ [
'uri' => $this->testImages[0],
'multiplier' => '1x',
- ),
- array(
+ ],
+ [
'uri' => $this->testImages[1],
'multiplier' => '2x',
- ),
- ),
+ ],
+ ],
'#width' => rand(0, 1000) . 'px',
'#height' => rand(0, 500) . 'px',
'#alt' => $this->randomMachineName(),
'#title' => $this->randomMachineName(),
- );
+ ];
$this->render($image);
// Make sure the srcset attribute has the correct value.
@@ -115,27 +115,27 @@ class ImageTest extends KernelTestBase {
*/
function testThemeImageWithSrcsetWidth() {
// Test with multipliers.
- $widths = array(
+ $widths = [
rand(0, 500) . 'w',
rand(500, 1000) . 'w',
- );
- $image = array(
+ ];
+ $image = [
'#theme' => 'image',
- '#srcset' => array(
- array(
+ '#srcset' => [
+ [
'uri' => $this->testImages[0],
'width' => $widths[0],
- ),
- array(
+ ],
+ [
'uri' => $this->testImages[1],
'width' => $widths[1],
- ),
- ),
+ ],
+ ],
'#width' => rand(0, 1000) . 'px',
'#height' => rand(0, 500) . 'px',
'#alt' => $this->randomMachineName(),
'#title' => $this->randomMachineName(),
- );
+ ];
$this->render($image);
// Make sure the srcset attribute has the correct value.
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php
index a9d61504668..985a57ab98e 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php
@@ -14,7 +14,7 @@ class MessageTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Tests setting messages output.
@@ -26,9 +26,9 @@ class MessageTest extends KernelTestBase {
drupal_set_message('An error occurred', 'error');
drupal_set_message('But then something nice happened');
- $messages = array(
+ $messages = [
'#type' => 'status_messages',
- );
+ ];
$this->render($messages);
$this->assertRaw('messages messages--error');
$this->assertRaw('messages messages--status');
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php
index 97559e5ddd5..bbd7342ba36 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php
@@ -20,7 +20,7 @@ class RegistryTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('theme_test', 'system');
+ public static $modules = ['theme_test', 'system'];
protected $profile = 'testing';
@@ -37,7 +37,7 @@ class RegistryTest extends KernelTestBase {
// entry to be written in __construct().
$cache = \Drupal::cache();
$lock_backend = \Drupal::lock();
- $registry = new ThemeRegistry($cid, $cache, $lock_backend, array('theme_registry'), $this->container->get('module_handler')->isLoaded());
+ $registry = new ThemeRegistry($cid, $cache, $lock_backend, ['theme_registry'], $this->container->get('module_handler')->isLoaded());
$this->assertTrue(\Drupal::cache()->get($cid), 'Cache entry was created.');
@@ -57,7 +57,7 @@ class RegistryTest extends KernelTestBase {
// Create a new instance of the class. Confirm that both the offset
// requested previously, and one that has not yet been requested are both
// available.
- $registry = new ThemeRegistry($cid, $cache, $lock_backend, array('theme_registry'), $this->container->get('module_handler')->isLoaded());
+ $registry = new ThemeRegistry($cid, $cache, $lock_backend, ['theme_registry'], $this->container->get('module_handler')->isLoaded());
$this->assertTrue($registry->get('theme_test_template_test'), 'Offset was returned correctly from the theme registry');
$this->assertTrue($registry->get('theme_test_template_test_2'), 'Offset was returned correctly from the theme registry');
}
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php
index f3e2ade0e1e..cbaf0a3d20e 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php
@@ -18,7 +18,7 @@ class ThemeInstallerTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* {@inheritdoc}
@@ -33,7 +33,7 @@ class ThemeInstallerTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
}
/**
@@ -61,7 +61,7 @@ class ThemeInstallerTest extends KernelTestBase {
$themes = $this->themeHandler()->listInfo();
$this->assertFalse(isset($themes[$name]));
- $this->themeInstaller()->install(array($name));
+ $this->themeInstaller()->install([$name]);
$this->assertIdentical($this->extensionConfig()->get("theme.$name"), 0);
@@ -87,13 +87,13 @@ class ThemeInstallerTest extends KernelTestBase {
$themes = $this->themeHandler()->listInfo();
$this->assertFalse(array_keys($themes));
- $this->themeInstaller()->install(array($name));
+ $this->themeInstaller()->install([$name]);
$themes = $this->themeHandler()->listInfo();
$this->assertTrue(isset($themes[$name]));
$this->assertTrue(isset($themes[$base_name]));
- $this->themeInstaller()->uninstall(array($name));
+ $this->themeInstaller()->uninstall([$name]);
$themes = $this->themeHandler()->listInfo();
$this->assertFalse(isset($themes[$name]));
@@ -111,7 +111,7 @@ class ThemeInstallerTest extends KernelTestBase {
try {
$message = 'ThemeHandler::install() throws InvalidArgumentException upon installing a non-existing theme.';
- $this->themeInstaller()->install(array($name));
+ $this->themeInstaller()->install([$name]);
$this->fail($message);
}
catch (\InvalidArgumentException $e) {
@@ -130,7 +130,7 @@ class ThemeInstallerTest extends KernelTestBase {
try {
$message = 'ThemeHandler::install() throws ExtensionNameLengthException upon installing a theme with a too long name.';
- $this->themeInstaller()->install(array($name));
+ $this->themeInstaller()->install([$name]);
$this->fail($message);
}
catch (ExtensionNameLengthException $e) {
@@ -144,7 +144,7 @@ class ThemeInstallerTest extends KernelTestBase {
function testUninstallDefault() {
$name = 'stark';
$other_name = 'bartik';
- $this->themeInstaller()->install(array($name, $other_name));
+ $this->themeInstaller()->install([$name, $other_name]);
$this->config('system.theme')->set('default', $name)->save();
$themes = $this->themeHandler()->listInfo();
@@ -153,7 +153,7 @@ class ThemeInstallerTest extends KernelTestBase {
try {
$message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling default theme.';
- $this->themeHandler()->uninstall(array($name));
+ $this->themeHandler()->uninstall([$name]);
$this->fail($message);
}
catch (\InvalidArgumentException $e) {
@@ -171,7 +171,7 @@ class ThemeInstallerTest extends KernelTestBase {
function testUninstallAdmin() {
$name = 'stark';
$other_name = 'bartik';
- $this->themeInstaller()->install(array($name, $other_name));
+ $this->themeInstaller()->install([$name, $other_name]);
$this->config('system.theme')->set('admin', $name)->save();
$themes = $this->themeHandler()->listInfo();
@@ -180,7 +180,7 @@ class ThemeInstallerTest extends KernelTestBase {
try {
$message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling admin theme.';
- $this->themeHandler()->uninstall(array($name));
+ $this->themeHandler()->uninstall([$name]);
$this->fail($message);
}
catch (\InvalidArgumentException $e) {
@@ -199,8 +199,8 @@ class ThemeInstallerTest extends KernelTestBase {
$name = 'test_subtheme';
$base_name = 'test_basetheme';
- $this->themeInstaller()->install(array($name));
- $this->themeInstaller()->uninstall(array($name));
+ $this->themeInstaller()->install([$name]);
+ $this->themeInstaller()->uninstall([$name]);
$themes = $this->themeHandler()->listInfo();
$this->assertFalse(isset($themes[$name]));
@@ -214,11 +214,11 @@ class ThemeInstallerTest extends KernelTestBase {
$name = 'test_basetheme';
$sub_name = 'test_subtheme';
- $this->themeInstaller()->install(array($sub_name));
+ $this->themeInstaller()->install([$sub_name]);
try {
$message = 'ThemeHandler::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.';
- $this->themeInstaller()->uninstall(array($name));
+ $this->themeInstaller()->uninstall([$name]);
$this->fail($message);
}
catch (\InvalidArgumentException $e) {
@@ -230,7 +230,7 @@ class ThemeInstallerTest extends KernelTestBase {
$this->assertTrue(isset($themes[$sub_name]));
// Verify that uninstalling both at the same time works.
- $this->themeInstaller()->uninstall(array($name, $sub_name));
+ $this->themeInstaller()->uninstall([$name, $sub_name]);
$themes = $this->themeHandler()->listInfo();
$this->assertFalse(isset($themes[$name]));
@@ -248,7 +248,7 @@ class ThemeInstallerTest extends KernelTestBase {
try {
$message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a non-existing theme.';
- $this->themeInstaller()->uninstall(array($name));
+ $this->themeInstaller()->uninstall([$name]);
$this->fail($message);
}
catch (\InvalidArgumentException $e) {
@@ -265,10 +265,10 @@ class ThemeInstallerTest extends KernelTestBase {
function testUninstall() {
$name = 'test_basetheme';
- $this->themeInstaller()->install(array($name));
+ $this->themeInstaller()->install([$name]);
$this->assertTrue($this->config("$name.settings")->get());
- $this->themeInstaller()->uninstall(array($name));
+ $this->themeInstaller()->uninstall([$name]);
$this->assertFalse(array_keys($this->themeHandler()->listInfo()));
$this->assertFalse(array_keys(system_list('theme')));
@@ -276,7 +276,7 @@ class ThemeInstallerTest extends KernelTestBase {
$this->assertFalse($this->config("$name.settings")->get());
// Ensure that the uninstalled theme can be installed again.
- $this->themeInstaller()->install(array($name));
+ $this->themeInstaller()->install([$name]);
$themes = $this->themeHandler()->listInfo();
$this->assertTrue(isset($themes[$name]));
$this->assertEqual($themes[$name]->getName(), $name);
@@ -292,7 +292,7 @@ class ThemeInstallerTest extends KernelTestBase {
try {
$message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a theme that is not installed.';
- $this->themeInstaller()->uninstall(array($name));
+ $this->themeInstaller()->uninstall([$name]);
$this->fail($message);
}
catch (\InvalidArgumentException $e) {
@@ -309,7 +309,7 @@ class ThemeInstallerTest extends KernelTestBase {
$name = 'seven';
$this->container->get('state')->set('module_test.hook_system_info_alter', TRUE);
- $this->themeInstaller()->install(array($name));
+ $this->themeInstaller()->install([$name]);
$themes = $this->themeHandler()->listInfo();
$this->assertFalse(isset($themes[$name]->info['regions']['test_region']));
@@ -317,7 +317,7 @@ class ThemeInstallerTest extends KernelTestBase {
// Rebuild module data so we know where module_test is located.
// @todo Remove as part of https://www.drupal.org/node/2186491
system_rebuild_module_data();
- $this->moduleInstaller()->install(array('module_test'), FALSE);
+ $this->moduleInstaller()->install(['module_test'], FALSE);
$this->assertTrue($this->moduleHandler()->moduleExists('module_test'));
$themes = $this->themeHandler()->listInfo();
@@ -333,7 +333,7 @@ class ThemeInstallerTest extends KernelTestBase {
$system_list = system_list('theme');
$this->assertTrue(isset($system_list[$name]->info['regions']['test_region']));
- $this->moduleInstaller()->uninstall(array('module_test'));
+ $this->moduleInstaller()->uninstall(['module_test']);
$this->assertFalse($this->moduleHandler()->moduleExists('module_test'));
$themes = $this->themeHandler()->listInfo();
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php
index 6c2dfb39f07..d74df1422a7 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php
@@ -18,7 +18,7 @@ class ThemeSettingsTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* List of discovered themes.
@@ -30,7 +30,7 @@ class ThemeSettingsTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
// Theme settings rely on System module's system.theme.global configuration.
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
if (!isset($this->availableThemes)) {
$discovery = new ExtensionDiscovery(\Drupal::root());
@@ -45,7 +45,7 @@ class ThemeSettingsTest extends KernelTestBase {
$name = 'test_basetheme';
$path = $this->availableThemes[$name]->getPath();
$this->assertTrue(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml"));
- $this->container->get('theme_handler')->install(array($name));
+ $this->container->get('theme_handler')->install([$name]);
$this->assertIdentical(theme_get_setting('base', $name), 'only');
}
@@ -56,7 +56,7 @@ class ThemeSettingsTest extends KernelTestBase {
$name = 'stark';
$path = $this->availableThemes[$name]->getPath();
$this->assertFalse(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml"));
- $this->container->get('theme_handler')->install(array($name));
+ $this->container->get('theme_handler')->install([$name]);
$this->assertNotNull(theme_get_setting('features.favicon', $name));
}
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php
index ba7a3cd8acc..5d6f61f205b 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php
@@ -21,7 +21,7 @@ class TwigEnvironmentTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Tests inline templates.
@@ -32,15 +32,15 @@ class TwigEnvironmentTest extends KernelTestBase {
/** @var \Drupal\Core\Template\TwigEnvironment $environment */
$environment = \Drupal::service('twig');
$this->assertEqual($environment->renderInline('test-no-context'), 'test-no-context');
- $this->assertEqual($environment->renderInline('test-with-context {{ llama }}', array('llama' => 'muuh')), 'test-with-context muuh');
+ $this->assertEqual($environment->renderInline('test-with-context {{ llama }}', ['llama' => 'muuh']), 'test-with-context muuh');
- $element = array();
+ $element = [];
$unsafe_string = '<script>alert(\'Danger! High voltage!\');</script>';
- $element['test'] = array(
+ $element['test'] = [
'#type' => 'inline_template',
'#template' => 'test-with-context <label>{{ unsafe_content }}</label>',
- '#context' => array('unsafe_content' => $unsafe_string),
- );
+ '#context' => ['unsafe_content' => $unsafe_string],
+ ];
$this->assertEqual($renderer->renderRoot($element), 'test-with-context <label>' . Html::escape($unsafe_string) . '</label>');
// Enable twig_auto_reload and twig_debug.
@@ -52,12 +52,12 @@ class TwigEnvironmentTest extends KernelTestBase {
$this->container = \Drupal::service('kernel')->rebuildContainer();
\Drupal::setContainer($this->container);
- $element = array();
- $element['test'] = array(
+ $element = [];
+ $element['test'] = [
'#type' => 'inline_template',
'#template' => 'test-with-context {{ llama }}',
- '#context' => array('llama' => 'muuh'),
- );
+ '#context' => ['llama' => 'muuh'],
+ ];
$element_copy = $element;
// Render it twice so that twig caching is triggered.
$this->assertEqual($renderer->renderRoot($element), 'test-with-context muuh');
@@ -101,7 +101,7 @@ class TwigEnvironmentTest extends KernelTestBase {
$environment = \Drupal::service('twig');
try {
- $environment->loadTemplate('this-template-does-not-exist.html.twig')->render(array());
+ $environment->loadTemplate('this-template-does-not-exist.html.twig')->render([]);
$this->fail('Did not throw an exception as expected.');
}
catch (\Twig_Error_Loader $e) {
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php
index 2e6e5a40288..d30d2de13d3 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php
@@ -90,7 +90,7 @@ class TwigMarkupInterfaceTest extends KernelTestBase {
$elements = [
'#type' => 'inline_template',
'#template' => '{%- if variable is not empty -%}<span>{{ variable }}</span>{%- endif -%}',
- '#context' => array('variable' => $variable),
+ '#context' => ['variable' => $variable],
];
return $renderer->render($elements);
});
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php
index 41984d6658a..f0bbb82a86e 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php
@@ -42,7 +42,7 @@ class TwigWhiteListTest extends KernelTestBase {
*/
protected function setUp() {
parent::setUp();
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installEntitySchema('taxonomy_term');
@@ -71,38 +71,38 @@ class TwigWhiteListTest extends KernelTestBase {
$this->term->save();
// Create a field.
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
// Add the term field.
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => 'field_term',
'type' => 'entity_reference',
'entity_type' => 'node',
'cardinality' => 1,
- 'settings' => array(
+ 'settings' => [
'target_type' => 'taxonomy_term',
- ),
- ))->save();
- FieldConfig::create(array(
+ ],
+ ])->save();
+ FieldConfig::create([
'field_name' => 'field_term',
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'Terms',
- 'settings' => array(
+ 'settings' => [
'handler' => 'default',
'handler_settings' => $handler_settings,
- ),
- ))->save();
+ ],
+ ])->save();
// Show on default display and teaser.
entity_get_display('node', 'page', 'default')
- ->setComponent('field_term', array(
+ ->setComponent('field_term', [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
// Boot twig environment.
$this->twig = \Drupal::service('twig');
diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php
index 4a23fbbc96c..05a36ba2e96 100644
--- a/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php
@@ -32,7 +32,7 @@ class AllowedValuesConstraintValidatorTest extends KernelTestBase {
public function testValidation() {
// Create a definition that specifies some AllowedValues.
$definition = DataDefinition::create('integer')
- ->addConstraint('AllowedValues', array(1, 2, 3));
+ ->addConstraint('AllowedValues', [1, 2, 3]);
// Test the validation.
$typed_data = $this->typedData->create($definition, 1);
diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php
index 078cb7a79f8..bbdf10992f3 100644
--- a/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php
@@ -35,19 +35,19 @@ class ComplexDataConstraintValidatorTest extends KernelTestBase {
// Create a definition that specifies some ComplexData constraint.
$definition = MapDataDefinition::create()
->setPropertyDefinition('key', DataDefinition::create('integer'))
- ->addConstraint('ComplexData', array(
- 'key' => array(
- 'AllowedValues' => array(1, 2, 3)
- ),
- ));
+ ->addConstraint('ComplexData', [
+ 'key' => [
+ 'AllowedValues' => [1, 2, 3]
+ ],
+ ]);
// Test the validation.
- $typed_data = $this->typedData->create($definition, array('key' => 1));
+ $typed_data = $this->typedData->create($definition, ['key' => 1]);
$violations = $typed_data->validate();
$this->assertEqual($violations->count(), 0, 'Validation passed for correct value.');
// Test the validation when an invalid value is passed.
- $typed_data = $this->typedData->create($definition, array('key' => 4));
+ $typed_data = $this->typedData->create($definition, ['key' => 4]);
$violations = $typed_data->validate();
$this->assertEqual($violations->count(), 1, 'Validation failed for incorrect value.');
@@ -59,19 +59,19 @@ class ComplexDataConstraintValidatorTest extends KernelTestBase {
// Test using the constraint with a map without the specified key. This
// should be ignored as long as there is no NotNull or NotBlank constraint.
- $typed_data = $this->typedData->create($definition, array('foo' => 'bar'));
+ $typed_data = $this->typedData->create($definition, ['foo' => 'bar']);
$violations = $typed_data->validate();
$this->assertEqual($violations->count(), 0, 'Constraint on non-existing key is ignored.');
$definition = MapDataDefinition::create()
->setPropertyDefinition('key', DataDefinition::create('integer'))
- ->addConstraint('ComplexData', array(
- 'key' => array(
- 'NotNull' => array()
- ),
- ));
+ ->addConstraint('ComplexData', [
+ 'key' => [
+ 'NotNull' => []
+ ],
+ ]);
- $typed_data = $this->typedData->create($definition, array('foo' => 'bar'));
+ $typed_data = $this->typedData->create($definition, ['foo' => 'bar']);
$violations = $typed_data->validate();
$this->assertEqual($violations->count(), 1, 'Key is required.');
}
diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php
index 4ff9ff6da10..8aeab575e92 100644
--- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php
@@ -66,7 +66,7 @@ class TypedDataDefinitionTest extends KernelTestBase {
$this->assertTrue($map_definition instanceof ComplexDataDefinitionInterface);
// Test retrieving metadata about contained properties.
- $this->assertEqual(array_keys($map_definition->getPropertyDefinitions()), array('one', 'two', 'three'));
+ $this->assertEqual(array_keys($map_definition->getPropertyDefinitions()), ['one', 'two', 'three']);
$this->assertEqual($map_definition->getPropertyDefinition('one')->getDataType(), 'string');
$this->assertNull($map_definition->getMainPropertyName());
$this->assertNull($map_definition->getPropertyDefinition('invalid'));
diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
index 08f27b36894..c79f2cfc9f4 100644
--- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
+++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
@@ -38,7 +38,7 @@ class TypedDataTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'field', 'file', 'user');
+ public static $modules = ['system', 'field', 'file', 'user'];
protected function setUp() {
parent::setup();
@@ -66,7 +66,7 @@ class TypedDataTest extends KernelTestBase {
*/
public function testGetAndSet() {
// Boolean type.
- $typed_data = $this->createTypedData(array('type' => 'boolean'), TRUE);
+ $typed_data = $this->createTypedData(['type' => 'boolean'], TRUE);
$this->assertTrue($typed_data instanceof BooleanInterface, 'Typed data object is an instance of BooleanInterface.');
$this->assertTrue($typed_data->getValue() === TRUE, 'Boolean value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -82,7 +82,7 @@ class TypedDataTest extends KernelTestBase {
// String type.
$value = $this->randomString();
- $typed_data = $this->createTypedData(array('type' => 'string'), $value);
+ $typed_data = $this->createTypedData(['type' => 'string'], $value);
$this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.');
$this->assertTrue($typed_data->getValue() === $value, 'String value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -95,12 +95,12 @@ class TypedDataTest extends KernelTestBase {
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'String wrapper is null-able.');
$this->assertEqual($typed_data->validate()->count(), 0);
- $typed_data->setValue(array('no string'));
+ $typed_data->setValue(['no string']);
$this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.');
// Integer type.
$value = rand();
- $typed_data = $this->createTypedData(array('type' => 'integer'), $value);
+ $typed_data = $this->createTypedData(['type' => 'integer'], $value);
$this->assertTrue($typed_data instanceof IntegerInterface, 'Typed data object is an instance of IntegerInterface.');
$this->assertTrue($typed_data->getValue() === $value, 'Integer value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -117,7 +117,7 @@ class TypedDataTest extends KernelTestBase {
// Float type.
$value = 123.45;
- $typed_data = $this->createTypedData(array('type' => 'float'), $value);
+ $typed_data = $this->createTypedData(['type' => 'float'], $value);
$this->assertTrue($typed_data instanceof FloatInterface, 'Typed data object is an instance of FloatInterface.');
$this->assertTrue($typed_data->getValue() === $value, 'Float value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -134,7 +134,7 @@ class TypedDataTest extends KernelTestBase {
// Date Time type.
$value = '2014-01-01T20:00:00+00:00';
- $typed_data = $this->createTypedData(array('type' => 'datetime_iso8601'), $value);
+ $typed_data = $this->createTypedData(['type' => 'datetime_iso8601'], $value);
$this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.');
$this->assertTrue($typed_data->getValue() == $value, 'Date value was fetched.');
$this->assertEqual($typed_data->getValue(), $typed_data->getDateTime()->format('c'), 'Value representation of a date is ISO 8601');
@@ -151,7 +151,7 @@ class TypedDataTest extends KernelTestBase {
$typed_data->setValue('invalid');
$this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.');
// Check implementation of DateTimeInterface.
- $typed_data = $this->createTypedData(array('type' => 'datetime_iso8601'), '2014-01-01T20:00:00+00:00');
+ $typed_data = $this->createTypedData(['type' => 'datetime_iso8601'], '2014-01-01T20:00:00+00:00');
$this->assertTrue($typed_data->getDateTime() instanceof DrupalDateTime);
$typed_data->setDateTime(new DrupalDateTime('2014-01-02T20:00:00+00:00'));
$this->assertEqual($typed_data->getValue(), '2014-01-02T20:00:00+00:00');
@@ -160,7 +160,7 @@ class TypedDataTest extends KernelTestBase {
// Timestamp type.
$value = REQUEST_TIME;
- $typed_data = $this->createTypedData(array('type' => 'timestamp'), $value);
+ $typed_data = $this->createTypedData(['type' => 'timestamp'], $value);
$this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.');
$this->assertTrue($typed_data->getValue() == $value, 'Timestamp value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -174,7 +174,7 @@ class TypedDataTest extends KernelTestBase {
$typed_data->setValue('invalid');
$this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.');
// Check implementation of DateTimeInterface.
- $typed_data = $this->createTypedData(array('type' => 'timestamp'), REQUEST_TIME);
+ $typed_data = $this->createTypedData(['type' => 'timestamp'], REQUEST_TIME);
$this->assertTrue($typed_data->getDateTime() instanceof DrupalDateTime);
$typed_data->setDateTime(DrupalDateTime::createFromTimestamp(REQUEST_TIME + 1));
$this->assertEqual($typed_data->getValue(), REQUEST_TIME + 1);
@@ -183,7 +183,7 @@ class TypedDataTest extends KernelTestBase {
// DurationIso8601 type.
$value = 'PT20S';
- $typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), $value);
+ $typed_data = $this->createTypedData(['type' => 'duration_iso8601'], $value);
$this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.');
$this->assertIdentical($typed_data->getValue(), $value, 'DurationIso8601 value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -197,7 +197,7 @@ class TypedDataTest extends KernelTestBase {
$typed_data->setValue('invalid');
$this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.');
// Check implementation of DurationInterface.
- $typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), 'PT20S');
+ $typed_data = $this->createTypedData(['type' => 'duration_iso8601'], 'PT20S');
$this->assertTrue($typed_data->getDuration() instanceof \DateInterval);
$typed_data->setDuration(new \DateInterval('P40D'));
// @todo: Should we make this "nicer"?
@@ -207,7 +207,7 @@ class TypedDataTest extends KernelTestBase {
// Time span type.
$value = 20;
- $typed_data = $this->createTypedData(array('type' => 'timespan'), $value);
+ $typed_data = $this->createTypedData(['type' => 'timespan'], $value);
$this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.');
$this->assertIdentical($typed_data->getValue(), $value, 'Time span value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -221,7 +221,7 @@ class TypedDataTest extends KernelTestBase {
$typed_data->setValue('invalid');
$this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.');
// Check implementation of DurationInterface.
- $typed_data = $this->createTypedData(array('type' => 'timespan'), 20);
+ $typed_data = $this->createTypedData(['type' => 'timespan'], 20);
$this->assertTrue($typed_data->getDuration() instanceof \DateInterval);
$typed_data->setDuration(new \DateInterval('PT4H'));
$this->assertEqual($typed_data->getValue(), 60 * 60 * 4);
@@ -230,7 +230,7 @@ class TypedDataTest extends KernelTestBase {
// URI type.
$uri = 'http://example.com/foo/';
- $typed_data = $this->createTypedData(array('type' => 'uri'), $uri);
+ $typed_data = $this->createTypedData(['type' => 'uri'], $uri);
$this->assertTrue($typed_data instanceof UriInterface, 'Typed data object is an instance of UriInterface.');
$this->assertTrue($typed_data->getValue() === $uri, 'URI value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -247,7 +247,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->validate()->count(), 0, 'Filename with spaces is valid.');
// Generate some files that will be used to test the binary data type.
- $files = array();
+ $files = [];
for ($i = 0; $i < 3; $i++) {
$path = "public://example_$i.png";
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', $path);
@@ -258,7 +258,7 @@ class TypedDataTest extends KernelTestBase {
// Email type.
$value = $this->randomString();
- $typed_data = $this->createTypedData(array('type' => 'email'), $value);
+ $typed_data = $this->createTypedData(['type' => 'email'], $value);
$this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.');
$this->assertIdentical($typed_data->getValue(), $value, 'Email value was fetched.');
$new_value = 'test@example.com';
@@ -273,7 +273,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.');
// Binary type.
- $typed_data = $this->createTypedData(array('type' => 'binary'), $files[0]->getFileUri());
+ $typed_data = $this->createTypedData(['type' => 'binary'], $files[0]->getFileUri());
$this->assertTrue($typed_data instanceof BinaryInterface, 'Typed data object is an instance of BinaryInterface.');
$this->assertTrue(is_resource($typed_data->getValue()), 'Binary value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
@@ -294,8 +294,8 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.');
// Any type.
- $value = array('foo');
- $typed_data = $this->createTypedData(array('type' => 'any'), $value);
+ $value = ['foo'];
+ $typed_data = $this->createTypedData(['type' => 'any'], $value);
$this->assertIdentical($typed_data->getValue(), $value, 'Any value was fetched.');
$new_value = 'test@example.com';
$typed_data->setValue($new_value);
@@ -307,9 +307,9 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->validate()->count(), 0);
// We cannot test invalid values as everything is valid for the any type,
// but make sure an array or object value passes validation also.
- $typed_data->setValue(array('entry'));
+ $typed_data->setValue(['entry']);
$this->assertEqual($typed_data->validate()->count(), 0);
- $typed_data->setValue((object) array('entry'));
+ $typed_data->setValue((object) ['entry']);
$this->assertEqual($typed_data->validate()->count(), 0);
}
@@ -318,7 +318,7 @@ class TypedDataTest extends KernelTestBase {
*/
public function testTypedDataLists() {
// Test working with an existing list of strings.
- $value = array('one', 'two', 'three');
+ $value = ['one', 'two', 'three'];
$typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value);
$this->assertEqual($typed_data->getValue(), $value, 'List value has been set.');
// Test iterating.
@@ -347,14 +347,14 @@ class TypedDataTest extends KernelTestBase {
$clone = clone $typed_data;
$this->assertTrue($typed_data->getValue() === $clone->getValue());
$this->assertTrue($typed_data[0] !== $clone[0]);
- $clone->setValue(array());
+ $clone->setValue([]);
$this->assertTrue($clone->isEmpty());
// Make sure that resetting the value using NULL results in an empty array.
- $clone->setValue(array());
+ $clone->setValue([]);
$typed_data->setValue(NULL);
- $this->assertIdentical($typed_data->getValue(), array());
- $this->assertIdentical($clone->getValue(), array());
+ $this->assertIdentical($typed_data->getValue(), []);
+ $this->assertIdentical($clone->getValue(), []);
// Test dealing with NULL items.
$typed_data[] = NULL;
@@ -367,7 +367,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertFalse($typed_data->isEmpty());
$this->assertEqual(count($typed_data), 3);
- $this->assertEqual($typed_data->getValue(), array(NULL, '', 'three'));
+ $this->assertEqual($typed_data->getValue(), [NULL, '', 'three']);
// Test unsetting.
unset($typed_data[1]);
$this->assertEqual(count($typed_data), 2);
@@ -379,7 +379,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual(count($typed_data), 2);
// Test setting the list with less values.
- $typed_data->setValue(array('one'));
+ $typed_data->setValue(['one']);
$this->assertEqual($typed_data->count(), 1);
// Test setting invalid values.
@@ -397,7 +397,7 @@ class TypedDataTest extends KernelTestBase {
*/
public function testTypedDataListsFilter() {
// Check that an all-pass filter leaves the list untouched.
- $value = array('zero', 'one');
+ $value = ['zero', 'one'];
$typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value);
$typed_data->filter(function(TypedDataInterface $item) {
return TRUE;
@@ -409,7 +409,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data[1]->getName(), 1);
// Check that a none-pass filter empties the list.
- $value = array('zero', 'one');
+ $value = ['zero', 'one'];
$typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value);
$typed_data->filter(function(TypedDataInterface $item) {
return FALSE;
@@ -417,7 +417,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->count(), 0);
// Check that filtering correctly renumbers elements.
- $value = array('zero', 'one', 'two');
+ $value = ['zero', 'one', 'two'];
$typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value);
$typed_data->filter(function(TypedDataInterface $item) {
return $item->getValue() !== 'one';
@@ -434,11 +434,11 @@ class TypedDataTest extends KernelTestBase {
*/
public function testTypedDataMaps() {
// Test working with a simple map.
- $value = array(
+ $value = [
'one' => 'eins',
'two' => 'zwei',
'three' => 'drei',
- );
+ ];
$definition = MapDataDefinition::create()
->setPropertyDefinition('one', DataDefinition::create('string'))
->setPropertyDefinition('two', DataDefinition::create('string'))
@@ -467,11 +467,11 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->get('one')->getValue(), 'uno');
// Make sure the update is reflected in the value of the map also.
$value = $typed_data->getValue();
- $this->assertEqual($value, array(
+ $this->assertEqual($value, [
'one' => 'uno',
'two' => 'zwei',
'three' => 'drei'
- ));
+ ]);
$properties = $typed_data->getProperties();
$this->assertEqual(array_keys($properties), array_keys($value));
@@ -479,12 +479,12 @@ class TypedDataTest extends KernelTestBase {
// Test setting a not defined property. It shouldn't show up in the
// properties, but be kept in the values.
- $typed_data->setValue(array('foo' => 'bar'));
- $this->assertEqual(array_keys($typed_data->getProperties()), array('one', 'two', 'three'));
- $this->assertEqual(array_keys($typed_data->getValue()), array('foo', 'one', 'two', 'three'));
+ $typed_data->setValue(['foo' => 'bar']);
+ $this->assertEqual(array_keys($typed_data->getProperties()), ['one', 'two', 'three']);
+ $this->assertEqual(array_keys($typed_data->getValue()), ['foo', 'one', 'two', 'three']);
// Test getting the string representation.
- $typed_data->setValue(array('one' => 'eins', 'two' => '', 'three' => 'drei'));
+ $typed_data->setValue(['one' => 'eins', 'two' => '', 'three' => 'drei']);
$this->assertEqual($typed_data->getString(), 'eins, drei');
// Test isEmpty and cloning.
@@ -492,14 +492,14 @@ class TypedDataTest extends KernelTestBase {
$clone = clone $typed_data;
$this->assertTrue($typed_data->getValue() === $clone->getValue());
$this->assertTrue($typed_data->get('one') !== $clone->get('one'));
- $clone->setValue(array());
+ $clone->setValue([]);
$this->assertTrue($clone->isEmpty());
// Make sure the difference between NULL (not set) and an empty array is
// kept.
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue());
- $typed_data->setValue(array());
+ $typed_data->setValue([]);
$value = $typed_data->getValue();
$this->assertTrue(isset($value) && is_array($value));
@@ -535,9 +535,9 @@ class TypedDataTest extends KernelTestBase {
*/
public function testTypedDataValidation() {
$definition = DataDefinition::create('integer')
- ->setConstraints(array(
- 'Range' => array('min' => 5),
- ));
+ ->setConstraints([
+ 'Range' => ['min' => 5],
+ ]);
$violations = $this->typedDataManager->create($definition, 10)->validate();
$this->assertEqual($violations->count(), 0);
@@ -546,27 +546,27 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($violations->count(), 1);
// Test translating violation messages.
- $message = t('This value should be %limit or more.', array('%limit' => 5));
+ $message = t('This value should be %limit or more.', ['%limit' => 5]);
$this->assertEqual($violations[0]->getMessage(), $message, 'Translated violation message retrieved.');
$this->assertEqual($violations[0]->getPropertyPath(), '');
$this->assertIdentical($violations[0]->getRoot(), $integer, 'Root object returned.');
// Test translating violation messages when pluralization is used.
$definition = DataDefinition::create('string')
- ->setConstraints(array(
- 'Length' => array('min' => 10),
- ));
+ ->setConstraints([
+ 'Length' => ['min' => 10],
+ ]);
$violations = $this->typedDataManager->create($definition, "short")->validate();
$this->assertEqual($violations->count(), 1);
- $message = t('This value is too short. It should have %limit characters or more.', array('%limit' => 10));
+ $message = t('This value is too short. It should have %limit characters or more.', ['%limit' => 10]);
$this->assertEqual($violations[0]->getMessage(), $message, 'Translated violation message retrieved.');
// Test having multiple violations.
$definition = DataDefinition::create('integer')
- ->setConstraints(array(
- 'Range' => array('min' => 5),
- 'Null' => array(),
- ));
+ ->setConstraints([
+ 'Range' => ['min' => 5],
+ 'Null' => [],
+ ]);
$violations = $this->typedDataManager->create($definition, 10)->validate();
$this->assertEqual($violations->count(), 1);
$violations = $this->typedDataManager->create($definition, 1)->validate();
@@ -575,12 +575,12 @@ class TypedDataTest extends KernelTestBase {
// Test validating property containers and make sure the NotNull and Null
// constraints work with typed data containers.
$definition = BaseFieldDefinition::create('integer')
- ->setConstraints(array('NotNull' => array()));
- $field_item = $this->typedDataManager->create($definition, array('value' => 10));
+ ->setConstraints(['NotNull' => []]);
+ $field_item = $this->typedDataManager->create($definition, ['value' => 10]);
$violations = $field_item->validate();
$this->assertEqual($violations->count(), 0);
- $field_item = $this->typedDataManager->create($definition, array('value' => 'no integer'));
+ $field_item = $this->typedDataManager->create($definition, ['value' => 'no integer']);
$violations = $field_item->validate();
$this->assertEqual($violations->count(), 1);
$this->assertEqual($violations[0]->getPropertyPath(), '0.value');
@@ -592,8 +592,8 @@ class TypedDataTest extends KernelTestBase {
// Test the Null constraint with typed data containers.
$definition = BaseFieldDefinition::create('float')
- ->setConstraints(array('Null' => array()));
- $field_item = $this->typedDataManager->create($definition, array('value' => 11.5));
+ ->setConstraints(['Null' => []]);
+ $field_item = $this->typedDataManager->create($definition, ['value' => 11.5]);
$violations = $field_item->validate();
$this->assertEqual($violations->count(), 1);
$field_item = $this->typedDataManager->create($definition);
@@ -622,9 +622,9 @@ class TypedDataTest extends KernelTestBase {
// Test validating a list of a values and make sure property paths starting
// with "0" are created.
$definition = BaseFieldDefinition::create('integer');
- $violations = $this->typedDataManager->create($definition, array(array('value' => 10)))->validate();
+ $violations = $this->typedDataManager->create($definition, [['value' => 10]])->validate();
$this->assertEqual($violations->count(), 0);
- $violations = $this->typedDataManager->create($definition, array(array('value' => 'string')))->validate();
+ $violations = $this->typedDataManager->create($definition, [['value' => 'string']])->validate();
$this->assertEqual($violations->count(), 1);
$this->assertEqual($violations[0]->getInvalidValue(), 'string');
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 9f6b975d8e8..5621d4aa192 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -147,7 +147,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
*
* @var array
*/
- protected static $modules = array();
+ protected static $modules = [];
/**
* The virtual filesystem root directory.
@@ -193,7 +193,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
*
* @var string[]
*/
- protected static $configSchemaCheckerExclusions = array(
+ protected static $configSchemaCheckerExclusions = [
// Following are used to test lack of or partial schema. Where partial
// schema is provided, that is explicitly tested in specific tests.
'config_schema_test.noschema',
@@ -202,7 +202,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
'config_schema_test.no_schema_data_types',
// Used to test application of schema to filtering of configuration.
'config_test.dynamic.system',
- );
+ ];
/**
* {@inheritdoc}
@@ -245,7 +245,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
* @internal
*/
protected function bootEnvironment() {
- $this->streamWrappers = array();
+ $this->streamWrappers = [];
\Drupal::unsetContainer();
$this->classLoader = require $this->root . '/autoload.php';
@@ -263,13 +263,13 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
$this->databasePrefix = $test_db->getDatabasePrefix();
drupal_valid_test_ua($this->databasePrefix);
- $settings = array(
+ $settings = [
'hash_salt' => get_class($this),
'file_public_path' => $this->siteDirectory . '/files',
// Disable Twig template caching/dumping.
'twig_cache' => FALSE,
// @see \Drupal\KernelTests\KernelTestBase::register()
- );
+ ];
new Settings($settings);
$this->setUpFilesystem();
@@ -298,9 +298,9 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
$settings['file_public_path'] = $this->siteDirectory . '/files';
new Settings($settings);
- $GLOBALS['config_directories'] = array(
+ $GLOBALS['config_directories'] = [
CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync',
- );
+ ];
}
/**
@@ -389,11 +389,11 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
// Write the core.extension configuration.
// Required for ConfigInstaller::installDefaultConfig() to work.
- $this->container->get('config.storage')->write('core.extension', array(
+ $this->container->get('config.storage')->write('core.extension', [
'module' => array_fill_keys($modules, 0),
- 'theme' => array(),
+ 'theme' => [],
'profile' => '',
- ));
+ ]);
$settings = Settings::getAll();
$settings['php_storage']['default'] = [
@@ -456,9 +456,9 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
foreach ($connection_info as $target => $value) {
// Replace the full table prefix definition to ensure that no table
// prefixes of the test runner leak into the test.
- $connection_info[$target]['prefix'] = array(
+ $connection_info[$target]['prefix'] = [
'default' => $value['prefix']['default'] . $this->databasePrefix,
- );
+ ];
}
}
return $connection_info;
@@ -563,9 +563,9 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
* @see \Drupal\Core\Extension\ModuleHandler::add()
*/
private function getExtensionsForModules(array $modules) {
- $extensions = array();
+ $extensions = [];
$discovery = new ExtensionDiscovery($this->root);
- $discovery->setProfileDirectories(array());
+ $discovery->setProfileDirectories([]);
$list = $discovery->scan('module');
foreach ($modules as $name) {
if (!isset($list[$name])) {
@@ -628,7 +628,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
if ($container->hasDefinition('password')) {
$container->getDefinition('password')
- ->setArguments(array(1));
+ ->setArguments([1]);
}
TestServiceProvider::addRouteProvider($container);
}
@@ -706,7 +706,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
// Free up memory: Custom test class properties.
// Note: Private properties cannot be cleaned up.
$rc = new \ReflectionClass(__CLASS__);
- $blacklist = array();
+ $blacklist = [];
foreach ($rc->getProperties() as $property) {
$blacklist[$property->name] = $property->getDeclaringClass()->name;
}
@@ -726,7 +726,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
}
\Drupal::unsetContainer();
$this->container = NULL;
- new Settings(array());
+ new Settings([]);
parent::tearDown();
}
@@ -829,18 +829,18 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
$all_tables_exist = TRUE;
foreach ($tables as $table) {
if (!$db_schema->tableExists($table)) {
- $this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', array(
+ $this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', [
'%entity_type' => $entity_type_id,
'%table' => $table,
- )));
+ ]));
$all_tables_exist = FALSE;
}
}
if ($all_tables_exist) {
- $this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', array(
+ $this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', [
'%entity_type' => $entity_type_id,
'%tables' => '{' . implode('}, {', $tables) . '}',
- )));
+ ]));
}
}
}
@@ -1027,7 +1027,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
* @return array
*/
private static function getModulesToEnable($class) {
- $modules = array();
+ $modules = [];
while ($class) {
if (property_exists($class, 'modules')) {
// Only add the modules, if the $modules property was not inherited.
@@ -1059,11 +1059,11 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
// @see /core/tests/bootstrap.php
$bootstrap_globals .= '$namespaces = ' . var_export($GLOBALS['namespaces'], TRUE) . ";\n";
- $template->setVar(array(
+ $template->setVar([
'constants' => '',
'included_files' => '',
'globals' => $bootstrap_globals,
- ));
+ ]);
}
/**
@@ -1086,12 +1086,12 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.2.0.
*/
public function __get($name) {
- if (in_array($name, array(
+ if (in_array($name, [
'public_files_directory',
'private_files_directory',
'temp_files_directory',
'translation_files_directory',
- ))) {
+ ])) {
// @comment it in again.
trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use the regular API method to retrieve it instead (e.g., Settings).", $name), E_USER_DEPRECATED);
switch ($name) {
@@ -1111,12 +1111,12 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
if ($name === 'configDirectories') {
trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name), E_USER_DEPRECATED);
- return array(
+ return [
CONFIG_SYNC_DIRECTORY => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
- );
+ ];
}
- $denied = array(
+ $denied = [
// @see \Drupal\simpletest\TestBase
'testId',
'timeLimit',
@@ -1134,7 +1134,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
'generatedTestFiles',
// Properties from the old KernelTestBase class that has been removed.
'keyValueFactory',
- );
+ ];
if (in_array($name, $denied) || strpos($name, 'original') === 0) {
throw new \RuntimeException(sprintf('TestBase::$%s property no longer exists', $name));
}
diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
index 469debed27d..7d89fd7bd89 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
@@ -27,21 +27,21 @@ class KernelTestBaseTest extends KernelTestBase {
public function testBootEnvironment() {
$this->assertRegExp('/^test\d{8}$/', $this->databasePrefix);
$this->assertStringStartsWith('vfs://root/sites/simpletest/', $this->siteDirectory);
- $this->assertEquals(array(
- 'root' => array(
- 'sites' => array(
- 'simpletest' => array(
- substr($this->databasePrefix, 4) => array(
- 'files' => array(
- 'config' => array(
- 'sync' => array(),
- ),
- ),
- ),
- ),
- ),
- ),
- ), vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure());
+ $this->assertEquals([
+ 'root' => [
+ 'sites' => [
+ 'simpletest' => [
+ substr($this->databasePrefix, 4) => [
+ 'files' => [
+ 'config' => [
+ 'sync' => [],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ], vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure());
}
/**
@@ -70,15 +70,15 @@ class KernelTestBaseTest extends KernelTestBase {
$this->assertArrayHasKey('destroy-me', $GLOBALS);
$database = $this->container->get('database');
- $database->schema()->createTable('foo', array(
- 'fields' => array(
- 'number' => array(
+ $database->schema()->createTable('foo', [
+ 'fields' => [
+ 'number' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->assertTrue($database->schema()->tableExists('foo'));
// Ensure that the database tasks have been run during set up. Neither MySQL
@@ -120,7 +120,7 @@ class KernelTestBaseTest extends KernelTestBase {
$this->assertSame($request, \Drupal::request());
// Trigger a container rebuild.
- $this->enableModules(array('system'));
+ $this->enableModules(['system']);
// Verify that this container is identical to the actual container.
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $this->container);
@@ -165,16 +165,16 @@ class KernelTestBaseTest extends KernelTestBase {
$element_info = $this->container->get('element_info');
$this->assertSame(['#defaults_loaded' => TRUE], $element_info->getInfo($type));
- $this->enableModules(array('filter'));
+ $this->enableModules(['filter']);
$this->assertNotSame($element_info, $this->container->get('element_info'));
$this->assertNotEmpty($this->container->get('element_info')->getInfo($type));
- $build = array(
+ $build = [
'#type' => 'html_tag',
'#tag' => 'h3',
'#value' => 'Inner',
- );
+ ];
$expected = "<h3>Inner</h3>\n";
$this->assertEquals('core', \Drupal::theme()->getActiveTheme()->getName());
@@ -189,12 +189,12 @@ class KernelTestBaseTest extends KernelTestBase {
* @covers ::render
*/
public function testRenderWithTheme() {
- $this->enableModules(array('system'));
+ $this->enableModules(['system']);
- $build = array(
+ $build = [
'#type' => 'textfield',
'#name' => 'test',
- );
+ ];
$expected = '/' . preg_quote('<input type="text" name="test"', '/') . '/';
$this->assertArrayNotHasKey('theme', $GLOBALS);
@@ -220,11 +220,11 @@ class KernelTestBaseTest extends KernelTestBase {
$this->assertTrue(empty($tables), 'All test tables have been removed.');
}
else {
- $result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", array(
+ $result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [
':type' => 'table',
':table_name' => '%',
':pattern' => 'sqlite_%',
- ))->fetchAllKeyed(0, 0);
+ ])->fetchAllKeyed(0, 0);
$this->assertTrue(empty($result), 'All test tables have been removed.');
}
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index d4968f44b2d..754f9d9838f 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -493,7 +493,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
}
// Delete test site directory.
- file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback'));
+ file_unmanaged_delete_recursive($this->siteDirectory, [$this, 'filePreDeleteCallback']);
}
/**
@@ -572,7 +572,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
* @return string
* An absolute URL stsring.
*/
- protected function buildUrl($path, array $options = array()) {
+ protected function buildUrl($path, array $options = []) {
if ($path instanceof Url) {
$url_options = $path->getOptions();
$options = $url_options + $options;
@@ -620,7 +620,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
* @return string
* The retrieved HTML string, also available as $this->getRawContent()
*/
- protected function drupalGet($path, array $options = array(), array $headers = array()) {
+ protected function drupalGet($path, array $options = [], array $headers = []) {
$options['absolute'] = TRUE;
$url = $this->buildUrl($path, $options);
@@ -715,14 +715,14 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
$this->drupalGet('user/login');
$this->assertSession()->statusCodeEquals(200);
- $this->submitForm(array(
+ $this->submitForm([
'name' => $account->getUsername(),
'pass' => $account->passRaw,
- ), t('Log in'));
+ ], t('Log in'));
// @see BrowserTestBase::drupalUserIsLoggedIn()
$account->sessionId = $this->getSession()->getCookie($this->getSessionName());
- $this->assertTrue($this->drupalUserIsLoggedIn($account), new FormattableMarkup('User %name successfully logged in.', array('%name' => $account->getAccountName())));
+ $this->assertTrue($this->drupalUserIsLoggedIn($account), new FormattableMarkup('User %name successfully logged in.', ['%name' => $account->getAccountName()]));
$this->loggedInUser = $account;
$this->container->get('current_user')->setAccount($account);
@@ -738,7 +738,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
// idea being if you were properly logged out you should be seeing a login
// screen.
$assert_session = $this->assertSession();
- $this->drupalGet('user/logout', array('query' => array('destination' => 'user')));
+ $this->drupalGet('user/logout', ['query' => ['destination' => 'user']]);
$assert_session->statusCodeEquals(200);
$assert_session->fieldExists('name');
$assert_session->fieldExists('pass');
@@ -893,7 +893,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
* @param array $options
* Options to be forwarded to the url generator.
*/
- protected function drupalPostForm($path, $edit, $submit, array $options = array()) {
+ protected function drupalPostForm($path, $edit, $submit, array $options = []) {
if (is_object($submit)) {
// Cast MarkupInterface objects to string.
$submit = (string) $submit;
@@ -965,35 +965,35 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
unset($connection_info['default']['namespace']);
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
- $parameters = array(
+ $parameters = [
'interactive' => FALSE,
- 'parameters' => array(
+ 'parameters' => [
'profile' => $this->profile,
'langcode' => 'en',
- ),
- 'forms' => array(
- 'install_settings_form' => array(
+ ],
+ 'forms' => [
+ 'install_settings_form' => [
'driver' => $driver,
$driver => $connection_info['default'],
- ),
- 'install_configure_form' => array(
+ ],
+ 'install_configure_form' => [
'site_name' => 'Drupal',
'site_mail' => 'simpletest@example.com',
- 'account' => array(
+ 'account' => [
'name' => $this->rootUser->name,
'mail' => $this->rootUser->getEmail(),
- 'pass' => array(
+ 'pass' => [
'pass1' => $this->rootUser->pass_raw,
'pass2' => $this->rootUser->pass_raw,
- ),
- ),
+ ],
+ ],
// form_type_checkboxes_value() requires NULL instead of FALSE values
// for programmatic form submissions to disable a checkbox.
'enable_update_status_module' => NULL,
'enable_update_status_emails' => NULL,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $parameters;
}
@@ -1063,10 +1063,10 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
drupal_valid_test_ua($this->databasePrefix);
// Reset settings.
- new Settings(array(
+ new Settings([
// For performance, simply use the database prefix as hash salt.
'hash_salt' => $this->databasePrefix,
- ));
+ ]);
drupal_set_time_limit($this->timeLimit);
diff --git a/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php b/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php
index 9efbf4ecc5d..c14bdfb3e59 100644
--- a/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php
@@ -80,41 +80,41 @@ class ZfExtensionManagerSfContainerTest extends UnitTestCase {
* array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => '')
*/
public function canonicalizeNameProvider() {
- return array(
- array(
+ return [
+ [
'foobar',
'foobar',
- ),
- array(
+ ],
+ [
'foo-bar',
'foobar',
- ),
- array(
+ ],
+ [
'foo_bar',
'foobar',
- ),
- array(
+ ],
+ [
'foo bar',
'foobar',
- ),
- array(
+ ],
+ [
'foo\\bar',
'foobar',
- ),
- array(
+ ],
+ [
'foo/bar',
'foobar',
- ),
+ ],
// There is also a strtolower in canonicalizeName.
- array(
+ [
'Foo/bAr',
'foobar',
- ),
- array(
+ ],
+ [
'foo/-_\\ bar',
'foobar',
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
index ddbcf6a119d..95fdd64d182 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
@@ -293,21 +293,21 @@ class DateTimePlusTest extends UnitTestCase {
* @see DateTimePlusTest::testDates()
*/
public function providerTestDates() {
- return array(
+ return [
// String input.
// Create date object from datetime string.
- array('2009-03-07 10:30', 'America/Chicago', '2009-03-07T10:30:00-06:00'),
+ ['2009-03-07 10:30', 'America/Chicago', '2009-03-07T10:30:00-06:00'],
// Same during daylight savings time.
- array('2009-06-07 10:30', 'America/Chicago', '2009-06-07T10:30:00-05:00'),
+ ['2009-06-07 10:30', 'America/Chicago', '2009-06-07T10:30:00-05:00'],
// Create date object from date string.
- array('2009-03-07', 'America/Chicago', '2009-03-07T00:00:00-06:00'),
+ ['2009-03-07', 'America/Chicago', '2009-03-07T00:00:00-06:00'],
// Same during daylight savings time.
- array('2009-06-07', 'America/Chicago', '2009-06-07T00:00:00-05:00'),
+ ['2009-06-07', 'America/Chicago', '2009-06-07T00:00:00-05:00'],
// Create date object from date string.
- array('2009-03-07 10:30', 'Australia/Canberra', '2009-03-07T10:30:00+11:00'),
+ ['2009-03-07 10:30', 'Australia/Canberra', '2009-03-07T10:30:00+11:00'],
// Same during daylight savings time.
- array('2009-06-07 10:30', 'Australia/Canberra', '2009-06-07T10:30:00+10:00'),
- );
+ ['2009-06-07 10:30', 'Australia/Canberra', '2009-06-07T10:30:00+10:00'],
+ ];
}
/**
@@ -320,17 +320,17 @@ class DateTimePlusTest extends UnitTestCase {
* @see DateTimePlusTest::testDates()
*/
public function providerTestDateArrays() {
- return array(
+ return [
// Array input.
// Create date object from date array, date only.
- array(array('year' => 2010, 'month' => 2, 'day' => 28), 'America/Chicago', '2010-02-28T00:00:00-06:00'),
+ [['year' => 2010, 'month' => 2, 'day' => 28], 'America/Chicago', '2010-02-28T00:00:00-06:00'],
// Create date object from date array with hour.
- array(array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10), 'America/Chicago', '2010-02-28T10:00:00-06:00'),
+ [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10], 'America/Chicago', '2010-02-28T10:00:00-06:00'],
// Create date object from date array, date only.
- array(array('year' => 2010, 'month' => 2, 'day' => 28), 'Europe/Berlin', '2010-02-28T00:00:00+01:00'),
+ [['year' => 2010, 'month' => 2, 'day' => 28], 'Europe/Berlin', '2010-02-28T00:00:00+01:00'],
// Create date object from date array with hour.
- array(array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10), 'Europe/Berlin', '2010-02-28T10:00:00+01:00'),
- );
+ [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10], 'Europe/Berlin', '2010-02-28T10:00:00+01:00'],
+ ];
}
/**
@@ -347,16 +347,16 @@ class DateTimePlusTest extends UnitTestCase {
* @see testDateFormats()
*/
public function providerTestDateFormat() {
- return array(
+ return [
// Create a year-only date.
- array('2009', NULL, 'Y', 'Y', '2009'),
+ ['2009', NULL, 'Y', 'Y', '2009'],
// Create a month and year-only date.
- array('2009-10', NULL, 'Y-m', 'Y-m', '2009-10'),
+ ['2009-10', NULL, 'Y-m', 'Y-m', '2009-10'],
// Create a time-only date.
- array('T10:30:00', NULL, '\TH:i:s', 'H:i:s', '10:30:00'),
+ ['T10:30:00', NULL, '\TH:i:s', 'H:i:s', '10:30:00'],
// Create a time-only date.
- array('10:30:00', NULL, 'H:i:s', 'H:i:s', '10:30:00'),
- );
+ ['10:30:00', NULL, 'H:i:s', 'H:i:s', '10:30:00'],
+ ];
}
/**
@@ -372,20 +372,20 @@ class DateTimePlusTest extends UnitTestCase {
* @see testInvalidDates
*/
public function providerTestInvalidDates() {
- return array(
+ return [
// Test for invalid month names when we are using a short version
// of the month.
- array('23 abc 2012', NULL, 'd M Y', "23 abc 2012 contains an invalid month name and did not produce errors.", \InvalidArgumentException::class),
+ ['23 abc 2012', NULL, 'd M Y', "23 abc 2012 contains an invalid month name and did not produce errors.", \InvalidArgumentException::class],
// Test for invalid hour.
- array('0000-00-00T45:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-00T45:30:00 contains an invalid hour and did not produce errors.", \UnexpectedValueException::class),
+ ['0000-00-00T45:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-00T45:30:00 contains an invalid hour and did not produce errors.", \UnexpectedValueException::class],
// Test for invalid day.
- array('0000-00-99T05:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-99T05:30:00 contains an invalid day and did not produce errors.", \UnexpectedValueException::class),
+ ['0000-00-99T05:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-99T05:30:00 contains an invalid day and did not produce errors.", \UnexpectedValueException::class],
// Test for invalid month.
- array('0000-75-00T15:30:00', NULL, 'Y-m-d\TH:i:s', "0000-75-00T15:30:00 contains an invalid month and did not produce errors.", \UnexpectedValueException::class),
+ ['0000-75-00T15:30:00', NULL, 'Y-m-d\TH:i:s', "0000-75-00T15:30:00 contains an invalid month and did not produce errors.", \UnexpectedValueException::class],
// Test for invalid year.
- array('11-08-01T15:30:00', NULL, 'Y-m-d\TH:i:s', "11-08-01T15:30:00 contains an invalid year and did not produce errors.", \UnexpectedValueException::class),
+ ['11-08-01T15:30:00', NULL, 'Y-m-d\TH:i:s', "11-08-01T15:30:00 contains an invalid year and did not produce errors.", \UnexpectedValueException::class],
- );
+ ];
}
/**
@@ -399,20 +399,20 @@ class DateTimePlusTest extends UnitTestCase {
* @see testInvalidDateArrays
*/
public function providerTestInvalidDateArrays() {
- return array(
+ return [
// One year larger than the documented upper limit of checkdate().
- array(array('year' => 32768, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0), 'America/Chicago', \InvalidArgumentException::class),
+ [['year' => 32768, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], 'America/Chicago', \InvalidArgumentException::class],
// One year smaller than the documented lower limit of checkdate().
- array(array('year' => 0, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0), 'America/Chicago', \InvalidArgumentException::class),
+ [['year' => 0, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], 'America/Chicago', \InvalidArgumentException::class],
// Test for invalid month from date array.
- array(array('year' => 2010, 'month' => 27, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0), 'America/Chicago', \InvalidArgumentException::class),
+ [['year' => 2010, 'month' => 27, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], 'America/Chicago', \InvalidArgumentException::class],
// Test for invalid hour from date array.
- array(array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 80, 'minute' => 0, 'second' => 0), 'America/Chicago', \InvalidArgumentException::class),
+ [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 80, 'minute' => 0, 'second' => 0], 'America/Chicago', \InvalidArgumentException::class],
// Test for invalid minute from date array.
- array(array('year' => 2010, 'month' => 7, 'day' => 8, 'hour' => 8, 'minute' => 88, 'second' => 0), 'America/Chicago', \InvalidArgumentException::class),
+ [['year' => 2010, 'month' => 7, 'day' => 8, 'hour' => 8, 'minute' => 88, 'second' => 0], 'America/Chicago', \InvalidArgumentException::class],
// Regression test for https://www.drupal.org/node/2084455.
- array(array('hour' => 59, 'minute' => 1, 'second' => 1), 'America/Chicago', \InvalidArgumentException::class),
- );
+ [['hour' => 59, 'minute' => 1, 'second' => 1], 'America/Chicago', \InvalidArgumentException::class],
+ ];
}
/**
@@ -434,17 +434,17 @@ class DateTimePlusTest extends UnitTestCase {
// Detect the system timezone.
$system_timezone = date_default_timezone_get();
- return array(
+ return [
// Create a date object with an unspecified timezone, which should
// end up using the system timezone.
- array($date_string, NULL, $system_timezone, 'DateTimePlus uses the system timezone when there is no site timezone.'),
+ [$date_string, NULL, $system_timezone, 'DateTimePlus uses the system timezone when there is no site timezone.'],
// Create a date object with a specified timezone name.
- array($date_string, 'America/Yellowknife', 'America/Yellowknife', 'DateTimePlus uses the specified timezone if provided.'),
+ [$date_string, 'America/Yellowknife', 'America/Yellowknife', 'DateTimePlus uses the specified timezone if provided.'],
// Create a date object with a timezone object.
- array($date_string, new \DateTimeZone('Australia/Canberra'), 'Australia/Canberra', 'DateTimePlus uses the specified timezone if provided.'),
+ [$date_string, new \DateTimeZone('Australia/Canberra'), 'Australia/Canberra', 'DateTimePlus uses the specified timezone if provided.'],
// Create a date object with another date object.
- array(new DateTimePlus('now', 'Pacific/Midway'), NULL, 'Pacific/Midway', 'DateTimePlus uses the specified timezone if provided.'),
- );
+ [new DateTimePlus('now', 'Pacific/Midway'), NULL, 'Pacific/Midway', 'DateTimePlus uses the specified timezone if provided.'],
+ ];
}
/**
@@ -457,46 +457,46 @@ class DateTimePlusTest extends UnitTestCase {
* @see testTimestamp()
*/
public function providerTestTimestamp() {
- return array(
+ return [
// Create date object from a unix timestamp and display it in
// local time.
- array(
+ [
'input' => 0,
- 'initial' => array(
+ 'initial' => [
'timezone' => 'UTC',
'format' => 'c',
'expected_date' => '1970-01-01T00:00:00+00:00',
'expected_timezone' => 'UTC',
'expected_offset' => 0,
- ),
- 'transform' => array(
+ ],
+ 'transform' => [
'timezone' => 'America/Los_Angeles',
'format' => 'c',
'expected_date' => '1969-12-31T16:00:00-08:00',
'expected_timezone' => 'America/Los_Angeles',
'expected_offset' => '-28800',
- ),
- ),
+ ],
+ ],
// Create a date using the timestamp of zero, then display its
// value both in UTC and the local timezone.
- array(
+ [
'input' => 0,
- 'initial' => array(
+ 'initial' => [
'timezone' => 'America/Los_Angeles',
'format' => 'c',
'expected_date' => '1969-12-31T16:00:00-08:00',
'expected_timezone' => 'America/Los_Angeles',
'expected_offset' => '-28800',
- ),
- 'transform' => array(
+ ],
+ 'transform' => [
'timezone' => 'UTC',
'format' => 'c',
'expected_date' => '1970-01-01T00:00:00+00:00',
'expected_timezone' => 'UTC',
'expected_offset' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -509,63 +509,63 @@ class DateTimePlusTest extends UnitTestCase {
* @see testDateTimestamp()
*/
public function providerTestDateTimestamp() {
- return array(
+ return [
// Create date object from datetime string in UTC, and convert
// it to a local date.
- array(
+ [
'input' => '1970-01-01 00:00:00',
- 'initial' => array(
+ 'initial' => [
'timezone' => 'UTC',
'format' => 'c',
'expected_date' => '1970-01-01T00:00:00+00:00',
'expected_timezone' => 'UTC',
'expected_offset' => 0,
- ),
- 'transform' => array(
+ ],
+ 'transform' => [
'timezone' => 'America/Los_Angeles',
'format' => 'c',
'expected_date' => '1969-12-31T16:00:00-08:00',
'expected_timezone' => 'America/Los_Angeles',
'expected_offset' => '-28800',
- ),
- ),
+ ],
+ ],
// Convert the local time to UTC using string input.
- array(
+ [
'input' => '1969-12-31 16:00:00',
- 'initial' => array(
+ 'initial' => [
'timezone' => 'America/Los_Angeles',
'format' => 'c',
'expected_date' => '1969-12-31T16:00:00-08:00',
'expected_timezone' => 'America/Los_Angeles',
'expected_offset' => '-28800',
- ),
- 'transform' => array(
+ ],
+ 'transform' => [
'timezone' => 'UTC',
'format' => 'c',
'expected_date' => '1970-01-01T00:00:00+00:00',
'expected_timezone' => 'UTC',
'expected_offset' => 0,
- ),
- ),
+ ],
+ ],
// Convert the local time to UTC using string input.
- array(
+ [
'input' => '1969-12-31 16:00:00',
- 'initial' => array(
+ 'initial' => [
'timezone' => 'Europe/Warsaw',
'format' => 'c',
'expected_date' => '1969-12-31T16:00:00+01:00',
'expected_timezone' => 'Europe/Warsaw',
'expected_offset' => '+3600',
- ),
- 'transform' => array(
+ ],
+ 'transform' => [
'timezone' => 'UTC',
'format' => 'c',
'expected_date' => '1969-12-31T15:00:00+00:00',
'expected_timezone' => 'UTC',
'expected_offset' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -590,60 +590,60 @@ class DateTimePlusTest extends UnitTestCase {
$negative_1_hour = new \DateInterval('PT1H');
$negative_1_hour->invert = 1;
- return array(
+ return [
// There should be a 19 hour time interval between
// new years in Sydney and new years in LA in year 2000.
- array(
+ [
'input2' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('Australia/Sydney')),
'input1' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles')),
'absolute' => FALSE,
'expected' => $positive_19_hours,
- ),
+ ],
// In 1970 Sydney did not observe daylight savings time
// So there is only a 18 hour time interval.
- array(
+ [
'input2' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('Australia/Sydney')),
'input1' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles')),
'absolute' => FALSE,
'expected' => $positive_18_hours,
- ),
- array(
+ ],
+ [
'input1' => DateTimePlus::createFromFormat('U', 3600, new \DateTimeZone('America/Los_Angeles')),
'input2' => DateTimePlus::createFromFormat('U', 0, new \DateTimeZone('UTC')),
'absolute' => FALSE,
'expected' => $negative_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DateTimePlus::createFromFormat('U', 3600),
'input2' => DateTimePlus::createFromFormat('U', 0),
'absolute' => FALSE,
'expected' => $negative_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DateTimePlus::createFromFormat('U', 3600),
'input2' => \DateTime::createFromFormat('U', 0),
'absolute' => FALSE,
'expected' => $negative_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DateTimePlus::createFromFormat('U', 3600),
'input2' => DateTimePlus::createFromFormat('U', 0),
'absolute' => TRUE,
'expected' => $positive_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DateTimePlus::createFromFormat('U', 3600),
'input2' => \DateTime::createFromFormat('U', 0),
'absolute' => TRUE,
'expected' => $positive_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DateTimePlus::createFromFormat('U', 0),
'input2' => DateTimePlus::createFromFormat('U', 0),
'absolute' => FALSE,
'expected' => $empty_interval,
- ),
- );
+ ],
+ ];
}
/**
@@ -656,18 +656,18 @@ class DateTimePlusTest extends UnitTestCase {
* @see DateTimePlusTest::testInvalidDateDiff()
*/
public function providerTestInvalidDateDiff() {
- return array(
- array(
+ return [
+ [
'input1' => DateTimePlus::createFromFormat('U', 3600),
'input2' => '1970-01-01 00:00:00',
'absolute' => FALSE,
- ),
- array(
+ ],
+ [
'input1' => DateTimePlus::createFromFormat('U', 3600),
'input2' => NULL,
'absolute' => FALSE,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
index c818bc6a77e..8aa9d9ac128 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
@@ -452,7 +452,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
* @covers ::resolveServicesAndParameters
*/
public function testGetForInstantiationWithVariousArgumentLengths() {
- $args = array();
+ $args = [];
for ($i = 0; $i < 12; $i++) {
$instantiation_service = $this->container->get('service_test_instantiation_' . $i);
$this->assertEquals($args, $instantiation_service->getArguments());
@@ -677,10 +677,10 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
* @dataProvider scopeExceptionTestProvider
*/
public function testScopeFunctionsWithException($method, $argument) {
- $callable = array(
+ $callable = [
$this->container,
$method,
- );
+ ];
$callable($argument);
}
@@ -695,13 +695,13 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
*/
public function scopeExceptionTestProvider() {
$scope = $this->prophesize('\Symfony\Component\DependencyInjection\ScopeInterface')->reveal();
- return array(
- array('enterScope', 'test_scope'),
- array('leaveScope', 'test_scope'),
- array('hasScope', 'test_scope'),
- array('isScopeActive', 'test_scope'),
- array('addScope', $scope),
- );
+ return [
+ ['enterScope', 'test_scope'],
+ ['leaveScope', 'test_scope'],
+ ['hasScope', 'test_scope'],
+ ['isScopeActive', 'test_scope'],
+ ['addScope', $scope],
+ ];
}
/**
@@ -729,7 +729,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
*/
protected function getMockContainerDefinition() {
$fake_service = new \stdClass();
- $parameters = array();
+ $parameters = [];
$parameters['some_parameter_class'] = get_class($fake_service);
$parameters['some_private_config'] = 'really_private_lama';
$parameters['some_config'] = 'foo';
@@ -738,262 +738,262 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
// Also test alias resolving.
$parameters['service_from_parameter'] = $this->getServiceCall('service.provider_alias');
- $services = array();
- $services['service_container'] = array(
+ $services = [];
+ $services['service_container'] = [
'class' => '\Drupal\service_container\DependencyInjection\Container',
- );
- $services['other.service'] = array(
+ ];
+ $services['other.service'] = [
'class' => get_class($fake_service),
- );
+ ];
- $services['non_shared_service'] = array(
+ $services['non_shared_service'] = [
'class' => get_class($fake_service),
'shared' => FALSE,
- );
+ ];
- $services['other.service_class_from_parameter'] = array(
+ $services['other.service_class_from_parameter'] = [
'class' => $this->getParameterCall('some_parameter_class'),
- );
- $services['late.service'] = array(
+ ];
+ $services['late.service'] = [
'class' => get_class($fake_service),
- );
- $services['service.provider'] = array(
+ ];
+ $services['service.provider'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getServiceCall('other.service'),
$this->getParameterCall('some_config'),
- )),
- 'properties' => $this->getCollection(array('_someProperty' => 'foo')),
- 'calls' => array(
- array('setContainer', $this->getCollection(array(
+ ]),
+ 'properties' => $this->getCollection(['_someProperty' => 'foo']),
+ 'calls' => [
+ ['setContainer', $this->getCollection([
$this->getServiceCall('service_container'),
- ))),
- array('setOtherConfigParameter', $this->getCollection(array(
+ ])],
+ ['setOtherConfigParameter', $this->getCollection([
$this->getParameterCall('some_other_config'),
- ))),
- ),
+ ])],
+ ],
'priority' => 0,
- );
+ ];
// Test private services.
- $private_service = array(
+ $private_service = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getServiceCall('other.service'),
$this->getParameterCall('some_private_config'),
- )),
+ ]),
'public' => FALSE,
- );
+ ];
- $services['service_using_private'] = array(
+ $services['service_using_private'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getPrivateServiceCall(NULL, $private_service),
$this->getParameterCall('some_config'),
- )),
- );
- $services['another_service_using_private'] = array(
+ ]),
+ ];
+ $services['another_service_using_private'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getPrivateServiceCall(NULL, $private_service),
$this->getParameterCall('some_config'),
- )),
- );
+ ]),
+ ];
// Test shared private services.
$id = 'private_service_shared_1';
- $services['service_using_shared_private'] = array(
+ $services['service_using_shared_private'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getPrivateServiceCall($id, $private_service, TRUE),
$this->getParameterCall('some_config'),
- )),
- );
- $services['another_service_using_shared_private'] = array(
+ ]),
+ ];
+ $services['another_service_using_shared_private'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getPrivateServiceCall($id, $private_service, TRUE),
$this->getParameterCall('some_config'),
- )),
- );
+ ]),
+ ];
// Tests service with invalid argument.
- $services['invalid_argument_service'] = array(
+ $services['invalid_argument_service'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
1, // Test passing non-strings, too.
- (object) array(
+ (object) [
'type' => 'invalid',
- ),
- )),
- );
+ ],
+ ]),
+ ];
- $services['invalid_arguments_service'] = array(
+ $services['invalid_arguments_service'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => (object) array(
+ 'arguments' => (object) [
'type' => 'invalid',
- ),
- );
+ ],
+ ];
// Test service that needs deep-traversal.
- $services['service_using_array'] = array(
+ $services['service_using_array'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
- $this->getCollection(array(
+ 'arguments' => $this->getCollection([
+ $this->getCollection([
$this->getServiceCall('other.service'),
- )),
+ ]),
$this->getParameterCall('some_private_config'),
- )),
- );
+ ]),
+ ];
- $services['service_with_optional_dependency'] = array(
+ $services['service_with_optional_dependency'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getServiceCall('service.does_not_exist', ContainerInterface::NULL_ON_INVALID_REFERENCE),
$this->getParameterCall('some_private_config'),
- )),
+ ]),
- );
+ ];
- $services['factory_service'] = array(
+ $services['factory_service'] = [
'class' => '\Drupal\service_container\ServiceContainer\ControllerInterface',
- 'factory' => array(
+ 'factory' => [
$this->getServiceCall('service.provider'),
'getFactoryMethod',
- ),
- 'arguments' => $this->getCollection(array(
+ ],
+ 'arguments' => $this->getCollection([
$this->getParameterCall('factory_service_class'),
- )),
- );
- $services['factory_class'] = array(
+ ]),
+ ];
+ $services['factory_class'] = [
'class' => '\Drupal\service_container\ServiceContainer\ControllerInterface',
'factory' => '\Drupal\Tests\Component\DependencyInjection\MockService::getFactoryMethod',
- 'arguments' => array(
+ 'arguments' => [
'\Drupal\Tests\Component\DependencyInjection\MockService',
- array(NULL, 'bar'),
- ),
- 'calls' => array(
- array('setContainer', $this->getCollection(array(
+ [NULL, 'bar'],
+ ],
+ 'calls' => [
+ ['setContainer', $this->getCollection([
$this->getServiceCall('service_container'),
- ))),
- ),
- );
+ ])],
+ ],
+ ];
- $services['wrong_factory'] = array(
+ $services['wrong_factory'] = [
'class' => '\Drupal\service_container\ServiceContainer\ControllerInterface',
- 'factory' => (object) array('I am not a factory, but I pretend to be.'),
- );
+ 'factory' => (object) ['I am not a factory, but I pretend to be.'],
+ ];
- $services['circular_dependency'] = array(
+ $services['circular_dependency'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getServiceCall('circular_dependency'),
- )),
- );
- $services['synthetic'] = array(
+ ]),
+ ];
+ $services['synthetic'] = [
'synthetic' => TRUE,
- );
+ ];
// The file could have been named as a .php file. The reason it is a .data
// file is that SimpleTest tries to load it. SimpleTest does not like such
// fixtures and hence we use a neutral name like .data.
- $services['container_test_file_service_test'] = array(
+ $services['container_test_file_service_test'] = [
'class' => '\stdClass',
'file' => __DIR__ . '/Fixture/container_test_file_service_test_service_function.data',
- );
+ ];
// Test multiple arguments.
- $args = array();
+ $args = [];
for ($i = 0; $i < 12; $i++) {
- $services['service_test_instantiation_' . $i] = array(
+ $services['service_test_instantiation_' . $i] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockInstantiationService',
// Also test a collection that does not need resolving.
'arguments' => $this->getCollection($args, FALSE),
- );
+ ];
$args[] = 'arg_' . $i;
}
- $services['service_parameter_not_exists'] = array(
+ $services['service_parameter_not_exists'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getServiceCall('service.provider'),
$this->getParameterCall('not_exists'),
- )),
- );
- $services['service_dependency_not_exists'] = array(
+ ]),
+ ];
+ $services['service_dependency_not_exists'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getServiceCall('service_not_exists'),
$this->getParameterCall('some_config'),
- )),
- );
+ ]),
+ ];
- $services['service_with_parameter_service'] = array(
+ $services['service_with_parameter_service'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$this->getParameterCall('service_from_parameter'),
// Also test deep collections that don't need resolving.
- $this->getCollection(array(
+ $this->getCollection([
1,
- ), FALSE),
- )),
- );
+ ], FALSE),
+ ]),
+ ];
// To ensure getAlternatives() finds something.
- $services['service_not_exists_similar'] = array(
+ $services['service_not_exists_similar'] = [
'synthetic' => TRUE,
- );
+ ];
// Test configurator.
- $services['configurator'] = array(
+ $services['configurator'] = [
'synthetic' => TRUE,
- );
- $services['configurable_service'] = array(
+ ];
+ $services['configurable_service'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => array(),
- 'configurator' => array(
+ 'arguments' => [],
+ 'configurator' => [
$this->getServiceCall('configurator'),
'configureService'
- ),
- );
- $services['configurable_service_exception'] = array(
+ ],
+ ];
+ $services['configurable_service_exception'] = [
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
- 'arguments' => array(),
+ 'arguments' => [],
'configurator' => 'configurator_service_test_does_not_exist',
- );
+ ];
- $aliases = array();
+ $aliases = [];
$aliases['service.provider_alias'] = 'service.provider';
$aliases['late.service_alias'] = 'late.service';
- return array(
+ return [
'aliases' => $aliases,
'parameters' => $parameters,
'services' => $services,
'frozen' => TRUE,
'machine_format' => $this->machineFormat,
- );
+ ];
}
/**
* Helper function to return a service definition.
*/
protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
- return (object) array(
+ return (object) [
'type' => 'service',
'id' => $id,
'invalidBehavior' => $invalid_behavior,
- );
+ ];
}
/**
* Helper function to return a service definition.
*/
protected function getParameterCall($name) {
- return (object) array(
+ return (object) [
'type' => 'parameter',
'name' => $name,
- );
+ ];
}
/**
@@ -1004,23 +1004,23 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
$hash = Crypt::hashBase64(serialize($service_definition));
$id = 'private__' . $hash;
}
- return (object) array(
+ return (object) [
'type' => 'private_service',
'id' => $id,
'value' => $service_definition,
'shared' => $shared,
- );
+ ];
}
/**
* Helper function to return a machine-optimized collection.
*/
protected function getCollection($collection, $resolve = TRUE) {
- return (object) array(
+ return (object) [
'type' => 'collection',
'value' => $collection,
'resolve' => $resolve,
- );
+ ];
}
}
@@ -1189,7 +1189,7 @@ class MockService {
* @return object
* The instantiated service object.
*/
- public static function getFactoryMethod($class, $arguments = array()) {
+ public static function getFactoryMethod($class, $arguments = []) {
$r = new \ReflectionClass($class);
$service = ($r->getConstructor() === NULL) ? $r->newInstance() : $r->newInstanceArgs($arguments);
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
index 5a6b3190fe3..a899aaa3917 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
@@ -62,15 +62,15 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
protected function setUp() {
// Setup a mock container builder.
$this->containerBuilder = $this->prophesize('\Symfony\Component\DependencyInjection\ContainerBuilder');
- $this->containerBuilder->getAliases()->willReturn(array());
+ $this->containerBuilder->getAliases()->willReturn([]);
$this->containerBuilder->getParameterBag()->willReturn(new ParameterBag());
$this->containerBuilder->getDefinitions()->willReturn(NULL);
$this->containerBuilder->isFrozen()->willReturn(TRUE);
- $definition = array();
- $definition['aliases'] = array();
- $definition['parameters'] = array();
- $definition['services'] = array();
+ $definition = [];
+ $definition['aliases'] = [];
+ $definition['parameters'] = [];
+ $definition['services'] = [];
$definition['frozen'] = TRUE;
$definition['machine_format'] = $this->machineFormat;
@@ -114,17 +114,17 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
* - aliases as expected in the container definition.
*/
public function getAliasesDataProvider() {
- return array(
- array(array(), array()),
- array(
- array('foo' => 'foo.alias'),
- array('foo' => 'foo.alias'),
- ),
- array(
- array('foo' => 'foo.alias', 'foo.alias' => 'foo.alias.alias'),
- array('foo' => 'foo.alias.alias', 'foo.alias' => 'foo.alias.alias'),
- ),
- );
+ return [
+ [[], []],
+ [
+ ['foo' => 'foo.alias'],
+ ['foo' => 'foo.alias'],
+ ],
+ [
+ ['foo' => 'foo.alias', 'foo.alias' => 'foo.alias.alias'],
+ ['foo' => 'foo.alias.alias', 'foo.alias' => 'foo.alias.alias'],
+ ],
+ ];
}
/**
@@ -164,34 +164,34 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
* - frozen value
*/
public function getParametersDataProvider() {
- return array(
- array(array(), array(), TRUE),
- array(
- array('foo' => 'value_foo'),
- array('foo' => 'value_foo'),
+ return [
+ [[], [], TRUE],
+ [
+ ['foo' => 'value_foo'],
+ ['foo' => 'value_foo'],
TRUE,
- ),
- array(
- array('foo' => array('llama' => 'yes')),
- array('foo' => array('llama' => 'yes')),
+ ],
+ [
+ ['foo' => ['llama' => 'yes']],
+ ['foo' => ['llama' => 'yes']],
TRUE,
- ),
- array(
- array('foo' => '%llama%', 'llama' => 'yes'),
- array('foo' => '%%llama%%', 'llama' => 'yes'),
+ ],
+ [
+ ['foo' => '%llama%', 'llama' => 'yes'],
+ ['foo' => '%%llama%%', 'llama' => 'yes'],
TRUE,
- ),
- array(
- array('foo' => '%llama%', 'llama' => 'yes'),
- array('foo' => '%llama%', 'llama' => 'yes'),
+ ],
+ [
+ ['foo' => '%llama%', 'llama' => 'yes'],
+ ['foo' => '%llama%', 'llama' => 'yes'],
FALSE,
- ),
- array(
- array('reference' => new Reference('referenced_service')),
- array('reference' => $this->getServiceCall('referenced_service')),
+ ],
+ [
+ ['reference' => new Reference('referenced_service')],
+ ['reference' => $this->getServiceCall('referenced_service')],
TRUE,
- ),
- );
+ ],
+ ];
}
/**
@@ -236,164 +236,164 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
* - frozen value
*/
public function getDefinitionsDataProvider() {
- $base_service_definition = array(
+ $base_service_definition = [
'class' => '\stdClass',
'public' => TRUE,
'file' => FALSE,
'synthetic' => FALSE,
'lazy' => FALSE,
- 'arguments' => array(),
+ 'arguments' => [],
'arguments_count' => 0,
- 'properties' => array(),
- 'calls' => array(),
+ 'properties' => [],
+ 'calls' => [],
'scope' => ContainerInterface::SCOPE_CONTAINER,
'shared' => TRUE,
'factory' => FALSE,
'configurator' => FALSE,
- );
+ ];
// Test basic flags.
- $service_definitions[] = array() + $base_service_definition;
+ $service_definitions[] = [] + $base_service_definition;
- $service_definitions[] = array(
+ $service_definitions[] = [
'public' => FALSE,
- ) + $base_service_definition;
+ ] + $base_service_definition;
- $service_definitions[] = array(
+ $service_definitions[] = [
'file' => 'test_include.php',
- ) + $base_service_definition;
+ ] + $base_service_definition;
- $service_definitions[] = array(
+ $service_definitions[] = [
'synthetic' => TRUE,
- ) + $base_service_definition;
+ ] + $base_service_definition;
- $service_definitions[] = array(
+ $service_definitions[] = [
'shared' => FALSE,
- ) + $base_service_definition;
+ ] + $base_service_definition;
- $service_definitions[] = array(
+ $service_definitions[] = [
'lazy' => TRUE,
- ) + $base_service_definition;
+ ] + $base_service_definition;
// Test a basic public Reference.
- $service_definitions[] = array(
- 'arguments' => array('foo', new Reference('bar')),
+ $service_definitions[] = [
+ 'arguments' => ['foo', new Reference('bar')],
'arguments_count' => 2,
- 'arguments_expected' => $this->getCollection(array('foo', $this->getServiceCall('bar'))),
- ) + $base_service_definition;
+ 'arguments_expected' => $this->getCollection(['foo', $this->getServiceCall('bar')]),
+ ] + $base_service_definition;
// Test a public reference that should not throw an Exception.
$reference = new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE);
- $service_definitions[] = array(
- 'arguments' => array($reference),
+ $service_definitions[] = [
+ 'arguments' => [$reference],
'arguments_count' => 1,
- 'arguments_expected' => $this->getCollection(array($this->getServiceCall('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE))),
- ) + $base_service_definition;
+ 'arguments_expected' => $this->getCollection([$this->getServiceCall('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE)]),
+ ] + $base_service_definition;
// Test a private shared service, denoted by having a Reference.
- $private_definition = array(
+ $private_definition = [
'class' => '\stdClass',
'public' => FALSE,
'arguments_count' => 0,
- );
+ ];
- $service_definitions[] = array(
- 'arguments' => array('foo', new Reference('private_definition')),
+ $service_definitions[] = [
+ 'arguments' => ['foo', new Reference('private_definition')],
'arguments_count' => 2,
- 'arguments_expected' => $this->getCollection(array(
+ 'arguments_expected' => $this->getCollection([
'foo',
$this->getPrivateServiceCall('private_definition', $private_definition, TRUE),
- )),
- ) + $base_service_definition;
+ ]),
+ ] + $base_service_definition;
// Test a private non-shared service, denoted by having a Definition.
$private_definition_object = new Definition('\stdClass');
$private_definition_object->setPublic(FALSE);
- $service_definitions[] = array(
- 'arguments' => array('foo', $private_definition_object),
+ $service_definitions[] = [
+ 'arguments' => ['foo', $private_definition_object],
'arguments_count' => 2,
- 'arguments_expected' => $this->getCollection(array(
+ 'arguments_expected' => $this->getCollection([
'foo',
$this->getPrivateServiceCall(NULL, $private_definition),
- )),
- ) + $base_service_definition;
+ ]),
+ ] + $base_service_definition;
// Test a deep collection without a reference.
- $service_definitions[] = array(
- 'arguments' => array(array(array('foo'))),
+ $service_definitions[] = [
+ 'arguments' => [[['foo']]],
'arguments_count' => 1,
- ) + $base_service_definition;
+ ] + $base_service_definition;
// Test a deep collection with a reference to resolve.
- $service_definitions[] = array(
- 'arguments' => array(array(new Reference('bar'))),
+ $service_definitions[] = [
+ 'arguments' => [[new Reference('bar')]],
'arguments_count' => 1,
- 'arguments_expected' => $this->getCollection(array($this->getCollection(array($this->getServiceCall('bar'))))),
- ) + $base_service_definition;
+ 'arguments_expected' => $this->getCollection([$this->getCollection([$this->getServiceCall('bar')])]),
+ ] + $base_service_definition;
// Test a collection with a variable to resolve.
- $service_definitions[] = array(
- 'arguments' => array(new Parameter('llama_parameter')),
+ $service_definitions[] = [
+ 'arguments' => [new Parameter('llama_parameter')],
'arguments_count' => 1,
- 'arguments_expected' => $this->getCollection(array($this->getParameterCall('llama_parameter'))),
- ) + $base_service_definition;
+ 'arguments_expected' => $this->getCollection([$this->getParameterCall('llama_parameter')]),
+ ] + $base_service_definition;
// Test objects that have _serviceId property.
$drupal_service = new \stdClass();
$drupal_service->_serviceId = 'bar';
- $service_definitions[] = array(
- 'arguments' => array($drupal_service),
+ $service_definitions[] = [
+ 'arguments' => [$drupal_service],
'arguments_count' => 1,
- 'arguments_expected' => $this->getCollection(array($this->getServiceCall('bar'))),
- ) + $base_service_definition;
+ 'arguments_expected' => $this->getCollection([$this->getServiceCall('bar')]),
+ ] + $base_service_definition;
// Test getMethodCalls.
- $calls = array(
- array('method', $this->getCollection(array())),
- array('method2', $this->getCollection(array())),
- );
- $service_definitions[] = array(
+ $calls = [
+ ['method', $this->getCollection([])],
+ ['method2', $this->getCollection([])],
+ ];
+ $service_definitions[] = [
'calls' => $calls,
- ) + $base_service_definition;
+ ] + $base_service_definition;
- $service_definitions[] = array(
+ $service_definitions[] = [
'scope' => ContainerInterface::SCOPE_PROTOTYPE,
'shared' => FALSE,
- ) + $base_service_definition;
+ ] + $base_service_definition;
- $service_definitions[] = array(
+ $service_definitions[] = [
'shared' => FALSE,
- ) + $base_service_definition;
+ ] + $base_service_definition;
// Test factory.
- $service_definitions[] = array(
- 'factory' => array(new Reference('bar'), 'factoryMethod'),
- 'factory_expected' => array($this->getServiceCall('bar'), 'factoryMethod'),
- ) + $base_service_definition;
+ $service_definitions[] = [
+ 'factory' => [new Reference('bar'), 'factoryMethod'],
+ 'factory_expected' => [$this->getServiceCall('bar'), 'factoryMethod'],
+ ] + $base_service_definition;
// Test invalid factory - needed to test deep dumpValue().
- $service_definitions[] = array(
- 'factory' => array(array('foo', 'llama'), 'factoryMethod'),
- ) + $base_service_definition;
+ $service_definitions[] = [
+ 'factory' => [['foo', 'llama'], 'factoryMethod'],
+ ] + $base_service_definition;
// Test properties.
- $service_definitions[] = array(
- 'properties' => array('_value' => 'llama'),
- ) + $base_service_definition;
+ $service_definitions[] = [
+ 'properties' => ['_value' => 'llama'],
+ ] + $base_service_definition;
// Test configurator.
- $service_definitions[] = array(
- 'configurator' => array(new Reference('bar'), 'configureService'),
- 'configurator_expected' => array($this->getServiceCall('bar'), 'configureService'),
- ) + $base_service_definition;
+ $service_definitions[] = [
+ 'configurator' => [new Reference('bar'), 'configureService'],
+ 'configurator_expected' => [$this->getServiceCall('bar'), 'configureService'],
+ ] + $base_service_definition;
- $services_provided = array();
- $services_provided[] = array(
- array(),
- array(),
- );
+ $services_provided = [];
+ $services_provided[] = [
+ [],
+ [],
+ ];
foreach ($service_definitions as $service_definition) {
$definition = $this->prophesize('\Symfony\Component\DependencyInjection\Definition');
@@ -412,7 +412,7 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
$definition->getConfigurator()->willReturn($service_definition['configurator']);
// Preserve order.
- $filtered_service_definition = array();
+ $filtered_service_definition = [];
foreach ($base_service_definition as $key => $value) {
$filtered_service_definition[$key] = $service_definition[$key];
unset($service_definition[$key]);
@@ -430,7 +430,7 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
$filtered_service_definition += $service_definition;
// Allow to set _expected values.
- foreach (array('arguments', 'factory', 'configurator') as $key) {
+ foreach (['arguments', 'factory', 'configurator'] as $key) {
$expected = $key . '_expected';
if (isset($filtered_service_definition[$expected])) {
$filtered_service_definition[$key] = $filtered_service_definition[$expected];
@@ -442,17 +442,17 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
unset($filtered_service_definition['scope']);
if (isset($filtered_service_definition['public']) && $filtered_service_definition['public'] === FALSE) {
- $services_provided[] = array(
- array('foo_service' => $definition->reveal()),
- array(),
- );
+ $services_provided[] = [
+ ['foo_service' => $definition->reveal()],
+ [],
+ ];
continue;
}
- $services_provided[] = array(
- array('foo_service' => $definition->reveal()),
- array('foo_service' => $this->serializeDefinition($filtered_service_definition)),
- );
+ $services_provided[] = [
+ ['foo_service' => $definition->reveal()],
+ ['foo_service' => $this->serializeDefinition($filtered_service_definition)],
+ ];
}
return $services_provided;
@@ -471,11 +471,11 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
* Helper function to return a service definition.
*/
protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
- return (object) array(
+ return (object) [
'type' => 'service',
'id' => $id,
'invalidBehavior' => $invalid_behavior,
- );
+ ];
}
/**
@@ -503,9 +503,9 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
*/
public function testGetServiceDefinitionWithReferenceToAlias($public) {
$bar_definition = new Definition('\stdClass');
- $bar_definition_php_array = array(
+ $bar_definition_php_array = [
'class' => '\stdClass',
- );
+ ];
if (!$public) {
$bar_definition->setPublic(FALSE);
$bar_definition_php_array['public'] = FALSE;
@@ -531,21 +531,21 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
else {
$service_definition = $this->getPrivateServiceCall('bar', $bar_definition_php_array, TRUE);
}
- $data = array(
+ $data = [
'class' => '\stdClass',
- 'arguments' => $this->getCollection(array(
+ 'arguments' => $this->getCollection([
$service_definition,
- )),
+ ]),
'arguments_count' => 1,
- );
+ ];
$this->assertEquals($this->serializeDefinition($data), $dump['services']['foo'], 'Expected definition matches dump.');
}
public function publicPrivateDataProvider() {
- return array(
- array(TRUE),
- array(FALSE),
- );
+ return [
+ [TRUE],
+ [FALSE],
+ ];
}
/**
@@ -629,33 +629,33 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
$hash = Crypt::hashBase64(serialize($service_definition));
$id = 'private__' . $hash;
}
- return (object) array(
+ return (object) [
'type' => 'private_service',
'id' => $id,
'value' => $service_definition,
'shared' => $shared,
- );
+ ];
}
/**
* Helper function to return a machine-optimized collection.
*/
protected function getCollection($collection, $resolve = TRUE) {
- return (object) array(
+ return (object) [
'type' => 'collection',
'value' => $collection,
'resolve' => $resolve,
- );
+ ];
}
/**
* Helper function to return a parameter definition.
*/
protected function getParameterCall($name) {
- return (object) array(
+ return (object) [
'type' => 'parameter',
'name' => $name,
- );
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php b/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php
index 68b16eeb44d..897a7889840 100644
--- a/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php
@@ -34,12 +34,12 @@ class YamlDiscoveryTest extends UnitTestCase {
file_put_contents($url . '/test_2/test_4.test.yml', '');
// Set up the directories to search.
- $directories = array(
+ $directories = [
'test_1' => $url . '/test_1',
'test_2' => $url . '/test_1',
'test_3' => $url . '/test_2',
'test_4' => $url . '/test_2',
- );
+ ];
$discovery = new YamlDiscovery('test', $directories);
$data = $discovery->findAll();
@@ -50,12 +50,12 @@ class YamlDiscoveryTest extends UnitTestCase {
$this->assertArrayHasKey('test_3', $data);
$this->assertArrayHasKey('test_4', $data);
- foreach (array('test_1', 'test_2', 'test_3') as $key) {
+ foreach (['test_1', 'test_2', 'test_3'] as $key) {
$this->assertArrayHasKey('name', $data[$key]);
$this->assertEquals($data[$key]['name'], 'test');
}
- $this->assertSame(array(), $data['test_4']);
+ $this->assertSame([], $data['test_4']);
}
}
diff --git a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
index 11ce86f08ad..7e746d7379a 100644
--- a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
+++ b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
@@ -42,7 +42,7 @@ class DrupalComponentTest extends UnitTestCase {
* An array of class paths.
*/
protected function findPhpClasses($dir) {
- $classes = array();
+ $classes = [];
foreach (new \DirectoryIterator($dir) as $file) {
if ($file->isDir() && !$file->isDot()) {
$classes = array_merge($classes, $this->findPhpClasses($file->getPathname()));
@@ -80,26 +80,26 @@ class DrupalComponentTest extends UnitTestCase {
* - File data as a string. This will be used as a virtual file.
*/
public function providerAssertNoCoreUseage() {
- return array(
- array(
+ return [
+ [
TRUE,
'@see \\Drupal\\Core\\Something',
- ),
- array(
+ ],
+ [
FALSE,
'\\Drupal\\Core\\Something',
- ),
- array(
+ ],
+ [
FALSE,
"@see \\Drupal\\Core\\Something\n" .
'\\Drupal\\Core\\Something',
- ),
- array(
+ ],
+ [
FALSE,
"\\Drupal\\Core\\Something\n" .
'@see \\Drupal\\Core\\Something',
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php
index eab85b385aa..e106fec3790 100644
--- a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php
+++ b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php
@@ -48,22 +48,22 @@ class PoHeaderTest extends UnitTestCase {
* value.
*/
public function providerTestPluralsFormula() {
- return array(
- array(
+ return [
+ [
'nplurals=1; plural=0;',
- array('default' => 0),
- ),
- array(
+ ['default' => 0],
+ ],
+ [
'nplurals=2; plural=(n > 1);',
- array(0 => 0, 1 => 0, 'default' => 1),
- ),
- array(
+ [0 => 0, 1 => 0, 'default' => 1],
+ ],
+ [
'nplurals=2; plural=(n!=1);',
- array(1 => 0, 'default' => 1),
- ),
- array(
+ [1 => 0, 'default' => 1],
+ ],
+ [
'nplurals=2; plural=(((n==1)||((n%10)==1))?(0):1);',
- array(
+ [
1 => 0,
11 => 0,
21 => 0,
@@ -85,11 +85,11 @@ class PoHeaderTest extends UnitTestCase {
181 => 0,
191 => 0,
'default' => 1,
- ),
- ),
- array(
+ ],
+ ],
+ [
'nplurals=3; plural=((((n%10)==1)&&((n%100)!=11))?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));',
- array(
+ [
1 => 0,
2 => 1,
3 => 1,
@@ -163,21 +163,21 @@ class PoHeaderTest extends UnitTestCase {
193 => 1,
194 => 1,
'default' => 2,
- ),
- ),
- array(
+ ],
+ ],
+ [
'nplurals=3; plural=((n==1)?(0):(((n>=2)&&(n<=4))?(1):2));',
- array(
+ [
1 => 0,
2 => 1,
3 => 1,
4 => 1,
'default' => 2,
- ),
- ),
- array(
+ ],
+ ],
+ [
'nplurals=3; plural=((n==1)?(0):(((n==0)||(((n%100)>0)&&((n%100)<20)))?(1):2));',
- array(
+ [
0 => 1,
1 => 0,
2 => 1,
@@ -218,11 +218,11 @@ class PoHeaderTest extends UnitTestCase {
118 => 1,
119 => 1,
'default' => 2,
- ),
- ),
- array(
+ ],
+ ],
+ [
'nplurals=3; plural=((n==1)?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));',
- array(
+ [
1 => 0,
2 => 1,
3 => 1,
@@ -279,10 +279,10 @@ class PoHeaderTest extends UnitTestCase {
193 => 1,
194 => 1,
'default' => 2,
- ),),
- array(
+ ],],
+ [
'nplurals=4; plural=(((n==1)||(n==11))?(0):(((n==2)||(n==12))?(1):(((n>2)&&(n<20))?(2):3)));',
- array(
+ [
1 => 0,
2 => 1,
3 => 2,
@@ -303,11 +303,11 @@ class PoHeaderTest extends UnitTestCase {
18 => 2,
19 => 2,
'default' => 3,
- ),
- ),
- array(
+ ],
+ ],
+ [
'nplurals=4; plural=(((n%100)==1)?(0):(((n%100)==2)?(1):((((n%100)==3)||((n%100)==4))?(2):3)));',
- array(
+ [
1 => 0,
2 => 1,
3 => 2,
@@ -317,11 +317,11 @@ class PoHeaderTest extends UnitTestCase {
103 => 2,
104 => 2,
'default' => 3,
- ),
- ),
- array(
+ ],
+ ],
+ [
'nplurals=5; plural=((n==1)?(0):((n==2)?(1):((n<7)?(2):((n<11)?(3):4))));',
- array(
+ [
0 => 2,
1 => 0,
2 => 1,
@@ -334,11 +334,11 @@ class PoHeaderTest extends UnitTestCase {
9 => 3,
10 => 3,
'default' => 4,
- ),
- ),
- array(
+ ],
+ ],
+ [
'nplurals=6; plural=((n==1)?(0):((n==0)?(1):((n==2)?(2):((((n%100)>=3)&&((n%100)<=10))?(3):((((n%100)>=11)&&((n%100)<=99))?(4):5)))));',
- array(
+ [
0 => 1,
1 => 0,
2 => 2,
@@ -362,9 +362,9 @@ class PoHeaderTest extends UnitTestCase {
109 => 3,
110 => 3,
'default' => 4,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
index e17c7ff03f4..9c4a7a52889 100644
--- a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
+++ b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
@@ -21,59 +21,59 @@ class GraphTest extends UnitTestCase {
// | | |
// | | |
// +---> 4 <-- 7 8 ---> 9
- $graph = $this->normalizeGraph(array(
- 1 => array(2),
- 2 => array(3, 4),
- 3 => array(),
- 4 => array(3),
- 5 => array(6),
- 7 => array(4, 5),
- 8 => array(9),
- 9 => array(),
- ));
+ $graph = $this->normalizeGraph([
+ 1 => [2],
+ 2 => [3, 4],
+ 3 => [],
+ 4 => [3],
+ 5 => [6],
+ 7 => [4, 5],
+ 8 => [9],
+ 9 => [],
+ ]);
$graph_object = new Graph($graph);
$graph = $graph_object->searchAndSort();
- $expected_paths = array(
- 1 => array(2, 3, 4),
- 2 => array(3, 4),
- 3 => array(),
- 4 => array(3),
- 5 => array(6),
- 7 => array(4, 3, 5, 6),
- 8 => array(9),
- 9 => array(),
- );
+ $expected_paths = [
+ 1 => [2, 3, 4],
+ 2 => [3, 4],
+ 3 => [],
+ 4 => [3],
+ 5 => [6],
+ 7 => [4, 3, 5, 6],
+ 8 => [9],
+ 9 => [],
+ ];
$this->assertPaths($graph, $expected_paths);
- $expected_reverse_paths = array(
- 1 => array(),
- 2 => array(1),
- 3 => array(2, 1, 4, 7),
- 4 => array(2, 1, 7),
- 5 => array(7),
- 7 => array(),
- 8 => array(),
- 9 => array(8),
- );
+ $expected_reverse_paths = [
+ 1 => [],
+ 2 => [1],
+ 3 => [2, 1, 4, 7],
+ 4 => [2, 1, 7],
+ 5 => [7],
+ 7 => [],
+ 8 => [],
+ 9 => [8],
+ ];
$this->assertReversePaths($graph, $expected_reverse_paths);
// Assert that DFS didn't created "missing" vertexes automatically.
$this->assertFalse(isset($graph[6]), 'Vertex 6 has not been created');
- $expected_components = array(
- array(1, 2, 3, 4, 5, 7),
- array(8, 9),
- );
+ $expected_components = [
+ [1, 2, 3, 4, 5, 7],
+ [8, 9],
+ ];
$this->assertComponents($graph, $expected_components);
- $expected_weights = array(
- array(1, 2, 3),
- array(2, 4, 3),
- array(7, 4, 3),
- array(7, 5),
- array(8, 9),
- );
+ $expected_weights = [
+ [1, 2, 3],
+ [2, 4, 3],
+ [7, 4, 3],
+ [7, 5],
+ [8, 9],
+ ];
$this->assertWeights($graph, $expected_weights);
}
@@ -87,10 +87,10 @@ class GraphTest extends UnitTestCase {
* The normalized version of a graph.
*/
protected function normalizeGraph($graph) {
- $normalized_graph = array();
+ $normalized_graph = [];
foreach ($graph as $vertex => $edges) {
// Create vertex even if it hasn't any edges.
- $normalized_graph[$vertex] = array();
+ $normalized_graph[$vertex] = [];
foreach ($edges as $edge) {
$normalized_graph[$vertex]['edges'][$edge] = TRUE;
}
@@ -110,7 +110,7 @@ class GraphTest extends UnitTestCase {
foreach ($expected_paths as $vertex => $paths) {
// Build an array with keys = $paths and values = TRUE.
$expected = array_fill_keys($paths, TRUE);
- $result = isset($graph[$vertex]['paths']) ? $graph[$vertex]['paths'] : array();
+ $result = isset($graph[$vertex]['paths']) ? $graph[$vertex]['paths'] : [];
$this->assertEquals($expected, $result, sprintf('Expected paths for vertex %s: %s, got %s', $vertex, $this->displayArray($expected, TRUE), $this->displayArray($result, TRUE)));
}
}
@@ -128,7 +128,7 @@ class GraphTest extends UnitTestCase {
foreach ($expected_reverse_paths as $vertex => $paths) {
// Build an array with keys = $paths and values = TRUE.
$expected = array_fill_keys($paths, TRUE);
- $result = isset($graph[$vertex]['reverse_paths']) ? $graph[$vertex]['reverse_paths'] : array();
+ $result = isset($graph[$vertex]['reverse_paths']) ? $graph[$vertex]['reverse_paths'] : [];
$this->assertEquals($expected, $result, sprintf('Expected reverse paths for vertex %s: %s, got %s', $vertex, $this->displayArray($expected, TRUE), $this->displayArray($result, TRUE)));
}
}
@@ -144,14 +144,14 @@ class GraphTest extends UnitTestCase {
protected function assertComponents($graph, $expected_components) {
$unassigned_vertices = array_fill_keys(array_keys($graph), TRUE);
foreach ($expected_components as $component) {
- $result_components = array();
+ $result_components = [];
foreach ($component as $vertex) {
$result_components[] = $graph[$vertex]['component'];
unset($unassigned_vertices[$vertex]);
}
$this->assertEquals(1, count(array_unique($result_components)), sprintf('Expected one unique component for vertices %s, got %s', $this->displayArray($component), $this->displayArray($result_components)));
}
- $this->assertEquals(array(), $unassigned_vertices, sprintf('Vertices not assigned to a component: %s', $this->displayArray($unassigned_vertices, TRUE)));
+ $this->assertEquals([], $unassigned_vertices, sprintf('Vertices not assigned to a component: %s', $this->displayArray($unassigned_vertices, TRUE)));
}
/**
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
index eca12416df2..8b8c95acd9e 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
@@ -33,15 +33,15 @@ class FileStorageReadOnlyTest extends PhpStorageTestBase {
protected function setUp() {
parent::setUp();
- $this->standardSettings = array(
+ $this->standardSettings = [
'directory' => $this->directory,
'bin' => 'test',
- );
- $this->readonlyStorage = array(
+ ];
+ $this->readonlyStorage = [
'directory' => $this->directory,
// Let this read from the bin where the other instance is writing.
'bin' => 'test',
- );
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
index 25a0ed00a46..a1a11ec38db 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
@@ -24,10 +24,10 @@ class FileStorageTest extends PhpStorageTestBase {
protected function setUp() {
parent::setUp();
- $this->standardSettings = array(
+ $this->standardSettings = [
'directory' => $this->directory,
'bin' => 'test',
- );
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php
index 726cd1c760f..577241d472a 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php
@@ -19,7 +19,7 @@ class MTimeProtectedFastFileStorageTest extends MTimeProtectedFileStorageBase {
* include the hacked file on the first try but the second test will change
* the directory mtime and so on the second try the file will not be included.
*/
- protected $expected = array(TRUE, FALSE);
+ protected $expected = [TRUE, FALSE];
/**
* The PHP storage class to test.
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php
index af9fa056a83..c36453c3280 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php
@@ -38,11 +38,11 @@ abstract class MTimeProtectedFileStorageBase extends PhpStorageTestBase {
$this->secret = $this->randomMachineName();
- $this->settings = array(
+ $this->settings = [
'directory' => $this->directory,
'bin' => 'test',
'secret' => $this->secret,
- );
+ ];
}
/**
@@ -90,7 +90,7 @@ abstract class MTimeProtectedFileStorageBase extends PhpStorageTestBase {
// Ensure the root directory for the bin has a .htaccess file denying web
// access.
- $this->assertSame(file_get_contents($expected_root_directory . '/.htaccess'), call_user_func(array($this->storageClass, 'htaccessLines')));
+ $this->assertSame(file_get_contents($expected_root_directory . '/.htaccess'), call_user_func([$this->storageClass, 'htaccessLines']));
// Ensure that if the file is replaced with an untrusted one (due to another
// script's file upload vulnerability), it does not get loaded. Since mtime
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php
index 15b75e723f9..bc88c334590 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php
@@ -18,7 +18,7 @@ class MTimeProtectedFileStorageTest extends MTimeProtectedFileStorageBase {
* The default implementation protects against even the filemtime change so
* both iterations will return FALSE.
*/
- protected $expected = array(FALSE, FALSE);
+ protected $expected = [FALSE, FALSE];
/**
* The PHP storage class to test.
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
index 917379e4d94..f320c554489 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
@@ -30,7 +30,7 @@ class ContextTest extends UnitTestCase {
// Mock a Context object.
$mock_context = $this->getMockBuilder('Drupal\Component\Plugin\Context\Context')
->disableOriginalConstructor()
- ->setMethods(array('getContextDefinition'))
+ ->setMethods(['getContextDefinition'])
->getMock();
// If the context value exists, getContextValue() behaves like a normal
@@ -49,7 +49,7 @@ class ContextTest extends UnitTestCase {
else {
// Create a mock definition.
$mock_definition = $this->getMockBuilder('Drupal\Component\Plugin\Context\ContextDefinitionInterface')
- ->setMethods(array('isRequired', 'getDataType'))
+ ->setMethods(['isRequired', 'getDataType'])
->getMockForAbstractClass();
// Set expectation for isRequired().
@@ -87,7 +87,7 @@ class ContextTest extends UnitTestCase {
*/
public function testDefaultValue() {
$mock_definition = $this->getMockBuilder('Drupal\Component\Plugin\Context\ContextDefinitionInterface')
- ->setMethods(array('getDefaultValue'))
+ ->setMethods(['getDefaultValue'])
->getMockForAbstractClass();
$mock_definition->expects($this->once())
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php
index 5218ec2a79e..0f112fb2ef4 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php
@@ -21,11 +21,11 @@ class DiscoveryCachedTraitTest extends UnitTestCase {
* - Plugin name to query for.
*/
public function providerGetDefinition() {
- return array(
+ return [
['definition', [], ['plugin_name' => 'definition'], 'plugin_name'],
['definition', ['plugin_name' => 'definition'], [], 'plugin_name'],
[NULL, ['plugin_name' => 'definition'], [], 'bad_plugin_name'],
- );
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
index 9f747f91b19..74a8c431291 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
@@ -19,10 +19,10 @@ class DiscoveryTraitTest extends UnitTestCase {
* - Plugin ID to get, passed to doGetDefinition().
*/
public function providerDoGetDefinition() {
- return array(
+ return [
['definition', ['plugin_name' => 'definition'], 'plugin_name'],
[NULL, ['plugin_name' => 'definition'], 'bad_plugin_name'],
- );
+ ];
}
/**
@@ -51,9 +51,9 @@ class DiscoveryTraitTest extends UnitTestCase {
* - Plugin ID to get, passed to doGetDefinition().
*/
public function providerDoGetDefinitionException() {
- return array(
+ return [
[FALSE, ['plugin_name' => 'definition'], 'bad_plugin_name'],
- );
+ ];
}
/**
@@ -123,10 +123,10 @@ class DiscoveryTraitTest extends UnitTestCase {
* - Plugin ID to look for.
*/
public function providerHasDefinition() {
- return array(
+ return [
[TRUE, 'valid'],
[FALSE, 'not_valid'],
- );
+ ];
}
/**
@@ -135,16 +135,16 @@ class DiscoveryTraitTest extends UnitTestCase {
*/
public function testHasDefinition($expected, $plugin_id) {
$trait = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryTrait')
- ->setMethods(array('getDefinition'))
+ ->setMethods(['getDefinition'])
->getMockForTrait();
// Set up our mocked getDefinition() to return TRUE for 'valid' and FALSE
// for 'not_valid'.
$trait->expects($this->once())
->method('getDefinition')
- ->will($this->returnValueMap(array(
+ ->will($this->returnValueMap([
['valid', FALSE, TRUE],
['not_valid', FALSE, FALSE],
- )));
+ ]));
// Call hasDefinition().
$this->assertSame(
$expected,
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
index bdab19c7ef4..1828d73f36c 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
@@ -23,7 +23,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
*/
public function getRegisterDefinitionsCallback() {
$mock_callable = $this->getMockBuilder('\stdClass')
- ->setMethods(array('registerDefinitionsCallback'))
+ ->setMethods(['registerDefinitionsCallback'])
->getMock();
// Set expectations for the callback method.
$mock_callable->expects($this->once())
@@ -62,7 +62,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
// Mock our StaticDiscoveryDecorator.
$mock_decorator = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator')
->disableOriginalConstructor()
- ->setMethods(array('registeredDefintionCallback'))
+ ->setMethods(['registeredDefintionCallback'])
->getMock();
// Set up the ::$registerDefinitions property.
@@ -72,7 +72,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
// Set the callback object on the mocked decorator.
$ref_register_definitions->setValue(
$mock_decorator,
- array($this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback')
+ [$this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback']
);
}
else {
@@ -83,11 +83,11 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
// Set up ::$definitions to an empty array.
$ref_definitions = new \ReflectionProperty($mock_decorator, 'definitions');
$ref_definitions->setAccessible(TRUE);
- $ref_definitions->setValue($mock_decorator, array());
+ $ref_definitions->setValue($mock_decorator, []);
// Mock a decorated object.
$mock_decorated = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface')
- ->setMethods(array('getDefinitions'))
+ ->setMethods(['getDefinitions'])
->getMockForAbstractClass();
// Return our definitions from getDefinitions().
$mock_decorated->expects($this->once())
@@ -132,7 +132,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
// Mock our StaticDiscoveryDecorator.
$mock_decorator = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator')
->disableOriginalConstructor()
- ->setMethods(array('registeredDefintionCallback'))
+ ->setMethods(['registeredDefintionCallback'])
->getMock();
// Set up the ::$registerDefinitions property.
@@ -142,7 +142,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
// Set the callback object on the mocked decorator.
$ref_register_definitions->setValue(
$mock_decorator,
- array($this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback')
+ [$this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback']
);
}
else {
@@ -153,11 +153,11 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
// Set up ::$definitions to an empty array.
$ref_definitions = new \ReflectionProperty($mock_decorator, 'definitions');
$ref_definitions->setAccessible(TRUE);
- $ref_definitions->setValue($mock_decorator, array());
+ $ref_definitions->setValue($mock_decorator, []);
// Mock a decorated object.
$mock_decorated = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface')
- ->setMethods(array('getDefinitions'))
+ ->setMethods(['getDefinitions'])
->getMockForAbstractClass();
// Our mocked method will return any arguments sent to it.
$mock_decorated->expects($this->once())
@@ -199,7 +199,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
public function testCall($method, $args) {
// Mock a decorated object.
$mock_decorated = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface')
- ->setMethods(array($method))
+ ->setMethods([$method])
->getMockForAbstractClass();
// Our mocked method will return any arguments sent to it.
$mock_decorated->expects($this->once())
@@ -222,7 +222,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase {
// Exercise __call.
$this->assertArrayEquals(
$args,
- \call_user_func_array(array($mock_decorated, $method), $args)
+ \call_user_func_array([$mock_decorated, $method], $args)
);
}
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
index 8130b2df206..c6a0adf8596 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
@@ -88,7 +88,7 @@ class ReflectionFactoryTest extends UnitTestCase {
public function testCreateInstance($expected, $reflector_name, $plugin_id, $plugin_definition, $configuration) {
// Create a mock DiscoveryInterface which can return our plugin definition.
$mock_discovery = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface')
- ->setMethods(array('getDefinition', 'getDefinitions', 'hasDefinition'))
+ ->setMethods(['getDefinition', 'getDefinitions', 'hasDefinition'])
->getMock();
$mock_discovery->expects($this->never())->method('getDefinitions');
$mock_discovery->expects($this->never())->method('hasDefinition');
diff --git a/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php b/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php
index 600993205fb..0ef8451aba2 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php
@@ -15,11 +15,11 @@ class PluginBaseTest extends UnitTestCase {
* @covers ::getPluginId
*/
public function testGetPluginId($plugin_id, $expected) {
- $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
- array(),
+ $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [
+ [],
$plugin_id,
- array(),
- ));
+ [],
+ ]);
$this->assertEquals($expected, $plugin_base->getPluginId());
}
@@ -30,10 +30,10 @@ class PluginBaseTest extends UnitTestCase {
* @return array
*/
public function providerTestGetPluginId() {
- return array(
- array('base_id', 'base_id'),
- array('base_id:derivative', 'base_id:derivative'),
- );
+ return [
+ ['base_id', 'base_id'],
+ ['base_id:derivative', 'base_id:derivative'],
+ ];
}
/**
@@ -42,11 +42,11 @@ class PluginBaseTest extends UnitTestCase {
*/
public function testGetBaseId($plugin_id, $expected) {
/** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit_Framework_MockObject_MockObject $plugin_base */
- $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
- array(),
+ $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [
+ [],
$plugin_id,
- array(),
- ));
+ [],
+ ]);
$this->assertEquals($expected, $plugin_base->getBaseId());
}
@@ -57,10 +57,10 @@ class PluginBaseTest extends UnitTestCase {
* @return array
*/
public function providerTestGetBaseId() {
- return array(
- array('base_id', 'base_id'),
- array('base_id:derivative', 'base_id'),
- );
+ return [
+ ['base_id', 'base_id'],
+ ['base_id:derivative', 'base_id'],
+ ];
}
@@ -70,11 +70,11 @@ class PluginBaseTest extends UnitTestCase {
*/
public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) {
/** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit_Framework_MockObject_MockObject $plugin_base */
- $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
- array(),
+ $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [
+ [],
$plugin_id,
- array(),
- ));
+ [],
+ ]);
$this->assertEquals($expected, $plugin_base->getDerivativeId());
}
@@ -85,23 +85,23 @@ class PluginBaseTest extends UnitTestCase {
* @return array
*/
public function providerTestGetDerivativeId() {
- return array(
- array('base_id', NULL),
- array('base_id:derivative', 'derivative'),
- );
+ return [
+ ['base_id', NULL],
+ ['base_id:derivative', 'derivative'],
+ ];
}
/**
* @covers ::getPluginDefinition
*/
public function testGetPluginDefinition() {
- $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
- array(),
+ $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [
+ [],
'plugin_id',
- array('value', array('key' => 'value')),
- ));
+ ['value', ['key' => 'value']],
+ ]);
- $this->assertEquals(array('value', array('key' => 'value')), $plugin_base->getPluginDefinition());
+ $this->assertEquals(['value', ['key' => 'value']], $plugin_base->getPluginDefinition());
}
}
diff --git a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php
index 608479a9493..24a7b089e71 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php
@@ -21,10 +21,10 @@ class PluginManagerBaseTest extends UnitTestCase {
if ('invalid' == $plugin_id) {
throw new PluginNotFoundException($plugin_id);
}
- return array(
+ return [
'plugin_id' => $plugin_id,
'configuration' => $configuration,
- );
+ ];
}
/**
@@ -32,11 +32,11 @@ class PluginManagerBaseTest extends UnitTestCase {
*/
public function getMockFactoryInterface($expects_count) {
$mock_factory = $this->getMockBuilder('Drupal\Component\Plugin\Factory\FactoryInterface')
- ->setMethods(array('createInstance'))
+ ->setMethods(['createInstance'])
->getMockForAbstractClass();
$mock_factory->expects($this->exactly($expects_count))
->method('createInstance')
- ->willReturnCallback(array($this, 'createInstanceCallback'));
+ ->willReturnCallback([$this, 'createInstanceCallback']);
return $mock_factory;
}
@@ -55,7 +55,7 @@ class PluginManagerBaseTest extends UnitTestCase {
$factory_ref->setValue($manager, $this->getMockFactoryInterface(1));
// Finally the test.
- $configuration_array = array('config' => 'something');
+ $configuration_array = ['config' => 'something'];
$result = $manager->createInstance('valid', $configuration_array);
$this->assertEquals('valid', $result['plugin_id']);
$this->assertArrayEquals($configuration_array, $result['configuration']);
@@ -75,7 +75,7 @@ class PluginManagerBaseTest extends UnitTestCase {
$factory_ref->setAccessible(TRUE);
// Set up the configuration array.
- $configuration_array = array('config' => 'something');
+ $configuration_array = ['config' => 'something'];
// Test with fallback interface and valid plugin_id.
$factory_ref->setValue($manager, $this->getMockFactoryInterface(1));
diff --git a/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php b/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php
index 8dc4f08753a..50283c6614b 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php
@@ -20,7 +20,7 @@ class StubFallbackPluginManager extends PluginManagerBase implements FallbackPlu
/**
* {@inheritdoc}
*/
- public function getFallbackPluginId($plugin_id, array $configuration = array()) {
+ public function getFallbackPluginId($plugin_id, array $configuration = []) {
// Minimally implement getFallbackPluginId so that we can test it.
return $plugin_id . '_fallback';
}
diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php
index f81ca0da402..30bf3105007 100644
--- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php
+++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php
@@ -381,7 +381,7 @@ class TestServiceMethodWithParameter {
class TestServiceComplexMethod {
- public function complexMethod($parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = array()) {
+ public function complexMethod($parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = []) {
}
diff --git a/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php b/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php
index fa6c325d01a..bdbe2b3cc8c 100644
--- a/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php
+++ b/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php
@@ -33,21 +33,21 @@ class HtmlEscapedTextTest extends UnitTestCase {
*/
function providerToString() {
// Checks that invalid multi-byte sequences are escaped.
- $tests[] = array("Foo\xC0barbaz", 'Foo�barbaz', 'Escapes invalid sequence "Foo\xC0barbaz"');
- $tests[] = array("\xc2\"", '�&quot;', 'Escapes invalid sequence "\xc2\""');
- $tests[] = array("Fooÿñ", "Fooÿñ", 'Does not escape valid sequence "Fooÿñ"');
+ $tests[] = ["Foo\xC0barbaz", 'Foo�barbaz', 'Escapes invalid sequence "Foo\xC0barbaz"'];
+ $tests[] = ["\xc2\"", '�&quot;', 'Escapes invalid sequence "\xc2\""'];
+ $tests[] = ["Fooÿñ", "Fooÿñ", 'Does not escape valid sequence "Fooÿñ"'];
// Checks that special characters are escaped.
$script_tag = $this->prophesize(MarkupInterface::class);
$script_tag->__toString()->willReturn('<script>');
$script_tag = $script_tag->reveal();
- $tests[] = array($script_tag, '&lt;script&gt;', 'Escapes &lt;script&gt; even inside an object that implements MarkupInterface.');
- $tests[] = array("<script>", '&lt;script&gt;', 'Escapes &lt;script&gt;');
- $tests[] = array('<>&"\'', '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters.');
+ $tests[] = [$script_tag, '&lt;script&gt;', 'Escapes &lt;script&gt; even inside an object that implements MarkupInterface.'];
+ $tests[] = ["<script>", '&lt;script&gt;', 'Escapes &lt;script&gt;'];
+ $tests[] = ['<>&"\'', '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters.'];
$specialchars = $this->prophesize(MarkupInterface::class);
$specialchars->__toString()->willReturn('<>&"\'');
$specialchars = $specialchars->reveal();
- $tests[] = array($specialchars, '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters even inside an object that implements MarkupInterface.');
+ $tests[] = [$specialchars, '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters even inside an object that implements MarkupInterface.'];
return $tests;
}
diff --git a/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php b/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php
index 9898a5fb9e9..65552cf5121 100644
--- a/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php
+++ b/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php
@@ -48,9 +48,9 @@ class JsonTest extends UnitTestCase {
// Characters that must be escaped.
// We check for unescaped " separately.
- $this->htmlUnsafe = array('<', '>', '\'', '&');
+ $this->htmlUnsafe = ['<', '>', '\'', '&'];
// The following are the encoded forms of: < > ' & "
- $this->htmlUnsafeEscaped = array('\u003C', '\u003E', '\u0027', '\u0026', '\u0022');
+ $this->htmlUnsafeEscaped = ['\u003C', '\u003E', '\u0027', '\u0026', '\u0022'];
}
/**
@@ -100,7 +100,7 @@ class JsonTest extends UnitTestCase {
public function testStructuredReversibility() {
// Verify reversibility for structured data. Also verify that necessary
// characters are escaped.
- $source = array(TRUE, FALSE, 0, 1, '0', '1', $this->string, array('key1' => $this->string, 'key2' => array('nested' => TRUE)));
+ $source = [TRUE, FALSE, 0, 1, '0', '1', $this->string, ['key1' => $this->string, 'key2' => ['nested' => TRUE]]];
$json = Json::encode($source);
foreach ($this->htmlUnsafe as $char) {
$this->assertTrue(strpos($json, $char) === FALSE, sprintf('A JSON encoded string does not contain %s.', $char));
diff --git a/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php b/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php
index a3c534aea6c..243fcfd20cd 100644
--- a/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php
+++ b/core/tests/Drupal/Tests/Component/Transliteration/PhpTransliterationTest.php
@@ -40,32 +40,32 @@ class PhpTransliterationTest extends UnitTestCase {
* self::testRemoveDiacritics().
*/
public function providerTestPhpTransliterationRemoveDiacritics() {
- return array(
+ return [
// Test all characters in the Unicode range 0x00bf to 0x017f.
- array('ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ', 'AAAAAAÆCEEEEIIII'),
- array('ÐÑÒÓÔÕÖרÙÚÛÜÝÞß', 'ÐNOOOOO×OUUUUYÞß'),
- array('àáâãäåæçèéêëìíîï', 'aaaaaaæceeeeiiii'),
- array('ðñòóôõö÷øùúûüýþÿ', 'ðnooooo÷ouuuuyþy'),
- array('ĀāĂ㥹ĆćĈĉĊċČčĎď', 'AaAaAaCcCcCcCcDd'),
- array('ĐđĒēĔĕĖėĘęĚěĜĝĞğ', 'DdEeEeEeEeEeGgGg'),
- array('ĠġĢģĤĥĦħĨĩĪīĬĭĮį', 'GgGgHhHhIiIiIiIi'),
- array('İıIJijĴĵĶķĸĹĺĻļĽľĿ', 'IiIJijJjKkĸLlLlLlL'),
- array('ŀŁłŃńŅņŇňʼnŊŋŌōŎŏ', 'lLlNnNnNnʼnŊŋOoOo'),
- array('ŐőŒœŔŕŖŗŘřŚśŜŝŞş', 'OoŒœRrRrRrSsSsSs'),
- array('ŠšŢţŤťŦŧŨũŪūŬŭŮů', 'SsTtTtTtUuUuUuUu'),
- array('ŰűŲųŴŵŶŷŸŹźŻżŽž', 'UuUuWwYyYZzZzZz'),
+ ['ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ', 'AAAAAAÆCEEEEIIII'],
+ ['ÐÑÒÓÔÕÖרÙÚÛÜÝÞß', 'ÐNOOOOO×OUUUUYÞß'],
+ ['àáâãäåæçèéêëìíîï', 'aaaaaaæceeeeiiii'],
+ ['ðñòóôõö÷øùúûüýþÿ', 'ðnooooo÷ouuuuyþy'],
+ ['ĀāĂ㥹ĆćĈĉĊċČčĎď', 'AaAaAaCcCcCcCcDd'],
+ ['ĐđĒēĔĕĖėĘęĚěĜĝĞğ', 'DdEeEeEeEeEeGgGg'],
+ ['ĠġĢģĤĥĦħĨĩĪīĬĭĮį', 'GgGgHhHhIiIiIiIi'],
+ ['İıIJijĴĵĶķĸĹĺĻļĽľĿ', 'IiIJijJjKkĸLlLlLlL'],
+ ['ŀŁłŃńŅņŇňʼnŊŋŌōŎŏ', 'lLlNnNnNnʼnŊŋOoOo'],
+ ['ŐőŒœŔŕŖŗŘřŚśŜŝŞş', 'OoŒœRrRrRrSsSsSs'],
+ ['ŠšŢţŤťŦŧŨũŪūŬŭŮů', 'SsTtTtTtUuUuUuUu'],
+ ['ŰűŲųŴŵŶŷŸŹźŻżŽž', 'UuUuWwYyYZzZzZz'],
// Test all characters in the Unicode range 0x01CD to 0x024F.
- array('ǍǎǏ', 'AaI'),
- array('ǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟ', 'iOoUuUuUuUuUuǝAa'),
- array('ǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯ', 'AaǢǣGgGgKkOoOoǮǯ'),
- array('ǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿ', 'jDZDzdzGgǶǷNnAaǼǽOo'),
- array('ȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏ', 'AaAaEeEeIiIiOoOo'),
- array('ȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ', 'RrRrUuUuSsTtȜȝHh'),
- array('ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯ', 'ȠȡȢȣZzAaEeOoOoOo'),
- array('ȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿ', 'OoYylntjȸȹACcLTs'),
- array('ɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏ', 'zɁɂBUɅEeJjQqRrYy'),
- );
+ ['ǍǎǏ', 'AaI'],
+ ['ǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟ', 'iOoUuUuUuUuUuǝAa'],
+ ['ǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯ', 'AaǢǣGgGgKkOoOoǮǯ'],
+ ['ǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿ', 'jDZDzdzGgǶǷNnAaǼǽOo'],
+ ['ȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏ', 'AaAaEeEeIiIiOoOo'],
+ ['ȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ', 'RrRrUuUuSsTtȜȝHh'],
+ ['ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯ', 'ȠȡȢȣZzAaEeOoOoOo'],
+ ['ȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿ', 'OoYylntjȸȹACcLTs'],
+ ['ɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏ', 'zɁɂBUɅEeJjQqRrYy'],
+ ];
}
/**
@@ -117,36 +117,36 @@ class PhpTransliterationTest extends UnitTestCase {
// They are not in our tables, but should at least give us '?' (unknown).
$five_byte = html_entity_decode('&#x10330;&#x10338;', ENT_NOQUOTES, 'UTF-8');
- return array(
+ return [
// Each test case is (language code, input, output).
// Test ASCII in English.
- array('en', $random, $random),
+ ['en', $random, $random],
// Test ASCII in some other language with no overrides.
- array('fr', $random, $random),
+ ['fr', $random, $random],
// Test 3 and 4-byte characters in a language without overrides.
// Note: if the data tables change, these will need to change too! They
// are set up to test that data table loading works, so values come
// directly from the data files.
- array('fr', $three_byte, 'c'),
- array('fr', $four_byte, 'wii'),
+ ['fr', $three_byte, 'c'],
+ ['fr', $four_byte, 'wii'],
// Test 5-byte characters.
- array('en', $five_byte, '??'),
+ ['en', $five_byte, '??'],
// Test a language with no overrides.
- array('en', $two_byte, 'A O U A O aouaohello'),
+ ['en', $two_byte, 'A O U A O aouaohello'],
// Test language overrides provided by core.
- array('de', $two_byte, 'Ae Oe Ue A O aeoeueaohello'),
- array('de', $random, $random),
- array('dk', $two_byte, 'A O U Aa Oe aouaaoehello'),
- array('dk', $random, $random),
- array('kg', $three_byte, 'ts'),
+ ['de', $two_byte, 'Ae Oe Ue A O aeoeueaohello'],
+ ['de', $random, $random],
+ ['dk', $two_byte, 'A O U Aa Oe aouaaoehello'],
+ ['dk', $random, $random],
+ ['kg', $three_byte, 'ts'],
// Test strings in some other languages.
// Turkish, provided by drupal.org user Kartagis.
- array('tr', 'Abayı serdiler bize. Söyleyeceğim yüzlerine. Sanırım hepimiz aynı şeyi düşünüyoruz.', 'Abayi serdiler bize. Soyleyecegim yuzlerine. Sanirim hepimiz ayni seyi dusunuyoruz.'),
+ ['tr', 'Abayı serdiler bize. Söyleyeceğim yüzlerine. Sanırım hepimiz aynı şeyi düşünüyoruz.', 'Abayi serdiler bize. Soyleyecegim yuzlerine. Sanirim hepimiz ayni seyi dusunuyoruz.'],
// Illegal/unknown unicode.
- array('en', chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), '?'),
+ ['en', chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), '?'],
// Max length.
- array('de', $two_byte, 'Ae Oe', '?', 5),
- );
+ ['de', $two_byte, 'Ae Oe', '?', 5],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/Utility/BytesTest.php b/core/tests/Drupal/Tests/Component/Utility/BytesTest.php
index f4ebf0e67d3..35872ac4bbe 100644
--- a/core/tests/Drupal/Tests/Component/Utility/BytesTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/BytesTest.php
@@ -40,21 +40,21 @@ class BytesTest extends UnitTestCase {
* value.
*/
public function providerTestToInt() {
- return array(
- array('1', 1),
- array('1 byte', 1),
- array('1 KB' , Bytes::KILOBYTE),
- array('1 MB' , pow(Bytes::KILOBYTE, 2)),
- array('1 GB' , pow(Bytes::KILOBYTE, 3)),
- array('1 TB' , pow(Bytes::KILOBYTE, 4)),
- array('1 PB' , pow(Bytes::KILOBYTE, 5)),
- array('1 EB' , pow(Bytes::KILOBYTE, 6)),
- array('1 ZB' , pow(Bytes::KILOBYTE, 7)),
- array('1 YB' , pow(Bytes::KILOBYTE, 8)),
- array('23476892 bytes', 23476892),
- array('76MRandomStringThatShouldBeIgnoredByParseSize.', 79691776), // 76 MB
- array('76.24 Giggabyte', 81862076662), // 76.24 GB (with typo)
- );
+ return [
+ ['1', 1],
+ ['1 byte', 1],
+ ['1 KB' , Bytes::KILOBYTE],
+ ['1 MB' , pow(Bytes::KILOBYTE, 2)],
+ ['1 GB' , pow(Bytes::KILOBYTE, 3)],
+ ['1 TB' , pow(Bytes::KILOBYTE, 4)],
+ ['1 PB' , pow(Bytes::KILOBYTE, 5)],
+ ['1 EB' , pow(Bytes::KILOBYTE, 6)],
+ ['1 ZB' , pow(Bytes::KILOBYTE, 7)],
+ ['1 YB' , pow(Bytes::KILOBYTE, 8)],
+ ['23476892 bytes', 23476892],
+ ['76MRandomStringThatShouldBeIgnoredByParseSize.', 79691776], // 76 MB
+ ['76.24 Giggabyte', 81862076662], // 76.24 GB (with typo)
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/ColorTest.php b/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
index c65bf55a097..e2f1629198f 100644
--- a/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
@@ -43,35 +43,35 @@ class ColorTest extends UnitTestCase {
* - (optional) Boolean indicating invalid status. Defaults to FALSE.
*/
public function providerTestHexToRgb() {
- $invalid = array();
+ $invalid = [];
// Any invalid arguments should throw an exception.
- foreach (array('', '-1', '1', '12', '12345', '1234567', '123456789', '123456789a', 'foo') as $value) {
- $invalid[] = array($value, '', TRUE);
+ foreach (['', '-1', '1', '12', '12345', '1234567', '123456789', '123456789a', 'foo'] as $value) {
+ $invalid[] = [$value, '', TRUE];
}
// Duplicate all invalid value tests with additional '#' prefix.
// The '#' prefix inherently turns the data type into a string.
foreach ($invalid as $value) {
- $invalid[] = array('#' . $value[0], '', TRUE);
+ $invalid[] = ['#' . $value[0], '', TRUE];
}
// Add invalid data types (hex value must be a string).
- foreach (array(
+ foreach ([
1, 12, 1234, 12345, 123456, 1234567, 12345678, 123456789, 123456789,
-1, PHP_INT_MAX, PHP_INT_MAX + 1, -PHP_INT_MAX, 0x0, 0x010
- ) as $value) {
- $invalid[] = array($value, '', TRUE);
+ ] as $value) {
+ $invalid[] = [$value, '', TRUE];
}
// And some valid values.
- $valid = array(
+ $valid = [
// Shorthands without alpha.
- array('hex' => '#000', 'rgb' => array('red' => 0, 'green' => 0, 'blue' => 0)),
- array('hex' => '#fff', 'rgb' => array('red' => 255, 'green' => 255, 'blue' => 255)),
- array('hex' => '#abc', 'rgb' => array('red' => 170, 'green' => 187, 'blue' => 204)),
- array('hex' => 'cba', 'rgb' => array('red' => 204, 'green' => 187, 'blue' => 170)),
+ ['hex' => '#000', 'rgb' => ['red' => 0, 'green' => 0, 'blue' => 0]],
+ ['hex' => '#fff', 'rgb' => ['red' => 255, 'green' => 255, 'blue' => 255]],
+ ['hex' => '#abc', 'rgb' => ['red' => 170, 'green' => 187, 'blue' => 204]],
+ ['hex' => 'cba', 'rgb' => ['red' => 204, 'green' => 187, 'blue' => 170]],
// Full without alpha.
- array('hex' => '#000000', 'rgb' => array('red' => 0, 'green' => 0, 'blue' => 0)),
- array('hex' => '#ffffff', 'rgb' => array('red' => 255, 'green' => 255, 'blue' => 255)),
- array('hex' => '#010203', 'rgb' => array('red' => 1, 'green' => 2, 'blue' => 3)),
- );
+ ['hex' => '#000000', 'rgb' => ['red' => 0, 'green' => 0, 'blue' => 0]],
+ ['hex' => '#ffffff', 'rgb' => ['red' => 255, 'green' => 255, 'blue' => 255]],
+ ['hex' => '#010203', 'rgb' => ['red' => 1, 'green' => 2, 'blue' => 3]],
+ ];
return array_merge($invalid, $valid);
}
@@ -101,19 +101,19 @@ class ColorTest extends UnitTestCase {
*/
public function providerTestRbgToHex() {
// Input using named RGB array (e.g., as returned by Color::hexToRgb()).
- $tests = array(
- array(array('red' => 0, 'green' => 0, 'blue' => 0), '#000000'),
- array(array('red' => 255, 'green' => 255, 'blue' => 255), '#ffffff'),
- array(array('red' => 119, 'green' => 119, 'blue' => 119), '#777777'),
- array(array('red' => 1, 'green' => 2, 'blue' => 3), '#010203'),
- );
+ $tests = [
+ [['red' => 0, 'green' => 0, 'blue' => 0], '#000000'],
+ [['red' => 255, 'green' => 255, 'blue' => 255], '#ffffff'],
+ [['red' => 119, 'green' => 119, 'blue' => 119], '#777777'],
+ [['red' => 1, 'green' => 2, 'blue' => 3], '#010203'],
+ ];
// Input using indexed RGB array (e.g.: array(10, 10, 10)).
foreach ($tests as $test) {
- $tests[] = array(array_values($test[0]), $test[1]);
+ $tests[] = [array_values($test[0]), $test[1]];
}
// Input using CSS RGB string notation (e.g.: 10, 10, 10).
foreach ($tests as $test) {
- $tests[] = array(implode(', ', $test[0]), $test[1]);
+ $tests[] = [implode(', ', $test[0]), $test[1]];
}
return $tests;
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
index 42d6015158a..f7091713d23 100644
--- a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
@@ -87,16 +87,16 @@ class CryptTest extends UnitTestCase {
* @return array Test data.
*/
public function providerTestHashBase64() {
- return array(
- array(
+ return [
+ [
'data' => 'The SHA (Secure Hash Algorithm) is one of a number of cryptographic hash functions. A cryptographic hash is like a signature for a text or a data file. SHA-256 algorithm generates an almost-unique, fixed size 256-bit (32-byte) hash. Hash is a one way function – it cannot be decrypted back. This makes it suitable for password validation, challenge hash authentication, anti-tamper, digital signatures.',
'expectedHash' => '034rT6smZAVRxpq8O98cFFNLIVx_Ph1EwLZQKcmRR_s',
- ),
- array(
+ ],
+ [
'data' => 'SHA-256 is one of the successor hash functions to SHA-1, and is one of the strongest hash functions available.',
'expected_hash' => 'yuqkDDYqprL71k4xIb6K6D7n76xldO4jseRhEkEE6SI',
- ),
- );
+ ],
+ ];
}
/**
@@ -105,13 +105,13 @@ class CryptTest extends UnitTestCase {
* @return array Test data.
*/
public function providerTestHmacBase64() {
- return array(
- array(
+ return [
+ [
'data' => 'Calculates a base-64 encoded, URL-safe sha-256 hmac.',
'key' => 'secret-key',
'expected_hmac' => '2AaH63zwjhekWZlEpAiufyfhAHIzbQhl9Hd9oCi3_c8',
- ),
- );
+ ],
+ ];
}
/**
@@ -120,33 +120,33 @@ class CryptTest extends UnitTestCase {
* @return array Test data.
*/
public function providerTestHmacBase64Invalid() {
- return array(
- array(new \stdClass(), new \stdClass()),
- array(new \stdClass(), 'string'),
- array(new \stdClass(), 1),
- array(new \stdClass(), 0),
- array(NULL, new \stdClass()),
- array('string', new \stdClass()),
- array(1, new \stdClass()),
- array(0, new \stdClass()),
- array(array(), array()),
- array(array(), NULL),
- array(array(), 'string'),
- array(array(), 1),
- array(array(), 0),
- array(NULL, array()),
- array(1, array()),
- array(0, array()),
- array('string', array()),
- array(array(), NULL),
- array(NULL, NULL),
- array(NULL, 'string'),
- array(NULL, 1),
- array(NULL, 0),
- array(1, NULL),
- array(0, NULL),
- array('string', NULL),
- );
+ return [
+ [new \stdClass(), new \stdClass()],
+ [new \stdClass(), 'string'],
+ [new \stdClass(), 1],
+ [new \stdClass(), 0],
+ [NULL, new \stdClass()],
+ ['string', new \stdClass()],
+ [1, new \stdClass()],
+ [0, new \stdClass()],
+ [[], []],
+ [[], NULL],
+ [[], 'string'],
+ [[], 1],
+ [[], 0],
+ [NULL, []],
+ [1, []],
+ [0, []],
+ ['string', []],
+ [[], NULL],
+ [NULL, NULL],
+ [NULL, 'string'],
+ [NULL, 1],
+ [NULL, 0],
+ [1, NULL],
+ [0, NULL],
+ ['string', NULL],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php b/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php
index b240e4e0da4..708eee9ab1d 100644
--- a/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php
@@ -47,16 +47,16 @@ class EnvironmentTest extends UnitTestCase {
$memory_limit = ini_get('memory_limit');
$twice_avail_memory = ($memory_limit * 2) . 'MB';
- return array(
+ return [
// Minimal amount of memory should be available.
- array('30MB', NULL, TRUE),
+ ['30MB', NULL, TRUE],
// Exceed a custom (unlimited) memory limit.
- array($twice_avail_memory, -1, TRUE),
+ [$twice_avail_memory, -1, TRUE],
// Exceed a custom memory limit.
- array('30MB', '16MB', FALSE),
+ ['30MB', '16MB', FALSE],
// Available = required.
- array('30MB', '30MB', TRUE),
- );
+ ['30MB', '30MB', TRUE],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
index 6a106c7b9e4..8bab1c7f03c 100644
--- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
@@ -59,25 +59,25 @@ class HtmlTest extends UnitTestCase {
$id1 = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789';
$id2 = '¡¢£¤¥';
$id3 = 'css__identifier__with__double__underscores';
- return array(
+ return [
// Verify that no valid ASCII characters are stripped from the identifier.
- array($id1, $id1, array()),
+ [$id1, $id1, []],
// Verify that valid UTF-8 characters are not stripped from the identifier.
- array($id2, $id2, array()),
+ [$id2, $id2, []],
// Verify that invalid characters (including non-breaking space) are stripped from the identifier.
- array($id3, $id3),
+ [$id3, $id3],
// Verify that double underscores are not stripped from the identifier.
- array('invalididentifier', 'invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()),
+ ['invalididentifier', 'invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', []],
// Verify that an identifier starting with a digit is replaced.
- array('_cssidentifier', '1cssidentifier', array()),
+ ['_cssidentifier', '1cssidentifier', []],
// Verify that an identifier starting with a hyphen followed by a digit is
// replaced.
- array('__cssidentifier', '-1cssidentifier', array()),
+ ['__cssidentifier', '-1cssidentifier', []],
// Verify that an identifier starting with two hyphens is replaced.
- array('__cssidentifier', '--cssidentifier', array()),
+ ['__cssidentifier', '--cssidentifier', []],
// Verify that passing double underscores as a filter is processed.
- array('_cssidentifier', '__cssidentifier', array('__' => '_')),
- );
+ ['_cssidentifier', '__cssidentifier', ['__' => '_']],
+ ];
}
/**
@@ -119,18 +119,18 @@ class HtmlTest extends UnitTestCase {
*/
public function providerTestHtmlGetUniqueId() {
$id = 'abcdefghijklmnopqrstuvwxyz-0123456789';
- return array(
+ return [
// Verify that letters, digits, and hyphens are not stripped from the ID.
- array($id, $id),
+ [$id, $id],
// Verify that invalid characters are stripped from the ID.
- array('invalididentifier', 'invalid,./:@\\^`{Üidentifier'),
+ ['invalididentifier', 'invalid,./:@\\^`{Üidentifier'],
// Verify Drupal coding standards are enforced.
- array('id-name-1', 'ID NAME_[1]'),
+ ['id-name-1', 'ID NAME_[1]'],
// Verify that a repeated ID is made unique.
- array('test-unique-id', 'test-unique-id', TRUE),
- array('test-unique-id--2', 'test-unique-id'),
- array('test-unique-id--3', 'test-unique-id'),
- );
+ ['test-unique-id', 'test-unique-id', TRUE],
+ ['test-unique-id--2', 'test-unique-id'],
+ ['test-unique-id--3', 'test-unique-id'],
+ ];
}
/**
@@ -168,13 +168,13 @@ class HtmlTest extends UnitTestCase {
* Test data.
*/
public function providerTestHtmlGetUniqueIdWithAjaxIds() {
- return array(
- array('test-unique-id1--', 'test-unique-id1'),
+ return [
+ ['test-unique-id1--', 'test-unique-id1'],
// Note, we truncate two hyphens at the end.
// @see \Drupal\Component\Utility\Html::getId()
- array('test-unique-id1---', 'test-unique-id1--'),
- array('test-unique-id2--', 'test-unique-id2'),
- );
+ ['test-unique-id1---', 'test-unique-id1--'],
+ ['test-unique-id2--', 'test-unique-id2'],
+ ];
}
/**
@@ -202,17 +202,17 @@ class HtmlTest extends UnitTestCase {
*/
public function providerTestHtmlGetId() {
$id = 'abcdefghijklmnopqrstuvwxyz-0123456789';
- return array(
+ return [
// Verify that letters, digits, and hyphens are not stripped from the ID.
- array($id, $id),
+ [$id, $id],
// Verify that invalid characters are stripped from the ID.
- array('invalididentifier', 'invalid,./:@\\^`{Üidentifier'),
+ ['invalididentifier', 'invalid,./:@\\^`{Üidentifier'],
// Verify Drupal coding standards are enforced.
- array('id-name-1', 'ID NAME_[1]'),
+ ['id-name-1', 'ID NAME_[1]'],
// Verify that a repeated ID is made unique.
- array('test-unique-id', 'test-unique-id'),
- array('test-unique-id', 'test-unique-id'),
- );
+ ['test-unique-id', 'test-unique-id'],
+ ['test-unique-id', 'test-unique-id'],
+ ];
}
/**
@@ -231,29 +231,29 @@ class HtmlTest extends UnitTestCase {
* @see testDecodeEntities()
*/
public function providerDecodeEntities() {
- return array(
- array('Drupal', 'Drupal'),
- array('<script>', '<script>'),
- array('&lt;script&gt;', '<script>'),
- array('&#60;script&#62;', '<script>'),
- array('&amp;lt;script&amp;gt;', '&lt;script&gt;'),
- array('"', '"'),
- array('&#34;', '"'),
- array('&amp;#34;', '&#34;'),
- array('&quot;', '"'),
- array('&amp;quot;', '&quot;'),
- array("'", "'"),
- array('&#39;', "'"),
- array('&amp;#39;', '&#39;'),
- array('©', '©'),
- array('&copy;', '©'),
- array('&#169;', '©'),
- array('→', '→'),
- array('&#8594;', '→'),
- array('➼', '➼'),
- array('&#10172;', '➼'),
- array('&euro;', '€'),
- );
+ return [
+ ['Drupal', 'Drupal'],
+ ['<script>', '<script>'],
+ ['&lt;script&gt;', '<script>'],
+ ['&#60;script&#62;', '<script>'],
+ ['&amp;lt;script&amp;gt;', '&lt;script&gt;'],
+ ['"', '"'],
+ ['&#34;', '"'],
+ ['&amp;#34;', '&#34;'],
+ ['&quot;', '"'],
+ ['&amp;quot;', '&quot;'],
+ ["'", "'"],
+ ['&#39;', "'"],
+ ['&amp;#39;', '&#39;'],
+ ['©', '©'],
+ ['&copy;', '©'],
+ ['&#169;', '©'],
+ ['→', '→'],
+ ['&#8594;', '→'],
+ ['➼', '➼'],
+ ['&#10172;', '➼'],
+ ['&euro;', '€'],
+ ];
}
/**
@@ -272,21 +272,21 @@ class HtmlTest extends UnitTestCase {
* @see testEscape()
*/
public function providerEscape() {
- return array(
- array('Drupal', 'Drupal'),
- array('&lt;script&gt;', '<script>'),
- array('&amp;lt;script&amp;gt;', '&lt;script&gt;'),
- array('&amp;#34;', '&#34;'),
- array('&quot;', '"'),
- array('&amp;quot;', '&quot;'),
- array('&#039;', "'"),
- array('&amp;#039;', '&#039;'),
- array('©', '©'),
- array('→', '→'),
- array('➼', '➼'),
- array('€', '€'),
- array('Drup�al', "Drup\x80al"),
- );
+ return [
+ ['Drupal', 'Drupal'],
+ ['&lt;script&gt;', '<script>'],
+ ['&amp;lt;script&amp;gt;', '&lt;script&gt;'],
+ ['&amp;#34;', '&#34;'],
+ ['&quot;', '"'],
+ ['&amp;quot;', '&quot;'],
+ ['&#039;', "'"],
+ ['&amp;#039;', '&#039;'],
+ ['©', '©'],
+ ['→', '→'],
+ ['➼', '➼'],
+ ['€', '€'],
+ ['Drup�al', "Drup\x80al"],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/Utility/ImageTest.php b/core/tests/Drupal/Tests/Component/Utility/ImageTest.php
index 7c3a5ac1295..eec1375eaef 100644
--- a/core/tests/Drupal/Tests/Component/Utility/ImageTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/ImageTest.php
@@ -44,113 +44,113 @@ class ImageTest extends UnitTestCase {
*/
public function providerTestScaleDimensions() {
// Define input / output datasets to test different branch conditions.
- $tests = array();
+ $tests = [];
// Test branch conditions:
// - No height.
// - Upscale, don't need to upscale.
- $tests[] = array(
- 'input' => array(
- 'dimensions' => array(
+ $tests[] = [
+ 'input' => [
+ 'dimensions' => [
'width' => 1000,
'height' => 2000,
- ),
+ ],
'width' => 200,
'height' => NULL,
'upscale' => TRUE,
- ),
- 'output' => array(
- 'dimensions' => array(
+ ],
+ 'output' => [
+ 'dimensions' => [
'width' => 200,
'height' => 400,
- ),
+ ],
'return_value' => TRUE,
- ),
- );
+ ],
+ ];
// Test branch conditions:
// - No width.
// - Don't upscale, don't need to upscale.
- $tests[] = array(
- 'input' => array(
- 'dimensions' => array(
+ $tests[] = [
+ 'input' => [
+ 'dimensions' => [
'width' => 1000,
'height' => 800,
- ),
+ ],
'width' => NULL,
'height' => 140,
'upscale' => FALSE,
- ),
- 'output' => array(
- 'dimensions' => array(
+ ],
+ 'output' => [
+ 'dimensions' => [
'width' => 175,
'height' => 140,
- ),
+ ],
'return_value' => TRUE,
- ),
- );
+ ],
+ ];
// Test branch conditions:
// - Source aspect ratio greater than target.
// - Upscale, need to upscale.
- $tests[] = array(
- 'input' => array(
- 'dimensions' => array(
+ $tests[] = [
+ 'input' => [
+ 'dimensions' => [
'width' => 8,
'height' => 20,
- ),
+ ],
'width' => 200,
'height' => 140,
'upscale' => TRUE,
- ),
- 'output' => array(
- 'dimensions' => array(
+ ],
+ 'output' => [
+ 'dimensions' => [
'width' => 56,
'height' => 140,
- ),
+ ],
'return_value' => TRUE,
- ),
- );
+ ],
+ ];
// Test branch condition: target aspect ratio greater than source.
- $tests[] = array(
- 'input' => array(
- 'dimensions' => array(
+ $tests[] = [
+ 'input' => [
+ 'dimensions' => [
'width' => 2000,
'height' => 800,
- ),
+ ],
'width' => 200,
'height' => 140,
'upscale' => FALSE,
- ),
- 'output' => array(
- 'dimensions' => array(
+ ],
+ 'output' => [
+ 'dimensions' => [
'width' => 200,
'height' => 80,
- ),
+ ],
'return_value' => TRUE,
- ),
- );
+ ],
+ ];
// Test branch condition: don't upscale, need to upscale.
- $tests[] = array(
- 'input' => array(
- 'dimensions' => array(
+ $tests[] = [
+ 'input' => [
+ 'dimensions' => [
'width' => 100,
'height' => 50,
- ),
+ ],
'width' => 200,
'height' => 140,
'upscale' => FALSE,
- ),
- 'output' => array(
- 'dimensions' => array(
+ ],
+ 'output' => [
+ 'dimensions' => [
'width' => 100,
'height' => 50,
- ),
+ ],
'return_value' => FALSE,
- ),
- );
+ ],
+ ];
return $tests;
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php b/core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php
index 92db2ac8ac6..0371ebb3503 100644
--- a/core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php
@@ -32,12 +32,12 @@ class NestedArrayTest extends UnitTestCase {
parent::setUp();
// Create a form structure with a nested element.
- $this->form['details']['element'] = array(
+ $this->form['details']['element'] = [
'#value' => 'Nested element',
- );
+ ];
// Set up parent array.
- $this->parents = array('details', 'element');
+ $this->parents = ['details', 'element'];
}
/**
@@ -76,10 +76,10 @@ class NestedArrayTest extends UnitTestCase {
* @covers ::setValue
*/
public function testSetValue() {
- $new_value = array(
+ $new_value = [
'#value' => 'New value',
'#required' => TRUE,
- );
+ ];
// Verify setting the value of a nested element.
NestedArray::setValue($this->form, $this->parents, $new_value);
@@ -93,11 +93,11 @@ class NestedArrayTest extends UnitTestCase {
* @covers ::setValue
*/
public function testSetValueForce() {
- $new_value = array(
+ $new_value = [
'one',
- );
+ ];
$this->form['details']['non-array-parent'] = 'string';
- $parents = array('details', 'non-array-parent', 'child');
+ $parents = ['details', 'non-array-parent', 'child'];
NestedArray::setValue($this->form, $parents, $new_value, TRUE);
$this->assertSame($new_value, $this->form['details']['non-array-parent']['child'], 'The nested element was not forced to the new value.');
}
@@ -144,23 +144,23 @@ class NestedArrayTest extends UnitTestCase {
* @covers ::mergeDeepArray
*/
public function testMergeDeepArray() {
- $link_options_1 = array(
+ $link_options_1 = [
'fragment' => 'x',
- 'attributes' => array('title' => 'X', 'class' => array('a', 'b')),
+ 'attributes' => ['title' => 'X', 'class' => ['a', 'b']],
'language' => 'en',
- );
- $link_options_2 = array(
+ ];
+ $link_options_2 = [
'fragment' => 'y',
- 'attributes' => array('title' => 'Y', 'class' => array('c', 'd')),
+ 'attributes' => ['title' => 'Y', 'class' => ['c', 'd']],
'absolute' => TRUE,
- );
- $expected = array(
+ ];
+ $expected = [
'fragment' => 'y',
- 'attributes' => array('title' => 'Y', 'class' => array('a', 'b', 'c', 'd')),
+ 'attributes' => ['title' => 'Y', 'class' => ['a', 'b', 'c', 'd']],
'language' => 'en',
'absolute' => TRUE,
- );
- $this->assertSame($expected, NestedArray::mergeDeepArray(array($link_options_1, $link_options_2)), 'NestedArray::mergeDeepArray() returned a properly merged array.');
+ ];
+ $this->assertSame($expected, NestedArray::mergeDeepArray([$link_options_1, $link_options_2]), 'NestedArray::mergeDeepArray() returned a properly merged array.');
// Test wrapper function, NestedArray::mergeDeep().
$this->assertSame($expected, NestedArray::mergeDeep($link_options_1, $link_options_2), 'NestedArray::mergeDeep() returned a properly merged array.');
}
@@ -171,18 +171,18 @@ class NestedArrayTest extends UnitTestCase {
* @covers ::mergeDeepArray
*/
public function testMergeImplicitKeys() {
- $a = array(
- 'subkey' => array('X', 'Y'),
- );
- $b = array(
- 'subkey' => array('X'),
- );
+ $a = [
+ 'subkey' => ['X', 'Y'],
+ ];
+ $b = [
+ 'subkey' => ['X'],
+ ];
// Drupal core behavior.
- $expected = array(
- 'subkey' => array('X', 'Y', 'X'),
- );
- $actual = NestedArray::mergeDeepArray(array($a, $b));
+ $expected = [
+ 'subkey' => ['X', 'Y', 'X'],
+ ];
+ $actual = NestedArray::mergeDeepArray([$a, $b]);
$this->assertSame($expected, $actual, 'drupal_array_merge_deep() creates new numeric keys in the implicit sequence.');
}
@@ -192,29 +192,29 @@ class NestedArrayTest extends UnitTestCase {
* @covers ::mergeDeepArray
*/
public function testMergeExplicitKeys() {
- $a = array(
- 'subkey' => array(
+ $a = [
+ 'subkey' => [
0 => 'A',
1 => 'B',
- ),
- );
- $b = array(
- 'subkey' => array(
+ ],
+ ];
+ $b = [
+ 'subkey' => [
0 => 'C',
1 => 'D',
- ),
- );
+ ],
+ ];
// Drupal core behavior.
- $expected = array(
- 'subkey' => array(
+ $expected = [
+ 'subkey' => [
0 => 'A',
1 => 'B',
2 => 'C',
3 => 'D',
- ),
- );
- $actual = NestedArray::mergeDeepArray(array($a, $b));
+ ],
+ ];
+ $actual = NestedArray::mergeDeepArray([$a, $b]);
$this->assertSame($expected, $actual, 'drupal_array_merge_deep() creates new numeric keys in the explicit sequence.');
}
@@ -228,29 +228,29 @@ class NestedArrayTest extends UnitTestCase {
* @covers ::mergeDeepArray
*/
public function testMergeOutOfSequenceKeys() {
- $a = array(
- 'subkey' => array(
+ $a = [
+ 'subkey' => [
10 => 'A',
30 => 'B',
- ),
- );
- $b = array(
- 'subkey' => array(
+ ],
+ ];
+ $b = [
+ 'subkey' => [
20 => 'C',
0 => 'D',
- ),
- );
+ ],
+ ];
// Drupal core behavior.
- $expected = array(
- 'subkey' => array(
+ $expected = [
+ 'subkey' => [
0 => 'A',
1 => 'B',
2 => 'C',
3 => 'D',
- ),
- );
- $actual = NestedArray::mergeDeepArray(array($a, $b));
+ ],
+ ];
+ $actual = NestedArray::mergeDeepArray([$a, $b]);
$this->assertSame($expected, $actual, 'drupal_array_merge_deep() ignores numeric key order when merging.');
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/NumberTest.php b/core/tests/Drupal/Tests/Component/Utility/NumberTest.php
index 3e326296600..8d415de92b3 100644
--- a/core/tests/Drupal/Tests/Component/Utility/NumberTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/NumberTest.php
@@ -60,36 +60,36 @@ class NumberTest extends UnitTestCase {
* @see \Drupal\Tests\Component\Utility\Number::testValidStep
*/
public static function providerTestValidStep() {
- return array(
+ return [
// Value and step equal.
- array(10.3, 10.3, TRUE),
+ [10.3, 10.3, TRUE],
// Valid integer steps.
- array(42, 21, TRUE),
- array(42, 3, TRUE),
+ [42, 21, TRUE],
+ [42, 3, TRUE],
// Valid float steps.
- array(42, 10.5, TRUE),
- array(1, 1 / 3, TRUE),
- array(-100, 100 / 7, TRUE),
- array(1000, -10, TRUE),
+ [42, 10.5, TRUE],
+ [1, 1 / 3, TRUE],
+ [-100, 100 / 7, TRUE],
+ [1000, -10, TRUE],
// Valid and very small float steps.
- array(1000.12345, 1e-10, TRUE),
- array(3.9999999999999, 1e-13, TRUE),
+ [1000.12345, 1e-10, TRUE],
+ [3.9999999999999, 1e-13, TRUE],
// Invalid integer steps.
- array(100, 30, FALSE),
- array(-10, 4, FALSE),
+ [100, 30, FALSE],
+ [-10, 4, FALSE],
// Invalid float steps.
- array(6, 5 / 7, FALSE),
- array(10.3, 10.25, FALSE),
+ [6, 5 / 7, FALSE],
+ [10.3, 10.25, FALSE],
// Step mismatches very close to being valid.
- array(70 + 9e-7, 10 + 9e-7, FALSE),
- array(1936.5, 3e-8, FALSE),
- );
+ [70 + 9e-7, 10 + 9e-7, FALSE],
+ [1936.5, 3e-8, FALSE],
+ ];
}
/**
@@ -98,22 +98,22 @@ class NumberTest extends UnitTestCase {
* @see \Drupal\Test\Component\Utility\NumberTest::testValidStepOffset()
*/
public static function providerTestValidStepOffset() {
- return array(
+ return [
// Try obvious fits.
- array(11.3, 10.3, 1, TRUE),
- array(100, 10, 50, TRUE),
- array(-100, 90 / 7, -10, TRUE),
- array(2 / 7 + 5 / 9, 1 / 7, 5 / 9, TRUE),
+ [11.3, 10.3, 1, TRUE],
+ [100, 10, 50, TRUE],
+ [-100, 90 / 7, -10, TRUE],
+ [2 / 7 + 5 / 9, 1 / 7, 5 / 9, TRUE],
// Ensure a small offset is still invalid.
- array(10.3, 10.3, 0.0001, FALSE),
- array(1 / 5, 1 / 7, 1 / 11, FALSE),
+ [10.3, 10.3, 0.0001, FALSE],
+ [1 / 5, 1 / 7, 1 / 11, FALSE],
// Try negative values and offsets.
- array(1000, 10, -5, FALSE),
- array(-10, 4, 0, FALSE),
- array(-10, 4, -4, FALSE),
- );
+ [1000, 10, -5, FALSE],
+ [-10, 4, 0, FALSE],
+ [-10, 4, -4, FALSE],
+ ];
}
/**
@@ -144,15 +144,15 @@ class NumberTest extends UnitTestCase {
* - The alphadecimal value.
*/
public function providerTestConversions() {
- return array(
- array(0, '00'),
- array(1, '01'),
- array(10, '0a'),
- array(20, '0k'),
- array(35, '0z'),
- array(36, '110'),
- array(100, '12s'),
- );
+ return [
+ [0, '00'],
+ [1, '01'],
+ [10, '0a'],
+ [20, '0k'],
+ [35, '0z'],
+ [36, '110'],
+ [100, '12s'],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
index b6775852689..e8cc6f663e4 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
@@ -29,7 +29,7 @@ class RandomTest extends UnitTestCase {
* @covers ::string
*/
public function testRandomStringUniqueness() {
- $strings = array();
+ $strings = [];
$random = new Random();
for ($i = 0; $i <= 50; $i++) {
$str = $random->string(1, TRUE);
@@ -44,7 +44,7 @@ class RandomTest extends UnitTestCase {
* @covers ::name
*/
public function testRandomNamesUniqueness() {
- $names = array();
+ $names = [];
$random = new Random();
for ($i = 0; $i <= 10; $i++) {
$str = $random->name(1, TRUE);
@@ -138,7 +138,7 @@ class RandomTest extends UnitTestCase {
public function testRandomStringValidator() {
$random = new Random();
$this->firstStringGenerated = '';
- $str = $random->string(1, TRUE, array($this, '_RandomStringValidate'));
+ $str = $random->string(1, TRUE, [$this, '_RandomStringValidate']);
$this->assertNotEquals($this->firstStringGenerated, $str);
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
index 8c1fdcec13a..7495fa5f015 100644
--- a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
@@ -89,15 +89,15 @@ class SafeMarkupTest extends UnitTestCase {
*/
function providerCheckPlain() {
// Checks that invalid multi-byte sequences are escaped.
- $tests[] = array("Foo\xC0barbaz", 'Foo�barbaz', 'Escapes invalid sequence "Foo\xC0barbaz"');
- $tests[] = array("\xc2\"", '�&quot;', 'Escapes invalid sequence "\xc2\""');
- $tests[] = array("Fooÿñ", "Fooÿñ", 'Does not escape valid sequence "Fooÿñ"');
+ $tests[] = ["Foo\xC0barbaz", 'Foo�barbaz', 'Escapes invalid sequence "Foo\xC0barbaz"'];
+ $tests[] = ["\xc2\"", '�&quot;', 'Escapes invalid sequence "\xc2\""'];
+ $tests[] = ["Fooÿñ", "Fooÿñ", 'Does not escape valid sequence "Fooÿñ"'];
// Checks that special characters are escaped.
- $tests[] = array(SafeMarkupTestMarkup::create("<script>"), '&lt;script&gt;', 'Escapes &lt;script&gt; even inside an object that implements MarkupInterface.');
- $tests[] = array("<script>", '&lt;script&gt;', 'Escapes &lt;script&gt;');
- $tests[] = array('<>&"\'', '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters.');
- $tests[] = array(SafeMarkupTestMarkup::create('<>&"\''), '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters even inside an object that implements MarkupInterface.');
+ $tests[] = [SafeMarkupTestMarkup::create("<script>"), '&lt;script&gt;', 'Escapes &lt;script&gt; even inside an object that implements MarkupInterface.'];
+ $tests[] = ["<script>", '&lt;script&gt;', 'Escapes &lt;script&gt;'];
+ $tests[] = ['<>&"\'', '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters.'];
+ $tests[] = [SafeMarkupTestMarkup::create('<>&"\''), '&lt;&gt;&amp;&quot;&#039;', 'Escapes reserved HTML characters even inside an object that implements MarkupInterface.'];
return $tests;
}
@@ -137,11 +137,11 @@ class SafeMarkupTest extends UnitTestCase {
* @see testFormat()
*/
function providerFormat() {
- $tests[] = array('Simple text', array(), 'Simple text', 'SafeMarkup::format leaves simple text alone.', TRUE);
- $tests[] = array('Escaped text: @value', array('@value' => '<script>'), 'Escaped text: &lt;script&gt;', 'SafeMarkup::format replaces and escapes string.', TRUE);
- $tests[] = array('Escaped text: @value', array('@value' => SafeMarkupTestMarkup::create('<span>Safe HTML</span>')), 'Escaped text: <span>Safe HTML</span>', 'SafeMarkup::format does not escape an already safe string.', TRUE);
- $tests[] = array('Placeholder text: %value', array('%value' => '<script>'), 'Placeholder text: <em class="placeholder">&lt;script&gt;</em>', 'SafeMarkup::format replaces, escapes and themes string.', TRUE);
- $tests[] = array('Placeholder text: %value', array('%value' => SafeMarkupTestMarkup::create('<span>Safe HTML</span>')), 'Placeholder text: <em class="placeholder"><span>Safe HTML</span></em>', 'SafeMarkup::format does not escape an already safe string themed as a placeholder.', TRUE);
+ $tests[] = ['Simple text', [], 'Simple text', 'SafeMarkup::format leaves simple text alone.', TRUE];
+ $tests[] = ['Escaped text: @value', ['@value' => '<script>'], 'Escaped text: &lt;script&gt;', 'SafeMarkup::format replaces and escapes string.', TRUE];
+ $tests[] = ['Escaped text: @value', ['@value' => SafeMarkupTestMarkup::create('<span>Safe HTML</span>')], 'Escaped text: <span>Safe HTML</span>', 'SafeMarkup::format does not escape an already safe string.', TRUE];
+ $tests[] = ['Placeholder text: %value', ['%value' => '<script>'], 'Placeholder text: <em class="placeholder">&lt;script&gt;</em>', 'SafeMarkup::format replaces, escapes and themes string.', TRUE];
+ $tests[] = ['Placeholder text: %value', ['%value' => SafeMarkupTestMarkup::create('<span>Safe HTML</span>')], 'Placeholder text: <em class="placeholder"><span>Safe HTML</span></em>', 'SafeMarkup::format does not escape an already safe string themed as a placeholder.', TRUE];
$tests['javascript-protocol-url'] = ['Simple text <a href=":url">giraffe</a>', [':url' => 'javascript://example.com?foo&bar'], 'Simple text <a href="//example.com?foo&amp;bar">giraffe</a>', 'Support for filtering bad protocols', TRUE];
$tests['external-url'] = ['Simple text <a href=":url">giraffe</a>', [':url' => 'http://example.com?foo&bar'], 'Simple text <a href="http://example.com?foo&amp;bar">giraffe</a>', 'Support for filtering bad protocols', TRUE];
diff --git a/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php b/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
index 3ff7ed1cf40..890d17171eb 100644
--- a/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
@@ -43,49 +43,49 @@ class SortArrayTest extends UnitTestCase {
* @see \Drupal\Tests\Component\Utility\SortArrayTest::testSortByWeightElement()
*/
public function providerSortByWeightElement() {
- $tests = array();
+ $tests = [];
// Weights set and equal.
- $tests[] = array(
- array('weight' => 1),
- array('weight' => 1),
+ $tests[] = [
+ ['weight' => 1],
+ ['weight' => 1],
0
- );
+ ];
// Weights set and $a is less (lighter) than $b.
- $tests[] = array(
- array('weight' => 1),
- array('weight' => 2),
+ $tests[] = [
+ ['weight' => 1],
+ ['weight' => 2],
-1
- );
+ ];
// Weights set and $a is greater (heavier) than $b.
- $tests[] = array(
- array('weight' => 2),
- array('weight' => 1),
+ $tests[] = [
+ ['weight' => 2],
+ ['weight' => 1],
1
- );
+ ];
// Weights not set.
- $tests[] = array(
- array(),
- array(),
+ $tests[] = [
+ [],
+ [],
0
- );
+ ];
// Weights for $b not set.
- $tests[] = array(
- array('weight' => 1),
- array(),
+ $tests[] = [
+ ['weight' => 1],
+ [],
1
- );
+ ];
// Weights for $a not set.
- $tests[] = array(
- array(),
- array('weight' => 1),
+ $tests[] = [
+ [],
+ ['weight' => 1],
-1
- );
+ ];
return $tests;
}
@@ -119,49 +119,49 @@ class SortArrayTest extends UnitTestCase {
* @see \Drupal\Tests\Component\Utility\SortArrayTest::testSortByWeightProperty()
*/
public function providerSortByWeightProperty() {
- $tests = array();
+ $tests = [];
// Weights set and equal.
- $tests[] = array(
- array('#weight' => 1),
- array('#weight' => 1),
+ $tests[] = [
+ ['#weight' => 1],
+ ['#weight' => 1],
0
- );
+ ];
// Weights set and $a is less (lighter) than $b.
- $tests[] = array(
- array('#weight' => 1),
- array('#weight' => 2),
+ $tests[] = [
+ ['#weight' => 1],
+ ['#weight' => 2],
-1
- );
+ ];
// Weights set and $a is greater (heavier) than $b.
- $tests[] = array(
- array('#weight' => 2),
- array('#weight' => 1),
+ $tests[] = [
+ ['#weight' => 2],
+ ['#weight' => 1],
1
- );
+ ];
// Weights not set.
- $tests[] = array(
- array(),
- array(),
+ $tests[] = [
+ [],
+ [],
0
- );
+ ];
// Weights for $b not set.
- $tests[] = array(
- array('#weight' => 1),
- array(),
+ $tests[] = [
+ ['#weight' => 1],
+ [],
1
- );
+ ];
// Weights for $a not set.
- $tests[] = array(
- array(),
- array('#weight' => 1),
+ $tests[] = [
+ [],
+ ['#weight' => 1],
-1
- );
+ ];
return $tests;
}
@@ -195,42 +195,42 @@ class SortArrayTest extends UnitTestCase {
* @see \Drupal\Tests\Component\Utility\SortArrayTest::testSortByTitleElement()
*/
public function providerSortByTitleElement() {
- $tests = array();
+ $tests = [];
// Titles set and equal.
- $tests[] = array(
- array('title' => 'test'),
- array('title' => 'test'),
+ $tests[] = [
+ ['title' => 'test'],
+ ['title' => 'test'],
0
- );
+ ];
// Title $a not set.
- $tests[] = array(
- array(),
- array('title' => 'test'),
+ $tests[] = [
+ [],
+ ['title' => 'test'],
-4
- );
+ ];
// Title $b not set.
- $tests[] = array(
- array('title' => 'test'),
- array(),
+ $tests[] = [
+ ['title' => 'test'],
+ [],
4
- );
+ ];
// Titles set but not equal.
- $tests[] = array(
- array('title' => 'test'),
- array('title' => 'testing'),
+ $tests[] = [
+ ['title' => 'test'],
+ ['title' => 'testing'],
-1
- );
+ ];
// Titles set but not equal.
- $tests[] = array(
- array('title' => 'testing'),
- array('title' => 'test'),
+ $tests[] = [
+ ['title' => 'testing'],
+ ['title' => 'test'],
1
- );
+ ];
return $tests;
}
@@ -264,42 +264,42 @@ class SortArrayTest extends UnitTestCase {
* @see \Drupal\Tests\Component\Utility\SortArrayTest::testSortByTitleProperty()
*/
public function providerSortByTitleProperty() {
- $tests = array();
+ $tests = [];
// Titles set and equal.
- $tests[] = array(
- array('#title' => 'test'),
- array('#title' => 'test'),
+ $tests[] = [
+ ['#title' => 'test'],
+ ['#title' => 'test'],
0
- );
+ ];
// Title $a not set.
- $tests[] = array(
- array(),
- array('#title' => 'test'),
+ $tests[] = [
+ [],
+ ['#title' => 'test'],
-4
- );
+ ];
// Title $b not set.
- $tests[] = array(
- array('#title' => 'test'),
- array(),
+ $tests[] = [
+ ['#title' => 'test'],
+ [],
4
- );
+ ];
// Titles set but not equal.
- $tests[] = array(
- array('#title' => 'test'),
- array('#title' => 'testing'),
+ $tests[] = [
+ ['#title' => 'test'],
+ ['#title' => 'testing'],
-1
- );
+ ];
// Titles set but not equal.
- $tests[] = array(
- array('#title' => 'testing'),
- array('#title' => 'test'),
+ $tests[] = [
+ ['#title' => 'testing'],
+ ['#title' => 'test'],
1
- );
+ ];
return $tests;
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
index 39759b51cd5..b834d2bbed3 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
@@ -51,15 +51,15 @@ class UnicodeTest extends UnitTestCase {
* - (optional) Boolean indicating invalid status. Defaults to FALSE.
*/
public function providerTestStatus() {
- return array(
- array(Unicode::STATUS_SINGLEBYTE, Unicode::STATUS_SINGLEBYTE),
- array(rand(10, 100), Unicode::STATUS_SINGLEBYTE, TRUE),
- array(rand(10, 100), Unicode::STATUS_SINGLEBYTE, TRUE),
- array(Unicode::STATUS_MULTIBYTE, Unicode::STATUS_MULTIBYTE),
- array(rand(10, 100), Unicode::STATUS_MULTIBYTE, TRUE),
- array(Unicode::STATUS_ERROR, Unicode::STATUS_ERROR),
- array(Unicode::STATUS_MULTIBYTE, Unicode::STATUS_MULTIBYTE),
- );
+ return [
+ [Unicode::STATUS_SINGLEBYTE, Unicode::STATUS_SINGLEBYTE],
+ [rand(10, 100), Unicode::STATUS_SINGLEBYTE, TRUE],
+ [rand(10, 100), Unicode::STATUS_SINGLEBYTE, TRUE],
+ [Unicode::STATUS_MULTIBYTE, Unicode::STATUS_MULTIBYTE],
+ [rand(10, 100), Unicode::STATUS_MULTIBYTE, TRUE],
+ [Unicode::STATUS_ERROR, Unicode::STATUS_ERROR],
+ [Unicode::STATUS_MULTIBYTE, Unicode::STATUS_MULTIBYTE],
+ ];
}
/**
@@ -83,11 +83,11 @@ class UnicodeTest extends UnitTestCase {
* An array containing a string and its encoded value.
*/
public function providerTestMimeHeader() {
- return array(
- array('tést.txt', '=?UTF-8?B?dMOpc3QudHh0?='),
+ return [
+ ['tést.txt', '=?UTF-8?B?dMOpc3QudHh0?='],
// Simple ASCII characters.
- array('ASCII', 'ASCII'),
- );
+ ['ASCII', 'ASCII'],
+ ];
}
/**
@@ -113,17 +113,17 @@ class UnicodeTest extends UnitTestCase {
* be processed as multibyte.
*/
public function providerStrtolower() {
- $cases = array(
- array('tHe QUIcK bRoWn', 'the quick brown'),
- array('FrançAIS is ÜBER-åwesome', 'français is über-åwesome'),
- );
+ $cases = [
+ ['tHe QUIcK bRoWn', 'the quick brown'],
+ ['FrançAIS is ÜBER-åwesome', 'français is über-åwesome'],
+ ];
foreach ($cases as $case) {
// Test the same string both in multibyte and singlebyte conditions.
array_push($case, TRUE);
$cases[] = $case;
}
// Add a multibyte string.
- $cases[] = array('ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', 'αβγδεζηθικλμνξοσὠ', TRUE);
+ $cases[] = ['ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', 'αβγδεζηθικλμνξοσὠ', TRUE];
return $cases;
}
@@ -150,17 +150,17 @@ class UnicodeTest extends UnitTestCase {
* be processed as multibyte.
*/
public function providerStrtoupper() {
- $cases = array(
- array('tHe QUIcK bRoWn', 'THE QUICK BROWN'),
- array('FrançAIS is ÜBER-åwesome', 'FRANÇAIS IS ÜBER-ÅWESOME'),
- );
+ $cases = [
+ ['tHe QUIcK bRoWn', 'THE QUICK BROWN'],
+ ['FrançAIS is ÜBER-åwesome', 'FRANÇAIS IS ÜBER-ÅWESOME'],
+ ];
foreach ($cases as $case) {
// Test the same string both in multibyte and singlebyte conditions.
array_push($case, TRUE);
$cases[] = $case;
}
// Add a multibyte string.
- $cases[] = array('αβγδεζηθικλμνξοσὠ', 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', TRUE);
+ $cases[] = ['αβγδεζηθικλμνξοσὠ', 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', TRUE];
return $cases;
}
@@ -183,14 +183,14 @@ class UnicodeTest extends UnitTestCase {
* An array containing a string and its uppercase first version.
*/
public function providerUcfirst() {
- return array(
- array('tHe QUIcK bRoWn', 'THe QUIcK bRoWn'),
- array('françAIS', 'FrançAIS'),
- array('über', 'Über'),
- array('åwesome', 'Åwesome'),
+ return [
+ ['tHe QUIcK bRoWn', 'THe QUIcK bRoWn'],
+ ['françAIS', 'FrançAIS'],
+ ['über', 'Über'],
+ ['åwesome', 'Åwesome'],
// A multibyte string.
- array('σion', 'Σion'),
- );
+ ['σion', 'Σion'],
+ ];
}
/**
@@ -215,14 +215,14 @@ class UnicodeTest extends UnitTestCase {
* be processed as multibyte.
*/
public function providerLcfirst() {
- return array(
- array('tHe QUIcK bRoWn', 'tHe QUIcK bRoWn'),
- array('FrançAIS is ÜBER-åwesome', 'françAIS is ÜBER-åwesome'),
- array('Über', 'über'),
- array('Åwesome', 'åwesome'),
+ return [
+ ['tHe QUIcK bRoWn', 'tHe QUIcK bRoWn'],
+ ['FrançAIS is ÜBER-åwesome', 'françAIS is ÜBER-åwesome'],
+ ['Über', 'über'],
+ ['Åwesome', 'åwesome'],
// Add a multibyte string.
- array('ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', 'αΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', TRUE),
- );
+ ['ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', 'αΒΓΔΕΖΗΘΙΚΛΜΝΞΟΣὨ', TRUE],
+ ];
}
/**
@@ -247,16 +247,16 @@ class UnicodeTest extends UnitTestCase {
* be processed as multibyte.
*/
public function providerUcwords() {
- return array(
- array('tHe QUIcK bRoWn', 'THe QUIcK BRoWn'),
- array('françAIS', 'FrançAIS'),
- array('über', 'Über'),
- array('åwesome', 'Åwesome'),
+ return [
+ ['tHe QUIcK bRoWn', 'THe QUIcK BRoWn'],
+ ['françAIS', 'FrançAIS'],
+ ['über', 'Über'],
+ ['åwesome', 'Åwesome'],
// Make sure we don't mangle extra spaces.
- array('frànçAIS is über-åwesome', 'FrànçAIS Is Über-Åwesome'),
+ ['frànçAIS is über-åwesome', 'FrànçAIS Is Über-Åwesome'],
// Add a multibyte string.
- array('σion', 'Σion', TRUE),
- );
+ ['σion', 'Σion', TRUE],
+ ];
}
/**
@@ -283,11 +283,11 @@ class UnicodeTest extends UnitTestCase {
* An array containing a string and its length.
*/
public function providerStrlen() {
- return array(
- array('tHe QUIcK bRoWn', 15),
- array('ÜBER-åwesome', 12),
- array('以呂波耳・ほへとち。リヌルヲ。', 15),
- );
+ return [
+ ['tHe QUIcK bRoWn', 15],
+ ['ÜBER-åwesome', 12],
+ ['以呂波耳・ほへとち。リヌルヲ。', 15],
+ ];
}
/**
@@ -318,33 +318,33 @@ class UnicodeTest extends UnitTestCase {
* - The expected string result.
*/
public function providerSubstr() {
- return array(
- array('frànçAIS is über-åwesome', 0, NULL, 'frànçAIS is über-åwesome'),
- array('frànçAIS is über-åwesome', 0, 0, ''),
- array('frànçAIS is über-åwesome', 0, 1, 'f'),
- array('frànçAIS is über-åwesome', 0, 8, 'frànçAIS'),
- array('frànçAIS is über-åwesome', 0, 23, 'frànçAIS is über-åwesom'),
- array('frànçAIS is über-åwesome', 0, 24, 'frànçAIS is über-åwesome'),
- array('frànçAIS is über-åwesome', 0, 25, 'frànçAIS is über-åwesome'),
- array('frànçAIS is über-åwesome', 0, 100, 'frànçAIS is über-åwesome'),
- array('frànçAIS is über-åwesome', 4, 4, 'çAIS'),
- array('frànçAIS is über-åwesome', 1, 0, ''),
- array('frànçAIS is über-åwesome', 100, 0, ''),
- array('frànçAIS is über-åwesome', -4, 2, 'so'),
- array('frànçAIS is über-åwesome', -4, 3, 'som'),
- array('frànçAIS is über-åwesome', -4, 4, 'some'),
- array('frànçAIS is über-åwesome', -4, 5, 'some'),
- array('frànçAIS is über-åwesome', -7, 10, 'åwesome'),
- array('frànçAIS is über-åwesome', 5, -10, 'AIS is üb'),
- array('frànçAIS is über-åwesome', 0, -10, 'frànçAIS is üb'),
- array('frànçAIS is über-åwesome', 0, -1, 'frànçAIS is über-åwesom'),
- array('frànçAIS is über-åwesome', -7, -2, 'åweso'),
- array('frànçAIS is über-åwesome', -7, -6, 'å'),
- array('frànçAIS is über-åwesome', -7, -7, ''),
- array('frànçAIS is über-åwesome', -7, -8, ''),
- array('...', 0, 2, '..'),
- array('以呂波耳・ほへとち。リヌルヲ。', 1, 3, '呂波耳'),
- );
+ return [
+ ['frànçAIS is über-åwesome', 0, NULL, 'frànçAIS is über-åwesome'],
+ ['frànçAIS is über-åwesome', 0, 0, ''],
+ ['frànçAIS is über-åwesome', 0, 1, 'f'],
+ ['frànçAIS is über-åwesome', 0, 8, 'frànçAIS'],
+ ['frànçAIS is über-åwesome', 0, 23, 'frànçAIS is über-åwesom'],
+ ['frànçAIS is über-åwesome', 0, 24, 'frànçAIS is über-åwesome'],
+ ['frànçAIS is über-åwesome', 0, 25, 'frànçAIS is über-åwesome'],
+ ['frànçAIS is über-åwesome', 0, 100, 'frànçAIS is über-åwesome'],
+ ['frànçAIS is über-åwesome', 4, 4, 'çAIS'],
+ ['frànçAIS is über-åwesome', 1, 0, ''],
+ ['frànçAIS is über-åwesome', 100, 0, ''],
+ ['frànçAIS is über-åwesome', -4, 2, 'so'],
+ ['frànçAIS is über-åwesome', -4, 3, 'som'],
+ ['frànçAIS is über-åwesome', -4, 4, 'some'],
+ ['frànçAIS is über-åwesome', -4, 5, 'some'],
+ ['frànçAIS is über-åwesome', -7, 10, 'åwesome'],
+ ['frànçAIS is über-åwesome', 5, -10, 'AIS is üb'],
+ ['frànçAIS is über-åwesome', 0, -10, 'frànçAIS is üb'],
+ ['frànçAIS is über-åwesome', 0, -1, 'frànçAIS is über-åwesom'],
+ ['frànçAIS is über-åwesome', -7, -2, 'åweso'],
+ ['frànçAIS is über-åwesome', -7, -6, 'å'],
+ ['frànçAIS is über-åwesome', -7, -7, ''],
+ ['frànçAIS is über-åwesome', -7, -8, ''],
+ ['...', 0, 2, '..'],
+ ['以呂波耳・ほへとち。リヌルヲ。', 1, 3, '呂波耳'],
+ ];
}
/**
@@ -371,52 +371,52 @@ class UnicodeTest extends UnitTestCase {
* - (optional) Boolean for the $add_ellipsis flag. Defaults to FALSE.
*/
public function providerTruncate() {
- return array(
- array('frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome'),
- array('frànçAIS is über-åwesome', 23, 'frànçAIS is über-åwesom'),
- array('frànçAIS is über-åwesome', 17, 'frànçAIS is über-'),
- array('以呂波耳・ほへとち。リヌルヲ。', 6, '以呂波耳・ほ'),
- array('frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome', FALSE, TRUE),
- array('frànçAIS is über-åwesome', 23, 'frànçAIS is über-åweso…', FALSE, TRUE),
- array('frànçAIS is über-åwesome', 17, 'frànçAIS is über…', FALSE, TRUE),
- array('123', 1, '…', TRUE, TRUE),
- array('123', 2, '1…', TRUE, TRUE),
- array('123', 3, '123', TRUE, TRUE),
- array('1234', 3, '12…', TRUE, TRUE),
- array('1234567890', 10, '1234567890', TRUE, TRUE),
- array('12345678901', 10, '123456789…', TRUE, TRUE),
- array('12345678901', 11, '12345678901', TRUE, TRUE),
- array('123456789012', 11, '1234567890…', TRUE, TRUE),
- array('12345 7890', 10, '12345 7890', TRUE, TRUE),
- array('12345 7890', 9, '12345…', TRUE, TRUE),
- array('123 567 90', 10, '123 567 90', TRUE, TRUE),
- array('123 567 901', 10, '123 567…', TRUE, TRUE),
- array('Stop. Hammertime.', 17, 'Stop. Hammertime.', TRUE, TRUE),
- array('Stop. Hammertime.', 16, 'Stop…', TRUE, TRUE),
- array('frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome', TRUE, TRUE),
- array('frànçAIS is über-åwesome', 23, 'frànçAIS is über…', TRUE, TRUE),
- array('frànçAIS is über-åwesome', 17, 'frànçAIS is über…', TRUE, TRUE),
- array('¿Dónde está el niño?', 20, '¿Dónde está el niño?', TRUE, TRUE),
- array('¿Dónde está el niño?', 19, '¿Dónde está el…', TRUE, TRUE),
- array('¿Dónde está el niño?', 13, '¿Dónde está…', TRUE, TRUE),
- array('¿Dónde está el niño?', 10, '¿Dónde…', TRUE, TRUE),
- array('Help! Help! Help!', 17, 'Help! Help! Help!', TRUE, TRUE),
- array('Help! Help! Help!', 16, 'Help! Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 15, 'Help! Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 14, 'Help! Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 13, 'Help! Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 12, 'Help! Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 11, 'Help! Help…', TRUE, TRUE),
- array('Help! Help! Help!', 10, 'Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 9, 'Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 8, 'Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 7, 'Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 6, 'Help!…', TRUE, TRUE),
- array('Help! Help! Help!', 5, 'Help…', TRUE, TRUE),
- array('Help! Help! Help!', 4, 'Hel…', TRUE, TRUE),
- array('Help! Help! Help!', 3, 'He…', TRUE, TRUE),
- array('Help! Help! Help!', 2, 'H…', TRUE, TRUE),
- );
+ return [
+ ['frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome'],
+ ['frànçAIS is über-åwesome', 23, 'frànçAIS is über-åwesom'],
+ ['frànçAIS is über-åwesome', 17, 'frànçAIS is über-'],
+ ['以呂波耳・ほへとち。リヌルヲ。', 6, '以呂波耳・ほ'],
+ ['frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome', FALSE, TRUE],
+ ['frànçAIS is über-åwesome', 23, 'frànçAIS is über-åweso…', FALSE, TRUE],
+ ['frànçAIS is über-åwesome', 17, 'frànçAIS is über…', FALSE, TRUE],
+ ['123', 1, '…', TRUE, TRUE],
+ ['123', 2, '1…', TRUE, TRUE],
+ ['123', 3, '123', TRUE, TRUE],
+ ['1234', 3, '12…', TRUE, TRUE],
+ ['1234567890', 10, '1234567890', TRUE, TRUE],
+ ['12345678901', 10, '123456789…', TRUE, TRUE],
+ ['12345678901', 11, '12345678901', TRUE, TRUE],
+ ['123456789012', 11, '1234567890…', TRUE, TRUE],
+ ['12345 7890', 10, '12345 7890', TRUE, TRUE],
+ ['12345 7890', 9, '12345…', TRUE, TRUE],
+ ['123 567 90', 10, '123 567 90', TRUE, TRUE],
+ ['123 567 901', 10, '123 567…', TRUE, TRUE],
+ ['Stop. Hammertime.', 17, 'Stop. Hammertime.', TRUE, TRUE],
+ ['Stop. Hammertime.', 16, 'Stop…', TRUE, TRUE],
+ ['frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome', TRUE, TRUE],
+ ['frànçAIS is über-åwesome', 23, 'frànçAIS is über…', TRUE, TRUE],
+ ['frànçAIS is über-åwesome', 17, 'frànçAIS is über…', TRUE, TRUE],
+ ['¿Dónde está el niño?', 20, '¿Dónde está el niño?', TRUE, TRUE],
+ ['¿Dónde está el niño?', 19, '¿Dónde está el…', TRUE, TRUE],
+ ['¿Dónde está el niño?', 13, '¿Dónde está…', TRUE, TRUE],
+ ['¿Dónde está el niño?', 10, '¿Dónde…', TRUE, TRUE],
+ ['Help! Help! Help!', 17, 'Help! Help! Help!', TRUE, TRUE],
+ ['Help! Help! Help!', 16, 'Help! Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 15, 'Help! Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 14, 'Help! Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 13, 'Help! Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 12, 'Help! Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 11, 'Help! Help…', TRUE, TRUE],
+ ['Help! Help! Help!', 10, 'Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 9, 'Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 8, 'Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 7, 'Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 6, 'Help!…', TRUE, TRUE],
+ ['Help! Help! Help!', 5, 'Help…', TRUE, TRUE],
+ ['Help! Help! Help!', 4, 'Hel…', TRUE, TRUE],
+ ['Help! Help! Help!', 3, 'He…', TRUE, TRUE],
+ ['Help! Help! Help!', 2, 'H…', TRUE, TRUE],
+ ];
}
/**
@@ -444,14 +444,14 @@ class UnicodeTest extends UnitTestCase {
* self::testTruncateBytes().
*/
public function providerTestTruncateBytes() {
- return array(
+ return [
// String shorter than max length.
- array('Short string', 42, 'Short string'),
+ ['Short string', 42, 'Short string'],
// Simple string longer than max length.
- array('Longer string than previous.', 10, 'Longer str'),
+ ['Longer string than previous.', 10, 'Longer str'],
// Unicode.
- array('以呂波耳・ほへとち。リヌルヲ。', 10, '以呂波'),
- );
+ ['以呂波耳・ほへとち。リヌルヲ。', 10, '以呂波'],
+ ];
}
/**
@@ -481,16 +481,16 @@ class UnicodeTest extends UnitTestCase {
* self::testValidateUtf8().
*/
public function providerTestValidateUtf8() {
- return array(
+ return [
// Empty string.
- array('', TRUE, 'An empty string did not validate.'),
+ ['', TRUE, 'An empty string did not validate.'],
// Simple text string.
- array('Simple text.', TRUE, 'A simple ASCII text string did not validate.'),
+ ['Simple text.', TRUE, 'A simple ASCII text string did not validate.'],
// Invalid UTF-8, overlong 5 byte encoding.
- array(chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), FALSE, 'Invalid UTF-8 was validated.'),
+ [chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), FALSE, 'Invalid UTF-8 was validated.'],
// High code-point without trailing characters.
- array(chr(0xD0) . chr(0x01), FALSE, 'Invalid UTF-8 was validated.'),
- );
+ [chr(0xD0) . chr(0x01), FALSE, 'Invalid UTF-8 was validated.'],
+ ];
}
/**
@@ -518,11 +518,11 @@ class UnicodeTest extends UnitTestCase {
* self::testConvertUtf8(). }
*/
public function providerTestConvertToUtf8() {
- return array(
- array(chr(0x97), 'Windows-1252', '—'),
- array(chr(0x99), 'Windows-1252', '™'),
- array(chr(0x80), 'Windows-1252', '€'),
- );
+ return [
+ [chr(0x97), 'Windows-1252', '—'],
+ [chr(0x99), 'Windows-1252', '™'],
+ [chr(0x80), 'Windows-1252', '€'],
+ ];
}
/**
@@ -553,18 +553,18 @@ class UnicodeTest extends UnitTestCase {
* - The expected integer/FALSE result.
*/
public function providerStrpos() {
- return array(
- array('frànçAIS is über-åwesome', 'frànçAIS is über-åwesome', 0, 0),
- array('frànçAIS is über-åwesome', 'rànçAIS is über-åwesome', 0, 1),
- array('frànçAIS is über-åwesome', 'not in string', 0, FALSE),
- array('frànçAIS is über-åwesome', 'r', 0, 1),
- array('frànçAIS is über-åwesome', 'nçAIS', 0, 3),
- array('frànçAIS is über-åwesome', 'nçAIS', 2, 3),
- array('frànçAIS is über-åwesome', 'nçAIS', 3, 3),
- array('以呂波耳・ほへとち。リヌルヲ。', '波耳', 0, 2),
- array('以呂波耳・ほへとち。リヌルヲ。', '波耳', 1, 2),
- array('以呂波耳・ほへとち。リヌルヲ。', '波耳', 2, 2),
- );
+ return [
+ ['frànçAIS is über-åwesome', 'frànçAIS is über-åwesome', 0, 0],
+ ['frànçAIS is über-åwesome', 'rànçAIS is über-åwesome', 0, 1],
+ ['frànçAIS is über-åwesome', 'not in string', 0, FALSE],
+ ['frànçAIS is über-åwesome', 'r', 0, 1],
+ ['frànçAIS is über-åwesome', 'nçAIS', 0, 3],
+ ['frànçAIS is über-åwesome', 'nçAIS', 2, 3],
+ ['frànçAIS is über-åwesome', 'nçAIS', 3, 3],
+ ['以呂波耳・ほへとち。リヌルヲ。', '波耳', 0, 2],
+ ['以呂波耳・ほへとち。リヌルヲ。', '波耳', 1, 2],
+ ['以呂波耳・ほへとち。リヌルヲ。', '波耳', 2, 2],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
index 87ab75f09c4..e487831b2f5 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
@@ -18,13 +18,13 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public function providerTestBuildQuery() {
- return array(
- array(array('a' => ' &#//+%20@۞'), 'a=%20%26%23//%2B%2520%40%DB%9E', 'Value was properly encoded.'),
- array(array(' &#//+%20@۞' => 'a'), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', 'Key was properly encoded.'),
- array(array('a' => '1', 'b' => '2', 'c' => '3'), 'a=1&b=2&c=3', 'Multiple values were properly concatenated.'),
- array(array('a' => array('b' => '2', 'c' => '3'), 'd' => 'foo'), 'a[b]=2&a[c]=3&d=foo', 'Nested array was properly encoded.'),
- array(array('foo' => NULL), 'foo', 'Simple parameters are properly added.'),
- );
+ return [
+ [['a' => ' &#//+%20@۞'], 'a=%20%26%23//%2B%2520%40%DB%9E', 'Value was properly encoded.'],
+ [[' &#//+%20@۞' => 'a'], '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', 'Key was properly encoded.'],
+ [['a' => '1', 'b' => '2', 'c' => '3'], 'a=1&b=2&c=3', 'Multiple values were properly concatenated.'],
+ [['a' => ['b' => '2', 'c' => '3'], 'd' => 'foo'], 'a[b]=2&a[c]=3&d=foo', 'Nested array was properly encoded.'],
+ [['foo' => NULL], 'foo', 'Simple parameters are properly added.'],
+ ];
}
/**
@@ -50,7 +50,7 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public function providerTestValidAbsoluteData() {
- $urls = array(
+ $urls = [
'example.com',
'www.example.com',
'ex-ample.com',
@@ -69,7 +69,7 @@ class UrlHelperTest extends UnitTestCase {
'example.org/~,$\'*;',
'caf%C3%A9.example.org',
'[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html',
- );
+ ];
return $this->dataEnhanceWithScheme($urls);
}
@@ -97,11 +97,11 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public function providerTestInvalidAbsolute() {
- $data = array(
+ $data = [
'',
'ex!ample.com',
'ex%ample.com',
- );
+ ];
return $this->dataEnhanceWithScheme($data);
}
@@ -128,13 +128,13 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public function providerTestValidRelativeData() {
- $data = array(
+ $data = [
'paren(the)sis',
'index.html#pagetop',
'index.php/node',
'index.php/node?param=false',
'login.php?do=login&style=%23#pagetop',
- );
+ ];
return $this->dataEnhanceWithPrefix($data);
}
@@ -162,11 +162,11 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public function providerTestInvalidRelativeData() {
- $data = array(
+ $data = [
'ex^mple',
'example<>',
'ex%ample',
- );
+ ];
return $this->dataEnhanceWithPrefix($data);
}
@@ -212,20 +212,20 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public static function providerTestFilterQueryParameters() {
- return array(
+ return [
// Test without an exclude filter.
- array(
- 'query' => array('a' => array('b' => 'c')),
- 'exclude' => array(),
- 'expected' => array('a' => array('b' => 'c')),
- ),
+ [
+ 'query' => ['a' => ['b' => 'c']],
+ 'exclude' => [],
+ 'expected' => ['a' => ['b' => 'c']],
+ ],
// Exclude the 'b' element.
- array(
- 'query' => array('a' => array('b' => 'c', 'd' => 'e')),
- 'exclude' => array('a[b]'),
- 'expected' => array('a' => array('d' => 'e')),
- ),
- );
+ [
+ 'query' => ['a' => ['b' => 'c', 'd' => 'e']],
+ 'exclude' => ['a[b]'],
+ 'expected' => ['a' => ['d' => 'e']],
+ ],
+ ];
}
/**
@@ -250,52 +250,52 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public static function providerTestParse() {
- return array(
- array(
+ return [
+ [
'http://www.example.com/my/path',
- array(
+ [
'path' => 'http://www.example.com/my/path',
- 'query' => array(),
+ 'query' => [],
'fragment' => '',
- ),
- ),
- array(
+ ],
+ ],
+ [
'http://www.example.com/my/path?destination=home#footer',
- array(
+ [
'path' => 'http://www.example.com/my/path',
- 'query' => array(
+ 'query' => [
'destination' => 'home',
- ),
+ ],
'fragment' => 'footer',
- ),
- ),
- array(
+ ],
+ ],
+ [
'http://',
- array(
+ [
'path' => '',
- 'query' => array(),
+ 'query' => [],
'fragment' => '',
- ),
- ),
- array(
+ ],
+ ],
+ [
'https://',
- array(
+ [
'path' => '',
- 'query' => array(),
+ 'query' => [],
'fragment' => '',
- ),
- ),
- array(
+ ],
+ ],
+ [
'/my/path?destination=home#footer',
- array(
+ [
'path' => '/my/path',
- 'query' => array(
+ 'query' => [
'destination' => 'home',
- ),
+ ],
'fragment' => 'footer',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -320,10 +320,10 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public static function providerTestEncodePath() {
- return array(
- array('unencoded path with spaces', 'unencoded%20path%20with%20spaces'),
- array('slashes/should/be/preserved', 'slashes/should/be/preserved'),
- );
+ return [
+ ['unencoded path with spaces', 'unencoded%20path%20with%20spaces'],
+ ['slashes/should/be/preserved', 'slashes/should/be/preserved'],
+ ];
}
/**
@@ -348,39 +348,39 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public static function providerTestIsExternal() {
- return array(
- array('/internal/path', FALSE),
- array('https://example.com/external/path', TRUE),
- array('javascript://fake-external-path', FALSE),
+ return [
+ ['/internal/path', FALSE],
+ ['https://example.com/external/path', TRUE],
+ ['javascript://fake-external-path', FALSE],
// External URL without an explicit protocol.
- array('//www.drupal.org/foo/bar?foo=bar&bar=baz&baz#foo', TRUE),
+ ['//www.drupal.org/foo/bar?foo=bar&bar=baz&baz#foo', TRUE],
// Internal URL starting with a slash.
- array('/www.drupal.org', FALSE),
+ ['/www.drupal.org', FALSE],
// Simple external URLs.
- array('http://example.com', TRUE),
- array('https://example.com', TRUE),
- array('http://drupal.org/foo/bar?foo=bar&bar=baz&baz#foo', TRUE),
- array('//drupal.org', TRUE),
+ ['http://example.com', TRUE],
+ ['https://example.com', TRUE],
+ ['http://drupal.org/foo/bar?foo=bar&bar=baz&baz#foo', TRUE],
+ ['//drupal.org', TRUE],
// Some browsers ignore or strip leading control characters.
- array("\x00//www.example.com", TRUE),
- array("\x08//www.example.com", TRUE),
- array("\x1F//www.example.com", TRUE),
- array("\n//www.example.com", TRUE),
+ ["\x00//www.example.com", TRUE],
+ ["\x08//www.example.com", TRUE],
+ ["\x1F//www.example.com", TRUE],
+ ["\n//www.example.com", TRUE],
// JSON supports decoding directly from UTF-8 code points.
- array(json_decode('"\u00AD"') . "//www.example.com", TRUE),
- array(json_decode('"\u200E"') . "//www.example.com", TRUE),
- array(json_decode('"\uE0020"') . "//www.example.com", TRUE),
- array(json_decode('"\uE000"') . "//www.example.com", TRUE),
+ [json_decode('"\u00AD"') . "//www.example.com", TRUE],
+ [json_decode('"\u200E"') . "//www.example.com", TRUE],
+ [json_decode('"\uE0020"') . "//www.example.com", TRUE],
+ [json_decode('"\uE000"') . "//www.example.com", TRUE],
// Backslashes should be normalized to forward.
- array('\\\\example.com', TRUE),
+ ['\\\\example.com', TRUE],
// Local URLs.
- array('node', FALSE),
- array('/system/ajax', FALSE),
- array('?q=foo:bar', FALSE),
- array('node/edit:me', FALSE),
- array('/drupal.org', FALSE),
- array('<front>', FALSE),
- );
+ ['node', FALSE],
+ ['/system/ajax', FALSE],
+ ['?q=foo:bar', FALSE],
+ ['node/edit:me', FALSE],
+ ['/drupal.org', FALSE],
+ ['<front>', FALSE],
+ ];
}
/**
@@ -411,15 +411,15 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public static function providerTestFilterBadProtocol() {
- return array(
- array('javascript://example.com?foo&bar', '//example.com?foo&amp;bar', array('http', 'https')),
+ return [
+ ['javascript://example.com?foo&bar', '//example.com?foo&amp;bar', ['http', 'https']],
// Test custom protocols.
- array('http://example.com?foo&bar', '//example.com?foo&amp;bar', array('https')),
+ ['http://example.com?foo&bar', '//example.com?foo&amp;bar', ['https']],
// Valid protocol.
- array('http://example.com?foo&bar', 'http://example.com?foo&amp;bar', array('https', 'http')),
+ ['http://example.com?foo&bar', 'http://example.com?foo&amp;bar', ['https', 'http']],
// Colon not part of the URL scheme.
- array('/test:8888?foo&bar', '/test:8888?foo&amp;bar', array('http')),
- );
+ ['/test:8888?foo&bar', '/test:8888?foo&amp;bar', ['http']],
+ ];
}
/**
@@ -448,15 +448,15 @@ class UrlHelperTest extends UnitTestCase {
* @return array
*/
public static function providerTestStripDangerousProtocols() {
- return array(
- array('javascript://example.com', '//example.com', array('http', 'https')),
+ return [
+ ['javascript://example.com', '//example.com', ['http', 'https']],
// Test custom protocols.
- array('http://example.com', '//example.com', array('https')),
+ ['http://example.com', '//example.com', ['https']],
// Valid protocol.
- array('http://example.com', 'http://example.com', array('https', 'http')),
+ ['http://example.com', 'http://example.com', ['https', 'http']],
// Colon not part of the URL scheme.
- array('/test:8888', '/test:8888', array('http')),
- );
+ ['/test:8888', '/test:8888', ['http']],
+ ];
}
/**
@@ -469,11 +469,11 @@ class UrlHelperTest extends UnitTestCase {
* A list of provider data with schemes.
*/
protected function dataEnhanceWithScheme(array $urls) {
- $url_schemes = array('http', 'https', 'ftp');
- $data = array();
+ $url_schemes = ['http', 'https', 'ftp'];
+ $data = [];
foreach ($url_schemes as $scheme) {
foreach ($urls as $url) {
- $data[] = array($url, $scheme);
+ $data[] = [$url, $scheme];
}
}
return $data;
@@ -489,11 +489,11 @@ class UrlHelperTest extends UnitTestCase {
* A list of provider data with prefixes.
*/
protected function dataEnhanceWithPrefix(array $urls) {
- $prefixes = array('', '/');
- $data = array();
+ $prefixes = ['', '/'];
+ $data = [];
foreach ($prefixes as $prefix) {
foreach ($urls as $url) {
- $data[] = array($url, $prefix);
+ $data[] = [$url, $prefix];
}
}
return $data;
@@ -523,31 +523,31 @@ class UrlHelperTest extends UnitTestCase {
* @see \Drupal\Tests\Component\Utility\UrlHelperTest::testExternalIsLocal()
*/
public function providerTestExternalIsLocal() {
- return array(
+ return [
// Different mixes of trailing slash.
- array('http://example.com', 'http://example.com', TRUE),
- array('http://example.com/', 'http://example.com', TRUE),
- array('http://example.com', 'http://example.com/', TRUE),
- array('http://example.com/', 'http://example.com/', TRUE),
+ ['http://example.com', 'http://example.com', TRUE],
+ ['http://example.com/', 'http://example.com', TRUE],
+ ['http://example.com', 'http://example.com/', TRUE],
+ ['http://example.com/', 'http://example.com/', TRUE],
// Sub directory of site.
- array('http://example.com/foo', 'http://example.com/', TRUE),
- array('http://example.com/foo/bar', 'http://example.com/foo', TRUE),
- array('http://example.com/foo/bar', 'http://example.com/foo/', TRUE),
+ ['http://example.com/foo', 'http://example.com/', TRUE],
+ ['http://example.com/foo/bar', 'http://example.com/foo', TRUE],
+ ['http://example.com/foo/bar', 'http://example.com/foo/', TRUE],
// Different sub-domain.
- array('http://example.com', 'http://www.example.com/', FALSE),
- array('http://example.com/', 'http://www.example.com/', FALSE),
- array('http://example.com/foo', 'http://www.example.com/', FALSE),
+ ['http://example.com', 'http://www.example.com/', FALSE],
+ ['http://example.com/', 'http://www.example.com/', FALSE],
+ ['http://example.com/foo', 'http://www.example.com/', FALSE],
// Different TLD.
- array('http://example.com', 'http://example.ca', FALSE),
- array('http://example.com', 'http://example.ca/', FALSE),
- array('http://example.com/', 'http://example.ca/', FALSE),
- array('http://example.com/foo', 'http://example.ca', FALSE),
- array('http://example.com/foo', 'http://example.ca/', FALSE),
+ ['http://example.com', 'http://example.ca', FALSE],
+ ['http://example.com', 'http://example.ca/', FALSE],
+ ['http://example.com/', 'http://example.ca/', FALSE],
+ ['http://example.com/foo', 'http://example.ca', FALSE],
+ ['http://example.com/foo', 'http://example.ca/', FALSE],
// Different site path.
- array('http://example.com/foo', 'http://example.com/bar', FALSE),
- array('http://example.com', 'http://example.com/bar', FALSE),
- array('http://example.com/bar', 'http://example.com/bar/', FALSE),
- );
+ ['http://example.com/foo', 'http://example.com/bar', FALSE],
+ ['http://example.com', 'http://example.com/bar', FALSE],
+ ['http://example.com/bar', 'http://example.com/bar/', FALSE],
+ ];
}
/**
@@ -572,17 +572,17 @@ class UrlHelperTest extends UnitTestCase {
* @see \Drupal\Tests\Component\Utility\UrlHelperTest::testExternalIsLocalInvalid()
*/
public function providerTestExternalIsLocalInvalid() {
- return array(
- array('http://example.com/foo', ''),
- array('http://example.com/foo', 'bar'),
- array('http://example.com/foo', 'http://'),
+ return [
+ ['http://example.com/foo', ''],
+ ['http://example.com/foo', 'bar'],
+ ['http://example.com/foo', 'http://'],
// Invalid destination urls.
- array('', 'http://example.com/foo'),
- array('bar', 'http://example.com/foo'),
- array('/bar', 'http://example.com/foo'),
- array('bar/', 'http://example.com/foo'),
- array('http://', 'http://example.com/foo'),
- );
+ ['', 'http://example.com/foo'],
+ ['bar', 'http://example.com/foo'],
+ ['/bar', 'http://example.com/foo'],
+ ['bar/', 'http://example.com/foo'],
+ ['http://', 'http://example.com/foo'],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php b/core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php
index 67fa940ece9..d804e1aab37 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php
@@ -21,7 +21,7 @@ class UserAgentTest extends UnitTestCase {
* Language codes, ordered by priority.
*/
protected function getLanguages() {
- return array(
+ return [
// In our test case, 'en' has priority over 'en-US'.
'en',
'en-US',
@@ -39,7 +39,7 @@ class UserAgentTest extends UnitTestCase {
'zh-hans',
'zh-hant',
'zh-hant-tw',
- );
+ ];
}
/**
@@ -49,7 +49,7 @@ class UserAgentTest extends UnitTestCase {
* Language mappings.
*/
protected function getMappings() {
- return array(
+ return [
'no' => 'nb',
'pt' => 'pt-pt',
'zh' => 'zh-hans',
@@ -60,7 +60,7 @@ class UserAgentTest extends UnitTestCase {
'zh-cn' => 'zh-hans',
'zh-sg' => 'zh-hans',
'zh-chs' => 'zh-hans',
- );
+ ];
}
/**
@@ -82,86 +82,86 @@ class UserAgentTest extends UnitTestCase {
* - Expected best matching language code.
*/
public function providerTestGetBestMatchingLangcode() {
- return array(
+ return [
// Equal qvalue for each language, choose the site preferred one.
- array('en,en-US,fr-CA,fr,es-MX', 'en'),
- array('en-US,en,fr-CA,fr,es-MX', 'en'),
- array('fr,en', 'en'),
- array('en,fr', 'en'),
- array('en-US,fr', 'en-US'),
- array('fr,en-US', 'en-US'),
- array('fr,fr-CA', 'fr-CA'),
- array('fr-CA,fr', 'fr-CA'),
- array('fr', 'fr-CA'),
- array('fr;q=1', 'fr-CA'),
- array('fr,es-MX', 'fr-CA'),
- array('fr,es', 'fr-CA'),
- array('es,fr', 'fr-CA'),
- array('es-MX,de', 'es-MX'),
- array('de,es-MX', 'es-MX'),
+ ['en,en-US,fr-CA,fr,es-MX', 'en'],
+ ['en-US,en,fr-CA,fr,es-MX', 'en'],
+ ['fr,en', 'en'],
+ ['en,fr', 'en'],
+ ['en-US,fr', 'en-US'],
+ ['fr,en-US', 'en-US'],
+ ['fr,fr-CA', 'fr-CA'],
+ ['fr-CA,fr', 'fr-CA'],
+ ['fr', 'fr-CA'],
+ ['fr;q=1', 'fr-CA'],
+ ['fr,es-MX', 'fr-CA'],
+ ['fr,es', 'fr-CA'],
+ ['es,fr', 'fr-CA'],
+ ['es-MX,de', 'es-MX'],
+ ['de,es-MX', 'es-MX'],
// Different cases and whitespace.
- array('en', 'en'),
- array('En', 'en'),
- array('EN', 'en'),
- array(' en', 'en'),
- array('en ', 'en'),
- array('en, fr', 'en'),
+ ['en', 'en'],
+ ['En', 'en'],
+ ['EN', 'en'],
+ [' en', 'en'],
+ ['en ', 'en'],
+ ['en, fr', 'en'],
// A less specific language from the browser matches a more specific one
// from the website, and the other way around for compatibility with
// some versions of Internet Explorer.
- array('es', 'es-MX'),
- array('es-MX', 'es-MX'),
- array('pt', 'pt'),
- array('pt-PT', 'pt'),
- array('pt-PT;q=0.5,pt-BR;q=1,en;q=0.7', 'en'),
- array('pt-PT;q=1,pt-BR;q=0.5,en;q=0.7', 'en'),
- array('pt-PT;q=0.4,pt-BR;q=0.1,en;q=0.7', 'en'),
- array('pt-PT;q=0.1,pt-BR;q=0.4,en;q=0.7', 'en'),
+ ['es', 'es-MX'],
+ ['es-MX', 'es-MX'],
+ ['pt', 'pt'],
+ ['pt-PT', 'pt'],
+ ['pt-PT;q=0.5,pt-BR;q=1,en;q=0.7', 'en'],
+ ['pt-PT;q=1,pt-BR;q=0.5,en;q=0.7', 'en'],
+ ['pt-PT;q=0.4,pt-BR;q=0.1,en;q=0.7', 'en'],
+ ['pt-PT;q=0.1,pt-BR;q=0.4,en;q=0.7', 'en'],
// Language code with several dashes are valid. The less specific language
// from the browser matches the more specific one from the website.
- array('eh-oh-laa-laa', 'eh-oh-laa-laa'),
- array('eh-oh-laa', 'eh-oh-laa-laa'),
- array('eh-oh', 'eh-oh-laa-laa'),
- array('eh', 'eh-oh-laa-laa'),
+ ['eh-oh-laa-laa', 'eh-oh-laa-laa'],
+ ['eh-oh-laa', 'eh-oh-laa-laa'],
+ ['eh-oh', 'eh-oh-laa-laa'],
+ ['eh', 'eh-oh-laa-laa'],
// Different qvalues.
- array('fr,en;q=0.5', 'fr-CA'),
- array('fr,en;q=0.5,fr-CA;q=0.25', 'fr'),
+ ['fr,en;q=0.5', 'fr-CA'],
+ ['fr,en;q=0.5,fr-CA;q=0.25', 'fr'],
// Silly wildcards are also valid.
- array('*,fr-CA;q=0.5', 'en'),
- array('*,en;q=0.25', 'fr-CA'),
- array('en,en-US;q=0.5,fr;q=0.25', 'en'),
- array('en-US,en;q=0.5,fr;q=0.25', 'en-US'),
+ ['*,fr-CA;q=0.5', 'en'],
+ ['*,en;q=0.25', 'fr-CA'],
+ ['en,en-US;q=0.5,fr;q=0.25', 'en'],
+ ['en-US,en;q=0.5,fr;q=0.25', 'en-US'],
// Unresolvable cases.
- array('', FALSE),
- array('de,pl', FALSE),
- array('iecRswK4eh', FALSE),
- array($this->randomMachineName(10), FALSE),
+ ['', FALSE],
+ ['de,pl', FALSE],
+ ['iecRswK4eh', FALSE],
+ [$this->randomMachineName(10), FALSE],
// Chinese langcodes.
- array('zh-cn, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hans'),
- array('zh-tw, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hant'),
- array('zh-hant, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hant'),
- array('zh-hans, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hans'),
+ ['zh-cn, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hans'],
+ ['zh-tw, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hant'],
+ ['zh-hant, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hant'],
+ ['zh-hans, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hans'],
// @todo: This is copied from RFC4647 but our regex skips the numbers so
// they where removed. Our code should be updated so private1-private2 is
// valid. http://tools.ietf.org/html/rfc4647#section-3.4
- array('zh-hant-CN-x-private-private, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hant'),
- array('zh-cn', 'zh-hans'),
- array('zh-sg', 'zh-hans'),
- array('zh-tw', 'zh-hant'),
- array('zh-hk', 'zh-hant'),
- array('zh-mo', 'zh-hant'),
- array('zh-hans', 'zh-hans'),
- array('zh-hant', 'zh-hant'),
- array('zh-chs', 'zh-hans'),
- array('zh-cht', 'zh-hant'),
- );
+ ['zh-hant-CN-x-private-private, en-us;q=0.90, en;q=0.80, zh;q=0.70', 'zh-hant'],
+ ['zh-cn', 'zh-hans'],
+ ['zh-sg', 'zh-hans'],
+ ['zh-tw', 'zh-hant'],
+ ['zh-hk', 'zh-hant'],
+ ['zh-mo', 'zh-hant'],
+ ['zh-hans', 'zh-hans'],
+ ['zh-hant', 'zh-hant'],
+ ['zh-chs', 'zh-hans'],
+ ['zh-cht', 'zh-hant'],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/VariableTest.php b/core/tests/Drupal/Tests/Component/Utility/VariableTest.php
index 0aef6d0688c..9096f87bfe9 100644
--- a/core/tests/Drupal/Tests/Component/Utility/VariableTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/VariableTest.php
@@ -29,72 +29,72 @@ class VariableTest extends UnitTestCase {
* - The variable to export.
*/
public function providerTestExport() {
- return array(
+ return [
// Array.
- array(
+ [
'array()',
- array(),
- ),
- array(
+ [],
+ ],
+ [
// non-associative.
"array(\n 1,\n 2,\n 3,\n 4,\n)",
- array(1, 2, 3, 4),
- ),
- array(
+ [1, 2, 3, 4],
+ ],
+ [
// associative.
"array(\n 'a' => 1,\n)",
- array('a' => 1),
- ),
+ ['a' => 1],
+ ],
// Bool.
- array(
+ [
'TRUE',
TRUE,
- ),
- array(
+ ],
+ [
'FALSE',
FALSE,
- ),
+ ],
// Strings.
- array(
+ [
"'string'",
'string',
- ),
- array(
+ ],
+ [
'"\n\r\t"',
"\n\r\t",
- ),
- array(
+ ],
+ [
// 2 backslashes. \\
"'\\'",
'\\',
- ),
- array(
+ ],
+ [
// Double-quote "
"'\"'",
"\"",
- ),
- array(
+ ],
+ [
// Single-quote '
'"\'"',
"'",
- ),
- array(
+ ],
+ [
// Quotes with $ symbols.
'"\$settings[\'foo\']"',
'$settings[\'foo\']',
- ),
+ ],
// Object.
- array(
+ [
// A stdClass object.
'(object) array()',
new \stdClass(),
- ),
- array(
+ ],
+ [
// A not-stdClass object.
"Drupal\Tests\Component\Utility\StubVariableTestClass::__set_state(array(\n))",
new StubVariableTestClass(),
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/Utility/XssTest.php b/core/tests/Drupal/Tests/Component/Utility/XssTest.php
index 0b2f51e1f41..e7832a31f0f 100644
--- a/core/tests/Drupal/Tests/Component/Utility/XssTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/XssTest.php
@@ -28,7 +28,7 @@ class XssTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- $allowed_protocols = array(
+ $allowed_protocols = [
'http',
'https',
'ftp',
@@ -41,7 +41,7 @@ class XssTest extends UnitTestCase {
'sftp',
'webcal',
'rtsp',
- );
+ ];
UrlHelper::setAllowedProtocols($allowed_protocols);
}
@@ -86,30 +86,30 @@ class XssTest extends UnitTestCase {
* \Drupal\Component\Utility\Xss::filter().
*/
public function providerTestFilterXssNormalized() {
- return array(
- array(
+ return [
+ [
"Who&#039;s Online",
"who's online",
'HTML filter -- html entity number',
- ),
- array(
+ ],
+ [
"Who&amp;#039;s Online",
"who&#039;s online",
'HTML filter -- encoded html entity number',
- ),
- array(
+ ],
+ [
"Who&amp;amp;#039; Online",
"who&amp;#039; online",
'HTML filter -- double encoded html entity number',
- ),
+ ],
// Custom elements with dashes in the tag name.
- array(
+ [
"<test-element></test-element>",
"<test-element></test-element>",
'Custom element with dashes in tag name.',
- array('test-element'),
- ),
- );
+ ['test-element'],
+ ],
+ ];
}
/**
@@ -153,289 +153,289 @@ class XssTest extends UnitTestCase {
* \Drupal\Component\Utility\Xss::filter().
*/
public function providerTestFilterXssNotNormalized() {
- $cases = array(
+ $cases = [
// Tag stripping, different ways to work around removal of HTML tags.
- array(
+ [
'<script>alert(0)</script>',
'script',
'HTML tag stripping -- simple script without special characters.',
- ),
- array(
+ ],
+ [
'<script src="http://www.example.com" />',
'script',
'HTML tag stripping -- empty script with source.',
- ),
- array(
+ ],
+ [
'<ScRipt sRc=http://www.example.com/>',
'script',
'HTML tag stripping evasion -- varying case.',
- ),
- array(
+ ],
+ [
"<script\nsrc\n=\nhttp://www.example.com/\n>",
'script',
'HTML tag stripping evasion -- multiline tag.',
- ),
- array(
+ ],
+ [
'<script/a src=http://www.example.com/a.js></script>',
'script',
'HTML tag stripping evasion -- non whitespace character after tag name.',
- ),
- array(
+ ],
+ [
'<script/src=http://www.example.com/a.js></script>',
'script',
'HTML tag stripping evasion -- no space between tag and attribute.',
- ),
+ ],
// Null between < and tag name works at least with IE6.
- array(
+ [
"<\0scr\0ipt>alert(0)</script>",
'ipt',
'HTML tag stripping evasion -- breaking HTML with nulls.',
- ),
- array(
+ ],
+ [
"<scrscriptipt src=http://www.example.com/a.js>",
'script',
'HTML tag stripping evasion -- filter just removing "script".',
- ),
- array(
+ ],
+ [
'<<script>alert(0);//<</script>',
'script',
'HTML tag stripping evasion -- double opening brackets.',
- ),
- array(
+ ],
+ [
'<script src=http://www.example.com/a.js?<b>',
'script',
'HTML tag stripping evasion -- no closing tag.',
- ),
+ ],
// DRUPAL-SA-2008-047: This doesn't seem exploitable, but the filter should
// work consistently.
- array(
+ [
'<script>>',
'script',
'HTML tag stripping evasion -- double closing tag.',
- ),
- array(
+ ],
+ [
'<script src=//www.example.com/.a>',
'script',
'HTML tag stripping evasion -- no scheme or ending slash.',
- ),
- array(
+ ],
+ [
'<script src=http://www.example.com/.a',
'script',
'HTML tag stripping evasion -- no closing bracket.',
- ),
- array(
+ ],
+ [
'<script src=http://www.example.com/ <',
'script',
'HTML tag stripping evasion -- opening instead of closing bracket.',
- ),
- array(
+ ],
+ [
'<nosuchtag attribute="newScriptInjectionVector">',
'nosuchtag',
'HTML tag stripping evasion -- unknown tag.',
- ),
- array(
+ ],
+ [
'<t:set attributeName="innerHTML" to="&lt;script defer&gt;alert(0)&lt;/script&gt;">',
't:set',
'HTML tag stripping evasion -- colon in the tag name (namespaces\' tricks).',
- ),
- array(
+ ],
+ [
'<img """><script>alert(0)</script>',
'script',
'HTML tag stripping evasion -- a malformed image tag.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<blockquote><script>alert(0)</script></blockquote>',
'script',
'HTML tag stripping evasion -- script in a blockqoute.',
- array('blockquote'),
- ),
- array(
+ ['blockquote'],
+ ],
+ [
"<!--[if true]><script>alert(0)</script><![endif]-->",
'script',
'HTML tag stripping evasion -- script within a comment.',
- ),
+ ],
// Dangerous attributes removal.
- array(
+ [
'<p onmouseover="http://www.example.com/">',
'onmouseover',
'HTML filter attributes removal -- events, no evasion.',
- array('p'),
- ),
- array(
+ ['p'],
+ ],
+ [
'<li style="list-style-image: url(javascript:alert(0))">',
'style',
'HTML filter attributes removal -- style, no evasion.',
- array('li'),
- ),
- array(
+ ['li'],
+ ],
+ [
'<img onerror =alert(0)>',
'onerror',
'HTML filter attributes removal evasion -- spaces before equals sign.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img onabort!#$%&()*~+-_.,:;?@[/|\]^`=alert(0)>',
'onabort',
'HTML filter attributes removal evasion -- non alphanumeric characters before equals sign.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img oNmediAError=alert(0)>',
'onmediaerror',
'HTML filter attributes removal evasion -- varying case.',
- array('img'),
- ),
+ ['img'],
+ ],
// Works at least with IE6.
- array(
+ [
"<img o\0nfocus\0=alert(0)>",
'focus',
'HTML filter attributes removal evasion -- breaking with nulls.',
- array('img'),
- ),
+ ['img'],
+ ],
// Only whitelisted scheme names allowed in attributes.
- array(
+ [
'<img src="javascript:alert(0)">',
'javascript',
'HTML scheme clearing -- no evasion.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src=javascript:alert(0)>',
'javascript',
'HTML scheme clearing evasion -- no quotes.',
- array('img'),
- ),
+ ['img'],
+ ],
// A bit like CVE-2006-0070.
- array(
+ [
'<img src="javascript:confirm(0)">',
'javascript',
'HTML scheme clearing evasion -- no alert ;)',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src=`javascript:alert(0)`>',
'javascript',
'HTML scheme clearing evasion -- grave accents.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img dynsrc="javascript:alert(0)">',
'javascript',
'HTML scheme clearing -- rare attribute.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<table background="javascript:alert(0)">',
'javascript',
'HTML scheme clearing -- another tag.',
- array('table'),
- ),
- array(
+ ['table'],
+ ],
+ [
'<base href="javascript:alert(0);//">',
'javascript',
'HTML scheme clearing -- one more attribute and tag.',
- array('base'),
- ),
- array(
+ ['base'],
+ ],
+ [
'<img src="jaVaSCriPt:alert(0)">',
'javascript',
'HTML scheme clearing evasion -- varying case.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#48;&#41;>',
'javascript',
'HTML scheme clearing evasion -- UTF-8 decimal encoding.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src=&#00000106&#0000097&#00000118&#0000097&#00000115&#0000099&#00000114&#00000105&#00000112&#00000116&#0000058&#0000097&#00000108&#00000101&#00000114&#00000116&#0000040&#0000048&#0000041>',
'javascript',
'HTML scheme clearing evasion -- long UTF-8 encoding.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x30&#x29>',
'javascript',
'HTML scheme clearing evasion -- UTF-8 hex encoding.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
"<img src=\"jav\tascript:alert(0)\">",
'script',
'HTML scheme clearing evasion -- an embedded tab.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src="jav&#x09;ascript:alert(0)">',
'script',
'HTML scheme clearing evasion -- an encoded, embedded tab.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src="jav&#x000000A;ascript:alert(0)">',
'script',
'HTML scheme clearing evasion -- an encoded, embedded newline.',
- array('img'),
- ),
+ ['img'],
+ ],
// With &#xD; this test would fail, but the entity gets turned into
// &amp;#xD;, so it's OK.
- array(
+ [
'<img src="jav&#x0D;ascript:alert(0)">',
'script',
'HTML scheme clearing evasion -- an encoded, embedded carriage return.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
"<img src=\"\n\n\nj\na\nva\ns\ncript:alert(0)\">",
'cript',
'HTML scheme clearing evasion -- broken into many lines.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
"<img src=\"jav\0a\0\0cript:alert(0)\">",
'cript',
'HTML scheme clearing evasion -- embedded nulls.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src="vbscript:msgbox(0)">',
'vbscript',
'HTML scheme clearing evasion -- another scheme.',
- array('img'),
- ),
- array(
+ ['img'],
+ ],
+ [
'<img src="nosuchscheme:notice(0)">',
'nosuchscheme',
'HTML scheme clearing evasion -- unknown scheme.',
- array('img'),
- ),
+ ['img'],
+ ],
// Netscape 4.x javascript entities.
- array(
+ [
'<br size="&{alert(0)}">',
'alert',
'Netscape 4.x javascript entities.',
- array('br'),
- ),
+ ['br'],
+ ],
// DRUPAL-SA-2008-006: Invalid UTF-8, these only work as reflected XSS with
// Internet Explorer 6.
- array(
+ [
"<p arg=\"\xe0\">\" style=\"background-image: url(javascript:alert(0));\"\xe0<p>",
'style',
'HTML filter -- invalid UTF-8.',
- array('p'),
- ),
- );
+ ['p'],
+ ],
+ ];
// @fixme This dataset currently fails under 5.4 because of
// https://www.drupal.org/node/1210798. Restore after its fixed.
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
- $cases[] = array(
+ $cases[] = [
'<img src=" &#14; javascript:alert(0)">',
'javascript',
'HTML scheme clearing evasion -- spaces and metacharacters before scheme.',
- array('img'),
- );
+ ['img'],
+ ];
}
return $cases;
}
@@ -468,11 +468,11 @@ class XssTest extends UnitTestCase {
* - The assertion message.
*/
public function providerTestInvalidMultiByte() {
- return array(
- array("Foo\xC0barbaz", '', 'Xss::filter() accepted invalid sequence "Foo\xC0barbaz"'),
- array("Fooÿñ", "Fooÿñ", 'Xss::filter() rejects valid sequence Fooÿñ"'),
- array("\xc0aaa", '', 'HTML filter -- overlong UTF-8 sequences.'),
- );
+ return [
+ ["Foo\xC0barbaz", '', 'Xss::filter() accepted invalid sequence "Foo\xC0barbaz"'],
+ ["Fooÿñ", "Fooÿñ", 'Xss::filter() rejects valid sequence Fooÿñ"'],
+ ["\xc0aaa", '', 'HTML filter -- overlong UTF-8 sequences.'],
+ ];
}
/**
@@ -498,38 +498,38 @@ class XssTest extends UnitTestCase {
* Data provider for testFilterXssAdminNotNormalized().
*/
public function providerTestAttributes() {
- return array(
- array(
+ return [
+ [
'<img src="http://example.com/foo.jpg" title="Example: title" alt="Example: alt">',
'<img src="http://example.com/foo.jpg" title="Example: title" alt="Example: alt">',
'Image tag with alt and title attribute',
- array('img')
- ),
- array(
+ ['img']
+ ],
+ [
'<a href="https://www.drupal.org/" rel="dc:publisher">Drupal</a>',
'<a href="https://www.drupal.org/" rel="dc:publisher">Drupal</a>',
'Link tag with rel attribute',
- array('a')
- ),
- array(
+ ['a']
+ ],
+ [
'<span property="dc:subject">Drupal 8: The best release ever.</span>',
'<span property="dc:subject">Drupal 8: The best release ever.</span>',
'Span tag with property attribute',
- array('span')
- ),
- array(
+ ['span']
+ ],
+ [
'<img src="http://example.com/foo.jpg" data-caption="Drupal 8: The best release ever.">',
'<img src="http://example.com/foo.jpg" data-caption="Drupal 8: The best release ever.">',
'Image tag with data attribute',
- array('img')
- ),
- array(
+ ['img']
+ ],
+ [
'<a data-a2a-url="foo"></a>',
'<a data-a2a-url="foo"></a>',
'Link tag with numeric data attribute',
- array('a')
- ),
- );
+ ['a']
+ ],
+ ];
}
/**
@@ -568,11 +568,11 @@ class XssTest extends UnitTestCase {
* - The assertion message.
*/
public function providerTestFilterXssAdminNotNormalized() {
- return array(
+ return [
// DRUPAL-SA-2008-044
- array('<object />', 'object', 'Admin HTML filter -- should not allow object tag.'),
- array('<script />', 'script', 'Admin HTML filter -- should not allow script tag.'),
- );
+ ['<object />', 'object', 'Admin HTML filter -- should not allow object tag.'],
+ ['<script />', 'script', 'Admin HTML filter -- should not allow script tag.'],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php b/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php
index a393bfb2775..a93dd0981a7 100644
--- a/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php
+++ b/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php
@@ -41,7 +41,7 @@ class UuidTest extends UnitTestCase {
*/
public function providerUuidInstances() {
- $instances = array();
+ $instances = [];
$instances[][] = new Php();
// If valid PECL extensions exists add to list.
@@ -83,15 +83,15 @@ class UuidTest extends UnitTestCase {
* - Failure message.
*/
public function providerTestValidation() {
- return array(
+ return [
// These valid UUIDs.
- array('6ba7b810-9dad-11d1-80b4-00c04fd430c8', TRUE, 'Basic FQDN UUID did not validate'),
- array('00000000-0000-0000-0000-000000000000', TRUE, 'Minimum UUID did not validate'),
- array('ffffffff-ffff-ffff-ffff-ffffffffffff', TRUE, 'Maximum UUID did not validate'),
+ ['6ba7b810-9dad-11d1-80b4-00c04fd430c8', TRUE, 'Basic FQDN UUID did not validate'],
+ ['00000000-0000-0000-0000-000000000000', TRUE, 'Minimum UUID did not validate'],
+ ['ffffffff-ffff-ffff-ffff-ffffffffffff', TRUE, 'Maximum UUID did not validate'],
// These are invalid UUIDs.
- array('0ab26e6b-f074-4e44-9da-601205fa0e976', FALSE, 'Invalid format was validated'),
- array('0ab26e6b-f074-4e44-9daf-1205fa0e9761f', FALSE, 'Invalid length was validated'),
- );
+ ['0ab26e6b-f074-4e44-9da-601205fa0e976', FALSE, 'Invalid format was validated'],
+ ['0ab26e6b-f074-4e44-9daf-1205fa0e9761f', FALSE, 'Invalid length was validated'],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
index eee52605939..c2a1da7ea19 100644
--- a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
@@ -100,25 +100,25 @@ class AccessManagerTest extends UnitTestCase {
$this->routeCollection = new RouteCollection();
$this->routeCollection->add('test_route_1', new Route('/test-route-1'));
- $this->routeCollection->add('test_route_2', new Route('/test-route-2', array(), array('_access' => 'TRUE')));
- $this->routeCollection->add('test_route_3', new Route('/test-route-3', array(), array('_access' => 'FALSE')));
- $this->routeCollection->add('test_route_4', new Route('/test-route-4/{value}', array(), array('_access' => 'TRUE')));
+ $this->routeCollection->add('test_route_2', new Route('/test-route-2', [], ['_access' => 'TRUE']));
+ $this->routeCollection->add('test_route_3', new Route('/test-route-3', [], ['_access' => 'FALSE']));
+ $this->routeCollection->add('test_route_4', new Route('/test-route-4/{value}', [], ['_access' => 'TRUE']));
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
- $map = array();
+ $map = [];
foreach ($this->routeCollection->all() as $name => $route) {
- $map[] = array($name, array(), $route);
+ $map[] = [$name, [], $route];
}
- $map[] = array('test_route_4', array('value' => 'example'), $this->routeCollection->get('test_route_4'));
+ $map[] = ['test_route_4', ['value' => 'example'], $this->routeCollection->get('test_route_4')];
$this->routeProvider->expects($this->any())
->method('getRouteByName')
->will($this->returnValueMap($map));
- $map = array();
- $map[] = array('test_route_1', array(), '/test-route-1');
- $map[] = array('test_route_2', array(), '/test-route-2');
- $map[] = array('test_route_3', array(), '/test-route-3');
- $map[] = array('test_route_4', array('value' => 'example'), '/test-route-4/example');
+ $map = [];
+ $map[] = ['test_route_1', [], '/test-route-1'];
+ $map[] = ['test_route_2', [], '/test-route-2'];
+ $map[] = ['test_route_3', [], '/test-route-3'];
+ $map[] = ['test_route_4', ['value' => 'example'], '/test-route-4/example'];
$this->paramConverter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
@@ -147,8 +147,8 @@ class AccessManagerTest extends UnitTestCase {
$this->checkProvider->setChecks($this->routeCollection);
$this->assertEquals($this->routeCollection->get('test_route_1')->getOption('_access_checks'), NULL);
- $this->assertEquals($this->routeCollection->get('test_route_2')->getOption('_access_checks'), array('test_access_default'));
- $this->assertEquals($this->routeCollection->get('test_route_3')->getOption('_access_checks'), array('test_access_default'));
+ $this->assertEquals($this->routeCollection->get('test_route_2')->getOption('_access_checks'), ['test_access_default']);
+ $this->assertEquals($this->routeCollection->get('test_route_3')->getOption('_access_checks'), ['test_access_default']);
}
/**
@@ -163,8 +163,8 @@ class AccessManagerTest extends UnitTestCase {
$this->container->set('test_access', $access_check);
$this->checkProvider->addCheckService('test_access', 'access');
- $route = new Route('/test-path', array(), array('_foo' => '1', '_bar' => '1'));
- $route2 = new Route('/test-path', array(), array('_foo' => '1', '_bar' => '2'));
+ $route = new Route('/test-path', [], ['_foo' => '1', '_bar' => '1']);
+ $route2 = new Route('/test-path', [], ['_foo' => '1', '_bar' => '2']);
$collection = new RouteCollection();
$collection->add('test_route', $route);
$collection->add('test_route2', $route2);
@@ -178,7 +178,7 @@ class AccessManagerTest extends UnitTestCase {
$this->checkProvider->setChecks($collection);
$this->assertEmpty($route->getOption('_access_checks'));
- $this->assertEquals(array('test_access'), $route2->getOption('_access_checks'));
+ $this->assertEquals(['test_access'], $route2->getOption('_access_checks'));
}
/**
@@ -254,43 +254,43 @@ class AccessManagerTest extends UnitTestCase {
$access_deny = AccessResult::neutral();
$access_kill = AccessResult::forbidden();
- $access_configurations = array();
- $access_configurations[] = array(
+ $access_configurations = [];
+ $access_configurations[] = [
'name' => 'test_route_4',
'condition_one' => 'TRUE',
'condition_two' => 'FALSE',
'expected' => $access_kill,
- );
- $access_configurations[] = array(
+ ];
+ $access_configurations[] = [
'name' => 'test_route_5',
'condition_one' => 'TRUE',
'condition_two' => 'NULL',
'expected' => $access_deny,
- );
- $access_configurations[] = array(
+ ];
+ $access_configurations[] = [
'name' => 'test_route_6',
'condition_one' => 'FALSE',
'condition_two' => 'NULL',
'expected' => $access_kill,
- );
- $access_configurations[] = array(
+ ];
+ $access_configurations[] = [
'name' => 'test_route_7',
'condition_one' => 'TRUE',
'condition_two' => 'TRUE',
'expected' => $access_allow,
- );
- $access_configurations[] = array(
+ ];
+ $access_configurations[] = [
'name' => 'test_route_8',
'condition_one' => 'FALSE',
'condition_two' => 'FALSE',
'expected' => $access_kill,
- );
- $access_configurations[] = array(
+ ];
+ $access_configurations[] = [
'name' => 'test_route_9',
'condition_one' => 'NULL',
'condition_two' => 'NULL',
'expected' => $access_deny,
- );
+ ];
return $access_configurations;
}
@@ -304,21 +304,21 @@ class AccessManagerTest extends UnitTestCase {
$this->setupAccessChecker();
$access_check = new DefinedTestAccessCheck();
$this->container->register('test_access_defined', $access_check);
- $this->checkProvider->addCheckService('test_access_defined', 'access', array('_test_access'));
+ $this->checkProvider->addCheckService('test_access_defined', 'access', ['_test_access']);
$route_collection = new RouteCollection();
// Setup a test route for each access configuration.
- $requirements = array(
+ $requirements = [
'_access' => $condition_one,
'_test_access' => $condition_two,
- );
- $route = new Route($name, array(), $requirements);
+ ];
+ $route = new Route($name, [], $requirements);
$route_collection->add($name, $route);
$this->checkProvider->setChecks($route_collection);
$this->setupAccessArgumentsResolverFactory();
- $route_match = new RouteMatch($name, $route, array(), array());
+ $route_match = new RouteMatch($name, $route, [], []);
$this->assertEquals($expected_access->isAllowed(), $this->accessManager->check($route_match, $this->account));
$this->assertEquals($expected_access, $this->accessManager->check($route_match, $this->account, NULL, TRUE));
}
@@ -335,27 +335,27 @@ class AccessManagerTest extends UnitTestCase {
$this->paramConverter->expects($this->at(0))
->method('convert')
- ->with(array(RouteObjectInterface::ROUTE_NAME => 'test_route_2', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_2')))
- ->will($this->returnValue(array()));
+ ->with([RouteObjectInterface::ROUTE_NAME => 'test_route_2', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_2')])
+ ->will($this->returnValue([]));
$this->paramConverter->expects($this->at(1))
->method('convert')
- ->with(array(RouteObjectInterface::ROUTE_NAME => 'test_route_2', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_2')))
- ->will($this->returnValue(array()));
+ ->with([RouteObjectInterface::ROUTE_NAME => 'test_route_2', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_2')])
+ ->will($this->returnValue([]));
$this->paramConverter->expects($this->at(2))
->method('convert')
- ->with(array('value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_4', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_4')))
- ->will($this->returnValue(array('value' => 'example')));
+ ->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_4', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_4')])
+ ->will($this->returnValue(['value' => 'example']));
$this->paramConverter->expects($this->at(3))
->method('convert')
- ->with(array('value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_4', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_4')))
- ->will($this->returnValue(array('value' => 'example')));
+ ->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_4', RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection->get('test_route_4')])
+ ->will($this->returnValue(['value' => 'example']));
// Tests the access with routes with parameters without given request.
- $this->assertEquals(TRUE, $this->accessManager->checkNamedRoute('test_route_2', array(), $this->account));
- $this->assertEquals(AccessResult::allowed(), $this->accessManager->checkNamedRoute('test_route_2', array(), $this->account, TRUE));
- $this->assertEquals(TRUE, $this->accessManager->checkNamedRoute('test_route_4', array('value' => 'example'), $this->account));
- $this->assertEquals(AccessResult::allowed(), $this->accessManager->checkNamedRoute('test_route_4', array('value' => 'example'), $this->account, TRUE));
+ $this->assertEquals(TRUE, $this->accessManager->checkNamedRoute('test_route_2', [], $this->account));
+ $this->assertEquals(AccessResult::allowed(), $this->accessManager->checkNamedRoute('test_route_2', [], $this->account, TRUE));
+ $this->assertEquals(TRUE, $this->accessManager->checkNamedRoute('test_route_4', ['value' => 'example'], $this->account));
+ $this->assertEquals(AccessResult::allowed(), $this->accessManager->checkNamedRoute('test_route_4', ['value' => 'example'], $this->account, TRUE));
}
/**
@@ -365,23 +365,23 @@ class AccessManagerTest extends UnitTestCase {
*/
public function testCheckNamedRouteWithUpcastedValues() {
$this->routeCollection = new RouteCollection();
- $route = new Route('/test-route-1/{value}', array(), array('_test_access' => 'TRUE'));
+ $route = new Route('/test-route-1/{value}', [], ['_test_access' => 'TRUE']);
$this->routeCollection->add('test_route_1', $route);
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
$this->routeProvider->expects($this->any())
->method('getRouteByName')
- ->with('test_route_1', array('value' => 'example'))
+ ->with('test_route_1', ['value' => 'example'])
->will($this->returnValue($route));
- $map = array();
- $map[] = array('test_route_1', array('value' => 'example'), '/test-route-1/example');
+ $map = [];
+ $map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
$this->paramConverter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
$this->paramConverter->expects($this->atLeastOnce())
->method('convert')
- ->with(array('value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route))
- ->will($this->returnValue(array('value' => 'upcasted_value')));
+ ->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route])
+ ->will($this->returnValue(['value' => 'upcasted_value']));
$this->setupAccessArgumentsResolverFactory($this->exactly(2))
->with($this->callback(function ($route_match) {
@@ -403,8 +403,8 @@ class AccessManagerTest extends UnitTestCase {
$this->checkProvider->addCheckService('test_access', 'access');
$this->checkProvider->setChecks($this->routeCollection);
- $this->assertEquals(FALSE, $this->accessManager->checkNamedRoute('test_route_1', array('value' => 'example'), $this->account));
- $this->assertEquals(AccessResult::forbidden(), $this->accessManager->checkNamedRoute('test_route_1', array('value' => 'example'), $this->account, TRUE));
+ $this->assertEquals(FALSE, $this->accessManager->checkNamedRoute('test_route_1', ['value' => 'example'], $this->account));
+ $this->assertEquals(AccessResult::forbidden(), $this->accessManager->checkNamedRoute('test_route_1', ['value' => 'example'], $this->account, TRUE));
}
/**
@@ -414,23 +414,23 @@ class AccessManagerTest extends UnitTestCase {
*/
public function testCheckNamedRouteWithDefaultValue() {
$this->routeCollection = new RouteCollection();
- $route = new Route('/test-route-1/{value}', array('value' => 'example'), array('_test_access' => 'TRUE'));
+ $route = new Route('/test-route-1/{value}', ['value' => 'example'], ['_test_access' => 'TRUE']);
$this->routeCollection->add('test_route_1', $route);
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
$this->routeProvider->expects($this->any())
->method('getRouteByName')
- ->with('test_route_1', array())
+ ->with('test_route_1', [])
->will($this->returnValue($route));
- $map = array();
- $map[] = array('test_route_1', array('value' => 'example'), '/test-route-1/example');
+ $map = [];
+ $map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
$this->paramConverter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
$this->paramConverter->expects($this->atLeastOnce())
->method('convert')
- ->with(array('value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route))
- ->will($this->returnValue(array('value' => 'upcasted_value')));
+ ->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route])
+ ->will($this->returnValue(['value' => 'upcasted_value']));
$this->setupAccessArgumentsResolverFactory($this->exactly(2))
->with($this->callback(function ($route_match) {
@@ -452,8 +452,8 @@ class AccessManagerTest extends UnitTestCase {
$this->checkProvider->addCheckService('test_access', 'access');
$this->checkProvider->setChecks($this->routeCollection);
- $this->assertEquals(FALSE, $this->accessManager->checkNamedRoute('test_route_1', array(), $this->account));
- $this->assertEquals(AccessResult::forbidden(), $this->accessManager->checkNamedRoute('test_route_1', array(), $this->account, TRUE));
+ $this->assertEquals(FALSE, $this->accessManager->checkNamedRoute('test_route_1', [], $this->account));
+ $this->assertEquals(AccessResult::forbidden(), $this->accessManager->checkNamedRoute('test_route_1', [], $this->account, TRUE));
}
/**
@@ -466,8 +466,8 @@ class AccessManagerTest extends UnitTestCase {
$this->setupAccessChecker();
- $this->assertEquals(FALSE, $this->accessManager->checkNamedRoute('test_route_1', array(), $this->account), 'A non existing route lead to access.');
- $this->assertEquals(AccessResult::forbidden()->addCacheTags(['config:core.extension']), $this->accessManager->checkNamedRoute('test_route_1', array(), $this->account, TRUE), 'A non existing route lead to access.');
+ $this->assertEquals(FALSE, $this->accessManager->checkNamedRoute('test_route_1', [], $this->account), 'A non existing route lead to access.');
+ $this->assertEquals(AccessResult::forbidden()->addCacheTags(['config:core.extension']), $this->accessManager->checkNamedRoute('test_route_1', [], $this->account, TRUE), 'A non existing route lead to access.');
}
/**
@@ -481,15 +481,15 @@ class AccessManagerTest extends UnitTestCase {
$route_provider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
// Setup a test route for each access configuration.
- $requirements = array(
+ $requirements = [
'_test_incorrect_value' => 'TRUE',
- );
- $options = array(
- '_access_checks' => array(
+ ];
+ $options = [
+ '_access_checks' => [
'test_incorrect_value',
- ),
- );
- $route = new Route('', array(), $requirements, $options);
+ ],
+ ];
+ $route = new Route('', [], $requirements, $options);
$route_provider->expects($this->any())
->method('getRouteByName')
@@ -498,7 +498,7 @@ class AccessManagerTest extends UnitTestCase {
$this->paramConverter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
$this->paramConverter->expects($this->any())
->method('convert')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->setupAccessArgumentsResolverFactory();
@@ -515,7 +515,7 @@ class AccessManagerTest extends UnitTestCase {
$this->checkProvider->setContainer($container);
$this->checkProvider->addCheckService('test_incorrect_value', 'access');
- $access_manager->checkNamedRoute('test_incorrect_value', array(), $this->account);
+ $access_manager->checkNamedRoute('test_incorrect_value', [], $this->account);
}
/**
@@ -524,12 +524,12 @@ class AccessManagerTest extends UnitTestCase {
* @return array
*/
public function providerCheckException() {
- return array(
- array(array(1)),
- array('string'),
- array(0),
- array(1),
- );
+ return [
+ [[1]],
+ ['string'],
+ [0],
+ [1],
+ ];
}
/**
@@ -538,7 +538,7 @@ class AccessManagerTest extends UnitTestCase {
protected function setupAccessChecker() {
$access_check = new DefaultAccessCheck();
$this->container->register('test_access_default', $access_check);
- $this->checkProvider->addCheckService('test_access_default', 'access', array('_access'));
+ $this->checkProvider->addCheckService('test_access_default', 'access', ['_access']);
}
/**
@@ -555,7 +555,7 @@ class AccessManagerTest extends UnitTestCase {
$resolver->expects($this->any())
->method('getArguments')
->will($this->returnCallback(function ($callable) use ($route_match) {
- return array($route_match->getRouteObject());
+ return [$route_match->getRouteObject()];
}));
return $resolver;
}));
diff --git a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
index c1b6c65fb6a..647da61255a 100644
--- a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
@@ -397,7 +397,7 @@ class AccessResultTest extends UnitTestCase {
$verify($access, ['bar', 'foo']);
// ::cachePerPermissions() convenience method.
- $contexts = array('user.permissions');
+ $contexts = ['user.permissions'];
$a = AccessResult::neutral()->addCacheContexts($contexts);
$verify($a, $contexts);
$b = AccessResult::neutral()->cachePerPermissions();
@@ -405,7 +405,7 @@ class AccessResultTest extends UnitTestCase {
$this->assertEquals($a, $b);
// ::cachePerUser() convenience method.
- $contexts = array('user');
+ $contexts = ['user'];
$a = AccessResult::neutral()->addCacheContexts($contexts);
$verify($a, $contexts);
$b = AccessResult::neutral()->cachePerUser();
@@ -413,7 +413,7 @@ class AccessResultTest extends UnitTestCase {
$this->assertEquals($a, $b);
// Both.
- $contexts = array('user', 'user.permissions');
+ $contexts = ['user', 'user.permissions'];
$a = AccessResult::neutral()->addCacheContexts($contexts);
$verify($a, $contexts);
$b = AccessResult::neutral()->cachePerPermissions()->cachePerUser();
@@ -429,7 +429,7 @@ class AccessResultTest extends UnitTestCase {
->method('hasPermission')
->with('may herd llamas')
->will($this->returnValue(FALSE));
- $contexts = array('user.permissions');
+ $contexts = ['user.permissions'];
// Verify the object when using the ::allowedIfHasPermission() convenience
// static method.
@@ -480,14 +480,14 @@ class AccessResultTest extends UnitTestCase {
$node = $this->getMock('\Drupal\node\NodeInterface');
$node->expects($this->any())
->method('getCacheTags')
- ->will($this->returnValue(array('node:20011988')));
+ ->will($this->returnValue(['node:20011988']));
$node->expects($this->any())
->method('getCacheMaxAge')
->willReturn(600);
$node->expects($this->any())
->method('getCacheContexts')
->willReturn(['user']);
- $tags = array('node:20011988');
+ $tags = ['node:20011988'];
$a = AccessResult::neutral()->addCacheTags($tags);
$verify($a, $tags);
$b = AccessResult::neutral()->addCacheableDependency($node);
diff --git a/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php
index b88373cade3..edbbfba2153 100644
--- a/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php
@@ -56,9 +56,9 @@ class CsrfAccessCheckTest extends UnitTestCase {
$this->routeMatch->expects($this->once())
->method('getRawParameters')
- ->will($this->returnValue(array('node' => 42)));
+ ->will($this->returnValue(['node' => 42]));
- $route = new Route('/test-path/{node}', array(), array('_csrf_token' => 'TRUE'));
+ $route = new Route('/test-path/{node}', [], ['_csrf_token' => 'TRUE']);
$request = Request::create('/test-path/42?token=test_query');
$this->assertEquals(AccessResult::allowed()->setCacheMaxAge(0), $this->accessCheck->access($route, $request, $this->routeMatch));
@@ -75,9 +75,9 @@ class CsrfAccessCheckTest extends UnitTestCase {
$this->routeMatch->expects($this->once())
->method('getRawParameters')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
- $route = new Route('/test-path', array(), array('_csrf_token' => 'TRUE'));
+ $route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
$request = Request::create('/test-path?token=test_query');
$this->assertEquals(AccessResult::forbidden("'csrf_token' URL query argument is invalid.")->setCacheMaxAge(0), $this->accessCheck->access($route, $request, $this->routeMatch));
@@ -94,9 +94,9 @@ class CsrfAccessCheckTest extends UnitTestCase {
$this->routeMatch->expects($this->once())
->method('getRawParameters')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
- $route = new Route('/test-path', array(), array('_csrf_token' => 'TRUE'));
+ $route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
$request = Request::create('/test-path');
$this->assertEquals(AccessResult::forbidden("'csrf_token' URL query argument is missing.")->setCacheMaxAge(0), $this->accessCheck->access($route, $request, $this->routeMatch));
}
diff --git a/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php b/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
index 6eabd37cb51..cc4691d74ca 100644
--- a/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
@@ -44,16 +44,16 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
$this->privateKey = $this->getMockBuilder('Drupal\Core\PrivateKey')
->disableOriginalConstructor()
- ->setMethods(array('get'))
+ ->setMethods(['get'])
->getMock();
$this->sessionMetadata = $this->getMockBuilder('Drupal\Core\Session\MetadataBag')
->disableOriginalConstructor()
->getMock();
- $settings = array(
+ $settings = [
'hash_salt' => $this->randomMachineName(),
- );
+ ];
new Settings($settings);
@@ -154,11 +154,11 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
* An array of data used by the test.
*/
public function providerTestValidateParameterTypes() {
- return array(
- array(array(), ''),
- array(TRUE, 'foo'),
- array(0, 'foo'),
- );
+ return [
+ [[], ''],
+ [TRUE, 'foo'],
+ [0, 'foo'],
+ ];
}
/**
@@ -186,12 +186,12 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
* An array of data used by the test.
*/
public function providerTestInvalidParameterTypes() {
- return array(
- array(NULL, new \stdClass()),
- array(0, array()),
- array('', array()),
- array(array(), array()),
- );
+ return [
+ [NULL, new \stdClass()],
+ [0, []],
+ ['', []],
+ [[], []],
+ ];
}
/**
@@ -202,7 +202,7 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
*/
public function testGetWithNoHashSalt() {
// Update settings with no hash salt.
- new Settings(array());
+ new Settings([]);
$generator = new CsrfTokenGenerator($this->privateKey, $this->sessionMetadata);
$generator->get();
}
diff --git a/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php
index 36d330de37d..9f0c2c9db40 100644
--- a/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php
@@ -59,12 +59,12 @@ class CustomAccessCheckTest extends UnitTestCase {
$this->controllerResolver->expects($this->at(0))
->method('getControllerFromDefinition')
->with('\Drupal\Tests\Core\Access\TestController::accessDeny')
- ->will($this->returnValue(array(new TestController(), 'accessDeny')));
+ ->will($this->returnValue([new TestController(), 'accessDeny']));
$resolver0 = $this->getMock('Drupal\Component\Utility\ArgumentsResolverInterface');
$resolver0->expects($this->once())
->method('getArguments')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->argumentsResolverFactory->expects($this->at(0))
->method('getArgumentsResolver')
->will($this->returnValue($resolver0));
@@ -72,12 +72,12 @@ class CustomAccessCheckTest extends UnitTestCase {
$this->controllerResolver->expects($this->at(1))
->method('getControllerFromDefinition')
->with('\Drupal\Tests\Core\Access\TestController::accessAllow')
- ->will($this->returnValue(array(new TestController(), 'accessAllow')));
+ ->will($this->returnValue([new TestController(), 'accessAllow']));
$resolver1 = $this->getMock('Drupal\Component\Utility\ArgumentsResolverInterface');
$resolver1->expects($this->once())
->method('getArguments')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->argumentsResolverFactory->expects($this->at(1))
->method('getArgumentsResolver')
->will($this->returnValue($resolver1));
@@ -85,24 +85,24 @@ class CustomAccessCheckTest extends UnitTestCase {
$this->controllerResolver->expects($this->at(2))
->method('getControllerFromDefinition')
->with('\Drupal\Tests\Core\Access\TestController::accessParameter')
- ->will($this->returnValue(array(new TestController(), 'accessParameter')));
+ ->will($this->returnValue([new TestController(), 'accessParameter']));
$resolver2 = $this->getMock('Drupal\Component\Utility\ArgumentsResolverInterface');
$resolver2->expects($this->once())
->method('getArguments')
- ->will($this->returnValue(array('parameter' => 'TRUE')));
+ ->will($this->returnValue(['parameter' => 'TRUE']));
$this->argumentsResolverFactory->expects($this->at(2))
->method('getArgumentsResolver')
->will($this->returnValue($resolver2));
- $route = new Route('/test-route', array(), array('_custom_access' => '\Drupal\Tests\Core\Access\TestController::accessDeny'));
+ $route = new Route('/test-route', [], ['_custom_access' => '\Drupal\Tests\Core\Access\TestController::accessDeny']);
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
$this->assertEquals(AccessResult::neutral(), $this->accessChecker->access($route, $route_match, $account));
- $route = new Route('/test-route', array(), array('_custom_access' => '\Drupal\Tests\Core\Access\TestController::accessAllow'));
+ $route = new Route('/test-route', [], ['_custom_access' => '\Drupal\Tests\Core\Access\TestController::accessAllow']);
$this->assertEquals(AccessResult::allowed(), $this->accessChecker->access($route, $route_match, $account));
- $route = new Route('/test-route', array('parameter' => 'TRUE'), array('_custom_access' => '\Drupal\Tests\Core\Access\TestController::accessParameter'));
+ $route = new Route('/test-route', ['parameter' => 'TRUE'], ['_custom_access' => '\Drupal\Tests\Core\Access\TestController::accessParameter']);
$this->assertEquals(AccessResult::allowed(), $this->accessChecker->access($route, $route_match, $account));
}
diff --git a/core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php
index ad447f8b161..e46585844f8 100644
--- a/core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php
@@ -42,15 +42,15 @@ class DefaultAccessCheckTest extends UnitTestCase {
* Test the access method.
*/
public function testAccess() {
- $request = new Request(array());
+ $request = new Request([]);
- $route = new Route('/test-route', array(), array('_access' => 'NULL'));
+ $route = new Route('/test-route', [], ['_access' => 'NULL']);
$this->assertEquals(AccessResult::neutral(), $this->accessChecker->access($route, $request, $this->account));
- $route = new Route('/test-route', array(), array('_access' => 'FALSE'));
+ $route = new Route('/test-route', [], ['_access' => 'FALSE']);
$this->assertEquals(AccessResult::forbidden(), $this->accessChecker->access($route, $request, $this->account));
- $route = new Route('/test-route', array(), array('_access' => 'TRUE'));
+ $route = new Route('/test-route', [], ['_access' => 'TRUE']);
$this->assertEquals(AccessResult::allowed(), $this->accessChecker->access($route, $request, $this->account));
}
diff --git a/core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php b/core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php
index 1a36c3d7689..2fef35f3d57 100644
--- a/core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/RouteProcessorCsrfTest.php
@@ -44,7 +44,7 @@ class RouteProcessorCsrfTest extends UnitTestCase {
->method('get');
$route = new Route('/test-path');
- $parameters = array();
+ $parameters = [];
$bubbleable_metadata = new BubbleableMetadata();
$this->processor->processOutbound('test', $route, $parameters, $bubbleable_metadata);
@@ -59,8 +59,8 @@ class RouteProcessorCsrfTest extends UnitTestCase {
* Tests the processOutbound() method with a _csrf_token route requirement.
*/
public function testProcessOutbound() {
- $route = new Route('/test-path', array(), array('_csrf_token' => 'TRUE'));
- $parameters = array();
+ $route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
+ $parameters = [];
$bubbleable_metadata = new BubbleableMetadata();
$this->processor->processOutbound('test', $route, $parameters, $bubbleable_metadata);
@@ -81,8 +81,8 @@ class RouteProcessorCsrfTest extends UnitTestCase {
* Tests the processOutbound() method with a dynamic path and one replacement.
*/
public function testProcessOutboundDynamicOne() {
- $route = new Route('/test-path/{slug}', array(), array('_csrf_token' => 'TRUE'));
- $parameters = array('slug' => 100);
+ $route = new Route('/test-path/{slug}', [], ['_csrf_token' => 'TRUE']);
+ $parameters = ['slug' => 100];
$bubbleable_metadata = new BubbleableMetadata();
$this->processor->processOutbound('test', $route, $parameters, $bubbleable_metadata);
@@ -100,8 +100,8 @@ class RouteProcessorCsrfTest extends UnitTestCase {
* Tests the processOutbound() method with two parameter replacements.
*/
public function testProcessOutboundDynamicTwo() {
- $route = new Route('{slug_1}/test-path/{slug_2}', array(), array('_csrf_token' => 'TRUE'));
- $parameters = array('slug_1' => 100, 'slug_2' => 'test');
+ $route = new Route('{slug_1}/test-path/{slug_2}', [], ['_csrf_token' => 'TRUE']);
+ $parameters = ['slug_1' => 100, 'slug_2' => 'test'];
$bubbleable_metadata = new BubbleableMetadata();
$this->processor->processOutbound('test', $route, $parameters, $bubbleable_metadata);
diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
index a076e545f0c..215d9224d91 100644
--- a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
+++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
@@ -38,10 +38,10 @@ class AjaxCommandsTest extends UnitTestCase {
public function testAddCssCommand() {
$command = new AddCssCommand('p{ text-decoration:blink; }');
- $expected = array(
+ $expected = [
'command' => 'add_css',
'data' => 'p{ text-decoration:blink; }',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -50,15 +50,15 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\AfterCommand
*/
public function testAfterCommand() {
- $command = new AfterCommand('#page-title', '<p>New Text!</p>', array('my-setting' => 'setting'));
+ $command = new AfterCommand('#page-title', '<p>New Text!</p>', ['my-setting' => 'setting']);
- $expected = array(
+ $expected = [
'command' => 'insert',
'method' => 'after',
'selector' => '#page-title',
'data' => '<p>New Text!</p>',
- 'settings' => array('my-setting' => 'setting'),
- );
+ 'settings' => ['my-setting' => 'setting'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -68,10 +68,10 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testAlertCommand() {
$command = new AlertCommand('Set condition 1 throughout the ship!');
- $expected = array(
+ $expected = [
'command' => 'alert',
'text' => 'Set condition 1 throughout the ship!',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -80,15 +80,15 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\AppendCommand
*/
public function testAppendCommand() {
- $command = new AppendCommand('#page-title', '<p>New Text!</p>', array('my-setting' => 'setting'));
+ $command = new AppendCommand('#page-title', '<p>New Text!</p>', ['my-setting' => 'setting']);
- $expected = array(
+ $expected = [
'command' => 'insert',
'method' => 'append',
'selector' => '#page-title',
'data' => '<p>New Text!</p>',
- 'settings' => array('my-setting' => 'setting'),
- );
+ 'settings' => ['my-setting' => 'setting'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -97,15 +97,15 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\BeforeCommand
*/
public function testBeforeCommand() {
- $command = new BeforeCommand('#page-title', '<p>New Text!</p>', array('my-setting' => 'setting'));
+ $command = new BeforeCommand('#page-title', '<p>New Text!</p>', ['my-setting' => 'setting']);
- $expected = array(
+ $expected = [
'command' => 'insert',
'method' => 'before',
'selector' => '#page-title',
'data' => '<p>New Text!</p>',
- 'settings' => array('my-setting' => 'setting'),
- );
+ 'settings' => ['my-setting' => 'setting'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -116,11 +116,11 @@ class AjaxCommandsTest extends UnitTestCase {
public function testChangedCommand() {
$command = new ChangedCommand('#page-title', '#page-title-changed');
- $expected = array(
+ $expected = [
'command' => 'changed',
'selector' => '#page-title',
'asterisk' => '#page-title-changed',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -129,18 +129,18 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\CssCommand
*/
public function testCssCommand() {
- $command = new CssCommand('#page-title', array('text-decoration' => 'blink'));
+ $command = new CssCommand('#page-title', ['text-decoration' => 'blink']);
$command->setProperty('font-size', '40px')->setProperty('font-weight', 'bold');
- $expected = array(
+ $expected = [
'command' => 'css',
'selector' => '#page-title',
- 'argument' => array(
+ 'argument' => [
'text-decoration' => 'blink',
'font-size' => '40px',
'font-weight' => 'bold',
- ),
- );
+ ],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -149,14 +149,14 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\DataCommand
*/
public function testDataCommand() {
- $command = new DataCommand('#page-title', 'my-data', array('key' => 'value'));
+ $command = new DataCommand('#page-title', 'my-data', ['key' => 'value']);
- $expected = array(
+ $expected = [
'command' => 'data',
'selector' => '#page-title',
'name' => 'my-data',
- 'value' => array('key' => 'value'),
- );
+ 'value' => ['key' => 'value'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -165,15 +165,15 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\HtmlCommand
*/
public function testHtmlCommand() {
- $command = new HtmlCommand('#page-title', '<p>New Text!</p>', array('my-setting' => 'setting'));
+ $command = new HtmlCommand('#page-title', '<p>New Text!</p>', ['my-setting' => 'setting']);
- $expected = array(
+ $expected = [
'command' => 'insert',
'method' => 'html',
'selector' => '#page-title',
'data' => '<p>New Text!</p>',
- 'settings' => array('my-setting' => 'setting'),
- );
+ 'settings' => ['my-setting' => 'setting'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -182,15 +182,15 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\InsertCommand
*/
public function testInsertCommand() {
- $command = new InsertCommand('#page-title', '<p>New Text!</p>', array('my-setting' => 'setting'));
+ $command = new InsertCommand('#page-title', '<p>New Text!</p>', ['my-setting' => 'setting']);
- $expected = array(
+ $expected = [
'command' => 'insert',
'method' => NULL,
'selector' => '#page-title',
'data' => '<p>New Text!</p>',
- 'settings' => array('my-setting' => 'setting'),
- );
+ 'settings' => ['my-setting' => 'setting'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -199,14 +199,14 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\InvokeCommand
*/
public function testInvokeCommand() {
- $command = new InvokeCommand('#page-title', 'myMethod', array('var1', 'var2'));
+ $command = new InvokeCommand('#page-title', 'myMethod', ['var1', 'var2']);
- $expected = array(
+ $expected = [
'command' => 'invoke',
'selector' => '#page-title',
'method' => 'myMethod',
- 'args' => array('var1', 'var2'),
- );
+ 'args' => ['var1', 'var2'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -215,15 +215,15 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\PrependCommand
*/
public function testPrependCommand() {
- $command = new PrependCommand('#page-title', '<p>New Text!</p>', array('my-setting' => 'setting'));
+ $command = new PrependCommand('#page-title', '<p>New Text!</p>', ['my-setting' => 'setting']);
- $expected = array(
+ $expected = [
'command' => 'insert',
'method' => 'prepend',
'selector' => '#page-title',
'data' => '<p>New Text!</p>',
- 'settings' => array('my-setting' => 'setting'),
- );
+ 'settings' => ['my-setting' => 'setting'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -234,10 +234,10 @@ class AjaxCommandsTest extends UnitTestCase {
public function testRemoveCommand() {
$command = new RemoveCommand('#page-title');
- $expected = array(
+ $expected = [
'command' => 'remove',
'selector' => '#page-title',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -246,15 +246,15 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\ReplaceCommand
*/
public function testReplaceCommand() {
- $command = new ReplaceCommand('#page-title', '<p>New Text!</p>', array('my-setting' => 'setting'));
+ $command = new ReplaceCommand('#page-title', '<p>New Text!</p>', ['my-setting' => 'setting']);
- $expected = array(
+ $expected = [
'command' => 'insert',
'method' => 'replaceWith',
'selector' => '#page-title',
'data' => '<p>New Text!</p>',
- 'settings' => array('my-setting' => 'setting'),
- );
+ 'settings' => ['my-setting' => 'setting'],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -265,10 +265,10 @@ class AjaxCommandsTest extends UnitTestCase {
public function testRestripeCommand() {
$command = new RestripeCommand('#page-title');
- $expected = array(
+ $expected = [
'command' => 'restripe',
'selector' => '#page-title',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -277,13 +277,13 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\SettingsCommand
*/
public function testSettingsCommand() {
- $command = new SettingsCommand(array('key' => 'value'), TRUE);
+ $command = new SettingsCommand(['key' => 'value'], TRUE);
- $expected = array(
+ $expected = [
'command' => 'settings',
- 'settings' => array('key' => 'value'),
+ 'settings' => ['key' => 'value'],
'merge' => TRUE,
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -293,13 +293,13 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testOpenDialogCommand() {
$command = $this->getMockBuilder('Drupal\Core\Ajax\OpenDialogCommand')
- ->setConstructorArgs(array(
- '#some-dialog', 'Title', '<p>Text!</p>', array(
+ ->setConstructorArgs([
+ '#some-dialog', 'Title', '<p>Text!</p>', [
'url' => FALSE,
'width' => 500,
- ),
- ))
- ->setMethods(array('getRenderedContent'))
+ ],
+ ])
+ ->setMethods(['getRenderedContent'])
->getMock();
// This method calls the render service, which isn't available. We want it
@@ -308,18 +308,18 @@ class AjaxCommandsTest extends UnitTestCase {
->method('getRenderedContent')
->willReturn('rendered content');
- $expected = array(
+ $expected = [
'command' => 'openDialog',
'selector' => '#some-dialog',
'settings' => NULL,
'data' => 'rendered content',
- 'dialogOptions' => array(
+ 'dialogOptions' => [
'url' => FALSE,
'width' => 500,
'title' => 'Title',
'modal' => FALSE,
- ),
- );
+ ],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -328,13 +328,13 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testOpenModalDialogCommand() {
$command = $this->getMockBuilder('Drupal\Core\Ajax\OpenModalDialogCommand')
- ->setConstructorArgs(array(
- 'Title', '<p>Text!</p>', array(
+ ->setConstructorArgs([
+ 'Title', '<p>Text!</p>', [
'url' => 'example',
'width' => 500,
- ),
- ))
- ->setMethods(array('getRenderedContent'))
+ ],
+ ])
+ ->setMethods(['getRenderedContent'])
->getMock();
// This method calls the render service, which isn't available. We want it
@@ -343,18 +343,18 @@ class AjaxCommandsTest extends UnitTestCase {
->method('getRenderedContent')
->willReturn('rendered content');
- $expected = array(
+ $expected = [
'command' => 'openDialog',
'selector' => '#drupal-modal',
'settings' => NULL,
'data' => 'rendered content',
- 'dialogOptions' => array(
+ 'dialogOptions' => [
'url' => 'example',
'width' => 500,
'title' => 'Title',
'modal' => TRUE,
- ),
- );
+ ],
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -363,11 +363,11 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testCloseModalDialogCommand() {
$command = new CloseModalDialogCommand();
- $expected = array(
+ $expected = [
'command' => 'closeDialog',
'selector' => '#drupal-modal',
'persist' => FALSE,
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -377,11 +377,11 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testCloseDialogCommand() {
$command = new CloseDialogCommand('#some-dialog', TRUE);
- $expected = array(
+ $expected = [
'command' => 'closeDialog',
'selector' => '#some-dialog',
'persist' => TRUE,
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -391,12 +391,12 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testSetDialogOptionCommand() {
$command = new SetDialogOptionCommand('#some-dialog', 'width', '500');
- $expected = array(
+ $expected = [
'command' => 'setDialogOption',
'selector' => '#some-dialog',
'optionName' => 'width',
'optionValue' => '500',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -406,12 +406,12 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testSetDialogTitleCommand() {
$command = new SetDialogTitleCommand('#some-dialog', 'Example');
- $expected = array(
+ $expected = [
'command' => 'setDialogOption',
'selector' => '#some-dialog',
'optionName' => 'title',
'optionValue' => 'Example',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
@@ -421,10 +421,10 @@ class AjaxCommandsTest extends UnitTestCase {
*/
public function testRedirectCommand() {
$command = new RedirectCommand('http://example.com');
- $expected = array(
+ $expected = [
'command' => 'redirect',
'url' => 'http://example.com',
- );
+ ];
$this->assertEquals($expected, $command->render());
}
diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
index fcfa4139270..880aaecf295 100644
--- a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
+++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
@@ -36,15 +36,15 @@ class AjaxResponseTest extends UnitTestCase {
$command_one = $this->getMock('Drupal\Core\Ajax\CommandInterface');
$command_one->expects($this->once())
->method('render')
- ->will($this->returnValue(array('command' => 'one')));
+ ->will($this->returnValue(['command' => 'one']));
$command_two = $this->getMock('Drupal\Core\Ajax\CommandInterface');
$command_two->expects($this->once())
->method('render')
- ->will($this->returnValue(array('command' => 'two')));
+ ->will($this->returnValue(['command' => 'two']));
$command_three = $this->getMock('Drupal\Core\Ajax\CommandInterface');
$command_three->expects($this->once())
->method('render')
- ->will($this->returnValue(array('command' => 'three')));
+ ->will($this->returnValue(['command' => 'three']));
$this->ajaxResponse->addCommand($command_one);
$this->ajaxResponse->addCommand($command_two);
@@ -52,9 +52,9 @@ class AjaxResponseTest extends UnitTestCase {
// Ensure that the added commands are in the right order.
$commands =& $this->ajaxResponse->getCommands();
- $this->assertSame($commands[1], array('command' => 'one'));
- $this->assertSame($commands[2], array('command' => 'two'));
- $this->assertSame($commands[0], array('command' => 'three'));
+ $this->assertSame($commands[1], ['command' => 'one']);
+ $this->assertSame($commands[2], ['command' => 'two']);
+ $this->assertSame($commands[0], ['command' => 'three']);
// Remove one and change one element from commands and ensure the reference
// worked as expected.
@@ -62,9 +62,9 @@ class AjaxResponseTest extends UnitTestCase {
$commands[0]['class'] = 'test-class';
$commands = $this->ajaxResponse->getCommands();
- $this->assertSame($commands[1], array('command' => 'one'));
+ $this->assertSame($commands[1], ['command' => 'one']);
$this->assertFalse(isset($commands[2]));
- $this->assertSame($commands[0], array('command' => 'three', 'class' => 'test-class'));
+ $this->assertSame($commands[0], ['command' => 'three', 'class' => 'test-class']);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php b/core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php
index ead56ae4251..7be87f593f3 100644
--- a/core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php
+++ b/core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php
@@ -36,10 +36,10 @@ class TranslationTest extends UnitTestCase {
$container->set('string_translation', $this->translationManager);
\Drupal::setContainer($container);
- $arguments = isset($values['arguments']) ? $values['arguments'] : array();
- $options = isset($values['context']) ? array(
+ $arguments = isset($values['arguments']) ? $values['arguments'] : [];
+ $options = isset($values['context']) ? [
'context' => $values['context'],
- ) : array();
+ ] : [];
$annotation = new Translation($values);
@@ -50,27 +50,27 @@ class TranslationTest extends UnitTestCase {
* Provides data to self::testGet().
*/
public function providerTestGet() {
- $data = array();
- $data[] = array(
- array(
+ $data = [];
+ $data[] = [
+ [
'value' => 'Foo',
- ),
+ ],
'Foo'
- );
+ ];
$random = $this->randomMachineName();
$random_html_entity = '&' . $random;
- $data[] = array(
- array(
+ $data[] = [
+ [
'value' => 'Foo @bar @baz %qux',
- 'arguments' => array(
+ 'arguments' => [
'@bar' => $random,
'@baz' => $random_html_entity,
'%qux' => $random_html_entity,
- ),
+ ],
'context' => $this->randomMachineName(),
- ),
+ ],
'Foo ' . $random . ' &amp;' . $random . ' <em class="placeholder">&amp;' . $random . '</em>',
- );
+ ];
return $data;
}
diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionGrouperUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionGrouperUnitTest.php
index 1e380c8611a..c75dc044280 100644
--- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionGrouperUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionGrouperUnitTest.php
@@ -29,78 +29,78 @@ class CssCollectionGrouperUnitTest extends UnitTestCase {
* Tests \Drupal\Core\Asset\CssCollectionGrouper.
*/
function testGrouper() {
- $css_assets = array(
- 'system.base.css' => array(
+ $css_assets = [
+ 'system.base.css' => [
'group' => -100,
'type' => 'file',
'weight' => 0.012,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'core/modules/system/system.base.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'system.base.css',
- ),
- 'js.module.css' => array(
+ ],
+ 'js.module.css' => [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'core/modules/system/js.module.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'js.module.css',
- ),
- 'jquery.ui.core.css' => array(
+ ],
+ 'jquery.ui.core.css' => [
'group' => -100,
'type' => 'file',
'weight' => 0.004,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'core/misc/ui/themes/base/jquery.ui.core.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'jquery.ui.core.css',
- ),
- 'field.css' => array(
+ ],
+ 'field.css' => [
'group' => 0,
'type' => 'file',
'weight' => 0.011,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'core/modules/field/theme/field.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'field.css',
- ),
- 'external.css' => array(
+ ],
+ 'external.css' => [
'group' => 0,
'type' => 'external',
'weight' => 0.009,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'http://example.com/external.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'external.css',
- ),
- 'elements.css' => array(
+ ],
+ 'elements.css' => [
'group' => 100,
'media' => 'all',
'type' => 'file',
'weight' => 0.001,
'preprocess' => TRUE,
'data' => 'core/themes/bartik/css/base/elements.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'elements.css',
- ),
- 'print.css' => array(
+ ],
+ 'print.css' => [
'group' => 100,
'media' => 'print',
'type' => 'file',
'weight' => 0.003,
'preprocess' => TRUE,
'data' => 'core/themes/bartik/css/print.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'print.css',
- ),
- );
+ ],
+ ];
$groups = $this->grouper->group($css_assets);
diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
index 86026610535..96a43b0b99a 100644
--- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
@@ -39,35 +39,35 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
$this->state = $this->getMock('Drupal\Core\State\StateInterface');
$this->renderer = new CssCollectionRenderer($this->state);
- $this->fileCssGroup = array(
+ $this->fileCssGroup = [
'group' => -100,
'type' => 'file',
'media' => 'all',
'preprocess' => TRUE,
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
- 'items' => array(
- 0 => array(
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
+ 'items' => [
+ 0 => [
'group' => -100,
'type' => 'file',
'weight' => 0.012,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'tests/Drupal/Tests/Core/Asset/foo.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'foo.css',
- ),
- 1 => array(
+ ],
+ 1 => [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'tests/Drupal/Tests/Core/Asset/bar.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'bar.css',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -76,59 +76,59 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
* @see testRender
*/
function providerTestRender() {
- $create_link_element = function($href, $media = 'all', $browsers = array()) {
- return array(
+ $create_link_element = function($href, $media = 'all', $browsers = []) {
+ return [
'#type' => 'html_tag',
'#tag' => 'link',
- '#attributes' => array(
+ '#attributes' => [
'rel' => 'stylesheet',
'href' => $href,
'media' => $media,
- ),
+ ],
'#browsers' => $browsers,
- );
+ ];
};
- $create_style_element = function($value, $media, $browsers = array()) {
- $style_element = array(
+ $create_style_element = function($value, $media, $browsers = []) {
+ $style_element = [
'#type' => 'html_tag',
'#tag' => 'style',
'#value' => $value,
- '#attributes' => array(
+ '#attributes' => [
'media' => $media
- ),
+ ],
'#browsers' => $browsers,
- );
+ ];
return $style_element;
};
$create_file_css_asset = function($data, $media = 'all', $preprocess = TRUE) {
- return array('group' => 0, 'type' => 'file', 'media' => $media, 'preprocess' => $preprocess, 'data' => $data, 'browsers' => array());
+ return ['group' => 0, 'type' => 'file', 'media' => $media, 'preprocess' => $preprocess, 'data' => $data, 'browsers' => []];
};
- return array(
+ return [
// Single external CSS asset.
- 0 => array(
+ 0 => [
// CSS assets.
- array(
- 0 => array('group' => 0, 'type' => 'external', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'http://example.com/popular.js', 'browsers' => array()),
- ),
+ [
+ 0 => ['group' => 0, 'type' => 'external', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'http://example.com/popular.js', 'browsers' => []],
+ ],
// Render elements.
- array(
+ [
0 => $create_link_element('http://example.com/popular.js', 'all'),
- ),
- ),
+ ],
+ ],
// Single file CSS asset.
- 2 => array(
- array(
- 0 => array('group' => 0, 'type' => 'file', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'public://css/file-all', 'browsers' => array()),
- ),
- array(
+ 2 => [
+ [
+ 0 => ['group' => 0, 'type' => 'file', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'public://css/file-all', 'browsers' => []],
+ ],
+ [
0 => $create_link_element(file_url_transform_relative(file_create_url('public://css/file-all')) . '?0', 'all'),
- ),
- ),
+ ],
+ ],
// 31 file CSS assets: expect 31 link elements.
- 3 => array(
- array(
+ 3 => [
+ [
0 => $create_file_css_asset('public://css/1.css'),
1 => $create_file_css_asset('public://css/2.css'),
2 => $create_file_css_asset('public://css/3.css'),
@@ -160,8 +160,8 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
28 => $create_file_css_asset('public://css/29.css'),
29 => $create_file_css_asset('public://css/30.css'),
30 => $create_file_css_asset('public://css/31.css'),
- ),
- array(
+ ],
+ [
0 => $create_link_element(file_url_transform_relative(file_create_url('public://css/1.css')) . '?0'),
1 => $create_link_element(file_url_transform_relative(file_create_url('public://css/2.css')) . '?0'),
2 => $create_link_element(file_url_transform_relative(file_create_url('public://css/3.css')) . '?0'),
@@ -193,11 +193,11 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
28 => $create_link_element(file_url_transform_relative(file_create_url('public://css/29.css')) . '?0'),
29 => $create_link_element(file_url_transform_relative(file_create_url('public://css/30.css')) . '?0'),
30 => $create_link_element(file_url_transform_relative(file_create_url('public://css/31.css')) . '?0'),
- ),
- ),
+ ],
+ ],
// 32 file CSS assets with the same properties: expect 2 style elements.
- 4 => array(
- array(
+ 4 => [
+ [
0 => $create_file_css_asset('public://css/1.css'),
1 => $create_file_css_asset('public://css/2.css'),
2 => $create_file_css_asset('public://css/3.css'),
@@ -230,8 +230,8 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
29 => $create_file_css_asset('public://css/30.css'),
30 => $create_file_css_asset('public://css/31.css'),
31 => $create_file_css_asset('public://css/32.css'),
- ),
- array(
+ ],
+ [
0 => $create_style_element('
@import url("' . file_url_transform_relative(file_create_url('public://css/1.css')) . '?0");
@import url("' . file_url_transform_relative(file_create_url('public://css/2.css')) . '?0");
@@ -268,13 +268,13 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
1 => $create_style_element('
@import url("' . file_url_transform_relative(file_create_url('public://css/32.css')) . '?0");
', 'all'),
- ),
- ),
+ ],
+ ],
// 32 file CSS assets with the same properties, except for the 10th and
// 20th files, they have different 'media' properties. Expect 5 style
// elements.
- 5 => array(
- array(
+ 5 => [
+ [
0 => $create_file_css_asset('public://css/1.css'),
1 => $create_file_css_asset('public://css/2.css'),
2 => $create_file_css_asset('public://css/3.css'),
@@ -307,8 +307,8 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
29 => $create_file_css_asset('public://css/30.css'),
30 => $create_file_css_asset('public://css/31.css'),
31 => $create_file_css_asset('public://css/32.css'),
- ),
- array(
+ ],
+ [
0 => $create_style_element('
@import url("' . file_url_transform_relative(file_create_url('public://css/1.css')) . '?0");
@import url("' . file_url_transform_relative(file_create_url('public://css/2.css')) . '?0");
@@ -351,12 +351,12 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
@import url("' . file_url_transform_relative(file_create_url('public://css/31.css')) . '?0");
@import url("' . file_url_transform_relative(file_create_url('public://css/32.css')) . '?0");
', 'all'),
- ),
- ),
+ ],
+ ],
// 32 file CSS assets with the same properties, except for the 15th, which
// has 'preprocess' = FALSE. Expect 1 link element and 2 style elements.
- 6 => array(
- array(
+ 6 => [
+ [
0 => $create_file_css_asset('public://css/1.css'),
1 => $create_file_css_asset('public://css/2.css'),
2 => $create_file_css_asset('public://css/3.css'),
@@ -389,8 +389,8 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
29 => $create_file_css_asset('public://css/30.css'),
30 => $create_file_css_asset('public://css/31.css'),
31 => $create_file_css_asset('public://css/32.css'),
- ),
- array(
+ ],
+ [
0 => $create_style_element('
@import url("' . file_url_transform_relative(file_create_url('public://css/1.css')) . '?0");
@import url("' . file_url_transform_relative(file_create_url('public://css/2.css')) . '?0");
@@ -427,9 +427,9 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
@import url("' . file_url_transform_relative(file_create_url('public://css/31.css')) . '?0");
@import url("' . file_url_transform_relative(file_create_url('public://css/32.css')) . '?0");
', 'all'),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -455,14 +455,14 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
->will($this->returnValue(NULL));
$this->setExpectedException('Exception', 'Invalid CSS asset type.');
- $css_group = array(
+ $css_group = [
'group' => 0,
'type' => 'internal',
'media' => 'all',
'preprocess' => TRUE,
- 'browsers' => array(),
+ 'browsers' => [],
'data' => 'http://example.com/popular.js'
- );
+ ];
$this->renderer->render($css_group);
}
diff --git a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php
index 48d2f4676c0..cf7d3ff9849 100644
--- a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php
@@ -36,24 +36,24 @@ class CssOptimizerUnitTest extends UnitTestCase {
function providerTestOptimize() {
$path = 'core/tests/Drupal/Tests/Core/Asset/css_test_files/';
$absolute_path = dirname(__FILE__) . '/css_test_files/';
- return array(
+ return [
// File. Tests:
// - Stripped comments and white-space.
// - Retain white-space in selectors. (https://www.drupal.org/node/472820)
// - Retain pseudo-selectors. (https://www.drupal.org/node/460448)
- array(
- array(
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.012,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_input_without_import.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'css_input_without_import.css',
- ),
+ ],
file_get_contents($absolute_path . 'css_input_without_import.css.optimized.css'),
- ),
+ ],
// File. Tests:
// - Proper URLs in imported files. (https://www.drupal.org/node/265719)
// - A background image with relative paths, which must be rewritten.
@@ -61,146 +61,146 @@ class CssOptimizerUnitTest extends UnitTestCase {
// file_create_url(). (https://www.drupal.org/node/1961340)
// - Imported files that are external (protocol-relative URL or not)
// should not be expanded. (https://www.drupal.org/node/2014851)
- array(
- array(
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_input_with_import.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'css_input_with_import.css',
- ),
+ ],
str_replace('url(images/icon.png)', 'url(' . file_url_transform_relative(file_create_url($path . 'images/icon.png')) . ')', file_get_contents($absolute_path . 'css_input_with_import.css.optimized.css')),
- ),
+ ],
// File. Tests:
// - Retain comment hacks.
- array(
- array(
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'comment_hacks.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'comment_hacks.css',
- ),
+ ],
file_get_contents($absolute_path . 'comment_hacks.css.optimized.css'),
- ),
+ ],
// File in subfolder. Tests:
// - CSS import path is properly interpreted.
// (https://www.drupal.org/node/1198904)
// - Don't adjust data URIs (https://www.drupal.org/node/2142441)
- array(
- array(
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_subfolder/css_input_with_import.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'css_input_with_import.css',
- ),
+ ],
str_replace('url(../images/icon.png)', 'url(' . file_url_transform_relative(file_create_url($path . 'images/icon.png')) . ')', file_get_contents($absolute_path . 'css_subfolder/css_input_with_import.css.optimized.css')),
- ),
+ ],
// File. Tests:
// - Any @charaset declaration at the beginning of a file should be
// removed without breaking subsequent CSS.
- array(
- array(
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'charset_sameline.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'charset_sameline.css',
- ),
+ ],
file_get_contents($absolute_path . 'charset.css.optimized.css'),
- ),
- array(
- array(
+ ],
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'charset_newline.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'charset_newline.css',
- ),
+ ],
file_get_contents($absolute_path . 'charset.css.optimized.css'),
- ),
- array(
- array(
+ ],
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_input_with_bom.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'css_input_with_bom.css',
- ),
+ ],
'.byte-order-mark-test{content:"☃";}' . "\n",
- ),
- array(
- array(
+ ],
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_input_with_charset.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'css_input_with_charset.css',
- ),
+ ],
'.charset-test{content:"€";}' . "\n",
- ),
- array(
- array(
+ ],
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_input_with_bom_and_charset.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'css_input_with_bom_and_charset.css',
- ),
+ ],
'.byte-order-mark-charset-test{content:"☃";}' . "\n",
- ),
- array(
- array(
+ ],
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_input_with_utf16_bom.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'css_input_with_utf16_bom.css',
- ),
+ ],
'.utf16-byte-order-mark-test{content:"☃";}' . "\n",
- ),
- array(
- array(
+ ],
+ [
+ [
'group' => -100,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'quotes.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'quotes.css',
- ),
+ ],
file_get_contents($absolute_path . 'quotes.css.optimized.css'),
- ),
- );
+ ],
+ ];
}
/**
@@ -229,7 +229,7 @@ class CssOptimizerUnitTest extends UnitTestCase {
function testTypeFilePreprocessingDisabled() {
$this->setExpectedException('Exception', 'Only file CSS assets with preprocessing enabled can be optimized.');
- $css_asset = array(
+ $css_asset = [
'group' => -100,
'type' => 'file',
'weight' => 0.012,
@@ -237,9 +237,9 @@ class CssOptimizerUnitTest extends UnitTestCase {
// Preprocessing disabled.
'preprocess' => FALSE,
'data' => 'tests/Drupal/Tests/Core/Asset/foo.css',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
'basename' => 'foo.css',
- );
+ ];
$this->optimizer->optimize($css_asset);
}
@@ -249,7 +249,7 @@ class CssOptimizerUnitTest extends UnitTestCase {
function testTypeExternal() {
$this->setExpectedException('Exception', 'Only file CSS assets can be optimized.');
- $css_asset = array(
+ $css_asset = [
'group' => -100,
// Type external.
'type' => 'external',
@@ -257,8 +257,8 @@ class CssOptimizerUnitTest extends UnitTestCase {
'media' => 'all',
'preprocess' => TRUE,
'data' => 'http://example.com/foo.js',
- 'browsers' => array('IE' => TRUE, '!IE' => TRUE),
- );
+ 'browsers' => ['IE' => TRUE, '!IE' => TRUE],
+ ];
$this->optimizer->optimize($css_asset);
}
diff --git a/core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php
index df71c220d2c..e2d55efe21f 100644
--- a/core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php
@@ -38,32 +38,32 @@ class JsOptimizerUnitTest extends UnitTestCase {
*/
function providerTestClean() {
$path = dirname(__FILE__) . '/js_test_files/';
- return array(
+ return [
// File. Tests:
// - Stripped sourceMappingURL with comment # syntax.
- 0 => array(
+ 0 => [
file_get_contents($path . 'source_mapping_url.min.js'),
file_get_contents($path . 'source_mapping_url.min.js.optimized.js'),
- ),
+ ],
// File. Tests:
// - Stripped sourceMappingURL with comment @ syntax.
- 1 => array(
+ 1 => [
file_get_contents($path . 'source_mapping_url_old.min.js'),
file_get_contents($path . 'source_mapping_url_old.min.js.optimized.js'),
- ),
+ ],
// File. Tests:
// - Stripped sourceURL with comment # syntax.
- 2 => array(
+ 2 => [
file_get_contents($path . 'source_url.min.js'),
file_get_contents($path . 'source_url.min.js.optimized.js'),
- ),
+ ],
// File. Tests:
// - Stripped sourceURL with comment @ syntax.
- 3 => array(
+ 3 => [
file_get_contents($path . 'source_url_old.min.js'),
file_get_contents($path . 'source_url_old.min.js.optimized.js'),
- ),
- );
+ ],
+ ];
}
/**
@@ -85,33 +85,33 @@ class JsOptimizerUnitTest extends UnitTestCase {
*/
function providerTestOptimize() {
$path = dirname(__FILE__) . '/js_test_files/';
- return array(
- 0 => array(
- array(
+ return [
+ 0 => [
+ [
'type' => 'file',
'preprocess' => TRUE,
'data' => $path . 'utf8_bom.js',
- ),
+ ],
file_get_contents($path . 'utf8_bom.js.optimized.js'),
- ),
- 1 => array(
- array(
+ ],
+ 1 => [
+ [
'type' => 'file',
'preprocess' => TRUE,
'data' => $path . 'utf16_bom.js',
- ),
+ ],
file_get_contents($path . 'utf16_bom.js.optimized.js'),
- ),
- 2 => array(
- array(
+ ],
+ 2 => [
+ [
'type' => 'file',
'preprocess' => TRUE,
'data' => $path . 'latin_9.js',
- 'attributes' => array('charset' => 'ISO-8859-15'),
- ),
+ 'attributes' => ['charset' => 'ISO-8859-15'],
+ ],
file_get_contents($path . 'latin_9.js.optimized.js'),
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
index a7a026a826c..40e18210800 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
@@ -37,7 +37,7 @@ class LibraryDependencyResolverTest extends UnitTestCase {
*
* @var array
*/
- protected $libraryData = array(
+ protected $libraryData = [
'no_deps_a' => ['js' => [], 'css' => []],
'no_deps_b' => ['js' => [], 'css' => []],
'no_deps_c' => ['js' => [], 'css' => []],
@@ -47,7 +47,7 @@ class LibraryDependencyResolverTest extends UnitTestCase {
'nested_deps_a' => ['js' => [], 'css' => [], 'dependencies' => ['test/deps_a']],
'nested_deps_b' => ['js' => [], 'css' => [], 'dependencies' => ['test/nested_deps_a']],
'nested_deps_c' => ['js' => [], 'css' => [], 'dependencies' => ['test/nested_deps_b']],
- );
+ ];
/**
* {@inheritdoc}
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php
index 0d82bfbe669..2eb34d33f94 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php
@@ -52,16 +52,16 @@ class LibraryDiscoveryCollectorTest extends UnitTestCase {
*
* @var array
*/
- protected $libraryData = array(
- 'test_1' => array(
- 'js' => array(),
- 'css' => array(),
- ),
- 'test_2' => array(
- 'js' => array(),
- 'css' => array(),
- ),
- );
+ protected $libraryData = [
+ 'test_1' => [
+ 'js' => [],
+ 'css' => [],
+ ],
+ 'test_2' => [
+ 'js' => [],
+ 'css' => [],
+ ],
+ ];
protected $activeTheme;
@@ -140,7 +140,7 @@ class LibraryDiscoveryCollectorTest extends UnitTestCase {
->willReturn(FALSE);
$this->cache->expects($this->once())
->method('set')
- ->with('library_info:kitten_theme', array('test' => $this->libraryData), Cache::PERMANENT, ['library_info']);
+ ->with('library_info:kitten_theme', ['test' => $this->libraryData], Cache::PERMANENT, ['library_info']);
$this->lock->expects($this->once())
->method('release')
->with($lock_key);
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
index 121aebc953b..ca71c81c0d5 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
@@ -137,7 +137,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$path = substr($path, strlen($this->root) + 1);
$this->libraryDiscoveryParser->setPaths('module', 'example_module', $path);
- $this->assertSame($this->libraryDiscoveryParser->buildByExtension('example_module'), array());
+ $this->assertSame($this->libraryDiscoveryParser->buildByExtension('example_module'), []);
}
/**
@@ -320,7 +320,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->assertEquals('file', $library['css'][0]['type']);
$this->assertEquals($path . '/css/base.css', $library['css'][0]['data']);
- $this->assertEquals(array('key' => 'value'), $library['drupalSettings']);
+ $this->assertEquals(['key' => 'value'], $library['drupalSettings']);
}
/**
@@ -443,65 +443,65 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->assertCount(1, $library['css']);
$this->assertCount(1, $library['js']);
$this->assertTrue(isset($library['license']));
- $default_license = array(
+ $default_license = [
'name' => 'GNU-GPL-2.0-or-later',
'url' => 'https://www.drupal.org/licensing/faq',
'gpl-compatible' => TRUE,
- );
+ ];
$this->assertEquals($library['license'], $default_license);
// GPL2-licensed libraries.
$library = $libraries['gpl2'];
$this->assertCount(1, $library['css']);
$this->assertCount(1, $library['js']);
- $expected_license = array(
+ $expected_license = [
'name' => 'gpl2',
'url' => 'https://url-to-gpl2-license',
'gpl-compatible' => TRUE,
- );
+ ];
$this->assertEquals($library['license'], $expected_license);
// MIT-licensed libraries.
$library = $libraries['mit'];
$this->assertCount(1, $library['css']);
$this->assertCount(1, $library['js']);
- $expected_license = array(
+ $expected_license = [
'name' => 'MIT',
'url' => 'https://url-to-mit-license',
'gpl-compatible' => TRUE,
- );
+ ];
$this->assertEquals($library['license'], $expected_license);
// Libraries in the Public Domain.
$library = $libraries['public-domain'];
$this->assertCount(1, $library['css']);
$this->assertCount(1, $library['js']);
- $expected_license = array(
+ $expected_license = [
'name' => 'Public Domain',
'url' => 'https://url-to-public-domain-license',
'gpl-compatible' => TRUE,
- );
+ ];
$this->assertEquals($library['license'], $expected_license);
// Apache-licensed libraries.
$library = $libraries['apache'];
$this->assertCount(1, $library['css']);
$this->assertCount(1, $library['js']);
- $expected_license = array(
+ $expected_license = [
'name' => 'apache',
'url' => 'https://url-to-apache-license',
'gpl-compatible' => FALSE,
- );
+ ];
$this->assertEquals($library['license'], $expected_license);
// Copyrighted libraries.
$library = $libraries['copyright'];
$this->assertCount(1, $library['css']);
$this->assertCount(1, $library['js']);
- $expected_license = array(
+ $expected_license = [
'name' => '© Some company',
'gpl-compatible' => FALSE,
- );
+ ];
$this->assertEquals($library['license'], $expected_license);
}
diff --git a/core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php b/core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php
index d2e0c131729..0c905e6d980 100644
--- a/core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php
+++ b/core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php
@@ -13,7 +13,7 @@ use Drupal\Tests\UnitTestCase;
* in all cases.
*/
class PercentagesTest extends UnitTestCase {
- protected $testCases = array();
+ protected $testCases = [];
/**
* @dataProvider providerTestPercentages
@@ -31,39 +31,39 @@ class PercentagesTest extends UnitTestCase {
*/
public function providerTestPercentages() {
// Set up an array of test cases.
- return array(
+ return [
// array(total, current, expected).
// 1/2 is 50%.
- array(2, 1, '50'),
+ [2, 1, '50'],
// Though we should never encounter a case where the current set is set
// 0, if we did, we should get 0%.
- array(3, 0, '0'),
+ [3, 0, '0'],
// 1/3 is closer to 33% than to 34%.
- array(3, 1, '33'),
+ [3, 1, '33'],
// 2/3 is closer to 67% than to 66%.
- array(3, 2, '67'),
+ [3, 2, '67'],
// 1/199 should round up to 1%.
- array(199, 1, '1'),
+ [199, 1, '1'],
// 198/199 should round down to 99%.
- array(199, 198, '99'),
+ [199, 198, '99'],
// 199/200 would have rounded up to 100%, which would give the false
// impression of being finished, so we add another digit and should get
// 99.5%.
- array(200, 199, '99.5'),
+ [200, 199, '99.5'],
// The same logic holds for 1/200: we should get 0.5%.
- array(200, 1, '0.5'),
+ [200, 1, '0.5'],
// Numbers that come out evenly, such as 50/200, should be forced to have
// extra digits for consistency.
- array(200, 50, '25.0'),
+ [200, 50, '25.0'],
// Regardless of number of digits we're using, 100% should always just be
// 100%.
- array(200, 200, '100'),
+ [200, 200, '100'],
// 1998/1999 should similarly round down to 99.9%.
- array(1999, 1998, '99.9'),
+ [1999, 1998, '99.9'],
// 1999/2000 should add another digit and go to 99.95%.
- array(2000, 1999, '99.95'),
+ [2000, 1999, '99.95'],
// 19999/20000 should add yet another digit and go to 99.995%.
- array(20000, 19999, '99.995'),
+ [20000, 19999, '99.995'],
// The next five test cases simulate a batch with a single operation
// ('total' equals 1) that takes several steps to complete. Within the
// operation, we imagine that there are 501 items to process, and 100 are
@@ -72,12 +72,12 @@ class PercentagesTest extends UnitTestCase {
// but for the last pass through, when 500 out of 501 items have been
// processed, we do not want to round up to 100%, since that would
// erroneously indicate that the processing is complete.
- array('total' => 1, 'current' => 100 / 501, '20'),
- array('total' => 1, 'current' => 200 / 501, '40'),
- array('total' => 1, 'current' => 300 / 501, '60'),
- array('total' => 1, 'current' => 400 / 501, '80'),
- array('total' => 1, 'current' => 500 / 501, '99.8'),
- );
+ ['total' => 1, 'current' => 100 / 501, '20'],
+ ['total' => 1, 'current' => 200 / 501, '40'],
+ ['total' => 1, 'current' => 300 / 501, '60'],
+ ['total' => 1, 'current' => 400 / 501, '80'],
+ ['total' => 1, 'current' => 500 / 501, '99.8'],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php b/core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php
index 541c0c186a3..70bc7f22dde 100644
--- a/core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php
+++ b/core/tests/Drupal/Tests/Core/Block/BlockBaseTest.php
@@ -19,24 +19,24 @@ class BlockBaseTest extends UnitTestCase {
public function testGetMachineNameSuggestion() {
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$transliteration = $this->getMockBuilder('Drupal\Core\Transliteration\PhpTransliteration')
- ->setConstructorArgs(array(NULL, $module_handler))
- ->setMethods(array('readLanguageOverrides'))
+ ->setConstructorArgs([NULL, $module_handler])
+ ->setMethods(['readLanguageOverrides'])
->getMock();
- $config = array();
- $definition = array(
+ $config = [];
+ $definition = [
'admin_label' => 'Admin label',
'provider' => 'block_test',
- );
+ ];
$block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
$block_base->setTransliteration($transliteration);
$this->assertEquals('adminlabel', $block_base->getMachineNameSuggestion());
// Test with more unicodes.
- $definition = array(
+ $definition = [
'admin_label' => 'über åwesome',
'provider' => 'block_test',
- );
+ ];
$block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
$block_base->setTransliteration($transliteration);
$this->assertEquals('uberawesome', $block_base->getMachineNameSuggestion());
diff --git a/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php b/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php
index 32ea0d01750..be1469cd8eb 100644
--- a/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php
@@ -80,7 +80,7 @@ class BreadcrumbManagerTest extends UnitTestCase {
*/
public function testBuildWithSingleBuilder() {
$builder = $this->getMock('Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface');
- $links = array('<a href="/example">Test</a>');
+ $links = ['<a href="/example">Test</a>'];
$this->breadcrumb->setLinks($links);
$this->breadcrumb->addCacheContexts(['foo'])->addCacheTags(['bar']);
@@ -95,7 +95,7 @@ class BreadcrumbManagerTest extends UnitTestCase {
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$this->moduleHandler->expects($this->once())
->method('alter')
- ->with('system_breadcrumb', $this->breadcrumb, $route_match, array('builder' => $builder));
+ ->with('system_breadcrumb', $this->breadcrumb, $route_match, ['builder' => $builder]);
$this->breadcrumbManager->addBuilder($builder, 0);
@@ -117,7 +117,7 @@ class BreadcrumbManagerTest extends UnitTestCase {
->method('build');
$builder2 = $this->getMock('Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface');
- $links2 = array('<a href="/example2">Test2</a>');
+ $links2 = ['<a href="/example2">Test2</a>'];
$this->breadcrumb->setLinks($links2);
$this->breadcrumb->addCacheContexts(['baz'])->addCacheTags(['qux']);
$builder2->expects($this->once())
@@ -131,7 +131,7 @@ class BreadcrumbManagerTest extends UnitTestCase {
$this->moduleHandler->expects($this->once())
->method('alter')
- ->with('system_breadcrumb', $this->breadcrumb, $route_match, array('builder' => $builder2));
+ ->with('system_breadcrumb', $this->breadcrumb, $route_match, ['builder' => $builder2]);
$this->breadcrumbManager->addBuilder($builder1, 0);
$this->breadcrumbManager->addBuilder($builder2, 10);
@@ -169,7 +169,7 @@ class BreadcrumbManagerTest extends UnitTestCase {
$this->moduleHandler->expects($this->once())
->method('alter')
- ->with('system_breadcrumb', $this->breadcrumb, $route_match, array('builder' => $builder2));
+ ->with('system_breadcrumb', $this->breadcrumb, $route_match, ['builder' => $builder2]);
$this->breadcrumbManager->addBuilder($builder1, 10);
$this->breadcrumbManager->addBuilder($builder2, 0);
diff --git a/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php b/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php
index f035bde3b87..ad51768daf7 100644
--- a/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php
@@ -100,7 +100,7 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
* Test the get multiple feature.
*/
public function testGetMultiple() {
- $cids = array('t123', 't23', 't3', 't4');
+ $cids = ['t123', 't23', 't3', 't4'];
$ret = $this->chain->getMultiple($cids);
$this->assertSame($ret['t123']->data, 1231, 'Got key 123 and value is from the first backend');
@@ -175,7 +175,7 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
* Ensure get multiple values propagation to previous backends.
*/
public function testGetMultipleHasPropagated() {
- $cids = array('t3', 't23');
+ $cids = ['t3', 't23'];
$this->chain->getMultiple($cids);
$cached = $this->firstBackend->get('t3');
@@ -213,8 +213,8 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
*/
public function testDeleteTagsPropagation() {
// Create two cache entries with the same tag and tag value.
- $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:2'));
- $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:2'));
+ $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, ['test_tag:2']);
+ $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, ['test_tag:2']);
$this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1')
&& $this->firstBackend->get('test_cid_clear2')
&& $this->secondBackend->get('test_cid_clear1')
@@ -224,7 +224,7 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
'Two cache items were created in all backends.');
// Invalidate test_tag of value 1. This should invalidate both entries.
- $this->chain->invalidateTags(array('test_tag:2'));
+ $this->chain->invalidateTags(['test_tag:2']);
$this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1')
&& $this->firstBackend->get('test_cid_clear2')
&& $this->secondBackend->get('test_cid_clear1')
@@ -234,8 +234,8 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
'Two caches removed from all backends after clearing a cache tag.');
// Create two cache entries with the same tag and an array tag value.
- $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:1'));
- $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:1'));
+ $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, ['test_tag:1']);
+ $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, ['test_tag:1']);
$this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1')
&& $this->firstBackend->get('test_cid_clear2')
&& $this->secondBackend->get('test_cid_clear1')
@@ -245,7 +245,7 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
'Two cache items were created in all backends.');
// Invalidate test_tag of value 1. This should invalidate both entries.
- $this->chain->invalidateTags(array('test_tag:1'));
+ $this->chain->invalidateTags(['test_tag:1']);
$this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1')
&& $this->firstBackend->get('test_cid_clear2')
&& $this->secondBackend->get('test_cid_clear1')
@@ -255,9 +255,9 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
'Two caches removed from all backends after clearing a cache tag.');
// Create three cache entries with a mix of tags and tag values.
- $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:1'));
- $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:2'));
- $this->chain->set('test_cid_clear3', 'foo', Cache::PERMANENT, array('test_tag_foo:3'));
+ $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, ['test_tag:1']);
+ $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, ['test_tag:2']);
+ $this->chain->set('test_cid_clear3', 'foo', Cache::PERMANENT, ['test_tag_foo:3']);
$this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1')
&& $this->firstBackend->get('test_cid_clear2')
&& $this->firstBackend->get('test_cid_clear3')
@@ -269,7 +269,7 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
&& $this->thirdBackend->get('test_cid_clear3'),
'Three cached items were created in all backends.');
- $this->chain->invalidateTags(array('test_tag_foo:3'));
+ $this->chain->invalidateTags(['test_tag_foo:3']);
$this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1')
&& $this->firstBackend->get('test_cid_clear2')
&& $this->secondBackend->get('test_cid_clear1')
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php
index 238911b42ee..a44e8d4acd9 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorHelper.php
@@ -13,7 +13,7 @@ class CacheCollectorHelper extends CacheCollector {
* Contains data to return on a cache miss.
* @var array
*/
- protected $cacheMissData = array();
+ protected $cacheMissData = [];
/**
* Number of calls to \Drupal\Core\Cache\CacheCollector::resolveCacheMiss().
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
index e0eeac72dfe..1ff662939ee 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
@@ -114,10 +114,10 @@ class CacheCollectorTest extends UnitTestCase {
$key = $this->randomMachineName();
$value = $this->randomMachineName();
- $cache = (object) array(
- 'data' => array($key => $value),
+ $cache = (object) [
+ 'data' => [$key => $value],
'created' => (int) $_SERVER['REQUEST_TIME'],
- );
+ ];
$this->cacheBackend->expects($this->once())
->method('get')
->with($this->cid)
@@ -183,7 +183,7 @@ class CacheCollectorTest extends UnitTestCase {
->with($this->cid, FALSE);
$this->cacheBackend->expects($this->once())
->method('set')
- ->with($this->cid, array($key => $value), Cache::PERMANENT, array());
+ ->with($this->cid, [$key => $value], Cache::PERMANENT, []);
$this->lock->expects($this->once())
->method('release')
->with($this->cid . ':Drupal\Core\Cache\CacheCollector');
@@ -222,10 +222,10 @@ class CacheCollectorTest extends UnitTestCase {
$key = $this->randomMachineName();
$value = $this->randomMachineName();
- $cache = (object) array(
- 'data' => array($key => $value),
+ $cache = (object) [
+ 'data' => [$key => $value],
'created' => (int) $_SERVER['REQUEST_TIME'],
- );
+ ];
$this->cacheBackend->expects($this->at(0))
->method('get')
->with($this->cid)
@@ -243,10 +243,10 @@ class CacheCollectorTest extends UnitTestCase {
->method('acquire')
->with($this->cid . ':Drupal\Core\Cache\CacheCollector')
->will($this->returnValue(TRUE));
- $cache = (object) array(
- 'data' => array($key => $value),
+ $cache = (object) [
+ 'data' => [$key => $value],
'created' => (int) $_SERVER['REQUEST_TIME'] + 1,
- );
+ ];
$this->cacheBackend->expects($this->at(0))
->method('get')
->with($this->cid)
@@ -279,17 +279,17 @@ class CacheCollectorTest extends UnitTestCase {
->method('acquire')
->with($this->cid . ':Drupal\Core\Cache\CacheCollector')
->will($this->returnValue(TRUE));
- $cache = (object) array(
- 'data' => array('other key' => 'other value'),
+ $cache = (object) [
+ 'data' => ['other key' => 'other value'],
'created' => (int) $_SERVER['REQUEST_TIME'] + 1,
- );
+ ];
$this->cacheBackend->expects($this->at(0))
->method('get')
->with($this->cid)
->will($this->returnValue($cache));
$this->cacheBackend->expects($this->once())
->method('set')
- ->with($this->cid, array('other key' => 'other value', $key => $value), Cache::PERMANENT, array());
+ ->with($this->cid, ['other key' => 'other value', $key => $value], Cache::PERMANENT, []);
$this->lock->expects($this->once())
->method('release')
->with($this->cid . ':Drupal\Core\Cache\CacheCollector');
@@ -305,10 +305,10 @@ class CacheCollectorTest extends UnitTestCase {
$key = $this->randomMachineName();
$value = $this->randomMachineName();
- $cache = (object) array(
- 'data' => array($key => $value),
+ $cache = (object) [
+ 'data' => [$key => $value],
'created' => (int) $_SERVER['REQUEST_TIME'],
- );
+ ];
$this->cacheBackend->expects($this->at(0))
->method('get')
->with($this->cid)
@@ -330,7 +330,7 @@ class CacheCollectorTest extends UnitTestCase {
->with($this->cid, TRUE);
$this->cacheBackend->expects($this->once())
->method('set')
- ->with($this->cid, array(), Cache::PERMANENT, array());
+ ->with($this->cid, [], Cache::PERMANENT, []);
$this->lock->expects($this->once())
->method('release')
->with($this->cid . ':Drupal\Core\Cache\CacheCollector');
@@ -392,7 +392,7 @@ class CacheCollectorTest extends UnitTestCase {
public function testUpdateCacheClearTags() {
$key = $this->randomMachineName();
$value = $this->randomMachineName();
- $tags = array($this->randomMachineName());
+ $tags = [$this->randomMachineName()];
$this->collector = new CacheCollectorHelper($this->cid, $this->cacheBackend, $this->lock, $tags);
// Set the data and request it.
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php
index be0fbdfbb5c..0c43bb22027 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php
@@ -20,7 +20,7 @@ class CacheFactoryTest extends UnitTestCase {
* @covers ::get
*/
public function testCacheFactoryWithDefaultSettings() {
- $settings = new Settings(array());
+ $settings = new Settings([]);
$cache_factory = new CacheFactory($settings);
$container = new ContainerBuilder();
@@ -46,11 +46,11 @@ class CacheFactoryTest extends UnitTestCase {
* @covers ::get
*/
public function testCacheFactoryWithCustomizedDefaultBackend() {
- $settings = new Settings(array(
- 'cache' => array(
+ $settings = new Settings([
+ 'cache' => [
'default' => 'cache.backend.custom',
- ),
- ));
+ ],
+ ]);
$cache_factory = new CacheFactory($settings);
$container = new ContainerBuilder();
@@ -77,11 +77,11 @@ class CacheFactoryTest extends UnitTestCase {
*/
public function testCacheFactoryWithDefaultBinBackend() {
// Ensure the default bin backends are used before the configured default.
- $settings = new Settings(array(
- 'cache' => array(
+ $settings = new Settings([
+ 'cache' => [
'default' => 'cache.backend.unused',
- ),
- ));
+ ],
+ ]);
$default_bin_backends = [
'render' => 'cache.backend.custom',
@@ -114,14 +114,14 @@ class CacheFactoryTest extends UnitTestCase {
public function testCacheFactoryWithSpecifiedPerBinBackend() {
// Ensure the per-bin configuration is used before the configured default
// and per-bin defaults.
- $settings = new Settings(array(
- 'cache' => array(
+ $settings = new Settings([
+ 'cache' => [
'default' => 'cache.backend.unused',
- 'bins' => array(
+ 'bins' => [
'render' => 'cache.backend.custom',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$default_bin_backends = [
'render' => 'cache.backend.unused',
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
index edb220a9923..3c41bdbe6b0 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
@@ -35,7 +35,7 @@ class CacheTagsInvalidatorTest extends UnitTestCase {
$invalidator_cache_bin = $this->getMock('\Drupal\Core\Cache\CacheTagsInvalidator');
$invalidator_cache_bin->expects($this->once())
->method('invalidateTags')
- ->with(array('node:1'));
+ ->with(['node:1']);
// We do not have to define that invalidateTags() is never called as the
// interface does not define that method, trying to call it would result in
@@ -45,17 +45,17 @@ class CacheTagsInvalidatorTest extends UnitTestCase {
$container = new Container();
$container->set('cache.invalidator_cache_bin', $invalidator_cache_bin);
$container->set('cache.non_invalidator_cache_bin', $non_invalidator_cache_bin);
- $container->setParameter('cache_bins', array('cache.invalidator_cache_bin' => 'invalidator_cache_bin', 'cache.non_invalidator_cache_bin' => 'non_invalidator_cache_bin'));
+ $container->setParameter('cache_bins', ['cache.invalidator_cache_bin' => 'invalidator_cache_bin', 'cache.non_invalidator_cache_bin' => 'non_invalidator_cache_bin']);
$cache_tags_invalidator->setContainer($container);
$invalidator = $this->getMock('\Drupal\Core\Cache\CacheTagsInvalidator');
$invalidator->expects($this->once())
->method('invalidateTags')
- ->with(array('node:1'));
+ ->with(['node:1']);
$cache_tags_invalidator->addInvalidator($invalidator);
- $cache_tags_invalidator->invalidateTags(array('node:1'));
+ $cache_tags_invalidator->invalidateTags(['node:1']);
}
}
diff --git a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php
index 93dbd9ffb67..52f18517466 100644
--- a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php
@@ -40,7 +40,7 @@ class ChainedFastBackendTest extends UnitTestCase {
$consistent_cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$timestamp_cid = ChainedFastBackend::LAST_WRITE_TIMESTAMP_PREFIX . 'cache_foo';
// Use the request time because that is what we will be comparing against.
- $timestamp_item = (object) array('cid' => $timestamp_cid, 'data' => (int) $_SERVER['REQUEST_TIME'] - 60);
+ $timestamp_item = (object) ['cid' => $timestamp_cid, 'data' => (int) $_SERVER['REQUEST_TIME'] - 60];
$consistent_cache->expects($this->once())
->method('get')->with($timestamp_cid)
->will($this->returnValue($timestamp_item));
@@ -62,17 +62,17 @@ class ChainedFastBackendTest extends UnitTestCase {
* Tests a fast cache miss gets data from the consistent cache backend.
*/
public function testFallThroughToConsistentCache() {
- $timestamp_item = (object) array(
+ $timestamp_item = (object) [
'cid' => ChainedFastBackend::LAST_WRITE_TIMESTAMP_PREFIX . 'cache_foo',
'data' => time() + 60, // Time travel is easy.
- );
- $cache_item = (object) array(
+ ];
+ $cache_item = (object) [
'cid' => 'foo',
'data' => 'baz',
'created' => time(),
'expire' => time() + 3600,
'tags' => ['tag'],
- );
+ ];
$consistent_cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$fast_cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
@@ -86,14 +86,14 @@ class ChainedFastBackendTest extends UnitTestCase {
// We should get a call for the cache item on the consistent backend.
$consistent_cache->expects($this->once())
->method('getMultiple')
- ->with(array($cache_item->cid))
- ->will($this->returnValue(array($cache_item->cid => $cache_item)));
+ ->with([$cache_item->cid])
+ ->will($this->returnValue([$cache_item->cid => $cache_item]));
// We should get a call for the cache item on the fast backend.
$fast_cache->expects($this->once())
->method('getMultiple')
- ->with(array($cache_item->cid))
- ->will($this->returnValue(array($cache_item->cid => $cache_item)));
+ ->with([$cache_item->cid])
+ ->will($this->returnValue([$cache_item->cid => $cache_item]));
// We should get a call to set the cache item on the fast backend.
$fast_cache->expects($this->once())
diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
index 0bc9d7f1ba2..e68dd9bc557 100644
--- a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
@@ -142,19 +142,19 @@ class CacheContextsManagerTest extends UnitTestCase {
public function testAvailableContextStrings() {
$cache_contexts_manager = new CacheContextsManager($this->getMockContainer(), $this->getContextsFixture());
$contexts = $cache_contexts_manager->getAll();
- $this->assertEquals(array("foo", "baz"), $contexts);
+ $this->assertEquals(["foo", "baz"], $contexts);
}
public function testAvailableContextLabels() {
$container = $this->getMockContainer();
$cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
$labels = $cache_contexts_manager->getLabels();
- $expected = array("foo" => "Foo");
+ $expected = ["foo" => "Foo"];
$this->assertEquals($expected, $labels);
}
protected function getContextsFixture() {
- return array('foo', 'baz');
+ return ['foo', 'baz'];
}
protected function getMockContainer() {
diff --git a/core/tests/Drupal/Tests/Core/Common/AttributesTest.php b/core/tests/Drupal/Tests/Core/Common/AttributesTest.php
index 39d7fc1def5..1f7d9c8014d 100644
--- a/core/tests/Drupal/Tests/Core/Common/AttributesTest.php
+++ b/core/tests/Drupal/Tests/Core/Common/AttributesTest.php
@@ -18,31 +18,31 @@ class AttributesTest extends UnitTestCase {
* @return array
*/
public function providerTestAttributeData() {
- return array(
+ return [
// Verify that special characters are HTML encoded.
- array(array('&"\'<>' => 'value'), ' &amp;&quot;&#039;&lt;&gt;="value"', 'HTML encode attribute names.'),
- array(array('title' => '&"\'<>'), ' title="&amp;&quot;&#039;&lt;&gt;"', 'HTML encode attribute values.'),
+ [['&"\'<>' => 'value'], ' &amp;&quot;&#039;&lt;&gt;="value"', 'HTML encode attribute names.'],
+ [['title' => '&"\'<>'], ' title="&amp;&quot;&#039;&lt;&gt;"', 'HTML encode attribute values.'],
// Verify multi-value attributes are concatenated with spaces.
- array(array('class' => array('first', 'last')), ' class="first last"', 'Concatenate multi-value attributes.'),
+ [['class' => ['first', 'last']], ' class="first last"', 'Concatenate multi-value attributes.'],
// Verify boolean attribute values are rendered correctly.
- array(array('disabled' => TRUE), ' disabled', 'Boolean attribute is rendered.'),
- array(array('disabled' => FALSE), '', 'Boolean attribute is not rendered.'),
+ [['disabled' => TRUE], ' disabled', 'Boolean attribute is rendered.'],
+ [['disabled' => FALSE], '', 'Boolean attribute is not rendered.'],
// Verify empty attribute values are rendered.
- array(array('alt' => ''), ' alt=""', 'Empty attribute value #1.'),
- array(array('alt' => NULL), '', 'Null attribute value #2.'),
+ [['alt' => ''], ' alt=""', 'Empty attribute value #1.'],
+ [['alt' => NULL], '', 'Null attribute value #2.'],
// Verify multiple attributes are rendered.
- array(
- array(
+ [
+ [
'id' => 'id-test',
- 'class' => array('first', 'last'),
+ 'class' => ['first', 'last'],
'alt' => 'Alternate',
- ),
+ ],
' id="id-test" class="first last" alt="Alternate"',
'Multiple attributes.'
- ),
+ ],
// Verify empty attributes array is rendered.
- array(array(), '', 'Empty attributes array.'),
- );
+ [[], '', 'Empty attributes array.'],
+ ];
}
/**
@@ -60,7 +60,7 @@ class AttributesTest extends UnitTestCase {
* Test attribute iteration
*/
public function testAttributeIteration() {
- $attribute = new Attribute(array('key1' => 'value1'));
+ $attribute = new Attribute(['key1' => 'value1']);
foreach ($attribute as $value) {
$this->assertSame((string) $value, 'value1', 'Iterate over attribute.');
}
diff --git a/core/tests/Drupal/Tests/Core/Common/DiffArrayTest.php b/core/tests/Drupal/Tests/Core/Common/DiffArrayTest.php
index 4112eaeb16e..2493ab511d5 100644
--- a/core/tests/Drupal/Tests/Core/Common/DiffArrayTest.php
+++ b/core/tests/Drupal/Tests/Core/Common/DiffArrayTest.php
@@ -29,42 +29,42 @@ class DiffArrayTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- $this->array1 = array(
+ $this->array1 = [
'same' => 'yes',
'different' => 'no',
- 'array_empty_diff' => array(),
+ 'array_empty_diff' => [],
'null' => NULL,
'int_diff' => 1,
- 'array_diff' => array('same' => 'same', 'array' => array('same' => 'same')),
- 'array_compared_to_string' => array('value'),
+ 'array_diff' => ['same' => 'same', 'array' => ['same' => 'same']],
+ 'array_compared_to_string' => ['value'],
'string_compared_to_array' => 'value',
'new' => 'new',
- );
- $this->array2 = array(
+ ];
+ $this->array2 = [
'same' => 'yes',
'different' => 'yes',
- 'array_empty_diff' => array(),
+ 'array_empty_diff' => [],
'null' => NULL,
'int_diff' => '1',
- 'array_diff' => array('same' => 'different', 'array' => array('same' => 'same')),
+ 'array_diff' => ['same' => 'different', 'array' => ['same' => 'same']],
'array_compared_to_string' => 'value',
- 'string_compared_to_array' => array('value'),
- );
+ 'string_compared_to_array' => ['value'],
+ ];
}
/**
* Tests DiffArray::diffAssocRecursive().
*/
public function testDiffAssocRecursive() {
- $expected = array(
+ $expected = [
'different' => 'no',
'int_diff' => 1,
// The 'array' key should not be returned, as it's the same.
- 'array_diff' => array('same' => 'same'),
- 'array_compared_to_string' => array('value'),
+ 'array_diff' => ['same' => 'same'],
+ 'array_compared_to_string' => ['value'],
'string_compared_to_array' => 'value',
'new' => 'new',
- );
+ ];
$this->assertSame(DiffArray::diffAssocRecursive($this->array1, $this->array2), $expected);
}
diff --git a/core/tests/Drupal/Tests/Core/Common/TagsTest.php b/core/tests/Drupal/Tests/Core/Common/TagsTest.php
index 48d788a8fef..3c3058f9655 100644
--- a/core/tests/Drupal/Tests/Core/Common/TagsTest.php
+++ b/core/tests/Drupal/Tests/Core/Common/TagsTest.php
@@ -12,12 +12,12 @@ use Drupal\Tests\UnitTestCase;
*/
class TagsTest extends UnitTestCase {
- protected $validTags = array(
+ protected $validTags = [
'Drupal' => 'Drupal',
'Drupal with some spaces' => 'Drupal with some spaces',
'"Legendary Drupal mascot of doom: ""Druplicon"""' => 'Legendary Drupal mascot of doom: "Druplicon"',
'"Drupal, although it rhymes with sloopal, is as awesome as a troopal!"' => 'Drupal, although it rhymes with sloopal, is as awesome as a troopal!',
- );
+ ];
/**
* Explodes a series of tags.
diff --git a/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php b/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php
index 241ea38c0ad..f0da2314099 100644
--- a/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php
+++ b/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php
@@ -29,7 +29,7 @@ class ConditionAccessResolverTraitTest extends UnitTestCase {
}
public function providerTestResolveConditions() {
- $data = array();
+ $data = [];
$condition_true = $this->getMock('Drupal\Core\Condition\ConditionInterface');
$condition_true->expects($this->any())
@@ -54,49 +54,49 @@ class ConditionAccessResolverTraitTest extends UnitTestCase {
->method('isNegated')
->will($this->returnValue(TRUE));
- $conditions = array();
- $data[] = array($conditions, 'and', TRUE);
- $data[] = array($conditions, 'or', FALSE);
+ $conditions = [];
+ $data[] = [$conditions, 'and', TRUE];
+ $data[] = [$conditions, 'or', FALSE];
- $conditions = array($condition_false);
- $data[] = array($conditions, 'or', FALSE);
- $data[] = array($conditions, 'and', FALSE);
+ $conditions = [$condition_false];
+ $data[] = [$conditions, 'or', FALSE];
+ $data[] = [$conditions, 'and', FALSE];
- $conditions = array($condition_true);
- $data[] = array($conditions, 'or', TRUE);
- $data[] = array($conditions, 'and', TRUE);
+ $conditions = [$condition_true];
+ $data[] = [$conditions, 'or', TRUE];
+ $data[] = [$conditions, 'and', TRUE];
- $conditions = array($condition_true, $condition_false);
- $data[] = array($conditions, 'or', TRUE);
- $data[] = array($conditions, 'and', FALSE);
+ $conditions = [$condition_true, $condition_false];
+ $data[] = [$conditions, 'or', TRUE];
+ $data[] = [$conditions, 'and', FALSE];
- $conditions = array($condition_exception);
- $data[] = array($conditions, 'or', FALSE);
- $data[] = array($conditions, 'and', FALSE);
+ $conditions = [$condition_exception];
+ $data[] = [$conditions, 'or', FALSE];
+ $data[] = [$conditions, 'and', FALSE];
- $conditions = array($condition_true, $condition_exception);
- $data[] = array($conditions, 'or', TRUE);
- $data[] = array($conditions, 'and', FALSE);
+ $conditions = [$condition_true, $condition_exception];
+ $data[] = [$conditions, 'or', TRUE];
+ $data[] = [$conditions, 'and', FALSE];
- $conditions = array($condition_exception, $condition_true);
- $data[] = array($conditions, 'or', TRUE);
- $data[] = array($conditions, 'and', FALSE);
+ $conditions = [$condition_exception, $condition_true];
+ $data[] = [$conditions, 'or', TRUE];
+ $data[] = [$conditions, 'and', FALSE];
- $conditions = array($condition_false, $condition_exception);
- $data[] = array($conditions, 'or', FALSE);
- $data[] = array($conditions, 'and', FALSE);
+ $conditions = [$condition_false, $condition_exception];
+ $data[] = [$conditions, 'or', FALSE];
+ $data[] = [$conditions, 'and', FALSE];
- $conditions = array($condition_exception, $condition_false);
- $data[] = array($conditions, 'or', FALSE);
- $data[] = array($conditions, 'and', FALSE);
+ $conditions = [$condition_exception, $condition_false];
+ $data[] = [$conditions, 'or', FALSE];
+ $data[] = [$conditions, 'and', FALSE];
- $conditions = array($condition_negated);
- $data[] = array($conditions, 'or', TRUE);
- $data[] = array($conditions, 'and', TRUE);
+ $conditions = [$condition_negated];
+ $data[] = [$conditions, 'or', TRUE];
+ $data[] = [$conditions, 'and', TRUE];
- $conditions = array($condition_negated, $condition_negated);
- $data[] = array($conditions, 'or', TRUE);
- $data[] = array($conditions, 'and', TRUE);
+ $conditions = [$condition_negated, $condition_negated];
+ $data[] = [$conditions, 'or', TRUE];
+ $data[] = [$conditions, 'and', TRUE];
return $data;
}
diff --git a/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php b/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
index 1a4c2db4a1a..c39efd62491 100644
--- a/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
@@ -25,7 +25,7 @@ class CachedStorageTest extends UnitTestCase {
$prefix = __FUNCTION__;
$storage = $this->getMock('Drupal\Core\Config\StorageInterface');
- $response = array("$prefix." . $this->randomMachineName(), "$prefix." . $this->randomMachineName());
+ $response = ["$prefix." . $this->randomMachineName(), "$prefix." . $this->randomMachineName()];
$storage->expects($this->once())
->method('listAll')
->with($prefix)
diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
index 223d8903e06..ef1db218013 100644
--- a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
@@ -87,16 +87,16 @@ class ConfigTest extends UnitTestCase {
* @see \Drupal\Tests\Core\Config\ConfigTest::testSetName()
*/
public function setNameProvider() {
- return array(
+ return [
// Valid name with dot.
- array(
+ [
'test.name',
- ),
+ ],
// Maximum length.
- array(
+ [
'test.' . str_repeat('a', Config::MAX_NAME_LENGTH - 5),
- ),
- );
+ ],
+ ];
}
/**
@@ -233,7 +233,7 @@ class ConfigTest extends UnitTestCase {
* @expectedException \Drupal\Core\Config\ConfigValueException
*/
public function testSetValidation() {
- $this->config->set('testData', array('dot.key' => 1));
+ $this->config->set('testData', ['dot.key' => 1]);
}
/**
@@ -369,16 +369,16 @@ class ConfigTest extends UnitTestCase {
* @see \Drupal\Tests\Core\Config\ConfigTest::testMerge()
*/
public function mergeDataProvider() {
- return array(
- array(
+ return [
+ [
// Data.
- array('a' => 1, 'b' => 2, 'c' => array('d' => 3)),
+ ['a' => 1, 'b' => 2, 'c' => ['d' => 3]],
// Data to merge.
- array('a' => 2, 'e' => 4, 'c' => array('f' => 5)),
+ ['a' => 2, 'e' => 4, 'c' => ['f' => 5]],
// Data merged.
- array('a' => 2, 'b' => 2, 'c' => array('d' => 3, 'f' => 5), 'e' => 4),
- ),
- );
+ ['a' => 2, 'b' => 2, 'c' => ['d' => 3, 'f' => 5], 'e' => 4],
+ ],
+ ];
}
/**
@@ -404,25 +404,25 @@ class ConfigTest extends UnitTestCase {
* @see \Drupal\Tests\Core\Config\ConfigTest::testValidateNameException()
*/
public function validateNameProvider() {
- $return = array(
+ $return = [
// Name missing namespace (dot).
- array(
+ [
'MissingNamespace',
'Missing namespace in Config object name MissingNamespace.',
- ),
+ ],
// Exceeds length (max length plus an extra dot).
- array(
+ [
str_repeat('a', Config::MAX_NAME_LENGTH) . ".",
'Config object name ' . str_repeat('a', Config::MAX_NAME_LENGTH) . '. exceeds maximum allowed length of ' . Config::MAX_NAME_LENGTH . ' characters.',
- ),
- );
+ ],
+ ];
// Name must not contain : ? * < > " ' / \
- foreach (array(':', '?', '*', '<', '>', '"', "'", '/', '\\') as $char) {
+ foreach ([':', '?', '*', '<', '>', '"', "'", '/', '\\'] as $char) {
$name = 'name.' . $char;
- $return[] = array(
+ $return[] = [
$name,
"Invalid character in Config object name $name.",
- );
+ ];
}
return $return;
}
@@ -434,22 +434,22 @@ class ConfigTest extends UnitTestCase {
* @see \Drupal\Tests\Core\Config\ConfigTest::testDelete()
*/
public function overrideDataProvider() {
- return array(
- array(
+ return [
+ [
// Original data.
- array(
+ [
'a' => 'originalValue',
- ),
+ ],
// Module overrides.
- array(
+ [
'a' => 'moduleValue',
- ),
+ ],
// Setting overrides.
- array(
+ [
'a' => 'settingValue',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -458,15 +458,15 @@ class ConfigTest extends UnitTestCase {
* @see \Drupal\Tests\Core\Config\ConfigTest::testClear()
*/
public function simpleDataProvider() {
- return array(
- array(
- array(
+ return [
+ [
+ [
'a' => '1',
'b' => '2',
'c' => '3',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -479,21 +479,21 @@ class ConfigTest extends UnitTestCase {
* @see \Drupal\Tests\Core\Config\ConfigTest::testNestedClear()
*/
public function nestedDataProvider() {
- return array(
- array(
- array(
- 'a' => array(
+ return [
+ [
+ [
+ 'a' => [
'd' => 1,
- ),
- 'b' => array(
+ ],
+ 'b' => [
'e' => 2,
- ),
- 'c' => array(
+ ],
+ 'c' => [
'f' => 3,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php
index 0c3f14dbde5..9f058d56f36 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php
@@ -19,11 +19,11 @@ class ConfigDependencyManagerTest extends UnitTestCase {
public function testNoConfigEntities() {
$dep_manger = new ConfigDependencyManager();
- $dep_manger->setData(array(
- 'simple.config' => array(
+ $dep_manger->setData([
+ 'simple.config' => [
'key' => 'value',
- ),
- ));
+ ],
+ ]);
$this->assertEmpty($dep_manger->getDependentEntities('config', 'config_test.dynamic.entity_id:745b0ce0-aece-42dd-a800-ade5b8455e84'));
// Configuration is always dependent on its provider.
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
index 4710765dd02..171f2d36c4a 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
@@ -96,11 +96,11 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
*/
protected function setUp() {
$this->id = $this->randomMachineName();
- $values = array(
+ $values = [
'id' => $this->id,
'langcode' => 'en',
'uuid' => '3bb9ee60-bea5-4622-b89b-a63319d10b3a',
- );
+ ];
$this->entityTypeId = $this->randomMachineName();
$this->provider = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
@@ -123,7 +123,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
$this->languageManager->expects($this->any())
->method('getLanguage')
->with('en')
- ->will($this->returnValue(new Language(array('id' => 'en'))));
+ ->will($this->returnValue(new Language(['id' => 'en'])));
$this->cacheTagsInvalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface');
@@ -137,7 +137,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
$container->set('config.typed', $this->typedConfigManager);
\Drupal::setContainer($container);
- $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Config\Entity\ConfigEntityBase', array($values, $this->entityTypeId));
+ $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Config\Entity\ConfigEntityBase', [$values, $this->entityTypeId]);
}
/**
@@ -146,12 +146,12 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
*/
public function testCalculateDependencies() {
// Calculating dependencies will reset the dependencies array.
- $this->entity->set('dependencies', array('module' => array('node')));
+ $this->entity->set('dependencies', ['module' => ['node']]);
$this->assertEmpty($this->entity->calculateDependencies()->getDependencies());
// Calculating dependencies will reset the dependencies array using enforced
// dependencies.
- $this->entity->set('dependencies', array('module' => array('node'), 'enforced' => array('module' => 'views')));
+ $this->entity->set('dependencies', ['module' => ['node'], 'enforced' => ['module' => 'views']]);
$dependencies = $this->entity->calculateDependencies()->getDependencies();
$this->assertContains('views', $dependencies['module']);
$this->assertNotContains('node', $dependencies['module']);
@@ -166,7 +166,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
$query->expects($this->any())
->method('execute')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$query->expects($this->any())
->method('condition')
->will($this->returnValue($query));
@@ -179,12 +179,12 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
// Saving an entity will not reset the dependencies array during config
// synchronization.
- $this->entity->set('dependencies', array('module' => array('node')));
+ $this->entity->set('dependencies', ['module' => ['node']]);
$this->entity->preSave($storage);
$this->assertEmpty($this->entity->getDependencies());
$this->entity->setSyncing(TRUE);
- $this->entity->set('dependencies', array('module' => array('node')));
+ $this->entity->set('dependencies', ['module' => ['node']]);
$this->entity->preSave($storage);
$dependencies = $this->entity->getDependencies();
$this->assertContains('node', $dependencies['module']);
@@ -207,12 +207,12 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
// Test sorting of dependencies.
$method->invoke($this->entity, 'module', 'action');
$dependencies = $this->entity->getDependencies();
- $this->assertEquals(array('action', 'node'), $dependencies['module']);
+ $this->assertEquals(['action', 'node'], $dependencies['module']);
// Test sorting of dependency types.
$method->invoke($this->entity, 'entity', 'system.action.id');
$dependencies = $this->entity->getDependencies();
- $this->assertEquals(array('entity', 'module'), array_keys($dependencies));
+ $this->assertEquals(['entity', 'module'], array_keys($dependencies));
}
/**
@@ -222,20 +222,20 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
* @dataProvider providerCalculateDependenciesWithPluginCollections
*/
public function testCalculateDependenciesWithPluginCollections($definition, $expected_dependencies) {
- $values = array();
+ $values = [];
$this->entity = $this->getMockBuilder('\Drupal\Tests\Core\Config\Entity\Fixtures\ConfigEntityBaseWithPluginCollections')
- ->setConstructorArgs(array($values, $this->entityTypeId))
- ->setMethods(array('getPluginCollections'))
+ ->setConstructorArgs([$values, $this->entityTypeId])
+ ->setMethods(['getPluginCollections'])
->getMock();
// Create a configurable plugin that would add a dependency.
$instance_id = $this->randomMachineName();
- $instance = new TestConfigurablePlugin(array(), $instance_id, $definition);
+ $instance = new TestConfigurablePlugin([], $instance_id, $definition);
// Create a plugin collection to contain the instance.
$pluginCollection = $this->getMockBuilder('\Drupal\Core\Plugin\DefaultLazyPluginCollection')
->disableOriginalConstructor()
- ->setMethods(array('get'))
+ ->setMethods(['get'])
->getMock();
$pluginCollection->expects($this->atLeastOnce())
->method('get')
@@ -246,7 +246,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
// Return the mocked plugin collection.
$this->entity->expects($this->once())
->method('getPluginCollections')
- ->will($this->returnValue(array($pluginCollection)));
+ ->will($this->returnValue([$pluginCollection]));
$this->assertEquals($expected_dependencies, $this->entity->calculateDependencies()->getDependencies());
}
@@ -261,34 +261,34 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
$instance_dependency_1 = 'a' . $this->randomMachineName(10);
$instance_dependency_2 = 'a' . $this->randomMachineName(11);
- return array(
+ return [
// Tests that the plugin provider is a module dependency.
- array(
- array('provider' => 'test'),
- array('module' => array('test')),
- ),
+ [
+ ['provider' => 'test'],
+ ['module' => ['test']],
+ ],
// Tests that a plugin that is provided by the same module as the config
// entity is not added to the dependencies array.
- array(
- array('provider' => $this->provider),
- array('module' => array(NULL)),
- ),
+ [
+ ['provider' => $this->provider],
+ ['module' => [NULL]],
+ ],
// Tests that a config entity that has a plugin which provides config
// dependencies in its definition has them.
- array(
- array(
+ [
+ [
'provider' => 'test',
- 'config_dependencies' => array(
- 'config' => array($instance_dependency_1),
- 'module' => array($instance_dependency_2),
- )
- ),
- array(
- 'config' => array($instance_dependency_1),
- 'module' => array($instance_dependency_2, 'test')
- )
- )
- );
+ 'config_dependencies' => [
+ 'config' => [$instance_dependency_1],
+ 'module' => [$instance_dependency_2],
+ ]
+ ],
+ [
+ 'config' => [$instance_dependency_1],
+ 'module' => [$instance_dependency_2, 'test']
+ ]
+ ]
+ ];
}
/**
@@ -297,17 +297,17 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
* @covers ::onDependencyRemoval
*/
public function testCalculateDependenciesWithThirdPartySettings() {
- $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Config\Entity\ConfigEntityBase', array(array(), $this->entityTypeId));
+ $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Config\Entity\ConfigEntityBase', [[], $this->entityTypeId]);
$this->entity->setThirdPartySetting('test_provider', 'test', 'test');
$this->entity->setThirdPartySetting('test_provider2', 'test', 'test');
$this->entity->setThirdPartySetting($this->provider, 'test', 'test');
- $this->assertEquals(array('test_provider', 'test_provider2'), $this->entity->calculateDependencies()->getDependencies()['module']);
+ $this->assertEquals(['test_provider', 'test_provider2'], $this->entity->calculateDependencies()->getDependencies()['module']);
$changed = $this->entity->onDependencyRemoval(['module' => ['test_provider2']]);
$this->assertTrue($changed, 'Calling onDependencyRemoval with an existing third party dependency provider returns TRUE.');
$changed = $this->entity->onDependencyRemoval(['module' => ['test_provider3']]);
$this->assertFalse($changed, 'Calling onDependencyRemoval with a non-existing third party dependency provider returns FALSE.');
- $this->assertEquals(array('test_provider'), $this->entity->calculateDependencies()->getDependencies()['module']);
+ $this->assertEquals(['test_provider'], $this->entity->calculateDependencies()->getDependencies()['module']);
}
/**
@@ -470,11 +470,11 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
$this->entityManager->expects($this->any())
->method('getDefinition')
->with($this->entityTypeId)
- ->will($this->returnValue(array(
- 'entity_keys' => array(
+ ->will($this->returnValue([
+ 'entity_keys' => [
'label' => 'label',
- ),
- )));
+ ],
+ ]));
$entity_a = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityInterface');
$entity_a->expects($this->atLeastOnce())
@@ -486,12 +486,12 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
->willReturn('bar');
// Test sorting by label.
- $list = array($entity_a, $entity_b);
+ $list = [$entity_a, $entity_b];
// Suppress errors because of https://bugs.php.net/bug.php?id=50688.
@usort($list, '\Drupal\Core\Config\Entity\ConfigEntityBase::sort');
$this->assertSame($entity_b, $list[0]);
- $list = array($entity_b, $entity_a);
+ $list = [$entity_b, $entity_a];
// Suppress errors because of https://bugs.php.net/bug.php?id=50688.
@usort($list, '\Drupal\Core\Config\Entity\ConfigEntityBase::sort');
$this->assertSame($entity_b, $list[0]);
@@ -499,12 +499,12 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
// Test sorting by weight.
$entity_a->weight = 0;
$entity_b->weight = 1;
- $list = array($entity_b, $entity_a);
+ $list = [$entity_b, $entity_a];
// Suppress errors because of https://bugs.php.net/bug.php?id=50688.
@usort($list, '\Drupal\Core\Config\Entity\ConfigEntityBase::sort');
$this->assertSame($entity_a, $list[0]);
- $list = array($entity_a, $entity_b);
+ $list = [$entity_a, $entity_b];
// Suppress errors because of https://bugs.php.net/bug.php?id=50688.
@usort($list, '\Drupal\Core\Config\Entity\ConfigEntityBase::sort');
$this->assertSame($entity_a, $list[0]);
@@ -521,7 +521,7 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
->willReturn(['id' => 'configId', 'dependencies' => 'dependencies']);
$properties = $this->entity->toArray();
$this->assertInternalType('array', $properties);
- $this->assertEquals(array('configId' => $this->entity->id(), 'dependencies' => array()), $properties);
+ $this->assertEquals(['configId' => $this->entity->id(), 'dependencies' => []], $properties);
}
/**
@@ -556,13 +556,13 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
public function testToArraySchemaFallback() {
$this->typedConfigManager->expects($this->once())
->method('getDefinition')
- ->will($this->returnValue(array('mapping' => array('id' => '', 'dependencies' => ''))));
+ ->will($this->returnValue(['mapping' => ['id' => '', 'dependencies' => '']]));
$this->entityType->expects($this->any())
->method('getPropertiesToExport')
->willReturn([]);
$properties = $this->entity->toArray();
$this->assertInternalType('array', $properties);
- $this->assertEquals(array('id' => $this->entity->id(), 'dependencies' => array()), $properties);
+ $this->assertEquals(['id' => $this->entity->id(), 'dependencies' => []], $properties);
}
/**
@@ -600,15 +600,15 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
// Test getThirdPartySettings().
$this->entity->setThirdPartySetting($third_party, 'test2', 'value2');
- $this->assertEquals(array($key => $value, 'test2' => 'value2'), $this->entity->getThirdPartySettings($third_party));
+ $this->assertEquals([$key => $value, 'test2' => 'value2'], $this->entity->getThirdPartySettings($third_party));
// Test getThirdPartyProviders().
$this->entity->setThirdPartySetting('test_provider2', $key, $value);
- $this->assertEquals(array($third_party, 'test_provider2'), $this->entity->getThirdPartyProviders());
+ $this->assertEquals([$third_party, 'test_provider2'], $this->entity->getThirdPartyProviders());
// Test unsetThirdPartyProviders().
$this->entity->unsetThirdPartySetting('test_provider2', $key);
- $this->assertEquals(array($third_party), $this->entity->getThirdPartyProviders());
+ $this->assertEquals([$third_party], $this->entity->getThirdPartyProviders());
}
}
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityDependencyTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityDependencyTest.php
index 5d617ce0c75..7bcbc97cc99 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityDependencyTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityDependencyTest.php
@@ -13,34 +13,34 @@ use Drupal\Core\Config\Entity\ConfigEntityDependency;
class ConfigEntityDependencyTest extends UnitTestCase {
public function testEmptyDependencies() {
- $dep = new ConfigEntityDependency('config_test.dynamic.entity_id', array());
+ $dep = new ConfigEntityDependency('config_test.dynamic.entity_id', []);
$this->assertEquals('config_test.dynamic.entity_id', $dep->getConfigDependencyName());
- $this->assertEquals(array(), $dep->getDependencies('theme'));
- $this->assertEquals(array(), $dep->getDependencies('config'));
- $this->assertEquals(array('config_test'), $dep->getDependencies('module'));
+ $this->assertEquals([], $dep->getDependencies('theme'));
+ $this->assertEquals([], $dep->getDependencies('config'));
+ $this->assertEquals(['config_test'], $dep->getDependencies('module'));
$this->assertTrue($dep->hasDependency('module', 'config_test'));
$this->assertFalse($dep->hasDependency('module', 'views'));
}
public function testWithDependencies() {
- $values = array(
+ $values = [
'uuid' => '60db47f4-54fb-4c86-a439-5769fbda4bd1',
- 'dependencies' => array(
- 'module' => array(
+ 'dependencies' => [
+ 'module' => [
'node',
'views'
- ),
- 'config' => array(
+ ],
+ 'config' => [
'config_test.dynamic.entity_id:745b0ce0-aece-42dd-a800-ade5b8455e84',
- ),
- ),
- );
+ ],
+ ],
+ ];
$dep = new ConfigEntityDependency('config_test.dynamic.entity_id', $values);
- $this->assertEquals(array(), $dep->getDependencies('theme'));
- $this->assertEquals(array('config_test.dynamic.entity_id:745b0ce0-aece-42dd-a800-ade5b8455e84'), $dep->getDependencies('config'));
- $this->assertEquals(array('node', 'views', 'config_test'), $dep->getDependencies('module'));
+ $this->assertEquals([], $dep->getDependencies('theme'));
+ $this->assertEquals(['config_test.dynamic.entity_id:745b0ce0-aece-42dd-a800-ade5b8455e84'], $dep->getDependencies('config'));
+ $this->assertEquals(['node', 'views', 'config_test'], $dep->getDependencies('module'));
$this->assertTrue($dep->hasDependency('module', 'config_test'));
$this->assertTrue($dep->hasDependency('module', 'views'));
$this->assertTrue($dep->hasDependency('module', 'node'));
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
index 62310a1901b..230b0856b5d 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
@@ -177,7 +177,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->uuidService->generate()->shouldNotBeCalled();
- $entity = $this->entityStorage->create(array('id' => 'foo', 'uuid' => 'baz'));
+ $entity = $this->entityStorage->create(['id' => 'foo', 'uuid' => 'baz']);
$this->assertInstanceOf(EntityInterface::class, $entity);
$this->assertSame('foo', $entity->id());
$this->assertSame('baz', $entity->uuid());
@@ -206,7 +206,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->uuidService->generate()->willReturn('bar');
- $entity = $this->entityStorage->create(array('id' => 'foo'));
+ $entity = $this->entityStorage->create(['id' => 'foo']);
$this->assertInstanceOf(EntityInterface::class, $entity);
$this->assertSame('foo', $entity->id());
$this->assertSame('bar', $entity->uuid());
@@ -220,7 +220,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
public function testCreateWithCurrentLanguage() {
$this->languageManager->getLanguage('hu')->willReturn(new Language(['id' => 'hu']));
- $entity = $this->entityStorage->create(array('id' => 'foo'));
+ $entity = $this->entityStorage->create(['id' => 'foo']);
$this->assertSame('hu', $entity->language()->getId());
}
@@ -231,7 +231,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
public function testCreateWithExplicitLanguage() {
$this->languageManager->getLanguage('en')->willReturn(new Language(['id' => 'en']));
- $entity = $this->entityStorage->create(array('id' => 'foo', 'langcode' => 'en'));
+ $entity = $this->entityStorage->create(['id' => 'foo', 'langcode' => 'en']);
$this->assertSame('en', $entity->language()->getId());
}
@@ -404,7 +404,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->configFactory->get('the_provider.the_config_prefix.foo')
->willReturn($config_object->reveal());
- $entity = $this->getMockEntity(array('id' => 'foo'));
+ $entity = $this->getMockEntity(['id' => 'foo']);
$entity->enforceIsNew();
$this->entityStorage->save($entity);
@@ -430,7 +430,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->entityQuery->condition('uuid', NULL)->willReturn($this->entityQuery);
$this->entityQuery->execute()->willReturn(['baz']);
- $entity = $this->getMockEntity(array('id' => 'foo'));
+ $entity = $this->getMockEntity(['id' => 'foo']);
$this->entityStorage->save($entity);
}
@@ -463,7 +463,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->entityQuery->condition('uuid', NULL)->willReturn($this->entityQuery);
$this->entityQuery->execute()->willReturn(['baz']);
- $entity = $this->getMockEntity(array('id' => 'foo'));
+ $entity = $this->getMockEntity(['id' => 'foo']);
$entity->setOriginalId('baz');
$entity->enforceIsNew();
$this->entityStorage->save($entity);
@@ -501,7 +501,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->entityQuery->condition('uuid', 'baz')->willReturn($this->entityQuery);
$this->entityQuery->execute()->willReturn(['foo']);
- $entity = $this->getMockEntity(array('id' => 'foo'));
+ $entity = $this->getMockEntity(['id' => 'foo']);
$entity->set('uuid', 'baz');
$this->entityStorage->save($entity);
@@ -595,7 +595,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->moduleHandler->getImplementations('entity_load')->willReturn([]);
$this->moduleHandler->getImplementations('test_entity_type_load')->willReturn([]);
- $entities = $this->entityStorage->loadMultiple(array('foo'));
+ $entities = $this->entityStorage->loadMultiple(['foo']);
$this->assertContainsOnlyInstancesOf(EntityInterface::class, $entities);
foreach ($entities as $id => $entity) {
$this->assertSame($id, $entity->id());
@@ -633,9 +633,9 @@ class ConfigEntityStorageTest extends UnitTestCase {
->getConfigEntitiesToChangeOnDependencyRemoval('config', ['the_provider.the_config_prefix.bar'], FALSE)
->willReturn(['update' => [], 'delete' => [], 'unchanged' => []]);
- $entities = array();
- foreach (array('foo', 'bar') as $id) {
- $entity = $this->getMockEntity(array('id' => $id));
+ $entities = [];
+ foreach (['foo', 'bar'] as $id) {
+ $entity = $this->getMockEntity(['id' => $id]);
$entities[] = $entity;
$config_object = $this->prophesize(Config::class);
@@ -674,7 +674,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
$this->cacheTagsInvalidator->invalidateTags(Argument::cetera())->shouldNotBeCalled();
- $this->entityStorage->delete(array());
+ $this->entityStorage->delete([]);
}
/**
@@ -687,7 +687,7 @@ class ConfigEntityStorageTest extends UnitTestCase {
*
* @return \Drupal\Core\Entity\EntityInterface|\PHPUnit_Framework_MockObject_MockObject
*/
- public function getMockEntity(array $values = array(), $methods = array()) {
+ public function getMockEntity(array $values = [], $methods = []) {
return $this->getMockForAbstractClass(ConfigEntityBase::class, [$values, 'test_entity_type'], '', TRUE, TRUE, TRUE, $methods);
}
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
index b131b26a15d..928cebc1532 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
@@ -21,9 +21,9 @@ class ConfigEntityTypeTest extends UnitTestCase {
*/
protected function setUpConfigEntityType($definition) {
if (!isset($definition['id'])) {
- $definition += array(
+ $definition += [
'id' => 'example_config_entity_type',
- );
+ ];
}
return new ConfigEntityType($definition);
}
@@ -37,10 +37,10 @@ class ConfigEntityTypeTest extends UnitTestCase {
public function testConfigPrefixLengthExceeds() {
// A provider length of 24 and config_prefix length of 59 (+1 for the .)
// results in a config length of 84, which is too long.
- $definition = array(
+ $definition = [
'provider' => $this->randomMachineName(24),
'config_prefix' => $this->randomMachineName(59),
- );
+ ];
$config_entity = $this->setUpConfigEntityType($definition);
$this->setExpectedException(
'\Drupal\Core\Config\ConfigPrefixLengthException',
@@ -58,10 +58,10 @@ class ConfigEntityTypeTest extends UnitTestCase {
public function testConfigPrefixLengthValid() {
// A provider length of 24 and config_prefix length of 58 (+1 for the .)
// results in a config length of 83, which is right at the limit.
- $definition = array(
+ $definition = [
'provider' => $this->randomMachineName(24),
'config_prefix' => $this->randomMachineName(58),
- );
+ ];
$config_entity = $this->setUpConfigEntityType($definition);
$expected_prefix = $definition['provider'] . '.' . $definition['config_prefix'];
$this->assertEquals($expected_prefix, $config_entity->getConfigPrefix());
@@ -117,10 +117,10 @@ class ConfigEntityTypeTest extends UnitTestCase {
* Provides test data.
*/
public function providerTestGetConfigPrefix() {
- return array(
- array(array('provider' => 'node', 'id' => 'node_type', 'config_prefix' => 'type'), 'node.type'),
- array(array('provider' => 'views', 'id' => 'view'), 'views.view'),
- );
+ return [
+ [['provider' => 'node', 'id' => 'node_type', 'config_prefix' => 'type'], 'node.type'],
+ [['provider' => 'views', 'id' => 'view'], 'views.view'],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php
index 2a0b126da0f..728fdca457f 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php
@@ -77,7 +77,7 @@ class EntityDisplayModeBaseUnitTest extends UnitTestCase {
$target_entity_type->expects($this->any())
->method('getProvider')
->will($this->returnValue('test_module'));
- $values = array('targetEntityType' => $target_entity_type_id);
+ $values = ['targetEntityType' => $target_entity_type_id];
$this->entityManager->expects($this->at(0))
->method('getDefinition')
@@ -89,8 +89,8 @@ class EntityDisplayModeBaseUnitTest extends UnitTestCase {
->will($this->returnValue($this->entityInfo));
$this->entity = $this->getMockBuilder('\Drupal\Core\Entity\EntityDisplayModeBase')
- ->setConstructorArgs(array($values, $this->entityType))
- ->setMethods(array('getFilterFormat'))
+ ->setConstructorArgs([$values, $this->entityType])
+ ->setMethods(['getFilterFormat'])
->getMock();
$dependencies = $this->entity->calculateDependencies()->getDependencies();
@@ -105,7 +105,7 @@ class EntityDisplayModeBaseUnitTest extends UnitTestCase {
$mock = $this->getMock(
'Drupal\Core\Entity\EntityDisplayModeBase',
NULL,
- array(array('something' => 'nothing'), 'test_type')
+ [['something' => 'nothing'], 'test_type']
);
// Some test values.
@@ -134,7 +134,7 @@ class EntityDisplayModeBaseUnitTest extends UnitTestCase {
$mock = $this->getMock(
'Drupal\Core\Entity\EntityDisplayModeBase',
NULL,
- array(array('something' => 'nothing'), 'test_type')
+ [['something' => 'nothing'], 'test_type']
);
// A test value.
diff --git a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php
index e339af7b8af..fc0d63bede3 100644
--- a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php
@@ -51,48 +51,48 @@ class StorageComparerTest extends UnitTestCase {
protected function getConfigData() {
$uuid = new Php();
// Mock data using minimal data to use ConfigDependencyManger.
- $this->configData = array(
+ $this->configData = [
// Simple config that controls configuration sync.
- 'system.site' => array(
+ 'system.site' => [
'title' => 'Drupal',
'uuid' => $uuid->generate(),
- ),
+ ],
// Config entity which requires another config entity.
- 'field.field.node.article.body' => array(
+ 'field.field.node.article.body' => [
'id' => 'node.article.body',
'uuid' => $uuid->generate(),
- 'dependencies' => array(
- 'config' => array(
+ 'dependencies' => [
+ 'config' => [
'field.storage.node.body'
- ),
- ),
- ),
+ ],
+ ],
+ ],
// Config entity which is required by another config entity.
- 'field.storage.node.body' => array(
+ 'field.storage.node.body' => [
'id' => 'node.body',
'uuid' => $uuid->generate(),
- 'dependencies' => array(
- 'module' => array(
+ 'dependencies' => [
+ 'module' => [
'text',
- ),
- ),
- ),
+ ],
+ ],
+ ],
// Config entity not which has no dependencies on configuration.
- 'views.view.test_view' => array(
+ 'views.view.test_view' => [
'id' => 'test_view',
'uuid' => $uuid->generate(),
- 'dependencies' => array(
- 'module' => array(
+ 'dependencies' => [
+ 'module' => [
'node',
- ),
- ),
- ),
+ ],
+ ],
+ ],
// Simple config.
- 'system.performance' => array(
+ 'system.performance' => [
'stale_file_threshold' => 2592000
- ),
+ ],
- );
+ ];
return $this->configData;
}
@@ -116,10 +116,10 @@ class StorageComparerTest extends UnitTestCase {
->will($this->returnValue($config_data));
$this->sourceStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->storageComparer->createChangelist();
$this->assertEmpty($this->storageComparer->getChangelist('create'));
@@ -150,17 +150,17 @@ class StorageComparerTest extends UnitTestCase {
->will($this->returnValue($target_data));
$this->sourceStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->storageComparer->createChangelist();
- $expected = array(
+ $expected = [
'field.storage.node.body',
'field.field.node.article.body',
'views.view.test_view',
- );
+ ];
$this->assertEquals($expected, $this->storageComparer->getChangelist('create'));
$this->assertEmpty($this->storageComparer->getChangelist('delete'));
$this->assertEmpty($this->storageComparer->getChangelist('update'));
@@ -189,17 +189,17 @@ class StorageComparerTest extends UnitTestCase {
->will($this->returnValue($target_data));
$this->sourceStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->storageComparer->createChangelist();
- $expected = array(
+ $expected = [
'views.view.test_view',
'field.field.node.article.body',
'field.storage.node.body',
- );
+ ];
$this->assertEquals($expected, $this->storageComparer->getChangelist('delete'));
$this->assertEmpty($this->storageComparer->getChangelist('create'));
$this->assertEmpty($this->storageComparer->getChangelist('update'));
@@ -228,17 +228,17 @@ class StorageComparerTest extends UnitTestCase {
->will($this->returnValue($target_data));
$this->sourceStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->targetStorage->expects($this->once())
->method('getAllCollectionNames')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->storageComparer->createChangelist();
- $expected = array(
+ $expected = [
'field.storage.node.body',
'field.field.node.article.body',
'system.site',
- );
+ ];
$this->assertEquals($expected, $this->storageComparer->getChangelist('update'));
$this->assertEmpty($this->storageComparer->getChangelist('create'));
$this->assertEmpty($this->storageComparer->getChangelist('delete'));
diff --git a/core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php b/core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php
index 9dfc690dff4..3d42dec4a55 100644
--- a/core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/AjaxRendererTest.php
@@ -42,7 +42,7 @@ class AjaxRendererTest extends UnitTestCase {
->with('ajax')
->willReturn([
'#header' => TRUE,
- '#commands' => array(),
+ '#commands' => [],
'#error' => NULL,
]);
$this->ajaxRenderer = new TestAjaxRenderer($element_info_manager);
diff --git a/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php b/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
index 9bcb6b524e1..3f55f1510b4 100644
--- a/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
@@ -26,14 +26,14 @@ class ControllerBaseTest extends UnitTestCase {
* Tests the config method.
*/
public function testGetConfig() {
- $config_factory = $this->getConfigFactoryStub(array(
- 'config_name' => array(
+ $config_factory = $this->getConfigFactoryStub([
+ 'config_name' => [
'key' => 'value',
- ),
- 'config_name2' => array(
+ ],
+ 'config_name2' => [
'key2' => 'value2',
- ),
- ));
+ ],
+ ]);
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->once())
diff --git a/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php b/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
index 98a18a35478..ef9c0761b2d 100644
--- a/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
@@ -78,11 +78,11 @@ class ControllerResolverTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$mock_account = $this->getMock('Drupal\Core\Session\AccountInterface');
- $request = new Request(array(), array(), array(
+ $request = new Request([], [], [
'entity' => $mock_entity,
'user' => $mock_account,
- '_raw_variables' => new ParameterBag(array('entity' => 1, 'user' => 1)),
- ), array(), array(), array('HTTP_HOST' => 'drupal.org'));
+ '_raw_variables' => new ParameterBag(['entity' => 1, 'user' => 1]),
+ ], [], [], ['HTTP_HOST' => 'drupal.org']);
$arguments = $this->controllerResolver->getArguments($request, $controller);
$this->assertEquals($mock_entity, $arguments[0]);
@@ -106,16 +106,16 @@ class ControllerResolverTest extends UnitTestCase {
* Provides test data for testCreateController().
*/
public function providerTestCreateController() {
- return array(
+ return [
// Tests class::method.
- array('Drupal\Tests\Core\Controller\MockController::getResult', 'Drupal\Tests\Core\Controller\MockController', 'This is a regular controller.'),
+ ['Drupal\Tests\Core\Controller\MockController::getResult', 'Drupal\Tests\Core\Controller\MockController', 'This is a regular controller.'],
// Tests service:method.
- array('some_service:getResult', 'Drupal\Tests\Core\Controller\MockController', 'This is a regular controller.'),
+ ['some_service:getResult', 'Drupal\Tests\Core\Controller\MockController', 'This is a regular controller.'],
// Tests a class with injection.
- array('Drupal\Tests\Core\Controller\MockContainerInjection::getResult', 'Drupal\Tests\Core\Controller\MockContainerInjection', 'This used injection.'),
+ ['Drupal\Tests\Core\Controller\MockContainerInjection::getResult', 'Drupal\Tests\Core\Controller\MockContainerInjection', 'This used injection.'],
// Tests a ContainerAware class.
- array('Drupal\Tests\Core\Controller\MockContainerAware::getResult', 'Drupal\Tests\Core\Controller\MockContainerAware', 'This is container aware.'),
- );
+ ['Drupal\Tests\Core\Controller\MockContainerAware::getResult', 'Drupal\Tests\Core\Controller\MockContainerAware', 'This is container aware.'],
+ ];
}
/**
@@ -142,7 +142,7 @@ class ControllerResolverTest extends UnitTestCase {
* @dataProvider providerTestGetController
*/
public function testGetController($attributes, $class, $output = NULL) {
- $request = new Request(array(), array(), $attributes);
+ $request = new Request([], [], $attributes);
$result = $this->controllerResolver->getController($request);
if ($class) {
$this->assertCallableController($result, $class, $output);
@@ -156,12 +156,12 @@ class ControllerResolverTest extends UnitTestCase {
* Provides test data for testGetController().
*/
public function providerTestGetController() {
- return array(
+ return [
// Tests passing a controller via the request.
- array(array('_controller' => 'Drupal\Tests\Core\Controller\MockContainerAware::getResult'), 'Drupal\Tests\Core\Controller\MockContainerAware', 'This is container aware.'),
+ [['_controller' => 'Drupal\Tests\Core\Controller\MockContainerAware::getResult'], 'Drupal\Tests\Core\Controller\MockContainerAware', 'This is container aware.'],
// Tests a request with no controller specified.
- array(array(), FALSE)
- );
+ [[], FALSE]
+ ];
}
/**
@@ -178,16 +178,16 @@ class ControllerResolverTest extends UnitTestCase {
* Provides test data for testGetControllerFromDefinition().
*/
public function providerTestGetControllerFromDefinition() {
- return array(
+ return [
// Tests a method on an object.
- array(array(new MockController(), 'getResult'), 'This is a regular controller.'),
+ [[new MockController(), 'getResult'], 'This is a regular controller.'],
// Tests a function.
- array('phpversion', phpversion()),
+ ['phpversion', phpversion()],
// Tests an object using __invoke().
- array(new MockInvokeController(), 'This used __invoke().'),
+ [new MockInvokeController(), 'This used __invoke().'],
// Tests a class using __invoke().
- array('Drupal\Tests\Core\Controller\MockInvokeController', 'This used __invoke().'),
- );
+ ['Drupal\Tests\Core\Controller\MockInvokeController', 'This used __invoke().'],
+ ];
}
/**
* Tests getControllerFromDefinition() without a callable.
diff --git a/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php b/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
index e2fca4b8fa8..7633f78a133 100644
--- a/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
@@ -55,8 +55,8 @@ class TitleResolverTest extends UnitTestCase {
*/
public function testStaticTitle() {
$request = new Request();
- $route = new Route('/test-route', array('_title' => 'static title'));
- $this->assertEquals(new TranslatableMarkup('static title', array(), array(), $this->translationManager), $this->titleResolver->getTitle($request, $route));
+ $route = new Route('/test-route', ['_title' => 'static title']);
+ $this->assertEquals(new TranslatableMarkup('static title', [], [], $this->translationManager), $this->titleResolver->getTitle($request, $route));
}
/**
@@ -66,8 +66,8 @@ class TitleResolverTest extends UnitTestCase {
*/
public function testStaticTitleWithContext() {
$request = new Request();
- $route = new Route('/test-route', array('_title' => 'static title', '_title_context' => 'context'));
- $this->assertEquals(new TranslatableMarkup('static title', array(), array('context' => 'context'), $this->translationManager), $this->titleResolver->getTitle($request, $route));
+ $route = new Route('/test-route', ['_title' => 'static title', '_title_context' => 'context']);
+ $this->assertEquals(new TranslatableMarkup('static title', [], ['context' => 'context'], $this->translationManager), $this->titleResolver->getTitle($request, $route));
}
/**
@@ -78,20 +78,20 @@ class TitleResolverTest extends UnitTestCase {
* @dataProvider providerTestStaticTitleWithParameter
*/
public function testStaticTitleWithParameter($title, $expected_title) {
- $raw_variables = new ParameterBag(array('test' => 'value', 'test2' => 'value2'));
+ $raw_variables = new ParameterBag(['test' => 'value', 'test2' => 'value2']);
$request = new Request();
$request->attributes->set('_raw_variables', $raw_variables);
- $route = new Route('/test-route', array('_title' => $title));
+ $route = new Route('/test-route', ['_title' => $title]);
$this->assertEquals($expected_title, $this->titleResolver->getTitle($request, $route));
}
public function providerTestStaticTitleWithParameter() {
$translation_manager = $this->getMock('\Drupal\Core\StringTranslation\TranslationInterface');
- return array(
- array('static title @test', new TranslatableMarkup('static title @test', ['@test' => 'value', '%test' => 'value', '@test2' => 'value2', '%test2' => 'value2'], array(), $translation_manager)),
- array('static title %test', new TranslatableMarkup('static title %test', ['@test' => 'value', '%test' => 'value', '@test2' => 'value2', '%test2' => 'value2'], array(), $translation_manager)),
- );
+ return [
+ ['static title @test', new TranslatableMarkup('static title @test', ['@test' => 'value', '%test' => 'value', '@test2' => 'value2', '%test2' => 'value2'], [], $translation_manager)],
+ ['static title %test', new TranslatableMarkup('static title %test', ['@test' => 'value', '%test' => 'value', '@test2' => 'value2', '%test2' => 'value2'], [], $translation_manager)],
+ ];
}
/**
@@ -101,9 +101,9 @@ class TitleResolverTest extends UnitTestCase {
*/
public function testDynamicTitle() {
$request = new Request();
- $route = new Route('/test-route', array('_title' => 'static title', '_title_callback' => 'Drupal\Tests\Core\Controller\TitleCallback::example'));
+ $route = new Route('/test-route', ['_title' => 'static title', '_title_callback' => 'Drupal\Tests\Core\Controller\TitleCallback::example']);
- $callable = array(new TitleCallback(), 'example');
+ $callable = [new TitleCallback(), 'example'];
$this->controllerResolver->expects($this->once())
->method('getControllerFromDefinition')
->with('Drupal\Tests\Core\Controller\TitleCallback::example')
@@ -111,7 +111,7 @@ class TitleResolverTest extends UnitTestCase {
$this->controllerResolver->expects($this->once())
->method('getArguments')
->with($request, $callable)
- ->will($this->returnValue(array('example')));
+ ->will($this->returnValue(['example']));
$this->assertEquals('test example', $this->titleResolver->getTitle($request, $route));
}
diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
index 8f4aa7ae29c..e4558470287 100644
--- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
@@ -21,22 +21,22 @@ class ConnectionTest extends UnitTestCase {
* - Expected result from Connection::tablePrefix().
*/
public function providerPrefixRoundTrip() {
- return array(
- array(
- array('' => 'test_'),
+ return [
+ [
+ ['' => 'test_'],
'test_',
- ),
- array(
- array(
+ ],
+ [
+ [
'fooTable' => 'foo_',
'barTable' => 'bar_',
- ),
- array(
+ ],
+ [
'fooTable' => 'foo_',
'barTable' => 'bar_',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -46,7 +46,7 @@ class ConnectionTest extends UnitTestCase {
*/
public function testPrefixRoundTrip($expected, $prefix_info) {
$mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
- $connection = new StubConnection($mock_pdo, array());
+ $connection = new StubConnection($mock_pdo, []);
// setPrefix() is protected, so we make it accessible with reflection.
$reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\StubConnection');
@@ -54,7 +54,7 @@ class ConnectionTest extends UnitTestCase {
$set_prefix->setAccessible(TRUE);
// Set the prefix data.
- $set_prefix->invokeArgs($connection, array($prefix_info));
+ $set_prefix->invokeArgs($connection, [$prefix_info]);
// Check the round-trip.
foreach ($expected as $table => $prefix) {
$this->assertEquals($prefix, $connection->tablePrefix($table));
@@ -71,21 +71,21 @@ class ConnectionTest extends UnitTestCase {
* - Query to be prefixed.
*/
public function providerTestPrefixTables() {
- return array(
- array(
+ return [
+ [
'SELECT * FROM test_table',
'test_',
'SELECT * FROM {table}',
- ),
- array(
+ ],
+ [
'SELECT * FROM first_table JOIN second_thingie',
- array(
+ [
'table' => 'first_',
'thingie' => 'second_',
- ),
+ ],
'SELECT * FROM {table} JOIN {thingie}',
- ),
- );
+ ],
+ ];
}
/**
@@ -95,7 +95,7 @@ class ConnectionTest extends UnitTestCase {
*/
public function testPrefixTables($expected, $prefix_info, $query) {
$mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
- $connection = new StubConnection($mock_pdo, array('prefix' => $prefix_info));
+ $connection = new StubConnection($mock_pdo, ['prefix' => $prefix_info]);
$this->assertEquals($expected, $connection->prefixTables($query));
}
@@ -108,14 +108,14 @@ class ConnectionTest extends UnitTestCase {
* - String to escape.
*/
public function providerEscapeMethods() {
- return array(
- array('thing', 'thing'),
- array('_item', '_item'),
- array('item_', 'item_'),
- array('_item_', '_item_'),
- array('', '!@#$%^&*()-=+'),
- array('123', '!1@2#3'),
- );
+ return [
+ ['thing', 'thing'],
+ ['_item', '_item'],
+ ['item_', 'item_'],
+ ['_item_', '_item_'],
+ ['', '!@#$%^&*()-=+'],
+ ['123', '!1@2#3'],
+ ];
}
/**
@@ -129,7 +129,7 @@ class ConnectionTest extends UnitTestCase {
*/
public function testEscapeMethods($expected, $name) {
$mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
- $connection = new StubConnection($mock_pdo, array());
+ $connection = new StubConnection($mock_pdo, []);
$this->assertEquals($expected, $connection->escapeDatabase($name));
$this->assertEquals($expected, $connection->escapeTable($name));
$this->assertEquals($expected, $connection->escapeField($name));
@@ -147,23 +147,23 @@ class ConnectionTest extends UnitTestCase {
* - Class name without namespace.
*/
public function providerGetDriverClass() {
- return array(
- array(
+ return [
+ [
'nonexistent_class',
'\\',
'nonexistent_class',
- ),
- array(
+ ],
+ [
'Drupal\Tests\Core\Database\Stub\Select',
NULL,
'Select',
- ),
- array(
+ ],
+ [
'Drupal\\Tests\\Core\\Database\\Stub\\Driver\\Schema',
'Drupal\\Tests\\Core\\Database\\Stub\\Driver',
'Schema',
- ),
- );
+ ],
+ ];
}
/**
@@ -173,7 +173,7 @@ class ConnectionTest extends UnitTestCase {
*/
public function testGetDriverClass($expected, $namespace, $class) {
$mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
- $connection = new StubConnection($mock_pdo, array('namespace' => $namespace));
+ $connection = new StubConnection($mock_pdo, ['namespace' => $namespace]);
// Set the driver using our stub class' public property.
$this->assertEquals($expected, $connection->getDriverClass($class));
}
@@ -188,13 +188,13 @@ class ConnectionTest extends UnitTestCase {
* - Namespace for connection.
*/
public function providerSchema() {
- return array(
- array(
+ return [
+ [
'Drupal\\Tests\\Core\\Database\\Stub\\Driver\\Schema',
'stub',
'Drupal\\Tests\\Core\\Database\\Stub\\Driver',
- ),
- );
+ ],
+ ];
}
/**
@@ -204,7 +204,7 @@ class ConnectionTest extends UnitTestCase {
*/
public function testSchema($expected, $driver, $namespace) {
$mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
- $connection = new StubConnection($mock_pdo, array('namespace' => $namespace));
+ $connection = new StubConnection($mock_pdo, ['namespace' => $namespace]);
$connection->driver = $driver;
$this->assertInstanceOf($expected, $connection->schema());
}
@@ -218,7 +218,7 @@ class ConnectionTest extends UnitTestCase {
$connection = $this->getMock(
'Drupal\Tests\Core\Database\Stub\StubConnection',
NULL,
- array($mock_pdo, array('namespace' => 'Drupal\\Tests\\Core\\Database\\Stub\\Driver'))
+ [$mock_pdo, ['namespace' => 'Drupal\\Tests\\Core\\Database\\Stub\\Driver']]
);
// Generate a schema object in order to verify that we've NULLed it later.
$this->assertInstanceOf(
@@ -238,20 +238,20 @@ class ConnectionTest extends UnitTestCase {
* - Arguments for Connection::makeComment().
*/
public function providerMakeComments() {
- return array(
- array(
+ return [
+ [
'/* */ ',
- array(''),
- ),
- array(
+ [''],
+ ],
+ [
'/* Exploit * / DROP TABLE node. -- */ ',
- array('Exploit * / DROP TABLE node; --'),
- ),
- array(
+ ['Exploit * / DROP TABLE node; --'],
+ ],
+ [
'/* Exploit * / DROP TABLE node. --. another comment */ ',
- array('Exploit * / DROP TABLE node; --', 'another comment'),
- ),
- );
+ ['Exploit * / DROP TABLE node; --', 'another comment'],
+ ],
+ ];
}
/**
@@ -261,7 +261,7 @@ class ConnectionTest extends UnitTestCase {
*/
public function testMakeComments($expected, $comment_array) {
$mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
- $connection = new StubConnection($mock_pdo, array());
+ $connection = new StubConnection($mock_pdo, []);
$this->assertEquals($expected, $connection->makeComment($comment_array));
}
@@ -274,11 +274,11 @@ class ConnectionTest extends UnitTestCase {
* - Comment to filter.
*/
public function providerFilterComments() {
- return array(
- array('', ''),
- array('Exploit * / DROP TABLE node. --', 'Exploit * / DROP TABLE node; --'),
- array('Exploit * / DROP TABLE node. --', 'Exploit */ DROP TABLE node; --'),
- );
+ return [
+ ['', ''],
+ ['Exploit * / DROP TABLE node. --', 'Exploit * / DROP TABLE node; --'],
+ ['Exploit * / DROP TABLE node. --', 'Exploit */ DROP TABLE node; --'],
+ ];
}
/**
@@ -288,7 +288,7 @@ class ConnectionTest extends UnitTestCase {
*/
public function testFilterComments($expected, $comment) {
$mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
- $connection = new StubConnection($mock_pdo, array());
+ $connection = new StubConnection($mock_pdo, []);
// filterComment() is protected, so we make it accessible with reflection.
$reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\StubConnection');
@@ -297,7 +297,7 @@ class ConnectionTest extends UnitTestCase {
$this->assertEquals(
$expected,
- $filter_comment->invokeArgs($connection, array($comment))
+ $filter_comment->invokeArgs($connection, [$comment])
);
}
diff --git a/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php
index 23f2386876f..b55ddbb85fd 100644
--- a/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php
@@ -35,17 +35,17 @@ class PostgresqlConnectionTest extends UnitTestCase {
* value is the value to test.
*/
public function providerEscapeTables() {
- return array(
- array('nocase', 'nocase'),
- array('"camelCase"', 'camelCase'),
- array('"camelCase"', '"camelCase"'),
- array('"camelCase"', 'camel/Case'),
+ return [
+ ['nocase', 'nocase'],
+ ['"camelCase"', 'camelCase'],
+ ['"camelCase"', '"camelCase"'],
+ ['"camelCase"', 'camel/Case'],
// Sometimes, table names are following the pattern database.schema.table.
- array('"camelCase".nocase.nocase', 'camelCase.nocase.nocase'),
- array('nocase."camelCase".nocase', 'nocase.camelCase.nocase'),
- array('nocase.nocase."camelCase"', 'nocase.nocase.camelCase'),
- array('"camelCase"."camelCase"."camelCase"', 'camelCase.camelCase.camelCase'),
- );
+ ['"camelCase".nocase.nocase', 'camelCase.nocase.nocase'],
+ ['nocase."camelCase".nocase', 'nocase.camelCase.nocase'],
+ ['nocase.nocase."camelCase"', 'nocase.nocase.camelCase'],
+ ['"camelCase"."camelCase"."camelCase"', 'camelCase.camelCase.camelCase'],
+ ];
}
/**
@@ -57,12 +57,12 @@ class PostgresqlConnectionTest extends UnitTestCase {
* - String to escape.
*/
public function providerEscapeAlias() {
- return array(
- array('nocase', 'nocase'),
- array('"camelCase"', '"camelCase"'),
- array('"camelCase"', 'camelCase'),
- array('"camelCase"', 'camel.Case'),
- );
+ return [
+ ['nocase', 'nocase'],
+ ['"camelCase"', '"camelCase"'],
+ ['"camelCase"', 'camelCase'],
+ ['"camelCase"', 'camel.Case'],
+ ];
}
/**
@@ -74,16 +74,16 @@ class PostgresqlConnectionTest extends UnitTestCase {
* - String to escape.
*/
public function providerEscapeFields() {
- return array(
- array('title', 'title'),
- array('"isDefaultRevision"', 'isDefaultRevision'),
- array('"isDefaultRevision"', '"isDefaultRevision"'),
- array('entity_test."isDefaultRevision"', 'entity_test.isDefaultRevision'),
- array('entity_test."isDefaultRevision"', '"entity_test"."isDefaultRevision"'),
- array('"entityTest"."isDefaultRevision"', '"entityTest"."isDefaultRevision"'),
- array('"entityTest"."isDefaultRevision"', 'entityTest.isDefaultRevision'),
- array('entity_test."isDefaultRevision"', 'entity_test.is.Default.Revision'),
- );
+ return [
+ ['title', 'title'],
+ ['"isDefaultRevision"', 'isDefaultRevision'],
+ ['"isDefaultRevision"', '"isDefaultRevision"'],
+ ['entity_test."isDefaultRevision"', 'entity_test.isDefaultRevision'],
+ ['entity_test."isDefaultRevision"', '"entity_test"."isDefaultRevision"'],
+ ['"entityTest"."isDefaultRevision"', '"entityTest"."isDefaultRevision"'],
+ ['"entityTest"."isDefaultRevision"', 'entityTest.isDefaultRevision'],
+ ['entity_test."isDefaultRevision"', 'entity_test.is.Default.Revision'],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php b/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php
index 46b1cd75064..f40ebe80ac7 100644
--- a/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php
@@ -36,7 +36,7 @@ class EmptyStatementTest extends UnitTestCase {
function testEmptyFetchAll() {
$result = new StatementEmpty();
- $this->assertEquals($result->fetchAll(), array(), 'Empty array returned from empty result set.');
+ $this->assertEquals($result->fetchAll(), [], 'Empty array returned from empty result set.');
}
}
diff --git a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php b/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php
index 7c934974049..4692dffb871 100644
--- a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php
+++ b/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php
@@ -23,14 +23,14 @@ class StubConnection extends Connection {
/**
* {@inheritdoc}
*/
- public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
+ public function queryRange($query, $from, $count, array $args = [], array $options = []) {
return new StatementEmpty();
}
/**
* {@inheritdoc}
*/
- public function queryTemporary($query, array $args = array(), array $options = array()) {
+ public function queryTemporary($query, array $args = [], array $options = []) {
return '';
}
diff --git a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php
index edf6d714e79..7dd8e193cb5 100644
--- a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php
+++ b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php
@@ -114,33 +114,33 @@ class DateTest extends UnitTestCase {
* Provides some test data for the format interval test.
*/
public function providerTestFormatInterval() {
- $data = array(
+ $data = [
// Checks for basic seconds.
- array(1, 1, '1 sec'),
- array(1, 2, '1 sec'),
- array(2, 1, '2 sec'),
- array(2, 2, '2 sec'),
+ [1, 1, '1 sec'],
+ [1, 2, '1 sec'],
+ [2, 1, '2 sec'],
+ [2, 2, '2 sec'],
// Checks for minutes with seconds.
- array(61, 1, '1 min'),
- array(61, 2, '1 min 1 sec'),
- array(62, 2, '1 min 2 sec'),
- array(121, 1, '2 min'),
- array(121, 2, '2 min 1 sec'),
+ [61, 1, '1 min'],
+ [61, 2, '1 min 1 sec'],
+ [62, 2, '1 min 2 sec'],
+ [121, 1, '2 min'],
+ [121, 2, '2 min 1 sec'],
// Check for hours with minutes and seconds.
- array(3601, 1, '1 hour'),
- array(3601, 2, '1 hour'),
+ [3601, 1, '1 hour'],
+ [3601, 2, '1 hour'],
// Check for higher units.
- array(86401, 1, '1 day'),
- array(604800, 1, '1 week'),
- array(2592000 * 2, 1, '2 months'),
- array(31536000 * 2, 1, '2 years'),
+ [86401, 1, '1 day'],
+ [604800, 1, '1 week'],
+ [2592000 * 2, 1, '2 months'],
+ [31536000 * 2, 1, '2 years'],
// Check for a complicated one with months weeks and days.
- array(2592000 * 2 + 604800 * 3 + 86400 * 4, 3, '2 months 3 weeks 4 days'),
+ [2592000 * 2 + 604800 * 3 + 86400 * 4, 3, '2 months 3 weeks 4 days'],
// Check for the langcode.
- array(61, 1, '1 min', 'xxx-lolspeak'),
+ [61, 1, '1 min', 'xxx-lolspeak'],
// Check with an unspecified granularity.
- array(61, NULL, '1 min 1 sec'),
- );
+ [61, NULL, '1 min 1 sec'],
+ ];
return $data;
}
@@ -150,7 +150,7 @@ class DateTest extends UnitTestCase {
*/
public function testFormatIntervalZeroSecond() {
$result = $this->dateFormatter->formatInterval(0, 1, 'xxx-lolspeak');
- $this->assertEquals(new TranslatableMarkup('0 sec', array(), array('langcode' => 'xxx-lolspeak'), $this->stringTranslation), $result);
+ $this->assertEquals(new TranslatableMarkup('0 sec', [], ['langcode' => 'xxx-lolspeak'], $this->stringTranslation), $result);
}
/**
@@ -181,7 +181,7 @@ class DateTest extends UnitTestCase {
$expected = '1 second';
$request_time = $this->createTimestamp('2013-12-11 10:09:08');
$timestamp = $this->createTimestamp('2013-12-11 10:09:09');
- $options = array();
+ $options = [];
// Mocks the formatDiff function of the dateformatter object.
$this->dateFormatterStub
@@ -218,7 +218,7 @@ class DateTest extends UnitTestCase {
$expected = '1 second';
$timestamp = $this->createTimestamp('2013-12-11 10:09:07');
$request_time = $this->createTimestamp('2013-12-11 10:09:08');
- $options = array();
+ $options = [];
// Mocks the formatDiff function of the dateformatter object.
$this->dateFormatterStub
@@ -253,7 +253,7 @@ class DateTest extends UnitTestCase {
*
* @covers ::formatDiff
*/
- public function testformatDiff($expected, $max_age, $timestamp1, $timestamp2, $options = array()) {
+ public function testformatDiff($expected, $max_age, $timestamp1, $timestamp2, $options = []) {
// Mocks a simple translateString implementation.
$this->stringTranslation->expects($this->any())
->method('translateString')
@@ -281,114 +281,114 @@ class DateTest extends UnitTestCase {
// This is the fixed request time in the test.
$request_time = $this->createTimestamp('2013-12-11 10:09:08');
- $granularity_3 = array('granularity' => 3);
- $granularity_4 = array('granularity' => 4);
+ $granularity_3 = ['granularity' => 3];
+ $granularity_4 = ['granularity' => 4];
- $langcode_en = array('langcode' => 'en');
- $langcode_lolspeak = array('langcode' => 'xxx-lolspeak');
+ $langcode_en = ['langcode' => 'en'];
+ $langcode_lolspeak = ['langcode' => 'xxx-lolspeak'];
- $non_strict = array('strict' => FALSE);
+ $non_strict = ['strict' => FALSE];
- $data = array(
+ $data = [
// Checks for equal timestamps.
- array('0 seconds', 0, $request_time, $request_time),
+ ['0 seconds', 0, $request_time, $request_time],
// Checks for seconds only.
- array('1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time),
- array('1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time),
- array('1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time, $granularity_3 + $langcode_en),
- array('1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time, $granularity_4 + $langcode_lolspeak),
- array('2 seconds', 1, $this->createTimestamp('2013-12-11 10:09:06'), $request_time),
- array('59 seconds', 1, $this->createTimestamp('2013-12-11 10:08:09'), $request_time),
- array('59 seconds', 1, $this->createTimestamp('2013-12-11 10:08:09'), $request_time),
+ ['1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time],
+ ['1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time],
+ ['1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time, $granularity_3 + $langcode_en],
+ ['1 second', 1, $this->createTimestamp('2013-12-11 10:09:07'), $request_time, $granularity_4 + $langcode_lolspeak],
+ ['2 seconds', 1, $this->createTimestamp('2013-12-11 10:09:06'), $request_time],
+ ['59 seconds', 1, $this->createTimestamp('2013-12-11 10:08:09'), $request_time],
+ ['59 seconds', 1, $this->createTimestamp('2013-12-11 10:08:09'), $request_time],
// Checks for minutes and possibly seconds.
- array('1 minute', 60, $this->createTimestamp('2013-12-11 10:08:08'), $request_time),
- array('1 minute', 60, $this->createTimestamp('2013-12-11 10:08:08'), $request_time),
- array('1 minute 1 second', 1, $this->createTimestamp('2013-12-11 10:08:07'), $request_time),
- array('1 minute 59 seconds', 1, $this->createTimestamp('2013-12-11 10:07:09'), $request_time),
- array('2 minutes', 60, $this->createTimestamp('2013-12-11 10:07:08'), $request_time),
- array('2 minutes 1 second', 1, $this->createTimestamp('2013-12-11 10:07:07'), $request_time),
- array('2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-11 10:07:06'), $request_time),
- array('2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-11 10:07:06'), $request_time, $granularity_3),
- array('2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-11 10:07:06'), $request_time, $granularity_4),
- array('30 minutes', 60, $this->createTimestamp('2013-12-11 09:39:08'), $request_time),
- array('59 minutes 59 seconds', 1, $this->createTimestamp('2013-12-11 09:09:09'), $request_time),
- array('59 minutes 59 seconds', 1, $this->createTimestamp('2013-12-11 09:09:09'), $request_time),
+ ['1 minute', 60, $this->createTimestamp('2013-12-11 10:08:08'), $request_time],
+ ['1 minute', 60, $this->createTimestamp('2013-12-11 10:08:08'), $request_time],
+ ['1 minute 1 second', 1, $this->createTimestamp('2013-12-11 10:08:07'), $request_time],
+ ['1 minute 59 seconds', 1, $this->createTimestamp('2013-12-11 10:07:09'), $request_time],
+ ['2 minutes', 60, $this->createTimestamp('2013-12-11 10:07:08'), $request_time],
+ ['2 minutes 1 second', 1, $this->createTimestamp('2013-12-11 10:07:07'), $request_time],
+ ['2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-11 10:07:06'), $request_time],
+ ['2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-11 10:07:06'), $request_time, $granularity_3],
+ ['2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-11 10:07:06'), $request_time, $granularity_4],
+ ['30 minutes', 60, $this->createTimestamp('2013-12-11 09:39:08'), $request_time],
+ ['59 minutes 59 seconds', 1, $this->createTimestamp('2013-12-11 09:09:09'), $request_time],
+ ['59 minutes 59 seconds', 1, $this->createTimestamp('2013-12-11 09:09:09'), $request_time],
// Checks for hours and possibly minutes or seconds.
- array('1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:08'), $request_time),
- array('1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:08'), $request_time),
- array('1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:07'), $request_time),
- array('1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:06'), $request_time),
- array('1 hour 1 minute', 60, $this->createTimestamp('2013-12-11 09:08:08'), $request_time),
- array('1 hour 1 minute 1 second', 1, $this->createTimestamp('2013-12-11 09:08:07'), $request_time, $granularity_3),
- array('1 hour 1 minute 2 seconds', 1, $this->createTimestamp('2013-12-11 09:08:06'), $request_time, $granularity_4),
- array('1 hour 30 minutes', 60, $this->createTimestamp('2013-12-11 08:39:08'), $request_time),
- array('2 hours', 3600, $this->createTimestamp('2013-12-11 08:09:08'), $request_time),
- array('23 hours 59 minutes', 60, $this->createTimestamp('2013-12-10 10:10:08'), $request_time),
+ ['1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:08'), $request_time],
+ ['1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:08'), $request_time],
+ ['1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:07'), $request_time],
+ ['1 hour', 3600, $this->createTimestamp('2013-12-11 09:09:06'), $request_time],
+ ['1 hour 1 minute', 60, $this->createTimestamp('2013-12-11 09:08:08'), $request_time],
+ ['1 hour 1 minute 1 second', 1, $this->createTimestamp('2013-12-11 09:08:07'), $request_time, $granularity_3],
+ ['1 hour 1 minute 2 seconds', 1, $this->createTimestamp('2013-12-11 09:08:06'), $request_time, $granularity_4],
+ ['1 hour 30 minutes', 60, $this->createTimestamp('2013-12-11 08:39:08'), $request_time],
+ ['2 hours', 3600, $this->createTimestamp('2013-12-11 08:09:08'), $request_time],
+ ['23 hours 59 minutes', 60, $this->createTimestamp('2013-12-10 10:10:08'), $request_time],
// Checks for days and possibly hours, minutes or seconds.
- array('1 day', 86400, $this->createTimestamp('2013-12-10 10:09:08'), $request_time),
- array('1 day', 86400, $this->createTimestamp('2013-12-10 10:09:07'), $request_time),
- array('1 day 1 hour', 3600, $this->createTimestamp('2013-12-10 09:09:08'), $request_time),
- array('1 day 1 hour 1 minute', 60, $this->createTimestamp('2013-12-10 09:08:07'), $request_time, $granularity_3 + $langcode_en),
- array('1 day 1 hour 1 minute 1 second', 1, $this->createTimestamp('2013-12-10 09:08:07'), $request_time, $granularity_4 + $langcode_lolspeak),
- array('1 day 2 hours 2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-10 08:07:06'), $request_time, $granularity_4),
- array('2 days', 86400, $this->createTimestamp('2013-12-09 10:09:08'), $request_time),
- array('2 days', 86400, $this->createTimestamp('2013-12-09 10:07:08'), $request_time),
- array('2 days 2 hours', 3600, $this->createTimestamp('2013-12-09 08:09:08'), $request_time),
- array('2 days 2 hours 2 minutes', 60, $this->createTimestamp('2013-12-09 08:07:06'), $request_time, $granularity_3 + $langcode_en),
- array('2 days 2 hours 2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-09 08:07:06'), $request_time, $granularity_4 + $langcode_lolspeak),
+ ['1 day', 86400, $this->createTimestamp('2013-12-10 10:09:08'), $request_time],
+ ['1 day', 86400, $this->createTimestamp('2013-12-10 10:09:07'), $request_time],
+ ['1 day 1 hour', 3600, $this->createTimestamp('2013-12-10 09:09:08'), $request_time],
+ ['1 day 1 hour 1 minute', 60, $this->createTimestamp('2013-12-10 09:08:07'), $request_time, $granularity_3 + $langcode_en],
+ ['1 day 1 hour 1 minute 1 second', 1, $this->createTimestamp('2013-12-10 09:08:07'), $request_time, $granularity_4 + $langcode_lolspeak],
+ ['1 day 2 hours 2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-10 08:07:06'), $request_time, $granularity_4],
+ ['2 days', 86400, $this->createTimestamp('2013-12-09 10:09:08'), $request_time],
+ ['2 days', 86400, $this->createTimestamp('2013-12-09 10:07:08'), $request_time],
+ ['2 days 2 hours', 3600, $this->createTimestamp('2013-12-09 08:09:08'), $request_time],
+ ['2 days 2 hours 2 minutes', 60, $this->createTimestamp('2013-12-09 08:07:06'), $request_time, $granularity_3 + $langcode_en],
+ ['2 days 2 hours 2 minutes 2 seconds', 1, $this->createTimestamp('2013-12-09 08:07:06'), $request_time, $granularity_4 + $langcode_lolspeak],
// Checks for weeks and possibly days, hours, minutes or seconds.
- array('1 week', 7 * 86400, $this->createTimestamp('2013-12-04 10:09:08'), $request_time),
- array('1 week 1 day', 86400, $this->createTimestamp('2013-12-03 10:09:08'), $request_time),
- array('2 weeks', 7 * 86400, $this->createTimestamp('2013-11-27 10:09:08'), $request_time),
- array('2 weeks 2 days', 86400, $this->createTimestamp('2013-11-25 08:07:08'), $request_time),
- array('2 weeks 2 days 2 hours 2 minutes', 60, $this->createTimestamp('2013-11-25 08:07:08'), $request_time, $granularity_4),
- array('4 weeks', 7 * 86400, $this->createTimestamp('2013-11-13 10:09:08'), $request_time),
- array('4 weeks 1 day', 86400, $this->createTimestamp('2013-11-12 10:09:08'), $request_time),
+ ['1 week', 7 * 86400, $this->createTimestamp('2013-12-04 10:09:08'), $request_time],
+ ['1 week 1 day', 86400, $this->createTimestamp('2013-12-03 10:09:08'), $request_time],
+ ['2 weeks', 7 * 86400, $this->createTimestamp('2013-11-27 10:09:08'), $request_time],
+ ['2 weeks 2 days', 86400, $this->createTimestamp('2013-11-25 08:07:08'), $request_time],
+ ['2 weeks 2 days 2 hours 2 minutes', 60, $this->createTimestamp('2013-11-25 08:07:08'), $request_time, $granularity_4],
+ ['4 weeks', 7 * 86400, $this->createTimestamp('2013-11-13 10:09:08'), $request_time],
+ ['4 weeks 1 day', 86400, $this->createTimestamp('2013-11-12 10:09:08'), $request_time],
// Checks for months and possibly days, hours, minutes or seconds.
- array('1 month', 30 * 86400, $this->createTimestamp('2013-11-11 10:09:08'), $request_time),
- array('1 month', 30 * 86400, $this->createTimestamp('2013-11-11 10:09:07'), $request_time),
- array('1 month', 30 * 86400, $this->createTimestamp('2013-11-11 09:09:08'), $request_time),
- array('1 month', 30 * 86400, $this->createTimestamp('2013-11-11 09:08:07'), $request_time, $granularity_3),
- array('1 month', 30 * 86400, $this->createTimestamp('2013-11-11 09:08:07'), $request_time, $granularity_4),
- array('1 month 4 weeks', 7 * 86400, $this->createTimestamp('2013-10-13 10:09:08'), $request_time),
- array('1 month 4 weeks 1 day', 86400, $this->createTimestamp('2013-10-13 10:09:08'), $request_time, $granularity_3),
- array('1 month 4 weeks', 7 * 86400, $this->createTimestamp('2013-10-12 10:09:08'), $request_time),
- array('1 month 4 weeks 2 days', 86400, $this->createTimestamp('2013-10-12 10:09:08'), $request_time, $granularity_3),
- array('2 months', 30 * 86400, $this->createTimestamp('2013-10-11 10:09:08'), $request_time),
- array('2 months', 30 * 86400, $this->createTimestamp('2013-10-10 10:09:08'), $request_time),
- array('2 months', 30 * 86400, $this->createTimestamp('2013-10-09 08:07:06'), $request_time),
- array('2 months', 30 * 86400, $this->createTimestamp('2013-10-09 08:07:06'), $request_time, $granularity_3),
- array('2 months', 30 * 86400, $this->createTimestamp('2013-10-09 08:07:06'), $request_time, $granularity_4),
- array('6 months', 30 * 86400, $this->createTimestamp('2013-06-09 10:09:08'), $request_time),
- array('11 months', 30 * 86400, $this->createTimestamp('2013-01-11 07:09:08'), $request_time),
- array('11 months 4 weeks', 7 * 86400, $this->createTimestamp('2012-12-12 10:09:08'), $request_time),
- array('11 months 4 weeks 2 days', 86400, $this->createTimestamp('2012-12-12 10:09:08'), $request_time, $granularity_3),
+ ['1 month', 30 * 86400, $this->createTimestamp('2013-11-11 10:09:08'), $request_time],
+ ['1 month', 30 * 86400, $this->createTimestamp('2013-11-11 10:09:07'), $request_time],
+ ['1 month', 30 * 86400, $this->createTimestamp('2013-11-11 09:09:08'), $request_time],
+ ['1 month', 30 * 86400, $this->createTimestamp('2013-11-11 09:08:07'), $request_time, $granularity_3],
+ ['1 month', 30 * 86400, $this->createTimestamp('2013-11-11 09:08:07'), $request_time, $granularity_4],
+ ['1 month 4 weeks', 7 * 86400, $this->createTimestamp('2013-10-13 10:09:08'), $request_time],
+ ['1 month 4 weeks 1 day', 86400, $this->createTimestamp('2013-10-13 10:09:08'), $request_time, $granularity_3],
+ ['1 month 4 weeks', 7 * 86400, $this->createTimestamp('2013-10-12 10:09:08'), $request_time],
+ ['1 month 4 weeks 2 days', 86400, $this->createTimestamp('2013-10-12 10:09:08'), $request_time, $granularity_3],
+ ['2 months', 30 * 86400, $this->createTimestamp('2013-10-11 10:09:08'), $request_time],
+ ['2 months', 30 * 86400, $this->createTimestamp('2013-10-10 10:09:08'), $request_time],
+ ['2 months', 30 * 86400, $this->createTimestamp('2013-10-09 08:07:06'), $request_time],
+ ['2 months', 30 * 86400, $this->createTimestamp('2013-10-09 08:07:06'), $request_time, $granularity_3],
+ ['2 months', 30 * 86400, $this->createTimestamp('2013-10-09 08:07:06'), $request_time, $granularity_4],
+ ['6 months', 30 * 86400, $this->createTimestamp('2013-06-09 10:09:08'), $request_time],
+ ['11 months', 30 * 86400, $this->createTimestamp('2013-01-11 07:09:08'), $request_time],
+ ['11 months 4 weeks', 7 * 86400, $this->createTimestamp('2012-12-12 10:09:08'), $request_time],
+ ['11 months 4 weeks 2 days', 86400, $this->createTimestamp('2012-12-12 10:09:08'), $request_time, $granularity_3],
// Checks for years and possibly months, days, hours, minutes or seconds.
- array('1 year', 365 * 86400, $this->createTimestamp('2012-12-11 10:09:08'), $request_time),
- array('1 year', 365 * 86400, $this->createTimestamp('2012-12-11 10:08:08'), $request_time),
- array('1 year', 365 * 86400, $this->createTimestamp('2012-12-10 10:09:08'), $request_time),
- array('2 years', 365 * 86400, $this->createTimestamp('2011-12-11 10:09:08'), $request_time),
- array('2 years', 365 * 86400, $this->createTimestamp('2011-12-11 10:07:08'), $request_time),
- array('2 years', 365 * 86400, $this->createTimestamp('2011-12-09 10:09:08'), $request_time),
- array('2 years 2 months', 30 * 86400, $this->createTimestamp('2011-10-09 08:07:06'), $request_time, $granularity_3),
- array('2 years 2 months', 30 * 86400, $this->createTimestamp('2011-10-09 08:07:06'), $request_time, $granularity_4),
- array('10 years', 365 * 86400, $this->createTimestamp('2003-12-11 10:09:08'), $request_time),
- array('100 years', 365 * 86400, $this->createTimestamp('1913-12-11 10:09:08'), $request_time),
+ ['1 year', 365 * 86400, $this->createTimestamp('2012-12-11 10:09:08'), $request_time],
+ ['1 year', 365 * 86400, $this->createTimestamp('2012-12-11 10:08:08'), $request_time],
+ ['1 year', 365 * 86400, $this->createTimestamp('2012-12-10 10:09:08'), $request_time],
+ ['2 years', 365 * 86400, $this->createTimestamp('2011-12-11 10:09:08'), $request_time],
+ ['2 years', 365 * 86400, $this->createTimestamp('2011-12-11 10:07:08'), $request_time],
+ ['2 years', 365 * 86400, $this->createTimestamp('2011-12-09 10:09:08'), $request_time],
+ ['2 years 2 months', 30 * 86400, $this->createTimestamp('2011-10-09 08:07:06'), $request_time, $granularity_3],
+ ['2 years 2 months', 30 * 86400, $this->createTimestamp('2011-10-09 08:07:06'), $request_time, $granularity_4],
+ ['10 years', 365 * 86400, $this->createTimestamp('2003-12-11 10:09:08'), $request_time],
+ ['100 years', 365 * 86400, $this->createTimestamp('1913-12-11 10:09:08'), $request_time],
// Checks the non-strict option vs. strict (default).
- array('1 second', 1, $this->createTimestamp('2013-12-11 10:09:08'), $this->createTimestamp('2013-12-11 10:09:07'), $non_strict),
- array('0 seconds', 0, $this->createTimestamp('2013-12-11 10:09:08'), $this->createTimestamp('2013-12-11 10:09:07')),
+ ['1 second', 1, $this->createTimestamp('2013-12-11 10:09:08'), $this->createTimestamp('2013-12-11 10:09:07'), $non_strict],
+ ['0 seconds', 0, $this->createTimestamp('2013-12-11 10:09:08'), $this->createTimestamp('2013-12-11 10:09:07')],
// Checks granularity limit.
- array('2 years 3 months 1 week', 7 * 86400, $this->createTimestamp('2011-08-30 11:15:57'), $request_time, $granularity_3),
- );
+ ['2 years 3 months 1 week', 7 * 86400, $this->createTimestamp('2011-08-30 11:15:57'), $request_time, $granularity_3],
+ ];
return $data;
}
diff --git a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
index e77542bc7b5..eff9f772942 100644
--- a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
+++ b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
@@ -73,61 +73,61 @@ class DrupalDateTimeTest extends UnitTestCase {
$negative_1_hour = new \DateInterval('PT1H');
$negative_1_hour->invert = 1;
- return array(
+ return [
// There should be a 19 hour time interval between
// new years in Sydney and new years in LA in year 2000.
- array(
+ [
'input2' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('Australia/Sydney'), $settings),
'input1' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles'), $settings),
'absolute' => FALSE,
'expected' => $positive_19_hours,
- ),
+ ],
// In 1970 Sydney did not observe daylight savings time
// So there is only a 18 hour time interval.
- array(
+ [
'input2' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('Australia/Sydney'), $settings),
'input1' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles'), $settings),
'absolute' => FALSE,
'expected' => $positive_18_hours,
- ),
- array(
+ ],
+ [
'input1' => DrupalDateTime::createFromFormat('U', 3600, new \DateTimeZone('America/Los_Angeles'), $settings),
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
'absolute' => FALSE,
'expected' => $negative_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
'absolute' => FALSE,
'expected' => $negative_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
'input2' => \DateTime::createFromFormat('U', 0),
'absolute' => FALSE,
'expected' => $negative_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
'absolute' => TRUE,
'expected' => $positive_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
'input2' => \DateTime::createFromFormat('U', 0),
'absolute' => TRUE,
'expected' => $positive_1_hour,
- ),
- array(
+ ],
+ [
'input1' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
'absolute' => FALSE,
'expected' => $empty_interval,
- ),
- );
+ ],
+ ];
}
/**
@@ -142,18 +142,18 @@ class DrupalDateTimeTest extends UnitTestCase {
public function providerTestInvalidDateDiff() {
$settings = ['langcode' => 'en'];
$utc_tz = new \DateTimeZone('UTC');
- return array(
- array(
+ return [
+ [
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
'input2' => '1970-01-01 00:00:00',
'absolute' => FALSE,
- ),
- array(
+ ],
+ [
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
'input2' => NULL,
'absolute' => FALSE,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/BackendCompilerPassTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/BackendCompilerPassTest.php
index ee13b934a78..3f8ca09bfe4 100644
--- a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/BackendCompilerPassTest.php
+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/BackendCompilerPassTest.php
@@ -57,18 +57,18 @@ class BackendCompilerPassTest extends UnitTestCase {
* @return array
*/
public function providerTestProcess() {
- $data = array();
+ $data = [];
// Add a container with no set default_backend.
$prefix = __NAMESPACE__ . '\\ServiceClass';
$service = (new Definition($prefix . 'Default'))->addTag('backend_overridable');
$container = $this->getMysqlContainer($service);
- $data[] = array($prefix . 'Default', $container);
+ $data[] = [$prefix . 'Default', $container];
// Set the default_backend so the mysql service should be used.
$container = $this->getMysqlContainer($service);
$container->setParameter('default_backend', 'mysql');
- $data[] = array($prefix . 'Mysql', $container);
+ $data[] = [$prefix . 'Mysql', $container];
// Configure a manual alias for the service, so ensure that it is not
// overridden by the default backend.
@@ -76,16 +76,16 @@ class BackendCompilerPassTest extends UnitTestCase {
$container->setParameter('default_backend', 'mysql');
$container->setDefinition('mariadb.service', new Definition($prefix . 'MariaDb'));
$container->setAlias('service', new Alias('mariadb.service'));
- $data[] = array($prefix . 'MariaDb', $container);
+ $data[] = [$prefix . 'MariaDb', $container];
// Check the database driver is the default.
$container = $this->getSqliteContainer($service);
- $data[] = array($prefix . 'Sqlite', $container);
+ $data[] = [$prefix . 'Sqlite', $container];
// Test the opt out.
$container = $this->getSqliteContainer($service);
$container->setParameter('default_backend', '');
- $data[] = array($prefix . 'Default', $container);
+ $data[] = [$prefix . 'Default', $container];
return $data;
}
diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php
index 6719cbc96fc..9335b7d7c83 100644
--- a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php
+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php
@@ -52,9 +52,9 @@ class TaggedHandlersPassTest extends UnitTestCase {
$container = $this->buildContainer();
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumer')
- ->addTag('service_collector', array(
+ ->addTag('service_collector', [
'required' => TRUE,
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -121,9 +121,9 @@ class TaggedHandlersPassTest extends UnitTestCase {
->addTag('consumer_id');
$container
->register('handler2', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'priority' => 10,
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -145,18 +145,18 @@ class TaggedHandlersPassTest extends UnitTestCase {
$container = $this->buildContainer();
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumer')
- ->addTag('service_collector', array(
+ ->addTag('service_collector', [
'call' => 'addNoPriority',
- ));
+ ]);
$container
->register('handler1', __NAMESPACE__ . '\ValidHandler')
->addTag('consumer_id');
$container
->register('handler2', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'priority' => 10,
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -178,18 +178,18 @@ class TaggedHandlersPassTest extends UnitTestCase {
$container = $this->buildContainer();
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumer')
- ->addTag('service_collector', array(
+ ->addTag('service_collector', [
'call' => 'addWithId',
- ));
+ ]);
$container
->register('handler1', __NAMESPACE__ . '\ValidHandler')
->addTag('consumer_id');
$container
->register('handler2', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'priority' => 10,
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -221,9 +221,9 @@ class TaggedHandlersPassTest extends UnitTestCase {
->addTag('consumer_id');
$container
->register('handler2', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'priority' => 10,
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -243,10 +243,10 @@ class TaggedHandlersPassTest extends UnitTestCase {
$container
->register('handler1', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'extra1' => 'extra1',
'extra2' => 'extra2',
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -269,15 +269,15 @@ class TaggedHandlersPassTest extends UnitTestCase {
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumerWithExtraArguments')
- ->addTag('service_collector', array(
+ ->addTag('service_collector', [
'call' => 'addNoPriority'
- ));
+ ]);
$container
->register('handler1', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'extra' => 'extra',
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -298,15 +298,15 @@ class TaggedHandlersPassTest extends UnitTestCase {
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumerWithExtraArguments')
- ->addTag('service_collector', array(
+ ->addTag('service_collector', [
'call' => 'addWithId'
- ));
+ ]);
$container
->register('handler1', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'extra1' => 'extra1',
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
@@ -330,17 +330,17 @@ class TaggedHandlersPassTest extends UnitTestCase {
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumerWithExtraArguments')
- ->addTag('service_collector', array(
+ ->addTag('service_collector', [
'call' => 'addWithDifferentOrder'
- ));
+ ]);
$container
->register('handler1', __NAMESPACE__ . '\ValidHandler')
- ->addTag('consumer_id', array(
+ ->addTag('consumer_id', [
'priority' => 0,
'extra1' => 'extra1',
'extra3' => 'extra3'
- ));
+ ]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
diff --git a/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php b/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php
index 2a5472559e2..3729d7eaee3 100644
--- a/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php
+++ b/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php
@@ -22,10 +22,10 @@ class DisplayVariantTest extends UnitTestCase {
* @return \Drupal\Core\Display\VariantBase|\PHPUnit_Framework_MockObject_MockObject
* A mocked display variant plugin.
*/
- public function setUpDisplayVariant($configuration = array(), $definition = array()) {
+ public function setUpDisplayVariant($configuration = [], $definition = []) {
return $this->getMockBuilder('Drupal\Core\Display\VariantBase')
- ->setConstructorArgs(array($configuration, 'test', $definition))
- ->setMethods(array('build'))
+ ->setConstructorArgs([$configuration, 'test', $definition])
+ ->setMethods(['build'])
->getMock();
}
@@ -35,7 +35,7 @@ class DisplayVariantTest extends UnitTestCase {
* @covers ::label
*/
public function testLabel() {
- $display_variant = $this->setUpDisplayVariant(array('label' => 'foo'));
+ $display_variant = $this->setUpDisplayVariant(['label' => 'foo']);
$this->assertSame('foo', $display_variant->label());
}
@@ -55,7 +55,7 @@ class DisplayVariantTest extends UnitTestCase {
* @covers ::getWeight
*/
public function testGetWeight() {
- $display_variant = $this->setUpDisplayVariant(array('weight' => 5));
+ $display_variant = $this->setUpDisplayVariant(['weight' => 5]);
$this->assertSame(5, $display_variant->getWeight());
}
@@ -86,34 +86,34 @@ class DisplayVariantTest extends UnitTestCase {
* Provides test data for testGetConfiguration().
*/
public function providerTestGetConfiguration() {
- $data = array();
- $data[] = array(
- array(),
- array(
+ $data = [];
+ $data[] = [
+ [],
+ [
'id' => 'test',
'label' => '',
'uuid' => '',
'weight' => 0,
- ),
- );
- $data[] = array(
- array('label' => 'Test'),
- array(
+ ],
+ ];
+ $data[] = [
+ ['label' => 'Test'],
+ [
'id' => 'test',
'label' => 'Test',
'uuid' => '',
'weight' => 0,
- ),
- );
- $data[] = array(
- array('id' => 'foo'),
- array(
+ ],
+ ];
+ $data[] = [
+ ['id' => 'foo'],
+ [
'id' => 'test',
'label' => '',
'uuid' => '',
'weight' => 0,
- ),
- );
+ ],
+ ];
return $data;
}
@@ -136,7 +136,7 @@ class DisplayVariantTest extends UnitTestCase {
$display_variant = $this->setUpDisplayVariant();
$this->assertSame('', $display_variant->label());
- $form = array();
+ $form = [];
$label = $this->randomMachineName();
$form_state = new FormState();
$form_state->setValue('label', $label);
diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php
index 164da9d954c..8983c8d76de 100644
--- a/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php
+++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php
@@ -19,23 +19,23 @@ class DiscoverServiceProvidersTest extends UnitTestCase {
* @covers ::discoverServiceProviders
*/
public function testDiscoverServiceCustom() {
- new Settings(array(
- 'container_yamls' => array(
+ new Settings([
+ 'container_yamls' => [
__DIR__ . '/fixtures/custom.yml'
- ),
- ));
+ ],
+ ]);
$kernel = new DrupalKernel('prod', new ClassLoader());
$kernel->discoverServiceProviders();
- $expect = array(
- 'app' => array(
+ $expect = [
+ 'app' => [
'core' => 'core/core.services.yml',
- ),
- 'site' => array(
+ ],
+ 'site' => [
__DIR__ . '/fixtures/custom.yml',
- ),
- );
+ ],
+ ];
$this->assertAttributeSame($expect, 'serviceYamls', $kernel);
}
diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
index 81f18181676..7278fd6a983 100644
--- a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
+++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
@@ -206,14 +206,14 @@ EOD;
* Whether to prepend the autoloader or not
*/
public function register($prepend = FALSE) {
- spl_autoload_register(array($this, 'loadClass'), TRUE, $prepend);
+ spl_autoload_register([$this, 'loadClass'], TRUE, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister() {
- spl_autoload_unregister(array($this, 'loadClass'));
+ spl_autoload_unregister([$this, 'loadClass']);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php
index 312e60799f5..55c9beaf754 100644
--- a/core/tests/Drupal/Tests/Core/DrupalTest.php
+++ b/core/tests/Drupal/Tests/Core/DrupalTest.php
@@ -31,7 +31,7 @@ class DrupalTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
- ->setMethods(array('get'))
+ ->setMethods(['get'])
->getMock();
}
@@ -347,8 +347,8 @@ class DrupalTest extends UnitTestCase {
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
*/
public function testUrl() {
- $route_parameters = array('test_parameter' => 'test');
- $options = array('test_option' => 'test');
+ $route_parameters = ['test_parameter' => 'test'];
+ $options = ['test_option' => 'test'];
$generator = $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface');
$generator->expects($this->once())
->method('generateFromRoute')
@@ -376,8 +376,8 @@ class DrupalTest extends UnitTestCase {
* @see \Drupal\Core\Utility\LinkGeneratorInterface::generate()
*/
public function testL() {
- $route_parameters = array('test_parameter' => 'test');
- $options = array('test_option' => 'test');
+ $route_parameters = ['test_parameter' => 'test'];
+ $options = ['test_option' => 'test'];
$generator = $this->getMock('Drupal\Core\Utility\LinkGeneratorInterface');
$url = new Url('test_route', $route_parameters, $options);
$generator->expects($this->once())
diff --git a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
index 104ca8cf19e..064cedf97af 100644
--- a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
+++ b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
@@ -41,14 +41,14 @@ class ParamConversionEnhancerTest extends UnitTestCase {
public function testEnhance() {
$route = new Route('/test/{id}/{literal}/{null}');
- $raw_variables = array(
+ $raw_variables = [
'id' => 1,
'literal' => 'this is a literal',
'null' => NULL,
- );
- $defaults = array(
+ ];
+ $defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
- ) + $raw_variables;
+ ] + $raw_variables;
$expected = $defaults;
$expected['id'] = 'something_better!';
@@ -75,10 +75,10 @@ class ParamConversionEnhancerTest extends UnitTestCase {
*/
public function testCopyRawVariables() {
$route = new Route('/test/{id}');
- $defaults = array(
+ $defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
'id' => '1',
- );
+ ];
// Set one default to mirror another by reference.
$defaults['bar'] = &$defaults['id'];
$this->paramConverterManager->expects($this->any())
@@ -89,7 +89,7 @@ class ParamConversionEnhancerTest extends UnitTestCase {
$defaults['bar'] = '2';
return $defaults;
}));
- $expected = new ParameterBag(array('id' => 1));
+ $expected = new ParameterBag(['id' => 1]);
$result = $this->paramConversionEnhancer->enhance($defaults, new Request());
$this->assertEquals($result['_raw_variables'], $expected);
}
diff --git a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
index bb4668306b4..f7a98517ceb 100644
--- a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
@@ -38,19 +38,19 @@ class BaseFieldDefinitionTest extends UnitTestCase {
$field_type_manager = $this->getMock('Drupal\Core\Field\FieldTypePluginManagerInterface');
$this->fieldType = $this->randomMachineName();
- $this->fieldTypeDefinition = array(
+ $this->fieldTypeDefinition = [
'id' => $this->fieldType,
- 'storage_settings' => array(
+ 'storage_settings' => [
'some_setting' => 'value 1'
- ),
- 'field_settings' => array(
+ ],
+ 'field_settings' => [
'some_instance_setting' => 'value 2',
- ),
- );
+ ],
+ ];
$field_type_manager->expects($this->any())
->method('getDefinitions')
- ->will($this->returnValue(array($this->fieldType => $this->fieldTypeDefinition)));
+ ->will($this->returnValue([$this->fieldType => $this->fieldTypeDefinition]));
$field_type_manager->expects($this->any())
->method('getDefinition')
->with($this->fieldType)
@@ -129,7 +129,7 @@ class BaseFieldDefinitionTest extends UnitTestCase {
$definition->setSetting($setting, $value);
$this->assertEquals($value, $definition->getSetting($setting));
$default_settings = $this->fieldTypeDefinition['storage_settings'] + $this->fieldTypeDefinition['field_settings'];
- $this->assertEquals(array($setting => $value) + $default_settings, $definition->getSettings());
+ $this->assertEquals([$setting => $value] + $default_settings, $definition->getSettings());
}
/**
@@ -156,10 +156,10 @@ class BaseFieldDefinitionTest extends UnitTestCase {
*/
public function testFieldDefaultValue() {
$definition = BaseFieldDefinition::create($this->fieldType);
- $default_value = array(
+ $default_value = [
'value' => $this->randomMachineName(),
- );
- $expected_default_value = array($default_value);
+ ];
+ $expected_default_value = [$default_value];
$definition->setDefaultValue($default_value);
$entity = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
->disableOriginalConstructor()
@@ -186,8 +186,8 @@ class BaseFieldDefinitionTest extends UnitTestCase {
$this->assertEquals($expected_default_value, $definition->getDefaultValue($entity));
// Set default value with an empty array.
- $definition->setDefaultValue(array());
- $this->assertEquals(array(), $definition->getDefaultValue($entity));
+ $definition->setDefaultValue([]);
+ $this->assertEquals([], $definition->getDefaultValue($entity));
// Set default value with NULL.
$definition->setDefaultValue(NULL);
diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
index e8134ef900f..b765af8a699 100644
--- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
@@ -107,21 +107,21 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
*/
protected function setUp() {
$this->id = 1;
- $values = array(
+ $values = [
'id' => $this->id,
'uuid' => '3bb9ee60-bea5-4622-b89b-a63319d10b3a',
- 'defaultLangcode' => array(LanguageInterface::LANGCODE_DEFAULT => 'en'),
- );
+ 'defaultLangcode' => [LanguageInterface::LANGCODE_DEFAULT => 'en'],
+ ];
$this->entityTypeId = $this->randomMachineName();
$this->bundle = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getKeys')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'id' => 'id',
'uuid' => 'uuid',
- )));
+ ]));
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
$this->entityManager->expects($this->any())
@@ -137,12 +137,12 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
->with('entity')
->will($this->returnValue(['class' => '\Drupal\Core\Entity\Plugin\DataType\EntityAdapter']));
- $english = new Language(array('id' => 'en'));
- $not_specified = new Language(array('id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'locked' => TRUE));
+ $english = new Language(['id' => 'en']);
+ $not_specified = new Language(['id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'locked' => TRUE]);
$this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager->expects($this->any())
->method('getLanguages')
- ->will($this->returnValue(array('en' => $english, LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified)));
+ ->will($this->returnValue(['en' => $english, LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified]));
$this->languageManager->expects($this->any())
->method('getLanguage')
->with('en')
@@ -157,10 +157,10 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
->getMock();
$this->fieldTypePluginManager->expects($this->any())
->method('getDefaultStorageSettings')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->fieldTypePluginManager->expects($this->any())
->method('getDefaultFieldSettings')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->fieldTypePluginManager->expects($this->any())
->method('createFieldItemList')
->will($this->returnValue($this->getMock('Drupal\Core\Field\FieldItemListInterface')));
@@ -173,19 +173,19 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
$container->set('plugin.manager.field.field_type', $this->fieldTypePluginManager);
\Drupal::setContainer($container);
- $this->fieldDefinitions = array(
+ $this->fieldDefinitions = [
'id' => BaseFieldDefinition::create('integer'),
'revision_id' => BaseFieldDefinition::create('integer'),
- );
+ ];
$this->entityManager->expects($this->any())
->method('getFieldDefinitions')
->with($this->entityTypeId, $this->bundle)
->will($this->returnValue($this->fieldDefinitions));
- $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', array($values, $this->entityTypeId, $this->bundle), '', TRUE, TRUE, TRUE, ['isNew']);
- $values['defaultLangcode'] = array(LanguageInterface::LANGCODE_DEFAULT => LanguageInterface::LANGCODE_NOT_SPECIFIED);
- $this->entityUnd = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', array($values, $this->entityTypeId, $this->bundle));
+ $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', [$values, $this->entityTypeId, $this->bundle], '', TRUE, TRUE, TRUE, ['isNew']);
+ $values['defaultLangcode'] = [LanguageInterface::LANGCODE_DEFAULT => LanguageInterface::LANGCODE_NOT_SPECIFIED];
+ $this->entityUnd = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', [$values, $this->entityTypeId, $this->bundle]);
}
/**
@@ -285,11 +285,11 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
$this->entityManager->expects($this->any())
->method('getBundleInfo')
->with($this->entityTypeId)
- ->will($this->returnValue(array(
- $this->bundle => array(
+ ->will($this->returnValue([
+ $this->bundle => [
'translatable' => TRUE,
- ),
- )));
+ ],
+ ]));
$this->languageManager->expects($this->any())
->method('isMultilingual')
->will($this->returnValue(TRUE));
@@ -458,7 +458,7 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
->will($this->returnValue($callback_label));
$this->entityType->expects($this->once())
->method('getLabelCallback')
- ->will($this->returnValue(array($callback_container, __FUNCTION__)));
+ ->will($this->returnValue([$callback_container, __FUNCTION__]));
$this->assertSame($callback_label, $this->entity->label());
}
@@ -491,7 +491,7 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
// Mock ContentEntityBase.
$mock_base = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
->disableOriginalConstructor()
- ->setMethods(array('getTranslatedField'))
+ ->setMethods(['getTranslatedField'])
->getMockForAbstractClass();
// Set up expectations for getTranslatedField() method. In get(),
@@ -553,14 +553,14 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
// Mock ContentEntityBase.
$mock_base = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
->disableOriginalConstructor()
- ->setMethods(array('getFieldDefinitions', 'get'))
+ ->setMethods(['getFieldDefinitions', 'get'])
->getMockForAbstractClass();
// Mock field definition objects for each element of $field_definitions.
- $mocked_field_definitions = array();
+ $mocked_field_definitions = [];
foreach ($field_definitions as $name) {
$mock_definition = $this->getMockBuilder('Drupal\Core\Field\FieldDefinitionInterface')
- ->setMethods(array('isComputed'))
+ ->setMethods(['isComputed'])
->getMockForAbstractClass();
// Set expectations for isComputed(). isComputed() gets called whenever
// $include_computed is FALSE, but not otherwise. It returns the value of
diff --git a/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php b/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php
index 2794603c305..1b6525a93b5 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php
@@ -23,7 +23,7 @@ class EntityRouteEnhancerTest extends UnitTestCase {
// Set a controller to ensure it is not overridden.
$request = new Request();
- $defaults = array();
+ $defaults = [];
$defaults['_controller'] = 'Drupal\Tests\Core\Controller\TestController::content';
$defaults['_entity_form'] = 'entity_test.default';
$new_defaults = $route_enhancer->enhance($defaults, $request);
@@ -31,13 +31,13 @@ class EntityRouteEnhancerTest extends UnitTestCase {
$this->assertEquals($defaults['_controller'], $new_defaults['_controller'], '_controller did not get overridden.');
// Set _entity_form and ensure that the form is set.
- $defaults = array();
+ $defaults = [];
$defaults['_entity_form'] = 'entity_test.default';
$new_defaults = $route_enhancer->enhance($defaults, $request);
$this->assertEquals('controller.entity_form:getContentResult', $new_defaults['_controller']);
// Set _entity_list and ensure that the entity list controller is set.
- $defaults = array();
+ $defaults = [];
$defaults['_entity_list'] = 'entity_test.default';
$new_defaults = $route_enhancer->enhance($defaults, $request);
$this->assertEquals('\Drupal\Core\Entity\Controller\EntityListController::listing', $new_defaults['_controller'], 'The entity list controller was not set.');
@@ -45,7 +45,7 @@ class EntityRouteEnhancerTest extends UnitTestCase {
$this->assertFalse(isset($new_defaults['_entity_list']));
// Set _entity_view and ensure that the entity view controller is set.
- $defaults = array();
+ $defaults = [];
$defaults['_entity_view'] = 'entity_test.full';
$defaults['entity_test'] = 'Mock entity';
$defaults = $route_enhancer->enhance($defaults, $request);
@@ -56,11 +56,11 @@ class EntityRouteEnhancerTest extends UnitTestCase {
// Set _entity_view and ensure that the entity view controller is set using
// a converter.
- $defaults = array();
+ $defaults = [];
$defaults['_entity_view'] = 'entity_test.full';
$defaults['foo'] = 'Mock entity';
// Add a converter.
- $options['parameters']['foo'] = array('type' => 'entity:entity_test');
+ $options['parameters']['foo'] = ['type' => 'entity:entity_test'];
// Set the route.
$route = $this->getMockBuilder('Symfony\Component\Routing\Route')
->disableOriginalConstructor()
@@ -78,7 +78,7 @@ class EntityRouteEnhancerTest extends UnitTestCase {
$this->assertFalse(isset($defaults['_entity_view']));
// Set _entity_view without a view mode.
- $defaults = array();
+ $defaults = [];
$defaults['_entity_view'] = 'entity_test';
$defaults['entity_test'] = 'Mock entity';
$defaults = $route_enhancer->enhance($defaults, $request);
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
index 5430fee6270..2c3d132cf3c 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
@@ -47,18 +47,18 @@ class EntityCreateAccessCheckTest extends UnitTestCase {
$no_access = FALSE;
$access = TRUE;
- return array(
- array('', 'entity_test', $no_access, $no_access),
- array('', 'entity_test', $access, $access),
- array('test_entity', 'entity_test:test_entity', $access, $access),
- array('test_entity', 'entity_test:test_entity', $no_access, $no_access),
- array('test_entity', 'entity_test:{bundle_argument}', $access, $access),
- array('test_entity', 'entity_test:{bundle_argument}', $no_access, $no_access),
- array('', 'entity_test:{bundle_argument}', $no_access, $no_access, FALSE),
+ return [
+ ['', 'entity_test', $no_access, $no_access],
+ ['', 'entity_test', $access, $access],
+ ['test_entity', 'entity_test:test_entity', $access, $access],
+ ['test_entity', 'entity_test:test_entity', $no_access, $no_access],
+ ['test_entity', 'entity_test:{bundle_argument}', $access, $access],
+ ['test_entity', 'entity_test:{bundle_argument}', $no_access, $no_access],
+ ['', 'entity_test:{bundle_argument}', $no_access, $no_access, FALSE],
// When the bundle is not provided, access should be denied even if the
// access control handler would allow access.
- array('', 'entity_test:{bundle_argument}', $access, $no_access, FALSE),
- );
+ ['', 'entity_test:{bundle_argument}', $access, $no_access, FALSE],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
index 15fd2345920..4bed37da592 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
@@ -52,7 +52,7 @@ class EntityFormTest extends UnitTestCase {
public function testFormId($expected, $definition) {
$this->entityType->set('entity_keys', ['bundle' => $definition['bundle']]);
- $entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', array(array(), $definition['entity_type']), '', TRUE, TRUE, TRUE, array('getEntityType', 'bundle'));
+ $entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', [[], $definition['entity_type']], '', TRUE, TRUE, TRUE, ['getEntityType', 'bundle']);
$entity->expects($this->any())
->method('getEntityType')
@@ -71,33 +71,33 @@ class EntityFormTest extends UnitTestCase {
* Provides test data for testFormId().
*/
public function providerTestFormIds() {
- return array(
- array('node_article_form', array(
+ return [
+ ['node_article_form', [
'entity_type' => 'node',
'bundle' => 'article',
'operation' => 'default',
- )),
- array('node_article_delete_form', array(
+ ]],
+ ['node_article_delete_form', [
'entity_type' => 'node',
'bundle' => 'article',
'operation' => 'delete',
- )),
- array('user_user_form', array(
+ ]],
+ ['user_user_form', [
'entity_type' => 'user',
'bundle' => 'user',
'operation' => 'default',
- )),
- array('user_form', array(
+ ]],
+ ['user_form', [
'entity_type' => 'user',
'bundle' => '',
'operation' => 'default',
- )),
- array('user_delete_form', array(
+ ]],
+ ['user_delete_form', [
'entity_type' => 'user',
'bundle' => '',
'operation' => 'delete',
- )),
- );
+ ]],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
index f5c12649b42..44e771ceaa5 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
@@ -90,14 +90,14 @@ class EntityListBuilderTest extends UnitTestCase {
*/
public function testGetOperations() {
$operation_name = $this->randomMachineName();
- $operations = array(
- $operation_name => array(
+ $operations = [
+ $operation_name => [
'title' => $this->randomMachineName(),
- ),
- );
+ ],
+ ];
$this->moduleHandler->expects($this->once())
->method('invokeAll')
- ->with('entity_operation', array($this->role))
+ ->with('entity_operation', [$this->role])
->will($this->returnValue($operations));
$this->moduleHandler->expects($this->once())
->method('alter')
@@ -116,7 +116,7 @@ class EntityListBuilderTest extends UnitTestCase {
->getMock();
$url->expects($this->any())
->method('toArray')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->role->expects($this->any())
->method('urlInfo')
->will($this->returnValue($url));
@@ -141,7 +141,7 @@ class EntityListBuilderTest extends UnitTestCase {
class TestEntityListBuilder extends EntityTestListBuilder {
public function buildOperations(EntityInterface $entity) {
- return array();
+ return [];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityRepositoryTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityRepositoryTest.php
index 83692483ead..688dd75b9b5 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityRepositoryTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityRepositoryTest.php
@@ -63,7 +63,7 @@ class EntityRepositoryTest extends UnitTestCase {
$this->languageManager->getFallbackCandidates(Argument::type('array'))
->will(function ($args) {
$context = $args[0];
- $candidates = array();
+ $candidates = [];
if (!empty($context['langcode'])) {
$candidates[$context['langcode']] = $context['langcode'];
}
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php
index 6e164708b94..d2e5eae318a 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php
@@ -74,9 +74,9 @@ class EntityResolverManagerTest extends UnitTestCase {
* @dataProvider providerTestSetRouteOptionsWithStandardRoute
*/
public function testSetRouteOptionsWithStandardRoute($controller) {
- $route = new Route('/example', array(
+ $route = new Route('/example', [
'_controller' => $controller,
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
@@ -88,10 +88,10 @@ class EntityResolverManagerTest extends UnitTestCase {
* Data provider for testSetRouteOptionsWithStandardRoute.
*/
public function providerTestSetRouteOptionsWithStandardRoute() {
- return array(
- array('Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerMethod'),
- array('Drupal\Tests\Core\Entity\test_function_controller'),
- );
+ return [
+ ['Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerMethod'],
+ ['Drupal\Tests\Core\Entity\test_function_controller'],
+ ];
}
/**
@@ -103,10 +103,10 @@ class EntityResolverManagerTest extends UnitTestCase {
* @dataProvider providerTestSetRouteOptionsWithStandardRouteWithArgument
*/
public function testSetRouteOptionsWithStandardRouteWithArgument($controller) {
- $route = new Route('/example/{argument}', array(
+ $route = new Route('/example/{argument}', [
'_controller' => $controller,
'argument' => 'test',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
@@ -118,10 +118,10 @@ class EntityResolverManagerTest extends UnitTestCase {
* Data provider for testSetRouteOptionsWithStandardRouteWithArgument.
*/
public function providerTestSetRouteOptionsWithStandardRouteWithArgument() {
- return array(
- array('Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerMethodWithArgument'),
- array('Drupal\Tests\Core\Entity\test_function_controller_with_argument'),
- );
+ return [
+ ['Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerMethodWithArgument'],
+ ['Drupal\Tests\Core\Entity\test_function_controller_with_argument'],
+ ];
}
/**
@@ -133,10 +133,10 @@ class EntityResolverManagerTest extends UnitTestCase {
* @dataProvider providerTestSetRouteOptionsWithContentController
*/
public function testSetRouteOptionsWithContentController($controller) {
- $route = new Route('/example/{argument}', array(
+ $route = new Route('/example/{argument}', [
'_controller' => $controller,
'argument' => 'test',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
@@ -148,10 +148,10 @@ class EntityResolverManagerTest extends UnitTestCase {
* Data provider for testSetRouteOptionsWithContentController.
*/
public function providerTestSetRouteOptionsWithContentController() {
- return array(
- array('Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerMethodWithArgument'),
- array('Drupal\Tests\Core\Entity\test_function_controller_with_argument'),
- );
+ return [
+ ['Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerMethodWithArgument'],
+ ['Drupal\Tests\Core\Entity\test_function_controller_with_argument'],
+ ];
}
/**
@@ -167,9 +167,9 @@ class EntityResolverManagerTest extends UnitTestCase {
public function testSetRouteOptionsWithEntityTypeNoUpcasting($controller) {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_controller' => $controller,
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
@@ -181,10 +181,10 @@ class EntityResolverManagerTest extends UnitTestCase {
* Data provider for testSetRouteOptionsWithEntityTypeNoUpcasting.
*/
public function providerTestSetRouteOptionsWithEntityTypeNoUpcasting() {
- return array(
- array('Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerWithEntityNoUpcasting'),
- array('Drupal\Tests\Core\Entity\test_function_controller_no_upcasting'),
- );
+ return [
+ ['Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerWithEntityNoUpcasting'],
+ ['Drupal\Tests\Core\Entity\test_function_controller_no_upcasting'],
+ ];
}
/**
@@ -200,25 +200,25 @@ class EntityResolverManagerTest extends UnitTestCase {
public function testSetRouteOptionsWithEntityTypeUpcasting($controller) {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_controller' => $controller,
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$parameters = $route->getOption('parameters');
- $this->assertEquals(array('entity_test' => array('type' => 'entity:entity_test')), $parameters);
+ $this->assertEquals(['entity_test' => ['type' => 'entity:entity_test']], $parameters);
}
/**
* Data provider for testSetRouteOptionsWithEntityTypeUpcasting.
*/
public function providerTestSetRouteOptionsWithEntityTypeUpcasting() {
- return array(
- array('Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerWithEntityUpcasting'),
- array('Drupal\Tests\Core\Entity\test_function_controller_entity_upcasting'),
- );
+ return [
+ ['Drupal\Tests\Core\Entity\BasicControllerClass::exampleControllerWithEntityUpcasting'],
+ ['Drupal\Tests\Core\Entity\test_function_controller_entity_upcasting'],
+ ];
}
/**
@@ -232,15 +232,15 @@ class EntityResolverManagerTest extends UnitTestCase {
public function testSetRouteOptionsWithEntityFormUpcasting() {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_form' => 'Drupal\Tests\Core\Entity\BasicForm',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$parameters = $route->getOption('parameters');
- $this->assertEquals(array('entity_test' => array('type' => 'entity:entity_test')), $parameters);
+ $this->assertEquals(['entity_test' => ['type' => 'entity:entity_test']], $parameters);
}
/**
@@ -254,15 +254,15 @@ class EntityResolverManagerTest extends UnitTestCase {
public function testSetRouteOptionsWithEntityUpcastingNoCreate() {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_form' => 'Drupal\Tests\Core\Entity\BasicFormNoContainerInjectionInterface',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$parameters = $route->getOption('parameters');
- $this->assertEquals(array('entity_test' => array('type' => 'entity:entity_test')), $parameters);
+ $this->assertEquals(['entity_test' => ['type' => 'entity:entity_test']], $parameters);
}
/**
@@ -276,9 +276,9 @@ class EntityResolverManagerTest extends UnitTestCase {
public function testSetRouteOptionsWithEntityFormNoUpcasting() {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_form' => 'Drupal\Tests\Core\Entity\BasicFormNoUpcasting',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
@@ -298,24 +298,24 @@ class EntityResolverManagerTest extends UnitTestCase {
public function testSetRouteOptionsWithEntityViewRouteAndManualParameters() {
$this->setupEntityTypes();
$route = new Route('/example/{foo}',
- array(
+ [
'_entity_view' => 'entity_test.view',
- ),
- array(),
- array(
- 'parameters' => array(
- 'foo' => array(
+ ],
+ [],
+ [
+ 'parameters' => [
+ 'foo' => [
'type' => 'entity:entity_test',
- ),
- ),
- )
+ ],
+ ],
+ ]
);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$parameters = $route->getOption('parameters');
- $this->assertEquals(array('foo' => array('type' => 'entity:entity_test')), $parameters);
+ $this->assertEquals(['foo' => ['type' => 'entity:entity_test']], $parameters);
}
/**
@@ -329,15 +329,15 @@ class EntityResolverManagerTest extends UnitTestCase {
*/
public function testSetRouteOptionsWithEntityViewRoute() {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_entity_view' => 'entity_test.view',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$parameters = $route->getOption('parameters');
- $this->assertEquals(array('entity_test' => array('type' => 'entity:entity_test')), $parameters);
+ $this->assertEquals(['entity_test' => ['type' => 'entity:entity_test']], $parameters);
}
/**
@@ -351,9 +351,9 @@ class EntityResolverManagerTest extends UnitTestCase {
*/
public function testSetRouteOptionsWithEntityListRoute() {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_entity_list' => 'entity_test',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
@@ -373,15 +373,15 @@ class EntityResolverManagerTest extends UnitTestCase {
*/
public function testSetRouteOptionsWithEntityFormRoute() {
$this->setupEntityTypes();
- $route = new Route('/example/{entity_test}', array(
+ $route = new Route('/example/{entity_test}', [
'_entity_form' => 'entity_test.edit',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
$this->assertEquals($defaults, $route->getDefaults());
$parameters = $route->getOption('parameters');
- $this->assertEquals(array('entity_test' => array('type' => 'entity:entity_test')), $parameters);
+ $this->assertEquals(['entity_test' => ['type' => 'entity:entity_test']], $parameters);
}
/**
@@ -427,9 +427,9 @@ class EntityResolverManagerTest extends UnitTestCase {
*/
public function testSetRouteOptionsWithEntityAddFormRoute() {
$this->setupEntityTypes();
- $route = new Route('/example/add', array(
+ $route = new Route('/example/add', [
'_entity_form' => 'entity_test.add',
- ));
+ ]);
$defaults = $route->getDefaults();
$this->entityResolverManager->setRouteOptions($route);
@@ -447,9 +447,9 @@ class EntityResolverManagerTest extends UnitTestCase {
->will($this->returnValue('Drupal\Tests\Core\Entity\SimpleTestEntity'));
$this->entityManager->expects($this->any())
->method('getDefinitions')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'entity_test' => $definition,
- )));
+ ]));
$this->entityManager->expects($this->any())
->method('getDefinition')
->will($this->returnCallback(function ($entity_type) use ($definition) {
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
index 06cf5e11dc1..6668f1ba55c 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
@@ -22,9 +22,9 @@ class EntityTypeTest extends UnitTestCase {
* @return \Drupal\Core\Entity\EntityTypeInterface
*/
protected function setUpEntityType($definition) {
- $definition += array(
+ $definition += [
'id' => 'example_entity_type',
- );
+ ];
return new EntityType($definition);
}
@@ -57,7 +57,7 @@ class EntityTypeTest extends UnitTestCase {
* @dataProvider providerTestGetKeys
*/
public function testGetKeys($entity_keys, $expected) {
- $entity_type = $this->setUpEntityType(array('entity_keys' => $entity_keys));
+ $entity_type = $this->setUpEntityType(['entity_keys' => $entity_keys]);
$this->assertSame($expected + ['default_langcode' => 'default_langcode'], $entity_type->getKeys());
}
@@ -67,7 +67,7 @@ class EntityTypeTest extends UnitTestCase {
* @dataProvider providerTestGetKeys
*/
public function testGetKey($entity_keys, $expected) {
- $entity_type = $this->setUpEntityType(array('entity_keys' => $entity_keys));
+ $entity_type = $this->setUpEntityType(['entity_keys' => $entity_keys]);
$this->assertSame($expected['bundle'], $entity_type->getKey('bundle'));
$this->assertSame(FALSE, $entity_type->getKey('bananas'));
}
@@ -78,7 +78,7 @@ class EntityTypeTest extends UnitTestCase {
* @dataProvider providerTestGetKeys
*/
public function testHasKey($entity_keys, $expected) {
- $entity_type = $this->setUpEntityType(array('entity_keys' => $entity_keys));
+ $entity_type = $this->setUpEntityType(['entity_keys' => $entity_keys]);
$this->assertSame(!empty($expected['bundle']), $entity_type->hasKey('bundle'));
$this->assertSame(!empty($expected['id']), $entity_type->hasKey('id'));
$this->assertSame(FALSE, $entity_type->hasKey('bananas'));
@@ -116,22 +116,22 @@ class EntityTypeTest extends UnitTestCase {
* Provides test data.
*/
public function providerTestGetKeys() {
- return array(
- array(array(), array('revision' => '', 'bundle' => '', 'langcode' => '')),
- array(array('id' => 'id'), array('id' => 'id', 'revision' => '', 'bundle' => '', 'langcode' => '')),
- array(array('bundle' => 'bundle'), array('bundle' => 'bundle', 'revision' => '', 'langcode' => '')),
- );
+ return [
+ [[], ['revision' => '', 'bundle' => '', 'langcode' => '']],
+ [['id' => 'id'], ['id' => 'id', 'revision' => '', 'bundle' => '', 'langcode' => '']],
+ [['bundle' => 'bundle'], ['bundle' => 'bundle', 'revision' => '', 'langcode' => '']],
+ ];
}
/**
* Tests the isRevisionable() method.
*/
public function testIsRevisionable() {
- $entity_type = $this->setUpEntityType(array('entity_keys' => array('id' => 'id')));
+ $entity_type = $this->setUpEntityType(['entity_keys' => ['id' => 'id']]);
$this->assertFalse($entity_type->isRevisionable());
- $entity_type = $this->setUpEntityType(array('entity_keys' => array('id' => 'id', 'revision' => FALSE)));
+ $entity_type = $this->setUpEntityType(['entity_keys' => ['id' => 'id', 'revision' => FALSE]]);
$this->assertFalse($entity_type->isRevisionable());
- $entity_type = $this->setUpEntityType(array('entity_keys' => array('id' => 'id', 'revision' => TRUE)));
+ $entity_type = $this->setUpEntityType(['entity_keys' => ['id' => 'id', 'revision' => TRUE]]);
$this->assertTrue($entity_type->isRevisionable());
}
@@ -140,14 +140,14 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testGetHandler() {
$controller = $this->getTestHandlerClass();
- $entity_type = $this->setUpEntityType(array(
- 'handlers' => array(
+ $entity_type = $this->setUpEntityType([
+ 'handlers' => [
'storage' => $controller,
- 'form' => array(
+ 'form' => [
'default' => $controller,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->assertSame($controller, $entity_type->getHandlerClass('storage'));
$this->assertSame($controller, $entity_type->getHandlerClass('form', 'default'));
}
@@ -157,11 +157,11 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testGetStorageClass() {
$controller = $this->getTestHandlerClass();
- $entity_type = $this->setUpEntityType(array(
- 'handlers' => array(
+ $entity_type = $this->setUpEntityType([
+ 'handlers' => [
'storage' => $controller,
- ),
- ));
+ ],
+ ]);
$this->assertSame($controller, $entity_type->getStorageClass());
}
@@ -170,7 +170,7 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testSetStorageClass() {
$controller = $this->getTestHandlerClass();
- $entity_type = $this->setUpEntityType(array());
+ $entity_type = $this->setUpEntityType([]);
$this->assertSame($entity_type, $entity_type->setStorageClass($controller));
}
@@ -179,11 +179,11 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testGetListBuilderClass() {
$controller = $this->getTestHandlerClass();
- $entity_type = $this->setUpEntityType(array(
- 'handlers' => array(
+ $entity_type = $this->setUpEntityType([
+ 'handlers' => [
'list_builder' => $controller,
- ),
- ));
+ ],
+ ]);
$this->assertSame($controller, $entity_type->getListBuilderClass());
}
@@ -192,11 +192,11 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testGetAccessControlClass() {
$controller = $this->getTestHandlerClass();
- $entity_type = $this->setUpEntityType(array(
- 'handlers' => array(
+ $entity_type = $this->setUpEntityType([
+ 'handlers' => [
'access' => $controller,
- ),
- ));
+ ],
+ ]);
$this->assertSame($controller, $entity_type->getAccessControlClass());
}
@@ -206,13 +206,13 @@ class EntityTypeTest extends UnitTestCase {
public function testGetFormClass() {
$controller = $this->getTestHandlerClass();
$operation = 'default';
- $entity_type = $this->setUpEntityType(array(
- 'handlers' => array(
- 'form' => array(
+ $entity_type = $this->setUpEntityType([
+ 'handlers' => [
+ 'form' => [
$operation => $controller,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
$this->assertSame($controller, $entity_type->getFormClass($operation));
}
@@ -222,16 +222,16 @@ class EntityTypeTest extends UnitTestCase {
public function testHasFormClasses() {
$controller = $this->getTestHandlerClass();
$operation = 'default';
- $entity_type1 = $this->setUpEntityType(array(
- 'handlers' => array(
- 'form' => array(
+ $entity_type1 = $this->setUpEntityType([
+ 'handlers' => [
+ 'form' => [
$operation => $controller,
- ),
- ),
- ));
- $entity_type2 = $this->setUpEntityType(array(
- 'handlers' => array(),
- ));
+ ],
+ ],
+ ]);
+ $entity_type2 = $this->setUpEntityType([
+ 'handlers' => [],
+ ]);
$this->assertTrue($entity_type1->hasFormClasses());
$this->assertFalse($entity_type2->hasFormClasses());
}
@@ -241,11 +241,11 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testGetViewBuilderClass() {
$controller = $this->getTestHandlerClass();
- $entity_type = $this->setUpEntityType(array(
- 'handlers' => array(
+ $entity_type = $this->setUpEntityType([
+ 'handlers' => [
'view_builder' => $controller,
- ),
- ));
+ ],
+ ]);
$this->assertSame($controller, $entity_type->getViewBuilderClass());
}
@@ -256,7 +256,7 @@ class EntityTypeTest extends UnitTestCase {
$id = $this->randomMachineName(33);
$message = 'Attempt to create an entity type with an ID longer than 32 characters: ' . $id;
$this->setExpectedException('Drupal\Core\Entity\Exception\EntityTypeIdLengthException', $message);
- $this->setUpEntityType(array('id' => $id));
+ $this->setUpEntityType(['id' => $id]);
}
/**
@@ -264,7 +264,7 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testgetOriginalClassUnchanged() {
$class = $this->randomMachineName();
- $entity_type = $this->setUpEntityType(array('class' => $class));
+ $entity_type = $this->setUpEntityType(['class' => $class]);
$this->assertEquals($class, $entity_type->getOriginalClass());
}
@@ -274,7 +274,7 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testgetOriginalClassChanged() {
$class = $this->randomMachineName();
- $entity_type = $this->setUpEntityType(array('class' => $class));
+ $entity_type = $this->setUpEntityType(['class' => $class]);
$entity_type->setClass($this->randomMachineName());
$this->assertEquals($class, $entity_type->getOriginalClass());
}
@@ -284,7 +284,7 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testId() {
$id = $this->randomMachineName(32);
- $entity_type = $this->setUpEntityType(array('id' => $id));
+ $entity_type = $this->setUpEntityType(['id' => $id]);
$this->assertEquals($id, $entity_type->id());
}
@@ -293,11 +293,11 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testGetLabel() {
$translatable_label = new TranslatableMarkup($this->randomMachineName());
- $entity_type = $this->setUpEntityType(array('label' => $translatable_label));
+ $entity_type = $this->setUpEntityType(['label' => $translatable_label]);
$this->assertSame($translatable_label, $entity_type->getLabel());
$label = $this->randomMachineName();
- $entity_type = $this->setUpEntityType(array('label' => $label));
+ $entity_type = $this->setUpEntityType(['label' => $label]);
$this->assertSame($label, $entity_type->getLabel());
}
@@ -306,15 +306,15 @@ class EntityTypeTest extends UnitTestCase {
*/
public function testGetGroupLabel() {
$translatable_group_label = new TranslatableMarkup($this->randomMachineName());
- $entity_type = $this->setUpEntityType(array('group_label' => $translatable_group_label));
+ $entity_type = $this->setUpEntityType(['group_label' => $translatable_group_label]);
$this->assertSame($translatable_group_label, $entity_type->getGroupLabel());
$default_label = $this->randomMachineName();
- $entity_type = $this->setUpEntityType(array('group_label' => $default_label));
+ $entity_type = $this->setUpEntityType(['group_label' => $default_label]);
$this->assertSame($default_label, $entity_type->getGroupLabel());
- $default_label = new TranslatableMarkup('Other', array(), array('context' => 'Entity type group'));
- $entity_type = $this->setUpEntityType(array('group_label' => $default_label));
+ $default_label = new TranslatableMarkup('Other', [], ['context' => 'Entity type group']);
+ $entity_type = $this->setUpEntityType(['group_label' => $default_label]);
$this->assertSame($default_label, $entity_type->getGroupLabel());
}
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
index f150e4fea63..69791613a01 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
@@ -82,17 +82,17 @@ class EntityUnitTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->values = array(
+ $this->values = [
'id' => 1,
'langcode' => 'en',
'uuid' => '3bb9ee60-bea5-4622-b89b-a63319d10b3a',
- );
+ ];
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getListCacheTags')
- ->willReturn(array($this->entityTypeId . '_list'));
+ ->willReturn([$this->entityTypeId . '_list']);
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
$this->entityManager->expects($this->any())
@@ -106,7 +106,7 @@ class EntityUnitTest extends UnitTestCase {
$this->languageManager->expects($this->any())
->method('getLanguage')
->with('en')
- ->will($this->returnValue(new Language(array('id' => 'en'))));
+ ->will($this->returnValue(new Language(['id' => 'en'])));
$this->cacheTagsInvalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidator');
@@ -117,7 +117,7 @@ class EntityUnitTest extends UnitTestCase {
$container->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
\Drupal::setContainer($container);
- $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\Entity', array($this->values, $this->entityTypeId));
+ $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\Entity', [$this->values, $this->entityTypeId]);
}
/**
@@ -175,7 +175,7 @@ class EntityUnitTest extends UnitTestCase {
->will($this->returnValue($callback_label));
$this->entityType->expects($this->at(0))
->method('getLabelCallback')
- ->will($this->returnValue(array($callback_container, __FUNCTION__)));
+ ->will($this->returnValue([$callback_container, __FUNCTION__]));
$this->entityType->expects($this->at(1))
->method('getLabelCallback')
->will($this->returnValue(NULL));
@@ -189,11 +189,11 @@ class EntityUnitTest extends UnitTestCase {
$this->entityManager->expects($this->at(1))
->method('getDefinition')
->with($this->entityTypeId)
- ->will($this->returnValue(array(
- 'entity_keys' => array(
+ ->will($this->returnValue([
+ 'entity_keys' => [
'label' => 'label',
- ),
- )));
+ ],
+ ]));
$this->entity->label = $property_label;
$this->assertSame($callback_label, $this->entity->label());
@@ -226,9 +226,9 @@ class EntityUnitTest extends UnitTestCase {
public function testLanguage() {
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('langcode', 'langcode'),
- )));
+ ->will($this->returnValueMap([
+ ['langcode', 'langcode'],
+ ]));
$this->assertSame('en', $this->entity->language()->getId());
}
@@ -298,8 +298,8 @@ class EntityUnitTest extends UnitTestCase {
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('loadMultiple')
- ->with(array(1))
- ->will($this->returnValue(array(1 => $this->entity)));
+ ->with([1])
+ ->will($this->returnValue([1 => $this->entity]));
$this->entityManager->expects($this->once())
->method('getStorage')
->with($this->entityTypeId)
@@ -307,7 +307,7 @@ class EntityUnitTest extends UnitTestCase {
// Call Entity::loadMultiple statically and check that it returns the mock
// entity.
- $this->assertSame(array(1 => $this->entity), $class_name::loadMultiple(array(1)));
+ $this->assertSame([1 => $this->entity], $class_name::loadMultiple([1]));
}
/**
@@ -325,7 +325,7 @@ class EntityUnitTest extends UnitTestCase {
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('create')
- ->with(array())
+ ->with([])
->will($this->returnValue($this->entity));
$this->entityManager->expects($this->once())
->method('getStorage')
@@ -334,7 +334,7 @@ class EntityUnitTest extends UnitTestCase {
// Call Entity::create() statically and check that it returns the mock
// entity.
- $this->assertSame($this->entity, $class_name::create(array()));
+ $this->assertSame($this->entity, $class_name::create([]));
}
/**
@@ -391,15 +391,15 @@ class EntityUnitTest extends UnitTestCase {
public function testPostSave() {
$this->cacheTagsInvalidator->expects($this->at(0))
->method('invalidateTags')
- ->with(array(
+ ->with([
$this->entityTypeId . '_list', // List cache tag.
- ));
+ ]);
$this->cacheTagsInvalidator->expects($this->at(1))
->method('invalidateTags')
- ->with(array(
+ ->with([
$this->entityTypeId . ':' . $this->values['id'], // Own cache tag.
$this->entityTypeId . '_list', // List cache tag.
- ));
+ ]);
// This method is internal, so check for errors on calling it only.
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
@@ -417,7 +417,7 @@ class EntityUnitTest extends UnitTestCase {
public function testPreCreate() {
// This method is internal, so check for errors on calling it only.
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
- $values = array();
+ $values = [];
// Our mocked entity->preCreate() returns NULL, so assert that.
$this->assertNull($this->entity->preCreate($storage, $values));
}
@@ -439,7 +439,7 @@ class EntityUnitTest extends UnitTestCase {
// This method is internal, so check for errors on calling it only.
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
// Our mocked entity->preDelete() returns NULL, so assert that.
- $this->assertNull($this->entity->preDelete($storage, array($this->entity)));
+ $this->assertNull($this->entity->preDelete($storage, [$this->entity]));
}
/**
@@ -448,16 +448,16 @@ class EntityUnitTest extends UnitTestCase {
public function testPostDelete() {
$this->cacheTagsInvalidator->expects($this->once())
->method('invalidateTags')
- ->with(array(
+ ->with([
$this->entityTypeId . ':' . $this->values['id'],
$this->entityTypeId . '_list',
- ));
+ ]);
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('getEntityType')
->willReturn($this->entityType);
- $entities = array($this->values['id'] => $this->entity);
+ $entities = [$this->values['id'] => $this->entity];
$this->entity->postDelete($storage, $entities);
}
@@ -467,7 +467,7 @@ class EntityUnitTest extends UnitTestCase {
public function testPostLoad() {
// This method is internal, so check for errors on calling it only.
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
- $entities = array($this->entity);
+ $entities = [$this->entity];
// Our mocked entity->postLoad() returns NULL, so assert that.
$this->assertNull($this->entity->postLoad($storage, $entities));
}
@@ -476,7 +476,7 @@ class EntityUnitTest extends UnitTestCase {
* @covers ::referencedEntities
*/
public function testReferencedEntities() {
- $this->assertSame(array(), $this->entity->referencedEntities());
+ $this->assertSame([], $this->entity->referencedEntities());
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
index 4fbdba396c2..49427014757 100644
--- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@@ -88,17 +88,17 @@ class KeyValueEntityStorageTest extends UnitTestCase {
protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') {
$this->entityType->expects($this->atLeastOnce())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', 'id'),
- array('uuid', $uuid_key),
- array('langcode', 'langcode'),
- )));
+ ->will($this->returnValueMap([
+ ['id', 'id'],
+ ['uuid', $uuid_key],
+ ['langcode', 'langcode'],
+ ]));
$this->entityType->expects($this->atLeastOnce())
->method('id')
->will($this->returnValue('test_entity_type'));
$this->entityType->expects($this->any())
->method('getListCacheTags')
- ->willReturn(array('test_entity_type_list'));
+ ->willReturn(['test_entity_type_list']);
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$this->entityManager->expects($this->any())
@@ -112,7 +112,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->uuidService = $this->getMock('Drupal\Component\Uuid\UuidInterface');
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
- $language = new Language(array('langcode' => 'en'));
+ $language = new Language(['langcode' => 'en']);
$this->languageManager->expects($this->any())
->method('getDefaultLanguage')
->will($this->returnValue($language));
@@ -149,7 +149,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->uuidService->expects($this->never())
->method('generate');
- $entity = $this->entityStorage->create(array('id' => 'foo', 'uuid' => 'baz'));
+ $entity = $this->entityStorage->create(['id' => 'foo', 'uuid' => 'baz']);
$this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
$this->assertSame('foo', $entity->id());
$this->assertSame('baz', $entity->uuid());
@@ -175,7 +175,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->uuidService->expects($this->never())
->method('generate');
- $entity = $this->entityStorage->create(array('id' => 'foo', 'uuid' => 'baz'));
+ $entity = $this->entityStorage->create(['id' => 'foo', 'uuid' => 'baz']);
$this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
$this->assertSame('foo', $entity->id());
$this->assertSame('baz', $entity->uuid());
@@ -188,7 +188,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
* @return \Drupal\Core\Entity\EntityInterface
*/
public function testCreate() {
- $entity = $this->getMockEntity('Drupal\Core\Entity\Entity', array(), array('toArray'));
+ $entity = $this->getMockEntity('Drupal\Core\Entity\Entity', [], ['toArray']);
$this->entityType->expects($this->once())
->method('getClass')
->will($this->returnValue(get_class($entity)));
@@ -204,7 +204,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
->method('generate')
->will($this->returnValue('bar'));
- $entity = $this->entityStorage->create(array('id' => 'foo'));
+ $entity = $this->entityStorage->create(['id' => 'foo']);
$this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
$this->assertSame('foo', $entity->id());
$this->assertSame('bar', $entity->uuid());
@@ -227,7 +227,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
->will($this->returnValue(get_class($entity)));
$this->setUpKeyValueEntityStorage();
- $expected = array('id' => 'foo');
+ $expected = ['id' => 'foo'];
$this->keyValueStore->expects($this->exactly(2))
->method('has')
->with('foo')
@@ -277,26 +277,26 @@ class KeyValueEntityStorageTest extends UnitTestCase {
->will($this->returnValue(get_class($entity)));
$this->setUpKeyValueEntityStorage();
- $expected = array('id' => 'foo');
+ $expected = ['id' => 'foo'];
$this->keyValueStore->expects($this->exactly(2))
->method('has')
->with('foo')
->will($this->returnValue(TRUE));
$this->keyValueStore->expects($this->once())
->method('getMultiple')
- ->with(array('foo'))
- ->will($this->returnValue(array(array('id' => 'foo'))));
+ ->with(['foo'])
+ ->will($this->returnValue([['id' => 'foo']]));
$this->keyValueStore->expects($this->never())
->method('delete');
$this->moduleHandler->expects($this->at(0))
->method('getImplementations')
->with('entity_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->moduleHandler->expects($this->at(1))
->method('getImplementations')
->with('test_entity_type_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->moduleHandler->expects($this->at(2))
->method('invokeAll')
->with('test_entity_type_presave');
@@ -324,15 +324,15 @@ class KeyValueEntityStorageTest extends UnitTestCase {
public function testSaveConfigEntity() {
$this->setUpKeyValueEntityStorage();
- $entity = $this->getMockEntity('Drupal\Core\Config\Entity\ConfigEntityBase', array(array('id' => 'foo')), array(
+ $entity = $this->getMockEntity('Drupal\Core\Config\Entity\ConfigEntityBase', [['id' => 'foo']], [
'toArray',
'preSave',
- ));
+ ]);
$entity->enforceIsNew();
// When creating a new entity, the ID is tracked as the original ID.
$this->assertSame('foo', $entity->getOriginalId());
- $expected = array('id' => 'foo');
+ $expected = ['id' => 'foo'];
$entity->expects($this->once())
->method('toArray')
->will($this->returnValue($expected));
@@ -367,12 +367,12 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->moduleHandler->expects($this->at(0))
->method('getImplementations')
->with('entity_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->moduleHandler->expects($this->at(1))
->method('getImplementations')
->with('test_entity_type_load')
- ->will($this->returnValue(array()));
- $expected = array('id' => 'foo');
+ ->will($this->returnValue([]));
+ $expected = ['id' => 'foo'];
$entity->expects($this->once())
->method('toArray')
->will($this->returnValue($expected));
@@ -382,8 +382,8 @@ class KeyValueEntityStorageTest extends UnitTestCase {
->will($this->returnValue(TRUE));
$this->keyValueStore->expects($this->once())
->method('getMultiple')
- ->with(array('foo'))
- ->will($this->returnValue(array(array('id' => 'foo'))));
+ ->with(['foo'])
+ ->will($this->returnValue([['id' => 'foo']]));
$this->keyValueStore->expects($this->once())
->method('delete')
->with('foo');
@@ -408,12 +408,12 @@ class KeyValueEntityStorageTest extends UnitTestCase {
public function testSaveContentEntity() {
$this->entityType->expects($this->any())
->method('getKeys')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'id' => 'id',
- )));
+ ]));
$this->setUpKeyValueEntityStorage();
- $expected = array('id' => 'foo');
+ $expected = ['id' => 'foo'];
$this->keyValueStore->expects($this->exactly(2))
->method('has')
->with('foo')
@@ -423,10 +423,10 @@ class KeyValueEntityStorageTest extends UnitTestCase {
->with('foo', $expected);
$this->keyValueStore->expects($this->never())
->method('delete');
- $entity = $this->getMockEntity('Drupal\Core\Entity\ContentEntityBase', array(), array(
+ $entity = $this->getMockEntity('Drupal\Core\Entity\ContentEntityBase', [], [
'toArray',
'id',
- ));
+ ]);
$entity->expects($this->atLeastOnce())
->method('id')
->will($this->returnValue('foo'));
@@ -466,7 +466,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
public function testSaveDuplicate() {
$this->setUpKeyValueEntityStorage();
- $entity = $this->getMockEntity('Drupal\Core\Entity\Entity', array(array('id' => 'foo')));
+ $entity = $this->getMockEntity('Drupal\Core\Entity\Entity', [['id' => 'foo']]);
$entity->enforceIsNew();
$this->keyValueStore->expects($this->once())
->method('has')
@@ -491,16 +491,16 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->keyValueStore->expects($this->once())
->method('getMultiple')
- ->with(array('foo'))
- ->will($this->returnValue(array(array('id' => 'foo'))));
+ ->with(['foo'])
+ ->will($this->returnValue([['id' => 'foo']]));
$this->moduleHandler->expects($this->at(0))
->method('getImplementations')
->with('entity_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->moduleHandler->expects($this->at(1))
->method('getImplementations')
->with('test_entity_type_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$entity = $this->entityStorage->load('foo');
$this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
$this->assertSame('foo', $entity->id());
@@ -516,8 +516,8 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->keyValueStore->expects($this->once())
->method('getMultiple')
- ->with(array('foo'))
- ->will($this->returnValue(array()));
+ ->with(['foo'])
+ ->will($this->returnValue([]));
$this->moduleHandler->expects($this->never())
->method('getImplementations');
$entity = $this->entityStorage->load('foo');
@@ -531,8 +531,8 @@ class KeyValueEntityStorageTest extends UnitTestCase {
* @covers ::doLoadMultiple
*/
public function testLoadMultipleAll() {
- $expected['foo'] = $this->getMockEntity('Drupal\Core\Entity\Entity', array(array('id' => 'foo')));
- $expected['bar'] = $this->getMockEntity('Drupal\Core\Entity\Entity', array(array('id' => 'bar')));
+ $expected['foo'] = $this->getMockEntity('Drupal\Core\Entity\Entity', [['id' => 'foo']]);
+ $expected['bar'] = $this->getMockEntity('Drupal\Core\Entity\Entity', [['id' => 'bar']]);
$this->entityType->expects($this->once())
->method('getClass')
->will($this->returnValue(get_class(reset($expected))));
@@ -540,15 +540,15 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->keyValueStore->expects($this->once())
->method('getAll')
- ->will($this->returnValue(array(array('id' => 'foo'), array('id' => 'bar'))));
+ ->will($this->returnValue([['id' => 'foo'], ['id' => 'bar']]));
$this->moduleHandler->expects($this->at(0))
->method('getImplementations')
->with('entity_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->moduleHandler->expects($this->at(1))
->method('getImplementations')
->with('test_entity_type_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$entities = $this->entityStorage->loadMultiple();
foreach ($entities as $id => $entity) {
$this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
@@ -564,7 +564,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
* @covers ::doLoadMultiple
*/
public function testLoadMultipleIds() {
- $entity = $this->getMockEntity('Drupal\Core\Entity\Entity', array(array('id' => 'foo')));
+ $entity = $this->getMockEntity('Drupal\Core\Entity\Entity', [['id' => 'foo']]);
$this->entityType->expects($this->once())
->method('getClass')
->will($this->returnValue(get_class($entity)));
@@ -573,17 +573,17 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$expected[] = $entity;
$this->keyValueStore->expects($this->once())
->method('getMultiple')
- ->with(array('foo'))
- ->will($this->returnValue(array(array('id' => 'foo'))));
+ ->with(['foo'])
+ ->will($this->returnValue([['id' => 'foo']]));
$this->moduleHandler->expects($this->at(0))
->method('getImplementations')
->with('entity_load')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->moduleHandler->expects($this->at(1))
->method('getImplementations')
->with('test_entity_type_load')
- ->will($this->returnValue(array()));
- $entities = $this->entityStorage->loadMultiple(array('foo'));
+ ->will($this->returnValue([]));
+ $entities = $this->entityStorage->loadMultiple(['foo']);
foreach ($entities as $id => $entity) {
$this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
$this->assertSame($id, $entity->id());
@@ -613,8 +613,8 @@ class KeyValueEntityStorageTest extends UnitTestCase {
* @covers ::doDelete
*/
public function testDelete() {
- $entities['foo'] = $this->getMockEntity('Drupal\Core\Entity\Entity', array(array('id' => 'foo')));
- $entities['bar'] = $this->getMockEntity('Drupal\Core\Entity\Entity', array(array('id' => 'bar')));
+ $entities['foo'] = $this->getMockEntity('Drupal\Core\Entity\Entity', [['id' => 'foo']]);
+ $entities['bar'] = $this->getMockEntity('Drupal\Core\Entity\Entity', [['id' => 'bar']]);
$this->entityType->expects($this->once())
->method('getClass')
->will($this->returnValue(get_class(reset($entities))));
@@ -647,7 +647,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->keyValueStore->expects($this->once())
->method('deleteMultiple')
- ->with(array('foo', 'bar'));
+ ->with(['foo', 'bar']);
$this->entityStorage->delete($entities);
}
@@ -665,7 +665,7 @@ class KeyValueEntityStorageTest extends UnitTestCase {
$this->keyValueStore->expects($this->never())
->method('deleteMultiple');
- $this->entityStorage->delete(array());
+ $this->entityStorage->delete([]);
}
/**
@@ -682,11 +682,11 @@ class KeyValueEntityStorageTest extends UnitTestCase {
*
* @return \Drupal\Core\Entity\EntityInterface|\PHPUnit_Framework_MockObject_MockObject
*/
- public function getMockEntity($class = 'Drupal\Core\Entity\Entity', array $arguments = array(), $methods = array()) {
+ public function getMockEntity($class = 'Drupal\Core\Entity\Entity', array $arguments = [], $methods = []) {
// Ensure the entity is passed at least an array of values and an entity
// type ID
if (!isset($arguments[0])) {
- $arguments[0] = array();
+ $arguments[0] = [];
}
if (!isset($arguments[1])) {
$arguments[1] = 'test_entity_type';
diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
index 1ce87c54021..aecc3e43640 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
@@ -70,13 +70,13 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
// Add an ID field. This also acts as a test for a simple, single-column
// field.
- $this->setUpStorageDefinition('id', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('id', [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
}
/**
@@ -95,277 +95,277 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
* @covers ::processIdentifierSchema
*/
public function testGetSchemaBase() {
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array('id' => 'id'),
- ));
+ 'entity_keys' => ['id' => 'id'],
+ ]);
// Add a field with a 'length' constraint.
- $this->setUpStorageDefinition('name', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('name', [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => 255,
- ),
- ),
- ));
+ ],
+ ],
+ ]);
// Add a multi-column field.
- $this->setUpStorageDefinition('description', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('description', [
+ 'columns' => [
+ 'value' => [
'type' => 'text',
- ),
- 'format' => array(
+ ],
+ 'format' => [
'type' => 'varchar',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
// Add a field with a unique key.
- $this->setUpStorageDefinition('uuid', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('uuid', [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => 128,
- ),
- ),
- 'unique keys' => array(
- 'value' => array('value'),
- ),
- ));
+ ],
+ ],
+ 'unique keys' => [
+ 'value' => ['value'],
+ ],
+ ]);
// Add a field with a unique key, specified as column name and length.
- $this->setUpStorageDefinition('hash', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('hash', [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
'length' => 20,
- ),
- ),
- 'unique keys' => array(
- 'value' => array(array('value', 10)),
- ),
- ));
+ ],
+ ],
+ 'unique keys' => [
+ 'value' => [['value', 10]],
+ ],
+ ]);
// Add a field with a multi-column unique key.
- $this->setUpStorageDefinition('email', array(
- 'columns' => array(
- 'username' => array(
+ $this->setUpStorageDefinition('email', [
+ 'columns' => [
+ 'username' => [
'type' => 'varchar',
- ),
- 'hostname' => array(
+ ],
+ 'hostname' => [
'type' => 'varchar',
- ),
- 'domain' => array(
+ ],
+ 'domain' => [
'type' => 'varchar',
- )
- ),
- 'unique keys' => array(
- 'email' => array('username', 'hostname', array('domain', 3)),
- ),
- ));
+ ]
+ ],
+ 'unique keys' => [
+ 'email' => ['username', 'hostname', ['domain', 3]],
+ ],
+ ]);
// Add a field with an index.
- $this->setUpStorageDefinition('owner', array(
- 'columns' => array(
- 'target_id' => array(
+ $this->setUpStorageDefinition('owner', [
+ 'columns' => [
+ 'target_id' => [
'type' => 'int',
- ),
- ),
- 'indexes' => array(
- 'target_id' => array('target_id'),
- ),
- ));
+ ],
+ ],
+ 'indexes' => [
+ 'target_id' => ['target_id'],
+ ],
+ ]);
// Add a field with an index, specified as column name and length.
- $this->setUpStorageDefinition('translator', array(
- 'columns' => array(
- 'target_id' => array(
+ $this->setUpStorageDefinition('translator', [
+ 'columns' => [
+ 'target_id' => [
'type' => 'int',
- ),
- ),
- 'indexes' => array(
- 'target_id' => array(array('target_id', 10)),
- ),
- ));
+ ],
+ ],
+ 'indexes' => [
+ 'target_id' => [['target_id', 10]],
+ ],
+ ]);
// Add a field with a multi-column index.
- $this->setUpStorageDefinition('location', array(
- 'columns' => array(
- 'country' => array(
+ $this->setUpStorageDefinition('location', [
+ 'columns' => [
+ 'country' => [
'type' => 'varchar',
- ),
- 'state' => array(
+ ],
+ 'state' => [
'type' => 'varchar',
- ),
- 'city' => array(
+ ],
+ 'city' => [
'type' => 'varchar',
- )
- ),
- 'indexes' => array(
- 'country_state_city' => array('country', 'state', array('city', 10)),
- ),
- ));
+ ]
+ ],
+ 'indexes' => [
+ 'country_state_city' => ['country', 'state', ['city', 10]],
+ ],
+ ]);
// Add a field with a foreign key.
- $this->setUpStorageDefinition('editor', array(
- 'columns' => array(
- 'target_id' => array(
+ $this->setUpStorageDefinition('editor', [
+ 'columns' => [
+ 'target_id' => [
'type' => 'int',
- ),
- ),
- 'foreign keys' => array(
- 'user_id' => array(
+ ],
+ ],
+ 'foreign keys' => [
+ 'user_id' => [
'table' => 'users',
- 'columns' => array('target_id' => 'uid'),
- ),
- ),
- ));
+ 'columns' => ['target_id' => 'uid'],
+ ],
+ ],
+ ]);
// Add a multi-column field with a foreign key.
- $this->setUpStorageDefinition('editor_revision', array(
- 'columns' => array(
- 'target_id' => array(
+ $this->setUpStorageDefinition('editor_revision', [
+ 'columns' => [
+ 'target_id' => [
'type' => 'int',
- ),
- 'target_revision_id' => array(
+ ],
+ 'target_revision_id' => [
'type' => 'int',
- ),
- ),
- 'foreign keys' => array(
- 'user_id' => array(
+ ],
+ ],
+ 'foreign keys' => [
+ 'user_id' => [
'table' => 'users',
- 'columns' => array('target_id' => 'uid'),
- ),
- ),
- ));
+ 'columns' => ['target_id' => 'uid'],
+ ],
+ ],
+ ]);
// Add a field with a really long index.
- $this->setUpStorageDefinition('long_index_name', array(
- 'columns' => array(
- 'long_index_name' => array(
+ $this->setUpStorageDefinition('long_index_name', [
+ 'columns' => [
+ 'long_index_name' => [
'type' => 'int',
- ),
- ),
- 'indexes' => array(
- 'long_index_name_really_long_long_name' => array(array('long_index_name', 10)),
- ),
- ));
-
- $expected = array(
- 'entity_test' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'long_index_name_really_long_long_name' => [['long_index_name', 10]],
+ ],
+ ]);
+
+ $expected = [
+ 'entity_test' => [
'description' => 'The base table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- 'name' => array(
+ ],
+ 'name' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
- ),
- 'description__value' => array(
+ ],
+ 'description__value' => [
'type' => 'text',
'not null' => FALSE,
- ),
- 'description__format' => array(
+ ],
+ 'description__format' => [
'type' => 'varchar',
'not null' => FALSE,
- ),
- 'uuid' => array(
+ ],
+ 'uuid' => [
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
- ),
- 'hash' => array(
+ ],
+ 'hash' => [
'type' => 'varchar',
'length' => 20,
'not null' => FALSE,
- ),
- 'email__username' => array(
+ ],
+ 'email__username' => [
'type' => 'varchar',
'not null' => FALSE,
- ),
- 'email__hostname' => array(
+ ],
+ 'email__hostname' => [
'type' => 'varchar',
'not null' => FALSE,
- ),
- 'email__domain' => array(
+ ],
+ 'email__domain' => [
'type' => 'varchar',
'not null' => FALSE,
- ),
- 'owner' => array(
+ ],
+ 'owner' => [
'type' => 'int',
'not null' => FALSE,
- ),
- 'translator' => array(
+ ],
+ 'translator' => [
'type' => 'int',
'not null' => FALSE,
- ),
- 'location__country' => array(
+ ],
+ 'location__country' => [
'type' => 'varchar',
'not null' => FALSE,
- ),
- 'location__state' => array(
+ ],
+ 'location__state' => [
'type' => 'varchar',
'not null' => FALSE,
- ),
- 'location__city' => array(
+ ],
+ 'location__city' => [
'type' => 'varchar',
'not null' => FALSE,
- ),
- 'editor' => array(
+ ],
+ 'editor' => [
'type' => 'int',
'not null' => FALSE,
- ),
- 'editor_revision__target_id' => array(
+ ],
+ 'editor_revision__target_id' => [
'type' => 'int',
'not null' => FALSE,
- ),
- 'editor_revision__target_revision_id' => array(
+ ],
+ 'editor_revision__target_revision_id' => [
'type' => 'int',
'not null' => FALSE,
- ),
- 'long_index_name' => array(
+ ],
+ 'long_index_name' => [
'type' => 'int',
'not null' => FALSE,
- ),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'entity_test_field__uuid__value' => array('uuid'),
- 'entity_test_field__hash__value' => array(array('hash', 10)),
- 'entity_test_field__email__email' => array(
+ ],
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'entity_test_field__uuid__value' => ['uuid'],
+ 'entity_test_field__hash__value' => [['hash', 10]],
+ 'entity_test_field__email__email' => [
'email__username',
'email__hostname',
- array('email__domain', 3),
- ),
- ),
- 'indexes' => array(
- 'entity_test_field__owner__target_id' => array('owner'),
- 'entity_test_field__translator__target_id' => array(
- array('translator', 10),
- ),
- 'entity_test_field__location__country_state_city' => array(
+ ['email__domain', 3],
+ ],
+ ],
+ 'indexes' => [
+ 'entity_test_field__owner__target_id' => ['owner'],
+ 'entity_test_field__translator__target_id' => [
+ ['translator', 10],
+ ],
+ 'entity_test_field__location__country_state_city' => [
'location__country',
'location__state',
- array('location__city', 10),
- ),
- 'entity_test__b588603cb9' => array(
- array('long_index_name', 10),
- ),
-
- ),
- 'foreign keys' => array(
- 'entity_test_field__editor__user_id' => array(
+ ['location__city', 10],
+ ],
+ 'entity_test__b588603cb9' => [
+ ['long_index_name', 10],
+ ],
+
+ ],
+ 'foreign keys' => [
+ 'entity_test_field__editor__user_id' => [
'table' => 'users',
- 'columns' => array('editor' => 'uid'),
- ),
- 'entity_test_field__editor_revision__user_id' => array(
+ 'columns' => ['editor' => 'uid'],
+ ],
+ 'entity_test_field__editor_revision__user_id' => [
'table' => 'users',
- 'columns' => array('editor_revision__target_id' => 'uid'),
- ),
- ),
- ),
- );
+ 'columns' => ['editor_revision__target_id' => 'uid'],
+ ],
+ ],
+ ],
+ ];
$this->setUpStorageSchema($expected);
$table_mapping = new DefaultTableMapping($this->entityType, $this->storageDefinitions);
$table_mapping->setFieldNames('entity_test', array_keys($this->storageDefinitions));
- $table_mapping->setExtraColumns('entity_test', array('default_langcode'));
+ $table_mapping->setExtraColumns('entity_test', ['default_langcode']);
$this->storage->expects($this->any())
->method('getTableMapping')
@@ -389,76 +389,76 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
* @covers ::processIdentifierSchema
*/
public function testGetSchemaRevisionable() {
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array(
+ 'entity_keys' => [
'id' => 'id',
'revision' => 'revision_id',
- ),
- ));
+ ],
+ ]);
$this->storage->expects($this->exactly(2))
->method('getRevisionTable')
->will($this->returnValue('entity_test_revision'));
- $this->setUpStorageDefinition('revision_id', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('revision_id', [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
- $expected = array(
- 'entity_test' => array(
+ $expected = [
+ 'entity_test' => [
'description' => 'The base table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'int',
'not null' => FALSE,
- )
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'entity_test__revision_id' => array('revision_id'),
- ),
- 'indexes' => array(),
- 'foreign keys' => array(
- 'entity_test__revision' => array(
+ ]
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'entity_test__revision_id' => ['revision_id'],
+ ],
+ 'indexes' => [],
+ 'foreign keys' => [
+ 'entity_test__revision' => [
'table' => 'entity_test_revision',
- 'columns' => array('revision_id' => 'revision_id'),
- )
- ),
- ),
- 'entity_test_revision' => array(
+ 'columns' => ['revision_id' => 'revision_id'],
+ ]
+ ],
+ ],
+ 'entity_test_revision' => [
'description' => 'The revision table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'int',
'not null' => TRUE,
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('revision_id'),
- 'unique keys' => array(),
- 'indexes' => array(
- 'entity_test__id' => array('id'),
- ),
- 'foreign keys' => array(
- 'entity_test__revisioned' => array(
+ ],
+ ],
+ 'primary key' => ['revision_id'],
+ 'unique keys' => [],
+ 'indexes' => [
+ 'entity_test__id' => ['id'],
+ ],
+ 'foreign keys' => [
+ 'entity_test__revisioned' => [
'table' => 'entity_test',
- 'columns' => array('id' => 'id'),
- ),
- ),
- ),
- );
+ 'columns' => ['id' => 'id'],
+ ],
+ ],
+ ],
+ ];
$this->setUpStorageSchema($expected);
@@ -484,87 +484,87 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
* @covers ::processDataTable
*/
public function testGetSchemaTranslatable() {
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array(
+ 'entity_keys' => [
'id' => 'id',
'langcode' => 'langcode',
- ),
- ));
+ ],
+ ]);
$this->storage->expects($this->any())
->method('getDataTable')
->will($this->returnValue('entity_test_field_data'));
- $this->setUpStorageDefinition('langcode', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('langcode', [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
- $this->setUpStorageDefinition('default_langcode', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('default_langcode', [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
'size' => 'tiny',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
- $expected = array(
- 'entity_test' => array(
+ $expected = [
+ 'entity_test' => [
'description' => 'The base table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar',
'not null' => TRUE,
- )
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(),
- 'indexes' => array(),
- 'foreign keys' => array(),
- ),
- 'entity_test_field_data' => array(
+ ]
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [],
+ 'indexes' => [],
+ 'foreign keys' => [],
+ ],
+ 'entity_test_field_data' => [
'description' => 'The data table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'int',
'not null' => TRUE,
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar',
'not null' => TRUE,
- ),
- 'default_langcode' => array(
+ ],
+ 'default_langcode' => [
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id', 'langcode'),
- 'unique keys' => array(),
- 'indexes' => array(
- 'entity_test__id__default_langcode__langcode' => array(
+ ],
+ ],
+ 'primary key' => ['id', 'langcode'],
+ 'unique keys' => [],
+ 'indexes' => [
+ 'entity_test__id__default_langcode__langcode' => [
0 => 'id',
1 => 'default_langcode',
2 => 'langcode',
- ),
- ),
- 'foreign keys' => array(
- 'entity_test' => array(
+ ],
+ ],
+ 'foreign keys' => [
+ 'entity_test' => [
'table' => 'entity_test',
- 'columns' => array('id' => 'id'),
- ),
- ),
- ),
- );
+ 'columns' => ['id' => 'id'],
+ ],
+ ],
+ ],
+ ];
$this->setUpStorageSchema($expected);
@@ -595,14 +595,14 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
* @covers ::processRevisionDataTable
*/
public function testGetSchemaRevisionableTranslatable() {
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array(
+ 'entity_keys' => [
'id' => 'id',
'revision' => 'revision_id',
'langcode' => 'langcode',
- ),
- ));
+ ],
+ ]);
$this->storage->expects($this->exactly(3))
->method('getRevisionTable')
@@ -614,166 +614,166 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
->method('getRevisionDataTable')
->will($this->returnValue('entity_test_revision_field_data'));
- $this->setUpStorageDefinition('revision_id', array(
- 'columns' => array(
- 'value' => array(
+ $this->setUpStorageDefinition('revision_id', [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
- ),
- ),
- ));
- $this->setUpStorageDefinition('langcode', array(
- 'columns' => array(
- 'value' => array(
+ ],
+ ],
+ ]);
+ $this->setUpStorageDefinition('langcode', [
+ 'columns' => [
+ 'value' => [
'type' => 'varchar',
- ),
- ),
- ));
- $this->setUpStorageDefinition('default_langcode', array(
- 'columns' => array(
- 'value' => array(
+ ],
+ ],
+ ]);
+ $this->setUpStorageDefinition('default_langcode', [
+ 'columns' => [
+ 'value' => [
'type' => 'int',
'size' => 'tiny',
- ),
- ),
- ));
+ ],
+ ],
+ ]);
- $expected = array(
- 'entity_test' => array(
+ $expected = [
+ 'entity_test' => [
'description' => 'The base table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'int',
'not null' => FALSE,
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar',
'not null' => TRUE,
- )
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(
- 'entity_test__revision_id' => array('revision_id'),
- ),
- 'indexes' => array(),
- 'foreign keys' => array(
- 'entity_test__revision' => array(
+ ]
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [
+ 'entity_test__revision_id' => ['revision_id'],
+ ],
+ 'indexes' => [],
+ 'foreign keys' => [
+ 'entity_test__revision' => [
'table' => 'entity_test_revision',
- 'columns' => array('revision_id' => 'revision_id'),
- ),
- ),
- ),
- 'entity_test_revision' => array(
+ 'columns' => ['revision_id' => 'revision_id'],
+ ],
+ ],
+ ],
+ 'entity_test_revision' => [
'description' => 'The revision table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'int',
'not null' => TRUE,
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar',
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('revision_id'),
- 'unique keys' => array(),
- 'indexes' => array(
- 'entity_test__id' => array('id'),
- ),
- 'foreign keys' => array(
- 'entity_test__revisioned' => array(
+ ],
+ ],
+ 'primary key' => ['revision_id'],
+ 'unique keys' => [],
+ 'indexes' => [
+ 'entity_test__id' => ['id'],
+ ],
+ 'foreign keys' => [
+ 'entity_test__revisioned' => [
'table' => 'entity_test',
- 'columns' => array('id' => 'id'),
- ),
- ),
- ),
- 'entity_test_field_data' => array(
+ 'columns' => ['id' => 'id'],
+ ],
+ ],
+ ],
+ 'entity_test_field_data' => [
'description' => 'The data table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'int',
'not null' => TRUE,
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'int',
'not null' => TRUE,
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar',
'not null' => TRUE,
- ),
- 'default_langcode' => array(
+ ],
+ 'default_langcode' => [
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id', 'langcode'),
- 'unique keys' => array(),
- 'indexes' => array(
- 'entity_test__revision_id' => array('revision_id'),
- 'entity_test__id__default_langcode__langcode' => array(
+ ],
+ ],
+ 'primary key' => ['id', 'langcode'],
+ 'unique keys' => [],
+ 'indexes' => [
+ 'entity_test__revision_id' => ['revision_id'],
+ 'entity_test__id__default_langcode__langcode' => [
0 => 'id',
1 => 'default_langcode',
2 => 'langcode',
- ),
- ),
- 'foreign keys' => array(
- 'entity_test' => array(
+ ],
+ ],
+ 'foreign keys' => [
+ 'entity_test' => [
'table' => 'entity_test',
- 'columns' => array('id' => 'id'),
- ),
- ),
- ),
- 'entity_test_revision_field_data' => array(
+ 'columns' => ['id' => 'id'],
+ ],
+ ],
+ ],
+ 'entity_test_revision_field_data' => [
'description' => 'The revision data table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'int',
'not null' => TRUE,
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'int',
'not null' => TRUE,
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar',
'not null' => TRUE,
- ),
- 'default_langcode' => array(
+ ],
+ 'default_langcode' => [
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('revision_id', 'langcode'),
- 'unique keys' => array(),
- 'indexes' => array(
- 'entity_test__id__default_langcode__langcode' => array(
+ ],
+ ],
+ 'primary key' => ['revision_id', 'langcode'],
+ 'unique keys' => [],
+ 'indexes' => [
+ 'entity_test__id__default_langcode__langcode' => [
0 => 'id',
1 => 'default_langcode',
2 => 'langcode',
- ),
- ),
- 'foreign keys' => array(
- 'entity_test' => array(
+ ],
+ ],
+ 'foreign keys' => [
+ 'entity_test' => [
'table' => 'entity_test',
- 'columns' => array('id' => 'id'),
- ),
- 'entity_test__revision' => array(
+ 'columns' => ['id' => 'id'],
+ ],
+ 'entity_test__revision' => [
'table' => 'entity_test_revision',
- 'columns' => array('revision_id' => 'revision_id'),
- ),
- ),
- ),
- );
+ 'columns' => ['revision_id' => 'revision_id'],
+ ],
+ ],
+ ],
+ ];
$this->setUpStorageSchema($expected);
@@ -801,53 +801,53 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
*/
public function testDedicatedTableSchema() {
$entity_type_id = 'entity_test';
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array('id' => 'id'),
- ));
+ 'entity_keys' => ['id' => 'id'],
+ ]);
// Setup a field having a dedicated schema.
$field_name = $this->getRandomGenerator()->name();
- $this->setUpStorageDefinition($field_name, array(
- 'columns' => array(
- 'shape' => array(
+ $this->setUpStorageDefinition($field_name, [
+ 'columns' => [
+ 'shape' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- 'color' => array(
+ ],
+ 'color' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- 'area' => array(
+ ],
+ 'area' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'depth' => array(
+ ],
+ 'depth' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- ),
- 'foreign keys' => array(
- 'color' => array(
+ ],
+ ],
+ 'foreign keys' => [
+ 'color' => [
'table' => 'color',
- 'columns' => array(
+ 'columns' => [
'color' => 'id'
- ),
- ),
- ),
- 'unique keys' => array(
- 'area' => array('area'),
- 'shape' => array(array('shape', 10)),
- ),
- 'indexes' => array(
- 'depth' => array('depth'),
- 'color' => array(array('color', 3)),
- ),
- ));
+ ],
+ ],
+ ],
+ 'unique keys' => [
+ 'area' => ['area'],
+ 'shape' => [['shape', 10]],
+ ],
+ 'indexes' => [
+ 'depth' => ['depth'],
+ 'color' => [['color', 3]],
+ ],
+ ]);
$field_storage = $this->storageDefinitions[$field_name];
$field_storage
@@ -868,97 +868,97 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
->method('getType')
->will($this->returnValue('integer'));
- $expected = array(
- $entity_type_id . '__' . $field_name => array(
+ $expected = [
+ $entity_type_id . '__' . $field_name => [
'description' => "Data storage for $entity_type_id field $field_name.",
- 'fields' => array(
- 'bundle' => array(
+ 'fields' => [
+ 'bundle' => [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The field instance bundle to which this row belongs, used when deleting a field instance',
- ),
- 'deleted' => array(
+ ],
+ 'deleted' => [
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'A boolean indicating whether this data item has been deleted',
- ),
- 'entity_id' => array(
+ ],
+ 'entity_id' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The entity id this data is attached to',
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar_ascii',
'length' => 32,
'not null' => TRUE,
'default' => '',
'description' => 'The language code for this data item.',
- ),
- 'delta' => array(
+ ],
+ 'delta' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The sequence number for this data item, used for multi-value fields',
- ),
- $field_name . '_shape' => array(
+ ],
+ $field_name . '_shape' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- $field_name . '_color' => array(
+ ],
+ $field_name . '_color' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- $field_name . '_area' => array(
+ ],
+ $field_name . '_area' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- $field_name . '_depth' => array(
+ ],
+ $field_name . '_depth' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('entity_id', 'deleted', 'delta', 'langcode'),
- 'indexes' => array(
- 'bundle' => array('bundle'),
- 'revision_id' => array('revision_id'),
- $field_name . '_depth' => array($field_name . '_depth'),
- $field_name . '_color' => array(array($field_name . '_color', 3)),
- ),
- 'unique keys' => array(
- $field_name . '_area' => array($field_name . '_area'),
- $field_name . '_shape' => array(array($field_name . '_shape', 10)),
- ),
- 'foreign keys' => array(
- $field_name . '_color' => array(
+ ],
+ ],
+ 'primary key' => ['entity_id', 'deleted', 'delta', 'langcode'],
+ 'indexes' => [
+ 'bundle' => ['bundle'],
+ 'revision_id' => ['revision_id'],
+ $field_name . '_depth' => [$field_name . '_depth'],
+ $field_name . '_color' => [[$field_name . '_color', 3]],
+ ],
+ 'unique keys' => [
+ $field_name . '_area' => [$field_name . '_area'],
+ $field_name . '_shape' => [[$field_name . '_shape', 10]],
+ ],
+ 'foreign keys' => [
+ $field_name . '_color' => [
'table' => 'color',
- 'columns' => array(
+ 'columns' => [
$field_name . '_color' => 'id',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
$this->setUpStorageSchema($expected);
$table_mapping = new DefaultTableMapping($this->entityType, $this->storageDefinitions);
$table_mapping->setFieldNames($entity_type_id, array_keys($this->storageDefinitions));
- $table_mapping->setExtraColumns($entity_type_id, array('default_langcode'));
+ $table_mapping->setExtraColumns($entity_type_id, ['default_langcode']);
$this->storage->expects($this->any())
->method('getTableMapping')
@@ -978,37 +978,37 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
*/
public function testDedicatedTableSchemaForEntityWithStringIdentifier() {
$entity_type_id = 'entity_test';
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array('id' => 'id'),
- ));
+ 'entity_keys' => ['id' => 'id'],
+ ]);
// Setup a field having a dedicated schema.
$field_name = $this->getRandomGenerator()->name();
- $this->setUpStorageDefinition($field_name, array(
- 'columns' => array(
- 'shape' => array(
+ $this->setUpStorageDefinition($field_name, [
+ 'columns' => [
+ 'shape' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- 'color' => array(
+ ],
+ 'color' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- ),
- 'foreign keys' => array(
- 'color' => array(
+ ],
+ ],
+ 'foreign keys' => [
+ 'color' => [
'table' => 'color',
- 'columns' => array(
+ 'columns' => [
'color' => 'id'
- ),
- ),
- ),
- 'unique keys' => array(),
- 'indexes' => array(),
- ));
+ ],
+ ],
+ ],
+ 'unique keys' => [],
+ 'indexes' => [],
+ ]);
$field_storage = $this->storageDefinitions[$field_name];
$field_storage
@@ -1029,81 +1029,81 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
->method('getType')
->will($this->returnValue('string'));
- $expected = array(
- $entity_type_id . '__' . $field_name => array(
+ $expected = [
+ $entity_type_id . '__' . $field_name => [
'description' => "Data storage for $entity_type_id field $field_name.",
- 'fields' => array(
- 'bundle' => array(
+ 'fields' => [
+ 'bundle' => [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The field instance bundle to which this row belongs, used when deleting a field instance',
- ),
- 'deleted' => array(
+ ],
+ 'deleted' => [
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'A boolean indicating whether this data item has been deleted',
- ),
- 'entity_id' => array(
+ ],
+ 'entity_id' => [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'description' => 'The entity id this data is attached to',
- ),
- 'revision_id' => array(
+ ],
+ 'revision_id' => [
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'description' => 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
- ),
- 'langcode' => array(
+ ],
+ 'langcode' => [
'type' => 'varchar_ascii',
'length' => 32,
'not null' => TRUE,
'default' => '',
'description' => 'The language code for this data item.',
- ),
- 'delta' => array(
+ ],
+ 'delta' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The sequence number for this data item, used for multi-value fields',
- ),
- $field_name . '_shape' => array(
+ ],
+ $field_name . '_shape' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- $field_name . '_color' => array(
+ ],
+ $field_name . '_color' => [
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
- ),
- ),
- 'primary key' => array('entity_id', 'deleted', 'delta', 'langcode'),
- 'indexes' => array(
- 'bundle' => array('bundle'),
- 'revision_id' => array('revision_id'),
- ),
- 'foreign keys' => array(
- $field_name . '_color' => array(
+ ],
+ ],
+ 'primary key' => ['entity_id', 'deleted', 'delta', 'langcode'],
+ 'indexes' => [
+ 'bundle' => ['bundle'],
+ 'revision_id' => ['revision_id'],
+ ],
+ 'foreign keys' => [
+ $field_name . '_color' => [
'table' => 'color',
- 'columns' => array(
+ 'columns' => [
$field_name . '_color' => 'id',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
$this->setUpStorageSchema($expected);
$table_mapping = new DefaultTableMapping($this->entityType, $this->storageDefinitions);
$table_mapping->setFieldNames($entity_type_id, array_keys($this->storageDefinitions));
- $table_mapping->setExtraColumns($entity_type_id, array('default_langcode'));
+ $table_mapping->setExtraColumns($entity_type_id, ['default_langcode']);
$this->storage->expects($this->any())
->method('getTableMapping')
@@ -1162,10 +1162,10 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
* @dataProvider providerTestRequiresEntityDataMigration
*/
public function testRequiresEntityDataMigration($updated_entity_type_definition, $original_entity_type_definition, $original_storage_has_data, $shared_table_structure_changed, $migration_required) {
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array('id' => 'id'),
- ));
+ 'entity_keys' => ['id' => 'id'],
+ ]);
$original_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
->disableOriginalConstructor()
@@ -1188,8 +1188,8 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
->willReturn($original_storage);
$this->storageSchema = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema')
- ->setConstructorArgs(array($this->entityManager, $this->entityType, $this->storage, $connection))
- ->setMethods(array('installedStorageSchema', 'hasSharedTableStructureChange'))
+ ->setConstructorArgs([$this->entityManager, $this->entityType, $this->storage, $connection])
+ ->setMethods(['installedStorageSchema', 'hasSharedTableStructureChange'])
->getMock();
$this->storageSchema->expects($this->any())
@@ -1273,15 +1273,15 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
*/
public function testRequiresEntityStorageSchemaChanges(ContentEntityTypeInterface $updated, ContentEntityTypeInterface $original, $requires_change, $change_schema, $change_shared_table) {
- $this->entityType = new ContentEntityType(array(
+ $this->entityType = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array('id' => 'id'),
- ));
+ 'entity_keys' => ['id' => 'id'],
+ ]);
$this->setUpStorageSchema();
$table_mapping = new DefaultTableMapping($this->entityType, $this->storageDefinitions);
$table_mapping->setFieldNames('entity_test', array_keys($this->storageDefinitions));
- $table_mapping->setExtraColumns('entity_test', array('default_langcode'));
+ $table_mapping->setExtraColumns('entity_test', ['default_langcode']);
$this->storage->expects($this->any())
->method('getTableMapping')
->will($this->returnValue($table_mapping));
@@ -1290,7 +1290,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
if ($change_schema) {
$this->storageSchema->expects($this->once())
->method('loadEntitySchemaData')
- ->willReturn(array());
+ ->willReturn([]);
}
else {
$expected = [
@@ -1321,7 +1321,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
* (optional) An associative array describing the expected entity schema to
* be created. Defaults to expecting nothing.
*/
- protected function setUpStorageSchema(array $expected = array()) {
+ protected function setUpStorageSchema(array $expected = []) {
$this->entityManager->expects($this->any())
->method('getDefinition')
->with($this->entityType->id())
@@ -1365,8 +1365,8 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
$key_value = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface');
$this->storageSchema = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema')
- ->setConstructorArgs(array($this->entityManager, $this->entityType, $this->storage, $connection))
- ->setMethods(array('installedStorageSchema', 'loadEntitySchemaData', 'hasSharedTableNameChanges', 'isTableEmpty'))
+ ->setConstructorArgs([$this->entityManager, $this->entityType, $this->storage, $connection])
+ ->setMethods(['installedStorageSchema', 'loadEntitySchemaData', 'hasSharedTableNameChanges', 'isTableEmpty'])
->getMock();
$this->storageSchema
->expects($this->any())
@@ -1405,7 +1405,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
->will($this->returnValue($schema['columns']));
// Add property definitions.
if (!empty($schema['columns'])) {
- $property_definitions = array();
+ $property_definitions = [];
foreach ($schema['columns'] as $column => $info) {
$property_definitions[$column] = $this->getMock('Drupal\Core\TypedData\DataDefinitionInterface');
$property_definitions[$column]->expects($this->any())
@@ -1422,49 +1422,49 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
* ::onEntityTypeUpdate
*/
public function testonEntityTypeUpdateWithNewIndex() {
- $this->entityType = $original_entity_type = new ContentEntityType(array(
+ $this->entityType = $original_entity_type = new ContentEntityType([
'id' => 'entity_test',
- 'entity_keys' => array('id' => 'id'),
- ));
+ 'entity_keys' => ['id' => 'id'],
+ ]);
// Add a field with a really long index.
- $this->setUpStorageDefinition('long_index_name', array(
- 'columns' => array(
- 'long_index_name' => array(
+ $this->setUpStorageDefinition('long_index_name', [
+ 'columns' => [
+ 'long_index_name' => [
'type' => 'int',
- ),
- ),
- 'indexes' => array(
- 'long_index_name_really_long_long_name' => array(array('long_index_name', 10)),
- ),
- ));
-
- $expected = array(
- 'entity_test' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'long_index_name_really_long_long_name' => [['long_index_name', 10]],
+ ],
+ ]);
+
+ $expected = [
+ 'entity_test' => [
'description' => 'The base table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- 'long_index_name' => array(
+ ],
+ 'long_index_name' => [
'type' => 'int',
'not null' => FALSE,
- ),
- ),
- 'indexes' => array(
- 'entity_test__b588603cb9' => array(
- array('long_index_name', 10),
- ),
- ),
- ),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'entity_test__b588603cb9' => [
+ ['long_index_name', 10],
+ ],
+ ],
+ ],
+ ];
$this->setUpStorageSchema($expected);
$table_mapping = new DefaultTableMapping($this->entityType, $this->storageDefinitions);
$table_mapping->setFieldNames('entity_test', array_keys($this->storageDefinitions));
- $table_mapping->setExtraColumns('entity_test', array('default_langcode'));
+ $table_mapping->setExtraColumns('entity_test', ['default_langcode']);
$this->storage->expects($this->any())
->method('getTableMapping')
diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
index f552bfeca80..b3e339b897d 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
@@ -41,7 +41,7 @@ class SqlContentEntityStorageTest extends UnitTestCase {
*
* @var \Drupal\Core\Field\BaseFieldDefinition[]|\PHPUnit_Framework_MockObject_MockObject[]
*/
- protected $fieldDefinitions = array();
+ protected $fieldDefinitions = [];
/**
* The mocked entity manager used in this test.
@@ -110,7 +110,7 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager->expects($this->any())
->method('getDefaultLanguage')
- ->will($this->returnValue(new Language(array('langcode' => 'en'))));
+ ->will($this->returnValue(new Language(['langcode' => 'en'])));
$this->connection = $this->getMockBuilder('Drupal\Core\Database\Connection')
->disableOriginalConstructor()
->getMock();
@@ -150,12 +150,12 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* value.
*/
public function providerTestGetBaseTable() {
- return array(
+ return [
// Test that the entity type's base table is used, if provided.
- array('entity_test', 'entity_test'),
+ ['entity_test', 'entity_test'],
// Test that the storage falls back to the entity type ID.
- array(NULL, 'entity_test'),
- );
+ [NULL, 'entity_test'],
+ ];
}
/**
@@ -195,13 +195,13 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* second value.
*/
public function providerTestGetRevisionTable() {
- return array(
+ return [
// Test that the entity type's revision table is used, if provided.
- array('entity_test_revision', 'entity_test_revision'),
+ ['entity_test_revision', 'entity_test_revision'],
// Test that the storage falls back to the entity type ID with a
// '_revision' suffix.
- array(NULL, 'entity_test_revision'),
- );
+ [NULL, 'entity_test_revision'],
+ ];
}
/**
@@ -267,13 +267,13 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* the second value.
*/
public function providerTestGetRevisionDataTable() {
- return array(
+ return [
// Test that the entity type's revision data table is used, if provided.
- array('entity_test_field_revision', 'entity_test_field_revision'),
+ ['entity_test_field_revision', 'entity_test_field_revision'],
// Test that the storage falls back to the entity type ID with a
// '_field_revision' suffix.
- array(NULL, 'entity_test_field_revision'),
- );
+ [NULL, 'entity_test_field_revision'],
+ ];
}
/**
@@ -284,52 +284,52 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* @covers ::getTableMapping
*/
public function testOnEntityTypeCreate() {
- $columns = array(
- 'value' => array(
+ $columns = [
+ 'value' => [
'type' => 'int',
- ),
- );
+ ],
+ ];
- $this->fieldDefinitions = $this->mockFieldDefinitions(array('id'));
+ $this->fieldDefinitions = $this->mockFieldDefinitions(['id']);
$this->fieldDefinitions['id']->expects($this->any())
->method('getColumns')
->will($this->returnValue($columns));
$this->fieldDefinitions['id']->expects($this->once())
->method('getSchema')
- ->will($this->returnValue(array('columns' => $columns)));
+ ->will($this->returnValue(['columns' => $columns]));
$this->entityType->expects($this->once())
->method('getKeys')
- ->will($this->returnValue(array('id' => 'id')));
+ ->will($this->returnValue(['id' => 'id']));
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
+ ->will($this->returnValueMap([
// EntityStorageBase::__construct()
- array('id', 'id'),
+ ['id', 'id'],
// ContentEntityStorageBase::__construct()
- array('uuid', NULL),
- array('bundle', NULL),
+ ['uuid', NULL],
+ ['bundle', NULL],
// SqlContentEntityStorageSchema::initializeBaseTable()
- array('id' => 'id'),
+ ['id' => 'id'],
// SqlContentEntityStorageSchema::processBaseTable()
- array('id' => 'id'),
- )));
+ ['id' => 'id'],
+ ]));
$this->setUpEntityStorage();
- $expected = array(
+ $expected = [
'description' => 'The base table for entity_test entities.',
- 'fields' => array(
- 'id' => array(
+ 'fields' => [
+ 'id' => [
'type' => 'serial',
'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- 'unique keys' => array(),
- 'indexes' => array(),
- 'foreign keys' => array(),
- );
+ ],
+ ],
+ 'primary key' => ['id'],
+ 'unique keys' => [],
+ 'indexes' => [],
+ 'foreign keys' => [],
+ ];
$schema_handler = $this->getMockBuilder('Drupal\Core\Database\Schema')
->disableOriginalConstructor()
@@ -343,14 +343,14 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->will($this->returnValue($schema_handler));
$storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
- ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager))
- ->setMethods(array('getStorageSchema'))
+ ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager])
+ ->setMethods(['getStorageSchema'])
->getMock();
$key_value = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface');
$schema_handler = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema')
- ->setConstructorArgs(array($this->entityManager, $this->entityType, $storage, $this->connection))
- ->setMethods(array('installedStorageSchema', 'createSharedTableSchema'))
+ ->setConstructorArgs([$this->entityManager, $this->entityType, $storage, $this->connection])
+ ->setMethods(['installedStorageSchema', 'createSharedTableSchema'])
->getMock();
$schema_handler
->expects($this->any())
@@ -375,9 +375,9 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$this->setUpEntityStorage();
$mapping = $this->entityStorage->getTableMapping();
- $this->assertSame(array('entity_test'), $mapping->getTableNames());
- $this->assertSame(array(), $mapping->getFieldNames('entity_test'));
- $this->assertSame(array(), $mapping->getExtraColumns('entity_test'));
+ $this->assertSame(['entity_test'], $mapping->getTableNames());
+ $this->assertSame([], $mapping->getFieldNames('entity_test'));
+ $this->assertSame([], $mapping->getExtraColumns('entity_test'));
}
/**
@@ -394,22 +394,22 @@ class SqlContentEntityStorageTest extends UnitTestCase {
public function testGetTableMappingSimple(array $entity_keys) {
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', $entity_keys['id']),
- array('uuid', $entity_keys['uuid']),
- array('bundle', $entity_keys['bundle']),
- )));
+ ->will($this->returnValueMap([
+ ['id', $entity_keys['id']],
+ ['uuid', $entity_keys['uuid']],
+ ['bundle', $entity_keys['bundle']],
+ ]));
$this->setUpEntityStorage();
$mapping = $this->entityStorage->getTableMapping();
- $this->assertEquals(array('entity_test'), $mapping->getTableNames());
+ $this->assertEquals(['entity_test'], $mapping->getTableNames());
$expected = array_values(array_filter($entity_keys));
$this->assertEquals($expected, $mapping->getFieldNames('entity_test'));
- $this->assertEquals(array(), $mapping->getExtraColumns('entity_test'));
+ $this->assertEquals([], $mapping->getExtraColumns('entity_test'));
}
/**
@@ -424,15 +424,15 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* @dataProvider providerTestGetTableMappingSimple()
*/
public function testGetTableMappingSimpleWithFields(array $entity_keys) {
- $base_field_names = array('title', 'description', 'owner');
+ $base_field_names = ['title', 'description', 'owner'];
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
$this->fieldDefinitions = $this->mockFieldDefinitions($field_names);
$this->setUpEntityStorage();
$mapping = $this->entityStorage->getTableMapping();
- $this->assertEquals(array('entity_test'), $mapping->getTableNames());
+ $this->assertEquals(['entity_test'], $mapping->getTableNames());
$this->assertEquals($field_names, $mapping->getFieldNames('entity_test'));
- $this->assertEquals(array(), $mapping->getExtraColumns('entity_test'));
+ $this->assertEquals([], $mapping->getExtraColumns('entity_test'));
}
/**
@@ -443,28 +443,28 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* entity keys to use for the mocked entity type.
*/
public function providerTestGetTableMappingSimple() {
- return array(
- array(array(
+ return [
+ [[
'id' => 'test_id',
'bundle' => NULL,
'uuid' => NULL,
- )),
- array(array(
+ ]],
+ [[
'id' => 'test_id',
'bundle' => 'test_bundle',
'uuid' => NULL,
- )),
- array(array(
+ ]],
+ [[
'id' => 'test_id',
'bundle' => NULL,
'uuid' => 'test_uuid',
- )),
- array(array(
+ ]],
+ [[
'id' => 'test_id',
'bundle' => 'test_bundle',
'uuid' => 'test_uuid',
- )),
- );
+ ]],
+ ];
}
/**
@@ -492,14 +492,14 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$this->assertEquals(['entity_test', 'entity_test__multi_valued_base_field'], $mapping->getTableNames());
$this->assertEquals($base_field_names, $mapping->getFieldNames('entity_test__multi_valued_base_field'));
- $extra_columns = array(
+ $extra_columns = [
'bundle',
'deleted',
'entity_id',
'revision_id',
'langcode',
'delta',
- );
+ ];
$this->assertEquals($extra_columns, $mapping->getExtraColumns('entity_test__multi_valued_base_field'));
}
@@ -516,24 +516,24 @@ class SqlContentEntityStorageTest extends UnitTestCase {
*/
public function testGetTableMappingRevisionable(array $entity_keys) {
// This allows to re-use the data provider.
- $entity_keys = array(
+ $entity_keys = [
'id' => $entity_keys['id'],
'revision' => 'test_revision',
'bundle' => $entity_keys['bundle'],
'uuid' => $entity_keys['uuid'],
- );
+ ];
$this->entityType->expects($this->exactly(2))
->method('isRevisionable')
->will($this->returnValue(TRUE));
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', $entity_keys['id']),
- array('uuid', $entity_keys['uuid']),
- array('bundle', $entity_keys['bundle']),
- array('revision', $entity_keys['revision']),
- )));
+ ->will($this->returnValueMap([
+ ['id', $entity_keys['id']],
+ ['uuid', $entity_keys['uuid']],
+ ['bundle', $entity_keys['bundle']],
+ ['revision', $entity_keys['revision']],
+ ]));
$this->entityType->expects($this->any())
->method('getRevisionMetadataKeys')
->will($this->returnValue([]));
@@ -542,16 +542,16 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$mapping = $this->entityStorage->getTableMapping();
- $expected = array('entity_test', 'entity_test_revision');
+ $expected = ['entity_test', 'entity_test_revision'];
$this->assertEquals($expected, $mapping->getTableNames());
$expected = array_values(array_filter($entity_keys));
$this->assertEquals($expected, $mapping->getFieldNames('entity_test'));
- $expected = array($entity_keys['id'], $entity_keys['revision']);
+ $expected = [$entity_keys['id'], $entity_keys['revision']];
$this->assertEquals($expected, $mapping->getFieldNames('entity_test_revision'));
- $this->assertEquals(array(), $mapping->getExtraColumns('entity_test'));
- $this->assertEquals(array(), $mapping->getExtraColumns('entity_test_revision'));
+ $this->assertEquals([], $mapping->getExtraColumns('entity_test'));
+ $this->assertEquals([], $mapping->getExtraColumns('entity_test_revision'));
}
/**
@@ -567,46 +567,46 @@ class SqlContentEntityStorageTest extends UnitTestCase {
*/
public function testGetTableMappingRevisionableWithFields(array $entity_keys) {
// This allows to re-use the data provider.
- $entity_keys = array(
+ $entity_keys = [
'id' => $entity_keys['id'],
'revision' => 'test_revision',
'bundle' => $entity_keys['bundle'],
'uuid' => $entity_keys['uuid'],
- );
+ ];
// PHPUnit does not allow for multiple data providers.
- $test_cases = array(
- array(),
- array('revision_created' => 'revision_timestamp'),
- array('revision_user' => 'revision_uid'),
- array('revision_log_message' => 'revision_log'),
- array('revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid'),
- array('revision_created' => 'revision_timestamp', 'revision_log_message' => 'revision_log'),
- array('revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'),
- array('revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'),
- );
+ $test_cases = [
+ [],
+ ['revision_created' => 'revision_timestamp'],
+ ['revision_user' => 'revision_uid'],
+ ['revision_log_message' => 'revision_log'],
+ ['revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid'],
+ ['revision_created' => 'revision_timestamp', 'revision_log_message' => 'revision_log'],
+ ['revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'],
+ ['revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'],
+ ];
foreach ($test_cases as $revision_metadata_field_names) {
$this->setUp();
- $base_field_names = array('title');
+ $base_field_names = ['title'];
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
$this->fieldDefinitions = $this->mockFieldDefinitions($field_names);
- $revisionable_field_names = array('description', 'owner');
+ $revisionable_field_names = ['description', 'owner'];
$field_names = array_merge($field_names, $revisionable_field_names);
- $this->fieldDefinitions += $this->mockFieldDefinitions(array_merge($revisionable_field_names, array_values($revision_metadata_field_names)), array('isRevisionable' => TRUE));
+ $this->fieldDefinitions += $this->mockFieldDefinitions(array_merge($revisionable_field_names, array_values($revision_metadata_field_names)), ['isRevisionable' => TRUE]);
$this->entityType->expects($this->exactly(2))
->method('isRevisionable')
->will($this->returnValue(TRUE));
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', $entity_keys['id']),
- array('uuid', $entity_keys['uuid']),
- array('bundle', $entity_keys['bundle']),
- array('revision', $entity_keys['revision']),
- )));
+ ->will($this->returnValueMap([
+ ['id', $entity_keys['id']],
+ ['uuid', $entity_keys['uuid']],
+ ['bundle', $entity_keys['bundle']],
+ ['revision', $entity_keys['revision']],
+ ]));
$this->entityType->expects($this->any())
->method('getRevisionMetadataKeys')
@@ -616,19 +616,19 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$mapping = $this->entityStorage->getTableMapping();
- $expected = array('entity_test', 'entity_test_revision');
+ $expected = ['entity_test', 'entity_test_revision'];
$this->assertEquals($expected, $mapping->getTableNames());
$this->assertEquals($field_names, $mapping->getFieldNames('entity_test'));
$expected = array_merge(
- array($entity_keys['id'], $entity_keys['revision']),
+ [$entity_keys['id'], $entity_keys['revision']],
$revisionable_field_names,
array_values($revision_metadata_field_names)
);
$this->assertEquals($expected, $mapping->getFieldNames('entity_test_revision'));
- $this->assertEquals(array(), $mapping->getExtraColumns('entity_test'));
- $this->assertEquals(array(), $mapping->getExtraColumns('entity_test_revision'));
+ $this->assertEquals([], $mapping->getExtraColumns('entity_test'));
+ $this->assertEquals([], $mapping->getExtraColumns('entity_test_revision'));
}
}
@@ -655,33 +655,33 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->will($this->returnValue('entity_test_field_data'));
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', $entity_keys['id']),
- array('uuid', $entity_keys['uuid']),
- array('bundle', $entity_keys['bundle']),
- array('langcode', $entity_keys['langcode']),
- )));
+ ->will($this->returnValueMap([
+ ['id', $entity_keys['id']],
+ ['uuid', $entity_keys['uuid']],
+ ['bundle', $entity_keys['bundle']],
+ ['langcode', $entity_keys['langcode']],
+ ]));
$this->setUpEntityStorage();
$mapping = $this->entityStorage->getTableMapping();
- $expected = array('entity_test', 'entity_test_field_data');
+ $expected = ['entity_test', 'entity_test_field_data'];
$this->assertEquals($expected, $mapping->getTableNames());
$expected = array_values(array_filter($entity_keys));
$actual = $mapping->getFieldNames('entity_test');
$this->assertEquals($expected, $actual);
// The UUID is not stored on the data table.
- $expected = array_values(array_filter(array(
+ $expected = array_values(array_filter([
$entity_keys['id'],
$entity_keys['bundle'],
$entity_keys['langcode'],
- )));
+ ]));
$actual = $mapping->getFieldNames('entity_test_field_data');
$this->assertEquals($expected, $actual);
- $expected = array();
+ $expected = [];
$actual = $mapping->getExtraColumns('entity_test');
$this->assertEquals($expected, $actual);
$actual = $mapping->getExtraColumns('entity_test_field_data');
@@ -703,7 +703,7 @@ class SqlContentEntityStorageTest extends UnitTestCase {
// This allows to re-use the data provider.
$entity_keys['langcode'] = 'langcode';
- $base_field_names = array('title', 'description', 'owner');
+ $base_field_names = ['title', 'description', 'owner'];
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
$this->fieldDefinitions = $this->mockFieldDefinitions($field_names);
@@ -715,33 +715,33 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->will($this->returnValue('entity_test_field_data'));
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', $entity_keys['id']),
- array('uuid', $entity_keys['uuid']),
- array('bundle', $entity_keys['bundle']),
- array('langcode', $entity_keys['langcode']),
- )));
+ ->will($this->returnValueMap([
+ ['id', $entity_keys['id']],
+ ['uuid', $entity_keys['uuid']],
+ ['bundle', $entity_keys['bundle']],
+ ['langcode', $entity_keys['langcode']],
+ ]));
$this->setUpEntityStorage();
$mapping = $this->entityStorage->getTableMapping();
- $expected = array('entity_test', 'entity_test_field_data');
+ $expected = ['entity_test', 'entity_test_field_data'];
$this->assertEquals($expected, $mapping->getTableNames());
$expected = array_values(array_filter($entity_keys));
$actual = $mapping->getFieldNames('entity_test');
$this->assertEquals($expected, $actual);
// The UUID is not stored on the data table.
- $expected = array_merge(array_filter(array(
+ $expected = array_merge(array_filter([
$entity_keys['id'],
$entity_keys['bundle'],
$entity_keys['langcode'],
- )), $base_field_names);
+ ]), $base_field_names);
$actual = $mapping->getFieldNames('entity_test_field_data');
$this->assertEquals($expected, $actual);
- $expected = array();
+ $expected = [];
$actual = $mapping->getExtraColumns('entity_test');
$this->assertEquals($expected, $actual);
$actual = $mapping->getExtraColumns('entity_test_field_data');
@@ -761,18 +761,18 @@ class SqlContentEntityStorageTest extends UnitTestCase {
*/
public function testGetTableMappingRevisionableTranslatable(array $entity_keys) {
// This allows to re-use the data provider.
- $entity_keys = array(
+ $entity_keys = [
'id' => $entity_keys['id'],
'revision' => 'test_revision',
'bundle' => $entity_keys['bundle'],
'uuid' => $entity_keys['uuid'],
'langcode' => 'langcode',
- );
- $revision_metadata_keys = array(
+ ];
+ $revision_metadata_keys = [
'revision_created' => 'revision_timestamp',
'revision_user' => 'revision_uid',
'revision_log_message' => 'revision_log'
- );
+ ];
$this->entityType->expects($this->atLeastOnce())
->method('isRevisionable')
@@ -785,13 +785,13 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->will($this->returnValue('entity_test_field_data'));
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', $entity_keys['id']),
- array('uuid', $entity_keys['uuid']),
- array('bundle', $entity_keys['bundle']),
- array('revision', $entity_keys['revision']),
- array('langcode', $entity_keys['langcode']),
- )));
+ ->will($this->returnValueMap([
+ ['id', $entity_keys['id']],
+ ['uuid', $entity_keys['uuid']],
+ ['bundle', $entity_keys['bundle']],
+ ['revision', $entity_keys['revision']],
+ ['langcode', $entity_keys['langcode']],
+ ]));
$this->entityType->expects($this->any())
->method('getRevisionMetadataKeys')
->will($this->returnValue($revision_metadata_keys));
@@ -800,53 +800,53 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$mapping = $this->entityStorage->getTableMapping();
- $expected = array(
+ $expected = [
'entity_test',
'entity_test_field_data',
'entity_test_revision',
'entity_test_field_revision',
- );
+ ];
$this->assertEquals($expected, $mapping->getTableNames());
// The default language code is stored on the base table.
- $expected = array_values(array_filter(array(
+ $expected = array_values(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['bundle'],
$entity_keys['uuid'],
$entity_keys['langcode'],
- )));
+ ]));
$actual = $mapping->getFieldNames('entity_test');
$this->assertEquals($expected, $actual);
// The revision table on the other hand does not store the bundle and the
// UUID.
- $expected = array_values(array_filter(array(
+ $expected = array_values(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['langcode'],
- )));
+ ]));
$expected = array_merge($expected, array_values($revision_metadata_keys));
$actual = $mapping->getFieldNames('entity_test_revision');
$this->assertEquals($expected, $actual);
// The UUID is not stored on the data table.
- $expected = array_values(array_filter(array(
+ $expected = array_values(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['bundle'],
$entity_keys['langcode'],
- )));
+ ]));
$actual = $mapping->getFieldNames('entity_test_field_data');
$this->assertEquals($expected, $actual);
// The data revision also does not store the bundle.
- $expected = array_values(array_filter(array(
+ $expected = array_values(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['langcode'],
- )));
+ ]));
$actual = $mapping->getFieldNames('entity_test_field_revision');
$this->assertEquals($expected, $actual);
- $expected = array();
+ $expected = [];
$actual = $mapping->getExtraColumns('entity_test');
$this->assertEquals($expected, $actual);
$actual = $mapping->getExtraColumns('entity_test_revision');
@@ -870,34 +870,34 @@ class SqlContentEntityStorageTest extends UnitTestCase {
*/
public function testGetTableMappingRevisionableTranslatableWithFields(array $entity_keys) {
// This allows to re-use the data provider.
- $entity_keys = array(
+ $entity_keys = [
'id' => $entity_keys['id'],
'revision' => 'test_revision',
'bundle' => $entity_keys['bundle'],
'uuid' => $entity_keys['uuid'],
'langcode' => 'langcode',
- );
+ ];
// PHPUnit does not allow for multiple data providers.
- $test_cases = array(
- array(),
- array('revision_created' => 'revision_timestamp'),
- array('revision_user' => 'revision_uid'),
- array('revision_log_message' => 'revision_log'),
- array('revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid'),
- array('revision_created' => 'revision_timestamp', 'revision_log_message' => 'revision_log'),
- array('revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'),
- array('revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'),
- );
+ $test_cases = [
+ [],
+ ['revision_created' => 'revision_timestamp'],
+ ['revision_user' => 'revision_uid'],
+ ['revision_log_message' => 'revision_log'],
+ ['revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid'],
+ ['revision_created' => 'revision_timestamp', 'revision_log_message' => 'revision_log'],
+ ['revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'],
+ ['revision_created' => 'revision_timestamp', 'revision_user' => 'revision_uid', 'revision_log_message' => 'revision_log'],
+ ];
foreach ($test_cases as $revision_metadata_field_names) {
$this->setUp();
- $base_field_names = array('title');
+ $base_field_names = ['title'];
$field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
$this->fieldDefinitions = $this->mockFieldDefinitions($field_names);
- $revisionable_field_names = array('description', 'owner');
- $this->fieldDefinitions += $this->mockFieldDefinitions(array_merge($revisionable_field_names, array_values($revision_metadata_field_names)), array('isRevisionable' => TRUE));
+ $revisionable_field_names = ['description', 'owner'];
+ $this->fieldDefinitions += $this->mockFieldDefinitions(array_merge($revisionable_field_names, array_values($revision_metadata_field_names)), ['isRevisionable' => TRUE]);
$this->entityType->expects($this->atLeastOnce())
->method('isRevisionable')
@@ -910,13 +910,13 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->will($this->returnValue('entity_test_field_data'));
$this->entityType->expects($this->any())
->method('getKey')
- ->will($this->returnValueMap(array(
- array('id', $entity_keys['id']),
- array('uuid', $entity_keys['uuid']),
- array('bundle', $entity_keys['bundle']),
- array('revision', $entity_keys['revision']),
- array('langcode', $entity_keys['langcode']),
- )));
+ ->will($this->returnValueMap([
+ ['id', $entity_keys['id']],
+ ['uuid', $entity_keys['uuid']],
+ ['bundle', $entity_keys['bundle']],
+ ['revision', $entity_keys['revision']],
+ ['langcode', $entity_keys['langcode']],
+ ]));
$this->entityType->expects($this->any())
->method('getRevisionMetadataKeys')
->will($this->returnValue($revision_metadata_field_names));
@@ -925,60 +925,60 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$mapping = $this->entityStorage->getTableMapping();
- $expected = array(
+ $expected = [
'entity_test',
'entity_test_field_data',
'entity_test_revision',
'entity_test_field_revision',
- );
+ ];
$this->assertEquals($expected, $mapping->getTableNames());
- $expected = array(
+ $expected = [
'entity_test',
'entity_test_field_data',
'entity_test_revision',
'entity_test_field_revision',
- );
+ ];
$this->assertEquals($expected, $mapping->getTableNames());
// The default language code is not stored on the base table.
- $expected = array_values(array_filter(array(
+ $expected = array_values(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['bundle'],
$entity_keys['uuid'],
$entity_keys['langcode'],
- )));
+ ]));
$actual = $mapping->getFieldNames('entity_test');
$this->assertEquals($expected, $actual);
// The revision table on the other hand does not store the bundle and the
// UUID.
- $expected = array_merge(array_filter(array(
+ $expected = array_merge(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['langcode'],
- )), array_values($revision_metadata_field_names));
+ ]), array_values($revision_metadata_field_names));
$actual = $mapping->getFieldNames('entity_test_revision');
$this->assertEquals($expected, $actual);
// The UUID is not stored on the data table.
- $expected = array_merge(array_filter(array(
+ $expected = array_merge(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['bundle'],
$entity_keys['langcode'],
- )), $base_field_names, $revisionable_field_names);
+ ]), $base_field_names, $revisionable_field_names);
$actual = $mapping->getFieldNames('entity_test_field_data');
$this->assertEquals($expected, $actual);
// The data revision also does not store the bundle.
- $expected = array_merge(array_filter(array(
+ $expected = array_merge(array_filter([
$entity_keys['id'],
$entity_keys['revision'],
$entity_keys['langcode'],
- )), $revisionable_field_names);
+ ]), $revisionable_field_names);
$actual = $mapping->getFieldNames('entity_test_field_revision');
$this->assertEquals($expected, $actual);
- $expected = array();
+ $expected = [];
$actual = $mapping->getExtraColumns('entity_test');
$this->assertEquals($expected, $actual);
$actual = $mapping->getExtraColumns('entity_test_revision');
@@ -996,7 +996,7 @@ class SqlContentEntityStorageTest extends UnitTestCase {
public function testCreate() {
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
- $language = new Language(array('id' => 'en'));
+ $language = new Language(['id' => 'en']);
$language_manager->expects($this->any())
->method('getCurrentLanguage')
->will($this->returnValue($language));
@@ -1007,7 +1007,7 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$entity = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
->disableOriginalConstructor()
- ->setMethods(array('id'))
+ ->setMethods(['id'])
->getMockForAbstractClass();
$this->entityType->expects($this->atLeastOnce())
@@ -1018,13 +1018,13 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->will($this->returnValue(get_class($entity)));
$this->entityType->expects($this->atLeastOnce())
->method('getKeys')
- ->will($this->returnValue(array('id' => 'id')));
+ ->will($this->returnValue(['id' => 'id']));
// ContentEntityStorageBase iterates over the entity which calls this method
// internally in ContentEntityBase::getProperties().
$this->entityManager->expects($this->once())
->method('getFieldDefinitions')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->entityType->expects($this->atLeastOnce())
->method('isRevisionable')
@@ -1058,14 +1058,14 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* @return \Drupal\Tests\Core\Field\TestBaseFieldDefinitionInterface[]|\PHPUnit_Framework_MockObject_MockObject[]
* An array of mock base field definitions.
*/
- protected function mockFieldDefinitions(array $field_names, $methods = array()) {
- $field_definitions = array();
+ protected function mockFieldDefinitions(array $field_names, $methods = []) {
+ $field_definitions = [];
$definition = $this->getMock('Drupal\Tests\Core\Field\TestBaseFieldDefinitionInterface');
// Assign common method return values.
- $methods += array(
+ $methods += [
'isBaseField' => TRUE,
- );
+ ];
foreach ($methods as $method => $result) {
$definition
->expects($this->any())
@@ -1136,15 +1136,15 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$this->cache->expects($this->once())
->method('getMultiple')
- ->with(array($key))
- ->will($this->returnValue(array($key => (object) array(
+ ->with([$key])
+ ->will($this->returnValue([$key => (object) [
'data' => $entity,
- ))));
+ ]]));
$this->cache->expects($this->never())
->method('set');
$this->setUpEntityStorage();
- $entities = $this->entityStorage->loadMultiple(array($id));
+ $entities = $this->entityStorage->loadMultiple([$id]);
$this->assertEquals($entity, $entities[$id]);
}
@@ -1182,17 +1182,17 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->method('set');
$entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
- ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager))
- ->setMethods(array('getFromStorage', 'invokeStorageLoadHook'))
+ ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager])
+ ->setMethods(['getFromStorage', 'invokeStorageLoadHook'])
->getMock();
$entity_storage->method('invokeStorageLoadHook')
->willReturn(NULL);
$entity_storage->expects($this->once())
->method('getFromStorage')
- ->with(array($id))
- ->will($this->returnValue(array($id => $entity)));
+ ->with([$id])
+ ->will($this->returnValue([$id => $entity]));
- $entities = $entity_storage->loadMultiple(array($id));
+ $entities = $entity_storage->loadMultiple([$id]);
$this->assertEquals($entity, $entities[$id]);
}
@@ -1227,24 +1227,24 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$key = 'values:' . $this->entityTypeId . ':1';
$this->cache->expects($this->once())
->method('getMultiple')
- ->with(array($key))
- ->will($this->returnValue(array()));
+ ->with([$key])
+ ->will($this->returnValue([]));
$this->cache->expects($this->once())
->method('set')
- ->with($key, $entity, CacheBackendInterface::CACHE_PERMANENT, array($this->entityTypeId . '_values', 'entity_field_info'));
+ ->with($key, $entity, CacheBackendInterface::CACHE_PERMANENT, [$this->entityTypeId . '_values', 'entity_field_info']);
$entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
- ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager))
- ->setMethods(array('getFromStorage', 'invokeStorageLoadHook'))
+ ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager])
+ ->setMethods(['getFromStorage', 'invokeStorageLoadHook'])
->getMock();
$entity_storage->method('invokeStorageLoadHook')
->willReturn(NULL);
$entity_storage->expects($this->once())
->method('getFromStorage')
- ->with(array($id))
- ->will($this->returnValue(array($id => $entity)));
+ ->with([$id])
+ ->will($this->returnValue([$id => $entity]));
- $entities = $entity_storage->loadMultiple(array($id));
+ $entities = $entity_storage->loadMultiple([$id]);
$this->assertEquals($entity, $entities[$id]);
}
@@ -1263,7 +1263,7 @@ class SqlContentEntityStorageTest extends UnitTestCase {
->willReturn($query);
$query->expects(($this->once()))
->method('execute')
- ->willReturn(array(5));
+ ->willReturn([5]);
$factory = $this->getMock(QueryFactoryInterface::class);
$factory->expects($this->once())
@@ -1300,7 +1300,7 @@ class SqlContentEntityStorageTest extends UnitTestCase {
* Tests entity ID sanitization.
*/
public function testCleanIds() {
- $valid_ids = array(
+ $valid_ids = [
-1,
0,
1,
@@ -1328,9 +1328,9 @@ class SqlContentEntityStorageTest extends UnitTestCase {
0.00,
1.00,
10.00,
- );
+ ];
- $this->fieldDefinitions = $this->mockFieldDefinitions(array('id'));
+ $this->fieldDefinitions = $this->mockFieldDefinitions(['id']);
$this->fieldDefinitions['id']->expects($this->any())
->method('getType')
->will($this->returnValue('integer'));
@@ -1340,14 +1340,14 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$this->entityType->expects($this->any())
->method('getKey')
->will($this->returnValueMap(
- array(array('id', 'id'))
+ [['id', 'id']]
));
$method = new \ReflectionMethod($this->entityStorage, 'cleanIds');
$method->setAccessible(TRUE);
$this->assertEquals($valid_ids, $method->invoke($this->entityStorage, $valid_ids));
- $invalid_ids = array(
+ $invalid_ids = [
'--1',
'-0x1A',
'0x1AFC',
@@ -1360,8 +1360,8 @@ class SqlContentEntityStorageTest extends UnitTestCase {
'32acb',
123.123,
123.678,
- );
- $this->assertEquals(array(), $method->invoke($this->entityStorage, $invalid_ids));
+ ];
+ $this->assertEquals([], $method->invoke($this->entityStorage, $invalid_ids));
}
@@ -1371,10 +1371,10 @@ class SqlContentEntityStorageTest extends UnitTestCase {
protected function setUpModuleHandlerNoImplementations() {
$this->moduleHandler->expects($this->any())
->method('getImplementations')
- ->will($this->returnValueMap(array(
- array('entity_load', array()),
- array($this->entityTypeId . '_load', array())
- )));
+ ->will($this->returnValueMap([
+ ['entity_load', []],
+ [$this->entityTypeId . '_load', []]
+ ]));
$this->container->set('module_handler', $this->moduleHandler);
}
diff --git a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
index 646f17a3a15..e290f5ab564 100644
--- a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
@@ -113,21 +113,21 @@ class EntityAdapterUnitTest extends UnitTestCase {
*/
protected function setUp() {
$this->id = 1;
- $values = array(
+ $values = [
'id' => $this->id,
'uuid' => '3bb9ee60-bea5-4622-b89b-a63319d10b3a',
- 'defaultLangcode' => array(LanguageInterface::LANGCODE_DEFAULT => 'en'),
- );
+ 'defaultLangcode' => [LanguageInterface::LANGCODE_DEFAULT => 'en'],
+ ];
$this->entityTypeId = $this->randomMachineName();
$this->bundle = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getKeys')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'id' => 'id',
'uuid' => 'uuid',
- )));
+ ]));
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
$this->entityManager->expects($this->any())
@@ -156,11 +156,11 @@ class EntityAdapterUnitTest extends UnitTestCase {
->method('getValidationConstraintManager')
->willReturn($validation_constraint_manager);
- $not_specified = new Language(array('id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'locked' => TRUE));
+ $not_specified = new Language(['id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'locked' => TRUE]);
$this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager->expects($this->any())
->method('getLanguages')
- ->will($this->returnValue(array(LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified)));
+ ->will($this->returnValue([LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified]));
$this->languageManager->expects($this->any())
->method('getLanguage')
@@ -172,10 +172,10 @@ class EntityAdapterUnitTest extends UnitTestCase {
->getMock();
$this->fieldTypePluginManager->expects($this->any())
->method('getDefaultStorageSettings')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->fieldTypePluginManager->expects($this->any())
->method('getDefaultFieldSettings')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->fieldItemList = $this->getMock('\Drupal\Core\Field\FieldItemListInterface');
$this->fieldTypePluginManager->expects($this->any())
@@ -190,16 +190,16 @@ class EntityAdapterUnitTest extends UnitTestCase {
$container->set('plugin.manager.field.field_type', $this->fieldTypePluginManager);
\Drupal::setContainer($container);
- $this->fieldDefinitions = array(
+ $this->fieldDefinitions = [
'id' => BaseFieldDefinition::create('integer'),
'revision_id' => BaseFieldDefinition::create('integer'),
- );
+ ];
$this->entityManager->expects($this->any())
->method('getFieldDefinitions')
->with($this->entityTypeId, $this->bundle)
->will($this->returnValue($this->fieldDefinitions));
- $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', array($values, $this->entityTypeId, $this->bundle));
+ $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', [$values, $this->entityTypeId, $this->bundle]);
$this->entityAdapter = EntityAdapter::createFromEntity($this->entity);
}
@@ -294,7 +294,7 @@ class EntityAdapterUnitTest extends UnitTestCase {
* @covers ::set
*/
public function testSet() {
- $id_items = [ array('value' => $this->id + 1) ];
+ $id_items = [ ['value' => $this->id + 1] ];
$this->fieldItemList->expects($this->once())
->method('setValue')
@@ -309,7 +309,7 @@ class EntityAdapterUnitTest extends UnitTestCase {
*/
public function testSetWithoutData() {
$this->entityAdapter->setValue(NULL);
- $id_items = [ array('value' => $this->id + 1) ];
+ $id_items = [ ['value' => $this->id + 1] ];
$this->entityAdapter->set('id', $id_items);
}
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
index 0597e8c9ac7..f60fe686713 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
@@ -28,24 +28,24 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
<track kind="captions" src="foo.en.vtt" srclang="en" label="English">
<track kind="captions" src="foo.sv.vtt" srclang="sv" label="Svenska">
</audio>';
- $html = array(
+ $html = [
// Simple HTML.
- 0 => array('prefix' => '<div><p>', 'suffix' => '</p></div>'),
+ 0 => ['prefix' => '<div><p>', 'suffix' => '</p></div>'],
// Tricky HTML5 example that's unsupported by PHP <=5.4's DOMDocument:
// https://www.drupal.org/comment/7938201#comment-7938201.
- 1 => array('prefix' => '<div><p>', 'suffix' => '</p>' . $edge_case_html5 . '</div>'),
+ 1 => ['prefix' => '<div><p>', 'suffix' => '</p>' . $edge_case_html5 . '</div>'],
// Multi-byte content *before* the HTML that needs the "is-active" class.
- 2 => array('prefix' => '<div><p>αβγδεζηθικλμνξοσὠ</p><p>', 'suffix' => '</p></div>'),
- );
- $tags = array(
+ 2 => ['prefix' => '<div><p>αβγδεζηθικλμνξοσὠ</p><p>', 'suffix' => '</p></div>'],
+ ];
+ $tags = [
// Of course, it must work on anchors.
'a',
// Unfortunately, it must also work on list items.
'li',
// … and therefor, on *any* tag, really.
'foo',
- );
- $contents = array(
+ ];
+ $contents = [
// Regular content.
'test',
// Mix of UTF-8 and HTML entities, both must be retained.
@@ -55,191 +55,191 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
// Text that closely approximates an important attribute, but should be
// ignored.
'data-drupal-link-system-path=&quot;&lt;front&gt;&quot;',
- );
+ ];
// Define all variations that *do* affect whether or not an "is-active"
// class is set: all possible situations that can be encountered.
- $situations = array();
+ $situations = [];
// Situations with context: front page, English, no query.
- $context = array(
+ $context = [
'path' => 'myfrontpage',
'front' => TRUE,
'language' => 'en',
- 'query' => array(),
- );
+ 'query' => [],
+ ];
// Nothing to do.
$markup = '<foo>bar</foo>';
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => array());
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => []];
// Matching path, plus all matching variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => 'myfrontpage',
- );
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ ];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en']];
// Matching path, plus all non-matching variations.
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => TRUE]];
// Special matching path, plus all variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => '<front>',
- );
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ ];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en']];
// Special matching path, plus all non-matching variations.
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => TRUE]];
// Situations with context: non-front page, Dutch, no query.
- $context = array(
+ $context = [
'path' => 'llama',
'front' => FALSE,
'language' => 'nl',
- 'query' => array(),
- );
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => array());
+ 'query' => [],
+ ];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => []];
// Matching path, plus all matching variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => 'llama',
- );
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes + array('hreflang' => 'nl'));
+ ];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'nl']];
// Matching path, plus all non-matching variations.
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
// Special non-matching path, plus all variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => '<front>',
- );
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => '{"foo":"bar"}'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => TRUE));
+ ];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => '{"foo":"bar"}']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
// Situations with context: non-front page, Dutch, with query.
- $context = array(
+ $context = [
'path' => 'llama',
'front' => FALSE,
'language' => 'nl',
- 'query' => array('foo' => 'bar'),
- );
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => array());
+ 'query' => ['foo' => 'bar'],
+ ];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => []];
// Matching path, plus all matching variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => 'llama',
- 'data-drupal-link-query' => Json::encode(array('foo' => 'bar')),
- );
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes + array('hreflang' => 'nl'));
+ 'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
+ ];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'nl']];
// Matching path, plus all non-matching variations.
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
unset($attributes['data-drupal-link-query']);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
// Special non-matching path, plus all variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => '<front>',
- );
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ ];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
unset($attributes['data-drupal-link-query']);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
// Situations with context: non-front page, Dutch, with query.
- $context = array(
+ $context = [
'path' => 'llama',
'front' => FALSE,
'language' => 'nl',
- 'query' => array('foo' => 'bar'),
- );
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => array());
+ 'query' => ['foo' => 'bar'],
+ ];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => []];
// Matching path, plus all matching variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => 'llama',
- 'data-drupal-link-query' => Json::encode(array('foo' => 'bar')),
- );
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes + array('hreflang' => 'nl'));
+ 'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
+ ];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'nl']];
// Matching path, plus all non-matching variations.
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
unset($attributes['data-drupal-link-query']);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
// Special non-matching path, plus all variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => '<front>',
- );
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl'));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ ];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en']];
unset($attributes['data-drupal-link-query']);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl', 'data-drupal-link-query' => TRUE]];
// Situations with context: front page, English, query.
- $context = array(
+ $context = [
'path' => 'myfrontpage',
'front' => TRUE,
'language' => 'en',
- 'query' => array('foo' => 'bar'),
- );
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => array());
+ 'query' => ['foo' => 'bar'],
+ ];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => []];
// Matching path, plus all matching variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => 'myfrontpage',
- 'data-drupal-link-query' => Json::encode(array('foo' => 'bar')),
- );
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ 'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
+ ];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en']];
// Matching path, plus all non-matching variations.
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl'));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
unset($attributes['data-drupal-link-query']);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => TRUE]];
// Special matching path, plus all variations.
- $attributes = array(
+ $attributes = [
'data-drupal-link-system-path' => '<front>',
- 'data-drupal-link-query' => Json::encode(array('foo' => 'bar')),
- );
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes);
- $situations[] = array('context' => $context, 'is active' => TRUE, 'attributes' => $attributes + array('hreflang' => 'en'));
+ 'data-drupal-link-query' => Json::encode(['foo' => 'bar']),
+ ];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
+ $situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes + ['hreflang' => 'en']];
// Special matching path, plus all non-matching variations.
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'nl'));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'nl']];
unset($attributes['data-drupal-link-query']);
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('data-drupal-link-query' => TRUE));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => ""));
- $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => TRUE));
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['data-drupal-link-query' => TRUE]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
+ $situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => TRUE]];
// Loop over the surrounding HTML variations.
- $data = array();
+ $data = [];
for ($h = 0; $h < count($html); $h++) {
$html_prefix = $html[$h]['prefix'];
$html_suffix = $html[$h]['suffix'];
@@ -272,13 +272,13 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
else {
$active_attributes = $situation['attributes'];
if (!isset($active_attributes['class'])) {
- $active_attributes['class'] = array();
+ $active_attributes['class'] = [];
}
$active_attributes['class'][] = 'is-active';
$target_markup = $create_markup(new Attribute($active_attributes));
}
- $data[] = array($source_markup, $situation['context']['path'], $situation['context']['front'], $situation['context']['language'], $situation['context']['query'], $target_markup);
+ $data[] = [$source_markup, $situation['context']['path'], $situation['context']['front'], $situation['context']['language'], $situation['context']['query'], $target_markup];
}
}
}
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php
index 81e7cc6a102..38cc28cc99e 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php
@@ -126,7 +126,7 @@ class CustomPageExceptionHtmlSubscriberTest extends UnitTestCase {
* Tests onHandleException with a POST request.
*/
public function testHandleWithPostRequest() {
- $request = Request::create('/test', 'POST', array('name' => 'druplicon', 'pass' => '12345'));
+ $request = Request::create('/test', 'POST', ['name' => 'druplicon', 'pass' => '12345']);
$request_context = new RequestContext();
$request_context->fromRequest($request);
@@ -152,7 +152,7 @@ class CustomPageExceptionHtmlSubscriberTest extends UnitTestCase {
* Tests onHandleException with a GET request.
*/
public function testHandleWithGetRequest() {
- $request = Request::create('/test', 'GET', array('name' => 'druplicon', 'pass' => '12345'));
+ $request = Request::create('/test', 'GET', ['name' => 'druplicon', 'pass' => '12345']);
$request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, AccessResult::forbidden()->addCacheTags(['druplicon']));
$request_context = new RequestContext();
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php
index a3e5a8e9306..6528d7327a9 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php
@@ -24,10 +24,10 @@ class ModuleRouteSubscriberTest extends UnitTestCase {
protected function setUp() {
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
- $value_map = array(
- array('enabled', TRUE),
- array('disabled', FALSE),
- );
+ $value_map = [
+ ['enabled', TRUE],
+ ['disabled', FALSE],
+ ];
$this->moduleHandler->expects($this->any())
->method('moduleExists')
@@ -49,7 +49,7 @@ class ModuleRouteSubscriberTest extends UnitTestCase {
*/
public function testRemoveRoute($route_name, array $requirements, $removed) {
$collection = new RouteCollection();
- $route = new Route('', array(), $requirements);
+ $route = new Route('', [], $requirements);
$collection->add($route_name, $route);
$event = new RouteBuildEvent($collection, 'test');
@@ -68,18 +68,18 @@ class ModuleRouteSubscriberTest extends UnitTestCase {
* Data provider for testRemoveRoute().
*/
public function providerTestRemoveRoute() {
- return array(
- array('enabled', array('_module_dependencies' => 'enabled'), FALSE),
- array('disabled', array('_module_dependencies' => 'disabled'), TRUE),
- array('enabled_or', array('_module_dependencies' => 'disabled,enabled'), FALSE),
- array('enabled_or', array('_module_dependencies' => 'enabled,disabled'), FALSE),
- array('disabled_or', array('_module_dependencies' => 'disabled,disabled'), TRUE),
- array('enabled_and', array('_module_dependencies' => 'enabled+enabled'), FALSE),
- array('enabled_and', array('_module_dependencies' => 'enabled+disabled'), TRUE),
- array('enabled_and', array('_module_dependencies' => 'disabled+enabled'), TRUE),
- array('disabled_and', array('_module_dependencies' => 'disabled+disabled'), TRUE),
- array('no_dependencies', array(), FALSE),
- );
+ return [
+ ['enabled', ['_module_dependencies' => 'enabled'], FALSE],
+ ['disabled', ['_module_dependencies' => 'disabled'], TRUE],
+ ['enabled_or', ['_module_dependencies' => 'disabled,enabled'], FALSE],
+ ['enabled_or', ['_module_dependencies' => 'enabled,disabled'], FALSE],
+ ['disabled_or', ['_module_dependencies' => 'disabled,disabled'], TRUE],
+ ['enabled_and', ['_module_dependencies' => 'enabled+enabled'], FALSE],
+ ['enabled_and', ['_module_dependencies' => 'enabled+disabled'], TRUE],
+ ['enabled_and', ['_module_dependencies' => 'disabled+enabled'], TRUE],
+ ['disabled_and', ['_module_dependencies' => 'disabled+disabled'], TRUE],
+ ['no_dependencies', [], FALSE],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/PathRootsSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/PathRootsSubscriberTest.php
index 96a922829a1..ea4ec9f8d5f 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/PathRootsSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/PathRootsSubscriberTest.php
@@ -66,7 +66,7 @@ class PathRootsSubscriberTest extends UnitTestCase {
$this->state->expects($this->once())
->method('set')
- ->with('router.path_roots', array('test', 'test2', 'test1'));
+ ->with('router.path_roots', ['test', 'test2', 'test1']);
$this->pathRootsSubscriber->onRouteFinished();
}
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php
index b945b141ffd..3f80e4d227f 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php
@@ -82,7 +82,7 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
$request->headers->set('HOST', 'example.com');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext);
- $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'checkRedirectUrl'));
+ $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch(KernelEvents::RESPONSE, $event);
@@ -101,16 +101,16 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
* @see \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest::testDestinationRedirect()
*/
public static function providerTestDestinationRedirect() {
- return array(
- array(new Request(), FALSE),
- array(new Request(array('destination' => 'test')), 'http://example.com/drupal/test'),
- array(new Request(array('destination' => '/drupal/test')), 'http://example.com/drupal/test'),
- array(new Request(array('destination' => 'example.com')), 'http://example.com/drupal/example.com'),
- array(new Request(array('destination' => 'example:com')), 'http://example.com/drupal/example:com'),
- array(new Request(array('destination' => 'javascript:alert(0)')), 'http://example.com/drupal/javascript:alert(0)'),
- array(new Request(array('destination' => 'http://example.com/drupal/')), 'http://example.com/drupal/'),
- array(new Request(array('destination' => 'http://example.com/drupal/test')), 'http://example.com/drupal/test'),
- );
+ return [
+ [new Request(), FALSE],
+ [new Request(['destination' => 'test']), 'http://example.com/drupal/test'],
+ [new Request(['destination' => '/drupal/test']), 'http://example.com/drupal/test'],
+ [new Request(['destination' => 'example.com']), 'http://example.com/drupal/example.com'],
+ [new Request(['destination' => 'example:com']), 'http://example.com/drupal/example:com'],
+ [new Request(['destination' => 'javascript:alert(0)']), 'http://example.com/drupal/javascript:alert(0)'],
+ [new Request(['destination' => 'http://example.com/drupal/']), 'http://example.com/drupal/'],
+ [new Request(['destination' => 'http://example.com/drupal/test']), 'http://example.com/drupal/test'],
+ ];
}
/**
@@ -124,7 +124,7 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
$response = new RedirectResponse('http://other-example.com');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext);
- $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'checkRedirectUrl'));
+ $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch(KernelEvents::RESPONSE, $event);
@@ -142,7 +142,7 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
$request->headers->set('HOST', 'example.com');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext);
- $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'checkRedirectUrl'));
+ $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch(KernelEvents::RESPONSE, $event);
@@ -175,7 +175,7 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
$response = new RedirectResponse('http://example.com/drupal');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext);
- $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'checkRedirectUrl'));
+ $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'checkRedirectUrl']);
$event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatch(KernelEvents::RESPONSE, $event);
@@ -187,8 +187,8 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
*/
public function providerTestDestinationRedirectWithInvalidUrl() {
$data = [];
- $data[] = [new Request(array('destination' => '//example:com'))];
- $data[] = [new Request(array('destination' => '//example:com/test'))];
+ $data[] = [new Request(['destination' => '//example:com'])];
+ $data[] = [new Request(['destination' => '//example:com/test'])];
$data['absolute external url'] = [new Request(['destination' => 'http://example.com'])];
$data['absolute external url with folder'] = [new Request(['destination' => 'http://example.ca/drupal'])];
$data['path without drupal basepath'] = [new Request(['destination' => '/test'])];
diff --git a/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php b/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php
index 56f913ae250..29677b2c6ec 100644
--- a/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php
@@ -24,11 +24,11 @@ class DefaultConfigTest extends UnitTestCase {
*/
public function testConfigIsEmpty() {
$config = Yaml::parse(file_get_contents($this->root . '/core/config/install/core.extension.yml'));
- $expected = array(
- 'module' => array(),
- 'theme' => array(),
+ $expected = [
+ 'module' => [],
+ 'theme' => [],
'profile' => '',
- );
+ ];
$this->assertEquals($expected, $config);
}
diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
index 2256045bb95..42a76bac5f3 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
@@ -35,13 +35,13 @@ class ModuleHandlerTest extends UnitTestCase {
parent::setUp();
$this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
- $this->moduleHandler = new ModuleHandler($this->root, array(
- 'module_handler_test' => array(
+ $this->moduleHandler = new ModuleHandler($this->root, [
+ 'module_handler_test' => [
'type' => 'module',
'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml',
'filename' => 'module_handler_test.module',
- )
- ), $this->cacheBackend);
+ ]
+ ], $this->cacheBackend);
}
/**
@@ -85,17 +85,17 @@ class ModuleHandlerTest extends UnitTestCase {
*/
public function testModuleReloading() {
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
- ->setConstructorArgs(array(
+ ->setConstructorArgs([
$this->root,
- array(
- 'module_handler_test' => array(
+ [
+ 'module_handler_test' => [
'type' => 'module',
'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml',
'filename' => 'module_handler_test.module',
- )
- ), $this->cacheBackend
- ))
- ->setMethods(array('load'))
+ ]
+ ], $this->cacheBackend
+ ])
+ ->setMethods(['load'])
->getMock();
// First reload.
$module_handler->expects($this->at(0))
@@ -130,9 +130,9 @@ class ModuleHandlerTest extends UnitTestCase {
* @covers ::getModuleList
*/
public function testGetModuleList() {
- $this->assertEquals($this->moduleHandler->getModuleList(), array(
+ $this->assertEquals($this->moduleHandler->getModuleList(), [
'module_handler_test' => new Extension($this->root, 'module', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml', 'module_handler_test.module'),
- ));
+ ]);
}
/**
@@ -160,17 +160,17 @@ class ModuleHandlerTest extends UnitTestCase {
*/
public function testSetModuleList() {
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
- ->setConstructorArgs(array(
- $this->root, array(), $this->cacheBackend
- ))
- ->setMethods(array('resetImplementations'))
+ ->setConstructorArgs([
+ $this->root, [], $this->cacheBackend
+ ])
+ ->setMethods(['resetImplementations'])
->getMock();
// Ensure we reset implementations when settings a new modules list.
$module_handler->expects($this->once())->method('resetImplementations');
// Make sure we're starting empty.
- $this->assertEquals($module_handler->getModuleList(), array());
+ $this->assertEquals($module_handler->getModuleList(), []);
// Replace the list with a prebuilt list.
$module_handler->setModuleList($this->moduleHandler->getModuleList());
@@ -188,10 +188,10 @@ class ModuleHandlerTest extends UnitTestCase {
public function testAddModule() {
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
- ->setConstructorArgs(array(
- $this->root, array(), $this->cacheBackend
- ))
- ->setMethods(array('resetImplementations'))
+ ->setConstructorArgs([
+ $this->root, [], $this->cacheBackend
+ ])
+ ->setMethods(['resetImplementations'])
->getMock();
// Ensure we reset implementations when settings a new modules list.
@@ -210,10 +210,10 @@ class ModuleHandlerTest extends UnitTestCase {
public function testAddProfile() {
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
- ->setConstructorArgs(array(
- $this->root, array(), $this->cacheBackend
- ))
- ->setMethods(array('resetImplementations'))
+ ->setConstructorArgs([
+ $this->root, [], $this->cacheBackend
+ ])
+ ->setMethods(['resetImplementations'])
->getMock();
// Ensure we reset implementations when settings a new modules list.
@@ -240,17 +240,17 @@ class ModuleHandlerTest extends UnitTestCase {
public function testLoadAllIncludes() {
$this->assertTrue(TRUE);
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
- ->setConstructorArgs(array(
+ ->setConstructorArgs([
$this->root,
- array(
- 'module_handler_test' => array(
+ [
+ 'module_handler_test' => [
'type' => 'module',
'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml',
'filename' => 'module_handler_test.module',
- )
- ), $this->cacheBackend
- ))
- ->setMethods(array('loadInclude'))
+ ]
+ ], $this->cacheBackend
+ ])
+ ->setMethods(['loadInclude'])
->getMock();
// Ensure we reset implementations when settings a new modules list.
@@ -280,9 +280,9 @@ class ModuleHandlerTest extends UnitTestCase {
* @covers ::invoke
*/
public function testInvokeModuleEnabled() {
- $this->assertTrue($this->moduleHandler->invoke('module_handler_test', 'hook', array(TRUE)), 'Installed module runs hook.');
- $this->assertFalse($this->moduleHandler->invoke('module_handler_test', 'hook', array(FALSE)), 'Installed module runs hook.');
- $this->assertNull($this->moduleHandler->invoke('module_handler_test_fake', 'hook', array(FALSE)), 'Installed module runs hook.');
+ $this->assertTrue($this->moduleHandler->invoke('module_handler_test', 'hook', [TRUE]), 'Installed module runs hook.');
+ $this->assertFalse($this->moduleHandler->invoke('module_handler_test', 'hook', [FALSE]), 'Installed module runs hook.');
+ $this->assertNull($this->moduleHandler->invoke('module_handler_test_fake', 'hook', [FALSE]), 'Installed module runs hook.');
}
/**
@@ -298,7 +298,7 @@ class ModuleHandlerTest extends UnitTestCase {
$this->assertTrue($this->moduleHandler->implementsHook('module_handler_test_added', 'hook'), 'Runtime added module with implementation in include found.');
$this->moduleHandler->addModule('module_handler_test_no_hook', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_added');
- $this->assertFalse($this->moduleHandler->implementsHook('module_handler_test_no_hook', 'hook', array(TRUE)), 'Missing implementation not found.');
+ $this->assertFalse($this->moduleHandler->implementsHook('module_handler_test_no_hook', 'hook', [TRUE]), 'Missing implementation not found.');
}
/**
@@ -309,7 +309,7 @@ class ModuleHandlerTest extends UnitTestCase {
* @covers ::buildImplementationInfo
*/
public function testGetImplementations() {
- $this->assertEquals(array('module_handler_test'), $this->moduleHandler->getImplementations('hook'));
+ $this->assertEquals(['module_handler_test'], $this->moduleHandler->getImplementations('hook'));
}
/**
@@ -322,26 +322,26 @@ class ModuleHandlerTest extends UnitTestCase {
$this->cacheBackend->expects($this->exactly(1))
->method('get')
->will($this->onConsecutiveCalls(
- (object) array('data' => array('hook' => array('module_handler_test' => 'test')))
+ (object) ['data' => ['hook' => ['module_handler_test' => 'test']]]
));
// Ensure buildImplementationInfo doesn't get called and that we work off cached results.
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
- ->setConstructorArgs(array(
- $this->root, array(
- 'module_handler_test' => array(
+ ->setConstructorArgs([
+ $this->root, [
+ 'module_handler_test' => [
'type' => 'module',
'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml',
'filename' => 'module_handler_test.module',
- )
- ), $this->cacheBackend
- ))
- ->setMethods(array('buildImplementationInfo', 'loadInclude'))
+ ]
+ ], $this->cacheBackend
+ ])
+ ->setMethods(['buildImplementationInfo', 'loadInclude'])
->getMock();
$module_handler->expects($this->never())->method('buildImplementationInfo');
$module_handler->expects($this->once())->method('loadInclude');
- $this->assertEquals(array('module_handler_test'), $module_handler->getImplementations('hook'));
+ $this->assertEquals(['module_handler_test'], $module_handler->getImplementations('hook'));
}
/**
@@ -354,28 +354,28 @@ class ModuleHandlerTest extends UnitTestCase {
$this->cacheBackend->expects($this->exactly(1))
->method('get')
->will($this->onConsecutiveCalls(
- (object) array('data' => array('hook' => array(
- 'module_handler_test' => array(),
- 'module_handler_test_missing' => array(),
- )))
+ (object) ['data' => ['hook' => [
+ 'module_handler_test' => [],
+ 'module_handler_test_missing' => [],
+ ]]]
));
// Ensure buildImplementationInfo doesn't get called and that we work off cached results.
$module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandler')
- ->setConstructorArgs(array(
- $this->root, array(
- 'module_handler_test' => array(
+ ->setConstructorArgs([
+ $this->root, [
+ 'module_handler_test' => [
'type' => 'module',
'pathname' => 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml',
'filename' => 'module_handler_test.module',
- )
- ), $this->cacheBackend
- ))
- ->setMethods(array('buildImplementationInfo'))
+ ]
+ ], $this->cacheBackend
+ ])
+ ->setMethods(['buildImplementationInfo'])
->getMock();
$module_handler->expects($this->never())->method('buildImplementationInfo');
- $this->assertEquals(array('module_handler_test'), $module_handler->getImplementations('hook'));
+ $this->assertEquals(['module_handler_test'], $module_handler->getImplementations('hook'));
}
/**
@@ -386,7 +386,7 @@ class ModuleHandlerTest extends UnitTestCase {
public function testInvokeAll() {
$this->moduleHandler->addModule('module_handler_test_all1', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all1');
$this->moduleHandler->addModule('module_handler_test_all2', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all2');
- $this->assertEquals(array(TRUE, TRUE, TRUE), $this->moduleHandler->invokeAll('hook', array(TRUE)));
+ $this->assertEquals([TRUE, TRUE, TRUE], $this->moduleHandler->invokeAll('hook', [TRUE]));
}
/**
@@ -421,20 +421,20 @@ class ModuleHandlerTest extends UnitTestCase {
->method('get')
->will($this->onConsecutiveCalls(
NULL,
- (object) array('data' =>
- array('hook_foo' => array('group' => 'hook'))))
+ (object) ['data' =>
+ ['hook_foo' => ['group' => 'hook']]])
);
// Results from building from mocked environment.
- $this->assertEquals(array(
- 'hook' => array('group' => 'hook'),
- ), $this->moduleHandler->getHookInfo());
+ $this->assertEquals([
+ 'hook' => ['group' => 'hook'],
+ ], $this->moduleHandler->getHookInfo());
// Reset local cache so we get our synthetic result from the cache handler.
$this->moduleHandler->resetImplementations();
- $this->assertEquals(array(
- 'hook_foo' => array('group' => 'hook'),
- ), $this->moduleHandler->getHookInfo());
+ $this->assertEquals([
+ 'hook_foo' => ['group' => 'hook'],
+ ], $this->moduleHandler->getHookInfo());
}
/**
@@ -483,33 +483,33 @@ class ModuleHandlerTest extends UnitTestCase {
* Provider for testing dependency parsing.
*/
public function dependencyProvider() {
- return array(
- array('system', array('name' => 'system')),
- array('taxonomy', array('name' => 'taxonomy')),
- array('views', array('name' => 'views')),
- array('views_ui(8.x-1.0)', array('name' => 'views_ui', 'original_version' => ' (8.x-1.0)', 'versions' => array(array('op' => '=', 'version' => '1.0')))),
+ return [
+ ['system', ['name' => 'system']],
+ ['taxonomy', ['name' => 'taxonomy']],
+ ['views', ['name' => 'views']],
+ ['views_ui(8.x-1.0)', ['name' => 'views_ui', 'original_version' => ' (8.x-1.0)', 'versions' => [['op' => '=', 'version' => '1.0']]]],
// Not supported?.
// array('views_ui(8.x-1.1-beta)', array('name' => 'views_ui', 'original_version' => ' (8.x-1.1-beta)', 'versions' => array(array('op' => '=', 'version' => '1.1-beta')))),
- array('views_ui(8.x-1.1-alpha12)', array('name' => 'views_ui', 'original_version' => ' (8.x-1.1-alpha12)', 'versions' => array(array('op' => '=', 'version' => '1.1-alpha12')))),
- array('views_ui(8.x-1.1-beta8)', array('name' => 'views_ui', 'original_version' => ' (8.x-1.1-beta8)', 'versions' => array(array('op' => '=', 'version' => '1.1-beta8')))),
- array('views_ui(8.x-1.1-rc11)', array('name' => 'views_ui', 'original_version' => ' (8.x-1.1-rc11)', 'versions' => array(array('op' => '=', 'version' => '1.1-rc11')))),
- array('views_ui(8.x-1.12)', array('name' => 'views_ui', 'original_version' => ' (8.x-1.12)', 'versions' => array(array('op' => '=', 'version' => '1.12')))),
- array('views_ui(8.x-1.x)', array('name' => 'views_ui', 'original_version' => ' (8.x-1.x)', 'versions' => array(array('op' => '<', 'version' => '2.x'), array('op' => '>=', 'version' => '1.x')))),
- array('views_ui( <= 8.x-1.x)', array('name' => 'views_ui', 'original_version' => ' ( <= 8.x-1.x)', 'versions' => array(array('op' => '<=', 'version' => '2.x')))),
- array('views_ui(<= 8.x-1.x)', array('name' => 'views_ui', 'original_version' => ' (<= 8.x-1.x)', 'versions' => array(array('op' => '<=', 'version' => '2.x')))),
- array('views_ui( <=8.x-1.x)', array('name' => 'views_ui', 'original_version' => ' ( <=8.x-1.x)', 'versions' => array(array('op' => '<=', 'version' => '2.x')))),
- array('views_ui(>8.x-1.x)', array('name' => 'views_ui', 'original_version' => ' (>8.x-1.x)', 'versions' => array(array('op' => '>', 'version' => '2.x')))),
- array('drupal:views_ui(>8.x-1.x)', array('project' => 'drupal', 'name' => 'views_ui', 'original_version' => ' (>8.x-1.x)', 'versions' => array(array('op' => '>', 'version' => '2.x')))),
- );
+ ['views_ui(8.x-1.1-alpha12)', ['name' => 'views_ui', 'original_version' => ' (8.x-1.1-alpha12)', 'versions' => [['op' => '=', 'version' => '1.1-alpha12']]]],
+ ['views_ui(8.x-1.1-beta8)', ['name' => 'views_ui', 'original_version' => ' (8.x-1.1-beta8)', 'versions' => [['op' => '=', 'version' => '1.1-beta8']]]],
+ ['views_ui(8.x-1.1-rc11)', ['name' => 'views_ui', 'original_version' => ' (8.x-1.1-rc11)', 'versions' => [['op' => '=', 'version' => '1.1-rc11']]]],
+ ['views_ui(8.x-1.12)', ['name' => 'views_ui', 'original_version' => ' (8.x-1.12)', 'versions' => [['op' => '=', 'version' => '1.12']]]],
+ ['views_ui(8.x-1.x)', ['name' => 'views_ui', 'original_version' => ' (8.x-1.x)', 'versions' => [['op' => '<', 'version' => '2.x'], ['op' => '>=', 'version' => '1.x']]]],
+ ['views_ui( <= 8.x-1.x)', ['name' => 'views_ui', 'original_version' => ' ( <= 8.x-1.x)', 'versions' => [['op' => '<=', 'version' => '2.x']]]],
+ ['views_ui(<= 8.x-1.x)', ['name' => 'views_ui', 'original_version' => ' (<= 8.x-1.x)', 'versions' => [['op' => '<=', 'version' => '2.x']]]],
+ ['views_ui( <=8.x-1.x)', ['name' => 'views_ui', 'original_version' => ' ( <=8.x-1.x)', 'versions' => [['op' => '<=', 'version' => '2.x']]]],
+ ['views_ui(>8.x-1.x)', ['name' => 'views_ui', 'original_version' => ' (>8.x-1.x)', 'versions' => [['op' => '>', 'version' => '2.x']]]],
+ ['drupal:views_ui(>8.x-1.x)', ['project' => 'drupal', 'name' => 'views_ui', 'original_version' => ' (>8.x-1.x)', 'versions' => [['op' => '>', 'version' => '2.x']]]],
+ ];
}
/**
* @covers ::getModuleDirectories
*/
public function testGetModuleDirectories() {
- $this->moduleHandler->setModuleList(array());
+ $this->moduleHandler->setModuleList([]);
$this->moduleHandler->addModule('module', 'place');
- $this->assertEquals(array('module' => $this->root . '/place'), $this->moduleHandler->getModuleDirectories());
+ $this->assertEquals(['module' => $this->root . '/place'], $this->moduleHandler->getModuleDirectories());
}
}
diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
index 5045d831c29..8c105f25ae8 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
@@ -70,15 +70,15 @@ class ThemeHandlerTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- $this->configFactory = $this->getConfigFactoryStub(array(
- 'core.extension' => array(
- 'module' => array(),
- 'theme' => array(),
- 'disabled' => array(
- 'theme' => array(),
- ),
- ),
- ));
+ $this->configFactory = $this->getConfigFactoryStub([
+ 'core.extension' => [
+ 'module' => [],
+ 'theme' => [],
+ 'disabled' => [
+ 'theme' => [],
+ ],
+ ],
+ ]);
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend('test'), new NullLockBackend());
$this->infoParser = $this->getMock('Drupal\Core\Extension\InfoParserInterface');
@@ -100,15 +100,15 @@ class ThemeHandlerTest extends UnitTestCase {
$this->extensionDiscovery->expects($this->at(0))
->method('scan')
->with('theme')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'seven' => new Extension($this->root, 'theme', $this->root . '/core/themes/seven/seven.info.yml', 'seven.theme'),
- )));
+ ]));
$this->extensionDiscovery->expects($this->at(1))
->method('scan')
->with('theme_engine')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'twig' => new Extension($this->root, 'theme_engine', $this->root . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'),
- )));
+ ]));
$this->infoParser->expects($this->once())
->method('parse')
->with($this->root . '/core/themes/seven/seven.info.yml')
@@ -136,7 +136,7 @@ class ThemeHandlerTest extends UnitTestCase {
$this->assertEquals('twig', $info->prefix);
$this->assertEquals('twig', $info->info['engine']);
- $this->assertEquals(array('seven/global-styling'), $info->info['libraries']);
+ $this->assertEquals(['seven/global-styling'], $info->info['libraries']);
}
/**
@@ -160,16 +160,16 @@ class ThemeHandlerTest extends UnitTestCase {
$this->extensionDiscovery->expects($this->at(0))
->method('scan')
->with('theme')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'test_subtheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml', 'test_subtheme.info.yml'),
'test_basetheme' => new Extension($this->root, 'theme', $this->root . '/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml', 'test_basetheme.info.yml'),
- )));
+ ]));
$this->extensionDiscovery->expects($this->at(1))
->method('scan')
->with('theme_engine')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'twig' => new Extension($this->root, 'theme_engine', $this->root . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'),
- )));
+ ]));
$this->infoParser->expects($this->at(0))
->method('parse')
->with($this->root . '/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml')
@@ -202,7 +202,7 @@ class ThemeHandlerTest extends UnitTestCase {
// Test the parent/child-theme properties.
$info_subtheme->info['base theme'] = 'test_basetheme';
- $info_basetheme->sub_themes = array('test_subtheme');
+ $info_basetheme->sub_themes = ['test_subtheme'];
$this->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info_basetheme->owner);
$this->assertEquals('twig', $info_basetheme->prefix);
@@ -234,73 +234,73 @@ class ThemeHandlerTest extends UnitTestCase {
* An array of theme test data.
*/
public function providerTestGetBaseThemes() {
- $data = array();
+ $data = [];
// Tests a theme without any base theme.
- $themes = array();
- $themes['test_1'] = (object) array(
+ $themes = [];
+ $themes['test_1'] = (object) [
'name' => 'test_1',
- 'info' => array(
+ 'info' => [
'name' => 'test_1',
- ),
- );
- $data[] = array($themes, 'test_1', array());
+ ],
+ ];
+ $data[] = [$themes, 'test_1', []];
// Tests a theme with a non existing base theme.
- $themes = array();
- $themes['test_1'] = (object) array(
+ $themes = [];
+ $themes['test_1'] = (object) [
'name' => 'test_1',
- 'info' => array(
+ 'info' => [
'name' => 'test_1',
'base theme' => 'test_2',
- ),
- );
- $data[] = array($themes, 'test_1', array('test_2' => NULL));
+ ],
+ ];
+ $data[] = [$themes, 'test_1', ['test_2' => NULL]];
// Tests a theme with a single existing base theme.
- $themes = array();
- $themes['test_1'] = (object) array(
+ $themes = [];
+ $themes['test_1'] = (object) [
'name' => 'test_1',
- 'info' => array(
+ 'info' => [
'name' => 'test_1',
'base theme' => 'test_2',
- ),
- );
- $themes['test_2'] = (object) array(
+ ],
+ ];
+ $themes['test_2'] = (object) [
'name' => 'test_2',
- 'info' => array(
+ 'info' => [
'name' => 'test_2',
- ),
- );
- $data[] = array($themes, 'test_1', array('test_2' => 'test_2'));
+ ],
+ ];
+ $data[] = [$themes, 'test_1', ['test_2' => 'test_2']];
// Tests a theme with multiple base themes.
- $themes = array();
- $themes['test_1'] = (object) array(
+ $themes = [];
+ $themes['test_1'] = (object) [
'name' => 'test_1',
- 'info' => array(
+ 'info' => [
'name' => 'test_1',
'base theme' => 'test_2',
- ),
- );
- $themes['test_2'] = (object) array(
+ ],
+ ];
+ $themes['test_2'] = (object) [
'name' => 'test_2',
- 'info' => array(
+ 'info' => [
'name' => 'test_2',
'base theme' => 'test_3',
- ),
- );
- $themes['test_3'] = (object) array(
+ ],
+ ];
+ $themes['test_3'] = (object) [
'name' => 'test_3',
- 'info' => array(
+ 'info' => [
'name' => 'test_3',
- ),
- );
- $data[] = array(
+ ],
+ ];
+ $data[] = [
$themes,
'test_1',
- array('test_2' => 'test_2', 'test_3' => 'test_3'),
- );
+ ['test_2' => 'test_2', 'test_3' => 'test_3'],
+ ];
return $data;
}
diff --git a/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module
index 18bf23c3517..3e0d59c6807 100644
--- a/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module
+++ b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module
@@ -9,9 +9,9 @@
* Implements hook_hook_info().
*/
function module_handler_test_hook_info() {
- return array(
- 'hook' => array('group' => 'hook'),
- );
+ return [
+ 'hook' => ['group' => 'hook'],
+ ];
}
function module_handler_test_hook($arg) { return $arg; }
diff --git a/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all1/module_handler_test_all1.module b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all1/module_handler_test_all1.module
index 4689c02ce42..563b7a5c2da 100644
--- a/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all1/module_handler_test_all1.module
+++ b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all1/module_handler_test_all1.module
@@ -8,4 +8,4 @@
/**
* Returns an array to test nested merge in invoke all.
*/
-function module_handler_test_all1_hook($arg) { return array($arg); }
+function module_handler_test_all1_hook($arg) { return [$arg]; }
diff --git a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php
index 9ee719eddfd..01d0bb2686c 100644
--- a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php
+++ b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php
@@ -77,7 +77,7 @@ class FieldDefinitionListenerTest extends UnitTestCase {
* @param \Drupal\Core\Entity\EntityTypeInterface[]|\Prophecy\Prophecy\ProphecyInterface[] $definitions
* (optional) An array of entity type definitions.
*/
- protected function setUpEntityManager($definitions = array()) {
+ protected function setUpEntityManager($definitions = []) {
$class = $this->getMockClass(EntityInterface::class);
foreach ($definitions as $key => $entity_type) {
// \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
diff --git a/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php b/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php
index 9440d08fafb..15f52a6dc8c 100644
--- a/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php
@@ -71,12 +71,12 @@ class ConfirmFormHelperTest extends UnitTestCase {
*/
public function testCancelLinkRouteWithUrl() {
$cancel_route = new Url(
- 'foo_bar.baz', array(
+ 'foo_bar.baz', [
'baz' => 'banana',
- ),
- array(
+ ],
+ [
'absolute' => TRUE,
- )
+ ]
);
$form = $this->getMock('Drupal\Core\Form\ConfirmFormInterface');
$form->expects($this->any())
@@ -95,7 +95,7 @@ class ConfirmFormHelperTest extends UnitTestCase {
* @dataProvider providerTestCancelLinkDestination
*/
public function testCancelLinkDestination($destination) {
- $query = array('destination' => $destination);
+ $query = ['destination' => $destination];
$form = $this->getMock('Drupal\Core\Form\ConfirmFormInterface');
$path_validator = $this->getMock('Drupal\Core\Path\PathValidatorInterface');
diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
index dfbf843a0c7..0b6ccff6702 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
@@ -171,10 +171,10 @@ class FormBuilderTest extends FormTestBase {
* Provides test data for testHandleFormStateResponse().
*/
public function formStateResponseProvider() {
- return array(
- array('Symfony\Component\HttpFoundation\Response', 'response'),
- array('Symfony\Component\HttpFoundation\RedirectResponse', 'redirect'),
- );
+ return [
+ ['Symfony\Component\HttpFoundation\Response', 'response'],
+ ['Symfony\Component\HttpFoundation\RedirectResponse', 'redirect'],
+ ];
}
/**
@@ -251,7 +251,7 @@ class FormBuilderTest extends FormTestBase {
public function testGetFormWithClassString() {
$form_id = '\Drupal\Tests\Core\Form\TestForm';
$object = new TestForm();
- $form = array();
+ $form = [];
$form_state = new FormState();
$expected_form = $object->buildForm($form, $form_state);
@@ -281,7 +281,7 @@ class FormBuilderTest extends FormTestBase {
public function testBuildFormWithClassString() {
$form_id = '\Drupal\Tests\Core\Form\TestForm';
$object = new TestForm();
- $form = array();
+ $form = [];
$form_state = new FormState();
$expected_form = $object->buildForm($form, $form_state);
diff --git a/core/tests/Drupal/Tests/Core/Form/FormHelperTest.php b/core/tests/Drupal/Tests/Core/Form/FormHelperTest.php
index 1ef17e9e9a5..f60b8e64c13 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormHelperTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormHelperTest.php
@@ -19,65 +19,65 @@ class FormHelperTest extends UnitTestCase {
function testRewriteStatesSelector() {
// Simple selectors.
- $value = array('value' => 'medium');
- $form['foo']['#states'] = array(
- 'visible' => array(
+ $value = ['value' => 'medium'];
+ $form['foo']['#states'] = [
+ 'visible' => [
'select[name="fields[foo-id][settings_edit_form][settings][image_style]"]' => $value,
- ),
- );
+ ],
+ ];
FormHelper::rewriteStatesSelector($form, 'fields[foo-id][settings_edit_form]', 'options');
$expected_selector = 'select[name="options[settings][image_style]"]';
$this->assertSame($form['foo']['#states']['visible'][$expected_selector], $value, 'The #states selector was not properly rewritten.');
// Complex selectors.
- $form = array();
- $form['bar']['#states'] = array(
- 'visible' => array(
- array(
- ':input[name="menu[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="menu[type]"]' => array('value' => 'tab'),
- ),
- ':input[name="menu[type]"]' => array('value' => 'default tab'),
- ),
+ $form = [];
+ $form['bar']['#states'] = [
+ 'visible' => [
+ [
+ ':input[name="menu[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="menu[type]"]' => ['value' => 'tab'],
+ ],
+ ':input[name="menu[type]"]' => ['value' => 'default tab'],
+ ],
// Example from https://www.drupal.org/node/1464758
- 'disabled' => array(
- '[name="menu[options][dependee_1]"]' => array('value' => 'ON'),
- array(
- array('[name="menu[options][dependee_2]"]' => array('value' => 'ON')),
- array('[name="menu[options][dependee_3]"]' => array('value' => 'ON')),
- ),
- array(
- array('[name="menu[options][dependee_4]"]' => array('value' => 'ON')),
+ 'disabled' => [
+ '[name="menu[options][dependee_1]"]' => ['value' => 'ON'],
+ [
+ ['[name="menu[options][dependee_2]"]' => ['value' => 'ON']],
+ ['[name="menu[options][dependee_3]"]' => ['value' => 'ON']],
+ ],
+ [
+ ['[name="menu[options][dependee_4]"]' => ['value' => 'ON']],
'xor',
- array('[name="menu[options][dependee_5]"]' => array('value' => 'ON')),
- ),
- ),
- );
- $expected['bar']['#states'] = array(
- 'visible' => array(
- array(
- ':input[name="options[type]"]' => array('value' => 'normal'),
- ),
- array(
- ':input[name="options[type]"]' => array('value' => 'tab'),
- ),
- ':input[name="options[type]"]' => array('value' => 'default tab'),
- ),
- 'disabled' => array(
- '[name="options[options][dependee_1]"]' => array('value' => 'ON'),
- array(
- array('[name="options[options][dependee_2]"]' => array('value' => 'ON')),
- array('[name="options[options][dependee_3]"]' => array('value' => 'ON')),
- ),
- array(
- array('[name="options[options][dependee_4]"]' => array('value' => 'ON')),
+ ['[name="menu[options][dependee_5]"]' => ['value' => 'ON']],
+ ],
+ ],
+ ];
+ $expected['bar']['#states'] = [
+ 'visible' => [
+ [
+ ':input[name="options[type]"]' => ['value' => 'normal'],
+ ],
+ [
+ ':input[name="options[type]"]' => ['value' => 'tab'],
+ ],
+ ':input[name="options[type]"]' => ['value' => 'default tab'],
+ ],
+ 'disabled' => [
+ '[name="options[options][dependee_1]"]' => ['value' => 'ON'],
+ [
+ ['[name="options[options][dependee_2]"]' => ['value' => 'ON']],
+ ['[name="options[options][dependee_3]"]' => ['value' => 'ON']],
+ ],
+ [
+ ['[name="options[options][dependee_4]"]' => ['value' => 'ON']],
'xor',
- array('[name="options[options][dependee_5]"]' => array('value' => 'ON')),
- ),
- ),
- );
+ ['[name="options[options][dependee_5]"]' => ['value' => 'ON']],
+ ],
+ ],
+ ];
FormHelper::rewriteStatesSelector($form, 'menu', 'options');
$this->assertSame($expected, $form, 'The #states selectors were properly rewritten.');
}
diff --git a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php
index 69118a8f77e..0da2fe0de0c 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php
@@ -41,17 +41,17 @@ class FormStateTest extends UnitTestCase {
* Returns some test data.
*/
public function providerTestGetRedirect() {
- $data = array();
- $data[] = array(array(), NULL);
+ $data = [];
+ $data[] = [[], NULL];
$redirect = new RedirectResponse('/example');
- $data[] = array(array('redirect' => $redirect), $redirect);
+ $data[] = [['redirect' => $redirect], $redirect];
- $data[] = array(array('redirect' => new Url('test_route_b', array('key' => 'value'))), new Url('test_route_b', array('key' => 'value')));
+ $data[] = [['redirect' => new Url('test_route_b', ['key' => 'value'])], new Url('test_route_b', ['key' => 'value'])];
- $data[] = array(array('programmed' => TRUE), NULL);
- $data[] = array(array('rebuild' => TRUE), NULL);
- $data[] = array(array('no_redirect' => TRUE), NULL);
+ $data[] = [['programmed' => TRUE], NULL];
+ $data[] = [['rebuild' => TRUE], NULL];
+ $data[] = [['no_redirect' => TRUE], NULL];
return $data;
}
@@ -63,7 +63,7 @@ class FormStateTest extends UnitTestCase {
*/
public function testSetError() {
$form_state = new FormState();
- $element['#parents'] = array('foo', 'bar');
+ $element['#parents'] = ['foo', 'bar'];
$form_state->setError($element, 'Fail');
$this->assertSame(['foo][bar' => 'Fail'], $form_state->getErrors());
}
@@ -84,18 +84,18 @@ class FormStateTest extends UnitTestCase {
}
public function providerTestGetError() {
- return array(
- array(array(), array('foo')),
- array(array('foo][bar' => 'Fail'), array()),
- array(array('foo][bar' => 'Fail'), array('foo')),
- array(array('foo][bar' => 'Fail'), array('bar')),
- array(array('foo][bar' => 'Fail'), array('baz')),
- array(array('foo][bar' => 'Fail'), array('foo', 'bar'), 'Fail'),
- array(array('foo][bar' => 'Fail'), array('foo', 'bar', 'baz'), 'Fail'),
- array(array('foo][bar' => 'Fail 2'), array('foo')),
- array(array('foo' => 'Fail 1', 'foo][bar' => 'Fail 2'), array('foo'), 'Fail 1'),
- array(array('foo' => 'Fail 1', 'foo][bar' => 'Fail 2'), array('foo', 'bar'), 'Fail 1'),
- );
+ return [
+ [[], ['foo']],
+ [['foo][bar' => 'Fail'], []],
+ [['foo][bar' => 'Fail'], ['foo']],
+ [['foo][bar' => 'Fail'], ['bar']],
+ [['foo][bar' => 'Fail'], ['baz']],
+ [['foo][bar' => 'Fail'], ['foo', 'bar'], 'Fail'],
+ [['foo][bar' => 'Fail'], ['foo', 'bar', 'baz'], 'Fail'],
+ [['foo][bar' => 'Fail 2'], ['foo']],
+ [['foo' => 'Fail 1', 'foo][bar' => 'Fail 2'], ['foo'], 'Fail 1'],
+ [['foo' => 'Fail 1', 'foo][bar' => 'Fail 2'], ['foo', 'bar'], 'Fail 1'],
+ ];
}
/**
@@ -117,15 +117,15 @@ class FormStateTest extends UnitTestCase {
}
public function providerTestSetErrorByName() {
- return array(
+ return [
// Only validate the 'options' element.
- array(array(array('options')), array('options' => '')),
+ [[['options']], ['options' => '']],
// Do not limit an validation, and, ensuring the first error is returned
// for the 'test' element.
[NULL, ['test' => 'Fail 1', 'options' => '']],
// Limit all validation.
- array(array(), array()),
- );
+ [[], []],
+ ];
}
/**
@@ -182,7 +182,7 @@ class FormStateTest extends UnitTestCase {
$module = 'some_module';
$name = 'some_name';
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('moduleLoadInclude'))
+ ->setMethods(['moduleLoadInclude'])
->getMock();
$form_state->expects($this->once())
->method('moduleLoadInclude')
@@ -198,7 +198,7 @@ class FormStateTest extends UnitTestCase {
$type = 'some_type';
$module = 'some_module';
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('moduleLoadInclude'))
+ ->setMethods(['moduleLoadInclude'])
->getMock();
$form_state->expects($this->once())
->method('moduleLoadInclude')
@@ -214,7 +214,7 @@ class FormStateTest extends UnitTestCase {
$type = 'some_type';
$module = 'some_module';
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('moduleLoadInclude'))
+ ->setMethods(['moduleLoadInclude'])
->getMock();
$form_state->expects($this->once())
->method('moduleLoadInclude')
@@ -231,7 +231,7 @@ class FormStateTest extends UnitTestCase {
$module = 'some_module';
$name = 'some_name';
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('moduleLoadInclude'))
+ ->setMethods(['moduleLoadInclude'])
->getMock();
$form_state->addBuildInfo('files', [
@@ -376,9 +376,9 @@ class FormStateTest extends UnitTestCase {
$form_state->setTemporaryValue('rainbow_sparkles', 'yes please');
$this->assertSame($form_state->getTemporaryValue('rainbow_sparkles'), 'yes please');
$this->assertTrue($form_state->hasTemporaryValue('rainbow_sparkles'), TRUE);
- $form_state->setTemporaryValue(array('rainbow_sparkles', 'magic_ponies'), 'yes please');
- $this->assertSame($form_state->getTemporaryValue(array('rainbow_sparkles', 'magic_ponies')), 'yes please');
- $this->assertTrue($form_state->hasTemporaryValue(array('rainbow_sparkles', 'magic_ponies')), TRUE);
+ $form_state->setTemporaryValue(['rainbow_sparkles', 'magic_ponies'], 'yes please');
+ $this->assertSame($form_state->getTemporaryValue(['rainbow_sparkles', 'magic_ponies']), 'yes please');
+ $this->assertTrue($form_state->hasTemporaryValue(['rainbow_sparkles', 'magic_ponies']), TRUE);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
index 6c8a6ebe653..15df6f65e94 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
@@ -46,7 +46,7 @@ class FormSubmitterTest extends UnitTestCase {
*/
public function testHandleFormSubmissionNotSubmitted() {
$form_submitter = $this->getFormSubmitter();
- $form = array();
+ $form = [];
$form_state = new FormState();
$return = $form_submitter->doSubmitForm($form, $form_state);
@@ -59,7 +59,7 @@ class FormSubmitterTest extends UnitTestCase {
*/
public function testHandleFormSubmissionNoRedirect() {
$form_submitter = $this->getFormSubmitter();
- $form = array();
+ $form = [];
$form_state = (new FormState())
->setSubmitted()
->disableRedirect();
@@ -87,17 +87,17 @@ class FormSubmitterTest extends UnitTestCase {
->setFormState([$form_state_key => $response]);
$form_submitter = $this->getFormSubmitter();
- $form = array();
+ $form = [];
$return = $form_submitter->doSubmitForm($form, $form_state);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $return);
}
public function providerTestHandleFormSubmissionWithResponses() {
- return array(
- array('Symfony\Component\HttpFoundation\Response', 'response'),
- array('Symfony\Component\HttpFoundation\RedirectResponse', 'redirect'),
- );
+ return [
+ ['Symfony\Component\HttpFoundation\Response', 'response'],
+ ['Symfony\Component\HttpFoundation\RedirectResponse', 'redirect'],
+ ];
}
/**
@@ -138,10 +138,10 @@ class FormSubmitterTest extends UnitTestCase {
$form_submitter = $this->getFormSubmitter();
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->will($this->returnValueMap(array(
- array('test_route_a', array(), array('absolute' => TRUE), FALSE, 'test-route'),
- array('test_route_b', array('key' => 'value'), array('absolute' => TRUE), FALSE, 'test-route/value'),
- ))
+ ->will($this->returnValueMap([
+ ['test_route_a', [], ['absolute' => TRUE], FALSE, 'test-route'],
+ ['test_route_b', ['key' => 'value'], ['absolute' => TRUE], FALSE, 'test-route/value'],
+ ])
);
$form_state = $this->getMock('Drupal\Core\Form\FormStateInterface');
@@ -160,10 +160,10 @@ class FormSubmitterTest extends UnitTestCase {
* Returns some test data.
*/
public function providerTestRedirectWithUrl() {
- return array(
- array(new Url('test_route_a', array(), array('absolute' => TRUE)), 'test-route'),
- array(new Url('test_route_b', array('key' => 'value'), array('absolute' => TRUE)), 'test-route/value'),
- );
+ return [
+ [new Url('test_route_a', [], ['absolute' => TRUE]), 'test-route'],
+ [new Url('test_route_b', ['key' => 'value'], ['absolute' => TRUE]), 'test-route/value'],
+ ];
}
/**
@@ -223,11 +223,11 @@ class FormSubmitterTest extends UnitTestCase {
->method('simple_string_submit')
->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'));
- $form = array();
+ $form = [];
$form_state = new FormState();
$form_submitter->executeSubmitHandlers($form, $form_state);
- $form['#submit'][] = array($mock, 'hash_submit');
+ $form['#submit'][] = [$mock, 'hash_submit'];
$form_submitter->executeSubmitHandlers($form, $form_state);
// $form_state submit handlers will supersede $form handlers.
@@ -248,8 +248,8 @@ class FormSubmitterTest extends UnitTestCase {
$request_stack = new RequestStack();
$request_stack->push(Request::create('/test-path'));
return $this->getMockBuilder('Drupal\Core\Form\FormSubmitter')
- ->setConstructorArgs(array($request_stack, $this->urlGenerator))
- ->setMethods(array('batchGet', 'drupalInstallationAttempted'))
+ ->setConstructorArgs([$request_stack, $this->urlGenerator])
+ ->setMethods(['batchGet', 'drupalInstallationAttempted'])
->getMock();
}
diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
index 078d30ed9c8..ef08ab77e2c 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
@@ -163,7 +163,7 @@ abstract class FormTestBase extends UnitTestCase {
->getMock();
$this->elementInfo->expects($this->any())
->method('getInfo')
- ->will($this->returnCallback(array($this, 'getInfo')));
+ ->will($this->returnCallback([$this, 'getInfo']));
$this->csrfToken = $this->getMockBuilder('Drupal\Core\Access\CsrfTokenGenerator')
->disableOriginalConstructor()
@@ -184,8 +184,8 @@ abstract class FormTestBase extends UnitTestCase {
->setMethods(NULL)
->getMock();
$this->formSubmitter = $this->getMockBuilder('Drupal\Core\Form\FormSubmitter')
- ->setConstructorArgs(array($this->requestStack, $this->urlGenerator))
- ->setMethods(array('batchGet', 'drupalInstallationAttempted'))
+ ->setConstructorArgs([$this->requestStack, $this->urlGenerator])
+ ->setMethods(['batchGet', 'drupalInstallationAttempted'])
->getMock();
$this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
@@ -290,25 +290,25 @@ abstract class FormTestBase extends UnitTestCase {
$types['hidden'] = [
'#input' => TRUE,
];
- $types['token'] = array(
+ $types['token'] = [
'#input' => TRUE,
- );
- $types['value'] = array(
+ ];
+ $types['value'] = [
'#input' => TRUE,
- );
- $types['radios'] = array(
+ ];
+ $types['radios'] = [
'#input' => TRUE,
- );
- $types['textfield'] = array(
+ ];
+ $types['textfield'] = [
'#input' => TRUE,
- );
- $types['submit'] = array(
+ ];
+ $types['submit'] = [
'#input' => TRUE,
'#name' => 'op',
'#is_button' => TRUE,
- );
+ ];
if (!isset($types[$type])) {
- $types[$type] = array();
+ $types[$type] = [];
}
return $types[$type];
}
diff --git a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
index e172e05fe2a..18f0be287a0 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
@@ -58,7 +58,7 @@ class FormValidatorTest extends UnitTestCase {
->setMethods(NULL)
->getMock();
- $form = array();
+ $form = [];
$form_state = new FormState();
$this->assertFalse($form_state->isValidationComplete());
$form_validator->validateForm('test_form_id', $form, $form_state);
@@ -73,12 +73,12 @@ class FormValidatorTest extends UnitTestCase {
public function testPreventDuplicateValidation() {
$form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
->setConstructorArgs([new RequestStack(), $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
- ->setMethods(array('doValidateForm'))
+ ->setMethods(['doValidateForm'])
->getMock();
$form_validator->expects($this->never())
->method('doValidateForm');
- $form = array();
+ $form = [];
$form_state = (new FormState())
->setValidationComplete();
$form_validator->validateForm('test_form_id', $form, $form_state);
@@ -93,14 +93,14 @@ class FormValidatorTest extends UnitTestCase {
public function testMustValidate() {
$form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
->setConstructorArgs([new RequestStack(), $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
- ->setMethods(array('doValidateForm'))
+ ->setMethods(['doValidateForm'])
->getMock();
$form_validator->expects($this->once())
->method('doValidateForm');
$this->formErrorHandler->expects($this->once())
->method('handleFormErrors');
- $form = array();
+ $form = [];
$form_state = (new FormState())
->setValidationComplete()
->setValidationEnforced();
@@ -112,7 +112,7 @@ class FormValidatorTest extends UnitTestCase {
*/
public function testValidateInvalidFormToken() {
$request_stack = new RequestStack();
- $request = new Request(array(), array(), array(), array(), array(), array('REQUEST_URI' => '/test/example?foo=bar'));
+ $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/test/example?foo=bar']);
$request_stack->push($request);
$this->csrfToken->expects($this->once())
->method('validate')
@@ -120,14 +120,14 @@ class FormValidatorTest extends UnitTestCase {
$form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
->setConstructorArgs([$request_stack, $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
- ->setMethods(array('doValidateForm'))
+ ->setMethods(['doValidateForm'])
->getMock();
$form_validator->expects($this->never())
->method('doValidateForm');
$form['#token'] = 'test_form_id';
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('setErrorByName'))
+ ->setMethods(['setErrorByName'])
->getMock();
$form_state->expects($this->once())
->method('setErrorByName')
@@ -148,14 +148,14 @@ class FormValidatorTest extends UnitTestCase {
$form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
->setConstructorArgs([$request_stack, $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
- ->setMethods(array('doValidateForm'))
+ ->setMethods(['doValidateForm'])
->getMock();
$form_validator->expects($this->once())
->method('doValidateForm');
$form['#token'] = 'test_form_id';
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('setErrorByName'))
+ ->setMethods(['setErrorByName'])
->getMock();
$form_state->expects($this->never())
->method('setErrorByName');
@@ -176,7 +176,7 @@ class FormValidatorTest extends UnitTestCase {
->getMock();
$triggering_element['#limit_validation_errors'] = $sections;
- $form = array();
+ $form = [];
$form_state = (new FormState())
->setValues($values)
->setTriggeringElement($triggering_element);
@@ -186,80 +186,80 @@ class FormValidatorTest extends UnitTestCase {
}
public function providerTestHandleErrorsWithLimitedValidation() {
- return array(
+ return [
// Test with a non-existent section.
- array(
- array(array('test1'), array('test3')),
- array(),
- array(
+ [
+ [['test1'], ['test3']],
+ [],
+ [
'test1' => 'foo',
'test2' => 'bar',
- ),
- array(
+ ],
+ [
'test1' => 'foo',
- ),
- ),
+ ],
+ ],
// Test with buttons in a non-validated section.
- array(
- array(array('test1')),
- array(
+ [
+ [['test1']],
+ [
'#is_button' => TRUE,
'#value' => 'baz',
'#name' => 'op',
- '#parents' => array('submit'),
- ),
- array(
+ '#parents' => ['submit'],
+ ],
+ [
'test1' => 'foo',
'test2' => 'bar',
'op' => 'baz',
'submit' => 'baz',
- ),
- array(
+ ],
+ [
'test1' => 'foo',
'submit' => 'baz',
'op' => 'baz',
- ),
- ),
+ ],
+ ],
// Test with a matching button #value and $form_state value.
- array(
- array(array('submit')),
- array(
+ [
+ [['submit']],
+ [
'#is_button' => TRUE,
'#value' => 'baz',
'#name' => 'op',
- '#parents' => array('submit'),
- ),
- array(
+ '#parents' => ['submit'],
+ ],
+ [
'test1' => 'foo',
'test2' => 'bar',
'op' => 'baz',
'submit' => 'baz',
- ),
- array(
+ ],
+ [
'submit' => 'baz',
'op' => 'baz',
- ),
- ),
+ ],
+ ],
// Test with a mismatched button #value and $form_state value.
- array(
- array(array('submit')),
- array(
+ [
+ [['submit']],
+ [
'#is_button' => TRUE,
'#value' => 'bar',
'#name' => 'op',
- '#parents' => array('submit'),
- ),
- array(
+ '#parents' => ['submit'],
+ ],
+ [
'test1' => 'foo',
'test2' => 'bar',
'op' => 'baz',
'submit' => 'baz',
- ),
- array(
+ ],
+ [
'submit' => 'baz',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -270,7 +270,7 @@ class FormValidatorTest extends UnitTestCase {
->setConstructorArgs([new RequestStack(), $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
->setMethods(NULL)
->getMock();
- $mock = $this->getMock('stdClass', array('validate_handler', 'hash_validate'));
+ $mock = $this->getMock('stdClass', ['validate_handler', 'hash_validate']);
$mock->expects($this->once())
->method('validate_handler')
->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'));
@@ -278,11 +278,11 @@ class FormValidatorTest extends UnitTestCase {
->method('hash_validate')
->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'));
- $form = array();
+ $form = [];
$form_state = new FormState();
$form_validator->executeValidateHandlers($form, $form_state);
- $form['#validate'][] = array($mock, 'hash_validate');
+ $form['#validate'][] = [$mock, 'hash_validate'];
$form_validator->executeValidateHandlers($form, $form_state);
// $form_state validate handlers will supersede $form handlers.
@@ -299,21 +299,21 @@ class FormValidatorTest extends UnitTestCase {
public function testRequiredErrorMessage($element, $expected_message) {
$form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
->setConstructorArgs([new RequestStack(), $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
- ->setMethods(array('executeValidateHandlers'))
+ ->setMethods(['executeValidateHandlers'])
->getMock();
$form_validator->expects($this->once())
->method('executeValidateHandlers');
- $form = array();
- $form['test'] = $element + array(
+ $form = [];
+ $form['test'] = $element + [
'#type' => 'textfield',
'#value' => '',
'#needs_validation' => TRUE,
'#required' => TRUE,
- '#parents' => array('test'),
- );
+ '#parents' => ['test'],
+ ];
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('setError'))
+ ->setMethods(['setError'])
->getMock();
$form_state->expects($this->once())
->method('setError')
@@ -322,23 +322,23 @@ class FormValidatorTest extends UnitTestCase {
}
public function providerTestRequiredErrorMessage() {
- return array(
- array(
+ return [
+ [
// Use the default message with a title.
- array('#title' => 'Test'),
+ ['#title' => 'Test'],
'Test field is required.',
- ),
+ ],
// Use a custom message.
- array(
- array('#required_error' => 'FAIL'),
+ [
+ ['#required_error' => 'FAIL'],
'FAIL',
- ),
+ ],
// No title or custom message.
- array(
- array(),
+ [
+ [],
'',
- ),
- );
+ ],
+ ];
}
/**
@@ -347,22 +347,22 @@ class FormValidatorTest extends UnitTestCase {
public function testElementValidate() {
$form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
->setConstructorArgs([new RequestStack(), $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
- ->setMethods(array('executeValidateHandlers'))
+ ->setMethods(['executeValidateHandlers'])
->getMock();
$form_validator->expects($this->once())
->method('executeValidateHandlers');
- $mock = $this->getMock('stdClass', array('element_validate'));
+ $mock = $this->getMock('stdClass', ['element_validate']);
$mock->expects($this->once())
->method('element_validate')
->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'), NULL);
- $form = array();
- $form['test'] = array(
+ $form = [];
+ $form['test'] = [
'#type' => 'textfield',
'#title' => 'Test',
- '#parents' => array('test'),
- '#element_validate' => array(array($mock, 'element_validate')),
- );
+ '#parents' => ['test'],
+ '#element_validate' => [[$mock, 'element_validate']],
+ ];
$form_state = new FormState();
$form_validator->validateForm('test_form_id', $form, $form_state);
}
@@ -375,7 +375,7 @@ class FormValidatorTest extends UnitTestCase {
public function testPerformRequiredValidation($element, $expected_message, $call_watchdog) {
$form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
->setConstructorArgs([new RequestStack(), $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
- ->setMethods(array('setError'))
+ ->setMethods(['setError'])
->getMock();
if ($call_watchdog) {
@@ -384,15 +384,15 @@ class FormValidatorTest extends UnitTestCase {
->with($this->isType('string'), $this->isType('array'));
}
- $form = array();
- $form['test'] = $element + array(
+ $form = [];
+ $form['test'] = $element + [
'#title' => 'Test',
'#needs_validation' => TRUE,
'#required' => FALSE,
- '#parents' => array('test'),
- );
+ '#parents' => ['test'],
+ ];
$form_state = $this->getMockBuilder('Drupal\Core\Form\FormState')
- ->setMethods(array('setError'))
+ ->setMethods(['setError'])
->getMock();
$form_state->expects($this->once())
->method('setError')
@@ -401,71 +401,71 @@ class FormValidatorTest extends UnitTestCase {
}
public function providerTestPerformRequiredValidation() {
- return array(
- array(
- array(
+ return [
+ [
+ [
'#type' => 'select',
- '#options' => array(
+ '#options' => [
'foo' => 'Foo',
'bar' => 'Bar',
- ),
+ ],
'#required' => TRUE,
'#value' => 'baz',
'#empty_value' => 'baz',
'#multiple' => FALSE,
- ),
+ ],
'Test field is required.',
FALSE,
- ),
- array(
- array(
+ ],
+ [
+ [
'#type' => 'select',
- '#options' => array(
+ '#options' => [
'foo' => 'Foo',
'bar' => 'Bar',
- ),
+ ],
'#value' => 'baz',
'#multiple' => FALSE,
- ),
+ ],
'An illegal choice has been detected. Please contact the site administrator.',
TRUE,
- ),
- array(
- array(
+ ],
+ [
+ [
'#type' => 'checkboxes',
- '#options' => array(
+ '#options' => [
'foo' => 'Foo',
'bar' => 'Bar',
- ),
- '#value' => array('baz'),
+ ],
+ '#value' => ['baz'],
'#multiple' => TRUE,
- ),
+ ],
'An illegal choice has been detected. Please contact the site administrator.',
TRUE,
- ),
- array(
- array(
+ ],
+ [
+ [
'#type' => 'select',
- '#options' => array(
+ '#options' => [
'foo' => 'Foo',
'bar' => 'Bar',
- ),
- '#value' => array('baz'),
+ ],
+ '#value' => ['baz'],
'#multiple' => TRUE,
- ),
+ ],
'An illegal choice has been detected. Please contact the site administrator.',
TRUE,
- ),
- array(
- array(
+ ],
+ [
+ [
'#type' => 'textfield',
'#maxlength' => 7,
'#value' => $this->randomMachineName(8),
- ),
+ ],
'Test cannot be longer than <em class="placeholder">7</em> characters but is currently <em class="placeholder">8</em> characters long.',
FALSE,
- ),
- );
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Form/OptGroupTest.php b/core/tests/Drupal/Tests/Core/Form/OptGroupTest.php
index 1d3a8fc0271..b38f336709a 100644
--- a/core/tests/Drupal/Tests/Core/Form/OptGroupTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/OptGroupTest.php
@@ -17,7 +17,7 @@ class OptGroupTest extends UnitTestCase {
* @dataProvider providerTestFlattenOptions
*/
public function testFlattenOptions($options) {
- $this->assertSame(array('foo' => 'foo'), OptGroup::flattenOptions($options));
+ $this->assertSame(['foo' => 'foo'], OptGroup::flattenOptions($options));
}
/**
@@ -27,18 +27,18 @@ class OptGroupTest extends UnitTestCase {
*/
public function providerTestFlattenOptions() {
$object1 = new \stdClass();
- $object1->option = array('foo' => 'foo');
+ $object1->option = ['foo' => 'foo'];
$object2 = new \stdClass();
- $object2->option = array(array('foo' => 'foo'), array('foo' => 'foo'));
+ $object2->option = [['foo' => 'foo'], ['foo' => 'foo']];
$object3 = new \stdClass();
- return array(
- array(array('foo' => 'foo')),
- array(array(array('foo' => 'foo'))),
- array(array($object1)),
- array(array($object2)),
- array(array($object1, $object2)),
- array(array('foo' => $object3, $object1, array('foo' => 'foo'))),
- );
+ return [
+ [['foo' => 'foo']],
+ [[['foo' => 'foo']]],
+ [[$object1]],
+ [[$object2]],
+ [[$object1, $object2]],
+ [['foo' => $object3, $object1, ['foo' => 'foo']]],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc b/core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc
index cd833946f33..b7623f76852 100644
--- a/core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc
+++ b/core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc
@@ -12,27 +12,27 @@
* The form array
*/
function test_form_id() {
- $form['test'] = array(
+ $form['test'] = [
'#type' => 'textfield',
'#title' => 'Test',
- );
- $form['options'] = array(
+ ];
+ $form['options'] = [
'#type' => 'radios',
- '#options' => array(
+ '#options' => [
'foo' => 'foo',
'bar' => 'bar',
- ),
- );
- $form['value'] = array(
+ ],
+ ];
+ $form['value'] = [
'#type' => 'value',
'#value' => 'bananas',
- );
- $form['actions'] = array(
+ ];
+ $form['actions'] = [
'#type' => 'actions',
- );
- $form['actions']['submit'] = array(
+ ];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
- );
+ ];
return $form;
}
diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
index 312bbdaf2e1..6b35f8655cb 100644
--- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php
+++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
@@ -58,9 +58,9 @@ class ImageTest extends UnitTestCase {
*
* @return \PHPUnit_Framework_MockObject_MockObject
*/
- protected function getToolkitMock(array $stubs = array()) {
+ protected function getToolkitMock(array $stubs = []) {
$mock_builder = $this->getMockBuilder('Drupal\system\Plugin\ImageToolkit\GDToolkit');
- $stubs = array_merge(array('getPluginId', 'save'), $stubs);
+ $stubs = array_merge(['getPluginId', 'save'], $stubs);
return $mock_builder
->disableOriginalConstructor()
->setMethods($stubs)
@@ -81,8 +81,8 @@ class ImageTest extends UnitTestCase {
$mock_builder = $this->getMockBuilder('Drupal\system\Plugin\ImageToolkit\Operation\gd\\' . $class_name);
$logger = $this->getMock('Psr\Log\LoggerInterface');
return $mock_builder
- ->setMethods(array('execute'))
- ->setConstructorArgs(array(array(), '', array(), $toolkit, $logger))
+ ->setMethods(['execute'])
+ ->setConstructorArgs([[], '', [], $toolkit, $logger])
->getMock();
}
@@ -98,9 +98,9 @@ class ImageTest extends UnitTestCase {
* @return \Drupal\Core\Image\Image
* An image object.
*/
- protected function getTestImage($load_expected = TRUE, array $stubs = array()) {
+ protected function getTestImage($load_expected = TRUE, array $stubs = []) {
if (!$load_expected && !in_array('load', $stubs)) {
- $stubs = array_merge(array('load'), $stubs);
+ $stubs = array_merge(['load'], $stubs);
}
$this->toolkit = $this->getToolkitMock($stubs);
@@ -127,7 +127,7 @@ class ImageTest extends UnitTestCase {
* An image object.
*/
protected function getTestImageForOperation($class_name) {
- $this->toolkit = $this->getToolkitMock(array('getToolkitOperation'));
+ $this->toolkit = $this->getToolkitMock(['getToolkitOperation']);
$this->toolkitOperation = $this->getToolkitOperationMock($class_name, $this->toolkit);
$this->toolkit->expects($this->any())
@@ -209,7 +209,7 @@ class ImageTest extends UnitTestCase {
->method('save')
->will($this->returnValue(TRUE));
- $image = $this->getMock('Drupal\Core\Image\Image', array('chmod'), array($toolkit, $this->image->getSource()));
+ $image = $this->getMock('Drupal\Core\Image\Image', ['chmod'], [$toolkit, $this->image->getSource()]);
$image->expects($this->any())
->method('chmod')
->will($this->returnValue(TRUE));
@@ -241,7 +241,7 @@ class ImageTest extends UnitTestCase {
->method('save')
->will($this->returnValue(TRUE));
- $image = $this->getMock('Drupal\Core\Image\Image', array('chmod'), array($toolkit, $this->image->getSource()));
+ $image = $this->getMock('Drupal\Core\Image\Image', ['chmod'], [$toolkit, $this->image->getSource()]);
$image->expects($this->any())
->method('chmod')
->will($this->returnValue(FALSE));
diff --git a/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php b/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php
index eaaf5a3321d..aefcbb0c0e2 100644
--- a/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php
@@ -19,7 +19,7 @@ class LanguageUnitTest extends UnitTestCase {
$name = $this->randomMachineName();
$language_code = $this->randomMachineName(2);
$uuid = $this->randomMachineName();
- $language = new Language(array('id' => $language_code, 'name' => $name, 'uuid' => $uuid));
+ $language = new Language(['id' => $language_code, 'name' => $name, 'uuid' => $uuid]);
// Test that nonexistent properties are not added to the language object.
$this->assertTrue(property_exists($language, 'id'));
$this->assertTrue(property_exists($language, 'name'));
@@ -32,7 +32,7 @@ class LanguageUnitTest extends UnitTestCase {
public function testGetName() {
$name = $this->randomMachineName();
$language_code = $this->randomMachineName(2);
- $language = new Language(array('id' => $language_code, 'name' => $name));
+ $language = new Language(['id' => $language_code, 'name' => $name]);
$this->assertSame($name, $language->getName());
}
@@ -41,7 +41,7 @@ class LanguageUnitTest extends UnitTestCase {
*/
public function testGetLangcode() {
$language_code = $this->randomMachineName(2);
- $language = new Language(array('id' => $language_code));
+ $language = new Language(['id' => $language_code]);
$this->assertSame($language_code, $language->getId());
}
@@ -50,7 +50,7 @@ class LanguageUnitTest extends UnitTestCase {
*/
public function testGetDirection() {
$language_code = $this->randomMachineName(2);
- $language = new Language(array('id' => $language_code, 'direction' => LanguageInterface::DIRECTION_RTL));
+ $language = new Language(['id' => $language_code, 'direction' => LanguageInterface::DIRECTION_RTL]);
$this->assertSame(LanguageInterface::DIRECTION_RTL, $language->getDirection());
}
@@ -66,14 +66,14 @@ class LanguageUnitTest extends UnitTestCase {
->will($this->returnValue($language_default));
\Drupal::setContainer($container);
- $language = new Language(array('id' => $this->randomMachineName(2)));
+ $language = new Language(['id' => $this->randomMachineName(2)]);
// Set up the LanguageDefault to return different default languages on
// consecutive calls.
$language_default->expects($this->any())
->method('get')
->willReturnOnConsecutiveCalls(
$language,
- new Language(array('id' => $this->randomMachineName(2)))
+ new Language(['id' => $this->randomMachineName(2)])
);
$this->assertTrue($language->isDefault());
@@ -104,58 +104,58 @@ class LanguageUnitTest extends UnitTestCase {
* An array of test data.
*/
public function providerTestSortArrayOfLanguages() {
- $language9A = new Language(array('id' => 'dd', 'name' => 'A', 'weight' => 9));
- $language10A = new Language(array('id' => 'ee', 'name' => 'A', 'weight' => 10));
- $language10B = new Language(array('id' => 'ff', 'name' => 'B', 'weight' => 10));
+ $language9A = new Language(['id' => 'dd', 'name' => 'A', 'weight' => 9]);
+ $language10A = new Language(['id' => 'ee', 'name' => 'A', 'weight' => 10]);
+ $language10B = new Language(['id' => 'ff', 'name' => 'B', 'weight' => 10]);
- return array(
+ return [
// Set up data set #0, already ordered by weight.
- array(
+ [
// Set the data.
- array(
+ [
$language9A->getId() => $language9A,
$language10B->getId() => $language10B,
- ),
+ ],
// Set the expected key order.
- array(
+ [
$language9A->getId(),
$language10B->getId(),
- ),
- ),
+ ],
+ ],
// Set up data set #1, out of order by weight.
- array(
- array(
+ [
+ [
$language10B->getId() => $language10B,
$language9A->getId() => $language9A,
- ),
- array(
+ ],
+ [
$language9A->getId(),
$language10B->getId(),
- ),
- ),
+ ],
+ ],
// Set up data set #2, tied by weight, already ordered by name.
- array(
- array(
+ [
+ [
$language10A->getId() => $language10A,
$language10B->getId() => $language10B,
- ),
- array(
+ ],
+ [
$language10A->getId(),
$language10B->getId(),
- ),
- ),
+ ],
+ ],
// Set up data set #3, tied by weight, out of order by name.
- array(
- array(
+ [
+ [
$language10B->getId() => $language10B,
$language10A->getId() => $language10A,
- ),
- array(
+ ],
+ [
$language10A->getId(),
$language10B->getId(),
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php b/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php
index 112abf13d00..395517f51fa 100644
--- a/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php
+++ b/core/tests/Drupal/Tests/Core/Logger/LogMessageParserTest.php
@@ -37,33 +37,33 @@ class LogMessageParserTest extends UnitTestCase {
* Data provider for testParseMessagePlaceholders().
*/
public function providerTestParseMessagePlaceholders() {
- return array(
+ return [
// PSR3 only message.
- array(
- array('message' => 'User {username} created', 'context' => array('username' => 'Dries')),
- array('message' => 'User @username created', 'context' => array('@username' => 'Dries')),
- ),
+ [
+ ['message' => 'User {username} created', 'context' => ['username' => 'Dries']],
+ ['message' => 'User @username created', 'context' => ['@username' => 'Dries']],
+ ],
// PSR3 style mixed in a format_string style message.
- array(
- array('message' => 'User {username} created @time', 'context' => array('username' => 'Dries', '@time' => 'now')),
- array('message' => 'User @username created @time', 'context' => array('@username' => 'Dries', '@time' => 'now')),
- ),
+ [
+ ['message' => 'User {username} created @time', 'context' => ['username' => 'Dries', '@time' => 'now']],
+ ['message' => 'User @username created @time', 'context' => ['@username' => 'Dries', '@time' => 'now']],
+ ],
// format_string style message only.
- array(
- array('message' => 'User @username created', 'context' => array('@username' => 'Dries')),
- array('message' => 'User @username created', 'context' => array('@username' => 'Dries')),
- ),
+ [
+ ['message' => 'User @username created', 'context' => ['@username' => 'Dries']],
+ ['message' => 'User @username created', 'context' => ['@username' => 'Dries']],
+ ],
// Message without placeholders but wildcard characters.
- array(
- array('message' => 'User W-\\};~{&! created @', 'context' => array('' => '')),
- array('message' => 'User W-\\};~{&! created @', 'context' => array()),
- ),
+ [
+ ['message' => 'User W-\\};~{&! created @', 'context' => ['' => '']],
+ ['message' => 'User W-\\};~{&! created @', 'context' => []],
+ ],
// Message with double PSR3 style messages.
- array(
- array('message' => 'Test {with} two {encapsuled} strings', 'context' => array('with' => 'together', 'encapsuled' => 'awesome')),
- array('message' => 'Test @with two @encapsuled strings', 'context' => array('@with' => 'together', '@encapsuled' => 'awesome')),
- ),
- );
+ [
+ ['message' => 'Test {with} two {encapsuled} strings', 'context' => ['with' => 'together', 'encapsuled' => 'awesome']],
+ ['message' => 'Test @with two @encapsuled strings', 'context' => ['@with' => 'together', '@encapsuled' => 'awesome']],
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
index 932edb727d3..d2b283adb9b 100644
--- a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
+++ b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
@@ -113,35 +113,35 @@ class LoggerChannelTest extends UnitTestCase {
$request_mock->headers = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
// No request or account.
- $cases [] = array(
+ $cases [] = [
function ($context) {
return $context['channel'] == 'test' && empty($context['uid']) && empty($context['ip']);
},
- );
+ ];
// With account but not request. Since the request is not available the
// current user should not be used.
- $cases [] = array(
+ $cases [] = [
function ($context) {
return $context['uid'] === 0 && empty($context['ip']);
},
NULL,
$account_mock,
- );
+ ];
// With request but not account.
- $cases [] = array(
+ $cases [] = [
function ($context) {
return $context['ip'] === '127.0.0.1' && empty($context['uid']);
},
$request_mock,
- );
+ ];
// Both request and account.
- $cases [] = array(
+ $cases [] = [
function ($context) {
return $context['ip'] === '127.0.0.1' && $context['uid'] === 1;
},
$request_mock,
$account_mock,
- );
+ ];
return $cases;
}
diff --git a/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php b/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
index d802374f369..9ba2fb52b70 100644
--- a/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
@@ -66,16 +66,16 @@ class MailManagerTest extends UnitTestCase {
*
* @var array
*/
- protected $definitions = array(
- 'php_mail' => array(
+ protected $definitions = [
+ 'php_mail' => [
'id' => 'php_mail',
'class' => 'Drupal\Core\Mail\Plugin\Mail\PhpMail',
- ),
- 'test_mail_collector' => array(
+ ],
+ 'test_mail_collector' => [
'id' => 'test_mail_collector',
'class' => 'Drupal\Core\Mail\Plugin\Mail\TestMailCollector',
- ),
- );
+ ],
+ ];
/**
* {@inheritdoc}
@@ -97,13 +97,13 @@ class MailManagerTest extends UnitTestCase {
/**
* Sets up the mail manager for testing.
*/
- protected function setUpMailManager($interface = array()) {
+ protected function setUpMailManager($interface = []) {
// Use the provided config for system.mail.interface settings.
- $this->configFactory = $this->getConfigFactoryStub(array(
- 'system.mail' => array(
+ $this->configFactory = $this->getConfigFactoryStub([
+ 'system.mail' => [
'interface' => $interface,
- ),
- ));
+ ],
+ ]);
$logger_factory = $this->getMock('\Drupal\Core\Logger\LoggerChannelFactoryInterface');
$string_translation = $this->getStringTranslationStub();
$this->renderer = $this->getMock(RendererInterface::class);
@@ -118,19 +118,19 @@ class MailManagerTest extends UnitTestCase {
* @covers ::getInstance
*/
public function testGetInstance() {
- $interface = array(
+ $interface = [
'default' => 'php_mail',
'default' => 'test_mail_collector',
- );
+ ];
$this->setUpMailManager($interface);
// Test that an unmatched message_id returns the default plugin instance.
- $options = array('module' => 'foo', 'key' => 'bar');
+ $options = ['module' => 'foo', 'key' => 'bar'];
$instance = $this->mailManager->getInstance($options);
$this->assertInstanceOf('Drupal\Core\Mail\Plugin\Mail\PhpMail', $instance);
// Test that a matching message_id returns the specified plugin instance.
- $options = array('module' => 'example', 'key' => 'testkey');
+ $options = ['module' => 'example', 'key' => 'testkey'];
$instance = $this->mailManager->getInstance($options);
$this->assertInstanceOf('Drupal\Core\Mail\Plugin\Mail\TestMailCollector', $instance);
}
@@ -142,10 +142,10 @@ class MailManagerTest extends UnitTestCase {
* @covers ::mail
*/
public function testMailInRenderContext() {
- $interface = array(
+ $interface = [
'default' => 'php_mail',
'example_testkey' => 'test_mail_collector',
- );
+ ];
$this->setUpMailManager($interface);
$this->renderer->expects($this->exactly(1))
@@ -176,9 +176,9 @@ class TestMailManager extends MailManager {
/**
* {@inheritdoc}
*/
- public function doMail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE) {
+ public function doMail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {
// Build a simplified message array and return it.
- $message = array(
+ $message = [
'id' => $module . '_' . $key,
'module' => $module,
'key' => $key,
@@ -189,8 +189,8 @@ class TestMailManager extends MailManager {
'params' => $params,
'send' => TRUE,
'subject' => '',
- 'body' => array(),
- );
+ 'body' => [],
+ ];
return $message;
}
diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php
index 970997fc628..a956d83467b 100644
--- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php
@@ -25,7 +25,7 @@ class ContextualLinkDefaultTest extends UnitTestCase {
*
* @var array
*/
- protected $config = array();
+ protected $config = [];
/**
* The used plugin ID.
@@ -39,9 +39,9 @@ class ContextualLinkDefaultTest extends UnitTestCase {
*
* @var array
*/
- protected $pluginDefinition = array(
+ protected $pluginDefinition = [
'id' => 'contextual_link_default',
- );
+ ];
/**
* The mocked translator.
@@ -80,7 +80,7 @@ class ContextualLinkDefaultTest extends UnitTestCase {
*/
public function testGetTitleWithContext() {
$title = 'Example';
- $this->pluginDefinition['title'] = (new TranslatableMarkup($title, array(), array('context' => 'context'), $this->stringTranslation));
+ $this->pluginDefinition['title'] = (new TranslatableMarkup($title, [], ['context' => 'context'], $this->stringTranslation));
$this->stringTranslation->expects($this->once())
->method('translateString')
->with($this->pluginDefinition['title'])
@@ -95,7 +95,7 @@ class ContextualLinkDefaultTest extends UnitTestCase {
*/
public function testGetTitleWithTitleArguments() {
$title = 'Example @test';
- $this->pluginDefinition['title'] = (new TranslatableMarkup($title, array('@test' => 'value'), [], $this->stringTranslation));
+ $this->pluginDefinition['title'] = (new TranslatableMarkup($title, ['@test' => 'value'], [], $this->stringTranslation));
$this->stringTranslation->expects($this->once())
->method('translateString')
->with($this->pluginDefinition['title'])
@@ -129,7 +129,7 @@ class ContextualLinkDefaultTest extends UnitTestCase {
/**
* @covers ::getOptions
*/
- public function testGetOptions($options = array('key' => 'value')) {
+ public function testGetOptions($options = ['key' => 'value']) {
$this->pluginDefinition['options'] = $options;
$this->setupContextualLinkDefault();
diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
index db0657845a0..92caa26d04e 100644
--- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
@@ -112,7 +112,7 @@ class ContextualLinkManagerTest extends UnitTestCase {
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->any())
->method('getCurrentLanguage')
- ->will($this->returnValue(new Language(array('id' => 'en'))));
+ ->will($this->returnValue(new Language(['id' => 'en'])));
$request_stack = new RequestStack();
$property = new \ReflectionProperty('Drupal\Core\Menu\ContextualLinkManager', 'requestStack');
@@ -132,26 +132,26 @@ class ContextualLinkManagerTest extends UnitTestCase {
* @see \Drupal\Core\Menu\ContextualLinkManager::getContextualLinkPluginsByGroup()
*/
public function testGetContextualLinkPluginsByGroup() {
- $definitions = array(
- 'test_plugin1' => array(
+ $definitions = [
+ 'test_plugin1' => [
'id' => 'test_plugin1',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route',
- ),
- 'test_plugin2' => array(
+ ],
+ 'test_plugin2' => [
'id' => 'test_plugin2',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route2',
- ),
- 'test_plugin3' => array(
+ ],
+ 'test_plugin3' => [
'id' => 'test_plugin3',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'group' => 'group2',
'route_name' => 'test_router3',
- ),
- );
+ ],
+ ];
$this->pluginDiscovery->expects($this->once())
->method('getDefinitions')
->will($this->returnValue($definitions));
@@ -161,35 +161,35 @@ class ContextualLinkManagerTest extends UnitTestCase {
$this->assertEmpty($result);
$result = $this->contextualLinkManager->getContextualLinkPluginsByGroup('group1');
- $this->assertEquals(array('test_plugin1', 'test_plugin2'), array_keys($result));
+ $this->assertEquals(['test_plugin1', 'test_plugin2'], array_keys($result));
$result = $this->contextualLinkManager->getContextualLinkPluginsByGroup('group2');
- $this->assertEquals(array('test_plugin3'), array_keys($result));
+ $this->assertEquals(['test_plugin3'], array_keys($result));
}
/**
* Tests the getContextualLinkPluginsByGroup method with a prefilled cache.
*/
public function testGetContextualLinkPluginsByGroupWithCache() {
- $definitions = array(
- 'test_plugin1' => array(
+ $definitions = [
+ 'test_plugin1' => [
'id' => 'test_plugin1',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route',
- ),
- 'test_plugin2' => array(
+ ],
+ 'test_plugin2' => [
'id' => 'test_plugin2',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route2',
- ),
- );
+ ],
+ ];
$this->cacheBackend->expects($this->once())
->method('get')
->with('contextual_links_plugins:en:group1')
- ->will($this->returnValue((object) array('data' => $definitions)));
+ ->will($this->returnValue((object) ['data' => $definitions]));
$result = $this->contextualLinkManager->getContextualLinkPluginsByGroup('group1');
$this->assertEquals($definitions, $result);
@@ -208,11 +208,11 @@ class ContextualLinkManagerTest extends UnitTestCase {
* @expectedException \Drupal\Component\Plugin\Exception\PluginException
*/
public function testProcessDefinitionWithoutRoute() {
- $definition = array(
+ $definition = [
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'group' => 'example',
'id' => 'test_plugin',
- );
+ ];
$this->contextualLinkManager->processDefinition($definition, 'test_plugin');
}
@@ -224,11 +224,11 @@ class ContextualLinkManagerTest extends UnitTestCase {
* @expectedException \Drupal\Component\Plugin\Exception\PluginException
*/
public function testProcessDefinitionWithoutGroup() {
- $definition = array(
+ $definition = [
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'route_name' => 'example',
'id' => 'test_plugin',
- );
+ ];
$this->contextualLinkManager->processDefinition($definition, 'test_plugin');
}
@@ -238,35 +238,35 @@ class ContextualLinkManagerTest extends UnitTestCase {
* @see \Drupal\Core\Menu\ContextualLinkManager::getContextualLinksArrayByGroup()
*/
public function testGetContextualLinksArrayByGroup() {
- $definitions = array(
- 'test_plugin1' => array(
+ $definitions = [
+ 'test_plugin1' => [
'id' => 'test_plugin1',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'title' => 'Plugin 1',
'weight' => 0,
'group' => 'group1',
'route_name' => 'test_route',
- 'options' => array(),
- ),
- 'test_plugin2' => array(
+ 'options' => [],
+ ],
+ 'test_plugin2' => [
'id' => 'test_plugin2',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'title' => 'Plugin 2',
'weight' => 2,
'group' => 'group1',
'route_name' => 'test_route2',
- 'options' => array('key' => 'value'),
- ),
- 'test_plugin3' => array(
+ 'options' => ['key' => 'value'],
+ ],
+ 'test_plugin3' => [
'id' => 'test_plugin3',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'title' => 'Plugin 3',
'weight' => 5,
'group' => 'group2',
'route_name' => 'test_router3',
- 'options' => array(),
- ),
- );
+ 'options' => [],
+ ],
+ ];
$this->pluginDiscovery->expects($this->once())
->method('getDefinitions')
@@ -277,7 +277,7 @@ class ContextualLinkManagerTest extends UnitTestCase {
->will($this->returnValue(AccessResult::allowed()));
// Set up mocking of the plugin factory.
- $map = array();
+ $map = [];
foreach ($definitions as $plugin_id => $definition) {
$plugin = $this->getMock('Drupal\Core\Menu\ContextualLinkInterface');
$plugin->expects($this->any())
@@ -292,7 +292,7 @@ class ContextualLinkManagerTest extends UnitTestCase {
$plugin->expects($this->any())
->method('getOptions')
->will($this->returnValue($definition['options']));
- $map[] = array($plugin_id, array(), $plugin);
+ $map[] = [$plugin_id, [], $plugin];
}
$this->factory->expects($this->any())
->method('createInstance')
@@ -300,11 +300,11 @@ class ContextualLinkManagerTest extends UnitTestCase {
$this->moduleHandler->expects($this->at(1))
->method('alter')
- ->with($this->equalTo('contextual_links'), new \PHPUnit_Framework_Constraint_Count(2), $this->equalTo('group1'), $this->equalTo(array('key' => 'value')));
+ ->with($this->equalTo('contextual_links'), new \PHPUnit_Framework_Constraint_Count(2), $this->equalTo('group1'), $this->equalTo(['key' => 'value']));
- $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', array('key' => 'value'));
+ $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', ['key' => 'value']);
$this->assertCount(2, $result);
- foreach (array('test_plugin1', 'test_plugin2') as $plugin_id) {
+ foreach (['test_plugin1', 'test_plugin2'] as $plugin_id) {
$definition = $definitions[$plugin_id];
$this->assertEquals($definition['weight'], $result[$plugin_id]['weight']);
$this->assertEquals($definition['title'], $result[$plugin_id]['title']);
@@ -318,26 +318,26 @@ class ContextualLinkManagerTest extends UnitTestCase {
* @see \Drupal\Core\Menu\ContextualLinkManager::getContextualLinksArrayByGroup()
*/
public function testGetContextualLinksArrayByGroupAccessCheck() {
- $definitions = array(
- 'test_plugin1' => array(
+ $definitions = [
+ 'test_plugin1' => [
'id' => 'test_plugin1',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'title' => 'Plugin 1',
'weight' => 0,
'group' => 'group1',
'route_name' => 'test_route',
- 'options' => array(),
- ),
- 'test_plugin2' => array(
+ 'options' => [],
+ ],
+ 'test_plugin2' => [
'id' => 'test_plugin2',
'class' => '\Drupal\Core\Menu\ContextualLinkDefault',
'title' => 'Plugin 2',
'weight' => 2,
'group' => 'group1',
'route_name' => 'test_route2',
- 'options' => array('key' => 'value'),
- ),
- );
+ 'options' => ['key' => 'value'],
+ ],
+ ];
$this->pluginDiscovery->expects($this->once())
->method('getDefinitions')
@@ -345,13 +345,13 @@ class ContextualLinkManagerTest extends UnitTestCase {
$this->accessManager->expects($this->any())
->method('checkNamedRoute')
- ->will($this->returnValueMap(array(
- array('test_route', array('key' => 'value'), $this->account, FALSE, TRUE),
- array('test_route2', array('key' => 'value'), $this->account, FALSE, FALSE),
- )));
+ ->will($this->returnValueMap([
+ ['test_route', ['key' => 'value'], $this->account, FALSE, TRUE],
+ ['test_route2', ['key' => 'value'], $this->account, FALSE, FALSE],
+ ]));
// Set up mocking of the plugin factory.
- $map = array();
+ $map = [];
foreach ($definitions as $plugin_id => $definition) {
$plugin = $this->getMock('Drupal\Core\Menu\ContextualLinkInterface');
$plugin->expects($this->any())
@@ -366,13 +366,13 @@ class ContextualLinkManagerTest extends UnitTestCase {
$plugin->expects($this->any())
->method('getOptions')
->will($this->returnValue($definition['options']));
- $map[] = array($plugin_id, array(), $plugin);
+ $map[] = [$plugin_id, [], $plugin];
}
$this->factory->expects($this->any())
->method('createInstance')
->will($this->returnValueMap($map));
- $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', array('key' => 'value'));
+ $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', ['key' => 'value']);
// Ensure that access checking was respected.
$this->assertTrue(isset($result['test_plugin1']));
@@ -383,15 +383,15 @@ class ContextualLinkManagerTest extends UnitTestCase {
* Tests the plugins alter hook.
*/
public function testPluginDefinitionAlter() {
- $definitions['test_plugin'] = array(
+ $definitions['test_plugin'] = [
'id' => 'test_plugin',
'class' => ContextualLinkDefault::class,
'title' => 'Plugin',
'weight' => 2,
'group' => 'group1',
'route_name' => 'test_route',
- 'options' => array('key' => 'value'),
- );
+ 'options' => ['key' => 'value'],
+ ];
$this->pluginDiscovery->expects($this->once())
->method('getDefinitions')
diff --git a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
index cab6d78e1f3..beb78287f6c 100644
--- a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
@@ -54,14 +54,14 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase {
*
* @var \Drupal\Core\Menu\MenuLinkTreeElement[]
*/
- protected $originalTree = array();
+ protected $originalTree = [];
/**
* Array of menu link instances
*
* @var \Drupal\Core\Menu\MenuLinkInterface[]
*/
- protected $links = array();
+ protected $links = [];
/**
* {@inheritdoc}
@@ -103,30 +103,30 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase {
* With link 6 being the only external link.
*/
protected function mockTree() {
- $this->links = array(
- 1 => MenuLinkMock::create(array('id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '')),
- 2 => MenuLinkMock::create(array('id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => 'test.example1', 'route_parameters' => array('foo' => 'bar'))),
- 3 => MenuLinkMock::create(array('id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'route_parameters' => array('baz' => 'qux'))),
- 4 => MenuLinkMock::create(array('id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3')),
- 5 => MenuLinkMock::create(array('id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '')),
- 6 => MenuLinkMock::create(array('id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '')),
- 7 => MenuLinkMock::create(array('id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => '')),
- 8 => MenuLinkMock::create(array('id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '')),
- 9 => DynamicMenuLinkMock::create(array('id' => 'test.example9', 'parent' => ''))->setCurrentUser($this->currentUser),
- );
- $this->originalTree = array();
- $this->originalTree[1] = new MenuLinkTreeElement($this->links[1], FALSE, 1, FALSE, array());
- $this->originalTree[2] = new MenuLinkTreeElement($this->links[2], TRUE, 1, FALSE, array(
- 3 => new MenuLinkTreeElement($this->links[3], TRUE, 2, FALSE, array(
- 4 => new MenuLinkTreeElement($this->links[4], FALSE, 3, FALSE, array()),
- )),
- ));
- $this->originalTree[5] = new MenuLinkTreeElement($this->links[5], TRUE, 1, FALSE, array(
- 7 => new MenuLinkTreeElement($this->links[7], FALSE, 2, FALSE, array()),
- ));
- $this->originalTree[6] = new MenuLinkTreeElement($this->links[6], FALSE, 1, FALSE, array());
- $this->originalTree[8] = new MenuLinkTreeElement($this->links[8], FALSE, 1, FALSE, array());
- $this->originalTree[9] = new MenuLinkTreeElement($this->links[9], FALSE, 1, FALSE, array());
+ $this->links = [
+ 1 => MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '']),
+ 2 => MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => 'test.example1', 'route_parameters' => ['foo' => 'bar']]),
+ 3 => MenuLinkMock::create(['id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'route_parameters' => ['baz' => 'qux']]),
+ 4 => MenuLinkMock::create(['id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3']),
+ 5 => MenuLinkMock::create(['id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '']),
+ 6 => MenuLinkMock::create(['id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '']),
+ 7 => MenuLinkMock::create(['id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => '']),
+ 8 => MenuLinkMock::create(['id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '']),
+ 9 => DynamicMenuLinkMock::create(['id' => 'test.example9', 'parent' => ''])->setCurrentUser($this->currentUser),
+ ];
+ $this->originalTree = [];
+ $this->originalTree[1] = new MenuLinkTreeElement($this->links[1], FALSE, 1, FALSE, []);
+ $this->originalTree[2] = new MenuLinkTreeElement($this->links[2], TRUE, 1, FALSE, [
+ 3 => new MenuLinkTreeElement($this->links[3], TRUE, 2, FALSE, [
+ 4 => new MenuLinkTreeElement($this->links[4], FALSE, 3, FALSE, []),
+ ]),
+ ]);
+ $this->originalTree[5] = new MenuLinkTreeElement($this->links[5], TRUE, 1, FALSE, [
+ 7 => new MenuLinkTreeElement($this->links[7], FALSE, 2, FALSE, []),
+ ]);
+ $this->originalTree[6] = new MenuLinkTreeElement($this->links[6], FALSE, 1, FALSE, []);
+ $this->originalTree[8] = new MenuLinkTreeElement($this->links[8], FALSE, 1, FALSE, []);
+ $this->originalTree[9] = new MenuLinkTreeElement($this->links[9], FALSE, 1, FALSE, []);
}
/**
@@ -165,13 +165,13 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase {
// calls will be made.
$this->accessManager->expects($this->exactly(5))
->method('checkNamedRoute')
- ->will($this->returnValueMap(array(
- array('example1', array(), $this->currentUser, TRUE, AccessResult::forbidden()),
- array('example2', array('foo' => 'bar'), $this->currentUser, TRUE, AccessResult::allowed()->cachePerPermissions()),
- array('example3', array('baz' => 'qux'), $this->currentUser, TRUE, AccessResult::neutral()),
- array('example5', array(), $this->currentUser, TRUE, AccessResult::allowed()),
- array('user.logout', array(), $this->currentUser, TRUE, AccessResult::allowed()),
- )));
+ ->will($this->returnValueMap([
+ ['example1', [], $this->currentUser, TRUE, AccessResult::forbidden()],
+ ['example2', ['foo' => 'bar'], $this->currentUser, TRUE, AccessResult::allowed()->cachePerPermissions()],
+ ['example3', ['baz' => 'qux'], $this->currentUser, TRUE, AccessResult::neutral()],
+ ['example5', [], $this->currentUser, TRUE, AccessResult::allowed()],
+ ['user.logout', [], $this->currentUser, TRUE, AccessResult::allowed()],
+ ]));
$this->mockTree();
$this->originalTree[5]->subtree[7]->access = AccessResult::neutral();
@@ -259,8 +259,8 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase {
public function testFlatten() {
$this->mockTree();
$tree = $this->defaultMenuTreeManipulators->flatten($this->originalTree);
- $this->assertEquals(array(1, 2, 5, 6, 8, 9), array_keys($this->originalTree));
- $this->assertEquals(array(1, 2, 5, 6, 8, 9, 3, 4, 7), array_keys($tree));
+ $this->assertEquals([1, 2, 5, 6, 8, 9], array_keys($this->originalTree));
+ $this->assertEquals([1, 2, 5, 6, 8, 9, 3, 4, 7], array_keys($tree));
}
/**
@@ -271,35 +271,35 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase {
* @covers ::checkAccess
*/
public function testCheckNodeAccess() {
- $links = array(
- 1 => MenuLinkMock::create(array('id' => 'node.1', 'route_name' => 'entity.node.canonical', 'title' => 'foo', 'parent' => '', 'route_parameters' => array('node' => 1))),
- 2 => MenuLinkMock::create(array('id' => 'node.2', 'route_name' => 'entity.node.canonical', 'title' => 'bar', 'parent' => '', 'route_parameters' => array('node' => 2))),
- 3 => MenuLinkMock::create(array('id' => 'node.3', 'route_name' => 'entity.node.canonical', 'title' => 'baz', 'parent' => 'node.2', 'route_parameters' => array('node' => 3))),
- 4 => MenuLinkMock::create(array('id' => 'node.4', 'route_name' => 'entity.node.canonical', 'title' => 'qux', 'parent' => 'node.3', 'route_parameters' => array('node' => 4))),
- 5 => MenuLinkMock::create(array('id' => 'test.1', 'route_name' => 'test_route', 'title' => 'qux', 'parent' => '')),
- 6 => MenuLinkMock::create(array('id' => 'test.2', 'route_name' => 'test_route', 'title' => 'qux', 'parent' => 'test.1')),
- );
- $tree = array();
- $tree[1] = new MenuLinkTreeElement($links[1], FALSE, 1, FALSE, array());
- $tree[2] = new MenuLinkTreeElement($links[2], TRUE, 1, FALSE, array(
- 3 => new MenuLinkTreeElement($links[3], TRUE, 2, FALSE, array(
- 4 => new MenuLinkTreeElement($links[4], FALSE, 3, FALSE, array()),
- )),
- ));
- $tree[5] = new MenuLinkTreeElement($links[5], TRUE, 1, FALSE, array(
- 6 => new MenuLinkTreeElement($links[6], FALSE, 2, FALSE, array()),
- ));
+ $links = [
+ 1 => MenuLinkMock::create(['id' => 'node.1', 'route_name' => 'entity.node.canonical', 'title' => 'foo', 'parent' => '', 'route_parameters' => ['node' => 1]]),
+ 2 => MenuLinkMock::create(['id' => 'node.2', 'route_name' => 'entity.node.canonical', 'title' => 'bar', 'parent' => '', 'route_parameters' => ['node' => 2]]),
+ 3 => MenuLinkMock::create(['id' => 'node.3', 'route_name' => 'entity.node.canonical', 'title' => 'baz', 'parent' => 'node.2', 'route_parameters' => ['node' => 3]]),
+ 4 => MenuLinkMock::create(['id' => 'node.4', 'route_name' => 'entity.node.canonical', 'title' => 'qux', 'parent' => 'node.3', 'route_parameters' => ['node' => 4]]),
+ 5 => MenuLinkMock::create(['id' => 'test.1', 'route_name' => 'test_route', 'title' => 'qux', 'parent' => '']),
+ 6 => MenuLinkMock::create(['id' => 'test.2', 'route_name' => 'test_route', 'title' => 'qux', 'parent' => 'test.1']),
+ ];
+ $tree = [];
+ $tree[1] = new MenuLinkTreeElement($links[1], FALSE, 1, FALSE, []);
+ $tree[2] = new MenuLinkTreeElement($links[2], TRUE, 1, FALSE, [
+ 3 => new MenuLinkTreeElement($links[3], TRUE, 2, FALSE, [
+ 4 => new MenuLinkTreeElement($links[4], FALSE, 3, FALSE, []),
+ ]),
+ ]);
+ $tree[5] = new MenuLinkTreeElement($links[5], TRUE, 1, FALSE, [
+ 6 => new MenuLinkTreeElement($links[6], FALSE, 2, FALSE, []),
+ ]);
$query = $this->getMock('Drupal\Core\Entity\Query\QueryInterface');
$query->expects($this->at(0))
->method('condition')
- ->with('nid', array(1, 2, 3, 4));
+ ->with('nid', [1, 2, 3, 4]);
$query->expects($this->at(1))
->method('condition')
->with('status', NodeInterface::PUBLISHED);
$query->expects($this->once())
->method('execute')
- ->willReturn(array(1, 2, 4));
+ ->willReturn([1, 2, 4]);
$storage = $this->getMock(EntityStorageInterface::class);
$storage->expects($this->once())
->method('getQuery')
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php
index 2f0c1a8d739..b026fb0624c 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php
@@ -25,7 +25,7 @@ class LocalActionDefaultTest extends UnitTestCase {
*
* @var array
*/
- protected $config = array();
+ protected $config = [];
/**
* The used plugin ID.
@@ -39,9 +39,9 @@ class LocalActionDefaultTest extends UnitTestCase {
*
* @var array
*/
- protected $pluginDefinition = array(
+ protected $pluginDefinition = [
'id' => 'local_action_default',
- );
+ ];
/**
* The mocked translator.
@@ -93,7 +93,7 @@ class LocalActionDefaultTest extends UnitTestCase {
* @see \Drupal\Core\Menu\LocalTaskDefault::getTitle()
*/
public function testGetTitleWithContext() {
- $this->pluginDefinition['title'] = (new TranslatableMarkup('Example', array(), array('context' => 'context'), $this->stringTranslation));
+ $this->pluginDefinition['title'] = (new TranslatableMarkup('Example', [], ['context' => 'context'], $this->stringTranslation));
$this->stringTranslation->expects($this->once())
->method('translateString')
->with($this->pluginDefinition['title'])
@@ -107,7 +107,7 @@ class LocalActionDefaultTest extends UnitTestCase {
* Tests the getTitle method with title arguments.
*/
public function testGetTitleWithTitleArguments() {
- $this->pluginDefinition['title'] = (new TranslatableMarkup('Example @test', array('@test' => 'value'), [], $this->stringTranslation));
+ $this->pluginDefinition['title'] = (new TranslatableMarkup('Example @test', ['@test' => 'value'], [], $this->stringTranslation));
$this->stringTranslation->expects($this->once())
->method('translateString')
->with($this->pluginDefinition['title'])
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php
index 92ce48e3387..0f1f848c924 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php
@@ -134,8 +134,8 @@ class LocalActionManagerTest extends UnitTestCase {
$this->controllerResolver->expects($this->once())
->method('getArguments')
- ->with($this->request, array($local_action, 'getTitle'))
- ->will($this->returnValue(array('test')));
+ ->with($this->request, [$local_action, 'getTitle'])
+ ->will($this->returnValue(['test']));
$this->localActionManager->getTitle($local_action);
}
@@ -149,7 +149,7 @@ class LocalActionManagerTest extends UnitTestCase {
$this->discovery->expects($this->any())
->method('getDefinitions')
->will($this->returnValue($plugin_definitions));
- $map = array();
+ $map = [];
foreach ($plugin_definitions as $plugin_id => $plugin_definition) {
$plugin = $this->getMock('Drupal\Core\Menu\LocalActionInterface');
$plugin->expects($this->any())
@@ -157,23 +157,23 @@ class LocalActionManagerTest extends UnitTestCase {
->will($this->returnValue($plugin_definition['route_name']));
$plugin->expects($this->any())
->method('getRouteParameters')
- ->will($this->returnValue(isset($plugin_definition['route_parameters']) ? $plugin_definition['route_parameters'] : array()));
+ ->will($this->returnValue(isset($plugin_definition['route_parameters']) ? $plugin_definition['route_parameters'] : []));
$plugin->expects($this->any())
->method('getTitle')
->will($this->returnValue($plugin_definition['title']));
$this->controllerResolver->expects($this->any())
->method('getArguments')
- ->with($this->request, array($plugin, 'getTitle'))
- ->will($this->returnValue(array()));
+ ->with($this->request, [$plugin, 'getTitle'])
+ ->will($this->returnValue([]));
$plugin->expects($this->any())
->method('getWeight')
->will($this->returnValue($plugin_definition['weight']));
$this->controllerResolver->expects($this->any())
->method('getArguments')
- ->with($this->request, array($plugin, 'getTitle'))
- ->will($this->returnValue(array()));
- $map[] = array($plugin_id, array(), $plugin);
+ ->with($this->request, [$plugin, 'getTitle'])
+ ->will($this->returnValue([]));
+ $map[] = [$plugin_id, [], $plugin];
}
$this->factory->expects($this->any())
->method('createInstance')
@@ -184,199 +184,199 @@ class LocalActionManagerTest extends UnitTestCase {
public function getActionsForRouteProvider() {
// Single available and single expected plugins.
- $data[] = array(
+ $data[] = [
'test_route',
- array(
- 'plugin_id_1' => array(
- 'appears_on' => array(
+ [
+ 'plugin_id_1' => [
+ 'appears_on' => [
'test_route',
- ),
+ ],
'route_name' => 'test_route_2',
'title' => 'Plugin ID 1',
'weight' => 0,
- ),
- ),
- array(
- '#cache' => array(
- 'contexts' => array('route'),
- ),
- 'plugin_id_1' => array(
+ ],
+ ],
+ [
+ '#cache' => [
+ 'contexts' => ['route'],
+ ],
+ 'plugin_id_1' => [
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
- ),
+ ],
'#access' => AccessResult::forbidden(),
'#weight' => 0,
- '#cache' => array(
- 'contexts' => array(),
- 'tags' => array(),
+ '#cache' => [
+ 'contexts' => [],
+ 'tags' => [],
'max-age' => 0,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
// Multiple available and single expected plugins.
- $data[] = array(
+ $data[] = [
'test_route',
- array(
- 'plugin_id_1' => array(
- 'appears_on' => array(
+ [
+ 'plugin_id_1' => [
+ 'appears_on' => [
'test_route',
- ),
+ ],
'route_name' => 'test_route_2',
'title' => 'Plugin ID 1',
'weight' => 0,
- ),
- 'plugin_id_2' => array(
- 'appears_on' => array(
+ ],
+ 'plugin_id_2' => [
+ 'appears_on' => [
'test_route2',
- ),
+ ],
'route_name' => 'test_route_3',
'title' => 'Plugin ID 2',
'weight' => 0,
- ),
- ),
- array(
- '#cache' => array(
- 'contexts' => array('route'),
- ),
- 'plugin_id_1' => array(
+ ],
+ ],
+ [
+ '#cache' => [
+ 'contexts' => ['route'],
+ ],
+ 'plugin_id_1' => [
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
- ),
+ ],
'#access' => AccessResult::forbidden(),
'#weight' => 0,
- '#cache' => array(
- 'contexts' => array(),
- 'tags' => array(),
+ '#cache' => [
+ 'contexts' => [],
+ 'tags' => [],
'max-age' => 0,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
// Multiple available and multiple expected plugins and specified weight.
- $data[] = array(
+ $data[] = [
'test_route',
- array(
- 'plugin_id_1' => array(
- 'appears_on' => array(
+ [
+ 'plugin_id_1' => [
+ 'appears_on' => [
'test_route',
- ),
+ ],
'route_name' => 'test_route_2',
'title' => 'Plugin ID 1',
'weight' => 1,
- ),
- 'plugin_id_2' => array(
- 'appears_on' => array(
+ ],
+ 'plugin_id_2' => [
+ 'appears_on' => [
'test_route',
- ),
+ ],
'route_name' => 'test_route_3',
'title' => 'Plugin ID 2',
'weight' => 0,
- ),
- ),
- array(
- '#cache' => array(
- 'contexts' => array('route'),
- ),
- 'plugin_id_1' => array(
+ ],
+ ],
+ [
+ '#cache' => [
+ 'contexts' => ['route'],
+ ],
+ 'plugin_id_1' => [
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
- ),
+ ],
'#access' => AccessResult::forbidden(),
'#weight' => 1,
- '#cache' => array(
- 'contexts' => array(),
- 'tags' => array(),
+ '#cache' => [
+ 'contexts' => [],
+ 'tags' => [],
'max-age' => 0,
- ),
- ),
- 'plugin_id_2' => array(
+ ],
+ ],
+ 'plugin_id_2' => [
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => 'Plugin ID 2',
'url' => Url::fromRoute('test_route_3'),
'localized_options' => '',
- ),
+ ],
'#access' => AccessResult::forbidden(),
'#weight' => 0,
- '#cache' => array(
- 'contexts' => array(),
- 'tags' => array(),
+ '#cache' => [
+ 'contexts' => [],
+ 'tags' => [],
'max-age' => 0,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
// Two plugins with the same route name but different route parameters.
- $data[] = array(
+ $data[] = [
'test_route',
- array(
- 'plugin_id_1' => array(
- 'appears_on' => array(
+ [
+ 'plugin_id_1' => [
+ 'appears_on' => [
'test_route',
- ),
+ ],
'route_name' => 'test_route_2',
- 'route_parameters' => array('test1'),
+ 'route_parameters' => ['test1'],
'title' => 'Plugin ID 1',
'weight' => 1,
- ),
- 'plugin_id_2' => array(
- 'appears_on' => array(
+ ],
+ 'plugin_id_2' => [
+ 'appears_on' => [
'test_route',
- ),
+ ],
'route_name' => 'test_route_2',
- 'route_parameters' => array('test2'),
+ 'route_parameters' => ['test2'],
'title' => 'Plugin ID 2',
'weight' => 0,
- ),
- ),
- array(
- '#cache' => array(
- 'contexts' => array('route'),
- ),
- 'plugin_id_1' => array(
+ ],
+ ],
+ [
+ '#cache' => [
+ 'contexts' => ['route'],
+ ],
+ 'plugin_id_1' => [
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => 'Plugin ID 1',
'url' => Url::fromRoute('test_route_2', ['test1']),
'localized_options' => '',
- ),
+ ],
'#access' => AccessResult::forbidden(),
'#weight' => 1,
- '#cache' => array(
- 'contexts' => array(),
- 'tags' => array(),
+ '#cache' => [
+ 'contexts' => [],
+ 'tags' => [],
'max-age' => 0,
- ),
- ),
- 'plugin_id_2' => array(
+ ],
+ ],
+ 'plugin_id_2' => [
'#theme' => 'menu_local_action',
- '#link' => array(
+ '#link' => [
'title' => 'Plugin ID 2',
'url' => Url::fromRoute('test_route_2', ['test2']),
'localized_options' => '',
- ),
+ ],
'#access' => AccessResult::forbidden(),
'#weight' => 0,
- '#cache' => array(
- 'contexts' => array(),
- 'tags' => array(),
+ '#cache' => [
+ 'contexts' => [],
+ 'tags' => [],
'max-age' => 0,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $data;
}
@@ -397,7 +397,7 @@ class TestLocalActionManager extends LocalActionManager {
$this->routeMatch = $route_match;
$this->moduleHandler = $module_handler;
$this->alterInfo('menu_local_actions');
- $this->setCacheBackend($cache_backend, 'local_action_plugins', array('local_action'));
+ $this->setCacheBackend($cache_backend, 'local_action_plugins', ['local_action']);
}
}
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
index 1e7ec1ed8bb..84b91afe97d 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
@@ -32,7 +32,7 @@ class LocalTaskDefaultTest extends UnitTestCase {
*
* @var array
*/
- protected $config = array();
+ protected $config = [];
/**
* The used plugin ID.
@@ -46,9 +46,9 @@ class LocalTaskDefaultTest extends UnitTestCase {
*
* @var array
*/
- protected $pluginDefinition = array(
+ protected $pluginDefinition = [
'id' => 'local_task_default',
- );
+ ];
/**
* The mocked translator.
@@ -84,9 +84,9 @@ class LocalTaskDefaultTest extends UnitTestCase {
* @covers ::getRouteParameters
*/
public function testGetRouteParametersForStaticRoute() {
- $this->pluginDefinition = array(
+ $this->pluginDefinition = [
'route_name' => 'test_route'
- );
+ ];
$this->routeProvider->expects($this->once())
->method('getRouteByName')
@@ -96,17 +96,17 @@ class LocalTaskDefaultTest extends UnitTestCase {
$this->setupLocalTaskDefault();
$route_match = new RouteMatch('', new Route('/'));
- $this->assertEquals(array(), $this->localTaskBase->getRouteParameters($route_match));
+ $this->assertEquals([], $this->localTaskBase->getRouteParameters($route_match));
}
/**
* @covers ::getRouteParameters
*/
public function testGetRouteParametersInPluginDefinitions() {
- $this->pluginDefinition = array(
+ $this->pluginDefinition = [
'route_name' => 'test_route',
- 'route_parameters' => array('parameter' => 'example')
- );
+ 'route_parameters' => ['parameter' => 'example']
+ ];
$this->routeProvider->expects($this->once())
->method('getRouteByName')
@@ -116,16 +116,16 @@ class LocalTaskDefaultTest extends UnitTestCase {
$this->setupLocalTaskDefault();
$route_match = new RouteMatch('', new Route('/'));
- $this->assertEquals(array('parameter' => 'example'), $this->localTaskBase->getRouteParameters($route_match));
+ $this->assertEquals(['parameter' => 'example'], $this->localTaskBase->getRouteParameters($route_match));
}
/**
* @covers ::getRouteParameters
*/
public function testGetRouteParametersForDynamicRouteWithNonUpcastedParameters() {
- $this->pluginDefinition = array(
+ $this->pluginDefinition = [
'route_name' => 'test_route'
- );
+ ];
$route = new Route('/test-route/{parameter}');
$this->routeProvider->expects($this->once())
@@ -135,9 +135,9 @@ class LocalTaskDefaultTest extends UnitTestCase {
$this->setupLocalTaskDefault();
- $route_match = new RouteMatch('', $route, array(), array('parameter' => 'example'));
+ $route_match = new RouteMatch('', $route, [], ['parameter' => 'example']);
- $this->assertEquals(array('parameter' => 'example'), $this->localTaskBase->getRouteParameters($route_match));
+ $this->assertEquals(['parameter' => 'example'], $this->localTaskBase->getRouteParameters($route_match));
}
/**
@@ -146,9 +146,9 @@ class LocalTaskDefaultTest extends UnitTestCase {
* @covers ::getRouteParameters
*/
public function testGetRouteParametersForDynamicRouteWithUpcastedParameters() {
- $this->pluginDefinition = array(
+ $this->pluginDefinition = [
'route_name' => 'test_route'
- );
+ ];
$route = new Route('/test-route/{parameter}');
$this->routeProvider->expects($this->once())
@@ -158,8 +158,8 @@ class LocalTaskDefaultTest extends UnitTestCase {
$this->setupLocalTaskDefault();
- $route_match = new RouteMatch('', $route, array('parameter' => (object) 'example2'), array('parameter' => 'example'));
- $this->assertEquals(array('parameter' => 'example'), $this->localTaskBase->getRouteParameters($route_match));
+ $route_match = new RouteMatch('', $route, ['parameter' => (object) 'example2'], ['parameter' => 'example']);
+ $this->assertEquals(['parameter' => 'example'], $this->localTaskBase->getRouteParameters($route_match));
}
/**
@@ -169,40 +169,40 @@ class LocalTaskDefaultTest extends UnitTestCase {
* A list or test plugin definition and expected weight.
*/
public function providerTestGetWeight() {
- return array(
+ return [
// Manually specify a weight, so this is used.
- array(array('weight' => 314), 'test_id', 314),
+ [['weight' => 314], 'test_id', 314],
// Ensure that a default tab gets a lower weight.
- array(
- array(
+ [
+ [
'base_route' => 'local_task_default',
'route_name' => 'local_task_default',
'id' => 'local_task_default'
- ),
+ ],
'local_task_default',
-10
- ),
+ ],
// If the base route is different from the route of the tab, ignore it.
- array(
- array(
+ [
+ [
'base_route' => 'local_task_example',
'route_name' => 'local_task_other',
'id' => 'local_task_default'
- ),
+ ],
'local_task_default',
0,
- ),
+ ],
// Ensure that a default tab of a derivative gets the default value.
- array(
- array(
+ [
+ [
'base_route' => 'local_task_example',
'id' => 'local_task_derivative_default:example_id',
'route_name' => 'local_task_example',
- ),
+ ],
'local_task_derivative_default:example_id',
-10,
- ),
- );
+ ],
+ ];
}
/**
@@ -248,7 +248,7 @@ class LocalTaskDefaultTest extends UnitTestCase {
*/
public function testGetTitleWithContext() {
$title = 'Example';
- $this->pluginDefinition['title'] = (new TranslatableMarkup($title, array(), array('context' => 'context'), $this->stringTranslation));
+ $this->pluginDefinition['title'] = (new TranslatableMarkup($title, [], ['context' => 'context'], $this->stringTranslation));
$this->stringTranslation->expects($this->once())
->method('translateString')
->with($this->pluginDefinition['title'])
@@ -262,7 +262,7 @@ class LocalTaskDefaultTest extends UnitTestCase {
* @covers ::getTitle
*/
public function testGetTitleWithTitleArguments() {
- $this->pluginDefinition['title'] = (new TranslatableMarkup('Example @test', array('@test' => 'value'), [], $this->stringTranslation));
+ $this->pluginDefinition['title'] = (new TranslatableMarkup('Example @test', ['@test' => 'value'], [], $this->stringTranslation));
$this->stringTranslation->expects($this->once())
->method('translateString')
->with($this->pluginDefinition['title'])
@@ -276,9 +276,9 @@ class LocalTaskDefaultTest extends UnitTestCase {
* @covers ::getOptions
*/
public function testGetOptions() {
- $this->pluginDefinition['options'] = array(
- 'attributes' => array('class' => array('example')),
- );
+ $this->pluginDefinition['options'] = [
+ 'attributes' => ['class' => ['example']],
+ ];
$this->setupLocalTaskDefault();
@@ -287,14 +287,14 @@ class LocalTaskDefaultTest extends UnitTestCase {
$this->localTaskBase->setActive(TRUE);
- $this->assertEquals(array(
- 'attributes' => array(
- 'class' => array(
+ $this->assertEquals([
+ 'attributes' => [
+ 'class' => [
'example',
'is-active'
- )
- )
- ), $this->localTaskBase->getOptions($route_match));
+ ]
+ ]
+ ], $this->localTaskBase->getOptions($route_match));
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php
index 5537046cb3b..8ac0bbf5366 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php
@@ -44,7 +44,7 @@ abstract class LocalTaskIntegrationTestBase extends UnitTestCase {
parent::setUp();
$container = new ContainerBuilder();
- $config_factory = $this->getConfigFactoryStub(array());
+ $config_factory = $this->getConfigFactoryStub([]);
$container->set('config.factory', $config_factory);
$container->set('app.root', $this->root);
\Drupal::setContainer($container);
@@ -115,7 +115,7 @@ abstract class LocalTaskIntegrationTestBase extends UnitTestCase {
$property->setValue($manager, $factory);
$cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
- $manager->setCacheBackend($cache_backend, 'local_task.en', array('local_task'));
+ $manager->setCacheBackend($cache_backend, 'local_task.en', ['local_task']);
return $manager;
}
@@ -130,9 +130,9 @@ abstract class LocalTaskIntegrationTestBase extends UnitTestCase {
* @param array $route_params
* (optional) a list of route parameters used to resolve tasks.
*/
- protected function assertLocalTasks($route_name, $expected_tasks, $route_params = array()) {
+ protected function assertLocalTasks($route_name, $expected_tasks, $route_params = []) {
- $directory_list = array();
+ $directory_list = [];
foreach ($this->directoryList as $key => $value) {
$directory_list[$key] = $this->root . '/' . $value;
}
@@ -148,7 +148,7 @@ abstract class LocalTaskIntegrationTestBase extends UnitTestCase {
// using the DefaultPluginManager base means we get into dependency soup
// because its factories create method and pulling services off the \Drupal
// container.
- $tasks = array();
+ $tasks = [];
foreach ($tmp_tasks as $level => $level_tasks) {
$tasks[$level] = array_keys($level_tasks);
}
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
index 2708c0c1eae..3d3d5015237 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
@@ -194,7 +194,7 @@ class LocalTaskManagerTest extends UnitTestCase {
$this->cacheBackend->expects($this->at(3))
->method('set')
- ->with('local_task_plugins:en:menu_local_task_test_tasks_view', $expected_set, Cache::PERMANENT, array('local_task'));
+ ->with('local_task_plugins:en:menu_local_task_test_tasks_view', $expected_set, Cache::PERMANENT, ['local_task']);
$local_tasks = $this->manager->getLocalTasksForRoute('menu_local_task_test_tasks_view');
$this->assertEquals($result, $local_tasks);
@@ -217,7 +217,7 @@ class LocalTaskManagerTest extends UnitTestCase {
$this->cacheBackend->expects($this->at(0))
->method('get')
->with('local_task_plugins:en:menu_local_task_test_tasks_view')
- ->will($this->returnValue((object) array('data' => $result)));
+ ->will($this->returnValue((object) ['data' => $result]));
$this->cacheBackend->expects($this->never())
->method('set');
@@ -239,8 +239,8 @@ class LocalTaskManagerTest extends UnitTestCase {
$this->controllerResolver->expects($this->once())
->method('getArguments')
- ->with($this->request, array($menu_local_task, 'getTitle'))
- ->will($this->returnValue(array()));
+ ->with($this->request, [$menu_local_task, 'getTitle'])
+ ->will($this->returnValue([]));
$this->manager->getTitle($menu_local_task);
}
@@ -254,11 +254,11 @@ class LocalTaskManagerTest extends UnitTestCase {
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$module_handler->expects($this->any())
->method('getModuleDirectories')
- ->willReturn(array());
+ ->willReturn([]);
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->any())
->method('getCurrentLanguage')
- ->will($this->returnValue(new Language(array('id' => 'en'))));
+ ->will($this->returnValue(new Language(['id' => 'en'])));
$this->manager = new LocalTaskManager($this->controllerResolver, $request_stack, $this->routeMatch, $this->routeProvider, $module_handler, $this->cacheBackend, $language_manager, $this->accessManager, $this->account);
@@ -279,51 +279,51 @@ class LocalTaskManagerTest extends UnitTestCase {
* An array of plugin definition keyed by plugin ID.
*/
protected function getLocalTaskFixtures() {
- $definitions = array();
- $definitions['menu_local_task_test_tasks_settings'] = array(
+ $definitions = [];
+ $definitions['menu_local_task_test_tasks_settings'] = [
'route_name' => 'menu_local_task_test_tasks_settings',
'title' => 'Settings',
'base_route' => 'menu_local_task_test_tasks_view',
- );
- $definitions['menu_local_task_test_tasks_edit'] = array(
+ ];
+ $definitions['menu_local_task_test_tasks_edit'] = [
'route_name' => 'menu_local_task_test_tasks_edit',
'title' => 'Settings',
'base_route' => 'menu_local_task_test_tasks_view',
'weight' => 20,
- );
+ ];
// Make this ID different from the route name to catch code that
// confuses them.
- $definitions['menu_local_task_test_tasks_view.tab'] = array(
+ $definitions['menu_local_task_test_tasks_view.tab'] = [
'route_name' => 'menu_local_task_test_tasks_view',
'title' => 'Settings',
'base_route' => 'menu_local_task_test_tasks_view',
- );
+ ];
- $definitions['menu_local_task_test_tasks_view_child1'] = array(
+ $definitions['menu_local_task_test_tasks_view_child1'] = [
'route_name' => 'menu_local_task_test_tasks_child1_page',
'title' => 'Settings child #1',
'parent_id' => 'menu_local_task_test_tasks_view.tab',
- );
- $definitions['menu_local_task_test_tasks_view_child2'] = array(
+ ];
+ $definitions['menu_local_task_test_tasks_view_child2'] = [
'route_name' => 'menu_local_task_test_tasks_child2_page',
'title' => 'Settings child #2',
'parent_id' => 'menu_local_task_test_tasks_view.tab',
'base_route' => 'this_should_be_replaced',
- );
+ ];
// Add the ID and defaults from the LocalTaskManager.
foreach ($definitions as $id => &$info) {
$info['id'] = $id;
- $info += array(
+ $info += [
'id' => '',
'route_name' => '',
- 'route_parameters' => array(),
+ 'route_parameters' => [],
'title' => '',
'base_route' => '',
'parent_id' => NULL,
'weight' => 0,
- 'options' => array(),
+ 'options' => [],
'class' => 'Drupal\Core\Menu\LocalTaskDefault',
- );
+ ];
}
return $definitions;
}
@@ -335,9 +335,9 @@ class LocalTaskManagerTest extends UnitTestCase {
* The mock plugin.
*/
protected function setupFactory($mock_plugin) {
- $map = array();
+ $map = [];
foreach ($this->getLocalTaskFixtures() as $info) {
- $map[] = array($info['id'], array(), $mock_plugin);
+ $map[] = [$info['id'], [], $mock_plugin];
}
$this->factory->expects($this->any())
->method('createInstance')
@@ -354,17 +354,17 @@ class LocalTaskManagerTest extends UnitTestCase {
* The expected result, keyed by local task level.
*/
protected function getLocalTasksForRouteResult($mock_plugin) {
- $result = array(
- 0 => array(
+ $result = [
+ 0 => [
'menu_local_task_test_tasks_settings' => $mock_plugin,
'menu_local_task_test_tasks_view.tab' => $mock_plugin,
'menu_local_task_test_tasks_edit' => $mock_plugin,
- ),
- 1 => array(
+ ],
+ 1 => [
'menu_local_task_test_tasks_view_child1' => $mock_plugin,
'menu_local_task_test_tasks_view_child2' => $mock_plugin,
- ),
- );
+ ],
+ ];
return $result;
}
@@ -375,26 +375,26 @@ class LocalTaskManagerTest extends UnitTestCase {
*/
protected function getLocalTasksCache() {
$local_task_fixtures = $this->getLocalTaskFixtures();
- $local_tasks = array(
- 'base_routes' => array(
+ $local_tasks = [
+ 'base_routes' => [
'menu_local_task_test_tasks_view' => 'menu_local_task_test_tasks_view',
- ),
- 'parents' => array(
+ ],
+ 'parents' => [
'menu_local_task_test_tasks_view.tab' => TRUE,
- ),
- 'children' => array(
- '> menu_local_task_test_tasks_view' => array(
+ ],
+ 'children' => [
+ '> menu_local_task_test_tasks_view' => [
'menu_local_task_test_tasks_settings' => $local_task_fixtures['menu_local_task_test_tasks_settings'],
'menu_local_task_test_tasks_edit' => $local_task_fixtures['menu_local_task_test_tasks_edit'],
'menu_local_task_test_tasks_view.tab' => $local_task_fixtures['menu_local_task_test_tasks_view.tab'],
- ),
- 'menu_local_task_test_tasks_view.tab' => array(
+ ],
+ 'menu_local_task_test_tasks_view.tab' => [
// The manager will fill in the base_route before caching.
- 'menu_local_task_test_tasks_view_child1' => array('base_route' => 'menu_local_task_test_tasks_view') + $local_task_fixtures['menu_local_task_test_tasks_view_child1'],
- 'menu_local_task_test_tasks_view_child2' => array('base_route' => 'menu_local_task_test_tasks_view') + $local_task_fixtures['menu_local_task_test_tasks_view_child2'],
- ),
- ),
- );
+ 'menu_local_task_test_tasks_view_child1' => ['base_route' => 'menu_local_task_test_tasks_view'] + $local_task_fixtures['menu_local_task_test_tasks_view_child1'],
+ 'menu_local_task_test_tasks_view_child2' => ['base_route' => 'menu_local_task_test_tasks_view'] + $local_task_fixtures['menu_local_task_test_tasks_view_child2'],
+ ],
+ ],
+ ];
$local_tasks['children']['> menu_local_task_test_tasks_view']['menu_local_task_test_tasks_settings']['weight'] = 0;
$local_tasks['children']['> menu_local_task_test_tasks_view']['menu_local_task_test_tasks_edit']['weight'] = 20 + 1e-6;
$local_tasks['children']['> menu_local_task_test_tasks_view']['menu_local_task_test_tasks_view.tab']['weight'] = 2e-6;
diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
index a1d21bd2f64..c7639388fd1 100644
--- a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
@@ -94,41 +94,41 @@ class MenuActiveTrailTest extends UnitTestCase {
* - expected_link: The expected active link for the given menu.
*/
public function provider() {
- $data = array();
+ $data = [];
$mock_route = new Route('');
$request = new Request();
$request->attributes->set(RouteObjectInterface::ROUTE_NAME, 'baby_llama');
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $mock_route);
- $request->attributes->set('_raw_variables', new ParameterBag(array()));
+ $request->attributes->set('_raw_variables', new ParameterBag([]));
- $link_1 = MenuLinkMock::create(array('id' => 'baby_llama_link_1', 'route_name' => 'baby_llama', 'title' => 'Baby llama', 'parent' => 'mama_llama_link'));
- $link_2 = MenuLinkMock::create(array('id' => 'baby_llama_link_2', 'route_name' => 'baby_llama', 'title' => 'Baby llama', 'parent' => 'papa_llama_link'));
+ $link_1 = MenuLinkMock::create(['id' => 'baby_llama_link_1', 'route_name' => 'baby_llama', 'title' => 'Baby llama', 'parent' => 'mama_llama_link']);
+ $link_2 = MenuLinkMock::create(['id' => 'baby_llama_link_2', 'route_name' => 'baby_llama', 'title' => 'Baby llama', 'parent' => 'papa_llama_link']);
// @see \Drupal\Core\Menu\MenuLinkManagerInterface::getParentIds()
- $link_1_parent_ids = array('baby_llama_link_1', 'mama_llama_link', '');
- $empty_active_trail = array('');
+ $link_1_parent_ids = ['baby_llama_link_1', 'mama_llama_link', ''];
+ $empty_active_trail = [''];
// No active link is returned when zero links match the current route.
- $data[] = array($request, array(), $this->randomMachineName(), NULL, $empty_active_trail);
+ $data[] = [$request, [], $this->randomMachineName(), NULL, $empty_active_trail];
// The first (and only) matching link is returned when one link matches the
// current route.
- $data[] = array($request, array('baby_llama_link_1' => $link_1), $this->randomMachineName(), $link_1, $link_1_parent_ids);
+ $data[] = [$request, ['baby_llama_link_1' => $link_1], $this->randomMachineName(), $link_1, $link_1_parent_ids];
// The first of multiple matching links is returned when multiple links
// match the current route, where "first" is determined by sorting by key.
- $data[] = array($request, array('baby_llama_link_1' => $link_1, 'baby_llama_link_2' => $link_2), $this->randomMachineName(), $link_1, $link_1_parent_ids);
+ $data[] = [$request, ['baby_llama_link_1' => $link_1, 'baby_llama_link_2' => $link_2], $this->randomMachineName(), $link_1, $link_1_parent_ids];
// No active link is returned in case of a 403.
$request = new Request();
$request->attributes->set('_exception_statuscode', 403);
- $data[] = array($request, FALSE, $this->randomMachineName(), NULL, $empty_active_trail);
+ $data[] = [$request, FALSE, $this->randomMachineName(), NULL, $empty_active_trail];
// No active link is returned when the route name is missing.
$request = new Request();
- $data[] = array($request, FALSE, $this->randomMachineName(), NULL, $empty_active_trail);
+ $data[] = [$request, FALSE, $this->randomMachineName(), NULL, $empty_active_trail];
return $data;
}
@@ -173,9 +173,9 @@ class MenuActiveTrailTest extends UnitTestCase {
if ($expected_link !== NULL) {
$this->menuLinkManager->expects($this->exactly(2))
->method('getParentIds')
- ->will($this->returnValueMap(array(
- array($expected_link->getPluginId(), $expected_trail_ids),
- )));
+ ->will($this->returnValueMap([
+ [$expected_link->getPluginId(), $expected_trail_ids],
+ ]));
}
}
@@ -213,9 +213,9 @@ class MenuActiveTrailTest extends UnitTestCase {
$this->menuLinkManager->expects($this->any())
->method('getParentIds')
- ->will($this->returnValueMap(array(
- array($expected_link->getPluginId(), $expected_trail_ids),
- )));
+ ->will($this->returnValueMap([
+ [$expected_link->getPluginId(), $expected_trail_ids],
+ ]));
$this->assertSame($expected_trail_ids, $this->menuActiveTrail->getActiveTrailIds($data[2]));
diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuLinkMock.php b/core/tests/Drupal/Tests/Core/Menu/MenuLinkMock.php
index 14c621ea2ca..5c3905c6b31 100644
--- a/core/tests/Drupal/Tests/Core/Menu/MenuLinkMock.php
+++ b/core/tests/Drupal/Tests/Core/Menu/MenuLinkMock.php
@@ -10,18 +10,18 @@ use Drupal\Core\Menu\MenuLinkBase;
*/
class MenuLinkMock extends MenuLinkBase {
- protected static $defaults = array(
+ protected static $defaults = [
'menu_name' => 'mock',
'route_name' => 'MUST BE PROVIDED',
- 'route_parameters' => array(),
+ 'route_parameters' => [],
'url' => '',
'title' => 'MUST BE PROVIDED',
- 'title_arguments' => array(),
+ 'title_arguments' => [],
'title_context' => '',
'description' => '',
'parent' => 'MUST BE PROVIDED',
'weight' => '0',
- 'options' => array(),
+ 'options' => [],
'expanded' => '0',
'enabled' => '1',
'provider' => 'simpletest',
@@ -33,13 +33,13 @@ class MenuLinkMock extends MenuLinkBase {
'class' => 'Drupal\\Tests\\Core\Menu\\MenuLinkMock',
'form_class' => 'Drupal\\Core\\Menu\\Form\\MenuLinkDefaultForm',
'id' => 'MUST BE PROVIDED',
- );
+ ];
/**
* Create an instance from a definition with at least id, title, route_name.
*/
public static function create($definition) {
- return new static(array(), $definition['id'], $definition + static::$defaults);
+ return new static([], $definition['id'], $definition + static::$defaults);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php
index 0ea10070319..a18cf8cf765 100644
--- a/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php
@@ -20,13 +20,13 @@ class MenuLinkTreeElementTest extends UnitTestCase {
* @covers ::__construct
*/
public function testConstruction() {
- $link = MenuLinkMock::create(array('id' => 'test'));
- $item = new MenuLinkTreeElement($link, FALSE, 3, FALSE, array());
+ $link = MenuLinkMock::create(['id' => 'test']);
+ $item = new MenuLinkTreeElement($link, FALSE, 3, FALSE, []);
$this->assertSame($link, $item->link);
$this->assertSame(FALSE, $item->hasChildren);
$this->assertSame(3, $item->depth);
$this->assertSame(FALSE, $item->inActiveTrail);
- $this->assertSame(array(), $item->subtree);
+ $this->assertSame([], $item->subtree);
}
/**
@@ -35,10 +35,10 @@ class MenuLinkTreeElementTest extends UnitTestCase {
* @covers ::count
*/
public function testCount() {
- $link_1 = MenuLinkMock::create(array('id' => 'test_1'));
- $link_2 = MenuLinkMock::create(array('id' => 'test_2'));
- $child_item = new MenuLinkTreeElement($link_2, FALSE, 2, FALSE, array());
- $parent_item = new MenuLinkTreeElement($link_1, FALSE, 2, FALSE, array($child_item));
+ $link_1 = MenuLinkMock::create(['id' => 'test_1']);
+ $link_2 = MenuLinkMock::create(['id' => 'test_2']);
+ $child_item = new MenuLinkTreeElement($link_2, FALSE, 2, FALSE, []);
+ $parent_item = new MenuLinkTreeElement($link_1, FALSE, 2, FALSE, [$child_item]);
$this->assertSame(1, $child_item->count());
$this->assertSame(2, $parent_item->count());
}
diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php
index e9d664e98ec..ccaf3b9c72e 100644
--- a/core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php
@@ -18,22 +18,22 @@ class MenuTreeParametersTest extends UnitTestCase {
* Provides test data for testSetMinDepth().
*/
public function providerTestSetMinDepth() {
- $data = array();
+ $data = [];
// Valid values at the extremes and in the middle.
- $data[] = array(1, 1);
- $data[] = array(2, 2);
- $data[] = array(9, 9);
+ $data[] = [1, 1];
+ $data[] = [2, 2];
+ $data[] = [9, 9];
// Invalid values are mapped to the closest valid value.
- $data[] = array(-10000, 1);
- $data[] = array(0, 1);
+ $data[] = [-10000, 1];
+ $data[] = [0, 1];
// … except for those invalid values that reach beyond the maximum depth,
// because MenuTreeParameters is a value object and hence cannot depend
// on anything; to know the actual maximum depth, it'd have to depend on the
// MenuTreeStorage service.
- $data[] = array(10, 10);
- $data[] = array(100000, 100000);
+ $data[] = [10, 10];
+ $data[] = [100000, 100000];
return $data;
}
@@ -59,21 +59,21 @@ class MenuTreeParametersTest extends UnitTestCase {
$parameters = new MenuTreeParameters();
// Verify default value.
- $this->assertEquals(array(), $parameters->expandedParents);
+ $this->assertEquals([], $parameters->expandedParents);
// Add actual menu link plugin IDs to be expanded.
- $parameters->addExpandedParents(array('foo', 'bar', 'baz'));
- $this->assertEquals(array('foo', 'bar', 'baz'), $parameters->expandedParents);
+ $parameters->addExpandedParents(['foo', 'bar', 'baz']);
+ $this->assertEquals(['foo', 'bar', 'baz'], $parameters->expandedParents);
// Add additional menu link plugin IDs; they should be merged, not replacing
// the old ones.
- $parameters->addExpandedParents(array('qux', 'quux'));
- $this->assertEquals(array('foo', 'bar', 'baz', 'qux', 'quux'), $parameters->expandedParents);
+ $parameters->addExpandedParents(['qux', 'quux']);
+ $this->assertEquals(['foo', 'bar', 'baz', 'qux', 'quux'], $parameters->expandedParents);
// Add pre-existing menu link plugin IDs; they should not be added again;
// this is a set.
- $parameters->addExpandedParents(array('bar', 'quux'));
- $this->assertEquals(array('foo', 'bar', 'baz', 'qux', 'quux'), $parameters->expandedParents);
+ $parameters->addExpandedParents(['bar', 'quux']);
+ $this->assertEquals(['foo', 'bar', 'baz', 'qux', 'quux'], $parameters->expandedParents);
}
/**
@@ -85,28 +85,28 @@ class MenuTreeParametersTest extends UnitTestCase {
$parameters = new MenuTreeParameters();
// Verify default value.
- $this->assertEquals(array(), $parameters->conditions);
+ $this->assertEquals([], $parameters->conditions);
// Add a condition.
$parameters->addCondition('expanded', 1);
- $this->assertEquals(array('expanded' => 1), $parameters->conditions);
+ $this->assertEquals(['expanded' => 1], $parameters->conditions);
// Add another condition.
$parameters->addCondition('has_children', 0);
- $this->assertEquals(array('expanded' => 1, 'has_children' => 0), $parameters->conditions);
+ $this->assertEquals(['expanded' => 1, 'has_children' => 0], $parameters->conditions);
// Add a condition with an operator.
- $parameters->addCondition('provider', array('module1', 'module2'), 'IN');
- $this->assertEquals(array('expanded' => 1, 'has_children' => 0, 'provider' => array(array('module1', 'module2'), 'IN')), $parameters->conditions);
+ $parameters->addCondition('provider', ['module1', 'module2'], 'IN');
+ $this->assertEquals(['expanded' => 1, 'has_children' => 0, 'provider' => [['module1', 'module2'], 'IN']], $parameters->conditions);
// Add another condition with an operator.
$parameters->addCondition('id', 1337, '<');
- $this->assertEquals(array('expanded' => 1, 'has_children' => 0, 'provider' => array(array('module1', 'module2'), 'IN'), 'id' => array(1337, '<')), $parameters->conditions);
+ $this->assertEquals(['expanded' => 1, 'has_children' => 0, 'provider' => [['module1', 'module2'], 'IN'], 'id' => [1337, '<']], $parameters->conditions);
// It's impossible to add two conditions on the same field; in that case,
// the old condition will be overwritten.
$parameters->addCondition('provider', 'other_module');
- $this->assertEquals(array('expanded' => 1, 'has_children' => 0, 'provider' => 'other_module', 'id' => array(1337, '<')), $parameters->conditions);
+ $this->assertEquals(['expanded' => 1, 'has_children' => 0, 'provider' => 'other_module', 'id' => [1337, '<']], $parameters->conditions);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
index e09a56e81a6..98a122ca214 100644
--- a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
@@ -17,7 +17,7 @@ class StaticMenuLinkOverridesTest extends UnitTestCase {
* @covers ::__construct
*/
public function testConstruct() {
- $config_factory = $this->getConfigFactoryStub(array('core.menu.static_menu_link_overrides' => array()));
+ $config_factory = $this->getConfigFactoryStub(['core.menu.static_menu_link_overrides' => []]);
$static_override = new StaticMenuLinkOverrides($config_factory);
$this->assertAttributeEquals($config_factory, 'configFactory', $static_override);
@@ -48,7 +48,7 @@ class StaticMenuLinkOverridesTest extends UnitTestCase {
* @covers ::getConfig
*/
public function testLoadOverride($overrides, $id, $expected) {
- $config_factory = $this->getConfigFactoryStub(array('core.menu.static_menu_link_overrides' => array('definitions' => $overrides)));
+ $config_factory = $this->getConfigFactoryStub(['core.menu.static_menu_link_overrides' => ['definitions' => $overrides]]);
$static_override = new StaticMenuLinkOverrides($config_factory);
$this->assertEquals($expected, $static_override->loadOverride($id));
@@ -58,15 +58,15 @@ class StaticMenuLinkOverridesTest extends UnitTestCase {
* Provides test data for testLoadOverride.
*/
public function providerTestLoadOverride() {
- $data = array();
+ $data = [];
// No specified ID.
- $data[] = array(array('test1' => array('parent' => 'test0')), NULL, array());
+ $data[] = [['test1' => ['parent' => 'test0']], NULL, []];
// Valid ID.
- $data[] = array(array('test1' => array('parent' => 'test0')), 'test1', array('parent' => 'test0'));
+ $data[] = [['test1' => ['parent' => 'test0']], 'test1', ['parent' => 'test0']];
// Non existing ID.
- $data[] = array(array('test1' => array('parent' => 'test0')), 'test2', array());
+ $data[] = [['test1' => ['parent' => 'test0']], 'test2', []];
// Ensure that the ID is encoded properly
- $data[] = array(array('test1__la___ma' => array('parent' => 'test0')), 'test1.la__ma', array('parent' => 'test0'));
+ $data[] = [['test1__la___ma' => ['parent' => 'test0']], 'test1.la__ma', ['parent' => 'test0']];
return $data;
}
@@ -78,15 +78,15 @@ class StaticMenuLinkOverridesTest extends UnitTestCase {
* @covers ::getConfig
*/
public function testLoadMultipleOverrides() {
- $overrides = array();
- $overrides['test1'] = array('parent' => 'test0');
- $overrides['test2'] = array('parent' => 'test1');
- $overrides['test1__la___ma'] = array('parent' => 'test2');
+ $overrides = [];
+ $overrides['test1'] = ['parent' => 'test0'];
+ $overrides['test2'] = ['parent' => 'test1'];
+ $overrides['test1__la___ma'] = ['parent' => 'test2'];
- $config_factory = $this->getConfigFactoryStub(array('core.menu.static_menu_link_overrides' => array('definitions' => $overrides)));
+ $config_factory = $this->getConfigFactoryStub(['core.menu.static_menu_link_overrides' => ['definitions' => $overrides]]);
$static_override = new StaticMenuLinkOverrides($config_factory);
- $this->assertEquals(array('test1' => array('parent' => 'test0'), 'test1.la__ma' => array('parent' => 'test2')), $static_override->loadMultipleOverrides(array('test1', 'test1.la__ma')));
+ $this->assertEquals(['test1' => ['parent' => 'test0'], 'test1.la__ma' => ['parent' => 'test2']], $static_override->loadMultipleOverrides(['test1', 'test1.la__ma']));
}
/**
@@ -103,23 +103,23 @@ class StaticMenuLinkOverridesTest extends UnitTestCase {
$config->expects($this->at(0))
->method('get')
->with('definitions')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$config->expects($this->at(1))
->method('get')
->with('definitions')
- ->will($this->returnValue(array()));
-
- $definition_save_1 = array(
- 'definitions' => array(
- 'test1' => array('parent' => 'test0', 'menu_name' => '', 'weight' => 0, 'expanded' => FALSE, 'enabled' => FALSE)
- )
- );
- $definitions_save_2 = array(
- 'definitions' => array(
- 'test1' => array('parent' => 'test0', 'menu_name' => '', 'weight' => 0, 'expanded' => FALSE, 'enabled' => FALSE),
- 'test1__la___ma' => array('parent' => 'test1', 'menu_name' => '', 'weight' => 0, 'expanded' => FALSE, 'enabled' => FALSE)
- )
- );
+ ->will($this->returnValue([]));
+
+ $definition_save_1 = [
+ 'definitions' => [
+ 'test1' => ['parent' => 'test0', 'menu_name' => '', 'weight' => 0, 'expanded' => FALSE, 'enabled' => FALSE]
+ ]
+ ];
+ $definitions_save_2 = [
+ 'definitions' => [
+ 'test1' => ['parent' => 'test0', 'menu_name' => '', 'weight' => 0, 'expanded' => FALSE, 'enabled' => FALSE],
+ 'test1__la___ma' => ['parent' => 'test1', 'menu_name' => '', 'weight' => 0, 'expanded' => FALSE, 'enabled' => FALSE]
+ ]
+ ];
$config->expects($this->at(2))
->method('set')
->with('definitions', $definition_save_1['definitions'])
@@ -148,8 +148,8 @@ class StaticMenuLinkOverridesTest extends UnitTestCase {
$static_override = new StaticMenuLinkOverrides($config_factory);
- $static_override->saveOverride('test1', array('parent' => 'test0'));
- $static_override->saveOverride('test1.la__ma', array('parent' => 'test1'));
+ $static_override->saveOverride('test1', ['parent' => 'test0']);
+ $static_override->saveOverride('test1.la__ma', ['parent' => 'test1']);
}
/**
@@ -202,15 +202,15 @@ class StaticMenuLinkOverridesTest extends UnitTestCase {
* Provides test data for testDeleteOverrides.
*/
public function providerTestDeleteOverrides() {
- $data = array();
+ $data = [];
// Delete a non existing ID.
- $data[] = array('test0', array(), array());
+ $data[] = ['test0', [], []];
// Delete an existing ID.
- $data[] = array('test1', array('test1' => array('parent' => 'test0')), array());
+ $data[] = ['test1', ['test1' => ['parent' => 'test0']], []];
// Delete an existing ID with a special ID.
- $data[] = array('test1.la__ma', array('test1__la___ma' => array('parent' => 'test0')), array());
+ $data[] = ['test1.la__ma', ['test1__la___ma' => ['parent' => 'test0']], []];
// Delete multiple IDs.
- $data[] = array(array('test1.la__ma', 'test1'), array('test1' => array('parent' => 'test0'), 'test1__la___ma' => array('parent' => 'test0')), array());
+ $data[] = [['test1.la__ma', 'test1'], ['test1' => ['parent' => 'test0'], 'test1__la___ma' => ['parent' => 'test0']], []];
return $data;
}
diff --git a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
index 2f62f1e8e40..46f78c637a1 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
@@ -22,7 +22,7 @@ class CommandLineOrUnsafeMethodTest extends UnitTestCase {
protected function setUp() {
// Note that it is necessary to partially mock the class under test in
// order to disable the isCli-check.
- $this->policy = $this->getMock('Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod', array('isCli'));
+ $this->policy = $this->getMock('Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod', ['isCli']);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
index cc248b0b43c..1c85cf6b9a0 100644
--- a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
@@ -68,35 +68,35 @@ class ParamConverterManagerTest extends UnitTestCase {
* @see ParamConverterManagerTest::testAddConverter()
*/
public function providerTestAddConverter() {
- $converters[0]['unsorted'] = array(
- array('name' => 'strawberry'),
- array('name' => 'raspberry'),
- array('name' => 'pear'),
- array('name' => 'peach'),
- array('name' => 'pineapple'),
- array('name' => 'banana'),
- array('name' => 'apple'),
- );
-
- $converters[0]['sorted'] = array(
+ $converters[0]['unsorted'] = [
+ ['name' => 'strawberry'],
+ ['name' => 'raspberry'],
+ ['name' => 'pear'],
+ ['name' => 'peach'],
+ ['name' => 'pineapple'],
+ ['name' => 'banana'],
+ ['name' => 'apple'],
+ ];
+
+ $converters[0]['sorted'] = [
'strawberry', 'raspberry', 'pear', 'peach',
'pineapple', 'banana', 'apple'
- );
-
- $converters[1]['unsorted'] = array(
- array('name' => 'giraffe'),
- array('name' => 'zebra'),
- array('name' => 'eagle'),
- array('name' => 'ape'),
- array('name' => 'cat'),
- array('name' => 'puppy'),
- array('name' => 'llama'),
- );
-
- $converters[1]['sorted'] = array(
+ ];
+
+ $converters[1]['unsorted'] = [
+ ['name' => 'giraffe'],
+ ['name' => 'zebra'],
+ ['name' => 'eagle'],
+ ['name' => 'ape'],
+ ['name' => 'cat'],
+ ['name' => 'puppy'],
+ ['name' => 'llama'],
+ ];
+
+ $converters[1]['sorted'] = [
'giraffe', 'zebra', 'eagle', 'ape',
'cat', 'puppy', 'llama'
- );
+ ];
return $converters;
}
@@ -111,15 +111,15 @@ class ParamConverterManagerTest extends UnitTestCase {
* @see ParamConverterManagerTest::testGetConverter()
*/
public function providerTestGetConverter() {
- return array(
- array('ape', 'ApeConverterClass'),
- array('cat', 'CatConverterClass'),
- array('puppy', 'PuppyConverterClass'),
- array('llama', 'LlamaConverterClass'),
- array('giraffe', 'GiraffeConverterClass'),
- array('zebra', 'ZebraConverterClass'),
- array('eagle', 'EagleConverterClass'),
- );
+ return [
+ ['ape', 'ApeConverterClass'],
+ ['cat', 'CatConverterClass'],
+ ['puppy', 'PuppyConverterClass'],
+ ['llama', 'LlamaConverterClass'],
+ ['giraffe', 'GiraffeConverterClass'],
+ ['zebra', 'ZebraConverterClass'],
+ ['eagle', 'EagleConverterClass'],
+ ];
}
/**
@@ -158,11 +158,11 @@ class ParamConverterManagerTest extends UnitTestCase {
* Provides data for testSetRouteParameterConverters().
*/
public function providerTestSetRouteParameterConverters() {
- return array(
- array('/test'),
- array('/test/{id}', array('id' => array()), 'applied'),
- array('/test/{id}', array('id' => array('converter' => 'predefined')), 'predefined'),
- );
+ return [
+ ['/test'],
+ ['/test/{id}', ['id' => []], 'applied'],
+ ['/test/{id}', ['id' => ['converter' => 'predefined']], 'predefined'],
+ ];
}
/**
@@ -170,22 +170,22 @@ class ParamConverterManagerTest extends UnitTestCase {
*/
public function testConvert() {
$route = new Route('/test/{id}/{literal}/{null}');
- $parameters = array(
- 'id' => array(
+ $parameters = [
+ 'id' => [
'converter' => 'test_convert',
- ),
- 'literal' => array(),
- 'null' => array(),
- );
+ ],
+ 'literal' => [],
+ 'null' => [],
+ ];
$route->setOption('parameters', $parameters);
- $defaults = array(
+ $defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
RouteObjectInterface::ROUTE_NAME => 'test_route',
'id' => 1,
'literal' => 'this is a literal',
'null' => NULL,
- );
+ ];
$expected = $defaults;
$expected['id'] = 'something_better!';
@@ -207,10 +207,10 @@ class ParamConverterManagerTest extends UnitTestCase {
*/
public function testConvertNoConverting() {
$route = new Route('/test');
- $defaults = array(
+ $defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
RouteObjectInterface::ROUTE_NAME => 'test_route',
- );
+ ];
$expected = $defaults;
@@ -226,18 +226,18 @@ class ParamConverterManagerTest extends UnitTestCase {
*/
public function testConvertMissingParam() {
$route = new Route('/test/{id}');
- $parameters = array(
- 'id' => array(
+ $parameters = [
+ 'id' => [
'converter' => 'test_convert',
- ),
- );
+ ],
+ ];
$route->setOption('parameters', $parameters);
- $defaults = array(
+ $defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
RouteObjectInterface::ROUTE_NAME => 'test_route',
'id' => 1,
- );
+ ];
$converter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterInterface');
$converter->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php b/core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php
index 5c378ed622a..efb8cac8507 100644
--- a/core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php
+++ b/core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php
@@ -152,21 +152,21 @@ class PasswordHashingTest extends UnitTestCase {
*/
public function providerLongPasswords() {
// '512 byte long password is allowed.'
- $passwords['allowed'] = array(str_repeat('x', PasswordInterface::PASSWORD_MAX_LENGTH), TRUE);
+ $passwords['allowed'] = [str_repeat('x', PasswordInterface::PASSWORD_MAX_LENGTH), TRUE];
// 513 byte long password is not allowed.
- $passwords['too_long'] = array(str_repeat('x', PasswordInterface::PASSWORD_MAX_LENGTH + 1), FALSE);
+ $passwords['too_long'] = [str_repeat('x', PasswordInterface::PASSWORD_MAX_LENGTH + 1), FALSE];
// Check a string of 3-byte UTF-8 characters, 510 byte long password is
// allowed.
$len = floor(PasswordInterface::PASSWORD_MAX_LENGTH / 3);
$diff = PasswordInterface::PASSWORD_MAX_LENGTH % 3;
- $passwords['utf8'] = array(str_repeat('€', $len), TRUE);
+ $passwords['utf8'] = [str_repeat('€', $len), TRUE];
// 512 byte long password is allowed.
- $passwords['ut8_extended'] = array($passwords['utf8'][0] . str_repeat('x', $diff), TRUE);
+ $passwords['ut8_extended'] = [$passwords['utf8'][0] . str_repeat('x', $diff), TRUE];
// Check a string of 3-byte UTF-8 characters, 513 byte long password is
// allowed.
- $passwords['utf8_too_long'] = array(str_repeat('€', $len + 1), FALSE);
+ $passwords['utf8_too_long'] = [str_repeat('€', $len + 1), FALSE];
return $passwords;
}
diff --git a/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php b/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php
index 569f394ba15..ffd52dc4af4 100644
--- a/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php
@@ -85,7 +85,7 @@ class AliasManagerTest extends UnitTestCase {
public function testGetPathByAliasNoMatch() {
$alias = '/' . $this->randomMachineName();
- $language = new Language(array('id' => 'en'));
+ $language = new Language(['id' => 'en']);
$this->languageManager->expects($this->any())
->method('getCurrentLanguage')
@@ -202,7 +202,7 @@ class AliasManagerTest extends UnitTestCase {
// This needs to write out the cache.
$this->cache->expects($this->once())
->method('set')
- ->with($this->cacheKey, array($language->getId() => array($path)), (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
+ ->with($this->cacheKey, [$language->getId() => [$path]], (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
$this->aliasManager->writeCache();
}
@@ -240,7 +240,7 @@ class AliasManagerTest extends UnitTestCase {
// This needs to write out the cache.
$this->cache->expects($this->once())
->method('set')
- ->with($this->cacheKey, array($language->getId() => array($path)), (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
+ ->with($this->cacheKey, [$language->getId() => [$path]], (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
$this->aliasManager->writeCache();
}
@@ -259,11 +259,11 @@ class AliasManagerTest extends UnitTestCase {
$language = $this->setUpCurrentLanguage();
- $cached_paths = array($language->getId() => array($path));
+ $cached_paths = [$language->getId() => [$path]];
$this->cache->expects($this->once())
->method('get')
->with($this->cacheKey)
- ->will($this->returnValue((object) array('data' => $cached_paths)));
+ ->will($this->returnValue((object) ['data' => $cached_paths]));
// Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path);
@@ -276,7 +276,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasStorage->expects($this->once())
->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId())
- ->will($this->returnValue(array($path => $alias)));
+ ->will($this->returnValue([$path => $alias]));
// LookupPathAlias should not be called.
$this->aliasStorage->expects($this->never())
@@ -305,13 +305,13 @@ class AliasManagerTest extends UnitTestCase {
$alias = $this->randomMachineName();
$language = $this->setUpCurrentLanguage();
- $cached_language = new Language(array('id' => 'de'));
+ $cached_language = new Language(['id' => 'de']);
- $cached_paths = array($cached_language->getId() => array($path));
+ $cached_paths = [$cached_language->getId() => [$path]];
$this->cache->expects($this->once())
->method('get')
->with($this->cacheKey)
- ->will($this->returnValue((object) array('data' => $cached_paths)));
+ ->will($this->returnValue((object) ['data' => $cached_paths]));
// Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path);
@@ -356,11 +356,11 @@ class AliasManagerTest extends UnitTestCase {
$language = $this->setUpCurrentLanguage();
- $cached_paths = array($language->getId() => array($cached_path, $path));
+ $cached_paths = [$language->getId() => [$cached_path, $path]];
$this->cache->expects($this->once())
->method('get')
->with($this->cacheKey)
- ->will($this->returnValue((object) array('data' => $cached_paths)));
+ ->will($this->returnValue((object) ['data' => $cached_paths]));
// Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path);
@@ -373,7 +373,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasStorage->expects($this->once())
->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId())
- ->will($this->returnValue(array($cached_path => $cached_alias)));
+ ->will($this->returnValue([$cached_path => $cached_alias]));
// LookupPathAlias() should not be called.
$this->aliasStorage->expects($this->never())
@@ -404,11 +404,11 @@ class AliasManagerTest extends UnitTestCase {
$language = $this->setUpCurrentLanguage();
- $cached_paths = array($language->getId() => array($cached_path));
+ $cached_paths = [$language->getId() => [$cached_path]];
$this->cache->expects($this->once())
->method('get')
->with($this->cacheKey)
- ->will($this->returnValue((object) array('data' => $cached_paths)));
+ ->will($this->returnValue((object) ['data' => $cached_paths]));
// Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path);
@@ -421,7 +421,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasStorage->expects($this->once())
->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId())
- ->will($this->returnValue(array($cached_path => $cached_alias)));
+ ->will($this->returnValue([$cached_path => $cached_alias]));
$this->aliasStorage->expects($this->once())
->method('lookupPathAlias')
@@ -493,11 +493,11 @@ class AliasManagerTest extends UnitTestCase {
$language = $this->setUpCurrentLanguage();
- $cached_paths = array($language->getId() => array($cached_path, $cached_no_alias_path));
+ $cached_paths = [$language->getId() => [$cached_path, $cached_no_alias_path]];
$this->cache->expects($this->once())
->method('get')
->with($this->cacheKey)
- ->will($this->returnValue((object) array('data' => $cached_paths)));
+ ->will($this->returnValue((object) ['data' => $cached_paths]));
// Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path);
@@ -510,7 +510,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasStorage->expects($this->once())
->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId())
- ->will($this->returnValue(array($cached_path => $cached_alias)));
+ ->will($this->returnValue([$cached_path => $cached_alias]));
$this->aliasStorage->expects($this->once())
->method('lookupPathAlias')
@@ -535,7 +535,7 @@ class AliasManagerTest extends UnitTestCase {
* The current language object.
*/
protected function setUpCurrentLanguage() {
- $language = new Language(array('id' => 'en'));
+ $language = new Language(['id' => 'en']);
$this->languageManager->expects($this->any())
->method('getCurrentLanguage')
diff --git a/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php b/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php
index b4566549575..7089121d5e2 100644
--- a/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php
+++ b/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php
@@ -25,11 +25,11 @@ class PathMatcherTest extends UnitTestCase {
// Create a stub config factory with all config settings that will be
// checked during this test.
$config_factory_stub = $this->getConfigFactoryStub(
- array(
- 'system.site' => array(
+ [
+ 'system.site' => [
'page.front' => '/dummy',
- ),
- )
+ ],
+ ]
);
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$this->pathMatcher = new PathMatcher($config_factory_stub, $route_match);
@@ -54,76 +54,76 @@ class PathMatcherTest extends UnitTestCase {
* A nested array of pattern arrays and path arrays.
*/
public function getMatchPathData() {
- return array(
- array(
+ return [
+ [
// Single absolute paths.
'/example/1',
- array(
+ [
'/example/1' => TRUE,
'/example/2' => FALSE,
'/test' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Single paths with wildcards.
'/example/*',
- array(
+ [
'/example/1' => TRUE,
'/example/2' => TRUE,
'/example/3/edit' => TRUE,
'/example/' => TRUE,
'/example' => FALSE,
'/test' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Single paths with multiple wildcards.
'/node/*/revisions/*',
- array(
+ [
'/node/1/revisions/3' => TRUE,
'/node/345/revisions/test' => TRUE,
'/node/23/edit' => FALSE,
'/test' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Single paths with '<front>'.
"<front>",
- array(
+ [
'/dummy' => TRUE,
"/dummy/" => FALSE,
"/dummy/edit" => FALSE,
'/node' => FALSE,
'' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Paths with both '<front>' and wildcards (should not work).
"<front>/*",
- array(
+ [
'/dummy' => FALSE,
'/dummy/' => FALSE,
'/dummy/edit' => FALSE,
'/node/12' => FALSE,
'/' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Multiple paths with the \n delimiter.
"/node/*\n/node/*/edit",
- array(
+ [
'/node/1' => TRUE,
'/node/view' => TRUE,
'/node/32/edit' => TRUE,
'/node/delete/edit' => TRUE,
'/node/50/delete' => TRUE,
'/test/example' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Multiple paths with the \r delimiter.
"/user/*\r/example/*",
- array(
+ [
'/user/1' => TRUE,
'/example/1' => TRUE,
'/user/1/example/1' => TRUE,
@@ -131,26 +131,26 @@ class PathMatcherTest extends UnitTestCase {
'/test/example' => FALSE,
'/user' => FALSE,
'/example' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Multiple paths with the \r\n delimiter.
"/test\r\n<front>",
- array(
+ [
'/test' => TRUE,
'/dummy' => TRUE,
'/example' => FALSE,
- ),
- ),
- array(
+ ],
+ ],
+ [
// Test existing regular expressions (should be escaped).
'[^/]+?/[0-9]',
- array(
+ [
'/test/1' => FALSE,
'[^/]+?/[0-9]' => TRUE,
- ),
- ),
- );
+ ],
+ ],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php
index 713a5386622..0473d79d788 100644
--- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php
+++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php
@@ -41,10 +41,10 @@ class PathProcessorAliasTest extends UnitTestCase {
public function testProcessInbound() {
$this->aliasManager->expects($this->exactly(2))
->method('getPathByAlias')
- ->will($this->returnValueMap(array(
- array('urlalias', NULL, 'internal-url'),
- array('url', NULL, 'url'),
- )));
+ ->will($this->returnValueMap([
+ ['urlalias', NULL, 'internal-url'],
+ ['url', NULL, 'url'],
+ ]));
$request = Request::create('/urlalias');
$this->assertEquals('internal-url', $this->pathProcessor->processInbound('urlalias', $request));
@@ -60,10 +60,10 @@ class PathProcessorAliasTest extends UnitTestCase {
public function testProcessOutbound($path, array $options, $expected_path) {
$this->aliasManager->expects($this->any())
->method('getAliasByPath')
- ->will($this->returnValueMap(array(
- array('internal-url', NULL, 'urlalias'),
- array('url', NULL, 'url'),
- )));
+ ->will($this->returnValueMap([
+ ['internal-url', NULL, 'urlalias'],
+ ['url', NULL, 'url'],
+ ]));
$bubbleable_metadata = new BubbleableMetadata();
$this->assertEquals($expected_path, $this->pathProcessor->processOutbound($path, $options, NULL, $bubbleable_metadata));
diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
index 1134eccab63..f416570dd96 100644
--- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
+++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
@@ -38,28 +38,28 @@ class PathProcessorTest extends UnitTestCase {
protected function setUp() {
// Set up some languages to be used by the language-based path processor.
- $languages = array();
- foreach (array('en', 'fr') as $langcode) {
- $language = new Language(array('id' => $langcode));
+ $languages = [];
+ foreach (['en', 'fr'] as $langcode) {
+ $language = new Language(['id' => $langcode]);
$languages[$langcode] = $language;
}
$this->languages = $languages;
// Create a stub configuration.
$language_prefixes = array_keys($this->languages);
- $config = array(
- 'url' => array(
+ $config = [
+ 'url' => [
'prefixes' => array_combine($language_prefixes, $language_prefixes)
- )
- );
+ ]
+ ];
// Create a URL-based language negotiation method definition.
- $method_definitions = array(
- LanguageNegotiationUrl::METHOD_ID => array(
+ $method_definitions = [
+ LanguageNegotiationUrl::METHOD_ID => [
'class' => '\Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl',
'weight' => 9,
- ),
- );
+ ],
+ ];
// Create a URL-based language negotiation method.
$method_instance = new LanguageNegotiationUrl($config);
@@ -75,7 +75,7 @@ class PathProcessorTest extends UnitTestCase {
->will($this->returnValue($this->languages));
$language_manager->expects($this->any())
->method('getLanguageTypes')
- ->will($this->returnValue(array(LanguageInterface::TYPE_INTERFACE)));
+ ->will($this->returnValue([LanguageInterface::TYPE_INTERFACE]));
$language_manager->expects($this->any())
->method('getNegotiationMethods')
->will($this->returnValue($method_definitions));
@@ -97,14 +97,14 @@ class PathProcessorTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- $system_path_map = array(
+ $system_path_map = [
// Set up one proper alias that can be resolved to a system path.
- array('/foo', NULL, '/user/1'),
+ ['/foo', NULL, '/user/1'],
// Passing in anything else should return the same string.
- array('/fr/foo', NULL, '/fr/foo'),
- array('/fr', NULL, '/fr'),
- array('/user/login', NULL, '/user/login'),
- );
+ ['/fr/foo', NULL, '/fr/foo'],
+ ['/fr', NULL, '/fr'],
+ ['/user/login', NULL, '/user/login'],
+ ];
$alias_manager->expects($this->any())
->method('getPathByAlias')
@@ -113,16 +113,16 @@ class PathProcessorTest extends UnitTestCase {
// Create a stub config factory with all config settings that will be checked
// during this test.
$config_factory_stub = $this->getConfigFactoryStub(
- array(
- 'system.site' => array(
+ [
+ 'system.site' => [
'page.front' => '/user/login'
- ),
- 'language.negotiation' => array(
- 'url' => array(
- 'prefixes' => array('fr' => 'fr'),
- ),
- ),
- )
+ ],
+ 'language.negotiation' => [
+ 'url' => [
+ 'prefixes' => ['fr' => 'fr'],
+ ],
+ ],
+ ]
);
// Create a language negotiator stub.
@@ -130,10 +130,10 @@ class PathProcessorTest extends UnitTestCase {
->getMock();
$negotiator->expects($this->any())
->method('getNegotiationMethods')
- ->will($this->returnValue(array(LanguageNegotiationUrl::METHOD_ID => array(
+ ->will($this->returnValue([LanguageNegotiationUrl::METHOD_ID => [
'class' => 'Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl',
'weight' => 9,
- ))));
+ ]]));
$method = new LanguageNegotiationUrl();
$method->setConfig($config_factory_stub);
$method->setLanguageManager($this->languageManager);
@@ -159,12 +159,12 @@ class PathProcessorTest extends UnitTestCase {
// First, test the processor manager with the processors in the incorrect
// order. The alias processor will run before the language processor, meaning
// aliases will not be found.
- $priorities = array(
+ $priorities = [
1000 => $alias_processor,
500 => $decode_processor,
300 => $front_processor,
200 => $language_processor,
- );
+ ];
// Create the processor manager and add the processors.
$processor_manager = new PathProcessorManager();
@@ -187,12 +187,12 @@ class PathProcessorTest extends UnitTestCase {
// Now create a new processor manager and add the processors, this time in
// the correct order.
$processor_manager = new PathProcessorManager();
- $priorities = array(
+ $priorities = [
1000 => $decode_processor,
500 => $language_processor,
300 => $front_processor,
200 => $alias_processor,
- );
+ ];
foreach ($priorities as $priority => $processor) {
$processor_manager->addInbound($processor, $priority);
}
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php
index fb1a4422985..8d9cc52d312 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php
@@ -19,10 +19,10 @@ class ContextDefinitionTest extends UnitTestCase {
* Very simple data provider.
*/
public function providerGetDataDefinition() {
- return array(
- array(TRUE),
- array(FALSE),
- );
+ return [
+ [TRUE],
+ [FALSE],
+ ];
}
/**
@@ -33,13 +33,13 @@ class ContextDefinitionTest extends UnitTestCase {
public function testGetDataDefinition($is_multiple) {
$data_type = 'valid';
$mock_data_definition = $this->getMockBuilder('\Drupal\Core\TypedData\ListDataDefinitionInterface')
- ->setMethods(array(
+ ->setMethods([
'setLabel',
'setDescription',
'setRequired',
'getConstraints',
'setConstraints',
- ))
+ ])
->getMockForAbstractClass();
$mock_data_definition->expects($this->once())
->method('setLabel')
@@ -52,7 +52,7 @@ class ContextDefinitionTest extends UnitTestCase {
->willReturnSelf();
$mock_data_definition->expects($this->once())
->method('getConstraints')
- ->willReturn(array());
+ ->willReturn([]);
$mock_data_definition->expects($this->once())
->method('setConstraints')
->willReturn(NULL);
@@ -67,16 +67,16 @@ class ContextDefinitionTest extends UnitTestCase {
// valid data type.
$mock_data_manager->expects($this->once())
->method($create_definition_method)
- ->willReturnMap(array(
- array('not_valid', NULL),
- array('valid', $mock_data_definition),
- ));
+ ->willReturnMap([
+ ['not_valid', NULL],
+ ['valid', $mock_data_definition],
+ ]);
// Mock a ContextDefinition object, setting up expectations for many of the
// methods.
$mock_context_definition = $this->getMockBuilder('Drupal\Core\Plugin\Context\ContextDefinition')
->disableOriginalConstructor()
- ->setMethods(array(
+ ->setMethods([
'isMultiple',
'getTypedDataManager',
'getDataType',
@@ -85,7 +85,7 @@ class ContextDefinitionTest extends UnitTestCase {
'isRequired',
'getConstraints',
'setConstraints',
- ))
+ ])
->getMock();
$mock_context_definition->expects($this->once())
->method('isMultiple')
@@ -98,7 +98,7 @@ class ContextDefinitionTest extends UnitTestCase {
->willReturn($data_type);
$mock_context_definition->expects($this->once())
->method('getConstraints')
- ->willReturn(array());
+ ->willReturn([]);
$this->assertSame(
$mock_data_definition,
@@ -130,20 +130,20 @@ class ContextDefinitionTest extends UnitTestCase {
// will eventually cause getDataDefinition() to throw an exception.
$mock_data_manager->expects($this->once())
->method($create_definition_method)
- ->willReturnMap(array(
- array('not_valid', NULL),
- array('valid', $mock_data_definition),
- ));
+ ->willReturnMap([
+ ['not_valid', NULL],
+ ['valid', $mock_data_definition],
+ ]);
// Mock a ContextDefinition object with expectations for only the methods
// that will be called before the expected exception.
$mock_context_definition = $this->getMockBuilder('Drupal\Core\Plugin\Context\ContextDefinition')
->disableOriginalConstructor()
- ->setMethods(array(
+ ->setMethods([
'isMultiple',
'getTypedDataManager',
'getDataType',
- ))
+ ])
->getMock();
$mock_context_definition->expects($this->once())
->method('isMultiple')
@@ -165,16 +165,16 @@ class ContextDefinitionTest extends UnitTestCase {
* Data provider for testGetConstraint
*/
public function providerGetConstraint() {
- return array(
- array(NULL, array(), 'nonexistent_constraint_name'),
- array(
+ return [
+ [NULL, [], 'nonexistent_constraint_name'],
+ [
'not_null',
- array(
+ [
'constraint_name' => 'not_null',
- ),
+ ],
'constraint_name',
- ),
- );
+ ],
+ ];
}
/**
@@ -185,9 +185,9 @@ class ContextDefinitionTest extends UnitTestCase {
public function testGetConstraint($expected, $constraint_array, $constraint) {
$mock_context_definition = $this->getMockBuilder('Drupal\Core\Plugin\Context\ContextDefinition')
->disableOriginalConstructor()
- ->setMethods(array(
+ ->setMethods([
'getConstraints',
- ))
+ ])
->getMock();
$mock_context_definition->expects($this->once())
->method('getConstraints')
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
index c0d750e0e29..e9b596438a0 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@@ -89,7 +89,7 @@ class ContextTest extends UnitTestCase {
public function testSetContextValueTypedData() {
$this->contextDefinition = $this->getMockBuilder('Drupal\Core\Plugin\Context\ContextDefinitionInterface')
- ->setMethods(array('getDefaultValue', 'getDataDefinition'))
+ ->setMethods(['getDefaultValue', 'getDataDefinition'])
->getMockForAbstractClass();
$typed_data = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
@@ -144,7 +144,7 @@ class ContextTest extends UnitTestCase {
$mock_data_definition = $this->getMock('Drupal\Core\TypedData\DataDefinitionInterface');
$this->contextDefinition = $this->getMockBuilder('Drupal\Core\Plugin\Context\ContextDefinitionInterface')
- ->setMethods(array('getDefaultValue', 'getDataDefinition'))
+ ->setMethods(['getDefaultValue', 'getDataDefinition'])
->getMockForAbstractClass();
$this->contextDefinition->expects($this->once())
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php
index dfc9361289b..aac6efc0e3a 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php
@@ -38,7 +38,7 @@ class ContextTypedDataTest extends UnitTestCase {
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
$typed_data_manager->expects($this->once())
->method('getCanonicalRepresentation')
- ->will($this->returnCallback(array($this, 'getCanonicalRepresentation')));
+ ->will($this->returnCallback([$this, 'getCanonicalRepresentation']));
$container = new ContainerBuilder();
$container->set('typed_data_manager', $typed_data_manager);
\Drupal::setContainer($container);
diff --git a/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php b/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php
index 981f4c22834..b0b43bb7bef 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php
@@ -62,7 +62,7 @@ class ContextHandlerTest extends UnitTestCase {
->will($this->returnValue(new ContextDefinition('empty')));
$requirement_specific = new ContextDefinition('specific');
- $requirement_specific->setConstraints(array('bar' => 'baz'));
+ $requirement_specific->setConstraints(['bar' => 'baz']);
$context_constraint_mismatch = $this->getMock('Drupal\Core\Plugin\Context\ContextInterface');
$context_constraint_mismatch->expects($this->atLeastOnce())
@@ -74,21 +74,21 @@ class ContextHandlerTest extends UnitTestCase {
->will($this->returnValue(new ContextDefinition('fuzzy')));
$context_definition_specific = new ContextDefinition('specific');
- $context_definition_specific->setConstraints(array('bar' => 'baz'));
+ $context_definition_specific->setConstraints(['bar' => 'baz']);
$context_specific = $this->getMock('Drupal\Core\Plugin\Context\ContextInterface');
$context_specific->expects($this->atLeastOnce())
->method('getContextDefinition')
->will($this->returnValue($context_definition_specific));
- $data = array();
- $data[] = array(array(), array(), TRUE);
- $data[] = array(array(), array($requirement_any), FALSE);
- $data[] = array(array(), array($requirement_optional), TRUE);
- $data[] = array(array(), array($requirement_any, $requirement_optional), FALSE);
- $data[] = array(array($context_any), array($requirement_any), TRUE);
- $data[] = array(array($context_constraint_mismatch), array($requirement_specific), FALSE);
- $data[] = array(array($context_datatype_mismatch), array($requirement_specific), FALSE);
- $data[] = array(array($context_specific), array($requirement_specific), TRUE);
+ $data = [];
+ $data[] = [[], [], TRUE];
+ $data[] = [[], [$requirement_any], FALSE];
+ $data[] = [[], [$requirement_optional], TRUE];
+ $data[] = [[], [$requirement_any, $requirement_optional], FALSE];
+ $data[] = [[$context_any], [$requirement_any], TRUE];
+ $data[] = [[$context_constraint_mismatch], [$requirement_specific], FALSE];
+ $data[] = [[$context_datatype_mismatch], [$requirement_specific], FALSE];
+ $data[] = [[$context_specific], [$requirement_specific], TRUE];
return $data;
}
@@ -112,7 +112,7 @@ class ContextHandlerTest extends UnitTestCase {
$requirement_any = new ContextDefinition();
$requirement_specific = new ContextDefinition('specific');
- $requirement_specific->setConstraints(array('bar' => 'baz'));
+ $requirement_specific->setConstraints(['bar' => 'baz']);
$context_any = $this->getMock('Drupal\Core\Plugin\Context\ContextInterface');
$context_any->expects($this->atLeastOnce())
@@ -127,24 +127,24 @@ class ContextHandlerTest extends UnitTestCase {
->method('getContextDefinition')
->will($this->returnValue(new ContextDefinition('fuzzy')));
$context_definition_specific = new ContextDefinition('specific');
- $context_definition_specific->setConstraints(array('bar' => 'baz'));
+ $context_definition_specific->setConstraints(['bar' => 'baz']);
$context_specific = $this->getMock('Drupal\Core\Plugin\Context\ContextInterface');
$context_specific->expects($this->atLeastOnce())
->method('getContextDefinition')
->will($this->returnValue($context_definition_specific));
- $data = array();
+ $data = [];
// No context will return no valid contexts.
- $data[] = array(array(), $requirement_any);
+ $data[] = [[], $requirement_any];
// A context with a generic matching requirement is valid.
- $data[] = array(array($context_any), $requirement_any);
+ $data[] = [[$context_any], $requirement_any];
// A context with a specific matching requirement is valid.
- $data[] = array(array($context_specific), $requirement_specific);
+ $data[] = [[$context_specific], $requirement_specific];
// A context with a mismatched constraint is invalid.
- $data[] = array(array($context_constraint_mismatch), $requirement_specific, array());
+ $data[] = [[$context_constraint_mismatch], $requirement_specific, []];
// A context with a mismatched datatype is invalid.
- $data[] = array(array($context_datatype_mismatch), $requirement_specific, array());
+ $data[] = [[$context_datatype_mismatch], $requirement_specific, []];
return $data;
}
@@ -157,14 +157,14 @@ class ContextHandlerTest extends UnitTestCase {
public function testFilterPluginDefinitionsByContexts($has_context, $definitions, $expected) {
if ($has_context) {
$context = $this->getMock('Drupal\Core\Plugin\Context\ContextInterface');
- $expected_context_definition = (new ContextDefinition('expected_data_type'))->setConstraints(array('expected_constraint_name' => 'expected_constraint_value'));
+ $expected_context_definition = (new ContextDefinition('expected_data_type'))->setConstraints(['expected_constraint_name' => 'expected_constraint_value']);
$context->expects($this->atLeastOnce())
->method('getContextDefinition')
->will($this->returnValue($expected_context_definition));
- $contexts = array($context);
+ $contexts = [$context];
}
else {
- $contexts = array();
+ $contexts = [];
}
$this->assertSame($expected, $this->contextHandler->filterPluginDefinitionsByContexts($contexts, $definitions));
@@ -174,55 +174,55 @@ class ContextHandlerTest extends UnitTestCase {
* Provides data for testFilterPluginDefinitionsByContexts().
*/
public function providerTestFilterPluginDefinitionsByContexts() {
- $data = array();
+ $data = [];
- $plugins = array();
+ $plugins = [];
// No context and no plugins, no plugins available.
- $data[] = array(FALSE, $plugins, array());
+ $data[] = [FALSE, $plugins, []];
- $plugins = array('expected_plugin' => array());
+ $plugins = ['expected_plugin' => []];
// No context, all plugins available.
- $data[] = array(FALSE, $plugins, $plugins);
+ $data[] = [FALSE, $plugins, $plugins];
- $plugins = array('expected_plugin' => array('context' => array()));
+ $plugins = ['expected_plugin' => ['context' => []]];
// No context, all plugins available.
- $data[] = array(FALSE, $plugins, $plugins);
+ $data[] = [FALSE, $plugins, $plugins];
- $plugins = array('expected_plugin' => array('context' => array('context1' => new ContextDefinition('expected_data_type'))));
+ $plugins = ['expected_plugin' => ['context' => ['context1' => new ContextDefinition('expected_data_type')]]];
// Missing context, no plugins available.
- $data[] = array(FALSE, $plugins, array());
+ $data[] = [FALSE, $plugins, []];
// Satisfied context, all plugins available.
- $data[] = array(TRUE, $plugins, $plugins);
+ $data[] = [TRUE, $plugins, $plugins];
- $mismatched_context_definition = (new ContextDefinition('expected_data_type'))->setConstraints(array('mismatched_constraint_name' => 'mismatched_constraint_value'));
- $plugins = array('expected_plugin' => array('context' => array('context1' => $mismatched_context_definition)));
+ $mismatched_context_definition = (new ContextDefinition('expected_data_type'))->setConstraints(['mismatched_constraint_name' => 'mismatched_constraint_value']);
+ $plugins = ['expected_plugin' => ['context' => ['context1' => $mismatched_context_definition]]];
// Mismatched constraints, no plugins available.
- $data[] = array(TRUE, $plugins, array());
+ $data[] = [TRUE, $plugins, []];
$optional_mismatched_context_definition = clone $mismatched_context_definition;
$optional_mismatched_context_definition->setRequired(FALSE);
- $plugins = array('expected_plugin' => array('context' => array('context1' => $optional_mismatched_context_definition)));
+ $plugins = ['expected_plugin' => ['context' => ['context1' => $optional_mismatched_context_definition]]];
// Optional mismatched constraint, all plugins available.
- $data[] = array(FALSE, $plugins, $plugins);
+ $data[] = [FALSE, $plugins, $plugins];
- $expected_context_definition = (new ContextDefinition('expected_data_type'))->setConstraints(array('expected_constraint_name' => 'expected_constraint_value'));
- $plugins = array('expected_plugin' => array('context' => array('context1' => $expected_context_definition)));
+ $expected_context_definition = (new ContextDefinition('expected_data_type'))->setConstraints(['expected_constraint_name' => 'expected_constraint_value']);
+ $plugins = ['expected_plugin' => ['context' => ['context1' => $expected_context_definition]]];
// Satisfied context with constraint, all plugins available.
- $data[] = array(TRUE, $plugins, $plugins);
+ $data[] = [TRUE, $plugins, $plugins];
$optional_expected_context_definition = clone $expected_context_definition;
$optional_expected_context_definition->setRequired(FALSE);
- $plugins = array('expected_plugin' => array('context' => array('context1' => $optional_expected_context_definition)));
+ $plugins = ['expected_plugin' => ['context' => ['context1' => $optional_expected_context_definition]]];
// Optional unsatisfied context, all plugins available.
- $data[] = array(FALSE, $plugins, $plugins);
+ $data[] = [FALSE, $plugins, $plugins];
- $unexpected_context_definition = (new ContextDefinition('unexpected_data_type'))->setConstraints(array('mismatched_constraint_name' => 'mismatched_constraint_value'));
- $plugins = array(
- 'unexpected_plugin' => array('context' => array('context1' => $unexpected_context_definition)),
- 'expected_plugin' => array('context' => array('context2' => new ContextDefinition('expected_data_type'))),
- );
+ $unexpected_context_definition = (new ContextDefinition('unexpected_data_type'))->setConstraints(['mismatched_constraint_name' => 'mismatched_constraint_value']);
+ $plugins = [
+ 'unexpected_plugin' => ['context' => ['context1' => $unexpected_context_definition]],
+ 'expected_plugin' => ['context' => ['context2' => new ContextDefinition('expected_data_type')]],
+ ];
// Context only satisfies one plugin.
- $data[] = array(TRUE, $plugins, array('expected_plugin' => $plugins['expected_plugin']));
+ $data[] = [TRUE, $plugins, ['expected_plugin' => $plugins['expected_plugin']]];
return $data;
}
@@ -246,10 +246,10 @@ class ContextHandlerTest extends UnitTestCase {
$context_miss->expects($this->never())
->method('getContextData');
- $contexts = array(
+ $contexts = [
'hit' => $context_hit,
'miss' => $context_miss,
- );
+ ];
$context_definition = $this->getMock('Drupal\Core\Plugin\Context\ContextDefinitionInterface');
@@ -259,7 +259,7 @@ class ContextHandlerTest extends UnitTestCase {
->willReturn([]);
$plugin->expects($this->once())
->method('getContextDefinitions')
- ->will($this->returnValue(array('hit' => $context_definition)));
+ ->will($this->returnValue(['hit' => $context_definition]));
$plugin->expects($this->once())
->method('setContextValue')
->with('hit', $context_hit_data);
@@ -288,9 +288,9 @@ class ContextHandlerTest extends UnitTestCase {
$context->expects($this->never())
->method('getContextValue');
- $contexts = array(
+ $contexts = [
'name' => $context,
- );
+ ];
$context_definition = $this->getMock('Drupal\Core\Plugin\Context\ContextDefinitionInterface');
$context_definition->expects($this->atLeastOnce())
@@ -303,7 +303,7 @@ class ContextHandlerTest extends UnitTestCase {
->willReturn([]);
$plugin->expects($this->once())
->method('getContextDefinitions')
- ->will($this->returnValue(array('hit' => $context_definition)));
+ ->will($this->returnValue(['hit' => $context_definition]));
$plugin->expects($this->never())
->method('setContextValue');
@@ -322,9 +322,9 @@ class ContextHandlerTest extends UnitTestCase {
$context->expects($this->never())
->method('getContextValue');
- $contexts = array(
+ $contexts = [
'name' => $context,
- );
+ ];
$context_definition = $this->getMock('Drupal\Core\Plugin\Context\ContextDefinitionInterface');
$context_definition->expects($this->atLeastOnce())
@@ -337,7 +337,7 @@ class ContextHandlerTest extends UnitTestCase {
->willReturn(['optional' => 'missing']);
$plugin->expects($this->once())
->method('getContextDefinitions')
- ->will($this->returnValue(array('optional' => $context_definition)));
+ ->will($this->returnValue(['optional' => $context_definition]));
$plugin->expects($this->never())
->method('setContextValue');
@@ -362,9 +362,9 @@ class ContextHandlerTest extends UnitTestCase {
->method('hasContextValue')
->willReturn(FALSE);
- $contexts = array(
+ $contexts = [
'hit' => $context,
- );
+ ];
$context_definition = $this->getMock('Drupal\Core\Plugin\Context\ContextDefinitionInterface');
$context_definition->expects($this->atLeastOnce())
@@ -377,7 +377,7 @@ class ContextHandlerTest extends UnitTestCase {
->willReturn([]);
$plugin->expects($this->once())
->method('getContextDefinitions')
- ->will($this->returnValue(array('hit' => $context_definition)));
+ ->will($this->returnValue(['hit' => $context_definition]));
$plugin->expects($this->never())
->method('setContextValue');
@@ -396,9 +396,9 @@ class ContextHandlerTest extends UnitTestCase {
->method('hasContextValue')
->willReturn(FALSE);
- $contexts = array(
+ $contexts = [
'hit' => $context,
- );
+ ];
$context_definition = $this->getMock('Drupal\Core\Plugin\Context\ContextDefinitionInterface');
$context_definition->expects($this->atLeastOnce())
@@ -411,7 +411,7 @@ class ContextHandlerTest extends UnitTestCase {
->willReturn([]);
$plugin->expects($this->once())
->method('getContextDefinitions')
- ->will($this->returnValue(array('hit' => $context_definition)));
+ ->will($this->returnValue(['hit' => $context_definition]));
$plugin->expects($this->never())
->method('setContextValue');
@@ -432,9 +432,9 @@ class ContextHandlerTest extends UnitTestCase {
->method('hasContextValue')
->willReturn(TRUE);
- $contexts = array(
+ $contexts = [
'name' => $context,
- );
+ ];
$context_definition = $this->getMock('Drupal\Core\Plugin\Context\ContextDefinitionInterface');
@@ -444,7 +444,7 @@ class ContextHandlerTest extends UnitTestCase {
->willReturn([]);
$plugin->expects($this->once())
->method('getContextDefinitions')
- ->will($this->returnValue(array('hit' => $context_definition)));
+ ->will($this->returnValue(['hit' => $context_definition]));
$plugin->expects($this->once())
->method('setContextValue')
->with('hit', $context_data);
@@ -473,9 +473,9 @@ class ContextHandlerTest extends UnitTestCase {
$context->expects($this->never())
->method('getContextValue');
- $contexts = array(
+ $contexts = [
'name' => $context,
- );
+ ];
$context_definition = $this->getMock('Drupal\Core\Plugin\Context\ContextDefinitionInterface');
@@ -485,7 +485,7 @@ class ContextHandlerTest extends UnitTestCase {
->willReturn([]);
$plugin->expects($this->once())
->method('getContextDefinitions')
- ->will($this->returnValue(array('hit' => $context_definition)));
+ ->will($this->returnValue(['hit' => $context_definition]));
$plugin->expects($this->never())
->method('setContextValue');
diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
index fbd6bc29fff..11efd4821c0 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php
@@ -58,12 +58,12 @@ class DefaultLazyPluginCollectionTest extends LazyPluginCollectionTestBase {
* The test data.
*/
public function providerTestSortHelper() {
- return array(
- array('apple', 'apple', 0),
- array('apple', 'cherry', -1),
- array('cherry', 'apple', 1),
- array('cherry', 'banana', 1),
- );
+ return [
+ ['apple', 'apple', 0],
+ ['apple', 'cherry', -1],
+ ['cherry', 'apple', 1],
+ ['cherry', 'banana', 1],
+ ];
}
/**
@@ -91,7 +91,7 @@ class DefaultLazyPluginCollectionTest extends LazyPluginCollectionTestBase {
public function testGetConfiguration() {
$this->setupPluginCollection($this->exactly(3));
// The expected order matches $this->config.
- $expected = array('banana', 'cherry', 'apple');
+ $expected = ['banana', 'cherry', 'apple'];
$config = $this->defaultPluginCollection->getConfiguration();
$this->assertSame($expected, array_keys($config), 'The order of the configuration is unchanged.');
@@ -113,21 +113,21 @@ class DefaultLazyPluginCollectionTest extends LazyPluginCollectionTestBase {
*/
public function testAddInstanceId() {
$this->setupPluginCollection($this->exactly(4));
- $expected = array(
+ $expected = [
'banana' => 'banana',
'cherry' => 'cherry',
'apple' => 'apple',
- );
+ ];
$this->defaultPluginCollection->addInstanceId('apple');
$result = $this->defaultPluginCollection->getInstanceIds();
$this->assertSame($expected, $result);
$this->assertSame($expected, array_intersect_key($result, $this->defaultPluginCollection->getConfiguration()));
- $expected = array(
+ $expected = [
'cherry' => 'cherry',
'apple' => 'apple',
'banana' => 'banana',
- );
+ ];
$this->defaultPluginCollection->removeInstanceId('banana');
$this->defaultPluginCollection->addInstanceId('banana', $this->config['banana']);
@@ -151,11 +151,11 @@ class DefaultLazyPluginCollectionTest extends LazyPluginCollectionTestBase {
*/
public function testSetInstanceConfiguration() {
$this->setupPluginCollection($this->exactly(3));
- $expected = array(
+ $expected = [
'id' => 'cherry',
'key' => 'value',
'custom' => 'bananas',
- );
+ ];
$this->defaultPluginCollection->setInstanceConfiguration('cherry', $expected);
$config = $this->defaultPluginCollection->getConfiguration();
$this->assertSame($expected, $config['cherry']);
@@ -189,12 +189,12 @@ class DefaultLazyPluginCollectionTest extends LazyPluginCollectionTestBase {
$this->defaultPluginCollection->set('cherry2', $instance);
$this->defaultPluginCollection->setInstanceConfiguration('cherry2', $this->config['cherry']);
- $expected = array(
+ $expected = [
'banana',
'cherry',
'apple',
'cherry2',
- );
+ ];
$config = $this->defaultPluginCollection->getConfiguration();
$this->assertSame($expected, array_keys($config));
}
diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
index 0a6e8d4c871..7e2842ec44e 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
@@ -35,27 +35,27 @@ class DefaultPluginManagerTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->expectedDefinitions = array(
- 'apple' => array(
+ $this->expectedDefinitions = [
+ 'apple' => [
'id' => 'apple',
'label' => 'Apple',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple',
- ),
- 'banana' => array(
+ ],
+ 'banana' => [
'id' => 'banana',
'label' => 'Banana',
'color' => 'yellow',
- 'uses' => array(
+ 'uses' => [
'bread' => 'Banana bread',
- 'loaf' => array(
+ 'loaf' => [
'singular' => '@count loaf',
'plural' => '@count loaves',
- ),
- ),
+ ],
+ ],
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Banana',
- ),
- );
+ ],
+ ];
$this->namespaces = new \ArrayObject();
$this->namespaces['Drupal\plugin_test'] = $this->root . '/core/modules/system/tests/modules/plugin_test/src';
@@ -65,14 +65,14 @@ class DefaultPluginManagerTest extends UnitTestCase {
* Tests the plugin manager with a plugin that extends a non-installed class.
*/
public function testDefaultPluginManagerWithPluginExtendingNonInstalledClass() {
- $definitions = array();
- $definitions['extending_non_installed_class'] = array(
+ $definitions = [];
+ $definitions['extending_non_installed_class'] = [
'id' => 'extending_non_installed_class',
'label' => 'A plugin whose class is extending from a non-installed module class',
'color' => 'pink',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\ExtendingNonInstalledClass',
'provider' => 'plugin_test',
- );
+ ];
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$plugin_manager = new TestPluginManager($this->namespaces, $definitions, $module_handler, 'test_alter_hook', '\Drupal\plugin_test\Plugin\plugin_test\fruit\FruitInterface');
@@ -85,13 +85,13 @@ class DefaultPluginManagerTest extends UnitTestCase {
*/
public function testDefaultPluginManagerWithDisabledModule() {
$definitions = $this->expectedDefinitions;
- $definitions['cherry'] = array(
+ $definitions['cherry'] = [
'id' => 'cherry',
'label' => 'Cherry',
'color' => 'red',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry',
'provider' => 'disabled_module',
- );
+ ];
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
@@ -110,13 +110,13 @@ class DefaultPluginManagerTest extends UnitTestCase {
*/
public function testDefaultPluginManagerWithObjects() {
$definitions = $this->expectedDefinitions;
- $definitions['cherry'] = (object) array(
+ $definitions['cherry'] = (object) [
'id' => 'cherry',
'label' => 'Cherry',
'color' => 'red',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry',
'provider' => 'disabled_module',
- );
+ ];
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
@@ -196,7 +196,7 @@ class DefaultPluginManagerTest extends UnitTestCase {
->expects($this->once())
->method('get')
->with($cid)
- ->will($this->returnValue((object) array('data' => $this->expectedDefinitions)));
+ ->will($this->returnValue((object) ['data' => $this->expectedDefinitions]));
$cache_backend
->expects($this->never())
->method('set');
@@ -241,7 +241,7 @@ class DefaultPluginManagerTest extends UnitTestCase {
$cache_tags_invalidator
->expects($this->once())
->method('invalidateTags')
- ->with(array('tag'));
+ ->with(['tag']);
$cache_backend
->expects($this->never())
->method('deleteMultiple');
@@ -249,7 +249,7 @@ class DefaultPluginManagerTest extends UnitTestCase {
$this->getContainerWithCacheTagsInvalidator($cache_tags_invalidator);
$plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, NULL, NULL, '\Drupal\plugin_test\Plugin\plugin_test\fruit\FruitInterface');
- $plugin_manager->setCacheBackend($cache_backend, $cid, array('tag'));
+ $plugin_manager->setCacheBackend($cache_backend, $cid, ['tag']);
$plugin_manager->clearCachedDefinitions();
}
@@ -283,13 +283,13 @@ class DefaultPluginManagerTest extends UnitTestCase {
->with('plugin_test')
->willReturn(TRUE);
- $this->expectedDefinitions['kale'] = array(
+ $this->expectedDefinitions['kale'] = [
'id' => 'kale',
'label' => 'Kale',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Kale',
'provider' => 'plugin_test',
- );
+ ];
$this->expectedDefinitions['apple']['provider'] = 'plugin_test';
$this->expectedDefinitions['banana']['provider'] = 'plugin_test';
@@ -310,13 +310,13 @@ class DefaultPluginManagerTest extends UnitTestCase {
->with('plugin_test')
->willReturn(FALSE);
- $this->expectedDefinitions['kale'] = array(
+ $this->expectedDefinitions['kale'] = [
'id' => 'kale',
'label' => 'Kale',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Kale',
'provider' => 'plugin_test',
- );
+ ];
$this->expectedDefinitions['apple']['provider'] = 'plugin_test';
$this->expectedDefinitions['banana']['provider'] = 'plugin_test';
diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
index ab7bfdc1dbf..21bbde83d8a 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php
@@ -27,7 +27,7 @@ class DefaultSingleLazyPluginCollectionTest extends LazyPluginCollectionTestBase
return $this->pluginInstances[$id];
});
- $this->defaultPluginCollection = new DefaultSingleLazyPluginCollection($this->pluginManager, 'apple', array('id' => 'apple', 'key' => 'value'));
+ $this->defaultPluginCollection = new DefaultSingleLazyPluginCollection($this->pluginManager, 'apple', ['id' => 'apple', 'key' => 'value']);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php
index 480e1151144..508fdc61e82 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php
@@ -17,7 +17,7 @@ class ContainerDerivativeDiscoveryDecoratorTest extends UnitTestCase {
public function testGetDefinitions() {
$example_service = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$example_container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
- ->setMethods(array('get'))
+ ->setMethods(['get'])
->getMock();
$example_container->expects($this->once())
->method('get')
@@ -26,15 +26,15 @@ class ContainerDerivativeDiscoveryDecoratorTest extends UnitTestCase {
\Drupal::setContainer($example_container);
- $definitions = array();
- $definitions['container_aware_discovery'] = array(
+ $definitions = [];
+ $definitions['container_aware_discovery'] = [
'id' => 'container_aware_discovery',
'deriver' => '\Drupal\Tests\Core\Plugin\Discovery\TestContainerDerivativeDiscovery',
- );
- $definitions['non_container_aware_discovery'] = array(
+ ];
+ $definitions['non_container_aware_discovery'] = [
'id' => 'non_container_aware_discovery',
'deriver' => '\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery',
- );
+ ];
$discovery_main = $this->getMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
$discovery_main->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
index 1e96458342c..81e7d56a804 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
@@ -36,11 +36,11 @@ class DerivativeDiscoveryDecoratorTest extends UnitTestCase {
* @see \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDerivativeFetcher()
*/
public function testGetDerivativeFetcher() {
- $definitions = array();
- $definitions['non_container_aware_discovery'] = array(
+ $definitions = [];
+ $definitions['non_container_aware_discovery'] = [
'id' => 'non_container_aware_discovery',
'deriver' => '\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery',
- );
+ ];
$this->discoveryMain->expects($this->any())
->method('getDefinitions')
@@ -62,11 +62,11 @@ class DerivativeDiscoveryDecoratorTest extends UnitTestCase {
* Tests the getDerivativeFetcher method with objects instead of arrays.
*/
public function testGetDerivativeFetcherWithAnnotationObjects() {
- $definitions = array();
- $definitions['non_container_aware_discovery'] = (object) array(
+ $definitions = [];
+ $definitions['non_container_aware_discovery'] = (object) [
'id' => 'non_container_aware_discovery',
'deriver' => '\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject',
- );
+ ];
$this->discoveryMain->expects($this->any())
->method('getDefinitions')
@@ -92,7 +92,7 @@ class DerivativeDiscoveryDecoratorTest extends UnitTestCase {
* @covers ::getDeriverClass
*/
public function testGetDeriverClassWithClassedDefinitions() {
- $definitions = array();
+ $definitions = [];
$definition = $this->prophesize(DerivablePluginDefinitionInterface::class);
$definition->id()->willReturn('non_container_aware_discovery');
$definition->getDeriver()->willReturn(TestDerivativeDiscoveryWithObject::class);
@@ -139,12 +139,12 @@ class DerivativeDiscoveryDecoratorTest extends UnitTestCase {
* @expectedExceptionMessage Plugin (non_existent_discovery) deriver "\Drupal\system\Tests\Plugin\NonExistentDeriver" does not exist.
*/
public function testNonExistentDerivativeFetcher() {
- $definitions = array();
+ $definitions = [];
// Do this with a class that doesn't exist.
- $definitions['non_existent_discovery'] = array(
+ $definitions['non_existent_discovery'] = [
'id' => 'non_existent_discovery',
'deriver' => '\Drupal\system\Tests\Plugin\NonExistentDeriver',
- );
+ ];
$this->discoveryMain->expects($this->any())
->method('getDefinitions')
->will($this->returnValue($definitions));
@@ -162,12 +162,12 @@ class DerivativeDiscoveryDecoratorTest extends UnitTestCase {
* @expectedExceptionMessage Plugin (invalid_discovery) deriver "\Drupal\KernelTests\Core\Plugin\DerivativeTest" must implement \Drupal\Component\Plugin\Derivative\DeriverInterface.
*/
public function testInvalidDerivativeFetcher() {
- $definitions = array();
+ $definitions = [];
// Do this with a class that doesn't implement the interface.
- $definitions['invalid_discovery'] = array(
+ $definitions['invalid_discovery'] = [
'id' => 'invalid_discovery',
'deriver' => '\Drupal\KernelTests\Core\Plugin\DerivativeTest',
- );
+ ];
$this->discoveryMain->expects($this->any())
->method('getDefinitions')
->will($this->returnValue($definitions));
@@ -180,26 +180,26 @@ class DerivativeDiscoveryDecoratorTest extends UnitTestCase {
* Tests derivative definitions when a definition already exists.
*/
public function testExistingDerivative() {
- $definitions = array();
- $definitions['non_container_aware_discovery'] = array(
+ $definitions = [];
+ $definitions['non_container_aware_discovery'] = [
'id' => 'non_container_aware_discovery',
'deriver' => '\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery',
'string' => 'string',
'empty_string' => 'not_empty',
- 'array' => array('one', 'two'),
- 'empty_array' => array('three'),
+ 'array' => ['one', 'two'],
+ 'empty_array' => ['three'],
'null_value' => TRUE,
- );
+ ];
// This will clash with a derivative id.
// @see \Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery
- $definitions['non_container_aware_discovery:test_discovery_1'] = array(
+ $definitions['non_container_aware_discovery:test_discovery_1'] = [
'id' => 'non_container_aware_discovery:test_discovery_1',
'string' => 'string',
'empty_string' => '',
- 'array' => array('one', 'two'),
- 'empty_array' => array(),
+ 'array' => ['one', 'two'],
+ 'empty_array' => [],
'null_value' => NULL,
- );
+ ];
$this->discoveryMain->expects($this->any())
->method('getDefinitions')
@@ -220,25 +220,25 @@ class DerivativeDiscoveryDecoratorTest extends UnitTestCase {
* Tests a single definition when a derivative already exists.
*/
public function testSingleExistingDerivative() {
- $base_definition = array(
+ $base_definition = [
'id' => 'non_container_aware_discovery',
'deriver' => '\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery',
'string' => 'string',
'empty_string' => 'not_empty',
- 'array' => array('one', 'two'),
- 'empty_array' => array('three'),
+ 'array' => ['one', 'two'],
+ 'empty_array' => ['three'],
'null_value' => TRUE,
- );
+ ];
// This will clash with a derivative id.
// @see \Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery
- $derivative_definition = array(
+ $derivative_definition = [
'id' => 'non_container_aware_discovery:test_discovery_1',
'string' => 'string',
'empty_string' => '',
- 'array' => array('one', 'two'),
- 'empty_array' => array(),
+ 'array' => ['one', 'two'],
+ 'empty_array' => [],
'null_value' => NULL,
- );
+ ];
$this->discoveryMain->expects($this->at(0))
->method('getDefinition')
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php
index 1472dc0c4d5..ab65ab723d5 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php
@@ -42,7 +42,7 @@ class HookDiscoveryTest extends UnitTestCase {
$this->moduleHandler->expects($this->once())
->method('getImplementations')
->with('test_plugin')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->assertCount(0, $this->hookDiscovery->getDefinitions());
}
@@ -56,7 +56,7 @@ class HookDiscoveryTest extends UnitTestCase {
$this->moduleHandler->expects($this->once())
->method('getImplementations')
->with('test_plugin')
- ->will($this->returnValue(array('hook_discovery_test', 'hook_discovery_test2')));
+ ->will($this->returnValue(['hook_discovery_test', 'hook_discovery_test2']));
$this->moduleHandler->expects($this->at(1))
->method('invoke')
@@ -89,14 +89,14 @@ class HookDiscoveryTest extends UnitTestCase {
$this->moduleHandler->expects($this->exactly(4))
->method('getImplementations')
->with('test_plugin')
- ->will($this->returnValue(array('hook_discovery_test', 'hook_discovery_test2')));
+ ->will($this->returnValue(['hook_discovery_test', 'hook_discovery_test2']));
$this->moduleHandler->expects($this->any())
->method('invoke')
- ->will($this->returnValueMap(array(
- array('hook_discovery_test', 'test_plugin', array(), $this->hookDiscoveryTestTestPlugin()),
- array('hook_discovery_test2', 'test_plugin', array(), $this->hookDiscoveryTest2TestPlugin()),
- )
+ ->will($this->returnValueMap([
+ ['hook_discovery_test', 'test_plugin', [], $this->hookDiscoveryTestTestPlugin()],
+ ['hook_discovery_test2', 'test_plugin', [], $this->hookDiscoveryTest2TestPlugin()],
+ ]
));
$this->assertNull($this->hookDiscovery->getDefinition('test_non_existant', FALSE));
@@ -124,21 +124,21 @@ class HookDiscoveryTest extends UnitTestCase {
public function testGetDefinitionWithUnknownID() {
$this->moduleHandler->expects($this->once())
->method('getImplementations')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->hookDiscovery->getDefinition('test_non_existant', TRUE);
}
protected function hookDiscoveryTestTestPlugin() {
- return array(
- 'test_id_1' => array('class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple'),
- 'test_id_2' => array('class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange'),
- );
+ return [
+ 'test_id_1' => ['class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple'],
+ 'test_id_2' => ['class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange'],
+ ];
}
protected function hookDiscoveryTest2TestPlugin() {
- return array(
- 'test_id_3' => array('class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry'),
- );
+ return [
+ 'test_id_3' => ['class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry'],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php
index 2fb2f5deda7..63f50d64c79 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php
@@ -21,7 +21,7 @@ class TestDerivativeDiscovery implements DeriverInterface {
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $plugins = array();
+ $plugins = [];
for ($i = 0; $i < 2; $i++) {
$plugins['test_discovery_' . $i] = $base_plugin_definition;
}
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php
index 656415d6cef..353b21d48a4 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php
@@ -26,7 +26,7 @@ class TestDerivativeDiscoveryWithObject implements DeriverInterface {
* @return array
*/
public function getDerivativeDefinitions($base_plugin_definition) {
- $plugins = array();
+ $plugins = [];
for ($i = 0; $i < 2; $i++) {
$plugins['test_discovery_' . $i] = $base_plugin_definition;
}
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDirectoryDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDirectoryDiscoveryTest.php
index 265374a6755..a2c000e1fc6 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDirectoryDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDirectoryDiscoveryTest.php
@@ -56,7 +56,7 @@ class YamlDirectoryDiscoveryTest extends UnitTestCase {
$this->assertCount(4, $definitions);
foreach ($definitions as $id => $definition) {
- foreach (array('id', 'provider', ComponentYamlDirectoryDiscovery::FILE_KEY) as $key) {
+ foreach (['id', 'provider', ComponentYamlDirectoryDiscovery::FILE_KEY] as $key) {
$this->assertArrayHasKey($key, $definition);
}
$this->assertEquals($id, $definition['id']);
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php
index ee48654d97f..ea193685667 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php
@@ -24,37 +24,37 @@ class YamlDiscoveryDecoratorTest extends UnitTestCase {
*
* @var array
*/
- protected $expectedKeys = array(
+ protected $expectedKeys = [
'test_1' => 'test_1_a',
'another_provider_1' => 'test_1_b',
'another_provider_2' => 'test_2_a',
'test_2' => 'test_2_b',
'decorated_1' => 'decorated_test_1',
'decorated_2' => 'decorated_test_2',
- );
+ ];
protected function setUp() {
parent::setUp();
$base_path = __DIR__ . '/Fixtures';
// Set up the directories to search.
- $directories = array(
+ $directories = [
'test_1' => $base_path . '/test_1',
'test_2' => $base_path . '/test_2',
- );
+ ];
- $definitions = array(
- 'decorated_test_1' => array(
+ $definitions = [
+ 'decorated_test_1' => [
'id' => 'decorated_test_1',
'name' => 'Decorated test 1',
'provider' => 'decorated_1',
- ),
- 'decorated_test_2' => array(
+ ],
+ 'decorated_test_2' => [
'id' => 'decorated_test_2',
'name' => 'Decorated test 1',
'provider' => 'decorated_2',
- ),
- );
+ ],
+ ];
$decorated = $this->getMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
$decorated->expects($this->once())
@@ -78,7 +78,7 @@ class YamlDiscoveryDecoratorTest extends UnitTestCase {
}
foreach ($definitions as $id => $definition) {
- foreach (array('name', 'id', 'provider') as $key) {
+ foreach (['name', 'id', 'provider'] as $key) {
$this->assertArrayHasKey($key, $definition);
}
$this->assertEquals($id, $definition['id']);
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php
index 0335145ce24..096c33fc73f 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php
@@ -25,22 +25,22 @@ class YamlDiscoveryTest extends UnitTestCase {
*
* @var array
*/
- protected $expectedKeys = array(
+ protected $expectedKeys = [
'test_1' => 'test_1_a',
'another_provider_1' => 'test_1_b',
'another_provider_2' => 'test_2_a',
'test_2' => 'test_2_b',
- );
+ ];
protected function setUp() {
parent::setUp();
$base_path = __DIR__ . '/Fixtures';
// Set up the directories to search.
- $directories = array(
+ $directories = [
'test_1' => $base_path . '/test_1',
'test_2' => $base_path . '/test_2',
- );
+ ];
$this->discovery = new YamlDiscovery('test', $directories);
}
@@ -59,7 +59,7 @@ class YamlDiscoveryTest extends UnitTestCase {
}
foreach ($definitions as $id => $definition) {
- foreach (array('name', 'id', 'provider') as $key) {
+ foreach (['name', 'id', 'provider'] as $key) {
$this->assertArrayHasKey($key, $definition);
}
$this->assertEquals($id, $definition['id']);
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Fixtures/TestConfigurablePlugin.php b/core/tests/Drupal/Tests/Core/Plugin/Fixtures/TestConfigurablePlugin.php
index 30b3e45e20c..383b4d2bbff 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Fixtures/TestConfigurablePlugin.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Fixtures/TestConfigurablePlugin.php
@@ -25,14 +25,14 @@ class TestConfigurablePlugin extends PluginBase implements ConfigurablePluginInt
* {@inheritdoc}
*/
public function defaultConfiguration() {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
- return array();
+ return [];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php
index 8e92ef0e8f8..1974e4a5a8c 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php
@@ -36,11 +36,11 @@ abstract class LazyPluginCollectionTestBase extends UnitTestCase {
*
* @var array
*/
- protected $config = array(
- 'banana' => array('id' => 'banana', 'key' => 'value'),
- 'cherry' => array('id' => 'cherry', 'key' => 'value'),
- 'apple' => array('id' => 'apple', 'key' => 'value'),
- );
+ protected $config = [
+ 'banana' => ['id' => 'banana', 'key' => 'value'],
+ 'cherry' => ['id' => 'cherry', 'key' => 'value'],
+ 'apple' => ['id' => 'apple', 'key' => 'value'],
+ ];
protected function setUp() {
$this->pluginManager = $this->getMock('Drupal\Component\Plugin\PluginManagerInterface');
@@ -59,18 +59,18 @@ abstract class LazyPluginCollectionTestBase extends UnitTestCase {
* Defaults to $this->never().
*/
protected function setupPluginCollection(\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder $create_count = NULL) {
- $this->pluginInstances = array();
- $map = array();
+ $this->pluginInstances = [];
+ $map = [];
foreach ($this->getPluginDefinitions() as $plugin_id => $definition) {
// Create a mock plugin instance.
$this->pluginInstances[$plugin_id] = $this->getPluginMock($plugin_id, $definition);
- $map[] = array($plugin_id, $this->config[$plugin_id], $this->pluginInstances[$plugin_id]);
+ $map[] = [$plugin_id, $this->config[$plugin_id], $this->pluginInstances[$plugin_id]];
}
$create_count = $create_count ?: $this->never();
$this->pluginManager->expects($create_count)
->method('createInstance')
- ->will($this->returnCallback(array($this, 'returnPluginMap')));
+ ->will($this->returnCallback([$this, 'returnPluginMap']));
$this->defaultPluginCollection = new DefaultLazyPluginCollection($this->pluginManager, $this->config);
}
@@ -116,32 +116,32 @@ abstract class LazyPluginCollectionTestBase extends UnitTestCase {
* The example plugin definitions.
*/
protected function getPluginDefinitions() {
- $definitions = array(
- 'apple' => array(
+ $definitions = [
+ 'apple' => [
'id' => 'apple',
'label' => 'Apple',
'color' => 'green',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple',
'provider' => 'plugin_test',
- ),
- 'banana' => array(
+ ],
+ 'banana' => [
'id' => 'banana',
'label' => 'Banana',
'color' => 'yellow',
- 'uses' => array(
+ 'uses' => [
'bread' => 'Banana bread',
- ),
+ ],
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Banana',
'provider' => 'plugin_test',
- ),
- 'cherry' => array(
+ ],
+ 'cherry' => [
'id' => 'cherry',
'label' => 'Cherry',
'color' => 'red',
'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry',
'provider' => 'plugin_test',
- ),
- );
+ ],
+ ];
return $definitions;
}
diff --git a/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php
index 0e883951a7a..5f0779e33eb 100644
--- a/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/ProxyBuilder/ProxyBuilderTest.php
@@ -165,7 +165,7 @@ class TestServiceNoMethod {
class TestServiceComplexMethod {
- public function complexMethod($parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = array()) {
+ public function complexMethod($parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = []) {
}
diff --git a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
index 93ee950e3f8..69d59d71f09 100644
--- a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
@@ -241,102 +241,102 @@ class BubbleableMetadataTest extends UnitTestCase {
* @covers ::mergeAttachments
*/
function testMergeAttachmentsLibraryMerging() {
- $a['#attached'] = array(
- 'library' => array(
+ $a['#attached'] = [
+ 'library' => [
'core/drupal',
'core/drupalSettings',
- ),
+ ],
'drupalSettings' => [
'foo' => ['d'],
],
- );
- $b['#attached'] = array(
- 'library' => array(
+ ];
+ $b['#attached'] = [
+ 'library' => [
'core/jquery',
- ),
+ ],
'drupalSettings' => [
'bar' => ['a', 'b', 'c'],
],
- );
- $expected['#attached'] = array(
- 'library' => array(
+ ];
+ $expected['#attached'] = [
+ 'library' => [
'core/drupal',
'core/drupalSettings',
'core/jquery',
- ),
+ ],
'drupalSettings' => [
'foo' => ['d'],
'bar' => ['a', 'b', 'c'],
],
- );
+ ];
$this->assertSame($expected['#attached'], BubbleableMetadata::mergeAttachments($a['#attached'], $b['#attached']), 'Attachments merged correctly.');
// Merging in the opposite direction yields the opposite library order.
- $expected['#attached'] = array(
- 'library' => array(
+ $expected['#attached'] = [
+ 'library' => [
'core/jquery',
'core/drupal',
'core/drupalSettings',
- ),
+ ],
'drupalSettings' => [
'bar' => ['a', 'b', 'c'],
'foo' => ['d'],
],
- );
+ ];
$this->assertSame($expected['#attached'], BubbleableMetadata::mergeAttachments($b['#attached'], $a['#attached']), 'Attachments merged correctly; opposite merging yields opposite order.');
// Merging with duplicates: duplicates are simply retained, it's up to the
// rest of the system to handle duplicates.
$b['#attached']['library'][] = 'core/drupalSettings';
- $expected['#attached'] = array(
- 'library' => array(
+ $expected['#attached'] = [
+ 'library' => [
'core/drupal',
'core/drupalSettings',
'core/jquery',
'core/drupalSettings',
- ),
+ ],
'drupalSettings' => [
'foo' => ['d'],
'bar' => ['a', 'b', 'c'],
],
- );
+ ];
$this->assertSame($expected['#attached'], BubbleableMetadata::mergeAttachments($a['#attached'], $b['#attached']), 'Attachments merged correctly; duplicates are retained.');
// Merging with duplicates (simple case).
$b['#attached']['drupalSettings']['foo'] = ['a', 'b', 'c'];
- $expected['#attached'] = array(
- 'library' => array(
+ $expected['#attached'] = [
+ 'library' => [
'core/drupal',
'core/drupalSettings',
'core/jquery',
'core/drupalSettings',
- ),
+ ],
'drupalSettings' => [
'foo' => ['a', 'b', 'c'],
'bar' => ['a', 'b', 'c'],
],
- );
+ ];
$this->assertSame($expected['#attached'], BubbleableMetadata::mergeAttachments($a['#attached'], $b['#attached']));
// Merging with duplicates (simple case) in the opposite direction yields
// the opposite JS setting asset order, but also opposite overriding order.
- $expected['#attached'] = array(
- 'library' => array(
+ $expected['#attached'] = [
+ 'library' => [
'core/jquery',
'core/drupalSettings',
'core/drupal',
'core/drupalSettings',
- ),
+ ],
'drupalSettings' => [
'bar' => ['a', 'b', 'c'],
'foo' => ['d', 'b', 'c'],
],
- );
+ ];
$this->assertSame($expected['#attached'], BubbleableMetadata::mergeAttachments($b['#attached'], $a['#attached']));
// Merging with duplicates: complex case.
// Only the second of these two entries should appear in drupalSettings.
- $build = array();
+ $build = [];
$build['a']['#attached']['drupalSettings']['commonTest'] = 'firstValue';
$build['b']['#attached']['drupalSettings']['commonTest'] = 'secondValue';
// Only the second of these entries should appear in drupalSettings.
@@ -348,12 +348,12 @@ class BubbleableMetadataTest extends UnitTestCase {
// Real world test case: multiple elements in a render array are adding the
// same (or nearly the same) JavaScript settings. When merged, they should
// contain all settings and not duplicate some settings.
- $settings_one = array('moduleName' => array('ui' => array('button A', 'button B'), 'magical flag' => 3.14159265359));
+ $settings_one = ['moduleName' => ['ui' => ['button A', 'button B'], 'magical flag' => 3.14159265359]];
$build['a']['#attached']['drupalSettings']['commonTestRealWorldIdentical'] = $settings_one;
$build['b']['#attached']['drupalSettings']['commonTestRealWorldIdentical'] = $settings_one;
- $settings_two_a = array('moduleName' => array('ui' => array('button A', 'button B', 'button C'), 'magical flag' => 3.14159265359, 'thingiesOnPage' => array('id1' => array())));
+ $settings_two_a = ['moduleName' => ['ui' => ['button A', 'button B', 'button C'], 'magical flag' => 3.14159265359, 'thingiesOnPage' => ['id1' => []]]];
$build['a']['#attached']['drupalSettings']['commonTestRealWorldAlmostIdentical'] = $settings_two_a;
- $settings_two_b = array('moduleName' => array('ui' => array('button D', 'button E'), 'magical flag' => 3.14, 'thingiesOnPage' => array('id2' => array())));
+ $settings_two_b = ['moduleName' => ['ui' => ['button D', 'button E'], 'magical flag' => 3.14, 'thingiesOnPage' => ['id2' => []]]];
$build['b']['#attached']['drupalSettings']['commonTestRealWorldAlmostIdentical'] = $settings_two_b;
$merged = BubbleableMetadata::mergeAttachments($build['a']['#attached'], $build['b']['#attached']);
@@ -373,7 +373,7 @@ class BubbleableMetadataTest extends UnitTestCase {
// adds the exact same settings twice and hence tests idempotency, the
// second adds *almost* the same settings twice: the second time, some
// values are altered, and some key-value pairs are added.
- $settings_two['moduleName']['thingiesOnPage']['id1'] = array();
+ $settings_two['moduleName']['thingiesOnPage']['id1'] = [];
$this->assertSame($settings_one, $merged['drupalSettings']['commonTestRealWorldIdentical']);
$expected_settings_two = $settings_two_a;
$expected_settings_two['moduleName']['ui'][0] = 'button D';
diff --git a/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php b/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php
index bef5ceff222..46dd91a87d6 100644
--- a/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/Element/HtmlTagTest.php
@@ -16,7 +16,7 @@ class HtmlTagTest extends UnitTestCase {
* @covers ::getInfo
*/
public function testGetInfo() {
- $htmlTag = new HtmlTag(array(), 'test', 'test');
+ $htmlTag = new HtmlTag([], 'test', 'test');
$info = $htmlTag->getInfo();
$this->assertArrayHasKey('#pre_render', $info);
$this->assertArrayHasKey('#attributes', $info);
@@ -37,60 +37,60 @@ class HtmlTagTest extends UnitTestCase {
* Data provider for preRenderHtmlTag test.
*/
public function providerPreRenderHtmlTag() {
- $tags = array();
+ $tags = [];
// Value prefix/suffix.
- $element = array(
+ $element = [
'#value' => 'value',
'#tag' => 'p',
- );
- $tags[] = array($element, '<p>value</p>' . "\n");
+ ];
+ $tags[] = [$element, '<p>value</p>' . "\n"];
// Normal element without a value should not result in a void element.
- $element = array(
+ $element = [
'#tag' => 'p',
'#value' => NULL,
- );
- $tags[] = array($element, "<p></p>\n");
+ ];
+ $tags[] = [$element, "<p></p>\n"];
// A void element.
- $element = array(
+ $element = [
'#tag' => 'br',
- );
- $tags[] = array($element, "<br />\n");
+ ];
+ $tags[] = [$element, "<br />\n"];
// Attributes.
- $element = array(
+ $element = [
'#tag' => 'div',
- '#attributes' => array('class' => 'test', 'id' => 'id'),
+ '#attributes' => ['class' => 'test', 'id' => 'id'],
'#value' => 'value',
- );
- $tags[] = array($element, '<div class="test" id="id">value</div>' . "\n");
+ ];
+ $tags[] = [$element, '<div class="test" id="id">value</div>' . "\n"];
// No script tags.
$element['#noscript'] = TRUE;
- $tags[] = array($element, '<noscript><div class="test" id="id">value</div>' . "\n" . '</noscript>');
+ $tags[] = [$element, '<noscript><div class="test" id="id">value</div>' . "\n" . '</noscript>'];
// Ensure that #tag is sanitised.
- $element = array(
+ $element = [
'#tag' => 'p><script>alert()</script><p',
'#value' => 'value',
- );
- $tags[] = array($element, "<p&gt;&lt;script&gt;alert()&lt;/script&gt;&lt;p>value</p&gt;&lt;script&gt;alert()&lt;/script&gt;&lt;p>\n");
+ ];
+ $tags[] = [$element, "<p&gt;&lt;script&gt;alert()&lt;/script&gt;&lt;p>value</p&gt;&lt;script&gt;alert()&lt;/script&gt;&lt;p>\n"];
// Ensure that #value is not filtered if it is marked as safe.
- $element = array(
+ $element = [
'#tag' => 'p',
'#value' => Markup::create('<script>value</script>'),
- );
- $tags[] = array($element, "<p><script>value</script></p>\n");
+ ];
+ $tags[] = [$element, "<p><script>value</script></p>\n"];
// Ensure that #value is filtered if it is not safe.
- $element = array(
+ $element = [
'#tag' => 'p',
'#value' => '<script>value</script>',
- );
- $tags[] = array($element, "<p>value</p>\n");
+ ];
+ $tags[] = [$element, "<p>value</p>\n"];
return $tags;
}
@@ -112,74 +112,74 @@ class HtmlTagTest extends UnitTestCase {
*/
public function providerPreRenderConditionalComments() {
// No browser specification.
- $element = array(
+ $element = [
'#tag' => 'link',
- );
- $tags[] = array($element, $element);
+ ];
+ $tags[] = [$element, $element];
// Specify all browsers.
- $element['#browsers'] = array(
+ $element['#browsers'] = [
'IE' => TRUE,
'!IE' => TRUE,
- );
- $tags[] = array($element, $element);
+ ];
+ $tags[] = [$element, $element];
// All IE.
- $element = array(
+ $element = [
'#tag' => 'link',
- '#browsers' => array(
+ '#browsers' => [
'IE' => TRUE,
'!IE' => FALSE,
- ),
- );
+ ],
+ ];
$expected = $element;
$expected['#prefix'] = "\n<!--[if IE]>\n";
$expected['#suffix'] = "<![endif]-->\n";
- $tags[] = array($element, $expected);
+ $tags[] = [$element, $expected];
// Exclude IE.
- $element = array(
+ $element = [
'#tag' => 'link',
- '#browsers' => array(
+ '#browsers' => [
'IE' => FALSE,
- ),
- );
+ ],
+ ];
$expected = $element;
$expected['#prefix'] = "\n<!--[if !IE]><!-->\n";
$expected['#suffix'] = "<!--<![endif]-->\n";
- $tags[] = array($element, $expected);
+ $tags[] = [$element, $expected];
// IE gt 8
- $element = array(
+ $element = [
'#tag' => 'link',
- '#browsers' => array(
+ '#browsers' => [
'IE' => 'gt IE 8',
- ),
- );
+ ],
+ ];
$expected = $element;
$expected['#prefix'] = "\n<!--[if gt IE 8]><!-->\n";
$expected['#suffix'] = "<!--<![endif]-->\n";
- $tags[] = array($element, $expected);
+ $tags[] = [$element, $expected];
// Prefix and suffix filtering if not safe.
- $element = array(
+ $element = [
'#tag' => 'link',
- '#browsers' => array(
+ '#browsers' => [
'IE' => FALSE,
- ),
+ ],
'#prefix' => '<blink>prefix</blink>',
'#suffix' => '<blink>suffix</blink>',
- );
+ ];
$expected = $element;
$expected['#prefix'] = "\n<!--[if !IE]><!-->\nprefix";
$expected['#suffix'] = "suffix<!--<![endif]-->\n";
- $tags[] = array($element, $expected);
+ $tags[] = [$element, $expected];
// Prefix and suffix filtering if marked as safe. This has to come after the
// previous test case.
$expected['#prefix'] = "\n<!--[if !IE]><!-->\n<blink>prefix</blink>";
$expected['#suffix'] = "<blink>suffix</blink><!--<![endif]-->\n";
- $tags[] = array($element, $expected, TRUE);
+ $tags[] = [$element, $expected, TRUE];
return $tags;
}
diff --git a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php
index 0d5aec69c53..c3058300d0e 100644
--- a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php
@@ -85,13 +85,13 @@ class ElementInfoManagerTest extends UnitTestCase {
$plugin = $this->getMock($plugin_class);
$plugin->expects($this->once())
->method('getInfo')
- ->willReturn(array(
+ ->willReturn([
'#theme' => 'page',
- ));
+ ]);
$element_info = $this->getMockBuilder('Drupal\Core\Render\ElementInfoManager')
- ->setConstructorArgs(array(new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager))
- ->setMethods(array('getDefinitions', 'createInstance'))
+ ->setConstructorArgs([new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager])
+ ->setMethods(['getDefinitions', 'createInstance'])
->getMock();
$this->themeManager->expects($this->any())
@@ -104,9 +104,9 @@ class ElementInfoManagerTest extends UnitTestCase {
->willReturn($plugin);
$element_info->expects($this->once())
->method('getDefinitions')
- ->willReturn(array(
- 'page' => array('class' => 'TestElementPlugin'),
- ));
+ ->willReturn([
+ 'page' => ['class' => 'TestElementPlugin'],
+ ]);
$this->assertEquals($expected_info, $element_info->getInfo('page'));
}
@@ -117,26 +117,26 @@ class ElementInfoManagerTest extends UnitTestCase {
* @return array
*/
public function providerTestGetInfoElementPlugin() {
- $data = array();
- $data[] = array(
+ $data = [];
+ $data[] = [
'Drupal\Core\Render\Element\ElementInterface',
- array(
+ [
'#type' => 'page',
'#theme' => 'page',
'#defaults_loaded' => TRUE,
- ),
- );
+ ],
+ ];
- $data[] = array(
+ $data[] = [
'Drupal\Core\Render\Element\FormElementInterface',
- array(
+ [
'#type' => 'page',
'#theme' => 'page',
'#input' => TRUE,
- '#value_callback' => array('TestElementPlugin', 'valueCallback'),
+ '#value_callback' => ['TestElementPlugin', 'valueCallback'],
'#defaults_loaded' => TRUE,
- ),
- );
+ ],
+ ];
return $data;
}
@@ -164,12 +164,12 @@ class TestElementInfoManager extends ElementInfoManager {
/**
* {@inheritdoc}
*/
- protected $elementInfo = array(
- 'test' => array(
- 'foo' => array(
+ protected $elementInfo = [
+ 'test' => [
+ 'foo' => [
'#bar' => 'baz',
- ),
- ),
- );
+ ],
+ ],
+ ];
}
diff --git a/core/tests/Drupal/Tests/Core/Render/ElementTest.php b/core/tests/Drupal/Tests/Core/Render/ElementTest.php
index 604d391d8d1..b9f86ac4918 100644
--- a/core/tests/Drupal/Tests/Core/Render/ElementTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/ElementTest.php
@@ -25,11 +25,11 @@ class ElementTest extends UnitTestCase {
* Tests the properties() method.
*/
public function testProperties() {
- $element = array(
+ $element = [
'#property1' => 'property1',
'#property2' => 'property2',
'property3' => 'property3'
- );
+ ];
$properties = Element::properties($element);
@@ -51,51 +51,51 @@ class ElementTest extends UnitTestCase {
* Tests the children() method.
*/
public function testChildren() {
- $element = array(
- 'child2' => array('#weight' => 10),
- 'child1' => array('#weight' => 0),
- 'child3' => array('#weight' => 20),
+ $element = [
+ 'child2' => ['#weight' => 10],
+ 'child1' => ['#weight' => 0],
+ 'child3' => ['#weight' => 20],
'#property' => 'property',
- );
+ ];
- $expected = array('child2', 'child1', 'child3');
+ $expected = ['child2', 'child1', 'child3'];
$element_copy = $element;
$this->assertSame($expected, Element::children($element_copy));
// If #sorted is already set, no sorting should happen.
$element_copy = $element;
$element_copy['#sorted'] = TRUE;
- $expected = array('child2', 'child1', 'child3');
+ $expected = ['child2', 'child1', 'child3'];
$this->assertSame($expected, Element::children($element_copy, TRUE));
// Test with weight sorting, #sorted property should be added.
- $expected = array('child1', 'child2', 'child3');
+ $expected = ['child1', 'child2', 'child3'];
$element_copy = $element;
$this->assertSame($expected, Element::children($element_copy, TRUE));
$this->assertArrayHasKey('#sorted', $element_copy);
$this->assertTrue($element_copy['#sorted']);
// The order should stay the same if no weights present.
- $element_no_weight = array(
- 'child2' => array(),
- 'child1' => array(),
- 'child3' => array(),
+ $element_no_weight = [
+ 'child2' => [],
+ 'child1' => [],
+ 'child3' => [],
'#property' => 'property',
- );
+ ];
- $expected = array('child2', 'child1', 'child3');
+ $expected = ['child2', 'child1', 'child3'];
$this->assertSame($expected, Element::children($element_no_weight, TRUE));
// The order of children with same weight should be preserved.
- $element_mixed_weight = array(
- 'child5' => array('#weight' => 10),
- 'child3' => array('#weight' => -10),
- 'child1' => array(),
- 'child4' => array('#weight' => 10),
- 'child2' => array(),
- );
-
- $expected = array('child3', 'child1', 'child2', 'child5', 'child4');
+ $element_mixed_weight = [
+ 'child5' => ['#weight' => 10],
+ 'child3' => ['#weight' => -10],
+ 'child1' => [],
+ 'child4' => ['#weight' => 10],
+ 'child2' => [],
+ ];
+
+ $expected = ['child3', 'child1', 'child2', 'child5', 'child4'];
$this->assertSame($expected, Element::children($element_mixed_weight, TRUE));
}
@@ -106,9 +106,9 @@ class ElementTest extends UnitTestCase {
* @expectedExceptionMessage "foo" is an invalid render array key
*/
public function testInvalidChildren() {
- $element = array(
+ $element = [
'foo' => 'bar',
- );
+ ];
Element::children($element);
}
@@ -116,10 +116,10 @@ class ElementTest extends UnitTestCase {
* Tests the children() method with an ignored key/value pair.
*/
public function testIgnoredChildren() {
- $element = array(
+ $element = [
'foo' => NULL,
- );
- $this->assertSame(array(), Element::children($element));
+ ];
+ $this->assertSame([], Element::children($element));
}
/**
@@ -142,17 +142,17 @@ class ElementTest extends UnitTestCase {
* @return array
*/
public function providerVisibleChildren() {
- return array(
- array(array('#property1' => '', '#property2' => array()), array()),
- array(array('#property1' => '', 'child1' => array()), array('child1')),
- array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => TRUE)), array('child1', 'child2')),
- array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => FALSE)), array('child1')),
- 'access_result_object_allowed' => array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => AccessResult::allowed())), array('child1', 'child2')),
- 'access_result_object_forbidden' => array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => AccessResult::forbidden())), array('child1')),
- array(array('#property1' => '', 'child1' => array(), 'child2' => array('#type' => 'textfield')), array('child1', 'child2')),
- array(array('#property1' => '', 'child1' => array(), 'child2' => array('#type' => 'value')), array('child1')),
- array(array('#property1' => '', 'child1' => array(), 'child2' => array('#type' => 'hidden')), array('child1')),
- );
+ return [
+ [['#property1' => '', '#property2' => []], []],
+ [['#property1' => '', 'child1' => []], ['child1']],
+ [['#property1' => '', 'child1' => [], 'child2' => ['#access' => TRUE]], ['child1', 'child2']],
+ [['#property1' => '', 'child1' => [], 'child2' => ['#access' => FALSE]], ['child1']],
+ 'access_result_object_allowed' => [['#property1' => '', 'child1' => [], 'child2' => ['#access' => AccessResult::allowed()]], ['child1', 'child2']],
+ 'access_result_object_forbidden' => [['#property1' => '', 'child1' => [], 'child2' => ['#access' => AccessResult::forbidden()]], ['child1']],
+ [['#property1' => '', 'child1' => [], 'child2' => ['#type' => 'textfield']], ['child1', 'child2']],
+ [['#property1' => '', 'child1' => [], 'child2' => ['#type' => 'value']], ['child1']],
+ [['#property1' => '', 'child1' => [], 'child2' => ['#type' => 'hidden']], ['child1']],
+ ];
}
/**
@@ -169,12 +169,12 @@ class ElementTest extends UnitTestCase {
* Data provider for testSetAttributes().
*/
public function providerTestSetAttributes() {
- $base = array('#id' => 'id', '#class' => array());
- return array(
- array($base, array(), $base),
- array($base, array('id', 'class'), $base + array('#attributes' => array('id' => 'id', 'class' => array()))),
- array($base + array('#attributes' => array('id' => 'id-not-overwritten')), array('id', 'class'), $base + array('#attributes' => array('id' => 'id-not-overwritten', 'class' => array()))),
- );
+ $base = ['#id' => 'id', '#class' => []];
+ return [
+ [$base, [], $base],
+ [$base, ['id', 'class'], $base + ['#attributes' => ['id' => 'id', 'class' => []]]],
+ [$base + ['#attributes' => ['id' => 'id-not-overwritten']], ['id', 'class'], $base + ['#attributes' => ['id' => 'id-not-overwritten', 'class' => []]]],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
index cea677b9b23..7ac4a901644 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
@@ -151,7 +151,7 @@ class RendererTest extends RendererTestBase {
// Test #allowed_tags in combination with #markup and #pre_render.
$data[] = [[
'#markup' => 'foo',
- '#allowed_tags' => array('script'),
+ '#allowed_tags' => ['script'],
'#pre_render' => [function($elements) {
$elements['#markup'] .= '<script>alert("bar");</script>';
return $elements;
@@ -408,17 +408,17 @@ class RendererTest extends RendererTestBase {
$first = $this->randomMachineName();
$second = $this->randomMachineName();
// The same array structure again, but with #sorted set to TRUE.
- $elements = array(
- 'second' => array(
+ $elements = [
+ 'second' => [
'#weight' => 10,
'#markup' => $second,
- ),
- 'first' => array(
+ ],
+ 'first' => [
'#weight' => 0,
'#markup' => $first,
- ),
+ ],
'#sorted' => TRUE,
- );
+ ];
$output = $this->renderer->renderRoot($elements);
// The elements should appear in output in the same order as the array.
@@ -597,9 +597,9 @@ class RendererTest extends RendererTestBase {
* @covers ::doRender
*/
public function testRenderWithoutThemeArguments() {
- $element = array(
+ $element = [
'#theme' => 'common_test_foo',
- );
+ ];
$this->themeManager->expects($this->once())
->method('render')
@@ -615,11 +615,11 @@ class RendererTest extends RendererTestBase {
* @covers ::doRender
*/
public function testRenderWithThemeArguments() {
- $element = array(
+ $element = [
'#theme' => 'common_test_foo',
'#foo' => $this->randomMachineName(),
'#bar' => $this->randomMachineName(),
- );
+ ];
$this->themeManager->expects($this->once())
->method('render')
diff --git a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
index dadf612f02d..96a01b431ca 100644
--- a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
@@ -27,54 +27,54 @@ class RoleAccessCheckTest extends UnitTestCase {
protected function getTestRouteCollection() {
$route_collection = new RouteCollection();
$route_collection->add('role_test_1', new Route('/role_test_1',
- array(
+ [
'_controller' => '\Drupal\router_test\TestControllers::test1',
- ),
- array(
+ ],
+ [
'_role' => 'role_test_1',
- )
+ ]
));
$route_collection->add('role_test_2', new Route('/role_test_2',
- array(
+ [
'_controller' => '\Drupal\router_test\TestControllers::test1',
- ),
- array(
+ ],
+ [
'_role' => 'role_test_2',
- )
+ ]
));
$route_collection->add('role_test_3', new Route('/role_test_3',
- array(
+ [
'_controller' => '\Drupal\router_test\TestControllers::test1',
- ),
- array(
+ ],
+ [
'_role' => 'role_test_1,role_test_2',
- )
+ ]
));
// Ensure that trimming the values works on "OR" conjunctions.
$route_collection->add('role_test_4', new Route('/role_test_4',
- array(
+ [
'_controller' => '\Drupal\router_test\TestControllers::test1',
- ),
- array(
+ ],
+ [
'_role' => 'role_test_1 , role_test_2',
- )
+ ]
));
$route_collection->add('role_test_5', new Route('/role_test_5',
- array(
+ [
'_controller' => '\Drupal\router_test\TestControllers::test1',
- ),
- array(
+ ],
+ [
'_role' => 'role_test_1+role_test_2',
- )
+ ]
));
// Ensure that trimming the values works on "AND" conjunctions.
$route_collection->add('role_test_6', new Route('/role_test_6',
- array(
+ [
'_controller' => '\Drupal\router_test\TestControllers::test1',
- ),
- array(
+ ],
+ [
'_role' => 'role_test_1 + role_test_2',
- )
+ ]
));
return $route_collection;
@@ -93,35 +93,35 @@ class RoleAccessCheckTest extends UnitTestCase {
// Setup one user with the first role, one with the second, one with both
// and one final without any of these two roles.
- $account_1 = new UserSession(array(
+ $account_1 = new UserSession([
'uid' => 1,
- 'roles' => array($rid_1),
- ));
+ 'roles' => [$rid_1],
+ ]);
- $account_2 = new UserSession(array(
+ $account_2 = new UserSession([
'uid' => 2,
- 'roles' => array($rid_2),
- ));
+ 'roles' => [$rid_2],
+ ]);
- $account_12 = new UserSession(array(
+ $account_12 = new UserSession([
'uid' => 3,
- 'roles' => array($rid_1, $rid_2),
- ));
+ 'roles' => [$rid_1, $rid_2],
+ ]);
- $account_none = new UserSession(array(
+ $account_none = new UserSession([
'uid' => 1,
- 'roles' => array(),
- ));
+ 'roles' => [],
+ ]);
// Setup expected values; specify which paths can be accessed by which user.
- return array(
- array('role_test_1', array($account_1, $account_12), array($account_2, $account_none)),
- array('role_test_2', array($account_2, $account_12), array($account_1, $account_none)),
- array('role_test_3', array($account_12), array($account_1, $account_2, $account_none)),
- array('role_test_4', array($account_12), array($account_1, $account_2, $account_none)),
- array('role_test_5', array($account_1, $account_2, $account_12), array()),
- array('role_test_6', array($account_1, $account_2, $account_12), array()),
- );
+ return [
+ ['role_test_1', [$account_1, $account_12], [$account_2, $account_none]],
+ ['role_test_2', [$account_2, $account_12], [$account_1, $account_none]],
+ ['role_test_3', [$account_12], [$account_1, $account_2, $account_none]],
+ ['role_test_4', [$account_12], [$account_1, $account_2, $account_none]],
+ ['role_test_5', [$account_1, $account_2, $account_12], []],
+ ['role_test_6', [$account_1, $account_2, $account_12], []],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php b/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php
index 5bc2be0fa36..1de17456e25 100644
--- a/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php
@@ -30,14 +30,14 @@ class RouteProcessorManagerTest extends UnitTestCase {
*/
public function testRouteProcessorManager() {
$route = new Route('');
- $parameters = array('test' => 'test');
+ $parameters = ['test' => 'test'];
$route_name = 'test_name';
- $processors = array(
+ $processors = [
10 => $this->getMockProcessor($route_name, $route, $parameters),
5 => $this->getMockProcessor($route_name, $route, $parameters),
0 => $this->getMockProcessor($route_name, $route, $parameters),
- );
+ ];
// Add the processors in reverse order.
foreach ($processors as $priority => $processor) {
diff --git a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
index 0b7bcc6730e..d73513e78c5 100644
--- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
@@ -61,7 +61,7 @@ class AccessAwareRouterTest extends UnitTestCase {
->getMock();
$this->chainRouter->expects($this->once())
->method('matchRequest')
- ->will($this->returnValue(array(RouteObjectInterface::ROUTE_OBJECT => $this->route)));
+ ->will($this->returnValue([RouteObjectInterface::ROUTE_OBJECT => $this->route]));
$this->router = new AccessAwareRouter($this->chainRouter, $this->accessManager, $this->currentUser);
}
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
index af3ef687fd5..d075934100d 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
@@ -106,7 +106,7 @@ class RouteBuilderTest extends UnitTestCase {
$this->yamlDiscovery->expects($this->any())
->method('findAll')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->assertTrue($this->routeBuilder->rebuild());
}
@@ -149,7 +149,7 @@ class RouteBuilderTest extends UnitTestCase {
$this->yamlDiscovery->expects($this->once())
->method('findAll')
- ->will($this->returnValue(array('test_module' => $routes)));
+ ->will($this->returnValue(['test_module' => $routes]));
$route_collection = $routing_fixtures->sampleRouteCollection();
$route_build_event = new RouteBuildEvent($route_collection);
@@ -192,14 +192,14 @@ class RouteBuilderTest extends UnitTestCase {
$this->yamlDiscovery->expects($this->once())
->method('findAll')
- ->will($this->returnValue(array(
- 'test_module' => array(
- 'route_callbacks' => array(
+ ->will($this->returnValue([
+ 'test_module' => [
+ 'route_callbacks' => [
'\Drupal\Tests\Core\Routing\TestRouteSubscriber::routesFromArray',
'test_module.route_service:routesFromCollection',
- ),
- ),
- )));
+ ],
+ ],
+ ]));
$container = new ContainerBuilder();
$container->set('test_module.route_service', new TestRouteSubscriber());
@@ -215,7 +215,7 @@ class RouteBuilderTest extends UnitTestCase {
list($class, $method) = explode('::', $controller, 2);
$object = new $class();
}
- return array($object, $method);
+ return [$object, $method];
}));
$route_collection_filled = new RouteCollection();
@@ -263,7 +263,7 @@ class RouteBuilderTest extends UnitTestCase {
$this->yamlDiscovery->expects($this->any())
->method('findAll')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$this->routeBuilder->setRebuildNeeded();
@@ -312,9 +312,9 @@ class TestRouteBuilder extends RouteBuilder {
*/
class TestRouteSubscriber {
public function routesFromArray() {
- return array(
+ return [
'test_route.1' => new Route('/test-route/1'),
- );
+ ];
}
public function routesFromCollection() {
$collection = new RouteCollection();
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php
index 271e313e2df..2ddfdcaedee 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php
@@ -38,15 +38,15 @@ class RouteCompilerTest extends UnitTestCase {
* value.
*/
public function providerTestGetFit() {
- return array(
- array('test', 1),
- array('/testwithleadingslash', 1),
- array('testwithtrailingslash/', 1),
- array('/testwithslashes/', 1),
- array('test/with/multiple/parts', 15),
- array('test/with/{some}/slugs', 13),
- array('test/very/long/path/that/drupal/7/could/not/have/handled', 2047),
- );
+ return [
+ ['test', 1],
+ ['/testwithleadingslash', 1],
+ ['testwithtrailingslash/', 1],
+ ['/testwithslashes/', 1],
+ ['test/with/multiple/parts', 15],
+ ['test/with/{some}/slugs', 13],
+ ['test/very/long/path/that/drupal/7/could/not/have/handled', 2047],
+ ];
}
/**
@@ -67,9 +67,9 @@ class RouteCompilerTest extends UnitTestCase {
public function testCompilationDefaultValue() {
// Because "here" has a default value, it should not factor into the outline
// or the fitness.
- $route = new Route('/test/{something}/more/{here}', array(
+ $route = new Route('/test/{something}/more/{here}', [
'here' => 'there',
- ));
+ ]);
$route->setOption('compiler_class', 'Drupal\Core\Routing\RouteCompiler');
$compiled = $route->compile();
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php
index 22055c9f28e..0a3c65cbe9f 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php
@@ -32,9 +32,9 @@ class RouteMatchTest extends RouteMatchTestBase {
$route_match = RouteMatch::createFromRequest($request);
$this->assertNull($route_match->getRouteName());
$this->assertNull($route_match->getRouteObject());
- $this->assertSame(array(), $route_match->getParameters()->all());
+ $this->assertSame([], $route_match->getParameters()->all());
$this->assertNull($route_match->getParameter('foo'));
- $this->assertSame(array(), $route_match->getRawParameters()->all());
+ $this->assertSame([], $route_match->getRawParameters()->all());
$this->assertNull($route_match->getRawParameter('foo'));
// A routed request without parameter upcasting.
@@ -45,17 +45,17 @@ class RouteMatchTest extends RouteMatchTestBase {
$route_match = RouteMatch::createFromRequest($request);
$this->assertSame('test_route', $route_match->getRouteName());
$this->assertSame($route, $route_match->getRouteObject());
- $this->assertSame(array('foo' => '1'), $route_match->getParameters()->all());
- $this->assertSame(array(), $route_match->getRawParameters()->all());
+ $this->assertSame(['foo' => '1'], $route_match->getParameters()->all());
+ $this->assertSame([], $route_match->getRawParameters()->all());
// A routed request with parameter upcasting.
$foo = new \stdClass();
$foo->value = 1;
$request->attributes->set('foo', $foo);
- $request->attributes->set('_raw_variables', new ParameterBag(array('foo' => '1')));
+ $request->attributes->set('_raw_variables', new ParameterBag(['foo' => '1']));
$route_match = RouteMatch::createFromRequest($request);
- $this->assertSame(array('foo' => $foo), $route_match->getParameters()->all());
- $this->assertSame(array('foo' => '1'), $route_match->getRawParameters()->all());
+ $this->assertSame(['foo' => $foo], $route_match->getParameters()->all());
+ $this->assertSame(['foo' => '1'], $route_match->getRawParameters()->all());
}
}
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php
index 6af83970cd6..2678fd3268c 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php
@@ -31,46 +31,46 @@ abstract class RouteMatchTestBase extends UnitTestCase {
* Provide sets of parameters and expected parameters for parameter tests.
*/
public function routeMatchProvider() {
- $base_data = array(
- array(
+ $base_data = [
+ [
new Route(
'/test-route/{param_without_leading_underscore}/{_param_with_leading_underscore}',
- array(
+ [
'default_without_leading_underscore' => NULL,
'_default_with_leading_underscore' => NULL,
- )
+ ]
),
- array(
+ [
'param_without_leading_underscore' => 'value',
'_param_with_leading_underscore' => 'value',
'default_without_leading_underscore' => 'value',
'_default_with_leading_underscore' => 'value',
'foo' => 'value',
- ),
+ ],
// Parameters should be filtered to only those defined by the route.
// Specifically:
// - Path parameters, regardless of name.
// - Defaults that are not path parameters only if they do not start with
// an underscore.
- array(
+ [
'param_without_leading_underscore' => 'value',
'_param_with_leading_underscore' => 'value',
'default_without_leading_underscore' => 'value',
- ),
- ),
- );
+ ],
+ ],
+ ];
- $data = array();
+ $data = [];
foreach ($base_data as $entry) {
$route = $entry[0];
$params = $entry[1];
$expected_params = $entry[2];
- $data[] = array(
+ $data[] = [
$this->getRouteMatch('test_route', $route, $params, $params),
$route,
$params,
$expected_params,
- );
+ ];
}
return $data;
diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
index 4db4297292c..90b4a9ddb66 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
@@ -61,15 +61,15 @@ class RoutePreloaderTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$route_collection = new RouteCollection();
- $route_collection->add('test', new Route('/admin/foo', array('_controller' => 'Drupal\ExampleController')));
- $route_collection->add('test2', new Route('/admin/bar', array('_controller' => 'Drupal\ExampleController')));
+ $route_collection->add('test', new Route('/admin/foo', ['_controller' => 'Drupal\ExampleController']));
+ $route_collection->add('test2', new Route('/admin/bar', ['_controller' => 'Drupal\ExampleController']));
$event->expects($this->once())
->method('getRouteCollection')
->will($this->returnValue($route_collection));
$this->state->expects($this->once())
->method('set')
- ->with('routing.non_admin_routes', array());
+ ->with('routing.non_admin_routes', []);
$this->preloader->onAlterRoutes($event);
$this->preloader->onFinishedRoutes(new Event());
}
@@ -82,17 +82,17 @@ class RoutePreloaderTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$route_collection = new RouteCollection();
- $route_collection->add('test', new Route('/foo/admin/foo', array('_controller' => 'Drupal\ExampleController')));
- $route_collection->add('test2', new Route('/bar/admin/bar', array('_controller' => 'Drupal\ExampleController')));
- $route_collection->add('test3', new Route('/administrator/a', array('_controller' => 'Drupal\ExampleController')));
- $route_collection->add('test4', new Route('/admin', array('_controller' => 'Drupal\ExampleController')));
+ $route_collection->add('test', new Route('/foo/admin/foo', ['_controller' => 'Drupal\ExampleController']));
+ $route_collection->add('test2', new Route('/bar/admin/bar', ['_controller' => 'Drupal\ExampleController']));
+ $route_collection->add('test3', new Route('/administrator/a', ['_controller' => 'Drupal\ExampleController']));
+ $route_collection->add('test4', new Route('/admin', ['_controller' => 'Drupal\ExampleController']));
$event->expects($this->once())
->method('getRouteCollection')
->will($this->returnValue($route_collection));
$this->state->expects($this->once())
->method('set')
- ->with('routing.non_admin_routes', array('test', 'test2', 'test3'));
+ ->with('routing.non_admin_routes', ['test', 'test2', 'test3']);
$this->preloader->onAlterRoutes($event);
$this->preloader->onFinishedRoutes(new Event());
}
@@ -106,17 +106,17 @@ class RoutePreloaderTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$route_collection = new RouteCollection();
- $route_collection->add('test', new Route('/admin/foo', array('_controller' => 'Drupal\ExampleController')));
- $route_collection->add('test2', new Route('/bar', array('_controller' => 'Drupal\ExampleController')));
+ $route_collection->add('test', new Route('/admin/foo', ['_controller' => 'Drupal\ExampleController']));
+ $route_collection->add('test2', new Route('/bar', ['_controller' => 'Drupal\ExampleController']));
// Non content routes, like ajax callbacks should be ignored.
- $route_collection->add('test3', new Route('/bar', array('_controller' => 'Drupal\ExampleController')));
+ $route_collection->add('test3', new Route('/bar', ['_controller' => 'Drupal\ExampleController']));
$event->expects($this->once())
->method('getRouteCollection')
->will($this->returnValue($route_collection));
$this->state->expects($this->once())
->method('set')
- ->with('routing.non_admin_routes', array('test2', 'test3'));
+ ->with('routing.non_admin_routes', ['test2', 'test3']);
$this->preloader->onAlterRoutes($event);
$this->preloader->onFinishedRoutes(new Event());
}
@@ -161,7 +161,7 @@ class RoutePreloaderTest extends UnitTestCase {
$this->state->expects($this->once())
->method('get')
->with('routing.non_admin_routes')
- ->will($this->returnValue(array('test2')));
+ ->will($this->returnValue(['test2']));
$this->preloader->onRequest($event);
}
diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php
index 8ceac687f9b..38278ab0811 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php
@@ -47,32 +47,32 @@ class RoutingFixtures {
* Returns a static version of the routes.
*/
public function staticSampleRouteCollection() {
- $routes = array();
- $routes['route_a'] = array(
+ $routes = [];
+ $routes['route_a'] = [
'path' => '/path/one',
- 'methods' => array('GET'),
- );
- $routes['route_b'] = array(
+ 'methods' => ['GET'],
+ ];
+ $routes['route_b'] = [
'path' => '/path/one',
- 'methods' => array('PUT'),
- );
- $routes['route_c'] = array(
+ 'methods' => ['PUT'],
+ ];
+ $routes['route_c'] = [
'path' => '/path/two',
- 'methods' => array('GET'),
- 'requirements' => array(
+ 'methods' => ['GET'],
+ 'requirements' => [
'_format' => 'json'
- ),
- );
- $routes['route_d'] = array(
+ ],
+ ];
+ $routes['route_d'] = [
'path' => '/path/three',
- );
- $routes['route_e'] = array(
+ ];
+ $routes['route_e'] = [
'path' => '/path/two',
- 'methods' => array('GET', 'HEAD'),
- 'requirements' => array(
+ 'methods' => ['GET', 'HEAD'],
+ 'requirements' => [
'_format' => 'html'
- ),
- );
+ ],
+ ];
return $routes;
}
@@ -235,74 +235,74 @@ class RoutingFixtures {
*/
public function routingTableDefinition() {
- $tables['test_routes'] = array(
+ $tables['test_routes'] = [
'description' => 'Maps paths to various callbacks (access, page and title)',
- 'fields' => array(
- 'name' => array(
+ 'fields' => [
+ 'name' => [
'description' => 'Primary Key: Machine name of this route',
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'path' => array(
+ ],
+ 'path' => [
'description' => 'The path for this URI',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'pattern_outline' => array(
+ ],
+ 'pattern_outline' => [
'description' => 'The pattern',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'provider' => array(
+ ],
+ 'provider' => [
'description' => 'The provider grouping to which a route belongs.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'access_callback' => array(
+ ],
+ 'access_callback' => [
'description' => 'The callback which determines the access to this router path. Defaults to \Drupal\Core\Session\AccountInterface::hasPermission.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
- ),
- 'access_arguments' => array(
+ ],
+ 'access_arguments' => [
'description' => 'A serialized array of arguments for the access callback.',
'type' => 'blob',
'not null' => FALSE,
- ),
- 'fit' => array(
+ ],
+ 'fit' => [
'description' => 'A numeric representation of how specific the path is.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- 'number_parts' => array(
+ ],
+ 'number_parts' => [
'description' => 'Number of parts in this router path.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'small',
- ),
- 'route' => array(
+ ],
+ 'route' => [
'description' => 'A serialized Route object',
'type' => 'text',
- ),
- ),
- 'indexes' => array(
- 'fit' => array('fit'),
- 'pattern_outline' => array('pattern_outline'),
- 'provider' => array('provider'),
- ),
- 'primary key' => array('name'),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'fit' => ['fit'],
+ 'pattern_outline' => ['pattern_outline'],
+ 'provider' => ['provider'],
+ ],
+ 'primary key' => ['name'],
+ ];
return $tables;
}
diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
index b0c1ca33fe9..6c6d768a456 100644
--- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
@@ -107,8 +107,8 @@ class UrlGeneratorTest extends UnitTestCase {
// We need to set up return value maps for both the getRouteByName() and the
// getRoutesByNames() method calls on the route provider. The parameters
// are not passed in and default to an empty array.
- $route_name_return_map = $routes_names_return_map = array();
- $return_map_values = array(
+ $route_name_return_map = $routes_names_return_map = [];
+ $return_map_values = [
[
'route_name' => 'test_1',
'return' => $first_route,
@@ -129,10 +129,10 @@ class UrlGeneratorTest extends UnitTestCase {
'route_name' => '<none>',
'return' => $none_route,
],
- );
+ ];
foreach ($return_map_values as $values) {
- $route_name_return_map[] = array($values['route_name'], $values['return']);
- $routes_names_return_map[] = array(array($values['route_name']), $values['return']);
+ $route_name_return_map[] = [$values['route_name'], $values['return']];
+ $routes_names_return_map[] = [[$values['route_name']], $values['return']];
}
$this->provider = $provider;
$this->provider->expects($this->any())
@@ -149,7 +149,7 @@ class UrlGeneratorTest extends UnitTestCase {
$alias_manager->expects($this->any())
->method('getAliasByPath')
- ->will($this->returnCallback(array($this, 'aliasManagerCallback')));
+ ->will($this->returnCallback([$this, 'aliasManagerCallback']));
$this->aliasManager = $alias_manager;
@@ -223,7 +223,7 @@ class UrlGeneratorTest extends UnitTestCase {
* Confirms that generated routes will have aliased paths using interface constants.
*/
public function testAliasGenerationUsingInterfaceConstants() {
- $url = $this->generator->generate('test_1', array(), UrlGenerator::ABSOLUTE_PATH);
+ $url = $this->generator->generate('test_1', [], UrlGenerator::ABSOLUTE_PATH);
$this->assertEquals('/hello/world', $url);
// No cacheability to test; UrlGenerator::generate() doesn't support
// collecting cacheability metadata.
@@ -303,7 +303,7 @@ class UrlGeneratorTest extends UnitTestCase {
* Confirms that generated routes will have aliased paths.
*/
public function testAliasGenerationWithParameters() {
- $url = $this->generator->generate('test_2', array('narf' => '5'));
+ $url = $this->generator->generate('test_2', ['narf' => '5']);
$this->assertEquals('/goodbye/cruel/world', $url);
// No cacheability to test; UrlGenerator::generate() doesn't support
// collecting cacheability metadata.
@@ -312,17 +312,17 @@ class UrlGeneratorTest extends UnitTestCase {
->method('processOutbound')
->with($this->anything());
- $options = array('fragment' => 'top');
+ $options = ['fragment' => 'top'];
// Extra parameters should appear in the query string.
$this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, '/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
- $options = array('query' => array('page' => '1'), 'fragment' => 'bottom');
+ $options = ['query' => ['page' => '1'], 'fragment' => 'bottom'];
$this->assertGenerateFromRoute('test_2', ['narf' => 5], $options, '/goodbye/cruel/world?page=1#bottom', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
// Changing the parameters, the route still matches but there is no alias.
$this->assertGenerateFromRoute('test_2', ['narf' => 7], $options, '/test/two/7?page=1#bottom', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
- $path = $this->generator->getPathFromRoute('test_2', array('narf' => '5'));
+ $path = $this->generator->getPathFromRoute('test_2', ['narf' => '5']);
$this->assertEquals('test/two/5', $path);
// Specify a query parameter with NULL.
@@ -396,7 +396,7 @@ class UrlGeneratorTest extends UnitTestCase {
* Confirms that absolute URLs work with generated routes.
*/
public function testAbsoluteURLGeneration() {
- $url = $this->generator->generate('test_1', array(), TRUE);
+ $url = $this->generator->generate('test_1', [], TRUE);
$this->assertEquals('http://localhost/hello/world', $url);
// No cacheability to test; UrlGenerator::generate() doesn't support
// collecting cacheability metadata.
@@ -405,7 +405,7 @@ class UrlGeneratorTest extends UnitTestCase {
->method('processOutbound')
->with($this->anything());
- $options = array('absolute' => TRUE, 'fragment' => 'top');
+ $options = ['absolute' => TRUE, 'fragment' => 'top'];
// Extra parameters should appear in the query string.
$this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, 'http://localhost/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['url.site']));
}
@@ -414,7 +414,7 @@ class UrlGeneratorTest extends UnitTestCase {
* Confirms that absolute URLs work with generated routes using interface constants.
*/
public function testAbsoluteURLGenerationUsingInterfaceConstants() {
- $url = $this->generator->generate('test_1', array(), UrlGenerator::ABSOLUTE_URL);
+ $url = $this->generator->generate('test_1', [], UrlGenerator::ABSOLUTE_URL);
$this->assertEquals('http://localhost/hello/world', $url);
// No cacheability to test; UrlGenerator::generate() doesn't support
// collecting cacheability metadata.
@@ -423,7 +423,7 @@ class UrlGeneratorTest extends UnitTestCase {
->method('processOutbound')
->with($this->anything());
- $options = array('absolute' => TRUE, 'fragment' => 'top');
+ $options = ['absolute' => TRUE, 'fragment' => 'top'];
// Extra parameters should appear in the query string.
$this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, 'http://localhost/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['url.site']));
}
@@ -432,20 +432,20 @@ class UrlGeneratorTest extends UnitTestCase {
* Confirms that explicitly setting the base_url works with generated routes
*/
public function testBaseURLGeneration() {
- $options = array('base_url' => 'http://www.example.com:8888');
+ $options = ['base_url' => 'http://www.example.com:8888'];
$this->assertGenerateFromRoute('test_1', [], $options, 'http://www.example.com:8888/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
- $options = array('base_url' => 'http://www.example.com:8888', 'https' => TRUE);
+ $options = ['base_url' => 'http://www.example.com:8888', 'https' => TRUE];
$this->assertGenerateFromRoute('test_1', [], $options, 'https://www.example.com:8888/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
- $options = array('base_url' => 'https://www.example.com:8888', 'https' => FALSE);
+ $options = ['base_url' => 'https://www.example.com:8888', 'https' => FALSE];
$this->assertGenerateFromRoute('test_1', [], $options, 'http://www.example.com:8888/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
$this->routeProcessorManager->expects($this->exactly(2))
->method('processOutbound')
->with($this->anything());
- $options = array('base_url' => 'http://www.example.com:8888', 'fragment' => 'top');
+ $options = ['base_url' => 'http://www.example.com:8888', 'fragment' => 'top'];
// Extra parameters should appear in the query string.
$this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, 'http://www.example.com:8888/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
}
@@ -454,7 +454,7 @@ class UrlGeneratorTest extends UnitTestCase {
* Test that the 'scheme' route requirement is respected during url generation.
*/
public function testUrlGenerationWithHttpsRequirement() {
- $url = $this->generator->generate('test_4', array(), TRUE);
+ $url = $this->generator->generate('test_4', [], TRUE);
$this->assertEquals('https://localhost/test/four', $url);
// No cacheability to test; UrlGenerator::generate() doesn't support
// collecting cacheability metadata.
@@ -463,7 +463,7 @@ class UrlGeneratorTest extends UnitTestCase {
->method('processOutbound')
->with($this->anything());
- $options = array('absolute' => TRUE, 'https' => TRUE);
+ $options = ['absolute' => TRUE, 'https' => TRUE];
$this->assertGenerateFromRoute('test_1', [], $options, 'https://localhost/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['url.site']));
}
@@ -514,7 +514,7 @@ class UrlGeneratorTest extends UnitTestCase {
$path_processor = $this->getMock(OutboundPathProcessorInterface::CLASS);
$path_processor->expects($this->atLeastOnce())
->method('processOutbound')
- ->willReturnCallback(function ($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
+ ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
$options['query'] = ['zoo' => 5];
return $path;
});
diff --git a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php
index 0840e0000ce..031de824462 100644
--- a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php
@@ -20,8 +20,8 @@ class AnonymousUserSessionTest extends UnitTestCase {
*/
public function testUserGetRoles() {
$anonymous_user = new AnonymousUserSession();
- $this->assertEquals(array(RoleInterface::ANONYMOUS_ID), $anonymous_user->getRoles());
- $this->assertEquals(array(), $anonymous_user->getRoles(TRUE));
+ $this->assertEquals([RoleInterface::ANONYMOUS_ID], $anonymous_user->getRoles());
+ $this->assertEquals([], $anonymous_user->getRoles(TRUE));
}
}
diff --git a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
index d5e8c32d82a..aa980f8c951 100644
--- a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
@@ -75,12 +75,12 @@ class PermissionsHashGeneratorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- new Settings(array('hash_salt' => 'test'));
+ new Settings(['hash_salt' => 'test']);
// The mocked super user account, with the same roles as Account 2.
$this->account1 = $this->getMockBuilder('Drupal\user\Entity\User')
->disableOriginalConstructor()
- ->setMethods(array('getRoles', 'id'))
+ ->setMethods(['getRoles', 'id'])
->getMock();
$this->account1->expects($this->any())
->method('id')
@@ -89,10 +89,10 @@ class PermissionsHashGeneratorTest extends UnitTestCase {
->method('getRoles');
// Account 2: 'administrator' and 'authenticated' roles.
- $roles_1 = array('administrator', 'authenticated');
+ $roles_1 = ['administrator', 'authenticated'];
$this->account2 = $this->getMockBuilder('Drupal\user\Entity\User')
->disableOriginalConstructor()
- ->setMethods(array('getRoles', 'id'))
+ ->setMethods(['getRoles', 'id'])
->getMock();
$this->account2->expects($this->any())
->method('getRoles')
@@ -102,10 +102,10 @@ class PermissionsHashGeneratorTest extends UnitTestCase {
->willReturn(2);
// Account 3: 'authenticated' and 'administrator' roles (different order).
- $roles_3 = array('authenticated', 'administrator');
+ $roles_3 = ['authenticated', 'administrator'];
$this->account3 = $this->getMockBuilder('Drupal\user\Entity\User')
->disableOriginalConstructor()
- ->setMethods(array('getRoles', 'id'))
+ ->setMethods(['getRoles', 'id'])
->getMock();
$this->account3->expects($this->any())
->method('getRoles')
@@ -115,10 +115,10 @@ class PermissionsHashGeneratorTest extends UnitTestCase {
->willReturn(3);
// Updated account 2: now also 'editor' role.
- $roles_2_updated = array('editor', 'administrator', 'authenticated');
+ $roles_2_updated = ['editor', 'administrator', 'authenticated'];
$this->account2Updated = $this->getMockBuilder('Drupal\user\Entity\User')
->disableOriginalConstructor()
- ->setMethods(array('getRoles', 'id'))
+ ->setMethods(['getRoles', 'id'])
->getMock();
$this->account2Updated->expects($this->any())
->method('getRoles')
@@ -131,7 +131,7 @@ class PermissionsHashGeneratorTest extends UnitTestCase {
$random = Crypt::randomBytesBase64(55);
$this->privateKey = $this->getMockBuilder('Drupal\Core\PrivateKey')
->disableOriginalConstructor()
- ->setMethods(array('get'))
+ ->setMethods(['get'])
->getMock();
$this->privateKey->expects($this->any())
->method('get')
@@ -251,9 +251,9 @@ namespace Drupal\Core\Session;
// @todo remove once user_role_permissions() can be injected.
if (!function_exists('user_role_permissions')) {
function user_role_permissions(array $roles) {
- $role_permissions = array();
+ $role_permissions = [];
foreach ($roles as $rid) {
- $role_permissions[$rid] = array();
+ $role_permissions[$rid] = [];
}
return $role_permissions;
}
diff --git a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php
index 52969e03eb3..85fe1bbf36d 100644
--- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php
@@ -18,7 +18,7 @@ class UserSessionTest extends UnitTestCase {
*
* @var \Drupal\Core\Session\AccountInterface[]
*/
- protected $users = array();
+ protected $users = [];
/**
* Provides test data for getHasPermission().
@@ -26,10 +26,10 @@ class UserSessionTest extends UnitTestCase {
* @return array
*/
public function providerTestHasPermission() {
- $data = array();
- $data[] = array('example permission', array('user_one', 'user_two'), array('user_last'));
- $data[] = array('another example permission', array('user_two'), array('user_one', 'user_last'));
- $data[] = array('final example permission', array(), array('user_one', 'user_two', 'user_last'));
+ $data = [];
+ $data[] = ['example permission', ['user_one', 'user_two'], ['user_last']];
+ $data[] = ['another example permission', ['user_two'], ['user_one', 'user_last']];
+ $data[] = ['final example permission', [], ['user_one', 'user_two', 'user_last']];
return $data;
}
@@ -45,9 +45,9 @@ class UserSessionTest extends UnitTestCase {
* @return \Drupal\Core\Session\AccountInterface
* The created user session.
*/
- protected function createUserSession(array $rids = array(), $authenticated = FALSE) {
+ protected function createUserSession(array $rids = [], $authenticated = FALSE) {
array_unshift($rids, $authenticated ? RoleInterface::AUTHENTICATED_ID : RoleInterface::ANONYMOUS_ID);
- return new UserSession(array('roles' => $rids));
+ return new UserSession(['roles' => $rids]);
}
/**
@@ -56,57 +56,57 @@ class UserSessionTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- $roles = array();
+ $roles = [];
$roles['role_one'] = $this->getMockBuilder('Drupal\user\Entity\Role')
->disableOriginalConstructor()
- ->setMethods(array('hasPermission'))
+ ->setMethods(['hasPermission'])
->getMock();
$roles['role_one']->expects($this->any())
->method('hasPermission')
- ->will($this->returnValueMap(array(
- array('example permission', TRUE),
- array('another example permission', FALSE),
- array('last example permission', FALSE),
- )));
+ ->will($this->returnValueMap([
+ ['example permission', TRUE],
+ ['another example permission', FALSE],
+ ['last example permission', FALSE],
+ ]));
$roles['role_two'] = $this->getMockBuilder('Drupal\user\Entity\Role')
->disableOriginalConstructor()
- ->setMethods(array('hasPermission'))
+ ->setMethods(['hasPermission'])
->getMock();
$roles['role_two']->expects($this->any())
->method('hasPermission')
- ->will($this->returnValueMap(array(
- array('example permission', TRUE),
- array('another example permission', TRUE),
- array('last example permission', FALSE),
- )));
+ ->will($this->returnValueMap([
+ ['example permission', TRUE],
+ ['another example permission', TRUE],
+ ['last example permission', FALSE],
+ ]));
$roles['anonymous'] = $this->getMockBuilder('Drupal\user\Entity\Role')
->disableOriginalConstructor()
- ->setMethods(array('hasPermission'))
+ ->setMethods(['hasPermission'])
->getMock();
$roles['anonymous']->expects($this->any())
->method('hasPermission')
- ->will($this->returnValueMap(array(
- array('example permission', FALSE),
- array('another example permission', FALSE),
- array('last example permission', FALSE),
- )));
+ ->will($this->returnValueMap([
+ ['example permission', FALSE],
+ ['another example permission', FALSE],
+ ['last example permission', FALSE],
+ ]));
$role_storage = $this->getMockBuilder('Drupal\user\RoleStorage')
->disableOriginalConstructor()
- ->setMethods(array('loadMultiple'))
+ ->setMethods(['loadMultiple'])
->getMock();
$role_storage->expects($this->any())
->method('loadMultiple')
- ->will($this->returnValueMap(array(
- array(array(), array()),
- array(NULL, $roles),
- array(array('anonymous'), array($roles['anonymous'])),
- array(array('anonymous', 'role_one'), array($roles['role_one'])),
- array(array('anonymous', 'role_two'), array($roles['role_two'])),
- array(array('anonymous', 'role_one', 'role_two'), array($roles['role_one'], $roles['role_two'])),
- )));
+ ->will($this->returnValueMap([
+ [[], []],
+ [NULL, $roles],
+ [['anonymous'], [$roles['anonymous']]],
+ [['anonymous', 'role_one'], [$roles['role_one']]],
+ [['anonymous', 'role_two'], [$roles['role_two']]],
+ [['anonymous', 'role_one', 'role_two'], [$roles['role_one'], $roles['role_two']]],
+ ]));
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$entity_manager->expects($this->any())
@@ -117,9 +117,9 @@ class UserSessionTest extends UnitTestCase {
$container->set('entity.manager', $entity_manager);
\Drupal::setContainer($container);
- $this->users['user_one'] = $this->createUserSession(array('role_one'));
- $this->users['user_two'] = $this->createUserSession(array('role_one', 'role_two'));
- $this->users['user_three'] = $this->createUserSession(array('role_two'), TRUE);
+ $this->users['user_one'] = $this->createUserSession(['role_one']);
+ $this->users['user_two'] = $this->createUserSession(['role_one', 'role_two']);
+ $this->users['user_three'] = $this->createUserSession(['role_two'], TRUE);
$this->users['user_last'] = $this->createUserSession();
}
@@ -153,8 +153,8 @@ class UserSessionTest extends UnitTestCase {
* @todo Move roles constants to a class/interface
*/
public function testUserGetRoles() {
- $this->assertEquals(array(RoleInterface::AUTHENTICATED_ID, 'role_two'), $this->users['user_three']->getRoles());
- $this->assertEquals(array('role_two'), $this->users['user_three']->getRoles(TRUE));
+ $this->assertEquals([RoleInterface::AUTHENTICATED_ID, 'role_two'], $this->users['user_three']->getRoles());
+ $this->assertEquals(['role_two'], $this->users['user_three']->getRoles(TRUE));
}
}
diff --git a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php
index 3b6eb65b71b..bdfb7101a36 100644
--- a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php
+++ b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php
@@ -16,7 +16,7 @@ class SettingsTest extends UnitTestCase {
*
* @var array
*/
- protected $config = array();
+ protected $config = [];
/**
* The class under test.
@@ -29,11 +29,11 @@ class SettingsTest extends UnitTestCase {
* @covers ::__construct
*/
protected function setUp(){
- $this->config = array(
+ $this->config = [
'one' => '1',
'two' => '2',
'hash_salt' => $this->randomMachineName(),
- );
+ ];
$this->settings = new Settings($this->config);
}
@@ -95,11 +95,11 @@ class SettingsTest extends UnitTestCase {
* @return array
*/
public function providerTestGetHashSaltEmpty() {
- return array(
- array(array()),
- array(array('hash_salt' => '')),
- array(array('hash_salt' => NULL)),
- );
+ return [
+ [[]],
+ [['hash_salt' => '']],
+ [['hash_salt' => NULL]],
+ ];
}
/**
@@ -119,10 +119,10 @@ class SettingsTest extends UnitTestCase {
* @covers ::getApcuPrefix
*/
public function testGetApcuPrefix() {
- $settings = new Settings(array('hash_salt' => 123));
+ $settings = new Settings(['hash_salt' => 123]);
$this->assertNotEquals($settings::getApcuPrefix('cache_test', '/test/a'), $settings::getApcuPrefix('cache_test', '/test/b'));
- $settings = new Settings(array('hash_salt' => 123, 'apcu_ensure_unique_prefix' => FALSE));
+ $settings = new Settings(['hash_salt' => 123, 'apcu_ensure_unique_prefix' => FALSE]);
$this->assertNotEquals($settings::getApcuPrefix('cache_test', '/test/a'), $settings::getApcuPrefix('cache_test', '/test/b'));
}
@@ -132,7 +132,7 @@ class SettingsTest extends UnitTestCase {
* @covers ::getInstance
*/
public function testGetInstanceReflection() {
- $settings = new Settings(array());
+ $settings = new Settings([]);
$class = new \ReflectionClass(Settings::class);
$instace_property = $class->getProperty("instance");
diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
index 585c4b975b7..b7a784d4871 100644
--- a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
+++ b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
@@ -30,12 +30,12 @@ class ReverseProxyMiddlewareTest extends UnitTestCase {
* Tests that subscriber does not act when reverse proxy is not set.
*/
public function testNoProxy() {
- $settings = new Settings(array());
+ $settings = new Settings([]);
$this->assertEquals(0, $settings->get('reverse_proxy'));
$middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $settings);
// Mock a request object.
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array('setTrustedHeaderName', 'setTrustedProxies'));
+ $request = $this->getMock('Symfony\Component\HttpFoundation\Request', ['setTrustedHeaderName', 'setTrustedProxies']);
// setTrustedHeaderName() should never fire.
$request->expects($this->never())
->method('setTrustedHeaderName');
@@ -50,7 +50,7 @@ class ReverseProxyMiddlewareTest extends UnitTestCase {
*/
public function testReverseProxyEnabled($provided_settings) {
// Enable reverse proxy and add test values.
- $settings = new Settings(array('reverse_proxy' => 1) + $provided_settings);
+ $settings = new Settings(['reverse_proxy' => 1] + $provided_settings);
$this->trustedHeadersAreSet($settings);
}
@@ -58,18 +58,18 @@ class ReverseProxyMiddlewareTest extends UnitTestCase {
* Data provider for testReverseProxyEnabled.
*/
public function reverseProxyEnabledProvider() {
- return array(
- array(
- array(
+ return [
+ [
+ [
'reverse_proxy_header' => 'X_FORWARDED_FOR_CUSTOMIZED',
'reverse_proxy_proto_header' => 'X_FORWARDED_PROTO_CUSTOMIZED',
'reverse_proxy_host_header' => 'X_FORWARDED_HOST_CUSTOMIZED',
'reverse_proxy_port_header' => 'X_FORWARDED_PORT_CUSTOMIZED',
'reverse_proxy_forwarded_header' => 'FORWARDED_CUSTOMIZED',
- 'reverse_proxy_addresses' => array('127.0.0.2', '127.0.0.3'),
- ),
- ),
- );
+ 'reverse_proxy_addresses' => ['127.0.0.2', '127.0.0.3'],
+ ],
+ ],
+ ];
}
/**
diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php
index 8ab6874e724..2cd750bf10a 100644
--- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php
@@ -36,21 +36,21 @@ class TranslationManagerTest extends UnitTestCase {
* @return array
*/
public function providerTestFormatPlural() {
- return array(
- [1, 'Singular', '@count plural', array(), array(), 'Singular'],
- [2, 'Singular', '@count plural', array(), array(), '2 plural'],
+ return [
+ [1, 'Singular', '@count plural', [], [], 'Singular'],
+ [2, 'Singular', '@count plural', [], [], '2 plural'],
// @todo support locale_get_plural
- [2, 'Singular', '@count @arg', array('@arg' => '<script>'), array(), '2 &lt;script&gt;'],
- [2, 'Singular', '@count %arg', array('%arg' => '<script>'), array(), '2 <em class="placeholder">&lt;script&gt;</em>'],
- [1, 'Singular', '@count plural', array(), array('langcode' => NULL), 'Singular'],
- [1, 'Singular', '@count plural', array(), array('langcode' => 'es'), 'Singular'],
- );
+ [2, 'Singular', '@count @arg', ['@arg' => '<script>'], [], '2 &lt;script&gt;'],
+ [2, 'Singular', '@count %arg', ['%arg' => '<script>'], [], '2 <em class="placeholder">&lt;script&gt;</em>'],
+ [1, 'Singular', '@count plural', [], ['langcode' => NULL], 'Singular'],
+ [1, 'Singular', '@count plural', [], ['langcode' => 'es'], 'Singular'],
+ ];
}
/**
* @dataProvider providerTestFormatPlural
*/
- public function testFormatPlural($count, $singular, $plural, array $args = array(), array $options = array(), $expected) {
+ public function testFormatPlural($count, $singular, $plural, array $args = [], array $options = [], $expected) {
$langcode = empty($options['langcode']) ? 'fr' : $options['langcode'];
$translator = $this->getMock('\Drupal\Core\StringTranslation\Translator\TranslatorInterface');
$translator->expects($this->once())
@@ -78,7 +78,7 @@ class TranslationManagerTest extends UnitTestCase {
*
* @dataProvider providerTestTranslatePlaceholder
*/
- public function testTranslatePlaceholder($string, array $args = array(), $expected_string) {
+ public function testTranslatePlaceholder($string, array $args = [], $expected_string) {
$actual = $this->translationManager->translate($string, $args);
$this->assertInstanceOf(MarkupInterface::class, $actual);
$this->assertEquals($expected_string, (string) $actual);
diff --git a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
index 09ec9894dcc..b9dc671faa6 100644
--- a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
@@ -20,9 +20,9 @@ class AttributeTest extends UnitTestCase {
* Tests the constructor of the attribute class.
*/
public function testConstructor() {
- $attribute = new Attribute(array('class' => array('example-class')));
+ $attribute = new Attribute(['class' => ['example-class']]);
$this->assertTrue(isset($attribute['class']));
- $this->assertEquals(new AttributeArray('class', array('example-class')), $attribute['class']);
+ $this->assertEquals(new AttributeArray('class', ['example-class']), $attribute['class']);
// Test adding boolean attributes through the constructor.
$attribute = new Attribute(['selected' => TRUE, 'checked' => FALSE]);
@@ -30,16 +30,16 @@ class AttributeTest extends UnitTestCase {
$this->assertFalse($attribute['checked']->value());
// Test that non-array values with name "class" are cast to array.
- $attribute = new Attribute(array('class' => 'example-class'));
+ $attribute = new Attribute(['class' => 'example-class']);
$this->assertTrue(isset($attribute['class']));
- $this->assertEquals(new AttributeArray('class', array('example-class')), $attribute['class']);
+ $this->assertEquals(new AttributeArray('class', ['example-class']), $attribute['class']);
// Test that safe string objects work correctly.
$safe_string = $this->prophesize(MarkupInterface::class);
$safe_string->__toString()->willReturn('example-class');
- $attribute = new Attribute(array('class' => $safe_string->reveal()));
+ $attribute = new Attribute(['class' => $safe_string->reveal()]);
$this->assertTrue(isset($attribute['class']));
- $this->assertEquals(new AttributeArray('class', array('example-class')), $attribute['class']);
+ $this->assertEquals(new AttributeArray('class', ['example-class']), $attribute['class']);
}
/**
@@ -47,27 +47,27 @@ class AttributeTest extends UnitTestCase {
*/
public function testSet() {
$attribute = new Attribute();
- $attribute['class'] = array('example-class');
+ $attribute['class'] = ['example-class'];
$this->assertTrue(isset($attribute['class']));
- $this->assertEquals(new AttributeArray('class', array('example-class')), $attribute['class']);
+ $this->assertEquals(new AttributeArray('class', ['example-class']), $attribute['class']);
}
/**
* Tests adding new values to an existing part of the attribute.
*/
public function testAdd() {
- $attribute = new Attribute(array('class' => array('example-class')));
+ $attribute = new Attribute(['class' => ['example-class']]);
$attribute['class'][] = 'other-class';
- $this->assertEquals(new AttributeArray('class', array('example-class', 'other-class')), $attribute['class']);
+ $this->assertEquals(new AttributeArray('class', ['example-class', 'other-class']), $attribute['class']);
}
/**
* Tests removing of values.
*/
public function testRemove() {
- $attribute = new Attribute(array('class' => array('example-class')));
+ $attribute = new Attribute(['class' => ['example-class']]);
unset($attribute['class']);
$this->assertFalse(isset($attribute['class']));
}
@@ -152,7 +152,7 @@ class AttributeTest extends UnitTestCase {
$this->assertEmpty($attribute['class']);
// Test various permutations of adding values to empty Attribute objects.
- foreach (array(NULL, FALSE, '', []) as $value) {
+ foreach ([NULL, FALSE, '', []] as $value) {
// Single value.
$attribute->addClass($value);
$this->assertEmpty((string) $attribute);
@@ -172,22 +172,22 @@ class AttributeTest extends UnitTestCase {
// Add one class on empty attribute.
$attribute->addClass('banana');
- $this->assertArrayEquals(array('banana'), $attribute['class']->value());
+ $this->assertArrayEquals(['banana'], $attribute['class']->value());
// Add one class.
$attribute->addClass('aa');
- $this->assertArrayEquals(array('banana', 'aa'), $attribute['class']->value());
+ $this->assertArrayEquals(['banana', 'aa'], $attribute['class']->value());
// Add multiple classes.
$attribute->addClass('xx', 'yy');
- $this->assertArrayEquals(array('banana', 'aa', 'xx', 'yy'), $attribute['class']->value());
+ $this->assertArrayEquals(['banana', 'aa', 'xx', 'yy'], $attribute['class']->value());
// Add an array of classes.
- $attribute->addClass(array('red', 'green', 'blue'));
- $this->assertArrayEquals(array('banana', 'aa', 'xx', 'yy', 'red', 'green', 'blue'), $attribute['class']->value());
+ $attribute->addClass(['red', 'green', 'blue']);
+ $this->assertArrayEquals(['banana', 'aa', 'xx', 'yy', 'red', 'green', 'blue'], $attribute['class']->value());
// Add an array of duplicate classes.
- $attribute->addClass(array('red', 'green', 'blue'), array('aa', 'aa', 'banana'), 'yy');
+ $attribute->addClass(['red', 'green', 'blue'], ['aa', 'aa', 'banana'], 'yy');
$this->assertEquals('banana aa xx yy red green blue', (string) $attribute['class']);
}
@@ -197,8 +197,8 @@ class AttributeTest extends UnitTestCase {
*/
public function testRemoveClasses() {
// Add duplicate class to ensure that both duplicates are removed.
- $classes = array('example-class', 'aa', 'xx', 'yy', 'red', 'green', 'blue', 'red');
- $attribute = new Attribute(array('class' => $classes));
+ $classes = ['example-class', 'aa', 'xx', 'yy', 'red', 'green', 'blue', 'red'];
+ $attribute = new Attribute(['class' => $classes]);
// Remove one class.
$attribute->removeClass('example-class');
@@ -206,17 +206,17 @@ class AttributeTest extends UnitTestCase {
// Remove multiple classes.
$attribute->removeClass('xx', 'yy');
- $this->assertNotContains(array('xx', 'yy'), $attribute['class']->value());
+ $this->assertNotContains(['xx', 'yy'], $attribute['class']->value());
// Remove an array of classes.
- $attribute->removeClass(array('red', 'green', 'blue'));
- $this->assertNotContains(array('red', 'green', 'blue'), $attribute['class']->value());
+ $attribute->removeClass(['red', 'green', 'blue']);
+ $this->assertNotContains(['red', 'green', 'blue'], $attribute['class']->value());
// Remove a class that does not exist.
$attribute->removeClass('gg');
- $this->assertNotContains(array('gg'), $attribute['class']->value());
+ $this->assertNotContains(['gg'], $attribute['class']->value());
// Test that the array index remains sequential.
- $this->assertArrayEquals(array('aa'), $attribute['class']->value());
+ $this->assertArrayEquals(['aa'], $attribute['class']->value());
$attribute->removeClass('aa');
$this->assertEmpty((string) $attribute);
@@ -244,14 +244,14 @@ class AttributeTest extends UnitTestCase {
*/
public function testChainAddRemoveClasses() {
$attribute = new Attribute(
- array('class' => array('example-class', 'red', 'green', 'blue'))
+ ['class' => ['example-class', 'red', 'green', 'blue']]
);
$attribute
- ->removeClass(array('red', 'green', 'pink'))
- ->addClass(array('apple', 'lime', 'grapefruit'))
- ->addClass(array('banana'));
- $expected = array('example-class', 'blue', 'apple', 'lime', 'grapefruit', 'banana');
+ ->removeClass(['red', 'green', 'pink'])
+ ->addClass(['apple', 'lime', 'grapefruit'])
+ ->addClass(['banana']);
+ $expected = ['example-class', 'blue', 'apple', 'lime', 'grapefruit', 'banana'];
$this->assertArrayEquals($expected, $attribute['class']->value(), 'Attributes chained');
}
@@ -262,10 +262,10 @@ class AttributeTest extends UnitTestCase {
* @covers ::removeClass
* @covers ::addClass
*/
- public function testTwigAddRemoveClasses($template, $expected, $seed_attributes = array()) {
+ public function testTwigAddRemoveClasses($template, $expected, $seed_attributes = []) {
$loader = new \Twig_Loader_String();
$twig = new \Twig_Environment($loader);
- $data = array('attributes' => new Attribute($seed_attributes));
+ $data = ['attributes' => new Attribute($seed_attributes)];
$result = $twig->render($template, $data);
$this->assertEquals($expected, $result);
}
@@ -278,52 +278,52 @@ class AttributeTest extends UnitTestCase {
* a resulting string of classes and an optional array of attributes.
*/
public function providerTestAttributeClassHelpers() {
- return array(
- array("{{ attributes.class }}", ''),
- array("{{ attributes.addClass('everest').class }}", 'everest'),
- array("{{ attributes.addClass(['k2', 'kangchenjunga']).class }}", 'k2 kangchenjunga'),
- array("{{ attributes.addClass('lhotse', 'makalu', 'cho-oyu').class }}", 'lhotse makalu cho-oyu'),
- array(
+ return [
+ ["{{ attributes.class }}", ''],
+ ["{{ attributes.addClass('everest').class }}", 'everest'],
+ ["{{ attributes.addClass(['k2', 'kangchenjunga']).class }}", 'k2 kangchenjunga'],
+ ["{{ attributes.addClass('lhotse', 'makalu', 'cho-oyu').class }}", 'lhotse makalu cho-oyu'],
+ [
"{{ attributes.addClass('nanga-parbat').class }}",
'dhaulagiri manaslu nanga-parbat',
- array('class' => array('dhaulagiri', 'manaslu')),
- ),
- array(
+ ['class' => ['dhaulagiri', 'manaslu']],
+ ],
+ [
"{{ attributes.removeClass('annapurna').class }}",
'gasherbrum-i',
- array('class' => array('annapurna', 'gasherbrum-i')),
- ),
- array(
+ ['class' => ['annapurna', 'gasherbrum-i']],
+ ],
+ [
"{{ attributes.removeClass(['broad peak']).class }}",
'gasherbrum-ii',
- array('class' => array('broad peak', 'gasherbrum-ii')),
- ),
- array(
+ ['class' => ['broad peak', 'gasherbrum-ii']],
+ ],
+ [
"{{ attributes.removeClass('gyachung-kang', 'shishapangma').class }}",
'',
- array('class' => array('shishapangma', 'gyachung-kang')),
- ),
- array(
+ ['class' => ['shishapangma', 'gyachung-kang']],
+ ],
+ [
"{{ attributes.removeClass('nuptse').addClass('annapurna-ii').class }}",
'himalchuli annapurna-ii',
- array('class' => array('himalchuli', 'nuptse')),
- ),
+ ['class' => ['himalchuli', 'nuptse']],
+ ],
// Test for the removal of an empty class name.
- array("{{ attributes.addClass('rakaposhi', '').class }}", 'rakaposhi'),
- );
+ ["{{ attributes.addClass('rakaposhi', '').class }}", 'rakaposhi'],
+ ];
}
/**
* Tests iterating on the values of the attribute.
*/
public function testIterate() {
- $attribute = new Attribute(array('class' => array('example-class'), 'id' => 'example-id'));
+ $attribute = new Attribute(['class' => ['example-class'], 'id' => 'example-id']);
$counter = 0;
foreach ($attribute as $key => $value) {
if ($counter == 0) {
$this->assertEquals('class', $key);
- $this->assertEquals(new AttributeArray('class', array('example-class')), $value);
+ $this->assertEquals(new AttributeArray('class', ['example-class']), $value);
}
if ($counter == 1) {
$this->assertEquals('id', $key);
@@ -337,7 +337,7 @@ class AttributeTest extends UnitTestCase {
* Tests printing of an attribute.
*/
public function testPrint() {
- $attribute = new Attribute(array('class' => array('example-class'), 'id' => 'example-id', 'enabled' => TRUE));
+ $attribute = new Attribute(['class' => ['example-class'], 'id' => 'example-id', 'enabled' => TRUE]);
$content = $this->randomMachineName();
$html = '<div' . (string) $attribute . '>' . $content . '</div>';
@@ -446,9 +446,9 @@ class AttributeTest extends UnitTestCase {
* Tests the storage method.
*/
public function testStorage() {
- $attribute = new Attribute(array('class' => array('example-class')));
+ $attribute = new Attribute(['class' => ['example-class']]);
- $this->assertEquals(array('class' => new AttributeArray('class', array('example-class'))), $attribute->storage());
+ $this->assertEquals(['class' => new AttributeArray('class', ['example-class'])], $attribute->storage());
}
}
diff --git a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
index fe9f6e63cd1..c4805bc3821 100644
--- a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
@@ -75,12 +75,12 @@ class TwigExtensionTest extends UnitTestCase {
* @dataProvider providerTestEscaping
*/
public function testEscaping($template, $expected) {
- $twig = new \Twig_Environment(NULL, array(
+ $twig = new \Twig_Environment(NULL, [
'debug' => TRUE,
'cache' => FALSE,
'autoescape' => 'html',
'optimizations' => 0,
- ));
+ ]);
$twig->addExtension($this->systemUnderTest);
$nodes = $twig->parse($twig->tokenize($template));
@@ -98,27 +98,27 @@ class TwigExtensionTest extends UnitTestCase {
* a boolean expecting whether the path will be safe.
*/
public function providerTestEscaping() {
- return array(
- array('{{ path("foo") }}', FALSE),
- array('{{ path("foo", {}) }}', FALSE),
- array('{{ path("foo", { foo: "foo" }) }}', FALSE),
- array('{{ path("foo", foo) }}', TRUE),
- array('{{ path("foo", { foo: foo }) }}', TRUE),
- array('{{ path("foo", { foo: ["foo", "bar"] }) }}', TRUE),
- array('{{ path("foo", { foo: "foo", bar: "bar" }) }}', TRUE),
- array('{{ path(name = "foo", parameters = {}) }}', FALSE),
- array('{{ path(name = "foo", parameters = { foo: "foo" }) }}', FALSE),
- array('{{ path(name = "foo", parameters = foo) }}', TRUE),
- array(
+ return [
+ ['{{ path("foo") }}', FALSE],
+ ['{{ path("foo", {}) }}', FALSE],
+ ['{{ path("foo", { foo: "foo" }) }}', FALSE],
+ ['{{ path("foo", foo) }}', TRUE],
+ ['{{ path("foo", { foo: foo }) }}', TRUE],
+ ['{{ path("foo", { foo: ["foo", "bar"] }) }}', TRUE],
+ ['{{ path("foo", { foo: "foo", bar: "bar" }) }}', TRUE],
+ ['{{ path(name = "foo", parameters = {}) }}', FALSE],
+ ['{{ path(name = "foo", parameters = { foo: "foo" }) }}', FALSE],
+ ['{{ path(name = "foo", parameters = foo) }}', TRUE],
+ [
'{{ path(name = "foo", parameters = { foo: ["foo", "bar"] }) }}',
TRUE
- ),
- array('{{ path(name = "foo", parameters = { foo: foo }) }}', TRUE),
- array(
+ ],
+ ['{{ path(name = "foo", parameters = { foo: foo }) }}', TRUE],
+ [
'{{ path(name = "foo", parameters = { foo: "foo", bar: "bar" }) }}',
TRUE
- ),
- );
+ ],
+ ];
}
/**
@@ -185,12 +185,12 @@ class TwigExtensionTest extends UnitTestCase {
* @covers ::escapeFilter
*/
public function testSafeStringEscaping() {
- $twig = new \Twig_Environment(NULL, array(
+ $twig = new \Twig_Environment(NULL, [
'debug' => TRUE,
'cache' => FALSE,
'autoescape' => 'html',
'optimizations' => 0,
- ));
+ ]);
// By default, TwigExtension will attempt to cast objects to strings.
// Ensure objects that implement MarkupInterface are unchanged.
diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
index 8be62d88dc6..f2cd22ea90b 100644
--- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
@@ -137,7 +137,7 @@ class RegistryTest extends UnitTestCase {
$this->moduleHandler->expects($this->exactly(2))
->method('getImplementations')
->with('theme')
- ->will($this->returnValue(array('theme_test')));
+ ->will($this->returnValue(['theme_test']));
$this->moduleHandler->expects($this->atLeastOnce())
->method('getModuleList')
->willReturn([]);
@@ -164,7 +164,7 @@ class RegistryTest extends UnitTestCase {
$this->assertEquals('module', $info['type']);
$this->assertEquals('core/modules/system/tests/modules/theme_test', $info['theme path']);
$this->assertEquals('theme_theme_test_function_suggestions', $info['function']);
- $this->assertEquals(array(), $info['variables']);
+ $this->assertEquals([], $info['variables']);
// The second call will initialize with the second theme. Ensure that this
// returns a different object and the discovery for the second theme's
diff --git a/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php b/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php
index 958a5454d5f..4b33fcbfcd2 100644
--- a/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php
@@ -61,7 +61,7 @@ class ThemeNegotiatorTest extends UnitTestCase {
->method('checkAccess')
->will($this->returnValue(TRUE));
- $route_match = new RouteMatch('test_route', new Route('/test-route'), array(), array());
+ $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
$theme = $this->themeNegotiator->determineActiveTheme($route_match);
$this->assertEquals('example_test', $theme);
@@ -95,7 +95,7 @@ class ThemeNegotiatorTest extends UnitTestCase {
->method('checkAccess')
->will($this->returnValue(TRUE));
- $route_match = new RouteMatch('test_route', new Route('/test-route'), array(), array());
+ $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
$theme = $this->themeNegotiator->determineActiveTheme($route_match);
$this->assertEquals('example_test', $theme);
@@ -137,7 +137,7 @@ class ThemeNegotiatorTest extends UnitTestCase {
->with('example_test2')
->will($this->returnValue(TRUE));
- $route_match = new RouteMatch('test_route', new Route('/test-route'), array(), array());
+ $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
$theme = $this->themeNegotiator->determineActiveTheme($route_match);
$this->assertEquals('example_test2', $theme);
@@ -172,7 +172,7 @@ class ThemeNegotiatorTest extends UnitTestCase {
->method('checkAccess')
->will($this->returnValue(TRUE));
- $route_match = new RouteMatch('test_route', new Route('/test-route'), array(), array());
+ $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
$theme = $this->themeNegotiator->determineActiveTheme($route_match);
$this->assertEquals('example_test2', $theme);
diff --git a/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php b/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php
index 0a3388f1e4a..ac19ffadf9a 100644
--- a/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php
+++ b/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php
@@ -74,13 +74,13 @@ class PhpTransliterationTest extends UnitTestCase {
// Five-byte characters do not work in MySQL, so make a printable version.
$five_byte_printable = '&#x10330;&#x10338;';
- $cases = array(
+ $cases = [
// Test the language override hook in the test module, which changes
// the transliteration of Ä to Z and provides for the 5-byte characters.
- array('zz', $two_byte, 'Z O U A O aouaohello'),
- array('zz', $random, $random),
- array('zz', $five_byte, 'ATh', $five_byte_printable),
- );
+ ['zz', $two_byte, 'Z O U A O aouaohello'],
+ ['zz', $random, $random],
+ ['zz', $five_byte, 'ATh', $five_byte_printable],
+ ];
return $cases;
}
diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php
index 2c157d5bdfe..64212b020c0 100644
--- a/core/tests/Drupal/Tests/Core/UrlTest.php
+++ b/core/tests/Drupal/Tests/Core/UrlTest.php
@@ -73,21 +73,21 @@ class UrlTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
- $map = array();
- $map[] = array('view.frontpage.page_1', array(), array(), FALSE, '/node');
- $map[] = array('node_view', array('node' => '1'), array(), FALSE, '/node/1');
- $map[] = array('node_edit', array('node' => '2'), array(), FALSE, '/node/2/edit');
+ $map = [];
+ $map[] = ['view.frontpage.page_1', [], [], FALSE, '/node'];
+ $map[] = ['node_view', ['node' => '1'], [], FALSE, '/node/1'];
+ $map[] = ['node_edit', ['node' => '2'], [], FALSE, '/node/2/edit'];
$this->map = $map;
- $alias_map = array(
+ $alias_map = [
// Set up one proper alias that can be resolved to a system path.
- array('node-alias-test', NULL, FALSE, 'node'),
+ ['node-alias-test', NULL, FALSE, 'node'],
// Passing in anything else should return the same string.
- array('node', NULL, FALSE, 'node'),
- array('node/1', NULL, FALSE, 'node/1'),
- array('node/2/edit', NULL, FALSE, 'node/2/edit'),
- array('non-existent', NULL, FALSE, 'non-existent'),
- );
+ ['node', NULL, FALSE, 'node'],
+ ['node/1', NULL, FALSE, 'node/1'],
+ ['node/2/edit', NULL, FALSE, 'node/2/edit'],
+ ['non-existent', NULL, FALSE, 'non-existent'],
+ ];
// $this->map has $collect_bubbleable_metadata = FALSE; also generate the
// $collect_bubbleable_metadata = TRUE case for ::generateFromRoute().
@@ -143,7 +143,7 @@ class UrlTest extends UnitTestCase {
'_raw_variables' => new ParameterBag(['node' => '2']),
]);
- $urls = array();
+ $urls = [];
foreach ($this->map as $index => $values) {
$path = array_pop($values);
$url = Url::createFromRequest(Request::create("$path"));
@@ -258,13 +258,13 @@ class UrlTest extends UnitTestCase {
* @covers ::createFromRequest
*/
public function testCreateFromRequest() {
- $attributes = array(
- '_raw_variables' => new ParameterBag(array(
+ $attributes = [
+ '_raw_variables' => new ParameterBag([
'color' => 'chartreuse',
- )),
+ ]),
RouteObjectInterface::ROUTE_NAME => 'the_route_name',
- );
- $request = new Request(array(), array(), $attributes);
+ ];
+ $request = new Request([], [], $attributes);
$this->router->expects($this->once())
->method('matchRequest')
@@ -272,7 +272,7 @@ class UrlTest extends UnitTestCase {
->will($this->returnValue($attributes));
$url = Url::createFromRequest($request);
- $expected = new Url('the_route_name', array('color' => 'chartreuse'));
+ $expected = new Url('the_route_name', ['color' => 'chartreuse']);
$this->assertEquals($expected, $url);
}
@@ -533,9 +533,9 @@ class UrlTest extends UnitTestCase {
* @dataProvider accessProvider
*/
public function testRenderAccess($access) {
- $element = array(
+ $element = [
'#url' => Url::fromRoute('entity.node.canonical', ['node' => 3]),
- );
+ ];
$this->container->set('current_user', $this->getMock('Drupal\Core\Session\AccountInterface'));
$this->container->set('access_manager', $this->getMockAccessManager($access));
$this->assertEquals($access, TestUrl::renderAccess($element));
@@ -853,10 +853,10 @@ class UrlTest extends UnitTestCase {
* Data provider for the access test methods.
*/
public function accessProvider() {
- return array(
- array(TRUE),
- array(FALSE),
- );
+ return [
+ [TRUE],
+ [FALSE],
+ ];
}
}
diff --git a/core/tests/Drupal/Tests/Core/Utility/ErrorTest.php b/core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
index 6c0960011f7..e89f21d103f 100644
--- a/core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
@@ -32,29 +32,29 @@ class ErrorTest extends UnitTestCase {
* An array of parameter data.
*/
public function providerTestGetLastCaller() {
- $data = array();
+ $data = [];
// Test with just one item. This should default to the function being
// main().
- $single_item = array($this->createBacktraceItem());
- $data[] = array($single_item, $this->createBacktraceItem('main()'));
+ $single_item = [$this->createBacktraceItem()];
+ $data[] = [$single_item, $this->createBacktraceItem('main()')];
// Add a second item, without a class.
$two_items = $single_item;
$two_items[] = $this->createBacktraceItem('test_function_two');
- $data[] = array($two_items, $this->createBacktraceItem('test_function_two()'));
+ $data[] = [$two_items, $this->createBacktraceItem('test_function_two()')];
// Add a second item, with a class.
$two_items = $single_item;
$two_items[] = $this->createBacktraceItem('test_function_two', 'TestClass');
- $data[] = array($two_items, $this->createBacktraceItem('TestClass->test_function_two()'));
+ $data[] = [$two_items, $this->createBacktraceItem('TestClass->test_function_two()')];
// Add blacklist functions to backtrace. They should get removed.
- foreach (array('debug', '_drupal_error_handler', '_drupal_exception_handler') as $function) {
+ foreach (['debug', '_drupal_error_handler', '_drupal_exception_handler'] as $function) {
$two_items = $single_item;
// Push to the start of the backtrace.
array_unshift($two_items, $this->createBacktraceItem($function));
- $data[] = array($single_item, $this->createBacktraceItem('main()'));
+ $data[] = [$single_item, $this->createBacktraceItem('main()')];
}
return $data;
@@ -80,31 +80,31 @@ class ErrorTest extends UnitTestCase {
* @return array
*/
public function providerTestFormatBacktrace() {
- $data = array();
+ $data = [];
// Test with no function, main should be in the backtrace.
- $data[] = array(array($this->createBacktraceItem(NULL, NULL)), "main() (Line: 10)\n");
+ $data[] = [[$this->createBacktraceItem(NULL, NULL)], "main() (Line: 10)\n"];
- $base = array($this->createBacktraceItem());
- $data[] = array($base, "test_function() (Line: 10)\n");
+ $base = [$this->createBacktraceItem()];
+ $data[] = [$base, "test_function() (Line: 10)\n"];
// Add a second item.
$second_item = $base;
$second_item[] = $this->createBacktraceItem('test_function_2');
- $data[] = array($second_item, "test_function() (Line: 10)\ntest_function_2() (Line: 10)\n");
+ $data[] = [$second_item, "test_function() (Line: 10)\ntest_function_2() (Line: 10)\n"];
// Add a second item, with a class.
$second_item_class = $base;
$second_item_class[] = $this->createBacktraceItem('test_function_2', 'TestClass');
- $data[] = array($second_item_class, "test_function() (Line: 10)\nTestClass->test_function_2() (Line: 10)\n");
+ $data[] = [$second_item_class, "test_function() (Line: 10)\nTestClass->test_function_2() (Line: 10)\n"];
// Add a second item, with a class.
$second_item_args = $base;
- $second_item_args[] = $this->createBacktraceItem('test_function_2', NULL, array('string', 10, new \stdClass()));
+ $second_item_args[] = $this->createBacktraceItem('test_function_2', NULL, ['string', 10, new \stdClass()]);
- $data[] = array($second_item_args, "test_function() (Line: 10)\ntest_function_2('string', 10, Object) (Line: 10)\n");
+ $data[] = [$second_item_args, "test_function() (Line: 10)\ntest_function_2('string', 10, Object) (Line: 10)\n"];
return $data;
}
@@ -124,13 +124,13 @@ class ErrorTest extends UnitTestCase {
* @return array
* A backtrace array item.
*/
- protected function createBacktraceItem($function = 'test_function', $class = NULL, array $args = array(), $line = 10) {
- $backtrace = array(
+ protected function createBacktraceItem($function = 'test_function', $class = NULL, array $args = [], $line = 10) {
+ $backtrace = [
'file' => 'test_file',
'line' => $line,
'function' => $function,
- 'args' => array(),
- );
+ 'args' => [],
+ ];
if (isset($class)) {
$backtrace['class'] = $class;
diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
index c3af2db09dd..50795b31ff6 100644
--- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
@@ -57,12 +57,12 @@ class LinkGeneratorTest extends UnitTestCase {
/**
* Contains the LinkGenerator default options.
*/
- protected $defaultOptions = array(
- 'query' => array(),
+ protected $defaultOptions = [
+ 'query' => [],
'language' => NULL,
'set_active_class' => FALSE,
'absolute' => FALSE,
- );
+ ];
/**
* {@inheritdoc}
@@ -88,14 +88,14 @@ class LinkGeneratorTest extends UnitTestCase {
* Returns some test data.
*/
public function providerTestGenerateHrefs() {
- return array(
+ return [
// Test that the url returned by the URL generator is used.
- array('test_route_1', array(), FALSE, '/test-route-1'),
+ ['test_route_1', [], FALSE, '/test-route-1'],
// Test that $parameters is passed to the URL generator.
- array('test_route_2', array('value' => 'example'), FALSE, '/test-route-2/example'),
+ ['test_route_2', ['value' => 'example'], FALSE, '/test-route-2/example'],
// Test that the 'absolute' option is passed to the URL generator.
- array('test_route_3', array(), TRUE, 'http://example.com/test-route-3'),
- );
+ ['test_route_3', [], TRUE, 'http://example.com/test-route-3'],
+ ];
}
/**
@@ -109,17 +109,17 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateHrefs($route_name, array $parameters, $absolute, $expected_url) {
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->with($route_name, $parameters, array('absolute' => $absolute) + $this->defaultOptions)
+ ->with($route_name, $parameters, ['absolute' => $absolute] + $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl($expected_url));
$this->moduleHandler->expects($this->once())
->method('alter');
- $url = new Url($route_name, $parameters, array('absolute' => $absolute));
+ $url = new Url($route_name, $parameters, ['absolute' => $absolute]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array('href' => $expected_url),
- ), $result);
+ $this->assertLink([
+ 'attributes' => ['href' => $expected_url],
+ ], $result);
}
/**
@@ -130,23 +130,23 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerate() {
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->with('test_route_1', array(), array('fragment' => 'the-fragment') + $this->defaultOptions)
+ ->with('test_route_1', [], ['fragment' => 'the-fragment'] + $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1#the-fragment'));
$this->moduleHandler->expects($this->once())
->method('alter')
->with('link', $this->isType('array'));
- $url = new Url('test_route_1', array(), array('fragment' => 'the-fragment'));
+ $url = new Url('test_route_1', [], ['fragment' => 'the-fragment']);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => '/test-route-1#the-fragment',
- ),
+ ],
'content' => 'Test',
- ), $result);
+ ], $result);
}
/**
@@ -180,7 +180,7 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateExternal() {
$this->urlAssembler->expects($this->once())
->method('assemble')
- ->with('https://www.drupal.org', array('set_active_class' => TRUE, 'external' => TRUE) + $this->defaultOptions)
+ ->with('https://www.drupal.org', ['set_active_class' => TRUE, 'external' => TRUE] + $this->defaultOptions)
->will($this->returnArgument(0));
$this->moduleHandler->expects($this->once())
@@ -189,7 +189,7 @@ class LinkGeneratorTest extends UnitTestCase {
$this->urlAssembler->expects($this->once())
->method('assemble')
- ->with('https://www.drupal.org', array('set_active_class' => TRUE, 'external' => TRUE) + $this->defaultOptions)
+ ->with('https://www.drupal.org', ['set_active_class' => TRUE, 'external' => TRUE] + $this->defaultOptions)
->willReturnArgument(0);
$url = Url::fromUri('https://www.drupal.org');
@@ -198,12 +198,12 @@ class LinkGeneratorTest extends UnitTestCase {
$url->setOption('set_active_class', TRUE);
$result = $this->linkGenerator->generate('Drupal', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => 'https://www.drupal.org',
- ),
+ ],
'content' => 'Drupal',
- ), $result);
+ ], $result);
}
/**
@@ -214,7 +214,7 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateUrlWithQuotes() {
$this->urlAssembler->expects($this->once())
->method('assemble')
- ->with('base:example', array('query' => array('foo' => '"bar"', 'zoo' => 'baz')) + $this->defaultOptions)
+ ->with('base:example', ['query' => ['foo' => '"bar"', 'zoo' => 'baz']] + $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/example?foo=%22bar%22&zoo=baz'));
$path_validator = $this->getMock('Drupal\Core\Path\PathValidatorInterface');
@@ -229,12 +229,12 @@ class LinkGeneratorTest extends UnitTestCase {
$result = $this->linkGenerator->generate('Drupal', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => '/example?foo=%22bar%22&zoo=baz',
- ),
+ ],
'content' => 'Drupal',
- ), $result, 1);
+ ], $result, 1);
}
/**
@@ -245,21 +245,21 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateAttributes() {
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->with('test_route_1', array(), $this->defaultOptions)
+ ->with('test_route_1', [], $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1'));
// Test that HTML attributes are added to the anchor.
- $url = new Url('test_route_1', array(), array(
- 'attributes' => array('title' => 'Tooltip'),
- ));
+ $url = new Url('test_route_1', [], [
+ 'attributes' => ['title' => 'Tooltip'],
+ ]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => '/test-route-1',
'title' => 'Tooltip',
- ),
- ), $result);
+ ],
+ ], $result);
}
/**
@@ -270,19 +270,19 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateQuery() {
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->with('test_route_1', array(), array('query' => array('test' => 'value')) + $this->defaultOptions)
+ ->with('test_route_1', [], ['query' => ['test' => 'value']] + $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1?test=value'));
- $url = new Url('test_route_1', array(), array(
- 'query' => array('test' => 'value'),
- ));
+ $url = new Url('test_route_1', [], [
+ 'query' => ['test' => 'value'],
+ ]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => '/test-route-1?test=value',
- ),
- ), $result);
+ ],
+ ], $result);
}
/**
@@ -293,17 +293,17 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateParametersAsQuery() {
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->with('test_route_1', array('test' => 'value'), $this->defaultOptions)
+ ->with('test_route_1', ['test' => 'value'], $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1?test=value'));
- $url = new Url('test_route_1', array('test' => 'value'), array());
+ $url = new Url('test_route_1', ['test' => 'value'], []);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => '/test-route-1?test=value',
- ),
- ), $result);
+ ],
+ ], $result);
}
/**
@@ -314,18 +314,18 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateOptions() {
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->with('test_route_1', array(), array('key' => 'value') + $this->defaultOptions)
+ ->with('test_route_1', [], ['key' => 'value'] + $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1?test=value'));
- $url = new Url('test_route_1', array(), array(
+ $url = new Url('test_route_1', [], [
'key' => 'value',
- ));
+ ]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => '/test-route-1?test=value',
- ),
- ), $result);
+ ],
+ ], $result);
}
/**
@@ -336,7 +336,7 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateXss() {
$this->urlGenerator->expects($this->once())
->method('generateFromRoute')
- ->with('test_route_4', array(), $this->defaultOptions)
+ ->with('test_route_4', [], $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-4'));
// Test that HTML link text is escaped by default.
@@ -354,38 +354,38 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateWithHtml() {
$this->urlGenerator->expects($this->at(0))
->method('generateFromRoute')
- ->with('test_route_5', array(), $this->defaultOptions)
+ ->with('test_route_5', [], $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-5'));
$this->urlGenerator->expects($this->at(1))
->method('generateFromRoute')
- ->with('test_route_5', array(), $this->defaultOptions)
+ ->with('test_route_5', [], $this->defaultOptions)
->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-5'));
// Test that HTML tags are stripped from the 'title' attribute.
- $url = new Url('test_route_5', array(), array(
- 'attributes' => array('title' => '<em>HTML Tooltip</em>'),
- ));
+ $url = new Url('test_route_5', [], [
+ 'attributes' => ['title' => '<em>HTML Tooltip</em>'],
+ ]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'href' => '/test-route-5',
'title' => 'HTML Tooltip',
- ),
- ), $result);
+ ],
+ ], $result);
// Test that safe HTML is output inside the anchor tag unescaped. The
// Markup::create() call is an intentional unit test for the interaction
// between MarkupInterface and the LinkGenerator.
- $url = new Url('test_route_5', array());
+ $url = new Url('test_route_5', []);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate(Markup::create('<em>HTML output</em>'), $url);
- $this->assertLink(array(
- 'attributes' => array('href' => '/test-route-5'),
- 'child' => array(
+ $this->assertLink([
+ 'attributes' => ['href' => '/test-route-5'],
+ 'child' => [
'tag' => 'em',
- ),
- ), $result);
+ ],
+ ], $result);
$this->assertTrue(strpos($result, '<em>HTML output</em>') !== FALSE);
}
@@ -397,7 +397,7 @@ class LinkGeneratorTest extends UnitTestCase {
public function testGenerateActive() {
$this->urlGenerator->expects($this->exactly(5))
->method('generateFromRoute')
- ->willReturnCallback(function($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
+ ->willReturnCallback(function($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) {
switch ($name) {
case 'test_route_1':
return (new GeneratedUrl())->setGeneratedUrl('/test-route-1');
@@ -412,70 +412,70 @@ class LinkGeneratorTest extends UnitTestCase {
$this->urlGenerator->expects($this->exactly(4))
->method('getPathFromRoute')
- ->will($this->returnValueMap(array(
- array('test_route_1', array(), 'test-route-1'),
- array('test_route_3', array(), 'test-route-3'),
- array('test_route_4', array('object' => '1'), 'test-route-4/1'),
- )));
+ ->will($this->returnValueMap([
+ ['test_route_1', [], 'test-route-1'],
+ ['test_route_3', [], 'test-route-3'],
+ ['test_route_4', ['object' => '1'], 'test-route-4/1'],
+ ]));
$this->moduleHandler->expects($this->exactly(5))
->method('alter');
// Render a link.
- $url = new Url('test_route_1', array(), array('set_active_class' => TRUE));
+ $url = new Url('test_route_1', [], ['set_active_class' => TRUE]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array('data-drupal-link-system-path' => 'test-route-1'),
- ), $result);
+ $this->assertLink([
+ 'attributes' => ['data-drupal-link-system-path' => 'test-route-1'],
+ ], $result);
// Render a link with the set_active_class option disabled.
- $url = new Url('test_route_1', array(), array('set_active_class' => FALSE));
+ $url = new Url('test_route_1', [], ['set_active_class' => FALSE]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
$this->assertNoXPathResults('//a[@data-drupal-link-system-path="test-route-1"]', $result);
// Render a link with an associated language.
- $url = new Url('test_route_1', array(), array(
- 'language' => new Language(array('id' => 'de')),
+ $url = new Url('test_route_1', [], [
+ 'language' => new Language(['id' => 'de']),
'set_active_class' => TRUE,
- ));
+ ]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'data-drupal-link-system-path' => 'test-route-1',
'hreflang' => 'de',
- ),
- ), $result);
+ ],
+ ], $result);
// Render a link with a query parameter.
- $url = new Url('test_route_3', array(), array(
- 'query' => array('value' => 'example_1'),
+ $url = new Url('test_route_3', [], [
+ 'query' => ['value' => 'example_1'],
'set_active_class' => TRUE,
- ));
+ ]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'data-drupal-link-system-path' => 'test-route-3',
'data-drupal-link-query' => '{"value":"example_1"}',
- ),
- ), $result);
+ ],
+ ], $result);
// Render a link with route parameters and a query parameter.
- $url = new Url('test_route_4', array('object' => '1'), array(
- 'query' => array('value' => 'example_1'),
+ $url = new Url('test_route_4', ['object' => '1'], [
+ 'query' => ['value' => 'example_1'],
'set_active_class' => TRUE,
- ));
+ ]);
$url->setUrlGenerator($this->urlGenerator);
$result = $this->linkGenerator->generate('Test', $url);
- $this->assertLink(array(
- 'attributes' => array(
+ $this->assertLink([
+ 'attributes' => [
'data-drupal-link-system-path' => 'test-route-4/1',
'data-drupal-link-query' => '{"value":"example_1"}',
- ),
- ), $result);
+ ],
+ ], $result);
}
/**
@@ -570,13 +570,13 @@ class LinkGeneratorTest extends UnitTestCase {
*/
public static function assertLink(array $properties, MarkupInterface $html, $count = 1) {
// Provide default values.
- $properties += array('attributes' => array());
+ $properties += ['attributes' => []];
// Create an XPath query that selects a link element.
$query = '//a';
// Append XPath predicates for the attributes and content text.
- $predicates = array();
+ $predicates = [];
foreach ($properties['attributes'] as $attribute => $value) {
$predicates[] = "@$attribute='$value'";
}
diff --git a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php
index 04a2b8f623d..91620e61559 100644
--- a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php
@@ -104,13 +104,13 @@ class TokenTest extends UnitTestCase {
* @covers ::getInfo
*/
public function testGetInfo() {
- $token_info = array(
- 'types' => array(
- 'foo' => array(
+ $token_info = [
+ 'types' => [
+ 'foo' => [
'name' => $this->randomMachineName(),
- ),
- ),
- );
+ ],
+ ],
+ ];
$this->language->expects($this->atLeastOnce())
->method('getId')
diff --git a/core/tests/Drupal/Tests/RandomGeneratorTrait.php b/core/tests/Drupal/Tests/RandomGeneratorTrait.php
index 4fdd89a88db..3cac5d2932e 100644
--- a/core/tests/Drupal/Tests/RandomGeneratorTrait.php
+++ b/core/tests/Drupal/Tests/RandomGeneratorTrait.php
@@ -36,7 +36,7 @@ trait RandomGeneratorTrait {
*/
public function randomString($length = 8) {
if ($length < 4) {
- return $this->getRandomGenerator()->string($length, TRUE, array($this, 'randomStringValidate'));
+ return $this->getRandomGenerator()->string($length, TRUE, [$this, 'randomStringValidate']);
}
// To prevent the introduction of random test failures, ensure that the
@@ -45,7 +45,7 @@ trait RandomGeneratorTrait {
$replacement_pos = floor($length / 2);
// Remove 2 from the length to account for the ampersand and greater than
// characters.
- $string = $this->getRandomGenerator()->string($length - 2, TRUE, array($this, 'randomStringValidate'));
+ $string = $this->getRandomGenerator()->string($length - 2, TRUE, [$this, 'randomStringValidate']);
return substr_replace($string, '>&', $replacement_pos, 0);
}
diff --git a/core/tests/Drupal/Tests/SchemaCheckTestTrait.php b/core/tests/Drupal/Tests/SchemaCheckTestTrait.php
index 7c16df3f204..0d4dd4bd57b 100644
--- a/core/tests/Drupal/Tests/SchemaCheckTestTrait.php
+++ b/core/tests/Drupal/Tests/SchemaCheckTestTrait.php
@@ -28,19 +28,19 @@ trait SchemaCheckTestTrait {
if ($errors === FALSE) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
- $this->fail(SafeMarkup::format('No schema for @config_name', array('@config_name' => $config_name)));
+ $this->fail(SafeMarkup::format('No schema for @config_name', ['@config_name' => $config_name]));
return;
}
elseif ($errors === TRUE) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
- $this->pass(SafeMarkup::format('Schema found for @config_name and values comply with schema.', array('@config_name' => $config_name)));
+ $this->pass(SafeMarkup::format('Schema found for @config_name and values comply with schema.', ['@config_name' => $config_name]));
}
else {
foreach ($errors as $key => $error) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
- $this->fail(SafeMarkup::format('Schema key @key failed with: @error', array('@key' => $key, '@error' => $error)));
+ $this->fail(SafeMarkup::format('Schema key @key failed with: @error', ['@key' => $key, '@error' => $error]));
}
}
}
diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php
index 0a3b41a7b53..f96b5109e83 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -104,18 +104,18 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
* @return \PHPUnit_Framework_MockObject_MockBuilder
* A MockBuilder object for the ConfigFactory with the desired return values.
*/
- public function getConfigFactoryStub(array $configs = array()) {
- $config_get_map = array();
- $config_editable_map = array();
+ public function getConfigFactoryStub(array $configs = []) {
+ $config_get_map = [];
+ $config_editable_map = [];
// Construct the desired configuration object stubs, each with its own
// desired return map.
foreach ($configs as $config_name => $config_values) {
- $map = array();
+ $map = [];
foreach ($config_values as $key => $value) {
- $map[] = array($key, $value);
+ $map[] = [$key, $value];
}
// Also allow to pass in no argument.
- $map[] = array('', $config_values);
+ $map[] = ['', $config_values];
$immutable_config_object = $this->getMockBuilder('Drupal\Core\Config\ImmutableConfig')
->disableOriginalConstructor()
@@ -123,7 +123,7 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
$immutable_config_object->expects($this->any())
->method('get')
->will($this->returnValueMap($map));
- $config_get_map[] = array($config_name, $immutable_config_object);
+ $config_get_map[] = [$config_name, $immutable_config_object];
$mutable_config_object = $this->getMockBuilder('Drupal\Core\Config\Config')
->disableOriginalConstructor()
@@ -131,7 +131,7 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
$mutable_config_object->expects($this->any())
->method('get')
->will($this->returnValueMap($map));
- $config_editable_map[] = array($config_name, $mutable_config_object);
+ $config_editable_map[] = [$config_name, $mutable_config_object];
}
// Construct a config factory with the array of configuration object stubs
// as its return map.
@@ -207,7 +207,7 @@ abstract class UnitTestCase extends \PHPUnit_Framework_TestCase {
$translation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
$translation->expects($this->any())
->method('translate')
- ->willReturnCallback(function ($string, array $args = array(), array $options = array()) use ($translation) {
+ ->willReturnCallback(function ($string, array $args = [], array $options = []) use ($translation) {
return new TranslatableMarkup($string, $args, $options, $translation);
});
$translation->expects($this->any())
diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php
index 55ba465ddad..ea425178188 100644
--- a/core/tests/Drupal/Tests/WebAssert.php
+++ b/core/tests/Drupal/Tests/WebAssert.php
@@ -113,10 +113,10 @@ class WebAssert extends MinkWebAssert {
*/
public function selectExists($select, TraversableElement $container = NULL) {
$container = $container ?: $this->session->getPage();
- $node = $container->find('named', array(
+ $node = $container->find('named', [
'select',
$this->session->getSelectorsHandler()->xpathLiteral($select),
- ));
+ ]);
if ($node === NULL) {
throw new ElementNotFoundException($this->session, 'select', 'id|name|label|value', $select);
@@ -143,16 +143,16 @@ class WebAssert extends MinkWebAssert {
*/
public function optionExists($select, $option, TraversableElement $container = NULL) {
$container = $container ?: $this->session->getPage();
- $select_field = $container->find('named', array(
+ $select_field = $container->find('named', [
'select',
$this->session->getSelectorsHandler()->xpathLiteral($select),
- ));
+ ]);
if ($select_field === NULL) {
throw new ElementNotFoundException($this->session, 'select', 'id|name|label|value', $select);
}
- $option_field = $select_field->find('named', array('option', $option));
+ $option_field = $select_field->find('named', ['option', $option]);
if ($option_field === NULL) {
throw new ElementNotFoundException($this->session, 'select', 'id|name|label|value', $option);
@@ -176,16 +176,16 @@ class WebAssert extends MinkWebAssert {
*/
public function optionNotExists($select, $option, TraversableElement $container = NULL) {
$container = $container ?: $this->session->getPage();
- $select_field = $container->find('named', array(
+ $select_field = $container->find('named', [
'select',
$this->session->getSelectorsHandler()->xpathLiteral($select),
- ));
+ ]);
if ($select_field === NULL) {
throw new ElementNotFoundException($this->session, 'select', 'id|name|label|value', $select);
}
- $option_field = $select_field->find('named', array('option', $option));
+ $option_field = $select_field->find('named', ['option', $option]);
$this->assert($option_field === NULL, sprintf('An option "%s" exists in select "%s", but it should not.', $option, $select));
}
@@ -316,7 +316,7 @@ class WebAssert extends MinkWebAssert {
* @return string
* An XPath query with arguments replaced.
*/
- public function buildXPathQuery($xpath, array $args = array()) {
+ public function buildXPathQuery($xpath, array $args = []) {
// Replace placeholders.
foreach ($args as $placeholder => $value) {
if (is_object($value)) {
diff --git a/core/tests/TestSuites/TestSuiteBase.php b/core/tests/TestSuites/TestSuiteBase.php
index bd047e83c4d..581ea36714e 100644
--- a/core/tests/TestSuites/TestSuiteBase.php
+++ b/core/tests/TestSuites/TestSuiteBase.php
@@ -23,7 +23,7 @@ abstract class TestSuiteBase extends \PHPUnit_Framework_TestSuite {
$extension_roots = \drupal_phpunit_contrib_extension_directory_roots($root);
$extension_directories = array_map('drupal_phpunit_find_extension_directories', $extension_roots);
- return array_reduce($extension_directories, 'array_merge', array());
+ return array_reduce($extension_directories, 'array_merge', []);
}
/**
diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php
index a2b4921a452..f78b69ff049 100644
--- a/core/tests/bootstrap.php
+++ b/core/tests/bootstrap.php
@@ -19,7 +19,7 @@ use Drupal\Component\Assertion\Handle;
* directory, keyed by extension name.
*/
function drupal_phpunit_find_extension_directories($scan_directory) {
- $extensions = array();
+ $extensions = [];
$dirs = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($scan_directory, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
foreach ($dirs as $dir) {
if (strpos($dir->getPathname(), '.info.yml') !== FALSE) {
@@ -46,13 +46,13 @@ function drupal_phpunit_contrib_extension_directory_roots($root = NULL) {
if ($root === NULL) {
$root = dirname(dirname(__DIR__));
}
- $paths = array(
+ $paths = [
$root . '/core/modules',
$root . '/core/profiles',
$root . '/modules',
$root . '/profiles',
$root . '/themes',
- );
+ ];
$sites_path = $root . '/sites';
// Note this also checks sites/../modules and sites/../profiles.
foreach (scandir($sites_path) as $site) {
@@ -78,7 +78,7 @@ function drupal_phpunit_contrib_extension_directory_roots($root = NULL) {
*/
function drupal_phpunit_get_extension_namespaces($dirs) {
$suite_names = ['Unit', 'Kernel', 'Functional', 'FunctionalJavascript'];
- $namespaces = array();
+ $namespaces = [];
foreach ($dirs as $extension => $dir) {
if (is_dir($dir . '/src')) {
// Register the PSR-4 directory for module-provided classes.
@@ -136,7 +136,7 @@ function drupal_phpunit_populate_class_loader() {
$extension_roots = drupal_phpunit_contrib_extension_directory_roots();
$dirs = array_map('drupal_phpunit_find_extension_directories', $extension_roots);
- $dirs = array_reduce($dirs, 'array_merge', array());
+ $dirs = array_reduce($dirs, 'array_merge', []);
$GLOBALS['namespaces'] = drupal_phpunit_get_extension_namespaces($dirs);
}
foreach ($GLOBALS['namespaces'] as $prefix => $paths) {
diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme
index b1b3308260a..1c408cf3cc5 100644
--- a/core/themes/bartik/bartik.theme
+++ b/core/themes/bartik/bartik.theme
@@ -45,14 +45,14 @@ function bartik_preprocess_page_title(&$variables) {
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
// Add a wrapper div using the title_prefix and title_suffix render
// elements.
- $variables['title_prefix']['shortcut_wrapper'] = array(
+ $variables['title_prefix']['shortcut_wrapper'] = [
'#markup' => '<div class="shortcut-wrapper clearfix">',
'#weight' => 100,
- );
- $variables['title_suffix']['shortcut_wrapper'] = array(
+ ];
+ $variables['title_suffix']['shortcut_wrapper'] = [
'#markup' => '</div>',
'#weight' => -99,
- );
+ ];
// Make sure the shortcut link is the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
diff --git a/core/themes/bartik/color/color.inc b/core/themes/bartik/color/color.inc
index 4f42620d9c8..55464f2403d 100644
--- a/core/themes/bartik/color/color.inc
+++ b/core/themes/bartik/color/color.inc
@@ -5,9 +5,9 @@
* Lists available colors and color schemes for the Bartik theme.
*/
-$info = array(
+$info = [
// Available colors and color labels used in theme.
- 'fields' => array(
+ 'fields' => [
'top' => t('Header background top'),
'bottom' => t('Header background bottom'),
'bg' => t('Main background'),
@@ -17,12 +17,12 @@ $info = array(
'titleslogan' => t('Title and slogan'),
'text' => t('Text color'),
'link' => t('Link color'),
- ),
+ ],
// Pre-defined color schemes.
- 'schemes' => array(
- 'default' => array(
+ 'schemes' => [
+ 'default' => [
'title' => t('Blue Lagoon (default)'),
- 'colors' => array(
+ 'colors' => [
'top' => '#055a8e',
'bottom' => '#1d84c3',
'bg' => '#ffffff',
@@ -32,11 +32,11 @@ $info = array(
'titleslogan' => '#fffeff',
'text' => '#3b3b3b',
'link' => '#0071B3',
- ),
- ),
- 'firehouse' => array(
+ ],
+ ],
+ 'firehouse' => [
'title' => t('Firehouse'),
- 'colors' => array(
+ 'colors' => [
'top' => '#cd2d2d',
'bottom' => '#d64e4e',
'bg' => '#ffffff',
@@ -46,11 +46,11 @@ $info = array(
'titleslogan' => '#fffeff',
'text' => '#888888',
'link' => '#d6121f',
- ),
- ),
- 'ice' => array(
+ ],
+ ],
+ 'ice' => [
'title' => t('Ice'),
- 'colors' => array(
+ 'colors' => [
'top' => '#d0d0d0',
'bottom' => '#c2c4c5',
'bg' => '#ffffff',
@@ -60,11 +60,11 @@ $info = array(
'titleslogan' => '#000000',
'text' => '#4a4a4a',
'link' => '#019dbf',
- ),
- ),
- 'plum' => array(
+ ],
+ ],
+ 'plum' => [
'title' => t('Plum'),
- 'colors' => array(
+ 'colors' => [
'top' => '#4c1c58',
'bottom' => '#593662',
'bg' => '#fffdf7',
@@ -74,11 +74,11 @@ $info = array(
'titleslogan' => '#ffffff',
'text' => '#301313',
'link' => '#9d408d',
- ),
- ),
- 'slate' => array(
+ ],
+ ],
+ 'slate' => [
'title' => t('Slate'),
- 'colors' => array(
+ 'colors' => [
'top' => '#4a4a4a',
'bottom' => '#4e4e4e',
'bg' => '#ffffff',
@@ -88,31 +88,31 @@ $info = array(
'titleslogan' => '#ffffff',
'text' => '#3b3b3b',
'link' => '#0073b6',
- ),
- ),
- ),
+ ],
+ ],
+ ],
// CSS files (excluding @import) to rewrite with new color scheme.
- 'css' => array(
+ 'css' => [
'css/colors.css',
- ),
+ ],
// Files to copy.
- 'copy' => array(
+ 'copy' => [
'logo.svg',
- ),
+ ],
// Gradient definitions.
- 'gradients' => array(
- array(
+ 'gradients' => [
+ [
// (x, y, width, height).
- 'dimension' => array(0, 0, 0, 0),
+ 'dimension' => [0, 0, 0, 0],
// Direction of gradient ('vertical' or 'horizontal').
'direction' => 'vertical',
// Keys of colors to use for the gradient.
- 'colors' => array('top', 'bottom'),
- ),
- ),
+ 'colors' => ['top', 'bottom'],
+ ],
+ ],
// Preview files.
'preview_library' => 'bartik/color.preview',
@@ -127,4 +127,4 @@ $info = array(
],
],
],
-);
+];
diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine
index c8f8f491d25..791f9083b89 100644
--- a/core/themes/engines/twig/twig.engine
+++ b/core/themes/engines/twig/twig.engine
@@ -13,7 +13,7 @@ use Drupal\Core\Extension\Extension;
* Implements hook_theme().
*/
function twig_theme($existing, $type, $theme, $path) {
- $templates = drupal_find_theme_functions($existing, array($theme));
+ $templates = drupal_find_theme_functions($existing, [$theme]);
$templates += drupal_find_theme_templates($existing, '.html.twig', $path);
return $templates;
}
diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme
index 64ee72440df..91c03e631fe 100644
--- a/core/themes/seven/seven.theme
+++ b/core/themes/seven/seven.theme
@@ -31,18 +31,18 @@ function seven_preprocess_html(&$variables) {
*/
function seven_preprocess_menu_local_tasks(&$variables) {
if (!empty($variables['primary'])) {
- $variables['primary']['#attached'] = array(
- 'library' => array(
+ $variables['primary']['#attached'] = [
+ 'library' => [
'seven/drupal.nav-tabs',
- ),
- );
+ ],
+ ];
}
elseif (!empty($variables['secondary'])) {
- $variables['secondary']['#attached'] = array(
- 'library' => array(
+ $variables['secondary']['#attached'] = [
+ 'library' => [
'seven/drupal.nav-tabs',
- ),
- );
+ ],
+ ];
}
}
@@ -61,7 +61,7 @@ function seven_preprocess_node_add_list(&$variables) {
/** @var \Drupal\node\NodeTypeInterface $type */
foreach ($variables['content'] as $type) {
$variables['types'][$type->id()]['label'] = $type->label();
- $variables['types'][$type->id()]['url'] = \Drupal::url('node.add', array('node_type' => $type->id()));
+ $variables['types'][$type->id()]['url'] = \Drupal::url('node.add', ['node_type' => $type->id()]);
}
}
}
@@ -76,8 +76,8 @@ function seven_preprocess_block_content_add_list(&$variables) {
if (!empty($variables['content'])) {
foreach ($variables['content'] as $type) {
$variables['types'][$type->id()]['label'] = $type->label();
- $options = array('query' => \Drupal::request()->query->all());
- $variables['types'][$type->id()]['url'] = \Drupal::url('block_content.add_form', array('block_content_type' => $type->id()), $options);
+ $options = ['query' => \Drupal::request()->query->all()];
+ $variables['types'][$type->id()]['url'] = \Drupal::url('block_content.add_form', ['block_content_type' => $type->id()], $options);
}
}
}
@@ -153,36 +153,36 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\node\NodeInterface $node */
$node = $form_state->getFormObject()->getEntity();
- $form['#theme'] = array('node_edit_form');
+ $form['#theme'] = ['node_edit_form'];
$form['#attached']['library'][] = 'seven/node-form';
$form['advanced']['#type'] = 'container';
$is_new = !$node->isNew() ? format_date($node->getChangedTime(), 'short') : t('Not saved yet');
- $form['meta'] = array(
- '#attributes' => array('class' => array('entity-meta__header')),
+ $form['meta'] = [
+ '#attributes' => ['class' => ['entity-meta__header']],
'#type' => 'container',
'#group' => 'advanced',
'#weight' => -100,
- 'published' => array(
+ 'published' => [
'#type' => 'html_tag',
'#tag' => 'h3',
'#value' => $node->isPublished() ? t('Published') : t('Not published'),
'#access' => !$node->isNew(),
- '#attributes' => array(
+ '#attributes' => [
'class' => ['entity-meta__title'],
- ),
- ),
- 'changed' => array(
+ ],
+ ],
+ 'changed' => [
'#type' => 'item',
- '#wrapper_attributes' => array('class' => array('entity-meta__last-saved', 'container-inline')),
+ '#wrapper_attributes' => ['class' => ['entity-meta__last-saved', 'container-inline']],
'#markup' => '<h4 class="label inline">' . t('Last saved') . '</h4> ' . $is_new,
- ),
- 'author' => array(
+ ],
+ 'author' => [
'#type' => 'item',
- '#wrapper_attributes' => array('class' => array('author', 'container-inline')),
+ '#wrapper_attributes' => ['class' => ['author', 'container-inline']],
'#markup' => '<h4 class="label inline">' . t('Author') . '</h4> ' . $node->getOwner()->getUsername(),
- ),
- );
+ ],
+ ];
$form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta';
}